|
hayskswx
|
 |
« on: April 28, 2012, 02:17:27 PM » |
|
Anyone one have the script and wouldn't mine sharing?
|
|
|
|
|
Logged
|
|
|
|
|
hayskswx
|
 |
« Reply #1 on: April 28, 2012, 04:54:31 PM » |
|
I found search his site but couldn't find it either.I will use that one until I find the united states one. If anyone has it would u mind sharing. I want to put it on the fly. Thanks Ryan
|
|
|
|
|
Logged
|
|
|
|
|
CNYWeather
|
 |
« Reply #2 on: April 28, 2012, 07:13:16 PM » |
|
<?php ############################################################################ # # Project: USA Extremes # Module: usaextremes.php # Purpose: Provides USA Extremes for Web page display # Authors: Michael (michael@relayweather.com) ############################################################################ # Usage: Place the following on your webpage # CHMOD 666 for cacheFile2.php # include_once('usaextremes.php'); # # Then call the following tags within the page where you would like them displayed: # $usahigh # $usalow # $usaprecip ############################################################################ // version $usaextremesverion = "2.0"; echo "<!-- USA Extremes Script Version $usaextremesverion. -->\n"; ///////////////////////////////////////////////////////////////////////////// //SETTINGS START HERE//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Site to Parse $url2 = "http://www.accuweather.com/news.asp"; // Set the time zone $ourTZ = 'America/New_York'; // Name of cache file -- This file must be set to CHMOD-666 $cacheFile2 = "usaextremesCache.php"; // Age of cache file before re-fetch caching time, in seconds (3600 = 1 hour) $cache_life = '3600'; ///////////////////////////////////////////////////////////////////////////// //END SETTINGS/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// if (file_exists($cacheFile2)) { $filemtime = filemtime($cacheFile2); $filesize = filesize($cacheFile2); if (0 == $filesize){ $filemtime = 0; } } else { $filemtime = 0; } // open the cache file and write the new data and then close the file. $current_time = time(); $cache_age = $current_time - $filemtime; if ($cache_age >= $cache_life){ $html2 = implode(' ', file($url2)); $fp2 = fopen($cacheFile2, 'w'); fwrite($fp2, $html2); fclose($fp2); echo "<!-- The cache life HAS expired and fresh data re-wrote the cache file -->\n"; } else { echo "<!-- The cache life HAS NOT expired and fresh data was not written to the cache file -->\n"; // Open the cache file, read it, then close it $handle2 = fopen($cacheFile2, "r"); $filesize = filesize($cacheFile2); $html2 = fread($handle2, $filesize); fclose($handle2); }
//Finds USA High preg_match_all('|<th scope="row">High</th>(.*)<tr class="lo">|Uis', $html2, $high);
//Finds USA Low preg_match_all('|<th scope="row">Low</th>(.*)<tr class="last pre">|Uis', $html2, $low);
//Finds USA High Precip preg_match_all('|<th scope="row">Precip</th>(.*)</tr>|Uis', $html2, $precip);
$high[1][0]= preg_replace('|<td>|', '', $high[1][0]); $high[1][0]= preg_replace('|</td>|', '', $high[1][0]); $high[1][0]= preg_replace('|</tr>|', '', $high[1][0]); $high[1][0]= preg_replace('|</td>|', '', $high[1][0]); $usahigh = $high[1][0];
$low[1][0]= preg_replace('|<td>|', '', $low[1][0]); $low[1][0]= preg_replace('|</td>|', '', $low[1][0]); $low[1][0]= preg_replace('|</tr>|', '', $low[1][0]); $low[1][0]= preg_replace('|</td>|', '', $low[1][0]); $usalow = $low[1][0];
$precip[1][0]= preg_replace('|<td>|', '', $precip[1][0]); $precip[1][0]= preg_replace('|</td>|', '', $precip[1][0]); $precip[1][0]= preg_replace('|</tr>|', '', $precip[1][0]); $precip[1][0]= preg_replace('|</td>|', '', $precip[1][0]); $usaprecip = $precip[1][0];
?> <!-- <?php print '$filemtime = '.$filemtime.'<br />$cache_age = '.$cache_age.' seconds.'; ?><br /><br />--> <?php echo "<!-- Cache refresh rate = $cache_life seconds. Cache age = $cache_age seconds. -->\n"; ?>
Not sure if you need to create or if the scrip creates the usaextremesCache.php cache file for you Tony
|
|
|
|
|
Logged
|
|
|
|
|
hayskswx
|
 |
