summaryrefslogtreecommitdiff
path: root/code/admin/auth.php
blob: f4afee07336913e87d133f4c7540c11e953975d0 (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
<?php
	// Edit secrets here
	$configured_user = 'admin';
	$configured_pass = 'admin';

	// Auth validation
	$auth_fail=FALSE;
	if ( array_key_exists('u', $_POST) && array_key_exists('p', $_POST) ) {
		if ( $_POST['u'] === $configured_user && $_POST['p'] === $configured_pass ) {
			// Auth success
			session_start();
			$_SESSION['auth_user'] = TRUE;
			// Auto-redirect to previous page
			if ( array_key_exists('auth_return', $_SESSION) && (strlen($_SESSION['auth_return']) > 0) ) {
				header('Location: ' . $_SESSION['auth_return']);
			}
			echo "Authenticated\n";
			exit();
		} else {
			$auth_fail=TRUE;
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Authentification</title>
</head>
<body>
<form method="post">
	<fieldset style="float:left">
		<legend>Authentification</legend>
		<table>
			<tr>
				<td><label>User</label></td>
				<td><input type="text" name="u" value="admin"></td>
			</tr>
			<tr>
				<td><label>Pass</label></td>
				<td><input type="password" name="p" value="admin"></td>
			</tr>
			<tr>
				<td colspan="2" align="right">
					<span><?php if ($auth_fail) echo "Login failed";?></span>
					<input type="submit" value="Login">
				</td>
			</tr>
		</table>
	</fieldset>
</form>
</body>
</html>