<?
if(isset($_GET['ozero']) && isset($_GET['catchfish_all']) && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'"),0)!=0 && $ku['catchfish']>0)
{
$q=mysql_querll("SELECT * FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'");
$ohv=0;
while($post=mysql_fetch_array($q))
{
$plant=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_fish` WHERE `id` = '$post[id_plant]'"));
if($plant['id']==$gos['id_plant'] && $mc)
{
$harv=(isset($catchfish_act)?$catchfish_act/100:0);
$hawk=(isset($yastreb_act)?3:0);

$exp=$plant['time_soil']+($plant['time_soil']*$harv)+($plant['time_soil']*$hawk);
if($gos['type']=='harvest')$exp=$exp*2;
mysql_querll("INSERT INTO `kolhoz_collective_rating_gos` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$exp', `time` = '$time'");
}
$count=$plant['count'];
$count_harvester_act=0;
$count_yastreb_act=0;
$count_greenhouse_act=0;
if(isset($catchfish_act))$count_harvester_act=floor(($count/100)*$catchfish_act);
if(isset($yastreb_act))$count_yastreb_act=(($count/100)*300);
if(isset($greenhouse_act))$count_greenhouse_act=(($count/100)*$greenhouse_ps);
$count=$count_harvester_act+$count_yastreb_act+$count+$count_greenhouse_act;
$count=floor($count);

if($pw=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id_plant` = '$plant[id]' AND `arena` = '0' AND `fish` = '1'")))
{
mysql_querll("UPDATE `kolhoz_warehouse` SET `count` = '".($pw['count']+$count)."' WHERE `id` = '$pw[id]'");
}
else mysql_querll("INSERT INTO `kolhoz_warehouse` SET `id_plant` = '$plant[id]', `id_user`  = '$ku[id]', `count` = '$count', `arena` = '0', `fish` = '1'");
mysql_querll("UPDATE `kolhoz_pond` SET `id_plant` = '0', `soil` = '0', `cultivator` = '0' WHERE `id` = '$post[id]' LIMIT 1");
$ohv=$ohv+$count;
}
$_SESSION['catchfish']=$ohv;
mysql_querll("UPDATE `kolhoz_user` SET `ribak` = '".($ku['ribak']+$ohv)."' WHERE `id` = '$ku[id]'");
header("Location:?ozero&".passgen());
exit;
}
?>