summaryrefslogtreecommitdiff
path: root/login.php
blob: eda2ac826a53324f32d9e5c84e70e83c9896f226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?
	session_start();

	require_once "sanity_check.php";
	require_once "version.php"; 
	require_once "config.php";
	require_once "functions.php";

	$url_path = get_script_urlpath();
	$redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path;

	if (SINGLE_USER_MODE) {
		header("Location: $redirect_base/tt-rss.php");
		exit;
	}

	$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);	

	$login = $_POST["login"];
	$password = $_POST["password"];

	if ($login && $password) {
		if (authenticate_user($link, $login, $password)) {
			initialize_user_prefs($link, $_SESSION["uid"]); 
			
			if ($_SESSION["login_redirect"]) {
				$redirect_to = $_SESSION["login_redirect"];
			} else {
				$redirect_to = "tt-rss.php";
			}
			header("Location: $redirect_base/$redirect_to");
		}
	}

	if ($_GET["rt"]) {
		$_SESSION["login_redirect"] = $_GET["rt"];
	}

?>
<html>
<head>
	<title>Tiny Tiny RSS : Login</title>
	<link rel="stylesheet" type="text/css" href="tt-rss.css">
	<!--[if gte IE 5.5000]>
		<script type="text/javascript" src="pngfix.js"></script>
	<![endif]-->
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

<body>

<table width='100%' height='100%' class="loginForm">

	<tr><td align='center' valign='middle'>

	<form action="login.php" method="POST">
	
	<table class="innerLoginForm">

	<tr><td valign="middle" align="center" colspan="2">
		<img src="images/ttrss_logo.png" alt="logo">
	</td></tr>
	
	<tr><td align="right">Login:</td>
		<td><input name="login"></td></tr>
	<tr><td align="right">Password:</td>
		<td><input type="password" name="password"></td></tr>

	<tr><td colspan="2" align="center">
		<input type="submit" class="button" value="Login">
	</td></tr>
	
	</table>
	
	</form>

	</td></tr>
</table>

<? db_close($link); ?>

</body>
</html>