From ded56b8a3f4e52c8fdb593d9cc71b51f2efbc63f Mon Sep 17 00:00:00 2001 From: nao-pon Date: Thu, 3 Nov 2016 20:56:50 +0900 Subject: [PATCH] [php:core] add public static function `getConnectorUrl()` --- php/elFinder.class.php | 18 ++++++++++++++++++ php/elFinderFlysystemGoogleDriveNetmount.php | 18 +----------------- php/elFinderVolumeDropbox.class.php | 17 +---------------- php/elFinderVolumeGoogleDrive.class.php | 20 +------------------- 4 files changed, 21 insertions(+), 52 deletions(-) diff --git a/php/elFinder.class.php b/php/elFinder.class.php index 4786768d7..ede8bf251 100644 --- a/php/elFinder.class.php +++ b/php/elFinder.class.php @@ -3168,4 +3168,22 @@ class elFinder { return (int)$val; } + /** + * Get script url. + * + * @return string full URL + * + * @author Naoki Sawada + */ + public static function getConnectorUrl() { + $https = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'); + $url = ($https ? 'https://' : 'http://') + .$_SERVER['SERVER_NAME'] // host + .(((! $https && $_SERVER['SERVER_PORT'] == 80) || ($https && $_SERVER['SERVER_PORT'] == 443)) ? '' : (':' . $_SERVER['SERVER_PORT'])) // port + .$_SERVER['REQUEST_URI']; // path & query + list($url) = explode('?', $url); + + return $url; + } + } // END class diff --git a/php/elFinderFlysystemGoogleDriveNetmount.php b/php/elFinderFlysystemGoogleDriveNetmount.php index a5321b8b7..51c35004b 100644 --- a/php/elFinderFlysystemGoogleDriveNetmount.php +++ b/php/elFinderFlysystemGoogleDriveNetmount.php @@ -123,7 +123,7 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst if ($options['user'] === 'init') { if (empty($options['url'])) { - $options['url'] = $this->getConnectorUrl(); + $options['url'] = elFinder::getConnectorUrl(); } $callback = $options['url'] @@ -320,22 +320,6 @@ class elFinderVolumeFlysystemGoogleDriveNetmount extends \Hypweb\elFinderFlysyst return $res; } - /** - * Get script url - * - * @return string full URL - * @author Naoki Sawada - */ - private function getConnectorUrl() - { - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') - . $_SERVER['SERVER_NAME'] // host - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port - . $_SERVER['REQUEST_URI']; // path & query - list($url) = explode('?', $url); - return $url; - } - /** * @inheritdoc */ diff --git a/php/elFinderVolumeDropbox.class.php b/php/elFinderVolumeDropbox.class.php index 983e9a162..689f2e1cb 100644 --- a/php/elFinderVolumeDropbox.class.php +++ b/php/elFinderVolumeDropbox.class.php @@ -189,7 +189,7 @@ class elFinderVolumeDropbox extends elFinderVolumeDriver { } } if (strpos($options['url'], 'http') !== 0 ) { - $options['url'] = $this->getConnectorUrl(); + $options['url'] = elFinder::getConnectorUrl(); } $callback = $options['url'] . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; @@ -259,21 +259,6 @@ class elFinderVolumeDropbox extends elFinderVolumeDriver { return true; } - /** - * Get script url - * - * @return string full URL - * @author Naoki Sawada - */ - private function getConnectorUrl() { - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') - . $_SERVER['SERVER_NAME'] // host - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port - . $_SERVER['REQUEST_URI']; // path & query - list($url) = explode('?', $url); - return $url; - } - /*********************************************************************/ /* INIT AND CONFIGURE */ /*********************************************************************/ diff --git a/php/elFinderVolumeGoogleDrive.class.php b/php/elFinderVolumeGoogleDrive.class.php index 6e6920f4b..c01811862 100644 --- a/php/elFinderVolumeGoogleDrive.class.php +++ b/php/elFinderVolumeGoogleDrive.class.php @@ -726,7 +726,7 @@ class elFinderVolumeGoogleDrive extends elFinderVolumeDriver if ($options['user'] === 'init') { if (empty($options['url'])) { - $options['url'] = $this->getConnectorUrl(); + $options['url'] = elFinder::getConnectorUrl(); } $callback = $options['url'] @@ -853,24 +853,6 @@ class elFinderVolumeGoogleDrive extends elFinderVolumeDriver return true; } - /** - * Get script url. - * - * @return string full URL - * - * @author Naoki Sawada - */ - private function getConnectorUrl() - { - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') - .$_SERVER['SERVER_NAME'] // host -.($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) // port -.$_SERVER['REQUEST_URI']; // path & query - list($url) = explode('?', $url); - - return $url; - } - /*********************************************************************/ /* INIT AND CONFIGURE */ /*********************************************************************/