Файл: pages/frend_new.php
Строк: 168
<?
# МОД ДРУЖБЫ ДЛЯ DCMS 6.x
# SimiX aka iNFERNO
# 4759229
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
only_reg();
$ank['id']=$user['id'];
if (isset($_GET['ok']))
{
$ok = intval($_GET['ok']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ok' LIMIT 1"),0)==0){header("Location: index.php?");exit;}
mysql_query("INSERT INTO `frends` (`user`, `frend`, `time`, `i`) values('$ank[id]', '$ok', '$time', '1')");
mysql_query("INSERT INTO `frends` (`user`, `frend`, `time`, `i`) values('$ok', '$ank[id]', '$time', '1')");
mysql_query("DELETE FROM `frends_new` WHERE `user` = '$ok' AND `to` = '$user[id]' LIMIT 1");
mysql_query("DELETE FROM `frends_new` WHERE `user` = '$user[id]' AND `to` = '$ok' LIMIT 1");
mysql_query("OPTIMIZE TABLE `frends`");
mysql_query("OPTIMIZE TABLE `frends_new`");
header("Location: frend.php?".SID);
exit;
}
if (isset($_GET['no']))
{
$no = intval($_GET['no']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$no' LIMIT 1"),0)==0){header("Location: index.php?");exit;}
mysql_query("DELETE FROM `frends` WHERE `user` = '$user[id]' AND `frend` = '$no' LIMIT 1");
mysql_query("DELETE FROM `frends` WHERE `user` = '$no' AND `frend` = '$user[id]' LIMIT 1");
mysql_query("DELETE FROM `frends_new` WHERE `user` = '$no' AND `to` = '$user[id]' LIMIT 1");
mysql_query("DELETE FROM `frends_new` WHERE `user` = '$user[id]' AND `to` = '$no' LIMIT 1");
mysql_query("OPTIMIZE TABLE `frends`");
mysql_query("OPTIMIZE TABLE `frends_new`");
header("Location: frend_new.php?".SID);
exit;
}
$set['title'] = 'Список друзей';
include_once '../sys/inc/thead.php';
title();
aut();
echo "<table class='post'><tr><td class='icon14'>
<img src='/style/icons/friendship.gif'>
</td><td class='p_t'>
Список заявок | <a href='frend.php'>Друзья</a></td></tr></table>";
$m = date('m', $time);
if (substr($m, 0, 1) == 0)$m = str_replace('0', '', $m);
$d = date('d', $time);
$k_f = mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$user[id]' LIMIT 1"), 0);
echo "<table class='post'><tr>
</td><td class='p_t'>
Заявки</td></tr></table>";
echo "<table class='post'>n";
if ($k_post==0)
{
echo " <tr>n";
echo " <td class='p_t'>n";
echo "Нет заявок на дружбуn";
echo " </td>n";
echo " </tr>n";
}
echo "<table class='post'>n";
$q = mysql_query("SELECT * FROM `frends_new` WHERE `to` = '$user[id]' ORDER BY time DESC");
while ($f = mysql_fetch_array($q))
{
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".$f['user']."' LIMIT 1"));
echo " <tr>n";
if ($set['set_show_icon']==2){
echo " <td class='icon48' rowspan='2'>n";
avatar($a['id']);
echo " </td>n";
}
elseif ($set['set_show_icon']==1)
{
echo " <td class='icon14'>n";
echo "".status($a['id'])."";
echo " </td>n";
}
echo " <td class='p_t'>n";
echo ' <a href="/info.php?id='.$a['id'].'">'.$a['nick'].'</a>'.online($a['id'])."n";
echo " </td>n";
echo " </tr>n";
echo " <tr>n";
if ($set['set_show_icon']==1)echo " <td class='p_m' colspan='2'>n"; else echo " <td class='p_m'>n";
echo ' Отправлена '.vremja($f['time']).'<br /> <a href="frend_new.php?ok='.$a['id'].'">Принять</a>/<a href="frend_new.php?no='.$a['id'].'">Отклонить</a>';
echo " </td>n";
echo " </tr>n";
}
echo "</table>n";
$k_t = mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `user` = '$user[id]' LIMIT 1"), 0);
echo "<table class='post'><tr>
</td><td class='p_t'>
Мои предложения</td></tr></table>";
echo '<table class="post">'."n";
if ($k_post==0)
{
echo " <tr>n";
echo " <td class='p_t'>n";
echo "Нет заявок на дружбуn";
echo " </td>n";
echo " </tr>n";
}
$q = mysql_query("SELECT * FROM `frends_new` WHERE `user` = '$user[id]' ORDER BY time DESC");
while ($f = mysql_fetch_array($q))
{
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".$f['to']."' LIMIT 1"));
echo " <tr>n";
if ($set['set_show_icon']==2){
echo " <td class='icon48' rowspan='2'>n";
avatar($a['id']);
echo " </td>n";
}
elseif ($set['set_show_icon']==1)
{
echo " <td class='icon14'>n";
echo "".status($a['id'])."";
echo " </td>n";
}
echo " <td class='p_t'>n";
echo ' <a href="/info.php?id='.$a['id'].'">'.$a['nick'].'</a>'.online($a['id'])."n";
echo " </td>n";
echo " </tr>n";
echo " <tr>n";
if ($set['set_show_icon']==1)echo " <td class='p_m' colspan='2'>n"; else echo " <td class='p_m'>n";
echo ' Отправлена '.vremja($f['time']).'<br /> <b>x</b> <a href="frend_new.php?no='.$a['id'].'">Отклонить</a>';
echo " </td>n";
echo " </tr>n";
}
echo "</table>n";
include_once '../sys/inc/tfoot.php';
?>