コード例 #1
0
function leoUser_changeEmail($userID, $newEmail)
{
    global $db, $CONF;
    if (!$userID || !$newEmail) {
        return -1;
    }
    $email = emailChecked($newEmail);
    if (!$email) {
        return -2;
    }
    $sql = 'UPDATE ' . $CONF['userdb']['users_table'] . ' SET ' . $CONF['userdb']['email_field'] . '="' . $email . '" WHERE ' . $CONF['userdb']['user_id_field'] . "={$userID}";
    $res = $db->sql_query($sql);
    if ($res <= 0) {
        return 0;
    }
    return 1;
}
コード例 #2
0
ファイル: FN_pilot.php プロジェクト: Peter2121/leonardoxc
/**
 * Martin Jursa 26.04.2007
 * Save email and password to user table if the respective options are set
 * returns a resultmessage
 *
 * @param int $userID
 * @param string $newEmail
 * @param string $newPassword
 * @param string $newPasswordConfirmation
 * @return string
 */
function saveLoginData($userID, $newEmail, $newPassword, $newPasswordConfirmation)
{
    global $db;
    global $CONF_edit_login;
    global $CONF_edit_email;
    global $CONF_password_minlength;
    global $CONF;
    $goodmsgs = array();
    $errmsgs = array();
    if (!$CONF['userdb']['edit']['enabled']) {
        $errmsgs[] = 'saveLoginData requires turning on CONF["userdb"]["edit"]["enabled"].';
    } elseif (empty($userID)) {
        $errmsgs[] = 'UserID is missing; cannot update login data.';
    } else {
        if ($CONF['userdb']['edit']['edit_email'] && $newEmail != '#same_as_old#leonardo#') {
            if (empty($newEmail)) {
                $errmsgs[] = _EmailEmpty;
            } else {
                $saved = false;
                $email = emailChecked($newEmail);
                if ($email == '') {
                    $errmsgs[] = _EmailInvalid;
                } else {
                    if (LeoUser::changeEmail($userID, $email) > 0) {
                        $saved = true;
                        $goodmsgs[] = _EmailSaved;
                    } else {
                        $errmsgs[] = _EmailSaveProblem;
                    }
                    /*
                    $sql='UPDATE '.$CONF['userdb']['users_table']." SET user_email='$email' WHERE user_id=$userID";
                    $res=$db->sql_query($sql);
                    			  		if($res<=0){
                    			  			$errmsgs[]=_EmailSaveProblem;
                    			  		}else {
                    	//$goodmsgs[]=_EmailSaved;
                    	$saved=true;
                    			  		}
                    */
                }
                if (!$saved) {
                    $errmsgs[] = _EmailNotSaved;
                }
            }
        }
        $newPassword = trim($newPassword);
        $newPasswordConfirmation = trim($newPasswordConfirmation);
        if ($CONF['userdb']['edit']['edit_password'] && $newPassword) {
            $saved = false;
            $passwordMinLength = !empty($CONF['userdb']['edit']['password_minlength']) ? $CONF['userdb']['edit']['password_minlength'] : 4;
            if ($newPasswordConfirmation == '') {
                $errmsgs[] = _PwdConfEmpty;
            } elseif (strlen($newPassword) < $passwordMinLength) {
                $pwdMsg = sprintf(_PwdTooShort, $passwordMinLength);
                $errmsgs[] = $pwdMsg;
            } elseif ($newPassword != $newPasswordConfirmation) {
                $errmsgs[] = _PwdAndConfDontMatch;
            } else {
                if (LeoUser::changePassword($userID, $newPassword) > 0) {
                    $saved = true;
                    $goodmsgs[] = _PwdChanged;
                } else {
                    $errmsgs[] = _PwdChangeProblem;
                }
                /*
                $pwd=md5($newPassword);
                $sql='UPDATE '.$CONF['userdb']['users_table']." SET user_password='******' WHERE user_id=$userID";
                $res=$db->sql_query($sql);
                		  		if($res<=0){
                		  			$errmsgs[]=_PwdChangeProblem;
                		  		}else {
                		  			$goodmsgs[]=_PwdChanged;
                	  				$saved=true;
                		  		}
                */
            }
            if (!$saved) {
                $errmsgs[] = _PwdNotChanged;
            }
        }
    }
    $message = '';
    if (count($goodmsgs) > 0) {
        $message .= '<span class="ok">' . implode('<br>', $goodmsgs) . '</span>';
    }
    if (count($errmsgs) > 0) {
        $message .= '<span class="alert">' . implode('<br>', $errmsgs) . '</span>';
    }
    return $message;
}
コード例 #3
0
 $pilotdata = _get_pilot_atributes();
 $actkey = md5(uniqid(rand(), true));
 $msg = '';
 //_EmailInvalid
 $expiretime = date("d/M/Y H:i:s", $userdata['user_emailtime'] + $CONF_expire_time);
 $email = trim($_POST['emtochange']);
 $email2 = trim($_POST['emtochange2']);
 if ($email != $email2) {
     $msg = _Email_AndConfDontMatch;
 }
 // "Informed emails are not equal";
 if (strlen($msg) == 0 && strlen($email) == 0) {
     $msg = _EmailEmpty;
 }
 //"Email can not be empty!";
 if (strlen($msg) == 0 && $email != emailChecked($email)) {
     $msg = _EmailInvalid;
 }
 // Invalid Email
 if (strlen($msg) == 0 && $userdata['user_email'] == $email) {
     $msg = _Email_allready_yours;
 }
 //"The informed email is allready yours, nothing to do"
 if (strlen($msg) == 0 && $userdata['user_new_email'] == $email) {
     $msg = _Email_allready_have_request;
 }
 //'There is already your request for changing to these email, nothing to do'
 if (strlen($msg) == 0 && _check_double_email($email, 'old')) {
     $msg = _Email_used_by_other;
 }
 //"this email are used in another pilot"