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