Passed
Push — master ( 6209eb...36ba5e )
by Michael
51s queued 14s
created

edituser.php (9 issues)

Labels
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
The constant editprofile was not found. Maybe you did not declare it correctly or list all dependencies?
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 ignore-call  annotation

50
    /** @scrutinizer ignore-call */ 
51
    $mod_yogurt    = $moduleHandler->getByDirname('profile');
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 ignore-call  annotation

53
        /** @scrutinizer ignore-call */ 
54
        $xoopsConfigUser = $configHandler->getConfigsByCat(0, $mod_yogurt->getVar('mid'));
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>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _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,
190
        'timezone_offset',
191
        $xoopsUser->getVar(
192
            'timezone_offset'
193
        )
194
    );
195
    $location_text   = new XoopsFormText(_US_LOCATION, 'user_from', 30, 100, $xoopsUser->getVar('user_from', 'E'));
196
    $occupation_text = new XoopsFormText(_US_OCCUPATION, 'user_occ', 30, 100, $xoopsUser->getVar('user_occ', 'E'));
197
    $interest_text   = new XoopsFormText(
198
        _US_INTEREST,
199
        'user_intrest',
200
        30,
201
        150,
202
        $xoopsUser->getVar(
203
            'user_intrest',
204
            'E'
205
        )
206
    );
207
    $sig_tray        = new XoopsFormElementTray(_US_SIGNATURE, '<br>');
208
    require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php';
209
    $sig_tarea = new XoopsFormDhtmlTextArea('', 'user_sig', $xoopsUser->getVar('user_sig', 'E'));
210
    $sig_tray->addElement($sig_tarea);
211
    $sig_cbox_value = $xoopsUser->getVar('attachsig') ? 1 : 0;
212
    $sig_cbox       = new XoopsFormCheckBox('', 'attachsig', $sig_cbox_value);
213
    $sig_cbox->addOption(1, _US_SHOWSIG);
214
    $sig_tray->addElement($sig_cbox);
215
    $umode_select = new XoopsFormSelect(_US_CDISPLAYMODE, 'umode', $xoopsUser->getVar('umode'));
216
    $umode_select->addOptionArray(
217
        [
218
            'nest'   => _NESTED,
219
            'flat'   => _FLAT,
220
            'thread' => _THREADED,
221
        ]
222
    );
223
    $uorder_select = new XoopsFormSelect(_US_CSORTORDER, 'uorder', $xoopsUser->getVar('uorder'));
224
    $uorder_select->addOptionArray(
225
        [
226
            XOOPS_COMMENT_OLD1ST => _OLDESTFIRST,
227
            XOOPS_COMMENT_NEW1ST => _NEWESTFIRST,
228
        ]
229
    );
230
    // RMV-NOTIFY
231
    // TODO: add this to admin user-edit functions...
232
    require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php';
233
    require_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
234
    $notify_method_select = new XoopsFormSelect(
235
        _NOT_NOTIFYMETHOD,
236
        'notify_method',
237
        $xoopsUser->getVar(
238
            'notify_method'
239
        )
240
    );
241
    $notify_method_select->addOptionArray(
242
        [
243
            XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE,
244
            XOOPS_NOTIFICATION_METHOD_PM      => _NOT_METHOD_PM,
245
            XOOPS_NOTIFICATION_METHOD_EMAIL   => _NOT_METHOD_EMAIL,
246
        ]
247
    );
248
    $notify_mode_select = new XoopsFormSelect(_NOT_NOTIFYMODE, 'notify_mode', $xoopsUser->getVar('notify_mode'));
249
    $notify_mode_select->addOptionArray(
250
        [
251
            XOOPS_NOTIFICATION_MODE_SENDALWAYS         => _NOT_MODE_SENDALWAYS,
252
            XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE,
253
            XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT   => _NOT_MODE_SENDONCEPERLOGIN,
254
        ]
255
    );
256
    $bio_tarea = new XoopsFormTextArea(_US_EXTRAINFO, 'bio', $xoopsUser->getVar('bio', 'E'));
257
    //    $cookie_radio_value = empty($_COOKIE[$xoopsConfig['usercookie']]) ? 0 : 1;
258
    //    $cookie_radio       = new \XoopsFormRadioYN(_US_USECOOKIE, 'usecookie', $cookie_radio_value, _YES, _NO);
