Файл: profi_wm/top/go.php
Строк: 20
<?php
// by -=ШАХТЕР=- (waphp.ru - качай только тут)
include "config.php";
$data = $_SERVER['QUERY_STRING'];
list($uid, $size) = explode(",", $data);
$uid = check(intval($uid));
if (empty($uid)) exit;
// проверка существования
$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 `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 `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 `weeks` SET `out`=$out_count WHERE `date`=$today AND `uid`=$uid LIMIT 1");
header("Location: $link");
?>