<?
if(isset($_GET['ozero']) && isset($_GET['water_all']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND `id_plant` != '0' AND (`time_water` = '$time' OR `time_water` < '$time') AND `time` > '$time' AND (`soil` = '0' AND `time_soil` > '$time' OR `soil` = '1')"),0)!=0 && $ku['sponder']>0)
{
$nt=1800;
if($ku['level']>=1 and $ku['level']<=9)$rat=1;
else if($ku['level']>=10 and $ku['level']<=19)$rat=4;
else if($ku['level']>=20 and $ku['level']<=39)$rat=40;
else if($ku['level']>=40 and $ku['level']<=49)$rat=400;
else if($ku['level']>=50 and $ku['level']<=60)$rat=4000;
else if($ku['level']>=61 and $ku['level']<=70)$rat=40000;
else $rat=10;
$rat_hp_act=0; //гидра
$rat_sponder_act=0;
if(isset($hp_act))$rat_hp_act=(($rat/100)*$hp_ps);
if(isset($sponder_act))$rat_sponder_act=(($rat/100)*$sponder_act);
$rat=double_exp(base_exp($rat)+$rat_hp_act+$rat_sponder_act);

$ntt=15*60;
$ntt_hp_act=0;
$ntt_mc_hp_act=0;
if(isset($hp_act))$ntt_hp_act=(($ntt/100)*$hp_ps);
if(isset($mc_hp_act))$ntt_mc_hp_act=(($ntt/100)*$mc_hp_ps);
$ntt=$ntt_hp_act+$ntt_mc_hp_act;
if(isset($irregate_act))
{
$nt=$nt-($irregate_act_mnp*60);

}
$orat=0;
$q=mysql_query("SELECT * FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND `id_plant` != '0' AND (`time_water` = '$time' OR `time_water` < '$time') AND `time` > '$time' AND (`soil` = '0' AND `time_soil` > '$time' OR `soil` = '1')");
$vc=0;
while($post=mysql_fetch_array($q))
{
$spoun=0;
if(isset($spondwater_act))$spoun=(($post['time']-$time)/100)*$spondwater_act;
$ntt=$spoun;

$vc=$vc+1;
mysql_query("UPDATE `kolhoz_pond` SET `time_water` = '".($time+$nt)."', `time` = '".($post['time']-$ntt)."' WHERE `id` = '$post[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
$orat=$rat+$orat;
}
mysql_query("UPDATE `kolhoz_user` SET `vodoley` = '".($ku['vodoley']+$vc)."' WHERE `id` = '$ku[id]'");
$_SESSION['rating']=$orat;
update_mc($orat);
header("Location:/ozero/".passgen());
exit;
}
?>