Author Topic: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue  (Read 717 times)

0 Members and 1 Guest are viewing this topic.

Offline sam2004gp

  • Mount Crawford, Virginia
  • Forecaster
  • *****
  • Posts: 2865
  • Weeeeeeeee!!!!
    • Mount Crawford Weather, VA
Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« on: January 26, 2021, 08:21:57 AM »
So recently I noticed that my "weather alerts" Stopped working on my website.  And what I noticed is that the cron that I have to run the atom feed was firing off every 5 minutes as before.

But when I check the Atomstatus.txt file left on my remote server.  I see that it has failed to retrieve the alert Info.

But when I run the php script "refresh" manually by typing in the url into my browser it works fine and pulls the current weather alerts.

So it is obvious the cron job and the script are working, but something has changed and it does not allow me to automatically update as it had before.  It only retrieves the weather alerts when I think to manually update it and invoke the php script myself. 

I have went to my server control panel and removed the cron jobs and recreated them with no avail.  But again they do appear to be running as shown in the file "Failed-AtomStauts.txt" versus, when I Manually refresh shown in the file "Manual-Success-AtomStatus.txt"

I am running version 4.91 of the script.  Any help would be appreciated.
« Last Edit: January 26, 2021, 08:30:58 AM by sam2004gp »
SAM --->>> http://www.mountcrawfordweather.org
OS WMR-968 with a Dedicated PWS Weather Computer running VWS v13.01 p09


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #1 on: January 26, 2021, 10:39:03 AM »
Since the script works when run manually (via your website) and fails when using a cron job, I suspect that the cron job is running a down-level version of PHP (which doesn't support curl/TLS1.2 for https).  In the failed log via cron it shows
Quote
* CURL Network error: SSL connect error

Would you post how the cron job is run (the cron command line) and if it's using a script, what the contents of that script are?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline sam2004gp

  • Mount Crawford, Virginia
  • Forecaster
  • *****
  • Posts: 2865
  • Weeeeeeeee!!!!
    • Mount Crawford Weather, VA
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #2 on: January 26, 2021, 10:58:17 AM »
Thanks Saratoga, for your suggestion it may have changed the level of PHP, but it was running fine for several years until last week.  But anyways I hope the following helps out a bit more.   :grin:


I am hosting with godaddy, and the control panel states it is using PHP 5.3 and there are the options of upgrading the server to 5.6.

the command line from godaddy, that I am using for my cron is   /web/cgi-bin/php5 "$HOME/html/AtomAlerts/AtomFeed.php5"

This command line was created by their interface by "Browsing" to the php script I wanted to run.  See attached pic.

The url for a manual refresh is http://www.mountcrawfordweather.org/AtomAlerts/AtomFeed.php5

I have also attached my version of the scripts slightly modified years ago for my website.



SAM --->>> http://www.mountcrawfordweather.org
OS WMR-968 with a Dedicated PWS Weather Computer running VWS v13.01 p09


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #3 on: January 26, 2021, 11:15:06 AM »
You need to find where the modern version of php is running from (same version as runs your website).

Put the following in a new .php page on your site
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Whereis</title>
</head>
<body>
<pre>
<?php
print "Document root ".$_SERVER['DOCUMENT_ROOT']."\n";
print 
"This PHP is running at ".PHP_BINDIR."/php \n";
print 
"PHP ".PHP_VERSION." built for ".PHP_OS."\n";
?>

</pre>
</body>
</html>
and run the script via your browser.  The "This PHP is running at {full-path-to-php}" shows the full path to the PHP executable you need to run, so your cron command would be
Code: [Select]
{full-path-to-php} -q "$HOME/html/AtomAlerts/AtomFeed.php5"The scripts likely don't have to be modified, just the updated version of php has to run the script.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline sam2004gp

  • Mount Crawford, Virginia
  • Forecaster
  • *****
  • Posts: 2865
  • Weeeeeeeee!!!!
    • Mount Crawford Weather, VA
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #4 on: January 26, 2021, 12:19:25 PM »
I did as you suggested. 


I placed the "Where.php" in my website

http://www.mountcrawfordweather.org/Where.php

and got the location returned to me.

I then created a new cron job with the following as the path:
/usr/local/php5_3/bin/php -q "$HOME/html/AtomAlerts/AtomFeed.php5"

It ran and again returned an "AtomStatus.txt" file stating that it had ran, but it had failed to retrieve the data.

 ](*,)