259
    $pwd_text  = new XoopsFormPassword(
260
        '',
261
        'password',
262
        10,
263
        255
264
    );
265
    $pwd_text2 = new XoopsFormPassword('', 'vpass', 10, 255);
266
    $pwd_tray  = new XoopsFormElementTray(_US_PASSWORD . '<br>' . _US_TYPEPASSTWICE);
267
    $pwd_tray->addElement($pwd_text);
268
    $pwd_tray->addElement($pwd_text2);
269
    $mailok_radio = new XoopsFormRadioYN(_US_MAILOK, 'user_mailok', $xoopsUser->getVar('user_mailok'));
270
    $uid_hidden    = new XoopsFormHidden('uid', $uid);
271
    $op_hidden     = new XoopsFormHidden('op', 'saveuser');
272
    $submit_button = new XoopsFormButton('', 'submit', _US_SAVECHANGES, 'submit');
273
274
    $form->addElement($timezone_select);
275
    $form->addElement($location_text);
276
    $form->addElement($occupation_text);
277
    $form->addElement($interest_text);
278
    $form->addElement($sig_tray);
279
    $form->addElement($umode_select);
280
    $form->addElement($uorder_select);
281
    $form->addElement($notify_method_select);
282
    $form->addElement($notify_mode_select);
283
    $form->addElement($bio_tarea);
284
    $form->addElement($pwd_tray);
285
    //    $form->addElement($cookie_radio);
286
    $form->addElement($mailok_radio);
287
    $form->addElement($uid_hidden);
288
    $form->addElement($op_hidden);
289
    //    $form->addElement($token_hidden);
290
    $form->addElement($submit_button);
291
    if (1 === $xoopsConfigUser['allow_chgmail']) {
292
        $form->setRequired($email_text);
293
    }
294
    $form->display();
295
    require XOOPS_ROOT_PATH . '/footer.php';
