#1
14.12.2011 11:26 Uhr
|
Ob es geht, musst du ja beim Test sehen?
ich habe noch was altes rum liegen, da hatte ich aber auch die URLs der Suchengines abgeglichen um nicht alles zu bekommen.
function ls_get_refer() {
// Break out quickly so we don't waste CPU cycles on non referrals
if (!isset($_SERVER['HTTP_REFERER']) || ($_SERVER['HTTP_REFERER'] == '')) return false;
// no google reader
if (strpos($_SERVER['HTTP_REFERER'], "/reader/view")) return false;
$referer_info = parse_url($_SERVER['HTTP_REFERER']);
$referer = $referer_info['host'];
// Remove www. is it exists
if (substr($referer, 0, 4) == 'www.')
$referer = substr($referer, 4);
return $referer;
}
function ls_get_delim($ref) {
$search_engines = array(
'google.com' => 'q',
'images.google.com' => 'prev',
'google.de' => 'q',
'images.google.de' => 'prev',
'google.it' => 'q',
'images.google.it' => 'prev',
'google.be' => 'q',
'images.google.be' => 'prev',
'google.at' => 'q',
'images.google.at' => 'prev',
'google.ch' => 'q',
'images.google.ch' => 'prev',
'google.nl' => 'q',
'images.google.nl' => 'prev',
'go.google.com' => 'q',
'maps.google.com' => 'q',
'local.google.com' => 'q',
'search.yahoo.com' => 'p',
'fr.search.yahoo.com' => 'p',
'search.msn.com' => 'q',
'msxml.excite.com' => 'qkw',
'search.lycos.com' => 'query',
'alltheweb.com' => 'q',
'search.aol.com' => 'query',
'search.iwon.com' => 'searchfor',
'ask.com' => 'q',
'de.ask.com' => 'q',
'ask.co.uk' => 'ask',
'search.cometsystems.com' => 'qry',
'hotbot.com' => 'query',
'overture.com' => 'Keywords',
'metacrawler.com' => 'qkw',
'search.netscape.com' => 'query',
'looksmart.com' => 'key',
'dpxml.webcrawler.com' => 'qkw',
'search.earthlink.net' => 'q',
'search.viewpoint.com' => 'k',
'mamma.com' => 'query',
'suche.t-online.de' => 'q',
'de.altavista.com' => 'q',
'fireball.de' => 'q',
'freenet.de' => 'q',
'suche.freenet.de' => 'query',
'dmoz.de' => 'q',
'fastbot.de' => 'q',
'allesklar.de' => 'q',
'web.de' => 'q',
'infoseeker.de' => 'q',
'hotbot.de' => 'q',
'blogsearch.google.com' => 'q',
'blogsearch.google.de' => 'q',
'blogsearch.google.ch' => 'q',
'blogsearch.google.at' => 'q',
'search.blogger.com' => 'q',
'de.search.yahoo.com' => 'p',
'ch.search.yahoo.com' => 'p',
'at.search.yahoo.com' => 'p',
'suche.lycos.de' => 'query',
'search.lycos.ch' => 'query',
'suche.lycos.at' => 'query',
'suche.aol.de' => 'q',
'suche.aolsvc.de' => 'q',
'sucheaol.aol.de' => 'query',
'search.ch' => 'q',
'search.bluewin.ch' => 'query',
'eu.ixquick.com' => 'query',
'clusty.com' => 'query',
'partner.exalead.com' => 'q',
'search.abacho.com' => 'q',
'mserv.rrzn.uni-hannover.de' => 'eingabe',
'gmx.net' => 'search',
'search.seznam.cz' => 'w',
'startgoogle.startpagina.nl' => 'q',
'search.platformaonline.com' => 'q',
'hispeed.ch' => 'q',
'answers.com' => 's',
'metager1.de' => 'q',
'metager2.de' => 'q',
'pagead2.googlesyndication.com/pagead/ads' => 'client',
'bing.com' => 'q'
);
$delim = false;
// Check to see if we have a host match in our lookup array
if ( isset($search_engines[$ref]) ) {
$delim = $search_engines[$ref];
} else {
// Lets check for referrals for international TLDs and sites with strange formats
// Optimizations
$sub13 = substr($ref, 0, 13);
// Search string for engine
if (substr($ref, 0, 7) == 'google.')
$delim = "q";
elseif ($sub13 == 'search.atomz.')
$delim = "sp-q";
elseif (substr($ref, 0, 11) == 'search.msn.')
$delim = "q";
elseif ($sub13 == 'search.yahoo.')
$delim = "p";
elseif ( preg_match('/home\.bellsouth\.net\/s\/s\.dll/i', $ref) )
$delim = "bellsouth";
}
return $delim;
}
function ls_get_terms($d) {
$terms = null;
$query_array = array();
$query_terms = null;
// Get raw query
$query = explode('&'.$d.'=', $_SERVER['HTTP_REFERER']);
if ($query[1] == '') {
$query = explode('?'.$d.'=', $_SERVER['HTTP_REFERER']);
}
$query = explode('&', $query[1]);
$query = urldecode($query[0]);
// Remove quotes, split into words, and format for HTML display
//$query = str_replace("&hl=de&rlz=", '', $query);
$query = str_replace("'", '', $query);
$query = str_replace('"', '', $query);
$query = str_replace("/images?q=", '', $query);
// google-image search
$query_imgstr = strstr($query, '&hl=');
$query = str_replace($query_imgstr, '', $query);
$query_imgstr = strstr($query, '&um=');
$query = str_replace($query_imgstr, '', $query);
$query_array = preg_split('/[\s,\+\.]+/',$query);
$query_terms = implode(' ', $query_array);
$terms = urldecode($query_terms);
return $terms;
}
// Return true if the referer is a search engine
function ls_getinfo() {
// Did we come from a search engine?
$referer = ls_get_refer();
if ( ! $referer ) return false;
$delimiter = ls_get_delim( $referer );
if ($delimiter) {
$terms = ls_get_terms($delimiter);
if ( strlen($terms) != 0 )
echo $terms;
}
}
|