diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-05-31 11:54:58 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-05-31 11:54:58 +0200 |
commit | 0261a9acffd47beb5b40bfa58d987e44b5ebf0c3 (patch) | |
tree | 89e0a2f3a0189b88b1cf46c8b7e3437606f9e96f /phpBB/includes/functions_upload.php | |
parent | 275dabbc4f7e412d6f21266d43708635f63384e2 (diff) | |
parent | c494abc8c765f2398b0b782fc6979a5e033bb0f5 (diff) | |
download | forums-0261a9acffd47beb5b40bfa58d987e44b5ebf0c3.tar forums-0261a9acffd47beb5b40bfa58d987e44b5ebf0c3.tar.gz forums-0261a9acffd47beb5b40bfa58d987e44b5ebf0c3.tar.bz2 forums-0261a9acffd47beb5b40bfa58d987e44b5ebf0c3.tar.xz forums-0261a9acffd47beb5b40bfa58d987e44b5ebf0c3.zip |
Merge remote-tracking branch 'naderman/ticket/10908' into develop-olympus
* naderman/ticket/10908:
[ticket/10908] Document that 0 filesize configuration means limited by PHP
[ticket/10908] Download files only up to max_upload_filesize if limit is 0
Diffstat (limited to 'phpBB/includes/functions_upload.php')
-rw-r--r-- | phpBB/includes/functions_upload.php | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index d5bbd80242..73ac1df2d2 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -751,6 +751,31 @@ class fileupload $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 = ''; @@ -779,9 +804,9 @@ class fileupload $block = @fread($fsock, 1024); $filesize += strlen($block); - if ($this->max_filesize && $filesize > $this->max_filesize) + if ($remote_max_filesize && $filesize > $remote_max_filesize) { - $max_filesize = get_formatted_filesize($this->max_filesize, false); + $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; @@ -807,9 +832,9 @@ class fileupload { $length = (int) str_replace('content-length: ', '', strtolower($line)); - if ($length && $length > $this->max_filesize) + if ($remote_max_filesize && $length && $length > $remote_max_filesize) { - $max_filesize = get_formatted_filesize($this->max_filesize, false); + $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; |