aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Request.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2015-05-30 18:13:32 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2015-05-30 18:13:32 +0200
commit737047296874bf8fbad22c9c030486748cde9943 (patch)
tree1b3877d7a53329a6e5924cb4ea598be41127a072 /lib/Minz/Request.php
parent68172c400ff568629bb9b9f540bf9d239ea9fe8b (diff)
parent27d2b88a19345dfc665dc086d3c2b2e4547e1b7f (diff)
Merge pull request #849 from Alkarex/RssFeed
Minz getBaseUrl correction and RSS template bug
Diffstat (limited to 'lib/Minz/Request.php')
-rw-r--r--lib/Minz/Request.php46
1 files changed, 14 insertions, 32 deletions
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index 6db2e9c7a..b9eda82a5 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -85,44 +85,26 @@ class Minz_Request {
}
/**
- * Retourn le nom de domaine du site
- */
- public static function getDomainName() {
- return $_SERVER['HTTP_HOST'];
- }
-
- /**
* Détermine la base de l'url
* @return la base de l'url
*/
- public static function getBaseUrl() {
+ public static function getBaseUrl($baseUrlSuffix = '') {
$conf = Minz_Configuration::get('system');
- $defaultBaseUrl = $conf->base_url;
- if (!empty($defaultBaseUrl)) {
- return $defaultBaseUrl;
- } elseif (isset($_SERVER['REQUEST_URI'])) {
- return dirname($_SERVER['REQUEST_URI']) . '/';
- } else {
- return '/';
- }
- }
-
- /**
- * Récupère l'URI de la requête
- * @return l'URI
- */
- public static function getURI() {
- if (isset($_SERVER['REQUEST_URI'])) {
- $base_url = self::getBaseUrl();
- $uri = $_SERVER['REQUEST_URI'];
-
- $len_base_url = strlen($base_url);
- $real_uri = substr($uri, $len_base_url);
+ $url = $conf->base_url;
+ if ($url == '' || !preg_match('%^https?://%i', $url)) {
+ $url = 'http';
+ $host = empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'];
+ $port = empty($_SERVER['SERVER_PORT']) ? 80 : $_SERVER['SERVER_PORT'];
+ if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
+ $url .= 's://' . $host . ($port == 443 ? '' : ':' . $port);
+ } else {
+ $url .= '://' . $host . ($port == 80 ? '' : ':' . $port);
+ }
+ $url .= isset($_SERVER['REQUEST_URI']) ? dirname($_SERVER['REQUEST_URI']) : '';
} else {
- $real_uri = '';
+ $url = rtrim($url, '/\\') . $baseUrlSuffix;
}
-
- return $real_uri;
+ return filter_var($url . '/', FILTER_SANITIZE_URL);
}
/**