Просмотр файла o5on.ru/wml/outtop.php

Размер файла: 1.27Kb
<?php
include "config.php";
include '../inc/config.inc.php';
include '../inc/functions.inc.php';
connect_to_db();

if (empty($_GET['uid'])) exit;
$uid=dig($_GET['uid']);

// проверка существования
$result = mysql_query("SELECT link FROM users WHERE uid=$uid");
$row=mysql_fetch_row($result);
if (empty($row[0])) exit;

// получаем ссылку
$user_data = mysql_query("SELECT link FROM 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");
?>