cvs: phpweb /bin mirrors.php

From: Date: Wed, 19 Sep 2001 16:15:41 +0000
Subject: cvs: phpweb /bin mirrors.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-6442@lists.php.net to get a copy of this message
goba Wed Sep 19 12:15:41 2001 EDT Modified files: /phpweb/bin mirrors.php Log: Adding some fail-safe codes to make sure the error mirroring thing we are currently suffering won't happen again Index: phpweb/bin/mirrors.php diff -u phpweb/bin/mirrors.php:1.2 phpweb/bin/mirrors.php:1.3 --- phpweb/bin/mirrors.php:1.2 Fri Jul 6 20:43:21 2001 +++ phpweb/bin/mirrors.php Wed Sep 19 12:15:38 2001 @@ -1,15 +1,32 @@ <?php -mysql_connect("localhost","nobody",""); -mysql_select_db("php3"); -$res = mysql_query("SELECT * FROM mirrors ORDER BY cc"); -if (!$res) die("error"); -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[mirrortype] = 2; - echo " \"$row[hostname]\" => array(\"$row[cc]\",\"$row[providername]\",$row[has_stats],\"$row[providerurl]\",$row[mirrortype],$row[has_search],\"$row[lang]\"),\n"; + +// This file is intended to be used on php.net only! +if (!is_primary_site()) { exit; } + +// Connect and generate the list from the DB +if (@mysql_connect("localhost","nobody","")) { + if (@mysql_select_db("php3")) { + $res = @mysql_query("SELECT * FROM mirrors ORDER BY cc"); + 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["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"; + exit; + } + } } -echo ' 0 => array("xx", "Unknown", 0, "/", 2, 0, "en")', "\n"; + +// In case of something went wrong +echo "<?php\n\$MIRRORS = array(\n"; +echo ' 0 => array("xx", "This feature is not working currently", 0, "/", 2, 0, "en")', "\n"; echo ");\n"; echo "?>\n"; + +?>

« previous php.mirrors (#6442) next »