private function write_log($user_id, $exception) { $file = $exception->getFile(); $file = str_replace('\\', '\\\\', $file); $trace_as_string = $exception->getTraceAsString(); $trace_as_string = str_replace('\\', '\\\\', $trace_as_string); $trace_as_string = str_replace('\'', '\\"', $trace_as_string); $system_log = new SystemLog(null); $system_log->create($user_id, 2, 1, $exception->getMessage(), $exception->getCode(), $file, $exception->getLine(), null); $system_log->set_stack_trace($trace_as_string); }
/** * @see AuthInterface::forgot_password() * @param string $username * @param string $name * @return bool */ public function forgot_password($username, $mail) { if ($username and $mail) { $system_log = new SystemLog(null); if (User::exist_username($username)) { $user_id = User::get_user_id_by_username($username); $user = new User($user_id); if ($user->check_mail(strtolower($mail))) { if ($user->get_boolean_user_entry("user_inactive") == false) { $new_password = User::generate_password(); $mail = new Mail(); $mail->set_recipient($user_id); $mail->set_subject("Your New Open-LIMS Password"); $mail->set_text("Your new password: "******"must_change_password", true); // Password sended successfully $system_log->create($user_id, 1, 1, "Password Send", "Forgot Password", "auth.php", null, null); return true; } else { // Error via sending throw new AuthForgotPasswordSendFailedException("", 0); } } else { // Inactive User $system_log->create($user_id, 1, 1, "Inactive User", "Forgot Password", "auth.php", null, null); throw new AuthUserNotFoundException("", 0); } } else { // Wrong E-Mail $system_log->create($user_id, 1, 0, "Wrong E-Mail", "Forgot Password", "auth.php", null, null); throw new AuthUserNotFoundException("", 0); } } else { // User Not Found $system_log->create(null, 1, 0, "User \"" . $username . "\" Not Found", "Forgot Password", "auth.php", null, null); throw new AuthUserNotFoundException("", 0); } } else { throw new AuthUserNotFoundException("", 0); } }