cloudy cloudy

Author Topic: nws-alerts.php broke - need help  (Read 626 times)

0 Members and 1 Guest are viewing this topic.

Offline K3JAE

  • Posts: 1,007
  • CoCoRaHS: TN-CR-7; WxUngrd: KTNBRUCE2; CWOP: AT066
  • Carroll County, TN, USA
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Firefox 50.0
    • K3JAE's Weather Station
nws-alerts.php broke - need help
« on: January 11, 2017, 02:02:09 AM »
A little quick history:

All was working flawlessly until one day in early Dec 2016 it became apparent someone had gotten into my web server and hacked the blazes out of it using Joomla (?) after "fighting" with the web host personnel and their insistence that no one had access to my site unless I gave out the passwords (which I would never do even at gun point or threat of anything) they finally admitted someone had hacked their system and was messing with all the site... hacking them.

Also of note, every one of my scheduled CRON jobs were deleted and removed. The php.ini and htaccess files were edited/modified once per day at exactly 01:30 like clockwork. This is what saved my rear with the hosting service after they checked for MalWare on my site (reporting clean) and finally realizing the site was being redirected off site to another server.

In my attempt to circumvent the consistent re-directing and re-writing of my php.ini and htaccess files I literally deleted the entire site including every directory and sub directory and left it to sit idle over Christmas. 26 Dec I re-uploaded my entire website. All went well with a few minor bumps.

Now all is well save my CRON jobs. I have re-entered them and they appear to be working yet the nws-alerts header on the index page is NOT updating... however, if I manually run the script NWS-ALERTS.PHP it works exactly as it is supposed to and updates the index page as is expected.

My CRON is currently set up as follows:
*/3 * * * * php -q /root/personal/public_html/nws-alerts.php > nws-alerts-status.txt 2>&1 (the nws-alerts-status.txt is so I can see if there are any errors encountered). Once the script is working properly I shall remove the writing of the nws-alerts-status.txt. NOTE: The directory structure:  /root/personal/public_html is NOT a true representation of the actual path as they were changed for security purposes... PHP version running is 5.6.1

The result of the nws-alerts-status.txt is as follows:
<!-- nws-alerts.php - 1.16 - 09-Jan-2013 - NWS Public Alerts core file -->
<!-- Cron job enabled -->
<!-- Preliminary codes checked: 48 -->
<!-- Preliminary data cull: 14.6011 seconds -->
<!-- Average cull per code: 0.3042 seconds -->
<!-- Primary alerts downloaded: 0 -->
<!-- Primary data cull: 0.0000 seconds -->
<!-- Cache file updated: Tue 18:51 CST -->
<!-- Alert box data file updated -->
<!-- RSS feed file updated -->
<!-- Total script process time: 14.6037 seconds -->

In the error_Log.txt in my root I have the following error:
PHP Notice:  Undefined index: SERVER_NAME in /root/personal/public_html/nws-alerts.php

When checking the proper directories (cache) all the files show that have been updated with the last 3 minutes depending on time elapsed since last run.