SAM --->>> http://www.mountcrawfordweather.org
OS WMR-968 with a Dedicated PWS Weather Computer running VWS v13.01 p09


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #5 on: January 26, 2021, 12:22:51 PM »
Yep, PHP5.3 won't cut it any more.. you'll need to have the site at 5.6 or even 7.x to work correctly with https via curl to external websites (like NWS sites).  The PHP5.3 doesn't have support for TLS1.2 so it can't establish https connections to sites requiring TLS1.2 or above for connection.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline sam2004gp

  • Mount Crawford, Virginia
  • Forecaster
  • *****
  • Posts: 2865
  • Weeeeeeeee!!!!
    • Mount Crawford Weather, VA
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #6 on: January 26, 2021, 12:27:20 PM »
Ok I see the option on my website control panel and i will update it to 5.6.  Hopefully that will fix it.

Will post back here when I get results.
SAM --->>> http://www.mountcrawfordweather.org
OS WMR-968 with a Dedicated PWS Weather Computer running VWS v13.01 p09


Offline sam2004gp

  • Mount Crawford, Virginia
  • Forecaster
  • *****
  • Posts: 2865
  • Weeeeeeeee!!!!
    • Mount Crawford Weather, VA
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #7 on: January 26, 2021, 01:35:10 PM »
Updated to 5.6 php and still fails with the same results.

I have included a copy of my php.ini in case that is also usefull. 

Not sure where to go from here.  The godaddy rep was trying to talk me into going from their linux hosting to a "Cpanel" with a version of php7 installed.  I already see that this update to 5.6 has now broke my other page at http://www.mountcrawfordweather.org/forecast_trop.php5

This is getting very frustrating.   ](*,) :sad:

SAM --->>> http://www.mountcrawfordweather.org
OS WMR-968 with a Dedicated PWS Weather Computer running VWS v13.01 p09


Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #8 on: January 26, 2021, 01:47:42 PM »
Would highly recommend you update to 7.x. SO much more security and efficiency with the PHP core...

Offline K6GKM

  • CamWX.com
  • Contributor
  • ***
  • Posts: 125
    • CamWX
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #9 on: January 26, 2021, 03:04:11 PM »
FWIW, I use a third-party to run my cron jobs, including running my nws-alerts.php.  Check out cron-job.org.  It's free, and can run as frequently as every minute. 
« Last Edit: February 24, 2021, 01:15:56 PM by K6GKM »
Grant Miles
Camarillo, CA, USA
Owner/Admin - CamWX.com
SKYWARN Spotter
Station Hardware: Davis Vantage Pro2 Plus w/ 24hr FARS
Station Software: Weather Display, Weather Message, FWI Calculator, StartWatch, with social media & messaging automation using Make.com, Twilio, and Brevo.


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #10 on: January 26, 2021, 03:33:36 PM »
Updated to 5.6 php and still fails with the same results.

I have included a copy of my php.ini in case that is also usefull. 

Not sure where to go from here.  The godaddy rep was trying to talk me into going from their linux hosting to a "Cpanel" with a version of php7 installed.  I already see that this update to 5.6 has now broke my other page at http://www.mountcrawfordweather.org/forecast_trop.php5

This is getting very frustrating.   ](*,) :sad:


The
Quote
Warning: include() [function.include]: http:// wrapper is disabled in the server configuration
is due to two things:
1) PHP has (wisely) set allow_url_include = off to prevent an easy path for cross-site scripting attacks to your website
2) your page likely has include('http://.....'); in it and that is now disallowed.  You can get the same effect (safely) by changing
Code: [Select]
include('http://...); to
Code: [Select]
readfile('http://...'); which will safely get the external page and echo the contents directly into your page.  And, I agree, PHP7 is SO much better/faster.  And having a cPanel hosting will get you out of an ancient PHP version.. I'd go for it.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #11 on: January 26, 2021, 03:48:41 PM »

Quote
And having a cPanel hosting will get you out of an ancient PHP version.. I'd go for it.
@Sam
I am also with GoDaddy and switched over to cPanel a couple years ago which they offered at no additional cost, and have found that very helpful.  Then later upgraded to PHP v7.  That did cause some issues that needed addressing.


Enjoy,
Paul








Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #12 on: January 26, 2021, 04:41:39 PM »
Converting from PHP5 to PHP7 may necessitate some changes in older scripts:

1) the split() function is removed .. replace with explode() (split was used in old versions of top.php and ajax-dashboard.php)
2) the each() function is removed, so constructs like
Code: [Select]
while (list($key, $val) = each($array)) { need to change to
Code: [Select]
foreach ($array as $key => $val) { to work.  The each() function was used in old versions of common.php and several older scripts of mine like buoy-data.php.
3) older Class code allowed the class name to also be used as the main function name .. now the main function name has to be __construct to be used.  Also, the __autoload part has to be converted to use  spl_autoload_register() instead.
4) php versions before 5.6 likely don't support TLS1.2, so may have issues with scripts fetching data from external websites that require TLS1.2 for connections.

