Файл: zfarm.mobi/inc/user/presents.php
Строк: 158
<?
$title='Подарки';
include_once '../system/config.php';
if(isset($_GET['presents']) && ($_GET['presents'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".($_GET['presents'])."' LIMIT 1"),0)!=0){
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['presents'])."'"));
$anku=$ank;
if(isset($_GET['do']))
{
if(isset($_GET['cat']) && intval($_GET['cat'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gift_cat` WHERE `id` = '".intval($_GET['cat'])."'"),0)!=0)
{
$cat=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_gift_cat` WHERE `id` = '".intval($_GET['cat'])."'"));
if(isset($_GET['gift']) && intval($_GET['gift'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gift` WHERE `id` = '".intval($_GET['gift'])."' AND `id_cat` = '$cat[id]'"),0)!=0)
{
$gift=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_gift` WHERE `id` = '".intval($_GET['gift'])."' AND `id_cat` = '$cat[id]'"));
if(isset($_GET['ok']))
{
if($ku['money']>=$gift['cena'])
{
$msg=$_POST['msg'];
if(strlen2($msg)>512)
{
$err=1;
echo "Сообщение длиннее 512-ти символов";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$ku[id]' LIMIT 1"),0)!=0)
{
$err=1;
err_game("Этот пользователь внес Вас в чёрный список, Вы не можете отправлять ему сообщения.");
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$ku[id]' LIMIT 1"),0)<1 && $ank['present']==1)
{
$err=1;
err_game("Этот пользователь получает подарки только от друзей, Вы не можете отправлять ему сообщения.");
}
if(!isset($err))
{
mysql_query("INSERT INTO `kolhoz_gifts` SET `id_user` = '$ank[id]', `id_kont` = '$ku[id]', `msg` = '".my_esc($msg)."', `time` = '$time', `id_gift` = '$gift[id]'");
$ku[money] = $ku['money']-$gift['cena'];
header("Location:/user/$ank[id]");
}
}
else
{
$_SESSION['no_money']=$gift['cena']-$ku['money'];
header("Location:/presents/$ank[id]/do/cat/$cat[id]/gift/$gift[id]");
}
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'>Подарок для $anku[nick]</h2></div>";
echo '<div class="content"><div class="div">';
echo "<img src='/img/gifts/$gift[id].png' alt='o' width='96' height='96'><br><span class='n'>".hsc($gift['name'])."</span><br><div class='small minor'>Сообщение к подарку (необязательно):</div><form action='/presents/$ank[id]/do/cat/$cat[id]/gift/$gift[id]/ok' method='post'><label><textarea class='wide' rows='5' name='msg'></textarea><br></label><input type='submit' value='Отправить' name='ok'></form>";
}
else
{echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'><a href='/presents/$ank[id]/do'>Виды подарков</a> / Подарок для $anku[nick]</h2></div>";
echo '<div class="content"><div class="div">';
echo "<ul>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gift` WHERE `id_cat` = '$cat[id]'"),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_gift` WHERE `id_cat` = '$cat[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{
echo "<li class='pb'><img src='/img/gifts/$post[id].png' alt='o' width='96' height='96'><br><span class='n'>".hsc($post['name'])."</span><br><span class='small minor'>Цена <span><img src='/img/icons/money.png' alt='o'> <span class='n'>$post[cena]</span></span></span><br><a href='/presents/$ank[id]/do/cat/$cat[id]/gift/$post[id]'>Подарить</a></li>";
}
if ($k_page>1)str("/presents/$ank[id]/do/cat/$cat[id]/",$k_page,$page); // Вывод страниц
echo "</ul>";
}
}
else
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'>Подарок для $anku[nick]</h2></div>";
echo '<div class="content"><div class="div">';
echo "<ul>";
$q=mysql_query("SELECT * FROM `kolhoz_gift_cat`");
while($post=mysql_fetch_array($q))
{
echo "<li><img src='/img/icons/gift.png' alt='o' width='16' height='16'> <a href='/presents/$ank[id]/do/cat/$post[id]'><span>".hsc($post['name'])."</span></a></li>";
}
}
echo "</ul><div></div></div>";
}
elseif(isset($_GET['del']) && intval($_GET['del'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id` = '".intval($_GET['del'])."'"),0)!=0)
{
mysql_query("DELETE FROM `kolhoz_gifts` WHERE `id` = '".intval($_GET['del'])."'");
header("Location:/presents/$ank[id]");
}
else
{
echo "<div class='title'>".($ank['id']==$ku['id']?"Мои подарки":"<a href='/user/$ank[id]'>$anku[nick]</a> / Подарки")."</h2></div>";
echo '<div class="content"><div class="div">';
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0 && $ank['id']==$ku['id'])
{
mysql_query("UPDATE `kolhoz_gifts` SET `read` = '1' WHERE `id_user` = '$ku[id]' AND `read` = '0'");
header("Location:/presents/$ku[id]");
}
echo "<ul>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id_user` = '$ank[id]'"),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_gifts` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{
$ank2=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_kont]'"));
$anku2=$ank2;
$gift=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_gift` WHERE `id` = '$post[id_gift]'"));
echo "<li class='pb'><div><img src='/img/gifts/$gift[id].png' alt='o' width='96' height='96'></div><div><span class='n'>".hsc($gift['name'])."</span></div><div><div><span>Подарил".($anku2['pol']==0?"a":null)."</span> <span>";
echo on_k($ank2['id']);
echo " <a class='' href='/user/$ank2[id]'>".nc($ank2['id'])."</a></span> <div class='minor'> (<span>".vremja($post['time'])."</span>)</div></div><div><span class='small n'>".output_text($post['msg'], $ank2['id'])."</p></span></div>";
if($ku['id']==$ank['id'])echo "<div><a class='small minor' href='/presents/$ank[id]/Delete/$post[id]'>[удалить]</a></div>";
echo "</div></li>";
}
if ($k_page>1)str("/presents/$ank[id]/",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "</div>";
echo "<li></li><div class='div'><img src='/img/icons/gift_plus.png' alt='o'> <a href='/presents/$ank[id]/do'>Подарить</a></div>";
}
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
?>