From 8d101667fdf4a83a9f42d051d7d80b2229f1b51b Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Tue, 13 Jun 2006 13:16:37 +0000 Subject: [PATCH] =?UTF-8?q?T=C3=A2che=20=20#328:=20la=20fonction=20http=5F?= =?UTF-8?q?lastmodified=20passe=20dans=20js=5Fmenu=5Frubriques,=20seul=20f?= =?UTF-8?q?ichier=20a=20encore=20l'utiliser=20(pas=20tres=20optimalement?= =?UTF-8?q?=20d'ailleurs).=20La=20fonction=20gmoddate=20est=20=C3=A9vacu?= =?UTF-8?q?=C3=A9e,=20sa=20petitesse=20justifiant=20qu'on=20substitue=20so?= =?UTF-8?q?n=20corps=20=C3=A0=20son=20appel.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/exec/js_menu_rubriques.php | 23 ++++++++++++++++ ecrire/inc/utils.php | 45 +++---------------------------- ecrire/public/assembler.php | 4 +-- ecrire/public/compiler.php | 4 +-- 4 files changed, 31 insertions(+), 45 deletions(-) diff --git a/ecrire/exec/js_menu_rubriques.php b/ecrire/exec/js_menu_rubriques.php index 4c85ceb79e..9bbdfa125c 100644 --- a/ecrire/exec/js_menu_rubriques.php +++ b/ecrire/exec/js_menu_rubriques.php @@ -143,6 +143,29 @@ function bandeau_rubrique($id_rubrique, $titre_rubrique, $z = 1) { return $ret; } + +function http_last_modified($lastmodified, $expire = 0) { + if (!$lastmodified) return false; + $headers_only = false; + $gmoddate = gmdate("D, d M Y H:i:s", $lastmodified); + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) + AND !preg_match(',IIS/,', $_SERVER['SERVER_SOFTWARE'])) # MSoft IIS is dumb + { + $if_modified_since = preg_replace('/;.*/', '', + $_SERVER['HTTP_IF_MODIFIED_SINCE']); + $if_modified_since = trim(str_replace('GMT', '', $if_modified_since)); + if ($if_modified_since == $gmoddate) { + include_spip('inc/headers'); + http_status(304); + $headers_only = true; + } + } + @Header ("Last-Modified: ".$gmoddate." GMT"); + if ($expire) + @Header ("Expires: ".gmdate("D, d M Y H:i:s", $expire)." GMT"); + return $headers_only; +} + function exec_js_menu_rubriques_dist() { if (http_last_modified(@filemtime(__FILE__), time() + 24 * 3600)) diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index e2bccba4fc..cf81d3cd98 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -16,7 +16,7 @@ if (!defined("_ECRIRE_INC_VERSION")) return; // Gestion des inclusions et infos repertoires // -# fonction obsolete, assurant la compatilibite ascendante +# fonction obsolete, assurant la compatilibite ascendante. cf include_spip function include_ecrire($file, $silence=false) { # Hack pour etre compatible avec les mes_options qui appellent cette fonction if (!defined('_DIR_INCLUDE')) @@ -76,7 +76,7 @@ function charger_fonction($nom, $dossier='exec', $continue=false) { } // -// une fonction remplacant include_ecrire, et autorisant les surcharges +// une fonction cherchant un fichier dans une liste de repertoires // function include_spip($f, $include = true) { @@ -376,14 +376,8 @@ function self($root = false) { } -// -// Gerer les valeurs meta -// -// Fonction lire_meta abandonnee, remplacee par son contenu. Ne plus utiliser -function lire_meta($nom) { - global $meta; - return $meta[$nom]; -} +// Fonction abandonnee. . Ne plus utiliser, remplacer par son contenu +function lire_meta($nom) { global $meta; return $meta[$nom];} // @@ -544,37 +538,6 @@ function cron ($gourmand=false) { } } - -// -// Entetes les plus courants (voir inc_headers.php pour les autres) -// - -function http_gmoddate($lastmodified) { - return gmdate("D, d M Y H:i:s", $lastmodified); -} - -function http_last_modified($lastmodified, $expire = 0) { - if (!$lastmodified) return false; - $headers_only = false; - $gmoddate = http_gmoddate($lastmodified); - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) - AND !preg_match(',IIS/,', $_SERVER['SERVER_SOFTWARE'])) # MSoft IIS is dumb - { - $if_modified_since = preg_replace('/;.*/', '', - $_SERVER['HTTP_IF_MODIFIED_SINCE']); - $if_modified_since = trim(str_replace('GMT', '', $if_modified_since)); - if ($if_modified_since == $gmoddate) { - include_spip('inc/headers'); - http_status(304); - $headers_only = true; - } - } - @Header ("Last-Modified: ".$gmoddate." GMT"); - if ($expire) - @Header ("Expires: ".http_gmoddate($expire)." GMT"); - return $headers_only; -} - // envoyer le navigateur sur une nouvelle adresse // en evitant les attaques par la redirection (souvent indique par 1 $_GET) diff --git a/ecrire/public/assembler.php b/ecrire/public/assembler.php index 6d6cd9139a..5317879dac 100644 --- a/ecrire/public/assembler.php +++ b/ecrire/public/assembler.php @@ -101,7 +101,7 @@ function assembler_page ($fond) { $since = preg_replace('/;.*/', '', $GLOBALS['HTTP_IF_MODIFIED_SINCE']); $since = str_replace('GMT', '', $since); - if (trim($since) == http_gmoddate($lastmodified)) { + if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { $page['status'] = 304; $headers_only = true; } @@ -160,7 +160,7 @@ function assembler_page ($fond) { } if ($lastmodified) - $page['entetes']["Last-Modified"]=http_gmoddate($lastmodified)." GMT"; + $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; return $page; diff --git a/ecrire/public/compiler.php b/ecrire/public/compiler.php index f44268c7af..2ec2f31047 100644 --- a/ecrire/public/compiler.php +++ b/ecrire/public/compiler.php @@ -724,8 +724,8 @@ function public_compiler_dist($squelette, $nom, $gram, $sourcefile) { $code = "<"."?php /* * Squelette : $sourcefile - * Date : ".http_gmoddate(@filemtime($sourcefile))." GMT - * Compile : ".http_gmoddate(time())." GMT ($secondes) + * Date : ".gmdate("D, d M Y H:i:s", @filemtime($sourcefile))." GMT + * Compile : ".gmdate("D, d M Y H:i:s", time())." GMT ($secondes) * " . (!$boucles ? "Pas de boucle" : ("Boucles : " . join (', ', array_keys($boucles)))) ." */ " . -- GitLab