<?
/*
ob_start(); 
$page_size = ob_get_length(); 
if(!isset($_SESSION['traf'])){ $_SESSION['traf'] = 0; } 
$_SESSION['traf'] += $page_size; 
*/

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_zkl'])){
no_zkl($_SESSION['no_zkl']);
unset($_SESSION['no_zkl']);
}

if(isset($_SESSION['no_money'])){
no_money($_SESSION['no_money']);
unset($_SESSION['no_money']);
}

$money_new = razdelen($ku['money']);
$rubies_new = razdelen($ku['rubies']);
$zkl_new = razdelen($ku['zkl']);
$euro_new = razdelen($ku['euro']);

if($ku['verh']==0)echo "<div class='event block'><font color='yellow'><p align='right'><img width='16' height='16' src='images/icons/money.png' alt='o'> <span>".$money_new."</span> <img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span>".$rubies_new."</span> <img width='16' height='16' src='images/icons/zkl.png' alt='o'> <span>".$zkl_new."</span> <img width='16' height='16' src='images/euro.png' alt='o'> <span>".$euro_new."</span></p></font></div>";


/*================================================//
if(isset($_GET['poluch_podarok'])){
if($ku['poluch_podarok']!=1){
if(mysql_querll("UPDATE `kolhoz_user` SET `rating`='".($ku['rating']+50000000000)."', `rubies`='".($ku['rubies']+10000000)."', `poluch_podarok`='1' WHERE `id`='".$ku['id']."'")){
msg_game('Подарок успешно принят!');
} else {err_game('Ошибка при принятии подарка.');}
} else {err_game('Подарок уже был принят!');}
}
if(($ku['poluch_podarok']!=1)&&(!isset($_GET['poluch_podarok']))){
echo "<div class='feedback'>"."\n";
echo "Так как сегодня наш онлайн перевалил за 300, все получат подарок!<br>"."\n";
echo "<img width='16' height='16' src='images/icons/experience.png'> 50'000'000'000 и <img width='16' height='16' src='images/icons/ruby.png'> 10'000'000 - <a href='?poluch_podarok'>Забрать</a>"."\n";
echo "</div>"."\n";
}
//================================================*/

// Сообщение о новом письме
$new_mes_sql = mysql_result(mysql_querll('SELECT COUNT(`id`) FROM `kolhoz_mail` WHERE `id_user`="'.$ku['id'].'" AND `read`="0"'), 0);
if($new_mes_sql>=1){echo '<div class="feedback">Новое письмо <span class="title">('.$new_mes_sql.')</span><br><a href="?mail&new">Читать</a></div>';}

// Сообщение о новом подарке
$new_prez_sql = mysql_result(mysql_querll('SELECT COUNT(`id`) FROM `kolhoz_gifts` WHERE `id_user`="'.$ku['id'].'" AND `read`="0"'), 0);
if($new_prez_sql>=1){echo '<div class="feedback">Не открытый подарок <span class="title">('.$new_prez_sql.')</span><br><a href="?presents='.$ku['id'].'">Открыть</a></div>';}

/*
if(mysql_result(mysql_querll("SELECT COUNT(`id`) FROM `kolhoz_mail` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0){
echo "<div class='feedback'><div>Новая почта <span class='title'>(<span>".mysql_result(mysql_querll("SELECT COUNT(`id`) 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_querll("SELECT COUNT(`id`) 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_querll("SELECT COUNT(`id`) FROM `kolhoz_collective_invite` WHERE `id_user` = '$ku[id]'"),0)!=0){
$invite = mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_collective_invite` WHERE `id_user` = '$ku[id]'"));
$cti = mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_collective` WHERE `id` = '$invite[id_collective]'"));
$who = mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_user` WHERE `id` = '$invite[id_who]'"));

if(isset($_GET['invite_collective']) && $_GET['invite_collective']=='yes'){
mysql_querll("DELETE FROM `kolhoz_collective_invite` WHERE `id` = '$invite[id]'");
mysql_querll("INSERT INTO `kolhoz_collective_user` SET `id_user` = '$ku[id]', `id_collective` = '$cti[id]', `time` = '$time', `status` = '7'");
mysql_querll("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_querll("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>";
}
}

$x = mysql_querll("SELECT * FROM `obyv`".($ku['status']==0?" WHERE `dostup` = '1'":null)." ORDER BY `id` DESC LIMIT 1");
while($row=mysql_fetch_assoc($x)){
if($ku['read_obyv']==0){
if(isset($_GET['read_obyv'])){
mysql_querll("UPDATE `kolhoz_user` SET `read_obyv` = '1' WHERE `id` = '$ku[id]'");
header("Location:?center");
}
echo '<div class="feedback"><div>'.($row['name']!=NULL?'<font color="red"><b>'.$row['name'].'...</b></font><br/>':null).'';
echo ''.output_text($row['opis'], $row['id_user']).'<br/>';
if($row['ssylka']!=NULL)echo "<a href='http://$row[ssylka]'>Подробнее →</a><br>";
if($row['dostup']==1)$dostup='Всем';else $dostup='Администрации';
if($ku['status']>0)echo "Кому: $dostup<br>";
echo "Объявил: ";
echo '<b>'.on_k($row['id_user']).' <a href="?user='.($row['id_user']).'">'.nc($row['id_user']).'</a></b><br/>';
echo "<img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='?read_obyv'>Скрыть</a></div></div>";
}
}

if(isset($_SESSION['msg'])){
msg_game($_SESSION['msg']);
unset($_SESSION['msg']);
}

if(isset($_SESSION['msg_ns'])){
echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>".$_SESSION['msg_ns']."</span></li></ul></div>";
unset($_SESSION['msg_ns']);
}

if($ku['arena2']<$ku['arena2max'] && $ku['arena2time']<=$time){
mysql_querll("UPDATE kolhoz_user SET arena2time = '".($time+300)."' WHERE id = '$ku[id]'");
mysql_querll("UPDATE kolhoz_user SET arena2 = '".($ku['arena2']+10)."' WHERE id = '$ku[id]'");
}
?>