]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - settings/general.php
Add start of Notes functionality
[irc/unrealircd/unrealircd-webpanel.git] / settings / general.php
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 }
9 if (isset($_POST['submit']) && $canEdit)
10 {
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
16 $dbug = (isset($config['debug']) && $config['debug']) ? true : false;
17 $config['debug'] = isset($_POST['debug_mode']) ? true : false;
18 if ($config['debug'] != $dbug) // we just toggled
19 Message::Info("Debug Mode is now ".(($config['debug']) ? "enabled" : "disabled"));
20
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
59 write_config();
60 unset($_POST['debug'], $_POST['submit'], $_POST['hibp']);
61 Hook::run(HOOKTYPE_GENERAL_SETTINGS_POST, $_POST);
62 }
63
64 do_log("\$_POST", $_POST);
65 do_log("\$_FILES", $_FILES);
66 ?>
67 <style>
68 .color-circle.selected {
69 border: 2px solid #fff; /* Optional: Add a border to highlight selected option */
70 }
71
72 .color-option input[type="radio"]:checked + .color-circle {
73 border: 2px solid #fff; /* Optional: Add a border to highlight selected option */
74 }
75
76 .color-option .color-circle {
77 width: 30px; /* Adjust size as needed */
78 height: 30px; /* Adjust size as needed */
79 border-radius: 50%; /* Ensure it's circular */
80 }
81
82 @media (max-width: 600px) {
83 .color-option {
84 flex-basis: 50%; /* Two items per row on smaller screens */
85 }
86 }
87
88 @media (max-width: 400px) {
89 .color-option {
90 flex-basis: 100%; /* One item per row on very small screens */
91 }
92 }
93 </style>
94
95 <h4>General Settings</h4>
96 <br>
97 <form method="post" enctype="multipart/form-data">
98 <div class="card m-1" style="padding-left:20px;padding-right:20px;padding-top:5px;padding-bottom:10px;max-width:fit-content">
99 <h6>Password Data Leak Checks</h6>
100 <div class="custom-control custom-switch">
101 <input name="hibp" type="checkbox" class="custom-control-input" id="hibp" <?php _ce($canEdit); echo (!isset($config['hibp']) || $config['hibp'] == true) ? " checked" : ""; ?>>
102 <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>
103 </div>
104 <i>This check is made everytime someone successfully logs into the webpanel or when they update their password.</i>
105 </div>
106 <div class="card m-1" style="padding-left:20px;padding-right:20px;padding-top:5px;padding-bottom:10px;max-width:fit-content">
107 <h6>Debug Mode</h6>
108 <div class="custom-control custom-switch">
109 <input name="debug_mode" type="checkbox" class="custom-control-input" id="debug_mode" <?php _ce($canEdit); echo ($config['debug'] == true) ? " checked" : ""; ?>>
110 <label class="custom-control-label" for="debug_mode">Enable Debug Mode (Developers Only)</label>
111 </div>
112 <i>Enabling this will likely make your webpanel more difficult to use</i>
113 </div>
114 <div class="card m-1" style="padding-left:20px;padding-right:20px;padding-top:5px;padding-bottom:10px;max-width:fit-content">
115 <h6>Themes</h6>
116 <div class="d-flex" id="color-options">
117 <label class="color-option">
118 <input type="radio" name="color" value="gradient1" class="color-input" checked>
119 <div class="color-circle selected" style="background: linear-gradient(to bottom, #4a0000, #6b0000);"></div>
120 </label>
121 <label class="color-option">
122 <input type="radio" name="color" value="gradient2" class="color-input">
123 <div class="color-circle" style="background: linear-gradient(to top right, #3c4858, #1f2833);"></div>
124 </label>
125 <label class="color-option">
126 <input type="radio" name="color" value="gradient3" class="color-input">
127 <div class="color-circle" style="background: radial-gradient(circle, #3f0f3f, #1a0643);"></div>
128 </label>
129 <label class="color-option">
130 <input type="radio" name="color" value="gradient4" class="color-input">
131 <div class="color-circle" style="background: linear-gradient(to right, #443d6e, #191b3f);"></div>
132 </label>
133 <label class="color-option">
134 <input type="radio" name="color" value="gradient5" class="color-input">
135 <div class="color-circle" style="background: linear-gradient(to bottom, #1a1a1a, #333333);"></div>
136 </label>
137 <label class="color-option">
138 <input type="radio" name="color" value="gradient6" class="color-input">
139 <div class="color-circle" style="background: linear-gradient(135deg, #4d194d, #1a0643);"></div>
140 </label>
141 <label class="color-option">
142 <input type="radio" name="color" value="gradient7" class="color-input">
143 <div class="color-circle" style="background: linear-gradient(to bottom right, #1a1a1a, #333333);"></div>
144 </label>
145 <label class="color-option">
146 <input type="radio" name="color" value="gradient8" class="color-input">
147 <div class="color-circle" style="background: linear-gradient(to bottom right, #331a33, #191b3f);"></div>
148 </label>
149 <!-- Extend with additional gradients -->
150 <label class="color-option">
151 <input type="radio" name="color" value="gradient9" class="color-input">
152 <div class="color-circle" style="background: linear-gradient(to bottom, #400000, #800000);"></div>
153 </label>
154 <label class="color-option">
155 <input type="radio" name="color" value="gradient10" class="color-input">
156 <div class="color-circle" style="background: linear-gradient(to top right, #363636, #1f1f1f);"></div>
157 </label>
158 <label class="color-option">
159 <input type="radio" name="color" value="gradient11" class="color-input">
160 <div class="color-circle" style="background: radial-gradient(circle, #730073, #400040);"></div>
161 </label>
162 <label class="color-option">
163 <input type="radio" name="color" value="gradient12" class="color-input">
164 <div class="color-circle" style="background: linear-gradient(to right, #4c4c99, #1a1a66);"></div>
165 </label>
166 <label class="color-option">
167 <input type="radio" name="color" value="gradient13" class="color-input">
168 <div class="color-circle" style="background: linear-gradient(to bottom, #2e2e2e, #4d4d4d);"></div>
169 </label>
170 <label class="color-option">
171 <input type="radio" name="color" value="gradient14" class="color-input">
172 <div class="color-circle" style="background: linear-gradient(135deg, #732673, #400040);"></div>
173 </label>
174 <label class="color-option">
175 <input type="radio" name="color" value="gradient15" class="color-input">
176 <div class="color-circle" style="background: linear-gradient(to bottom right, #2e2e2e, #4d4d4d);"></div>
177 </label>
178 <label class="color-option">
179 <input type="radio" name="color" value="gradient16" class="color-input">
180 <div class="color-circle" style="background: linear-gradient(to bottom right, #662266, #330033);"></div>
181 </label>
182 <label class="color-option">
183 <input type="radio" name="color" value="gradient17" class="color-input">
184 <div class="color-circle" style="background: linear-gradient(to bottom right, #993399, #660066);"></div>
185 </label>
186 <label class="color-option">
187 <input type="radio" name="color" value="gradient18" class="color-input">
188 <div class="color-circle" style="background: linear-gradient(to bottom right, #4c4c4c, #666666);"></div>
189 </label>
190 <label class="color-option">
191 <input type="radio" name="color" value="gradient19" class="color-input">
192 <div class="color-circle" style="background: linear-gradient(to bottom right, #660066, #330033);"></div>
193 </label>
194 <label class="color-option">
195 <input type="radio" name="color" value="gradient20" class="color-input">
196 <div class="color-circle" style="background: linear-gradient(to bottom right, #993399, #660066);"></div>
197 </label>
198 <label class="color-option">
199 <input type="radio" name="color" value="gradient21" class="color-input">
200 <div class="color-circle" style="background: linear-gradient(to bottom right, #4c4c4c, #666666);"></div>
201 </label>
202 <label class="color-option">
203 <input type="radio" name="color" value="gradient22" class="color-input">
204 <div class="color-circle" style="background: linear-gradient(to bottom right, #4c4c99, #191966);"></div>
205 </label>
206 <label class="color-option">
207 <input type="radio" name="color" value="gradient23" class="color-input">
208 <div class="color-circle" style="background: linear-gradient(to bottom right, #4c4c99, #191966);"></div>
209 </label>
210 <label class="color-option">
211 <input type="radio" name="color" value="gradient24" class="color-input">
212 <div class="color-circle" style="background: linear-gradient(to bottom right, #330000, #191966);"></div>
213 </label>
214 <label class="color-option">
215 <input type="radio" name="color" value="gradient25" class="color-input">
216 <div class="color-circle" style="background: linear-gradient(to bottom right, #4c4c99, #191966);"></div>
217 </label>
218 <label class="color-option">
219 <input type="radio" name="color" value="gradient26" class="color-input">
220 <div class="color-circle" style="background: linear-gradient(to bottom right, #330000, #191966);"></div>
221 </label>
222 <label class="color-option">
223 <input type="radio" name="color" value="gradient27" class="color-input">
224 <div class="color-circle" style="background: linear-gradient(to bottom right, #ffccff, #ff66ff);"></div>
225 </label>
226 <label class="color-option">
227 <input type="radio" name="color" value="gradient28" class="color-input">
228 <div class="color-circle" style="background: linear-gradient(to bottom right, #ff66ff, #ff99ff);"></div>
229 </label>
230 <label class="color-option">
231 <input type="radio" name="color" value="gradient29" class="color-input">
232 <div class="color-circle" style="background: linear-gradient(to bottom right, #ff66ff, #ffccff);"></div>
233 </label>
234 <label class="color-option">
235 <input type="radio" name="color" value="gradient30" class="color-input">
236 <div class="color-circle" style="background: linear-gradient(to bottom right, #ffccff, #ff66ff);"></div>
237 </label>
238 </div>
239 </div>
240
241 <script>
242 const iframe =document.getElementById('frame');
243 iframe.contentWindow.location.reload(true);
244 </script>
245
246 <style>
247 #wrap {
248 border: none;
249 padding: 0;
250 margin:0;}
251 #frame { transform:none; zoom: 0.8; -moz-transform: scale(0.8); -moz-transform-origin: 0 0; transform-origin: 3%; border:none;}
252 </style>
253 <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">
254 <h6>Overview Background Image</h6>
255 <div class="" id="wrap">
256 <label class="form-label" for="customFile">Upload an image</label>
257 <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.
258
259 <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>
260 </div>
261 </div>
262 <?php $a = []; Hook::run(HOOKTYPE_GENERAL_SETTINGS, $a); ?>
263 <br><br>
264 <button type="post" name="submit" class="btn btn-primary">Save</div>
265 </form>
266 <?php
267 require_once "../inc/footer.php";