mambax7 /
newbb
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||
| 2 | /* |
||
| 3 | * You may not change or alter any portion of this comment or credits |
||
| 4 | * of supporting developers from this source code or any supporting source code |
||
| 5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | * |
||
| 7 | * This program is distributed in the hope that it will be useful, |
||
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | // ------------------------------------------------------------------------ // |
||
| 12 | // Author: phppp (D.J., [email protected]) // |
||
| 13 | // URL: https://xoops.org // |
||
| 14 | // Project: Article Project // |
||
| 15 | // ------------------------------------------------------------------------ // |
||
| 16 | |||
| 17 | use Xmf\Request; |
||
| 18 | use XoopsModules\Newbb\{ |
||
| 19 | Forum, |
||
| 20 | ForumHandler, |
||
| 21 | Helper, |
||
| 22 | KarmaHandler, |
||
| 23 | UserHandler, |
||
| 24 | Post, |
||
| 25 | PostHandler, |
||
| 26 | OnlineHandler, |
||
| 27 | ModerateHandler |
||
| 28 | }; |
||
| 29 | |||
| 30 | /** @var Post[] $posts */ |
||
| 31 | /** @var OnlineHandler $onlineHandler */ |
||
| 32 | /** @var Post $post */ |
||
| 33 | /** @var ModerateHandler $moderateHandler */ |
||
| 34 | require_once __DIR__ . '/header.php'; |
||
| 35 | |||
| 36 | $start = Request::getInt('start', 0, 'GET'); |
||
| 37 | $forum_id = Request::getInt('forum', 0, 'GET'); |
||
| 38 | $order = Request::getString('order', 'DESC', 'GET'); |
||
| 39 | |||
| 40 | $uid = Request::getInt('uid', 0, 'GET'); |
||
| 41 | |||
| 42 | $status = (Request::getString('status', '', 'GET') |
||
| 43 | && in_array(Request::getString('status', '', 'GET'), ['active', 'pending', 'deleted', 'new', 'all', 'digest'], true)) ? Request::getString('status', '', 'GET') : ''; |
||
| 44 | $mode = Request::getInt('mode', 0, 'GET'); |
||
| 45 | $mode = (!empty($status) && in_array($status, ['active', 'pending', 'deleted'], true)) ? 2 : $mode; |
||
| 46 | |||
| 47 | ///** @var ForumHandler $forumHandler */ |
||
| 48 | //$forumHandler = Helper::getInstance()->getHandler('Forum'); |
||
| 49 | ///** @var PostHandler $postHandler */ |
||
| 50 | //$postHandler = Helper::getInstance()->getHandler('Post'); |
||
| 51 | |||
| 52 | /** @var Forum $forumObject */ |
||
| 53 | $forumObject = null; |
||
| 54 | $forums = null; |
||
| 55 | if (empty($forum_id)) { |
||
| 56 | $forums = $forumHandler->getByPermission(0, 'view'); |
||
| 57 | $accessForums = array_keys($forums); |
||
| 58 | $isAdmin = $GLOBALS['xoopsUserIsAdmin']; |
||
| 59 | } else { |
||
| 60 | $forumObject = $forumHandler->get($forum_id); |
||
| 61 | $forums[$forum_id] = $forumObject; |
||
| 62 | $accessForums = [$forum_id]; |
||
| 63 | $isAdmin = newbbIsAdmin($forumObject); |
||
| 64 | } |
||
| 65 | |||
| 66 | /* Only admin has access to admin mode */ |
||
| 67 | if (!$isAdmin && 2 === $mode) { |
||
| 68 | $status = in_array($status, ['active', 'pending', 'deleted'], true) ? '' : $status; |
||
| 69 | $mode = 0; |
||
| 70 | } |
||
| 71 | if ($mode) { |
||
| 72 | $_GET['viewmode'] = 'flat'; |
||
| 73 | } |
||
| 74 | //echo $mode.' - '.$status; |
||
| 75 | $post_perpage = $GLOBALS['xoopsModuleConfig']['posts_per_page']; |
||
| 76 | |||
| 77 | $criteria_count = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(',', $accessForums) . ')', 'IN')); |
||
| 78 | $criteria_post = new \CriteriaCompo(new \Criteria('p.forum_id', '(' . implode(',', $accessForums) . ')', 'IN')); |
||
| 79 | $criteria_post->setSort('p.post_id'); |
||
| 80 | $criteria_post->setOrder($order); |
||
| 81 | |||
| 82 | if (!empty($uid)) { |
||
| 83 | $criteria_count->add(new \Criteria('uid', (string)$uid)); |
||
| 84 | $criteria_post->add(new \Criteria('p.uid', (string)$uid)); |
||
| 85 | } |
||
| 86 | |||
| 87 | $join = null; |
||
| 88 | // START irmtfan solve the status issues and specially status = new issue |
||
| 89 | switch ($status) { |
||
| 90 | case 'pending': |
||
| 91 | $criteria_count->add(new \Criteria('approved', '0')); // irmtfan add new \Criteria |
||
| 92 | $criteria_post->add(new \Criteria('p.approved', '0')); // irmtfan add new \Criteria |
||
| 93 | break; |
||
| 94 | case 'deleted': |
||
| 95 | $criteria_count->add(new \Criteria('approved', '-1')); // irmtfan add new \Criteria |
||
| 96 | $criteria_post->add(new \Criteria('p.approved', '-1')); // irmtfan add new \Criteria |
||
| 97 | break; |
||
| 98 | case 'new': |
||
| 99 | //$criteria_status_count = new \CriteriaCompo(new \Criteria("post_time", $last_visit, ">"));// irmtfan commented and removed |
||
| 100 | //$criteria_status_post = new \CriteriaCompo(new \Criteria("p.post_time", $last_visit, ">"));// irmtfan commented and removed |
||
| 101 | $criteria_count->add(new \Criteria('approved', '1')); // irmtfan uncomment |
||
| 102 | $criteria_post->add(new \Criteria('p.approved', '1')); // irmtfan uncomment |
||
| 103 | // following is for 'unread' -- not finished -- irmtfan Now it is finished! |
||
| 104 | if (empty($GLOBALS['xoopsModuleConfig']['read_mode'])) { |
||
| 105 | //$criteria_status_count->add(new \Criteria('approved', '1'));// irmtfan commented and removed |
||
| 106 | //$criteria_status_post->add(new \Criteria('p.approved', '1'));// irmtfan commented and removed |
||
| 107 | } elseif (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) { |
||
| 108 | // START irmtfan use read_uid to find the unread posts when the user is logged in |
||
| 109 | $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
| 110 | if (!empty($read_uid)) { |
||
| 111 | $join = ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_reads_topic') . ' AS r ON r.read_item = p.topic_id AND r.uid = ' . $read_uid . ' '; // irmtfan corrected add AS |
||
| 112 | $criteria_status_post = new \CriteriaCompo(); // irmtfan new \Criteria |
||
| 113 | $criteria_status_post->add(new \Criteria('p.post_id', 'r.`post_id`', '>')); // irmtfan corrected - should use $value='r.``' to render in XOOPS/class/criteria.php |
||
| 114 | $criteria_status_post->add(new \Criteria('r.read_id', null, 'IS NULL'), 'OR'); // irmtfan corrected - should use "IS NULL" to render in XOOPS/class/criteria.php |
||
| 115 | $criteria_post->add($criteria_status_post); // irmtfan add the status criteria to post criteria - move here |
||
| 116 | $criteria_count = $criteria_post; // irmtfan criteria count is equal to criteria post - move here |
||
| 117 | } |
||
| 118 | |||
| 119 | // END irmtfan use read_uid to find the unread posts when the user is logged in |
||
| 120 | //$criteria_status_post->add(new \Criteria("p.approved", '1')); // irmtfan commented and removed |
||
| 121 | //$criteria_status_count =& $criteria_status_post; |
||
| 122 | } elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) { |
||
| 123 | $criteria_count->add(new \Criteria('post_time', $last_visit, '>')); // irmtfan add new \Criteria |
||
| 124 | $criteria_post->add(new \Criteria('p.post_time', $last_visit, '>')); // irmtfan add new \Criteria |
||
| 125 | // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) |
||
| 126 | $topics = []; |
||
| 127 | $topic_lastread = newbbGetCookie('LT', true); |
||
| 128 | if ((is_countable($topic_lastread) ? count($topic_lastread) : 0) > 0) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 129 | foreach ($topic_lastread as $id => $time) { |
||
| 130 | if ($time > (int)$last_visit) { |
||
| 131 | $topics[] = $id; |
||
| 132 | } |
||
| 133 | } |
||
| 134 | } |
||
| 135 | if (count($topics) > 0) { |
||
| 136 | $criteria_count->add(new \Criteria('topic_id', '(' . implode(',', $topics) . ')', 'NOT IN')); |
||
| 137 | $criteria_post->add(new \Criteria('p.topic_id', '(' . implode(',', $topics) . ')', 'NOT IN')); |
||
| 138 | } |
||
| 139 | // END irmtfan fix read_mode = 1 bugs - for all users (member and anon) |
||
| 140 | //$criteria_status_count->add(new \Criteria("approved", '1'));// irmtfan commented and removed |
||
| 141 | //$criteria_status_post->add(new \Criteria("p.approved", '1'));// irmtfan commented and removed |
||
| 142 | } |
||
| 143 | break; |
||
| 144 | default: |
||
| 145 | $criteria_count->add(new \Criteria('approved', '1')); // irmtfan add new \Criteria |
||
| 146 | $criteria_post->add(new \Criteria('p.approved', '1')); // irmtfan add new \Criteria |
||
| 147 | break; |
||
| 148 | } |
||
| 149 | //$criteria_count->add($criteria_status_count); // irmtfan commented and removed |
||
| 150 | //$criteria_post->add($criteria_status_post); // irmtfan commented and removed |
||
| 151 | // END irmtfan solve the status issues and specially status = new issue |
||
| 152 | ///** @var KarmaHandler $karmaHandler */ |
||
| 153 | //$karmaHandler = Helper::getInstance()->getHandler('Karma'); |
||
| 154 | $user_karma = $karmaHandler->getUserKarma(); |
||
| 155 | |||
| 156 | $valid_modes = ['flat', 'compact']; |
||
| 157 | $viewmode_cookie = newbbGetCookie('V'); |
||
| 158 | |||
| 159 | if ('compact' === Request::getString('viewmode', '', 'GET')) { |
||
| 160 | newbbSetCookie('V', 'compact', $forumCookie['expire']); |
||
| 161 | } |
||
| 162 | |||
| 163 | $viewmode = Request::getString('viewmode', (!empty($viewmode_cookie) ? $viewmode_cookie : (@$valid_modes[$GLOBALS['xoopsModuleConfig']['view_mode'] - 1])), 'GET'); |
||
| 164 | $viewmode = in_array($viewmode, $valid_modes, true) ? $viewmode : $valid_modes[0]; |
||
| 165 | |||
| 166 | $postCount = $postHandler->getPostCount($criteria_count, $join); // irmtfan add join for read_mode = 2 |
||
| 167 | $posts = $postHandler->getPostsByLimit($criteria_post, $post_perpage, $start, $join); // irmtfan add join for read_mode = 2 |
||
| 168 | |||
| 169 | $poster_array = []; |
||
| 170 | if ((is_countable($posts) ? count($posts) : 0) > 0) { |
||
| 171 | foreach (array_keys($posts) as $id) { |
||
| 172 | $poster_array[$posts[$id]->getVar('uid')] = 1; |
||
| 173 | } |
||
| 174 | } |
||
| 175 | |||
| 176 | $xoopsPageTitle = $xoopsModule->getVar('name') . ' - ' . _MD_NEWBB_VIEWALLPOSTS; |
||
| 177 | $xoopsOption['xoops_pagetitle'] = $xoopsPageTitle; |
||
| 178 | $xoopsOption['template_main'] = 'newbb_viewpost.tpl'; |
||
| 179 | |||
| 180 | require_once $GLOBALS['xoops']->path('header.php'); |
||
| 181 | require_once __DIR__ . '/include/functions.time.php'; |
||
| 182 | require_once __DIR__ . '/include/functions.render.php'; |
||
| 183 | |||
| 184 | //global $xoTheme; |
||
| 185 | //$xoTheme->addScript('/Frameworks/textsanitizer/xoops.js'); |
||
| 186 | |||
| 187 | if (!empty($forum_id)) { |
||
| 188 | if (!$forumHandler->getPermission($forumObject, 'view')) { |
||
| 189 | redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
||
| 190 | } |
||
| 191 | if ($forumObject->getVar('parent_forum')) { |
||
| 192 | $parent_forumObject = $forumHandler->get($forumObject->getVar('parent_forum'), ['forum_name']); |
||
| 193 | $parentforum = [ |
||
| 194 | 'id' => $forumObject->getVar('parent_forum'), |
||
| 195 | 'name' => $parent_forumObject->getVar('forum_name'), |
||
| 196 | ]; |
||
| 197 | unset($parent_forumObject); |
||
| 198 | $xoopsTpl->assign_by_ref('parentforum', $parentforum); |
||
| 199 | } |
||
| 200 | $xoopsTpl->assign('forum_name', $forumObject->getVar('forum_name')); |
||
| 201 | $xoopsTpl->assign('forum_moderators', $forumObject->dispForumModerators()); |
||
| 202 | |||
| 203 | $xoopsPageTitle = $forumObject->getVar('forum_name') . ' - ' . _MD_NEWBB_VIEWALLPOSTS . ' [' . $xoopsModule->getVar('name') . ']'; |
||
| 204 | $xoopsTpl->assign('forum_id', $forumObject->getVar('forum_id')); |
||
| 205 | // irmtfan new method |
||
| 206 | if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { |
||
| 207 | $xoopsTpl->assign( |
||
| 208 | 'xoops_module_header', |
||
| 209 | ' |
||
| 210 | <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '-' . $forumObject->getVar('forum_name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php?f=' . $forum_id . '" > |
||
| 211 | ' . @$xoopsTpl->get_template_vars('xoops_module_header') |
||
| 212 | ); |
||
| 213 | } |
||
| 214 | } elseif (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { |
||
| 215 | $xoopsTpl->assign( |
||
| 216 | 'xoops_module_header', |
||
| 217 | ' |
||
| 218 | <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php" > |
||
| 219 | ' . @$xoopsTpl->get_template_vars('xoops_module_header') |
||
| 220 | ); |
||
| 221 | } |
||
| 222 | // irmtfan remove and move to footer.php |
||
| 223 | //$xoopsTpl->assign('xoops_module_header', $xoops_module_header); |
||
| 224 | $xoopsTpl->assign('xoops_pagetitle', $xoopsPageTitle); |
||
| 225 | // irmtfan - remove icon_path and use newbbDisplayImage |
||
| 226 | $xoopsTpl->assign('anonym_avatar', newbbDisplayImage('anonym')); |
||
| 227 | $userid_array = []; |
||
| 228 | if (count($poster_array) > 0) { |
||
| 229 | /** @var \XoopsMemberHandler $memberHandler */ |
||
| 230 | $memberHandler = xoops_getHandler('member'); |
||
| 231 | $userid_array = array_keys($poster_array); |
||
| 232 | $user_criteria = '(' . implode(',', $userid_array) . ')'; |
||
| 233 | $users = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true); |
||
| 234 | } else { |
||
| 235 | $user_criteria = ''; |
||
| 236 | $users = null; |
||
| 237 | } |
||
| 238 | |||
| 239 | $online = []; |
||
| 240 | |||
| 241 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
||
| 242 | if (($user_criteria !== '' && $user_criteria !== '0')) { |
||
| 243 | // $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); |
||
| 244 | $onlineHandler->init($forum_id); |
||
| 245 | } |
||
| 246 | } |
||
| 247 | |||
| 248 | $viewtopic_users = []; |
||
| 249 | |||
| 250 | if (count($userid_array) > 0) { |
||
| 251 | // require_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/user.php'); |
||
| 252 | $userHandler = new UserHandler((bool)$GLOBALS['xoopsModuleConfig']['groupbar_enabled'], (bool)$GLOBALS['xoopsModuleConfig']['wol_enabled']); |
||
| 253 | $userHandler->users = $users; |
||
| 254 | $userHandler->online = $online; |
||
| 255 | $viewtopic_users = $userHandler->getUsers(); |
||
| 256 | } |
||
| 257 | |||
| 258 | $pn = 0; |
||
| 259 | //$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); |
||
| 260 | static $suspension = []; |
||
| 261 | foreach (array_keys($posts) as $id) { |
||
| 262 | ++$pn; |
||
| 263 | |||
| 264 | $post = $posts[$id]; |
||
| 265 | $post_title = $post->getVar('subject'); |
||
| 266 | |||
| 267 | $posticon = $post->getVar('icon'); |
||
| 268 | if ($posticon) { |
||
| 269 | $post_image = '<a name="' . $post->getVar('post_id') . '"><img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars((string)$posticon, ENT_QUOTES | ENT_HTML5) . '" alt="" ></a>'; |
||
| 270 | } else { |
||
| 271 | $post_image = '<a name="' . $post->getVar('post_id') . '"><img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" ></a>'; |
||
| 272 | } |
||
| 273 | $poster = [ |
||
| 274 | 'uid' => 0, |
||
| 275 | 'name' => $post->getVar('poster_name') ?: htmlspecialchars((string)$GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5), |
||
| 276 | 'link' => $post->getVar('poster_name') ?: htmlspecialchars((string)$GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5), |
||
| 277 | ]; |
||
| 278 | if ($post->getVar('uid') > 0 && isset($viewtopic_users[$post->getVar('uid')])) { |
||
| 279 | $poster = $viewtopic_users[$post->getVar('uid')]; |
||
| 280 | } |
||
| 281 | if ($isAdmin || $post->checkIdentity()) { |
||
| 282 | $post_text = $post->getVar('post_text'); |
||
| 283 | $post_attachment = $post->displayAttachment(); |
||
| 284 | } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $post->getVar('post_karma') > $user_karma) { |
||
| 285 | $post_text = "<div class='karma'>" . sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $post->getVar('post_karma')) . '</div>'; |
||
| 286 | $post_attachment = ''; |
||
| 287 | } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $post->getVar('require_reply')) { |
||
| 288 | $post_text = "<div class='karma'>" . _MD_NEWBB_REPLY_REQUIREMENT . '</div>'; |
||
| 289 | $post_attachment = ''; |
||
| 290 | } else { |
||
| 291 | $post_text = $post->getVar('post_text'); |
||
| 292 | $post_attachment = $post->displayAttachment(); |
||
| 293 | } |
||
| 294 | |||
| 295 | $thread_buttons = []; |
||
| 296 | |||
| 297 | if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) { |
||
| 298 | if (!isset($suspension[$post->getVar('forum_id')])) { |
||
| 299 | // $moderateHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate'); |
||
| 300 | $suspension[$post->getVar('forum_id')] = !$moderateHandler->verifyUser(-1, '', $post->getVar('forum_id')); |
||
| 301 | } |
||
| 302 | |||
| 303 | if ($isAdmin |
||
| 304 | || (!$suspension[$post->getVar('forum_id')] && $post->checkIdentity() |
||
| 305 | && $post->checkTimelimit('delete_timelimit'))) { |
||
| 306 | $thread_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE); |
||
| 307 | $thread_buttons['delete']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/delete.php?forum=' . $post->getVar('forum_id') . '&topic_id=' . $post->getVar('topic_id'); |
||
| 308 | $thread_buttons['delete']['name'] = _DELETE; |
||
| 309 | } |
||
| 310 | if ($isAdmin |
||
| 311 | || !$suspension[$post->getVar('forum_id')] && $post->checkIdentity() |
||
| 312 | && $post->checkTimelimit('edit_timelimit')) { |
||
| 313 | $thread_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT); |
||
| 314 | $thread_buttons['edit']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/edit.php?forum=' . $post->getVar('forum_id') . '&topic_id=' . $post->getVar('topic_id'); |
||
| 315 | $thread_buttons['edit']['name'] = _EDIT; |
||
| 316 | } |
||
| 317 | if (is_object($GLOBALS['xoopsUser']) && !$suspension[$post->getVar('forum_id')]) { |
||
| 318 | $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY); |
||
| 319 | $thread_buttons['reply']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/reply.php?forum=' . $post->getVar('forum_id') . '&topic_id=' . $post->getVar('topic_id'); |
||
| 320 | $thread_buttons['reply']['name'] = _MD_NEWBB_REPLY; |
||
| 321 | |||
| 322 | $thread_buttons['quote']['image'] = newbbDisplayImage('p_quote', _MD_NEWBB_QUOTE); |
||
| 323 | $thread_buttons['quote']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/reply.php?forum=' . $post->getVar('forum_id') . '&topic_id=' . $post->getVar('topic_id') . '&quotedac=1'; |
||
| 324 | $thread_buttons['quote']['name'] = _MD_NEWBB_QUOTE; |
||
| 325 | } |
||
| 326 | } else { |
||
| 327 | $thread_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE); |
||
| 328 | $thread_buttons['delete']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/delete.php?forum=' . $post->getVar('forum_id') . '&topic_id=' . $post->getVar('topic_id'); |
||
| 329 | $thread_buttons['delete']['name'] = _DELETE; |
||
| 330 | $thread_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT); |
||
| 331 | $thread_buttons['edit']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/edit.php?forum=' . $post->getVar('forum_id') . '&topic_id=' . $post->getVar('topic_id'); |
||
| 332 | $thread_buttons['edit']['name'] = _EDIT; |
||
| 333 | $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY); |
||
| 334 | $thread_buttons['reply']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/reply.php?forum=' . $post->getVar('forum_id') . '&topic_id=' . $post->getVar('topic_id'); |
||
| 335 | $thread_buttons['reply']['name'] = _MD_NEWBB_REPLY; |
||
| 336 | } |
||
| 337 | |||
| 338 | if (!$isAdmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) { |
||
| 339 | $thread_buttons['report']['image'] = newbbDisplayImage('p_report', _MD_NEWBB_REPORT); |
||
| 340 | $thread_buttons['report']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/report.php?forum=' . $post->getVar('forum_id') . '&topic_id=' . $post->getVar('topic_id'); |
||
| 341 | $thread_buttons['report']['name'] = _MD_NEWBB_REPORT; |
||
| 342 | } |
||
| 343 | $thread_action = []; |
||
| 344 | |||
| 345 | $xoopsTpl->append( |
||
| 346 | 'posts', |
||
| 347 | [ |
||
| 348 | 'post_id' => $post->getVar('post_id'), |
||
| 349 | 'topic_id' => $post->getVar('topic_id'), |
||
| 350 | 'forum_id' => $post->getVar('forum_id'), |
||
| 351 | 'post_date' => newbbFormatTimestamp($post->getVar('post_time')), |
||
| 352 | 'post_image' => $post_image, |
||
| 353 | 'post_title' => $post_title, |
||
| 354 | 'post_text' => $post_text, |
||
| 355 | 'post_attachment' => $post_attachment, |
||
| 356 | 'post_edit' => $post->displayPostEdit(), |
||
| 357 | 'post_no' => $start + $pn, |
||
| 358 | 'post_signature' => $post->getVar('attachsig') ? @$poster['signature'] : '', |
||
| 359 | // 'poster_ip' => ($isAdmin && $GLOBALS['xoopsModuleConfig']['show_ip']) ? long2ip($post->getVar('poster_ip')) : '', |
||
| 360 | 'poster_ip' => ($isAdmin && $GLOBALS['xoopsModuleConfig']['show_ip']) ? $post->getVar('poster_ip') : '', |
||
| 361 | 'thread_action' => $thread_action, |
||
| 362 | 'thread_buttons' => $thread_buttons, |
||
| 363 | 'poster' => $poster, |
||
| 364 | ] |
||
| 365 | ); |
||
| 366 | |||
| 367 | unset($thread_buttons, $poster); |
||
| 368 | } |
||
| 369 | unset($viewtopic_users, $forums); |
||
| 370 | |||
| 371 | if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) { |
||
| 372 | require_once __DIR__ . '/include/functions.forum.php'; |
||
| 373 | $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id)); |
||
| 374 | } |
||
| 375 | |||
| 376 | if ($postCount > $post_perpage) { |
||
| 377 | require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
||
| 378 | $nav = new \XoopsPageNav($postCount, $post_perpage, $start, 'start', 'forum=' . $forum_id . '&viewmode=' . $viewmode . '&status=' . $status . '&uid=' . $uid . '&order=' . $order . '&mode=' . $mode); |
||
| 379 | //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . $nav->url; |
||
| 380 | if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
||
| 381 | $navi = $nav->renderSelect(); |
||
| 382 | } elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
||
| 383 | $navi = $nav->renderImageNav(4); |
||
| 384 | } else { |
||
| 385 | $navi = $nav->renderNav(4); |
||
| 386 | } |
||
| 387 | |||
| 388 | $xoopsTpl->assign('pagenav', $navi); |
||
| 389 | } else { |
||
| 390 | $xoopsTpl->assign('pagenav', ''); |
||
| 391 | } |
||
| 392 | |||
| 393 | $xoopsTpl->assign('lang_forum_index', sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars((string)$GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES))); |
||
| 394 | |||
| 395 | switch ($status) { |
||
| 396 | case 'active': |
||
| 397 | $lang_title = _MD_NEWBB_VIEWALLPOSTS . ' [' . _MD_NEWBB_TYPE_ADMIN . ']'; |
||
| 398 | break; |
||
| 399 | case 'pending': |
||
| 400 | $lang_title = _MD_NEWBB_VIEWALLPOSTS . ' [' . _MD_NEWBB_TYPE_PENDING . ']'; |
||
| 401 | break; |
||
| 402 | case 'deleted': |
||
| 403 | $lang_title = _MD_NEWBB_VIEWALLPOSTS . ' [' . _MD_NEWBB_TYPE_DELETED . ']'; |
||
| 404 | break; |
||
| 405 | case 'new': |
||
| 406 | $lang_title = _MD_NEWBB_NEWPOSTS; |
||
| 407 | break; |
||
| 408 | default: |
||
| 409 | $lang_title = _MD_NEWBB_VIEWALLPOSTS; |
||
| 410 | break; |
||
| 411 | } |
||
| 412 | if ($uid > 0) { |
||
| 413 | $lang_title .= ' (' . \XoopsUser::getUnameFromId($uid) . ')'; |
||
| 414 | } |
||
| 415 | $xoopsTpl->assign('lang_title', $lang_title); |
||
| 416 | // irmtfan up to p_up |
||
| 417 | $xoopsTpl->assign('p_up', newbbDisplayImage('up', _MD_NEWBB_TOP)); |
||
| 418 | $xoopsTpl->assign('groupbar_enable', $GLOBALS['xoopsModuleConfig']['groupbar_enabled']); |
||
| 419 | $xoopsTpl->assign('anonymous_prefix', $GLOBALS['xoopsModuleConfig']['anonymous_prefix']); |
||
| 420 | $xoopsTpl->assign('down', newbbDisplayImage('down', _MD_NEWBB_BOTTOM)); |
||
| 421 | |||
| 422 | $all_link = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . "&start=$start"; |
||
| 423 | $post_link = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id; |
||
| 424 | $newpost_link = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . '&status=new'; |
||
| 425 | $digest_link = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . "&start=$start&status=digest"; |
||
| 426 | $unreplied_link = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . "&start=$start&status=unreplied"; |
||
| 427 | $unread_link = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . "&start=$start&status=unread"; |
||
| 428 | |||
| 429 | $xoopsTpl->assign('all_link', $all_link); |
||
| 430 | $xoopsTpl->assign('post_link', $post_link); |
||
| 431 | $xoopsTpl->assign('newpost_link', $newpost_link); |
||
| 432 | $xoopsTpl->assign('digest_link', $digest_link); |
||
| 433 | $xoopsTpl->assign('unreplied_link', $unreplied_link); |
||
| 434 | $xoopsTpl->assign('unread_link', $unread_link); |
||
| 435 | |||
| 436 | $viewmode_options = []; |
||
| 437 | if ('DESC' === $order) { |
||
| 438 | $viewmode_options[] = [ |
||
| 439 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?viewmode=flat&order=ASC&forum=' . $forum_id, |
||
| 440 | 'title' => _OLDESTFIRST, |
||
| 441 | ]; |
||
| 442 | } else { |
||
| 443 | $viewmode_options[] = [ |
||
| 444 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?viewmode=flat&order=DESC&forum=' . $forum_id, |
||
| 445 | 'title' => _NEWESTFIRST, |
||
| 446 | ]; |
||
| 447 | } |
||
| 448 | |||
| 449 | //$xoopsTpl->assign('viewmode_compact', ($viewmode=="compact")?1:0); |
||
| 450 | $xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options); |
||
| 451 | $xoopsTpl->assign('menumode', $menumode); |
||
| 452 | $xoopsTpl->assign('menumode_other', $menumode_other); |
||
| 453 | |||
| 454 | $xoopsTpl->assign('viewer_level', $isAdmin ? 2 : is_object($GLOBALS['xoopsUser'])); |
||
| 455 | $xoopsTpl->assign('uid', $uid); |
||
| 456 | $xoopsTpl->assign('mode', $mode); |
||
| 457 | $xoopsTpl->assign('status', $status); |
||
| 458 | // irmtfan move to footer.php |
||
| 459 | require_once __DIR__ . '/footer.php'; |
||
| 460 | require_once $GLOBALS['xoops']->path('footer.php'); |
||
| 461 |