]> git.wh0rd.org - tt-rss.git/blame - login.php
login: exit after redirect
[tt-rss.git] / login.php
CommitLineData
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
AD
9 $url_path = get_script_urlpath();
10 $redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path;
11
4585ff0e 12 if (SINGLE_USER_MODE) {
75836f33 13 header("Location: $redirect_base/tt-rss.php");
4585ff0e
AD
14 exit;
15 }
16
c8437f35
AD
17 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
18
19 $login = $_POST["login"];
20 $password = $_POST["password"];
21
a5ebd1f9
AD
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");
8858b67b 27 exit;
a5ebd1f9
AD
28 }
29 }
30
c8437f35 31 if ($login && $password) {
5ccc1cf5
AD
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
8c453eac 39 require_once "sessions.php";
5ccc1cf5 40
c8437f35 41 if (authenticate_user($link, $login, $password)) {
e6cb77a0 42 initialize_user_prefs($link, $_SESSION["uid"]);
f6d0ab14
AD
43
44 if ($_SESSION["login_redirect"]) {
45 $redirect_to = $_SESSION["login_redirect"];
46 } else {
47 $redirect_to = "tt-rss.php";
48 }
75836f33 49 header("Location: $redirect_base/$redirect_to");
c8437f35
AD
50 }
51 }
46a1969d 52
f6d0ab14
AD
53 if ($_GET["rt"]) {
54 $_SESSION["login_redirect"] = $_GET["rt"];
55 }
56
46a1969d
AD
57?>
58<html>
59<head>
60 <title>Tiny Tiny RSS : Login</title>
61 <link rel="stylesheet" type="text/css" href="tt-rss.css">
62 <!--[if gte IE 5.5000]>
63 <script type="text/javascript" src="pngfix.js"></script>
64 <![endif]-->
65 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
66</head>
67
68<body>
69
70<table width='100%' height='100%' class="loginForm">
71
72 <tr><td align='center' valign='middle'>
747976de
AD
73
74 <form action="login.php" method="POST">
46a1969d
AD
75
76 <table class="innerLoginForm">
77
78 <tr><td valign="middle" align="center" colspan="2">
79 <img src="images/ttrss_logo.png" alt="logo">
80 </td></tr>
81
82 <tr><td align="right">Login:</td>
83 <td><input name="login"></td></tr>
84 <tr><td align="right">Password:</td>
85 <td><input type="password" name="password"></td></tr>
5ccc1cf5
AD
86 <tr><td>&nbsp;</td><td>
87 <input type="checkbox" name="remember_me" id="remember_me">
88 <label for="remember_me">Remember me</label>
89 </td></tr>
c8437f35
AD
90 <tr><td colspan="2" align="center">
91 <input type="submit" class="button" value="Login">
92 </td></tr>
46a1969d 93
747976de
AD
94 </table>
95
96 </form>
46a1969d 97
747976de
AD
98 </td></tr>
99</table>
c8437f35
AD
100
101<? db_close($link); ?>
102
46a1969d
AD
103</body>
104</html>