cvs: php-master-web /scripts mirror-summary mirror-test

From: Date: Sun, 02 Jun 2002 05:04:11 +0000
Subject: cvs: php-master-web /scripts mirror-summary mirror-test
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-10615@lists.php.net to get a copy of this message
jimw Sun Jun 2 01:04:11 2002 EDT Added files: /php-master-web/scripts mirror-summary Modified files: /php-master-web/scripts mirror-test Log: split mirror checking from script to send summary to php-mirrors. don't play with active field in mirrors table, but just update the lastupdated, lastchecked, and phpversion fields. Index: php-master-web/scripts/mirror-test diff -u php-master-web/scripts/mirror-test:1.6 php-master-web/scripts/mirror-test:1.7 --- php-master-web/scripts/mirror-test:1.6 Sun Jun 2 00:12:05 2002 +++ php-master-web/scripts/mirror-test Sun Jun 2 01:04:10 2002 @@ -1,8 +1,7 @@ #!/usr/local/bin/php -q <?php set_time_limit (0); -/* simple testing system to ping each mirror, and see what state they are in, - and alert the php-mirrors team as to the results. */ +/* simple testing system to ping each mirror, and see what state they are in.*/ /* firstly, get some data */ @@ -10,7 +9,7 @@ or die("unable to connect to database"); mysql_select_db("php3"); -$query = "SELECT maintainer,hostname,id FROM mirrors WHERE mirrortype = 1"; +$query = "SELECT maintainer,hostname,id FROM mirrors WHERE mirrortype = 1 AND active"; $result = mysql_query($query) or die("unable to get from the database"); @@ -21,11 +20,6 @@ $hosts[$i]['maintainer'] = $row['maintainer']; } -/* make all hosts active again -- cop out / cheat to get around the deactivation later */ - -#$query = "UPDATE mirrors SET active = 1 WHERE mirrortype = 1 "; -#$result = mysql_query($query) or die("unable to update the database"); - /* now this stage takes a long time, and we need to go out of PHP to execute it, so we are going to write that info to a file */ @@ -95,73 +89,13 @@ } } -/* now prepare a mailer for php-mirrors */ - - $body = "Following is data gathered from the various mirrors. It is ordered by those\n" - . "that are suspected to be dead, mirrors which are alive but have errors, sites\n" - . "which need to be prompted to update their PHP version, and finally the rest,\n" - . "sorted by last update.\n" - . "Edit mirror listings here: http://master.php.net/manage/mirrors.php\n\n"; - - $body .= "No response was returned from these following hosts, and they were removed from the active list:\n\n"; - - for($i=0; $i < $total; $i++) { - if ($hosts[$i]['active'] == false) { - $body .= sprintf("%s -- %s\n", $hosts[$i]['hostname'], $hosts[$i]['maintainer']); - - mysql_connect("localhost","nobody","") or die("unable to connect to database"); - mysql_select_db("php3"); - $query = "UPDATE mirrors SET active = 0 WHERE hostname = '" . $hosts[$i]['hostname'] . "'"; -# $result = mysql_query($query) or die("unable to get from the database"); - } - } +for($i=0; $i < $total; $i++) { + mysql_connect("localhost","nobody","") or die("unable to connect to database"); + mysql_select_db("php3"); + $query = "UPDATE mirrors SET lastchecked=NOW()" . ($hosts[$i]['active'] ? ",lastupdated=FROM_UNIXTIME(".$hosts[$i]['lastupdate']."),phpversion='".addslashes($hosts[$i]['phpversion'])."'" : "") . " WHERE hostname = '" . $hosts[$i]['hostname'] . "'"; + $result = mysql_query($query) or die("unable to get from the database"); +} - if (isset($moreinfo)){ - $body .= "\nThese hosts returned extra information, so there may be errors:\n"; - - for($i=0; $i < $total; $i++) { - if (strlen($hosts[$i]['xtra']) > 0) { - $body .= sprintf("%s - %s - %s\n%s\n", $hosts[$i]['hostname'], $hosts[$i]['phpversion'], date("F j, Y, g:i a", $hosts[$i]['lastupdate']), $hosts[$i]['xtra']); - } - } - } - - $body .= "\nAnd now for the rest of the mirrors:\n" - . "----------------------------------------------------------------------------------------\n" - . " Host \t\t PHP Version \t\t Last Updated\t\t Maintainer\n" - . "----------------------------------------------------------------------------------------\n"; - -/* a note about the padding - given that email readers produce interesting results for spacing, -i've gone for tabs here to help seperate the text columns. to make sure i don't over tab, i do -a quick strlen check, and depending on how different it is from the string length i give as avg -(first argument), will determine how many tabs i use, or alternatively a space. */ - - function pad($deflen, $item) { - global $i, $hosts; - $str = strlen($hosts[$i][$item]); - if ($str >= $deflen*2) { - $sp =" "; - } - else if ($str <= $deflen){ - $sp ="\t\t"; - } else { - $sp = "\t"; - } - return $sp; - } - - for($i=0; $i < $total; $i++) { - if($hosts[$i]['active'] == true){ - $body .= sprintf(" %s%s%s%s%s\t\t%s\n", $hosts[$i]['hostname'], pad(11, "hostname"), $hosts[$i]['phpversion'], pad(5, "phpversion"), date("F j, Y, g:i a", $hosts[$i]['lastupdate']), $hosts[$i]['maintainer']); - } - } - - $body . "---------------------------------------------------------------------------------------\n"; - -/* please edit this when testing to send mail to yourself, not to the list every time */ - -mail("php-mirrors@lists.php.net", "PHP Mirror Status Info.", $body, "From: php-mirrors@lists.php.net"); - /* this cleans what we did. it also kills all the wget sessions that didn't end - however, the make session goes defunct and loses reporting over the child processes. This should die within a short period of time. */

« previous php.mirrors (#10615) next »