Размер файла: 2.68Kb
<?php
// by mides, wmclub.mobi
require_once '../system/sys.php';
require_once '../system/auth_a.php';
require_once '../system/header.php';
if ($u['access'] < 2) header('location: ../');
switch ($_GET['act']) {
default:
tp('Форум');
$cats_r = mysql_query("SELECT * FROM `forum_cats` ORDER BY `order`");
while ($cat = mysql_fetch_assoc($cats_r)) {
echo '<a href="../loads.php?act=cat&id='.$cat['id'].'">'.$cat['name'].'</a> (<a href="?act=cat_edit&id='.$cat['id'].'">ред</a>)<br />';
$subcats_r = mysql_query("SELECT * FROM `forum_subcats` WHERE `id_cat` = '$cat[id]' ORDER BY `name`");
while ($subcat = mysql_fetch_assoc($subcats_r)) {
echo '- <a href="../loads.php?act=subcat&id='.$subcat['id'].'">'.$subcat['name'].'</a> (<a href="?act=subcat_edit&id='.$subcat['id'].'">ред</a>)<br />';
}
}
echo '<br/>
<form action="?act=cat_add" method="post" name="form">
<select name="cat">
<option value="0">Главная</option>';
$cats_r = mysql_query("SELECT * FROM `forum_cats` ORDER BY `order`");
while ($cat = mysql_fetch_assoc($cats_r)) {
echo '<option value="'.$cat['id'].'">'.$cat['name'].'</option>';
}
echo '</select><br />
Название (под)раздела:<br/><input name="name" type="text" maxlength="50" /><br />
<input name="submit" type="submit" value="Добавить"></form>';
nav('./');
break;
case 'cat_add':
if ($_POST['name']) {
$cat = intval($_POST['cat']);
$name = check($_POST['name']);
if ($cat > 0) {
mysql_query("INSERT INTO `forum_subcats` SET `id_cat` = '$cat', `name` = '$name'");
} else {
mysql_query("INSERT INTO `forum_cats` SET `name` = '$name'");
}
}
header('location: ?');
break;
case 'cat_edit':
$id = intval($_REQUEST['id']);
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_cats` WHERE `id` = '$id'"));
if ($cat['id']) {
if ($_REQUEST['ok']) {
if ($_POST['name']) {
$name = check($_POST['name']);
mysql_query("UPDATE `forum_cats` SET `name` = '$name' WHERE `id` = '$id'");
header('location: ?');
} else {
header('location: ?act=cat_edit&id='.$id);
}
} else {
tp('Редактировать раздел');
echo '<form action="?act=cat_edit&id='.$id.'&ok=1" method="post">
Название:<br /><input name="name" type="text" maxlength="50" value="'.$cat['name'].'" /><br />
<input name="submit" type="submit" value="Ok" />
</form>';
}
} else {
error('Раздел не существует.');
}
nav('?');
break;
}
require_once '../system/tail_p.php';
?>