From c8437f35c62f0ad12eee5d4b2ac075c44d7ed2c7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 18 Nov 2005 07:21:24 +0100 Subject: optional login form/http basic auth support --- functions.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index fc9818021..67575cbb2 100644 --- a/functions.php +++ b/functions.php @@ -515,8 +515,26 @@ db_query($link, "COMMIT"); } + + function authenticate_user($link, $login, $password) { + + $pwd_hash = 'SHA1:' . sha1($password); + + $result = db_query($link, "SELECT id,login FROM ttrss_users WHERE + login = '$login' AND (pwd_hash = '$password' OR pwd_hash = '$pwd_hash')"); + + if (db_num_rows($result) == 1) { + $_SESSION["uid"] = db_fetch_result($result, 0, "id"); + $_SESSION["name"] = db_fetch_result($result, 0, "login"); + + return true; + } - function authenticate_user($link) { + return false; + + } + + function http_authenticate_user($link) { if (!$_SERVER['PHP_AUTH_USER']) { @@ -529,16 +547,9 @@ $login = db_escape_string($_SERVER['PHP_AUTH_USER']); $password = db_escape_string($_SERVER['PHP_AUTH_PW']); - $pwd_hash = 'SHA1:' . sha1($password); - - $result = db_query($link, "SELECT id,login FROM ttrss_users WHERE - login = '$login' AND (pwd_hash = '$password' OR pwd_hash = '$pwd_hash')"); - if (db_num_rows($result) == 1) { - $_SESSION["uid"] = db_fetch_result($result, 0, "id"); - $_SESSION["name"] = db_fetch_result($result, 0, "login"); - } - } + return authenticate_user($link, $login, $password); + } } ?> -- cgit v1.2.3-54-g00ecf