", "\"", "/", "."); $arneworigin = array("", "", "", "", "", "", "", "", "", ""); $arqstring=array();//make sure array is empty $arqstring=explode("&", $_SERVER["HTTP_REFERER"]);//break up query string $arqueue=explode("?", $arqstring[0]);//just break up the first string (normally includes the URL just in case an variables still lurking array_unshift($arqstring, $arqueue[0], $arqueue[1]); for ( $adf = 0; $adf <= count($arqstring); ++$adf) { $arqkeyval=array(); $arqkeyval=explode("=", $arqstring[$adf]); if($arqkeyval[0]=="q"){$arkeyword=$arqkeyval[1];}//if q is set then keyword found hurrah! //other keyword finders can be added here as well }//loop through and split on = find q $arreferrer="";//make sure it is empty $qareferrer=explode("/", $_SERVER["HTTP_REFERER"]);//split the referrerer and pull out the URL only if($qareferrer[2]!=substr($wpath,7,200)){$arreferrer=$qareferrer[2];} if(EMPTY($qareferrer[0])){$arreferrer=substr($wpath,7,200);} //echo $arreferrer; //echo substr($wpath,7,136); //work out browser name $useragent=$_SERVER['HTTP_USER_AGENT']; if (preg_match( '|Opera/([0-9].[0-9]{1,2})|',$useragent,$matched)) { $arbrowser_version=$matched[1]; $arbrowser = 'Opera'; } elseif (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$useragent,$matched)) { $arbrowser_version=$matched[1]; $arbrowser = 'IE'; } elseif(preg_match('|Firefox/([0-9\.]+)|',$useragent,$matched)) { $arbrowser_version=$matched[1]; $arbrowser = 'Firefox'; } elseif(preg_match('|Chrome/([0-9\.]+)|',$useragent,$matched)) { $arbrowser_version=$matched[1]; $arbrowser = "Chrome"; } elseif(preg_match('|Safari/([0-9\.]+)|',$useragent,$matched)) { $arbrowser_version=$matched[1]; $arbrowser = "Safari"; } else { // browser not recognized! $arbrowser_version=""; $arbrowser="Other"; } $arbot=0;//we assume visitor is not a bot $arspider = mysqli_query($link,"SELECT sd_id, sd_bot FROM settings_bots WHERE sd_live=1 order by sd_order");//only show front-end variables if(mysqli_num_rows($arspider) > 0) { while ( $grbot = mysqli_fetch_array($arspider) ) {$arbotid[]=$grbot["sd_id"];$arbotname[]=$grbot["sd_bot"];}} //print_r($arbotname); for ($ari = 0; $ari < count($arbotid); $ari++) {if(preg_match("/$arbotname[$ari]/", $useragent, $matches)) {$arbot=$arbotid[$ari];print "$arbotname[$ari]"; break;}} //if source has not been set by anything then set it to the referrer if($_SESSION['EVIAN'] == "N/A"){$_SESSION['EVIAN'] = $arreferrer;} $query = "INSERT INTO artemis ( ar_sessid, ar_page, ar_date, ar_time, ar_ipaddress, ar_browser, ar_source, ar_referrer, ar_ppc, ar_querystring, ar_keyword, ar_browsername, ar_bot, ar_location) values ( '" . $_SESSION['CCSID'] . "', '$pn', '$uberdate', '$artemistime', '" . $_SERVER['REMOTE_ADDR'] . "', '" . $useragent . "', '" . $_SESSION['EVIAN'] . "', '" . $arreferrer . "', '$arppc', '" . $_SERVER["HTTP_REFERER"] . "', '" . str_replace(arorigin, arneworigin, urldecode($arkeyword)) . "', '$arbrowser $arbrowser_version', '$arbot','$udlocation')"; //echo "
" .$query; if (! mysqli_query($link, $query) ) { $dberror = mysql_error(); } else { //NOW RESET ENTSET WITH THIS PAGE NAME - $PN. $_SESSION['ENTSET'] = "$pn"; } //end of db entry //echo $_SESSION['CCSID']; }//end of if clause for ip block else {//ip address is blocked so we don't do anything other than change the ENTSET so page can not be called again $_SESSION['ENTSET'] = "$pn"; //echo "blocked"; } } $testoutput.="
Session ID:" . $_SESSION['CCSID'] . "
Source: " . $_SESSION['EVIAN'] . "
"; ?> TCOM 144