diff options
Diffstat (limited to 'lib/config.php')
| -rw-r--r-- | lib/config.php | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/lib/config.php b/lib/config.php new file mode 100644 index 0000000..1c6797d --- /dev/null +++ b/lib/config.php @@ -0,0 +1,113 @@ +<?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 + ], + '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); + +define("INSTANCE_STATIC_FOLDER", "static"); // Static folder. Used only in /404.php. + +// FOR DEVELOPERS +define("CLIENT_REQUIRES_JSON", isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json");
\ No newline at end of file |
