diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-01-21 14:33:07 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-01-21 14:33:07 +0000 |
commit | 5bea3ea3b430c0e9de46154ecd638092b67dc8eb (patch) | |
tree | 9dab17bf316470c693c5cb4d928a1aac2ce9d640 /phpBB/common.php | |
parent | 8c31649706cf4d01c82f1e1b72d806f37359d670 (diff) | |
download | forums-5bea3ea3b430c0e9de46154ecd638092b67dc8eb.tar forums-5bea3ea3b430c0e9de46154ecd638092b67dc8eb.tar.gz forums-5bea3ea3b430c0e9de46154ecd638092b67dc8eb.tar.bz2 forums-5bea3ea3b430c0e9de46154ecd638092b67dc8eb.tar.xz forums-5bea3ea3b430c0e9de46154ecd638092b67dc8eb.zip |
Re-jiggle where acl_option caching is done, move to common in-keeping with config
git-svn-id: file:///svn/phpbb/trunk@3341 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/common.php')
-rw-r--r-- | phpBB/common.php | 106 |
1 files changed, 47 insertions, 59 deletions
diff --git a/phpBB/common.php b/phpBB/common.php index f56569f8e1..072333141d 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -19,7 +19,7 @@ * ***************************************************************************/ -if ( !defined('IN_PHPBB') ) +if (!defined('IN_PHPBB')) { die('Hacking attempt'); } @@ -29,7 +29,7 @@ error_reporting(E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitia set_magic_quotes_runtime(0); // If magic quotes is off, addslashes -if ( !get_magic_quotes_gpc() ) +if (!get_magic_quotes_gpc()) { $_GET = slash_input_data($_GET); $_POST = slash_input_data($_POST); @@ -37,9 +37,8 @@ if ( !get_magic_quotes_gpc() ) } require($phpbb_root_path . 'config.'.$phpEx); -//require($phpbb_root_path . 'config_cache.'.$phpEx); -if ( !defined('PHPBB_INSTALLED') ) +if (!defined('PHPBB_INSTALLED')) { header('Location: install/install.'.$phpEx); exit; @@ -47,10 +46,10 @@ if ( !defined('PHPBB_INSTALLED') ) // Include files require($phpbb_root_path . 'includes/acm/cache_' . $acm_type . '.'.$phpEx); +require($phpbb_root_path . 'db/' . $dbms . '.'.$phpEx); require($phpbb_root_path . 'includes/template.'.$phpEx); require($phpbb_root_path . 'includes/session.'.$phpEx); require($phpbb_root_path . 'includes/functions.'.$phpEx); -require($phpbb_root_path . 'db/' . $dbms . '.'.$phpEx); // User related define('ANONYMOUS', 0); @@ -90,10 +89,6 @@ define('POST_ANNOUNCE', 2); define('LASTREAD_NORMAL', 0); // not used at the moment define('LASTREAD_POSTED', 1); -// Error codes -define('MESSAGE', 200); -define('ERROR', 201); - // Private messaging define('PRIVMSGS_READ_MAIL', 0); define('PRIVMSGS_NEW_MAIL', 1); @@ -140,7 +135,7 @@ define('USERS_TABLE', $table_prefix.'users'); define('WORDS_TABLE', $table_prefix.'words'); define('POLL_OPTIONS_TABLE', $table_prefix.'poll_results'); define('POLL_VOTES_TABLE', $table_prefix.'poll_voters'); - +// Unnecessary define('VOTE_DESC_TABLE', $table_prefix.'vote_desc'); define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results'); define('VOTE_USERS_TABLE', $table_prefix.'vote_voters'); @@ -148,64 +143,61 @@ define('VOTE_USERS_TABLE', $table_prefix.'vote_voters'); // Set PHP error handler to ours set_error_handler('msg_handler'); -// Experimental cache manager -$cache = new acm(); +// Instantiate some basic classes +$user = new user(); +$auth = new auth(); // Need these here so instantiate them now +$cache = new acm();// Experimental cache manager $template = new Template(); $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); -/* -// Obtain boardwide default config (rebuilding cache if reqd) -if ( empty($config) ) -{ - require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); - $config = config_config(); -} - -$sql = "SELECT * - FROM " . CONFIG_TABLE . " - WHERE is_dynamic = 1"; -$result = $db->sql_query($sql, false); - -while ( $row = $db->sql_fetchrow($result) ) -{ - $config[$row['config_name']] = $row['config_value']; -} - -// Re-cache acl options if reqd -if ( empty($acl_options) ) -{ - require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); - $auth_admin = new auth_admin(); - $acl_options = $auth_admin->acl_cache_options(); -} -*/ - -if (!$config = $cache->get('config')) +// Grab global variables, re-cache if necessary +if (!($config = $cache->get('config'))) { $config = array(); - $sql = 'SELECT * FROM ' . CONFIG_TABLE; +/* + WHERE is_dynamic = 1'; +*/ + $sql = 'SELECT * + FROM ' . CONFIG_TABLE; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $config[$row['config_name']] = $row['config_value']; } + $db->sql_freeresult($result); $cache->put('config', $config); } -if ($cache->exists('acl_options')) +if (!($acl_options = $cache->get('acl_options'))) { - $acl_options = $cache->get('acl_options'); -} -else -{ - require_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - $auth_admin = new auth_admin(); - $acl_options = $auth_admin->acl_cache_options(); + $acl_options = array(); + + $sql = "SELECT auth_value, is_global, is_local + FROM " . ACL_OPTIONS_TABLE . " + ORDER BY auth_option_id"; + $result = $db->sql_query($sql); + + $global = $local = 0; + while ($row = $db->sql_fetchrow($result)) + { + if (!empty($row['is_global'])) + { + $acl_options['global'][$row['auth_value']] = $global++; + } + if (!empty($row['is_local'])) + { + $acl_options['local'][$row['auth_value']] = $local++; + } + } + $db->sql_freeresult($result); + + $cache->put('acl_options', $acl_options); + $auth->acl_clear_prefetch(); } /* @@ -215,28 +207,24 @@ if (time() - $config['cache_interval'] >= $config['cache_last_gc']) } */ -// Instantiate some basic classes -$user = new user(); -$auth = new auth(); - // Show 'Board is disabled' message -if ( $config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN') ) +if ($config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN')) { - $message = ( !empty($config['board_disable_msg']) ) ? $config['board_disable_msg'] : 'Board_disable'; + $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'Board_disable'; trigger_error($message); } // addslashes to vars if magic_quotes_gpc is off function slash_input_data(&$data) { - if ( is_array($data) ) + if (is_array($data)) { - foreach ( $data as $k => $v ) + foreach ($data as $k => $v) { - $data[$k] = ( is_array($v) ) ? slash_input_data($v) : addslashes($v); + $data[$k] = (is_array($v)) ? slash_input_data($v) : addslashes($v); } } return $data; } -?> +?>
\ No newline at end of file |