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