1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-12 01:50:48 +01:00

indent the file (inc/functions.php) after the latest changes

This commit is contained in:
czaks 2015-04-05 19:12:41 +02:00
parent aadbf4852f
commit 45f11d1d78

View File

@ -80,177 +80,175 @@ function loadConfig() {
} }
else { else {
$config = array(); $config = array();
// We will indent that later.
reset_events(); reset_events();
$arrays = array( $arrays = array(
'db', 'db',
'api', 'api',
'cache', 'cache',
'cookies', 'cookies',
'error', 'error',
'dir', 'dir',
'mod', 'mod',
'spam', 'spam',
'filters', 'filters',
'wordfilters', 'wordfilters',
'custom_capcode', 'custom_capcode',
'custom_tripcode', 'custom_tripcode',
'dnsbl', 'dnsbl',
'dnsbl_exceptions', 'dnsbl_exceptions',
'remote', 'remote',
'allowed_ext', 'allowed_ext',
'allowed_ext_files', 'allowed_ext_files',
'file_icons', 'file_icons',
'footer', 'footer',
'stylesheets', 'stylesheets',
'additional_javascript', 'additional_javascript',
'markup', 'markup',
'custom_pages', 'custom_pages',
'dashboard_links' 'dashboard_links'
); );
foreach ($arrays as $key) { foreach ($arrays as $key) {
$config[$key] = array(); $config[$key] = array();
} }
if (!file_exists('inc/instance-config.php')) if (!file_exists('inc/instance-config.php'))
$error('Tinyboard is not configured! Create inc/instance-config.php.'); $error('Tinyboard is not configured! Create inc/instance-config.php.');
// Initialize locale as early as possible // Initialize locale as early as possible
// 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_' . $boardsuffix ) ) { if (file_exists($fn = 'tmp/cache/locale_' . $boardsuffix ) ) {
$config['locale'] = file_get_contents($fn); $config['locale'] = file_get_contents($fn);
} }
else { else {
$config['locale'] = 'en'; $config['locale'] = 'en';
$configstr = file_get_contents('inc/instance-config.php'); $configstr = file_get_contents('inc/instance-config.php');
if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) {
$configstr .= file_get_contents($board['dir'] . '/config.php');
}
$matches = array();
preg_match_all('/[^\/*#]\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches);
if ($matches && isset ($matches[2]) && $matches[2]) {
$matches = $matches[2];
$config['locale'] = $matches[count($matches)-1];
}
file_put_contents($fn, $config['locale']);
}
if ($config['locale'] != $current_locale) {
$current_locale = $config['locale'];
init_locale($config['locale'], $error);
}
require 'inc/config.php';
require 'inc/instance-config.php';
if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) {
$configstr .= file_get_contents($board['dir'] . '/config.php'); require $board['dir'] . '/config.php';
}
$matches = array();
preg_match_all('/[^\/*#]\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches);
if ($matches && isset ($matches[2]) && $matches[2]) {
$matches = $matches[2];
$config['locale'] = $matches[count($matches)-1];
} }
file_put_contents($fn, $config['locale']); if ($config['locale'] != $current_locale) {
} $current_locale = $config['locale'];
init_locale($config['locale'], $error);
if ($config['locale'] != $current_locale) {
$current_locale = $config['locale'];
init_locale($config['locale'], $error);
}
require 'inc/config.php';
require 'inc/instance-config.php';
if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) {
require $board['dir'] . '/config.php';
}
if ($config['locale'] != $current_locale) {
$current_locale = $config['locale'];
init_locale($config['locale'], $error);
}
if (!isset($config['global_message']))
$config['global_message'] = false;
if (!isset($config['post_url']))
$config['post_url'] = $config['root'] . $config['file_post'];
if (!isset($config['referer_match']))
if (isset($_SERVER['HTTP_HOST'])) {
$config['referer_match'] = '/^' .
(preg_match('@^https?://@', $config['root']) ? '' :
'https?:\/\/' . $_SERVER['HTTP_HOST']) .
preg_quote($config['root'], '/') .
'(' .
str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) .
'(' .
preg_quote($config['file_index'], '/') . '|' .
str_replace('%d', '\d+', preg_quote($config['file_page'])) .
')?' .
'|' .
str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) .
preg_quote($config['dir']['res'], '/') .
'(' .
str_replace('%d', '\d+', preg_quote($config['file_page'], '/')) . '|' .
str_replace('%d', '\d+', preg_quote($config['file_page50'], '/')) . '|' .
str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page_slug'], '/')) . '|' .
str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '/')) .
')' .
'|' .
preg_quote($config['file_mod'], '/') . '\?\/.+' .
')([#?](.+)?)?$/ui';
} else {
// CLI mode
$config['referer_match'] = '//';
} }
if (!isset($config['cookies']['path']))
$config['cookies']['path'] = &$config['root'];
if (!isset($config['dir']['static'])) if (!isset($config['global_message']))
$config['dir']['static'] = $config['root'] . 'static/'; $config['global_message'] = false;
if (!isset($config['image_blank'])) if (!isset($config['post_url']))
$config['image_blank'] = $config['dir']['static'] . 'blank.gif'; $config['post_url'] = $config['root'] . $config['file_post'];
if (!isset($config['image_sticky']))
$config['image_sticky'] = $config['dir']['static'] . 'sticky.gif';
if (!isset($config['image_locked']))
$config['image_locked'] = $config['dir']['static'] . 'locked.gif';
if (!isset($config['image_bumplocked']))
$config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif';
if (!isset($config['image_deleted']))
$config['image_deleted'] = $config['dir']['static'] . 'deleted.png';
if (!isset($config['uri_thumb'])) if (!isset($config['referer_match']))
$config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb']; if (isset($_SERVER['HTTP_HOST'])) {
elseif (isset($board['dir'])) $config['referer_match'] = '/^' .
$config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']); (preg_match('@^https?://@', $config['root']) ? '' :
'https?:\/\/' . $_SERVER['HTTP_HOST']) .
preg_quote($config['root'], '/') .
'(' .
str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) .
'(' .
preg_quote($config['file_index'], '/') . '|' .
str_replace('%d', '\d+', preg_quote($config['file_page'])) .
')?' .
'|' .
str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) .
preg_quote($config['dir']['res'], '/') .
'(' .
str_replace('%d', '\d+', preg_quote($config['file_page'], '/')) . '|' .
str_replace('%d', '\d+', preg_quote($config['file_page50'], '/')) . '|' .
str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page_slug'], '/')) . '|' .
str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '/')) .
')' .
'|' .
preg_quote($config['file_mod'], '/') . '\?\/.+' .
')([#?](.+)?)?$/ui';
} else {
// CLI mode
$config['referer_match'] = '//';
}
if (!isset($config['cookies']['path']))
$config['cookies']['path'] = &$config['root'];
if (!isset($config['uri_img'])) if (!isset($config['dir']['static']))
$config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img']; $config['dir']['static'] = $config['root'] . 'static/';
elseif (isset($board['dir']))
$config['uri_img'] = sprintf($config['uri_img'], $board['dir']);
if (!isset($config['uri_stylesheets'])) if (!isset($config['image_blank']))
$config['uri_stylesheets'] = $config['root'] . 'stylesheets/'; $config['image_blank'] = $config['dir']['static'] . 'blank.gif';
if (!isset($config['url_stylesheet'])) if (!isset($config['image_sticky']))
$config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css'; $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif';
if (!isset($config['url_javascript'])) if (!isset($config['image_locked']))
$config['url_javascript'] = $config['root'] . $config['file_script']; $config['image_locked'] = $config['dir']['static'] . 'locked.gif';
if (!isset($config['additional_javascript_url'])) if (!isset($config['image_bumplocked']))
$config['additional_javascript_url'] = $config['root']; $config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif';
if (!isset($config['uri_flags'])) if (!isset($config['image_deleted']))
$config['uri_flags'] = $config['root'] . 'static/flags/%s.png'; $config['image_deleted'] = $config['dir']['static'] . 'deleted.png';
if (!isset($config['user_flag']))
$config['user_flag'] = false;
if (!isset($config['user_flags']))
$config['user_flags'] = array();
if (!isset($__version)) if (!isset($config['uri_thumb']))
$__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; $config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb'];
$config['version'] = $__version; elseif (isset($board['dir']))
$config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']);
if ($config['allow_roll']) if (!isset($config['uri_img']))
event_handler('post', 'diceRoller'); $config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img'];
elseif (isset($board['dir']))
$config['uri_img'] = sprintf($config['uri_img'], $board['dir']);
if (is_array($config['anonymous'])) if (!isset($config['uri_stylesheets']))
$config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])]; $config['uri_stylesheets'] = $config['root'] . 'stylesheets/';
if (!isset($config['url_stylesheet']))
$config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css';
if (!isset($config['url_javascript']))
$config['url_javascript'] = $config['root'] . $config['file_script'];
if (!isset($config['additional_javascript_url']))
$config['additional_javascript_url'] = $config['root'];
if (!isset($config['uri_flags']))
$config['uri_flags'] = $config['root'] . 'static/flags/%s.png';
if (!isset($config['user_flag']))
$config['user_flag'] = false;
if (!isset($config['user_flags']))
$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: