@@ -79,20 +79,20 @@ discard block |
||
| 79 | 79 | (!$equiv and !spip_cookie_envoye()) or ( |
| 80 | 80 | (!empty($_SERVER['SERVER_SOFTWARE']) |
| 81 | 81 | and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE |
| 82 | - and preg_match('/' . _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SOFTWARE'])) |
|
| 82 | + and preg_match('/'._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE.'/i', $_SERVER['SERVER_SOFTWARE'])) |
|
| 83 | 83 | or (!empty($_SERVER['SERVER_SIGNATURE']) |
| 84 | 84 | and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE |
| 85 | - and preg_match('/' . _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SIGNATURE'])) |
|
| 85 | + and preg_match('/'._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE.'/i', $_SERVER['SERVER_SIGNATURE'])) |
|
| 86 | 86 | or function_exists('apache_getenv') |
| 87 | 87 | or defined('_SERVER_APACHE') |
| 88 | 88 | ) |
| 89 | 89 | ) { |
| 90 | - @header('Location: ' . $url); |
|
| 90 | + @header('Location: '.$url); |
|
| 91 | 91 | $equiv = ''; |
| 92 | 92 | } else { |
| 93 | - @header('Refresh: 0; url=' . $url); |
|
| 93 | + @header('Refresh: 0; url='.$url); |
|
| 94 | 94 | if (isset($GLOBALS['meta']['charset'])) { |
| 95 | - @header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 95 | + @header('Content-Type: text/html; charset='.$GLOBALS['meta']['charset']); |
|
| 96 | 96 | } |
| 97 | 97 | $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>"; |
| 98 | 98 | } |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | html_lang_attributes(), ' |
| 105 | 105 | <head>', |
| 106 | 106 | $equiv, ' |
| 107 | -<title>HTTP ' . $status . '</title> |
|
| 108 | -' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset=' . $GLOBALS['meta']['charset'] . '">' : '') . ' |
|
| 107 | +<title>HTTP ' . $status.'</title> |
|
| 108 | +' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset='.$GLOBALS['meta']['charset'].'">' : '').' |
|
| 109 | 109 | </head> |
| 110 | 110 | <body> |
| 111 | -<h1>HTTP ' . $status . '</h1> |
|
| 111 | +<h1>HTTP ' . $status.'</h1> |
|
| 112 | 112 | <a href="', |
| 113 | 113 | quote_amp($url), |
| 114 | 114 | '">', |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | # en theorie on devrait faire ca tout le temps, mais quand la chaine |
| 145 | 145 | # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne |
| 146 | 146 | if ($url[0] == '?') { |
| 147 | - $url = url_de_base() . $url; |
|
| 147 | + $url = url_de_base().$url; |
|
| 148 | 148 | } |
| 149 | 149 | $url = str_replace('&', '&', $url); |
| 150 | 150 | spip_log("redirige formulaire ajax: $url"); |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | if ($format == 'ajaxform') { |
| 153 | 153 | return [ |
| 154 | 154 | // on renvoie un lien masque qui sera traite par ajaxCallback.js |
| 155 | - '<a href="' . quote_amp($url) . '" name="ajax_redirect" style="display:none;">' . _T('navigateur_pas_redirige') . '</a>', |
|
| 155 | + '<a href="'.quote_amp($url).'" name="ajax_redirect" style="display:none;">'._T('navigateur_pas_redirige').'</a>', |
|
| 156 | 156 | // et un message au cas ou |
| 157 | - '<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>' |
|
| 157 | + '<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>' |
|
| 158 | 158 | ]; |
| 159 | 159 | } else // format message texte, tout en js inline |
| 160 | 160 | { |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>" |
| 164 | 164 | . http_img_pack('loader.svg', '', " class='loader'") |
| 165 | 165 | . '<br />' |
| 166 | - . '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'; |
|
| 166 | + . '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'; |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | header("Content-Type: text/html; charset=$charset"); |
| 224 | 224 | header('Expires: 0'); |
| 225 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 225 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 226 | 226 | header('Cache-Control: no-cache, must-revalidate'); |
| 227 | 227 | header('Pragma: no-cache'); |
| 228 | 228 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -38,133 +38,133 @@ discard block |
||
| 38 | 38 | * @param int $status Code de redirection (301 ou 302) |
| 39 | 39 | **/ |
| 40 | 40 | function redirige_par_entete($url, $equiv = '', $status = 302) { |
| 41 | - if (!in_array($status, [301, 302])) { |
|
| 42 | - $status = 302; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $url = trim(strtr($url, "\n\r", ' ')); |
|
| 46 | - # si l'url de redirection est relative, on la passe en absolue |
|
| 47 | - if (!preg_match(',^(\w+:)?//,', $url)) { |
|
| 48 | - include_spip('inc/filtres_mini'); |
|
| 49 | - $url = url_absolue($url); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - if (defined('_AJAX') and _AJAX) { |
|
| 53 | - $url = parametre_url($url, 'var_ajax_redir', 1, '&'); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - // ne pas laisser passer n'importe quoi dans l'url |
|
| 57 | - $url = str_replace(['<', '"'], ['<', '"'], $url); |
|
| 58 | - $url = str_replace(["\r", "\n", ' '], ['%0D', '%0A', '%20'], $url); |
|
| 59 | - while (strpos($url, '%0A') !== false) { |
|
| 60 | - $url = str_replace('%0A', '', $url); |
|
| 61 | - } |
|
| 62 | - // interdire les url inline avec des pseudo-protocoles : |
|
| 63 | - if ( |
|
| 64 | - (preg_match(',data:,i', $url) and preg_match('/base64\s*,/i', $url)) |
|
| 65 | - or preg_match(',(javascript|mailto):,i', $url) |
|
| 66 | - ) { |
|
| 67 | - $url = './'; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // Il n'y a que sous Apache que setcookie puis redirection fonctionne |
|
| 71 | - include_spip('inc/cookie'); |
|
| 72 | - if (!defined('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE')) { |
|
| 73 | - define('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE', '^(Apache|Cherokee|nginx)'); |
|
| 74 | - } |
|
| 75 | - if (!defined('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE')) { |
|
| 76 | - define('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE', 'Apache|Cherokee|nginx'); |
|
| 77 | - } |
|
| 78 | - if ( |
|
| 79 | - (!$equiv and !spip_cookie_envoye()) or ( |
|
| 80 | - (!empty($_SERVER['SERVER_SOFTWARE']) |
|
| 81 | - and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE |
|
| 82 | - and preg_match('/' . _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SOFTWARE'])) |
|
| 83 | - or (!empty($_SERVER['SERVER_SIGNATURE']) |
|
| 84 | - and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE |
|
| 85 | - and preg_match('/' . _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SIGNATURE'])) |
|
| 86 | - or function_exists('apache_getenv') |
|
| 87 | - or defined('_SERVER_APACHE') |
|
| 88 | - ) |
|
| 89 | - ) { |
|
| 90 | - @header('Location: ' . $url); |
|
| 91 | - $equiv = ''; |
|
| 92 | - } else { |
|
| 93 | - @header('Refresh: 0; url=' . $url); |
|
| 94 | - if (isset($GLOBALS['meta']['charset'])) { |
|
| 95 | - @header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 96 | - } |
|
| 97 | - $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>"; |
|
| 98 | - } |
|
| 99 | - include_spip('inc/lang'); |
|
| 100 | - if ($status != 302) { |
|
| 101 | - http_response_code($status); |
|
| 102 | - } |
|
| 103 | - echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n", |
|
| 104 | - html_lang_attributes(), ' |
|
| 41 | + if (!in_array($status, [301, 302])) { |
|
| 42 | + $status = 302; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $url = trim(strtr($url, "\n\r", ' ')); |
|
| 46 | + # si l'url de redirection est relative, on la passe en absolue |
|
| 47 | + if (!preg_match(',^(\w+:)?//,', $url)) { |
|
| 48 | + include_spip('inc/filtres_mini'); |
|
| 49 | + $url = url_absolue($url); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + if (defined('_AJAX') and _AJAX) { |
|
| 53 | + $url = parametre_url($url, 'var_ajax_redir', 1, '&'); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + // ne pas laisser passer n'importe quoi dans l'url |
|
| 57 | + $url = str_replace(['<', '"'], ['<', '"'], $url); |
|
| 58 | + $url = str_replace(["\r", "\n", ' '], ['%0D', '%0A', '%20'], $url); |
|
| 59 | + while (strpos($url, '%0A') !== false) { |
|
| 60 | + $url = str_replace('%0A', '', $url); |
|
| 61 | + } |
|
| 62 | + // interdire les url inline avec des pseudo-protocoles : |
|
| 63 | + if ( |
|
| 64 | + (preg_match(',data:,i', $url) and preg_match('/base64\s*,/i', $url)) |
|
| 65 | + or preg_match(',(javascript|mailto):,i', $url) |
|
| 66 | + ) { |
|
| 67 | + $url = './'; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // Il n'y a que sous Apache que setcookie puis redirection fonctionne |
|
| 71 | + include_spip('inc/cookie'); |
|
| 72 | + if (!defined('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE')) { |
|
| 73 | + define('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE', '^(Apache|Cherokee|nginx)'); |
|
| 74 | + } |
|
| 75 | + if (!defined('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE')) { |
|
| 76 | + define('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE', 'Apache|Cherokee|nginx'); |
|
| 77 | + } |
|
| 78 | + if ( |
|
| 79 | + (!$equiv and !spip_cookie_envoye()) or ( |
|
| 80 | + (!empty($_SERVER['SERVER_SOFTWARE']) |
|
| 81 | + and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE |
|
| 82 | + and preg_match('/' . _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SOFTWARE'])) |
|
| 83 | + or (!empty($_SERVER['SERVER_SIGNATURE']) |
|
| 84 | + and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE |
|
| 85 | + and preg_match('/' . _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SIGNATURE'])) |
|
| 86 | + or function_exists('apache_getenv') |
|
| 87 | + or defined('_SERVER_APACHE') |
|
| 88 | + ) |
|
| 89 | + ) { |
|
| 90 | + @header('Location: ' . $url); |
|
| 91 | + $equiv = ''; |
|
| 92 | + } else { |
|
| 93 | + @header('Refresh: 0; url=' . $url); |
|
| 94 | + if (isset($GLOBALS['meta']['charset'])) { |
|
| 95 | + @header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 96 | + } |
|
| 97 | + $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>"; |
|
| 98 | + } |
|
| 99 | + include_spip('inc/lang'); |
|
| 100 | + if ($status != 302) { |
|
| 101 | + http_response_code($status); |
|
| 102 | + } |
|
| 103 | + echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n", |
|
| 104 | + html_lang_attributes(), ' |
|
| 105 | 105 | <head>', |
| 106 | - $equiv, ' |
|
| 106 | + $equiv, ' |
|
| 107 | 107 | <title>HTTP ' . $status . '</title> |
| 108 | 108 | ' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset=' . $GLOBALS['meta']['charset'] . '">' : '') . ' |
| 109 | 109 | </head> |
| 110 | 110 | <body> |
| 111 | 111 | <h1>HTTP ' . $status . '</h1> |
| 112 | 112 | <a href="', |
| 113 | - quote_amp($url), |
|
| 114 | - '">', |
|
| 115 | - _T('navigateur_pas_redirige'), |
|
| 116 | - '</a></body></html>'; |
|
| 113 | + quote_amp($url), |
|
| 114 | + '">', |
|
| 115 | + _T('navigateur_pas_redirige'), |
|
| 116 | + '</a></body></html>'; |
|
| 117 | 117 | |
| 118 | - spip_log("redirige $status: $url"); |
|
| 118 | + spip_log("redirige $status: $url"); |
|
| 119 | 119 | |
| 120 | - exit; |
|
| 120 | + exit; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | function redirige_formulaire($url, $equiv = '', $format = 'message') { |
| 124 | - if ( |
|
| 125 | - !_AJAX |
|
| 126 | - and !headers_sent() |
|
| 127 | - and !_request('var_ajax') |
|
| 128 | - ) { |
|
| 129 | - redirige_par_entete(str_replace('&', '&', $url), $equiv); |
|
| 130 | - } // si c'est une ancre, fixer simplement le window.location.hash |
|
| 131 | - elseif ($format == 'ajaxform' and preg_match(',^#[0-9a-z\-_]+$,i', $url)) { |
|
| 132 | - return [ |
|
| 133 | - // on renvoie un lien masque qui sera traite par ajaxCallback.js |
|
| 134 | - "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>", |
|
| 135 | - // et rien dans le message ok |
|
| 136 | - '' |
|
| 137 | - ]; |
|
| 138 | - } else { |
|
| 139 | - // ne pas laisser passer n'importe quoi dans l'url |
|
| 140 | - $url = str_replace(['<', '"'], ['<', '"'], $url); |
|
| 141 | - |
|
| 142 | - $url = strtr($url, "\n\r", ' '); |
|
| 143 | - # en theorie on devrait faire ca tout le temps, mais quand la chaine |
|
| 144 | - # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne |
|
| 145 | - if ($url[0] == '?') { |
|
| 146 | - $url = url_de_base() . $url; |
|
| 147 | - } |
|
| 148 | - $url = str_replace('&', '&', $url); |
|
| 149 | - spip_log("redirige formulaire ajax: $url"); |
|
| 150 | - include_spip('inc/filtres'); |
|
| 151 | - if ($format == 'ajaxform') { |
|
| 152 | - return [ |
|
| 153 | - // on renvoie un lien masque qui sera traite par ajaxCallback.js |
|
| 154 | - '<a href="' . quote_amp($url) . '" name="ajax_redirect" style="display:none;">' . _T('navigateur_pas_redirige') . '</a>', |
|
| 155 | - // et un message au cas ou |
|
| 156 | - '<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>' |
|
| 157 | - ]; |
|
| 158 | - } else // format message texte, tout en js inline |
|
| 159 | - { |
|
| 160 | - return |
|
| 161 | - // ie poste les formulaires dans une iframe, il faut donc rediriger son parent |
|
| 162 | - "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>" |
|
| 163 | - . http_img_pack('loader.svg', '', " class='loader'") |
|
| 164 | - . '<br />' |
|
| 165 | - . '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'; |
|
| 166 | - } |
|
| 167 | - } |
|
| 124 | + if ( |
|
| 125 | + !_AJAX |
|
| 126 | + and !headers_sent() |
|
| 127 | + and !_request('var_ajax') |
|
| 128 | + ) { |
|
| 129 | + redirige_par_entete(str_replace('&', '&', $url), $equiv); |
|
| 130 | + } // si c'est une ancre, fixer simplement le window.location.hash |
|
| 131 | + elseif ($format == 'ajaxform' and preg_match(',^#[0-9a-z\-_]+$,i', $url)) { |
|
| 132 | + return [ |
|
| 133 | + // on renvoie un lien masque qui sera traite par ajaxCallback.js |
|
| 134 | + "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>", |
|
| 135 | + // et rien dans le message ok |
|
| 136 | + '' |
|
| 137 | + ]; |
|
| 138 | + } else { |
|
| 139 | + // ne pas laisser passer n'importe quoi dans l'url |
|
| 140 | + $url = str_replace(['<', '"'], ['<', '"'], $url); |
|
| 141 | + |
|
| 142 | + $url = strtr($url, "\n\r", ' '); |
|
| 143 | + # en theorie on devrait faire ca tout le temps, mais quand la chaine |
|
| 144 | + # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne |
|
| 145 | + if ($url[0] == '?') { |
|
| 146 | + $url = url_de_base() . $url; |
|
| 147 | + } |
|
| 148 | + $url = str_replace('&', '&', $url); |
|
| 149 | + spip_log("redirige formulaire ajax: $url"); |
|
| 150 | + include_spip('inc/filtres'); |
|
| 151 | + if ($format == 'ajaxform') { |
|
| 152 | + return [ |
|
| 153 | + // on renvoie un lien masque qui sera traite par ajaxCallback.js |
|
| 154 | + '<a href="' . quote_amp($url) . '" name="ajax_redirect" style="display:none;">' . _T('navigateur_pas_redirige') . '</a>', |
|
| 155 | + // et un message au cas ou |
|
| 156 | + '<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>' |
|
| 157 | + ]; |
|
| 158 | + } else // format message texte, tout en js inline |
|
| 159 | + { |
|
| 160 | + return |
|
| 161 | + // ie poste les formulaires dans une iframe, il faut donc rediriger son parent |
|
| 162 | + "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>" |
|
| 163 | + . http_img_pack('loader.svg', '', " class='loader'") |
|
| 164 | + . '<br />' |
|
| 165 | + . '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'; |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @return void |
| 186 | 186 | **/ |
| 187 | 187 | function redirige_url_ecrire($script = '', $args = '', $equiv = '') { |
| 188 | - return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv); |
|
| 188 | + return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv); |
|
| 189 | 189 | } |
| 190 | 190 | /** |
| 191 | 191 | * Renvoie au client le header HTTP avec le message correspondant au code indiqué. |
@@ -200,27 +200,27 @@ discard block |
||
| 200 | 200 | * Code d'erreur |
| 201 | 201 | **/ |
| 202 | 202 | function http_status($status) { |
| 203 | - http_response_code($status); |
|
| 203 | + http_response_code($status); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache |
| 207 | 207 | function http_no_cache() { |
| 208 | - if (headers_sent()) { |
|
| 209 | - spip_log('http_no_cache arrive trop tard'); |
|
| 210 | - |
|
| 211 | - return; |
|
| 212 | - } |
|
| 213 | - $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset']; |
|
| 214 | - |
|
| 215 | - // selon http://developer.apple.com/internet/safari/faq.html#anchor5 |
|
| 216 | - // il faudrait aussi pour Safari |
|
| 217 | - // header("Cache-Control: post-check=0, pre-check=0", false) |
|
| 218 | - // mais ca ne respecte pas |
|
| 219 | - // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 |
|
| 220 | - |
|
| 221 | - header("Content-Type: text/html; charset=$charset"); |
|
| 222 | - header('Expires: 0'); |
|
| 223 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 224 | - header('Cache-Control: no-cache, must-revalidate'); |
|
| 225 | - header('Pragma: no-cache'); |
|
| 208 | + if (headers_sent()) { |
|
| 209 | + spip_log('http_no_cache arrive trop tard'); |
|
| 210 | + |
|
| 211 | + return; |
|
| 212 | + } |
|
| 213 | + $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset']; |
|
| 214 | + |
|
| 215 | + // selon http://developer.apple.com/internet/safari/faq.html#anchor5 |
|
| 216 | + // il faudrait aussi pour Safari |
|
| 217 | + // header("Cache-Control: post-check=0, pre-check=0", false) |
|
| 218 | + // mais ca ne respecte pas |
|
| 219 | + // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 |
|
| 220 | + |
|
| 221 | + header("Content-Type: text/html; charset=$charset"); |
|
| 222 | + header('Expires: 0'); |
|
| 223 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 224 | + header('Cache-Control: no-cache, must-revalidate'); |
|
| 225 | + header('Pragma: no-cache'); |
|
| 226 | 226 | } |
@@ -11,65 +11,65 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_articles_charger_dist() { |
| 18 | - $valeurs = []; |
|
| 19 | - foreach ( |
|
| 20 | - [ |
|
| 21 | - 'articles_surtitre', |
|
| 22 | - 'articles_soustitre', |
|
| 23 | - 'articles_descriptif', |
|
| 24 | - 'articles_chapeau', |
|
| 25 | - 'articles_texte', |
|
| 26 | - 'articles_ps', |
|
| 27 | - 'articles_redac', |
|
| 28 | - 'articles_urlref', |
|
| 29 | - 'post_dates', |
|
| 30 | - 'articles_redirection', |
|
| 31 | - ] as $m |
|
| 32 | - ) { |
|
| 33 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 34 | - } |
|
| 18 | + $valeurs = []; |
|
| 19 | + foreach ( |
|
| 20 | + [ |
|
| 21 | + 'articles_surtitre', |
|
| 22 | + 'articles_soustitre', |
|
| 23 | + 'articles_descriptif', |
|
| 24 | + 'articles_chapeau', |
|
| 25 | + 'articles_texte', |
|
| 26 | + 'articles_ps', |
|
| 27 | + 'articles_redac', |
|
| 28 | + 'articles_urlref', |
|
| 29 | + 'post_dates', |
|
| 30 | + 'articles_redirection', |
|
| 31 | + ] as $m |
|
| 32 | + ) { |
|
| 33 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - return $valeurs; |
|
| 36 | + return $valeurs; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | function formulaires_configurer_articles_traiter_dist() { |
| 41 | - $res = ['editable' => true]; |
|
| 42 | - $purger_skel = false; |
|
| 43 | - // Purger les squelettes si un changement de meta les affecte |
|
| 44 | - if ($i = _request('post_dates') and ($i != $GLOBALS['meta']['post_dates'])) { |
|
| 45 | - $purger_skel = true; |
|
| 46 | - } |
|
| 41 | + $res = ['editable' => true]; |
|
| 42 | + $purger_skel = false; |
|
| 43 | + // Purger les squelettes si un changement de meta les affecte |
|
| 44 | + if ($i = _request('post_dates') and ($i != $GLOBALS['meta']['post_dates'])) { |
|
| 45 | + $purger_skel = true; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - foreach ( |
|
| 49 | - [ |
|
| 50 | - 'articles_surtitre', |
|
| 51 | - 'articles_soustitre', |
|
| 52 | - 'articles_descriptif', |
|
| 53 | - 'articles_chapeau', |
|
| 54 | - 'articles_texte', |
|
| 55 | - 'articles_ps', |
|
| 56 | - 'articles_redac', |
|
| 57 | - 'articles_urlref', |
|
| 58 | - 'post_dates', |
|
| 59 | - 'articles_redirection', |
|
| 60 | - ] as $m |
|
| 61 | - ) { |
|
| 62 | - if (!is_null($v = _request($m))) { |
|
| 63 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 64 | - } |
|
| 65 | - } |
|
| 48 | + foreach ( |
|
| 49 | + [ |
|
| 50 | + 'articles_surtitre', |
|
| 51 | + 'articles_soustitre', |
|
| 52 | + 'articles_descriptif', |
|
| 53 | + 'articles_chapeau', |
|
| 54 | + 'articles_texte', |
|
| 55 | + 'articles_ps', |
|
| 56 | + 'articles_redac', |
|
| 57 | + 'articles_urlref', |
|
| 58 | + 'post_dates', |
|
| 59 | + 'articles_redirection', |
|
| 60 | + ] as $m |
|
| 61 | + ) { |
|
| 62 | + if (!is_null($v = _request($m))) { |
|
| 63 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - if ($purger_skel) { |
|
| 68 | - include_spip('inc/invalideur'); |
|
| 69 | - purger_repertoire(_DIR_SKELS); |
|
| 70 | - } |
|
| 67 | + if ($purger_skel) { |
|
| 68 | + include_spip('inc/invalideur'); |
|
| 69 | + purger_repertoire(_DIR_SKELS); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 72 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 73 | 73 | |
| 74 | - return $res; |
|
| 74 | + return $res; |
|
| 75 | 75 | } |
@@ -11,37 +11,37 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/presentation'); |
| 17 | 17 | |
| 18 | 18 | function formulaires_configurer_avertisseur_charger_dist() { |
| 19 | - $valeurs = []; |
|
| 20 | - foreach ( |
|
| 21 | - [ |
|
| 22 | - 'articles_modif', |
|
| 23 | - ] as $m |
|
| 24 | - ) { |
|
| 25 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - return $valeurs; |
|
| 19 | + $valeurs = []; |
|
| 20 | + foreach ( |
|
| 21 | + [ |
|
| 22 | + 'articles_modif', |
|
| 23 | + ] as $m |
|
| 24 | + ) { |
|
| 25 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + return $valeurs; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | function formulaires_configurer_avertisseur_traiter_dist() { |
| 33 | - $res = ['editable' => true]; |
|
| 34 | - foreach ( |
|
| 35 | - [ |
|
| 36 | - 'articles_modif', |
|
| 37 | - ] as $m |
|
| 38 | - ) { |
|
| 39 | - if (!is_null($v = _request($m))) { |
|
| 40 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 45 | - |
|
| 46 | - return $res; |
|
| 33 | + $res = ['editable' => true]; |
|
| 34 | + foreach ( |
|
| 35 | + [ |
|
| 36 | + 'articles_modif', |
|
| 37 | + ] as $m |
|
| 38 | + ) { |
|
| 39 | + if (!is_null($v = _request($m))) { |
|
| 40 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 45 | + |
|
| 46 | + return $res; |
|
| 47 | 47 | } |
@@ -11,51 +11,51 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/presentation'); |
| 17 | 17 | |
| 18 | 18 | function formulaires_configurer_visiteurs_charger_dist() { |
| 19 | - $valeurs = []; |
|
| 20 | - if (avoir_visiteurs(false, false)) { |
|
| 21 | - $valeurs['editable'] = false; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - foreach ( |
|
| 25 | - [ |
|
| 26 | - 'accepter_visiteurs' |
|
| 27 | - ] as $m |
|
| 28 | - ) { |
|
| 29 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - return $valeurs; |
|
| 19 | + $valeurs = []; |
|
| 20 | + if (avoir_visiteurs(false, false)) { |
|
| 21 | + $valeurs['editable'] = false; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + foreach ( |
|
| 25 | + [ |
|
| 26 | + 'accepter_visiteurs' |
|
| 27 | + ] as $m |
|
| 28 | + ) { |
|
| 29 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + return $valeurs; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | function formulaires_configurer_visiteurs_traiter_dist() { |
| 37 | - $res = ['editable' => true]; |
|
| 38 | - // Modification du reglage accepter_inscriptions => vider le cache |
|
| 39 | - // (pour repercuter la modif sur le panneau de login) |
|
| 40 | - if ( |
|
| 41 | - ($i = _request('accepter_visiteurs') |
|
| 42 | - and $i != $GLOBALS['meta']['accepter_visiteurs']) |
|
| 43 | - ) { |
|
| 44 | - include_spip('inc/invalideur'); |
|
| 45 | - suivre_invalideur('1'); # tout effacer |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - foreach ( |
|
| 49 | - [ |
|
| 50 | - 'accepter_visiteurs', |
|
| 51 | - ] as $m |
|
| 52 | - ) { |
|
| 53 | - if (!is_null($v = _request($m))) { |
|
| 54 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 59 | - |
|
| 60 | - return $res; |
|
| 37 | + $res = ['editable' => true]; |
|
| 38 | + // Modification du reglage accepter_inscriptions => vider le cache |
|
| 39 | + // (pour repercuter la modif sur le panneau de login) |
|
| 40 | + if ( |
|
| 41 | + ($i = _request('accepter_visiteurs') |
|
| 42 | + and $i != $GLOBALS['meta']['accepter_visiteurs']) |
|
| 43 | + ) { |
|
| 44 | + include_spip('inc/invalideur'); |
|
| 45 | + suivre_invalideur('1'); # tout effacer |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + foreach ( |
|
| 49 | + [ |
|
| 50 | + 'accepter_visiteurs', |
|
| 51 | + ] as $m |
|
| 52 | + ) { |
|
| 53 | + if (!is_null($v = _request($m))) { |
|
| 54 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 59 | + |
|
| 60 | + return $res; |
|
| 61 | 61 | } |
@@ -11,38 +11,38 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_rubriques_charger_dist() { |
| 18 | - $valeurs = []; |
|
| 19 | - foreach ( |
|
| 20 | - [ |
|
| 21 | - 'rubriques_descriptif', |
|
| 22 | - 'rubriques_texte' |
|
| 23 | - ] as $m |
|
| 24 | - ) { |
|
| 25 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - return $valeurs; |
|
| 18 | + $valeurs = []; |
|
| 19 | + foreach ( |
|
| 20 | + [ |
|
| 21 | + 'rubriques_descriptif', |
|
| 22 | + 'rubriques_texte' |
|
| 23 | + ] as $m |
|
| 24 | + ) { |
|
| 25 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + return $valeurs; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | function formulaires_configurer_rubriques_traiter_dist() { |
| 33 | - $res = ['editable' => true]; |
|
| 34 | - foreach ( |
|
| 35 | - [ |
|
| 36 | - 'rubriques_descriptif', |
|
| 37 | - 'rubriques_texte' |
|
| 38 | - ] as $m |
|
| 39 | - ) { |
|
| 40 | - if (!is_null($v = _request($m))) { |
|
| 41 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 46 | - |
|
| 47 | - return $res; |
|
| 33 | + $res = ['editable' => true]; |
|
| 34 | + foreach ( |
|
| 35 | + [ |
|
| 36 | + 'rubriques_descriptif', |
|
| 37 | + 'rubriques_texte' |
|
| 38 | + ] as $m |
|
| 39 | + ) { |
|
| 40 | + if (!is_null($v = _request($m))) { |
|
| 41 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 46 | + |
|
| 47 | + return $res; |
|
| 48 | 48 | } |
@@ -11,36 +11,36 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_flux_charger_dist() { |
| 18 | - $valeurs = []; |
|
| 19 | - foreach ( |
|
| 20 | - [ |
|
| 21 | - 'syndication_integrale' |
|
| 22 | - ] as $m |
|
| 23 | - ) { |
|
| 24 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - return $valeurs; |
|
| 18 | + $valeurs = []; |
|
| 19 | + foreach ( |
|
| 20 | + [ |
|
| 21 | + 'syndication_integrale' |
|
| 22 | + ] as $m |
|
| 23 | + ) { |
|
| 24 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + return $valeurs; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | function formulaires_configurer_flux_traiter_dist() { |
| 32 | - $res = ['editable' => true]; |
|
| 33 | - foreach ( |
|
| 34 | - [ |
|
| 35 | - 'syndication_integrale', |
|
| 36 | - ] as $m |
|
| 37 | - ) { |
|
| 38 | - if (!is_null($v = _request($m))) { |
|
| 39 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 44 | - |
|
| 45 | - return $res; |
|
| 32 | + $res = ['editable' => true]; |
|
| 33 | + foreach ( |
|
| 34 | + [ |
|
| 35 | + 'syndication_integrale', |
|
| 36 | + ] as $m |
|
| 37 | + ) { |
|
| 38 | + if (!is_null($v = _request($m))) { |
|
| 39 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 44 | + |
|
| 45 | + return $res; |
|
| 46 | 46 | } |
@@ -11,38 +11,38 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_logos_charger_dist() { |
| 18 | - $valeurs = []; |
|
| 19 | - foreach ( |
|
| 20 | - [ |
|
| 21 | - 'activer_logos', |
|
| 22 | - 'activer_logos_survol' |
|
| 23 | - ] as $m |
|
| 24 | - ) { |
|
| 25 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - return $valeurs; |
|
| 18 | + $valeurs = []; |
|
| 19 | + foreach ( |
|
| 20 | + [ |
|
| 21 | + 'activer_logos', |
|
| 22 | + 'activer_logos_survol' |
|
| 23 | + ] as $m |
|
| 24 | + ) { |
|
| 25 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + return $valeurs; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | function formulaires_configurer_logos_traiter_dist() { |
| 33 | - $res = ['editable' => true]; |
|
| 34 | - foreach ( |
|
| 35 | - [ |
|
| 36 | - 'activer_logos', |
|
| 37 | - 'activer_logos_survol', |
|
| 38 | - ] as $m |
|
| 39 | - ) { |
|
| 40 | - if (!is_null($v = _request($m))) { |
|
| 41 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 46 | - |
|
| 47 | - return $res; |
|
| 33 | + $res = ['editable' => true]; |
|
| 34 | + foreach ( |
|
| 35 | + [ |
|
| 36 | + 'activer_logos', |
|
| 37 | + 'activer_logos_survol', |
|
| 38 | + ] as $m |
|
| 39 | + ) { |
|
| 40 | + if (!is_null($v = _request($m))) { |
|
| 41 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 46 | + |
|
| 47 | + return $res; |
|
| 48 | 48 | } |
@@ -11,46 +11,46 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_redacteurs_charger_dist() { |
| 18 | - $valeurs = []; |
|
| 19 | - foreach ( |
|
| 20 | - [ |
|
| 21 | - 'accepter_inscriptions', |
|
| 22 | - ] as $m |
|
| 23 | - ) { |
|
| 24 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - return $valeurs; |
|
| 18 | + $valeurs = []; |
|
| 19 | + foreach ( |
|
| 20 | + [ |
|
| 21 | + 'accepter_inscriptions', |
|
| 22 | + ] as $m |
|
| 23 | + ) { |
|
| 24 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + return $valeurs; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | function formulaires_configurer_redacteurs_traiter_dist() { |
| 32 | - $res = ['editable' => true]; |
|
| 33 | - // Modification du reglage accepter_inscriptions => vider le cache |
|
| 34 | - // (pour repercuter la modif sur le panneau de login) |
|
| 35 | - if ( |
|
| 36 | - ($i = _request('accepter_inscriptions') |
|
| 37 | - and $i != $GLOBALS['meta']['accepter_inscriptions']) |
|
| 38 | - ) { |
|
| 39 | - include_spip('inc/invalideur'); |
|
| 40 | - suivre_invalideur('1'); # tout effacer |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - foreach ( |
|
| 44 | - [ |
|
| 45 | - 'accepter_inscriptions', |
|
| 46 | - ] as $m |
|
| 47 | - ) { |
|
| 48 | - if (!is_null($v = _request($m))) { |
|
| 49 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 54 | - |
|
| 55 | - return $res; |
|
| 32 | + $res = ['editable' => true]; |
|
| 33 | + // Modification du reglage accepter_inscriptions => vider le cache |
|
| 34 | + // (pour repercuter la modif sur le panneau de login) |
|
| 35 | + if ( |
|
| 36 | + ($i = _request('accepter_inscriptions') |
|
| 37 | + and $i != $GLOBALS['meta']['accepter_inscriptions']) |
|
| 38 | + ) { |
|
| 39 | + include_spip('inc/invalideur'); |
|
| 40 | + suivre_invalideur('1'); # tout effacer |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + foreach ( |
|
| 44 | + [ |
|
| 45 | + 'accepter_inscriptions', |
|
| 46 | + ] as $m |
|
| 47 | + ) { |
|
| 48 | + if (!is_null($v = _request($m))) { |
|
| 49 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 54 | + |
|
| 55 | + return $res; |
|
| 56 | 56 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | function generer_nom_fichier_cache($contexte, $page) { |
| 30 | 30 | $u = md5(var_export([$contexte, $page], true)); |
| 31 | 31 | |
| 32 | - return $u . '.cache'; |
|
| 32 | + return $u.'.cache'; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | else { |
| 63 | 63 | // en lecture on essaye pas de creer les repertoires, on va au plus vite |
| 64 | - $rep = _DIR_CACHE . "calcul/$d/"; |
|
| 64 | + $rep = _DIR_CACHE."calcul/$d/"; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - return $rep . $u . '.cache'; |
|
| 67 | + return $rep.$u.'.cache'; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | ); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return crc32($GLOBALS['meta']['cache_signature'] . $page['texte']); |
|
| 118 | + return crc32($GLOBALS['meta']['cache_signature'].$page['texte']); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | // "cache sessionne" ; sa date indique la date de validite |
| 272 | 272 | // des caches sessionnes |
| 273 | 273 | if (!$tmp = lire_cache($chemin_cache)) { |
| 274 | - spip_log('Creation cache sessionne ' . $chemin_cache); |
|
| 274 | + spip_log('Creation cache sessionne '.$chemin_cache); |
|
| 275 | 275 | $tmp = [ |
| 276 | 276 | 'invalideurs' => ['session' => ''], |
| 277 | 277 | 'lastmodified' => $_SERVER['REQUEST_TIME'] |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | // l'enregistrer, compresse ou non... |
| 298 | 298 | $ok = ecrire_cache($chemin_cache, $pagez); |
| 299 | 299 | |
| 300 | - spip_log((_IS_BOT ? 'Bot:' : '') . "Creation du cache $chemin_cache pour " |
|
| 301 | - . $page['entetes']['X-Spip-Cache'] . ' secondes' . ($ok ? '' : ' (erreur!)'), _LOG_INFO); |
|
| 300 | + spip_log((_IS_BOT ? 'Bot:' : '')."Creation du cache $chemin_cache pour " |
|
| 301 | + . $page['entetes']['X-Spip-Cache'].' secondes'.($ok ? '' : ' (erreur!)'), _LOG_INFO); |
|
| 302 | 302 | |
| 303 | 303 | // Inserer ses invalideurs |
| 304 | 304 | include_spip('inc/invalideur'); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | function nettoyer_petit_cache($prefix, $duree = 300) { |
| 320 | 320 | // determiner le repertoire a purger : 'tmp/CACHE/rech/' |
| 321 | 321 | $dircache = sous_repertoire(_DIR_CACHE, $prefix); |
| 322 | - if (spip_touch($dircache . 'purger_' . $prefix, $duree, true)) { |
|
| 322 | + if (spip_touch($dircache.'purger_'.$prefix, $duree, true)) { |
|
| 323 | 323 | foreach (preg_files($dircache, '[.]txt$') as $f) { |
| 324 | 324 | if ($_SERVER['REQUEST_TIME'] - (@file_exists($f) ? @filemtime($f) : 0) > $duree) { |
| 325 | 325 | spip_unlink($f); |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | if (spip_connect()) { |
| 415 | 415 | include_spip('inc/invalideur'); |
| 416 | 416 | retire_caches($chemin_cache); # API invalideur inutile |
| 417 | - supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 417 | + supprimer_fichier(_DIR_CACHE.$chemin_cache); |
|
| 418 | 418 | if (isset($chemin_cache_session) and $chemin_cache_session) { |
| 419 | - supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 419 | + supprimer_fichier(_DIR_CACHE.$chemin_cache_session); |
|
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | } |
@@ -433,9 +433,9 @@ discard block |
||
| 433 | 433 | $page = ['contexte_implicite' => $contexte_implicite]; // ignorer le cache deja lu |
| 434 | 434 | include_spip('inc/invalideur'); |
| 435 | 435 | retire_caches($chemin_cache); # API invalideur inutile |
| 436 | - supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 436 | + supprimer_fichier(_DIR_CACHE.$chemin_cache); |
|
| 437 | 437 | if (isset($chemin_cache_session) and $chemin_cache_session) { |
| 438 | - supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 438 | + supprimer_fichier(_DIR_CACHE.$chemin_cache_session); |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | $rep = sous_repertoire(_DIR_CACHE, '', false, true); |
| 59 | 59 | $rep = sous_repertoire($rep, 'calcul/', false, true); |
| 60 | 60 | $rep = sous_repertoire($rep, $d, false, true); |
| 61 | - } |
|
| 62 | - else { |
|
| 61 | + } else { |
|
| 63 | 62 | // en lecture on essaye pas de creer les repertoires, on va au plus vite |
| 64 | 63 | $rep = _DIR_CACHE . "calcul/$d/"; |
| 65 | 64 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | 27 | function generer_nom_fichier_cache($contexte, $page) { |
| 28 | - $u = md5(var_export([$contexte, $page], true)); |
|
| 28 | + $u = md5(var_export([$contexte, $page], true)); |
|
| 29 | 29 | |
| 30 | - return $u . '.cache'; |
|
| 30 | + return $u . '.cache'; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -43,26 +43,26 @@ discard block |
||
| 43 | 43 | * @return string |
| 44 | 44 | */ |
| 45 | 45 | function cache_chemin_fichier($nom_cache, $ecrire = false) { |
| 46 | - static $l1, $l2; |
|
| 47 | - if (is_null($l1)) { |
|
| 48 | - $length = (defined('_CACHE_PROFONDEUR_STOCKAGE') ? min(8, max(_CACHE_PROFONDEUR_STOCKAGE, 2)) : 4); |
|
| 49 | - $l1 = intval(floor($length / 2)); |
|
| 50 | - $l2 = $length - $l1; |
|
| 51 | - } |
|
| 52 | - $d = substr($nom_cache, 0, $l1); |
|
| 53 | - $u = substr($nom_cache, $l1, $l2); |
|
| 54 | - |
|
| 55 | - if ($ecrire) { |
|
| 56 | - $rep = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 57 | - $rep = sous_repertoire($rep, 'calcul/', false, true); |
|
| 58 | - $rep = sous_repertoire($rep, $d, false, true); |
|
| 59 | - } |
|
| 60 | - else { |
|
| 61 | - // en lecture on essaye pas de creer les repertoires, on va au plus vite |
|
| 62 | - $rep = _DIR_CACHE . "calcul/$d/"; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - return $rep . $u . '.cache'; |
|
| 46 | + static $l1, $l2; |
|
| 47 | + if (is_null($l1)) { |
|
| 48 | + $length = (defined('_CACHE_PROFONDEUR_STOCKAGE') ? min(8, max(_CACHE_PROFONDEUR_STOCKAGE, 2)) : 4); |
|
| 49 | + $l1 = intval(floor($length / 2)); |
|
| 50 | + $l2 = $length - $l1; |
|
| 51 | + } |
|
| 52 | + $d = substr($nom_cache, 0, $l1); |
|
| 53 | + $u = substr($nom_cache, $l1, $l2); |
|
| 54 | + |
|
| 55 | + if ($ecrire) { |
|
| 56 | + $rep = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 57 | + $rep = sous_repertoire($rep, 'calcul/', false, true); |
|
| 58 | + $rep = sous_repertoire($rep, $d, false, true); |
|
| 59 | + } |
|
| 60 | + else { |
|
| 61 | + // en lecture on essaye pas de creer les repertoires, on va au plus vite |
|
| 62 | + $rep = _DIR_CACHE . "calcul/$d/"; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + return $rep . $u . '.cache'; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @return bool |
| 74 | 74 | */ |
| 75 | 75 | function ecrire_cache($nom_cache, $valeur) { |
| 76 | - return ecrire_fichier(cache_chemin_fichier($nom_cache, true), serialize(['nom_cache' => $nom_cache, 'valeur' => $valeur])); |
|
| 76 | + return ecrire_fichier(cache_chemin_fichier($nom_cache, true), serialize(['nom_cache' => $nom_cache, 'valeur' => $valeur])); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -83,38 +83,38 @@ discard block |
||
| 83 | 83 | * @return mixed |
| 84 | 84 | */ |
| 85 | 85 | function lire_cache($nom_cache) { |
| 86 | - $tmp = []; |
|
| 87 | - if ( |
|
| 88 | - file_exists($f = cache_chemin_fichier($nom_cache)) |
|
| 89 | - and lire_fichier($f, $tmp) |
|
| 90 | - and $tmp = unserialize($tmp) |
|
| 91 | - and $tmp['nom_cache'] == $nom_cache |
|
| 92 | - and isset($tmp['valeur']) |
|
| 93 | - ) { |
|
| 94 | - return $tmp['valeur']; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return false; |
|
| 86 | + $tmp = []; |
|
| 87 | + if ( |
|
| 88 | + file_exists($f = cache_chemin_fichier($nom_cache)) |
|
| 89 | + and lire_fichier($f, $tmp) |
|
| 90 | + and $tmp = unserialize($tmp) |
|
| 91 | + and $tmp['nom_cache'] == $nom_cache |
|
| 92 | + and isset($tmp['valeur']) |
|
| 93 | + ) { |
|
| 94 | + return $tmp['valeur']; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return false; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Parano : on signe le cache, afin d'interdire un hack d'injection |
| 101 | 101 | // dans notre memcache |
| 102 | 102 | function cache_signature(&$page) { |
| 103 | - if (!isset($GLOBALS['meta']['cache_signature'])) { |
|
| 104 | - include_spip('inc/acces'); |
|
| 105 | - include_spip('auth/sha256.inc'); |
|
| 106 | - ecrire_meta( |
|
| 107 | - 'cache_signature', |
|
| 108 | - spip_sha256( |
|
| 109 | - $_SERVER['DOCUMENT_ROOT'] |
|
| 110 | - . ($_SERVER['SERVER_SIGNATURE'] ?? '') |
|
| 111 | - . creer_uniqid() |
|
| 112 | - ), |
|
| 113 | - 'non' |
|
| 114 | - ); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - return crc32($GLOBALS['meta']['cache_signature'] . $page['texte']); |
|
| 103 | + if (!isset($GLOBALS['meta']['cache_signature'])) { |
|
| 104 | + include_spip('inc/acces'); |
|
| 105 | + include_spip('auth/sha256.inc'); |
|
| 106 | + ecrire_meta( |
|
| 107 | + 'cache_signature', |
|
| 108 | + spip_sha256( |
|
| 109 | + $_SERVER['DOCUMENT_ROOT'] |
|
| 110 | + . ($_SERVER['SERVER_SIGNATURE'] ?? '') |
|
| 111 | + . creer_uniqid() |
|
| 112 | + ), |
|
| 113 | + 'non' |
|
| 114 | + ); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + return crc32($GLOBALS['meta']['cache_signature'] . $page['texte']); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | * @return array |
| 128 | 128 | */ |
| 129 | 129 | function gzip_page($page) { |
| 130 | - if (function_exists('gzcompress') and strlen($page['texte']) > 16 * 1024) { |
|
| 131 | - $page['gz'] = true; |
|
| 132 | - $page['texte'] = gzcompress($page['texte']); |
|
| 133 | - } else { |
|
| 134 | - $page['gz'] = false; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $page; |
|
| 130 | + if (function_exists('gzcompress') and strlen($page['texte']) > 16 * 1024) { |
|
| 131 | + $page['gz'] = true; |
|
| 132 | + $page['texte'] = gzcompress($page['texte']); |
|
| 133 | + } else { |
|
| 134 | + $page['gz'] = false; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + return $page; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | * @return void |
| 148 | 148 | */ |
| 149 | 149 | function gunzip_page(&$page) { |
| 150 | - if ($page['gz']) { |
|
| 151 | - $page['texte'] = gzuncompress($page['texte']); |
|
| 152 | - $page['gz'] = false; // ne pas gzuncompress deux fois une meme page |
|
| 153 | - } |
|
| 150 | + if ($page['gz']) { |
|
| 151 | + $page['texte'] = gzuncompress($page['texte']); |
|
| 152 | + $page['gz'] = false; // ne pas gzuncompress deux fois une meme page |
|
| 153 | + } |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -165,72 +165,72 @@ discard block |
||
| 165 | 165 | * -1 si il faut calculer sans stocker en cache |
| 166 | 166 | */ |
| 167 | 167 | function cache_valide(&$page, $date) { |
| 168 | - $now = $_SERVER['REQUEST_TIME']; |
|
| 169 | - |
|
| 170 | - // Apparition d'un nouvel article post-date ? |
|
| 171 | - if ( |
|
| 172 | - isset($GLOBALS['meta']['post_dates']) |
|
| 173 | - and $GLOBALS['meta']['post_dates'] == 'non' |
|
| 174 | - and isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 175 | - and $now > $GLOBALS['meta']['date_prochain_postdate'] |
|
| 176 | - ) { |
|
| 177 | - spip_log('Un article post-date invalide le cache'); |
|
| 178 | - include_spip('inc/rubriques'); |
|
| 179 | - calculer_prochain_postdate(true); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - if (defined('_VAR_NOCACHE') and _VAR_NOCACHE) { |
|
| 183 | - return -1; |
|
| 184 | - } |
|
| 185 | - if (isset($GLOBALS['meta']['cache_inhib']) and $_SERVER['REQUEST_TIME'] < $GLOBALS['meta']['cache_inhib']) { |
|
| 186 | - return -1; |
|
| 187 | - } |
|
| 188 | - if (defined('_NO_CACHE')) { |
|
| 189 | - return (_NO_CACHE == 0 and !isset($page['texte'])) ? 1 : _NO_CACHE; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - // pas de cache ? on le met a jour, sauf pour les bots (on leur calcule la page sans mise en cache) |
|
| 193 | - if (!$page or !isset($page['texte']) or !isset($page['entetes']['X-Spip-Cache'])) { |
|
| 194 | - return _IS_BOT ? -1 : 1; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - // controle de la signature |
|
| 198 | - if ($page['sig'] !== cache_signature($page)) { |
|
| 199 | - return _IS_BOT ? -1 : 1; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - // #CACHE{n,statique} => on n'invalide pas avec derniere_modif |
|
| 203 | - // cf. ecrire/public/balises.php, balise_CACHE_dist() |
|
| 204 | - if (!isset($page['entetes']['X-Spip-Statique']) or $page['entetes']['X-Spip-Statique'] !== 'oui') { |
|
| 205 | - // Cache invalide par la meta 'derniere_modif' |
|
| 206 | - // sauf pour les bots, qui utilisent toujours le cache |
|
| 207 | - if ( |
|
| 208 | - !_IS_BOT |
|
| 209 | - and $GLOBALS['derniere_modif_invalide'] |
|
| 210 | - and isset($GLOBALS['meta']['derniere_modif']) |
|
| 211 | - and $date < $GLOBALS['meta']['derniere_modif'] |
|
| 212 | - ) { |
|
| 213 | - return 1; |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // Sinon comparer l'age du fichier a sa duree de cache |
|
| 218 | - $duree = intval($page['entetes']['X-Spip-Cache']); |
|
| 219 | - $cache_mark = ($GLOBALS['meta']['cache_mark'] ?? 0); |
|
| 220 | - if ($duree == 0) { #CACHE{0} |
|
| 221 | - return -1; |
|
| 222 | - } // sauf pour les bots, qui utilisent toujours le cache |
|
| 223 | - else { |
|
| 224 | - if ( |
|
| 225 | - (!_IS_BOT and $date + $duree < $now) |
|
| 226 | - # le cache est anterieur a la derniere purge : l'ignorer, meme pour les bots |
|
| 227 | - or $date < $cache_mark |
|
| 228 | - ) { |
|
| 229 | - return _IS_BOT ? -1 : 1; |
|
| 230 | - } else { |
|
| 231 | - return 0; |
|
| 232 | - } |
|
| 233 | - } |
|
| 168 | + $now = $_SERVER['REQUEST_TIME']; |
|
| 169 | + |
|
| 170 | + // Apparition d'un nouvel article post-date ? |
|
| 171 | + if ( |
|
| 172 | + isset($GLOBALS['meta']['post_dates']) |
|
| 173 | + and $GLOBALS['meta']['post_dates'] == 'non' |
|
| 174 | + and isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 175 | + and $now > $GLOBALS['meta']['date_prochain_postdate'] |
|
| 176 | + ) { |
|
| 177 | + spip_log('Un article post-date invalide le cache'); |
|
| 178 | + include_spip('inc/rubriques'); |
|
| 179 | + calculer_prochain_postdate(true); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + if (defined('_VAR_NOCACHE') and _VAR_NOCACHE) { |
|
| 183 | + return -1; |
|
| 184 | + } |
|
| 185 | + if (isset($GLOBALS['meta']['cache_inhib']) and $_SERVER['REQUEST_TIME'] < $GLOBALS['meta']['cache_inhib']) { |
|
| 186 | + return -1; |
|
| 187 | + } |
|
| 188 | + if (defined('_NO_CACHE')) { |
|
| 189 | + return (_NO_CACHE == 0 and !isset($page['texte'])) ? 1 : _NO_CACHE; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + // pas de cache ? on le met a jour, sauf pour les bots (on leur calcule la page sans mise en cache) |
|
| 193 | + if (!$page or !isset($page['texte']) or !isset($page['entetes']['X-Spip-Cache'])) { |
|
| 194 | + return _IS_BOT ? -1 : 1; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + // controle de la signature |
|
| 198 | + if ($page['sig'] !== cache_signature($page)) { |
|
| 199 | + return _IS_BOT ? -1 : 1; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + // #CACHE{n,statique} => on n'invalide pas avec derniere_modif |
|
| 203 | + // cf. ecrire/public/balises.php, balise_CACHE_dist() |
|
| 204 | + if (!isset($page['entetes']['X-Spip-Statique']) or $page['entetes']['X-Spip-Statique'] !== 'oui') { |
|
| 205 | + // Cache invalide par la meta 'derniere_modif' |
|
| 206 | + // sauf pour les bots, qui utilisent toujours le cache |
|
| 207 | + if ( |
|
| 208 | + !_IS_BOT |
|
| 209 | + and $GLOBALS['derniere_modif_invalide'] |
|
| 210 | + and isset($GLOBALS['meta']['derniere_modif']) |
|
| 211 | + and $date < $GLOBALS['meta']['derniere_modif'] |
|
| 212 | + ) { |
|
| 213 | + return 1; |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + // Sinon comparer l'age du fichier a sa duree de cache |
|
| 218 | + $duree = intval($page['entetes']['X-Spip-Cache']); |
|
| 219 | + $cache_mark = ($GLOBALS['meta']['cache_mark'] ?? 0); |
|
| 220 | + if ($duree == 0) { #CACHE{0} |
|
| 221 | + return -1; |
|
| 222 | + } // sauf pour les bots, qui utilisent toujours le cache |
|
| 223 | + else { |
|
| 224 | + if ( |
|
| 225 | + (!_IS_BOT and $date + $duree < $now) |
|
| 226 | + # le cache est anterieur a la derniere purge : l'ignorer, meme pour les bots |
|
| 227 | + or $date < $cache_mark |
|
| 228 | + ) { |
|
| 229 | + return _IS_BOT ? -1 : 1; |
|
| 230 | + } else { |
|
| 231 | + return 0; |
|
| 232 | + } |
|
| 233 | + } |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -243,59 +243,59 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | function creer_cache(&$page, &$chemin_cache) { |
| 245 | 245 | |
| 246 | - // Ne rien faire si on est en preview, debug, ou si une erreur |
|
| 247 | - // grave s'est presentee (compilation du squelette, MySQL, etc) |
|
| 248 | - // le cas var_nocache ne devrait jamais arriver ici (securite) |
|
| 249 | - // le cas spip_interdire_cache correspond a une ereur SQL grave non anticipable |
|
| 250 | - if ( |
|
| 251 | - (defined('_VAR_NOCACHE') and _VAR_NOCACHE) |
|
| 252 | - or defined('spip_interdire_cache') |
|
| 253 | - ) { |
|
| 254 | - return; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - // Si la page c1234 a un invalideur de session 'zz', sauver dans |
|
| 258 | - // 'tmp/cache/MD5(chemin_cache)_zz' |
|
| 259 | - if ( |
|
| 260 | - isset($page['invalideurs']) |
|
| 261 | - and isset($page['invalideurs']['session']) |
|
| 262 | - ) { |
|
| 263 | - // on verifie que le contenu du chemin cache indique seulement |
|
| 264 | - // "cache sessionne" ; sa date indique la date de validite |
|
| 265 | - // des caches sessionnes |
|
| 266 | - if (!$tmp = lire_cache($chemin_cache)) { |
|
| 267 | - spip_log('Creation cache sessionne ' . $chemin_cache); |
|
| 268 | - $tmp = [ |
|
| 269 | - 'invalideurs' => ['session' => ''], |
|
| 270 | - 'lastmodified' => $_SERVER['REQUEST_TIME'] |
|
| 271 | - ]; |
|
| 272 | - ecrire_cache($chemin_cache, $tmp); |
|
| 273 | - } |
|
| 274 | - $chemin_cache = generer_nom_fichier_cache( |
|
| 275 | - ['chemin_cache' => $chemin_cache], |
|
| 276 | - ['session' => $page['invalideurs']['session']] |
|
| 277 | - ); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - // ajouter la date de production dans le cache lui meme |
|
| 281 | - // (qui contient deja sa duree de validite) |
|
| 282 | - $page['lastmodified'] = $_SERVER['REQUEST_TIME']; |
|
| 283 | - |
|
| 284 | - // compresser le contenu si besoin |
|
| 285 | - $pagez = gzip_page($page); |
|
| 286 | - |
|
| 287 | - // signer le contenu |
|
| 288 | - $pagez['sig'] = cache_signature($pagez); |
|
| 289 | - |
|
| 290 | - // l'enregistrer, compresse ou non... |
|
| 291 | - $ok = ecrire_cache($chemin_cache, $pagez); |
|
| 292 | - |
|
| 293 | - spip_log((_IS_BOT ? 'Bot:' : '') . "Creation du cache $chemin_cache pour " |
|
| 294 | - . $page['entetes']['X-Spip-Cache'] . ' secondes' . ($ok ? '' : ' (erreur!)'), _LOG_INFO); |
|
| 295 | - |
|
| 296 | - // Inserer ses invalideurs |
|
| 297 | - include_spip('inc/invalideur'); |
|
| 298 | - maj_invalideurs($chemin_cache, $page); |
|
| 246 | + // Ne rien faire si on est en preview, debug, ou si une erreur |
|
| 247 | + // grave s'est presentee (compilation du squelette, MySQL, etc) |
|
| 248 | + // le cas var_nocache ne devrait jamais arriver ici (securite) |
|
| 249 | + // le cas spip_interdire_cache correspond a une ereur SQL grave non anticipable |
|
| 250 | + if ( |
|
| 251 | + (defined('_VAR_NOCACHE') and _VAR_NOCACHE) |
|
| 252 | + or defined('spip_interdire_cache') |
|
| 253 | + ) { |
|
| 254 | + return; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + // Si la page c1234 a un invalideur de session 'zz', sauver dans |
|
| 258 | + // 'tmp/cache/MD5(chemin_cache)_zz' |
|
| 259 | + if ( |
|
| 260 | + isset($page['invalideurs']) |
|
| 261 | + and isset($page['invalideurs']['session']) |
|
| 262 | + ) { |
|
| 263 | + // on verifie que le contenu du chemin cache indique seulement |
|
| 264 | + // "cache sessionne" ; sa date indique la date de validite |
|
| 265 | + // des caches sessionnes |
|
| 266 | + if (!$tmp = lire_cache($chemin_cache)) { |
|
| 267 | + spip_log('Creation cache sessionne ' . $chemin_cache); |
|
| 268 | + $tmp = [ |
|
| 269 | + 'invalideurs' => ['session' => ''], |
|
| 270 | + 'lastmodified' => $_SERVER['REQUEST_TIME'] |
|
| 271 | + ]; |
|
| 272 | + ecrire_cache($chemin_cache, $tmp); |
|
| 273 | + } |
|
| 274 | + $chemin_cache = generer_nom_fichier_cache( |
|
| 275 | + ['chemin_cache' => $chemin_cache], |
|
| 276 | + ['session' => $page['invalideurs']['session']] |
|
| 277 | + ); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + // ajouter la date de production dans le cache lui meme |
|
| 281 | + // (qui contient deja sa duree de validite) |
|
| 282 | + $page['lastmodified'] = $_SERVER['REQUEST_TIME']; |
|
| 283 | + |
|
| 284 | + // compresser le contenu si besoin |
|
| 285 | + $pagez = gzip_page($page); |
|
| 286 | + |
|
| 287 | + // signer le contenu |
|
| 288 | + $pagez['sig'] = cache_signature($pagez); |
|
| 289 | + |
|
| 290 | + // l'enregistrer, compresse ou non... |
|
| 291 | + $ok = ecrire_cache($chemin_cache, $pagez); |
|
| 292 | + |
|
| 293 | + spip_log((_IS_BOT ? 'Bot:' : '') . "Creation du cache $chemin_cache pour " |
|
| 294 | + . $page['entetes']['X-Spip-Cache'] . ' secondes' . ($ok ? '' : ' (erreur!)'), _LOG_INFO); |
|
| 295 | + |
|
| 296 | + // Inserer ses invalideurs |
|
| 297 | + include_spip('inc/invalideur'); |
|
| 298 | + maj_invalideurs($chemin_cache, $page); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | |
@@ -308,15 +308,15 @@ discard block |
||
| 308 | 308 | * @return void |
| 309 | 309 | */ |
| 310 | 310 | function nettoyer_petit_cache($prefix, $duree = 300) { |
| 311 | - // determiner le repertoire a purger : 'tmp/CACHE/rech/' |
|
| 312 | - $dircache = sous_repertoire(_DIR_CACHE, $prefix); |
|
| 313 | - if (spip_touch($dircache . 'purger_' . $prefix, $duree, true)) { |
|
| 314 | - foreach (preg_files($dircache, '[.]txt$') as $f) { |
|
| 315 | - if ($_SERVER['REQUEST_TIME'] - (@file_exists($f) ? @filemtime($f) : 0) > $duree) { |
|
| 316 | - spip_unlink($f); |
|
| 317 | - } |
|
| 318 | - } |
|
| 319 | - } |
|
| 311 | + // determiner le repertoire a purger : 'tmp/CACHE/rech/' |
|
| 312 | + $dircache = sous_repertoire(_DIR_CACHE, $prefix); |
|
| 313 | + if (spip_touch($dircache . 'purger_' . $prefix, $duree, true)) { |
|
| 314 | + foreach (preg_files($dircache, '[.]txt$') as $f) { |
|
| 315 | + if ($_SERVER['REQUEST_TIME'] - (@file_exists($f) ? @filemtime($f) : 0) > $duree) { |
|
| 316 | + spip_unlink($f); |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | |
@@ -344,134 +344,134 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | function public_cacher_dist($contexte, &$use_cache, &$chemin_cache, &$page, &$lastmodified) { |
| 346 | 346 | |
| 347 | - # fonction de cache minimale : dire "non on ne met rien en cache" |
|
| 348 | - # $use_cache = -1; return; |
|
| 349 | - |
|
| 350 | - // Second appel, destine a l'enregistrement du cache sur le disque |
|
| 351 | - if (isset($chemin_cache)) { |
|
| 352 | - creer_cache($page, $chemin_cache); |
|
| 353 | - return; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - // Toute la suite correspond au premier appel |
|
| 357 | - $contexte_implicite = $page['contexte_implicite']; |
|
| 358 | - |
|
| 359 | - // Cas ignorant le cache car completement dynamique |
|
| 360 | - if ( |
|
| 361 | - (!empty($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] === 'POST') |
|
| 362 | - or _request('connect') |
|
| 363 | - ) { |
|
| 364 | - $use_cache = -1; |
|
| 365 | - $lastmodified = 0; |
|
| 366 | - $chemin_cache = ''; |
|
| 367 | - $page = []; |
|
| 368 | - |
|
| 369 | - return; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - // Controler l'existence d'un cache nous correspondant |
|
| 373 | - $chemin_cache = generer_nom_fichier_cache($contexte, $page); |
|
| 374 | - $lastmodified = 0; |
|
| 375 | - |
|
| 376 | - // charger le cache s'il existe (et si il a bien le bon hash = anticollision) |
|
| 377 | - if (!$page = lire_cache($chemin_cache)) { |
|
| 378 | - $page = []; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - // s'il est sessionne, charger celui correspondant a notre session |
|
| 382 | - if ( |
|
| 383 | - isset($page['invalideurs']) |
|
| 384 | - and isset($page['invalideurs']['session']) |
|
| 385 | - ) { |
|
| 386 | - $chemin_cache_session = generer_nom_fichier_cache( |
|
| 387 | - ['chemin_cache' => $chemin_cache], |
|
| 388 | - ['session' => spip_session()] |
|
| 389 | - ); |
|
| 390 | - if ( |
|
| 391 | - $page_session = lire_cache($chemin_cache_session) |
|
| 392 | - and $page_session['lastmodified'] >= $page['lastmodified'] |
|
| 393 | - ) { |
|
| 394 | - $page = $page_session; |
|
| 395 | - } else { |
|
| 396 | - $page = []; |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - |
|
| 401 | - // Faut-il effacer des pages invalidees (en particulier ce cache-ci) ? |
|
| 402 | - if (isset($GLOBALS['meta']['invalider'])) { |
|
| 403 | - // ne le faire que si la base est disponible |
|
| 404 | - if (spip_connect()) { |
|
| 405 | - include_spip('inc/invalideur'); |
|
| 406 | - retire_caches($chemin_cache); # API invalideur inutile |
|
| 407 | - supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 408 | - if (isset($chemin_cache_session) and $chemin_cache_session) { |
|
| 409 | - supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - // Si un calcul, recalcul [ou preview, mais c'est recalcul] est demande, |
|
| 415 | - // on supprime le cache |
|
| 416 | - if ( |
|
| 417 | - defined('_VAR_MODE') && |
|
| 418 | - _VAR_MODE && |
|
| 419 | - (isset($_COOKIE['spip_session']) || |
|
| 420 | - isset($_COOKIE['spip_admin']) || |
|
| 421 | - @file_exists(_ACCESS_FILE_NAME)) |
|
| 422 | - ) { |
|
| 423 | - $page = ['contexte_implicite' => $contexte_implicite]; // ignorer le cache deja lu |
|
| 424 | - include_spip('inc/invalideur'); |
|
| 425 | - retire_caches($chemin_cache); # API invalideur inutile |
|
| 426 | - supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 427 | - if (isset($chemin_cache_session) and $chemin_cache_session) { |
|
| 428 | - supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - // $delais par defaut |
|
| 433 | - // pour toutes les pages sans #CACHE{} hors modeles/ et espace privé |
|
| 434 | - // qui sont a cache nul par defaut |
|
| 435 | - if (!isset($GLOBALS['delais'])) { |
|
| 436 | - if (!defined('_DUREE_CACHE_DEFAUT')) { |
|
| 437 | - define('_DUREE_CACHE_DEFAUT', 24 * 3600); |
|
| 438 | - } |
|
| 439 | - $GLOBALS['delais'] = _DUREE_CACHE_DEFAUT; |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - // determiner la validite de la page |
|
| 443 | - if ($page) { |
|
| 444 | - $use_cache = cache_valide($page, $page['lastmodified'] ?? 0); |
|
| 445 | - // le contexte implicite n'est pas stocke dans le cache, mais il y a equivalence |
|
| 446 | - // par le nom du cache. On le reinjecte donc ici pour utilisation eventuelle au calcul |
|
| 447 | - $page['contexte_implicite'] = $contexte_implicite; |
|
| 448 | - if (!$use_cache) { |
|
| 449 | - // $page est un cache utilisable |
|
| 450 | - gunzip_page($page); |
|
| 451 | - |
|
| 452 | - return; |
|
| 453 | - } |
|
| 454 | - } else { |
|
| 455 | - $page = ['contexte_implicite' => $contexte_implicite]; |
|
| 456 | - $use_cache = cache_valide($page, 0); // fichier cache absent : provoque le calcul |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - // Si pas valide mais pas de connexion a la base, le garder quand meme |
|
| 460 | - if (!spip_connect()) { |
|
| 461 | - if (isset($page['texte'])) { |
|
| 462 | - gunzip_page($page); |
|
| 463 | - $use_cache = 0; |
|
| 464 | - } else { |
|
| 465 | - spip_log("Erreur base de donnees, impossible utiliser $chemin_cache"); |
|
| 466 | - include_spip('inc/minipres'); |
|
| 467 | - |
|
| 468 | - return minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 469 | - } |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - if ($use_cache < 0) { |
|
| 473 | - $chemin_cache = ''; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - return; |
|
| 347 | + # fonction de cache minimale : dire "non on ne met rien en cache" |
|
| 348 | + # $use_cache = -1; return; |
|
| 349 | + |
|
| 350 | + // Second appel, destine a l'enregistrement du cache sur le disque |
|
| 351 | + if (isset($chemin_cache)) { |
|
| 352 | + creer_cache($page, $chemin_cache); |
|
| 353 | + return; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + // Toute la suite correspond au premier appel |
|
| 357 | + $contexte_implicite = $page['contexte_implicite']; |
|
| 358 | + |
|
| 359 | + // Cas ignorant le cache car completement dynamique |
|
| 360 | + if ( |
|
| 361 | + (!empty($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] === 'POST') |
|
| 362 | + or _request('connect') |
|
| 363 | + ) { |
|
| 364 | + $use_cache = -1; |
|
| 365 | + $lastmodified = 0; |
|
| 366 | + $chemin_cache = ''; |
|
| 367 | + $page = []; |
|
| 368 | + |
|
| 369 | + return; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + // Controler l'existence d'un cache nous correspondant |
|
| 373 | + $chemin_cache = generer_nom_fichier_cache($contexte, $page); |
|
| 374 | + $lastmodified = 0; |
|
| 375 | + |
|
| 376 | + // charger le cache s'il existe (et si il a bien le bon hash = anticollision) |
|
| 377 | + if (!$page = lire_cache($chemin_cache)) { |
|
| 378 | + $page = []; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + // s'il est sessionne, charger celui correspondant a notre session |
|
| 382 | + if ( |
|
| 383 | + isset($page['invalideurs']) |
|
| 384 | + and isset($page['invalideurs']['session']) |
|
| 385 | + ) { |
|
| 386 | + $chemin_cache_session = generer_nom_fichier_cache( |
|
| 387 | + ['chemin_cache' => $chemin_cache], |
|
| 388 | + ['session' => spip_session()] |
|
| 389 | + ); |
|
| 390 | + if ( |
|
| 391 | + $page_session = lire_cache($chemin_cache_session) |
|
| 392 | + and $page_session['lastmodified'] >= $page['lastmodified'] |
|
| 393 | + ) { |
|
| 394 | + $page = $page_session; |
|
| 395 | + } else { |
|
| 396 | + $page = []; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + |
|
| 401 | + // Faut-il effacer des pages invalidees (en particulier ce cache-ci) ? |
|
| 402 | + if (isset($GLOBALS['meta']['invalider'])) { |
|
| 403 | + // ne le faire que si la base est disponible |
|
| 404 | + if (spip_connect()) { |
|
| 405 | + include_spip('inc/invalideur'); |
|
| 406 | + retire_caches($chemin_cache); # API invalideur inutile |
|
| 407 | + supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 408 | + if (isset($chemin_cache_session) and $chemin_cache_session) { |
|
| 409 | + supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + // Si un calcul, recalcul [ou preview, mais c'est recalcul] est demande, |
|
| 415 | + // on supprime le cache |
|
| 416 | + if ( |
|
| 417 | + defined('_VAR_MODE') && |
|
| 418 | + _VAR_MODE && |
|
| 419 | + (isset($_COOKIE['spip_session']) || |
|
| 420 | + isset($_COOKIE['spip_admin']) || |
|
| 421 | + @file_exists(_ACCESS_FILE_NAME)) |
|
| 422 | + ) { |
|
| 423 | + $page = ['contexte_implicite' => $contexte_implicite]; // ignorer le cache deja lu |
|
| 424 | + include_spip('inc/invalideur'); |
|
| 425 | + retire_caches($chemin_cache); # API invalideur inutile |
|
| 426 | + supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 427 | + if (isset($chemin_cache_session) and $chemin_cache_session) { |
|
| 428 | + supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + // $delais par defaut |
|
| 433 | + // pour toutes les pages sans #CACHE{} hors modeles/ et espace privé |
|
| 434 | + // qui sont a cache nul par defaut |
|
| 435 | + if (!isset($GLOBALS['delais'])) { |
|
| 436 | + if (!defined('_DUREE_CACHE_DEFAUT')) { |
|
| 437 | + define('_DUREE_CACHE_DEFAUT', 24 * 3600); |
|
| 438 | + } |
|
| 439 | + $GLOBALS['delais'] = _DUREE_CACHE_DEFAUT; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + // determiner la validite de la page |
|
| 443 | + if ($page) { |
|
| 444 | + $use_cache = cache_valide($page, $page['lastmodified'] ?? 0); |
|
| 445 | + // le contexte implicite n'est pas stocke dans le cache, mais il y a equivalence |
|
| 446 | + // par le nom du cache. On le reinjecte donc ici pour utilisation eventuelle au calcul |
|
| 447 | + $page['contexte_implicite'] = $contexte_implicite; |
|
| 448 | + if (!$use_cache) { |
|
| 449 | + // $page est un cache utilisable |
|
| 450 | + gunzip_page($page); |
|
| 451 | + |
|
| 452 | + return; |
|
| 453 | + } |
|
| 454 | + } else { |
|
| 455 | + $page = ['contexte_implicite' => $contexte_implicite]; |
|
| 456 | + $use_cache = cache_valide($page, 0); // fichier cache absent : provoque le calcul |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + // Si pas valide mais pas de connexion a la base, le garder quand meme |
|
| 460 | + if (!spip_connect()) { |
|
| 461 | + if (isset($page['texte'])) { |
|
| 462 | + gunzip_page($page); |
|
| 463 | + $use_cache = 0; |
|
| 464 | + } else { |
|
| 465 | + spip_log("Erreur base de donnees, impossible utiliser $chemin_cache"); |
|
| 466 | + include_spip('inc/minipres'); |
|
| 467 | + |
|
| 468 | + return minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 469 | + } |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + if ($use_cache < 0) { |
|
| 473 | + $chemin_cache = ''; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + return; |
|
| 477 | 477 | } |