mambax7 /
newbb5
| 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 (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; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 13 | |||||||
| 14 | include_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') |
||||||
| 29 | && 'flat' !== Request::getString('viewmode', '', 'GET')) ? 'thread' : 'flat'; |
||||||
| 30 | $viewmode = $viewmode ?: (Request::getString('viewmode', '', 'POST') ?: 'flat'); |
||||||
| 31 | |||||||
| 32 | ///** @var Newbb\ForumHandler $forumHandler */ |
||||||
| 33 | //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
||||||
| 34 | ///** @var Newbb\TopicHandler $topicHandler */ |
||||||
| 35 | //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
||||||
| 36 | ///** @var Newbb\PostHandler $postHandler */ |
||||||
| 37 | //$postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
||||||
| 38 | |||||||
| 39 | if (!empty($post_id)) { |
||||||
| 40 | $topic = $topicHandler->getByPost($post_id); |
||||||
| 41 | } else { |
||||||
| 42 | $topic = $topicHandler->get($topic_id); |
||||||
| 43 | } |
||||||
| 44 | $topic_id = $topic->getVar('topic_id'); |
||||||
| 45 | if (!$topic_id) { |
||||||
| 46 | $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum=' . $forum; |
||||||
| 47 | $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 48 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||||||
|
0 ignored issues
–
show
The function
redirect_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 49 | } |
||||||
| 50 | |||||||
| 51 | $forum = $topic->getVar('forum_id'); |
||||||
| 52 | $forumObject = $forumHandler->get($forum); |
||||||
| 53 | if (!$forumHandler->getPermission($forumObject)) { |
||||||
| 54 | redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
||||||
| 55 | } |
||||||
| 56 | |||||||
| 57 | $isAdmin = newbbIsAdmin($forumObject); |
||||||
| 58 | $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||||||
| 59 | |||||||
| 60 | /** @var Post $postObject */ |
||||||
| 61 | $postObject = $postHandler->get($post_id); |
||||||
| 62 | $topic_status = $topic->getVar('topic_status'); |
||||||
| 63 | if (($postObject->checkIdentity() || $isAdmin) && $topicHandler->getPermission($topic->getVar('forum_id'), $topic_status, 'delete')) { |
||||||
|
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. Loading history...
|
|||||||
| 64 | } else { |
||||||
| 65 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED); |
||||||
| 66 | } |
||||||
| 67 | |||||||
| 68 | if (!$isAdmin && !$postObject->checkTimelimit('delete_timelimit')) { |
||||||
| 69 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL); |
||||||
| 70 | } |
||||||
| 71 | |||||||
| 72 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
||||||
| 73 | // /** @var Newbb\OnlineHandler $onlineHandler */ |
||||||
| 74 | // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
||||||
| 75 | $onlineHandler->init($forumObject); |
||||||
| 76 | } |
||||||
| 77 | |||||||
| 78 | if ($ok) { |
||||||
| 79 | $isDeleteOne = (1 === $ok); |
||||||
| 80 | if ($postObject->isTopic() && 0 == $topic->getVar('topic_replies')) { |
||||||
| 81 | $isDeleteOne = false; |
||||||
| 82 | } |
||||||
| 83 | if ($isDeleteOne && $postObject->isTopic() && $topic->getVar('topic_replies') > 0) { |
||||||
| 84 | //$postHandler->emptyTopic($postObject); |
||||||
| 85 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED); |
||||||
| 86 | } else { |
||||||
| 87 | if (Request::getString('post_text', '', 'POST')) { |
||||||
| 88 | //send a message |
||||||
| 89 | /** @var \XoopsMemberHandler $memberHandler */ |
||||||
| 90 | $memberHandler = xoops_getHandler('member'); |
||||||
|
0 ignored issues
–
show
The function
xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 91 | $senduser = $memberHandler->getUser($postObject->getVar('uid')); |
||||||
| 92 | if ($senduser->getVar('notify_method') > 0) { |
||||||
| 93 | $xoopsMailer = xoops_getMailer(); |
||||||
|
0 ignored issues
–
show
The function
xoops_getMailer was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 94 | $xoopsMailer->reset(); |
||||||
| 95 | if (1 == $senduser->getVar('notify_method')) { |
||||||
| 96 | $xoopsMailer->usePM(); |
||||||
| 97 | } else { |
||||||
| 98 | $xoopsMailer->useMail(); |
||||||
| 99 | } |
||||||
| 100 | $xoopsMailer->setHTML(true); |
||||||
| 101 | $xoopsMailer->setToUsers($senduser); |
||||||
| 102 | $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname')); |
||||||
| 103 | $xoopsMailer->setSubject(_MD_NEWBB_DELEDEDMSG_SUBJECT); |
||||||
| 104 | $forenurl = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postObject->getVar('topic_id') . '">' . $postObject->getVar('subject') . '</a>'; |
||||||
| 105 | if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
||||||
| 106 | $forenurl = seo_urls($forenurl); |
||||||
| 107 | } |
||||||
| 108 | $body = sprintf(_MD_NEWBB_DELEDEDMSG_BODY, $senduser->getVar('uname'), $forenurl, Request::getString('post_text', '', 'POST'), $GLOBALS['xoopsUser']->getVar('uname'), $GLOBALS['xoopsConfig']['sitename'], XOOPS_URL . '/'); |
||||||
| 109 | $body = $myts->nl2Br($body); |
||||||
| 110 | $xoopsMailer->setBody($body); |
||||||
| 111 | $xoopsMailer->send(); |
||||||
| 112 | } |
||||||
| 113 | } |
||||||
| 114 | $postHandler->delete($postObject, $isDeleteOne); |
||||||
| 115 | $forumHandler->synchronization($forum); |
||||||
| 116 | $topicHandler->synchronization($topic_id); |
||||||
| 117 | // /** @var Newbb\StatsHandler $statsHandler */ |
||||||
| 118 | // $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
||||||
| 119 | $statsHandler->reset(); |
||||||
| 120 | } |
||||||
| 121 | |||||||
| 122 | //$postObject->loadFilters('delete'); |
||||||
| 123 | if ($isDeleteOne) { |
||||||
| 124 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTDELETED); |
||||||
| 125 | } else { |
||||||
| 126 | redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED); |
||||||
| 127 | } |
||||||
| 128 | } else { |
||||||
| 129 | include $GLOBALS['xoops']->path('header.php'); |
||||||
| 130 | //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); |
||||||
| 131 | echo '<div class="confirmMsg">' . _MD_NEWBB_DEL_ONE . '<br> |
||||||
| 132 | <form method="post" action="' . XOOPS_URL . '/modules/newbb/delete.php">'; |
||||||
| 133 | echo _MD_NEWBB_DELEDEDMSG . '<br>'; |
||||||
| 134 | echo '<textarea name="post_text" cols="50" rows="5"></textarea><br>'; |
||||||
| 135 | echo '<input type="hidden" name="post_id" value="' . htmlspecialchars($post_id) . '" />'; |
||||||
| 136 | echo '<input type="hidden" name="order" value="' . htmlspecialchars($order) . '" />'; |
||||||
| 137 | echo '<input type="hidden" name="forum" value="' . htmlspecialchars($forum) . '" />'; |
||||||
| 138 | echo '<input type="hidden" name="topic_id" value="' . htmlspecialchars($topic_id) . '" />'; |
||||||
| 139 | echo '<input type="hidden" name="ok" value="1" />'; |
||||||
| 140 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||||||
| 141 | echo '<input type="submit" name="confirm_submit" value="' . _SUBMIT . '" title="' . _SUBMIT . '"/> |
||||||
|
0 ignored issues
–
show
|
|||||||
| 142 | <input type="button" name="confirm_back" value="' . _CANCEL . '" onclick="history.go(-1);" title="' . _CANCEL . '" /> |
||||||
|
0 ignored issues
–
show
|
|||||||
| 143 | </form> |
||||||
| 144 | </div>'; |
||||||
| 145 | if ($isAdmin) { |
||||||
| 146 | xoops_confirm([ |
||||||
|
0 ignored issues
–
show
The function
xoops_confirm was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 147 | 'post_id' => $post_id, |
||||||
| 148 | 'viewmode' => $viewmode, |
||||||
| 149 | 'order' => $order, |
||||||
| 150 | 'forum' => $forum, |
||||||
| 151 | 'topic_id' => $topic_id, |
||||||
| 152 | 'ok' => 99 |
||||||
| 153 | ], 'delete.php', _MD_NEWBB_DEL_RELATED); |
||||||
| 154 | } |
||||||
| 155 | include $GLOBALS['xoops']->path('footer.php'); |
||||||
| 156 | } |
||||||
| 157 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths