summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-07-28 17:15:20 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-07-28 17:16:02 +0200
commit079b3ac10d5d47b9d24320337a7b477f64f060af (patch)
tree0a2ea30cc547dafbc4efd7d31bcf70a9eebeb8f3 /inc/common.php
parentc4a2059c6e88bf3055f0ba3f8e079f10c950e1b0 (diff)
downloadrpg-079b3ac10d5d47b9d24320337a7b477f64f060af.tar.gz
rpg-079b3ac10d5d47b9d24320337a7b477f64f060af.tar.bz2
highlight queries from popular serch engines only FS#2448
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/inc/common.php b/inc/common.php
index 33da2523a..ac7e744d8 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1197,8 +1197,10 @@ function getGoogleQuery() {
}
$url = parse_url($_SERVER['HTTP_REFERER']);
- $query = array();
+ // only handle common SEs
+ if(!preg_match('/(google|bing|yahoo|ask|duckduckgo|babylon|aol|yandex)/',$url['host'])) return '';
+ $query = array();
// temporary workaround against PHP bug #49733
// see http://bugs.php.net/bug.php?id=49733
if(UTF8_MBSTRING) $enc = mb_internal_encoding();
@@ -1206,16 +1208,16 @@ function getGoogleQuery() {
if(UTF8_MBSTRING) mb_internal_encoding($enc);
$q = '';
- if(isset($query['q']))
- $q = $query['q']; // google, live/msn, aol, ask, altavista, alltheweb, gigablast
- elseif(isset($query['p']))
- $q = $query['p']; // yahoo
- elseif(isset($query['query']))
- $q = $query['query']; // lycos, netscape, clusty, hotbot
- elseif(preg_match("#a9\.com#i", $url['host'])) // a9
- $q = urldecode(ltrim($url['path'], '/'));
-
- if($q === '') return '';
+ if(isset($query['q'])){
+ $q = $query['q'];
+ }elseif(isset($query['p'])){
+ $q = $query['p'];
+ }elseif(isset($query['query'])){
+ $q = $query['query'];
+ }
+ $q = trim($q);
+
+ if(!$q) return '';
$q = preg_split('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/', $q, -1, PREG_SPLIT_NO_EMPTY);
return $q;
}