From e7714ce11add5709e2f61fa9553ce2fbd977d19f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 15 Dec 2014 13:57:00 +0100 Subject: [PATCH] Moved supportsSSL() from HTTPRequest to RemoteFile --- .../lib/data/package/PackageAction.class.php | 5 ++-- .../files/lib/system/io/RemoteFile.class.php | 27 +++++++++++++++++++ .../files/lib/util/HTTPRequest.class.php | 27 ------------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/wcfsetup/install/files/lib/data/package/PackageAction.class.php b/wcfsetup/install/files/lib/data/package/PackageAction.class.php index 70fd45f324..51768848ea 100644 --- a/wcfsetup/install/files/lib/data/package/PackageAction.class.php +++ b/wcfsetup/install/files/lib/data/package/PackageAction.class.php @@ -3,10 +3,11 @@ namespace wcf\data\package; use wcf\data\AbstractDatabaseObjectAction; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; +use wcf\system\io\RemoteFile; use wcf\system\request\LinkHandler; use wcf\system\WCF; -use wcf\util\HTTPRequest; use wcf\util\JSON; +use wcf\util\HTTPRequest; /** * Executes package-related actions. @@ -79,7 +80,7 @@ class PackageAction extends AbstractDatabaseObjectAction { * @return array */ public function searchForPurchasedItems() { - if (!HTTPRequest::supportSSL()) { + if (!RemoteFile::supportsSSL()) { return array( 'noSSL' => WCF::getLanguage()->get('wcf.acp.pluginStore.api.noSSL') ); diff --git a/wcfsetup/install/files/lib/system/io/RemoteFile.class.php b/wcfsetup/install/files/lib/system/io/RemoteFile.class.php index 4ff441d42c..da47f6a843 100644 --- a/wcfsetup/install/files/lib/system/io/RemoteFile.class.php +++ b/wcfsetup/install/files/lib/system/io/RemoteFile.class.php @@ -37,6 +37,12 @@ class RemoteFile extends File { */ protected $errorDesc = ''; + /** + * true if PHP supports SSL/TLS + * @var boolean + */ + private static $hasSSLSupport = null; + /** * Opens a new connection to a remote host. * @@ -94,4 +100,25 @@ class RemoteFile extends File { public function hasTLSSupport() { return function_exists('stream_socket_enable_crypto'); } + + /** + * Returns true if PHP supports SSL/TLS. + * + * @return boolean + */ + public static function supportsSSL() { + if (static::$hasSSLSupport === null) { + static::$hasSSLSupport = false; + + $transports = stream_get_transports(); + foreach ($transports as $transport) { + if (preg_match('~^(ssl(v[23])?|tls(v[0-9\.]+)?)$~', $transport)) { + static::$hasSSLSupport = true; + break; + } + } + } + + return static::$hasSSLSupport; + } } diff --git a/wcfsetup/install/files/lib/util/HTTPRequest.class.php b/wcfsetup/install/files/lib/util/HTTPRequest.class.php index c1a02bfc28..867eb942bd 100644 --- a/wcfsetup/install/files/lib/util/HTTPRequest.class.php +++ b/wcfsetup/install/files/lib/util/HTTPRequest.class.php @@ -128,12 +128,6 @@ final class HTTPRequest { */ private $statusCode = 0; - /** - * true if PHP supports SSL/TLS - * @var boolean - */ - private static $hasSSLSupport = null; - /** * Constructs a new instance of HTTPRequest. * @@ -607,25 +601,4 @@ final class HTTPRequest { $this->replyBody = ''; $this->statusCode = 0; } - - /** - * Returns true if PHP supports SSL/TLS. - * - * @return boolean - */ - public static function supportSSL() { - if (static::$hasSSLSupport === null) { - static::$hasSSLSupport = false; - - $transports = stream_get_transports(); - foreach ($transports as $transport) { - if (preg_match('~^(ssl(v[23])?|tls(v[0-9\.]+)?)$~', $transport)) { - static::$hasSSLSupport = true; - break; - } - } - } - - return static::$hasSSLSupport; - } } -- 2.20.1