cvs: php-master-web /fetch mirrors.php /scripts mirror-summary mirror-test
| From: | jim winstead | Date: | Sun, 02 Jun 2002 05:32:28 +0000 |
| Subject: | cvs: php-master-web /fetch mirrors.php /scripts mirror-summary mirror-test | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-10617@lists.php.net to get a copy of this message | ||
jimw Sun Jun 2 01:32:28 2002 EDT
Modified files:
/php-master-web/scripts mirror-summary mirror-test
/php-master-web/fetch mirrors.php
Log:
duh, be smarter about how we use lastchecked so we can distinguish between down and stale.
Index: php-master-web/scripts/mirror-summary
diff -u php-master-web/scripts/mirror-summary:1.1 php-master-web/scripts/mirror-summary:1.2
--- php-master-web/scripts/mirror-summary:1.1 Sun Jun 2 01:04:10 2002
+++ php-master-web/scripts/mirror-summary Sun Jun 2 01:32:28 2002
@@ -11,7 +11,7 @@
. "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";
+ $body .= "No response was returned from these following hosts within the last three
days:\n\n";
/* firstly, get some data */
@@ -19,13 +19,13 @@
or die("unable to connect to database");
mysql_select_db("php3");
-$query = "SELECT maintainer,hostname,id,UNIX_TIMESTAMP(lastupdated) AS
lastupdate,phpversion,(DATE_SUB(NOW(), INTERVAL 3 DAY) < lastupdated) AS active FROM mirrors
WHERE mirrortype = 1 ORDER BY hostname";
+$query = "SELECT maintainer,hostname,id,UNIX_TIMESTAMP(lastupdated) AS
lastupdate,phpversion,(DATE_SUB(NOW(), INTERVAL 3 DAY) < lastchecked) AS active,(DATE_SUB(NOW(),
INTERVAL 7 DAY) < lastupdated) AS current FROM mirrors WHERE mirrortype = 1 ORDER BY
hostname";
$result = mysql_query($query)
or die("unable to get from the database");
-while ($hosts[] = mysql_fetch_assoc($result)) {
- /* do nothing */
+while ($host = mysql_fetch_assoc($result)) {
+ $hosts[] = $host;
}
$total = count($hosts);
@@ -36,6 +36,16 @@
}
}
+
+ $body .= "\nThese mirrors have not been updated in at least 7 days:\n\n";
+ for($i=0; $i < $total; $i++) {
+ if ($hosts[$i]['active'] && !$hosts[$i]['current']) {
+ $body .= sprintf("%s -- %s\n", $hosts[$i]['hostname'],
$hosts[$i]['maintainer']);
+
+ }
+ }
+
+
$body .= "\nAnd now for the rest of the mirrors:\n"
.
"----------------------------------------------------------------------------------------\n"
. " Host \t\t PHP Version \t\t Last Updated\t\t Maintainer\n"
Index: php-master-web/scripts/mirror-test
diff -u php-master-web/scripts/mirror-test:1.7 php-master-web/scripts/mirror-test:1.8
--- php-master-web/scripts/mirror-test:1.7 Sun Jun 2 01:04:10 2002
+++ php-master-web/scripts/mirror-test Sun Jun 2 01:32:28 2002
@@ -89,11 +89,15 @@
}
}
+/* reconnect to the database */
+mysql_connect("localhost","nobody","") or die("unable to connect
to database");
+mysql_select_db("php3");
+
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 ($hosts[$i]['active']) {
+ $query = "UPDATE mirrors SET
lastchecked=NOW(),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");
+ }
}
/* this cleans what we did. it also kills all the wget sessions that didn't end - however, the
make session
Index: php-master-web/fetch/mirrors.php
diff -u php-master-web/fetch/mirrors.php:1.4 php-master-web/fetch/mirrors.php:1.5
--- php-master-web/fetch/mirrors.php:1.4 Sun Jun 2 01:08:08 2002
+++ php-master-web/fetch/mirrors.php Sun Jun 2 01:32:28 2002
@@ -7,13 +7,13 @@
// Connect and generate the list from the DB
if (@mysql_pconnect("localhost","nobody","")) {
if (@mysql_select_db("php3")) {
- $res = @mysql_query("SELECT mirrors.*,country.name AS cname,(DATE_SUB(NOW(),INTERVAL 3
DAY) < mirrors.lastupdated) AS current FROM mirrors LEFT JOIN country ON mirrors.cc = country.id
ORDER BY country.name,hostname");
+ $res = @mysql_query("SELECT mirrors.*,country.name AS cname,(DATE_SUB(NOW(),INTERVAL 3
DAY) < mirrors.lastchecked) AS up,(DATE_SUB(NOW(),INTERVAL 7 DAY) < mirrors.lastupdated) AS
current FROM mirrors LEFT JOIN country ON mirrors.cc = country.id ORDER BY
country.name,hostname");
if ($res) {
echo "<?php\n\$MIRRORS = array(\n";
while ($row = @mysql_fetch_array($res)) {
if (!strstr("http:",$row[hostname])) {
$row[hostname]="http://$row[hostname]/"; }
// Set inactive mirrors to type 2 so they won't show up in the drop-down.
- if (!$row["active"] || !$row["current"]) { $row["mirrortype"]
= 2; }
+ if (!$row["active"] || !$row["current"] || !$row["up"]) {
$row["mirrortype"] = 2; }
echo " \"$row[hostname]\" =>
array(\"$row[cc]\",\"$row[providername]\",$row[has_stats],\"$row[providerurl]\",$row[mirrortype],$row[has_search],\"$row[lang]\"),\n";
}
echo ' 0 => array("xx", "Unknown", 0, "/", 2, 0,
"en")', "\n";