cvs: phpweb / search.php /include loadavg.inc

From: Date: Thu, 22 May 2003 21:40:04 +0000
Subject: cvs: phpweb / search.php /include loadavg.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17910@lists.php.net to get a copy of this message
wez Thu May 22 17:40:04 2003 EDT Modified files: /phpweb search.php /phpweb/include loadavg.inc Log: Unconditionally dump manual searches onto mirrors (that are search capable). Index: phpweb/search.php diff -u phpweb/search.php:1.80 phpweb/search.php:1.81 --- phpweb/search.php:1.80 Thu May 22 13:37:49 2003 +++ phpweb/search.php Thu May 22 17:40:04 2003 @@ -1,7 +1,15 @@ <?php -/* $Id: search.php,v 1.80 2003/05/22 17:37:49 wez Exp $ */ +/* $Id: search.php,v 1.81 2003/05/22 21:40:04 wez Exp $ */ include_once "prepend.inc"; + +/* convert POST -> GET when dumping the user onto a mirror */ +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $_SERVER['REQUEST_URI'] = "/search.php?show=$show&pattern=" . + urlencode($pattern) . + "&base=" . urlencode($MYSITE) . "&lang=$lang"; +} + include 'loadavg.inc'; /* Index: phpweb/include/loadavg.inc diff -u phpweb/include/loadavg.inc:1.2 phpweb/include/loadavg.inc:1.3 --- phpweb/include/loadavg.inc:1.2 Thu May 22 14:33:22 2003 +++ phpweb/include/loadavg.inc Thu May 22 17:40:04 2003 @@ -11,16 +11,23 @@ return; } $l = getloadavg(); - if (is_array($l) && $l[0] > 10) { - /* offload them to their favourite mirror */ - foreach ($MIRRORS as $murl => $mirror) { - if ($murl != 'http://www.php.net' && mirror_country($murl) == $COUNTRY && mirror_status($murl) == MIRROR_OK && $mirror[5]) { - header("Location: $murl" . substr($_SERVER['REQUEST_URI'], 1)); - header("X-PHP-Load: [" . implode(", ", $l) . "] Too-high, try this mirror"); - exit; - } + header("X-PHP-Load: " . implode(", ", $l)); + + /* offload them to their favourite mirror */ + foreach ($MIRRORS as $murl => $mirror) { + if ($murl != 'http://www.php.net' && + mirror_country($murl) == $COUNTRY && + mirror_status($murl) == MIRROR_OK && + $mirror[5] /* searchable */) { + header("Location: $murl" . substr($_SERVER['REQUEST_URI'], 1)); + exit; } - header("Status: 503 Server too busy, try again later"); + } + /* no searchable mirror was found, allow the request through if the load + * isn't really really high */ + if ($l[0] > 20) { + header("HTTP/1.1 503 Too busy, try again later"); + echo "Server too busy, please try again later, or <a href=\"/mirrors.php\">use a mirror</a>"; exit; } }

« previous php.mirrors (#17910) next »