Файл: user/links/index.php
Строк: 605
<?php
/* DCMS Special
* Дата последнего редактирования 21.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 "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/?umenu'>Кабинет</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/user/links/'>Панель навигации</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='?admin'>Управление</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'>Добавление ссылок</a></li>";
echo "</ul>";
echo "</nav>";
echo "<form class='list-group-item' method='post' action=''>n";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='name' name='name' length='100' type='text' value='' class='validate'>";
echo "<label for='name'>Название</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='url' name='url' length='100' type='text' value='' class='validate'>";
echo "<label for='url'>Ссылка</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='icon' name='icon' length='100' type='text' value='' class='validate'>";
echo "<label for='icon'>Иконка</label>";
echo "</div>";
echo "</div>";
echo "<a href='https://design.google.com/icons/'>Список иконок</a><br />";
echo "<button name='ok' class='waves-effect waves-light btn'>Добавить</button>";
echo "</form>";
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 "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/?umenu'>Кабинет</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/user/links/'>Панель навигации</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='?admin'>Управление</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'>Редактирование</a></li>";
echo "</ul>";
echo "</nav>";
echo "<form class='list-group-item' method='POST' action='?admin&edit=$link[id]&ok'>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='name' name='name' length='100' type='text' value='$link[name]' class='validate'>";
echo "<label for='name'>Название</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='url' name='url' length='100' type='text' value='$link[url]' class='validate'>";
echo "<label for='url'>Ссылка</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='icon' name='icon' length='100' type='text' value='$link[icon]' class='validate'>";
echo "<label for='icon'>Иконка</label>";
echo "</div>";
echo "</div>";
echo "<a href='https://design.google.com/icons/'>Список иконок</a><br />";
echo "<button name='ok' class='waves-effect waves-light btn'><i class='material-icons'>save</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 "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/?umenu'>Кабинет</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/user/links/'>Панель навигации</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='?admin'>Управление</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'>Удаление</a></li>";
echo "</ul>";
echo "</nav>";
echo "<div class='list-group-item'>";
echo "Вы уверены, что хотите удалить эту ссылку?<br />";
echo "<a class='waves-effect waves-light btn' href='?admin&del=$link[id]&ok'>Да</a> <a class='waves-effect waves-light btn' 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 "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/?umenu'>Кабинет</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/user/links/'>Панель навигации</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='?admin'>Управление</a></li>";
echo "</ul>";
echo "</nav>";
echo "<a class='list-group-item list-group-item-warning' href='?admin&new'><i class='material-icons'>add</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' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<i class='material-icons'>feedback</i> Нет результатовn";
echo "</div>n";
}
while ($post = mysql_fetch_array($links)) {
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<div style='float: right;' id='hides'>";
echo "<a href='?admin&edit=$post[id]' title='Редактировать ссылку'><i class='material-icons'>settings</i></a> ";
echo "<a href='?admin&del=$post[id]' title='Удалить ссылку'><i class='material-icons'>delete</i></a>";
echo "</div>";
echo "<i class='material-icons'>$post[icon]</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 "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/?umenu'>Кабинет</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/user/links/'>Панель навигации</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'>Добавление ссылок</a></li>";
echo "</ul>";
echo "</nav>";
echo "<div class='collection'>";
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='material-icons'>$post[icon]</i> $post[name]</a>";
}
}
echo "</div>n";
if ($cr == 0) {
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<i class='material-icons'>feedback</i> Нет результатовn";
echo "</div>n";
}
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 "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/?umenu'>Кабинет</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/user/links/'>Панель навигации</a></li>";
echo "</ul>";
echo "</nav>";
echo "<div class='collection'>";
if ($user['level'] >= 3) {
echo "<a class='list-group-item list-group-item-warning' href='?admin'><i class='material-icons'>navigation</i> Управление ссылками</a>";
}
echo "<a class='list-group-item' href='?add'><i class='material-icons'>add</i> Добавить ссылку</a>";
echo "" . ($user['show_foot'] == 'on' ? '<a href="?show_off" class="list-group-item"><i class="material-icons">power_settings_new</i> Выключить панель навигации</a>' : '<a class="list-group-item" href="?show_on"><i class="material-icons">power_settings_new</i> Включить панель навигации</a>') . "";
echo "</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='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<i class='material-icons'>feedback</i> Нет результатовn";
echo "</div>n";
}
echo "<div class='collection'>";
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 = 'Поднять выше'><i class='material-icons'>arrow_upward</i></a> ";
echo "<a href = '?down=$post[id]' title = 'Опустить ниже'><i class='material-icons'>arrow_downward</i></a> ";
echo "<a href = '?del=$post[id]' title = 'Удалить ссылку'><i class='material-icons'>delete</i></a>";
echo "</div>";
echo "<i class='material-icons'>$link[icon]</i> $link[name]";
echo "</div>";
}
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit;