db error

"); @mysql_select_db($db_name); } ?> MakeCacheDir (nome1/nome2) // Get var if not 60 seconds old $variable = $cache->Get("variable_with_id", 60); if (!$variable) { // Cache file expired or is inexistant // Do something to get new data $cache->Set("variable_with_id", $newdata); $variable = $newdata; } echo $variable; **/ class Cacher { // How long to cache something for in seconds, default 1hr var $defaultCacheLife = "1296000"; var $cacheDir = null; // Where things are cached to (must have trailing slash!) /*function MakeCacheDir ($dir_cache){#nome1/nome2 $array_dir=explode("/",$dir_cache); $cacheDir2=$this->cacheDir; foreach ($array_dir as $makedir){ $cacheDir2.=$makedir; @mkdir ($cacheDir2, 0777); $cacheDir2.="/"; } return $dir_cache; }*/ /** Set($varId, $varValue) -- Creates a file named "VARID.TIMESTAMP" and fills it with the serialized value from $varValue. If a cache file with the same varId exists, Delete() will remove it. **/ function __construct() { $this->cacheDir = "/var/www/vhosts/"; } function Set($varId, $varValue) { // Clean up old caches with same varId // Create new file $fileHandler = fopen($this->cacheDir . $varId . ".cache", "w"); // Write serialized data fwrite($fileHandler, serialize($varValue)); fclose($fileHandler); } /** Get($varID, $cacheLife) -- Retrives the value inside a cache file specified by $varID if the expiration time (specified by $cacheLife) is not over. If expired, returns FALSE **/ function Get($varId, $cacheLife="") { // Set default cache life $cacheLife = (!empty($cacheLife)) ? $cacheLife : $this->defaultCacheLife; // Cache file creation time $cacheFile = $this->cacheDir . $varId . ".cache"; $cacheFileLife =@filemtime($cacheFile); // Full location /* Check to see if cache file has expired or not */ if ((time() - $cacheFileLife) < $cacheLife) { $fileHandler = fopen($cacheFile, "r"); $varValueResult = fread($fileHandler, filesize($cacheFile)); fclose($fileHandler); // Still good, return unseralized data return unserialize($varValueResult); } return FALSE; } } ?> (&(?:[a-z]{0,4}\w{2,3};|#\d{2,5};)))|(\S+?)", "'\\1'.mb_encode_numericentity('\\2',array(0x0,0x2FFFF,0,0xFFFF),'UTF-8')", $str, "ime"); $str = correctIllegalEntities($str); return $str; } } // Convert common characters to named or numbered entities function makeTagEntities($str, $useNamedEntities = 1) { // Note that we should use ' for the single quote, but IE doesn't like it $arrReplace = $useNamedEntities ? array(''','"','<','>') : array(''','"','<','>'); return str_replace(array("'",'"','<','>'), $arrReplace, $str); } // Convert ampersands to named or numbered entities. // Use regex to skip any that might be part of existing entities. function makeAmpersandEntities($str, $useNamedEntities = 1) { return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/m", $useNamedEntities ? "&" : "&", $str); } // Convert illegal HTML numbered entities in the range 128 - 159 to legal couterparts function correctIllegalEntities($str) { $chars = array( 128 => '€', 130 => '‚', 131 => 'ƒ', 132 => '„', 133 => '…', 134 => '†', 135 => '‡', 136 => 'ˆ', 137 => '‰', 138 => 'Š', 139 => '‹', 140 => 'Œ', 142 => 'Ž', 145 => '‘', 146 => '’', 147 => '“', 148 => '”', 149 => '•', 150 => '–', 151 => '—', 152 => '˜', 153 => '™', 154 => 'š', 155 => '›', 156 => 'œ', 158 => 'ž', 159 => 'Ÿ'); foreach (array_keys($chars) as $num) $str = str_replace("&#".$num.";", $chars[$num], $str); return $str; } // Compare to native utf8_encode function, which will re-encode text that is already UTF-8 function makeUTF8($str,$encoding = "") { if ($str !== "") { if (empty($encoding) && isUTF8($str)) $encoding = "UTF-8"; if (empty($encoding)) $encoding = mb_detect_encoding($str,'UTF-8, ISO-8859-1'); if (empty($encoding)) $encoding = "ISO-8859-1"; // if charset can't be detected, default to ISO-8859-1 return $encoding == "UTF-8" ? $str : @mb_convert_encoding($str,"UTF-8",$encoding); } } // Much simpler UTF-8-ness checker using a regular expression created by the W3C: // Returns true if $string is valid UTF-8 and false otherwise. // From function isUTF8($str) { return preg_match('%^(?: [\x09\x0A\x0D\x20-\x7E] // ASCII | [\xC2-\xDF][\x80-\xBF] // non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] // excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} // straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] // excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} // planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} // planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} // plane 16 )*$%xs', $str); } function ExtractKeywords($refurl) { global $searchengine,$searchengineurl,$sechecked; $ses=array( '4Anything'=>array( 'url'=>'', 'query'=>'query'), '7Metasearch'=>array( 'url'=>'', 'query'=>'q'), '7Search'=>array( 'url'=>'', 'query'=>'qu'), 'About'=>array( 'url'=>'', 'query'=>'terms'), 'AllTheWeb'=>array( 'url'=>'', 'query'=>'query'), // Altavista 'Altavista Austria'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Australia'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Belgium (French)'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Belgium (Dutch)'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Brazil'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Canada (English)'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Canada (French)'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Switzerland (German)'=>array('url'=>'', 'query'=>'q'), 'Altavista Switzerland (French)'=>array('url'=>'', 'query'=>'q'), 'Altavista Czech Republic'=>array( 'url'=>'', 'query'=>'p'), 'Altavista Germany'=>array( 'url'=>'', 'query'=>'p'), 'Altavista Denmark'=>array( 'url'=>'', 'query'=>'p'), 'Altavista Spain'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Finland'=>array( 'url'=>'', 'query'=>'q'), 'Altavista France'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Health'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Hungary'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Ireland'=>array( 'url'=>'', 'query'=>'q'), 'Altavista India'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Italy'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Korea (South)'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Mexico'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Netherlands'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Norway'=>array( 'url'=>'', 'query'=>'q'), 'Altavista New Zealand'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Portugal'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Sweden'=>array( 'url'=>'', 'query'=>'q'), 'Altavista United Kingdom'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Listings'=>array( 'url'=>'','query'=>'q'), 'Altavista Raging Search'=>array( 'url'=>'','query'=>'q'), 'Altavista'=>array( 'url'=>'', 'query'=>'q'), 'Altavista Poland'=>array( 'url'=>'', 'query'=>'q'), // AOL 'AOL'=>array( 'url'=>'', 'query'=>'query'), 'AOL Tv'=>array( 'url'=>'', 'query'=>'query'), 'AOL Australia'=>array( 'url'=>'', 'query'=>'query'), 'AOL Brasil'=>array( 'url'=>'', 'query'=>'query'), 'AOL Canada'=>array( 'url'=>'', 'query'=>'query'), 'AOL Japan'=>array( 'url'=>'', 'query'=>'MT'), 'AOL UK'=>array( 'url'=>'', 'query'=>'query'), 'AOL Netfind'=>array( 'url'=>'', 'query'=>'query'), 'AOL Netfind Germany'=>array( 'url'=>'', 'query'=>'query'), // Ask Jeeves 'Ask Jeeves UK'=>array( 'url'=>'', 'query'=>'ask'), 'Ask Jeeves'=>array( 'url'=>'', 'query'=>'ask'), 'Ask Jeeves Kids'=>array( 'url'=>'', 'query'=>'ask'), 'Atomica'=>array( 'url'=>'', 'query'=>'s'), 'ATT News'=>array( 'url'=>'', 'query'=>'qry'), 'Austria'=>array( 'url'=>'', 'query'=>'query'), 'Bellsouth'=>array( 'url'=>'', 'query'=>'Keywords', 'query2'=>'string'), 'Biglobe Japan'=>array( 'url'=>'','query'=>'q'), 'Blueyonder'=>array( 'url'=>'','query'=>'q'), 'Bol (Brazil)'=>array( 'url'=>'', 'query'=>'q'), 'BlueWin Switzerland'=>array( 'url'=>'', 'query'=>'q'), 'BZZ Russia'=>array( 'url'=>'', 'query'=>'query'), 'Catloga (France)'=>array( 'url'=>'', 'query'=>'q'), 'Chopstix'=>array( 'url'=>'', 'query'=>'search'), 'Compuserve'=>array( 'url'=>'','query'=>'sTerm'), 'Curryguide'=>array( 'url'=>'','query'=>'query'), // DirectHit 'DirectHit/Ask Jeeves'=>array( 'url'=>'','query'=>'qry'), 'DirectHit/Britannica'=>array( 'url'=>'','query'=>'qry'), 'DirectHit/Comet'=>array( 'url'=>'', 'query'=>'qry'), 'DirectHit/Dictionary'=>array( 'url'=>'','query'=>'qry'), 'DirectHit/Megadirectory'=>array( 'url'=>'','query'=>'qry'), 'DirectHit/MSN'=>array( 'url'=>'', 'query'=>'qry'), 'DirectHit/Systema'=>array( 'url'=>'', 'query'=>'qry'), 'DirectHit/Webster'=>array( 'url'=>'', 'query'=>'qry'), 'DirectHit'=>array( 'url'=>'', 'query'=>'qry'), 'Open Directory Project'=>array( 'url'=>'', 'query'=>'search'), 'Dogpile'=>array( 'url'=>'', 'query'=>'q'), 'Dreamx'=>array( 'url'=>'', 'query'=>'query'), 'Earthlink'=>array( 'url'=>'', 'query'=>'Keywords'), 'Education World'=>array( 'url'=>'','query'=>'queryText'), 'Elsitio'=>array( 'url'=>'', 'query'=>'palabras'), 'Elmundo Spain'=>array( 'url'=>'', 'query'=>'q'), 'Espotting'=>array( 'url'=>'','query'=>'keyword'), 'Eureka'=>array( 'url'=>'', 'query'=>'q'), // Excite 'Excite Austria'=>array( 'url'=>'', 'query'=>'search'), 'Excite Australia'=>array( 'url'=>'', 'query'=>'search'), 'Excite Chinese'=>array( 'url'=>'', 'query'=>'search'), 'Excite Canada'=>array( 'url'=>'', 'query'=>'search'), 'Excite Germany'=>array( 'url'=>'', 'query'=>'search'), 'Excite Denmark'=>array( 'url'=>'', 'query'=>'search'), 'Excite Spain'=>array( 'url'=>'', 'query'=>'search'), 'Excite France'=>array( 'url'=>'', 'query'=>'search'), 'Excite Italy'=>array( 'url'=>'', 'query'=>'search'), 'Excite Japan'=>array( 'url'=>'', 'query'=>'search'), 'Excite UK'=>array( 'url'=>'', 'query'=>'search'), 'Findia'=>array( 'url'=>'', 'query'=>'query'), 'Go/Infoseek'=>array( 'url'=>'', 'query'=>'qt'), // Google 'Google Directory'=>array( 'url'=>'', 'query'=>'q'), 'Google/Gotonet'=>array( 'url'=>'', 'query'=>'q'), 'Google Groups'=>array( 'url'=>'', 'query'=>'q'), 'Google Images'=>array( 'url'=>'', 'query'=>'q'), 'Google'=>array( 'url'=>'', 'query'=>'q', 'query2'=>'query'), 'Google WAP'=>array( 'url'=>'', 'query'=>'q', 'query2'=>'query'), 'Google (Austria)'=>array( 'url'=>'', 'query'=>'q'), 'Google (United Arab Emirates)'=>array('url'=>'', 'query'=>'q'), 'Google (Belgium)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Canada)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Cocos (Keeling) Islands)'=>array('url'=>'', 'query'=>'q'), 'Google (Switzerland)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Costa Rica)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Israel)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Japan)'=>array( 'url'=>'', 'query'=>'q'), 'Google (South Korea)'=>array( 'url'=>'', 'query'=>'q'), 'Google (New Zealand)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Thailand)'=>array( 'url'=>'', 'query'=>'q'), 'Google (United Kingdom)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Argentina)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Brasil)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Greece)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Poland)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Russia)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Germany)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Micronesia)'=>array( 'url'=>'', 'query'=>'q'), 'Google (France)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Ireland)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Italy)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Liechtenstein)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Lithuania)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Latvia)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Netherlands)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Portugal)'=>array( 'url'=>'', 'query'=>'q'), 'Google (Portugal/English)'=>array( 'url'=>'', 'query'=>'q'), 'Google (British Virgin Islands)'=>array('url'=>'', 'query'=>'q'), 'Goto'=>array( 'url'=>'', 'query'=>'Keywords'), 'Hananet'=>array( 'url'=>'', 'query'=>'query'), 'Hanafos'=>array( 'url'=>'', 'query'=>'query'), 'Hispatvista'=>array( 'url'=>'', 'query'=>'cadena'), 'HotBot'=>array( 'url'=>'', 'query'=>'query'), 'ICQ/Google'=>array( 'url'=>'', 'query'=>'q'), 'Infospace'=>array( 'url'=>'', 'query'=>'qkw'), 'Infospace'=>array( 'url'=>'', 'query'=>'qkw'), 'IOL Italy'=>array( 'url'=>'','query'=>'B1'), 'IOL Israel'=>array( 'url'=>'', 'query'=>'q'), 'IPoinc Hong Kong'=>array( 'url'=>'', 'query'=>'terms'), 'IXQuick'=>array( 'url'=>'', 'query'=>'query'), ''=>array( 'url'=>'', 'query'=>'Keywords'), 'Kolumbus Finland'=>array( 'url'=>'', 'query'=>'q'), 'Kvasir (Norway)'=>array( 'url'=>'', 'query'=>'q'), 'Libero'=>array( 'url'=>'', 'query'=>'query'), 'LinkSynergy'=>array( 'url'=>'', 'query'=>'q'), 'LookSmart (CNN)'=>array( 'url'=>'', 'query'=>'key'), 'LookSmart (CNNFN)'=>array( 'url'=>'', 'query'=>'key'), // Lycos 'Lycos'=>array( 'url'=>'', 'query'=>'query'), 'Lycos/Hotbot Directory'=>array( 'url'=>'', 'query'=>'MT'), 'Lycos/Hotbot'=>array( 'url'=>'', 'query'=>'MT', 'query2'=>'query'), 'Lycos/Lycospro'=>array( 'url'=>'', 'query'=>'query'), 'LycosAsia India'=>array( 'url'=>'', 'query'=>'query'), 'LycosAsia Malaysia'=>array( 'url'=>'', 'query'=>'query'), 'Lycos Italy'=>array( 'url'=>'', 'query'=>'query'), 'Lycos Spain'=>array( 'url'=>'', 'query'=>'query'), 'Lycos/Google Korea (South)'=>array( 'url'=>'', 'query'=>'q'), 'Lycos Russia'=>array( 'url'=>'', 'query'=>'query'), 'Mamma'=>array( 'url'=>'', 'query'=>'query'), 'Metacrawler'=>array( 'url'=>'', 'query'=>'general'), 'Mirago'=>array( 'url'=>'', 'query'=>'qry'), 'MSN Search'=>array( 'url'=>'', 'query'=>'q'), 'MSN Canada (French)'=>array( 'url'=>'', 'query'=>'q'), 'MSN'=>array( 'url'=>'', 'query'=>'MT,q'), 'MyNet'=>array( 'url'=>'', 'query'=>'q'), 'NANA Israel'=>array( 'url'=>'', 'query'=>'string'), 'NANA Israel (English)'=>array( 'url'=>'', 'query'=>'string'), 'Naver'=>array( 'url'=>'', 'query'=>'query', 'query2'=>'oldquery'), 'NBCI'=>array( 'url'=>'', 'query'=>'keyword'), 'NetBul'=>array( 'url'=>'', 'query'=>'keyword'), // Netscape 'Netscape/Excite Australia'=>array( 'url'=>'','query'=>'search'), 'Netscape/Excite Germany'=>array( 'url'=>'','query'=>'search'), 'Netscape/Excite France'=>array( 'url'=>'','query'=>'search'), 'Netscape/Excite UK'=>array( 'url'=>'','query'=>'search'), 'Netscape (Directory)'=>array( 'url'=>'','query'=>'search'), 'Netscape/Google'=>array( 'url'=>'', 'query'=>'query,q'), 'Netscape NetBusiness'=>array( 'url'=>'', 'query'=>'searchString'), 'Netscape'=>array( 'url'=>'', 'query'=>'search'), 'Netscape Online'=>array( 'url'=>'', 'query'=>'query'), 'Northernlight'=>array( 'url'=>'', 'query'=>'qr'), 'Nomade France'=>array( 'url'=>'', 'query'=>'MT'), 'New Net'=>array( 'url'=>'','query'=>'Keywords'), 'Opasia Denmark'=>array( 'url'=>'', 'query'=>'q'), 'OZU Spain'=>array( 'url'=>'', 'query'=>'q'), 'Passagen Sweden'=>array( 'url'=>'', 'query'=>'q'), ''=>array( 'url'=>'', 'query'=>'q'), 'Searchopolis'=>array( 'url'=>'', 'query'=>'request'), 'Snap'=>array( 'url'=>'', 'query'=>'keyword'), 'StarMedia'=>array( 'url'=>'','query'=>'query'), 'Superonline'=>array( 'url'=>'','query'=>'query'), 'Spray/Lycos Sweden'=>array( 'url'=>'', 'query'=>'query'), 'Spray/Lycossvar Sweden'=>array( 'url'=>'', 'query'=>'query'), 'Suomi24 Finland'=>array( 'url'=>'', 'query'=>'q'), 'Terra (Brasil)'=>array( 'url'=>'', 'query'=>'query'), 'Terra (Spain)'=>array( 'url'=>'', 'query'=>'Claus', 'query2'=>'query'), 'Tiscalinet'=>array( 'url'=>'', 'query'=>'query'), 'T-Online (Germany)'=>array( 'url'=>'', 'query'=>'q'), 'UOL Argentina'=>array( 'url'=>'', 'query'=>'q'), 'Virgilio/Google'=>array( 'url'=>'', 'query'=>'qs', 'extra'=>'db=gg'), 'Virgilio/Altavista'=>array( 'url'=>'', 'query'=>'qs', 'extra'=>'db=av'), 'Virgilio'=>array( 'url'=>'', 'query'=>'qs'), 'Ya'=>array( 'url'=>'', 'query'=>'item'), // Yahoo 'Yahoo/Busca Brasil'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Argentina'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Asia'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Brasil'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Canada'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google China'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Germany'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Denmark'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Spain'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google France'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Hong Kong (English)'=>array('url'=>'','query'=>'p'), 'Yahoo/Google India'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Italy'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Mexico'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Sweden'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google Singapore'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google United Kingdom'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Asia'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Australia'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Canada'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Germany'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Denmark'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search France'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search India'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Mexico'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Norway'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Sweden'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search Singapore'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Search United Kingdom'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo/Google'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Chinese'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Spanish'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Advanced Search'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Inktomi Singapore'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Inktomi United Kingdom'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo Inktomi'=>array( 'url'=>'', 'query'=>'p'), 'Yahoo'=>array( 'url'=>'', 'query'=>'p'), 'Weather underground'=>array( 'url'=>'', 'query'=>'q,search'), 'Weather underground (Dutch)'=>array( 'url'=>'', 'query'=>'search'), 'Walla Israel'=>array( 'url'=>'', 'query'=>'q'), 'Web Agri (France)'=>array( 'url'=>'', 'query'=>'SearchString'), 'WWW Finland'=>array( 'url'=>'', 'query'=>'qt,w'), 'WWW Finland'=>array( 'url'=>'', 'query'=>'word'), ); $replacements=array( // Replace this host With this one '204\.152\.166\.41' => '', '204\.152\.166\.43' => '', '208\.49\.237\.73' => '', '64\.210\.177\.12' => '', '205\.178\.174\.151' => '', '206\.132\.152\.250' => '', '216\.15\.219\.40' => '', '216\.200\.119\.160' => '', '216\.239\.[0-9]+\.[0-9]+' => '', 'go[o]?[o]?gle\.[net|org]' => '', '[googil|goolge|wwwgoogle]\.com'=> '', '216\.34\.146\.167:8000' => '', '216\.46\.233\.50' => '', '62\.0\.45\.51' => '', 'aj\.com' => '', '' => '', '' => '', '' => '', '' => '', '' => '', 'av\.com' => '', '' => '', '' => '', '' => '', '' => '', '' => '', 'go2\.com' => '', 'results.*\.profusion\.com' => '', 's[0-9]+\.ixquick\.com' => '', 'search.*\.virgilio\.it' => '', 'search2\.cometsystems\.com' => '', 'www.*\.savvysearch\.com' => '', '[0-9]+' => '', '' => '', '' => '', '' => '', '' => '', ); if (ereg('^(.*)\?(.*)',$refurl,$regs)) { $refhost=$regs[1];$refquery=$regs[2]; foreach ($replacements as $key => $value) { if (preg_match("/^http:\/\/(www)?".$key."\//",$refhost)) { $refhost="http://".$value."/"; break; } } $sechecked=0; foreach($ses as $name=>$seng) { $sechecked++; if (ereg($seng['url']."/",$refhost)) { if (isset($seng['home'])) { // if there is a 'set homepage' for the SE, store that $searchengineurl="http://".$seng['home']."/"; } else { // other wise 'build' the SE's URL based on the search URL $searchengineurl="http://www.".$seng['url']."/"; } if (isset($seng['extra'])) { //any extra parameters to check ? if (!preg_match('/'.$seng['extra'].'/Ui',$refquery)) { continue; } } if (preg_match('/'.$seng['query'].'=(.*)(?:&|$)/Ui',$refquery,$regs)) { // ok, we have a match! $searched=urldecode($regs[1]); $keywords=$searched; $keywords=split(' ',$searched); // split up the keywords $searchengine=$name; // store the name of the search engine } else { if (isset($seng["query2"])) { if (preg_match('/'.$seng['query2'].'=(.*)(?:&|$)/Ui',$refquery,$regs)) { // ok, we have a match! $searched=urldecode($regs[1]); $keywords=$searched; $keywords=split(' ',$searched); // split up the keywords $searchengine=$name; // store the name of the search engine } } // end if (isset($seng["query2"])) { } // end if (preg_match('/'.$seng['query'].'(.*)(?:&|$)/Ui',$refquery,$regs) break; // exit the foreach loop } // end if (ereg($seng['url']."/",$refurl)) { } // end foreach($ses as $name=>$seng) { } // end if (ereg('^(.*)\?(.*)',$refurl,$regs)) // this little bit added by jennifer @ // to prevent breaking if url passed in was not a search query if (isset($searched)) { return $searched; } else { return; } } #-------------------------------------------------------------- $url =getenv("HTTP_REFERER"); $searched = ExtractKeywords($url); if (isset($searched)): mysql_conn(); $sql="UPDATE referrals SET hits=hits+1 WHERE kw = '".addslashes($searched)."' AND url_page='".$_SERVER['REQUEST_URI']."' AND refer='".$searchengine."'"; mysql_query($sql); if (mysql_affected_rows()>0): $sql2="INSERT INTO referrals (url_page,kw,hits,refer) VALUES ('".$_SERVER['REQUEST_URI']."','".addslashes($searched)."','1','".$searchengine."')"; mysql_query($sql2); endif; endif; ?>