cvs: php-master-web /fetch mirrors.php
| From: | Gabor Hojtsy | Date: | Sun, 15 Dec 2002 20:59:01 +0000 |
| Subject: | cvs: php-master-web /fetch mirrors.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-14211@lists.php.net to get a copy of this message | ||
goba Sun Dec 15 15:59:01 2002 EDT
Modified files:
/php-master-web/fetch mirrors.php
Log:
Try to provide a bit more information about why a mirror
is delisted (marked as special on the fly). So mirror
maintainers can see more about why their mirror is not
listed...
We should also start again discussions about
"special mirrors" anyway...
Index: php-master-web/fetch/mirrors.php
diff -u php-master-web/fetch/mirrors.php:1.5 php-master-web/fetch/mirrors.php:1.6
--- php-master-web/fetch/mirrors.php:1.5 Sun Jun 2 01:32:28 2002
+++ php-master-web/fetch/mirrors.php Sun Dec 15 15:59:01 2002
@@ -1,24 +1,63 @@
<?php
-# token required, since this should only get accessed from rsync.php.net
-if (!isset($token) || md5($token) != "19a3ec370affe2d899755f005e5cd90e")
- die("token not correct.");
+// A token is required, since this should only get accessed from rsync.php.net
+if (!isset($token) || md5($token) != "19a3ec370affe2d899755f005e5cd90e") {
+ die("token not correct.");
+}
-// Connect and generate the list from the DB
+// Connect to local mysql database
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.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["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";
- echo ");\n";
- echo "?>\n";
+
+ // Select php3 database
+ if (@mysql_select_db("php3")) {
+
+ // Select mirrors list with some on-the-fly counted columns
+ $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 there is a mysql result
+ if ($res) {
+
+ // Start PHP script output
+ echo "<?php\n\$MIRRORS = array(\n";
+
+ // Go through all result rows
+ while ($row = @mysql_fetch_array($res)) {
+
+ // Prepend http:// to hostname, if it is not there
+ if (!strstr("http:",
$row["hostname"])) {
+ $row["hostname"] = "http://$row[hostname]/";
+ }
+
+ // We don't have any comment for general mirrors
+ $comment = '';
+
+ // Set inactive mirrors to type 2 so they won't show up in the drop-down,
+ // and provide information in comment for diagnostical purposes
+ if (!$row["active"]) {
+ $row["mirrortype"] = 2;
+ $comment = '// not active';
+ } elseif (!$row["current"]) {
+ $row["mirrortype"] = 2;
+ $comment = '// not up to date';
+ } elseif (!$row["up"]) {
+ $row["mirrortype"] = 2;
+ $comment = '// does not seem to work';
+ }
+
+ // Print out the array element for this mirror
+ echo " \"$row[hostname]\" =>
array(\"$row[cc]\"," .
+
"\"$row[providername]\",$row[has_stats],\"$row[providerurl]\"" .
+
",$row[mirrortype],$row[has_search],\"$row[lang]\"),$comment\n";
+ }
+ echo ' 0 => array("xx", "Unknown", 0, "/", 2,
0, "en")', "\n";
+ echo ");\n";
+ echo "?>\n";
+ }
}
- }
}