summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2005-11-18 07:21:24 +0100
committerAndrew Dolgov <[email protected]>2005-11-18 07:21:24 +0100
commitc8437f35c62f0ad12eee5d4b2ac075c44d7ed2c7 (patch)
tree6b8c41f78785dc2ff6a35c09fa600b82597cf400 /functions.php
parent1c7f75ed2c8e0c914bba2134158e483aa1c3af40 (diff)
optional login form/http basic auth support
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php31
1 files changed, 21 insertions, 10 deletions
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);
+ }
}
?>