/
codelist.php
57 lines (50 loc) · 1.58 KB
/
codelist.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
<?php
$pageTitle = "SeaAuth - Code Management";
require_once "authlib.php";
require_once "header.php";
if(!hasPerm("codes.list", $user)) {
header('Location: index.php');
die;
}
?>
<main id="content-wrapper" class="container">
<div class="page-header">
<h1>SeaAuth <small>Code Management</small></h1>
</div>
<div class="btn-group">
<a href="code.php" class="btn btn-warning">Add Code</a>
<a href="?di" class="btn btn-warning">Show Inactive</a>
<a href="permlist.php" class="btn btn-warning">Permission List</a>
</div>
<table class="table table-striped table-hover">
<?php
//Get Columns
$cols = array("codename", "username", "perms");
//Get fields
$col_ss = implode(", ", $cols) . ", userID";
$joinType = (isset($_GET['di']) && hasPerm("codes.inactive", $user) ? "left" : "") . " join";
$cmd = $conn->prepare("select $col_ss from $codeTable
$joinType $userTable using(userID)");
$cmd->execute();
$results = $cmd->fetchAll();
//Print out our table
echo "<thead><tr>";
foreach($cols as $col) {
echo "<th>$col</th>";
}
echo "<th>Edit</th><th>Delete</th></tr></thead><tbody>";
foreach($results as $row) {
$ccode = base64_encode($row['codename']);
echo "<tr>";
foreach($cols as $col) {
$val = strlen($row[$col]) > 47 ? substr($row[$col], 0, 47) . "..." : $row[$col];
echo "<td>$val</td>";
}
echo "<td><a href='code.php?ccode=$ccode'>Edit</a></td>";
echo "<td><a href='delete-code.php?ccode=$ccode' onclick='return confirm(\"Are you sure?\");'>X</a></td></tr>";
}
echo "</tbody>";
?>
</table>
</main>
<?php require_once "footer.php"; ?>