Skip to content
Extraits de code Groupes Projets
Valider 12344d91 rédigé par Antoine Pitrou's avatar Antoine Pitrou
Parcourir les fichiers

"Last-Modified" et aide en ligne

parent 165d0eb6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -9,10 +9,48 @@ if (file_exists("inc_connect.php3")) {
include_ecrire ("inc_lang.php3");
utiliser_langue_visiteur();
if ($var_lang) changer_langue($var_lang);
include_ecrire ("inc_texte.php3");
include_ecrire ("inc_filtres.php3");
// Selection du fichier d'aide correspondant a la langue
function fichier_aide($lang_aide) {
if (@file_exists($fichier_aide = "AIDE/$lang_aide/aide"))
return array($fichier_aide, $lang_aide);
else // reduction ISO du code langue oci_prv_ni => oci_prv => oci
if (ereg("(.*)_", $lang_aide, $regs))
return fichier_aide($regs[1]);
return false;
}
if (!$aide) $aide = 'spip';
$lang_aide = $spip_lang;
// Recuperation du contenu de l'aide demandee
list($fichier_aide, $l) = fichier_aide($lang_aide);
if (!$fichier_aide)
$html = _T('aide_non_disponible');
else {
$lastmodified = filemtime($fichier_aide);
$headers_only = http_last_modified($lastmodified);
if ($headers_only) exit;
$html = join('', file($fichier_aide));
$html = substr($html, strpos($html,"<$aide>") + strlen("<$aide>"));
$html = substr($html, 0, strpos($html, "</$aide>"));
// Localisation des images de l'aide (si disponibles)
$suite = $html;
$html = "";
while (ereg("AIDE/([-_a-zA-Z0-9]+\.(gif|jpg))", $suite, $r)) {
$f = $r[1];
if (file_exists("AIDE/$l/$f")) $f = "$l/$f";
else if (file_exists("AIDE/fr/$f")) $f = "fr/$f";
$p = strpos($suite, $r[0]);
$html .= substr($suite, 0, $p) . "AIDE/$f";
$suite = substr($suite, $p + strlen($r[0]));
}
$html .= $suite;
}
?>
<html>
......@@ -70,13 +108,15 @@ table.spip td {
</head>
<?php
include_ecrire ("inc_texte.php3");
include_ecrire ("inc_filtres.php3");
echo '<body bgcolor="#FFFFFF" text="#000000" TOPMARGIN="24" LEFTMARGIN="24" MARGINWIDTH="24" MARGINHEIGHT="24"';
if ($spip_lang_rtl)
echo " dir='rtl'";
echo ">";
if (!$aide) {
$aide = 'spip';
if ($aide == 'spip') {
echo '<TABLE BORDER=0 WIDTH=100% HEIGHT=60%>
<TR WIDTH=100% HEIGHT=60%>
<TD WIDTH=100% HEIGHT=60% ALIGN="center" VALIGN="middle">
......@@ -88,39 +128,6 @@ if (!$aide) {
</TD></TR></TABLE>';
}
// Selection du fichier d'aide correspondant a la langue
function fichier_aide($lang_aide, $aide) {
if (@file_exists($fichier_aide = "AIDE/$lang_aide/aide")) {
$html = join('', file($fichier_aide));
$html = substr($html, strpos($html,"<$aide>") + strlen("<$aide>"));
$html = substr($html, 0, strpos($html, "</$aide>"));
}
else // reduction ISO du code langue oci_prv_ni => oci_prv => oci
if (ereg("(.*)_", $lang_aide, $regs))
list($html,$lang_aide) = fichier_aide($regs[1], $aide);
return array($html,$lang_aide);
}
$lang_aide = $GLOBALS['spip_lang'];
list($html,$l) = fichier_aide($lang_aide, $aide);
if (!$html)
$html = _T('aide_non_disponible');
// Localisation des images de l'aide (si disponibles)
$suite = $html;
$html = "";
while (ereg("AIDE/([-_a-zA-Z0-9]+\.(gif|jpg))", $suite, $r)) {
$f = $r[1];
if (file_exists("AIDE/$l/$f")) $f = "$l/$f";
else if (file_exists("AIDE/fr/$f")) $f = "fr/$f";
$p = strpos($suite, $r[0]);
$html .= substr($suite, 0, $p) . "AIDE/$f";
$suite = substr($suite, $p + strlen($r[0]));
}
$html .= $suite;
// hack pour que la langue de typo() soit celle de l'aide en ligne
$spip_lang = $lang_aide;
......
......@@ -2,6 +2,10 @@
include ("inc_version.php3");
$lastmodified = filemtime("aide_gauche.php3");
$headers_only = http_last_modified($lastmodified, time() + 24 * 3600);
if ($headers_only) exit;
if (file_exists($flag_ecrire ? "inc_connect.php3" : "ecrire/inc_connect.php3")) {
include_ecrire("inc_auth.php3");
$aide_statut = ($connect_statut == '1comite') ? 'redac' : 'admin';
......@@ -10,6 +14,7 @@ else $aide_statut = 'admin';
include_ecrire("inc_lang.php3");
utiliser_langue_visiteur();
if ($var_lang) changer_langue($var_lang);
?>
<HTML>
......
......@@ -2,6 +2,10 @@
include ("inc_version.php3");
$lastmodified = filemtime("aide_index.php3");
$headers_only = http_last_modified($lastmodified, time() + 24 * 3600);
if ($headers_only) exit;
// Recuperer les infos de langue (preferences auteur), si possible
if (file_exists("inc_connect.php3")) {
include_ecrire ("inc_auth.php3");
......@@ -9,14 +13,15 @@ if (file_exists("inc_connect.php3")) {
include_ecrire("inc_lang.php3");
utiliser_langue_visiteur();
if ($var_lang) changer_langue($var_lang);
echo "<HTML>";
echo "<HEAD>";
echo "<TITLE dir=\"".($spip_lang_rtl ? 'rtl' : 'ltr')."\">"._T('info_aide_en_ligne')."</TITLE>";
echo "</HEAD>";
$frame_menu = "<frame src=\"aide_gauche.php3?aide=$aide&les_rub=$les_rub#$ancre\" name=\"gauche\" scrolling=\"auto\" noresize>\n";
$frame_body = "<frame src=\"aide_droite.php3?aide=$aide\" name=\"droite\" scrolling=\"auto\" noresize>\n";
$frame_menu = "<frame src=\"aide_gauche.php3?aide=$aide&les_rub=$les_rub&var_lang=$spip_lang#$ancre\" name=\"gauche\" scrolling=\"auto\" noresize>\n";
$frame_body = "<frame src=\"aide_droite.php3?aide=$aide&var_lang=$spip_lang\" name=\"droite\" scrolling=\"auto\" noresize>\n";
if ($spip_lang_rtl) {
echo '<frameset cols="*,160" border="0" frameborder="0" framespacing="0">';
......
......@@ -13,11 +13,11 @@ utiliser_langue_visiteur();
// Aide
//
function aide($aide='') {
global $couleur_foncee, $spip_lang_rtl, $dir_ecrire;
global $couleur_foncee, $spip_lang, $spip_lang_rtl, $dir_ecrire;
if (!$aide) return;
return "&nbsp;&nbsp;<a class='aide' href=\"".$dir_ecrire."aide_index.php3?aide=$aide\" target=\"spip_aide\" ".
return "&nbsp;&nbsp;<a class='aide' href=\"".$dir_ecrire."aide_index.php3?aide=$aide&var_lang=$spip_lang\" target=\"spip_aide\" ".
"onclick=\"javascript:window.open(this.href, 'spip_aide', 'scrollbars=yes, ".
"resizable=yes, width=740, height=580'); return false;\"><img ".
"src=\"img_pack/aide.gif\" alt=\""._T('info_image_aide')."\" ".
......@@ -1336,7 +1336,7 @@ function debut_page($titre = "", $rubrique = "asuivre", $sous_rubrique = "asuivr
global $connect_toutes_rubriques;
global $auth_can_disconnect, $connect_login;
global $options, $spip_display, $spip_ecran;
global $spip_lang_rtl;
global $spip_lang, $spip_lang_rtl;
$activer_messagerie = lire_meta("activer_messagerie");
global $clean_link;
......@@ -1399,7 +1399,7 @@ function debut_page($titre = "", $rubrique = "asuivre", $sous_rubrique = "asuivr
echo "</tr></table>\n";
echo "<table class='droite'><tr>\n";
icone_bandeau_principal (_T('icone_aide_ligne'), "javascript:window.open('aide_index.php3', 'aide_spip', 'scrollbars=yes,resizable=yes,width=740,height=580');", "aide-48$spip_lang_rtl.gif", "vide", "", "aide_index.php3");
icone_bandeau_principal (_T('icone_aide_ligne'), "javascript:window.open('aide_index.php3?var_lang=$spip_lang', 'aide_spip', 'scrollbars=yes,resizable=yes,width=740,height=580');", "aide-48$spip_lang_rtl.gif", "vide", "", "aide_index.php3?var_lang=$spip_lang");
icone_bandeau_principal (_T('icone_visiter_site'), "$adresse_site", "visiter-48$spip_lang_rtl.gif");
echo "</tr></table>\n";
......
......@@ -378,6 +378,21 @@ function http_status($status) {
else Header("HTTP/1.0 ".$status_string[$status]);
}
function http_last_modified($lastmodified, $expire = 0) {
$gmoddate = gmdate("D, d M Y H:i:s", $lastmodified);
if ($GLOBALS['HTTP_IF_MODIFIED_SINCE']) {
$if_modified_since = ereg_replace(';.*$', '', $GLOBALS['HTTP_IF_MODIFIED_SINCE']);
$if_modified_since = trim(str_replace('GMT', '', $if_modified_since));
if ($if_modified_since == $gmoddate) {
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;
}
$flag_upload = (!$flag_get_cfg_var || (get_cfg_var('upload_max_filesize') > 0));
......
......@@ -9,15 +9,7 @@
// En-tetes
$lastmodified = @filemtime("spip_style.php3");
$gmoddate = gmdate("D, d M Y H:i:s", $lastmodified);
$if_modified_since = ereg_replace(';.*$', '', $HTTP_IF_MODIFIED_SINCE);
$if_modified_since = trim(str_replace('GMT', '', $if_modified_since));
if ($if_modified_since == $gmoddate) {
http_status(304);
$headers_only = true;
}
@Header ("Last-Modified: ".$gmoddate." GMT");
@Header ("Expires: ".gmdate("D, d M Y H:i:s", $lastmodified + 7 * 24 * 3600)." GMT");
$headers_only = http_last_modified($lastmodified, time() + 24 * 3600);
@Header ("Content-Type: text/css");
if ($headers_only) exit;
......
......@@ -166,17 +166,8 @@ $effacer_cache |= $ecraser_cache; // ecraser le cache de l'article x s'il n'est
// Envoyer les entetes
$headers_only = ($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'HEAD');
if (!$effacer_cache && !$flag_dynamique && $recalcul != 'oui' && !$HTTP_COOKIE_VARS['spip_admin']) {
if ($lastmodified) {
$gmoddate = gmdate("D, d M Y H:i:s", $lastmodified);
$if_modified_since = ereg_replace(';.*$', '', $HTTP_IF_MODIFIED_SINCE);
$if_modified_since = trim(str_replace('GMT', '', $if_modified_since));
if ($if_modified_since == $gmoddate) {
http_status(304);
$headers_only = true;
}
@Header ("Last-Modified: ".$gmoddate." GMT");
@Header ("Expires: ".gmdate("D, d M Y H:i:s", $lastmodified + $delais)." GMT");
}
if ($lastmodified)
$headers_only |= http_last_modified($lastmodified, $lastmodified + $delais);
}
else {
@Header("Expires: 0");
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter