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 |
||||||
2 | /** |
||||||
3 | * Newbb module |
||||||
4 | * |
||||||
5 | * You may not change or alter any portion of this comment or credits |
||||||
6 | * of supporting developers from this source code or any supporting source code |
||||||
7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
8 | * This program is distributed in the hope that it will be useful, |
||||||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
11 | * |
||||||
12 | * @copyright XOOPS Project (https://xoops.org) |
||||||
13 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||||
14 | * @package newbb |
||||||
15 | * @since 4.0 |
||||||
16 | * @author Taiwen Jiang <[email protected]> |
||||||
17 | */ |
||||||
18 | |||||||
19 | use Xmf\Request; |
||||||
20 | use XoopsModules\Newbb; |
||||||
21 | |||||||
22 | require_once __DIR__ . '/header.php'; |
||||||
23 | |||||||
24 | foreach ( |
||||||
25 | [ |
||||||
26 | 'forum', |
||||||
27 | 'topic_id', |
||||||
28 | 'post_id', |
||||||
29 | 'order', |
||||||
30 | 'pid', |
||||||
31 | 'start', |
||||||
32 | 'isreply', |
||||||
33 | 'isedit', |
||||||
34 | ] as $getint |
||||||
35 | ) { |
||||||
36 | ${$getint} = Request::getInt($getint, 0, 'POST'); |
||||||
37 | } |
||||||
38 | $token_valid = false; |
||||||
39 | $op = Request::getCmd('op', '', 'POST'); |
||||||
40 | $viewmode = ('flat' !== Request::getString('viewmode', '', 'POST')) ? 'thread' : 'flat'; |
||||||
41 | if (empty($forum)) { |
||||||
42 | redirect_header('index.php', 2, _MD_NEWBB_ERRORFORUM); |
||||||
43 | } |
||||||
44 | |||||||
45 | ///** @var Newbb\ForumHandler $forumHandler */ |
||||||
46 | //$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); |
||||||
47 | ///** @var Newbb\TopicHandler $topicHandler */ |
||||||
48 | //$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); |
||||||
49 | ///** @var Newbb\PostHandler $postHandler */ |
||||||
50 | //$postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); |
||||||
51 | |||||||
52 | if (!empty($isedit) && $post_id > 0) { |
||||||
53 | /** @var Post $postObject */ |
||||||
54 | $postObject = $postHandler->get($post_id); |
||||||
55 | $topic_id = $postObject->getVar('topic_id'); |
||||||
56 | } else { |
||||||
57 | $postObject = $postHandler->create(); |
||||||
58 | } |
||||||
59 | $topicObject = $topicHandler->get($topic_id); |
||||||
60 | $forum_id = $topic_id ? $topicObject->getVar('forum_id') : $forum; |
||||||
61 | $forumObject = $forumHandler->get($forum_id); |
||||||
62 | if (!$forumHandler->getPermission($forumObject)) { |
||||||
63 | redirect_header('index.php', 2, _NOPERM); |
||||||
64 | } |
||||||
65 | |||||||
66 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
||||||
67 | // /** @var Newbb\OnlineHandler $onlineHandler */ |
||||||
68 | // $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); |
||||||
69 | $onlineHandler->init($forumObject); |
||||||
70 | } |
||||||
71 | |||||||
72 | $error_message = []; |
||||||
73 | |||||||
74 | if (Request::getString('contents_submit', '', 'POST')) { |
||||||
75 | $token_valid = $GLOBALS['xoopsSecurity']->check(); |
||||||
76 | |||||||
77 | $captcha_invalid = false; |
||||||
78 | if (!is_object($GLOBALS['xoopsUser']) && Request::hasVar('uname', 'POST') && Request::hasVar('pass', 'POST')) { |
||||||
79 | $uname = Request::getString('uname', '', 'POST'); |
||||||
80 | $pass = Request::getString('pass', '', 'POST'); |
||||||
81 | /** @var \XoopsMemberHandler $memberHandler */ |
||||||
82 | $memberHandler = xoops_getHandler('member'); |
||||||
83 | $user = $memberHandler->loginUser($uname, $pass); |
||||||
84 | if (is_object($user) && $user->getVar('level') > 0) { |
||||||
85 | if (Request::getString('login', '', 'POST')) { |
||||||
86 | $user->setVar('last_login', time()); |
||||||
87 | if (!$memberHandler->insertUser($user)) { |
||||||
88 | } |
||||||
89 | $_SESSION = []; |
||||||
90 | $_SESSION['xoopsUserId'] = $user->getVar('uid'); |
||||||
91 | $_SESSION['xoopsUserGroups'] = $user->getGroups(); |
||||||
92 | if ($GLOBALS['xoopsConfig']['use_mysession'] && '' !== $GLOBALS['xoopsConfig']['session_name']) { |
||||||
93 | setcookie($GLOBALS['xoopsConfig']['session_name'], session_id(), time() + (60 * $GLOBALS['xoopsConfig']['session_expire']), '/', '', 0); |
||||||
94 | } |
||||||
95 | $user_theme = $user->getVar('theme'); |
||||||
96 | if (in_array($user_theme, $GLOBALS['xoopsConfig']['theme_set_allowed'])) { |
||||||
97 | $_SESSION['xoopsUserTheme'] = $user_theme; |
||||||
98 | } |
||||||
99 | } |
||||||
100 | $GLOBALS['xoopsUser'] = $user; |
||||||
101 | $xoopsUserIsAdmin = $GLOBALS['xoopsUser']->isAdmin($xoopsModule->getVar('mid')); |
||||||
102 | } |
||||||
103 | } |
||||||
104 | if (!is_object($GLOBALS['xoopsUser'])) { |
||||||
105 | xoops_load('captcha'); |
||||||
106 | $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
||||||
107 | if (!$xoopsCaptcha->verify()) { |
||||||
108 | $captcha_invalid = true; |
||||||
109 | $error_message[] = $xoopsCaptcha->getMessage(); |
||||||
110 | } |
||||||
111 | } |
||||||
112 | |||||||
113 | $isAdmin = newbbIsAdmin($forumObject); |
||||||
114 | |||||||
115 | $time_valid = true; |
||||||
116 | if (!$isAdmin && !empty($GLOBALS['xoopsModuleConfig']['post_timelimit'])) { |
||||||
117 | $last_post = newbbGetSession('LP'); |
||||||
118 | if (time() - $last_post < $GLOBALS['xoopsModuleConfig']['post_timelimit']) { |
||||||
119 | $time_valid = false; |
||||||
120 | } |
||||||
121 | } |
||||||
122 | |||||||
123 | if ($captcha_invalid || !$token_valid || !$time_valid) { |
||||||
124 | $_POST['contents_preview'] = 1; |
||||||
125 | $_POST['contents_submit'] = null; |
||||||
126 | $_POST['contents_upload'] = null; |
||||||
127 | if (!$token_valid) { |
||||||
128 | $error_message[] = _MD_NEWBB_INVALID_SUBMIT; |
||||||
129 | } |
||||||
130 | if (!$time_valid) { |
||||||
131 | $error_message[] = sprintf(_MD_NEWBB_POSTING_LIMITED, $GLOBALS['xoopsModuleConfig']['post_timelimit']); |
||||||
132 | } |
||||||
133 | } |
||||||
134 | } |
||||||
135 | |||||||
136 | if (Request::getString('contents_submit', '', 'POST')) { |
||||||
137 | $message = Request::getText('message', '', 'POST'); |
||||||
138 | if (empty($message)) { |
||||||
139 | // irmtfan - issue with javascript:history.go(-1) - add error message |
||||||
140 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 1, _MD_NEWBB_ERROR_BACK); |
||||||
141 | } |
||||||
142 | if (!empty($isedit) && $post_id > 0) { |
||||||
143 | $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||||||
144 | |||||||
145 | $topic_status = $topicObject->getVar('topic_status'); |
||||||
146 | if ($topicHandler->getPermission($forumObject, $topic_status, 'edit') |
||||||
147 | && ($isAdmin |
||||||
148 | || ($postObject->checkTimelimit('edit_timelimit') |
||||||
149 | && $postObject->checkIdentity()))) { |
||||||
150 | } else { |
||||||
151 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum={$forum_id}&topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}", 2, _MD_NEWBB_NORIGHTTOEDIT); |
||||||
152 | } |
||||||
153 | |||||||
154 | $delete_attach = Request::getArray('delete_attach', [], 'POST'); |
||||||
155 | if ($delete_attach && is_array($delete_attach)) { |
||||||
0 ignored issues
–
show
|
|||||||
156 | $postObject->deleteAttachment($delete_attach); |
||||||
157 | } |
||||||
158 | } else { |
||||||
159 | if ($topic_id) { |
||||||
160 | $topic_status = $topicObject->getVar('topic_status'); |
||||||
161 | if (!$topicHandler->getPermission($forumObject, $topic_status, 'reply')) { |
||||||
162 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum={$forum_id}&topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}", 2, _MD_NEWBB_NORIGHTTOREPLY); |
||||||
163 | } |
||||||
164 | } else { |
||||||
165 | $topic_status = 0; |
||||||
166 | if (!$topicHandler->getPermission($forumObject, $topic_status, 'post')) { |
||||||
167 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum={$forum_id}", 2, _MD_NEWBB_NORIGHTTOPOST); |
||||||
168 | } |
||||||
169 | } |
||||||
170 | |||||||
171 | $isreply = 0; |
||||||
172 | $isnew = 1; |
||||||
173 | if (!is_object($GLOBALS['xoopsUser']) |
||||||
174 | || (Request::getString('noname', '', 'POST') |
||||||
175 | && !empty($GLOBALS['xoopsModuleConfig']['allow_user_anonymous']))) { |
||||||
176 | $uid = 0; |
||||||
177 | } else { |
||||||
178 | $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
||||||
179 | } |
||||||
180 | if (!empty($pid)) { |
||||||
181 | $postObject->setVar('pid', $pid); |
||||||
182 | } |
||||||
183 | if (!empty($topic_id)) { |
||||||
184 | $postObject->setVar('topic_id', $topic_id); |
||||||
185 | $isreply = 1; |
||||||
186 | } |
||||||
187 | $postObject->setVar('poster_ip', Xmf\IPAddress::fromRequest()->asReadable()); |
||||||
188 | $postObject->setVar('uid', $uid); |
||||||
189 | $postObject->setVar('post_time', time()); |
||||||
190 | } |
||||||
191 | |||||||
192 | $approved = $topicHandler->getPermission($forumObject, $topic_status, 'noapprove'); |
||||||
193 | $postObject->setVar('approved', $approved); |
||||||
194 | |||||||
195 | $postObject->setVar('forum_id', $forumObject->getVar('forum_id')); |
||||||
196 | |||||||
197 | $subject = xoops_trim(Request::getString('subject', '', 'POST')); |
||||||
198 | $subject = ('' === $subject) ? _NOTITLE : $subject; |
||||||
199 | $poster_name = xoops_trim(Request::getString('poster_name', '', 'POST')); |
||||||
200 | $dohtml = Request::getInt('dohtml', 0, 'POST') |
||||||
201 | && $topicHandler->getPermission($forumObject, $topic_status, 'html'); |
||||||
202 | $dosmiley = Request::getInt('dosmiley', 0, 'POST'); |
||||||
203 | $doxcode = Request::getInt('doxcode', 0, 'POST') ? 1 : 0; |
||||||
204 | $dobr = Request::getInt('dobr', 0, 'POST') ? 1 : 0; |
||||||
205 | $icon = (Request::getString('icon', '', 'POST') |
||||||
206 | && is_file($GLOBALS['xoops']->path('images/subject/' . Request::getString('icon', '', 'POST'))) ? Request::getString('icon', '', 'POST') : ''); |
||||||
207 | $attachsig = Request::getBool('attachsig', false, 'POST') |
||||||
208 | && $topicHandler->getPermission($forumObject, $topic_status, 'signature'); |
||||||
209 | $view_require = Request::getString('view_require', '', 'POST'); |
||||||
210 | $post_karma = ('require_karma' === $view_require) ? Request::getInt('post_karma', 0, 'POST') : 0; |
||||||
211 | $require_reply = ('require_reply' === $view_require); |
||||||
212 | $postObject->setVar('subject', $subject); |
||||||
213 | $editwhy = xoops_trim(Request::getString('editwhy', '', 'POST')); // !empty($_POST['editwhy'])) ? xoops_trim($_POST['editwhy']) : ""; |
||||||
214 | |||||||
215 | if ($dohtml && !newbbIsAdmin($forumObject)) { |
||||||
216 | //$message=newbb_textFilter($message); |
||||||
217 | } |
||||||
218 | $postObject->setVar('post_text', $message); |
||||||
219 | $postObject->setVar('post_karma', $post_karma); |
||||||
220 | $postObject->setVar('require_reply', $require_reply); |
||||||
221 | $postObject->setVar('poster_name', $poster_name); |
||||||
222 | $postObject->setVar('dohtml', $dohtml); |
||||||
223 | $postObject->setVar('dosmiley', $dosmiley); |
||||||
224 | $postObject->setVar('doxcode', $doxcode); |
||||||
225 | $postObject->setVar('dobr', $dobr); |
||||||
226 | $postObject->setVar('icon', $icon); |
||||||
227 | $postObject->setVar('attachsig', $attachsig); |
||||||
228 | $postObject->setAttachment(); |
||||||
229 | if (!empty($post_id)) { |
||||||
230 | $postObject->setPostEdit($poster_name, $editwhy); |
||||||
231 | } // is reply |
||||||
232 | |||||||
233 | // $attachments_tmp = []; |
||||||
234 | // if (!empty($_POST["attachments_tmp"])) { |
||||||
235 | if (Request::getString('attachments_tmp', '', 'POST')) { |
||||||
236 | $attachments_tmp = unserialize(base64_decode(Request::getString('attachments_tmp', '', 'POST'), true)); |
||||||
237 | if (Request::getArray('delete_tmp', null, 'POST') && count(Request::getArray('delete_tmp', null, 'POST')) > 1) { |
||||||
238 | foreach (Request::getArray('delete_tmp', null, 'POST') as $key) { |
||||||
239 | unlink($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0])); |
||||||
240 | unset($attachments_tmp[$key]); |
||||||
241 | } |
||||||
242 | } |
||||||
243 | } |
||||||
244 | if (isset($attachments_tmp) && count($attachments_tmp)) { |
||||||
245 | foreach ($attachments_tmp as $key => $attach) { |
||||||
246 | if (rename(XOOPS_CACHE_PATH . '/' . $attachments_tmp[$key][0], $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0]))) { |
||||||
247 | $postObject->setAttachment($attach[0], $attach[1], $attach[2]); |
||||||
248 | } |
||||||
249 | } |
||||||
250 | } |
||||||
251 | $error_upload = ''; |
||||||
252 | |||||||
253 | if (isset($_FILES['userfile']['name']) && '' !== $_FILES['userfile']['name'] |
||||||
254 | && $topicHandler->getPermission($forumObject, $topic_status, 'attach')) { |
||||||
255 | // require_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/uploader.php'); |
||||||
256 | $maxfilesize = $forumObject->getVar('attach_maxkb') * 1024; |
||||||
257 | $uploaddir = XOOPS_CACHE_PATH; |
||||||
258 | |||||||
259 | $uploader = new Newbb\Uploader($uploaddir, $forumObject->getVar('attach_ext'), (int)$maxfilesize, (int)$GLOBALS['xoopsModuleConfig']['max_img_width'], (int)$GLOBALS['xoopsModuleConfig']['max_img_height']); |
||||||
260 | |||||||
261 | if ($_FILES['userfile']['error'] > 0) { |
||||||
262 | switch ($_FILES['userfile']['error']) { |
||||||
263 | case 1: |
||||||
264 | $error_message[] = _MD_NEWBB_MAXUPLOADFILEINI; |
||||||
265 | break; |
||||||
266 | case 2: |
||||||
267 | $error_message[] = sprintf(_MD_NEWBB_MAXKB, $forumObject->getVar('attach_maxkb')); |
||||||
268 | break; |
||||||
269 | default: |
||||||
270 | $error_message[] = _MD_NEWBB_UPLOAD_ERRNODEF; |
||||||
271 | break; |
||||||
272 | } |
||||||
273 | } else { |
||||||
274 | $uploader->setCheckMediaTypeByExt(); |
||||||
275 | $temp = Request::getArray('xoops_upload_file', [], 'POST'); |
||||||
276 | if ($uploader->fetchMedia($temp[0])) { |
||||||
277 | $prefix = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() . '_' : 'newbb_'; |
||||||
278 | $uploader->setPrefix($prefix); |
||||||
279 | if (!$uploader->upload()) { |
||||||
280 | $error_message[] = $error_upload = $uploader->getErrors(); |
||||||
281 | } else { |
||||||
282 | if (is_file($uploader->getSavedDestination())) { |
||||||
283 | if (rename(XOOPS_CACHE_PATH . '/' . $uploader->getSavedFileName(), $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $uploader->getSavedFileName()))) { |
||||||
284 | $postObject->setAttachment($uploader->getSavedFileName(), $uploader->getMediaName(), $uploader->getMediaType()); |
||||||
285 | } |
||||||
286 | } |
||||||
287 | } |
||||||
288 | } else { |
||||||
289 | $error_message[] = $error_upload = $uploader->getErrors(); |
||||||
290 | } |
||||||
291 | } |
||||||
292 | } |
||||||
293 | |||||||
294 | $postid = $postHandler->insert($postObject); |
||||||
295 | |||||||
296 | if (!$postid) { |
||||||
297 | require_once $GLOBALS['xoops']->path('header.php'); |
||||||
298 | xoops_error($postObject->getErrors()); |
||||||
299 | require_once $GLOBALS['xoops']->path('footer.php'); |
||||||
300 | } |
||||||
301 | newbbSetSession('LP', time()); // Recording last post time |
||||||
302 | $topicObject = $topicHandler->get($postObject->getVar('topic_id')); |
||||||
303 | $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||||||
304 | if (newbbIsAdmin($forumObject) |
||||||
305 | || ($topicHandler->getPermission($forumObject, $topic_status, 'type') |
||||||
306 | && (0 == $topic_id |
||||||
307 | || $uid == $topicObject->getVar('topic_poster')))) { |
||||||
308 | $topicObject->setVar('type_id', Request::getInt('type_id', 0, 'POST')); |
||||||
309 | } |
||||||
310 | |||||||
311 | if (!empty($GLOBALS['xoopsModuleConfig']['do_tag']) && $postObject->isTopic()) { |
||||||
312 | $topicObject->setVar('topic_tags', Request::getInt('topic_tags', 0, 'POST')); |
||||||
313 | } |
||||||
314 | $topicHandler->insert($topicObject); |
||||||
315 | |||||||
316 | // Set read mark |
||||||
317 | if (!empty($isnew)) { |
||||||
318 | require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.read.php'); |
||||||
319 | newbbSetRead('topic', $topicObject->getVar('topic_id'), $postid); |
||||||
320 | if (!$postObject->getVar('pid')) { |
||||||
321 | newbbSetRead('forum', $forumObject->getVar('forum_id'), $postid); |
||||||
322 | } |
||||||
323 | } |
||||||
324 | |||||||
325 | //$postObject->loadFilters(empty($isnew) ? 'update' : 'insert'); |
||||||
326 | |||||||
327 | // Define tags for notification message |
||||||
328 | if (!empty($isnew) && $approved && !empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
||||||
329 | $tags = []; |
||||||
330 | $tags['THREAD_NAME'] = Request::getString('subject', '', 'POST'); |
||||||
331 | $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?post_id=' . $postid; |
||||||
332 | $tags['POST_URL'] = $tags['THREAD_URL']; // . '#forumpost' . $postid; |
||||||
333 | require_once __DIR__ . '/include/notification.inc.php'; |
||||||
334 | $forum_info = newbb_notify_iteminfo('forum', $forumObject->getVar('forum_id')); |
||||||
335 | $tags['FORUM_NAME'] = $forum_info['name']; |
||||||
336 | $tags['FORUM_URL'] = $forum_info['url']; |
||||||
337 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||||||
338 | $notificationHandler = xoops_getHandler('notification'); |
||||||
339 | if (empty($isreply)) { |
||||||
340 | // Notify of new thread |
||||||
341 | $notificationHandler->triggerEvent('forum', $forumObject->getVar('forum_id'), 'new_thread', $tags); |
||||||
342 | } else { |
||||||
343 | // Notify of new post |
||||||
344 | $notificationHandler->triggerEvent('thread', $topic_id, 'new_post', $tags); |
||||||
345 | $_tags['name'] = $tags['THREAD_NAME']; |
||||||
346 | $_tags['url'] = $tags['POST_URL']; |
||||||
347 | $_tags['uid'] = $uid; |
||||||
348 | $notificationHandler->triggerEvent('thread', $topic_id, 'post', $_tags); |
||||||
349 | } |
||||||
350 | $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
||||||
351 | $notificationHandler->triggerEvent('forum', $forumObject->getVar('forum_id'), 'new_post', $tags); |
||||||
352 | $tags['POST_CONTENT'] = Request::getString('message', '', 'POST'); |
||||||
353 | $tags['POST_NAME'] = Request::getString('subject', '', 'POST'); |
||||||
354 | $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
||||||
355 | $notificationHandler->triggerEvent('forum', $forumObject->getVar('forum_id'), 'new_fullpost', $tags); |
||||||
356 | } |
||||||
357 | |||||||
358 | // If user checked notification box, subscribe them to the |
||||||
359 | // appropriate event; if unchecked, then unsubscribe |
||||||
360 | if (!empty($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
||||||
361 | $notificationHandler = xoops_getHandler('notification'); |
||||||
362 | if (!Request::getInt('notify', 0, 'POST')) { |
||||||
363 | $notificationHandler->unsubscribe('thread', $postObject->getVar('topic_id'), 'new_post'); |
||||||
0 ignored issues
–
show
The method
unsubscribe() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsNotificationHandler or XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
364 | } elseif (Request::getInt('notify', 0, 'POST') > 0) { |
||||||
365 | $notificationHandler->subscribe('thread', $postObject->getVar('topic_id'), 'new_post'); |
||||||
0 ignored issues
–
show
The method
subscribe() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsNotificationHandler or XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
366 | } |
||||||
367 | // elseif ($_POST['notify']<0) keep it as it is |
||||||
368 | } |
||||||
369 | |||||||
370 | if ($approved) { |
||||||
371 | if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) { |
||||||
372 | newbbSetSession('t' . $postObject->getVar('topic_id'), null); |
||||||
373 | } |
||||||
374 | // Update user |
||||||
375 | if ($uid > 0) { |
||||||
376 | $sql = 'SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE approved=1 AND topic_poster =' . $uid; |
||||||
377 | $ret = $GLOBALS['xoopsDB']->query($sql); |
||||||
378 | list($topics) = $GLOBALS['xoopsDB']->fetchRow($ret); |
||||||
379 | |||||||
380 | $sql = ' SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE approved=1 AND topic_digest > 0 AND topic_poster =' . $uid; |
||||||
381 | $ret = $GLOBALS['xoopsDB']->query($sql); |
||||||
382 | list($digests) = $GLOBALS['xoopsDB']->fetchRow($ret); |
||||||
383 | |||||||
384 | $sql = ' SELECT count(*), MAX(post_time)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE approved=1 AND uid =' . $uid; |
||||||
385 | $ret = $GLOBALS['xoopsDB']->query($sql); |
||||||
386 | list($posts, $lastpost) = $GLOBALS['xoopsDB']->fetchRow($ret); |
||||||
387 | |||||||
388 | $GLOBALS['xoopsDB']->queryF(' REPLACE INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . " SET uid = '{$uid}', user_topics = '{$topics}', user_posts = '{$posts}', user_digests = '{$digests}', user_lastpost = '{$lastpost}'"); |
||||||
389 | } |
||||||
390 | |||||||
391 | $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $postid; |
||||||
392 | $message = _MD_NEWBB_THANKSSUBMIT . '<br>' . $error_upload; |
||||||
393 | } else { |
||||||
394 | $redirect = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $postObject->getVar('forum_id'); |
||||||
395 | $message = _MD_NEWBB_THANKSSUBMIT . '<br>' . _MD_NEWBB_WAITFORAPPROVAL . '<br>' . $error_upload; |
||||||
396 | } |
||||||
397 | |||||||
398 | if ('add' === $op) { |
||||||
399 | redirect_header(XOOPS_URL . '/modules/newbb/polls.php?op=add&forum=' . $postObject->getVar('forum_id') . '&topic_id=' . $postObject->getVar('topic_id'), 1, _MD_NEWBB_ADDPOLL); |
||||||
400 | } else { |
||||||
401 | redirect_header($redirect, 2, $message); |
||||||
402 | } |
||||||
403 | } |
||||||
404 | |||||||
405 | $xoopsOption['template_main'] = 'newbb_edit_post.tpl'; |
||||||
406 | $GLOBALS['xoopsConfig']['module_cache'][$xoopsModule->getVar('mid')] = 0; |
||||||
407 | // irmtfan remove and move to footer.php |
||||||
408 | //$xoopsOption['xoops_module_header']= $xoops_module_header; |
||||||
409 | // irmtfan include header.php after defining $xoopsOption['template_main'] |
||||||
410 | require_once $GLOBALS['xoops']->path('header.php'); |
||||||
411 | //$xoopsTpl->assign('xoops_module_header', $xoops_module_header); |
||||||
412 | |||||||
413 | if (Request::getString('contents_upload', null, 'POST')) { |
||||||
414 | $attachments_tmp = []; |
||||||
415 | if (Request::getArray('attachments_tmp', null, 'POST')) { |
||||||
416 | $attachments_tmp = unserialize(base64_decode(Request::getArray('attachments_tmp', [], 'POST'), true)); |
||||||
0 ignored issues
–
show
Xmf\Request::getArray('a..._tmp', array(), 'POST') of type array is incompatible with the type string expected by parameter $data of base64_decode() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
417 | if (Request::getArray('delete_tmp', null, 'POST') && count(Request::getArray('delete_tmp', null, 'POST'))) { |
||||||
418 | foreach (Request::getArray('delete_tmp', '', 'POST') as $key) { |
||||||
419 | unlink($uploaddir = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0])); |
||||||
420 | unset($attachments_tmp[$key]); |
||||||
421 | } |
||||||
422 | } |
||||||
423 | } |
||||||
424 | |||||||
425 | $error_upload = ''; |
||||||
426 | if (isset($_FILES['userfile']['name']) && '' !== $_FILES['userfile']['name']) { |
||||||
427 | // require_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/uploader.php'); |
||||||
428 | $maxfilesize = $forumObject->getVar('attach_maxkb') * 1024; |
||||||
429 | $uploaddir = XOOPS_CACHE_PATH; |
||||||
430 | |||||||
431 | $uploader = new Newbb\Uploader($uploaddir, $forumObject->getVar('attach_ext'), (int)$maxfilesize, (int)$GLOBALS['xoopsModuleConfig']['max_img_width'], (int)$GLOBALS['xoopsModuleConfig']['max_img_height']); |
||||||
432 | if ($_FILES['userfile']['error'] > 0) { |
||||||
433 | switch ($_FILES['userfile']['error']) { |
||||||
434 | case 1: |
||||||
435 | $error_message[] = _MD_NEWBB_MAXUPLOADFILEINI; |
||||||
436 | break; |
||||||
437 | case 2: |
||||||
438 | $error_message[] = sprintf(_MD_NEWBB_MAXKB, $forumObject->getVar('attach_maxkb')); |
||||||
439 | break; |
||||||
440 | default: |
||||||
441 | $error_message[] = _MD_NEWBB_UPLOAD_ERRNODEF; |
||||||
442 | break; |
||||||
443 | } |
||||||
444 | } else { |
||||||
445 | $uploader->setCheckMediaTypeByExt(); |
||||||
446 | $temp = Request::getArray('xoops_upload_file', [], 'POST'); |
||||||
447 | if ($uploader->fetchMedia($temp[0])) { |
||||||
448 | $prefix = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() . '_' : 'newbb_'; |
||||||
449 | $uploader->setPrefix($prefix); |
||||||
450 | if (!$uploader->upload()) { |
||||||
451 | $error_message[] = $error_upload = $uploader->getErrors(); |
||||||
452 | } else { |
||||||
453 | if (is_file($uploader->getSavedDestination())) { |
||||||
454 | $attachments_tmp[(string)time()] = [ |
||||||
455 | $uploader->getSavedFileName(), |
||||||
456 | $uploader->getMediaName(), |
||||||
457 | $uploader->getMediaType(), |
||||||
458 | ]; |
||||||
459 | } |
||||||
460 | } |
||||||
461 | } else { |
||||||
462 | $error_message[] = $error_upload = $uploader->getErrors(); |
||||||
463 | } |
||||||
464 | } |
||||||
465 | } |
||||||
466 | } |
||||||
467 | |||||||
468 | if (Request::getString('contents_preview', Request::getString('contents_preview', '', 'POST'), 'GET')) { |
||||||
469 | if (Request::getString('attachments_tmp', '', 'POST')) { |
||||||
470 | $attachments_tmp = unserialize(base64_decode(Request::getString('attachments_tmp', '', 'POST'), true)); |
||||||
471 | } |
||||||
472 | |||||||
473 | $p_subject = $myts->htmlSpecialChars(Request::getString('subject', '', 'POST')); |
||||||
474 | $dosmiley = Request::getInt('dosmiley', 0, 'POST'); |
||||||
475 | $dohtml = Request::getInt('dohtml', 0, 'POST'); |
||||||
476 | $doxcode = Request::getInt('doxcode', 0, 'POST'); |
||||||
477 | $dobr = Request::getInt('dobr', 0, 'POST'); |
||||||
478 | $p_message = Request::getString('message', '', 'POST'); |
||||||
479 | $p_message = $myts->previewTarea($p_message, $dohtml, $dosmiley, $doxcode, 1, $dobr); |
||||||
480 | $p_date = formatTimestamp(time()); |
||||||
481 | if ($postObject->isNew()) { |
||||||
482 | if (is_object($GLOBALS['xoopsUser'])) { |
||||||
483 | $p_name = $GLOBALS['xoopsUser']->getVar('uname'); |
||||||
484 | if (!empty($GLOBALS['xoopsModuleConfig']['show_realname']) && $GLOBALS['xoopsUser']->getVar('name')) { |
||||||
485 | $p_name = $GLOBALS['xoopsUser']->getVar('name'); |
||||||
486 | } |
||||||
487 | } |
||||||
488 | } elseif ($postObject->getVar('uid')) { |
||||||
489 | $p_name = newbbGetUnameFromId($postObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']); |
||||||
490 | } |
||||||
491 | if (empty($p_name)) { |
||||||
492 | $p_name = Request::getString('poster_name', '', 'POST') ? htmlspecialchars(Request::getString('poster_name', '', 'POST'), ENT_QUOTES | ENT_HTML5) : htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5); |
||||||
493 | } |
||||||
494 | |||||||
495 | $post_preview = [ |
||||||
496 | 'subject' => $p_subject, |
||||||
497 | 'meta' => _MD_NEWBB_BY . ' ' . $p_name . ' ' . _MD_NEWBB_ON . ' ' . $p_date, |
||||||
498 | 'content' => $p_message, |
||||||
499 | ]; |
||||||
500 | $xoopsTpl->assign_by_ref('post_preview', $post_preview); |
||||||
501 | } |
||||||
502 | |||||||
503 | if (Request::getString('contents_upload', null, 'POST') || Request::getString('contents_preview', null, 'POST') |
||||||
504 | || Request::getString('contents_preview', null, 'GET') |
||||||
505 | || Request::getString('editor', '', 'POST')) { |
||||||
506 | $editor = Request::getString('editor', '', 'POST'); |
||||||
507 | $dosmiley = Request::getInt('dosmiley', 0, 'POST'); |
||||||
508 | $dohtml = Request::getInt('dohtml', 0, 'POST'); |
||||||
509 | $doxcode = Request::getInt('doxcode', 0, 'POST'); |
||||||
510 | $dobr = Request::getInt('dobr', 0, 'POST'); |
||||||
511 | $subject = Request::getString('subject', '', 'POST'); |
||||||
512 | $message = Request::getString('message', '', 'POST'); |
||||||
513 | $poster_name = Request::getString('poster_name', '', 'POST'); |
||||||
514 | $hidden = Request::getString('hidden', '', 'POST'); |
||||||
515 | $notify = Request::getInt('notify', 0, 'POST'); |
||||||
516 | $attachsig = Request::getInt('attachsig', 0, 'POST'); //!empty($_POST['attachsig']) ? 1 : 0; |
||||||
517 | $isreply = Request::getInt('isreply', 0, 'POST'); //!empty($_POST['isreply']) ? 1 : 0; |
||||||
518 | $isedit = Request::getInt('isedit', 0, 'POST'); //!empty($_POST['isedit']) ? 1 : 0; |
||||||
519 | $icon = (Request::getString('icon', '', 'POST') |
||||||
520 | && is_file($GLOBALS['xoops']->path('images/subject/' . Request::getString('icon', '', 'POST'))) ? Request::getString('icon', '', 'POST') : ''); |
||||||
521 | $view_require = Request::getString('view_require', '', 'POST'); |
||||||
522 | $post_karma = (('require_karma' === $view_require) |
||||||
523 | && !Request::getInt('post_karma', 0, 'POST')) ? Request::getInt('post_karma', 0, 'POST') : 0; |
||||||
524 | $require_reply = ('require_reply' === $view_require) ? 1 : 0; |
||||||
525 | |||||||
526 | if (!Request::getString('contents_upload', '', 'POST')) { |
||||||
527 | $contents_preview = 1; |
||||||
528 | } |
||||||
529 | $attachments = $postObject->getAttachment(); |
||||||
530 | $xoopsTpl->assign('error_message', implode('<br>', $error_message)); |
||||||
531 | |||||||
532 | require_once __DIR__ . '/include/form.post.php'; |
||||||
533 | } |
||||||
534 | // irmtfan move to footer.php |
||||||
535 | require_once __DIR__ . '/footer.php'; |
||||||
536 | require_once $GLOBALS['xoops']->path('footer.php'); |
||||||
537 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.