Skip to content

Commit

Permalink
rearrange config processing a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
czaks committed Feb 27, 2015
1 parent a93f168 commit bffe03e
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions inc/functions.php
Expand Up @@ -124,10 +124,6 @@ function loadConfig() {
init_locale($config['locale'], $error);
}

if (!isset($__version))
$__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false;
$config['version'] = $__version;

date_default_timezone_set($config['timezone']);

if (!isset($config['global_message']))
Expand All @@ -136,6 +132,7 @@ function loadConfig() {
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'] = '/^' .
Expand Down Expand Up @@ -206,10 +203,24 @@ function loadConfig() {
if (!isset($config['user_flags']))
$config['user_flags'] = array();

// Effectful config processing below:

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 (!isset($__version))
$__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false;
$config['version'] = $__version;

if ($config['verbose_errors']) {
set_error_handler('verbose_error_handler');
error_reporting(E_ALL);
Expand All @@ -219,19 +230,12 @@ function loadConfig() {
ini_set('display_errors', false);
}

// 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['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';

Expand Down

0 comments on commit bffe03e

Please sign in to comment.