]>
Commit | Line | Data |
---|---|---|
0d3adafe | 1 | <? |
3dd46f19 | 2 | require_once "functions.php"; |
0d3adafe AD |
3 | |
4 | require_once "../version.php"; | |
5 | require_once "../config.php"; | |
6 | require_once "../functions.php"; | |
7 | ||
8 | $url_path = get_script_urlpath(); | |
9 | $redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path; | |
10 | ||
11 | if (SINGLE_USER_MODE) { | |
12 | header("Location: $redirect_base/tt-rss.php"); | |
13 | exit; | |
14 | } | |
15 | ||
16 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
17 | ||
18 | $login = $_POST["login"]; | |
19 | $password = $_POST["password"]; | |
20 | $return_to = $_POST["rt"]; | |
21 | ||
3dd46f19 | 22 | if ($_COOKIE[get_session_cookie_name()]) { |
0d3adafe AD |
23 | require_once "../sessions.php"; |
24 | if ($_SESSION["uid"]) { | |
25 | initialize_user_prefs($link, $_SESSION["uid"]); | |
26 | header("Location: $redirect_base/tt-rss.php"); | |
27 | exit; | |
28 | } | |
29 | } | |
30 | ||
31 | if ($login && $password) { | |
32 | ||
33 | if ($_POST["remember_me"]) { | |
34 | session_set_cookie_params(SESSION_COOKIE_LIFETIME_REMEMBER); | |
35 | } else { | |
36 | session_set_cookie_params(SESSION_COOKIE_LIFETIME); | |
37 | } | |
38 | ||
39 | require_once "../sessions.php"; | |
40 | ||
41 | if (authenticate_user($link, $login, $password)) { | |
42 | initialize_user_prefs($link, $_SESSION["uid"]); | |
43 | ||
44 | if ($_POST["remember_me"]) { | |
45 | $_SESSION["cookie_lifetime"] = time() + SESSION_COOKIE_LIFETIME_REMEMBER; | |
46 | } else { | |
47 | $_SESSION["cookie_lifetime"] = time() + SESSION_COOKIE_LIFETIME; | |
48 | } | |
49 | ||
50 | setcookie("ttrss_cltime", $_SESSION["cookie_lifetime"], | |
51 | $_SESSION["cookie_lifetime"]); | |
52 | ||
53 | if (!$return_to) { | |
54 | $return_to = "tt-rss.php"; | |
55 | } | |
56 | header("Location: $redirect_base/$return_to"); | |
57 | exit; | |
58 | } | |
59 | } | |
60 | ||
61 | ?> | |
62 | <html> | |
63 | <head> | |
64 | <title>Tiny Tiny RSS : Login</title> | |
65 | <link rel="stylesheet" type="text/css" href="mobile.css"> | |
66 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
67 | </head> | |
68 | ||
69 | <body> | |
70 | ||
ab1486d5 AD |
71 | <div id="content"> |
72 | <div id="heading">Tiny Tiny RSS</div> | |
0d3adafe AD |
73 | |
74 | <form action="login.php" method="POST"> | |
ab1486d5 | 75 | <input type="hidden" name="rt" value="<?= $_GET['rt'] ?>"> |
0d3adafe | 76 | |
ab1486d5 AD |
77 | <table> |
78 | <tr><td align='right'>Login:</td><td><input name="login"></td> | |
79 | <tr><td align='right'>Password:</td><td><input type="password" name="password"></tr> | |
0d3adafe | 80 | |
ab1486d5 AD |
81 | <tr><td colspan='2'> |
82 | <input type="submit" class="button" value="Login"> | |
83 | <input type="checkbox" name="remember_me" id="remember_me"> | |
84 | <label for="remember_me">Remember me</label></td></tr> | |
85 | </table> | |
0d3adafe AD |
86 | |
87 | </form> | |
88 | ||
89 | </div> | |
ab1486d5 | 90 | |
0d3adafe AD |
91 | </body> |
92 | </html> | |
93 | ||
94 | <? db_close($link); ?> | |
95 |