<?php
$db_hostname = "**.***.***.**"; /*Host database*/
$db_username = "********"; /*User database*/
$db_password = "********"; /*Pass database*/
$db_name = "********"; /*Nome database*/
$dbcon = mysql_connect($db_hostname, $db_username, $db_password);
mysql_select_db("$db_name");
$timestamp= time();
$usr_ip= $_SERVER['REMOTE_ADDR'] ;
$timestamp_out = $timestamp - 86400;
$banner = array("<img src=\"http://www.celmania.org/modules/LinkMe/images/500x60.gif\" width=\"468\" height=\"60\" alt=\"1\" />",
"<img src=\"<img src=\"http://www.celmania.org/modules/LinkMe/images/banner2.jpg\" width=\"468\" height=\"60\" alt=\"2\" />",
"<img src=\"http://www.celmania.org/modules/LinkMe/images/minibanner.gif\" width=\"468\" height=\"60\" alt=\"3\" />");
$sql = "SELECT adv_ip, adv_time, adv_views FROM `tfk_adv` WHERE adv_ip = '$usr_ip' AND adv_time > '$timestamp_out' LIMIT 0, 1";
$result = mysql_query($sql, $dbcon);
$row = mysql_fetch_array($result);
if ($row[adv_ip] == $usr_ip) {
if ($row[adv_views] >= 2) {
$row[adv_views]=0;
$tfk_banner = $banner[2];
$sql = "UPDATE `tfk_adv` SET `adv_views` = '$row[adv_views]' WHERE adv_ip = '$usr_ip' AND adv_time > '$timestamp_out';";
mysql_query($sql, $dbcon);
}
else {
$row[adv_views]++;
$tfk_banner = $banner[$row[adv_views]];
$sql = "UPDATE `tfk_adv` SET `adv_views` = '$row[adv_views]' WHERE adv_ip = '$usr_ip' AND adv_time > '$timestamp_out';";
mysql_query($sql, $dbcon);
}
}
else {
$tfk_banner = $banner[0];
$sql = "INSERT INTO tfk_adv (adv_ip, adv_time) VALUES ('$usr_ip', '$timestamp');";
mysql_query($sql, $dbcon);
}
echo $tfk_banner;
?>