This repository has been archived by the owner on Oct 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
login.php
112 lines (104 loc) · 3.42 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
session_start();
error_reporting(0);
require 'resources/secret/config.php';
require 'resources/php/functions.php';
require 'resources/php/markdown.php';
$db = new mysqli($db_host, $db_user, $db_pass, $db_database);
if ($db->connect_errno) {
printf("Connect failed: %s\n", $db->connect_error);
exit();
}
if(isset($_SESSION['username'])) { // User has logged in
if (isset($_REQUEST['logout'])) {
$_SESSION = array();
session_destroy();
}
header('Location: index.php');
} else {
if ($use_native_login == false) {
header('Location: '. $non_native_login_url);
}
}
if ($_POST){
$formUsername = $_POST['username'];
$formPW = sha1($_POST['password']);
$user_result=$db->query("SELECT * FROM user WHERE user_username = '$formUsername' AND password = '$formPW' LIMIT 1");
if(($user_result) && ($user_result->num_rows > 0)) {
$_SESSION['username'] = $formUsername;
header('Location: index.php');
} else {
$m = "Your username or password was incorrect.<br> Please try again.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $library_name; ?> Status</title>
<style>
@font-face {
font-family: 'AlternateGothicFSNo3';
src: url('//gvsuliblabs.com/libs/fonts/AlternateGothicNo3-webfont.eot');
src: url('//gvsuliblabs.com/libs/fonts/AlternateGothicNo3-webfont.eot?#iefix') format('embedded-opentype'),
url('//gvsuliblabs.com/libs/fonts/AlternateGothicNo3-webfont.woff') format('woff'),
url('//gvsuliblabs.com/libs/fonts/AlternateGothicNo3-webfont.ttf') format('truetype'),
url('//gvsuliblabs.com/libs/fonts/AlternateGothicNo3-webfont.svg#AlternateGothicFSNo3') format('svg');
font-weight: normal;
font-style: normal;
}
</style>
<link rel="stylesheet" type="text/css" href="resources/css/styles.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/layout.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="header-wrapper" style="<?php echo 'background-color:' . $banner_color . ';'; ?>">
<div id="header">
<div id="logo">
<a href="<?php echo $header_url; ?>">
<img src="<?php echo $header_image; ?>" alt="<?php echo $library_name; ?>" border="0">
</a>
</div>
</div>
</div>
<div id="wrapper">
<div class="line break">
<div class="span2 unit left">
<h1>Login to <?php echo $library_name;?> Status</h1>
<?php
if(isset($m)) {
echo '<div class="lib-error">' . $m . '</div>';
}
?>
<form class="lib-form" action="login.php" method="POST">
<div class="line">
<div class="left span2 unit">
<label for="username">Username</label>
<input name="username" type="text"/>
</div>
</div>
<div class="line">
<div class="left span2 unit">
<label for="password">Password</label>
<input name="password" id="password" type="password"/>
<label for="show">Show Password?</label>
<input name="show" id="show" type="checkbox">
</div>
</div>
<div class="line">
<div class="left span2 unit" style="padding-top: 10px">
<input class="lib-button-small" name="post" type="submit" value="Login" />
</div>
</div>
</div> <!-- end span -->
</div> <!-- end line -->
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
jQuery("#show").click(function(){
jQuery("#password").prop('type', this.checked ? 'text' : 'password');
});
</script>
</body>
</html>