From 4a92b95ffba4c735aea77141c21b9164b789f487 Mon Sep 17 00:00:00 2001 From: All Unser Miranda Date: Mon, 22 Oct 2012 14:26:07 -0200 Subject: [PATCH] Updated the method to get the server protocol This edit will make the HTTP protocol to be automatic, so if you have a SSL Certificate, the Monstra will know and will make your urls more friendly. --- monstra/helpers/url.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/monstra/helpers/url.php b/monstra/helpers/url.php index 66a3d71..c25faea 100644 --- a/monstra/helpers/url.php +++ b/monstra/helpers/url.php @@ -93,7 +93,8 @@ * @return string */ public static function find($url) { - $pos = strpos($url, 'http://'); + $https = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == strtolower('on')) ? 'https://' : 'http://'; + $pos = strpos($url, $https); if ($pos === false) { $url_output = Option::get('siteurl') . $url; } else { $url_output = $url; } return $url_output; } @@ -109,7 +110,7 @@ * @return string */ public static function base() { - return 'http://' . rtrim(rtrim($_SERVER['HTTP_HOST'], '\\/') . dirname($_SERVER['PHP_SELF']), '\\/'); + $https = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == strtolower('on')) ? 'https://' : 'http://'; + return $https . rtrim(rtrim($_SERVER['HTTP_HOST'], '\\/') . dirname($_SERVER['PHP_SELF']), '\\/'); } - } \ No newline at end of file