/** * Change account email and validate authenticity */ public function changeEmail() { // confirm_delete $player = new Player(self_char_id()); $self_info = $player->dataWithClan(); $passW = in('passw', null); $username = $self_info['uname']; $in_newEmail = trim(in('newemail')); $in_confirmEmail = trim(in('confirmemail')); $error = ''; $successMessage = ''; $verify = self::is_authentic($username, $passW); if ($verify) { if ($in_newEmail === $in_confirmEmail) { if (!email_is_duplicate($in_newEmail)) { if (email_fits_pattern($in_newEmail)) { $this->_changeEmail($player->id(), $in_newEmail); $successMessage = 'Your email has been updated.'; } else { $error = 'Your email must be a valid email address containing a domain name and no spaces.'; } } else { $error = 'The email you provided is already in use.'; } } else { $error = 'Your new emails did not match.'; } } else { $error = 'You did not provide the correct current password.'; } $parts = ['error' => $error, 'successMessage' => $successMessage]; return $this->render($parts); }
function validate_email($email) { $error = null; if (FALSE) { // CURRENTLY NO BLOCKED EMAIL SERVICES //strstr($send_email, '@') == '@aol.com' || strstr($send_email, '@') == '@netscape.com' || strstr($send_email, '@') == '@aim.com' //Throws error if email from blocked domain. $error = 'Phase 3 Incomplete: We cannot currently accept @aol.com, @netscape.com, or @aim.com email addresses.'; } elseif (!email_fits_pattern($email)) { $error = 'Phase 3 Incomplete: The email address (' . htmlentities($email) . ') must not contain spaces and must contain an @ symbol and a domain name to be valid.'; } elseif (email_is_duplicate($email)) { $error = 'Phase 3 Incomplete: There is already an account using that email. If that account is yours, you can request a password reset to gain access again.'; } return $error; }
} else { if ($deleteAccount == 2) { SESSION::set('delete_attempts', 1); $error = 'Deleting of account failed, please email ' . SUPPORT_EMAIL; } else { $confirm_delete = true; } } } else { if ($change_email) { if ($change_email == 2) { $verify = is_authentic($username, $passW); if ($verify) { if ($in_newEmail === $in_confirmEmail) { if (!email_is_duplicate($in_newEmail)) { if (email_fits_pattern($in_newEmail)) { changeEmail($user_id, $in_newEmail); $change_email = 0; $successMessage = 'Your email has been updated.'; } else { $error = 'Your email must be a valid email address containing a domain name and no spaces.'; } } else { $error = 'The email you provided is already in use.'; } } else { $error = 'Your new emails did not match.'; } } else { $error = 'You did not provide the correct current password.'; }