<?php
// ======================================================================== //
//   KOOBI - CMS                                                            //
//   SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS                     //
//                                                                          //
//   DREAM4 - AM MICHELSGRUND 7 - 69469 WEINHEIM - GERMANY                  //    
//   TEL. +49(0) 6201 - 980442 / FAX. +49(0) 6201 - 64809                   //
// ======================================================================== //
$f_id = escs($_REQUEST['fid']);

// =========================================================
// <<-- zugriffsrechte -->>
// =========================================================
$cat_query = new dbc("SELECT group_id FROM " . PREFIX . "_f_forum WHERE id = '" . $f_id . "'");
while ($category = $cat_query->fetchrow_assoc()) {
	
	// miscrechte
	include ( BASEDIR . "/system/misc_ids.php");
	
	$groups = explode(",", $category['group_id']);
	if (array_intersect($group_ids, $groups)) {
			$permissions = getForumPermissionsByUser($f_id, UID);
	}
}
// =========================================================

if ( ($islogged == 0 ) || ($permissions[FORUM_PERMISSIONS_CAN_CLOSE_TOPIC] == 0) ) {
	$EOUT = msg("nopermission", "nopermission_t", str_replace("__URL__", "index.php?p=showforums&amp;area=$area", $lang['redirect']), "index.php?p=showforums&amp;area=$area");
	$NOOUT = 1;
}

if($NOOUT != 1){
	
	if ($_GET['toid'] == "" || $_GET['fid'] == '') {
		$EOUT = msg("f_newforum", "f_noid", str_replace("__URL__", "index.php?p=showforums&amp;area=$area", $lang['redirect']), "index.php?p=showforums&amp;area=$area");
		$NOOUT = 1;
	}
	
	$q_forum = "SELECT status FROM " . PREFIX . "_f_forum WHERE id = '$f_id'";
	$r_forum = new dbc($q_forum);
	$forum = $r_forum->fetchrow();
	
	if ($forum->status == FORUM_STATUS_CLOSED) {
		$EOUT = msg("f_forum", "f_msg_forumclosed", str_replace("__URL__", "index.php?p=showforum&amp;fid=$f_id&amp;area=$area", $lang['redirect']), "index.php?p=showforum&amp;fid=$f_id&amp;area=$area");
		$NOOUT = 1;
	}
	
	$status = FORUM_STATUS_CLOSED;
	$q_closetopic = "UPDATE " . PREFIX . "_f_topic SET status = $status WHERE id = '" . escs($_GET['toid']) ."'";
	$r_closetopic = new dbc($q_closetopic);
	
	$EOUT = msg("f_forum", "f_actionsuccess", str_replace("__URL__", "index.php?p=showtopic&amp;toid=$_GET[toid]&amp;area=$area", $lang['redirect']), "index.php?p=showtopic&amp;toid=$_GET[toid]&amp;area=$area");
	$NOOUT = 1;
}
?>