Файл: user/links/index.php
Строк: 379
<?php
/* DCMS S (Special)
* Версия файла 0.0.1
* Дата последнего редактирования 24.10.2015
* Модифицировал densnet
*/
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';
if (!isset($user)) {
header("Location: /aut.php");
}
if (isset($_GET['admin']) && $user['level'] >= 3) {
$set['title'] = 'Панель ссылок';
require_once H . 'sys/inc/thead.php';
aut();
err();
$opendiricon = opendir(H . 'style/icons');
while ($icons = readdir($opendiricon)) {
if (preg_match('#^.|default.png#', $icons)) {
continue;
}
$icon[] = $icons;
}
closedir($opendiricon);
if (isset($_GET['new'])) {
if (isset($_POST['name']) && isset($_POST['sname']) && isset($_POST['url']) && isset($_POST['icon'])) {
$name = $_POST['name'];
$sname = $_POST['sname'];
$url = $_POST['url'];
$icon = preg_replace('#[^a-z0-9 _-.]#i', null, $_POST['icon']);
mysql_query("INSERT INTO `links_foot` (`name`, `sname`, `url`, `icon`) VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($sname) . "', '$url', '$icon')");
$_SESSION['new'] = 1;
header("location: ?admin");
exit;
}
echo "<form class = 'comm' method='post' action=''>n";
echo "Название:<br />";
echo "<input name = 'name' type = 'text' value = '' /><br />";
echo "Сокращённое название:<br />";
echo "<input name = 'sname' type = 'text' value = '' /><br />";
echo "Ссылка:<br />";
echo "<input name = 'url' type = 'text' value = '/' /><br />";
echo "Иконка:<br />";
echo "<select name = 'icon'>";
echo "<option value = 'marker.png'>По умолчанию</option>";
for ($i = 0; $i < sizeof($icon); $i++) {
echo "<option value = '$icon[$i]'>$icon[$i]</option>";
}
echo "</select><br />";
echo "<button name = 'ok' class = 'button-green'>Добавить</button>";
echo "</form>";
echo "<div class = 'comm'><a href = '?admin' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit;
} elseif (isset($_GET['edit']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `links_foot` WHERE `id` = '" . intval($_GET['edit']) . "' LIMIT 1"), 0) != 0) {
$link = mysql_fetch_array(mysql_query("SELECT * FROM `links_foot` WHERE `id` = '" . intval($_GET['edit']) . "' LIMIT 1"));
if (isset($_POST['name']) && isset($_POST['sname']) && isset($_POST['url']) && isset($_POST['icon'])) {
$name = $_POST['name'];
$sname = $_POST['sname'];
$url = $_POST['url'];
$icon = preg_replace('#[^a-z0-9 _-.]#i', null, $_POST['icon']);
mysql_query("UPDATE `links_foot` SET `name` = '" . mysql_real_escape_string($name) . "', `sname` = '$sname', `url` = '$url', `icon` = '$icon' WHERE `id` = '$link[id]' LIMIT 1");
$_SESSION['edit'] = 1;
header("location: ?admin");
exit;
}
echo "<form class = 'comm' method = 'POST' action = '?admin&edit=$link[id]&ok'>";
echo "Название:<br />";
echo "<input name = 'name' type = 'text' value = '$link[name]' /><br />";
echo "Сокращённое название:<br />";
echo "<input name = 'sname' type = 'text' value = '$link[sname]' /><br />";
echo "Ссылка:<br />";
echo "<input name = 'url' type = 'text' value = '$link[url]' /><br />";
echo "Иконка:<br />";
echo "<select name = 'icon'>n";
echo "<option value = 'marker.png'>По умолчанию</option>";
for ($i = 0; $i < sizeof($icon); $i++) {
echo "<option value = '$icon[$i]'" . ($link['icon'] == $icon[$i] ? " selected='selected'" : null) . ">$icon[$i]</option>n";
}
echo "</select><br />";
echo "<button name = 'ok' class = 'button-green'>Сохранить</button>";
echo "</form>";
echo "<div class = 'comm'><a href = '?admin' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit;
} elseif (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `links_foot` WHERE `id` = '" . intval($_GET['del']) . "' LIMIT 1"), 0) != 0) {
$link = mysql_fetch_array(mysql_query("SELECT * FROM `links_foot` WHERE `id` = '" . intval($_GET['del']) . "' LIMIT 1"));
if (isset($_GET['ok'])) {
mysql_query("DELETE FROM `links_foot` WHERE `id` = '$link[id]'");
mysql_query("DELETE FROM `links_foot_user` WHERE `id_link` = '$link[id]'");
$_SESSION['del'] = 1;
header("location: ?admin");
exit;
}
echo "<div class = 'errs'>";
echo "Вы уверены, что хотите удалить эту ссылку?<br />";
echo "<a class = 'add' href = '?admin&del=$link[id]&ok'>Да</a> <a class = 'add' href = '?admin'>Нет</a>";
echo "</div>";
echo "<div class = 'comm'><a href = '?admin' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
if (isset($_SESSION['new'])) {
echo "<div class = 'msgs'>";
echo "Ссылка успешно добавлена";
echo "</div>";
unset($_SESSION['new']);
}
if (isset($_SESSION['edit'])) {
echo "<div class = 'msgs'>";
echo "Ссылка успешно изменена";
echo "</div>";
unset($_SESSION['edit']);
}
if (isset($_SESSION['del'])) {
echo "<div class = 'msgs'>";
echo "Ссылка успешно удалена";
echo "</div>";
unset($_SESSION['del']);
}
echo "<div class = 'comm'><a href = '?admin&new' style = 'color: #88C057;'><img src = '/style/icons/plus.png'/> Добавить ссылку</a></div>";
$links = mysql_query("SELECT * FROM `links_foot` ORDER BY `name` DESC");
if (mysql_num_rows($links) == 0) {
echo "<div class = 'comm'>";
echo "<img src = '/style/icons/error.png'/> Нет ссылок";
echo "</div>";
}
while ($post = mysql_fetch_array($links)) {
echo "<table class = 'comm'><tr><td class = 'null'>";
echo "<div style = 'float: right;' id = 'hide'>";
echo "<a href = '?admin&edit=$post[id]' title = 'Редактировать ссылку'><img src = '/style/icons/set.png'/></a> ";
echo "<a href = '?admin&del=$post[id]' title = 'Удалить ссылку'><img src = '/style/icons/del.png'/></a>";
echo "</div>";
echo "<img src = '/style/icons/$post[icon]' /> <b>$post[name]</b> - $post[sname] ($post[url])";
echo "</td></tr></table>";
}
echo "<div class = 'comm'><a href = '/user/links/' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
/* * *************************** */
$set['title'] = 'Нижние ссылки';
require_once H . 'sys/inc/thead.php';
title();
aut();
err();
if (isset($_GET['add'])) {
if (isset($_GET['link']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `links_foot` WHERE `id` = '" . intval($_GET['link']) . "' LIMIT 1"), 0) != 0) {
$link = mysql_fetch_array(mysql_query("SELECT * FROM `links_foot` WHERE `id` = '" . intval($_GET['link']) . "' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `links_foot_user` WHERE `id_link` = '$link[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
$pos = mysql_result(mysql_query("SELECT MAX(`pos`) FROM `links_foot_user` WHERE `id_user` = '$user[id]'"), 0) + 1;
mysql_query("INSERT INTO `links_foot_user` (`id_link`, `id_user`, `pos`) VALUES ('$link[id]', '$user[id]', '$pos')");
$_SESSION['new_user'] = 1;
}
header("location: /user/links/");
exit;
}
$links = mysql_query("SELECT * FROM `links_foot` ORDER BY `name` DESC");
$cr = 0;
while ($post = mysql_fetch_array($links)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `links_foot_user` WHERE `id_link` = '$post[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
$cr++;
echo "<div class = 'comm'>";
echo "<img src = '/style/icons/$post[icon]'/> <a href = '?add&link=$post[id]'><b>$post[name]</b> - $post[sname]</a><br />";
echo "</div>";
}
}
if ($cr == 0) {
echo "<div class = 'errs'>";
echo "<img src = '/style/icons/error.png'/> Нет результатов";
echo "</div>";
}
echo "<div class = 'comm'><a href = '/user/links/' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Вернуться</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit;
} elseif (isset($_GET['up'])) {
$link = mysql_fetch_assoc(mysql_query("SELECT * FROM `links_foot_user` WHERE `id` = '" . intval($_GET['up']) . "' AND `id_user` = '$user[id]' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `links_foot_user` WHERE `pos` < '$link[pos]' AND `id_user` = '$user[id]' LIMIT 1"), 0) != 0) {
mysql_query("UPDATE `links_foot_user` SET `pos` = '" . ($link['pos']) . "' WHERE `pos` = '" . ($link['pos'] - 1) . "' AND `id_user` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `links_foot_user` SET `pos` = '" . ($link['pos'] - 1) . "' WHERE `id` = '" . intval($_GET['up']) . "' AND `id_user` = '$user[id]' LIMIT 1");
$_SESSION['up'] = 1;
header("location: /user/links/");
} else {
header("Location: /user/links/");
}
} elseif (isset($_GET['down'])) {
$link = mysql_fetch_assoc(mysql_query("SELECT * FROM `links_foot_user` WHERE `id` = '" . intval($_GET['down']) . "' AND `id_user` = '$user[id]' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `links_foot_user` WHERE `pos` > '$link[pos]' AND `id_user` = '$user[id]' LIMIT 1"), 0) != 0) {
mysql_query("UPDATE `links_foot_user` SET `pos` = '" . ($link['pos']) . "' WHERE `pos` = '" . ($link['pos'] + 1) . "' AND `id_user` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `links_foot_user` SET `pos` = '" . ($link['pos'] + 1) . "' WHERE `id` = '" . intval($_GET['down']) . "' AND `id_user` = '$user[id]' LIMIT 1");
$_SESSION['down'] = 1;
header("location: /user/links/");
} else {
header("Location: /user/links/");
}
} elseif (isset($_GET['del'])) {
$link = mysql_fetch_array(mysql_query("SELECT * FROM `links_foot_user` WHERE `id` = '" . intval($_GET['del']) . "' AND `id_user` = '$user[id]' LIMIT 1"));
$links = mysql_query("SELECT * FROM `links_foot_user` WHERE `id_user` = '$user[id]' AND `pos` > '$link[pos]' ORDER BY `pos` ASC");
while ($p = mysql_fetch_array($links)) {
mysql_query("UPDATE `links_foot_user` SET `pos` = '" . ($p['pos'] - 1) . "' WHERE `id` = '$p[id]' LIMIT 1");
}
mysql_query("DELETE FROM `links_foot_user` WHERE `id` = '$link[id]' AND `id_user` = '$user[id]'");
$_SESSION['del_user'] = 1;
header("Location: ?");
} elseif (isset($_GET['show_icons'])) {
mysql_query("UPDATE `user` SET `show_foot_type` = 'icons' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['show_icons'] = 1;
header("Location: ?");
} elseif (isset($_GET['show_text'])) {
mysql_query("UPDATE `user` SET `show_foot_type` = 'text' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['show_text'] = 1;
header("Location: ?");
} elseif (isset($_GET['show_on'])) {
mysql_query("UPDATE `user` SET `show_foot` = 'on' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['show_on'] = 1;
header("Location: ?");
} elseif (isset($_GET['show_off'])) {
mysql_query("UPDATE `user` SET `show_foot` = 'off' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['show_off'] = 1;
header("Location: ?");
} elseif (isset($_GET['show_left'])) {
mysql_query("UPDATE `user` SET `foot_sit` = 'left' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['show_left'] = 1;
header("Location: ?");
} elseif (isset($_GET['show_center'])) {
mysql_query("UPDATE `user` SET `foot_sit` = 'center' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['show_center'] = 1;
header("Location: ?");
} elseif (isset($_GET['show_right'])) {
mysql_query("UPDATE `user` SET `foot_sit` = 'right' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['show_right'] = 1;
header("Location: ?");
}
if (isset($_SESSION['new_user'])) {
echo "<div class = 'msgs'>";
echo "Ссылка успешно добавлена";
echo "</div>";
unset($_SESSION['new_user']);
}
if (isset($_SESSION['up'])) {
echo "<div class = 'msgs'>";
echo "Ссылка перемещена выше";
echo "</div>";
unset($_SESSION['up']);
}
if (isset($_SESSION['down'])) {
echo "<div class = 'msgs'>";
echo "Ссылка перемещена ниже";
echo "</div>";
unset($_SESSION['down']);
}
if (isset($_SESSION['del_user'])) {
echo "<div class = 'msgs'>";
echo "Ссылка успешно удалена";
echo "</div>";
unset($_SESSION['del_user']);
}
if (isset($_SESSION['show_icons'])) {
echo "<div class = 'msgs'>";
echo "Включен показ ссылок ввиде иконок";
echo "</div>";
unset($_SESSION['show_icons']);
}
if (isset($_SESSION['show_text'])) {
echo "<div class = 'msgs'>";
echo "Включен показ ссылок ввиде текста";
echo "</div>";
unset($_SESSION['show_text']);
}
if (isset($_SESSION['show_on'])) {
echo "<div class = 'msgs'>";
echo "Показ нижних ссылок успешно включен";
echo "</div>";
unset($_SESSION['show_on']);
}
if (isset($_SESSION['show_off'])) {
echo "<div class = 'msgs'>";
echo "Показ нижних ссылок успешно выключен";
echo "</div>";
unset($_SESSION['show_off']);
}
if (isset($_SESSION['show_left'])) {
echo "<div class = 'msgs'>";
echo "Включен показ ссылок слева";
echo "</div>";
unset($_SESSION['show_left']);
}
if (isset($_SESSION['show_center'])) {
echo "<div class = 'msgs'>";
echo "Включен показ ссылок в центре";
echo "</div>";
unset($_SESSION['show_center']);
}
if (isset($_SESSION['show_right'])) {
echo "<div class = 'msg'>";
echo "Включен показ ссылок справа";
echo "</div>";
unset($_SESSION['show_right']);
}
if ($user['level'] >= 3) {
echo "<div class = 'comm'><a href = '?admin'>";
echo "<img src = '/style/icons/setting.png'/> <b>Панель управления ссылками</b>";
echo "</a></div>";
}
echo "<div class = 'comm'><a href = '?add' style = 'color: #88C057;'><img src = '/style/icons/plus.png'/> Добавить ссылку</a></div>";
$links = mysql_query("SELECT * FROM `links_foot_user` WHERE `id_user` = '$user[id]' ORDER BY `pos` ASC");
if (mysql_num_rows($links) == 0) {
echo "<div class = 'errs'>";
echo "<img src = '/style/icons/error.png'/> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_array($links)) {
echo "<div class = 'comm'>";
$link = mysql_fetch_array(mysql_query("SELECT * FROM `links_foot` WHERE `id` = '$post[id_link]' LIMIT 1"));
echo "<div style = 'float: right;' id = 'hide'>";
echo "<a href = '?up=$post[id]' title = 'Поднять выше'><img src = '/style/icons/up.png'/></a> ";
echo "<a href = '?down=$post[id]' title = 'Опустить ниже'><img src = '/style/icons/down.png'/></a> ";
echo "<a href = '?del=$post[id]' title = 'Удалить ссылку'><img src = '/style/icons/del.png'/></a>";
echo "</div>";
echo "<img src = '/style/icons/$link[icon]' /> <b>$link[name]</b> - $link[sname]";
echo "</div>";
}
echo "<div class = 'comm'>";
echo "" . ($user['show_foot'] == 'on' ? '<a href = "?show_off" style = "color:red">Выключить панель ссылок</a>' : '<a href = "?show_on" style = "color:green">Включить нижнее меню</a>') . "";
echo "</div><div class = 'comm'>";
echo "Вид ссылок: " . ($user['show_foot_type'] == 'icons' ? 'Графика' : '<a href = "?show_icons">Графика</a>') . " | " . ($user['show_foot_type'] == 'text' ? 'Текст' : '<a href = "?show_text">Текст</a>');
echo "</div><div class = 'comm'>";
echo "Расположение нижнего меню:<br /> " . ($user['foot_sit'] == 'left' ? 'Слева' : '<a href = "?show_left">Слева</a>') . " | " . ($user['foot_sit'] == 'center' ? 'В центре' : '<a href = "?show_center">В центре</a>') . " | " . ($user['foot_sit'] == 'right' ? 'Справа' : '<a href = "?show_right">Справа</a>');
echo "</div><div class = 'comm'><a href = '/umenu.php' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Кабинет</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit;