protected function password_reset_send_code() { global $lang, $config; if (!$this->is_password_reset) { return $this->account_login_status; } // Проверяем поддержку сброса пароля if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { return $this->account_login_status; } try { $email_unsafe = $this->input_email_unsafe; unset($this->account); $this->account = new Account($this->db); if (!$this->account->db_get_by_email($email_unsafe)) { throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR); // return $this->account_login_status; } $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 $user_list = db_user_list_by_id(array_keys($account_translation)); // TODO - Проверять уровень доступа аккаунта! // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ! foreach ($user_list as $user_id => $user_data) { if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR); } } $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR); } // Удаляем предыдущие записи продтверждения сброса пароля !empty($confirmation['id']) or $this->confirmation->db_confirmation_delete_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 sn_db_transaction_start(); $confirm_code_unsafe = $this->confirmation->db_confirmation_get_unique_code_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 sn_db_transaction_commit(); @($result = mymail($email_unsafe, sprintf($lang['log_lost_email_title'], $config->game_name), sprintf($lang['log_lost_email_code'], SN_ROOT_VIRTUAL . 'login.php', $confirm_code_unsafe, date(FMT_DATE_TIME, SN_TIME_NOW + AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE), $config->game_name))); $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING; } catch (Exception $e) { sn_db_transaction_rollback(); $result = $e->getMessage(); } return $this->account_login_status = $result; }