1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2026-02-07 19:11:34 +00:00

http user auth, password changer in preferences

This commit is contained in:
Andrew Dolgov
2005-11-18 07:04:32 +01:00
parent 99620a7fe0
commit 1c7f75ed2c
7 changed files with 93 additions and 14 deletions

View File

@@ -4,8 +4,8 @@
require_once 'config.php';
require_once 'db-prefs.php';
$_SESSION["uid"] = PLACEHOLDER_UID; // FIXME: placeholder
$_SESSION["name"] = PLACEHOLDER_NAME;
// $_SESSION["uid"] = PLACEHOLDER_UID; // FIXME: placeholder
// $_SESSION["name"] = PLACEHOLDER_NAME;
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
@@ -516,4 +516,29 @@
}
function authenticate_user($link) {
if (!$_SERVER['PHP_AUTH_USER']) {
header('WWW-Authenticate: Basic realm="Tiny Tiny RSS"');
header('HTTP/1.0 401 Unauthorized');
print "<h1>401 Unathorized</h1>";
exit;
} else {
$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");
}
}
}
?>