// GET AND LOG QUERYSTRING FROM REFERER if ($_SERVER['HTTP_REFERER']){ $refer = $_SERVER['HTTP_REFERER']; $referrer_url = $refer; if (strstr($referrer_url, "google")) { $sitefrom = "Google"; $ptn = '![?&]q=([^&.]*)!'; } else if (strstr($referrer_url, "yahoo")) { $sitefrom = "Yahoo"; $ptn = '![?&]p=([^&.]*)!'; } else if (strstr($referrer_url, "msn")) { $sitefrom = "MSN"; $ptn = '![?&]q=([^&.]*)!'; } if (preg_match($ptn, $referrer_url, $matches)) { $qstring = urldecode($matches[1]); logaction("arrived from " . $sitefrom .", searched for '" . $qstring . "'"); } }