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
|
<?php
$file_path = "{$_SERVER['DOCUMENT_ROOT']}/config.json";
define('CFG_PATH', $file_path);
$cfg = [
'instance' => [
'name' => $_SERVER['HTTP_HOST']
],
'database' => [
'name' => '',
'user' => '',
'pass' => '',
'host' => 'localhost',
'url' => ''
],
'anonymous' => [
'upload' => false,
'defaultname' => 'Anonymous'
],
'emote' => [
'upload' => true,
'nameregex' => "/^[A-Za-z0-9_]+$/",
'defaultvisibility' => 2,
'maxnamelength' => 100,
'maxcommentlength' => 100,
'maxsizex' => 128,
'maxsizey' => 128,
'storeoriginal' => true,
'urlupload' => true
],
'reupload' => [
'enable' => true
],
'rating' => [
'enable' => true,
'names' => "-1=COAL\n1=GEM",
'minvotes' => 10
],
'tags' => [
'enable' => true,
'regex' => "/^[A-Za-z0-9_]+$/",
'maxcount' => 10
],
'emoteset' => [
'public' => true
],
'mod' => [
'dashboard' => true,
'approve' => true
],
'reports' => [
'enable' => true
],
'account' => [
'registration' => true,
'maxcookielifetime' => 86400 * 30,
'regex' => "/^[A-Za-z0-9_]+$/",
'minusernamelength' => 2,
'maxusernamelength' => 20,
'minpasswordlength' => 10,
'secretkeylength' => 32,
'pfpsizex' => 128,
'pfpsizey' => 128,
'bannersizex' => 1920,
'bannersizey' => 1080,
'badgesizex' => 72,
'badgesizey' => 72,
'publiclist' => true,
'log' => true
],
'twitch' => [
'registration' => false,
'clientid' => '',
'clientsecret' => '',
'redirecturi' => ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https" : "http") . "://$_SERVER[HTTP_HOST]/account/login/twitch.php"
],
'captcha' => [
'enable' => false,
'x' => 580,
'y' => 220,
'force' => false
]
];
if (file_exists(CFG_PATH)) {
$c = json_decode(file_get_contents(CFG_PATH), true);
foreach ($cfg as $sk => $sv) {
if (!is_array($sv) || !array_key_exists($sk, $c)) {
continue;
}
foreach ($sv as $k => $v) {
if (array_key_exists($k, $c[$sk])) {
$cfg[$sk][$k] = $c[$sk][$k];
}
}
}
}
if (!empty($cfg['database']['host'])) {
$cfg['database']['url'] = "mysql:host={$cfg['database']['host']};dbname={$cfg['database']['name']};port=3306";
}
$cfg['rating']['names_string'] = $cfg['rating']['names'];
$n = [];
foreach (explode("\n", $cfg['rating']['names']) as $_ => $v) {
[$k, $v] = explode('=', $v, 2);
$n[intval($k)] = $v;
}
$cfg['rating']['names'] = $n;
define('CONFIG', $cfg);
// FOR DEVELOPERS
define("CLIENT_REQUIRES_JSON", isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json");
|