File size: 1.55Kb
<? $dir=''; include("../head.php");if(!isset($_SESSION['user_id']) or @$me['admin']!=2)exit("Нету доступа");
if(isset($_GET['edit'])){
$id=abs($_GET['edit']);if(!$post=mysql_fetch_array(mysql_query("SELECT * FROM `sh_post` WHERE `id`='$id'")))die("Не найдено");
if(!isset($_POST['sub']))echo "<form action='post.php?edit=$id' method='post'>
<textarea name='text' cols=30 rows=5>$post[text]</textarea><br/><input type='submit' name='sub' value='Изменить'></form>";
else if(trim($_POST['text']) !=''){$text= mysql_real_escape_string(trim($_POST['text']));
if(mysql_query("UPDATE `sh_post` SET `text`='$text' WHERE `id`='$id'"))echo "Сообщение отредактировано";
else echo mysql_error().'Ошибка';
}
}
else if(isset($_GET['del']))
{$id=$_GET['del']; if(!$post=mysql_fetch_array(mysql_query("SELECT * FROM `sh_post` WHERE `id`='$id'")))die("Не найдено");
$tema=mysql_fetch_array(mysql_query("SELECT * FROM `sh_tem` WHERE `id`='$post[tema]'"));
$podcat=mysql_fetch_array(mysql_query("SELECT * FROM `sh_podcat` WHERE `id`='$tema[cat]'"));
$cat=mysql_fetch_array(mysql_query("SELECT * FROM `sh_cat` WHERE `id`='$podcat[refid]'"));
$pc=$podcat['post']-1; $c=$cat['post']-1;
if(mysql_query("DELETE FROM `sh_post` WHERE `id`='$id'")){echo "Сообщение удалено";
mysql_query("UPDATE `sh_podcat` SET `post`='$pc' WHERE `id`='$tema[cat]'");
mysql_query("UPDATE `sh_cat` SET `post`='$c' WHERE `id`='$podcat[refid]'");}
else echo mysql_error().'Ошибка';
}
include("../foot.php"); ?>