cvs: php-master-web /scripts mirror-test
| From: | Gabor Hojtsy | Date: | Mon, 06 Jan 2003 20:06:46 +0000 |
| Subject: | cvs: php-master-web /scripts mirror-test | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-14802@lists.php.net to get a copy of this message | ||
goba Mon Jan 6 15:06:46 2003 EDT
Modified files:
/php-master-web/scripts mirror-test
Log:
Check to see where does the script fail? Now mail me at all die() points,
and all runtime error ocassions...
Index: php-master-web/scripts/mirror-test
diff -u php-master-web/scripts/mirror-test:1.25 php-master-web/scripts/mirror-test:1.26
--- php-master-web/scripts/mirror-test:1.25 Mon Jan 6 10:12:52 2003
+++ php-master-web/scripts/mirror-test Mon Jan 6 15:06:46 2003
@@ -10,21 +10,23 @@
script.
*/
+set_error_handler("myhandler");
+
// This script will run for a long time
set_time_limit (0);
-// Debug mail
-@mail("goba@php.net", "Mirror site check started", "Mirror site check
started");
+// DEBUG
+sendmessage("Mirror site check started");
// Connect to local MySQL database
mysql_connect("localhost","nobody","")
- or die("unable to connect to database");
+ or sendmessage("unable to connect to database", TRUE);
mysql_select_db("php3");
// Get mirror information for all active mirrors (regardless of their type!)
$query = "SELECT maintainer, hostname, id, has_search FROM mirrors WHERE active = 1";
$result = mysql_query($query)
- or die("unable to get from the database: " . mysql_error());
+ or sendmessage("unable to get from the database: " . mysql_error(), TRUE);
// Get the number of mirrors in the resultset
$total = mysql_num_rows($result);
@@ -96,8 +98,8 @@
}
}
-// Debug mail
-@mail("goba@php.net", "All mirrors checked", "All mirrors checked");
+// DEBUG
+sendmessage("All mirrors checked");
// Go through all mirror sites checked
$mirrorsupdated = 0;
@@ -111,15 +113,28 @@
"lastupdated = FROM_UNIXTIME(" . $hosts[$i]['mirrorupdated'] .
"), " .
"phpversion = '" . addslashes($hosts[$i]['phpversion']) .
"' " .
"WHERE hostname = '" . $hosts[$i]['hostname'] .
"'";
- $result = mysql_query($query);
+ $result = mysql_query($query) or sendmessage("unable to update the database: $query:
" . mysql_error(), TRUE);
if ($result) { $mirrorsupdated++; }
- else {
- $errorstr = "unable to update the database: $query: " . mysql_error();
- @mail("goba@php.net", "Mirror sites update failed",
"$errorstr");
- die($errorstr);
- }
}
}
-// Debug mail
-@mail("goba@php.net", "Mirror sites checked", "$mirrorsupdated number of
mirror sites properly updated");
\ No newline at end of file
+// DEBUG
+sendmessage("$mirrorsupdated number of mirror sites properly updated");
+
+// Debug message sender and die function
+function sendmessage($string, $die = FALSE)
+{
+ @mail("goba@php.net", "Mirror site check status report", $string);
+ if ($die) {
+ die($string);
+ }
+}
+
+// Custom error handler
+function myhandler($errno, $errstr, $errfile, $errline)
+{
+ // See if the error is under the error reporting level
+ if ($errno & error_reporting()) {
+ sendmessage("$errno : $errstr : $errfile : $errline", TRUE);
+ }
+}