mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
change cache:: to phpbb_cache::
git-svn-id: file:///svn/phpbb/trunk@9226 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
ac37f87105
commit
3cd007c49d
21 changed files with 229 additions and 267 deletions
|
@ -217,15 +217,6 @@ $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('
|
|||
unset($dbpasswd);
|
||||
|
||||
// Grab global variables, re-cache if necessary
|
||||
$config = 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);
|
||||
}
|
||||
$config = phpbb_cache::obtain_config();
|
||||
|
||||
?>
|
|
@ -17,7 +17,7 @@ if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
|
|||
include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
|
||||
|
||||
|
||||
// Thank you sun.
|
||||
// Thank you sun.
|
||||
if (isset($_SERVER['CONTENT_TYPE']))
|
||||
{
|
||||
if ($_SERVER['CONTENT_TYPE'] === 'application/x-java-archive')
|
||||
|
@ -35,11 +35,11 @@ if (request::is_set('avatar', request::GET))
|
|||
// worst-case default
|
||||
$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);
|
||||
$avatar_group = false;
|
||||
$exit = false;
|
||||
|
||||
|
||||
if ($filename[0] === 'g')
|
||||
{
|
||||
$avatar_group = true;
|
||||
|
@ -66,8 +66,8 @@ if (request::is_set('avatar', request::GET))
|
|||
header("HTTP/1.0 403 Forbidden");
|
||||
$exit = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!$exit)
|
||||
{
|
||||
if (!$filename)
|
||||
|
@ -133,7 +133,7 @@ if ($attachment['is_orphan'])
|
|||
}
|
||||
|
||||
// Obtain all extensions...
|
||||
$extensions = cache::obtain_attach_extensions(true);
|
||||
$extensions = phpbb_cache::obtain_extensions();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* @package acm
|
||||
* @version $Id$
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @copyright (c) 2005, 2008 phpBB Group
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @return array configuration
|
||||
* @access public
|
||||
*/
|
||||
public static function obtain_config()
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
if (($config = $cache->get('config')) !== false)
|
||||
if ((phpbb::$config = phpbb::$acm->get('#config')) !== false)
|
||||
{
|
||||
$sql = 'SELECT config_name, config_value
|
||||
FROM ' . CONFIG_TABLE . '
|
||||
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
|
||||
{
|
||||
$config = $cached_config = array();
|
||||
phpbb::$config = $cached_config = array();
|
||||
|
||||
$sql = 'SELECT config_name, config_value, is_dynamic
|
||||
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'])
|
||||
{
|
||||
$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
|
||||
* calling script
|
||||
* Obtain list of naughty words and build preg style replacement arrays for use by the calling script
|
||||
*
|
||||
* @return array Censored words
|
||||
* @access public
|
||||
*/
|
||||
public static function obtain_word_list()
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if (($censors = $cache->get('_word_censors')) === false)
|
||||
if (($censors = phpbb::$acm->get('word_censors')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT word, replacement
|
||||
FROM ' . WORDS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
$result = phpbb::$db->sql_query($sql);
|
||||
|
||||
$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['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;
|
||||
|
@ -99,32 +113,31 @@ class cache
|
|||
|
||||
/**
|
||||
* Obtain currently listed icons
|
||||
*
|
||||
* @return array Icons
|
||||
* @access public
|
||||
*/
|
||||
public static function obtain_icons()
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if (($icons = $cache->get('_icons')) === false)
|
||||
if (($icons = phpbb::$acm->get('icons')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Topic icons
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ICONS_TABLE . '
|
||||
ORDER BY icons_order';
|
||||
$result = $db->sql_query($sql);
|
||||
$result = phpbb::$db->sql_query($sql);
|
||||
|
||||
$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']]['width'] = (int) $row['icons_width'];
|
||||
$icons[$row['icons_id']]['height'] = (int) $row['icons_height'];
|
||||
$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;
|
||||
|
@ -132,22 +145,21 @@ class cache
|
|||
|
||||
/**
|
||||
* Obtain ranks
|
||||
*
|
||||
* @return Ranks
|
||||
* @access public
|
||||
*/
|
||||
public static function obtain_ranks()
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if (($ranks = $cache->get('_ranks')) === false)
|
||||
if (($ranks = phpbb::$acm->get('ranks')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . RANKS_TABLE . '
|
||||
ORDER BY rank_min DESC';
|
||||
$result = $db->sql_query($sql);
|
||||
$result = phpbb::$db->sql_query($sql);
|
||||
|
||||
$ranks = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
while ($row = phpbb::$db->sql_fetchrow($result))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 allowed extensions array.
|
||||
* @return array Cached extensions
|
||||
* @access private
|
||||
*/
|
||||
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(
|
||||
'_allowed_post' => array(),
|
||||
'_allowed_pm' => array(),
|
||||
$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'],
|
||||
);
|
||||
|
||||
// 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 = $db->sql_query($sql);
|
||||
$allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array();
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
// Store allowed extensions forum wise
|
||||
if ($row['allow_group'])
|
||||
{
|
||||
$extension = strtolower(trim($row['extension']));
|
||||
|
||||
$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['_allowed_post'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums;
|
||||
}
|
||||
|
||||
$extensions = $return;
|
||||
}
|
||||
else if ($forum_id === true)
|
||||
{
|
||||
return $extensions;
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_id = (int) $forum_id;
|
||||
$return = array('_allowed_' => array());
|
||||
|
||||
foreach ($extensions['_allowed_post'] as $extension => $check)
|
||||
if ($row['allow_in_pm'])
|
||||
{
|
||||
// Check for allowed forums
|
||||
if (is_array($check))
|
||||
{
|
||||
$allowed = (!in_array($forum_id, $check)) ? false : true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$allowed = true;
|
||||
}
|
||||
$extensions['_allowed_pm'][$extension] = 0;
|
||||
}
|
||||
}
|
||||
phpbb::$db->sql_freeresult($result);
|
||||
|
||||
if ($allowed)
|
||||
{
|
||||
$return['_allowed_'][$extension] = 0;
|
||||
$return[$extension] = $extensions[$extension];
|
||||
}
|
||||
phpbb::$acm->put('extensions', $extensions);
|
||||
return $extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
@ -286,47 +324,45 @@ class cache
|
|||
|
||||
/**
|
||||
* Obtain active bots
|
||||
*
|
||||
* @return array Active bots
|
||||
* @access public
|
||||
*/
|
||||
public static function obtain_bots()
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if (($bots = $cache->get('_bots')) === false)
|
||||
if (($bots = phpbb::$acm->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
|
||||
FROM ' . BOTS_TABLE . '
|
||||
WHERE bot_active = 1
|
||||
ORDER BY ' . $db->sql_function('length_varchar', 'bot_agent') . 'DESC';
|
||||
$result = $db->sql_query($sql);
|
||||
ORDER BY ' . phpbb::$db->sql_function('length_varchar', 'bot_agent') . 'DESC';
|
||||
$result = phpbb::$db->sql_query($sql);
|
||||
|
||||
$bots = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
while ($row = phpbb::$db->sql_fetchrow($result))
|
||||
{
|
||||
$bots[] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
phpbb::$db->sql_freeresult($result);
|
||||
|
||||
$cache->put('_bots', $bots);
|
||||
phpbb::$acm->put('bots', $bots);
|
||||
}
|
||||
|
||||
return $bots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain cfg file data
|
||||
*
|
||||
* @param array $theme An array containing the path to the item
|
||||
* Obtain Styles .cfg file data
|
||||
*
|
||||
* @param array $theme An array containing the path to the items
|
||||
* @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')
|
||||
{
|
||||
global $config, $cache;
|
||||
|
||||
$parsed_array = $cache->get('_cfg_' . $item . '_' . $theme[$item . '_path']);
|
||||
$parsed_array = phpbb::$acm->get('cfg_' . $item . '_' . $theme[$item . '_path']);
|
||||
|
||||
if ($parsed_array === false)
|
||||
{
|
||||
|
@ -341,7 +377,7 @@ class cache
|
|||
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;
|
||||
}
|
||||
|
@ -352,7 +388,7 @@ class cache
|
|||
$parsed_array = parse_cfg_file($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;
|
||||
|
@ -360,63 +396,30 @@ class cache
|
|||
|
||||
/**
|
||||
* Obtain disallowed usernames
|
||||
*
|
||||
* @return array Disallowed usernames
|
||||
* @access public
|
||||
*/
|
||||
public static function obtain_disallowed_usernames()
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if (($usernames = $cache->get('_disallowed_usernames')) === false)
|
||||
if (($usernames = phpbb::$acm->get('disallowed_usernames')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT disallow_username
|
||||
FROM ' . DISALLOW_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
$result = phpbb::$db->sql_query($sql);
|
||||
|
||||
$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']), '#'));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
phpbb::$db->sql_freeresult($result);
|
||||
|
||||
$cache->put('_disallowed_usernames', $usernames);
|
||||
phpbb::$acm->put('disallowed_usernames', $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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -682,7 +682,7 @@ function censor_text($text)
|
|||
}
|
||||
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))
|
||||
{
|
||||
$extensions = cache::obtain_attach_extensions($forum_id);
|
||||
$extensions = phpbb_cache::obtain_extensions_forum($forum_id);
|
||||
}
|
||||
|
||||
// Look for missing attachment information...
|
||||
|
@ -1069,7 +1069,7 @@ function extension_allowed($forum_id, $extension, &$extensions)
|
|||
if (empty($extensions))
|
||||
{
|
||||
global $cache;
|
||||
$extensions = cache::obtain_attach_extensions($forum_id);
|
||||
$extensions = phpbb_cache::obtain_extensions_forum($forum_id);
|
||||
}
|
||||
|
||||
return (!isset($extensions['_allowed_'][$extension])) ? false : true;
|
||||
|
|
|
@ -1156,7 +1156,7 @@ function get_user_rank($user_id, $user_rank, $user_posts, &$rank_title, &$rank_i
|
|||
if (empty($ranks))
|
||||
{
|
||||
global $cache;
|
||||
$ranks = cache::obtain_ranks();
|
||||
$ranks = phpbb_cache::obtain_ranks();
|
||||
}
|
||||
|
||||
if (!empty($user_rank))
|
||||
|
|
|
@ -248,7 +248,7 @@ function posting_gen_topic_icons($mode, $icon_id)
|
|||
global $config, $template, $cache;
|
||||
|
||||
// Grab icons
|
||||
$icons = cache::obtain_icons();
|
||||
$icons = phpbb_cache::obtain_icons();
|
||||
|
||||
if (!$icon_id)
|
||||
{
|
||||
|
@ -376,7 +376,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
|
|||
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_']));
|
||||
|
||||
$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();
|
||||
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...
|
||||
$sql = 'SELECT *
|
||||
|
|
|
@ -1420,7 +1420,7 @@ function validate_username($username, $allowed_username = false)
|
|||
return 'USERNAME_TAKEN';
|
||||
}
|
||||
|
||||
$bad_usernames = cache::obtain_disallowed_usernames();
|
||||
$bad_usernames = phpbb_cache::obtain_disallowed_usernames();
|
||||
|
||||
foreach ($bad_usernames as $bad_username)
|
||||
{
|
||||
|
|
|
@ -86,22 +86,6 @@ $user = new user();
|
|||
$cache = new acm();
|
||||
$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
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
|
||||
|
||||
|
|
|
@ -249,22 +249,6 @@ $auth = new auth();
|
|||
$cache = new acm();
|
||||
$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
|
||||
$config = array(
|
||||
'load_tplcompile' => '1'
|
||||
|
|
|
@ -64,7 +64,7 @@ $sort_dir = request_var('sd', 'a');
|
|||
|
||||
|
||||
// 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 ...
|
||||
|
|
|
@ -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);
|
||||
|
||||
// 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']))
|
||||
{
|
||||
|
|
|
@ -134,7 +134,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
|
|||
));
|
||||
|
||||
// Grab icons
|
||||
$icons = cache::obtain_icons();
|
||||
$icons = phpbb_cache::obtain_icons();
|
||||
|
||||
$topic_rows = array();
|
||||
|
||||
|
|
|
@ -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']))
|
||||
{
|
||||
$extensions = cache::obtain_attach_extensions($post_info['forum_id']);
|
||||
$extensions = phpbb_cache::obtain_extensions_forum($post_info['forum_id']);
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
|
|
|
@ -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']))
|
||||
{
|
||||
$extensions = cache::obtain_attach_extensions($post_info['forum_id']);
|
||||
$extensions = phpbb_cache::obtain_extensions_forum($post_info['forum_id']);
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
|
|
|
@ -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']))
|
||||
{
|
||||
$extensions = cache::obtain_attach_extensions($post_info['forum_id']);
|
||||
$extensions = phpbb_cache::obtain_extensions_forum($post_info['forum_id']);
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
|
@ -425,7 +425,7 @@ class mcp_reports
|
|||
'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
|
||||
'TOPIC_ID' => $topic_id,
|
||||
'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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($post_info as $post)
|
||||
{
|
||||
$forum_ids[$post['forum_id']] = $post['forum_id'];
|
||||
$topic_ids[$post['topic_id']] = $post['topic_id'];
|
||||
}
|
||||
|
||||
|
||||
unset($notify_reporters, $post_info, $reports);
|
||||
|
||||
$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) . '&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>'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ function mcp_topic_view($id, $mode, $action)
|
|||
$extensions = $attachments = array();
|
||||
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...
|
||||
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id']))
|
||||
|
|
|
@ -33,7 +33,7 @@ function view_folder($id, $mode, $folder_id, $folder)
|
|||
$user->add_lang('viewforum');
|
||||
|
||||
// Grab icons
|
||||
$icons = cache::obtain_icons();
|
||||
$icons = phpbb_cache::obtain_icons();
|
||||
|
||||
$color_rows = array('marked', 'replied');
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
|
|||
}
|
||||
|
||||
// Grab icons
|
||||
$icons = cache::obtain_icons();
|
||||
$icons = phpbb_cache::obtain_icons();
|
||||
|
||||
$bbcode = false;
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
|||
$user->add_lang('viewtopic');
|
||||
|
||||
// Grab icons
|
||||
$icons = cache::obtain_icons();
|
||||
$icons = phpbb_cache::obtain_icons();
|
||||
|
||||
// Output header
|
||||
if ($search_id && ($total_match_count > 1000))
|
||||
|
|
|
@ -306,7 +306,7 @@ $template->assign_vars(array(
|
|||
'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_VIEWFORUM' => true,
|
||||
|
||||
|
||||
'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid('mcp', "f=$forum_id&i=main&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&f=' . $forum_id) : '',
|
||||
'U_VIEW_FORUM' => append_sid('viewforum', "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . "&start=$start"),
|
||||
|
@ -314,7 +314,7 @@ $template->assign_vars(array(
|
|||
));
|
||||
|
||||
// Grab icons
|
||||
$icons = cache::obtain_icons();
|
||||
$icons = phpbb_cache::obtain_icons();
|
||||
|
||||
// Grab all topic data
|
||||
$rowset = $announcement_list = $topic_list = $global_announce_list = array();
|
||||
|
|
|
@ -505,16 +505,16 @@ if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('b
|
|||
}
|
||||
|
||||
// Grab ranks
|
||||
$ranks = cache::obtain_ranks();
|
||||
$ranks = phpbb_cache::obtain_ranks();
|
||||
|
||||
// Grab icons
|
||||
$icons = cache::obtain_icons();
|
||||
$icons = phpbb_cache::obtain_icons();
|
||||
|
||||
// Grab extensions
|
||||
$extensions = array();
|
||||
if ($topic_data['topic_attachment'])
|
||||
{
|
||||
$extensions = cache::obtain_attach_extensions($forum_id);
|
||||
$extensions = phpbb_cache::obtain_extensions_forum($forum_id);
|
||||
}
|
||||
|
||||
// Forum rules listing
|
||||
|
|
Loading…
Add table
Reference in a new issue