From b9a455b5d5f489d54dfa05e5da739714971f215d Mon Sep 17 00:00:00 2001
From: Fil <fil@rezo.net>
Date: Fri, 24 Feb 2006 12:00:59 +0000
Subject: [PATCH] generer_url_...() et https (corrige notamment #104)

---
 ecrire/inc_utils.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ecrire/inc_utils.php b/ecrire/inc_utils.php
index 19d3f412da..d62284ed76 100644
--- a/ecrire/inc_utils.php
+++ b/ecrire/inc_utils.php
@@ -661,7 +661,6 @@ function charger_generer_url() {
 // l'URL de base du site, sans se fier a meta(adresse_site) qui peut etre fausse
 // (sites a plusieurs noms d'hotes, deplacements, erreurs)
 function url_de_base() {
-	global $_SERVER;
 	global $REQUEST_URI;
 
 	static $url;
@@ -669,9 +668,12 @@ function url_de_base() {
 	if ($url)
 		return $url;
 
-	$http = (substr($_SERVER["SCRIPT_URI"],0,5) == 'https') ? 'https' : 'http';
+	$http = (
+		substr($_SERVER["SCRIPT_URI"],0,5) == 'https'
+		OR $_SERVER['HTTPS']
+	) ? 'https' : 'http';
 	# note : HTTP_HOST contient le :port si necessaire
-	$myself = $http.'://' .$_SERVER['HTTP_HOST'].$REQUEST_URI;
+	$myself = $http.'://'.$_SERVER['HTTP_HOST'].$REQUEST_URI;
 
 	# supprimer (ecrire/)?xxxxx
 	$url = preg_replace(',/('._DIR_RESTREINT_ABS.')?[^/]*$,', '/', $myself);
-- 
GitLab