Файл: inc/cellar/sell_all.php
Строк: 37
<?
include_once '../system/config.php';
if(isset($_GET['sell_all']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_recipes` != '0'"),0)!=0)
{
$ccl=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_recipes` != '0'"),0);
$q=mysql_query("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_query("SELECT * FROM `kolhoz_recipes` WHERE `id` = '$post[id_recipes]'"));
$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($mc['MedalRating']>0)$rat_medal=(($rat/100)*($mc['MedalRating']*0.5));
if(isset($kulinary_act))$rat_kulinary_act=($rat/100)*$kulinary_ps_r;
$ratt=$rat_drakon_act+$rat_medal+$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;
if(isset($exp3))$rat=$rat*3;
$money=$recipes['money'];
$cm=0;
$cm=$cm+floor($money*$ccl);
$orat=$rat+$orat;
$count=$recipes['count'];
$count=$count_harvester2_act+$count_yastreb2_act+$count+$count_greenhouse_act;
mysql_query("UPDATE `kolhoz_polka` SET `id_recipes` = '0', `soil` = '0', `clean` = '0' WHERE `id` = '$post[id]' LIMIT 1");
$ohv=$ohv+$count;
}
$_SESSION['rating']=$orat;
$_SESSION['mon']=$cm;
update_mc($orat);
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$cm)."' WHERE `id` = '$ku[id]'");
header("Location:/cellar");
exit;
}
?>