]>
Commit | Line | Data |
---|---|---|
46a1969d | 1 | <? |
5ccc1cf5 | 2 | // require_once "sessions.php"; |
46a1969d | 3 | |
66581886 | 4 | require_once "sanity_check.php"; |
46a1969d AD |
5 | require_once "version.php"; |
6 | require_once "config.php"; | |
c8437f35 | 7 | require_once "functions.php"; |
46a1969d | 8 | |
75836f33 | 9 | $url_path = get_script_urlpath(); |
3a82bc60 AD |
10 | |
11 | if (ENABLE_LOGIN_SSL) { | |
12 | $redirect_base = "https://" . $_SERVER["SERVER_NAME"] . $url_path; | |
13 | } else { | |
14 | $redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path; | |
15 | } | |
75836f33 | 16 | |
4585ff0e | 17 | if (SINGLE_USER_MODE) { |
75836f33 | 18 | header("Location: $redirect_base/tt-rss.php"); |
4585ff0e AD |
19 | exit; |
20 | } | |
21 | ||
c8437f35 AD |
22 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
23 | ||
24 | $login = $_POST["login"]; | |
25 | $password = $_POST["password"]; | |
1f0d3e07 | 26 | $return_to = $_POST["rt"]; |
c8437f35 | 27 | |
3dd46f19 | 28 | if ($_COOKIE[get_session_cookie_name()]) { |
a5ebd1f9 AD |
29 | require_once "sessions.php"; |
30 | if ($_SESSION["uid"]) { | |
31 | initialize_user_prefs($link, $_SESSION["uid"]); | |
32 | header("Location: $redirect_base/tt-rss.php"); | |
8858b67b | 33 | exit; |
a5ebd1f9 AD |
34 | } |
35 | } | |
36 | ||
c8437f35 | 37 | if ($login && $password) { |
5ccc1cf5 AD |
38 | |
39 | if ($_POST["remember_me"]) { | |
40 | session_set_cookie_params(SESSION_COOKIE_LIFETIME_REMEMBER); | |
41 | } else { | |
42 | session_set_cookie_params(SESSION_COOKIE_LIFETIME); | |
43 | } | |
44 | ||
8c453eac | 45 | require_once "sessions.php"; |
5ccc1cf5 | 46 | |
c8437f35 | 47 | if (authenticate_user($link, $login, $password)) { |
e6cb77a0 | 48 | initialize_user_prefs($link, $_SESSION["uid"]); |
76b4eae1 AD |
49 | |
50 | if ($_POST["remember_me"]) { | |
51 | $_SESSION["cookie_lifetime"] = time() + SESSION_COOKIE_LIFETIME_REMEMBER; | |
52 | } else { | |
53 | $_SESSION["cookie_lifetime"] = time() + SESSION_COOKIE_LIFETIME; | |
54 | } | |
55 | ||
56 | setcookie("ttrss_cltime", $_SESSION["cookie_lifetime"], | |
57 | $_SESSION["cookie_lifetime"]); | |
58 | ||
1f0d3e07 AD |
59 | if (!$return_to) { |
60 | $return_to = "tt-rss.php"; | |
f6d0ab14 | 61 | } |
1f0d3e07 | 62 | header("Location: $redirect_base/$return_to"); |
ab9ecc04 | 63 | exit; |
c8437f35 AD |
64 | } |
65 | } | |
46a1969d AD |
66 | |
67 | ?> | |
68 | <html> | |
69 | <head> | |
70 | <title>Tiny Tiny RSS : Login</title> | |
71 | <link rel="stylesheet" type="text/css" href="tt-rss.css"> | |
72 | <!--[if gte IE 5.5000]> | |
73 | <script type="text/javascript" src="pngfix.js"></script> | |
74 | <![endif]--> | |
75 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
76 | </head> | |
77 | ||
78 | <body> | |
79 | ||
a1b48fd7 AD |
80 | <script type="text/javascript"> |
81 | function init() { | |
82 | ||
83 | if (arguments.callee.done) return; | |
84 | arguments.callee.done = true; | |
85 | ||
86 | var login = document.forms["loginForm"].login; | |
87 | ||
88 | login.focus(); | |
89 | ||
90 | } | |
91 | </script> | |
92 | ||
93 | <script type="text/javascript"> | |
94 | if (document.addEventListener) { | |
95 | document.addEventListener("DOMContentLoaded", init, null); | |
96 | } | |
97 | window.onload = init; | |
98 | </script> | |
99 | ||
46a1969d AD |
100 | <table width='100%' height='100%' class="loginForm"> |
101 | ||
102 | <tr><td align='center' valign='middle'> | |
747976de | 103 | |
a1b48fd7 | 104 | <form action="login.php" method="POST" name="loginForm"> |
46a1969d AD |
105 | |
106 | <table class="innerLoginForm"> | |
107 | ||
108 | <tr><td valign="middle" align="center" colspan="2"> | |
109 | <img src="images/ttrss_logo.png" alt="logo"> | |
110 | </td></tr> | |
111 | ||
112 | <tr><td align="right">Login:</td> | |
113 | <td><input name="login"></td></tr> | |
114 | <tr><td align="right">Password:</td> | |
115 | <td><input type="password" name="password"></td></tr> | |
5ccc1cf5 AD |
116 | <tr><td> </td><td> |
117 | <input type="checkbox" name="remember_me" id="remember_me"> | |
118 | <label for="remember_me">Remember me</label> | |
119 | </td></tr> | |
c8437f35 AD |
120 | <tr><td colspan="2" align="center"> |
121 | <input type="submit" class="button" value="Login"> | |
1f0d3e07 | 122 | <input type="hidden" name="rt" value="<?= $_GET['rt'] ?>"> |
c8437f35 | 123 | </td></tr> |
46a1969d | 124 | |
747976de AD |
125 | </table> |
126 | ||
127 | </form> | |
46a1969d | 128 | |
747976de AD |
129 | </td></tr> |
130 | </table> | |
c8437f35 AD |
131 | |
132 | <? db_close($link); ?> | |
133 | ||
a1b48fd7 AD |
134 | <script type="text/javascript"> |
135 | /* for IE */ | |
136 | function statechange() { | |
137 | if (document.readyState == "interactive") init(); | |
138 | } | |
139 | ||
140 | if (document.readyState) { | |
141 | if (document.readyState == "interactive" || document.readyState == "complete") { | |
142 | init(); | |
143 | } else { | |
144 | document.onreadystatechange = statechange; | |
145 | } | |
146 | } | |
147 | </script> | |
148 | ||
46a1969d AD |
149 | </body> |
150 | </html> |