diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_styles.php | 571 | ||||
-rw-r--r-- | phpBB/includes/captcha/captcha_factory.php | 2 | ||||
-rw-r--r-- | phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php | 2 | ||||
-rw-r--r-- | phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php | 2 | ||||
-rw-r--r-- | phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php | 2 | ||||
-rw-r--r-- | phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 2 | ||||
-rw-r--r-- | phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 1 | ||||
-rw-r--r-- | phpBB/includes/functions_acp.php | 1 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 21 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_prefs.php | 9 |
11 files changed, 321 insertions, 294 deletions
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 2772fb2217..d33be274b4 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -20,31 +20,53 @@ if (!defined('IN_PHPBB')) */ class acp_styles { - var $u_action; - var $u_base_action; - var $s_hidden_fields; - var $mode; - var $styles_path; - var $styles_path_absolute = 'styles'; - - function main($id, $mode) + public $u_action; + + protected $u_base_action; + protected $s_hidden_fields; + protected $mode; + protected $styles_path; + protected $styles_path_absolute = 'styles'; + protected $default_style = 0; + + protected $db; + protected $user; + protected $template; + protected $request; + protected $cache; + protected $auth; + protected $phpbb_root_path; + protected $phpEx; + + public function main($id, $mode) { - global $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request; + global $db, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request, $cache, $auth, $config; + + $this->db = $db; + $this->user = $user; + $this->template = $template; + $this->request = $request; + $this->cache = $cache; + $this->auth = $auth; + $this->config = $config; + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; - $this->styles_path = $phpbb_root_path . $this->styles_path_absolute . '/'; + $this->default_style = $config['default_style']; + $this->styles_path = $this->phpbb_root_path . $this->styles_path_absolute . '/'; $this->u_base_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$id}"); $this->s_hidden_fields = array( 'mode' => $mode, ); - $user->add_lang('acp/styles'); + $this->user->add_lang('acp/styles'); $this->tpl_name = 'acp_styles'; $this->page_title = 'ACP_CAT_STYLES'; $this->mode = $mode; - $action = $request->variable('action', ''); + $action = $this->request->variable('action', ''); $post_actions = array('install', 'activate', 'deactivate', 'uninstall'); foreach ($post_actions as $key) { @@ -58,12 +80,12 @@ class acp_styles $this->s_hidden_fields['action'] = $action; } - $template->assign_vars(array( + $this->template->assign_vars(array( 'U_ACTION' => $this->u_base_action, 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields) ) ); - + // Execute actions switch ($action) { @@ -86,11 +108,11 @@ class acp_styles $this->frontend(); } } - + /** * Main page */ - function frontend() + protected function frontend() { // Check mode switch ($this->mode) @@ -107,41 +129,36 @@ class acp_styles $this->action_cache(); return; } - global $user; - trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); } - + /** * Purge cache */ - function action_cache() + protected function action_cache() { - global $cache, $auth, $user; - - $cache->purge(); + $this->cache->purge(); // Clear permissions - $auth->acl_clear_prefetch(); + $this->auth->acl_clear_prefetch(); cache_moderators(); add_log('admin', 'LOG_PURGE_CACHE'); - - trigger_error($user->lang['PURGED_CACHE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); + + trigger_error($this->user->lang['PURGED_CACHE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); } - + /** * Install style(s) */ - function action_install() + protected function action_install() { - global $user; - // Get list of styles to install $dirs = $this->request_vars('dir', '', true); - + // Get list of styles that can be installed $styles = $this->find_available(false); - + // Install each style $messages = array(); $installed_names = array(); @@ -166,52 +183,50 @@ class acp_styles $last_installed = $style['style_id']; $installed_names[] = $style['style_name']; $installed_dirs[] = $style['style_path']; - $messages[] = sprintf($user->lang['STYLE_INSTALLED'], htmlspecialchars($style['style_name'])); + $messages[] = sprintf($this->user->lang['STYLE_INSTALLED'], htmlspecialchars($style['style_name'])); } } if (!$found) { - $messages[] = sprintf($user->lang['STYLE_NOT_INSTALLED'], htmlspecialchars($dir)); + $messages[] = sprintf($this->user->lang['STYLE_NOT_INSTALLED'], htmlspecialchars($dir)); } } - + // Show message if (!count($messages)) { - trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } $message = implode('<br />', $messages); - $message .= '<br /><br />' . sprintf($user->lang['STYLE_INSTALLED_RETURN_STYLES'], $this->u_base_action . '&mode=style'); - $message .= '<br /><br />' . sprintf($user->lang['STYLE_INSTALLED_RETURN_UNINSTALLED'], $this->u_base_action . '&mode=install'); + $message .= '<br /><br />' . sprintf($this->user->lang['STYLE_INSTALLED_RETURN_STYLES'], $this->u_base_action . '&mode=style'); + $message .= '<br /><br />' . sprintf($this->user->lang['STYLE_INSTALLED_RETURN_UNINSTALLED'], $this->u_base_action . '&mode=install'); trigger_error($message, E_USER_NOTICE); } - + /** * Confirm styles removal */ - function action_uninstall() + protected function action_uninstall() { - global $user, $config, $template, $request; - // Get list of styles to uninstall $ids = $this->request_vars('id', 0, true); - + // Check if confirmation box was submitted if (confirm_box(true)) { // Uninstall - $this->action_uninstall_confirmed($ids, $request->variable('confirm_delete_files', false)); + $this->action_uninstall_confirmed($ids, $this->request->variable('confirm_delete_files', false)); return; } - + // Confirm box $s_hidden = build_hidden_fields(array( 'action' => 'uninstall', 'ids' => $ids )); - $template->assign_var('S_CONFIRM_DELETE', true); - confirm_box(false, $user->lang['CONFIRM_UNINSTALL_STYLES'], $s_hidden, 'acp_styles.html'); - + $this->template->assign_var('S_CONFIRM_DELETE', true); + confirm_box(false, $this->user->lang['CONFIRM_UNINSTALL_STYLES'], $s_hidden, 'acp_styles.html'); + // Canceled - show styles list $this->frontend(); } @@ -222,11 +237,9 @@ class acp_styles * @param array $ids List of style IDs * @param bool $delete_files If true, script will attempt to remove files for selected styles */ - function action_uninstall_confirmed($ids, $delete_files) + protected function action_uninstall_confirmed($ids, $delete_files) { - global $db, $user, $cache, $config; - - $default = $config['default_style']; + $default = $this->default_style; $uninstalled = array(); $messages = array(); @@ -235,11 +248,11 @@ class acp_styles { if (!$id) { - trigger_error($user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING); } if ($id == $default) { - trigger_error($user->lang['UNINSTALL_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['UNINSTALL_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); } $uninstalled[$id] = false; } @@ -250,10 +263,10 @@ class acp_styles FROM ' . STYLES_TABLE . ' WHERE style_id IN (' . implode(', ', $ids) . ') ORDER BY style_id DESC'; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); - $rows = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); // Uinstall each style $uninstalled = array(); @@ -266,20 +279,20 @@ class acp_styles $messages[] = $result; continue; } - $messages[] = sprintf($user->lang['STYLE_UNINSTALLED'], $style['style_name']); + $messages[] = sprintf($this->user->lang['STYLE_UNINSTALLED'], $style['style_name']); $uninstalled[] = $style['style_name']; // Attempt to delete files if ($delete_files) { - $messages[] = sprintf($user->lang[$this->delete_style_files($style['style_path']) ? 'DELETE_STYLE_FILES_SUCCESS' : 'DELETE_STYLE_FILES_FAILED'], $style['style_name']); + $messages[] = sprintf($this->user->lang[$this->delete_style_files($style['style_path']) ? 'DELETE_STYLE_FILES_SUCCESS' : 'DELETE_STYLE_FILES_FAILED'], $style['style_name']); } } if (empty($messages)) { // Nothing to uninstall? - trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } // Log action @@ -289,7 +302,7 @@ class acp_styles } // Clear cache - $cache->purge(); + $this->cache->purge(); // Show message trigger_error(implode('<br />', $messages) . adm_back_link($this->u_action), E_USER_NOTICE); @@ -298,22 +311,20 @@ class acp_styles /** * Activate styles */ - function action_activate() + protected function action_activate() { - global $user, $config, $cache, $db; - // Get list of styles to activate $ids = $this->request_vars('id', 0, true); - + // Activate styles $sql = 'UPDATE ' . STYLES_TABLE . ' SET style_active = 1 WHERE style_id IN (' . implode(', ', $ids) . ')'; - $db->sql_query($sql); + $this->db->sql_query($sql); // Purge cache - $cache->destroy('sql', STYLES_TABLE); - + $this->cache->destroy('sql', STYLES_TABLE); + // Show styles list $this->frontend(); } @@ -321,19 +332,17 @@ class acp_styles /** * Deactivate styles */ - function action_deactivate() + protected function action_deactivate() { - global $user, $config, $cache, $db; - // Get list of styles to deactivate $ids = $this->request_vars('id', 0, true); // Check for default style foreach ($ids as $id) { - if ($id == $config['default_style']) + if ($id == $this->default_style) { - trigger_error($user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); } } @@ -341,38 +350,36 @@ class acp_styles $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0 WHERE user_style IN (' . implode(', ', $ids) . ')'; - $db->sql_query($sql); + $this->db->sql_query($sql); // Deactivate styles $sql = 'UPDATE ' . STYLES_TABLE . ' SET style_active = 0 WHERE style_id IN (' . implode(', ', $ids) . ')'; - $db->sql_query($sql); + $this->db->sql_query($sql); // Purge cache - $cache->destroy('sql', STYLES_TABLE); + $this->cache->destroy('sql', STYLES_TABLE); // Show styles list $this->frontend(); } - + /** * Show style details */ - function action_details() + protected function action_details() { - global $user, $config, $db, $request, $template, $cache; - - $id = $request->variable('id', 0); + $id = $this->request->variable('id', 0); if (!$id) { - trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } - + // Get all styles $styles = $this->get_styles(); - usort($styles, 'acp_styles::sort_styles'); - + usort($styles, array($this, 'sort_styles')); + // Find current style $style = false; foreach ($styles as $row) @@ -386,34 +393,43 @@ class acp_styles if ($style === false) { - trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } - + // Find all available parent styles $list = $this->find_possible_parents($styles, $id); - + + // Add form key + $form_key = 'acp_styles'; + add_form_key($form_key); + // Change data - if ($request->variable('update', false)) + if ($this->request->variable('update', false)) { + if (!check_form_key($form_key)) + { + trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); + } + $update = array( - 'style_name' => trim($request->variable('style_name', $style['style_name'])), - 'style_parent_id' => $request->variable('style_parent', (int) $style['style_parent_id']), - 'style_active' => $request->variable('style_active', (int) $style['style_active']), + 'style_name' => trim($this->request->variable('style_name', $style['style_name'])), + 'style_parent_id' => $this->request->variable('style_parent', (int) $style['style_parent_id']), + 'style_active' => $this->request->variable('style_active', (int) $style['style_active']), ); $update_action = $this->u_action . '&action=details&id=' . $id; - + // Check style name if ($update['style_name'] != $style['style_name']) { if (!strlen($update['style_name'])) { - trigger_error($user->lang['STYLE_ERR_STYLE_NAME'] . adm_back_link($update_action), E_USER_WARNING); + trigger_error($this->user->lang['STYLE_ERR_STYLE_NAME'] . adm_back_link($update_action), E_USER_WARNING); } foreach ($styles as $row) { if ($row['style_name'] == $update['style_name']) { - trigger_error($user->lang['STYLE_ERR_NAME_EXIST'] . adm_back_link($update_action), E_USER_WARNING); + trigger_error($this->user->lang['STYLE_ERR_NAME_EXIST'] . adm_back_link($update_action), E_USER_WARNING); } } } @@ -421,7 +437,7 @@ class acp_styles { unset($update['style_name']); } - + // Check parent style id if ($update['style_parent_id'] != $style['style_parent_id']) { @@ -439,7 +455,7 @@ class acp_styles } if (!$found) { - trigger_error($user->lang['STYLE_ERR_INVALID_PARENT'] . adm_back_link($update_action), E_USER_WARNING); + trigger_error($this->user->lang['STYLE_ERR_INVALID_PARENT'] . adm_back_link($update_action), E_USER_WARNING); } } else @@ -451,64 +467,64 @@ class acp_styles { unset($update['style_parent_id']); } - + // Check style_active if ($update['style_active'] != $style['style_active']) { - if (!$update['style_active'] && $config['default_style'] == $style['style_id']) + if (!$update['style_active'] && $this->default_style == $style['style_id']) { - trigger_error($user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($update_action), E_USER_WARNING); + trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($update_action), E_USER_WARNING); } } else { unset($update['style_active']); } - + // Update data if (count($update)) { $sql = 'UPDATE ' . STYLES_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $update) . " + SET ' . $this->db->sql_build_array('UPDATE', $update) . " WHERE style_id = $id"; - $db->sql_query($sql); - + $this->db->sql_query($sql); + $style = array_merge($style, $update); - + if (isset($update['style_parent_id'])) { // Update styles tree $styles = $this->get_styles(); - if ($this->update_styles_tree(&$styles, $style)) + if ($this->update_styles_tree($styles, $style)) { // Something was changed in styles tree, purge all cache - $cache->purge(); + $this->cache->purge(); } } add_log('admin', 'LOG_STYLE_EDIT_DETAILS', $style['style_name']); } - + // Update default style - $default = $request->variable('style_default', 0); + $default = $this->request->variable('style_default', 0); if ($default) { if (!$style['style_active']) { - trigger_error($user->lang['STYLE_DEFAULT_CHANGE_INACTIVE'] . adm_back_link($update_action), E_USER_WARNING); + trigger_error($this->user->lang['STYLE_DEFAULT_CHANGE_INACTIVE'] . adm_back_link($update_action), E_USER_WARNING); } set_config('default_style', $id); - $cache->purge(); + $this->cache->purge(); } - + // Show styles list $this->frontend(); return; } - + // Show parent styles foreach ($list as $row) { - $template->assign_block_vars('parent_styles', array( + $this->template->assign_block_vars('parent_styles', array( 'STYLE_ID' => $row['style_id'], 'STYLE_NAME' => htmlspecialchars($row['style_name']), 'LEVEL' => $row['level'], @@ -516,9 +532,9 @@ class acp_styles ) ); } - + // Show style details - $template->assign_vars(array( + $this->template->assign_vars(array( 'S_STYLE_DETAILS' => true, 'STYLE_ID' => $style['style_id'], 'STYLE_NAME' => htmlspecialchars($style['style_name']), @@ -526,7 +542,7 @@ class acp_styles 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), 'STYLE_PARENT' => $style['style_parent_id'], 'S_STYLE_ACTIVE' => $style['style_active'], - 'S_STYLE_DEFAULT' => ($style['style_id'] == $config['default_style']) + 'S_STYLE_DEFAULT' => ($style['style_id'] == $this->default_style) ) ); } @@ -534,65 +550,63 @@ class acp_styles /** * List installed styles */ - function show_installed() + protected function show_installed() { - global $user, $template; - // Get all installed styles $styles = $this->get_styles(); if (!count($styles)) { - trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } - - usort($styles, 'acp_styles::sort_styles'); + + usort($styles, array($this, 'sort_styles')); // Get users $users = $this->get_users(); - + // Add users counter to rows foreach ($styles as &$style) { $style['_users'] = isset($users[$style['style_id']]) ? $users[$style['style_id']] : 0; } - + // Set up styles list variables // Addons should increase this number and update template variable $this->styles_list_cols = 4; - $template->assign_var('STYLES_LIST_COLS', $this->styles_list_cols); + $this->template->assign_var('STYLES_LIST_COLS', $this->styles_list_cols); // Show styles list - $this->show_styles_list(&$styles, 0, 0); - + $this->show_styles_list($styles, 0, 0); + // Show styles with invalid inherits_id foreach ($styles as $style) { if (empty($style['_shown'])) { - $style['_note'] = sprintf($user->lang['REQUIRES_STYLE'], htmlspecialchars($style['style_parent_tree'])); + $style['_note'] = sprintf($this->user->lang['REQUIRES_STYLE'], htmlspecialchars($style['style_parent_tree'])); $this->list_style($style, 0); } } // Add buttons - $template->assign_block_vars('extra_actions', array( + $this->template->assign_block_vars('extra_actions', array( 'ACTION_NAME' => 'activate', - 'L_ACTION' => $user->lang['STYLE_ACTIVATE'], + 'L_ACTION' => $this->user->lang['STYLE_ACTIVATE'], ) ); - $template->assign_block_vars('extra_actions', array( + $this->template->assign_block_vars('extra_actions', array( 'ACTION_NAME' => 'deactivate', - 'L_ACTION' => $user->lang['STYLE_DEACTIVATE'], + 'L_ACTION' => $this->user->lang['STYLE_DEACTIVATE'], ) ); if (isset($this->style_counters) && $this->style_counters['total'] > 1) { - $template->assign_block_vars('extra_actions', array( + $this->template->assign_block_vars('extra_actions', array( 'ACTION_NAME' => 'uninstall', - 'L_ACTION' => $user->lang['STYLE_UNINSTALL'], + 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'], ) ); } @@ -601,28 +615,26 @@ class acp_styles /** * Show list of styles that can be installed */ - function show_available() + protected function show_available() { - global $user, $template; - // Get list of styles $styles = $this->find_available(true); - + // Show styles if (empty($styles)) { - trigger_error($user->lang['NO_UNINSTALLED_STYLE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); + trigger_error($this->user->lang['NO_UNINSTALLED_STYLE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); } - - usort($styles, 'acp_styles::sort_styles'); + + usort($styles, array($this, 'sort_styles')); $this->styles_list_cols = 3; - $template->assign_vars(array( + $this->template->assign_vars(array( 'STYLES_LIST_COLS' => $this->styles_list_cols, 'STYLES_LIST_HIDE_COUNT' => true ) ); - + // Show styles foreach ($styles as &$style) { @@ -641,41 +653,39 @@ class acp_styles } if (!$has_parent) { - $this->list_style(&$style, 0); - $this->show_available_child_styles(&$styles, $style['style_name'], 1); + $this->list_style($style, 0); + $this->show_available_child_styles($styles, $style['style_name'], 1); } } - + // Show styles that do not have parent style in styles list foreach ($styles as $style) { if (empty($style['_shown'])) { - $this->list_style(&$style, 0); + $this->list_style($style, 0); } } - + // Add button if (isset($this->style_counters) && $this->style_counters['caninstall'] > 0) { - $template->assign_block_vars('extra_actions', array( + $this->template->assign_block_vars('extra_actions', array( 'ACTION_NAME' => 'install', - 'L_ACTION' => $user->lang['INSTALL_STYLES'], + 'L_ACTION' => $this->user->lang['INSTALL_STYLES'], ) ); } } - + /** * Find styles available for installation * * @param bool $all if true, function will return all installable styles. if false, function will return only styles that can be installed - * @returns array list of styles + * @return array List of styles */ - function find_available($all) + protected function find_available($all) { - global $user; - // Get list of installed styles $installed = $this->get_styles(); @@ -691,10 +701,10 @@ class acp_styles 'tree' => (strlen($style['style_parent_tree']) ? $style['style_parent_tree'] . '/' : '') . $style['style_path'], ); } - + // Get list of directories $dirs = $this->find_style_dirs(); - + // Find styles that can be installed $styles = array(); foreach ($dirs as $dir) @@ -743,10 +753,10 @@ class acp_styles { // Parent style is not installed yet $style['_available'] = false; - $style['_note'] = sprintf($user->lang['REQUIRES_STYLE'], htmlspecialchars($parent)); + $style['_note'] = sprintf($this->user->lang['REQUIRES_STYLE'], htmlspecialchars($parent)); } } - + if ($all || $style['_available']) { $styles[] = $style; @@ -755,7 +765,7 @@ class acp_styles return $styles; } - + /** * Show styles list * @@ -763,18 +773,18 @@ class acp_styles * @param int $parent parent style id * @param int $level style inheritance level */ - function show_styles_list($styles, $parent, $level) + protected function show_styles_list(&$styles, $parent, $level) { foreach ($styles as &$style) { if (empty($style['_shown']) && $style['style_parent_id'] == $parent) { - $this->list_style(&$style, $level); - $this->show_styles_list(&$styles, $style['style_id'], $level + 1); + $this->list_style($style, $level); + $this->show_styles_list($styles, $style['style_id'], $level + 1); } } } - + /** * Show available styles tree * @@ -782,26 +792,26 @@ class acp_styles * @param string $name Name of parent style * @param string $level Styles tree level */ - function show_available_child_styles($styles, $name, $level) + protected function show_available_child_styles(&$styles, $name, $level) { foreach ($styles as &$style) { if (empty($style['_shown']) && $style['_inherit_name'] == $name) { - $this->list_style(&$style, $level); - $this->show_available_child_styles(&$styles, $style['style_name'], $level + 1); + $this->list_style($style, $level); + $this->show_available_child_styles($styles, $style['style_name'], $level + 1); } } } - + /** * Update styles tree * * @param array $styles Styles list, passed as reference * @param array $style Current style, false if root - * @returns true if something was updated, false if not + * @return bool True if something was updated, false if not */ - function update_styles_tree($styles, $style = false) + protected function update_styles_tree(&$styles, $style = false) { $parent_id = ($style === false) ? 0 : $style['style_id']; $parent_tree = ($style === false) ? '' : ($style['style_parent_tree'] == '' ? '' : $style['style_parent_tree']) . $style['style_path']; @@ -816,21 +826,20 @@ class acp_styles $row['style_parent_tree'] = $parent_tree; $update = true; } - $updated |= $this->update_styles_tree(&$styles, $row); + $updated |= $this->update_styles_tree($styles, $row); } } if ($update) { - global $db; $sql = 'UPDATE ' . STYLES_TABLE . " - SET style_parent_tree = '" . $db->sql_escape($parent_tree) . "' + SET style_parent_tree = '" . $this->db->sql_escape($parent_tree) . "' WHERE style_parent_id = {$parent_id}"; - $db->sql_query($sql); + $this->db->sql_query($sql); $updated = true; } return $updated; } - + /** * Find all possible parent styles for style * @@ -838,9 +847,9 @@ class acp_styles * @param int $id id of style * @param int $parent current parent style id * @param int $level current tree level - * @returns array of style ids, names and levels + * @return array Style ids, names and levels */ - function find_possible_parents($styles, $id = -1, $parent = 0, $level = 0) + protected function find_possible_parents($styles, $id = -1, $parent = 0, $level = 0) { $results = array(); foreach ($styles as $style) @@ -860,21 +869,19 @@ class acp_styles } return $results; } - + /** * Show item in styles list * * @param array $style style row * @param array $level style inheritance level */ - function list_style($style, $level) + protected function list_style(&$style, $level) { - global $template, $config, $db, $user, $phpbb_root_path, $phpEx; - // Mark row as shown if (!empty($style['_shown'])) return; $style['_shown'] = true; - + // Generate template variables $actions = array(); $row = array( @@ -884,56 +891,56 @@ class acp_styles 'STYLE_PATH' => htmlspecialchars($style['style_path']), 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), 'STYLE_ACTIVE' => $style['style_active'], - + // Additional data - 'DEFAULT' => ($style['style_id'] && $style['style_id'] == $config['default_style']), + 'DEFAULT' => ($style['style_id'] && $style['style_id'] == $this->default_style), 'USERS' => (isset($style['_users'])) ? $style['_users'] : '', 'LEVEL' => $level, 'PADDING' => (4 + 16 * $level), 'SHOW_COPYRIGHT' => ($style['style_id']) ? false : true, 'STYLE_PATH_FULL' => htmlspecialchars($this->styles_path_absolute . '/' . $style['style_path']) . '/', - + // Comment to show below style 'COMMENT' => (isset($style['_note'])) ? $style['_note'] : '', - + // The following variables should be used by hooks to add custom HTML code 'EXTRA' => '', 'EXTRA_OPTIONS' => '' ); - + // Status specific data if ($style['style_id']) { // Style is installed - + // Details $actions[] = array( 'U_ACTION' => $this->u_action . '&action=details&id=' . $style['style_id'], - 'L_ACTION' => $user->lang['DETAILS'] + 'L_ACTION' => $this->user->lang['DETAILS'] ); // Activate $actions[] = array( 'U_ACTION' => $this->u_action . '&action=' . ($style['style_active'] ? 'de' : '') . 'activate&id=' . $style['style_id'], - 'L_ACTION' => $user->lang['STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE'] + 'L_ACTION' => $this->user->lang['STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE'] ); /* // Export $actions[] = array( 'U_ACTION' => $this->u_action . '&action=export&id=' . $style['style_id'], - 'L_ACTION' => $user->lang['EXPORT'] + 'L_ACTION' => $this->user->lang['EXPORT'] ); */ // Uninstall $actions[] = array( 'U_ACTION' => $this->u_action . '&action=uninstall&id=' . $style['style_id'], - 'L_ACTION' => $user->lang['STYLE_UNINSTALL'] + 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'] ); - + // Preview $actions[] = array( - 'U_ACTION' => append_sid("{$phpbb_root_path}index.$phpEx", 'style=' . $style['style_id']), - 'L_ACTION' => $user->lang['PREVIEW'] + 'U_ACTION' => append_sid($this->phpbb_root_path . 'index.' . $this->phpEx, 'style=' . $style['style_id']), + 'L_ACTION' => $this->user->lang['PREVIEW'] ); } else @@ -942,27 +949,27 @@ class acp_styles if (empty($style['_available'])) { $actions[] = array( - 'HTML' => $user->lang['CANNOT_BE_INSTALLED'] + 'HTML' => $this->user->lang['CANNOT_BE_INSTALLED'] ); } else { $actions[] = array( 'U_ACTION' => $this->u_action . '&action=install&dir=' . urlencode($style['style_path']), - 'L_ACTION' => $user->lang['INSTALL_STYLE'] + 'L_ACTION' => $this->user->lang['INSTALL_STYLE'] ); } } - + // todo: add hook - + // Assign template variables - $template->assign_block_vars('styles_list', $row); + $this->template->assign_block_vars('styles_list', $row); foreach($actions as $action) { - $template->assign_block_vars('styles_list.actions', $action); + $this->template->assign_block_vars('styles_list.actions', $action); } - + // Increase counters $counter = ($style['style_id']) ? ($style['style_active'] ? 'active' : 'inactive') : (empty($style['_available']) ? 'cannotinstall' : 'caninstall'); if (!isset($this->style_counters)) @@ -975,32 +982,31 @@ class acp_styles 'cannotinstall' => 0 ); } - $this->style_counters[$counter] ++; - $this->style_counters['total'] ++; + $this->style_counters[$counter]++; + $this->style_counters['total']++; } - + /** * Show welcome message * * @param string $title main title * @param string $description page description */ - function welcome_message($title, $description) + protected function welcome_message($title, $description) { - global $user, $template; - $template->assign_vars(array( - 'L_TITLE' => (isset($user->lang[$title])) ? $user->lang[$title] : $title, - 'L_EXPLAIN' => (isset($user->lang[$description])) ? $user->lang[$description] : $description + $this->template->assign_vars(array( + 'L_TITLE' => $this->user->lang[$title], + 'L_EXPLAIN' => (isset($this->user->lang[$description])) ? $this->user->lang[$description] : '' ) ); } - + /** * Find all directories that have styles * - * @returns array of directory names + * @return array Directory names */ - function find_style_dirs() + protected function find_style_dirs() { $styles = array(); @@ -1025,11 +1031,11 @@ class acp_styles return $styles; } - + /** * Sort styles */ - function sort_styles($style1, $style2) + public function sort_styles($style1, $style2) { if ($style1['style_active'] != $style2['style_active']) { @@ -1041,19 +1047,18 @@ class acp_styles } return strcasecmp(isset($style1['style_name']) ? $style1['style_name'] : $style1['name'], isset($style2['style_name']) ? $style2['style_name'] : $style2['name']); } - + /** * Read style configuration file * * @param string $dir style directory - * @returns array of style data - * @returns false on error + * @return array|bool Style data, false on error */ - function read_style_cfg($dir) + protected function read_style_cfg($dir) { static $required = array('name', 'version', 'copyright'); $cfg = parse_cfg_file($this->styles_path . $dir . '/style.cfg'); - + // Check if it is a valid file foreach ($required as $key) { @@ -1062,7 +1067,7 @@ class acp_styles return false; } } - + // Check data if (!isset($cfg['parent']) || !is_string($cfg['parent']) || $cfg['parent'] == $cfg['name']) { @@ -1072,20 +1077,18 @@ class acp_styles { $cfg['template_bitfield'] = $this->default_bitfield(); } - + return $cfg; } - + /** * Install style * * @param $style style data - * @returns int style id + * @return int Style id */ - function install_style($style) + protected function install_style($style) { - global $db; - // Generate row $sql_ary = array(); foreach ($style as $key => $value) @@ -1095,38 +1098,36 @@ class acp_styles $sql_ary[$key] = $value; } } - + // Add to database - $db->sql_transaction('begin'); + $this->db->sql_transaction('begin'); $sql = 'INSERT INTO ' . STYLES_TABLE . ' - ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); + ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->db->sql_query($sql); - $id = $db->sql_nextid(); + $id = $this->db->sql_nextid(); - $db->sql_transaction('commit'); + $this->db->sql_transaction('commit'); add_log('admin', 'LOG_STYLE_ADD', $sql_ary['style_name']); - + return $id; } /** * Lists all styles * - * @returns array of rows with styles data + * @return array Rows with styles data */ - function get_styles() + protected function get_styles() { - global $db; - - $sql = 'SELECT * + $sql = 'SELECT * FROM ' . STYLES_TABLE; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); - $rows = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); return $rows; } @@ -1134,64 +1135,60 @@ class acp_styles /** * Count users for each style * - * @returns array of styles in following format: [style_id] = number of users + * @return array Styles in following format: [style_id] = number of users */ - function get_users() + protected function get_users() { - global $db; - $sql = 'SELECT user_style, COUNT(user_style) AS style_count FROM ' . USERS_TABLE . ' GROUP BY user_style'; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); - $style_count = array(); - while ($row = $db->sql_fetchrow($result)) + $style_count = array(); + while ($row = $this->db->sql_fetchrow($result)) { $style_count[$row['user_style']] = $row['style_count']; } - $db->sql_freeresult($result); - + $this->db->sql_freeresult($result); + return $style_count; } - + /** * Uninstall style * * @param array $style Style data - * @returns true on success, error message on error + * @return bool|string True on success, error message on error */ - function uninstall_style($style) + protected function uninstall_style($style) { - global $db, $user; - $id = $style['style_id']; $path = $style['style_path']; - + // Check if style has child styles - $sql = 'SELECT style_id + $sql = 'SELECT style_id FROM ' . STYLES_TABLE . ' - WHERE style_parent_id = ' . $id . " OR style_parent_tree = '" . $db->sql_escape($path) . "'"; - $result = $db->sql_query($sql); - - $conflict = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + WHERE style_parent_id = ' . (int) $id . " OR style_parent_tree = '" . $this->db->sql_escape($path) . "'"; + $result = $this->db->sql_query($sql); + + $conflict = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); if ($conflict !== false) { - return sprintf($user->lang['STYLE_UNINSTALL_DEPENDENT'], $style['style_name']); + return sprintf($this->user->lang['STYLE_UNINSTALL_DEPENDENT'], $style['style_name']); } - + // Change default style for users $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0 WHERE user_style = ' . $id; - $db->sql_query($sql); - + $this->db->sql_query($sql); + // Uninstall style $sql = 'DELETE FROM ' . STYLES_TABLE . ' WHERE style_id = ' . $id; - $db->sql_query($sql); + $this->db->sql_query($sql); return true; } @@ -1200,13 +1197,13 @@ class acp_styles * * @param string $path Style directory * @param string $dir Directory to remove inside style's directory - * @returns true on success, false on error + * @return bool True on success, false on error */ - function delete_style_files($path, $dir = '') + protected function delete_style_files($path, $dir = '') { $dirname = $this->styles_path . $path . $dir; $result = true; - + $dp = @opendir($dirname); if ($dp) @@ -1239,24 +1236,22 @@ class acp_styles { return false; } - + return $result; } - + /** * Get list of items from posted data * * @param string $name Variable name - * @param $default Default value for array: string or number + * @param string|int $default Default value for array * @param bool $error If true, error will be triggered if list is empty - * @returns array of items + * @return array Items */ - function request_vars($name, $default, $error = false) + protected function request_vars($name, $default, $error = false) { - global $request, $user; - - $item = $request->variable($name, $default); - $items = $request->variable($name . 's', array($default)); + $item = $this->request->variable($name, $default); + $items = $this->request->variable($name . 's', array($default)); if (count($items) == 1 && $items[0] == $default) { @@ -1267,28 +1262,30 @@ class acp_styles { $items[] = $item; } - + if ($error && !count($items)) { - trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } return $items; } /** - * Generates hardcoded bitfield + * Generates default bitfield + * + * This bitfield decides which bbcodes are defined in a template. * - * @returns bitfield string + * @return string Bitfield */ - function default_bitfield() + protected function default_bitfield() { static $value; if (isset($value)) { return $value; } - + // Hardcoded template bitfield to add for new templates $bitfield = new bitfield(); $bitfield->set(0); diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index 62fb90d3c5..d57b333c69 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -25,7 +25,7 @@ class phpbb_captcha_factory /** * return an instance of class $name in file $name_plugin.php */ - function get_instance($name) + public static function get_instance($name) { global $phpbb_root_path, $phpEx; diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index a63b0e448f..6c1f3bf00b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -49,7 +49,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha } } - function get_instance() + public static function get_instance() { $instance = new phpbb_captcha_gd(); return $instance; diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php index f523cae191..a5588178bb 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -39,7 +39,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha } } - function get_instance() + public static function get_instance() { return new phpbb_captcha_gd_wave(); } diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php index 4a0418146d..96f13fbe1b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php @@ -39,7 +39,7 @@ class phpbb_captcha_nogd extends phpbb_default_captcha } } - function get_instance() + public static function get_instance() { $instance = new phpbb_captcha_nogd(); return $instance; diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index e12ad00d25..99813189d7 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -98,7 +98,7 @@ class phpbb_captcha_qa /** * API function */ - function get_instance() + public static function get_instance() { $instance = new phpbb_captcha_qa(); diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 0ea8b9c6e7..70c24a8c30 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -54,7 +54,7 @@ class phpbb_recaptcha extends phpbb_default_captcha $this->response = request_var('recaptcha_response_field', ''); } - function get_instance() + public static function get_instance() { $instance = new phpbb_recaptcha(); return $instance; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a44ebb04e8..9a6af29d69 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4860,6 +4860,7 @@ function page_footer($run_cron = true) $template->assign_vars(array( 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', + 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="http://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group'), 'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", false, true, $user->session_id) : '') ); diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 03dec1787a..dc61859363 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -131,6 +131,7 @@ function adm_page_footer($copyright_html = true) 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, + 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="http://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group'), 'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.js", 'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false, 'VERSION' => $config['version']) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 18452c27e9..5b05c3a78d 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1948,6 +1948,27 @@ function validate_jabber($jid) } /** +* Verifies whether a style ID corresponds to an active style. +* +* @param int $style_id The style_id of a style which should be checked if activated or not. +* @return boolean +*/ +function phpbb_style_is_active($style_id) +{ + global $db; + + $sql = 'SELECT style_active + FROM ' . STYLES_TABLE . ' + WHERE style_id = '. (int) $style_id; + $result = $db->sql_query($sql); + + $style_is_active = (bool) $db->sql_fetchfield('style_active'); + $db->sql_freeresult($result); + + return $style_is_active; +} + +/** * Remove avatar */ function avatar_delete($mode, $row, $clean_db = false) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 11f2d231fe..0c9f20f266 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -60,7 +60,14 @@ class ucp_prefs if ($submit) { - $data['style'] = ($config['override_user_style']) ? $config['default_style'] : $data['style']; + if ($config['override_user_style']) + { + $data['style'] = (int) $config['default_style']; + } + else if (!phpbb_style_is_active($data['style'])) + { + $data['style'] = (int) $user->data['user_style']; + } $error = validate_data($data, array( 'dateformat' => array('string', false, 1, 30), |