Simon Redmond wrote:
Hi,
I call this function where I want a warning message to go, with the name of the
function required (i.e. imagecreatefrom jpeg):
function warn_function ($funname) {
if (!function_exis ts($funname)):
?>
<div align = "center"><d iv class = "warn" align = "left">
This script is not working right now. The most likely cause is my host,
<a href="http://www.veoweb.net" class =
"warn" target = "_blank">VeoWeb .net</a>, messing something up on the server
(it's happened often enough for me to put i
n this automated warning). I have been notified by email that it's not working
and will strive to fix it quickly.
</div> </div>
<?PHP
endif;
}
The following script mails me if something one or more functions in
$functionlist suddenly stops working. It tells me when the build date was and
lists the functions that don't work. It's set to run every half hour.
<?PHP
/*
Check to see if functions are working that have a history of not working after
Veoweb makes changes.
*/
$starttime = explode (" ", microtime());
$starttime = $start_time[1] + $start_time[0];
$email = "Shawn Wilson <sh***@glassgia nt.com>";
$subject = "Website functions not working.";
$headers = "From: VeoWeb Hosting <sh***@glassgia nt.com>\nX-Priority: 1";
$message = "Some functions are not working. Please check out immediately.\n\ n";
$functionlist = array(
"imagecreatefro mjpeg",
"imagecreatefro mpng",
"imagecreat e",
"imagecopyresiz ed",
"imagecopy" ,
"imagejpeg" ,
"imagepng",
"imagecreatetru ecolor",
"fopen",
"mysql_quer y",
"filesize",
"mysql_conn ect"
);
sort ($functionlist) ;
$works = "";
$notworks = "";
$builddate = "";
foreach($functi onlist as $var) {
if (function_exist s($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;
}
}
$endtime = explode (" ", microtime());
$endtime = $start_time[1] + $start_time[0];
if (strlen($notwor ks) > 0)
mail($email, $subject, $message . $notworks . "\n" . $works . "\n\nBuild
Date: $builddate\n\nE xecution time: " .
($endtime - $starttime) . " sec", $headers);
echo "DONE";
?>
Hope you don't mind me contacting off board....
I'd be real interested in see how you achieved that..... don't want your
script per say.... just how you did it....
Thats if you don't mind : )
Simon
----- Original Message -----
From: "Shawn Wilson" <sh***@glassgia nt.com>
Newsgroups: comp.lang.php
Sent: Wednesday, November 19, 2003 1:38 PM
Subject: Re: lost jpeg functionality
Simon Redmond wrote:
not there any more
cheers will get onto the provider tomorrow
"Matthias Esken" <mu************ ******@usenetve rwaltung.org> wrote in
message news:bp******** **@usenet.esken .de...
> "Simon Redmond" <no*****@sibass .com> schrieb:
>
> > my hosting provider just upgraded the server and now some of my scripts > > don't work....
> >
> > Fatal error: Call to undefined function: imagecreatefrom jpeg()
> >
> > should I look for something specific in the output from phpinfo()???
>
> Yes. Look at the configure command There should be a '--with-gd'
> somewhere in the configuration line. More information about the
> configuration of gd should be some blocks down in the phpinfo().
My host keeps doing this to me. For some reason they don't build GD into
PHP whenever they do a rebuild (every few months). In the past it's taken up
to 2 weeks for me to notice that the scripts aren't working. I've asked them
to email me when they make changes to the server, so I can make sure my
scripts still work. They never do. So I now use IF (function_exist s()), with an
array of functions I need. If the function doesn't exist, a nicely-formatted
error message is displayed on the screen explaining that my host has made
changes again, screwed up the server and the script will no longer work. It also
mentions that I have been notified and the problem will be remedied
shortly. I put similar code into a cron job that runs every half hour. If the
functions don't exist, I get an email. You might want to consider doing this. I
wish I'd done it a year ago.
Regards,
Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com
--
Shawn Wilson
sh***@glassgian t.com http://www.glassgiant.com