Размер файла: 4.25Kb
<? $dir='';include("../head.php");if(!isset($me) or @$me['admin']!=2)exit("Нету доступа");
if(isset($_GET['id'])){
$id=$_GET['id'];
$pod_cat=mysql_fetch_array(mysql_query("SELECT * FROM `sh_podcat` WHERE `id`=$id"));
if(!$pod_cat)die("Не найдено");
$cat=mysql_fetch_array(mysql_query("SELECT * FROM `sh_cat` WHERE `id`=$pod_cat[refid]"));
if(!$cat)die("Не найдено");
echo "Форум <b><a href='cat.php?id=$cat[id]'>$cat[name]</a></b> | Категория <b>$pod_cat[name]</b><br/>";
$num = 10;@$page = $_GET['page'];
$result00 = mysql_query("SELECT COUNT(*) FROM `sh_tem` where `cat`='$id'");
$temp = mysql_fetch_array($result00);
$posts = $temp[0];
$total = (($posts - 1) / $num) + 1;
$total = intval($total);
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$tem_q=mysql_query("SELECT * FROM `sh_tem` WHERE `cat`='$id' ORDER BY `time` DESC LIMIT $start,$num");
if($posts != 0) {echo "<div class='menu'>";
while($tema=mysql_fetch_array($tem_q)) {
$postov=mysql_num_rows(mysql_query("SELECT * FROM `sh_post` WHERE `tema`='$tema[id]' ORDER BY `date` DESC"));
if($tema['close']==1)echo "<img src='../images/lock.gif'> ";
if($tema['up']==1)echo "<img src='../images/up.gif'> ";
echo "<a href='tema.php?id=$tema[id]'>$tema[name]</a> ($postov) <a href='tema.php?edit=$tema[id]'>[редакт]</a>
<a href='tema.php?del=$tema[id]'>[уд]</a><br/>";
}
echo "</div>";
if($total > 1)
{$nav['url']="podcat.php?id=$id&page=";
echo "<br/>";
if($page > 1){$pag=$page-1;
echo "<a href='".$nav['url'].$pag."'>Назад</a>";}
if($page + 1 <= $total){$pag=$page+1;
echo "<a href='".$nav['url'].$pag."'> Далее</a>";}
echo "<br/>Страница $page из $total";
if($page>2)echo ' <a href="'.$nav['url'].'1">В начало</a>';
}
}
else echo "В данной категории тем нет";
}
else if(isset($_GET['new']))
{$id=abs($_GET['new']); if(!$new_forum=mysql_fetch_array(mysql_query("SELECT * FROM `sh_cat` WHERE `id`='$id'")))die("Форум не найден");
if(!isset($_POST['sub']))echo "<form action='podcat.php?new=$id' method='post'>Добавление категории в форум <b>$new_forum[name]</b><br/>
Название категории<br/><input type='text' name='name'><br/><input type='submit' name='sub' value='Создать'></form>";
else if(trim($_POST['name'])!=''){$name = mysql_real_escape_string(htmlspecialchars(trim($_POST['name'])));
$add_podcat=mysql_query("INSERT INTO `sh_podcat` SET `name`='$name', `refid`='$id'");
if($add_podcat)echo "Категория добавлена";
else echo "Ошибка<br/>".mysql_error(); }
}
else if(isset($_GET['edit']))
{$id=abs($_GET['edit']); if(!$podcat=mysql_fetch_array(mysql_query("SELECT * FROM `sh_podcat` WHERE `id`='$id'")))die("Не найдено");
if(!isset($_POST['sub']))echo "<form action='podcat.php?edit=$id' method='post'>Название<br/>
<input type='text' name='name' value='$podcat[name]'><br/><input type='submit' name='sub' value='Редактировать'></form>";
else if(trim($_POST['name'])!= ''){$name = mysql_real_escape_string(htmlspecialchars(trim($_POST['name'])));
$upd_podcat=mysql_query("UPDATE `sh_podcat` SET `name`='$name' WHERE `id`='$id'");
if($upd_podcat)echo "Категория переименована";
else echo "Ошибка<br/>".mysql_error();}
}
else if(isset($_GET['del']))
{$id=abs($_GET['del']); if(!$del_cat=mysql_fetch_array(mysql_query("SELECT * FROM `sh_podcat` WHERE `id`='$id'")))die("Не найдено");
$tem=mysql_num_rows(mysql_query("SELECT * FROM `sh_tem` WHERE `cat`='$id'"));
$tem_1=mysql_fetch_array(mysql_query("SELECT * FROM `sh_cat` WHERE `id`='$del_cat[refid]'"));
$budet_tem=$tem_1['tem']-$tem;
$budet_postov=$tem_1['post']-$tem;
$del_podcat=mysql_query("DELETE FROM `sh_podcat` WHERE `id`='$id'");
if($del_podcat){echo "Категория удалена"; mysql_query("UPDATE `sh_cat` SET `tem`='$budet_tem' WHERE `id`='$del_cat[refid]'");
mysql_query("UPDATE `sh_cat` SET `post`='$budet_postov' WHERE `id`='$del_cat[refid]'");}
else echo "Ошибка".mysql_error();
}
echo "<br/><a href='index.php'>В админ-меню</a>";
include("../foot.php");?>