<?

if(isset($_GET['mypool']) && isset($_GET['incube']) && intval($_GET['incube'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id` = '".intval($_GET['incube'])."' AND `id_user` = '$ku[id]' AND `id_fish` = '0'"),0)!=0)
{
if(empty($ku['last_pool'])){header("Location:/mypool/change_fish");exit;}
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pool_plant` WHERE `id` = '".intval($ku['last_pool'])."'"));
$times=$plant['time']*$incubator_time_act;
$stime=$plant['time_soil']*$incubator_timesoil_act;
if(!empty($plant['rcena'])){
if($ku['rubies']>=$plant['rcena'])
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$plant['rcena'])."' WHERE `id` = '$ku[id]'");
}else{
$nm=$plant['rcena']-$ku['rubies'];
$_SESSION['no_rubies']=$nm;
header("Location:/mypool");exit;
}

}else{
if($ku['money']>=$plant['mcena'])
{
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$plant['mcena'])."' WHERE `id` = '$ku[id]'");
}else{
$nm=$plant['mcena']-$ku['money'];
$_SESSION['no_money']=$nm;
header("Location:/mypool");exit;
}
}
mysql_query("UPDATE `kolhoz_pool` SET `id_fish` = '$plant[id]', `time_soil` = '".($stime+$time)."', `time` = '".($times+$time)."' WHERE `id` = '".intval($_GET['incube'])."' LIMIT 1")or die (mysql_error());
header("Location:/mypool/".passgen());
exit;
}
?>