<?
Error_Reporting (0);
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($ku['verxmoney']==0){
echo "<TABLE WIDTH='100%'><TR>
<TD><center><div class='img_obj' style='background:url(style/pesok2.gif);'><img width='16' height='16' src='images/icons/money.png' alt='o'> <font color='#000000'> $ku[money] </font></div></center></TD>
<TD><center><div class='img_obj' style='background:url(style/pesok2.gif);'><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <font color='#000000'> $ku[rubies]</font></div></center></TD>
<TD><center><a href='?payment'> <div class='img_obj' style='background:url(style/pesok2.gif);'><img width='34'  src='img/5.png' alt='o'></div></a></center>
</TR></TABLE>";
}

if($ku['verxgr']==0){
echo "<TABLE WIDTH='100%'><TR>
</TR></TABLE><div class='img_obj' style='background:url(style/pesok2.gif);'> <div style='text-align:right;'><font color='#000000'>Время: ".vremja($time)." </font></div></div
</TR></TABLE>";
}


if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0)
{
echo "<div class='img_obj' style='background:url(style/pesok2.gif);'><font color='#000000'>Новая почта <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></font>";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0)
{
echo "<div class='feedback'><img width='16' height='16' src='images/icons/gift_plus.png' alt='o'/> <a href='?presents=$ku[id]'>Вам подарок</a><br></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>";
}
}
if($ku['arena2']<$ku['arena2max'] && $ku['arena2time']<=$time)
{
mysql_query("UPDATE kolhoz_user SET arena2time = '".($time+300)."' WHERE id = '$ku[id]'");
mysql_query("UPDATE kolhoz_user SET arena2 = '".($ku['arena2']+10)."' WHERE id = '$ku[id]'");
}

?>