aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_attachments.php6
-rw-r--r--phpBB/includes/acp/acp_extensions.php3
-rw-r--r--phpBB/includes/acp/acp_main.php2
-rw-r--r--phpBB/includes/acp/auth.php10
-rw-r--r--phpBB/includes/constants.php6
-rw-r--r--phpBB/includes/functions.php23
-rw-r--r--phpBB/includes/functions_content.php32
-rw-r--r--phpBB/includes/functions_display.php2
-rw-r--r--phpBB/includes/functions_mcp.php4
-rw-r--r--phpBB/includes/functions_messenger.php2
-rw-r--r--phpBB/includes/functions_posting.php13
-rw-r--r--phpBB/includes/functions_upload.php1129
-rw-r--r--phpBB/includes/mcp/mcp_forum.php9
-rw-r--r--phpBB/includes/mcp/mcp_logs.php2
-rw-r--r--phpBB/includes/mcp/mcp_main.php3
-rw-r--r--phpBB/includes/mcp/mcp_post.php1
-rw-r--r--phpBB/includes/mcp/mcp_queue.php2
-rw-r--r--phpBB/includes/mcp/mcp_reports.php1
-rw-r--r--phpBB/includes/mcp/mcp_topic.php24
-rw-r--r--phpBB/includes/mcp/mcp_warn.php1
-rw-r--r--phpBB/includes/message_parser.php2
21 files changed, 80 insertions, 1197 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index 7413152e7a..7ff9846a75 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -620,10 +620,7 @@ class acp_attachments
$cat_lang = array(
ATTACHMENT_CATEGORY_NONE => $user->lang['NO_FILE_CAT'],
ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'],
- ATTACHMENT_CATEGORY_WM => $user->lang['CAT_WM_FILES'],
- ATTACHMENT_CATEGORY_RM => $user->lang['CAT_RM_FILES'],
ATTACHMENT_CATEGORY_FLASH => $user->lang['CAT_FLASH_FILES'],
- ATTACHMENT_CATEGORY_QUICKTIME => $user->lang['CAT_QUICKTIME_FILES'],
);
$group_id = $request->variable('g', 0);
@@ -1371,10 +1368,7 @@ class acp_attachments
$types = array(
ATTACHMENT_CATEGORY_NONE => $user->lang['NO_FILE_CAT'],
ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'],
- ATTACHMENT_CATEGORY_WM => $user->lang['CAT_WM_FILES'],
- ATTACHMENT_CATEGORY_RM => $user->lang['CAT_RM_FILES'],
ATTACHMENT_CATEGORY_FLASH => $user->lang['CAT_FLASH_FILES'],
- ATTACHMENT_CATEGORY_QUICKTIME => $user->lang['CAT_QUICKTIME_FILES'],
);
if ($group_id)
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index 0373a3b115..7bcf6e1957 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -371,6 +371,7 @@ class acp_extensions
foreach ($enabled_extension_meta_data as $name => $block_vars)
{
+ $block_vars['NAME'] = $name;
$block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name);
$this->template->assign_block_vars('enabled', $block_vars);
@@ -428,6 +429,7 @@ class acp_extensions
foreach ($disabled_extension_meta_data as $name => $block_vars)
{
+ $block_vars['NAME'] = $name;
$block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name);
$this->template->assign_block_vars('disabled', $block_vars);
@@ -488,6 +490,7 @@ class acp_extensions
foreach ($available_extension_meta_data as $name => $block_vars)
{
+ $block_vars['NAME'] = $name;
$block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name);
$this->template->assign_block_vars('disabled', $block_vars);
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index 8a53edb8ee..47e2660770 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -426,7 +426,7 @@ class acp_main
// Version check
$user->add_lang('install');
- if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.3.3', '<'))
+ if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.4', '<'))
{
$template->assign_vars(array(
'S_PHP_VERSION_OLD' => true,
diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php
index 2c4c82fcc7..027be03a00 100644
--- a/phpBB/includes/acp/auth.php
+++ b/phpBB/includes/acp/auth.php
@@ -1114,6 +1114,11 @@ class auth_admin extends \phpbb\auth\auth
@reset($category_array);
while (list($cat, $cat_array) = each($category_array))
{
+ if (!$phpbb_permissions->category_defined($cat))
+ {
+ continue;
+ }
+
$template->assign_block_vars($tpl_cat, array(
'S_YES' => ($cat_array['S_YES'] && !$cat_array['S_NEVER'] && !$cat_array['S_NO']) ? true : false,
'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false,
@@ -1140,6 +1145,11 @@ class auth_admin extends \phpbb\auth\auth
@reset($cat_array['permissions']);
while (list($permission, $allowed) = each($cat_array['permissions']))
{
+ if (!$phpbb_permissions->permission_defined($permission))
+ {
+ continue;
+ }
+
if ($s_view)
{
$template->assign_block_vars($tpl_cat . '.' . $tpl_mask, array(
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index 126cf44842..bd73201290 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -171,11 +171,11 @@ define('CONFIRM_REPORT', 4);
// Categories - Attachments
define('ATTACHMENT_CATEGORY_NONE', 0);
define('ATTACHMENT_CATEGORY_IMAGE', 1); // Inline Images
-define('ATTACHMENT_CATEGORY_WM', 2); // Windows Media Files - Streaming
-define('ATTACHMENT_CATEGORY_RM', 3); // Real Media Files - Streaming
+define('ATTACHMENT_CATEGORY_WM', 2); // Windows Media Files - Streaming - @deprecated 3.2
+define('ATTACHMENT_CATEGORY_RM', 3); // Real Media Files - Streaming - @deprecated 3.2
define('ATTACHMENT_CATEGORY_THUMB', 4); // Not used within the database, only while displaying posts
define('ATTACHMENT_CATEGORY_FLASH', 5); // Flash/SWF files
-define('ATTACHMENT_CATEGORY_QUICKTIME', 6); // Quicktime/Mov files
+define('ATTACHMENT_CATEGORY_QUICKTIME', 6); // Quicktime/Mov files - @deprecated 3.2
// BBCode UID length
define('BBCODE_UID_LEN', 8);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index c6d63e13f4..58b2f0ca57 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3475,7 +3475,15 @@ function phpbb_filter_root_path($errfile)
if (empty($root_path))
{
- $root_path = $phpbb_filesystem->realpath(dirname(__FILE__) . '/../');
+ if ($phpbb_filesystem)
+ {
+ $root_path = $phpbb_filesystem->realpath(dirname(__FILE__) . '/../');
+ }
+ else
+ {
+ $filesystem = new \phpbb\filesystem\filesystem();
+ $root_path = $filesystem->realpath(dirname(__FILE__) . '/../');
+ }
}
return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile);
@@ -4012,7 +4020,7 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)
/* @var $phpbb_avatar_manager \phpbb\avatar\manager */
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
- $driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config);
+ $driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], !$ignore_config);
$html = '';
if ($driver)
@@ -4023,7 +4031,7 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)
return $html;
}
- $avatar_data = $driver->get_data($row, $ignore_config);
+ $avatar_data = $driver->get_data($row);
}
else
{
@@ -4351,7 +4359,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),
'U_PRIVACY' => 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' => generate_board_url() . "/feed.$phpEx",
+ 'U_FEED' => $controller_helper->route('phpbb_feed_index'),
'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false,
'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false,
@@ -4402,7 +4410,8 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/",
'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/",
'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'],
- 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'],
+ 'T_STYLESHEET_LANG_LINK'=> "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'],
+ 'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$web_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'],
'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.min.js?assets_version=" . $config['assets_version'],
'S_ALLOW_CDN' => !empty($config['allow_cdn']),
@@ -4494,10 +4503,10 @@ function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \php
if (isset($GLOBALS['starttime']))
{
$totaltime = microtime(true) - $GLOBALS['starttime'];
- $debug_info[] = sprintf('<abbr title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</abbr>', $db->get_sql_time(), ($totaltime - $db->get_sql_time()), $totaltime);
+ $debug_info[] = sprintf('<span title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</span>', $db->get_sql_time(), ($totaltime - $db->get_sql_time()), $totaltime);
}
- $debug_info[] = sprintf('<abbr title="Cached: %d">Queries: %d</abbr>', $db->sql_num_queries(true), $db->sql_num_queries());
+ $debug_info[] = sprintf('<span title="Cached: %d">Queries: %d</span>', $db->sql_num_queries(true), $db->sql_num_queries());
$memory_usage = memory_get_peak_usage();
if ($memory_usage)
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index fd39c61b14..345df1d47a 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -1171,38 +1171,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
$update_count[] = $attachment['attach_id'];
break;
- // Windows Media Streams
- case ATTACHMENT_CATEGORY_WM:
-
- // Giving the filename directly because within the wm object all variables are in local context making it impossible
- // to validate against a valid session (all params can differ)
- // $download_link = $filename;
-
- $block_array += array(
- 'U_FORUM' => generate_board_url(),
- 'ATTACH_ID' => $attachment['attach_id'],
- 'S_WM_FILE' => true,
- );
-
- // Viewed/Heared File ... update the download count
- $update_count[] = $attachment['attach_id'];
- break;
-
- // Real Media Streams
- case ATTACHMENT_CATEGORY_RM:
- case ATTACHMENT_CATEGORY_QUICKTIME:
-
- $block_array += array(
- 'S_RM_FILE' => ($display_cat == ATTACHMENT_CATEGORY_RM) ? true : false,
- 'S_QUICKTIME_FILE' => ($display_cat == ATTACHMENT_CATEGORY_QUICKTIME) ? true : false,
- 'U_FORUM' => generate_board_url(),
- 'ATTACH_ID' => $attachment['attach_id'],
- );
-
- // Viewed/Heared File ... update the download count
- $update_count[] = $attachment['attach_id'];
- break;
-
// Macromedia Flash Files
case ATTACHMENT_CATEGORY_FLASH:
list($width, $height) = @getimagesize($filename);
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index c53a9f3bc0..3d61b5c098 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -1483,7 +1483,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
* @param array $user_data the current stored users data
* @param int $user_posts the users number of posts
*
-* @return array An associative array containing the rank title (title), the rank image source (img) and the rank image as full img tag (img)
+* @return array An associative array containing the rank title (title), the rank image as full img tag (img) and the rank image source (img_src)
*
* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false
*/
diff --git a/phpBB/includes/functions_mcp.php b/phpBB/includes/functions_mcp.php
index 46e85c5674..50acbebd4f 100644
--- a/phpBB/includes/functions_mcp.php
+++ b/phpBB/includes/functions_mcp.php
@@ -389,7 +389,7 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by
if (!$auth->acl_get('m_approve', $forum_id))
{
- $sql .= 'AND topic_visibility = ' . ITEM_APPROVED;
+ $sql .= ' AND topic_visibility = ' . ITEM_APPROVED;
}
break;
@@ -405,7 +405,7 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by
if (!$auth->acl_get('m_approve', $forum_id))
{
- $sql .= 'AND post_visibility = ' . ITEM_APPROVED;
+ $sql .= ' AND post_visibility = ' . ITEM_APPROVED;
}
break;
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 6abfb40b01..810f2c0584 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -931,6 +931,8 @@ class queue
{
// Do nothing
}
+
+ $this->data = array();
}
$lock->release();
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index e4520d7f03..8b17dba534 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -311,6 +311,7 @@ function posting_gen_topic_icons($mode, $icon_id)
{
$template->assign_block_vars('topic_icon', array(
'ICON_ID' => $id,
+ 'ICON_NAME' => $data['img'],
'ICON_IMG' => $root_path . $config['icons_path'] . '/' . $data['img'],
'ICON_WIDTH' => $data['width'],
'ICON_HEIGHT' => $data['height'],
@@ -404,14 +405,13 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
{
global $auth, $user, $config, $db, $cache;
- global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_filesystem;
+ global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_container;
$filedata = array(
'error' => array()
);
- include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
- $upload = new fileupload($phpbb_filesystem);
+ $upload = $phpbb_container->get('files.upload');
if ($config['check_attachment_content'] && isset($config['mime_triggers']))
{
@@ -433,9 +433,10 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
$extensions = $cache->obtain_attach_extensions((($is_message) ? false : (int) $forum_id));
$upload->set_allowed_extensions(array_keys($extensions['_allowed_']));
- $file = ($local) ? $upload->local_upload($local_storage, $local_filedata, $mimetype_guesser) : $upload->form_upload($form_name, $mimetype_guesser, $plupload);
+ /** @var \phpbb\files\filespec $file */
+ $file = ($local) ? $upload->handle_upload('files.types.local', $local_storage, $local_filedata) : $upload->handle_upload('files.types.form', $form_name);
- if ($file->init_error)
+ if ($file->init_error())
{
$filedata['post_attach'] = false;
return $filedata;
@@ -1700,6 +1701,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array(
'forum_id' => $data['forum_id'],
'topic_id' => $data['topic_id'],
+ 'post_id' => $data['post_id'],
$log_subject,
(!empty($username)) ? $username : $user->lang['GUEST'],
$data['post_edit_reason']
@@ -2666,6 +2668,7 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), false, array(
'forum_id' => $forum_id,
'topic_id' => $topic_id,
+ 'post_id' => $post_id,
$post_data['post_subject'],
$post_username,
$delete_reason
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
deleted file mode 100644
index dcc9bc4874..0000000000
--- a/phpBB/includes/functions_upload.php
+++ /dev/null
@@ -1,1129 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
-* Responsible for holding all file relevant information, as well as doing file-specific operations.
-* The {@link fileupload fileupload class} can be used to upload several files, each of them being this object to operate further on.
-*/
-class filespec
-{
- var $filename = '';
- var $realname = '';
- var $uploadname = '';
- var $mimetype = '';
- var $extension = '';
- var $filesize = 0;
- var $width = 0;
- var $height = 0;
- var $image_info = array();
-
- var $destination_file = '';
- var $destination_path = '';
-
- var $file_moved = false;
- var $init_error = false;
- var $local = false;
-
- var $error = array();
-
- var $upload = '';
-
- /**
- * @var \phpbb\filesystem\filesystem_interface
- */
- protected $filesystem;
-
- /**
- * The plupload object
- * @var \phpbb\plupload\plupload
- */
- protected $plupload;
-
- /**
- * phpBB Mimetype guesser
- * @var \phpbb\mimetype\guesser
- */
- protected $mimetype_guesser;
-
- /**
- * File Class
- * @access private
- */
- function filespec($upload_ary, $upload_namespace, \phpbb\filesystem\filesystem_interface $phpbb_filesystem, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
- {
- if (!isset($upload_ary))
- {
- $this->init_error = true;
- return;
- }
-
- $this->filename = $upload_ary['tmp_name'];
- $this->filesize = $upload_ary['size'];
- $name = (STRIP) ? stripslashes($upload_ary['name']) : $upload_ary['name'];
- $name = trim(utf8_basename($name));
- $this->realname = $this->uploadname = $name;
- $this->mimetype = $upload_ary['type'];
-
- // Opera adds the name to the mime type
- $this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
-
- if (!$this->mimetype)
- {
- $this->mimetype = 'application/octet-stream';
- }
-
- $this->extension = strtolower(self::get_extension($this->realname));
-
- // Try to get real filesize from temporary folder (not always working) ;)
- $this->filesize = (@filesize($this->filename)) ? @filesize($this->filename) : $this->filesize;
-
- $this->width = $this->height = 0;
- $this->file_moved = false;
-
- $this->local = (isset($upload_ary['local_mode'])) ? true : false;
- $this->upload = $upload_namespace;
- $this->plupload = $plupload;
- $this->mimetype_guesser = $mimetype_guesser;
- $this->filesystem = $phpbb_filesystem;
- }
-
- /**
- * Cleans destination filename
- *
- * @param real|unique|unique_ext $mode real creates a realname, filtering some characters, lowering every character. Unique creates an unique filename
- * @param string $prefix Prefix applied to filename
- * @param string $user_id The user_id is only needed for when cleaning a user's avatar
- * @access public
- */
- function clean_filename($mode = 'unique', $prefix = '', $user_id = '')
- {
- if ($this->init_error)
- {
- return;
- }
-
- switch ($mode)
- {
- case 'real':
- // Remove every extension from filename (to not let the mime bug being exposed)
- if (strpos($this->realname, '.') !== false)
- {
- $this->realname = substr($this->realname, 0, strpos($this->realname, '.'));
- }
-
- // Replace any chars which may cause us problems with _
- $bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|');
-
- $this->realname = rawurlencode(str_replace($bad_chars, '_', strtolower($this->realname)));
- $this->realname = preg_replace("/%(\w{2})/", '_', $this->realname);
-
- $this->realname = $prefix . $this->realname . '.' . $this->extension;
- break;
-
- case 'unique':
- $this->realname = $prefix . md5(unique_id());
- break;
-
- case 'avatar':
- $this->extension = strtolower($this->extension);
- $this->realname = $prefix . $user_id . '.' . $this->extension;
-
- break;
-
- case 'unique_ext':
- default:
- $this->realname = $prefix . md5(unique_id()) . '.' . $this->extension;
- break;
- }
- }
-
- /**
- * Get property from file object
- */
- function get($property)
- {
- if ($this->init_error || !isset($this->$property))
- {
- return false;
- }
-
- return $this->$property;
- }
-
- /**
- * Check if file is an image (mimetype)
- *
- * @return true if it is an image, false if not
- */
- function is_image()
- {
- return (strpos($this->mimetype, 'image/') === 0);
- }
-
- /**
- * Check if the file got correctly uploaded
- *
- * @return true if it is a valid upload, false if not
- */
- function is_uploaded()
- {
- $is_plupload = $this->plupload && $this->plupload->is_active();
-
- if (!$this->local && !$is_plupload && !is_uploaded_file($this->filename))
- {
- return false;
- }
-
- if (($this->local || $is_plupload) && !file_exists($this->filename))
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * Remove file
- */
- function remove()
- {
- if ($this->file_moved)
- {
- @unlink($this->destination_file);
- }
- }
-
- /**
- * Get file extension
- *
- * @param string Filename that needs to be checked
- * @return string Extension of the supplied filename
- */
- static public function get_extension($filename)
- {
- $filename = utf8_basename($filename);
-
- if (strpos($filename, '.') === false)
- {
- return '';
- }
-
- $filename = explode('.', $filename);
- return array_pop($filename);
- }
-
- /**
- * Get mimetype
- *
- * @param string $filename Filename that needs to be checked
- * @return string Mimetype of supplied filename
- */
- function get_mimetype($filename)
- {
- if ($this->mimetype_guesser !== null)
- {
- $mimetype = $this->mimetype_guesser->guess($filename, $this->uploadname);
-
- if ($mimetype !== 'application/octet-stream')
- {
- $this->mimetype = $mimetype;
- }
- }
-
- return $this->mimetype;
- }
-
- /**
- * Get filesize
- */
- function get_filesize($filename)
- {
- return @filesize($filename);
- }
-
-
- /**
- * Check the first 256 bytes for forbidden content
- */
- function check_content($disallowed_content)
- {
- if (empty($disallowed_content))
- {
- return true;
- }
-
- $fp = @fopen($this->filename, 'rb');
-
- if ($fp !== false)
- {
- $ie_mime_relevant = fread($fp, 256);
- fclose($fp);
- foreach ($disallowed_content as $forbidden)
- {
- if (stripos($ie_mime_relevant, '<' . $forbidden) !== false)
- {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Move file to destination folder
- * The phpbb_root_path variable will be applied to the destination path
- *
- * @param string $destination Destination path, for example $config['avatar_path']
- * @param bool $overwrite If set to true, an already existing file will be overwritten
- * @param bool $skip_image_check If set to true, the check for the file to be a valid image is skipped
- * @param string $chmod Permission mask for chmodding the file after a successful move. The mode entered here reflects the mode defined by {@link phpbb_chmod()}
- *
- * @access public
- */
- function move_file($destination, $overwrite = false, $skip_image_check = false, $chmod = false)
- {
- global $user, $phpbb_root_path;
-
- if (sizeof($this->error))
- {
- return false;
- }
-
- $chmod = ($chmod === false) ? CHMOD_READ | CHMOD_WRITE : $chmod;
-
- // We need to trust the admin in specifying valid upload directories and an attacker not being able to overwrite it...
- $this->destination_path = $phpbb_root_path . $destination;
-
- // Check if the destination path exist...
- if (!file_exists($this->destination_path))
- {
- @unlink($this->filename);
- return false;
- }
-
- $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on') ? 'move' : 'copy';
- $upload_mode = ($this->local) ? 'local' : $upload_mode;
- $this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname);
-
- // Check if the file already exist, else there is something wrong...
- if (file_exists($this->destination_file) && !$overwrite)
- {
- @unlink($this->filename);
- $this->error[] = $user->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file);
- $this->file_moved = false;
- return false;
- }
- else
- {
- if (file_exists($this->destination_file))
- {
- @unlink($this->destination_file);
- }
-
- switch ($upload_mode)
- {
- case 'copy':
-
- if (!@copy($this->filename, $this->destination_file))
- {
- if (!@move_uploaded_file($this->filename, $this->destination_file))
- {
- $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
- }
- }
-
- break;
-
- case 'move':
-
- if (!@move_uploaded_file($this->filename, $this->destination_file))
- {
- if (!@copy($this->filename, $this->destination_file))
- {
- $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
- }
- }
-
- break;
-
- case 'local':
-
- if (!@copy($this->filename, $this->destination_file))
- {
- $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
- }
-
- break;
- }
-
- // Remove temporary filename
- @unlink($this->filename);
-
- if (sizeof($this->error))
- {
- return false;
- }
-
- try
- {
- $this->filesystem->phpbb_chmod($this->destination_file, $chmod);
- }
- catch (\phpbb\filesystem\exception\filesystem_exception $e)
- {
- // Do nothing
- }
- }
-
- // Try to get real filesize from destination folder
- $this->filesize = (@filesize($this->destination_file)) ? @filesize($this->destination_file) : $this->filesize;
-
- // Get mimetype of supplied file
- $this->mimetype = $this->get_mimetype($this->destination_file);
-
- if ($this->is_image() && !$skip_image_check)
- {
- $this->width = $this->height = 0;
-
- // Get imagesize class
- $imagesize = new \fastImageSize\fastImageSize();
-
- $this->image_info = $imagesize->getImageSize($this->destination_file, $this->mimetype);
-
- if ($this->image_info !== false)
- {
- $this->width = $this->image_info['width'];
- $this->height = $this->image_info['height'];
-
- // Check image type
- $types = fileupload::image_types();
-
- if (!isset($types[$this->image_info['type']]) || !in_array($this->extension, $types[$this->image_info['type']]))
- {
- if (!isset($types[$this->image_info['type']]))
- {
- $this->error[] = $user->lang('IMAGE_FILETYPE_INVALID', $this->image_info['type'], $this->mimetype);
- }
- else
- {
- $this->error[] = $user->lang('IMAGE_FILETYPE_MISMATCH', $types[$this->image_info['type']][0], $this->extension);
- }
- }
-
- // Make sure the dimensions match a valid image
- if (empty($this->width) || empty($this->height))
- {
- $this->error[] = $user->lang['ATTACHED_IMAGE_NOT_IMAGE'];
- }
- }
- else
- {
- $this->error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
- }
- }
-
- $this->file_moved = true;
- $this->additional_checks();
- unset($this->upload);
-
- return true;
- }
-
- /**
- * Performing additional checks
- */
- function additional_checks()
- {
- global $user;
-
- if (!$this->file_moved)
- {
- return false;
- }
-
- // Filesize is too big or it's 0 if it was larger than the maxsize in the upload form
- if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0))
- {
- $max_filesize = get_formatted_filesize($this->upload->max_filesize, false);
-
- $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']);
-
- return false;
- }
-
- if (!$this->upload->valid_dimensions($this))
- {
- $this->error[] = $user->lang($this->upload->error_prefix . 'WRONG_SIZE',
- $user->lang('PIXELS', (int) $this->upload->min_width),
- $user->lang('PIXELS', (int) $this->upload->min_height),
- $user->lang('PIXELS', (int) $this->upload->max_width),
- $user->lang('PIXELS', (int) $this->upload->max_height),
- $user->lang('PIXELS', (int) $this->width),
- $user->lang('PIXELS', (int) $this->height));
-
- return false;
- }
-
- return true;
- }
-}
-
-/**
-* Class for assigning error messages before a real filespec class can be assigned
-*/
-class fileerror extends filespec
-{
- function fileerror($error_msg)
- {
- $this->error[] = $error_msg;
- }
-}
-
-/**
-* File upload class
-* Init class (all parameters optional and able to be set/overwritten separately) - scope is global and valid for all uploads
-*/
-class fileupload
-{
- var $allowed_extensions = array();
- var $disallowed_content = array('body', 'head', 'html', 'img', 'plaintext', 'a href', 'pre', 'script', 'table', 'title');
- var $max_filesize = 0;
- var $min_width = 0;
- var $min_height = 0;
- var $max_width = 0;
- var $max_height = 0;
- var $error_prefix = '';
-
- /** @var int Timeout for remote upload */
- var $upload_timeout = 6;
-
- /**
- * @var \phpbb\filesystem\filesystem_interface
- */
- protected $filesystem;
-
- /**
- * Init file upload class.
- *
- * @param \phpbb\filesystem\filesystem_interface $filesystem
- * @param string $error_prefix Used error messages will get prefixed by this string
- * @param array $allowed_extensions Array of allowed extensions, for example array('jpg', 'jpeg', 'gif', 'png')
- * @param int $max_filesize Maximum filesize
- * @param int $min_width Minimum image width (only checked for images)
- * @param int $min_height Minimum image height (only checked for images)
- * @param int $max_width Maximum image width (only checked for images)
- * @param int $max_height Maximum image height (only checked for images)
- * @param bool|array $disallowed_content If enabled, the first 256 bytes of the file must not
- * contain any of its values. Defaults to false.
- *
- */
- function fileupload(\phpbb\filesystem\filesystem_interface $filesystem, $error_prefix = '', $allowed_extensions = false, $max_filesize = false, $min_width = false, $min_height = false, $max_width = false, $max_height = false, $disallowed_content = false)
- {
- $this->set_allowed_extensions($allowed_extensions);
- $this->set_max_filesize($max_filesize);
- $this->set_allowed_dimensions($min_width, $min_height, $max_width, $max_height);
- $this->set_error_prefix($error_prefix);
- $this->set_disallowed_content($disallowed_content);
- $this->filesystem = $filesystem;
- }
-
- /**
- * Reset vars
- */
- function reset_vars()
- {
- $this->max_filesize = 0;
- $this->min_width = $this->min_height = $this->max_width = $this->max_height = 0;
- $this->error_prefix = '';
- $this->allowed_extensions = array();
- $this->disallowed_content = array();
- }
-
- /**
- * Set allowed extensions
- */
- function set_allowed_extensions($allowed_extensions)
- {
- if ($allowed_extensions !== false && is_array($allowed_extensions))
- {
- $this->allowed_extensions = $allowed_extensions;
- }
- }
-
- /**
- * Set allowed dimensions
- */
- function set_allowed_dimensions($min_width, $min_height, $max_width, $max_height)
- {
- $this->min_width = (int) $min_width;
- $this->min_height = (int) $min_height;
- $this->max_width = (int) $max_width;
- $this->max_height = (int) $max_height;
- }
-
- /**
- * Set maximum allowed filesize
- */
- function set_max_filesize($max_filesize)
- {
- if ($max_filesize !== false && (int) $max_filesize)
- {
- $this->max_filesize = (int) $max_filesize;
- }
- }
-
- /**
- * Set disallowed strings
- */
- function set_disallowed_content($disallowed_content)
- {
- if ($disallowed_content !== false && is_array($disallowed_content))
- {
- $this->disallowed_content = array_diff($disallowed_content, array(''));
- }
- }
-
- /**
- * Set error prefix
- */
- function set_error_prefix($error_prefix)
- {
- $this->error_prefix = $error_prefix;
- }
-
- /**
- * Form upload method
- * Upload file from users harddisk
- *
- * @param string $form_name Form name assigned to the file input field (if it is an array, the key has to be specified)
- * @param \phpbb\mimetype\guesser $mimetype_guesser Mimetype guesser
- * @param \phpbb\plupload\plupload $plupload The plupload object
- *
- * @return object $file Object "filespec" is returned, all further operations can be done with this object
- * @access public
- */
- function form_upload($form_name, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
- {
- global $user, $request;
-
- $upload = $request->file($form_name);
- unset($upload['local_mode']);
-
- if ($plupload)
- {
- $result = $plupload->handle_upload($form_name);
- if (is_array($result))
- {
- $upload = array_merge($upload, $result);
- }
- }
-
- $file = new filespec($upload, $this, $this->filesystem, $mimetype_guesser, $plupload);
-
- if ($file->init_error)
- {
- $file->error[] = '';
- return $file;
- }
-
- // Error array filled?
- if (isset($upload['error']))
- {
- $error = $this->assign_internal_error($upload['error']);
-
- if ($error !== false)
- {
- $file->error[] = $error;
- return $file;
- }
- }
-
- // Check if empty file got uploaded (not catched by is_uploaded_file)
- if (isset($upload['size']) && $upload['size'] == 0)
- {
- $file->error[] = $user->lang[$this->error_prefix . 'EMPTY_FILEUPLOAD'];
- return $file;
- }
-
- // PHP Upload filesize exceeded
- if ($file->get('filename') == 'none')
- {
- $max_filesize = @ini_get('upload_max_filesize');
- $unit = 'MB';
-
- if (!empty($max_filesize))
- {
- $unit = strtolower(substr($max_filesize, -1, 1));
- $max_filesize = (int) $max_filesize;
-
- $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB');
- }
-
- $file->error[] = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]);
- return $file;
- }
-
- // Not correctly uploaded
- if (!$file->is_uploaded())
- {
- $file->error[] = $user->lang[$this->error_prefix . 'NOT_UPLOADED'];
- return $file;
- }
-
- $this->common_checks($file);
-
- return $file;
- }
-
- /**
- * Move file from another location to phpBB
- */
- function local_upload($source_file, $filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null)
- {
- global $user, $request;
-
- $upload = array();
-
- $upload['local_mode'] = true;
- $upload['tmp_name'] = $source_file;
-
- if ($filedata === false)
- {
- $upload['name'] = utf8_basename($source_file);
- $upload['size'] = 0;
- }
- else
- {
- $upload['name'] = $filedata['realname'];
- $upload['size'] = $filedata['size'];
- $upload['type'] = $filedata['type'];
- }
-
- $file = new filespec($upload, $this, $this->filesystem, $mimetype_guesser);
-
- if ($file->init_error)
- {
- $file->error[] = '';
- return $file;
- }
-
- if (isset($upload['error']))
- {
- $error = $this->assign_internal_error($upload['error']);
-
- if ($error !== false)
- {
- $file->error[] = $error;
- return $file;
- }
- }
-
- // PHP Upload filesize exceeded
- if ($file->get('filename') == 'none')
- {
- $max_filesize = @ini_get('upload_max_filesize');
- $unit = 'MB';
-
- if (!empty($max_filesize))
- {
- $unit = strtolower(substr($max_filesize, -1, 1));
- $max_filesize = (int) $max_filesize;
-
- $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB');
- }
-
- $file->error[] = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]);
- return $file;
- }
-
- // Not correctly uploaded
- if (!$file->is_uploaded())
- {
- $file->error[] = $user->lang[$this->error_prefix . 'NOT_UPLOADED'];
- return $file;
- }
-
- $this->common_checks($file);
- $request->overwrite('local', $upload, \phpbb\request\request_interface::FILES);
-
- return $file;
- }
-
- /**
- * Remote upload method
- * Uploads file from given url
- *
- * @param string $upload_url URL pointing to file to upload, for example http://www.foobar.com/example.gif
- * @param \phpbb\mimetype\guesser $mimetype_guesser Mimetype guesser
- * @return object $file Object "filespec" is returned, all further operations can be done with this object
- * @access public
- */
- function remote_upload($upload_url, \phpbb\mimetype\guesser $mimetype_guesser = null)
- {
- global $user, $phpbb_root_path;
-
- $upload_ary = array();
- $upload_ary['local_mode'] = true;
-
- if (!preg_match('#^(https?://).*?\.(' . implode('|', $this->allowed_extensions) . ')$#i', $upload_url, $match))
- {
- $file = new fileerror($user->lang[$this->error_prefix . 'URL_INVALID']);
- return $file;
- }
-
- if (empty($match[2]))
- {
- $file = new fileerror($user->lang[$this->error_prefix . 'URL_INVALID']);
- return $file;
- }
-
- $url = parse_url($upload_url);
-
- $host = $url['host'];
- $path = $url['path'];
- $port = (!empty($url['port'])) ? (int) $url['port'] : 80;
-
- $upload_ary['type'] = 'application/octet-stream';
-
- $url['path'] = explode('.', $url['path']);
- $ext = array_pop($url['path']);
-
- $url['path'] = implode('', $url['path']);
- $upload_ary['name'] = utf8_basename($url['path']) . (($ext) ? '.' . $ext : '');
- $filename = $url['path'];
- $filesize = 0;
-
- $remote_max_filesize = $this->max_filesize;
- if (!$remote_max_filesize)
- {
- $max_filesize = @ini_get('upload_max_filesize');
-
- if (!empty($max_filesize))
- {
- $unit = strtolower(substr($max_filesize, -1, 1));
- $remote_max_filesize = (int) $max_filesize;
-
- switch ($unit)
- {
- case 'g':
- $remote_max_filesize *= 1024;
- // no break
- case 'm':
- $remote_max_filesize *= 1024;
- // no break
- case 'k':
- $remote_max_filesize *= 1024;
- // no break
- }
- }
- }
-
- $errno = 0;
- $errstr = '';
-
- if (!($fsock = @fsockopen($host, $port, $errno, $errstr)))
- {
- $file = new fileerror($user->lang[$this->error_prefix . 'NOT_UPLOADED']);
- return $file;
- }
-
- // Make sure $path not beginning with /
- if (strpos($path, '/') === 0)
- {
- $path = substr($path, 1);
- }
-
- fputs($fsock, 'GET /' . $path . " HTTP/1.1\r\n");
- fputs($fsock, "HOST: " . $host . "\r\n");
- fputs($fsock, "Connection: close\r\n\r\n");
-
- // Set a proper timeout for the socket
- socket_set_timeout($fsock, $this->upload_timeout);
-
- $get_info = false;
- $data = '';
- $length = false;
- $timer_stop = time() + $this->upload_timeout;
-
- while ((!$length || $filesize < $length) && !@feof($fsock))
- {
- if ($get_info)
- {
- if ($length)
- {
- // Don't attempt to read past end of file if server indicated length
- $block = @fread($fsock, min($length - $filesize, 1024));
- }
- else
- {
- $block = @fread($fsock, 1024);
- }
-
- $filesize += strlen($block);
-
- if ($remote_max_filesize && $filesize > $remote_max_filesize)
- {
- $max_filesize = get_formatted_filesize($remote_max_filesize, false);
-
- $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']));
- return $file;
- }
-
- $data .= $block;
- }
- else
- {
- $line = @fgets($fsock, 1024);
-
- if ($line == "\r\n")
- {
- $get_info = true;
- }
- else
- {
- if (stripos($line, 'content-type: ') !== false)
- {
- $upload_ary['type'] = rtrim(str_replace('content-type: ', '', strtolower($line)));
- }
- else if ($this->max_filesize && stripos($line, 'content-length: ') !== false)
- {
- $length = (int) str_replace('content-length: ', '', strtolower($line));
-
- if ($remote_max_filesize && $length && $length > $remote_max_filesize)
- {
- $max_filesize = get_formatted_filesize($remote_max_filesize, false);
-
- $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']));
- return $file;
- }
- }
- else if (stripos($line, '404 not found') !== false)
- {
- $file = new fileerror($user->lang[$this->error_prefix . 'URL_NOT_FOUND']);
- return $file;
- }
- }
- }
-
- $stream_meta_data = stream_get_meta_data($fsock);
-
- // Cancel upload if we exceed timeout
- if (!empty($stream_meta_data['timed_out']) || time() >= $timer_stop)
- {
- $file = new fileerror($user->lang[$this->error_prefix . 'REMOTE_UPLOAD_TIMEOUT']);
- return $file;
- }
- }
- @fclose($fsock);
-
- if (empty($data))
- {
- $file = new fileerror($user->lang[$this->error_prefix . 'EMPTY_REMOTE_DATA']);
- return $file;
- }
-
- $tmp_path = (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') ? false : $phpbb_root_path . 'cache';
- $filename = tempnam($tmp_path, unique_id() . '-');
-
- if (!($fp = @fopen($filename, 'wb')))
- {
- $file = new fileerror($user->lang[$this->error_prefix . 'NOT_UPLOADED']);
- return $file;
- }
-
- $upload_ary['size'] = fwrite($fp, $data);
- fclose($fp);
- unset($data);
-
- $upload_ary['tmp_name'] = $filename;
-
- $file = new filespec($upload_ary, $this, $this->filesystem, $mimetype_guesser);
- $this->common_checks($file);
-
- return $file;
- }
-
- /**
- * Assign internal error
- * @access private
- */
- function assign_internal_error($errorcode)
- {
- global $user;
-
- switch ($errorcode)
- {
- case 1:
- $max_filesize = @ini_get('upload_max_filesize');
- $unit = 'MB';
-
- if (!empty($max_filesize))
- {
- $unit = strtolower(substr($max_filesize, -1, 1));
- $max_filesize = (int) $max_filesize;
-
- $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB');
- }
-
- $error = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]);
- break;
-
- case 2:
- $max_filesize = get_formatted_filesize($this->max_filesize, false);
-
- $error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']);
- break;
-
- case 3:
- $error = $user->lang[$this->error_prefix . 'PARTIAL_UPLOAD'];
- break;
-
- case 4:
- $error = $user->lang[$this->error_prefix . 'NOT_UPLOADED'];
- break;
-
- case 6:
- $error = 'Temporary folder could not be found. Please check your PHP installation.';
- break;
-
- default:
- $error = false;
- break;
- }
-
- return $error;
- }
-
- /**
- * Perform common checks
- */
- function common_checks(&$file)
- {
- global $user;
-
- // Filesize is too big or it's 0 if it was larger than the maxsize in the upload form
- if ($this->max_filesize && ($file->get('filesize') > $this->max_filesize || $file->get('filesize') == 0))
- {
- $max_filesize = get_formatted_filesize($this->max_filesize, false);
-
- $file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']);
- }
-
- // check Filename
- if (preg_match("#[\\/:*?\"<>|]#i", $file->get('realname')))
- {
- $file->error[] = sprintf($user->lang[$this->error_prefix . 'INVALID_FILENAME'], $file->get('realname'));
- }
-
- // Invalid Extension
- if (!$this->valid_extension($file))
- {
- $file->error[] = sprintf($user->lang[$this->error_prefix . 'DISALLOWED_EXTENSION'], $file->get('extension'));
- }
-
- // MIME Sniffing
- if (!$this->valid_content($file))
- {
- $file->error[] = sprintf($user->lang[$this->error_prefix . 'DISALLOWED_CONTENT']);
- }
- }
-
- /**
- * Check for allowed extension
- */
- function valid_extension(&$file)
- {
- return (in_array($file->get('extension'), $this->allowed_extensions)) ? true : false;
- }
-
- /**
- * Check for allowed dimension
- */
- function valid_dimensions(&$file)
- {
- if (!$this->max_width && !$this->max_height && !$this->min_width && !$this->min_height)
- {
- return true;
- }
-
- if (($file->get('width') > $this->max_width && $this->max_width) ||
- ($file->get('height') > $this->max_height && $this->max_height) ||
- ($file->get('width') < $this->min_width && $this->min_width) ||
- ($file->get('height') < $this->min_height && $this->min_height))
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * Check if form upload is valid
- */
- function is_valid($form_name)
- {
- global $request;
- $upload = $request->file($form_name);
-
- return (!empty($upload) && $upload['name'] !== 'none');
- }
-
-
- /**
- * Check for bad content (IE mime-sniffing)
- */
- function valid_content(&$file)
- {
- return ($file->check_content($this->disallowed_content));
- }
-
- /**
- * Get image type/extension mapping
- *
- * @return array Array containing the image types and their extensions
- */
- static public function image_types()
- {
- $result = array(
- IMAGETYPE_GIF => array('gif'),
- IMAGETYPE_JPEG => array('jpg', 'jpeg'),
- IMAGETYPE_PNG => array('png'),
- IMAGETYPE_SWF => array('swf'),
- IMAGETYPE_PSD => array('psd'),
- IMAGETYPE_BMP => array('bmp'),
- IMAGETYPE_TIFF_II => array('tif', 'tiff'),
- IMAGETYPE_TIFF_MM => array('tif', 'tiff'),
- IMAGETYPE_JPC => array('jpg', 'jpeg'),
- IMAGETYPE_JP2 => array('jpg', 'jpeg'),
- IMAGETYPE_JPX => array('jpg', 'jpeg'),
- IMAGETYPE_JB2 => array('jpg', 'jpeg'),
- IMAGETYPE_IFF => array('iff'),
- IMAGETYPE_WBMP => array('wbmp'),
- IMAGETYPE_XBM => array('xbm'),
- );
-
- if (defined('IMAGETYPE_SWC'))
- {
- $result[IMAGETYPE_SWC] = array('swc');
- }
-
- return $result;
- }
-}
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index 485c9d5eec..f73973b81d 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -35,15 +35,6 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
// merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
$merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;
- if ($merge_select)
- {
- // Fixes a "bug" that makes forum_view use the same ordering as topic_view
- $request->overwrite('sk', null);
- $request->overwrite('sd', null);
- $request->overwrite('sk', null, \phpbb\request\request_interface::POST);
- $request->overwrite('sd', null, \phpbb\request\request_interface::POST);
- }
-
$forum_id = $forum_info['forum_id'];
$start = $request->variable('start', 0);
$topic_id_list = $request->variable('topic_id_list', array(0));
diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php
index 43327707b3..bf2d462801 100644
--- a/phpBB/includes/mcp/mcp_logs.php
+++ b/phpBB/includes/mcp/mcp_logs.php
@@ -205,7 +205,7 @@ class mcp_logs
{
$data = array();
- $checks = array('viewtopic', 'viewforum');
+ $checks = array('viewpost', 'viewtopic', 'viewforum');
foreach ($checks as $check)
{
if (isset($row[$check]) && $row[$check])
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index 66e59bb74d..b0579d8995 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -322,6 +322,7 @@ function lock_unlock($action, $ids)
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_' . strtoupper($action), false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
+ 'post_id' => isset($row['post_id']) ? $row['post_id'] : 0,
$row['topic_title']
));
}
@@ -1022,6 +1023,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_POST', false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
+ 'post_id' => $row['post_id'],
$row['post_subject'],
$post_username,
$soft_delete_reason
@@ -1071,6 +1073,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_POST', false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
+ 'post_id' => $row['post_id'],
$row['post_subject'],
$post_username,
$soft_delete_reason
diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php
index f53f40d66a..e59f0abb04 100644
--- a/phpBB/includes/mcp/mcp_post.php
+++ b/phpBB/includes/mcp/mcp_post.php
@@ -574,6 +574,7 @@ function change_poster(&$post_info, $userdata)
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MCP_CHANGE_POSTER', false, array(
'forum_id' => $post_info['forum_id'],
'topic_id' => $post_info['topic_id'],
+ 'post_id' => $post_info['post_id'],
$post_info['topic_title'],
$from_username,
$to_username
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index 3488ea326d..ac82c9f2ad 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -678,6 +678,7 @@ class mcp_queue
$approve_log[] = array(
'forum_id' => $post_data['forum_id'],
'topic_id' => $post_data['topic_id'],
+ 'post_id' => $post_id,
'post_subject' => $post_data['post_subject'],
);
}
@@ -694,6 +695,7 @@ class mcp_queue
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_' . strtoupper($action) . 'D', false, array(
'forum_id' => $log_data['forum_id'],
'topic_id' => $log_data['topic_id'],
+ 'post_id' => $log_data['post_id'],
$log_data['post_subject']
));
}
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index 3970237058..45265c89e7 100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -716,6 +716,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_REPORT_' . strtoupper($action) . 'D', false, array(
'forum_id' => $post_info[$report['post_id']]['forum_id'],
'topic_id' => $post_info[$report['post_id']]['topic_id'],
+ 'post_id' => $report['post_id'],
$post_info[$report['post_id']]['post_subject']
));
$phpbb_notifications->delete_notifications('notification.type.report_post', $report['post_id']);
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index 66bcdad72c..70794312f4 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -196,6 +196,30 @@ function mcp_topic_view($id, $mode, $action)
}
}
+ /**
+ * Event to modify the post data for the MCP topic review before assigning the posts
+ *
+ * @event core.mcp_topic_modify_post_data
+ * @var array attachments List of attachments post_id => array of attachments
+ * @var int forum_id The forum ID we are currently in
+ * @var int id ID of the tab we are displaying
+ * @var string mode Mode of the MCP page we are displaying
+ * @var array post_id_list Array with post ids we are going to display
+ * @var array rowset Array with the posts data
+ * @var int topic_id The topic ID we are currently reviewing
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'attachments',
+ 'forum_id',
+ 'id',
+ 'mode',
+ 'post_id_list',
+ 'rowset',
+ 'topic_id',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.mcp_topic_modify_post_data', compact($vars)));
+
foreach ($rowset as $i => $row)
{
$message = $row['post_text'];
diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php
index 970bdc6174..d4c5486ed4 100644
--- a/phpBB/includes/mcp/mcp_warn.php
+++ b/phpBB/includes/mcp/mcp_warn.php
@@ -589,6 +589,7 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0)
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING', false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
+ 'post_id' => $post_id,
$user_row['username']
));
}
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index c50212e8ff..31fc1577a2 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -403,7 +403,7 @@ class bbcode_firstpass extends bbcode
if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width'])
{
- $imagesize = new \fastImageSize\fastImageSize();
+ $imagesize = new \FastImageSize\FastImageSize();
$size_info = $imagesize->getImageSize(htmlspecialchars_decode($in));
if ($size_info === false)