Размер файла: 1.26Kb
<?php
include('config.php');
include('functions.php');
if(empty($_GET['uid'])) exit;
$uid=intval($_GET['uid']);
// проверка существования
$result=mysql_query("SELECT `link` FROM `top_users` WHERE `uid`='".$uid."';");
$row=mysql_fetch_row($result);
if(empty($row[0])) exit;
// получаем ссылку
$user_data=mysql_query("SELECT `link` FROM `top_users` WHERE `uid`='".$uid."';");
$user_data_row=mysql_fetch_array($user_data);
$link=$user_data_row['link'];
// вышло из топа
$week_day=date("w");
$today=date("Ymd");
// подсчет
$result=mysql_query("SELECT `out` FROM `top_weeks` WHERE `date`='".$today."' AND `uid`='".$uid."' LIMIT 1;");
$row=mysql_fetch_array($result);
if(empty($row))
{
$dayNext=$week_day+7;
if($dayNext>7)
{
$dayNext-=7;
}
$cntDay=8-$dayNext;
$nextMonday=date("Ymd",mktime(0,0,0,date("m"),date("d")+$cntDay));
mysql_query("INSERT INTO `top_weeks` VALUES ('','".$uid."','".$nextMonday."','".$today."','".$week_day."','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');");
$out_count=0;
}
else
{
$out_count=$row['out'];
}
$out_count++;
// сохранение
mysql_query("UPDATE `top_weeks` SET `out`='".$out_count."' WHERE `date`='".$today."' AND `uid`='".$uid."' LIMIT 1;");
header("Location: ".$link);
?>