-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
executable file
·67 lines (54 loc) · 1.67 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
<?php // Login page
// Session start
require_once "lib/Auth/core.php";
$bad_login = 0;
// Prevent logged in users from acessing the page.
if (isset($_SESSION["username"]))
{
redirect();
exit();
}
// Check if form has been filled out.
if (isset($_POST['username']) && isset($_POST['password']))
{
$_POST["username"] = strtolower($_POST["username"]);
if (authenticate($_POST['username'],$_POST['password']))
{
$_SESSION["username"] = $_POST["username"];
$_SESSION["displayname"] = getDisplayname($_POST["username"]);
$_SESSION["admin"] = isAdmin($_POST["username"]);
// Redirect away from login page
redirect();
exit();
}
else
{
$bad_login = 1;
}
}
// Requirements
require_once "./lib/headder.php";
// CONTENT
echo("<div id='content'>");
?>
<div id="logincontent">
<div class="post" >
<div class="headder">
<h4 class="center"> Login </h4>
</div>
<div class="content">
<form method="post" action="login.php" onsubmit="validate(this)" name="login"><pre>
<label> Username </label> <input type="text" name="username" required />
<label> Password </label> <input type="password" name="password" required />
<input type="submit" value="Sign In"/>
</pre></form>
<?php if($bad_login) echo('<span class="red-text"> Invalid Username or Password <span>'); ?>
</div>
</div>
</div>
<?php
echo("</div>");
// END OF CONTENT
// Footer contents and closing.
require_once "lib/footer.php";
?>