View file news-ds/comm_delete/index.php

File size: 1.38Kb
<?
	include_once '../../sys/inc/start.php';
	include_once '../../sys/inc/compress.php';
	include_once '../../sys/inc/sess.php';
	include_once '../../sys/inc/home.php';
	include_once '../../sys/inc/settings.php';
	include_once '../../sys/inc/db_connect.php';
	include_once '../../sys/inc/ipua.php';
	include_once '../../sys/inc/fnc.php';
	include_once '../../sys/inc/user.php';

// Только для пользователей

	if (!isset($user))header("location: /index.php?");

	define ('id', isset( $_GET['id'] ) ? abs(intval($_GET['id'])) : 0);	
	define ('page', isset( $_GET['page'] ) ? abs(intval($_GET['page'])) : 0);	
	
	$act = mysql_fetch_assoc(mysql_query("SELECT * FROM `news_komm` WHERE `id` = '".id."' LIMIT 1"));	
	
// проверяем существует комментарий
	
	if (!empty($act)) {

	$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $act[id_user] LIMIT 1"));
	
	if (isset($user) && ($user['level'] > $ank['level']))
	mysql_query("DELETE FROM `news_komm` WHERE `id` = '$act[id]'");
	
	$_SESSION['message'] = 'Ваш комментарий удален';
	header('Location: /news/news/?id=' . $act['id_news'] . '&page=' . page .'');
	exit;
	
	
	}else{$_SESSION['message'] = 'Ошибка комментарий не найдена';header('location: /news/news.php?id=' . $act['id_news'] . '&page=' . page .'');}	

?>