<?
if(isset($_GET['mygarden']) && isset($_GET['harv']) && intval($_GET['harv'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_sad` WHERE `id` = '".intval($_GET['harv'])."' AND `id_user` = '$ku[id]' AND `id_tree` != '0'"),0)!=0)
{
$sad=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_sad` WHERE `id` = '".intval($_GET['harv'])."' AND `id_user` = '$ku[id]' AND `id_tree` != '0'"));
$tree=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_tree` WHERE `id` = '$sad[id_tree]'"));
if($sad['time_sbor']<=$time && $sad['id_tree']!=0 && $sad['time']>$time)
{
$nt=7200;
$rat=10;
$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;

$count=$tree['count'];
$count_harvester_act=0;
$count_yastreb_act=0;
$count_greenhouse_act=0;
$count=$count_harvester_act+$count_yastreb_act+$count+$count_greenhouse_act;
$count=floor($count);
if($gos['id_plant']==$plant['id'] && $gos['type']=='harvest' && isset($mc))$count=$count*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))
if($pw=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_market` WHERE `id_user` = '$ku[id]' AND `id_tree` = '$tree[id]' AND `arena` = '0'")))
{
mysql_query("UPDATE `kolhoz_market` SET `count` = '".($pw['count']+$count)."' WHERE `id` = '$pw[id]'");
$nt=$nt-($irregate_act_mnp*30);
$ntt=$ntt+($irregate_act_m*60);
}
else mysql_query("INSERT INTO `kolhoz_market` SET `id_tree` = '$tree[id]', `id_user`  = '$ku[id]', `count` = '$count', `arena` = '0'");
mysql_query("UPDATE `kolhoz_market` SET `count` = '".($pw['count']+$count)."' WHERE `id` = '$pw[id]'");
mysql_query("UPDATE `kolhoz_sad` SET `time_sbor` = '".($time+$nt)."', `time` = '".($sad['time']-$ntt)."' WHERE `id` = '".intval($_GET['harv'])."' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
$_SESSION['rating']=$rat;
$_SESSION['harvest']=$count;
update_mc($rat);
header("Location:?mygarden&".passgen());
}
else header("Location:?mygarden&".passgen());
exit;
}
?>