aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_attachments.php183
-rw-r--r--phpBB/includes/acp/acp_bbcodes.php46
-rw-r--r--phpBB/includes/acp/acp_board.php27
-rw-r--r--phpBB/includes/acp/acp_bots.php14
-rw-r--r--phpBB/includes/acp/acp_database.php224
-rw-r--r--phpBB/includes/acp/acp_email.php14
-rw-r--r--phpBB/includes/acp/acp_extensions.php8
-rw-r--r--phpBB/includes/acp/acp_forums.php73
-rw-r--r--phpBB/includes/acp/acp_groups.php30
-rw-r--r--phpBB/includes/acp/acp_help_phpbb.php2
-rw-r--r--phpBB/includes/acp/acp_icons.php16
-rw-r--r--phpBB/includes/acp/acp_inactive.php6
-rw-r--r--phpBB/includes/acp/acp_language.php19
-rw-r--r--phpBB/includes/acp/acp_logs.php6
-rw-r--r--phpBB/includes/acp/acp_main.php3
-rw-r--r--phpBB/includes/acp/acp_modules.php8
-rw-r--r--phpBB/includes/acp/acp_permission_roles.php4
-rw-r--r--phpBB/includes/acp/acp_permissions.php84
-rw-r--r--phpBB/includes/acp/acp_profile.php81
-rw-r--r--phpBB/includes/acp/acp_prune.php52
-rw-r--r--phpBB/includes/acp/acp_reasons.php6
-rw-r--r--phpBB/includes/acp/acp_search.php12
-rw-r--r--phpBB/includes/acp/acp_styles.php60
-rw-r--r--phpBB/includes/acp/acp_update.php16
-rw-r--r--phpBB/includes/acp/acp_users.php76
-rw-r--r--phpBB/includes/acp/auth.php40
-rw-r--r--phpBB/includes/bbcode.php17
-rw-r--r--phpBB/includes/compatibility_globals.php5
-rw-r--r--phpBB/includes/constants.php2
-rw-r--r--phpBB/includes/diff/diff.php102
-rw-r--r--phpBB/includes/diff/engine.php10
-rw-r--r--phpBB/includes/diff/renderer.php26
-rw-r--r--phpBB/includes/functions.php286
-rw-r--r--phpBB/includes/functions_acp.php22
-rw-r--r--phpBB/includes/functions_admin.php108
-rw-r--r--phpBB/includes/functions_compatibility.php2
-rw-r--r--phpBB/includes/functions_compress.php10
-rw-r--r--phpBB/includes/functions_content.php72
-rw-r--r--phpBB/includes/functions_convert.php52
-rw-r--r--phpBB/includes/functions_display.php19
-rw-r--r--phpBB/includes/functions_download.php12
-rw-r--r--phpBB/includes/functions_jabber.php16
-rw-r--r--phpBB/includes/functions_mcp.php34
-rw-r--r--phpBB/includes/functions_messenger.php190
-rw-r--r--phpBB/includes/functions_module.php8
-rw-r--r--phpBB/includes/functions_posting.php150
-rw-r--r--phpBB/includes/functions_privmsgs.php125
-rw-r--r--phpBB/includes/functions_transfer.php10
-rw-r--r--phpBB/includes/functions_user.php214
-rw-r--r--phpBB/includes/hooks/index.php2
-rw-r--r--phpBB/includes/mcp/mcp_ban.php9
-rw-r--r--phpBB/includes/mcp/mcp_forum.php20
-rw-r--r--phpBB/includes/mcp/mcp_front.php5
-rw-r--r--phpBB/includes/mcp/mcp_logs.php8
-rw-r--r--phpBB/includes/mcp/mcp_main.php190
-rw-r--r--phpBB/includes/mcp/mcp_notes.php4
-rw-r--r--phpBB/includes/mcp/mcp_pm_reports.php14
-rw-r--r--phpBB/includes/mcp/mcp_post.php15
-rw-r--r--phpBB/includes/mcp/mcp_queue.php119
-rw-r--r--phpBB/includes/mcp/mcp_reports.php74
-rw-r--r--phpBB/includes/mcp/mcp_topic.php62
-rw-r--r--phpBB/includes/mcp/mcp_warn.php4
-rw-r--r--phpBB/includes/message_parser.php62
-rw-r--r--phpBB/includes/questionnaire/questionnaire.php7
-rw-r--r--phpBB/includes/sphinxapi.php44
-rw-r--r--phpBB/includes/ucp/ucp_activate.php2
-rw-r--r--phpBB/includes/ucp/ucp_attachments.php38
-rw-r--r--phpBB/includes/ucp/ucp_auth_link.php4
-rw-r--r--phpBB/includes/ucp/ucp_groups.php44
-rw-r--r--phpBB/includes/ucp/ucp_login_link.php23
-rw-r--r--phpBB/includes/ucp/ucp_main.php92
-rw-r--r--phpBB/includes/ucp/ucp_notifications.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm.php37
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php137
-rw-r--r--phpBB/includes/ucp/ucp_pm_options.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php14
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php41
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php8
-rw-r--r--phpBB/includes/ucp/ucp_profile.php42
-rw-r--r--phpBB/includes/ucp/ucp_register.php127
-rw-r--r--phpBB/includes/ucp/ucp_remind.php116
-rw-r--r--phpBB/includes/ucp/ucp_zebra.php26
-rw-r--r--phpBB/includes/utf/utf_tools.php2
83 files changed, 2593 insertions, 1405 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index 3cfe5de293..94e3660de8 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -27,6 +27,9 @@ class acp_attachments
/** @var \phpbb\config\config */
protected $config;
+ /** @var \phpbb\language\language */
+ protected $language;
+
/** @var ContainerBuilder */
protected $phpbb_container;
@@ -54,6 +57,7 @@ class acp_attachments
$this->id = $id;
$this->db = $db;
$this->config = $config;
+ $this->language = $phpbb_container->get('language');
$this->template = $template;
$this->user = $user;
$this->phpbb_container = $phpbb_container;
@@ -128,7 +132,7 @@ class acp_attachments
$s_assigned_groups = array();
while ($row = $db->sql_fetchrow($result))
{
- $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
+ $row['group_name'] = $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) : $row['group_name'];
$s_assigned_groups[$row['cat_id']][] = $row['group_name'];
}
$db->sql_freeresult($result);
@@ -164,7 +168,6 @@ class acp_attachments
'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
- 'img_imagick' => array('lang' => 'IMAGICK_PATH', 'validate' => 'absolute_path', 'type' => 'text:20:200', 'explain' => true, 'append' => '&nbsp;&nbsp;<span>[ <a href="' . $this->u_action . '&amp;action=imgmagick">' . $user->lang['SEARCH_IMAGICK'] . '</a> ]</span>'),
'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
)
@@ -190,7 +193,7 @@ class acp_attachments
validate_config_vars($display_vars['vars'], $cfg_array, $error);
// Do not write values if there is an error
- if (sizeof($error))
+ if (count($error))
{
$submit = false;
}
@@ -226,7 +229,7 @@ class acp_attachments
// Check Settings
$this->test_upload($error, $this->new_config['upload_path'], false);
- if (!sizeof($error))
+ if (!count($error))
{
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
@@ -234,38 +237,6 @@ class acp_attachments
$template->assign_var('S_ATTACHMENT_SETTINGS', true);
- if ($action == 'imgmagick')
- {
- $this->new_config['img_imagick'] = $this->search_imagemagick();
- }
-
- // We strip eventually manual added convert program, we only want the patch
- if ($this->new_config['img_imagick'])
- {
- // Change path separator
- $this->new_config['img_imagick'] = str_replace('\\', '/', $this->new_config['img_imagick']);
- $this->new_config['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $this->new_config['img_imagick']);
-
- // Check for trailing slash
- if (substr($this->new_config['img_imagick'], -1) !== '/')
- {
- $this->new_config['img_imagick'] .= '/';
- }
- }
-
- $supported_types = get_supported_image_types();
-
- // Check Thumbnail Support
- if (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format'])))
- {
- $this->new_config['img_create_thumbnail'] = 0;
- }
-
- $template->assign_vars(array(
- 'U_SEARCH_IMAGICK' => $this->u_action . '&amp;action=imgmagick',
- 'S_THUMBNAIL_SUPPORT' => (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format']))) ? false : true)
- );
-
// Secure Download Options - Same procedure as with banning
$allow_deny = ($this->new_config['secure_allow_deny']) ? 'ALLOWED' : 'DISALLOWED';
@@ -290,7 +261,7 @@ class acp_attachments
$template->assign_vars(array(
'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'],
'S_DEFINED_IPS' => ($defined_ips != '') ? true : false,
- 'S_WARNING' => (sizeof($error)) ? true : false,
+ 'S_WARNING' => (count($error)) ? true : false,
'WARNING_MSG' => implode('<br />', $error),
'DEFINED_IPS' => $defined_ips,
@@ -363,7 +334,7 @@ class acp_attachments
// Generate correct Change List
$extensions = array();
- for ($i = 0, $size = sizeof($extension_change_list); $i < $size; $i++)
+ for ($i = 0, $size = count($extension_change_list); $i < $size; $i++)
{
$extensions[$extension_change_list[$i]]['group_id'] = $group_select_list[$i];
}
@@ -390,7 +361,7 @@ class acp_attachments
// Delete Extension?
$extension_id_list = $request->variable('extension_id_list', array(0));
- if (sizeof($extension_id_list))
+ if (count($extension_id_list))
{
$sql = 'SELECT extension
FROM ' . EXTENSIONS_TABLE . '
@@ -420,7 +391,7 @@ class acp_attachments
if ($add_extension && $add)
{
- if (!sizeof($error))
+ if (!count($error))
{
$sql = 'SELECT extension_id
FROM ' . EXTENSIONS_TABLE . "
@@ -433,7 +404,7 @@ class acp_attachments
}
$db->sql_freeresult($result);
- if (!sizeof($error))
+ if (!count($error))
{
$sql_ary = array(
'group_id' => $add_extension_group,
@@ -447,7 +418,7 @@ class acp_attachments
}
}
- if (!sizeof($error))
+ if (!count($error))
{
$notify[] = $user->lang['EXTENSIONS_UPDATED'];
}
@@ -558,7 +529,7 @@ class acp_attachments
$db->sql_freeresult($result);
}
- if (!sizeof($error))
+ if (!count($error))
{
// Ok, build the update/insert array
$upload_icon = $request->variable('upload_icon', 'no_image');
@@ -575,7 +546,7 @@ class acp_attachments
$max_filesize = 0;
}
- if (!sizeof($allowed_forums))
+ if (!count($allowed_forums))
{
$forum_select = false;
}
@@ -606,13 +577,13 @@ class acp_attachments
$group_id = $db->sql_nextid();
}
- $group_name = (isset($user->lang['EXT_GROUP_' . $group_name])) ? $user->lang['EXT_GROUP_' . $group_name] : $group_name;
+ $group_name = $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($group_name)) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($group_name)) : $group_name;
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), false, array($group_name));
}
$extension_list = $request->variable('extensions', array(0));
- if ($action == 'edit' && sizeof($extension_list))
+ if ($action == 'edit' && count($extension_list))
{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = 0
@@ -620,7 +591,7 @@ class acp_attachments
$db->sql_query($sql);
}
- if (sizeof($extension_list))
+ if (count($extension_list))
{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = $group_id
@@ -630,7 +601,7 @@ class acp_attachments
$cache->destroy('_extensions');
- if (!sizeof($error))
+ if (!count($error))
{
$notify[] = $user->lang['SUCCESS_EXTENSION_GROUP_' . strtoupper($action)];
}
@@ -806,7 +777,7 @@ class acp_attachments
'S_FILENAME_LIST' => $filename_list,
'S_EDIT_GROUP' => true,
'S_NO_IMAGE' => $no_image_select,
- 'S_FORUM_IDS' => (sizeof($forum_ids)) ? true : false,
+ 'S_FORUM_IDS' => (count($forum_ids)) ? true : false,
'U_EXTENSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&amp;mode=extensions"),
'U_BACK' => $this->u_action,
@@ -908,7 +879,7 @@ class acp_attachments
'U_EDIT' => $this->u_action . "&amp;action=edit&amp;g={$row['group_id']}",
'U_DELETE' => $this->u_action . "&amp;action=delete&amp;g={$row['group_id']}",
- 'GROUP_NAME' => (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'],
+ 'GROUP_NAME' => $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) : $row['group_name'],
'CATEGORY' => $cat_lang[$row['cat_id']],
)
);
@@ -922,13 +893,16 @@ class acp_attachments
case 'orphan':
+ /* @var $pagination \phpbb\pagination */
+ $pagination = $this->phpbb_container->get('pagination');
+
if ($submit)
{
$delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array();
$add_files = (isset($_POST['add'])) ? array_keys($request->variable('add', array('' => 0))) : array();
$post_ids = $request->variable('post_id', array('' => 0));
- if (sizeof($delete_files))
+ if (count($delete_files))
{
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
@@ -951,7 +925,7 @@ class acp_attachments
$db->sql_freeresult($result);
}
- if (sizeof($delete_files))
+ if (count($delete_files))
{
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($delete_files));
@@ -971,7 +945,7 @@ class acp_attachments
}
unset($add_files);
- if (sizeof($upload_list))
+ if (count($upload_list))
{
$template->assign_var('S_UPLOADING_FILES', true);
@@ -1064,13 +1038,29 @@ class acp_attachments
'S_ORPHAN' => true)
);
+ $attachments_per_page = (int) $config['topics_per_page'];
+
+ // Get total number or orphans older than 3 hours
+ $sql = 'SELECT COUNT(attach_id) as num_files, SUM(filesize) as total_size
+ FROM ' . ATTACHMENTS_TABLE . '
+ WHERE is_orphan = 1
+ AND filetime < ' . (time() - 3*60*60);
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $num_files = (int) $row['num_files'];
+ $total_size = (int) $row['total_size'];
+ $this->db->sql_freeresult($result);
+
+ $start = $request->variable('start', 0);
+ $start = $pagination->validate_start($start, $attachments_per_page, $num_files);
+
// Just get the files with is_orphan set and older than 3 hours
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE is_orphan = 1
AND filetime < ' . (time() - 3*60*60) . '
ORDER BY filetime DESC';
- $result = $db->sql_query($sql);
+ $result = $db->sql_query_limit($sql, $attachments_per_page, $start);
while ($row = $db->sql_fetchrow($result))
{
@@ -1086,6 +1076,20 @@ class acp_attachments
}
$db->sql_freeresult($result);
+ $pagination->generate_template_pagination(
+ $this->u_action,
+ 'pagination',
+ 'start',
+ $num_files,
+ $attachments_per_page,
+ $start
+ );
+
+ $template->assign_vars(array(
+ 'TOTAL_FILES' => $num_files,
+ 'TOTAL_SIZE' => get_formatted_filesize($total_size),
+ ));
+
break;
case 'manage':
@@ -1094,7 +1098,7 @@ class acp_attachments
{
$delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array();
- if (sizeof($delete_files))
+ if (count($delete_files))
{
// Select those attachments we want to delete...
$sql = 'SELECT real_filename
@@ -1110,7 +1114,7 @@ class acp_attachments
if ($num_deleted = $this->attachment_manager->delete('attach', $delete_files))
{
- if (sizeof($delete_files) != $num_deleted)
+ if (count($delete_files) != $num_deleted)
{
$error[] = $user->lang['FILES_GONE'];
}
@@ -1231,28 +1235,24 @@ class acp_attachments
// Grab extensions
$extensions = $cache->obtain_attach_extensions(true);
- for ($i = 0, $end = sizeof($attachments_list); $i < $end; ++$i)
+ for ($i = 0, $end = count($attachments_list); $i < $end; ++$i)
{
$row = $attachments_list[$i];
$row['extension'] = strtolower(trim((string) $row['extension']));
$comment = ($row['attach_comment'] && !$row['in_message']) ? str_replace(array("\n", "\r"), array('<br />', "\n"), $row['attach_comment']) : '';
- $display_cat = $extensions[$row['extension']]['display_cat'];
+ $display_cat = isset($extensions[$row['extension']]['display_cat']) ? $extensions[$row['extension']]['display_cat'] : ATTACHMENT_CATEGORY_NONE;
$l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNTS' : 'VIEWED_COUNTS';
$template->assign_block_vars('attachments', array(
'ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']),
'FILESIZE' => get_formatted_filesize((int) $row['filesize']),
'FILETIME' => $user->format_date((int) $row['filetime']),
- 'REAL_FILENAME' => (!$row['in_message']) ? utf8_basename((string) $row['real_filename']) : '',
- 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']),
- 'EXT_GROUP_NAME' => (!empty($extensions[$row['extension']]['group_name'])) ? $user->lang['EXT_GROUP_' . $extensions[$row['extension']]['group_name']] : '',
+ 'REAL_FILENAME' => utf8_basename((string) $row['real_filename']),
+ 'EXT_GROUP_NAME' => $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($extensions[$row['extension']]['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($extensions[$row['extension']]['group_name'])) : $extensions[$row['extension']]['group_name'],
'COMMENT' => $comment,
'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '',
'ATTACH_ID' => (int) $row['attach_id'],
- 'POST_ID' => (int) $row['post_msg_id'],
- 'TOPIC_ID' => (int) $row['topic_id'],
- 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? (int) $post_ids[$row['attach_id']] : '',
'L_DOWNLOAD_COUNT' => $user->lang($l_downloaded_viewed, (int) $row['download_count']),
@@ -1266,7 +1266,7 @@ class acp_attachments
break;
}
- if (sizeof($error))
+ if (count($error))
{
$template->assign_vars(array(
'S_WARNING' => true,
@@ -1274,7 +1274,7 @@ class acp_attachments
);
}
- if (sizeof($notify))
+ if (count($notify))
{
$template->assign_vars(array(
'S_NOTIFY' => true,
@@ -1434,7 +1434,7 @@ class acp_attachments
$group_name = array();
while ($row = $db->sql_fetchrow($result))
{
- $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
+ $row['group_name'] = $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) : $row['group_name'];
$group_name[] = $row;
}
$db->sql_freeresult($result);
@@ -1443,7 +1443,7 @@ class acp_attachments
$row['group_name'] = $user->lang['NOT_ASSIGNED'];
$group_name[] = $row;
- for ($i = 0, $groups_size = sizeof($group_name); $i < $groups_size; $i++)
+ for ($i = 0, $groups_size = count($group_name); $i < $groups_size; $i++)
{
if ($default_group === false)
{
@@ -1463,47 +1463,6 @@ class acp_attachments
}
/**
- * Search Imagick
- */
- function search_imagemagick()
- {
- $imagick = '';
-
- $exe = ((defined('PHP_OS')) && (preg_match('#^win#i', PHP_OS))) ? '.exe' : '';
-
- $magic_home = getenv('MAGICK_HOME');
-
- if (empty($magic_home))
- {
- $locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');
- $path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));
-
- $locations = array_merge($path_locations, $locations);
-
- foreach ($locations as $location)
- {
- // The path might not end properly, fudge it
- if (substr($location, -1) !== '/')
- {
- $location .= '/';
- }
-
- if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000)
- {
- $imagick = str_replace('\\', '/', $location);
- continue;
- }
- }
- }
- else
- {
- $imagick = str_replace('\\', '/', $magic_home);
- }
-
- return $imagick;
- }
-
- /**
* Test Settings
*/
function test_upload(&$error, $upload_dir, $create_directory = false)
@@ -1676,7 +1635,7 @@ class acp_attachments
}
$db->sql_freeresult($result);
- if (sizeof($iplist))
+ if (count($iplist))
{
foreach ($iplist as $ip_entry)
{
@@ -1686,7 +1645,7 @@ class acp_attachments
}
}
- if (sizeof($hostlist))
+ if (count($hostlist))
{
foreach ($hostlist as $host_entry)
{
@@ -1709,7 +1668,7 @@ class acp_attachments
{
$unip_sql = $request->variable('unip', array(0));
- if (sizeof($unip_sql))
+ if (count($unip_sql))
{
$l_unip_list = '';
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php
index f958ae93c7..1f7374a07f 100644
--- a/phpBB/includes/acp/acp_bbcodes.php
+++ b/phpBB/includes/acp/acp_bbcodes.php
@@ -253,7 +253,7 @@ class acp_bbcodes
if ($row)
{
- $bbcode_id = $row['max_bbcode_id'] + 1;
+ $bbcode_id = (int) $row['max_bbcode_id'] + 1;
// Make sure it is greater than the core bbcode ids...
if ($bbcode_id <= NUM_CORE_BBCODES)
@@ -295,6 +295,22 @@ class acp_bbcodes
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log_action, false, array($data['bbcode_tag']));
+ /**
+ * Event after a BBCode has been added or updated
+ *
+ * @event core.acp_bbcodes_modify_create_after
+ * @var string action Type of the action: modify|create
+ * @var int bbcode_id The id of the added or updated bbcode
+ * @var array sql_ary Array with bbcode data (read only)
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'action',
+ 'bbcode_id',
+ 'sql_ary',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create_after', compact($vars)));
+
trigger_error($user->lang[$lang] . adm_back_link($this->u_action));
}
else
@@ -325,10 +341,28 @@ class acp_bbcodes
{
if (confirm_box(true))
{
+ $bbcode_tag = $row['bbcode_tag'];
+
$db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id");
$cache->destroy('sql', BBCODES_TABLE);
$phpbb_container->get('text_formatter.cache')->invalidate();
- $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_BBCODE_DELETE', false, array($row['bbcode_tag']));
+ $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_BBCODE_DELETE', false, array($bbcode_tag));
+
+ /**
+ * Event after a BBCode has been deleted
+ *
+ * @event core.acp_bbcodes_delete_after
+ * @var string action Type of the action: delete
+ * @var int bbcode_id The id of the deleted bbcode
+ * @var string bbcode_tag The tag of the deleted bbcode
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'action',
+ 'bbcode_id',
+ 'bbcode_tag',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_delete_after', compact($vars)));
if ($request->is_ajax())
{
@@ -494,7 +528,7 @@ class acp_bbcodes
// Pad backreference numbers from tokens
if (preg_match_all('/(?<!\\\\)\$([0-9]+)/', $replace, $repad))
{
- $repad = $pad + sizeof(array_unique($repad[0]));
+ $repad = $pad + count(array_unique($repad[0]));
$replace = preg_replace_callback('/(?<!\\\\)\$([0-9]+)/', function ($match) use ($pad) {
return '${' . ($match[1] + $pad) . '}';
}, $replace);
@@ -553,10 +587,10 @@ class acp_bbcodes
}
// Lowercase tags
- $bbcode_tag = preg_replace('/.*?\[([a-z0-9_-]+=?).*/i', '$1', $bbcode_match);
- $bbcode_search = preg_replace('/.*?\[([a-z0-9_-]+)=?.*/i', '$1', $bbcode_match);
+ $bbcode_tag = preg_replace('/.*?\[([a-z0-9_-]+).*/i', '$1', $bbcode_match);
+ $bbcode_search = preg_replace('/.*?\[([a-z0-9_-]+).*/i', '$1', $bbcode_match);
- if (!preg_match('/^[a-zA-Z0-9_-]+=?$/', $bbcode_tag))
+ if (!preg_match('/^[a-zA-Z0-9_-]+$/', $bbcode_tag))
{
global $user;
trigger_error($user->lang['BBCODE_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 77e6133fe6..0730b4e285 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -30,10 +30,13 @@ class acp_board
function main($id, $mode)
{
- global $user, $template, $request;
+ global $user, $template, $request, $language;
global $config, $phpbb_root_path, $phpEx;
global $cache, $phpbb_container, $phpbb_dispatcher, $phpbb_log;
+ /** @var \phpbb\language\language $language Language object */
+ $language = $phpbb_container->get('language');
+
$user->add_lang('acp/board');
$submit = (isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable'])) ? true : false;
@@ -56,7 +59,7 @@ class acp_board
'legend1' => 'ACP_BOARD_SETTINGS',
'sitename' => array('lang' => 'SITE_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => false),
'site_desc' => array('lang' => 'SITE_DESC', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => false),
- 'site_home_url' => array('lang' => 'SITE_HOME_URL', 'validate' => 'string', 'type' => 'url:40:255', 'explain' => true),
+ 'site_home_url' => array('lang' => 'SITE_HOME_URL', 'validate' => 'url', 'type' => 'url:40:255', 'explain' => true),
'site_home_text' => array('lang' => 'SITE_HOME_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
'board_index_text' => array('lang' => 'BOARD_INDEX_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
'board_disable' => array('lang' => 'DISABLE_BOARD', 'validate' => 'bool', 'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
@@ -122,6 +125,7 @@ class acp_board
$avatar_vars = array();
foreach ($avatar_drivers as $current_driver)
{
+ /** @var \phpbb\avatar\driver\driver_interface $driver */
$driver = $phpbb_avatar_manager->get_driver($current_driver, false);
/*
@@ -356,6 +360,7 @@ class acp_board
'load_user_activity_limit' => array('lang' => 'LOAD_USER_ACTIVITY_LIMIT', 'validate' => 'int:0:99999999', 'type' => 'number:0:99999999', 'explain' => true),
'load_tplcompile' => array('lang' => 'RECOMPILE_STYLES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'allow_cdn' => array('lang' => 'ALLOW_CDN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'enable_accurate_pm_button' => array('lang' => 'YES_ACCURATE_PM_BUTTON', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'allow_live_searches' => array('lang' => 'ALLOW_LIVE_SEARCHES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'legend3' => 'CUSTOM_PROFILE_FIELDS',
@@ -444,11 +449,12 @@ class acp_board
'legend1' => 'GENERAL_SETTINGS',
'email_enable' => array('lang' => 'ENABLE_EMAIL', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true),
'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true),
- 'email_function_name' => array('lang' => 'EMAIL_FUNCTION_NAME', 'validate' => 'string', 'type' => 'text:20:50', 'explain' => true),
'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'number:0:99999', 'explain' => true),
+ 'email_max_chunk_size' => array('lang' => 'EMAIL_MAX_CHUNK_SIZE', 'validate' => 'int:1:99999', 'type' => 'number:1:99999', 'explain' => true),
'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true),
'board_contact_name' => array('lang' => 'CONTACT_EMAIL_NAME', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => true),
'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true),
+ 'email_force_sender' => array('lang' => 'EMAIL_FORCE_SENDER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true),
'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'send_test_email' => array('lang' => 'SEND_TEST_EMAIL', 'validate' => 'bool', 'type' => 'custom', 'method' => 'send_test_email', 'explain' => true),
@@ -503,7 +509,7 @@ class acp_board
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
- if (sizeof($error))
+ if (count($error))
{
$submit = false;
}
@@ -532,13 +538,6 @@ class acp_board
$this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
- if ($config_name == 'email_function_name')
- {
- $this->new_config['email_function_name'] = trim(str_replace(array('(', ')'), array('', ''), $this->new_config['email_function_name']));
- $this->new_config['email_function_name'] = (empty($this->new_config['email_function_name']) || !function_exists($this->new_config['email_function_name'])) ? 'mail' : $this->new_config['email_function_name'];
- $config_value = $this->new_config['email_function_name'];
- }
-
if ($submit)
{
if (strpos($data['type'], 'password') === 0 && $config_value === '********')
@@ -690,7 +689,7 @@ class acp_board
'L_TITLE' => $user->lang[$display_vars['title']],
'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'],
- 'S_ERROR' => (sizeof($error)) ? true : false,
+ 'S_ERROR' => (count($error)) ? true : false,
'ERROR_MSG' => implode('<br />', $error),
'U_ACTION' => $this->u_action)
@@ -736,7 +735,7 @@ class acp_board
$template->assign_block_vars('options', array(
'KEY' => $config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
- 'S_EXPLAIN' => $vars['explain'],
+ 'S_EXPLAIN' => $vars['explain'] && !empty($l_explain),
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => $content,
)
@@ -1110,7 +1109,7 @@ class acp_board
$db->sql_query($sql);
// Already emptied for all...
- if (sizeof($values))
+ if (count($values))
{
// Set for selected forums
$sql = 'UPDATE ' . FORUMS_TABLE . '
diff --git a/phpBB/includes/acp/acp_bots.php b/phpBB/includes/acp/acp_bots.php
index e89b16663c..8bd357bc91 100644
--- a/phpBB/includes/acp/acp_bots.php
+++ b/phpBB/includes/acp/acp_bots.php
@@ -55,7 +55,7 @@ class acp_bots
switch ($action)
{
case 'activate':
- if ($bot_id || sizeof($mark))
+ if ($bot_id || count($mark))
{
$sql_id = ($bot_id) ? " = $bot_id" : ' IN (' . implode(', ', $mark) . ')';
@@ -69,7 +69,7 @@ class acp_bots
break;
case 'deactivate':
- if ($bot_id || sizeof($mark))
+ if ($bot_id || count($mark))
{
$sql_id = ($bot_id) ? " = $bot_id" : ' IN (' . implode(', ', $mark) . ')';
@@ -83,7 +83,7 @@ class acp_bots
break;
case 'delete':
- if ($bot_id || sizeof($mark))
+ if ($bot_id || count($mark))
{
if (confirm_box(true))
{
@@ -109,7 +109,7 @@ class acp_bots
WHERE bot_id $sql_id";
$db->sql_query($sql);
- if (sizeof($user_id_ary))
+ if (count($user_id_ary))
{
$_tables = array(USERS_TABLE, USER_GROUP_TABLE);
foreach ($_tables as $table)
@@ -207,7 +207,7 @@ class acp_bots
$error[] = $user->lang['BOT_NAME_TAKEN'];
}
- if (!sizeof($error))
+ if (!count($error))
{
// New bot? Create a new user and group entry
if ($action == 'add')
@@ -338,7 +338,7 @@ class acp_bots
'L_TITLE' => $user->lang['BOT_' . $l_title],
'U_ACTION' => $this->u_action . "&amp;id=$bot_id&amp;action=$action",
'U_BACK' => $this->u_action,
- 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR_MSG' => (count($error)) ? implode('<br />', $error) : '',
'BOT_NAME' => $bot_row['bot_name'],
'BOT_IP' => $bot_row['bot_ip'],
@@ -348,7 +348,7 @@ class acp_bots
'S_ACTIVE_OPTIONS' => $s_active_options,
'S_STYLE_OPTIONS' => $style_select,
'S_LANG_OPTIONS' => $lang_select,
- 'S_ERROR' => (sizeof($error)) ? true : false,
+ 'S_ERROR' => (count($error)) ? true : false,
)
);
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php
index 00c7ef40c0..677fce7217 100644
--- a/phpBB/includes/acp/acp_database.php
+++ b/phpBB/includes/acp/acp_database.php
@@ -23,6 +23,7 @@ class acp_database
{
var $db_tools;
var $u_action;
+ public $page_title;
function main($id, $mode)
{
@@ -57,9 +58,8 @@ class acp_database
$type = $request->variable('type', '');
$table = array_intersect($this->db_tools->sql_list_tables(), $request->variable('table', array('')));
$format = $request->variable('method', '');
- $where = $request->variable('where', '');
- if (!sizeof($table))
+ if (!count($table))
{
trigger_error($user->lang['TABLE_SELECT_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -69,17 +69,9 @@ class acp_database
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
- $store = $download = $structure = $schema_data = false;
-
- if ($where == 'store_and_download' || $where == 'store')
- {
- $store = true;
- }
-
- if ($where == 'store_and_download' || $where == 'download')
- {
- $download = true;
- }
+ $store = true;
+ $structure = false;
+ $schema_data = false;
if ($type == 'full' || $type == 'structure')
{
@@ -98,8 +90,9 @@ class acp_database
$filename = 'backup_' . $time . '_' . unique_id();
+ /** @var phpbb\db\extractor\extractor_interface $extractor Database extractor */
$extractor = $phpbb_container->get('dbal.extractor');
- $extractor->init_extractor($format, $filename, $time, $download, $store);
+ $extractor->init_extractor($format, $filename, $time, false, $store);
$extractor->write_start($table_prefix);
@@ -145,11 +138,6 @@ class acp_database
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DB_BACKUP');
- if ($download == true)
- {
- exit;
- }
-
trigger_error($user->lang['BACKUP_SUCCESS'] . adm_back_link($this->u_action));
break;
@@ -201,16 +189,10 @@ class acp_database
case 'submit':
$delete = $request->variable('delete', '');
$file = $request->variable('file', '');
- $download = $request->variable('download', '');
- if (!preg_match('#^backup_\d{10,}_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches))
- {
- trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- $file_name = $phpbb_root_path . 'store/' . $matches[0];
+ $backup_info = $this->get_backup_file($phpbb_root_path . 'store/', $file);
- if (!file_exists($file_name) || !is_readable($file_name))
+ if (empty($backup_info) || !is_readable($backup_info['file_name']))
{
trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -219,7 +201,7 @@ class acp_database
{
if (confirm_box(true))
{
- unlink($file_name);
+ unlink($backup_info['file_name']);
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DB_DELETE');
trigger_error($user->lang['BACKUP_DELETE'] . adm_back_link($this->u_action));
}
@@ -228,50 +210,12 @@ class acp_database
confirm_box(false, $user->lang['DELETE_SELECTED_BACKUP'], build_hidden_fields(array('delete' => $delete, 'file' => $file)));
}
}
- else if ($download || confirm_box(true))
+ else if (confirm_box(true))
{
- if ($download)
- {
- $name = $matches[0];
-
- switch ($matches[1])
- {
- case 'sql':
- $mimetype = 'text/x-sql';
- break;
- case 'sql.bz2':
- $mimetype = 'application/x-bzip2';
- break;
- case 'sql.gz':
- $mimetype = 'application/x-gzip';
- break;
- }
-
- header('Cache-Control: private, no-cache');
- header("Content-Type: $mimetype; name=\"$name\"");
- header("Content-disposition: attachment; filename=$name");
-
- @set_time_limit(0);
-
- $fp = @fopen($file_name, 'rb');
-
- if ($fp !== false)
- {
- while (!feof($fp))
- {
- echo fread($fp, 8192);
- }
- fclose($fp);
- }
-
- flush();
- exit;
- }
-
- switch ($matches[1])
+ switch ($backup_info['extension'])
{
case 'sql':
- $fp = fopen($file_name, 'rb');
+ $fp = fopen($backup_info['file_name'], 'rb');
$read = 'fread';
$seek = 'fseek';
$eof = 'feof';
@@ -280,7 +224,7 @@ class acp_database
break;
case 'sql.bz2':
- $fp = bzopen($file_name, 'r');
+ $fp = bzopen($backup_info['file_name'], 'r');
$read = 'bzread';
$seek = '';
$eof = 'feof';
@@ -289,13 +233,17 @@ class acp_database
break;
case 'sql.gz':
- $fp = gzopen($file_name, 'rb');
+ $fp = gzopen($backup_info['file_name'], 'rb');
$read = 'gzread';
$seek = 'gzseek';
$eof = 'gzeof';
$close = 'gzclose';
$fgetd = 'fgetd';
break;
+
+ default:
+ trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
+ return;
}
switch ($db->get_sql_layer())
@@ -375,43 +323,13 @@ class acp_database
trigger_error($user->lang['RESTORE_SUCCESS'] . adm_back_link($this->u_action));
break;
}
- else if (!$download)
+ else
{
confirm_box(false, $user->lang['RESTORE_SELECTED_BACKUP'], build_hidden_fields(array('file' => $file)));
}
default:
- $methods = array('sql');
- $available_methods = array('sql.gz' => 'zlib', 'sql.bz2' => 'bz2');
-
- foreach ($available_methods as $type => $module)
- {
- if (!@extension_loaded($module))
- {
- continue;
- }
- $methods[] = $type;
- }
-
- $dir = $phpbb_root_path . 'store/';
- $dh = @opendir($dir);
-
- $backup_files = array();
-
- if ($dh)
- {
- while (($file = readdir($dh)) !== false)
- {
- if (preg_match('#^backup_(\d{10,})_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches))
- {
- if (in_array($matches[2], $methods))
- {
- $backup_files[(int) $matches[1]] = $file;
- }
- }
- }
- closedir($dh);
- }
+ $backup_files = $this->get_file_list($phpbb_root_path . 'store/');
if (!empty($backup_files))
{
@@ -420,8 +338,8 @@ class acp_database
foreach ($backup_files as $name => $file)
{
$template->assign_block_vars('files', array(
- 'FILE' => $file,
- 'NAME' => $user->format_date($name, 'd-m-Y H:i:s', true),
+ 'FILE' => sha1($file),
+ 'NAME' => $user->format_date($name, 'd-m-Y H:i', true),
'SUPPORTED' => true,
));
}
@@ -435,6 +353,92 @@ class acp_database
break;
}
}
+
+ /**
+ * Get backup file from file hash
+ *
+ * @param string $directory Relative path to directory
+ * @param string $file_hash Hash of selected file
+ *
+ * @return array Backup file data or empty array if unable to find file
+ */
+ protected function get_backup_file($directory, $file_hash)
+ {
+ $backup_data = [];
+
+ $file_list = $this->get_file_list($directory);
+ $supported_extensions = $this->get_supported_extensions();
+
+ foreach ($file_list as $file)
+ {
+ preg_match('#^backup_(\d{10,})_(?:[a-z\d]{16}|[a-z\d]{32})\.(sql(?:\.(?:gz|bz2))?)$#i', $file, $matches);
+ if (sha1($file) === $file_hash && in_array($matches[2], $supported_extensions))
+ {
+ $backup_data = [
+ 'file_name' => $directory . $file,
+ 'extension' => $matches[2],
+ ];
+ break;
+ }
+ }
+
+ return $backup_data;
+ }
+
+ /**
+ * Get backup file list for directory
+ *
+ * @param string $directory Relative path to backup directory
+ *
+ * @return array List of backup files in specified directory
+ */
+ protected function get_file_list($directory)
+ {
+ $supported_extensions = $this->get_supported_extensions();
+
+ $dh = @opendir($directory);
+
+ $backup_files = [];
+
+ if ($dh)
+ {
+ while (($file = readdir($dh)) !== false)
+ {
+ if (preg_match('#^backup_(\d{10,})_(?:[a-z\d]{16}|[a-z\d]{32})\.(sql(?:\.(?:gz|bz2))?)$#i', $file, $matches))
+ {
+ if (in_array($matches[2], $supported_extensions))
+ {
+ $backup_files[(int) $matches[1]] = $file;
+ }
+ }
+ }
+ closedir($dh);
+ }
+
+ return $backup_files;
+ }
+
+ /**
+ * Get supported extensions for backup
+ *
+ * @return array List of supported extensions
+ */
+ protected function get_supported_extensions()
+ {
+ $extensions = ['sql'];
+ $available_methods = ['sql.gz' => 'zlib', 'sql.bz2' => 'bz2'];
+
+ foreach ($available_methods as $type => $module)
+ {
+ if (!@extension_loaded($module))
+ {
+ continue;
+ }
+ $extensions[] = $type;
+ }
+
+ return $extensions;
+ }
}
// get how much space we allow for a chunk of data, very similar to phpMyAdmin's way of doing things ;-) (hey, we only do this for MySQL anyway :P)
@@ -495,7 +499,7 @@ function sanitize_data_mssql($text)
{
$val[] = "'" . $value . "'";
}
- if (sizeof($matches[0]))
+ if (count($matches[0]))
{
$val[] = 'char(' . ord(array_shift($matches[0])) . ')';
}
@@ -519,7 +523,7 @@ function sanitize_data_oracle($text)
{
$val[] = "'" . $value . "'";
}
- if (sizeof($matches[0]))
+ if (count($matches[0]))
{
$val[] = 'chr(' . ord(array_shift($matches[0])) . ')';
}
@@ -541,7 +545,7 @@ function sanitize_data_generic($text)
{
$val[] = "'" . $value . "'";
}
- if (sizeof($matches[0]))
+ if (count($matches[0]))
{
$val[] = "'" . array_shift($matches[0]) . "'";
}
@@ -583,7 +587,7 @@ function fgetd_seekless(&$fp, $delim, $read, $seek, $eof, $buffer = 8192)
static $array = array();
static $record = '';
- if (!sizeof($array))
+ if (!count($array))
{
while (!$eof($fp))
{
@@ -605,7 +609,7 @@ function fgetd_seekless(&$fp, $delim, $read, $seek, $eof, $buffer = 8192)
}
}
- if (sizeof($array))
+ if (count($array))
{
return array_shift($array);
}
diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php
index 57eefad02d..5a1fbac9f6 100644
--- a/phpBB/includes/acp/acp_email.php
+++ b/phpBB/includes/acp/acp_email.php
@@ -68,7 +68,7 @@ class acp_email
$error[] = $user->lang['NO_EMAIL_MESSAGE'];
}
- if (!sizeof($error))
+ if (!count($error))
{
if (!empty($usernames))
{
@@ -168,7 +168,7 @@ class acp_email
{
$i = 0;
- if (sizeof($email_list))
+ if (count($email_list))
{
$j++;
}
@@ -235,16 +235,16 @@ class acp_email
);
extract($phpbb_dispatcher->trigger_event('core.acp_email_send_before', compact($vars)));
- for ($i = 0, $size = sizeof($email_list); $i < $size; $i++)
+ for ($i = 0, $size = count($email_list); $i < $size; $i++)
{
$used_lang = $email_list[$i][0]['lang'];
$used_method = $email_list[$i][0]['method'];
- for ($j = 0, $list_size = sizeof($email_list[$i]); $j < $list_size; $j++)
+ for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
{
$email_row = $email_list[$i][$j];
- $messenger->{((sizeof($email_list[$i]) == 1) ? 'to' : 'bcc')}($email_row['email'], $email_row['name']);
+ $messenger->{((count($email_list[$i]) == 1) ? 'to' : 'bcc')}($email_row['email'], $email_row['name']);
$messenger->im($email_row['jabber'], $email_row['name']);
}
@@ -322,8 +322,8 @@ class acp_email
$s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
$template_data = array(
- 'S_WARNING' => (sizeof($error)) ? true : false,
- 'WARNING_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'S_WARNING' => (count($error)) ? true : false,
+ 'WARNING_MSG' => (count($error)) ? implode('<br />', $error) : '',
'U_ACTION' => $this->u_action,
'S_GROUP_OPTIONS' => $select_list,
'USERNAMES' => implode("\n", $usernames),
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index 6f65dc9fa0..a1cb2108e7 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -35,11 +35,13 @@ class acp_extensions
private $request;
private $phpbb_dispatcher;
private $ext_manager;
+ private $phpbb_container;
+ private $php_ini;
function main()
{
// Start the page
- global $config, $user, $template, $request, $phpbb_extension_manager, $phpbb_root_path, $phpbb_log, $phpbb_dispatcher;
+ global $config, $user, $template, $request, $phpbb_extension_manager, $phpbb_root_path, $phpbb_log, $phpbb_dispatcher, $phpbb_container;
$this->config = $config;
$this->template = $template;
@@ -48,6 +50,8 @@ class acp_extensions
$this->log = $phpbb_log;
$this->phpbb_dispatcher = $phpbb_dispatcher;
$this->ext_manager = $phpbb_extension_manager;
+ $this->phpbb_container = $phpbb_container;
+ $this->php_ini = $this->phpbb_container->get('php_ini');
$this->user->add_lang(array('install', 'acp/extensions', 'migrator'));
@@ -57,7 +61,7 @@ class acp_extensions
$ext_name = $this->request->variable('ext_name', '');
// What is a safe limit of execution time? Half the max execution time should be safe.
- $safe_time_limit = (ini_get('max_execution_time') / 2);
+ $safe_time_limit = ($this->php_ini->getNumeric('max_execution_time') / 2);
$start_time = time();
// Cancel action
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index 66bb630241..cb0593b14a 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -90,7 +90,7 @@ class acp_forums
$errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id);
- if (sizeof($errors))
+ if (count($errors))
{
break;
}
@@ -198,7 +198,7 @@ class acp_forums
$errors = $this->update_forum_data($forum_data);
- if (!sizeof($errors))
+ if (!count($errors))
{
$forum_perm_from = $request->variable('forum_perm_from', 0);
$cache->destroy('sql', FORUMS_TABLE);
@@ -622,7 +622,7 @@ class acp_forums
$template_data = array(
'S_EDIT_FORUM' => true,
- 'S_ERROR' => (sizeof($errors)) ? true : false,
+ 'S_ERROR' => (count($errors)) ? true : false,
'S_PARENT_ID' => $this->parent_id,
'S_FORUM_PARENT_ID' => $forum_data['parent_id'],
'S_ADD_ACTION' => ($action == 'add') ? true : false,
@@ -632,7 +632,7 @@ class acp_forums
'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'],
'L_TITLE' => $user->lang[$this->page_title],
- 'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',
+ 'ERROR_MSG' => (count($errors)) ? implode('<br />', $errors) : '',
'FORUM_NAME' => $forum_data['forum_name'],
'FORUM_DATA_LINK' => $forum_data['forum_link'],
@@ -772,8 +772,8 @@ class acp_forums
'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false,
'S_FORUMS_LIST' => $forums_list,
- 'S_ERROR' => (sizeof($errors)) ? true : false,
- 'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '')
+ 'S_ERROR' => (count($errors)) ? true : false,
+ 'ERROR_MSG' => (count($errors)) ? implode('<br />', $errors) : '')
);
return;
@@ -924,7 +924,7 @@ class acp_forums
unset($rowset);
$template->assign_vars(array(
- 'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',
+ 'ERROR_MSG' => (count($errors)) ? implode('<br />', $errors) : '',
'NAVIGATION' => $navigation,
'FORUM_BOX' => $forum_box,
'U_SEL_ACTION' => $this->u_action,
@@ -986,6 +986,13 @@ class acp_forums
$errors[] = $user->lang['FORUM_NAME_EMPTY'];
}
+ // No Emojis
+ if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $forum_data_ary['forum_name'], $matches))
+ {
+ $character_list = implode('<br>', $matches[0]);
+ $errors[] = $user->lang('FORUM_NAME_EMOJI', $character_list);
+ }
+
if (utf8_strlen($forum_data_ary['forum_desc']) > 4000)
{
$errors[] = $user->lang['FORUM_DESC_TOO_LONG'];
@@ -1012,7 +1019,7 @@ class acp_forums
}
$range_test_ary = array(
- array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data_ary['forum_topics_per_page'], 'column_type' => 'TINT:0'),
+ array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data_ary['forum_topics_per_page'], 'column_type' => 'USINT:0'),
);
if (!empty($forum_data_ary['forum_image']) && !file_exists($phpbb_root_path . $forum_data_ary['forum_image']))
@@ -1053,7 +1060,7 @@ class acp_forums
// What are we going to do tonight Brain? The same thing we do everynight,
// try to take over the world ... or decide whether to continue update
// and if so, whether it's a new forum/cat/link or an existing one
- if (sizeof($errors))
+ if (count($errors))
{
return $errors;
}
@@ -1217,12 +1224,12 @@ class acp_forums
$errors = array_merge($errors, $this->delete_forum_content($_row['forum_id']));
}
- if (sizeof($errors))
+ if (count($errors))
{
return $errors;
}
- if (sizeof($forum_ids))
+ if (count($forum_ids))
{
$sql = 'DELETE FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
@@ -1252,7 +1259,7 @@ class acp_forums
$allowed_forums = array_diff($allowed_forums, $forum_ids);
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
- SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "'
+ SET allowed_forums = '" . ((count($allowed_forums)) ? serialize($allowed_forums) : '') . "'
WHERE group_id = {$_row['group_id']}";
$db->sql_query($sql);
}
@@ -1321,7 +1328,7 @@ class acp_forums
$forum_data_sql['forum_last_poster_colour'] = '';
}
- if (sizeof($errors))
+ if (count($errors))
{
return $errors;
}
@@ -1338,7 +1345,7 @@ class acp_forums
}
}
- if (sizeof($errors))
+ if (count($errors))
{
return $errors;
}
@@ -1431,12 +1438,14 @@ class acp_forums
return $errors;
}
+ $db->sql_transaction('begin');
+
$moved_forums = get_forum_branch($from_id, 'children', 'descending');
$from_data = $moved_forums[0];
- $diff = sizeof($moved_forums) * 2;
+ $diff = count($moved_forums) * 2;
$moved_ids = array();
- for ($i = 0, $size = sizeof($moved_forums); $i < $size; ++$i)
+ for ($i = 0, $size = count($moved_forums); $i < $size; ++$i)
{
$moved_ids[] = $moved_forums[$i]['forum_id'];
}
@@ -1502,6 +1511,8 @@ class acp_forums
WHERE " . $db->sql_in_set('forum_id', $moved_ids);
$db->sql_query($sql);
+ $db->sql_transaction('commit');
+
return $errors;
}
@@ -1537,6 +1548,16 @@ class acp_forums
$table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
+ /**
+ * Perform additional actions before move forum content
+ *
+ * @event core.acp_manage_forums_move_content_sql_before
+ * @var array table_ary Array of tables from which forum_id will be updated
+ * @since 3.2.4-RC1
+ */
+ $vars = array('table_ary');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content_sql_before', compact($vars)));
+
foreach ($table_ary as $table)
{
$sql = "UPDATE $table
@@ -1612,7 +1633,7 @@ class acp_forums
}
}
- if (sizeof($errors))
+ if (count($errors))
{
return $errors;
}
@@ -1628,12 +1649,12 @@ class acp_forums
$errors = array_merge($errors, $this->delete_forum_content($row['forum_id']));
}
- if (sizeof($errors))
+ if (count($errors))
{
return $errors;
}
- $diff = sizeof($forum_ids) * 2;
+ $diff = count($forum_ids) * 2;
$sql = 'DELETE FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
@@ -1706,7 +1727,7 @@ class acp_forums
}
}
- if (sizeof($errors))
+ if (count($errors))
{
return $errors;
}
@@ -1754,7 +1775,7 @@ class acp_forums
$allowed_forums = array_diff($allowed_forums, $forum_ids);
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
- SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "'
+ SET allowed_forums = '" . ((count($allowed_forums)) ? serialize($allowed_forums) : '') . "'
WHERE group_id = {$row['group_id']}";
$db->sql_query($sql);
}
@@ -1927,9 +1948,9 @@ class acp_forums
}
$db->sql_freeresult($result);
- if (sizeof($ids))
+ if (count($ids))
{
- $start += sizeof($ids);
+ $start += count($ids);
foreach ($tables as $table)
{
@@ -1937,7 +1958,7 @@ class acp_forums
}
}
}
- while (sizeof($ids) == $batch_size);
+ while (count($ids) == $batch_size);
}
unset($ids);
@@ -1978,7 +1999,7 @@ class acp_forums
}
// Adjust users post counts
- if (sizeof($post_counts))
+ if (count($post_counts))
{
foreach ($post_counts as $poster_id => $substract)
{
@@ -2062,7 +2083,7 @@ class acp_forums
}
$db->sql_freeresult($result);
- if (!sizeof($target))
+ if (!count($target))
{
// The forum is already on top or bottom
return false;
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index 305296d013..7b1dc706db 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -29,6 +29,9 @@ class acp_groups
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
global $request, $phpbb_container, $phpbb_dispatcher;
+ /** @var \phpbb\language\language $language Language object */
+ $language = $phpbb_container->get('language');
+
$user->add_lang('acp/groups');
$this->tpl_name = 'acp_groups';
$this->page_title = 'ACP_GROUPS_MANAGE';
@@ -187,7 +190,7 @@ class acp_groups
group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
- $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200;
+ $start = (count($mark_ary) < 200) ? 0 : $start + 200;
}
else
{
@@ -293,7 +296,19 @@ class acp_groups
// Add user/s to group
if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, $leader, 0, $group_row))
{
- trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
+ $display_message = $language->lang($error);
+
+ if ($error == 'GROUP_USERS_INVALID')
+ {
+ // Find which users don't exist
+ $actual_name_ary = $name_ary;
+ $actual_user_id_ary = [];
+ user_get_id_name($actual_user_id_ary, $actual_name_ary, false, true);
+
+ $display_message = $language->lang('GROUP_USERS_INVALID', implode($language->lang('COMMA_SEPARATOR'), array_udiff($name_ary, $actual_name_ary, 'strcasecmp')));
+ }
+
+ trigger_error($display_message . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
}
$message = ($leader) ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED';
@@ -486,7 +501,7 @@ class acp_groups
$error = array_merge($error, $validation_error);
}
- if (!sizeof($error))
+ if (!count($error))
{
// Only set the rank, colour, etc. if it's changed or if we're adding a new
// group. This prevents existing group members being updated if no changes
@@ -614,7 +629,7 @@ class acp_groups
}
}
- if (sizeof($error))
+ if (count($error))
{
$error = array_map(array(&$user, 'lang'), $error);
$group_rank = $submit_ary['rank'];
@@ -732,12 +747,12 @@ class acp_groups
'S_ADD_GROUP' => ($action == 'add') ? true : false,
'S_GROUP_PERM' => ($action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) ? true : false,
'S_INCLUDE_SWATCH' => true,
- 'S_ERROR' => (sizeof($error)) ? true : false,
+ 'S_ERROR' => (count($error)) ? true : false,
'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false,
'S_USER_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled),
- 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR_MSG' => (count($error)) ? implode('<br />', $error) : '',
'GROUP_NAME' => $group_helper->get_name($group_name),
'GROUP_INTERNAL_NAME' => $group_name,
'GROUP_DESC' => $group_desc_data['text'],
@@ -926,7 +941,7 @@ class acp_groups
);
// Get us all the groups
- $sql = 'SELECT g.group_id, g.group_name, g.group_type
+ $sql = 'SELECT g.group_id, g.group_name, g.group_type, g.group_colour
FROM ' . GROUPS_TABLE . ' g
ORDER BY g.group_type ASC, g.group_name';
$result = $db->sql_query($sql);
@@ -985,6 +1000,7 @@ class acp_groups
'S_GROUP_SPECIAL' => ($row['group_type'] == GROUP_SPECIAL) ? true : false,
'GROUP_NAME' => $group_name,
+ 'GROUP_COLOR' => $row['group_colour'],
'TOTAL_MEMBERS' => $row['total_members'],
'PENDING_MEMBERS' => $row['pending_members']
));
diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php
index 7991a0dad6..a36b36eddc 100644
--- a/phpBB/includes/acp/acp_help_phpbb.php
+++ b/phpBB/includes/acp/acp_help_phpbb.php
@@ -48,7 +48,7 @@ class acp_help_phpbb
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
- if (sizeof($error))
+ if (count($error))
{
$submit = false;
}
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php
index 6cd5386857..2c3948f644 100644
--- a/phpBB/includes/acp/acp_icons.php
+++ b/phpBB/includes/acp/acp_icons.php
@@ -166,7 +166,7 @@ class acp_icons
}
$db->sql_freeresult($result);
- if (sizeof($smilies))
+ if (count($smilies))
{
foreach ($smilies as $row)
{
@@ -301,7 +301,7 @@ class acp_icons
}
// Ok, another row for adding an addition code for a pre-existing image...
- if ($action == 'add' && $mode == 'smilies' && sizeof($smilies))
+ if ($action == 'add' && $mode == 'smilies' && count($smilies))
{
$template->assign_vars(array(
'S_ADD_CODE' => true,
@@ -378,7 +378,7 @@ class acp_icons
{
$smiley_count = $this->item_count($table);
- $addable_smileys_count = sizeof($images);
+ $addable_smileys_count = count($images);
foreach ($images as $image)
{
if (!isset($image_add[$image]))
@@ -546,8 +546,8 @@ class acp_icons
{
if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data))
{
- if ((sizeof($data[1]) != 4 && $mode == 'icons') ||
- ((sizeof($data[1]) != 6 || (empty($data[1][4]) || empty($data[1][5]))) && $mode == 'smilies' ))
+ if ((count($data[1]) != 4 && $mode == 'icons') ||
+ ((count($data[1]) != 6 || (empty($data[1][4]) || empty($data[1][5]))) && $mode == 'smilies' ))
{
trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -605,7 +605,7 @@ class acp_icons
if ($mode == 'smilies')
{
$smiley_count = $this->item_count($table);
- if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT)
+ if ($smiley_count + count($pak_ary) > SMILEY_LIMIT)
{
trigger_error($user->lang('TOO_MANY_SMILIES', SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -616,8 +616,8 @@ class acp_icons
$data = array();
if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data))
{
- if ((sizeof($data[1]) != 4 && $mode == 'icons') ||
- (sizeof($data[1]) != 6 && $mode == 'smilies'))
+ if ((count($data[1]) != 4 && $mode == 'icons') ||
+ (count($data[1]) != 6 && $mode == 'smilies'))
{
trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php
index ec256e93ef..4ee4cd4816 100644
--- a/phpBB/includes/acp/acp_inactive.php
+++ b/phpBB/includes/acp/acp_inactive.php
@@ -24,9 +24,9 @@ class acp_inactive
var $u_action;
var $p_master;
- function acp_inactive(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
@@ -70,7 +70,7 @@ class acp_inactive
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
- if ($submit && sizeof($mark))
+ if ($submit && count($mark))
{
if ($action !== 'delete' && !check_form_key($form_key))
{
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index 4baff921b6..8881f624e3 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -32,7 +32,7 @@ class acp_language
function main($id, $mode)
{
global $config, $db, $user, $template, $phpbb_log, $phpbb_container;
- global $phpbb_root_path, $phpEx, $request;
+ global $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher;
if (!function_exists('validate_language_iso_name'))
{
@@ -229,7 +229,20 @@ class acp_language
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_DELETED', false, array($row['lang_english_name']));
- trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action));
+ $delete_message = sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']);
+ $lang_iso = $row['lang_iso'];
+ /**
+ * Run code after language deleted
+ *
+ * @event core.acp_language_after_delete
+ * @var string lang_iso Language ISO code
+ * @var string delete_message Delete message appear to user
+ * @since 3.2.2-RC1
+ */
+ $vars = array('lang_iso', 'delete_message');
+ extract($phpbb_dispatcher->trigger_event('core.acp_language_after_delete', compact($vars)));
+
+ trigger_error($delete_message . adm_back_link($this->u_action));
}
else
{
@@ -402,7 +415,7 @@ class acp_language
unset($installed);
- if (sizeof($new_ary))
+ if (count($new_ary))
{
foreach ($new_ary as $iso => $lang_ary)
{
diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php
index c33ca8c4fc..f9bb35791c 100644
--- a/phpBB/includes/acp/acp_logs.php
+++ b/phpBB/includes/acp/acp_logs.php
@@ -57,7 +57,7 @@ class acp_logs
{
$conditions = array();
- if ($deletemark && sizeof($marked))
+ if ($deletemark && count($marked))
{
$conditions['log_id'] = array('IN' => $marked);
}
@@ -151,7 +151,7 @@ class acp_logs
{
$data = array();
- $checks = array('viewtopic', 'viewlogs', 'viewforum');
+ $checks = array('viewpost', 'viewtopic', 'viewlogs', 'viewforum');
foreach ($checks as $check)
{
if (isset($row[$check]) && $row[$check])
@@ -167,7 +167,7 @@ class acp_logs
'IP' => $row['ip'],
'DATE' => $user->format_date($row['time']),
'ACTION' => $row['action'],
- 'DATA' => (sizeof($data)) ? implode(' | ', $data) : '',
+ 'DATA' => (count($data)) ? implode(' | ', $data) : '',
'ID' => $row['id'],
)
);
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index 9b1a248923..8f169d15a7 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -337,7 +337,7 @@ class acp_main
}
unset($posted);
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
}
@@ -585,6 +585,7 @@ class acp_main
'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&amp;mode=list'),
'U_VERSIONCHECK' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=update&amp;mode=version_check'),
'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.$phpEx", 'versioncheck_force=1'),
+ 'U_ATTACH_ORPHAN' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=acp_attachments&mode=orphan'),
'S_VERSIONCHECK' => ($auth->acl_get('a_board')) ? true : false,
'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false,
diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php
index 4d90b2da8b..fb0c09055e 100644
--- a/phpBB/includes/acp/acp_modules.php
+++ b/phpBB/includes/acp/acp_modules.php
@@ -249,7 +249,7 @@ class acp_modules
trigger_error($msg . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
}
- if (!sizeof($errors))
+ if (!count($errors))
{
$module_manager->remove_cache_file($this->module_class);
@@ -364,7 +364,7 @@ class acp_modules
trigger_error($msg . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
}
- if (!sizeof($errors))
+ if (!count($errors))
{
$module_manager->remove_cache_file($this->module_class);
@@ -430,7 +430,7 @@ class acp_modules
array_change_key_case($module_data, CASE_UPPER))
);
- if (sizeof($errors))
+ if (count($errors))
{
$template->assign_vars(array(
'S_ERROR' => true,
@@ -444,7 +444,7 @@ class acp_modules
}
// Default management page
- if (sizeof($errors))
+ if (count($errors))
{
if ($request->is_ajax())
{
diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php
index 0bfe67830f..80cad9915d 100644
--- a/phpBB/includes/acp/acp_permission_roles.php
+++ b/phpBB/includes/acp/acp_permission_roles.php
@@ -348,7 +348,7 @@ class acp_permission_roles
{
$hold_ary = $this->auth_admin->get_role_mask($role_id);
- if (sizeof($hold_ary))
+ if (count($hold_ary))
{
$role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name'];
@@ -496,7 +496,7 @@ class acp_permission_roles
$content_array = $content_array[0];
- $template->assign_var('S_NUM_PERM_COLS', sizeof($categories));
+ $template->assign_var('S_NUM_PERM_COLS', count($categories));
// Assign to template
foreach ($content_array as $cat => $cat_array)
diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php
index 12c43bf94c..e683b1972e 100644
--- a/phpBB/includes/acp/acp_permissions.php
+++ b/phpBB/includes/acp/acp_permissions.php
@@ -131,11 +131,11 @@ class acp_permissions
}
unset($usernames);
- if (sizeof($username) && !sizeof($user_id))
+ if (count($username) && !count($user_id))
{
user_get_id_name($user_id, $username);
- if (!sizeof($user_id))
+ if (!count($user_id))
{
trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -260,17 +260,17 @@ class acp_permissions
{
$items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type);
- if ($all_users && sizeof($items['user_ids']))
+ if ($all_users && count($items['user_ids']))
{
$user_id = $items['user_ids'];
}
- else if ($all_groups && sizeof($items['group_ids']))
+ else if ($all_groups && count($items['group_ids']))
{
$group_id = $items['group_ids'];
}
}
- if (sizeof($user_id) || sizeof($group_id))
+ if (count($user_id) || count($group_id))
{
$this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id);
}
@@ -349,7 +349,7 @@ class acp_permissions
{
case 'forum_dropdown':
- if (sizeof($forum_id))
+ if (count($forum_id))
{
$this->check_existence('forum', $forum_id);
continue 2;
@@ -364,7 +364,7 @@ class acp_permissions
case 'forums':
- if (sizeof($forum_id))
+ if (count($forum_id))
{
$this->check_existence('forum', $forum_id);
continue 2;
@@ -394,7 +394,7 @@ class acp_permissions
case 'user':
- if (sizeof($user_id))
+ if (count($user_id))
{
$this->check_existence('user', $user_id);
continue 2;
@@ -409,7 +409,7 @@ class acp_permissions
case 'group':
- if (sizeof($group_id))
+ if (count($group_id))
{
$this->check_existence('group', $group_id);
continue 2;
@@ -428,14 +428,14 @@ class acp_permissions
$all_users = (isset($_POST['all_users'])) ? true : false;
$all_groups = (isset($_POST['all_groups'])) ? true : false;
- if ((sizeof($user_id) && !$all_users) || (sizeof($group_id) && !$all_groups))
+ if ((count($user_id) && !$all_users) || (count($group_id) && !$all_groups))
{
- if (sizeof($user_id))
+ if (count($user_id))
{
$this->check_existence('user', $user_id);
}
- if (sizeof($group_id))
+ if (count($group_id))
{
$this->check_existence('group', $group_id);
}
@@ -446,13 +446,13 @@ class acp_permissions
// Now we check the users... because the "all"-selection is different here (all defined users/groups)
$items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type);
- if ($all_users && sizeof($items['user_ids']))
+ if ($all_users && count($items['user_ids']))
{
$user_id = $items['user_ids'];
continue 2;
}
- if ($all_groups && sizeof($items['group_ids']))
+ if ($all_groups && count($items['group_ids']))
{
$group_id = $items['group_ids'];
continue 2;
@@ -487,14 +487,14 @@ class acp_permissions
'ANONYMOUS_USER_ID' => ANONYMOUS,
'S_SELECT_VICTIM' => true,
- 'S_ALLOW_ALL_SELECT' => (sizeof($forum_id) > 5) ? false : true,
+ 'S_ALLOW_ALL_SELECT' => (count($forum_id) > 5) ? false : true,
'S_CAN_SELECT_USER' => ($auth->acl_get('a_authusers')) ? true : false,
'S_CAN_SELECT_GROUP' => ($auth->acl_get('a_authgroups')) ? true : false,
'S_HIDDEN_FIELDS' => $s_hidden_fields)
);
// Let the forum names being displayed
- if (sizeof($forum_id))
+ if (count($forum_id))
{
$sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . '
@@ -510,7 +510,7 @@ class acp_permissions
$db->sql_freeresult($result);
$template->assign_vars(array(
- 'S_FORUM_NAMES' => (sizeof($forum_names)) ? true : false,
+ 'S_FORUM_NAMES' => (count($forum_names)) ? true : false,
'FORUM_NAMES' => implode($user->lang['COMMA_SEPARATOR'], $forum_names))
);
}
@@ -527,13 +527,13 @@ class acp_permissions
));
// Do not allow forum_ids being set and no other setting defined (will bog down the server too much)
- if (sizeof($forum_id) && !sizeof($user_id) && !sizeof($group_id))
+ if (count($forum_id) && !count($user_id) && !count($group_id))
{
trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$template->assign_vars(array(
- 'S_PERMISSION_DROPDOWN' => (sizeof($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false,
+ 'S_PERMISSION_DROPDOWN' => (count($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false,
'L_PERMISSION_TYPE' => $this->permissions->get_type_lang($permission_type),
'U_ACTION' => $this->u_action,
@@ -546,8 +546,8 @@ class acp_permissions
'S_SETTING_PERMISSIONS' => true)
);
- $hold_ary = $auth_admin->get_mask('set', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO);
- $auth_admin->display_mask('set', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false));
+ $hold_ary = $auth_admin->get_mask('set', (count($user_id)) ? $user_id : false, (count($group_id)) ? $group_id : false, (count($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO);
+ $auth_admin->display_mask('set', $permission_type, $hold_ary, ((count($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false));
}
else
{
@@ -555,8 +555,8 @@ class acp_permissions
'S_VIEWING_PERMISSIONS' => true)
);
- $hold_ary = $auth_admin->get_mask('view', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER);
- $auth_admin->display_mask('view', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false));
+ $hold_ary = $auth_admin->get_mask('view', (count($user_id)) ? $user_id : false, (count($group_id)) ? $group_id : false, (count($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER);
+ $auth_admin->display_mask('view', $permission_type, $hold_ary, ((count($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false));
}
}
@@ -652,7 +652,7 @@ class acp_permissions
break;
}
- if (sizeof($ids))
+ if (count($ids))
{
$sql = "SELECT $sql_id
FROM $table
@@ -667,7 +667,7 @@ class acp_permissions
$db->sql_freeresult($result);
}
- if (!sizeof($ids))
+ if (!count($ids))
{
trigger_error($user->lang['SELECTED_' . strtoupper($mode) . '_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -676,7 +676,7 @@ class acp_permissions
/**
* Apply permissions
*/
- function set_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
+ function set_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id)
{
global $db, $cache, $user, $auth;
global $request;
@@ -684,7 +684,7 @@ class acp_permissions
$psubmit = $request->variable('psubmit', array(0 => array(0 => 0)));
// User or group to be set?
- $ug_type = (sizeof($user_id)) ? 'user' : 'group';
+ $ug_type = (count($user_id)) ? 'user' : 'group';
// Check the permission setting again
if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's'))
@@ -715,7 +715,7 @@ class acp_permissions
$ug_id = array($ug_id);
$forum_id = array($forum_id);
- if (sizeof($inherit))
+ if (count($inherit))
{
foreach ($inherit as $_ug_id => $forum_id_ary)
{
@@ -765,13 +765,13 @@ class acp_permissions
/**
* Apply all permissions
*/
- function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
+ function set_all_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id)
{
global $db, $cache, $user, $auth;
global $request;
// User or group to be set?
- $ug_type = (sizeof($user_id)) ? 'user' : 'group';
+ $ug_type = (count($user_id)) ? 'user' : 'group';
// Check the permission setting again
if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's'))
@@ -870,7 +870,7 @@ class acp_permissions
}
}
- if (sizeof(array_diff_assoc($auth_settings, $test_auth_settings)))
+ if (count(array_diff_assoc($auth_settings, $test_auth_settings)))
{
return false;
}
@@ -881,12 +881,12 @@ class acp_permissions
/**
* Remove permissions
*/
- function remove_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id, &$forum_id)
+ function remove_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id, &$forum_id)
{
global $user, $db, $cache, $auth;
// User or group to be set?
- $ug_type = (sizeof($user_id)) ? 'user' : 'group';
+ $ug_type = (count($user_id)) ? 'user' : 'group';
// Check the permission setting again
if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's'))
@@ -895,7 +895,7 @@ class acp_permissions
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
- $auth_admin->acl_delete($ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : false), $permission_type);
+ $auth_admin->acl_delete($ug_type, (($ug_type == 'user') ? $user_id : $group_id), (count($forum_id) ? $forum_id : false), $permission_type);
// Do we need to recache the moderator lists?
if ($permission_type == 'm_')
@@ -903,7 +903,7 @@ class acp_permissions
phpbb_cache_moderators($db, $cache, $auth);
}
- $this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : array(0 => 0)));
+ $this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (count($forum_id) ? $forum_id : array(0 => 0)));
if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local')
{
@@ -1053,7 +1053,7 @@ class acp_permissions
$total = ACL_NO;
$add_key = (($forum_id) ? '_LOCAL' : '');
- if (sizeof($groups))
+ if (count($groups))
{
// Get group auth settings
$hold_ary = $auth->acl_group_raw_data(array_keys($groups), $permission, $forum_id);
@@ -1099,7 +1099,7 @@ class acp_permissions
// Get user specific permission... globally or for this forum
$hold_ary = $auth->acl_user_raw_data($user_id, $permission, $forum_id);
- $auth_setting = (!sizeof($hold_ary)) ? ACL_NO : $hold_ary[$user_id][$forum_id][$permission];
+ $auth_setting = (!count($hold_ary)) ? ACL_NO : $hold_ary[$user_id][$forum_id][$permission];
switch ($auth_setting)
{
@@ -1258,7 +1258,7 @@ class acp_permissions
/** @var \phpbb\group\helper $group_helper */
$group_helper = $phpbb_container->get('group_helper');
- $sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((sizeof($forum_id)) ? 'AND ' . $db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0');
+ $sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((count($forum_id)) ? 'AND ' . $db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0');
// Permission options are only able to be a permission set... therefore we will pre-fetch the possible options and also the possible roles
$option_ids = $role_ids = array();
@@ -1274,7 +1274,7 @@ class acp_permissions
}
$db->sql_freeresult($result);
- if (sizeof($option_ids))
+ if (count($option_ids))
{
$sql = 'SELECT DISTINCT role_id
FROM ' . ACL_ROLES_DATA_TABLE . '
@@ -1288,15 +1288,15 @@ class acp_permissions
$db->sql_freeresult($result);
}
- if (sizeof($option_ids) && sizeof($role_ids))
+ if (count($option_ids) && count($role_ids))
{
$sql_where = 'AND (' . $db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . $db->sql_in_set('a.auth_role_id', $role_ids) . ')';
}
- else if (sizeof($role_ids))
+ else if (count($role_ids))
{
$sql_where = 'AND ' . $db->sql_in_set('a.auth_role_id', $role_ids);
}
- else if (sizeof($option_ids))
+ else if (count($option_ids))
{
$sql_where = 'AND ' . $db->sql_in_set('a.auth_option_id', $option_ids);
}
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index 18dde382ca..49da7d84a4 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -446,7 +446,7 @@ class acp_profile
{
$exploded_options = (is_array($options)) ? $options : explode("\n", $options);
- if (sizeof($exploded_options) == sizeof($lang_options) || $action == 'create')
+ if (count($exploded_options) == count($lang_options) || $action == 'create')
{
// The number of options in the field is equal to the number of options already in the database
// Or we are creating a new dropdown list.
@@ -567,7 +567,7 @@ class acp_profile
}
}
- if (sizeof($error))
+ if (count($error))
{
$submit = false;
}
@@ -600,9 +600,9 @@ class acp_profile
$s_hidden_fields .= build_hidden_fields($_new_key_ary);
}
- if (!sizeof($error))
+ if (!count($error))
{
- if (($step == 3 && (sizeof($this->lang_defs['iso']) == 1 || $save)) || ($action == 'edit' && $save))
+ if (($step == 3 && (count($this->lang_defs['iso']) == 1 || $save)) || ($action == 'edit' && $save))
{
if (!check_form_key($form_key))
{
@@ -616,7 +616,7 @@ class acp_profile
$template->assign_vars(array(
'S_EDIT' => true,
'S_EDIT_MODE' => ($action == 'edit') ? true : false,
- 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR_MSG' => (count($error)) ? implode('<br />', $error) : '',
'L_TITLE' => $user->lang['STEP_' . $step . '_TITLE_' . strtoupper($action)],
'L_EXPLAIN' => $user->lang['STEP_' . $step . '_EXPLAIN_' . strtoupper($action)],
@@ -664,7 +664,7 @@ class acp_profile
$template->assign_vars(array(
'S_STEP_TWO' => true,
- 'L_NEXT_STEP' => (sizeof($this->lang_defs['iso']) == 1) ? $user->lang['SAVE'] : $user->lang['PROFILE_LANG_OPTIONS'])
+ 'L_NEXT_STEP' => (count($this->lang_defs['iso']) == 1) ? $user->lang['SAVE'] : $user->lang['PROFILE_LANG_OPTIONS'])
);
// Build options based on profile type
@@ -738,6 +738,32 @@ class acp_profile
break;
}
+ $tpl_name = $this->tpl_name;
+ $page_title = $this->page_title;
+ $u_action = $this->u_action;
+
+ /**
+ * Event to handle actions on the ACP profile fields page
+ *
+ * @event core.acp_profile_action
+ * @var string action Action that is being performed
+ * @var string tpl_name Template file to load
+ * @var string page_title Page title
+ * @var string u_action The URL we are at, read only
+ * @since 3.2.2-RC1
+ */
+ $vars = array(
+ 'action',
+ 'tpl_name',
+ 'page_title',
+ 'u_action',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.acp_profile_action', compact($vars)));
+
+ $this->tpl_name = $tpl_name;
+ $this->page_title = $page_title;
+ unset($u_action);
+
$sql = 'SELECT *
FROM ' . PROFILE_FIELDS_TABLE . '
ORDER BY field_order';
@@ -750,7 +776,7 @@ class acp_profile
$active_value = (!$row['field_active']) ? 'activate' : 'deactivate';
$id = $row['field_id'];
- $s_need_edit = (sizeof($this->lang_defs['diff'][$row['field_id']])) ? true : false;
+ $s_need_edit = (count($this->lang_defs['diff'][$row['field_id']])) ? true : false;
if ($s_need_edit)
{
@@ -762,7 +788,8 @@ class acp_profile
continue;
}
$profile_field = $this->type_collection[$row['field_type']];
- $template->assign_block_vars('fields', array(
+
+ $field_block = array(
'FIELD_IDENT' => $row['field_ident'],
'FIELD_TYPE' => $profile_field->get_name(),
@@ -774,8 +801,26 @@ class acp_profile
'U_MOVE_UP' => $this->u_action . "&amp;action=move_up&amp;field_id=$id" . '&amp;hash=' . generate_link_hash('acp_profile'),
'U_MOVE_DOWN' => $this->u_action . "&amp;action=move_down&amp;field_id=$id" . '&amp;hash=' . generate_link_hash('acp_profile'),
- 'S_NEED_EDIT' => $s_need_edit)
+ 'S_NEED_EDIT' => $s_need_edit,
);
+
+ /**
+ * Event to modify profile field data before it is assigned to the template
+ *
+ * @event core.acp_profile_modify_profile_row
+ * @var array row Array with data for the current profile field
+ * @var array field_block Template data that is being assigned to the 'fields' block
+ * @var object profile_field A profile field instance, implements \phpbb\profilefields\type\type_base
+ * @since 3.2.2-RC1
+ */
+ $vars = array(
+ 'row',
+ 'field_block',
+ 'profile_field',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.acp_profile_modify_profile_row', compact($vars)));
+
+ $template->assign_block_vars('fields', $field_block);
}
$db->sql_freeresult($result);
@@ -800,7 +845,7 @@ class acp_profile
/**
* Build all Language specific options
*/
- function build_language_options(&$cp, $field_type, $action = 'create')
+ function build_language_options($cp, $field_type, $action = 'create')
{
global $user, $config, $db, $request;
@@ -897,7 +942,7 @@ class acp_profile
/**
* Save Profile Field
*/
- function save_profile_field(&$cp, $field_type, $action = 'create')
+ function save_profile_field($cp, $field_type, $action = 'create')
{
global $db, $config, $user, $phpbb_container, $phpbb_log, $request, $phpbb_dispatcher;
@@ -1011,7 +1056,7 @@ class acp_profile
$this->update_insert(PROFILE_LANG_TABLE, $sql_ary, array('field_id' => $field_id, 'lang_id' => $default_lang_id));
}
- if (is_array($cp->vars['l_lang_name']) && sizeof($cp->vars['l_lang_name']))
+ if (is_array($cp->vars['l_lang_name']) && count($cp->vars['l_lang_name']))
{
foreach ($cp->vars['l_lang_name'] as $lang_id => $data)
{
@@ -1087,7 +1132,7 @@ class acp_profile
}
}
- if (is_array($cp->vars['l_lang_options']) && sizeof($cp->vars['l_lang_options']))
+ if (is_array($cp->vars['l_lang_options']) && count($cp->vars['l_lang_options']))
{
$empty_lang = array();
@@ -1098,7 +1143,7 @@ class acp_profile
$lang_ary = explode("\n", $lang_ary);
}
- if (sizeof($lang_ary) != sizeof($cp->vars['lang_options']))
+ if (count($lang_ary) != count($cp->vars['lang_options']))
{
$empty_lang[$lang_id] = true;
}
@@ -1150,7 +1195,7 @@ class acp_profile
}
}
- if (sizeof($profile_lang_fields))
+ if (count($profile_lang_fields))
{
foreach ($profile_lang_fields as $sql)
{
@@ -1213,7 +1258,7 @@ class acp_profile
$where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . $db->sql_escape($value) . "'" : (int) $value);
}
- if (!sizeof($where_sql))
+ if (!count($where_sql))
{
return;
}
@@ -1229,14 +1274,14 @@ class acp_profile
{
$sql_ary = array_merge($where_fields, $sql_ary);
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary));
}
}
else
{
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE ' . implode(' AND ', $where_sql);
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php
index d37050869a..3eee4f7922 100644
--- a/phpBB/includes/acp/acp_prune.php
+++ b/phpBB/includes/acp/acp_prune.php
@@ -55,7 +55,7 @@ class acp_prune
*/
function prune_forums($id, $mode)
{
- global $db, $user, $auth, $template, $phpbb_log, $request;
+ global $db, $user, $auth, $template, $phpbb_log, $request, $phpbb_dispatcher;
$all_forums = $request->variable('all_forums', 0);
$forum_id = $request->variable('f', array(0));
@@ -97,7 +97,7 @@ class acp_prune
'S_PRUNED' => true)
);
- $sql_forum = (sizeof($forum_id)) ? ' AND ' . $db->sql_in_set('forum_id', $forum_id) : '';
+ $sql_forum = (count($forum_id)) ? ' AND ' . $db->sql_in_set('forum_id', $forum_id) : '';
// Get a list of forum's or the data for the forum that we are pruning.
$sql = 'SELECT forum_id, forum_name
@@ -165,7 +165,7 @@ class acp_prune
}
else
{
- confirm_box(false, $user->lang['PRUNE_FORUM_CONFIRM'], build_hidden_fields(array(
+ $hidden_fields = array(
'i' => $id,
'mode' => $mode,
'submit' => 1,
@@ -177,13 +177,25 @@ class acp_prune
'prune_old_polls' => $request->variable('prune_old_polls', 0),
'prune_announce' => $request->variable('prune_announce', 0),
'prune_sticky' => $request->variable('prune_sticky', 0),
- )));
+ );
+
+ /**
+ * Use this event to pass data from the prune form to the confirmation screen
+ *
+ * @event core.prune_forums_settings_confirm
+ * @var array hidden_fields Hidden fields that are passed through the confirm screen
+ * @since 3.2.2-RC1
+ */
+ $vars = array('hidden_fields');
+ extract($phpbb_dispatcher->trigger_event('core.prune_forums_settings_confirm', compact($vars)));
+
+ confirm_box(false, $user->lang['PRUNE_FORUM_CONFIRM'], build_hidden_fields($hidden_fields));
}
}
// If they haven't selected a forum for pruning yet then
// display a select box to use for pruning.
- if (!sizeof($forum_id))
+ if (!count($forum_id))
{
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
@@ -215,15 +227,27 @@ class acp_prune
$db->sql_freeresult($result);
- $l_selected_forums = (sizeof($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS';
+ $l_selected_forums = (count($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS';
- $template->assign_vars(array(
+ $template_data = array(
'L_SELECTED_FORUMS' => $user->lang[$l_selected_forums],
'U_ACTION' => $this->u_action,
'U_BACK' => $this->u_action,
'FORUM_LIST' => $forum_list,
- 'S_HIDDEN_FIELDS' => $s_hidden_fields)
+ 'S_HIDDEN_FIELDS' => $s_hidden_fields,
);
+
+ /**
+ * Event to add/modify prune forums settings template data
+ *
+ * @event core.prune_forums_settings_template_data
+ * @var array template_data Array with form template data
+ * @since 3.2.2-RC1
+ */
+ $vars = array('template_data');
+ extract($phpbb_dispatcher->trigger_event('core.prune_forums_settings_template_data', compact($vars)));
+
+ $template->assign_vars($template_data);
}
}
@@ -252,7 +276,7 @@ class acp_prune
$user_ids = $usernames = array();
$this->get_prune_users($user_ids, $usernames);
- if (sizeof($user_ids))
+ if (count($user_ids))
{
if ($action == 'deactivate')
{
@@ -291,7 +315,7 @@ class acp_prune
$user_ids = $usernames = array();
$this->get_prune_users($user_ids, $usernames);
- if (!sizeof($user_ids))
+ if (!count($user_ids))
{
trigger_error($user->lang['USER_PRUNE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -434,7 +458,7 @@ class acp_prune
}
// implicit else when both arrays are empty do nothing
- if ((sizeof($active) && sizeof($active) != 3) || (sizeof($joined_before) && sizeof($joined_before) != 3) || (sizeof($joined_after) && sizeof($joined_after) != 3))
+ if ((count($active) && count($active) != 3) || (count($joined_before) && count($joined_before) != 3) || (count($joined_after) && count($joined_after) != 3))
{
trigger_error($user->lang['WRONG_ACTIVE_JOINED_DATE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -448,15 +472,15 @@ class acp_prune
$where_sql .= ($count !== false) ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : '';
// First handle pruning of users who never logged in, last active date is 0000-00-00
- if (sizeof($active) && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0)
+ if (count($active) && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0)
{
$where_sql .= ' AND user_lastvisit = 0';
}
- else if (sizeof($active) && $active_select != 'lt')
+ else if (count($active) && $active_select != 'lt')
{
$where_sql .= ' AND user_lastvisit ' . $key_match[$active_select] . ' ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]);
}
- else if (sizeof($active))
+ else if (count($active))
{
$where_sql .= ' AND (user_lastvisit > 0 AND user_lastvisit < ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]) . ')';
}
diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php
index 51c398681d..dfb2ccbfd3 100644
--- a/phpBB/includes/acp/acp_reasons.php
+++ b/phpBB/includes/acp/acp_reasons.php
@@ -103,7 +103,7 @@ class acp_reasons
}
}
- if (!sizeof($error))
+ if (!count($error))
{
// New reason?
if ($action == 'add')
@@ -171,7 +171,7 @@ class acp_reasons
'L_TITLE' => $user->lang['REASON_' . $l_title],
'U_ACTION' => $this->u_action . "&amp;id=$reason_id&amp;action=$action",
'U_BACK' => $this->u_action,
- 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR_MSG' => (count($error)) ? implode('<br />', $error) : '',
'REASON_TITLE' => $reason_row['reason_title'],
'REASON_DESCRIPTION' => $reason_row['reason_description'],
@@ -182,7 +182,7 @@ class acp_reasons
'S_AVAILABLE_TITLES' => implode($user->lang['COMMA_SEPARATOR'], array_map('htmlspecialchars', array_keys($user->lang['report_reasons']['TITLE']))),
'S_EDIT_REASON' => true,
'S_TRANSLATED' => $translated,
- 'S_ERROR' => (sizeof($error)) ? true : false,
+ 'S_ERROR' => (count($error)) ? true : false,
)
);
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index a792ee6b79..538a28a926 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -332,9 +332,9 @@ class acp_search
$forum_ids[] = $row['forum_id'];
}
$db->sql_freeresult($result);
- $row_count += sizeof($ids);
+ $row_count += count($ids);
- if (sizeof($ids))
+ if (count($ids))
{
$this->search->index_remove($ids, $posters, $forum_ids);
}
@@ -349,7 +349,7 @@ class acp_search
$totaltime = microtime(true) - $starttime;
$rows_per_second = $row_count / $totaltime;
meta_refresh(1, append_sid($this->u_action . '&amp;action=delete&amp;skip_rows=' . $post_counter . '&amp;hash=' . generate_link_hash('acp_search')));
- trigger_error($user->lang('SEARCH_INDEX_DELETE_REDIRECT', (int) $row_count, $post_counter, $rows_per_second));
+ trigger_error($user->lang('SEARCH_INDEX_DELETE_REDIRECT', (int) $row_count, $post_counter) . $user->lang('SEARCH_INDEX_DELETE_REDIRECT_RATE', $rows_per_second));
}
}
@@ -474,8 +474,8 @@ class acp_search
$statistics = array();
foreach ($data as $statistic => $value)
{
- $n = sizeof($statistics);
- if ($n && sizeof($statistics[$n - 1]) < 3)
+ $n = count($statistics);
+ if ($n && count($statistics[$n - 1]) < 3)
{
$statistics[$n - 1] += array('statistic_2' => $statistic, 'value_2' => $value);
}
@@ -492,7 +492,7 @@ class acp_search
'S_ACTIVE' => ($type == $config['search_type']) ? true : false,
'S_HIDDEN_FIELDS' => build_hidden_fields(array('search_type' => $type)),
'S_INDEXED' => (bool) $search->index_created(),
- 'S_STATS' => (bool) sizeof($statistics))
+ 'S_STATS' => (bool) count($statistics))
);
foreach ($statistics as $statistic)
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index b954f90451..87c8d88f52 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -259,6 +259,19 @@ class acp_styles
// Get list of styles to uninstall
$ids = $this->request_vars('id', 0, true);
+ // Don't remove prosilver, you can still deactivate it.
+ $sql = 'SELECT style_id
+ FROM ' . STYLES_TABLE . "
+ WHERE style_name = '" . $this->db->sql_escape('prosilver') . "'";
+ $result = $this->db->sql_query($sql);
+ $prosilver_id = (int) $this->db->sql_fetchfield('style_id');
+ $this->db->sql_freeresult($result);
+
+ if ($prosilver_id && in_array($prosilver_id, $ids))
+ {
+ trigger_error($this->user->lang('UNINSTALL_PROSILVER') . adm_back_link($this->u_action), E_USER_WARNING);
+ }
+
// Check if confirmation box was submitted
if (confirm_box(true))
{
@@ -398,7 +411,7 @@ class acp_styles
// Reset default style for users who use selected styles
$sql = 'UPDATE ' . USERS_TABLE . '
- SET user_style = 0
+ SET user_style = ' . (int) $this->default_style . '
WHERE user_style IN (' . implode(', ', $ids) . ')';
$this->db->sql_query($sql);
@@ -952,6 +965,7 @@ class acp_styles
// Style data
'STYLE_ID' => $style['style_id'],
'STYLE_NAME' => htmlspecialchars($style['style_name']),
+ 'STYLE_PHPBB_VERSION' => $this->read_style_cfg($style['style_path'])['phpbb_version'],
'STYLE_PATH' => htmlspecialchars($style['style_path']),
'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']),
'STYLE_ACTIVE' => $style['style_active'],
@@ -997,11 +1011,14 @@ class acp_styles
'L_ACTION' => $this->user->lang['EXPORT']
); */
- // Uninstall
- $actions[] = array(
- 'U_ACTION' => $this->u_action . '&amp;action=uninstall&amp;hash=' . generate_link_hash('uninstall') . '&amp;id=' . $style['style_id'],
- 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL']
- );
+ if ($style['style_name'] !== 'prosilver')
+ {
+ // Uninstall
+ $actions[] = array(
+ 'U_ACTION' => $this->u_action . '&amp;action=uninstall&amp;hash=' . generate_link_hash('uninstall') . '&amp;id=' . $style['style_id'],
+ 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL']
+ );
+ }
// Preview
$actions[] = array(
@@ -1122,7 +1139,14 @@ class acp_styles
*/
protected function read_style_cfg($dir)
{
+ // This should never happen, we give them a red warning because of its relevance.
+ if (!file_exists($this->styles_path . $dir . '/style.cfg'))
+ {
+ trigger_error($this->user->lang('NO_STYLE_CFG', $dir), E_USER_WARNING);
+ }
+
static $required = array('name', 'phpbb_version', 'copyright');
+
$cfg = parse_cfg_file($this->styles_path . $dir . '/style.cfg');
// Check if it is a valid file
@@ -1249,7 +1273,7 @@ class acp_styles
// Change default style for users
$sql = 'UPDATE ' . USERS_TABLE . '
- SET user_style = 0
+ SET user_style = ' . (int) $this->default_style . '
WHERE user_style = ' . $id;
$this->db->sql_query($sql);
@@ -1355,18 +1379,18 @@ class acp_styles
}
// Hardcoded template bitfield to add for new templates
+ $default_bitfield = '1111111111111';
+
$bitfield = new bitfield();
- $bitfield->set(0);
- $bitfield->set(1);
- $bitfield->set(2);
- $bitfield->set(3);
- $bitfield->set(4);
- $bitfield->set(8);
- $bitfield->set(9);
- $bitfield->set(11);
- $bitfield->set(12);
- $value = $bitfield->get_base64();
- return $value;
+ for ($i = 0; $i < strlen($default_bitfield); $i++)
+ {
+ if ($default_bitfield[$i] == '1')
+ {
+ $bitfield->set($i);
+ }
+ }
+
+ return $bitfield->get_base64();
}
}
diff --git a/phpBB/includes/acp/acp_update.php b/phpBB/includes/acp/acp_update.php
index 9124a59ef2..fa3afa6ce3 100644
--- a/phpBB/includes/acp/acp_update.php
+++ b/phpBB/includes/acp/acp_update.php
@@ -59,17 +59,19 @@ class acp_update
$update_link = $phpbb_root_path . 'install/app.' . $phpEx;
- $template->assign_vars(array(
- 'S_UP_TO_DATE' => empty($updates_available),
- 'U_ACTION' => $this->u_action,
- 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&amp;versioncheck_force=1'),
+ $template_ary = [
+ 'S_UP_TO_DATE' => empty($updates_available),
+ 'U_ACTION' => $this->u_action,
+ 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&amp;versioncheck_force=1'),
- 'CURRENT_VERSION' => $config['version'],
+ 'CURRENT_VERSION' => $config['version'],
- 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $update_link),
+ 'UPDATE_INSTRUCTIONS' => $user->lang('UPDATE_INSTRUCTIONS', $update_link),
'S_VERSION_UPGRADEABLE' => !empty($upgrades_available),
'UPGRADE_INSTRUCTIONS' => !empty($upgrades_available) ? $user->lang('UPGRADE_INSTRUCTIONS', $upgrades_available['current'], $upgrades_available['announcement']) : false,
- ));
+ ];
+
+ $template->assign_vars($template_ary);
// Incomplete update?
if (phpbb_version_compare($config['version'], PHPBB_VERSION, '<'))
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 090cb32ebb..fd4b5e8c24 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -24,9 +24,9 @@ class acp_users
var $u_action;
var $p_master;
- function acp_users(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
@@ -690,7 +690,7 @@ class acp_users
}
$db->sql_freeresult($result);
- if (sizeof($topic_id_ary))
+ if (count($topic_id_ary))
{
$sql = 'SELECT topic_id, forum_id, topic_title, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_attachment
FROM ' . TOPICS_TABLE . '
@@ -718,12 +718,12 @@ class acp_users
}
// Entire topic comprises posts by this user, move these topics
- if (sizeof($move_topic_ary))
+ if (count($move_topic_ary))
{
move_topics($move_topic_ary, $new_forum_id, false);
}
- if (sizeof($move_post_ary))
+ if (count($move_post_ary))
{
// Create new topic
// Update post_ids, report_ids, attachment_ids
@@ -769,13 +769,13 @@ class acp_users
$forum_id_ary = array_unique($forum_id_ary);
$topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary));
- if (sizeof($topic_id_ary))
+ if (count($topic_id_ary))
{
sync('topic_reported', 'topic_id', $topic_id_ary);
sync('topic', 'topic_id', $topic_id_ary);
}
- if (sizeof($forum_id_ary))
+ if (count($forum_id_ary))
{
sync('forum', 'forum_id', $forum_id_ary, false, true);
}
@@ -855,7 +855,7 @@ class acp_users
$check_ary += array(
'username' => array(
array('string', false, $config['min_name_chars'], $config['max_name_chars']),
- array('username', $user_row['username'])
+ array('username', $user_row['username'], true)
),
);
}
@@ -892,7 +892,7 @@ class acp_users
$update_password = $data['new_password'] && !$passwords_manager->check($data['new_password'], $user_row['user_password']);
$update_email = ($data['email'] != $user_row['user_email']) ? $data['email'] : false;
- if (!sizeof($error))
+ if (!count($error))
{
$sql_ary = array();
@@ -994,7 +994,7 @@ class acp_users
));
}
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
@@ -1347,7 +1347,7 @@ class acp_users
{
$s_hidden_fields['delall'] = 1;
}
- if (isset($_POST['delall']) || (isset($_POST['delmarked']) && sizeof($marked)))
+ if (isset($_POST['delall']) || (isset($_POST['delmarked']) && count($marked)))
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
}
@@ -1383,9 +1383,9 @@ class acp_users
{
// Check if there are more occurrences of % than arguments, if there are we fill out the arguments array
// It doesn't matter if we add more arguments than placeholders
- if ((substr_count($row['action'], '%') - sizeof($log_data_ary)) > 0)
+ if ((substr_count($row['action'], '%') - count($log_data_ary)) > 0)
{
- $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), ''));
+ $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - count($log_data_ary), ''));
}
$row['action'] = vsprintf($row['action'], $log_data_ary);
$row['action'] = bbcode_nl2br(censor_text($row['action']));
@@ -1478,7 +1478,7 @@ class acp_users
// validate custom profile fields
$cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error);
- if (sizeof($cp_error))
+ if (count($cp_error))
{
$error = array_merge($error, $cp_error);
}
@@ -1501,7 +1501,7 @@ class acp_users
$vars = array('data', 'user_id', 'user_row', 'error');
extract($phpbb_dispatcher->trigger_event('core.acp_users_profile_validate', compact($vars)));
- if (!sizeof($error))
+ if (!count($error))
{
$sql_ary = array(
'user_jabber' => $data['jabber'],
@@ -1645,7 +1645,7 @@ class acp_users
$error[] = 'FORM_INVALID';
}
- if (!sizeof($error))
+ if (!count($error))
{
$this->optionset($user_row, 'viewimg', $data['view_images']);
$this->optionset($user_row, 'viewflash', $data['view_flash']);
@@ -1696,7 +1696,7 @@ class acp_users
$vars = array('data', 'user_row', 'sql_ary', 'error');
extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_sql', compact($vars)));
- if (!sizeof($error))
+ if (!count($error))
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
@@ -1883,6 +1883,17 @@ class acp_users
'user_avatar_height' => $result['avatar_height'],
);
+ /**
+ * Modify users preferences data before assigning it to the template
+ *
+ * @event core.acp_users_avatar_sql
+ * @var array user_row Array with user data
+ * @var array result Array with user avatar data to be updated in the DB
+ * @since 3.2.4-RC1
+ */
+ $vars = array('user_row', 'result');
+ extract($phpbb_dispatcher->trigger_event('core.acp_users_avatar_sql', compact($vars)));
+
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $result) . '
WHERE user_id = ' . (int) $user_id;
@@ -2060,7 +2071,7 @@ class acp_users
'sig'
);
- if (sizeof($warn_msg))
+ if (count($warn_msg))
{
$error += $warn_msg;
}
@@ -2072,7 +2083,7 @@ class acp_users
}
else
{
- if (!sizeof($error))
+ if (!count($error))
{
$this->optionset($user_row, 'sig_bbcode', $enable_bbcode);
$this->optionset($user_row, 'sig_smilies', $enable_smilies);
@@ -2085,6 +2096,17 @@ class acp_users
'user_sig_bbcode_bitfield' => $bbcode_bitfield,
);
+ /**
+ * Modify user signature before it is stored in the DB
+ *
+ * @event core.acp_users_modify_signature_sql_ary
+ * @var array user_row Array with user data
+ * @var array sql_ary Array with user signature data to be updated in the DB
+ * @since 3.2.4-RC1
+ */
+ $vars = array('user_row', 'sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.acp_users_modify_signature_sql_ary', compact($vars)));
+
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_id;
@@ -2099,7 +2121,7 @@ class acp_users
if ($request->is_set_post('preview'))
{
- $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_bitfield);
+ $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags);
}
/** @var \phpbb\controller\helper $controller_helper */
@@ -2147,7 +2169,7 @@ class acp_users
$sort_key = $request->variable('sk', 'a');
$sort_dir = $request->variable('sd', 'd');
- if ($deletemark && sizeof($marked))
+ if ($deletemark && count($marked))
{
$sql = 'SELECT attach_id
FROM ' . ATTACHMENTS_TABLE . '
@@ -2164,7 +2186,7 @@ class acp_users
$db->sql_freeresult($result);
}
- if ($deletemark && sizeof($marked))
+ if ($deletemark && count($marked))
{
if (confirm_box(true))
{
@@ -2185,7 +2207,7 @@ class acp_users
$attachment_manager->delete('attach', $marked);
unset($attachment_manager);
- $message = (sizeof($log_attachments) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED'];
+ $message = (count($log_attachments) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED'];
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACHMENTS_DELETED', false, array(implode($user->lang['COMMA_SEPARATOR'], $log_attachments)));
trigger_error($message . adm_back_link($this->u_action . '&amp;u=' . $user_id));
@@ -2455,7 +2477,7 @@ class acp_users
// Select box for other groups
$sql = 'SELECT group_id, group_name, group_type, group_founder_manage
FROM ' . GROUPS_TABLE . '
- ' . ((sizeof($id_ary)) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . '
+ ' . ((count($id_ary)) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . '
ORDER BY group_type DESC, group_name ASC';
$result = $db->sql_query($sql);
@@ -2497,7 +2519,7 @@ class acp_users
'U_DELETE' => $this->u_action . "&amp;action=delete&amp;u=$user_id&amp;g=" . $data['group_id'],
'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&amp;action=approve&amp;u=$user_id&amp;g=" . $data['group_id'] : '',
- 'GROUP_NAME' => ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name'],
+ 'GROUP_NAME' => $group_helper->get_name($data['group_name']),
'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'],
'S_IS_MEMBER' => ($group_type != 'pending') ? true : false,
@@ -2604,8 +2626,8 @@ class acp_users
// Assign general variables
$template->assign_vars(array(
- 'S_ERROR' => (sizeof($error)) ? true : false,
- 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '')
+ 'S_ERROR' => (count($error)) ? true : false,
+ 'ERROR_MSG' => (count($error)) ? implode('<br />', $error) : '')
);
}
diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php
index b36b900396..b414a3121a 100644
--- a/phpBB/includes/acp/auth.php
+++ b/phpBB/includes/acp/auth.php
@@ -27,7 +27,7 @@ class auth_admin extends \phpbb\auth\auth
/**
* Init auth settings
*/
- function auth_admin()
+ function __construct()
{
global $db, $cache;
@@ -107,7 +107,7 @@ class auth_admin extends \phpbb\auth\auth
$compare_options = array_diff(preg_replace('/^((?!' . $auth_option . ').+)|(' . $auth_option . ')$/', '', array_keys($this->acl_options[$scope])), array(''));
// If forum_ids is false and the scope is local we actually want to have all forums within the array
- if ($scope == 'local' && !sizeof($forum_ids))
+ if ($scope == 'local' && !count($forum_ids))
{
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
@@ -177,9 +177,9 @@ class auth_admin extends \phpbb\auth\auth
// Now, we need to fill the gaps with $acl_fill. ;)
// Now switch back to keys
- if (sizeof($compare_options))
+ if (count($compare_options))
{
- $compare_options = array_combine($compare_options, array_fill(1, sizeof($compare_options), $acl_fill));
+ $compare_options = array_combine($compare_options, array_fill(1, count($compare_options), $acl_fill));
}
// Defining the user-function here to save some memory
@@ -189,7 +189,7 @@ class auth_admin extends \phpbb\auth\auth
};
// Actually fill the gaps
- if (sizeof($hold_ary))
+ if (count($hold_ary))
{
foreach ($hold_ary as $ug_id => $row)
{
@@ -356,7 +356,7 @@ class auth_admin extends \phpbb\auth\auth
// Build js roles array (role data assignments)
$s_role_js_array = '';
- if (sizeof($roles))
+ if (count($roles))
{
$s_role_js_array = array();
@@ -422,7 +422,7 @@ class auth_admin extends \phpbb\auth\auth
// If we only have one forum id to display or being in local mode and more than one user/group to display,
// we switch the complete interface to group by user/usergroup instead of grouping by forum
// To achieve this, we need to switch the array a bit
- if (sizeof($forum_ids) == 1 || ($local && sizeof($ug_names_ary) > 1))
+ if (count($forum_ids) == 1 || ($local && count($ug_names_ary) > 1))
{
$hold_ary_temp = $hold_ary;
$hold_ary = array();
@@ -453,9 +453,9 @@ class auth_admin extends \phpbb\auth\auth
'S_LOCAL' => ($local) ? true : false,
'S_GLOBAL' => (!$local) ? true : false,
- 'S_NUM_CATS' => sizeof($categories),
+ 'S_NUM_CATS' => count($categories),
'S_VIEW' => ($mode == 'view') ? true : false,
- 'S_NUM_OBJECTS' => sizeof($content_array),
+ 'S_NUM_OBJECTS' => count($content_array),
'S_USER_MODE' => ($user_mode == 'user') ? true : false,
'S_GROUP_MODE' => ($user_mode == 'group') ? true : false)
);
@@ -546,15 +546,15 @@ class auth_admin extends \phpbb\auth\auth
'NAME' => $ug_name,
'CATEGORIES' => implode('</th><th>', $categories),
- 'USER_GROUPS_DEFAULT' => ($user_mode == 'user' && isset($user_groups_default[$ug_id]) && sizeof($user_groups_default[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_default[$ug_id]) : '',
- 'USER_GROUPS_CUSTOM' => ($user_mode == 'user' && isset($user_groups_custom[$ug_id]) && sizeof($user_groups_custom[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_custom[$ug_id]) : '',
+ 'USER_GROUPS_DEFAULT' => ($user_mode == 'user' && isset($user_groups_default[$ug_id]) && count($user_groups_default[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_default[$ug_id]) : '',
+ 'USER_GROUPS_CUSTOM' => ($user_mode == 'user' && isset($user_groups_custom[$ug_id]) && count($user_groups_custom[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_custom[$ug_id]) : '',
'L_ACL_TYPE' => $l_acl_type,
'S_LOCAL' => ($local) ? true : false,
'S_GLOBAL' => (!$local) ? true : false,
- 'S_NUM_CATS' => sizeof($categories),
+ 'S_NUM_CATS' => count($categories),
'S_VIEW' => ($mode == 'view') ? true : false,
- 'S_NUM_OBJECTS' => sizeof($content_array),
+ 'S_NUM_OBJECTS' => count($content_array),
'S_USER_MODE' => ($user_mode == 'user') ? true : false,
'S_GROUP_MODE' => ($user_mode == 'group') ? true : false)
);
@@ -637,7 +637,7 @@ class auth_admin extends \phpbb\auth\auth
global $db, $template, $user, $phpbb_root_path, $phpEx;
global $phpbb_container;
- if (!sizeof($hold_ary))
+ if (!count($hold_ary))
{
return;
}
@@ -669,7 +669,7 @@ class auth_admin extends \phpbb\auth\auth
'FORUM_ID' => $forum_id)
);
- if (isset($auth_ary['users']) && sizeof($auth_ary['users']))
+ if (isset($auth_ary['users']) && count($auth_ary['users']))
{
$sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . '
@@ -688,7 +688,7 @@ class auth_admin extends \phpbb\auth\auth
$db->sql_freeresult($result);
}
- if (isset($auth_ary['groups']) && sizeof($auth_ary['groups']))
+ if (isset($auth_ary['groups']) && count($auth_ary['groups']))
{
$sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . '
@@ -819,7 +819,7 @@ class auth_admin extends \phpbb\auth\auth
// Because we just changed the options and also purged the options cache, we instantly update/regenerate it for later calls to succeed.
$this->acl_options = array();
- $this->auth_admin();
+ $this->__construct();
return true;
}
@@ -890,7 +890,7 @@ class auth_admin extends \phpbb\auth\auth
}
$db->sql_freeresult($result);
- if (sizeof($role_ids))
+ if (count($role_ids))
{
$sql = "DELETE FROM $table
WHERE $forum_sql
@@ -1000,7 +1000,7 @@ class auth_admin extends \phpbb\auth\auth
}
// If no data is there, we set the any-flag to ACL_NEVER...
- if (!sizeof($sql_ary))
+ if (!count($sql_ary))
{
$sql_ary[] = array(
'role_id' => (int) $role_id,
@@ -1083,7 +1083,7 @@ class auth_admin extends \phpbb\auth\auth
$db->sql_freeresult($result);
// Get role data for resetting data
- if (sizeof($cur_role_auth))
+ if (count($cur_role_auth))
{
$sql = 'SELECT ao.auth_option, rd.role_id, rd.auth_setting
FROM ' . ACL_OPTIONS_TABLE . ' ao, ' . ACL_ROLES_DATA_TABLE . ' rd
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 6572c0ad2c..c31b63a403 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -35,9 +35,18 @@ class bbcode
/**
* Constructor
+ */
+ function __construct($bitfield = '')
+ {
+ $this->bbcode_set_bitfield($bitfield);
+ }
+
+ /**
* Init bbcode cache entries if bitfield is specified
+ *
+ * @param string $bbcode_bitfield The bbcode bitfield
*/
- function bbcode($bitfield = '')
+ function bbcode_set_bitfield($bitfield = '')
{
if ($bitfield)
{
@@ -94,13 +103,13 @@ class bbcode
${$type}['replace'][] = $replace;
}
- if (sizeof($str['search']))
+ if (count($str['search']))
{
$message = str_replace($str['search'], $str['replace'], $message);
$str = array('search' => array(), 'replace' => array());
}
- if (sizeof($preg['search']))
+ if (count($preg['search']))
{
// we need to turn the entities back into their original form to allow the
// search patterns to work properly
@@ -191,7 +200,7 @@ class bbcode
}
}
- if (sizeof($sql))
+ if (count($sql))
{
global $db;
diff --git a/phpBB/includes/compatibility_globals.php b/phpBB/includes/compatibility_globals.php
index 0f403896a7..ad394e3782 100644
--- a/phpBB/includes/compatibility_globals.php
+++ b/phpBB/includes/compatibility_globals.php
@@ -29,7 +29,7 @@ function register_compatibility_globals()
{
global $phpbb_container;
- global $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log;
+ global $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $language, $phpbb_log;
global $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template;
// set up caching
@@ -48,6 +48,9 @@ function register_compatibility_globals()
/* @var $user \phpbb\user */
$user = $phpbb_container->get('user');
+ /* @var \phpbb\language\language $language */
+ $language = $phpbb_container->get('language');
+
/* @var $auth \phpbb\auth\auth */
$auth = $phpbb_container->get('auth');
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index 07f9f27555..a2e7d92f7d 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -28,7 +28,7 @@ if (!defined('IN_PHPBB'))
*/
// phpBB Version
-@define('PHPBB_VERSION', '3.2.2-dev');
+@define('PHPBB_VERSION', '3.2.9-dev');
// QA-related
// define('PHPBB_QA', 1);
diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php
index d307880c4b..d8ae9d77ac 100644
--- a/phpBB/includes/diff/diff.php
+++ b/phpBB/includes/diff/diff.php
@@ -50,7 +50,7 @@ class diff
* @param array &$to_content An array of strings.
* @param bool $preserve_cr If true, \r is replaced by a new line in the diff output
*/
- function diff(&$from_content, &$to_content, $preserve_cr = true)
+ function __construct(&$from_content, &$to_content, $preserve_cr = true)
{
$diff_engine = new diff_engine();
$this->_edits = $diff_engine->diff($from_content, $to_content, $preserve_cr);
@@ -75,7 +75,7 @@ class diff
{
$count = 0;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -98,7 +98,7 @@ class diff
{
$count = 0;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -136,7 +136,7 @@ class diff
$rev->_edits = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
$rev->_edits[] = $edit->reverse();
@@ -152,7 +152,7 @@ class diff
*/
function is_empty()
{
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -168,8 +168,8 @@ class diff
$final = $edit->final;
// We can simplify one case where the array is usually supposed to be empty...
- if (sizeof($orig) == 1 && trim($orig[0]) === '') $orig = array();
- if (sizeof($final) == 1 && trim($final[0]) === '') $final = array();
+ if (count($orig) == 1 && trim($orig[0]) === '') $orig = array();
+ if (count($final) == 1 && trim($final[0]) === '') $final = array();
if (!$orig && !$final)
{
@@ -196,13 +196,13 @@ class diff
{
$lcs = 0;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
if (is_a($edit, 'diff_op_copy'))
{
- $lcs += sizeof($edit->orig);
+ $lcs += count($edit->orig);
}
}
return $lcs;
@@ -219,13 +219,13 @@ class diff
{
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
if ($edit->orig)
{
- array_splice($lines, sizeof($lines), 0, $edit->orig);
+ array_splice($lines, count($lines), 0, $edit->orig);
}
}
return $lines;
@@ -242,13 +242,13 @@ class diff
{
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
if ($edit->final)
{
- array_splice($lines, sizeof($lines), 0, $edit->final);
+ array_splice($lines, count($lines), 0, $edit->final);
}
}
return $lines;
@@ -296,7 +296,7 @@ class diff
$prevtype = null;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -330,30 +330,30 @@ class mapped_diff extends diff
* compared when computing the diff.
* @param array $mapped_to_lines This array should have the same number of elements as $to_lines.
*/
- function mapped_diff(&$from_lines, &$to_lines, &$mapped_from_lines, &$mapped_to_lines)
+ function __construct(&$from_lines, &$to_lines, &$mapped_from_lines, &$mapped_to_lines)
{
- if (sizeof($from_lines) != sizeof($mapped_from_lines) || sizeof($to_lines) != sizeof($mapped_to_lines))
+ if (count($from_lines) != count($mapped_from_lines) || count($to_lines) != count($mapped_to_lines))
{
return false;
}
- parent::diff($mapped_from_lines, $mapped_to_lines);
+ parent::__construct($mapped_from_lines, $mapped_to_lines);
$xi = $yi = 0;
- for ($i = 0; $i < sizeof($this->_edits); $i++)
+ for ($i = 0; $i < count($this->_edits); $i++)
{
$orig = &$this->_edits[$i]->orig;
if (is_array($orig))
{
- $orig = array_slice($from_lines, $xi, sizeof($orig));
- $xi += sizeof($orig);
+ $orig = array_slice($from_lines, $xi, count($orig));
+ $xi += count($orig);
}
$final = &$this->_edits[$i]->final;
if (is_array($final))
{
- $final = array_slice($to_lines, $yi, sizeof($final));
- $yi += sizeof($final);
+ $final = array_slice($to_lines, $yi, count($final));
+ $yi += count($final);
}
}
}
@@ -377,12 +377,12 @@ class diff_op
function norig()
{
- return ($this->orig) ? sizeof($this->orig) : 0;
+ return ($this->orig) ? count($this->orig) : 0;
}
function nfinal()
{
- return ($this->final) ? sizeof($this->final) : 0;
+ return ($this->final) ? count($this->final) : 0;
}
}
@@ -394,7 +394,7 @@ class diff_op
*/
class diff_op_copy extends diff_op
{
- function diff_op_copy($orig, $final = false)
+ function __construct($orig, $final = false)
{
if (!is_array($final))
{
@@ -419,7 +419,7 @@ class diff_op_copy extends diff_op
*/
class diff_op_delete extends diff_op
{
- function diff_op_delete($lines)
+ function __construct($lines)
{
$this->orig = $lines;
$this->final = false;
@@ -440,7 +440,7 @@ class diff_op_delete extends diff_op
*/
class diff_op_add extends diff_op
{
- function diff_op_add($lines)
+ function __construct($lines)
{
$this->final = $lines;
$this->orig = false;
@@ -461,7 +461,7 @@ class diff_op_add extends diff_op
*/
class diff_op_change extends diff_op
{
- function diff_op_change($orig, $final)
+ function __construct($orig, $final)
{
$this->orig = $orig;
$this->final = $final;
@@ -498,7 +498,7 @@ class diff3 extends diff
* @param bool $preserve_cr If true, \r\n and bare \r are replaced by a new line
* in the diff output
*/
- function diff3(&$orig, &$final1, &$final2, $preserve_cr = true)
+ function __construct(&$orig, &$final1, &$final2, $preserve_cr = true)
{
$diff_engine = new diff_engine();
@@ -517,7 +517,7 @@ class diff3 extends diff
{
$conflicts = 0;
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -550,7 +550,7 @@ class diff3 extends diff
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -590,7 +590,7 @@ class diff3 extends diff
{
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -614,7 +614,7 @@ class diff3 extends diff
{
$lines = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -638,7 +638,7 @@ class diff3 extends diff
{
$conflicts = array();
- for ($i = 0, $size = sizeof($this->_edits); $i < $size; $i++)
+ for ($i = 0, $size = count($this->_edits); $i < $size; $i++)
{
$edit = $this->_edits[$i];
@@ -754,7 +754,7 @@ class diff3 extends diff
*/
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->final1 = $final1 ? $final1 : array();
@@ -803,9 +803,9 @@ class diff3_op
function solve_prepare()
{
// We can simplify one case where the array is usually supposed to be empty...
- if (sizeof($this->orig) == 1 && trim($this->orig[0]) === '') $this->orig = array();
- if (sizeof($this->final1) == 1 && trim($this->final1[0]) === '') $this->final1 = array();
- if (sizeof($this->final2) == 1 && trim($this->final2[0]) === '') $this->final2 = array();
+ if (count($this->orig) == 1 && trim($this->orig[0]) === '') $this->orig = array();
+ if (count($this->final1) == 1 && trim($this->final1[0]) === '') $this->final1 = array();
+ if (count($this->final2) == 1 && trim($this->final2[0]) === '') $this->final2 = array();
// Now we only can have the case where the only difference between arrays are newlines, so compare all cases
@@ -848,10 +848,10 @@ class diff3_op
$_final1 = &$this->$final1;
// Ok, we basically search for $orig in $final1
- $compare_seq = sizeof($_orig);
+ $compare_seq = count($_orig);
// Go through the conflict code
- for ($i = 0, $j = 0, $size = sizeof($_final1); $i < $size; $i++, $j = $i)
+ for ($i = 0, $j = 0, $size = count($_final1); $i < $size; $i++, $j = $i)
{
$line = $_final1[$i];
$skip = 0;
@@ -895,7 +895,7 @@ class diff3_op
// CASE ONE: orig changed into final2, but modified/unknown code in final1.
// IF orig is found "as is" in final1 we replace the code directly in final1 and populate this as final2/merge
- if (sizeof($this->orig) && sizeof($this->final2))
+ if (count($this->orig) && count($this->final2))
{
$result = $this->_compare_conflict_seq('orig', 'final1', 'final2');
@@ -915,7 +915,7 @@ class diff3_op
}
// Try to solve $Id$ issues. ;)
- if (sizeof($this->orig) == 1 && sizeof($this->final1) == 1 && sizeof($this->final2) == 1)
+ if (count($this->orig) == 1 && count($this->final1) == 1 && count($this->final2) == 1)
{
$match = '#^' . preg_quote('* @version $Id: ', '#') . '[a-z\._\- ]+[0-9]+ [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9\:Z]+ [a-z0-9_\- ]+\$$#';
@@ -939,9 +939,9 @@ class diff3_op
}
// The same is true for a line at the end. ;)
- if (sizeof($this->orig) && sizeof($this->final2) && sizeof($this->orig) === sizeof($this->final2) && trim($this->orig[sizeof($this->orig)-1]) === '' && trim($this->final2[sizeof($this->final2)-1]) === '')
+ if (count($this->orig) && count($this->final2) && count($this->orig) === count($this->final2) && trim($this->orig[count($this->orig)-1]) === '' && trim($this->final2[count($this->final2)-1]) === '')
{
- unset($this->orig[sizeof($this->orig)-1], $this->final2[sizeof($this->final2)-1]);
+ unset($this->orig[count($this->orig)-1], $this->final2[count($this->final2)-1]);
$this->orig = array_values($this->orig);
$this->final2 = array_values($this->final2);
@@ -972,7 +972,7 @@ class diff3_op
}
// CASE TWO: Added lines from orig to final2 but final1 had added lines too. Just merge them.
- if (!sizeof($this->orig) && $this->final1 !== $this->final2 && sizeof($this->final1) && sizeof($this->final2))
+ if (!count($this->orig) && $this->final1 !== $this->final2 && count($this->final1) && count($this->final2))
{
$result = $this->_compare_conflict_seq('final2', 'final1');
@@ -1001,7 +1001,7 @@ class diff3_op
}
// CASE THREE: Removed lines (orig has the to-remove line(s), but final1 has additional lines which does not need to be removed). Just remove orig from final1 and then use final1 as final2/merge
- if (!sizeof($this->final2) && sizeof($this->orig) && sizeof($this->final1) && $this->orig !== $this->final1)
+ if (!count($this->final2) && count($this->orig) && count($this->final1) && $this->orig !== $this->final1)
{
$result = $this->_compare_conflict_seq('orig', 'final1');
@@ -1011,11 +1011,11 @@ class diff3_op
}
// First of all, try to find the code in orig in final1. ;)
- $compare_seq = sizeof($this->orig);
+ $compare_seq = count($this->orig);
$begin = $end = -1;
$j = 0;
- for ($i = 0, $size = sizeof($this->final1); $i < $size; $i++)
+ for ($i = 0, $size = count($this->final1); $i < $size; $i++)
{
$line = $this->final1[$i];
@@ -1066,7 +1066,7 @@ class diff3_op
*/
class diff3_op_copy extends diff3_op
{
- function diff3_op_copy($lines = false)
+ function __construct($lines = false)
{
$this->orig = $lines ? $lines : array();
$this->final1 = &$this->orig;
@@ -1092,7 +1092,7 @@ class diff3_op_copy extends diff3_op
*/
class diff3_block_builder
{
- function diff3_block_builder()
+ function __construct()
{
$this->_init();
}
@@ -1147,6 +1147,6 @@ class diff3_block_builder
function _append(&$array, $lines)
{
- array_splice($array, sizeof($array), 0, $lines);
+ array_splice($array, count($array), 0, $lines);
}
}
diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php
index bc21b3b9ba..757fdadde9 100644
--- a/phpBB/includes/diff/engine.php
+++ b/phpBB/includes/diff/engine.php
@@ -84,8 +84,8 @@ class diff_engine
$to_lines = explode("\n", preg_replace('#[\n\r]+#', "\n", $to_lines));
}
- $n_from = sizeof($from_lines);
- $n_to = sizeof($to_lines);
+ $n_from = count($from_lines);
+ $n_to = count($to_lines);
$this->xchanged = $this->ychanged = $this->xv = $this->yv = $this->xind = $this->yind = array();
unset($this->seq, $this->in_seq, $this->lcs);
@@ -145,7 +145,7 @@ class diff_engine
}
// Find the LCS.
- $this->_compareseq(0, sizeof($this->xv), 0, sizeof($this->yv));
+ $this->_compareseq(0, count($this->xv), 0, count($this->yv));
// Merge edits when possible.
if ($this->skip_whitespace_changes)
@@ -444,8 +444,8 @@ class diff_engine
$i = 0;
$j = 0;
- $len = sizeof($lines);
- $other_len = sizeof($other_changed);
+ $len = count($lines);
+ $other_len = count($other_changed);
while (1)
{
diff --git a/phpBB/includes/diff/renderer.php b/phpBB/includes/diff/renderer.php
index 6b7f07cf9c..8a8b0c295e 100644
--- a/phpBB/includes/diff/renderer.php
+++ b/phpBB/includes/diff/renderer.php
@@ -56,7 +56,7 @@ class diff_renderer
/**
* Constructor.
*/
- function diff_renderer($params = array())
+ function __construct($params = array())
{
foreach ($params as $param => $value)
{
@@ -128,8 +128,8 @@ class diff_renderer
if (is_array($block))
{
// How many lines to keep as context from the copy block.
- $keep = ($i == sizeof($diffs) - 1) ? $ntrail : $nlead + $ntrail;
- if (sizeof($edit->orig) <= $keep)
+ $keep = ($i == count($diffs) - 1) ? $ntrail : $nlead + $ntrail;
+ if (count($edit->orig) <= $keep)
{
// We have less lines in the block than we want for context => keep the whole block.
$block[] = $edit;
@@ -156,9 +156,9 @@ class diff_renderer
if (!is_array($block))
{
// Extract context lines from the preceding copy block.
- $context = array_slice($context, sizeof($context) - $nlead);
- $x0 = $xi - sizeof($context);
- $y0 = $yi - sizeof($context);
+ $context = array_slice($context, count($context) - $nlead);
+ $x0 = $xi - count($context);
+ $y0 = $yi - count($context);
$block = array();
if ($context)
@@ -169,8 +169,8 @@ class diff_renderer
$block[] = $edit;
}
- $xi += ($edit->orig) ? sizeof($edit->orig) : 0;
- $yi += ($edit->final) ? sizeof($edit->final) : 0;
+ $xi += ($edit->orig) ? count($edit->orig) : 0;
+ $yi += ($edit->final) ? count($edit->final) : 0;
}
if (is_array($block))
@@ -433,7 +433,7 @@ class diff_renderer_inline extends diff_renderer
{
array_walk($lines, array(&$this, '_encode'));
$lines[0] = $this->_ins_prefix . $lines[0];
- $lines[sizeof($lines) - 1] .= $this->_ins_suffix;
+ $lines[count($lines) - 1] .= $this->_ins_suffix;
return $this->_lines($lines, ' ', false);
}
@@ -441,7 +441,7 @@ class diff_renderer_inline extends diff_renderer
{
array_walk($lines, array(&$this, '_encode'));
$lines[0] = $this->_del_prefix . $lines[0];
- $lines[sizeof($lines) - 1] .= $this->_del_suffix;
+ $lines[count($lines) - 1] .= $this->_del_suffix;
return $this->_lines($lines, ' ', false);
}
@@ -617,7 +617,7 @@ class diff_renderer_side_by_side extends diff_renderer
$this->render($diff);
// Is the diff empty?
- if (!sizeof($this->lines))
+ if (!count($this->lines))
{
$output .= '<tr><th colspan="2">' . $user->lang['NO_VISIBLE_CHANGES'] . '</th></tr>';
}
@@ -672,8 +672,8 @@ class diff_renderer_side_by_side extends diff_renderer
case 'change':
// Pop the old/new stacks one by one, until both are empty.
- $oldsize = sizeof($change['old']);
- $newsize = sizeof($change['new']);
+ $oldsize = count($change['old']);
+ $newsize = count($change['new']);
$left = $right = '';
for ($row = 0, $row_max = max($oldsize, $newsize); $row < $row_max; ++$row)
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 2cd62d7bac..c9f589c174 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -66,29 +66,48 @@ function set_var(&$result, $var, $type, $multibyte = false)
/**
* Generates an alphanumeric random string of given length
*
+* @param int $num_chars Length of random string, defaults to 8.
+* This number should be less or equal than 64.
+*
* @return string
*/
function gen_rand_string($num_chars = 8)
{
- // [a, z] + [0, 9] = 36
- return substr(strtoupper(base_convert(unique_id(), 16, 36)), 0, $num_chars);
+ $range = array_merge(range('A', 'Z'), range(0, 9));
+ $size = count($range);
+
+ $output = '';
+ for ($i = 0; $i < $num_chars; $i++)
+ {
+ $rand = random_int(0, $size-1);
+ $output .= $range[$rand];
+ }
+
+ return $output;
}
/**
* Generates a user-friendly alphanumeric random string of given length
* We remove 0 and O so users cannot confuse those in passwords etc.
*
+* @param int $num_chars Length of random string, defaults to 8.
+* This number should be less or equal than 64.
+*
* @return string
*/
function gen_rand_string_friendly($num_chars = 8)
{
- $rand_str = unique_id();
+ $range = array_merge(range('A', 'N'), range('P', 'Z'), range(1, 9));
+ $size = count($range);
- // Remove Z and Y from the base_convert(), replace 0 with Z and O with Y
- // [a, z] + [0, 9] - {z, y} = [a, z] + [0, 9] - {0, o} = 34
- $rand_str = str_replace(array('0', 'O'), array('Z', 'Y'), strtoupper(base_convert($rand_str, 16, 34)));
+ $output = '';
+ for ($i = 0; $i < $num_chars; $i++)
+ {
+ $rand = random_int(0, $size-1);
+ $output .= $range[$rand];
+ }
- return substr($rand_str, 0, $num_chars);
+ return $output;
}
/**
@@ -96,7 +115,7 @@ function gen_rand_string_friendly($num_chars = 8)
*/
function unique_id()
{
- return bin2hex(random_bytes(8));
+ return strtolower(gen_rand_string(16));
}
/**
@@ -602,7 +621,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
if ($mode == 'all')
{
- if ($forum_id === false || !sizeof($forum_id))
+ if (empty($forum_id))
{
// Mark all forums read (index page)
/* @var $phpbb_notifications \phpbb\notification\manager */
@@ -661,8 +680,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
}
}
}
-
- return;
}
else if ($mode == 'topics')
{
@@ -727,7 +744,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
}
$db->sql_freeresult($result);
- if (sizeof($sql_update))
+ if (count($sql_update))
{
$sql = 'UPDATE ' . FORUMS_TRACK_TABLE . "
SET mark_time = $post_time
@@ -789,8 +806,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
unset($tracking);
}
-
- return;
}
else if ($mode == 'topic')
{
@@ -863,7 +878,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
// We get the ten most minimum stored time offsets and its associated topic ids
$time_keys = array();
- for ($i = 0; $i < 10 && sizeof($tracking['t']); $i++)
+ for ($i = 0; $i < 10 && count($tracking['t']); $i++)
{
$min_value = min($tracking['t']);
$m_tkey = array_search($min_value, $tracking['t']);
@@ -904,8 +919,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
$user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000);
$request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), \phpbb\request\request_interface::COOKIE);
}
-
- return;
}
else if ($mode == 'post')
{
@@ -930,9 +943,28 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
$db->sql_return_on_error(false);
}
-
- return;
}
+
+ /**
+ * This event is used for performing actions directly after forums,
+ * topics or posts have been marked as read.
+ *
+ * @event core.markread_after
+ * @var string mode Variable containing marking mode value
+ * @var mixed forum_id Variable containing forum id, or false
+ * @var mixed topic_id Variable containing topic id, or false
+ * @var int post_time Variable containing post time
+ * @var int user_id Variable containing the user id
+ * @since 3.2.6-RC1
+ */
+ $vars = array(
+ 'mode',
+ 'forum_id',
+ 'topic_id',
+ 'post_time',
+ 'user_id',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.markread_after', compact($vars)));
}
/**
@@ -959,7 +991,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
$topic_ids = array_diff($topic_ids, array_keys($last_read));
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$mark_time = array();
@@ -1011,7 +1043,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
$topic_ids = array_diff($topic_ids, array_keys($last_read));
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$sql = 'SELECT forum_id, mark_time
FROM ' . FORUMS_TRACK_TABLE . "
@@ -1038,7 +1070,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
{
global $tracking_topics;
- if (!isset($tracking_topics) || !sizeof($tracking_topics))
+ if (!isset($tracking_topics) || !count($tracking_topics))
{
$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
@@ -1065,7 +1097,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
$topic_ids = array_diff($topic_ids, array_keys($last_read));
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$mark_time = array();
@@ -1407,7 +1439,7 @@ function tracking_unserialize($string, $max_depth = 3)
switch ($string[$i])
{
case '(':
- if (sizeof($stack) >= $max_depth)
+ if (count($stack) >= $max_depth)
{
die('Invalid data supplied');
}
@@ -1461,7 +1493,7 @@ function tracking_unserialize($string, $max_depth = 3)
}
}
- if (sizeof($stack) != 0 || ($mode != 0 && $mode != 3))
+ if (count($stack) != 0 || ($mode != 0 && $mode != 3))
{
die('Invalid data supplied');
}
@@ -1725,14 +1757,14 @@ function redirect($url, $return = false, $disable_cd_check = false)
if ($url_parts === false)
{
// Malformed url
- trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
+ trigger_error('INSECURE_REDIRECT', E_USER_WARNING);
}
else if (!empty($url_parts['scheme']) && !empty($url_parts['host']))
{
// Attention: only able to redirect within the same domain if $disable_cd_check is false (yourdomain.com -> www.yourdomain.com will not work)
if (!$disable_cd_check && $url_parts['host'] !== $user->host)
{
- trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
+ trigger_error('INSECURE_REDIRECT', E_USER_WARNING);
}
}
else if ($url[0] == '/')
@@ -1772,13 +1804,13 @@ function redirect($url, $return = false, $disable_cd_check = false)
if (!$disable_cd_check && strpos($url, generate_board_url(true) . '/') !== 0)
{
- trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
+ trigger_error('INSECURE_REDIRECT', E_USER_WARNING);
}
// Make sure no linebreaks are there... to prevent http response splitting for PHP < 4.4.2
if (strpos(urldecode($url), "\n") !== false || strpos(urldecode($url), "\r") !== false || strpos($url, ';') !== false)
{
- trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
+ trigger_error('INSECURE_REDIRECT', E_USER_WARNING);
}
// Now, also check the protocol and for a valid url the last time...
@@ -1787,7 +1819,7 @@ function redirect($url, $return = false, $disable_cd_check = false)
if ($url_parts === false || empty($url_parts['scheme']) || !in_array($url_parts['scheme'], $allowed_protocols))
{
- trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
+ trigger_error('INSECURE_REDIRECT', E_USER_WARNING);
}
/**
@@ -1811,27 +1843,6 @@ function redirect($url, $return = false, $disable_cd_check = false)
garbage_collection();
}
- // Redirect via an HTML form for PITA webservers
- if (@preg_match('#WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
- {
- header('Refresh: 0; URL=' . $url);
-
- echo '<!DOCTYPE html>';
- echo '<html dir="' . $user->lang['DIRECTION'] . '" lang="' . $user->lang['USER_LANG'] . '">';
- echo '<head>';
- echo '<meta charset="utf-8">';
- echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
- echo '<meta http-equiv="refresh" content="0; url=' . str_replace('&', '&amp;', $url) . '" />';
- echo '<title>' . $user->lang['REDIRECT'] . '</title>';
- echo '</head>';
- echo '<body>';
- echo '<div style="text-align: center;">' . sprintf($user->lang['URL_REDIRECT'], '<a href="' . str_replace('&', '&amp;', $url) . '">', '</a>') . '</div>';
- echo '</body>';
- echo '</html>';
-
- exit;
- }
-
// Behave as per HTTP/1.1 spec for others
header('Location: ' . $url);
exit;
@@ -2111,25 +2122,29 @@ function check_form_key($form_name, $timespan = false)
/**
* Build Confirm box
* @param boolean $check True for checking if confirmed (without any additional parameters) and false for displaying the confirm box
-* @param string $title Title/Message used for confirm box.
+* @param string|array $title Title/Message used for confirm box.
* message text is _CONFIRM appended to title.
* If title cannot be found in user->lang a default one is displayed
* If title_CONFIRM cannot be found in user->lang the text given is used.
+* If title is an array, the first array value is used as explained per above,
+* all other array values are sent as parameters to the language function.
* @param string $hidden Hidden variables
* @param string $html_body Template used for confirm box
* @param string $u_action Custom form action
+*
+* @return bool True if confirmation was successful, false if not
*/
function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '')
{
global $user, $template, $db, $request;
- global $config, $phpbb_path_helper;
+ global $config, $language, $phpbb_path_helper, $phpbb_dispatcher;
if (isset($_POST['cancel']))
{
return false;
}
- $confirm = ($user->lang['YES'] === $request->variable('confirm', '', true, \phpbb\request\request_interface::POST));
+ $confirm = ($language->lang('YES') === $request->variable('confirm', '', true, \phpbb\request\request_interface::POST));
if ($check && $confirm)
{
@@ -2163,13 +2178,27 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
// generate activation key
$confirm_key = gen_rand_string(10);
+ // generate language strings
+ if (is_array($title))
+ {
+ $key = array_shift($title);
+ $count = array_shift($title);
+ $confirm_title = $language->is_set($key) ? $language->lang($key, $count, $title) : $language->lang('CONFIRM');
+ $confirm_text = $language->is_set($key . '_CONFIRM') ? $language->lang($key . '_CONFIRM', $count, $title) : $key;
+ }
+ else
+ {
+ $confirm_title = $language->is_set($title) ? $language->lang($title) : $language->lang('CONFIRM');
+ $confirm_text = $language->is_set($title . '_CONFIRM') ? $language->lang($title . '_CONFIRM') : $title;
+ }
+
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
{
- adm_page_header((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]);
+ adm_page_header($confirm_title);
}
else
{
- page_header((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]);
+ page_header($confirm_title);
}
$template->set_filenames(array(
@@ -2185,14 +2214,14 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
// re-add sid / transform & to &amp; for user->page (user->page is always using &)
$use_page = ($u_action) ? $u_action : str_replace('&', '&amp;', $user->page['page']);
- $u_action = reapply_sid($phpbb_path_helper->get_valid_page($use_page, $config['enable_mod_rewrite']), $phpbb_path_helper->is_router_used());
+ $u_action = reapply_sid($phpbb_path_helper->get_valid_page($use_page, $config['enable_mod_rewrite']));
$u_action .= ((strpos($u_action, '?') === false) ? '?' : '&amp;') . 'confirm_key=' . $confirm_key;
$template->assign_vars(array(
- 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang($title, 1),
- 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'],
+ 'MESSAGE_TITLE' => $confirm_title,
+ 'MESSAGE_TEXT' => $confirm_text,
- 'YES_VALUE' => $user->lang['YES'],
+ 'YES_VALUE' => $language->lang('YES'),
'S_CONFIRM_ACTION' => $u_action,
'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields,
'S_AJAX_REQUEST' => $request->is_ajax(),
@@ -2205,16 +2234,36 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
if ($request->is_ajax())
{
$u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id;
- $json_response = new \phpbb\json_response;
- $json_response->send(array(
+ $data = array(
'MESSAGE_BODY' => $template->assign_display('body'),
- 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title],
- 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'],
+ 'MESSAGE_TITLE' => $confirm_title,
+ 'MESSAGE_TEXT' => $confirm_text,
- 'YES_VALUE' => $user->lang['YES'],
+ 'YES_VALUE' => $language->lang('YES'),
'S_CONFIRM_ACTION' => str_replace('&amp;', '&', $u_action), //inefficient, rewrite whole function
'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields
- ));
+ );
+
+ /**
+ * This event allows an extension to modify the ajax output of confirm box.
+ *
+ * @event core.confirm_box_ajax_before
+ * @var string u_action Action of the form
+ * @var array data Data to be sent
+ * @var string hidden Hidden fields generated by caller
+ * @var string s_hidden_fields Hidden fields generated by this function
+ * @since 3.2.8-RC1
+ */
+ $vars = array(
+ 'u_action',
+ 'data',
+ 'hidden',
+ 's_hidden_fields',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.confirm_box_ajax_before', compact($vars)));
+
+ $json_response = new \phpbb\json_response;
+ $json_response->send($data);
}
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
@@ -2225,6 +2274,8 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
{
page_footer();
}
+
+ exit; // unreachable, page_footer() above will call exit()
}
/**
@@ -2236,6 +2287,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
global $request, $phpbb_container, $phpbb_dispatcher, $phpbb_log;
$err = '';
+ $form_name = 'login';
// Make sure user->setup() has been called
if (!$user->is_setup())
@@ -2311,8 +2363,19 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
trigger_error('NO_AUTH_ADMIN_USER_DIFFER');
}
- // If authentication is successful we redirect user to previous page
- $result = $auth->login($username, $password, $autologin, $viewonline, $admin);
+ // Check form key
+ if ($password && !defined('IN_CHECK_BAN') && !check_form_key($form_name))
+ {
+ $result = array(
+ 'status' => false,
+ 'error_msg' => 'FORM_INVALID',
+ );
+ }
+ else
+ {
+ // If authentication is successful we redirect user to previous page
+ $result = $auth->login($username, $password, $autologin, $viewonline, $admin);
+ }
// If admin authentication and login, we will log if it was a success or not...
// We also break the operation on the first non-success login - it could be argued that the user already knows
@@ -2344,10 +2407,12 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
* @event core.login_box_redirect
* @var string redirect Redirect string
* @var bool admin Is admin?
+ * @var array result Result from auth provider
* @since 3.1.0-RC5
* @changed 3.1.9-RC1 Removed undefined return variable
+ * @changed 3.2.4-RC1 Added result
*/
- $vars = array('redirect', 'admin');
+ $vars = array('redirect', 'admin', 'result');
extract($phpbb_dispatcher->trigger_event('core.login_box_redirect', compact($vars)));
// append/replace SID (may change during the session for AOL users)
@@ -2463,7 +2528,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
$s_hidden_fields = build_hidden_fields($s_hidden_fields);
- $template->assign_vars(array(
+ $login_box_template_data = array(
'LOGIN_ERROR' => $err,
'LOGIN_EXPLAIN' => $l_explain,
@@ -2471,6 +2536,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '',
'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),
'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'),
+ 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')),
'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
@@ -2480,7 +2546,29 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
'USERNAME_CREDENTIAL' => 'username',
'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password',
- ));
+ );
+
+ /**
+ * Event to add/modify login box template data
+ *
+ * @event core.login_box_modify_template_data
+ * @var int admin Flag whether user is admin
+ * @var string username User name
+ * @var int autologin Flag whether autologin is enabled
+ * @var string redirect Redirect URL
+ * @var array login_box_template_data Array with the login box template data
+ * @since 3.2.3-RC2
+ */
+ $vars = array(
+ 'admin',
+ 'username',
+ 'autologin',
+ 'redirect',
+ 'login_box_template_data',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.login_box_modify_template_data', compact($vars)));
+
+ $template->assign_vars($login_box_template_data);
page_header($user->lang['LOGIN']);
@@ -2497,7 +2585,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
*/
function login_forum_box($forum_data)
{
- global $db, $phpbb_container, $request, $template, $user, $phpbb_dispatcher;
+ global $db, $phpbb_container, $request, $template, $user, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
$password = $request->variable('password', '', true);
@@ -2582,6 +2670,8 @@ function login_forum_box($forum_data)
'body' => 'login_forum.html')
);
+ make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_data['forum_id']);
+
page_footer();
}
@@ -2676,9 +2766,9 @@ function parse_cfg_file($filename, $lines = false)
{
$value = '';
}
- else if (($value[0] == "'" && $value[sizeof($value) - 1] == "'") || ($value[0] == '"' && $value[sizeof($value) - 1] == '"'))
+ else if (($value[0] == "'" && $value[strlen($value) - 1] == "'") || ($value[0] == '"' && $value[strlen($value) - 1] == '"'))
{
- $value = htmlspecialchars(substr($value, 1, sizeof($value)-2));
+ $value = htmlspecialchars(substr($value, 1, strlen($value)-2));
}
else
{
@@ -2780,12 +2870,17 @@ function get_preg_expression($mode)
case 'url':
// generated with regex_idn.php file in the develop folder
- return "[a-z][a-z\d+\-.]*:/{2}(?:(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@/?|]+|%[\dA-F]{2})*)?";
+ return "[a-z][a-z\d+\-.]*(?<!javascript):/{2}(?:(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@/?|]+|%[\dA-F]{2})*)?";
+ break;
+
+ case 'url_http':
+ // generated with regex_idn.php file in the develop folder
+ return "http[s]?:/{2}(?:(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'()*+,;=:@/?|]+|%[\dA-F]{2})*)?";
break;
case 'url_inline':
// generated with regex_idn.php file in the develop folder
- return "[a-z][a-z\d+]*:/{2}(?:(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@/?|]+|%[\dA-F]{2})*)?";
+ return "[a-z][a-z\d+]*(?<!javascript):/{2}(?:(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@/?|]+|%[\dA-F]{2})*)?";
break;
case 'www_url':
@@ -3007,7 +3102,7 @@ function phpbb_inet_pton($address)
if (preg_match(get_preg_expression('ipv6'), $address))
{
$parts = explode(':', $address);
- $missing_parts = 8 - sizeof($parts) + 1;
+ $missing_parts = 8 - count($parts) + 1;
if (substr($address, 0, 2) === '::')
{
@@ -3024,7 +3119,7 @@ function phpbb_inet_pton($address)
if (preg_match(get_preg_expression('ipv4'), $last_part))
{
- $parts[sizeof($parts) - 1] = '';
+ $parts[count($parts) - 1] = '';
$last_part = phpbb_inet_pton($last_part);
$embedded_ipv4 = true;
--$missing_parts;
@@ -3036,7 +3131,7 @@ function phpbb_inet_pton($address)
{
$ret .= str_pad($part, 4, '0', STR_PAD_LEFT);
}
- else if ($i && $i < sizeof($parts) - 1)
+ else if ($i && $i < count($parts) - 1)
{
$ret .= str_repeat('0000', $missing_parts);
}
@@ -3632,7 +3727,7 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum'
// Need caps version of $item for language-strings
$item_caps = strtoupper($item);
- if (sizeof($online_users['online_users']))
+ if (count($online_users['online_users']))
{
$sql_ary = array(
'SELECT' => 'u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour',
@@ -4030,9 +4125,9 @@ function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config =
*
* @return string Avatar html
*/
-function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
+function phpbb_get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
{
- $row = \phpbb\avatar\manager::clean_row($user_row, 'group');
+ $row = \phpbb\avatar\manager::clean_row($group_row, 'group');
return phpbb_get_avatar($row, $alt, $ignore_config, $lazy);
}
@@ -4337,6 +4432,23 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
$controller_helper = $phpbb_container->get('controller.helper');
$notification_mark_hash = generate_link_hash('mark_all_notifications_read');
+ $s_login_redirect = build_hidden_fields(array('redirect' => $phpbb_path_helper->remove_web_root_path(build_url())));
+
+ // Add form token for login box, in case page is presenting a login form.
+ add_form_key('login', '_LOGIN');
+
+ /**
+ * Workaround for missing template variable in pre phpBB 3.2.6 styles.
+ * @deprecated 3.2.7 (To be removed: 3.3.0-a1)
+ */
+ $form_token_login = $template->retrieve_var('S_FORM_TOKEN_LOGIN');
+ if (!empty($form_token_login))
+ {
+ $s_login_redirect .= $form_token_login;
+ // Remove S_FORM_TOKEN_LOGIN as it's already appended to S_LOGIN_REDIRECT
+ $template->assign_var('S_FORM_TOKEN_LOGIN', '');
+ }
+
// The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array(
'SITENAME' => $config['sitename'],
@@ -4396,9 +4508,10 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'),
'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'),
'U_CONTACT_US' => ($config['contact_admin_form_enable'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '',
- 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'),
+ 'U_TEAM' => (!$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'),
'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),
'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'),
+ 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')),
'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '',
'U_FEED' => $controller_helper->route('phpbb_feed_index'),
@@ -4425,7 +4538,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'S_TOPIC_ID' => $topic_id,
'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id)),
- 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => $phpbb_path_helper->remove_web_root_path(build_url()))),
+ 'S_LOGIN_REDIRECT' => $s_login_redirect,
'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false,
'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false,
@@ -4458,7 +4571,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'S_COOKIE_NOTICE' => !empty($config['cookie_notice']),
'T_THEME_NAME' => rawurlencode($user->style['style_path']),
- 'T_THEME_LANG_NAME' => $user->data['user_lang'],
+ 'T_THEME_LANG_NAME' => $user->lang_name,
'T_TEMPLATE_NAME' => $user->style['style_path'],
'T_SUPER_TEMPLATE_NAME' => rawurlencode((isset($user->style['style_parent_tree']) && $user->style['style_parent_tree']) ? $user->style['style_parent_tree'] : $user->style['style_path']),
'T_IMAGES' => 'images',
@@ -4476,12 +4589,13 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
if ($send_headers)
{
- // An array of http headers that phpbb will set. The following event may override these.
+ // An array of http headers that phpBB will set. The following event may override these.
$http_headers += array(
// application/xhtml+xml not used because of IE
'Content-type' => 'text/html; charset=UTF-8',
'Cache-Control' => 'private, no-cache="set-cookie"',
'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
+ 'Referrer-Policy' => 'strict-origin-when-cross-origin',
);
if (!empty($user->data['is_bot']))
{
diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php
index 8bf42aa36e..a2014a7d5b 100644
--- a/phpBB/includes/functions_acp.php
+++ b/phpBB/includes/functions_acp.php
@@ -112,12 +112,13 @@ function adm_page_header($page_title)
'CONTAINER_EXCEPTION' => $phpbb_container->hasParameter('container_exception') ? $phpbb_container->getParameter('container_exception') : false,
));
- // An array of http headers that phpbb will set. The following event may override these.
+ // An array of http headers that phpBB will set. The following event may override these.
$http_headers = array(
// application/xhtml+xml not used because of IE
'Content-type' => 'text/html; charset=UTF-8',
'Cache-Control' => 'private, no-cache="set-cookie"',
'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
+ 'Referrer-Policy' => 'strict-origin-when-cross-origin',
);
/**
@@ -419,7 +420,7 @@ function build_cfg_template($tpl_type, $key, &$new_ary, $config_key, $vars)
*/
function validate_config_vars($config_vars, &$cfg_array, &$error)
{
- global $phpbb_root_path, $user, $phpbb_dispatcher, $phpbb_filesystem;
+ global $phpbb_root_path, $user, $phpbb_dispatcher, $phpbb_filesystem, $language;
$type = 0;
$min = 1;
@@ -442,6 +443,16 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
// Validate a bit. ;) (0 = type, 1 = min, 2= max)
switch ($validator[$type])
{
+ case 'url':
+ $cfg_array[$config_name] = trim($cfg_array[$config_name]);
+
+ if (!empty($cfg_array[$config_name]) && !preg_match('#^' . get_preg_expression('url') . '$#iu', $cfg_array[$config_name]))
+ {
+ $error[] = $language->lang('URL_INVALID', $language->lang($config_definition['lang']));
+ }
+
+ // no break here
+
case 'string':
$length = utf8_strlen($cfg_array[$config_name]);
@@ -564,9 +575,6 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
$cfg_array[$config_name] = trim($destination);
- // Absolute file path
- case 'absolute_path':
- case 'absolute_path_writable':
// Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir...
case 'path':
case 'wpath':
@@ -585,7 +593,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
break;
}
- $path = in_array($config_definition['validate'], array('wpath', 'path', 'rpath', 'rwpath')) ? $phpbb_root_path . $cfg_array[$config_name] : $cfg_array[$config_name];
+ $path = $phpbb_root_path . $cfg_array[$config_name];
if (!file_exists($path))
{
@@ -598,7 +606,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
}
// Check if the path is writable
- if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath' || $config_definition['validate'] === 'absolute_path_writable')
+ if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath')
{
if (file_exists($path) && !$phpbb_filesystem->is_writable($path))
{
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 1ad41156f9..c19d48b0be 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -167,7 +167,7 @@ function size_select_options($size_compare)
$s_size_options = '';
- for ($i = 0, $size = sizeof($size_types_text); $i < $size; $i++)
+ for ($i = 0, $size = count($size_types_text); $i < $size; $i++)
{
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$s_size_options .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
@@ -192,7 +192,7 @@ function group_select_options($group_id, $exclude_ids = false, $manage_founder =
/** @var \phpbb\group\helper $group_helper */
$group_helper = $phpbb_container->get('group_helper');
- $exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';
+ $exclude_sql = ($exclude_ids !== false && count($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';
$sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : '';
$sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : '';
@@ -747,7 +747,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
{
$where_ids = (is_array($where_ids)) ? array_unique($where_ids) : array($where_ids);
- if (!sizeof($where_ids))
+ if (!count($where_ids))
{
return array('topics' => 0, 'posts' => 0);
}
@@ -777,9 +777,9 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
}
$db->sql_freeresult($result);
- $return['topics'] = sizeof($topic_ids);
+ $return['topics'] = count($topic_ids);
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
return $return;
}
@@ -837,7 +837,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
}
$db->sql_freeresult($result);
- if (sizeof($moved_topic_ids))
+ if (count($moved_topic_ids))
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $moved_topic_ids);
@@ -923,7 +923,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
$where_ids = array($where_ids);
}
- if (!sizeof($where_ids))
+ if (!count($where_ids))
{
return false;
}
@@ -931,7 +931,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
$where_ids = array_map('intval', $where_ids);
/* Possible code for splitting post deletion
- if (sizeof($where_ids) >= 1001)
+ if (count($where_ids) >= 1001)
{
// Split into chunks of 1000
$chunks = array_chunk($where_ids, 1000);
@@ -974,7 +974,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
}
$db->sql_freeresult($result);
- if (!sizeof($post_ids))
+ if (!count($post_ids))
{
return false;
}
@@ -1018,7 +1018,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
unset($table_ary);
// Adjust users post counts
- if (sizeof($post_counts) && $post_count_sync)
+ if (count($post_counts) && $post_count_sync)
{
foreach ($post_counts as $poster_id => $substract)
{
@@ -1037,7 +1037,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
}
// Remove topics now having no posts?
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
@@ -1147,7 +1147,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
}
// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)
- if (sizeof($remove_topics) && $call_delete_topics)
+ if (count($remove_topics) && $call_delete_topics)
{
delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false);
}
@@ -1157,7 +1157,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
$phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids);
- return sizeof($post_ids);
+ return count($post_ids);
}
/**
@@ -1232,7 +1232,7 @@ function delete_topic_shadows($forum_id, $sql_more = '', $auto_sync = true)
$db->sql_query($sql);
}
}
- while (sizeof($topic_ids) == $batch_size);
+ while (count($topic_ids) == $batch_size);
if ($auto_sync)
{
@@ -1363,7 +1363,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// Do not sync the "global forum"
$where_ids = array_diff($where_ids, array(0));
- if (!sizeof($where_ids))
+ if (!count($where_ids))
{
// Empty array with IDs. This means that we don't have any work to do. Just return.
return;
@@ -1377,7 +1377,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
else
{
- if (!sizeof($where_ids))
+ if (!count($where_ids))
{
return;
}
@@ -1416,7 +1416,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
$db->sql_freeresult($result);
- if (!sizeof($topic_id_ary))
+ if (!count($topic_id_ary))
{
return;
}
@@ -1533,7 +1533,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$post_ids[] = $post_id;
}
- if (sizeof($post_ids))
+ if (count($post_ids))
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 1 - post_reported
@@ -1579,7 +1579,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
$db->sql_freeresult($result);
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 1 - topic_reported
@@ -1638,7 +1638,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$post_ids[] = $post_id;
}
- if (sizeof($post_ids))
+ if (count($post_ids))
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 1 - post_attachment
@@ -1684,7 +1684,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
$db->sql_freeresult($result);
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_attachment = 1 - topic_attachment
@@ -1736,7 +1736,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
$db->sql_freeresult($result);
- if (!sizeof($forum_ids))
+ if (!count($forum_ids))
{
break;
}
@@ -1775,7 +1775,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// 3: Get post count for each forum (optional)
if ($sync_extra)
{
- if (sizeof($forum_ids) == 1)
+ if (count($forum_ids) == 1)
{
$sql = 'SELECT SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted
FROM ' . TOPICS_TABLE . ' t
@@ -1795,7 +1795,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
while ($row = $db->sql_fetchrow($result))
{
- $forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];
+ $forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];
$forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts_approved'];
$forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved'];
@@ -1805,7 +1805,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
// 4: Get last_post_id for each forum
- if (sizeof($forum_ids) == 1)
+ if (count($forum_ids) == 1)
{
$sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id
FROM ' . TOPICS_TABLE . ' t
@@ -1825,7 +1825,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
while ($row = $db->sql_fetchrow($result))
{
- $forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];
+ $forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];
$forum_data[$forum_id]['last_post_id'] = (int) $row['last_post_id'];
@@ -1834,7 +1834,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$db->sql_freeresult($result);
// 5: Retrieve last_post infos
- if (sizeof($post_ids))
+ if (count($post_ids))
{
$sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
@@ -1902,7 +1902,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
}
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
@@ -2025,20 +2025,20 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
// Now we delete empty topics and orphan posts
- if (sizeof($delete_posts))
+ if (count($delete_posts))
{
delete_posts('topic_id', array_keys($delete_posts), false);
unset($delete_posts);
}
- if (!sizeof($topic_data))
+ if (!count($topic_data))
{
// If we get there, topic ids were invalid or topics did not contain any posts
delete_topics($where_type, $where_ids, true);
return;
}
- if (sizeof($delete_topics))
+ if (count($delete_topics))
{
$delete_topic_ids = array();
foreach ($delete_topics as $topic_id => $void)
@@ -2081,7 +2081,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$db->sql_freeresult($result);
// Make sure shadow topics do link to existing topics
- if (sizeof($moved_topics))
+ if (count($moved_topics))
{
$delete_topics = array();
@@ -2098,7 +2098,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
$db->sql_freeresult($result);
- if (sizeof($delete_topics))
+ if (count($delete_topics))
{
delete_topics('topic_id', $delete_topics, false);
}
@@ -2121,7 +2121,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$db->sql_freeresult($result);
$sync_shadow_topics = array();
- if (sizeof($post_ids))
+ if (count($post_ids))
{
$sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
@@ -2174,7 +2174,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$shadow_topic_data = array();
// Update the information we collected
- if (sizeof($sync_shadow_topics))
+ if (count($sync_shadow_topics))
{
foreach ($sync_shadow_topics as $sync_topic_id => $sql_ary)
{
@@ -2239,7 +2239,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
}
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
@@ -2256,7 +2256,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// if some topics have been resync'ed then resync parent forums
// except when we're only syncing a range, we don't want to sync forums during
// batch processing.
- if ($resync_parents && sizeof($resync_forums) && $where_type != 'range')
+ if ($resync_parents && count($resync_forums) && $where_type != 'range')
{
sync('forum', 'forum_id', array_values($resync_forums), true, true);
}
@@ -2278,7 +2278,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync
$forum_id = array($forum_id);
}
- if (!sizeof($forum_id))
+ if (!count($forum_id))
{
return;
}
@@ -2369,6 +2369,16 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync
$topic_list = array_unique($topic_list);
}
+ /**
+ * Perform additional actions before topic deletion via pruning
+ *
+ * @event core.prune_delete_before
+ * @var int[] topic_list The IDs of the topics to be deleted
+ * @since 3.2.2-RC1
+ */
+ $vars = array('topic_list');
+ extract($phpbb_dispatcher->trigger_event('core.prune_delete_before', compact($vars)));
+
return delete_topics('topic_id', $topic_list, $auto_sync, false);
}
@@ -2441,7 +2451,7 @@ function phpbb_cache_moderators($db, $cache, $auth)
$hold_ary = $auth->acl_user_raw_data(false, 'm_%', false);
// Add users?
- if (sizeof($hold_ary))
+ if (!empty($hold_ary))
{
// At least one moderative option warrants a display
$ug_id_ary = array_keys($hold_ary);
@@ -2486,7 +2496,7 @@ function phpbb_cache_moderators($db, $cache, $auth)
}
$db->sql_freeresult($result);
- if (sizeof($hold_ary))
+ if (count($hold_ary))
{
// Get usernames...
$sql = 'SELECT user_id, username
@@ -2526,7 +2536,7 @@ function phpbb_cache_moderators($db, $cache, $auth)
// Now to the groups...
$hold_ary = $auth->acl_group_raw_data(false, 'm_%', false);
- if (sizeof($hold_ary))
+ if (!empty($hold_ary))
{
$ug_id_ary = array_keys($hold_ary);
@@ -2630,7 +2640,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
{
// update foes for some user
- if (is_array($user_id) && sizeof($user_id))
+ if (is_array($user_id) && count($user_id))
{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', $user_id) . '
@@ -2640,7 +2650,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
}
// update foes for some group
- if (is_array($group_id) && sizeof($group_id))
+ if (is_array($group_id) && count($group_id))
{
// Grab group settings...
$sql_ary = array(
@@ -2674,7 +2684,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
}
$db->sql_freeresult($result);
- if (!sizeof($groups))
+ if (!count($groups))
{
return;
}
@@ -2704,7 +2714,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
}
$db->sql_freeresult($result);
- if (sizeof($users))
+ if (count($users))
{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', $users) . '
@@ -2727,7 +2737,7 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
}
}
- if (sizeof($perms))
+ if (count($perms))
{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', array_unique($perms)) . '
@@ -2990,7 +3000,7 @@ function tidy_warnings()
}
$db->sql_freeresult($result);
- if (sizeof($warning_list))
+ if (count($warning_list))
{
$db->sql_transaction('begin');
@@ -3032,6 +3042,8 @@ function tidy_database()
}
$db->sql_freeresult($result);
+ $db->sql_transaction('begin');
+
// Delete those rows from the acl tables not having listed the forums above
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true);
@@ -3041,6 +3053,8 @@ function tidy_database()
WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true);
$db->sql_query($sql);
+ $db->sql_transaction('commit');
+
$config->set('database_last_gc', time(), false);
}
diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php
index 4fe7e71117..e95fa40a58 100644
--- a/phpBB/includes/functions_compatibility.php
+++ b/phpBB/includes/functions_compatibility.php
@@ -391,7 +391,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $
*
* @deprecated 3.1.0 (To be removed: 3.3.0)
*/
-function get_tables(&$db)
+function get_tables($db)
{
$db_tools_factory = new \phpbb\db\tools\factory();
$db_tools = $db_tools_factory->get($db);
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 910708f502..e86da77b38 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -210,7 +210,7 @@ class compress_zip extends compress
/**
* Constructor
*/
- function compress_zip($mode, $file)
+ function __construct($mode, $file)
{
global $phpbb_filesystem;
@@ -409,7 +409,7 @@ class compress_zip extends compress
function close()
{
// Write out central file directory and footer ... if it exists
- if (sizeof($this->ctrl_dir))
+ if (count($this->ctrl_dir))
{
fwrite($this->fp, $this->file());
}
@@ -511,8 +511,8 @@ class compress_zip extends compress
$ctrldir = implode('', $this->ctrl_dir);
return $ctrldir . $this->eof_cdh .
- pack('v', sizeof($this->ctrl_dir)) . // total # of entries "on this disk"
- pack('v', sizeof($this->ctrl_dir)) . // total # of entries overall
+ pack('v', count($this->ctrl_dir)) . // total # of entries "on this disk"
+ pack('v', count($this->ctrl_dir)) . // total # of entries overall
pack('V', strlen($ctrldir)) . // size of central dir
pack('V', $this->datasec_len) . // offset to start of central dir
"\x00\x00"; // .zip file comment length
@@ -569,7 +569,7 @@ class compress_tar extends compress
/**
* Constructor
*/
- function compress_tar($mode, $file, $type = '')
+ function __construct($mode, $file, $type = '')
{
global $phpbb_filesystem;
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 06223027d8..2542be5e02 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -336,7 +336,7 @@ function get_context($text, $words, $length = 400)
$text = str_replace($entities, $characters, $text);
$word_indizes = array();
- if (sizeof($words))
+ if (count($words))
{
$match = '';
// find the starting indizes of all words
@@ -361,12 +361,12 @@ function get_context($text, $words, $length = 400)
}
unset($match);
- if (sizeof($word_indizes))
+ if (count($word_indizes))
{
$word_indizes = array_unique($word_indizes);
sort($word_indizes);
- $wordnum = sizeof($word_indizes);
+ $wordnum = count($word_indizes);
// number of characters on the right and left side of each word
$sequence_length = (int) ($length / (2 * $wordnum)) - 2;
$final_text = '';
@@ -434,7 +434,7 @@ function get_context($text, $words, $length = 400)
}
}
- if (!sizeof($words) || !sizeof($word_indizes))
+ if (!count($words) || !count($word_indizes))
{
return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text));
}
@@ -627,7 +627,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text
}
else
{
- $bbcode->bbcode($bitfield);
+ $bbcode->bbcode_set_bitfield($bitfield);
}
$bbcode->bbcode_second_pass($text, $uid);
@@ -1021,7 +1021,7 @@ function censor_text($text)
}
}
- if (sizeof($censors))
+ if (count($censors))
{
return preg_replace($censors['match'], $censors['replace'], $text);
}
@@ -1079,7 +1079,7 @@ function smiley_text($text, $force_option = false)
*/
function parse_attachments($forum_id, &$message, &$attachments, &$update_count_ary, $preview = false)
{
- if (!sizeof($attachments))
+ if (!count($attachments))
{
return;
}
@@ -1114,7 +1114,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
}
// Grab attachments (security precaution)
- if (sizeof($attach_ids))
+ if (count($attach_ids))
{
global $db;
@@ -1151,7 +1151,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
foreach ($attachments as $attachment)
{
- if (!sizeof($attachment))
+ if (!count($attachment))
{
continue;
}
@@ -1443,7 +1443,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al
$chars = array_map('utf8_htmlspecialchars', $_chars);
// Now check the length ;)
- if (sizeof($chars) > $max_length)
+ if (count($chars) > $max_length)
{
// Cut off the last elements from the array
$string = implode('', array_slice($chars, 0, $max_length - utf8_strlen($append)));
@@ -1482,6 +1482,8 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al
* Get username details for placing into templates.
* This function caches all modes on first call, except for no_profile and anonymous user - determined by $user_id.
*
+* @html Username spans and links
+*
* @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link)
* @param int $user_id The users id
* @param string $username The users name
@@ -1501,6 +1503,7 @@ function get_username_string($mode, $user_id, $username, $username_colour = '',
{
global $phpbb_root_path, $phpEx;
+ /** @html Username spans and links for usage in the template */
$_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u={USER_ID}');
$_profile_cache['tpl_noprofile'] = '<span class="username">{USERNAME}</span>';
$_profile_cache['tpl_noprofile_colour'] = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>';
@@ -1651,7 +1654,7 @@ function phpbb_generate_string_list($items, $user)
return '';
}
- $count = sizeof($items);
+ $count = count($items);
$last_item = array_pop($items);
$lang_key = 'STRING_LIST_MULTI';
@@ -1672,7 +1675,7 @@ class bitfield
{
var $data;
- function bitfield($bitfield = '')
+ function __construct($bitfield = '')
{
$this->data = base64_decode($bitfield);
}
@@ -1758,3 +1761,48 @@ class bitfield
$this->data = $this->data | $bitfield->get_blob();
}
}
+
+/**
+ * Formats the quote according to the given BBCode status setting
+ *
+ * @param phpbb\language\language $language Language class
+ * @param parse_message $message_parser Message parser class
+ * @param phpbb\textformatter\utils_interface $text_formatter_utils Text formatter utilities
+ * @param bool $bbcode_status The status of the BBCode setting
+ * @param array $quote_attributes The attributes of the quoted post
+ * @param string $message_link Link of the original quoted post
+ */
+function phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link = '')
+{
+ if ($bbcode_status)
+ {
+ $quote_text = $text_formatter_utils->generate_quote(
+ censor_text($message_parser->message),
+ $quote_attributes
+ );
+
+ $message_parser->message = $quote_text . "\n\n";
+ }
+ else
+ {
+ $offset = 0;
+ $quote_string = "&gt; ";
+ $message = censor_text(trim($message_parser->message));
+ // see if we are nesting. It's easily tricked but should work for one level of nesting
+ if (strpos($message, "&gt;") !== false)
+ {
+ $offset = 10;
+ }
+ $message = utf8_wordwrap($message, 75 + $offset, "\n");
+
+ $message = $quote_string . $message;
+ $message = str_replace("\n", "\n" . $quote_string, $message);
+
+ $message_parser->message = $quote_attributes['author'] . " " . $language->lang('WROTE') . ":\n" . $message . "\n";
+ }
+
+ if ($message_link)
+ {
+ $message_parser->message = $message_link . $message_parser->message;
+ }
+}
diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php
index 176e3dd6de..2cfbe9541d 100644
--- a/phpBB/includes/functions_convert.php
+++ b/phpBB/includes/functions_convert.php
@@ -192,7 +192,7 @@ function get_group_id($group_name)
$db->sql_freeresult($result);
}
- if (!sizeof($group_mapping))
+ if (!count($group_mapping))
{
add_default_groups();
return get_group_id($group_name);
@@ -249,7 +249,7 @@ function validate_website($url)
{
return '';
}
- else if (!preg_match('#^[a-z0-9]+://#i', $url) && strlen($url) > 0)
+ else if (!preg_match('#^http[s]?://#i', $url) && strlen($url) > 0)
{
return 'http://' . $url;
}
@@ -307,7 +307,7 @@ function decode_ip($int_ip)
$hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
// Any mod changing the way ips are stored? Then we are not able to convert and enter the ip "as is" to not "destroy" anything...
- if (sizeof($hexipbang) < 4)
+ if (count($hexipbang) < 4)
{
return $int_ip;
}
@@ -479,7 +479,7 @@ function import_avatar_gallery($gallery_name = '', $subdirs_as_galleries = false
$dir->close();
}
- for ($i = 0, $end = sizeof($dirlist); $i < $end; ++$i)
+ for ($i = 0, $end = count($dirlist); $i < $end; ++$i)
{
$dir = $dirlist[$i];
@@ -1261,7 +1261,7 @@ function get_config()
}
}
- if (!sizeof($convert_config))
+ if (!count($convert_config))
{
$convert->p_master->error($user->lang['CONV_ERROR_CONFIG_EMPTY'], __LINE__, __FILE__);
}
@@ -1406,9 +1406,9 @@ function get_path($src_path, $src_url, $test_file)
$url_parts = explode('/', $m[2]);
if (substr($src_url, -1) != '/')
{
- if (preg_match('/.*\.([a-z0-9]{3,4})$/i', $url_parts[sizeof($url_parts) - 1]))
+ if (preg_match('/.*\.([a-z0-9]{3,4})$/i', $url_parts[count($url_parts) - 1]))
{
- $url_parts[sizeof($url_parts) - 1] = '';
+ $url_parts[count($url_parts) - 1] = '';
}
else
{
@@ -1425,9 +1425,9 @@ function get_path($src_path, $src_url, $test_file)
$path_array = array();
$phpbb_parts = explode('/', $script_path);
- for ($i = 0, $end = sizeof($url_parts); $i < $end; ++$i)
+ for ($i = 0, $end = count($url_parts); $i < $end; ++$i)
{
- if ($i < sizeof($phpbb_parts[$i]) && $url_parts[$i] == $phpbb_parts[$i])
+ if ($i < count($phpbb_parts[$i]) && $url_parts[$i] == $phpbb_parts[$i])
{
$path_array[] = $url_parts[$i];
unset($url_parts[$i]);
@@ -1435,7 +1435,7 @@ function get_path($src_path, $src_url, $test_file)
else
{
$path = '';
- for ($j = $i, $end2 = sizeof($phpbb_parts); $j < $end2; ++$j)
+ for ($j = $i, $end2 = count($phpbb_parts); $j < $end2; ++$j)
{
$path .= '../';
}
@@ -1458,7 +1458,7 @@ function get_path($src_path, $src_url, $test_file)
function compare_table($tables, $tablename, &$prefixes)
{
- for ($i = 0, $table_size = sizeof($tables); $i < $table_size; ++$i)
+ for ($i = 0, $table_size = count($tables); $i < $table_size; ++$i)
{
if (preg_match('/(.*)' . $tables[$i] . '$/', $tablename, $m))
{
@@ -1754,7 +1754,7 @@ function add_default_groups()
);
}
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_multi_insert(GROUPS_TABLE, $sql_ary);
}
@@ -1786,7 +1786,7 @@ function add_groups_to_teampage()
}
$db->sql_freeresult($result);
- if (sizeof($teampage_ary))
+ if (count($teampage_ary))
{
$db->sql_multi_insert(TEAMPAGE_TABLE, $teampage_ary);
}
@@ -2101,7 +2101,7 @@ function update_topics_posted()
}
unset($posted);
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
}
@@ -2136,7 +2136,7 @@ function fix_empty_primary_groups()
}
$db->sql_freeresult($result);
- if (sizeof($user_ids))
+ if (count($user_ids))
{
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('administrators') . '
WHERE group_id = 0 AND ' . $db->sql_in_set('user_id', $user_ids));
@@ -2152,7 +2152,7 @@ function fix_empty_primary_groups()
}
$db->sql_freeresult($result);
- if (sizeof($user_ids))
+ if (count($user_ids))
{
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('global_moderators') . '
WHERE group_id = 0 AND ' . $db->sql_in_set('user_id', $user_ids));
@@ -2264,7 +2264,7 @@ function convert_bbcode($message, $convert_size = true, $extended_bbcodes = fals
"\n\n"
);
- for ($i = 0, $end = sizeof($str_from); $i < $end; ++$i)
+ for ($i = 0, $end = count($str_from); $i < $end; ++$i)
{
$origx[] = '#\\' . str_replace(']', '\\]', $str_from[$i]) . '#is';
$replx[] = $str_to[$i];
@@ -2273,7 +2273,7 @@ function convert_bbcode($message, $convert_size = true, $extended_bbcodes = fals
if (preg_match_all('#\[email=([^\]]+)\](.*?)\[/email\]#i', $message, $m))
{
- for ($i = 0, $end = sizeof($m[1]); $i < $end; ++$i)
+ for ($i = 0, $end = count($m[1]); $i < $end; ++$i)
{
if ($m[1][$i] == $m[2][$i])
{
@@ -2292,7 +2292,7 @@ function convert_bbcode($message, $convert_size = true, $extended_bbcodes = fals
$message = preg_replace('#\[size=([0-9]+)\](.*?)\[/size\]#i', '[size=\1]\2[/size]', $message);
$message = preg_replace('#\[size=[0-9]{2,}\](.*?)\[/size\]#i', '[size=29]\1[/size]', $message);
- for ($i = sizeof($size); $i;)
+ for ($i = count($size); $i;)
{
$i--;
$message = str_replace('[size=' . $i . ']', '[size=' . $size[$i] . ']', $message);
@@ -2335,9 +2335,9 @@ function copy_file($src, $trg, $overwrite = false, $die_on_failure = true, $sour
$path = $phpbb_root_path;
$parts = explode('/', $trg);
- unset($parts[sizeof($parts) - 1]);
+ unset($parts[count($parts) - 1]);
- for ($i = 0, $end = sizeof($parts); $i < $end; ++$i)
+ for ($i = 0, $end = count($parts); $i < $end; ++$i)
{
$path .= $parts[$i] . '/';
@@ -2437,7 +2437,7 @@ function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_
if ($copy_subdirs)
{
- for ($i = 0, $end = sizeof($dirlist); $i < $end; ++$i)
+ for ($i = 0, $end = count($dirlist); $i < $end; ++$i)
{
$dir = $dirlist[$i];
@@ -2458,21 +2458,21 @@ function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_
$bad_dirs[] = $trg_path . $dir;
}
- if (!sizeof($bad_dirs))
+ if (!count($bad_dirs))
{
copy_dir($src . $dir, $trg . $dir, true, $overwrite, $die_on_failure, $source_relative_path);
}
}
}
- if (sizeof($bad_dirs))
+ if (count($bad_dirs))
{
- $str = (sizeof($bad_dirs) == 1) ? $user->lang['MAKE_FOLDER_WRITABLE'] : $user->lang['MAKE_FOLDERS_WRITABLE'];
+ $str = (count($bad_dirs) == 1) ? $user->lang['MAKE_FOLDER_WRITABLE'] : $user->lang['MAKE_FOLDERS_WRITABLE'];
sort($bad_dirs);
$convert->p_master->error(sprintf($str, implode('<br />', $bad_dirs)), __LINE__, __FILE__);
}
- for ($i = 0, $end = sizeof($filelist); $i < $end; ++$i)
+ for ($i = 0, $end = count($filelist); $i < $end; ++$i)
{
copy_file($src . $filelist[$i], $trg . $filelist[$i], $overwrite, $die_on_failure, $source_relative_path);
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index e5d6d683fe..d0a0c97c4e 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -506,7 +506,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}
}
- $l_subforums = (sizeof($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'];
+ $l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'];
$folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum';
}
else
@@ -537,7 +537,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
// Create last post link information, if appropriate
if ($row['forum_last_post_id'])
{
- if ($row['forum_password_last_post'] === '' && $auth->acl_get('f_read', $row['forum_id_last_post']))
+ if ($row['forum_password_last_post'] === '' && $auth->acl_gets('f_read', 'f_list_topics', $row['forum_id_last_post']))
{
$last_post_subject = censor_text($row['forum_last_post_subject']);
$last_post_subject_truncated = truncate_string($last_post_subject, 30, 255, false, $user->lang['ELLIPSIS']);
@@ -559,7 +559,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
$l_moderator = $moderators_list = '';
if ($display_moderators && !empty($forum_moderators[$forum_id]))
{
- $l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
+ $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
$moderators_list = implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]);
}
@@ -606,7 +606,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
'S_AUTH_READ' => $auth->acl_get('f_read', $row['forum_id']),
'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false,
'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false,
- 'S_SUBFORUMS' => (sizeof($subforums_list)) ? true : false,
+ 'S_SUBFORUMS' => (count($subforums_list)) ? true : false,
'S_DISPLAY_SUBJECT' => ($last_post_subject !== '' && $config['display_last_subject']) ? true : false,
'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST) ? true : false,
@@ -1243,6 +1243,7 @@ function display_user_activity(&$userdata_ary)
}
$userdata = $userdata_ary;
+ $show_user_activity = true;
/**
* Alter list of forums and topics to display as active
*
@@ -1250,9 +1251,11 @@ function display_user_activity(&$userdata_ary)
* @var array userdata User's data
* @var array active_f_row List of active forums
* @var array active_t_row List of active posts
+ * @var bool show_user_activity Show user forum and topic activity
* @since 3.1.0-RC3
+ * @changed 3.2.5-RC1 Added show_user_activity into event
*/
- $vars = array('userdata', 'active_f_row', 'active_t_row');
+ $vars = array('userdata', 'active_f_row', 'active_t_row', 'show_user_activity');
extract($phpbb_dispatcher->trigger_event('core.display_user_activity_modify_actives', compact($vars)));
$userdata_ary = $userdata;
unset($userdata);
@@ -1289,7 +1292,7 @@ function display_user_activity(&$userdata_ary)
'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct),
'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id),
'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id),
- 'S_SHOW_ACTIVITY' => true)
+ 'S_SHOW_ACTIVITY' => $show_user_activity)
);
}
@@ -1648,10 +1651,10 @@ function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabl
($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) &&
// They must be able to read PMs
- sizeof($auth->acl_get_list($user_id, 'u_readpm')) &&
+ count($auth->acl_get_list($user_id, 'u_readpm')) &&
// They must not be permanently banned
- !sizeof(phpbb_get_banned_user_ids($user_id, false)) &&
+ !count(phpbb_get_banned_user_ids($user_id, false)) &&
// They must allow users to contact via PM
(($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm'])
diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php
index e00be1e01a..1f409be58c 100644
--- a/phpBB/includes/functions_download.php
+++ b/phpBB/includes/functions_download.php
@@ -196,7 +196,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
}
// Now the tricky part... let's dance
- header('Cache-Control: public');
+ header('Cache-Control: private');
// Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer.
header('Content-Type: ' . $attachment['mimetype']);
@@ -451,7 +451,7 @@ function set_modified_headers($stamp, $browser)
{
send_status_line(304, 'Not Modified');
// seems that we need those too ... browsers
- header('Cache-Control: public');
+ header('Cache-Control: private');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
return true;
}
@@ -568,7 +568,7 @@ function phpbb_parse_range_request($request_array, $filesize)
$range = explode('-', trim($range_string));
// "-" is invalid, "0-0" however is valid and means the very first byte.
- if (sizeof($range) != 2 || $range[0] === '' && $range[1] === '')
+ if (count($range) != 2 || $range[0] === '' && $range[1] === '')
{
continue;
}
@@ -662,6 +662,8 @@ function phpbb_increment_downloads($db, $ids)
*/
function phpbb_download_handle_forum_auth($db, $auth, $topic_id)
{
+ global $phpbb_container;
+
$sql_array = array(
'SELECT' => 't.topic_visibility, t.forum_id, f.forum_name, f.forum_password, f.parent_id',
'FROM' => array(
@@ -677,7 +679,9 @@ function phpbb_download_handle_forum_auth($db, $auth, $topic_id)
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- if ($row && $row['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))
+ $phpbb_content_visibility = $phpbb_container->get('content.visibility');
+
+ if ($row && !$phpbb_content_visibility->is_visible('topic', $row['forum_id'], $row))
{
send_status_line(404, 'Not Found');
trigger_error('ERROR_NO_ATTACHMENT');
diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php
index cfe8c2a90e..cf0865e608 100644
--- a/phpBB/includes/functions_jabber.php
+++ b/phpBB/includes/functions_jabber.php
@@ -207,7 +207,7 @@ class jabber
*/
function login()
{
- if (!sizeof($this->features))
+ if (!count($this->features))
{
$this->add_to_log('Error: No feature information from server available.');
return false;
@@ -293,7 +293,7 @@ class jabber
*/
function get_log()
{
- if ($this->enable_logging && sizeof($this->log_array))
+ if ($this->enable_logging && count($this->log_array))
{
return implode("<br /><br />", $this->log_array);
}
@@ -400,14 +400,14 @@ class jabber
*/
function response($xml)
{
- if (!is_array($xml) || !sizeof($xml))
+ if (!is_array($xml) || !count($xml))
{
return false;
}
// did we get multiple elements? do one after another
// array('message' => ..., 'presence' => ...)
- if (sizeof($xml) > 1)
+ if (count($xml) > 1)
{
foreach ($xml as $key => $value)
{
@@ -419,7 +419,7 @@ class jabber
{
// or even multiple elements of the same type?
// array('message' => array(0 => ..., 1 => ...))
- if (sizeof(reset($xml)) > 1)
+ if (count(reset($xml)) > 1)
{
foreach (reset($xml) as $value)
{
@@ -858,14 +858,14 @@ class jabber
array_push($children, $vals[$i]['value']);
}
- while (++$i < sizeof($vals))
+ while (++$i < count($vals))
{
switch ($vals[$i]['type'])
{
case 'open':
$tagname = (isset($vals[$i]['tag'])) ? $vals[$i]['tag'] : '';
- $size = (isset($children[$tagname])) ? sizeof($children[$tagname]) : 0;
+ $size = (isset($children[$tagname])) ? count($children[$tagname]) : 0;
if (isset($vals[$i]['attributes']))
{
@@ -883,7 +883,7 @@ class jabber
case 'complete':
$tagname = $vals[$i]['tag'];
- $size = (isset($children[$tagname])) ? sizeof($children[$tagname]) : 0;
+ $size = (isset($children[$tagname])) ? count($children[$tagname]) : 0;
$children[$tagname][$size]['#'] = (isset($vals[$i]['value'])) ? $vals[$i]['value'] : array();
if (isset($vals[$i]['attributes']))
diff --git a/phpBB/includes/functions_mcp.php b/phpBB/includes/functions_mcp.php
index dfe3fefbd0..75e24618de 100644
--- a/phpBB/includes/functions_mcp.php
+++ b/phpBB/includes/functions_mcp.php
@@ -22,12 +22,12 @@ if (!defined('IN_PHPBB'))
/**
* Functions used to generate additional URL paramters
*/
-function phpbb_module__url($mode, &$module_row)
+function phpbb_module__url($mode, $module_row)
{
return phpbb_extra_url();
}
-function phpbb_module_notes_url($mode, &$module_row)
+function phpbb_module_notes_url($mode, $module_row)
{
if ($mode == 'front')
{
@@ -38,7 +38,7 @@ function phpbb_module_notes_url($mode, &$module_row)
return ($user_id) ? "&amp;u=$user_id" : '';
}
-function phpbb_module_warn_url($mode, &$module_row)
+function phpbb_module_warn_url($mode, $module_row)
{
if ($mode == 'front' || $mode == 'list')
{
@@ -64,27 +64,27 @@ function phpbb_module_warn_url($mode, &$module_row)
}
}
-function phpbb_module_main_url($mode, &$module_row)
+function phpbb_module_main_url($mode, $module_row)
{
return phpbb_extra_url();
}
-function phpbb_module_logs_url($mode, &$module_row)
+function phpbb_module_logs_url($mode, $module_row)
{
return phpbb_extra_url();
}
-function phpbb_module_ban_url($mode, &$module_row)
+function phpbb_module_ban_url($mode, $module_row)
{
return phpbb_extra_url();
}
-function phpbb_module_queue_url($mode, &$module_row)
+function phpbb_module_queue_url($mode, $module_row)
{
return phpbb_extra_url();
}
-function phpbb_module_reports_url($mode, &$module_row)
+function phpbb_module_reports_url($mode, $module_row)
{
return phpbb_extra_url();
}
@@ -113,7 +113,7 @@ function phpbb_get_topic_data($topic_ids, $acl_list = false, $read_tracking = fa
$topics = array();
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
return array();
}
@@ -130,7 +130,7 @@ function phpbb_get_topic_data($topic_ids, $acl_list = false, $read_tracking = fa
$cache_topic_ids = array();
}
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$sql_array = array(
'SELECT' => 't.*, f.*',
@@ -197,11 +197,11 @@ function phpbb_get_topic_data($topic_ids, $acl_list = false, $read_tracking = fa
*/
function phpbb_get_post_data($post_ids, $acl_list = false, $read_tracking = false)
{
- global $db, $auth, $config, $user;
+ global $db, $auth, $config, $user, $phpbb_container;
$rowset = array();
- if (!sizeof($post_ids))
+ if (!count($post_ids))
{
return array();
}
@@ -246,6 +246,8 @@ function phpbb_get_post_data($post_ids, $acl_list = false, $read_tracking = fals
$result = $db->sql_query($sql);
unset($sql_array);
+ $phpbb_content_visibility = $phpbb_container->get('content.visibility');
+
while ($row = $db->sql_fetchrow($result))
{
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
@@ -253,7 +255,7 @@ function phpbb_get_post_data($post_ids, $acl_list = false, $read_tracking = fals
continue;
}
- if ($row['post_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))
+ if (!$phpbb_content_visibility->is_visible('post', $row['forum_id'], $row))
{
// Moderators without the permission to approve post should at least not see them. ;)
continue;
@@ -280,7 +282,7 @@ function phpbb_get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking =
$forum_id = array($forum_id);
}
- if (!sizeof($forum_id))
+ if (!count($forum_id))
{
return array();
}
@@ -329,7 +331,7 @@ function phpbb_get_pm_data($pm_ids)
$rowset = array();
- if (!sizeof($pm_ids))
+ if (!count($pm_ids))
{
return array();
}
@@ -730,7 +732,7 @@ function phpbb_check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_foru
}
$db->sql_freeresult($result);
- if (!sizeof($ids))
+ if (!count($ids))
{
return false;
}
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index ab7f00a65a..7f8238e1bf 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -24,8 +24,9 @@ if (!defined('IN_PHPBB'))
*/
class messenger
{
- var $msg, $extra_headers, $replyto, $from, $subject;
+ var $msg, $replyto, $from, $subject;
var $addresses = array();
+ var $extra_headers = array();
var $mail_priority = MAIL_NORMAL_PRIORITY;
var $use_queue = true;
@@ -36,7 +37,7 @@ class messenger
/**
* Constructor
*/
- function messenger($use_queue = true)
+ function __construct($use_queue = true)
{
global $config;
@@ -84,7 +85,7 @@ class messenger
return;
}
- $pos = isset($this->addresses['to']) ? sizeof($this->addresses['to']) : 0;
+ $pos = isset($this->addresses['to']) ? count($this->addresses['to']) : 0;
$this->addresses['to'][$pos]['email'] = trim($address);
@@ -109,7 +110,7 @@ class messenger
return;
}
- $pos = isset($this->addresses['cc']) ? sizeof($this->addresses['cc']) : 0;
+ $pos = isset($this->addresses['cc']) ? count($this->addresses['cc']) : 0;
$this->addresses['cc'][$pos]['email'] = trim($address);
$this->addresses['cc'][$pos]['name'] = trim($realname);
}
@@ -124,7 +125,7 @@ class messenger
return;
}
- $pos = isset($this->addresses['bcc']) ? sizeof($this->addresses['bcc']) : 0;
+ $pos = isset($this->addresses['bcc']) ? count($this->addresses['bcc']) : 0;
$this->addresses['bcc'][$pos]['email'] = trim($address);
$this->addresses['bcc'][$pos]['name'] = trim($realname);
}
@@ -140,7 +141,7 @@ class messenger
return;
}
- $pos = isset($this->addresses['im']) ? sizeof($this->addresses['im']) : 0;
+ $pos = isset($this->addresses['im']) ? count($this->addresses['im']) : 0;
$this->addresses['im'][$pos]['uid'] = trim($address);
$this->addresses['im'][$pos]['name'] = trim($realname);
}
@@ -180,10 +181,9 @@ class messenger
/**
* Adds X-AntiAbuse headers
*
- * @param array $config Configuration array
- * @param user $user A user object
- *
- * @return null
+ * @param \phpbb\config\config $config Config object
+ * @param \phpbb\user $user User object
+ * @return void
*/
function anti_abuse_headers($config, $user)
{
@@ -325,9 +325,26 @@ class messenger
));
$subject = $this->subject;
- $message = $this->msg;
+ $template = $this->template;
+ /**
+ * Event to modify the template before parsing
+ *
+ * @event core.modify_notification_template
+ * @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH
+ * @var bool break Flag indicating if the function only formats the subject
+ * and the message without sending it
+ * @var string subject The message subject
+ * @var \phpbb\template\template template The (readonly) template object
+ * @since 3.2.4-RC1
+ */
+ $vars = array('method', 'break', 'subject', 'template');
+ extract($phpbb_dispatcher->trigger_event('core.modify_notification_template', compact($vars)));
+
+ // Parse message through template
+ $message = trim($this->template->assign_display('body'));
+
/**
- * Event to modify notification message text before parsing
+ * Event to modify notification message text after parsing
*
* @event core.modify_notification_message
* @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH
@@ -337,19 +354,12 @@ class messenger
* @var string message The message text
* @since 3.1.11-RC1
*/
- $vars = array(
- 'method',
- 'break',
- 'subject',
- 'message',
- );
+ $vars = array('method', 'break', 'subject', 'message');
extract($phpbb_dispatcher->trigger_event('core.modify_notification_message', compact($vars)));
+
$this->subject = $subject;
$this->msg = $message;
- unset($subject, $message);
-
- // Parse message through template
- $this->msg = trim($this->template->assign_display('body'));
+ unset($subject, $message, $template);
// Because we use \n for newlines in the body message we need to fix line encoding errors for those admins who uploaded email template files in the wrong encoding
$this->msg = str_replace("\r\n", "\n", $this->msg);
@@ -368,6 +378,12 @@ class messenger
$this->subject = (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']);
}
+ if (preg_match('#^(List-Unsubscribe:(.*?))$#m', $this->msg, $match))
+ {
+ $this->extra_headers[] = $match[1];
+ $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
+ }
+
if ($drop_header)
{
$this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
@@ -416,7 +432,7 @@ class messenger
switch ($type)
{
case 'EMAIL':
- $message = '<strong>EMAIL/' . (($config['smtp_delivery']) ? 'SMTP' : 'PHP/' . $config['email_function_name'] . '()') . '</strong>';
+ $message = '<strong>EMAIL/' . (($config['smtp_delivery']) ? 'SMTP' : 'PHP/mail()') . '</strong>';
break;
default:
@@ -503,7 +519,7 @@ class messenger
$vars = array('headers');
extract($phpbb_dispatcher->trigger_event('core.modify_email_headers', compact($vars)));
- if (sizeof($this->extra_headers))
+ if (count($this->extra_headers))
{
$headers = array_merge($headers, $this->extra_headers);
}
@@ -516,7 +532,7 @@ class messenger
*/
function msg_email()
{
- global $config;
+ global $config, $phpbb_dispatcher;
if (empty($config['email_enable']))
{
@@ -544,6 +560,33 @@ class messenger
$contact_name = htmlspecialchars_decode($config['board_contact_name']);
$board_contact = (($contact_name !== '') ? '"' . mail_encode($contact_name) . '" ' : '') . '<' . $config['board_contact'] . '>';
+ $break = false;
+ $addresses = $this->addresses;
+ $subject = $this->subject;
+ $msg = $this->msg;
+ /**
+ * Event to send message via external transport
+ *
+ * @event core.notification_message_email
+ * @var bool break Flag indicating if the function return after hook
+ * @var array addresses The message recipients
+ * @var string subject The message subject
+ * @var string msg The message text
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'break',
+ 'addresses',
+ 'subject',
+ 'msg',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.notification_message_email', compact($vars)));
+
+ if ($break)
+ {
+ return true;
+ }
+
if (empty($this->replyto))
{
$this->replyto = $board_contact;
@@ -749,7 +792,7 @@ class queue
/**
* constructor
*/
- function queue()
+ function __construct()
{
global $phpEx, $phpbb_root_path, $phpbb_filesystem, $phpbb_container;
@@ -782,7 +825,7 @@ class queue
*/
function process()
{
- global $config, $phpEx, $phpbb_root_path, $user;
+ global $config, $phpEx, $phpbb_root_path, $user, $phpbb_dispatcher;
$lock = new \phpbb\lock\flock($this->cache_file);
$lock->acquire();
@@ -814,7 +857,7 @@ class queue
}
$package_size = $data_ary['package_size'];
- $num_items = (!$package_size || sizeof($data_ary['data']) < $package_size) ? sizeof($data_ary['data']) : $package_size;
+ $num_items = (!$package_size || count($data_ary['data']) < $package_size) ? count($data_ary['data']) : $package_size;
/*
* This code is commented out because it causes problems on some web hosts.
@@ -823,9 +866,9 @@ class queue
* web host and the package size setting is wrong.
// If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs...
- if (sizeof($data_ary['data']) > $package_size * 2.5)
+ if (count($data_ary['data']) > $package_size * 2.5)
{
- $num_items = sizeof($data_ary['data']);
+ $num_items = count($data_ary['data']);
}
*/
@@ -879,23 +922,45 @@ class queue
switch ($object)
{
case 'email':
- $err_msg = '';
- $to = (!$to) ? 'undisclosed-recipients:;' : $to;
-
- if ($config['smtp_delivery'])
- {
- $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers);
- }
- else
+ $break = false;
+ /**
+ * Event to send message via external transport
+ *
+ * @event core.notification_message_process
+ * @var bool break Flag indicating if the function return after hook
+ * @var array addresses The message recipients
+ * @var string subject The message subject
+ * @var string msg The message text
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'break',
+ 'addresses',
+ 'subject',
+ 'msg',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.notification_message_process', compact($vars)));
+
+ if (!$break)
{
- $result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg);
- }
+ $err_msg = '';
+ $to = (!$to) ? 'undisclosed-recipients:;' : $to;
- if (!$result)
- {
- $messenger = new messenger();
- $messenger->error('EMAIL', $err_msg);
- continue 2;
+ if ($config['smtp_delivery'])
+ {
+ $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers);
+ }
+ else
+ {
+ $result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg);
+ }
+
+ if (!$result)
+ {
+ $messenger = new messenger();
+ $messenger->error('EMAIL', $err_msg);
+ continue 2;
+ }
}
break;
@@ -914,7 +979,7 @@ class queue
}
// No more data for this object? Unset it
- if (!sizeof($this->queue_data[$object]['data']))
+ if (!count($this->queue_data[$object]['data']))
{
unset($this->queue_data[$object]);
}
@@ -930,7 +995,7 @@ class queue
}
}
- if (!sizeof($this->queue_data))
+ if (!count($this->queue_data))
{
@unlink($this->cache_file);
}
@@ -965,7 +1030,7 @@ class queue
*/
function save()
{
- if (!sizeof($this->data))
+ if (!count($this->data))
{
return;
}
@@ -979,7 +1044,7 @@ class queue
foreach ($this->queue_data as $object => $data_ary)
{
- if (isset($this->data[$object]) && sizeof($this->data[$object]))
+ if (isset($this->data[$object]) && count($this->data[$object]))
{
$this->data[$object]['data'] = array_merge($data_ary['data'], $this->data[$object]['data']);
}
@@ -1067,7 +1132,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false)
$mail_rcpt = $mail_to = $mail_cc = array();
// Build correct addresses for RCPT TO command and the client side display (TO, CC)
- if (isset($addresses['to']) && sizeof($addresses['to']))
+ if (isset($addresses['to']) && count($addresses['to']))
{
foreach ($addresses['to'] as $which_ary)
{
@@ -1076,7 +1141,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false)
}
}
- if (isset($addresses['bcc']) && sizeof($addresses['bcc']))
+ if (isset($addresses['bcc']) && count($addresses['bcc']))
{
foreach ($addresses['bcc'] as $which_ary)
{
@@ -1084,7 +1149,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false)
}
}
- if (isset($addresses['cc']) && sizeof($addresses['cc']))
+ if (isset($addresses['cc']) && count($addresses['cc']))
{
foreach ($addresses['cc'] as $which_ary)
{
@@ -1263,7 +1328,7 @@ class smtp_class
var $backtrace = false;
var $backtrace_log = array();
- function smtp_class()
+ function __construct()
{
// Always create a backtrace for admins to identify SMTP problems
$this->backtrace = true;
@@ -1516,6 +1581,14 @@ class smtp_class
*/
protected function starttls()
{
+ global $config;
+
+ // allow SMTPS (what was used by phpBB 3.0) if hostname is prefixed with tls:// or ssl://
+ if (strpos($config['smtp_host'], 'tls://') === 0 || strpos($config['smtp_host'], 'ssl://') === 0)
+ {
+ return true;
+ }
+
if (!function_exists('stream_socket_enable_crypto'))
{
return false;
@@ -1538,7 +1611,9 @@ class smtp_class
if (socket_set_blocking($this->socket, 1))
{
- $result = stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+ // https://secure.php.net/manual/en/function.stream-socket-enable-crypto.php#119122
+ $crypto = (phpbb_version_compare(PHP_VERSION, '5.6.7', '<')) ? STREAM_CRYPTO_METHOD_TLS_CLIENT : STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
+ $result = stream_socket_enable_crypto($this->socket, true, $crypto);
socket_set_blocking($this->socket, (int) $stream_meta['blocked']);
}
@@ -1802,11 +1877,11 @@ function mail_encode($str, $eol = "\r\n")
$array = utf8_str_split($str);
$str = '';
- while (sizeof($array))
+ while (count($array))
{
$text = '';
- while (sizeof($array) && intval((strlen($text . $array[0]) + 2) / 3) << 2 <= $split_length)
+ while (count($array) && intval((strlen($text . $array[0]) + 2) / 3) << 2 <= $split_length)
{
$text .= array_shift($array);
}
@@ -1839,7 +1914,8 @@ function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg)
// On some PHP Versions mail() *may* fail if there are newlines within the subject.
// Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8.
// Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used)
- $result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
+ $additional_parameters = $config['email_force_sender'] ? '-f' . $config['board_email'] : '';
+ $result = mail($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers, $additional_parameters);
$collector->uninstall();
$err_msg = $collector->format_errors();
diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php
index 7a1991d69a..88dafc4300 100644
--- a/phpBB/includes/functions_module.php
+++ b/phpBB/includes/functions_module.php
@@ -40,7 +40,7 @@ class p_master
* Constuctor
* Set module include path
*/
- function p_master($include_path = false)
+ function __construct($include_path = false)
{
global $phpbb_root_path;
@@ -243,7 +243,7 @@ class p_master
}
}
- $depth = sizeof($this->module_cache['parents'][$row['module_id']]);
+ $depth = count($this->module_cache['parents'][$row['module_id']]);
// We need to prefix the functions to not create a naming conflict
@@ -279,7 +279,7 @@ class p_master
'parent' => (int) $row['parent_id'],
'cat' => ($row['right_id'] > $row['left_id'] + 1) ? true : false,
- 'is_duplicate' => ($row['module_basename'] && sizeof($names[$row['module_basename'] . '_' . $row['module_mode']]) > 1) ? true : false,
+ 'is_duplicate' => ($row['module_basename'] && count($names[$row['module_basename'] . '_' . $row['module_mode']]) > 1) ? true : false,
'name' => (string) $row['module_basename'],
'mode' => (string) $row['module_mode'],
@@ -431,7 +431,7 @@ class p_master
extract($phpbb_dispatcher->trigger_event('core.module_auth', compact($vars)));
$tokens = $match[0];
- for ($i = 0, $size = sizeof($tokens); $i < $size; $i++)
+ for ($i = 0, $size = count($tokens); $i < $size; $i++)
{
$token = &$tokens[$i];
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index d9f395efb3..2cce77e092 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -114,7 +114,7 @@ function generate_smilies($mode, $forum_id)
}
$db->sql_freeresult($result);
- if (sizeof($smilies))
+ if (count($smilies))
{
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path();
@@ -200,13 +200,15 @@ function update_post_information($type, $ids, $return_update_sql = false)
$topic_condition = '';
}
- if (sizeof($ids) == 1)
+ if (count($ids) == 1)
{
- $sql = 'SELECT MAX(p.post_id) as last_post_id
+ $sql = 'SELECT p.post_id as last_post_id
FROM ' . POSTS_TABLE . " p $topic_join
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
$topic_condition
- AND p.post_visibility = " . ITEM_APPROVED;
+ AND p.post_visibility = " . ITEM_APPROVED . "
+ ORDER BY p.post_id DESC";
+ $result = $db->sql_query_limit($sql, 1);
}
else
{
@@ -216,13 +218,13 @@ function update_post_information($type, $ids, $return_update_sql = false)
$topic_condition
AND p.post_visibility = " . ITEM_APPROVED . "
GROUP BY p.{$type}_id";
+ $result = $db->sql_query($sql);
}
- $result = $db->sql_query($sql);
$last_post_ids = array();
while ($row = $db->sql_fetchrow($result))
{
- if (sizeof($ids) == 1)
+ if (count($ids) == 1)
{
$row[$type . '_id'] = $ids[0];
}
@@ -256,7 +258,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
}
}
- if (sizeof($last_post_ids))
+ if (count($last_post_ids))
{
$sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
@@ -277,7 +279,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
}
unset($empty_forums, $ids, $last_post_ids);
- if ($return_update_sql || !sizeof($update_sql))
+ if ($return_update_sql || !count($update_sql))
{
return $update_sql;
}
@@ -310,7 +312,7 @@ function posting_gen_topic_icons($mode, $icon_id)
$template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"');
}
- if (sizeof($icons))
+ if (count($icons))
{
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;
@@ -519,7 +521,7 @@ function get_supported_image_types($type = false)
*/
function create_thumbnail($source, $destination, $mimetype)
{
- global $config, $phpbb_filesystem;
+ global $config, $phpbb_filesystem, $phpbb_dispatcher;
$min_filesize = (int) $config['img_min_thumb_filesize'];
$img_filesize = (file_exists($source)) ? @filesize($source) : false;
@@ -551,25 +553,31 @@ function create_thumbnail($source, $destination, $mimetype)
return false;
}
- $used_imagick = false;
-
- // Only use ImageMagick if defined and the passthru function not disabled
- if ($config['img_imagick'] && function_exists('passthru'))
- {
- if (substr($config['img_imagick'], -1) !== '/')
- {
- $config['img_imagick'] .= '/';
- }
-
- @passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
+ $thumbnail_created = false;
- if (file_exists($destination))
- {
- $used_imagick = true;
- }
- }
+ /**
+ * Create thumbnail event to replace GD thumbnail creation with for example ImageMagick
+ *
+ * @event core.thumbnail_create_before
+ * @var string source Image source path
+ * @var string destination Thumbnail destination path
+ * @var string mimetype Image mime type
+ * @var float new_width Calculated thumbnail width
+ * @var float new_height Calculated thumbnail height
+ * @var bool thumbnail_created Set to true to skip default GD thumbnail creation
+ * @since 3.2.4
+ */
+ $vars = array(
+ 'source',
+ 'destination',
+ 'mimetype',
+ 'new_width',
+ 'new_height',
+ 'thumbnail_created',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.thumbnail_create_before', compact($vars)));
- if (!$used_imagick)
+ if (!$thumbnail_created)
{
$type = get_supported_image_types($type);
@@ -690,7 +698,7 @@ function posting_gen_inline_attachments(&$attachment_data)
{
global $template;
- if (sizeof($attachment_data))
+ if (count($attachment_data))
{
$s_inline_attachment_options = '';
@@ -717,20 +725,21 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
// Some default template variables
$template->assign_vars(array(
'S_SHOW_ATTACH_BOX' => $show_attach_box,
- 'S_HAS_ATTACHMENTS' => sizeof($attachment_data),
+ 'S_HAS_ATTACHMENTS' => count($attachment_data),
'FILESIZE' => $config['max_filesize'],
'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '',
));
- if (sizeof($attachment_data))
+ if (count($attachment_data))
{
// We display the posted attachments within the desired order.
($config['display_order']) ? krsort($attachment_data) : ksort($attachment_data);
+ $attachrow_template_vars = [];
+
foreach ($attachment_data as $count => $attach_row)
{
$hidden = '';
- $attachrow_template_vars = array();
$attach_row['real_filename'] = utf8_basename($attach_row['real_filename']);
foreach ($attach_row as $key => $value)
@@ -768,7 +777,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
$template->assign_block_vars_array('attach_row', $attachrow_template_vars);
}
- return sizeof($attachment_data);
+ return count($attachment_data);
}
//
@@ -816,13 +825,13 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $ms
}
$db->sql_freeresult($result);
- if (!sizeof($draft_rows))
+ if (!count($draft_rows))
{
return;
}
$topic_rows = array();
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$sql = 'SELECT topic_id, forum_id, topic_title, topic_poster
FROM ' . TOPICS_TABLE . '
@@ -935,7 +944,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$db->sql_freeresult($result);
- if (!sizeof($post_list))
+ if (!count($post_list))
{
return false;
}
@@ -969,6 +978,30 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
AND u.user_id = p.poster_id',
);
+ /**
+ * Event to modify the SQL query for topic reviews
+ *
+ * @event core.topic_review_modify_sql_ary
+ * @var int topic_id The topic ID that is being reviewed
+ * @var int forum_id The topic's forum ID
+ * @var string mode The topic review mode
+ * @var int cur_post_id Post offset ID
+ * @var bool show_quote_button Flag indicating if the quote button should be displayed
+ * @var array post_list Array with the post IDs
+ * @var array sql_ary Array with the SQL query
+ * @since 3.2.8-RC1
+ */
+ $vars = array(
+ 'topic_id',
+ 'forum_id',
+ 'mode',
+ 'cur_post_id',
+ 'show_quote_button',
+ 'post_list',
+ 'sql_ary',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_sql_ary', compact($vars)));
+
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
@@ -1030,7 +1063,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
);
extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_post_list', compact($vars)));
- for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
+ for ($i = 0, $end = count($post_list); $i < $end; ++$i)
{
// A non-existing rowset only happens if there was no user present for the entered poster_id
// This could be a broken posts table.
@@ -1257,7 +1290,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
foreach ($shadow_forum_ids as $updated_forum => $topic_count)
{
- // counting is fun! we only have to do sizeof($forum_ids) number of queries,
+ // counting is fun! we only have to do count($forum_ids) number of queries,
// even if the topic is moved back to where its shadow lives (we count how many times it is in a forum)
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_topics_approved = forum_topics_approved - ' . $topic_count . '
@@ -1275,9 +1308,10 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
delete_topics('topic_id', array($topic_id), false);
$phpbb_content_visibility->remove_topic_from_statistic($data, $sql_data);
+ $config->increment('num_posts', -1, false);
$update_sql = update_post_information('forum', $forum_id, true);
- if (sizeof($update_sql))
+ if (count($update_sql))
{
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
@@ -1326,7 +1360,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
{
// Update last post information when hard deleting. Soft delete already did that by itself.
$update_sql = update_post_information('forum', $forum_id, true);
- if (sizeof($update_sql))
+ if (count($update_sql))
{
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . implode(', ', $update_sql[$forum_id]);
}
@@ -1968,7 +2002,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
$sql_insert_ary = array();
- for ($i = 0, $size = sizeof($poll_ary['poll_options']); $i < $size; $i++)
+ for ($i = 0, $size = count($poll_ary['poll_options']); $i < $size; $i++)
{
if (strlen(trim($poll_ary['poll_options'][$i])))
{
@@ -1976,7 +2010,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
{
// If we add options we need to put them to the end to be able to preserve votes...
$sql_insert_ary[] = array(
- 'poll_option_id' => (int) sizeof($cur_poll_options) + 1 + sizeof($sql_insert_ary),
+ 'poll_option_id' => (int) count($cur_poll_options) + 1 + count($sql_insert_ary),
'topic_id' => (int) $data_ary['topic_id'],
'poll_option_text' => (string) $poll_ary['poll_options'][$i]
);
@@ -1994,16 +2028,16 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
$db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary);
- if (sizeof($poll_ary['poll_options']) < sizeof($cur_poll_options))
+ if (count($poll_ary['poll_options']) < count($cur_poll_options))
{
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . '
- WHERE poll_option_id > ' . sizeof($poll_ary['poll_options']) . '
+ WHERE poll_option_id > ' . count($poll_ary['poll_options']) . '
AND topic_id = ' . $data_ary['topic_id'];
$db->sql_query($sql);
}
// If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option
- if ($mode == 'edit' && sizeof($poll_ary['poll_options']) != sizeof($cur_poll_options))
+ if ($mode == 'edit' && count($poll_ary['poll_options']) != count($cur_poll_options))
{
$db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data_ary['topic_id']);
$db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data_ary['topic_id']);
@@ -2021,7 +2055,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
$orphan_rows[(int) $attach_row['attach_id']] = array();
}
- if (sizeof($orphan_rows))
+ if (count($orphan_rows))
{
$sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . '
@@ -2045,6 +2079,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
continue;
}
+ if (preg_match('/[\x{10000}-\x{10FFFF}]/u', $attach_row['attach_comment']))
+ {
+ trigger_error('ATTACH_COMMENT_NO_EMOJIS');
+ }
+
if (!$attach_row['is_orphan'])
{
// update entry in db if attachment already stored in db and filespace
@@ -2281,6 +2320,19 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
'post_subject' => $subject,
));
+ /**
+ * This event allows you to modify the notification data upon submission
+ *
+ * @event core.modify_submit_notification_data
+ * @var array notification_data The notification data to be inserted in to the database
+ * @var array data_ary The data array with a lot of the post submission data
+ * @var string mode The posting mode
+ * @var int poster_id The poster id
+ * @since 3.2.4-RC1
+ */
+ $vars = array('notification_data', 'data_ary', 'mode', 'poster_id');
+ extract($phpbb_dispatcher->trigger_event('core.modify_submit_notification_data', compact($vars)));
+
/* @var $phpbb_notifications \phpbb\notification\manager */
$phpbb_notifications = $phpbb_container->get('notification_manager');
@@ -2308,8 +2360,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
case 'edit_first_post':
case 'edit':
case 'edit_last_post':
+ if ($user->data['user_id'] == $poster_id)
+ {
+ $phpbb_notifications->update_notifications(array(
+ 'notification.type.quote',
+ ), $notification_data);
+ }
+
$phpbb_notifications->update_notifications(array(
- 'notification.type.quote',
'notification.type.bookmark',
'notification.type.topic',
'notification.type.post',
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index ff962075a8..f07512d623 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -466,7 +466,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$user_rules = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
- if (sizeof($user_rules))
+ if (count($user_rules))
{
$sql = 'SELECT zebra_id, friend, foe
FROM ' . ZEBRA_TABLE . "
@@ -490,7 +490,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
'bcc' => explode(':', $row['bcc_address']),
'friend' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['friend'] : 0,
'foe' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['foe'] : 0,
- 'user_in_group' => array($user->data['group_id']),
+ 'user_in_group' => $user->data['group_id'],
'author_in_group' => array())
);
@@ -499,7 +499,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$db->sql_freeresult($result);
// Retrieve user memberships
- if (sizeof($user_ids))
+ if (count($user_ids))
{
$sql = 'SELECT *
FROM ' . USER_GROUP_TABLE . '
@@ -600,14 +600,14 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
// only gone through if new messages arrive.
// Delete messages
- if (sizeof($delete_ids))
+ if (count($delete_ids))
{
- $num_removed += sizeof($delete_ids);
+ $num_removed += count($delete_ids);
delete_pm($user_id, $delete_ids, PRIVMSGS_NO_BOX);
}
// Set messages to Unread
- if (sizeof($unread_ids))
+ if (count($unread_ids))
{
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_unread = 0
@@ -618,7 +618,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
}
// mark messages as important
- if (sizeof($important_ids))
+ if (count($important_ids))
{
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_marked = 1 - pm_marked
@@ -631,7 +631,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
// Move into folder
$folder = array();
- if (sizeof($move_into_folder))
+ if (count($move_into_folder))
{
// Determine Full Folder Action - we need the move to folder id later eventually
$full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder'];
@@ -676,12 +676,12 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
// Check Message Limit - we calculate with the complete array, most of the time it is one message
// But we are making sure that the other way around works too (more messages in queue than allowed to be stored)
- if ($user->data['message_limit'] && $folder[$folder_id] && ($folder[$folder_id] + sizeof($msg_ary)) > $user->data['message_limit'])
+ if ($user->data['message_limit'] && $folder[$folder_id] && ($folder[$folder_id] + count($msg_ary)) > $user->data['message_limit'])
{
$full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder'];
// If destination folder itself is full...
- if ($full_folder_action >= 0 && ($folder[$full_folder_action] + sizeof($msg_ary)) > $user->data['message_limit'])
+ if ($full_folder_action >= 0 && ($folder[$full_folder_action] + count($msg_ary)) > $user->data['message_limit'])
{
$full_folder_action = $config['full_folder_action'] - (FULL_FOLDER_NONE*(-1));
}
@@ -699,7 +699,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
WHERE user_id = $user_id
AND folder_id = $dest_folder
ORDER BY msg_id ASC";
- $result = $db->sql_query_limit($sql, (($folder[$dest_folder] + sizeof($msg_ary)) - $user->data['message_limit']));
+ $result = $db->sql_query_limit($sql, (($folder[$dest_folder] + count($msg_ary)) - $user->data['message_limit']));
$delete_ids = array();
while ($row = $db->sql_fetchrow($result))
@@ -708,7 +708,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
}
$db->sql_freeresult($result);
- $num_removed += sizeof($delete_ids);
+ $num_removed += count($delete_ids);
delete_pm($user_id, $delete_ids, $dest_folder);
}
}
@@ -744,7 +744,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
}
}
- if (sizeof($action_ary))
+ if (count($action_ary))
{
// Move from OUTBOX to SENTBOX
// We are not checking any full folder status here... SENTBOX is a special treatment (old messages get deleted)
@@ -785,7 +785,7 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
$move_msg_ids = array($move_msg_ids);
}
- if (sizeof($move_msg_ids) && !in_array($dest_folder, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)) &&
+ if (count($move_msg_ids) && !in_array($dest_folder, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)) &&
!in_array($cur_folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)) && $cur_folder_id != $dest_folder)
{
// We have to check the destination folder ;)
@@ -805,7 +805,7 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
trigger_error('NOT_AUTHORISED');
}
- if ($message_limit && $row['pm_count'] + sizeof($move_msg_ids) > $message_limit)
+ if ($message_limit && $row['pm_count'] + count($move_msg_ids) > $message_limit)
{
$message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $row['folder_name']) . '<br /><br />';
$message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=' . $row['folder_id']) . '">', '</a>', $row['folder_name']);
@@ -822,7 +822,7 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
$num_messages = (int) $db->sql_fetchfield('num_messages');
$db->sql_freeresult($result);
- if ($message_limit && $num_messages + sizeof($move_msg_ids) > $message_limit)
+ if ($message_limit && $num_messages + count($move_msg_ids) > $message_limit)
{
$message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $user->lang['PM_INBOX']) . '<br /><br />';
$message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=inbox') . '">', '</a>', $user->lang['PM_INBOX']);
@@ -949,7 +949,7 @@ function handle_mark_actions($user_id, $mark_action)
$msg_ids = $request->variable('marked_msg_id', array(0));
$cur_folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX);
- if (!sizeof($msg_ids))
+ if (!count($msg_ids))
{
return false;
}
@@ -981,7 +981,7 @@ function handle_mark_actions($user_id, $mark_action)
{
delete_pm($user_id, $msg_ids, $cur_folder_id);
- $success_msg = (sizeof($msg_ids) == 1) ? 'MESSAGE_DELETED' : 'MESSAGES_DELETED';
+ $success_msg = (count($msg_ids) == 1) ? 'MESSAGE_DELETED' : 'MESSAGES_DELETED';
$redirect = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=' . $cur_folder_id);
meta_refresh(3, $redirect);
@@ -1032,7 +1032,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
$msg_ids = array($msg_ids);
}
- if (!sizeof($msg_ids))
+ if (!count($msg_ids))
{
return false;
}
@@ -1069,7 +1069,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
$db->sql_freeresult($result);
unset($msg_ids);
- if (!sizeof($delete_rows))
+ if (!count($delete_rows))
{
return false;
}
@@ -1156,7 +1156,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
$delete_ids = array_keys($delete_rows);
- if (sizeof($delete_ids))
+ if (count($delete_ids))
{
// Check if there are any attachments we need to remove
/** @var \phpbb\attachment\manager $attachment_manager */
@@ -1289,7 +1289,7 @@ function phpbb_delete_users_pms($user_ids)
$num_pms = (int) $row['num_undelivered_privmsgs'];
$undelivered_user[$num_pms][] = (int) $row['user_id'];
- if (sizeof($undelivered_user[$num_pms]) > 50)
+ if (count($undelivered_user[$num_pms]) > 50)
{
// If there are too many users affected the query might get
// too long, so we update the value for the first bunch here.
@@ -1416,7 +1416,7 @@ function rebuild_header($check_ary)
$_types = array('u', 'g');
foreach ($_types as $type)
{
- if (sizeof(${$type}))
+ if (count(${$type}))
{
foreach (${$type} as $id)
{
@@ -1461,7 +1461,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
}
$address = array();
- if (sizeof($u))
+ if (count($u))
{
$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . '
@@ -1485,7 +1485,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
$db->sql_freeresult($result);
}
- if (sizeof($g))
+ if (count($g))
{
if ($plaintext)
{
@@ -1532,7 +1532,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
}
}
- if (sizeof($address) && !$plaintext)
+ if (count($address) && !$plaintext)
{
$template->assign_var('S_' . strtoupper($check_type) . '_RECIPIENT', true);
@@ -1651,7 +1651,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
$_types = array('u', 'g');
foreach ($_types as $ug_type)
{
- if (isset($data_ary['address_list'][$ug_type]) && sizeof($data_ary['address_list'][$ug_type]))
+ if (isset($data_ary['address_list'][$ug_type]) && count($data_ary['address_list'][$ug_type]))
{
foreach ($data_ary['address_list'][$ug_type] as $id => $field)
{
@@ -1673,7 +1673,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
}
}
- if (isset($data_ary['address_list']['g']) && sizeof($data_ary['address_list']['g']))
+ if (isset($data_ary['address_list']['g']) && count($data_ary['address_list']['g']))
{
// We need to check the PM status of group members (do they want to receive PM's?)
// Only check if not a moderator or admin, since they are allowed to override this user setting
@@ -1696,7 +1696,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
$db->sql_freeresult($result);
}
- if (!sizeof($recipients))
+ if (!count($recipients))
{
trigger_error('NO_RECIPIENT');
}
@@ -1764,7 +1764,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
break;
}
- if (sizeof($sql_data))
+ if (count($sql_data))
{
if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward')
{
@@ -1844,7 +1844,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
$orphan_rows[(int) $attach_row['attach_id']] = array();
}
- if (sizeof($orphan_rows))
+ if (count($orphan_rows))
{
$sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . '
@@ -1966,7 +1966,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
*/
function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode = false)
{
- global $db, $user, $template, $phpbb_root_path, $phpEx, $auth;
+ global $db, $user, $template, $phpbb_root_path, $phpEx, $auth, $phpbb_dispatcher;
// Select all receipts and the author from the pm we currently view, to only display their pm-history
$sql = 'SELECT author_id, user_id
@@ -1985,9 +1985,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
$recipients = array_unique($recipients);
// Get History Messages (could be newer)
- $sql = 'SELECT t.*, p.*, u.*
- FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . ' t, ' . USERS_TABLE . ' u
- WHERE t.msg_id = p.msg_id
+ $sql_where = 't.msg_id = p.msg_id
AND p.author_id = u.user_id
AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND ' . $db->sql_in_set('t.author_id', $recipients, false, true) . "
@@ -1998,13 +1996,37 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
if (!$message_row['root_level'])
{
- $sql .= " AND (p.root_level = $msg_id OR (p.root_level = 0 AND p.msg_id = $msg_id))";
+ $sql_where .= " AND (p.root_level = $msg_id OR (p.root_level = 0 AND p.msg_id = $msg_id))";
}
else
{
- $sql .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')';
+ $sql_where .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')';
}
- $sql .= ' ORDER BY p.message_time DESC';
+
+ $sql_ary = array(
+ 'SELECT' => 't.*, p.*, u.*',
+ 'FROM' => array(
+ PRIVMSGS_TABLE => 'p',
+ PRIVMSGS_TO_TABLE => 't',
+ USERS_TABLE => 'u'
+ ),
+ 'LEFT_JOIN' => array(),
+ 'WHERE' => $sql_where,
+ 'ORDER_BY' => 'p.message_time DESC',
+ );
+
+ /**
+ * Event to modify the SQL query before the message history in private message is queried
+ *
+ * @event core.message_history_modify_sql_ary
+ * @var array sql_ary The SQL array to get the data of the message history in private message
+ * @since 3.2.8-RC1
+ */
+ $vars = array('sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.message_history_modify_sql_ary', compact($vars)));
+
+ $sql = $db->sql_build_query('SELECT', $sql_ary);
+ unset($sql_ary);
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
@@ -2038,7 +2060,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
- if (sizeof($rowset) == 1 && !$in_post_mode)
+ if (count($rowset) == 1 && !$in_post_mode)
{
return false;
}
@@ -2051,7 +2073,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
// Re-order rowset to be able to get the next/prev message rows...
$rowset = array_values($rowset);
- for ($i = 0, $size = sizeof($rowset); $i < $size; $i++)
+ for ($i = 0, $size = count($rowset); $i < $size; $i++)
{
$row = &$rowset[$i];
$id = (int) $row['msg_id'];
@@ -2087,7 +2109,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
$previous_history_pm = $prev_id;
}
- $template->assign_block_vars('history_row', array(
+ $template_vars = array(
'MESSAGE_AUTHOR_QUOTE' => (($decoded_message) ? addslashes(get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username'])) : ''),
'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $row['username'], $row['user_colour'], $row['username']),
'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $row['username'], $row['user_colour'], $row['username']),
@@ -2109,8 +2131,25 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
'USER_ID' => $row['user_id'],
'U_VIEW_MESSAGE' => "$url&amp;f=$folder_id&amp;p=" . $row['msg_id'],
'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&amp;mode=compose&amp;action=quote&amp;f=" . $folder_id . "&amp;p=" . $row['msg_id'] : '',
- 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : '')
+ 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : ''
+ );
+
+ /**
+ * Modify the template vars for displaying the message history in private message
+ *
+ * @event core.message_history_modify_template_vars
+ * @var array template_vars Array containing the query
+ * @var array row Array containing the action user row
+ * @since 3.2.8-RC1
+ */
+ $vars = array(
+ 'template_vars',
+ 'row',
);
+ extract($phpbb_dispatcher->trigger_event('core.message_history_modify_template_vars', compact($vars)));
+
+ $template->assign_block_vars('history_row', $template_vars);
+
unset($rowset[$i]);
$prev_id = $id;
}
@@ -2197,7 +2236,7 @@ function get_recipient_strings($pm_by_id)
foreach ($_types as $ug_type)
{
- if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type]))
+ if (isset($address[$message_id][$ug_type]) && count($address[$message_id][$ug_type]))
{
foreach ($address[$message_id][$ug_type] as $ug_id => $in_to)
{
diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php
index 0fc8a7eea5..7427b89917 100644
--- a/phpBB/includes/functions_transfer.php
+++ b/phpBB/includes/functions_transfer.php
@@ -38,7 +38,7 @@ class transfer
/**
* Constructor - init some basic values
*/
- function transfer()
+ function __construct()
{
global $phpbb_root_path;
@@ -112,7 +112,7 @@ class transfer
$dir = explode('/', $dir);
$dirs = '';
- for ($i = 0, $total = sizeof($dir); $i < $total; $i++)
+ for ($i = 0, $total = count($dir); $i < $total; $i++)
{
$result = true;
@@ -264,7 +264,7 @@ class ftp extends transfer
/**
* 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->port = $port;
@@ -512,7 +512,7 @@ class ftp_fsock extends transfer
/**
* 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->port = $port;
@@ -529,7 +529,7 @@ class ftp_fsock extends transfer
}
// Init some needed values
- $this->transfer();
+ parent::__construct();
return;
}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index c746bd0e4c..3bf4aa16b7 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -26,8 +26,10 @@ if (!defined('IN_PHPBB'))
* @param array &$user_id_ary The user ids to check or empty if usernames used
* @param array &$username_ary The usernames to check or empty if user ids used
* @param mixed $user_type Array of user types to check, false if not restricting by user type
+* @param boolean $update_references If false, the supplied array is unset and appears unchanged from where it was called
+* @return boolean|string Returns false on success, error string on failure
*/
-function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false)
+function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false, $update_references = false)
{
global $db;
@@ -50,7 +52,13 @@ function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false)
}
$sql_in = ($which_ary == 'user_id_ary') ? array_map('intval', ${$which_ary}) : array_map('utf8_clean_string', ${$which_ary});
- unset(${$which_ary});
+
+ // By unsetting the array here, the values passed in at the point user_get_id_name() was called will be retained.
+ // Otherwise, if we don't unset (as the array was passed by reference) the original array will be updated below.
+ if ($update_references === false)
+ {
+ unset(${$which_ary});
+ }
$user_id_ary = $username_ary = array();
@@ -170,7 +178,7 @@ function user_update_name($old_name, $new_name)
* Adds an user
*
* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded.
-* @param string $cp_data custom profile fields, see custom_profile::build_insert_sql_array
+* @param array $cp_data custom profile fields, see custom_profile::build_insert_sql_array
* @param array $notifications_data The notifications settings for the new user
* @return the new user's ID.
*/
@@ -260,7 +268,7 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
$remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary));
// Now fill our sql array with the remaining vars
- if (sizeof($remaining_vars))
+ if (count($remaining_vars))
{
foreach ($remaining_vars as $key)
{
@@ -272,8 +280,8 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
* Use this event to modify the values to be inserted when a user is added
*
* @event core.user_add_modify_data
- * @var array user_row Array of user details submited to user_add
- * @var array cp_data Array of Custom profile fields submited to user_add
+ * @var array user_row Array of user details submitted to user_add
+ * @var array cp_data Array of Custom profile fields submitted to user_add
* @var array sql_ary Array of data to be inserted when a user is added
* @var array notifications_data Array of notification data to be inserted when a user is added
* @since 3.1.0-a1
@@ -289,7 +297,7 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
$user_id = $db->sql_nextid();
// Insert Custom Profile Fields
- if ($cp_data !== false && sizeof($cp_data))
+ if ($cp_data !== false && count($cp_data))
{
$cp_data['user_id'] = (int) $user_id;
@@ -376,6 +384,19 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
);
}
+ /**
+ * Modify the notifications data to be inserted in the database when a user is added
+ *
+ * @event core.user_add_modify_notifications_data
+ * @var array user_row Array of user details submitted to user_add
+ * @var array cp_data Array of Custom profile fields submitted to user_add
+ * @var array sql_ary Array of data to be inserted when a user is added
+ * @var array notifications_data Array of notification data to be inserted when a user is added
+ * @since 3.2.2-RC1
+ */
+ $vars = array('user_row', 'cp_data', 'sql_ary', 'notifications_data');
+ extract($phpbb_dispatcher->trigger_event('core.user_add_modify_notifications_data', compact($vars)));
+
// Subscribe user to notifications if necessary
if (!empty($notifications_data))
{
@@ -388,12 +409,12 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
}
/**
- * Event that returns user id, user detals and user CPF of newly registared user
+ * Event that returns user id, user details and user CPF of newly registered user
*
* @event core.user_add_after
- * @var int user_id User id of newly registared user
- * @var array user_row Array of user details submited to user_add
- * @var array cp_data Array of Custom profile fields submited to user_add
+ * @var int user_id User id of newly registered user
+ * @var array user_row Array of user details submitted to user_add
+ * @var array cp_data Array of Custom profile fields submitted to user_add
* @since 3.1.0-b5
*/
$vars = array('user_id', 'user_row', 'cp_data');
@@ -448,9 +469,11 @@ function user_delete($mode, $user_ids, $retain_username = true)
* @var array user_ids IDs of the deleted user
* @var mixed retain_username True if username should be retained
* or false if not
+ * @var array user_rows Array containing data of the deleted users
* @since 3.1.0-a1
+ * @changed 3.2.4-RC1 Added user_rows
*/
- $vars = array('mode', 'user_ids', 'retain_username');
+ $vars = array('mode', 'user_ids', 'retain_username', 'user_rows');
extract($phpbb_dispatcher->trigger_event('core.delete_user_before', compact($vars)));
// Before we begin, we will remove the reports the user issued.
@@ -468,7 +491,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
}
$db->sql_freeresult($result);
- if (sizeof($report_posts))
+ if (count($report_posts))
{
$report_posts = array_unique($report_posts);
$report_topics = array_unique($report_topics);
@@ -488,7 +511,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
}
$db->sql_freeresult($result);
- if (sizeof($keep_report_topics))
+ if (count($keep_report_topics))
{
$report_topics = array_diff($report_topics, $keep_report_topics);
}
@@ -500,7 +523,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
WHERE ' . $db->sql_in_set('post_id', $report_posts);
$db->sql_query($sql);
- if (sizeof($report_topics))
+ if (count($report_topics))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
@@ -651,8 +674,30 @@ function user_delete($mode, $user_ids, $retain_username = true)
delete_posts('poster_id', $user_ids);
}
- $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE, PRIVMSGS_FOLDER_TABLE, PRIVMSGS_RULES_TABLE);
-
+ $table_ary = [
+ USERS_TABLE,
+ USER_GROUP_TABLE,
+ TOPICS_WATCH_TABLE,
+ FORUMS_WATCH_TABLE,
+ ACL_USERS_TABLE,
+ TOPICS_TRACK_TABLE,
+ TOPICS_POSTED_TABLE,
+ FORUMS_TRACK_TABLE,
+ PROFILE_FIELDS_DATA_TABLE,
+ MODERATOR_CACHE_TABLE,
+ DRAFTS_TABLE,
+ BOOKMARKS_TABLE,
+ SESSIONS_KEYS_TABLE,
+ PRIVMSGS_FOLDER_TABLE,
+ PRIVMSGS_RULES_TABLE,
+ $phpbb_container->getParameter('tables.auth_provider_oauth_token_storage'),
+ $phpbb_container->getParameter('tables.auth_provider_oauth_states'),
+ $phpbb_container->getParameter('tables.auth_provider_oauth_account_assoc'),
+ $phpbb_container->getParameter('tables.user_notifications')
+ ];
+
+ // Ignore errors on deleting from non-existent tables, e.g. when migrating
+ $db->sql_return_on_error(true);
// Delete the miscellaneous (non-post) data for the user
foreach ($table_ary as $table)
{
@@ -660,6 +705,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
WHERE " . $user_id_sql;
$db->sql_query($sql);
}
+ $db->sql_return_on_error();
$cache->destroy('sql', MODERATOR_CACHE_TABLE);
@@ -767,7 +813,7 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
$user_id_ary = array($user_id_ary);
}
- if (!sizeof($user_id_ary))
+ if (!count($user_id_ary))
{
return;
}
@@ -825,7 +871,7 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
$vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements');
extract($phpbb_dispatcher->trigger_event('core.user_active_flip_before', compact($vars)));
- if (sizeof($sql_statements))
+ if (count($sql_statements))
{
foreach ($sql_statements as $user_id => $sql_ary)
{
@@ -903,7 +949,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
else
{
$ban_other = explode('-', $ban_len_other);
- if (sizeof($ban_other) == 3 && ((int) $ban_other[0] < 9999) &&
+ if (count($ban_other) == 3 && ((int) $ban_other[0] < 9999) &&
(strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2))
{
$ban_end = max($current_time, $user->create_datetime()
@@ -971,7 +1017,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
}
// Make sure we have been given someone to ban
- if (!sizeof($sql_usernames))
+ if (!count($sql_usernames))
{
trigger_error('NO_USER_SPECIFIED', E_USER_WARNING);
}
@@ -982,7 +1028,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
// Do not allow banning yourself, the guest account, or founders.
$non_bannable = array($user->data['user_id'], ANONYMOUS);
- if (sizeof($founder))
+ if (count($founder))
{
$sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), $non_bannable), true);
}
@@ -1122,14 +1168,14 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
continue;
}
- if (!sizeof($founder) || !in_array($ban_item, $founder))
+ if (!count($founder) || !in_array($ban_item, $founder))
{
$banlist_ary[] = $ban_item;
}
}
}
- if (sizeof($ban_list) == 0)
+ if (count($ban_list) == 0)
{
trigger_error('NO_EMAILS_DEFINED', E_USER_WARNING);
}
@@ -1176,7 +1222,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
$banlist_ary_tmp = array_intersect($banlist_ary, $banlist_ary_tmp);
- if (sizeof($banlist_ary_tmp))
+ if (count($banlist_ary_tmp))
{
// One or more entities are already banned/excluded, delete the existing bans, so they can be re-inserted with the given new length
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
@@ -1190,7 +1236,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
$db->sql_freeresult($result);
// We have some entities to ban
- if (sizeof($banlist_ary))
+ if (count($banlist_ary))
{
$sql_ary = array();
@@ -1318,7 +1364,7 @@ function user_unban($mode, $ban)
$unban_sql = array_map('intval', $ban);
- if (sizeof($unban_sql))
+ if (count($unban_sql))
{
// Grab details of bans for logging information later
switch ($mode)
@@ -1414,21 +1460,14 @@ function user_ipwhois($ip)
return '';
}
- if (preg_match(get_preg_expression('ipv4'), $ip))
- {
- // IPv4 address
- $whois_host = 'whois.arin.net.';
- }
- else if (preg_match(get_preg_expression('ipv6'), $ip))
- {
- // IPv6 address
- $whois_host = 'whois.sixxs.net.';
- }
- else
+ if (!preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip))
{
return '';
}
+ // IPv4 & IPv6 addresses
+ $whois_host = 'whois.arin.net.';
+
$ipwhois = '';
if (($fsk = @fsockopen($whois_host, 43)))
@@ -1582,7 +1621,7 @@ function validate_num($num, $optional = false, $min = 0, $max = 1E99)
function validate_date($date_string, $optional = false)
{
$date = explode('-', $date_string);
- if ((empty($date) || sizeof($date) != 3) && $optional)
+ if ((empty($date) || count($date) != 3) && $optional)
{
return false;
}
@@ -1604,7 +1643,7 @@ function validate_date($date_string, $optional = false)
}
}
- if (sizeof($date) != 3 || !checkdate($date[1], $date[0], $date[2]))
+ if (count($date) != 3 || !checkdate($date[1], $date[0], $date[2]))
{
return 'INVALID';
}
@@ -1679,17 +1718,21 @@ function phpbb_validate_timezone($timezone)
return (in_array($timezone, phpbb_get_timezone_identifiers($timezone))) ? false : 'TIMEZONE_INVALID';
}
-/**
-* Check to see if the username has been taken, or if it is disallowed.
-* Also checks if it includes the " character, which we don't allow in usernames.
-* Used for registering, changing names, and posting anonymously with a username
-*
-* @param string $username The username to check
-* @param string $allowed_username An allowed username, default being $user->data['username']
-*
-* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
-*/
-function validate_username($username, $allowed_username = false)
+/***
+ * Validate Username
+ *
+ * Check to see if the username has been taken, or if it is disallowed.
+ * Also checks if it includes the " character or the 4-bytes Unicode ones
+ * (aka emojis) which we don't allow in usernames.
+ * Used for registering, changing names, and posting anonymously with a username
+ *
+ * @param string $username The username to check
+ * @param string $allowed_username An allowed username, default being $user->data['username']
+ *
+ * @return mixed Either false if validation succeeded or a string which will be
+ * used as the error message (with the variable name appended)
+ */
+function validate_username($username, $allowed_username = false, $allow_all_names = false)
{
global $config, $db, $user, $cache;
@@ -1701,6 +1744,14 @@ function validate_username($username, $allowed_username = false)
return false;
}
+ // The very first check is for
+ // out-of-bounds characters that are currently
+ // not supported by utf8_bin in MySQL
+ if (preg_match('/[\x{10000}-\x{10FFFF}]/u', $username))
+ {
+ return 'INVALID_EMOJIS';
+ }
+
// ... fast checks first.
if (strpos($username, '&quot;') !== false || strpos($username, '"') !== false || empty($clean_username))
{
@@ -1764,13 +1815,16 @@ function validate_username($username, $allowed_username = false)
return 'USERNAME_TAKEN';
}
- $bad_usernames = $cache->obtain_disallowed_usernames();
-
- foreach ($bad_usernames as $bad_username)
+ if (!$allow_all_names)
{
- if (preg_match('#^' . $bad_username . '$#', $clean_username))
+ $bad_usernames = $cache->obtain_disallowed_usernames();
+
+ foreach ($bad_usernames as $bad_username)
{
- return 'USERNAME_DISALLOWED';
+ if (preg_match('#^' . $bad_username . '$#', $clean_username))
+ {
+ return 'USERNAME_DISALLOWED';
+ }
}
}
@@ -1891,9 +1945,9 @@ function validate_user_email($email, $allowed_email = false)
return $validate_email;
}
- if (($ban_reason = $user->check_ban(false, false, $email, true)) !== false)
+ if (($ban = $user->check_ban(false, false, $email, true)) !== false)
{
- return ($ban_reason === true) ? 'EMAIL_BANNED' : $ban_reason;
+ return ($ban === true) ? 'EMAIL_BANNED' : (!empty($ban['ban_give_reason']) ? $ban['ban_give_reason'] : $ban);
}
if (!$config['allow_emailreuse'])
@@ -1944,7 +1998,7 @@ function validate_jabber($jid)
$arr = explode('.', $realm);
- if (sizeof($arr) == 0)
+ if (count($arr) == 0)
{
return 'WRONG_DATA';
}
@@ -2268,7 +2322,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
$group_teampage = !empty($group_attributes['group_teampage']);
unset($group_attributes['group_teampage']);
- if (!sizeof($error))
+ if (!count($error))
{
$current_legend = \phpbb\groupposition\legend::GROUP_DISABLED;
$current_teampage = \phpbb\groupposition\teampage::GROUP_DISABLED;
@@ -2341,7 +2395,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies);
}
- if (sizeof($group_attributes))
+ if (count($group_attributes))
{
// Merge them with $sql_ary to properly update the group
$sql_ary = array_merge($sql_ary, $group_attributes);
@@ -2467,7 +2521,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
// Set user attributes
$sql_ary = array();
- if (sizeof($group_attributes))
+ if (count($group_attributes))
{
// Go through the user attributes array, check if a group attribute matches it and then set it. ;)
foreach ($user_attribute_ary as $attribute)
@@ -2487,7 +2541,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
}
}
- if (sizeof($sql_ary) && sizeof($user_ary))
+ if (count($sql_ary) && count($user_ary))
{
group_set_user_default($group_id, $user_ary, $sql_ary);
}
@@ -2498,7 +2552,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
group_update_listings($group_id);
}
- return (sizeof($error)) ? $error : false;
+ return (count($error)) ? $error : false;
}
@@ -2663,11 +2717,18 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);
- if (!sizeof($user_id_ary) || $result !== false)
+ if (empty($user_id_ary) || $result !== false)
{
return 'NO_USER';
}
+ // Because the item that gets passed into the previous function is unset, the reference is lost and our original
+ // array is retained - so we know there's a problem if there's a different number of ids to usernames now.
+ if (count($user_id_ary) != count($username_ary))
+ {
+ return 'GROUP_USERS_INVALID';
+ }
+
// Remove users who are already members of this group
$sql = 'SELECT user_id, group_leader
FROM ' . USER_GROUP_TABLE . '
@@ -2691,7 +2752,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
$add_id_ary = array_diff($user_id_ary, $add_id_ary);
// If we have no users
- if (!sizeof($add_id_ary) && !sizeof($update_id_ary))
+ if (!count($add_id_ary) && !count($update_id_ary))
{
return 'GROUP_USERS_EXIST';
}
@@ -2699,7 +2760,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
$db->sql_transaction('begin');
// Insert the new users
- if (sizeof($add_id_ary))
+ if (count($add_id_ary))
{
$sql_ary = array();
@@ -2716,7 +2777,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
$db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary);
}
- if (sizeof($update_id_ary))
+ if (count($update_id_ary))
{
$sql = 'UPDATE ' . USER_GROUP_TABLE . '
SET group_leader = 1
@@ -2808,7 +2869,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);
- if (!sizeof($user_id_ary) || $result !== false)
+ if (empty($user_id_ary) || $result !== false)
{
return 'NO_USER';
}
@@ -2884,7 +2945,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
foreach ($special_group_data as $gid => $default_data_ary)
{
- if (isset($sql_where_ary[$gid]) && sizeof($sql_where_ary[$gid]))
+ if (isset($sql_where_ary[$gid]) && count($sql_where_ary[$gid]))
{
remove_default_rank($group_id, $sql_where_ary[$gid]);
remove_default_avatar($group_id, $sql_where_ary[$gid]);
@@ -3043,7 +3104,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);
- if (!sizeof($user_id_ary) || $result !== false)
+ if (empty($user_id_ary) || $result !== false)
{
return 'NO_USERS';
}
@@ -3098,7 +3159,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
}
$db->sql_freeresult($result);
- if (!sizeof($user_id_ary))
+ if (!count($user_id_ary))
{
return false;
}
@@ -3139,7 +3200,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
$db->sql_freeresult($result);
$result = user_get_id_name($user_id_ary, $username_ary);
- if (!sizeof($user_id_ary) || $result !== false)
+ if (!count($user_id_ary) || $result !== false)
{
return 'NO_USERS';
}
@@ -3502,7 +3563,7 @@ function group_update_listings($group_id)
$hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_'));
- if (!sizeof($hold_ary))
+ if (empty($hold_ary))
{
return;
}
@@ -3589,11 +3650,6 @@ function remove_newly_registered($user_id, $user_data = false)
}
}
- if (empty($user_data['user_new']))
- {
- return false;
- }
-
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
WHERE group_name = 'NEWLY_REGISTERED'
diff --git a/phpBB/includes/hooks/index.php b/phpBB/includes/hooks/index.php
index 805e0eea1a..821242cbf4 100644
--- a/phpBB/includes/hooks/index.php
+++ b/phpBB/includes/hooks/index.php
@@ -44,7 +44,7 @@ class phpbb_hook
*
* @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)
{
diff --git a/phpBB/includes/mcp/mcp_ban.php b/phpBB/includes/mcp/mcp_ban.php
index 2f3405f915..6f748f5433 100644
--- a/phpBB/includes/mcp/mcp_ban.php
+++ b/phpBB/includes/mcp/mcp_ban.php
@@ -34,7 +34,10 @@ class mcp_ban
}
// Include the admin banning interface...
- include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx);
+ if (!class_exists('acp_ban'))
+ {
+ include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx);
+ }
$bansubmit = $request->is_set_post('bansubmit');
$unbansubmit = $request->is_set_post('unbansubmit');
@@ -266,9 +269,9 @@ class mcp_ban
}
else if ($post_id)
{
- $post_info = phpbb_get_post_data($post_id, 'm_ban');
+ $post_info = phpbb_get_post_data(array($post_id), 'm_ban');
- if (sizeof($post_info) && !empty($post_info[$post_id]))
+ if (count($post_info) && !empty($post_info[$post_id]))
{
switch ($mode)
{
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index 3e214797c8..19f71e092a 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -96,14 +96,14 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
$pagination = $phpbb_container->get('pagination');
$selected_ids = '';
- if (sizeof($post_id_list) && $action != 'merge_topics')
+ if (count($post_id_list) && $action != 'merge_topics')
{
foreach ($post_id_list as $num => $post_id)
{
$selected_ids .= '&amp;post_id_list[' . $num . ']=' . $post_id;
}
}
- else if (sizeof($topic_id_list) && $action == 'merge_topics')
+ else if (count($topic_id_list) && $action == 'merge_topics')
{
foreach ($topic_id_list as $num => $topic_id)
{
@@ -221,13 +221,13 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
$db->sql_freeresult($result);
// If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
- if (!sizeof($topic_list) && $forum_topics && $start > 0)
+ if (!count($topic_list) && $forum_topics && $start > 0)
{
redirect($url . "&amp;i=$id&amp;action=$action&amp;mode=$mode");
}
// Get topic tracking info
- if (sizeof($topic_list))
+ if (count($topic_list))
{
if ($config['load_db_lastread'])
{
@@ -358,7 +358,7 @@ function mcp_resync_topics($topic_ids)
{
global $db, $user, $phpbb_log, $request;
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
trigger_error('NO_TOPIC_SELECTED');
}
@@ -389,7 +389,7 @@ function mcp_resync_topics($topic_ids)
}
$db->sql_freeresult($result);
- $msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
+ $msg = (count($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
$redirect = $request->variable('redirect', $user->data['session_page']);
@@ -406,7 +406,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
{
global $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher;
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
$template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
return;
@@ -421,7 +421,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
$all_topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');
- if (!sizeof($all_topic_data) || empty($all_topic_data[$to_topic_id]))
+ if (!count($all_topic_data) || empty($all_topic_data[$to_topic_id]))
{
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
return;
@@ -440,7 +440,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
$post_id_list = $request->variable('post_id_list', array(0));
$start = $request->variable('start', 0);
- if (!sizeof($post_id_list) && sizeof($topic_ids))
+ if (!count($post_id_list) && count($topic_ids))
{
$sql = 'SELECT post_id
FROM ' . POSTS_TABLE . '
@@ -455,7 +455,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
$db->sql_freeresult($result);
}
- if (!sizeof($post_id_list))
+ if (!count($post_id_list))
{
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
return;
diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php
index aeb716c1f9..918a98734b 100644
--- a/phpBB/includes/mcp/mcp_front.php
+++ b/phpBB/includes/mcp/mcp_front.php
@@ -290,7 +290,10 @@ function mcp_front_view($id, $mode, $action)
if ($total)
{
- include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
+ if (!function_exists('get_recipient_strings'))
+ {
+ include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
+ }
$sql_ary = array(
'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, p.message_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id',
diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php
index c34c915a40..79f9d35ebe 100644
--- a/phpBB/includes/mcp/mcp_logs.php
+++ b/phpBB/includes/mcp/mcp_logs.php
@@ -28,9 +28,9 @@ class mcp_logs
var $u_action;
var $p_master;
- function mcp_logs(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
@@ -115,7 +115,7 @@ class mcp_logs
{
if (confirm_box(true))
{
- if ($deletemark && sizeof($marked))
+ if ($deletemark && count($marked))
{
$conditions = array(
'forum_id' => array('IN' => $forum_list),
@@ -221,7 +221,7 @@ class mcp_logs
'IP' => $row['ip'],
'DATE' => $user->format_date($row['time']),
'ACTION' => $row['action'],
- 'DATA' => (sizeof($data)) ? implode(' | ', $data) : '',
+ 'DATA' => (count($data)) ? implode(' | ', $data) : '',
'ID' => $row['id'],
)
);
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index 3d56bba21c..744eaebd7d 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -28,9 +28,9 @@ class mcp_main
var $p_master;
var $u_action;
- function mcp_main(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
@@ -41,13 +41,29 @@ class mcp_main
$quickmod = ($mode == 'quickmod') ? true : false;
+ /**
+ * Event to perform additional actions before an MCP action is executed.
+ *
+ * @event core.mcp_main_before
+ * @var string action The action that is about to be performed
+ * @var string mode The mode in which the MCP is accessed, e.g. front, forum_view, topic_view, post_details, quickmod
+ * @var boolean quickmod Whether or not the action is performed via QuickMod
+ * @since 3.2.8-RC1
+ */
+ $vars = [
+ 'action',
+ 'mode',
+ 'quickmod',
+ ];
+ extract($phpbb_dispatcher->trigger_event('core.mcp_main_before', compact($vars)));
+
switch ($action)
{
case 'lock':
case 'unlock':
$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
trigger_error('NO_TOPIC_SELECTED');
}
@@ -60,7 +76,7 @@ class mcp_main
$post_ids = (!$quickmod) ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0));
- if (!sizeof($post_ids))
+ if (!count($post_ids))
{
trigger_error('NO_POST_SELECTED');
}
@@ -75,7 +91,7 @@ class mcp_main
$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
trigger_error('NO_TOPIC_SELECTED');
}
@@ -88,7 +104,7 @@ class mcp_main
$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
trigger_error('NO_TOPIC_SELECTED');
}
@@ -101,7 +117,7 @@ class mcp_main
$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
trigger_error('NO_TOPIC_SELECTED');
}
@@ -118,7 +134,7 @@ class mcp_main
$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
$soft_delete = (($request->is_set_post('confirm') && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false;
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
trigger_error('NO_TOPIC_SELECTED');
}
@@ -135,7 +151,7 @@ class mcp_main
$post_ids = (!$quickmod) ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0));
$soft_delete = (($request->is_set_post('confirm') && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false;
- if (!sizeof($post_ids))
+ if (!count($post_ids))
{
trigger_error('NO_POST_SELECTED');
}
@@ -148,7 +164,7 @@ class mcp_main
$topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
trigger_error('NO_TOPIC_SELECTED');
}
@@ -174,7 +190,10 @@ class mcp_main
switch ($mode)
{
case 'front':
- include($phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx);
+ if (!function_exists('mcp_front_view'))
+ {
+ include($phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx);
+ }
$user->add_lang('acp/common');
@@ -185,7 +204,10 @@ class mcp_main
break;
case 'forum_view':
- include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx);
+ if (!function_exists('mcp_forum_view'))
+ {
+ include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx);
+ }
$user->add_lang('viewforum');
@@ -193,7 +215,7 @@ class mcp_main
$forum_info = phpbb_get_forum_data($forum_id, 'm_', true);
- if (!sizeof($forum_info))
+ if (!count($forum_info))
{
$this->main('main', 'front');
return;
@@ -208,7 +230,10 @@ class mcp_main
break;
case 'topic_view':
- include($phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx);
+ if (!function_exists('mcp_topic_view'))
+ {
+ include($phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx);
+ }
mcp_topic_view($id, $mode, $action);
@@ -217,7 +242,10 @@ class mcp_main
break;
case 'post_details':
- include($phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx);
+ if (!function_exists('mcp_post_details'))
+ {
+ include($phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx);
+ }
mcp_post_details($id, $mode, $action);
@@ -342,7 +370,7 @@ function lock_unlock($action, $ids)
);
extract($phpbb_dispatcher->trigger_event('core.mcp_lock_unlock_after', compact($vars)));
- $success_msg = $l_prefix . ((sizeof($ids) == 1) ? '' : 'S') . '_' . (($action == 'lock' || $action == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS';
+ $success_msg = $l_prefix . ((count($ids) == 1) ? '' : 'S') . '_' . (($action == 'lock' || $action == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS';
meta_refresh(2, $redirect);
$message = $user->lang[$success_msg];
@@ -355,7 +383,7 @@ function lock_unlock($action, $ids)
}
else
{
- confirm_box(false, strtoupper($action) . '_' . $l_prefix . ((sizeof($ids) == 1) ? '' : 'S'), $s_hidden_fields);
+ confirm_box(false, strtoupper($action) . '_' . $l_prefix . ((count($ids) == 1) ? '' : 'S'), $s_hidden_fields);
}
redirect($redirect);
@@ -366,32 +394,32 @@ function lock_unlock($action, $ids)
*/
function change_topic_type($action, $topic_ids)
{
- global $user, $db, $request, $phpbb_log;
+ global $user, $db, $request, $phpbb_log, $phpbb_dispatcher;
switch ($action)
{
case 'make_announce':
$new_topic_type = POST_ANNOUNCE;
$check_acl = 'f_announce';
- $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_ANNOUNCEMENT' : 'MCP_MAKE_ANNOUNCEMENTS';
+ $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_ANNOUNCEMENT' : 'MCP_MAKE_ANNOUNCEMENTS';
break;
case 'make_global':
$new_topic_type = POST_GLOBAL;
$check_acl = 'f_announce_global';
- $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS';
+ $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS';
break;
case 'make_sticky':
$new_topic_type = POST_STICKY;
$check_acl = 'f_sticky';
- $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_STICKY' : 'MCP_MAKE_STICKIES';
+ $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_STICKY' : 'MCP_MAKE_STICKIES';
break;
default:
$new_topic_type = POST_NORMAL;
$check_acl = false;
- $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_NORMAL' : 'MCP_MAKE_NORMALS';
+ $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_NORMAL' : 'MCP_MAKE_NORMALS';
break;
}
@@ -414,27 +442,43 @@ function change_topic_type($action, $topic_ids)
if (confirm_box(true))
{
+
+ /**
+ * Perform additional actions before changing topic(s) type
+ *
+ * @event core.mcp_change_topic_type_before
+ * @var int new_topic_type The candidated topic type.
+ * @var int forum_id The forum ID for the topic ID(s).
+ * @var array topic_ids Array containing the topic ID(s) that will be changed
+ * @since 3.2.6-RC1
+ */
+ $vars = array(
+ 'new_topic_type',
+ 'forum_id',
+ 'topic_ids',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_change_topic_type_before', compact($vars)));
+
+ $db->sql_transaction('begin');
+
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type
WHERE " . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
- if (($new_topic_type == POST_GLOBAL) && sizeof($topic_ids))
+ if (($new_topic_type == POST_GLOBAL) && count($topic_ids))
{
// Delete topic shadows for global announcements
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
$db->sql_query($sql);
-
- $sql = 'UPDATE ' . TOPICS_TABLE . "
- SET topic_type = $new_topic_type
- WHERE " . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
}
- $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED';
+ $db->sql_transaction('commit');
+
+ $success_msg = (count($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED';
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$data = phpbb_get_topic_data($topic_ids);
@@ -448,6 +492,22 @@ function change_topic_type($action, $topic_ids)
}
}
+ /**
+ * Perform additional actions after changing topic types
+ *
+ * @event core.mcp_change_topic_type_after
+ * @var int new_topic_type The newly changed topic type.
+ * @var int forum_id The forum ID where the newly changed topic type belongs to.
+ * @var array topic_ids Array containing the topic IDs that have been changed
+ * @since 3.2.6-RC1
+ */
+ $vars = array(
+ 'new_topic_type',
+ 'forum_id',
+ 'topic_ids',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_change_topic_type_after', compact($vars)));
+
meta_refresh(2, $redirect);
$message = $user->lang[$success_msg];
@@ -496,7 +556,7 @@ function mcp_move_topic($topic_ids)
{
$forum_data = phpbb_get_forum_data($to_forum_id, 'f_post');
- if (!sizeof($forum_data))
+ if (!count($forum_data))
{
$additional_msg = $user->lang['FORUM_NOT_EXIST'];
}
@@ -691,7 +751,7 @@ function mcp_move_topic($topic_ids)
$sync_sql[$forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted - ' . (int) $topics_moved_softdeleted;
}
- $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS';
+ $success_msg = (count($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS';
foreach ($sync_sql as $forum_id_key => $array)
{
@@ -714,7 +774,7 @@ function mcp_move_topic($topic_ids)
'ADDITIONAL_MSG' => $additional_msg)
);
- confirm_box(false, 'MOVE_TOPIC' . ((sizeof($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');
+ confirm_box(false, 'MOVE_TOPIC' . ((count($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');
}
$redirect = $request->variable('redirect', "index.$phpEx");
@@ -762,7 +822,7 @@ function mcp_restore_topic($topic_ids)
if (confirm_box(true))
{
- $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_RESTORED_SUCCESS' : 'TOPICS_RESTORED_SUCCESS';
+ $success_msg = (count($topic_ids) == 1) ? 'TOPIC_RESTORED_SUCCESS' : 'TOPICS_RESTORED_SUCCESS';
$data = phpbb_get_topic_data($topic_ids);
@@ -784,7 +844,7 @@ function mcp_restore_topic($topic_ids)
}
else
{
- confirm_box(false, (sizeof($topic_ids) == 1) ? 'RESTORE_TOPIC' : 'RESTORE_TOPICS', $s_hidden_fields);
+ confirm_box(false, (count($topic_ids) == 1) ? 'RESTORE_TOPIC' : 'RESTORE_TOPICS', $s_hidden_fields);
}
$topic_id = $request->variable('t', 0);
@@ -842,7 +902,7 @@ function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = ''
if (confirm_box(true))
{
- $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_DELETED_SUCCESS' : 'TOPICS_DELETED_SUCCESS';
+ $success_msg = (count($topic_ids) == 1) ? 'TOPIC_DELETED_SUCCESS' : 'TOPICS_DELETED_SUCCESS';
$data = phpbb_get_topic_data($topic_ids);
@@ -927,13 +987,14 @@ function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = ''
'S_TOPIC_MODE' => true,
'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id),
'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id),
- 'DELETE_TOPIC_PERMANENTLY_EXPLAIN' => $user->lang('DELETE_TOPIC_PERMANENTLY', sizeof($topic_ids)),
+ 'DELETE_TOPIC_PERMANENTLY_EXPLAIN' => $user->lang('DELETE_TOPIC_PERMANENTLY', count($topic_ids)),
));
- $l_confirm = (sizeof($topic_ids) == 1) ? 'DELETE_TOPIC' : 'DELETE_TOPICS';
+ $count = count($topic_ids);
+ $l_confirm = $count === 1 ? 'DELETE_TOPIC' : 'DELETE_TOPICS';
if ($only_softdeleted)
{
- $l_confirm .= '_PERMANENTLY';
+ $l_confirm = array($l_confirm . '_PERMANENTLY', $count);
$s_hidden_fields['delete_permanent'] = '1';
}
else if ($only_shadow || !$auth->acl_get('m_softdelete', $forum_id))
@@ -1042,11 +1103,11 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
{
$phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), $soft_delete_reason, isset($topic_data['first_post']), isset($topic_data['last_post']));
}
- $affected_topics = sizeof($topic_info);
+ $affected_topics = count($topic_info);
// None of the topics is really deleted, so a redirect won't hurt much.
$deleted_topics = 0;
- $success_msg = (sizeof($post_info) == 1) ? $user->lang['POST_DELETED_SUCCESS'] : $user->lang['POSTS_DELETED_SUCCESS'];
+ $success_msg = (count($post_info) == 1) ? $user->lang['POST_DELETED_SUCCESS'] : $user->lang['POSTS_DELETED_SUCCESS'];
foreach ($approve_log as $row)
{
@@ -1093,7 +1154,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
{
$topic_id_list[] = $row['topic_id'];
}
- $affected_topics = sizeof($topic_id_list);
+ $affected_topics = count($topic_id_list);
$db->sql_freeresult($result);
$post_data = phpbb_get_post_data($post_ids);
@@ -1132,7 +1193,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
}
$return_link[] = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>');
- if (sizeof($post_ids) == 1)
+ if (count($post_ids) == 1)
{
if ($deleted_topics)
{
@@ -1181,13 +1242,14 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
'S_SOFTDELETED' => $only_softdeleted,
'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id),
'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id),
- 'DELETE_POST_PERMANENTLY_EXPLAIN' => $user->lang('DELETE_POST_PERMANENTLY', sizeof($post_ids)),
+ 'DELETE_POST_PERMANENTLY_EXPLAIN' => $user->lang('DELETE_POST_PERMANENTLY', count($post_ids)),
));
- $l_confirm = (sizeof($post_ids) == 1) ? 'DELETE_POST' : 'DELETE_POSTS';
+ $count = count($post_ids);
+ $l_confirm = $count === 1 ? 'DELETE_POST' : 'DELETE_POSTS';
if ($only_softdeleted)
{
- $l_confirm .= '_PERMANENTLY';
+ $l_confirm = array($l_confirm . '_PERMANENTLY', $count);
$s_hidden_fields['delete_permanent'] = '1';
}
else if (!$auth->acl_get('m_softdelete', $forum_id))
@@ -1247,11 +1309,11 @@ function mcp_fork_topic($topic_ids)
{
$forum_data = phpbb_get_forum_data($to_forum_id, 'f_post');
- if (!sizeof($topic_ids))
+ if (!count($topic_ids))
{
$additional_msg = $user->lang['NO_TOPIC_SELECTED'];
}
- else if (!sizeof($forum_data))
+ else if (!count($forum_data))
{
$additional_msg = $user->lang['FORUM_NOT_EXIST'];
}
@@ -1409,7 +1471,7 @@ function mcp_fork_topic($topic_ids)
}
$db->sql_freeresult($result);
- if (!sizeof($post_rows))
+ if (!count($post_rows))
{
continue;
}
@@ -1458,6 +1520,24 @@ function mcp_fork_topic($topic_ids)
$db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
$new_post_id = $db->sql_nextid();
+ /**
+ * Perform actions after forked topic is created.
+ *
+ * @event core.mcp_main_fork_sql_after
+ * @var int new_topic_id The newly created topic ID
+ * @var int to_forum_id The forum ID where the forked topic has been moved to
+ * @var int new_post_id The newly created post ID
+ * @var array row Post data
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'new_topic_id',
+ 'to_forum_id',
+ 'new_post_id',
+ 'row',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_main_fork_sql_after', compact($vars)));
+
switch ($row['post_visibility'])
{
case ITEM_APPROVED:
@@ -1512,7 +1592,7 @@ function mcp_fork_topic($topic_ids)
}
$db->sql_freeresult($result);
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_multi_insert(ATTACHMENTS_TABLE, $sql_ary);
}
@@ -1536,7 +1616,7 @@ function mcp_fork_topic($topic_ids)
}
$db->sql_freeresult($result);
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
}
@@ -1557,7 +1637,7 @@ function mcp_fork_topic($topic_ids)
}
$db->sql_freeresult($result);
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary);
}
@@ -1589,7 +1669,7 @@ function mcp_fork_topic($topic_ids)
sync('topic', 'topic_id', $new_topic_id_list);
sync('forum', 'forum_id', $to_forum_id);
- $config->increment('num_topics', sizeof($new_topic_id_list), false);
+ $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)
@@ -1601,7 +1681,7 @@ function mcp_fork_topic($topic_ids)
));
}
- $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_FORKED_SUCCESS' : 'TOPICS_FORKED_SUCCESS';
+ $success_msg = (count($topic_ids) == 1) ? 'TOPIC_FORKED_SUCCESS' : 'TOPICS_FORKED_SUCCESS';
}
else
{
@@ -1611,7 +1691,7 @@ function mcp_fork_topic($topic_ids)
'ADDITIONAL_MSG' => $additional_msg)
);
- confirm_box(false, 'FORK_TOPIC' . ((sizeof($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');
+ confirm_box(false, 'FORK_TOPIC' . ((count($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');
}
$redirect = $request->variable('redirect', "index.$phpEx");
diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php
index 67f59bd618..a4c2356a43 100644
--- a/phpBB/includes/mcp/mcp_notes.php
+++ b/phpBB/includes/mcp/mcp_notes.php
@@ -28,9 +28,9 @@ class mcp_notes
var $p_master;
var $u_action;
- function mcp_notes(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php
index 67a1a959e4..eecfe9cbc8 100644
--- a/phpBB/includes/mcp/mcp_pm_reports.php
+++ b/phpBB/includes/mcp/mcp_pm_reports.php
@@ -28,9 +28,9 @@ class mcp_pm_reports
var $p_master;
var $u_action;
- function mcp_pm_reports(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
@@ -55,7 +55,7 @@ class mcp_pm_reports
$report_id_list = $request->variable('report_id_list', array(0));
- if (!sizeof($report_id_list))
+ if (!count($report_id_list))
{
trigger_error('NO_REPORT_SELECTED');
}
@@ -104,7 +104,7 @@ class mcp_pm_reports
$pm_info = phpbb_get_pm_data(array($pm_id));
- if (!sizeof($pm_info))
+ if (!count($pm_info))
{
trigger_error('NO_REPORT_SELECTED');
}
@@ -141,7 +141,7 @@ class mcp_pm_reports
}
$db->sql_freeresult($result);
- if (sizeof($attachments))
+ if (count($attachments))
{
$update_count = array();
parse_attachments(0, $message, $attachments, $update_count);
@@ -251,7 +251,7 @@ class mcp_pm_reports
}
$db->sql_freeresult($result);
- if (sizeof($report_ids))
+ if (count($report_ids))
{
$sql = 'SELECT p.*, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id
FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru
@@ -270,7 +270,7 @@ class mcp_pm_reports
}
$db->sql_freeresult($result);
- if (sizeof($pm_list))
+ if (count($pm_list))
{
$address_list = get_recipient_strings($pm_by_id);
diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php
index 60ec3b8f5a..8d278079fb 100644
--- a/phpBB/includes/mcp/mcp_post.php
+++ b/phpBB/includes/mcp/mcp_post.php
@@ -38,7 +38,7 @@ function mcp_post_details($id, $mode, $action)
add_form_key('mcp_post_details');
- if (!sizeof($post_info))
+ if (!count($post_info))
{
trigger_error('POST_NOT_EXIST');
}
@@ -165,7 +165,7 @@ function mcp_post_details($id, $mode, $action)
}
$db->sql_freeresult($result);
- if (sizeof($attachments))
+ if (count($attachments))
{
$user->add_lang('viewtopic');
$update_count = array();
@@ -213,6 +213,10 @@ function mcp_post_details($id, $mode, $action)
$l_deleted_by = '';
}
+ // parse signature
+ $parse_flags = ($post_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
+ $post_info['user_sig'] = generate_text_for_display($post_info['user_sig'], $post_info['user_sig_bbcode_uid'], $post_info['user_sig_bbcode_bitfield'], $parse_flags, true);
+
$mcp_post_template_data = array(
'U_MCP_ACTION' => "$url&amp;i=main&amp;quickmod=1&amp;mode=post_details", // Use this for mode paramaters
'U_POST_ACTION' => "$url&amp;i=$id&amp;mode=post_details", // Use this for action parameters
@@ -262,6 +266,7 @@ function mcp_post_details($id, $mode, $action)
'POST_IP' => $post_info['poster_ip'],
'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && $request->variable('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
'POST_ID' => $post_info['post_id'],
+ 'SIGNATURE' => $post_info['user_sig'],
'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? "$url&amp;i=$id&amp;mode=$mode&amp;lookup={$post_info['poster_ip']}#ip" : '',
'U_WHOIS' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;mode=$mode&amp;action=whois&amp;p=$post_id&amp;ip={$post_info['poster_ip']}") : '',
@@ -409,7 +414,7 @@ function mcp_post_details($id, $mode, $action)
);
}
- if (sizeof($users_ary))
+ if (count($users_ary))
{
// Get the usernames
$sql = 'SELECT user_id, username
@@ -495,7 +500,7 @@ function mcp_post_details($id, $mode, $action)
$user_select = '';
- if (sizeof($usernames_ary))
+ if (count($usernames_ary))
{
ksort($usernames_ary);
@@ -656,7 +661,7 @@ function change_poster(&$post_info, $userdata)
// Renew post info
$post_info = phpbb_get_post_data(array($post_id), false, true);
- if (!sizeof($post_info))
+ if (!count($post_info))
{
trigger_error('POST_NOT_EXIST');
}
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index f379392b12..dec583f6f4 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -28,9 +28,9 @@ class mcp_queue
var $p_master;
var $u_action;
- public function mcp_queue(&$p_master)
+ public function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
public function main($id, $mode)
@@ -179,7 +179,7 @@ class mcp_queue
$post_info = phpbb_get_post_data(array($post_id), 'm_approve', true);
- if (!sizeof($post_info))
+ if (!count($post_info))
{
trigger_error('NO_POST_SELECTED');
}
@@ -230,7 +230,7 @@ class mcp_queue
}
$db->sql_freeresult($result);
- if (sizeof($attachments))
+ if (count($attachments))
{
$update_count = array();
parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
@@ -280,7 +280,7 @@ class mcp_queue
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&amp;p=' . $post_info['post_id'] . '#p' . $post_info['post_id']);
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&amp;t=' . $post_info['topic_id']);
- $template->assign_vars(array(
+ $post_data = array(
'S_MCP_QUEUE' => true,
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&amp;p=$post_id&amp;f=$forum_id"),
'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']),
@@ -324,7 +324,35 @@ class mcp_queue
'S_FIRST_POST' => ($post_info['topic_first_post_id'] == $post_id),
'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id . '&amp;lookup=' . $post_info['poster_ip']) . '#ip' : '',
- ));
+ );
+
+ /**
+ * Alter post awaiting approval template before it is rendered
+ *
+ * @event core.mcp_queue_approve_details_template
+ * @var int post_id Post ID
+ * @var int topic_id Topic ID
+ * @var array topic_info Topic data
+ * @var array post_info Post data
+ * @var array post_data Post template data
+ * @var string message Post message
+ * @var string post_url Post URL
+ * @var string topic_url Topic URL
+ * @since 3.2.2-RC1
+ */
+ $vars = array(
+ 'post_id',
+ 'topic_id',
+ 'topic_info',
+ 'post_info',
+ 'post_data',
+ 'message',
+ 'post_url',
+ 'topic_url',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_queue_approve_details_template', compact($vars)));
+
+ $template->assign_vars($post_data);
break;
@@ -349,7 +377,7 @@ class mcp_queue
{
$topic_info = phpbb_get_topic_data(array($topic_id));
- if (!sizeof($topic_info))
+ if (!count($topic_info))
{
trigger_error('TOPIC_NOT_EXIST');
}
@@ -379,7 +407,7 @@ class mcp_queue
$forum_list[] = $row['forum_id'];
}
- if (!sizeof($forum_list))
+ if (!count($forum_list))
{
trigger_error('NOT_MODERATOR');
}
@@ -395,7 +423,7 @@ class mcp_queue
{
$forum_info = phpbb_get_forum_data(array($forum_id), $m_perm);
- if (!sizeof($forum_info))
+ if (!count($forum_info))
{
trigger_error('NOT_MODERATOR');
}
@@ -465,7 +493,7 @@ class mcp_queue
}
$db->sql_freeresult($result);
- if (sizeof($post_ids))
+ if (count($post_ids))
{
$sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
@@ -473,6 +501,29 @@ class mcp_queue
AND t.topic_id = p.topic_id
AND u.user_id = p.poster_id
ORDER BY ' . $sort_order_sql;
+
+ /**
+ * Alter sql query to get information on all posts in queue
+ *
+ * @event core.mcp_queue_get_posts_for_posts_query_before
+ * @var string sql String with the query to be executed
+ * @var array forum_list List of forums that contain the posts
+ * @var int visibility_const Integer with one of the possible ITEM_* constant values
+ * @var int topic_id topic_id in the page request
+ * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string)
+ * @var string sort_order_sql String with the ORDER BY SQL code used in this query
+ * @since 3.2.3-RC2
+ */
+ $vars = array(
+ 'sql',
+ 'forum_list',
+ 'visibility_const',
+ 'topic_id',
+ 'limit_time_sql',
+ 'sort_order_sql',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_for_posts_query_before', compact($vars)));
+
$result = $db->sql_query($sql);
$post_data = $rowset = array();
@@ -537,7 +588,7 @@ class mcp_queue
$db->sql_freeresult($result);
}
- if (sizeof($forum_names))
+ if (count($forum_names))
{
// Select the names for the forum_ids
$sql = 'SELECT forum_id, forum_name
@@ -560,7 +611,7 @@ class mcp_queue
$row['post_username'] = $row['username'] ?: $user->lang['GUEST'];
}
- $template->assign_block_vars('postrow', array(
+ $post_row = array(
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''),
@@ -578,7 +629,25 @@ class mcp_queue
'TOPIC_TITLE' => $row['topic_title'],
'POST_TIME' => $user->format_date($row['post_time']),
'S_HAS_ATTACHMENTS' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'],
- ));
+ );
+
+ /**
+ * Alter sql query to get information on all topics in the list of forums provided.
+ *
+ * @event core.mcp_queue_get_posts_modify_post_row
+ * @var array post_row Template variables for current post
+ * @var array row Post data
+ * @var array forum_names Forum names
+ * @since 3.2.3-RC2
+ */
+ $vars = array(
+ 'post_row',
+ 'row',
+ 'forum_names',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_modify_post_row', compact($vars)));
+
+ $template->assign_block_vars('postrow', $post_row);
}
unset($rowset, $forum_names);
@@ -771,7 +840,7 @@ class mcp_queue
}
else
{
- $success_msg = (sizeof($post_info) == 1) ? 'POST_' . strtoupper($action) . 'D_SUCCESS' : 'POSTS_' . strtoupper($action) . 'D_SUCCESS';
+ $success_msg = (count($post_info) == 1) ? 'POST_' . strtoupper($action) . 'D_SUCCESS' : 'POSTS_' . strtoupper($action) . 'D_SUCCESS';
}
/**
@@ -814,7 +883,7 @@ class mcp_queue
$message .= '<br /><br />' . $user->lang('RETURN_PAGE', '<a href="' . $redirect . '">', '</a>');
// If approving one post, also give links back to post...
- if (sizeof($post_info) == 1 && $post_url)
+ if (count($post_info) == 1 && $post_url)
{
$message .= '<br /><br />' . $user->lang('RETURN_POST', '<a href="' . $post_url . '">', '</a>');
}
@@ -847,14 +916,14 @@ class mcp_queue
// Create the confirm box message
$action_msg = strtoupper($action);
- $num_posts = sizeof($post_id_list) - $num_topics;
+ $num_posts = count($post_id_list) - $num_topics;
if ($num_topics > 0 && $num_posts <= 0)
{
$action_msg .= '_TOPIC' . (($num_topics == 1) ? '' : 'S');
}
else
{
- $action_msg .= '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S');
+ $action_msg .= '_POST' . ((count($post_id_list) == 1) ? '' : 'S');
}
confirm_box(false, $action_msg, $s_hidden_fields, 'mcp_approve.html');
}
@@ -919,9 +988,9 @@ class mcp_queue
);
}
- if (sizeof($topic_info) >= 1)
+ if (count($topic_info) >= 1)
{
- $success_msg = (sizeof($topic_info) == 1) ? 'TOPIC_' . strtoupper($action) . 'D_SUCCESS' : 'TOPICS_' . strtoupper($action) . 'D_SUCCESS';
+ $success_msg = (count($topic_info) == 1) ? 'TOPIC_' . strtoupper($action) . 'D_SUCCESS' : 'TOPICS_' . strtoupper($action) . 'D_SUCCESS';
}
foreach ($approve_log as $log_data)
@@ -1024,7 +1093,7 @@ class mcp_queue
$message .= '<br /><br />' . $user->lang('RETURN_PAGE', '<a href="' . $redirect . '">', '</a>');
// If approving one topic, also give links back to topic...
- if (sizeof($topic_info) == 1 && $topic_url)
+ if (count($topic_info) == 1 && $topic_url)
{
$message .= '<br /><br />' . $user->lang('RETURN_TOPIC', '<a href="' . $topic_url . '">', '</a>');
}
@@ -1055,7 +1124,7 @@ class mcp_queue
'S_' . strtoupper($action) => true,
));
- confirm_box(false, strtoupper($action) . '_TOPIC' . ((sizeof($topic_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
+ confirm_box(false, strtoupper($action) . '_TOPIC' . ((count($topic_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
}
redirect($redirect);
@@ -1206,8 +1275,8 @@ class mcp_queue
}
// Get disapproved posts/topics counts separately
- $num_disapproved_topics = sizeof($disapprove_log_topics);
- $num_disapproved_posts = sizeof($disapprove_log_posts);
+ $num_disapproved_topics = count($disapprove_log_topics);
+ $num_disapproved_posts = count($disapprove_log_posts);
// Build the whole log
$disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts);
@@ -1216,7 +1285,7 @@ class mcp_queue
unset($post_data, $disapprove_log_topics, $disapprove_log_posts);
// Let's do the job - delete disapproved posts
- if (sizeof($post_disapprove_list))
+ if (count($post_disapprove_list))
{
if (!function_exists('delete_posts'))
{
@@ -1444,7 +1513,7 @@ class mcp_queue
$l_confirm_msg = 'DELETE_POST_PERMANENTLY';
$confirm_template = 'confirm_delete_body.html';
}
- $l_confirm_msg .= ((sizeof($post_id_list) == 1) ? '' : 'S');
+ $l_confirm_msg .= ((count($post_id_list) == 1) ? '' : 'S');
$template->assign_vars(array(
'S_NOTIFY_POSTER' => $show_notify,
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index 1462acf110..4600257344 100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -28,9 +28,9 @@ class mcp_reports
var $p_master;
var $u_action;
- function mcp_reports(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
@@ -53,7 +53,7 @@ class mcp_reports
$report_id_list = $request->variable('report_id_list', array(0));
- if (!sizeof($report_id_list))
+ if (!count($report_id_list))
{
trigger_error('NO_REPORT_SELECTED');
}
@@ -158,7 +158,7 @@ class mcp_reports
$post_info = phpbb_get_post_data(array($post_id), 'm_report', true);
- if (!sizeof($post_info))
+ if (!count($post_info))
{
trigger_error('NO_REPORT_SELECTED');
}
@@ -222,7 +222,7 @@ class mcp_reports
}
$db->sql_freeresult($result);
- if (sizeof($attachments))
+ if (count($attachments))
{
$update_count = array();
parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
@@ -242,7 +242,14 @@ class mcp_reports
}
}
- $template->assign_vars(array(
+ // parse signature
+ $parse_flags = ($post_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
+ $post_info['user_sig'] = generate_text_for_display($post_info['user_sig'], $post_info['user_sig_bbcode_uid'], $post_info['user_sig_bbcode_bitfield'], $parse_flags, true);
+
+ $topic_id = (int) $post_info['topic_id'];
+
+ // So it can be sent through the event below.
+ $report_template = array(
'S_MCP_REPORT' => true,
'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id),
'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
@@ -291,9 +298,36 @@ class mcp_reports
'POST_IP' => $post_info['poster_ip'],
'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && $request->variable('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
'POST_ID' => $post_info['post_id'],
+ 'SIGNATURE' => $post_info['user_sig'],
'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? $this->u_action . '&amp;r=' . $report_id . '&amp;p=' . $post_id . '&amp;f=' . $forum_id . '&amp;lookup=' . $post_info['poster_ip'] . '#ip' : '',
- ));
+ );
+
+ /**
+ * Event to add/modify MCP report details template data.
+ *
+ * @event core.mcp_report_template_data
+ * @var int forum_id The forum_id, the number in the f GET parameter
+ * @var int topic_id The topic_id of the report being viewed
+ * @var int post_id The post_id of the report being viewed (if 0, it is meaningless)
+ * @var int report_id The report_id of the report being viewed
+ * @var array report Array with the report data
+ * @var array report_template Array with the report template data
+ * @var array post_info Array with the reported post data
+ * @since 3.2.5-RC1
+ */
+ $vars = array(
+ 'forum_id',
+ 'topic_id',
+ 'post_id',
+ 'report_id',
+ 'report',
+ 'report_template',
+ 'post_info',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_report_template_data', compact($vars)));
+
+ $template->assign_vars($report_template);
$this->tpl_name = 'mcp_post';
@@ -321,7 +355,7 @@ class mcp_reports
{
$topic_info = phpbb_get_topic_data(array($topic_id));
- if (!sizeof($topic_info))
+ if (!count($topic_info))
{
trigger_error('TOPIC_NOT_EXIST');
}
@@ -346,7 +380,7 @@ class mcp_reports
$forum_list[] = $row['forum_id'];
}
- if (!sizeof($forum_list))
+ if (!count($forum_list))
{
trigger_error('NOT_MODERATOR');
}
@@ -362,7 +396,7 @@ class mcp_reports
{
$forum_info = phpbb_get_forum_data(array($forum_id), 'm_report');
- if (!sizeof($forum_info))
+ if (!count($forum_info))
{
trigger_error('NOT_MODERATOR');
}
@@ -443,7 +477,7 @@ class mcp_reports
}
$db->sql_freeresult($result);
- if (sizeof($report_ids))
+ if (count($report_ids))
{
$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru
@@ -617,12 +651,12 @@ function close_report($report_id_list, $mode, $action, $pm = false)
}
$db->sql_freeresult($result);
- if (sizeof($reports))
+ if (count($reports))
{
$close_report_posts = array_unique($close_report_posts);
$close_report_topics = array_unique($close_report_topics);
- if (!$pm && sizeof($close_report_posts))
+ if (!$pm && count($close_report_posts))
{
// Get a list of topics that still contain reported posts
$sql = 'SELECT DISTINCT topic_id
@@ -658,7 +692,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)
}
$db->sql_query($sql);
- if (sizeof($close_report_posts))
+ if (count($close_report_posts))
{
if ($pm)
{
@@ -679,7 +713,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)
WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
$db->sql_query($sql);
- if (sizeof($close_report_topics))
+ if (count($close_report_topics))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
@@ -721,7 +755,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)
}
// Notify reporters
- if (sizeof($notify_reporters))
+ if (count($notify_reporters))
{
foreach ($notify_reporters as $report_id => $reporter)
{
@@ -761,11 +795,11 @@ function close_report($report_id_list, $mode, $action, $pm = false)
unset($notify_reporters, $post_info, $reports);
- $success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS';
+ $success_msg = (count($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS';
}
else
{
- confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);
+ confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((count($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);
}
$redirect = $request->variable('redirect', "index.$phpEx");
@@ -784,12 +818,12 @@ function close_report($report_id_list, $mode, $action, $pm = false)
if (!$pm)
{
- if (sizeof($forum_ids) === 1)
+ if (count($forum_ids) === 1)
{
$return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
}
- if (sizeof($topic_ids) === 1)
+ if (count($topic_ids) === 1)
{
$return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . current($topic_ids) . '&amp;f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
}
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index 76df5b3a5e..83ad56f3e4 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -36,7 +36,7 @@ function mcp_topic_view($id, $mode, $action)
$topic_id = $request->variable('t', 0);
$topic_info = phpbb_get_topic_data(array($topic_id), false, true);
- if (!sizeof($topic_info))
+ if (!count($topic_info))
{
trigger_error('TOPIC_NOT_EXIST');
}
@@ -93,11 +93,15 @@ function mcp_topic_view($id, $mode, $action)
// Restore or pprove posts?
if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id']))
{
- include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx);
+ if (!class_exists('mcp_queue'))
+ {
+ include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx);
+ }
+
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
- if (!sizeof($post_id_list))
+ if (!count($post_id_list))
{
trigger_error('NO_POST_SELECTED');
}
@@ -138,14 +142,36 @@ function mcp_topic_view($id, $mode, $action)
}
$start = $pagination->validate_start($start, $posts_per_page, $total);
- $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.*
- FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
- WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . '
+ $sql_where = (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . '
p.topic_id = ' . $topic_id . '
AND ' . $phpbb_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . '
AND p.poster_id = u.user_id ' .
- $limit_time_sql . '
- ORDER BY ' . $sort_order_sql;
+ $limit_time_sql;
+
+ $sql_ary = array(
+ 'SELECT' => 'u.username, u.username_clean, u.user_colour, p.*',
+ 'FROM' => array(
+ POSTS_TABLE => 'p',
+ USERS_TABLE => 'u'
+ ),
+ 'LEFT_JOIN' => array(),
+ 'WHERE' => $sql_where,
+ 'ORDER_BY' => $sort_order_sql,
+ );
+
+ /**
+ * Event to modify the SQL query before the MCP topic review posts is queried
+ *
+ * @event core.mcp_topic_modify_sql_ary
+ * @var array sql_ary The SQL array to get the data of the MCP topic review posts
+ * @since 3.2.8-RC1
+ */
+ $vars = array('sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.mcp_topic_modify_sql_ary', compact($vars)));
+
+ $sql = $db->sql_build_query('SELECT', $sql_ary);
+ unset($sql_ary);
+
$result = $db->sql_query_limit($sql, $posts_per_page, $start);
$rowset = $post_id_list = array();
@@ -172,7 +198,7 @@ function mcp_topic_view($id, $mode, $action)
// Grab extensions
$attachments = array();
- if ($topic_info['topic_attachment'] && sizeof($post_id_list))
+ if ($topic_info['topic_attachment'] && count($post_id_list))
{
// Get attachments...
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id']))
@@ -326,7 +352,7 @@ function mcp_topic_view($id, $mode, $action)
{
$to_topic_info = phpbb_get_topic_data(array($to_topic_id), 'm_merge');
- if (!sizeof($to_topic_info))
+ if (!count($to_topic_info))
{
$to_topic_id = 0;
}
@@ -408,7 +434,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
$forum_id = $request->variable('forum_id', 0);
$start = $request->variable('start', 0);
- if (!sizeof($post_id_list))
+ if (!count($post_id_list))
{
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
return;
@@ -422,7 +448,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
$post_id = $post_id_list[0];
$post_info = phpbb_get_post_data(array($post_id));
- if (!sizeof($post_info))
+ if (!count($post_info))
{
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
return;
@@ -446,7 +472,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
$forum_info = phpbb_get_forum_data(array($to_forum_id), 'f_post');
- if (!sizeof($forum_info))
+ if (!count($forum_info))
{
$template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']);
return;
@@ -530,7 +556,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
$db->sql_freeresult($result);
}
- if (!sizeof($post_id_list))
+ if (!count($post_id_list))
{
trigger_error('NO_POST_SELECTED');
}
@@ -628,7 +654,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
}
$db->sql_freeresult($result);
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
}
@@ -649,7 +675,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
}
$db->sql_freeresult($result);
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary);
}
@@ -690,7 +716,7 @@ function merge_posts($topic_id, $to_topic_id)
$topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');
- if (!sizeof($topic_data) || empty($topic_data[$to_topic_id]))
+ if (!count($topic_data) || empty($topic_data[$to_topic_id]))
{
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
return;
@@ -707,7 +733,7 @@ function merge_posts($topic_id, $to_topic_id)
$post_id_list = $request->variable('post_id_list', array(0));
$start = $request->variable('start', 0);
- if (!sizeof($post_id_list))
+ if (!count($post_id_list))
{
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
return;
diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php
index 0e80372f43..df175133fc 100644
--- a/phpBB/includes/mcp/mcp_warn.php
+++ b/phpBB/includes/mcp/mcp_warn.php
@@ -28,9 +28,9 @@ class mcp_warn
var $p_master;
var $u_action;
- function mcp_warn(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 45f00c9ee1..0b79cca864 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -705,10 +705,10 @@ class bbcode_firstpass extends bbcode
if ($tok == ']')
{
// if $tok is ']' the buffer holds a tag
- if (strtolower($buffer) == '/list' && sizeof($list_end_tags))
+ if (strtolower($buffer) == '/list' && count($list_end_tags))
{
// valid [/list] tag, check nesting so that we don't hit false positives
- if (sizeof($item_end_tags) && sizeof($item_end_tags) >= sizeof($list_end_tags))
+ if (count($item_end_tags) && count($item_end_tags) >= count($list_end_tags))
{
// current li tag has not been closed
$out = preg_replace('/\n?\[$/', '[', $out) . array_pop($item_end_tags) . '][';
@@ -733,10 +733,10 @@ class bbcode_firstpass extends bbcode
}
else
{
- if (($buffer == '*' || substr($buffer, -2) == '[*') && sizeof($list_end_tags))
+ if (($buffer == '*' || substr($buffer, -2) == '[*') && count($list_end_tags))
{
// the buffer holds a bullet tag and we have a [list] tag open
- if (sizeof($item_end_tags) >= sizeof($list_end_tags))
+ if (count($item_end_tags) >= count($list_end_tags))
{
if (substr($buffer, -2) == '[*')
{
@@ -780,11 +780,11 @@ class bbcode_firstpass extends bbcode
while ($in);
// do we have some tags open? close them now
- if (sizeof($item_end_tags))
+ if (count($item_end_tags))
{
$out .= '[' . implode('][', $item_end_tags) . ']';
}
- if (sizeof($list_end_tags))
+ if (count($list_end_tags))
{
$out .= '[' . implode('][', $list_end_tags) . ']';
}
@@ -835,7 +835,7 @@ class bbcode_firstpass extends bbcode
if ($tok == ']')
{
- if (strtolower($buffer) == '/quote' && sizeof($close_tags) && substr($out, -1, 1) == '[')
+ if (strtolower($buffer) == '/quote' && count($close_tags) && substr($out, -1, 1) == '[')
{
// we have found a closing tag
$out .= array_pop($close_tags) . ']';
@@ -949,7 +949,7 @@ class bbcode_firstpass extends bbcode
$out .= $buffer;
- if (sizeof($close_tags))
+ if (count($close_tags))
{
$out .= '[' . implode('][', $close_tags) . ']';
}
@@ -1139,7 +1139,7 @@ class parse_message extends bbcode_firstpass
/**
* Init - give message here or manually
*/
- function parse_message($message = '')
+ function __construct($message = '')
{
// Init BBCode UID
$this->bbcode_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN);
@@ -1500,7 +1500,7 @@ class parse_message extends bbcode_firstpass
$db->sql_freeresult($result);
}
- if (sizeof($match))
+ if (count($match))
{
if ($max_smilies)
{
@@ -1534,7 +1534,7 @@ class parse_message extends bbcode_firstpass
$error = array();
- $num_attachments = sizeof($this->attachment_data);
+ $num_attachments = count($this->attachment_data);
$this->filename_data['filecomment'] = $request->variable('filecomment', '', true);
$upload = $request->file($form_name);
$upload_file = (!empty($upload) && $upload['name'] !== 'none' && trim($upload['name']));
@@ -1571,7 +1571,7 @@ class parse_message extends bbcode_firstpass
$filedata = $attachment_manager->upload($form_name, $forum_id, false, '', $is_message);
$error = $filedata['error'];
- if ($filedata['post_attach'] && !sizeof($error))
+ if ($filedata['post_attach'] && !count($error))
{
$sql_ary = array(
'physical_filename' => $filedata['physical_filename'],
@@ -1587,6 +1587,16 @@ class parse_message extends bbcode_firstpass
'poster_id' => $user->data['user_id'],
);
+ /**
+ * Modify attachment sql array on submit
+ *
+ * @event core.modify_attachment_sql_ary_on_submit
+ * @var array sql_ary Array containing SQL data
+ * @since 3.2.6-RC1
+ */
+ $vars = array('sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.modify_attachment_sql_ary_on_submit', compact($vars)));
+
$db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
$new_entry = array(
@@ -1635,7 +1645,7 @@ class parse_message extends bbcode_firstpass
}
}
- if ($preview || $refresh || sizeof($error))
+ if ($preview || $refresh || count($error))
{
if (isset($this->plupload) && $this->plupload->is_active())
{
@@ -1706,7 +1716,7 @@ class parse_message extends bbcode_firstpass
$filedata = $attachment_manager->upload($form_name, $forum_id, false, '', $is_message);
$error = array_merge($error, $filedata['error']);
- if (!sizeof($error))
+ if (!count($error))
{
$sql_ary = array(
'physical_filename' => $filedata['physical_filename'],
@@ -1722,6 +1732,16 @@ class parse_message extends bbcode_firstpass
'poster_id' => $user->data['user_id'],
);
+ /**
+ * Modify attachment sql array on upload
+ *
+ * @event core.modify_attachment_sql_ary_on_upload
+ * @var array sql_ary Array containing SQL data
+ * @since 3.2.6-RC1
+ */
+ $vars = array('sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.modify_attachment_sql_ary_on_upload', compact($vars)));
+
$db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
$new_entry = array(
@@ -1802,7 +1822,7 @@ class parse_message extends bbcode_firstpass
$check_user_id = ($check_user_id === false) ? $user->data['user_id'] : $check_user_id;
- if (!sizeof($attachment_data))
+ if (!count($attachment_data))
{
return;
}
@@ -1822,7 +1842,7 @@ class parse_message extends bbcode_firstpass
}
// Regenerate already posted attachments
- if (sizeof($not_orphan))
+ if (count($not_orphan))
{
// Get the attachment data, based on the poster id...
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment, filesize
@@ -1842,13 +1862,13 @@ class parse_message extends bbcode_firstpass
$db->sql_freeresult($result);
}
- if (sizeof($not_orphan))
+ if (count($not_orphan))
{
trigger_error('NO_ACCESS_ATTACHMENT', E_USER_ERROR);
}
// Regenerate newly uploaded attachments
- if (sizeof($orphan))
+ if (count($orphan))
{
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment, filesize
FROM ' . ATTACHMENTS_TABLE . '
@@ -1868,7 +1888,7 @@ class parse_message extends bbcode_firstpass
$db->sql_freeresult($result);
}
- if (sizeof($orphan))
+ if (count($orphan))
{
trigger_error('NO_ACCESS_ATTACHMENT', E_USER_ERROR);
}
@@ -1889,7 +1909,7 @@ class parse_message extends bbcode_firstpass
$tmp_message = $this->message;
$poll['poll_options'] = preg_split('/\s*?\n\s*/', trim($poll['poll_option_text']));
- $poll['poll_options_size'] = sizeof($poll['poll_options']);
+ $poll['poll_options_size'] = count($poll['poll_options']);
foreach ($poll['poll_options'] as &$poll_option)
{
@@ -1918,7 +1938,7 @@ class parse_message extends bbcode_firstpass
}
}
- if (sizeof($poll['poll_options']) == 1)
+ if (count($poll['poll_options']) == 1)
{
$this->warn_msg[] = $user->lang['TOO_FEW_POLL_OPTIONS'];
}
diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php
index 9699843db4..2f80582918 100644
--- a/phpBB/includes/questionnaire/questionnaire.php
+++ b/phpBB/includes/questionnaire/questionnaire.php
@@ -40,7 +40,7 @@ class phpbb_questionnaire_data_collector
*
* @param string
*/
- function phpbb_questionnaire_data_collector($install_id)
+ function __construct($install_id)
{
$this->install_id = $install_id;
$this->providers = array();
@@ -223,7 +223,7 @@ class phpbb_questionnaire_phpbb_data_provider
*
* @param array $config
*/
- function phpbb_questionnaire_phpbb_data_provider($config)
+ function __construct($config)
{
// generate a unique id if necessary
if (empty($config['questionnaire_unique_id']))
@@ -337,7 +337,7 @@ class phpbb_questionnaire_phpbb_data_provider
'edit_time' => true,
'email_check_mx' => true,
'email_enable' => true,
- 'email_function_name' => true,
+ 'email_force_sender' => true,
'email_package_size' => true,
'enable_confirm' => true,
'enable_pm_icons' => true,
@@ -369,7 +369,6 @@ class phpbb_questionnaire_phpbb_data_provider
'hot_threshold' => true,
'img_create_thumbnail' => true,
'img_display_inlined' => true,
- 'img_imagick' => true,
'img_link_height' => true,
'img_link_width' => true,
'img_max_height' => true,
diff --git a/phpBB/includes/sphinxapi.php b/phpBB/includes/sphinxapi.php
index 5e1f131ac2..b63a85a90f 100644
--- a/phpBB/includes/sphinxapi.php
+++ b/phpBB/includes/sphinxapi.php
@@ -126,7 +126,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 );
function sphPackI64 ( $v )
{
assert ( is_numeric($v) );
-
+
// x64
if ( PHP_INT_SIZE>=8 )
{
@@ -138,7 +138,7 @@ function sphPackI64 ( $v )
if ( is_int($v) )
return pack ( "NN", $v < 0 ? -1 : 0, $v );
- // x32, bcmath
+ // x32, bcmath
if ( function_exists("bcmul") )
{
if ( bccomp ( $v, 0 ) == -1 )
@@ -175,16 +175,16 @@ function sphPackI64 ( $v )
function sphPackU64 ( $v )
{
assert ( is_numeric($v) );
-
+
// x64
if ( PHP_INT_SIZE>=8 )
{
assert ( $v>=0 );
-
+
// x64, int
if ( is_int($v) )
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
-
+
// x64, bcmath
if ( function_exists("bcmul") )
{
@@ -192,12 +192,12 @@ function sphPackU64 ( $v )
$l = bcmod ( $v, 4294967296 );
return pack ( "NN", $h, $l );
}
-
+
// x64, no-bcmath
$p = max ( 0, strlen($v) - 13 );
$lo = (int)substr ( $v, $p );
$hi = (int)substr ( $v, 0, $p );
-
+
$m = $lo + $hi*1316134912;
$l = $m % 4294967296;
$h = $hi*2328 + (int)($m/4294967296);
@@ -208,7 +208,7 @@ function sphPackU64 ( $v )
// x32, int
if ( is_int($v) )
return pack ( "NN", 0, $v );
-
+
// x32, bcmath
if ( function_exists("bcmul") )
{
@@ -221,7 +221,7 @@ function sphPackU64 ( $v )
$p = max(0, strlen($v) - 13);
$lo = (float)substr($v, $p);
$hi = (float)substr($v, 0, $p);
-
+
$m = $lo + $hi*1316134912.0;
$q = floor($m / 4294967296.0);
$l = $m - ($q * 4294967296.0);
@@ -277,11 +277,11 @@ function sphUnpackU64 ( $v )
// x32, bcmath
if ( function_exists("bcmul") )
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
-
+
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
-
+
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@@ -324,7 +324,7 @@ function sphUnpackI64 ( $v )
return $lo;
return sprintf ( "%.0f", $lo - 4294967296.0 );
}
-
+
$neg = "";
$c = 0;
if ( $hi<0 )
@@ -333,7 +333,7 @@ function sphUnpackI64 ( $v )
$lo = ~$lo;
$c = 1;
$neg = "-";
- }
+ }
$hi = sprintf ( "%u", $hi );
$lo = sprintf ( "%u", $lo );
@@ -345,7 +345,7 @@ function sphUnpackI64 ( $v )
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
-
+
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@@ -427,7 +427,7 @@ class SphinxClient
/////////////////////////////////////////////////////////////////////////////
/// create a new client object and fill defaults
- function SphinxClient ()
+ function __construct ()
{
// per-client-object settings
$this->_host = "localhost";
@@ -510,7 +510,7 @@ class SphinxClient
$this->_path = $host;
return;
}
-
+
assert ( is_int($port) );
$this->_host = $host;
$this->_port = $port;
@@ -590,14 +590,14 @@ class SphinxClient
$fp = @fsockopen ( $host, $port, $errno, $errstr );
else
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
-
+
if ( !$fp )
{
if ( $this->_path )
$location = $this->_path;
else
$location = "{$this->_host}:{$this->_port}";
-
+
$errstr = trim ( $errstr );
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
$this->_connerror = true;
@@ -1236,7 +1236,7 @@ class SphinxClient
if ( $type==SPH_ATTR_FLOAT )
{
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
- list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
+ list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
$attrvals[$attr] = $fval;
continue;
}
@@ -1264,7 +1264,7 @@ class SphinxClient
} else if ( $type==SPH_ATTR_STRING )
{
$attrvals[$attr] = substr ( $response, $p, $val );
- $p += $val;
+ $p += $val;
} else
{
$attrvals[$attr] = sphFixUint($val);
@@ -1345,7 +1345,7 @@ class SphinxClient
if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;
-
+
/////////////////
// build request
@@ -1634,7 +1634,7 @@ class SphinxClient
fclose ( $this->_socket );
$this->_socket = false;
-
+
return true;
}
diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php
index 1e54c18dc1..7a90f2e3b1 100644
--- a/phpBB/includes/ucp/ucp_activate.php
+++ b/phpBB/includes/ucp/ucp_activate.php
@@ -87,6 +87,8 @@ class ucp_activate
WHERE user_id = ' . $user_row['user_id'];
$db->sql_query($sql);
+ $user->reset_login_keys($user_row['user_id']);
+
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array(
'reportee_id' => $user_row['user_id'],
$user_row['username']
diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php
index 66c3109b3d..7808fed325 100644
--- a/phpBB/includes/ucp/ucp_attachments.php
+++ b/phpBB/includes/ucp/ucp_attachments.php
@@ -29,7 +29,7 @@ class ucp_attachments
function main($id, $mode)
{
- global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request;
+ global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request, $auth;
$start = $request->variable('start', 0);
$sort_key = $request->variable('sk', 'a');
@@ -38,25 +38,36 @@ class ucp_attachments
$delete = (isset($_POST['delete'])) ? true : false;
$delete_ids = array_keys($request->variable('attachment', array(0)));
- if ($delete && sizeof($delete_ids))
+ if ($delete && count($delete_ids))
{
// Validate $delete_ids...
- $sql = 'SELECT attach_id
- FROM ' . ATTACHMENTS_TABLE . '
- WHERE poster_id = ' . $user->data['user_id'] . '
- AND is_orphan = 0
- AND ' . $db->sql_in_set('attach_id', $delete_ids);
+ $sql = 'SELECT a.attach_id, p.post_edit_locked, t.topic_status, f.forum_id, f.forum_status
+ FROM ' . ATTACHMENTS_TABLE . ' a
+ LEFT JOIN ' . POSTS_TABLE . ' p
+ ON (a.post_msg_id = p.post_id AND a.in_message = 0)
+ LEFT JOIN ' . TOPICS_TABLE . ' t
+ ON (t.topic_id = p.topic_id AND a.in_message = 0)
+ LEFT JOIN ' . FORUMS_TABLE . ' f
+ ON (f.forum_id = t.forum_id AND a.in_message = 0)
+ WHERE a.poster_id = ' . $user->data['user_id'] . '
+ AND a.is_orphan = 0
+ AND ' . $db->sql_in_set('a.attach_id', $delete_ids);
$result = $db->sql_query($sql);
$delete_ids = array();
while ($row = $db->sql_fetchrow($result))
{
+ if (!$auth->acl_get('m_edit', $row['forum_id']) && ($row['forum_status'] == ITEM_LOCKED || $row['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']))
+ {
+ continue;
+ }
+
$delete_ids[] = $row['attach_id'];
}
$db->sql_freeresult($result);
}
- if ($delete && sizeof($delete_ids))
+ if ($delete && count($delete_ids))
{
$s_hidden_fields = array(
'delete' => 1
@@ -75,12 +86,12 @@ class ucp_attachments
unset($attachment_manager);
meta_refresh(3, $this->u_action);
- $message = ((sizeof($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
+ $message = ((count($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message);
}
else
{
- confirm_box(false, (sizeof($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));
+ confirm_box(false, (count($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));
}
}
@@ -124,10 +135,12 @@ class ucp_attachments
$pagination = $phpbb_container->get('pagination');
$start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments);
- $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
+ $sql = 'SELECT a.*, t.topic_title, pr.message_subject as message_title, p.post_edit_locked, t.topic_status, f.forum_id, f.forum_status
FROM ' . ATTACHMENTS_TABLE . ' a
+ LEFT JOIN ' . POSTS_TABLE . ' p ON (a.post_msg_id = p.post_id AND a.in_message = 0)
LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)
- LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1)
+ LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id AND a.in_message = 0)
+ LEFT JOIN ' . PRIVMSGS_TABLE . ' pr ON (a.post_msg_id = pr.msg_id AND a.in_message = 1)
WHERE a.poster_id = ' . $user->data['user_id'] . "
AND a.is_orphan = 0
ORDER BY $order_by";
@@ -164,6 +177,7 @@ class ucp_attachments
'TOPIC_ID' => $row['topic_id'],
'S_IN_MESSAGE' => $row['in_message'],
+ 'S_LOCKED' => !$row['in_message'] && !$auth->acl_get('m_edit', $row['forum_id']) && ($row['forum_status'] == ITEM_LOCKED || $row['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']),
'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']),
'U_VIEW_TOPIC' => $view_topic)
diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php
index 08aacdef3a..e069f15eb2 100644
--- a/phpBB/includes/ucp/ucp_auth_link.php
+++ b/phpBB/includes/ucp/ucp_auth_link.php
@@ -55,14 +55,14 @@ class ucp_auth_link
$submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST);
// This path is only for primary actions
- if (!sizeof($error) && $submit)
+ if (!count($error) && $submit)
{
if (!check_form_key('ucp_auth_link'))
{
$error[] = 'FORM_INVALID';
}
- if (!sizeof($error))
+ if (!count($error))
{
// Any post data could be necessary for auth (un)linking
$link_data = $request->get_super_global(\phpbb\request\request_interface::POST);
diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php
index 352b7d1ec3..2423af86be 100644
--- a/phpBB/includes/ucp/ucp_groups.php
+++ b/phpBB/includes/ucp/ucp_groups.php
@@ -32,6 +32,9 @@ class ucp_groups
global $db, $user, $auth, $cache, $template;
global $request, $phpbb_container, $phpbb_log;
+ /** @var \phpbb\language\language $language Language object */
+ $language = $phpbb_container->get('language');
+
$user->add_lang('groups');
$return_page = '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '">', '</a>');
@@ -71,7 +74,7 @@ class ucp_groups
}
$db->sql_freeresult($result);
- if (!sizeof($group_row))
+ if (!count($group_row))
{
trigger_error('GROUP_NOT_EXIST');
}
@@ -330,7 +333,7 @@ class ucp_groups
$sql = 'SELECT group_id, group_name, group_colour, group_desc, group_desc_uid, group_desc_bitfield, group_desc_options, group_type, group_founder_manage
FROM ' . GROUPS_TABLE . '
- WHERE ' . ((sizeof($group_id_ary)) ? $db->sql_in_set('group_id', $group_id_ary, true) . ' AND ' : '') . "
+ WHERE ' . ((count($group_id_ary)) ? $db->sql_in_set('group_id', $group_id_ary, true) . ' AND ' : '') . "
group_type $sql_and
ORDER BY group_type DESC, group_name";
$result = $db->sql_query($sql);
@@ -396,7 +399,10 @@ class ucp_groups
$action = (isset($_POST['addusers'])) ? 'addusers' : $request->variable('action', '');
$group_id = $request->variable('g', 0);
- include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ if (!function_exists('phpbb_get_user_rank'))
+ {
+ include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ }
add_form_key('ucp_groups');
@@ -562,7 +568,7 @@ class ucp_groups
$error = array_merge($error, $colour_error);
}
- if (!sizeof($error))
+ if (!count($error))
{
// Only set the rank, colour, etc. if it's changed or if we're adding a new
// group. This prevents existing group members being updated if no changes
@@ -605,7 +611,7 @@ class ucp_groups
}
}
- if (sizeof($error))
+ if (count($error))
{
$error = array_map(array(&$user, 'lang'), $error);
$group_rank = $submit_ary['rank'];
@@ -703,12 +709,12 @@ class ucp_groups
'S_EDIT' => true,
'S_INCLUDE_SWATCH' => true,
'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"',
- 'S_ERROR' => (sizeof($error)) ? true : false,
+ 'S_ERROR' => (count($error)) ? true : false,
'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false,
'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled),
'S_GROUP_MANAGE' => true,
- 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR_MSG' => (count($error)) ? implode('<br />', $error) : '',
'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '',
'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0,
'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0,
@@ -911,7 +917,7 @@ class ucp_groups
if (confirm_box(true))
{
- if (!sizeof($mark_ary))
+ if (!count($mark_ary))
{
$start = 0;
@@ -934,7 +940,7 @@ class ucp_groups
group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
- $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200;
+ $start = (count($mark_ary) < 200) ? 0 : $start + 200;
}
else
{
@@ -1054,13 +1060,27 @@ class ucp_groups
if (confirm_box(true))
{
+ $return_manage_page = '<br /><br />' . $language->lang('RETURN_PAGE', '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>');
+
// Add user/s to group
if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, 0, 0, $group_row))
{
- trigger_error($user->lang[$error] . $return_page);
+ $display_message = $language->lang($error);
+
+ if ($error == 'GROUP_USERS_INVALID')
+ {
+ // Find which users don't exist
+ $actual_name_ary = $name_ary;
+ $actual_user_id_ary = [];
+ user_get_id_name($actual_user_id_ary, $actual_name_ary, false, true);
+
+ $display_message = $language->lang('GROUP_USERS_INVALID', implode($language->lang('COMMA_SEPARATOR'), array_udiff($name_ary, $actual_name_ary, 'strcasecmp')));
+ }
+
+ trigger_error($display_message . $return_manage_page);
}
- trigger_error($user->lang['GROUP_USERS_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
+ trigger_error($language->lang('GROUP_USERS_ADDED') . $return_manage_page);
}
else
{
@@ -1073,7 +1093,7 @@ class ucp_groups
'action' => $action
);
- confirm_box(false, $user->lang('GROUP_CONFIRM_ADD_USERS', sizeof($name_ary), implode($user->lang['COMMA_SEPARATOR'], $name_ary)), build_hidden_fields($s_hidden_fields));
+ confirm_box(false, $user->lang('GROUP_CONFIRM_ADD_USERS', count($name_ary), implode($user->lang['COMMA_SEPARATOR'], $name_ary)), build_hidden_fields($s_hidden_fields));
}
trigger_error($user->lang['NO_USERS_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php
index f4d47e30bb..c1f307eeb5 100644
--- a/phpBB/includes/ucp/ucp_login_link.php
+++ b/phpBB/includes/ucp/ucp_login_link.php
@@ -39,7 +39,7 @@ class ucp_login_link
*/
function main($id, $mode)
{
- global $phpbb_container, $request, $template, $user;
+ global $phpbb_container, $request, $template, $user, $phpbb_dispatcher;
global $phpbb_root_path, $phpEx;
// Initialize necessary variables
@@ -108,7 +108,7 @@ class ucp_login_link
}
}
- $template->assign_vars(array(
+ $tpl_ary = array(
// Common template elements
'LOGIN_LINK_ERROR' => $login_link_error,
'PASSWORD_CREDENTIAL' => 'login_password',
@@ -121,7 +121,24 @@ class ucp_login_link
// Login elements
'LOGIN_ERROR' => $login_error,
'LOGIN_USERNAME' => $login_username,
- ));
+ );
+
+ /**
+ * Event to perform additional actions before ucp_login_link is displayed
+ *
+ * @event core.ucp_login_link_template_after
+ * @var array data Login link data
+ * @var \phpbb\auth\provider_interface auth_provider Auth provider
+ * @var string login_link_error Login link error
+ * @var string login_error Login error
+ * @var string login_username Login username
+ * @var array tpl_ary Template variables
+ * @since 3.2.4-RC1
+ */
+ $vars = array('data', 'auth_provider', 'login_link_error', 'login_error', 'login_username', 'tpl_ary');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_login_link_template_after', compact($vars)));
+
+ $template->assign_vars($tpl_ary);
$this->tpl_name = 'ucp_login_link';
$this->page_title = 'UCP_LOGIN_LINK';
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index 77ac1dfb54..36f45f3f46 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -28,9 +28,9 @@ class ucp_main
var $p_master;
var $u_action;
- function ucp_main(&$p_master)
+ function __construct($p_master)
{
- $this->p_master = &$p_master;
+ $this->p_master = $p_master;
}
function main($id, $mode)
@@ -77,6 +77,22 @@ class ucp_main
// If the user can't see any forums, he can't read any posts because fid of 0 is invalid
if (!empty($forum_ary))
{
+ /**
+ * Modify sql variables before query is processed
+ *
+ * @event core.ucp_main_front_modify_sql
+ * @var string sql_select SQL select
+ * @var string sql_from SQL from
+ * @var array forum_ary Forum array
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'sql_select',
+ 'sql_from',
+ 'forum_ary',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.ucp_main_front_modify_sql', compact($vars)));
+
$sql = "SELECT t.* $sql_select
FROM $sql_from
WHERE t.topic_type = " . POST_GLOBAL . '
@@ -144,7 +160,7 @@ class ucp_main
$folder_img .= '_mine';
}
- $template->assign_block_vars('topicrow', array(
+ $topicrow = array(
'FORUM_ID' => $forum_id,
'TOPIC_ID' => $topic_id,
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
@@ -171,8 +187,30 @@ class ucp_main
'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',
- 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id"))
+ 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id"),
+ );
+
+ /**
+ * Add template variables to a front topics row.
+ *
+ * @event core.ucp_main_front_modify_template_vars
+ * @var array topicrow Array containing the template variables for the row
+ * @var array row Array containing the subscribed forum row data
+ * @var int forum_id Forum ID
+ * @var string folder_img Folder image
+ * @var string folder_alt Alt text for the folder image
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'topicrow',
+ 'row',
+ 'forum_id',
+ 'folder_img',
+ 'folder_alt',
);
+ extract($phpbb_dispatcher->trigger_event('core.ucp_main_front_modify_template_vars', compact($vars)));
+
+ $template->assign_block_vars('topicrow', $topicrow);
}
if ($config['load_user_activity'])
@@ -207,7 +245,10 @@ class ucp_main
case 'subscribed':
- include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ if (!function_exists('topic_status'))
+ {
+ include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ }
$user->add_lang('viewforum');
@@ -230,10 +271,10 @@ class ucp_main
$forums = array_keys($request->variable('f', array(0 => 0)));
$topics = array_keys($request->variable('t', array(0 => 0)));
- if (sizeof($forums) || sizeof($topics))
+ if (count($forums) || count($topics))
{
$l_unwatch = '';
- if (sizeof($forums))
+ if (count($forums))
{
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forums) . '
@@ -243,7 +284,7 @@ class ucp_main
$l_unwatch .= '_FORUMS';
}
- if (sizeof($topics))
+ if (count($topics))
{
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topics) . '
@@ -443,7 +484,10 @@ class ucp_main
break;
}
- include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ if (!function_exists('topic_status'))
+ {
+ include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ }
$user->add_lang('viewforum');
@@ -453,7 +497,7 @@ class ucp_main
$topics = (isset($_POST['t'])) ? array_keys($request->variable('t', array(0 => 0))) : array();
$url = $this->u_action;
- if (!sizeof($topics))
+ if (!count($topics))
{
trigger_error('NO_BOOKMARKS_SELECTED');
}
@@ -502,13 +546,16 @@ class ucp_main
$draft_subject = $draft_message = '';
add_form_key('ucp_draft');
+ include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
+ $message_parser = new parse_message();
+
if ($delete)
{
if (check_form_key('ucp_draft'))
{
$drafts = array_keys($request->variable('d', array(0 => 0)));
- if (sizeof($drafts))
+ if (count($drafts))
{
$sql = 'DELETE FROM ' . DRAFTS_TABLE . '
WHERE ' . $db->sql_in_set('draft_id', $drafts) . '
@@ -535,9 +582,19 @@ class ucp_main
{
if ($draft_message && $draft_subject)
{
+ // $auth->acl_gets can't be used here because it will check for global forum permissions in this case
+ // In general we don't need too harsh checking here for permissions, as this will be handled later when submitting
+ $bbcode_status = $auth->acl_get('u_pm_bbcode') || $auth->acl_getf_global('f_bbcode');
+ $smilies_status = $auth->acl_get('u_pm_smilies') || $auth->acl_getf_global('f_smilies');
+ $img_status = $auth->acl_get('u_pm_img') || $auth->acl_getf_global('f_img');
+ $flash_status = $auth->acl_get('u_pm_flash') || $auth->acl_getf_global('f_flash');
+
+ $message_parser->message = $draft_message;
+ $message_parser->parse($bbcode_status, $config['allow_post_links'], $smilies_status, $img_status, $flash_status, true, $config['allow_post_links']);
+
$draft_row = array(
'draft_subject' => $draft_subject,
- 'draft_message' => $draft_message
+ 'draft_message' => $message_parser->message,
);
$sql = 'UPDATE ' . DRAFTS_TABLE . '
@@ -594,7 +651,7 @@ class ucp_main
}
$db->sql_freeresult($result);
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$sql = 'SELECT topic_id, forum_id, topic_title
FROM ' . TOPICS_TABLE . '
@@ -639,9 +696,16 @@ class ucp_main
$insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&amp;mode=compose&amp;d=" . $draft['draft_id']);
}
+ if (!$submit)
+ {
+ $message_parser->message = $draft['draft_message'];
+ $message_parser->decode_message();
+ $draft_message = $message_parser->message;
+ }
+
$template_row = array(
'DATE' => $user->format_date($draft['save_time']),
- 'DRAFT_MESSAGE' => ($submit) ? $draft_message : $draft['draft_message'],
+ 'DRAFT_MESSAGE' => $draft_message,
'DRAFT_SUBJECT' => ($submit) ? $draft_subject : $draft['draft_subject'],
'TITLE' => $title,
diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php
index 029588bb23..a6d925f95e 100644
--- a/phpBB/includes/ucp/ucp_notifications.php
+++ b/phpBB/includes/ucp/ucp_notifications.php
@@ -205,7 +205,7 @@ class ucp_notifications
}
$template->assign_vars(array(
- strtoupper($block) . '_COLS' => sizeof($notification_methods) + 1,
+ strtoupper($block) . '_COLS' => count($notification_methods) + 1,
));
}
diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php
index d145d66f59..4d02620e89 100644
--- a/phpBB/includes/ucp/ucp_pm.php
+++ b/phpBB/includes/ucp/ucp_pm.php
@@ -82,7 +82,10 @@ class ucp_pm
$mode = 'view';
}
- include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
+ if (!function_exists('get_folder'))
+ {
+ include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
+ }
switch ($mode)
{
@@ -104,7 +107,10 @@ class ucp_pm
break;
}
- include($phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx);
+ if (!function_exists('compose_pm'))
+ {
+ include($phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx);
+ }
compose_pm($id, $mode, $action, $user_folders);
$tpl_file = 'posting_body';
@@ -114,7 +120,10 @@ class ucp_pm
set_user_message_limit();
get_folder($user->data['user_id']);
- include($phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx);
+ if (!function_exists('message_options'))
+ {
+ include($phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx);
+ }
message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions);
$tpl_file = 'ucp_pm_options';
@@ -125,8 +134,10 @@ class ucp_pm
get_folder($user->data['user_id']);
$this->p_name = 'pm';
- // Call another module... please do not try this at home... Hoochie Coochie Man
- include($phpbb_root_path . 'includes/ucp/ucp_main.' . $phpEx);
+ if (!class_exists('ucp_main'))
+ {
+ include($phpbb_root_path . 'includes/ucp/ucp_main.' . $phpEx);
+ }
$module = new ucp_main($this);
$module->u_action = $this->u_action;
@@ -170,6 +181,12 @@ class ucp_pm
trigger_error('NO_AUTH_READ_MESSAGE');
}
+ if ($view == 'print' && (!$config['print_pm'] || !$auth->acl_get('u_pm_printpm')))
+ {
+ send_status_line(403, 'Forbidden');
+ trigger_error('NO_AUTH_PRINT_MESSAGE');
+ }
+
// Do not allow hold messages to be seen
if ($folder_id == PRIVMSGS_HOLD_BOX)
{
@@ -369,7 +386,10 @@ class ucp_pm
if ($action == 'view_folder')
{
- include($phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.' . $phpEx);
+ if (!function_exists('view_folder'))
+ {
+ include($phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.' . $phpEx);
+ }
view_folder($id, $mode, $folder_id, $folder);
$tpl_file = 'ucp_pm_viewfolder';
@@ -387,7 +407,10 @@ class ucp_pm
trigger_error('NO_MESSAGE');
}
- include($phpbb_root_path . 'includes/ucp/ucp_pm_viewmessage.' . $phpEx);
+ if (!function_exists('view_message'))
+ {
+ include($phpbb_root_path . 'includes/ucp/ucp_pm_viewmessage.' . $phpEx);
+ }
view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row);
$tpl_file = ($view == 'print') ? 'ucp_pm_viewmessage_print' : 'ucp_pm_viewmessage';
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 86cdb090c8..cb45112b01 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -33,9 +33,20 @@ function compose_pm($id, $mode, $action, $user_folders = array())
// Needed for handle_message_list_actions()
global $refresh, $submit, $preview;
- include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
- include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
- include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
+ if (!function_exists('generate_smilies'))
+ {
+ include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
+ }
+
+ if (!function_exists('display_custom_bbcodes'))
+ {
+ include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ }
+
+ if (!class_exists('parse_message'))
+ {
+ include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
+ }
if (!$action)
{
@@ -48,7 +59,6 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$to_group_id = $request->variable('g', 0);
$msg_id = $request->variable('p', 0);
$draft_id = $request->variable('d', 0);
- $lastclick = $request->variable('lastclick', 0);
// Reply to all triggered (quote/reply)
$reply_to_all = $request->variable('reply_to_all', 0);
@@ -80,7 +90,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$group_helper = $phpbb_container->get('group_helper');
// Was cancel pressed? If so then redirect to the appropriate page
- if ($cancel || ($current_time - $lastclick < 2 && $submit))
+ if ($cancel)
{
if ($msg_id)
{
@@ -125,7 +135,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
// Add groups to PM box
if ($config['allow_mass_pm'] && $auth->acl_get('u_masspm_group'))
{
- $sql = 'SELECT g.group_id, g.group_name, g.group_type
+ $sql = 'SELECT g.group_id, g.group_name, g.group_type, g.group_colour
FROM ' . GROUPS_TABLE . ' g';
if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
@@ -148,7 +158,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$group_options = '';
while ($row = $db->sql_fetchrow($result))
{
- $group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . $group_helper->get_name($row['group_name']) . '</option>';
+ $group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . ($row['group_colour'] ? ' style="color: #' . $row['group_colour'] . '"' : '') . '>' . $group_helper->get_name($row['group_name']) . '</option>';
}
$db->sql_freeresult($result);
}
@@ -406,7 +416,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$quote_username = (isset($post['quote_username'])) ? $post['quote_username'] : '';
$icon_id = (isset($post['icon_id'])) ? $post['icon_id'] : 0;
- if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !sizeof($address_list) && !$refresh && !$submit && !$preview)
+ if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !count($address_list) && !$refresh && !$submit && !$preview)
{
// Add the original author as the recipient if quoting a post or only replying and not having checked "reply to all"
if ($action == 'quotepost' || !$reply_to_all)
@@ -428,7 +438,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
}
}
}
- else if ($action == 'edit' && !sizeof($address_list) && !$refresh && !$submit && !$preview)
+ else if ($action == 'edit' && !count($address_list) && !$refresh && !$submit && !$preview)
{
// Rebuild TO and BCC Header
$address_list = rebuild_header(array('to' => $post['to_address'], 'bcc' => $post['bcc_address']));
@@ -561,7 +571,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
unset($list[$user->data['user_id']]);
}
- $max_recipients = ($max_recipients < sizeof($list)) ? sizeof($list) : $max_recipients;
+ $max_recipients = ($max_recipients < count($list)) ? count($list) : $max_recipients;
unset($list);
}
@@ -584,7 +594,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
}
// Check for too many recipients
- if (!empty($address_list['u']) && $max_recipients && sizeof($address_list['u']) > $max_recipients)
+ if (!empty($address_list['u']) && $max_recipients && count($address_list['u']) > $max_recipients)
{
$address_list = get_recipients($address_list, $max_recipients);
$error[] = $user->lang('TOO_MANY_RECIPIENTS', $max_recipients);
@@ -659,13 +669,16 @@ function compose_pm($id, $mode, $action, $user_folders = array())
{
if (confirm_box(true))
{
+ $message_parser->message = $message;
+ $message_parser->parse($bbcode_status, $url_status, $smilies_status, $img_status, $flash_status, true, $url_status);
+
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'user_id' => $user->data['user_id'],
'topic_id' => 0,
'forum_id' => 0,
'save_time' => $current_time,
'draft_subject' => $subject,
- 'draft_message' => $message
+ 'draft_message' => $message_parser->message,
)
);
$db->sql_query($sql);
@@ -788,7 +801,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
// Parse Attachments - before checksum is calculated
$message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true);
- if (sizeof($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc))
+ if (count($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc))
{
$error[] = implode('<br />', $message_parser->warn_msg);
$message_parser->warn_msg = array();
@@ -798,7 +811,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$message_parser->parse($enable_bbcode, ($config['allow_post_links']) ? $enable_urls : false, $enable_smilies, $img_status, $flash_status, true, $config['allow_post_links']);
// On a refresh we do not care about message parsing errors
- if (sizeof($message_parser->warn_msg) && !$refresh)
+ if (count($message_parser->warn_msg) && !$refresh)
{
$error[] = implode('<br />', $message_parser->warn_msg);
}
@@ -825,14 +838,14 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$error[] = $user->lang['EMPTY_MESSAGE_SUBJECT'];
}
- if (!sizeof($address_list))
+ if (!count($address_list))
{
$error[] = $user->lang['NO_RECIPIENT'];
}
}
// Store message, sync counters
- if (!sizeof($error) && $submit)
+ if (!count($error) && $submit)
{
$pm_data = array(
'msg_id' => (int) $msg_id,
@@ -889,7 +902,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
}
// Preview
- if (!sizeof($error) && $preview)
+ if (!count($error) && $preview)
{
$preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
@@ -909,7 +922,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
}
// Attachment Preview
- if (sizeof($message_parser->attachment_data))
+ if (count($message_parser->attachment_data))
{
$template->assign_var('S_HAS_ATTACHMENTS', true);
@@ -929,7 +942,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$preview_subject = censor_text($subject);
- if (!sizeof($error))
+ if (!count($error))
{
$template->assign_vars(array(
'PREVIEW_SUBJECT' => $preview_subject,
@@ -943,7 +956,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
}
// Decode text for message display
- $bbcode_uid = (($action == 'quote' || $action == 'forward') && !$preview && !$refresh && (!sizeof($error) || (sizeof($error) && !$submit))) ? $bbcode_uid : $message_parser->bbcode_uid;
+ $bbcode_uid = (($action == 'quote' || $action == 'forward') && !$preview && !$refresh && (!count($error) || (count($error) && !$submit))) ? $bbcode_uid : $message_parser->bbcode_uid;
$message_parser->decode_message($bbcode_uid);
@@ -954,7 +967,16 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$post_id = $request->variable('p', 0);
if ($config['allow_post_links'])
{
- $message_link = "[url=" . generate_board_url() . "/viewtopic.$phpEx?p={$post_id}#p{$post_id}]{$user->lang['SUBJECT']}{$user->lang['COLON']} {$message_subject}[/url]\n\n";
+ $message_link = generate_board_url() . "/viewtopic.$phpEx?p={$post_id}#p{$post_id}";
+ $message_link_subject = "{$user->lang['SUBJECT']}{$user->lang['COLON']} {$message_subject}";
+ if ($bbcode_status)
+ {
+ $message_link = "[url=" . $message_link . "]" . $message_link_subject . "[/url]\n\n";
+ }
+ else
+ {
+ $message_link = $message_link . " - " . $message_link_subject . "\n\n";
+ }
}
else
{
@@ -974,16 +996,27 @@ function compose_pm($id, $mode, $action, $user_folders = array())
{
$quote_attributes['post_id'] = $post['msg_id'];
}
- $quote_text = $phpbb_container->get('text_formatter.utils')->generate_quote(
- censor_text($message_parser->message),
- $quote_attributes
- );
- $message_parser->message = $message_link . $quote_text . "\n\n";
+
+ /** @var \phpbb\language\language $language */
+ $language = $phpbb_container->get('language');
+ /** @var \phpbb\textformatter\utils_interface $text_formatter_utils */
+ $text_formatter_utils = $phpbb_container->get('text_formatter.utils');
+ phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link);
}
if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh)
{
$message_subject = ((!preg_match('/^Re:/', $message_subject)) ? 'Re: ' : '') . censor_text($message_subject);
+
+ /**
+ * This event allows you to modify the PM subject of the PM being quoted
+ *
+ * @event core.pm_modify_message_subject
+ * @var string message_subject String with the PM subject already censored.
+ * @since 3.2.8-RC1
+ */
+ $vars = array('message_subject');
+ extract($phpbb_dispatcher->trigger_event('core.pm_modify_message_subject', compact($vars)));
}
if ($action == 'forward' && !$preview && !$refresh && !$submit)
@@ -1035,7 +1068,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
// Build address list for display
// array('u' => array($author_id => 'to'));
- if (sizeof($address_list))
+ if (count($address_list))
{
// Get Usernames and Group Names
$result = array();
@@ -1174,8 +1207,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
break;
}
- $s_hidden_fields = '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
- $s_hidden_fields .= (isset($check_value)) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : '';
+ $s_hidden_fields = (isset($check_value)) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : '';
$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . ((isset($_REQUEST['draft_loaded'])) ? $request->variable('draft_loaded', 0) : $draft_id) . '" />' : '';
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_pm_attach'] || !$auth->acl_get('u_pm_attach')) ? '' : ' enctype="multipart/form-data"';
@@ -1184,7 +1216,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$controller_helper = $phpbb_container->get('controller.helper');
// Start assigning vars for main posting page ...
- $template->assign_vars(array(
+ $template_ary = array(
'L_POST_A' => $page_title,
'L_ICON' => $user->lang['PM_ICON'],
'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']),
@@ -1198,7 +1230,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
'URL_STATUS' => ($url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
'MAX_FONT_SIZE' => (int) $config['max_post_font_size'],
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']),
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'MAX_RECIPIENTS' => ($config['allow_mass_pm'] && ($auth->acl_get('u_masspm') || $auth->acl_get('u_masspm_group'))) ? $max_recipients : 0,
'S_COMPOSE_PM' => true,
@@ -1229,7 +1261,19 @@ function compose_pm($id, $mode, $action, $user_folders = array())
'S_CLOSE_PROGRESS_WINDOW' => isset($_POST['add_file']),
'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&amp;mode=popup'),
'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&amp;mode=popup')),
- ));
+ );
+
+ /**
+ * Modify the default template vars
+ *
+ * @event core.ucp_pm_compose_template
+ * @var array template_ary Template variables
+ * @since 3.2.6-RC1
+ */
+ $vars = array('template_ary');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_template', compact($vars)));
+
+ $template->assign_vars($template_ary);
// Build custom bbcodes array
display_custom_bbcodes();
@@ -1262,7 +1306,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove_g, $add_to, $add_bcc)
{
global $auth, $db, $user;
- global $request;
+ global $request, $phpbb_dispatcher;
// Delete User [TO/BCC]
if ($remove_u && $request->variable('remove_u', array(0 => '')))
@@ -1300,7 +1344,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
}
// If add to or add bcc not pressed, users could still have usernames listed they want to add...
- if (!$add_to && !$add_bcc && (sizeof($group_list) || sizeof($usernames)))
+ if (!$add_to && !$add_bcc && (count($group_list) || count($usernames)))
{
$add_to = true;
@@ -1321,7 +1365,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
{
$type = ($add_to) ? 'to' : 'bcc';
- if (sizeof($group_list))
+ if (count($group_list))
{
foreach ($group_list as $group_id)
{
@@ -1333,13 +1377,13 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
$user_id_ary = array();
// Reveal the correct user_ids
- if (sizeof($usernames))
+ if (count($usernames))
{
$user_id_ary = array();
user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER, USER_INACTIVE));
// If there are users not existing, we will at least print a notice...
- if (!sizeof($user_id_ary))
+ if (!count($user_id_ary))
{
$error[] = $user->lang['PM_NO_USERS'];
}
@@ -1408,7 +1452,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
$error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
}
- if (!sizeof(array_keys($address_list['u'])))
+ if (!count(array_keys($address_list['u'])))
{
return;
}
@@ -1439,6 +1483,21 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
$error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
}
}
+
+ /**
+ * Event for additional message list actions
+ *
+ * @event core.message_list_actions
+ * @var array address_list The assoc array with the recipient user/group ids
+ * @var array error The array containing error data
+ * @var bool remove_u The variable for removing a user
+ * @var bool remove_g The variable for removing a group
+ * @var bool add_to The variable for adding a user to the [TO] field
+ * @var bool add_bcc The variable for adding a user to the [BCC] field
+ * @since 3.2.4-RC1
+ */
+ $vars = array('address_list', 'error', 'remove_u', 'remove_g', 'add_to', 'add_bcc');
+ extract($phpbb_dispatcher->trigger_event('core.message_list_actions', compact($vars)));
}
/**
@@ -1466,7 +1525,7 @@ function num_recipients($address_list)
foreach ($address_list as $field => $adr_ary)
{
- $num_recipients += sizeof($adr_ary);
+ $num_recipients += count($adr_ary);
}
return $num_recipients;
diff --git a/phpBB/includes/ucp/ucp_pm_options.php b/phpBB/includes/ucp/ucp_pm_options.php
index 2458c4118d..3861962516 100644
--- a/phpBB/includes/ucp/ucp_pm_options.php
+++ b/phpBB/includes/ucp/ucp_pm_options.php
@@ -521,7 +521,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$action_option = $request->variable('action_option', '');
$back = (isset($_REQUEST['back'])) ? $request->variable('back', array('' => 0)) : array();
- if (sizeof($back))
+ if (count($back))
{
if ($action_option)
{
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index b5bb406d7d..09e7bf4d7c 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -39,7 +39,7 @@ function view_folder($id, $mode, $folder_id, $folder)
// Grab icons
$icons = $cache->obtain_icons();
- $color_rows = array('marked', 'replied');
+ $color_rows = array('message_reported', 'marked', 'replied');
$_module = new p_master();
$_module->list_modules('ucp');
@@ -114,7 +114,7 @@ function view_folder($id, $mode, $folder_id, $folder)
);
// Okay, lets dump out the page ...
- if (sizeof($folder_info['pm_list']))
+ if (count($folder_info['pm_list']))
{
$address_list = array();
@@ -138,9 +138,9 @@ function view_folder($id, $mode, $folder_id, $folder)
$row_indicator = '';
foreach ($color_rows as $var)
{
- if (($var != 'friend' && $var != 'foe' && $row['pm_' . $var])
+ if (($var !== 'friend' && $var !== 'foe' && $row[($var === 'message_reported') ? $var : "pm_{$var}"])
||
- (($var == 'friend' || $var == 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']]))
+ (($var === 'friend' || $var === 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']]))
{
$row_indicator = $var;
break;
@@ -236,7 +236,7 @@ function view_folder($id, $mode, $folder_id, $folder)
$_types = array('u', 'g');
foreach ($_types as $ug_type)
{
- if (isset($address_temp[$message_id][$ug_type]) && sizeof($address_temp[$message_id][$ug_type]))
+ if (isset($address_temp[$message_id][$ug_type]) && count($address_temp[$message_id][$ug_type]))
{
if (!isset($address[$message_id][$ug_type]))
{
@@ -269,8 +269,8 @@ function view_folder($id, $mode, $folder_id, $folder)
// There is the chance that all recipients of the message got deleted. To avoid creating
// exports without recipients, we add a bogus "undisclosed recipient".
- if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) &&
- !(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u'])))
+ if (!(isset($address[$message_id]['g']) && count($address[$message_id]['g'])) &&
+ !(isset($address[$message_id]['u']) && count($address[$message_id]['u'])))
{
$address[$message_id]['u'] = array();
$address[$message_id]['u']['to'] = array();
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index 48d14a133c..7c0091ef47 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -113,7 +113,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
$db->sql_freeresult($result);
// No attachments exist, but message table thinks they do so go ahead and reset attach flags
- if (!sizeof($attachments))
+ if (!count($attachments))
{
$sql = 'UPDATE ' . PRIVMSGS_TABLE . "
SET message_attachment = 0
@@ -134,7 +134,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
parse_attachments(false, $message, $attachments, $update_count);
// Update the attachment download counts
- if (sizeof($update_count))
+ if (count($update_count))
{
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
SET download_count = download_count + 1
@@ -240,7 +240,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
'U_PM_ACTION' => $url . '&amp;mode=compose&amp;f=' . $folder_id . '&amp;p=' . $message_row['msg_id'],
- 'S_HAS_ATTACHMENTS' => (sizeof($attachments)) ? true : false,
+ 'S_HAS_ATTACHMENTS' => (count($attachments)) ? true : false,
'S_DISPLAY_NOTICE' => $display_notice && $message_row['message_attachment'],
'S_AUTHOR_DELETED' => ($author_id == ANONYMOUS) ? true : false,
'S_SPECIAL_FOLDER' => in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)),
@@ -267,6 +267,8 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
* @var array user_info User data of the sender
* @since 3.1.0-a1
* @changed 3.1.6-RC1 Added user_info into event
+ * @changed 3.2.2-RC1 Deprecated
+ * @deprecated 4.0.0 Event name is misspelled and is replaced with new event with correct name
*/
$vars = array(
'id',
@@ -281,6 +283,37 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
);
extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_messsage', compact($vars)));
+ /**
+ * Modify pm and sender data before it is assigned to the template
+ *
+ * @event core.ucp_pm_view_message
+ * @var mixed id Active module category (can be int or string)
+ * @var string mode Active module
+ * @var int folder_id ID of the folder the message is in
+ * @var int msg_id ID of the private message
+ * @var array folder Array with data of user's message folders
+ * @var array message_row Array with message data
+ * @var array cp_row Array with senders custom profile field data
+ * @var array msg_data Template array with message data
+ * @var array user_info User data of the sender
+ * @var array attachments Attachments data
+ * @since 3.2.2-RC1
+ * @changed 3.2.5-RC1 Added attachments
+ */
+ $vars = array(
+ 'id',
+ 'mode',
+ 'folder_id',
+ 'msg_id',
+ 'folder',
+ 'message_row',
+ 'cp_row',
+ 'msg_data',
+ 'user_info',
+ 'attachments',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_message', compact($vars)));
+
$template->assign_vars($msg_data);
$contact_fields = array(
@@ -330,7 +363,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
}
// Display not already displayed Attachments for this post, we already parsed them. ;)
- if (isset($attachments) && sizeof($attachments))
+ if (isset($attachments) && count($attachments))
{
foreach ($attachments as $attachment)
{
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index c2aa910ed0..7785aeb07b 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -96,7 +96,7 @@ class ucp_prefs
$error[] = 'FORM_INVALID';
}
- if (!sizeof($error))
+ if (!count($error))
{
$sql_ary = array(
'user_allow_pm' => $data['allowpm'],
@@ -188,7 +188,7 @@ class ucp_prefs
$db->sql_freeresult($result);
$template->assign_vars(array(
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'S_NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false,
'S_NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false,
@@ -277,7 +277,7 @@ class ucp_prefs
$error[] = 'FORM_INVALID';
}
- if (!sizeof($error))
+ if (!count($error))
{
$user->optionset('viewimg', $data['images']);
$user->optionset('viewflash', $data['flash']);
@@ -412,7 +412,7 @@ class ucp_prefs
extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_after', compact($vars)));
$template->assign_vars(array(
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'S_IMAGES' => $data['images'],
'S_FLASH' => $data['flash'],
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index b7f8501fe4..36ab3d0463 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -98,7 +98,7 @@ class ucp_profile
$passwords_manager = $phpbb_container->get('passwords.manager');
// Only check the new password against the previous password if there have been no errors
- if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password']))
+ if (!count($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password']))
{
$error[] = 'SAME_PASSWORD_ERROR';
}
@@ -125,7 +125,7 @@ class ucp_profile
$vars = array('data', 'submit', 'error');
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_validate', compact($vars)));
- if (!sizeof($error))
+ if (!count($error))
{
$sql_ary = array(
'username' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'],
@@ -133,7 +133,6 @@ class ucp_profile
'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'],
'user_email_hash' => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'],
'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'],
- 'user_passchg' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0,
);
if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
@@ -147,6 +146,8 @@ class ucp_profile
if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password']))
{
+ $sql_ary['user_passchg'] = time();
+
$user->reset_login_keys();
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array(
'reportee_id' => $user->data['user_id'],
@@ -159,7 +160,7 @@ class ucp_profile
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array(
'reportee_id' => $user->data['user_id'],
$user->data['username'],
- $data['user_email'],
+ $user->data['user_email'],
$data['email']
));
}
@@ -220,7 +221,7 @@ class ucp_profile
$vars = array('data', 'sql_ary');
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_sql_ary', compact($vars)));
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
@@ -257,7 +258,7 @@ class ucp_profile
}
$template->assign_vars(array(
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'USERNAME' => $data['username'],
'EMAIL' => $data['email'],
@@ -343,7 +344,7 @@ class ucp_profile
// validate custom profile fields
$cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
- if (sizeof($cp_error))
+ if (count($cp_error))
{
$error = array_merge($error, $cp_error);
}
@@ -365,7 +366,7 @@ class ucp_profile
$vars = array('data', 'submit', 'error');
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_validate_profile_info', compact($vars)));
- if (!sizeof($error))
+ if (!count($error))
{
$data['notify'] = $user->data['user_notify_type'];
@@ -449,7 +450,7 @@ class ucp_profile
}
$template->assign_vars(array(
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'S_JABBER_ENABLED' => $config['jab_enable'],
'JABBER' => $data['jabber'],
));
@@ -469,8 +470,15 @@ class ucp_profile
trigger_error('NO_AUTH_SIGNATURE');
}
- include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
- include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ if (!function_exists('generate_smilies'))
+ {
+ include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
+ }
+
+ if (!function_exists('display_custom_bbcodes'))
+ {
+ include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ }
$preview = $request->is_set_post('preview');
@@ -537,7 +545,7 @@ class ucp_profile
'sig'
);
- if (sizeof($warn_msg))
+ if (count($warn_msg))
{
$error += $warn_msg;
}
@@ -549,7 +557,7 @@ class ucp_profile
}
else
{
- if (!sizeof($error))
+ if (!count($error))
{
$user->optionset('sig_bbcode', $enable_bbcode);
$user->optionset('sig_smilies', $enable_smilies);
@@ -594,7 +602,7 @@ class ucp_profile
$controller_helper = $phpbb_container->get('controller.helper');
$template->assign_vars(array(
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'SIGNATURE' => $decoded_message['text'],
'SIGNATURE_PREVIEW' => $signature_preview,
@@ -753,7 +761,7 @@ class ucp_profile
$avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true);
$template->assign_vars(array(
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'AVATAR' => $avatar,
'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"',
@@ -778,7 +786,7 @@ class ucp_profile
$error[] = 'FORM_INVALID';
}
- if (!sizeof($error))
+ if (!count($error))
{
if (!empty($keys))
{
@@ -825,7 +833,7 @@ class ucp_profile
}
$template->assign_vars(array(
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)],
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index 594100ac65..0e673cb692 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -166,8 +166,8 @@ class ucp_register
->format($user->lang['DATE_FORMAT'], true);
unset($now);
- $template->assign_vars(array(
- 'S_LANG_OPTIONS' => (sizeof($lang_row) > 1) ? language_select($user_lang) : '',
+ $template_vars = array(
+ 'S_LANG_OPTIONS' => (count($lang_row) > 1) ? language_select($user_lang) : '',
'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday),
'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday),
@@ -180,12 +180,12 @@ class ucp_register
'COOKIE_NAME' => $config['cookie_name'],
'COOKIE_PATH' => $config['cookie_path'],
- ));
+ );
}
else
{
- $template->assign_vars(array(
- 'S_LANG_OPTIONS' => (sizeof($lang_row) > 1) ? language_select($user_lang) : '',
+ $template_vars = array(
+ 'S_LANG_OPTIONS' => (count($lang_row) > 1) ? language_select($user_lang) : '',
'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()),
'S_SHOW_COPPA' => false,
@@ -195,11 +195,32 @@ class ucp_register
'COOKIE_NAME' => $config['cookie_name'],
'COOKIE_PATH' => $config['cookie_path'],
- )
);
}
+
+ $tpl_name = 'ucp_agreement';
+
+ /**
+ * Allows to modify the agreements.
+ *
+ * @event core.ucp_register_agreement_modify_template_data
+ * @var string tpl_name Template file
+ * @var array template_vars Array with data about to be assigned to the template
+ * @var array s_hidden_fields Array with hidden form elements
+ * @var array lang_row Array with available languages, read only
+ * @since 3.2.2-RC1
+ */
+ $vars = array('tpl_name', 'template_vars', 's_hidden_fields', 'lang_row');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_register_agreement_modify_template_data', compact($vars)));
+
unset($lang_row);
+ $template_vars = array_merge($template_vars, array(
+ 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
+ ));
+
+ $template->assign_vars($template_vars);
+
/**
* Allows to modify the agreements.
*
@@ -207,10 +228,11 @@ class ucp_register
*
* @event core.ucp_register_agreement
* @since 3.1.6-RC1
+ * @deprecated 3.2.2-RC1 Replaced by core.ucp_register_agreement_modify_template_data and to be removed in 3.3.0-RC1
*/
$phpbb_dispatcher->dispatch('core.ucp_register_agreement');
- $this->tpl_name = 'ucp_agreement';
+ $this->tpl_name = $tpl_name;
return;
}
@@ -297,7 +319,7 @@ class ucp_register
// validate custom profile fields
$cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error);
- if (!sizeof($error))
+ if (!count($error))
{
if ($data['new_password'] != $data['password_confirm'])
{
@@ -318,7 +340,7 @@ class ucp_register
$vars = array('submit', 'data', 'cp_data', 'error');
extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_after', compact($vars)));
- if (!sizeof($error))
+ if (!count($error))
{
$server_url = generate_board_url();
@@ -459,6 +481,32 @@ class ucp_register
);
}
+ /**
+ * Modify messenger data before welcome mail is sent
+ *
+ * @event core.ucp_register_welcome_email_before
+ * @var array user_row Array with user registration data
+ * @var array cp_data Array with custom profile fields data
+ * @var array data Array with current ucp registration data
+ * @var string message Message to be displayed to the user after registration
+ * @var string server_url Server URL
+ * @var int user_id New user ID
+ * @var string user_actkey User activation key
+ * @var messenger messenger phpBB Messenger
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'user_row',
+ 'cp_data',
+ 'data',
+ 'message',
+ 'server_url',
+ 'user_id',
+ 'user_actkey',
+ 'messenger',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars)));
+
$messenger->send(NOTIFY_EMAIL);
}
@@ -486,6 +534,30 @@ class ucp_register
}
}
+ /**
+ * Perform additional actions after user registration
+ *
+ * @event core.ucp_register_register_after
+ * @var array user_row Array with user registration data
+ * @var array cp_data Array with custom profile fields data
+ * @var array data Array with current ucp registration data
+ * @var string message Message to be displayed to the user after registration
+ * @var string server_url Server URL
+ * @var int user_id New user ID
+ * @var string user_actkey User activation key
+ * @since 3.2.4-RC1
+ */
+ $vars = array(
+ 'user_row',
+ 'cp_data',
+ 'data',
+ 'message',
+ 'server_url',
+ 'user_id',
+ 'user_actkey',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.ucp_register_register_after', compact($vars)));
+
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
trigger_error($message);
}
@@ -505,7 +577,6 @@ class ucp_register
{
$s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields());
}
- $s_hidden_fields = build_hidden_fields($s_hidden_fields);
// Visual Confirmation - Show images
if ($config['enable_confirm'])
@@ -531,8 +602,7 @@ class ucp_register
// Assign template vars for timezone select
phpbb_timezone_select($template, $user, $data['tz'], true);
- $template->assign_vars(array(
- 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+ $template_vars = array(
'USERNAME' => $data['username'],
'PASSWORD' => $data['new_password'],
'PASSWORD_CONFIRM' => $data['password_confirm'],
@@ -547,13 +617,41 @@ class ucp_register
'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false,
'S_REGISTRATION' => true,
'S_COPPA' => $coppa,
- 'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
'COOKIE_NAME' => $config['cookie_name'],
'COOKIE_PATH' => $config['cookie_path'],
+ );
+
+ $tpl_name = 'ucp_register';
+
+ /**
+ * Modify template data on the registration page
+ *
+ * @event core.ucp_register_modify_template_data
+ * @var array template_vars Array with template data
+ * @var array data Array with user data, read only
+ * @var array error Array with errors
+ * @var array s_hidden_fields Array with hidden field elements
+ * @var string tpl_name Template name
+ * @since 3.2.2-RC1
+ */
+ $vars = array(
+ 'template_vars',
+ 'data',
+ 'error',
+ 's_hidden_fields',
+ 'tpl_name',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.ucp_register_modify_template_data', compact($vars)));
+
+ $template_vars = array_merge($template_vars, array(
+ 'ERROR' => (count($error)) ? implode('<br />', $error) : '',
+ 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
));
+ $template->assign_vars($template_vars);
+
//
$user->profile_fields = array();
@@ -561,8 +659,7 @@ class ucp_register
$cp->generate_profile_fields('register', $user->get_iso_lang_id());
//
- $this->tpl_name = 'ucp_register';
- $this->page_title = 'UCP_REGISTRATION';
+ $this->tpl_name = $tpl_name;
}
/**
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index f46df99edb..e50428bfea 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -50,11 +50,16 @@ class ucp_remind
trigger_error('FORM_INVALID');
}
+ if (empty($email))
+ {
+ trigger_error('NO_EMAIL_USER');
+ }
+
$sql_array = array(
'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason',
'FROM' => array(USERS_TABLE => 'u'),
- 'WHERE' => "user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'
- AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"
+ 'WHERE' => "user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'" .
+ (!empty($username) ? " AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : ''),
);
/**
@@ -74,82 +79,87 @@ class ucp_remind
extract($phpbb_dispatcher->trigger_event('core.ucp_remind_modify_select_sql', compact($vars)));
$sql = $db->sql_build_query('SELECT', $sql_array);
- $result = $db->sql_query($sql);
- $user_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = $db->sql_query_limit($sql, 2); // don't waste resources on more rows than we need
+ $rowset = $db->sql_fetchrowset($result);
- if (!$user_row)
+ if (count($rowset) > 1)
{
- trigger_error('NO_EMAIL_USER');
- }
+ $db->sql_freeresult($result);
- if ($user_row['user_type'] == USER_IGNORE)
- {
- trigger_error('NO_USER');
+ $template->assign_vars(array(
+ 'USERNAME_REQUIRED' => true,
+ 'EMAIL' => $email,
+ ));
}
-
- if ($user_row['user_type'] == USER_INACTIVE)
+ else
{
- if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL)
+ $message = $user->lang['PASSWORD_UPDATED_IF_EXISTED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
+
+ if (empty($rowset))
{
- trigger_error('ACCOUNT_DEACTIVATED');
+ trigger_error($message);
}
- else
+
+ $user_row = $rowset[0];
+ $db->sql_freeresult($result);
+
+ if (!$user_row)
{
- trigger_error('ACCOUNT_NOT_ACTIVATED');
+ trigger_error($message);
}
- }
- // Check users permissions
- $auth2 = new \phpbb\auth\auth();
- $auth2->acl($user_row);
+ if ($user_row['user_type'] == USER_IGNORE || $user_row['user_type'] == USER_INACTIVE)
+ {
+ trigger_error($message);
+ }
- if (!$auth2->acl_get('u_chgpasswd'))
- {
- send_status_line(403, 'Forbidden');
- trigger_error('NO_AUTH_PASSWORD_REMINDER');
- }
+ // Check users permissions
+ $auth2 = new \phpbb\auth\auth();
+ $auth2->acl($user_row);
- $server_url = generate_board_url();
+ if (!$auth2->acl_get('u_chgpasswd'))
+ {
+ trigger_error($message);
+ }
- // Make password at least 8 characters long, make it longer if admin wants to.
- // gen_rand_string() however has a limit of 12 or 13.
- $user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
+ $server_url = generate_board_url();
- // For the activation key a random length between 6 and 10 will do.
- $user_actkey = gen_rand_string(mt_rand(6, 10));
+ // Make password at least 8 characters long, make it longer if admin wants to.
+ // gen_rand_string() however has a limit of 12 or 13.
+ $user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
- // Instantiate passwords manager
- /* @var $manager \phpbb\passwords\manager */
- $passwords_manager = $phpbb_container->get('passwords.manager');
+ // For the activation key a random length between 6 and 10 will do.
+ $user_actkey = gen_rand_string(mt_rand(6, 10));
- $sql = 'UPDATE ' . USERS_TABLE . "
- SET user_newpasswd = '" . $db->sql_escape($passwords_manager->hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'
- WHERE user_id = " . $user_row['user_id'];
- $db->sql_query($sql);
+ // Instantiate passwords manager
+ /* @var $manager \phpbb\passwords\manager */
+ $passwords_manager = $phpbb_container->get('passwords.manager');
- include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_newpasswd = '" . $db->sql_escape($passwords_manager->hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'
+ WHERE user_id = " . $user_row['user_id'];
+ $db->sql_query($sql);
- $messenger = new messenger(false);
+ include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
- $messenger->template('user_activate_passwd', $user_row['user_lang']);
+ $messenger = new messenger(false);
- $messenger->set_addresses($user_row);
+ $messenger->template('user_activate_passwd', $user_row['user_lang']);
- $messenger->anti_abuse_headers($config, $user);
+ $messenger->set_addresses($user_row);
- $messenger->assign_vars(array(
- 'USERNAME' => htmlspecialchars_decode($user_row['username']),
- 'PASSWORD' => htmlspecialchars_decode($user_password),
- 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
- );
+ $messenger->anti_abuse_headers($config, $user);
- $messenger->send($user_row['user_notify_type']);
+ $messenger->assign_vars(array(
+ 'USERNAME' => htmlspecialchars_decode($user_row['username']),
+ 'PASSWORD' => htmlspecialchars_decode($user_password),
+ 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
+ );
- meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
+ $messenger->send($user_row['user_notify_type']);
- $message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
- trigger_error($message);
+ trigger_error($message);
+ }
}
$template->assign_vars(array(
diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php
index fa6a03f87c..b4c561fc76 100644
--- a/phpBB/includes/ucp/ucp_zebra.php
+++ b/phpBB/includes/ucp/ucp_zebra.php
@@ -47,7 +47,7 @@ class ucp_zebra
$data[$var] = $request->variable($var, $default, true);
}
- if (!empty($data['add']) || sizeof($data['usernames']))
+ if (!empty($data['add']) || count($data['usernames']))
{
if (confirm_box(true))
{
@@ -105,35 +105,35 @@ class ucp_zebra
$db->sql_freeresult($result);
// remove friends from the username array
- $n = sizeof($data['add']);
+ $n = count($data['add']);
$data['add'] = array_diff($data['add'], $friends);
- if (sizeof($data['add']) < $n && $mode == 'foes')
+ if (count($data['add']) < $n && $mode == 'foes')
{
$error[] = $user->lang['NOT_ADDED_FOES_FRIENDS'];
}
// remove foes from the username array
- $n = sizeof($data['add']);
+ $n = count($data['add']);
$data['add'] = array_diff($data['add'], $foes);
- if (sizeof($data['add']) < $n && $mode == 'friends')
+ if (count($data['add']) < $n && $mode == 'friends')
{
$error[] = $user->lang['NOT_ADDED_FRIENDS_FOES'];
}
// remove the user himself from the username array
- $n = sizeof($data['add']);
+ $n = count($data['add']);
$data['add'] = array_diff($data['add'], array(utf8_clean_string($user->data['username'])));
- if (sizeof($data['add']) < $n)
+ if (count($data['add']) < $n)
{
$error[] = $user->lang['NOT_ADDED_' . $l_mode . '_SELF'];
}
unset($friends, $foes, $n);
- if (sizeof($data['add']))
+ if (count($data['add']))
{
$sql = 'SELECT user_id, user_type
FROM ' . USERS_TABLE . '
@@ -159,7 +159,7 @@ class ucp_zebra
}
$db->sql_freeresult($result);
- if (sizeof($user_id_ary))
+ if (count($user_id_ary))
{
// Remove users from foe list if they are admins or moderators
if ($mode == 'foes')
@@ -175,7 +175,7 @@ class ucp_zebra
$perms = array_unique($perms);
- if (sizeof($perms))
+ if (count($perms))
{
$error[] = $user->lang['NOT_ADDED_FOES_MOD_ADMIN'];
}
@@ -185,7 +185,7 @@ class ucp_zebra
unset($perms);
}
- if (sizeof($user_id_ary))
+ if (count($user_id_ary))
{
$sql_mode = ($mode == 'friends') ? 'friend' : 'foe';
@@ -218,7 +218,7 @@ class ucp_zebra
}
unset($user_id_ary);
}
- else if (!sizeof($error))
+ else if (!count($error))
{
$error[] = $user->lang['USER_NOT_FOUND_OR_INACTIVE'];
}
@@ -244,7 +244,7 @@ class ucp_zebra
else if ($updated)
{
meta_refresh(3, $this->u_action);
- $message = $user->lang[$l_mode . '_UPDATED'] . '<br />' . implode('<br />', $error) . ((sizeof($error)) ? '<br />' : '') . '<br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
+ $message = $user->lang[$l_mode . '_UPDATED'] . '<br />' . implode('<br />', $error) . ((count($error)) ? '<br />' : '') . '<br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message);
}
else
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php
index 01caf47349..89de454427 100644
--- a/phpBB/includes/utf/utf_tools.php
+++ b/phpBB/includes/utf/utf_tools.php
@@ -1390,7 +1390,7 @@ function utf8_wordwrap($string, $width = 75, $break = "\n", $cut = false)
{
$words = explode(' ', $line);
- for ($i = 0, $size = sizeof($words); $i < $size; $i++)
+ for ($i = 0, $size = count($words); $i < $size; $i++)
{
$word = $words[$i];