1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

i am not sure if people will like the config layout i test here... it requires the framework at least being present

git-svn-id: file:///svn/phpbb/trunk@9281 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2009-01-20 16:54:15 +00:00
parent b55f9854e7
commit cd4091af43
19 changed files with 154 additions and 219 deletions

View File

@@ -16,15 +16,6 @@ if (!defined('IN_PHPBB'))
exit;
}
/**
* Define missing ACM config variable... if not initialized yet
* @ignore
*/
if (!defined('CONFIG_ACM_TYPE'))
{
define('CONFIG_ACM_TYPE', 'file');
}
/**
* Base cache class.
*
@@ -63,6 +54,9 @@ class phpbb_acm
/**
* Magic method for calling type-specific functions.
* Functions directly supported are: get(), put(), exists(), destroy()
*
* The type is added to the methods name, for getting sql data just use get_sql() for example.
*
* see {@link phpbb_acm_abstract phpbb_acm_abstract} for more information
*
* @access public
@@ -176,8 +170,10 @@ class phpbb_acm
* @return bool Returns true on success, else false.
* @access public
*/
public function register($cache_type, $cache_append = false, $cache_object = CONFIG_ACM_TYPE)
public function register($cache_type, $cache_append = false, $cache_object = false)
{
$cache_object = ($cache_object === false) ? basename(phpbb::$base_config['acm_type']) : basename($cache_object);
// We need to init every cache type...
if (!isset($this->cache_types[$cache_type]))
{

View File

@@ -1265,7 +1265,7 @@ abstract class phpbb_session
if ($user_ip !== $session_ip || $user_browser !== $session_browser || $user_forwarded_for !== $session_forwarded_for || !$referer_valid)
{
// Added logging temporarly to help debug bugs...
if (defined('DEBUG_EXTRA') && $this->data['user_id'] != ANONYMOUS && $log_failure)
if (phpbb::$base_config['debug_extra'] && $this->data['user_id'] != ANONYMOUS && $log_failure)
{
if ($referer_valid)
{

View File

@@ -236,7 +236,7 @@ class phpbb_template
$recompile = (!file_exists($filename) || @filesize($filename) === 0 || (phpbb::$config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle]))) ? true : false;
if (defined('DEBUG_EXTRA'))
if (phpbb::$base_config['debug_extra'])
{
$recompile = true;
}

View File

@@ -457,7 +457,7 @@ class phpbb_user extends phpbb_session
// Disable board if the install/ directory is still present
// For the brave development army we do not care about this, else we need to comment out this everytime we develop locally
if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists(PHPBB_ROOT_PATH . 'install'))
if (!phpbb::$base_config['debug_extra'] && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists(PHPBB_ROOT_PATH . 'install'))
{
// Adjust the message slightly according to the permissions
if (phpbb::$acl->acl_gets('a_', 'm_') || phpbb::$acl->acl_getf_global('m_'))

View File

@@ -173,69 +173,68 @@ define('REFERER_VALIDATE_PATH', 2);
define('VOTE_CONVERTED', 127);
// Table names
define('ACL_GROUPS_TABLE', $table_prefix . 'acl_groups');
define('ACL_OPTIONS_TABLE', $table_prefix . 'acl_options');
define('ACL_ROLES_DATA_TABLE', $table_prefix . 'acl_roles_data');
define('ACL_ROLES_TABLE', $table_prefix . 'acl_roles');
define('ACL_USERS_TABLE', $table_prefix . 'acl_users');
define('ATTACHMENTS_TABLE', $table_prefix . 'attachments');
define('BANLIST_TABLE', $table_prefix . 'banlist');
define('BBCODES_TABLE', $table_prefix . 'bbcodes');
define('BOOKMARKS_TABLE', $table_prefix . 'bookmarks');
define('BOTS_TABLE', $table_prefix . 'bots');
define('CONFIG_TABLE', $table_prefix . 'config');
define('CONFIRM_TABLE', $table_prefix . 'confirm');
define('DISALLOW_TABLE', $table_prefix . 'disallow');
define('DRAFTS_TABLE', $table_prefix . 'drafts');
define('EXTENSIONS_TABLE', $table_prefix . 'extensions');
define('EXTENSION_GROUPS_TABLE', $table_prefix . 'extension_groups');
define('FORUMS_TABLE', $table_prefix . 'forums');
define('FORUMS_ACCESS_TABLE', $table_prefix . 'forums_access');
define('FORUMS_TRACK_TABLE', $table_prefix . 'forums_track');
define('FORUMS_WATCH_TABLE', $table_prefix . 'forums_watch');
define('GROUPS_TABLE', $table_prefix . 'groups');
define('ICONS_TABLE', $table_prefix . 'icons');
define('LANG_TABLE', $table_prefix . 'lang');
define('LOG_TABLE', $table_prefix . 'log');
define('MODERATOR_CACHE_TABLE', $table_prefix . 'moderator_cache');
define('MODULES_TABLE', $table_prefix . 'modules');
define('POLL_OPTIONS_TABLE', $table_prefix . 'poll_options');
define('POLL_VOTES_TABLE', $table_prefix . 'poll_votes');
define('POSTS_TABLE', $table_prefix . 'posts');
define('PRIVMSGS_TABLE', $table_prefix . 'privmsgs');
define('PRIVMSGS_FOLDER_TABLE', $table_prefix . 'privmsgs_folder');
define('PRIVMSGS_RULES_TABLE', $table_prefix . 'privmsgs_rules');
define('PRIVMSGS_TO_TABLE', $table_prefix . 'privmsgs_to');
define('PROFILE_FIELDS_TABLE', $table_prefix . 'profile_fields');
define('PROFILE_FIELDS_DATA_TABLE', $table_prefix . 'profile_fields_data');
define('PROFILE_FIELDS_LANG_TABLE', $table_prefix . 'profile_fields_lang');
define('PROFILE_LANG_TABLE', $table_prefix . 'profile_lang');
define('RANKS_TABLE', $table_prefix . 'ranks');
define('REPORTS_TABLE', $table_prefix . 'reports');
define('REPORTS_REASONS_TABLE', $table_prefix . 'reports_reasons');
define('SEARCH_RESULTS_TABLE', $table_prefix . 'search_results');
define('SEARCH_WORDLIST_TABLE', $table_prefix . 'search_wordlist');
define('SEARCH_WORDMATCH_TABLE', $table_prefix . 'search_wordmatch');
define('SESSIONS_TABLE', $table_prefix . 'sessions');
define('SESSIONS_KEYS_TABLE', $table_prefix . 'sessions_keys');
define('SITELIST_TABLE', $table_prefix . 'sitelist');
define('SMILIES_TABLE', $table_prefix . 'smilies');
define('STYLES_TABLE', $table_prefix . 'styles');
define('STYLES_TEMPLATE_TABLE', $table_prefix . 'styles_template');
define('STYLES_THEME_TABLE', $table_prefix . 'styles_theme');
define('STYLES_IMAGESET_TABLE', $table_prefix . 'styles_imageset');
define('STYLES_IMAGESET_DATA_TABLE',$table_prefix . 'styles_imageset_data');
define('TOPICS_TABLE', $table_prefix . 'topics');
define('TOPICS_POSTED_TABLE', $table_prefix . 'topics_posted');
define('TOPICS_TRACK_TABLE', $table_prefix . 'topics_track');
define('TOPICS_WATCH_TABLE', $table_prefix . 'topics_watch');
define('USER_GROUP_TABLE', $table_prefix . 'user_group');
define('USERS_TABLE', $table_prefix . 'users');
define('WARNINGS_TABLE', $table_prefix . 'warnings');
define('WORDS_TABLE', $table_prefix . 'words');
define('ZEBRA_TABLE', $table_prefix . 'zebra');
define('ACL_GROUPS_TABLE', phpbb::$base_config['table_prefix'] . 'acl_groups');
define('ACL_OPTIONS_TABLE', phpbb::$base_config['table_prefix'] . 'acl_options');
define('ACL_ROLES_DATA_TABLE', phpbb::$base_config['table_prefix'] . 'acl_roles_data');
define('ACL_ROLES_TABLE', phpbb::$base_config['table_prefix'] . 'acl_roles');
define('ACL_USERS_TABLE', phpbb::$base_config['table_prefix'] . 'acl_users');
define('ATTACHMENTS_TABLE', phpbb::$base_config['table_prefix'] . 'attachments');
define('BANLIST_TABLE', phpbb::$base_config['table_prefix'] . 'banlist');
define('BBCODES_TABLE', phpbb::$base_config['table_prefix'] . 'bbcodes');
define('BOOKMARKS_TABLE', phpbb::$base_config['table_prefix'] . 'bookmarks');
define('BOTS_TABLE', phpbb::$base_config['table_prefix'] . 'bots');
define('CONFIG_TABLE', phpbb::$base_config['table_prefix'] . 'config');
define('CONFIRM_TABLE', phpbb::$base_config['table_prefix'] . 'confirm');
define('DISALLOW_TABLE', phpbb::$base_config['table_prefix'] . 'disallow');
define('DRAFTS_TABLE', phpbb::$base_config['table_prefix'] . 'drafts');
define('EXTENSIONS_TABLE', phpbb::$base_config['table_prefix'] . 'extensions');
define('EXTENSION_GROUPS_TABLE', phpbb::$base_config['table_prefix'] . 'extension_groups');
define('FORUMS_TABLE', phpbb::$base_config['table_prefix'] . 'forums');
define('FORUMS_ACCESS_TABLE', phpbb::$base_config['table_prefix'] . 'forums_access');
define('FORUMS_TRACK_TABLE', phpbb::$base_config['table_prefix'] . 'forums_track');
define('FORUMS_WATCH_TABLE', phpbb::$base_config['table_prefix'] . 'forums_watch');
define('GROUPS_TABLE', phpbb::$base_config['table_prefix'] . 'groups');
define('ICONS_TABLE', phpbb::$base_config['table_prefix'] . 'icons');
define('LANG_TABLE', phpbb::$base_config['table_prefix'] . 'lang');
define('LOG_TABLE', phpbb::$base_config['table_prefix'] . 'log');
define('MODERATOR_CACHE_TABLE', phpbb::$base_config['table_prefix'] . 'moderator_cache');
define('MODULES_TABLE', phpbb::$base_config['table_prefix'] . 'modules');
define('POLL_OPTIONS_TABLE', phpbb::$base_config['table_prefix'] . 'poll_options');
define('POLL_VOTES_TABLE', phpbb::$base_config['table_prefix'] . 'poll_votes');
define('POSTS_TABLE', phpbb::$base_config['table_prefix'] . 'posts');
define('PRIVMSGS_TABLE', phpbb::$base_config['table_prefix'] . 'privmsgs');
define('PRIVMSGS_FOLDER_TABLE', phpbb::$base_config['table_prefix'] . 'privmsgs_folder');
define('PRIVMSGS_RULES_TABLE', phpbb::$base_config['table_prefix'] . 'privmsgs_rules');
define('PRIVMSGS_TO_TABLE', phpbb::$base_config['table_prefix'] . 'privmsgs_to');
define('PROFILE_FIELDS_TABLE', phpbb::$base_config['table_prefix'] . 'profile_fields');
define('PROFILE_FIELDS_DATA_TABLE', phpbb::$base_config['table_prefix'] . 'profile_fields_data');
define('PROFILE_FIELDS_LANG_TABLE', phpbb::$base_config['table_prefix'] . 'profile_fields_lang');
define('PROFILE_LANG_TABLE', phpbb::$base_config['table_prefix'] . 'profile_lang');
define('RANKS_TABLE', phpbb::$base_config['table_prefix'] . 'ranks');
define('REPORTS_TABLE', phpbb::$base_config['table_prefix'] . 'reports');
define('REPORTS_REASONS_TABLE', phpbb::$base_config['table_prefix'] . 'reports_reasons');
define('SEARCH_RESULTS_TABLE', phpbb::$base_config['table_prefix'] . 'search_results');
define('SEARCH_WORDLIST_TABLE', phpbb::$base_config['table_prefix'] . 'search_wordlist');
define('SEARCH_WORDMATCH_TABLE', phpbb::$base_config['table_prefix'] . 'search_wordmatch');
define('SESSIONS_TABLE', phpbb::$base_config['table_prefix'] . 'sessions');
define('SESSIONS_KEYS_TABLE', phpbb::$base_config['table_prefix'] . 'sessions_keys');
define('SITELIST_TABLE', phpbb::$base_config['table_prefix'] . 'sitelist');
define('SMILIES_TABLE', phpbb::$base_config['table_prefix'] . 'smilies');
define('STYLES_TABLE', phpbb::$base_config['table_prefix'] . 'styles');
define('STYLES_TEMPLATE_TABLE', phpbb::$base_config['table_prefix'] . 'styles_template');
define('STYLES_THEME_TABLE', phpbb::$base_config['table_prefix'] . 'styles_theme');
define('STYLES_IMAGESET_TABLE', phpbb::$base_config['table_prefix'] . 'styles_imageset');
define('STYLES_IMAGESET_DATA_TABLE',phpbb::$base_config['table_prefix'] . 'styles_imageset_data');
define('TOPICS_TABLE', phpbb::$base_config['table_prefix'] . 'topics');
define('TOPICS_POSTED_TABLE', phpbb::$base_config['table_prefix'] . 'topics_posted');
define('TOPICS_TRACK_TABLE', phpbb::$base_config['table_prefix'] . 'topics_track');
define('TOPICS_WATCH_TABLE', phpbb::$base_config['table_prefix'] . 'topics_watch');
define('USER_GROUP_TABLE', phpbb::$base_config['table_prefix'] . 'user_group');
define('USERS_TABLE', phpbb::$base_config['table_prefix'] . 'users');
define('WARNINGS_TABLE', phpbb::$base_config['table_prefix'] . 'warnings');
define('WORDS_TABLE', phpbb::$base_config['table_prefix'] . 'words');
define('ZEBRA_TABLE', phpbb::$base_config['table_prefix'] . 'zebra');
// Additional tables
?>

View File

@@ -61,44 +61,14 @@ if (defined('IN_CRON'))
// Set some default configuration parameter if the config file does not exist
if (!file_exists(PHPBB_ROOT_PATH . 'config.' . PHP_EXT))
{
define('CONFIG_ADM_FOLDER', 'adm');
define('CONFIG_ACM_TYPE', 'file');
// phpbb::$base_config['config_set'] = false
// This allows common.php or an installation script to do specific actions if the configuration is missing
define('PHPBB_CONFIG_MISSING', true);
}
else
{
require PHPBB_ROOT_PATH . 'config.' . PHP_EXT;
}
// Set default configuration variables if phpBB is not installed
if (!defined('PHPBB_INSTALLED'))
{
$dbms = $dbhost = $dbport = $dbname = $dbuser = $dbpasswd = '';
$table_prefix = 'phpbb_';
}
if (defined('DEBUG_EXTRA'))
{
$base_memory_usage = 0;
if (function_exists('memory_get_usage'))
{
$base_memory_usage = memory_get_usage();
}
}
// Load Extensions
if (!empty($load_extensions))
{
$load_extensions = explode(',', $load_extensions);
foreach ($load_extensions as $extension)
{
@dl(trim($extension));
}
}
// Register autoload function
spl_autoload_register('__phpbb_autoload');

View File

@@ -81,7 +81,24 @@ abstract class phpbb
* @var array The phpBB configuration array
*/
public static $config = array();
/**#@-*/
/**
* @var array The base configuration array
*/
public static $base_config = array(
'table_prefix' => 'phpbb_',
'admin_folder' => 'adm',
'acm_type' => 'file',
'config_set' => false,
'extensions_set' => false,
'memory_usage' => 0,
'debug' => false,
'debug_extra' => false,
'installed' => false,
);
/**#@+
* Permission constant
@@ -144,6 +161,33 @@ abstract class phpbb
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
/**
* Set base configuration - called from config.php file
*/
public static function set_config($config)
{
phpbb::$base_config = array_merge(phpbb::$base_config, $config);
phpbb::$base_config['config_set'] = true;
if (phpbb::$base_config['debug_extra'] && function_exists('memory_get_usage'))
{
phpbb::$base_config['memory_usage'] = memory_get_usage();
}
// Load Extensions
if (!empty(phpbb::$base_config['extensions']) && !phpbb::$base_config['extensions_set'])
{
$load_extensions = explode(',', phpbb::$base_config['extensions']);
foreach ($load_extensions as $extension)
{
@dl(trim($extension));
}
phpbb::$base_config['extensions_set'] = true;
}
}
/**
* Get instance of static property
*

View File

@@ -2026,7 +2026,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
// Check the error reporting level and return if the error level does not match
// If DEBUG is defined the default level is E_ALL
if (($errno & ((defined('DEBUG')) ? E_ALL | E_STRICT : error_reporting())) == 0)
if (($errno & ((phpbb::$base_config['debug']) ? E_ALL | E_STRICT : error_reporting())) == 0)
{
return;
}
@@ -2122,7 +2122,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo ' <div>' . $msg_text;
if ((phpbb::registered('acl') && phpbb::$acl->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA'))
if ((phpbb::registered('acl') && phpbb::$acl->acl_get('a_')) || defined('IN_INSTALL') || phpbb::$base_config['debug_extra'])
{
echo ($backtrace = get_backtrace()) ? '<br /><br />BACKTRACE' . $backtrace : '';
}
@@ -2522,26 +2522,25 @@ function page_footer($run_cron = true)
global $starttime;
// Output page creation time
if (defined('DEBUG'))
if (phpbb::$base_config['debug'])
{
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
if (phpbb_request::variable('explain', false) && /*phpbb::$acl->acl_get('a_') &&*/ defined('DEBUG_EXTRA') && method_exists(phpbb::$db, 'sql_report'))
if (phpbb_request::variable('explain', false) && /*phpbb::$acl->acl_get('a_') &&*/ phpbb::$base_config['debug_extra'] && method_exists(phpbb::$db, 'sql_report'))
{
phpbb::$db->sql_report('display');
}
$debug_output = sprintf('Time : %.3fs | ' . phpbb::$db->sql_num_queries() . ' Queries | GZIP : ' . ((phpbb::$config['gzip_compress']) ? 'On' : 'Off') . ((phpbb::$user->system['load']) ? ' | Load : ' . phpbb::$user->system['load'] : ''), $totaltime);
if (/*phpbb::$acl->acl_get('a_') &&*/ defined('DEBUG_EXTRA'))
if (/*phpbb::$acl->acl_get('a_') &&*/ phpbb::$base_config['debug_extra'])
{
if (function_exists('memory_get_usage'))
{
if ($memory_usage = memory_get_usage())
{
global $base_memory_usage;
$memory_usage -= $base_memory_usage;
$memory_usage -= phpbb::$base_config['memory_usage'];
$memory_usage = get_formatted_filesize($memory_usage);
$debug_output .= ' | Memory Usage: ' . $memory_usage;
@@ -2553,10 +2552,10 @@ function page_footer($run_cron = true)
}
phpbb::$template->assign_vars(array(
'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '',
'DEBUG_OUTPUT' => (phpbb::$base_config['debug']) ? $debug_output : '',
'TRANSLATION_INFO' => (!empty(phpbb::$user->lang['TRANSLATION_INFO'])) ? phpbb::$user->lang['TRANSLATION_INFO'] : '',
'U_ACP' => (phpbb::$acl->acl_get('a_') && !empty(phpbb::$user->is_registered)) ? phpbb::$url->append_sid(CONFIG_ADM_FOLDER . '/index', false, true, phpbb::$user->session_id) : '',
'U_ACP' => (phpbb::$acl->acl_get('a_') && !empty(phpbb::$user->is_registered)) ? phpbb::$url->append_sid(phpbb::$base_config['admin_folder'] . '/index', false, true, phpbb::$user->session_id) : '',
));
// Call cron-type script

View File

@@ -2707,8 +2707,6 @@ function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limi
*/
function get_database_size()
{
global $table_prefix;
$database_size = false;
// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0
@@ -2737,9 +2735,9 @@ function get_database_size()
{
if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB')))
{
if ($table_prefix != '')
if (phpbb::$base_config['table_prefix'] != '')
{
if (strpos($row['Name'], $table_prefix) !== false)
if (strpos($row['Name'], phpbb::$base_config['table_prefix']) !== false)
{
$database_size += $row['Data_length'] + $row['Index_length'];
}