WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: tmabell on October 31, 2017, 10:07:10 AM

Title: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 10:07:10 AM
Within the past few weeks Curly's WxStory script is not working for at least one local office.  For site KIWX Northern Indiana the text is being retreived but the image is not. It still seems to work for the other sites I checked. 

http://ww2.mymishawakaweather.com/wxstory_inc.php (http://ww2.mymishawakaweather.com/wxstory_inc.php)

The cache file:

Code: [Select]
<?php

$mainStory 
= array (
  
'Tab2FileL.png?150944' => 
  array (
    
=> 'One More Cold Day',
    
=> 'The cloudy and cold weather will linger for 1 more day with a few showers near Lake Michigan. Warmer temperatures will arrive starting Wednesday, with above normal temperatures by Thursday and Friday. The warmer temperatures will bring increasing chances for showers, especially Thursday and Thursday night.',
    
=> 'http://www.weather.gov/images/iwx/wxstory/Tab2FileL.png?1509444443',
    
=> 'https://www.weather.gov/iwx/weatherstory',
    
=> './wscache/wsimg_iwx_Tab2FileL.png?150944.443',
    
=> '443',
    
=> 'Tab2FileL.png?150944',
    
=> 'iwx',
    
=> 'Northern Indiana',
  ),
);

$altStory = array (
  
'Tab3FileL.png?150944' => 
  array (
    
=> 'Halloween Forecast',
    
=> 'Trick or Treat Forecast: Bundle up as you go out later this afternoon and early evening as temperatures will start in the upper 30s to lower 40s at the start of trick or treating and end up in the middle 30s by the end. Wind should be on the lighter side, but will still make it feel like its 30 to 35 degrees.',
    
=> 'http://www.weather.gov/images/iwx/wxstory/Tab3FileL.png?1509444443',
    
=> 'https://www.weather.gov/iwx/weatherstory',
    
=> './wscache/wsimg_iwx_Tab3FileL.png?150944.443',
    
=> '443',
    
=> 'Tab3FileL.png?150944',
    
=> 'iwx',
    
=> 'Northern Indiana',
  ),
);

$nfo 'Northern Indiana';

$hdlnr = array (
  
=> '     <td style="text-align: center; background-color:#F0F7FF; padding: 6px 0px 6px;"><a href="/wxstory_inc.php?i=iwx&amp;ifn=Tab2FileL.png?150944" title="One More Cold Day" style="text-decoration: none; color: #0071BC; font-size: 1.3em;">One More Cold Day</a></td>',
  
=> '     <td style="text-align: center; background-color:#F0F7FF; padding: 6px 0px 6px;"><a href="/wxstory_inc.php?i=iwx&amp;ifn=Tab3FileL.png?150944" title="Halloween Forecast" style="text-decoration: none; color: #0071BC; font-size: 1.3em;">Halloween Forecast</a></td>',
);


?>

Debugging indicates that the image file is not found (404) yet manually entering the link into a browser displays the image just fine.  I am out of ideas!
Title: Re: Curly's Wx Story script
Post by: UpstateWeather.com on October 31, 2017, 10:24:20 AM
Wish I can help, but honestly, this is the first time I've seen this script. And I LOVE it! Can anyone provide the raw files? I can't seem to find a valid download link any more.

