<?


//echo'<font color=orange>Всем игрокам дали vip статус на 24 часа</font>';

if($ku['id']==90000000000)
{
error_reporting(E_ALL); // включаем показ ошибок
ini_set('display_errors',true); // включаем показ ошибок
}

if($ku['level']==1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0)==0)
{
mysql_query("INSERT INTO `kolhoz_ground` (`id_user`,`cultivator`) VALUES ('$ku[id]','1'),('$ku[id]','1'),('$ku[id]','1'),('$ku[id]','1')");
header("Location:/myfarm/".passgen());
exit;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `badge` WHERE `id_user` = '$ku[id]'"),0)<1)
{
mysql_query("INSERT INTO `badge` SET `id_user` = '$ku[id]'");
}
if($ku['NewYearDay']>=15)
{
    mysql_query("UPDATE `badge` SET `NewYear` = '1' WHERE `id_user` = '$ku[id]'");
}
if($ku['star']==1)
{
    mysql_query("UPDATE `badge` SET `mvp` = '1' WHERE `id_user` = '$ku[id]'");

}
if($ku['level']==15 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mest` WHERE `id_user` = '$ku[id]'"),0)<1)
{
mysql_query("INSERT INTO `kolhoz_mest` SET `id_user` = '$ku[id]'");
}
if($ku['level']==40 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]'"),0)<1)
{
mysql_query("INSERT INTO `kolhoz_pool` SET `id_user` = '$ku[id]'");
}
/*
if($ku['level']>0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `puzzle` WHERE `id_user` = '$ku[id]'"),0)<1)
{
mysql_query("INSERT INTO `puzzle` SET `id_user` = '$ku[id]'");
}
if($ku['level']>0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `ivent_6farm` WHERE `id_user` = '$ku[id]'"),0)<1)
{
mysql_query("INSERT INTO `ivent_6farm` SET `id_user` = '$ku[id]'");
}
*/
if($ku['level']>=30 && mysql_result(mysql_query("SELECT COUNT(*) FROM `collections` WHERE `id_user` = '$ku[id]'"),0)<1)
{
mysql_query("INSERT INTO `collections` SET `id_user` = '$ku[id]'");
}
if($ku['level']==10 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]'"),0)<4)
{
mysql_query("INSERT INTO `kolhoz_petground` (`id_user`) VALUES ('$ku[id]'),('$ku[id]'),('$ku[id]'),('$ku[id]')");
}

if($ku['level']==45 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_garden` WHERE `id_user` = '$ku[id]'"),0)<4)
{
mysql_query("INSERT INTO `kolhoz_garden` (`id_user`) VALUES ('$ku[id]'),('$ku[id]'),('$ku[id]'),('$ku[id]')");
}

if($ku['level']==2 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]'"),0)==0)
{
mysql_query("INSERT INTO `kolhoz_pond` (`id_user`,`cultivator`) VALUES ('$ku[id]','1'),('$ku[id]','1'),('$ku[id]','1'),('$ku[id]','1')");
}

//mysql_query("UPDATE `kolhoz_user` SET `date_last` = '$time' WHERE `id` = '$ku[id]' LIMIT 1");

$activ=time()-$ku['date_last'];
if($activ < 240)
{
$newactiv=$ku['time']+$activ;
mysql_query("UPDATE `kolhoz_user` SET `time` ='$newactiv' WHERE `id` = '$ku[id]' LIMIT 1");
}
/*$tim2=microtime(1);
include_once 'inc/q_animals.php';
if($ku['id']==1)echo '<br/> '.number_format(microtime(1)-$tim2,5).' сек. start';*/
// Collective
/*
if($ku['storona']==0){
$storona1=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `storona` = '1'"), 0);
$storona2=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `storona` = '2'"), 0);
if($storona1>$storona2)mysql_query("UPDATE `kolhoz_user` SET `storona` = '2' WHERE `id` = '$ku[id]'");
if($storona2>$storona1)mysql_query("UPDATE `kolhoz_user` SET `storona` = '1' WHERE `id` = '$ku[id]'");
if($storona2==$storona1)mysql_query("UPDATE `kolhoz_user` SET `storona` = '1' WHERE `id` = '$ku[id]'");

}
*/
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"),0)!=0)
{
$mcu=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"));
$mc=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective` WHERE `id` = '$mcu[id_collective]'"));
mysql_query("UPDATE `kolhoz_collective` SET `date_last` = '$time' WHERE `id` = '$mc[id]' LIMIT 1");
$mc['next_level']=$mc['level']+1;
$mc['flowerbed_max']=$mc['level']*10;
$mc['users_max']=($mc['level']*5)+10+$mc['users_add'];
if(isset($_GET['mycollective']) || isset($_GET['collective']) || isset($_GET['shark']))$mc['users']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_user` WHERE `id_collective` = '$mc[id]'"),0);
}
include_once 'inc/gos_start.php';
$gos=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_gos` WHERE `active` = '1' ORDER BY `time` DESC LIMIT 1"));
if($ku['expdouble']==NULL)
{
$rand=rand(1,7);
if($rand==1)$day='Mon';elseif($rand==2)$day='Tue';elseif($rand==3)$day='Wed';elseif($rand==4)$day='Thu';elseif($rand==5)$day='Fri';elseif($rand==6)$day='Sat';else $day='Sun';
mysql_query("UPDATE `kolhoz_user` SET `expdouble` = '$day' WHERE `id` = '$ku[id]'");
$ku['expdouble']=$day;
}
if($ku['expdouble']==date("D"))$dexp=1;
//$dexp=1;////////Двойной опыт
$ixp =mysql_fetch_array(mysql_query("SELECT * FROM `exp` WHERE `id` = '1'"));
if($ixp['time']>$time)$dexp3=1;////////Тройной опыт
if($ku['action_time']>time()){$id_actio = mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_action` "));$id_action = $id_actio['id_action'];}
$ku['mdp']=md5($ku['password']);
$ku['autologin']=update_ku('autologin',md5("nick:".$ku['nick'].",password:".$ku['password'].",id:".$ku['id'].""));
if(isset($_GET['outlogin']) && hsc($_GET['outlogin'])==$ku['mdp'])
{
setcookie('id', '', time() - 100, '/');

setcookie('pass', '', time() - 100, '/');
unset($_SESSION['id_user'],$_SESSION['buy_pet'],$_SESSION['buy_tree']);
header("Location: http://$_SERVER[HTTP_HOST]");
exit;
}
if(isset($_COOKIE['admin']) && ($_COOKIE['admin']>0)) {
$_SESSION['msg']='Вы находитесь в режиме просмотра профиля, [url=/?admineprof]вернуться в свой профиль[/url]';
    
}
if(isset($_GET['admineprof']) && ($_COOKIE['admin']>0)){
setcookie('id', '');
setcookie('pass', '');
unset($_SESSION['id_user'],$_SESSION['buy_pet'],$_SESSION['buy_tree']);
setcookie('admin', '');
$profile=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".($_COOKIE['admin'])."'"));
header("Location:?autologin=$profile[autologin]");
exit;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ban` WHERE `id_user` = '$ku[id]'  AND `time`>'$time')) LIMIT 1"),0)!=0){
$readban1=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_ban` WHERE `id_user` = '$ku[id]' AND `time`>'$time' LIMIT 1"));
echo '<div class="feedback"><span style="color:red">Вы заблокированы до '.vremja($readban1['msg']).'</span></div>';
}
//if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ban` WHERE `id_user` = '$ku[id]' AND (`izg` = '1' AND ((`time`>'$time' OR `time`='0') AND `inlock`IS NULL)) LIMIT 1"),0)!=0 && (!isset($_GET['user']) || isset($_GET['user']) && $_GET['user']!=$ku['id'])){header("Location:/user-$ku[id]/bans");exit;}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ban` WHERE `id_user` = '$ku[id]' AND (`izg` = '1' AND ((`time`>'$time' OR `time`='0') AND `inlock`IS NULL)) LIMIT 1"),0)!=0){
$readban=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_ban` WHERE `id_user` = '$ku[id]' AND (`izg` = '1' AND ((`time`>'$time' OR `time`='0') AND `inlock`IS NULL)) LIMIT 1"));
echo '<div class="content block"><span style="color:red">Аккаунт '.$ku['nick'].' заблокирован '.($readban['time']>0?' до '.(vremja($readban['time'])).'':'НАВСЕГДА').' за<br/>нарушение правил Сайта. Любые<br/>действия под данным аккаунтом<br/>запрещены!<br/>Причина: '.$readban['msg'].'</span><li></li></div>';

exit;
}
if($ku['id']==8232326)
{
echo '<div class="event"><h1><center>Мы скоро вернемся..</center></h1></div>';
  echo '<font color="yellow"><center><center><div class="block">В данный момент мы производим обновление игры. В течение 30 минут вы сможете продолжить наслаждаться игрой<li class="pavelgrey"><a href="/">обновить</a><li class="pavelgrey"></center></font>';

echo "</div></div></div></div></div></div></div></div></div></div><div style='text-align:center;'>";
echo'<div style="text-align:center;" class="pt small minor">';
echo "Онлайн</span> <b>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `date_last` > '".(time()-3600)."'"), 0)."</b>, регистраций
<b>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user`"), 0)."</b><br />";
echo "Моя Деревня</a> <br/>";
echo'</div>';
exit;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `complaint` WHERE `infringer` = '$ku[id]' AND `check` ='0'"),0)>=3)
{
echo '<div class="event"><h1><center>Доступ запрещен</center></h1></div>';
  echo '<font color="red"><center><center><div class="block">Мы заметили подозрительную активность на странице игрока <span class="title">'.($ku['nick']).'</span> и были вынуждены его временно заблокировать.<br>Аккаунт будет разблокирован после проверки администрацией, пожалуйста, подождите.<br> Это не займет много времени.</center></font>';
echo "</div></div></div></div></div></div></div></div></div></div><div style='text-align:center;'>";
echo'<div style="text-align:center;" class="pt small minor">';
echo "<div class='foot-box'>";
echo "Онлайн</span> <b>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `date_last` > '".(time()-3600)."'"), 0)."</b>, регистраций
<b>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user`"), 0)."</b><br />";
echo "Моя Деревня</a> <br/>";
echo'</div>';
exit;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ban` WHERE `id_user` = '$ku[id]' AND `time` > '$time' AND `izg` = '0' AND `inlock` IS NULL LIMIT 1"),0)!=0)$molchi=1; 
$ban=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_ban` WHERE `id_user` = '$ku[id]' AND `time` > '$time' AND `izg` = '0' AND `inlock` IS NULL ORDER BY `id` DESC LIMIT 1"));
$us_ban=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$ban[id_who]'"));

?>