So my question is simply... if I am getting no apparent errors, the script is presumably operating properly, why is it not updating on the index page unless I actually and MANUALLY type it in the web browser (http://www.k3jae.com/nws-alerts.php) ... then it works EXACTLY as it is supposed to?

I can let the script run over an hour in the CRON and nothing changes on the webpage... run it via the browser and it immediately updates the index page with current info.   :?
« Last Edit: January 11, 2017, 05:15:38 AM by K3JAE »


73's de K3JAE
John
K3JAE Weather Station

Online Weather Display

  • Posts: 81,908
  • Davis VP2
  • New Zealand
  • OS/Browser:
  • Win NT 10.0
  • Chrome 55.0.2883.87
    • Weather Display
Re: nws-alerts.php broke - need help
« Reply #1 on: January 11, 2017, 10:43:25 AM »
is this post in the correct section of the forum?

Offline K3JAE

  • Posts: 1,007
  • CoCoRaHS: TN-CR-7; WxUngrd: KTNBRUCE2; CWOP: AT066
  • Carroll County, TN, USA
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Firefox 50.0
    • K3JAE's Weather Station
Re: nws-alerts.php broke - need help
« Reply #2 on: January 11, 2017, 06:37:34 PM »
Apologize...


73's de K3JAE
John
K3JAE Weather Station

Offline saratogaWX

  • Global Moderator
  • Posts: 5,667
  • Ken True
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
  • OS/Browser:
  • Win NT 10.0
  • Firefox 50.0
    • Saratoga Weather
Re: nws-alerts.php broke - need help
« Reply #3 on: January 11, 2017, 11:09:46 PM »
It could be that the default version of PHP when run as 'php -q /root/personal/public_html/nws-alerts.php > nws-alerts-status.txt 2>&1' in cron is actually PHP 5.2 (or even PHP 4.x).  Check your server for a link to PHP 5.3+ and include it in the path.

On my 1and1 shared server I had to use '/usr/bin/php5.5' as the command in cron to get the correct PHP version running.
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline K3JAE

  • Posts: 1,007
  • CoCoRaHS: TN-CR-7; WxUngrd: KTNBRUCE2; CWOP: AT066
  • Carroll County, TN, USA
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Firefox 50.0
    • K3JAE's Weather Station
Re: nws-alerts.php broke - need help
« Reply #4 on: January 11, 2017, 11:25:43 PM »
I was on the phone late last night --- or early this AM depending on how you want to look at it... and the tech made the following statement:
"You might have to actually code in the SERVER_NAME in the script you are running." This is a bit confusing as I am not keenly aware what SERVER_NAME is looking for... www.k3jae.com, k3jae.com, literal path to the script?

My understanding then is that this would require me to edit both the Settings.php and/or the nws-alerts.php (at around line 550) with a literal path.... I did try both but not sure I am following the proper convention when assigning a literal link to the variable SERVERNAME or SERVER_NAME.

He made mention that the servers were just upgraded to php5.5 yet I am able to install/run 5.6??

The error log is showing the following: [11-Jan-2017 17:21:16 America/Chicago] PHP Notice:  Undefined index: SERVER_NAME in /root/personal/public_html/nws-alerts.php on line 551

My settings.php is as follows: $SITE['SERVERNAME']  = $_SERVER['SERVER_NAME'];
Line 551 of nws-alerts.php reads: : <link>'.$_SERVER['SERVER_NAME'].'/</link> and the VAR is called again at Line 562: <link>href="http://'.$_SERVER['SERVER_NAME'].'/"</link>

The nws-alerts-config.php file is as follows:
$cacheFileDir  = './cache/';                  // Default cache file directory
$icons_folder  = './alert-images';            // Folder that contains the icons. No slash on end
// File Names
$cacheFileName = 'wxNWS-alertsMainData.php';  // Main data cache file name
$aboxFileName  = 'wxNWS-alertsBoxData.php';   // Alert box cache file name
$iconFileName  = 'wxNWS-alertsIconData.php';  // Big icons cache file
$alertURL      = 'wxNWS-Details.php.php';     // Web page file name for complete details
$summaryURL    = 'wxNWS-AlertSummaries.php';  // Web page for the alert summary


If I understand correctly... the cacheFileName should be written in subdirectory "public_html/cache/" correct? If this is a true statement then the script is not writing properly as it is writing into a cache directory at the very root of the site.

In response to your suggested answer: The technician made a small adjustment to the CRON as follows: */3 * * * * /usr/bin/php -e -f /root/personal/public_html/nws-alerts.php >> nws-alerts-status.txt 2>&1. The  ">> nws-alerts-status.txt" is used to append, rather than overwrite the nws-alerts-status.txt for review purposes. I have not tried yet, adding 5.6 to the php but will do so in a few and will report back in a few minutes.

------ UPDATE ------
Changed the CRON to */3 * * * * /usr/bin/php5.6 -e -f /root/personal/public_html/nws-alerts.php >> nws-alerts-status.txt 2>&1 places the script in "JAILSHELL" meaning it broke.

nws-status.status.txt is as follows:
<!-- Cron job enabled -->
<!-- Preliminary codes checked: 48 -->
<!-- Preliminary data cull: 18.1352 seconds -->
<!-- Average cull per code: 0.3778 seconds -->
<!-- Primary alerts downloaded: 1 -->
<!-- Primary data cull: 0.1404 seconds -->
<!-- Cache file updated: Wed 17:36 CST -->
<!-- Alert box data file updated -->
<!-- RSS feed file updated -->
<!-- Total script process time: 18.2825 seconds -->
/usr/local/cpanel/bin/jailshell: /usr/bin/php5.6: No such file or directory
/usr/local/cpanel/bin/jailshell: /usr/bin/php5.6: No such file or directory
/usr/local/cpanel/bin/jailshell: /usr/bin/php5.6: No such file or directory
/usr/local/cpanel/bin/jailshell: /usr/bin/php5.6: No such file or directory
/usr/local/cpanel/bin/jailshell: /usr/bin/php5.6: No such file or directory

I removed the 5.6 from the php command line and the CRON appears to complete properly...
<!-- nws-alerts.php - 1.16 - 09-Jan-2013 - NWS Public Alerts core file -->
<!-- Cron job enabled -->
<!-- Preliminary codes checked: 48 -->
<!-- Preliminary data cull: 13.1845 seconds -->
<!-- Average cull per code: 0.2747 seconds -->
<!-- Primary alerts downloaded: 1 -->
<!-- Primary data cull: 0.2071 seconds -->
<!-- Cache file updated: Wed 17:57 CST -->
<!-- Alert box data file updated -->
<!-- RSS feed file updated -->
<!-- Total script process time: 13.3931 seconds -->
« Last Edit: January 11, 2017, 11:59:21 PM by K3JAE »


73's de K3JAE
John
K3JAE Weather Station

Offline K3JAE

  • Posts: 1,007
  • CoCoRaHS: TN-CR-7; WxUngrd: KTNBRUCE2; CWOP: AT066
  • Carroll County, TN, USA
  • OS/Browser:
  • Win 7/Srvr 2008R2
  • Firefox 50.0
    • K3JAE's Weather Station
Re: nws-alerts.php broke - need help
« Reply #5 on: January 12, 2017, 11:56:39 AM »
OK, after hammering away at the host tech support and finally, after threatening to pull someone's teeth and hear out got to a SENIOR tech person.

Seems you were on the right track and the directory structure was "revamped" and of course no one was told. The PROPER directory is now:
"/usr/php/56/usr/bin/php" so that seems to have resolved the issue. It took their LEVEL5 technician to finally advise me of the directory restructuring!!!

I will continue to monitor this closely. It would be nice if the stinking host would advise that a directory structure was changed.. and even more so tell their entry level tech support personal of this change instead of having a week plus of discussions with them only to be told it was MY fault and they will not support CRON jobs etc.

I will update, as required should this issue continue to be unresolved. I will allow a few days and if errors go away I will then close this thread.


73's de K3JAE
John
K3JAE Weather Station

Online Weather Display

  • Posts: 81,908
  • Davis VP2
  • New Zealand
  • OS/Browser:
  • Win NT 10.0
  • Chrome 55.0.2883.87
    • Weather Display
Re: nws-alerts.php broke - need help
« Reply #6 on: January 12, 2017, 06:25:13 PM »
Quote
after threatening to pull someone's teeth and hear out got to a SENIOR tech person.

seriously?

 

cumulus