nws-alerts.php broke - need help

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:

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. :?

is this post in the correct section of the forum?

Apologize…

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.

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: : ‘.$_SERVER[‘SERVER_NAME’].’/ and the VAR is called again at Line 562: href=“http://‘.$_SERVER[‘SERVER_NAME’].’/”

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:

/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…

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.

after threatening to pull someone's teeth and hear out got to a SENIOR tech person.

seriously?