<?

if(isset($_GET['mypool']) && isset($_GET['soil_all']) && $ku['fishfooder']>0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND (`time_soil` = '$time' OR `time_soil` < '$time' ) AND `time`>'$time'"),0)!=0)
{
if($ku['fishfooder']>0)$proc=$ku['fishfooder']*10;	else $proc=0;
$q = mysql_query("SELECT * FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND (`time_soil` = '$time' OR `time_soil` < '$time' ) AND `time`>'$time'");
$orat=0;
While($ground=mysql_fetch_array($q))
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pool_plant` WHERE `id` = '".intval($ground['id_fish'])."'"));

$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($proc>0)$rat_fishfooder_act=($rat/100)*$proc;
if($ku['arena_rating']>1000){$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/20));}

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