<?
if(isset($_GET['mycellar']) && isset($_GET['sell']) && intval($_GET['sell'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka` WHERE `id` = '".intval($_GET['sell'])."' AND `id_user` = '$ku[id]' AND `id_recipes` != '0'"),0)!=0)
{
$polka=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_polka` WHERE `id` = '".intval($_GET['sell'])."' AND `id_user` = '$ku[id]' AND `id_recipes` != '0'"));
$recipes=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_recipes` WHERE `id` = '$polka[id_recipes]'"));
if($polka['time']<=$time)
{
if($recipes['id']==$gos['id_recipes'] && isset($mc))
{
$harv=(isset($harvester2_act)?$harvester2_act/100:0);
$hawk=(isset($yastreb2_act)?3:0);
$exp=$recipes['time_soil']+($recipes['time_soil']*$harv)+($recipes['time_soil']*$hawk);
if($gos['type']=='harvest2')$exp=$exp*2;
mysql_query("INSERT INTO `kolhoz_collective_rating_gos` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$exp', `time` = '$time'");
}
$rat=$recipes['rating'];
$rat_sc_act=0;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_kulinary_act=0;
$rat_lib_act=0;
$rat_vetruk=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($vetruk))$rat_vetruk=$rat+$rat*2;
if(isset($drakon_act))$rat_drakon_act=(($recipes['rating']/100)*300);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat*2;
if(isset($kulinary_act))$rat_kulinary_act=($rat/100)*$kulinary_ps_r;
$ratt=$rat_drakon_act+$rat_sc_act+$rat_vetruk+$rat_kulinary_act+$rat_school_act+$rat_lib_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
$count=$recipes['count'];
$count=$count_harvester2_act+$count_yastreb2_act+$count+$count_greenhouse_act;
$money=($count*$recipes['money']);
mysql_query("UPDATE `kolhoz_polka` SET `id_recipes` = '0', `soil` = '0', `clean` = '0' WHERE `id` = '".intval($_GET['sell'])."' LIMIT 1");
{
}
$_SESSION['km']=+1;
$_SESSION['mon']=$money;
$_SESSION['rating']=$rat;
mysql_query("UPDATE `kolhoz_user` SET `cook_mas` = '".($ku['cook_mas']+1)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$money)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_polka` SET `id_recipes` = '0', `soil` = '0', `clean` = '0' WHERE `id` = '".intval($_GET['sell'])."' LIMIT 1");
header("Location:?mycellar&".passgen());
}
else header("Location:?mycellar&".passgen());
exit;
}
?>