<?
if(isset($_GET['mycellar']) && isset($_GET['sell_all']) && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_recipes` != '0'"),0)!=0)
{
$q=mysql_querll("SELECT * FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_recipes` != '0'");
$ohv=0;
while($post=mysql_fetch_array($q))
{
$recipes=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_recipes` WHERE `id` = '$post[id_recipes]'"));
if($recipes['id']==$gos['id_recipes'] && $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_querll("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_kulinary_act=0;
$rat_school_act=0;
$rat_lib_act=0;
if(isset($sc_act))$rat_sc_act=$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_kulinary_act+$rat_school_act+$rat_lib_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
$orat=$rat+$orat;
$count=$recipes['count'];
$count=$count_harvester2_act+$count_yastreb2_act+$count+$count_greenhouse_act;
$money=($ohv*$recipes['money']);
mysql_querll("UPDATE `kolhoz_polka` SET `id_recipes` = '0', `soil` = '0', `clean` = '0' WHERE `id` = '".intval($_GET['sell_all'])."' LIMIT 1");
{
}
mysql_querll("UPDATE `kolhoz_polka` SET `id_recipes` = '0', `soil` = '0', `clean` = '0' WHERE `id` = '$post[id]' LIMIT 1");
$ohv=$ohv+$count;
}
$_SESSION['km']=$ohv;
$_SESSION['mon']=$money;
$_SESSION['rating']=$orat;
mysql_querll("UPDATE `kolhoz_user` SET `cook_mas` = '".($ku['cook_mas']+$ohv)."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$money)."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_polka` SET `id_recipes` = '0', `soil` = '0', `clean` = '0' WHERE `id` = '".intval($_GET['sell_all'])."' LIMIT 1");
header("Location:?mycellar&".passgen());
exit;
}
?>