<?php
if(!isset($_GET['get']) OR $_GET['get'] < 1)
	{
		exit('Не верно введен идентификатор');
	}
$q = Core::count("SELECT COUNT(*) FROM `user_sites` WHERE `ban` = '0' && `mod` = '0' && `host` > '0' && `id`='".$_GET['get']."'");
if($q == 0)
	{
		exit('Нет такого сайта!');
	}
$site = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
if(Core::count("SELECT COUNT(*) FROM `ip_v_top` WHERE `ip` = ? && `id_site` = ?", array($_SERVER['REMOTE_ADDR'], $site['id'])) == false){
			Core::query("INSERT INTO `ip_v_top` SET `ip` = ?, `id_site` = ?", array($_SERVER['REMOTE_ADDR'], $site['id']));
			Core::query("UPDATE `user_sites` SET `v_top` = '".($site['v_top'] + 1)."' WHERE `id` = ?", array($site['id']));
		}
		if($site['category']!=27){
			$num = 1;
	$q = Core::query("SELECT * FROM `user_sites` WHERE `category`!='27' && `ban` = '0' && `mod` = '0' && `host` > '0' ORDER BY `host` DESC");
	while($post = $q -> fetch()){	
				if($post['id']==$_GET['get']){$numer=$num;}
				$num = ++$num;
	}
header('Location: /?p='.ceil($numer/10).'&id_s='.$_GET['get'].'');
}else{
			$num = 1;
	$q = Core::query("SELECT * FROM `user_sites` WHERE `ban` = '0' && `mod` = '0' && `host` > '0' && `category`='27' ORDER BY `host` DESC");
	while($post = $q -> fetch()){	
				if($post['id']==$_GET['get']){$numer=$num;}
				$num = ++$num;
	}
header('Location: /category/sites/27/?p='.ceil($numer/10));
}
?>