<?php
	/*
	*by Krite (http://upcoder.net)
	*/
	defined('_IN_JOHNCMS') or die('Error: restricted access');
	if($user_id)
	{
		$textl = 'Удаление статьи';
		require_once('../incfiles/head.php');
		if (empty ($_GET['id']))
		{
			echo '<div class="rmenu">Ощибка!</div>';
			echo '<div class="phdr"><a href="./">Назад</a></div>';
			require_once ("../incfiles/end.php");
			exit;
		}
		$req = mysql_query("SELECT * FROM `".$set['prefblog']."blogs` WHERE `id`='" . $id . "' AND `mod`='0' AND `uid`='".$user_id."' ;");
		if (mysql_num_rows($req) == 0)
		{
			echo '<div class="rmenu">Ощибка!</div>';
			echo '<div class="phdr"><a href="./">Назад</a></div>';
			require_once ("../incfiles/end.php");
			exit;
		}
		//$res = mysql_fetch_assoc($req);
		
		if(!isset($_GET['ok']))
		{
			echo '<div class="menu">Подтвердите удаление</div>';
			echo '<div class="menu"><a href="?act=view&amp;id='.$id.'">Отмена</a> | <a href="index.php?act=del&amp;id='.$id.'&amp;ok">Удалить</a></div>';
		}
		else
		{
			mysql_query("DELETE FROM `".$set['prefblog']."blogs` WHERE `id` = '" . $id . "';");
			$req_f = mysql_fetch_assoc(mysql_query('SELECT * FROM `'.$set['prefblog'].'blogs_files` WHERE `post` = '.$id));
			@ unlink('../blogs/files/' . $req_f['name']);
			@ unlink('../blogs/screen/' . $id . '.png');
			mysql_query("DELETE FROM `".$set['prefblog']."blogs_komm` WHERE `ref` = '" . $id . "';");
			mysql_query("DELETE FROM `".$set['prefblog']."blogs_files` WHERE `post` = '" . $id . "';");
			mysql_query("DELETE FROM `".$set['prefblog']."blogs_rat` WHERE `ref` = '" . $id . "';");
			mysql_query("DELETE FROM `".$set['prefblog']."blogs_rdm` WHERE `topic_id` = '" . $id . "';");
			echo '<div class="menu">Статья удалена</div>';
			echo '<div class="menu"><a href="./">Назад</a></div>';
		}
	}
	else
	{
		header('Location: ../?err');
		exit;
	}
?>