Better way of loading configuration
This commit is contained in:
parent
a528996bcd
commit
c237b016e6
@ -173,6 +173,7 @@
|
|||||||
$config['file_index'] = 'index.html';
|
$config['file_index'] = 'index.html';
|
||||||
$config['file_page'] = '%d.html';
|
$config['file_page'] = '%d.html';
|
||||||
$config['file_mod'] = 'mod.php';
|
$config['file_mod'] = 'mod.php';
|
||||||
|
$config['file_post'] = 'post.php';
|
||||||
|
|
||||||
// Multi-board (%s is board abbreviation)
|
// Multi-board (%s is board abbreviation)
|
||||||
$config['board_path'] = '%s/';
|
$config['board_path'] = '%s/';
|
||||||
|
@ -1,4 +1,42 @@
|
|||||||
<?php
|
<?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 = '%') {
|
function sprintf3($str, $vars, $delim = '%') {
|
||||||
$replaces = array();
|
$replaces = array();
|
||||||
foreach($vars as $k => $v) {
|
foreach($vars as $k => $v) {
|
||||||
|
4
mod.php
4
mod.php
@ -1,10 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'inc/functions.php';
|
require 'inc/functions.php';
|
||||||
require 'inc/display.php';
|
require 'inc/display.php';
|
||||||
require 'inc/config.php';
|
|
||||||
if (file_exists('inc/instance-config.php')) {
|
|
||||||
require 'inc/instance-config.php';
|
|
||||||
}
|
|
||||||
require 'inc/template.php';
|
require 'inc/template.php';
|
||||||
require 'inc/database.php';
|
require 'inc/database.php';
|
||||||
require 'inc/user.php';
|
require 'inc/user.php';
|
||||||
|
4
post.php
4
post.php
@ -1,10 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'inc/functions.php';
|
require 'inc/functions.php';
|
||||||
require 'inc/display.php';
|
require 'inc/display.php';
|
||||||
require 'inc/config.php';
|
|
||||||
if (file_exists('inc/instance-config.php')) {
|
|
||||||
require 'inc/instance-config.php';
|
|
||||||
}
|
|
||||||
require 'inc/template.php';
|
require 'inc/template.php';
|
||||||
require 'inc/database.php';
|
require 'inc/database.php';
|
||||||
require 'inc/user.php';
|
require 'inc/user.php';
|
||||||
|
Loading…
Reference in New Issue
Block a user