« Reply #3 on: April 28, 2012, 09:16:50 PM » |
|
Thanks Tony. Ryan
|
|
|
|
|
Logged
|
|
|
|
|
k8jsl
|
 |
« Reply #4 on: April 28, 2012, 11:54:23 PM » |
|
if you put the extremes on your website your in violation of Accuweather's TOS 5. Permitted Uses.Subscriber may download, view, copy and print Products incorporated in or accessed through this Site subject to the following: (1) the Products may be used solely for personal, informational, internal purposes and may not be re-distributed without the express written permission of AccuWeather; By placing it on a website ... your redistributing it
|
|
|
|
|
Logged
|
|
|
|
|
DaculaWeather
|
 |
« Reply #5 on: April 29, 2012, 09:25:20 AM » |
|
I've taken one of Ken's scripts and modified it to capture the highs/lows from the HPC, but ironically, they don't have precip as one of their values. Since I can only hack php, I have no way of exploding the various pieces into something that could actually be formatted, so I simply formatted the <pre> tag in the script so that it would fit on the right hand side of one of my pages. I'm sure someone here could easily modify the script to allow for some more creative formatting. My test sample is at the bottom of this page on the right. http://www.daculaweather.com/4_spc_storm_reports.phpPlus this one is ok to put on your website!
|
|
|
|
|
Logged
|
Steve Davis Vue, VWS, WDisplay, VVP, StartWatch CWOP  
|
|
|
|
hayskswx
|
 |
« Reply #6 on: April 29, 2012, 03:12:46 PM » |
|
I installed it. Does it take 24 hours for it to work because it's not displaying data. It is on the flyout menu. You can see it here www.hayskansasweather.com
|
|
|
|
|
Logged
|
|
|
|
|
wxman1952
|
 |
« Reply #7 on: April 30, 2012, 08:00:08 PM » |
|
I'd like to use that script too, but my website doesn't work with php. Anyone know a iframe or html for the same extreme data?
|
|
|
|
|
Logged
|
|
|
|
|
Silversword
|
 |
« Reply #8 on: July 05, 2012, 01:04:23 PM » |
|
Hi All,
Something is amiss with this script for me. It has worked for me since I installed it a couple of years ago now when I checked my site the data was gone for the past weeks . I uploaded a file from another person last night and it gave me some data and this morning I got the same data as yesterday and not the updated data comparing it with other sites
I don't know what is causing it not to write to the usaextremesCache.php properly. The CHMOD is set to 666. When I checked this file this morning it was empty so no data was present in the menu bar.
Hope someone can shed some light as to what happened..
Thanks for any solutions.
--Stan Y. Maui, Hawaii
|
|
|
|
|
Logged
|
WD 10.37r Bld 56 WDL 6.05  MS Windows XP Pro-SP3 Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM Davis Vantage Pro 2 Wireless + 1-Wire Solar + 1-Wire UV + 1-Wire Lighting Webcam:Panasonic BL-C1A
|
|
|
|
Bunty
|
 |
« Reply #9 on: July 05, 2012, 05:54:20 PM » |
|
if you put the extremes on your website your in violation of Accuweather's TOS 5. Permitted Uses.Subscriber may download, view, copy and print Products incorporated in or accessed through this Site subject to the following: (1) the Products may be used solely for personal, informational, internal purposes and may not be re-distributed without the express written permission of AccuWeather; By placing it on a website ... your redistributing it Has anyone actually tried asking for permission?
|
|
|
|
|
Logged
|
|
|
|
|
DaculaWeather
|
 |
