mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08: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);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -35,7 +35,7 @@ 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;
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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,29 +177,22 @@ 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;
|
|
||||||
|
|
||||||
if (($extensions = $cache->get('_extensions')) === false)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$extensions = array(
|
$extensions = array(
|
||||||
'_allowed_post' => array(),
|
'_allowed_post' => array(),
|
||||||
'_allowed_pm' => array(),
|
'_allowed_pm' => array(),
|
||||||
|
@ -198,9 +203,9 @@ class cache
|
||||||
FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
|
FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
|
||||||
WHERE e.group_id = g.group_id
|
WHERE e.group_id = g.group_id
|
||||||
AND (g.allow_group = 1 OR g.allow_in_pm = 1)';
|
AND (g.allow_group = 1 OR g.allow_in_pm = 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))
|
||||||
{
|
{
|
||||||
$extension = strtolower(trim($row['extension']));
|
$extension = strtolower(trim($row['extension']));
|
||||||
|
|
||||||
|
@ -226,33 +231,53 @@ class cache
|
||||||
$extensions['_allowed_pm'][$extension] = 0;
|
$extensions['_allowed_pm'][$extension] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
phpbb::$db->sql_freeresult($result);
|
||||||
|
|
||||||
$cache->put('_extensions', $extensions);
|
phpbb::$acm->put('extensions', $extensions);
|
||||||
|
return $extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forum post
|
/**
|
||||||
if ($forum_id === false)
|
* 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...
|
// We are checking for private messages, therefore we only need to get the pm extensions...
|
||||||
$return = array('_allowed_' => array());
|
$result = array('_allowed_' => array());
|
||||||
|
|
||||||
foreach ($extensions['_allowed_pm'] as $extension => $check)
|
foreach ($extensions['_allowed_pm'] as $extension => $check)
|
||||||
{
|
{
|
||||||
$return['_allowed_'][$extension] = 0;
|
$result['_allowed_'][$extension] = 0;
|
||||||
$return[$extension] = $extensions[$extension];
|
$result[$extension] = $extensions[$extension];
|
||||||
}
|
}
|
||||||
|
|
||||||
$extensions = $return;
|
return $result;
|
||||||
}
|
}
|
||||||
else if ($forum_id === true)
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
{
|
{
|
||||||
return $extensions;
|
if (($extensions = phpbb::$acm->get('extensions')) === false)
|
||||||
|
{
|
||||||
|
$extensions = self::cache_extensions();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$forum_id = (int) $forum_id;
|
$forum_id = (int) $forum_id;
|
||||||
$return = array('_allowed_' => array());
|
$result = array('_allowed_' => array());
|
||||||
|
|
||||||
foreach ($extensions['_allowed_post'] as $extension => $check)
|
foreach ($extensions['_allowed_post'] as $extension => $check)
|
||||||
{
|
{
|
||||||
|
@ -268,17 +293,30 @@ class cache
|
||||||
|
|
||||||
if ($allowed)
|
if ($allowed)
|
||||||
{
|
{
|
||||||
$return['_allowed_'][$extension] = 0;
|
$result['_allowed_'][$extension] = 0;
|
||||||
$return[$extension] = $extensions[$extension];
|
$result[$extension] = $extensions[$extension];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$extensions = $return;
|
if (!isset($result['_allowed_']))
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($extensions['_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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -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;
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -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 *
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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'
|
||||||
|
|
|
@ -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 ...
|
||||||
|
|
|
@ -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']))
|
||||||
{
|
{
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -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 . '
|
||||||
|
|
|
@ -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 . '
|
||||||
|
|
|
@ -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 . '
|
||||||
|
|
|
@ -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']))
|
||||||
|
|
|
@ -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');
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue