blob: e03e95b9637bf2c2f48c2167b09fce43b01b9d53 (
plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
<?php
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/config.php";
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/partials.php";
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/alert.php";
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/accounts.php";
if (file_exists(CFG_PATH) && (!authorize_user(true) || !isset($_SESSION['user_role']) || !$_SESSION['user_role']['permission_admin'])) {
generate_alert('/404.php', 'Unauthorized', 401);
exit();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$c = CONFIG;
$c['rating']['names'] = $c['rating']['names_string'];
unset($c['rating']['names_string']);
// setting all checkboxes to false
foreach ($c as $sk => $sv) {
foreach ($sv as $k => &$v) {
if (is_bool($v) && !array_key_exists("{$sk}_$k", $_POST)) {
$c[$sk][$k] = false;
}
}
unset($v);
}
foreach ($_POST as $k => $v) {
$parts = explode('_', $k);
$part_count = count($parts);
if ($part_count != 2) {
continue;
}
$section = $parts[0];
$key = $parts[1];
if (!array_key_exists($section, $c)) {
$c[$section] = [];
}
if ($v === 'on') {
$v = true;
}
if (is_numeric($v)) {
$v += 0;
}
$c[$section][$key] = $v;
}
if (!file_put_contents(CFG_PATH, json_encode($c, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT))) {
http_response_code(500);
exit("Failed to write the configuration file.");
}
generate_alert('/system/config.php', 'Saved!', 200);
exit();
}
?>
<html>
<head>
<title>Configuration - <?= CONFIG['instance']['name'] ?></title>
<link rel="stylesheet" href="/static/style.css">
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
</head>
<body>
<div class="container">
<div class="wrapper">
<?php html_navigation_bar() ?>
<section class="content">
<h1>Instance configuration</h1>
<?php if (!file_exists(CFG_PATH)): ?>
<div class="box">
<p>This message confirms the instance is nearly ready. The configuration below shows the default
settings. Enter your database credentials to complete the setup.</p>
</div>
<?php endif; ?>
<form action="/system/config.php" method="post">
<div class="box">
<div class="box navtab">
<p>Instance</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Name</th>
<td><input type="text" name="instance_name"
value="<?= CONFIG['instance']['name'] ?>"></td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Database</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Name</th>
<td><input type="text" name="database_name"
value="<?= CONFIG['database']['name'] ?>" required></td>
</tr>
<tr>
<th>User</th>
<td><input type="text" name="database_user"
value="<?= CONFIG['database']['user'] ?>" required></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" name="database_pass"
value="<?= CONFIG['database']['pass'] ?>" required></td>
</tr>
<tr>
<th>Host</th>
<td><input type="text" name="database_host"
value="<?= CONFIG['database']['host'] ?>" required></td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Emotes</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Allow emote upload</th>
<td><input type="checkbox" name="emote_upload" value="on"
<?= CONFIG['emote']['upload'] ? 'checked' : '' ?>></td>
</tr>
<tr>
<th>Allow anonymous emote upload</th>
<td><input type="checkbox" name="anonymous_upload" value="on"
<?= CONFIG['anonymous']['upload'] ? 'checked' : '' ?>></td>
</tr>
<tr>
<th>Allow emote upload with URL</th>
<td><input type="checkbox" name="emote_urlupload" value="on"
<?= CONFIG['emote']['urlupload'] ? 'checked' : '' ?>></td>
</tr>
<tr>
<th>Default uploader name</th>
<td><input type="text" name="anonymous_defaultname"
value="<?= CONFIG['anonymous']['defaultname'] ?>"></td>
</tr>
<tr>
<th>RegEx filter for names</th>
<td><input type="text" name="emote_nameregex"
value="<?= CONFIG['emote']['nameregex'] ?>"></td>
</tr>
<tr>
<th>Default visibility</th>
<td>
<select name="emote_defaultvisibility">
<option value="0" <?= CONFIG['emote']['defaultvisibility'] == 0 ? 'selected' : '' ?>>Unlisted</option>
<option value="on" <?= CONFIG['emote']['defaultvisibility'] == 1 ? 'selected' : '' ?>>Public</option>
<option value="2" <?= CONFIG['emote']['defaultvisibility'] == 2 ? 'selected' : '' ?>>Pending approval</option>
</select>
</td>
</tr>
<tr>
<th>Max name length</th>
<td><input type="number" name="emote_maxnamelength"
value="<?= CONFIG['emote']['maxnamelength'] ?>"></td>
</tr>
<tr>
<th>Max comment length</th>
<td><input type="number" name="emote_maxcommentlength"
value="<?= CONFIG['emote']['maxcommentlength'] ?>"></td>
</tr>
<tr>
<th>Max size</th>
<td>X: <input type="number" name="emote_maxsizex"
value="<?= CONFIG['emote']['maxsizex'] ?>"> Y:
<input type="number" name="emote_maxsizey"
value="<?= CONFIG['emote']['maxsizey'] ?>">
</td>
</tr>
<tr>
<th>Store original uploaded file</th>
<td><input type="checkbox" name="emote_storeoriginal" value="on"
<?= CONFIG['emote']['storeoriginal'] ? 'checked' : '' ?>></td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Accounts</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Enable account registration</th>
<td><input type="checkbox" name="account_registration" value="on"
<?= CONFIG['account']['registration'] ? 'checked' : '' ?>></td>
</tr>
<tr>
<th>Max. cookie lifetime <i>(in seconds)</i></th>
<td><input type="number" name="account_maxcookielifetime"
value="<?= CONFIG['account']['maxcookielifetime'] ?>"></td>
</tr>
<tr>
<th>RegEx filter for usernames</th>
<td><input type="text" name="account_regex"
value="<?= CONFIG['account']['regex'] ?>"></td>
</tr>
<tr>
<th>Username length</th>
<td>Min: <input type="number" name="account_minusernamelength"
value="<?= CONFIG['account']['minusernamelength'] ?>">
Max: <input type="number" name="account_maxusernamelength"
value="<?= CONFIG['account']['maxusernamelength'] ?>"></td>
</tr>
<tr>
<th>Min. password length</th>
<td><input type="number" name="account_minpasswordlength"
value="<?= CONFIG['account']['minpasswordlength'] ?>"></td>
</tr>
<tr>
<th>Secret key length</th>
<td><input type="number" name="account_secretkeylength"
value="<?= CONFIG['account']['secretkeylength'] ?>"></td>
</tr>
<tr>
<th>Profile picture size</th>
<td>X: <input type="number" name="account_pfpsizex"
value="<?= CONFIG['account']['pfpsizex'] ?>">
Y: <input type="number" name="account_pfpsizey"
value="<?= CONFIG['account']['pfpsizey'] ?>"></td>
</tr>
<tr>
<th>Profile banner size</th>
<td>X: <input type="number" name="account_bannersizex"
value="<?= CONFIG['account']['bannersizex'] ?>">
Y: <input type="number" name="account_bannersizey"
value="<?= CONFIG['account']['bannersizey'] ?>"></td>
</tr>
<tr>
<th>Badge size</th>
<td>X: <input type="number" name="account_badgesizex"
value="<?= CONFIG['account']['badgesizex'] ?>">
Y: <input type="number" name="account_badgesizey"
value="<?= CONFIG['account']['badgesizey'] ?>"></td>
</tr>
<tr>
<th>Enable public list</th>
<td><input type="checkbox" name="account_publiclist" value="on"
<?= CONFIG['account']['publiclist'] ? 'checked' : '' ?>></td>
</tr>
<tr>
<th>Log actions</th>
<td><input type="checkbox" name="account_log" value="on" <?= CONFIG['account']['log'] ? 'checked' : '' ?>></td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Twitch</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Enable account registration via Twitch</th>
<td><input type="checkbox" name="twitch_registration"
<?= CONFIG['twitch']['registration'] ? 'checked' : '' ?> value="on">
</td>
</tr>
<tr>
<th>Client ID</th>
<td><input type="text" name="twitch_clientid"
value="<?= CONFIG['twitch']['clientid'] ?>">
</td>
</tr>
<tr>
<th>Client secret</th>
<td><input type="password" name="twitch_clientsecret"
value="<?= CONFIG['twitch']['clientsecret'] ?>">
</td>
</tr>
<tr>
<th>Redirect URI</th>
<td><input type="url" name="twitch_redirecturi"
value="<?= CONFIG['twitch']['redirecturi'] ?>">
</td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>CAPTCHA</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Enable CAPTCHA</th>
<td><input type="checkbox" name="captcha_enable" <?= CONFIG['captcha']['enable'] ? 'checked' : '' ?> value="on">
</td>
</tr>
<tr>
<th>Force authorized users to solve CAPTCHA</th>
<td><input type="checkbox" name="captcha_force" <?= CONFIG['captcha']['force'] ? 'checked' : '' ?> value="on">
</td>
</tr>
<tr>
<th>Size</th>
<td>Min: <input type="number" name="captcha_x"
value="<?= CONFIG['captcha']['x'] ?>">
Max: <input type="number" name="captcha_y"
value="<?= CONFIG['captcha']['y'] ?>"></td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Rating</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Enable rating</th>
<td><input type="checkbox" name="rating_enable" <?= CONFIG['rating']['enable'] ? 'checked' : '' ?> value="on">
</td>
</tr>
<tr>
<th>Names<sup title="The schema is ['id/rating_point' => 'name']">[?]</sup></th>
<td><textarea name="rating_names"><?= CONFIG['rating']['names_string'] ?></textarea>
</td>
</tr>
<tr>
<th>Minimal amount of votes</th>
<td><input type="number" name="rating_minvotes"
value="<?= CONFIG['rating']['minvotes'] ?>"></td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Tags</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Enable tags</th>
<td><input type="checkbox" name="tags_enable" <?= CONFIG['tags']['enable'] ? 'checked' : '' ?> value="on">
</td>
</tr>
<tr>
<th>RegEx filter</th>
<td><input type="text" name="tags_regex" value="<?= CONFIG['tags']['regex'] ?>">
</td>
</tr>
<tr>
<th>Maximum amount of tags per emote.</th>
<td><input type="number" name="tags_maxcount"
value="<?= CONFIG['tags']['maxcount'] ?>"></td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Emotesets</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Show emotesets public</th>
<td><input type="checkbox" name="emoteset_public" <?= CONFIG['emoteset']['public'] ? 'checked' : '' ?> value="on">
</td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Moderation</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Enable system dashboard for moderators</th>
<td><input type="checkbox" name="mod_dashboard" <?= CONFIG['mod']['dashboard'] ? 'checked' : '' ?> value="on">
</td>
</tr>
<tr>
<th>Enable manual emote approval</th>
<td><input type="checkbox" name="mod_approve" <?= CONFIG['mod']['approve'] ? 'checked' : '' ?> value="on">
</td>
</tr>
</table>
</div>
</div>
<div class="box">
<div class="box navtab">
<p>Reports</p>
</div>
<div class="box content">
<table class="vertical left">
<tr>
<th>Enable reports</th>
<td><input type="checkbox" name="reports_enable" <?= CONFIG['reports']['enable'] ? 'checked' : '' ?> value="on">
</td>
</tr>
</table>
</div>
</div>
<button type="submit">Save</button>
</form>
</section>
</div>
</div>
</body>
</html>
|