Файл: user/friends/index.php
Строк: 147
<?php
/* DCMS Special
* Дата последнего редактирования 14.12.2015
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/{$inc}.php";
}
only_reg();
$set['title'] = 'Друзья';
require_once H . 'sys/inc/thead.php';
if (isset($_GET['id'])) {
$sid = intval($_GET['id']);
} else {
$sid = $user['id'];
}
$ank = get_user($sid);
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 = 'alert alert-danger'>";
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 = 'alert alert-danger'>";
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 = 'alert alert-danger' action = '' method = 'post'>";
echo "Список друзей пользователя <b>$ank[nick]</b> доступен только по паролю:<br/>";
echo "<div class='col-xs-5'><input name='password' class='form-control' type = 'password' value=''/></div>";
echo "<button class = 'btn btn-default' name = 'submited'>Войти</button>";
echo "</form>";
require_once H . 'sys/inc/tfoot.php';
exit();
}
}
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li><a href='/info.php?id=$ank[id]'>$ank[nick]</a></li>";
echo "<li class='active'>Друзья</li>";
echo "</ol>";
$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 active'>Друзья <span class='label label-default'>$k_post</span></a></li>";
if (isset($user) && $user['id'] == $ank['id']) {
echo "<li class='nav-item'><a class='nav-link' href='new.php'>Заявки <span class='label label-default'>$k_z</span></a></li>";
}
echo "<li class='nav-item'><a class='nav-link' href='online.php?id=$ank[id]'>Онлайн <span class='label label-default'>$k_online</span></a></li>";
echo "</ul>";
echo "</div>";
if ($k_post == 0) {
echo "<div class='card-block'>";
echo "<i class='fa fa-info-circle fa-fw'></i> Нет результатов";
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)) {
$friends = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[friends]' LIMIT 1"));
echo "<div class='card-block'>";
echo "<table><tr><td class='icon14'>";
avatar($friends['id'], '48');
echo "</td><td class='null'>";
if ($ank['id'] == $user['id']) {
echo "<span style='float:right' id='hides'>";
echo "<a href='/user/friends/new.php?del=$friends[id]' title='Удалить'><i class='fa fa-trash-o fa-fw'></i></a>";
echo "</span>";
}
user($friends['id']);
echo "<br />";
if (isset($user) && $user['id'] == $friends['id']) {
echo "<font color='grey'><i class='fa fa-envelope fa-fw'></i> Сообщение</font>";
} else {
echo "<a href = '/user/mail/messageList.php?contact=$friends[id]'><i class='fa fa-envelope fa-fw'></i> Сообщение</a>";
}
echo "</td></tr></table></div>";
}
if (isset($user) && $user['id'] == $ank['id']) {
echo "<div class = 'card-block'>";
echo "<a href = 'access.php'><span class='fa fa-cog fa-fw'></span> Настройки</a><br />";
echo "<a href = 'invite.php'><span class='fa fa-hand-pointer-o fa-fw'></span> Пригласить друга</a><br/>";
echo "</div>";
}
if ($k_page > 1) {
str('?id=' . $ank['id'] . '&', $k_page, $page);
}
echo "</div>";
require_once H . 'sys/inc/tfoot.php';