Файл: user/friends/new.php
Строк: 229
<?php
/* DCMS Special
* Дата последнего редактирования 11.12.2015
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/{$inc}.php";
}
only_reg();
$ank['id'] = $user['id'];
$set['title'] = 'Предложения дружбы';
require_once H . 'sys/inc/thead.php';
aut();
#Навигация
echo "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/info.php?id=$user[id]'>$user[nick]</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'>Друзья</a></li>";
echo "</ul>";
echo "</nav>";
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 `friends` (`user`, `friends`, `time`, `i`) values('$ank[id]', '$ok', '$time', '1')");
mysql_query("INSERT INTO `friends` (`user`, `friends`, `time`, `i`) values('$ok', '$ank[id]', '$time', '1')");
mysql_query("DELETE FROM `friends_new` WHERE `user` = '$ok' AND `to` = '$user[id]' LIMIT 1");
mysql_query("DELETE FROM `friends_new` WHERE `user` = '$user[id]' AND `to` = '$ok' LIMIT 1");
mysql_query("OPTIMIZE TABLE `friends`");
mysql_query("OPTIMIZE TABLE `friends_new`");
$msg = "" . ($user['sex'] ? 'подтвердил' : 'подтвердила') . ", что Вы друзья.";
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ok', '$msg', '$time')");
msg('Пользователь добавлен в список Ваших друзей');
}
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 `friends` WHERE `user` = '$user[id]' AND `friends` = '$no' LIMIT 1");
mysql_query("DELETE FROM `friends` WHERE `user` = '$no' AND `friends` = '$user[id]' LIMIT 1");
mysql_query("DELETE FROM `friends_new` WHERE `user` = '$no' AND `to` = '$user[id]' LIMIT 1");
mysql_query("DELETE FROM `friends_new` WHERE `user` = '$user[id]' AND `to` = '$no' LIMIT 1");
mysql_query("OPTIMIZE TABLE `friends`");
mysql_query("OPTIMIZE TABLE `friends_new`");
$msg = "" . ($user['sex'] ? 'отклонил' : 'отклонила') . " Ваше предложение дружбы.";
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$no', '$msg', '$time')");
msg('Предложение отклонено');
header("Location: new.php?r=outgoing");
exit();
}
if (isset($_GET['del'])) {
$no = intval($_GET['del']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$no' LIMIT 1"), 0) == 0) {
header("Location: index.php?");
exit;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE (`user` = '$user[id]' AND `friends` = '$no') OR (`user` = '$no' AND `friends` = '$user[id]') LIMIT 1"), 0) > 0) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$no', '" . ($user['sex'] ? 'удалил' : 'удалила') . " Вас из списка своих друзей.', '$time')");
mysql_query("DELETE FROM `friends` WHERE `user` = '$user[id]' AND `friends` = '$no' LIMIT 1");
mysql_query("DELETE FROM `friends` WHERE `user` = '$no' AND `friends` = '$user[id]' LIMIT 1");
mysql_query("DELETE FROM `freinds_new` WHERE `user` = '$no' AND `to` = '$user[id]' LIMIT 1");
mysql_query("DELETE FROM `friends_new` WHERE `user` = '$user[id]' AND `to` = '$no' LIMIT 1");
mysql_query("OPTIMIZE TABLE `friends`");
mysql_query("OPTIMIZE TABLE `friends_new`");
msg('Пользователь удален из списка ваших друзей');
header("location: " . htmlspecialchars($_SERVER['HTTP_REFERER']) . "");
}
exit;
}
$k_online = mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` INNER JOIN `user` ON `friends`.`friends`=`user`.`id` WHERE `friends`.`user` = '$ank[id]' AND `friends`.`i` = '1' AND `user`.`date_last`>'" . (time() - 300) . "'"), 0);
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);
$k_z = mysql_result(mysql_query("SELECT COUNT(id) FROM `friends_new` WHERE `to` = '$ank[id]'"), 0);
echo "<div class='card'>";
echo "<div class='card-header'>Друзья</div><div class='card-block'>";
echo "<ul class='nav nav-tabs'>";
echo "<li class='nav-item'><a class='nav-link' href='index.php'>Друзья <span class='label label-default'>$k_post</span></a></li>";
echo "<li class='nav-item'><a class='nav-link active'>Заявки <span class='label label-default'>$k_z</span></a></li>";
echo "<li class='nav-item'><a class='nav-link' href='online.php'>Онлайн <span class='label label-default'>$k_online</span></a></li>";
echo "</ul>";
echo "</div>";
$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 `friends_new` WHERE `to` = '$user[id]' LIMIT 1"), 0);
$r = (isset($_GET['r'])) ? htmlspecialchars($_GET['r']) : null;
switch ($r) {
default:
echo "<div class='card-block'>";
echo "<ul class='nav nav-pills'>";
echo "<li class='nav-item'><a class='nav-link active'>Входящие</a></li>";
echo "<li class='nav-item'><a class='nav-link' href='/user/friends/new.php?r=outgoing'>Исходящие</a></li>";
echo "</ul>";
if ($k_f == 0) {
echo "<div class='card-block'>";
echo "<i class='material-icons'>feedback</i> Нет результатов";
echo "</div>";
}
$q = mysql_query("SELECT * FROM `friends_new` WHERE `to` = '$user[id]' ORDER BY time DESC");
while ($f = mysql_fetch_array($q)) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '" . $f['user'] . "' LIMIT 1"));
echo "<table><tr><td class = 'icon14'>";
avatar($ank['id'], '48');
echo "</td><td class = 'null'>";
echo "<small style='float: right;'>" . date::time($f['time']) . "</small>";
echo "Вы знаете <a href='/info.php?id=$ank[id]'><b>$ank[nick]</b></a>?<br />";
echo "<span style='float: right;'><a href='new.php?no=$ank[id]'><font color='red'>Нет, не знаю</font></a></span>";
echo "<a href='new.php?ok=$ank[id]'> <font color='green'><i class='material-icons'>done</i> Да, знаю</font></a> ";
echo "</td></tr></table>";
}
echo '</div>';
break;
case 'outgoing':
$k_t = mysql_result(mysql_query("SELECT COUNT(id) FROM `friends_new` WHERE `user` = '$user[id]' LIMIT 1"), 0);
echo "<div class='card-block'>";
echo "<ul class='nav nav-pills'>";
echo "<li class='nav-item'><a class='nav-link' href='/user/friends/new.php?'>Входящие</a></li>";
echo "<li class='nav-item'><a class='nav-link active'>Исходящие</a></li>";
echo "</ul>";
if ($k_t == 0) {
echo "<div class='card-block'>";
echo "<i class='material-icons'>feedback</i> Нет результатов";
echo "</div>";
}
$q = mysql_query("SELECT * FROM `friends_new` WHERE `user` = '$user[id]' ORDER BY time DESC");
while ($f = mysql_fetch_array($q)) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '" . $f['to'] . "' LIMIT 1"));
echo "<table><tr><td class = 'icon14'>";
avatar($ank['id'], '48');
echo "</td><td class = 'null'>";
echo "<span style='float:right' id='hides'>";
echo "<a href = 'new.php?no=$ank[id]' title = 'Удалить'><i class='material-icons'>delete</i></a>";
echo "</span>";
user($ank['id']);
echo " <small>" . date::time($f['time']) . "</small>";
echo "<br />";
echo "Ожидается...";
echo "</td></tr></table>";
}
echo '</div>';
break;
}
echo "</div>";
require_once H . 'sys/inc/tfoot.php';