<?

if(isset($ku['id'])){
if($ku['theme']==2){$style="404040";}
if(empty($ku['theme']) or $ku['theme']==1){$style="114411";}

if($level['rating']<1)$level['rating']=1;
$exp=round($kr/($level['rating']/100));
echo'<li class="ptm"></li></div><div style="margin:0px;background-color:#'.$style.'"> 
<div class="expline1" style="width:'.$exp.'%;"></div></div>';
echo "<div class='content'><ul class='block'>";
echo "<li class='ptm'></li></li><li>";
echo "<img width='16' height='16' src='images/icons/plants.png' alt='*'> <a href='/myfarm'>Грядки</a> ".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`id_plant` = '0' OR `time_water` = '$time' OR `time` = '$time' OR `time_water` < '$time' OR `time` < '$time' OR (`time_soil` = '$time' AND `soil` = '0') OR (`time_soil` < '$time' AND `soil` = '0'))"),0)!=0?"<span class='title'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`id_plant` = '0' OR `time_water` = '$time' OR `time` = '$time' OR `time_water` < '$time' OR `time` < '$time' OR (`time_soil` = '$time' AND `soil` = '0') OR (`time_soil` < '$time' AND `soil` = '0'))"),0).")</span>":null)."</li>";

echo "<img width='16' height='16' src='images/fish/fish.png' alt='*'> <a href='/ozero'>Озеро</a> ".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND (`id_plant` = '0' OR `time_water` = '$time' OR `time` = '$time' OR `time_water` < '$time' OR `time` < '$time' OR (`time_soil` = '$time' AND `soil` = '0') OR (`time_soil` < '$time' AND `soil` = '0'))"),0)!=0?"<span class='title'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND (`id_plant` = '0' OR `time_water` = '$time' OR `time` = '$time' OR `time_water` < '$time' OR `time` < '$time' OR (`time_soil` = '$time' AND `soil` = '0') OR (`time_soil` < '$time' AND `soil` = '0'))"),0).")</span>":null)."</li>";
if($ku['level']>=40)echo "<li><img width='16' height='16' src='images/icons/pool.png' alt='*'> <a href='/mypool'>Пруды</a> ".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND (`id_fish` = '0' OR `time` = '$time' OR `time` < '$time' OR `time_soil` = '$time' OR `time_soil` < '$time')"),0)!=0?"<span class='title'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND (`id_fish` = '0' OR `time` = '$time' OR `time` < '$time' OR `time_soil` = '$time' OR `time_soil` < '$time')"),0).")</span>":null)."</li>";

