Page MenuHomeDevCentral

D3870.id10018.diff
No OneTemporary

D3870.id10018.diff

diff --git a/workspaces/src/Engines/Auth/Methods/AzharProvider.php b/workspaces/src/Engines/Auth/Methods/AzharProvider.php
--- a/workspaces/src/Engines/Auth/Methods/AzharProvider.php
+++ b/workspaces/src/Engines/Auth/Methods/AzharProvider.php
@@ -20,6 +20,8 @@
use Waystone\Workspaces\Engines\Auth\AuthenticationMethod;
use Waystone\Workspaces\Engines\I18n\Language;
+use Keruald\OmniTools\HTTP\Requests\Request;
+
use stdClass;
/**
@@ -56,7 +58,7 @@
if ($action == "user.login.azhar.initialize") {
//Redirects user to Azhàr SSO service
$callbackUrl =
- get_server_url() . get_url($this->context->workspace->code)
+ Request::getServerURL() . get_url($this->context->workspace->code)
. '?action=user.login.azhar.success&authenticationMethodId='
. $this->id;
$url = $this->url . '?mode=provider&key=' . $this->clientKey
@@ -150,7 +152,7 @@
* @retrun string the login link
*/
public function getAuthenticationLink () {
- $url = get_server_url() . get_url($this->context->workspace->code)
+ $url = Request::getServerURL() . get_url($this->context->workspace->code)
. '?action=user.login.azhar.initialize&authenticationMethodId=' . $this->id;
return $url;
}
diff --git a/workspaces/src/includes/GlobalFunctions.php b/workspaces/src/includes/GlobalFunctions.php
--- a/workspaces/src/includes/GlobalFunctions.php
+++ b/workspaces/src/includes/GlobalFunctions.php
@@ -2,6 +2,8 @@
use Waystone\Workspaces\Engines\Workspaces\Workspace;
+use Keruald\OmniTools\HTTP\Requests\Request;
+
////////////////////////////////////////////////////////////////////////////////
/// ///
/// Misc helper functions ///
@@ -62,27 +64,6 @@
}
}
-/*
- * Gets server URL
- * @todo find a way to detect https:// on non standard port
- * @return string the server URL
- */
-function get_server_url () {
- if (php_sapi_name() == 'cli') {
- return '';
- }
- switch ($port = $_SERVER['SERVER_PORT']) {
- case '80':
- return "http://$_SERVER[SERVER_NAME]";
-
- case '443':
- return "https://$_SERVER[SERVER_NAME]";
-
- default:
- return "http://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]";
- }
-}
-
/*
* Gets $_SERVER['PATH_INFO'] or computes the equivalent if not defined.
* @return string the relevant URL part
@@ -98,20 +79,20 @@
}
//In other cases, we'll need to get the relevant part of the URL
- $current_url = get_server_url() . $_SERVER['REQUEST_URI'];
+ $current_url = Request::getServerURL() . $_SERVER['REQUEST_URI'];
//Relevant URL part starts after the site URL
$len = strlen($Config['SiteURL']);
//We need to assert it's the correct site
if (substr($current_url, 0, $len) != $Config['SiteURL']) {
- dieprint_r(GENERAL_ERROR, "Edit includes/config.php and specify the correct site URL<br /><strong>Current value:</strong> $Config[SiteURL]<br /><strong>Expected value:</strong> a string starting by " . get_server_url(), "Setup");
+ dieprint_r(GENERAL_ERROR, "Edit includes/config.php and specify the correct site URL<br /><strong>Current value:</strong> $Config[SiteURL]<br /><strong>Expected value:</strong> a string starting by " . Request::getServerURL(), "Setup");
}
if (array_key_exists('REDIRECT_URL', $_SERVER)) {
//With mod_rewrite, we can use REDIRECT_URL
//We take the end of the URL, ie *FROM* $len position
- return substr(get_server_url() . $_SERVER["REDIRECT_URL"], $len);
+ return substr(Request::getServerURL() . $_SERVER["REDIRECT_URL"], $len);
}
//Last possibility: use REQUEST_URI, but remove QUERY_STRING
@@ -119,7 +100,7 @@
//but you need to discard $_SERVER['QUERY_STRING']
//We take the end of the URL, ie *FROM* $len position
- $url = substr(get_server_url() . $_SERVER["REQUEST_URI"], $len);
+ $url = substr(Request::getServerURL() . $_SERVER["REQUEST_URI"], $len);
//But if there are a query string (?action=... we need to discard it)
if ($_SERVER['QUERY_STRING']) {
diff --git a/workspaces/src/includes/config.php b/workspaces/src/includes/config.php
--- a/workspaces/src/includes/config.php
+++ b/workspaces/src/includes/config.php
@@ -21,6 +21,7 @@
use Keruald\Cache\Engines\CacheVoid;
use Keruald\Database\Engines\MySQLiEngine;
+use Keruald\OmniTools\HTTP\Requests\Request;
////////////////////////////////////////////////////////////////////////////////
/// ///
@@ -119,7 +120,7 @@
*
*/
-$Config['SiteURL'] = get_server_url();
+$Config['SiteURL'] = Request::getServerURL();
$Config['BaseURL'] = '';
////////////////////////////////////////////////////////////////////////////////

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 20, 17:25 (20 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3188157
Default Alt Text
D3870.id10018.diff (4 KB)

Event Timeline