cvs: phpweb / search.php /include loadavg.inc
| From: | Wez Furlong | Date: | Fri, 23 May 2003 01:30:20 +0000 |
| Subject: | cvs: phpweb / search.php /include loadavg.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-17922@lists.php.net to get a copy of this message | ||
wez Thu May 22 21:30:20 2003 EDT
Modified files:
/phpweb/include loadavg.inc
/phpweb search.php
Log:
deprecate ht://dig in favour of alltheweb.
alltheweb has better results than ht://dig and allows us to utilize all mirrors
equally for load balancing.
Index: phpweb/include/loadavg.inc
diff -u phpweb/include/loadavg.inc:1.7 phpweb/include/loadavg.inc:1.8
--- phpweb/include/loadavg.inc:1.7 Thu May 22 20:27:55 2003
+++ phpweb/include/loadavg.inc Thu May 22 21:30:20 2003
@@ -5,7 +5,7 @@
* machine. */
function check_load()
{
- global $COUNTRY, $MIRRORS;
+ global $COUNTRY, $MIRRORS, $MYSITE;
if (!function_exists("getloadavg")) {
return;
@@ -25,8 +25,7 @@
/* find potential mirrors */
foreach ($MIRRORS as $murl => $mirror) {
if ($murl != 'http://www.php.net/' &&
- $mirror[7] == MIRROR_OK /* mirror status */ &&
- $mirror[5] /* searchable */) {
+ $mirror[7] == MIRROR_OK /* mirror status */) {
if ($mirror[0] == $COUNTRY) {
$mirrors[] = $murl;
@@ -36,18 +35,28 @@
}
}
+ $need_mirror = true;
+
/* randomly pick one of the mirrors in their country */
if (count($mirrors) > 0) {
$murl = $mirrors[array_rand($mirrors)];
- header("Location: $murl" . substr($_SERVER['REQUEST_URI'], 1));
- exit;
+
+ if ($murl == $MYSITE) {
+ $need_mirror = false; /* selected this site */
+ } else {
+ header("Location: $murl" . substr($_SERVER['REQUEST_URI'], 1));
+ exit;
+ }
}
/* pick a random mirror if load is moderate */
- if ($l[0] > 10 && count($any_mirrors) > 0) {
+ if ($need_mirror && $l[0] > 10 && count($any_mirrors) > 0) {
$murl = $any_mirrors[array_rand($any_mirrors)];
- header("Location: $murl" . substr($_SERVER['REQUEST_URI'], 1));
- exit;
+
+ if ($murl != $MYSITE) {
+ header("Location: $murl" . substr($_SERVER['REQUEST_URI'], 1));
+ exit;
+ }
}
/* no searchable mirror was found, allow the request through if the load
Index: phpweb/search.php
diff -u phpweb/search.php:1.84 phpweb/search.php:1.85
--- phpweb/search.php:1.84 Thu May 22 20:52:34 2003
+++ phpweb/search.php Thu May 22 21:30:20 2003
@@ -1,5 +1,5 @@
<?php
-/* $Id: search.php,v 1.84 2003/05/23 00:52:34 wez Exp $ */
+/* $Id: search.php,v 1.85 2003/05/23 01:30:20 wez Exp $ */
include_once "prepend.inc";
@@ -150,10 +150,15 @@
exit;
}
+ header("Location: http://www.alltheweb.com/search?q=" .
urlencode($pattern) .
+ "+site:" . urlencode(substr($MYSITE, 7)) . "&l=$lang");
+ exit;
+
// If some local search is needed and we have no support for
// it, send the user to the central search page on php.net
if (!isset($htsearch_prog)) {
-
+
+
// We cannot redirect to anywhere, absolute failure
if (is_primary_site()) {
commonHeader("Search Service");
@@ -233,8 +238,8 @@
if ($result[2] == "NOMATCH") {
echo "Sorry, no documents matched your search for
<b>\"$htmlpt\"</b>.<br /><br />";
echo "Continue your search at ";
- echo "<a href=\"http://www.alltheweb.com/search?q=$urlpt\">AllTheWeb</a>
";
- echo "or <a href=\"http://www.google.com/search?q=$urlpt&as_sitesearch=www.php.net\">Google</a><br
/><br />";
+ echo "<a href=\"http://www.alltheweb.com/search?q=$urlpt+site:www.php.net\">AllTheWeb</a>
";
+ echo "or <a href=\"http://www.google.com/search?q=$urlpt+site:www.php.net\">Google</a><br
/><br />";
echo "Click here for a <a href=\"$sourceurl\">New Search</a>
on the PHP website<br /><br />\n";
commonFooter();
exit;