diff --git a/forum.php b/forum.php index d8bbc00..d808f6f 100644 --- a/forum.php +++ b/forum.php @@ -498,7 +498,8 @@ if (isset($_GET['do']) && $isModerator == true) { - | Комментарий + | + Комментарий @@ -584,10 +585,10 @@ if (isset($_GET['do']) && $isModerator == true) { 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) { $confname = 'Конференция «' . $row['topic'] . '»'; - $pgs = db::c()->query('SELECT count(`id`) FROM `forum` WHERE `parent` = ?i ORDER BY `fix` DESC, `updated` DESC', $_GET['conf'])->fetch_assoc(); + $pgs = db::c()->query('SELECT count(`id`) FROM `forum` WHERE `parent` = ?i ORDER BY `fix` DESC, `updated` DESC', $_GET['conf'])->fetch_row(); $pgs = $pgs[0] / 20; $pages_str = ''; - $page = (int)$_GET['page'] > 0 ? (((int)$_GET['page'] + 1) > $pgs ? ($pgs - 1) : (int)$_GET['page']) : 0; + $page = !empty((int)$_GET['page']) ? (((int)$_GET['page'] + 1) > $pgs ? ($pgs - 1) : (int)$_GET['page']) : 0; $page = ceil($page); ?> @@ -614,47 +615,49 @@ if (isset($_GET['do']) && $isModerator == true) { Страницы: 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 = ''; - $userlist = ''; - $icons = $row['icon']; - $data2 = db::c()->query('SELECT `author` FROM (SELECT `author`,`id` FROM `forum` WHERE `parent` = ?i ORDER BY `id` DESC LIMIT 10) AS sTable ORDER BY id DESC', $row['id']); - while ($row2 = $data2->fetch_assoc()) { - $userlist = strip_tags($row2[0], ""); - list ($username, $level) = split(" \[", $userlist); - $logi .= $username; - } - $datacount = db::c()->query('SELECT count(*) AS CountNumber FROM `forum` WHERE `parent` = ?i', $row['id'])->fetch_assoc(); - $count = $datacount["CountNumber"]; - $lasttimedb = db::c()->query('SELECT `date` FROM `forum` WHERE `parent` = ?i ORDER BY `id` DESC', $row['id'])->fetch_assoc(); - $lasttime = $lasttimedb['date']; - echo "
+ if (!empty($_GET['conf']) AND !empty($_GET['page'])) { + $data = db::c()->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 = ''; + $userlist = ''; + $icons = $row['icon']; + $data2 = db::c()->query('SELECT `author` FROM (SELECT `author`,`id` FROM `forum` WHERE `parent` = ?i ORDER BY `id` DESC LIMIT 10) AS sTable ORDER BY id DESC', $row['id']); + while ($row2 = $data2->fetch_row()) { + $userlist = strip_tags($row2[0], ""); + list ($username, $level) = split(" \[", $userlist); + $logi .= $username; + } + $datacount = db::c()->query('SELECT count(*) AS CountNumber FROM `forum` WHERE `parent` = ?i', $row['id'])->fetch_assoc(); + $count = $datacount["CountNumber"]; + $lasttimedb = db::c()->query('SELECT `date` FROM `forum` WHERE `parent` = ?i ORDER BY `id` DESC', $row['id'])->fetch_assoc(); + $lasttime = $lasttimedb['date']; + echo "

" . ($row['fix'] ? "\"Закреплено\" " : "") . "" . ($i + 1) . "" : "" . ($i + 1) . ""); - $pages_str1 .= ($page1 < $pgs1 - 5 ? " ..." : ""); - } - if ($pgs1 > 1) { - $pages_str1 = "" . $pages_str1 . ""; - } + $pgs1 = db::c()->query('SELECT count(`id`) FROM `forum` WHERE `parent` = ?i', $row['id'])->fetch_assoc(); + $pgs1 = $pgs1[0] / 20; + $pages_str1 = ''; + $page1 = (int)$_GET['page'] > 0 ? (((int)$_GET['page'] + 1) > $pgs ? ($pgs - 1) : (int)$_GET['page']) : 0; + $page1 = ceil($page1); + if ($pgs1 > 1) { + for ($i = 0; $i < ceil($pgs1); $i++) + if (($i > ($page1 - 5)) && ($i <= ($page1 + 4))) + $pages_str1 .= ($i == $page1 ? "" . ($i + 1) . "" : "" . ($i + 1) . ""); + $pages_str1 .= ($page1 < $pgs1 - 5 ? " ..." : ""); + } + if ($pgs1 > 1) { + $pages_str1 = "" . $pages_str1 . ""; + } - echo "'> {$row['topic']} " . $pages_str1 . " {$row['author']}"; + echo "'> {$row['topic']} " . $pages_str1 . " {$row['author']}"; - if ($isModerator) echo " Удалить"; + if ($isModerator) echo " Удалить"; - echo "
" . $row['date'] . " " . strip_tags(substr($row['text'], 0, 250), "") . " + echo "
" . $row['date'] . " " . strip_tags(substr($row['text'], 0, 250), "") . "
Ответов: " . $count . " (" . $lasttime . ")

"; + } } if ($pgs > 1) echo "

Страницы:";