<?

if(isset($_GET['mypool']) && isset($_GET['sell']) && intval($_GET['sell'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id` = '".intval($_GET['sell'])."' AND `id_user` = '$ku[id]' AND (`time` = '$time' OR `time` < '$time' )"),0)!=0)
{
$ground=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pool` WHERE `id` = '".intval($_GET['sell'])."' AND `id_user` = '$ku[id]'"));

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

$rat=$plant['rating'];

$rat_autocrane_act=0;
if($proc>0)$rat_autocrane_act=($rat/100)*$proc;
if($ku['labspices']>=1)$labspices=($rat/100)*($ku['labspices']*10); 
if($ku['talent_5']>=1)$talent_51=($rat/100)*($ku['talent_5']*15); 

$rat=double_exp(base_exp($rat)+$talent_51+$rat_autocrane_act+$labspices);
if($ku['money2x_time']>=$time)$money2x=($plant['dohod']/100)*100; 
if($ku['labsweets']>=1)$labsweets=($plant['dohod']/100)*($ku['labsweets']*10); 
if($ku['talent_5']>=1)$talent_5=($plant['dohod']/100)*($ku['talent_5']*15); 

$dohod=floor($talent_5+$labsweets+$money2x+$plant['dohod']+(($plant['dohod']/100)*$proc));
mysql_query("UPDATE `kolhoz_pool` SET `time_soil` = '0', `time` = '0',`id_fish`='0' WHERE `id` = '".intval($_GET['sell'])."' LIMIT 1")or die (mysql_error());
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."',`money`='".($ku['money']+$dohod)."',`umoney`='$dohod' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_setting` SET `pool_fish_count` = '".($conf['pool_fish_count']+1)."' WHERE `id_user` = '$ku[id]'");
if(isset($mc) && $mc['nalog']>0)
{
$cm = $dohod;
$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']=$rat;
update_mc($rat);
header("Location:/mypool/".passgen());
exit;
}
?>