is_anonymous()) { logout(); header("Location: login.html"); exit; } define("login_no_error", 0); define("login_bad", 1); define("login_bad_credentials", 2); define("login_user_banned", 3); define("login_unconfirmed", 4); class logger { private $recovery = false; private $email = ""; private $password = ""; private $remember = false; private $from_register = false; private $error = ""; public function __construct() { if (isset($_POST["submit"])) { $this->email = safe_post("email"); $this->password = safe_post("password"); $this->remember = (safe_post("remember") == "1"); } else if (isset($_GET["r"])) { $this->recovery = true; } else if (isset($_GET["reg"])) { $this->from_register = true; } } public function output() { $s = "
"; if ($this->recovery) $s .= loc("login_recovery") . "

"; else if ($this->from_register) $s .= html::wrap_div("bt_forum_notif", loc("login_wait_confirm")); if ($this->error !== "") $s .= html::wrap_div("bt_forum_error", $this->error) . "
"; $s .= "
" . loc("login_email") . "
" . html::text("email", "", true) . "

" . loc("login_password") . "
" . html::password("password") . "

" . html::checkbox( "remember", "1", loc("login_remember"), $this->remember) . "

" . html::submit(loc("login_submit")) . " " . make_back_inputs() . "

" . html::wrap_div("bt_forum_recover_link", html::a("recover.html", loc("recover_link"))) . "
"; echo $s; } public function go() { if (!$this->verify()) return; try { $lifetime = 0; if ($this->remember) $lifetime = 60 * 60 * 24 * 30; if (try_login($this->email, $this->password, $lifetime)) return true; $this->error = loc("login_bad"); } catch(user_banned $e) { $this->error = loc("login_banned"); } catch(unconfirmed_user $e) { $this->error = loc("login_unconfirmed"); } sleep(1); return false; } public function verify() { if ($this->email == "" || $this->password == "") return false; return true; } } $lg = new logger(); if (isset($_POST["submit"])) { if ($lg->go()) { goto_back_link(); exit; } } ?>
output(); output_footer(); ?>