<?

if(isset($_GET['mypool']) && isset($_GET['soil']) && intval($_GET['soil'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id` = '".intval($_GET['soil'])."' AND `id_user` = '$ku[id]' AND (`time_soil` = '$time' OR `time_soil` < '$time' )"),0)!=0)
{
$ground=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pool` WHERE `id` = '".intval($_GET['soil'])."' AND `id_user` = '$ku[id]'"));

$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pool_plant` WHERE `id` = '".intval($ground['id_fish'])."'"));
if($ku['fishfooder']>0)$proc=$ku['fishfooder']*10;	else $proc=0;

$rat=$plant['soil_rating'];
$rat_sc_act=0;
$rat_dog_act=0;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_lib_act=0;
$arena_rat=0;
$rat_fishfooder_act=0;

if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($dog_type))$rat_dog_act=(($rat/100)*$dog_type);
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
if($ku['arena_rating']>1000){$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/20));}
if($proc>0)$rat_fishfooder_act=($rat/100)*$proc;
$ratt=$rat+$rat_drakon_act+$rat_school_act+$rat_lib_act+$rat_sc_act+$rat_fishfooder_act+$rat_dog_act+$arena_rat;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp) AND !isset($dexp3))$rat=$rat*2; elseif(isset($dexp3))$rat=$rat*3;

mysql_query("UPDATE `kolhoz_pool` SET `time_soil` = '".($plant['time_soil']*$incubator_timesoil_act+$time)."', `time` = '".($ground['time']-$plant['time_soil_minus'])."' WHERE `id` = '".intval($_GET['soil'])."' LIMIT 1")or die (mysql_error());
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
$_SESSION['rating']=$rat;
update_mc($rat);
header("Location:/mypool/".passgen());
exit;
}
?>