Файл: zfarm.mobi/inc/petfarm/buy_animal.php
Строк: 118
<?
$title='Покупка животнрго';
include_once '../system/config.php';
if(isset($_GET['buy']) && intval($_GET['buy'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id` = '".intval($_GET['buy'])."' AND `id_user` = '$ku[id]' AND `id_pet` = '0'"),0)!=0)
{
$petground=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id` = '".intval($_GET['buy'])."' AND `id_user` = '$ku[id]'"));
$pet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '".intval($_GET['select'])."'"));
if(isset($_GET['select']) && intval($_GET['select'])!=NULL && $pet['dostup']<1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pet` WHERE `id` = '".intval($_GET['select'])."' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
{
$pet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '".intval($_GET['select'])."'"));
if($ku['action']==3){$cena=$pet['cena']/2;}else{$cena=$pet['cena'];}
if($pet['rub']){
$z="rubies";
}else{
$z="money";
}
if($ku["$z"]>=$cena)
{
if(isset($_GET['ok']))
{
mysql_query("UPDATE `kolhoz_petground` SET `id_pet` = '$pet[id]', `time_money` = '$time', `time_money2` = '0', `last_rf` = '$time' WHERE `id` = '$petground[id]' LIMIT 1");
if($pet['rub']){
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$cena)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `info_user` SET `id_user` = '$ku[id]', `status` = '-', `many` = '$pet[cena]', `kuda` = 'покупка животного', `time` = '$time'");
}else{
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$cena)."' WHERE `id` = '$ku[id]'");
}
header("Location:/barnyard");
exit;
}
podtv("/barnyard/buy/$petground[id]/select/$pet[id]/ok","/barnyard/buy/$petground[id]");
include_once '../system/foot.php';
}
else
{
if($pet[rub]){
no_money2($cena-$ku['rubies'],$pet[rub]);
}else{
no_money2($cena-$ku['money'],$pet[rub]);
}
}
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Магазин животных</h2></div>';
echo "<div class='content'>";
echo "<div class='div'>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pet`"),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_pet` 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 style='border-radius: 5px' width='55' height='61' src='/img/pets/$post[img].png' alt='o' class='portrait'>";
echo "<div class='small'>";
if($post['rub']==0){$img="money";}else{$img="ruby";}
if($ku['action']==3){
$cenas=$post['cena']/2;
}
else{
$cenas=$post['cena'];
}
if($ku['level']>=$post['level'] && $post['dostup']<1)echo"<a href='/barnyard/buy/$petground[id]/select/$post[id]'><span>".hsc($post['name'])."</a></span><span class='minor'>, цена: </span><span><img src='/img/icons/$img.png' alt='o'><span class='n'>$cenas</span></span></span></div>";
if($ku['level']<$post['level'] && $post['dostup']<1)echo"<span>".hsc($post['name'])."</a></span><span class='minor'>, доступно c <span class='n'>$post[level]</span></span> уровня</span></div>";
if($post['dostup']>0)echo"<span>".hsc($post['name'])."</a></span><span class='minor'>, доступно в период <span class='n'>ивентов</span></span></span></div>";
echo" <div class='minor small'><span>".hsc($post['work'])."</span>, доход: <span><img src='/img/icons/money.png' alt='o'> <span
class='n'>$post[money]</span></span>, опыт за одно кормление: <img src='/img/icons/experience.png' alt='o'>
<span>$post[rating]</span></li>";
}
if ($k_page>1)str("/barnyard/buy/$petground[id]/",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "</div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
?>