XoopsModules25x /
suico
| 1 | <?php declare(strict_types=1); |
||||||
| 2 | |||||||
| 3 | /* |
||||||
| 4 | You may not change or alter any portion of this comment or credits |
||||||
| 5 | of supporting developers from this source code or any supporting source code |
||||||
| 6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 7 | |||||||
| 8 | This program is distributed in the hope that it will be useful, |
||||||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 11 | */ |
||||||
| 12 | |||||||
| 13 | /** |
||||||
| 14 | * @copyright XOOPS Project https://xoops.org/ |
||||||
| 15 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||||||
| 16 | * @author Marcello Brandão aka Suico |
||||||
| 17 | * @author XOOPS Development Team |
||||||
| 18 | * @since |
||||||
| 19 | */ |
||||||
| 20 | |||||||
| 21 | use Xmf\Request; |
||||||
| 22 | |||||||
| 23 | require __DIR__ . '/header.php'; |
||||||
| 24 | |||||||
| 25 | //require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||||||
| 26 | //if (!@ require_once XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php') { |
||||||
| 27 | // require_once XOOPS_ROOT_PATH . '/language/english/user.php'; |
||||||
| 28 | //} |
||||||
| 29 | |||||||
| 30 | require_once dirname(__DIR__, 2) . '/class/pagenav.php'; |
||||||
| 31 | |||||||
| 32 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||||
| 33 | |||||||
| 34 | if (!is_object($xoopsUser)) { |
||||||
| 35 | redirect_header('index.php', 3, _US_NOEDITRIGHT); |
||||||
| 36 | } |
||||||
| 37 | |||||||
| 38 | // initialize $op variable |
||||||
| 39 | //$op = 'editprofile'; |
||||||
| 40 | $op = Request::getCmd('op', editprofile); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 41 | |||||||
| 42 | //$op = isset($_GET['op']) ? trim(htmlspecialchars($_GET['op'], ENT_QUOTES | ENT_HTML5) |
||||||
| 43 | //) : (isset($_POST['op']) ? trim(htmlspecialchars($_POST['op'], ENT_QUOTES | ENT_HTML5) |
||||||
| 44 | //) : 'editprofile'); |
||||||
| 45 | |||||||
| 46 | $configHandler = xoops_getHandler('config'); |
||||||
| 47 | //Fix for XOOPS 2.2 and SX |
||||||
| 48 | if (!defined('XOOPS_CONF_USER')) { |
||||||
| 49 | $moduleHandler = xoops_getHandler('module'); |
||||||
| 50 | $mod_yogurt = $moduleHandler->getByDirname('profile'); |
||||||
|
0 ignored issues
–
show
The method
getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 51 | if (1 === $mod_yogurt->getVar('isactive')) { |
||||||
| 52 | define('XOOPS_CONF_USER', 0); |
||||||
| 53 | $xoopsConfigUser = $configHandler->getConfigsByCat(0, $mod_yogurt->getVar('mid')); |
||||||
|
0 ignored issues
–
show
The method
getConfigsByCat() 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...
|
|||||||
| 54 | unset($moduleHandler); |
||||||
| 55 | unset($mod_yogurt); |
||||||
| 56 | } elseif (defined('SXVERSION')) { |
||||||
| 57 | define('XOOPS_CONF_USER', 1); |
||||||
| 58 | $xoopsConfigUser = $configHandler->getConfigsByCat(0, XOOPS_CONF_USER); |
||||||
| 59 | unset($moduleHandler); |
||||||
| 60 | unset($mod_yogurt); |
||||||
| 61 | } else { |
||||||
| 62 | redirect_header('index.php', 3, _TAKINGBACK); |
||||||
| 63 | exit(); |
||||||
| 64 | } |
||||||
| 65 | } else { |
||||||
| 66 | $xoopsConfigUser = $configHandler->getConfigsByCat(XOOPS_CONF_USER); |
||||||
| 67 | } |
||||||
| 68 | $myts = MyTextSanitizer::getInstance(); |
||||||
| 69 | |||||||
| 70 | if ('saveuser' === $op) { |
||||||
| 71 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
| 72 | redirect_header( |
||||||
| 73 | 'index.php', |
||||||
| 74 | 3, |
||||||
| 75 | _US_NOEDITRIGHT . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()) |
||||||
| 76 | ); |
||||||
| 77 | } |
||||||
| 78 | $uid = 0; |
||||||
| 79 | if (!empty($_POST['uid'])) { |
||||||
| 80 | $uid = Request::getInt('uid', 0, 'POST'); |
||||||
| 81 | } |
||||||
| 82 | if (empty($uid) || $xoopsUser->getVar('uid') !== $uid) { |
||||||
| 83 | redirect_header('index.php', 3, _US_NOEDITRIGHT); |
||||||
| 84 | } |
||||||
| 85 | $errors = []; |
||||||
| 86 | if (1 === $xoopsConfigUser['allow_chgmail']) { |
||||||
| 87 | $email = ''; |
||||||
| 88 | if (!empty($_POST['email'])) { |
||||||
| 89 | $email = Request::getEmail('email', '', 'POST'); |
||||||
| 90 | } |
||||||
| 91 | if ('' === $email || !checkEmail($email)) { |
||||||
| 92 | $errors[] = _US_INVALIDMAIL; |
||||||
| 93 | } |
||||||
| 94 | } |
||||||
| 95 | $password = ''; |
||||||
| 96 | if (!empty($_POST['password'])) { |
||||||
| 97 | $password = Request::getString('password', '', 'POST'); |
||||||
| 98 | } |
||||||
| 99 | if ('' !== $password) { |
||||||
| 100 | if (mb_strlen($password) < $xoopsConfigUser['minpass']) { |
||||||
| 101 | $errors[] = sprintf(_US_PWDTOOSHORT, $xoopsConfigUser['minpass']); |
||||||
| 102 | } |
||||||
| 103 | $vpass = ''; |
||||||
| 104 | if (!empty($_POST['vpass'])) { |
||||||
| 105 | $vpass = Request::getString('vpass', '', 'POST'); |
||||||
| 106 | } |
||||||
| 107 | if ($password !== $vpass) { |
||||||
| 108 | $errors[] = _US_PASSNOTSAME; |
||||||
| 109 | } |
||||||
| 110 | } |
||||||
| 111 | if (count($errors) > 0) { |
||||||
| 112 | require XOOPS_ROOT_PATH . '/header.php'; |
||||||
| 113 | echo '<div>'; |
||||||
| 114 | foreach ($errors as $er) { |
||||||
| 115 | echo '<span style="color: #ff0000; font-weight: bold;">' . $er . '</span><br>'; |
||||||
| 116 | } |
||||||
| 117 | echo '</div><br>'; |
||||||
| 118 | $op = 'editprofile'; |
||||||
| 119 | } else { |
||||||
| 120 | /** @var \XoopsMemberHandler $memberHandler */ |
||||||
| 121 | $memberHandler = xoops_getHandler('member'); |
||||||
| 122 | $edituser = $memberHandler->getUser($uid); |
||||||
| 123 | $edituser->setVar('name', Request::getString('name', '', 'POST')); |
||||||
| 124 | if (1 === $xoopsConfigUser['allow_chgmail']) { |
||||||
| 125 | $edituser->setVar('email', $email, true); |
||||||
| 126 | } |
||||||
| 127 | $edituser->setVar('url', formatURL(Request::getUrl('url', '', 'POST'))); |
||||||
| 128 | $edituser->setVar('user_from', Request::getString('user_from', '', 'POST')); |
||||||
| 129 | $edituser->setVar('user_sig', xoops_substr(Request::getString('user_sig', '', 'POST'), 0, 255)); |
||||||
| 130 | $userViewEmail = !empty(Request::getString('user_viewemail', '', 'POST')) ? 1 : 0; |
||||||
| 131 | $edituser->setVar('user_viewemail', $userViewEmail); |
||||||
| 132 | $edituser->setVar('user_viewoid', $user_viewoid); |
||||||
| 133 | if ('' !== $password) { |
||||||
| 134 | $edituser->setVar('pass', md5($password), true); |
||||||
| 135 | } |
||||||
| 136 | $attachsig = !empty($_POST['attachsig']) ? 1 : 0; |
||||||
| 137 | $edituser->setVar('attachsig', $attachsig); |
||||||
| 138 | $edituser->setVar('timezone_offset', $_POST['timezone_offset']); |
||||||
| 139 | $edituser->setVar('uorder', $_POST['uorder']); |
||||||
| 140 | $edituser->setVar('umode', $_POST['umode']); |
||||||
| 141 | $edituser->setVar('notify_method', Request::getString('notify_method', '', 'POST')); |
||||||
| 142 | $edituser->setVar('notify_mode', Request::getString('notify_mode', '', 'POST')); |
||||||
| 143 | $edituser->setVar('bio', xoops_substr(Request::getString('bio', '', 'POST'), 0, 255)); |
||||||
| 144 | $edituser->setVar('user_occ', $_POST['user_occ']); |
||||||
| 145 | $edituser->setVar('user_intrest', Request::getString('user_intrest', '', 'POST')); |
||||||
| 146 | $edituser->setVar('user_mailok', $_POST['user_mailok']); |
||||||
| 147 | if (!empty($_POST['usecookie'])) { |
||||||
| 148 | setcookie($xoopsConfig['usercookie'], $xoopsUser->getVar('uname'), time() + 31536000); |
||||||
| 149 | } else { |
||||||
| 150 | setcookie($xoopsConfig['usercookie']); |
||||||
| 151 | } |
||||||
| 152 | if (!$memberHandler->insertUser($edituser)) { |
||||||
| 153 | require XOOPS_ROOT_PATH . '/header.php'; |
||||||
| 154 | echo $edituser->getHtmlErrors(); |
||||||
| 155 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||||
| 156 | } else { |
||||||
| 157 | redirect_header('index.php?uid=' . $uid, 1, _US_PROFUPDATED); |
||||||
| 158 | } |
||||||
| 159 | exit(); |
||||||
| 160 | } |
||||||
| 161 | } |
||||||
| 162 | |||||||
| 163 | if ('editprofile' === $op) { |
||||||
| 164 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||||||
| 165 | require_once XOOPS_ROOT_PATH . '/include/comment_constants.php'; |
||||||
| 166 | $uid = (int)$xoopsUser->getVar('uid'); |
||||||
| 167 | echo '<a href="index.php?uid=' . $uid . '">' . _US_PROFILE . '</a> <span style="font-weight:bold;">»»</span> ' . _US_EDITPROFILE . '<br><br>'; |
||||||
| 168 | $form = new XoopsThemeForm(_US_EDITPROFILE, 'userinfo', 'edituser.php', 'post', true); |
||||||
| 169 | $uname_label = new XoopsFormLabel(_US_NICKNAME, $xoopsUser->getVar('uname')); |
||||||
| 170 | $form->addElement($uname_label); |
||||||
| 171 | $name_text = new XoopsFormText(_US_REALNAME, 'name', 30, 60, $xoopsUser->getVar('name', 'E')); |
||||||
| 172 | $form->addElement($name_text); |
||||||
| 173 | $email_tray = new XoopsFormElementTray(_US_EMAIL, '<br>'); |
||||||
| 174 | if (1 === $xoopsConfigUser['allow_chgmail']) { |
||||||
| 175 | $email_text = new XoopsFormText('', 'email', 30, 60, $xoopsUser->getVar('email')); |
||||||
| 176 | } else { |
||||||
| 177 | $email_text = new XoopsFormLabel('', $xoopsUser->getVar('email')); |
||||||
| 178 | } |
||||||
| 179 | $email_tray->addElement($email_text); |
||||||
| 180 | $email_cbox_value = $xoopsUser->user_viewemail() ? 1 : 0; |
||||||
| 181 | $email_cbox = new XoopsFormCheckBox('', 'user_viewemail', $email_cbox_value); |
||||||
| 182 | $email_cbox->addOption(1, _US_ALLOWVIEWEMAIL); |
||||||
| 183 | $email_tray->addElement($email_cbox); |
||||||
| 184 | $form->addElement($email_tray); |
||||||
| 185 | $url_text = new XoopsFormText(_US_WEBSITE, 'url', 30, 100, $xoopsUser->getVar('url', 'E')); |
||||||
| 186 | $form->addElement($url_text); |
||||||
| 187 | |||||||
| 188 | $timezone_select = new XoopsFormSelectTimezone( |
||||||
| 189 | _US_TIMEZONE, 'timezone_offset', $xoopsUser->getVar( |
||||||
| 190 | 'timezone_offset' |
||||||
| 191 | ) |
||||||
| 192 | ); |
||||||
| 193 | $location_text = new XoopsFormText(_US_LOCATION, 'user_from', 30, 100, $xoopsUser->getVar('user_from', 'E')); |
||||||
| 194 | $occupation_text = new XoopsFormText(_US_OCCUPATION, 'user_occ', 30, 100, $xoopsUser->getVar('user_occ', 'E')); |
||||||
| 195 | $interest_text = new XoopsFormText( |
||||||
| 196 | _US_INTEREST, 'user_intrest', 30, 150, $xoopsUser->getVar( |
||||||
| 197 | 'user_intrest', |
||||||
| 198 | 'E' |
||||||
| 199 | ) |
||||||
| 200 | ); |
||||||
| 201 | $sig_tray = new XoopsFormElementTray(_US_SIGNATURE, '<br>'); |
||||||
| 202 | require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php'; |
||||||
| 203 | $sig_tarea = new XoopsFormDhtmlTextArea('', 'user_sig', $xoopsUser->getVar('user_sig', 'E')); |
||||||
| 204 | $sig_tray->addElement($sig_tarea); |
||||||
| 205 | $sig_cbox_value = $xoopsUser->getVar('attachsig') ? 1 : 0; |
||||||
| 206 | $sig_cbox = new XoopsFormCheckBox('', 'attachsig', $sig_cbox_value); |
||||||
| 207 | $sig_cbox->addOption(1, _US_SHOWSIG); |
||||||
| 208 | $sig_tray->addElement($sig_cbox); |
||||||
| 209 | $umode_select = new XoopsFormSelect(_US_CDISPLAYMODE, 'umode', $xoopsUser->getVar('umode')); |
||||||
| 210 | $umode_select->addOptionArray( |
||||||
| 211 | [ |
||||||
| 212 | 'nest' => _NESTED, |
||||||
| 213 | 'flat' => _FLAT, |
||||||
| 214 | 'thread' => _THREADED, |
||||||
| 215 | ] |
||||||
| 216 | ); |
||||||
| 217 | $uorder_select = new XoopsFormSelect(_US_CSORTORDER, 'uorder', $xoopsUser->getVar('uorder')); |
||||||
| 218 | $uorder_select->addOptionArray( |
||||||
| 219 | [ |
||||||
| 220 | XOOPS_COMMENT_OLD1ST => _OLDESTFIRST, |
||||||
| 221 | XOOPS_COMMENT_NEW1ST => _NEWESTFIRST, |
||||||
| 222 | ] |
||||||
| 223 | ); |
||||||
| 224 | // RMV-NOTIFY |
||||||
| 225 | // TODO: add this to admin user-edit functions... |
||||||
| 226 | require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php'; |
||||||
| 227 | require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||||||
| 228 | $notify_method_select = new XoopsFormSelect( |
||||||
| 229 | _NOT_NOTIFYMETHOD, 'notify_method', $xoopsUser->getVar( |
||||||
| 230 | 'notify_method' |
||||||
| 231 | ) |
||||||
| 232 | ); |
||||||
| 233 | $notify_method_select->addOptionArray( |
||||||
| 234 | [ |
||||||
| 235 | XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, |
||||||
| 236 | XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, |
||||||
| 237 | XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL, |
||||||
| 238 | ] |
||||||
| 239 | ); |
||||||
| 240 | $notify_mode_select = new XoopsFormSelect(_NOT_NOTIFYMODE, 'notify_mode', $xoopsUser->getVar('notify_mode')); |
||||||
| 241 | $notify_mode_select->addOptionArray( |
||||||
| 242 | [ |
||||||
| 243 | XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, |
||||||
| 244 | XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, |
||||||
| 245 | XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN, |
||||||
| 246 | ] |
||||||
| 247 | ); |
||||||
| 248 | $bio_tarea = new XoopsFormTextArea(_US_EXTRAINFO, 'bio', $xoopsUser->getVar('bio', 'E')); |
||||||
| 249 | // $cookie_radio_value = empty($_COOKIE[$xoopsConfig['usercookie']]) ? 0 : 1; |
||||||
| 250 | // $cookie_radio = new \XoopsFormRadioYN(_US_USECOOKIE, 'usecookie', $cookie_radio_value, _YES, _NO); |
||||||
| 251 | $pwd_text = new XoopsFormPassword( |
||||||
| 252 | '', 'password', 10, 255 |
||||||
| 253 | ); |
||||||
| 254 | $pwd_text2 = new XoopsFormPassword('', 'vpass', 10, 255); |
||||||
| 255 | $pwd_tray = new XoopsFormElementTray(_US_PASSWORD . '<br>' . _US_TYPEPASSTWICE); |
||||||
| 256 | $pwd_tray->addElement($pwd_text); |
||||||
| 257 | $pwd_tray->addElement($pwd_text2); |
||||||
| 258 | $mailok_radio = new XoopsFormRadioYN(_US_MAILOK, 'user_mailok', $xoopsUser->getVar('user_mailok')); |
||||||
| 259 | $uid_hidden = new XoopsFormHidden('uid', $uid); |
||||||
| 260 | $op_hidden = new XoopsFormHidden('op', 'saveuser'); |
||||||
| 261 | $submit_button = new XoopsFormButton('', 'submit', _US_SAVECHANGES, 'submit'); |
||||||
| 262 | |||||||
| 263 | $form->addElement($timezone_select); |
||||||
| 264 | $form->addElement($location_text); |
||||||
| 265 | $form->addElement($occupation_text); |
||||||
| 266 | $form->addElement($interest_text); |
||||||
| 267 | $form->addElement($sig_tray); |
||||||
| 268 | $form->addElement($umode_select); |
||||||
| 269 | $form->addElement($uorder_select); |
||||||
| 270 | $form->addElement($notify_method_select); |
||||||
| 271 | $form->addElement($notify_mode_select); |
||||||
| 272 | $form->addElement($bio_tarea); |
||||||
| 273 | $form->addElement($pwd_tray); |
||||||
| 274 | // $form->addElement($cookie_radio); |
||||||
| 275 | $form->addElement($mailok_radio); |
||||||
| 276 | $form->addElement($uid_hidden); |
||||||
| 277 | $form->addElement($op_hidden); |
||||||
| 278 | // $form->addElement($token_hidden); |
||||||
| 279 | $form->addElement($submit_button); |
||||||
| 280 | if (1 === $xoopsConfigUser['allow_chgmail']) { |
||||||
| 281 | $form->setRequired($email_text); |
||||||
| 282 | } |
||||||
| 283 | $form->display(); |
||||||
| 284 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||||
| 285 | } |
||||||
| 286 | |||||||
| 287 | if ('avatarform' === $op) { |
||||||
| 288 | require XOOPS_ROOT_PATH . '/header.php'; |
||||||
| 289 | $uid = (int)$xoopsUser->getVar('uid'); |
||||||
| 290 | echo '<a href="index.php?uid=' . $uid . '">' . _US_PROFILE . '</a> <span style="font-weight:bold;">»»</span> ' . _US_UPLOADMYAVATAR . '<br><br>'; |
||||||
| 291 | $oldavatar = $xoopsUser->getVar('user_avatar'); |
||||||
| 292 | if (!empty($oldavatar) && 'avatars/blank.gif' !== $oldavatar) { |
||||||
| 293 | echo '<div style="text-align:center;"><h4 style="color:#ff0000; font-weight:bold;">' . _US_OLD_DELETED . '</h4>'; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 294 | echo '<img src="' . XOOPS_UPLOAD_URL . '/' . $oldavatar . '" alt=""></div>'; |
||||||
| 295 | } |
||||||
| 296 | if (1 === $xoopsConfigUser['avatar_allow_upload'] |
||||||
| 297 | && $xoopsUser->getVar( |
||||||
| 298 | 'posts' |
||||||
| 299 | ) >= $xoopsConfigUser['avatar_minposts']) { |
||||||
| 300 | require_once __DIR__ . '/class/xoopsformloader.php'; |
||||||
| 301 | $form = new XoopsThemeForm(_US_UPLOADMYAVATAR, 'uploadavatar', 'edituser.php', 'post', true); |
||||||
| 302 | $form->setExtra('enctype="multipart/form-data"'); |
||||||
| 303 | $form->addElement( |
||||||
| 304 | new XoopsFormLabel( |
||||||
| 305 | _US_MAXPIXEL, $xoopsConfigUser['avatar_width'] . ' x ' . $xoopsConfigUser['avatar_height'] |
||||||
| 306 | ) |
||||||
| 307 | ); |
||||||
| 308 | $form->addElement(new XoopsFormLabel(_US_MAXIMGSZ, $xoopsConfigUser['avatar_maxsize'])); |
||||||
| 309 | $form->addElement(new XoopsFormFile(_US_SELFILE, 'avatarfile', $xoopsConfigUser['avatar_maxsize']), true); |
||||||
| 310 | $form->addElement(new XoopsFormHidden('op', 'avatarupload')); |
||||||
| 311 | $form->addElement(new XoopsFormHidden('uid', $uid)); |
||||||
| 312 | $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||||||
| 313 | $form->display(); |
||||||
| 314 | } |
||||||
| 315 | $avatarHandler = xoops_getHandler('avatar'); |
||||||
| 316 | $form2 = new XoopsThemeForm(_US_CHOOSEAVT, 'uploadavatar', 'edituser.php', 'post', true); |
||||||
| 317 | $avatar_select = new XoopsFormSelect('', 'user_avatar', $xoopsUser->getVar('user_avatar')); |
||||||
| 318 | $avatar_select->addOptionArray($avatarHandler->getList('S')); |
||||||
|
0 ignored issues
–
show
The method
getList() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsImageHandler or XoopsRankHandler or XoopsCommentHandler or XoopsTplsetHandler or XoopsAvatarHandler or XoopsBlockHandler or XoopsImagesetHandler or XoopsPersistableObjectHandler or XoopsImagecategoryHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 319 | $avatar_select->setExtra( |
||||||
| 320 | "onchange='showImgSelected(\"avatar\", \"user_avatar\", \"uploads\", \"\", \"" . XOOPS_URL . "\")'" |
||||||
| 321 | ); |
||||||
| 322 | $avatar_tray = new XoopsFormElementTray(_US_AVATAR, ' '); |
||||||
| 323 | $avatar_tray->addElement($avatar_select); |
||||||
| 324 | $avatar_tray->addElement( |
||||||
| 325 | new XoopsFormLabel( |
||||||
| 326 | '', "<img src='" . XOOPS_UPLOAD_URL . '/' . $xoopsUser->getVar( |
||||||
| 327 | 'user_avatar', |
||||||
| 328 | 'E' |
||||||
| 329 | ) . "' name='avatar' id='avatar' alt=''> <a href=\"javascript:openWithSelfMain('" . XOOPS_URL . "/misc.php?action=showpopups&type=avatars','avatars',600,400);\">" . _LIST . '</a>' |
||||||
| 330 | ) |
||||||
| 331 | ); |
||||||
| 332 | $form2->addElement($avatar_tray); |
||||||
| 333 | $form2->addElement(new XoopsFormHidden('uid', $uid)); |
||||||
| 334 | $form2->addElement(new XoopsFormHidden('op', 'avatarchoose')); |
||||||
| 335 | $form2->addElement(new XoopsFormButton('', 'submit2', _SUBMIT, 'submit')); |
||||||
| 336 | $form2->display(); |
||||||
| 337 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||||
| 338 | } |
||||||
| 339 | |||||||
| 340 | if ('avatarupload' === $op) { |
||||||
| 341 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
| 342 | redirect_header( |
||||||
| 343 | 'index.php', |
||||||
| 344 | 3, |
||||||
| 345 | _US_NOEDITRIGHT . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()) |
||||||
| 346 | ); |
||||||
| 347 | } |
||||||
| 348 | $xoops_upload_file = []; |
||||||
| 349 | $uid = 0; |
||||||
| 350 | if (!empty($_POST['xoops_upload_file']) && is_array($_POST['xoops_upload_file'])) { |
||||||
| 351 | $xoops_upload_file = $_POST['xoops_upload_file']; |
||||||
| 352 | } |
||||||
| 353 | if (!empty($_POST['uid'])) { |
||||||
| 354 | $uid = Request::getInt('uid', 0, 'POST'); |
||||||
| 355 | } |
||||||
| 356 | if (empty($uid) || $xoopsUser->getVar('uid') !== $uid) { |
||||||
| 357 | redirect_header('index.php', 3, _US_NOEDITRIGHT); |
||||||
| 358 | } |
||||||
| 359 | $uploadDir = XOOPS_UPLOAD_PATH . '/'; |
||||||
| 360 | $allowed_mimetypes = ['image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png']; |
||||||
| 361 | if (1 === $xoopsConfigUser['avatar_allow_upload'] |
||||||
| 362 | && $xoopsUser->getVar( |
||||||
| 363 | 'posts' |
||||||
| 364 | ) >= $xoopsConfigUser['avatar_minposts']) { |
||||||
| 365 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||||||
| 366 | $uploader = new XoopsMediaUploader( |
||||||
| 367 | XOOPS_UPLOAD_PATH, $allowed_mimetypes, $xoopsConfigUser['avatar_maxsize'], $xoopsConfigUser['avatar_width'], $xoopsConfigUser['avatar_height'] |
||||||
| 368 | ); |
||||||
| 369 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
||||||
| 370 | $uploader->setPrefix('cavt'); |
||||||
| 371 | if ($uploader->upload()) { |
||||||
| 372 | $avtHandler = xoops_getHandler('avatar'); |
||||||
| 373 | $avatar = $avtHandler->create(); |
||||||
| 374 | $avatar->setVar('avatar_file', $uploader->getSavedFileName()); |
||||||
| 375 | $avatar->setVar('avatar_name', $xoopsUser->getVar('uname')); |
||||||
| 376 | $avatar->setVar('avatar_mimetype', $uploader->getMediaType()); |
||||||
| 377 | $avatar->setVar('avatar_display', 1); |
||||||
| 378 | $avatar->setVar('avatar_type', 'C'); |
||||||
| 379 | if (!$avtHandler->insert($avatar)) { |
||||||
|
0 ignored issues
–
show
Are you sure the usage of
$avtHandler->insert($avatar) targeting XoopsObjectHandler::insert() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||||||
| 380 | @unlink($uploader->getSavedDestination()); |
||||||
|
0 ignored issues
–
show
It seems like you do not handle an error condition for
unlink(). This can introduce security issues, and is generally not recommended.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
|
|||||||
| 381 | } else { |
||||||
| 382 | $oldavatar = $xoopsUser->getVar('user_avatar'); |
||||||
| 383 | if (!empty($oldavatar) && 0 === stripos($oldavatar, 'cavt')) { |
||||||
| 384 | $avatars = &$avtHandler->getObjects(new Criteria('avatar_file', $oldavatar)); |
||||||
|
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...
|
|||||||
| 385 | if (!empty($avatars) && 1 === count($avatars) && is_object($avatars[0])) { |
||||||
| 386 | $avtHandler->delete($avatars[0]); |
||||||
| 387 | $oldavatar_path = str_replace('\\', '/', realpath(XOOPS_UPLOAD_PATH . '/' . $oldavatar)); |
||||||
| 388 | if (0 === mb_strpos($oldavatar_path, XOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) { |
||||||
| 389 | unlink($oldavatar_path); |
||||||
| 390 | } |
||||||
| 391 | } |
||||||
| 392 | } |
||||||
| 393 | $sql = sprintf( |
||||||
| 394 | "UPDATE %s SET user_avatar = %s WHERE uid = '%u'", |
||||||
| 395 | $xoopsDB->prefix('users'), |
||||||
| 396 | $xoopsDB->quoteString($uploader->getSavedFileName()), |
||||||
| 397 | $uid |
||||||
| 398 | ); |
||||||
| 399 | $xoopsDB->query($sql); |
||||||
| 400 | $avtHandler->addUser($avatar->getVar('avatar_id'), $uid); |
||||||
|
0 ignored issues
–
show
The method
addUser() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsAvatarHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 401 | redirect_header('index.php?t=' . time() . '&uid=' . $uid, 2, _US_PROFUPDATED); |
||||||
| 402 | } |
||||||
| 403 | } |
||||||
| 404 | } |
||||||
| 405 | require XOOPS_ROOT_PATH . '/header.php'; |
||||||
| 406 | echo $uploader->getErrors(); |
||||||
| 407 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||||
| 408 | } |
||||||
| 409 | } |
||||||
| 410 | |||||||
| 411 | if ('avatarchoose' === $op) { |
||||||
| 412 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
| 413 | redirect_header( |
||||||
| 414 | 'index.php', |
||||||
| 415 | 3, |
||||||
| 416 | _US_NOEDITRIGHT . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()) |
||||||
| 417 | ); |
||||||
| 418 | } |
||||||
| 419 | $uid = 0; |
||||||
| 420 | if (!empty($_POST['uid'])) { |
||||||
| 421 | $uid = Request::getInt('uid', 0, 'POST'); |
||||||
| 422 | } |
||||||
| 423 | if (empty($uid) || $xoopsUser->getVar('uid') !== $uid) { |
||||||
| 424 | redirect_header('index.php', 3, _US_NOEDITRIGHT); |
||||||
| 425 | } |
||||||
| 426 | $user_avatar = ''; |
||||||
| 427 | $avtHandler = xoops_getHandler('avatar'); |
||||||
| 428 | if (!empty($_POST['user_avatar'])) { |
||||||
| 429 | $user_avatar = Request::getString('user_avatar', '', 'POST'); |
||||||
| 430 | $criteria_avatar = new CriteriaCompo(new Criteria('avatar_file', $user_avatar)); |
||||||
| 431 | $criteria_avatar->add(new Criteria('avatar_type', 'S')); |
||||||
| 432 | $avatars = &$avtHandler->getObjects($criteria_avatar); |
||||||
| 433 | if (!is_array($avatars) || !count($avatars)) { |
||||||
| 434 | $user_avatar = 'avatars/blank.gif'; |
||||||
| 435 | } |
||||||
| 436 | unset($avatars, $criteria_avatar); |
||||||
| 437 | } |
||||||
| 438 | $user_avatarpath = str_replace('\\', '/', realpath(XOOPS_UPLOAD_PATH . '/' . $user_avatar)); |
||||||
| 439 | if (0 === mb_strpos($user_avatarpath, XOOPS_UPLOAD_PATH) && is_file($user_avatarpath)) { |
||||||
| 440 | $oldavatar = $xoopsUser->getVar('user_avatar'); |
||||||
| 441 | $xoopsUser->setVar('user_avatar', $user_avatar); |
||||||
| 442 | $memberHandler = xoops_getHandler('member'); |
||||||
| 443 | if (!$memberHandler->insertUser($xoopsUser)) { |
||||||
|
0 ignored issues
–
show
The method
insertUser() does not exist on XoopsObjectHandler. Did you maybe mean insert()?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 444 | require XOOPS_ROOT_PATH . '/header.php'; |
||||||
| 445 | echo $xoopsUser->getHtmlErrors(); |
||||||
| 446 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||||
| 447 | exit(); |
||||||
| 448 | } |
||||||
| 449 | if ($oldavatar && 0 === stripos($oldavatar, 'cavt')) { |
||||||
| 450 | $avatars = &$avtHandler->getObjects(new Criteria('avatar_file', $oldavatar)); |
||||||
| 451 | if (!empty($avatars) && 1 === count($avatars) && is_object($avatars[0])) { |
||||||
| 452 | $avtHandler->delete($avatars[0]); |
||||||
| 453 | $oldavatar_path = str_replace('\\', '/', realpath(XOOPS_UPLOAD_PATH . '/' . $oldavatar)); |
||||||
| 454 | if (0 === mb_strpos($oldavatar_path, XOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) { |
||||||
| 455 | unlink($oldavatar_path); |
||||||
| 456 | } |
||||||
| 457 | } |
||||||
| 458 | } |
||||||
| 459 | if ('avatars/blank.gif' !== $user_avatar) { |
||||||
| 460 | $avatars = &$avtHandler->getObjects(new Criteria('avatar_file', $user_avatar)); |
||||||
| 461 | if (is_object($avatars[0])) { |
||||||
| 462 | $avtHandler->addUser($avatars[0]->getVar('avatar_id'), $uid); |
||||||
| 463 | } |
||||||
| 464 | } |
||||||
| 465 | } |
||||||
| 466 | redirect_header('index.php?uid=' . $uid, 0, _US_PROFUPDATED); |
||||||
| 467 | } |
||||||
| 468 |