$mirror) { if (mirror_status($murl) != MIRROR_OK) { continue; } if ($country === FALSE || mirror_country($murl) == $country) { $count++; } } return $count; } // Redirect to an URI on this mirror site or outside this site function mirror_redirect($absoluteURI) { global $MYSITE; // Test if there is no protocol spec // in the URL, then prepend local site URI if (!preg_match("!^[a-z]+://!", $absoluteURI)) { $absoluteURI = substr($MYSITE, 0, -1) . $absoluteURI; } // Do a redirection, if headers are not sent if (!headers_sent()) { header("Location: $absoluteURI"); } // Always exit (the page is not to be displayed) exit; } // Set a cookie for all the .php.net sites for the root // dir with $name and $content. Provide $exptime relatively // to the current time! function mirror_setcookie($name, $content, $exptime) { if (!headers_sent()) { if (is_official_mirror()) { return setcookie($name, $content, time() + $exptime, '/', '.php.net'); } else { return setcookie($name, $content, time() + $exptime, '/'); } } else { return FALSE; } } // Use this function to write out proper headers on // pages where the content should not be publicly cached function header_nocache() { // Only try to send out headers in case // those were not sent already if (!headers_sent()) { header("Cache-Control: private"); header("Pragma: no-cache"); } } // Guess the current site from what Apache tells us. // This should be the main name of the mirror (in case // it works under more then one name). SERVER_NAME is // the name of the Apache vhost. $MYSITE = 'http://' . $_SERVER["SERVER_NAME"] . '/'; // 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). $MYSITE = 'http://' . preg_replace("!^www\\.!", "", $_SERVER["HTTP_HOST"]) . '/'; // 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 if (isset($_SERVER['MIRROR_LANGUAGE'])) { if (isset($LANGUAGES[$_SERVER['MIRROR_LANGUAGE']])) { $MIRRORS[$MYSITE][6] = $_SERVER['MIRROR_LANGUAGE']; } } // Fallback to English in case the language // set is definitely not supported if (!isset($LANGUAGES[$MIRRORS[$MYSITE][6]])) { $MIRRORS[$MYSITE][6] = "en"; } // Override central stats information if specified in vhost if (isset($_SERVER['MIRROR_STATS'])) { $MIRRORS[$MYSITE][2] = TRUE; } // Provide base href information to make relative links on // shortcut URL accessed pages work without redirection if (isset($_SERVER['BASE_PAGE'])) { $_SERVER['BASE_HREF'] = $MYSITE . $_SERVER['BASE_PAGE']; } else { unset($_SERVER['BASE_HREF']); }