Файл: user/links/index.php
Строк: 363
<?php
/* Мод "Ссылки"
* Версия v0.0.1
* Дата последнего редактирования 20.01.2015
* Двиг 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';
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/img');
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 = 'razd' 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 sign-ins'>Добавить</button>";
echo "</form>";
echo "<a href = '?admin'><div class = 'razd'>" . img16('left.png') . " Назад</div></a>";
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 = 'razd' 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 sign-ins'>Сохранить</button>";
echo "</form>";
echo "<a href = '?admin'><div class = 'razd'>" . img16('left.png') . " Назад</div></a>";
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 /><br />";
echo "<a class = 'add' href = '?admin&del=$link[id]&ok'>Да</a> <a class = 'add' href = '?admin'>Нет</a>";
echo "</div>";
echo "<a href = '?admin'><div class = 'razd'>" . img16('left.png') . " Назад</div></a>";
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 "<a href = '?admin&new'><div class = 'razd'>" . img16('plus.png') . " Добавить ссылку</div></a>";
$links = mysql_query("SELECT * FROM `links_foot` ORDER BY `name` DESC");
if (mysql_num_rows($links) == 0) {
echo "<div class = 'errs'>";
echo img16('error.png') . " Нет ссылок";
echo "</div>";
}
while ($post = mysql_fetch_array($links)) {
echo "<table class = 'razd'><tr><td class = 'null'>";
echo "<div style = 'float: right;' id = 'hide'>";
echo "<a href = '?admin&edit=$post[id]' class = 'add' title = 'Редактировать ссылку'>" . img16('set.png') . "</a> ";
echo "<a href = '?admin&del=$post[id]' class = 'add' title = 'Удалить ссылку'>" . img16('musor.png') . "</a>";
echo "</div>";
echo img16("$post[icon]") . " <b>$post[name]</b> - $post[sname] ($post[url])";
echo "</td></tr></table>";
}
echo "<a href = '/user/links/'><div class = 'razd'>" . img16('left.png') . " Назад</div></a>";
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 = 'razd'>";
echo img16("$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 img16('error.png') . " Нет результатов";
echo "</div>";
}
echo "<a href = '/user/links/'><div class = 'razd'>" . img16('left.png') . " Вернуться</div></a>";
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 "<a href = '?admin'><div class = 'razd'>";
echo img16('set.png') . " Панель управления ссылками";
echo "</div></a>";
}
echo "<a href = '?add'><div class = 'razd'>" . img16('plus.png') . " Добавить ссылку</div></a>";
$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 img16('error.png') . " Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_array($links)) {
echo "<div class = 'razd'>";
$link = mysql_fetch_array(mysql_query("SELECT * FROM `links_foot` WHERE `id` = '$post[id_link]' LIMIT 1"));
echo "<span style = 'float: right;' id = 'hide'>";
echo "<a href = '?up=$post[id]' class = 'add' title = 'Поднять выше'>" . img16('up.png') . " </a>";
echo "<a href = '?down=$post[id]' class = 'add' title = 'Опустить ниже'>" . img16('down.png') . "</a>";
echo "<a href = '?del=$post[id]' class = 'add' title = 'Удалить ссылку'>" . img16('musor.png') . "</a>";
echo "</span>";
echo img16("$link[icon]") . " <b>$link[name]</b> - $link[sname]";
echo "</div>";
}
echo "<div class = 'razd'>";
echo "" . ($user['show_foot'] == 'on' ? '<a href = "?show_off" style = "color:yellow">' . img16("off.png") . ' Выключить панель ссылок</a>' : '<a href = "?show_on" style = "color:write">' . img16("off.png") . ' Включить нижнее меню</a>') . "";
echo "</div><div class = 'razd'>";
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 = 'razd'>";
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><a href = '/umenu.php'><div class = 'razd'>" . img16('left.png') . " Кабинет</div></a>";
require_once H . 'sys/inc/tfoot.php';
exit;