-
Notifications
You must be signed in to change notification settings - Fork 0
/
preferences.php
68 lines (59 loc) · 3.57 KB
/
preferences.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
<?php
include "auth.php";
if (authMain() != "admin") {
die("You do not have the adequate credentials to view this page.");
}
?>
<html>
<head>
<title>TR37 Tree Lot | Website Preferences</title>
<link rel="icon" href="favicon.png">
<style>
th, td {border:1px solid grey; text-align:center;}
body {text-align:center;font-family:"Arial";}
</style>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?change" method="post">
<h2>Website Preferences</h2>
<p>Site-wide preferences. Warning: don't mess with this unless you know what you're doing.</p><br />
<?php
$dtsin = json_decode(file_get_contents("resetDates.json"));
$prefs = json_decode(file_get_contents('preferences.json'), true);
?>
<a><b>Expand shifts to three slots </b><i>(default: always)</i>: </a>
<input type="radio" id="expand_shifts" name="expand_shifts" value="always" <?php echo $prefs["expand"] === "always" ? 'checked="checked"' : ""; ?> required>Always</input>
<input type="radio" id="expand_shifts" name="expand_shifts" value="weekends" <?php echo $prefs["expand"] === "weekends" ? 'checked="checked"' : ""; ?>>Weekends</input>
<input type="radio" id="expand_shifts" name="expand_shifts" value="never" <?php echo $prefs["expand"] === "never" ? 'checked="checked"' : ""; ?>>Never</input><br />
<a>(each time slot will have three shift slots instead of two)</a><br /><br />
<a><b>Enable deletion requests </b><i>(default: yes)</i>: </a>
<input type="radio" id="request_delete" name="request_delete" value="true" <?php echo $prefs["requests"] === "true" ? 'checked="checked"' : ""; ?> required>Yes</input>
<input type="radio" id="request_delete" name="request_delete" value="false" <?php echo $prefs["requests"] === "false" ? 'checked="checked"' : ""; ?>>No</input><br />
<a>(shift deletions must be approved by an admin)</a><br /><br />
<a><b>Enable comments </b><i>(default: yes)</i>: </a>
<input type="radio" id="comments" name="comments" value="true" <?php echo $prefs["comments"] === "true" ? 'checked="checked"' : ""; ?> required>Yes</input>
<input type="radio" id="comments" name="comments" value="false" <?php echo $prefs["comments"] === "false" ? 'checked="checked"' : ""; ?>>No</input><br />
<a>(comments will be displayed at the top of the main page)</a><br /><br />
<a><b>Enable lot setup shifts </b><i>(default: no)</i>: </a>
<input type="radio" id="setup_shifts" name="setup_shifts" value="true" <?php echo $prefs["setup"] === "true" ? 'checked="checked"' : ""; ?> required>Yes</input>
<input type="radio" id="setup_shifts" name="setup_shifts" value="false" <?php echo $prefs["setup"] === "false" ? 'checked="checked"' : ""; ?>>No</input><br />
<a>(users will not be able to sign up for shifts during tree recieving)</a><br /><br />
<a><b>Put site into Maintenance Mode </b><i>(default: no)</i>: </a>
<input type="radio" id="maintenance" name="maintenance" value="true" <?php echo $prefs["maintenance"] === "true" ? 'checked="checked"' : ""; ?> required>Yes</input>
<input type="radio" id="maintenance" name="maintenance" value="false" <?php echo $prefs["maintenance"] === "false" ? 'checked="checked"' : ""; ?>>No</input><br />
<a>(signups are disabled to use or access)</a><br /><br />
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
if(isset($_GET["change"])) {
file_put_contents("preferences.json", json_encode(array(
"expand" => $_POST["expand_shifts"],
"requests" => $_POST["request_delete"],
"comments" => $_POST["comments"],
"setup" => $_POST["setup_shifts"],
"maintenance" => $_POST["maintenance"]), JSON_PRETTY_PRINT));
echo 'Site-wide preferences changed successfully';
}
?>