<?php
$sql1 = "SELECT *
FROM `gallery_counter`
WHERE catID = '".$_GET['id']."'";
$results = mysqli_query($buller, $sql1);
$show = mysqli_fetch_array($results);
$ip = $_SERVER['REMOTE_ADDR'];
$id = $_GET['id'];
$sql = "SELECT COUNT(*) AS MyVisit FROM `gallery_counter` WHERE catID = '".$id."'";
$result_count2 = mysqli_query($buller,$sql);
$ShowMyVistis = mysqli_fetch_array($result_count2);
print 'Set antal gange: ';
print $ShowMyVistis["MyVisit"];
$visit_inactive = 15; // 1 min - bare som test.
$visitsession_life = time() - $_SESSION['visittimeout'];
if($visitsession_life > $visit_inactive) {
$gammeltid = $show['visitdate'];
$curtime = time();
$oldtime = strtotime($gammeltid);
//if (($curtime-$oldtime) > 24*60*60) {
if (($curtime-$oldtime) > 15) {
$_SESSION['visittimeout']=time();
# +1 i count.
$quer1 = "INSERT INTO gallery_counter (ip,catID,visitdate) VALUES (?,?,?)";
if($stmt = mysqli_prepare($buller, $quer1)){
mysqli_stmt_bind_param($stmt, "sss", $ip,$catID,$visitdate);
$ip = $_SERVER['REMOTE_ADDR'];
$catID = $id;
$visitdate = date("Y-m-d H:i:s");
mysqli_stmt_execute($stmt);
}
}
}
?>