/*This piece of code enters some tracking information into the database*/
/*Excluding hits from hosting server*/
/*If you want to change this script in the future, make sure you change it in other header files as well i.e headersearch.php, tempheaderGuide.php*/
if (!stristr($_SERVER['REMOTE_HOST'],'dhcp.soton.ac.uk')) {
//setup static variables
$referer=$_SERVER['HTTP_REFERER'];
$user_agent=getenv ("HTTP_USER_AGENT");
$ipAddress=$_SERVER['REMOTE_ADDR'];
$page_accessed="http://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
$remoteHost=$_SERVER['REMOTE_HOST'];
/*Redirect all permanently banned IPs to google web site here*/
if ($ipAddress=='109.236.80.29') {
header('Location:http://www.google.com');
exit();
}
/*Connect to the server and select database*/
$conn=mysql_connect("uos-web00155-vs","restore","6bgSiq6Nr") or die ('Error connecting to mysql db');
mysql_select_db("restore") or die("Unable to select database");
/*verify that the coming request is genuine and the IP address is not amongst those banned from visiting the site*/
$sqlip="select ipaddress from ipAddress where ipAddress='".$ipAddress."'";
$ipresult=mysql_query($sqlip);
$rows=mysql_num_rows($ipresult);
//echo $rows;
if (mysql_num_rows($ipresult) > 0) {
header('Location:http://www.restore.ac.uk/sitewarning.php');
exit();
}
mysql_free_result($ipresult);
/*verification of hosting server's genuine request ends*/
//create and issue query after confirming that the hosting server's IP is not one of the banned IPs
$sql="INSERT INTO access_tracker (page_url, user_agent, http_referer, ip_address, date_accessed, remote_host) values ('".$page_accessed."', '".$user_agent."', '".$referer."', '".$ipAddress."' , CURDATE(),'".$remoteHost."' )";
mysql_query($sql) or die (mysql_error ());
//close connection to mysql
mysql_close($conn);
}