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';
/*
See http://php.net/mirroring-search for directions if you want
to run the search engine on your mirror site.
*/
// ============================================================================
// For safety reasons, we disallow the
// setting of this variable from outside
unset($htsearch_prog);
// Load in mirror specific configuration data (htdig path)
if (file_exists("configuration.inc")) {
include_once 'configuration.inc';
}
// Override configuration.inc setting with per vhost setting
// [this will be used in the future instead of configuration.inc]
if (isset($_SERVER['HTSEARCH_PROG'])) {
$htsearch_prog = $_SERVER['HTSEARCH_PROG'];
}
// If the program to use to search is not excutable, we cannot
// get search results, regardless of what we do
if (!@is_executable($htsearch_prog)) {
unset($htsearch_prog);
}
// ============================================================================
/* Form parameters expected:
pattern - search keywords
lang - language to limit search to [this is not
used currently in searches, only for redirection!!!]
show - target of search action
base - base URL to point result links to
*/
// If PHP added some slashes to quotes, get rid of them
if ($MQ) {
if (isset($pattern)) { $pattern = stripslashes($pattern); }
if (isset($base)) { $base = stripslashes($base); }
if (isset($lang)) { $lang = stripslashes($lang); }
}
// Set language to the preferred one if not set
// (also preserves $lang if provided in POST/GET)
if (!isset($lang) && isset($LANG)) {
$lang = $LANG;
}
// Only allow alphabetical chars in lang (security)
if (!preg_match("!^\\w+$!", $lang)) {
$lang = default_language();
}
// Only allow alphabetical chars in show (security)
if (!isset($show) || !preg_match("!^\\w+$!", $show)) {
$show = "wholesite";
}
// Set base if it is not specified
if (!isset($base)) {
// The base is the referrer site. Check if it was a PHP mirror site,
// and not some other site offering a direct PHP.net search form.
// Links should not be pointed back to a non PHP.net mirror site
if (isset($_SERVER['HTTP_REFERER']) && preg_match("!^http://(\\w{2}\\d?)\\.php\\.net/!", $HTTP_REFERER, $matches) &&
$matches[1] != 'qa') {
$base = "http://{$matches[1]}.php.net/";
}
unset($matches);
}
// If we are on the same site, there is no need for the base
// This makes URLs shorter and POST data smaller.
if (isset($base) && $base == $MYSITE) {
unset($base);
}
// If we still have a base, we need to make relative
// links be relative to the original server
unset($SEARCH_BASE);
if (isset($base)) {
$SEARCH_BASE = $base . "search.php";
}
// ============================================================================
// We received something to search for
if (isset($pattern)) {
// Remember the last search settings for a week
mirror_setcookie("LAST_SEARCH", "$show,$pattern", 60*60*24*7);
// Mailing list search base URL
$ml_url = "http://marc.theaimsgroup.com/";
// Do redirections for external search engines
switch ($show) {
// Quick reference lookup
case "quickref" :
header("Location: manual-lookup.php?pattern=" . urlencode($pattern) . "&lang=$lang");
exit;
// PHP-General mailing list search
case "maillist" :
$query = "l=php-general&r=1&w=2&q=b&s=" . urlencode($pattern);
header("Location: $ml_url?$query");
exit;
// Internals (known as php-dev by marc) mailing list search
case "devlist" :
$query = "l=php-dev&r=1&w=2&q=b&s=" . urlencode($pattern);
header("Location: $ml_url?$query");
exit;
// PHPDoc mailing list search
case "phpdoc" :
$query = "l=phpdoc&r=1&w=2&q=b&s=" . urlencode($pattern);
header("Location: $ml_url?$query");
exit;
// Bug database search
case "bugdb" :
// Redirect to bug page in case of exact number
if (preg_match("!^\\d+$!", $pattern)) {
header("Location: http://bugs.php.net/$pattern");
}
// Redirect to bug search page in case of some other pattern
else {
$location = "http://bugs.php.net/search.php";
$query = "cmd=Display+Bugs&status=All&bug_type=Any&search_for=" . urlencode($pattern);
header("Location: $location?$query");
}
exit;
}
$site = substr($MYSITE, 7, strlen($MYSITE) - 8);
header("Location: http://www.google.com/search?q=" . urlencode($pattern) .
"+site:www.php.net&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");
echo "The search service is currently not available..
";
echo "Please try later.\n";
commonFooter();
exit;
}
// We can redirect to the php.net search page
else {
$location = "http://ch.php.net/search.php";
$query = "show=$show&pattern=" . urlencode($pattern) .
"&base=" . urlencode($MYSITE) . "&lang=$lang";
header("Location: $location?$query");
exit;
}
}
// The local search engine is in place, and some
// local search function is needed, so try to do it
else {
// Print out common headers
commonHeader("Search Results");
echo "
Website search powered by " . make_link("http://www.htdig.org/", "ht://Dig") . "
\n"; // End HTML page with footer commonFooter(); } } // else of isset($pattern) else { // Print out common header commonHeader("Site Search"); // Choose the target for the search form if (isset($htsearch_prog)) { $target = $PHP_SELF; } else { $target = "http://ch.php.net/search.php"; } ?>| ' . $display . ' | ';
echo '|
| ' . spacer(1, 1, TRUE) . ' | |
| ' . $prev . ' | ';
echo '' . $next . ' | ';
echo '