<?
if(isset($_SESSION['harvest']))
{
harvest($_SESSION['harvest']);
unset($_SESSION['harvest']);
}
if(isset($_SESSION['rating']))
{
ratingg($_SESSION['rating']);
unset($_SESSION['rating']);
}
if(isset($_SESSION['mon']))
{
mon($_SESSION['mon']);
unset($_SESSION['mon']);
}
if(isset($_SESSION['km']))
{
km($_SESSION['km']);
unset($_SESSION['km']);
}
if($ku['umoney']!=0)
{
money($ku['umoney']);
}

if(isset($_SESSION['no_rubies']))
{
no_rubies($_SESSION['no_rubies']);
unset($_SESSION['no_rubies']);
}
if(isset($_SESSION['no_money']))
{
no_money($_SESSION['no_money']);
unset($_SESSION['no_money']);
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0)
{
echo "<div class='feedback'><div><img width='16' height='16' src='images/icons/mail_new.png' alt='o'>Новая почта <span class='title'>(<span>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)."</span>)</span><br><a href='?mail&new'>Читать</a><br></div></div>";
}


if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_tikets` WHERE `read` = '0'"),0)!=0)
{
echo "".($ku['status']==1?"<div class='feedback'><div><img width='16' height='16' src='images/icons/mail_new.png' alt='o'>Новый тикет <span class='title'>(<span>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_tikets` WHERE `read` = '0'"),0)."</span>)</span><br><a href='?tikets'>Читать</a><br></div></div>":null)."";
}

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_jalob` WHERE `read` = '0'"),0)!=0)
{
echo "".($ku['status']>0?"<div class='feedback'><div><img width='16' height='16' src='images/icons/mail_new.png' alt='o'>Новая Жалоба <span class='title'>(<span>".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_jalob` WHERE `read` = '0'"),0)."</span>)</span><br><a href='?jalob'>Читать</a><br></div></div>":null)."";
}

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0)
{
echo "<div class='feedback'><div>У вас новый подарок<br><a href='?presents=$ku[id]'>Смотреть</a><br></div></div>";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_invite` WHERE `id_user` = '$ku[id]'"),0)!=0)
{
$invite=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_invite` WHERE `id_user` = '$ku[id]'"));
$cti=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective` WHERE `id` = '$invite[id_collective]'"));
$who=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$invite[id_who]'"));
if(isset($_GET['invite_collective']) && $_GET['invite_collective']=='yes')
{
mysql_query("DELETE FROM `kolhoz_collective_invite` WHERE `id` = '$invite[id]'");
mysql_query("INSERT INTO `kolhoz_collective_user` SET `id_user` = '$ku[id]', `id_collective` = '$cti[id]', `time` = '$time', `status` = '7'");
mysql_query("INSERT INTO `kolhoz_collective_history` SET `id_user` = '$ku[id]', `id_who` = '$who[id]', `id_collective` = '$cti[id]', `time` = '$time', `type` = 'in', `dei` = 'who'");
header("Location:?collective=$cti[id]");
}
elseif(isset($_GET['invite_collective']) && $_GET['invite_collective']=='no')
{
mysql_query("DELETE FROM `kolhoz_collective_invite` WHERE `id` = '$invite[id]'");
}
else
{
echo "<div class='feedback'><div><span>";
echo on_k($who['id']);
echo " <a class='' href='?user=$who[id]'>".nc($who['id'])."</a></span> приглашает Вас в свой колхоз <a href='?collective=$cti[id]'><span>".hsc($cti['name'])."</span></a><br/>";
echo "<img width='16' height='16' src='images/icons/tick.png' alt='o'> <a href='?myfarm&invite_collective=yes'>Принять приглашение</a><br/>";
echo "<img width='16' height='16' src='images/icons/delete.png' alt='o'> <a href='?myfarm&invite_collective=no'>Отказаться</a>";
echo "</div>\n
</div>";
}
}



if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_zags` WHERE `she` = '$ku[nick]' and `she_yes` = '0'"),0)!=0)
{
$c=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_zags` WHERE `she`='".$ku['nick']."'"));
$who=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `nick` = '$c[he]'"));
if(isset($_GET['brak']) && $_GET['brak']=='yes')
{
mysql_query("UPDATE `kolhoz_user` SET `brak`='$c[she]' WHERE `nick`='".$c['he']."'");
mysql_query("UPDATE `kolhoz_user` SET `brak`='$c[he]' WHERE `nick`='".$c['she']."'");
mysql_query("INSERT INTO `kolhoz_mail` SET `id_user` = '$who[id]', `id_kont` = '0', `msg` = 'Поздравляем! Вы связали себя брачными узами ".($c['she']).".', `time` = '$time', `type` = 'to'");
mysql_query("UPDATE `kolhoz_zags` SET `she_yes`='1', `who`='1' WHERE `she`='".$ku['nick']."'");
echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>Поздравляем! Вы связали себя брачными узами с ".nc($who['id']).".</span></li></ul></div>";
}
elseif(isset($_GET['brak']) && $_GET['brak']=='no')
{
mysql_query("DELETE FROM `kolhoz_zags` WHERE `she` = '$ku[nick]' AND `she_yes` = '0'");
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` + '80' WHERE `nick`='".$c['he']."'");
}
else
{

echo "<div class='feedback'><div><span>";
echo on_k($who['id']);
echo " <a class='' href='?user=$who[id]'>".nc($who['id'])."</a></span> предлагает вам заключить брак.<br>
<img width='16' height='16' src='/images/icons/tick.png' alt='o'> <a href='?myfarm&brak=yes'>Согласиться</a><br>
<img width='16' height='16' src='/images/icons/delete.png' alt='o'> <a href='?myfarm&brak=no'>Отказаться</a>
</div>
</div>";
}
}
?>