<?

include_once "../SYSTEM/include/functions.php";

include_once "../SYSTEM/include/mysql.php";

include_once "../SYSTEM/include/param.php";

include_once "../SYSTEM/include/ban.php";

include_once "../SYSTEM/include/sess.php";

include_once "../SYSTEM/include/ban_2.php";

include_once "../SYSTEM/include/theme.php";

$title='Параметры темы';

$mesto='Меняет параметры темы в форуме';

head();




if (!isset($user) || $user['level']<1)

{

header ("Location: index.php?".SID."");


exit;

}



if (!isset($_GET['id_forum']))

{

header ("Location: index.php?".SID."");


exit;

}

if (!isset($_GET['id_forum']))

{

header ("Location: index.php?".SID."");


exit;

}

$id_forum=intval($_GET['id_forum']);

$q = mysql_query("SELECT * FROM `$mysql[pref]forum_f` WHERE `id` = '$id_forum';");

if(mysql_num_rows($q) != 0)

{

$forum = mysql_fetch_array($q);

}

else

{

header ("Location: index.php?".SID."");


exit;

}


if (!isset($_GET['id_razd']))

{

header ("Location: index.php?".SID."&id_forum=$id_forum");


exit;

}

$id_razd=intval($_GET['id_razd']);

$q = mysql_query("SELECT * FROM `$mysql[pref]forum_r` WHERE `id_f` = '$id_forum' AND `id` = '$id_razd';");

if(mysql_num_rows($q) != 0)

{

$razd = mysql_fetch_array($q);

}

else

{

header ("Location: index.php?".SID."&id_forum=$id_forum");


exit;

}


if (!isset($_GET['id_them']))

{

header ("Location: index.php?".SID."&id_forum=$id_forum&id_razd=$id_razd");


exit;

}

$id_them=intval($_GET['id_them']);

$q = mysql_query("SELECT * FROM `$mysql[pref]forum_t` WHERE `id_f` = '$id_forum' AND `id_r` = '$id_razd' AND `id` = '$id_them';");

if(mysql_num_rows($q) != 0)

{

$thema = mysql_fetch_array($q);

}

else

{

header ("Location: index.php?".SID."&id_forum=$id_forum&id_razd=$id_razd");


exit;

}




if (isset($_GET['act']) && $_GET['act']=='name' && $_POST['name']!='') // переименование темы

{

$name=$_POST['name'];

$name=stripslashes(htmlspecialchars($name));

$name=$name;

mysql_query("UPDATE `$mysql[pref]forum_t` SET `name` = '$name' WHERE `id` = '$id_them';");

action("Переименование темы в форуме");

header ("Location: index.php?".SID."&id_forum=$id_forum&id_razd=$id_razd&id_them=$id_them");

exit;

}


if (isset($_GET['act']) && $_GET['act']=='mesto' && isset($_POST['razd']) && $_POST['razd']!='') // перемещение темы

{

$newrazd=intval($_POST['razd']);

$q = mysql_query("SELECT id_f FROM `$mysql[pref]forum_r` WHERE `id` = '$newrazd' LIMIT 1;");

$newww = mysql_fetch_array($q);

mysql_query("UPDATE `$mysql[pref]forum_t` SET `id_f` = '$newww[id_f]', `id_r` = '$newrazd' WHERE `id` = '$id_them';");

mysql_query("UPDATE `$mysql[pref]forum_p` SET `id_f` = '$newww[id_f]', `id_r` = '$newrazd' WHERE `id_t` = '$id_them';");

$id_forum=$newww['id_f'];

$id_razd=$newrazd;

action("Перемещение темы в форуме");

header ("Location: index.php?".SID."&id_forum=$id_forum&id_razd=$id_razd&id_them=$id_them");

exit;

}


if (isset($_GET['act']) && $_GET['act']=='close')

{

mysql_query("UPDATE `$mysql[pref]forum_t` SET `close` = '1' WHERE `id` = '$id_them';");

action("Закрытие темы темы в форуме");

header("Location: index.php?".SID."&act=set&id_forum=$id_forum&id_razd=$id_razd");

exit;

}


if (isset($_GET['act']) && $_GET['act']=='open')

{

mysql_query("UPDATE `$mysql[pref]forum_t` SET `close` = '0' WHERE `id` = '$id_them';");

action("Открытие темы в форуме");

header("Location: index.php?".SID."&act=set&id_forum=$id_forum&id_razd=$id_razd");

exit;

}


if (isset($_GET['act']) && $_GET['act']=='crep')

{

mysql_query("UPDATE `$mysql[pref]forum_t` SET `crep` = '0' WHERE `id` = '$id_them';");

action("Закрепление темы в форуме");

header("Location: index.php?".SID."&act=set&id_forum=$id_forum&id_razd=$id_razd");

exit;

}


