Файл: KOSMOS/inc/buy_fish.php
Строк: 71
<?
if(isset($_GET['myprud']) && isset($_GET['buy']) && intval($_GET['buy'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_prud` WHERE `id` = '".intval($_GET['buy'])."' AND `id_user` = '$ku[id]' AND `id_fish` = '0'"),0)!=0)
{
$prud=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_prud` WHERE `id` = '".intval($_GET['buy'])."' AND `id_user` = '$ku[id]'"));
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)
{
$fish=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_fish` WHERE `id` = '".intval($_GET['select'])."'"));
if($ku['rubies']>=$fish['cena'])
{
if(isset($_GET['ok']))
{
$rat=$fish['rost'];
$rat_sc_act=0;
$rat_incubator_act=0;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_lib_act=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($incubator_act))$rat_incubator_act=(($rat/100)*$incubator_act);
if(isset($drakon_act))$rat_drakon_act=(($plant['rating']/100)*300);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat*2;
$ratt=$rat_drakon_act+$rat_sc_act+$rat_incubator_act+$rat_school_act+$rat_lib_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
$_SESSION['rating']=$rat;
update_mc($rat);
mysql_query("UPDATE `kolhoz_prud` SET `id_fish` = '$fish[id]', `time_money` = '$time', `time_money2` = '0', `last_rf` = '$time' WHERE `id` = '$prud[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$fish['cena'])."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
header("Location:?myprud&".passgen());
exit;
}
podtv("?myprud&buy=$prud[id]&select=$fish[id]&ok","?myprud&buy=$prud[id]");
include_once 'inc/foot.php';
}
else
{
no_rubies($fish['cena']-$ku['rubies']);
}
}
echo '<div class="event"><h1>Магазин Рыб</h1></div>';
echo "<div class='content'>";
echo "<div class='block'>";
$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='?myprud&buy=$prud[id]&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/ruby.png' alt='o'> <span class='title'>$post[cena]</span></span>":"доступно с $post[level] уровня</span>")."</div><div class='minor small'>доход: <span><img width='16' height='16' src='images/icons/money.png' alt='o'> <span
class='title'>$post[money]</span></span>, опыт за одно кормление: <img width='16' height='16' src='images/icons/experience.png' alt='o'>
<span>$post[rating]</span></div></li>";
}
if ($k_page>1)str("?myprud&buy=$prud[id]&",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "</div>";
include_once 'inc/foot.php';
}
?>