session_start();
define(SITE_BASE,"callctr_quoteit");
$user_agent=strtolower($HTTP_USER_AGENT);
if (strlen($_REQUEST["source"]) > 0)
$source = $_REQUEST["source"];
else
{
$source = $_SESSION["source"];
$mysource = $_SESSION["mysource"];
}
//check if the agent is a robot
$browsers=array('msie','opera','windows','powerpc','macintosh','[en]','gecko','win32','win16','win95','winnt','konqueror','galeon','firefox');
$robots=array('seeker','crawler','retriever','infoseek','fireball','activex','bot','spider');
foreach($browsers as $browser)
{
if(substr_count($user_agent,$browser)>0)
{
$pass=true;
foreach($robots as $robot)
{
if(substr_count($user_agent,$robot)>0)
{
$pass=false;
}
}
break;
}
}
if($pass!=false)
{
session_register("mysource");
session_register("mykeyword");
session_register("referer");
if(($source!='')&&($mysource==''))
{
$referer=strtolower($HTTP_REFERER);
$mysource=SITE_BASE."_".str_replace(":","",$source);
if(substr_count(strtolower($HTTP_REFERER),"google")>0){$key="q=";}
elseif(substr_count(strtolower($HTTP_REFERER),"altavista")>0){$key="q=";}
elseif(substr_count(strtolower($HTTP_REFERER),"lycos")>0){$key="query=";}
elseif(substr_count(strtolower($HTTP_REFERER),"yahoo")>0){$key="p=";}
elseif(substr_count(strtolower($HTTP_REFERER),"search.aol")>0){$key="query=";}
elseif(substr_count(strtolower($HTTP_REFERER),"search.msn")>0){$key="q=";}
elseif(substr_count(strtolower($HTTP_REFERER),"overture")>0){$key="keywords=";}
elseif(substr_count(strtolower($HTTP_REFERER),"excite")>0){$key="qkw=";}
elseif(substr_count(strtolower($HTTP_REFERER),"directhit")>0){$key="qry=";}
elseif(substr_count(strtolower($HTTP_REFERER),"webcrawler")>0){$key="qkw=";}
elseif(substr_count(strtolower($HTTP_REFERER),"alexa")>0){$key="p=";}
if($key!='')
{
$temp=explode("$key",strtolower($HTTP_REFERER));
$temp2=explode("&",$temp[1]);
$mykeyword=trim(str_replace("+"," ",str_replace("%2C"," ",str_replace("%20"," ",str_replace("%22","",$temp2[0])))));
}
}
elseif($mysource=='')
{
// echo "";
$referer=strtolower($HTTP_REFERER);
if(substr_count(strtolower($HTTP_REFERER),"google")>0){$key="q=";}
elseif(substr_count(strtolower($HTTP_REFERER),"altavista")>0){$key="q=";}
elseif(substr_count(strtolower($HTTP_REFERER),"lycos")>0){$key="query=";}
elseif(substr_count(strtolower($HTTP_REFERER),"yahoo")>0){$key="p=";}
elseif(substr_count(strtolower($HTTP_REFERER),"search.aol")>0){$key="query=";}
elseif(substr_count(strtolower($HTTP_REFERER),"search.msn")>0){$key="q=";}
elseif(substr_count(strtolower($HTTP_REFERER),"overture")>0){$key="keywords=";}
elseif(substr_count(strtolower($HTTP_REFERER),"excite")>0){$key="qkw=";}
elseif(substr_count(strtolower($HTTP_REFERER),"directhit")>0){$key="qry=";}
elseif(substr_count(strtolower($HTTP_REFERER),"webcrawler")>0){$key="qkw=";}
elseif(substr_count(strtolower($HTTP_REFERER),"alexa")>0){$key="p=";}
if($key!='')
{
$temp=explode("$key",strtolower($HTTP_REFERER));
$temp2=explode("&",$temp[1]);
$mykeyword=trim(str_replace("+"," ",str_replace("%2C"," ",str_replace("%20"," ",str_replace("%22","",$temp2[0])))));
}
$engines = array("google","altavista","lycos","yahoo","aol","looksmart","overture","excite","directhit","hotbot","webcrawler","ask","alexa","alltheweb");
$found = false;
foreach($engines as $engine)
{
if(substr_count(strtolower($HTTP_REFERER),$engine)>0)
{
$mysource=SITE_BASE."_".$engine;
$found = true;
break;
}
}
if (!$found)
$mysource = SITE_BASE;
}
session_register("mysource");
session_register("source");
$_SESSION["source"] = $source;
$_SESSION["mysource"] = $mysource;
if (substr_count($_SERVER['HTTP_REFERER'],"pagead2.googlesyndication.com") > 0)
{
$_SESSION['google_content'] = true;
mail("code@irelocation.com","tac content ip",$_SERVER['REMOTE_ADDR']);
}
if(isset($show_referer))
{
echo "\n
source: $mysource\n keyword: $mykeyword\n referer: $referer
\n\n";
}
$source = $mysource;
}
?>