oh boy...

- Migrate code base to PHP 5.1+


git-svn-id: file:///svn/phpbb/trunk@8295 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
David M 2008-01-03 17:00:40 +00:00
parent 0f26ffbade
commit 85055ac97f
77 changed files with 827 additions and 3121 deletions

View file

@ -20,7 +20,7 @@ $starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0]; $starttime = $starttime[1] + $starttime[0];
// Report all errors, except notices // Report all errors, except notices
error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL | E_STRICT);
/* /*
* Remove variables created by register_globals from the global scope * Remove variables created by register_globals from the global scope
@ -199,7 +199,7 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle
$user = new user(); $user = new user();
$auth = new auth(); $auth = new auth();
$template = new template(); $template = new template();
$cache = new cache(); $cache = new acm();
$db = new $sql_db(); $db = new $sql_db();
// Connect to DB // Connect to DB
@ -209,13 +209,13 @@ $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 = cache::obtain_config();
// Add own hook handler // Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
foreach ($cache->obtain_hooks() as $hook) foreach (cache::obtain_hooks() as $hook)
{ {
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
} }

View file

@ -198,7 +198,7 @@ while (!feof($fp))
foreach (array('nfc', 'nfkc', 'nfd', 'nfkd') as $form) foreach (array('nfc', 'nfkc', 'nfd', 'nfkd') as $form)
{ {
$utf_result = $utf_expected; $utf_result = $utf_expected;
utf_normalizer::$form($utf_result); call_user_func(array('utf_normalizer', $form), $utf_result);
$hex_result = utf_to_hexseq($utf_result); $hex_result = utf_to_hexseq($utf_result);
// echo "$form($utf_expected) == $utf_result\n"; // echo "$form($utf_expected) == $utf_result\n";

View file

@ -90,6 +90,7 @@
<li>[Fix] Allow single quotes in db password to be stored within config.php in installer</li> <li>[Fix] Allow single quotes in db password to be stored within config.php in installer</li>
<li>[Fix] Correctly quote db password for re-display in installer (Bug #16695 / thanks to m313 for reporting too - #s17235)</li> <li>[Fix] Correctly quote db password for re-display in installer (Bug #16695 / thanks to m313 for reporting too - #s17235)</li>
<li>[Fix] Correctly handle empty imageset entries (Bug #16865)</li> <li>[Fix] Correctly handle empty imageset entries (Bug #16865)</li>
<li>[Change] Migrate phpBB to PHP versions >= 5.1</li>
</ul> </ul>
<a name="v30rc8"></a><h3>1.i. Changes since 3.0.RC8</h3> <a name="v30rc8"></a><h3>1.i. Changes since 3.0.RC8</h3>

View file

@ -24,7 +24,7 @@ if (isset($_GET['avatar']))
require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx);
$db = new $sql_db(); $db = new $sql_db();
$cache = new cache(); $cache = new acm();
// Connect to DB // Connect to DB
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
@ -36,7 +36,7 @@ if (isset($_GET['avatar']))
// 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 = cache::obtain_config();
$filename = $_GET['avatar']; $filename = $_GET['avatar'];
$avatar_group = false; $avatar_group = false;
if ($filename[0] === 'g') if ($filename[0] === 'g')
@ -172,7 +172,7 @@ if ($attachment['is_orphan'])
} }
// Obtain all extensions... // Obtain all extensions...
$extensions = $cache->obtain_attach_extensions(true); $extensions = cache::obtain_attach_extensions(true);
} }
else else
{ {

View file

@ -22,18 +22,18 @@ if (!defined('IN_PHPBB'))
*/ */
class acm class acm
{ {
var $vars = array(); private $vars = array();
var $var_expires = array(); private $var_expires = array();
var $is_modified = false; private $is_modified = false;
var $sql_rowset = array(); public $sql_rowset = array();
var $sql_row_pointer = array(); private $sql_row_pointer = array();
var $cache_dir = ''; public $cache_dir = '';
/** /**
* Set cache path * Set cache path
*/ */
function acm() function __construct()
{ {
global $phpbb_root_path; global $phpbb_root_path;
$this->cache_dir = $phpbb_root_path . 'cache/'; $this->cache_dir = $phpbb_root_path . 'cache/';
@ -42,25 +42,24 @@ class acm
/** /**
* Load global cache * Load global cache
*/ */
function load() private function load()
{ {
global $phpEx; global $phpEx;
// grab the global cache
if (file_exists($this->cache_dir . 'data_global.' . $phpEx)) if (file_exists($this->cache_dir . 'data_global.' . $phpEx))
{ {
@include($this->cache_dir . 'data_global.' . $phpEx); @include($this->cache_dir . 'data_global.' . $phpEx);
} return true;
else
{
return false;
} }
return true; return false;
} }
/** /**
* Unload cache object * Unload cache object
*/ */
function unload() public function unload()
{ {
$this->save(); $this->save();
unset($this->vars); unset($this->vars);
@ -77,7 +76,7 @@ class acm
/** /**
* Save modified objects * Save modified objects
*/ */
function save() private function save()
{ {
if (!$this->is_modified) if (!$this->is_modified)
{ {
@ -112,7 +111,7 @@ class acm
/** /**
* Tidy cache * Tidy cache
*/ */
function tidy() public function tidy()
{ {
global $phpEx; global $phpEx;
@ -161,9 +160,9 @@ class acm
/** /**
* Get saved cache object * Get saved cache object
*/ */
function get($var_name) public function get($var_name)
{ {
if ($var_name[0] == '_') if ($var_name[0] === '_')
{ {
global $phpEx; global $phpEx;
@ -186,7 +185,7 @@ class acm
*/ */
function put($var_name, $var, $ttl = 31536000) function put($var_name, $var, $ttl = 31536000)
{ {
if ($var_name[0] == '_') if ($var_name[0] === '_')
{ {
global $phpEx; global $phpEx;
@ -252,7 +251,7 @@ class acm
{ {
global $phpEx; global $phpEx;
if ($var_name == 'sql' && !empty($table)) if ($var_name === 'sql' && !empty($table))
{ {
if (!is_array($table)) if (!is_array($table))
{ {
@ -310,7 +309,7 @@ class acm
return; return;
} }
if ($var_name[0] == '_') if ($var_name[0] === '_')
{ {
$this->remove_file($this->cache_dir . 'data' . $var_name . ".$phpEx"); $this->remove_file($this->cache_dir . 'data' . $var_name . ".$phpEx");
} }
@ -330,7 +329,7 @@ class acm
*/ */
function _exists($var_name) function _exists($var_name)
{ {
if ($var_name[0] == '_') if ($var_name[0] === '_')
{ {
global $phpEx; global $phpEx;
return file_exists($this->cache_dir . 'data' . $var_name . ".$phpEx"); return file_exists($this->cache_dir . 'data' . $var_name . ".$phpEx");

View file

@ -44,6 +44,7 @@ class acp_captcha
{ {
$config[$captcha_var] = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; $config[$captcha_var] = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var];
} }
if ($config['captcha_gd']) if ($config['captcha_gd'])
{ {
include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx); include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx);
@ -52,9 +53,9 @@ class acp_captcha
{ {
include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx); include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx);
} }
$captcha = new captcha();
$captcha->execute(gen_rand_string(mt_rand(5, 8)), time()); captcha::execute(gen_rand_string(mt_rand(5, 8)), time());
exit_handler(); exit();
} }
$config_vars = array( $config_vars = array(

View file

@ -446,7 +446,7 @@ class base_extractor
var $format; var $format;
var $run_comp = false; var $run_comp = false;
function base_extractor($download = false, $store = false, $format, $filename, $time) function __construct($download = false, $store = false, $format, $filename, $time)
{ {
$this->download = $download; $this->download = $download;
$this->store = $store; $this->store = $store;

View file

@ -24,7 +24,7 @@ class acp_inactive
var $u_action; var $u_action;
var $p_master; var $p_master;
function acp_inactive(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }

View file

@ -729,7 +729,7 @@ class acp_profile
'S_FIELD_NO_VIEW' => ($cp->vars['field_no_view']) ? true : false, 'S_FIELD_NO_VIEW' => ($cp->vars['field_no_view']) ? true : false,
'L_LANG_SPECIFIC' => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']), 'L_LANG_SPECIFIC' => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']),
'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper($cp->profile_types[$field_type])], 'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper(custom_profile::profile_types[$field_type])],
'FIELD_IDENT' => $cp->vars['field_ident'], 'FIELD_IDENT' => $cp->vars['field_ident'],
'LANG_NAME' => $cp->vars['lang_name'], 'LANG_NAME' => $cp->vars['lang_name'],
'LANG_EXPLAIN' => $cp->vars['lang_explain']) 'LANG_EXPLAIN' => $cp->vars['lang_explain'])
@ -742,7 +742,7 @@ class acp_profile
'S_TEXT' => ($field_type == FIELD_TEXT) ? true : false, 'S_TEXT' => ($field_type == FIELD_TEXT) ? true : false,
'S_STRING' => ($field_type == FIELD_STRING) ? true : false, 'S_STRING' => ($field_type == FIELD_STRING) ? true : false,
'L_DEFAULT_VALUE_EXPLAIN' => $user->lang[strtoupper($cp->profile_types[$field_type]) . '_DEFAULT_VALUE_EXPLAIN'], 'L_DEFAULT_VALUE_EXPLAIN' => $user->lang[strtoupper(custom_profile::profile_types[$field_type]) . '_DEFAULT_VALUE_EXPLAIN'],
'LANG_DEFAULT_VALUE' => $cp->vars['lang_default_value']) 'LANG_DEFAULT_VALUE' => $cp->vars['lang_default_value'])
); );
} }
@ -769,7 +769,7 @@ class acp_profile
'S_BOOL' => ($field_type == FIELD_BOOL) ? true : false, 'S_BOOL' => ($field_type == FIELD_BOOL) ? true : false,
'S_DROPDOWN' => ($field_type == FIELD_DROPDOWN) ? true : false, 'S_DROPDOWN' => ($field_type == FIELD_DROPDOWN) ? true : false,
'L_LANG_OPTIONS_EXPLAIN' => $user->lang[strtoupper($cp->profile_types[$field_type]) . '_ENTRIES_EXPLAIN'], 'L_LANG_OPTIONS_EXPLAIN' => $user->lang[strtoupper(custom_profile::profile_types[$field_type]) . '_ENTRIES_EXPLAIN'],
'LANG_OPTIONS' => ($field_type == FIELD_DROPDOWN) ? implode("\n", $cp->vars['lang_options']) : '', 'LANG_OPTIONS' => ($field_type == FIELD_DROPDOWN) ? implode("\n", $cp->vars['lang_options']) : '',
'FIRST_LANG_OPTION' => ($field_type == FIELD_BOOL) ? $cp->vars['lang_options'][0] : '', 'FIRST_LANG_OPTION' => ($field_type == FIELD_BOOL) ? $cp->vars['lang_options'][0] : '',
'SECOND_LANG_OPTION' => ($field_type == FIELD_BOOL) ? $cp->vars['lang_options'][1] : '') 'SECOND_LANG_OPTION' => ($field_type == FIELD_BOOL) ? $cp->vars['lang_options'][1] : '')
@ -786,7 +786,7 @@ class acp_profile
); );
// Build options based on profile type // Build options based on profile type
$function = 'get_' . $cp->profile_types[$field_type] . '_options'; $function = 'get_' . custom_profile::profile_types[$field_type] . '_options';
$options = $cp->$function(); $options = $cp->$function();
foreach ($options as $num => $option_ary) foreach ($options as $num => $option_ary)
@ -851,7 +851,7 @@ class acp_profile
$template->assign_block_vars('fields', array( $template->assign_block_vars('fields', array(
'FIELD_IDENT' => $row['field_ident'], 'FIELD_IDENT' => $row['field_ident'],
'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper($cp->profile_types[$row['field_type']])], 'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper(custom_profile::profile_types[$row['field_type']])],
'L_ACTIVATE_DEACTIVATE' => $user->lang[$active_lang], 'L_ACTIVATE_DEACTIVATE' => $user->lang[$active_lang],
'U_ACTIVATE_DEACTIVATE' => $this->u_action . "&amp;action=$active_value&amp;field_id=$id", 'U_ACTIVATE_DEACTIVATE' => $this->u_action . "&amp;action=$active_value&amp;field_id=$id",
@ -873,7 +873,7 @@ class acp_profile
} }
$s_select_type = ''; $s_select_type = '';
foreach ($cp->profile_types as $key => $value) foreach (custom_profile::profile_types as $key => $value)
{ {
$s_select_type .= '<option value="' . $key . '">' . $user->lang['FIELD_' . strtoupper($value)] . '</option>'; $s_select_type .= '<option value="' . $key . '">' . $user->lang['FIELD_' . strtoupper($value)] . '</option>';
} }

View file

@ -1782,7 +1782,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_items($style_row); $items = cache::obtain_cfg_items($style_row);
$items = $items['theme']; $items = $items['theme'];
if (!isset($items['parse_css_file'])) if (!isset($items['parse_css_file']))

View file

@ -24,7 +24,7 @@ class acp_users
var $u_action; var $u_action;
var $p_master; var $p_master;
function acp_users(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }

View file

@ -27,7 +27,7 @@ class auth_admin extends auth
/** /**
* Init auth settings * Init auth settings
*/ */
function auth_admin() function __construct()
{ {
global $db, $cache; global $db, $cache;
@ -84,7 +84,7 @@ class auth_admin extends auth
* @param local|global $scope the scope defines the permission scope. If local, a forum_id is additionally required * @param local|global $scope the scope defines the permission scope. If local, a forum_id is additionally required
* @param ACL_NEVER|ACL_NO|ACL_YES $acl_fill defines the mode those permissions not set are getting filled with * @param ACL_NEVER|ACL_NO|ACL_YES $acl_fill defines the mode those permissions not set are getting filled with
*/ */
function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = ACL_NEVER) public function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = ACL_NEVER)
{ {
global $db, $user; global $db, $user;
@ -235,7 +235,7 @@ class auth_admin extends auth
* Get permission mask for roles * Get permission mask for roles
* This function only supports getting masks for one role * This function only supports getting masks for one role
*/ */
function get_role_mask($role_id) public function get_role_mask($role_id)
{ {
global $db; global $db;
@ -273,7 +273,7 @@ class auth_admin extends auth
/** /**
* Display permission mask (assign to template) * Display permission mask (assign to template)
*/ */
function display_mask($mode, $permission_type, &$hold_ary, $user_mode = 'user', $local = false, $group_display = true) public function display_mask($mode, $permission_type, array $hold_ary, $user_mode = 'user', $local = false, $group_display = true)
{ {
global $template, $user, $db, $phpbb_root_path, $phpEx; global $template, $user, $db, $phpbb_root_path, $phpEx;
@ -451,7 +451,7 @@ class auth_admin extends auth
foreach ($hold_ary as $forum_id => $forum_array) foreach ($hold_ary as $forum_id => $forum_array)
{ {
$content_array = $categories = array(); $content_array = $categories = array();
$this->build_permission_array($hold_ary[$forum_id], $content_array, $categories, array_keys($ug_names_ary)); this::build_permission_array($hold_ary[$forum_id], $content_array, $categories, array_keys($ug_names_ary));
$template->assign_block_vars($tpl_pmask, array( $template->assign_block_vars($tpl_pmask, array(
'NAME' => ($forum_id == 0) ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], 'NAME' => ($forum_id == 0) ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'],
@ -519,7 +519,7 @@ class auth_admin extends auth
'FORUM_ID' => $forum_id) 'FORUM_ID' => $forum_id)
); );
$this->assign_cat_array($ug_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, $show_trace, ($mode == 'view')); this::assign_cat_array($ug_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, $show_trace, ($mode == 'view'));
unset($content_array[$ug_id]); unset($content_array[$ug_id]);
} }
@ -537,7 +537,7 @@ class auth_admin extends auth
} }
$content_array = $categories = array(); $content_array = $categories = array();
$this->build_permission_array($hold_ary[$ug_id], $content_array, $categories, array_keys($forum_names_ary)); this::build_permission_array($hold_ary[$ug_id], $content_array, $categories, array_keys($forum_names_ary));
$template->assign_block_vars($tpl_pmask, array( $template->assign_block_vars($tpl_pmask, array(
'NAME' => $ug_name, 'NAME' => $ug_name,
@ -606,7 +606,7 @@ class auth_admin extends auth
'FORUM_ID' => $forum_id) 'FORUM_ID' => $forum_id)
); );
$this->assign_cat_array($forum_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, $show_trace, ($mode == 'view')); this::assign_cat_array($forum_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, $show_trace, ($mode == 'view'));
} }
unset($hold_ary[$ug_id], $ug_names_ary[$ug_id]); unset($hold_ary[$ug_id], $ug_names_ary[$ug_id]);
@ -617,7 +617,7 @@ class auth_admin extends auth
/** /**
* Display permission mask for roles * Display permission mask for roles
*/ */
function display_role_mask(&$hold_ary) public function display_role_mask(array $hold_ary)
{ {
global $db, $template, $user, $phpbb_root_path, $phpbb_admin_path, $phpEx; global $db, $template, $user, $phpbb_root_path, $phpbb_admin_path, $phpEx;
@ -698,15 +698,10 @@ class auth_admin extends auth
* 'global' => array('optionA', 'optionB', ...) * 'global' => array('optionA', 'optionB', ...)
* ); * );
*/ */
function acl_add_option($options) public function acl_add_option(array $options)
{ {
global $db, $cache; global $db, $cache;
if (!is_array($options))
{
return false;
}
$cur_options = array(); $cur_options = array();
$sql = 'SELECT auth_option, is_global, is_local $sql = 'SELECT auth_option, is_global, is_local
@ -784,7 +779,7 @@ class auth_admin extends auth
/** /**
* Set a user or group ACL record * Set a user or group ACL record
*/ */
function acl_set($ug_type, $forum_id, $ug_id, $auth, $role_id = 0, $clear_prefetch = true) public function acl_set($ug_type, $forum_id, $ug_id, $auth, $role_id = 0, $clear_prefetch = true)
{ {
global $db; global $db;
@ -917,7 +912,7 @@ class auth_admin extends auth
/** /**
* Set a role-specific ACL record * Set a role-specific ACL record
*/ */
function acl_set_role($role_id, $auth) public function acl_set_role($role_id, $auth)
{ {
global $db; global $db;
@ -980,7 +975,7 @@ class auth_admin extends auth
/** /**
* Remove local permission * Remove local permission
*/ */
function acl_delete($mode, $ug_id = false, $forum_id = false, $permission_type = false) public function acl_delete($mode, $ug_id = false, $forum_id = false, $permission_type = false)
{ {
global $db; global $db;
@ -1088,7 +1083,7 @@ class auth_admin extends auth
* Assign category to template * Assign category to template
* used by display_mask() * used by display_mask()
*/ */
function assign_cat_array(&$category_array, $tpl_cat, $tpl_mask, $ug_id, $forum_id, $show_trace = false, $s_view) private static function assign_cat_array(array $category_array, $tpl_cat, $tpl_mask, $ug_id, $forum_id, $show_trace = false, $s_view)
{ {
global $template, $user, $phpbb_admin_path, $phpEx; global $template, $user, $phpbb_admin_path, $phpEx;
@ -1164,7 +1159,7 @@ class auth_admin extends auth
* Building content array from permission rows with explicit key ordering * Building content array from permission rows with explicit key ordering
* used by display_mask() * used by display_mask()
*/ */
function build_permission_array(&$permission_row, &$content_array, &$categories, $key_sort_array) public static function build_permission_array(array $permission_row, array &$content_array, array &$categories, array $key_sort_array)
{ {
global $user; global $user;
@ -1229,7 +1224,7 @@ class auth_admin extends auth
* "more" permissions by this. * "more" permissions by this.
* Admin permissions will not be copied. * Admin permissions will not be copied.
*/ */
function ghost_permissions($from_user_id, $to_user_id) public function ghost_permissions($from_user_id, $to_user_id)
{ {
global $db; global $db;

View file

@ -22,15 +22,15 @@ if (!defined('IN_PHPBB'))
*/ */
class auth class auth
{ {
var $acl = array(); private $acl = array();
var $cache = array(); private $cache = array();
var $acl_options = array(); public $acl_options = array();
var $acl_forum_ids = false; private $acl_forum_ids = false;
/** /**
* Init permissions * Init permissions
*/ */
function acl(&$userdata) function acl(array &$userdata)
{ {
global $db, $cache; global $db, $cache;
@ -100,7 +100,7 @@ class auth
* If a forum id is specified the local option will be combined with a global option if one exist. * If a forum id is specified the local option will be combined with a global option if one exist.
* If a forum id is not specified, only the global option will be checked. * If a forum id is not specified, only the global option will be checked.
*/ */
function acl_get($opt, $f = 0) public function acl_get($opt, $f = 0)
{ {
$negate = false; $negate = false;
@ -110,6 +110,7 @@ class auth
$opt = substr($opt, 1); $opt = substr($opt, 1);
} }
// @todo: use the ref technique to reduce opcode generation
if (!isset($this->cache[$f][$opt])) if (!isset($this->cache[$f][$opt]))
{ {
// We combine the global/local option with an OR because some options are global and local. // We combine the global/local option with an OR because some options are global and local.
@ -137,7 +138,7 @@ class auth
} }
// Founder always has all global options set to true... // Founder always has all global options set to true...
return ($negate) ? !$this->cache[$f][$opt] : $this->cache[$f][$opt]; return $negate xor $this->cache[$f][$opt];
} }
/** /**
@ -146,7 +147,7 @@ class auth
* *
* @param bool $clean set to true if only values needs to be returned which are set/unset * @param bool $clean set to true if only values needs to be returned which are set/unset
*/ */
function acl_getf($opt, $clean = false) public function acl_getf($opt, $clean = false)
{ {
$acl_f = array(); $acl_f = array();
$negate = false; $negate = false;
@ -196,17 +197,14 @@ class auth
if (!$clean) if (!$clean)
{ {
$acl_f[$f][$opt] = ($negate) ? !$allowed : $allowed; $acl_f[$f][$opt] = $negate xor $allowed;
} }
else else if ($negate xor $allowed)
{
if (($negate && !$allowed) || (!$negate && $allowed))
{ {
$acl_f[$f][$opt] = 1; $acl_f[$f][$opt] = 1;
} }
} }
} }
}
// If we get forum_ids not having this permission, we need to fill the remaining parts // If we get forum_ids not having this permission, we need to fill the remaining parts
if ($negate && sizeof($this->acl_forum_ids)) if ($negate && sizeof($this->acl_forum_ids))
@ -227,7 +225,7 @@ class auth
* If global option is checked it returns the global state (same as acl_get($opt)) * If global option is checked it returns the global state (same as acl_get($opt))
* Local option has precedence... * Local option has precedence...
*/ */
function acl_getf_global($opt) public function acl_getf_global($opt)
{ {
if (is_array($opt)) if (is_array($opt))
{ {
@ -271,7 +269,7 @@ class auth
/** /**
* Get permission settings (more than one) * Get permission settings (more than one)
*/ */
function acl_gets() public function acl_gets()
{ {
$args = func_get_args(); $args = func_get_args();
$f = array_pop($args); $f = array_pop($args);
@ -300,7 +298,7 @@ class auth
/** /**
* Get permission listing based on user_id/options/forum_ids * Get permission listing based on user_id/options/forum_ids
*/ */
function acl_get_list($user_id = false, $opts = false, $forum_id = false) public function acl_get_list($user_id = false, $opts = false, $forum_id = false)
{ {
$hold_ary = $this->acl_raw_data($user_id, $opts, $forum_id); $hold_ary = $this->acl_raw_data($user_id, $opts, $forum_id);
@ -325,7 +323,7 @@ class auth
/** /**
* Cache data to user_permissions row * Cache data to user_permissions row
*/ */
function acl_cache(&$userdata) public function acl_cache(array &$userdata)
{ {
global $db; global $db;
@ -403,7 +401,7 @@ class auth
/** /**
* Build bitstring from permission set * Build bitstring from permission set
*/ */
function build_bitstring(&$hold_ary) protected function build_bitstring(&$hold_ary)
{ {
$hold_str = ''; $hold_str = '';
@ -464,7 +462,7 @@ class auth
/** /**
* Clear one or all users cached permission settings * Clear one or all users cached permission settings
*/ */
function acl_clear_prefetch($user_id = false) public function acl_clear_prefetch($user_id = false)
{ {
global $db; global $db;
@ -487,8 +485,9 @@ class auth
/** /**
* Get assigned roles * Get assigned roles
* @todo: protected or public?
*/ */
function acl_role_data($user_type, $role_type, $ug_id = false, $forum_id = false) public function acl_role_data($user_type, $role_type, $ug_id = false, $forum_id = false)
{ {
global $db; global $db;
@ -520,8 +519,9 @@ class auth
/** /**
* Get raw acl data based on user/option/forum * Get raw acl data based on user/option/forum
* @todo: protected or public?
*/ */
function acl_raw_data($user_id = false, $opts = false, $forum_id = false) public function acl_raw_data($user_id = false, $opts = false, $forum_id = false)
{ {
global $db; global $db;
@ -632,6 +632,7 @@ class auth
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
// @todo: use the ref technique to reduce opcode generation
if (!isset($hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']]) || (isset($hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']]) && $hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] != ACL_NEVER)) if (!isset($hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']]) || (isset($hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']]) && $hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] != ACL_NEVER))
{ {
$setting = ($row['auth_role_id']) ? $row['role_auth_setting'] : $row['auth_setting']; $setting = ($row['auth_role_id']) ? $row['role_auth_setting'] : $row['auth_setting'];
@ -663,7 +664,7 @@ class auth
/** /**
* Get raw user based permission settings * Get raw user based permission settings
*/ */
function acl_user_raw_data($user_id = false, $opts = false, $forum_id = false) public function acl_user_raw_data($user_id = false, $opts = false, $forum_id = false)
{ {
global $db; global $db;
@ -717,7 +718,7 @@ class auth
/** /**
* Get raw group based permission settings * Get raw group based permission settings
*/ */
function acl_group_raw_data($group_id = false, $opts = false, $forum_id = false) public function acl_group_raw_data($group_id = false, $opts = false, $forum_id = false)
{ {
global $db; global $db;
@ -771,7 +772,7 @@ class auth
/** /**
* Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him. * Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him.
*/ */
function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0) public function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0)
{ {
global $config, $db, $user, $phpbb_root_path, $phpEx; global $config, $db, $user, $phpbb_root_path, $phpEx;
@ -873,7 +874,7 @@ class auth
/** /**
* Fill auth_option statement for later querying based on the supplied options * Fill auth_option statement for later querying based on the supplied options
*/ */
function build_auth_option_statement($key, $auth_options, &$sql_opts) private function build_auth_option_statement($key, $auth_options, &$sql_opts)
{ {
global $db; global $db;

View file

@ -112,8 +112,9 @@ function login_db(&$username, &$password)
} }
} }
// @todo: safe to remove?
// If the password convert flag is set we need to convert it // If the password convert flag is set we need to convert it
if ($row['user_pass_convert']) /*if ($row['user_pass_convert'])
{ {
// in phpBB2 passwords were used exactly as they were sent, with addslashes applied // in phpBB2 passwords were used exactly as they were sent, with addslashes applied
$password_old_format = isset($_REQUEST['password']) ? (string) $_REQUEST['password'] : ''; $password_old_format = isset($_REQUEST['password']) ? (string) $_REQUEST['password'] : '';
@ -161,7 +162,7 @@ function login_db(&$username, &$password)
); );
} }
} }
} }*/
// Check password ... // Check password ...
if (!$row['user_pass_convert'] && phpbb_check_hash($password, $row['user_password'])) if (!$row['user_pass_convert'] && phpbb_check_hash($password, $row['user_password']))

View file

@ -36,7 +36,7 @@ class bbcode
* Constructor * Constructor
* Init bbcode cache entries if bitfield is specified * Init bbcode cache entries if bitfield is specified
*/ */
function bbcode($bitfield = '') function __construct($bitfield = '')
{ {
if ($bitfield) if ($bitfield)
{ {

View file

@ -20,16 +20,16 @@ if (!defined('IN_PHPBB'))
* Class for grabbing/handling cached entries, extends acm_file or acm_db depending on the setup * Class for grabbing/handling cached entries, extends acm_file or acm_db depending on the setup
* @package acm * @package acm
*/ */
class cache extends acm class cache
{ {
/** /**
* Get config values * Get config values
*/ */
function obtain_config() public static function obtain_config()
{ {
global $db; global $db, $cache;
if (($config = $this->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 . '
@ -61,7 +61,7 @@ class cache extends acm
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$this->put('config', $cached_config); $cache->put('config', $cached_config);
} }
return $config; return $config;
@ -71,12 +71,14 @@ class cache extends acm
* 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
*/ */
function obtain_word_list() public static function obtain_word_list()
{
global $cache;
if (($censors = $cache->get('_word_censors')) === false)
{ {
global $db; global $db;
if (($censors = $this->get('_word_censors')) === false)
{
$sql = 'SELECT word, replacement $sql = 'SELECT word, replacement
FROM ' . WORDS_TABLE; FROM ' . WORDS_TABLE;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -89,7 +91,7 @@ class cache extends acm
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$this->put('_word_censors', $censors); $cache->put('_word_censors', $censors);
} }
return $censors; return $censors;
@ -98,9 +100,11 @@ class cache extends acm
/** /**
* Obtain currently listed icons * Obtain currently listed icons
*/ */
function obtain_icons() public static function obtain_icons()
{ {
if (($icons = $this->get('_icons')) === false) global $cache;
if (($icons = $cache->get('_icons')) === false)
{ {
global $db; global $db;
@ -120,7 +124,7 @@ class cache extends acm
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$this->put('_icons', $icons); $cache->put('_icons', $icons);
} }
return $icons; return $icons;
@ -129,9 +133,11 @@ class cache extends acm
/** /**
* Obtain ranks * Obtain ranks
*/ */
function obtain_ranks() public static function obtain_ranks()
{ {
if (($ranks = $this->get('_ranks')) === false) global $cache;
if (($ranks = $cache->get('_ranks')) === false)
{ {
global $db; global $db;
@ -161,7 +167,7 @@ class cache extends acm
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$this->put('_ranks', $ranks); $cache->put('_ranks', $ranks);
} }
return $ranks; return $ranks;
@ -174,9 +180,11 @@ class cache extends acm
* *
* @return array allowed extensions array. * @return array allowed extensions array.
*/ */
function obtain_attach_extensions($forum_id) public static function obtain_attach_extensions($forum_id)
{ {
if (($extensions = $this->get('_extensions')) === false) global $cache;
if (($extensions = $cache->get('_extensions')) === false)
{ {
global $db; global $db;
@ -220,7 +228,7 @@ class cache extends acm
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$this->put('_extensions', $extensions); $cache->put('_extensions', $extensions);
} }
// Forum post // Forum post
@ -279,9 +287,11 @@ class cache extends acm
/** /**
* Obtain active bots * Obtain active bots
*/ */
function obtain_bots() public static function obtain_bots()
{ {
if (($bots = $this->get('_bots')) === false) global $cache;
if (($bots = $cache->get('_bots')) === false)
{ {
global $db; global $db;
@ -319,7 +329,7 @@ class cache extends acm
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$this->put('_bots', $bots); $cache->put('_bots', $bots);
} }
return $bots; return $bots;
@ -328,9 +338,9 @@ class cache extends acm
/** /**
* Obtain cfg file data * Obtain cfg file data
*/ */
function obtain_cfg_items($theme) public static function obtain_cfg_items($theme)
{ {
global $config, $phpbb_root_path; global $config, $phpbb_root_path, $cache;
$parsed_items = array( $parsed_items = array(
'theme' => array(), 'theme' => array(),
@ -340,7 +350,7 @@ class cache extends acm
foreach ($parsed_items as $key => $parsed_array) foreach ($parsed_items as $key => $parsed_array)
{ {
$parsed_array = $this->get('_cfg_' . $key . '_' . $theme[$key . '_path']); $parsed_array = $cache->get('_cfg_' . $key . '_' . $theme[$key . '_path']);
if ($parsed_array === false) if ($parsed_array === false)
{ {
@ -366,7 +376,7 @@ class cache extends acm
$parsed_array = parse_cfg_file($filename); $parsed_array = parse_cfg_file($filename);
$parsed_array['filetime'] = @filemtime($filename); $parsed_array['filetime'] = @filemtime($filename);
$this->put('_cfg_' . $key . '_' . $theme[$key . '_path'], $parsed_array); $cache->put('_cfg_' . $key . '_' . $theme[$key . '_path'], $parsed_array);
} }
$parsed_items[$key] = $parsed_array; $parsed_items[$key] = $parsed_array;
} }
@ -377,9 +387,11 @@ class cache extends acm
/** /**
* Obtain disallowed usernames * Obtain disallowed usernames
*/ */
function obtain_disallowed_usernames() public static function obtain_disallowed_usernames()
{ {
if (($usernames = $this->get('_disallowed_usernames')) === false) global $cache;
if (($usernames = $cache->get('_disallowed_usernames')) === false)
{ {
global $db; global $db;
@ -394,7 +406,7 @@ class cache extends acm
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$this->put('_disallowed_usernames', $usernames); $cache->put('_disallowed_usernames', $usernames);
} }
return $usernames; return $usernames;
@ -403,12 +415,14 @@ class cache extends acm
/** /**
* Obtain hooks... * Obtain hooks...
*/ */
function obtain_hooks() public static function obtain_hooks()
{ {
global $phpbb_root_path, $phpEx; global $cache;
if (($hook_files = $this->get('_hooks')) === false) if (($hook_files = $cache->get('_hooks')) === false)
{ {
global $phpbb_root_path;
$hook_files = array(); $hook_files = array();
// Now search for hooks... // Now search for hooks...
@ -416,6 +430,8 @@ class cache extends acm
if ($dh) if ($dh)
{ {
global $phpEx;
while (($file = readdir($dh)) !== false) while (($file = readdir($dh)) !== false)
{ {
if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx) if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx)
@ -426,7 +442,7 @@ class cache extends acm
closedir($dh); closedir($dh);
} }
$this->put('_hooks', $hook_files); $cache->put('_hooks', $hook_files);
} }
return $hook_files; return $hook_files;

View file

@ -24,20 +24,20 @@ if (!defined('IN_PHPBB'))
*/ */
class captcha class captcha
{ {
var $width = 360; const width = 360;
var $height = 96; const height = 96;
/** /**
* Create the image containing $code with a seed of $seed * Create the image containing $code with a seed of $seed
*/ */
function execute($code, $seed) public static function execute($code, $seed)
{ {
global $config; global $config;
srand($seed); srand($seed);
mt_srand($seed); mt_srand($seed);
// Create image // Create image
$img = imagecreatetruecolor($this->width, $this->height); $img = imagecreatetruecolor(self::width, self::height);
// Generate colours // Generate colours
$colour = new colour_manager($img, array( $colour = new colour_manager($img, array(
@ -53,15 +53,15 @@ class captcha
// Generate code characters // Generate code characters
$characters = $sizes = $bounding_boxes = array(); $characters = $sizes = $bounding_boxes = array();
$width_avail = $this->width - 15; $width_avail = self::width - 15;
$code_len = strlen($code); $code_len = strlen($code);
$captcha_bitmaps = $this->captcha_bitmaps(); $captcha_bitmaps = self::captcha_bitmaps();
for ($i = 0; $i < $code_len; ++$i) for ($i = 0; $i < $code_len; ++$i)
{ {
$characters[$i] = new char_cube3d($captcha_bitmaps, $code[$i]); $characters[$i] = new char_cube3d($captcha_bitmaps, $code[$i]);
list($min, $max) = $characters[$i]->range(); list($min, $max) = char_cube3d::range();
$sizes[$i] = mt_rand($min, $max); $sizes[$i] = mt_rand($min, $max);
$box = $characters[$i]->dimensions($sizes[$i]); $box = $characters[$i]->dimensions($sizes[$i]);
@ -82,20 +82,20 @@ class captcha
if ($config['captcha_gd_x_grid']) if ($config['captcha_gd_x_grid'])
{ {
$grid = (int) $config['captcha_gd_x_grid']; $grid = (int) $config['captcha_gd_x_grid'];
for ($y = 0; $y < $this->height; $y += mt_rand($grid - 2, $grid + 2)) for ($y = 0; $y < self::height; $y += mt_rand($grid - 2, $grid + 2))
{ {
$current_colour = $scheme[array_rand($scheme)]; $current_colour = $scheme[array_rand($scheme)];
imageline($img, mt_rand(0,4), mt_rand($y - 3, $y), mt_rand($this->width - 5, $this->width), mt_rand($y - 3, $y), $current_colour); imageline($img, mt_rand(0,4), mt_rand($y - 3, $y), mt_rand(self::width - 5, self::width), mt_rand($y - 3, $y), $current_colour);
} }
} }
if ($config['captcha_gd_y_grid']) if ($config['captcha_gd_y_grid'])
{ {
$grid = (int) $config['captcha_gd_y_grid']; $grid = (int) $config['captcha_gd_y_grid'];
for ($x = 0; $x < $this->width; $x += mt_rand($grid - 2, $grid + 2)) for ($x = 0; $x < self::width; $x += mt_rand($grid - 2, $grid + 2))
{ {
$current_colour = $scheme[array_rand($scheme)]; $current_colour = $scheme[array_rand($scheme)];
imagedashedline($img, mt_rand($x -3, $x + 3), mt_rand(0, 4), mt_rand($x -3, $x + 3), mt_rand($this->height - 5, $this->height), $current_colour); imagedashedline($img, mt_rand($x -3, $x + 3), mt_rand(0, 4), mt_rand($x -3, $x + 3), mt_rand(self::height - 5, self::height), $current_colour);
} }
} }
@ -104,7 +104,7 @@ class captcha
{ {
$dimm = $bounding_boxes[$i]; $dimm = $bounding_boxes[$i];
$xoffset += ($offset[$i] - $dimm[0]); $xoffset += ($offset[$i] - $dimm[0]);
$yoffset = mt_rand(-$dimm[1], $this->height - $dimm[3]); $yoffset = mt_rand(-$dimm[1], self::height - $dimm[3]);
$characters[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme); $characters[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
$xoffset += $dimm[2]; $xoffset += $dimm[2];
@ -112,7 +112,7 @@ class captcha
if ($config['captcha_gd_foreground_noise']) if ($config['captcha_gd_foreground_noise'])
{ {
$this->noise_line($img, 0, 0, $this->width, $this->height, $colour->get_resource('background'), $scheme, $bg_colours); self::noise_line($img, 0, 0, self::width, self::height, $colour->get_resource('background'), $scheme, $bg_colours);
} }
// Send image // Send image
@ -125,7 +125,7 @@ class captcha
/** /**
* Noise line * Noise line
*/ */
function noise_line($img, $min_x, $min_y, $max_x, $max_y, $bg, $font, $non_font) private static function noise_line($img, $min_x, $min_y, $max_x, $max_y, $bg, $font, $non_font)
{ {
imagesetthickness($img, 2); imagesetthickness($img, 2);
@ -174,7 +174,7 @@ class captcha
/** /**
* Return bitmaps * Return bitmaps
*/ */
function captcha_bitmaps() private static function captcha_bitmaps()
{ {
return array( return array(
'width' => 9, 'width' => 9,
@ -786,21 +786,21 @@ class captcha
*/ */
class char_cube3d class char_cube3d
{ {
var $bitmap; private $bitmap;
var $bitmap_width; private $bitmap_width;
var $bitmap_height; private $bitmap_height;
var $basis_matrix = array(array(1, 0, 0), array(0, 1, 0), array(0, 0, 1)); private $basis_matrix = array(array(1, 0, 0), array(0, 1, 0), array(0, 0, 1));
var $abs_x = array(1, 0); private $abs_x = array(1, 0);
var $abs_y = array(0, 1); private $abs_y = array(0, 1);
var $x = 0; private $x = 0;
var $y = 1; private $y = 1;
var $z = 2; private $z = 2;
var $letter = ''; private $letter = '';
/** /**
*/ */
function char_cube3d(&$bitmaps, $letter) function __construct(&$bitmaps, $letter)
{ {
$this->bitmap = $bitmaps['data'][$letter]; $this->bitmap = $bitmaps['data'][$letter];
$this->bitmap_width = $bitmaps['width']; $this->bitmap_width = $bitmaps['width'];
@ -886,7 +886,7 @@ class char_cube3d
/** /**
* Draw a character * Draw a character
*/ */
function drawchar($scale, $xoff, $yoff, $img, $background, $colours) public function drawchar($scale, $xoff, $yoff, $img, $background, $colours)
{ {
$width = $this->bitmap_width; $width = $this->bitmap_width;
$height = $this->bitmap_height; $height = $this->bitmap_height;
@ -915,16 +915,16 @@ class char_cube3d
$origin = array(0, 0, 0); $origin = array(0, 0, 0);
$xvec = $this->scale($this->basis_matrix[$this->x], $scale); $xvec = $this->scale($this->basis_matrix[$this->x], $scale);
$yvec = $this->scale($this->basis_matrix[$this->y], $scale); $yvec = $this->scale($this->basis_matrix[$this->y], $scale);
$face_corner = $this->sum2($xvec, $yvec); $face_corner = self::sum2($xvec, $yvec);
$zvec = $this->scale($this->basis_matrix[$this->z], $scale); $zvec = $this->scale($this->basis_matrix[$this->z], $scale);
$x_corner = $this->sum2($xvec, $zvec); $x_corner = self::sum2($xvec, $zvec);
$y_corner = $this->sum2($yvec, $zvec); $y_corner = self::sum2($yvec, $zvec);
imagefilledpolygon($img, $this->gen_poly($xo, $yo, $origin, $xvec, $x_corner,$zvec), 4, $colour1); imagefilledpolygon($img, self::gen_poly($xo, $yo, $origin, $xvec, $x_corner,$zvec), 4, $colour1);
imagefilledpolygon($img, $this->gen_poly($xo, $yo, $origin, $yvec, $y_corner,$zvec), 4, $colour2); imagefilledpolygon($img, self::gen_poly($xo, $yo, $origin, $yvec, $y_corner,$zvec), 4, $colour2);
$face = $this->gen_poly($xo, $yo, $origin, $xvec, $face_corner, $yvec); $face = self::gen_poly($xo, $yo, $origin, $xvec, $face_corner, $yvec);
imagefilledpolygon($img, $face, 4, $background); imagefilledpolygon($img, $face, 4, $background);
imagepolygon($img, $face, 4, $colour1); imagepolygon($img, $face, 4, $colour1);
@ -936,7 +936,7 @@ class char_cube3d
/* /*
* return a roughly acceptable range of sizes for rendering with this texttype * return a roughly acceptable range of sizes for rendering with this texttype
*/ */
function range() public static function range()
{ {
return array(3, 4); return array(3, 4);
} }
@ -944,7 +944,7 @@ class char_cube3d
/** /**
* Vector length * Vector length
*/ */
function vectorlen($vector) private static function vectorlen($vector)
{ {
return sqrt(pow($vector[0], 2) + pow($vector[1], 2) + pow($vector[2], 2)); return sqrt(pow($vector[0], 2) + pow($vector[1], 2) + pow($vector[2], 2));
} }
@ -952,10 +952,10 @@ class char_cube3d
/** /**
* Normalize * Normalize
*/ */
function normalize(&$vector, $length = 1) private static function normalize(&$vector, $length = 1)
{ {
$length = (( $length < 1) ? 1 : $length); $length = (( $length < 1) ? 1 : $length);
$length /= $this->vectorlen($vector); $length /= self::vectorlen($vector);
$vector[0] *= $length; $vector[0] *= $length;
$vector[1] *= $length; $vector[1] *= $length;
$vector[2] *= $length; $vector[2] *= $length;
@ -963,7 +963,7 @@ class char_cube3d
/** /**
*/ */
function cross_product($vector1, $vector2) private static function cross_product($vector1, $vector2)
{ {
$retval = array(0, 0, 0); $retval = array(0, 0, 0);
$retval[0] = (($vector1[1] * $vector2[2]) - ($vector1[2] * $vector2[1])); $retval[0] = (($vector1[1] * $vector2[2]) - ($vector1[2] * $vector2[1]));
@ -975,21 +975,21 @@ class char_cube3d
/** /**
*/ */
function sum($vector1, $vector2) private static function sum($vector1, $vector2)
{ {
return array($vector1[0] + $vector2[0], $vector1[1] + $vector2[1], $vector1[2] + $vector2[2]); return array($vector1[0] + $vector2[0], $vector1[1] + $vector2[1], $vector1[2] + $vector2[2]);
} }
/** /**
*/ */
function sum2($vector1, $vector2) private static function sum2($vector1, $vector2)
{ {
return array($vector1[0] + $vector2[0], $vector1[1] + $vector2[1]); return array($vector1[0] + $vector2[0], $vector1[1] + $vector2[1]);
} }
/** /**
*/ */
function scale($vector, $length) private static function scale($vector, $length)
{ {
if (sizeof($vector) == 2) if (sizeof($vector) == 2)
{ {
@ -1001,7 +1001,7 @@ class char_cube3d
/** /**
*/ */
function gen_poly($xoff, $yoff, &$vec1, &$vec2, &$vec3, &$vec4) private static function gen_poly($xoff, $yoff, &$vec1, &$vec2, &$vec3, &$vec4)
{ {
$poly = array(); $poly = array();
$poly[0] = $xoff + $vec1[0]; $poly[0] = $xoff + $vec1[0];
@ -1019,7 +1019,7 @@ class char_cube3d
/** /**
* dimensions * dimensions
*/ */
function dimensions($size) public function dimensions($size)
{ {
$xn = $this->scale($this->basis_matrix[$this->x], -($this->bitmap_width / 2) * $size); $xn = $this->scale($this->basis_matrix[$this->x], -($this->bitmap_width / 2) * $size);
$xp = $this->scale($this->basis_matrix[$this->x], ($this->bitmap_width / 2) * $size); $xp = $this->scale($this->basis_matrix[$this->x], ($this->bitmap_width / 2) * $size);
@ -1027,10 +1027,10 @@ class char_cube3d
$yp = $this->scale($this->basis_matrix[$this->y], ($this->bitmap_height / 2) * $size); $yp = $this->scale($this->basis_matrix[$this->y], ($this->bitmap_height / 2) * $size);
$p = array(); $p = array();
$p[0] = $this->sum2($xn, $yn); $p[0] = self::sum2($xn, $yn);
$p[1] = $this->sum2($xp, $yn); $p[1] = self::sum2($xp, $yn);
$p[2] = $this->sum2($xp, $yp); $p[2] = self::sum2($xp, $yp);
$p[3] = $this->sum2($xn, $yp); $p[3] = self::sum2($xn, $yp);
$min_x = $max_x = $p[0][0]; $min_x = $max_x = $p[0][0];
$min_y = $max_y = $p[0][1]; $min_y = $max_y = $p[0][1];
@ -1052,15 +1052,15 @@ class char_cube3d
*/ */
class colour_manager class colour_manager
{ {
var $img; private $img;
var $mode; private $mode;
var $colours; private $colours;
var $named_colours; private $named_colours;
/** /**
* Create the colour manager, link it to the image resource * Create the colour manager, link it to the image resource
*/ */
function colour_manager($img, $background = false, $mode = 'ahsv') function __construct($img, $background = false, $mode = 'ahsv')
{ {
$this->img = $img; $this->img = $img;
$this->mode = $mode; $this->mode = $mode;
@ -1077,7 +1077,7 @@ class colour_manager
/** /**
* Lookup a named colour resource * Lookup a named colour resource
*/ */
function get_resource($named_colour) public function get_resource($named_colour)
{ {
if (isset($this->named_colours[$named_colour])) if (isset($this->named_colours[$named_colour]))
{ {
@ -1095,7 +1095,7 @@ class colour_manager
/** /**
* Assign a name to a colour resource * Assign a name to a colour resource
*/ */
function name_colour($name, $resource) private function name_colour($name, $resource)
{ {
$this->named_colours[$name] = $resource; $this->named_colours[$name] = $resource;
} }
@ -1103,7 +1103,7 @@ class colour_manager
/** /**
* names and allocates a colour resource * names and allocates a colour resource
*/ */
function allocate_named($name, $colour, $mode = false) private function allocate_named($name, $colour, $mode = false)
{ {
$resource = $this->allocate($colour, $mode); $resource = $this->allocate($colour, $mode);
@ -1117,7 +1117,7 @@ class colour_manager
/** /**
* allocates a specified colour into the image * allocates a specified colour into the image
*/ */
function allocate($colour, $mode = false) private function allocate($colour, $mode = false)
{ {
if ($mode === false) if ($mode === false)
{ {
@ -1164,7 +1164,7 @@ class colour_manager
/** /**
* randomly generates a colour, with optional params * randomly generates a colour, with optional params
*/ */
function random_colour($params = array(), $mode = false) private function random_colour($params = array(), $mode = false)
{ {
if ($mode === false) if ($mode === false)
{ {
@ -1263,7 +1263,7 @@ class colour_manager
/** /**
*/ */
function colour_scheme($resource, $include_original = true) public function colour_scheme($resource, $include_original = true)
{ {
$mode = 'hsv'; $mode = 'hsv';
@ -1289,7 +1289,7 @@ class colour_manager
/** /**
*/ */
function mono_range($resource, $count = 5, $include_original = true) public function mono_range($resource, $count = 5, $include_original = true)
{ {
if (is_array($resource)) if (is_array($resource))
{ {
@ -1331,7 +1331,7 @@ class colour_manager
/** /**
* Convert from one colour model to another * Convert from one colour model to another
*/ */
function model_convert($colour, $from_model, $to_model) private static function model_convert($colour, $from_model, $to_model)
{ {
if ($from_model == $to_model) if ($from_model == $to_model)
{ {
@ -1387,7 +1387,7 @@ class colour_manager
/** /**
* Slightly altered from wikipedia's algorithm * Slightly altered from wikipedia's algorithm
*/ */
function hsv2rgb($hsv) private static function hsv2rgb($hsv)
{ {
colour_manager::normalize_hue($hsv[0]); colour_manager::normalize_hue($hsv[0]);
@ -1450,7 +1450,7 @@ class colour_manager
/** /**
* (more than) Slightly altered from wikipedia's algorithm * (more than) Slightly altered from wikipedia's algorithm
*/ */
function rgb2hsv($rgb) private static function rgb2hsv($rgb)
{ {
$r = min(255, max(0, $rgb[0])); $r = min(255, max(0, $rgb[0]));
$g = min(255, max(0, $rgb[1])); $g = min(255, max(0, $rgb[1]));
@ -1488,7 +1488,7 @@ class colour_manager
/** /**
*/ */
function normalize_hue(&$hue) private static function normalize_hue(&$hue)
{ {
$hue %= 360; $hue %= 360;
@ -1501,7 +1501,7 @@ class colour_manager
/** /**
* Alternate hue to hue * Alternate hue to hue
*/ */
function ah2h($ahue) private static function ah2h($ahue)
{ {
if (is_array($ahue)) if (is_array($ahue))
{ {
@ -1535,7 +1535,7 @@ class colour_manager
/** /**
* hue to Alternate hue * hue to Alternate hue
*/ */
function h2ah($hue) private static function h2ah($hue)
{ {
if (is_array($hue)) if (is_array($hue))
{ {

View file

@ -23,25 +23,15 @@ if (!defined('IN_PHPBB'))
*/ */
class captcha class captcha
{ {
var $filtered_pngs; const width = 320;
var $width = 320; const height = 50;
var $height = 50;
/**
* Define filtered pngs on init
*/
function captcha()
{
// If we can we will generate a single filtered png, we avoid nastiness via emulation of some Zlib stuff
$this->define_filtered_pngs();
}
/** /**
* Create the image containing $code with a seed of $seed * Create the image containing $code with a seed of $seed
*/ */
function execute($code, $seed) public static function execute($code, $seed)
{ {
$img_height = $this->height - 10; $img_height = self::height - 10;
$img_width = 0; $img_width = 0;
mt_srand($seed); mt_srand($seed);
@ -49,27 +39,30 @@ class captcha
$char_widths = $hold_chars = array(); $char_widths = $hold_chars = array();
$code_len = strlen($code); $code_len = strlen($code);
// If we can we will generate a single filtered png, we avoid nastiness via emulation of some Zlib stuff
$filtered_pngs = self::define_filtered_pngs();
for ($i = 0; $i < $code_len; $i++) for ($i = 0; $i < $code_len; $i++)
{ {
$char = $code[$i]; $char = $code[$i];
$width = mt_rand(0, 4); $width = mt_rand(0, 4);
$raw_width = $this->filtered_pngs[$char]['width']; $raw_width = $filtered_pngs[$char]['width'];
$char_widths[$i] = $width; $char_widths[$i] = $width;
$img_width += $raw_width - $width; $img_width += $raw_width - $width;
// Split the char into chunks of $raw_width + 1 length // Split the char into chunks of $raw_width + 1 length
if (empty($hold_chars[$char])) if (empty($hold_chars[$char]))
{ {
$hold_chars[$char] = str_split(base64_decode($this->filtered_pngs[$char]['data']), $raw_width + 1); $hold_chars[$char] = str_split(base64_decode($filtered_pngs[$char]['data']), $raw_width + 1);
} }
} }
$offset_x = mt_rand(0, $this->width - $img_width); $offset_x = mt_rand(0, self::width - $img_width);
$offset_y = mt_rand(0, $this->height - $img_height); $offset_y = mt_rand(0, self::height - $img_height);
$image = ''; $image = '';
for ($i = 0; $i < $this->height; $i++) for ($i = 0; $i < self::height; $i++)
{ {
$image .= chr(0); $image .= chr(0);
@ -82,10 +75,10 @@ class captcha
for ($j = 0; $j < $code_len; $j++) for ($j = 0; $j < $code_len; $j++)
{ {
$image .= $this->randomise(substr($hold_chars[$code{$j}][$i - $offset_y - 1], 1), $char_widths[$j]); $image .= self::randomise(substr($hold_chars[$code{$j}][$i - $offset_y - 1], 1), $char_widths[$j]);
} }
for ($j = $offset_x + $img_width; $j < $this->width; $j++) for ($j = $offset_x + $img_width; $j < self::width; $j++)
{ {
$image .= chr(mt_rand(140, 255)); $image .= chr(mt_rand(140, 255));
} }
@ -100,13 +93,12 @@ class captcha
} }
unset($hold_chars); unset($hold_chars);
$image = $this->create_png($image, $this->width, $this->height); $image = self::create_png($image, $this->width, $this->height);
// Output image // Output image
header('Content-Type: image/png'); header('Content-Type: image/png');
header('Cache-control: no-cache, no-store'); header('Cache-control: no-cache, no-store');
echo $image; echo $image;
exit;
} }
/** /**
@ -114,14 +106,14 @@ class captcha
* certain limits so as to keep it readable. It also varies the image * certain limits so as to keep it readable. It also varies the image
* width a little * width a little
*/ */
function randomise($scanline, $width) private static function randomise($scanline, $width)
{ {
$new_line = ''; $new_line = '';
$end = strlen($scanline) - ceil($width / 2); $end = strlen($scanline) - ceil($width / 2);
for ($i = floor($width/2); $i < $end; $i++) for ($i = $width >> 1; $i < $end; $i++)
{ {
$pixel = ord($scanline{$i}); $pixel = ord($scanline[$i]);
if ($pixel < 190) if ($pixel < 190)
{ {
@ -144,7 +136,7 @@ class captcha
* This creates a chunk of the given type, with the given data * This creates a chunk of the given type, with the given data
* of the given length adding the relevant crc * of the given length adding the relevant crc
*/ */
function png_chunk($length, $type, $data) private static function png_chunk($length, $type, $data)
{ {
$raw = $type . $data; $raw = $type . $data;
@ -165,7 +157,7 @@ class captcha
// IHDR // IHDR
$raw = pack('N2', $width, $height); $raw = pack('N2', $width, $height);
$raw .= pack('C5', 8, 0, 0, 0, 0); $raw .= pack('C5', 8, 0, 0, 0, 0);
$image .= $this->png_chunk(13, 'IHDR', $raw); $image .= self::png_chunk(13, 'IHDR', $raw);
// IDAT // IDAT
if (@extension_loaded('zlib')) if (@extension_loaded('zlib'))
@ -226,10 +218,10 @@ class captcha
} }
// IDAT // IDAT
$image .= $this->png_chunk($length, 'IDAT', $raw_image); $image .= self::png_chunk($length, 'IDAT', $raw_image);
// IEND // IEND
$image .= $this->png_chunk(0, 'IEND', ''); $image .= self::png_chunk(0, 'IEND', '');
return $image; return $image;
} }
@ -238,7 +230,7 @@ class captcha
* png image data * png image data
* Each 'data' element is base64_encoded uncompressed IDAT * Each 'data' element is base64_encoded uncompressed IDAT
*/ */
function define_filtered_pngs() private static function define_filtered_pngs()
{ {
$this->filtered_pngs = array( $this->filtered_pngs = array(
'0' => array( '0' => array(

View file

@ -253,7 +253,7 @@ class phpbb_db_tools
/** /**
*/ */
function phpbb_db_tools(&$db) function __construct(&$db)
{ {
$this->db = $db; $this->db = $db;

View file

@ -66,7 +66,7 @@ class dbal
/** /**
* Constructor * Constructor
*/ */
function dbal() function __construct()
{ {
$this->num_queries = array( $this->num_queries = array(
'cached' => 0, 'cached' => 0,

View file

@ -27,7 +27,6 @@ class dbal_firebird extends dbal
{ {
var $last_query_text = ''; var $last_query_text = '';
var $service_handle = false; var $service_handle = false;
var $affected_rows = 0;
/** /**
* Connect to server * Connect to server
@ -41,7 +40,7 @@ class dbal_firebird extends dbal
$this->db_connect_id = ($this->persistency) ? @ibase_pconnect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3); $this->db_connect_id = ($this->persistency) ? @ibase_pconnect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3);
$this->service_handle = (function_exists('ibase_service_attach')) ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false; $this->service_handle = (strtolower($this->user) == 'sysdba') ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false;
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
} }
@ -51,7 +50,7 @@ class dbal_firebird extends dbal
*/ */
function sql_server_info() function sql_server_info()
{ {
if ($this->service_handle !== false && function_exists('ibase_server_info')) if ($this->service_handle !== false)
{ {
return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION); return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION);
} }
@ -164,25 +163,6 @@ class dbal_firebird extends dbal
} }
} }
if (!function_exists('ibase_affected_rows') && (preg_match('/^UPDATE ([\w_]++)\s+SET [\w_]++\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+)(?:,\s*[\w_]++\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+))*+\s+(WHERE.*)?$/s', $query, $regs) || preg_match('/^DELETE FROM ([\w_]++)\s*(WHERE\s*.*)?$/s', $query, $regs)))
{
$affected_sql = 'SELECT COUNT(*) as num_rows_affected FROM ' . $regs[1];
if (!empty($regs[2]))
{
$affected_sql .= ' ' . $regs[2];
}
if (!($temp_q_id = @ibase_query($this->db_connect_id, $affected_sql)))
{
return false;
}
$temp_result = @ibase_fetch_assoc($temp_q_id);
@ibase_free_result($temp_q_id);
$this->affected_rows = ($temp_result) ? $temp_result['NUM_ROWS_AFFECTED'] : false;
}
if (sizeof($array)) if (sizeof($array))
{ {
$p_query = @ibase_prepare($this->db_connect_id, $query); $p_query = @ibase_prepare($this->db_connect_id, $query);
@ -206,17 +186,9 @@ class dbal_firebird extends dbal
} }
if (!$this->transaction) if (!$this->transaction)
{
if (function_exists('ibase_commit_ret'))
{ {
@ibase_commit_ret(); @ibase_commit_ret();
} }
else
{
// way cooler than ibase_commit_ret :D
@ibase_query('COMMIT RETAIN;');
}
}
if ($cache_ttl && method_exists($cache, 'sql_save')) if ($cache_ttl && method_exists($cache, 'sql_save'))
{ {
@ -257,17 +229,9 @@ class dbal_firebird extends dbal
* Return number of affected rows * Return number of affected rows
*/ */
function sql_affectedrows() function sql_affectedrows()
{
// PHP 5+ function
if (function_exists('ibase_affected_rows'))
{ {
return ($this->db_connect_id) ? @ibase_affected_rows($this->db_connect_id) : false; return ($this->db_connect_id) ? @ibase_affected_rows($this->db_connect_id) : false;
} }
else
{
return $this->affected_rows;
}
}
/** /**
* Fetch current row * Fetch current row
@ -438,7 +402,7 @@ class dbal_firebird extends dbal
{ {
return array( return array(
'message' => @ibase_errmsg(), 'message' => @ibase_errmsg(),
'code' => (@function_exists('ibase_errcode') ? @ibase_errcode() : '') 'code' => @ibase_errcode()
); );
} }

View file

@ -39,14 +39,7 @@ class dbal_mssql extends dbal
@ini_set('mssql.textlimit', 2147483647); @ini_set('mssql.textlimit', 2147483647);
@ini_set('mssql.textsize', 2147483647); @ini_set('mssql.textsize', 2147483647);
if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.1', '>=')))
{
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link); $this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link);
}
else
{
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword) : @mssql_connect($this->server, $this->user, $sqlpassword);
}
if ($this->db_connect_id && $this->dbname != '') if ($this->db_connect_id && $this->dbname != '')
{ {

View file

@ -362,11 +362,12 @@ class dbal_mysql extends dbal
function _sql_report($mode, $query = '') function _sql_report($mode, $query = '')
{ {
static $test_prof; static $test_prof;
static $test_extend;
// current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING // current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING
if ($test_prof === null) if ($test_prof === null)
{ {
$test_prof = false; $test_prof = $test_extend = false;
if (strpos($this->mysql_version, 'community') !== false) if (strpos($this->mysql_version, 'community') !== false)
{ {
$ver = substr($this->mysql_version, 0, strpos($this->mysql_version, '-')); $ver = substr($this->mysql_version, 0, strpos($this->mysql_version, '-'));
@ -375,6 +376,11 @@ class dbal_mysql extends dbal
$test_prof = true; $test_prof = true;
} }
} }
if (version_compare($ver, '4.1.1', '>='))
{
$test_extend = true;
}
} }
switch ($mode) switch ($mode)
@ -401,7 +407,7 @@ class dbal_mysql extends dbal
@mysql_query('SET profiling = 1;', $this->db_connect_id); @mysql_query('SET profiling = 1;', $this->db_connect_id);
} }
if ($result = @mysql_query("EXPLAIN $explain_query", $this->db_connect_id)) if ($result = @mysql_query('EXPLAIN ' . (($test_extend) ? 'EXTENDED ' : '') . "$explain_query", $this->db_connect_id))
{ {
while ($row = @mysql_fetch_assoc($result)) while ($row = @mysql_fetch_assoc($result))
{ {
@ -415,6 +421,27 @@ class dbal_mysql extends dbal
$this->html_hold .= '</table>'; $this->html_hold .= '</table>';
} }
if ($test_extend)
{
$html_table = false;
if ($result = @mysql_query('SHOW WARNINGS', $this->db_connect_id))
{
$this->html_hold .= '<br />';
while ($row = @mysql_fetch_assoc($result))
{
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
}
}
@mysql_free_result($result);
if ($html_table)
{
$this->html_hold .= '</table>';
}
}
if ($test_prof) if ($test_prof)
{ {
$html_table = false; $html_table = false;

View file

@ -48,7 +48,7 @@ class dbal_oracle extends dbal
$connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database; $connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database;
} }
$this->db_connect_id = ($new_link) ? @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8') : (($this->persistency) ? @ociplogon($this->user, $sqlpassword, $connect, 'UTF8') : @ocilogon($this->user, $sqlpassword, $connect, 'UTF8')); $this->db_connect_id = ($new_link) ? @oci_new_connect($this->user, $sqlpassword, $connect, 'UTF8') : (($this->persistency) ? @oci_pconnect($this->user, $sqlpassword, $connect, 'UTF8') : @oci_connect($this->user, $sqlpassword, $connect, 'UTF8'));
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
} }
@ -58,7 +58,7 @@ class dbal_oracle extends dbal
*/ */
function sql_server_info() function sql_server_info()
{ {
return @ociserverversion($this->db_connect_id); return @oci_server_version($this->db_connect_id);
} }
/** /**
@ -74,11 +74,11 @@ class dbal_oracle extends dbal
break; break;
case 'commit': case 'commit':
return @ocicommit($this->db_connect_id); return @oci_commit($this->db_connect_id);
break; break;
case 'rollback': case 'rollback':
return @ocirollback($this->db_connect_id); return @oci_rollback($this->db_connect_id);
break; break;
} }
@ -308,14 +308,14 @@ class dbal_oracle extends dbal
break; break;
} }
$this->query_result = @ociparse($this->db_connect_id, $query); $this->query_result = @oci_parse($this->db_connect_id, $query);
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
@ocibindbyname($this->query_result, $key, $array[$key], -1); @oci_bind_by_name($this->query_result, $key, $array[$key], -1);
} }
$success = @ociexecute($this->query_result, OCI_DEFAULT); $success = @oci_execute($this->query_result, OCI_DEFAULT);
if (!$success) if (!$success)
{ {
@ -375,7 +375,7 @@ class dbal_oracle extends dbal
*/ */
function sql_affectedrows() function sql_affectedrows()
{ {
return ($this->query_result) ? @ocirowcount($this->query_result) : false; return ($this->query_result) ? @oci_num_rows($this->query_result) : false;
} }
/** /**
@ -398,9 +398,9 @@ class dbal_oracle extends dbal
if ($query_id !== false) if ($query_id !== false)
{ {
$row = array(); $row = array();
$result = @ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS); $row = @oci_fetch_array($query_id, OCI_ASSOC + OCI_RETURN_NULLS);
if (!$result || !$row) if (!$row)
{ {
return false; return false;
} }
@ -453,7 +453,7 @@ class dbal_oracle extends dbal
} }
// Reset internal pointer // Reset internal pointer
@ociexecute($query_id, OCI_DEFAULT); @oci_execute($query_id, OCI_DEFAULT);
// We do not fetch the row for rownum == 0 because then the next resultset would be the second row // We do not fetch the row for rownum == 0 because then the next resultset would be the second row
for ($i = 0; $i < $rownum; $i++) for ($i = 0; $i < $rownum; $i++)
@ -479,13 +479,13 @@ class dbal_oracle extends dbal
if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename)) if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename))
{ {
$query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL'; $query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL';
$stmt = @ociparse($this->db_connect_id, $query); $stmt = @oci_parse($this->db_connect_id, $query);
@ociexecute($stmt, OCI_DEFAULT); @oci_execute($stmt, OCI_DEFAULT);
$temp_result = @ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS); $temp_array = @oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS);
@ocifreestatement($stmt); @oci_free_statement($stmt);
if ($temp_result) if ($temp_array)
{ {
return $temp_array['CURRVAL']; return $temp_array['CURRVAL'];
} }
@ -519,7 +519,7 @@ class dbal_oracle extends dbal
if (isset($this->open_queries[(int) $query_id])) if (isset($this->open_queries[(int) $query_id]))
{ {
unset($this->open_queries[(int) $query_id]); unset($this->open_queries[(int) $query_id]);
return @ocifreestatement($query_id); return @oci_free_statement($query_id);
} }
return false; return false;
@ -553,9 +553,9 @@ class dbal_oracle extends dbal
*/ */
function _sql_error() function _sql_error()
{ {
$error = @ocierror(); $error = @oci_error();
$error = (!$error) ? @ocierror($this->query_result) : $error; $error = (!$error) ? @oci_error($this->query_result) : $error;
$error = (!$error) ? @ocierror($this->db_connect_id) : $error; $error = (!$error) ? @oci_error($this->db_connect_id) : $error;
if ($error) if ($error)
{ {
@ -575,7 +575,7 @@ class dbal_oracle extends dbal
*/ */
function _sql_close() function _sql_close()
{ {
return @ocilogoff($this->db_connect_id); return @oci_close($this->db_connect_id);
} }
/** /**
@ -594,11 +594,11 @@ class dbal_oracle extends dbal
$sql = "SELECT table_name $sql = "SELECT table_name
FROM USER_TABLES FROM USER_TABLES
WHERE table_name LIKE '%PLAN_TABLE%'"; WHERE table_name LIKE '%PLAN_TABLE%'";
$stmt = ociparse($this->db_connect_id, $sql); $stmt = oci_parse($this->db_connect_id, $sql);
ociexecute($stmt); oci_execute($stmt);
$result = array(); $result = array();
if (ocifetchinto($stmt, $result, OCI_ASSOC + OCI_RETURN_NULLS)) if ($result = oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS))
{ {
$table = $result['TABLE_NAME']; $table = $result['TABLE_NAME'];
@ -606,17 +606,17 @@ class dbal_oracle extends dbal
$statement_id = substr(md5($query), 0, 30); $statement_id = substr(md5($query), 0, 30);
// Remove any stale plans // Remove any stale plans
$stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); $stmt2 = oci_parse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'");
ociexecute($stmt2); oci_execute($stmt2);
ocifreestatement($stmt2); oci_free_statement($stmt2);
// Explain the plan // Explain the plan
$sql = "EXPLAIN PLAN $sql = "EXPLAIN PLAN
SET STATEMENT_ID = '$statement_id' SET STATEMENT_ID = '$statement_id'
FOR $query"; FOR $query";
$stmt2 = ociparse($this->db_connect_id, $sql); $stmt2 = ociparse($this->db_connect_id, $sql);
ociexecute($stmt2); oci_execute($stmt2);
ocifreestatement($stmt2); oci_free_statement($stmt2);
// Get the data from the plan // Get the data from the plan
$sql = "SELECT operation, options, object_name, object_type, cardinality, cost $sql = "SELECT operation, options, object_name, object_type, cardinality, cost
@ -624,24 +624,24 @@ class dbal_oracle extends dbal
START WITH id = 0 AND statement_id = '$statement_id' START WITH id = 0 AND statement_id = '$statement_id'
CONNECT BY PRIOR id = parent_id CONNECT BY PRIOR id = parent_id
AND statement_id = '$statement_id'"; AND statement_id = '$statement_id'";
$stmt2 = ociparse($this->db_connect_id, $sql); $stmt2 = oci_parse($this->db_connect_id, $sql);
ociexecute($stmt2); oci_execute($stmt2);
$row = array(); $row = array();
while (ocifetchinto($stmt2, $row, OCI_ASSOC + OCI_RETURN_NULLS)) while ($row = oci_fetch_array($stmt2, OCI_ASSOC + OCI_RETURN_NULLS))
{ {
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row); $html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
} }
ocifreestatement($stmt2); oci_free_statement($stmt2);
// Remove the plan we just made, we delete them on request anyway // Remove the plan we just made, we delete them on request anyway
$stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); $stmt2 = oci_parse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'");
ociexecute($stmt2); oci_execute($stmt2);
ocifreestatement($stmt2); oci_free_statement($stmt2);
} }
ocifreestatement($stmt); oci_free_statement($stmt);
if ($html_table) if ($html_table)
{ {
@ -654,15 +654,15 @@ class dbal_oracle extends dbal
$endtime = explode(' ', microtime()); $endtime = explode(' ', microtime());
$endtime = $endtime[0] + $endtime[1]; $endtime = $endtime[0] + $endtime[1];
$result = @ociparse($this->db_connect_id, $query); $result = @oci_parse($this->db_connect_id, $query);
$success = @ociexecute($result, OCI_DEFAULT); $success = @oci_execute($result, OCI_DEFAULT);
$row = array(); $row = array();
while (@ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS)) while ($void = @oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS))
{ {
// Take the time spent on parsing rows into account // Take the time spent on parsing rows into account
} }
@ocifreestatement($result); @oci_free_statement($result);
$splittime = explode(' ', microtime()); $splittime = explode(' ', microtime());
$splittime = $splittime[0] + $splittime[1]; $splittime = $splittime[0] + $splittime[1];

View file

@ -82,21 +82,7 @@ class dbal_postgres extends dbal
if ($this->db_connect_id) if ($this->db_connect_id)
{ {
// determine what version of PostgreSQL is running, we can be more efficient if they are running 8.2+ // determine what version of PostgreSQL is running, we can be more efficient if they are running 8.2+
if (version_compare(PHP_VERSION, '5.0.0', '>='))
{
$this->pgsql_version = @pg_parameter_status($this->db_connect_id, 'server_version'); $this->pgsql_version = @pg_parameter_status($this->db_connect_id, 'server_version');
}
else
{
$query_id = @pg_query($this->db_connect_id, 'SELECT VERSION()');
$row = @pg_fetch_assoc($query_id, null);
@pg_free_result($query_id);
if (!empty($row['version']))
{
$this->pgsql_version = substr($row['version'], 10);
}
}
if (!empty($this->pgsql_version) && $this->pgsql_version[0] >= '8' && $this->pgsql_version[2] >= '2') if (!empty($this->pgsql_version) && $this->pgsql_version[0] >= '8' && $this->pgsql_version[2] >= '2')
{ {
@ -172,7 +158,7 @@ class dbal_postgres extends dbal
if ($this->query_result === false) if ($this->query_result === false)
{ {
if (($this->query_result = @pg_query($this->db_connect_id, $query)) === false) if (($this->query_result = pg_query($this->db_connect_id, $query)) === false)
{ {
$this->sql_error($query); $this->sql_error($query);
} }

View file

@ -43,7 +43,7 @@ class diff
* @param array $from_lines An array of strings. Typically these are lines from a file. * @param array $from_lines An array of strings. Typically these are lines from a file.
* @param array $to_lines An array of strings. * @param array $to_lines An array of strings.
*/ */
function diff(&$from_content, &$to_content, $preserve_cr = true) function __construct(&$from_content, &$to_content, $preserve_cr = true)
{ {
$diff_engine = &new diff_engine(); $diff_engine = &new diff_engine();
$this->_edits = $diff_engine->diff($from_content, $to_content, $preserve_cr); $this->_edits = $diff_engine->diff($from_content, $to_content, $preserve_cr);
@ -645,7 +645,7 @@ class diff3 extends diff
*/ */
class diff3_op class diff3_op
{ {
function diff3_op($orig = false, $final1 = false, $final2 = false) function __construct($orig = false, $final1 = false, $final2 = false)
{ {
$this->orig = $orig ? $orig : array(); $this->orig = $orig ? $orig : array();
$this->final1 = $final1 ? $final1 : array(); $this->final1 = $final1 ? $final1 : array();
@ -717,7 +717,7 @@ class diff3_op_copy extends diff3_op
*/ */
class diff3_block_builder class diff3_block_builder
{ {
function diff3_block_builder() function __construct()
{ {
$this->_init(); $this->_init();
} }

View file

@ -51,7 +51,7 @@ class diff_renderer
/** /**
* Constructor. * Constructor.
*/ */
function diff_renderer($params = array()) function __construct($params = array())
{ {
foreach ($params as $param => $value) foreach ($params as $param => $value)
{ {

View file

@ -323,7 +323,7 @@ function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
} }
$output = '$H$'; $output = '$H$';
$output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)]; $output .= $itoa64[min($iteration_count_log2 + 5, 30)];
$output .= _hash_encode64($input, 6, $itoa64); $output .= _hash_encode64($input, 6, $itoa64);
return $output; return $output;
@ -409,24 +409,12 @@ function _hash_crypt_private($password, $setting, &$itoa64)
* consequently in lower iteration counts and hashes that are * consequently in lower iteration counts and hashes that are
* quicker to crack (by non-PHP code). * quicker to crack (by non-PHP code).
*/ */
if (PHP_VERSION >= 5)
{
$hash = md5($salt . $password, true); $hash = md5($salt . $password, true);
do do
{ {
$hash = md5($hash . $password, true); $hash = md5($hash . $password, true);
} }
while (--$count); while (--$count);
}
else
{
$hash = pack('H*', md5($salt . $password));
do
{
$hash = pack('H*', md5($hash . $password));
}
while (--$count);
}
$output = substr($setting, 0, 12); $output = substr($setting, 0, 12);
$output .= _hash_encode64($hash, 16, $itoa64); $output .= _hash_encode64($hash, 16, $itoa64);
@ -434,95 +422,6 @@ function _hash_crypt_private($password, $setting, &$itoa64)
return $output; return $output;
} }
// Compatibility functions
if (!function_exists('array_combine'))
{
/**
* A wrapper for the PHP5 function array_combine()
* @param array $keys contains keys for the resulting array
* @param array $values contains values for the resulting array
*
* @return Returns an array by using the values from the keys array as keys and the
* values from the values array as the corresponding values. Returns false if the
* number of elements for each array isn't equal or if the arrays are empty.
*/
function array_combine($keys, $values)
{
$keys = array_values($keys);
$values = array_values($values);
$n = sizeof($keys);
$m = sizeof($values);
if (!$n || !$m || ($n != $m))
{
return false;
}
$combined = array();
for ($i = 0; $i < $n; $i++)
{
$combined[$keys[$i]] = $values[$i];
}
return $combined;
}
}
if (!function_exists('str_split'))
{
/**
* A wrapper for the PHP5 function str_split()
* @param array $string contains the string to be converted
* @param array $split_length contains the length of each chunk
*
* @return Converts a string to an array. If the optional split_length parameter is specified,
* the returned array will be broken down into chunks with each being split_length in length,
* otherwise each chunk will be one character in length. FALSE is returned if split_length is
* less than 1. If the split_length length exceeds the length of string, the entire string is
* returned as the first (and only) array element.
*/
function str_split($string, $split_length = 1)
{
if ($split_length < 1)
{
return false;
}
else if ($split_length >= strlen($string))
{
return array($string);
}
else
{
preg_match_all('#.{1,' . $split_length . '}#s', $string, $matches);
return $matches[0];
}
}
}
if (!function_exists('stripos'))
{
/**
* A wrapper for the PHP5 function stripos
* Find position of first occurrence of a case-insensitive string
*
* @param string $haystack is the string to search in
* @param string $needle is the string to search for
*
* @return mixed Returns the numeric position of the first occurrence of needle in the haystack string. Unlike strpos(), stripos() is case-insensitive.
* Note that the needle may be a string of one or more characters.
* If needle is not found, stripos() will return boolean FALSE.
*/
function stripos($haystack, $needle)
{
if (preg_match('#' . preg_quote($needle, '#') . '#i', $haystack, $m))
{
return strpos($haystack, $m[0]);
}
return false;
}
}
if (!function_exists('realpath')) if (!function_exists('realpath'))
{ {
/** /**
@ -713,18 +612,6 @@ else
} }
} }
if (!function_exists('htmlspecialchars_decode'))
{
/**
* A wrapper for htmlspecialchars_decode
* @ignore
*/
function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT)
{
return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
}
}
// functions used for building option fields // functions used for building option fields
/** /**
@ -3153,6 +3040,8 @@ function page_header($page_title = '', $display_online_list = true)
ORDER BY u.username_clean ASC, s.session_ip ASC'; ORDER BY u.username_clean ASC, s.session_ip ASC';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$prev_user_id = false;
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
// User is logged in and therefore not a guest // User is logged in and therefore not a guest
@ -3355,6 +3244,9 @@ function page_header($page_title = '', $display_online_list = true)
'S_BOARD_DISABLED' => ($config['board_disable']) ? true : false, 'S_BOARD_DISABLED' => ($config['board_disable']) ? true : false,
'S_REGISTERED_USER' => $user->data['is_registered'], 'S_REGISTERED_USER' => $user->data['is_registered'],
'S_IS_BOT' => $user->data['is_bot'], 'S_IS_BOT' => $user->data['is_bot'],
'S_IN_SEARCH' => false,
'S_VIEWTOPIC' => false,
'S_VIEWFORUM' => false,
'S_USER_PM_POPUP' => $user->optionget('popuppm'), 'S_USER_PM_POPUP' => $user->optionget('popuppm'),
'S_USER_LANG' => $user->lang['USER_LANG'], 'S_USER_LANG' => $user->lang['USER_LANG'],
'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'],

View file

@ -22,12 +22,12 @@ if (!defined('IN_PHPBB'))
*/ */
class compress class compress
{ {
var $fp = 0; protected $fp = 0;
/** /**
* Add file to archive * Add file to archive
*/ */
function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '') public function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '')
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -87,7 +87,7 @@ class compress
/** /**
* Add custom file (the filepath will not be adjusted) * Add custom file (the filepath will not be adjusted)
*/ */
function add_custom_file($src, $filename) public function add_custom_file($src, $filename)
{ {
$this->data($filename, file_get_contents($src), false, stat($src)); $this->data($filename, file_get_contents($src), false, stat($src));
return true; return true;
@ -96,7 +96,7 @@ class compress
/** /**
* Add file data * Add file data
*/ */
function add_data($src, $name) public function add_data($src, $name)
{ {
$stat = array(); $stat = array();
$stat[2] = 436; //384 $stat[2] = 436; //384
@ -110,7 +110,7 @@ class compress
/** /**
* Return available methods * Return available methods
*/ */
function methods() public static function methods()
{ {
$methods = array('.tar'); $methods = array('.tar');
$available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib'); $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
@ -143,17 +143,17 @@ class compress
*/ */
class compress_zip extends compress class compress_zip extends compress
{ {
var $datasec = array(); private $datasec = array();
var $ctrl_dir = array(); private $ctrl_dir = array();
var $eof_cdh = "\x50\x4b\x05\x06\x00\x00\x00\x00"; const eof_cdh = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0; private $old_offset = 0;
var $datasec_len = 0; private $datasec_len = 0;
/** /**
* Constructor * Constructor
*/ */
function compress_zip($mode, $file) function __construct($mode, $file)
{ {
return $this->fp = @fopen($file, $mode . 'b'); return $this->fp = @fopen($file, $mode . 'b');
} }
@ -161,7 +161,7 @@ class compress_zip extends compress
/** /**
* Convert unix to dos time * Convert unix to dos time
*/ */
function unix_to_dos_time($time) private static function unix_to_dos_time($time)
{ {
$timearray = (!$time) ? getdate() : getdate($time); $timearray = (!$time) ? getdate() : getdate($time);
@ -178,7 +178,7 @@ class compress_zip extends compress
/** /**
* Extract archive * Extract archive
*/ */
function extract($dst) public function extract($dst)
{ {
// Loop the file, looking for files and folders // Loop the file, looking for files and folders
$dd_try = false; $dd_try = false;
@ -313,7 +313,7 @@ class compress_zip extends compress
/** /**
* Close archive * Close archive
*/ */
function close() public function close()
{ {
// Write out central file directory and footer ... if it exists // Write out central file directory and footer ... if it exists
if (sizeof($this->ctrl_dir)) if (sizeof($this->ctrl_dir))
@ -326,11 +326,11 @@ class compress_zip extends compress
/** /**
* Create the structures ... note we assume version made by is MSDOS * Create the structures ... note we assume version made by is MSDOS
*/ */
function data($name, $data, $is_dir = false, $stat) protected function data($name, $data, $is_dir = false, $stat)
{ {
$name = str_replace('\\', '/', $name); $name = str_replace('\\', '/', $name);
$hexdtime = pack('V', $this->unix_to_dos_time($stat[9])); $hexdtime = pack('V', self::unix_to_dos_time($stat[9]));
if ($is_dir) if ($is_dir)
{ {
@ -412,11 +412,11 @@ class compress_zip extends compress
/** /**
* file * file
*/ */
function file() private function file()
{ {
$ctrldir = implode('', $this->ctrl_dir); $ctrldir = implode('', $this->ctrl_dir);
return $ctrldir . $this->eof_cdh . return $ctrldir . self::eof_cdh .
pack('v', sizeof($this->ctrl_dir)) . // total # of entries "on this disk" pack('v', sizeof($this->ctrl_dir)) . // total # of entries "on this disk"
pack('v', sizeof($this->ctrl_dir)) . // total # of entries overall pack('v', sizeof($this->ctrl_dir)) . // total # of entries overall
pack('V', strlen($ctrldir)) . // size of central dir pack('V', strlen($ctrldir)) . // size of central dir
@ -427,7 +427,7 @@ class compress_zip extends compress
/** /**
* Download archive * Download archive
*/ */
function download($filename, $download_name = false) public function download($filename, $download_name = false)
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -462,17 +462,17 @@ class compress_zip extends compress
*/ */
class compress_tar extends compress class compress_tar extends compress
{ {
var $isgz = false; private $isgz = false;
var $isbz = false; private $isbz = false;
var $filename = ''; private $filename = '';
var $mode = ''; private $mode = '';
var $type = ''; private $type = '';
var $wrote = false; private $wrote = false;
/** /**
* Constructor * Constructor
*/ */
function compress_tar($mode, $file, $type = '') function __construct($mode, $file, $type = '')
{ {
$type = (!$type) ? $file : $type; $type = (!$type) ? $file : $type;
$this->isgz = (strpos($type, '.tar.gz') !== false || strpos($type, '.tgz') !== false) ? true : false; $this->isgz = (strpos($type, '.tar.gz') !== false || strpos($type, '.tgz') !== false) ? true : false;
@ -487,7 +487,7 @@ class compress_tar extends compress
/** /**
* Extract archive * Extract archive
*/ */
function extract($dst) public function extract($dst)
{ {
$fzread = ($this->isbz && function_exists('bzread')) ? 'bzread' : (($this->isgz && @extension_loaded('zlib')) ? 'gzread' : 'fread'); $fzread = ($this->isbz && function_exists('bzread')) ? 'bzread' : (($this->isgz && @extension_loaded('zlib')) ? 'gzread' : 'fread');
@ -549,7 +549,7 @@ class compress_tar extends compress
/** /**
* Close archive * Close archive
*/ */
function close() public function close()
{ {
$fzclose = ($this->isbz && function_exists('bzclose')) ? 'bzclose' : (($this->isgz && @extension_loaded('zlib')) ? 'gzclose' : 'fclose'); $fzclose = ($this->isbz && function_exists('bzclose')) ? 'bzclose' : (($this->isgz && @extension_loaded('zlib')) ? 'gzclose' : 'fclose');
@ -567,7 +567,7 @@ class compress_tar extends compress
/** /**
* Create the structures * Create the structures
*/ */
function data($name, $data, $is_dir = false, $stat) protected function data($name, $data, $is_dir = false, $stat)
{ {
$this->wrote = true; $this->wrote = true;
$fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite'); $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');
@ -613,7 +613,7 @@ class compress_tar extends compress
/** /**
* Open archive * Open archive
*/ */
function open() private function open()
{ {
$fzopen = ($this->isbz && function_exists('bzopen')) ? 'bzopen' : (($this->isgz && @extension_loaded('zlib')) ? 'gzopen' : 'fopen'); $fzopen = ($this->isbz && function_exists('bzopen')) ? 'bzopen' : (($this->isgz && @extension_loaded('zlib')) ? 'gzopen' : 'fopen');
$this->fp = @$fzopen($this->file, $this->mode . (($fzopen == 'bzopen') ? '' : 'b') . (($fzopen == 'gzopen') ? '9' : '')); $this->fp = @$fzopen($this->file, $this->mode . (($fzopen == 'bzopen') ? '' : 'b') . (($fzopen == 'gzopen') ? '9' : ''));
@ -627,7 +627,7 @@ class compress_tar extends compress
/** /**
* Download archive * Download archive
*/ */
function download($filename, $download_name = false) public function download($filename, $download_name = false)
{ {
global $phpbb_root_path; global $phpbb_root_path;

View file

@ -660,7 +660,7 @@ function censor_text($text)
} }
else else
{ {
$censors = $cache->obtain_word_list(); $censors = cache::obtain_word_list();
} }
} }
@ -722,6 +722,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
// //
$compiled_attachments = array(); $compiled_attachments = array();
// @todo: do we really need this check?
if (!isset($template->filename['attachment_tpl'])) if (!isset($template->filename['attachment_tpl']))
{ {
$template->set_filenames(array( $template->set_filenames(array(
@ -731,7 +732,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 = cache::obtain_attach_extensions($forum_id);
} }
// Look for missing attachment information... // Look for missing attachment information...
@ -1046,7 +1047,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 = cache::obtain_attach_extensions($forum_id);
} }
return (!isset($extensions['_allowed_'][$extension])) ? false : true; return (!isset($extensions['_allowed_'][$extension])) ? false : true;
@ -1187,7 +1188,7 @@ class bitfield
{ {
var $data; var $data;
function bitfield($bitfield = '') function __construct($bitfield = '')
{ {
$this->data = base64_decode($bitfield); $this->data = base64_decode($bitfield);
} }

View file

@ -1106,7 +1106,7 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank
if (empty($ranks)) if (empty($ranks))
{ {
global $cache; global $cache;
$ranks = $cache->obtain_ranks(); $ranks = cache::obtain_ranks();
} }
if (!empty($user_rank)) if (!empty($user_rank))

View file

@ -362,7 +362,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
case 'firebird': case 'firebird':
// check the version of FB, use some hackery if we can't get access to the server info // check the version of FB, use some hackery if we can't get access to the server info
if ($db->service_handle !== false && function_exists('ibase_server_info')) if ($db->service_handle !== false && strtolower($dbuser) == 'sysdba')
{ {
$val = @ibase_server_info($db->service_handle, IBASE_SVC_SERVER_VERSION); $val = @ibase_server_info($db->service_handle, IBASE_SVC_SERVER_VERSION);
preg_match('#V([\d.]+)#', $val, $match); preg_match('#V([\d.]+)#', $val, $match);

View file

@ -30,31 +30,31 @@ if (!defined('IN_PHPBB'))
*/ */
class jabber class jabber
{ {
var $connection = null; private $connection = null;
var $session = array(); private $session = array();
var $timeout = 10; private $timeout = 10;
var $server; private $server;
var $port; private $port;
var $username; private $username;
var $password; private $password;
var $use_ssl; private $use_ssl;
var $resource = 'functions_jabber.phpbb.php'; private $resource = 'functions_jabber.phpbb.php';
var $enable_logging; private $enable_logging;
var $log_array; private $log_array;
var $features = array(); private $features = array();
/** /**
*/ */
function jabber($server, $port, $username, $password, $use_ssl = false) function __construct($server, $port, $username, $password, $use_ssl = false)
{ {
$this->server = ($server) ? $server : 'localhost'; $this->server = ($server) ? $server : 'localhost';
$this->port = ($port) ? $port : 5222; $this->port = ($port) ? $port : 5222;
$this->username = $username; $this->username = $username;
$this->password = $password; $this->password = $password;
$this->use_ssl = ($use_ssl && $this->can_use_ssl()) ? true : false; $this->use_ssl = ($use_ssl && self::can_use_ssl()) ? true : false;
// Change port if we use SSL // Change port if we use SSL
if ($this->port == 5222 && $this->use_ssl) if ($this->port == 5222 && $this->use_ssl)
@ -69,7 +69,7 @@ class jabber
/** /**
* Able to use the SSL functionality? * Able to use the SSL functionality?
*/ */
function can_use_ssl() public static function can_use_ssl()
{ {
// Will not work with PHP >= 5.2.1 or < 5.2.3RC2 until timeout problem with ssl hasn't been fixed (http://bugs.php.net/41236) // Will not work with PHP >= 5.2.1 or < 5.2.3RC2 until timeout problem with ssl hasn't been fixed (http://bugs.php.net/41236)
return ((version_compare(PHP_VERSION, '5.2.1', '<') || version_compare(PHP_VERSION, '5.2.3RC2', '>=')) && @extension_loaded('openssl')) ? true : false; return ((version_compare(PHP_VERSION, '5.2.1', '<') || version_compare(PHP_VERSION, '5.2.3RC2', '>=')) && @extension_loaded('openssl')) ? true : false;
@ -78,7 +78,7 @@ class jabber
/** /**
* Able to use TLS? * Able to use TLS?
*/ */
function can_use_tls() public static function can_use_tls()
{ {
if (!@extension_loaded('openssl') || !function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('socket_set_blocking') || !function_exists('stream_get_wrappers')) if (!@extension_loaded('openssl') || !function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('socket_set_blocking') || !function_exists('stream_get_wrappers'))
{ {
@ -105,7 +105,7 @@ class jabber
* @param string $name * @param string $name
* @access public * @access public
*/ */
function set_resource($name) public function set_resource($name)
{ {
$this->resource = $name; $this->resource = $name;
} }
@ -113,7 +113,7 @@ class jabber
/** /**
* Connect * Connect
*/ */
function connect() public function connect()
{ {
/* if (!$this->check_jid($this->username . '@' . $this->server)) /* if (!$this->check_jid($this->username . '@' . $this->server))
{ {
@ -142,7 +142,7 @@ class jabber
/** /**
* Disconnect * Disconnect
*/ */
function disconnect() public function disconnect()
{ {
if ($this->connected()) if ($this->connected())
{ {
@ -163,7 +163,7 @@ class jabber
/** /**
* Connected? * Connected?
*/ */
function connected() public function connected()
{ {
return (is_resource($this->connection) && !feof($this->connection)) ? true : false; return (is_resource($this->connection) && !feof($this->connection)) ? true : false;
} }
@ -174,7 +174,7 @@ class jabber
* @access public * @access public
* @return bool * @return bool
*/ */
function login() public function login()
{ {
if (!sizeof($this->features)) if (!sizeof($this->features))
{ {
@ -188,10 +188,10 @@ class jabber
/** /**
* Send data to the Jabber server * Send data to the Jabber server
* @param string $xml * @param string $xml
* @access public * @access private
* @return bool * @return bool
*/ */
function send($xml) private function send($xml)
{ {
if ($this->connected()) if ($this->connected())
{ {
@ -211,10 +211,10 @@ class jabber
* @param string $server host to connect to * @param string $server host to connect to
* @param int $port port number * @param int $port port number
* @param bool $use_ssl use ssl or not * @param bool $use_ssl use ssl or not
* @access public * @access private
* @return bool * @return bool
*/ */
function open_socket($server, $port, $use_ssl = false) private function open_socket($server, $port, $use_ssl = false)
{ {
if (@function_exists('dns_get_record')) if (@function_exists('dns_get_record'))
{ {
@ -243,7 +243,7 @@ class jabber
/** /**
* Return log * Return log
*/ */
function get_log() public function get_log()
{ {
if ($this->enable_logging && sizeof($this->log_array)) if ($this->enable_logging && sizeof($this->log_array))
{ {
@ -256,7 +256,7 @@ class jabber
/** /**
* Add information to log * Add information to log
*/ */
function add_to_log($string) private function add_to_log($string)
{ {
if ($this->enable_logging) if ($this->enable_logging)
{ {
@ -267,10 +267,10 @@ class jabber
/** /**
* Listens to the connection until it gets data or the timeout is reached. * Listens to the connection until it gets data or the timeout is reached.
* Thus, it should only be called if data is expected to be received. * Thus, it should only be called if data is expected to be received.
* @access public * @access private
* @return mixed either false for timeout or an array with the received data * @return mixed either false for timeout or an array with the received data
*/ */
function listen($timeout = 10, $wait = false) private function listen($timeout = 10, $wait = false)
{ {
if (!$this->connected()) if (!$this->connected())
{ {
@ -291,7 +291,7 @@ class jabber
if ($data != '') if ($data != '')
{ {
$this->add_to_log('RECV: '. $data); $this->add_to_log('RECV: '. $data);
return $this->xmlize($data); return self::xmlize($data);
} }
else else
{ {
@ -302,10 +302,10 @@ class jabber
/** /**
* Initiates account registration (based on data used for contructor) * Initiates account registration (based on data used for contructor)
* @access public * @access private
* @return bool * @return bool
*/ */
function register() private function register()
{ {
if (!isset($this->session['id']) || isset($this->session['jid'])) if (!isset($this->session['id']) || isset($this->session['jid']))
{ {
@ -322,10 +322,10 @@ class jabber
* @param $message online, offline... * @param $message online, offline...
* @param $type dnd, away, chat, xa or nothing * @param $type dnd, away, chat, xa or nothing
* @param $unavailable set this to true if you want to become unavailable * @param $unavailable set this to true if you want to become unavailable
* @access public * @access private
* @return bool * @return bool
*/ */
function send_presence($message = '', $type = '', $unavailable = false) private function send_presence($message = '', $type = '', $unavailable = false)
{ {
if (!isset($this->session['jid'])) if (!isset($this->session['jid']))
{ {
@ -347,10 +347,10 @@ class jabber
/** /**
* This handles all the different XML elements * This handles all the different XML elements
* @param array $xml * @param array $xml
* @access public * @access private
* @return bool * @return bool
*/ */
function response($xml) private function response($xml)
{ {
if (!is_array($xml) || !sizeof($xml)) if (!is_array($xml) || !sizeof($xml))
{ {
@ -420,7 +420,7 @@ class jabber
} }
// Let's use TLS if SSL is not enabled and we can actually use it // Let's use TLS if SSL is not enabled and we can actually use it
if (!$this->session['ssl'] && $this->can_use_tls() && $this->can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls'])) if (!$this->session['ssl'] && self::can_use_tls() && self::can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls']))
{ {
$this->add_to_log('Switching to TLS.'); $this->add_to_log('Switching to TLS.');
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\n"); $this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\n");
@ -483,7 +483,7 @@ class jabber
case 'challenge': case 'challenge':
// continue with authentication...a challenge literally -_- // continue with authentication...a challenge literally -_-
$decoded = base64_decode($xml['challenge'][0]['#']); $decoded = base64_decode($xml['challenge'][0]['#']);
$decoded = $this->parse_data($decoded); $decoded = self::parse_data($decoded);
if (!isset($decoded['digest-uri'])) if (!isset($decoded['digest-uri']))
{ {
@ -656,7 +656,7 @@ class jabber
} }
} }
function send_message($to, $text, $subject = '', $type = 'normal') public function send_message($to, $text, $subject = '', $type = 'normal')
{ {
if (!isset($this->session['jid'])) if (!isset($this->session['jid']))
{ {
@ -681,7 +681,7 @@ class jabber
* @access public * @access public
* @return string * @return string
*/ */
function encrypt_password($data) public function encrypt_password($data)
{ {
// let's me think about <challenge> again... // let's me think about <challenge> again...
foreach (array('realm', 'cnonce', 'digest-uri') as $key) foreach (array('realm', 'cnonce', 'digest-uri') as $key)
@ -712,10 +712,10 @@ class jabber
/** /**
* parse_data like a="b",c="d",... or like a="a, b", c, d="e", f=g,... * parse_data like a="b",c="d",... or like a="a, b", c, d="e", f=g,...
* @param string $data * @param string $data
* @access public * @access private
* @return array a => b ... * @return array a => b ...
*/ */
function parse_data($data) private static function parse_data($data)
{ {
$data = explode(',', $data); $data = explode(',', $data);
$pairs = array(); $pairs = array();
@ -744,10 +744,10 @@ class jabber
/** /**
* opposite of jabber::parse_data() * opposite of jabber::parse_data()
* @param array $data * @param array $data
* @access public * @access private
* @return string * @return string
*/ */
function implode_data($data) private function implode_data($data)
{ {
$return = array(); $return = array();
foreach ($data as $key => $value) foreach ($data as $key => $value)
@ -762,7 +762,7 @@ class jabber
* @author Hans Anderson * @author Hans Anderson
* @copyright Hans Anderson / http://www.hansanderson.com/php/xml/ * @copyright Hans Anderson / http://www.hansanderson.com/php/xml/
*/ */
function xmlize($data, $skip_white = 1, $encoding = 'UTF-8') private static function xmlize($data, $skip_white = 1, $encoding = 'UTF-8')
{ {
$data = trim($data); $data = trim($data);
@ -783,7 +783,7 @@ class jabber
$tagname = $vals[$i]['tag']; $tagname = $vals[$i]['tag'];
$array[$tagname][0]['@'] = (isset($vals[$i]['attributes'])) ? $vals[$i]['attributes'] : array(); $array[$tagname][0]['@'] = (isset($vals[$i]['attributes'])) ? $vals[$i]['attributes'] : array();
$array[$tagname][0]['#'] = $this->_xml_depth($vals, $i); $array[$tagname][0]['#'] = self::_xml_depth($vals, $i);
if (substr($data, 0, 5) != '<?xml') if (substr($data, 0, 5) != '<?xml')
{ {
@ -798,7 +798,7 @@ class jabber
* @author Hans Anderson * @author Hans Anderson
* @copyright Hans Anderson / http://www.hansanderson.com/php/xml/ * @copyright Hans Anderson / http://www.hansanderson.com/php/xml/
*/ */
function _xml_depth($vals, &$i) private static function _xml_depth($vals, &$i)
{ {
$children = array(); $children = array();
@ -821,7 +821,7 @@ class jabber
$children[$tagname][$size]['@'] = $vals[$i]['attributes']; $children[$tagname][$size]['@'] = $vals[$i]['attributes'];
} }
$children[$tagname][$size]['#'] = $this->_xml_depth($vals, $i); $children[$tagname][$size]['#'] = self::_xml_depth($vals, $i);
break; break;

View file

@ -22,17 +22,17 @@ if (!defined('IN_PHPBB'))
*/ */
class messenger class messenger
{ {
var $vars, $msg, $extra_headers, $replyto, $from, $subject; private $vars, $msg, $extra_headers, $replyto, $from, $subject;
var $addresses = array(); private $addresses = array();
var $mail_priority = MAIL_NORMAL_PRIORITY; private $mail_priority = MAIL_NORMAL_PRIORITY;
var $use_queue = true; private $use_queue = true;
var $tpl_msg = array(); private $tpl_msg = array();
/** /**
* Constructor * Constructor
*/ */
function messenger($use_queue = true) function __construct($use_queue = true)
{ {
global $config; global $config;
@ -43,7 +43,7 @@ class messenger
/** /**
* Resets all the data (address, template file, etc etc) to default * Resets all the data (address, template file, etc etc) to default
*/ */
function reset() private function reset()
{ {
$this->addresses = $this->extra_headers = array(); $this->addresses = $this->extra_headers = array();
$this->vars = $this->msg = $this->replyto = $this->from = ''; $this->vars = $this->msg = $this->replyto = $this->from = '';
@ -254,7 +254,7 @@ class messenger
/** /**
* Add error message to log * Add error message to log
*/ */
function error($type, $msg) public static function error($type, $msg)
{ {
global $user, $phpEx, $phpbb_root_path, $config; global $user, $phpEx, $phpbb_root_path, $config;
@ -299,7 +299,7 @@ class messenger
/** /**
* Return email header * Return email header
*/ */
function build_header($to, $cc, $bcc) private function build_header($to, $cc, $bcc)
{ {
global $config; global $config;
@ -346,7 +346,7 @@ class messenger
/** /**
* Send out emails * Send out emails
*/ */
function msg_email() private function msg_email()
{ {
global $config, $user; global $config, $user;
@ -413,7 +413,7 @@ class messenger
if (!$result) if (!$result)
{ {
$this->error('EMAIL', $err_msg); self::error('EMAIL', $err_msg);
return false; return false;
} }
} }
@ -434,7 +434,7 @@ class messenger
/** /**
* Send jabber message out * Send jabber message out
*/ */
function msg_jabber() private function msg_jabber()
{ {
global $config, $db, $user, $phpbb_root_path, $phpEx; global $config, $db, $user, $phpbb_root_path, $phpEx;
@ -468,13 +468,13 @@ class messenger
if (!$this->jabber->connect()) if (!$this->jabber->connect())
{ {
$this->error('JABBER', $user->lang['ERR_JAB_CONNECT'] . '<br />' . $this->jabber->get_log()); self::error('JABBER', $user->lang['ERR_JAB_CONNECT'] . '<br />' . $this->jabber->get_log());
return false; return false;
} }
if (!$this->jabber->login()) if (!$this->jabber->login())
{ {
$this->error('JABBER', $user->lang['ERR_JAB_AUTH'] . '<br />' . $this->jabber->get_log()); self::error('JABBER', $user->lang['ERR_JAB_AUTH'] . '<br />' . $this->jabber->get_log());
return false; return false;
} }
@ -504,15 +504,15 @@ class messenger
*/ */
class queue class queue
{ {
var $data = array(); private $data = array();
var $queue_data = array(); private $queue_data = array();
var $package_size = 0; private $package_size = 0;
var $cache_file = ''; private $cache_file = '';
/** /**
* constructor * constructor
*/ */
function queue() function __construct()
{ {
global $phpEx, $phpbb_root_path; global $phpEx, $phpbb_root_path;
@ -523,7 +523,7 @@ class queue
/** /**
* Init a queue object * Init a queue object
*/ */
function init($object, $package_size) public function init($object, $package_size)
{ {
$this->data[$object] = array(); $this->data[$object] = array();
$this->data[$object]['package_size'] = $package_size; $this->data[$object]['package_size'] = $package_size;
@ -533,7 +533,7 @@ class queue
/** /**
* Put object in queue * Put object in queue
*/ */
function put($object, $scope) public function put($object, $scope)
{ {
$this->data[$object]['data'][] = $scope; $this->data[$object]['data'][] = $scope;
} }
@ -542,7 +542,7 @@ class queue
* Process queue * Process queue
* Using lock file * Using lock file
*/ */
function process() public function process()
{ {
global $db, $config, $phpEx, $phpbb_root_path, $user; global $db, $config, $phpEx, $phpbb_root_path, $user;
@ -707,7 +707,7 @@ class queue
/** /**
* Save queue * Save queue
*/ */
function save() public function save()
{ {
if (!sizeof($this->data)) if (!sizeof($this->data))
{ {
@ -963,16 +963,16 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
*/ */
class smtp_class class smtp_class
{ {
var $server_response = ''; private $server_response = '';
var $socket = 0; public $socket = 0;
var $responses = array(); private $responses = array();
var $commands = array(); private $commands = array();
var $numeric_response_code = 0; public $numeric_response_code = 0;
var $backtrace = false; private $backtrace = false;
var $backtrace_log = array(); private $backtrace_log = array();
function smtp_class() function __construct()
{ {
// Always create a backtrace for admins to identify SMTP problems // Always create a backtrace for admins to identify SMTP problems
$this->backtrace = true; $this->backtrace = true;
@ -982,7 +982,7 @@ class smtp_class
/** /**
* Add backtrace message for debugging * Add backtrace message for debugging
*/ */
function add_backtrace($message) public function add_backtrace($message)
{ {
if ($this->backtrace) if ($this->backtrace)
{ {
@ -993,7 +993,7 @@ class smtp_class
/** /**
* Send command to smtp server * Send command to smtp server
*/ */
function server_send($command, $private_info = false) public function server_send($command, $private_info = false)
{ {
fputs($this->socket, $command . "\r\n"); fputs($this->socket, $command . "\r\n");
@ -1005,7 +1005,7 @@ class smtp_class
/** /**
* We use the line to give the support people an indication at which command the error occurred * We use the line to give the support people an indication at which command the error occurred
*/ */
function server_parse($response, $line) public function server_parse($response, $line)
{ {
global $user; global $user;
@ -1037,7 +1037,7 @@ class smtp_class
/** /**
* Close session * Close session
*/ */
function close_session(&$err_msg) public function close_session(&$err_msg)
{ {
fclose($this->socket); fclose($this->socket);
@ -1051,7 +1051,7 @@ class smtp_class
/** /**
* Log into server and get possible auth codes if neccessary * Log into server and get possible auth codes if neccessary
*/ */
function log_into_server($hostname, $username, $password, $default_auth_method) public function log_into_server($hostname, $username, $password, $default_auth_method)
{ {
global $user; global $user;
@ -1171,7 +1171,7 @@ class smtp_class
/** /**
* Pop before smtp authentication * Pop before smtp authentication
*/ */
function pop_before_smtp($hostname, $username, $password) private function pop_before_smtp($hostname, $username, $password)
{ {
global $user; global $user;
@ -1206,7 +1206,7 @@ class smtp_class
/** /**
* Plain authentication method * Plain authentication method
*/ */
function plain($username, $password) private function plain($username, $password)
{ {
$this->server_send('AUTH PLAIN'); $this->server_send('AUTH PLAIN');
if ($err_msg = $this->server_parse('334', __LINE__)) if ($err_msg = $this->server_parse('334', __LINE__))
@ -1227,7 +1227,7 @@ class smtp_class
/** /**
* Login authentication method * Login authentication method
*/ */
function login($username, $password) private function login($username, $password)
{ {
$this->server_send('AUTH LOGIN'); $this->server_send('AUTH LOGIN');
if ($err_msg = $this->server_parse('334', __LINE__)) if ($err_msg = $this->server_parse('334', __LINE__))
@ -1253,7 +1253,7 @@ class smtp_class
/** /**
* cram_md5 authentication method * cram_md5 authentication method
*/ */
function cram_md5($username, $password) private function cram_md5($username, $password)
{ {
$this->server_send('AUTH CRAM-MD5'); $this->server_send('AUTH CRAM-MD5');
if ($err_msg = $this->server_parse('334', __LINE__)) if ($err_msg = $this->server_parse('334', __LINE__))
@ -1280,7 +1280,7 @@ class smtp_class
* digest_md5 authentication method * digest_md5 authentication method
* A real pain in the *** * A real pain in the ***
*/ */
function digest_md5($username, $password) private function digest_md5($username, $password)
{ {
global $config, $user; global $config, $user;

View file

@ -249,7 +249,7 @@ function posting_gen_topic_icons($mode, $icon_id)
global $phpbb_root_path, $config, $template, $cache; global $phpbb_root_path, $config, $template, $cache;
// Grab icons // Grab icons
$icons = $cache->obtain_icons(); $icons = cache::obtain_icons();
if (!$icon_id) if (!$icon_id)
{ {
@ -373,7 +373,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 = cache::obtain_attach_extensions((($is_message) ? false : (int) $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);
@ -991,7 +991,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 = cache::obtain_attach_extensions($forum_id);
// Get attachments... // Get attachments...
$sql = 'SELECT * $sql = 'SELECT *

View file

@ -22,16 +22,16 @@ if (!defined('IN_PHPBB'))
*/ */
class custom_profile class custom_profile
{ {
var $profile_types = array(FIELD_INT => 'int', FIELD_STRING => 'string', FIELD_TEXT => 'text', FIELD_BOOL => 'bool', FIELD_DROPDOWN => 'dropdown', FIELD_DATE => 'date'); const profile_types = array(FIELD_INT => 'int', FIELD_STRING => 'string', FIELD_TEXT => 'text', FIELD_BOOL => 'bool', FIELD_DROPDOWN => 'dropdown', FIELD_DATE => 'date');
var $profile_cache = array(); private $profile_cache = array();
var $options_lang = array(); private $options_lang = array();
/** /**
* Assign editable fields to template, mode can be profile (for profile change) or register (for registration) * Assign editable fields to template, mode can be profile (for profile change) or register (for registration)
* Called by ucp_profile and ucp_register * Called by ucp_profile and ucp_register
* @access public * @access public
*/ */
function generate_profile_fields($mode, $lang_id) public function generate_profile_fields($mode, $lang_id)
{ {
global $db, $template, $auth; global $db, $template, $auth;
@ -88,7 +88,7 @@ class custom_profile
* Validate entered profile field data * Validate entered profile field data
* @access public * @access public
*/ */
function validate_profile_field($field_type, &$field_value, $field_data) public function validate_profile_field($field_type, &$field_value, $field_data)
{ {
switch ($field_type) switch ($field_type)
{ {
@ -200,7 +200,7 @@ class custom_profile
* Build profile cache, used for display * Build profile cache, used for display
* @access private * @access private
*/ */
function build_cache() private function build_cache()
{ {
global $db, $user, $auth; global $db, $user, $auth;
@ -227,7 +227,7 @@ class custom_profile
/** /**
* Get language entries for options and store them here for later use * Get language entries for options and store them here for later use
*/ */
function get_option_lang($field_id, $lang_id, $field_type, $preview) private function get_option_lang($field_id, $lang_id, $field_type, $preview)
{ {
global $db; global $db;
@ -235,6 +235,7 @@ class custom_profile
{ {
$lang_options = (!is_array($this->vars['lang_options'])) ? explode("\n", $this->vars['lang_options']) : $this->vars['lang_options']; $lang_options = (!is_array($this->vars['lang_options'])) ? explode("\n", $this->vars['lang_options']) : $this->vars['lang_options'];
// @todo: ref optimize
foreach ($lang_options as $num => $var) foreach ($lang_options as $num => $var)
{ {
$this->options_lang[$field_id][$lang_id][($num + 1)] = $var; $this->options_lang[$field_id][$lang_id][($num + 1)] = $var;
@ -250,6 +251,7 @@ class custom_profile
ORDER BY option_id"; ORDER BY option_id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
// @todo: ref optimize
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$this->options_lang[$field_id][$lang_id][($row['option_id'] + 1)] = $row['lang_value']; $this->options_lang[$field_id][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
@ -262,7 +264,7 @@ class custom_profile
* Submit profile field * Submit profile field
* @access public * @access public
*/ */
function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error) public function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
{ {
global $auth, $db, $user; global $auth, $db, $user;
@ -354,7 +356,7 @@ class custom_profile
* This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template * This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template
* @access public * @access public
*/ */
function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false) public function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false)
{ {
global $db; global $db;
@ -446,12 +448,12 @@ class custom_profile
/** /**
* Get Profile Value for display * Get Profile Value for display
*/ */
function get_profile_value($ident_ary) private function get_profile_value($ident_ary)
{ {
$value = $ident_ary['value']; $value = $ident_ary['value'];
$field_type = $ident_ary['data']['field_type']; $field_type = $ident_ary['data']['field_type'];
switch ($this->profile_types[$field_type]) switch (self::profile_types[$field_type])
{ {
case 'int': case 'int':
if ($value == '') if ($value == '')
@ -550,7 +552,7 @@ class custom_profile
* Get field value for registration/profile * Get field value for registration/profile
* @access private * @access private
*/ */
function get_var($field_validation, &$profile_row, $default_value, $preview) private function get_var($field_validation, &$profile_row, $default_value, $preview)
{ {
global $user; global $user;
@ -609,19 +611,19 @@ class custom_profile
* Process int-type * Process int-type
* @access private * @access private
*/ */
function generate_int($profile_row, $preview = false) private function generate_int($profile_row, $preview = false)
{ {
global $template; global $template;
$profile_row['field_value'] = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview); $profile_row['field_value'] = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); $template->assign_block_vars(self::profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
} }
/** /**
* Process date-type * Process date-type
* @access private * @access private
*/ */
function generate_date($profile_row, $preview = false) private function generate_date($profile_row, $preview = false)
{ {
global $user, $template; global $user, $template;
@ -673,21 +675,21 @@ class custom_profile
unset($now); unset($now);
$profile_row['field_value'] = 0; $profile_row['field_value'] = 0;
$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); $template->assign_block_vars(self::profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
} }
/** /**
* Process bool-type * Process bool-type
* @access private * @access private
*/ */
function generate_bool($profile_row, $preview = false) private function generate_bool($profile_row, $preview = false)
{ {
global $template; global $template;
$value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview); $value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
$profile_row['field_value'] = $value; $profile_row['field_value'] = $value;
$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); $template->assign_block_vars(self::profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
if ($profile_row['field_length'] == 1) if ($profile_row['field_length'] == 1)
{ {
@ -711,19 +713,19 @@ class custom_profile
* Process string-type * Process string-type
* @access private * @access private
*/ */
function generate_string($profile_row, $preview = false) private function generate_string($profile_row, $preview = false)
{ {
global $template; global $template;
$profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview); $profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview);
$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); $template->assign_block_vars(self::profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
} }
/** /**
* Process text-type * Process text-type
* @access private * @access private
*/ */
function generate_text($profile_row, $preview = false) private function generate_text($profile_row, $preview = false)
{ {
global $template; global $template;
global $user, $phpEx, $phpbb_root_path; global $user, $phpEx, $phpbb_root_path;
@ -733,14 +735,14 @@ class custom_profile
$profile_row['field_cols'] = $field_length[1]; $profile_row['field_cols'] = $field_length[1];
$profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview); $profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview);
$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); $template->assign_block_vars(self::profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
} }
/** /**
* Process dropdown-type * Process dropdown-type
* @access private * @access private
*/ */
function generate_dropdown($profile_row, $preview = false) private function generate_dropdown($profile_row, $preview = false)
{ {
global $user, $template; global $user, $template;
@ -752,7 +754,7 @@ class custom_profile
} }
$profile_row['field_value'] = $value; $profile_row['field_value'] = $value;
$template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); $template->assign_block_vars(self::profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
foreach ($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']] as $option_id => $option_value) foreach ($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']] as $option_id => $option_value)
{ {
@ -769,7 +771,7 @@ class custom_profile
* change == user is able to set/enter profile values; preview == just show the value * change == user is able to set/enter profile values; preview == just show the value
* @access private * @access private
*/ */
function process_field_row($mode, $profile_row) private function process_field_row($mode, $profile_row)
{ {
global $template; global $template;
@ -781,13 +783,13 @@ class custom_profile
); );
// empty previously filled blockvars // empty previously filled blockvars
foreach ($this->profile_types as $field_case => $field_type) foreach (self::profile_types as $field_case => $field_type)
{ {
$template->destroy_block_vars($field_type); $template->destroy_block_vars($field_type);
} }
// Assign template variables // Assign template variables
$type_func = 'generate_' . $this->profile_types[$profile_row['field_type']]; $type_func = 'generate_' . self::profile_types[$profile_row['field_type']];
$this->$type_func($profile_row, $preview); $this->$type_func($profile_row, $preview);
// Return templated data // Return templated data
@ -797,7 +799,7 @@ class custom_profile
/** /**
* Build Array for user insertion into custom profile fields table * Build Array for user insertion into custom profile fields table
*/ */
function build_insert_sql_array($cp_data) public static function build_insert_sql_array($cp_data)
{ {
global $db, $user, $auth; global $db, $user, $auth;
@ -833,7 +835,7 @@ class custom_profile
* Get profile field value on submit * Get profile field value on submit
* @access private * @access private
*/ */
function get_profile_field($profile_row) private function get_profile_field($profile_row)
{ {
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
global $config; global $config;
@ -906,12 +908,12 @@ class custom_profile
*/ */
class custom_profile_admin extends custom_profile class custom_profile_admin extends custom_profile
{ {
var $vars = array(); public $vars = array();
/** /**
* Return possible validation options * Return possible validation options
*/ */
function validate_options() public function validate_options()
{ {
global $user; global $user;
@ -930,7 +932,7 @@ class custom_profile_admin extends custom_profile
/** /**
* Get string options for second step in ACP * Get string options for second step in ACP
*/ */
function get_string_options() public function get_string_options()
{ {
global $user; global $user;
@ -947,7 +949,7 @@ class custom_profile_admin extends custom_profile
/** /**
* Get text options for second step in ACP * Get text options for second step in ACP
*/ */
function get_text_options() public function get_text_options()
{ {
global $user; global $user;
@ -964,7 +966,7 @@ class custom_profile_admin extends custom_profile
/** /**
* Get int options for second step in ACP * Get int options for second step in ACP
*/ */
function get_int_options() public function get_int_options()
{ {
global $user; global $user;
@ -981,7 +983,7 @@ class custom_profile_admin extends custom_profile
/** /**
* Get bool options for second step in ACP * Get bool options for second step in ACP
*/ */
function get_bool_options() public function get_bool_options()
{ {
global $user, $config, $lang_defs; global $user, $config, $lang_defs;
@ -1011,7 +1013,7 @@ class custom_profile_admin extends custom_profile
/** /**
* Get dropdown options for second step in ACP * Get dropdown options for second step in ACP
*/ */
function get_dropdown_options() public function get_dropdown_options()
{ {
global $user, $config, $lang_defs; global $user, $config, $lang_defs;
@ -1045,7 +1047,7 @@ class custom_profile_admin extends custom_profile
/** /**
* Get date options for second step in ACP * Get date options for second step in ACP
*/ */
function get_date_options() public function get_date_options()
{ {
global $user, $config, $lang_defs; global $user, $config, $lang_defs;

View file

@ -37,16 +37,16 @@ if (!defined('IN_PHPBB'))
*/ */
class template_compile class template_compile
{ {
var $template; private $template;
// Various storage arrays // Various storage arrays
var $block_names = array(); private $block_names = array();
var $block_else_level = array(); private $block_else_level = array();
/** /**
* constuctor * constuctor
*/ */
function template_compile(&$template) function __construct(template &$template)
{ {
$this->template = &$template; $this->template = &$template;
} }
@ -55,7 +55,7 @@ class template_compile
* Load template source from file * Load template source from file
* @access private * @access private
*/ */
function _tpl_load_file($handle, $store_in_db = false) public function _tpl_load_file($handle, $store_in_db = false)
{ {
// Try and open template for read // Try and open template for read
if (!file_exists($this->template->files[$handle])) if (!file_exists($this->template->files[$handle]))
@ -91,7 +91,7 @@ class template_compile
* the ones that exist in zend_language_scanner.l * the ones that exist in zend_language_scanner.l
* @access private * @access private
*/ */
function remove_php_tags(&$code) private function remove_php_tags(&$code)
{ {
// This matches the information gathered from the internal PHP lexer // This matches the information gathered from the internal PHP lexer
$match = array( $match = array(
@ -107,7 +107,7 @@ class template_compile
* The all seeing all doing compile method. Parts are inspired by or directly from Smarty * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
* @access private * @access private
*/ */
function compile($code, $no_echo = false, $echo_var = '') public function compile($code, $no_echo = false, $echo_var = '')
{ {
global $config; global $config;
@ -232,7 +232,7 @@ class template_compile
* Compile variables * Compile variables
* @access private * @access private
*/ */
function compile_var_tags(&$text_blocks) private function compile_var_tags(&$text_blocks)
{ {
// change template varrefs into PHP varrefs // change template varrefs into PHP varrefs
$varrefs = array(); $varrefs = array();
@ -274,7 +274,7 @@ class template_compile
* Compile blocks * Compile blocks
* @access private * @access private
*/ */
function compile_tag_block($tag_args) private function compile_tag_block($tag_args)
{ {
$no_nesting = false; $no_nesting = false;
@ -379,7 +379,7 @@ class template_compile
* some adaptions for our block level methods * some adaptions for our block level methods
* @access private * @access private
*/ */
function compile_tag_if($tag_args, $elseif) private function compile_tag_if($tag_args, $elseif)
{ {
// Tokenize args for 'if' tag. // Tokenize args for 'if' tag.
preg_match_all('/(?: preg_match_all('/(?:
@ -527,7 +527,7 @@ class template_compile
* Compile DEFINE tags * Compile DEFINE tags
* @access private * @access private
*/ */
function compile_tag_define($tag_args, $op) private function compile_tag_define($tag_args, $op)
{ {
preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
@ -580,7 +580,7 @@ class template_compile
* Compile INCLUDE tag * Compile INCLUDE tag
* @access private * @access private
*/ */
function compile_tag_include($tag_args) private function compile_tag_include($tag_args)
{ {
return "\$this->_tpl_include('$tag_args');"; return "\$this->_tpl_include('$tag_args');";
} }
@ -589,7 +589,7 @@ class template_compile
* Compile INCLUDE_PHP tag * Compile INCLUDE_PHP tag
* @access private * @access private
*/ */
function compile_tag_include_php($tag_args) private function compile_tag_include_php($tag_args)
{ {
return "include('" . $tag_args . "');"; return "include('" . $tag_args . "');";
} }
@ -599,7 +599,7 @@ class template_compile
* This is from Smarty * This is from Smarty
* @access private * @access private
*/ */
function _parse_is_expr($is_arg, $tokens) private function _parse_is_expr($is_arg, array $tokens)
{ {
$expr_end = 0; $expr_end = 0;
$negate_expr = false; $negate_expr = false;
@ -670,7 +670,7 @@ class template_compile
* NOTE: expects a trailing "." on the namespace. * NOTE: expects a trailing "." on the namespace.
* @access private * @access private
*/ */
function generate_block_varref($namespace, $varname, $echo = true, $defop = false) private function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
{ {
// Strip the trailing period. // Strip the trailing period.
$namespace = substr($namespace, 0, -1); $namespace = substr($namespace, 0, -1);
@ -695,7 +695,7 @@ class template_compile
* NOTE: does not expect a trailing "." on the blockname. * NOTE: does not expect a trailing "." on the blockname.
* @access private * @access private
*/ */
function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) private function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
{ {
// Get an array of the blocks involved. // Get an array of the blocks involved.
$blocks = explode('.', $blockname); $blocks = explode('.', $blockname);
@ -733,7 +733,7 @@ class template_compile
* Write compiled file to cache directory * Write compiled file to cache directory
* @access private * @access private
*/ */
function compile_write($handle, $data) public function compile_write($handle, $data)
{ {
global $phpEx; global $phpEx;

View file

@ -36,7 +36,7 @@ class transfer
/** /**
* Constructor - init some basic values * Constructor - init some basic values
*/ */
function transfer() function __construct()
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -50,7 +50,7 @@ class transfer
/** /**
* Write file to location * Write file to location
*/ */
function write_file($destination_file = '', $contents = '') public function write_file($destination_file = '', $contents = '')
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -86,7 +86,7 @@ class transfer
/** /**
* Moving file into location. If the destination file already exists it gets overwritten * Moving file into location. If the destination file already exists it gets overwritten
*/ */
function overwrite_file($source_file, $destination_file) public function overwrite_file($source_file, $destination_file)
{ {
/** /**
* @todo generally think about overwriting files in another way, by creating a temporary file and then renaming it * @todo generally think about overwriting files in another way, by creating a temporary file and then renaming it
@ -102,7 +102,7 @@ class transfer
/** /**
* Create directory structure * Create directory structure
*/ */
function make_dir($dir) public function make_dir($dir)
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -142,7 +142,7 @@ class transfer
/** /**
* Copy file from source location to destination location * Copy file from source location to destination location
*/ */
function copy_file($from_loc, $to_loc) public function copy_file($from_loc, $to_loc)
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -162,7 +162,7 @@ class transfer
/** /**
* Remove file * Remove file
*/ */
function delete_file($file) public function delete_file($file)
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -175,7 +175,7 @@ class transfer
* Remove directory * Remove directory
* @todo remove child directories? * @todo remove child directories?
*/ */
function remove_dir($dir) public function remove_dir($dir)
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -187,7 +187,7 @@ class transfer
/** /**
* Rename a file or folder * Rename a file or folder
*/ */
function rename($old_handle, $new_handle) public function rename($old_handle, $new_handle)
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -199,7 +199,7 @@ class transfer
/** /**
* Check if a specified file exist... * Check if a specified file exist...
*/ */
function file_exists($directory, $filename) public function file_exists($directory, $filename)
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -219,7 +219,7 @@ class transfer
/** /**
* Open session * Open session
*/ */
function open_session() public function open_session()
{ {
return $this->_init(); return $this->_init();
} }
@ -227,7 +227,7 @@ class transfer
/** /**
* Close current session * Close current session
*/ */
function close_session() public function close_session()
{ {
return $this->_close(); return $this->_close();
} }
@ -235,7 +235,7 @@ class transfer
/** /**
* Determine methods able to be used * Determine methods able to be used
*/ */
function methods() public static function methods()
{ {
$methods = array(); $methods = array();
$disabled_functions = explode(',', @ini_get('disable_functions')); $disabled_functions = explode(',', @ini_get('disable_functions'));
@ -263,7 +263,7 @@ class ftp extends transfer
/** /**
* Standard parameters for FTP session * Standard parameters for FTP session
*/ */
function ftp($host, $username, $password, $root_path, $port = 21, $timeout = 10) function __construct($host, $username, $password, $root_path, $port = 21, $timeout = 10)
{ {
$this->host = $host; $this->host = $host;
$this->port = $port; $this->port = $port;
@ -280,7 +280,7 @@ class ftp extends transfer
} }
// Init some needed values // Init some needed values
transfer::transfer(); parent::__construct();
return; return;
} }
@ -288,7 +288,7 @@ class ftp extends transfer
/** /**
* Requests data * Requests data
*/ */
function data() private function data()
{ {
global $user; global $user;
@ -306,7 +306,7 @@ class ftp extends transfer
* Init FTP Session * Init FTP Session
* @access private * @access private
*/ */
function _init() private function _init()
{ {
// connect to the server // connect to the server
$this->connection = @ftp_connect($this->host, $this->port, $this->timeout); $this->connection = @ftp_connect($this->host, $this->port, $this->timeout);
@ -338,7 +338,7 @@ class ftp extends transfer
* Create Directory (MKDIR) * Create Directory (MKDIR)
* @access private * @access private
*/ */
function _mkdir($dir) private function _mkdir($dir)
{ {
return @ftp_mkdir($this->connection, $dir); return @ftp_mkdir($this->connection, $dir);
} }
@ -347,7 +347,7 @@ class ftp extends transfer
* Remove directory (RMDIR) * Remove directory (RMDIR)
* @access private * @access private
*/ */
function _rmdir($dir) private function _rmdir($dir)
{ {
return @ftp_rmdir($this->connection, $dir); return @ftp_rmdir($this->connection, $dir);
} }
@ -356,7 +356,7 @@ class ftp extends transfer
* Rename file * Rename file
* @access private * @access private
*/ */
function _rename($old_handle, $new_handle) private function _rename($old_handle, $new_handle)
{ {
return @ftp_rename($this->connection, $old_handle, $new_handle); return @ftp_rename($this->connection, $old_handle, $new_handle);
} }
@ -365,7 +365,7 @@ class ftp extends transfer
* Change current working directory (CHDIR) * Change current working directory (CHDIR)
* @access private * @access private
*/ */
function _chdir($dir = '') private function _chdir($dir = '')
{ {
if ($dir && $dir !== '/') if ($dir && $dir !== '/')
{ {
@ -382,7 +382,7 @@ class ftp extends transfer
* change file permissions (CHMOD) * change file permissions (CHMOD)
* @access private * @access private
*/ */
function _chmod($file, $perms) private function _chmod($file, $perms)
{ {
if (function_exists('ftp_chmod')) if (function_exists('ftp_chmod'))
{ {
@ -403,7 +403,7 @@ class ftp extends transfer
* Upload file to location (PUT) * Upload file to location (PUT)
* @access private * @access private
*/ */
function _put($from_file, $to_file) private function _put($from_file, $to_file)
{ {
// get the file extension // get the file extension
$file_extension = strtolower(substr(strrchr($to_file, '.'), 1)); $file_extension = strtolower(substr(strrchr($to_file, '.'), 1));
@ -425,7 +425,7 @@ class ftp extends transfer
* Delete file (DELETE) * Delete file (DELETE)
* @access private * @access private
*/ */
function _delete($file) private function _delete($file)
{ {
return @ftp_delete($this->connection, $file); return @ftp_delete($this->connection, $file);
} }
@ -434,7 +434,7 @@ class ftp extends transfer
* Close ftp session (CLOSE) * Close ftp session (CLOSE)
* @access private * @access private
*/ */
function _close() private function _close()
{ {
if (!$this->connection) if (!$this->connection)
{ {
@ -449,7 +449,7 @@ class ftp extends transfer
* At the moment not used by parent class * At the moment not used by parent class
* @access private * @access private
*/ */
function _cwd() private function _cwd()
{ {
return @ftp_pwd($this->connection); return @ftp_pwd($this->connection);
} }
@ -458,7 +458,7 @@ class ftp extends transfer
* Return list of files in a given directory (LS) * Return list of files in a given directory (LS)
* @access private * @access private
*/ */
function _ls($dir = './') private function _ls($dir = './')
{ {
return @ftp_nlist($this->connection, $dir); return @ftp_nlist($this->connection, $dir);
} }
@ -467,7 +467,7 @@ class ftp extends transfer
* FTP SITE command (ftp-only function) * FTP SITE command (ftp-only function)
* @access private * @access private
*/ */
function _site($command) private function _site($command)
{ {
return @ftp_site($this->connection, $command); return @ftp_site($this->connection, $command);
} }
@ -486,7 +486,7 @@ class ftp_fsock extends transfer
/** /**
* Standard parameters for FTP session * Standard parameters for FTP session
*/ */
function ftp_fsock($host, $username, $password, $root_path, $port = 21, $timeout = 10) function __construct($host, $username, $password, $root_path, $port = 21, $timeout = 10)
{ {
$this->host = $host; $this->host = $host;
$this->port = $port; $this->port = $port;
@ -503,7 +503,7 @@ class ftp_fsock extends transfer
} }
// Init some needed values // Init some needed values
transfer::transfer(); parent::__construct();
return; return;
} }
@ -511,7 +511,7 @@ class ftp_fsock extends transfer
/** /**
* Requests data * Requests data
*/ */
function data() private function data()
{ {
global $user; global $user;
@ -529,7 +529,7 @@ class ftp_fsock extends transfer
* Init FTP Session * Init FTP Session
* @access private * @access private
*/ */
function _init() private function _init()
{ {
$errno = 0; $errno = 0;
$errstr = ''; $errstr = '';
@ -568,7 +568,7 @@ class ftp_fsock extends transfer
* Create Directory (MKDIR) * Create Directory (MKDIR)
* @access private * @access private
*/ */
function _mkdir($dir) private function _mkdir($dir)
{ {
return $this->_send_command('MKD', $dir); return $this->_send_command('MKD', $dir);
} }
@ -577,7 +577,7 @@ class ftp_fsock extends transfer
* Remove directory (RMDIR) * Remove directory (RMDIR)
* @access private * @access private
*/ */
function _rmdir($dir) private function _rmdir($dir)
{ {
return $this->_send_command('RMD', $dir); return $this->_send_command('RMD', $dir);
} }
@ -586,7 +586,7 @@ class ftp_fsock extends transfer
* Rename File * Rename File
* @access private * @access private
*/ */
function _rename($old_handle, $new_handle) private function _rename($old_handle, $new_handle)
{ {
$this->_send_command('RNFR', $old_handle); $this->_send_command('RNFR', $old_handle);
return $this->_send_command('RNTO', $new_handle); return $this->_send_command('RNTO', $new_handle);
@ -613,7 +613,7 @@ class ftp_fsock extends transfer
* change file permissions (CHMOD) * change file permissions (CHMOD)
* @access private * @access private
*/ */
function _chmod($file, $perms) private function _chmod($file, $perms)
{ {
// Unfortunatly CHMOD is not expecting an octal value... // Unfortunatly CHMOD is not expecting an octal value...
// We need to transform the integer (which was an octal) to an octal representation (to get the int) and then pass as is. ;) // We need to transform the integer (which was an octal) to an octal representation (to get the int) and then pass as is. ;)
@ -624,7 +624,7 @@ class ftp_fsock extends transfer
* Upload file to location (PUT) * Upload file to location (PUT)
* @access private * @access private
*/ */
function _put($from_file, $to_file) private function _put($from_file, $to_file)
{ {
// We only use the BINARY file mode to cicumvent rewrite actions from ftp server (mostly linefeeds being replaced) // We only use the BINARY file mode to cicumvent rewrite actions from ftp server (mostly linefeeds being replaced)
// 'I' == BINARY // 'I' == BINARY
@ -660,7 +660,7 @@ class ftp_fsock extends transfer
* Delete file (DELETE) * Delete file (DELETE)
* @access private * @access private
*/ */
function _delete($file) private function _delete($file)
{ {
return $this->_send_command('DELE', $file); return $this->_send_command('DELE', $file);
} }
@ -669,7 +669,7 @@ class ftp_fsock extends transfer
* Close ftp session (CLOSE) * Close ftp session (CLOSE)
* @access private * @access private
*/ */
function _close() private function _close()
{ {
if (!$this->connection) if (!$this->connection)
{ {
@ -684,7 +684,7 @@ class ftp_fsock extends transfer
* At the moment not used by parent class * At the moment not used by parent class
* @access private * @access private
*/ */
function _cwd() private function _cwd()
{ {
$this->_send_command('PWD', '', false); $this->_send_command('PWD', '', false);
return preg_replace('#^[0-9]{3} "(.+)" .+\r\n#', '\\1', $this->_check_command(true)); return preg_replace('#^[0-9]{3} "(.+)" .+\r\n#', '\\1', $this->_check_command(true));
@ -694,7 +694,7 @@ class ftp_fsock extends transfer
* Return list of files in a given directory (LS) * Return list of files in a given directory (LS)
* @access private * @access private
*/ */
function _ls($dir = './') private function _ls($dir = './')
{ {
if (!$this->_open_data_connection()) if (!$this->_open_data_connection())
{ {
@ -717,7 +717,7 @@ class ftp_fsock extends transfer
* Send a command to server (FTP fsock only function) * Send a command to server (FTP fsock only function)
* @access private * @access private
*/ */
function _send_command($command, $args = '', $check = true) private function _send_command($command, $args = '', $check = true)
{ {
if (!empty($args)) if (!empty($args))
{ {
@ -738,7 +738,7 @@ class ftp_fsock extends transfer
* Opens a connection to send data (FTP fosck only function) * Opens a connection to send data (FTP fosck only function)
* @access private * @access private
*/ */
function _open_data_connection() private function _open_data_connection()
{ {
$this->_send_command('PASV', '', false); $this->_send_command('PASV', '', false);
@ -773,7 +773,7 @@ class ftp_fsock extends transfer
* Closes a connection used to send data * Closes a connection used to send data
* @access private * @access private
*/ */
function _close_data_connection() private function _close_data_connection()
{ {
return @fclose($this->data_connection); return @fclose($this->data_connection);
} }
@ -782,7 +782,7 @@ class ftp_fsock extends transfer
* Check to make sure command was successful (FTP fsock only function) * Check to make sure command was successful (FTP fsock only function)
* @access private * @access private
*/ */
function _check_command($return = false) private function _check_command($return = false)
{ {
$response = ''; $response = '';

View file

@ -48,7 +48,7 @@ class filespec
* File Class * File Class
* @access private * @access private
*/ */
function filespec($upload_ary, $upload_namespace) function __construct($upload_ary, $upload_namespace)
{ {
if (!isset($upload_ary)) if (!isset($upload_ary))
{ {
@ -446,7 +446,7 @@ class fileupload
* @param int $max_height Maximum image height (only checked for images) * @param int $max_height Maximum image height (only checked for images)
* *
*/ */
function fileupload($error_prefix = '', $allowed_extensions = false, $max_filesize = false, $min_width = false, $min_height = false, $max_width = false, $max_height = false) function __construct($error_prefix = '', $allowed_extensions = false, $max_filesize = false, $min_width = false, $min_height = false, $max_width = false, $max_height = false)
{ {
$this->set_allowed_extensions($allowed_extensions); $this->set_allowed_extensions($allowed_extensions);
$this->set_max_filesize($max_filesize); $this->set_max_filesize($max_filesize);

View file

@ -1354,89 +1354,39 @@ function validate_username($username, $allowed_username = false)
$mbstring = $pcre = false; $mbstring = $pcre = false;
// generic UTF-8 character types supported? // generic UTF-8 character types supported
if ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false)
{
$pcre = true;
}
else if (function_exists('mb_ereg_match'))
{
mb_regex_encoding('UTF-8');
$mbstring = true;
}
switch ($config['allow_name_chars']) switch ($config['allow_name_chars'])
{ {
case 'USERNAME_CHARS_ANY': case 'USERNAME_CHARS_ANY':
$pcre = true;
$regex = '.+'; $regex = '.+';
break; break;
case 'USERNAME_ALPHA_ONLY': case 'USERNAME_ALPHA_ONLY':
$pcre = true;
$regex = '[A-Za-z0-9]+'; $regex = '[A-Za-z0-9]+';
break; break;
case 'USERNAME_ALPHA_SPACERS': case 'USERNAME_ALPHA_SPACERS':
$pcre = true;
$regex = '[A-Za-z0-9-[\]_+ ]+'; $regex = '[A-Za-z0-9-[\]_+ ]+';
break; break;
case 'USERNAME_LETTER_NUM': case 'USERNAME_LETTER_NUM':
if ($pcre)
{
$regex = '[\p{Lu}\p{Ll}\p{N}]+'; $regex = '[\p{Lu}\p{Ll}\p{N}]+';
}
else if ($mbstring)
{
$regex = '[[:upper:][:lower:][:digit:]]+';
}
else
{
$pcre = true;
$regex = '[a-zA-Z0-9]+';
}
break; break;
case 'USERNAME_LETTER_NUM_SPACERS': case 'USERNAME_LETTER_NUM_SPACERS':
if ($pcre)
{
$regex = '[-\]_+ [\p{Lu}\p{Ll}\p{N}]+'; $regex = '[-\]_+ [\p{Lu}\p{Ll}\p{N}]+';
}
else if ($mbstring)
{
$regex = '[-\]_+ [[:upper:][:lower:][:digit:]]+';
}
else
{
$pcre = true;
$regex = '[-\]_+ [a-zA-Z0-9]+';
}
break; break;
case 'USERNAME_ASCII': case 'USERNAME_ASCII':
default: default:
$pcre = true;
$regex = '[\x01-\x7F]+'; $regex = '[\x01-\x7F]+';
break; break;
} }
if ($pcre)
{
if (!preg_match('#^' . $regex . '$#u', $username)) if (!preg_match('#^' . $regex . '$#u', $username))
{ {
return 'INVALID_CHARS'; return 'INVALID_CHARS';
} }
}
else if ($mbstring)
{
$matches = array();
mb_ereg_search_init('^' . $username . '$', $regex, $matches);
if (!mb_ereg_search())
{
return 'INVALID_CHARS';
}
}
$sql = 'SELECT username $sql = 'SELECT username
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
@ -1462,7 +1412,7 @@ function validate_username($username, $allowed_username = false)
return 'USERNAME_TAKEN'; return 'USERNAME_TAKEN';
} }
$bad_usernames = $cache->obtain_disallowed_usernames(); $bad_usernames = cache::obtain_disallowed_usernames();
foreach ($bad_usernames as $bad_username) foreach ($bad_usernames as $bad_username)
{ {
@ -1503,37 +1453,12 @@ function validate_password($password)
return false; return false;
} }
$pcre = $mbstring = false; // generic UTF-8 character types supported
// generic UTF-8 character types supported?
if ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false)
{
$upp = '\p{Lu}'; $upp = '\p{Lu}';
$low = '\p{Ll}'; $low = '\p{Ll}';
$let = '\p{L}'; $let = '\p{L}';
$num = '\p{N}'; $num = '\p{N}';
$sym = '[^\p{Lu}\p{Ll}\p{N}]'; $sym = '[^\p{Lu}\p{Ll}\p{N}]';
$pcre = true;
}
else if (function_exists('mb_ereg_match'))
{
mb_regex_encoding('UTF-8');
$upp = '[[:upper:]]';
$low = '[[:lower:]]';
$let = '[[:lower:][:upper:]]';
$num = '[[:digit:]]';
$sym = '[^[:upper:][:lower:][:digit:]]';
$mbstring = true;
}
else
{
$upp = '[A-Z]';
$low = '[a-z]';
$let = '[a-zA-Z]';
$num = '[0-9]';
$sym = '[^A-Za-z0-9]';
$pcre = true;
}
$chars = array(); $chars = array();
@ -1799,6 +1724,7 @@ function validate_jabber($jid)
$pos = 0; $pos = 0;
$result = true; $result = true;
// @todo: rewrite this!
while ($pos < strlen($username)) while ($pos < strlen($username))
{ {
$len = $uni = 0; $len = $uni = 0;

View file

@ -42,7 +42,7 @@ class phpbb_hook
* *
* @param array $valid_hooks array containing the hookable functions/methods * @param array $valid_hooks array containing the hookable functions/methods
*/ */
function phpbb_hook($valid_hooks) function __construct($valid_hooks)
{ {
foreach ($valid_hooks as $_null => $method) foreach ($valid_hooks as $_null => $method)
{ {

View file

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

View file

@ -26,7 +26,7 @@ class mcp_logs
var $u_action; var $u_action;
var $p_master; var $p_master;
function mcp_logs(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }

View file

@ -26,7 +26,7 @@ class mcp_main
var $p_master; var $p_master;
var $u_action; var $u_action;
function mcp_main(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }

View file

@ -26,7 +26,7 @@ class mcp_notes
var $p_master; var $p_master;
var $u_action; var $u_action;
function mcp_notes(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }

View file

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

View file

@ -26,7 +26,7 @@ class mcp_queue
var $p_master; var $p_master;
var $u_action; var $u_action;
function mcp_queue(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }
@ -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 = cache::obtain_attach_extensions($post_info['forum_id']);
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '

View file

@ -26,7 +26,7 @@ class mcp_reports
var $p_master; var $p_master;
var $u_action; var $u_action;
function mcp_reports(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }
@ -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 = cache::obtain_attach_extensions($post_info['forum_id']);
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '

View file

@ -164,7 +164,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 = cache::obtain_attach_extensions($topic_info['forum_id']);
// Get attachments... // Get attachments...
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id']))

View file

@ -26,7 +26,7 @@ class mcp_warn
var $p_master; var $p_master;
var $u_action; var $u_action;
function mcp_warn(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }

View file

@ -28,42 +28,25 @@ include_once($phpbb_root_path . 'includes/search/search.' . $phpEx);
*/ */
class fulltext_mysql extends search_backend class fulltext_mysql extends search_backend
{ {
var $stats = array(); private $stats = array();
var $word_length = array(); public $word_length = array();
var $split_words = array(); private $split_words = array();
var $search_query; public $search_query;
var $common_words = array(); public $common_words = array();
var $pcre_properties = false;
var $mbstring_regex = false;
function fulltext_mysql(&$error) function __construct(&$error)
{ {
global $config; global $config;
$this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']); $this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']);
if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>=')))
{
// While this is the proper range of PHP versions, PHP may not be linked with the bundled PCRE lib and instead with an older version
if (@preg_match('/\p{L}/u', 'a') !== false)
{
$this->pcre_properties = true;
}
}
if (function_exists('mb_ereg'))
{
$this->mbstring_regex = true;
mb_regex_encoding('UTF-8');
}
$error = false; $error = false;
} }
/** /**
* Checks for correct MySQL version and stores min/max word length in the config * Checks for correct MySQL version and stores min/max word length in the config
*/ */
function init() public function init()
{ {
global $db, $user; global $db, $user;
@ -116,7 +99,7 @@ class fulltext_mysql extends search_backend
* @param string $terms is either 'all' or 'any' * @param string $terms is either 'all' or 'any'
* @return bool false if no valid keywords were found and otherwise true * @return bool false if no valid keywords were found and otherwise true
*/ */
function split_keywords(&$keywords, $terms) public function split_keywords(&$keywords, $terms)
{ {
global $config; global $config;
@ -132,40 +115,11 @@ class fulltext_mysql extends search_backend
$split_keywords = preg_replace("#[\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords))); $split_keywords = preg_replace("#[\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords)));
// Split words // Split words
if ($this->pcre_properties)
{
$split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords))); $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords)));
}
else if ($this->mbstring_regex)
{
$split_keywords = mb_ereg_replace('([^\w\'*"()])', '\\1\\1', str_replace('\'\'', '\' \'', trim($split_keywords)));
}
else
{
$split_keywords = preg_replace('#([^\w\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords)));
}
if ($this->pcre_properties)
{
$matches = array(); $matches = array();
preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches); preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches);
$this->split_words = $matches[1]; $this->split_words = $matches[1];
}
else if ($this->mbstring_regex)
{
mb_ereg_search_init($split_keywords, '(?:[^\w*"()]|^)([+\-|]?(?:[\w*"()]+\'?)*[\w*"()])(?:[^\w*"()]|$)');
while (($word = mb_ereg_search_regs()))
{
$this->split_words[] = $word[1];
}
}
else
{
$matches = array();
preg_match_all('#(?:[^\w*"()]|^)([+\-|]?(?:[\w*"()]+\'?)*[\w*"()])(?:[^\w*"()]|$)#u', $split_keywords, $matches);
$this->split_words = $matches[1];
}
// to allow phrase search, we need to concatenate quoted words // to allow phrase search, we need to concatenate quoted words
$tmp_split_words = array(); $tmp_split_words = array();
@ -259,46 +213,16 @@ class fulltext_mysql extends search_backend
/** /**
* Turns text into an array of words * Turns text into an array of words
*/ */
function split_message($text) private function split_message($text)
{ {
global $config; global $config;
// Split words // Split words
if ($this->pcre_properties)
{
$text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text))); $text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
}
else if ($this->mbstring_regex)
{
$text = mb_ereg_replace('([^\w\'*])', '\\1\\1', str_replace('\'\'', '\' \'', trim($text)));
}
else
{
$text = preg_replace('#([^\w\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
}
if ($this->pcre_properties)
{
$matches = array(); $matches = array();
preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches); preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches);
$text = $matches[1]; $text = $matches[1];
}
else if ($this->mbstring_regex)
{
mb_ereg_search_init($text, '(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)');
$text = array();
while (($word = mb_ereg_search_regs()))
{
$text[] = $word[1];
}
}
else
{
$matches = array();
preg_match_all('#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#u', $text, $matches);
$text = $matches[1];
}
// remove too short or too long words // remove too short or too long words
$text = array_values($text); $text = array_values($text);
@ -335,7 +259,7 @@ class fulltext_mysql extends search_backend
* *
* @access public * @access public
*/ */
function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) public function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)
{ {
global $config, $db; global $config, $db;
@ -361,7 +285,7 @@ class fulltext_mysql extends search_backend
// try reading the results from cache // try reading the results from cache
$result_count = 0; $result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == self::SEARCH_RESULT_IN_CACHE)
{ {
return $result_count; return $result_count;
} }
@ -494,7 +418,7 @@ class fulltext_mysql extends search_backend
* @param int $per_page number of ids each page is supposed to contain * @param int $per_page number of ids each page is supposed to contain
* @return total number of results * @return total number of results
*/ */
function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) public function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)
{ {
global $config, $db; global $config, $db;
@ -521,7 +445,7 @@ class fulltext_mysql extends search_backend
// try reading the results from cache // try reading the results from cache
$result_count = 0; $result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == self::SEARCH_RESULT_IN_CACHE)
{ {
return $result_count; return $result_count;
} }
@ -642,7 +566,7 @@ class fulltext_mysql extends search_backend
* *
* @param string $mode contains the post mode: edit, post, reply, quote ... * @param string $mode contains the post mode: edit, post, reply, quote ...
*/ */
function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
{ {
global $db; global $db;
@ -664,7 +588,7 @@ class fulltext_mysql extends search_backend
/** /**
* Destroy cached results, that might be outdated after deleting a post * Destroy cached results, that might be outdated after deleting a post
*/ */
function index_remove($post_ids, $author_ids, $forum_ids) public function index_remove($post_ids, $author_ids, $forum_ids)
{ {
$this->destroy_cache(array(), $author_ids); $this->destroy_cache(array(), $author_ids);
} }
@ -672,7 +596,7 @@ class fulltext_mysql extends search_backend
/** /**
* Destroy old cache entries * Destroy old cache entries
*/ */
function tidy() public function tidy()
{ {
global $db, $config; global $db, $config;
@ -685,7 +609,7 @@ class fulltext_mysql extends search_backend
/** /**
* Create fulltext index * Create fulltext index
*/ */
function create_index($acp_module, $u_action) public function create_index($acp_module, $u_action)
{ {
global $db; global $db;
@ -746,7 +670,7 @@ class fulltext_mysql extends search_backend
/** /**
* Drop fulltext index * Drop fulltext index
*/ */
function delete_index($acp_module, $u_action) public function delete_index($acp_module, $u_action)
{ {
global $db; global $db;
@ -791,7 +715,7 @@ class fulltext_mysql extends search_backend
/** /**
* Returns true if both FULLTEXT indexes exist * Returns true if both FULLTEXT indexes exist
*/ */
function index_created() public function index_created()
{ {
if (empty($this->stats)) if (empty($this->stats))
{ {
@ -804,7 +728,7 @@ class fulltext_mysql extends search_backend
/** /**
* Returns an associative array containing information about the indexes * Returns an associative array containing information about the indexes
*/ */
function index_stats() public function index_stats()
{ {
global $user; global $user;
@ -818,7 +742,7 @@ class fulltext_mysql extends search_backend
); );
} }
function get_stats() private function get_stats()
{ {
global $db; global $db;
@ -863,22 +787,13 @@ class fulltext_mysql extends search_backend
} }
/** /**
* Display a note, that UTF-8 support is not available with certain versions of PHP * Display nothing, we force UTF-8 support in all versions of PHP
*/ */
function acp() function acp()
{ {
global $user, $config; global $user, $config;
$tpl = ' $tpl = '';
<dl>
<dt><label>' . $user->lang['FULLTEXT_MYSQL_PCRE'] . '</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_PCRE_EXPLAIN'] . '</span></dt>
<dd>' . (($this->pcre_properties) ? $user->lang['YES'] : $user->lang['NO']) . ' (PHP ' . PHP_VERSION . ')</dd>
</dl>
<dl>
<dt><label>' . $user->lang['FULLTEXT_MYSQL_MBSTRING'] . '</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MBSTRING_EXPLAIN'] . '</span></dt>
<dd>' . (($this->mbstring_regex) ? $user->lang['YES'] : $user->lang['NO']). '</dd>
</dl>
';
// These are fields required in the config table // These are fields required in the config table
return array( return array(

View file

@ -28,14 +28,14 @@ include_once($phpbb_root_path . 'includes/search/search.' . $phpEx);
*/ */
class fulltext_native extends search_backend class fulltext_native extends search_backend
{ {
var $stats = array(); private $stats = array();
var $word_length = array(); public $word_length = array();
var $search_query; public $search_query;
var $common_words = array(); public $common_words = array();
var $must_contain_ids = array(); private $must_contain_ids = array();
var $must_not_contain_ids = array(); private $must_not_contain_ids = array();
var $must_exclude_one_ids = array(); private $must_exclude_one_ids = array();
/** /**
* Initialises the fulltext_native search backend with min/max word length and makes sure the UTF-8 normalizer is loaded. * Initialises the fulltext_native search backend with min/max word length and makes sure the UTF-8 normalizer is loaded.
@ -44,7 +44,7 @@ class fulltext_native extends search_backend
* *
* @access public * @access public
*/ */
function fulltext_native(&$error) function __construct(&$error)
{ {
global $phpbb_root_path, $phpEx, $config; global $phpbb_root_path, $phpEx, $config;
@ -79,7 +79,7 @@ class fulltext_native extends search_backend
* *
* @access public * @access public
*/ */
function split_keywords($keywords, $terms) public function split_keywords($keywords, $terms)
{ {
global $db, $user; global $db, $user;
@ -402,7 +402,7 @@ class fulltext_native extends search_backend
* *
* @access public * @access public
*/ */
function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) public function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)
{ {
global $config, $db; global $config, $db;
@ -430,7 +430,7 @@ class fulltext_native extends search_backend
// try reading the results from cache // try reading the results from cache
$total_results = 0; $total_results = 0;
if ($this->obtain_ids($search_key, $total_results, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) if ($this->obtain_ids($search_key, $total_results, $id_ary, $start, $per_page, $sort_dir) == self::SEARCH_RESULT_IN_CACHE)
{ {
return $total_results; return $total_results;
} }
@ -761,7 +761,7 @@ class fulltext_native extends search_backend
* *
* @access public * @access public
*/ */
function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) public function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)
{ {
global $config, $db; global $config, $db;
@ -788,7 +788,7 @@ class fulltext_native extends search_backend
// try reading the results from cache // try reading the results from cache
$total_results = 0; $total_results = 0;
if ($this->obtain_ids($search_key, $total_results, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) if ($this->obtain_ids($search_key, $total_results, $id_ary, $start, $per_page, $sort_dir) == self::SEARCH_RESULT_IN_CACHE)
{ {
return $total_results; return $total_results;
} }
@ -973,7 +973,7 @@ class fulltext_native extends search_backend
* *
* @access private * @access private
*/ */
function split_message($text) private function split_message($text)
{ {
global $phpbb_root_path, $phpEx, $user; global $phpbb_root_path, $phpEx, $user;
@ -1052,7 +1052,7 @@ class fulltext_native extends search_backend
* *
* @access public * @access public
*/ */
function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
{ {
global $config, $db, $user; global $config, $db, $user;
@ -1211,7 +1211,7 @@ class fulltext_native extends search_backend
/** /**
* Removes entries from the wordmatch table for the specified post_ids * Removes entries from the wordmatch table for the specified post_ids
*/ */
function index_remove($post_ids, $author_ids, $forum_ids) public function index_remove($post_ids, $author_ids, $forum_ids)
{ {
global $db; global $db;
@ -1271,7 +1271,7 @@ class fulltext_native extends search_backend
* Tidy up indexes: Tag 'common words' and remove * Tidy up indexes: Tag 'common words' and remove
* words no longer referenced in the match table * words no longer referenced in the match table
*/ */
function tidy() public function tidy()
{ {
global $db, $config; global $db, $config;
@ -1336,7 +1336,7 @@ class fulltext_native extends search_backend
/** /**
* Deletes all words from the index * Deletes all words from the index
*/ */
function delete_index($acp_module, $u_action) public function delete_index($acp_module, $u_action)
{ {
global $db; global $db;
@ -1360,7 +1360,7 @@ class fulltext_native extends search_backend
/** /**
* Returns true if both FULLTEXT indexes exist * Returns true if both FULLTEXT indexes exist
*/ */
function index_created() public function index_created()
{ {
if (!sizeof($this->stats)) if (!sizeof($this->stats))
{ {
@ -1373,7 +1373,7 @@ class fulltext_native extends search_backend
/** /**
* Returns an associative array containing information about the indexes * Returns an associative array containing information about the indexes
*/ */
function index_stats() public function index_stats()
{ {
global $user; global $user;
@ -1387,7 +1387,7 @@ class fulltext_native extends search_backend
$user->lang['TOTAL_MATCHES'] => $this->stats['total_matches']); $user->lang['TOTAL_MATCHES'] => $this->stats['total_matches']);
} }
function get_stats() private function get_stats()
{ {
global $db; global $db;
@ -1414,24 +1414,16 @@ class fulltext_native extends search_backend
* *
* @param string $text Text to split, in UTF-8 (not normalized or sanitized) * @param string $text Text to split, in UTF-8 (not normalized or sanitized)
* @param string $allowed_chars String of special chars to allow * @param string $allowed_chars String of special chars to allow
* @param string $encoding Text encoding
* @return string Cleaned up text, only alphanumeric chars are left * @return string Cleaned up text, only alphanumeric chars are left
* *
* @todo normalizer::cleanup being able to be used? * @todo normalizer::cleanup being able to be used?
*/ */
function cleanup($text, $allowed_chars = null, $encoding = 'utf-8') private function cleanup($text, $allowed_chars = null)
{ {
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
static $conv = array(), $conv_loaded = array(); static $conv = array(), $conv_loaded = array();
$words = $allow = array(); $words = $allow = array();
// Convert the text to UTF-8
$encoding = strtolower($encoding);
if ($encoding != 'utf-8')
{
$text = utf8_recode($text, $encoding);
}
$utf_len_mask = array( $utf_len_mask = array(
"\xC0" => 2, "\xC0" => 2,
"\xD0" => 2, "\xD0" => 2,
@ -1649,7 +1641,7 @@ class fulltext_native extends search_backend
/** /**
* Returns a list of options for the ACP to display * Returns a list of options for the ACP to display
*/ */
function acp() public function acp()
{ {
global $user, $config; global $user, $config;

View file

@ -16,13 +16,6 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
/**
* @ignore
*/
define('SEARCH_RESULT_NOT_IN_CACHE', 0);
define('SEARCH_RESULT_IN_CACHE', 1);
define('SEARCH_RESULT_INCOMPLETE', 2);
/** /**
* search_backend * search_backend
* optional base class for search plugins providing simple caching based on ACM * optional base class for search plugins providing simple caching based on ACM
@ -31,11 +24,15 @@ define('SEARCH_RESULT_INCOMPLETE', 2);
*/ */
class search_backend class search_backend
{ {
var $ignore_words = array(); const SEARCH_RESULT_NOT_IN_CACHE = 0;
var $match_synonym = array(); const SEARCH_RESULT_IN_CACHE = 1;
var $replace_synonym = array(); const SEARCH_RESULT_INCOMPLETE = 2;
function search_backend(&$error) public $ignore_words = array();
public $match_synonym = array();
public $replace_synonym = array();
function __construct(&$error)
{ {
// This class cannot be used as a search plugin // This class cannot be used as a search plugin
$error = true; $error = true;
@ -44,7 +41,7 @@ class search_backend
/** /**
* Retrieves a language dependend list of words that should be ignored by the search * Retrieves a language dependend list of words that should be ignored by the search
*/ */
function get_ignore_words() public function get_ignore_words()
{ {
if (!sizeof($this->ignore_words)) if (!sizeof($this->ignore_words))
{ {
@ -66,7 +63,7 @@ class search_backend
/** /**
* Stores a list of synonyms that should be replaced in $this->match_synonym and $this->replace_synonym and caches them * Stores a list of synonyms that should be replaced in $this->match_synonym and $this->replace_synonym and caches them
*/ */
function get_synonyms() public function get_synonyms()
{ {
if (!sizeof($this->match_synonym)) if (!sizeof($this->match_synonym))
{ {
@ -95,14 +92,14 @@ class search_backend
* *
* @return int SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE * @return int SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE
*/ */
function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir) protected function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir)
{ {
global $cache; global $cache;
if (!($stored_ids = $cache->get('_search_results_' . $search_key))) if (!($stored_ids = $cache->get('_search_results_' . $search_key)))
{ {
// no search results cached for this search_key // no search results cached for this search_key
return SEARCH_RESULT_NOT_IN_CACHE; return self::SEARCH_RESULT_NOT_IN_CACHE;
} }
else else
{ {
@ -119,7 +116,7 @@ class search_backend
// the user requested a page past the last index // the user requested a page past the last index
if ($start < 0) if ($start < 0)
{ {
return SEARCH_RESULT_NOT_IN_CACHE; return self::SEARCH_RESULT_NOT_IN_CACHE;
} }
} }
@ -143,9 +140,9 @@ class search_backend
if (!$complete) if (!$complete)
{ {
return SEARCH_RESULT_INCOMPLETE; return self::SEARCH_RESULT_INCOMPLETE;
} }
return SEARCH_RESULT_IN_CACHE; return self::SEARCH_RESULT_IN_CACHE;
} }
} }
@ -155,7 +152,7 @@ class search_backend
* @param array &$id_ary contains a list of post or topic ids that shall be cached, the first element * @param array &$id_ary contains a list of post or topic ids that shall be cached, the first element
* must have the absolute index $start in the result set. * must have the absolute index $start in the result set.
*/ */
function save_ids($search_key, $keywords, $author_ary, $result_count, &$id_ary, $start, $sort_dir) protected function save_ids($search_key, $keywords, $author_ary, $result_count, &$id_ary, $start, $sort_dir)
{ {
global $cache, $config, $db, $user; global $cache, $config, $db, $user;
@ -264,7 +261,7 @@ class search_backend
/** /**
* Removes old entries from the search results table and removes searches with keywords that contain a word in $words. * Removes old entries from the search results table and removes searches with keywords that contain a word in $words.
*/ */
function destroy_cache($words, $authors = false) public function destroy_cache($words, $authors = false)
{ {
global $db, $cache, $config; global $db, $cache, $config;

View file

@ -371,7 +371,7 @@ class session
* bot, act accordingly * bot, act accordingly
*/ */
$bot = false; $bot = false;
$active_bots = $cache->obtain_bots(); $active_bots = cache::obtain_bots();
foreach ($active_bots as $row) foreach ($active_bots as $row)
{ {
@ -1403,7 +1403,7 @@ class user extends session
} }
// Now parse the cfg file and cache it // Now parse the cfg file and cache it
$parsed_items = $cache->obtain_cfg_items($this->theme); $parsed_items = cache::obtain_cfg_items($this->theme);
// We are only interested in the theme configuration for now // We are only interested in the theme configuration for now
$parsed_items = $parsed_items['theme']; $parsed_items = $parsed_items['theme'];

View file

@ -28,23 +28,23 @@ class template
* if it's a root-level variable, it'll be like this: * if it's a root-level variable, it'll be like this:
* --> $this->_tpldata[.][0][varname] == value * --> $this->_tpldata[.][0][varname] == value
*/ */
var $_tpldata = array('.' => array(0 => array())); private $_tpldata = array('.' => array(0 => array()));
var $_rootref; private $_rootref;
// Root dir and hash of filenames for each template handle. // Root dir and hash of filenames for each template handle.
var $root = ''; private $root = '';
var $cachepath = ''; public $cachepath = '';
var $files = array(); public $files = array();
var $filename = array(); public $filename = array();
// this will hash handle names to the compiled/uncompiled code for that handle. // this will hash handle names to the compiled/uncompiled code for that handle.
var $compiled_code = array(); public $compiled_code = array();
/** /**
* Set template location * Set template location
* @access public * @access public
*/ */
function set_template() public function set_template()
{ {
global $phpbb_root_path, $user; global $phpbb_root_path, $user;
@ -67,7 +67,7 @@ class template
* Set custom template location (able to use directory outside of phpBB) * Set custom template location (able to use directory outside of phpBB)
* @access public * @access public
*/ */
function set_custom_template($template_path, $template_name) public function set_custom_template($template_path, $template_name)
{ {
global $phpbb_root_path; global $phpbb_root_path;
@ -82,13 +82,8 @@ class template
* should be a hash of handle => filename pairs. * should be a hash of handle => filename pairs.
* @access public * @access public
*/ */
function set_filenames($filename_array) public function set_filenames(array $filename_array)
{ {
if (!is_array($filename_array))
{
return false;
}
foreach ($filename_array as $handle => $filename) foreach ($filename_array as $handle => $filename)
{ {
if (empty($filename)) if (empty($filename))
@ -107,7 +102,7 @@ class template
* Destroy template data set * Destroy template data set
* @access public * @access public
*/ */
function destroy() function __destruct()
{ {
$this->_tpldata = array('.' => array(0 => array())); $this->_tpldata = array('.' => array(0 => array()));
} }
@ -116,7 +111,7 @@ class template
* Reset/empty complete block * Reset/empty complete block
* @access public * @access public
*/ */
function destroy_block_vars($blockname) public function destroy_block_vars($blockname)
{ {
if (strpos($blockname, '.') !== false) if (strpos($blockname, '.') !== false)
{ {
@ -146,7 +141,7 @@ class template
* Display handle * Display handle
* @access public * @access public
*/ */
function display($handle, $include_once = true) public function display($handle, $include_once = true)
{ {
global $user, $phpbb_hook; global $user, $phpbb_hook;
@ -162,7 +157,7 @@ class template
{ {
if ((E_NOTICE & error_reporting()) == E_NOTICE) if ((E_NOTICE & error_reporting()) == E_NOTICE)
{ {
error_reporting(error_reporting() ^ E_NOTICE); //error_reporting(error_reporting() ^ E_NOTICE);
} }
} }
@ -182,7 +177,7 @@ class template
* Display the handle and assign the output to a template variable or return the compiled result. * Display the handle and assign the output to a template variable or return the compiled result.
* @access public * @access public
*/ */
function assign_display($handle, $template_var = '', $return_content = true, $include_once = false) public function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)
{ {
ob_start(); ob_start();
$this->display($handle, $include_once); $this->display($handle, $include_once);
@ -202,7 +197,7 @@ class template
* Load a compiled template if possible, if not, recompile it * Load a compiled template if possible, if not, recompile it
* @access private * @access private
*/ */
function _tpl_load(&$handle) private function _tpl_load(&$handle)
{ {
global $user, $phpEx, $config; global $user, $phpEx, $config;
@ -305,7 +300,7 @@ class template
* Assign key variable pairs from an array * Assign key variable pairs from an array
* @access public * @access public
*/ */
function assign_vars($vararray) public function assign_vars(array $vararray)
{ {
foreach ($vararray as $key => $val) foreach ($vararray as $key => $val)
{ {
@ -319,7 +314,7 @@ class template
* Assign a single variable to a single key * Assign a single variable to a single key
* @access public * @access public
*/ */
function assign_var($varname, $varval) public function assign_var($varname, $varval)
{ {
$this->_rootref[$varname] = $varval; $this->_rootref[$varname] = $varval;
@ -330,7 +325,7 @@ class template
* Assign key variable pairs from an array to a specified block * Assign key variable pairs from an array to a specified block
* @access public * @access public
*/ */
function assign_block_vars($blockname, $vararray) public function assign_block_vars($blockname, array $vararray)
{ {
if (strpos($blockname, '.') !== false) if (strpos($blockname, '.') !== false)
{ {
@ -421,7 +416,7 @@ class template
* @return bool false on error, true on success * @return bool false on error, true on success
* @access public * @access public
*/ */
function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert') public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert')
{ {
if (strpos($blockname, '.') !== false) if (strpos($blockname, '.') !== false)
{ {
@ -507,7 +502,7 @@ class template
* Include a separate template * Include a separate template
* @access private * @access private
*/ */
function _tpl_include($filename, $include = true) public function _tpl_include($filename, $include = true)
{ {
$handle = $filename; $handle = $filename;
$this->filename[$handle] = $filename; $this->filename[$handle] = $filename;

View file

@ -71,8 +71,7 @@ class ucp_confirm
include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx); include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx);
} }
$captcha = new captcha(); captcha::execute($row['code'], $row['seed']);
$captcha->execute($row['code'], $row['seed']);
exit; exit;
} }
} }

View file

@ -26,7 +26,7 @@ class ucp_main
var $p_master; var $p_master;
var $u_action; var $u_action;
function ucp_main(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }

View file

@ -34,7 +34,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 = cache::obtain_icons();
$color_rows = array('marked', 'replied'); $color_rows = array('marked', 'replied');

View file

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

View file

@ -15,52 +15,9 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
/**
* Some Unicode characters encoded in UTF-8
*
* Preserved for compatibility
*/
define('UTF8_REPLACEMENT', "\xEF\xBF\xBD");
define('UTF8_MAX', "\xF4\x8F\xBF\xBF");
define('UTF8_FFFE', "\xEF\xBF\xBE");
define('UTF8_FFFF', "\xEF\xBF\xBF");
define('UTF8_SURROGATE_FIRST', "\xED\xA0\x80");
define('UTF8_SURROGATE_LAST', "\xED\xBF\xBF");
define('UTF8_HANGUL_FIRST', "\xEA\xB0\x80");
define('UTF8_HANGUL_LAST', "\xED\x9E\xA3");
define('UTF8_CJK_FIRST', "\xE4\xB8\x80");
define('UTF8_CJK_LAST', "\xE9\xBE\xBB");
define('UTF8_CJK_B_FIRST', "\xF0\xA0\x80\x80");
define('UTF8_CJK_B_LAST', "\xF0\xAA\x9B\x96");
// Unset global variables // Unset global variables
unset($GLOBALS['utf_jamo_index'], $GLOBALS['utf_jamo_type'], $GLOBALS['utf_nfc_qc'], $GLOBALS['utf_combining_class'], $GLOBALS['utf_canonical_comp'], $GLOBALS['utf_canonical_decomp'], $GLOBALS['utf_nfkc_qc'], $GLOBALS['utf_compatibility_decomp']); unset($GLOBALS['utf_jamo_index'], $GLOBALS['utf_jamo_type'], $GLOBALS['utf_nfc_qc'], $GLOBALS['utf_combining_class'], $GLOBALS['utf_canonical_comp'], $GLOBALS['utf_canonical_decomp'], $GLOBALS['utf_nfkc_qc'], $GLOBALS['utf_compatibility_decomp']);
// NFC_QC and NFKC_QC values
define('UNICODE_QC_MAYBE', 0);
define('UNICODE_QC_NO', 1);
// Contains all the ASCII characters appearing in UTF-8, sorted by frequency
define('UTF8_ASCII_RANGE', "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F");
// Contains all the tail bytes that can appear in the composition of a UTF-8 char
define('UTF8_TRAILING_BYTES', "\xA9\xA0\xA8\x80\xAA\x99\xA7\xBB\xAB\x89\x94\x82\xB4\xA2\xAE\x83\xB0\xB9\xB8\x93\xAF\xBC\xB3\x81\xA4\xB2\x9C\xA1\xB5\xBE\xBD\xBA\x98\xAD\xB1\x84\x95\xA6\xB6\x88\x8D\x90\xB7\xBF\x92\x85\xA5\x97\x8C\x86\xA3\x8E\x9F\x8F\x87\x91\x9D\xAC\x9E\x8B\x96\x9B\x8A\x9A");
// Constants used by the Hangul [de]composition algorithms
define('UNICODE_HANGUL_SBASE', 0xAC00);
define('UNICODE_HANGUL_LBASE', 0x1100);
define('UNICODE_HANGUL_VBASE', 0x1161);
define('UNICODE_HANGUL_TBASE', 0x11A7);
define('UNICODE_HANGUL_SCOUNT', 11172);
define('UNICODE_HANGUL_LCOUNT', 19);
define('UNICODE_HANGUL_VCOUNT', 21);
define('UNICODE_HANGUL_TCOUNT', 28);
define('UNICODE_HANGUL_NCOUNT', 588);
define('UNICODE_JAMO_L', 0);
define('UNICODE_JAMO_V', 1);
define('UNICODE_JAMO_T', 2);
/** /**
* Unicode normalization routines * Unicode normalization routines
* *
@ -68,6 +25,50 @@ define('UNICODE_JAMO_T', 2);
*/ */
class utf_normalizer class utf_normalizer
{ {
/**
* Some Unicode characters encoded in UTF-8
*
* Preserved for compatibility
*/
const UTF8_REPLACEMENT = "\xEF\xBF\xBD";
const UTF8_MAX = "\xF4\x8F\xBF\xBF";
const UTF8_FFFE = "\xEF\xBF\xBE";
const UTF8_FFFF = "\xEF\xBF\xBF";
const UTF8_SURROGATE_FIRST = "\xED\xA0\x80";
const UTF8_SURROGATE_LAST = "\xED\xBF\xBF";
const UTF8_HANGUL_FIRST = "\xEA\xB0\x80";
const UTF8_HANGUL_LAST = "\xED\x9E\xA3";
const UTF8_CJK_FIRST = "\xE4\xB8\x80";
const UTF8_CJK_LAST = "\xE9\xBE\xBB";
const UTF8_CJK_B_FIRST = "\xF0\xA0\x80\x80";
const UTF8_CJK_B_LAST = "\xF0\xAA\x9B\x96";
// NFC_QC and NFKC_QC values
const UNICODE_QC_MAYBE = 0;
const UNICODE_QC_NO = 1;
// Contains all the ASCII characters appearing in UTF-8, sorted by frequency
const UTF8_ASCII_RANGE = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
// Contains all the tail bytes that can appear in the composition of a UTF-8 char
const UTF8_TRAILING_BYTES = "\xA9\xA0\xA8\x80\xAA\x99\xA7\xBB\xAB\x89\x94\x82\xB4\xA2\xAE\x83\xB0\xB9\xB8\x93\xAF\xBC\xB3\x81\xA4\xB2\x9C\xA1\xB5\xBE\xBD\xBA\x98\xAD\xB1\x84\x95\xA6\xB6\x88\x8D\x90\xB7\xBF\x92\x85\xA5\x97\x8C\x86\xA3\x8E\x9F\x8F\x87\x91\x9D\xAC\x9E\x8B\x96\x9B\x8A\x9A";
// Constants used by the Hangul [de]composition algorithms
const UNICODE_HANGUL_SBASE = 0xAC00;
const UNICODE_HANGUL_LBASE = 0x1100;
const UNICODE_HANGUL_VBASE = 0x1161;
const UNICODE_HANGUL_TBASE = 0x11A7;
const UNICODE_HANGUL_SCOUNT = 11172;
const UNICODE_HANGUL_LCOUNT = 19;
const UNICODE_HANGUL_VCOUNT = 21;
const UNICODE_HANGUL_TCOUNT = 28;
const UNICODE_HANGUL_NCOUNT = 588;
const UNICODE_JAMO_L = 0;
const UNICODE_JAMO_V = 1;
const UNICODE_JAMO_T = 2;
/** /**
* Validate, cleanup and normalize a string * Validate, cleanup and normalize a string
* *
@ -77,9 +78,9 @@ class utf_normalizer
* @param string &$str The dirty string * @param string &$str The dirty string
* @return string The same string, all shiny and cleaned-up * @return string The same string, all shiny and cleaned-up
*/ */
function cleanup(&$str) public static function cleanup(&$str)
{ {
// The string below is the list of all autorized characters, sorted by frequency in latin text // The string below is the list of all authorized characters, sorted by frequency in latin text
$pos = strspn($str, "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x0D"); $pos = strspn($str, "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x0D");
$len = strlen($str); $len = strlen($str);
@ -110,7 +111,7 @@ class utf_normalizer
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
); );
$str = utf_normalizer::recompose($str, $pos, $len, $GLOBALS['utf_nfc_qc'], $GLOBALS['utf_canonical_decomp']); $str = self::recompose($str, $pos, $len, $GLOBALS['utf_nfc_qc'], $GLOBALS['utf_canonical_decomp']);
} }
/** /**
@ -119,9 +120,9 @@ class utf_normalizer
* @param string &$str Unchecked UTF string * @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form * @return string The string, validated and in normal form
*/ */
function nfc(&$str) public static function nfc(&$str)
{ {
$pos = strspn($str, UTF8_ASCII_RANGE); $pos = strspn($str, self::UTF8_ASCII_RANGE);
$len = strlen($str); $len = strlen($str);
if ($pos == $len) if ($pos == $len)
@ -142,7 +143,7 @@ class utf_normalizer
include($phpbb_root_path . 'includes/utf/data/utf_canonical_decomp.' . $phpEx); include($phpbb_root_path . 'includes/utf/data/utf_canonical_decomp.' . $phpEx);
} }
$str = utf_normalizer::recompose($str, $pos, $len, $GLOBALS['utf_nfc_qc'], $GLOBALS['utf_canonical_decomp']); $str = self::recompose($str, $pos, $len, $GLOBALS['utf_nfc_qc'], $GLOBALS['utf_canonical_decomp']);
} }
/** /**
@ -151,9 +152,9 @@ class utf_normalizer
* @param string &$str Unchecked UTF string * @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form * @return string The string, validated and in normal form
*/ */
function nfkc(&$str) public static function nfkc(&$str)
{ {
$pos = strspn($str, UTF8_ASCII_RANGE); $pos = strspn($str, self::UTF8_ASCII_RANGE);
$len = strlen($str); $len = strlen($str);
if ($pos == $len) if ($pos == $len)
@ -174,7 +175,7 @@ class utf_normalizer
include($phpbb_root_path . 'includes/utf/data/utf_compatibility_decomp.' . $phpEx); include($phpbb_root_path . 'includes/utf/data/utf_compatibility_decomp.' . $phpEx);
} }
$str = utf_normalizer::recompose($str, $pos, $len, $GLOBALS['utf_nfkc_qc'], $GLOBALS['utf_compatibility_decomp']); $str = self::recompose($str, $pos, $len, $GLOBALS['utf_nfkc_qc'], $GLOBALS['utf_compatibility_decomp']);
} }
/** /**
@ -183,9 +184,9 @@ class utf_normalizer
* @param string &$str Unchecked UTF string * @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form * @return string The string, validated and in normal form
*/ */
function nfd(&$str) public static function nfd(&$str)
{ {
$pos = strspn($str, UTF8_ASCII_RANGE); $pos = strspn($str, self::UTF8_ASCII_RANGE);
$len = strlen($str); $len = strlen($str);
if ($pos == $len) if ($pos == $len)
@ -200,7 +201,7 @@ class utf_normalizer
include($phpbb_root_path . 'includes/utf/data/utf_canonical_decomp.' . $phpEx); include($phpbb_root_path . 'includes/utf/data/utf_canonical_decomp.' . $phpEx);
} }
$str = utf_normalizer::decompose($str, $pos, $len, $GLOBALS['utf_canonical_decomp']); $str = self::decompose($str, $pos, $len, $GLOBALS['utf_canonical_decomp']);
} }
/** /**
@ -209,9 +210,9 @@ class utf_normalizer
* @param string &$str Unchecked UTF string * @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form * @return string The string, validated and in normal form
*/ */
function nfkd(&$str) public static function nfkd(&$str)
{ {
$pos = strspn($str, UTF8_ASCII_RANGE); $pos = strspn($str, self::UTF8_ASCII_RANGE);
$len = strlen($str); $len = strlen($str);
if ($pos == $len) if ($pos == $len)
@ -226,7 +227,7 @@ class utf_normalizer
include($phpbb_root_path . 'includes/utf/data/utf_compatibility_decomp.' . $phpEx); include($phpbb_root_path . 'includes/utf/data/utf_compatibility_decomp.' . $phpEx);
} }
$str = utf_normalizer::decompose($str, $pos, $len, $GLOBALS['utf_compatibility_decomp']); $str = self::decompose($str, $pos, $len, $GLOBALS['utf_compatibility_decomp']);
} }
@ -242,7 +243,7 @@ class utf_normalizer
* *
* @access private * @access private
*/ */
function recompose($str, $pos, $len, &$qc, &$decomp_map) private static function recompose($str, $pos, $len, &$qc, &$decomp_map)
{ {
global $utf_combining_class, $utf_canonical_comp, $utf_jamo_type, $utf_jamo_index; global $utf_combining_class, $utf_canonical_comp, $utf_jamo_type, $utf_jamo_index;
@ -363,8 +364,8 @@ class utf_normalizer
$trailing_bytes = $utf_len - 1; $trailing_bytes = $utf_len - 1;
} }
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . UTF8_REPLACEMENT; $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . self::UTF8_REPLACEMENT;
$pos += strspn($str, UTF8_TRAILING_BYTES, ++$pos, $trailing_bytes); $pos += strspn($str, self::UTF8_TRAILING_BYTES, ++$pos, $trailing_bytes);
$tmp_pos = $pos; $tmp_pos = $pos;
continue; continue;
@ -379,7 +380,7 @@ class utf_normalizer
if ($utf_char >= "\xED\xA0\x80") if ($utf_char >= "\xED\xA0\x80")
{ {
// Surrogates (U+D800..U+DFFF) are not allowed in UTF-8 (UTF sequence 0xEDA080..0xEDBFBF) // Surrogates (U+D800..U+DFFF) are not allowed in UTF-8 (UTF sequence 0xEDA080..0xEDBFBF)
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . UTF8_REPLACEMENT; $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . self::UTF8_REPLACEMENT;
$pos += $utf_len; $pos += $utf_len;
$tmp_pos = $pos; $tmp_pos = $pos;
continue 2; continue 2;
@ -391,7 +392,7 @@ class utf_normalizer
if ($utf_char == "\xEF\xBF\xBE" || $utf_char == "\xEF\xBF\xBF") if ($utf_char == "\xEF\xBF\xBE" || $utf_char == "\xEF\xBF\xBF")
{ {
// U+FFFE and U+FFFF are explicitly disallowed (UTF sequence 0xEFBFBE..0xEFBFBF) // U+FFFE and U+FFFF are explicitly disallowed (UTF sequence 0xEFBFBE..0xEFBFBF)
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . UTF8_REPLACEMENT; $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . self::UTF8_REPLACEMENT;
$pos += $utf_len; $pos += $utf_len;
$tmp_pos = $pos; $tmp_pos = $pos;
continue 2; continue 2;
@ -403,7 +404,7 @@ class utf_normalizer
if ($utf_char <= "\xC1\xBF") if ($utf_char <= "\xC1\xBF")
{ {
// Overlong sequence: Unicode char U+0000..U+007F encoded as a double-byte UTF char // Overlong sequence: Unicode char U+0000..U+007F encoded as a double-byte UTF char
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . UTF8_REPLACEMENT; $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . self::UTF8_REPLACEMENT;
$pos += $utf_len; $pos += $utf_len;
$tmp_pos = $pos; $tmp_pos = $pos;
continue 2; continue 2;
@ -414,7 +415,7 @@ class utf_normalizer
if ($utf_char <= "\xE0\x9F\xBF") if ($utf_char <= "\xE0\x9F\xBF")
{ {
// Unicode char U+0000..U+07FF encoded in 3 bytes // Unicode char U+0000..U+07FF encoded in 3 bytes
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . UTF8_REPLACEMENT; $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . self::UTF8_REPLACEMENT;
$pos += $utf_len; $pos += $utf_len;
$tmp_pos = $pos; $tmp_pos = $pos;
continue 2; continue 2;
@ -425,7 +426,7 @@ class utf_normalizer
if ($utf_char <= "\xF0\x8F\xBF\xBF") if ($utf_char <= "\xF0\x8F\xBF\xBF")
{ {
// Unicode char U+0000..U+FFFF encoded in 4 bytes // Unicode char U+0000..U+FFFF encoded in 4 bytes
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . UTF8_REPLACEMENT; $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . self::UTF8_REPLACEMENT;
$pos += $utf_len; $pos += $utf_len;
$tmp_pos = $pos; $tmp_pos = $pos;
continue 2; continue 2;
@ -454,8 +455,8 @@ class utf_normalizer
$trailing_bytes = 5; $trailing_bytes = 5;
} }
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . UTF8_REPLACEMENT; $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . self::UTF8_REPLACEMENT;
$pos += strspn($str, UTF8_TRAILING_BYTES, ++$pos, $trailing_bytes); $pos += strspn($str, self::UTF8_TRAILING_BYTES, ++$pos, $trailing_bytes);
$tmp_pos = $pos; $tmp_pos = $pos;
continue 2; continue 2;
} }
@ -472,8 +473,8 @@ class utf_normalizer
{ {
// A trailing byte came out of nowhere, we will advance the cursor and treat the this byte and all following trailing bytes as if // A trailing byte came out of nowhere, we will advance the cursor and treat the this byte and all following trailing bytes as if
// each of them was a Unicode replacement char // each of them was a Unicode replacement char
$spn = strspn($str, UTF8_TRAILING_BYTES, $pos); $spn = strspn($str, self::UTF8_TRAILING_BYTES, $pos);
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . str_repeat(UTF8_REPLACEMENT, $spn); $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . str_repeat(self::UTF8_REPLACEMENT, $spn);
$pos += $spn; $pos += $spn;
$tmp_pos = $pos; $tmp_pos = $pos;
@ -533,7 +534,7 @@ class utf_normalizer
// Check out the combining class of the first character of the UTF sequence // Check out the combining class of the first character of the UTF sequence
$k = 0; $k = 0;
if (isset($utf_combining_class[$utf_seq[0]]) || $qc[$utf_char] == UNICODE_QC_MAYBE) if (isset($utf_combining_class[$utf_seq[0]]) || $qc[$utf_char] == self::UNICODE_QC_MAYBE)
{ {
// Not a starter, inspect previous characters // Not a starter, inspect previous characters
// The last 8 characters are kept in a buffer so that we don't have to capture them everytime. // The last 8 characters are kept in a buffer so that we don't have to capture them everytime.
@ -762,12 +763,11 @@ class utf_normalizer
if (!$k && $k_max == 1) if (!$k && $k_max == 1)
{ {
// There is only one char in the UTF sequence, add it then jump to the next iteration of main loop // There is only one char in the UTF sequence, add it then jump to the next iteration of main loop
// Note: the two commented lines below can be enabled under PHP5 for a very small performance gain in most cases if (substr_compare($str, $utf_seq[0], $lpos, $pos - $lpos))
// if (substr_compare($str, $utf_seq[0], $lpos, $pos - $lpos)) {
// {
$tmp .= substr($str, $tmp_pos, $lpos - $tmp_pos) . $utf_seq[0]; $tmp .= substr($str, $tmp_pos, $lpos - $tmp_pos) . $utf_seq[0];
$tmp_pos = $pos; $tmp_pos = $pos;
// } }
continue; continue;
} }
@ -809,10 +809,10 @@ class utf_normalizer
else if (isset($utf_jamo_type[$utf_char])) else if (isset($utf_jamo_type[$utf_char]))
{ {
// Current char is a composable jamo // Current char is a composable jamo
if (isset($utf_jamo_type[$starter]) && $utf_jamo_type[$starter] == UNICODE_JAMO_L && $utf_jamo_type[$utf_char] == UNICODE_JAMO_V) if (isset($utf_jamo_type[$starter]) && $utf_jamo_type[$starter] == self::UNICODE_JAMO_L && $utf_jamo_type[$utf_char] == self::UNICODE_JAMO_V)
{ {
// We have a L jamo followed by a V jamo, we are going to prefetch the next char to see if it's a T jamo // We have a L jamo followed by a V jamo, we are going to prefetch the next char to see if it's a T jamo
if (isset($utf_jamo_type[$utf_seq[$k]]) && $utf_jamo_type[$utf_seq[$k]] == UNICODE_JAMO_T) if (isset($utf_jamo_type[$utf_seq[$k]]) && $utf_jamo_type[$utf_seq[$k]] == self::UNICODE_JAMO_T)
{ {
// L+V+T jamos, combine to a LVT Hangul syllable ($k is incremented) // L+V+T jamos, combine to a LVT Hangul syllable ($k is incremented)
$cp = $utf_jamo_index[$starter] + $utf_jamo_index[$utf_char] + $utf_jamo_index[$utf_seq[$k]]; $cp = $utf_jamo_index[$starter] + $utf_jamo_index[$utf_char] + $utf_jamo_index[$utf_seq[$k]];
@ -901,7 +901,7 @@ class utf_normalizer
{ {
if ($str[$pos] < "\x80") if ($str[$pos] < "\x80")
{ {
$pos += strspn($str, UTF8_ASCII_RANGE, ++$pos); $pos += strspn($str, self::UTF8_ASCII_RANGE, ++$pos);
$buffer[++$i & 7] = $str[$pos - 1]; $buffer[++$i & 7] = $str[$pos - 1];
} }
else else
@ -944,7 +944,7 @@ class utf_normalizer
* *
* @access private * @access private
*/ */
function decompose($str, $pos, $len, &$decomp_map) private static function decompose($str, $pos, $len, &$decomp_map)
{ {
global $utf_combining_class; global $utf_combining_class;
@ -1011,7 +1011,7 @@ class utf_normalizer
{ {
// A trailing byte came out of nowhere, we will treat it and all following trailing bytes as if each of them was a Unicode // A trailing byte came out of nowhere, we will treat it and all following trailing bytes as if each of them was a Unicode
// replacement char and we will advance the cursor // replacement char and we will advance the cursor
$spn = strspn($str, UTF8_TRAILING_BYTES, $pos); $spn = strspn($str, self::UTF8_TRAILING_BYTES, $pos);
if ($dump) if ($dump)
{ {
@ -1031,12 +1031,12 @@ class utf_normalizer
} }
} }
$tmp .= str_repeat(UTF8_REPLACEMENT, $spn); $tmp .= str_repeat(self::UTF8_REPLACEMENT, $spn);
$dump = $sort = 0; $dump = $sort = 0;
} }
else else
{ {
$tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . str_repeat(UTF8_REPLACEMENT, $spn); $tmp .= substr($str, $tmp_pos, $pos - $tmp_pos) . str_repeat(self::UTF8_REPLACEMENT, $spn);
} }
$pos += $spn; $pos += $spn;
@ -1177,7 +1177,7 @@ class utf_normalizer
else else
{ {
// Non-decomposable starter, check out if it's a Hangul syllable // Non-decomposable starter, check out if it's a Hangul syllable
if ($utf_char < UTF8_HANGUL_FIRST || $utf_char > UTF8_HANGUL_LAST) if ($utf_char < self::UTF8_HANGUL_FIRST || $utf_char > self::UTF8_HANGUL_LAST)
{ {
// Nope, regular UTF char, check that we have the correct number of trailing bytes // Nope, regular UTF char, check that we have the correct number of trailing bytes
if (($utf_char & $utf_validation_mask[$utf_len]) != $utf_validation_check[$utf_len]) if (($utf_char & $utf_validation_mask[$utf_len]) != $utf_validation_check[$utf_len])
@ -1202,8 +1202,8 @@ class utf_normalizer
// Add a replacement char then another replacement char for every trailing byte. // Add a replacement char then another replacement char for every trailing byte.
// //
// @todo I'm not entirely sure that's how we're supposed to mark invalidated byte sequences, check this // @todo I'm not entirely sure that's how we're supposed to mark invalidated byte sequences, check this
$spn = strspn($str, UTF8_TRAILING_BYTES, ++$pos); $spn = strspn($str, self::UTF8_TRAILING_BYTES, ++$pos);
$tmp .= str_repeat(UTF8_REPLACEMENT, $spn + 1); $tmp .= str_repeat(self::UTF8_REPLACEMENT, $spn + 1);
$dump = $sort = 0; $dump = $sort = 0;
@ -1234,7 +1234,7 @@ class utf_normalizer
$utf_sort = array(); $utf_sort = array();
} }
$tmp .= UTF8_REPLACEMENT; $tmp .= self::UTF8_REPLACEMENT;
$dump = $sort = 0; $dump = $sort = 0;
$tmp_pos = $starter_pos = $pos; $tmp_pos = $starter_pos = $pos;
@ -1260,7 +1260,7 @@ class utf_normalizer
$utf_sort = array(); $utf_sort = array();
} }
$tmp .= UTF8_REPLACEMENT; $tmp .= self::UTF8_REPLACEMENT;
$dump = $sort = 0; $dump = $sort = 0;
$tmp_pos = $starter_pos = $pos; $tmp_pos = $starter_pos = $pos;
@ -1286,7 +1286,7 @@ class utf_normalizer
$utf_sort = array(); $utf_sort = array();
} }
$tmp .= UTF8_REPLACEMENT; $tmp .= self::UTF8_REPLACEMENT;
$dump = $sort = 0; $dump = $sort = 0;
$tmp_pos = $starter_pos = $pos; $tmp_pos = $starter_pos = $pos;
@ -1311,7 +1311,7 @@ class utf_normalizer
$utf_sort = array(); $utf_sort = array();
} }
$tmp .= UTF8_REPLACEMENT; $tmp .= self::UTF8_REPLACEMENT;
$dump = $sort = 0; $dump = $sort = 0;
$tmp_pos = $starter_pos = $pos; $tmp_pos = $starter_pos = $pos;
@ -1336,7 +1336,7 @@ class utf_normalizer
$utf_sort = array(); $utf_sort = array();
} }
$tmp .= UTF8_REPLACEMENT; $tmp .= self::UTF8_REPLACEMENT;
$dump = $sort = 0; $dump = $sort = 0;
$tmp_pos = $starter_pos = $pos; $tmp_pos = $starter_pos = $pos;
@ -1361,7 +1361,7 @@ class utf_normalizer
$utf_sort = array(); $utf_sort = array();
} }
$tmp .= UTF8_REPLACEMENT; $tmp .= self::UTF8_REPLACEMENT;
$dump = $sort = 0; $dump = $sort = 0;
$tmp_pos = $starter_pos = $pos; $tmp_pos = $starter_pos = $pos;
@ -1374,12 +1374,12 @@ class utf_normalizer
else else
{ {
// Hangul syllable // Hangul syllable
$idx = (((ord($utf_char[0]) & 0x0F) << 12) | ((ord($utf_char[1]) & 0x3F) << 6) | (ord($utf_char[2]) & 0x3F)) - UNICODE_HANGUL_SBASE; $idx = (((ord($utf_char[0]) & 0x0F) << 12) | ((ord($utf_char[1]) & 0x3F) << 6) | (ord($utf_char[2]) & 0x3F)) - self::UNICODE_HANGUL_SBASE;
// LIndex can only range from 0 to 18, therefore it cannot influence the first two bytes of the L Jamo, which allows us to hardcode them (based on LBase). // LIndex can only range from 0 to 18, therefore it cannot influence the first two bytes of the L Jamo, which allows us to hardcode them (based on LBase).
// //
// The same goes for VIndex, but for TIndex there's a catch: the value of the third byte could exceed 0xBF and we would have to increment the second byte // The same goes for VIndex, but for TIndex there's a catch: the value of the third byte could exceed 0xBF and we would have to increment the second byte
if ($t_index = $idx % UNICODE_HANGUL_TCOUNT) if ($t_index = $idx % self::UNICODE_HANGUL_TCOUNT)
{ {
if ($t_index < 25) if ($t_index < 25)
{ {
@ -1397,8 +1397,8 @@ class utf_normalizer
$utf_char = "\xE1\x84\x00\xE1\x85\x00"; $utf_char = "\xE1\x84\x00\xE1\x85\x00";
} }
$utf_char[2] = chr(0x80 + (int) ($idx / UNICODE_HANGUL_NCOUNT)); $utf_char[2] = chr(0x80 + (int) ($idx / self::UNICODE_HANGUL_NCOUNT));
$utf_char[5] = chr(0xA1 + (int) (($idx % UNICODE_HANGUL_NCOUNT) / UNICODE_HANGUL_TCOUNT)); $utf_char[5] = chr(0xA1 + (int) (($idx % self::UNICODE_HANGUL_NCOUNT) / self::UNICODE_HANGUL_TCOUNT));
// Just like other decompositions, the resulting Jamos must be dumped to the tmp string // Just like other decompositions, the resulting Jamos must be dumped to the tmp string
$dump = 1; $dump = 1;
@ -1458,11 +1458,11 @@ class utf_normalizer
$dump = $sort = 0; $dump = $sort = 0;
$tmp_pos = ++$pos; $tmp_pos = ++$pos;
$pos += strspn($str, UTF8_ASCII_RANGE, $pos); $pos += strspn($str, self::UTF8_ASCII_RANGE, $pos);
} }
else else
{ {
$pos += strspn($str, UTF8_ASCII_RANGE, ++$pos); $pos += strspn($str, self::UTF8_ASCII_RANGE, ++$pos);
} }
$last_cc = 0; $last_cc = 0;

View file

@ -687,231 +687,6 @@ function utf8_ucfirst($str)
} }
} }
/**
* Recode a string to UTF-8
*
* If the encoding is not supported, the string is returned as-is
*
* @param string $string Original string
* @param string $encoding Original encoding (lowered)
* @return string The string, encoded in UTF-8
*/
function utf8_recode($string, $encoding)
{
$encoding = strtolower($encoding);
if ($encoding == 'utf-8' || !is_string($string) || empty($string))
{
return $string;
}
// we force iso-8859-1 to be cp1252
if ($encoding == 'iso-8859-1')
{
$encoding = 'cp1252';
}
// convert iso-8859-8-i to iso-8859-8
else if ($encoding == 'iso-8859-8-i')
{
$encoding = 'iso-8859-8';
$string = hebrev($string);
}
// First, try iconv()
if (function_exists('iconv'))
{
$ret = @iconv($encoding, 'utf-8', $string);
if (!empty($ret))
{
return $ret;
}
}
// Try the mb_string extension
if (function_exists('mb_convert_encoding'))
{
// mbstring is nasty on PHP4, we must make *sure* that we send a good encoding
switch ($encoding)
{
case 'iso-8859-1':
case 'iso-8859-2':
case 'iso-8859-4':
case 'iso-8859-7':
case 'iso-8859-9':
case 'iso-8859-15':
case 'windows-1251':
case 'windows-1252':
case 'cp1252':
case 'shift_jis':
case 'euc-kr':
case 'big5':
case 'gb2312':
$ret = @mb_convert_encoding($string, 'utf-8', $encoding);
if (!empty($ret))
{
return $ret;
}
}
}
// Try the recode extension
if (function_exists('recode_string'))
{
$ret = @recode_string($encoding . '..utf-8', $string);
if (!empty($ret))
{
return $ret;
}
}
// If nothing works, check if we have a custom transcoder available
if (!preg_match('#^[a-z0-9_ \\-]+$#', $encoding))
{
// Make sure the encoding name is alphanumeric, we don't want it to be abused into loading arbitrary files
trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR);
}
global $phpbb_root_path, $phpEx;
// iso-8859-* character encoding
if (preg_match('/iso[_ -]?8859[_ -]?(\\d+)/', $encoding, $array))
{
switch ($array[1])
{
case '1':
case '2':
case '4':
case '7':
case '8':
case '9':
case '15':
if (!function_exists('iso_8859_' . $array[1]))
{
if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx))
{
trigger_error('Basic reencoder file is missing', E_USER_ERROR);
}
include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx);
}
return call_user_func('iso_8859_' . $array[1], $string);
break;
default:
trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR);
break;
}
}
// CP/WIN character encoding
if (preg_match('/(?:cp|windows)[_\- ]?(\\d+)/', $encoding, $array))
{
switch ($array[1])
{
case '932':
break;
case '1250':
case '1251':
case '1252':
case '1254':
case '1255':
case '1256':
case '1257':
case '874':
if (!function_exists('cp' . $array[1]))
{
if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx))
{
trigger_error('Basic reencoder file is missing', E_USER_ERROR);
}
include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx);
}
return call_user_func('cp' . $array[1], $string);
break;
default:
trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR);
break;
}
}
// TIS-620
if (preg_match('/tis[_ -]?620/', $encoding))
{
if (!function_exists('tis_620'))
{
if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx))
{
trigger_error('Basic reencoder file is missing', E_USER_ERROR);
}
include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx);
}
return tis_620($string);
}
// SJIS
if (preg_match('/sjis(?:[_ -]?win)?|(?:cp|ibm)[_ -]?932|shift[_ -]?jis/', $encoding))
{
if (!function_exists('sjis'))
{
if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx))
{
trigger_error('CJK reencoder file is missing', E_USER_ERROR);
}
include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx);
}
return sjis($string);
}
// EUC_KR
if (preg_match('/euc[_ -]?kr/', $encoding))
{
if (!function_exists('euc_kr'))
{
if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx))
{
trigger_error('CJK reencoder file is missing', E_USER_ERROR);
}
include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx);
}
return euc_kr($string);
}
// BIG-5
if (preg_match('/big[_ -]?5/', $encoding))
{
if (!function_exists('big5'))
{
if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx))
{
trigger_error('CJK reencoder file is missing', E_USER_ERROR);
}
include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx);
}
return big5($string);
}
// GB2312
if (preg_match('/gb[_ -]?2312/', $encoding))
{
if (!function_exists('gb2312'))
{
if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx))
{
trigger_error('CJK reencoder file is missing', E_USER_ERROR);
}
include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx);
}
return gb2312($string);
}
// Trigger an error?! Fow now just give bad data :-(
trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR);
//return $string; // use utf_normalizer::cleanup() ?
}
/** /**
* Replace all UTF-8 chars that are not in ASCII with their NCR * Replace all UTF-8 chars that are not in ASCII with their NCR
* *
@ -1827,7 +1602,7 @@ function utf8_clean_string($text)
$text = utf8_case_fold_nfkc($text); $text = utf8_case_fold_nfkc($text);
$text = strtr($text, $homographs); $text = strtr($text, $homographs);
// Other control characters // Other control characters
$text = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $text); $text = preg_replace('#[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+#', '', $text);
// we need to reduce multiple spaces to a single one // we need to reduce multiple spaces to a single one
$text = preg_replace('# {2,}#', ' ', $text); $text = preg_replace('# {2,}#', ' ', $text);
@ -1861,7 +1636,7 @@ function utf8_convert_message($message)
} }
// else we need to convert some part of the message // else we need to convert some part of the message
return utf8_htmlspecialchars(utf8_recode($message, 'ISO-8859-1')); return utf8_htmlspecialchars(utf8_encode($message));
} }
/** /**

File diff suppressed because one or more lines are too long

View file

@ -1,196 +0,0 @@
<?php
/**
*
* @package install
* @version $Id$
* @copyright (c) 2007 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* A wrapper function for the normalizer which takes care of including the class if required and modifies the passed strings
* to be in NFC (Normalization Form Composition).
*
* @param mixed $strings a string or an array of strings to normalize
* @return mixed the normalized content, preserving array keys if array given.
*/
function utf8_new_normalize_nfc($strings)
{
if (empty($strings))
{
return $strings;
}
if (!is_array($strings))
{
utf_new_normalizer::nfc($strings);
}
else if (is_array($strings))
{
foreach ($strings as $key => $string)
{
if (is_array($string))
{
foreach ($string as $_key => $_string)
{
utf_new_normalizer::nfc($strings[$key][$_key]);
}
}
else
{
utf_new_normalizer::nfc($strings[$key]);
}
}
}
return $strings;
}
class utf_new_normalizer
{
/**
* Validate, cleanup and normalize a string
*
* The ultimate convenience function! Clean up invalid UTF-8 sequences,
* and convert to Normal Form C, canonical composition.
*
* @param string &$str The dirty string
* @return string The same string, all shiny and cleaned-up
*/
function cleanup(&$str)
{
// The string below is the list of all autorized characters, sorted by frequency in latin text
$pos = strspn($str, "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x0D");
$len = strlen($str);
if ($pos == $len)
{
// ASCII strings with no special chars return immediately
return;
}
// Note: we do not check for $GLOBALS['utf_canonical_decomp']. It is assumed they are always loaded together
if (!isset($GLOBALS['utf_nfc_qc']))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/utf/data/utf_nfc_qc.' . $phpEx);
}
if (!isset($GLOBALS['utf_canonical_decomp']))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/utf/data/utf_canonical_decomp.' . $phpEx);
}
// Replace any byte in the range 0x00..0x1F, except for \r, \n and \t
// We replace those characters with a 0xFF byte, which is illegal in UTF-8 and will in turn be replaced with a UTF replacement char
$str = strtr(
$str,
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F",
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
);
$str = utf_new_normalizer::recompose($str, $pos, $len, $GLOBALS['utf_nfc_qc'], $GLOBALS['utf_canonical_decomp']);
}
/**
* Validate and normalize a UTF string to NFC
*
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
function nfc(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
if ($pos == $len)
{
// ASCII strings return immediately
return;
}
if (!isset($GLOBALS['utf_nfc_qc']))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/utf/data/utf_nfc_qc.' . $phpEx);
}
if (!isset($GLOBALS['utf_canonical_decomp']))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/utf/data/utf_canonical_decomp.' . $phpEx);
}
$str = utf_new_normalizer::recompose($str, $pos, $len, $GLOBALS['utf_nfc_qc'], $GLOBALS['utf_canonical_decomp']);
}
/**
* Validate and normalize a UTF string to NFKC
*
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
function nfkc(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
if ($pos == $len)
{
// ASCII strings return immediately
return;
}
if (!isset($GLOBALS['utf_nfkc_qc']))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/utf/data/utf_nfkc_qc.' . $phpEx);
}
if (!isset($GLOBALS['utf_compatibility_decomp']))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/utf/data/utf_compatibility_decomp.' . $phpEx);
}
$str = utf_new_normalizer::recompose($str, $pos, $len, $GLOBALS['utf_nfkc_qc'], $GLOBALS['utf_compatibility_decomp']);
}
/**
* Recompose a UTF string
*
* @param string $str Unchecked UTF string
* @param integer $pos Position of the first UTF char (in bytes)
* @param integer $len Length of the string (in bytes)
* @param array &$qc Quick-check array, passed by reference but never modified
* @param array &$decomp_map Decomposition mapping, passed by reference but never modified
* @return string The string, validated and recomposed
*
* @access private
*/
function recompose($str, $pos, $len, &$qc, &$decomp_map)
{
global $utf_canonical_comp;
// Load the canonical composition table
if (!isset($utf_canonical_comp))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/utf/data/utf_canonical_comp.' . $phpEx);
}
return utf_normalizer::recompose($str, $pos, $len, $qc, $decomp_map);
}
}
?>

View file

@ -83,7 +83,7 @@ else
} }
$user = new user(); $user = new user();
$cache = new cache(); $cache = new acm();
$db = new $sql_db(); $db = new $sql_db();
// Add own hook handler, if present. :o // Add own hook handler, if present. :o
@ -92,7 +92,7 @@ if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
foreach ($cache->obtain_hooks() as $hook) foreach (cache::obtain_hooks() as $hook)
{ {
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
} }
@ -337,142 +337,6 @@ $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP');
// Only an example, but also commented out // Only an example, but also commented out
$database_update_info = array( $database_update_info = array(
// Changes from 3.0.RC2 to the next version
'3.0.RC2' => array(
// Change the following columns
'change_columns' => array(
BANLIST_TABLE => array(
'ban_reason' => array('VCHAR_UNI', ''),
'ban_give_reason' => array('VCHAR_UNI', ''),
),
),
),
// Changes from 3.0.RC3 to the next version
'3.0.RC3' => array(
// Change the following columns
'change_columns' => array(
BANLIST_TABLE => array(
'ban_reason' => array('VCHAR_UNI', ''),
'ban_give_reason' => array('VCHAR_UNI', ''),
),
STYLES_TABLE => array(
'style_id' => array('USINT', 0),
'template_id' => array('USINT', 0),
'theme_id' => array('USINT', 0),
'imageset_id' => array('USINT', 0),
),
STYLES_TEMPLATE_TABLE => array(
'template_id' => array('USINT', 0),
),
STYLES_TEMPLATE_DATA_TABLE => array(
'template_id' => array('USINT', 0),
),
STYLES_THEME_TABLE => array(
'theme_id' => array('USINT', 0),
),
STYLES_IMAGESET_TABLE => array(
'imageset_id' => array('USINT', 0),
),
STYLES_IMAGESET_DATA_TABLE => array(
'imageset_id' => array('USINT', 0),
),
USERS_TABLE => array(
'user_style' => array('USINT', 0),
),
FORUMS_TABLE => array(
'forum_style' => array('USINT', 0),
),
GROUPS_TABLE => array(
'group_avatar_type' => array('TINT:2', 0),
'group_avatar_width' => array('USINT', 0),
'group_avatar_height' => array('USINT', 0),
),
),
),
// Changes from 3.0.RC4 to the next version
'3.0.RC4' => array(
// Change the following columns
'change_columns' => array(
STYLES_TABLE => array(
'style_id' => array('USINT', NULL, 'auto_increment'),
'template_id' => array('USINT', 0),
'theme_id' => array('USINT', 0),
'imageset_id' => array('USINT', 0),
),
STYLES_TEMPLATE_TABLE => array(
'template_id' => array('USINT', NULL, 'auto_increment'),
),
STYLES_TEMPLATE_DATA_TABLE => array(
'template_id' => array('USINT', 0),
),
STYLES_THEME_TABLE => array(
'theme_id' => array('USINT', NULL, 'auto_increment'),
),
STYLES_IMAGESET_TABLE => array(
'imageset_id' => array('USINT', NULL, 'auto_increment'),
),
STYLES_IMAGESET_DATA_TABLE => array(
'imageset_id' => array('USINT', 0),
),
USERS_TABLE => array(
'user_style' => array('USINT', 0),
),
FORUMS_TABLE => array(
'forum_style' => array('USINT', 0),
),
GROUPS_TABLE => array(
'group_avatar_width' => array('USINT', 0),
'group_avatar_height' => array('USINT', 0),
),
),
),
// Changes from 3.0.RC5 to the next version
'3.0.RC5' => array(
// Add the following columns
'add_columns' => array(
USERS_TABLE => array(
'user_form_salt' => array('VCHAR_UNI:32', ''),
),
),
// Change the following columns
'change_columns' => array(
POSTS_TABLE => array(
'bbcode_uid' => array('VCHAR:8', ''),
),
PRIVMSGS_TABLE => array(
'bbcode_uid' => array('VCHAR:8', ''),
),
USERS_TABLE => array(
'user_sig_bbcode_uid' => array('VCHAR:8', ''),
),
),
),
// Changes from 3.0.RC6 to the next version
'3.0.RC6' => array(
// Change the following columns
'change_columns' => array(
FORUMS_TABLE => array(
'forum_desc_uid' => array('VCHAR:8', ''),
'forum_rules_uid' => array('VCHAR:8', ''),
),
GROUPS_TABLE => array(
'group_desc_uid' => array('VCHAR:8', ''),
),
USERS_TABLE => array(
'user_newpasswd' => array('VCHAR_UNI:40', ''),
),
),
),
// Changes from 3.0.RC8 to the next version
'3.0.RC8' => array(
// Change the following columns
'change_columns' => array(
USERS_TABLE => array(
'user_new_privmsg' => array('INT:4', 0),
'user_unread_privmsg' => array('INT:4', 0),
),
),
),
); );
// Determine mapping database type // Determine mapping database type
@ -581,440 +445,6 @@ else
// Checks/Operations that have to be completed prior to starting the update itself // Checks/Operations that have to be completed prior to starting the update itself
$exit = false; $exit = false;
if (version_compare($current_version, '3.0.RC8', '<='))
{
// Define missing language entries...
if (!isset($lang['CLEANING_USERNAMES']))
{
$lang = array_merge($lang, array(
'CLEANING_USERNAMES' => 'Cleaning usernames',
'LONG_SCRIPT_EXECUTION' => 'Please note that this can take a while... Please do not stop the script.',
'CHANGE_CLEAN_NAMES' => 'The method used to make sure a username is not used by multiple users has been changed. There are some users which have the same name when compared with the new method. You have to delete or rename these users to make sure that each name is only used by one user before you can proceed.',
'USER_ACTIVE' => 'Active user',
'USER_INACTIVE' => 'Inactive user',
'BOT' => 'Spider/Robot',
'UPDATE_REQUIRES_FILE' => 'The updater requires that the following file is present: %s',
'DELETE_USER_REMOVE' => 'Delete user and remove posts',
'DELETE_USER_RETAIN' => 'Delete user but keep posts',
'EDIT_USERNAME' => 'Edit username',
'KEEP_OLD_NAME' => 'Keep username',
'NEW_USERNAME' => 'New username',
));
}
?>
<br /><br />
<h1><?php echo $lang['CLEANING_USERNAMES']; ?></h1>
<br />
<?php
flush();
$submit = (isset($_POST['resolve_conflicts'])) ? true : false;
$modify_users = request_var('modify_users', array(0 => ''));
$new_usernames = request_var('new_usernames', array(0 => ''), true);
if (!class_exists('utf_new_normalizer'))
{
if (!file_exists($phpbb_root_path . 'install/data/new_normalizer.' . $phpEx))
{
global $lang;
trigger_error(sprintf($lang['UPDATE_REQUIRES_FILE'], $phpbb_root_path . 'install/data/new_normalizer.' . $phpEx), E_USER_ERROR);
}
include($phpbb_root_path . 'install/data/new_normalizer.' . $phpEx);
}
// the admin decided to change some usernames
if (sizeof($modify_users) && $submit)
{
$sql = 'SELECT user_id, username, user_type
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_keys($modify_users));
$result = $db->sql_query($sql);
$users = 0;
while ($row = $db->sql_fetchrow($result))
{
$users++;
$user_id = (int) $row['user_id'];
if (isset($modify_users[$user_id]))
{
$row['action'] = $modify_users[$user_id];
$modify_users[$user_id] = $row;
}
}
$db->sql_freeresult($result);
// only if all ids really existed
if (sizeof($modify_users) == $users)
{
$user->data['user_id'] = ANONYMOUS;
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
foreach ($modify_users as $user_id => $row)
{
switch ($row['action'])
{
case 'edit':
if (isset($new_usernames[$user_id]))
{
$data = array('username' => utf8_new_normalize_nfc($new_usernames[$user_id]));
// Need to update config, forum, topic, posting, messages, etc.
if ($data['username'] != $row['username'])
{
$check_ary = array('username' => array(
array('string', false, $config['min_name_chars'], $config['max_name_chars']),
array('username'),
));
// need a little trick for this to work properly
$user->data['username_clean'] = utf8_clean_string($data['username']) . 'a';
$errors = validate_data($data, $check_ary);
if ($errors)
{
include($phpbb_root_path . 'language/' . $language . '/ucp.' . $phpEx);
echo '<div class="errorbox">';
foreach ($errors as $error)
{
echo '<p>' . $lang[$error] . '</p>';
}
echo '</div>';
}
if (!$errors)
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', array(
'username' => $data['username'],
'username_clean' => utf8_clean_string($data['username'])
)) . '
WHERE user_id = ' . $user_id;
$db->sql_query($sql);
add_log('user', $user_id, 'LOG_USER_UPDATE_NAME', $row['username'], $data['username']);
user_update_name($row['username'], $data['username']);
}
}
}
break;
case 'delete_retain':
case 'delete_remove':
if ($user_id != ANONYMOUS && $row['user_type'] != USER_FOUNDER)
{
user_delete(substr($row['action'], 7), $user_id, $row['username']);
add_log('admin', 'LOG_USER_DELETED', $row['username']);
}
break;
}
}
}
}
?>
<p><?php echo $lang['LONG_SCRIPT_EXECUTION']; ?></p>
<p><?php echo $lang['PROGRESS']; ?> :: <strong>
<?php
flush();
// after RC3 a different utf8_clean_string function is used, this requires that
// the unique column username_clean is recalculated, during this recalculation
// duplicates might be created. Since the column has to be unique such usernames
// must not exist. We need identify them and let the admin decide what to do
// about them.
// After RC8 this was changed again, but this time only usernames containing spaces
// are affected.
$sql_where = (version_compare($current_version, '3.0.RC4', '<=')) ? '' : "WHERE username_clean LIKE '% %'";
$sql = 'SELECT user_id, username, username_clean
FROM ' . USERS_TABLE . "
$sql_where
ORDER BY user_id ASC";
$result = $db->sql_query($sql);
$colliding_users = $found_names = array();
$echos = 0;
while ($row = $db->sql_fetchrow($result))
{
// Calculate the new clean name. If it differs from the old one we need
// to make sure there is no collision
$clean_name = utf8_new_clean_string($row['username']);
if ($clean_name != $row['username_clean'])
{
// Check if there would be a collission, if not put it up for changing
$user_id = (int) $row['user_id'];
// If this clean name was not the result of another user already ...
if (!isset($found_names[$clean_name]))
{
// then we need to figure out whether there are any other users
// who already had this clean name with the old version
$sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . '
WHERE username_clean = \'' . $db->sql_escape($clean_name) . '\'';
$result2 = $db->sql_query($sql);
$user_ids = array($user_id);
while ($row = $db->sql_fetchrow($result2))
{
// For not trimmed entries this could happen, yes. ;)
if ($row['user_id'] == $user_id)
{
continue;
}
// Make sure this clean name will still be the same with the
// new function. If it is, then we have to add it to the list
// of user ids for this clean name
if (utf8_new_clean_string($row['username']) == $clean_name)
{
$user_ids[] = (int) $row['user_id'];
}
}
$db->sql_freeresult($result2);
// if we already found a collision save it
if (sizeof($user_ids) > 1)
{
$colliding_users[$clean_name] = $user_ids;
$found_names[$clean_name] = true;
}
else
{
// otherwise just mark this name as found
$found_names[$clean_name] = $user_id;
}
}
// Else, if we already found the username
else
{
// If the value in the found_names lookup table is only true ...
if ($found_names[$clean_name] === true)
{
// then the actual data was already added to $colliding_users
// and we only need to append the user_id
$colliding_users[$clean_name][] = $user_id;
}
else
{
// otherwise it still keeps the first user_id for this name
// and we need to move the data to $colliding_users, and set
// the value in the found_names lookup table to true, so
// following users will directly be appended to $colliding_users
$colliding_users[$clean_name] = array($found_names[$clean_name], $user_id);
$found_names[$clean_name] = true;
}
}
}
if (($echos % 1000) == 0)
{
echo '.';
flush();
}
$echos++;
}
$db->sql_freeresult($result);
_write_result(false, $errored, $error_ary);
// now retrieve all information about the users and let the admin decide what to do
if (sizeof($colliding_users))
{
$exit = true;
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'language/' . $language . '/memberlist.' . $phpEx);
include($phpbb_root_path . 'language/' . $language . '/acp/users.' . $phpEx);
// link a few things to the correct place so we don't get any problems
$user->lang = &$lang;
$user->data['user_id'] = ANONYMOUS;
$user->date_format = $config['default_dateformat'];
// a little trick to get all user_ids
$user_ids = call_user_func_array('array_merge', array_values($colliding_users));
$sql = 'SELECT session_user_id, MAX(session_time) AS session_time
FROM ' . SESSIONS_TABLE . '
WHERE session_time >= ' . (time() - $config['session_length']) . '
AND ' . $db->sql_in_set('session_user_id', $user_ids) . '
GROUP BY session_user_id';
$result = $db->sql_query($sql);
$session_times = array();
while ($row = $db->sql_fetchrow($result))
{
$session_times[$row['session_user_id']] = $row['session_time'];
}
$db->sql_freeresult($result);
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $user_ids);
$result = $db->sql_query($sql);
$users = array();
while ($row = $db->sql_fetchrow($result))
{
if (isset($session_times[$row['user_id']]))
{
$row['session_time'] = $session_times[$row['user_id']];
}
else
{
$row['session_time'] = 0;
}
$users[(int) $row['user_id']] = $row;
}
$db->sql_freeresult($result);
unset($session_times);
// now display a table with all users, some information about them and options
// for the admin: keep name, change name (with text input) or delete user
$u_action = "database_update.$phpEx?language=$language&amp;type=$inline_update";
?>
<br /><br />
<p><?php echo $lang['CHANGE_CLEAN_NAMES']; ?></p>
<form id="change_clean_names" method="post" action="<?php echo $u_action; ?>">
<?php
foreach ($colliding_users as $clean_name => $user_ids)
{
?>
<fieldset class="tabulated">
<table>
<caption><?php echo sprintf($lang['COLLIDING_CLEAN_USERNAME'], $clean_name); ?></caption>
<thead>
<tr>
<th><?php echo $lang['RANK']; ?> <?php echo $lang['USERNAME']; ?></th>
<th><?php echo $lang['POSTS']; ?></th>
<th><?php echo $lang['INFORMATION']; ?></th>
<th><?php echo $lang['JOINED']; ?></th>
<th><?php echo $lang['LAST_ACTIVE']; ?></th>
<th><?php echo $lang['ACTION']; ?></th>
<th><?php echo $lang['NEW_USERNAME']; ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($user_ids as $i => $user_id)
{
$row = $users[$user_id];
$rank_title = $rank_img = '';
get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src);
$last_visit = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'];
$info = '';
switch ($row['user_type'])
{
case USER_INACTIVE:
$info .= $lang['USER_INACTIVE'];
break;
case USER_IGNORE:
$info .= $lang['BOT'];
break;
case USER_FOUNDER:
$info .= $lang['FOUNDER'];
break;
default:
$info .= $lang['USER_ACTIVE'];
}
if ($user_id == ANONYMOUS)
{
$info = $lang['GUEST'];
}
?>
<tr class="bg<?php echo ($i % 2) + 1; ?>">
<td>
<span class="rank-img"><?php echo ($rank_img) ? $rank_img : $rank_title; ?></span><br />
<?php echo get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); ?>
</td>
<td class="posts"><?php echo $row['user_posts']; ?></td>
<td class="info"><?php echo $info; ?></td>
<td><?php echo $user->format_date($row['user_regdate']) ?></td>
<td><?php echo (empty($last_visit)) ? ' - ' : $user->format_date($last_visit); ?>&nbsp;</td>
<td>
<label><input type="radio" class="radio" id="keep_user_<?php echo $user_id; ?>" name="modify_users[<?php echo $user_id; ?>]" value="keep" checked="checked" /> <?php echo $lang['KEEP_OLD_NAME']; ?></label><br />
<label><input type="radio" class="radio" id="edit_user_<?php echo $user_id; ?>" name="modify_users[<?php echo $user_id; ?>]" value="edit" /> <?php echo $lang['EDIT_USERNAME']; ?></label><br />
<?php
// some users must not be deleted
if ($user_id != ANONYMOUS && $row['user_type'] != USER_FOUNDER)
{
?>
<label><input type="radio" class="radio" id="delete_user_retain_<?php echo $user_id; ?>" name="modify_users[<?php echo $user_id; ?>]" value="delete_retain" /> <?php echo $lang['DELETE_USER_RETAIN']; ?></label><br />
<label><input type="radio" class="radio" id="delete_user_remove_<?php echo $user_id; ?>" name="modify_users[<?php echo $user_id; ?>]" value="delete_remove" /> <?php echo $lang['DELETE_USER_REMOVE']; ?></label>
<?php
}
?>
</td>
<td>
<input id="new_username_<?php echo $user_id; ?>" type="text" name="new_usernames[<?php echo $user_id; ?>]" value="<?php echo $row['username']; ?>" />
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</fieldset>
<?php
}
?>
<p class="quick">
<input class="button2" id="resolve_conflicts" type="submit" name="resolve_conflicts" value="<?php echo $lang['SUBMIT']; ?>" />
</p>
</form>
<?php
}
else if (sizeof($found_names))
{
$sql = 'SELECT user_id, username, username_clean
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_values($found_names));
$result = $db->sql_query($sql);
$found_names = array();
while ($row = $db->sql_fetchrow($result))
{
$clean_name = utf8_new_clean_string($row['username']);
if ($clean_name != $row['username_clean'])
{
$user_id = (int) $row['user_id'];
$found_names[$user_id] = $clean_name;
// impossible unique clean name
$sql = 'UPDATE ' . USERS_TABLE . "
SET username_clean = ' {$user_id}'
WHERE user_id = {$user_id}";
$db->sql_query($sql);
}
}
$db->sql_freeresult($result);
foreach ($found_names as $user_id => $clean_name)
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET username_clean = \'' . $db->sql_escape($clean_name) . '\'
WHERE user_id = ' . $user_id;
$db->sql_query($sql);
}
}
unset($found_names);
unset($colliding_users);
}
if ($exit) if ($exit)
{ {
@ -1178,374 +608,6 @@ flush();
$no_updates = true; $no_updates = true;
// some code magic // some code magic
if (version_compare($current_version, '3.0.RC2', '<='))
{
$smileys = array();
$sql = 'SELECT smiley_id, code
FROM ' . SMILIES_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$smileys[$row['smiley_id']] = $row['code'];
}
$db->sql_freeresult($result);
foreach ($smileys as $id => $code)
{
// 2.0 only entitized lt and gt; We need to do something about double quotes.
if (strchr($code, '"') === false)
{
continue;
}
$new_code = str_replace('&amp;', '&', $code);
$new_code = str_replace('&lt;', '<', $new_code);
$new_code = str_replace('&gt;', '>', $new_code);
$new_code = utf8_htmlspecialchars($new_code);
$sql = 'UPDATE ' . SMILIES_TABLE . '
SET code = \'' . $db->sql_escape($new_code) . '\'
WHERE smiley_id = ' . (int) $id;
$db->sql_query($sql);
}
$index_list = sql_list_index($map_dbms, ACL_ROLES_DATA_TABLE);
if (in_array('ath_opt_id', $index_list))
{
sql_index_drop($map_dbms, 'ath_opt_id', ACL_ROLES_DATA_TABLE);
sql_create_index($map_dbms, 'ath_op_id', ACL_ROLES_DATA_TABLE, array('auth_option_id'));
}
$no_updates = false;
}
if (version_compare($current_version, '3.0.RC3', '<='))
{
if ($map_dbms === 'postgres')
{
$sql = "SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));';
_sql($sql, $errored, $error_ary);
}
// we check for:
// ath_opt_id
// ath_op_id
// ACL_ROLES_DATA_TABLE_ath_opt_id
// we want ACL_ROLES_DATA_TABLE_ath_op_id
$table_index_fix = array(
ACL_ROLES_DATA_TABLE => array(
'ath_opt_id' => 'ath_op_id',
'ath_op_id' => 'ath_op_id',
ACL_ROLES_DATA_TABLE . '_ath_opt_id' => 'ath_op_id'
),
STYLES_IMAGESET_DATA_TABLE => array(
'i_id' => 'i_d',
'i_d' => 'i_d',
STYLES_IMAGESET_DATA_TABLE . '_i_id' => 'i_d'
)
);
// we need to create some indicies...
$needed_creation = array();
foreach ($table_index_fix as $table_name => $index_info)
{
$index_list = sql_list_fake($map_dbms, $table_name);
foreach ($index_info as $bad_index => $good_index)
{
if (in_array($bad_index, $index_list))
{
// mysql is actually OK, it won't get a hand in this crud
switch ($map_dbms)
{
// last version, mssql had issues with index removal
case 'mssql':
$sql = 'DROP INDEX ' . $table_name . '.' . $bad_index;
_sql($sql, $errored, $error_ary);
break;
// last version, firebird, oracle, postgresql and sqlite all got bad index names
// we got kinda lucky, tho: they all support the same syntax
case 'firebird':
case 'oracle':
case 'postgres':
case 'sqlite':
$sql = 'DROP INDEX ' . $bad_index;
_sql($sql, $errored, $error_ary);
break;
}
// If the good index already exist we do not need to create it again...
if (($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41') && $bad_index == $good_index)
{
}
else
{
$needed_creation[$table_name][$good_index] = 1;
}
}
}
}
$new_index_defs = array('ath_op_id' => array('auth_option_id'), 'i_d' => array('imageset_id'));
foreach ($needed_creation as $bad_table => $index_repair_list)
{
foreach ($index_repair_list as $new_index => $garbage)
{
sql_create_index($map_dbms, $new_index, $bad_table, $new_index_defs[$new_index]);
$no_updates = false;
}
}
// Make sure empty smiley codes do not exist
$sql = 'DELETE FROM ' . SMILIES_TABLE . "
WHERE code = ''";
_sql($sql, $errored, $error_ary);
set_config('allow_birthdays', '1');
set_config('cron_lock', '0', true);
$no_updates = false;
}
if (version_compare($current_version, '3.0.RC4', '<='))
{
$update_auto_increment = array(
STYLES_TABLE => 'style_id',
STYLES_TEMPLATE_TABLE => 'template_id',
STYLES_THEME_TABLE => 'theme_id',
STYLES_IMAGESET_TABLE => 'imageset_id'
);
$sql = 'SELECT *
FROM ' . STYLES_TABLE . '
WHERE style_id = 0';
$result = _sql($sql, $errored, $error_ary);
$bad_style_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($bad_style_row)
{
$sql = 'SELECT MAX(style_id) as max_id
FROM ' . STYLES_TABLE;
$result = _sql($sql, $errored, $error_ary);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$proper_id = $row['max_id'] + 1;
_sql('UPDATE ' . STYLES_TABLE . " SET style_id = $proper_id WHERE style_id = 0", $errored, $error_ary);
_sql('UPDATE ' . FORUMS_TABLE . " SET forum_style = $proper_id WHERE forum_style = 0", $errored, $error_ary);
_sql('UPDATE ' . USERS_TABLE . " SET user_style = $proper_id WHERE user_style = 0", $errored, $error_ary);
$sql = 'SELECT config_value
FROM ' . CONFIG_TABLE . "
WHERE config_name = 'default_style'";
$result = _sql($sql, $errored, $error_ary);
$style_config = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($style_config['config_value'] === '0')
{
set_config('default_style', (string) $proper_id);
}
}
$sql = 'SELECT *
FROM ' . STYLES_TEMPLATE_TABLE . '
WHERE template_id = 0';
$result = _sql($sql, $errored, $error_ary);
$bad_style_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($bad_style_row)
{
$sql = 'SELECT MAX(template_id) as max_id
FROM ' . STYLES_TEMPLATE_TABLE;
$result = _sql($sql, $errored, $error_ary);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$proper_id = $row['max_id'] + 1;
_sql('UPDATE ' . STYLES_TABLE . " SET template_id = $proper_id WHERE template_id = 0", $errored, $error_ary);
}
$sql = 'SELECT *
FROM ' . STYLES_THEME_TABLE . '
WHERE theme_id = 0';
$result = _sql($sql, $errored, $error_ary);
$bad_style_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($bad_style_row)
{
$sql = 'SELECT MAX(theme_id) as max_id
FROM ' . STYLES_THEME_TABLE;
$result = _sql($sql, $errored, $error_ary);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$proper_id = $row['max_id'] + 1;
_sql('UPDATE ' . STYLES_TABLE . " SET theme_id = $proper_id WHERE theme_id = 0", $errored, $error_ary);
}
$sql = 'SELECT *
FROM ' . STYLES_IMAGESET_TABLE . '
WHERE imageset_id = 0';
$result = _sql($sql, $errored, $error_ary);
$bad_style_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($bad_style_row)
{
$sql = 'SELECT MAX(imageset_id) as max_id
FROM ' . STYLES_IMAGESET_TABLE;
$result = _sql($sql, $errored, $error_ary);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$proper_id = $row['max_id'] + 1;
_sql('UPDATE ' . STYLES_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary);
_sql('UPDATE ' . STYLES_IMAGESET_DATA_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary);
}
if ($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41')
{
foreach ($update_auto_increment as $auto_table_name => $auto_column_name)
{
$sql = "SELECT MAX({$auto_column_name}) as max_id
FROM {$auto_table_name}";
$result = _sql($sql, $errored, $error_ary);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$max_id = ((int) $row['max_id']) + 1;
_sql("ALTER TABLE {$auto_table_name} AUTO_INCREMENT = {$max_id}", $errored, $error_ary);
}
$no_updates = false;
}
else if ($map_dbms == 'postgres')
{
foreach ($update_auto_increment as $auto_table_name => $auto_column_name)
{
$sql = "SELECT SETVAL('" . $auto_table_name . "_seq',(select case when max({$auto_column_name})>0 then max({$auto_column_name})+1 else 1 end from " . $auto_table_name . '));';
_sql($sql, $errored, $error_ary);
}
$sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq';
_sql($sql, $errored, $error_ary);
}
else if ($map_dbms == 'firebird')
{
$sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE;
_sql($sql, $errored, $error_ary);
$sql = 'DROP GENERATOR ' . STYLES_TEMPLATE_DATA_TABLE . '_gen';
_sql($sql, $errored, $error_ary);
}
else if ($map_dbms == 'oracle')
{
$sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE;
_sql($sql, $errored, $error_ary);
$sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq';
_sql($sql, $errored, $error_ary);
}
else if ($map_dbms == 'mssql')
{
// we use transactions because we need to have a working DB at the end of all of this
$db->sql_transaction('begin');
$sql = 'SELECT *
FROM ' . STYLES_TEMPLATE_DATA_TABLE;
$result = _sql($sql, $errored, $error_ary);
$old_style_rows = array();
while ($row = $db->sql_fetchrow($result))
{
$old_style_rows[] = $row;
}
$db->sql_freeresult($result);
// death to the table, it is evil!
$sql = 'DROP TABLE ' . STYLES_TEMPLATE_DATA_TABLE;
_sql($sql, $errored, $error_ary);
// the table of awesomeness, praise be to it (or something)
$sql = 'CREATE TABLE [' . STYLES_TEMPLATE_DATA_TABLE . "] (
[template_id] [int] DEFAULT (0) NOT NULL ,
[template_filename] [varchar] (100) DEFAULT ('') NOT NULL ,
[template_included] [varchar] (8000) DEFAULT ('') NOT NULL ,
[template_mtime] [int] DEFAULT (0) NOT NULL ,
[template_data] [text] DEFAULT ('') NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]";
_sql($sql, $errored, $error_ary);
// index? index
$sql = 'CREATE INDEX [tid] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_id]) ON [PRIMARY]';
_sql($sql, $errored, $error_ary);
// yet another index
$sql = 'CREATE INDEX [tfn] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_filename]) ON [PRIMARY]';
_sql($sql, $errored, $error_ary);
foreach ($old_style_rows as $return_row)
{
_sql('INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $return_row), $errored, $error_ary);
}
$db->sql_transaction('commit');
}
// Setting this here again because new installations may not have it...
set_config('cron_lock', '0', true);
set_config('ldap_port', '');
set_config('ldap_user_filter', '');
$no_updates = false;
}
if (version_compare($current_version, '3.0.RC5', '<='))
{
// In case the user is having the bot mediapartner google "as is", adjust it.
$sql = 'UPDATE ' . BOTS_TABLE . "
SET bot_agent = '" . $db->sql_escape('Mediapartners-Google') . "'
WHERE bot_agent = '" . $db->sql_escape('Mediapartners-Google/') . "'";
_sql($sql, $errored, $error_ary);
set_config('form_token_lifetime', '7200');
set_config('form_token_mintime', '0');
set_config('min_time_reg', '5');
set_config('min_time_terms', '2');
set_config('form_token_sid_guests', '1');
$db->sql_transaction('begin');
$sql = 'SELECT forum_id, forum_password
FROM ' . FORUMS_TABLE;
$result = _sql($sql, $errored, $error_ary);
while ($row = $db->sql_fetchrow($result))
{
if (!empty($row['forum_password']))
{
_sql('UPDATE ' . FORUMS_TABLE . " SET forum_password = '" . md5($row['forum_password']) . "' WHERE forum_id = {$row['forum_id']}", $errored, $error_ary);
}
}
$db->sql_freeresult($result);
$db->sql_transaction('commit');
$no_updates = false;
}
_write_result($no_updates, $errored, $error_ary); _write_result($no_updates, $errored, $error_ary);

View file

@ -22,9 +22,9 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1);
error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL ^ E_NOTICE);
// @todo Review this test and see if we can find out what it is which prevents PHP 4.2.x from even displaying the page with requirements on it // @todo Review this test and see if we can find out what it is which prevents PHP 4.2.x from even displaying the page with requirements on it
if (version_compare(PHP_VERSION, '4.3.3') < 0) if (version_compare(PHP_VERSION, '5.1.0') < 0)
{ {
die('You are running an unsupported PHP version. Please upgrade to PHP 4.3.3 or higher before trying to install phpBB 3.0'); die('You are running an unsupported PHP version. Please upgrade to PHP 5.1.0 or higher before trying to install phpBB 3.0');
} }
/* /*
@ -238,7 +238,7 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle
$user = new user(); $user = new user();
$auth = new auth(); $auth = new auth();
$cache = new cache(); $cache = new acm();
$template = new template(); $template = new template();
// Add own hook handler, if present. :o // Add own hook handler, if present. :o
@ -247,7 +247,7 @@ if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
foreach ($cache->obtain_hooks() as $hook) foreach (cache::obtain_hooks() as $hook)
{ {
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
} }

View file

@ -68,7 +68,7 @@ class convert
var $p_master; var $p_master;
function convert(&$p_master) function __construct(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }

View file

@ -141,7 +141,7 @@ class install_install extends module
// Test the minimum PHP version // Test the minimum PHP version
$php_version = PHP_VERSION; $php_version = PHP_VERSION;
if (version_compare($php_version, '4.3.3') < 0) if (version_compare($php_version, '5.1.0') < 0)
{ {
$result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
} }
@ -246,6 +246,26 @@ class install_install extends module
'S_LEGEND' => false, 'S_LEGEND' => false,
)); ));
// Check for PCRE unicode property support
if (@preg_match('/\p{Ll}/u', 'a'))
{
$passed['pcre'] = true;
$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
}
else
{
$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
}
$template->assign_block_vars('checks', array(
'TITLE' => $lang['PCRE_UNI_PROP_SUPPORT'],
'TITLE_EXPLAIN' => $lang['PCRE_UNI_PROP_SUPPORT_EXPLAIN'],
'RESULT' => $result,
'S_EXPLAIN' => true,
'S_LEGEND' => false,
));
/** /**
* Better not enabling and adding to the loaded extensions due to the specific requirements needed * Better not enabling and adding to the loaded extensions due to the specific requirements needed
if (!@extension_loaded('mbstring')) if (!@extension_loaded('mbstring'))

View file

@ -55,10 +55,6 @@ $lang = array_merge($lang, array(
'FULLTEXT_MYSQL_INCOMPATIBLE_VERSION' => 'The MySQL fulltext backend can only be used with MySQL4 and above.', 'FULLTEXT_MYSQL_INCOMPATIBLE_VERSION' => 'The MySQL fulltext backend can only be used with MySQL4 and above.',
'FULLTEXT_MYSQL_NOT_MYISAM' => 'MySQL fulltext indexes can only be used with MyISAM tables.', 'FULLTEXT_MYSQL_NOT_MYISAM' => 'MySQL fulltext indexes can only be used with MyISAM tables.',
'FULLTEXT_MYSQL_TOTAL_POSTS' => 'Total number of indexed posts', 'FULLTEXT_MYSQL_TOTAL_POSTS' => 'Total number of indexed posts',
'FULLTEXT_MYSQL_MBSTRING' => 'Support for non-latin UTF-8 characters using mbstring:',
'FULLTEXT_MYSQL_PCRE' => 'Support for non-latin UTF-8 characters using PCRE:',
'FULLTEXT_MYSQL_MBSTRING_EXPLAIN' => 'If PCRE does not have unicode character properties, the search backend will try to use mbstrings regular expression engine.',
'FULLTEXT_MYSQL_PCRE_EXPLAIN' => 'This search backend requires PCRE unicode character properties, only available in PHP 4.4, 5.1 and above, if you want to search for non-latin characters.',
'GENERAL_SEARCH_SETTINGS' => 'General search settings', 'GENERAL_SEARCH_SETTINGS' => 'General search settings',
'GO_TO_SEARCH_INDEX' => 'Go to search index page', 'GO_TO_SEARCH_INDEX' => 'Go to search index page',

View file

@ -282,6 +282,8 @@ $lang = array_merge($lang, array(
'PCRE_UTF_SUPPORT' => 'PCRE UTF-8 support', 'PCRE_UTF_SUPPORT' => 'PCRE UTF-8 support',
'PCRE_UTF_SUPPORT_EXPLAIN' => 'phpBB will <strong>not</strong> run if your PHP installation is not compiled with UTF-8 support in the PCRE extension.', 'PCRE_UTF_SUPPORT_EXPLAIN' => 'phpBB will <strong>not</strong> run if your PHP installation is not compiled with UTF-8 support in the PCRE extension.',
'PCRE_UNI_PROP_SUPPORT' => 'PCRE Unicode Property support',
'PCRE_UNI_PROP_SUPPORT_EXPLAIN' => 'phpBB will <strong>not</strong> run if your PHP installation is not compiled with Unicode Property support in the PCRE extension.',
'PHP_GETIMAGESIZE_SUPPORT' => 'PHP function getimagesize() is available', 'PHP_GETIMAGESIZE_SUPPORT' => 'PHP function getimagesize() is available',
'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN' => '<strong>Required</strong> - In order for phpBB to function correctly, the getimagesize function needs to be available.', 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN' => '<strong>Required</strong> - In order for phpBB to function correctly, the getimagesize function needs to be available.',
'PHP_OPTIONAL_MODULE' => 'Optional modules', 'PHP_OPTIONAL_MODULE' => 'Optional modules',
@ -295,7 +297,7 @@ $lang = array_merge($lang, array(
'PHP_SETTINGS_EXPLAIN' => '<strong>Required</strong> - You must be running at least version 4.3.3 of PHP in order to install phpBB. If <var>safe mode</var> is displayed below your PHP installation is running in that mode. This will impose limitations on remote administration and similar features.', 'PHP_SETTINGS_EXPLAIN' => '<strong>Required</strong> - You must be running at least version 4.3.3 of PHP in order to install phpBB. If <var>safe mode</var> is displayed below your PHP installation is running in that mode. This will impose limitations on remote administration and similar features.',
'PHP_URL_FOPEN_SUPPORT' => 'PHP setting <var>allow_url_fopen</var> is enabled', 'PHP_URL_FOPEN_SUPPORT' => 'PHP setting <var>allow_url_fopen</var> is enabled',
'PHP_URL_FOPEN_SUPPORT_EXPLAIN' => '<strong>Optional</strong> - This setting is optional, however certain phpBB functions like off-site avatars will not work properly without it. ', 'PHP_URL_FOPEN_SUPPORT_EXPLAIN' => '<strong>Optional</strong> - This setting is optional, however certain phpBB functions like off-site avatars will not work properly without it. ',
'PHP_VERSION_REQD' => 'PHP version >= 4.3.3', 'PHP_VERSION_REQD' => 'PHP version >= 5.1.0',
'POST_ID' => 'Post ID', 'POST_ID' => 'Post ID',
'PREFIX_FOUND' => 'A scan of your tables has shown a valid installation using <strong>%s</strong> as table prefix.', 'PREFIX_FOUND' => 'A scan of your tables has shown a valid installation using <strong>%s</strong> as table prefix.',
'PREPROCESS_STEP' => 'Executing pre-processing functions/queries', 'PREPROCESS_STEP' => 'Executing pre-processing functions/queries',

View file

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

View file

@ -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 = cache::obtain_icons();
// Output header // Output header
if ($search_id && ($total_match_count > 1000)) if ($search_id && ($total_match_count > 1000))

View file

@ -60,7 +60,7 @@ if ($id)
require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx);
$db = new $sql_db(); $db = new $sql_db();
$cache = new cache(); $cache = new acm();
// Connect to DB // Connect to DB
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
@ -69,7 +69,7 @@ if ($id)
} }
unset($dbpasswd); unset($dbpasswd);
$config = $cache->obtain_config(); $config = cache::obtain_config();
$user = false; $user = false;
if ($sid) if ($sid)

View file

@ -8,10 +8,10 @@
<ul class="linklist"> <ul class="linklist">
<li class="icon-home"><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a></li> <li class="icon-home"><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a></li>
<!-- IF not S_IS_BOT --> <!-- IF not S_IS_BOT -->
<!-- IF S_WATCH_FORUM_LINK --><li <!-- IF S_WATCHING_FORUM -->class="icon-unsubscribe"<!-- ELSE -->class="icon-subscribe"<!-- ENDIF -->><a href="{S_WATCH_FORUM_LINK}" title="{S_WATCH_FORUM_TITLE}">{S_WATCH_FORUM_TITLE}</a></li><!-- ENDIF --> <!-- IF S_VIEWFORUM and S_WATCH_FORUM_LINK --><li <!-- IF S_WATCHING_FORUM -->class="icon-unsubscribe"<!-- ELSE -->class="icon-subscribe"<!-- ENDIF -->><a href="{S_WATCH_FORUM_LINK}" title="{S_WATCH_FORUM_TITLE}">{S_WATCH_FORUM_TITLE}</a></li><!-- ENDIF -->
<!-- IF U_WATCH_TOPIC --><li <!-- IF S_WATCHING_TOPIC -->class="icon-unsubscribe"<!-- ELSE -->class="icon-subscribe"<!-- ENDIF -->><a href="{U_WATCH_TOPIC}" title="{L_WATCH_TOPIC}">{L_WATCH_TOPIC}</a></li><!-- ENDIF --> <!-- IF S_VIEWTOPIC and U_WATCH_TOPIC --><li <!-- IF S_WATCHING_TOPIC -->class="icon-unsubscribe"<!-- ELSE -->class="icon-subscribe"<!-- ENDIF -->><a href="{U_WATCH_TOPIC}" title="{L_WATCH_TOPIC}">{L_WATCH_TOPIC}</a></li><!-- ENDIF -->
<!-- IF U_BOOKMARK_TOPIC --><li class="icon-bookmark"><a href="{U_BOOKMARK_TOPIC}" title="{L_BOOKMARK_TOPIC}">{L_BOOKMARK_TOPIC}</a></li><!-- ENDIF --> <!-- IF S_VIEWTOPIC and U_BOOKMARK_TOPIC --><li class="icon-bookmark"><a href="{U_BOOKMARK_TOPIC}" title="{L_BOOKMARK_TOPIC}">{L_BOOKMARK_TOPIC}</a></li><!-- ENDIF -->
<!-- IF U_BUMP_TOPIC --><li class="icon-bump"><a href="{U_BUMP_TOPIC}" title="{L_BUMP_TOPIC}">{L_BUMP_TOPIC}</a></li><!-- ENDIF --> <!-- IF S_VIEWTOPIC and U_BUMP_TOPIC --><li class="icon-bump"><a href="{U_BUMP_TOPIC}" title="{L_BUMP_TOPIC}">{L_BUMP_TOPIC}</a></li><!-- ENDIF -->
<!-- ENDIF --> <!-- ENDIF -->
<li class="rightside"><a href="{U_TEAM}">{L_THE_TEAM}</a> &bull; <!-- IF not S_IS_BOT --><a href="{U_DELETE_COOKIES}">{L_DELETE_COOKIES}</a> &bull; <!-- ENDIF -->{S_TIMEZONE}</li> <li class="rightside"><a href="{U_TEAM}">{L_THE_TEAM}</a> &bull; <!-- IF not S_IS_BOT --><a href="{U_DELETE_COOKIES}">{L_DELETE_COOKIES}</a> &bull; <!-- ENDIF -->{S_TIMEZONE}</li>
</ul> </ul>

View file

@ -127,10 +127,12 @@
<li class="rightside"><a href="#" onclick="fontsizeup(); return false;" class="fontsize" title="{L_CHANGE_FONT_SIZE}">{L_CHANGE_FONT_SIZE}</a></li> <li class="rightside"><a href="#" onclick="fontsizeup(); return false;" class="fontsize" title="{L_CHANGE_FONT_SIZE}">{L_CHANGE_FONT_SIZE}</a></li>
<!-- IF S_VIEWTOPIC -->
<!-- IF U_EMAIL_TOPIC --><li class="rightside"><a href="{U_EMAIL_TOPIC}" title="{L_EMAIL_TOPIC}" class="sendemail">{L_EMAIL_TOPIC}</a></li><!-- ENDIF --> <!-- IF U_EMAIL_TOPIC --><li class="rightside"><a href="{U_EMAIL_TOPIC}" title="{L_EMAIL_TOPIC}" class="sendemail">{L_EMAIL_TOPIC}</a></li><!-- ENDIF -->
<!-- IF U_EMAIL_PM --><li class="rightside"><a href="{U_EMAIL_PM}" title="{L_EMAIL_PM}" class="sendemail">{L_EMAIL_PM}</a></li><!-- ENDIF --> <!-- IF U_EMAIL_PM --><li class="rightside"><a href="{U_EMAIL_PM}" title="{L_EMAIL_PM}" class="sendemail">{L_EMAIL_PM}</a></li><!-- ENDIF -->
<!-- IF U_PRINT_TOPIC --><li class="rightside"><a href="{U_PRINT_TOPIC}" title="{L_PRINT_TOPIC}" accesskey="p" class="print">{L_PRINT_TOPIC}</a></li><!-- ENDIF --> <!-- IF U_PRINT_TOPIC --><li class="rightside"><a href="{U_PRINT_TOPIC}" title="{L_PRINT_TOPIC}" accesskey="p" class="print">{L_PRINT_TOPIC}</a></li><!-- ENDIF -->
<!-- IF U_PRINT_PM --><li class="rightside"><a href="{U_PRINT_PM}" title="{L_PRINT_PM}" accesskey="p" class="print">{L_PRINT_PM}</a></li><!-- ENDIF --> <!-- IF U_PRINT_PM --><li class="rightside"><a href="{U_PRINT_PM}" title="{L_PRINT_PM}" accesskey="p" class="print">{L_PRINT_PM}</a></li><!-- ENDIF -->
<!-- ENDIF -->
</ul> </ul>
<!-- IF not S_IS_BOT and S_USER_LOGGED_IN --> <!-- IF not S_IS_BOT and S_USER_LOGGED_IN -->

View file

@ -303,7 +303,7 @@ $template->assign_vars(array(
)); ));
// Grab icons // Grab icons
$icons = $cache->obtain_icons(); $icons = cache::obtain_icons();
// Grab all topic data // Grab all topic data
$rowset = $announcement_list = $topic_list = $global_announce_list = array(); $rowset = $announcement_list = $topic_list = $global_announce_list = array();

View file

@ -480,16 +480,16 @@ if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('b
} }
// Grab ranks // Grab ranks
$ranks = $cache->obtain_ranks(); $ranks = cache::obtain_ranks();
// Grab icons // Grab icons
$icons = $cache->obtain_icons(); $icons = 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 = cache::obtain_attach_extensions($forum_id);
} }
// Forum rules listing // Forum rules listing