Файл: user/friends/index.php
Строк: 157
<?php
/* Мод "Друзья"
* Версия v0.0.1
* Дата последнего редактирования 21.11.2014
* Двиг DCMS Special
* Модифицировал densnet
* Файл index.php
* Описание: выводит список друзей, настройки
*/
require_once '../../sys/inc/start.php';
require_once H . 'sys/inc/compress.php';
require_once H . 'sys/inc/sess.php';
require_once H . 'sys/inc/settings.php';
require_once H . 'sys/inc/db_connect.php';
require_once H . 'sys/inc/ipua.php';
require_once H . 'sys/inc/fnc.php';
require_once H . 'sys/inc/user.php';
user::only_reg();
$set['title'] = 'Список друзей';
require_once H . 'sys/inc/thead.php';
if (isset($_GET['id'])) {
$ank = user::get_user(intval($_GET['id']));
if ($ank['id'] == 0) {
$ank = $user;
} else {
$ank = user::get_user(intval($_GET['id']));
}
} else {
user::only_reg('/reg.php');
$ank = $user;
}
title();
aut();
if (isset($_POST['password'])) {
$set_cook = $_POST['password'];
setcookie("passfriend$ank[id]", $set_cook);
if (isset($_POST['password']) && $_POST['password'] == $ank['friends_password']) {
header("Location: ?id=$ank[id]");
}
}
if ($ank['friends_access'] == 'only_me') {
if ($ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3) {
} else {
echo "<div class = 'errs'>";
echo "Доступ к списку друзей пользователя <b>$ank[nick]</b> закрыт.";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit();
}
} elseif ($ank['friends_access'] == 'friends') {
if ($ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3 || $ank['id'] == $user['id'] && isset($user) || isset($umodd) || mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE (`user` = '$user[id]' AND `friends` = '$ank[id]') OR (`user` = '$ank[id]' AND `friends` = '$user[id]')"), 0) != 0) {
} else {
echo "<div class = 'errs'>";
echo "Доступ к списку друзей пользователя <b>$ank[nick]</b> открыт только для друзей.";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit();
}
} elseif ($ank['friends_access'] == 'pass') {
if (isset($_COOKIE["passfriend$ank[id]"]) && $_COOKIE["passfriend$ank[id]"] == $ank['friends_password'] || $ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3) {
} else {
if (isset($_POST['password']) && $_POST['password'] != $ank['friends_password']) {
$err[] = "Пароль неправильный.";
}
err();
echo "<form class = 'errs' action = '' method = 'post'>";
echo "Список друзей пользователя <b>$ank[nick]</b> доступен только по паролю:<br/>";
echo "<b>Пароль</b> <br />";
echo "<input name = 'password' aria-required = 'true' aria-invalid = 'false' required = 'required' type = 'password' value = ''/>";
echo "<button class = 'active' name = 'submited'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Войти</span>";
echo "</button></form>";
require_once H . 'sys/inc/tfoot.php';
exit();
}
}
$ank['id'] = $user['id'];
if (isset($_GET['id'])) {
$ank['id'] = intval($_GET['id']);
}
$q = mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1");
if (mysql_num_rows($q) == 0) {
header("Location: index.php?" . SID);
exit;
}
$ank = mysql_fetch_array($q);
$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 = 'navigation'><a href = '/index.php'>Главная</a> > <a href = '/id$ank[id]'>$ank[nick]</a> > <a href = '?'><b>Друзья</b></a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('friends.png') . " Друзья</div>";
echo "<div class = 'tabs t_bar clear_fix'>";
echo "<a href = '/user/friends/' class = 'active'>Друзья [$k_post]</a>";
if (isset($user) && $user['id'] == $ank['id']) {
echo "<a href = '/user/friends/new.php'>Заявки [$k_z]</a>";
echo "<a href = '/user/friends/online.php'>Онлайн [$k_online]</a>";
}
echo "</div>";
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img('error.png') . " Нет результатов";
echo "</div>";
}
$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 `friends` WHERE `user` = '$ank[id]' AND `i` = '1' ORDER BY time DESC LIMIT $start, $set[p_str]");
while ($f = mysql_fetch_array($q)) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[friends]' LIMIT 1"));
echo "<table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank['id'], '48');
echo "</td><td class = 'null'>";
if (isset($user) && $user['id'] != $ank['id']) {
echo "<a href = '/user/friends/new.php?del=$ank[id]' class = 'count' style = 'float:right;' title = 'Удалить'>" . img('del.png') . "</a>";
}
user($ank['id']);
echo "<br /><br />";
echo "<a href = '/mail.php?id=$ank[id]' class = 'count'>" . img('sms.png') . " Сообщение</a>";
echo "</td></tr></table>";
}
if (isset($user) && $user['id'] != $ank['id']) {
echo "<div class = 'razd'>";
echo "<a class = 'count' href = 'access.php'>" . img('set_mini.png') . " Настройки</a> ";
echo "<a class = 'count' href = 'invite.php'>Пригласить друга</a><br/>";
echo "</div>";
}
if ($k_page > 1) {
str('?id=' . $ank['id'] . '&', $k_page, $page);
}
require_once H . 'sys/inc/tfoot.php';