From 2b8b845abe7c13ecbb266613910484310cffe8e1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 5 Mar 2021 21:14:35 +0300 Subject: * use ORM for trivial queries * environment-based configuration * useradm.php -> update.php with new options * support for schema migrations * various fixes --- login.php | 135 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 67 insertions(+), 68 deletions(-) (limited to 'login.php') diff --git a/login.php b/login.php index 2526a26..76f7a7f 100644 --- a/login.php +++ b/login.php @@ -1,93 +1,92 @@ where('user', $username) + ->where('pass', $pass_hash) + ->find_one(); - $sth = $dbh->prepare("SELECT id FROM epube_users WHERE user = ? AND pass = ?"); - $sth->execute([$user, $password]); + if ($user) { + if (session_status() != PHP_SESSION_ACTIVE) + session_start(); - if ($line = $sth->fetch()) { - - session_start(); session_regenerate_id(true); - $_SESSION["owner"] = $user; + $_SESSION["owner"] = $username; + $_SESSION["pass_hash"] = sha1($user->pass); + header("Location: index.php"); + exit; + } else { $login_notice = "Incorrect username or password"; } } - ?> - - - - - - - The Epube - - - - - - - - - - -
- - -
- - -
- - -
- - + + + + + + + The Epube + + + + + + + + - - +
+ +
+ + +
+ + +
+ + +
+
+ + +
+ +
+
+ -- cgit v1.2.3