/home/techb158/immovalet.ca/Client
Edit: /home/techb158/immovalet.ca/Client/counter.php (3513B)
query($querys);
while($row = $results->fetch_assoc())
{
$totalhits = $row['totalhits'];
}
// ########################################################
// ######### check if counter exsist and update ###########
// ########################################################
if(mysqli_num_rows(mysqli_query($mysqli,"SELECT page FROM $dbtablehits WHERE page = '$page'")))
{
$totalhits++;
//A counter for this page already exsists. Now we have to update it.
$updatecounter = mysqli_query($mysqli,"UPDATE $dbtablehits SET count = '$totalhits' WHERE page = '$page'");
if (!$updatecounter)
{
die ("Can't update the counter : " . mysqli_error()); // remove ?
}
}
else
{
// This page did not exsist in the counter database. A new counter must be created for this page.
$insert = mysqli_query($mysqli,"INSERT INTO $dbtablehits (page, count)VALUES ('$page', '1')");
if (!$insert)
{
die ("Can\'t insert into $dbtablehits : " . mysqli_error()); // remove ?
}
}
// ####################################################
// ######### add IP and user-agent and time ###########
// ####################################################
// gather user data
$ip= $_SERVER["REMOTE_ADDR"];
$agent =$_SERVER["HTTP_USER_AGENT"];
$datetime =date("Y/m/d") . ' ' . date('H:i:s') ;
if(!mysqli_num_rows(mysqli_query($mysqli,"SELECT ip_address FROM info WHERE ip_address = '$ip'"))) // check if the IP is in database
{
// if not , add it.
$adddata = mysqli_query($mysqli,"INSERT INTO $dbtableinfo (ip_address, user_agent, datetime) VALUES('$ip' , '$agent','$datetime' ) ") ;
if (!$adddata)
{
die('Could not add IP : ' . mysqli_error()); // remove ?
}
}
// ***************************************************************
// ** delete the first entry in $dbtableinfo if rows > $maxrows **
// ***************************************************************
mysqli_close($mysqli);
}
?>