296
}
297
298
if ('avatarform' === $op) {
299
    require XOOPS_ROOT_PATH . '/header.php';
300
    $uid = (int)$xoopsUser->getVar('uid');
301
    echo '<a href="index.php?uid=' . $uid . '">' . _US_PROFILE . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _US_UPLOADMYAVATAR . '<br><br>';
302
    $oldavatar = $xoopsUser->getVar('user_avatar');
303
    if (!empty($oldavatar) && 'avatars/blank.gif' !== $oldavatar) {
304
        echo '<div style="text-align:center;"><h4 style="color:#ff0000; font-weight:bold;">' . _US_OLD_DELETED . '</h4>';
0 ignored issues
show
The constant _US_OLD_DELETED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
305
        echo '<img src="' . XOOPS_UPLOAD_URL . '/' . $oldavatar . '" alt=""></div>';
306
    }
307
    if (1 === $xoopsConfigUser['avatar_allow_upload']
308
        && $xoopsUser->getVar(
309
            'posts'
310
        ) >= $xoopsConfigUser['avatar_minposts']) {
311
        require_once __DIR__ . '/class/xoopsformloader.php';
312
        $form = new XoopsThemeForm(_US_UPLOADMYAVATAR, 'uploadavatar', 'edituser.php', 'post', true);
313
        $form->setExtra('enctype="multipart/form-data"');
314
        $form->addElement(
315
            new XoopsFormLabel(
316
                _US_MAXPIXEL,
317
                $xoopsConfigUser['avatar_width'] . ' x ' . $xoopsConfigUser['avatar_height']
318
            )
319
        );
320
        $form->addElement(new XoopsFormLabel(_US_MAXIMGSZ, $xoopsConfigUser['avatar_maxsize']));
321
        $form->addElement(new XoopsFormFile(_US_SELFILE, 'avatarfile', $xoopsConfigUser['avatar_maxsize']), true);
322
        $form->addElement(new XoopsFormHidden('op', 'avatarupload'));
323
        $form->addElement(new XoopsFormHidden('uid', $uid));
324
        $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
325
        $form->display();
326
    }
327
    $avatarHandler = xoops_getHandler('avatar');
328
    $form2         = new XoopsThemeForm(_US_CHOOSEAVT, 'uploadavatar', 'edituser.php', 'post', true);
329
    $avatar_select = new XoopsFormSelect('', 'user_avatar', $xoopsUser->getVar('user_avatar'));
330
    $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 ignore-call  annotation

330
    $avatar_select->addOptionArray($avatarHandler->/** @scrutinizer ignore-call */ getList('S'));
Loading history...
331
    $avatar_select->setExtra(
332
        "onchange='showImgSelected(\"avatar\", \"user_avatar\", \"uploads\", \"\", \"" . XOOPS_URL . "\")'"
333
    );
334
    $avatar_tray = new XoopsFormElementTray(_US_AVATAR, '&nbsp;');
335
    $avatar_tray->addElement($avatar_select);
336
    $avatar_tray->addElement(
337
        new XoopsFormLabel(
338
            '',
339
            "<img src='" . XOOPS_UPLOAD_URL . '/' . $xoopsUser->getVar(
340
                'user_avatar',
341
                'E'
342
            ) . "' name='avatar' id='avatar' alt=''> <a href=\"javascript:openWithSelfMain('" . XOOPS_URL . "/misc.php?action=showpopups&amp;type=avatars','avatars',600,400);\">" . _LIST . '</a>'
343
        )
344
    );
345
    $form2->addElement($avatar_tray);
346
    $form2->addElement(new XoopsFormHidden('uid', $uid));
347
    $form2->addElement(new XoopsFormHidden('op', 'avatarchoose'));
348
    $form2->addElement(new XoopsFormButton('', 'submit2', _SUBMIT, 'submit'));
349
    $form2->display();
350
    require XOOPS_ROOT_PATH . '/footer.php';
351
}
352
353
if ('avatarupload' === $op) {
354
    if (!$GLOBALS['xoopsSecurity']->check()) {
355
        redirect_header(
356
            'index.php',
357
            3,
358
            _US_NOEDITRIGHT . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
359
        );
360
    }
361
    $xoops_upload_file = [];
362
    $uid               = 0;
363
    if (!empty($_POST['xoops_upload_file']) && is_array($_POST['xoops_upload_file'])) {
364
        $xoops_upload_file = $_POST['xoops_upload_file'];
365
    }
366
    if (!empty($_POST['uid'])) {
367
        $uid = Request::getInt('uid', 0, 'POST');
368
    }
369
    if (empty($uid) || $xoopsUser->getVar('uid') !== $uid) {
370
        redirect_header('index.php', 3, _US_NOEDITRIGHT);
371
    }
372
    $uploadDir         = XOOPS_UPLOAD_PATH . '/';
373
    $allowed_mimetypes = ['image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'];
374
    if (1 === $xoopsConfigUser['avatar_allow_upload']
375
        && $xoopsUser->getVar(
376
            'posts'
377
        ) >= $xoopsConfigUser['avatar_minposts']) {
378
        require_once XOOPS_ROOT_PATH . '/class/uploader.php';
379
        $uploader = new XoopsMediaUploader(
380
            XOOPS_UPLOAD_PATH,
381
            $allowed_mimetypes,
382
            $xoopsConfigUser['avatar_maxsize'],
383
            $xoopsConfigUser['avatar_width'],
384
            $xoopsConfigUser['avatar_height']
385
        );
386
        if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
387
            $uploader->setPrefix('cavt');
388
            if ($uploader->upload()) {
389
                $avtHandler = xoops_getHandler('avatar');
390
                $avatar     = $avtHandler->create();
391
                $avatar->setVar('avatar_file', $uploader->getSavedFileName());
392
                $avatar->setVar('avatar_name', $xoopsUser->getVar('uname'));
393
                $avatar->setVar('avatar_mimetype', $uploader->getMediaType());
394
                $avatar->setVar('avatar_display', 1);
395
                $avatar->setVar('avatar_type', 'C');
396
                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 getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
397
                    @unlink($uploader->getSavedDestination());
398
                } else {
399
                    $oldavatar = $xoopsUser->getVar('user_avatar');
400
                    if (!empty($oldavatar) && 0 === stripos($oldavatar, 'cavt')) {
401
                        $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 ignore-call  annotation

401
                        $avatars = &$avtHandler->/** @scrutinizer ignore-call */ getObjects(new Criteria('avatar_file', $oldavatar));
Loading history...
402
                        if (!empty($avatars) && 1 === count($avatars) && is_object($avatars[0])) {
403
                            $avtHandler->delete($avatars[0]);
404
                            $oldavatar_path = str_replace('\\', '/', realpath(XOOPS_UPLOAD_PATH . '/' . $oldavatar));
405
                            if (0 === mb_strpos($oldavatar_path, XOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) {
406
                                unlink($oldavatar_path);
407
                            }
408
                        }
409
                    }
410
                    $sql = sprintf(
411
                        "UPDATE %s SET user_avatar = %s WHERE uid = '%u'",
412
                        $xoopsDB->prefix('users'),
413
                        $xoopsDB->quoteString($uploader->getSavedFileName()),
414
                        $uid
415
                    );
416
                    $xoopsDB->query($sql);
417
                    $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 ignore-call  annotation

417
                    $avtHandler->/** @scrutinizer ignore-call */ 
418
                                 addUser($avatar->getVar('avatar_id'), $uid);
Loading history...
418
                    redirect_header('index.php?t=' . time() . '&amp;uid=' . $uid, 2, _US_PROFUPDATED);
419
                }
420
            }
421
        }
422
        require XOOPS_ROOT_PATH . '/header.php';
423
        echo $uploader->getErrors();
424
        require XOOPS_ROOT_PATH . '/footer.php';
425
    }
