<?
$barek=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` = '0'"),0);
if(isset($_GET['mypetfarm']) && isset($_GET['buy_all']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE  `id_user` = '$ku[id]' AND `id_pet` = '0'"),0)!=0)
{
$petground_all=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]'"));
if(isset($_GET['select']) && intval($_GET['select'])!=NULL && 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_all=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '".intval($_GET['select'])."'"));
//if($ku['money']>=$pet_all['cena'])
if($ku['money']>=$pet_all['cena']*$barek)
{
if(isset($_GET['ok']))
{
mysql_query("UPDATE `kolhoz_petground` SET `id_pet` = '$pet_all[id]', `time_money` = '$time', `time_money2` = '0', `last_rf` = '$time' WHERE `id_user` = '$ku[id]' ");
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$pet_all['cena']*$barek)."' WHERE `id` = '$ku[id]'");
header("Location:?mypetfarm");
//header("Location:?mypetfarm&".passgen());
exit;
}
podtv("?mypetfarm&buy_all&select=$pet_all[id]&ok","?mypetfarm&buy_all");
include_once 'inc/foot.php';
}
else
{
no_money($pet_all['cena']*$barek-$ku['money']);
}
}
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_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 width='48' height='48' src='img/pets/$post[id].png' alt='o' class='portrait'>";
echo "<div class='small'>";
echo "".($ku['level']>=$post['level']?"<a href='?mypetfarm&buy_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='img/icons/money.png' alt='o'><span class='title'>$post[cena]</span></span>":"доступно с $post[level] уровня</span>")."</div><div class='minor small'><span>".hsc($post['work'])."</span>, доход: <span><img width='16' height='16' src='img/icons/money.png' alt='o'> <span
class='title'>$post[money]</span></span>, опыт за одно кормление: <img width='16' height='16' src='img/icons/experience.png' alt='o'>
<span>$post[rating]</span></div></li>";
}
if ($k_page>1)str("?mypetfarm&buy_all&",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "</div>";
include_once 'inc/foot.php';
}
?>