mambax7 /
newbb5
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * NewBB 5.0x, the forum module for XOOPS project |
||
| 4 | * |
||
| 5 | * @copyright XOOPS Project (http://xoops.org) |
||
| 6 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
| 7 | * @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
||
| 8 | * @since 4.00 |
||
| 9 | * @package module::newbb |
||
| 10 | */ |
||
| 11 | |||
| 12 | use Xmf\Request; |
||
| 13 | |||
| 14 | include_once __DIR__ . '/header.php'; |
||
| 15 | |||
| 16 | $forum_id = Request::getInt('forum_id', 0, 'POST'); |
||
| 17 | $topic_id = Request::getArray('topic_id', null, 'POST'); |
||
| 18 | |||
| 19 | $op = Request::getCmd('op', '', 'POST'); |
||
| 20 | $op = in_array($op, ['approve', 'delete', 'restore', 'move'], true) ? $op : ''; |
||
| 21 | |||
| 22 | if (0 === count($topic_id) || 0 === count($op)) { |
||
| 23 | // irmtfan - issue with javascript:history.go(-1) |
||
| 24 | redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_NEWBB_NORIGHTTOACCESS); |
||
| 25 | } |
||
| 26 | |||
| 27 | $topic_id = array_values($topic_id); |
||
| 28 | /** @var \NewbbTopicHandler $topicHandler */ |
||
| 29 | $topicHandler = xoops_getModuleHandler('topic', 'newbb'); |
||
| 30 | /** @var \NewbbForumHandler $forumHandler */ |
||
| 31 | $forumHandler = xoops_getModuleHandler('forum', 'newbb'); |
||
| 32 | |||
| 33 | $isadmin = newbb_isAdmin($forum_id); |
||
| 34 | |||
| 35 | if (!$isadmin) { |
||
| 36 | redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
||
| 37 | } |
||
| 38 | switch ($op) { |
||
| 39 | View Code Duplication | case 'restore': |
|
| 40 | $forums = []; |
||
| 41 | $topics_obj = $topicHandler->getAll(new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
||
| 42 | foreach (array_keys($topics_obj) as $id) { |
||
| 43 | /** @var \Topic $topic_obj */ |
||
| 44 | $topic_obj = $topics_obj[$id]; |
||
| 45 | $topicHandler->approve($topic_obj); |
||
| 46 | $topicHandler->synchronization($topic_obj); |
||
| 47 | $forums[$topic_obj->getVar('forum_id')] = 1; |
||
| 48 | } |
||
| 49 | $criteria_forum = new Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
||
| 50 | $forums_obj = $forumHandler->getAll($criteria_forum); |
||
| 51 | foreach (array_keys($forums_obj) as $id) { |
||
| 52 | $forumHandler->synchronization($forums_obj[$id]); |
||
| 53 | } |
||
| 54 | unset($topics_obj, $forums_obj); |
||
| 55 | break; |
||
| 56 | case 'approve': |
||
| 57 | $forums = []; |
||
| 58 | $topics_obj = $topicHandler->getAll(new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
||
| 59 | foreach (array_keys($topics_obj) as $id) { |
||
| 60 | /** @var \Topic $topic_obj */ |
||
| 61 | $topic_obj = $topics_obj[$id]; |
||
| 62 | $topicHandler->approve($topic_obj); |
||
| 63 | $topicHandler->synchronization($topic_obj); |
||
| 64 | $forums[$topic_obj->getVar('forum_id')] = 1; |
||
| 65 | } |
||
| 66 | |||
| 67 | $criteria_forum = new Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
||
| 68 | $forums_obj = $forumHandler->getAll($criteria_forum); |
||
| 69 | foreach (array_keys($forums_obj) as $id) { |
||
| 70 | $forumHandler->synchronization($forums_obj[$id]); |
||
| 71 | } |
||
| 72 | |||
| 73 | if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
||
| 74 | break; |
||
| 75 | } |
||
| 76 | |||
| 77 | include_once __DIR__ . '/include/notification.inc.php'; |
||
| 78 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||
| 79 | $notificationHandler = xoops_getHandler('notification'); |
||
| 80 | foreach (array_keys($topics_obj) as $id) { |
||
| 81 | $topic_obj = $topics_obj[$id]; |
||
| 82 | $tags = []; |
||
| 83 | $tags['THREAD_NAME'] = $topic_obj->getVar('topic_title'); |
||
| 84 | $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $id . '&forum=' . $topic_obj->getVar('forum_id'); |
||
| 85 | $tags['FORUM_NAME'] = $forums_obj[$topic_obj->getVar('forum_id')]->getVar('forum_name'); |
||
| 86 | $tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $topic_obj->getVar('forum_id'); |
||
| 87 | $notificationHandler->triggerEvent('global', 0, 'new_thread', $tags); |
||
| 88 | $notificationHandler->triggerEvent('forum', $topic_obj->getVar('forum_id'), 'new_thread', $tags); |
||
| 89 | $post_obj = $topicHandler->getTopPost($id); |
||
|
0 ignored issues
–
show
|
|||
| 90 | $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post_obj->getVar('post_id'); |
||
|
0 ignored issues
–
show
|
|||
| 91 | $notificationHandler->triggerEvent('thread', $id, 'new_post', $tags); |
||
| 92 | $notificationHandler->triggerEvent('forum', $topic_obj->getVar('forum_id'), 'new_post', $tags); |
||
| 93 | $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
||
| 94 | $tags['POST_CONTENT'] = $post_obj->getVar('post_text'); |
||
|
0 ignored issues
–
show
|
|||
| 95 | $tags['POST_NAME'] = $post_obj->getVar('subject'); |
||
|
0 ignored issues
–
show
|
|||
| 96 | $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
||
| 97 | $notificationHandler->triggerEvent('forum', $topic_obj->getVar('forum_id'), 'new_fullpost', $tags); |
||
| 98 | unset($post_obj); |
||
| 99 | } |
||
| 100 | unset($topics_obj, $forums_obj); |
||
| 101 | break; |
||
| 102 | View Code Duplication | case 'delete': |
|
| 103 | $forums = []; |
||
| 104 | $topics_obj = $topicHandler->getAll(new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
||
| 105 | foreach (array_keys($topics_obj) as $id) { |
||
| 106 | $topic_obj = $topics_obj[$id]; |
||
| 107 | // irmtfan should be set to false to not delete topic from database |
||
| 108 | $topicHandler->delete($topic_obj, false); |
||
| 109 | $topicHandler->synchronization($topic_obj); |
||
| 110 | $forums[$topic_obj->getVar('forum_id')] = 1; |
||
| 111 | } |
||
| 112 | |||
| 113 | $criteria_forum = new Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
||
| 114 | $forums_obj = $forumHandler->getAll($criteria_forum); |
||
| 115 | foreach (array_keys($forums_obj) as $id) { |
||
| 116 | $forumHandler->synchronization($forums_obj[$id]); |
||
| 117 | } |
||
| 118 | unset($topics_obj, $forums_obj); |
||
| 119 | break; |
||
| 120 | case 'move': |
||
| 121 | if (Request::getInt('newforum', 0, 'POST') |
||
| 122 | && Request::getInt('newforum', 0, 'POST') !== $forum_id |
||
| 123 | && $forumHandler->getPermission(Request::getInt('newforum', 0, 'POST'), 'post') |
||
| 124 | ) { |
||
| 125 | $criteria = new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'); |
||
| 126 | /** @var \NewbbPostHandler $postHandler */ |
||
| 127 | $postHandler = xoops_getModuleHandler('post', 'newbb'); |
||
| 128 | $postHandler->updateAll('forum_id', Request::getInt('newforum', 0, 'POST'), $criteria, true); |
||
| 129 | $topicHandler->updateAll('forum_id', Request::getInt('newforum', 0, 'POST'), $criteria, true); |
||
| 130 | $forumHandler->synchronization(Request::getInt('newforum', 0, 'POST')); |
||
| 131 | $forumHandler->synchronization($forum_id); |
||
| 132 | } else { |
||
| 133 | include $GLOBALS['xoops']->path('header.php'); |
||
| 134 | /** @var \NewbbCategoryHandler $categoryHandler */ |
||
| 135 | $categoryHandler = xoops_getModuleHandler('category', 'newbb'); |
||
| 136 | $categories = $categoryHandler->getByPermission('access'); |
||
| 137 | $forums = $forumHandler->getForumsByCategory(array_keys($categories), 'post', false); |
||
| 138 | |||
| 139 | $box = '<select name="newforum" size="1">'; |
||
| 140 | View Code Duplication | if (count($categories) > 0 && count($forums) > 0) { |
|
| 141 | foreach (array_keys($forums) as $key) { |
||
| 142 | |||
| 143 | /** @var \NewbbCategory[] $categories */ |
||
| 144 | $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>'; |
||
| 145 | foreach ($forums[$key] as $forumid => $_forum) { |
||
| 146 | $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>'; |
||
| 147 | if (!isset($_forum['sub'])) { |
||
| 148 | continue; |
||
| 149 | } |
||
| 150 | foreach (array_keys($_forum['sub']) as $fid) { |
||
| 151 | $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>'; |
||
| 152 | } |
||
| 153 | } |
||
| 154 | } |
||
| 155 | } else { |
||
| 156 | $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>'; |
||
| 157 | } |
||
| 158 | $box .= '</select>'; |
||
| 159 | unset($forums, $categories); |
||
| 160 | |||
| 161 | echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>"; |
||
| 162 | echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>"; |
||
| 163 | echo "<tr><td class='bg2'>"; |
||
| 164 | echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>"; |
||
| 165 | echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">'; |
||
| 166 | echo $box; |
||
| 167 | echo '</td></tr>'; |
||
| 168 | echo '<tr class="bg3"><td colspan="2" align="center">'; |
||
| 169 | echo "<input type='hidden' name='op' value='move' />"; |
||
| 170 | echo "<input type='hidden' name='forum_id' value='{$forum_id}' />"; |
||
| 171 | foreach ($topic_id as $id) { |
||
| 172 | echo "<input type='hidden' name='topic_id[]' value='" . $id . "' />"; |
||
| 173 | } |
||
| 174 | echo "<input type='submit' name='submit' value='" . _SUBMIT . "' />"; |
||
| 175 | echo '</td></tr></table></td></tr></table>'; |
||
| 176 | echo '</form>'; |
||
| 177 | include $GLOBALS['xoops']->path('footer.php'); |
||
| 178 | exit(); |
||
| 179 | } |
||
| 180 | break; |
||
| 181 | } |
||
| 182 | /** @var \NewbbStatsHandler $statsHandler */ |
||
| 183 | $statsHandler = xoops_getModuleHandler('stats', 'newbb'); |
||
| 184 | $statsHandler->reset(); |
||
| 185 | if (empty($forum_id)) { |
||
| 186 | redirect_header(XOOPS_URL . '/modules/newbb/list.topic.php', 2, _MD_NEWBB_DBUPDATED); |
||
| 187 | } else { |
||
| 188 | redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED); |
||
| 189 | } |
||
| 190 | // irmtfan move to footer.php |
||
| 191 | include_once __DIR__ . '/footer.php'; |
||
| 192 | include $GLOBALS['xoops']->path('footer.php'); |
||
| 193 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.