Файл: user/blacklist/index.php
Строк: 145
<?php
require_once '../../sys/inc/start.php';
require_once '../../sys/inc/compress.php';
require_once '../../sys/inc/sess.php';
require_once '../../sys/inc/settings.php';
require_once '../../sys/inc/db_connect.php';
require_once '../../sys/inc/ipua.php';
require_once '../../sys/inc/fnc.php';
require_once '../../sys/inc/user.php';
only_reg();
if (isset($_POST['add_w']) && isset($_POST['nick']) && isset($_POST['mdp']) && $_POST['mdp'] == $user['pass']) {
$nick = htmlspecialchars($_POST['nick']);
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `nick` = '$nick'"));
header("Location:?add=$ank[id]");
exit;
}
if (isset($_GET['add'])) {
$set['title'] = "Чёрный список - Добавление";
require_once '../../sys/inc/thead.php';
aut();
$ank = get_user(intval($_GET['add']));
if (!$ank || $ank['id'] == 0) {
echo "Пользователь не обнаружен!";
require_once '../../sys/inc/tfoot.php';
exit;
}
if ($ank['id'] == $user['id']) {
echo "Нельзя добавлять себя в свой Чёрный список";
require_once '../../sys/inc/tfoot.php';
exit;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_blacklist` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]'"), 0) != 0) {
$id = mysql_fetch_array(mysql_query("SELECT * FROM `user_blacklist` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]'"));
header("Location:?id=$id[id]");
exit;
}
if (isset($_POST['ok']) && isset($_POST['msg']) && isset($_POST['mdp']) && $_POST['mdp'] == $user['pass']) {
if (utf8_strlen($_POST['msg']) < 1) {
$err[] = 'Укажите причину';
}
if (utf8_strlen($_POST['msg']) > 200) {
$err[] = 'Причина слишком длинная';
}
$tt = $_POST['time_to'];
if ($tt == 1 || $tt == 6 || $tt == 24 || $tt == 120 || $tt == 'forever') {
if ($tt == 'forever') {
$forever = 1;
} else {
$time_to = $time + ($tt * 3600);
}
} else {
$err[] = 'Техническая ошибка';
}
if (!isset($err)) {
mysql_query("INSERT INTO `user_blacklist` SET `id_user` = '$user[id]', `id_ank` = '$ank[id]', `time` = '$time', `msg` = '" . mysql_real_escape_string($_POST['msg']) . "'" . (isset($forever) ? ", `forever` = '1'" : ", `time_to` = '$time_to'") . "");
header("Location:?");
}
}
err();
echo "<form class = 'blok' name = 'black' method = 'POST' action = '?add=$ank[id]'>";
echo "Пользователь: ";
echo text::gradient("$ank[nick] ", "$ank[ncolor]", "$ank[ncolor2]");
echo "<br />";
echo "Причина (200 символов):<br />";
echo "<input type = 'hidden' name = 'mdp' value = '$user[pass]'/>";
echo "<textarea name = 'msg'></textarea><br />";
echo "Срок:<br />";
echo "<select name = 'time_to'>";
echo "<option value = '1' selected = 'selected'>1 ч.</option>";
echo "<option value = '6'>6 ч.</option>";
echo "<option value = '24'>24 ч.</option>";
echo "<option value = '120'>120 ч.</option>";
echo "<option value = 'forever'>Навсегда</option>";
echo "</select><br/>";
echo "<div class = 'button_blue'>";
echo "<button name = 'ok'>Сохранить изменения</button>";
echo "</div></form>";
echo "<a href = '/info.php?id=$ank[id]'><div class = 'razd'><img src = '/style/icons/left.png' /> $ank[nick]</div></a>";
require_once '../../sys/inc/tfoot.php';
exit;
} elseif (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_blacklist` WHERE `id` = '" . intval($_GET['del']) . "' AND `id_user` = '$user[id]'"), 0) != 0) {
mysql_query("DELETE FROM `user_blacklist` WHERE `id` = '" . intval($_GET['del']) . "' AND `id_user` = '$user[id]'");
header("Location:?");
exit;
} elseif (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_blacklist` WHERE `id` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]'"), 0) != 0) {
$set['title'] = "Чёрный список";
require_once '../../sys/inc/thead.php';
aut();
$id = mysql_fetch_array(mysql_query("SELECT * FROM `user_blacklist` WHERE `id` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]'"));
$ank = get_user($id['id_ank']);
$tt = $id['time_to'] - $id['time'];
echo "<div class = 'blok'>";
echo "Пользователь: ";
echo text::gradient("$ank[nick] ", "$ank[ncolor]", "$ank[ncolor2]");
echo "<br/>";
echo "Причина: " . output_text($id['msg'])."<br />";
echo "Время: " . ($id['forever'] == 0 ? "$tt ч." : "Навсегда") . "<br/>";
echo "<a href = '?del=$id[id]'><span style='text-decoration:underline;color:grey;'> Удалить</span></a><br/>";
echo "</div>";
echo "<a href = '/user/blacklist/'><div class = 'razd'><img src = '/style/icons/left.png' /> Назад</div></a>";
require_once '../../sys/inc/tfoot.php';
exit;
}
$set['title'] = "Чёрный список";
require_once '../../sys/inc/thead.php';
aut();
echo "<form class = 'blok' method = 'post'>";
echo "Логин пользователя<br/>";
echo "<input type = 'hidden' name = 'mdp' value = '$user[pass]' />";
echo "<input type = 'text' name = 'nick' value = '' /><br/>";
echo "<div class = 'button_blue'>";
echo "<button name = 'add_w'>Добавить</button>";
echo "</div></form>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user_blacklist` WHERE `id_user` = '$user[id]'"), 0);
$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 `user_blacklist` WHERE `id_user` = '$user[id]' ORDER BY `time` ASC LIMIT $start, $set[p_str]");
if ($k_post == 0) {
echo "<table class = 'blok'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет результатов";
echo "</td></tr></table>";
}
while ($post = mysql_fetch_array($q)) {
echo "<table class = 'razd'><tr><td class = 'icon14'>";
$an = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_ank]'"));
avatar($an['id'], '20');
echo "</td><td class = 'null'>";
echo "<a href = '?id=$post[id]'><b>";
echo text::gradient("$an[nick] ", "$an[ncolor]", "$an[ncolor2]");
echo "</b></a>";
echo "<div class = 'right' id = 'hide'>";
echo "<a href = '?del=$post[id]' title = 'Удалить из списка'><img src = '/style/icons/cross.png' /></a>";
echo "</div></td></tr></table>";
}
if ($k_page > 1) {
str("?", $k_page, $page);
}
require_once '../../sys/inc/tfoot.php';
exit;