aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-06-02 11:48:55 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-09-09 08:27:46 +0200
commita53825ad760cc8437d8c26eb1f947622c0fcf229 (patch)
tree62feed6b143c62736d96a50124440dd600534820 /phpBB/phpbb
parenteb11973ea8af41623a9e6e6c320cb1fb0df7a222 (diff)
downloadforums-a53825ad760cc8437d8c26eb1f947622c0fcf229.tar
forums-a53825ad760cc8437d8c26eb1f947622c0fcf229.tar.gz
forums-a53825ad760cc8437d8c26eb1f947622c0fcf229.tar.bz2
forums-a53825ad760cc8437d8c26eb1f947622c0fcf229.tar.xz
forums-a53825ad760cc8437d8c26eb1f947622c0fcf229.zip
[ticket/13904] No longer use fileerror class for extending filespec class
PHPBB3-13904
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/files/filespec.php14
-rw-r--r--phpBB/phpbb/files/upload.php27
2 files changed, 23 insertions, 18 deletions
diff --git a/phpBB/phpbb/files/filespec.php b/phpBB/phpbb/files/filespec.php
index 2fdba2d793..d14c9a226d 100644
--- a/phpBB/phpbb/files/filespec.php
+++ b/phpBB/phpbb/files/filespec.php
@@ -119,6 +119,20 @@ class filespec
}
/**
+ * Set error in error array
+ *
+ * @param mixed $error Content for error array
+ *
+ * @return \phpbb\files\filespec This instance of the filespec class
+ */
+ public function set_error($error)
+ {
+ $this->error[] = $error;
+
+ return $this;
+ }
+
+ /**
* Cleans destination filename
*
* @param real|unique|unique_ext $mode real creates a realname, filtering some characters, lowering every character. Unique creates an unique filename
diff --git a/phpBB/phpbb/files/upload.php b/phpBB/phpbb/files/upload.php
index 7ca29efe1a..291cdb266c 100644
--- a/phpBB/phpbb/files/upload.php
+++ b/phpBB/phpbb/files/upload.php
@@ -306,14 +306,12 @@ class upload
if (!preg_match('#^(https?://).*?\.(' . implode('|', $this->allowed_extensions) . ')$#i', $upload_url, $match))
{
- $file = new fileerror($user->lang[$this->error_prefix . 'URL_INVALID']);
- return $file;
+ return $this->factory->get('filespec')->set_error($user->lang[$this->error_prefix . 'URL_INVALID']);
}
if (empty($match[2]))
{
- $file = new fileerror($user->lang[$this->error_prefix . 'URL_INVALID']);
- return $file;
+ return $this->factory->get('filespec')->set_error($user->lang[$this->error_prefix . 'URL_INVALID']);e;
}
$url = parse_url($upload_url);
@@ -362,8 +360,7 @@ class upload
if (!($fsock = @fsockopen($host, $port, $errno, $errstr)))
{
- $file = new fileerror($user->lang[$this->error_prefix . 'NOT_UPLOADED']);
- return $file;
+ return $this->factory->get('filespec')->set_error($user->lang[$this->error_prefix . 'NOT_UPLOADED']);
}
// Make sure $path not beginning with /
@@ -404,8 +401,7 @@ class upload
{
$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;
+ return $this->factory->get('filespec')->set_error(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']));
}
$data .= $block;
@@ -432,14 +428,12 @@ class upload
{
$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;
+ return $this->factory->get('filespec')->set_error(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']));
}
}
else if (stripos($line, '404 not found') !== false)
{
- $file = new fileerror($user->lang[$this->error_prefix . 'URL_NOT_FOUND']);
- return $file;
+ return $this->factory->get('filespec')->set_error($this->error_prefix . 'URL_NOT_FOUND');
}
}
}
@@ -449,16 +443,14 @@ class upload
// 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;
+ return $this->factory->get('filespec')->set_error($this->error_prefix . 'REMOTE_UPLOAD_TIMEOUT');
}
}
@fclose($fsock);
if (empty($data))
{
- $file = new fileerror($user->lang[$this->error_prefix . 'EMPTY_REMOTE_DATA']);
- return $file;
+ return $this->factory->get('filespec')->set_error($this->error_prefix . 'EMPTY_REMOTE_DATA');
}
$tmp_path = (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') ? false : $phpbb_root_path . 'cache';
@@ -466,8 +458,7 @@ class upload
if (!($fp = @fopen($filename, 'wb')))
{
- $file = new fileerror($user->lang[$this->error_prefix . 'NOT_UPLOADED']);
- return $file;
+ return $this->factory->get('filespec')->set_error($this->error_prefix . 'NOT_UPLOADED');
}
$upload_ary['size'] = fwrite($fp, $data);