Title: Re: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 10:32:09 AM
Eric799... PM sent!
Title: Re: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 11:48:13 AM
For others wishing to have this script it is attached (with Curly's permission).
Title: Re: Curly's Wx Story script
Post by: UpstateWeather.com on October 31, 2017, 12:18:30 PM
Thanks tmabell!
Title: Re: Curly's Wx Story script
Post by: SoMDWx on October 31, 2017, 12:55:17 PM
Love the script, but it won't work at Washington-Baltimore NWS office... :(
Title: Re: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 01:03:36 PM
I don't think any of the Eastern Region WFO's use the Weather Story.  I might be wrong.
Title: Re: Curly's Wx Story script
Post by: 92merc on October 31, 2017, 01:11:49 PM
Is the script supposed to pull the graphics as well?

http://www.bismarckweather.net/wxstory.php

If I go to the first link, I don't see any graphics. But then change the office to Bismarck North Dakota, I can see the graphics.

On my own site, I don't see the graphics no matter what.
Title: Re: Curly's Wx Story script
Post by: 92merc on October 31, 2017, 01:17:51 PM
I looked at the code and realized I needed a wscache folder.  Once I put that there, the images came.

But what is supposed to be in the wsimages folder?  Anything?
Title: Re: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 01:19:05 PM
I am able to see the graphics on your site for the default KBIS office, all three (currently) images are there.
Title: Re: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 01:25:08 PM
I've attached the contents of my wsimages folder.
Title: Re: Curly's Wx Story script
Post by: 92merc on October 31, 2017, 01:28:25 PM
Thanks!
Title: Re: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 02:01:25 PM
I'm not sure but I think those images are used if you enable the map option in the settings of the script.
Title: Re: Curly's Wx Story script
Post by: gwwilk on October 31, 2017, 02:10:30 PM
If Curly has given his permission to release the WxStory script into the wild, I have his May 20, 2017 final release (https://www.gwwilkins.org/wxstory.php) running on my site.  It works!

The zip is attached.  There is an option to use a 'dropdown' list rather than the map, which is fairly current although some sites shown as red or orange may now have the Weather Story.
Title: Re: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 02:33:51 PM
He has and thank you Jerry!!

EDIT:

I'm using V2.25 which works with PHP 7.1 but exibits the KIWX bug.  Sadly, V2.23 doesn't work on my site because of unnessary changes made to PHP 7.1 (which is what I'm using)

If you have time to take a look well, your help wolde be greatly appreciated.. as always!
Title: Re: Curly's Wx Story script
Post by: gwwilk on October 31, 2017, 06:39:51 PM
He has and thank you Jerry!!

EDIT:

I'm using V2.25 which works with PHP 7.1 but exibits the KIWX bug.  Sadly, V2.23 doesn't work on my site because of unnessary changes made to PHP 7.1 (which is what I'm using)

If you have time to take a look well, your help wolde be greatly appreciated.. as always!
Not fond here of these perpetual updates which keep breaking scripts!  PHP 7.0 works just fine here (http://selincolnwx.info/wxstory.php).  My original link is running PHP 5.4!  What doesn't work for me under PHP 7.0 is 'whos-online (http://selincolnwx.info/whos-online-maps.php)'.  If Ken True can't figure that one out, I'm sure it's beyond me.
Title: Re: Curly's Wx Story script
Post by: mldenison on October 31, 2017, 07:15:59 PM
I'm not sure what version of php I'm using.  How do I tell?

I just created a page on my Saratoga website and it's working fine: http://www.m82a1.us/wxStory.php (http://www.m82a1.us/wxStory.php) - unfortunately no nearby weather stories for me.

I wonder why the eastern NWS stations don't have a weather story.
Title: Re: Curly's Wx Story script
Post by: tmabell on October 31, 2017, 07:59:18 PM
The issue is with php 7.1 and up.  I agree which is why I mentioned "unnecessary changes" to PHP 7.  When your version is run on my site with PHP7.1 a fatal error is encounterd:

 [php7:warn] [pid 12300:tid 908] [client 192.168.10.156:63217] PHP Warning:  fopen(./wscache/wsimg_iwx_Tab2FileL.png?150947.193): failed to open stream: Resource temporarily unavailable in C:\\www\\wxStory_inc.php on line 356, referer: https://mymishawakaweather.com/wxstory_inc.php?i=lot
[Tue Oct 31 19:56:48.754078 2017] [php7:warn] [pid 12300:tid 908] [client 192.168.10.156:63217] PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in C:\\www\\wxStory_inc.php on line 357, referer: https://mymishawakaweather.com/wxstory_inc.php?i=lot
[Tue Oct 31 19:56:48.754078 2017] [php7:warn] [pid 12300:tid 908] [client 192.168.10.156:63217] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in C:\\www\\wxStory_inc.php on line 358, referer: https://mymishawakaweather.com/wxstory_inc.php?i=lot
[Tue Oct 31 19:56:48.754078 2017] [php7:error] [pid 12300:tid 908] [client 192.168.10.156:63217] PHP Fatal error:  Uncaught Error: Call to undefined function mb_detect_encoding() in C:\\www\\wxStory_inc.php:371\nStack trace:\n#0 {main}\n  thrown in C:\\www\\wxStory_inc.php on line 371, referer: https://mymishawakaweather.com/wxstory_inc.php?i=lot
Title: Re: Curly's Wx Story script
Post by: ALITTLEweird1 on October 31, 2017, 10:49:18 PM
 The last time i tried this script,  it didn't work for Washington State.
Title: Re: Curly's Wx Story script
Post by: mldenison on October 31, 2017, 10:59:02 PM
I just checked on GoDaddy (my host) and I'm running 7.0.  There's some changes enforcing some php scripting that needs to be looked at for 7.1.  Above my paygrade unfortunately.
Title: Re: Curly's Wx Story script
Post by: Fox_Of_The_Wind on December 13, 2017, 09:06:21 PM
has anyone worked on this script yet? I see mine will not load the image anymore.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 13, 2017, 10:19:49 PM
has anyone worked on this script yet? I see mine will not load the image anymore.

Noticed this as well earlier today but haven't had a chance to dig into it yet.
Title: Re: Curly's Wx Story script
Post by: tmabell on December 14, 2017, 09:16:44 AM
This problem first showed up a few months ago on one or two sites.  Now the whole thing went belly up altogether.  The thing I find odd is that the links used by the script are still good.  Those images can be retrieved using a web browser or even an image caching script.
Title: Re: Curly's Wx Story script
Post by: 92merc on December 14, 2017, 09:26:27 AM
Oh good.  I thought it was just me.  Mine went down about 2 days ago as well.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 14, 2017, 03:44:22 PM
Ok, finally had a few minutes to look at this and it is a simple fix it seems.
In the wxStory-inc.php  script... scroll down not too far and you'll see a group of "preg_replace" like so...
Code: [Select]
$html = preg_replace('//', '&deg;', $html);                                         //  change it to an entity
  $html = preg_replace('//', '\'', $html);                                            //  change stray character
  $html = preg_replace('/<u>/', '', $html);                                            //  fix error
  $html = preg_replace('/<\/u>/', '', $html);                                          //  fix error
  $html = preg_replace('/<br>/', '<br />', $html);                                     //  fix error
 

Add these to that group...
Code: [Select]
$html = preg_replace("/\.png\?(.+?)/" , ".png " , $html);               // cut off random numbering of png
$html = preg_replace("/\.jpg\?(.+?)/" , ".jpg " , $html);               // cut off random numbering of jpg

and it should fix it. At least it did for me.
Title: Re: Curly's Wx Story script
Post by: 92merc on December 14, 2017, 04:09:38 PM
That fixed mine up as well.
Title: Re: Curly's Wx Story script
Post by: tmabell on December 14, 2017, 04:35:07 PM
Nice work!  That seems to have restored it for most people but if you select North Webster (Indiana) then you get nothing.  The images are there so I don't know what's up with that.
Title: Re: Curly's Wx Story script
Post by: gwwilk on December 14, 2017, 06:47:03 PM
Nicely done!  Even 'Northern Indiana' is showing up for me right now.  It looks as though some WFO's have resorted to the '?timestamp' appended to the end of some graphics in order to thwart browser caching.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 14, 2017, 07:02:35 PM
I also just noticed that some sites use .jpg for their images.
So add this line in the same place as well....
Code: [Select]
$html = preg_replace("/\.jpg\?(.+?)/" , ".jpg " , $html);               // cut off random numbering of jpg
I've also added that to the code in my earlier post.
Title: Re: Curly's Wx Story script
Post by: Fox_Of_The_Wind on December 14, 2017, 09:39:47 PM
Ok, finally had a few minutes to look at this and it is a simple fix it seems.
In the wxStory-inc.php  script... scroll down not too far and you'll see a group of "preg_replace" like so...
Code: [Select]
$html = preg_replace('//', '&deg;', $html);                                         //  change it to an entity
  $html = preg_replace('//', '\'', $html);                                            //  change stray character
  $html = preg_replace('/<u>/', '', $html);                                            //  fix error
  $html = preg_replace('/<\/u>/', '', $html);                                          //  fix error
  $html = preg_replace('/<br>/', '<br />', $html);                                     //  fix error
 

Add these to that group...
Code: [Select]
$html = preg_replace("/\.png\?(.+?)/" , ".png " , $html);               // cut off random numbering of png
$html = preg_replace("/\.jpg\?(.+?)/" , ".jpg " , $html);               // cut off random numbering of jpg

and it should fix it. At least it did for me.

Thank you. Mine is working great again!
Title: Re: Curly's Wx Story script
Post by: tmabell on December 15, 2017, 10:42:45 AM
I hope what I found helps someone eventually.  I will say that I am not skilled enough in php to be able to explain why most every site worked but a few, even after the fixes by RRRICK8 but they didn't.  ("Northern Indiana" is the one I was focused on.)  I was able to prove that the image was being retrieved but that the script wasn't processing it.  I learned that by replacing


Code: [Select]
$imgName   = '';

with this

Code: [Select]
$imgName   = array();

that the KIWX image suddenly began displaying correctly.  Why other sites worked before I don't know but I'd like to learn about it.  The wild card here is that I am using PHP 7.2.  There are a number of changes that affect our scripts in that version.


Title: Re: Curly's Wx Story script
Post by: jgillett on December 15, 2017, 11:07:36 AM
Mine now working fine, images and all. Unfortunately Phoenix isn't posting the story right now but have a call in to the PSR manager to see if he'll get it going again.

Thanks to all.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 15, 2017, 12:33:23 PM
On my site I've also updated the WS_map.png   to reflect some of the WFO's that were indicated as seldom used are now using the Weather Story daily or almost daily.  I've changed those that have it 3 days in a row at least that I've checked.
If you want to replace it, just download it here and then upload it to your directory where you have it in your script.
(http://vermilionweather.com/images/WS_map.png)
Title: Re: Curly's Wx Story script
Post by: UpstateWeather.com on December 18, 2017, 02:22:36 PM
Ok, finally had a few minutes to look at this and it is a simple fix it seems.
In the wxStory-inc.php  script... scroll down not too far and you'll see a group of "preg_replace" like so...
Code: [Select]
$html = preg_replace('//', '&deg;', $html);                                         //  change it to an entity
  $html = preg_replace('//', '\'', $html);                                            //  change stray character
  $html = preg_replace('/<u>/', '', $html);                                            //  fix error
  $html = preg_replace('/<\/u>/', '', $html);                                          //  fix error
  $html = preg_replace('/<br>/', '<br />', $html);                                     //  fix error
 


Any other ideas? This didn't work for me.... :(
Add these to that group...
Code: [Select]
$html = preg_replace("/\.png\?(.+?)/" , ".png " , $html);               // cut off random numbering of png
$html = preg_replace("/\.jpg\?(.+?)/" , ".jpg " , $html);               // cut off random numbering of jpg

and it should fix it. At least it did for me.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 02:57:24 PM
Looks like it's all working except the first radar tab.
That gif image adds another dimension to it.

Along with the .png and .jpg replace we need to add .gif to the mix.
So add gif to the solution....
Code: [Select]
$html = preg_replace("/\.png(.+?)/" , ".png " , $html);               // cut off random numbering of png
 $html = preg_replace("/\.jpg\?(.+?)/" , ".jpg " , $html);               // cut off random numbering of jpg
 $html = preg_replace("/\.gif\?(.+?)/" , ".gif " , $html);               // cut off random numbering of gif
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 03:12:57 PM
On my site I've also updated the WS_map.png   to reflect some of the WFO's that were indicated as seldom used are now using the Weather Story daily or almost daily.  I've changed those that have it 3 days in a row at least that I've checked.
If you want to replace it, just download it here and then upload it to your directory where you have it in your script.
(http://vermilionweather.com/images/WS_map.png)

As a side... I've notice the last few days (that I've been monitoring) that even the few remaining orange "Seldom Used" have been working except Boise. As of time of this posting, both Arizona sites, Medford OR., and Washington is working and has been for the most part the last few days. Portland (which is labeled red- not used) is even using theirs today. So I might be updating this map again in a few days.
 [ You are not allowed to view attachments ]
Title: Re: Curly's Wx Story script
Post by: Silversword on December 18, 2017, 03:17:20 PM
Hi All,

Looks like this scrip will not work for me or folks in Alaska.  Hawaii and Alaska are not included in the mix.

Looks good for the CONUS (Lower 48) though.

Maybe one day we will be included.

Regards,

--Stan Y.
   Maui, Hawaii
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 03:28:58 PM
Hi All,

Looks like this scrip will not work for me or folks in Alaska.  Hawaii and Alaska are not included in the mix.

Looks good for the CONUS (Lower 48) though.

Maybe one day we will be included.

Regards,

--Stan Y.
   Maui, Hawaii

Yeah, I don't see a Weather Story on any of the WFO's for those areas. 
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 05:58:26 PM
Quote
Warning: imagecreatefrompng(): './images/WS_map.png' is not a valid PNG file in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 279

Warning: getimagesize(): PNG file corrupted by ASCII conversion in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 280

Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 281

Warning: imagecolortransparent() expects parameter 1 to be resource, boolean given in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 282

Warning: imagecreatetruecolor(): Invalid image dimensions in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 283

Warning: imagecreatefrompng(./images/ind.png): failed to open stream: No such file or directory in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 284

Warning: imagecopymerge() expects parameter 1 to be resource, boolean given in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 285

Warning: imagedestroy() expects parameter 1 to be resource, boolean given in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 286

Warning: imagepng() expects parameter 1 to be resource, boolean given in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 287

Warning: imagedestroy() expects parameter 1 to be resource, boolean given in /home/hj2ke8lfpx43/public_html/wxStory_inc.php on line 288

not sure what i did wrong i just changed

//  MAP & DATA SETTINGS
$useWFOmap      = true;               // true=use map to select WFO     false=use drop down menu to select the WFO
$ws_mapfolder   = './images/';         // main map image file FOLDER
$ws_cachefolder = './wscache/';        // cache file FOLDER
$wfomaps        = './images/';       // folder containing individual WFO coverage maps
$mapname        = 'WS_map';            // main map name - without extension
$ift            = '.png';              // map image file extesion
$autocacheclean = true;                // true=auto delete cache files older than 1 day   false=keep cache files
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 06:04:05 PM
So what did you change there?
Only thing I see different than mine is the $wfomaps folder location.
Mine is $wfomaps        = './wsimages/';
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 06:06:03 PM
So what did you change there?
Only thing I see different than mine is the $wfomaps folder location.
Mine is $wfomaps        = './wsimages/';

was there a zip for wxstory cuz i dont have wsimages?
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 06:07:38 PM
So what did you change? You said you changed that section.
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 06:08:26 PM
So what did you change? You said you changed that section.

Just False to true on $useWFOmap      = true;               // true=use map to select WFO     false=use drop down menu to select the WFO
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 06:13:03 PM
Change it back to false to see if your errors go away.
I suspect that you didn't upload the WFOmaps folder or it's in a different location.
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 06:23:57 PM
Change it back to false to see if your errors go away.
I suspect that you didn't upload the WFOmaps folder or it's in a different location.

There was never a WFOmaps folder where do i get one at? I changed it back and i had no errors.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 06:38:08 PM
Here is the original zip I have. Don't know for sure if this is the one that Curly released because I was doing some beta testing for him on a few scripts and I believe this was one of them.
If you do a complete new reload, make sure to add the preg_replace changes posted earlier...
 [ You are not allowed to view attachments ]
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 06:40:20 PM
Here is the original zip I have. Don't know for sure if this is the one that Curly released because I was doing some beta testing for him on a few scripts and I believe this was one of them.
If you do a complete new reload, make sure to add the preg_replace changes posted earlier...
 [ You are not allowed to view attachments ]

Ok thanks :)
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 06:45:10 PM
This is crazy I still get the errors lol
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 06:52:33 PM
This is crazy I still get the errors lol

Did you upload everything like the Readme file instructed?
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 06:54:20 PM
Yep im wondering if its because of PHP 7
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 06:58:28 PM
You can hide the errors by commenting out the error reporting function at the top of the script.
When I looked earlier on your site, your current weather story was showing but the map wasn't. You need to get that part working first if you want to use the map. You need to set the settings correctly to point to where you added the WFOmaps
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 07:01:09 PM
You can hide the errors by commenting out the error reporting function at the top of the script.
When I looked earlier on your site, your current weather story was showing but the map wasn't. You need to get that part working first if you want to use the map. You need to set the settings correctly to point to where you added the WFOmaps

Now the .png doesnt want to load http://gosportwx.com/wxstory.php
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 07:03:50 PM
You can hide the errors by commenting out the error reporting function at the top of the script.
When I looked earlier on your site, your current weather story was showing but the map wasn't. You need to get that part working first if you want to use the map. You need to set the settings correctly to point to where you added the WFOmaps

Now the .png doesnt want to load http://gosportwx.com/wxstory.php
Did you add the preg_replace codes from above?  The .png is showing in your "View Source" but it still has the random numbers atteached.
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 07:07:35 PM
Ya I fixed that part now. Want to use the map it looks cool
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 07:08:24 PM
Ok, I see you have the image back now need to get the map working.
Your view source shows that you are calling for it in here... ./cache/WS_mapind.png

Did you upload the WFOmaps into that cache folder or into a different folder? They are the ones that are in the wsimages folder
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 07:10:36 PM
Ok, I see you have the image back now need to get the map working.
Your view source shows that you are calling for it in here... ./cache/WS_mapind.png

Did you upload the WFOmaps into that cache folder or into a different folder? They are the ones that are in the wsimages folder

wsimages
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 07:13:47 PM
Ok, I see you have the image back now need to get the map working.
Your view source shows that you are calling for it in here... ./cache/WS_mapind.png

Did you upload the WFOmaps into that cache folder or into a different folder? They are the ones that are in the wsimages folder

wsimages
So you need to change the settings to reflect where you uploaded them to.... $wfomaps        = './wsimages/';       // folder containing individual WFO coverage maps

You also need to upload the WS_map that was in the zip to your images folder.
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 07:15:19 PM
Ok I done that.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 07:18:41 PM
Ok I done that.

Did both? WS_map into images folder and uploaded complete wximages folder onto your server?
If so, can you post your setting from the script like you did earlier so I can see them?
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 07:26:56 PM
Below is attached my wxStory_inc.php in a txt file

Mike
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 07:27:31 PM
This is my Map Settings from the script...
//  MAP & DATA SETTINGS
$useWFOmap      = true;               // true=use map to select WFO     false=use drop down menu to select the WFO
$ws_mapfolder   = './images/';         // main map image file FOLDER   WS_map.png goes into "images" folder;
$ws_cachefolder = './wscache/';        // cache file FOLDER
$wfomaps        = './wsimages/';       // folder containing individual WFO coverage maps   Upload entire wsimages folder onto your server
$mapname        = 'WS_map';            // main map name - without extension
$ift            = '.png';              // map image file extension
$autocacheclean = true;                // true=auto delete cache files older than 1 day   false=keep cache files
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 07:28:38 PM
This is my Map Settings from the script...
//  MAP & DATA SETTINGS
$useWFOmap      = true;               // true=use map to select WFO     false=use drop down menu to select the WFO
$ws_mapfolder   = './images/';         // main map image file FOLDER   WS_map.png goes into "images" folder;
$ws_cachefolder = './wscache/';        // cache file FOLDER
$wfomaps        = './wsimages/';       // folder containing individual WFO coverage maps   Upload entire wsimages folder onto your server
$mapname        = 'WS_map';            // main map name - without extension
$ift            = '.png';              // map image file extension
$autocacheclean = true;                // true=auto delete cache files older than 1 day   false=keep cache files

yep mine looks like that except i use /cache instead of /wscache ... idk why its not generating like it should..
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 07:31:27 PM
http://gosportwx.com/images/WS_map.png (http://gosportwx.com/images/WS_map.png) why is it like this?
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 07:37:35 PM
Try the new updated WS_map.png I posted here earlier.

Download it then upload to your server in the images folder overwriting the current one.

(http://vermilionweather.com/images/WS_map.png)
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 07:41:38 PM
Try the new updated WS_map.png I posted here earlier.

Download it then upload to your server in the images folder overwriting the current one.

(http://vermilionweather.com/images/WS_map.png)

That's what I used. I just went back to the original style i had with the drop down menu.. I tried everything :(
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 18, 2017, 07:46:32 PM
Ok.  Just seems like it's an issue that it can't get the WS_map.png 
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 08:04:08 PM
Ok.  Just seems like it's an issue that it can't get the WS_map.png

Maybe Ken can chime in on this once he is back on *shrugs*
Title: Re: Curly's Wx Story script
Post by: SteveFitz1 on December 18, 2017, 08:50:12 PM
Mike,

I've seen this error before and it was caused by an image being uploaded in ASCII mode instead of Binary mode. Make sure first you can view the image correctly on your machine after you've downloaded it from the forum. If that works, ensure you're FTPing correctly to your host.

Steve
Title: Re: Curly's Wx Story script
Post by: mkutche on December 18, 2017, 09:43:03 PM
Mike,

I've seen this error before and it was caused by an image being uploaded in ASCII mode instead of Binary mode. Make sure first you can view the image correctly on your machine after you've downloaded it from the forum. If that works, ensure you're FTPing correctly to your host.

Steve

That was what i was about to do i was using FileZilla and switched to CoreFTP and it fixed it now to figure why the cache isnt wanting to update and process the image files...

http://gosportwx.com/wxstory.php?i=lsx (http://gosportwx.com/wxstory.php?i=lsx)
Title: Re: Curly's Wx Story script
Post by: tmabell on December 19, 2017, 09:13:26 AM
What version of php is your host using?
Title: Re: Curly's Wx Story script
Post by: mkutche on December 19, 2017, 12:21:56 PM
What version of php is your host using?

7.1
Title: Re: Curly's Wx Story script
Post by: tmabell on December 19, 2017, 12:24:45 PM
You may want to review my earlier mention of a change I made to restore functionality when using php 7.1 + up.  However, My version of the script is not displaying the St. Louis images either.  rrrick8, is that site showing an image?  Jerry's site isn't working for LSX either.  Right now I'm stumped.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 19, 2017, 12:48:52 PM
You may want to review my earlier mention of a change I made to restore functionality when using php 7.1 + up.  However, My version of the script is not displaying the St. Louis images either.  rrrick8, is that site showing an image?  Jerry's site isn't working for LSX either.  Right now I'm stumped.

Looking at the lsx  issue.... there is a ? in their time stamp/number after the image.  Removing that fixed it for me.
So, we add the following to the preg_replace grouping and watch to see if it adversely effects the script in other ways.

Code: [Select]
$html = preg_replace("/\?/" , " " , $html);               // cut out ?

Title: Re: Curly's Wx Story script
Post by: mkutche on December 19, 2017, 02:18:19 PM
You may want to review my earlier mention of a change I made to restore functionality when using php 7.1 + up.  However, My version of the script is not displaying the St. Louis images either.  rrrick8, is that site showing an image?  Jerry's site isn't working for LSX either.  Right now I'm stumped.

Looking at the lsx  issue.... there is a ? in their time stamp/number after the image.  Removing that fixed it for me.
So, we add the following to the preg_replace grouping and watch to see if it adversely effects the script in other ways.

Code: [Select]
$html = preg_replace("/\?/" , " " , $html);               // cut out ?


Thanks Rick that fixed it :)
Title: Re: Curly's Wx Story script
Post by: jgillett on December 21, 2017, 11:05:29 PM
Rick, another map change, please. psr (Phoenix) needs to be green. Had a chat with the manager here and he indicates they are now supporting Story. I have it up at http://tiggrweather.net/wxstory.php.

Thanks.
Title: Re: Curly's Wx Story script
Post by: mkutche on December 22, 2017, 06:25:11 AM
Rick, another map change, please. psr (Phoenix) needs to be green. Had a chat with the manager here and he indicates they are now supporting Story. I have it up at http://tiggrweather.net/wxstory.php.

Thanks.

I'm not seeing any pic of the story?
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 22, 2017, 08:32:38 AM

Rick, another map change, please. psr (Phoenix) needs to be green. Had a chat with the manager here and he indicates they are now supporting Story. I have it up at http://tiggrweather.net/wxstory.php.
Thanks.
Yes, I've been monitoring those out west and Boise seems to be the only one not having a Weather Story virtually every day.
I'll get the map changed later today hopefully.

I'm not seeing any pic of the story?

Probably just timing. At time of your posting it is only 3-something AM out there so they just haven't posted it yet and the last one had expired.
They've had one daily that I've seen.
Title: Re: Curly's Wx Story script
Post by: SteveFitz1 on December 22, 2017, 08:44:39 AM
There seems to be an issue displaying the Weather Story page out of Shreveport, LA this morning. On the initial display, 5 tabs are shown below the map. However, nothing is shown for the first one - SHV Radar. All the other ones work. However, when I go to the actual NWS page at http://www.weather.gov/shv/, there is radar showing on that first tab.

Any ideas?

Thanks,

Steve
Title: Re: Curly's Wx Story script
Post by: jgillett on December 22, 2017, 08:51:55 AM
I'm not seeing any pic of the story?
Weird. It was there late last night. I've seen 2 different pics in the past 2 days.
Title: Re: Curly's Wx Story script
Post by: jgillett on December 22, 2017, 09:01:27 AM
Hmm - might be me (drat) or possibly the pic was coded wrong. There are numerous Freeze and Hard Freeze Warnings out (http://tiggrweather.net/wxadvisory.php) that don't expire until 0900 today but am not seeing them on http://tiggrweather.net/ where they should be. Most recent pics have shown data corresponding to these warnings.
Title: Re: Curly's Wx Story script
Post by: jgillett on December 22, 2017, 10:34:22 AM
Alerts are back on my home page where they should be. The only thing I see on the story page is a header-like banner with 'Cold Weather' in it right below the map. Apparently a "pic"??
Title: Re: Curly's Wx Story script
Post by: mkutche on December 22, 2017, 11:00:28 AM

Rick, another map change, please. psr (Phoenix) needs to be green. Had a chat with the manager here and he indicates they are now supporting Story. I have it up at http://tiggrweather.net/wxstory.php.
Thanks.
Yes, I've been monitoring those out west and Boise seems to be the only one not having a Weather Story virtually every day.
I'll get the map changed later today hopefully.

I'm not seeing any pic of the story?

Probably just timing. At time of your posting it is only 3-something AM out there so they just haven't posted it yet and the last one had expired.
They've had one daily that I've seen.

http://gosportwx.com/wxstory.php?i=psr (http://gosportwx.com/wxstory.php?i=psr)

On my website I get this "Today's Weather Story has not been posted for Phoenix"
Title: Re: Curly's Wx Story script
Post by: jgillett on December 22, 2017, 12:15:19 PM
Not seeing that on mine, Mike. Only the banner mentioned above.
Title: Re: Curly's Wx Story script
Post by: SteveFitz1 on December 22, 2017, 12:23:58 PM
On my website I get this "Today's Weather Story has not been posted for Phoenix"

When I go to that Phoenix link, below that map it says "Phoenix does not have the Weather Story".

Steve
Title: Re: Curly's Wx Story script
Post by: tmabell on December 22, 2017, 01:08:08 PM
+1
Title: Re: Curly's Wx Story script
Post by: jgillett on December 22, 2017, 05:36:50 PM
Turns out the 'Cold Weather' banner just below the US map is actually a link. Clicking on it brings up the Story image. Not the way I would do it, but...
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 22, 2017, 07:51:36 PM
There seems to be an issue displaying the Weather Story page out of Shreveport, LA this morning. On the initial display, 5 tabs are shown below the map. However, nothing is shown for the first one - SHV Radar. All the other ones work. However, when I go to the actual NWS page at http://www.weather.gov/shv/, there is radar showing on that first tab.

Any ideas?

Thanks,

Steve
I'd say you probably missed the post earlier about adding gif to the preg -replace list. That radar runs a gif image.
Here is the complete list to include getting rid of the ? that was hanging up some images.

Code: [Select]
// fix characters
  $html = preg_replace('//', '&deg;', $html);                                         //  change it to an entity
  $html = preg_replace('//', '\'', $html);                                            //  change stray character
  $html = preg_replace('/<u>/', '', $html);                                            //  fix error
  $html = preg_replace('/<\/u>/', '', $html);                                          //  fix error
  $html = preg_replace('/<br>/', '<br />', $html);                                     //  fix error
  $html = preg_replace("/\.png\?(.+?)/" , ".png " , $html);               // cut off random numbering of png
  $html = preg_replace("/\.png(.+?)/" , ".png " , $html);               // cut off random numbering of png
  $html = preg_replace("/\.jpg\?(.+?)/" , ".jpg " , $html);               // cut off random numbering of jpg
  $html = preg_replace("/\.gif\?(.+?)/" , ".gif " , $html);               // cut off random numbering of gif
  $html = preg_replace("/\?/" , " " , $html);               // cut off ?
Title: Re: Curly's Wx Story script
Post by: SteveFitz1 on December 22, 2017, 09:02:46 PM

I'd say you probably missed the post earlier about adding gif to the preg -replace list. That radar runs a gif image.
Here is the complete list to include getting rid of the ? that was hanging up some images.


Rick,

I had seen that post and "thought" I had updated the script, but obviously I hadn't. Sorry for the bother. It's working great now.

Thanks,

Steve
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 22, 2017, 09:27:15 PM

I'd say you probably missed the post earlier about adding gif to the preg -replace list. That radar runs a gif image.
Here is the complete list to include getting rid of the ? that was hanging up some images.


Rick,

I had seen that post and "thought" I had updated the script, but obviously I hadn't. Sorry for the bother. It's working great now.

Thanks,

Steve

No problem.  Glad you got it working.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 23, 2017, 10:34:30 AM
I went ahead and updated the WS_map.png showing everything in the west as green with the exception of Boise.
Both Phoenix and Tucson haven't had theirs active the last couple of days but they were for numerous days prior to this. So they may still be spotty but with John saying they are going to be having it, I went ahead and updated those as well to green status.
Hopefully we have all the images extension problems ironed out.

(http://vermilionweather.com/images/WS_map.png)
Title: Re: Curly's Wx Story script
Post by: jgillett on December 23, 2017, 11:07:50 AM
I have to play Dumbo again. Where are you hiding the download link? The message where you originally had it - http://www.wxforum.net/index.php?topic=33102.msg338505#msg338505 - no longer shows it, and unless I've gone blind too I can't find it.

Thanks, and also for updating the map. True to form PSR is not showing a story for today.
Title: Re: Curly's Wx Story script
Post by: tmabell on December 23, 2017, 11:28:03 AM
I have a challenging thought.  If one wished to display both the map and the story in a side-by-side manner, how hard would that be?  I imagine in addition to rearranging them, some re-sizing might be needed as well.  Is this goal too lofty?
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 23, 2017, 11:41:56 AM
I have to play Dumbo again. Where are you hiding the download link? The message where you originally had it - http://www.wxforum.net/index.php?topic=33102.msg338505#msg338505 - no longer shows it, and unless I've gone blind too I can't find it.

Thanks, and also for updating the map. True to form PSR is not showing a story for today.

Should just be able to right click image and save it as WS_map.png then upload to your server.  I didn't add a link.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 25, 2017, 07:54:46 PM
Kind of weird that Melbourne, FL is the only site in that state that does not have a daily weather story but yet they do something similar to it daily called an Impact Weather Update or Graphicast. You can see it here.... http://www.weather.gov/mlb/blog (http://www.weather.gov/mlb/blog)
Wish they'd just do it like all the others then we could add it to the mix.
Title: Re: Curly's Wx Story script
Post by: jgillett on December 28, 2017, 07:26:02 PM
PSR is working again, along with station and official record high temps at my site (28 Dec). Nice. Hopefully they'll keep at the story.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 28, 2017, 07:40:16 PM
PSR is working again, along with station and official record high temps at my site (28 Dec). Nice. Hopefully they'll keep at the story.

Yeah, I think they activated it just to show off the temps while the rest of the country is freezing.  :evil:
Seriously though, since I changed the map, they haven't had it active but a couple of times. Hopefully the frequency increases.
I've notice a few of the western sites haven't been posting during the holidays here as much as they did before. I'll just blame it on skeleton crew manning until after the New Year.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 28, 2017, 07:45:03 PM
Even Boise has one active now. First time I've seen theirs active in ages.
Title: Re: Curly's Wx Story script
Post by: jgillett on December 28, 2017, 09:49:39 PM
Definitely a mess in most of the rest of the country. It was running here for at least 3 days before I posted about it, then it stopped, now it's back. Hopefully they will keep their word.
Title: Re: Curly's Wx Story script
Post by: W3DRM on December 29, 2017, 10:44:10 PM
Have been reading this thread and decided to give wxstory a try. So, far, I have been able to get it to run decently however, I am having issues with both width and vertical sizing. I am using a standard Saratoga template. Some selections show a very wide and long area while others work as I think they should. I have looked at a couple other websites using the same code and they don't exhibit the same behavior I am seeing.

I've placed the link to my wxstory.php in my NWS Forecast & Advisories menu. The wxstory.php link is at the bottom of the forecast flyout menu item. Reno is my default and its width seems to be okay.
Title: Re: Curly's Wx Story script
Post by: jgillett on December 30, 2017, 01:26:59 AM
Unable to see any problems now as it shows, "Today's Weather Story has not been posted for Reno". Reno shows the same from my site. Would help if you could list some of the other cities you indicate are causing problems for you.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 30, 2017, 07:56:19 AM
Don, I ran just your wxStory_inc.php without the template and everything was normal on 15 sites I tested.
Your problem is use withing the template, which I don't use so can't help you with that.
Again, though... it appears your WxStory is running fine.
Title: Re: Curly's Wx Story script
Post by: W3DRM on December 30, 2017, 07:03:51 PM
John, rrrick8,

I have attached two screen captures showing what I am seeing for both Reno and Grand Junction, CO. I see many other sites with similar results. For some reason, some of the sites display in a very wide format.
Title: Re: Curly's Wx Story script
Post by: rrrick8 on December 30, 2017, 09:04:44 PM
Like I said above... if you run just the script wxStory_inc.php  it all looks good.
So I believe the script is fine it's just something askew with your placement in the template which I don't use so I can't help you on that one.
Title: Re: Curly's Wx Story script
Post by: jgillett on December 31, 2017, 11:18:41 AM
Don, as Rick said it seems not to be in Curly's script. I ran my site script and selected Reno and it looks just fine (attached). I was unable to find the problem as well. Sorry.
Title: Re: Curly's Wx Story script
Post by: wvdkuil on December 31, 2017, 11:33:57 AM
John, rrrick8,

I have attached two screen captures showing what I am seeing for both Reno and Grand Junction, CO. I see many other sites with similar results. For some reason, some of the sites display in a very wide format.
Your http://www.carsonvalleyweather.com/wxStory_inc.php is fine. All html is clear and correct for all cities, without or with text..
But your wxstory.php has an extra line of code
Code: [Select]
<!-- end of menubar -->

<div id="main-copy">
<pre>
  <table border="0" cellspacing="0" cellpadding="0" style="width: 700px; margin: 20px auto 0px auto;">
 <tr>
  <td style="text-align:center;"><a href="http://www.weather.gov/rev/" onclick="window.open(this.href,'_blank');return false;" title="Click to view this forecast office" style="text-decoration: none; color: inherit;"><span style="font-size:20px; letter-spacing:2px;"><b><span style="color:#0061AC;">WEATHER STORY</span><br />Reno<br /><span style="font-size:60%; vertical-align: text-top;">Weather Forecast Office</span></b></span></a></td>
 </tr>
</table>

You should find that '<pre>' and remove it. That will take care of the very wide page, which only occurs when there is text below the map. That text will be as wide as the longest line, because of that '<pre>'. You can see that all bottom text is displayed in a monospaced courier font and without line-breaks. 
 
We can not check your php script online, so if you can not find that <pre> , post the script here with the .txt extension.

Wim
Title: Re: Curly's Wx Story script
Post by: W3DRM on December 31, 2017, 12:52:18 PM
John, rrrick8,

I have attached two screen captures showing what I am seeing for both Reno and Grand Junction, CO. I see many other sites with similar results. For some reason, some of the sites display in a very wide format.
Your http://www.carsonvalleyweather.com/wxStory_inc.php (http://www.carsonvalleyweather.com/wxStory_inc.php) is fine. All html is clear and correct for all cities, without or with text..
But your wxstory.php has an extra line of code
Code: [Select]
<!-- end of menubar -->

<div id="main-copy">
   <pre>
     <table border="0" cellspacing="0" cellpadding="0" style="width: 700px; margin: 20px auto 0px auto;">
 <tr>
  <td style="text-align:center;"><a href="http://www.weather.gov/rev/" onclick="window.open(this.href,'_blank');return false;" title="Click to view this forecast office" style="text-decoration: none; color: inherit;"><span style="font-size:20px; letter-spacing:2px;"><b><span style="color:#0061AC;">WEATHER STORY</span><br />Reno<br /><span style="font-size:60%; vertical-align: text-top;">Weather Forecast Office</span></b></span></a></td>
 </tr>
</table>

You should find that '<pre>' and remove it. That will take care of the very wide page, which only occurs when there is text below the map. That text will be as wide as the longest line, because of that '<pre>'. You can see that all bottom text is displayed in a monospaced courier font and without line-breaks. 
 
We can not check your php script online, so if you can not find that <pre> , post the script here with the .txt extension.

Wim

Wim, you are a genius! =D&gt;  That was the problem. Since I was incorporating this code into my Saratoga template, I had simply taken the code and included the <pre>...</pre> in my wxstory.php and that is what was causing the issue with screen width.

Thank you very much for the assistance. I have included the code section from my wxstory.php that I am now using to include the wxStory_inc.php, for Saratoga template users.

Code: [Select]
<body>
<?php
############################################################################
include("header.php");
############################################################################
include("menubar.php");
############################################################################
?>


<div id="main-copy">
  <?php include("wxStory_inc.php"); ?> 
<><!-- end main-copy -->

<?php
############################################################################
include("footer.php");
############################################################################
# End of Page
############################################################################
?>

Title: Re: Curly's Wx Story script
Post by: tmabell on February 28, 2018, 04:26:51 PM
I think this script is another casualty of the changes made yesterday by the NWS.  There are no images showing as of today.  Any thoughts on what needs to be changed?
Title: Re: Curly's Wx Story script
Post by: gwwilk on February 28, 2018, 07:32:39 PM
I just checked it this morning and it was working.  Now it's not displaying the graphics.

Yecchhh! :-(
Title: Re: Curly's Wx Story script
Post by: saratogaWX on February 28, 2018, 07:36:01 PM
I'd try changing
Code: [Select]
(in_array($wswfo, $hpwxs)) ? $wxsurl =  'http://www.weather.gov/'.$wswfo.'/' : $wxsurl = 'http://www.weather.gov/'.$wswfo.'/weatherstory';
to
Code: [Select]
(in_array($wswfo, $hpwxs)) ? $wxsurl =  'https://www.weather.gov/'.$wswfo.'/' : $wxsurl = 'https://www.weather.gov/'.$wswfo.'/weatherstory';
and make sure you have
Code: [Select]
$useCURL        = true;               // true=get data by cURL method  false=stream data
Title: Re: Curly's Wx Story script
Post by: gwwilk on February 28, 2018, 07:41:19 PM
Thanks, but no joy, Ken.  Still no images.  I tried  to place 'oax' in the https array, but that didn't work either.

Curly's code is more than a bit difficult for me to unwind.  I've given it a shot but now I'm not even seeing new images show up in my '/wscache' directory.
Title: Re: Curly's Wx Story script
Post by: jgillett on February 28, 2018, 08:07:58 PM
Not every city displays graphics on a regular or daily basis. PSR is a good example. Yesterday there was info about a coming rainstorm and a large graphic to go along with it. Today it says, "Phoenix does not have the Weather Story." Well they do, but when they want. I pushed a lot of green buttons on the map today. Pretty much the same wording along with a lot of other text items below the map.
Title: Re: Curly's Wx Story script
Post by: mkutche on February 28, 2018, 08:39:26 PM
Thanks, but no joy, Ken.  Still no images.  I tried  to place 'oax' in the https array, but that didn't work either.

Curly's code is more than a bit difficult for me to unwind.  I've given it a shot but now I'm not even seeing new images show up in my '/wscache' directory.


none of mine are working either.. i applied the fix that ken suggested but nothing. http://www.gosportwx.com/wxstory.php?i=ind
Title: Re: Curly's Wx Story script
Post by: W3DRM on March 01, 2018, 11:01:49 AM
Worked fine for me two days ago (2/27) but now all I get is the text with a broken image symbol displayed. Just when I need it most as we have the season's largest storm coming-in right now...  ](*,)
Title: Re: Curly's Wx Story script
Post by: jmcmurry on March 01, 2018, 11:09:30 AM
It seems that the NWS used to accept query strings without a "?" such as http://www.weather.gov/images/arx/wxstory/Tab2FileL.png e73c9f3d342158b6aa283cb30e80054 but no longer does.  Perhaps Ken and his regex wizardry will be able to come up with a better fix, but this seems to be doing it for me:
replace
Code: [Select]
function GetDataByCurl($url)    {
  global $noted;                                                          // set global

with
function GetDataByCurl($url)    {
  $url = str_replace("png ", "png?", $url);    // added 3/1/18
  global $noted;                                                          // set global
and
Code: [Select]

function getWSBystream($url) {
  global $noted;

with
function getWSBystream($url) {
  $url = str_replace("png ", "png?", $url);        // added 3/1/18
  global $noted;

- Jim
Title: Re: Curly's Wx Story script
Post by: 92merc on March 01, 2018, 11:19:29 AM
That update worked for me as well.
Title: Re: Curly's Wx Story script
Post by: gwwilk on March 01, 2018, 12:45:02 PM
Thanks, Jim! \:D/ =D&gt; \:D/ Works great!
Title: Re: Curly's Wx Story script
Post by: W3DRM on March 02, 2018, 10:21:46 AM
Thanks, Jim! \:D/ =D&gt; \:D/ Works great!

Jerry  - I notice the map does not change when you select the various green dots. Once I select another location, it always shows the Pocatello, ID section of the map. The wx story and header do change with each different selection. Not sure if it's me or not. I've tried it on Chrome and Firefox and get similar results.
Title: Re: Curly's Wx Story script
Post by: gwwilk on March 02, 2018, 10:28:51 AM
Thanks, Jim! \:D/ =D&gt; \:D/ Works great!

Jerry  - I notice the map does not change when you select the various green dots. Once I select another location, it always shows the Pocatello, ID section of the map. The wx story and header do change with each different selection. Not sure if it's me or not. I've tried it on Chrome and Firefox and get similar results.
I think it has to do with file permissions, but I haven't solved the problem yet.
Title: Re: Curly's Wx Story script
Post by: W3DRM on March 02, 2018, 11:21:11 AM
Jim's update worked for me, except for the Reno sector. Others appear to be working just fine but not Reno, that still gives me the broken image icon... And, the map shows the correct selection so not sure what the issue is with Jerry's. It could be file permissions as he indicated.
Title: Re: Curly's Wx Story script
Post by: jmcmurry on March 02, 2018, 02:41:42 PM
I just tried Reno and it worked fine for me.

As for the overlays on the US map working, are you using wscache as your cache?  I had to go to that to fix something, but I don't remember what the problem was when I did that.  I used to be able to remember things.

- Jim
Title: Re: Curly's Wx Story script
Post by: W3DRM on March 02, 2018, 03:14:50 PM
I just tried Reno and it worked fine for me.

As for the overlays on the US map working, are you using wscache as your cache?  I had to go to that to fix something, but I don't remember what the problem was when I did that.  I used to be able to remember things.

- Jim
The Reno image is working now. I don't know what "wscache" is...
Title: Re: Curly's Wx Story script
Post by: jgillett on March 02, 2018, 03:51:34 PM
The Reno image is working now. I don't know what "wscache" is...
Created by wxStory_inc.php - $ws_cachefolder = './wscache/'; Also $wfomaps = './wsimages/';

It's loaded with stuff!
Title: Re: Curly's Wx Story script
Post by: W3DRM on March 02, 2018, 04:14:55 PM
The Reno image is working now. I don't know what "wscache" is...
Created by wxStory_inc.php - $ws_cachefolder = './wscache/'; Also $wfomaps = './wsimages/';

It's loaded with stuff!

Yes, I see them now. Both of them are loaded with files. I also have another folder named "wsmainimages". It has one file in it named WS_map.png. That same file is also located in the wsimages folder. They appear to be identical.
Title: Re: Curly's Wx Story script
Post by: jgillett on March 02, 2018, 04:33:43 PM
Yes, I see them now. Both of them are loaded with files. I also have another folder named "wsmainimages". It has one file in it named WS_map.png. That same file is also located in the wsimages folder. They appear to be identical.
Interesting - I don't have the "wsmainimages".
Title: Re: Curly's Wx Story script
Post by: W3DRM on March 02, 2018, 10:47:14 PM
Yes, I see them now. Both of them are loaded with files. I also have another folder named "wsmainimages". It has one file in it named WS_map.png. That same file is also located in the wsimages folder. They appear to be identical.
Interesting - I don't have the "wsmainimages".

It's a mystery to me too. I suspect it might be a remnant of an earlier installation although all of the image files have a date of 1/6/2018 which is about the time I installed the Weather story routines. I don't have the original files I downloaded so can't go back to them to see if there was a sub-folder in them.

However, this brings up a question regarding the map of the US which shows the wfo's who participate in the weather story program. Who maintains this image file and how does it get updated when wfo's come on-line or drop-off the program?
Title: Re: Curly's Wx Story script
Post by: jgillett on March 02, 2018, 11:10:21 PM
However, this brings up a question regarding the map of the US which shows the wfo's who participate in the weather story program. Who maintains this image file and how does it get updated when wfo's come on-line or drop-off the program?
rrrick8 made the recent changes to it.
Title: Re: Curly's Wx Story script
Post by: mkutche on March 03, 2018, 07:56:48 AM
It seems that the NWS used to accept query strings without a "?" such as http://www.weather.gov/images/arx/wxstory/Tab2FileL.png e73c9f3d342158b6aa283cb30e80054 but no longer does.  Perhaps Ken and his regex wizardry will be able to come up with a better fix, but this seems to be doing it for me:
replace
Code: [Select]
function GetDataByCurl($url)    {
  global $noted;                                                          // set global

with
function GetDataByCurl($url)    {
  $url = str_replace("png ", "png?", $url);    // added 3/1/18
  global $noted;                                                          // set global
and
Code: [Select]

function getWSBystream($url) {
  global $noted;

with
function getWSBystream($url) {
  $url = str_replace("png ", "png?", $url);        // added 3/1/18
  global $noted;

- Jim

Thanks Jim works great on my end!
Title: Re: Curly's Wx Story script
Post by: gwwilk on March 03, 2018, 10:24:26 AM
Thanks, Jim! \:D/ =D&gt; \:D/ Works great!

Jerry  - I notice the map does not change when you select the various green dots. Once I select another location, it always shows the Pocatello, ID section of the map. The wx story and header do change with each different selection. Not sure if it's me or not. I've tried it on Chrome and Firefox and get similar results.
To buttress my idea that file permissions are the issue with the map not changing to a newly selected area, my alternate self-hosted test-site (http://selincolnwx.info/wxstory.php) has no such problems.  I have granular control of file permissions there, whereas on my main GoDaddy-hosted site (https://www.gwwilkins.org/wxstory.php) I don't, and the permissions keep getting hosed when the files are re-written.  All modified files in the GoDaddy /wscache revert to '604' from '707'.  Anybody know how to keep this from happening?
Title: Re: Curly's Wx Story script
Post by: jmcmurry on March 03, 2018, 02:04:37 PM
Today I found that there are sites using .gif and .jpg files so we need another tweak.  Now we should have

Code: [Select]
function GetDataByCurl($url)    {
  $url = str_replace("png ", "png?", $url);    // added 3/1/18
  $url = str_replace("jpg ", "jpg?", $url);    // added 3/3/18 Shreveport uses .jpg
  $url = str_replace("gif ", "gif?", $url);    // added 3/3/18 Fort Worth use .gif   
  global $noted;                                                          // set global

and

Code: [Select]
function getWSBystream($url) {
  $url = str_replace("png ", "png?", $url);    // added 3/1/18
  $url = str_replace("jpg ", "jpg?", $url);    // added 3/3/18 Shreveport uses .jpg
  $url = str_replace("gif ", "gif?", $url);    // added 3/3/18 Fort Worth use .gif   
  global $noted;

- Jim
Title: Re: Curly's Wx Story script
Post by: tmabell on March 03, 2018, 05:09:26 PM
Thanks Jim!
Title: Re: Curly's Wx Story script
Post by: rrrick8 on March 03, 2018, 05:16:39 PM
Sorry I'm late to the party. Been traveling this past week and just got back last night.
Caught up on the developments and applied Jim's fixes and resolved that problem but I see a new problem, at least for me..
The Southern Region has switched their images url subfolders from /wxstory/  to /graphicast/  thus their images are not working.

I see the line that is probably the reason is my line#297
Code: [Select]
$wxsimage = 'https://www.weather.gov/images/'.$wswfo.'/wxstory/'.$imName.'.png'; //  set image path
It probably needs an array to add the
Code: [Select]
$wxsimage = 'https://www.weather.gov/images/'.$wswfo.'/graphicast/'.$imName.'.png'; //  set image path  option but to be honest, arrays are not my forte.
Title: Re: Curly's Wx Story script
Post by: tmabell on March 03, 2018, 05:23:53 PM
rrrick8,

I have not had any problems.  My images are showing for all Southern Region WFO's without your most recent edit.  I should mention that I have disabled caching.  Might this be the reason?
Title: Re: Curly's Wx Story script
Post by: rrrick8 on March 04, 2018, 07:56:21 PM
rrrick8,

I have not had any problems.  My images are showing for all Southern Region WFO's without your most recent edit.  I should mention that I have disabled caching.  Might this be the reason?

Well, everything works for me except the Southern Region WFO's. I get the wording, just no images. I'm using V2.24 which I don't know if that was Curly's last or not. I was a beta tester for him and some of my scripts are from that endeavor and may not be his released version.
I have absolutely nothing in the script that mentions graphicast as a possible folder.
Title: Re: Curly's Wx Story script
Post by: tmabell on March 04, 2018, 08:02:15 PM
This is what I thought was his latest (2.23) but includes the recent fixes posted earlier.
Title: Re: Curly's Wx Story script
Post by: chief-david on July 07, 2020, 10:52:09 PM
Sorry to resurrect this-but I wanted to make a change.

92merc sent me the package and I have done what I thought was correct with all the instructions-but cannot get it to work.

To isolate the issue-I created a page with just the weather story. As you can see it just cuts off and stops.  https://rms-weather.rdale.org/Weatherstory.php

I would not be surprised if it is a code issue on my end somehow. We all know my site is put together with duct tape and chicken wire.

Any help is appreciated. I try as best as a can.
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 12:11:09 PM
bump.
Need help. Would like it to update itself instead of me doing it via Teamviewer.
Title: Re: Curly's Wx Story script
Post by: tmabell on July 17, 2020, 01:59:25 PM
Any chance you could post your code?
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 02:29:03 PM
I can only do part of the code at a time. It will not let me attach php

Quote
$NWSregion      = 'mpx';               // Enter your local NWS office three letter code
$useallwfos     = true;                // true=allow all WFO locations to be selected    false=display only the default WFO
$wstitle        = 'Weather Story';     // page title
$ourTZ          = 'America/Chicago';  // Time Zone     http://www.php.net/manual/en/timezones.america.php
$ws_cachetime   = '30';                // time in minutes to hold cache files before updating fresh data  ( 0 is not recommended)
$tablewdth      = '700';               // displayed image width in pixels inside the table

//  MAP & DATA SETTINGS
$useWFOmap      = false;               // true=use map to select WFO     false=use drop down menu to select the WFO
$ws_mapfolder   = '.images/';         // main map image file FOLDER
$ws_cachefolder = './wscache/';        // cache file FOLDER
$wfomaps        = './wsimages/';       // folder containing individual WFO coverage maps
$mapname        = 'WS_map';            // main map name - without extension
$ift            = '.png';              // map image file extesion
$autocacheclean = true;                // true=auto delete cache files older than 1 day   false=keep cache files

// Download method
// IF downloading seems slow, change setting
$useCURL        = false;               // true=get data by cURL method  false=stream data

###  END OF SETTINGS  ############################################################################################################
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 02:30:34 PM
Quote
// set variables
$updateCache = true;                   // SET update cache file(s)
$updateTextTime = $ws_cachetime * 60;  // change cache time minutes to seconds
$uts       = date("U");                // current unix time stamp
$goodWFO   = true;
$altStory  = array();
$cft       = '';
$hdline    = '';
$hdlnr     = array();
$imgMn     = array();
$imgName   = '';
$imName    = '';
$ifn       = '';
$mainStory = array();
$nfo       = '';
$noted     = '';
$wsdata    = '';
$wxsimage  = '';

// HTTPS sites
$usehttps = array('grr','iwx','lmk');

// old CRH or non working WFO codes
$nonWorkingCodes = array('akq','aly','bgm','boi','box','btv',
                         'buf','byz','cae','car','chs','cle',
                         'ctp','ggw','gsp','gyx','hnx','ilm',
                         'iln','lox','lwx','mhx','mlb','okx',
                         'pbz','phi','pih','pqr','psr','rah',
                         'rlx','rnk','sew','slc','tae','tfx',
                         'vef'
                         );

// home page WS WFO's - not in  /weatherstory
$hpwxs2 = array('abq','ama','bmx','bro','crp','eka','epz','ewx','ffc',
                'fgz','fwd','hgx','hun','jan','jax','key','lch','lix',
                'lkn','lub','lzk','maf','meg','mfl','mfr','mob','mrx',
                'mso','mtr','ohx','otx','oun','pdt','rev','sgx','shv',
                'sjt','sju','sto','tbw','tsa','twc'
             );

$hpwxs = array_merge($nonWorkingCodes, $hpwxs2);

// WFO code and location array as of 4/27/2017
$fo = array(
    'abq' => 'Albuquerque',
    'abr' => 'Aberdeen',
    'afc' => 'Anchorage',
    'afg' => 'Fairbanks',
    'ajk' => 'Juneau',
    'akq' => 'Wakefield',
    'aly' => 'Albany',
    'ama' => 'Amarillo',
    'apx' => 'Gaylord',
    'arx' => 'La Crosse',
    'bgm' => 'Binghamton',
    'bis' => 'Bismarck',
    'bmx' => 'Birmingham',
    'boi' => 'Boise',
    'bou' => 'Denver/Boulder',
    'box' => 'Boston',
    'bro' => 'Brownsville',
    'btv' => 'Burlington',
    'buf' => 'Buffalo',
    'byz' => 'Billings',
    'cae' => 'Columbia',
    'car' => 'Caribou',
    'chs' => 'Charleston',
    'cle' => 'Cleveland',
    'crp' => 'Corpus Christi',
    'ctp' => 'State College',
    'cys' => 'Cheyenne',
    'ddc' => 'Dodge City',
    'dlh' => 'Duluth',
    'dmx' => 'Des Moines',
    'dtx' => 'Detroit/Pontiac',
    'dvn' => 'Quad Cities',
    'eax' => 'Kansas City/Pleasant Hill',
    'eka' => 'Eureka',
    'epz' => 'El Paso Area',
    'ewx' => 'Austin/San Antonio',
    'ffc' => 'Peachtree City',
    'fgf' => 'Grand Forks',
    'fgz' => 'Flagstaff',
    'fsd' => 'Sioux Falls',
    'fwd' => 'Fort Worth',
    'ggw' => 'Glasgow',
    'gid' => 'Hastings',
    'gjt' => 'Grand Junction',
    'gld' => 'Goodland',
    'grb' => 'Green Bay',
    'grr' => 'Grand Rapids',
    'gsp' => 'Greenville-Spartanburg',
    'gyx' => 'Gray/Portland',
    'hfo' => 'Honolulu',
    'hgx' => 'Houston/Galveston',
    'hnx' => 'San Joaquin Valley/Hanford',
    'hun' => 'Huntsville',
    'ict' => 'Wichita',
    'ilm' => 'Wilmington',
    'iln' => 'Wilmington',
    'ilx' => 'Central Illinois',
    'ind' => 'Indianapolis',
    'iwx' => 'Northern Indiana',
    'jan' => 'Jackson',
    'jax' => 'Jacksonville',
    'jkl' => 'Jackson',
    'key' => 'Key West',
    'lbf' => 'North Platte',
    'lch' => 'Lake Charles',
    'lix' => 'New Orleans/Baton Rouge',
    'lkn' => 'Elko',
    'lmk' => 'Louisville',
    'lot' => 'Chicago',
    'lox' => 'Los Angeles/Oxnard',
    'lsx' => 'St. Louis',
    'lub' => 'Lubbock',
    'lwx' => 'Baltimore/Washington',
    'lzk' => 'Little Rock',
    'maf' => 'Midland/Odessa',
    'meg' => 'Memphis',
    'mfl' => 'Miami-South Florida',
    'mfr' => 'Medford',
    'mhx' => 'Newport/Morehead City',
    'mkx' => 'Milwaukee/Sullivan',
    'mlb' => 'Melbourne',
    'mob' => 'Mobile/Pensacola',
    'mpx' => 'Twin Cities',
    'mqt' => 'Marquette',
    'mrx' => 'Morristown',
    'mso' => 'Missoula',
    'mtr' => 'San Francisco/Monterey Bay Area',
    'oax' => 'Omaha/Valley',
    'ohx' => 'Nashville',
    'okx' => 'New York City/Upton',
    'otx' => 'Spokane',
    'oun' => 'Norman',
    'pah' => 'Paducah',
    'pbz' => 'Pittsburgh',
    'pdt' => 'Pendleton',
    'phi' => 'Philadelphia/Mount Holly',
    'pih' => 'Pocatello',
    'pqr' => 'Portland',
    'psr' => 'Phoenix',
    'pub' => 'Pueblo',
    'rah' => 'Raleigh',
    'rev' => 'Reno',
    'riw' => 'Riverton',
    'rlx' => 'Charleston',
    'rnk' => 'Blacksburg',
    'sew' => 'Seattle',
    'sgf' => 'Springfield',
    'sgx' => 'San Diego',
    'shv' => 'Shreveport',
    'sjt' => 'San Angelo',
    'sju' => 'San Juan',
    'slc' => 'Salt Lake City',
    'sto' => 'Sacramento',
    'tae' => 'Tallahassee',
    'tbw' => 'Tampa Bay',
    'tfx' => 'Great Falls',
    'top' => 'Topeka',
    'tsa' => 'Tulsa',
    'twc' => 'Tucson',
    'unr' => 'Rapid City',
    'vef' => 'Las Vegas'
   );

// set download method from main settings
($useCURL == true) ? $dldata = 'GetDataByCurl' : $dldata = 'getWSBystream';
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 02:32:43 PM
// set download method from main settings
($useCURL == true) ? $dldata = 'GetDataByCurl' : $dldata = 'getWSBystream';

// set the time zone
date_default_timezone_set("$ourTZ");

// check for map in folder
if($useWFOmap == true and !file_exists($ws_mapfolder.$mapname.$ift)){   // IF use map and the map is not in the folder
  $useWFOmap = false;                                                   //  turn off map and use drop down menu
  $noted .= "<!-- The required map is missing -->\n";                   //  display notice
}

// template map - ./folder/mapname.extension
$mainmap = $ws_mapfolder.$mapname.$ift;

// copy default WFO code
$wswfo = $NWSregion;

//  Set the DEFAULT weather story & image
(in_array($wswfo, $hpwxs)) ? $wxsurl =  'http://www.weather.gov/'.$wswfo.'/' : $wxsurl = 'http://www.weather.gov/'.$wswfo.'/weatherstory';

//  IF the WFO is using https
if(in_array($wswfo, $usehttps)){$wxsurl = preg_replace('/https:/', 'https:', $wxsurl);}  //   change http to https

// auto clean cache file
$defcachedata = $ws_cachefolder.'wsdata_'.$NWSregion.'.php';                   // default WFO data file
if(is_file($defcachedata) and filemtime($defcachedata) < strtotime("today")){  // IF default WFO cache file is found AND the filetime is older than today
  if($autocacheclean == true and $ws_cachefolder != './cache/'){               //  IF auto cache clean is true AND not in a default cache folder
    $cfs = array();                                                            //   set array
    $i = 0;                                                                    //   set counter
    foreach (glob($ws_cachefolder."ws*.*") as $cachedfile) {                   //   FOR EACH file in the cache folder
      if(filemtime($cachedfile) < strtotime("today")){                         //    IF the file time is older than today - before 12:00am
        $cfs[] = filesize($cachedfile);                                        //     set the cache file size
        unlink($cachedfile);                                                   //     delete the file
        $i++;                                                                  //     increment counter
      }
    }
    $dfs = array_sum($cfs);                                                    //   get the deleted cache file size sum
   $fb = getFileSize($dfs);                                                   //   set to mbytes or gbytes
    $noted .= "<!-- Cache files deleted: $i - $fb -->\n";                      //   display notice
  }
}

//   print_r($wxsurl);  echo "<br />\n";

// get submitted location
if(isset($_GET['i']) and strlen($_GET['i']) == "3"){                         // IF a WFO was selected
  $newwswfo = $_GET['i'];                                                    //  get the location
  $wswfo = htmlspecialchars(strip_tags($newwswfo));                          //  clean the location
  $wxsurl =  'http://www.weather.gov/'.$wswfo.'/weatherstory';               //  set the link
  if(in_array($wswfo, $hpwxs)){                                              //  IF the WS is on the WFO home page
    $wxsurl =  'http://www.weather.gov/'.$wswfo.'/';                         //   change the path
  }
  if(in_array($wswfo, $usehttps)){                                           //  IF the WFO is using https
    $wxsurl = preg_replace('/http:/', 'https:', $wxsurl);                    //   change http to https
  }
  // MAP CREATION
  if($useWFOmap){                                                            // IF using the map feature
    $mm = imagecreatefrompng($mainmap);                                      //  creat map from map template
    $orig_size = getimagesize($mainmap);                                    //  get original map size
    $red = imagecolorallocate($mm, 255, 0, 0);                                //  designate red because of county color
    imagecolortransparent($mm, $red);                                        //  make transparent color
    $im = imagecreatetruecolor($orig_size[0], $orig_size[1]);                //  create blank image the size of the map
    $id = imagecreatefrompng($wfomaps.$wswfo.'.png');                        //  create image from county alert png file
    imagecopymerge($mm, $id, 0, 0, 0, 0, $orig_size[0],$orig_size[1] ,100);  //  merge the county image to the map image
    imagedestroy($id);                                                       //  destroy the original county image
    imagepng($mm, $ws_cachefolder.$mapname.$ift,2);                          //  save the image
    imagedestroy($im);                                                       //  destroy the transparent image
    $swfoi = $ws_cachefolder.$mapname.$ift;                                  //  set selected WFO image
  }
}
else{                                                                          // OR ELSE if no selection, create default location map
  if($useWFOmap){
    if(!file_exists($ws_cachefolder.$mapname.$NWSregion.'.png')) {             // IF the WFO boundary image is found
      $mm = imagecreatefrompng($mainmap);                                      //  create image from US map file
      $orig_size = getimagesize($mainmap);                                      //  get original map size
      $red = imagecolorallocate($mm, 255, 0, 0);                              //  designate red because of county color
      imagecolortransparent($mm, $red);                                          //  make transparent color
      $im = imagecreatetruecolor($orig_size[0], $orig_size[1]);                //  create blank image the size of the map
      $id = imagecreatefrompng($wfomaps.$wswfo.'.png');                        //  create image from county alert png file
      imagecopymerge($mm, $id, 0, 0, 0, 0, $orig_size[0],$orig_size[1] ,100);  //  merge the county image to the map image
      imagedestroy($id);                                                       //  destroy the original county image
      imagepng($mm, $ws_cachefolder.$mapname.$NWSregion.'.png',2);             //  save the image
      imagedestroy($im);                                                       //  destroy the transparent image
    }
    $swfoi = $ws_cachefolder.$mapname.$NWSregion.'.png';                       //  set default WFO image
  }
}

// get submitted image
if(isset($_GET['ifn'])){                                                          // IF a headline was selected
  $imName = htmlspecialchars(strip_tags($_GET['ifn']));                           //  clean up the name
  $wxsimage = 'http://www.weather.gov/images/'.$wswfo.'/wxstory/'.$imName.'.png'; //  set image path
  $noted .= "<!-- $imName selected -->\n";                                        //   display notice
}

// create unique cache filenames
$wsimg = $ws_cachefolder.'wsimg_'.$wswfo.'.png';           // Weather Story image
$ws_cachefile = $ws_cachefolder.'wsdata_'.$wswfo.'.php';   // Weather Story text

// update cache file policy
if(file_exists($ws_cachefile)) {                   // IF the data cache file exists
  $cft = filemtime($ws_cachefile);                 //   get cache file last modified time
  $cfAge = $uts - $cft;                            //   get cache file age in seconds
  if($cfAge < $updateTextTime) {                   //   IF cache file has not expired
    $updateCache = false;                          //     don't update
    $noted .= "<!-- Cached data displayed -->\n";  //     display notice
  }
  if(!empty($_GET['mu'])) {                        //   IF you want to manually update the report   webpagefilename.php?mu=1
    $updateCache = true;                           //     set update cache
    $noted .= "<!-- manually updated -->\n";       //     display notice
  }
}

// IF the WFO code is in the above array, set the location
if(array_key_exists($wswfo, $fo)){
  $nfo = $fo[$wswfo];
}

if($updateCache) {                                                                     // IF the cache file needs updating
  if(!$html = $dldata($wxsurl)) {                                                      //  IF the weather story is not found
    $noted .= "<!-- First attempt in getting NWS URL data failed -->\n";               //   create note
    sleep(1);                                                                          //   wait a second !
    if(!$html = $dldata($wxsurl)) {                                                    //   IF the second chance WS fails
      sleep(1);                                                                        //    wait a second...
      $noted .= "<!-- Second attempt in getting NWS URL data failed -->\n";            //    create note
      if(!$html = $dldata($wxsurl)) {                                                  //    IF the last chance to get the WS failed
        $html = '';                                                                    //     set data to null
        $noted .= "<!-- FAILURE:  Could not get the WS data after 3 attempts -->\n";   //     create note
      }
    }
  }
 
  // fix characters
  $html = preg_replace('//', '&deg;', $html);                                         //  change it to an entity
  $html = preg_replace('//', '\'', $html);                                            //  change stray character
  $html = preg_replace('/<u>/', '', $html);                                            //  fix error
  $html = preg_replace('/<\/u>/', '', $html);                                          //  fix error
  $html = preg_replace('/<br>/', '<br />', $html);                                     //  fix error

  // MAIN IMAGE URL
  preg_match('|c-tab__content">.*image"><img s.*"(.*)" style|Uis', $html, $image);     //  search for the image
  if(isset($image[1])){                                                                //  IF the image is available
    $iurl = $image[1];                                                                 //   pick out the image URL
    if(!preg_match("|http|",$iurl)) {$iurl = 'http://www.weather.gov'.$iurl;}
    $emi  = explode("/", $iurl);                                                       //   split up the URL
    $imgMn = array_pop($emi);                                                          //   get file name from the last array
    $ifn = substr($imgMn, 0, -4);                                                      //   cut off the extension - image file name w/o extension
    $ift = substr($imgMn, -3, 3);                                                      //   get the image file type/extension
    $di = $dldata($iurl);                                                              //   get the image
    $wxsimage = $ws_cachefolder.'wsimg_'.$wswfo.'_'.$ifn.'.'.$ift;                     //   assemble image cache file name
    $wsif = fopen($wxsimage, 'w');                                                     //   open weather story image file
    fwrite($wsif, $di);                                                                //   write image file to cache folder
    fclose($wsif);                                                                     //   close weather story image file
    $noted .= "<!-- Weather Story image downloaded -->\n";                             //   display remark

    // MAIN DESCRIPTION TEXT
    preg_match('|is-active">.*description">(.*)</div>|Uis', $html, $story);            //  search for the story
    (isset($story[1])) ? $wsdata = $story[1] :  $wsdata = '';                          //  IF the story is found, set variable

    // remvoe added non-story information
   if($wsdata <> '' and preg_match('/<hr>/Uis', $wsdata)){                            //  IF data shows a horizontal rule
      $wsdata = preg_replace('/<hr>.*/', ' +more', $wsdata);                           //   delete the hotizontal line and everythig after it
   }
    $wsdata = preg_replace("/target='_blank'/", 'onclick="window.open(this.href,\'_blank\');return false;"', $wsdata);  //  fix to validate
   
    if(mb_detect_encoding($wsdata) == 'UTF-8'){                                        // IF character encoding is set to URF-8
      $wsdata = html_entity_decode(strip_tags($wsdata));                               //  decode story text html enities
      $wsdata = htmlentities($wsdata);                                                 //  convert all story text html entities
      $noted .= "<!-- UTF-8 was detected in the main story -->\n";                     //  create note
    }

//  print_r($wsdata);  echo "<br />\n";
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 02:33:41 PM
Quote
Quote
// MAIN HEADLINE
    preg_match('|c-tabs-nav__link is-active"><span>(.*)</span>|Uis', $html, $hdln);    //  search for the story headline
    (isset($hdln[1])) ? $wshdlne = $hdln[1] : $wshdlne = '';                           //  IF the headline is found, set variable
    $wshdlne = html_entity_decode($wshdlne);                                           //   decode headline html enities
    $wshdlne = preg_replace('/ & /', ' &amp; ', $wshdlne);                             //   convert headline html entities
    $mainStory[$ifn] = array($wshdlne, $wsdata, $iurl, $wxsurl, $wxsimage, $ift, $ifn, $wswfo, $nfo);  //  array for cache file
    if($wshdlne <> ''){                                                                //  IF there is a headline, create table div
      $hdlnr[] = '     <td style="text-align: center; background-color:#F0F7FF; padding: 6px 0px 6px;"><a href="'.
                  $_SERVER['PHP_SELF'].'?i='.$wswfo.'&amp;ifn='.$ifn.'" title="'.$wshdlne.
                  '" style="text-decoration: none; color: #0071BC; font-size: 1.3em;">'.$wshdlne.'</a></td>';
    }
    else{
      $hdlnr[] = '     <td style="text-align: center; background-color:#F0F7FF; padding: 6px 0px 6px;"><a href="'.
                  $_SERVER['PHP_SELF'].'?i='.$wswfo.'&amp;ifn='.$ifn.'" title="'.$wshdlne.
                  '" style="text-decoration: none; color: #0071BC; font-size: 1.3em;">Weather Story</a></td>';
   }

    // ALTERNATE HEADLINE & DESCRIPTION & LINK
    preg_match_all('|c-tabs-nav__link"><span>(.*)</span>|Uis', $html, $hdlnAlt);         //  search for any ALTERNATE story headlines
    if(!empty($hdlnAlt[1])){                                                             //  IF any alternative headlines are found
      preg_match_all('|c-tab">.*description">(.*)</div>|Uis', $html, $altstory);         //   get the story
      preg_match_all('|c-tab">.*image"><img src="(.*)" style|Uis', $html, $altImage);    //   get the image URL
      foreach($hdlnAlt[1] as $ahk => $ahv){                                              //   FOR EACH alternative headline
        $ai = $altImage[1][$ahk];                                                        //    get the alternate image URL
        if(!preg_match("|http|",$ai)) {$ai = 'http://www.weather.gov'.$ai;}              //    IF the alternate image URL is incomplete, add pefix
        $eai = preg_split('/\//', $ai);                                                  //    split up the URL
        $imgalt = array_pop($eai);                                                       //    get the file name and extension
        $imgAlt = substr($imgalt, 0, -4);                                                //    cut off the extension - image file name w/o extension
        $aift = substr($imgalt, -3, 3);                                                  //    get the image file type/extension
        $awxsimage = $ws_cachefolder.'wsimg_'.$wswfo.'_'.$imgAlt.'.'.$aift;              //    assemble image cache file name
        $wshdlne = $ahv;                                                                 //    get alternate headline
        $wshdlne = html_entity_decode($wshdlne);                                         //    decode stray headline html enities
        $wshdlne = preg_replace('/ & /', ' &amp; ', $wshdlne);                           //    convert headline html entities
        $altstry = html_entity_decode($altstory[1][$ahk]);                               //    decode stray story text html enities
        $altstry = preg_replace("/target='_blank'/", 'onclick="window.open(this.href,\'_blank\');return false;"', $altstry); //  fix to validate
 
        $altstry = preg_replace('/&/', '&amp;', $altstry);                               //  convert headline html entities
        if(mb_detect_encoding($altstry) == 'UTF-8'){                                     //  IF character encoding is set to URF-8
          $altstry = html_entity_decode(strip_tags($altstry));                           //   decode story text html enities
          $altstry = htmlentities($altstry);                                             //   convert all story text html entities
          $noted .= "<!-- UTF-8 was detected in an alternate story -->\n";               //   create note
        }
        $altStory[$imgAlt] = array($wshdlne, $altstry, $ai, $wxsurl, $awxsimage, $aift, $imgAlt, $wswfo, $nfo);  // create array
        $hdlnr[] = '     <td style="text-align: center; background-color:#F0F7FF; padding: 6px 0px 6px;"><a href="'.$_SERVER['PHP_SELF'].'?i='.
                  $wswfo.'&amp;ifn='.$imgAlt.'" title="'.$wshdlne.'" style="text-decoration: none; color: #0071BC; font-size: 1.3em;">'.$wshdlne.'</a></td>';
      }
    }
    $focf = fopen($ws_cachefile,'wb');                                          //  open the text cache file
    if($focf) {                                                                 //  IF cache file opens
      fwrite($focf, "<?php\n\n");                                               //   write
      fwrite($focf, '$mainStory = '.var_export($mainStory, 1).";\n\n");         //   write the main story data
      fwrite($focf, '$altStory = '.var_export($altStory, 1).";\n\n");           //   write the alternate story data
      fwrite($focf, '$nfo = '.var_export($nfo, 1).";\n\n");                     //   write the foreccast office name
      fwrite($focf, '$hdlnr = '.var_export($hdlnr, 1).";\n\n");                 //   write the headline data
      fwrite($focf, "\n?>");                                                    //   end of the php code
      fclose($focf);                                                            //   close the file
      $noted .= "<!-- Cache file written -->\n";                                //   display notice
    }
  }
  else {                                                                        //  OR ELSE if a weather story was not posted at the WFO
    $onfo = $nfo;                                                               //   copy WFO location name
    if(is_file($ws_cachefile) and $wswfo != $NWSregion){                        //   IF the data cache file exists AND it not the default WFO
      unlink($ws_cachefile);                                                    //    delete the file
      $noted .= "<!-- Weather Story is not available for $nfo -->\n";           //   display remark
      // create the headliner
      $hdlnr[] = '<td style="text-align: center; background-color:#F0F7FF; color:#FFF; padding: 6px 0px 6px;; font-size: 1.3em">Today\'s Weather Story has not been posted for '.$onfo.'</td>';
    }

     // IF a WFO is selected without a WS, create the headliner
    elseif(in_array($wswfo,$nonWorkingCodes)){
      $noted .= "<!-- $onfo does not have the new weather story -->\n";          //   display notice
      $hdlnr[] = '<td style="text-align: center; background-color:#F0F7FF; color:#FFF; padding: 6px 0px 6px;; font-size: 1.3em">'.$onfo.' does not have the Weather Story</td>';
    }

    // IF a weather story WFO without a weatherstory folder is selected, create the headliner
    elseif(in_array($wswfo,$hpwxs2)){
      $hdlnr[] = '<td style="text-align: center; background-color:#F0F7FF; color:#FFF; padding: 6px 0px 6px;; font-size: 1.3em">Today\'s Weather Story has not been posted for '.$onfo.'</td>';
      $noted .= "<!-- $onfo does not have the weather story in their home page -->\n"; //   display notice
    }
   
    // OR ELSE create the headliner
    else {
      $hdlnr[] = '<td style="text-align: center; background-color:#F0F7FF; color:#FFF; padding: 6px 0px 6px;; font-size: 1.3em">Today\'s Weather Story has not been posted for '.$onfo.'</td>';
      $noted .= "<!-- $onfo does not have the weather story -->\n"; //   display notice
    }
    $goodWFO = false;
  }
}
// end of updating cache file
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 02:36:13 PM
Quote
// set page title
$wstitle2 = '<span style="color:#0061AC;">'.strtoupper($wstitle).'</span><br />'.$nfo.'<br /><span style="font-size:60%; vertical-align: text-top;">Weather Forecast Office</span>';

// include the cache file
if(is_file($ws_cachefile)){
  include($ws_cachefile);
}

// get submitted image
if(isset($_GET['ifn']) and $wswfo){                                                       // IF the WFO was submitted
  $imgname = htmlspecialchars(strip_tags($_GET['ifn']));                                  //  get the WFO code
  if(!array_key_exists($imgname, $mainStory) and !array_key_exists($imgname, $altStory)){ //  IF the name is not a key in either array
    $mskey = key($mainStory);                                                             //   get the main story array key
   $imgname = $mskey;                                                                    //   change the image name to the mainstory name
   $altStory = $mainStory;                                                               //   change the alternate story to the main story
    $noted .= "<!-- An invalid file name was selected -->\n";                             //   display notice
  }
  $mskey = key($mainStory);                                               //  get the main story array key
  ($mskey != $imgname) ? $altStory = $altStory : $altStory = $mainStory;  //  IF the selected story is the same as the main story, set variable back to the main data
  $wsimg = $altStory[$imgname][4];                                        //  get the cached image file name
  $wswfo = $altStory[$imgname][7];                                        //  get the WFO code
  $wxsurl = $altStory[$imgname][3];                                       //  get the NWS story text link
  $wsdata = $altStory[$imgname][1];                                       //  get the story headline
  $nfo = $altStory[$imgname][8];                                          //  get the WFO location
  $imName = $altStory[$imgname][6];                                       //  use main story image file name
  $imagepath = $altStory[$imgname][4];                                    //  get the cached image path
  $wshdlne = $altStory[$imgname][0];                                      //  get the headline
  $wxsimage = $imagepath;                                                 //  copy the image cache path
  if(file_exists($imagepath)) {                                           //  IF the iamge cache file exists
    $cft = filemtime($imagepath);                                         //   get cache file last modified time
    $cfAge = $uts - $cft;                                                 //   get cache file age in seconds
    if($cfAge > $updateTextTime) {                                        //   IF cache file has expired
      if($mskey != $imgname) {                                            //    IF the image cache file does not exist
       $di = $dldata($altStory[$imgname][2]);                             //     get the image from the NWS
        $icf = fopen($imagepath, 'w');                                    //     open the image cache file
        fwrite($icf, $di);                                                //     write image file in cache folder
        fclose($icf);                                                     //     open the image cache fil
        $noted .= "<!-- Weather Story image downloaded ! -->\n";          //     display remark
      }
    }
  }
  else{                                                                   //  OR ELSE
    $di = $dldata($altStory[$imgname][2]);                                //   get the image
    $aicf = fopen($imagepath, 'w');                                       //   open the alternate image cache file
    fwrite($aicf, $di);                                                   //   write image file in cache folder
    fclose($aicf);                                                        //   close the file
    $noted .= "<!-- Weather Story image downloaded  -->\n";               //   display remark
  }
}
else {                                                                    // OR ELSE
  if($goodWFO){
    $curkey = key($mainStory);                                            //  ket main story key
    $wsimg = $mainStory[$curkey][4];                                      //  use main story image
    $wswfo = $mainStory[$curkey][7];                                      //  use main story WFO
    $wxsurl = $mainStory[$curkey][3];                                     //  use main story cached file
    $wsdata = $mainStory[$curkey][1];                                     //  use main story cached text
    $nfo = $mainStory[$curkey][8];                                        //  use main story cached location
    $imName = $mainStory[$curkey][6];                                     //  use main story image file name
    $wshdlne = $mainStory[$curkey][0];                                    //  use main story headline
  }
}

// Change headline colors after selection
$hdlrcount = count($hdlnr);                                                          // count the headlines
$hdlnrwidth = round($tablewdth / $hdlrcount);                                        // get width of headline from table width
foreach($hdlnr as $hk => $hv){                                                       // FOR EACH headline
  if(preg_match("|$imName|",$hv)) {                                                  //  IF the selected image is in the headline
    $hv = preg_replace('/-color:#F0F7FF/', '-color:#0071BC', $hv);                   //   change background color to blue
    $hv = preg_replace('/ color: #0071BC/', ' color:#FFF', $hv);                     //   change text color to white
    $hv = preg_replace('/td style="/', 'td style="width:'.$hdlnrwidth.'px; ', $hv);  //   adjust column width
  }
  else{                                                                              //  OR ELSE
    $hv = preg_replace('/ background-color:#F0F7FF;/', '', $hv);                     //   change background color to a light color
    $hv = preg_replace('/td style="/', 'td style="width:'.$hdlnrwidth.'px; ', $hv);  //   change column width
    $hv = preg_replace('/td style="/', 'td class="hdline" style="border-bottom: thin solid #0071BC; border-top: thin solid #0071BC; ', $hv);  //   change column width
  }
  $hdline .= $hv."\n";
}

// print_r($wswfo);  echo "<br />\n";
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 02:37:08 PM
Quote
// FUNCTION - get data cURL
function GetDataByCurl($url)    {
  global $noted;                                                          // set global
  $data = '';                                                             // set variable
  $ch = curl_init();                                                      // initialize a cURL session
  curl_setopt($ch, CURLOPT_URL, $url);                                    // connect to provided URL
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);                            // don't verify peer certificate
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:14.0) Gecko/20100101 Firefox/14.0.1  (.NET CLR 4.0.20506)');
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);                            // 3 sec connection timeout
  curl_setopt($ch, CURLOPT_TIMEOUT, 3);                                   // 2 sec data timeout
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                         // return the data transfer
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION , true);                        // follow HTTP 3xx redirects
  curl_setopt($ch, CURLOPT_NOBODY, false);                                // set nobody
  curl_setopt($ch, CURLOPT_HEADER, false);                                // do not pass headers to the data stream
  $data = curl_exec($ch);                                                 // execute session
  if(curl_error($ch) <> '') {                                             // IF there is an error
   $noted .= "<!-- Error: ". curl_error($ch) ." -->\n";                   //  display error notice
   $noted .= "<!-- cURL Error at $url -->\n";                             //  display error source notice
  }
  $header_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);                // set header information
  curl_close($ch);                                                        // close the cURL session
  if(preg_match('/text\/html|image\/png|image\/gif|image\/jpeg|image\/jpg/',$header_type)) {                           // IF text/html is found in the header
   $data = $data;                                                         //  set data
   $noted .= "<!-- cURL Data source: $url -->\n";                         //  display notice
  }
  else {                                                                  // OR ELSE
    $noted .= "<!-- cURL error source: $url -->\n";                       //  display error source notice
    $data = '';                                                           //  set data to null value
  }
  return $data;                                                           // return data
}// end GetDataByCurl


// FUNCTION - Get file contents
function getWSBystream($url) {
  global $noted;
  $hdropts = array('http' => array('method'=>"GET",
                                   "timeout" => 3,
                                   'header'=>"Cache-control: max-age=0\r\n" .
                                   "Connection: close\r\n" .
                                   "User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:14.0) Gecko/20100101 Firefox/14.0.1  (.NET CLR 4.0.20506)\r\n" .
                                   "Accept: text/html; image/png; image/gif; image/jpeg; image/jpg\r\n"
                                   )
  );
  $context = stream_context_create($hdropts);
  if(@$data = file_get_contents($url,false,$context)){
    $noted .= "<!-- Stream data source: $url -->\n";                        //  display notice
  }
  else{
    $data = '';
    $noted .= "<!-- Stream failure source: $url -->\n";                     //  display notice
  }
  return $data;
} // end function getWSBystream


// FUNCTION - File size
function getFileSize($bytes) {
  $precision = 2;
  $units = ['Bytes', 'Kilobytes', 'Megabytes', 'Gigabytes', 'Terabytes'];
  $i = 0;
  while($bytes > 1024) {
    $bytes /= 1024;
    $i++;
  }
  return round($bytes, $precision) . ' ' . $units[$i];
}

?>
<table border="0" cellspacing="0" cellpadding="0" style="width: <?php echo $tablewdth ?>px; margin: 20px auto 0px auto;">
 <tr>
  <td style="text-align:center;"><a href="<?php echo $wxsurl; ?>" onclick="window.open(this.href,'_blank');return false;" title="Click to view this forecast office" style="text-decoration: none; color: inherit;"><span style="font-size:20px; letter-spacing:2px;"><b><?php echo $wstitle2 ?></b></span></a></td>
 </tr>
</table>
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 02:38:03 PM
Then assuming the rest is ok I have not changed it.
Title: Re: Curly's Wx Story script
Post by: tmabell on July 17, 2020, 03:17:29 PM
That is old code.  For starters try changing all references from http://www.weather.gov/ (http://www.weather.gov/)  to https://www.weather.gov/ (https://www.weather.gov/) The script will likely jump back to life.  If it doesn't I posted the most recent version a few posts up in this thread a while back.  Try that version and make the changes you require.
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 03:48:15 PM
also assuming all folders need to be in the same place. Which they are.

is the recall line still the same?

I also changed the number from 0 to 5.


Give it time but nothing yet.
Title: Re: Curly's Wx Story script
Post by: tmabell on July 17, 2020, 04:02:31 PM
Did you try the version I posted?
Title: Re: Curly's Wx Story script
Post by: chief-david on July 17, 2020, 04:25:04 PM
Yes the one from Mar 14, 2018.
Title: Re: Curly's Wx Story script
Post by: tmabell on July 17, 2020, 04:28:28 PM
Check your PM's
Title: Re: Curly's Wx Story script
Post by: chief-david on July 27, 2020, 12:13:57 PM
Nothing I have tried has worked.

I was able to Iframe tmabell's info to my page-but that is not fair to his system.

He made/edited a script for me.
I am thinking either an issue with the call script or my template. So I have removed it.

Something else has to be the issue. Please help.

edit: here is my page with everything removed but weather story
https://rms-weather.rdale.org/weatherstory.php

I did use this for the call script and it allowed the page to finish.
<?php include("https://rms-weather.rdale.org/ChiefDavid1.php"); ?>

The frame on there is an iframe of my ChiefDavid1 page. Nothing in it.
Title: Re: Curly's Wx Story script
Post by: tmabell on July 28, 2020, 09:50:52 PM
We know the script works because as you stated, it works on my server here.  Check your server's error logs.  When your script is viewed from the outside I get this (using Chromes Developer Tools) "Failed to load resource: the server responded with a status of 500 (Internal Server Error)"

Hopefully, the server's error log will provide a clue.
Title: Re: Curly's Wx Story script
Post by: chief-david on July 28, 2020, 10:37:08 PM
I will get ahold of IT and see if they can do anything. I do know there are no images in any folder.

Title: Re: Curly's Wx Story script
Post by: chief-david on August 01, 2020, 07:17:16 PM
There has to be an issue with server.
So I was able to iframe the weather story page to focus on the story part and not see the rest of the page.
Title: Re: Curly's Wx Story script
Post by: the beteljuice on August 01, 2020, 08:38:01 PM
Try putting this at the top of the script and see what comes back ..
Code: [Select]
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
error_reporting(E_ALL);