<?
if($ku['garden_time']<=$time){
mysql_query("UPDATE `kolhoz_user` SET `gardener` = '',`garden_time`='' WHERE `id` = '$ku[id]' LIMIT 1");}else{
if($ku['gardener']==1)$water=1;$name='Молчан';
if($ku['gardener']==2){$water=1;$name='Казимир';$harvest=1;$cultivate=1;$seat=1;}
if($ku['gardener']==3){$water=1;$name='Ярило';
$harvest=1;
$cultivate=1;
$seat=1;
$soil=1;
}
if(isset($water) AND mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` 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){

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` != '0' AND  `time_water` < '".time()."' AND `time` > '".time()."' AND (`soil` = '0' AND `time_soil` > '".time()."' OR `soil` = '1')LIMIT 1"),0)!=0)
{
$nt=1800;
$rat=5;
$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($mc_hp_act))$rat_mc_hp_act=(($rat/100)*$mc_hp_ps);
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($irregate_act))$rat_irregate_act=(($rat/100)*$irregate_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_act=$rat_irregate_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_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);
$ntt=$ntt+($irregate_act_m*60);
}


$orat=0;
$q=mysql_query("SELECT * FROM `kolhoz_ground` 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))
{
$vc=$vc+1;
mysql_query("UPDATE `kolhoz_ground` 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:?myfarm&".passgen());
//exit;
}

echo"<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>
<img width=\"16\" height=\"16\" src=\"images/icons/gardener".$ku[gardener].".png\" alt=\"\"> Садовник ".$name." полил грядки
</span></li></ul></div>";}
}
?>
