diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2008-12-28 13:27:58 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2008-12-28 13:27:58 +0000 |
commit | 889fa871402814874d5d4f01b2f1c829d8206eb9 (patch) | |
tree | ce3d6b9c23a6df118c1458cc7adeafa10ffde5a8 /phpBB | |
parent | fbaf2baa8d683a2afdd3cf98ea1e7c035369f1a3 (diff) | |
download | forums-889fa871402814874d5d4f01b2f1c829d8206eb9.tar forums-889fa871402814874d5d4f01b2f1c829d8206eb9.tar.gz forums-889fa871402814874d5d4f01b2f1c829d8206eb9.tar.bz2 forums-889fa871402814874d5d4f01b2f1c829d8206eb9.tar.xz forums-889fa871402814874d5d4f01b2f1c829d8206eb9.zip |
implement new phpbb::$acm object, replacing $cache global
git-svn-id: file:///svn/phpbb/trunk@9240 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
57 files changed, 523 insertions, 754 deletions
diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 14d5da9882..be11528a60 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -166,7 +166,7 @@ function adm_page_header($page_title) */ function adm_page_footer($copyright_html = true) { - global $db, $config, $template, $user, $auth, $cache; + global $db, $config, $template, $user, $auth; global $starttime; // Output page creation time diff --git a/phpBB/common.php b/phpBB/common.php index 328125999c..b898effead 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -69,7 +69,7 @@ phpbb_request::disable_super_globals(); if (!empty($dbms)) { // Register DB object. - phpbb::assign('db', phpbb_db_dbal::connect($dbms, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false)); + //phpbb::assign('db', phpbb_db_dbal::connect($dbms, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false)); } // We do not need the db password any longer, unset for safety purposes diff --git a/phpBB/cron.php b/phpBB/cron.php index 324437d812..aa16453002 100644 --- a/phpBB/cron.php +++ b/phpBB/cron.php @@ -101,18 +101,18 @@ switch ($cron_type) case 'tidy_cache': - if (time() - $config['cache_gc'] <= $config['cache_last_gc'] || !method_exists($cache, 'tidy')) + if (time() - $config['cache_gc'] <= $config['cache_last_gc'] || !method_exists(phpbb::$acm, 'tidy')) { break; } if ($use_shutdown_function) { - register_shutdown_function(array(&$cache, 'tidy')); + register_shutdown_function(array(&phpbb::$acm, 'tidy')); } else { - $cache->tidy(); + phpbb::$acm->tidy(); } break; diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 47ccff3b65..9dfdf6a5ae 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -656,12 +656,16 @@ function set_modified_headers($stamp, $browser) function file_gc() { - global $cache, $db; - if (!empty($cache)) + if (phpbb::registered('acm')) { - $cache->unload(); + phpbb::$acm->unload(); } - $db->sql_close(); + + if (phpbb::registered('db')) + { + phpbb::$db->sql_close(); + } + exit; } diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 23183d1865..e05977d158 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -17,67 +17,155 @@ if (!defined('IN_PHPBB')) } /** -* ACM File Based Caching +* Define file-based cache. * @package acm */ -class acm +class phpbb_acm_file extends phpbb_acm_abstract { - private $vars = array(); - private $var_expires = array(); - private $is_modified = false; - - public $sql_rowset = array(); + /** + * @var string The cache directory to use + */ public $cache_dir = ''; /** - * Set cache path + * @var array|bool The cache types this class supports. True indicates support for all types. + */ + public $supported = true; + + /** + * Set cache directory + * + * @param string $cache_prefix The cache prefix the instance is responsible for + * @access public */ - function __construct() + public function __construct($cache_prefix) { $this->cache_dir = PHPBB_ROOT_PATH . 'cache/'; + $this->cache_prefix = $cache_prefix; } /** - * Load global cache + * {@link phpbb_acm_abstract::get() get()} */ - private function load() + public function get($var_name) { - // grab the global cache - if (file_exists($this->cache_dir . 'data_global.' . PHP_EXT)) + if ($var_name[0] === '#') { - @include($this->cache_dir . 'data_global.' . PHP_EXT); - return true; + $var_name = substr($var_name, 1); + return $this->get_global($var_name); } - return false; + if (!$this->exists($var_name)) + { + return false; + } + + @include($this->cache_dir . $this->cache_prefix . '_' . $var_name . '.' . PHP_EXT); + + // If no data there, then the file expired... + if ($expired) + { + // Destroy + $this->destroy($var_name); + return false; + } + + return $data; } /** - * Unload cache object + * {@link phpbb_acm_abstract::put() put()} */ - public function unload() + public function put($var_name, $data, $ttl = 31536000) + { + if ($var_name[0] === '#') + { + $var_name = substr($var_name, 1); + return $this->put_global($var_name, $data, $ttl); + } + + $filename = $this->cache_dir . $this->cache_prefix . '_' . $var_name . '.' . PHP_EXT; + + if ($fp = @fopen($filename, 'wb')) + { + @flock($fp, LOCK_EX); + fwrite($fp, "<?php\n\$expired = (time() > " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\$data = " . (sizeof($data) ? "unserialize(" . var_export(serialize($data), true) . ");" : 'array();')); + @flock($fp, LOCK_UN); + fclose($fp); + + if (!function_exists('phpbb_chmod')) + { + include(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT); + } + + phpbb_chmod($filename, phpbb::CHMOD_WRITE); + } + + return $data; + } + + + /** + * {@link phpbb_acm_abstract::exists() exists()} + */ + public function exists($var_name) + { + if ($var_name[0] === '#') + { + $var_name = substr($var_name, 1); + return $this->exists_global($var_name); + } + + return file_exists($this->cache_dir . $this->cache_prefix . '_' . $var_name . '.' . PHP_EXT); + } + + /** + * {@link phpbb_acm_abstract::destroy() destroy()} + */ + public function destroy($var_name) + { + if ($var_name[0] === '#') + { + $var_name = substr($var_name, 1); + $this->destroy_global($var_name); + } + + if (!$this->exists($var_name)) + { + return false; + } + + $this->remove_file($this->cache_dir . $this->cache_prefix . '_' . $var_name . '.' . PHP_EXT, true); + } + + /** + * {@link phpbb_acm_abstract::load() load()} + */ + public function load() { - $this->save(); - unset($this->vars); - unset($this->var_expires); - unset($this->sql_rowset); - - $this->vars = array(); - $this->var_expires = array(); - $this->sql_rowset = array(); + // grab the global cache + if (file_exists($this->cache_dir . $this->cache_prefix . '_global.' . PHP_EXT)) + { + @include($this->cache_dir . $this->cache_prefix . '_global.' . PHP_EXT); + return true; + } + + return false; } /** - * Save modified objects + * {@link phpbb_acm_abstract::unload() unload()} */ - private function save() + public function unload() { if (!$this->is_modified) { return; } - if ($fp = @fopen($this->cache_dir . 'data_global.' . PHP_EXT, 'wb')) + $filename = $this->cache_dir . $this->cache_prefix . '_global.' . PHP_EXT; + + if ($fp = @fopen($filename, 'wb')) { @flock($fp, LOCK_EX); fwrite($fp, "<?php\n\$this->vars = unserialize(" . var_export(serialize($this->vars), true) . ");\n\$this->var_expires = unserialize(" . var_export(serialize($this->var_expires), true) . ");"); @@ -89,7 +177,7 @@ class acm include(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT); } - phpbb_chmod($this->cache_dir . 'data_global.' . PHP_EXT, phpbb::CHMOD_WRITE); + phpbb_chmod($filename, phpbb::CHMOD_WRITE); } else { @@ -99,16 +187,20 @@ class acm trigger_error($this->cache_dir . ' is NOT writable.', E_USER_ERROR); } - trigger_error('Not able to open ' . $this->cache_dir . 'data_global.' . PHP_EXT, E_USER_ERROR); + trigger_error('Not able to open ' . $filename, E_USER_ERROR); } $this->is_modified = false; + + // To reset the global vars + $this->vars = $this->var_expires = array(); } /** - * Tidy cache + * Tidy local cache data. Also see {@link phpbb_acm_abstract::tidy() tidy()} + * @access protected */ - public function tidy() + protected function tidy_local() { $dir = @opendir($this->cache_dir); @@ -119,96 +211,28 @@ class acm while (($entry = readdir($dir)) !== false) { - if (!preg_match('/^(sql_|data_(?!global))/', $entry)) + if (strpos($entry, $this->cache_prefix . '_') !== 0 || strpos($entry, $this->cache_prefix . '_global') === 0) { continue; } $expired = true; @include($this->cache_dir . $entry); + if ($expired) { $this->remove_file($this->cache_dir . $entry); } } closedir($dir); - - if (file_exists($this->cache_dir . 'data_global.' . PHP_EXT)) - { - if (!sizeof($this->vars)) - { - $this->load(); - } - - foreach ($this->var_expires as $var_name => $expires) - { - if (time() > $expires) - { - $this->destroy($var_name); - } - } - } - - set_config('cache_last_gc', time(), true); - } - - /** - * Get saved cache object - */ - public function get($var_name) - { - if ($var_name[0] === '_') - { - if (!$this->_exists($var_name)) - { - return false; - } - - @include($this->cache_dir . "data{$var_name}." . PHP_EXT); - return (isset($data)) ? $data : false; - } - else - { - return ($this->_exists($var_name)) ? $this->vars[$var_name] : false; - } } /** - * Put data into cache + * Purge local cache data. Also see {@link phpbb_acm_abstract::purge() purge()} + * @access protected */ - function put($var_name, $var, $ttl = 31536000) + protected function purge_local() { - if ($var_name[0] === '_') - { - if ($fp = @fopen($this->cache_dir . "data{$var_name}." . PHP_EXT, 'wb')) - { - @flock($fp, LOCK_EX); - fwrite($fp, "<?php\n\$expired = (time() > " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\$data = " . (sizeof($var) ? "unserialize(" . var_export(serialize($var), true) . ");" : 'array();')); - @flock($fp, LOCK_UN); - fclose($fp); - - if (!function_exists('phpbb_chmod')) - { - include(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT); - } - - phpbb_chmod($this->cache_dir . "data{$var_name}." . PHP_EXT, phpbb::CHMOD_WRITE); - } - } - else - { - $this->vars[$var_name] = $var; - $this->var_expires[$var_name] = time() + $ttl; - $this->is_modified = true; - } - } - - /** - * Purge cache data - */ - public function purge() - { - // Purge all phpbb cache files $dir = @opendir($this->cache_dir); if (!$dir) @@ -218,7 +242,7 @@ class acm while (($entry = readdir($dir)) !== false) { - if (strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) + if (strpos($entry, $this->cache_prefix . '_') !== 0 || strpos($entry, $this->cache_prefix . '_global') === 0) { continue; } @@ -226,240 +250,101 @@ class acm $this->remove_file($this->cache_dir . $entry); } closedir($dir); - - unset($this->vars); - unset($this->var_expires); - unset($this->sql_rowset); - - $this->vars = array(); - $this->var_expires = array(); - $this->sql_rowset = array(); - - $this->is_modified = false; } /** - * Destroy cache data + * Get modified date for cache entry + * + * @param string $var_name The cache variable name + * @access public */ - public function destroy($var_name, $table = '') + public function get_modified_date($var_name) { - if ($var_name === 'sql' && !empty($table)) - { - if (!is_array($table)) - { - $table = array($table); - } - - $dir = @opendir($this->cache_dir); - - if (!$dir) - { - return; - } - - while (($entry = readdir($dir)) !== false) - { - if (strpos($entry, 'sql_') !== 0) - { - continue; - } - - // The following method is more failproof than simply assuming the query is on line 3 (which it should be) - $check_line = @file_get_contents($this->cache_dir . $entry); - - if (empty($check_line)) - { - continue; - } - - // Now get the contents between /* and */ - $check_line = substr($check_line, strpos($check_line, '/* ') + 3, strpos($check_line, ' */') - strpos($check_line, '/* ') - 3); - - $found = false; - foreach ($table as $check_table) - { - // Better catch partial table names than no table names. ;) - if (strpos($check_line, $check_table) !== false) - { - $found = true; - break; - } - } - - if ($found) - { - $this->remove_file($this->cache_dir . $entry); - } - } - closedir($dir); - - return; - } - - if (!$this->_exists($var_name)) - { - return; - } - - if ($var_name[0] === '_') - { - $this->remove_file($this->cache_dir . 'data' . $var_name . '.' . PHP_EXT, true); - } - else if (isset($this->vars[$var_name])) - { - $this->is_modified = true; - unset($this->vars[$var_name]); - unset($this->var_expires[$var_name]); - - // We save here to let the following cache hits succeed - $this->save(); - } + return @filemtime($this->cache_dir . $this->cache_prefix . '_' . $var_name . '.' . PHP_EXT); } /** - * Check if a given cache entry exist + * Removes/unlinks file + * + * @param string $filename The filename to remove + * @param bool $check If true the cache directory is checked for correct directory permissions. + * @access protected */ - private function _exists($var_name) + protected function remove_file($filename, $check = false) { - if ($var_name[0] === '_') + if ($check && !@is_writable($this->cache_dir)) { - return file_exists($this->cache_dir . 'data' . $var_name . '.' . PHP_EXT); + // E_USER_ERROR - not using language entry - intended. + trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); } - else - { - if (!sizeof($this->vars)) - { - $this->load(); - } - - if (!isset($this->var_expires[$var_name])) - { - return false; - } - return (time() > $this->var_expires[$var_name]) ? false : isset($this->vars[$var_name]); - } + return @unlink($filename); } +} +/** +* Special implementation for cache type 'sql' +* @package acm +*/ +class phpbb_acm_file_sql extends phpbb_acm_file +{ /** - * Load cached sql query + * {@link phpbb_acm_abstract::destroy() destroy()} */ - public function sql_load($query) + public function destroy($var_name) { - // Remove extra spaces and tabs - $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = sizeof($this->sql_rowset); - - if (!file_exists($this->cache_dir . 'sql_' . md5($query) . '.' . PHP_EXT)) + if ($var_name[0] === '#') { - return false; + $var_name = substr($var_name, 1); + $this->destroy_global($var_name); } - @include($this->cache_dir . 'sql_' . md5($query) . '.' . PHP_EXT); + $table = (!is_array($var_name)) ? array($var_name) : $var_name; + $dir = @opendir($this->cache_dir); - if (!isset($expired)) - { - return false; - } - else if ($expired) + if (!$dir) { - $this->remove_file($this->cache_dir . 'sql_' . md5($query) . '.' . PHP_EXT, true); - return false; + return; } - - return $query_id; - } - - /** - * Save sql query - */ - public function sql_save($query, &$query_result, $ttl) - { - global $db; - - // Remove extra spaces and tabs - $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $filename = $this->cache_dir . 'sql_' . md5($query) . '.' . PHP_EXT; - - if ($fp = @fopen($filename, 'wb')) + while (($entry = readdir($dir)) !== false) { - @flock($fp, LOCK_EX); - - $query_id = sizeof($this->sql_rowset); - $this->sql_rowset[$query_id] = array(); - - while ($row = $db->sql_fetchrow($query_result)) + if (strpos($entry, $this->cache_prefix . '_') !== 0) { - $this->sql_rowset[$query_id][] = $row; + continue; } - $db->sql_freeresult($query_result); - $file = "<?php\n/* " . str_replace('*/', '*\/', $query) . " */"; - $file .= "\n\$expired = (time() > " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n"; - - fwrite($fp, $file . "\$this->sql_rowset[\$query_id] = " . (sizeof($this->sql_rowset[$query_id]) ? "unserialize(" . var_export(serialize($this->sql_rowset[$query_id]), true) . ");" : 'array();')); - @flock($fp, LOCK_UN); - fclose($fp); + // The following method is more failproof than simply assuming the query is on line 3 (which it should be) + @include($this->cache_dir . $entry); - if (!function_exists('phpbb_chmod')) + if (empty($data)) { - include(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT); + $this->remove_file($this->cache_dir . $entry); + continue; } - phpbb_chmod($filename, phpbb::CHMOD_WRITE); - - $query_result = $query_id; - } - } - - /** - * Fetch row from cache (database) - */ - public function sql_fetchrow($query_id) - { - list(, $row) = each($this->sql_rowset[$query_id]); - - return ($row !== NULL) ? $row : false; - } - - /** - * Fetch a field from the current row of a cached database result (database) - */ - public function sql_fetchfield($query_id, $field) - { - $row = current($this->sql_rowset[$query_id]); - - return ($row !== false && isset($row[$field])) ? $row[$field] : false; - } - - /** - * Free memory used for a cached database result (database) - */ - public function sql_freeresult($query_id) - { - if (!isset($this->sql_rowset[$query_id])) - { - return false; - } + // Get the query + $data = $data['query']; - unset($this->sql_rowset[$query_id]); - - return true; - } + $found = false; + foreach ($table as $check_table) + { + // Better catch partial table names than no table names. ;) + if (strpos($data, $check_table) !== false) + { + $found = true; + break; + } + } - /** - * Removes/unlinks file - */ - private function remove_file($filename, $check = false) - { - if ($check && !@is_writable($this->cache_dir)) - { - // E_USER_ERROR - not using language entry - intended. - trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); + if ($found) + { + $this->remove_file($this->cache_dir . $entry); + } } + closedir($dir); - return @unlink($filename); + return; } } diff --git a/phpBB/includes/classes/acl.php b/phpBB/includes/classes/acl.php index 226bb8be23..97a7b02d41 100644 --- a/phpBB/includes/classes/acl.php +++ b/phpBB/includes/classes/acl.php @@ -17,36 +17,38 @@ if (!defined('IN_PHPBB')) } /** -* Permission/Auth class +* Permission/ACL class * @package phpBB3 */ -class auth +class phpbb_acl { + public $phpbb_required = array('acm', 'db'); + public $phpbb_optional = array(); + + public $acl_raw; + private $acl = array(); private $cache = array(); public $acl_options = array(); - private $acl_forum_ids = false; + private $acl_element_ids = false; + private $recache = false; - /** - * Init permissions - */ - function acl(array &$userdata) + public function __construct() { - global $db, $cache; - $this->acl = $this->cache = $this->acl_options = array(); - $this->acl_forum_ids = false; + $this->acl_element_ids = false; - if (($this->acl_options = $cache->get('_acl_options')) === false) + if (($this->acl_options = phpbb::$acm->get('acl_options')) === false) { $sql = 'SELECT auth_option_id, auth_option, is_global, is_local FROM ' . ACL_OPTIONS_TABLE . ' ORDER BY auth_option_id'; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); $global = $local = 0; $this->acl_options = array(); - while ($row = $db->sql_fetchrow($result)) + + while ($row = phpbb::$db->sql_fetchrow($result)) { if ($row['is_global']) { @@ -61,12 +63,22 @@ class auth $this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id']; $this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); - $cache->put('_acl_options', $this->acl_options); - $this->acl_cache($userdata); + phpbb::$acm->put('acl_options', $this->acl_options); + $this->recache = true; } - else if (!trim($userdata['user_permissions'])) + + // Add raw data acl class + $this->acl_raw = new phpbb_acl_raw_data(); + } + + /** + * Init permissions + */ + public function init(array &$userdata) + { + if (!trim($userdata['user_permissions']) || $this->recache) { $this->acl_cache($userdata); } @@ -150,7 +162,6 @@ class auth $opt = substr($opt, 1); } - // @todo: use the ref technique to reduce opcode generation if (!isset($this->cache[$f][$opt])) { // We combine the global/local option with an OR because some options are global and local. @@ -203,23 +214,21 @@ class auth { if ($this->acl_forum_ids === false) { - global $db; - $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE; if (sizeof($this->acl)) { - $sql .= ' WHERE ' . $db->sql_in_set('forum_id', array_keys($this->acl), true); + $sql .= ' WHERE ' . phpbb::$db->sql_in_set('forum_id', array_keys($this->acl), true); } - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); $this->acl_forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $this->acl_forum_ids[] = $row['forum_id']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); } } @@ -342,11 +351,11 @@ class auth { if ($user_id !== false && !is_array($user_id) && $opts === false && $forum_id === false) { - $hold_ary = array($user_id => $this->acl_raw_data_single_user($user_id)); + $hold_ary = array($user_id => $this->acl_raw->single_user($user_id)); } else { - $hold_ary = $this->acl_raw_data($user_id, $opts, $forum_id); + $hold_ary = $this->acl_raw->data($user_id, $opts, $forum_id); } $auth_ary = array(); @@ -372,17 +381,15 @@ class auth */ public function acl_cache(array &$userdata) { - global $db; - // Empty user_permissions $userdata['user_permissions'] = ''; - $hold_ary = $this->acl_raw_data_single_user($userdata['user_id']); + $hold_ary = $this->acl_raw->single_user($userdata['user_id']); // Key 0 in $hold_ary are global options, all others are forum_ids // If this user is founder we're going to force fill the admin options ... - if ($userdata['user_type'] == phpbb::USER_FOUNDER) + if ($userdata['user_type'] == USER_FOUNDER) { foreach ($this->acl_options['global'] as $opt => $id) { @@ -400,10 +407,10 @@ class auth $userdata['user_permissions'] = $hold_str; $sql = 'UPDATE ' . USERS_TABLE . " - SET user_permissions = '" . $db->sql_escape($userdata['user_permissions']) . "', + SET user_permissions = '" . phpbb::$db->sql_escape($userdata['user_permissions']) . "', user_perm_from = 0 WHERE user_id = " . $userdata['user_id']; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); } return; @@ -475,29 +482,27 @@ class auth */ public function acl_clear_prefetch($user_id = false) { - global $db, $cache; - // Rebuild options cache - $cache->destroy('_role_cache'); + phpbb::$acm->destroy('role_cache'); $sql = 'SELECT * FROM ' . ACL_ROLES_DATA_TABLE . ' ORDER BY role_id ASC'; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); $this->role_cache = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); foreach ($this->role_cache as $role_id => $role_options) { $this->role_cache[$role_id] = serialize($role_options); } - $cache->put('_role_cache', $this->role_cache); + phpbb::$acm->put('role_cache', $this->role_cache); // Now empty user permissions $where_sql = ''; @@ -505,62 +510,72 @@ class auth if ($user_id !== false) { $user_id = (!is_array($user_id)) ? $user_id = array((int) $user_id) : array_map('intval', $user_id); - $where_sql = ' WHERE ' . $db->sql_in_set('user_id', $user_id); + $where_sql = ' WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id); } $sql = 'UPDATE ' . USERS_TABLE . " SET user_permissions = '', user_perm_from = 0 $where_sql"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); return; } +/** +} + + * Role-specific methods/definitionis used by phpbb_acl +class phpbb_acl_role +{ + */ + /** * Get assigned roles * @todo: protected or public? */ public function acl_role_data($user_type, $role_type, $ug_id = false, $forum_id = false) { - global $db; - $roles = array(); $sql_id = ($user_type == 'user') ? 'user_id' : 'group_id'; - $sql_ug = ($ug_id !== false) ? ((!is_array($ug_id)) ? "AND a.$sql_id = $ug_id" : 'AND ' . $db->sql_in_set("a.$sql_id", $ug_id)) : ''; - $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? "AND a.forum_id = $forum_id" : 'AND ' . $db->sql_in_set('a.forum_id', $forum_id)) : ''; + $sql_ug = ($ug_id !== false) ? ((!is_array($ug_id)) ? "AND a.$sql_id = $ug_id" : 'AND ' . phpbb::$db->sql_in_set("a.$sql_id", $ug_id)) : ''; + $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? "AND a.forum_id = $forum_id" : 'AND ' . phpbb::$db->sql_in_set('a.forum_id', $forum_id)) : ''; // Grab assigned roles... $sql = 'SELECT a.auth_role_id, a.' . $sql_id . ', a.forum_id FROM ' . (($user_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE) . ' a, ' . ACL_ROLES_TABLE . " r WHERE a.auth_role_id = r.role_id - AND r.role_type = '" . $db->sql_escape($role_type) . "' + AND r.role_type = '" . phpbb::$db->sql_escape($role_type) . "' $sql_ug $sql_forum ORDER BY r.role_order ASC"; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $roles[$row[$sql_id]][$row['forum_id']] = $row['auth_role_id']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); return $roles; } +} +/** +* data-specific methods/definitionis used by phpbb_acl +*/ +class phpbb_acl_raw_data +{ /** * Get raw acl data based on user/option/forum * @todo: protected or public? */ - public function acl_raw_data($user_id = false, $opts = false, $forum_id = false) + public function data($user_id = false, $opts = false, $forum_id = false) { - global $db; - - $sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : $db->sql_in_set('user_id', array_map('intval', $user_id))) : ''; - $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; + $sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : phpbb::$db->sql_in_set('user_id', array_map('intval', $user_id))) : ''; + $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . phpbb::$db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; $sql_opts = $sql_opts_select = $sql_opts_from = ''; $hold_ary = array(); @@ -594,14 +609,14 @@ class auth foreach ($sql_ary as $sql) { - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']]; $hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); } $sql_ary = array(); @@ -630,9 +645,9 @@ class auth foreach ($sql_ary as $sql) { - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']]; @@ -641,7 +656,7 @@ class auth { $hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting']; - // If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again) + // If we detect phpbb::ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again) if ($row['auth_setting'] == phpbb::ACL_NEVER) { $flag = substr($option, 0, strpos($option, '_') + 1); @@ -659,7 +674,7 @@ class auth } } } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); } return $hold_ary; @@ -668,12 +683,10 @@ class auth /** * Get raw user based permission settings */ - public function acl_user_raw_data($user_id = false, $opts = false, $forum_id = false) + public function user($user_id = false, $opts = false, $forum_id = false) { - global $db; - - $sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : $db->sql_in_set('user_id', array_map('intval', $user_id))) : ''; - $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; + $sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : phpbb::$db->sql_in_set('user_id', array_map('intval', $user_id))) : ''; + $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . phpbb::$db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; $sql_opts = ''; $hold_ary = $sql_ary = array(); @@ -705,13 +718,13 @@ class auth foreach ($sql_ary as $sql) { - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] = $row['auth_setting']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); } return $hold_ary; @@ -720,12 +733,10 @@ class auth /** * Get raw group based permission settings */ - public function acl_group_raw_data($group_id = false, $opts = false, $forum_id = false) + public function group($group_id = false, $opts = false, $forum_id = false) { - global $db; - - $sql_group = ($group_id !== false) ? ((!is_array($group_id)) ? 'group_id = ' . (int) $group_id : $db->sql_in_set('group_id', array_map('intval', $group_id))) : ''; - $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; + $sql_group = ($group_id !== false) ? ((!is_array($group_id)) ? 'group_id = ' . (int) $group_id : phpbb::$db->sql_in_set('group_id', array_map('intval', $group_id))) : ''; + $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . phpbb::$db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : ''; $sql_opts = ''; $hold_ary = $sql_ary = array(); @@ -757,13 +768,13 @@ class auth foreach ($sql_ary as $sql) { - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $hold_ary[$row['group_id']][$row['forum_id']][$row['auth_option']] = $row['auth_setting']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); } return $hold_ary; @@ -771,14 +782,12 @@ class auth /** * Get raw acl data based on user for caching user_permissions - * This function returns the same data as acl_raw_data(), but without the user id as the first key within the array. + * This function returns the same data as data(), but without the user id as the first key within the array. */ - public function acl_raw_data_single_user($user_id) + public function single_user($user_id) { - global $db, $cache; - // Check if the role-cache is there - if (($this->role_cache = $cache->get('_role_cache')) === false) + if (($this->role_cache = phpbb::$acm->get('role_cache')) === false) { $this->role_cache = array(); @@ -786,20 +795,20 @@ class auth $sql = 'SELECT * FROM ' . ACL_ROLES_DATA_TABLE . ' ORDER BY role_id ASC'; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); foreach ($this->role_cache as $role_id => $role_options) { $this->role_cache[$role_id] = serialize($role_options); } - $cache->put('_role_cache', $this->role_cache); + phpbb::$acm->put('role_cache', $this->role_cache); } $hold_ary = array(); @@ -808,9 +817,9 @@ class auth $sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting FROM ' . ACL_USERS_TABLE . ' WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { // If a role is assigned, assign all options included within this role. Else, only set this one option. if ($row['auth_role_id']) @@ -822,7 +831,7 @@ class auth $hold_ary[$row['forum_id']][$row['auth_option_id']] = $row['auth_setting']; } } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); // Now grab group-specific permission settings $sql = 'SELECT a.forum_id, a.auth_option_id, a.auth_role_id, a.auth_setting @@ -830,9 +839,9 @@ class auth WHERE a.group_id = ug.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user_id; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { if (!$row['auth_role_id']) { @@ -846,7 +855,7 @@ class auth } } } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); return $hold_ary; } @@ -860,7 +869,7 @@ class auth { $hold_ary[$option_id] = $setting; - // If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again) + // If we detect phpbb::ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again) if ($setting == phpbb::ACL_NEVER) { $flag = substr($this->acl_options['option'][$option_id], 0, strpos($this->acl_options['option'][$option_id], '_') + 1); @@ -881,123 +890,19 @@ class auth } /** - * Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him. - */ - public function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0) - { - global $config, $db, $user; - - $method = trim(basename($config['auth_method'])); - include_once(PHPBB_ROOT_PATH . 'includes/auth/auth_' . $method . '.' . PHP_EXT); - - $method = 'login_' . $method; - if (function_exists($method)) - { - $login = $method($username, $password); - - // If the auth module wants us to create an empty profile do so and then treat the status as LOGIN_SUCCESS - if ($login['status'] == LOGIN_SUCCESS_CREATE_PROFILE) - { - // we are going to use the user_add function so include functions_user.php if it wasn't defined yet - if (!function_exists('user_add')) - { - include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); - } - - user_add($login['user_row'], (isset($login['cp_data'])) ? $login['cp_data'] : false); - - $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'AUTH_NO_PROFILE_CREATED', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $login = array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ); - } - - // If login succeeded, we will log the user in... else we pass the login array through... - if ($login['status'] == LOGIN_SUCCESS) - { - $old_session_id = $user->session_id; - - if ($admin) - { - global $SID, $_SID; - - $cookie_expire = time() - 31536000; - $user->set_cookie('u', '', $cookie_expire); - $user->set_cookie('sid', '', $cookie_expire); - unset($cookie_expire); - - $SID = '?sid='; - $user->session_id = $_SID = ''; - } - - $result = $user->session_create($login['user_row']['user_id'], $admin, $autologin, $viewonline); - - // Successful session creation - if ($result === true) - { - // If admin re-authentication we remove the old session entry because a new one has been created... - if ($admin) - { - // the login array is used because the user ids do not differ for re-authentication - $sql = 'DELETE FROM ' . SESSIONS_TABLE . " - WHERE session_id = '" . $db->sql_escape($old_session_id) . "' - AND session_user_id = {$login['user_row']['user_id']}"; - $db->sql_query($sql); - } - - return array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $login['user_row'], - ); - } - - return array( - 'status' => LOGIN_BREAK, - 'error_msg' => $result, - 'user_row' => $login['user_row'], - ); - } - - return $login; - } - - trigger_error('Authentication method not found', E_USER_ERROR); - } - - /** * Fill auth_option statement for later querying based on the supplied options */ private function build_auth_option_statement($key, $auth_options, &$sql_opts) { - global $db; - if (!is_array($auth_options)) { if (strpos($auth_options, '%') !== false) { - $sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->any_char, $auth_options)); + $sql_opts = "AND $key " . phpbb::$db->sql_like_expression(str_replace('%', phpbb::$db->any_char, $auth_options)); } else { - $sql_opts = "AND $key = '" . $db->sql_escape($auth_options) . "'"; + $sql_opts = "AND $key = '" . phpbb::$db->sql_escape($auth_options) . "'"; } } else @@ -1014,7 +919,7 @@ class auth if (!$is_like_expression) { - $sql_opts = 'AND ' . $db->sql_in_set($key, $auth_options); + $sql_opts = 'AND ' . phpbb::$db->sql_in_set($key, $auth_options); } else { @@ -1024,11 +929,11 @@ class auth { if (strpos($option, '%') !== false) { - $sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->any_char, $option)); + $sql[] = $key . ' ' . phpbb::$db->sql_like_expression(str_replace('%', phpbb::$db->any_char, $option)); } else { - $sql[] = $key . " = '" . $db->sql_escape($option) . "'"; + $sql[] = $key . " = '" . phpbb::$db->sql_escape($option) . "'"; } } diff --git a/phpBB/includes/classes/template.php b/phpBB/includes/classes/template.php index a49fd75eb3..167f33f3e8 100644 --- a/phpBB/includes/classes/template.php +++ b/phpBB/includes/classes/template.php @@ -20,9 +20,12 @@ if (!defined('IN_PHPBB')) * Base Template class. * @package phpBB3 */ -class template +class phpbb_template { - /** + public $phpbb_required = array('user', 'config'); + public $phpbb_optional = array(); + + /** * variable that holds all the data we'll be substituting into * the compiled templates. Takes form: * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value @@ -63,16 +66,14 @@ class template */ public function set_template() { - global $user; - - if (file_exists(PHPBB_ROOT_PATH . 'styles/' . $user->theme['template_path'] . '/template')) + if (file_exists(PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['template_path'] . '/template')) { - $this->root = PHPBB_ROOT_PATH . 'styles/' . $user->theme['template_path'] . '/template'; - $this->cachepath = PHPBB_ROOT_PATH . 'cache/tpl_' . $user->theme['template_path'] . '_'; + $this->root = PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['template_path'] . '/template'; + $this->cachepath = PHPBB_ROOT_PATH . 'cache/tpl_' . phpbb::$user->theme['template_path'] . '_'; } else { - trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR); + trigger_error('Template path could not be found: styles/' . phpbb::$user->theme['template_path'] . '/template', E_USER_ERROR); } $this->_rootref = &$this->_tpldata['.'][0]; @@ -158,8 +159,7 @@ class template */ public function display($handle, $include_once = true) { - global $user, $phpbb_hook; - +/* if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once)) { if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__))) @@ -167,7 +167,7 @@ class template return $phpbb_hook->hook_return_result(array(__CLASS__, __FUNCTION__)); } } - +*/ /* if (defined('IN_ERROR_HANDLER')) { if ((E_NOTICE & error_reporting()) == E_NOTICE) @@ -178,7 +178,7 @@ class template $_tpldata = &$this->_tpldata; $_rootref = &$this->_rootref; - $_lang = &$user->lang; + $_lang = &phpbb::$user->lang; // These _are_ used the included files. $_tpldata; $_rootref; $_lang; @@ -235,21 +235,19 @@ class template */ private function _tpl_load($handle) { - global $config; - $filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . PHP_EXT; - $recompile = (!file_exists($filename) || @filesize($filename) === 0 || ($config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle]))) ? true : false; + $recompile = (!file_exists($filename) || @filesize($filename) === 0 || (phpbb::$config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle]))) ? true : false; + + if (defined('DEBUG_EXTRA')) + { + $recompile = true; + } // Recompile page if the original template is newer, otherwise load the compiled version if ($recompile) { - if (!class_exists('template_compile')) - { - include(PHPBB_ROOT_PATH . 'includes/functions_template.' . PHP_EXT); - } - - $compile = new template_compile($this); + $compile = new phpbb_template_compile($this); // If we don't have a file assigned to this handle, die. if (!isset($this->files[$handle])) @@ -275,12 +273,7 @@ class template */ private function _tpl_eval($handle) { - if (!class_exists('template_compile')) - { - include(PHPBB_ROOT_PATH . 'includes/functions_template.' . PHP_EXT); - } - - $compile = new template_compile($this); + $compile = new phpbb_template_compile($this); // If we don't have a file assigned to this handle, die. if (!isset($this->files[$handle])) @@ -500,11 +493,9 @@ class template if ($include) { - global $user; - $_tpldata = &$this->_tpldata; $_rootref = &$this->_rootref; - $_lang = &$user->lang; + $_lang = &phpbb::$user->lang; // These _are_ used the included files. $_tpldata; $_rootref; $_lang; @@ -516,12 +507,7 @@ class template } else { - if (!class_exists('template_compile')) - { - include(PHPBB_ROOT_PATH . 'includes/functions_template.' . PHP_EXT); - } - - $compile = new template_compile($this); + $compile = new phpbb_template_compile($this); if (($code = $compile->_tpl_gen_src($handle)) !== false) { diff --git a/phpBB/includes/classes/template_compile.php b/phpBB/includes/classes/template_compile.php index 0ad6021e44..b8fc662208 100644 --- a/phpBB/includes/classes/template_compile.php +++ b/phpBB/includes/classes/template_compile.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) * @package phpBB3 * */ -class template_filter extends php_user_filter +class phpbb_template_filter extends php_user_filter { /** * @var string Replaceable tokens regex @@ -93,8 +93,6 @@ class template_filter extends php_user_filter private function replace($matches) { - global $config; - if (isset($matches[3])) { return $this->compile_var_tags($matches[0]); @@ -146,15 +144,15 @@ class template_filter extends php_user_filter break; case 'INCLUDEPHP': - return ($config['tpl_allow_php']) ? '<?php ' . $this->compile_tag_include_php($matches[2]) . ' ?>' : ''; + return (phpbb::$config['tpl_allow_php']) ? '<?php ' . $this->compile_tag_include_php($matches[2]) . ' ?>' : ''; break; case 'PHP': - return ($config['tpl_allow_php']) ? '<?php ' : '<!-- '; + return (phpbb::$config['tpl_allow_php']) ? '<?php ' : '<!-- '; break; case 'ENDPHP': - return ($config['tpl_allow_php']) ? ' ?>' : ' -->'; + return (phpbb::$config['tpl_allow_php']) ? ' ?>' : ' -->'; break; default: @@ -437,7 +435,7 @@ class template_filter extends php_user_filter $namespace = substr($varrefs[1], 0, -1); $namespace = (strpos($namespace, '.') === false) ? $namespace : strrchr($namespace, '.'); - // S_ROW_COUNT is deceptive, it returns the current row number not the number of rows + // S_ROW_COUNT is deceptive, it returns the current row number now the number of rows // hence S_ROW_COUNT is deprecated in favour of S_ROW_NUM switch ($varrefs[3]) { @@ -643,7 +641,7 @@ class template_filter extends php_user_filter $expr = true; - // S_ROW_COUNT is deceptive, it returns the current row number not the number of rows + // S_ROW_COUNT is deceptive, it returns the current row number now the number of rows // hence S_ROW_COUNT is deprecated in favour of S_ROW_NUM switch ($varname) { @@ -731,7 +729,7 @@ class template_filter extends php_user_filter } } -stream_filter_register('template', 'template_filter'); +stream_filter_register('phpbb_template', 'phpbb_template_filter'); /** * Extension of template class - Functions needed for compiling templates only. @@ -753,7 +751,7 @@ stream_filter_register('template', 'template_filter'); * @package phpBB3 * @uses template_filter As a PHP stream filter to perform compilation of templates */ -class template_compile +class phpbb_template_compile { /** * @var template Reference to the {@link template template} object performing compilation @@ -764,7 +762,7 @@ class template_compile * Constructor * @param template $template {@link template Template} object performing compilation */ - function __construct(template $template) + function __construct(phpbb_template $template) { $this->template = $template; } @@ -826,7 +824,7 @@ class template_compile @flock($destination_handle, LOCK_EX); - stream_filter_append($source_handle, 'template'); + stream_filter_append($source_handle, 'phpbb_template'); stream_copy_to_stream($source_handle, $destination_handle); @fclose($source_handle); @@ -856,7 +854,7 @@ class template_compile return false; } - stream_filter_append($source_handle, 'template'); + stream_filter_append($source_handle, 'phpbb_template'); stream_copy_to_stream($source_handle, $destination_handle); @fclose($source_handle); diff --git a/phpBB/includes/classes/user.php b/phpBB/includes/classes/user.php index 85a2ee012f..d86eb3d886 100644 --- a/phpBB/includes/classes/user.php +++ b/phpBB/includes/classes/user.php @@ -412,7 +412,7 @@ class phpbb_user extends phpbb_session { phpbb::$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary); phpbb::$db->sql_transaction('commit'); - phpbb::$acm->destroy('sql', STYLES_IMAGESET_DATA_TABLE); + phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); add_log('admin', 'LOG_IMAGESET_LANG_REFRESHED', $this->theme['imageset_name'], $this->img_lang); } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 89c6a21468..f9fde6fcd0 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2118,10 +2118,10 @@ function remove_comments(&$output) */ function cache_moderators() { - global $db, $cache, $auth; + global $db, $auth; // Remove cached sql results - $cache->destroy('sql', MODERATOR_CACHE_TABLE); + phpbb::$acm->destroy_sql(MODERATOR_CACHE_TABLE); // Clear table if ($db->truncate) diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index e497a61920..7f8ee5d4c0 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -673,7 +673,7 @@ function censor_text($text) // We moved the word censor checks in here because we call this function quite often - and then only need to do the check once if (!isset($censors) || !is_array($censors)) { - global $config, $user, $auth, $cache; + global $config, $user, $auth; // We check here if the user is having viewing censors disabled (and also allowed to do so). if (!$user->optionget('viewcensors') && $config['allow_nocensors'] && $auth->acl_get('u_chgcensors')) @@ -738,7 +738,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, return; } - global $template, $cache, $user; + global $template, $user; global $extensions, $config; // @@ -1068,7 +1068,6 @@ function extension_allowed($forum_id, $extension, &$extensions) { if (empty($extensions)) { - global $cache; $extensions = phpbb_cache::obtain_extensions_forum($forum_id); } diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 0936279fde..18788f1204 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1155,7 +1155,6 @@ function get_user_rank($user_id, $user_rank, $user_posts, &$rank_title, &$rank_i if (empty($ranks)) { - global $cache; $ranks = phpbb_cache::obtain_ranks(); } diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 2899848009..6a7301c798 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -78,13 +78,13 @@ class p_master */ function list_modules($p_class) { - global $auth, $db, $user, $cache, $config; + global $auth, $db, $user, $config; // Sanitise for future path use, it's escaped as appropriate for queries $this->p_class = str_replace(array('.', '/', '\\'), '', basename($p_class)); // Get cached modules - if (($this->module_cache = $cache->get('_modules_' . $this->p_class)) === false) + if (($this->module_cache = phpbb::$acm->get('modules_' . $this->p_class)) === false) { // Get modules $sql = 'SELECT * @@ -108,7 +108,7 @@ class p_master } unset($rows); - $cache->put('_modules_' . $this->p_class, $this->module_cache); + phpbb::$acm->put('modules_' . $this->p_class, $this->module_cache); } if (empty($this->module_cache)) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 40d075a52c..e30e088132 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -245,7 +245,7 @@ function update_post_information($type, $ids, $return_update_sql = false) */ function posting_gen_topic_icons($mode, $icon_id) { - global $config, $template, $cache; + global $config, $template; // Grab icons $icons = phpbb_cache::obtain_icons(); @@ -347,7 +347,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) */ function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false) { - global $auth, $user, $config, $db, $cache; + global $auth, $user, $config, $db; $filedata = array( 'error' => array() @@ -932,7 +932,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) */ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true) { - global $user, $auth, $db, $template, $bbcode, $cache, $config; + global $user, $auth, $db, $template, $bbcode, $config; // Go ahead and pull all data for this topic $sql = 'SELECT p.post_id diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c9eafc3d90..f6223b93aa 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -113,7 +113,7 @@ function update_last_username() */ function user_update_name($old_name, $new_name) { - global $config, $db, $cache; + global $config, $db; $update_ary = array( FORUMS_TABLE => array('forum_last_poster_name'), @@ -139,7 +139,7 @@ function user_update_name($old_name, $new_name) } // Because some tables/caches use username-specific data we need to purge this here. - $cache->destroy('sql', MODERATOR_CACHE_TABLE); + phpbb::$acm->destroy_sql(MODERATOR_CACHE_TABLE); } /** @@ -300,7 +300,7 @@ function user_add($user_row, $cp_data = false) */ function user_delete($mode, $user_id, $post_username = false) { - global $cache, $config, $db, $user, $auth; + global $config, $db, $user, $auth; $sql = 'SELECT * FROM ' . USERS_TABLE . ' @@ -498,7 +498,7 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_query($sql); } - $cache->destroy('sql', MODERATOR_CACHE_TABLE); + phpbb::$acm->destroy_sql(MODERATOR_CACHE_TABLE); // Remove any undelivered mails... $sql = 'SELECT msg_id, user_id @@ -674,7 +674,7 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL) */ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason = '') { - global $db, $user, $auth, $cache; + global $db, $user, $auth; // Delete stale bans $sql = 'DELETE FROM ' . BANLIST_TABLE . ' @@ -1053,13 +1053,13 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas add_log('admin', $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); add_log('mod', 0, 0, $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); - $cache->destroy('sql', BANLIST_TABLE); + phpbb::$acm->destroy_sql(BANLIST_TABLE); return true; } // There was nothing to ban/exclude. But destroying the cache because of the removal of stale bans. - $cache->destroy('sql', BANLIST_TABLE); + phpbb::$acm->destroy_sql(BANLIST_TABLE); return false; } @@ -1069,7 +1069,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas */ function user_unban($mode, $ban) { - global $db, $user, $auth, $cache; + global $db, $user, $auth; // Delete stale bans $sql = 'DELETE FROM ' . BANLIST_TABLE . ' @@ -1126,7 +1126,7 @@ function user_unban($mode, $ban) add_log('mod', 0, 0, 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list); } - $cache->destroy('sql', BANLIST_TABLE); + phpbb::$acm->destroy_sql(BANLIST_TABLE); return false; } @@ -1344,7 +1344,7 @@ function validate_match($string, $optional = false, $match = '') */ function validate_username($username, $allowed_username = false) { - global $config, $db, $user, $cache; + global $config, $db, $user; $clean_username = utf8_clean_string($username); $allowed_username = ($allowed_username === false) ? $user->data['username_clean'] : utf8_clean_string($allowed_username); @@ -1947,7 +1947,7 @@ function get_avatar_filename($avatar_entry) */ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var = 'avatar_row') { - global $user, $cache, $template, $config; + global $user, $template, $config; $avatar_list = array(); diff --git a/phpBB/includes/search/search.php b/phpBB/includes/search/search.php index a6986dfa2a..f3a5cc363f 100644 --- a/phpBB/includes/search/search.php +++ b/phpBB/includes/search/search.php @@ -94,9 +94,7 @@ class search_backend */ protected function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir) { - global $cache; - - if (!($stored_ids = $cache->get('_search_results_' . $search_key))) + if (!($stored_ids = phpbb::$acm->get('search_results_' . $search_key))) { // no search results cached for this search_key return self::SEARCH_RESULT_NOT_IN_CACHE; @@ -154,7 +152,7 @@ class search_backend */ protected function save_ids($search_key, $keywords, $author_ary, $result_count, &$id_ary, $start, $sort_dir) { - global $cache, $config, $db, $user; + global $config, $db, $user; $length = min(sizeof($id_ary), $config['search_block_size']); @@ -168,7 +166,7 @@ class search_backend // create a new resultset if there is none for this search_key yet // or add the ids to the existing resultset - if (!($store = $cache->get('_search_results_' . $search_key))) + if (!($store = phpbb::$acm->get('search_results_' . $search_key))) { // add the current keywords to the recent searches in the cache which are listed on the search page if (!empty($keywords) || sizeof($author_ary)) @@ -245,7 +243,7 @@ class search_backend } } } - $cache->put('_search_results_' . $search_key, $store, $config['search_store_results']); + phpbb::$acm->put('search_results_' . $search_key, $store, $config['search_store_results']); $sql = 'UPDATE ' . SEARCH_RESULTS_TABLE . ' SET search_time = ' . time() . ' @@ -263,7 +261,7 @@ class search_backend */ public function destroy_cache($words, $authors = false) { - global $db, $cache, $config; + global $db, $config; // clear all searches that searched for the specified words if (sizeof($words)) @@ -281,7 +279,7 @@ class search_backend while ($row = $db->sql_fetchrow($result)) { - $cache->destroy('_search_results_' . $row['search_key']); + phpbb::$acm->destroy('search_results_' . $row['search_key']); } $db->sql_freeresult($result); } @@ -302,7 +300,7 @@ class search_backend while ($row = $db->sql_fetchrow($result)) { - $cache->destroy('_search_results_' . $row['search_key']); + phpbb::$acm->destroy('search_results_' . $row['search_key']); } $db->sql_freeresult($result); } diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index 8b15c81ca8..a9710031f8 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -71,8 +71,8 @@ function phpbb_insert_forums() $result = $src_db->sql_query($sql); $prune_enabled = (int) $src_db->sql_fetchfield('config_value'); $src_db->sql_freeresult($result); - - + + // Insert categories $sql = 'SELECT cat_id, cat_title FROM ' . $convert->src_table_prefix . 'categories @@ -543,7 +543,7 @@ function phpbb_copy_table_fields() */ function phpbb_convert_authentication($mode) { - global $db, $src_db, $same_db, $convert, $user, $config, $cache; + global $db, $src_db, $same_db, $convert, $user, $config; if ($mode == 'start') { @@ -968,12 +968,12 @@ function phpbb_convert_authentication($mode) { // And now the moderators // We make sure that they have at least standard access to the forums they moderate in addition to the moderating permissions - + $mod_post_map = array( 'auth_announce' => 'f_announce', 'auth_sticky' => 'f_sticky' ); - + foreach ($user_access as $forum_id => $access_map) { $forum_id = (int) $forum_id; @@ -1223,7 +1223,7 @@ function phpbb_replace_size($matches) */ function phpbb_prepare_message($message) { - global $db, $convert, $user, $config, $cache, $convert_row, $message_parser; + global $db, $convert, $user, $config, $convert_row, $message_parser; if (!$message) { @@ -1247,7 +1247,7 @@ function phpbb_prepare_message($message) { $message = preg_replace('/\[quote="(.*?)"\]/s', '[quote="\1"]', $message); $message = preg_replace('/\[quote=\\\"(.*?)\\\"\]/s', '[quote="\1"]', $message); - + // let's hope that this solves more problems than it causes. Deal with escaped quotes. $message = str_replace('\"', '"', $message); $message = str_replace('\"', '"', $message); @@ -1276,7 +1276,7 @@ function phpbb_prepare_message($message) // parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post') $message_parser->parse($enable_bbcode, $enable_magic_url, $enable_smilies); - + if (sizeof($message_parser->warn_msg)) { $msg_id = isset($convert->row['post_id']) ? $convert->row['post_id'] : $convert->row['privmsgs_id']; @@ -1328,7 +1328,7 @@ function phpbb_get_files_dir() return; } - global $src_db, $same_db, $convert, $user, $config, $cache; + global $src_db, $same_db, $convert, $user, $config; if ($convert->mysql_convert && $same_db) { @@ -1367,10 +1367,10 @@ function phpbb_get_files_dir() */ function phpbb_copy_thumbnails() { - global $db, $convert, $user, $config, $cache; + global $db, $convert, $user, $config; $src_path = $convert->options['forum_path'] . '/' . phpbb_get_files_dir() . '/thumbs/'; - + if ($handle = @opendir($src_path)) { while ($entry = readdir($handle)) @@ -1449,13 +1449,13 @@ function phpbb_attachment_forum_perms($forum_permissions) $pos--; continue; } - + $forum_auth = substr($forum_permissions, $pos, $auth_len); $forum_id = base64_unpack($forum_auth); $forum_ids[] = (int) $forum_id; } - + if (sizeof($forum_ids)) { return attachment_forum_perms($forum_ids); @@ -1534,7 +1534,7 @@ function phpbb_import_avatar($user_avatar) function phpbb_get_avatar_height($user_avatar) { global $convert_row; - + if (empty($convert_row['user_avatar_type'])) { return 0; @@ -1554,7 +1554,7 @@ function phpbb_get_avatar_width($user_avatar) { return 0; } - + return get_avatar_width($user_avatar, 'phpbb_avatar_type', $convert_row['user_avatar_type']); } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 583ec0861f..996deb0339 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -83,7 +83,6 @@ else } $user = new user(); -$cache = new acm(); $db = new $sql_db(); // Connect to DB @@ -652,7 +651,7 @@ _write_result($no_updates, $errored, $error_ary); if (!$inline_update) { // Purge the cache... - $cache->purge(); + phpbb::$acm->purge(); ?> <p style="color:red"><?php echo $lang['UPDATE_FILES_NOTICE']; ?></p> @@ -676,7 +675,7 @@ else add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $updates_to_version); // Now we purge the session table as well as all cache files -$cache->purge(); +phpbb::$acm->purge(); ?> diff --git a/phpBB/install/index.php b/phpBB/install/index.php index f918a01786..ac8796feb2 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -240,7 +240,6 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle $user = new user(); $auth = new auth(); -$cache = new acm(); $template = new template(); // Set some standard variables we want to force diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index 552fb7a113..0a2d1b5d44 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -90,7 +90,7 @@ class install_convert extends module function main($mode, $sub) { - global $lang, $template, $cache, $config, $language, $table_prefix; + global $lang, $template, $config, $language, $table_prefix; global $convert; $this->tpl_name = 'install_convert'; @@ -213,7 +213,7 @@ class install_convert extends module // If we reached this step (conversion completed) we want to purge the cache and log the user out. // This is for making sure the session get not screwed due to the 3.0.x users table being completely new. - $cache->purge(); + phpbb::$acm->purge(); require(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); require(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT); @@ -333,7 +333,7 @@ class install_convert extends module */ function get_convert_settings($sub) { - global $lang, $language, $template, $db, $config, $cache; + global $lang, $language, $template, $db, $config; require(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); require(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT); @@ -581,7 +581,7 @@ class install_convert extends module */ function convert_data($sub) { - global $template, $user, $db, $lang, $config, $cache; + global $template, $user, $db, $lang, $config; global $convert, $convert_row, $message_parser, $skip_rows, $language; require(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); @@ -1438,7 +1438,7 @@ class install_convert extends module */ function sync_forums($sync_batch) { - global $template, $user, $db, $config, $cache; + global $template, $user, $db, $config; global $convert; $template->assign_block_vars('checks', array( @@ -1578,7 +1578,7 @@ class install_convert extends module */ function final_jump($final_jump) { - global $template, $user, $src_db, $same_db, $db, $config, $cache; + global $template, $user, $src_db, $same_db, $db, $config; global $convert; $template->assign_block_vars('checks', array( @@ -1617,7 +1617,7 @@ class install_convert extends module */ function jump($jump, $last_statement) { - global $template, $user, $src_db, $same_db, $db, $config, $cache; + global $template, $user, $src_db, $same_db, $db, $config; global $convert; $template->assign_block_vars('checks', array( @@ -1743,7 +1743,7 @@ class install_convert extends module // TODO: sync() is likely going to bomb out on forums with a considerable amount of topics. // TODO: the sync function is able to handle FROM-TO values, we should use them here (batch processing) sync('forum', '', '', false, true); - $cache->destroy('sql', FORUMS_TABLE); + phpbb::$acm->destroy_sql(FORUMS_TABLE); $template->assign_block_vars('checks', array( 'TITLE' => $user->lang['SYNC_FORUMS'], @@ -1920,7 +1920,7 @@ class install_convert extends module */ function process_row(&$schema, &$sql_data, &$insert_values) { - global $template, $user, $db, $lang, $config, $cache; + global $template, $user, $db, $lang, $config; global $convert, $convert_row; $sql_flag = false; diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 28ee7a95ff..a396c04dc5 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -70,7 +70,7 @@ class install_update extends module function main($mode, $sub) { - global $template, $user, $db, $config, $cache, $auth; + global $template, $user, $db, $config, $auth; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; @@ -122,17 +122,17 @@ class install_update extends module // If we are within the intro page we need to make sure we get up-to-date version info if ($sub == 'intro') { - $cache->destroy('_version_info'); + phpbb::$acm->destroy('version_info'); } // Set custom template again. ;) $template->set_custom_template('../adm/style', 'admin'); // Get current and latest version - if (($latest_version = $cache->get('_version_info')) === false) + if (($latest_version = phpbb::$acm->get('version_info')) === false) { $this->latest_version = $this->get_file('version_info'); - $cache->put('_version_info', $this->latest_version); + phpbb::$acm->put('version_info', $this->latest_version); } else { @@ -224,8 +224,8 @@ class install_update extends module )); // Make sure the update list is destroyed. - $cache->destroy('_update_list'); - $cache->destroy('_diff_files'); + phpbb::$acm->destroy('update_list'); + phpbb::$acm->destroy('diff_files'); break; case 'version_check': @@ -273,7 +273,7 @@ class install_update extends module } // Just a precaution - $cache->purge(); + phpbb::$acm->purge(); // Redirect the user to the database update script with some explanations... $template->assign_vars(array( @@ -289,7 +289,7 @@ class install_update extends module case 'file_check': // Make sure the previous file collection is no longer valid... - $cache->destroy('_diff_files'); + phpbb::$acm->destroy('diff_files'); $this->page_title = 'STAGE_FILE_CHECK'; @@ -297,8 +297,8 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = (phpbb_request::variable('check_again', false, false, phpbb_request::POST)) ? false : $cache->get('_update_list'); - $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . PHP_EXT) : 0; + $update_list = (phpbb_request::variable('check_again', false, false, phpbb_request::POST)) ? false : phpbb::$acm->get('update_list'); + $modified = ($update_list !== false) ? phpbb::$acm->get_modified_date('data', 'update_list') : 0; // Make sure the list is up-to-date if ($update_list !== false) @@ -326,7 +326,7 @@ class install_update extends module if ($get_new_list) { $this->get_update_structure($update_list); - $cache->put('_update_list', $update_list); + phpbb::$acm->put('update_list', $update_list); // Refresh the page if we are still not finished... if ($update_list['status'] != -1) @@ -497,7 +497,7 @@ class install_update extends module WHERE theme_id = ' . $theme['theme_id']; $db->sql_query($sql); - $cache->destroy('sql', STYLES_THEME_TABLE); + phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); } } @@ -505,7 +505,7 @@ class install_update extends module $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); $db->sql_return_on_error(false); - $cache->purge(); + phpbb::$acm->purge(); } break; @@ -544,7 +544,7 @@ class install_update extends module } // Before the user is choosing his preferred method, let's create the content list... - $update_list = $cache->get('_update_list'); + $update_list = phpbb::$acm->get('update_list'); if ($update_list === false) { @@ -601,7 +601,7 @@ class install_update extends module // Before we do anything, let us diff the files and store the raw file information "somewhere" $get_files = false; - $file_list = $cache->get('_diff_files'); + $file_list = phpbb::$acm->get('diff_files'); if ($file_list === false || $file_list['status'] != -1) { @@ -642,7 +642,7 @@ class install_update extends module // Refresh if we reach 5 diffs... if ($processed >= 5) { - $cache->put('_diff_files', $file_list); + phpbb::$acm->put('diff_files', $file_list); if (request_var('download', false)) { @@ -687,8 +687,8 @@ class install_update extends module break; } - $file_list[$file_struct['filename']] = '_file_' . md5($file_struct['filename']); - $cache->put($file_list[$file_struct['filename']], base64_encode($contents)); + $file_list[$file_struct['filename']] = 'file_' . md5($file_struct['filename']); + phpbb::$acm->put($file_list[$file_struct['filename']], base64_encode($contents)); $file_list['status']++; $processed++; @@ -732,8 +732,8 @@ class install_update extends module break; } - $file_list[$file_struct['filename']] = '_file_' . md5($file_struct['filename']); - $cache->put($file_list[$file_struct['filename']], base64_encode($contents)); + $file_list[$file_struct['filename']] = 'file_' . md5($file_struct['filename']); + phpbb::$acm->put($file_list[$file_struct['filename']], base64_encode($contents)); $file_list['status']++; $processed++; @@ -745,7 +745,7 @@ class install_update extends module } $file_list['status'] = -1; - $cache->put('_diff_files', $file_list); + phpbb::$acm->put('diff_files', $file_list); if (request_var('download', false)) { @@ -784,7 +784,7 @@ class install_update extends module ); // To ease the update process create a file location map - $update_list = $cache->get('_update_list'); + $update_list = phpbb::$acm->get('update_list'); $script_path = ($config['force_server_vars']) ? (($config['script_path'] == '/') ? '/' : $config['script_path'] . '/') : $user->page['root_script_path']; foreach ($update_list as $status => $files) @@ -974,7 +974,7 @@ class install_update extends module case 'modified': - $contents = base64_decode($cache->get($file_list[$file_struct['filename']])); + $contents = base64_decode(phpbb::$acm->get($file_list[$file_struct['filename']])); if ($update_mode == 'download') { @@ -990,7 +990,7 @@ class install_update extends module case 'conflict': - $contents = base64_decode($cache->get($file_list[$file_struct['filename']])); + $contents = base64_decode(phpbb::$acm->get($file_list[$file_struct['filename']])); if ($update_mode == 'download') { diff --git a/phpBB/modules/acp/acp_attachments.php b/phpBB/modules/acp/acp_attachments.php index 6b827a91fb..a447ffd923 100644 --- a/phpBB/modules/acp/acp_attachments.php +++ b/phpBB/modules/acp/acp_attachments.php @@ -26,7 +26,7 @@ class acp_attachments function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang(array('posting', 'viewtopic', 'acp/attachments')); @@ -396,7 +396,7 @@ class acp_attachments $notify[] = $user->lang['EXTENSIONS_UPDATED']; } - $cache->destroy('_extensions'); + phpbb::$acm->destroy('extensions'); } $template->assign_vars(array( @@ -575,7 +575,7 @@ class acp_attachments $db->sql_query($sql); } - $cache->destroy('_extensions'); + phpbb::$acm->destroy('extensions'); if (!sizeof($error)) { @@ -621,7 +621,7 @@ class acp_attachments add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $group_name); - $cache->destroy('_extensions'); + phpbb::$acm->destroy('extensions'); trigger_error($user->lang['EXTENSION_GROUP_DELETED'] . adm_back_link($this->u_action)); } diff --git a/phpBB/modules/acp/acp_ban.php b/phpBB/modules/acp/acp_ban.php index 578ddd02d8..c6ce71371d 100644 --- a/phpBB/modules/acp/acp_ban.php +++ b/phpBB/modules/acp/acp_ban.php @@ -25,7 +25,7 @@ class acp_ban function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template; include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); diff --git a/phpBB/modules/acp/acp_bbcodes.php b/phpBB/modules/acp/acp_bbcodes.php index 4118e5f919..b76d4f5e27 100644 --- a/phpBB/modules/acp/acp_bbcodes.php +++ b/phpBB/modules/acp/acp_bbcodes.php @@ -25,7 +25,7 @@ class acp_bbcodes function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang('acp/posting'); @@ -167,8 +167,8 @@ class acp_bbcodes { trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); } - - + + if (strlen($bbcode_helpline) > 255) { trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); @@ -217,7 +217,7 @@ class acp_bbcodes $sql_ary['bbcode_id'] = (int) $bbcode_id; $db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary)); - $cache->destroy('sql', BBCODES_TABLE); + phpbb::$acm->destroy_sql(BBCODES_TABLE); $lang = 'BBCODE_ADDED'; $log_action = 'LOG_BBCODE_ADD'; @@ -228,7 +228,7 @@ class acp_bbcodes SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE bbcode_id = ' . $bbcode_id; $db->sql_query($sql); - $cache->destroy('sql', BBCODES_TABLE); + phpbb::$acm->destroy_sql(BBCODES_TABLE); $lang = 'BBCODE_EDITED'; $log_action = 'LOG_BBCODE_EDIT'; @@ -254,7 +254,7 @@ class acp_bbcodes if (confirm_box(true)) { $db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id"); - $cache->destroy('sql', BBCODES_TABLE); + phpbb::$acm->destroy_sql(BBCODES_TABLE); add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']); } else diff --git a/phpBB/modules/acp/acp_bots.php b/phpBB/modules/acp/acp_bots.php index b1a0f3f7cd..7a23ca09c5 100644 --- a/phpBB/modules/acp/acp_bots.php +++ b/phpBB/modules/acp/acp_bots.php @@ -25,7 +25,7 @@ class acp_bots function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template; $action = request_var('action', ''); $submit = phpbb_request::is_set_post('submit'); @@ -64,7 +64,7 @@ class acp_bots $db->sql_query($sql); } - $cache->destroy('_bots'); + phpbb::$acm->destroy('bots'); break; case 'deactivate': @@ -78,7 +78,7 @@ class acp_bots $db->sql_query($sql); } - $cache->destroy('_bots'); + phpbb::$acm->destroy('bots'); break; case 'delete': @@ -121,7 +121,7 @@ class acp_bots $db->sql_transaction('commit'); - $cache->destroy('_bots'); + phpbb::$acm->destroy('bots'); add_log('admin', 'LOG_BOT_DELETE', implode(', ', $bot_name_ary)); trigger_error($user->lang['BOT_DELETED'] . adm_back_link($this->u_action)); @@ -290,7 +290,7 @@ class acp_bots $log = 'UPDATED'; } - $cache->destroy('_bots'); + phpbb::$acm->destroy('bots'); add_log('admin', 'LOG_BOT_' . $log, $bot_row['bot_name']); trigger_error($user->lang['BOT_' . $log] . adm_back_link($this->u_action)); diff --git a/phpBB/modules/acp/acp_database.php b/phpBB/modules/acp/acp_database.php index 9261998d80..837e7280e2 100644 --- a/phpBB/modules/acp/acp_database.php +++ b/phpBB/modules/acp/acp_database.php @@ -25,7 +25,7 @@ class acp_database function main($id, $mode) { - global $cache, $db, $user, $auth, $template, $table_prefix, $config; + global $db, $user, $auth, $template, $table_prefix, $config; $user->add_lang('acp/database'); @@ -399,7 +399,7 @@ class acp_database $close($fp); // Purge the cache due to updated data - $cache->purge(); + phpbb::$acm->purge(); add_log('admin', 'LOG_DB_RESTORE'); trigger_error($user->lang['RESTORE_SUCCESS'] . adm_back_link($this->u_action)); diff --git a/phpBB/modules/acp/acp_disallow.php b/phpBB/modules/acp/acp_disallow.php index 774fef67fc..507cbbdf15 100644 --- a/phpBB/modules/acp/acp_disallow.php +++ b/phpBB/modules/acp/acp_disallow.php @@ -25,7 +25,7 @@ class acp_disallow function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); @@ -58,7 +58,7 @@ class acp_disallow $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user)); $db->sql_query($sql); - $cache->destroy('_disallowed_usernames'); + phpbb::$acm->destroy('disallowed_usernames'); $message = $user->lang['DISALLOW_SUCCESSFUL']; add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user)); @@ -78,7 +78,7 @@ class acp_disallow WHERE disallow_id = ' . $disallowed_id; $db->sql_query($sql); - $cache->destroy('_disallowed_usernames'); + phpbb::$acm->destroy('disallowed_usernames'); add_log('admin', 'LOG_DISALLOW_DELETE'); diff --git a/phpBB/modules/acp/acp_email.php b/phpBB/modules/acp/acp_email.php index c516c77f6c..3e9be9e34c 100644 --- a/phpBB/modules/acp/acp_email.php +++ b/phpBB/modules/acp/acp_email.php @@ -25,7 +25,7 @@ class acp_email function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template; $user->add_lang('acp/email'); $this->tpl_name = 'acp_email'; diff --git a/phpBB/modules/acp/acp_forums.php b/phpBB/modules/acp/acp_forums.php index 303080a5e0..30a038c611 100644 --- a/phpBB/modules/acp/acp_forums.php +++ b/phpBB/modules/acp/acp_forums.php @@ -26,7 +26,7 @@ class acp_forums function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang('acp/forums'); $this->tpl_name = 'acp_forums'; @@ -96,7 +96,7 @@ class acp_forums } $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); + phpbb::$acm->destroy_sql(FORUMS_TABLE); trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); @@ -246,7 +246,7 @@ class acp_forums } $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); + phpbb::$acm->destroy_sql(FORUMS_TABLE); $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; @@ -298,7 +298,7 @@ class acp_forums if ($move_forum_name !== false) { add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); - $cache->destroy('sql', FORUMS_TABLE); + phpbb::$acm->destroy_sql(FORUMS_TABLE); } break; @@ -404,7 +404,7 @@ class acp_forums sync('forum', 'forum_id', $forum_id, false, true); add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']); - $cache->destroy('sql', FORUMS_TABLE); + phpbb::$acm->destroy_sql(FORUMS_TABLE); $template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name'])); @@ -887,7 +887,7 @@ class acp_forums */ function update_forum_data(&$forum_data) { - global $db, $user, $cache; + global $db, $user; $errors = array(); @@ -1138,7 +1138,7 @@ class acp_forums } $db->sql_freeresult($result); - $cache->destroy('_extensions'); + phpbb::$acm->destroy('extensions'); } } else if ($action_subforums == 'move') @@ -1387,7 +1387,7 @@ class acp_forums */ function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0) { - global $db, $user, $cache; + global $db, $user; $forum_data = $this->get_forum_info($forum_id); @@ -1577,7 +1577,7 @@ class acp_forums } $db->sql_freeresult($result); - $cache->destroy('_extensions'); + phpbb::$acm->destroy('extensions'); $log_action = implode('_', array($log_action_posts, $log_action_forums)); diff --git a/phpBB/modules/acp/acp_groups.php b/phpBB/modules/acp/acp_groups.php index f01ca2290c..fce4ba7e55 100644 --- a/phpBB/modules/acp/acp_groups.php +++ b/phpBB/modules/acp/acp_groups.php @@ -25,7 +25,7 @@ class acp_groups function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache, $file_uploads; + global $config, $db, $user, $auth, $template, $file_uploads; $user->add_lang('acp/groups'); $this->tpl_name = 'acp_groups'; @@ -458,7 +458,7 @@ class acp_groups } } - $cache->destroy('sql', GROUPS_TABLE); + phpbb::$acm->destroy_sql(GROUPS_TABLE); $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; trigger_error($user->lang[$message] . adm_back_link($this->u_action)); diff --git a/phpBB/modules/acp/acp_icons.php b/phpBB/modules/acp/acp_icons.php index 1da9bc0910..c766ab5540 100644 --- a/phpBB/modules/acp/acp_icons.php +++ b/phpBB/modules/acp/acp_icons.php @@ -26,7 +26,7 @@ class acp_icons function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang('acp/posting'); @@ -429,8 +429,8 @@ class acp_icons } } - $cache->destroy('_icons'); - $cache->destroy('sql', $table); + phpbb::$acm->destroy('icons'); + phpbb::$acm->destroy_sql($table); $level = E_USER_NOTICE; switch ($icons_updated) @@ -607,8 +607,8 @@ class acp_icons } } - $cache->destroy('_icons'); - $cache->destroy('sql', $table); + phpbb::$acm->destroy('icons'); + phpbb::$acm->destroy_sql($table); trigger_error($user->lang[$lang . '_IMPORT_SUCCESS'] . adm_back_link($this->u_action)); } @@ -729,8 +729,8 @@ class acp_icons $notice = $user->lang[$lang . '_DELETED']; - $cache->destroy('_icons'); - $cache->destroy('sql', $table); + phpbb::$acm->destroy('icons'); + phpbb::$acm->destroy_sql($table); } else { @@ -781,8 +781,8 @@ class acp_icons $db->sql_query($sql); } - $cache->destroy('_icons'); - $cache->destroy('sql', $table); + phpbb::$acm->destroy('icons'); + phpbb::$acm->destroy_sql($table); break; } diff --git a/phpBB/modules/acp/acp_language.php b/phpBB/modules/acp/acp_language.php index cdc8a798e1..fd33057e07 100644 --- a/phpBB/modules/acp/acp_language.php +++ b/phpBB/modules/acp/acp_language.php @@ -31,7 +31,7 @@ class acp_language function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template; global $safe_mode, $file_uploads; /** @@ -796,7 +796,7 @@ class acp_language $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; $result = $db->sql_query($sql); - $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); + phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']); @@ -908,7 +908,7 @@ class acp_language if (sizeof($sql_ary)) { $db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary); - $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); + phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); } // Now let's copy the default language entries for custom profile fields for this new language - makes admin's life easier. diff --git a/phpBB/modules/acp/acp_logs.php b/phpBB/modules/acp/acp_logs.php index 0b2ec76271..95442b336c 100644 --- a/phpBB/modules/acp/acp_logs.php +++ b/phpBB/modules/acp/acp_logs.php @@ -25,7 +25,7 @@ class acp_logs function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang('mcp'); diff --git a/phpBB/modules/acp/acp_main.php b/phpBB/modules/acp/acp_main.php index 5e7e998f34..78ada1d09d 100644 --- a/phpBB/modules/acp/acp_main.php +++ b/phpBB/modules/acp/acp_main.php @@ -328,8 +328,7 @@ class acp_main trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } - global $cache; - $cache->purge(); + phpbb::$acm->purge(); // Clear permissions $auth->acl_clear_prefetch(); diff --git a/phpBB/modules/acp/acp_modules.php b/phpBB/modules/acp/acp_modules.php index 093216c330..e04961099c 100644 --- a/phpBB/modules/acp/acp_modules.php +++ b/phpBB/modules/acp/acp_modules.php @@ -720,15 +720,13 @@ class acp_modules */ function remove_cache_file() { - global $cache; - // Sanitise for future path use, it's escaped as appropriate for queries $p_class = str_replace(array('.', '/', '\\'), '', basename($this->module_class)); - $cache->destroy('_modules_' . $p_class); + phpbb::$acm->destroy('modules_' . $p_class); // Additionally remove sql cache - $cache->destroy('sql', MODULES_TABLE); + phpbb::$acm->destroy_sql(MODULES_TABLE); } /** diff --git a/phpBB/modules/acp/acp_permission_roles.php b/phpBB/modules/acp/acp_permission_roles.php index 00bdcedcc6..8348c622c5 100644 --- a/phpBB/modules/acp/acp_permission_roles.php +++ b/phpBB/modules/acp/acp_permission_roles.php @@ -25,7 +25,7 @@ class acp_permission_roles function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; include_once(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); include_once(PHPBB_ROOT_PATH . 'includes/acp/auth.' . PHP_EXT); diff --git a/phpBB/modules/acp/acp_permissions.php b/phpBB/modules/acp/acp_permissions.php index 9b3d966ebd..8b3b424ce8 100644 --- a/phpBB/modules/acp/acp_permissions.php +++ b/phpBB/modules/acp/acp_permissions.php @@ -26,7 +26,7 @@ class acp_permissions function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; include_once(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); include_once(PHPBB_ROOT_PATH . 'includes/acp/auth.' . PHP_EXT); diff --git a/phpBB/modules/acp/acp_profile.php b/phpBB/modules/acp/acp_profile.php index 629ac34e43..75bbd1ab14 100644 --- a/phpBB/modules/acp/acp_profile.php +++ b/phpBB/modules/acp/acp_profile.php @@ -28,7 +28,7 @@ class acp_profile function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template; include(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT); include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); diff --git a/phpBB/modules/acp/acp_prune.php b/phpBB/modules/acp/acp_prune.php index 91d9a371c0..0f6fa9933d 100644 --- a/phpBB/modules/acp/acp_prune.php +++ b/phpBB/modules/acp/acp_prune.php @@ -51,7 +51,7 @@ class acp_prune */ function prune_forums($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $all_forums = request_var('all_forums', 0); $forum_id = request_var('f', array(0)); @@ -227,7 +227,7 @@ class acp_prune */ function prune_users($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang('memberlist'); diff --git a/phpBB/modules/acp/acp_ranks.php b/phpBB/modules/acp/acp_ranks.php index d779132d6e..64ed46cc96 100644 --- a/phpBB/modules/acp/acp_ranks.php +++ b/phpBB/modules/acp/acp_ranks.php @@ -25,7 +25,7 @@ class acp_ranks function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang('acp/posting'); @@ -88,7 +88,7 @@ class acp_ranks } $db->sql_query($sql); - $cache->destroy('_ranks'); + phpbb::$acm->destroy('ranks'); trigger_error($message . adm_back_link($this->u_action)); @@ -119,7 +119,7 @@ class acp_ranks WHERE user_rank = $rank_id"; $db->sql_query($sql); - $cache->destroy('_ranks'); + phpbb::$acm->destroy('ranks'); add_log('admin', 'LOG_RANK_REMOVED', $rank_title); } diff --git a/phpBB/modules/acp/acp_reasons.php b/phpBB/modules/acp/acp_reasons.php index 305f4c615e..1c80fcfa40 100644 --- a/phpBB/modules/acp/acp_reasons.php +++ b/phpBB/modules/acp/acp_reasons.php @@ -25,7 +25,7 @@ class acp_reasons function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang(array('mcp', 'acp/posting')); diff --git a/phpBB/modules/acp/acp_search.php b/phpBB/modules/acp/acp_search.php index aa9159f8e8..380890ec64 100644 --- a/phpBB/modules/acp/acp_search.php +++ b/phpBB/modules/acp/acp_search.php @@ -50,7 +50,7 @@ class acp_search function settings($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $submit = phpbb_request::is_set_post('submit'); @@ -226,7 +226,7 @@ class acp_search function index($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $action = request_var('action', array('' => false)); if (sizeof($action)) diff --git a/phpBB/modules/acp/acp_styles.php b/phpBB/modules/acp/acp_styles.php index 4eb0928716..17c33c9c82 100644 --- a/phpBB/modules/acp/acp_styles.php +++ b/phpBB/modules/acp/acp_styles.php @@ -31,7 +31,7 @@ class acp_styles function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; // Hardcoded template bitfield to add for new templates $bitfield = new bitfield(); @@ -300,7 +300,7 @@ parse_css_file = {PARSE_CSS_FILE} WHERE theme_id = $style_id"; $db->sql_query($sql); - $cache->destroy('sql', STYLES_THEME_TABLE); + phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); add_log('admin', 'LOG_THEME_REFRESHED', $theme_row['theme_name']); trigger_error($user->lang['THEME_REFRESHED'] . adm_back_link($this->u_action)); @@ -447,7 +447,7 @@ parse_css_file = {PARSE_CSS_FILE} $db->sql_transaction('commit'); - $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); + phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); add_log('admin', 'LOG_IMAGESET_REFRESHED', $imageset_row['imageset_name']); trigger_error($user->lang['IMAGESET_REFRESHED'] . adm_back_link($this->u_action)); @@ -631,7 +631,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function edit_template($template_id) { - global $config, $db, $cache, $user, $template, $safe_mode; + global $config, $db, $user, $template, $safe_mode; if (defined('PHPBB_DISABLE_ACP_EDITOR')) { @@ -692,7 +692,7 @@ parse_css_file = {PARSE_CSS_FILE} // destroy the cached version of the template (filename without extension) $this->clear_template_cache($template_info, array(substr($template_file, 0, -5))); - $cache->destroy('sql', STYLES_TABLE); + phpbb::$acm->destroy_sql(STYLES_TABLE); add_log('admin', 'LOG_TEMPLATE_EDIT', $template_info['template_name'], $template_file); trigger_error($user->lang['TEMPLATE_FILE_UPDATED'] . $additional . adm_back_link($this->u_action . "&action=edit&id=$template_id&text_rows=$text_rows&template_file=$template_file")); @@ -801,7 +801,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function template_cache($template_id) { - global $config, $db, $cache, $user, $template; + global $config, $db, $user, $template; $source = str_replace('/', '.', request_var('source', '')); $file_ary = array_diff(request_var('delete', array('')), array('')); @@ -920,7 +920,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function edit_theme($theme_id) { - global $config, $db, $cache, $user, $template, $safe_mode; + global $config, $db, $user, $template, $safe_mode; $this->page_title = 'EDIT_THEME'; @@ -981,7 +981,7 @@ parse_css_file = {PARSE_CSS_FILE} WHERE theme_id = ' . $theme_id; $db->sql_query($sql); - $cache->destroy('sql', STYLES_THEME_TABLE); + phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); // notify the user if the theme was not stored in the db before his modification if (!$theme_info['theme_storedb']) @@ -990,7 +990,7 @@ parse_css_file = {PARSE_CSS_FILE} $message .= '<br />' . $user->lang['EDIT_THEME_STORED_DB']; } } - $cache->destroy('sql', STYLES_THEME_TABLE); + phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); add_log('admin', (!$theme_info['theme_storedb']) ? 'LOG_THEME_EDIT_FILE' : 'LOG_THEME_EDIT', $theme_info['theme_name'], (!$theme_info['theme_storedb']) ? $theme_file : ''); trigger_error($message . adm_back_link($this->u_action . "&action=edit&id=$theme_id&template_file=$theme_file&text_rows=$text_rows")); @@ -1107,7 +1107,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function edit_imageset($imageset_id) { - global $db, $user, $cache, $template; + global $db, $user, $template; $this->page_title = 'EDIT_IMAGESET'; @@ -1232,7 +1232,7 @@ parse_css_file = {PARSE_CSS_FILE} $db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); } - $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); + phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name); @@ -1376,7 +1376,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function remove($mode, $style_id) { - global $db, $template, $user, $cache, $config; + global $db, $template, $user, $config; $new_id = request_var('new_id', 0); $update = phpbb_request::is_set_post('update'); @@ -1480,7 +1480,7 @@ parse_css_file = {PARSE_CSS_FILE} $db->sql_query($sql); } - $cache->destroy('sql', STYLES_TABLE); + phpbb::$acm->destroy_sql(STYLES_TABLE); add_log('admin', 'LOG_' . $l_prefix . '_DELETE', $style_row[$mode . '_name']); $message = ($mode != 'style') ? $l_prefix . '_DELETED_FS' : $l_prefix . '_DELETED'; @@ -1512,7 +1512,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function export($mode, $style_id) { - global $db, $template, $user, $cache, $config; + global $db, $template, $user, $config; $update = phpbb_request::is_set_post('update'); @@ -1909,7 +1909,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function details($mode, $style_id) { - global $template, $db, $config, $user, $safe_mode, $cache; + global $template, $db, $config, $user, $safe_mode; $update = phpbb_request::is_set_post('update'); $l_type = strtoupper($mode); @@ -2056,7 +2056,7 @@ parse_css_file = {PARSE_CSS_FILE} } } - $cache->destroy('sql', STYLES_TABLE); + phpbb::$acm->destroy_sql(STYLES_TABLE); add_log('admin', 'LOG_' . $l_type . '_EDIT_DETAILS', $name); if (sizeof($error)) @@ -2260,7 +2260,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function install($mode) { - global $config, $db, $cache, $user, $template; + global $config, $db, $user, $template; $l_type = strtoupper($mode); @@ -2373,7 +2373,7 @@ parse_css_file = {PARSE_CSS_FILE} if (!sizeof($error)) { - $cache->destroy('sql', STYLES_TABLE); + phpbb::$acm->destroy_sql(STYLES_TABLE); trigger_error($user->lang[$l_type . '_ADDED'] . adm_back_link($this->u_action)); } @@ -2415,7 +2415,7 @@ parse_css_file = {PARSE_CSS_FILE} */ function add($mode) { - global $config, $db, $cache, $user, $template; + global $config, $db, $user, $template; $l_type = strtoupper($mode); $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE, 'imageset' => STYLES_IMAGESET_TABLE); @@ -2503,7 +2503,7 @@ parse_css_file = {PARSE_CSS_FILE} if (!sizeof($error)) { - $cache->destroy('sql', STYLES_TABLE); + phpbb::$acm->destroy_sql(STYLES_TABLE); trigger_error($user->lang[$l_type . '_ADDED'] . adm_back_link($this->u_action)); } diff --git a/phpBB/modules/acp/acp_update.php b/phpBB/modules/acp/acp_update.php index a6440c8364..d021fe5e09 100644 --- a/phpBB/modules/acp/acp_update.php +++ b/phpBB/modules/acp/acp_update.php @@ -25,7 +25,7 @@ class acp_update function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template; $user->add_lang('install'); diff --git a/phpBB/modules/acp/acp_users.php b/phpBB/modules/acp/acp_users.php index ab48f3b186..0cb973058c 100644 --- a/phpBB/modules/acp/acp_users.php +++ b/phpBB/modules/acp/acp_users.php @@ -31,7 +31,7 @@ class acp_users function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache, $file_uploads; + global $config, $db, $user, $auth, $template, $file_uploads; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; diff --git a/phpBB/modules/acp/acp_words.php b/phpBB/modules/acp/acp_words.php index c473d27f13..61728c01af 100644 --- a/phpBB/modules/acp/acp_words.php +++ b/phpBB/modules/acp/acp_words.php @@ -26,7 +26,7 @@ class acp_words function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $config; + global $db, $user, $auth, $template, $config; $user->add_lang('acp/posting'); @@ -106,7 +106,7 @@ class acp_words $db->sql_query('INSERT INTO ' . WORDS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); } - $cache->destroy('_word_censors'); + phpbb::$acm->destroy('word_censors'); $log_action = ($word_id) ? 'LOG_WORD_EDIT' : 'LOG_WORD_ADD'; add_log('admin', $log_action, $word); @@ -138,7 +138,7 @@ class acp_words WHERE word_id = $word_id"; $db->sql_query($sql); - $cache->destroy('_word_censors'); + phpbb::$acm->destroy('word_censors'); add_log('admin', 'LOG_WORD_DELETE', $deleted_word); diff --git a/phpBB/modules/acp/auth.php b/phpBB/modules/acp/auth.php index ee4e45a08d..92e61f0480 100644 --- a/phpBB/modules/acp/auth.php +++ b/phpBB/modules/acp/auth.php @@ -27,9 +27,9 @@ class auth_admin extends auth */ function __construct() { - global $db, $cache; + global $db; - if (($this->acl_options = $cache->get('_acl_options')) === false) + if (($this->acl_options = phpbb::$acm->get('acl_options')) === false) { $sql = 'SELECT auth_option_id, auth_option, is_global, is_local FROM ' . ACL_OPTIONS_TABLE . ' @@ -55,7 +55,7 @@ class auth_admin extends auth } $db->sql_freeresult($result); - $cache->put('_acl_options', $this->acl_options); + phpbb::$acm->put('acl_options', $this->acl_options); } } @@ -687,7 +687,7 @@ class auth_admin extends auth */ public function acl_add_option(array $options) { - global $db, $cache; + global $db; $cur_options = array(); @@ -757,7 +757,7 @@ class auth_admin extends auth $db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary); - $cache->destroy('_acl_options'); + phpbb::$acm->destroy('acl_options'); $this->acl_clear_prefetch(); // Because we just changed the options and also purged the options cache, we instantly update/regenerate it for later calls to succeed. diff --git a/phpBB/modules/mcp/mcp_ban.php b/phpBB/modules/mcp/mcp_ban.php index 8feab368de..f4f3708799 100644 --- a/phpBB/modules/mcp/mcp_ban.php +++ b/phpBB/modules/mcp/mcp_ban.php @@ -25,7 +25,7 @@ class mcp_ban function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template; include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); diff --git a/phpBB/modules/mcp/mcp_forum.php b/phpBB/modules/mcp/mcp_forum.php index c99ae0c067..2f90e99e93 100644 --- a/phpBB/modules/mcp/mcp_forum.php +++ b/phpBB/modules/mcp/mcp_forum.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ function mcp_forum_view($id, $mode, $action, $forum_info) { - global $template, $db, $user, $auth, $cache, $module, $config; + global $template, $db, $user, $auth, $module, $config; $user->add_lang(array('viewtopic', 'viewforum')); diff --git a/phpBB/modules/mcp/mcp_post.php b/phpBB/modules/mcp/mcp_post.php index 9cb5b2cdae..b296c3626f 100644 --- a/phpBB/modules/mcp/mcp_post.php +++ b/phpBB/modules/mcp/mcp_post.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ function mcp_post_details($id, $mode, $action) { - global $template, $db, $user, $auth, $cache, $config; + global $template, $db, $user, $auth, $config; $user->add_lang('posting'); diff --git a/phpBB/modules/mcp/mcp_queue.php b/phpBB/modules/mcp/mcp_queue.php index 96ac7accb1..eefeb08f3d 100644 --- a/phpBB/modules/mcp/mcp_queue.php +++ b/phpBB/modules/mcp/mcp_queue.php @@ -33,7 +33,7 @@ class mcp_queue function main($id, $mode) { - global $auth, $db, $user, $template, $cache; + global $auth, $db, $user, $template; global $config, $action; include_once(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT); diff --git a/phpBB/modules/mcp/mcp_reports.php b/phpBB/modules/mcp/mcp_reports.php index 63d145eb49..a86e156438 100644 --- a/phpBB/modules/mcp/mcp_reports.php +++ b/phpBB/modules/mcp/mcp_reports.php @@ -33,7 +33,7 @@ class mcp_reports function main($id, $mode) { - global $auth, $db, $user, $template, $cache; + global $auth, $db, $user, $template; global $config, $action; include_once(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT); diff --git a/phpBB/modules/mcp/mcp_topic.php b/phpBB/modules/mcp/mcp_topic.php index 4ab9e244e1..22675a8c84 100644 --- a/phpBB/modules/mcp/mcp_topic.php +++ b/phpBB/modules/mcp/mcp_topic.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ function mcp_topic_view($id, $mode, $action) { - global $template, $db, $user, $auth, $cache, $config; + global $template, $db, $user, $auth, $config; $url = append_sid(PHPBB_ROOT_PATH. 'mcp.' . PHP_EXT . '?' . extra_url()); diff --git a/phpBB/modules/ucp/ucp_groups.php b/phpBB/modules/ucp/ucp_groups.php index 67e6fdb9ea..f8c676df5f 100644 --- a/phpBB/modules/ucp/ucp_groups.php +++ b/phpBB/modules/ucp/ucp_groups.php @@ -26,7 +26,7 @@ class ucp_groups function main($id, $mode) { - global $db, $user, $auth, $cache, $template, $config; + global $db, $user, $auth, $template, $config; $user->add_lang('groups'); @@ -612,7 +612,7 @@ class ucp_groups if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) { - $cache->destroy('sql', GROUPS_TABLE); + phpbb::$acm->destroy_sql(GROUPS_TABLE); $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; trigger_error($user->lang[$message] . $return_page); diff --git a/phpBB/modules/ucp/ucp_pm_viewfolder.php b/phpBB/modules/ucp/ucp_pm_viewfolder.php index a67b64d229..7024c1d318 100644 --- a/phpBB/modules/ucp/ucp_pm_viewfolder.php +++ b/phpBB/modules/ucp/ucp_pm_viewfolder.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) */ function view_folder($id, $mode, $folder_id, $folder) { - global $user, $template, $auth, $db, $cache, $config; + global $user, $template, $auth, $db, $config; $submit_export = phpbb_request::is_set_post('submit_export'); diff --git a/phpBB/modules/ucp/ucp_pm_viewmessage.php b/phpBB/modules/ucp/ucp_pm_viewmessage.php index e6e34efbfa..cd183a1085 100644 --- a/phpBB/modules/ucp/ucp_pm_viewmessage.php +++ b/phpBB/modules/ucp/ucp_pm_viewmessage.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) { - global $user, $template, $auth, $db, $cache, $config; + global $user, $template, $auth, $db, $config; $user->add_lang(array('viewtopic', 'memberlist')); @@ -249,7 +249,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) */ function get_user_information($user_id, $user_row) { - global $db, $auth, $user, $cache, $config; + global $db, $auth, $user, $config; if (!$user_id) { diff --git a/phpBB/style.php b/phpBB/style.php index 9f8d8ff4d3..7792df8a90 100644 --- a/phpBB/style.php +++ b/phpBB/style.php @@ -162,7 +162,7 @@ if ($recache) WHERE theme_id = {$theme['theme_id']}"; $db->sql_query($sql); - $cache->destroy('sql', STYLES_THEME_TABLE); + phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); } // Only set the expire time if the theme changed data is older than 30 minutes - to cope with changes from the ACP |