<?
if(isset($_GET['sh_myfarm']) && isset($_GET['sh_water']) && intval($_GET['sh_water'])!=NULL && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_sh` WHERE `id` = '".intval($_GET['sh_water'])."' AND `id_user` = '$ku[id]' AND (`soil` = '0' AND `time_soil` > '$time' OR `soil` = '1')"),0)!=0)
{
$ground=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_ground_sh` WHERE `id` = '".intval($_GET['sh_water'])."' AND `id_user` = '$ku[id]'"));
if($ground['time_water']<=$time && $ground['id_plant']!=0 && $ground['time']>$time)
{
$nt=1800;
$rat=5;

$rat_hp_act=0; //гидра
$rat_mc_hp_act=0; //ороситель
$rat_sc_act=0; //пугало
$rat_drakon_act=0; //дракон
$rat_irregate_sh_act=0; //оПроситель
$rat_school_act=0; //школа
$rat_lib_act=0;
if(isset($hp_act))$rat_hp_act=(($rat/100)*$hp_ps);
if(isset($mc_hp_act))$rat_mc_hp_act=(($rat/100)*$mc_hp_ps);
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($irregate_sh_act))$rat_irregate_sh_act=(($rat/100)*$irregate_sh_act);
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(isset($shmel_act))$rat_irregate_sh_act=$rat_irregate_sh_act*2;
if(isset($shmel_act))$rat_hp_act=$rat_hp_act*2;
$ratt=$rat_hp_act+$rat_sc_act+$rat_drakon_act+$rat_irregate_sh_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=900;

$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_sh_act))
{
$nt=$nt-($irregate_sh_act_mnp*60);
$ntt=$ntt+($irregate_sh_act_m*60);
}

mysql_querll("UPDATE `kolhoz_ground_sh` SET `time_water` = '".($time+$nt)."', `time` = '".($ground['time']-$ntt)."' WHERE `id` = '".intval($_GET['sh_water'])."' LIMIT 1");
mysql_querll("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
$_SESSION['rating']=$rat;
update_mc($rat);
header("Location:?sh_myfarm".$peremenn."&".passgen());
}
else header("Location:?sh_myfarm".$peremenn."&".passgen());
exit;
}
?>