public function changeEmail($uid, $email, $password, $captcha = NULL)
{
$return['error'] = true;
$block_status = $this->isBlocked();
if ($block_status == "verify") {
if ($this->checkCaptcha($captcha) == false) {
$return['message'] = $this->lang["user_verify_failed"];
return $return;
}
}
if ($block_status == "block") {
$return['message'] = $this->lang["user_blocked"];
return $return;
}
$validateEmail = $this->validateEmail($email);
if ($validateEmail['error'] == 1) {
$return['message'] = $validateEmail['message'];
return $return;
}
$validatePassword = $this->validatePassword($password);
if ($validatePassword['error'] == 1) {
$return['message'] = $this->lang["password_notvalid"];
return $return;
}
$user = $this->getBaseUser($uid);
if (!$user) {
$this->addAttempt();
$return['message'] = $this->lang["system_error"] . " #14";
return $return;
}
if (!password_verify($password, $user['password'])) {
$this->addAttempt();
$return['message'] = $this->lang["password_incorrect"];
return $return;
}
if ($email == $user['email']) {
$this->addAttempt();
$return['message'] = $this->lang["newemail_match"];
return $return;
}
$query = $this->dbh->prepare("UPDATE {$this->config->table_users} SET email = ? WHERE id = ?");
$query->execute(array($email, $uid));
if ($query->rowCount() == 0) {
$return['message'] = $this->lang["system_error"] . " #15";
return $return;
}
$return['error'] = false;
$return['message'] = $this->lang["email_changed"];
return $return;
}