File size: 11.63Kb
<?
/*
=============================================
Движок: SHCMS Engine
=============================================
Название файла: SHCMS Engine Редактор Левого Меню
=============================================
Official website: http://shcms.ru
=============================================
*/
define('SHCMS', true);
include_once'../system/inc/basic_settings.php';
$shcmsengine['title'] = 'SHCMS Engine - Редактор Левого Меню';
include_once'../template/head.php';
registrat();
$adminka ->admin();
if($_GET['id']){$id_menu = $_GET['id'];}
$menuli = mysql_fetch_array(mysql_query("SELECT * FROM `left_menu` WHERE `id` = '".$id_menu."'"));
switch($act):
default:
$private = mysql_query("SELECT * FROM `left_menu` ORDER BY `mesto` ASC");
while($privates = mysql_fetch_array($private)) {
if($privates['razdel'] == 'razd') {
echo "<div class='maintext'><strong>$privates[name] <span style='font-size:9px;'>[раздел]</span></strong>";
}else {
echo "<div class='posts'><strong>$privates[name] <span style='font-size:9px;'><a href='$privates[link]'>[перейти]</a></span></strong>";
}
if($privates['close'] == 0) {
echo '<div style="color:green;" class="maintime mainrazd">Доступен всем</div>';
}else {
echo '<div style="color:red;" class="maintime mainrazd">Доступ закрыт</div>';
}
echo "
<div style='text-align:right;'>";
if($privates['close'] == 2) {
echo "<a title='Открыть' href='?id_open=$privates[id]&act=open_menu'><img width='12px' height='12' src='/template/icon/open.png'/></a>";}
elseif($privates['close'] == 1) {
echo "<a title='Скрыть' href='?id_close=$privates[id]&act=close_menu'><img width='12px' height='12' src='/template/icon/close.png'/></a>";}
echo "
<a title='Редактировать' href='?edit_id=$privates[id]&act=edit'><img width='12px' height='12' src='/template/icon/edit.png'></a>
<a title='Перенести вниз' href='?id=$privates[id]&act=down'><img width='12px' height='12' src='/template/icon/down.png'></a>
<a title='Перенести вверх' href='?id=$privates[id]&act=up'><img width='12px' height='12' src='/template/icon/up.png'></a>
<a title='Удаление раздела' href='?id_delete=$privates[id]&act=delete'><img width='12px' height='12' src='/template/icon/delete.png'></a>
</div>";
if($privates['themes'] != 'razdel') {
echo '</div>';
}else {
echo '</div>';
}
}
echo '<div class="maintitle mainrazd">Навигация</div>';
echo "<div class='maintext'><div class='posts'><img src='/template/icon/new_doc.png'><a href='?act=new_razd'>Добавить раздел</a></div>";
echo "<div class='posts'><img src='/template/icon/new_doc.png'><a href='?act=new_links'>Добавить ссылку</a></div></div>";
break;
case 'close_menu':
if($_GET['id_close']){$id_close = $_GET['id_close'];}
$menuclose = mysql_fetch_array(mysql_query("SELECT * FROM `left_menu` WHERE `id` = '$id_close'"));
$close = mysql_query("UPDATE `left_menu` SET `close` = '1' WHERE `id`='$id_close'");
if($close == true)
{
messag("Раздел $menuclose[name] успешно скрыт");
header('Refresh: 1; url=?act=edit_razd');
}
else
{
errors("Ошибка при закрытие файла $menuclose[name]");
header('Refresh: 1; url=?act=edit_razd' );
}
break;
case 'open_menu':
if($_GET['id_open']){$id_open = $_GET['id_open'];}
$menuclose = mysql_fetch_array(mysql_query("SELECT * FROM `left_menu` WHERE `id` = '$id_open'"));
$close = mysql_query("UPDATE `left_menu` SET `close` = '0' WHERE `id`='$id_open'");
if($close == true)
{
messag("Раздел $menuclose[name] успешно открыт");
header('Refresh: 1; url=?act=edit_razd');
}
else
{
errors("Ошибка при открытие раздела $menuclose[name]");
header('Refresh: 1; url=?act=edit_razd' );
}
break;
case 'up':
mysql_query("UPDATE `left_menu` SET `mesto` = '".($menuli['mesto'])."' WHERE `mesto` = '".($menuli['mesto']-1)."' LIMIT 1");
mysql_query("UPDATE `left_menu` SET `mesto` = '".($menuli['mesto']-1)."' WHERE `id` = '".$id_menu."' LIMIT 1");
messag($menuli['name'].' перенесен вверх');
header('Refresh: 1; url=?act=edit_razd');
break;
case'down':
mysql_query("UPDATE `left_menu` SET `mesto` = '".($menuli['mesto'])."' WHERE `mesto` = '".($menuli['mesto']+1)."' LIMIT 1");
mysql_query("UPDATE `left_menu` SET `mesto` = '".($menuli['mesto']+1)."' WHERE `id` = '".$id_menu."' LIMIT 1");
messag($menuli['name'].' перенесен вниз');
header('Refresh: 1; url=?act=edit_razd');
break;
case 'edit':
if($_GET['edit_id']){$edit_id = $_GET['edit_id'];}
$editors = mysql_fetch_array(mysql_query("SELECT * FROM `left_menu` WHERE `id` = '$edit_id'"));
if($_POST['submit']) {
$submit = $_POST['submit'];}
if(isset($submit)) {
if($_POST['name']) {
$name = $_POST['name'];}
if($_POST['link']) {
$link = $_POST['link'];}
if($_POST['icons_menu']) {
$icons_menu = $_POST['icons_menu'];}
if($_POST['mesto']) {
$mesto = $_POST['mesto'];}
if(empty($name))
{
echo '<div class="errors">Введите название</div>';
header('Refresh: 1; url=?edit_id='.$edit_id.'&act=edit' );
include_once'../template/foot.php';
exit();
}
if($editors['razdel'] != 'razd') {
if(empty($link))
{
echo '<div class="errors">Введите пусть к папке</div>';
header('Refresh: 1; url=?edit_id='.$edit_id.'&act=edit' );
include_once'../template/foot.php';
exit();
}
if(empty($mesto))
{
echo '<div class="errors">Укажите места ссылки</div>';
header('Refresh: 1; url=?edit_id='.$edit_id.'&act=edit' );
include_once'../template/foot.php';
exit();
}
}
$edit_menu = mysql_query("UPDATE `left_menu` SET `name` = '$name', `icons` = '$icons_menu',`mesto`='$mesto', `link` = '$link' WHERE `id`= '$edit_id'");
if($edit_menu == true){
messag("Раздел $editors[name] успешно изменено");
header('Refresh: 1; url=?edit_id='.$edit_id.'&act=edit' );
}else
{
errors('Возникла ошика при редактирование раздела '.$editors['name'].'');
header('Refresh: 1; url=?edit_id='.$edit_id.'&act=edit' );
}
}
echo '<form action="" method="post">';
echo 'Название:<br/><input type="text" name="name" value='.$editors['name'].'>';
if($editors['razdel'] != 'razd') {
echo '<br/>Путь:<br/><input type="text" name="link" value='.$editors['link'].'>';
}
echo '<br/>Места:<br/><input type="text" name="mesto" value='.$editors['mesto'].'>';
if($editors['razdel'] == 'razd') {
echo "<br/>Иконка раздела:<br />\n<select name='icons_menu'>\n";
$icons_menu = opendir(H.'template/icon/');
while ($icon_menu = readdir($icons_menu)) {
if (($icon_menu!= 'users' and $icon_menu!= 'Thumbs.db' and $icon_menu!= '.' and $icon_menu!= '..')) {
echo '<option' . ($editors['icons'] == $icon_menu ? ' selected="selected">' : '>') . $icon_menu . '</option>';
}
}
closedir($icons_menu);
echo '</select>';
}echo '<br/>';
echo '<input type="submit" name="submit">';
echo SHCMS_core::link_shcms('<div class="link_str">Назад</div>','?act=edit_razd');
break;
case 'prosm_icon':
$dir_them = opendir('../template/icon/');
while ($des_them = readdir($dir_them)) {
if (($des_them != 'users' and $des_them != 'Thumbs.db' and $des_them != '.' and $des_them != '..' and $des_them != 'mail')) {
echo '<div class="posts"><img src="../template/icon/'.$des_them.'"> '.$des_them.'</div>';
}}
closedir($dir_them);
break;
case 'new_razd':
$editors = mysql_fetch_array(mysql_query("SELECT * FROM `left_menu` ORDER BY `mesto` DESC"));
if($_POST['submit']) {
$submit = $_POST['submit'];}
if(isset($submit)) {
if($_POST['name']) {
$name = $_POST['name'];}
if($_POST['icons_menu']) {
$icons_menu = $_POST['icons_menu'];}
if($_POST['mesto']) {
$mesto = $_POST['mesto'];}
if(empty($name))
{
echo '<div class="errors">Введите название</div>';
header('Refresh: 1; url=?' );
include_once'../template/foot.php';
exit();
}
$new_menu = mysql_query("INSERT INTO `left_menu` (`name`,`icons`,`mesto`,`razdel`) VALUES ('$name','$icons_menu','".($editors['mesto']+1) ."','razd')");
if($new_menu == true){
messag("Раздел $editors[name] успешно создан");
header('Refresh: 1; url=?' );
}else
{
errors('Возникла ошика при создании раздела '.$editors['name'].'');
header('Refresh: 1; url=?' );
}
}
echo '<form action="" method="post">';
echo 'Название:<br/><input type="text" name="name">';
echo '<br/>Места:<br/><input type="text" name="mesto" value="'.($editors['mesto']+1) .'" disabled="disabled">';
echo "<br/>Иконка раздела:[<a href='?act=prosm_icon'>Просмотр icon</a>]<br />\n<select name='icons_menu'>\n";
$icons_menu = opendir(H.'template/icon/');
while ($icon_menu = readdir($icons_menu)) {
if (($icon_menu!= 'users' and $icon_menu!= 'Thumbs.db' and $icon_menu!= '.' and $icon_menu!= '..')) {
echo '<option>'.$icon_menu . '</option>';
}
}
closedir($icons_menu);
echo '</select><br/>';
echo '<input type="submit" name="submit">';
break;
case 'new_links':
$new_links = mysql_fetch_array(mysql_query("SELECT * FROM `left_menu` ORDER BY `mesto` DESC"));
if($_POST['submit']) {
$submit = $_POST['submit'];}
if(isset($submit)) {
if($_POST['name']) {
$name = $_POST['name'];}
if($_POST['link']) {
$link = $_POST['link'];}
if($_POST['mesto']) {
$mesto = $_POST['mesto'];}
if(empty($name))
{
echo '<div class="errors">Введите название</div>';
header('Refresh: 1; url=?' );
include_once'../template/foot.php';
exit();
}
if(empty($link))
{
echo '<div class="errors">Введите путь файла</div>';
header('Refresh: 1; url=?' );
include_once'../template/foot.php';
exit();
}
$new_menu = mysql_query("INSERT INTO `left_menu` (`name`,`link`,`mesto`,`razdel`) VALUES ('$name','$link','".($new_links['mesto']+1) ."','link')");
if($new_menu == true){
messag("Раздел $name успешно создан");
header('Refresh: 1; url=?' );
}else
{
errors('Возникла ошика при создании раздела '.$name.'');
header('Refresh: 1; url=?' );
}
}
echo '<form action="" method="post">';
echo 'Название:<br/><input type="text" name="name"><br/>';
echo 'Путь:<br/><input type="text" name="link"><br/>';
echo 'Места:<br/><input type="text" name="mesto" value="'.($new_links['mesto']+1) .'" disabled="disabled"><br/>';
echo '<input type="submit" name="submit">';
break;
case 'delete':
if($_GET['id_delete']){$id_delete = $_GET['id_delete'];}
$del_razel = mysql_fetch_array(mysql_query("SELECT * FROM `left_menu` WHERE `id`= '$id_delete'"));
$delete = mysql_query("DELETE FROM `left_menu` WHERE `id` = '$id_delete'");
mysql_query("OPTIMIZE TABLE `left_menu`");
if($delete == true){
messag('Раздел '.$del_razel['name'].' успешно удален');
header('Refresh: 1; url=?' );
}else {
errors('Возникла ошибка при удаление раздела '.$del_razel['name'].'');
header('Refresh: 1; url=?' );
}
break;
endswitch;
include_once'../template/foot.php';