-
Notifications
You must be signed in to change notification settings - Fork 0
/
permissions.php
executable file
·79 lines (62 loc) · 3.28 KB
/
permissions.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
<?php
include "./config.php"; // Import the configuration library.
include "./database.php"; // Import the database library.
include "./utils.php"; // Import the utils library.
$admin_only = true;
include "./authentication.php"; // Import the authentication library.
// Get autofill information from the URL, if it exists.
$autouser = $_GET["autouser"];
$automaxitems = $_GET["automaxitems"];
// Sanitize the information from the URL.
if ($autouser != filter_var($autouser, FILTER_SANITIZE_STRING)) { echo "<p>Autofill manipulation detected.</p>"; exit(); } // Sanitize the 'username' input.
$automaxitems = intval($automaxitems);
// Get the inputs from the form data, if it exists.
$user = $_POST["user"];
$max_items = $_POST["maxitems"];
// Sanitize inputs.
if ($user != filter_var($user, FILTER_SANITIZE_STRING)) { echo "<p>Form manipulation detected.</p>"; exit(); } // Sanitize the 'username' input.
$max_items = intval($max_items); if ($max_items < 0) { echo "<p>Form manipulation detected</p>"; exit(); } // Sanitize the 'max items' input.
// Process any form input information.
if ($user != null and $user != "") { // Check to see if information was input through the form.
$item_database[$user]["permissions"]["maxitems"] = $max_items;
save_database($config["database_location"], $item_database, $config); // Save database changes to the disk.
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $config["instance_name"]; ?> - Permissions</title>
<link rel="stylesheet" type="text/css" href="./styles/main.css">
<link rel="stylesheet" type="text/css" href="./styles/themes/<?php echo $config["theme"]; ?>.css">
</head>
<body>
<div class="button-container">
<a class="button" href="./tools.php">Back</a>
</div>
<form method="POST">
<label for="user">User: </label><input id="user" name="user" type="text" value="<?php echo $autouser; ?>" placeholder="Username">
<br><br>
<label for="maxitems">Max Items: </label><input id="maxitems" name="maxitems" type="number" step="1" min="0" value="<?php echo $automaxitems; ?>" placeholder="1000 items">
<br><br>
<input type="submit" value="Submit">
<div class="new-item">
<?php
foreach ($item_database as $database_user => $user_information) {
if ($database_user != null and $database_user != "") { // Check to make sure this user from the database is a valid user. This is designed to filter out broken information from improper database migration.
$user_max_items = round(intval($item_database[$database_user]["permissions"]["maxitems"]));
echo "<p><a href='?autouser=" . $database_user . "&automaxitems=" . $user_max_items . "'>" . $database_user . "</a> - ";
if ($user_max_items == 0) {
echo "default";
} else {
echo $user_max_items;
}
echo " max items</p>";
}
}
?>
</div>
</form>
</body>
</html>