I think that phpBB3 handles paths and URLs poorly. If you have rewrite rules, sometimes it won't show the css properly, or link you to a page in the wrong directory. The template vars that refer to paths also seem to miss a lot. I think the system should be changed quite a bit. I think that the following should be added to the config.php file and editable through the ACP:
Code: Select all
define('EXT', substr(__FILE__, strrpos(__FILE__, '.')));
$file = explode('/', __FILE__);
array_pop($file);
$dir = implode('/', $file);
define('DIR_BASE', $dir.'/');
$dir_constants = array(
'ADM' => 'adm/',
'CACHE' => 'cache/',
'DOWNLOAD' => 'download/',
'FILES' => 'files/',
'IMAGES' => 'images/',
'INCLUDES' => 'includes/',
'LANGUAGE' => 'language/',
'STORE' => 'store/',
'STYLES' => 'styles/',
'THEME' => 'styles/prosilver/theme/',
'TEMPLATE' => 'styles/prosilver/template/'
//and so on and so on...
);
$url_constants = array(
'ADM' => URL_BASE.'adm/',
'CACHE' => URL_BASE.'cache/',
'DOWNLOAD' => URL_BASE.'download/',
'FILES' => URL_BASE.'files/',
'IMAGES' => URL_BASE.'images/',
'INCLUDES' => URL_BASE.'includes/',
'LANGUAGE' => URL_BASE.'language/',
'STORE' => URL_BASE.'store/',
'STYLES' => URL_BASE.'styles/',
'THEME' => URL_BASE.'styles/prosilver/theme/',
'TEMPLATE' => URL_BASE.'styles/prosilver/template/'
//and so on and so on...
);
foreach ($dir_constants as $name => $path)
{
define('DIR_'.$name, DIR_BASE.$path);
}
define('URL_BASEDIR', 'phpBB3/');
$url = substr($_SERVER['REQUEST_URI'], strlen(URL_BASEDIR+1);
define('URL', $url);
$substr_count = substr_count(URL, '/');
define('URL_BASE', ($substr_count) ? str_repeat('../', $substr_count) : './');
foreach ($url_constants as $name => $path)
{
define('URL_'.$name, $path);
}
DIR_BASE: /var/www/phpBB3/
DIR_ADM: /var/www/phpBB3/adm/
DIR_CACHE: /var/www/phpBB3/cache/
DIR_DOWNLOAD: /var/www/phpBB3/download/
DIR_FILES: /var/www/phpBB3/files/
DIR_IMAGES: /var/www/phpBB3/images/
DIR_INCLUDES: /var/www/phpBB3/includes/
DIR_LANGUAGE: /var/www/phpBB3/language/
DIR_STORE: /var/www/phpBB3/store/
DIR_STYLES: /var/www/phpBB3/styles/
DIR_THEME: /var/www/phpBB3/styles/prosilver/theme/
DIR_TEMPLATE: /var/www/phpBB3/styles/prosilver/template/
URL_BASE: ../phpBB3/
URL_ADM: ../phpBB3/adm/
URL_CACHE: ../phpBB3/cache/
URL_DOWNLOAD: ../phpBB3/download/
URL_FILES: ../phpBB3/files/
URL_IMAGES: ../phpBB3/images/
URL_INCLUDES: ../phpBB3/includes/
URL_LANGUAGE: ../phpBB3/language/
URL_STORE: ../phpBB3/store/
URL_STYLES: ../phpBB3/styles/
URL_THEME: ../phpBB3/styles/prosilver/theme/
URL_TEMPLATE: ../phpBB3/styles/prosilver/template/
URL: index.php
URL_BASEDIR: phpBB3/
The configuration would be a list of path names, input boxes for user defined paths. You could set the image url to http://my_super_awesome_cdn.com/ and use your super awesome cdn to deliver images. The dir constants would be used all over phpbb in includes/requires and other operations on local files. All of the constants would also be template variables. This would allow for flexibility in the file and url structure.
If this is too much work, I propose that only some basic constants are set, like so:
Code: Select all
define('EXT', substr(__FILE__, strrpos(__FILE__, '.')));
$file = explode('/', __FILE__);
array_pop($file);
$dir = implode('/', $file);
define('DIR_BASE', $dir.'/');
define('URL_BASEDIR', 'phpBB3/');
$url = substr($_SERVER['REQUEST_URI'], strlen(URL_BASEDIR+1);
define('URL', $url);
$substr_count = substr_count(URL, '/');
define('URL_BASE', ($substr_count) ? str_repeat('../', $substr_count) : './');