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 | * 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 XoopsModules\Newbb; |
||||||
| 13 | |||||||
| 14 | global $xoopsModule, $myts, $xoopsUser, $forumObject; |
||||||
| 15 | |||||||
| 16 | if (!defined('XOOPS_ROOT_PATH') || !is_object($forumObject) || !is_object($GLOBALS['xoopsUser']) |
||||||
| 17 | || !is_object($xoopsModule)) { |
||||||
| 18 | return; |
||||||
| 19 | } |
||||||
| 20 | |||||||
| 21 | $forum_id = $forumObject->getVar('forum_id'); |
||||||
| 22 | $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); |
||||||
| 23 | $postObject = $postHandler->create(); |
||||||
| 24 | $postObject->setVar('poster_ip', \Xmf\IPAddress::fromRequest()->asReadable()); |
||||||
| 25 | $postObject->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); |
||||||
| 26 | $postObject->setVar('approved', 1); |
||||||
| 27 | $postObject->setVar('forum_id', $forum_id); |
||||||
| 28 | |||||||
| 29 | $subject = sprintf(_MD_NEWBB_WELCOME_SUBJECT, $GLOBALS['xoopsUser']->getVar('uname')); |
||||||
| 30 | $postObject->setVar('subject', $subject); |
||||||
| 31 | $postObject->setVar('dohtml', 1); |
||||||
| 32 | $postObject->setVar('dosmiley', 1); |
||||||
| 33 | $postObject->setVar('doxcode', 0); |
||||||
| 34 | $postObject->setVar('dobr', 1); |
||||||
| 35 | $postObject->setVar('icon', ''); |
||||||
| 36 | $postObject->setVar('attachsig', 1); |
||||||
| 37 | $postObject->setVar('post_time', time()); |
||||||
| 38 | |||||||
| 39 | $categories = []; |
||||||
| 40 | |||||||
| 41 | /** @var \XoopsModuleHandler $moduleHandler */ |
||||||
| 42 | $moduleHandler = xoops_getHandler('module'); |
||||||
| 43 | |||||||
| 44 | $mod = @$moduleHandler->getByDirname('profile', true); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 45 | if ($mod) { |
||||||
| 46 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
| 47 | $groups = [XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS]; |
||||||
| 48 | |||||||
| 49 | if (!defined('_PROFILE_MA_ALLABOUT')) { |
||||||
| 50 | $mod->loadLanguage(); |
||||||
| 51 | } |
||||||
| 52 | /** var Newbb\PermissionHandler $permHandler */ |
||||||
| 53 | $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); |
||||||
| 54 | $show_ids = $permHandler->getItemIds('profile_show', $groups, $mod->getVar('mid')); |
||||||
| 55 | $visible_ids = $permHandler->getItemIds('profile_visible', $groups, $mod->getVar('mid')); |
||||||
| 56 | unset($mod); |
||||||
| 57 | $fieldids = array_intersect($show_ids, $visible_ids); |
||||||
| 58 | |||||||
| 59 | // /** @var \ProfileProfileHandler $profileHandler */ |
||||||
| 60 | // $profileHandler = $helper->getHandler('Profile', 'profile'); |
||||||
| 61 | $profileHandler = xoops_getModuleHandler('profile', 'profile'); |
||||||
| 62 | $fields = $profileHandler->loadFields(); |
||||||
|
0 ignored issues
–
show
The method
loadFields() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 63 | // /** @var \ProfileCategoryHandler $catHandler */ |
||||||
| 64 | // $catHandler = $helper->getHandler('Category', 'profile'); |
||||||
| 65 | $catHandler = xoops_getModuleHandler('category', 'profile'); |
||||||
| 66 | $categories = $catHandler->getObjects(null, true, false); |
||||||
|
0 ignored issues
–
show
The method
getObjects() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsRankHandler or XoUserHandler. Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 67 | // /** @var \ProfileFieldHandler $fieldcatHandler */ |
||||||
| 68 | // $fieldcatHandler = $helper->getHandler('Field', 'profile'); |
||||||
| 69 | $fieldcatHandler = xoops_getModuleHandler('field', 'profile'); |
||||||
| 70 | $fieldcats = $fieldcatHandler->getObjects(null, true, false); |
||||||
| 71 | |||||||
| 72 | // Add core fields |
||||||
| 73 | $categories[0]['cat_title'] = sprintf(_MD_NEWBB_AUTO_CREATE_ABOUT, $GLOBALS['xoopsUser']->getVar('uname')); |
||||||
| 74 | $avatar = trim($GLOBALS['xoopsUser']->getVar('user_avatar')); |
||||||
| 75 | if (!empty($avatar) && 'blank.gif' !== $avatar) { |
||||||
| 76 | $categories[0]['fields'][] = [ |
||||||
| 77 | 'title' => _MD_NEWBB_AUTO_CREATE_AVATARS, |
||||||
| 78 | 'value' => "<img src='" . XOOPS_UPLOAD_URL . '/' . $GLOBALS['xoopsUser']->getVar('user_avatar') . "' alt='" . $GLOBALS['xoopsUser']->getVar('uname') . "' >", |
||||||
| 79 | ]; |
||||||
| 80 | $weights[0][] = 0; |
||||||
| 81 | } |
||||||
| 82 | if (1 == $GLOBALS['xoopsUser']->getVar('user_viewemail')) { |
||||||
| 83 | $email = $GLOBALS['xoopsUser']->getVar('email', 'E'); |
||||||
| 84 | $categories[0]['fields'][] = ['title' => _MD_NEWBB_AUTO_CREATE_EMAIL, 'value' => $email]; |
||||||
| 85 | $weights[0][] = 0; |
||||||
| 86 | } |
||||||
| 87 | |||||||
| 88 | // Add dynamic fields |
||||||
| 89 | foreach (array_keys($fields) as $i) { |
||||||
| 90 | if (in_array($fields[$i]->getVar('fieldid'), $fieldids)) { |
||||||
| 91 | $catid = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? $fieldcats[$fields[$i]->getVar('fieldid')]['catid'] : 0; |
||||||
| 92 | $value = $fields[$i]->getOutputValue($GLOBALS['xoopsUser']); |
||||||
| 93 | if (is_array($value)) { |
||||||
| 94 | $value = implode('<br>', array_values($value)); |
||||||
| 95 | } |
||||||
| 96 | |||||||
| 97 | if (empty($value)) { |
||||||
| 98 | continue; |
||||||
| 99 | } |
||||||
| 100 | $categories[$catid]['fields'][] = ['title' => $fields[$i]->getVar('field_title'), 'value' => $value]; |
||||||
| 101 | $weights[$catid][] = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? (int)$fieldcats[$fields[$i]->getVar('fieldid')]['field_weight'] : 1; |
||||||
| 102 | } |
||||||
| 103 | } |
||||||
| 104 | |||||||
| 105 | foreach (array_keys($categories) as $i) { |
||||||
| 106 | if (isset($categories[$i]['fields'])) { |
||||||
| 107 | array_multisort($weights[$i], SORT_ASC, array_keys($categories[$i]['fields']), SORT_ASC, $categories[$i]['fields']); |
||||||
| 108 | } |
||||||
| 109 | } |
||||||
| 110 | ksort($categories); |
||||||
| 111 | } |
||||||
| 112 | |||||||
| 113 | $message = sprintf(_MD_NEWBB_WELCOME_MESSAGE, $GLOBALS['xoopsUser']->getVar('uname')) . "\n\n"; |
||||||
| 114 | //$message .= _PROFILE . ": <a href='" . XOOPS_URL . '/userinfo.php?uid=' . $GLOBALS['xoopsUser']->getVar('uid') . "'><strong>" . $GLOBALS['xoopsUser']->getVar('uname') . '</strong></a> '; |
||||||
| 115 | //$message .= " | <a target='_blank' href='".XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $GLOBALS['xoopsUser']->getVar('uid') . "'>" . _MD_NEWBB_PM . "</a>\n"; |
||||||
| 116 | $message .= sprintf($GLOBALS['xoopsModuleConfig']['welcome_forum_message']); |
||||||
| 117 | //foreach ($categories as $category) { |
||||||
| 118 | // if (isset($category['fields'])) { |
||||||
| 119 | // $message .= "\n\n" . $category['cat_title'] . ":\n\n"; |
||||||
| 120 | // foreach ($category['fields'] as $field) { |
||||||
| 121 | // if (empty($field['value'])) { |
||||||
| 122 | // continue; |
||||||
| 123 | // } |
||||||
| 124 | // $message .= $field['title'] . ': ' . $field['value'] . "\n"; |
||||||
| 125 | // } |
||||||
| 126 | // } |
||||||
| 127 | //} |
||||||
| 128 | $postObject->setVar('post_text', $message); |
||||||
| 129 | $post_id = $postHandler->insert($postObject); |
||||||
| 130 | |||||||
| 131 | if (!empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
||||||
| 132 | $tags = []; |
||||||
| 133 | $tags['THREAD_NAME'] = $subject; |
||||||
| 134 | $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $post_id . '&topic_id=' . $postObject->getVar('topic_id') . '&forum=' . $forum_id; |
||||||
| 135 | $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post_id; |
||||||
| 136 | require_once __DIR__ . '/notification.inc.php'; |
||||||
| 137 | $forum_info = newbb_notify_iteminfo('forum', $forum_id); |
||||||
| 138 | $tags['FORUM_NAME'] = $forum_info['name']; |
||||||
| 139 | $tags['FORUM_URL'] = $forum_info['url']; |
||||||
| 140 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||||||
| 141 | $notificationHandler = xoops_getHandler('notification'); |
||||||
| 142 | $notificationHandler->triggerEvent('forum', $forum_id, 'new_thread', $tags); |
||||||
| 143 | $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
||||||
| 144 | $notificationHandler->triggerEvent('forum', $forum_id, 'new_post', $tags); |
||||||
| 145 | $tags['POST_CONTENT'] = $message; |
||||||
| 146 | $tags['POST_NAME'] = $subject; |
||||||
| 147 | $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
||||||
| 148 | } |
||||||
| 149 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.