File size: 3.23Kb
<?php
/***************************************************************************
* admin_smiles_cat.php
* -------------------
*
****************************************************************************/
define('IN_PHPBB', 1);
if( !empty($setmodules) )
{
$filename = basename(__FILE__);
$module['General']['Категории смайлов'] = $filename;
return;
}
$no_page_header = TRUE;
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include('./page_header_admin.'.$phpEx);
switch($_GET['section']){
default:
echo'<center>Управление категориями смайлов</center>';
$sql = "SELECT * FROM " . $table_prefix . "smilies_cat ORDER BY id ASC ";
if ($result = $db->sql_query($sql))
{
while ($row = $db->sql_fetchrow($result))
{
echo'<div class="row1">'. $row['cat_title'];
echo'<a href="'.append_sid("?section=edit&id=".$row['id']).'"> [Edit]</a>
<a href="'.append_sid("?section=del&id=".$row['id']).'"> [Del]</a></div>';
}
}
echo'<div class="row1"><a href="'.append_sid("?section=add").'">Добавить категорию</a></div>';
break;
case'edit':
$id = abs(intval($_GET['id']));
if(!empty($_POST['submit'])) {
$cat_title = mysql_real_escape_string($_POST['name']);
if(empty($cat_title)){
echo'<div class="row1">Введите название</div>';
}else{
mysql_query("UPDATE " . $table_prefix . "smilies_cat SET cat_title = '$cat_title' WHERE id = '$id'");
echo 'Отредактировано';
echo "<meta http-equiv='refresh'; content='1; url=".append_sid('admin_smiles_cat.php')."'> ";
}
}else{
$row = mysql_fetch_array(mysql_query("SELECT * FROM " . $table_prefix . "smilies_cat WHERE id = '".$id."'"));
$cat_title = $row['cat_title'];
echo'<div class="tab"><span class="cattitle">Редактирование категории</span></div>';
echo'<div class="row1">';
echo'<form action="'.append_sid("?section=edit&id=".$row['id']).'" method="POST">';
echo'<input type="text" name="name" value="'.$cat_title.'"><br>';
echo'<input type="submit" name="submit" value="Изменить"></form></div>';
}
break;
case'del':
$id = abs(intval($_GET['id']));
mysql_query("DELETE FROM " . $table_prefix . "smilies_cat WHERE id = $id LIMIT 1");
echo 'Удалено';
echo "<meta http-equiv='refresh'; content='1; url=".append_sid('admin_smiles_cat.php')."'> ";
break;
case'add':
if(empty($_POST['submit'])) {
echo'<div class="tab"><span class="cattitle">Добавление категории</span></div>';
echo'<div class="row1">';
echo'
<form action="'.append_sid("?section=add").'" method="POST">
Название:<br/>
<input type="text" name="name" value="">
<input type="submit" name="submit" value="Добавить">
</form></div>
';
}else{
$cat_title = mysql_real_escape_string($_POST['name']);
if(empty($cat_title)){
echo'Введите название';
}else{
mysql_query("INSERT INTO " . $table_prefix . "smilies_cat (cat_title) VALUES ('$cat_title') ");
echo 'Добавлено';
echo "<meta http-equiv='refresh'; content='1; url=".append_sid('admin_smiles_cat.php')."'> ";
}
}
break;
}
include('./page_footer_admin.'.$phpEx);
?>