-
Notifications
You must be signed in to change notification settings - Fork 4
/
login.php
70 lines (64 loc) · 2.44 KB
/
login.php
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
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
require_once("php/configuration.php");
include_once "php/constants.php";
include_once "php/functions.php";
ensureDefaultUser();
if (isset($_POST['userMail']) && isset($_POST['password'])) {
switch ($_POST['submitType']) {
case "login":
loginUser($_POST['userMail'], $_POST['password']);
break;
case "register":
registerUser($_POST['userMail'], $_POST['password']);
die("registration disabled");
break;
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Annotation Interface -- Login</title>
<link href="css/login.css" rel="stylesheet" />
<script defer src="plugins/fontawesome-all.min.js"></script>
<?php if (isset($_SESSION['user']) && isset($_SESSION['admin'])) { ?>
<meta http-equiv="refresh">
<script language="javascript">
window.location.href = "index.php"
</script>
<?php } ?>
</head>
<body>
<?php if (!isset($_SESSION['loggedIn'])) { ?>
<section class="loginForm cf">
<form id="form" name="login" method="post" accept-charset="utf-8">
<ul>
<li><label for="userMail">Email</label>
<input id="userMail" type="text" name="userMail" placeholder="username" value="<?= isset($_POST['userMail']) ? $_POST['userMail'] : "" ?>" required /></li>
<li><label for="password">Password</label>
<input id="password" type="password" name="password" placeholder="password" required <?php if (isset($_POST['userMail'])) echo 'class="invalid"' ?> /></li>
<li><input id="submitType" type="hidden" name="submitType"/> </li>
<li><input type="submit" value="Login" onclick="(function() {
document.getElementById('submitType').value='login';
})()" /></li>
<?php
// <li><input type="submit" value="Create Account" onclick="(function() {
// document.getElementById('submitType').value='register';
// })()" /></li>
?>
</ul>
</form>
</section>
<?php
if (Configuration::instance()->get("misc", "showinfo") == 1) {
include("blocks/info.php");
}
?>
<?php } else { ?>
<p>Logged in successfully. If you are not redirected automatically, follow the <a href='index.php'>link</a>.</p>
<?php } ?>
</body>