|
@ -50,15 +50,40 @@ $current_locale = 'en'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadConfig() { |
|
|
function loadConfig() { |
|
|
global $board, $config, $__ip, $debug, $__version, $microtime_start, $current_locale; |
|
|
global $board, $config, $__ip, $debug, $__version, $microtime_start, $current_locale, $events; |
|
|
|
|
|
|
|
|
$error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet'; |
|
|
$error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet'; |
|
|
|
|
|
|
|
|
reset_events(); |
|
|
$boardsuffix = isset($board['uri']) ? $board['uri'] : ''; |
|
|
|
|
|
|
|
|
if (!isset($_SERVER['REMOTE_ADDR'])) |
|
|
if (!isset($_SERVER['REMOTE_ADDR'])) |
|
|
$_SERVER['REMOTE_ADDR'] = '0.0.0.0'; |
|
|
$_SERVER['REMOTE_ADDR'] = '0.0.0.0'; |
|
|
|
|
|
|
|
|
|
|
|
if (file_exists('tmp/cache/cache_config.php')) { |
|
|
|
|
|
require_once('tmp/cache/cache_config.php'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($config['cache_config']) && |
|
|
|
|
|
$config['cache_config'] && |
|
|
|
|
|
$config = Cache::get('config_' . $boardsuffix ) ) { |
|
|
|
|
|
$events = Cache::get('events_' . $boardsuffix ); |
|
|
|
|
|
|
|
|
|
|
|
if (file_exists('inc/instance-functions.php')) { |
|
|
|
|
|
require_once('inc/instance-functions.php'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($config['locale'] != $current_locale) { |
|
|
|
|
|
$current_locale = $config['locale']; |
|
|
|
|
|
init_locale($config['locale'], $error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
$config = array(); |
|
|
|
|
|
// We will indent that later. |
|
|
|
|
|
|
|
|
|
|
|
reset_events(); |
|
|
|
|
|
|
|
|
$arrays = array( |
|
|
$arrays = array( |
|
|
'db', |
|
|
'db', |
|
|
'api', |
|
|
'api', |
|
@ -86,7 +111,6 @@ function loadConfig() { |
|
|
'dashboard_links' |
|
|
'dashboard_links' |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
$config = array(); |
|
|
|
|
|
foreach ($arrays as $key) { |
|
|
foreach ($arrays as $key) { |
|
|
$config[$key] = array(); |
|
|
$config[$key] = array(); |
|
|
} |
|
|
} |
|
@ -99,7 +123,7 @@ function loadConfig() { |
|
|
// Those calls are expensive. Unfortunately, our cache system is not initialized at this point. |
|
|
// Those calls are expensive. Unfortunately, our cache system is not initialized at this point. |
|
|
// So, we may store the locale in a tmp/ filesystem. |
|
|
// So, we may store the locale in a tmp/ filesystem. |
|
|
|
|
|
|
|
|
if (file_exists($fn = 'tmp/cache/locale_' . ( isset($board['uri']) ? $board['uri'] : '' ) ) ) { |
|
|
if (file_exists($fn = 'tmp/cache/locale_' . $boardsuffix ) ) { |
|
|
$config['locale'] = file_get_contents($fn); |
|
|
$config['locale'] = file_get_contents($fn); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -138,8 +162,6 @@ function loadConfig() { |
|
|
init_locale($config['locale'], $error); |
|
|
init_locale($config['locale'], $error); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
date_default_timezone_set($config['timezone']); |
|
|
|
|
|
|
|
|
|
|
|
if (!isset($config['global_message'])) |
|
|
if (!isset($config['global_message'])) |
|
|
$config['global_message'] = false; |
|
|
$config['global_message'] = false; |
|
|
|
|
|
|
|
@ -219,8 +241,22 @@ function loadConfig() { |
|
|
if (!isset($config['user_flags'])) |
|
|
if (!isset($config['user_flags'])) |
|
|
$config['user_flags'] = array(); |
|
|
$config['user_flags'] = array(); |
|
|
|
|
|
|
|
|
|
|
|
if (!isset($__version)) |
|
|
|
|
|
$__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; |
|
|
|
|
|
$config['version'] = $__version; |
|
|
|
|
|
|
|
|
|
|
|
if ($config['allow_roll']) |
|
|
|
|
|
event_handler('post', 'diceRoller'); |
|
|
|
|
|
|
|
|
|
|
|
if (is_array($config['anonymous'])) |
|
|
|
|
|
$config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
// Effectful config processing below: |
|
|
// Effectful config processing below: |
|
|
|
|
|
|
|
|
|
|
|
date_default_timezone_set($config['timezone']); |
|
|
|
|
|
|
|
|
if ($config['root_file']) { |
|
|
if ($config['root_file']) { |
|
|
chdir($config['root_file']); |
|
|
chdir($config['root_file']); |
|
|
} |
|
|
} |
|
@ -233,10 +269,6 @@ function loadConfig() { |
|
|
if (preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m)) |
|
|
if (preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m)) |
|
|
$_SERVER['REMOTE_ADDR'] = $m[2]; |
|
|
$_SERVER['REMOTE_ADDR'] = $m[2]; |
|
|
|
|
|
|
|
|
if (!isset($__version)) |
|
|
|
|
|
$__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; |
|
|
|
|
|
$config['version'] = $__version; |
|
|
|
|
|
|
|
|
|
|
|
if ($config['verbose_errors']) { |
|
|
if ($config['verbose_errors']) { |
|
|
set_error_handler('verbose_error_handler'); |
|
|
set_error_handler('verbose_error_handler'); |
|
|
error_reporting(E_ALL); |
|
|
error_reporting(E_ALL); |
|
@ -260,13 +292,22 @@ function loadConfig() { |
|
|
event_handler('post', 'postHandler'); |
|
|
event_handler('post', 'postHandler'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (is_array($config['anonymous'])) |
|
|
event('load-config'); |
|
|
$config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])]; |
|
|
|
|
|
|
|
|
|
|
|
if ($config['allow_roll']) |
|
|
if ($config['cache_config'] && !isset ($config['cache_config_loaded'])) { |
|
|
event_handler('post', 'diceRoller'); |
|
|
file_put_contents('tmp/cache/cache_config.php', '<?php '. |
|
|
|
|
|
'$config = array();'. |
|
|
|
|
|
'$config[\'cache\'] = '. |
|
|
|
|
|
var_export($config['cache'], true).';'. |
|
|
|
|
|
'$config[\'cache_config\'] = true;'. |
|
|
|
|
|
'require_once(\'inc/cache.php\');' |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
event('load-config'); |
|
|
$config['cache_config_loaded'] = true; |
|
|
|
|
|
|
|
|
|
|
|
Cache::set('config_'.$boardsuffix, $config); |
|
|
|
|
|
Cache::set('events_'.$boardsuffix, $events); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ($config['debug']) { |
|
|
if ($config['debug']) { |
|
|
if (!isset($debug)) { |
|
|
if (!isset($debug)) { |
|
|