Example #1
0
// initialize $op variable
$op = XoopsRequest::getCmd('op', 'editprofile');
$config_handler = xoops_getHandler('config');
$xoopsConfigUser = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
$myts = MyTextSanitizer::getInstance();
if ($op === 'saveuser') {
    if (!$GLOBALS['xoopsSecurity']->check()) {
        redirect_header('index.php', 3, _US_NOEDITRIGHT . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
    }
    $uid = XoopsRequest::getInt('uid', 0);
    if (empty($uid) || $xoopsUser->getVar('uid') != $uid) {
        redirect_header('index.php', 3, _US_NOEDITRIGHT);
    }
    $errors = array();
    if ($xoopsConfigUser['allow_chgmail'] == 1) {
        $email = XoopsRequest::getEmail('email', '');
        if (empty($email)) {
            $errors[] = _US_INVALIDMAIL;
        }
    }
    $password = XoopsRequest::getString('password', '');
    if (!empty($password)) {
        if (strlen($password) < $xoopsConfigUser['minpass']) {
            $errors[] = sprintf(_US_PWDTOOSHORT, $xoopsConfigUser['minpass']);
        } else {
            $vpass = XoopsRequest::getString('vpass', '');
            if ($password != $vpass) {
                $errors[] = _US_PASSNOTSAME;
            }
        }
    }