<?php
define('NTOP', 1);
require_once('system/connect.php');
require_once('system/core.php');
require_once('system/function.php');
if(!$id OR $id < 1)
	{
		exit('Не верно введен ID');
	}
$isset = mysql_query("SELECT * FROM `".$prefix."sait` WHERE `status` != '0' AND `id` = '".$id."'");
if(mysql_num_rows($isset) == 0)
	{
		exit('Нет такого сайта!');
	}

          $host = mysql_fetch_array(mysql_query("SELECT `hosts` FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0' AND `id` = '".$id."'"));

          $count = mysql_result(mysql_query("SELECT COUNT(*) FROM `".$prefix."sait` WHERE `status` = '1' AND `hosts` > '0' AND `hosts` > '".$host['hosts']."'"), 0);

          $page = ceil(($count+1) / $page_top);

	mysql_query("INSERT INTO `".$prefix."go` SET 
                `id_sait` = '".$id."', 
                `type` = 'in', 
                `time` = '".time()."'");
	mysql_query("UPDATE `".$prefix."sait` SET `in` = (`in` + 1), `all_in` = (`all_in` + 1) WHERE `id` = '".$id."'");
session_start();
////пишем в сессию id сайта
$_SESSION['id'] = $id;

	header('Location: http://'.$set['home'].'/'.$page);
?>