« Reply #10 on: July 06, 2012, 09:10:01 AM » |
|
That would be too easy.
|
|
|
|
|
Logged
|
Steve Davis Vue, VWS, WDisplay, VVP, StartWatch CWOP  
|
|
|
|
Silversword
|
 |
« Reply #11 on: July 06, 2012, 02:08:18 PM » |
|
Hi,
Finally got it to work. Thanks to Ken for finding a solution.
--Stan Y. Maui, Hawaii
|
|
|
|
|
Logged
|
WD 10.37r Bld 56 WDL 6.05  MS Windows XP Pro-SP3 Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM Davis Vantage Pro 2 Wireless + 1-Wire Solar + 1-Wire UV + 1-Wire Lighting Webcam:Panasonic BL-C1A
|
|
|
|
ed2kayak
|
 |
« Reply #12 on: October 07, 2012, 08:42:30 AM » |
|
Having a bit of problem with this version, getting the following error. http://cvweather.org/usaextremes.phpWarning: fopen(usaextremesCache.php) [function.fopen]: failed to open stream: Permission denied in /virtual/users/e16840-18278/web/usaextremes.php on line 56 Warning: fwrite(): supplied argument is not a valid stream resource in /virtual/users/e16840-18278/web/usaextremes.php on line 57 Warning: fclose(): supplied argument is not a valid stream resource in /virtual/users/e16840-18278/web/usaextremes.php on line 58
|
|
|
|
|
Logged
|
Ed CoCoRaHS PA-CD-6, Weather Underground KPAMECHA7, CWOP DW5425 
|
|
|
|
Silversword
|
 |
« Reply #13 on: October 07, 2012, 08:35:21 PM » |
|
Hi ed2kayak,
In the attached script change it to your time zone and save it as a php file. Then check to see if you followed the following directions as written in Kens notes within this script especially the last note:
Usage: Place the following on your webpage CHMOD 666 for cacheFile2.php include_once('usaextremes.php'); Then call the following tags within the page where you would like them displayed: $usahigh $usalow $usaprecip
Note: allow_url_fopen = on in your php.ini is required to run this script.
Hope that this helps.
--Stan Y. Maui, Hawaii
|
|
|
|
|
Logged
|
WD 10.37r Bld 56 WDL 6.05  MS Windows XP Pro-SP3 Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM Davis Vantage Pro 2 Wireless + 1-Wire Solar + 1-Wire UV + 1-Wire Lighting Webcam:Panasonic BL-C1A
|
|
|
|
ed2kayak
|
 |
« Reply #14 on: October 07, 2012, 08:52:49 PM » |
|
Thanks Stan,
Reread instructions was missing this, $cacheFile2 = "usaextremesCache.php";
ok next question, how do I place in menubar
|
|
|
|
« Last Edit: October 07, 2012, 09:01:49 PM by ed2kayak »
|
Logged
|
Ed CoCoRaHS PA-CD-6, Weather Underground KPAMECHA7, CWOP DW5425 
|
|
|
|
Silversword
|
 |
« Reply #15 on: October 07, 2012, 09:59:43 PM » |
|
Thanks Stan,
Reread instructions was missing this, $cacheFile2 = "usaextremesCache.php";
ok next question, how do I place in menubar
Hi, Looks like you already have it on your menu bar already. --Stan Y. Maui, Hawaii
|
|
|
|
|
Logged
|
WD 10.37r Bld 56 WDL 6.05  MS Windows XP Pro-SP3 Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM Davis Vantage Pro 2 Wireless + 1-Wire Solar + 1-Wire UV + 1-Wire Lighting Webcam:Panasonic BL-C1A
|
|
|
|
ed2kayak
|
 |
« Reply #16 on: October 08, 2012, 07:39:23 AM » |
|
Looks like you already have it on your menu bar already.
--Stan Y. Maui, Hawaii
That is a RelayWeather script worldextremesGadget.php on my menubar. I think a read a post about three different versions of this script? Maybe three different sources. Not sure.
|
|
|
|
|
Logged
|
Ed CoCoRaHS PA-CD-6, Weather Underground KPAMECHA7, CWOP DW5425 
|
|
|
|
Silversword
|
 |
