<?
if(isset($_GET['ozero']) && isset($_GET['water']) && intval($_GET['water'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id` = '".intval($_GET['water'])."' AND `id_user` = '$ku[id]' AND (`soil` = '0' AND `time_soil` > '$time' OR `soil` = '1')"),0)!=0)
{
$ground=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pond` WHERE `id` = '".intval($_GET['water'])."' AND `id_user` = '$ku[id]'"));
if($ground['time_water']<=$time && $ground['id_plant']!=0 && $ground['time']>$time)
{
$nt=1800;
if($ku['level']>=1 and $ku['level']<=9){$min=4;$max=6;}
if($ku['level']>=10 and $ku['level']<=19){$min=8;$max=10;}
if($ku['level']>=20 and $ku['level']<=39){$min=12;$max=25;}
if($ku['level']>=40 and $ku['level']<=50){$min=30;$max=35;}

$rat=rand($min,$max);
$rat_hp_act=0; //гидра
$rat_mc_hp_act=0; //ороситель
$rat_sc_act=0; //пугало
$rat_drakon_act=0; //дракон
$rat_irregate_act=0; //оПроситель
$rat_school_act=0; //школа
$rat_lib_act=0;
if(isset($hp_act))$rat_hp_act=(($rat/100)*$hp_ps);

if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($spondwater_act))$rat_act=
$ratt=$rat_hp_act+$rat_sc_act+$rat_act+$rat_irregate_act+$rat_mc_hp_act+$rat_school_act+$rat_lib_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;

$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);
if(isset($spondwater_act))$spoun=(($ground[time]-$time)/100)*$spondwater_act;
$ntt=$ntt+$spoun;
}
mysql_query("UPDATE `kolhoz_pond` SET `time_water` = '".($time+$nt)."', `time` = '".($ground['time']-$ntt)."' WHERE `id` = '".intval($_GET['water'])."' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
$_SESSION['rating']=$rat;
update_mc($rat);
header("Location:?ozero&".passgen());
}
else header("Location:?ozero&".passgen());
exit;
}
?>