]> git.wh0rd.org - tt-rss.git/blame - login.php
fix indent
[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();
4724a093 12 $return_to = $_REQUEST["rt"];
3a82bc60
AD
13
14 if (ENABLE_LOGIN_SSL) {
15 $redirect_base = "https://" . $_SERVER["SERVER_NAME"] . $url_path;
16 } else {
17 $redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path;
18 }
75836f33 19
4724a093 20 if (SINGLE_USER_MODE && $return_to != "none") {
75836f33 21 header("Location: $redirect_base/tt-rss.php");
4585ff0e
AD
22 exit;
23 }
24
c8437f35
AD
25 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
26
27 $login = $_POST["login"];
28 $password = $_POST["password"];
1d3a17c7 29 $action = $_POST["action"];
c8437f35 30
4724a093 31 if ($_COOKIE[get_session_cookie_name()] && $return_to != "none") {
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 131 <input type="hidden" name="action" value="login">
4724a093
AD
132 <input type="hidden" name="rt"
133 value="<?php if ($return_to != 'none') { echo $return_to; } ?>">
660c059f
AD
134 </td></tr>
135 </table>
136 </td>
137</tr><tr>
138 <td align="center" class="loginBottom">
17b3e8e6 139 <a href="http://tt-rss.spb.ru/">Tiny Tiny RSS</a> &copy; 2005-2007 <a href="http://bah.org.ru/">Andrew Dolgov</a>
660c059f
AD
140 </td>
141</tr>
142
747976de 143</table>
c8437f35 144
660c059f
AD
145</form>
146
1d3a17c7 147<?php db_close($link); ?>
c8437f35 148
a1b48fd7
AD
149<script type="text/javascript">
150 /* for IE */
151 function statechange() {
152 if (document.readyState == "interactive") init();
153 }
154
155 if (document.readyState) {
156 if (document.readyState == "interactive" || document.readyState == "complete") {
157 init();
158 } else {
159 document.onreadystatechange = statechange;
160 }
161 }
162</script>
163
46a1969d
AD
164</body>
165</html>