<?
if(isset($_GET['ozero']) && isset($_GET['soil']) && intval($_GET['soil'])!=NULL && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id` = '".intval($_GET['soil'])."' AND `id_user` = '$ku[id]'"),0)!=0)
{
echo '<div class="event"><h1>Подкормка</h1></div>';
echo "<div class='content'>";
echo "<div class='block'>";
$ground=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_pond` WHERE `id` = '".intval($_GET['soil'])."' AND `id_user` = '$ku[id]'"));
$plant=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_fish` WHERE `id` = '$ground[id_plant]'"));
if($ground['soil']==0 && $ground['time_soil']<=$time && $ground['id_plant']!=0 && $ground['time']>$time)
{
if(isset($_GET['select']) && intval($_GET['select'])!=NULL && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_korm` WHERE `id` = '".intval($_GET['select'])."' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
{
$soil=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_korm` WHERE `id` = '".intval($_GET['select'])."'"));
if($ku['money']>=$soil['cena'])
{
$rat=$soil['rating'];
$rat_sc_act=0;
$rat_hp_act=0;
$rat_mc_hp_act=0;
$rat_drakon_act=0;
$rat_soiler_act=0;
$rat_school_act=0;
$rat_lib_act=0;

if(isset($catchfish_act))$rat_catchfisher_act=(($rat/100)*$catchfish_act);

$ratt=$rat_drakon_act+$rat_catchfisher_act+$rat_school_act+$rat;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;

$st=$soil['time'];
$st_hp_act=0;
$st_mc_hp_act=0;
$st_soiler_act=0;
if(isset($catckorm_act))$st_catckorm_act=($ground[time]/100)*$catckorm_act;

$st=$st+$st_catckorm_act;
mysql_querll("UPDATE `kolhoz_pond` SET `time` = '".($ground['time']-$st)."', `soil` = '1' WHERE `id` = '$ground[id]' LIMIT 1");
mysql_querll("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$soil['cena'])."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_user` SET `last_korm` = '$soil[id]' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_user` SET `agronom` = '".($ku['agronom']+1)."' WHERE `id` = '$ku[id]'");
$_SESSION['rating']=$rat;
update_mc($rat);
}
else
{
$nm=$soil['cena']-$ku['money'];
$_SESSION['no_money']=$nm;
}
header("Location:?ozero&".passgen());
exit;
}/*
echo "<div><img width='48' height='48' src='img/fish/$plant[id].png' alt='o' class='portrait'><div class='title'>".hsc($plant['name'])."</div><div class='small minor'>(Урожай через <span>".time_left($ground['time']-$time)."</span>)</div><div style='clear:both'></div></div>';*/

echo"<h3>Выбери корм</h3>";
$q=mysql_querll("SELECT * FROM `kolhoz_korm`");
echo "<ul>";
while($post=mysql_fetch_array($q))
{
echo "<li style='padding-bottom:8px'>";
echo "<img width='48' height='48' src='img/soils/korm$post[id].png' alt='o' class='portrait'><div>".($ku['level']>=$post['level']?"<a href='?ozero&soil=$ground[id]&select=$post[id]'>":null)."<span>".hsc($post['name'])."</span>".($ku['level']>=$post['level']?"</a>":null)."<span class='minor'>, ".($ku['level']>=$post['level']?"цена: </span><span><img width='16' height='16' src='img/icons/money.png' alt='o'><span class='title'>$post[cena]</span></span>":"доступно с $post[level] уровня</span>")."</div><div class='minor small'>Ускоряет рост на <span class='title'>".time_left($post['time'])."</span>,опыт: <img width='16' height='16' src='img/icons/experience.png' alt='o'> <span class='title'>$post[rating]</span></div><div style='clear:both'></div></li>";
}
echo "</ul></div>";
include_once 'inc/foot.php';
}
}
?>