aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-07-15 23:10:23 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-09-09 08:28:04 +0200
commita09c6d1fb760151b1a6c654b597b4578c3136be1 (patch)
treee0952fa5beee9825d9173485f977ce32d4d4d7d5 /phpBB/phpbb
parent0a6f54d522f7799819969fcd588a354b7beb3fa9 (diff)
downloadforums-a09c6d1fb760151b1a6c654b597b4578c3136be1.tar
forums-a09c6d1fb760151b1a6c654b597b4578c3136be1.tar.gz
forums-a09c6d1fb760151b1a6c654b597b4578c3136be1.tar.bz2
forums-a09c6d1fb760151b1a6c654b597b4578c3136be1.tar.xz
forums-a09c6d1fb760151b1a6c654b597b4578c3136be1.zip
[ticket/13904] Split code up and pass root path to remote upload type
PHPBB3-13904
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/files/types/remote.php66
1 files changed, 41 insertions, 25 deletions
diff --git a/phpBB/phpbb/files/types/remote.php b/phpBB/phpbb/files/types/remote.php
index f2db6c798c..65cff8ccc7 100644
--- a/phpBB/phpbb/files/types/remote.php
+++ b/phpBB/phpbb/files/types/remote.php
@@ -32,17 +32,21 @@ class remote extends base
/** @var \phpbb\files\upload */
protected $upload;
+ /** @var string phpBB root path */
+ protected $phpbb_root_path;
+
/**
* Construct a form upload type
*
* @param factory $factory
* @param request_interface $request
*/
- public function __construct(factory $factory, language $language, request_interface $request)
+ public function __construct(factory $factory, language $language, request_interface $request, $phpbb_root_path)
{
$this->factory = $factory;
$this->language = $language;
$this->request = $request;
+ $this->phpbb_root_path = $phpbb_root_path;
}
/**
@@ -93,30 +97,7 @@ class remote extends base
$filename = $url['path'];
$filesize = 0;
- $remote_max_filesize = $this->upload->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
- }
- }
- }
+ $remote_max_filesize = $this->get_max_file_size();
$errno = 0;
$errstr = '';
@@ -238,4 +219,39 @@ class remote extends base
return $file;
}
+
+ /**
+ * Get maximum file size for remote uploads
+ *
+ * @return int Maximum file size
+ */
+ protected function get_max_file_size()
+ {
+ $max_file_size = $this->upload->max_filesize;
+ if (!$max_file_size)
+ {
+ $max_file_size = @ini_get('upload_max_filesize');
+
+ if (!empty($max_filesize))
+ {
+ $unit = strtolower(substr($max_file_size, -1, 1));
+ $max_file_size = (int) $max_filesize;
+
+ switch ($unit)
+ {
+ case 'g':
+ $max_file_size *= 1024;
+ // no break
+ case 'm':
+ $max_file_size *= 1024;
+ // no break
+ case 'k':
+ $max_file_size *= 1024;
+ // no break
+ }
+ }
+ }
+
+ return $max_file_size;
+ }
}