$CounterName="pocitadlo"; $CookieDeath=20; $ip_addr=$REMOTE_ADDR; if (isset($CounterName)) { $Last_visit=date("Y-m-d H:i:s"); $Conn=mysql_connect("localhost","vbartos.org","KiMiZeme"); mysql_select_db("vbartos_org"); $SQLText="SELECT * FROM gabbercounter WHERE CounterName='$CounterName'"; $result=mysql_query($SQLText); if (mysql_num_rows($result)==0){ $Visits=1; $SQLText="INSERT INTO gabbercounter (CounterName,Visits,Last_visit) VALUES ('$CounterName',$Visits,'$Last_visit')"; mysql_query($SQLText); $SQLText="INSERT INTO gabbercounter_log (CounterName,Visits,Visited,ip_addr) VALUES ('$CounterName',$Visits,'$Last_visit','$ip_addr')"; mysql_query($SQLText); } else{ $row=mysql_fetch_array($result); if (empty(${$CounterName})){ $Visits=++$row["Visits"]; $SQLText="UPDATE gabbercounter SET Visits=$Visits,Last_visit='$Last_visit' WHERE CounterName='$CounterName'"; mysql_query($SQLText); $SQLText="INSERT INTO gabbercounter_log (CounterName,Visits,Visited,ip_addr) VALUES ('$CounterName',$Visits,'$Last_visit','$ip_addr')"; mysql_query($SQLText); } else{ $SQLText="SELECT Visits,Last_visit FROM gabbercounter WHERE CounterName='$CounterName'"; $result=mysql_query($SQLText); $row=mysql_fetch_array($result); $Visits=$row["Visits"]; $Last_visit=$row["Last_visit"]; } } setcookie("$CounterName",$Visits,time()+$CookieDeath*60); mysql_close($Conn); $CSLast_visit=substr($Last_visit,8,2).".".substr($Last_visit,5,2).".".substr($Last_visit,0,4)." v ".substr($Last_visit,11,8); $pocet_pristupov="$Visits"; } ?>