426
}
427
428
if ('avatarchoose' === $op) {
429
    if (!$GLOBALS['xoopsSecurity']->check()) {
430
        redirect_header(
431
            'index.php',
432
            3,
433
            _US_NOEDITRIGHT . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
434
        );
435
    }
436
    $uid = 0;
437
    if (!empty($_POST['uid'])) {
438
        $uid = Request::getInt('uid', 0, 'POST');
439
    }
440
    if (empty($uid) || $xoopsUser->getVar('uid') !== $uid) {
441
        redirect_header('index.php', 3, _US_NOEDITRIGHT);
442
    }
443
    $user_avatar = '';
444
    $avtHandler  = xoops_getHandler('avatar');
445
    if (!empty($_POST['user_avatar'])) {
446
        $user_avatar     = Request::getString('user_avatar', '', 'POST');
447
        $criteria_avatar = new CriteriaCompo(new Criteria('avatar_file', $user_avatar));
448
        $criteria_avatar->add(new Criteria('avatar_type', 'S'));
449
        $avatars = &$avtHandler->getObjects($criteria_avatar);
450
        if (!is_array($avatars) || !count($avatars)) {
451
            $user_avatar = 'avatars/blank.gif';
452
        }
453
        unset($avatars, $criteria_avatar);
454
    }
455
    $user_avatarpath = str_replace('\\', '/', realpath(XOOPS_UPLOAD_PATH . '/' . $user_avatar));
456
    if (0 === mb_strpos($user_avatarpath, XOOPS_UPLOAD_PATH) && is_file($user_avatarpath)) {
457
        $oldavatar = $xoopsUser->getVar('user_avatar');
458
        $xoopsUser->setVar('user_avatar', $user_avatar);
459
        $memberHandler = xoops_getHandler('member');
460
        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 ignore-call  annotation

460
        if (!$memberHandler->/** @scrutinizer ignore-call */ insertUser($xoopsUser)) {

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...
461
            require XOOPS_ROOT_PATH . '/header.php';
462
            echo $xoopsUser->getHtmlErrors();
463
            require XOOPS_ROOT_PATH . '/footer.php';
464
            exit();
465
        }
466
        if ($oldavatar && 0 === stripos($oldavatar, 'cavt')) {
467
            $avatars = &$avtHandler->getObjects(new Criteria('avatar_file', $oldavatar));
468
            if (!empty($avatars) && 1 === count($avatars) && is_object($avatars[0])) {
469
                $avtHandler->delete($avatars[0]);
470
                $oldavatar_path = str_replace('\\', '/', realpath(XOOPS_UPLOAD_PATH . '/' . $oldavatar));
471
                if (0 === mb_strpos($oldavatar_path, XOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) {
472
                    unlink($oldavatar_path);
473
                }
474
            }
475
        }
476
        if ('avatars/blank.gif' !== $user_avatar) {
477
            $avatars = &$avtHandler->getObjects(new Criteria('avatar_file', $user_avatar));
478
            if (is_object($avatars[0])) {
479
                $avtHandler->addUser($avatars[0]->getVar('avatar_id'), $uid);
480
            }
481
        }
482
    }
483
    redirect_header('index.php?uid=' . $uid, 0, _US_PROFUPDATED);
484
}
485