/
admin.php
82 lines (74 loc) · 1.8 KB
/
admin.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
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet prefetch' href='inc/jquery-ui.css'>
<link rel="stylesheet" href="inc/style.css">
</head>
<body>
<?php
if(file_exists("install.php"))
unlink("install.php");
include_once("client_functions.php");
include_once("users.php");
include_once("admin_functions.php");
include_once("list.php");
if (admin_logged_in())
{
if( isset( $_POST['create'] ))
{
echo '<div class="login-card">';
echo "<center>Password : ".create_user()."</center>";
echo '</div>';
direct("admin.php", 3);
}
elseif(isset($_POST['log_out']))
{
session_destroy();
direct('admin.php', 0);
}
elseif(isset($_POST['update_book']))
{
$list = new BookList(get_pathname());
$list->saveList();
echo '<div class="login-card">';
echo "<center>List has been updated.</center>";
echo '</div>';
direct('admin.php', 3);
}
else
{
echo '<div class="login-card">';
echo "<form method='post' action=''>
<input type='submit' name='create' value='Create User' class='login login-submit' />
<br/>
<input type='submit' name='update_book' value='Update List' class='login login-submit' />
<br/>
<input type='submit' name='log_out' value='Logout' class='login login-submit' />
</form>";
echo '</div>';
}
}
else
{
if(isset($_POST['sub']))
{
verify_admin();
direct('admin.php', 0);
}
else
{
echo '<div class="login-card">';
echo '<h1>Admin Panel</h1>';
echo '<form action="" method="post" accept-charset="utf-8">
<input type="text" name="username" id="username" placeholder="Username"> <br/>
<input type="text" name="password" placeholder="Password">
<p><input type="submit" name="sub" value="Login" class="login login-submit"></p>
</form>';
echo '</div>';
}
}
?>
<script src='inc/jquery.min.js'></script>
<script src='inc/jquery-ui.min.js'></script>
</body>
</html>