]>
Commit | Line | Data |
---|---|---|
0d3adafe AD |
1 | <? |
2 | // require_once "sessions.php"; | |
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 | ||
22 | if ($_COOKIE["ttrss_sid"]) { | |
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 | ||
71 | <div class="main"> | |
72 | ||
73 | <h1>Tiny Tiny RSS</h1> | |
74 | ||
75 | <form action="login.php" method="POST"> | |
76 | ||
77 | Login: <input name="login"><br> | |
78 | Password: <input type="password" name="password"><br> | |
79 | ||
80 | <input type="checkbox" name="remember_me" id="remember_me"> | |
81 | <label for="remember_me">Remember me</label><br> | |
82 | ||
83 | <input type="submit" class="button" value="Login"> | |
84 | <input type="hidden" name="rt" value="<?= $_GET['rt'] ?>"> | |
85 | ||
86 | </form> | |
87 | ||
88 | </div> | |
89 | </body> | |
90 | </html> | |
91 | ||
92 | <? db_close($link); ?> | |
93 |