]> git.wh0rd.org - tt-rss.git/blame - login.php
set redirect_base to https:// prefix when ENABLE_LOGIN_SSL is enabled (closes #71)
[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 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
80<table width='100%' height='100%' class="loginForm">
81
82 <tr><td align='center' valign='middle'>
747976de
AD
83
84 <form action="login.php" method="POST">
46a1969d
AD
85
86 <table class="innerLoginForm">
87
88 <tr><td valign="middle" align="center" colspan="2">
89 <img src="images/ttrss_logo.png" alt="logo">
90 </td></tr>
91
92 <tr><td align="right">Login:</td>
93 <td><input name="login"></td></tr>
94 <tr><td align="right">Password:</td>
95 <td><input type="password" name="password"></td></tr>
5ccc1cf5
AD
96 <tr><td>&nbsp;</td><td>
97 <input type="checkbox" name="remember_me" id="remember_me">
98 <label for="remember_me">Remember me</label>
99 </td></tr>
c8437f35
AD
100 <tr><td colspan="2" align="center">
101 <input type="submit" class="button" value="Login">
1f0d3e07 102 <input type="hidden" name="rt" value="<?= $_GET['rt'] ?>">
c8437f35 103 </td></tr>
46a1969d 104
747976de
AD
105 </table>
106
107 </form>
46a1969d 108
747976de
AD
109 </td></tr>
110</table>
c8437f35
AD
111
112<? db_close($link); ?>
113
46a1969d
AD
114</body>
115</html>