1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-06 15:45:34 +02:00

[ticket/16790] Remove unused code

PHPBB3-16790
This commit is contained in:
rubencm 2021-06-05 01:42:01 +02:00 committed by Ruben Calvo
parent 072d62b0c0
commit 2f41ce219c
22 changed files with 51 additions and 197 deletions

View File

@ -272,15 +272,13 @@ class acp_attachments
$result = $db->sql_query($sql);
$defined_ips = '';
$ips = array();
while ($row = $db->sql_fetchrow($result))
{
$value = ($row['site_ip']) ? $row['site_ip'] : $row['site_hostname'];
$value = $row['site_ip'] ?: $row['site_hostname'];
if ($value)
{
$defined_ips .= '<option' . (($row['ip_exclude']) ? ' class="sep"' : '') . ' value="' . $row['site_id'] . '">' . $value . '</option>';
$ips[$row['site_id']] = $value;
}
}
$db->sql_freeresult($result);
@ -353,7 +351,6 @@ class acp_attachments
break;
case 'extensions':
if ($submit || isset($_POST['add_extension_check']))
{
if ($submit)
@ -422,30 +419,27 @@ class acp_attachments
if ($add_extension && $add)
{
$sql = 'SELECT extension_id
FROM ' . EXTENSIONS_TABLE . "
WHERE extension = '" . $db->sql_escape($add_extension) . "'";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$error[] = sprintf($user->lang['EXTENSION_EXIST'], $add_extension);
}
$db->sql_freeresult($result);
if (!count($error))
{
$sql = 'SELECT extension_id
FROM ' . EXTENSIONS_TABLE . "
WHERE extension = '" . $db->sql_escape($add_extension) . "'";
$result = $db->sql_query($sql);
$sql_ary = array(
'group_id' => $add_extension_group,
'extension' => $add_extension
);
if ($row = $db->sql_fetchrow($result))
{
$error[] = sprintf($user->lang['EXTENSION_EXIST'], $add_extension);
}
$db->sql_freeresult($result);
$db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
if (!count($error))
{
$sql_ary = array(
'group_id' => $add_extension_group,
'extension' => $add_extension
);
$db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXT_ADD', false, array($add_extension));
}
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXT_ADD', false, array($add_extension));
}
}
@ -747,7 +741,7 @@ class acp_attachments
$imglist = array_values($imglist);
$imglist = $imglist[0];
foreach ($imglist as $key => $img)
foreach ($imglist as $img)
{
if (!$ext_group_row['upload_icon'])
{
@ -770,7 +764,7 @@ class acp_attachments
$i = 0;
$assigned_extensions = '';
foreach ($extensions as $num => $row)
foreach ($extensions as $row)
{
if ($row['group_id'] == $group_id && $group_id)
{
@ -819,8 +813,8 @@ class acp_attachments
ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600);
$right = $cat_right = $padding_inc = 0;
$padding = $forum_list = $holding = '';
$right = $cat_right = 0;
$padding = $holding = '';
$padding_store = array('0' => '');
while ($row = $db->sql_fetchrow($result))
@ -1131,6 +1125,8 @@ class acp_attachments
WHERE ' . $db->sql_in_set('attach_id', $delete_files) . '
AND is_orphan = 0';
$result = $db->sql_query($sql);
$deleted_filenames = [];
while ($row = $db->sql_fetchrow($result))
{
$deleted_filenames[] = $row['real_filename'];

View File

@ -216,15 +216,6 @@ class acp_bbcodes
}
}
if (substr($data['bbcode_tag'], -1) === '=')
{
$test = substr($data['bbcode_tag'], 0, -1);
}
else
{
$test = $data['bbcode_tag'];
}
if (strlen($data['bbcode_tag']) > 16)
{
trigger_error($user->lang['BBCODE_TAG_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);

View File

@ -1224,7 +1224,7 @@ class acp_forums
if ($action_subforums == 'delete')
{
$rows = get_forum_branch($row['forum_id'], 'children', 'descending', false);
$forum_ids = [];
foreach ($rows as $_row)
{
// Do not remove the forum id we are about to change. ;)
@ -2183,29 +2183,4 @@ class acp_forums
adm_page_footer();
}
/**
* Display copy permission page
* Not used at the moment - we will have a look at it for 3.0.7
*/
function copy_permission_page($forum_data)
{
global $phpEx, $phpbb_admin_path, $template, $user;
$acl_url = '&amp;mode=setting_forum_local&amp;forum_id[]=' . $forum_data['forum_id'];
$action = append_sid($this->u_action . "&amp;parent_id={$this->parent_id}&amp;f={$forum_data['forum_id']}&amp;action=copy_perm");
$l_acl = sprintf($user->lang['COPY_TO_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
$this->tpl_name = 'acp_forums_copy_perm';
$template->assign_vars(array(
'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url),
'L_ACL_LINK' => $l_acl,
'L_BACK_LINK' => adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id),
'S_COPY_ACTION' => $action,
'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false),
));
}
}

View File

@ -40,7 +40,6 @@ class acp_icons
$action = (isset($_POST['edit'])) ? 'edit' : $action;
$action = (isset($_POST['import'])) ? 'import' : $action;
$icon_id = $request->variable('id', 0);
$submit = $request->is_set_post('submit', false);
$form_key = 'acp_icons';
add_form_key($form_key);
@ -148,7 +147,7 @@ class acp_icons
case 'add':
$smilies = $default_row = array();
$smiley_options = $order_list = $add_order_list = '';
$smiley_options = '';
if ($action == 'add' && $mode == 'smilies')
{

View File

@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
class acp_logs
{
var $u_action;
public $u_action;
function main($id, $mode)
{
@ -45,7 +45,6 @@ class acp_logs
$sort_dir = $request->variable('sd', 'd');
$this->tpl_name = 'acp_logs';
$this->log_type = constant('LOG_' . strtoupper($mode));
/* @var $pagination \phpbb\pagination */
$pagination = $phpbb_container->get('pagination');

View File

@ -197,7 +197,6 @@ class acp_main
}
// Resync post counts
$start = $max_post_id = 0;
// Find the maximum post ID, we can only stop the cycle when we've reached it
$sql = 'SELECT MAX(forum_last_post_id) as max_post_id
@ -226,6 +225,7 @@ class acp_main
$step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
$start = 0;
while ($start < $max_post_id)
{
$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id

View File

@ -75,7 +75,6 @@ class acp_modules
$this->parent_id = $request->variable('parent_id', 0);
$module_id = $request->variable('m', 0);
$action = $request->variable('action', '');
$errors = array();
switch ($action)
{
@ -249,12 +248,8 @@ class acp_modules
trigger_error($msg . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
}
if (!count($errors))
{
$module_manager->remove_cache_file($this->module_class);
trigger_error($user->lang['MODULE_ADDED'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
}
$module_manager->remove_cache_file($this->module_class);
trigger_error($user->lang['MODULE_ADDED'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
}
}
else
@ -364,12 +359,8 @@ class acp_modules
trigger_error($msg . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
}
if (!count($errors))
{
$module_manager->remove_cache_file($this->module_class);
trigger_error((($action == 'add') ? $user->lang['MODULE_ADDED'] : $user->lang['MODULE_EDITED']) . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
}
$module_manager->remove_cache_file($this->module_class);
trigger_error((($action == 'add') ? $user->lang['MODULE_ADDED'] : $user->lang['MODULE_EDITED']) . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
}
// Category/not category?
@ -430,38 +421,11 @@ class acp_modules
array_change_key_case($module_data, CASE_UPPER))
);
if (count($errors))
{
$template->assign_vars(array(
'S_ERROR' => true,
'ERROR_MSG' => implode('<br />', $errors))
);
}
return;
break;
}
// Default management page
if (count($errors))
{
if ($request->is_ajax())
{
$json_response = new \phpbb\json_response;
$json_response->send(array(
'MESSAGE_TITLE' => $user->lang('ERROR'),
'MESSAGE_TEXT' => implode('<br />', $errors),
'SUCCESS' => false,
));
}
$template->assign_vars(array(
'S_ERROR' => true,
'ERROR_MSG' => implode('<br />', $errors))
);
}
if (!$this->parent_id)
{
$navigation = strtoupper($this->module_class);
@ -605,7 +569,7 @@ class acp_modules
ORDER BY left_id ASC";
$result = $db->sql_query($sql);
$right = $iteration = 0;
$right = 0;
$padding_store = array('0' => '');
$module_list = $padding = '';

View File

@ -1060,11 +1060,11 @@ class acp_permissions
foreach ($hold_ary as $group_id => $forum_ary)
{
$groups[$group_id]['auth_setting'] = $hold_ary[$group_id][$forum_id][$permission];
$groups[$group_id]['auth_setting'] = $forum_ary[$forum_id][$permission];
}
unset($hold_ary);
foreach ($groups as $id => $row)
foreach ($groups as $row)
{
switch ($row['auth_setting'])
{

View File

@ -344,10 +344,10 @@ class acp_profile
$s_hidden_fields = '<input type="hidden" name="field_id" value="' . $field_id . '" />';
}
else
else // action = create
{
// We are adding a new field, define basic params
$lang_options = $field_row = array();
$lang_options = array();
$field_type = $request->variable('field_type', '');
@ -475,41 +475,6 @@ class acp_profile
$cp->vars[$key] = $var;
}
// step 3 - all arrays
if ($action == 'edit')
{
// Get language entries
$sql = 'SELECT *
FROM ' . PROFILE_FIELDS_LANG_TABLE . '
WHERE lang_id <> ' . $this->edit_lang_id . "
AND field_id = $field_id
ORDER BY option_id ASC";
$result = $db->sql_query($sql);
$l_lang_options = array();
while ($row = $db->sql_fetchrow($result))
{
$l_lang_options[$row['lang_id']][$row['option_id']] = $row['lang_value'];
}
$db->sql_freeresult($result);
$sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value
FROM ' . PROFILE_LANG_TABLE . '
WHERE lang_id <> ' . $this->edit_lang_id . "
AND field_id = $field_id
ORDER BY lang_id ASC";
$result = $db->sql_query($sql);
$l_lang_name = $l_lang_explain = $l_lang_default_value = array();
while ($row = $db->sql_fetchrow($result))
{
$l_lang_name[$row['lang_id']] = $row['lang_name'];
$l_lang_explain[$row['lang_id']] = $row['lang_explain'];
$l_lang_default_value[$row['lang_id']] = $row['lang_default_value'];
}
$db->sql_freeresult($result);
}
foreach ($exclude[3] as $key)
{
$cp->vars[$key] = $request->variable($key, array(0 => ''), true);
@ -670,7 +635,7 @@ class acp_profile
// Build options based on profile type
$options = $profile_field->get_options($this->lang_defs['iso'][$config['default_lang']], $cp->vars);
foreach ($options as $num => $option_ary)
foreach ($options as $option_ary)
{
$template->assign_block_vars('option', $option_ary);
}

View File

@ -110,6 +110,7 @@ class acp_prune
if ($row = $db->sql_fetchrow($result))
{
$prune_ids = array();
$p_result = [];
$p_result['topics'] = 0;
$p_result['posts'] = 0;
$log_data = '';

View File

@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
class acp_storage
{
/** @var \phpbb\config $config */
/** @var \phpbb\config\config $config */
protected $config;
/** @var \phpbb\language\language $lang */
@ -33,9 +33,6 @@ class acp_storage
/** @var \phpbb\template\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/** @var \phpbb\di\service_collection */
protected $provider_collection;
@ -70,7 +67,6 @@ class acp_storage
$this->lang = $phpbb_container->get('language');
$this->request = $phpbb_container->get('request');
$this->template = $phpbb_container->get('template');
$this->user = $phpbb_container->get('user');
$this->provider_collection = $phpbb_container->get('storage.provider_collection');
$this->storage_collection = $phpbb_container->get('storage.storage_collection');
$this->phpbb_root_path = $phpbb_root_path;

View File

@ -594,11 +594,6 @@ function mcp_move_topic($topic_ids)
$topic_data = phpbb_get_topic_data($topic_ids);
$leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false;
$forum_sync_data = array();
$forum_sync_data[$forum_id] = current($topic_data);
$forum_sync_data[$to_forum_id] = $forum_data;
$topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0;
$posts_moved = $posts_moved_unapproved = $posts_moved_softdeleted = 0;
@ -636,12 +631,8 @@ function mcp_move_topic($topic_ids)
}
$shadow_topics = 0;
$forum_ids = array($to_forum_id);
foreach ($topic_data as $topic_id => $row)
{
// Get the list of forums to resync
$forum_ids[] = $row['forum_id'];
// We add the $to_forum_id twice, because 'forum_id' is updated
// when the topic is moved again later.
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MOVE', false, array(
@ -1202,7 +1193,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
$post_data = phpbb_get_post_data($post_ids);
foreach ($post_data as $id => $row)
foreach ($post_data as $row)
{
$post_username = ($row['poster_id'] == ANONYMOUS && !empty($row['post_username'])) ? $row['post_username'] : $row['username'];
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_POST', false, array(
@ -1741,7 +1732,7 @@ function mcp_fork_topic($topic_ids)
$config->increment('num_topics', count($new_topic_id_list), false);
$config->increment('num_posts', $total_posts, false);
foreach ($new_topic_id_list as $topic_id => $new_topic_id)
foreach ($new_topic_id_list as $new_topic_id)
{
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_FORK', false, array(
'forum_id' => $to_forum_id,

View File

@ -135,6 +135,7 @@ class mcp_pm_reports
ORDER BY filetime DESC';
$result = $db->sql_query($sql);
$attachments = [];
while ($row = $db->sql_fetchrow($result))
{
$attachments[] = $row;
@ -242,12 +243,10 @@ class mcp_pm_reports
ORDER BY $sort_order_sql";
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
$i = 0;
$report_ids = array();
while ($row = $db->sql_fetchrow($result))
{
$report_ids[] = $row['report_id'];
$row_num[$row['report_id']] = $i++;
}
$db->sql_freeresult($result);

View File

@ -129,7 +129,7 @@ function mcp_post_details($id, $mode, $action)
// Set some vars
$users_ary = $usernames_ary = array();
$attachments = $extensions = array();
$attachments = array();
$post_id = $post_info['post_id'];
// Get topic tracking info

View File

@ -369,7 +369,6 @@ class mcp_queue
$user->add_lang(array('viewtopic', 'viewforum'));
$topic_id = $request->variable('t', 0);
$forum_info = array();
// If 'sort' is set, "Go" was pressed which is located behind the forums <select> box
// Then, unset the topic id so it does not override the forum id
@ -413,13 +412,6 @@ class mcp_queue
{
trigger_error('NOT_MODERATOR');
}
$sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics
FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_list);
$result = $db->sql_query($sql);
$forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics');
$db->sql_freeresult($result);
}
else
{
@ -486,12 +478,10 @@ class mcp_queue
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
$i = 0;
$post_ids = array();
while ($row = $db->sql_fetchrow($result))
{
$post_ids[] = $row['post_id'];
$row_num[$row['post_id']] = $i++;
}
$db->sql_freeresult($result);

View File

@ -342,7 +342,6 @@ class mcp_reports
$topic_id = $request->variable('t', 0, false, \phpbb\request\request_interface::POST);
}
$forum_info = array();
$forum_list_reports = get_forum_list('m_report', false, true);
$forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs
@ -389,13 +388,6 @@ class mcp_reports
{
trigger_error('NOT_MODERATOR');
}
$sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics
FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_list);
$result = $db->sql_query($sql);
$forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics');
$db->sql_freeresult($result);
}
else
{

View File

@ -199,7 +199,7 @@ class ucp_login_link
*/
protected function process_login_result($result)
{
global $config, $template, $user, $phpbb_container;
global $config, $template, $user, $phpbb_container, $phpbb_root_path, $phpEx;
$login_error = null;

View File

@ -658,6 +658,7 @@ class ucp_main
WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids));
$result = $db->sql_query($sql);
$topic_rows = [];
while ($row = $db->sql_fetchrow($result))
{
$topic_rows[$row['topic_id']] = $row;
@ -882,7 +883,7 @@ class ucp_main
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
$topic_list = $topic_forum_list = $global_announce_list = $rowset = array();
$topic_list = $topic_forum_list = $rowset = array();
while ($row = $db->sql_fetchrow($result))
{
$topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id'];
@ -892,11 +893,6 @@ class ucp_main
$topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread']) ? $row['forum_mark_time'] : 0;
$topic_forum_list[$row['forum_id']]['topics'][] = $topic_id;
if ($row['topic_type'] == POST_GLOBAL)
{
$global_announce_list[] = $topic_id;
}
}
$db->sql_freeresult($result);

View File

@ -45,7 +45,7 @@ class ucp_pm
function main($id, $mode)
{
global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $config, $request;
global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $config, $request, $global_privmsgs_rules, $global_rule_conditions;
if (!$user->data['is_registered'])
{

View File

@ -1030,7 +1030,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
parse_attachments(false, $preview_message, $attachment_data, $update_count, true);
foreach ($attachment_data as $i => $attachment)
foreach ($attachment_data as $attachment)
{
$template->assign_block_vars('attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)

View File

@ -37,7 +37,7 @@ class ucp_profile
$user->add_lang('posting');
$submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST);
$error = $data = array();
$error = array();
$s_hidden_fields = '';
switch ($mode)

View File

@ -106,7 +106,7 @@ class ucp_register
/* @var $cp \phpbb\profilefields\manager */
$cp = $phpbb_container->get('profilefields.manager');
$error = $cp_data = $cp_error = array();
$error = $cp_data = array();
$s_hidden_fields = array();
// Handle login_link data added to $_hidden_fields