<?php
header("Content-Type: application/x-javascript");
?>if (!document.getElementById && document.all) {
	document.write("<style type=\"text\/css\">\n#prevnext{width:50%;}\n#menu{top:2000px;}\n<\/style>\n");
}
function posRight() {
if (location.hash == "#comments" && document.getElementById && document.getElementById(location.hash.substr(1)).offsetTop > document.getElementById("menubot").offsetTop) document.getElementById("menu").style.top = (document.getElementById(location.hash.substr(1)).offsetTop-document.getElementById("menubot").offsetTop+5)+"px";
if (!document.getElementById && document.all) {
	var layerPos = -3 + document.all['header'].offsetWidth;
	if(document.all['menu']){document.all['menu'].style.pixelLeft=layerPos;document.all['menu'].style.pixelTop=0;}
}}
<?php
$mysites= "safie|datatrain|monitor|mainframe-training|localhost";
$host	= getenv("HTTP_HOST");
$latest = "/safie/latest.log";
$log	= "/safie/referrer.htm";
$al	= getenv("HTTP_ACCEPT_LANGUAGE");
$ra	= $_SERVER["REMOTE_ADDR"];
$me	= 0;
if (ereg("^192\.168\.[0-2]\.", $ra) || $ra == "127.0.0.1" || $ra == "84.87.225.195") $me = 1;
$qs	= rawurldecode($_SERVER["QUERY_STRING"]);
$href	= rawurldecode($_SERVER["QUERY_STRING"]);
$ua	= $_SERVER["HTTP_USER_AGENT"];
if(!$href)	$href	= "http://www.monitor.nl/nohref.htm";
if(!$qs)	$qs	= "http://www.monitor.nl/noqs.htm";
$hr	= $href;
$rh	= explode("/", $hr);
if (eregi("($mysites)", $rh[2]) || ereg("atomz\.php", $hr)) {
  $hr	= $qs;
  $rh	= explode("/", $hr);
}
if (!eregi("($mysites)", $rh[2]) || ereg("atomz\.php", $hr)) {
	$lockout = "verjaardag|neuken|bordelen|bordeel|hoer|fellatio";

	# begin knip van ehrhardt.nl
	if (!$al)	$al	= $_SERVER["HTTP_ACCEPT_LANGUAGE"];
	if (!$remove)	$remove = "near";
	if (!$lockout)	$lockout = "noppes";
	if (!$mysites)	$mysites = "noppes";
	$exclhosts	= $exclhosts."massivecocks|tricus|surfcontrol|cheapweb|whois|precisionintelligence|tagword|adresses\.com|classicalcd|theyellowpages|loopnull|deep-depth-miner|greetingcard|techspecialties|instantssl|2host|freenet\.de|dressinha|kwmap|pc-repair|sealect-usa|revkom|netfactual|internic|young-direct|beasys|hostitcheap|miniatures|medicalanthropology|acroarte|bizland|internationallacquers|tfish\.net|hjequinedentistry|jobs\.bg|rayburn|xomar|websearchde|discount-first|a-b-l-o-g|wr18\.com|worldnewslog|malixya|teoras\.com|websearchus|blog|bongohome|akksess|saulem|mikesspot|mp3int|skysports|eisborussen|216\.219\.253\.225|college\.|spruce|iguatemi|du-q|atsync\.|lmhsoft\.|jfmulti|webserverland|mailsoft|acetools|producerstickets|bulk-email|wallacegroup|bwiusa|tina.hall|qualityinn|wholesale|bestseller|mail-marketing|mail-news|-software\.|zoeky|fok\.nl|agnitum\.com|plexmatrix|katsuhara|e-sulat|inissoft|grillshop24|doegrids|greenlaptop|kanoodle|myrice|bestofnet|marsfind|avantbrowser|warriorsaints|shareware-catalog|teleflorist|cfwb\.be|uptimebot|avantbrowser|citytower|ipower\.be|randomtaxi|dino-online|christycanyon|\.biz|teenkelly|seggi\.co|lollipop|dna-dna|site\.yahoo|tg\.ch|freehosting|hardcore|robert\.to|islam|skyart|relsoftware|enlarge|uncover|miragorobot|easythumbs|adminshop|datashaping|newprinceton|suite916|wilcox|drbook|parish|ige\.com|faxo|old-young|southernhill|arcades|pfyfn|zhenjiangstar|porn|xxx|neuf\.fr|itoverblik|battcave|shoplocal|pitbull|deconstruction|dynamics|michael|formular|euclids|revoforum|joshua|photo-info|7forum|aleksika|christ|saturn-kino|infospace|optimi|linkexplore|freehost|adult|keljob|webdev|istarthere|formula42|supervision|squeeze|dvd|kissing|xanax|smsportal|airplay|poker|hgh|hormo|beast|sex|blikvanrik|domain|covert|us-volley|money|kakke|syntryx|clickscoring|shaping|zoekbank|strippers|cfnm|fast-search|blowjob|apartment|natural|roundandbrown|inthevip|sitereview|teach2000|counter|misumena|adres|address|turnkey|russia\.com|page-not-found|monster|cock\.|mouth|jobs|fuck|lottery|financial|eastunion|globusy|trade-ideas|[0-9]teen|amat(eu|ue)r|dangerousdongs|unknown|shopping|buy-|qq\.com|cialis|adipex|phenter|hydroco|for-sale|designer|love\.com|v3\.com|cupid|anti.?spy|askmysite|barracuda|verblud|delfinno|hotinfocenter|levitra|payperview|mcr8\.com|carisoprodol|seccams|lol\.to|luck.*\.to|ripway|fioricet|servik|prozac|paxil|tenuate|bontril|didrex|4us?\.net|4us?\.com|black[-]?jack|bingo|licats|casino|koekjes|flash|games|adsense|cash|gambl|slot";
	$exclbots	= $exclbots."vagabondo|crawler|LinkWalker|htdig|yotta|OmniExplorer";
	$exclips	= $exclips."212\.19\.205";
	$temp = eregi_replace("(.*)(translate)(.*)(&u=http://[[:alnum:]]+\.($mysites)\.(nl|be|de|info))(.*)(&)(.*)", "\\7", $href);
	if (ereg("^/", $temp)) $href = $temp;
	$temp = eregi_replace("(.*)(translate)(.*)(&u=[[:alnum:]]+\.($mysites)\.(nl|be|de|info))(.*)(&)(.*)", "\\7", $href);
	if (ereg("^/", $temp)) $href = $temp;
	$temp = eregi_replace("(.*)(cache)(.*)(:[[:alnum:]]+\.($mysites)\.(nl|be|de|info))(.*)(\+)(.*)", "\\7", $href);
	if (ereg("^/", $temp)) $href = $temp;
	$hr = ereg_replace("^\?", "", $hr);
	$hr = str_replace("http://", "", $hr);
	$tekort = "voor|over|van|het|een|den|der|tot|ter|ten|uit|met|bij|and|what|[a-z][a-z]|[a-z]";
	if (!$ra)	$ra	= $_SERVER["REMOTE_ADDR"];
	if (!$host)	$host	= $_SERVER["HTTP_HOST"];
	$refhost = $host;
	$today = date( "d-m-y H:i:s", time() );
	$ua = $_SERVER["HTTP_USER_AGENT"];
	$mozilla4 = "Mozilla/4.0 (compatible; ";
	if ( stristr($ua, $mozilla4) ) {
	  $ua = str_replace($mozilla4, "", $ua);
	  $ua = str_replace(")", "", $ua);
	}
	$px = $_SERVER["HTTP_X_FORWARDED_FOR"];
	$pi = $_SERVER["HTTP_CLIENT_IP"];
	$pf = $_SERVER["HTTP_FORWARDED"];
	$hv = $_SERVER["HTTP_VIA"];
	$pu = $_SERVER["HTTP_PROXY_USER"];
	$sa = $_SERVER["SERVER_ADDR"];
	$j = 20 - strlen($host);
	while ($j > 0):
	  $host = "$host ";
	  $j--;
	endwhile;
	$zoek = 0;
	$search = "";
	$trimmed = "";
	$engine = "";
	function trimsearch($search) {
		global $tekort;
		$trimmed = " ".$search." ";
		$trimmed = eregi_replace("(( -)([a-z]|\+|\")+)+( )", " ", $trimmed);
#		$trimmed = eregi_replace("([a-z0-9])(-)([a-z0-9])", "\\1 \\3", $trimmed);
		$trimmed = ereg_replace("(\.|,|\+|-|:)", " ", $trimmed);
		$trimmed = eregi_replace("(( |-|\+)($tekort))+( |\")", "\\4", $trimmed);
		$trimmed = eregi_replace("( |\")(($tekort)( |-|\+))+", "\\1", $trimmed);
		$trimmed = eregi_replace("((\")($tekort)(\"))+", "", $trimmed);
		$trimmed = eregi_replace("(\")(([[:alnum:]])+)(\")", "\\2", $trimmed);
		$trimmed = ereg_replace(" +", " ", $trimmed);
		$trimmed = trim($trimmed);
		$trimmed2 = trim(ereg_replace("(.*)(\")(.*)(\")(.*)", "\\3", " ".$trimmed." "));
		if ($trimmed2 == $trimmed)	$trimmed2 = "";
		else				$trimmed2 = " ".$trimmed2;
		return("$trimmed$trimmed2");
	}
	function decode_subj($search) {
		global $hr, $refhost;
		$search = ereg_replace("%25", "%", $search);
		$search = urldecode($search);
		# twice for Google Translate, Planet, Ask-redir
		if (eregi("(translate_|/translate\?)", $hr)) $search = trim(urldecode($search));
		if (eregi("(planet|wxs)", $refhost)) $search = trim(urldecode($search));
		if (strstr($hr, "/redir?")) $search = trim(urldecode($search));
		$search = ereg_replace(" +", " ", $search);
		$search = str_replace("Ã¸", "ø", $search);
		$search = str_replace("Ã¤", "ä", $search);
		$search = str_replace("Ã«", "ë", $search);
		$search = str_replace("Ã¯", "ï", $search);
		$search = str_replace("Ã¶", "ö", $search);
		$search = str_replace("Ã¼", "ü", $search);
		$search = str_replace("Ã ", "à", $search);
		$search = str_replace("Ã¨", "è", $search);
		$search = str_replace("Ã¬", "ì", $search);
		$search = str_replace("Ã²", "ò", $search);
		$search = str_replace("Ã¹", "ù", $search);
		$search = str_replace("Ã¡", "á", $search);
		$search = str_replace("Ã©", "é", $search);
		$search = str_replace("Ã­", "í", $search);
		$search = str_replace("Ã³", "ó", $search);
		$search = str_replace("Ãº", "ú", $search);
		$search = str_replace("Ã¥", "å", $search);
		$search = str_replace("Ã¦", "æ", $search);
		$search = str_replace("Ã†", "Æ", $search);
		$search = str_replace("Ã§", "ç", $search);
		$search = str_replace("Ã‡", "Ç", $search);
		$search = str_replace("Ã¢", "â", $search);
		$search = str_replace("%E2%80%98", "'", $search);
		$search = str_replace("%E2%82%AC", "€;", $search);
		$search = str_replace("â‚¬", "€", $search);
		return($search);
	}
	function html_subj($search) {
		$search = str_replace("%E2%82%AC", "&euro;", $search);
		$search = str_replace("â‚¬", "&euro;", $search);
		$search = str_replace("€", "&euro;", $search);
		$search = str_replace("ø", "&oslash;", $search);
		$search = str_replace("ä", "&auml;", $search);
		$search = str_replace("ë", "&euml;", $search);
		$search = str_replace("ï", "&iuml;", $search);
		$search = str_replace("ö", "&ouml;", $search);
		$search = str_replace("ü", "&uuml;", $search);
		$search = str_replace("à", "&agrave;", $search);
		$search = str_replace("è", "&egrave;", $search);
		$search = str_replace("ì", "&igrave;", $search);
		$search = str_replace("ò", "&ograve;", $search);
		$search = str_replace("ù", "&ugrave;", $search);
		$search = str_replace("á", "&aacute;", $search);
		$search = str_replace("é", "&eacute;", $search);
		$search = str_replace("í", "&iacute;", $search);
		$search = str_replace("ó", "&oacute;", $search);
		$search = str_replace("ú", "&uacute;", $search);
		$search = str_replace("å", "&aring;", $search);
		$search = str_replace("æ", "&aelig;", $search);
		$search = str_replace("Æ", "&Aelig;", $search);
		$search = str_replace("ç", "&ccedil;", $search);
		$search = str_replace("Ç", "&Ccedil;", $search);
		$search = str_replace("â", "&acirc;", $search);
		return($search);
	}
	$hr = str_replace("193.172.237.17", "www.vindex.nl", $hr);
	$hr = str_replace("62.250.9.19", "www.zoekhet.nl", $hr);
	$hr = ereg_replace("[?]http://", "", $hr);
	$hr = str_replace("http://", "", $hr);
	$hr = str_replace("highlight.pl?u=", "highlight.pl?u=http://", $hr);
	$hr = str_replace("out.php?site=", "out.php?site=http://", $hr);
	$hr = str_replace("browse_view.php?s=", "browse_view.php?s=http://", $hr);
	$hr = str_replace("imgrefurl=", "imgrefurl=http://", $hr);
	$hr = str_replace("target=", "target=http://", $hr);
	$hr = str_replace("http://http", "http", $hr);
	$hr = ereg_replace("[?]news", "news", $hr);
	if (stristr($hr, "news://")) {
	  $gs = substr($hr, strrpos($hr, "/")+1);
	  $gs = str_replace("%40", "@", $gs);
	  $hr = str_replace("news://", "", $hr);
	  $engine = "Usenet - ";
	  $refhost = substr($hr, 0, strpos($hr, "/"));
	  if (strstr($hr, "/")) $engine = "$engine"."$refhost ";
	  $search = "$gs";
	  $hr = "groups.google.com/groups?selm=$gs";
	} else {
	  $search    = $hr;
	  if (strstr($hr, ".")) {
	    if (strstr($hr, "/")) {
	      $refpos  = strpos($hr, "/");
	      $refhost = substr($hr, 0, $refpos);
	      $refpath = substr($hr, $refpos);
	    } else {
	      $refhost = $hr;
	      $refpath = "/";
	    }
	    $refhost = ereg_replace("62\.250\.20\.123", "www.vindex.nl", $refhost);
	    $refhost = ereg_replace("62\.250\.9\.98", "www.zoekhet.nl", $refhost);
	    $refhost = ereg_replace("64\.15\.129\.51", "www.mamma.com", $refhost);
	    $refhost = ereg_replace("203\.197\.64\.220", "www.indiatimes.com", $refhost);
	    $refhost = ereg_replace("213\.61\.4\.104", "colt-de", $refhost);
	    $refhost = ereg_replace("161\.58\.151\.191", "crawl-it-all", $refhost);
	    $refhost = ereg_replace("66\.150\.[0-3]{1}\.[0-9]{1,3}", "metacrawler.com", $refhost);
	    $refhost = ereg_replace("217\.160\.[0-9]{1,3}\.[0-9]{1,3}", "metacrawler.de", $refhost);
	    $refhost = ereg_replace("212\.40\.[0-9]{1,3}\.[0-9]{1,3}", "metacrawler.de", $refhost);
	    $refhost = ereg_replace("64\.4\.([0-9]{1}|[0-6]{1}[0-9]{1})\.", "hotmail", $refhost);
	    $refhost = ereg_replace("65\.54\.24[0-9]{1}\.[0-9]{1,3}", "hotmail", $refhost);
	    $refhost = ereg_replace("65\.54\.18[0-9]{1}\.[0-9]{1,3}", "hotmail", $refhost);
	    $refhost = ereg_replace("207\.68\.176.[0-9]{1,3}", "search.msn.com", $refhost);
	    $refhost = ereg_replace("207\.68\.[0-9]{1,3}\.[0-9]{1,3}", "hotmail", $refhost);
	    $refhost = ereg_replace("212\.227\.33\.241", "metaspinner.de", $refhost);
	    $refhost = ereg_replace("216\.182\.196\.154", "mamma.com", $refhost);
	    $refhost = ereg_replace("169\.207\.238\.189", "positiontech", $refhost);
	    $refhost = ereg_replace("66\.218\.[0-9]{1,3}\.[0-9]{1,3}", "yahoo", $refhost);
	    $refhost = ereg_replace("64\.58\.[0-9]{1,3}\.[0-9]{1,3}", "yahoo", $refhost);
	    $refhost = ereg_replace("64\.12\.[0-9]{1,3}\.[0-9]{1,3}", "netscape", $refhost);
	    $refhost = ereg_replace("64\.233\.[0-9]{1,3}\.[0-9]{1,3}", "google", $refhost);
	    $refhost = ereg_replace("66\.249\.[6-9][0-9]\.[0-9]{1,3}", "google", $refhost);
	    $refhost = ereg_replace("66\.102\.([0-9]|1[0-5])\.[0-9]{1,3}", "google", $refhost);
	    if (ereg("1stekeuze", $qs)) $refpath = str_replace("http://www.1stekeuze.nl/d/", "/d=", $qs);
	    $zoekmach1 = "(translate_|/translate\?|cgi\.monitor|/World/|google|216\.239|search\.nl|search\.com|msn|altavista|alta\-vista|lycos|hotbot|alltheweb|northernlight|ixquick|teoma|vinden\.nl|vindin\.nl|kvasir|webferret|netmenu|track\.nl|search4it|zoek\.zonnet|passagen|accessgenealogy|fireball|zoek\.nl|toile\.com|soeg\.sol|jubii|wwwgids|freelersearch|lapoo|profusion|metacrawler|nu\.nl|kunstkontakt|skynet|planet\.nl|wxs\.nl|zoekhet|abcsearch|kobala|dmoz|webinfosearch|dogpile|metaspider|overture|webcrawler|sympatico|nettavisen|wwwijzer|aolsearch|w\.aol\.|iol\.i|excite|oingo|bellsouth|mamma\.com|rediff|start4all|directhit|iwon|web\.de|netscape\.com|netscape\.de|askjeeves|ask\.co|aj\.com|virgilio|cometsystems|vivisimo|looksmart|euroseek|yahoo|attbi|att\.net|about\.com|earthlink|business\.com|surfwax|tiscali|arianna|profusion|intelliseek|infospace|metabot\.ru|bonzi|info400|search400|techtarget|huntbar|megaspider|metor\.|botbot|baidu|sohu|uol\.|searchhippo|alexa|netbul|new\.net|megaspider|clix\.pt|ahnenforschung|spriet|ez2www|megajames|freeserve|wisenut|nedgen|kazaa|infogrid|bbc|myway|redhat|buscador\.ya|search66|terra\.es|ieplugin|belgacom|sina\.com|bellsouth|goo\.ne\.jp|firehunt|seite\.com|megaweb|brisbane|findtarget|lizzy|indiatimes|metaseek|register\.com|1banana|colt|suchen|comcast|netster|curryguide|tjgo\.com|crawl-it-all|crawldad|brint\.com|searchalot|rogers\.com|ceoexpress|wp\.pl|startnow|ubbi|verizon|hotmail|vdab|experts-exchange|searchwho|cnn|i-une|metaspinner\.de|monstercrawler|home\.nl|allthesites|algebraic|turbo10|blueyonder|positiontech|ancestry|mybegin\.nl|searchy|hurra\.de|zoekinalles|search123|searchandclick|blueglobus|webwatch\.be|eniro\.se|searchscout|startium|\.info\.com|amazon|munky|ilectric|vvamsterdam|lop\.com|searchit|amsterdamonline|020online|anywho|holland\.info|zoeky|search2525|wanadoo\.nl|googlealert|ezanga|sbsonline|\.crawler|canoe\.com|searchscout|voila|tele2internet|3721\.com|metaeureka|yoursearchfinder|your\.com|gigablast|sirsearch|copernic|avantfind|gebeld|qsrch\.com|bestsearchonearth|upspiral|usseek|01net|1stekeuze|fullreviews|findallresults|redzip|need2find|reliableresults|\.sify\.|howstuffworks|seznam|oemji|chello\.nl|nigma\.ru|starware|bisnis\.nl)";
	    $zoekmach2 = "(q=|query=|search=)";
	    $zoekmach = "$zoekmach1|$zoekmach2";
	    if (strstr($refhost, "ilse") && !strstr($refhost, "spsearch")) {
	      if (strstr($refpath, "search_for=") || strstr($refpath, "search=")) {
		$ss = "search_for=";
		if (strstr($refhost, "ilsesearch")) $ss = "search=";
		$regs = explode ($ss, $refpath);
		$search = $regs[1];
		if ($regs[2]) $search = $regs[2];
		if (strstr($search, "%26")) {
		  $regs = explode ("%26", $search);
		  $search = $regs[0];
		}
		if (strstr($search, "&")) {
		  $regs = explode ("&", $search);
		  $search = $regs[0];
		}
		if (strstr($search, ";")) {
		  $regs = explode (";", $search);
		  $search = $regs[0];
		}
		$search = trim(urldecode($search));
		$engine = "Ilse - ";
	      }
	      if (!$skipold && strstr($refpath, "oldquery=") && !strstr($refpath, "oldquery=&")) {
		$regs = explode ("oldquery=", $refpath);
		$oldq = $regs[1];
		if (strstr($oldq, "&")) {
		  $regs = explode ("&", $oldq);
		  $oldq = $regs[0];
		}
		if (strstr($oldq, ";")) {
		  $regs = explode (";", $oldq);
		  $oldq = $regs[0];
		}
		if ($oldq != "" && $oldq != $search) $search = "$search / oldquery: ".trim(urldecode($oldq));
	      }
	    } else {
	      if (strstr($refhost, "spsearch") || strstr($refhost, "vindex")) {
		$zoek = 1;
		$regs = explode ("in=", $refpath);
		if ($regs[1] == "") $regs = explode ("search_for=", $refpath);
		if ($regs[1] == "") $regs = explode ("query=", $refpath);
		$search = $regs[1];
		$search = str_replace("&verfijn=", "", $search);
		$search = str_replace("&in_2=", "", $search);
		if (strstr($search, "&")) {
		  $regs = explode ("&", $search);
		  $search = $regs[0];
		}
		$search = decode_subj($search);
		$search = $search;
		$engine = "Vindex - ";
		if (strstr($refhost, "spsearch")) $engine = "Startpagina - ";
	      } else {
		$trans = (strstr($hr, "translate_") || (strstr($hr, "/translate?") && strstr($hr, "q%3D")));
		if ((!stristr($refhost, "cgi.monitor.nl") && (ereg($zoekmach1, $refhost) || ereg($zoekmach2, $refpath) || $trans)) || stristr($refpath, "atomz")) {
#		if (ereg($zoekmach1, $refhost) || ereg($zoekmach2, $refpath) || $trans) {
		  $zoek = 1;
		  if (strstr($refhost, "groups.google")) {
		    $ss = "q=";
		    if (strstr($refpath, $ss)) {
		      $regs = explode ($ss, $refpath);
		      $gs   = $regs[1];
		      if (strstr($gs, "&")) {
			$regs = explode ("&", $gs);
			$gs   = $regs[0];
		      }
		      $gs = trim(urldecode($gs));
		      $engine = "Google Groupsearch - ";
		    } else {
		      $ss = "selm=";
		      $refpath = str_replace("seekm", "selm", $refpath);
		      if (strstr($refpath, $ss)) {
			$regs = explode ($ss, $refpath);
			$gs   = $regs[1];
			if (strstr($gs, "&")) {
			  $regs = explode ("&", $gs);
			  $gs   = $regs[0];
			}
		      }
		      $engine = "Google Groups - ";
		    }
		    $search = "$gs";
		  } else {
		    $ss = "q=";
		    if (strstr($refpath, "atomz")) $ss = "sp-q=";
		    if (strstr($refhost, "msn")) $refpath = ereg_replace("origq=", "orig=", $refpath);
		    if (strstr($refhost, "yahoo")) $ss = "p=";
		    if (strstr($refhost, "northernlight")) $ss = "qr=";
		    if (strstr($refhost, "about.com")) $ss = "terms=";
		    if (strstr($refhost, "images.google")) $ss = "q%3D";
		    if (strstr($refhost, "directory.google")) $ss = "Top";
		    if (strstr($refhost, "webferret")) $ss = "wf,";
		    if (strstr($refhost, ".search.com")) $ss = "wf,";
		    if (strstr($refhost, "sirsearch")) $ss = "keywords=";
		    if (strstr($refhost, "nu.nl")) $ss = "QUERY=";
		    if (strstr($refhost, "netmenu")) $ss = "qry=";
		    if (strstr($refhost, "track.nl")) $ss = "qr=";
		    if (strstr($refpath, "/Raven")) $ss = "qr=";
		    if (strstr($refhost, "search4it")) $ss = "rdq_";
		    if (strstr($refhost, "accessgenealogy")) $ss = "Criteria=";
		    if (strstr($refhost, "jubii")) $ss = "soegeord=";
		    if (strstr($refhost, "wwwgids")) $ss = "zoekwoord=";
		    if (strstr($refhost, "freelersearch")) $ss = "qr=";
		    if (strstr($refhost, "profusion")) $ss = "queryterm=";
		    if (strstr($refhost, "kunstkontakt")) $ss = "naam=";
		    if (strstr($refhost, "zoekhet")) $ss = "qry=";
		    if (strstr($refhost, "abcsearch")) $ss = "Terms=";
		    if (strstr($refhost, "kobala")) $ss = "qr=";
		    if (strstr($refhost, "dmoz")) $ss = "search=";
		    if (strstr($refhost, "zoeky")) $ss = "search=";
		    if (strstr($refhost, "webinfosearch")) $ss = "searchterm=";
		    if (strstr($hr, "directhit")) $ss = "qry=";
		    if (strstr($refhost, "askjeeves")) $ss = "ask=";
		    if (strstr($refhost, "ask.co")) $ss = "ask=";
		    if (strstr($refhost, "aj.com")) $ss = "ask=";
		    if (eregi("(translate_|/translate\?)", $refpath)) $ss = "q%3D";
		    if (strstr($refhost, "metaplus")) $ss = "g=";
		    if (strstr($refhost, "overture")) $ss = "Keywords=";
		    if (strstr($refhost, "webcrawler")) $ss = "Keywords=";
		    if (strstr($refhost, "oingo")) $ss = "Keywords=";
		    if (strstr($refhost, "avantfind")) $ss = "Keywords=";
		    if (strstr($refhost, "bonzi")) $ss = "keywords=";
		    if (strstr($refhost, "searchwho")) $ss = "keywords=";
		    if (strstr($refhost, "i-une")) $ss = "keywords=";
		    if (strstr($refhost, "blueglobus")) $ss = "keywords=";
		    if (strstr($refhost, "startium")) $ss = "keywords=";
		    if (strstr($refhost, "searchit")) $ss = "keywords=";
		    if (strstr($refhost, "search2525")) $ss = "keywords=";
		    if (strstr($refpath, "/World/")) $ss = "/World/";
		    if (strstr($refhost, "start4all")) $ss = "subject=";
		    if (strstr($refhost, "web.de")) $ss = "su=";
		    if (strstr($refhost, "iwon")) $ss = "searchfor=";
		    if (strstr($refhost, "iwon.ask")) $ss = "q=";
		    if (strstr($refhost, "ixquick") && !strstr($refpath, "highlight")) $ss = "query=";
		    if (strstr($refhost, "virgilio")) $ss = "qs=";
		    if (strstr($refhost, "cometsystems")) $ss = "qry=";
		    if (strstr($refhost, "attbi")) $ss = "qry=";
		    if (strstr($refhost, "att.net")) $ss = "qry=";
		    if (strstr($refhost, "metabot.ru")) $ss = "st=";
		    if (strstr($refhost, "info400")) $ss = "rubriek=";
		    if (strstr($refhost, "metor.")) $ss = "k=";
		    if (strstr($refhost, "botbot")) $ss = "?";
		    if (strstr($refhost, "baidu")) $ss = "word=";
		    if (strstr($refhost, "sohu")) $ss = "Word=";
		    if (strstr($refhost, "netbul")) $ss = "keyword=";
		    if (strstr($refhost, "new.net")) $ss = "s=";
		    if (strstr($refhost, "clix.pt")) $ss = "question=";
		    if (strstr($refhost, "ez2www")) $ss = "qry_str=";
		    if (strstr($refhost, "redhat")) $ss = "query_cb=";
		    if (strstr($refhost, "buscador.ya")) $ss = "item=";
		    if (strstr($refhost, "myway")) $ss = "searchfor=";
		    if (strstr($refhost, "belgacom")) $ss = "keywords=";
		    if (strstr($refhost, "sina.com")) $ss = "word=";
		    if (strstr($refhost, "sina.com")) $ss = "Keywords=";
		    if (strstr($refhost, "goo.ne.jp")) $ss = "MT=";
		    if (strstr($refhost, "firehunt")) $ss = "Keywords=";
		    if (strstr($refhost, "seite.com")) $ss = "s=";
		    if (strstr($refhost, "megaweb")) $ss = "?";
		    if (strstr($refhost, "lizzy")) $ss = "qr=";
		    if (strstr($refhost, "metaseek")) $ss = "qry=";
		    if (strstr($refhost, "register.com")) $ss = "Keywords=";
		    if (strstr($refhost, "1banana")) $ss = "s=";
		    if (strstr($refhost, "bellsouth")) $ss = "string=";
		    if (strstr($refhost, "netster")) $ss = "Keywords=";
		    if (strstr($refhost, "ceoexpress")) $ss = "DTqb1=";
		    if (strstr($refhost, "wp.pl")) $ss = "szukaj=";
		    if (strstr($refhost, "hotmail")) $ss = "action=";
		    if (strstr($refhost, "metaspider.com")) $ss = "Spider?";
		    if (strstr($refhost, "metaspinner.de")) $ss = "qry=";
		    if (strstr($refhost, "monstercrawler")) $ss = "qry=";
		    if (strstr($refhost, "turbo10")) $ss = "s=";
		    if (strstr($refhost, "ancestry")) $ss = "surnames.";
		    if (strstr($refhost, "searchy")) $ss = "search_term=";
		    if (strstr($refhost, "searchandclick")) $ss = "keywords=";
		    if (strstr($refhost, "webwatch.be")) $ss = "findindb=";
		    if (strstr($refhost, "searchscout")) $ss = "keyword=";
		    if (strstr($refhost, "ilectric")) $ss = "searchwords=";
		    if (strstr($refhost, "vvamsterdam")) $ss = "url.cgi/";
		    if (strstr($refhost, "lop.com")) $ss = "s=";
		    if (strstr($refhost, "amsterdamonline")) $ss = "ContentSubRubr=";
		    if (strstr($refhost, "020online")) $ss = "ContentSubRubr=";
		    if (strstr($refhost, "tjgo.com")) $ss = "s=";
		    if (strstr($refhost, "anywho")) $ss = "qry=";
		    if (strstr($refhost, "holland.info")) $ss = "qnl=";
		    if (strstr($refhost, "wanadoo.nl")) $ss = "Keywords=";
		    if (strstr($refhost, "googlealert")) $ss = "s=";
		    if (strstr($refhost, "searchscout")) $ss = "k=";
		    if (strstr($refhost, "voila")) $ss = "rdata=";
		    if (strstr($refhost, "3721.com")) $ss = "name=";
		    if (strstr($refhost, "metaeureka")) $ss = "terms=";
		    if (strstr($refhost, "yoursearchfinder")) $ss = "Keywords=";
		    if (strstr($refhost, "your.com")) $ss = "Keywords=";
		    if (strstr($refhost, "gigablast")) $ss = "&q=";
		    if (strstr($refhost, "gebeld")) $ss = "sbURL=";
		    if (strstr($refhost, "upspiral")) $ss = "st=";
		    if (strstr($refhost, "usseek")) $ss = "string=";
		    if (strstr($refhost, "01net")) $ss = "fullText=";
		    if (strstr($refhost, "1stekeuze")) $ss = "d=";
		    if (strstr($refhost, "fullreviews")) $ss = "keywords=";
		    if (strstr($refhost, "findallresults")) $ss = "s=";
		    if (strstr($refhost, "redzip")) $ss = "st=";
		    if (strstr($refhost, "need2find")) $ss = "searchfor=";
		    if (strstr($refhost, "reliableresults")) $ss = "s=";
		    if (strstr($refhost, ".sify.")) $ss = "keyword=";
		    if (strstr($refhost, "howstuffworks")) $ss = "terms=";
		    if (strstr($refhost, "seznam")) $ss = "w=";
		    if (strstr($refhost, "nigma.ru")) $ss = "request_str=";
		    if (strstr($refhost, "starware")) $ss = "qry=";
		    if (strstr($refhost, "mywebsearch")) $ss = "searchFor=";
		    if (strstr($refhost, "bisnis.nl")) $ss = "s=";
		    # zoekmach q=
		    $refpath = str_replace("googleq=q%3D", "q=", $refpath);
		    if (strstr($refhost, "crawldad")) {
		      $ss = "keywords=";
		      if (!ereg("$q=", $refpath)) {
			$refpath = "\?".$ss.$refpath;
			$refpath = eregi_replace("/", "", $refpath);
			$refpath = eregi_replace("\.html", "", $refpath);
			$refpath = eregi_replace("(_|-)", "+", $refpath);
		      }
		    }
		    if (strstr($refhost, "alltheweb")) {
		      if (ereg("&wf", $refpath)) {
			$refpath = trim(urldecode($refpath));
			$refpath = eregi_replace("(&wf\[[0-9]\]\[[a-z]\]=)*&", "&", $refpath);
			$refpath = ereg_replace("&wf\[([0-9])\]\[q\]=", "&q\\1=", $refpath);
	 		$refpath = ereg_replace("(&wf\[[0-9]\]\[[a-z]\]=\+&q([0-9])=)(([[:alnum:]]|/|\+| )+)(&)", "&q\\2=%2B\\3&", $refpath);
	 		$refpath = ereg_replace("(&wf\[[0-9]\]\[[a-z]\]=\+&q([0-9])=)(([[:alnum:]]|/|\+| )+)(&)", "&q\\2=%2B\\3&", $refpath);
	 		$refpath = ereg_replace("(&wf\[[0-9]\]\[[a-z]\]=\+&q([0-9])=)(([[:alnum:]]|/|\+| )+)(&)", "&q\\2=%2B\\3&", $refpath);
	 		$refpath = ereg_replace("(&wf\[[0-9]\]\[[a-z]\]=\-&q([0-9])=)(([[:alnum:]]|%2B|%22|\+| )+)(&)", "&q\\2=-%22\\3%22&", $refpath);
	 		$refpath = ereg_replace("(&wf\[[0-9]\]\[[a-z]\]=\-&q([0-9])=)(([[:alnum:]]|%2B|%22|\+| )+)(&)", "&q\\2=-%22\\3%22&", $refpath);
			if (!ereg("&q=", $refpath)) $refpath = "&q=&".$refpath;
	 		$refpath = ereg_replace("&q=(([[:alnum:]]|%2B|%22|\+| )*)(&(.*))*&q0=", "&q=\\1+", $refpath);
	 		$refpath = ereg_replace("&q=(([[:alnum:]]|%2B|%22|\+| )+)(&(.*))*&q1=", "&q=\\1+", $refpath);
	 		$refpath = ereg_replace("&q=(([[:alnum:]]|%2B|%22|\+| )+)(&(.*))*&q2=", "&q=\\1+", $refpath);
	 		$refpath = ereg_replace("&q([1-9])=", "+", $refpath);
		      }
		    }
		    if (strstr($refhost, "altavista") || strstr($refhost, "alta-vista")) {
		      if (ereg("&aq", $refpath)) {
			if (ereg("&aqp=", $refpath) && !ereg("&aqp=&", $refpath))
	 		  $refpath = ereg_replace("(&aqp=)(([[:alnum:]]|\+|%22)+)(&)", "+%22\\2%22&", $refpath);
			if (ereg("&aqn=", $refpath) && !ereg("&aqn=&", $refpath))
	 		  $refpath = ereg_replace("(&aqn=)(([[:alnum:]]|\+|%22)+)(&)", "+%2D%22\\2%22&", $refpath);
			if (ereg("&aqa=", $refpath) && !ereg("aqa=&", $refpath)) $ss = "aqa=";
			if (ereg("&aqp=", $refpath) && !ereg("aqp=&", $refpath)) $ss = "aqp=";
			if (ereg("&aqs=", $refpath) && !ereg("aqs=&", $refpath)) $ss = "aqs=";
			if (ereg("&aqb=", $refpath) && !ereg("aqb=&", $refpath)) $ss = "aqb=";
		      }
		      if (ereg("pg=dir", $refpath)) $ss = "tp=";
		    } # altavista & eniro.se:
		    $refpath = ereg_replace("&stq=0", "", $refpath);
		    $refpath = ereg_replace("stq=0&", "", $refpath);
		    if (strstr($refhost, "lycos")) {
		      $refpath = ereg_replace("&SWR=", "+", $refpath);
		      $refpath = ereg_replace("&cat=([A-Za-z0-9]*)&", "&", $refpath);
		      $refpath = ereg_replace("&pt1=([A-Za-z0-9])&", "&", $refpath);
		      $refpath = ereg_replace("&pt2=([A-Za-z0-9])&", "&", $refpath);
		      $refpath = ereg_replace("&ps1=", "+", $refpath);
		      $refpath = ereg_replace("&ps2=", "+", $refpath);
		      $refpath = ereg_replace("&pt1=([A-Za-z0-9])&", "&", $refpath);
		      $refpath = ereg_replace("&pt2=([A-Za-z0-9])&", "&", $refpath);
		      $refpath = ereg_replace("&ps1=&", "&", $refpath);
		      $refpath = ereg_replace("&ps2=&", "&", $refpath);
		      $refpath = ereg_replace("&ps1=", "+%2D", $refpath);
		      $refpath = ereg_replace("&ps2=", "+%2D", $refpath);
		    }
		    if (strstr($refhost, "vinden.nl")) {
		      if (!ereg("&q=", $refpath)) {
			if (ereg("&q_phr=", $refpath) && !ereg("&q_phr=&", $refpath))
	 		  $refpath = ereg_replace("(&q_phr=)(([[:alnum:]]|\+|%22)+)(&)", "+%22\\2%22&", $refpath);
			if (ereg("&q_not", $refpath) && !ereg("&q_not&", $refpath))
	 		  $refpath = ereg_replace("(&q_not)(([[:alnum:]]|\+|%22)+)(&)", "+%2D%22\\2%22&", $refpath);
			if (ereg("&q_and=", $refpath) && !ereg("q_and=&", $refpath)) $ss = "q_and=";
			if (ereg("&q_or=", $refpath) && !ereg("q_or=&", $refpath)) $ss = "q_or=";
			if (ereg("&q_phr=", $refpath) && !ereg("q_phr=&", $refpath)) $ss = "q_phr=";
			if (ereg("&q_not=", $refpath) && !ereg("q_not=&", $refpath)) $ss = "q_not=";
		      }
		      if (!ereg("q=", $refpath) && eregi("cat=[/a-z]", $refpath)) $ss = "cat=";
		    }
		    if (strstr($refhost, "lapoo")) {
			$refpath = ereg_replace("search=web&", "", $refpath);
			$refpath = ereg_replace("&search=web", "", $refpath);
		    }
		    if (eregi("(google|yahoo)", $refhost)) {
		      if (strstr($refhost, "yahoo")) {
			$refpath = str_replace("va=", "as_q=", $refpath);
			$refpath = str_replace("vp=", "as_epq=", $refpath);
			$refpath = str_replace("vo=", "as_oq=", $refpath);
			$refpath = str_replace("ve=", "as_eq", $refpath);
		      }
		      if (!eregi("\?as_q=", $refpath)) {
			$refpath = str_replace("as_epq=", "as_q=", $refpath);
		      }
		      if (eregi("\?as_q=", $refpath)) {
	 		$refpath = ereg_replace("(.*[?])(as_q=)(.*)(&num=|&hl=)(.*)(&as_epq)(.*)", "\\1\\2\\3\\6\\7\\4\\5", $refpath);
	 		$refpath = ereg_replace("(.*[?])(as_q=)(.*)(&num=|&hl=)(.*)(&as_epq)(.*)", "\\1\\2\\3\\6\\7\\4\\5", $refpath);
		      }
	 	      $refpath = ereg_replace("&(as_epq=|as_oq=|as_eq=)+&", "&", $refpath);
	 	      $refpath = ereg_replace("&num=([0-9]+)", "", $refpath);
	 	      $refpath = eregi_replace("&hl=[a-z|-]+", "", $refpath);
		      if (eregi("&as_epq=[A-Za-z0-9|\+|%22]", $refpath)) {
	 		$refpath = eregi_replace("(.*)(&as_epq=)(([A-Za-z0-9]|%|\+|-)+)(&)(.*)", "\\1\\2%22\\3%22\\5\\6", $refpath);
	 		$refpath = ereg_replace("&as_epq=", "+", $refpath);
		      }
		      if (eregi("&as_oq=[A-Za-z0-9|\+|%22]", $refpath)) {
	 		$as_oq = eregi_replace(".*as_oq=(.*)", "\\1", $refpath);
	 		$as_oq = eregi_replace("(&(.*))+", "", $as_oq);
	 		$as_nq = eregi_replace("(^\+|\+$)+", "", $as_oq);
	 		$as_nq = eregi_replace("\+", "+OR+", $as_nq);
	 		$refpath = str_replace("&as_oq=$as_oq", "+$as_nq", $refpath);
		      }
		      if (strstr($refhost, "google") && eregi("&as_q=[a-z]", $refpath)) {
	 		$refpath = ereg_replace("&as_q=", "+", $refpath);
		      }
		      if (strstr($refhost, "yahoo")) {
			$refpath = str_replace("as_q=", "va=", $refpath);
			$refpath = str_replace("as_epq=", "vp=", $refpath);
			$refpath = str_replace("as_oq=", "vo=", $refpath);
			$refpath = str_replace("as_eq", "ve=", $refpath);
			$refpath = ereg_replace("fr=op&va=", "p=", $refpath);
			$refpath = ereg_replace("va=", "p=", $refpath);
		      }
		      if (eregi("query=", $refpath)) {
			$ss = "query=";
		      }
		    }
		    if ($ss == "ask=" && !stristr($refpath, "ask=")) {
			if (strstr($refpath, "q=")) $ss = "q=";
			if (strstr($refpath, "q%3d")) $ss = "q%3d";
			if (strstr($refpath, "q%3D")) $ss = "q%3D";
		    }
		    $refpath = str_replace("metasearch=yes", "", $refpath);
		    $qt = $ss."&";
		    while (strstr($refpath, $qt)) {
			$refpath = str_replace($qt, "&", $refpath);
		    }
		    while (strstr($refpath, "+&")) {
			$refpath = str_replace("+&", "&", $refpath);
		    }
		    while (strstr($refpath, "+%22&")) {
			$refpath = str_replace("+%22&", "%22&", $refpath);
		    }
		    while (strstr($refpath, "%2B&")) {
			$refpath = str_replace("%2B&", "&", $refpath);
		    }
		    if (strstr($refpath, $ss)) {
		      $regs = explode ($ss, $refpath);
		      $search1 = $regs[1];
		      if (strstr($search1, "%26")) {
			$search1 = str_replace("+%26+", "+^+", $search1);
			$regs = explode ("%26", $search1);
			if (strlen($regs[0])>1) { $search = $regs[0]; $search1 = $regs[0]; }
		      }
		      if (strstr($search1, "&")) {
			$regs = explode ("&", $search1);
			if (strlen($regs[0])>1) $search = $regs[0];
		      } else {
			if (strstr($search1, ",,")) {
			  $regs = explode (",,", $search1);
			  if (strlen($regs[0])>1) $search = $regs[0];
			} else {
			  if (strstr($search1, "/") && strstr($refhost, "search4it")) {
			    $regs = explode ("/", $search1);
			    if (strlen($regs[0])>1) $search = $regs[0];
			    $search = str_replace("_", " ", $search);
			  } else {
			    if (strlen($search1)>1) $search = $search1;
			  }
			}
		      }
		    }
		    $ss = "query=";
		    if (strstr($refpath, "atomz")) $ss = "split=";
		    if (strstr($refhost, "msn")) $ss = "MT=";
		    if (strstr($refhost, "rediff")) $ss = "MT=";
		    if (strstr($refhost, "northernlight")) $ss = "q%3D";
		    if (strstr($refhost, "vindin.nl")) $ss = "QUERY=";
		    if (strstr($refhost, "google")) $ss = "pq=";
		    if (strstr($refhost, "images.google")) $ss = "q=";
		    if (strstr($refhost, "webferret")) $ss = "q=";
		    if (strstr($refhost, "skynet")) $ss = "keywords=";
		    if (strstr($refhost, "webcrawler")) $ss = "qkw=";
		    if (strstr($refhost, "copernic")) $ss = "qkw=";
		    if (strstr($refhost, "verizon")) $ss = "qkw=";
		    if (strstr($refhost, "infospace")) $ss = "qkw=";
		    if (strstr($refhost, "excite")) $ss = "qkw=";
		    if (strstr($refhost, "metacrawler")) $ss = "qkw=";
		    if (strstr($refhost, "teoma")) $ss = "t=";
		    if (strstr($refhost, "ixquick")) $ss = "query=";
		    if (strstr($refhost, "abcsearch")) $ss = "terms=";
		    if (strstr($refhost, "bonzi")) $ss = "Keywords=";
		    if (strstr($refhost, "kazaa")) $ss = "keywords=";
		    if (strstr($refhost, "zoek.nl") && strstr($refpath, "Terms=")) $ss = "Terms=";
		    if (strstr($refhost, "megaspider")) $ss = "html?";
		    if (strstr($refhost, "netster")) $ss = "KeyWords=";
		    if (strstr($refhost, "vvamsterdam")) $ss = "selection=";
		    if (strstr($refhost, "mybegin.nl")) $ss = "s=";
		    if (strstr($refhost, "qsrch.com")) $ss = "s=";
		    if (strstr($refhost, "bestsearchonearth")) $ss = "s=";
		    if (strstr($refhost, "sbsonline")) $ss = "query_string=";
		    if (strstr($refhost, "canoe")) $ss = "q=";
		    if (strstr($refhost, "voila")) $ss = "kw=";
		    if (strstr($refhost, "planet.nl")) $ss = "googleq=q=";
		    if (strstr($refhost, "wxs.nl")) $ss = "googleq=q=";
		    if (strstr($refhost, "avantfind")) $ss = "keywords=";
		    if (strstr($refhost, "chello.nl")) $ss = "q1=";
		    # zoekmach query=
		    if (strstr($refhost, "lycos")) {
		      $refpath = ereg_replace("&SWR=", "+", $refpath);
		      if (strstr($refpath, "query=&")) $ss="wfq%3D";
		    }
		    $qt = $ss."&";
		    while (strstr($refpath, $qt)) {
			$refpath = str_replace($qt, "", $refpath);
		    }
		    if (strstr($refpath, $ss)) {
		      $regs = explode ($ss, $refpath);
		      $search1 = $regs[1];
		      if (strstr($search1, "%26")) {
			$search1 = str_replace("+%26+", "+^+", $search1);
			$regs = explode ("%26", $search1);
			if (strlen($regs[0])>1) { $search = $regs[0]; $search1 = $regs[0]; }
		      }
		      if (strstr($search1, "&")) {
			$regs = explode ("&", $search1);
			if (strlen($regs[0])>1) $search = $regs[0];
		      } else {
			if (strstr($search1, ";")) {
			  $regs = explode (";", $search1);
			  if (strlen($regs[0])>1) $search = $regs[0];
			} else {
			  if (strlen($search1)>1) $search = $search1;
			}
		      }
		    }
		    $ss = "search=";
		    if (strstr($refpath, "atomz")) $ss = "Split=";
		    if (strstr($refhost, "altavista")) $ss = "aqp=";
		    if (strstr($refhost, "zoek.nl")) $ss = "Category=";
		    if (strstr($refhost, "zoek.zonnet")) $ss = "Category=";
		    if (strstr($refhost, "google")) $ss = "oq=";
		    if (strstr($refhost, "ixquick")) $ss = "query=";
		    if (strstr($refhost, "askjeeves") && $search == $hr) $ss = "pt=";
		    if (strstr($refhost, "ask.co") && $search == $hr) $ss = "pt=";
		    if (strstr($refhost, "aj.com") && $search == $hr) $ss = "pt=";
		    if (strstr($refhost, "hotbot")) $ss = "MT=";
		    if (strstr($refhost, "looksmart")) $ss = "key=";
		    if (strstr($refhost, "looksmart") && !strstr($refpath, $ss)) $ss = "QueryString=";
		    if (strstr($refhost, "euroseek")) $ss = "string=";
		    if (strstr($refhost, "webcrawler")) $ss = "searchText=";
		    if (strstr($refhost, ".search.com")) $ss = "qt=";
		    if (strstr($refhost, "7search.com")) $ss = "qu=";
		    if (strstr($refhost, "allcybersearch")) $ss = "term=";
		    if (strstr($refhost, "quickbrowsersearch")) $ss = "s=";
		    if (strstr($refhost, "mysearch")) $ss = "searchfor=";
		    if (strstr($refhost, "websearch")) $ss = "qkw=";
		    if (strstr($refhost, "easywebsearch.nl")) $ss = "Keywords=";
		    if (strstr($refhost, "mywebsearch")) $ss = "searchfor=";
		    if (strstr($refhost, "2020search")) $ss = "Keywords=";
		    if (strstr($refhost, "steadysearch")) $ss = "w=";
		    if (strstr($refhost, "\.isearch")) $ss = "Terms=";
		    if (strstr($refhost, "huntbar")) $ss = "Q=";
		    if (strstr($refhost, "metacrawler")) $ss = "general=";
		    if (strstr($refhost, "metacrawler.de")) $ss = "qry=";
		    if (strstr($refhost, "teoma")) $ss = "terms=";
		    if (strstr($refhost, "tiscali")) $ss = "key=";
		    if (strstr($refhost, "sohu")) $ss = "Tl=";
		    if (strstr($refhost, "arianna")) $ss = "B1=";
		    if (strstr($refhost, "netster")) $ss = "keywords=";
		    if (strstr($refhost, "zoekinalles")) $ss = "keywords=";
		    if (strstr($refhost, ".search.com")) $ss = "q=";
		    if (strstr($refhost, "search123")) $ss = "QUERY=";
		    if (strstr($refhost, "dogpile")) $ss = "qkw=";
		    if (strstr($refhost, ".info.com")) $ss = "qkw=";
		    if (strstr($refhost, ".crawler.com")) $ss = "qkw=";
		    if (strstr($refhost, "ezanga.com")) $ss = "qkw=";
		    if (strstr($refhost, "amazon")) $ss = "keywords=";
		    if (strstr($refhost, "munky")) $ss = "term=";
		    if (strstr($refhost, "nedgen")) $ss = "string=";
		    if (strstr($refhost, "excite")) $ss = "key=";
		    if (strstr($refhost, "netscape")) $ss = "userQuery=";
		    if (strstr($refhost, "tele2internet")) $ss = "query=";
		    if (strstr($refhost, "home.nl")) $ss = "s=";
		    if (strstr($refhost, "planet.nl")) $ss = "googleq=q%3D";
		    if (strstr($refhost, "wxs.nl")) $ss = "googleq=q%3D";
		    if (strstr($refhost, "oemji")) $ss = "Keywords=";
		    # zoekmach search=
		    $qt = $ss."&";
		    while (strstr($refpath, $qt)) {
			$refpath = str_replace($qt, "", $refpath);
		    }
		    if (strstr($refpath, $ss)) {
		      $regs = explode ($ss, $refpath);
		      $search1 = $regs[1];
		      if (strstr($search1, "&")) {
			$regs = explode ("&", $search1);
			if (strlen($regs[0])>1) $search = $regs[0];
		      } else {
			if (strlen($search1)>1) $search = $search1;
		      }
		    }
		    if (strstr($refhost, "webferret") && $search == $hr) {
		      $search = ereg_replace(".*frame\.[0-9]+\.(.*)\.[0-9]+,http.*", "\\1", $hr);
		    }
		    $search = str_replace("+^+", "+%26+", $search);
		    $search = decode_subj($search);

		    if (strstr($refhost, "zoekhet"))			$engine = "Zoekhet - ";
		    else {
		      if (strstr($refhost, "yahoo") && !strstr($refhost, "ixquick")) {$engine = "Yahoo - "; if(strstr($refhost,"mail.")) {$engine = "YahooMail - ";$search="Search";}}
		      else {
			if (strstr($refhost, "ixquick"))		$engine = "Ixquick - ";
			else {
			  if (strstr($refhost, "images.google"))	$engine = "Google Images - ";
			  else {
			    if (strstr($refhost, "directory.google") || (strstr($refhost, "google") && eregi("cat=[/a-z]", $refpath))) $engine = "Google Directory - ";
			    else {
			      if (strstr($refhost, "www.google") && !strstr($hr, "google.com/")) $engine = str_replace("www.google", "Google", $refhost)." - ";
			      else {
				if (strstr($refhost, "google"))		$engine = "Google - ";
			      }
			    }
			  }
			  if (strstr($refhost, "looksmart"))		$engine = "Looksmart - ";
			  if (strstr($refhost, "search.nl")) 		$engine = "SearchNL - ";
			  if (strstr($refhost, "search.com"))		$engine = "SearchCOM - ";
			  if (strstr($refhost, "abcsearch"))		$engine = "ABCsearch - ";
			  if (strstr($refhost, "7search"))		$engine = "7Search - ";
			  if (strstr($refhost, "allcybersearch"))	$engine = "Allcybersearch - ";
			  if (strstr($refhost, "mysearch"))		$engine = "MySearch - ";
			  if (strstr($refhost, "websearch"))		$engine = "WebSearch - ";
			  if (strstr($refhost, "easywebsearch.nl"))	$engine = "EasyWebSearchNL - ";
			  if (strstr($refhost, "mywebsearch"))		$engine = "MyWay - ";
			  if (strstr($refhost, "2020search"))		$engine = "2020Search - ";
			  if (strstr($refhost, "sirsearch"))		$engine = "SirSearch - ";
			  if (strstr($refhost, "isearch"))		$engine = "ISearch - ";
			  if (strstr($refhost, "steadysearch"))		$engine = "Steadysearch - ";
			  if (strstr($refhost, "quickbrowsersearch"))	$engine = "Quick - ";
			  if (strstr($refhost, "webferret"))		$engine = "Webferret - ";
			  if (strstr($refhost, "altavista"))	 	$engine = "Altavista - ";
			  if (strstr($refhost, "alta-vista"))		$engine = "Altavista - ";
			  if (strstr($refhost, "lycos"))		$engine = "Lycos - ";
			  if (strstr($refhost, "hotbot"))		$engine = "Hotbot - ";
			  if (strstr($refhost, "alltheweb"))		$engine = "AllTheWeb - ";
			  if (strstr($refhost, "northernlight"))	$engine = "NorthernLight - ";
			  if (strstr($refhost, "teoma"))		$engine = "Teoma - ";
			  if (strstr($refhost, "vinden.nl"))		$engine = "Vinden - ";
			  if (strstr($refhost, "vindin.nl"))		$engine = "VindIn - ";
			  if (strstr($refhost, "kvasir"))		$engine = "KvasirNO - ";
			  if (strstr($refhost, "netmenu"))		$engine = "Netmenu - ";
			  if (strstr($refhost, "track.nl"))		$engine = "Track - ";
			  if (strstr($refhost, "search4it"))		$engine = "Search4it - ";
			  if (strstr($refhost, "zoek.zonnet"))		$engine = "Zonzoeken - ";
			  if (strstr($refhost, "passagen"))		$engine = "PassagenSE - ";
			  if (strstr($refhost, "accessgenealogy"))	$engine = "Accessgenealogy - ";
			  if (strstr($refhost, "fireball"))		$engine = "FireballDE - ";
			  if (strstr($refpath, "atomz"))		$engine = "Atomz - ";
			  if (strstr($refhost, "zoek.nl"))		$engine = "ZoekNL - ";
			  if (strstr($refhost, "toile.com"))		$engine = "ToileCA - ";
			  if (strstr($refhost, "soeg.sol"))		$engine = "SOLs&oslash;g - ";
			  if (strstr($refhost, "jubii"))		$engine = "JubiiDK - ";
			  if (strstr($refhost, "wwwgids"))		$engine = "WWW gids - ";
			  if (strstr($refhost, "freelersearch"))	$engine = "Freeler - ";
			  if (strstr($refhost, "lapoo"))		$engine = "Lapoo - ";
			  if (strstr($refhost, "metacrawler"))		$engine = "MetaCrawler - ";
			  if (strstr($refhost, "metacrawler.de"))	$engine = "MetacrawlerDE - ";
			  if (strstr($refhost, "nu.nl") && !strstr($refhost, "netmenu") && !strstr($refhost, "nlmenu")) $engine = "NuNL - ";
			  if (strstr($refhost, "kunstkontakt"))		$engine = "KunstKontakt - ";
			  if (strstr($refhost, "skynet"))		$engine = "SkynetBE - ";
			  if (strstr($refhost, "planet"))		$engine = "Planet - ";
			  if (strstr($refhost, "wxs.nl"))		$engine = "Planet - ";
			  if (strstr($refhost, "planetinternet.be"))	$engine = "PlanetBE - ";
			  if (strstr($refhost, "kobala"))		$engine = "Kobala - ";
			  if (strstr($refhost, "dmoz"))			$engine = "DMoz - ";
			  if (strstr($refhost, "webinfosearch"))	$engine = "Webinfosearch - ";
			  if (strstr($refhost, "directhit"))		$engine = "Directhit - ";
			  if (strstr($refhost, "askjeeves"))		$engine = "AskJeeves - ";
			  if (strstr($refhost, "ask.co.uk"))		$engine = "AskJeevesUK - ";
			  if (strstr($refhost, "ask.com"))		$engine = "AskJeeves - ";
			  if (strstr($refhost, "aj.com"))		$engine = "AskJeeves - ";
			  if (strstr($refhost, "dogpile"))		$engine = "Dogpile - ";
			  if (strstr($refhost, "metaspider.com"))	$engine = "MetaSpiderCOM - ";
			  if (strstr($refhost, "metaspider.nl"))	$engine = "MetaSpiderNL - ";
			  if (strstr($refhost, "overture"))		$engine = "Overture - ";
			  if (strstr($refhost, "webcrawler"))		$engine = "WebCrawler - ";
			  if (strstr($refhost, "sympatico"))		$engine = "SympaticoLycos - ";
			  if (strstr($refhost, "nettavisen"))		$engine = "NettguideNO - ";
			  if (strstr($refpath, "translate_"))		$engine = "Google Translate - ";
			  if (strstr($refpath, "/translate?"))		$engine = "Google Translate - ";
			  if (strstr($refhost, "wwwijzer"))		$engine = "WWWijzer - ";
			  if (strstr($refhost, "aolsearch"))		$engine = "AOL - ";
			  if (strstr($refhost, "aol."))			$engine = "AOL - ";
			  if (strstr($refhost, "iol.ie"))		$engine = "IolIE - ";
			  if (strstr($refhost, "iol.it"))		$engine = "IolIT - ";
			  if (strstr($refhost, "excite"))		$engine = "Excite - ";
			  if (strstr($refhost, "oingo"))		$engine = "Oingo - ";
			  if (strstr($refhost, "mamma.com"))		$engine = "Mamma - ";
			  if (strstr($refhost, "rediff"))		$engine = "Rediff - ";
			  if (strstr($refhost, "start4all"))		$engine = "Start4all - ";
			  if (strstr($refhost, "iwon"))			$engine = "iWon - ";
			  if (strstr($refhost, "web.de"))		$engine = "WebDE - ";
			  if (strstr($refhost, "netscape.com"))		$engine = "Netscape - ";
			  if (strstr($refhost, "netscape.de"))		$engine = "NetscapeDE - ";
			  if (strstr($refhost, "virgilio"))		$engine = "VirgilioIT - ";
			  if (strstr($refhost, "cometsystems"))		$engine = "Comet - ";
			  if (strstr($refhost, "attbi"))		$engine = "AT&amp;T Worldnet - ";
			  if (strstr($refhost, "att.net"))		$engine = "AT&amp;T Worldnet - ";
			  if (strstr($refhost, "about.com"))		$engine = "AboutCom - ";
			  if (strstr($refhost, "earthlink"))		$engine = "Earthlink - ";
			  if (strstr($refhost, "business.com"))		$engine = "BusinessCom - ";
			  if (strstr($refhost, "surfwax"))		$engine = "Surfwax - ";
			  if (strstr($refhost, "tiscali.nl"))		$engine = "TiscaliNL - ";
			  if (strstr($refhost, "tiscali.be"))		$engine = "TiscaliBE - ";
			  if (strstr($refhost, "tiscali"))		$engine = "Tiscali - ";
			  if (strstr($refhost, "arianna"))		$engine = "Arianna - ";
			  if (strstr($refhost, "profusion"))		$engine = "ProFusion - ";
			  if (strstr($refhost, "intelliseek"))		$engine = "Intelliseek - ";
			  if (strstr($refhost, "infospace"))		$engine = "InfoSpace - ";
			  if (strstr($refhost, "metabot.ru"))		$engine = "MetaBotRU - ";
			  if (strstr($refhost, "bonzi"))		$engine = "Bonzi - ";
			  if (strstr($refhost, "info400"))		$engine = "Info400 - ";
			  if (strstr($refhost, "techtarget"))		$engine = "TechTarget - ";
			  if (strstr($refhost, "search400"))		$engine = "Search400 - ";
			  if (strstr($refhost, "searchhp"))		$engine = "SearchHP - ";
			  if (strstr($refhost, "search390"))		$engine = "Search390 - ";
			  if (strstr($refhost, "huntbar"))		$engine = "HuntBar - ";
			  if (strstr($refhost, "megaspider"))		$engine = "MegaSpider - ";
			  if (strstr($refhost, "metor."))		$engine = "Metor - ";
			  if (strstr($refhost, "baidu"))		$engine = "Baidu - ";
			  if (strstr($refhost, "sohu"))			$engine = "Sohu - ";
			  if (strstr($refhost, "radaroul"))		$engine = "RadarUOL - ";
			  if (strstr($refhost, "botbot"))		$engine = "BotBot - ";
			  if (strstr($refhost, "megaspider"))		$engine = "MegaSpider - ";
			  if (strstr($refhost, "searchhippo"))		$engine = "SearchHippo - ";
			  if (strstr($refhost, "alexa"))		$engine = "Alexa - ";
			  if (strstr($refhost, "netbul"))		$engine = "Netbul - ";
			  if (strstr($refhost, "new.net"))		$engine = "Newnet - ";
			  if (strstr($refhost, "clix.pt"))		$engine = "ClixPT - ";
			  if (strstr($refhost, "ahnenforschung"))	$engine = "Ahnenforschung - ";
			  if (strstr($refhost, "spriet"))		$engine = "Spriet - ";
			  if (strstr($refhost, "voelspriet"))		$engine = "Voelspriet - ";
			  if (strstr($refhost, "ez2www"))		$engine = "Ez2wWw - ";
			  if (strstr($refhost, "megajames"))		$engine = "MegaJames - ";
			  if (strstr($refhost, "freeserve"))		$engine = "Freeserve - ";
			  if (strstr($refhost, "wisenut"))		$engine = "Wisenut - ";
			  if (strstr($refhost, "nedgen"))		$engine = "NedGen - ";
			  if (strstr($refhost, "kazaa"))		$engine = "Kazaa - ";
			  if (strstr($refhost, "infogrid"))		$engine = "Infogrid - ";
			  if (strstr($refhost, "bbc"))			$engine = "BBC - ";
			  if (strstr($refhost, "myway"))		$engine = "MyWay - ";
			  if (strstr($refhost, "redhat"))		$engine = "Redhat - ";
			  if (strstr($refhost, "buscador.ya"))		$engine = "BuscadorYa - ";
			  if (strstr($refhost, "search66"))		$engine = "Search66 - ";
			  if (strstr($refhost, "terra.es"))		$engine = "TerraES - ";
			  if (strstr($refhost, "ieplugin"))		$engine = "IEplugin - ";
			  if (strstr($refhost, "belgacom"))		$engine = "Belgacom - ";
			  if (strstr($refhost, "sina.com"))		$engine = "SinaCN - ";
			  if (strstr($refhost, "bellsouth"))		$engine = "Bellsouth - ";
			  if (strstr($refhost, "goo.ne.jp"))		$engine = "GooJP - ";
			  if (strstr($refhost, "firehunt"))		$engine = "FireHunt - ";
			  if (strstr($refhost, "seite.com"))		$engine = "Seite - ";
			  if (strstr($refhost, "megaweb"))		$engine = "MegaWeb - ";
			  if (strstr($refhost, "brisbane"))		$engine = "T-Online - ";
			  if (strstr($refhost, "findtarget"))		$engine = "FindTarget - ";
			  if (strstr($refhost, "lizzy"))		$engine = "Lizzy - ";
			  if (strstr($refhost, "indiatimes"))		$engine = "IndiaTimes - ";
			  if (strstr($refhost, "metaseek"))		$engine = "Metaseek - ";
			  if (strstr($refhost, "register.com"))		$engine = "Register - ";
			  if (strstr($refhost, "1banana"))		$engine = "1Banana - ";
			  if (strstr($refhost, "colt"))			$engine = "Colt - ";
			  if (strstr($refhost, "suchen"))		$engine = "Suchen - ";
			  if (strstr($refhost, "comcast"))		$engine = "Comcast - ";
			  if (strstr($refhost, "netster"))		$engine = "Netster - ";
			  if (strstr($refhost, "curryguide"))		$engine = "SearchtheWeb - ";
			  if (strstr($refhost, "tjgo.com"))		$engine = "SearchtheWeb - ";
			  if (strstr($refhost, "crawl-it-all"))		$engine = "Crawl-It-All - ";
			  if (strstr($refhost, "crawldad"))		$engine = "Crawldad - ";
			  if (strstr($refhost, "brint.com"))		$engine = "Brint - ";
			  if (strstr($refhost, "home.nl"))		$engine = "A@HomeNL - ";
			  if (strstr($refhost, "chello.nl"))		$engine = "ChelloNL - ";
			  if (strstr($refhost, "searchalot"))		$engine = "Searchalot - ";
			  if (strstr($refhost, "rogers.com"))		$engine = "RogersCom - ";
			  if (strstr($refhost, "ceoexpress"))		$engine = "CEOExpress - ";
			  if (strstr($refhost, "wp.pl"))		$engine = "WP.pl - ";
			  if (strstr($refhost, "startnow"))		$engine = "StartNow - ";
			  if (strstr($refhost, "ubbi"))			$engine = "Ubbi - ";
			  if (strstr($refhost, "verizon"))		$engine = "Verizon - ";
			  if (strstr($refhost, "hotmail"))		$engine = "Hotmail - ";
			  if (strstr($refhost, "searchwho"))		$engine = "SearchWho - ";
			  if (strstr($refhost, "cnn"))			$engine = "CNN - ";
			  if (strstr($refhost, "i-une"))		$engine = "i-une - ";
			  if (strstr($refhost, "metaspinner.de"))	$engine = "MetaSpinnerDE - ";
			  if (strstr($refhost, "monstercrawler"))	$engine = "Monstercrawler - ";
			  if (strstr($refhost, "allthesites"))		$engine = "Allthesites - ";
			  if (strstr($refhost, "algebraic"))		$engine = "GeometryNET - ";
			  if (strstr($refhost, "geometry"))		$engine = "GeometryNET - ";
			  if (strstr($refhost, "turbo10"))		$engine = "Turbo10 - ";
			  if (strstr($refhost, "blueyonder"))		$engine = "BlueYonder - ";
			  if (strstr($refhost, "positiontech"))		$engine = "PositionTech - ";
			  if (strstr($refhost, "ancestry"))		$engine = "Ancestry - ";
			  if (strstr($refhost, "mybegin.nl"))		$engine = "MybeginNL - ";
			  if (strstr($refhost, "searchy"))		$engine = "SearchY - ";
			  if (strstr($refhost, "hurra.de"))		$engine = "HurraDE - ";
			  if (strstr($refhost, "zoekinalles"))		$engine = "Zoekinalles - ";
			  if (strstr($refhost, "search123"))		$engine = "Search123 - ";
			  if (strstr($refhost, "searchandclick"))	$engine = "Search+Click - ";
			  if (strstr($refhost, "blueglobus"))		$engine = "BlueGlobus - ";
			  if (strstr($refhost, "webwatch.be"))		$engine = "WebWatchBE - ";
			  if (strstr($refhost, "eniro.se"))		$engine = "EniroSE - ";
			  if (strstr($refhost, "searchscout"))		$engine = "SearchScout - ";
			  if (strstr($refhost, "startium"))		$engine = "Startium - ";
			  if (strstr($refhost, ".info.com"))		$engine = "InfoCOM - ";
			  if (strstr($refhost, ".crawler.com"))		$engine = "CrawlerCOM - ";
			  if (strstr($refhost, "amazon"))		$engine = "Amazon - ";
			  if (strstr($refhost, "munky"))		$engine = "Munky - ";
			  if (strstr($refhost, "ilectric"))		$engine = "Ilectric - ";
			  if (strstr($refhost, "vvamsterdam"))		$engine = "VV Amsterdam - ";
			  if (strstr($refhost, "lop.com"))		$engine = "Lop - ";
			  if (strstr($refhost, "searchit"))		$engine = "Searchit - ";
			  if (strstr($refhost, "amsterdamonline"))	$engine = "AmsterdamOnline - ";
			  if (strstr($refhost, "020online"))		$engine = "020 Online - ";
			  if (strstr($refhost, "anywho"))		$engine = "AnyWho - ";
			  if (strstr($refhost, "holland.info"))		$engine = "Holland Info - ";
			  if (strstr($refhost, "zoeky"))		$engine = "Zoeky - ";
			  if (strstr($refhost, "search2525"))		$engine = "Search2525 - ";
			  if (strstr($refhost, "wanadoo.nl"))		$engine = "Wanadoo - ";
			  if (strstr($refhost, "googlealert"))		$engine = "GoogleAlert - ";
			  if (strstr($refhost, "ezanga"))		$engine = "eZanga - ";
			  if (strstr($refhost, "sbsonline"))		$engine = "SBSonline - ";
			  if (strstr($refhost, "canoe"))		$engine = "Canoe - ";
			  if (strstr($refhost, "searchscout"))		$engine = "SearchScout - ";
			  if (strstr($refhost, "voila"))		$engine = "Voila - ";
			  if (strstr($refhost, "tele2internet"))	$engine = "Tele2Internet - ";
			  if (strstr($refhost, "3721.com"))		$engine = "3721CN - ";
			  if (strstr($refhost, "metaeureka"))		$engine = "MetaEureka - ";
			  if (strstr($refhost, "yoursearchfinder"))	$engine = "YourSearchFinder - ";
			  if (strstr($refhost, "your.com"))		$engine = "YourCOM - ";
			  if (strstr($refhost, "gigablast"))		$engine = "Gigablast - ";
			  if (strstr($refhost, "copernic"))		$engine = "Copernic - ";
			  if (strstr($refhost, "gebeld"))		$engine = "Gebeld - ";
			  if (strstr($refhost, "qsrch"))		$engine = "Quick! - ";
			  if (strstr($refhost, "bestsearchonearth"))	$engine = "Quick! - ";
			  if (strstr($refhost, "upspiral"))		$engine = "UpSpiral - ";
			  if (strstr($refhost, "usseek"))		$engine = "USseek - ";
			  if (strstr($refhost, "01net"))		$engine = "01net - ";
			  if (strstr($refhost, "avantfind"))		$engine = "AvantFind - ";
			  if (strstr($refhost, "fullreviews"))		$engine = "FullReviews - ";
			  if (strstr($refhost, "findallresults"))	$engine = "FindAllResults - ";
			  if (strstr($refhost, "need2find"))		$engine = "Need2Find - ";
			  if (strstr($refhost, "reliableresults"))	$engine = "ReliableResults - ";
			  if (strstr($refhost, "startpagina"))		$engine = "Startpagina - ";
			  if (strstr($refhost, ".sify."))		$engine = "Sify - ";
			  if (strstr($refhost, "howstuffworks"))	$engine = "HowStuffWorks - ";
			  if (strstr($refhost, "seznam"))		$engine = "Seznam - ";
			  if (strstr($refhost, "oemji"))		$engine = "Oemji - ";
			  if (strstr($refhost, "nigma.ru"))		$engine = "NigmaRU - ";
			  if (strstr($refhost, "starware.com"))		$engine = "Starware - ";
			  if (strstr($refhost, "bisnis.nl"))		$engine = "BisNis - ";
			  # zoekmach
			  if (strstr($refhost, "1stekeuze"))		{ $engine = "1stekeuze - "; $search = str_replace("_"," ",str_replace(".html","",$search)); }
			  if (strstr($refhost, "linkcity") && $search == $hr) {$engine = "LinkcityBE - "; $search = "Link";}
			  if (strstr($refhost, "vdab"))			{$engine = "Vdab-BE - "; $search = "Link";}
			  if (strstr($refhost, "experts-exchange"))	{$engine = "Experts-Exchange - "; $search = "Forum";}
			  if (strstr($refhost, "euroseek"))		$engine = "Euroseek - ";
			  if (strstr($refhost, "vivisimo"))	{	$engine = "Vivisimo - ";
									$hr = "vivisimo.com/search?query=".urlencode($search); }
			  if (strstr($refhost, "msn") && !strstr($engine, " - ")) $engine = "MSN - ";
			}
		      }
		    }
		    if (!strstr($engine, " - ")) $engine = str_replace("www.", "", $refhost)." - ";
		    if (strstr($refpath, "DenHamV"))
		      $search = "Historie Den Ham - Vroomshoop";
		  }
		} else {
		  if (strstr($refhost, "cgi.monitor.nl") || !eregi("($mysites)", $refhost)){
		    if (strstr($refpath, "DenHamV") || strstr($refhost, "goodtimes")){
		      if (strstr($refpath, "DenHamV")) $search = "Historie Den Ham - Vroomshoop";
		      if (strstr($refhost, "goodtimes")) $search = "Waterkant.net - Naslag";
		    } else {
		      $search = "No title";
		      $fr = fsockopen ("$refhost", 80, $errno, $errstr);
		      if ($fr) {
			$regs = explode ("#", $refpath);
			$fsockpath = $regs[0];
			fputs ($fr, "GET $fsockpath HTTP/1.1\r\n");
			fputs ($fr, "Host: $refhost\r\n\r\n");
			while (!feof($fr)) {
			  $regel = fgets ($fr,1024);
			  if ( ereg("^Location: http://", $regel)) {
			    $hr	= ereg_replace("^Location: http://", "", $regel);
			    $hr = ereg_replace("(\015\012)|(\015)|(\012)", "", $hr);
			    $refpos  = strpos($hr, "/");
			    $refhost = substr($hr, 0, $refpos);
			    $refpath = substr($hr, $refpos);
			    $fq = fsockopen ("$refhost", 80, $errno, $errstr);
			    if ($fq) {
			      fclose ($fq);
			      fclose ($fr);
			      $fr = fsockopen ("$refhost", 80, $errno, $errstr);
			      if ($fr) {
				$regs = explode ("#", $refpath);
				$fsockpath = $regs[0];
				fputs ($fr, "GET $fsockpath HTTP/1.1\r\n");
				fputs ($fr, "Host: $refhost\r\n\r\n");
				$regel = fgets ($fr,1024);
			      }
			    }
			  }
			  if ( stristr($regel, "<title>") ) {
			    while (!feof($fr) && !stristr($regel, "</title>")) {
			      $regel = $regel.fgets ($fr,1024);
			      $regel = ereg_replace("(\015\012)|(\015)|(\012)"," ",$regel);
			    }
			    $regel = str_replace("<TITLE>", "<title>", $regel);
			    $regs = explode ("<title>", $regel);
			    $regel = $regs[1];
			    if ( strstr($regel, "<") ) {
			      $regs  = explode ("<", $regel);
			      $regel = $regs[0];
			    }
			    $search = trim($regel);
			    break;
			  }
			}
			fclose ($fr);
		      }
		    }
		  }
		}
	      }
	    }
	    $hr = ereg_replace("(%20)+", "+", $hr);
	    $hr = ereg_replace("\++", "+", $hr);
	    $hr = ereg_replace("\"+", "%22", $hr);
	    if ($search == "302 Found") $search = $refhost;
	    $hr = str_replace("imgrefurl=http:///", "imgrefurl=http://$host/", $hr);
	  }
	}
	if (ereg("Google Groups ", $engine)) $search = "Search";
	if (ereg("Usenet", $engine)) $search = "Search";
	if (ereg("216\.239\.", $hr))
	  $engine = eregi_replace("(216\.239\.)([0-9]{1}\.|[0-9]{2}\.|[0-9]{3}\.)([0-9]{1}|[0-9]{2}|[0-9]{3})(.*)", "Google - ", $hr);
	if (!ereg("\.", $engine)) {
	  $taal = eregi_replace("(en|off|of|on|pdf|xx-bork)", "", eregi_replace("(.*)(hl=)(([A-Za-z]|-)*)(&| )(.*)", "\\3", "hl=en&".$hr." "));
	  if (!$taal) $taal = eregi_replace("(en|off|of|on|pdf)", "", eregi_replace("(.*)(lr=lang_)(([A-Za-z]|-)*)(&| )(.*)", "\\3", "lr=lang_en&".$hr." "));
	  if (!$taal) $taal = eregi_replace("(en|off|of|on|pdf|XX)", "", eregi_replace("(.*)(kl=)(([A-Za-z]){2})(&| )(.*)", "\\3", "kl=en&".$hr." "));
	  if (!$taal) $taal = eregi_replace("(en|any|pdf|srch|XX)", "", eregi_replace("(.*)(&l=)(([A-Za-z]|-){2,5})(&| )(.*)", "\\3", "&l=any&".$hr." "));
	  if (!$taal) $taal = eregi_replace("(web|www|looksmart|search.*)", "", str_replace(eregi_replace("(.*)(\.altavista\.|\.alta-vista\.|\.av\.)(.*)", "\\2\\3", $refhost), "", $refhost));
	  if (!$taal) $taal = eregi_replace("(com\.|com)+", "", str_replace(eregi_replace("(.*)(\.msn\.|\.ninemsn\.)(.*)", "\\1\\2", $refhost), "", $refhost));
	  if (!$taal) $taal = eregi_replace("(com\.|com)+", "", str_replace(eregi_replace("(.*)(\.lycos\.)(.*)", "\\1\\2", $refhost), "", $refhost));
	  if ( $taal) $engine = str_replace("Google", "Google.$taal", $engine);
	  if (!$taal && !ereg("\.", $engine)) {
	    $ala = explode(";", $al);
	    $taal = eregi_replace("(en-us|en|pdf),", "", $ala[0]);
	    $taal = eregi_replace(",(en-us|en|pdf)", "", $taal);
	    $taal = trim(eregi_replace("(en-securid|en-us|pdf)", "", $taal));
	    $taal = ($taal != "en") ? $taal : "";
	    $taal = (!ereg("[0-9]", $taal)) ? $taal : "";
	  }
	  if ($taal != "" && !ereg("\.", $engine) && $px != "84.87.225.195") $engine = str_replace(" - ", ".$taal - ", $engine);
	}
	if (ereg("cache[:|%3A]", $hr)) $engine = ereg_replace(" - ", " cache - ", $engine);
	if (ereg("translate_", $hr) && !ereg("translate", $engine)) $engine = ereg_replace(" - ", " translate - ", $engine);
	if (($engine == "Altavista - ") && ereg("pg=dir", $refpath)) {
		$search = urldecode(ereg_replace("_", " ", (eregi_replace("\.([a-z0-9][a-z0-9])", "%\\1", $search))));
	}
	$search = eregi_replace("(looksmart.alta|www.alta|alta)vista.com/r(([a-z0-9]|:|%|_|\.|\/|-|\?|=|&)+)http://([a-z0-9]+)\.($mysites)\.(nl|be|de|info)/", "\\4", $search);
	$search = eregi_replace("(cache)(([a-z0-9]|:|%|_|\.|\/|-)+)( )", "", $search);
	$search = trim(eregi_replace("site:[[:alnum:]]+\.($mysites)\.(nl|be|de|info)", "", $search));
	if ($search == "No title") $search = "Search";
	if ($ziek && $search == "Search") $search = "Zoeken";
	$hr = ereg_replace("translate_(c|n)", "translate", $hr);
	$lr = $hr;
	$trimmed = trimsearch($search);
	$search = eregi_replace("(( |-|\+)($tekort))+(( |-|\+)($remove))+(( |-|\+)($tekort))+( |-|\+|\")", " ", " ".$search." ");
	$search = eregi_replace("(( |-|\+)($tekort))+(( |-|\+)($remove))+( |-|\+|\")", "\\7", " ".$search." ");
	$search = eregi_replace("(( |-|\+)($remove))+(( |-|\+)($tekort))+( |-|\+|\")", "\\7", " ".$search." ");
	$search = eregi_replace("(( |-|\+)($remove))+( |-|\+|\")", "\\4", " ".$search." ");
	$search = eregi_replace("( |-|\+|\")(($tekort)( |-|\+))+(($remove)( |-|\+))+(($tekort)( |-|\+))+", "\\1", $search);
	$search = eregi_replace("( |-|\+|\")(($tekort)( |-|\+))+(($remove)( |-|\+))+", "\\1", $search);
	$search = eregi_replace("( |-|\+|\")(($remove)( |-|\+))+(($tekort)( |-|\+))+", "\\1", $search);
	$search = eregi_replace("( |-|\+|\")(($remove)( |-|\+))+", "\\1", $search);
	$search = trim(eregi_replace("((\")($remove)(\"))+", "", $search));
	if (!ereg("%C3", $hr)) {
	  $hr = eregi_replace("(&ie=UTF-8|&ie=UTF8)+", "", $hr);
	  $hr = eregi_replace("(%26ie%3DUTF-8|%26oe%3DUTF-8|%26ie%3DUTF8|%26oe%3DUTF8)+", "", $hr);
	}
	$rm = "newwindow=1|hc=0|hs=0|c=web|ics=iso-8859-1|cs=iso-8859-1|ics=utf-8|cs=utf-8|sourceid=navclient|sourceid=opera|sourceid=mozilla-search|start=0|spell=1|hl=en|oe=UTF-8|oe=UTF8|ie=ISO-8859-1|oe=ISO-8859-1|btnG=Google(-|\+)(Search|Zoeken|Suche)";
	$hr = eregi_replace("(&($rm))+", "", $hr);
	$hr = eregi_replace("(\?|&)($rm)&+", "\\1", $hr);
	$hr = eregi_replace("(meta=&|&meta=$|lr=&|&lr=$)", "", $hr);
	$hr = ereg_replace("&x=[[:digit:]]+", "", $hr);
	$hr = ereg_replace("&y=[[:digit:]]+", "", $hr);
	$lr = "<A HREF=\"http://$hr\">$engine".html_subj($search)."</A>";
	$lr = str_replace(" - </A>", "</A>", $lr);
#	if (!strstr($hr, "?") && !strstr($hr, "/World/")) { $search = ""; $trimmed = "";}
	if (eregi("($exclhosts)", $refhost)) { $lr = ""; $engine ="" ; $search = ""; $trimmed = "";}
	if (eregi("(mbc\.ea|phenter|misumena|ballaire|citytower|pps=wm)", $hr)) { $hr = ""; $lr = ""; $engine ="" ; $search = ""; $trimmed = "";}
	if (eregi("($exclbots)", $ua)) { $lr = ""; $engine ="" ; $search = ""; $trimmed = "";}
	if (eregi("($exclips)", $ra)) { $lr = ""; $engine ="" ; $search = ""; $trimmed = "";}
	if ($search == "www.ilse.nl/searchresults.dbl") { $lr = ""; $engine ="" ; $search = ""; $trimmed = "";}
	# einde knip van ehrhardt.nl

	if ($me == 0) {
	  if (strstr($lr, ".")
	  && !strstr($hr, "netcraft")
	  && !strstr($hr, "unknown origin")
	  && !strstr($hr, "bookmarks")
	  && !strstr($kr, "hotmail")
	  && (!$zoek || eregi("(search4it|/World/|Usenet)", $hr) || ereg("[?]", $refpath))
	  ){
	    $fl   = eregi_replace("^(.{2,6}://)?[^/]*($mysites)\.(nl|be|de|cg|mo)(.*)", "\\3", $href);
	    $href = eregi_replace("^(.{2,6}://)?([^/]*)($mysites)\.(nl|be|de|cg|mo)/", "\\2\\4/", $href);
	    $href = eregi_replace("(^www\.|^/)", "", $href);
	    $le   = trim("$ra - $search");
	    $trimmed = trimsearch($search);
	    if (($trimmed != "" && !eregi($lockout, $search)) || $sa == "127.0.0.1") {
	      $fp = @fopen($latest, "r");
	      if($fp) $la = fread($fp, 1024);
	      if($fp) fclose($fp);
	      if ("$le" != "$la" || $sa == "127.0.0.1") {
		$fp = @fopen($latest, "w");
		if($fp) fwrite($fp, "$le");
		if($fp) fclose($fp);
		$fp = @fopen($log, "ab");
		if($fp) fwrite($fp, "$today - $lr<BR>\n");
		if($fp) fclose($fp);
	      }
	    }
	  }
	}
}
if ($ra == "80.126.8.179" && ereg("^Opera", $ua)) {
	$fl   = eregi_replace("^(.{2,6}://)?[^/]*($mysites)\.(nl|be|de|cg|mo)(.*)", "\\3", $href);
	$href = eregi_replace("^(.{2,6}://)?([^/]*)($mysites)\.(nl|be|de|cg|mo)/", "\\2\\4/", $href);
	$href = eregi_replace("(^www\.|^/)", "", $href);
	$href = eregi_replace("/cbt/", "/", $href);
#	$lo = trim("$lr - $href");
#	if ($trimmed == "Search") $lo = trim("$lr".(($href != "/") ? " - $href" : ""));
#	$lo = ereg_replace(" - (nl|be|de)\/nohref.htm", "<!-- nohref $ua -->", $lo);
	$lo = trim("$today - $fl $lr - $href");
	$lo = ereg_replace(" - (nl|be|de)\/nohref.htm", "<!-- nohref $ua -->", $lo);
	$le = trim("$search - ".substr($href,strpos($href, "/")));
	print ("// \$host	= $host\n");
	print ("// \$ru		= $REQUEST_URI\n");
	print ("// \$file	= $file\n");
	print ("// \$fl		= $fl\n");
	print ("// \$sc		= $sc\n");
	print ("// \$href	= $href\n");
	print ("// \$hr		= $hr\n");
	print ("// \$refhost	= $refhost\n");
	print ("// \$refpath	= $refpath\n");
	print ("// \$ss		= $ss\n");
	print ("// \$engine	= $engine\n");
	print ("// \$zoek	= $zoek\n");
	print ("// \$search	= $search\n");
	print ("// \$trimmed	= $trimmed\n");
	print ("// \$lr		= $lr\n");
	print ("// \$lo		= $lo\n");
	print ("// \$le		= $le\n");
	print ("// \$QS		= ".getenv("QUERY_STRING")."\n");
	print ("// \$HR		= ".getenv("HTTP_REFERER")."\n");
	print ("// \$loc	= $loc\n");
	print ("// \$taal	= $taal\n");

	print ("document.write(\"<!-- \$href	= ".ereg_replace("\"", "\\\"", getenv("HTTP_REFERER"))." -->\\n\");\n");
	print ("document.write(\"<!-- \$qs	= ".ereg_replace("\"", "\\\"", getenv("QUERY_STRING"))." -->\\n\");\n");
}
?>
