This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
dashboard.php
128 lines (126 loc) · 4.29 KB
/
dashboard.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
session_start();
if(!isset($_SESSION['username'])){
header("Location: index.php");
}
include('libs/db/db.php');
include('config.php');
include('functions.php');
$data = new JSONDatabase($config['db'], $config['db_location']);
?>
<html>
<?php include('head.php'); ?>
<!-- Dashboard show -->
<body>
<div class="container-fluid">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="./">Mail-In-A-Box Account Management</a>
</div>
<ul class="nav navbar-nav">
<li><a href="#">Welcome, <?php echo $_SESSION['username'];?>!</a></li>
<li><a href="aliases.php"><i class="fa fa-person"></i> Aliases</a></li>
<li><a href="logout.php"><i class="fa fa-person"></i> Logout</a></li>
</ul>
</div>
</nav>
</div>
<div class="container">
<div class="row">
<?php
if(isset($_SESSION['msg'])){
echo '<div class="alert alert-danger">'.$_SESSION['msg'].'</div>';
$_SESSION['msg'] = null;
unset($_SESSION['msg']);
}
if(isset($_SESSION['good'])){
echo '<div class="alert alert-success">'.$_SESSION['good'].'</div>';
$_SESSION['good'] = null;
unset($_SESSION['good']);
}
?>
<div class="col-md-8">
<div class="page-header">
<h2>Current Users</h2>
</div>
<table class="table table-striped">
<thead>
<tr><th>Name</th><th>Account Type</th><th>Options</th></tr>
</thead>
<tbody>
<?php
$users = getUsers();
$aliases = getAliases();
$noDel = false;
if(count($users) == 1){
$noDel = true;
}
foreach($users as $user){
$uType = "User";
$userAliases = '';
if($user['status'] != "active"){
$bForm = '<form action="api.php" method="POST">
<input type="hidden" name="t" value="restore">
<input type="hidden" name="userName" value="'.$user['email'].'">
<button class="btn btn-success btn-sm" type="submit">Restore User</button>
</form>';
} else {
$bForm = '<form action="api.php" method="POST">
<input type="hidden" name="t" value="archive">
<input type="hidden" name="email" value="'.$user['email'].'">
<button class="btn btn-danger btn-sm" type="submit">Delete User</button>
</form>';
}
foreach($aliases as $alias){
if(in_array($user['email'],$alias['forwards_to'])){
$userAliases .= "<li>".$alias['address']."</li>";
}
}
if(!empty($user['privileges'])){
$uType = "Admin";
}
echo '<tr><td>'.$user['email'].'<br>
<ul>
'.$userAliases.'
</ul>
</td><td>'.$uType.'</td><td>';if(!$noDel){ echo $bForm; }echo '</td></tr>';
}
?>
</tbody>
</table>
</div>
<div class="col-md-4">
<div class="row">
<div class="page-header">
<h2>Make New User</h2>
</div>
<form action="api.php" method="POST">
<input type="hidden" name="t" value="new">
<div class="input-group">
<input class="form-control" type="text" name="userName" placeholder="Username (Max 32. Char.)" maxlength="32"><span class="input-group-addon">@<?php echo $_SESSION['domain'];?></span><br>
</div><br>
<input class="form-control" type="password" name="userPass" placeholder="Su73rSt40ngP@ssW0rD"><br>
<button class="btn btn-primary pull-right" type="submit" name="submit">Add Account</button>
</form>
</div>
<div class="row">
<div class="page-header">
<h3>Change Dashboard Password</h3>
</div>
<form action="api.php" method="POST">
<input type="hidden" name="t" value="password">
<div class="input-group">
<input class="form-control" type="password" name="old" placeholder="Old Password">
</div><br>
<input class="form-control" type="password" name="password1" placeholder="New Password"><br>
<input class="form-control" type="password" name="password2" placeholder="New Password (Repeat)"><br>
<button class="btn btn-primary pull-right" type="submit" name="submit">Submit</button>
</form>
</div>
</div>
</div>
</div>
<?php include('foot.php'); ?>
</body>
</html>