[php:core] add public static function getConnectorUrl()

This commit is contained in:
nao-pon
2016-11-03 20:56:50 +09:00
parent 68234b9934
commit ded56b8a3f
4 changed files with 21 additions and 52 deletions
+18
View File
@@ -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
+1 -17
View File
@@ -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
*/
+1 -16
View File
@@ -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 */
/*********************************************************************/
+1 -19
View File
@@ -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 */
/*********************************************************************/