diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2011-02-16 16:21:14 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2011-02-16 16:21:14 +1100 |
| commit | c237b016e60c6073eeee14f08463f20c47169a79 (patch) | |
| tree | bf66d9d6ec2d657f32fb18633652c1bec853b464 /inc | |
| parent | a528996bcd2e7e0a0c60b409aaa76f32d9311217 (diff) | |
Better way of loading configuration
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/config.php | 1 | ||||
| -rw-r--r-- | inc/functions.php | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/inc/config.php b/inc/config.php index c60ecace..5d798581 100644 --- a/inc/config.php +++ b/inc/config.php @@ -173,6 +173,7 @@ $config['file_index'] = 'index.html'; $config['file_page'] = '%d.html'; $config['file_mod'] = 'mod.php'; + $config['file_post'] = 'post.php'; // Multi-board (%s is board abbreviation) $config['board_path'] = '%s/'; diff --git a/inc/functions.php b/inc/functions.php index cc2a02f8..1c9f6b78 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1,4 +1,42 @@ <?php + loadConfig(); + + function loadConfig() { + global $board, $config; + + require 'config.php'; + if (file_exists('inc/instance-config.php')) { + require 'instance-config.php'; + } + + $config['post_url'] = $config['root'] . $config['file_post']; + + $config['url_match'] = '/^' . + (preg_match($config['url_regex'], $config['root']) ? '' : + (@$_SERVER['HTTPS']?'https':'http') . + ':\/\/'.$_SERVER['HTTP_HOST']) . + preg_quote($config['root'], '/') . + '(' . + str_replace('%s', '\w{1,8}', preg_quote($config['board_path'], '/')) . + '|' . + str_replace('%s', '\w{1,8}', preg_quote($config['board_path'], '/')) . + preg_quote($config['file_index'], '/') . + '|' . + str_replace('%s', '\w{1,8}', preg_quote($config['board_path'], '/')) . + str_replace('%d', '\d+', preg_quote($config['file_page'], '/')) . + '|' . + preg_quote($config['file_mod'], '/') . + '\?\/.+' . + ')$/i'; + + $config['dir']['static'] = $config['root'] . 'static/'; + + $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif'; + $config['image_locked'] = $config['dir']['static'] . 'locked.gif'; + $config['image_deleted'] = $config['dir']['static'] . 'deleted.png'; + $config['image_zip'] = $config['dir']['static'] . 'zip.png'; + } + function sprintf3($str, $vars, $delim = '%') { $replaces = array(); foreach($vars as $k => $v) { |
