]>
Commit | Line | Data |
---|---|---|
ee8927ad VP |
1 | <?php |
2 | require_once "../inc/common.php"; | |
3 | require_once "../inc/header.php"; | |
4 | ||
5 | $canEdit = current_user_can(PERMISSION_MANAGE_USERS); | |
6 | function _ce($can){ | |
7 | echo ($can) ? "" : "disabled"; | |
8 | } | |
f2e07243 VP |
9 | if (isset($_POST['submit']) && $canEdit) |
10 | { | |
3d4e4ec4 VP |
11 | $hibp = (!isset($config['hibp']) || $config['hibp']) ? true : false; |
12 | $config['hibp'] = isset($_POST['hibp']) ? true : false; | |
13 | if ($config['hibp'] != $hibp) // we just toggled | |
14 | Message::Info("Checking passwords against data breaches is now is now ".(($config['hibp']) ? "enabled" : "disabled")); | |
15 | ||
f2e07243 | 16 | $dbug = (isset($config['debug']) && $config['debug']) ? true : false; |
3d4e4ec4 | 17 | $config['debug'] = isset($_POST['debug_mode']) ? true : false; |
f2e07243 VP |
18 | if ($config['debug'] != $dbug) // we just toggled |
19 | Message::Info("Debug Mode is now ".(($config['debug']) ? "enabled" : "disabled")); | |
3d4e4ec4 | 20 | |
452b8ead VP |
21 | |
22 | if (!empty($_FILES['customFile'])) | |
23 | { | |
24 | $cwd = getcwd(); | |
25 | $a = split($cwd,'/'); | |
26 | $a[sizeof($a) - 1] = NULL; | |
27 | $cwd = glue($a,'/'); | |
28 | $target_dir = "$cwd/img/"; | |
29 | $target_file = "/$target_dir/wallpaper.jpg"; | |
30 | $uploadOk = 1; | |
31 | $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); | |
32 | $check = getimagesize($_FILES["customFile"]["tmp_name"]); | |
33 | $errs = []; | |
34 | ||
35 | if($check == false) | |
36 | { | |
37 | $errs[] = "File is not an image."; | |
38 | $uploadOk = 0; | |
39 | } | |
40 | else if ($_FILES["customFile"]["size"] > 500000) { | |
41 | $errs[] = "File is too large."; | |
42 | $uploadOk = 0; | |
43 | } | |
44 | elseif($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" | |
45 | && $imageFileType != "gif" ) | |
46 | { | |
47 | $errs[] = "Only JPG, JPEG, PNG & GIF files are allowed."; | |
48 | $uploadOk = 0; | |
49 | } | |
50 | if ($uploadOk != 0) { | |
51 | if (file_exists($target_file)) | |
52 | unlink($target_file); | |
53 | move_uploaded_file($_FILES["customFile"]["tmp_name"], $target_file); | |
54 | Message::Success("Updloaded file: $target_file"); | |
55 | } | |
56 | else Message::Fail($errs); | |
57 | } | |
58 | ||
f2e07243 | 59 | write_config(); |
3d4e4ec4 | 60 | unset($_POST['debug'], $_POST['submit'], $_POST['hibp']); |
f2e07243 VP |
61 | Hook::run(HOOKTYPE_GENERAL_SETTINGS_POST, $_POST); |
62 | } | |
ee8927ad | 63 | |
f2e07243 | 64 | do_log("\$_POST", $_POST); |
452b8ead | 65 | do_log("\$_FILES", $_FILES); |
ee8927ad VP |
66 | ?> |
67 | <h4>General Settings</h4> | |
68 | <br> | |
452b8ead | 69 | <form method="post" enctype="multipart/form-data"> |
3d4e4ec4 VP |
70 | <div class="card m-1" style="padding-left:20px;padding-right:20px;padding-top:5px;padding-bottom:10px;max-width:fit-content"> |
71 | <h6>Password Data Leak Checks</h6> | |
72 | <div class="custom-control custom-switch"> | |
73 | <input name="hibp" type="checkbox" class="custom-control-input" id="hibp" <?php _ce($canEdit); echo (!isset($config['hibp']) || $config['hibp'] == true) ? " checked" : ""; ?>> | |
74 | <label class="custom-control-label" for="hibp">Checks a users password on login against known data leaks (<a href="https://haveibeenpwned.com">Have I Been Pwned</a>)</label> | |
75 | </div> | |
76 | <i>This check is made everytime someone successfully logs into the webpanel or when they update their password.</i> | |
77 | </div> | |
78 | <div class="card m-1" style="padding-left:20px;padding-right:20px;padding-top:5px;padding-bottom:10px;max-width:fit-content"> | |
f2e07243 VP |
79 | <h6>Debug Mode</h6> |
80 | <div class="custom-control custom-switch"> | |
81 | <input name="debug_mode" type="checkbox" class="custom-control-input" id="debug_mode" <?php _ce($canEdit); echo ($config['debug'] == true) ? " checked" : ""; ?>> | |
82 | <label class="custom-control-label" for="debug_mode">Enable Debug Mode (Developers Only)</label> | |
83 | </div> | |
84 | <i>Enabling this will likely make your webpanel more difficult to use</i> | |
ee8927ad | 85 | </div> |
452b8ead VP |
86 | <script> |
87 | const iframe =document.getElementById('frame'); | |
88 | iframe.contentWindow.location.reload(true); | |
89 | </script> | |
ee8927ad | 90 | |
452b8ead VP |
91 | <style> |
92 | #wrap { | |
93 | border: none; | |
94 | padding: 0; | |
95 | margin:0;} | |
96 | #frame { transform:none; zoom: 0.8; -moz-transform: scale(0.8); -moz-transform-origin: 0 0; transform-origin: 3%; border:none;} | |
97 | </style> | |
98 | <div class="card mb-2" style="padding-left:20px;padding-right:20px;padding-top:5px;padding-bottom:10px;max-width:fit-content;max-height:fit-content"> | |
99 | <h6>Overview Background Image</h6> | |
100 | <div class="" id="wrap"> | |
101 | <label class="form-label" for="customFile">Upload an image</label> | |
102 | <input type="file" class="form-control" name="customFile" id="customFile" /> Might not show current image if caching is used. You'll notice the changes soon. | |
103 | ||
104 | <iframe width="100%" height="500vh" id="frame" style="pointer-events: none;position:relative;margin-top:10px" src="<?php echo get_config('base_url'); ?>">Loading Live Preview</iframe> | |
105 | </div> | |
106 | </div> | |
ee8927ad VP |
107 | <?php $a = []; Hook::run(HOOKTYPE_GENERAL_SETTINGS, $a); ?> |
108 | <br><br> | |
f2e07243 VP |
109 | <button type="post" name="submit" class="btn btn-primary">Save</div> |
110 | </form> | |
ee8927ad VP |
111 | <?php |
112 | require_once "../inc/footer.php"; |