From e01c6f27d770fb371273d19ea65ff00369418875 Mon Sep 17 00:00:00 2001 From: lopar Date: Thu, 1 Nov 2018 00:26:24 +0200 Subject: [PATCH] Code cleanup --- forum.php | 1098 ++++++++++++++++++++++++++--------------------------- 1 file changed, 534 insertions(+), 564 deletions(-) diff --git a/forum.php b/forum.php index 0da052b..617797c 100644 --- a/forum.php +++ b/forum.php @@ -11,16 +11,16 @@ if (!isset($_GET['page'])) { $ps = $_GET['page']; } -$dostupPal = false; -$dostupSovet = false; +$isModerator = false; +$isAdmin = false; -if (($user['align'] >= 1.7 && $user['align'] < 2) || $user['align'] == 2.4) { - $dostupPal = true; +if (($user['align'] >= 1.7 && $user['align'] < 2)) { + $isModerator = true; } -if (($user['align'] >= 1.98 && $user['align'] <= 1.99) || $user['admin'] == 1 || $user['align'] == 10) { - $dostupSovet = true; - $dostupPal = true; +if ($user['admin'] == 1) { + $isAdmin = true; + $isModerator = true; } $edit = ''; @@ -32,11 +32,322 @@ if (isset($_GET['do']) && $_GET['do'] != "search" && $_GET['do'] != "my_topics" $search .= '


'; } -$news_topic = false; -if (isset($_GET['topic']) && is_numeric($_GET['topic']) && $_GET['topic'] == 228043095) { - $news_topic = true; +if (isset($_POST['selectt'], $_POST['numt']) && $_POST['selectt'] != '' && $_POST['numt'] != '') { + $AlignTop = db::c()->query('SELECT `min_align`, `max_align` FROM `forum` WHERE `id` = ?i', $_POST['selectt'])->fetch_assoc(); + db::c()->query('UPDATE `forum` SET `parent` = ?i, `min_align` = "?s", `max_align` = "?s" WHERE `id` = ?i', $_POST['selectt'], $AlignTop['min_align'], $AlignTop['max_align'], $_POST['numt']); } +if (!isset($_GET['conf']) && !isset($_GET['topic'])) { + $_GET['conf'] = 1; +} + +$Movemess = ($isModerator == true) ? 1 : 0; +$replasepost = ''; + +function parse_bb_code($text) +{ + $bbCodes = array( + // Стандартные BB коды + '/\[(\/?)(b|i|u|s)\s*\]/' => "<$1$2>", + '/\[(left|center|right)\]/' => '

', + '/\[\/(left|center|right)\]/' => '

', + '/\[url\s?(src=)?\s?(.+?)\s?(target=(_blank|_self))?\](.+?)\[\/url\]/' => '$5', + '/\[img width=([0-9]{1,4}) height=([0-9]{1,4})\](.+?)\[\/img\]/' => '', + '/\[img\](.+?)\[\/img\]/' => '', + '/\[quote\](.+?)\[\/quote\]/' => "
$1
", + '/\[code\](.+?)\[\/code\]/' => "
$1
", + // Смайлы + '/\:smile0\:/' => '', + '/\:baby\:/' => '', + '/\:sniper\:/' => '', + '/\:trup\:/' => '', + '/\:beggar\:/' => '', + '/\:rotate\:/' => '', + '/\:hello\:/' => '', + '/\:sten\:/' => '', + '/\:shuffle\:/' => '', + '/\:elix\:/' => '', + '/\:smil\:/' => '', + '/\:mdr\:/' => '', + '/\:podz\:/' => '', + '/\:dont\:/' => '', + '/\:grust\:/' => '', + '/\:boks\:/' => '', + '/\:susel\:/' => '', + '/\:dedmoroz\:/' => '', + '/\:creator\:/' => '', + '/\:no\:/' => '', + '/\:horse\:/' => '', + '/\:vamp\:/' => '', + '/\:eek\:/' => '', + '/\:sorry\:/' => '', + '/\:friday\:/' => '', + '/\:obm\:/' => '', + '/\:smile\:/' => '', + '/\:nail\:/' => '', + '/\:gent\:/' => '', + '/\:beer\:/' => '', + '/\:inv\:/' => '', + '/\:fire\:/' => '', + '/\:dance1\:/' => '', + '/\:maniac\:/' => '', + '/\:kiss4\:/' => '', + '/\:confused\:/' => '', + '/\:kiss2\:/' => '', + '/\:snowfight\:/' => '', + '/\:row\:/' => '', + '/\:naem\:/' => '', + '/\:radio1\:/' => '', + '/\:fie\:/' => '', + '/\:love\:/' => '', + '/\:sneeze\:/' => '', + '/\:mol\:/' => '', + '/\:showng\:/' => '', + '/\:rocket\:/' => '', + '/\:dustman\:/' => '', + '/\:rupor\:/' => '', + '/\:nnn\:/' => '', + '/\:snegur\:/' => '', + '/\:dance2\:/' => '', + '/\:jeer\:/' => '', + '/\:kiss\:/' => '', + '/\:ponder\:/' => '', + '/\:drink\:/' => '', + '/\:angel\:/' => '', + '/\:idea\:/' => '', + '/\:lady\:/' => '', + '/\:gun\:/' => '', + '/\:pif\:/' => '', + '/\:help\:/' => '', + '/\:alch\:/' => '', + '/\:kiss3\:/' => '', + '/\:hug\:/' => '', + '/\:lordhaos\:/' => '', + '/\:rose\:/' => '', + '/\:radio2\:/' => '', + '/\:boks2\:/' => '', + '/\:str\:/' => '', + '/\:invis\:/' => '', + '/\:rev\:/' => '', + '/\:ok\:/' => '', + '/\:alien\:/' => '', + '/\:smash\:/' => '', + '/\:super\:/' => '', + '/\:love2\:/' => '', + '/\:victory\:/' => '', + '/\:kruger\:/' => '', + '/\:agree\:/' => '', + '/\:hi\:/' => '', + '/\:privet\:/' => '', + '/\:devil\:/' => '', + '/\:naem2\:/' => '', + '/\:tongue\:/' => '', + '/\:red\:/' => '', + '/\:doc\:/' => '', + '/\:icon7\:/' => '', + '/\:lightfly\:/' => '', + '/\:owl\:/' => '', + '/\:pirate\:/' => '', + '/\:sword\:/' => '', + '/\:bye\:/' => '', + '/\:mad\:/' => '', + '/\:fingal\:/' => '', + '/\:nono\:/' => '', + '/\:loveya\:/' => '', + '/\:cry\:/' => '', + '/\:superng\:/' => '', + '/\:yes\:/' => '', + '/\:crying\:/' => '', + '/\:\'\(\:/' => '', + '/\:flowers\:/' => '', + '/\:tease\:/' => '', + '/\:wink\:/' => '', + '/\:sharp\:/' => '', + '/\:nunu\:/' => '', + '/\:angel2\:/' => '', + '/\:naem3\:/' => '', + '/\:lick\:/' => '', + '/\:ninja\:/' => '', + '/\:cat\:/' => '', + '/\:smoke\:/' => '', + '/\:chtoza\:/' => '', + '/\:grace\:/' => '', + '/\:tongue2\:/' => '', + '/\:sorry2\:/' => '', + '/\:yar\:/' => '', + '/\:king2\:/' => '', + '/\:carreat\:/' => '', + '/\:hlw\:/' => '', + '/\:grenade\:/' => '', + '/\:bow\:/' => '', + '/\:doc2\:/' => '', + '/\:duel\:/' => '', + '/\:mag\:/' => '', + '/\:king\:/' => '', + '/\:laugh\:/' => '', + '/\:pal\:/' => '', + '/\:nun\:/' => '', + '/\:ura\:/' => '', + ); + + $text = preg_replace(array_keys($bbCodes), array_values($bbCodes), $text); + $text = close_dangling_tags($text); + + return $text; +} + +function close_dangling_tags($html) +{ + preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU", $html, $result); + $openedtags = $result[1]; + preg_match_all("##iU", $html, $result); + $closedtags = $result[1]; + $len_opened = count($openedtags); + if (count($closedtags) == $len_opened) { + return $html; + } + $openedtags = array_reverse($openedtags); + for ($i = 0; $i < $len_opened; $i++) { + if (!in_array($openedtags[$i], $closedtags)) { + if ($openedtags[$i] != 'br') { + $html .= ''; + } + } else { + unset($closedtags[array_search($openedtags[$i], $closedtags)]); + } + } + return $html; +} + +if (isset($_POST['add']) && isset($user['id'])) { + + $icon = htmlentities($_POST['icon'], ENT_NOQUOTES, 'utf8'); + $text2 = htmlspecialchars($_POST['title'], ENT_NOQUOTES, 'utf8'); + $text1 = parse_bb_code(preg_replace("/\n/", "
", $_POST['text'])); + + $minmax = db::c()->query('SELECT `min_align`, `max_align` FROM `forum` WHERE `id` = ?i', $_GET['conf'])->fetch_assoc(); + $min_align = $minmax['min_align']; + $max_align = $minmax['max_align']; + + rtrim($_POST['title']); + rtrim($_POST['text']); + if (empty($_POST['text']) || empty($_POST['title'])) { + $error = "Заголовок или текст не могут быть пустыми!"; + } elseif (($minmax['min_align'] == 0 && $minmax['max_align'] == 0) || ($user['align'] >= $minmax['min_align'] && $user['align'] <= $minmax['max_align']) || $isAdmin) { + if ($user['invis'] == 1) { + $userPost = 'Невидимка'; + } else { + $userPost = nick::id($user['id'])->full(1); + } + if ($isModerator == false) $text1 = strip_tags($text1, '
'); + + db::c()->query('INSERT INTO `forum` (`type`, `topic`, `text`, `parent`, `author`, `date`, `min_align`, `max_align`, `icon`) VALUES (2,"?s","?s",?i,"?s","?s","?s","?s","?s")', $text2, $text1, $_GET['conf'], $userPost, date('d.m.y H:i:s'), $min_align, $max_align, $icon); + $topic_id = db::c()->getLastInsertId(); + unset($_POST['text']); + print ""; + exit(); + } else { + $error = "Вы не можете писать в этой конференции!"; + } + unset($_POST['add']); +} + +if (isset($_POST['add2']) && isset($user['id'])) { + $text2 = htmlspecialchars($_POST['title'], ENT_NOQUOTES, 'utf8'); + $text1 = parse_bb_code(preg_replace("/\n/", "
", $_POST['text'])); + + $minmax = db::c()->query('SELECT `min_align`,`max_align`, `close`, `parent` FROM `forum` WHERE `id` = ?i', $_GET['topic'])->fetch_assoc(); + $min_align = $minmax['min_align']; + $max_align = $minmax['max_align']; + + rtrim($_POST['text']); + if (empty($_POST['text'])) { + $error = "Текст не может быть пустыми"; + } elseif (!is_numeric($_GET['topic'])) { + $error = "Не надо так делать"; + } + + if (($minmax['min_align'] == 0 && $minmax['max_align'] == 0) || ($user['align'] >= $minmax['min_align'] && $user['align'] <= $minmax['max_align']) && $minmax['close'] == "0" || $isAdmin) { + if ($user['invis'] == 1) { + $userPost = 'Невидимка'; + } else { + $userPost = nick::id($user['id'])->full(1); + } + + if ($isModerator == false) { + $text1 = strip_tags($text1, '

'); + } + + db::c()->query('INSERT INTO `forum` (`type`, `topic`, `text`, `parent`, `author`, `date`, `min_align`, `max_align`) VALUES (2,"?s","?s",?i,"?s","?s","?s","?s")', $text2, $text1, $_GET['topic'], $userPost, date('d.m.y H:i:s'), $min_align, $max_align); + db::c()->query('UPDATE `forum` SET `updated` = now() WHERE `id` = ?i', $_GET['topic']); + + unset($_POST['text']); + if (isset($_GET['page']) && (int)$_GET['page'] > 0) { + $page_num = '&page=' . $_GET['page']; + } else { + $page_num = '&page=0'; + } + echo ''; + exit(); + } else { + $error = "Вы не можете писать в этой конференции!"; + } + unset($_POST['add2']); +} + +if (isset($_GET['dp']) && $isModerator == true) { + if ($_GET['dp'] > 100) { + db::c()->query('DELETE FROM `forum` WHERE `id` = ?i OR `parent` = ?i', $_GET['dp'], $_GET['dp']); + echo ""; + exit(); + } +} + +if (isset($_GET['dt']) && $isModerator == true) { + if ($_GET['dt'] > 100) { + db::c()->query('DELETE FROM `forum` WHERE `id` = ?i OR `parent` = ?i', $_GET['dt'], $_GET['dt']); + echo ""; + exit(); + } +} + +if (isset($_GET['com']) && isset($_GET['cpr']) && $isModerator == true) { + if ($user['invis'] == 1) { + $addText = "
Невидимка: " . $_GET['cpr']; + } else { + $addText = nick::id($user['id'])->full(1) . ": " . $_GET['cpr']; + } + db::c()->query('UPDATE `forum` SET `text` = CONCAT(`text`,"?s") WHERE `id` = ?i', $addText, $_GET['com']); + echo ""; + exit(); +} + +if (isset($_GET['do']) && $isModerator == true) { + if ($_GET['do'] == "open") { + db::c()->query('UPDATE `forum` SET `close` = 0 WHERE `id` = "?s"', $_GET['topic']); + echo ""; + exit(); + } + + if ($_GET['do'] == "close") { + $closeComment = "Обсуждение закрыл " . ($isAdmin) ? "Администратор" : nick::id($user['id'])->full(1); + db::c()->query('UPDATE `forum` SET `close` = 1, `closepal` = "?s" WHERE `id` = "?s"', $closeComment, $_GET['topic']); + echo ""; + exit(); + } + + if ($_GET['do'] == "fix") { + db::c()->query('UPDATE `forum` SET `fix` = 1 WHERE `id` = "?s"', $_GET['topic']); + echo ""; + exit(); + } + + if ($_GET['do'] == "unfix") { + db::c()->query('UPDATE `forum` SET `fix` = 0 WHERE `id` = "?s"', $_GET['topic']); + echo ""; + exit(); + } +} ?> @@ -55,49 +366,26 @@ if (isset($_GET['topic']) && is_numeric($_GET['topic']) && $_GET['topic'] == 228

Форум

← на главную - - +

+ full(1) . "
"; ?> +

Конференции

Не авторизованы
"; - } else { - echo "Игрок : " . nick::id($user['id'])->full(1) . "
"; - } - ?> -

Конференции

- query('SELECT `min_align`, `max_align` FROM `forum` WHERE `id` = ?i', $_POST['selectt'])->fetch_assoc(); - db::c()->query('UPDATE `forum` SET `parent` = ?i, `min_align` = "?s", `max_align` = "?s" WHERE `id` = ?i', $_POST['selectt'], $AlignTop['min_align'], $AlignTop['max_align'], $_POST['numt']); - } - - if (!isset($_GET['conf']) && !isset($_GET['topic'])) { - $_GET['conf'] = 1; - } - - $Movemess = ($dostupPal == true) ? 1 : 0; - $replasepost = ''; - if ((isset($_GET['conf']) && is_numeric($_GET['conf'])) || (isset($_GET['konftop']) && is_numeric($_GET['konftop'])) || $Movemess == 1) { $data = db::c()->query('SELECT * FROM `forum` WHERE `parent` = 0 AND `type` = 1 ORDER BY `id` ASC'); while ($row = $data->fetch_assoc()) { - if ($row['id'] == 228043095) { - $news_topic = true; - } - - if (($row['min_align'] == 0 && $row['max_align'] == 0) || ($user['align'] >= $row['min_align'] && $user['align'] <= $row['max_align']) || $user['align'] == '1.99' || $user['admin'] == '1' || $user['align'] == '10') { + if (($row['min_align'] == 0 && $row['max_align'] == 0) || ($user['align'] >= $row['min_align'] && $user['align'] <= $row['max_align']) || $isAdmin) { $replasepost .= ""; $min = $row['min_align'] == 0; $max = $row['max_align'] == 0; - if (!isset($user['id']) || (($user['align'] < $row['min_align']) || ($user['align'] > $row['max_align']) && !$min && !$max) && $user['align'] != '2.99') { - echo '   '; + if (!isset($user['id']) || (($user['align'] < $row['min_align']) || ($user['align'] > $row['max_align']) && !$min && !$max)) { + echo '  📕'; } else { - echo '    '; + echo '  📖 '; } echo '' . $row['topic'] . '
'; } @@ -107,516 +395,204 @@ if (isset($_GET['topic']) && is_numeric($_GET['topic']) && $_GET['topic'] == 228
"<$1$2>", - '/\[(left|center|right)\]/' => '

', - '/\[\/(left|center|right)\]/' => '

', - '/\[url\s?(src=)?\s?(.+?)\s?(target=(_blank|_self))?\](.+?)\[\/url\]/' => '$5', - '/\[img width=([0-9]{1,4}) height=([0-9]{1,4})\](.+?)\[\/img\]/' => '', - '/\[img\](.+?)\[\/img\]/' => '', - '/\[quote\](.+?)\[\/quote\]/' => "
$1
", - '/\[code\](.+?)\[\/code\]/' => "
$1
", - // Смайлы - '/\:smile0\:/' => '', - '/\:baby\:/' => '', - '/\:sniper\:/' => '', - '/\:trup\:/' => '', - '/\:beggar\:/' => '', - '/\:rotate\:/' => '', - '/\:hello\:/' => '', - '/\:sten\:/' => '', - '/\:shuffle\:/' => '', - '/\:elix\:/' => '', - '/\:smil\:/' => '', - '/\:mdr\:/' => '', - '/\:podz\:/' => '', - '/\:dont\:/' => '', - '/\:grust\:/' => '', - '/\:boks\:/' => '', - '/\:susel\:/' => '', - '/\:dedmoroz\:/' => '', - '/\:creator\:/' => '', - '/\:no\:/' => '', - '/\:horse\:/' => '', - '/\:vamp\:/' => '', - '/\:eek\:/' => '', - '/\:sorry\:/' => '', - '/\:friday\:/' => '', - '/\:obm\:/' => '', - '/\:smile\:/' => '', - '/\:nail\:/' => '', - '/\:gent\:/' => '', - '/\:beer\:/' => '', - '/\:inv\:/' => '', - '/\:fire\:/' => '', - '/\:dance1\:/' => '', - '/\:maniac\:/' => '', - '/\:kiss4\:/' => '', - '/\:confused\:/' => '', - '/\:kiss2\:/' => '', - '/\:snowfight\:/' => '', - '/\:row\:/' => '', - '/\:naem\:/' => '', - '/\:radio1\:/' => '', - '/\:fie\:/' => '', - '/\:love\:/' => '', - '/\:sneeze\:/' => '', - '/\:mol\:/' => '', - '/\:showng\:/' => '', - '/\:rocket\:/' => '', - '/\:dustman\:/' => '', - '/\:rupor\:/' => '', - '/\:nnn\:/' => '', - '/\:snegur\:/' => '', - '/\:dance2\:/' => '', - '/\:jeer\:/' => '', - '/\:kiss\:/' => '', - '/\:ponder\:/' => '', - '/\:drink\:/' => '', - '/\:angel\:/' => '', - '/\:idea\:/' => '', - '/\:lady\:/' => '', - '/\:gun\:/' => '', - '/\:pif\:/' => '', - '/\:help\:/' => '', - '/\:alch\:/' => '', - '/\:kiss3\:/' => '', - '/\:hug\:/' => '', - '/\:lordhaos\:/' => '', - '/\:rose\:/' => '', - '/\:radio2\:/' => '', - '/\:boks2\:/' => '', - '/\:str\:/' => '', - '/\:invis\:/' => '', - '/\:rev\:/' => '', - '/\:ok\:/' => '', - '/\:alien\:/' => '', - '/\:smash\:/' => '', - '/\:super\:/' => '', - '/\:love2\:/' => '', - '/\:victory\:/' => '', - '/\:kruger\:/' => '', - '/\:agree\:/' => '', - '/\:hi\:/' => '', - '/\:privet\:/' => '', - '/\:devil\:/' => '', - '/\:naem2\:/' => '', - '/\:tongue\:/' => '', - '/\:red\:/' => '', - '/\:doc\:/' => '', - '/\:icon7\:/' => '', - '/\:lightfly\:/' => '', - '/\:owl\:/' => '', - '/\:pirate\:/' => '', - '/\:sword\:/' => '', - '/\:bye\:/' => '', - '/\:mad\:/' => '', - '/\:fingal\:/' => '', - '/\:nono\:/' => '', - '/\:loveya\:/' => '', - '/\:cry\:/' => '', - '/\:superng\:/' => '', - '/\:yes\:/' => '', - '/\:crying\:/' => '', - '/\:\'\(\:/' => '', - '/\:flowers\:/' => '', - '/\:tease\:/' => '', - '/\:wink\:/' => '', - '/\:sharp\:/' => '', - '/\:nunu\:/' => '', - '/\:angel2\:/' => '', - '/\:naem3\:/' => '', - '/\:lick\:/' => '', - '/\:ninja\:/' => '', - '/\:cat\:/' => '', - '/\:smoke\:/' => '', - '/\:chtoza\:/' => '', - '/\:grace\:/' => '', - '/\:tongue2\:/' => '', - '/\:sorry2\:/' => '', - '/\:yar\:/' => '', - '/\:king2\:/' => '', - '/\:carreat\:/' => '', - '/\:hlw\:/' => '', - '/\:grenade\:/' => '', - '/\:bow\:/' => '', - '/\:doc2\:/' => '', - '/\:duel\:/' => '', - '/\:mag\:/' => '', - '/\:king\:/' => '', - '/\:laugh\:/' => '', - '/\:pal\:/' => '', - '/\:nun\:/' => '', - '/\:ura\:/' => '', - ); - - $text = preg_replace(array_keys($bbCodes), array_values($bbCodes), $text); - $text = close_dangling_tags($text); - - return $text; - } - - function close_dangling_tags($html) - { - preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU", $html, $result); - $openedtags = $result[1]; - preg_match_all("##iU", $html, $result); - $closedtags = $result[1]; - $len_opened = count($openedtags); - if (count($closedtags) == $len_opened) { - return $html; - } - $openedtags = array_reverse($openedtags); - for ($i = 0; $i < $len_opened; $i++) { - if (!in_array($openedtags[$i], $closedtags)) { - if ($openedtags[$i] != 'br') { - $html .= ''; - } - } else { - unset($closedtags[array_search($openedtags[$i], $closedtags)]); - } - } - return $html; - } - - if (isset($_POST['add']) && isset($user['id'])) { - - $icon = htmlentities($_POST['icon'], ENT_NOQUOTES, 'utf8'); - $text2 = htmlspecialchars($_POST['title'], ENT_NOQUOTES, 'utf8'); - $text1 = parse_bb_code(preg_replace("/\n/", "
", $_POST['text'])); - - $minmax = db::c()->query('SELECT `min_align`, `max_align` FROM `forum` WHERE `id` = ?i', $_GET['conf'])->fetch_assoc(); - $min_align = $minmax['min_align']; - $max_align = $minmax['max_align']; - if (!isset($_POST['text']) || !isset($_POST['title']) || $_POST['title'] == "" || $_POST['title'] == " " || $_POST['text'] == "" || $_POST['text'] == " ") { - $error = "Заголовок или текст не могут быть пустыми!"; - } elseif (($minmax['min_align'] == 0 && $minmax['max_align'] == 0) || ($user['align'] >= $minmax['min_align'] && $user['align'] <= $minmax['max_align']) || $dostupSovet) { - if ($user['invis'] == 1) { - $userPost = 'Невидимка'; - } else { - $userPost = nick::id($user['id'])->full(1); - } - if ($dostupPal == false) $text1 = strip_tags($text1, '
'); - - db::c()->query('INSERT INTO `forum` (`type`, `topic`, `text`, `parent`, `author`, `date`, `min_align`, `max_align`, `icon`) VALUES (2,"?s","?s",?i,"?s","?s","?s","?s","?s")', $text2, $text1, $_GET['conf'], $userPost, date('d.m.y H:i:s'), $min_align, $max_align, $icon); - $topic_id = db::c()->getLastInsertId(); - unset($_POST['text']); - print ""; - exit(); - } else { - $error = "Вы не можете писать в этой конференции!"; - } - unset($_POST['add']); - } - - if (isset($_POST['add2']) && isset($user['id'])) { - $text2 = htmlspecialchars($_POST['title'], ENT_NOQUOTES, 'utf8'); - $text1 = parse_bb_code(preg_replace("/\n/", "
", $_POST['text'])); - - $minmax = db::c()->query('SELECT `min_align`,`max_align`, `close`, `parent` FROM `forum` WHERE `id` = ?i', $_GET['topic'])->fetch_assoc(); - $min_align = $minmax['min_align']; - $max_align = $minmax['max_align']; - - if (!isset($_POST['text']) || $_POST['text'] == "" || $_POST['text'] == " ") { - $error = "Текст не может быть пустыми"; - } elseif (!is_numeric($_GET['topic'])) { - $error = "Не надо так делать"; - } - - if (($minmax['min_align'] == 0 && $minmax['max_align'] == 0) || ($user['align'] >= $minmax['min_align'] && $user['align'] <= $minmax['max_align']) && $minmax['close'] == "0" || $dostupSovet) { - if ($user['invis'] == 1) { - $userPost = 'Невидимка'; - } else { - $userPost = nick::id($user['id'])->full(1); - } - - if ($dostupPal == false) { - $text1 = strip_tags($text1, '

'); - } - - db::c()->query('INSERT INTO `forum` (`type`, `topic`, `text`, `parent`, `author`, `date`, `min_align`, `max_align`) VALUES (2,"?s","?s",?i,"?s","?s","?s","?s")', $text2, $text1, $_GET['topic'], $userPost, date('d.m.y H:i:s'), $min_align, $max_align); - db::c()->query('UPDATE `forum` SET `updated` = now() WHERE `id` = ?i', $_GET['topic']); - - unset($_POST['text']); - if (isset($_GET['page']) && (int)$_GET['page'] > 0) { - $page_num = '&page=' . $_GET['page']; - } else { - $page_num = '&page=0'; - } - echo ''; - exit(); - } else { - $error = "Вы не можете писать в этой конференции!"; - } - unset($_POST['add2']); - } - - if (isset($_GET['dp']) && $dostupPal == true) { - if ($_GET['dp'] > 100) { - db::c()->query('DELETE FROM `forum` WHERE `id` = ?i OR `parent` = ?i', $_GET['dp'], $_GET['dp']); - echo ""; - exit(); - } - } - - if (isset($_GET['dt']) && $dostupPal == true) { - if ($_GET['dt'] > 100) { - db::c()->query('DELETE FROM `forum` WHERE `id` = ?i OR `parent` = ?i', $_GET['dt'], $_GET['dt']); - echo ""; - exit(); - } - } - - if (isset($_GET['com']) && isset($_GET['cpr']) && $dostupPal == true) { - if ($user['invis'] == 1) { - $addText = "
Невидимка: " . $_GET['cpr']; - } else { - $addText = nick::id($user['id'])->full(1) . ": " . $_GET['cpr']; - } - db::c()->query('UPDATE `forum` SET `text` = CONCAT(`text`,"?s") WHERE `id` = ?i', $addText, $_GET['com']); - echo ""; - exit(); - } - - if (isset($_GET['do']) && $dostupPal == true) { - if ($_GET['do'] == "open") { - db::c()->query('UPDATE `forum` SET `close` = 0 WHERE `id` = "?s"', $_GET['topic']); - echo ""; - exit(); - } - - if ($_GET['do'] == "close") { - $closeComment = "Обсуждение закрыл " . ($user['admin'] == 1) ? "Администратор" : nick::id($user['id'])->full(1); - db::c()->query('UPDATE `forum` SET `close` = 1, `closepal` = "?s" WHERE `id` = "?s"', $closeComment, $_GET['topic']); - echo ""; - exit(); - } - - if ($_GET['do'] == "fix") { - db::c()->query('UPDATE `forum` SET `fix` = 1 WHERE `id` = "?s"', $_GET['topic']); - echo ""; - exit(); - } - - if ($_GET['do'] == "unfix") { - db::c()->query('UPDATE `forum` SET `fix` = 0 WHERE `id` = "?s"', $_GET['topic']); - echo ""; - exit(); - } - } - if (!isset($_GET['conf'])) { - $row = db::c()->query('SELECT * FROM `forum` WHERE `id` = "?s"', $_GET['topic'])->fetch_assoc(); - if (($row['min_align'] == 0 && $row['max_align'] == 0) || ($user['align'] >= $row['min_align'] && $user['align'] <= $row['max_align']) || $user['admin'] == "1") { - $top = $row['parent']; - $parentCat = db::c()->query('SELECT * FROM `forum` WHERE `id` = ?i', $top)->fetch_assoc(); - $icons = $row['icon']; - ?> -
- query('SELECT `closepal`, `id` FROM `forum` WHERE `id` = "?s"', $_GET['topic'])->fetch_row(); - if (((int)$par_top[1] != 0) || ((int)$_GET['konftop'] > 0)) { - if ($row['close'] == 1) { - $close = "Открыть"; - $closed = 1; - $closepal = $row['closepal']; - } else { - $close = "Закрыть"; - } - if ($row['fix'] == 1) { - $fix = "Открепить"; - } else { - $fix = "Прикрепить"; - } - - if ($dostupPal == true) { - echo '
-
- - ' . $close . ' | ' . $fix . ' - -

- '; - echo "
"; - if (isset($_POST['selectt'], $_POST['numt']) && $_POST['selectt'] != '' && $_POST['numt'] != '') { - $error = "

Тема перемещена.

forum.php?topic=" . $_POST['numt'] . "&konftop=" . $_POST['selectt'] . ""; - } - } - $pgs = db::c()->query('SELECT count(`id`) FROM `forum` WHERE `parent` = "?s"', $_GET['topic'])->fetch_row(); - $pgs = $pgs[0] / 20; - if ($pgs > 1) echo " Страницы : "; - $pages_str = ''; - $page = isset($_GET['page']) ? (((int)$_GET['page'] + 1) > $pgs ? ($pgs - 1) : (int)$_GET['page']) : 0; - $page = ceil($page); - if ($pgs > 1) { - for ($i = 0; $i < ceil($pgs); $i++) { - if (($i > ($page - 5)) && ($i <= ($page + 4))) { - $pages_str .= ($i == $page ? " " . ($i + 1) . "" : " " . ($i + 1) . ""); - } - } - $pages_str .= ($page < $pgs - 5 ? " ..." : ""); - $pages_str = ($page > 4 ? " « ... " : "") . $pages_str . (($page < ($pgs - 1) ? " » " : "")); - } - $FirstPage = (ceil($pgs) > 4 ? $_GET['page'] > 0 ? " Первая " : "" : ""); - $LastPage = (ceil($pgs) > 4 ? (ceil($pgs) - 1) != $_GET['page'] ? " Последняя " : "" : ""); - $pages_str = $FirstPage . $pages_str . $LastPage; - echo $pages_str; - - if ($dostupSovet == true) $edit = ""; - - ?> -
- - - -
- "" -
("")
- - - - - - "; - echo " "; - } - - echo "

"; - echo " " . $row['text'] . "
"; - - $sort_type = 'ASC'; - - if (isset($_GET['topic']) && is_numeric($_GET['topic']) && $_GET['topic'] == 228043095) { - $sort_type = 'DESC'; - } - - if (empty($_GET['page'])) $_GET['page'] = ""; - - #$data = mysql_query("SELECT * FROM `forum` WHERE `parent` = '" . mysql_real_escape_string($_GET['topic']) . "' ORDER by `id` {$sort_type} LIMIT " . (int)($_GET['page'] * 20) . ",20"); - $data = db::c()->query('SELECT * FROM `forum` WHERE `parent` = "?s" ORDER BY "?s" LIMIT ?i,20', $_GET['topic'], $sort_type, ($_GET['page'] * 20)); - while ($row = $data->fetch_assoc()) { - echo "
- - - - - -
- - " . $row['author'] . " (" . $row['date'] . ") - "; - if ($dostupSovet == true) { - $edit = ""; - } - - if ($dostupPal == true && $news_topic == false) { - echo " "; - echo " "; - } - echo " - - - - $edit -
- "; - echo " " . ($row['text']) . " -
-
- "; - } - if ($pgs > 1) { - echo " Страницы : "; - } - echo $pages_str; - $closed = ''; - $closepal = ''; - - if (($closed == 1 && $_GET['topic'] != 228043095)) { - echo "
" . $closepal . "


"; - } else { - if (isset($user['baned']) AND $user['baned'] == 1) { - $error = "

Заблокированным персонажам запрещено писать на форуме!

"; - } elseif ($user['level'] < 2) { - $error = "

Персонажам до 2-го уровня запрещено писать на форуме!

"; - } elseif (isset($sleep['id'])) { - $error = "

Персонажам с заклинанием форумного молчания запрещено писать на форуме!

"; - } elseif ($user['level'] > 1 && !isset($sleep['id'])) { - ?> - -
- - - - -

- - - - - - - - - - -
-

Оставить комментарий

-
- - - - -
- -
-
- -
-
- - - - - -
-
"; - } - } - } else { - echo "Тема удалена с форума, либо её не существует
"; - } - } - } else { - if (is_numeric($_GET['conf']) && $row = db::c()->query('SELECT * FROM `forum` WHERE `id` = ?i', $_GET['conf'])->fetch_assoc()) { - if (($row['min_align'] == 0 && $row['max_align'] == 0) || ($user['align'] >= $row['min_align'] && $user['align'] <= $row['max_align']) || $dostupSovet) { + $row = db::c()->query('SELECT * FROM `forum` WHERE `id` = "?s"', $_GET['topic'])->fetch_assoc(); + if (($row['min_align'] == 0 && $row['max_align'] == 0) || ($user['align'] >= $row['min_align'] && $user['align'] <= $row['max_align']) || $isAdmin) { + $top = $row['parent']; + $parentCat = db::c()->query('SELECT * FROM `forum` WHERE `id` = ?i', $top)->fetch_assoc(); + $icons = $row['icon']; ?> + + query('SELECT `closepal`, `id` FROM `forum` WHERE `id` = "?s"', $_GET['topic'])->fetch_row(); + if (((int)$par_top[1] != 0) || ((int)$_GET['konftop'] > 0)) { + if ($row['close'] == 1) { + $close = "Открыть"; + $closed = 1; + $closepal = $row['closepal']; + } else { + $close = "Закрыть"; + } + if ($row['fix'] == 1) { + $fix = "Открепить"; + } else { + $fix = "Прикрепить"; + } + + if ($isModerator == true) { + ?> +
+
+ + | + +

+ + +
+ Тема перемещена.forum.php?topic=" . $_POST['numt'] . "&konftop=" . $_POST['selectt'] . ""; + } + } + $pgs = db::c()->query('SELECT count(`id`) FROM `forum` WHERE `parent` = "?s"', $_GET['topic'])->fetch_row(); + $pgs = $pgs[0] / 20; + if ($pgs > 1) echo " Страницы : "; + $pages_str = ''; + $page = isset($_GET['page']) ? (((int)$_GET['page'] + 1) > $pgs ? ($pgs - 1) : (int)$_GET['page']) : 0; + $page = ceil($page); + if ($pgs > 1) { + for ($i = 0; $i < ceil($pgs); $i++) { + if (($i > ($page - 5)) && ($i <= ($page + 4))) { + $pages_str .= ($i == $page ? " " . ($i + 1) . "" : " " . ($i + 1) . ""); + } + } + $pages_str .= ($page < $pgs - 5 ? " ..." : ""); + $pages_str = ($page > 4 ? " « ... " : "") . $pages_str . (($page < ($pgs - 1) ? " » " : "")); + } + $FirstPage = (ceil($pgs) > 4 ? $_GET['page'] > 0 ? " Первая " : "" : ""); + $LastPage = (ceil($pgs) > 4 ? (ceil($pgs) - 1) != $_GET['page'] ? " Последняя " : "" : ""); + $pages_str = $FirstPage . $pages_str . $LastPage; + echo $pages_str; + + ?> +
+ + + + +
+ "" +
("")
+ + + + + + + + + + + + + + + +
+
+
+ +
+ query('SELECT * FROM `forum` WHERE `parent` = "?s" ORDER BY `id` ASC LIMIT ?i,20', $_GET['topic'], ($_GET['page'] * 20)); + while ($row = $data->fetch_assoc()): ?> +
+
+ + + + + +
+ () + + + + + + + + + + + + + + + +
+
+ +
+ 1) { + echo " Страницы : "; + } + echo $pages_str; + $closed = ''; + $closepal = ''; + + if ($closed == 1) { + echo "
" . $closepal . "


"; + } else { + if (!empty($user['block'])) { + $error = "

Заблокированным персонажам запрещено писать на форуме!

"; + } elseif ($user['level'] < 2) { + $error = "

Персонажам до 2-го уровня запрещено писать на форуме!

"; + } elseif (isset($sleep['id'])) { + $error = "

Персонажам с заклинанием форумного молчания запрещено писать на форуме!

"; + } elseif ($user['level'] > 1 && !isset($sleep['id'])) { + ?> + +
+ + + + + + + + + + + +
+

Оставить комментарий

+
+ +
+ + +
+ + + + + + +
+ "; + } + } else { + if (is_numeric($_GET['conf']) && $row = db::c()->query('SELECT * FROM `forum` WHERE `id` = ?i', $_GET['conf'])->fetch_assoc()) { + if (($row['min_align'] == 0 && $row['max_align'] == 0) || ($user['align'] >= $row['min_align'] && $user['align'] <= $row['max_align']) || $isAdmin) { + ?>

@@ -663,7 +639,6 @@ if (isset($_GET['topic']) && is_numeric($_GET['topic']) && $_GET['topic'] == 228
query('SELECT * FROM `forum` WHERE `parent` = "?s" ORDER BY `fix` DESC, `updated` DESC LIMIT ?i,20', $_GET['conf'], ($_GET['page'] * 20)); while ($row = $data->fetch_assoc()) { $logi = ''; @@ -704,7 +679,7 @@ if (isset($_GET['topic']) && is_numeric($_GET['topic']) && $_GET['topic'] == 228 echo "'> {$row['topic']} " . $pages_str1 . " {$row['author']}"; - if ($dostupPal == true && $row['id'] != 228043095) { + if ($isModerator == true && $row['id'] != 228043095) { echo " "; } @@ -717,15 +692,13 @@ if (isset($_GET['topic']) && is_numeric($_GET['topic']) && $_GET['topic'] == 228 } echo $pages_str . "

"; - - if ($user['baned'] == 1) { - $error = "

Заблокированным персонажам запрещено писать на форуме!

"; + if (!empty($user['block'])) { + $error = "Вы заблокированы!"; } elseif ($user['level'] < 2) { - $error = "

Персонажам до 4-го уровня запрещено писать на форуме!

"; + $error = "Персонажам до 2-го уровня запрещено писать на форуме!"; } elseif (isset($sleep['id'])) { - $error = "

Персонажам с заклинанием форумного молчания запрещено писать на форуме!

"; - } elseif ($user['level'] > 1 && !isset($sleep['id'])) { - + $error = "Вы молчите!"; + } else { ?>
@@ -778,24 +751,21 @@ if (isset($_GET['topic']) && is_numeric($_GET['topic']) && $_GET['topic'] == 228
"; } - - } } else echo '
Ничего не найдено!
'; } ?> + - -
+ +
- + \ No newline at end of file