From d19565756add78e246f193b4cffd104836b87fb4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 6 Apr 2010 15:30:54 +0200 Subject: [feature/remote_upload-filesize] When transferring files from a remote webserver, abort the transfer as soon as the allowed filesize has been exceeded. PHPBB3-9517 --- phpBB/includes/functions_upload.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_upload.php') diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 054af29045..40872f0425 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -775,7 +775,18 @@ class fileupload { if ($get_info) { - $data .= @fread($fsock, 1024); + $block = @fread($fsock, 1024); + $filesize += strlen($block); + + if ($this->max_filesize && $filesize > $this->max_filesize) + { + $max_filesize = get_formatted_filesize($this->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 { -- cgit v1.2.1