mambax7 /
newbb5
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 | namespace XoopsModules\Newbb; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * NewBB 5.0x, the forum module for XOOPS project |
||
| 7 | * |
||
| 8 | * @copyright XOOPS Project (https://xoops.org) |
||
| 9 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 10 | * @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
||
| 11 | * @since 4.00 |
||
| 12 | * @package module::newbb |
||
| 13 | */ |
||
| 14 | |||
| 15 | use XoopsModules\Newbb; |
||
| 16 | use XoopsModules\Xoopspoll; |
||
|
0 ignored issues
–
show
|
|||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Class Topic |
||
| 24 | */ |
||
| 25 | class Topic extends \XoopsObject |
||
| 26 | { |
||
| 27 | public function __construct() |
||
| 28 | { |
||
| 29 | parent::__construct(); |
||
| 30 | $this->initVar('topic_id', \XOBJ_DTYPE_INT); |
||
| 31 | $this->initVar('topic_title', \XOBJ_DTYPE_TXTBOX); |
||
| 32 | $this->initVar('topic_poster', \XOBJ_DTYPE_INT); |
||
| 33 | $this->initVar('topic_time', \XOBJ_DTYPE_INT); |
||
| 34 | $this->initVar('topic_views', \XOBJ_DTYPE_INT); |
||
| 35 | $this->initVar('topic_replies', \XOBJ_DTYPE_INT); |
||
| 36 | $this->initVar('topic_last_post_id', \XOBJ_DTYPE_INT); |
||
| 37 | $this->initVar('forum_id', \XOBJ_DTYPE_INT); |
||
| 38 | $this->initVar('topic_status', \XOBJ_DTYPE_INT); |
||
| 39 | $this->initVar('type_id', \XOBJ_DTYPE_INT); |
||
| 40 | $this->initVar('topic_sticky', \XOBJ_DTYPE_INT); |
||
| 41 | $this->initVar('topic_digest', \XOBJ_DTYPE_INT); |
||
| 42 | $this->initVar('digest_time', \XOBJ_DTYPE_INT); |
||
| 43 | $this->initVar('approved', \XOBJ_DTYPE_INT); |
||
| 44 | $this->initVar('poster_name', \XOBJ_DTYPE_TXTBOX); |
||
| 45 | $this->initVar('rating', \XOBJ_DTYPE_OTHER); |
||
| 46 | $this->initVar('votes', \XOBJ_DTYPE_INT); |
||
| 47 | $this->initVar('topic_haspoll', \XOBJ_DTYPE_INT); |
||
| 48 | $this->initVar('poll_id', \XOBJ_DTYPE_INT); |
||
| 49 | $this->initVar('topic_tags', \XOBJ_DTYPE_SOURCE); |
||
| 50 | } |
||
| 51 | |||
| 52 | // irmtfan add LAST_INSERT_ID to enhance the mysql performances |
||
| 53 | public function incrementCounter() |
||
| 54 | { |
||
| 55 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' SET topic_views = LAST_INSERT_ID(topic_views + 1) WHERE topic_id =' . $this->getVar('topic_id'); |
||
| 56 | $GLOBALS['xoopsDB']->queryF($sql); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Create full title of the topic |
||
| 61 | * |
||
| 62 | * the title is composed of [type_name] if type_id is greater than 0 plus topic_title |
||
| 63 | */ |
||
| 64 | public function getFullTitle() |
||
| 65 | { |
||
| 66 | $topic_title = $this->getVar('topic_title'); |
||
| 67 | if (!$this->getVar('type_id')) { |
||
| 68 | return $topic_title; |
||
| 69 | } |
||
| 70 | $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); |
||
| 71 | if (!$typeObject = $typeHandler->get($this->getVar('type_id'))) { |
||
| 72 | return $topic_title; |
||
| 73 | } |
||
| 74 | |||
| 75 | require_once \dirname(__DIR__) . '/include/functions.topic.php'; |
||
| 76 | |||
| 77 | return \getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color')); |
||
| 78 | } |
||
| 79 | |||
| 80 | // START irmtfan loadOldPoll function |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Load functions needed for old xoopspoll (older than version 1.4 by zyspec) and umfrage modules |
||
| 84 | * |
||
| 85 | * @access public |
||
| 86 | * @param string $pollModule dirname of the poll module |
||
| 87 | * @return string|false $classPoll = the name of the old poll class eg: "XoopsPoll" | "Umfrage" |
||
| 88 | */ |
||
| 89 | public function loadOldPoll($pollModule = null) |
||
| 90 | { |
||
| 91 | static $classPoll = false; |
||
| 92 | if ($classPoll && null === $pollModule) { |
||
| 93 | return $classPoll; |
||
| 94 | } |
||
| 95 | $newbbConfig = \newbbLoadConfig(); |
||
| 96 | if (null !== $pollModule) { |
||
| 97 | $newbbConfig['poll_module'] = $pollModule; |
||
| 98 | } |
||
| 99 | // $relPath = $GLOBALS['xoops']->path('modules/' . $newbbConfig['poll_module'] . '/class/' . $newbbConfig['poll_module']); |
||
| 100 | // require_once $relPath . '.php'; |
||
| 101 | // require_once $relPath . 'option.php'; |
||
| 102 | // require_once $relPath . 'log.php'; |
||
| 103 | // require_once $relPath . 'renderer.php'; |
||
| 104 | $classes = \get_declared_classes(); |
||
| 105 | foreach (\array_reverse($classes) as $class) { |
||
| 106 | if (mb_strtolower($class) == $newbbConfig['poll_module']) { |
||
| 107 | $classPoll = $class; |
||
| 108 | |||
| 109 | return $classPoll; |
||
| 110 | } |
||
| 111 | } |
||
| 112 | |||
| 113 | return false; |
||
| 114 | } |
||
| 115 | |||
| 116 | // END irmtfan loadOldPoll function |
||
| 117 | // START irmtfan add deletePoll function |
||
| 118 | |||
| 119 | /** |
||
| 120 | * delete a poll in database |
||
| 121 | * |
||
| 122 | * @access public |
||
| 123 | * @param int $poll_id |
||
| 124 | * @return bool |
||
| 125 | */ |
||
| 126 | public function deletePoll($poll_id) |
||
| 127 | { |
||
| 128 | if (empty($poll_id)) { |
||
| 129 | return false; |
||
| 130 | } |
||
| 131 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 132 | $moduleHandler = \xoops_getHandler('module'); |
||
| 133 | $newbbConfig = \newbbLoadConfig(); |
||
| 134 | $pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']); |
||
| 135 | if (!\is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { |
||
| 136 | return false; |
||
| 137 | } |
||
| 138 | // new xoopspoll module |
||
| 139 | if ($pollModuleHandler->getVar('version') >= 140) { |
||
| 140 | /** @var \XoopsModules\Xoopspoll\PollHandler $pollHandler */ |
||
| 141 | $pollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
||
|
0 ignored issues
–
show
The type
XoopsModules\Xoopspoll\Helper was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 142 | if (false !== $pollHandler->deleteAll(new \Criteria('poll_id', $poll_id, '='))) { |
||
| 143 | /** @var \XoopsModules\XoopsPoll\OptionHandler $optionHandler */ |
||
| 144 | $optionHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Option'); |
||
| 145 | $optionHandler->deleteAll(new \Criteria('poll_id', $poll_id, '=')); |
||
| 146 | /** @var \XoopsModules\XoopsPoll\LogHandler $logHandler */ |
||
| 147 | $logHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Log'); |
||
| 148 | $logHandler->deleteAll(new \Criteria('poll_id', $poll_id, '=')); |
||
| 149 | \xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); |
||
| 150 | } |
||
| 151 | // old Xoopspoll or Umfrage or any clone from them |
||
| 152 | } else { |
||
| 153 | $classPoll = $this->loadOldPoll(); |
||
| 154 | /** @var \XoopsPoll $poll */ |
||
| 155 | $poll = new $classPoll($poll_id); |
||
| 156 | if (false !== $poll->delete()) { |
||
| 157 | $classOption = $classPoll . 'Option'; |
||
| 158 | $classOption::deleteByPollId($poll->getVar('poll_id')); |
||
| 159 | $classLog = $classPoll . 'Log'; |
||
| 160 | $classLog::deleteByPollId($poll->getVar('poll_id')); |
||
| 161 | \xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id')); |
||
| 162 | } |
||
| 163 | } // end poll_module new or old |
||
| 164 | |||
| 165 | return true; |
||
| 166 | } |
||
| 167 | |||
| 168 | // END irmtfan add deletePoll function |
||
| 169 | |||
| 170 | // START irmtfan add getPoll function |
||
| 171 | |||
| 172 | /** |
||
| 173 | * get a poll object from a poll module. |
||
| 174 | * note: can be used to find if a poll exist in a module |
||
| 175 | * @access public |
||
| 176 | * @param int $poll_id |
||
| 177 | * @param string $pollModule dirname of the poll module |
||
| 178 | * @return bool|\XoopsObject poll |
||
| 179 | */ |
||
| 180 | public function getPoll($poll_id, $pollModule = null) |
||
| 181 | { |
||
| 182 | if (empty($poll_id)) { |
||
| 183 | return false; |
||
| 184 | } |
||
| 185 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 186 | $moduleHandler = \xoops_getHandler('module'); |
||
| 187 | $newbbConfig = \newbbLoadConfig(); |
||
| 188 | if (null !== $pollModule) { |
||
| 189 | $newbbConfig['poll_module'] = $pollModule; |
||
| 190 | } |
||
| 191 | |||
| 192 | $pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']); |
||
| 193 | if (!\is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { |
||
| 194 | return false; |
||
| 195 | } |
||
| 196 | // new xoopspoll module |
||
| 197 | if ($pollModuleHandler->getVar('version') >= 140) { |
||
| 198 | $pollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
||
| 199 | $pollObject = $pollHandler->get($poll_id); |
||
| 200 | // old xoopspoll or umfrage or any clone from them |
||
| 201 | } else { |
||
| 202 | $classPoll = $this->loadOldPoll($newbbConfig['poll_module']); |
||
| 203 | $pollObject = new $classPoll($poll_id); |
||
| 204 | } // end poll_module new or old |
||
| 205 | |||
| 206 | return $pollObject; |
||
| 207 | } |
||
| 208 | |||
| 209 | // END irmtfan add getPoll function |
||
| 210 | } |
||
| 211 |
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