@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -18,154 +18,154 @@ discard block |
||
| 18 | 18 | * @return string |
| 19 | 19 | */ |
| 20 | 20 | function securiser_redirect_action($redirect) { |
| 21 | - $redirect ??= ''; |
|
| 22 | - // cas d'un double urlencode : si un urldecode de l'url n'est pas secure, on retient ca comme redirect |
|
| 23 | - if (str_contains($redirect, '%')) { |
|
| 24 | - $r2 = urldecode($redirect); |
|
| 25 | - if (($r3 = securiser_redirect_action($r2)) !== $r2) { |
|
| 26 | - return $r3; |
|
| 27 | - } |
|
| 28 | - } |
|
| 29 | - if ( |
|
| 30 | - (tester_url_absolue($redirect) || preg_match(',^\w+:,', trim($redirect))) |
|
| 31 | - && !defined('_AUTORISER_ACTION_ABS_REDIRECT') |
|
| 32 | - ) { |
|
| 33 | - // si l'url est une url du site, on la laisse passer sans rien faire |
|
| 34 | - // c'est encore le plus simple |
|
| 35 | - $base = $GLOBALS['meta']['adresse_site'] . '/'; |
|
| 36 | - if (strlen($base) && str_starts_with($redirect, $base)) { |
|
| 37 | - return $redirect; |
|
| 38 | - } |
|
| 39 | - $base = url_de_base(); |
|
| 40 | - if (strlen($base) && str_starts_with($redirect, $base)) { |
|
| 41 | - return $redirect; |
|
| 42 | - } |
|
| 21 | + $redirect ??= ''; |
|
| 22 | + // cas d'un double urlencode : si un urldecode de l'url n'est pas secure, on retient ca comme redirect |
|
| 23 | + if (str_contains($redirect, '%')) { |
|
| 24 | + $r2 = urldecode($redirect); |
|
| 25 | + if (($r3 = securiser_redirect_action($r2)) !== $r2) { |
|
| 26 | + return $r3; |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | + if ( |
|
| 30 | + (tester_url_absolue($redirect) || preg_match(',^\w+:,', trim($redirect))) |
|
| 31 | + && !defined('_AUTORISER_ACTION_ABS_REDIRECT') |
|
| 32 | + ) { |
|
| 33 | + // si l'url est une url du site, on la laisse passer sans rien faire |
|
| 34 | + // c'est encore le plus simple |
|
| 35 | + $base = $GLOBALS['meta']['adresse_site'] . '/'; |
|
| 36 | + if (strlen($base) && str_starts_with($redirect, $base)) { |
|
| 37 | + return $redirect; |
|
| 38 | + } |
|
| 39 | + $base = url_de_base(); |
|
| 40 | + if (strlen($base) && str_starts_with($redirect, $base)) { |
|
| 41 | + return $redirect; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return ''; |
|
| 45 | - } |
|
| 44 | + return ''; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $redirect; |
|
| 47 | + return $redirect; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | function traiter_appels_actions() { |
| 51 | - // cas de l'appel qui renvoie une redirection (302) ou rien (204) |
|
| 52 | - if ($action = _request('action')) { |
|
| 53 | - include_spip('base/abstract_sql'); // chargement systematique pour les actions |
|
| 54 | - include_spip('inc/autoriser'); |
|
| 55 | - include_spip('inc/headers'); |
|
| 56 | - include_spip('inc/actions'); |
|
| 57 | - // des actions peuvent appeler _T |
|
| 58 | - if (!isset($GLOBALS['spip_lang'])) { |
|
| 59 | - include_spip('inc/lang'); |
|
| 60 | - utiliser_langue_visiteur(); |
|
| 61 | - } |
|
| 62 | - // si l'action est provoque par un hit {ajax} |
|
| 63 | - // il faut transmettre l'env ajax au redirect |
|
| 64 | - // on le met avant dans la query string au cas ou l'action fait elle meme sa redirection |
|
| 65 | - if ( |
|
| 66 | - ($v = _request('var_ajax')) |
|
| 67 | - && $v !== 'form' |
|
| 68 | - && ($args = _request('var_ajax_env')) |
|
| 69 | - && ($url = _request('redirect')) |
|
| 70 | - ) { |
|
| 71 | - $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 72 | - $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 73 | - set_request('redirect', $url); |
|
| 74 | - } else { |
|
| 75 | - if (_request('redirect')) { |
|
| 76 | - set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - $var_f = charger_fonction($action, 'action'); |
|
| 80 | - $var_f(); |
|
| 81 | - if (!isset($GLOBALS['redirect'])) { |
|
| 82 | - $GLOBALS['redirect'] = _request('redirect') ?? ''; |
|
| 83 | - if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
| 84 | - $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']); |
|
| 85 | - } |
|
| 86 | - $GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']); |
|
| 87 | - } |
|
| 88 | - if ($url = $GLOBALS['redirect']) { |
|
| 89 | - // si l'action est provoque par un hit {ajax} |
|
| 90 | - // il faut transmettre l'env ajax au redirect |
|
| 91 | - // qui a pu etre defini par l'action |
|
| 92 | - if ( |
|
| 93 | - ($v = _request('var_ajax')) |
|
| 94 | - && $v !== 'form' |
|
| 95 | - && ($args = _request('var_ajax_env')) |
|
| 96 | - ) { |
|
| 97 | - $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 98 | - $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 99 | - // passer l'ancre en variable pour pouvoir la gerer cote serveur |
|
| 100 | - $url = preg_replace(',#([^#&?]+)$,', "&var_ajax_ancre=\\1", $url); |
|
| 101 | - } |
|
| 102 | - $url = str_replace('&', '&', $url); // les redirections se font en &, pas en en & |
|
| 103 | - redirige_par_entete($url); |
|
| 104 | - } |
|
| 51 | + // cas de l'appel qui renvoie une redirection (302) ou rien (204) |
|
| 52 | + if ($action = _request('action')) { |
|
| 53 | + include_spip('base/abstract_sql'); // chargement systematique pour les actions |
|
| 54 | + include_spip('inc/autoriser'); |
|
| 55 | + include_spip('inc/headers'); |
|
| 56 | + include_spip('inc/actions'); |
|
| 57 | + // des actions peuvent appeler _T |
|
| 58 | + if (!isset($GLOBALS['spip_lang'])) { |
|
| 59 | + include_spip('inc/lang'); |
|
| 60 | + utiliser_langue_visiteur(); |
|
| 61 | + } |
|
| 62 | + // si l'action est provoque par un hit {ajax} |
|
| 63 | + // il faut transmettre l'env ajax au redirect |
|
| 64 | + // on le met avant dans la query string au cas ou l'action fait elle meme sa redirection |
|
| 65 | + if ( |
|
| 66 | + ($v = _request('var_ajax')) |
|
| 67 | + && $v !== 'form' |
|
| 68 | + && ($args = _request('var_ajax_env')) |
|
| 69 | + && ($url = _request('redirect')) |
|
| 70 | + ) { |
|
| 71 | + $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 72 | + $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 73 | + set_request('redirect', $url); |
|
| 74 | + } else { |
|
| 75 | + if (_request('redirect')) { |
|
| 76 | + set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + $var_f = charger_fonction($action, 'action'); |
|
| 80 | + $var_f(); |
|
| 81 | + if (!isset($GLOBALS['redirect'])) { |
|
| 82 | + $GLOBALS['redirect'] = _request('redirect') ?? ''; |
|
| 83 | + if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
| 84 | + $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']); |
|
| 85 | + } |
|
| 86 | + $GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']); |
|
| 87 | + } |
|
| 88 | + if ($url = $GLOBALS['redirect']) { |
|
| 89 | + // si l'action est provoque par un hit {ajax} |
|
| 90 | + // il faut transmettre l'env ajax au redirect |
|
| 91 | + // qui a pu etre defini par l'action |
|
| 92 | + if ( |
|
| 93 | + ($v = _request('var_ajax')) |
|
| 94 | + && $v !== 'form' |
|
| 95 | + && ($args = _request('var_ajax_env')) |
|
| 96 | + ) { |
|
| 97 | + $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 98 | + $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 99 | + // passer l'ancre en variable pour pouvoir la gerer cote serveur |
|
| 100 | + $url = preg_replace(',#([^#&?]+)$,', "&var_ajax_ancre=\\1", $url); |
|
| 101 | + } |
|
| 102 | + $url = str_replace('&', '&', $url); // les redirections se font en &, pas en en & |
|
| 103 | + redirige_par_entete($url); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - // attention : avec zlib.output_compression=1 on a vu des cas de ob_get_length() qui renvoi 0 |
|
| 107 | - // et du coup en renvoi un status 204 a tort (vu sur le menu rubriques notamment) |
|
| 108 | - if (!headers_sent() && !ob_get_length()) { |
|
| 109 | - http_response_code(204); |
|
| 110 | - } // No Content |
|
| 111 | - return true; |
|
| 112 | - } |
|
| 106 | + // attention : avec zlib.output_compression=1 on a vu des cas de ob_get_length() qui renvoi 0 |
|
| 107 | + // et du coup en renvoi un status 204 a tort (vu sur le menu rubriques notamment) |
|
| 108 | + if (!headers_sent() && !ob_get_length()) { |
|
| 109 | + http_response_code(204); |
|
| 110 | + } // No Content |
|
| 111 | + return true; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return false; |
|
| 114 | + return false; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
| 118 | 118 | function refuser_traiter_formulaire_ajax() { |
| 119 | - if ( |
|
| 120 | - ($v = _request('var_ajax')) |
|
| 121 | - && $v == 'form' |
|
| 122 | - && ($form = _request('formulaire_action')) |
|
| 123 | - && ($args = _request('formulaire_action_args')) |
|
| 124 | - && decoder_contexte_ajax($args, $form) !== false |
|
| 125 | - ) { |
|
| 126 | - // on est bien dans le contexte de traitement d'un formulaire en ajax |
|
| 127 | - // mais traiter ne veut pas |
|
| 128 | - // on le dit a la page qui va resumbit |
|
| 129 | - // sans ajax |
|
| 130 | - include_spip('inc/actions'); |
|
| 131 | - ajax_retour('noajax', false); |
|
| 132 | - exit; |
|
| 133 | - } |
|
| 119 | + if ( |
|
| 120 | + ($v = _request('var_ajax')) |
|
| 121 | + && $v == 'form' |
|
| 122 | + && ($form = _request('formulaire_action')) |
|
| 123 | + && ($args = _request('formulaire_action_args')) |
|
| 124 | + && decoder_contexte_ajax($args, $form) !== false |
|
| 125 | + ) { |
|
| 126 | + // on est bien dans le contexte de traitement d'un formulaire en ajax |
|
| 127 | + // mais traiter ne veut pas |
|
| 128 | + // on le dit a la page qui va resumbit |
|
| 129 | + // sans ajax |
|
| 130 | + include_spip('inc/actions'); |
|
| 131 | + ajax_retour('noajax', false); |
|
| 132 | + exit; |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | function traiter_appels_inclusions_ajax() { |
| 137 | - // traiter les appels de bloc ajax (ex: pagination) |
|
| 138 | - if ( |
|
| 139 | - ($v = _request('var_ajax')) |
|
| 140 | - && $v !== 'form' |
|
| 141 | - && ($args = _request('var_ajax_env')) |
|
| 142 | - ) { |
|
| 143 | - include_spip('inc/filtres'); |
|
| 144 | - include_spip('inc/actions'); |
|
| 145 | - if ( |
|
| 146 | - ($args = decoder_contexte_ajax($args)) && ($fond = $args['fond']) |
|
| 147 | - ) { |
|
| 148 | - include_spip('public/assembler'); |
|
| 149 | - $contexte = calculer_contexte(); |
|
| 150 | - $contexte = array_merge($args, $contexte); |
|
| 151 | - $page = recuperer_fond($fond, $contexte, ['trim' => false]); |
|
| 152 | - $texte = $page; |
|
| 153 | - if ($ancre = _request('var_ajax_ancre')) { |
|
| 154 | - // pas n'importe quoi quand meme dans la variable ! |
|
| 155 | - $ancre = str_replace(['<', '"', "'"], ['<', '"', ''], $ancre); |
|
| 156 | - $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>" . $texte; |
|
| 157 | - } |
|
| 158 | - } else { |
|
| 159 | - include_spip('inc/headers'); |
|
| 160 | - http_response_code(400); |
|
| 161 | - $texte = _L('signature ajax bloc incorrecte'); |
|
| 162 | - } |
|
| 163 | - ajax_retour($texte, false); |
|
| 137 | + // traiter les appels de bloc ajax (ex: pagination) |
|
| 138 | + if ( |
|
| 139 | + ($v = _request('var_ajax')) |
|
| 140 | + && $v !== 'form' |
|
| 141 | + && ($args = _request('var_ajax_env')) |
|
| 142 | + ) { |
|
| 143 | + include_spip('inc/filtres'); |
|
| 144 | + include_spip('inc/actions'); |
|
| 145 | + if ( |
|
| 146 | + ($args = decoder_contexte_ajax($args)) && ($fond = $args['fond']) |
|
| 147 | + ) { |
|
| 148 | + include_spip('public/assembler'); |
|
| 149 | + $contexte = calculer_contexte(); |
|
| 150 | + $contexte = array_merge($args, $contexte); |
|
| 151 | + $page = recuperer_fond($fond, $contexte, ['trim' => false]); |
|
| 152 | + $texte = $page; |
|
| 153 | + if ($ancre = _request('var_ajax_ancre')) { |
|
| 154 | + // pas n'importe quoi quand meme dans la variable ! |
|
| 155 | + $ancre = str_replace(['<', '"', "'"], ['<', '"', ''], $ancre); |
|
| 156 | + $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>" . $texte; |
|
| 157 | + } |
|
| 158 | + } else { |
|
| 159 | + include_spip('inc/headers'); |
|
| 160 | + http_response_code(400); |
|
| 161 | + $texte = _L('signature ajax bloc incorrecte'); |
|
| 162 | + } |
|
| 163 | + ajax_retour($texte, false); |
|
| 164 | 164 | |
| 165 | - return true; // on a fini le hit |
|
| 166 | - } |
|
| 165 | + return true; // on a fini le hit |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - return false; |
|
| 168 | + return false; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // au 1er appel, traite les formulaires dynamiques charger/verifier/traiter |
@@ -173,176 +173,176 @@ discard block |
||
| 173 | 173 | // Le 1er renvoie True si il faut faire exit a la sortie |
| 174 | 174 | |
| 175 | 175 | function traiter_formulaires_dynamiques($get = false) { |
| 176 | - static $post = []; |
|
| 177 | - static $done = false; |
|
| 176 | + static $post = []; |
|
| 177 | + static $done = false; |
|
| 178 | 178 | |
| 179 | - if ($get) { |
|
| 180 | - return $post; |
|
| 181 | - } |
|
| 182 | - if ($done) { |
|
| 183 | - return false; |
|
| 184 | - } |
|
| 185 | - $done = true; |
|
| 179 | + if ($get) { |
|
| 180 | + return $post; |
|
| 181 | + } |
|
| 182 | + if ($done) { |
|
| 183 | + return false; |
|
| 184 | + } |
|
| 185 | + $done = true; |
|
| 186 | 186 | |
| 187 | - if ( |
|
| 188 | - !(($form = _request('formulaire_action')) |
|
| 189 | - && ($args = _request('formulaire_action_args'))) |
|
| 190 | - ) { |
|
| 191 | - return false; |
|
| 192 | - } // le hit peut continuer normalement |
|
| 187 | + if ( |
|
| 188 | + !(($form = _request('formulaire_action')) |
|
| 189 | + && ($args = _request('formulaire_action_args'))) |
|
| 190 | + ) { |
|
| 191 | + return false; |
|
| 192 | + } // le hit peut continuer normalement |
|
| 193 | 193 | |
| 194 | - // verifier que le post est licite (du meme auteur ou d'une session anonyme) |
|
| 195 | - $sign = _request('formulaire_action_sign'); |
|
| 196 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 197 | - if (empty($sign)) { |
|
| 198 | - spip_logger('formulaires')->error("signature ajax form incorrecte : $form (formulaire non signe mais on a une session)"); |
|
| 199 | - return false; |
|
| 200 | - } |
|
| 201 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 202 | - $secu = $securiser_action($form, $args, '', -1); |
|
| 203 | - if ($sign !== $secu['hash']) { |
|
| 204 | - spip_logger('formulaires')->error("signature ajax form incorrecte : $form (formulaire signe mais ne correspond pas a la session)"); |
|
| 205 | - return false; |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - else { |
|
| 209 | - if (!empty($sign)) { |
|
| 210 | - spip_logger('formulaires')->error("signature ajax form incorrecte : $form (formulaire signe mais pas de session)"); |
|
| 211 | - return false; |
|
| 212 | - } |
|
| 213 | - } |
|
| 194 | + // verifier que le post est licite (du meme auteur ou d'une session anonyme) |
|
| 195 | + $sign = _request('formulaire_action_sign'); |
|
| 196 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 197 | + if (empty($sign)) { |
|
| 198 | + spip_logger('formulaires')->error("signature ajax form incorrecte : $form (formulaire non signe mais on a une session)"); |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 201 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 202 | + $secu = $securiser_action($form, $args, '', -1); |
|
| 203 | + if ($sign !== $secu['hash']) { |
|
| 204 | + spip_logger('formulaires')->error("signature ajax form incorrecte : $form (formulaire signe mais ne correspond pas a la session)"); |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + else { |
|
| 209 | + if (!empty($sign)) { |
|
| 210 | + spip_logger('formulaires')->error("signature ajax form incorrecte : $form (formulaire signe mais pas de session)"); |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - include_spip('inc/filtres'); |
|
| 216 | - if (($args = decoder_contexte_ajax($args, $form)) === false) { |
|
| 217 | - spip_logger('formulaires')->error("signature ajax form incorrecte : $form (encodage corrompu)"); |
|
| 215 | + include_spip('inc/filtres'); |
|
| 216 | + if (($args = decoder_contexte_ajax($args, $form)) === false) { |
|
| 217 | + spip_logger('formulaires')->error("signature ajax form incorrecte : $form (encodage corrompu)"); |
|
| 218 | 218 | |
| 219 | - return false; // continuons le hit comme si de rien etait |
|
| 220 | - } else { |
|
| 221 | - include_spip('inc/lang'); |
|
| 222 | - // sauvegarder la lang en cours |
|
| 223 | - $old_lang = $GLOBALS['spip_lang']; |
|
| 224 | - // changer la langue avec celle qui a cours dans le formulaire |
|
| 225 | - // on la depile de $args car c'est un argument implicite masque |
|
| 226 | - changer_langue(array_shift($args)); |
|
| 219 | + return false; // continuons le hit comme si de rien etait |
|
| 220 | + } else { |
|
| 221 | + include_spip('inc/lang'); |
|
| 222 | + // sauvegarder la lang en cours |
|
| 223 | + $old_lang = $GLOBALS['spip_lang']; |
|
| 224 | + // changer la langue avec celle qui a cours dans le formulaire |
|
| 225 | + // on la depile de $args car c'est un argument implicite masque |
|
| 226 | + changer_langue(array_shift($args)); |
|
| 227 | 227 | |
| 228 | 228 | |
| 229 | - // inclure mes_fonctions et autres filtres avant verifier/traiter |
|
| 230 | - include_fichiers_fonctions(); |
|
| 231 | - // ainsi que l'API SQL bien utile dans verifier/traiter |
|
| 232 | - include_spip('base/abstract_sql'); |
|
| 229 | + // inclure mes_fonctions et autres filtres avant verifier/traiter |
|
| 230 | + include_fichiers_fonctions(); |
|
| 231 | + // ainsi que l'API SQL bien utile dans verifier/traiter |
|
| 232 | + include_spip('base/abstract_sql'); |
|
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * Pipeline exécuté lors de la soumission d'un formulaire, |
|
| 236 | - * mais avant l'appel de la fonction de vérification. |
|
| 237 | - */ |
|
| 238 | - pipeline( |
|
| 239 | - 'formulaire_receptionner', |
|
| 240 | - [ |
|
| 241 | - 'args' => ['form' => $form, 'args' => $args], |
|
| 242 | - 'data' => null, |
|
| 243 | - ] |
|
| 244 | - ); |
|
| 234 | + /** |
|
| 235 | + * Pipeline exécuté lors de la soumission d'un formulaire, |
|
| 236 | + * mais avant l'appel de la fonction de vérification. |
|
| 237 | + */ |
|
| 238 | + pipeline( |
|
| 239 | + 'formulaire_receptionner', |
|
| 240 | + [ |
|
| 241 | + 'args' => ['form' => $form, 'args' => $args], |
|
| 242 | + 'data' => null, |
|
| 243 | + ] |
|
| 244 | + ); |
|
| 245 | 245 | |
| 246 | - $verifier = charger_fonction('verifier', "formulaires/$form/", true); |
|
| 247 | - $post["erreurs_$form"] = pipeline( |
|
| 248 | - 'formulaire_verifier', |
|
| 249 | - [ |
|
| 250 | - 'args' => ['form' => $form, 'args' => $args], |
|
| 251 | - 'data' => $verifier ? $verifier(...$args) : [] |
|
| 252 | - ] |
|
| 253 | - ); |
|
| 254 | - // prise en charge CVT multi etape si besoin |
|
| 255 | - if (_request('cvtm_prev_post')) { |
|
| 256 | - include_spip('inc/cvt_multietapes'); |
|
| 257 | - $post["erreurs_$form"] = cvtmulti_formulaire_verifier_etapes( |
|
| 258 | - ['form' => $form, 'args' => $args], |
|
| 259 | - $post["erreurs_$form"] |
|
| 260 | - ); |
|
| 261 | - } |
|
| 246 | + $verifier = charger_fonction('verifier', "formulaires/$form/", true); |
|
| 247 | + $post["erreurs_$form"] = pipeline( |
|
| 248 | + 'formulaire_verifier', |
|
| 249 | + [ |
|
| 250 | + 'args' => ['form' => $form, 'args' => $args], |
|
| 251 | + 'data' => $verifier ? $verifier(...$args) : [] |
|
| 252 | + ] |
|
| 253 | + ); |
|
| 254 | + // prise en charge CVT multi etape si besoin |
|
| 255 | + if (_request('cvtm_prev_post')) { |
|
| 256 | + include_spip('inc/cvt_multietapes'); |
|
| 257 | + $post["erreurs_$form"] = cvtmulti_formulaire_verifier_etapes( |
|
| 258 | + ['form' => $form, 'args' => $args], |
|
| 259 | + $post["erreurs_$form"] |
|
| 260 | + ); |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - // accessibilite : si des erreurs mais pas de message general l'ajouter |
|
| 264 | - if (isset($post["erreurs_$form"]) && (is_countable($post["erreurs_$form"]) ? count($post["erreurs_$form"]) : 0) && !isset($post["erreurs_$form"]['message_erreur'])) { |
|
| 265 | - $post["erreurs_$form"]['message_erreur'] = singulier_ou_pluriel( |
|
| 266 | - is_countable($post["erreurs_$form"]) ? count($post["erreurs_$form"]) : 0, |
|
| 267 | - 'avis_1_erreur_saisie', |
|
| 268 | - 'avis_nb_erreurs_saisie' |
|
| 269 | - ); |
|
| 270 | - } |
|
| 263 | + // accessibilite : si des erreurs mais pas de message general l'ajouter |
|
| 264 | + if (isset($post["erreurs_$form"]) && (is_countable($post["erreurs_$form"]) ? count($post["erreurs_$form"]) : 0) && !isset($post["erreurs_$form"]['message_erreur'])) { |
|
| 265 | + $post["erreurs_$form"]['message_erreur'] = singulier_ou_pluriel( |
|
| 266 | + is_countable($post["erreurs_$form"]) ? count($post["erreurs_$form"]) : 0, |
|
| 267 | + 'avis_1_erreur_saisie', |
|
| 268 | + 'avis_nb_erreurs_saisie' |
|
| 269 | + ); |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - // si on ne demandait qu'une verif json |
|
| 273 | - if (_request('formulaire_action_verifier_json')) { |
|
| 274 | - include_spip('inc/json'); |
|
| 275 | - include_spip('inc/actions'); |
|
| 276 | - ajax_retour(json_encode($post["erreurs_$form"], JSON_THROW_ON_ERROR), 'text/plain'); |
|
| 272 | + // si on ne demandait qu'une verif json |
|
| 273 | + if (_request('formulaire_action_verifier_json')) { |
|
| 274 | + include_spip('inc/json'); |
|
| 275 | + include_spip('inc/actions'); |
|
| 276 | + ajax_retour(json_encode($post["erreurs_$form"], JSON_THROW_ON_ERROR), 'text/plain'); |
|
| 277 | 277 | |
| 278 | - return true; // on a fini le hit |
|
| 279 | - } |
|
| 280 | - $retour = ''; |
|
| 281 | - if (isset($post["erreurs_$form"]) && (is_countable($post["erreurs_$form"]) ? count($post["erreurs_$form"]) : 0) == 0) { |
|
| 282 | - $rev = ''; |
|
| 283 | - if ($traiter = charger_fonction('traiter', "formulaires/$form/", true)) { |
|
| 284 | - $rev = $traiter(...$args); |
|
| 285 | - } |
|
| 278 | + return true; // on a fini le hit |
|
| 279 | + } |
|
| 280 | + $retour = ''; |
|
| 281 | + if (isset($post["erreurs_$form"]) && (is_countable($post["erreurs_$form"]) ? count($post["erreurs_$form"]) : 0) == 0) { |
|
| 282 | + $rev = ''; |
|
| 283 | + if ($traiter = charger_fonction('traiter', "formulaires/$form/", true)) { |
|
| 284 | + $rev = $traiter(...$args); |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - $rev = pipeline( |
|
| 288 | - 'formulaire_traiter', |
|
| 289 | - [ |
|
| 290 | - 'args' => ['form' => $form, 'args' => $args], |
|
| 291 | - 'data' => $rev |
|
| 292 | - ] |
|
| 293 | - ); |
|
| 294 | - // le retour de traiter est |
|
| 295 | - // un tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx) |
|
| 296 | - // il permet le pipelinage, en particulier |
|
| 297 | - // en y passant l'id de l'objet cree/modifie |
|
| 298 | - // si message_erreur est present, on considere que le traitement a echoue |
|
| 299 | - $post["message_ok_$form"] = ''; |
|
| 300 | - // on peut avoir message_ok et message_erreur |
|
| 301 | - if (isset($rev['message_ok'])) { |
|
| 302 | - $post["message_ok_$form"] = $rev['message_ok']; |
|
| 303 | - } |
|
| 287 | + $rev = pipeline( |
|
| 288 | + 'formulaire_traiter', |
|
| 289 | + [ |
|
| 290 | + 'args' => ['form' => $form, 'args' => $args], |
|
| 291 | + 'data' => $rev |
|
| 292 | + ] |
|
| 293 | + ); |
|
| 294 | + // le retour de traiter est |
|
| 295 | + // un tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx) |
|
| 296 | + // il permet le pipelinage, en particulier |
|
| 297 | + // en y passant l'id de l'objet cree/modifie |
|
| 298 | + // si message_erreur est present, on considere que le traitement a echoue |
|
| 299 | + $post["message_ok_$form"] = ''; |
|
| 300 | + // on peut avoir message_ok et message_erreur |
|
| 301 | + if (isset($rev['message_ok'])) { |
|
| 302 | + $post["message_ok_$form"] = $rev['message_ok']; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - // verifier si traiter n'a pas echoue avec une erreur : |
|
| 306 | - if (isset($rev['message_erreur'])) { |
|
| 307 | - $post["erreurs_$form"]['message_erreur'] = $rev['message_erreur']; |
|
| 308 | - // si il y a une erreur on ne redirige pas |
|
| 309 | - } else { |
|
| 310 | - // sinon faire ce qu'il faut : |
|
| 311 | - if (isset($rev['editable'])) { |
|
| 312 | - $post["editable_$form"] = $rev['editable']; |
|
| 313 | - } |
|
| 314 | - // si une redirection est demandee, appeler redirigae_formulaire qui choisira |
|
| 315 | - // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) |
|
| 316 | - if (isset($rev['redirect']) && $rev['redirect']) { |
|
| 317 | - include_spip('inc/headers'); |
|
| 318 | - [$masque, $message] = redirige_formulaire($rev['redirect'], '', 'ajaxform'); |
|
| 319 | - $post["message_ok_$form"] .= $message; |
|
| 320 | - $retour .= $masque; |
|
| 321 | - } |
|
| 322 | - // Si multiétape, puisqu'on a tout fait, on peut recommencer à zéro |
|
| 323 | - if (_request('_etapes')) { |
|
| 324 | - set_request('_etape', null); |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - } |
|
| 328 | - // si le formulaire a ete soumis en ajax, on le renvoie direct ! |
|
| 329 | - if (_request('var_ajax')) { |
|
| 330 | - if (find_in_path('formulaire_.php', 'balise/', true)) { |
|
| 331 | - include_spip('inc/actions'); |
|
| 332 | - include_spip('public/assembler'); |
|
| 333 | - $retour .= inclure_balise_dynamique(balise_formulaire__dyn($form, ...$args), false); |
|
| 334 | - // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 |
|
| 335 | - // sans cela le formulaire n'est pas actif apres le hit ajax |
|
| 336 | - // la classe ajax-form-is-ok sert a s'assurer que le retour ajax s'est bien passe |
|
| 337 | - $retour = "<br class='bugajaxie ajax-form-is-ok' style='display:none;'/>" . $retour; |
|
| 338 | - ajax_retour($retour, false); |
|
| 305 | + // verifier si traiter n'a pas echoue avec une erreur : |
|
| 306 | + if (isset($rev['message_erreur'])) { |
|
| 307 | + $post["erreurs_$form"]['message_erreur'] = $rev['message_erreur']; |
|
| 308 | + // si il y a une erreur on ne redirige pas |
|
| 309 | + } else { |
|
| 310 | + // sinon faire ce qu'il faut : |
|
| 311 | + if (isset($rev['editable'])) { |
|
| 312 | + $post["editable_$form"] = $rev['editable']; |
|
| 313 | + } |
|
| 314 | + // si une redirection est demandee, appeler redirigae_formulaire qui choisira |
|
| 315 | + // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) |
|
| 316 | + if (isset($rev['redirect']) && $rev['redirect']) { |
|
| 317 | + include_spip('inc/headers'); |
|
| 318 | + [$masque, $message] = redirige_formulaire($rev['redirect'], '', 'ajaxform'); |
|
| 319 | + $post["message_ok_$form"] .= $message; |
|
| 320 | + $retour .= $masque; |
|
| 321 | + } |
|
| 322 | + // Si multiétape, puisqu'on a tout fait, on peut recommencer à zéro |
|
| 323 | + if (_request('_etapes')) { |
|
| 324 | + set_request('_etape', null); |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | + // si le formulaire a ete soumis en ajax, on le renvoie direct ! |
|
| 329 | + if (_request('var_ajax')) { |
|
| 330 | + if (find_in_path('formulaire_.php', 'balise/', true)) { |
|
| 331 | + include_spip('inc/actions'); |
|
| 332 | + include_spip('public/assembler'); |
|
| 333 | + $retour .= inclure_balise_dynamique(balise_formulaire__dyn($form, ...$args), false); |
|
| 334 | + // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 |
|
| 335 | + // sans cela le formulaire n'est pas actif apres le hit ajax |
|
| 336 | + // la classe ajax-form-is-ok sert a s'assurer que le retour ajax s'est bien passe |
|
| 337 | + $retour = "<br class='bugajaxie ajax-form-is-ok' style='display:none;'/>" . $retour; |
|
| 338 | + ajax_retour($retour, false); |
|
| 339 | 339 | |
| 340 | - return true; // on a fini le hit |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - // restaurer la lang en cours |
|
| 344 | - changer_langue($old_lang); |
|
| 345 | - } |
|
| 340 | + return true; // on a fini le hit |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + // restaurer la lang en cours |
|
| 344 | + changer_langue($old_lang); |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | - return false; // le hit peut continuer normalement |
|
| 347 | + return false; // le hit peut continuer normalement |
|
| 348 | 348 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | ) { |
| 33 | 33 | // si l'url est une url du site, on la laisse passer sans rien faire |
| 34 | 34 | // c'est encore le plus simple |
| 35 | - $base = $GLOBALS['meta']['adresse_site'] . '/'; |
|
| 35 | + $base = $GLOBALS['meta']['adresse_site'].'/'; |
|
| 36 | 36 | if (strlen($base) && str_starts_with($redirect, $base)) { |
| 37 | 37 | return $redirect; |
| 38 | 38 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | if ($ancre = _request('var_ajax_ancre')) { |
| 154 | 154 | // pas n'importe quoi quand meme dans la variable ! |
| 155 | 155 | $ancre = str_replace(['<', '"', "'"], ['<', '"', ''], $ancre); |
| 156 | - $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>" . $texte; |
|
| 156 | + $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>".$texte; |
|
| 157 | 157 | } |
| 158 | 158 | } else { |
| 159 | 159 | include_spip('inc/headers'); |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 |
| 335 | 335 | // sans cela le formulaire n'est pas actif apres le hit ajax |
| 336 | 336 | // la classe ajax-form-is-ok sert a s'assurer que le retour ajax s'est bien passe |
| 337 | - $retour = "<br class='bugajaxie ajax-form-is-ok' style='display:none;'/>" . $retour; |
|
| 337 | + $retour = "<br class='bugajaxie ajax-form-is-ok' style='display:none;'/>".$retour; |
|
| 338 | 338 | ajax_retour($retour, false); |
| 339 | 339 | |
| 340 | 340 | return true; // on a fini le hit |
@@ -204,8 +204,7 @@ |
||
| 204 | 204 | spip_logger('formulaires')->error("signature ajax form incorrecte : $form (formulaire signe mais ne correspond pas a la session)"); |
| 205 | 205 | return false; |
| 206 | 206 | } |
| 207 | - } |
|
| 208 | - else { |
|
| 207 | + } else { |
|
| 209 | 208 | if (!empty($sign)) { |
| 210 | 209 | spip_logger('formulaires')->error("signature ajax form incorrecte : $form (formulaire signe mais pas de session)"); |
| 211 | 210 | return false; |
@@ -19,17 +19,17 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | require_once __DIR__ . '/bootstrap/config/initial.php'; |
| 26 | 26 | |
| 27 | 27 | // inclure l'ecran de securite si il n'a pas été inclus en prepend php |
| 28 | 28 | if ( |
| 29 | - !defined('_ECRAN_SECURITE') |
|
| 30 | - && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 29 | + !defined('_ECRAN_SECURITE') |
|
| 30 | + && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 31 | 31 | ) { |
| 32 | - include $f; |
|
| 32 | + include $f; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // et on peut lancer l'autoloader |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | // Definition personnelles eventuelles |
| 77 | 77 | |
| 78 | 78 | if (_FILE_OPTIONS) { |
| 79 | - include_once _FILE_OPTIONS; |
|
| 79 | + include_once _FILE_OPTIONS; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | if (!defined('SPIP_ERREUR_REPORT')) { |
| 83 | - /** Masquer les warning */ |
|
| 84 | - define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 83 | + /** Masquer les warning */ |
|
| 84 | + define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | ErrorHandler::setup(SPIP_ERREUR_REPORT); |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | // ===> on execute en neutralisant les messages d'erreur |
| 96 | 96 | |
| 97 | 97 | spip_initialisation_core( |
| 98 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 99 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 100 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 101 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 98 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 99 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 100 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 101 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | // chargement des plugins : doit arriver en dernier |
@@ -107,75 +107,75 @@ discard block |
||
| 107 | 107 | // donc il faut avoir tout fini ici avant de charger les plugins |
| 108 | 108 | |
| 109 | 109 | if (@is_readable(_CACHE_PLUGINS_OPT) && @is_readable(_CACHE_PLUGINS_PATH)) { |
| 110 | - // chargement optimise precompile |
|
| 111 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 110 | + // chargement optimise precompile |
|
| 111 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 112 | 112 | } else { |
| 113 | - spip_initialisation_suite(); |
|
| 114 | - include_spip('inc/plugin'); |
|
| 115 | - // generer les fichiers php precompiles |
|
| 116 | - // de chargement des plugins et des pipelines |
|
| 117 | - actualise_plugins_actifs(); |
|
| 113 | + spip_initialisation_suite(); |
|
| 114 | + include_spip('inc/plugin'); |
|
| 115 | + // generer les fichiers php precompiles |
|
| 116 | + // de chargement des plugins et des pipelines |
|
| 117 | + actualise_plugins_actifs(); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Initialisations non critiques surchargeables par les plugins |
| 121 | 121 | spip_initialisation_suite(); |
| 122 | 122 | |
| 123 | 123 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 124 | - /** |
|
| 125 | - * Niveau maxi d'enregistrement des logs |
|
| 126 | - * @var LogLevel::* |
|
| 127 | - */ |
|
| 128 | - define('_LOG_FILTRE_GRAVITE', LogLevel::NOTICE); |
|
| 124 | + /** |
|
| 125 | + * Niveau maxi d'enregistrement des logs |
|
| 126 | + * @var LogLevel::* |
|
| 127 | + */ |
|
| 128 | + define('_LOG_FILTRE_GRAVITE', LogLevel::NOTICE); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | if (!defined('_OUTILS_DEVELOPPEURS')) { |
| 132 | - /** Activer des outils pour développeurs ? */ |
|
| 133 | - define('_OUTILS_DEVELOPPEURS', false); |
|
| 132 | + /** Activer des outils pour développeurs ? */ |
|
| 133 | + define('_OUTILS_DEVELOPPEURS', false); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // charger systematiquement inc/autoriser dans l'espace restreint |
| 137 | 137 | if (test_espace_prive()) { |
| 138 | - include_spip('inc/autoriser'); |
|
| 138 | + include_spip('inc/autoriser'); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // |
| 142 | 142 | // Installer Spip si pas installe... sauf si justement on est en train |
| 143 | 143 | // |
| 144 | 144 | if ( |
| 145 | - !(_FILE_CONNECT |
|
| 146 | - || autoriser_sans_cookie(_request('exec')) |
|
| 147 | - || _request('action') == 'cookie' |
|
| 148 | - || _request('action') == 'converser' |
|
| 149 | - || _request('action') == 'test_dirs') |
|
| 145 | + !(_FILE_CONNECT |
|
| 146 | + || autoriser_sans_cookie(_request('exec')) |
|
| 147 | + || _request('action') == 'cookie' |
|
| 148 | + || _request('action') == 'converser' |
|
| 149 | + || _request('action') == 'test_dirs') |
|
| 150 | 150 | ) { |
| 151 | - // Si on peut installer, on lance illico |
|
| 152 | - if (test_espace_prive()) { |
|
| 153 | - include_spip('inc/headers'); |
|
| 154 | - redirige_url_ecrire('install'); |
|
| 155 | - } else { |
|
| 156 | - // Si on est dans le site public, dire que qq s'en occupe |
|
| 157 | - include_spip('inc/lang'); |
|
| 158 | - utiliser_langue_visiteur(); |
|
| 159 | - include_spip('inc/minipres'); |
|
| 160 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 161 | - exit; |
|
| 162 | - } |
|
| 163 | - // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 151 | + // Si on peut installer, on lance illico |
|
| 152 | + if (test_espace_prive()) { |
|
| 153 | + include_spip('inc/headers'); |
|
| 154 | + redirige_url_ecrire('install'); |
|
| 155 | + } else { |
|
| 156 | + // Si on est dans le site public, dire que qq s'en occupe |
|
| 157 | + include_spip('inc/lang'); |
|
| 158 | + utiliser_langue_visiteur(); |
|
| 159 | + include_spip('inc/minipres'); |
|
| 160 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 161 | + exit; |
|
| 162 | + } |
|
| 163 | + // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // memoriser un tri sessionne eventuel |
| 167 | 167 | if ( |
| 168 | - isset($_REQUEST['var_memotri']) |
|
| 169 | - && ($t = $_REQUEST['var_memotri']) |
|
| 170 | - && (str_starts_with((string) $t, 'trisession') || str_starts_with((string) $t, 'senssession')) |
|
| 168 | + isset($_REQUEST['var_memotri']) |
|
| 169 | + && ($t = $_REQUEST['var_memotri']) |
|
| 170 | + && (str_starts_with((string) $t, 'trisession') || str_starts_with((string) $t, 'senssession')) |
|
| 171 | 171 | ) { |
| 172 | - if (!function_exists('session_set')) { |
|
| 173 | - include_spip('inc/session'); |
|
| 174 | - } |
|
| 175 | - $t = preg_replace(',\W,', '_', (string) $t); |
|
| 176 | - if ($v = _request($t)) { |
|
| 177 | - session_set($t, $v); |
|
| 178 | - } |
|
| 172 | + if (!function_exists('session_set')) { |
|
| 173 | + include_spip('inc/session'); |
|
| 174 | + } |
|
| 175 | + $t = preg_replace(',\W,', '_', (string) $t); |
|
| 176 | + if ($v = _request($t)) { |
|
| 177 | + session_set($t, $v); |
|
| 178 | + } |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -185,22 +185,22 @@ discard block |
||
| 185 | 185 | * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite |
| 186 | 186 | */ |
| 187 | 187 | if (!defined('_HEADER_COMPOSED_BY')) { |
| 188 | - define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 188 | + define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 189 | 189 | } |
| 190 | 190 | if (!headers_sent() && _HEADER_COMPOSED_BY) { |
| 191 | - if (!defined('_HEADER_VARY')) { |
|
| 192 | - define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 193 | - } |
|
| 194 | - if (_HEADER_VARY) { |
|
| 195 | - header(_HEADER_VARY); |
|
| 196 | - } |
|
| 197 | - if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
|
| 198 | - include_spip('inc/filtres_mini'); |
|
| 199 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 200 | - } else { |
|
| 201 | - // header minimal |
|
| 202 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 203 | - } |
|
| 191 | + if (!defined('_HEADER_VARY')) { |
|
| 192 | + define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 193 | + } |
|
| 194 | + if (_HEADER_VARY) { |
|
| 195 | + header(_HEADER_VARY); |
|
| 196 | + } |
|
| 197 | + if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
|
| 198 | + include_spip('inc/filtres_mini'); |
|
| 199 | + header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 200 | + } else { |
|
| 201 | + // header minimal |
|
| 202 | + header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 203 | + } |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
@@ -22,22 +22,22 @@ discard block |
||
| 22 | 22 | return; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -require_once __DIR__ . '/bootstrap/config/initial.php'; |
|
| 25 | +require_once __DIR__.'/bootstrap/config/initial.php'; |
|
| 26 | 26 | |
| 27 | 27 | // inclure l'ecran de securite si il n'a pas été inclus en prepend php |
| 28 | 28 | if ( |
| 29 | 29 | !defined('_ECRAN_SECURITE') |
| 30 | - && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 30 | + && @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES.'ecran_securite.php') |
|
| 31 | 31 | ) { |
| 32 | 32 | include $f; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // et on peut lancer l'autoloader |
| 36 | -require_once dirname(__DIR__) . '/vendor/autoload.php'; |
|
| 36 | +require_once dirname(__DIR__).'/vendor/autoload.php'; |
|
| 37 | 37 | |
| 38 | -require_once __DIR__ . '/bootstrap/config/globals.php'; |
|
| 39 | -require_once __DIR__ . '/bootstrap/proxy.php'; |
|
| 40 | -require_once __DIR__ . '/bootstrap/mitigation.php'; |
|
| 38 | +require_once __DIR__.'/bootstrap/config/globals.php'; |
|
| 39 | +require_once __DIR__.'/bootstrap/proxy.php'; |
|
| 40 | +require_once __DIR__.'/bootstrap/mitigation.php'; |
|
| 41 | 41 | |
| 42 | 42 | // numero de branche, utilise par les plugins |
| 43 | 43 | // pour specifier les versions de SPIP necessaires |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | // |
| 72 | 72 | // Charger les fonctions liees aux serveurs Http et Sql. |
| 73 | 73 | // |
| 74 | -require_once __DIR__ . '/bootstrap/functions.php'; |
|
| 74 | +require_once __DIR__.'/bootstrap/functions.php'; |
|
| 75 | 75 | |
| 76 | 76 | // Definition personnelles eventuelles |
| 77 | 77 | |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | // ===> on execute en neutralisant les messages d'erreur |
| 96 | 96 | |
| 97 | 97 | spip_initialisation_core( |
| 98 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 99 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 100 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 101 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 98 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 99 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 100 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 101 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | // chargement des plugins : doit arriver en dernier |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | include_spip('inc/lang'); |
| 158 | 158 | utiliser_langue_visiteur(); |
| 159 | 159 | include_spip('inc/minipres'); |
| 160 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 160 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>"._T('info_travaux_texte').'</p>', ['status' => 503]); |
|
| 161 | 161 | exit; |
| 162 | 162 | } |
| 163 | 163 | // autrement c'est une install ad hoc (spikini...), on sait pas faire |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
| 198 | 198 | include_spip('inc/filtres_mini'); |
| 199 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 199 | + header(_HEADER_COMPOSED_BY." $spip_version_affichee @ www.spip.net + ".url_absolue(_DIR_VAR.'config.txt')); |
|
| 200 | 200 | } else { |
| 201 | 201 | // header minimal |
| 202 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 202 | + header(_HEADER_COMPOSED_BY.' @ www.spip.net'); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
| 207 | -spip_logger()->debug($methode . ' ' . self() . ' - ' . _FILE_CONNECT); |
|
| 207 | +spip_logger()->debug($methode.' '.self().' - '._FILE_CONNECT); |
|
@@ -28,52 +28,52 @@ discard block |
||
| 28 | 28 | * texte |
| 29 | 29 | */ |
| 30 | 30 | function _T($texte, $args = [], $options = []) { |
| 31 | - static $traduire = false; |
|
| 32 | - $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 33 | - if ($options) { |
|
| 34 | - // support de l'ancien argument $class |
|
| 35 | - if (is_string($options)) { |
|
| 36 | - $options = ['class' => $options]; |
|
| 37 | - } |
|
| 38 | - $o = array_merge($o, $options); |
|
| 39 | - } |
|
| 31 | + static $traduire = false; |
|
| 32 | + $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 33 | + if ($options) { |
|
| 34 | + // support de l'ancien argument $class |
|
| 35 | + if (is_string($options)) { |
|
| 36 | + $options = ['class' => $options]; |
|
| 37 | + } |
|
| 38 | + $o = array_merge($o, $options); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - if (!$traduire) { |
|
| 42 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 43 | - include_spip('inc/lang'); |
|
| 44 | - } |
|
| 41 | + if (!$traduire) { |
|
| 42 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 43 | + include_spip('inc/lang'); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // On peut passer explicitement la langue dans le tableau |
|
| 47 | - // On utilise le même nom de variable que la globale |
|
| 48 | - if (isset($args['spip_lang'])) { |
|
| 49 | - $lang = $args['spip_lang']; |
|
| 50 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 51 | - unset($args['spip_lang']); |
|
| 52 | - } // Sinon on prend la langue du contexte |
|
| 53 | - else { |
|
| 54 | - $lang = $GLOBALS['spip_lang']; |
|
| 55 | - } |
|
| 56 | - $text = $traduire($texte, $lang); |
|
| 46 | + // On peut passer explicitement la langue dans le tableau |
|
| 47 | + // On utilise le même nom de variable que la globale |
|
| 48 | + if (isset($args['spip_lang'])) { |
|
| 49 | + $lang = $args['spip_lang']; |
|
| 50 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 51 | + unset($args['spip_lang']); |
|
| 52 | + } // Sinon on prend la langue du contexte |
|
| 53 | + else { |
|
| 54 | + $lang = $GLOBALS['spip_lang']; |
|
| 55 | + } |
|
| 56 | + $text = $traduire($texte, $lang); |
|
| 57 | 57 | |
| 58 | - if ($text === null || !strlen($text)) { |
|
| 59 | - if (!$o['force']) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 58 | + if ($text === null || !strlen($text)) { |
|
| 59 | + if (!$o['force']) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $text = $texte; |
|
| 63 | + $text = $texte; |
|
| 64 | 64 | |
| 65 | - // pour les chaines non traduites, assurer un service minimum |
|
| 66 | - if (!$GLOBALS['test_i18n'] && _request('var_mode') != 'traduction') { |
|
| 67 | - $n = strpos($text, ':'); |
|
| 68 | - if ($n !== false) { |
|
| 69 | - $text = substr($text, $n + 1); |
|
| 70 | - } |
|
| 71 | - $text = str_replace('_', ' ', $text); |
|
| 72 | - } |
|
| 73 | - $o['class'] = null; |
|
| 74 | - } |
|
| 65 | + // pour les chaines non traduites, assurer un service minimum |
|
| 66 | + if (!$GLOBALS['test_i18n'] && _request('var_mode') != 'traduction') { |
|
| 67 | + $n = strpos($text, ':'); |
|
| 68 | + if ($n !== false) { |
|
| 69 | + $text = substr($text, $n + 1); |
|
| 70 | + } |
|
| 71 | + $text = str_replace('_', ' ', $text); |
|
| 72 | + } |
|
| 73 | + $o['class'] = null; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return _L($text, $args, $o); |
|
| 76 | + return _L($text, $args, $o); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
@@ -100,53 +100,53 @@ discard block |
||
| 100 | 100 | * texte |
| 101 | 101 | */ |
| 102 | 102 | function _L($text, $args = [], $options = []) { |
| 103 | - $f = $text; |
|
| 104 | - $defaut_options = [ |
|
| 105 | - 'class' => null, |
|
| 106 | - 'sanitize' => true, |
|
| 107 | - ]; |
|
| 108 | - // support de l'ancien argument $class |
|
| 109 | - if ($options && is_string($options)) { |
|
| 110 | - $options = ['class' => $options]; |
|
| 111 | - } |
|
| 112 | - if (is_array($options)) { |
|
| 113 | - $options += $defaut_options; |
|
| 114 | - } else { |
|
| 115 | - $options = $defaut_options; |
|
| 116 | - } |
|
| 103 | + $f = $text; |
|
| 104 | + $defaut_options = [ |
|
| 105 | + 'class' => null, |
|
| 106 | + 'sanitize' => true, |
|
| 107 | + ]; |
|
| 108 | + // support de l'ancien argument $class |
|
| 109 | + if ($options && is_string($options)) { |
|
| 110 | + $options = ['class' => $options]; |
|
| 111 | + } |
|
| 112 | + if (is_array($options)) { |
|
| 113 | + $options += $defaut_options; |
|
| 114 | + } else { |
|
| 115 | + $options = $defaut_options; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - if (is_array($args) && count($args)) { |
|
| 119 | - if (!function_exists('interdire_scripts')) { |
|
| 120 | - include_spip('inc/texte'); |
|
| 121 | - } |
|
| 122 | - if (!function_exists('echapper_html_suspect')) { |
|
| 123 | - include_spip('inc/texte_mini'); |
|
| 124 | - } |
|
| 125 | - foreach ($args as $name => $value) { |
|
| 126 | - if (str_contains($text, (string) "@$name@")) { |
|
| 127 | - if ($options['sanitize']) { |
|
| 128 | - $value = echapper_html_suspect($value); |
|
| 129 | - $value = interdire_scripts($value, -1); |
|
| 130 | - } |
|
| 131 | - if (!empty($options['class'])) { |
|
| 132 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 133 | - } |
|
| 134 | - $text = str_replace("@$name@", (string) $value, (string) $text); |
|
| 135 | - unset($args[$name]); |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 139 | - // (chaines de langues pas a jour) |
|
| 140 | - if ($args) { |
|
| 141 | - spip_logger()->debug("$f: variables inutilisees " . join(', ', array_keys($args))); |
|
| 142 | - } |
|
| 143 | - } |
|
| 118 | + if (is_array($args) && count($args)) { |
|
| 119 | + if (!function_exists('interdire_scripts')) { |
|
| 120 | + include_spip('inc/texte'); |
|
| 121 | + } |
|
| 122 | + if (!function_exists('echapper_html_suspect')) { |
|
| 123 | + include_spip('inc/texte_mini'); |
|
| 124 | + } |
|
| 125 | + foreach ($args as $name => $value) { |
|
| 126 | + if (str_contains($text, (string) "@$name@")) { |
|
| 127 | + if ($options['sanitize']) { |
|
| 128 | + $value = echapper_html_suspect($value); |
|
| 129 | + $value = interdire_scripts($value, -1); |
|
| 130 | + } |
|
| 131 | + if (!empty($options['class'])) { |
|
| 132 | + $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 133 | + } |
|
| 134 | + $text = str_replace("@$name@", (string) $value, (string) $text); |
|
| 135 | + unset($args[$name]); |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 139 | + // (chaines de langues pas a jour) |
|
| 140 | + if ($args) { |
|
| 141 | + spip_logger()->debug("$f: variables inutilisees " . join(', ', array_keys($args))); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if (($GLOBALS['test_i18n'] || _request('var_mode') == 'traduction') && is_null($options['class'])) { |
|
| 146 | - return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 147 | - } else { |
|
| 148 | - return $text; |
|
| 149 | - } |
|
| 145 | + if (($GLOBALS['test_i18n'] || _request('var_mode') == 'traduction') && is_null($options['class'])) { |
|
| 146 | + return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 147 | + } else { |
|
| 148 | + return $text; |
|
| 149 | + } |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
@@ -169,19 +169,19 @@ discard block |
||
| 169 | 169 | * - string Langue utilisée. |
| 170 | 170 | **/ |
| 171 | 171 | function lang_select($lang = null) { |
| 172 | - static $pile_langues = []; |
|
| 173 | - if (!function_exists('changer_langue')) { |
|
| 174 | - include_spip('inc/lang'); |
|
| 175 | - } |
|
| 176 | - if ($lang === null) { |
|
| 177 | - $lang = array_pop($pile_langues); |
|
| 178 | - } else { |
|
| 179 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 180 | - } |
|
| 181 | - if (isset($GLOBALS['spip_lang']) && $lang == $GLOBALS['spip_lang']) { |
|
| 182 | - return $lang; |
|
| 183 | - } |
|
| 184 | - changer_langue($lang); |
|
| 172 | + static $pile_langues = []; |
|
| 173 | + if (!function_exists('changer_langue')) { |
|
| 174 | + include_spip('inc/lang'); |
|
| 175 | + } |
|
| 176 | + if ($lang === null) { |
|
| 177 | + $lang = array_pop($pile_langues); |
|
| 178 | + } else { |
|
| 179 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 180 | + } |
|
| 181 | + if (isset($GLOBALS['spip_lang']) && $lang == $GLOBALS['spip_lang']) { |
|
| 182 | + return $lang; |
|
| 183 | + } |
|
| 184 | + changer_langue($lang); |
|
| 185 | 185 | |
| 186 | - return $lang; |
|
| 186 | + return $lang; |
|
| 187 | 187 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $value = interdire_scripts($value, -1); |
| 130 | 130 | } |
| 131 | 131 | if (!empty($options['class'])) { |
| 132 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 132 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 133 | 133 | } |
| 134 | 134 | $text = str_replace("@$name@", (string) $value, (string) $text); |
| 135 | 135 | unset($args[$name]); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | // Si des variables n'ont pas ete inserees, le signaler |
| 139 | 139 | // (chaines de langues pas a jour) |
| 140 | 140 | if ($args) { |
| 141 | - spip_logger()->debug("$f: variables inutilisees " . join(', ', array_keys($args))); |
|
| 141 | + spip_logger()->debug("$f: variables inutilisees ".join(', ', array_keys($args))); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -27,71 +27,71 @@ discard block |
||
| 27 | 27 | * Nom de la fonction, ou false. |
| 28 | 28 | */ |
| 29 | 29 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 30 | - static $echecs = []; |
|
| 31 | - |
|
| 32 | - if (strlen($dossier) && !str_ends_with($dossier, '/')) { |
|
| 33 | - $dossier .= '/'; |
|
| 34 | - } |
|
| 35 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 36 | - |
|
| 37 | - if (function_exists($f)) { |
|
| 38 | - return $f; |
|
| 39 | - } |
|
| 40 | - if (function_exists($g = $f . '_dist')) { |
|
| 41 | - return $g; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - if (isset($echecs[$f])) { |
|
| 45 | - return $echecs[$f]; |
|
| 46 | - } |
|
| 47 | - // Sinon charger le fichier de declaration si plausible |
|
| 48 | - |
|
| 49 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 50 | - if ($continue) { |
|
| 51 | - return false; |
|
| 52 | - } //appel interne, on passe |
|
| 53 | - include_spip('inc/minipres'); |
|
| 54 | - echo minipres(); |
|
| 55 | - exit; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - // passer en minuscules (cf les balises de formulaires) |
|
| 59 | - // et inclure le fichier |
|
| 60 | - if ( |
|
| 61 | - !($inc = include_spip($dossier . ($d = strtolower($nom)))) |
|
| 62 | - && strlen(dirname($dossier)) |
|
| 63 | - && dirname($dossier) != '.' |
|
| 64 | - ) { |
|
| 65 | - include_spip(substr($dossier, 0, -1)); |
|
| 66 | - } |
|
| 67 | - if (function_exists($f)) { |
|
| 68 | - return $f; |
|
| 69 | - } |
|
| 70 | - if (function_exists($g)) { |
|
| 71 | - return $g; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if ($continue) { |
|
| 75 | - return $echecs[$f] = false; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // Echec : message d'erreur |
|
| 79 | - spip_logger()->info("fonction $nom ($f ou $g) indisponible" . |
|
| 80 | - ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 81 | - |
|
| 82 | - include_spip('inc/minipres'); |
|
| 83 | - include_spip('inc/filtres_mini'); |
|
| 84 | - echo minipres( |
|
| 85 | - _T('forum_titre_erreur'), |
|
| 86 | - $inc ? |
|
| 87 | - _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 88 | - . '<br />' |
|
| 89 | - . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 90 | - : |
|
| 91 | - _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 92 | - ['all_inline' => true,'status' => 404] |
|
| 93 | - ); |
|
| 94 | - exit; |
|
| 30 | + static $echecs = []; |
|
| 31 | + |
|
| 32 | + if (strlen($dossier) && !str_ends_with($dossier, '/')) { |
|
| 33 | + $dossier .= '/'; |
|
| 34 | + } |
|
| 35 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 36 | + |
|
| 37 | + if (function_exists($f)) { |
|
| 38 | + return $f; |
|
| 39 | + } |
|
| 40 | + if (function_exists($g = $f . '_dist')) { |
|
| 41 | + return $g; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + if (isset($echecs[$f])) { |
|
| 45 | + return $echecs[$f]; |
|
| 46 | + } |
|
| 47 | + // Sinon charger le fichier de declaration si plausible |
|
| 48 | + |
|
| 49 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 50 | + if ($continue) { |
|
| 51 | + return false; |
|
| 52 | + } //appel interne, on passe |
|
| 53 | + include_spip('inc/minipres'); |
|
| 54 | + echo minipres(); |
|
| 55 | + exit; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + // passer en minuscules (cf les balises de formulaires) |
|
| 59 | + // et inclure le fichier |
|
| 60 | + if ( |
|
| 61 | + !($inc = include_spip($dossier . ($d = strtolower($nom)))) |
|
| 62 | + && strlen(dirname($dossier)) |
|
| 63 | + && dirname($dossier) != '.' |
|
| 64 | + ) { |
|
| 65 | + include_spip(substr($dossier, 0, -1)); |
|
| 66 | + } |
|
| 67 | + if (function_exists($f)) { |
|
| 68 | + return $f; |
|
| 69 | + } |
|
| 70 | + if (function_exists($g)) { |
|
| 71 | + return $g; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if ($continue) { |
|
| 75 | + return $echecs[$f] = false; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // Echec : message d'erreur |
|
| 79 | + spip_logger()->info("fonction $nom ($f ou $g) indisponible" . |
|
| 80 | + ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 81 | + |
|
| 82 | + include_spip('inc/minipres'); |
|
| 83 | + include_spip('inc/filtres_mini'); |
|
| 84 | + echo minipres( |
|
| 85 | + _T('forum_titre_erreur'), |
|
| 86 | + $inc ? |
|
| 87 | + _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 88 | + . '<br />' |
|
| 89 | + . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 90 | + : |
|
| 91 | + _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 92 | + ['all_inline' => true,'status' => 404] |
|
| 93 | + ); |
|
| 94 | + exit; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | * @return bool |
| 102 | 102 | */ |
| 103 | 103 | function include_once_check($file) { |
| 104 | - if (file_exists($file)) { |
|
| 105 | - include_once $file; |
|
| 104 | + if (file_exists($file)) { |
|
| 105 | + include_once $file; |
|
| 106 | 106 | |
| 107 | - return true; |
|
| 108 | - } |
|
| 109 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 110 | - $crash = ($crash ?: []); |
|
| 111 | - $crash[$file] = true; |
|
| 112 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 107 | + return true; |
|
| 108 | + } |
|
| 109 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 110 | + $crash = ($crash ?: []); |
|
| 111 | + $crash[$file] = true; |
|
| 112 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 113 | 113 | |
| 114 | - return false; |
|
| 114 | + return false; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * - string : chemin du fichier trouvé |
| 136 | 136 | **/ |
| 137 | 137 | function include_spip($f, $include = true) { |
| 138 | - return find_in_path($f . '.php', '', $include); |
|
| 138 | + return find_in_path($f . '.php', '', $include); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * - string : chemin du fichier trouvé |
| 156 | 156 | **/ |
| 157 | 157 | function require_spip($f) { |
| 158 | - return find_in_path($f . '.php', '', 'required'); |
|
| 158 | + return find_in_path($f . '.php', '', 'required'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -165,27 +165,27 @@ discard block |
||
| 165 | 165 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 166 | 166 | */ |
| 167 | 167 | function include_fichiers_fonctions() { |
| 168 | - static $done = false; |
|
| 169 | - if (!$done) { |
|
| 170 | - include_spip('inc/lang'); |
|
| 171 | - |
|
| 172 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 173 | - // donc il faut l'inclure "en globals" |
|
| 174 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 175 | - global $dossier_squelettes; |
|
| 176 | - include_once(_ROOT_CWD . $f); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 180 | - // chargement optimise precompile |
|
| 181 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 182 | - } |
|
| 183 | - if (test_espace_prive()) { |
|
| 184 | - include_spip('inc/filtres_ecrire'); |
|
| 185 | - } |
|
| 186 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 187 | - $done = true; |
|
| 188 | - } |
|
| 168 | + static $done = false; |
|
| 169 | + if (!$done) { |
|
| 170 | + include_spip('inc/lang'); |
|
| 171 | + |
|
| 172 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 173 | + // donc il faut l'inclure "en globals" |
|
| 174 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 175 | + global $dossier_squelettes; |
|
| 176 | + include_once(_ROOT_CWD . $f); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 180 | + // chargement optimise precompile |
|
| 181 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 182 | + } |
|
| 183 | + if (test_espace_prive()) { |
|
| 184 | + include_spip('inc/filtres_ecrire'); |
|
| 185 | + } |
|
| 186 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 187 | + $done = true; |
|
| 188 | + } |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -198,59 +198,59 @@ discard block |
||
| 198 | 198 | * @return string |
| 199 | 199 | */ |
| 200 | 200 | function charger_fonction_url(string $quoi, string $type = '') { |
| 201 | - if ($type === 'defaut') { |
|
| 202 | - $objet = objet_type($quoi); |
|
| 203 | - if ( |
|
| 204 | - ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)) |
|
| 205 | - || ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated |
|
| 206 | - ) { |
|
| 207 | - return $f; |
|
| 208 | - } |
|
| 209 | - return ''; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $url_type = $type; |
|
| 213 | - if (!$url_type) { |
|
| 214 | - $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // inclure le module d'url |
|
| 218 | - include_spip('urls/' . $url_type); |
|
| 219 | - |
|
| 220 | - switch ($quoi) { |
|
| 221 | - case 'page': |
|
| 222 | - if ( |
|
| 223 | - function_exists($f = "urls_{$url_type}_generer_url_page") |
|
| 224 | - || function_exists($f .= '_dist') |
|
| 225 | - // ou une fonction custom utilisateur independante du type d'url |
|
| 226 | - || function_exists($f = 'generer_url_page') |
|
| 227 | - || function_exists($f .= '_dist') |
|
| 228 | - ) { |
|
| 229 | - return $f; |
|
| 230 | - } |
|
| 231 | - // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 232 | - return ''; |
|
| 233 | - case 'objet': |
|
| 234 | - case 'decoder': |
|
| 235 | - default: |
|
| 236 | - $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 237 | - if ( |
|
| 238 | - function_exists($f = "urls_{$url_type}_{$fquoi}") |
|
| 239 | - || function_exists($f .= '_dist') |
|
| 240 | - ) { |
|
| 241 | - return $f; |
|
| 242 | - } |
|
| 243 | - // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 244 | - // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 245 | - if ($f = charger_fonction($url_type, 'urls', true)) { |
|
| 246 | - return $f; |
|
| 247 | - } |
|
| 248 | - // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement |
|
| 249 | - if (!$type && $url_type !== 'page') { |
|
| 250 | - return charger_fonction_url($quoi, 'page'); |
|
| 251 | - } |
|
| 252 | - return ''; |
|
| 253 | - } |
|
| 201 | + if ($type === 'defaut') { |
|
| 202 | + $objet = objet_type($quoi); |
|
| 203 | + if ( |
|
| 204 | + ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)) |
|
| 205 | + || ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated |
|
| 206 | + ) { |
|
| 207 | + return $f; |
|
| 208 | + } |
|
| 209 | + return ''; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $url_type = $type; |
|
| 213 | + if (!$url_type) { |
|
| 214 | + $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + // inclure le module d'url |
|
| 218 | + include_spip('urls/' . $url_type); |
|
| 219 | + |
|
| 220 | + switch ($quoi) { |
|
| 221 | + case 'page': |
|
| 222 | + if ( |
|
| 223 | + function_exists($f = "urls_{$url_type}_generer_url_page") |
|
| 224 | + || function_exists($f .= '_dist') |
|
| 225 | + // ou une fonction custom utilisateur independante du type d'url |
|
| 226 | + || function_exists($f = 'generer_url_page') |
|
| 227 | + || function_exists($f .= '_dist') |
|
| 228 | + ) { |
|
| 229 | + return $f; |
|
| 230 | + } |
|
| 231 | + // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 232 | + return ''; |
|
| 233 | + case 'objet': |
|
| 234 | + case 'decoder': |
|
| 235 | + default: |
|
| 236 | + $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 237 | + if ( |
|
| 238 | + function_exists($f = "urls_{$url_type}_{$fquoi}") |
|
| 239 | + || function_exists($f .= '_dist') |
|
| 240 | + ) { |
|
| 241 | + return $f; |
|
| 242 | + } |
|
| 243 | + // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 244 | + // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 245 | + if ($f = charger_fonction($url_type, 'urls', true)) { |
|
| 246 | + return $f; |
|
| 247 | + } |
|
| 248 | + // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement |
|
| 249 | + if (!$type && $url_type !== 'page') { |
|
| 250 | + return charger_fonction_url($quoi, 'page'); |
|
| 251 | + } |
|
| 252 | + return ''; |
|
| 253 | + } |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @return string |
| 262 | 262 | */ |
| 263 | 263 | function trouve_modele($nom) { |
| 264 | - return trouver_fond($nom, 'modeles/'); |
|
| 264 | + return trouver_fond($nom, 'modeles/'); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -277,28 +277,28 @@ discard block |
||
| 277 | 277 | * @return array|string |
| 278 | 278 | */ |
| 279 | 279 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 280 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 281 | - if (!$pathinfo) { |
|
| 282 | - return $f; |
|
| 283 | - } |
|
| 284 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 285 | - if ($f === null) { |
|
| 286 | - return [ |
|
| 287 | - 'extension' => _EXTENSION_SQUELETTES, |
|
| 288 | - 'filename' => '', |
|
| 289 | - 'fond' => '' |
|
| 290 | - ]; |
|
| 291 | - } |
|
| 292 | - $p = pathinfo($f); |
|
| 293 | - if (!isset($p['extension']) || !$p['extension']) { |
|
| 294 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 295 | - } |
|
| 296 | - if (!isset($p['extension']) || !$p['filename']) { |
|
| 297 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 298 | - } |
|
| 299 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 300 | - |
|
| 301 | - return $p; |
|
| 280 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 281 | + if (!$pathinfo) { |
|
| 282 | + return $f; |
|
| 283 | + } |
|
| 284 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 285 | + if ($f === null) { |
|
| 286 | + return [ |
|
| 287 | + 'extension' => _EXTENSION_SQUELETTES, |
|
| 288 | + 'filename' => '', |
|
| 289 | + 'fond' => '' |
|
| 290 | + ]; |
|
| 291 | + } |
|
| 292 | + $p = pathinfo($f); |
|
| 293 | + if (!isset($p['extension']) || !$p['extension']) { |
|
| 294 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 295 | + } |
|
| 296 | + if (!isset($p['extension']) || !$p['filename']) { |
|
| 297 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 298 | + } |
|
| 299 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 300 | + |
|
| 301 | + return $p; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -316,9 +316,9 @@ discard block |
||
| 316 | 316 | * Lien sur une icone d'aide |
| 317 | 317 | **/ |
| 318 | 318 | function aider($aide = '', $distante = false) { |
| 319 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 319 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 320 | 320 | |
| 321 | - return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 321 | + return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | |
@@ -339,19 +339,19 @@ discard block |
||
| 339 | 339 | * Nom de l'exec, sinon chaîne vide. |
| 340 | 340 | **/ |
| 341 | 341 | function tester_url_ecrire($nom) { |
| 342 | - static $exec = []; |
|
| 343 | - if (isset($exec[$nom])) { |
|
| 344 | - return $exec[$nom]; |
|
| 345 | - } |
|
| 346 | - // tester si c'est une page en squelette |
|
| 347 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 348 | - return $exec[$nom] = 'fond'; |
|
| 349 | - } // echafaudage d'un fond ! |
|
| 350 | - elseif (include_spip('public/styliser_par_z') && z_echafaudable($nom)) { |
|
| 351 | - return $exec[$nom] = 'fond'; |
|
| 352 | - } |
|
| 353 | - // attention, il ne faut pas inclure l'exec ici |
|
| 354 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 355 | - // et des define intrusifs potentiels |
|
| 356 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') || charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 342 | + static $exec = []; |
|
| 343 | + if (isset($exec[$nom])) { |
|
| 344 | + return $exec[$nom]; |
|
| 345 | + } |
|
| 346 | + // tester si c'est une page en squelette |
|
| 347 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 348 | + return $exec[$nom] = 'fond'; |
|
| 349 | + } // echafaudage d'un fond ! |
|
| 350 | + elseif (include_spip('public/styliser_par_z') && z_echafaudable($nom)) { |
|
| 351 | + return $exec[$nom] = 'fond'; |
|
| 352 | + } |
|
| 353 | + // attention, il ne faut pas inclure l'exec ici |
|
| 354 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 355 | + // et des define intrusifs potentiels |
|
| 356 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') || charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 357 | 357 | } |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | if (strlen($dossier) && !str_ends_with($dossier, '/')) { |
| 33 | 33 | $dossier .= '/'; |
| 34 | 34 | } |
| 35 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 35 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 36 | 36 | |
| 37 | 37 | if (function_exists($f)) { |
| 38 | 38 | return $f; |
| 39 | 39 | } |
| 40 | - if (function_exists($g = $f . '_dist')) { |
|
| 40 | + if (function_exists($g = $f.'_dist')) { |
|
| 41 | 41 | return $g; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | // passer en minuscules (cf les balises de formulaires) |
| 59 | 59 | // et inclure le fichier |
| 60 | 60 | if ( |
| 61 | - !($inc = include_spip($dossier . ($d = strtolower($nom)))) |
|
| 61 | + !($inc = include_spip($dossier.($d = strtolower($nom)))) |
|
| 62 | 62 | && strlen(dirname($dossier)) |
| 63 | 63 | && dirname($dossier) != '.' |
| 64 | 64 | ) { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Echec : message d'erreur |
| 79 | - spip_logger()->info("fonction $nom ($f ou $g) indisponible" . |
|
| 79 | + spip_logger()->info("fonction $nom ($f ou $g) indisponible". |
|
| 80 | 80 | ($inc ? '' : " (fichier $d absent de $dossier)")); |
| 81 | 81 | |
| 82 | 82 | include_spip('inc/minipres'); |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | echo minipres( |
| 85 | 85 | _T('forum_titre_erreur'), |
| 86 | 86 | $inc ? |
| 87 | - _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 87 | + _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($f).'</code>']) |
|
| 88 | 88 | . '<br />' |
| 89 | - . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 89 | + . _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($g).'</code>']) |
|
| 90 | 90 | : |
| 91 | - _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 92 | - ['all_inline' => true,'status' => 404] |
|
| 91 | + _T('fichier_introuvable', ['fichier' => '<code>'.spip_htmlentities($d).'</code>']), |
|
| 92 | + ['all_inline' => true, 'status' => 404] |
|
| 93 | 93 | ); |
| 94 | 94 | exit; |
| 95 | 95 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * - string : chemin du fichier trouvé |
| 136 | 136 | **/ |
| 137 | 137 | function include_spip($f, $include = true) { |
| 138 | - return find_in_path($f . '.php', '', $include); |
|
| 138 | + return find_in_path($f.'.php', '', $include); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * - string : chemin du fichier trouvé |
| 156 | 156 | **/ |
| 157 | 157 | function require_spip($f) { |
| 158 | - return find_in_path($f . '.php', '', 'required'); |
|
| 158 | + return find_in_path($f.'.php', '', 'required'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | // donc il faut l'inclure "en globals" |
| 174 | 174 | if ($f = find_in_path('mes_fonctions.php')) { |
| 175 | 175 | global $dossier_squelettes; |
| 176 | - include_once(_ROOT_CWD . $f); |
|
| 176 | + include_once(_ROOT_CWD.$f); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | if ($type === 'defaut') { |
| 202 | 202 | $objet = objet_type($quoi); |
| 203 | 203 | if ( |
| 204 | - ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)) |
|
| 205 | - || ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated |
|
| 204 | + ($f = charger_fonction('generer_'.$objet.'_url', 'urls', true)) |
|
| 205 | + || ($f = charger_fonction('generer_url_'.$objet, 'urls', true)) // deprecated |
|
| 206 | 206 | ) { |
| 207 | 207 | return $f; |
| 208 | 208 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // inclure le module d'url |
| 218 | - include_spip('urls/' . $url_type); |
|
| 218 | + include_spip('urls/'.$url_type); |
|
| 219 | 219 | |
| 220 | 220 | switch ($quoi) { |
| 221 | 221 | case 'page': |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @return array|string |
| 278 | 278 | */ |
| 279 | 279 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 280 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 280 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 281 | 281 | if (!$pathinfo) { |
| 282 | 282 | return $f; |
| 283 | 283 | } |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | * @param string $ta Répertoire temporaire accessible |
| 10 | 10 | */ |
| 11 | 11 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 12 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 13 | - spip_initialisation_suite(); |
|
| 12 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 13 | + spip_initialisation_suite(); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -30,313 +30,313 @@ discard block |
||
| 30 | 30 | * @param string $ta Répertoire temporaire accessible |
| 31 | 31 | */ |
| 32 | 32 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 33 | - static $too_late = 0; |
|
| 34 | - if ($too_late++) { |
|
| 35 | - return; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - // Declaration des repertoires |
|
| 39 | - |
|
| 40 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 41 | - if (!defined('_DIR_PLUGINS')) { |
|
| 42 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 46 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 47 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // le nom du repertoire des librairies |
|
| 51 | - if (!defined('_DIR_LIB')) { |
|
| 52 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - // répertoire des libs via Composer |
|
| 56 | - if (!defined('_DIR_VENDOR')) { |
|
| 57 | - define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - if (!defined('_DIR_IMG')) { |
|
| 61 | - define('_DIR_IMG', $pa); |
|
| 62 | - } |
|
| 63 | - if (!defined('_DIR_LOGOS')) { |
|
| 64 | - define('_DIR_LOGOS', $pa); |
|
| 65 | - } |
|
| 66 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 67 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if (!defined('_DIR_DUMP')) { |
|
| 71 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 72 | - } |
|
| 73 | - if (!defined('_DIR_SESSIONS')) { |
|
| 74 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 75 | - } |
|
| 76 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 77 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 78 | - } |
|
| 79 | - if (!defined('_DIR_CACHE')) { |
|
| 80 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 81 | - } |
|
| 82 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 83 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 84 | - } |
|
| 85 | - if (!defined('_DIR_SKELS')) { |
|
| 86 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 87 | - } |
|
| 88 | - if (!defined('_DIR_AIDE')) { |
|
| 89 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 90 | - } |
|
| 91 | - if (!defined('_DIR_TMP')) { |
|
| 92 | - define('_DIR_TMP', $ti); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if (!defined('_DIR_VAR')) { |
|
| 96 | - define('_DIR_VAR', $ta); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if (!defined('_DIR_ETC')) { |
|
| 100 | - define('_DIR_ETC', $pi); |
|
| 101 | - } |
|
| 102 | - if (!defined('_DIR_CONNECT')) { |
|
| 103 | - define('_DIR_CONNECT', $pi); |
|
| 104 | - } |
|
| 105 | - if (!defined('_DIR_CHMOD')) { |
|
| 106 | - define('_DIR_CHMOD', $pi); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - if (!isset($GLOBALS['test_dirs'])) { |
|
| 110 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 111 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 112 | - $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // Declaration des fichiers |
|
| 116 | - |
|
| 117 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 118 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 119 | - } |
|
| 120 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 121 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 122 | - } |
|
| 123 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 124 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 125 | - } |
|
| 126 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 127 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 128 | - } |
|
| 129 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 130 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 134 | - if (!defined('_FILE_META')) { |
|
| 135 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 136 | - } |
|
| 137 | - if (!defined('_DIR_LOG')) { |
|
| 138 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 139 | - } |
|
| 140 | - if (!defined('_FILE_LOG')) { |
|
| 141 | - define('_FILE_LOG', 'spip'); |
|
| 142 | - } |
|
| 143 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 144 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // Le fichier de connexion a la base de donnees |
|
| 148 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 149 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 150 | - } |
|
| 151 | - if (!defined('_FILE_CONNECT')) { |
|
| 152 | - define( |
|
| 153 | - '_FILE_CONNECT', |
|
| 154 | - @is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false |
|
| 155 | - ); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - // Le fichier de reglages des droits |
|
| 159 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 160 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 161 | - } |
|
| 162 | - if (!defined('_FILE_CHMOD')) { |
|
| 163 | - define( |
|
| 164 | - '_FILE_CHMOD', |
|
| 165 | - @is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false |
|
| 166 | - ); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - if (!defined('_FILE_LDAP')) { |
|
| 170 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 174 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 175 | - } |
|
| 176 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 177 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 178 | - } |
|
| 179 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 180 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // Definition des droits d'acces en ecriture |
|
| 184 | - if (!defined('_SPIP_CHMOD') && _FILE_CHMOD) { |
|
| 185 | - include_once _FILE_CHMOD; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - // Se mefier des fichiers mal remplis! |
|
| 189 | - if (!defined('_SPIP_CHMOD')) { |
|
| 190 | - define('_SPIP_CHMOD', 0777); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 194 | - /** Le charset par défaut lors de l'installation */ |
|
| 195 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 196 | - } |
|
| 197 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 198 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins' . DIRECTORY_SEPARATOR); |
|
| 199 | - } |
|
| 200 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 201 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist' . DIRECTORY_SEPARATOR); |
|
| 202 | - } |
|
| 203 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 204 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - // La taille des Log |
|
| 208 | - if (!defined('_MAX_LOG')) { |
|
| 209 | - define('_MAX_LOG', 100); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - // Sommes-nous dans l'empire du Mal ? |
|
| 213 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 214 | - if (isset($_SERVER['SERVER_SOFTWARE']) && str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) { |
|
| 215 | - if (!defined('_OS_SERVEUR')) { |
|
| 216 | - define('_OS_SERVEUR', 'windows'); |
|
| 217 | - } |
|
| 218 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 219 | - define('_SPIP_LOCK_MODE', 1); |
|
| 220 | - } // utiliser le flock php |
|
| 221 | - } else { |
|
| 222 | - if (!defined('_OS_SERVEUR')) { |
|
| 223 | - define('_OS_SERVEUR', ''); |
|
| 224 | - } |
|
| 225 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 226 | - define('_SPIP_LOCK_MODE', 1); |
|
| 227 | - } // utiliser le flock php |
|
| 228 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - // Langue par defaut |
|
| 232 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 233 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - // |
|
| 237 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 238 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 239 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 240 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 241 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 242 | - |
|
| 243 | - // charger le path des plugins |
|
| 244 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 245 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - // *********** traiter les variables ************ |
|
| 249 | - |
|
| 250 | - // |
|
| 251 | - // Securite |
|
| 252 | - // |
|
| 253 | - |
|
| 254 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 255 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 256 | - die(); |
|
| 257 | - } |
|
| 258 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 259 | - spip_desinfecte($_GET); |
|
| 260 | - spip_desinfecte($_POST); |
|
| 261 | - spip_desinfecte($_COOKIE); |
|
| 262 | - spip_desinfecte($_REQUEST); |
|
| 263 | - |
|
| 264 | - // appliquer le cookie_prefix |
|
| 265 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 266 | - include_spip('inc/cookie'); |
|
| 267 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 271 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 272 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 273 | - } else { |
|
| 274 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 275 | - if ( |
|
| 276 | - !empty($_SERVER['QUERY_STRING']) |
|
| 277 | - && !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 278 | - ) { |
|
| 279 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 284 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 285 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 286 | - } |
|
| 287 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 288 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 292 | - // charge aussi effacer_meta et ecrire_meta |
|
| 293 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 294 | - $inc_meta(); |
|
| 295 | - |
|
| 296 | - // nombre de repertoires depuis la racine |
|
| 297 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 298 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 299 | - // le calcul est faux) |
|
| 300 | - if (!_DIR_RESTREINT) { |
|
| 301 | - $GLOBALS['profondeur_url'] = 1; |
|
| 302 | - } else { |
|
| 303 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 304 | - $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 305 | - if ( |
|
| 306 | - !$uri_ref |
|
| 307 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 308 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 309 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 310 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 311 | - || $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 312 | - ) { |
|
| 313 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 314 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 315 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 316 | - } else { |
|
| 317 | - $uri_ref = ''; |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - if (!$uri || !$uri_ref) { |
|
| 321 | - $GLOBALS['profondeur_url'] = 0; |
|
| 322 | - } else { |
|
| 323 | - $GLOBALS['profondeur_url'] = max( |
|
| 324 | - 0, |
|
| 325 | - substr_count($uri[0], '/') |
|
| 326 | - - substr_count($uri_ref, '/') |
|
| 327 | - ); |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 331 | - if (_FILE_CONNECT) { |
|
| 332 | - if ( |
|
| 333 | - verifier_visiteur() == '0minirezo' |
|
| 334 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 335 | - && !isset($_COOKIE['spip_admin']) |
|
| 336 | - ) { |
|
| 337 | - clear_path_cache(); |
|
| 338 | - } |
|
| 339 | - } |
|
| 33 | + static $too_late = 0; |
|
| 34 | + if ($too_late++) { |
|
| 35 | + return; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + // Declaration des repertoires |
|
| 39 | + |
|
| 40 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 41 | + if (!defined('_DIR_PLUGINS')) { |
|
| 42 | + define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 46 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 47 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // le nom du repertoire des librairies |
|
| 51 | + if (!defined('_DIR_LIB')) { |
|
| 52 | + define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + // répertoire des libs via Composer |
|
| 56 | + if (!defined('_DIR_VENDOR')) { |
|
| 57 | + define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + if (!defined('_DIR_IMG')) { |
|
| 61 | + define('_DIR_IMG', $pa); |
|
| 62 | + } |
|
| 63 | + if (!defined('_DIR_LOGOS')) { |
|
| 64 | + define('_DIR_LOGOS', $pa); |
|
| 65 | + } |
|
| 66 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 67 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if (!defined('_DIR_DUMP')) { |
|
| 71 | + define('_DIR_DUMP', $ti . 'dump/'); |
|
| 72 | + } |
|
| 73 | + if (!defined('_DIR_SESSIONS')) { |
|
| 74 | + define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 75 | + } |
|
| 76 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 77 | + define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 78 | + } |
|
| 79 | + if (!defined('_DIR_CACHE')) { |
|
| 80 | + define('_DIR_CACHE', $ti . 'cache/'); |
|
| 81 | + } |
|
| 82 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 83 | + define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 84 | + } |
|
| 85 | + if (!defined('_DIR_SKELS')) { |
|
| 86 | + define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 87 | + } |
|
| 88 | + if (!defined('_DIR_AIDE')) { |
|
| 89 | + define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 90 | + } |
|
| 91 | + if (!defined('_DIR_TMP')) { |
|
| 92 | + define('_DIR_TMP', $ti); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if (!defined('_DIR_VAR')) { |
|
| 96 | + define('_DIR_VAR', $ta); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if (!defined('_DIR_ETC')) { |
|
| 100 | + define('_DIR_ETC', $pi); |
|
| 101 | + } |
|
| 102 | + if (!defined('_DIR_CONNECT')) { |
|
| 103 | + define('_DIR_CONNECT', $pi); |
|
| 104 | + } |
|
| 105 | + if (!defined('_DIR_CHMOD')) { |
|
| 106 | + define('_DIR_CHMOD', $pi); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 110 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 111 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 112 | + $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // Declaration des fichiers |
|
| 116 | + |
|
| 117 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 118 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 119 | + } |
|
| 120 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 121 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 122 | + } |
|
| 123 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 124 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 125 | + } |
|
| 126 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 127 | + define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 128 | + } |
|
| 129 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 130 | + define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 134 | + if (!defined('_FILE_META')) { |
|
| 135 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 136 | + } |
|
| 137 | + if (!defined('_DIR_LOG')) { |
|
| 138 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 139 | + } |
|
| 140 | + if (!defined('_FILE_LOG')) { |
|
| 141 | + define('_FILE_LOG', 'spip'); |
|
| 142 | + } |
|
| 143 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 144 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // Le fichier de connexion a la base de donnees |
|
| 148 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 149 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 150 | + } |
|
| 151 | + if (!defined('_FILE_CONNECT')) { |
|
| 152 | + define( |
|
| 153 | + '_FILE_CONNECT', |
|
| 154 | + @is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false |
|
| 155 | + ); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + // Le fichier de reglages des droits |
|
| 159 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 160 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 161 | + } |
|
| 162 | + if (!defined('_FILE_CHMOD')) { |
|
| 163 | + define( |
|
| 164 | + '_FILE_CHMOD', |
|
| 165 | + @is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false |
|
| 166 | + ); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + if (!defined('_FILE_LDAP')) { |
|
| 170 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 174 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 175 | + } |
|
| 176 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 177 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 178 | + } |
|
| 179 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 180 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // Definition des droits d'acces en ecriture |
|
| 184 | + if (!defined('_SPIP_CHMOD') && _FILE_CHMOD) { |
|
| 185 | + include_once _FILE_CHMOD; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + // Se mefier des fichiers mal remplis! |
|
| 189 | + if (!defined('_SPIP_CHMOD')) { |
|
| 190 | + define('_SPIP_CHMOD', 0777); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 194 | + /** Le charset par défaut lors de l'installation */ |
|
| 195 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 196 | + } |
|
| 197 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 198 | + define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins' . DIRECTORY_SEPARATOR); |
|
| 199 | + } |
|
| 200 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 201 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist' . DIRECTORY_SEPARATOR); |
|
| 202 | + } |
|
| 203 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 204 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + // La taille des Log |
|
| 208 | + if (!defined('_MAX_LOG')) { |
|
| 209 | + define('_MAX_LOG', 100); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // Sommes-nous dans l'empire du Mal ? |
|
| 213 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 214 | + if (isset($_SERVER['SERVER_SOFTWARE']) && str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) { |
|
| 215 | + if (!defined('_OS_SERVEUR')) { |
|
| 216 | + define('_OS_SERVEUR', 'windows'); |
|
| 217 | + } |
|
| 218 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 219 | + define('_SPIP_LOCK_MODE', 1); |
|
| 220 | + } // utiliser le flock php |
|
| 221 | + } else { |
|
| 222 | + if (!defined('_OS_SERVEUR')) { |
|
| 223 | + define('_OS_SERVEUR', ''); |
|
| 224 | + } |
|
| 225 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 226 | + define('_SPIP_LOCK_MODE', 1); |
|
| 227 | + } // utiliser le flock php |
|
| 228 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + // Langue par defaut |
|
| 232 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 233 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + // |
|
| 237 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 238 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 239 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 240 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 241 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 242 | + |
|
| 243 | + // charger le path des plugins |
|
| 244 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 245 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + // *********** traiter les variables ************ |
|
| 249 | + |
|
| 250 | + // |
|
| 251 | + // Securite |
|
| 252 | + // |
|
| 253 | + |
|
| 254 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 255 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 256 | + die(); |
|
| 257 | + } |
|
| 258 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 259 | + spip_desinfecte($_GET); |
|
| 260 | + spip_desinfecte($_POST); |
|
| 261 | + spip_desinfecte($_COOKIE); |
|
| 262 | + spip_desinfecte($_REQUEST); |
|
| 263 | + |
|
| 264 | + // appliquer le cookie_prefix |
|
| 265 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 266 | + include_spip('inc/cookie'); |
|
| 267 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 271 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 272 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 273 | + } else { |
|
| 274 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 275 | + if ( |
|
| 276 | + !empty($_SERVER['QUERY_STRING']) |
|
| 277 | + && !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 278 | + ) { |
|
| 279 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 284 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 285 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 286 | + } |
|
| 287 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 288 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 292 | + // charge aussi effacer_meta et ecrire_meta |
|
| 293 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 294 | + $inc_meta(); |
|
| 295 | + |
|
| 296 | + // nombre de repertoires depuis la racine |
|
| 297 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 298 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 299 | + // le calcul est faux) |
|
| 300 | + if (!_DIR_RESTREINT) { |
|
| 301 | + $GLOBALS['profondeur_url'] = 1; |
|
| 302 | + } else { |
|
| 303 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 304 | + $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 305 | + if ( |
|
| 306 | + !$uri_ref |
|
| 307 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 308 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 309 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 310 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 311 | + || $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 312 | + ) { |
|
| 313 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 314 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 315 | + $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 316 | + } else { |
|
| 317 | + $uri_ref = ''; |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + if (!$uri || !$uri_ref) { |
|
| 321 | + $GLOBALS['profondeur_url'] = 0; |
|
| 322 | + } else { |
|
| 323 | + $GLOBALS['profondeur_url'] = max( |
|
| 324 | + 0, |
|
| 325 | + substr_count($uri[0], '/') |
|
| 326 | + - substr_count($uri_ref, '/') |
|
| 327 | + ); |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 331 | + if (_FILE_CONNECT) { |
|
| 332 | + if ( |
|
| 333 | + verifier_visiteur() == '0minirezo' |
|
| 334 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 335 | + && !isset($_COOKIE['spip_admin']) |
|
| 336 | + ) { |
|
| 337 | + clear_path_cache(); |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -345,158 +345,158 @@ discard block |
||
| 345 | 345 | * |
| 346 | 346 | */ |
| 347 | 347 | function spip_initialisation_suite() { |
| 348 | - static $too_late = 0; |
|
| 349 | - if ($too_late++) { |
|
| 350 | - return; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - // taille mini des login |
|
| 354 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 355 | - define('_LOGIN_TROP_COURT', 4); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 359 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 360 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 361 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 362 | - |
|
| 363 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 364 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 365 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 366 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 367 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 368 | - |
|
| 369 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 370 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - // largeur maximale des images dans l'administration |
|
| 374 | - if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 375 | - define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 379 | - if (!defined('_IMG_QUALITE')) { |
|
| 380 | - define('_IMG_QUALITE', 85); |
|
| 381 | - } # valeur par defaut |
|
| 382 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 383 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 384 | - } # surcharge pour la lib GD |
|
| 385 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 386 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 387 | - } # surcharge pour imagick en ligne de commande |
|
| 388 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 389 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 390 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 391 | - } # surcharge pour imagick en PHP |
|
| 392 | - |
|
| 393 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 394 | - define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 395 | - } // poids en octet |
|
| 396 | - |
|
| 397 | - // qq chaines standard |
|
| 398 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 399 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 400 | - } |
|
| 401 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 402 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 403 | - } |
|
| 404 | - if (!defined('_SPIP_DUMP')) { |
|
| 405 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 406 | - } |
|
| 407 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 408 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 409 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 410 | - } |
|
| 411 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 412 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 413 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 417 | - /** |
|
| 418 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 419 | - * @var int Nombre de caractères */ |
|
| 420 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 424 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 428 | - /** Définit le doctype de l’espace privé */ |
|
| 429 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 430 | - } |
|
| 431 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 432 | - /** Définit le doctype de l’aide en ligne */ |
|
| 433 | - define( |
|
| 434 | - '_DOCTYPE_AIDE', |
|
| 435 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 436 | - ); |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 440 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 441 | - * le script de l'espace public, alias index.php */ |
|
| 442 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 443 | - } |
|
| 444 | - if (!defined('_SPIP_PAGE')) { |
|
| 445 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 446 | - define('_SPIP_PAGE', 'page'); |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - // le script de l'espace prive |
|
| 450 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 451 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 452 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 453 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 454 | - if (!empty($_SERVER['SERVER_SOFTWARE']) && preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 455 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 456 | - } else { |
|
| 457 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 458 | - } |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - |
|
| 462 | - if (!defined('_SPIP_AJAX')) { |
|
| 463 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 464 | - ? 1 |
|
| 465 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - // La requete est-elle en ajax ? |
|
| 469 | - if (!defined('_AJAX')) { |
|
| 470 | - define( |
|
| 471 | - '_AJAX', |
|
| 472 | - ( |
|
| 473 | - isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 474 | - || !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuer |
|
| 475 | - || !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 476 | - || !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 477 | - ) |
|
| 478 | - && empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 479 | - ); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 483 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 484 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 485 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 486 | - define( |
|
| 487 | - '_IMG_GD_MAX_PIXELS', |
|
| 488 | - (isset($GLOBALS['meta']['max_taille_vignettes']) && $GLOBALS['meta']['max_taille_vignettes']) |
|
| 489 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 490 | - : 0 |
|
| 491 | - ); |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - // Protocoles a normaliser dans les chaines de langues |
|
| 495 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 496 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - init_var_mode(); |
|
| 348 | + static $too_late = 0; |
|
| 349 | + if ($too_late++) { |
|
| 350 | + return; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + // taille mini des login |
|
| 354 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 355 | + define('_LOGIN_TROP_COURT', 4); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 359 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 360 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 361 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 362 | + |
|
| 363 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 364 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 365 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 366 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 367 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 368 | + |
|
| 369 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 370 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + // largeur maximale des images dans l'administration |
|
| 374 | + if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 375 | + define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 379 | + if (!defined('_IMG_QUALITE')) { |
|
| 380 | + define('_IMG_QUALITE', 85); |
|
| 381 | + } # valeur par defaut |
|
| 382 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 383 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 384 | + } # surcharge pour la lib GD |
|
| 385 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 386 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 387 | + } # surcharge pour imagick en ligne de commande |
|
| 388 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 389 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 390 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 391 | + } # surcharge pour imagick en PHP |
|
| 392 | + |
|
| 393 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 394 | + define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 395 | + } // poids en octet |
|
| 396 | + |
|
| 397 | + // qq chaines standard |
|
| 398 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 399 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 400 | + } |
|
| 401 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 402 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 403 | + } |
|
| 404 | + if (!defined('_SPIP_DUMP')) { |
|
| 405 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 406 | + } |
|
| 407 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 408 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 409 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 410 | + } |
|
| 411 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 412 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 413 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 417 | + /** |
|
| 418 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 419 | + * @var int Nombre de caractères */ |
|
| 420 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 424 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 428 | + /** Définit le doctype de l’espace privé */ |
|
| 429 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 430 | + } |
|
| 431 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 432 | + /** Définit le doctype de l’aide en ligne */ |
|
| 433 | + define( |
|
| 434 | + '_DOCTYPE_AIDE', |
|
| 435 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 436 | + ); |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 440 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 441 | + * le script de l'espace public, alias index.php */ |
|
| 442 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 443 | + } |
|
| 444 | + if (!defined('_SPIP_PAGE')) { |
|
| 445 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 446 | + define('_SPIP_PAGE', 'page'); |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + // le script de l'espace prive |
|
| 450 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 451 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 452 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 453 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 454 | + if (!empty($_SERVER['SERVER_SOFTWARE']) && preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 455 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 456 | + } else { |
|
| 457 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 458 | + } |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + |
|
| 462 | + if (!defined('_SPIP_AJAX')) { |
|
| 463 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 464 | + ? 1 |
|
| 465 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + // La requete est-elle en ajax ? |
|
| 469 | + if (!defined('_AJAX')) { |
|
| 470 | + define( |
|
| 471 | + '_AJAX', |
|
| 472 | + ( |
|
| 473 | + isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 474 | + || !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuer |
|
| 475 | + || !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 476 | + || !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 477 | + ) |
|
| 478 | + && empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 479 | + ); |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 483 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 484 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 485 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 486 | + define( |
|
| 487 | + '_IMG_GD_MAX_PIXELS', |
|
| 488 | + (isset($GLOBALS['meta']['max_taille_vignettes']) && $GLOBALS['meta']['max_taille_vignettes']) |
|
| 489 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 490 | + : 0 |
|
| 491 | + ); |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + // Protocoles a normaliser dans les chaines de langues |
|
| 495 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 496 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + init_var_mode(); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -530,133 +530,133 @@ discard block |
||
| 530 | 530 | * ` var_mode` (calcul ou recalcul). |
| 531 | 531 | */ |
| 532 | 532 | function init_var_mode() { |
| 533 | - static $done = false; |
|
| 534 | - if (!$done) { |
|
| 535 | - if (isset($_GET['var_mode'])) { |
|
| 536 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 537 | - // tout le monde peut calcul/recalcul |
|
| 538 | - if (!defined('_VAR_MODE')) { |
|
| 539 | - if (in_array('recalcul', $var_mode)) { |
|
| 540 | - define('_VAR_MODE', 'recalcul'); |
|
| 541 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 542 | - define('_VAR_MODE', 'calcul'); |
|
| 543 | - } |
|
| 544 | - } |
|
| 545 | - $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 546 | - if ($var_mode) { |
|
| 547 | - include_spip('inc/autoriser'); |
|
| 548 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 549 | - if ( |
|
| 550 | - autoriser( |
|
| 551 | - ($_GET['var_mode'] == 'preview') |
|
| 552 | - ? 'previsualiser' |
|
| 553 | - : 'debug' |
|
| 554 | - ) |
|
| 555 | - ) { |
|
| 556 | - if (in_array('traduction', $var_mode)) { |
|
| 557 | - // forcer le calcul pour passer dans traduire |
|
| 558 | - if (!defined('_VAR_MODE')) { |
|
| 559 | - define('_VAR_MODE', 'calcul'); |
|
| 560 | - } |
|
| 561 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 562 | - if (!defined('_VAR_NOCACHE')) { |
|
| 563 | - define('_VAR_NOCACHE', true); |
|
| 564 | - } |
|
| 565 | - $var_mode = array_diff($var_mode, ['traduction']); |
|
| 566 | - } |
|
| 567 | - if (in_array('preview', $var_mode)) { |
|
| 568 | - // basculer sur les criteres de preview dans les boucles |
|
| 569 | - if (!defined('_VAR_PREVIEW')) { |
|
| 570 | - define('_VAR_PREVIEW', true); |
|
| 571 | - } |
|
| 572 | - // forcer le calcul |
|
| 573 | - if (!defined('_VAR_MODE')) { |
|
| 574 | - define('_VAR_MODE', 'calcul'); |
|
| 575 | - } |
|
| 576 | - // et ne pas enregistrer de cache |
|
| 577 | - if (!defined('_VAR_NOCACHE')) { |
|
| 578 | - define('_VAR_NOCACHE', true); |
|
| 579 | - } |
|
| 580 | - $var_mode = array_diff($var_mode, ['preview']); |
|
| 581 | - } |
|
| 582 | - if (in_array('inclure', $var_mode)) { |
|
| 583 | - // forcer le compilo et ignorer les caches existants |
|
| 584 | - if (!defined('_VAR_MODE')) { |
|
| 585 | - define('_VAR_MODE', 'calcul'); |
|
| 586 | - } |
|
| 587 | - if (!defined('_VAR_INCLURE')) { |
|
| 588 | - define('_VAR_INCLURE', true); |
|
| 589 | - } |
|
| 590 | - // et ne pas enregistrer de cache |
|
| 591 | - if (!defined('_VAR_NOCACHE')) { |
|
| 592 | - define('_VAR_NOCACHE', true); |
|
| 593 | - } |
|
| 594 | - $var_mode = array_diff($var_mode, ['inclure']); |
|
| 595 | - } |
|
| 596 | - if (in_array('urls', $var_mode)) { |
|
| 597 | - // forcer le compilo et ignorer les caches existants |
|
| 598 | - if (!defined('_VAR_MODE')) { |
|
| 599 | - define('_VAR_MODE', 'calcul'); |
|
| 600 | - } |
|
| 601 | - if (!defined('_VAR_URLS')) { |
|
| 602 | - define('_VAR_URLS', true); |
|
| 603 | - } |
|
| 604 | - $var_mode = array_diff($var_mode, ['urls']); |
|
| 605 | - } |
|
| 606 | - if (in_array('images', $var_mode)) { |
|
| 607 | - // forcer le compilo et ignorer les caches existants |
|
| 608 | - if (!defined('_VAR_MODE')) { |
|
| 609 | - define('_VAR_MODE', 'calcul'); |
|
| 610 | - } |
|
| 611 | - // indiquer qu'on doit recalculer les images |
|
| 612 | - if (!defined('_VAR_IMAGES')) { |
|
| 613 | - define('_VAR_IMAGES', true); |
|
| 614 | - } |
|
| 615 | - $var_mode = array_diff($var_mode, ['images']); |
|
| 616 | - } |
|
| 617 | - if (in_array('debug', $var_mode)) { |
|
| 618 | - if (!defined('_VAR_MODE')) { |
|
| 619 | - define('_VAR_MODE', 'debug'); |
|
| 620 | - } |
|
| 621 | - // et ne pas enregistrer de cache |
|
| 622 | - if (!defined('_VAR_NOCACHE')) { |
|
| 623 | - define('_VAR_NOCACHE', true); |
|
| 624 | - } |
|
| 625 | - $var_mode = array_diff($var_mode, ['debug']); |
|
| 626 | - } |
|
| 627 | - if (count($var_mode) && !defined('_VAR_MODE')) { |
|
| 628 | - define('_VAR_MODE', reset($var_mode)); |
|
| 629 | - } |
|
| 630 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 631 | - spip_logger()->info($GLOBALS['visiteur_session']['nom'] . ' ' . _VAR_MODE); |
|
| 632 | - } |
|
| 633 | - } // pas autorise ? |
|
| 634 | - else { |
|
| 635 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 636 | - if ( |
|
| 637 | - !$GLOBALS['visiteur_session'] |
|
| 638 | - && !empty($_SERVER['HTTP_HOST']) |
|
| 639 | - && !empty($_SERVER['REQUEST_METHOD']) |
|
| 640 | - && $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 641 | - ) { |
|
| 642 | - $self = self('&', true); |
|
| 643 | - if (!str_contains($self, 'page=login')) { |
|
| 644 | - include_spip('inc/headers'); |
|
| 645 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 646 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - // sinon tant pis |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - if (!defined('_VAR_MODE')) { |
|
| 654 | - /** |
|
| 655 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 656 | - * @see init_var_mode() |
|
| 657 | - */ |
|
| 658 | - define('_VAR_MODE', false); |
|
| 659 | - } |
|
| 660 | - $done = true; |
|
| 661 | - } |
|
| 533 | + static $done = false; |
|
| 534 | + if (!$done) { |
|
| 535 | + if (isset($_GET['var_mode'])) { |
|
| 536 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 537 | + // tout le monde peut calcul/recalcul |
|
| 538 | + if (!defined('_VAR_MODE')) { |
|
| 539 | + if (in_array('recalcul', $var_mode)) { |
|
| 540 | + define('_VAR_MODE', 'recalcul'); |
|
| 541 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 542 | + define('_VAR_MODE', 'calcul'); |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | + $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 546 | + if ($var_mode) { |
|
| 547 | + include_spip('inc/autoriser'); |
|
| 548 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 549 | + if ( |
|
| 550 | + autoriser( |
|
| 551 | + ($_GET['var_mode'] == 'preview') |
|
| 552 | + ? 'previsualiser' |
|
| 553 | + : 'debug' |
|
| 554 | + ) |
|
| 555 | + ) { |
|
| 556 | + if (in_array('traduction', $var_mode)) { |
|
| 557 | + // forcer le calcul pour passer dans traduire |
|
| 558 | + if (!defined('_VAR_MODE')) { |
|
| 559 | + define('_VAR_MODE', 'calcul'); |
|
| 560 | + } |
|
| 561 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 562 | + if (!defined('_VAR_NOCACHE')) { |
|
| 563 | + define('_VAR_NOCACHE', true); |
|
| 564 | + } |
|
| 565 | + $var_mode = array_diff($var_mode, ['traduction']); |
|
| 566 | + } |
|
| 567 | + if (in_array('preview', $var_mode)) { |
|
| 568 | + // basculer sur les criteres de preview dans les boucles |
|
| 569 | + if (!defined('_VAR_PREVIEW')) { |
|
| 570 | + define('_VAR_PREVIEW', true); |
|
| 571 | + } |
|
| 572 | + // forcer le calcul |
|
| 573 | + if (!defined('_VAR_MODE')) { |
|
| 574 | + define('_VAR_MODE', 'calcul'); |
|
| 575 | + } |
|
| 576 | + // et ne pas enregistrer de cache |
|
| 577 | + if (!defined('_VAR_NOCACHE')) { |
|
| 578 | + define('_VAR_NOCACHE', true); |
|
| 579 | + } |
|
| 580 | + $var_mode = array_diff($var_mode, ['preview']); |
|
| 581 | + } |
|
| 582 | + if (in_array('inclure', $var_mode)) { |
|
| 583 | + // forcer le compilo et ignorer les caches existants |
|
| 584 | + if (!defined('_VAR_MODE')) { |
|
| 585 | + define('_VAR_MODE', 'calcul'); |
|
| 586 | + } |
|
| 587 | + if (!defined('_VAR_INCLURE')) { |
|
| 588 | + define('_VAR_INCLURE', true); |
|
| 589 | + } |
|
| 590 | + // et ne pas enregistrer de cache |
|
| 591 | + if (!defined('_VAR_NOCACHE')) { |
|
| 592 | + define('_VAR_NOCACHE', true); |
|
| 593 | + } |
|
| 594 | + $var_mode = array_diff($var_mode, ['inclure']); |
|
| 595 | + } |
|
| 596 | + if (in_array('urls', $var_mode)) { |
|
| 597 | + // forcer le compilo et ignorer les caches existants |
|
| 598 | + if (!defined('_VAR_MODE')) { |
|
| 599 | + define('_VAR_MODE', 'calcul'); |
|
| 600 | + } |
|
| 601 | + if (!defined('_VAR_URLS')) { |
|
| 602 | + define('_VAR_URLS', true); |
|
| 603 | + } |
|
| 604 | + $var_mode = array_diff($var_mode, ['urls']); |
|
| 605 | + } |
|
| 606 | + if (in_array('images', $var_mode)) { |
|
| 607 | + // forcer le compilo et ignorer les caches existants |
|
| 608 | + if (!defined('_VAR_MODE')) { |
|
| 609 | + define('_VAR_MODE', 'calcul'); |
|
| 610 | + } |
|
| 611 | + // indiquer qu'on doit recalculer les images |
|
| 612 | + if (!defined('_VAR_IMAGES')) { |
|
| 613 | + define('_VAR_IMAGES', true); |
|
| 614 | + } |
|
| 615 | + $var_mode = array_diff($var_mode, ['images']); |
|
| 616 | + } |
|
| 617 | + if (in_array('debug', $var_mode)) { |
|
| 618 | + if (!defined('_VAR_MODE')) { |
|
| 619 | + define('_VAR_MODE', 'debug'); |
|
| 620 | + } |
|
| 621 | + // et ne pas enregistrer de cache |
|
| 622 | + if (!defined('_VAR_NOCACHE')) { |
|
| 623 | + define('_VAR_NOCACHE', true); |
|
| 624 | + } |
|
| 625 | + $var_mode = array_diff($var_mode, ['debug']); |
|
| 626 | + } |
|
| 627 | + if (count($var_mode) && !defined('_VAR_MODE')) { |
|
| 628 | + define('_VAR_MODE', reset($var_mode)); |
|
| 629 | + } |
|
| 630 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 631 | + spip_logger()->info($GLOBALS['visiteur_session']['nom'] . ' ' . _VAR_MODE); |
|
| 632 | + } |
|
| 633 | + } // pas autorise ? |
|
| 634 | + else { |
|
| 635 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 636 | + if ( |
|
| 637 | + !$GLOBALS['visiteur_session'] |
|
| 638 | + && !empty($_SERVER['HTTP_HOST']) |
|
| 639 | + && !empty($_SERVER['REQUEST_METHOD']) |
|
| 640 | + && $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 641 | + ) { |
|
| 642 | + $self = self('&', true); |
|
| 643 | + if (!str_contains($self, 'page=login')) { |
|
| 644 | + include_spip('inc/headers'); |
|
| 645 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 646 | + redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + // sinon tant pis |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + if (!defined('_VAR_MODE')) { |
|
| 654 | + /** |
|
| 655 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 656 | + * @see init_var_mode() |
|
| 657 | + */ |
|
| 658 | + define('_VAR_MODE', false); |
|
| 659 | + } |
|
| 660 | + $done = true; |
|
| 661 | + } |
|
| 662 | 662 | } |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // le nom du repertoire plugins/ activables/desactivables |
| 41 | 41 | if (!defined('_DIR_PLUGINS')) { |
| 42 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 42 | + define('_DIR_PLUGINS', _DIR_RACINE.'plugins/'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 46 | 46 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 47 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 47 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // le nom du repertoire des librairies |
| 51 | 51 | if (!defined('_DIR_LIB')) { |
| 52 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 52 | + define('_DIR_LIB', _DIR_RACINE.'lib/'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // répertoire des libs via Composer |
| 56 | 56 | if (!defined('_DIR_VENDOR')) { |
| 57 | - define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 57 | + define('_DIR_VENDOR', _DIR_RACINE.'vendor/'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if (!defined('_DIR_IMG')) { |
@@ -64,29 +64,29 @@ discard block |
||
| 64 | 64 | define('_DIR_LOGOS', $pa); |
| 65 | 65 | } |
| 66 | 66 | if (!defined('_DIR_IMG_ICONES')) { |
| 67 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 67 | + define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if (!defined('_DIR_DUMP')) { |
| 71 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 71 | + define('_DIR_DUMP', $ti.'dump/'); |
|
| 72 | 72 | } |
| 73 | 73 | if (!defined('_DIR_SESSIONS')) { |
| 74 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 74 | + define('_DIR_SESSIONS', $ti.'sessions/'); |
|
| 75 | 75 | } |
| 76 | 76 | if (!defined('_DIR_TRANSFERT')) { |
| 77 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 77 | + define('_DIR_TRANSFERT', $ti.'upload/'); |
|
| 78 | 78 | } |
| 79 | 79 | if (!defined('_DIR_CACHE')) { |
| 80 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 80 | + define('_DIR_CACHE', $ti.'cache/'); |
|
| 81 | 81 | } |
| 82 | 82 | if (!defined('_DIR_CACHE_XML')) { |
| 83 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 83 | + define('_DIR_CACHE_XML', _DIR_CACHE.'xml/'); |
|
| 84 | 84 | } |
| 85 | 85 | if (!defined('_DIR_SKELS')) { |
| 86 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 86 | + define('_DIR_SKELS', _DIR_CACHE.'skel/'); |
|
| 87 | 87 | } |
| 88 | 88 | if (!defined('_DIR_AIDE')) { |
| 89 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 89 | + define('_DIR_AIDE', _DIR_CACHE.'aide/'); |
|
| 90 | 90 | } |
| 91 | 91 | if (!defined('_DIR_TMP')) { |
| 92 | 92 | define('_DIR_TMP', $ti); |
@@ -115,27 +115,27 @@ discard block |
||
| 115 | 115 | // Declaration des fichiers |
| 116 | 116 | |
| 117 | 117 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 118 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 118 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php'); |
|
| 119 | 119 | } |
| 120 | 120 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 121 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 121 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php'); |
|
| 122 | 122 | } |
| 123 | 123 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 124 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 124 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php'); |
|
| 125 | 125 | } |
| 126 | 126 | if (!defined('_CACHE_PIPELINES')) { |
| 127 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 127 | + define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php'); |
|
| 128 | 128 | } |
| 129 | 129 | if (!defined('_CACHE_CHEMIN')) { |
| 130 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 130 | + define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt'); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | # attention .php obligatoire pour ecrire_fichier_securise |
| 134 | 134 | if (!defined('_FILE_META')) { |
| 135 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 135 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 136 | 136 | } |
| 137 | 137 | if (!defined('_DIR_LOG')) { |
| 138 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 138 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 139 | 139 | } |
| 140 | 140 | if (!defined('_FILE_LOG')) { |
| 141 | 141 | define('_FILE_LOG', 'spip'); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | if (!defined('_FILE_CONNECT')) { |
| 152 | 152 | define( |
| 153 | 153 | '_FILE_CONNECT', |
| 154 | - @is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false |
|
| 154 | + @is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f : false |
|
| 155 | 155 | ); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | if (!defined('_FILE_CHMOD')) { |
| 163 | 163 | define( |
| 164 | 164 | '_FILE_CHMOD', |
| 165 | - @is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false |
|
| 165 | + @is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f : false |
|
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 175 | 175 | } |
| 176 | 176 | if (!defined('_FILE_CONNECT_TMP')) { |
| 177 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 177 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 178 | 178 | } |
| 179 | 179 | if (!defined('_FILE_CHMOD_TMP')) { |
| 180 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 180 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // Definition des droits d'acces en ecriture |
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 196 | 196 | } |
| 197 | 197 | if (!defined('_ROOT_PLUGINS')) { |
| 198 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins' . DIRECTORY_SEPARATOR); |
|
| 198 | + define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins'.DIRECTORY_SEPARATOR); |
|
| 199 | 199 | } |
| 200 | 200 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 201 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist' . DIRECTORY_SEPARATOR); |
|
| 201 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist'.DIRECTORY_SEPARATOR); |
|
| 202 | 202 | } |
| 203 | 203 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 204 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 204 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // La taille des Log |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 239 | 239 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 240 | 240 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 241 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 241 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 242 | 242 | |
| 243 | 243 | // charger le path des plugins |
| 244 | 244 | if (@is_readable(_CACHE_PLUGINS_PATH)) { |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | !empty($_SERVER['QUERY_STRING']) |
| 277 | 277 | && !strpos($_SERVER['REQUEST_URI'], '?') |
| 278 | 278 | ) { |
| 279 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 279 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | ) { |
| 313 | 313 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 314 | 314 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 315 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 315 | + $uri_ref = ($uri_ref['path'] ?? '').'/'; |
|
| 316 | 316 | } else { |
| 317 | 317 | $uri_ref = ''; |
| 318 | 318 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | } |
| 407 | 407 | if (!defined('_CACHE_RUBRIQUES')) { |
| 408 | 408 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 409 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 409 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 410 | 410 | } |
| 411 | 411 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 412 | 412 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | define('_VAR_MODE', reset($var_mode)); |
| 629 | 629 | } |
| 630 | 630 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 631 | - spip_logger()->info($GLOBALS['visiteur_session']['nom'] . ' ' . _VAR_MODE); |
|
| 631 | + spip_logger()->info($GLOBALS['visiteur_session']['nom'].' '._VAR_MODE); |
|
| 632 | 632 | } |
| 633 | 633 | } // pas autorise ? |
| 634 | 634 | else { |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | if (!str_contains($self, 'page=login')) { |
| 644 | 644 | include_spip('inc/headers'); |
| 645 | 645 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 646 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 646 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | // sinon tant pis |
@@ -24,23 +24,23 @@ discard block |
||
| 24 | 24 | * Les paramètres du pipeline modifiés |
| 25 | 25 | **/ |
| 26 | 26 | function minipipe($fonc, &$val) { |
| 27 | - // fonction |
|
| 28 | - if (function_exists($fonc)) { |
|
| 29 | - $val = $fonc($val); |
|
| 30 | - } // Class::Methode |
|
| 31 | - else { |
|
| 32 | - if ( |
|
| 33 | - preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 34 | - && ($methode = [$regs[1], $regs[2]]) |
|
| 35 | - && is_callable($methode) |
|
| 36 | - ) { |
|
| 37 | - $val = $methode($val); |
|
| 38 | - } else { |
|
| 39 | - spip_logger()->info("Erreur - '$fonc' non definie !"); |
|
| 40 | - } |
|
| 41 | - } |
|
| 27 | + // fonction |
|
| 28 | + if (function_exists($fonc)) { |
|
| 29 | + $val = $fonc($val); |
|
| 30 | + } // Class::Methode |
|
| 31 | + else { |
|
| 32 | + if ( |
|
| 33 | + preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 34 | + && ($methode = [$regs[1], $regs[2]]) |
|
| 35 | + && is_callable($methode) |
|
| 36 | + ) { |
|
| 37 | + $val = $methode($val); |
|
| 38 | + } else { |
|
| 39 | + spip_logger()->info("Erreur - '$fonc' non definie !"); |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - return $val; |
|
| 43 | + return $val; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -71,44 +71,44 @@ discard block |
||
| 71 | 71 | * Résultat |
| 72 | 72 | */ |
| 73 | 73 | function pipeline($action, $val = null) { |
| 74 | - static $charger; |
|
| 74 | + static $charger; |
|
| 75 | 75 | |
| 76 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 77 | - if (!$charger) { |
|
| 78 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 79 | - include_spip('inc/plugin'); |
|
| 80 | - // generer les fichiers php precompiles |
|
| 81 | - // de chargement des plugins et des pipelines |
|
| 82 | - actualise_plugins_actifs(); |
|
| 83 | - if (!($ok = @is_readable($charger))) { |
|
| 84 | - spip_logger()->info("fichier $charger pas cree"); |
|
| 85 | - } |
|
| 86 | - } |
|
| 76 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 77 | + if (!$charger) { |
|
| 78 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 79 | + include_spip('inc/plugin'); |
|
| 80 | + // generer les fichiers php precompiles |
|
| 81 | + // de chargement des plugins et des pipelines |
|
| 82 | + actualise_plugins_actifs(); |
|
| 83 | + if (!($ok = @is_readable($charger))) { |
|
| 84 | + spip_logger()->info("fichier $charger pas cree"); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - if ($ok) { |
|
| 89 | - include_once $charger; |
|
| 90 | - } |
|
| 91 | - } |
|
| 88 | + if ($ok) { |
|
| 89 | + include_once $charger; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - // appliquer notre fonction si elle existe |
|
| 94 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 95 | - if (function_exists($fonc)) { |
|
| 96 | - $val = $fonc($val); |
|
| 97 | - } else { |
|
| 98 | - // plantage ? |
|
| 99 | - spip_logger()->error("fonction $fonc absente : pipeline desactive"); |
|
| 100 | - } |
|
| 93 | + // appliquer notre fonction si elle existe |
|
| 94 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 95 | + if (function_exists($fonc)) { |
|
| 96 | + $val = $fonc($val); |
|
| 97 | + } else { |
|
| 98 | + // plantage ? |
|
| 99 | + spip_logger()->error("fonction $fonc absente : pipeline desactive"); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - // si le flux est une table avec 2 cle args&data |
|
| 103 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 104 | - // array_key_exists pour php 4.1.0 |
|
| 105 | - if ( |
|
| 106 | - is_array($val) |
|
| 107 | - && count($val) == 2 |
|
| 108 | - && array_key_exists('data', $val) |
|
| 109 | - ) { |
|
| 110 | - $val = $val['data']; |
|
| 111 | - } |
|
| 102 | + // si le flux est une table avec 2 cle args&data |
|
| 103 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 104 | + // array_key_exists pour php 4.1.0 |
|
| 105 | + if ( |
|
| 106 | + is_array($val) |
|
| 107 | + && count($val) == 2 |
|
| 108 | + && array_key_exists('data', $val) |
|
| 109 | + ) { |
|
| 110 | + $val = $val['data']; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - return $val; |
|
| 113 | + return $val; |
|
| 114 | 114 | } |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // appliquer notre fonction si elle existe |
| 94 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 94 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 95 | 95 | if (function_exists($fonc)) { |
| 96 | 96 | $val = $fonc($val); |
| 97 | 97 | } else { |
@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | * @uses cron() |
| 8 | 8 | **/ |
| 9 | 9 | function action_cron() { |
| 10 | - include_spip('inc/headers'); |
|
| 11 | - http_response_code(204); // No Content |
|
| 12 | - header('Connection: close'); |
|
| 13 | - define('_DIRECT_CRON_FORCE', true); |
|
| 14 | - cron(); |
|
| 10 | + include_spip('inc/headers'); |
|
| 11 | + http_response_code(204); // No Content |
|
| 12 | + header('Connection: close'); |
|
| 13 | + define('_DIRECT_CRON_FORCE', true); |
|
| 14 | + cron(); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -27,26 +27,26 @@ discard block |
||
| 27 | 27 | * True si la tache a pu être effectuée |
| 28 | 28 | */ |
| 29 | 29 | function cron($taches = [], $taches_old = []) { |
| 30 | - // si pas en mode cron force, laisser tomber. |
|
| 31 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 32 | - return false; |
|
| 33 | - } |
|
| 34 | - if (!is_array($taches)) { |
|
| 35 | - $taches = $taches_old; |
|
| 36 | - } // compat anciens appels |
|
| 37 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 38 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 39 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 40 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 41 | - if ($taches && count($taches) && !spip_connect()) { |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 44 | - spip_logger('jq')->debug('cron !'); |
|
| 45 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 46 | - return $genie($taches); |
|
| 47 | - } |
|
| 30 | + // si pas en mode cron force, laisser tomber. |
|
| 31 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 32 | + return false; |
|
| 33 | + } |
|
| 34 | + if (!is_array($taches)) { |
|
| 35 | + $taches = $taches_old; |
|
| 36 | + } // compat anciens appels |
|
| 37 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 38 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 39 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 40 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 41 | + if ($taches && count($taches) && !spip_connect()) { |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | + spip_logger('jq')->debug('cron !'); |
|
| 45 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 46 | + return $genie($taches); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return false; |
|
| 49 | + return false; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 79 | 79 | */ |
| 80 | 80 | function job_queue_add( |
| 81 | - $function, |
|
| 82 | - $description, |
|
| 83 | - $arguments = [], |
|
| 84 | - $file = '', |
|
| 85 | - $no_duplicate = false, |
|
| 86 | - $time = 0, |
|
| 87 | - $priority = 0 |
|
| 81 | + $function, |
|
| 82 | + $description, |
|
| 83 | + $arguments = [], |
|
| 84 | + $file = '', |
|
| 85 | + $no_duplicate = false, |
|
| 86 | + $time = 0, |
|
| 87 | + $priority = 0 |
|
| 88 | 88 | ) { |
| 89 | - include_spip('inc/queue'); |
|
| 89 | + include_spip('inc/queue'); |
|
| 90 | 90 | |
| 91 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 91 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | * @return bool |
| 100 | 100 | */ |
| 101 | 101 | function job_queue_remove($id_job) { |
| 102 | - include_spip('inc/queue'); |
|
| 102 | + include_spip('inc/queue'); |
|
| 103 | 103 | |
| 104 | - return queue_remove_job($id_job); |
|
| 104 | + return queue_remove_job($id_job); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * or an array of simple array to link multiples objet in one time |
| 115 | 115 | */ |
| 116 | 116 | function job_queue_link($id_job, $objets) { |
| 117 | - include_spip('inc/queue'); |
|
| 117 | + include_spip('inc/queue'); |
|
| 118 | 118 | |
| 119 | - return queue_link_job($id_job, $objets); |
|
| 119 | + return queue_link_job($id_job, $objets); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
@@ -135,35 +135,35 @@ discard block |
||
| 135 | 135 | * - `null` si la queue n'est pas encore initialisée |
| 136 | 136 | */ |
| 137 | 137 | function queue_sleep_time_to_next_job($force = null) { |
| 138 | - static $queue_next_job_time = -1; |
|
| 139 | - if ($force === true) { |
|
| 140 | - $queue_next_job_time = -1; |
|
| 141 | - } elseif ($force) { |
|
| 142 | - $queue_next_job_time = $force; |
|
| 143 | - } |
|
| 138 | + static $queue_next_job_time = -1; |
|
| 139 | + if ($force === true) { |
|
| 140 | + $queue_next_job_time = -1; |
|
| 141 | + } elseif ($force) { |
|
| 142 | + $queue_next_job_time = $force; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if ($queue_next_job_time == -1) { |
|
| 146 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 147 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 148 | - } |
|
| 149 | - // utiliser un cache memoire si dispo |
|
| 150 | - if (function_exists('cache_get') && defined('_MEMOIZE_MEMORY') && _MEMOIZE_MEMORY) { |
|
| 151 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 152 | - } else { |
|
| 153 | - $queue_next_job_time = null; |
|
| 154 | - $contenu = null; |
|
| 155 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 156 | - $queue_next_job_time = intval($contenu); |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - } |
|
| 145 | + if ($queue_next_job_time == -1) { |
|
| 146 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 147 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 148 | + } |
|
| 149 | + // utiliser un cache memoire si dispo |
|
| 150 | + if (function_exists('cache_get') && defined('_MEMOIZE_MEMORY') && _MEMOIZE_MEMORY) { |
|
| 151 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 152 | + } else { |
|
| 153 | + $queue_next_job_time = null; |
|
| 154 | + $contenu = null; |
|
| 155 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 156 | + $queue_next_job_time = intval($contenu); |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - if (is_null($queue_next_job_time)) { |
|
| 162 | - return null; |
|
| 163 | - } |
|
| 164 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 165 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 166 | - } |
|
| 161 | + if (is_null($queue_next_job_time)) { |
|
| 162 | + return null; |
|
| 163 | + } |
|
| 164 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 165 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 168 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 169 | 169 | } |
@@ -144,7 +144,7 @@ |
||
| 144 | 144 | |
| 145 | 145 | if ($queue_next_job_time == -1) { |
| 146 | 146 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 147 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 147 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt'); |
|
| 148 | 148 | } |
| 149 | 149 | // utiliser un cache memoire si dispo |
| 150 | 150 | if (function_exists('cache_get') && defined('_MEMOIZE_MEMORY') && _MEMOIZE_MEMORY) { |
@@ -26,85 +26,85 @@ discard block |
||
| 26 | 26 | * ``` |
| 27 | 27 | */ |
| 28 | 28 | function spip_logger(?string $name = null): LoggerInterface { |
| 29 | - /* @var array<string,LoggerInterface> */ |
|
| 30 | - static $loggers = []; |
|
| 31 | - /* @var ?Factory */ |
|
| 32 | - static $loggerFactory = null; |
|
| 33 | - |
|
| 34 | - $name ??= 'spip'; |
|
| 35 | - |
|
| 36 | - if ($loggerFactory === null) { |
|
| 37 | - $spipToMonologLevels = [ |
|
| 38 | - Level::Emergency, // _LOG_HS |
|
| 39 | - Level::Alert, // _LOG_ALERTE_ROUGE |
|
| 40 | - Level::Critical, // _LOG_CRITIQUE |
|
| 41 | - Level::Error, // _LOG_ERREUR |
|
| 42 | - Level::Warning, // _LOG_AVERTISSEMENT |
|
| 43 | - Level::Notice, // _LOG_INFO_IMPORTANTE |
|
| 44 | - Level::Info, // _LOG_INFO |
|
| 45 | - Level::Debug, // _LOG_DEBUG |
|
| 46 | - ]; |
|
| 47 | - |
|
| 48 | - $config = [ |
|
| 49 | - 'siteDir' => _ROOT_RACINE, |
|
| 50 | - 'filesystem' => new Filesystem(), |
|
| 51 | - // max log par hit |
|
| 52 | - 'max_log' => defined('_MAX_LOG') ? constant('_MAX_LOG') : null, |
|
| 53 | - // pour indiquer le chemin du fichier qui envoie le log |
|
| 54 | - 'fileline' => defined('_LOG_FILELINE') ? constant('_LOG_FILELINE') : null, |
|
| 55 | - // échappement des log |
|
| 56 | - 'brut' => defined('_LOG_BRUT') ? constant('_LOG_BRUT') : null, |
|
| 57 | - // à quel level on commence à logguer |
|
| 58 | - 'max_level' => (function() use ($spipToMonologLevels): Level { |
|
| 59 | - if (!defined('_LOG_FILTRE_GRAVITE')) { |
|
| 60 | - return Level::Notice; |
|
| 61 | - } |
|
| 62 | - $level = constant('_LOG_FILTRE_GRAVITE'); |
|
| 63 | - if ($level instanceof Level) { |
|
| 64 | - return $level; |
|
| 65 | - } |
|
| 66 | - if (isset($spipToMonologLevels[$level])) { |
|
| 67 | - return $spipToMonologLevels[$level]; |
|
| 68 | - } |
|
| 69 | - return match($level) { |
|
| 70 | - LogLevel::EMERGENCY => Level::Emergency, |
|
| 71 | - LogLevel::ALERT => Level::Alert, |
|
| 72 | - LogLevel::CRITICAL => Level::Critical, |
|
| 73 | - LogLevel::CRITICAL => Level::Error, |
|
| 74 | - LogLevel::CRITICAL => Level::Warning, |
|
| 75 | - LogLevel::CRITICAL => Level::Notice, |
|
| 76 | - LogLevel::CRITICAL => Level::Info, |
|
| 77 | - LogLevel::CRITICAL => Level::Debug, |
|
| 78 | - default => Level::Notice, |
|
| 79 | - }; |
|
| 80 | - })(), |
|
| 81 | - // rotation: nombre de fichiers |
|
| 82 | - 'max_files' => $GLOBALS['nombre_de_logs'] ??= 4, |
|
| 83 | - // rotation: taille max d’un fichier |
|
| 84 | - 'max_size' => ($GLOBALS['taille_des_logs'] ??= 100) * 1024, |
|
| 85 | - // chemin du fichier de log |
|
| 86 | - 'log_path' => (function() { |
|
| 87 | - $log_dir = defined('_DIR_LOG') ? str_replace(_DIR_RACINE, '', constant('_DIR_LOG')) : 'tmp/log/'; |
|
| 88 | - $log_file = defined('_FILE_LOG') ? constant('_FILE_LOG') : 'spip'; |
|
| 89 | - $log_suffix = defined('_FILE_LOG_SUFFIX') ? constant('_FILE_LOG_SUFFIX') : '.log'; |
|
| 90 | - |
|
| 91 | - $log_file = str_replace('spip', '%s', $log_file); |
|
| 92 | - return sprintf('%s%s%s', $log_dir, $log_file, $log_suffix); |
|
| 93 | - })(), |
|
| 94 | - ]; |
|
| 95 | - $env = getenv('APP_ENV') ?? 'prod'; |
|
| 96 | - if ($env === 'dev') { |
|
| 97 | - $config = [ |
|
| 98 | - ...$config, |
|
| 99 | - 'fileline' => true, |
|
| 100 | - 'max_level' => Level::Debug, |
|
| 101 | - ]; |
|
| 102 | - } |
|
| 103 | - $config = array_filter($config); |
|
| 104 | - |
|
| 105 | - $loggerFactory = new Factory(new Config(...$config), new LineFormatter()); |
|
| 106 | - unset($args, $env, $spipToMonologLevels); |
|
| 107 | - } |
|
| 29 | + /* @var array<string,LoggerInterface> */ |
|
| 30 | + static $loggers = []; |
|
| 31 | + /* @var ?Factory */ |
|
| 32 | + static $loggerFactory = null; |
|
| 33 | + |
|
| 34 | + $name ??= 'spip'; |
|
| 35 | + |
|
| 36 | + if ($loggerFactory === null) { |
|
| 37 | + $spipToMonologLevels = [ |
|
| 38 | + Level::Emergency, // _LOG_HS |
|
| 39 | + Level::Alert, // _LOG_ALERTE_ROUGE |
|
| 40 | + Level::Critical, // _LOG_CRITIQUE |
|
| 41 | + Level::Error, // _LOG_ERREUR |
|
| 42 | + Level::Warning, // _LOG_AVERTISSEMENT |
|
| 43 | + Level::Notice, // _LOG_INFO_IMPORTANTE |
|
| 44 | + Level::Info, // _LOG_INFO |
|
| 45 | + Level::Debug, // _LOG_DEBUG |
|
| 46 | + ]; |
|
| 47 | + |
|
| 48 | + $config = [ |
|
| 49 | + 'siteDir' => _ROOT_RACINE, |
|
| 50 | + 'filesystem' => new Filesystem(), |
|
| 51 | + // max log par hit |
|
| 52 | + 'max_log' => defined('_MAX_LOG') ? constant('_MAX_LOG') : null, |
|
| 53 | + // pour indiquer le chemin du fichier qui envoie le log |
|
| 54 | + 'fileline' => defined('_LOG_FILELINE') ? constant('_LOG_FILELINE') : null, |
|
| 55 | + // échappement des log |
|
| 56 | + 'brut' => defined('_LOG_BRUT') ? constant('_LOG_BRUT') : null, |
|
| 57 | + // à quel level on commence à logguer |
|
| 58 | + 'max_level' => (function() use ($spipToMonologLevels): Level { |
|
| 59 | + if (!defined('_LOG_FILTRE_GRAVITE')) { |
|
| 60 | + return Level::Notice; |
|
| 61 | + } |
|
| 62 | + $level = constant('_LOG_FILTRE_GRAVITE'); |
|
| 63 | + if ($level instanceof Level) { |
|
| 64 | + return $level; |
|
| 65 | + } |
|
| 66 | + if (isset($spipToMonologLevels[$level])) { |
|
| 67 | + return $spipToMonologLevels[$level]; |
|
| 68 | + } |
|
| 69 | + return match($level) { |
|
| 70 | + LogLevel::EMERGENCY => Level::Emergency, |
|
| 71 | + LogLevel::ALERT => Level::Alert, |
|
| 72 | + LogLevel::CRITICAL => Level::Critical, |
|
| 73 | + LogLevel::CRITICAL => Level::Error, |
|
| 74 | + LogLevel::CRITICAL => Level::Warning, |
|
| 75 | + LogLevel::CRITICAL => Level::Notice, |
|
| 76 | + LogLevel::CRITICAL => Level::Info, |
|
| 77 | + LogLevel::CRITICAL => Level::Debug, |
|
| 78 | + default => Level::Notice, |
|
| 79 | + }; |
|
| 80 | + })(), |
|
| 81 | + // rotation: nombre de fichiers |
|
| 82 | + 'max_files' => $GLOBALS['nombre_de_logs'] ??= 4, |
|
| 83 | + // rotation: taille max d’un fichier |
|
| 84 | + 'max_size' => ($GLOBALS['taille_des_logs'] ??= 100) * 1024, |
|
| 85 | + // chemin du fichier de log |
|
| 86 | + 'log_path' => (function() { |
|
| 87 | + $log_dir = defined('_DIR_LOG') ? str_replace(_DIR_RACINE, '', constant('_DIR_LOG')) : 'tmp/log/'; |
|
| 88 | + $log_file = defined('_FILE_LOG') ? constant('_FILE_LOG') : 'spip'; |
|
| 89 | + $log_suffix = defined('_FILE_LOG_SUFFIX') ? constant('_FILE_LOG_SUFFIX') : '.log'; |
|
| 90 | + |
|
| 91 | + $log_file = str_replace('spip', '%s', $log_file); |
|
| 92 | + return sprintf('%s%s%s', $log_dir, $log_file, $log_suffix); |
|
| 93 | + })(), |
|
| 94 | + ]; |
|
| 95 | + $env = getenv('APP_ENV') ?? 'prod'; |
|
| 96 | + if ($env === 'dev') { |
|
| 97 | + $config = [ |
|
| 98 | + ...$config, |
|
| 99 | + 'fileline' => true, |
|
| 100 | + 'max_level' => Level::Debug, |
|
| 101 | + ]; |
|
| 102 | + } |
|
| 103 | + $config = array_filter($config); |
|
| 104 | + |
|
| 105 | + $loggerFactory = new Factory(new Config(...$config), new LineFormatter()); |
|
| 106 | + unset($args, $env, $spipToMonologLevels); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | return $loggers[$name] ??= $loggerFactory->createFromFilename($name); |
| 110 | 110 | } |
@@ -135,18 +135,18 @@ discard block |
||
| 135 | 135 | function spip_log($message, $name = null): void |
| 136 | 136 | { |
| 137 | 137 | static $spipToMonologLevels = [ |
| 138 | - Level::Emergency, // _LOG_HS |
|
| 139 | - Level::Alert, // _LOG_ALERTE_ROUGE |
|
| 140 | - Level::Critical, // _LOG_CRITIQUE |
|
| 141 | - Level::Error, // _LOG_ERREUR |
|
| 142 | - Level::Warning, // _LOG_AVERTISSEMENT |
|
| 143 | - Level::Notice, // _LOG_INFO_IMPORTANTE |
|
| 144 | - Level::Info, // _LOG_INFO |
|
| 145 | - Level::Debug, // _LOG_DEBUG |
|
| 138 | + Level::Emergency, // _LOG_HS |
|
| 139 | + Level::Alert, // _LOG_ALERTE_ROUGE |
|
| 140 | + Level::Critical, // _LOG_CRITIQUE |
|
| 141 | + Level::Error, // _LOG_ERREUR |
|
| 142 | + Level::Warning, // _LOG_AVERTISSEMENT |
|
| 143 | + Level::Notice, // _LOG_INFO_IMPORTANTE |
|
| 144 | + Level::Info, // _LOG_INFO |
|
| 145 | + Level::Debug, // _LOG_DEBUG |
|
| 146 | 146 | ]; |
| 147 | 147 | |
| 148 | - # Éviter de trop polluer les logs de dépréciation |
|
| 149 | - static $deprecated = []; |
|
| 148 | + # Éviter de trop polluer les logs de dépréciation |
|
| 149 | + static $deprecated = []; |
|
| 150 | 150 | |
| 151 | 151 | preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
| 152 | 152 | $logFile = 'spip'; |
@@ -154,46 +154,46 @@ discard block |
||
| 154 | 154 | $logFile = $regs[1]; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if (!isset($regs[2])) { |
|
| 158 | - $level = Level::Info; |
|
| 159 | - } else { |
|
| 160 | - $level = $spipToMonologLevels[intval($regs[2])] ?? Level::Info; |
|
| 161 | - } |
|
| 157 | + if (!isset($regs[2])) { |
|
| 158 | + $level = Level::Info; |
|
| 159 | + } else { |
|
| 160 | + $level = $spipToMonologLevels[intval($regs[2])] ?? Level::Info; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - $logger = spip_logger($logFile); |
|
| 164 | - $logger->log($level, preg_replace( |
|
| 163 | + $logger = spip_logger($logFile); |
|
| 164 | + $logger->log($level, preg_replace( |
|
| 165 | 165 | "/\n*$/", |
| 166 | 166 | "\n", |
| 167 | 167 | is_string($message) ? $message : print_r($message, true) |
| 168 | 168 | )); |
| 169 | 169 | |
| 170 | 170 | |
| 171 | - if (!array_key_exists($logFile, $deprecated)) { |
|
| 172 | - $deprecated[$logFile] = true; |
|
| 173 | - if ($logFile === 'spip') { |
|
| 174 | - trigger_deprecation( |
|
| 175 | - 'spip', |
|
| 176 | - '5.0', |
|
| 177 | - sprintf( |
|
| 178 | - 'spip_log(\'message\') function is deprecated ; use spip_logger().' |
|
| 179 | - . ' Example: spip_logger()->info(\'message\').', |
|
| 180 | - $logFile, |
|
| 181 | - $logFile, |
|
| 182 | - ) |
|
| 183 | - ); |
|
| 184 | - } else { |
|
| 185 | - trigger_deprecation( |
|
| 186 | - 'spip', |
|
| 187 | - '5.0', |
|
| 188 | - sprintf( |
|
| 189 | - 'spip_log(\'message\', \'%s\') function is deprecated ; use spip_logger().' |
|
| 190 | - . ' Example: spip_logger(\'%s\')->info(\'message\').', |
|
| 191 | - $logFile, |
|
| 192 | - $logFile, |
|
| 193 | - ) |
|
| 194 | - ); |
|
| 195 | - } |
|
| 196 | - } |
|
| 171 | + if (!array_key_exists($logFile, $deprecated)) { |
|
| 172 | + $deprecated[$logFile] = true; |
|
| 173 | + if ($logFile === 'spip') { |
|
| 174 | + trigger_deprecation( |
|
| 175 | + 'spip', |
|
| 176 | + '5.0', |
|
| 177 | + sprintf( |
|
| 178 | + 'spip_log(\'message\') function is deprecated ; use spip_logger().' |
|
| 179 | + . ' Example: spip_logger()->info(\'message\').', |
|
| 180 | + $logFile, |
|
| 181 | + $logFile, |
|
| 182 | + ) |
|
| 183 | + ); |
|
| 184 | + } else { |
|
| 185 | + trigger_deprecation( |
|
| 186 | + 'spip', |
|
| 187 | + '5.0', |
|
| 188 | + sprintf( |
|
| 189 | + 'spip_log(\'message\', \'%s\') function is deprecated ; use spip_logger().' |
|
| 190 | + . ' Example: spip_logger(\'%s\')->info(\'message\').', |
|
| 191 | + $logFile, |
|
| 192 | + $logFile, |
|
| 193 | + ) |
|
| 194 | + ); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
@@ -205,6 +205,6 @@ discard block |
||
| 205 | 205 | * @param array $opt Tableau d'options |
| 206 | 206 | **/ |
| 207 | 207 | function journal($phrase, $opt = []) { |
| 208 | - $journal = charger_fonction('journal', 'inc'); |
|
| 209 | - $journal($phrase, $opt); |
|
| 208 | + $journal = charger_fonction('journal', 'inc'); |
|
| 209 | + $journal($phrase, $opt); |
|
| 210 | 210 | } |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | if ($loggerFactory === null) { |
| 37 | 37 | $spipToMonologLevels = [ |
| 38 | 38 | Level::Emergency, // _LOG_HS |
| 39 | - Level::Alert, // _LOG_ALERTE_ROUGE |
|
| 40 | - Level::Critical, // _LOG_CRITIQUE |
|
| 41 | - Level::Error, // _LOG_ERREUR |
|
| 42 | - Level::Warning, // _LOG_AVERTISSEMENT |
|
| 43 | - Level::Notice, // _LOG_INFO_IMPORTANTE |
|
| 44 | - Level::Info, // _LOG_INFO |
|
| 45 | - Level::Debug, // _LOG_DEBUG |
|
| 39 | + Level::Alert, // _LOG_ALERTE_ROUGE |
|
| 40 | + Level::Critical, // _LOG_CRITIQUE |
|
| 41 | + Level::Error, // _LOG_ERREUR |
|
| 42 | + Level::Warning, // _LOG_AVERTISSEMENT |
|
| 43 | + Level::Notice, // _LOG_INFO_IMPORTANTE |
|
| 44 | + Level::Info, // _LOG_INFO |
|
| 45 | + Level::Debug, // _LOG_DEBUG |
|
| 46 | 46 | ]; |
| 47 | 47 | |
| 48 | 48 | $config = [ |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | // échappement des log |
| 56 | 56 | 'brut' => defined('_LOG_BRUT') ? constant('_LOG_BRUT') : null, |
| 57 | 57 | // à quel level on commence à logguer |
| 58 | - 'max_level' => (function() use ($spipToMonologLevels): Level { |
|
| 58 | + 'max_level' => (function() use ($spipToMonologLevels) : Level { |
|
| 59 | 59 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 60 | 60 | return Level::Notice; |
| 61 | 61 | } |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | static $spipToMonologLevels = [ |
| 138 | 138 | Level::Emergency, // _LOG_HS |
| 139 | - Level::Alert, // _LOG_ALERTE_ROUGE |
|
| 140 | - Level::Critical, // _LOG_CRITIQUE |
|
| 141 | - Level::Error, // _LOG_ERREUR |
|
| 142 | - Level::Warning, // _LOG_AVERTISSEMENT |
|
| 143 | - Level::Notice, // _LOG_INFO_IMPORTANTE |
|
| 144 | - Level::Info, // _LOG_INFO |
|
| 145 | - Level::Debug, // _LOG_DEBUG |
|
| 139 | + Level::Alert, // _LOG_ALERTE_ROUGE |
|
| 140 | + Level::Critical, // _LOG_CRITIQUE |
|
| 141 | + Level::Error, // _LOG_ERREUR |
|
| 142 | + Level::Warning, // _LOG_AVERTISSEMENT |
|
| 143 | + Level::Notice, // _LOG_INFO_IMPORTANTE |
|
| 144 | + Level::Info, // _LOG_INFO |
|
| 145 | + Level::Debug, // _LOG_DEBUG |
|
| 146 | 146 | ]; |
| 147 | 147 | |
| 148 | 148 | # Éviter de trop polluer les logs de dépréciation |
@@ -8,11 +8,11 @@ discard block |
||
| 8 | 8 | * @return string |
| 9 | 9 | */ |
| 10 | 10 | function quote_amp($u) { |
| 11 | - return preg_replace( |
|
| 12 | - '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 13 | - '&', |
|
| 14 | - $u |
|
| 15 | - ); |
|
| 11 | + return preg_replace( |
|
| 12 | + '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 13 | + '&', |
|
| 14 | + $u |
|
| 15 | + ); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -20,23 +20,22 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * On est sur le web, on exclut certains protocoles, |
| 22 | 22 | * notamment 'file://', 'php://' et d'autres… |
| 23 | - |
|
| 24 | 23 | * @param string $url |
| 25 | 24 | * @return bool |
| 26 | 25 | */ |
| 27 | 26 | function tester_url_absolue($url) { |
| 28 | - $url = trim($url ?? ''); |
|
| 29 | - if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 30 | - if ( |
|
| 31 | - isset($m[1]) |
|
| 32 | - && ($p = strtolower(rtrim($m[1], ':'))) |
|
| 33 | - && in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 34 | - ) { |
|
| 35 | - return false; |
|
| 36 | - } |
|
| 37 | - return true; |
|
| 38 | - } |
|
| 39 | - return false; |
|
| 27 | + $url = trim($url ?? ''); |
|
| 28 | + if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 29 | + if ( |
|
| 30 | + isset($m[1]) |
|
| 31 | + && ($p = strtolower(rtrim($m[1], ':'))) |
|
| 32 | + && in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 33 | + ) { |
|
| 34 | + return false; |
|
| 35 | + } |
|
| 36 | + return true; |
|
| 37 | + } |
|
| 38 | + return false; |
|
| 40 | 39 | } |
| 41 | 40 | |
| 42 | 41 | /** |
@@ -58,100 +57,100 @@ discard block |
||
| 58 | 57 | * @return string URL |
| 59 | 58 | */ |
| 60 | 59 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 61 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 62 | - if (str_contains($c, '|') && is_null($v)) { |
|
| 63 | - return null; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - // lever l'#ancre |
|
| 67 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 68 | - $url = $r[1]; |
|
| 69 | - $ancre = $r[2]; |
|
| 70 | - } else { |
|
| 71 | - $ancre = ''; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - // eclater |
|
| 75 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 76 | - |
|
| 77 | - // recuperer la base |
|
| 78 | - $a = array_shift($url); |
|
| 79 | - if (!$a) { |
|
| 80 | - $a = './'; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - // preparer la regexp de maniere securisee |
|
| 84 | - $regexp = explode('|', $c); |
|
| 85 | - foreach ($regexp as $r => $e) { |
|
| 86 | - $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e)); |
|
| 87 | - } |
|
| 88 | - $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,'; |
|
| 89 | - $ajouts = array_flip(explode('|', $c)); |
|
| 90 | - $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 91 | - $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 92 | - $v_read = null; |
|
| 93 | - // lire les variables et agir |
|
| 94 | - foreach ($url as $n => $val) { |
|
| 95 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 96 | - $r = array_pad($r, 3, null); |
|
| 97 | - if ($v === null) { |
|
| 98 | - // c'est un tableau, on memorise les valeurs |
|
| 99 | - if (str_ends_with($r[1], '[]')) { |
|
| 100 | - if (!$v_read) { |
|
| 101 | - $v_read = []; |
|
| 102 | - } |
|
| 103 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 104 | - } // c'est un scalaire, on retourne direct |
|
| 105 | - else { |
|
| 106 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 107 | - } |
|
| 108 | - } // suppression |
|
| 109 | - elseif (!$testv) { |
|
| 110 | - unset($url[$n]); |
|
| 111 | - } |
|
| 112 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 113 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 114 | - elseif (!str_ends_with($r[1], '[]')) { |
|
| 115 | - $url[$n] = $r[1] . '=' . $u; |
|
| 116 | - unset($ajouts[$r[1]]); |
|
| 117 | - } |
|
| 118 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 119 | - // départ, on remplira à l'étape suivante |
|
| 120 | - else { |
|
| 121 | - unset($url[$n]); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // traiter les parametres pas encore trouves |
|
| 127 | - if ( |
|
| 128 | - $v === null |
|
| 129 | - && ($args = func_get_args()) |
|
| 130 | - && count($args) == 2 |
|
| 131 | - ) { |
|
| 132 | - return $v_read; // rien trouve ou un tableau |
|
| 133 | - } elseif ($testv) { |
|
| 134 | - foreach ($ajouts as $k => $n) { |
|
| 135 | - if (!is_array($v)) { |
|
| 136 | - $url[] = $k . '=' . $u; |
|
| 137 | - } else { |
|
| 138 | - $id = (str_ends_with($k, '[]')) ? $k : ($k . '[]'); |
|
| 139 | - foreach ($v as $w) { |
|
| 140 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - // eliminer les vides |
|
| 147 | - $url = array_filter($url); |
|
| 148 | - |
|
| 149 | - // recomposer l'adresse |
|
| 150 | - if ($url) { |
|
| 151 | - $a .= '?' . join($sep, $url); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $a . $ancre; |
|
| 60 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 61 | + if (str_contains($c, '|') && is_null($v)) { |
|
| 62 | + return null; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + // lever l'#ancre |
|
| 66 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 67 | + $url = $r[1]; |
|
| 68 | + $ancre = $r[2]; |
|
| 69 | + } else { |
|
| 70 | + $ancre = ''; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // eclater |
|
| 74 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 75 | + |
|
| 76 | + // recuperer la base |
|
| 77 | + $a = array_shift($url); |
|
| 78 | + if (!$a) { |
|
| 79 | + $a = './'; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + // preparer la regexp de maniere securisee |
|
| 83 | + $regexp = explode('|', $c); |
|
| 84 | + foreach ($regexp as $r => $e) { |
|
| 85 | + $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e)); |
|
| 86 | + } |
|
| 87 | + $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,'; |
|
| 88 | + $ajouts = array_flip(explode('|', $c)); |
|
| 89 | + $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 90 | + $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 91 | + $v_read = null; |
|
| 92 | + // lire les variables et agir |
|
| 93 | + foreach ($url as $n => $val) { |
|
| 94 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 95 | + $r = array_pad($r, 3, null); |
|
| 96 | + if ($v === null) { |
|
| 97 | + // c'est un tableau, on memorise les valeurs |
|
| 98 | + if (str_ends_with($r[1], '[]')) { |
|
| 99 | + if (!$v_read) { |
|
| 100 | + $v_read = []; |
|
| 101 | + } |
|
| 102 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 103 | + } // c'est un scalaire, on retourne direct |
|
| 104 | + else { |
|
| 105 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 106 | + } |
|
| 107 | + } // suppression |
|
| 108 | + elseif (!$testv) { |
|
| 109 | + unset($url[$n]); |
|
| 110 | + } |
|
| 111 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 112 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 113 | + elseif (!str_ends_with($r[1], '[]')) { |
|
| 114 | + $url[$n] = $r[1] . '=' . $u; |
|
| 115 | + unset($ajouts[$r[1]]); |
|
| 116 | + } |
|
| 117 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 118 | + // départ, on remplira à l'étape suivante |
|
| 119 | + else { |
|
| 120 | + unset($url[$n]); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + // traiter les parametres pas encore trouves |
|
| 126 | + if ( |
|
| 127 | + $v === null |
|
| 128 | + && ($args = func_get_args()) |
|
| 129 | + && count($args) == 2 |
|
| 130 | + ) { |
|
| 131 | + return $v_read; // rien trouve ou un tableau |
|
| 132 | + } elseif ($testv) { |
|
| 133 | + foreach ($ajouts as $k => $n) { |
|
| 134 | + if (!is_array($v)) { |
|
| 135 | + $url[] = $k . '=' . $u; |
|
| 136 | + } else { |
|
| 137 | + $id = (str_ends_with($k, '[]')) ? $k : ($k . '[]'); |
|
| 138 | + foreach ($v as $w) { |
|
| 139 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + // eliminer les vides |
|
| 146 | + $url = array_filter($url); |
|
| 147 | + |
|
| 148 | + // recomposer l'adresse |
|
| 149 | + if ($url) { |
|
| 150 | + $a .= '?' . join($sep, $url); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $a . $ancre; |
|
| 155 | 154 | } |
| 156 | 155 | |
| 157 | 156 | /** |
@@ -166,22 +165,22 @@ discard block |
||
| 166 | 165 | * @uses translitteration() |
| 167 | 166 | */ |
| 168 | 167 | function ancre_url(string $url, ?string $ancre = ''): string { |
| 169 | - $ancre ??= ''; |
|
| 170 | - // lever l'#ancre |
|
| 171 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 172 | - $url = $r[1]; |
|
| 173 | - } |
|
| 174 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 175 | - if (!function_exists('translitteration')) { |
|
| 176 | - include_spip('inc/charsets'); |
|
| 177 | - } |
|
| 178 | - $ancre = preg_replace( |
|
| 179 | - ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 180 | - ['', '-'], |
|
| 181 | - translitteration($ancre) |
|
| 182 | - ); |
|
| 183 | - } |
|
| 184 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 168 | + $ancre ??= ''; |
|
| 169 | + // lever l'#ancre |
|
| 170 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 171 | + $url = $r[1]; |
|
| 172 | + } |
|
| 173 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 174 | + if (!function_exists('translitteration')) { |
|
| 175 | + include_spip('inc/charsets'); |
|
| 176 | + } |
|
| 177 | + $ancre = preg_replace( |
|
| 178 | + ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 179 | + ['', '-'], |
|
| 180 | + translitteration($ancre) |
|
| 181 | + ); |
|
| 182 | + } |
|
| 183 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 185 | 184 | } |
| 186 | 185 | |
| 187 | 186 | /** |
@@ -191,16 +190,16 @@ discard block |
||
| 191 | 190 | * @return string |
| 192 | 191 | */ |
| 193 | 192 | function nettoyer_uri($reset = null) { |
| 194 | - static $done = false; |
|
| 195 | - static $propre = ''; |
|
| 196 | - if (!is_null($reset)) { |
|
| 197 | - return $propre = $reset; |
|
| 198 | - } |
|
| 199 | - if ($done) { |
|
| 200 | - return $propre; |
|
| 201 | - } |
|
| 202 | - $done = true; |
|
| 203 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 193 | + static $done = false; |
|
| 194 | + static $propre = ''; |
|
| 195 | + if (!is_null($reset)) { |
|
| 196 | + return $propre = $reset; |
|
| 197 | + } |
|
| 198 | + if ($done) { |
|
| 199 | + return $propre; |
|
| 200 | + } |
|
| 201 | + $done = true; |
|
| 202 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 204 | 203 | } |
| 205 | 204 | |
| 206 | 205 | /** |
@@ -215,36 +214,36 @@ discard block |
||
| 215 | 214 | * @return string |
| 216 | 215 | */ |
| 217 | 216 | function nettoyer_uri_var($request_uri) { |
| 218 | - static $preg_nettoyer; |
|
| 219 | - if (!defined('_CONTEXTE_IGNORE_LISTE_VARIABLES')) { |
|
| 220 | - /** @var array<string> Liste (regexp) de noms de variables à ignorer d’une URI */ |
|
| 221 | - define('_CONTEXTE_IGNORE_LISTE_VARIABLES', ['^var_', '^PHPSESSID$', '^fbclid$', '^utm_']); |
|
| 222 | - } |
|
| 223 | - if (empty($preg_nettoyer)) { |
|
| 224 | - $preg_nettoyer_vars = _CONTEXTE_IGNORE_LISTE_VARIABLES; |
|
| 225 | - foreach ($preg_nettoyer_vars as &$var) { |
|
| 226 | - if (str_starts_with($var, '^')) { |
|
| 227 | - $var = substr($var, 1); |
|
| 228 | - } else { |
|
| 229 | - $var = '[^=&]*' . $var; |
|
| 230 | - } |
|
| 231 | - if (str_ends_with($var, '$')) { |
|
| 232 | - $var = substr($var, 0, -1); |
|
| 233 | - } else { |
|
| 234 | - $var .= '[^=&]*'; |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - $preg_nettoyer = ',([?&])(' . implode('|', $preg_nettoyer_vars) . ')=[^&]*(&|$),i'; |
|
| 238 | - } |
|
| 239 | - if (empty($request_uri)) { |
|
| 240 | - return $request_uri; |
|
| 241 | - } |
|
| 242 | - $uri1 = $request_uri; |
|
| 243 | - do { |
|
| 244 | - $uri = $uri1; |
|
| 245 | - $uri1 = preg_replace($preg_nettoyer, '\1', $uri); |
|
| 246 | - } while ($uri <> $uri1); |
|
| 247 | - return rtrim($uri1, '?&'); |
|
| 217 | + static $preg_nettoyer; |
|
| 218 | + if (!defined('_CONTEXTE_IGNORE_LISTE_VARIABLES')) { |
|
| 219 | + /** @var array<string> Liste (regexp) de noms de variables à ignorer d’une URI */ |
|
| 220 | + define('_CONTEXTE_IGNORE_LISTE_VARIABLES', ['^var_', '^PHPSESSID$', '^fbclid$', '^utm_']); |
|
| 221 | + } |
|
| 222 | + if (empty($preg_nettoyer)) { |
|
| 223 | + $preg_nettoyer_vars = _CONTEXTE_IGNORE_LISTE_VARIABLES; |
|
| 224 | + foreach ($preg_nettoyer_vars as &$var) { |
|
| 225 | + if (str_starts_with($var, '^')) { |
|
| 226 | + $var = substr($var, 1); |
|
| 227 | + } else { |
|
| 228 | + $var = '[^=&]*' . $var; |
|
| 229 | + } |
|
| 230 | + if (str_ends_with($var, '$')) { |
|
| 231 | + $var = substr($var, 0, -1); |
|
| 232 | + } else { |
|
| 233 | + $var .= '[^=&]*'; |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + $preg_nettoyer = ',([?&])(' . implode('|', $preg_nettoyer_vars) . ')=[^&]*(&|$),i'; |
|
| 237 | + } |
|
| 238 | + if (empty($request_uri)) { |
|
| 239 | + return $request_uri; |
|
| 240 | + } |
|
| 241 | + $uri1 = $request_uri; |
|
| 242 | + do { |
|
| 243 | + $uri = $uri1; |
|
| 244 | + $uri1 = preg_replace($preg_nettoyer, '\1', $uri); |
|
| 245 | + } while ($uri <> $uri1); |
|
| 246 | + return rtrim($uri1, '?&'); |
|
| 248 | 247 | } |
| 249 | 248 | |
| 250 | 249 | |
@@ -258,49 +257,49 @@ discard block |
||
| 258 | 257 | * URL vers soi-même |
| 259 | 258 | **/ |
| 260 | 259 | function self($amp = '&', $root = false) { |
| 261 | - $url = nettoyer_uri(); |
|
| 262 | - if ( |
|
| 263 | - !$root |
|
| 264 | - && ( |
|
| 265 | - // si pas de profondeur on peut tronquer |
|
| 266 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 267 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 268 | - || defined('_SET_HTML_BASE') && !_SET_HTML_BASE |
|
| 269 | - ) |
|
| 270 | - ) { |
|
| 271 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 272 | - } |
|
| 273 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 274 | - foreach ($_POST as $v => $c) { |
|
| 275 | - if (str_starts_with($v, 'id_')) { |
|
| 276 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - // supprimer les variables sans interet |
|
| 281 | - if (test_espace_prive()) { |
|
| 282 | - $url = preg_replace(',([?&])(' |
|
| 283 | - . 'lang|show_docs|' |
|
| 284 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 285 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 286 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - // eviter les hacks |
|
| 290 | - include_spip('inc/filtres_mini'); |
|
| 291 | - $url = spip_htmlspecialchars($url); |
|
| 292 | - |
|
| 293 | - $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 294 | - |
|
| 295 | - // & ? |
|
| 296 | - if ($amp != '&') { |
|
| 297 | - $url = str_replace('&', $amp, $url); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - // Si ca demarre par ? ou vide, donner './' |
|
| 301 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 302 | - |
|
| 303 | - return $url; |
|
| 260 | + $url = nettoyer_uri(); |
|
| 261 | + if ( |
|
| 262 | + !$root |
|
| 263 | + && ( |
|
| 264 | + // si pas de profondeur on peut tronquer |
|
| 265 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 266 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 267 | + || defined('_SET_HTML_BASE') && !_SET_HTML_BASE |
|
| 268 | + ) |
|
| 269 | + ) { |
|
| 270 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 271 | + } |
|
| 272 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 273 | + foreach ($_POST as $v => $c) { |
|
| 274 | + if (str_starts_with($v, 'id_')) { |
|
| 275 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + // supprimer les variables sans interet |
|
| 280 | + if (test_espace_prive()) { |
|
| 281 | + $url = preg_replace(',([?&])(' |
|
| 282 | + . 'lang|show_docs|' |
|
| 283 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 284 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 285 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + // eviter les hacks |
|
| 289 | + include_spip('inc/filtres_mini'); |
|
| 290 | + $url = spip_htmlspecialchars($url); |
|
| 291 | + |
|
| 292 | + $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 293 | + |
|
| 294 | + // & ? |
|
| 295 | + if ($amp != '&') { |
|
| 296 | + $url = str_replace('&', $amp, $url); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + // Si ca demarre par ? ou vide, donner './' |
|
| 300 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 301 | + |
|
| 302 | + return $url; |
|
| 304 | 303 | } |
| 305 | 304 | |
| 306 | 305 | /** |
@@ -325,48 +324,48 @@ discard block |
||
| 325 | 324 | * url codee ou fonction de decodage |
| 326 | 325 | */ |
| 327 | 326 | function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string { |
| 328 | - if ($public === null) { |
|
| 329 | - $public = !test_espace_prive(); |
|
| 330 | - } |
|
| 331 | - $id = intval($id); |
|
| 332 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 333 | - |
|
| 334 | - if (!$public) { |
|
| 335 | - if (!$entite) { |
|
| 336 | - return ''; |
|
| 337 | - } |
|
| 338 | - if (!function_exists('generer_objet_url_ecrire')) { |
|
| 339 | - include_spip('inc/urls'); |
|
| 340 | - } |
|
| 341 | - $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect); |
|
| 342 | - } else { |
|
| 343 | - $f = charger_fonction_url('objet', $type ?? ''); |
|
| 344 | - |
|
| 345 | - // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 346 | - // @see charger_fonction_url |
|
| 347 | - if (!$entite) { |
|
| 348 | - return $f; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 352 | - // base distante |
|
| 353 | - if ( |
|
| 354 | - $connect |
|
| 355 | - && ($g = charger_fonction('connect', 'urls', true)) |
|
| 356 | - ) { |
|
| 357 | - $f = $g; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect); |
|
| 361 | - } |
|
| 362 | - if ($res) { |
|
| 363 | - return $res; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - // On a ete gentil mais la .... |
|
| 367 | - spip_logger()->error("generer_objet_url: entite $entite " . ($public ? "($f)" : '') . " inconnue $type $public $connect"); |
|
| 368 | - |
|
| 369 | - return ''; |
|
| 327 | + if ($public === null) { |
|
| 328 | + $public = !test_espace_prive(); |
|
| 329 | + } |
|
| 330 | + $id = intval($id); |
|
| 331 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 332 | + |
|
| 333 | + if (!$public) { |
|
| 334 | + if (!$entite) { |
|
| 335 | + return ''; |
|
| 336 | + } |
|
| 337 | + if (!function_exists('generer_objet_url_ecrire')) { |
|
| 338 | + include_spip('inc/urls'); |
|
| 339 | + } |
|
| 340 | + $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect); |
|
| 341 | + } else { |
|
| 342 | + $f = charger_fonction_url('objet', $type ?? ''); |
|
| 343 | + |
|
| 344 | + // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 345 | + // @see charger_fonction_url |
|
| 346 | + if (!$entite) { |
|
| 347 | + return $f; |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 351 | + // base distante |
|
| 352 | + if ( |
|
| 353 | + $connect |
|
| 354 | + && ($g = charger_fonction('connect', 'urls', true)) |
|
| 355 | + ) { |
|
| 356 | + $f = $g; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect); |
|
| 360 | + } |
|
| 361 | + if ($res) { |
|
| 362 | + return $res; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + // On a ete gentil mais la .... |
|
| 366 | + spip_logger()->error("generer_objet_url: entite $entite " . ($public ? "($f)" : '') . " inconnue $type $public $connect"); |
|
| 367 | + |
|
| 368 | + return ''; |
|
| 370 | 369 | } |
| 371 | 370 | |
| 372 | 371 | /** |
@@ -374,11 +373,11 @@ discard block |
||
| 374 | 373 | * @see generer_objet_url |
| 375 | 374 | */ |
| 376 | 375 | function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 377 | - trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url'); |
|
| 378 | - if ($public && is_string($public)) { |
|
| 379 | - return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
|
| 380 | - } |
|
| 381 | - return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? ''); |
|
| 376 | + trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url'); |
|
| 377 | + if ($public && is_string($public)) { |
|
| 378 | + return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
|
| 379 | + } |
|
| 380 | + return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? ''); |
|
| 382 | 381 | } |
| 383 | 382 | |
| 384 | 383 | /** |
@@ -386,19 +385,19 @@ discard block |
||
| 386 | 385 | * @param int|string|null $id |
| 387 | 386 | */ |
| 388 | 387 | function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string { |
| 389 | - $id = intval($id); |
|
| 390 | - $exec = objet_info($entite, 'url_edit'); |
|
| 391 | - $url = generer_url_ecrire($exec, $args); |
|
| 392 | - if (intval($id)) { |
|
| 393 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 394 | - } else { |
|
| 395 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 396 | - } |
|
| 397 | - if ($ancre) { |
|
| 398 | - $url = ancre_url($url, $ancre); |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - return $url; |
|
| 388 | + $id = intval($id); |
|
| 389 | + $exec = objet_info($entite, 'url_edit'); |
|
| 390 | + $url = generer_url_ecrire($exec, $args); |
|
| 391 | + if (intval($id)) { |
|
| 392 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 393 | + } else { |
|
| 394 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 395 | + } |
|
| 396 | + if ($ancre) { |
|
| 397 | + $url = ancre_url($url, $ancre); |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + return $url; |
|
| 402 | 401 | } |
| 403 | 402 | |
| 404 | 403 | /** |
@@ -406,19 +405,19 @@ discard block |
||
| 406 | 405 | * @see generer_objet_url_ecrire_edit |
| 407 | 406 | */ |
| 408 | 407 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 409 | - trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url_ecrire_edit'); |
|
| 410 | - return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
|
| 408 | + trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url_ecrire_edit'); |
|
| 409 | + return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
|
| 411 | 410 | } |
| 412 | 411 | |
| 413 | 412 | |
| 414 | 413 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 415 | - include_spip('base/connect_sql'); |
|
| 416 | - $id_type = id_table_objet($entite, $public); |
|
| 414 | + include_spip('base/connect_sql'); |
|
| 415 | + $id_type = id_table_objet($entite, $public); |
|
| 417 | 416 | |
| 418 | - return _DIR_RACINE . get_spip_script('./') |
|
| 419 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 420 | - . (!$args ? '' : "&$args") |
|
| 421 | - . (!$ancre ? '' : "#$ancre"); |
|
| 417 | + return _DIR_RACINE . get_spip_script('./') |
|
| 418 | + . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 419 | + . (!$args ? '' : "&$args") |
|
| 420 | + . (!$ancre ? '' : "#$ancre"); |
|
| 422 | 421 | } |
| 423 | 422 | |
| 424 | 423 | |
@@ -429,18 +428,18 @@ discard block |
||
| 429 | 428 | * @return string |
| 430 | 429 | */ |
| 431 | 430 | function urlencode_1738($url) { |
| 432 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 433 | - $uri = ''; |
|
| 434 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 435 | - if (ord($a = $url[$i]) > 127) { |
|
| 436 | - $a = rawurlencode($a); |
|
| 437 | - } |
|
| 438 | - $uri .= $a; |
|
| 439 | - } |
|
| 440 | - $url = $uri; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - return quote_amp($url); |
|
| 431 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 432 | + $uri = ''; |
|
| 433 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 434 | + if (ord($a = $url[$i]) > 127) { |
|
| 435 | + $a = rawurlencode($a); |
|
| 436 | + } |
|
| 437 | + $uri .= $a; |
|
| 438 | + } |
|
| 439 | + $url = $uri; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return quote_amp($url); |
|
| 444 | 443 | } |
| 445 | 444 | |
| 446 | 445 | /** |
@@ -449,14 +448,14 @@ discard block |
||
| 449 | 448 | * @param int|string|null $id |
| 450 | 449 | */ |
| 451 | 450 | function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string { |
| 452 | - $id = intval($id); |
|
| 453 | - $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect); |
|
| 454 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 455 | - include_spip('inc/filtres_mini'); |
|
| 456 | - $h = url_absolue($h); |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - return $h; |
|
| 451 | + $id = intval($id); |
|
| 452 | + $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect); |
|
| 453 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 454 | + include_spip('inc/filtres_mini'); |
|
| 455 | + $h = url_absolue($h); |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + return $h; |
|
| 460 | 459 | } |
| 461 | 460 | |
| 462 | 461 | /** |
@@ -464,8 +463,8 @@ discard block |
||
| 464 | 463 | * @see generer_objet_url_absolue |
| 465 | 464 | */ |
| 466 | 465 | function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) { |
| 467 | - trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url_absolue'); |
|
| 468 | - return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? ''); |
|
| 466 | + trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url_absolue'); |
|
| 467 | + return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? ''); |
|
| 469 | 468 | } |
| 470 | 469 | |
| 471 | 470 | |
@@ -494,89 +493,89 @@ discard block |
||
| 494 | 493 | */ |
| 495 | 494 | function url_de_base($profondeur = null) { |
| 496 | 495 | |
| 497 | - static $url = []; |
|
| 498 | - if (is_array($profondeur)) { |
|
| 499 | - return $url = $profondeur; |
|
| 500 | - } |
|
| 501 | - if ($profondeur === false) { |
|
| 502 | - return $url; |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - if (is_null($profondeur)) { |
|
| 506 | - $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - if (isset($url[$profondeur])) { |
|
| 510 | - return $url[$profondeur]; |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - $http = 'http'; |
|
| 514 | - |
|
| 515 | - if ( |
|
| 516 | - isset($_SERVER['SCRIPT_URI']) |
|
| 517 | - && str_starts_with($_SERVER['SCRIPT_URI'], 'https') |
|
| 518 | - ) { |
|
| 519 | - $http = 'https'; |
|
| 520 | - } elseif ( |
|
| 521 | - isset($_SERVER['HTTPS']) |
|
| 522 | - && test_valeur_serveur($_SERVER['HTTPS']) |
|
| 523 | - ) { |
|
| 524 | - $http = 'https'; |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 528 | - if ($host = $_SERVER['HTTP_HOST'] ?? null) { |
|
| 529 | - // Filtrer $host pour proteger d'attaques d'entete HTTP |
|
| 530 | - $host = (filter_var($host, FILTER_SANITIZE_URL) ?: null); |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 534 | - if (is_null($host) && isset($GLOBALS['meta']['adresse_site'])) { |
|
| 535 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 536 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 537 | - $http = $scheme; |
|
| 538 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 539 | - } |
|
| 540 | - } |
|
| 541 | - if ( |
|
| 542 | - isset($_SERVER['SERVER_PORT']) |
|
| 543 | - && ($port = $_SERVER['SERVER_PORT']) |
|
| 544 | - && !str_contains($host, ':') |
|
| 545 | - ) { |
|
| 546 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 547 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 548 | - } |
|
| 549 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 550 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 551 | - } |
|
| 552 | - if ($http == 'http' && !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 553 | - $host .= ":$port"; |
|
| 554 | - } |
|
| 555 | - if ($http == 'https' && !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 556 | - $host .= ":$port"; |
|
| 557 | - } |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 561 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 562 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 563 | - } else { |
|
| 564 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 565 | - if ( |
|
| 566 | - !empty($_SERVER['QUERY_STRING']) |
|
| 567 | - && !str_contains($_SERVER['REQUEST_URI'], '?') |
|
| 568 | - ) { |
|
| 569 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 570 | - } |
|
| 571 | - } |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - // Et nettoyer l'url |
|
| 575 | - $GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: ''); |
|
| 576 | - |
|
| 577 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 578 | - |
|
| 579 | - return $url[$profondeur]; |
|
| 496 | + static $url = []; |
|
| 497 | + if (is_array($profondeur)) { |
|
| 498 | + return $url = $profondeur; |
|
| 499 | + } |
|
| 500 | + if ($profondeur === false) { |
|
| 501 | + return $url; |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + if (is_null($profondeur)) { |
|
| 505 | + $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 506 | + } |
|
| 507 | + |
|
| 508 | + if (isset($url[$profondeur])) { |
|
| 509 | + return $url[$profondeur]; |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + $http = 'http'; |
|
| 513 | + |
|
| 514 | + if ( |
|
| 515 | + isset($_SERVER['SCRIPT_URI']) |
|
| 516 | + && str_starts_with($_SERVER['SCRIPT_URI'], 'https') |
|
| 517 | + ) { |
|
| 518 | + $http = 'https'; |
|
| 519 | + } elseif ( |
|
| 520 | + isset($_SERVER['HTTPS']) |
|
| 521 | + && test_valeur_serveur($_SERVER['HTTPS']) |
|
| 522 | + ) { |
|
| 523 | + $http = 'https'; |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 527 | + if ($host = $_SERVER['HTTP_HOST'] ?? null) { |
|
| 528 | + // Filtrer $host pour proteger d'attaques d'entete HTTP |
|
| 529 | + $host = (filter_var($host, FILTER_SANITIZE_URL) ?: null); |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 533 | + if (is_null($host) && isset($GLOBALS['meta']['adresse_site'])) { |
|
| 534 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 535 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 536 | + $http = $scheme; |
|
| 537 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 538 | + } |
|
| 539 | + } |
|
| 540 | + if ( |
|
| 541 | + isset($_SERVER['SERVER_PORT']) |
|
| 542 | + && ($port = $_SERVER['SERVER_PORT']) |
|
| 543 | + && !str_contains($host, ':') |
|
| 544 | + ) { |
|
| 545 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 546 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 547 | + } |
|
| 548 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 549 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 550 | + } |
|
| 551 | + if ($http == 'http' && !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 552 | + $host .= ":$port"; |
|
| 553 | + } |
|
| 554 | + if ($http == 'https' && !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 555 | + $host .= ":$port"; |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 560 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 561 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 562 | + } else { |
|
| 563 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 564 | + if ( |
|
| 565 | + !empty($_SERVER['QUERY_STRING']) |
|
| 566 | + && !str_contains($_SERVER['REQUEST_URI'], '?') |
|
| 567 | + ) { |
|
| 568 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + // Et nettoyer l'url |
|
| 574 | + $GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: ''); |
|
| 575 | + |
|
| 576 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 577 | + |
|
| 578 | + return $url[$profondeur]; |
|
| 580 | 579 | } |
| 581 | 580 | |
| 582 | 581 | /** |
@@ -589,26 +588,26 @@ discard block |
||
| 589 | 588 | * @return string |
| 590 | 589 | */ |
| 591 | 590 | function url_de_($http, $host, $request, $prof = 0) { |
| 592 | - $prof = max($prof, 0); |
|
| 593 | - |
|
| 594 | - $myself = ltrim($request, '/'); |
|
| 595 | - # supprimer la chaine de GET |
|
| 596 | - [$myself] = explode('?', $myself); |
|
| 597 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 598 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 599 | - if (str_contains($myself, '://')) { |
|
| 600 | - $myself = explode('://', $myself); |
|
| 601 | - array_shift($myself); |
|
| 602 | - $myself = implode('://', $myself); |
|
| 603 | - $myself = explode('/', $myself); |
|
| 604 | - array_shift($myself); |
|
| 605 | - $myself = implode('/', $myself); |
|
| 606 | - } |
|
| 607 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 608 | - |
|
| 609 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 610 | - |
|
| 611 | - return $url; |
|
| 591 | + $prof = max($prof, 0); |
|
| 592 | + |
|
| 593 | + $myself = ltrim($request, '/'); |
|
| 594 | + # supprimer la chaine de GET |
|
| 595 | + [$myself] = explode('?', $myself); |
|
| 596 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 597 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 598 | + if (str_contains($myself, '://')) { |
|
| 599 | + $myself = explode('://', $myself); |
|
| 600 | + array_shift($myself); |
|
| 601 | + $myself = implode('://', $myself); |
|
| 602 | + $myself = explode('/', $myself); |
|
| 603 | + array_shift($myself); |
|
| 604 | + $myself = implode('/', $myself); |
|
| 605 | + } |
|
| 606 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 607 | + |
|
| 608 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 609 | + |
|
| 610 | + return $url; |
|
| 612 | 611 | } |
| 613 | 612 | |
| 614 | 613 | |
@@ -643,26 +642,26 @@ discard block |
||
| 643 | 642 | * @return string URL |
| 644 | 643 | **/ |
| 645 | 644 | function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) { |
| 646 | - $script ??= ''; |
|
| 647 | - if (!$rel) { |
|
| 648 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 649 | - } else { |
|
| 650 | - if (!is_string($rel)) { |
|
| 651 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 652 | - } |
|
| 653 | - } |
|
| 654 | - |
|
| 655 | - [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 656 | - if ($script && ($script <> 'accueil' || $rel)) { |
|
| 657 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 658 | - } elseif ($args) { |
|
| 659 | - $args = "?$args"; |
|
| 660 | - } |
|
| 661 | - if ($ancre) { |
|
| 662 | - $args .= "#$ancre"; |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 645 | + $script ??= ''; |
|
| 646 | + if (!$rel) { |
|
| 647 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 648 | + } else { |
|
| 649 | + if (!is_string($rel)) { |
|
| 650 | + $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 655 | + if ($script && ($script <> 'accueil' || $rel)) { |
|
| 656 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 657 | + } elseif ($args) { |
|
| 658 | + $args = "?$args"; |
|
| 659 | + } |
|
| 660 | + if ($ancre) { |
|
| 661 | + $args .= "#$ancre"; |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 666 | 665 | } |
| 667 | 666 | |
| 668 | 667 | // |
@@ -684,15 +683,15 @@ discard block |
||
| 684 | 683 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 685 | 684 | **/ |
| 686 | 685 | function get_spip_script($default = '') { |
| 687 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 688 | - return 'spip.php'; |
|
| 689 | - } |
|
| 690 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 691 | - if (_SPIP_SCRIPT) { |
|
| 692 | - return _SPIP_SCRIPT; |
|
| 693 | - } else { |
|
| 694 | - return $default; |
|
| 695 | - } |
|
| 686 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 687 | + return 'spip.php'; |
|
| 688 | + } |
|
| 689 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 690 | + if (_SPIP_SCRIPT) { |
|
| 691 | + return _SPIP_SCRIPT; |
|
| 692 | + } else { |
|
| 693 | + return $default; |
|
| 694 | + } |
|
| 696 | 695 | } |
| 697 | 696 | |
| 698 | 697 | /** |
@@ -721,45 +720,45 @@ discard block |
||
| 721 | 720 | * @return string URL |
| 722 | 721 | **/ |
| 723 | 722 | function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') { |
| 724 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 725 | - // standardiser vers la nouvelle API |
|
| 726 | - |
|
| 727 | - if (is_array($args)) { |
|
| 728 | - $args = http_build_query($args); |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - $url = ''; |
|
| 732 | - if ($f = charger_fonction_url('page')) { |
|
| 733 | - $url = $f($script, $args); |
|
| 734 | - if ($url && !$rel) { |
|
| 735 | - include_spip('inc/filtres_mini'); |
|
| 736 | - $url = url_absolue($url); |
|
| 737 | - } |
|
| 738 | - } |
|
| 739 | - if (!$url) { |
|
| 740 | - if (!$action) { |
|
| 741 | - $action = get_spip_script(); |
|
| 742 | - } |
|
| 743 | - if ($script) { |
|
| 744 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 745 | - } |
|
| 746 | - if ($args) { |
|
| 747 | - $action .= (str_contains($action, '?') ? '&' : '?') . $args; |
|
| 748 | - } |
|
| 749 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 750 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - if (!$no_entities) { |
|
| 754 | - $url = quote_amp($url); |
|
| 755 | - } |
|
| 756 | - |
|
| 757 | - return $url; |
|
| 723 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 724 | + // standardiser vers la nouvelle API |
|
| 725 | + |
|
| 726 | + if (is_array($args)) { |
|
| 727 | + $args = http_build_query($args); |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + $url = ''; |
|
| 731 | + if ($f = charger_fonction_url('page')) { |
|
| 732 | + $url = $f($script, $args); |
|
| 733 | + if ($url && !$rel) { |
|
| 734 | + include_spip('inc/filtres_mini'); |
|
| 735 | + $url = url_absolue($url); |
|
| 736 | + } |
|
| 737 | + } |
|
| 738 | + if (!$url) { |
|
| 739 | + if (!$action) { |
|
| 740 | + $action = get_spip_script(); |
|
| 741 | + } |
|
| 742 | + if ($script) { |
|
| 743 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 744 | + } |
|
| 745 | + if ($args) { |
|
| 746 | + $action .= (str_contains($action, '?') ? '&' : '?') . $args; |
|
| 747 | + } |
|
| 748 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 749 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + if (!$no_entities) { |
|
| 753 | + $url = quote_amp($url); |
|
| 754 | + } |
|
| 755 | + |
|
| 756 | + return $url; |
|
| 758 | 757 | } |
| 759 | 758 | |
| 760 | 759 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 761 | 760 | |
| 762 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 761 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 763 | 762 | } |
| 764 | 763 | |
| 765 | 764 | |
@@ -779,22 +778,22 @@ discard block |
||
| 779 | 778 | * URL |
| 780 | 779 | */ |
| 781 | 780 | function generer_url_action($script, $args = '', $no_entities = false, $public = false) { |
| 782 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 783 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 784 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 785 | - $url = (_DIR_RACINE && !$public) |
|
| 786 | - ? generer_url_ecrire(_request('exec')) |
|
| 787 | - : generer_url_public('', '', false, false); |
|
| 788 | - $url = parametre_url($url, 'action', $script); |
|
| 789 | - if ($args) { |
|
| 790 | - $url .= quote_amp('&' . $args); |
|
| 791 | - } |
|
| 792 | - |
|
| 793 | - if ($no_entities) { |
|
| 794 | - $url = str_replace('&', '&', $url); |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - return $url; |
|
| 781 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 782 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 783 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 784 | + $url = (_DIR_RACINE && !$public) |
|
| 785 | + ? generer_url_ecrire(_request('exec')) |
|
| 786 | + : generer_url_public('', '', false, false); |
|
| 787 | + $url = parametre_url($url, 'action', $script); |
|
| 788 | + if ($args) { |
|
| 789 | + $url .= quote_amp('&' . $args); |
|
| 790 | + } |
|
| 791 | + |
|
| 792 | + if ($no_entities) { |
|
| 793 | + $url = str_replace('&', '&', $url); |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + return $url; |
|
| 798 | 797 | } |
| 799 | 798 | |
| 800 | 799 | |
@@ -813,21 +812,21 @@ discard block |
||
| 813 | 812 | * URL |
| 814 | 813 | */ |
| 815 | 814 | function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) { |
| 816 | - if (is_null($public)) { |
|
| 817 | - $public = (_DIR_RACINE ? false : true); |
|
| 818 | - } |
|
| 819 | - if (!str_ends_with($script, '.api')) { |
|
| 820 | - $script .= '.api'; |
|
| 821 | - } |
|
| 822 | - $url = |
|
| 823 | - (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
|
| 824 | - . $script . '/' |
|
| 825 | - . ($path ? trim($path, '/') : '') |
|
| 826 | - . ($args ? '?' . quote_amp($args) : ''); |
|
| 827 | - |
|
| 828 | - if ($no_entities) { |
|
| 829 | - $url = str_replace('&', '&', $url); |
|
| 830 | - } |
|
| 831 | - |
|
| 832 | - return $url; |
|
| 815 | + if (is_null($public)) { |
|
| 816 | + $public = (_DIR_RACINE ? false : true); |
|
| 817 | + } |
|
| 818 | + if (!str_ends_with($script, '.api')) { |
|
| 819 | + $script .= '.api'; |
|
| 820 | + } |
|
| 821 | + $url = |
|
| 822 | + (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
|
| 823 | + . $script . '/' |
|
| 824 | + . ($path ? trim($path, '/') : '') |
|
| 825 | + . ($args ? '?' . quote_amp($args) : ''); |
|
| 826 | + |
|
| 827 | + if ($no_entities) { |
|
| 828 | + $url = str_replace('&', '&', $url); |
|
| 829 | + } |
|
| 830 | + |
|
| 831 | + return $url; |
|
| 833 | 832 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | foreach ($regexp as $r => $e) { |
| 86 | 86 | $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e)); |
| 87 | 87 | } |
| 88 | - $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,'; |
|
| 88 | + $regexp = ',^('.implode('|', $regexp).'[[]?[]]?)(=.*)?$,'; |
|
| 89 | 89 | $ajouts = array_flip(explode('|', $c)); |
| 90 | 90 | $u = is_array($v) ? $v : rawurlencode((string) $v); |
| 91 | 91 | $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 113 | 113 | // pour un tableau ce sera fait dans la prochaine boucle |
| 114 | 114 | elseif (!str_ends_with($r[1], '[]')) { |
| 115 | - $url[$n] = $r[1] . '=' . $u; |
|
| 115 | + $url[$n] = $r[1].'='.$u; |
|
| 116 | 116 | unset($ajouts[$r[1]]); |
| 117 | 117 | } |
| 118 | 118 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | } elseif ($testv) { |
| 134 | 134 | foreach ($ajouts as $k => $n) { |
| 135 | 135 | if (!is_array($v)) { |
| 136 | - $url[] = $k . '=' . $u; |
|
| 136 | + $url[] = $k.'='.$u; |
|
| 137 | 137 | } else { |
| 138 | - $id = (str_ends_with($k, '[]')) ? $k : ($k . '[]'); |
|
| 138 | + $id = (str_ends_with($k, '[]')) ? $k : ($k.'[]'); |
|
| 139 | 139 | foreach ($v as $w) { |
| 140 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 140 | + $url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | // recomposer l'adresse |
| 150 | 150 | if ($url) { |
| 151 | - $a .= '?' . join($sep, $url); |
|
| 151 | + $a .= '?'.join($sep, $url); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - return $a . $ancre; |
|
| 154 | + return $a.$ancre; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | translitteration($ancre) |
| 182 | 182 | ); |
| 183 | 183 | } |
| 184 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 184 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | if (str_starts_with($var, '^')) { |
| 227 | 227 | $var = substr($var, 1); |
| 228 | 228 | } else { |
| 229 | - $var = '[^=&]*' . $var; |
|
| 229 | + $var = '[^=&]*'.$var; |
|
| 230 | 230 | } |
| 231 | 231 | if (str_ends_with($var, '$')) { |
| 232 | 232 | $var = substr($var, 0, -1); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $var .= '[^=&]*'; |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | - $preg_nettoyer = ',([?&])(' . implode('|', $preg_nettoyer_vars) . ')=[^&]*(&|$),i'; |
|
| 237 | + $preg_nettoyer = ',([?&])('.implode('|', $preg_nettoyer_vars).')=[^&]*(&|$),i'; |
|
| 238 | 238 | } |
| 239 | 239 | if (empty($request_uri)) { |
| 240 | 240 | return $request_uri; |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | // On a ete gentil mais la .... |
| 367 | - spip_logger()->error("generer_objet_url: entite $entite " . ($public ? "($f)" : '') . " inconnue $type $public $connect"); |
|
| 367 | + spip_logger()->error("generer_objet_url: entite $entite ".($public ? "($f)" : '')." inconnue $type $public $connect"); |
|
| 368 | 368 | |
| 369 | 369 | return ''; |
| 370 | 370 | } |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | include_spip('base/connect_sql'); |
| 416 | 416 | $id_type = id_table_objet($entite, $public); |
| 417 | 417 | |
| 418 | - return _DIR_RACINE . get_spip_script('./') |
|
| 419 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 418 | + return _DIR_RACINE.get_spip_script('./') |
|
| 419 | + . '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 420 | 420 | . (!$args ? '' : "&$args") |
| 421 | 421 | . (!$ancre ? '' : "#$ancre"); |
| 422 | 422 | } |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | !empty($_SERVER['QUERY_STRING']) |
| 567 | 567 | && !str_contains($_SERVER['REQUEST_URI'], '?') |
| 568 | 568 | ) { |
| 569 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 569 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | } |
@@ -604,9 +604,9 @@ discard block |
||
| 604 | 604 | array_shift($myself); |
| 605 | 605 | $myself = implode('/', $myself); |
| 606 | 606 | } |
| 607 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 607 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 608 | 608 | |
| 609 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 609 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 610 | 610 | |
| 611 | 611 | return $url; |
| 612 | 612 | } |
@@ -645,16 +645,16 @@ discard block |
||
| 645 | 645 | function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) { |
| 646 | 646 | $script ??= ''; |
| 647 | 647 | if (!$rel) { |
| 648 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 648 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 649 | 649 | } else { |
| 650 | 650 | if (!is_string($rel)) { |
| 651 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 651 | + $rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT; |
|
| 652 | 652 | } |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
| 656 | 656 | if ($script && ($script <> 'accueil' || $rel)) { |
| 657 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 657 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 658 | 658 | } elseif ($args) { |
| 659 | 659 | $args = "?$args"; |
| 660 | 660 | } |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | $args .= "#$ancre"; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 665 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | // |
@@ -744,10 +744,10 @@ discard block |
||
| 744 | 744 | $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
| 745 | 745 | } |
| 746 | 746 | if ($args) { |
| 747 | - $action .= (str_contains($action, '?') ? '&' : '?') . $args; |
|
| 747 | + $action .= (str_contains($action, '?') ? '&' : '?').$args; |
|
| 748 | 748 | } |
| 749 | 749 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 750 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 750 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | if (!$no_entities) { |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | |
| 760 | 760 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 761 | 761 | |
| 762 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 762 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | : generer_url_public('', '', false, false); |
| 788 | 788 | $url = parametre_url($url, 'action', $script); |
| 789 | 789 | if ($args) { |
| 790 | - $url .= quote_amp('&' . $args); |
|
| 790 | + $url .= quote_amp('&'.$args); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | if ($no_entities) { |
@@ -821,9 +821,9 @@ discard block |
||
| 821 | 821 | } |
| 822 | 822 | $url = |
| 823 | 823 | (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
| 824 | - . $script . '/' |
|
| 824 | + . $script.'/' |
|
| 825 | 825 | . ($path ? trim($path, '/') : '') |
| 826 | - . ($args ? '?' . quote_amp($args) : ''); |
|
| 826 | + . ($args ? '?'.quote_amp($args) : ''); |
|
| 827 | 827 | |
| 828 | 828 | if ($no_entities) { |
| 829 | 829 | $url = str_replace('&', '&', $url); |