com web/php: Nearing the completion of the 'missing sponsor data' bug for the round-robin CC.PHP.NET base.: include/site.inc
| From: | Daniel P. Brown | Date: | Wed, 10 Oct 2012 19:43:54 +0000 |
| Subject: | com web/php: Nearing the completion of the 'missing sponsor data' bug for the round-robin CC.PHP.NET base.: include/site.inc | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-14826@lists.php.net to get a copy of this message | ||
Commit: 64b4e805257856289ff0a419d6d352f6d371c788
Author: Daniel P. Brown <danbrown@php.net> Wed, 10 Oct 2012 15:43:54 -0400
Parents: 5421e405f33a4b5b34e80987a681f043b9b43fdc
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=64b4e805257856289ff0a419d6d352f6d371c788
Log:
Nearing the completion of the 'missing sponsor data' bug for the round-robin CC.PHP.NET
base.
Changed paths:
M include/site.inc
Diff:
diff --git a/include/site.inc b/include/site.inc
index b25b132..543d0c5 100644
--- a/include/site.inc
+++ b/include/site.inc
@@ -78,7 +78,14 @@ function mirror_provider($site = FALSE)
{
global $MIRRORS, $MYSITE;
if (!$site) { $site = $MYSITE; }
- return (isset($MIRRORS[$site]) ? $MIRRORS[$site][1] : FALSE);
+
+ if (isset($MIRRORS[$site])) {
+ return $MIRRORS[$site][1];
+ } elseif (isset($MIRRORS[$_SERVER['SERVER_ADDR']])) {
+ return $MIRRORS[$_SERVER['SERVER_ADDR']][1];
+ }
+
+ return false;
}
// Returns the current (or specified)
@@ -87,7 +94,14 @@ function mirror_provider_url($site = FALSE)
{
global $MIRRORS,$MYSITE;
if (!$site) { $site = $MYSITE; }
- return (isset($MIRRORS[$site]) ? $MIRRORS[$site][3] : FALSE);
+
+ if (isset($MIRRORS[$site])) {
+ return $MIRRORS[$site][3];
+ } elseif (isset($MIRRORS[$_SERVER['SERVER_ADDR']])) {
+ return $MIRRORS[$_SERVER['SERVER_ADDR']][3];
+ }
+
+ return false;
}
// Returns the current (or specified)
@@ -96,7 +110,14 @@ function mirror_type($site = FALSE)
{
global $MIRRORS, $MYSITE;
if (!$site) { $site = $MYSITE; }
- return (isset($MIRRORS[$site]) ? $MIRRORS[$site][4] : FALSE);
+
+ if (isset($MIRRORS[$site])) {
+ return $MIRRORS[$site][4];
+ } elseif (isset($MIRRORS[$_SERVER['SERVER_ADDR']])) {
+ return $MIRRORS[$_SERVER['SERVER_ADDR']][4];
+ }
+
+ return false;
}
// Returns the current (or specified)
@@ -105,7 +126,14 @@ function mirror_status($site = FALSE)
{
global $MIRRORS, $MYSITE;
if (!$site) { $site = $MYSITE; }
- return (isset($MIRRORS[$site]) ? $MIRRORS[$site][7] : FALSE);
+
+ if (isset($MIRRORS[$site])) {
+ return $MIRRORS[$site][7];
+ } elseif (isset($MIRRORS[$_SERVER['SERVER_ADDR']])) {
+ return $MIRRORS[$_SERVER['SERVER_ADDR']][7];
+ }
+
+ return false;
}
// Count all mirrors or mirrors in a given country
@@ -408,27 +436,32 @@ if($_SERVER["SERVER_PORT"] != '80') {
// If this site does not exist
if (!isset($MIRRORS[$MYSITE])) {
- // Try the hostname [without www].. In case the main name above is
- // not found, we try to find the mirror with the name provided by
- // the browser (in the Host HTTP header).
-
- if($_SERVER["SERVER_PORT"] != '80') {
- $tmp = 'http://' .
preg_replace("!^www\\.!", "", $_SERVER["SERVER_NAME"]) . ':'
. (int)$_SERVER["SERVER_PORT"] . '/';
+ // Check if the IP address exists (a fix for the round-robin introduction)
+ if (isset($MIRRORS[$_SERVER['SERVER_ADDR']])) {
+ $MYSITE = $_SERVER['SERVER_ADDR'];
} else {
- $tmp = 'http://' .
preg_replace("!^www\\.!", "", $_SERVER["SERVER_NAME"]) .
'/';
- }
- // If the name without www. exists, use it
- if (isset($MIRRORS[$tmp])) {
- $MYSITE = $tmp;
- }
+ // Try the hostname [without www]. In case the main name above is
+ // not found, we try to find the mirror with the name provided by
+ // the browser (in the Host HTTP header).
+
+ if($_SERVER["SERVER_PORT"] != '80') {
+ $tmp = 'http://' .
preg_replace("!^www\\.!", "", $_SERVER["SERVER_NAME"]) . ':'
. (int)$_SERVER["SERVER_PORT"] . '/';
+ } else {
+ $tmp = 'http://' .
preg_replace("!^www\\.!", "", $_SERVER["SERVER_NAME"]) .
'/';
+ }
- // If the mirror is not registered with this name, provide defaults
- // (no country code, no search, no stats, English default language ...)
- if (!isset($MIRRORS[$MYSITE])) {
- $MIRRORS[$MYSITE] = array("xx", $MYSITE, FALSE, $MYSITE, MIRROR_VIRTUAL, FALSE,
"en", MIRROR_OK);
- }
+ // If the name without www. exists, use it
+ if (isset($MIRRORS[$tmp])) {
+ $MYSITE = $tmp;
+ }
+ // If the mirror is not registered with this name, provide defaults
+ // (no country code, no search, no stats, English default language ...)
+ if (!isset($MIRRORS[$MYSITE])) {
+ $MIRRORS[$MYSITE] = array("xx", $MYSITE, FALSE, $MYSITE, MIRROR_VIRTUAL,
FALSE, "en", MIRROR_OK);
+ }
+ }
}
// Override mirror language with local preference