function loadConfig() { 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'; $boardsuffix = isset($board['uri']) ? $board['uri'] : ''; if (!isset($_SERVER['REMOTE_ADDR'])) { $_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); define_groups(); 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('db', 'api', 'cache', 'cookies', 'error', 'dir', 'mod', 'spam', 'filters', 'wordfilters', 'custom_capcode', 'custom_tripcode', 'dnsbl', 'dnsbl_exceptions', 'remote', 'allowed_ext', 'allowed_ext_files', 'file_icons', 'footer', 'stylesheets', 'additional_javascript', 'markup', 'custom_pages', 'dashboard_links'); foreach ($arrays as $key) { $config[$key] = array(); } if (!file_exists('inc/instance-config.php')) { $error('Posting is down momentarily. Please try again later.'); } // Initialize locale as early as possible // Those calls are expensive. Unfortunately, our cache system is not initialized at this point. // So, we may store the locale in a tmp/ filesystem. if (file_exists($fn = 'tmp/cache/locale_' . $boardsuffix)) { $config['locale'] = file_get_contents($fn); } else { $config['locale'] = 'en'; $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')) { 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'], '/')) . ')' . '|' . 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'])) { $config['dir']['static'] = $config['root'] . 'static/'; } if (!isset($config['image_blank'])) { $config['image_blank'] = $config['dir']['static'] . 'blank.gif'; } 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'])) { $config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb']; } elseif (isset($board['dir'])) { $config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']); } if (!isset($config['uri_img'])) { $config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img']; } elseif (isset($board['dir'])) { $config['uri_img'] = sprintf($config['uri_img'], $board['dir']); } if (!isset($config['uri_stylesheets'])) { $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: date_default_timezone_set($config['timezone']); if ($config['root_file']) { chdir($config['root_file']); } // Keep the original address to properly comply with other board configurations if (!isset($__ip)) { $__ip = $_SERVER['REMOTE_ADDR']; } // ::ffff:0.0.0.0 if (preg_match('/^\\:\\:(ffff\\:)?(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', $__ip, $m)) { $_SERVER['REMOTE_ADDR'] = $m[2]; } if ($config['verbose_errors']) { set_error_handler('verbose_error_handler'); error_reporting(E_ALL); ini_set('display_errors', true); ini_set('html_errors', false); } else { ini_set('display_errors', false); } if ($config['syslog']) { openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG); } // open a connection to sysem logger if ($config['recaptcha']) { require_once 'inc/lib/recaptcha/recaptchalib.php'; } if ($config['cache']['enabled']) { require_once 'inc/cache.php'; } if (in_array('webm', $config['allowed_ext_files'])) { require_once 'inc/lib/webm/posthandler.php'; event_handler('post', 'postHandler'); } event('load-config'); if ($config['cache_config'] && !isset($config['cache_config_loaded'])) { file_put_contents('tmp/cache/cache_config.php', '<?php ' . '$config = array();' . '$config[\'cache\'] = ' . var_export($config['cache'], true) . ';' . '$config[\'cache_config\'] = true;' . '$config[\'debug\'] = ' . var_export($config['debug'], true) . ';' . 'require_once(\'inc/cache.php\');'); $config['cache_config_loaded'] = true; Cache::set('config_' . $boardsuffix, $config); Cache::set('events_' . $boardsuffix, $events); } if ($config['debug']) { if (!isset($debug)) { $debug = array('sql' => array(), 'exec' => array(), 'purge' => array(), 'cached' => array(), 'write' => array(), 'time' => array('db_queries' => 0, 'exec' => 0), 'start' => $microtime_start, 'start_debug' => microtime(true)); $debug['start'] = $microtime_start; } } }
$config['mod']['raw_html_default'] = false; // Automatically dismiss all reports regarding a thread when it is locked. $config['mod']['dismiss_reports_on_lock'] = true; // Replace ?/config with a simple text editor for editing inc/instance-config.php. $config['mod']['config_editor_php'] = false; /* * ==================== * Mod permissions * ==================== */ // Probably best not to change this unless you are smart enough to figure out what you're doing. If you // decide to change it, remember that it is impossible to redefinite/overwrite groups; you may only add // new ones. $config['mod']['groups'] = array(10 => 'Janitor', 20 => 'Mod', 30 => 'Admin', 99 => 'Disabled'); // If you add stuff to the above, you'll need to call this function immediately after. define_groups(); // Example: Adding a new permissions group. // $config['mod']['groups'][0] = 'NearlyPowerless'; // define_groups(); // Capcode permissions. $config['mod']['capcode'] = array(MOD => array('Mod'), ADMIN => true); // Example: Allow mods to post with "## Moderator" as well // $config['mod']['capcode'][MOD][] = 'Moderator'; // Example: Allow janitors to post with any capcode // $config['mod']['capcode'][JANITOR] = true; // Set any of the below to "DISABLED" to make them unavailable for everyone. // Don't worry about per-board moderators. Let all mods moderate any board. $config['mod']['skip_per_board'] = false; /* Post Controls */ // View IP addresses $config['mod']['show_ip'] = MOD;