<?php
include("header.php");
if ( empty($forum) ){
	redirect_header("index.php", 2, _MD_ERRORFORUM);
	exit();
} elseif ( empty($post_id) ) {
	redirect_header("viewforum.php?forum=$forum", 2, _MD_ERRORPOST);
	exit();
}
if ( $xoopsUser ) {
	if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
		if ( !is_moderator($forum, $xoopsUser->uid()) ) {
			redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_DELNOTALLOWED);
			exit();
		}
	}
} else {
	redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_DELNOTALLOWED);
	exit();
}
include_once("class/class.forumposts.php");
if ( !empty($ok) ) {
	if ( !empty($post_id) ) {
		$post = new ForumPosts($post_id);
		$post->delete();
		sync($post->forum(), "forum");
		sync($post->topic(), "topic");
	}
	if ( $post->istopic() ) {
		redirect_header("viewforum.php?forum=$forum", 2, _MD_POSTSDELETED);
		exit();
	} else {
		redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_POSTSDELETED);
		exit();
	}
} else {
	include(XOOPS_ROOT_PATH."/header.php");
	OpenTable();
	echo "<div>";
	echo "<h4 style='color:#ff0000;'>"._MD_AREUSUREDEL."</font></h4>";
	echo "<table><tr><td>\n";
	echo myTextForm($PHP_SELF."?post_id=".$post_id."&viewmode=".$viewmode."&order=".$order."&forum=".$forum."&topic_id=".$topic_id."&ok=1", _YES);
	echo "</td><td>\n";
	echo myTextForm("javascript:history.go(-1)", _NO);
	echo "</td></tr></table>\n";
	echo "</div>";
	CloseTable();
}
include(XOOPS_ROOT_PATH."/footer.php");
?>