Просмотр файла admin_list/categories.php

Размер файла: 5.7Kb
<?php
/*
=============================================
Движок: 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();

switch($act):
default:
echo '<div class="maintitle mainrazd">Новая категория</div>';
echo '<div class="maintext"><div class="maintext"><a href="?act=new_cat">Добавить новую категорию</a></div></div>';
$spisoc_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `uncos_category`"),0);
echo '<div class="maintitle mainrazd">Список Категорий ('.$spisoc_count.')</div>';
echo '<div class="maintext">';
$cat_spisoc = mysql_query("SELECT * FROM `uncos_category`");
while($spisoc = mysql_fetch_array($cat_spisoc)) {

echo '<div class="maintext"><STRONG>ID: '.$spisoc['id'].'</STRONG> | <a href="../uncos/categories.php?act=news&id='.$spisoc['id'].'">'.$spisoc['name'].'</a> |  <span style="font-size:11px;">'.$timedate->times($spisoc['time']).'</span>';
echo "<span style='float:right;'>
<a title='Редактировать' href='?edit_id=$spisoc[id]&act=edit'><img  src='../template/icon/edit.png'></a>
<a title='Удалить' href='?delete_id=$spisoc[id]&act=edit'><img  src='../template/icon/delete.png'></a>
</span></div>";
}
echo '</div>';
break;

case 'edit':
if(isset($_GET['edit_id'])) {$edit_id = $_GET['edit_id'];}

$editor = mysql_fetch_array(mysql_query("SELECT * FROM `uncos_category` WHERE `id` = '$edit_id'"));


if($_POST['submit']) { $submit = $_POST['submit']; }
if($_POST['name']) { $name = $_POST['name']; }
if($_POST['titles']) { $titles = $_POST['titles']; }
if($_POST['opis']) { $opis = $_POST['opis']; }
if($_POST['description']) { $description = $_POST['description']; }

if(isset($submit)) {


if(empty($name)) {
echo '<div class="errors">Введите название категории</div>';
header("Refresh: 1; url=?act=edit&edit_id=$edit_id");
include_once'../template/foot.php';
exit();
}

$editor_ok = mysql_query("UPDATE `uncos_category` SET `name` = '$name',`title` = '$titles', `opis` = '$opis', `description` = '$description' WHERE `id` = '$edit_id'");

	if($editor_ok == true){
	messag("Категория успешно изменена");
header("Refresh: 1; url=?act=edit&edit_id=$edit_id");
include_once'../template/foot.php';
exit();
	}else
	{
	errors('Возникла ошика при изменении категории');
header("Refresh: 1; url=?act=edit&edit_id=$edit_id");
include_once'../template/foot.php';
exit();
	}
	

}




$form = new form('?act=edit&edit_id='.$edit_id);
$form->input('Название категории:','name','text',$editor['name'],true);
$form->input('Название страницы (title):','titles','text',$editor['title'],true);
$form->textarea('Описание категории:','opis',$editor['opis'],true);
$form->textarea('Ключевые слова: (255 символов)','description',$editor['description'],false);
$form->submit('Применить','submit');
$form->finish();
break;


case 'new_cat':


if($_POST['submit']) { $submit = $_POST['submit']; }
if($_POST['name']) { $name = $_POST['name']; }
if($_POST['titles']) { $titles = $_POST['titles']; }
if($_POST['opis']) { $opis = $_POST['opis']; }
if($_POST['description']) { $description = $_POST['description']; }

if(isset($submit)) {


if(empty($name)) {
echo '<div class="errors">Введите название категории</div>';
header("Refresh: 1; url=?act=new_cat");
include_once'../template/foot.php';
exit();
}

$editor_ok = mysql_query("INSERT INTO `uncos_category` (`name`,`title`,`opis`,`description`,`time`) VALUES ('$name','$titles','$opis','description','".time()."')");

	if($editor_ok == true){
	messag("Категория $name  успешно создана");
header("Refresh: 1; url=?act=new_cat");
include_once'../template/foot.php';
exit();
	}else
	{
	errors('Возникла ошика при создании категории');
header("Refresh: 1; url=?act=new_cat");
include_once'../template/foot.php';
exit();
	}
	

}




$form = new form('?act=new_cat');
$form->input('Название категории:','name','text',false,true);
$form->input('Название страницы (title):','titles','text',false,true);
$form->textarea('Описание категории:','opis',false,true);
$form->textarea('Ключевые слова: (255 символов)','description',false,false);
$form->submit('Применить','submit');
$form->finish();
break;


case 'delete':
if($_GET['delete_id']){$delete_id = $_GET['delete_id'];}
$del_razel = mysql_fetch_array(mysql_query("SELECT * FROM `uncos_category` WHERE `id`= '$delete_id'"));
$delete = mysql_query("DELETE FROM `uncos_category` WHERE `id` = '$id_delete'");
mysql_query("OPTIMIZE TABLE `uncos_category`");

    if($delete == true){
      messag('Категория '.$del_razel['name'].' успешно удалена');
      header('Refresh: 1; url=?' );
    }else {
      errors('Возникла ошибка при удаление категории '.$del_razel['name'].'');
      header('Refresh: 1; url=?' );
    }

break;

endswitch;


if($act == 'edit' or $act == 'new_cat') {
echo '<a class="link_str" href="categories.php">Назад</a>';
}

include_once'../template/foot.php';
?>