« Reply #17 on: October 08, 2012, 01:04:46 PM » |
|
Hi ed2kayak,
Here is what I am using on my menubar.php file for USA Extremes display:
<p class="sideBarTitle">USA Extremes</p> <br /> <table align="center" cellspacing="0" cellpadding="0" border="0" width="100"> <tr> <td align="center"><span style="font-size: 65%; color: black;">Past 24 hours</span></td> </tr> <tr> <td align="center"> </td> </tr> <tr> <td align="center"><span style="font-size: 90%; font-weight:bold; color: red;">High Temp</span></td> </tr> <tr> <td align="center"><span style="font-size: 80%; color: black;"><?php print $usahigh; ?></span></td> </tr> <tr> <td align="center"> </td> </tr> <tr> <td align="center"><span style="font-size: 90%; font-weight:bold; color: blue;">Low Temp</span></td> </tr> <tr> <td align="center"><span style="font-size: 80%; color: black;"><?php print $usalow; ?></span></td> </tr> <tr> <td align="center"> </td> </tr> <tr> <td align="center"><span style="font-size: 90%; font-weight:bold; color: green;">Precipitation</span></td> </tr> <tr> <td align="center"><span style="font-size: 80%; color: black;"><?php print $usaprecip; ?></span></td> </tr> </table> <br /> <br />
Hope that this helps a bit.
--Stan Y. Maui, Hawaii
|
|
|
|
|
Logged
|
WD 10.37r Bld 56 WDL 6.05  MS Windows XP Pro-SP3 Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM Davis Vantage Pro 2 Wireless + 1-Wire Solar + 1-Wire UV + 1-Wire Lighting Webcam:Panasonic BL-C1A
|
|
|
|
gwwilk
|
 |
« Reply #18 on: October 08, 2012, 06:16:17 PM » |
|
Thanks, Stan! I've taken the liberty of modifying your code to allow for CSS style switching. <div class="thisPage" style="font-weight:lighter"> <table align="center" cellspacing="0" cellpadding="0" border="0" width="100"> <tr><td align="center"><span style="font-size: 65%">Past 24 hours</span></td></tr> <tr><td align="center"> </td></tr> <tr><td align="center"><span style="font-size: 90%; font-weight:bold; color: red;">High Temp</span></td></tr> <tr><td align="center"><span style="font-size: 80%"><?php print $usahigh; ?></span></td></tr> <tr><td align="center"> </td></tr> <tr><td align="center"><span style="font-size: 90%; font-weight:bold; color: blue;">Low Temp</span></td></tr> <tr><td align="center"><span style="font-size: 80%"><?php print $usalow; ?></span></td></tr> <tr><td align="center"> </td></tr> <tr><td align="center"><span style="font-size: 90%; font-weight:bold; color: green;">Precipitation</span></td></tr> <tr><td align="center"><span style="font-size: 80%"><?php print $usaprecip; ?></span></td></tr> </table> </div>
It's a bit scrunched up on my site, but my menubar is overlong as it is.
|
|
|
|
« Last Edit: October 08, 2012, 06:26:28 PM by gwwilk »
|
Logged
|
|
|
|
|
ed2kayak
|
 |
« Reply #19 on: October 08, 2012, 09:20:20 PM » |
|
Thanks, Stan! Jerry clicked on your link on left and got: http://www.gwwilk.com/I see the banner links to another site. I was confused at first. LOL
|
|
|
|
|
Logged
|
Ed CoCoRaHS PA-CD-6, Weather Underground KPAMECHA7, CWOP DW5425 
|
|
|
|
gwwilk
|
 |
« Reply #20 on: October 08, 2012, 10:41:32 PM » |
|
Thanks, Stan! Jerry clicked on your link on left and got: http://www.gwwilk.com/I see the banner links to another site. I was confused at first. LOL Thanks for the heads up.  I never got around to changing the url after putting up my new site a few years ago. The old site's still there. Link now fixed.
|
|
|
|
|
Logged
|
|
|
|
|