1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 16:56:44 +02:00

implement new phpbb::$acm object, replacing $cache global

git-svn-id: file:///svn/phpbb/trunk@9240 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2008-12-28 13:27:58 +00:00
parent fbaf2baa8d
commit 889fa87140
57 changed files with 543 additions and 774 deletions

View File

@@ -17,36 +17,38 @@ if (!defined('IN_PHPBB'))
}
/**
* Permission/Auth class
* Permission/ACL class
* @package phpBB3
*/
class auth
class phpbb_acl
{
public $phpbb_required = array('acm', 'db');
public $phpbb_optional = array();
public $acl_raw;
private $acl = array();
private $cache = array();
public $acl_options = array();
private $acl_forum_ids = false;
private $acl_element_ids = false;
private $recache = false;
/**
* Init permissions
*/
function acl(array &$userdata)
public function __construct()
{
global $db, $cache;
$this->acl = $this->cache = $this->acl_options = array();
$this->acl_forum_ids = false;
$this->acl_element_ids = false;
if (($this->acl_options = $cache->get('_acl_options')) === false)
if (($this->acl_options = phpbb::$acm->get('acl_options')) === false)
{
$sql = 'SELECT auth_option_id, auth_option, is_global, is_local
FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id';
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
$global = $local = 0;
$this->acl_options = array();
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
if ($row['is_global'])
{
@@ -61,12 +63,22 @@ class auth
$this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id'];
$this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option'];
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
$cache->put('_acl_options', $this->acl_options);
$this->acl_cache($userdata);
phpbb::$acm->put('acl_options', $this->acl_options);
$this->recache = true;
}
else if (!trim($userdata['user_permissions']))
// Add raw data acl class
$this->acl_raw = new phpbb_acl_raw_data();
}
/**
* Init permissions
*/
public function init(array &$userdata)
{
if (!trim($userdata['user_permissions']) || $this->recache)
{
$this->acl_cache($userdata);
}
@@ -150,7 +162,6 @@ class auth
$opt = substr($opt, 1);
}
// @todo: use the ref technique to reduce opcode generation
if (!isset($this->cache[$f][$opt]))
{
// We combine the global/local option with an OR because some options are global and local.
@@ -203,23 +214,21 @@ class auth
{
if ($this->acl_forum_ids === false)
{
global $db;
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
if (sizeof($this->acl))
{
$sql .= ' WHERE ' . $db->sql_in_set('forum_id', array_keys($this->acl), true);
$sql .= ' WHERE ' . phpbb::$db->sql_in_set('forum_id', array_keys($this->acl), true);
}
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
$this->acl_forum_ids = array();
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
$this->acl_forum_ids[] = $row['forum_id'];
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
}
}
@@ -342,11 +351,11 @@ class auth
{
if ($user_id !== false && !is_array($user_id) && $opts === false && $forum_id === false)
{
$hold_ary = array($user_id => $this->acl_raw_data_single_user($user_id));
$hold_ary = array($user_id => $this->acl_raw->single_user($user_id));
}
else
{
$hold_ary = $this->acl_raw_data($user_id, $opts, $forum_id);
$hold_ary = $this->acl_raw->data($user_id, $opts, $forum_id);
}
$auth_ary = array();
@@ -372,17 +381,15 @@ class auth
*/
public function acl_cache(array &$userdata)
{
global $db;
// Empty user_permissions
$userdata['user_permissions'] = '';
$hold_ary = $this->acl_raw_data_single_user($userdata['user_id']);
$hold_ary = $this->acl_raw->single_user($userdata['user_id']);
// Key 0 in $hold_ary are global options, all others are forum_ids
// If this user is founder we're going to force fill the admin options ...
if ($userdata['user_type'] == phpbb::USER_FOUNDER)
if ($userdata['user_type'] == USER_FOUNDER)
{
foreach ($this->acl_options['global'] as $opt => $id)
{
@@ -400,10 +407,10 @@ class auth
$userdata['user_permissions'] = $hold_str;
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_permissions = '" . $db->sql_escape($userdata['user_permissions']) . "',
SET user_permissions = '" . phpbb::$db->sql_escape($userdata['user_permissions']) . "',
user_perm_from = 0
WHERE user_id = " . $userdata['user_id'];
$db->sql_query($sql);
phpbb::$db->sql_query($sql);
}
return;
@@ -475,29 +482,27 @@ class auth
*/
public function acl_clear_prefetch($user_id = false)
{
global $db, $cache;
// Rebuild options cache
$cache->destroy('_role_cache');
phpbb::$acm->destroy('role_cache');
$sql = 'SELECT *
FROM ' . ACL_ROLES_DATA_TABLE . '
ORDER BY role_id ASC';
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
$this->role_cache = array();
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
$this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting'];
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
foreach ($this->role_cache as $role_id => $role_options)
{
$this->role_cache[$role_id] = serialize($role_options);
}
$cache->put('_role_cache', $this->role_cache);
phpbb::$acm->put('role_cache', $this->role_cache);
// Now empty user permissions
$where_sql = '';
@@ -505,62 +510,72 @@ class auth
if ($user_id !== false)
{
$user_id = (!is_array($user_id)) ? $user_id = array((int) $user_id) : array_map('intval', $user_id);
$where_sql = ' WHERE ' . $db->sql_in_set('user_id', $user_id);
$where_sql = ' WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id);
}
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_permissions = '',
user_perm_from = 0
$where_sql";
$db->sql_query($sql);
phpbb::$db->sql_query($sql);
return;
}
/**
}
* Role-specific methods/definitionis used by phpbb_acl
class phpbb_acl_role
{
*/
/**
* Get assigned roles
* @todo: protected or public?
*/
public function acl_role_data($user_type, $role_type, $ug_id = false, $forum_id = false)
{
global $db;
$roles = array();
$sql_id = ($user_type == 'user') ? 'user_id' : 'group_id';
$sql_ug = ($ug_id !== false) ? ((!is_array($ug_id)) ? "AND a.$sql_id = $ug_id" : 'AND ' . $db->sql_in_set("a.$sql_id", $ug_id)) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? "AND a.forum_id = $forum_id" : 'AND ' . $db->sql_in_set('a.forum_id', $forum_id)) : '';
$sql_ug = ($ug_id !== false) ? ((!is_array($ug_id)) ? "AND a.$sql_id = $ug_id" : 'AND ' . phpbb::$db->sql_in_set("a.$sql_id", $ug_id)) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? "AND a.forum_id = $forum_id" : 'AND ' . phpbb::$db->sql_in_set('a.forum_id', $forum_id)) : '';
// Grab assigned roles...
$sql = 'SELECT a.auth_role_id, a.' . $sql_id . ', a.forum_id
FROM ' . (($user_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE) . ' a, ' . ACL_ROLES_TABLE . " r
WHERE a.auth_role_id = r.role_id
AND r.role_type = '" . $db->sql_escape($role_type) . "'
AND r.role_type = '" . phpbb::$db->sql_escape($role_type) . "'
$sql_ug
$sql_forum
ORDER BY r.role_order ASC";
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
$roles[$row[$sql_id]][$row['forum_id']] = $row['auth_role_id'];
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
return $roles;
}
}
/**
* data-specific methods/definitionis used by phpbb_acl
*/
class phpbb_acl_raw_data
{
/**
* Get raw acl data based on user/option/forum
* @todo: protected or public?
*/
public function acl_raw_data($user_id = false, $opts = false, $forum_id = false)
public function data($user_id = false, $opts = false, $forum_id = false)
{
global $db;
$sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : $db->sql_in_set('user_id', array_map('intval', $user_id))) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : phpbb::$db->sql_in_set('user_id', array_map('intval', $user_id))) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . phpbb::$db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_opts = $sql_opts_select = $sql_opts_from = '';
$hold_ary = array();
@@ -594,14 +609,14 @@ class auth
foreach ($sql_ary as $sql)
{
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
$option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']];
$hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting'];
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
}
$sql_ary = array();
@@ -630,9 +645,9 @@ class auth
foreach ($sql_ary as $sql)
{
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
$option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']];
@@ -641,7 +656,7 @@ class auth
{
$hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting'];
// If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
// If we detect phpbb::ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
if ($row['auth_setting'] == phpbb::ACL_NEVER)
{
$flag = substr($option, 0, strpos($option, '_') + 1);
@@ -659,7 +674,7 @@ class auth
}
}
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
}
return $hold_ary;
@@ -668,12 +683,10 @@ class auth
/**
* Get raw user based permission settings
*/
public function acl_user_raw_data($user_id = false, $opts = false, $forum_id = false)
public function user($user_id = false, $opts = false, $forum_id = false)
{
global $db;
$sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : $db->sql_in_set('user_id', array_map('intval', $user_id))) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : phpbb::$db->sql_in_set('user_id', array_map('intval', $user_id))) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . phpbb::$db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_opts = '';
$hold_ary = $sql_ary = array();
@@ -705,13 +718,13 @@ class auth
foreach ($sql_ary as $sql)
{
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
$hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] = $row['auth_setting'];
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
}
return $hold_ary;
@@ -720,12 +733,10 @@ class auth
/**
* Get raw group based permission settings
*/
public function acl_group_raw_data($group_id = false, $opts = false, $forum_id = false)
public function group($group_id = false, $opts = false, $forum_id = false)
{
global $db;
$sql_group = ($group_id !== false) ? ((!is_array($group_id)) ? 'group_id = ' . (int) $group_id : $db->sql_in_set('group_id', array_map('intval', $group_id))) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_group = ($group_id !== false) ? ((!is_array($group_id)) ? 'group_id = ' . (int) $group_id : phpbb::$db->sql_in_set('group_id', array_map('intval', $group_id))) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . phpbb::$db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_opts = '';
$hold_ary = $sql_ary = array();
@@ -757,13 +768,13 @@ class auth
foreach ($sql_ary as $sql)
{
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
$hold_ary[$row['group_id']][$row['forum_id']][$row['auth_option']] = $row['auth_setting'];
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
}
return $hold_ary;
@@ -771,14 +782,12 @@ class auth
/**
* Get raw acl data based on user for caching user_permissions
* This function returns the same data as acl_raw_data(), but without the user id as the first key within the array.
* This function returns the same data as data(), but without the user id as the first key within the array.
*/
public function acl_raw_data_single_user($user_id)
public function single_user($user_id)
{
global $db, $cache;
// Check if the role-cache is there
if (($this->role_cache = $cache->get('_role_cache')) === false)
if (($this->role_cache = phpbb::$acm->get('role_cache')) === false)
{
$this->role_cache = array();
@@ -786,20 +795,20 @@ class auth
$sql = 'SELECT *
FROM ' . ACL_ROLES_DATA_TABLE . '
ORDER BY role_id ASC';
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
$this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting'];
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
foreach ($this->role_cache as $role_id => $role_options)
{
$this->role_cache[$role_id] = serialize($role_options);
}
$cache->put('_role_cache', $this->role_cache);
phpbb::$acm->put('role_cache', $this->role_cache);
}
$hold_ary = array();
@@ -808,9 +817,9 @@ class auth
$sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
FROM ' . ACL_USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
// If a role is assigned, assign all options included within this role. Else, only set this one option.
if ($row['auth_role_id'])
@@ -822,7 +831,7 @@ class auth
$hold_ary[$row['forum_id']][$row['auth_option_id']] = $row['auth_setting'];
}
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
// Now grab group-specific permission settings
$sql = 'SELECT a.forum_id, a.auth_option_id, a.auth_role_id, a.auth_setting
@@ -830,9 +839,9 @@ class auth
WHERE a.group_id = ug.group_id
AND ug.user_pending = 0
AND ug.user_id = ' . $user_id;
$result = $db->sql_query($sql);
$result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = phpbb::$db->sql_fetchrow($result))
{
if (!$row['auth_role_id'])
{
@@ -846,7 +855,7 @@ class auth
}
}
}
$db->sql_freeresult($result);
phpbb::$db->sql_freeresult($result);
return $hold_ary;
}
@@ -860,7 +869,7 @@ class auth
{
$hold_ary[$option_id] = $setting;
// If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
// If we detect phpbb::ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
if ($setting == phpbb::ACL_NEVER)
{
$flag = substr($this->acl_options['option'][$option_id], 0, strpos($this->acl_options['option'][$option_id], '_') + 1);
@@ -880,124 +889,20 @@ class auth
}
}
/**
* Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him.
*/
public function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0)
{
global $config, $db, $user;
$method = trim(basename($config['auth_method']));
include_once(PHPBB_ROOT_PATH . 'includes/auth/auth_' . $method . '.' . PHP_EXT);
$method = 'login_' . $method;
if (function_exists($method))
{
$login = $method($username, $password);
// If the auth module wants us to create an empty profile do so and then treat the status as LOGIN_SUCCESS
if ($login['status'] == LOGIN_SUCCESS_CREATE_PROFILE)
{
// we are going to use the user_add function so include functions_user.php if it wasn't defined yet
if (!function_exists('user_add'))
{
include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT);
}
user_add($login['user_row'], (isset($login['cp_data'])) ? $login['cp_data'] : false);
$sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type
FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row)
{
return array(
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
'error_msg' => 'AUTH_NO_PROFILE_CREATED',
'user_row' => array('user_id' => ANONYMOUS),
);
}
$login = array(
'status' => LOGIN_SUCCESS,
'error_msg' => false,
'user_row' => $row,
);
}
// If login succeeded, we will log the user in... else we pass the login array through...
if ($login['status'] == LOGIN_SUCCESS)
{
$old_session_id = $user->session_id;
if ($admin)
{
global $SID, $_SID;
$cookie_expire = time() - 31536000;
$user->set_cookie('u', '', $cookie_expire);
$user->set_cookie('sid', '', $cookie_expire);
unset($cookie_expire);
$SID = '?sid=';
$user->session_id = $_SID = '';
}
$result = $user->session_create($login['user_row']['user_id'], $admin, $autologin, $viewonline);
// Successful session creation
if ($result === true)
{
// If admin re-authentication we remove the old session entry because a new one has been created...
if ($admin)
{
// the login array is used because the user ids do not differ for re-authentication
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
WHERE session_id = '" . $db->sql_escape($old_session_id) . "'
AND session_user_id = {$login['user_row']['user_id']}";
$db->sql_query($sql);
}
return array(
'status' => LOGIN_SUCCESS,
'error_msg' => false,
'user_row' => $login['user_row'],
);
}
return array(
'status' => LOGIN_BREAK,
'error_msg' => $result,
'user_row' => $login['user_row'],
);
}
return $login;
}
trigger_error('Authentication method not found', E_USER_ERROR);
}
/**
* Fill auth_option statement for later querying based on the supplied options
*/
private function build_auth_option_statement($key, $auth_options, &$sql_opts)
{
global $db;
if (!is_array($auth_options))
{
if (strpos($auth_options, '%') !== false)
{
$sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->any_char, $auth_options));
$sql_opts = "AND $key " . phpbb::$db->sql_like_expression(str_replace('%', phpbb::$db->any_char, $auth_options));
}
else
{
$sql_opts = "AND $key = '" . $db->sql_escape($auth_options) . "'";
$sql_opts = "AND $key = '" . phpbb::$db->sql_escape($auth_options) . "'";
}
}
else
@@ -1014,7 +919,7 @@ class auth
if (!$is_like_expression)
{
$sql_opts = 'AND ' . $db->sql_in_set($key, $auth_options);
$sql_opts = 'AND ' . phpbb::$db->sql_in_set($key, $auth_options);
}
else
{
@@ -1024,11 +929,11 @@ class auth
{
if (strpos($option, '%') !== false)
{
$sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->any_char, $option));
$sql[] = $key . ' ' . phpbb::$db->sql_like_expression(str_replace('%', phpbb::$db->any_char, $option));
}
else
{
$sql[] = $key . " = '" . $db->sql_escape($option) . "'";
$sql[] = $key . " = '" . phpbb::$db->sql_escape($option) . "'";
}
}

