<?

if(isset($_GET['mypool']) && isset($_GET['sell_all']) && $ku['autocrane']>0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND `id_fish`>'0' AND (`time` = '$time' OR `time` < '$time' )"),0)!=0)
{

$q = mysql_query("SELECT * FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND `id_fish`>'0' AND (`time` = '$time' OR `time` < '$time' )");
$orat=0;
$odohod=0;
$c_fish=0;
While($ground=mysql_fetch_array($q))
{

$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pool_plant` WHERE `id` = '$ground[id_fish]'"));
if($ku['autocrane']>0)$proc=$ku['autocrane']*10;	else $proc=0;

$rat=$plant['rating'];
$rat_sc_act=0;
$rat_dog_act=0;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_lib_act=0;
$arena_rat=0;
$rat_autocrane_act=0;

if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($dog_type))$rat_dog_act=(($rat/100)*$dog_type);
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($ku['arena_rating']>1000){$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/20));}
if($proc>0)$rat_autocrane_act=($rat/100)*$proc;

$ratt=$rat+$rat_drakon_act+$rat_school_act+$rat_lib_act+$rat_sc_act+$rat_autocrane_act+$rat_dog_act+$arena_rat;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp) AND !isset($dexp3))$rat=$rat*2; elseif(isset($dexp3))$rat=$rat*3;

$dohod=floor($plant['dohod']+(($plant['dohod']/100)*$proc));
$odohod=$odohod+$dohod;
$orat=$orat+$rat;
$c_fish++;
mysql_query("UPDATE `kolhoz_pool` SET `time_soil` = '0', `time` = '0',`id_fish`='0' WHERE `id` = '$ground[id]' LIMIT 1")or die (mysql_error());
}
mysql_query("UPDATE `kolhoz_setting` SET `pool_fish_count` = '".($conf['pool_fish_count']+$c_fish)."' WHERE `id_user` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."',`money`='".($ku['money']+$odohod)."',`umoney`='$odohod' WHERE `id` = '$ku[id]'");
if(isset($mc) && $mc['nalog']>0)
{
$cm = $odohod;
$nmoney=floor(($cm/100)*$mc['nalog']);
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$cm-$nmoney)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_collective_user` SET `money` = '".($mcu['money']+$nmoney)."' WHERE `id_user` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_collective` SET `money` = '".($mc['money']+$nmoney)."' WHERE `id` = '$mc[id]'");
}
$_SESSION['rating']=$orat;
update_mc($orat);
header("Location:/mypool/".passgen());
exit;
}


?>