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 5.0x, the forum module for XOOPS project |
||
4 | * |
||
5 | * @copyright XOOPS Project (https://xoops.org) |
||
6 | * @license GNU GPL 2 or later (https://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 | require_once __DIR__ . '/header.php'; |
||
15 | |||
16 | $ok = Request::getInt('ok', 0, 'POST'); |
||
17 | |||
18 | foreach (['forum', 'topic_id', 'post_id', 'order', 'pid', 'act'] as $getint) { |
||
19 | ${$getint} = Request::getInt($getint, 0, 'POST'); |
||
20 | } |
||
21 | |||
22 | foreach (['forum', 'topic_id', 'post_id', 'order', 'pid', 'act'] as $getint) { |
||
23 | ${$getint} = !empty(${$getint}) ? ${$getint} : Request::getInt($getint, 0, 'GET'); |
||
24 | } |
||
25 | //$viewmode = (isset($_GET['viewmode']) && $_GET['viewmode'] !== 'flat') ? 'thread' : 'flat'; |
||
26 | //$viewmode = ($viewmode) ? $viewmode: (isset($_POST['viewmode'])?$_POST['viewmode'] : 'flat'); |
||
27 | |||
28 | $viewmode = (Request::getString('viewmode', '', 'GET') && 'flat' !== Request::getString('viewmode', '', 'GET')) ? 'thread' : 'flat'; |
||
29 | $viewmode = $viewmode ?: (Request::getString('viewmode', '', 'POST') ?: 'flat'); |
||
30 | |||
31 | ///** @var Newbb\ForumHandler $forumHandler */ |
||
32 | //$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); |
||
33 | ///** @var Newbb\TopicHandler $topicHandler */ |
||
34 | //$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); |
||
35 | ///** @var Newbb\PostHandler $postHandler */ |
||
36 | //$postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); |
||
37 | |||
38 | if (!empty($post_id)) { |
||
39 | $topic = $topicHandler->getByPost($post_id); |
||
40 | } else { |
||
41 | $topic = $topicHandler->get($topic_id); |
||
42 | } |
||
43 | $topic_id = $topic->getVar('topic_id'); |
||
44 | if (!$topic_id) { |
||
45 | $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum=' . $forum; |
||
46 | $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
||
47 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||
48 | } |
||
49 | |||
50 | $forum = $topic->getVar('forum_id'); |
||
51 | $forumObject = $forumHandler->get($forum); |
||
52 | if (!$forumHandler->getPermission($forumObject)) { |
||
53 | redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
||
54 | } |
||
55 | |||
56 | $isAdmin = newbbIsAdmin($forumObject); |
||
57 | $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
58 | |||
59 | /** @var Post $postObject */ |
||
60 | $postObject = $postHandler->get($post_id); |
||
61 | $topic_status = $topic->getVar('topic_status'); |
||
62 | if (($postObject->checkIdentity() || $isAdmin) && $topicHandler->getPermission($topic->getVar('forum_id'), $topic_status, 'delete')) { |
||
63 | } else { |
||
64 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED); |
||
65 | } |
||
66 | |||
67 | if (!$isAdmin && !$postObject->checkTimelimit('delete_timelimit')) { |
||
68 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL); |
||
69 | } |
||
70 | |||
71 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
||
72 | // /** @var Newbb\OnlineHandler $onlineHandler */ |
||
73 | // $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); |
||
74 | $onlineHandler->init($forumObject); |
||
75 | } |
||
76 | |||
77 | if ($ok) { |
||
78 | $isDeleteOne = (1 === $ok); |
||
79 | if ($postObject->isTopic() && 0 == $topic->getVar('topic_replies')) { |
||
80 | $isDeleteOne = false; |
||
81 | } |
||
82 | if ($isDeleteOne && $postObject->isTopic() && $topic->getVar('topic_replies') > 0) { |
||
83 | //$postHandler->emptyTopic($postObject); |
||
84 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED); |
||
85 | } else { |
||
86 | if (Request::getString('post_text', '', 'POST')) { |
||
87 | //send a message |
||
88 | /** @var \XoopsMemberHandler $memberHandler */ |
||
89 | $memberHandler = xoops_getHandler('member'); |
||
90 | $senduser = $memberHandler->getUser($postObject->getVar('uid')); |
||
91 | if ($senduser->getVar('notify_method') > 0) { |
||
92 | $xoopsMailer = xoops_getMailer(); |
||
93 | $xoopsMailer->reset(); |
||
94 | if (1 == $senduser->getVar('notify_method')) { |
||
95 | $xoopsMailer->usePM(); |
||
96 | } else { |
||
97 | $xoopsMailer->useMail(); |
||
98 | } |
||
99 | $xoopsMailer->setHTML(true); |
||
100 | $xoopsMailer->setToUsers($senduser); |
||
101 | $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname')); |
||
102 | $xoopsMailer->setSubject(_MD_NEWBB_DELEDEDMSG_SUBJECT); |
||
103 | $forenurl = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postObject->getVar('topic_id') . '">' . $postObject->getVar('subject') . '</a>'; |
||
104 | if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
||
105 | $forenurl = seo_urls($forenurl); |
||
106 | } |
||
107 | $body = sprintf(_MD_NEWBB_DELEDEDMSG_BODY, $senduser->getVar('uname'), $forenurl, Request::getString('post_text', '', 'POST'), $GLOBALS['xoopsUser']->getVar('uname'), $GLOBALS['xoopsConfig']['sitename'], XOOPS_URL . '/'); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
108 | $body = $myts->nl2Br($body); |
||
109 | $xoopsMailer->setBody($body); |
||
110 | $xoopsMailer->send(); |
||
111 | } |
||
112 | } |
||
113 | $postHandler->delete($postObject, $isDeleteOne); |
||
114 | $forumHandler->synchronization($forum); |
||
115 | $topicHandler->synchronization($topic_id); |
||
116 | // /** @var Newbb\StatsHandler $statsHandler */ |
||
117 | // $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); |
||
118 | $statsHandler->reset(); |
||
119 | } |
||
120 | |||
121 | //$postObject->loadFilters('delete'); |
||
122 | if ($isDeleteOne) { |
||
123 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTDELETED); |
||
124 | } else { |
||
125 | redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED); |
||
126 | } |
||
127 | } else { |
||
128 | require_once $GLOBALS['xoops']->path('header.php'); |
||
129 | //xoops_confirm(array('post_id' => $post_id, 'viewmode' => $viewmode, 'order' => $order, 'forum' => $forum, 'topic_id' => $topic_id, 'ok' => 1), 'delete.php', _MD_NEWBB_DEL_ONE); |
||
130 | echo '<div class="confirmMsg">' . _MD_NEWBB_DEL_ONE . '<br> |
||
131 | <form method="post" action="' . XOOPS_URL . '/modules/newbb/delete.php">'; |
||
132 | echo _MD_NEWBB_DELEDEDMSG . '<br>'; |
||
133 | echo '<textarea name="post_text" cols="50" rows="5"></textarea><br>'; |
||
134 | echo '<input type="hidden" name="post_id" value="' . htmlspecialchars($post_id, ENT_QUOTES | ENT_HTML5) . '" >'; |
||
135 | echo '<input type="hidden" name="order" value="' . htmlspecialchars($order, ENT_QUOTES | ENT_HTML5) . '" >'; |
||
136 | echo '<input type="hidden" name="forum" value="' . htmlspecialchars($forum, ENT_QUOTES | ENT_HTML5) . '" >'; |
||
137 | echo '<input type="hidden" name="topic_id" value="' . htmlspecialchars($topic_id, ENT_QUOTES | ENT_HTML5) . '" >'; |
||
138 | echo '<input type="hidden" name="ok" value="1" >'; |
||
139 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||
140 | echo '<input type="submit" name="confirm_submit" value="' . _SUBMIT . '" title="' . _SUBMIT . '"> |
||
141 | <input type="button" name="confirm_back" value="' . _CANCEL . '" onclick="history.go(-1);" title="' . _CANCEL . '" > |
||
142 | </form> |
||
143 | </div>'; |
||
144 | if ($isAdmin) { |
||
145 | xoops_confirm( |
||
146 | [ |
||
147 | 'post_id' => $post_id, |
||
148 | 'viewmode' => $viewmode, |
||
149 | 'order' => $order, |
||
150 | 'forum' => $forum, |
||
151 | 'topic_id' => $topic_id, |
||
152 | 'ok' => 99, |
||
153 | ], |
||
154 | 'delete.php', |
||
155 | _MD_NEWBB_DEL_RELATED |
||
156 | ); |
||
157 | } |
||
158 | require_once $GLOBALS['xoops']->path('footer.php'); |
||
159 | } |
||
160 |