View File

@@ -20,9 +20,12 @@ if (!defined('IN_PHPBB'))
* Base Template class.
* @package phpBB3
*/
class template
class phpbb_template
{
/**
public $phpbb_required = array('user', 'config');
public $phpbb_optional = array();
/**
* variable that holds all the data we'll be substituting into
* the compiled templates. Takes form:
* --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
@@ -63,16 +66,14 @@ class template
*/
public function set_template()
{
global $user;
if (file_exists(PHPBB_ROOT_PATH . 'styles/' . $user->theme['template_path'] . '/template'))
if (file_exists(PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['template_path'] . '/template'))
{
$this->root = PHPBB_ROOT_PATH . 'styles/' . $user->theme['template_path'] . '/template';
$this->cachepath = PHPBB_ROOT_PATH . 'cache/tpl_' . $user->theme['template_path'] . '_';
$this->root = PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['template_path'] . '/template';
$this->cachepath = PHPBB_ROOT_PATH . 'cache/tpl_' . phpbb::$user->theme['template_path'] . '_';
}
else
{
trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR);
trigger_error('Template path could not be found: styles/' . phpbb::$user->theme['template_path'] . '/template', E_USER_ERROR);
}
$this->_rootref = &$this->_tpldata['.'][0];
@@ -158,8 +159,7 @@ class template
*/
public function display($handle, $include_once = true)
{
global $user, $phpbb_hook;
/*
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once))
{
if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__)))
@@ -167,7 +167,7 @@ class template
return $phpbb_hook->hook_return_result(array(__CLASS__, __FUNCTION__));
}
}
*/
/* if (defined('IN_ERROR_HANDLER'))
{
if ((E_NOTICE & error_reporting()) == E_NOTICE)
@@ -178,7 +178,7 @@ class template
$_tpldata = &$this->_tpldata;
$_rootref = &$this->_rootref;
$_lang = &$user->lang;
$_lang = &phpbb::$user->lang;
// These _are_ used the included files.
$_tpldata; $_rootref; $_lang;
@@ -235,21 +235,19 @@ class template
*/
private function _tpl_load($handle)
{
global $config;
$filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . PHP_EXT;
$recompile = (!file_exists($filename) || @filesize($filename) === 0 || ($config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle]))) ? true : false;
$recompile = (!file_exists($filename) || @filesize($filename) === 0 || (phpbb::$config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle]))) ? true : false;
if (defined('DEBUG_EXTRA'))
{
$recompile = true;
}
// Recompile page if the original template is newer, otherwise load the compiled version
if ($recompile)
{
if (!class_exists('template_compile'))
{
include(PHPBB_ROOT_PATH . 'includes/functions_template.' . PHP_EXT);
}
$compile = new template_compile($this);
$compile = new phpbb_template_compile($this);
// If we don't have a file assigned to this handle, die.
if (!isset($this->files[$handle]))
@@ -275,12 +273,7 @@ class template
*/
private function _tpl_eval($handle)
{
if (!class_exists('template_compile'))
{
include(PHPBB_ROOT_PATH . 'includes/functions_template.' . PHP_EXT);
}
$compile = new template_compile($this);
$compile = new phpbb_template_compile($this);
// If we don't have a file assigned to this handle, die.
if (!isset($this->files[$handle]))
@@ -500,11 +493,9 @@ class template
if ($include)
{
global $user;
$_tpldata = &$this->_tpldata;
$_rootref = &$this->_rootref;
$_lang = &$user->lang;
$_lang = &phpbb::$user->lang;
// These _are_ used the included files.
$_tpldata; $_rootref; $_lang;
@@ -516,12 +507,7 @@ class template
}
else
{
if (!class_exists('template_compile'))
{
include(PHPBB_ROOT_PATH . 'includes/functions_template.' . PHP_EXT);
}
$compile = new template_compile($this);
$compile = new phpbb_template_compile($this);
if (($code = $compile->_tpl_gen_src($handle)) !== false)
{

View File

@@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
* @package phpBB3
*
*/
class template_filter extends php_user_filter
class phpbb_template_filter extends php_user_filter
{
/**
* @var string Replaceable tokens regex
@@ -93,8 +93,6 @@ class template_filter extends php_user_filter
private function replace($matches)
{
global $config;
if (isset($matches[3]))
{
return $this->compile_var_tags($matches[0]);
@@ -146,15 +144,15 @@ class template_filter extends php_user_filter
break;
case 'INCLUDEPHP':
return ($config['tpl_allow_php']) ? '<?php ' . $this->compile_tag_include_php($matches[2]) . ' ?>' : '';
return (phpbb::$config['tpl_allow_php']) ? '<?php ' . $this->compile_tag_include_php($matches[2]) . ' ?>' : '';
break;
case 'PHP':
return ($config['tpl_allow_php']) ? '<?php ' : '<!-- ';
return (phpbb::$config['tpl_allow_php']) ? '<?php ' : '<!-- ';
break;
case 'ENDPHP':
return ($config['tpl_allow_php']) ? ' ?>' : ' -->';
return (phpbb::$config['tpl_allow_php']) ? ' ?>' : ' -->';
break;
default:
@@ -437,7 +435,7 @@ class template_filter extends php_user_filter
$namespace = substr($varrefs[1], 0, -1);
$namespace = (strpos($namespace, '.') === false) ? $namespace : strrchr($namespace, '.');
// S_ROW_COUNT is deceptive, it returns the current row number not the number of rows
// S_ROW_COUNT is deceptive, it returns the current row number now the number of rows
// hence S_ROW_COUNT is deprecated in favour of S_ROW_NUM
switch ($varrefs[3])
{
@@ -643,7 +641,7 @@ class template_filter extends php_user_filter
$expr = true;
// S_ROW_COUNT is deceptive, it returns the current row number not the number of rows
// S_ROW_COUNT is deceptive, it returns the current row number now the number of rows
// hence S_ROW_COUNT is deprecated in favour of S_ROW_NUM
switch ($varname)
{
@@ -731,7 +729,7 @@ class template_filter extends php_user_filter
}
}
stream_filter_register('template', 'template_filter');
stream_filter_register('phpbb_template', 'phpbb_template_filter');
/**
* Extension of template class - Functions needed for compiling templates only.
@@ -753,7 +751,7 @@ stream_filter_register('template', 'template_filter');
* @package phpBB3
* @uses template_filter As a PHP stream filter to perform compilation of templates
*/
class template_compile
class phpbb_template_compile
{
/**
* @var template Reference to the {@link template template} object performing compilation
@@ -764,7 +762,7 @@ class template_compile
* Constructor
* @param template $template {@link template Template} object performing compilation
*/
function __construct(template $template)
function __construct(phpbb_template $template)
{
$this->template = $template;
}
@@ -826,7 +824,7 @@ class template_compile
@flock($destination_handle, LOCK_EX);
stream_filter_append($source_handle, 'template');
stream_filter_append($source_handle, 'phpbb_template');
stream_copy_to_stream($source_handle, $destination_handle);
@fclose($source_handle);
@@ -856,7 +854,7 @@ class template_compile
return false;
}
stream_filter_append($source_handle, 'template');
stream_filter_append($source_handle, 'phpbb_template');
stream_copy_to_stream($source_handle, $destination_handle);
@fclose($source_handle);

View File

@@ -412,7 +412,7 @@ class phpbb_user extends phpbb_session
{
phpbb::$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
phpbb::$db->sql_transaction('commit');
phpbb::$acm->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE);
add_log('admin', 'LOG_IMAGESET_LANG_REFRESHED', $this->theme['imageset_name'], $this->img_lang);
}