From 71f7bde7834ef576e5312e68d5e739bfe70afbcb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 4 Aug 2007 14:51:24 +0200 Subject: generic search engines result highlighting darcs-hash:20070804125124-7ad00-5558de577207bb63af7629f278c24991f23924bc.gz --- inc/common.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 4f61db560..e812d181d 100644 --- a/inc/common.php +++ b/inc/common.php @@ -893,20 +893,27 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){ } /** - * extracts the query from a google referer + * extracts the query from a search engine referrer * - * @todo should be more generic and support yahoo et al * @author Andreas Gohr + * @author Todd Augsburger */ function getGoogleQuery(){ $url = parse_url($_SERVER['HTTP_REFERER']); if(!$url) return ''; - if(!preg_match("#google\.#i",$url['host'])) return ''; $query = array(); parse_str($url['query'],$query); - - return $query['q']; + if(isset($query['q'])) + return $query['q']; // google, live/msn, aol, ask, altavista, alltheweb, gigablast + elseif(isset($query['p'])) + return $query['p']; // yahoo + elseif(isset($query['query'])) + return $query['query']; // lycos, netscape, clusty, hotbot + elseif(preg_match("#a9\.com#i",$url['host'])) // a9 + return urldecode(ltrim($url['path'],'/')); + + return ''; } /** -- cgit v1.2.3