<?php
if(isset($user) && $admin['uid']==$user['id'] && isset($_GET['act']) && $_GET['act']=='mesto'){
	echo '<form method="post" action="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'&amp;act=mesto&amp;ok">';
	echo 'Раздел:<br/><select name="razdel">';

if(isset($user) && $admin['uid']==$user['id'] && $admin['priv']>0){

$q = mysql_query("SELECT * FROM `comm_forum_f` WHERE `id_comm` = '$id_comm' ORDER BY `pos` ASC");
while($forums = mysql_fetch_array($q)){
	echo '<optgroup label="'.$forums['name'].'">';

$q2 = mysql_query("SELECT * FROM `comm_forum_r` WHERE `id_forum` = '$forums[id]' AND `id_comm` = '$id_comm' ORDER BY `time` DESC");
while($razdels = mysql_fetch_array($q2)){
	$check='';

if($razdel['id']==$razdels['id']){
	$check=' selected="selected"';
	}

echo '<option'.$check.' value="'.$razdels['id'].'">'.$razdels['name'].'</option>';
}

echo '</optgroup>';
}
}else{
	$q2 = mysql_query("SELECT * FROM `comm_forum_r` WHERE `id_forum` = '$forum[id]' AND `id_comm` = '$id_comm' ORDER BY `time` DESC");
while($razdels = mysql_fetch_array($q2)){
	$check='';

if($razdel['id']==$razdels['id']){
	$check=' selected="selected"';
	}

echo '<option'.$check.' value="'.$razdels['id'].'">'.$razdels['name'].'</option>';
}
}

echo '</select><br/>';
echo '<input value="Переместить" type="submit"/><br/>';
echo '&#187;&nbsp;<a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'">Отмена</a></form>';

}else if(isset($user) && $admin['uid']==$user['id'] && isset($_GET['act']) && $_GET['act']=='set'){
	echo '<a href="/smiles/index.php">Смайлы</a><br/>';
	echo '<form method="post" action="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'&amp;act=set&amp;ok">';
	echo 'Название темы:<br/><input name="name" type="text" maxlength="32" value="'.$them['name'].'"/><br/>';

if($user['set_translit']==1){
	echo '<label><input type="checkbox" name="translit1" value="1"/> Транслит</label><br/>';
	}

if($admin['priv']>0){

if($them['up']==1){
	$check=' checked="checked"';
	}else{
		$check=NULL;
		}

echo '<label><input type="checkbox"'.$check.' name="up" value="1"/> Всегда наверху</label><br/>';
}

if($them['close']==1){
	$check=' checked="checked"';
	}else{
		$check=NULL;
		}

echo '<label><input type="checkbox"'.$check.' name="close" value="1"/> Закрыть</label><br/>';

if($ank2['id']!=$user['id']){
	echo '<label><input type="checkbox" name="autor" value="1"/> Забрать у автора права</label><br/>';
	}

echo '<input value="Изменить" type="submit"/><br/>';
echo '&#187;&nbsp;<a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'">Отмена</a></form>';

}else if(isset($user) && $admin['uid']==$user['id'] && isset($_GET['act']) && $_GET['act']=='del' && $admin['priv']>0){
	echo '<div class="err">Подтвердите удаление темы<br/>';
	echo '<a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'&amp;act=delete&amp;ok">Да</a> <a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'">Нет</a><br/></div>';

}else if(isset($user) && $admin['uid']==$user['id'] && isset($_GET['act']) && $_GET['act']=='post_delete'){
	echo '<input value="Удалить выбранные посты" type="submit"/><br/>';
	echo '&#187;&nbsp;<a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'">Отмена</a></form>';

}

if((!isset($_GET['act']) || $_GET['act']!='post_delete')){
	echo '&#187;&nbsp;<a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'&amp;act=post_delete">Удаление постов</a><br/>';
	}

echo '&#187;&nbsp;<a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'&amp;act=mesto">Переместить тему</a><br/>';

if(isset($user) && $admin['uid']==$user['id'] && $admin['priv']>0){
	echo '&#187;&nbsp;<a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'&amp;act=del">Удалить тему</a><br/>';
	}

if(isset($user) && $admin['uid']==$user['id'] && $admin['priv']>0){
echo '&#187;&nbsp;<a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'&amp;act=set">Параметры темы</a><br/>';
}
?>