aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-02-04 17:10:59 +0100
committerMarc Alexander <admin@m-a-styles.de>2016-02-04 17:14:48 +0100
commitfd9c05309d186332728b533467aaecad5c543c52 (patch)
treedc5738e6d3ab1ee32ffa6c3145429fc88eb2c979 /phpBB/phpbb
parent9a5b2d5e66c2b9bea16f22589b0a2507f766fd9d (diff)
downloadforums-fd9c05309d186332728b533467aaecad5c543c52.tar
forums-fd9c05309d186332728b533467aaecad5c543c52.tar.gz
forums-fd9c05309d186332728b533467aaecad5c543c52.tar.bz2
forums-fd9c05309d186332728b533467aaecad5c543c52.tar.xz
forums-fd9c05309d186332728b533467aaecad5c543c52.zip
[ticket/14448] Let user decide if remote upload certs should be checked
Also fixed some minor issues like coding style. PHPBB3-14448
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/db/migration/data/v320/remote_upload_validation.php31
-rw-r--r--phpBB/phpbb/files/types/remote.php34
2 files changed, 45 insertions, 20 deletions
diff --git a/phpBB/phpbb/db/migration/data/v320/remote_upload_validation.php b/phpBB/phpbb/db/migration/data/v320/remote_upload_validation.php
new file mode 100644
index 0000000000..d61f6b96fd
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v320/remote_upload_validation.php
@@ -0,0 +1,31 @@
+<?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.
+*
+*/
+
+namespace phpbb\db\migration\data\v320;
+
+class remote_upload_validation extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v320\v320a2',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.add', array('remote_upload_verify', '0')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/files/types/remote.php b/phpBB/phpbb/files/types/remote.php
index f4a4fa70d1..7e5157baa9 100644
--- a/phpBB/phpbb/files/types/remote.php
+++ b/phpBB/phpbb/files/types/remote.php
@@ -14,6 +14,7 @@
namespace phpbb\files\types;
use bantu\IniGetWrapper\IniGetWrapper;
+use phpbb\config\config;
use phpbb\files\factory;
use phpbb\files\filespec;
use phpbb\language\language;
@@ -21,6 +22,9 @@ use phpbb\request\request_interface;
class remote extends base
{
+ /** @var config phpBB config */
+ protected $config;
+
/** @var factory Files factory */
protected $factory;
@@ -42,14 +46,16 @@ class remote extends base
/**
* Construct a form upload type
*
+ * @param config $config phpBB config
* @param factory $factory Files factory
* @param language $language Language class
* @param IniGetWrapper $php_ini ini_get() wrapper
* @param request_interface $request Request object
* @param string $phpbb_root_path phpBB root path
*/
- public function __construct(factory $factory, language $language, IniGetWrapper $php_ini, request_interface $request, $phpbb_root_path)
+ public function __construct(config $config, factory $factory, language $language, IniGetWrapper $php_ini, request_interface $request, $phpbb_root_path)
{
+ $this->config = $config;
$this->factory = $factory;
$this->language = $language;
$this->php_ini = $php_ini;
@@ -97,8 +103,9 @@ class remote extends base
$remote_max_filesize = $this->get_max_file_size();
$guzzle_options = [
- 'timeout' => $this->upload->upload_timeout,
- 'connect_timeout' => $this->upload->upload_timeout,
+ 'timeout' => $this->upload->upload_timeout,
+ 'connect_timeout' => $this->upload->upload_timeout,
+ 'verify' => !empty($this->config['remote_upload_verify']),
];
$client = new \GuzzleHttp\Client($guzzle_options);
@@ -118,24 +125,11 @@ class remote extends base
}
else
{
- if (strpos($requestException->getMessage(), 'cURL error 60') !== false)
- {
- // Work around non existent CA file
- try
- {
- $response = $client->get($upload_url, array_merge($guzzle_options, ['verify' => false]));
- }
- catch (\GuzzleHttp\Exception\RequestException $requestException)
- {
- return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED'));
- }
- }
- else
- {
- return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED'));
- }
+ return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED'));
}
- } catch (\Exception $e) {
+ }
+ catch (\Exception $e)
+ {
return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED'));
}