<?php

###########################
#Скрипт: Keo v1#
#Автор: GulievMMA#
#Версия: v1#
#Страна: Азербайджан#
#Город: Сумгайыт#
#Спорт: ММА#
#Сайт: KeoTop.Ru#
#Сайт: H9M.Ru#
#Телеграм: @AnarQuliyevMMA#
#E-mail: guliev.mma@gmail.com  #
#WhatsApp: +994 (77) 768-39-39#
#WhatsApp: +994 (55) 968-78-69#
############################
#Скрипт Принадлежит Мне , Продавать и Распростронять Нельзя (!)#
############################

define('NTOP', 1);
require_once('system/connect.php');
require_once('system/core.php');
require_once('system/function.php');
error_reporting(0);
if(!$id OR $id < 1)
{
exit('Не верно введен ID');
header('Location: http://'.$set['home'].'/'.$page);
}
$isset = mysql_query("SELECT * FROM `".$prefix."sait` WHERE `status` != '0' AND `id` = '".$id."'");
if(mysql_num_rows($isset) == 0)
{
exit('Сайт на модерации, ждите одобрения администрации <b>GulievMMA</b> !!!!');
header('Location: http://'.$set['home'].'/'.$page);
}
///////
mysql_query("INSERT INTO `".$prefix."go` SET
                    `id_sait` = '".$id."',
                    `type` = 'in',
                    `time` = '".time()."'");
$host = mysql_fetch_array(mysql_query("SELECT `hosts`, `vip`, `newsait` FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0' AND `id` = '".$id."'"));
$category = mysql_fetch_array(mysql_query("SELECT `category` FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0' AND `id` = '".$id."'"));
$lh = mysql_fetch_array(mysql_query("SELECT `all_in` FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0' AND `id` = '".$id."'"));
if ($category['category'] == 11) {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `".$prefix."sait` WHERE `status` = '1' AND `hosts` > '0' AND `hosts` > '".$host['hosts']."' AND `category` = '11'"), 0);
}

elseif ($host['vip'] == '1') {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `".$prefix."sait` WHERE `status` = '1' AND `hosts` > '0' AND `hosts` > '".$host['hosts']."' AND `vip` = '1'"), 0);
} elseif ($host['newsait'] != '1') {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `".$prefix."sait` WHERE `status` = '1' AND `hosts` > '0' AND `hosts` > '".$host['hosts']."' AND `category` != '6' AND `newsait` != '1'"), 0);
} else {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `".$prefix."sait` WHERE `status` = '1' AND `hosts` > '0' AND `hosts` > '".$host['hosts']."' AND `category` != '6' AND `newsait` = '1'"), 0);
}
$page = ceil(($count+1) / $page_top);

//$id = (int) $_SERVER['QUERY_STRING'];
$sql = mysql_query("SELECT `in`, `all_in` FROM `top_sait` WHERE `ban` != '1' AND `id` = ".$id.";");
$ip = substr(str_replace('.', '', getenv('REMOTE_ADDR')), 0, 5);
$ip = intval($ip);list($in, $all_in) = mysql_fetch_row($sql);
$in++;
$all_in++;
$sqls = mysql_result(mysql_query("SELECT COUNT(*) FROM `top_inhost` WHERE `id` = ".$id." AND `ip` = '".$ip."'"), 0);
if ($sqls < 1) {
$user_isse = mysql_query("SELECT * FROM `".$prefix."sait` WHERE `id` = '$id'");
$use = mysql_fetch_array($user_isse);
$umka_id = $use['id_user'];
mysql_query("UPDATE `".$prefix."users` SET `balans` = (`balans` + 1) WHERE `id` = '$umka_id'");
}
if ($sqls < 1) {

mysql_unbuffered_query("INSERT INTO `top_inhost` SET `id` = ".$id.", `time` = ".time().", `ip` = ".$ip.";");

mysql_unbuffered_query("UPDATE `top_sait` SET `in` = '".$in."', `all_in` = '".$all_in."' WHERE `id` = ".$id.";");
}
          $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);
session_start();
if ($category['category'] == 11) {
header('Location: http://'.$set['home'].'/m/category/view/11/'.$page.'/'.$id);
} elseif ($category['category'] == 14) {
header('Location: http://'.$set['home'].'/m/category/view/14/'.$page.'/'.$id);
}
else {
header('Location: http://'.$set['home'].'/'.$page.'/'.$id);
}
////пишем в сессию id сайта
$_SESSION['id'] = $id;


?>