Файл: inc/petfarm/buy_animal.php
Строк: 129
<?
$title='Покупка животнoго';
include_once '../system/config.php';
echo '<img src="http://'.$_SERVER['HTTP_HOST'].'/img/barnyard.jpg">';
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'] == '1')
{
$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'] == '1')
{
no_money($cena-$ku['rubies'],$pet[rub]);
}
else
{
no_money($cena-$ku['money'],$pet[rub]);
}
}
}
echo"<div class='rzd2'></div>";
echo '<div class="title">Магазин животных</div>';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pet`"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,5);
$page=page($k_page);
$start=5*$page-5;
$q=mysql_query("SELECT * FROM `kolhoz_pet` ORDER BY `level` ASC LIMIT $start, 5");
echo "<ul>";
while($post=mysql_fetch_array($q))
{
if($post['rub']==0)
{
$img="money";
}
else
{
$img="ruby";
}
if($ku['action']==3)
{
$cenas=$post['cena']/2;
}
else
{
$cenas=$post['cena'];
}
echo '<div><div class="flat-content mb0 bg-brown font14 text-bold">'.hsc($post['name']).'</div><div class="flat-content mb2">
<table width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="25%" align="center">
<div class="f-animal-dirt">
<img width="80" height="77" style="padding: 7px;" src="/img/pets/'.$post['img'].'.png" alt="o" class="portrait">
</div>
</td>
<td class="pr5" width="45%" align="left">
Доход <span><img src="/img/icons/money.png" alt="o"><span class="nobr">'.$post['money'].'</span></span><br>
Опыт <img src="/img/icons/new/dostig.png" alt="o"> <span>'.$post['rating'].'</span><br>
'.hsc($post['tovar']).' <span>'.$post['count'].'</span> '.hsc($post['value']).'<br>
за <img width="16" height="16" src="/img/ctime.png" alt="o"> <span>'.time_left_fish($post['time_count']).'</span>
</td>
<td align="center">';
if($ku['level']>=$post['level'] && $post['dostup'] < '1')
{
echo '<a href="/barnyard/buy/'.$petground['id'].'/select/'.$post['id'].'"><span class="turquoise flat-btn pad">
<span><span class="nobr"><span class="f-icon f-icon-coin"></span><img src="/img/icons/'.$img.'.png" alt="o"> '.strkol($cenas).'</span></span>
</span></a>';
}
elseif(($ku['level'] < $post['level'] || $ku['level']>=$post['level']) && $post['dostup'] > '0')
{
echo '<span class="font15 locked-btn">Доступно в период ивентов</span>';
}
elseif($ku['level'] < $post['level'] && $post['dostup'] < '1')
{
echo '<span class="font14 locked-btn"><img src="/ImgStyle/locked.png" width="30" height="36" alt="o"> <br><span>'.$post['level'].'</span> +</span>';
}
echo '</td>
</tr>
</tbody>
</table>
</div></div>
';
}
echo'<div class="menu-foot">';
if ($k_page>1)str("/barnyard/buy/$petground[id]/",$k_page,$page); // Вывод страниц
echo'</div>';
echo '<a href="/barnyard" class="flat-btn lblue mb2 pt15 pb15">Назад</a>';
echo "</ul>";
echo"<div class='rzd2'></div>";
include_once '../system/foot.php';
}
?>