if (isset($_GET['act']) && $_GET['act']=='no_crep')

{

mysql_query("UPDATE `$mysql[pref]forum_t` SET `crep` = '1' WHERE `id` = '$id_them';");

action("Открепление темы в форуме");

header("Location: index.php?".SID."&act=set&id_forum=$id_forum&id_razd=$id_razd");

exit;

}


if (isset($_GET['act']) && $_GET['act']=='del')

{

mysql_query("DELETE FROM `$mysql[pref]forum_t` WHERE `id` = '$id_them';");

mysql_query("DELETE FROM `$mysql[pref]forum_p` WHERE `id_t` = '$id_them';");

action("Удаление темы в форуме");

header("Location: index.php?".SID."&act=del&id_forum=$id_forum&id_razd=$id_razd");

exit;

}



echo "<div class=\"h\">Настройки темы $thema[name]</div><hr />\n";


if ($mail_in_new>0)echo "<div class=\"privat\"><img src=\"../SYSTEM/themes/$them/img/mail0.gif\" alt=\"\" /> <a href=\"../mail.php?act=in\">Приват</a> [$mail_in_new]</div><hr />\n";


echo "<form method=\"post\" action=\"set_t.php?act=name&amp;id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$id_them\">";

echo "<div class=\"menu\">";

echo "<div class=\"title\">Название</div>";

echo "<input name=\"name\" class=\"form\" type=\"text\" value=\"$thema[name]\" /><br />\n";

echo "<input value=\"Изменить\" class=\"form\" type=\"submit\" />\n";

echo "</div>";

echo "</form>\n";




echo "<form method=\"post\" action=\"set_t.php?act=mesto&amp;id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$id_them\">";

echo "<div class=\"menu\">";

echo "<div class=\"title\">Переместить</div>";

echo "<select class=\"form\" name=\"razd\">\n";

$q2 = mysql_query("SELECT * FROM `$mysql[pref]forum_f` ORDER BY num;");

while ($forums = mysql_fetch_array($q2))

{

echo "<option value=\"\">$forums[name]</option>\n";

$q = mysql_query("SELECT * FROM `$mysql[pref]forum_r` WHERE `id_f` = '$forums[id]' ORDER BY num;");

while ($razdeles = mysql_fetch_array($q)){$check='';

if ($id_razd==$razdeles['id']){$check=' selected="selected"';}

echo "<option$check value=\"$razdeles[id]\">&gt;&gt;&gt; $razdeles[name]</option>\n";}

}

echo "</select><br />\n";

echo "<input value=\"Переместить\" class=\"form\" type=\"submit\" />\n";

echo "</div>";

echo "</form>\n";




if ($thema['close']==1)

{

echo "<form method=\"post\" action=\"set_t.php?act=open&amp;id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$id_them\">";

echo "<div class=\"menu\">";

echo "<div class=\"title\">Открыть тему</div>";

echo "<input value=\"Открыть\" class=\"form\" type=\"submit\" />\n";

echo "</div>";

echo "</form>\n";

}

else

{

echo "<form method=\"post\" action=\"set_t.php?act=close&amp;id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$id_them\">";
echo "<div class=\"menu\">";
echo "<div class=\"title\">Закрыть тему</div>";
echo "<input value=\"Закрыть\" class=\"form\" type=\"submit\" />\n";
echo "</div>";
echo "</form>\n";
}


if ($thema['crep']==0)
{
echo "<form method=\"post\" action=\"set_t.php?act=no_crep&amp;id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$id_them\">";
echo "<div class=\"menu\">";
echo "<div class=\"title\">Открепить тему</div>";
echo "<input value=\"Открепить\" class=\"form\" type=\"submit\" />\n";
echo "</div>";
echo "</form>\n";
}
else
{
echo "<form method=\"post\" action=\"set_t.php?act=crep&amp;id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$id_them\">";
echo "<div class=\"menu\">";
echo "<div class=\"title\">Прикрепить тему</div>";
echo "<input value=\"Закрепить\" class=\"form\" type=\"submit\" />\n";
echo "</div>";
echo "</form>\n";
}

echo "<form method=\"post\" action=\"set_t.php?act=del&amp;id_forum=$id_forum&amp;id_razd=$id_razd&amp;id_them=$id_them\">";
echo "<div class=\"menu\">";
echo "<div class=\"title\">Удалить тему</div>";
echo "<input value=\"Удалить\" class=\"form\" type=\"submit\" />\n";
echo "</div>";
echo "</form>\n";





echo "<a href=\"index.php?id_forum=$id_forum&amp;id_razd=$id_razd\">Вернуться</a>\n";
echo "<br /><a href=\"../index.php\">На главную</a><br />\n";

foot();
?>
