<?

echo "<div class='event'><h1>Город</h1></div>";
echo "<div class='content'>";
echo "<div class='block'>";

$khus=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"));
$khinfo=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective` WHERE `id` = '$khus[id_collective]'"));

$price=10;
if(isset($_GET['kolhoz'])){
if($ku['zkl'] < $price){
$_SESSION['no_zkl']=$price-$ku['zkl'];
header("Location:?center");
}

if(isset($mc))
{
echo "<div class='block'>";
if(isset($_POST['titleText']) && strlen2($_POST['titleText'])<=140)
{
mysql_query("UPDATE `kolhoz_topclan` SET `message` = '".my_esc($_POST['titleText'])."', `id_user` = '$ku[id]', `name` = '$khinfo[name]', `id_clan` = '$khinfo[id]', `name_user` = '$ku[nick]'");
mysql_query("UPDATE `kolhoz_user` SET `zkl` = `zkl` - '".$price."' WHERE id='".$ku['id']."'");
header("Location:?center");
}
else echo "<img src='img/icons/right.png' width='16' height='16' alt='o'> Цена: $price <img src='img/icons/zkl.png' width='16' height='16' alt='o'><br>
<form method='post'><div><label for='titleText'>Текст приветствия: (140 сим.)</label></div>\n
<div><textarea id='titleText' class='wide' rows='2' name='titleText'></textarea></div>\n
<input type='submit' value='Сохранить'>\n
</form>\n";
echo '</div>';
}else{
err_game ('Вы не состоите в колхозе.');
}
include_once 'inc/foot.php';
}

//===============

$chas=date("H",time()); if($chas>24){$chas=round($chas-24);} if($chas<0){$chas=round($chas+24);} if($chas<=4 || $chas>=23){echo 'Доброй ночи <b><span>'.nc($ku['id']).'</span></b></span> ';} if($chas>=5 && $chas<=10){echo 'Доброе утро <b><span>'.nc($ku['id']).'</span></b></span> ';} if($chas>=11 && $chas<=17){echo 'Удачного дня <b><span>'.nc($ku['id']).'</span></b></span> ';} if($chas>=18 && $chas<=22){echo 'Приятного вечера <b><span>'.nc($ku['id']).'</span></b></span> ';}
echo " ".med($ku['id'])."";
//include_once 'novij_god.php';//Новый год
include_once 'novij_god.php';

echo "<img src='img/logozima2.png' alt='o'>";

echo "</div>";

//=============
if(isset($_GET['mod'])){
echo "<span class='small'>
<img src='img/icons/right.png' width='16' height='16' alt='o'> Любой игрок состоящий в колхозе может сделать свой колхоз передовым.<br>
<img src='img/icons/right.png' width='16' height='16' alt='o'> Цена: $price <img src='img/icons/zkl.png' width='16' height='16' alt='o'><br>
<img src='img/icons/right.png' width='16' height='16' alt='o'> Ваш колхоз будет передовым до тех пор пока кто-то не перекупит место для своего кх.</span>";
echo "".(isset($_GET['mod'])?"<div class='xr'></div><img width='16' height='16' src='img/icons/left.png'/> <a href='?center'>Назад</a><br/>":"<img width='16' height='16' src='/images/icons/rules.png'/> <a href='?center&mod'>Подробнее...</a><br/>")."";

include_once 'inc/foot.php';
}
//=============ЛИДЕР СНИЖИНОК
$q=mysql_query("SELECT * FROM `kolhoz_user` ORDER BY `turnir` DESC, `rating` DESC LIMIT 1");
while($post=mysql_fetch_array($q))
{echo "<div class='block'><div class='event'>Лидер поцелуев: ".on_k($post['id'])." <a href='?user=$post[id]'><span>".nc($post['id'])."</span></a>";
echo " ".med($post['id'])."";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '$post[id]' AND `date_last` > '".(time()-600)."' LIMIT 1"),0)==1)
echo " <img src='img/icons/online.gif' alt='' class='*'/>";
echo "</div></div>";
}
//=========================ЛИДЕРЫ
include_once 'leaders/bestank.php';
//=========================КОЛХОЗ
echo "<div class='block'>";
$topclan = mysql_query("SELECT * FROM `kolhoz_topclan` ORDER BY `id_user` DESC LIMIT 1") or die(mysql_error());
$topclan_row = mysql_fetch_array($topclan);
echo "<div class='event'><font color='violet'><b>Передовой колхоз:</b></font> [<a href='?center&mod'>Инфо</a>]<br/>";
echo "<img src='img/icons/guild.png' width='16' height='16' alt='o'> <span class='title'>Колхоз:</span> <a href='?collective=".intval($topclan_row['id_clan'])."'><b>".hsc($topclan_row['name'])."</b></a><br/>";
$ban = mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_ban` WHERE `id_user` = '$topclan_row[id_user]' AND (`time` > '$time' OR `izg` = '1') ORDER BY `id` DESC LIMIT 1"));
$us_ban = mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_user` WHERE `id` = '$ban[id_who]'"));

if($ban['id']){
echo "".($ban['izg']==1?'<font color="tomato">Сообщение заблокировано</font>':"<font color='tomato'>Сообщение заблокировано до:</font> <b>".vremja($ban['time']))."</b><br/>";
}
else

if($topclan_row['id_user']){

//====
echo "<img src='img/icons/chat.png' width='16' height='16' alt='o'> <span class='title'>Сообщение:</span> ".output_text($topclan_row['message']!=''?"".hsc($topclan_row['message'], $topclan_row['id_user'])."":"Приветствие отсутствует")."<br/>";
}


$profi=mysql_query("SELECT * FROM `kolhoz_user` WHERE id = '".$topclan_row['id_user']."'") or die(mysql_error());
$prof = mysql_fetch_array($profi);
if ($prof['pol']==1){echo "<img src='img/icons/on.png' width='16' height='16' alt='o'> <span class='title'>Добавил:</span> ";}
if ($prof['pol']==0){echo "<img src='img/icons/ona.png' width='16' height='16' alt='o'> <span class='title'>Добавила:</span> ";}

echo " ".on_k($topclan_row['id_user'])."";
echo "<a href='/?user=".$topclan_row['id_user']."'>".nc($topclan_row['id_user'])."</a> ";
echo "".med($topclan_row['id_user'])."";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '$topclan_row[id_user]' AND `date_last` > '".(time()-600)."' LIMIT 1"),0)==1)
echo " <img src='img/icons/online.gif' alt='' class='*'/>";
echo "<br/>[<a href='?center&kolhoz'>Перекупить место</a>]</div></div>";

//=====================
echo "<div class='block'>";
//echo "<div class='block'><a href='?elka'><img width='16' height='16' src='elka.gif' alt='o'> Наша Елка</div></a>";
echo "<div class='block'><a href='?smska'><img width='16' height='16' src='img/icons/mob.png' alt='o'> Отправка смс сообщений</div></a>";

echo "<a href='?payment'><div class='block'><img width='16' height='16' src='img/icons/ruby.png'> Акции и покупки</div></a>";
echo "<a href='?shop'><div class='block'><img width='16' height='16' src='img/icons/cart.png' alt='o'> Магазин</div></a>";
echo "<a href='?euro_bank'><div class='block'><img width='16' height='16' src='img/euro.png' alt='o'> Хранилище евро</div></a>";
echo "<a href='?converter'><div class='block'><img width='16' height='16' src='img/icons/converter.png' alt='o'> Обменник 2o14 <font color='#FF69B4'>news!</font></div></a>";
echo "<a href='?obmens'><div class='block'><img src='/img/icons/baks.png'> Купить баксов</div></a>";
//echo "<a href='?mywork'><div class='block'><img width='16' height='16' src='img/icons/dig.png' > Работа</div></a>";
echo "<a href='?lottery'><div class='block'><img width='16' height='16' src='/img/trophy.png'> Лотерея</a> (В разработке)</div></a>";
echo "<a href='?zags'><div class='block'><img width='16' height='16' src='/img/zags.png'> ЗАГС</div></a>";
echo "<a href='?col_nik'><div class='block'><img width='16' height='16' src='img/icons/rainbow.png'> Купить цвет нику <font color='#FF69B4'>news!</font></div></a>";
echo "<a href='?turnir'><div class='block'><img width='16' height='16' src='img/snewka.png'> Турнир поцелуев</div></a>";

if ($ku['status']>0){echo "<a href='?ban_list'><div class='block'><img width='16' height='16' src='img/icons/rules.png' alt='o'> Доска позора</div></a>";}
echo "<a href='?safe'><div class='block'><img width='16' height='16' src='safe/img/safe_off.png' alt='o'> Хранилище "; if($ku[safe]==20){echo "<img src='safe/img/safe_ur-1.png' alt='o'><font color='violet'>20%</font>";}if($ku[safe]==40){echo "<img src='safe/img/safe_ur-2.png' alt='o'><font color='violet'>40%</font>";}if($ku[safe]==60){echo "<img src='safe/img/safe_ur-3.png' alt='o'><font color='violet'>60%</font>";}if($ku[safe]==80){echo "<img src='safe/img/safe_ur-4.png' alt='o'><font color='violet'>80%</font>";}if($ku[safe]==100){echo "<img src='safe/img/safe_ur-5.png' alt='o'><font color='violet'>100%</font>";}echo " BETA</div></a>";
$lid=mysql_result(mysql_query("SELECT COUNT(*) FROM `leaders` WHERE `id` >= '1'"),0);
echo "<a href='/?glav'><div class='block'><img width='16' height='16' src='img/icons/lideri.gif'> Лидеры дня <span class='title'>(<span>$lid</span>)</span></div></a>";

echo "<br/>";

echo "<a href='?online'><div class='block'><img width='16' height='16' src='img/icons/online.png' alt='o'> Онлайн <span class='title'>(<span>".mysql_result(mysql_querll("SELECT COUNT(`id`) FROM `kolhoz_user` WHERE `date_last` > '".(time()-600)."'"), 0)."</span>)</span></div></a>";
echo "<a href='?collectives'><div class='block'><img width='16' height='16' src='img/icons/guild.png' alt='o'> Колхозы <span class='title'>(<span>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective`"), 0)."</span>)</span></div></a>";
echo "<a href='?rating'><div class='block'><img width='16' height='16' src='img/icons/rating.png' alt='o'> Фермеры <span class='title'>(<span>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user`"), 0)."</span>)</span></div></a>";
echo "<a href='?admin_list'><div class='block'><img width='16' height='16' src='img/admins.png' alt='o'> Администрация <span class='title'>(<span>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `status` > '0'"), 0)."</span>)</span></div></a>";


echo "<a href='?search'><div class='block'><img width='16' height='16' src='img/icons/search.png' alt='o'> Поиск игроков</div></a>";
echo "<a href='?search_collective'><div class='block'><img width='16' height='16' src='img/icons/search.png' alt='o'> Поиск колхозов</div></a>";
echo "<br/></div>";
include_once 'inc/foot.php';
?>