Файл: user/links/index.php
Строк: 327
<?php
/* DCMS Special
* Дата последнего редактирования 15.12.2015
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/{$inc}.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();
if (isset($_GET['new'])) {
if (isset($_POST['name']) && isset($_POST['url']) && isset($_POST['icon'])) {
$name = $_POST['name'];
$url = $_POST['url'];
$icon = preg_replace('#[^a-z0-9 _-.]#i', null, $_POST['icon']);
mysql_query("INSERT INTO `links_foot` (`name`, `url`, `icon`) VALUES ('" . mysql_real_escape_string($name) . "', '$url', '$icon')");
$_SESSION['new'] = 1;
header("location: ?admin");
exit;
}
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li><a href='/?umenu'>Кабинет</a></li>";
echo "<li><a href='/user/links/'>Панель навигации</a></li>";
echo "<li><a href='?admin'>Управление</a></li>";
echo "<li class='active'>Добавление ссылок</li>";
echo "</ol>";
echo "<form class='list-group-item' method='post' action=''>n";
echo "Название:<br />";
echo "<input name='name' class='form-control' type='text' value='' />";
echo "Ссылка:<br />";
echo "<input name='url' class='form-control' type='text' value='/' />";
echo "Иконка:<br />";
echo "<input name='icon' class='form-control' type='text' value='fa fa-' />";
echo "Иконки - <a href='https://fortawesome.github.io/Font-Awesome/icons/'>https://fortawesome.github.io/Font-Awesome/icons/</a><br />";
echo "<button name='ok' class='btn btn-success'>Добавить</button>";
echo "</form>";
echo "<div class='list-group-item'><a href='?admin'><span class='fa fa-arrow-left fa-fw'></span> Назад</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['url']) && isset($_POST['icon'])) {
$name = $_POST['name'];
$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) . "', `url` = '$url', `icon` = '$icon' WHERE `id` = '$link[id]' LIMIT 1");
$_SESSION['edit'] = 1;
header("location: ?admin");
exit;
}
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li><a href='/?umenu'>Кабинет</a></li>";
echo "<li><a href='/user/links/'>Панель навигации</a></li>";
echo "<li><a href='?admin'>Управление</a></li>";
echo "<li class='active'>Редактирование</li>";
echo "</ol>";
echo "<form class='list-group-item' method='POST' action='?admin&edit=$link[id]&ok'>";
echo "Название:<br />";
echo "<input name='name' class='form-control' type='text' value='$link[name]' />";
echo "Ссылка:<br />";
echo "<input name='url' class='form-control' type='text' value='$link[url]' />";
echo "Иконка:<br />";
echo "<input name='icon' class='form-control' type='text' value='$link[icon]' />";
echo "Иконки - <a href='https://fortawesome.github.io/Font-Awesome/icons/'>https://fortawesome.github.io/Font-Awesome/icons/</a><br />";
echo "<button name='ok' class='btn btn-success'><i class='fa fa-save fa-fw'></i> Сохранить</button>";
echo "</form>";
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 "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li><a href='/?umenu'>Кабинет</a></li>";
echo "<li><a href='/user/links/'>Панель навигации</a></li>";
echo "<li><a href='?admin'>Управление</a></li>";
echo "<li class='active'>Удаление</li>";
echo "</ol>";
echo "<div class='list-group-item'>";
echo "Вы уверены, что хотите удалить эту ссылку?<br />";
echo "<a class='btn btn-success' href='?admin&del=$link[id]&ok'>Да</a> <a class='btn btn-success' href = '?admin'>Нет</a>";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
if (isset($_SESSION['new'])) {
echo "<div class = 'alert alert-success'>";
echo "Ссылка успешно добавлена";
echo "</div>";
unset($_SESSION['new']);
}
if (isset($_SESSION['edit'])) {
echo "<div class = 'alert alert-success'>";
echo "Ссылка успешно изменена";
echo "</div>";
unset($_SESSION['edit']);
}
if (isset($_SESSION['del'])) {
echo "<div class = 'alert alert-success'>";
echo "Ссылка успешно удалена";
echo "</div>";
unset($_SESSION['del']);
}
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li><a href='/?umenu'>Кабинет</a></li>";
echo "<li><a href='/user/links/'>Панель навигации</a></li>";
echo "<li class='active'>Управление</li>";
echo "</ol>";
echo "<a class='list-group-item list-group-item-warning' href='?admin&new'><i class='fa fa-plus fa-fw'></i> Добавить ссылку</a>";
$links = mysql_query("SELECT * FROM `links_foot` ORDER BY `name` DESC");
if (mysql_num_rows($links) == 0) {
echo "<div class='list-group-item'>";
echo "<span class='fa fa-info-circle fa-fw'></span> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_array($links)) {
echo "<div class='list-group-item'>";
echo "<div style='float: right;' id='hides'>";
echo "<a href='?admin&edit=$post[id]' title='Редактировать ссылку'><i class='fa fa-cog fa-fw'></i></a> ";
echo "<a href='?admin&del=$post[id]' title='Удалить ссылку'><i class='fa fa-trash-o fa-fw'></i></a>";
echo "</div>";
echo "<i class='$post[icon] fa-fw'></i> $post[name] ($post[url])";
echo "</div>";
}
require_once H . 'sys/inc/tfoot.php';
exit;
}
/* * *************************** */
$set['title'] = 'Нижние ссылки';
require_once H . 'sys/inc/thead.php';
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;
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li><a href='/?umenu'>Кабинет</a></li>";
echo "<li><a href='/user/links/'>Панель навигации</a></li>";
echo "<li class='active'>Добавление ссылок</li>";
echo "</ol>";
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 "<a class='list-group-item' href='?add&link=$post[id]'><i class='$post[icon] fa-fw'></i> $post[name]</a>";
}
}
if ($cr == 0) {
echo "<div class='list-group-item'>";
echo "<span class='fa fa-info-circle fa-fw'></span> Нет ссылок";
echo "</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 = 'alert alert-success'>";
echo "Ссылка успешно добавлена";
echo "</div>";
unset($_SESSION['new_user']);
}
if (isset($_SESSION['up'])) {
echo "<div class = 'alert alert-success'>";
echo "Ссылка перемещена выше";
echo "</div>";
unset($_SESSION['up']);
}
if (isset($_SESSION['down'])) {
echo "<div class = 'alert alert-success'>";
echo "Ссылка перемещена ниже";
echo "</div>";
unset($_SESSION['down']);
}
if (isset($_SESSION['del_user'])) {
echo "<div class = 'alert alert-success'>";
echo "Ссылка успешно удалена";
echo "</div>";
unset($_SESSION['del_user']);
}
if (isset($_SESSION['show_on'])) {
echo "<div class = 'alert alert-success'>";
echo "Показ нижних ссылок успешно включен";
echo "</div>";
unset($_SESSION['show_on']);
}
if (isset($_SESSION['show_off'])) {
echo "<div class = 'alert alert-success'>";
echo "Показ нижних ссылок успешно выключен";
echo "</div>";
unset($_SESSION['show_off']);
}
if (isset($_SESSION['show_left'])) {
echo "<div class = 'alert alert-success'>";
echo "Включен показ ссылок слева";
echo "</div>";
unset($_SESSION['show_left']);
}
if (isset($_SESSION['show_center'])) {
echo "<div class = 'alert alert-success'>";
echo "Включен показ ссылок в центре";
echo "</div>";
unset($_SESSION['show_center']);
}
if (isset($_SESSION['show_right'])) {
echo "<div class = 'alert alert-success'>";
echo "Включен показ ссылок справа";
echo "</div>";
unset($_SESSION['show_right']);
}
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li><a href='/?umenu'>Кабинет</a></li>";
echo "<li class='active'>Панель навигации</li>";
echo "</ol>";
if ($user['level'] >= 3) {
echo "<a class='list-group-item list-group-item-warning' href='?admin'><i class='fa fa-th fa-fw'></i> Управление ссылками</a>";
}
echo "<a class='list-group-item' href='?add'><i class='fa fa-plus fa-fw'></i> Добавить ссылку</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='list-group-item'>";
echo "<span class='fa fa-info-circle fa-fw'></span> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_array($links)) {
echo "<div class='list-group-item'>";
$link = mysql_fetch_array(mysql_query("SELECT * FROM `links_foot` WHERE `id` = '$post[id_link]' LIMIT 1"));
echo "<div style='float: right;' id='hides'>";
echo "<a href = '?up=$post[id]' title = 'Поднять выше'><span class='fa fa-arrow-up fa-fw'></span></a> ";
echo "<a href = '?down=$post[id]' title = 'Опустить ниже'><span class='fa fa-arrow-down fa-fw'></span></a> ";
echo "<a href = '?del=$post[id]' title = 'Удалить ссылку'><span class='fa fa-trash-o fa-fw'></span></a>";
echo "</div>";
echo "<i class='$link[icon] fa-fw'></i> $link[name]";
echo "</div>";
}
echo "" . ($user['show_foot'] == 'on' ? '<a href="?show_off" class="list-group-item"><span class="fa fa-power-off fa-fw"></span> Выключить панель навигации</a>' : '<a class="list-group-item" href="?show_on"><span class="fa fa-power-off fa-fw"></span> Включить нижнее меню</a>') . "";
require_once H . 'sys/inc/tfoot.php';
exit;