Файл: LinkUser/LinkPodarki.php
Строк: 146
<?php
$set['p_str'] = $user['set'];
$ku = $user;
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_user` WHERE `id` = '".intval($_GET['presents'])."'"));
$anku=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_user` WHERE `id` = '$ank[id]'"));
if(isset($_GET['do']))
{
if(intval($_GET['presents']) == $user['id']){
header("Location:index.php");
exit;
}
if(isset($_GET['cat']) && intval($_GET['cat'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_gift_cat` WHERE `id` = '".intval($_GET['cat'])."'"),0)!=0)
{
$cat=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_gift_cat` WHERE `id` = '".intval($_GET['cat'])."'"));
if(isset($_GET['gift']) && intval($_GET['gift'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_gift` WHERE `id` = '".intval($_GET['gift'])."' AND `id_cat` = '$cat[id]'"),0)!=0)
{
$gift=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_gift` WHERE `id` = '".intval($_GET['gift'])."' AND `id_cat` = '$cat[id]'"));
if(isset($_GET['ok']))
{
$money = $gift['cena']/$frend['podarki'];
if($ku['money']>=$money)
{
$msg=$_POST['msg'];
if(strlen2($msg)>512)
{
$err=1;
echo "Сообщение длиннее 512-ти символов";
}
if(!isset($err))
{
$money = $gift['cena']/$frend['podarki'];
mysql_query("INSERT INTO `mystyle_gifts` SET `id_user` = '$ank[id]', `id_kont` = '$ku[id]', `msg` = '".my_esc($msg)."', `time` = '$time', `id_gift` = '$gift[id]'");
mysql_query("UPDATE `mystyle_user` SET `money` = '".($ku['money']-$money)."' WHERE `id` = '$ku[id]'");
header("Location:index.php?LinkPodarok");
}
}
else
{
header("Location:?presents=$ank[id]&do&cat=$cat[id]&gift=$gift[id]");
}
}
echo "<div class="emptyPanel"><h1>Подгон для $anku[nick]</h1></div>";
echo '<div class="content"><div class="emptyPanel">';
echo "<img src='images/gifts/$gift[id].png' alt='o' width='96' height='96'><br><span class='title'>".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='event'><h1><a href='?presents=$ank[id]&do'>Виды подгонов</a> / Подгон для $anku[nick]</h1></div>";
echo '<div class="content"><div class="block">';
echo "<ul>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_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 `mystyle_gift` WHERE `id_cat` = '$cat[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{
$money = ($frend['podarki'] <= 0) ? $post['cena'] / 1 : $post['cena'] / $frend['podarki'];
echo "<li class="emptyPanel"><img src='images/gifts/$post[id].png' alt='o' width='96' height='96'><br><span class='title'>".hsc($post['name'])."</span><br><span class='small minor'>Цена <span><img width='16' height='16' src='images/icons/money.png' alt='o'> <span class='title'>$money</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="emptyPanel"><h1>Подгон для $anku[nick]</h1></div>";
echo '<div class="emptyPanel">';
echo "<ul>";
$q=mysql_query("SELECT * FROM `mystyle_gift_cat`");
while($post=mysql_fetch_array($q))
{
echo "<li class="bntp"><img src='images/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>";
}
elseif(isset($_GET['del']) && intval($_GET['del'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_gifts` WHERE `id` = '".intval($_GET['del'])."'"),0)!=0)
{
mysql_query("DELETE FROM `mystyle_gifts` WHERE `id` = '".intval($_GET['del'])."'");
header("Location:?presents=$ank[id]");
}
else
{
echo "<div class="btnm"><h1>".($ank['id']==$user['id']?"Мои подгоны":"<a href='?user=$ank[id]'>$anku[nick]</a> / Подгоны <a class="btnp" href='?presents=$ank[id]&do'>Подарить</a>")."</h1></div>";
echo '<div class="content"><div class="block">';
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_gifts` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0 && $ank['id']==$ku['id'])
{
mysql_query("UPDATE `mystyle_gifts` SET `read` = '1' WHERE `id_user` = '$ku[id]' AND `read` = '0'");
header("Location:?presents=$ku[id]");
}
echo "<ul class="emptyPanel">";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_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 `mystyle_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 `mystyle_user` WHERE `id` = '$post[id_kont]'"));
$anku2=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_user` WHERE `id` = '$ank2[id_user]'"));
$gift=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_gift` WHERE `id` = '$post[id_gift]'"));
echo "<li class='pb'><div><img src='images/gifts/$gift[id].png' alt='o' width='96' height='96'></div><div><span class='title'>".hsc($gift['name'])."</span></div><div><div><span>Подогнал".($anku2['pol']==1?"a":null)."</span> <span>";
echo " <a class='' href='?user=$ank2[id]'>".users($ank2['id'])."</a></span> <div class='minor'> (<span>".vremja($post['time'])."</span>)</div></div><div><span class='small title'><p>".smile($post['msg'])."</p></span></div>";
if($ku['id']==$ank['id'])echo "<div><a class='small minor' href='?presents=$ank[id]&del=$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>";
}
?>