View file forum/forum/thmedit.php

File size: 6.97Kb
<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";
require_once"../template/db.php";
include_once"fnc.php";


if ($provpar == md5($_SESSION['par']) && $provlog == $_SESSION['log']) {
if ($dostup == 101 || $dostup == 102 || $dostup == 103 || $dostup == 105) {
$id = (int)$_GET['id'];
if ($id) {
$check = mysql_fetch_array(mysql_query("SELECT * FROM `theme` WHERE `id` = '$id'"));
if (trim($check)) {


if ($_POST['edits']) {
if (!isset($theme {3})) {header ("Location: ?act=themes&isset=stheme&id=$id"); exit;} 
if (!isset($description {5})) {header ("Location: ?act=themes&isset=sdescription&id=$id"); exit;} 
if (strlen($theme) > 50) {header ("Location: ?act=themes&isset=btheme&id=$id");exit;} 
if (strlen($description) > 100) { header ("Location: ?act=themes&isset=bdescription&id=$id"); exit;} 
mysql_query("UPDATE `theme` SET `name`='".check($theme)."' WHERE `id` = '$id'");
mysql_query("UPDATE `theme` SET `description`='".check($description)."' WHERE `id` = '$id'");
header ("Location: ".$config_home."/forum/posts/".$id."/".strts($id,$config_forumpost).""); exit;} 

$thms = mysql_query("SELECT * FROM `theme` WHERE `id` = '$id' ");
$thm = mysql_fetch_array($thms);
echo '<div class="b">Управление темой:</div><div>';
echo "<form action='".$config_home."/forum/thmedit/".$id."' method='post'>\n";
echo "Название:<br><input type='text' name='theme' maxlength='50' value='" . $thm['name'] . "'><br>\n";
echo "Описание:<br><input type='text' name='description' maxlength='100' value='" . $thm['description'] . "'><br>\n";
echo "<input type='submit' name='edits' value='Отправить'></form></div>";
						
						
						
if ($carry == '2') {
$thmsq = mysql_query("SELECT * FROM `theme` WHERE `id` = '$id' ");
$thmq = mysql_fetch_array($thmsq);
mysql_query("UPDATE `theme` SET `forums`='$forumsid' WHERE `id` = '$id'");
mysql_query("UPDATE `theme` SET `under`='$underid' WHERE `id` = '$id'");
mysql_query("UPDATE `posts` SET `forums`='$forumsid' WHERE `theme` = '$id'");
mysql_query("UPDATE `posts` SET `under`='$underid' WHERE `theme` = '$id'");

$pst = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `forums`='" . $thmq['forums'] . "'"), 0);
$thm = mysql_result(mysql_query("SELECT COUNT(*) FROM `theme` WHERE `forums`='" . $thmq['forums'] . "'"), 0);
$pst1 = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `under`='" . $thmq['under'] . "'"), 0);
$thm1 = mysql_result(mysql_query("SELECT COUNT(*) FROM `theme` WHERE `under`='" . $thmq['under'] . "'"), 0);
$pst2 = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `forums`='$forumsid'"), 0);
$thm2 = mysql_result(mysql_query("SELECT COUNT(*) FROM `theme` WHERE `forums`='$forumsid'"), 0);
$pst3 = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `under`='$underid'"), 0);
$thm3 = mysql_result(mysql_query("SELECT COUNT(*) FROM `theme` WHERE `under`='$underid'"), 0);
$last = mysql_fetch_array(mysql_query("SELECT * FROM `posts` WHERE `forums` = '" . $thmq['forums'] . "' ORDER BY `id` DESC "));
$last_t = mysql_fetch_array(mysql_query("SELECT * FROM `theme` WHERE `id` = '" . $last['theme'] . "'"));
mysql_query("UPDATE `forums` SET `last_theme`='" . $last['theme'] . "' WHERE `id` = '" . $thmq['forums'] . "'");
mysql_query("UPDATE `forums` SET `last_theme_name`='" . $last_t['name'] . "' WHERE `id` = '" . $thmq['forums'] . "'");
$last = mysql_fetch_array(mysql_query("SELECT * FROM `posts` WHERE `forums` = '" . $forumsid . "' ORDER BY `id` DESC "));
$last_t = mysql_fetch_array(mysql_query("SELECT * FROM `theme` WHERE `id` = '" . $last['theme'] . "'"));
mysql_query("UPDATE `forums` SET `last_theme`='" . $last['theme'] . "' WHERE `id` = '" . $forumsid . "'");
mysql_query("UPDATE `forums` SET `last_theme_name`='" . $last_t['name'] . "' WHERE `id` = '" . $forumsid . "'");
mysql_query("UPDATE `forums` SET `last_time`='" . $last['time'] . "' WHERE `id` = '" . $thmq['forums'] . "'");
mysql_query("UPDATE `forums` SET `last_posts`='" . $pst . "' WHERE `id` = '" . $thmq['forums'] . "'");
mysql_query("UPDATE `forums` SET `last_login`='" . $last['author'] . "' WHERE `id` = '" . $thmq['forums'] . "'");

mysql_query("UPDATE `forums` SET `posts`='$pst' WHERE `id` = '" . $thmq['forums'] . "'");
mysql_query("UPDATE `forums` SET `theme`='$thm' WHERE `id` = '" . $thmq['forums'] . "'");
mysql_query("UPDATE `under` SET `posts`='$pst1' WHERE `id` = '" . $thmq['under'] . "'");
mysql_query("UPDATE `under` SET `theme`='$thm1' WHERE `id` = '" . $thmq['under'] . "'");
mysql_query("UPDATE `forums` SET `posts`='$pst2' WHERE `id` = '$forumsid'");
mysql_query("UPDATE `forums` SET `theme`='$thm2' WHERE `id` = '$forumsid'");
mysql_query("UPDATE `under` SET `posts`='$pst3' WHERE `id` = '$underid'");
mysql_query("UPDATE `under` SET `theme`='$thm3' WHERE `id` = '$underid'");
header ("Location: ".$config_home."/forum/posts/".$id."/".strts($id,$config_forumpost)."");exit; } 

if ($carry == '1') {
echo '<div class="b">Перенос темы:</div><div>';
echo "<form action='".$config_home."/forum/thmedit/".$id."/2/".$forumsid."' method='post'>\n";
echo "Раздел: <br><select name='underid'>\n";
$frms = mysql_query("SELECT * FROM `under` WHERE `forum` = '$forumsid'");
if (mysql_num_rows($frms)) {
echo "<option value='0' selected='selected'>Выбирите подфорум</option>\n";
while ($frm = mysql_fetch_array($frms)) {
echo "<option value='" . $frm['id'] . "'>" . $frm['name'] . "</option>\n";} 
} else {echo "<option selected='selected'>Подфорумов нет </option>\n";} 
echo "</select><br>\n";
echo "<input type='submit' value='Вперед'></form>";
} else {
echo '<div class="b">Перенос темы:</div><div>';
echo "<form action='".$config_home."/forum/thmedit/".$id."/1' method='post'>\n";
echo "Раздел: <br><select name='forumsid'>\n";
$frms = mysql_query("SELECT * FROM `forums` WHERE `under` > '0'");
if (mysql_num_rows($frms)) {
echo "<option value='0' selected='selected'>Выбирите раздел </option>\n";
while ($frm = mysql_fetch_array($frms)) {
echo "<option value='" . $frm['id'] . "'>" . $frm['name'] . "</option>\n";} 
} else {
echo "<option selected='selected'>Разделов нет </option>\n";} 
echo "</select><br>\n";
echo "<input type='submit' value='Вперед'></form>";}}}}}

echo '</div><hr><div>';
echo ': <a href="'.$config_home.'/forum/posts/'.$id.'/'.strts($id,$config_forumpost).'">В тему</a><br>'; 
echo ':: <a href="'.$config_home.'/forum/">В форум</a><br>';
echo '::: <a href="'.$config_home.'/">На главную</a>';
echo '</div>';
include_once"../themes/$config_themes/foot.php";
?>