////////////////////////////////////////////////////////////Загоны
if($ku['level']>=10)
{
$count_mon=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0' AND (`time_money` = '$time' OR `time_money` < '$time')"),0);
$q=mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0'");
$count_gol=0;
while($post=mysql_fetch_array($q))
{
$max_time=$time+$post['level']*(3600*4);
$mezh_time=$max_time-$post['time'];
if($mezh_time>=4*3600)$count_gol++;
}
$q=mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0'");
$count_mon=0;
while($post=mysql_fetch_array($q))
{
$d_money=floor($post['time_money2']/(4*3600));
if($d_money>0)$count_mon++;
}
if($count_gol>$count_mon)$count_zag=$count_mon+$count_gol;else $count_zag=$count_mon+$count_gol;
echo "<li><img width='16' height='16' src='images/icons/animal.png' alt='*'> <a href='/mypetfarm'>Загоны</a> ".($count_zag?"<span class='title'>($count_zag)</span>":null)."</li>";
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if($ku['level']>=20){
if($ku['keytime']<$time)echo "<li><img width='16' height='16' src='images/icons/zkey.png' alt='*'> <a href='/nk'>Погреб</a></li>";
if($ku['keytime']>=$time)echo "<li><img width='16' height='16' src='images/icons/last_recipes.png' alt='*'> <a href='/
mycellar'>Пoгpeб</a> ".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]'
AND (`id_plant2` = '0' OR `time` < '$time' )"),0)!=0?"<span class='title'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka2` WHERE `id_user`
= '$ku[id]' AND (`id_plant2` = '0' OR `time` < '$time' )"),0).")</span>":null)."</li>";
}
////////////////////////////////////////////////////////////Сады
if($ku['level']>=45)
{
$count_mon=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_garden` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0' AND (`time_money` = '$time' OR `time_money` < '$time')"),0);
$q=mysql_query("SELECT * FROM `kolhoz_garden` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0'");
$count_gol=0;
while($post=mysql_fetch_array($q))
{
$max_time=$time+$post['level']*(3600*4);
$mezh_time=$max_time-$post['time'];
if($mezh_time>=4*3600)$count_gol++;
}
$q=mysql_query("SELECT * FROM `kolhoz_garden` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0'");
$count_mon=0;
while($post=mysql_fetch_array($q))
{
$d_money=floor($post['time_money2']/(4*3600));
if($d_money>0)$count_mon++;
}
if($count_gol>$count_mon)$count_zag=$count_mon+$count_gol;else $count_zag=$count_mon+$count_gol;
echo "<li><img width='16' height='16' src='images/icons/sad.png' alt='*'> <a href='/mygarden'>Сады</a> ".($count_zag?"<span class='title'>($count_zag)</span>":null)."</li>";
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if($ku['level']>=20)echo '<li><img width="16" height="16" src="images/icons/sword.png" alt="o"> <a href="/arena">Арена</a></li>';
echo '<li><img width="16" height="16" src="images/icons/warehouse.png" alt="o"> <a href="/warehouse">Амбар</a></li>';
echo'<li><img width="16" height="16" src="images/icons/cart.png" alt="o"> <a href="/shop">Магазин</a></li>';
echo'<li><img width="16" height="16" src="images/icons/center.png" alt="o"> <a href="/center">Город</a></li>';
$action=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_action` "));
if($action['id_action']==1)$icones='ruby';
if($action['id_action']==2)$icones='harv';
if($action['id_action']==3)$icones='plants';
if($action['id_action']==4)$icones='guild';

echo '<li class="pt"><img alt="" width="16" height="16" src="images/icons/'.$icones.'.png"> <a class="epic" href="/action">Акция</a><br>';
echo '<img alt="" width="16" height="16" src="images/icons/trophy.png"> <a href="/gos">Госзаказ</a>'.(isset($mc) && $conf['gos_look']==0?'<img width="16" height="16" alt="*" src="/images/icons/nocollective.png"/>':null).'<br/>';
echo '<img width="16" height="16" src="images/icons/ruby.png" alt="*"> <a href="/payment'.($_SERVER['HTTP_HOST']=='vk.vferme.com'?'_vk':null).'">Рубины</a></li>';
echo '<li><img width="16" height="16" src="images/icons/forum.png" alt=""> <a href="/forum">Форум</a></li><li><img width="16" height="16" src="images/icons/chat.png" alt="*"> <a href="/chat">Чат</a></li>';
echo "<li class='pt'><img width='16' height='16' src='images/icons/mails.png' alt=''> <a href='/mail'>Почта</a>".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0?" <span class='title'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0).")</span>":null)."</li>";
echo "".(($ku['status']==1 || $ku['status']==3) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ticket` WHERE (`id_adm` = '0' || (`id_adm` = '$ku[id]' && `otvet`='1')) && `otdel`='".($ku['status']==1?"1":"2")."'"),0)!=0?"<li><img width='16' height='16' src='/images/icons/tickets.png' alt=''> <a href='/support'>Заявки</a>  <span class='title'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ticket` WHERE (`id_adm` = '0' || (`id_adm` = '$ku[id]' && `otvet`='1')) && `otdel`='".($ku['status']==1?"1":"2")."'"),0).")</span>":null)."";echo '<li><img width="16" height="16" src="images/icons/favorite.png" alt=""> <a href="/friends">Друзья</a></li>';
echo "<li>";
echo "".on_k($ku['id'])."";
echo ' <a href="/user/'.$ku['id'].'">Профиль</a></li>';
if(isset($mc))
{
echo '<li><img alt="" width="16" height="16" src="images/icons/guild.png"> <a href="/mycollective">Колхоз</a></li>
<li><img width="16" height="16" src="images/icons/chat.png" alt="o"> <a href="/selsovet/collective-'.$mc['id'].'">Сельсовет</a></li>';
}
echo '</ul></div></div>';
echo "<div class='block small event'><img width='16' height='16' src='images/icons/money.png' alt='*'> <span>".(strkol($ku['money']))."</span> монет <img width='16' height='16' src='images/icons/ruby.png' alt='*'> <span>".(strkol($ku['rubies']))."</span> рубинов <img width='16' height='16' src='images/icons/".(isset($dexp) && !isset($dexp3)?"doubleexp":"".(isset($dexp3)?"threexp":"experience")."").".png' alt='*'> <span> ".($ku['level']<$bigl?"".rating($kr)."/".rating($level['rating'])."":"".rating($ku['rating'])."")." </span> опыта ";
echo "".on_k($ku['id'])."";
echo " <span>$ku[level]</span> уровень</div>";
echo "<div style='text-align:center;'><div class='ptm'>";
//Вы вошли как <span>$ku[nick]</span>, <a href='?outlogin=$ku[mdp]'>выйти</a>?
echo"</div><small><a href='/forum-28304'>Помощь</a> | <a href='/rules'>Правила игры</a> | <a href='/support'>Тех. поддержка</a>".($ku['status']==3?" | <a href='/admin'>Админка</a>":null)."";
echo "<br/>Онлайн-игра <span class='epic'>Супер Ферма</span><br/>";
if($_SERVER['HTTP_HOST']!=='vk.vferme.com'){
echo'<script type="text/javascript" src="http://mobtop.ru/c/47508.js"></script><noscript><a href="http://mobtop.ru/in/47508"><img src="http://mobtop.ru/47508.gif" alt="MobTop"/></a></noscript>';
///Счетчик
echo'<a href="http://waplog.net/c.shtml?498012"><img src="http://c.waplog.net/498012.cnt" alt="waplog" /></a><br/>';}                         

if($ku['arena_rating']>$ku['level']*100)mysql_query("UPDATE `kolhoz_user` SET `arena_rating` = '".floor($ku['level']*100)."' WHERE `id` = '$ku[id]' LIMIT 1");
$count=$ku['sponder']+$ku['catchfish']+$ku['flowerbed']+$ku['cultivator']+$ku['irregate']+$ku['soiler']+$ku['conveyor']+$ku['seeder']+$ku['fooder']+$ku['harvester']+$ku['harvester2']+$ku['cultivator2']+$ku['seeder2']+$ku['avtoconveyor']+$ku['avtofooder']+$ku['fishfooder']+$ku['autocrane']+$ku['incubator'];
if($count!==$ku['tehnika'])mysql_query("UPDATE `kolhoz_user` SET `tehnika` = '$count' WHERE `id` = '$ku[id]'");
if($ku['time_start']==0 || $ku['time_start']==NULL)mysql_query("UPDATE `kolhoz_user` SET `time_start` = '$time' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `count_fp` = '0' WHERE `time_fp` < '$time' and `id`='$ku[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `count_cp` = '0' WHERE `time_cp` < '$time' and `id`='$ku[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `count_pp` = '0' WHERE `time_pp` < '$time' and `id`='$ku[id]' LIMIT 1");
$ku=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$ku[id]'"));
mysql_query("UPDATE `kolhoz_user` SET `money` = '".round($ku['money'])."',`rating` = '".round($ku['rating'])."',`rubies` = '".round($ku['rubies'])."', `date_last` = '".time()."' WHERE `id` = '$ku[id]' LIMIT 1");

if(isset($_GET['user']) || isset($_GET['dostig']))include_once 'inc/dostig2.php';

$a=number_format(microtime(1)-$t,3);
$y = explode('.', $a);
echo '<div style="color:#555555;"><span> '.intval($y[1]).' ms.</span></div>';
}else{
echo "</div><div class='block event'>";
$online=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `date_last` > '".(time()-600)."'"), 0);
if($online==0){$online=1;}
echo "Онлайн <span class='title'>$online</span>, регистраций
<span class='title'>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user`"), 0)."</span></div>";
echo "</div>";
if($_SERVER['HTTP_HOST']!=='vk.vferme.com'){echo "<div></div><div style='text-align:center;' class='ptm'>Добавь в закладки ";
echo "<a href='http://$_SERVER[HTTP_HOST]' class='epic'><span>$_SERVER[HTTP_HOST]</span></a><br/>";}else{echo"<div style='text-align:center;' class='ptm'>";}
if($_SERVER['HTTP_HOST']!=='vk.vferme.com'){
echo'<script type="text/javascript" src="http://mobtop.ru/c/47507.js"></script><noscript><a href="http://mobtop.ru/in/47507"><img src="http://mobtop.ru/47507.gif" alt="MobTop"/></a></noscript> ';
//Рабочие счетчики
echo'<a href="http://waplog.net/c.shtml?498012"><img src="http://c.waplog.net/498011.cnt" alt="waplog" /></a>';
echo'<img src="http://wbn.su/1114.gif" alt="wbn" /><br/>';
}
$a=number_format(microtime(1)-$t,3);
$y = explode('.', $a);
echo '<div style="color:#555555;"><span> '.intval($y[1]).' ms.</span></div>';
echo "</div>";}


echo'</body></html>';
unset($ku,$conf);
exit;
ob_end_flush();
?>