change cache:: to phpbb_cache::

git-svn-id: file:///svn/phpbb/trunk@9226 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2008-12-24 14:44:19 +00:00
parent ac37f87105
commit 3cd007c49d
21 changed files with 229 additions and 267 deletions

View file

@ -217,15 +217,6 @@ $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('
unset($dbpasswd); unset($dbpasswd);
// Grab global variables, re-cache if necessary // Grab global variables, re-cache if necessary
$config = cache::obtain_config(); $config = phpbb_cache::obtain_config();
// Add own hook handler
require(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
foreach (cache::obtain_hooks() as $hook)
{
@include(PHPBB_ROOT_PATH . 'includes/hooks/' . $hook . '.' . PHP_EXT);
}
?> ?>

View file

@ -17,7 +17,7 @@ if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
// Thank you sun. // Thank you sun.
if (isset($_SERVER['CONTENT_TYPE'])) if (isset($_SERVER['CONTENT_TYPE']))
{ {
if ($_SERVER['CONTENT_TYPE'] === 'application/x-java-archive') if ($_SERVER['CONTENT_TYPE'] === 'application/x-java-archive')
@ -35,11 +35,11 @@ if (request::is_set('avatar', request::GET))
// worst-case default // worst-case default
$browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : 'msie 6.0'; $browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : 'msie 6.0';
$config = cache::obtain_config(); $config = phpbb_cache::obtain_config();
$filename = request::variable('avatar', '', false, request::GET); $filename = request::variable('avatar', '', false, request::GET);
$avatar_group = false; $avatar_group = false;
$exit = false; $exit = false;
if ($filename[0] === 'g') if ($filename[0] === 'g')
{ {
$avatar_group = true; $avatar_group = true;
@ -66,8 +66,8 @@ if (request::is_set('avatar', request::GET))
header("HTTP/1.0 403 Forbidden"); header("HTTP/1.0 403 Forbidden");
$exit = true; $exit = true;
} }
if (!$exit) if (!$exit)
{ {
if (!$filename) if (!$filename)
@ -133,7 +133,7 @@ if ($attachment['is_orphan'])
} }
// Obtain all extensions... // Obtain all extensions...
$extensions = cache::obtain_attach_extensions(true); $extensions = phpbb_cache::obtain_extensions();
} }
else else
{ {

View file

@ -3,7 +3,7 @@
* *
* @package acm * @package acm
* @version $Id$ * @version $Id$
* @copyright (c) 2005 phpBB Group * @copyright (c) 2005, 2008 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
@ -17,81 +17,95 @@ if (!defined('IN_PHPBB'))
} }
/** /**
* Class for grabbing/handling cached entries, extends acm_file or acm_db depending on the setup * Class for obtaining cached entries, for example censor word list, configuration...
* @package acm * @package acm
*/ */
class cache class phpbb_cache
{ {
/**
* We do not want this object instantiable
*/
private function ___construct() { }
/**
* Required phpBB objects
*/
public $phpbb_required = array('config', 'acm', 'db');
/**
* Optional phpBB objects
*/
public $phpbb_optional = array();
/** /**
* Get config values * Get config values
*
* @return array configuration
* @access public
*/ */
public static function obtain_config() public static function obtain_config()
{ {
global $db, $cache; if ((phpbb::$config = phpbb::$acm->get('#config')) !== false)
if (($config = $cache->get('config')) !== false)
{ {
$sql = 'SELECT config_name, config_value $sql = 'SELECT config_name, config_value
FROM ' . CONFIG_TABLE . ' FROM ' . CONFIG_TABLE . '
WHERE is_dynamic = 1'; WHERE is_dynamic = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$config[$row['config_name']] = $row['config_value']; phpbb::$config[$row['config_name']] = $row['config_value'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
$config = $cached_config = array(); phpbb::$config = $cached_config = array();
$sql = 'SELECT config_name, config_value, is_dynamic $sql = 'SELECT config_name, config_value, is_dynamic
FROM ' . CONFIG_TABLE; FROM ' . CONFIG_TABLE;
$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['is_dynamic']) if (!$row['is_dynamic'])
{ {
$cached_config[$row['config_name']] = $row['config_value']; $cached_config[$row['config_name']] = $row['config_value'];
} }
$config[$row['config_name']] = $row['config_value']; phpbb::$config[$row['config_name']] = $row['config_value'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$cache->put('config', $cached_config); phpbb::$acm->put('#config', $cached_config);
} }
return $config; return phpbb::$config;
} }
/** /**
* Obtain list of naughty words and build preg style replacement arrays for use by the * Obtain list of naughty words and build preg style replacement arrays for use by the calling script
* calling script *
* @return array Censored words
* @access public
*/ */
public static function obtain_word_list() public static function obtain_word_list()
{ {
global $cache; if (($censors = phpbb::$acm->get('word_censors')) === false)
if (($censors = $cache->get('_word_censors')) === false)
{ {
global $db;
$sql = 'SELECT word, replacement $sql = 'SELECT word, replacement
FROM ' . WORDS_TABLE; FROM ' . WORDS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$censors = array(); $censors = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$censors['match'][] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')(?!\w)#i'; $censors['match'][] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')(?!\w)#i';
$censors['replace'][] = $row['replacement']; $censors['replace'][] = $row['replacement'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$cache->put('_word_censors', $censors); phpbb::$acm->put('word_censors', $censors);
} }
return $censors; return $censors;
@ -99,32 +113,31 @@ class cache
/** /**
* Obtain currently listed icons * Obtain currently listed icons
*
* @return array Icons
* @access public
*/ */
public static function obtain_icons() public static function obtain_icons()
{ {
global $cache; if (($icons = phpbb::$acm->get('icons')) === false)
if (($icons = $cache->get('_icons')) === false)
{ {
global $db;
// Topic icons // Topic icons
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ICONS_TABLE . ' FROM ' . ICONS_TABLE . '
ORDER BY icons_order'; ORDER BY icons_order';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$icons = array(); $icons = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$icons[$row['icons_id']]['img'] = $row['icons_url']; $icons[$row['icons_id']]['img'] = $row['icons_url'];
$icons[$row['icons_id']]['width'] = (int) $row['icons_width']; $icons[$row['icons_id']]['width'] = (int) $row['icons_width'];
$icons[$row['icons_id']]['height'] = (int) $row['icons_height']; $icons[$row['icons_id']]['height'] = (int) $row['icons_height'];
$icons[$row['icons_id']]['display'] = (bool) $row['display_on_posting']; $icons[$row['icons_id']]['display'] = (bool) $row['display_on_posting'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$cache->put('_icons', $icons); phpbb::$acm->put('icons', $icons);
} }
return $icons; return $icons;
@ -132,22 +145,21 @@ class cache
/** /**
* Obtain ranks * Obtain ranks
*
* @return Ranks
* @access public
*/ */
public static function obtain_ranks() public static function obtain_ranks()
{ {
global $cache; if (($ranks = phpbb::$acm->get('ranks')) === false)
if (($ranks = $cache->get('_ranks')) === false)
{ {
global $db;
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . RANKS_TABLE . ' FROM ' . RANKS_TABLE . '
ORDER BY rank_min DESC'; ORDER BY rank_min DESC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$ranks = array(); $ranks = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['rank_special']) if ($row['rank_special'])
{ {
@ -165,120 +177,146 @@ class cache
); );
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$cache->put('_ranks', $ranks); phpbb::$acm->put('ranks', $ranks);
} }
return $ranks; return $ranks;
} }
/** /**
* Obtain allowed extensions * Put attachment extensions data into cache
* *
* @param mixed $forum_id If false then check for private messaging, if int then check for forum id. If true, then only return extension informations. * @return array Cached extensions
* * @access private
* @return array allowed extensions array.
*/ */
public static function obtain_attach_extensions($forum_id) private static function cache_extensions()
{ {
global $cache; $extensions = array(
'_allowed_post' => array(),
'_allowed_pm' => array(),
);
if (($extensions = $cache->get('_extensions')) === false) // The rule is to only allow those extensions defined. ;)
$sql = 'SELECT e.extension, g.*
FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
WHERE e.group_id = g.group_id
AND (g.allow_group = 1 OR g.allow_in_pm = 1)';
$result = phpbb::$db->sql_query($sql);
while ($row = phpbb::$db->sql_fetchrow($result))
{ {
global $db; $extension = strtolower(trim($row['extension']));
$extensions = array( $extensions[$extension] = array(
'_allowed_post' => array(), 'display_cat' => (int) $row['cat_id'],
'_allowed_pm' => array(), 'download_mode' => (int) $row['download_mode'],
'upload_icon' => trim($row['upload_icon']),
'max_filesize' => (int) $row['max_filesize'],
'allow_group' => $row['allow_group'],
'allow_in_pm' => $row['allow_in_pm'],
); );
// The rule is to only allow those extensions defined. ;) $allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array();
$sql = 'SELECT e.extension, g.*
FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
WHERE e.group_id = g.group_id
AND (g.allow_group = 1 OR g.allow_in_pm = 1)';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) // Store allowed extensions forum wise
if ($row['allow_group'])
{ {
$extension = strtolower(trim($row['extension'])); $extensions['_allowed_post'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums;
$extensions[$extension] = array(
'display_cat' => (int) $row['cat_id'],
'download_mode' => (int) $row['download_mode'],
'upload_icon' => trim($row['upload_icon']),
'max_filesize' => (int) $row['max_filesize'],
'allow_group' => $row['allow_group'],
'allow_in_pm' => $row['allow_in_pm'],
);
$allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array();
// Store allowed extensions forum wise
if ($row['allow_group'])
{
$extensions['_allowed_post'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums;
}
if ($row['allow_in_pm'])
{
$extensions['_allowed_pm'][$extension] = 0;
}
}
$db->sql_freeresult($result);
$cache->put('_extensions', $extensions);
}
// Forum post
if ($forum_id === false)
{
// We are checking for private messages, therefore we only need to get the pm extensions...
$return = array('_allowed_' => array());
foreach ($extensions['_allowed_pm'] as $extension => $check)
{
$return['_allowed_'][$extension] = 0;
$return[$extension] = $extensions[$extension];
} }
$extensions = $return; if ($row['allow_in_pm'])
}
else if ($forum_id === true)
{
return $extensions;
}
else
{
$forum_id = (int) $forum_id;
$return = array('_allowed_' => array());
foreach ($extensions['_allowed_post'] as $extension => $check)
{ {
// Check for allowed forums $extensions['_allowed_pm'][$extension] = 0;
if (is_array($check)) }
{ }
$allowed = (!in_array($forum_id, $check)) ? false : true; phpbb::$db->sql_freeresult($result);
}
else
{
$allowed = true;
}
if ($allowed) phpbb::$acm->put('extensions', $extensions);
{ return $extensions;
$return['_allowed_'][$extension] = 0; }
$return[$extension] = $extensions[$extension];
} /**
* Obtain allowed attachment extensions in private messages
*
* @return array Allowed extensions
* @access public
*/
public static function obtain_extensions_pm()
{
if (($extensions = phpbb::$acm->get('extensions')) === false)
{
$extensions = self::cache_extensions();
}
// We are checking for private messages, therefore we only need to get the pm extensions...
$result = array('_allowed_' => array());
foreach ($extensions['_allowed_pm'] as $extension => $check)
{
$result['_allowed_'][$extension] = 0;
$result[$extension] = $extensions[$extension];
}
return $result;
}
/**
* Obtain allowed attachment extensions in specific forum
*
* @param int $forum_id The forum id
* @return array Allowed extensions within the specified forum
* @access public
*/
public static function obtain_extensions_forum($forum_id)
{
if (($extensions = phpbb::$acm->get('extensions')) === false)
{
$extensions = self::cache_extensions();
}
$forum_id = (int) $forum_id;
$result = array('_allowed_' => array());
foreach ($extensions['_allowed_post'] as $extension => $check)
{
// Check for allowed forums
if (is_array($check))
{
$allowed = (!in_array($forum_id, $check)) ? false : true;
}
else
{
$allowed = true;
} }
$extensions = $return; if ($allowed)
{
$result['_allowed_'][$extension] = 0;
$result[$extension] = $extensions[$extension];
}
} }
if (!isset($extensions['_allowed_'])) if (!isset($result['_allowed_']))
{ {
$extensions['_allowed_'] = array(); $result['_allowed_'] = array();
}
return $result;
}
/**
* Obtain general attachment extension information
*
* @return array Cached extension information
* @access public
*/
public static function obtain_extensions()
{
if (($extensions = phpbb::$acm->get('extensions')) === false)
{
$extensions = self::cache_extensions();
} }
return $extensions; return $extensions;
@ -286,47 +324,45 @@ class cache
/** /**
* Obtain active bots * Obtain active bots
*
* @return array Active bots
* @access public
*/ */
public static function obtain_bots() public static function obtain_bots()
{ {
global $cache; if (($bots = phpbb::$acm->get('bots')) === false)
if (($bots = $cache->get('_bots')) === false)
{ {
global $db; // @todo We order by last visit date. This way we are able to safe some cycles by checking the most active ones first.
$sql = 'SELECT user_id, bot_agent, bot_ip $sql = 'SELECT user_id, bot_agent, bot_ip
FROM ' . BOTS_TABLE . ' FROM ' . BOTS_TABLE . '
WHERE bot_active = 1 WHERE bot_active = 1
ORDER BY ' . $db->sql_function('length_varchar', 'bot_agent') . 'DESC'; ORDER BY ' . phpbb::$db->sql_function('length_varchar', 'bot_agent') . 'DESC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$bots = array(); $bots = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$bots[] = $row; $bots[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$cache->put('_bots', $bots); phpbb::$acm->put('bots', $bots);
} }
return $bots; return $bots;
} }
/** /**
* Obtain cfg file data * Obtain Styles .cfg file data
*
* @param array $theme An array containing the path to the item
* *
* @param array $theme An array containing the path to the items
* @param string $item The specific item to get: 'theme', 'template', or 'imageset' * @param string $item The specific item to get: 'theme', 'template', or 'imageset'
* * @return array The configuration
* @access public
*/ */
public static function obtain_cfg_item($theme, $item = 'theme') public static function obtain_cfg_item($theme, $item = 'theme')
{ {
global $config, $cache; $parsed_array = phpbb::$acm->get('cfg_' . $item . '_' . $theme[$item . '_path']);
$parsed_array = $cache->get('_cfg_' . $item . '_' . $theme[$item . '_path']);
if ($parsed_array === false) if ($parsed_array === false)
{ {
@ -341,7 +377,7 @@ class cache
return $parsed_array; return $parsed_array;
} }
if (!isset($parsed_array['filetime']) || (($config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime']))) if (!isset($parsed_array['filetime']) || ((phpbb::$config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime'])))
{ {
$reparse = true; $reparse = true;
} }
@ -352,7 +388,7 @@ class cache
$parsed_array = parse_cfg_file($filename); $parsed_array = parse_cfg_file($filename);
$parsed_array['filetime'] = @filemtime($filename); $parsed_array['filetime'] = @filemtime($filename);
$cache->put('_cfg_' . $item . '_' . $theme[$item . '_path'], $parsed_array); phpbb::$acm->put('cfg_' . $item . '_' . $theme[$item . '_path'], $parsed_array);
} }
return $parsed_array; return $parsed_array;
@ -360,63 +396,30 @@ class cache
/** /**
* Obtain disallowed usernames * Obtain disallowed usernames
*
* @return array Disallowed usernames
* @access public
*/ */
public static function obtain_disallowed_usernames() public static function obtain_disallowed_usernames()
{ {
global $cache; if (($usernames = phpbb::$acm->get('disallowed_usernames')) === false)
if (($usernames = $cache->get('_disallowed_usernames')) === false)
{ {
global $db;
$sql = 'SELECT disallow_username $sql = 'SELECT disallow_username
FROM ' . DISALLOW_TABLE; FROM ' . DISALLOW_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$usernames = array(); $usernames = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$usernames[] = str_replace('%', '.*?', preg_quote(utf8_clean_string($row['disallow_username']), '#')); $usernames[] = str_replace('%', '.*?', preg_quote(utf8_clean_string($row['disallow_username']), '#'));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$cache->put('_disallowed_usernames', $usernames); phpbb::$acm->put('disallowed_usernames', $usernames);
} }
return $usernames; return $usernames;
} }
/**
* Obtain hooks...
*/
public static function obtain_hooks()
{
global $cache;
if (($hook_files = $cache->get('_hooks')) === false)
{
$hook_files = array();
// Now search for hooks...
$dh = @opendir(PHPBB_ROOT_PATH . 'includes/hooks/');
if ($dh)
{
while (($file = readdir($dh)) !== false)
{
if (strpos($file, 'hook_') === 0 && substr($file, -(strlen(PHP_EXT) + 1)) === '.' . PHP_EXT)
{
$hook_files[] = substr($file, 0, -(strlen(PHP_EXT) + 1));
}
}
closedir($dh);
}
$cache->put('_hooks', $hook_files);
}
return $hook_files;
}
} }
?> ?>

View file

@ -682,7 +682,7 @@ function censor_text($text)
} }
else else
{ {
$censors = cache::obtain_word_list(); $censors = phpbb_cache::obtain_word_list();
} }
} }
@ -754,7 +754,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
if (empty($extensions) || !is_array($extensions)) if (empty($extensions) || !is_array($extensions))
{ {
$extensions = cache::obtain_attach_extensions($forum_id); $extensions = phpbb_cache::obtain_extensions_forum($forum_id);
} }
// Look for missing attachment information... // Look for missing attachment information...
@ -1069,7 +1069,7 @@ function extension_allowed($forum_id, $extension, &$extensions)
if (empty($extensions)) if (empty($extensions))
{ {
global $cache; global $cache;
$extensions = cache::obtain_attach_extensions($forum_id); $extensions = phpbb_cache::obtain_extensions_forum($forum_id);
} }
return (!isset($extensions['_allowed_'][$extension])) ? false : true; return (!isset($extensions['_allowed_'][$extension])) ? false : true;

View file

@ -1156,7 +1156,7 @@ function get_user_rank($user_id, $user_rank, $user_posts, &$rank_title, &$rank_i
if (empty($ranks)) if (empty($ranks))
{ {
global $cache; global $cache;
$ranks = cache::obtain_ranks(); $ranks = phpbb_cache::obtain_ranks();
} }
if (!empty($user_rank)) if (!empty($user_rank))

View file

@ -248,7 +248,7 @@ function posting_gen_topic_icons($mode, $icon_id)
global $config, $template, $cache; global $config, $template, $cache;
// Grab icons // Grab icons
$icons = cache::obtain_icons(); $icons = phpbb_cache::obtain_icons();
if (!$icon_id) if (!$icon_id)
{ {
@ -376,7 +376,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
return $filedata; return $filedata;
} }
$extensions = cache::obtain_attach_extensions((($is_message) ? false : (int) $forum_id)); $extensions = ($is_message) ? phpbb_cache::obtain_extensions_pm() : phpbb_cache::obtain_extensions_forum($forum_id);
$upload->set_allowed_extensions(array_keys($extensions['_allowed_'])); $upload->set_allowed_extensions(array_keys($extensions['_allowed_']));
$file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->form_upload($form_name); $file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->form_upload($form_name);
@ -998,7 +998,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$extensions = $attachments = array(); $extensions = $attachments = array();
if ($has_attachments && $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) if ($has_attachments && $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id))
{ {
$extensions = cache::obtain_attach_extensions($forum_id); $extensions = phpbb_cache::obtain_extensions_forum($forum_id);
// Get attachments... // Get attachments...
$sql = 'SELECT * $sql = 'SELECT *

View file

@ -1420,7 +1420,7 @@ function validate_username($username, $allowed_username = false)
return 'USERNAME_TAKEN'; return 'USERNAME_TAKEN';
} }
$bad_usernames = cache::obtain_disallowed_usernames(); $bad_usernames = phpbb_cache::obtain_disallowed_usernames();
foreach ($bad_usernames as $bad_username) foreach ($bad_usernames as $bad_username)
{ {

View file

@ -86,22 +86,6 @@ $user = new user();
$cache = new acm(); $cache = new acm();
$db = new $sql_db(); $db = new $sql_db();
// Add own hook handler, if present. :o
if (file_exists(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT))
{
require(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
foreach (cache::obtain_hooks() as $hook)
{
@include(PHPBB_ROOT_PATH . 'includes/hooks/' . $hook . '.' . PHP_EXT);
}
}
else
{
$phpbb_hook = false;
}
// Connect to DB // Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);

View file

@ -249,22 +249,6 @@ $auth = new auth();
$cache = new acm(); $cache = new acm();
$template = new template(); $template = new template();
// Add own hook handler, if present. :o
if (file_exists(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT))
{
require(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
foreach (cache::obtain_hooks() as $hook)
{
@include(PHPBB_ROOT_PATH . 'includes/hooks/' . $hook . '.' . PHP_EXT);
}
}
else
{
$phpbb_hook = false;
}
// Set some standard variables we want to force // Set some standard variables we want to force
$config = array( $config = array(
'load_tplcompile' => '1' 'load_tplcompile' => '1'

View file

@ -64,7 +64,7 @@ $sort_dir = request_var('sd', 'a');
// Grab rank information for later // Grab rank information for later
$ranks = cache::obtain_ranks(); $ranks = phpbb_cache::obtain_ranks();
// What do you want to do today? ... oops, I think that line is taken ... // What do you want to do today? ... oops, I think that line is taken ...

View file

@ -1660,7 +1660,7 @@ parse_css_file = {PARSE_CSS_FILE}
$theme_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['theme_name'], $style_row['theme_copyright'], $config['version']), $this->theme_cfg); $theme_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['theme_name'], $style_row['theme_copyright'], $config['version']), $this->theme_cfg);
// Read old cfg file // Read old cfg file
$items = cache::obtain_cfg_item($style_row, 'theme'); $items = phpbb_cache::obtain_cfg_item($style_row, 'theme');
if (!isset($items['parse_css_file'])) if (!isset($items['parse_css_file']))
{ {

View file

@ -134,7 +134,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
)); ));
// Grab icons // Grab icons
$icons = cache::obtain_icons(); $icons = phpbb_cache::obtain_icons();
$topic_rows = array(); $topic_rows = array();

View file

@ -140,7 +140,7 @@ function mcp_post_details($id, $mode, $action)
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
{ {
$extensions = cache::obtain_attach_extensions($post_info['forum_id']); $extensions = phpbb_cache::obtain_extensions_forum($post_info['forum_id']);
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '

View file

@ -140,7 +140,7 @@ class mcp_queue
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
{ {
$extensions = cache::obtain_attach_extensions($post_info['forum_id']); $extensions = phpbb_cache::obtain_extensions_forum($post_info['forum_id']);
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '

View file

@ -149,7 +149,7 @@ class mcp_reports
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
{ {
$extensions = cache::obtain_attach_extensions($post_info['forum_id']); $extensions = phpbb_cache::obtain_extensions_forum($post_info['forum_id']);
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
@ -425,7 +425,7 @@ class mcp_reports
'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
'TOPIC_ID' => $topic_id, 'TOPIC_ID' => $topic_id,
'TOTAL' => $total, 'TOTAL' => $total,
'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total),
) )
); );
@ -610,13 +610,13 @@ function close_report($report_id_list, $mode, $action)
$messenger->send($reporter['user_notify_type']); $messenger->send($reporter['user_notify_type']);
} }
} }
foreach ($post_info as $post) foreach ($post_info as $post)
{ {
$forum_ids[$post['forum_id']] = $post['forum_id']; $forum_ids[$post['forum_id']] = $post['forum_id'];
$topic_ids[$post['topic_id']] = $post['topic_id']; $topic_ids[$post['topic_id']] = $post['topic_id'];
} }
unset($notify_reporters, $post_info, $reports); unset($notify_reporters, $post_info, $reports);
$messenger->save_queue(); $messenger->save_queue();
@ -648,7 +648,7 @@ function close_report($report_id_list, $mode, $action)
{ {
$return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid('viewtopic', 't=' . current($topic_ids) . '&amp;f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />'; $return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid('viewtopic', 't=' . current($topic_ids) . '&amp;f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
} }
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>')); trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>'));
} }
} }

View file

@ -171,7 +171,7 @@ function mcp_topic_view($id, $mode, $action)
$extensions = $attachments = array(); $extensions = $attachments = array();
if ($topic_info['topic_attachment'] && sizeof($post_id_list)) if ($topic_info['topic_attachment'] && sizeof($post_id_list))
{ {
$extensions = cache::obtain_attach_extensions($topic_info['forum_id']); $extensions = phpbb_cache::obtain_extensions_forum($topic_info['forum_id']);
// Get attachments... // Get attachments...
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id']))

View file

@ -33,7 +33,7 @@ function view_folder($id, $mode, $folder_id, $folder)
$user->add_lang('viewforum'); $user->add_lang('viewforum');
// Grab icons // Grab icons
$icons = cache::obtain_icons(); $icons = phpbb_cache::obtain_icons();
$color_rows = array('marked', 'replied'); $color_rows = array('marked', 'replied');

View file

@ -46,7 +46,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
} }
// Grab icons // Grab icons
$icons = cache::obtain_icons(); $icons = phpbb_cache::obtain_icons();
$bbcode = false; $bbcode = false;

View file

@ -450,7 +450,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$user->add_lang('viewtopic'); $user->add_lang('viewtopic');
// Grab icons // Grab icons
$icons = cache::obtain_icons(); $icons = phpbb_cache::obtain_icons();
// Output header // Output header
if ($search_id && ($total_match_count > 1000)) if ($search_id && ($total_match_count > 1000))

View file

@ -306,7 +306,7 @@ $template->assign_vars(array(
'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true, 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true,
'S_IS_LOCKED' => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false, 'S_IS_LOCKED' => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false,
'S_VIEWFORUM' => true, 'S_VIEWFORUM' => true,
'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid('mcp', "f=$forum_id&amp;i=main&amp;mode=forum_view", true, $user->session_id) : '', 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid('mcp', "f=$forum_id&amp;i=main&amp;mode=forum_view", true, $user->session_id) : '',
'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid('posting', 'mode=post&amp;f=' . $forum_id) : '', 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid('posting', 'mode=post&amp;f=' . $forum_id) : '',
'U_VIEW_FORUM' => append_sid('viewforum', "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . "&amp;start=$start"), 'U_VIEW_FORUM' => append_sid('viewforum', "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . "&amp;start=$start"),
@ -314,7 +314,7 @@ $template->assign_vars(array(
)); ));
// Grab icons // Grab icons
$icons = cache::obtain_icons(); $icons = phpbb_cache::obtain_icons();
// Grab all topic data // Grab all topic data
$rowset = $announcement_list = $topic_list = $global_announce_list = array(); $rowset = $announcement_list = $topic_list = $global_announce_list = array();

View file

@ -505,16 +505,16 @@ if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('b
} }
// Grab ranks // Grab ranks
$ranks = cache::obtain_ranks(); $ranks = phpbb_cache::obtain_ranks();
// Grab icons // Grab icons
$icons = cache::obtain_icons(); $icons = phpbb_cache::obtain_icons();
// Grab extensions // Grab extensions
$extensions = array(); $extensions = array();
if ($topic_data['topic_attachment']) if ($topic_data['topic_attachment'])
{ {
$extensions = cache::obtain_attach_extensions($forum_id); $extensions = phpbb_cache::obtain_extensions_forum($forum_id);
} }
// Forum rules listing // Forum rules listing