By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,826 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,826 IT Pros & Developers. It's quick & easy.

phpinfo returning 2 different build dates

P: n/a
Hi,

My host keeps messing things up and not telling me. I am trying to write a cron
job that will test to make sure the "unusual" functions I use work and, if not,
email me. I want it to send me the build date as well. The weird thing is, my
cron script (using phpinfo) gives me a different build date than phpinfo() in an
"admin tool" section of my website.

The cron script is sitting in the root of my home directory (non web
accessable). The admin tool is sitting in a password-protected (BASIC AUTH)
section of the site.

----------------------

CRON SCRIPT SNIPPET:
ob_start();
phpinfo();
$string = ob_get_contents();
ob_end_clean();

echo "\n\n" . $string . "\n\n";

----------------------

ADMIN TOOL SNIPPET:
phpinfo();

----------------------

CRON SCRIPT RESULT SNIPPET:
PHP Version => 4.3.3

System => Linux mydomain.com X.XX.XX-XX.X #1 Mon Aug 18 14:56:30 EDT 2003 i686
Build Date => Oct 21 2003 02:52:32

----------------------

ADMIN TOOL RESULT SNIPPET (copied from HTML):
PHP Version 4.3.3

System
Linux mydomain.com X.XX.XX-XX.X #1 Mon Aug 18 14:56:30 EDT 2003 i686
Build Date
Oct 18 2003 21:23:42

----------------------

I have tried both with phpinfo(INFO_GENERAL) as well - same result.
Does anyone have any idea why this is happening and how to fix it? Both scripts
are owned by the same user, and have the same permissions. Since I'm testing, I
currently execute the cron script through SSH with: php -q ./filename.php. I
execute the admin tool by accessing it through a browser.

Thanks in advance,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Shawn Wilson <sh***@glassgiant.com> wrote:
email me. I want it to send me the build date as well. The weird thing
is, my cron script (using phpinfo) gives me a different build date than
phpinfo() in an "admin tool" section of my website.


Hi Shawn,

The command "php" and the php module for the web server are two different
things, unless PHP is run as CGI.

BTW, your php script could be shortened to a call to php:

/path/to/php -i

Outputs the same as phpinfo().

HTH;
JOn
Jul 17 '05 #2

P: n/a
Jon Kraft wrote:

Shawn Wilson <sh***@glassgiant.com> wrote:
email me. I want it to send me the build date as well. The weird thing
is, my cron script (using phpinfo) gives me a different build date than
phpinfo() in an "admin tool" section of my website.


Hi Shawn,

The command "php" and the php module for the web server are two different
things, unless PHP is run as CGI.

BTW, your php script could be shortened to a call to php:

/path/to/php -i

Outputs the same as phpinfo().


Ah, I should have known that. I guess I'll have to set up a cron script to
fopen() a webpage that uses phpinfo() to display the build date, as it's the PHP
module's build date I'm interested in, unless anyone knows of a less "cludgy"
solution =D

Thanks for your help,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #3

P: n/a
Shawn Wilson wrote:

Jon Kraft wrote:

Shawn Wilson <sh***@glassgiant.com> wrote:
email me. I want it to send me the build date as well. The weird thing
is, my cron script (using phpinfo) gives me a different build date than
phpinfo() in an "admin tool" section of my website.


Hi Shawn,

The command "php" and the php module for the web server are two different
things, unless PHP is run as CGI.

BTW, your php script could be shortened to a call to php:

/path/to/php -i

Outputs the same as phpinfo().


Ah, I should have known that. I guess I'll have to set up a cron script to
fopen() a webpage that uses phpinfo() to display the build date, as it's the PHP
module's build date I'm interested in, unless anyone knows of a less "cludgy"
solution =D


In case anyone is looking for the a solution to the same problem, my script
follows:

<?PHP

$email = "Shawn Wilson <sh***@glassgiant.com>";
$subject = "Website functions not working.";
$headers = "From: Server <sh***@glassgiant.com>\nX-Priority: 1";
$message = "Some functions are not working. Please check out immediately.\n\n";

$functionlist = array(
"imagecreatefromjpeg",
"imagecreatefrompng",
"imagecreate",
"imagecopyresized",
"imagecopy",
"imagejpeg",
"imagepng",
"imagecreatetruecolor",
"fopen",
"mysql_query",
"filesize",
"mysql_connect"
);

sort ($functionlist);

$works = "";
$notworks = "";
$builddate = "";

foreach($functionlist as $var) {
if (function_exists($var))
$works .= "Function \"$var\" works.\n";
else
$notworks .= "Function \"$var\" does not work.\n";
}

ob_start();
phpinfo();
$string = ob_get_contents();
ob_end_clean();

$string = explode("\n", $string);

foreach($string as $var) {
$var = strip_tags($var);
if (preg_match("/^Build Date\s+([A-Za-z]+ [0-9]+ [0-9]+
[0-9]+:[0-9]+:[0-9]+).+$/", $var)) {
$var = preg_replace("/^Build Date\s+([A-Za-z]+ [0-9]+ [0-9]+
[0-9]+:[0-9]+:[0-9]+)[^0-9]?.*$/", "\$1", $
var);
$builddate = $var;
break;
}
}

if (strlen($notworks) > 0)
mail($email, $subject, $message . $notworks . "\n" . $works . "\n\nBuild
Date: $builddate", $headers);
echo "DONE";
?>

I've got a cron job that calls this script through http every hour. I'm sure
there's a more efficient regex, but this was a quickie. I might add my host's
tech support address to the To: header.

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.