<?
if(isset($_GET['ozero']) && isset($_GET['seat_all']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'"),0)!=0 && $ku['catchfish']>0)
{
echo '<div class="event"><h1>Рыбная лавка</h1></div>';
echo "<div class='content'>";
echo "<div class='block'>";
if($ku['last_fish']!=0)
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_fish` WHERE `id` = '$ku[last_fish]'"));
$cg=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0'"),0);

$money=floor($plant['cena']);
$sc=$money*$cg;
$rat=$plant['rating'];
$rat_sc_act=0;
$rat_drakon_act=0;
$rat_seeder_act=0;
$rat_school_act=0;
if(isset($sc_act)){$rat_sc_act=$rat*2;
if(isset($vtr_act))$rat_sc_act=$rat*2*4;}else{
if(isset($vtr_act))$rat_sc_act=$rat*4;
}
if(isset($catckorm_act))$rat_drakon_act=(($plant['rating']/100)*$catckorm_act);

$ratt=$rat_drakon_act+$rat_sc_act+$rat+$rat_school_act+$rat_lib_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
if($gos['id_plant']==$plant['id'] && $gos['type']=='rating' && isset($mc))$rat=$rat*2;
if($ku['money']>=$sc)
{
$q=mysql_query("SELECT * FROM `kolhoz_pond` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'");
$orat=0;
while($post=mysql_fetch_array($q))
{
$orat=$rat+$orat;
mysql_query("UPDATE `kolhoz_pond` SET `id_plant` = '$plant[id]', `time_soil` = '".($time+$plant['time_soil'])."', `time_water` = '".($time+120)."', `soil` = '0', `time` = '".($plant['time']+$time)."' WHERE `id` = '$post[id]' LIMIT 1");
}
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$sc)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
update_mc($orat);
$_SESSION['rating']=$orat;
}
else
{
$_SESSION['no_money']=$sc-$ku['money'];
}
header("Location:?ozero&".passgen());
exit;
}
else
{
if(isset($_GET['select']) && intval($_GET['select'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_fish` WHERE `id` = '".intval($_GET['select'])."' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_fish` WHERE `id` = '".intval($_GET['select'])."'"));
mysql_query("UPDATE `kolhoz_user` SET `last_fish` = '$plant[id]' WHERE `id` = '$ku[id]'");
header("Location:?ozero&seat_all");
exit;
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_fish`"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `kolhoz_fish` ORDER BY `level` ASC LIMIT $start, $set[p_str]");
echo "<ul>";
while($post=mysql_fetch_array($q))
{
echo "<li style='padding-bottom:8px'>";
echo "<img width='48' height='48' src='images/fish/$post[id].png' alt='o' class='portrait'>";
echo "<div class='small'>";
echo "".($ku['level']>=$post['level']?"<a href='?ozero&seat_all&select=$post[id]'>":null)."<span>".hsc($post['name'])."</span>".($ku['level']>=$post['level']?"</a>":null)." <span class='minor'>, ".($ku['level']>=$post['level']?"цена: </span><span><img width='16' height='16' src='images/icons/money.png' alt='o'><span class='title'>$post[cena]</span></span>":"доступно с $post[level] уровня</span>")."</div><div class='small minor'> Время роста: <span class='title'>".time_left($post['time'])."</span>, Время до подкормки: <span class='title'>".time_left($post['time_soil'])."</span><br>Доход: <img width='16' height='16' src='images/icons/money.png' alt='o'> <span>$post[money]</span>,
Опыт: <img width='16' height='16' src='images/icons/experience.png' alt='o'> <span>$post[rating]</span>,
Прирост: <span>$post[count]</span> <span>кг.</span></div></li>";
}
echo "</ul>";
if ($k_page>1)str("?ozero&seat_all&",$k_page,$page); // Вывод страниц
}
echo "</div>";
include_once 'inc/foot.php';
}
?>