Those are the key gotcha's I've found (and corrected in all my current scripts) so far.  The moral is:  Keep your scripts up-to-date to support changes by your hoster with PHP version upgrades. 
« Last Edit: January 26, 2021, 04:46:19 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline sam2004gp

  • Mount Crawford, Virginia
  • Forecaster
  • *****
  • Posts: 2865
  • Weeeeeeeee!!!!
    • Mount Crawford Weather, VA
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #13 on: January 26, 2021, 05:43:45 PM »

The
Quote
Warning: include() [function.include]: http:// wrapper is disabled in the server configuration
is due to two things:
1) PHP has (wisely) set allow_url_include = off to prevent an easy path for cross-site scripting attacks to your website
2) your page likely has include('http://.....'); in it and that is now disallowed.  You can get the same effect (safely) by changing
Code: [Select]
include('http://...); to
Code: [Select]
readfile('http://...'); which will safely get the external page and echo the contents directly into your page.  And, I agree, PHP7 is SO much better/faster.  And having a cPanel hosting will get you out of an ancient PHP version.. I'd go for it.

Ok the readfile suggestion worked for the 2nd page failure.  Now back to original issue at hand.   ](*,)
SAM --->>> http://www.mountcrawfordweather.org
OS WMR-968 with a Dedicated PWS Weather Computer running VWS v13.01 p09


Offline sam2004gp

  • Mount Crawford, Virginia
  • Forecaster
  • *****
  • Posts: 2865
  • Weeeeeeeee!!!!
    • Mount Crawford Weather, VA
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #14 on: January 26, 2021, 06:03:36 PM »
FWIW, I use a third-party to run my cron jobs, including running my news-alerts.php.  Check out cron-job.org.  It's free, and can run as frequently as every minute.

Ok partial success.  I disabled the Cron Jobs on godaddy's server, and created the a new cron job using this recommended site.  Now it appears to be working.  So it must be something with godaddy's cron server. Not sure what, but thankfull it works for now.
SAM --->>> http://www.mountcrawfordweather.org
OS WMR-968 with a Dedicated PWS Weather Computer running VWS v13.01 p09


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #15 on: January 27, 2021, 09:54:35 AM »
So, based on your Where.php output, your PHP5.6 is located at /usr/local/php5_6/bin/php and that is what you use for the php command in cron.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline sam2004gp

  • Mount Crawford, Virginia
  • Forecaster
  • *****
  • Posts: 2865
  • Weeeeeeeee!!!!
    • Mount Crawford Weather, VA
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #16 on: January 27, 2021, 10:31:07 AM »
Yes, and godaddy's server would run the php, but it would never successfully retrieve the NWS data.  It only retrieves the data when I run the php manually or I use the automated cron services from cron-job.org that K6GKM recommended. 
SAM --->>> http://www.mountcrawfordweather.org
OS WMR-968 with a Dedicated PWS Weather Computer running VWS v13.01 p09


Offline CNYWeather

  • Forecaster
  • *****
  • Posts: 2297
    • CNYWeather
Re: Curly's AtomFeed script - NWS ATOM XML FEED ALERTS - Issue
« Reply #17 on: January 27, 2021, 11:51:42 AM »
I had issues at the start when I got moved to a new GoDaddy server.

I've had this cron job running well over a year without any issues.
I've got this in the command for running the cron job. Not sure if this would help:

Code: [Select]
php -f /home/myCpanelLogInHere/public_html/nws-alerts.php
Tony