From aad52615ab9fe34c244d60d990dcccfd804f127a Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Sat, 16 Jul 2011 06:51:35 +0000 Subject: [PATCH] Distinguish between 404s and explicit searches and don't log mirrortest --- error.php | 2 +- manual-lookup.php | 4 ++++ quickref.php | 7 +++++-- search.php | 6 ++++-- ws.php | 6 +++++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/error.php b/error.php index 9247461ea..e61948afb 100644 --- a/error.php +++ b/error.php @@ -495,7 +495,7 @@ if (strpos($URI, "manual/") === 0) { // ============================================================================ // If no match was found till this point, the last action is to start a // search with the URI the user typed in -$fallback = (myphpnet_urlsearch() === MYPHPNET_URL_MANUAL ? "manual" : "quickref"); +$fallback = (myphpnet_urlsearch() === MYPHPNET_URL_MANUAL ? "404manual" : "404quickref"); mirror_redirect( '/search.php?show=' . $fallback . '&lang=' . urlencode($LANG) . '&pattern=' . urlencode(substr($_SERVER['REQUEST_URI'], 1)) diff --git a/manual-lookup.php b/manual-lookup.php index ede9550e9..b7e1e0422 100644 --- a/manual-lookup.php +++ b/manual-lookup.php @@ -16,6 +16,10 @@ if (empty($_GET['function'])) { $function = htmlspecialchars($_GET['function'], ENT_QUOTES, 'UTF-8'); } +if(!empty($_GET['scope'])) { + $scope = htmlspecialchars($_GET['scope'], ENT_QUOTES, 'UTF-8'); +} else $scope = ''; + // Prepare data for search if ($function) { if ($MQ) { diff --git a/quickref.php b/quickref.php index 3d5a998a6..4343566e8 100644 --- a/quickref.php +++ b/quickref.php @@ -1,5 +1,4 @@ 2): -$srch_rqst = "/ws.php?profile=local&q=".urlencode($notfound)."&lang=$LANG&results=5&start=0&mirror=".trim(substr($MYSITE,7),'/'); +$srch_rqst = "/ws.php?profile=$scope&q=".urlencode($notfound)."&lang=$LANG&results=5&start=0&mirror=".trim(substr($MYSITE,7),'/'); $url = "http://www.php.net".$srch_rqst; $data = fetch_contents($url); if(!is_array($data)) { diff --git a/search.php b/search.php index 6ecdfcfbe..31aa4f093 100644 --- a/search.php +++ b/search.php @@ -49,8 +49,9 @@ if (!empty($_FORM['pattern'])) { switch ($_FORM['show']) { case "quickref" : + case "404quickref" : $langparam = (isset($EXPL_LANG) ? "&lang=$EXPL_LANG" : ""); - mirror_redirect("/manual-lookup.php?pattern={$ucp}{$langparam}"); + mirror_redirect("/manual-lookup.php?pattern={$ucp}{$langparam}&scope={$_FORM['show']}"); case "maillist" : mirror_redirect("{$ml_url}l=php-general&s={$ucp}"); @@ -76,7 +77,8 @@ if (!empty($_FORM['pattern'])) { } case "manual": - mirror_redirect($MYSITE . "results.php?q={$ucp}&p=manual&l=$LANG"); + case "404manual": + mirror_redirect($MYSITE . "results.php?q={$ucp}&p={$_FORM['show']}&l=$LANG"); break; case "news_archive": diff --git a/ws.php b/ws.php index bf44b1347..2ab34628f 100644 --- a/ws.php +++ b/ws.php @@ -12,8 +12,10 @@ $l = isset($_REQUEST['lang']) ? htmlspecialchars($_REQUEST['lang'], ENT_QUOTES) $m = isset($_REQUEST['mirror']) ? htmlspecialchars($_REQUEST['mirror'], ENT_QUOTES) : ''; $sites = array( 'all'=>'php.net', 'local'=>'www.php.net', - '404'=>'www.php.net', + 'quickref'=>'www.php.net', + '404quickref'=>'www.php.net', 'manual'=>"www.php.net/manual/$l", + '404manual'=>"www.php.net/manual/$l", 'news'=>'news.php.net', 'bugs'=>'bugs.php.net', 'pear'=>'pear.php.net', @@ -69,6 +71,7 @@ function ws_bing_massage($data) { return serialize($massaged); } +if($scope!='mirrortest'): $dbh = new PDO('mysql:host=localhost;dbname=ws', $conf['db_user'], $conf['db_pw'], array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true)); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -78,4 +81,5 @@ try { } catch (PDOException $e) { } +endif; ?>