From b6d10d259db28e554703248d4e917e0c7cf63a23 Mon Sep 17 00:00:00 2001 From: Matthieu Marcillaud <marcimat@rezo.net> Date: Wed, 4 Oct 2017 14:55:52 +0000 Subject: [PATCH] =?UTF-8?q?1)=20=C3=89viter=20des=20notices=20PHP=20en=20C?= =?UTF-8?q?LI=202)=20=C3=89viter=20de=20prendre=20'PHP=5FSELF',=20en=20CLI?= =?UTF-8?q?=20comme=20=C3=A9tant=20l=E2=80=99URL=20(c=E2=80=99est=20le=20c?= =?UTF-8?q?hemin=20du=20script),=20sinon,=20notamment=20le=20calcul=20des?= =?UTF-8?q?=20urls=20absolues=20devient=20fauss=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc/utils.php | 8 ++++---- ecrire/public/assembler.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 1af21b9442..1e5375f1b9 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -1881,7 +1881,7 @@ function url_de_base($profondeur = null) { } // note : HTTP_HOST contient le :port si necessaire - $host = $_SERVER['HTTP_HOST']; + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { $host = $GLOBALS['meta']['adresse_site']; @@ -1912,8 +1912,8 @@ function url_de_base($profondeur = null) { if (isset($_SERVER['REQUEST_URI'])) { $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; } else { - $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; - if ($_SERVER['QUERY_STRING'] + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; + if (!empty($_SERVER['QUERY_STRING']) and !strpos($_SERVER['REQUEST_URI'], '?') ) { $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; @@ -2521,7 +2521,7 @@ function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null if (isset($_SERVER['REQUEST_URI'])) { $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; } else { - $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; if (!empty($_SERVER['QUERY_STRING']) and !strpos($_SERVER['REQUEST_URI'], '?') ) { diff --git a/ecrire/public/assembler.php b/ecrire/public/assembler.php index c4855cfef0..46d519e89d 100644 --- a/ecrire/public/assembler.php +++ b/ecrire/public/assembler.php @@ -215,7 +215,7 @@ function calculer_contexte_implicite() { } $contexte_implicite = array( 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? - 'host' => $_SERVER['HTTP_HOST'], + 'host' => (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null), 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), 'espace' => test_espace_prive(), 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), -- GitLab