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