]> git.wh0rd.org - tt-rss.git/blame - login.php
default theme updates
[tt-rss.git] / login.php
CommitLineData
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">
375a346d 79 <link rel="shortcut icon" type="image/png" href="images/favicon.png">
46a1969d
AD
80 <!--[if gte IE 5.5000]>
81 <script type="text/javascript" src="pngfix.js"></script>
82 <![endif]-->
83 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
84</head>
85
86<body>
87
a1b48fd7
AD
88<script type="text/javascript">
89function init() {
90
91 if (arguments.callee.done) return;
92 arguments.callee.done = true;
93
94 var login = document.forms["loginForm"].login;
95
96 login.focus();
97
98}
99</script>
100
101<script type="text/javascript">
102if (document.addEventListener) {
103 document.addEventListener("DOMContentLoaded", init, null);
104}
105window.onload = init;
106</script>
107
660c059f
AD
108<form action="login.php" method="POST" name="loginForm">
109
110<table width="100%" class="loginForm2">
111<tr>
112 <td class="loginTop" valign="bottom" align="left">
113 <img src="images/ttrss_logo_big.png" alt="Logo">
114 </td>
115</tr><tr>
116 <td align="center" valign="middle" class="loginMiddle" height="100%">
1d3a17c7
AD
117 <?php if ($error_msg) { ?>
118 <div class="loginError"><?php echo $error_msg ?></div>
119 <?php } ?>
660c059f
AD
120 <table>
121 <tr><td align="right">Login:</td>
104ddfe0 122 <td align="right"><input name="login"></td></tr>
660c059f 123 <tr><td align="right">Password:</td>
104ddfe0 124 <td align="right"><input type="password" name="password"></td></tr>
660c059f
AD
125 <tr><td colspan="2">
126 <input type="checkbox" name="remember_me" id="remember_me">
127 <label for="remember_me">Remember me on this computer</label>
128 </td></tr>
104ddfe0 129 <tr><td colspan="2" align="right" class="innerLoginCell">
660c059f 130 <input type="submit" class="button" value="Login">
1d3a17c7
AD
131 <input type="hidden" name="action" value="login">
132 <input type="hidden" name="rt" value="<?php echo $_GET['rt'] ?>">
660c059f
AD
133 </td></tr>
134 </table>
135 </td>
136</tr><tr>
137 <td align="center" class="loginBottom">
52db9978 138 <a href="http://tt-rss.spb.ru/">Tiny Tiny RSS</a> &copy; 2005-2006 Andrew Dolgov
1d3a17c7 139 <?php if (WEB_DEMO_MODE) { ?>
660c059f 140 <br>Running in demo mode, some functionality is disabled.
1d3a17c7 141 <?php } ?>
660c059f
AD
142 </td>
143</tr>
144
747976de 145</table>
c8437f35 146
660c059f
AD
147</form>
148
1d3a17c7 149<?php db_close($link); ?>
c8437f35 150
a1b48fd7
AD
151<script type="text/javascript">
152 /* for IE */
153 function statechange() {
154 if (document.readyState == "interactive") init();
155 }
156
157 if (document.readyState) {
158 if (document.readyState == "interactive" || document.readyState == "complete") {
159 init();
160 } else {
161 document.onreadystatechange = statechange;
162 }
163 }
164</script>
165
46a1969d
AD
166</body>
167</html>