@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -32,16 +32,16 @@ discard block |
||
| 32 | 32 | * @return array|bool|null |
| 33 | 33 | */ |
| 34 | 34 | function quete_virtuel($id_article, $connect) { |
| 35 | - return sql_getfetsel( |
|
| 36 | - 'virtuel', |
|
| 37 | - 'spip_articles', |
|
| 38 | - ['id_article=' . (int) $id_article, "statut='publie'"], |
|
| 39 | - '', |
|
| 40 | - '', |
|
| 41 | - '', |
|
| 42 | - '', |
|
| 43 | - $connect |
|
| 44 | - ); |
|
| 35 | + return sql_getfetsel( |
|
| 36 | + 'virtuel', |
|
| 37 | + 'spip_articles', |
|
| 38 | + ['id_article=' . (int) $id_article, "statut='publie'"], |
|
| 39 | + '', |
|
| 40 | + '', |
|
| 41 | + '', |
|
| 42 | + '', |
|
| 43 | + $connect |
|
| 44 | + ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -56,39 +56,39 @@ discard block |
||
| 56 | 56 | * @return array |
| 57 | 57 | */ |
| 58 | 58 | function quete_parent_lang($table, $id, string $connect = '') { |
| 59 | - static $cache_quete = []; |
|
| 60 | - |
|
| 61 | - if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 62 | - if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 63 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 64 | - if ( |
|
| 65 | - !($desc = $trouver_table($table, $connect)) |
|
| 66 | - || !isset($desc['field']['id_rubrique']) |
|
| 67 | - ) { |
|
| 68 | - // pas de parent rubrique, on passe |
|
| 69 | - $cache_quete[$connect][$table]['_select'] = false; |
|
| 70 | - } else { |
|
| 71 | - $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 72 | - $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 73 | - $cache_quete[$connect][$table]['_select'] = $select; |
|
| 74 | - $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - if ($cache_quete[$connect][$table]['_select']) { |
|
| 78 | - $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 79 | - $cache_quete[$connect][$table]['_select'], |
|
| 80 | - $table, |
|
| 81 | - $cache_quete[$connect][$table]['_id'] . '=' . (int) $id, |
|
| 82 | - '', |
|
| 83 | - '', |
|
| 84 | - '', |
|
| 85 | - '', |
|
| 86 | - $connect |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return $cache_quete[$connect][$table][$id] ?? null; |
|
| 59 | + static $cache_quete = []; |
|
| 60 | + |
|
| 61 | + if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 62 | + if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 63 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 64 | + if ( |
|
| 65 | + !($desc = $trouver_table($table, $connect)) |
|
| 66 | + || !isset($desc['field']['id_rubrique']) |
|
| 67 | + ) { |
|
| 68 | + // pas de parent rubrique, on passe |
|
| 69 | + $cache_quete[$connect][$table]['_select'] = false; |
|
| 70 | + } else { |
|
| 71 | + $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 72 | + $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 73 | + $cache_quete[$connect][$table]['_select'] = $select; |
|
| 74 | + $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + if ($cache_quete[$connect][$table]['_select']) { |
|
| 78 | + $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 79 | + $cache_quete[$connect][$table]['_select'], |
|
| 80 | + $table, |
|
| 81 | + $cache_quete[$connect][$table]['_id'] . '=' . (int) $id, |
|
| 82 | + '', |
|
| 83 | + '', |
|
| 84 | + '', |
|
| 85 | + '', |
|
| 86 | + $connect |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return $cache_quete[$connect][$table][$id] ?? null; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | * @return int |
| 106 | 106 | */ |
| 107 | 107 | function quete_parent($id_rubrique, string $connect = '') { |
| 108 | - if (!$id_rubrique = (int) $id_rubrique) { |
|
| 109 | - return 0; |
|
| 110 | - } |
|
| 111 | - $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 112 | - return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 108 | + if (!$id_rubrique = (int) $id_rubrique) { |
|
| 109 | + return 0; |
|
| 110 | + } |
|
| 111 | + $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 112 | + return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * @return int |
| 126 | 126 | */ |
| 127 | 127 | function quete_rubrique($id_article, $serveur) { |
| 128 | - $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 128 | + $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 129 | 129 | |
| 130 | - return $id_parent['id_rubrique'] ?? 0; |
|
| 130 | + return $id_parent['id_rubrique'] ?? 0; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | * @return int |
| 141 | 141 | */ |
| 142 | 142 | function quete_profondeur($id, string $connect = '') { |
| 143 | - $n = 0; |
|
| 144 | - while ($id) { |
|
| 145 | - $n++; |
|
| 146 | - $id = quete_parent($id, $connect); |
|
| 147 | - } |
|
| 143 | + $n = 0; |
|
| 144 | + while ($id) { |
|
| 145 | + $n++; |
|
| 146 | + $id = quete_parent($id, $connect); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - return $n; |
|
| 149 | + return $n; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
@@ -162,15 +162,15 @@ discard block |
||
| 162 | 162 | * Morceau de la requête SQL testant la date |
| 163 | 163 | */ |
| 164 | 164 | function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) { |
| 165 | - if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && !$ignore_previsu) { |
|
| 166 | - return '1=1'; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - return |
|
| 170 | - (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 171 | - && $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 172 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 173 | - : '1=1'; |
|
| 165 | + if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && !$ignore_previsu) { |
|
| 166 | + return '1=1'; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + return |
|
| 170 | + (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 171 | + && $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 172 | + ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 173 | + : '1=1'; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | |
@@ -190,101 +190,101 @@ discard block |
||
| 190 | 190 | * @return array|string |
| 191 | 191 | */ |
| 192 | 192 | function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) { |
| 193 | - static $cond = []; |
|
| 194 | - $key = func_get_args(); |
|
| 195 | - $key = implode('-', $key); |
|
| 196 | - if (isset($cond[$key])) { |
|
| 197 | - return $cond[$key]; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $liste_statuts = $publie; |
|
| 201 | - if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && !$ignore_previsu) { |
|
| 202 | - $liste_statuts = $previsu; |
|
| 203 | - } |
|
| 204 | - $not = false; |
|
| 205 | - if (str_starts_with($liste_statuts, '!')) { |
|
| 206 | - $not = true; |
|
| 207 | - $liste_statuts = substr($liste_statuts, 1); |
|
| 208 | - } |
|
| 209 | - // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 210 | - if (!strlen($liste_statuts)) { |
|
| 211 | - return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - $liste_statuts = explode(',', $liste_statuts); |
|
| 215 | - $where = []; |
|
| 216 | - foreach ($liste_statuts as $k => $v) { |
|
| 217 | - // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 218 | - // a ceux de l'auteur identifie |
|
| 219 | - if (str_contains($v, '/')) { |
|
| 220 | - $v = explode('/', $v); |
|
| 221 | - $filtre = end($v); |
|
| 222 | - $v = reset($v); |
|
| 223 | - $v = preg_replace(',\W,', '', $v); |
|
| 224 | - if ( |
|
| 225 | - $filtre == 'auteur' |
|
| 226 | - && str_contains($mstatut, '.') |
|
| 227 | - && ($objet = explode('.', $mstatut)) |
|
| 228 | - && ($id_table = reset($objet)) |
|
| 229 | - && ($objet = objet_type($id_table)) |
|
| 230 | - ) { |
|
| 231 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 232 | - |
|
| 233 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 234 | - // sinon l’auteur en session |
|
| 235 | - include_spip('inc/securiser_action'); |
|
| 236 | - if ($desc = decrire_token_previsu()) { |
|
| 237 | - $id_auteur = $desc['id_auteur']; |
|
| 238 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 239 | - $id_auteur = (int) $GLOBALS['visiteur_session']['id_auteur']; |
|
| 240 | - } else { |
|
| 241 | - $id_auteur = null; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 245 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 246 | - // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 247 | - if (!$id_auteur) { |
|
| 248 | - $where[] = $w; |
|
| 249 | - } else { |
|
| 250 | - $primary = id_table_objet($objet); |
|
| 251 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 252 | - 'ssss.id_objet', |
|
| 253 | - 'spip_auteurs_liens AS ssss', |
|
| 254 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . (int) $id_auteur, |
|
| 255 | - '', |
|
| 256 | - '', |
|
| 257 | - '', |
|
| 258 | - '', |
|
| 259 | - $serveur |
|
| 260 | - ) . '))'; |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 264 | - else { |
|
| 265 | - $v = ''; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - // securite |
|
| 269 | - $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 270 | - } |
|
| 271 | - $liste_statuts = array_filter($liste_statuts); |
|
| 272 | - if (count($liste_statuts) == 1) { |
|
| 273 | - $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 274 | - } else { |
|
| 275 | - $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - while (count($where) > 1) { |
|
| 279 | - $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 280 | - $where[] = $and; |
|
| 281 | - } |
|
| 282 | - $cond[$key] = reset($where); |
|
| 283 | - if ($not) { |
|
| 284 | - $cond[$key] = ['NOT', $cond[$key]]; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - return $cond[$key]; |
|
| 193 | + static $cond = []; |
|
| 194 | + $key = func_get_args(); |
|
| 195 | + $key = implode('-', $key); |
|
| 196 | + if (isset($cond[$key])) { |
|
| 197 | + return $cond[$key]; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $liste_statuts = $publie; |
|
| 201 | + if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && !$ignore_previsu) { |
|
| 202 | + $liste_statuts = $previsu; |
|
| 203 | + } |
|
| 204 | + $not = false; |
|
| 205 | + if (str_starts_with($liste_statuts, '!')) { |
|
| 206 | + $not = true; |
|
| 207 | + $liste_statuts = substr($liste_statuts, 1); |
|
| 208 | + } |
|
| 209 | + // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 210 | + if (!strlen($liste_statuts)) { |
|
| 211 | + return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + $liste_statuts = explode(',', $liste_statuts); |
|
| 215 | + $where = []; |
|
| 216 | + foreach ($liste_statuts as $k => $v) { |
|
| 217 | + // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 218 | + // a ceux de l'auteur identifie |
|
| 219 | + if (str_contains($v, '/')) { |
|
| 220 | + $v = explode('/', $v); |
|
| 221 | + $filtre = end($v); |
|
| 222 | + $v = reset($v); |
|
| 223 | + $v = preg_replace(',\W,', '', $v); |
|
| 224 | + if ( |
|
| 225 | + $filtre == 'auteur' |
|
| 226 | + && str_contains($mstatut, '.') |
|
| 227 | + && ($objet = explode('.', $mstatut)) |
|
| 228 | + && ($id_table = reset($objet)) |
|
| 229 | + && ($objet = objet_type($id_table)) |
|
| 230 | + ) { |
|
| 231 | + $w = "$mstatut<>" . sql_quote($v); |
|
| 232 | + |
|
| 233 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 234 | + // sinon l’auteur en session |
|
| 235 | + include_spip('inc/securiser_action'); |
|
| 236 | + if ($desc = decrire_token_previsu()) { |
|
| 237 | + $id_auteur = $desc['id_auteur']; |
|
| 238 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 239 | + $id_auteur = (int) $GLOBALS['visiteur_session']['id_auteur']; |
|
| 240 | + } else { |
|
| 241 | + $id_auteur = null; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 245 | + if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 246 | + // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 247 | + if (!$id_auteur) { |
|
| 248 | + $where[] = $w; |
|
| 249 | + } else { |
|
| 250 | + $primary = id_table_objet($objet); |
|
| 251 | + $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 252 | + 'ssss.id_objet', |
|
| 253 | + 'spip_auteurs_liens AS ssss', |
|
| 254 | + 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . (int) $id_auteur, |
|
| 255 | + '', |
|
| 256 | + '', |
|
| 257 | + '', |
|
| 258 | + '', |
|
| 259 | + $serveur |
|
| 260 | + ) . '))'; |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 264 | + else { |
|
| 265 | + $v = ''; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + // securite |
|
| 269 | + $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 270 | + } |
|
| 271 | + $liste_statuts = array_filter($liste_statuts); |
|
| 272 | + if (count($liste_statuts) == 1) { |
|
| 273 | + $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 274 | + } else { |
|
| 275 | + $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + while (count($where) > 1) { |
|
| 279 | + $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 280 | + $where[] = $and; |
|
| 281 | + } |
|
| 282 | + $cond[$key] = reset($where); |
|
| 283 | + if ($not) { |
|
| 284 | + $cond[$key] = ['NOT', $cond[$key]]; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + return $cond[$key]; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @return array|bool|null |
| 296 | 296 | */ |
| 297 | 297 | function quete_fichier($id_document, $serveur = '') { |
| 298 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 298 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @return array|bool |
| 307 | 307 | */ |
| 308 | 308 | function quete_document($id_document, $serveur = '') { |
| 309 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 309 | + return sql_fetsel('*', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return array|bool|null |
| 318 | 318 | */ |
| 319 | 319 | function quete_meta($nom, $serveur) { |
| 320 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 320 | + return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -343,67 +343,67 @@ discard block |
||
| 343 | 343 | * Retourne soit un tableau, soit le chemin du fichier. |
| 344 | 344 | */ |
| 345 | 345 | function quete_logo($cle_objet, $onoff, $id, $id_rubrique, $flag = false) { |
| 346 | - include_spip('base/objets'); |
|
| 347 | - $nom = strtolower($onoff); |
|
| 348 | - |
|
| 349 | - $cle_objet = id_table_objet($cle_objet); |
|
| 350 | - |
|
| 351 | - while (1) { |
|
| 352 | - $objet = objet_type($cle_objet); |
|
| 353 | - |
|
| 354 | - $on = quete_logo_objet($id, $objet, $nom); |
|
| 355 | - |
|
| 356 | - if ($on) { |
|
| 357 | - if ($flag) { |
|
| 358 | - return $on['fichier']; |
|
| 359 | - } else { |
|
| 360 | - $taille = @spip_getimagesize($on['chemin']); |
|
| 361 | - |
|
| 362 | - // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 363 | - // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 364 | - // alors on ne cherche pas du tout le survol ici |
|
| 365 | - $off = $onoff != 'ON' ? '' : quete_logo_objet($id, $objet, 'off'); |
|
| 366 | - |
|
| 367 | - // on retourne une url du type IMG/artonXX?timestamp |
|
| 368 | - // qui permet de distinguer le changement de logo |
|
| 369 | - // et placer un expire sur le dossier IMG/ |
|
| 370 | - $res = [ |
|
| 371 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 372 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 373 | - ($taille ? ' ' . $taille[3] : ('')) |
|
| 374 | - ]; |
|
| 375 | - $res['src'] = $res[0]; |
|
| 376 | - $res['logo_on'] = $res[0]; |
|
| 377 | - $res['logo_off'] = $res[1]; |
|
| 378 | - $res['width'] = ($taille ? $taille[0] : ''); |
|
| 379 | - $res['height'] = ($taille ? $taille[1] : ''); |
|
| 380 | - $res['fichier'] = $on['fichier']; |
|
| 381 | - $res['titre'] = ($on['titre'] ?? ''); |
|
| 382 | - $res['descriptif'] = ($on['descriptif'] ?? ''); |
|
| 383 | - $res['credits'] = ($on['credits'] ?? ''); |
|
| 384 | - $res['alt'] = ($on['alt'] ?? ''); |
|
| 385 | - $res['id'] = ($on['id_document'] ?? 0); |
|
| 386 | - |
|
| 387 | - return $res; |
|
| 388 | - } |
|
| 389 | - } else { |
|
| 390 | - if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 391 | - return ''; |
|
| 392 | - } else { |
|
| 393 | - if ($id_rubrique) { |
|
| 394 | - $cle_objet = 'id_rubrique'; |
|
| 395 | - $id = $id_rubrique; |
|
| 396 | - $id_rubrique = 0; |
|
| 397 | - } else { |
|
| 398 | - if ($id && $cle_objet == 'id_rubrique') { |
|
| 399 | - $id = quete_parent($id); |
|
| 400 | - } else { |
|
| 401 | - return ''; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - } |
|
| 346 | + include_spip('base/objets'); |
|
| 347 | + $nom = strtolower($onoff); |
|
| 348 | + |
|
| 349 | + $cle_objet = id_table_objet($cle_objet); |
|
| 350 | + |
|
| 351 | + while (1) { |
|
| 352 | + $objet = objet_type($cle_objet); |
|
| 353 | + |
|
| 354 | + $on = quete_logo_objet($id, $objet, $nom); |
|
| 355 | + |
|
| 356 | + if ($on) { |
|
| 357 | + if ($flag) { |
|
| 358 | + return $on['fichier']; |
|
| 359 | + } else { |
|
| 360 | + $taille = @spip_getimagesize($on['chemin']); |
|
| 361 | + |
|
| 362 | + // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 363 | + // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 364 | + // alors on ne cherche pas du tout le survol ici |
|
| 365 | + $off = $onoff != 'ON' ? '' : quete_logo_objet($id, $objet, 'off'); |
|
| 366 | + |
|
| 367 | + // on retourne une url du type IMG/artonXX?timestamp |
|
| 368 | + // qui permet de distinguer le changement de logo |
|
| 369 | + // et placer un expire sur le dossier IMG/ |
|
| 370 | + $res = [ |
|
| 371 | + $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 372 | + ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 373 | + ($taille ? ' ' . $taille[3] : ('')) |
|
| 374 | + ]; |
|
| 375 | + $res['src'] = $res[0]; |
|
| 376 | + $res['logo_on'] = $res[0]; |
|
| 377 | + $res['logo_off'] = $res[1]; |
|
| 378 | + $res['width'] = ($taille ? $taille[0] : ''); |
|
| 379 | + $res['height'] = ($taille ? $taille[1] : ''); |
|
| 380 | + $res['fichier'] = $on['fichier']; |
|
| 381 | + $res['titre'] = ($on['titre'] ?? ''); |
|
| 382 | + $res['descriptif'] = ($on['descriptif'] ?? ''); |
|
| 383 | + $res['credits'] = ($on['credits'] ?? ''); |
|
| 384 | + $res['alt'] = ($on['alt'] ?? ''); |
|
| 385 | + $res['id'] = ($on['id_document'] ?? 0); |
|
| 386 | + |
|
| 387 | + return $res; |
|
| 388 | + } |
|
| 389 | + } else { |
|
| 390 | + if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 391 | + return ''; |
|
| 392 | + } else { |
|
| 393 | + if ($id_rubrique) { |
|
| 394 | + $cle_objet = 'id_rubrique'; |
|
| 395 | + $id = $id_rubrique; |
|
| 396 | + $id_rubrique = 0; |
|
| 397 | + } else { |
|
| 398 | + if ($id && $cle_objet == 'id_rubrique') { |
|
| 399 | + $id = quete_parent($id); |
|
| 400 | + } else { |
|
| 401 | + return ''; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -418,43 +418,43 @@ discard block |
||
| 418 | 418 | * @return bool|array |
| 419 | 419 | **/ |
| 420 | 420 | function quete_logo_objet($id_objet, $objet, $mode) { |
| 421 | - static $chercher_logo; |
|
| 422 | - if (is_null($chercher_logo)) { |
|
| 423 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 424 | - } |
|
| 425 | - $cle_objet = id_table_objet($objet); |
|
| 426 | - |
|
| 427 | - // On cherche pas la méthode classique |
|
| 428 | - $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 429 | - |
|
| 430 | - // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 431 | - if (!empty($infos_logo)) { |
|
| 432 | - $infos = [ |
|
| 433 | - 'chemin' => $infos_logo[0], |
|
| 434 | - 'timestamp' => $infos_logo[4], |
|
| 435 | - 'id_document' => ($infos_logo[5]['id_document'] ?? ''), |
|
| 436 | - ]; |
|
| 437 | - foreach (['fichier', 'titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 438 | - $infos[$champ] = ($infos_logo[5][$champ] ?? ''); |
|
| 439 | - } |
|
| 440 | - $infos_logo = $infos; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - // On passe cette recherche de logo dans un pipeline |
|
| 444 | - $infos_logo = pipeline( |
|
| 445 | - 'quete_logo_objet', |
|
| 446 | - [ |
|
| 447 | - 'args' => [ |
|
| 448 | - 'id_objet' => $id_objet, |
|
| 449 | - 'objet' => $objet, |
|
| 450 | - 'cle_objet' => $cle_objet, |
|
| 451 | - 'mode' => $mode, |
|
| 452 | - ], |
|
| 453 | - 'data' => $infos_logo, |
|
| 454 | - ] |
|
| 455 | - ); |
|
| 456 | - |
|
| 457 | - return $infos_logo; |
|
| 421 | + static $chercher_logo; |
|
| 422 | + if (is_null($chercher_logo)) { |
|
| 423 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 424 | + } |
|
| 425 | + $cle_objet = id_table_objet($objet); |
|
| 426 | + |
|
| 427 | + // On cherche pas la méthode classique |
|
| 428 | + $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 429 | + |
|
| 430 | + // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 431 | + if (!empty($infos_logo)) { |
|
| 432 | + $infos = [ |
|
| 433 | + 'chemin' => $infos_logo[0], |
|
| 434 | + 'timestamp' => $infos_logo[4], |
|
| 435 | + 'id_document' => ($infos_logo[5]['id_document'] ?? ''), |
|
| 436 | + ]; |
|
| 437 | + foreach (['fichier', 'titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 438 | + $infos[$champ] = ($infos_logo[5][$champ] ?? ''); |
|
| 439 | + } |
|
| 440 | + $infos_logo = $infos; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + // On passe cette recherche de logo dans un pipeline |
|
| 444 | + $infos_logo = pipeline( |
|
| 445 | + 'quete_logo_objet', |
|
| 446 | + [ |
|
| 447 | + 'args' => [ |
|
| 448 | + 'id_objet' => $id_objet, |
|
| 449 | + 'objet' => $objet, |
|
| 450 | + 'cle_objet' => $cle_objet, |
|
| 451 | + 'mode' => $mode, |
|
| 452 | + ], |
|
| 453 | + 'data' => $infos_logo, |
|
| 454 | + ] |
|
| 455 | + ); |
|
| 456 | + |
|
| 457 | + return $infos_logo; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /** |
@@ -467,25 +467,25 @@ discard block |
||
| 467 | 467 | * @return bool|string |
| 468 | 468 | */ |
| 469 | 469 | function quete_logo_file($row, $connect = null) { |
| 470 | - include_spip('inc/documents'); |
|
| 471 | - $logo = vignette_logo_document($row, $connect); |
|
| 472 | - if (!$logo) { |
|
| 473 | - $logo = image_du_document($row, $connect); |
|
| 474 | - } |
|
| 475 | - if (!$logo) { |
|
| 476 | - $f = charger_fonction('vignette', 'inc'); |
|
| 477 | - $logo = $f($row['extension'], false); |
|
| 478 | - } |
|
| 479 | - // si c'est une vignette type doc, la renvoyer direct |
|
| 480 | - if ( |
|
| 481 | - strcmp((string) $logo, (string) _DIR_PLUGINS) == 0 |
|
| 482 | - || strcmp((string) $logo, (string) _DIR_PLUGINS_DIST) == 0 |
|
| 483 | - || strcmp((string) $logo, _DIR_RACINE . 'prive/') == 0 |
|
| 484 | - ) { |
|
| 485 | - return $logo; |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - return get_spip_doc($logo); |
|
| 470 | + include_spip('inc/documents'); |
|
| 471 | + $logo = vignette_logo_document($row, $connect); |
|
| 472 | + if (!$logo) { |
|
| 473 | + $logo = image_du_document($row, $connect); |
|
| 474 | + } |
|
| 475 | + if (!$logo) { |
|
| 476 | + $f = charger_fonction('vignette', 'inc'); |
|
| 477 | + $logo = $f($row['extension'], false); |
|
| 478 | + } |
|
| 479 | + // si c'est une vignette type doc, la renvoyer direct |
|
| 480 | + if ( |
|
| 481 | + strcmp((string) $logo, (string) _DIR_PLUGINS) == 0 |
|
| 482 | + || strcmp((string) $logo, (string) _DIR_PLUGINS_DIST) == 0 |
|
| 483 | + || strcmp((string) $logo, _DIR_RACINE . 'prive/') == 0 |
|
| 484 | + ) { |
|
| 485 | + return $logo; |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + return get_spip_doc($logo); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -513,20 +513,20 @@ discard block |
||
| 513 | 513 | */ |
| 514 | 514 | function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, string $connect = '') { |
| 515 | 515 | |
| 516 | - include_spip('inc/documents'); |
|
| 517 | - $logo = ''; |
|
| 518 | - if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 519 | - $logo = vignette_logo_document($row, $connect); |
|
| 520 | - } |
|
| 521 | - // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 522 | - if ($mode_logo == 'vignette' && !$logo) { |
|
| 523 | - return ''; |
|
| 524 | - } |
|
| 525 | - if ($mode_logo == 'icone') { |
|
| 526 | - $row['fichier'] = ''; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 516 | + include_spip('inc/documents'); |
|
| 517 | + $logo = ''; |
|
| 518 | + if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 519 | + $logo = vignette_logo_document($row, $connect); |
|
| 520 | + } |
|
| 521 | + // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 522 | + if ($mode_logo == 'vignette' && !$logo) { |
|
| 523 | + return ''; |
|
| 524 | + } |
|
| 525 | + if ($mode_logo == 'icone') { |
|
| 526 | + $row['fichier'] = ''; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -538,26 +538,26 @@ discard block |
||
| 538 | 538 | */ |
| 539 | 539 | function quete_html_logo($logo, $align, $lien) { |
| 540 | 540 | |
| 541 | - if (!is_array($logo)) { |
|
| 542 | - return ''; |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - $contexte = []; |
|
| 546 | - foreach ($logo as $k => $v) { |
|
| 547 | - if (!is_numeric($k)) { |
|
| 548 | - $contexte[$k] = $v; |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - foreach (['titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 553 | - if (!empty($contexte[$champ])) { |
|
| 554 | - $contexte[$champ] = appliquer_traitement_champ($contexte[$champ], $champ, 'document'); |
|
| 555 | - } |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - $contexte['align'] = $align; |
|
| 559 | - $contexte['lien'] = $lien; |
|
| 560 | - return recuperer_fond('modeles/logo', $contexte); |
|
| 541 | + if (!is_array($logo)) { |
|
| 542 | + return ''; |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + $contexte = []; |
|
| 546 | + foreach ($logo as $k => $v) { |
|
| 547 | + if (!is_numeric($k)) { |
|
| 548 | + $contexte[$k] = $v; |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + foreach (['titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 553 | + if (!empty($contexte[$champ])) { |
|
| 554 | + $contexte[$champ] = appliquer_traitement_champ($contexte[$champ], $champ, 'document'); |
|
| 555 | + } |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + $contexte['align'] = $align; |
|
| 559 | + $contexte['lien'] = $lien; |
|
| 560 | + return recuperer_fond('modeles/logo', $contexte); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
@@ -571,14 +571,14 @@ discard block |
||
| 571 | 571 | * @return string|false |
| 572 | 572 | */ |
| 573 | 573 | function document_spip_externe($fichier, $connect) { |
| 574 | - if ($connect) { |
|
| 575 | - $site = quete_meta('adresse_site', $connect); |
|
| 576 | - if ($site) { |
|
| 577 | - $dir = quete_meta('dir_img', $connect); |
|
| 578 | - return "$site/$dir$fichier"; |
|
| 579 | - } |
|
| 580 | - } |
|
| 581 | - return false; |
|
| 574 | + if ($connect) { |
|
| 575 | + $site = quete_meta('adresse_site', $connect); |
|
| 576 | + if ($site) { |
|
| 577 | + $dir = quete_meta('dir_img', $connect); |
|
| 578 | + return "$site/$dir$fichier"; |
|
| 579 | + } |
|
| 580 | + } |
|
| 581 | + return false; |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -591,23 +591,23 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | function vignette_logo_document($row, string $connect = '') { |
| 593 | 593 | |
| 594 | - if (!$row || empty($row['id_vignette'])) { |
|
| 595 | - return ''; |
|
| 596 | - } |
|
| 597 | - $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 598 | - if ($url = document_spip_externe($fichier, $connect)) { |
|
| 599 | - return $url; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - $f = get_spip_doc($fichier); |
|
| 603 | - if ($f && @file_exists($f)) { |
|
| 604 | - return $f; |
|
| 605 | - } |
|
| 606 | - if ($row['mode'] !== 'vignette') { |
|
| 607 | - return ''; |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - return generer_objet_url($row['id_document'], 'document', '', '', null, '', $connect); |
|
| 594 | + if (!$row || empty($row['id_vignette'])) { |
|
| 595 | + return ''; |
|
| 596 | + } |
|
| 597 | + $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 598 | + if ($url = document_spip_externe($fichier, $connect)) { |
|
| 599 | + return $url; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + $f = get_spip_doc($fichier); |
|
| 603 | + if ($f && @file_exists($f)) { |
|
| 604 | + return $f; |
|
| 605 | + } |
|
| 606 | + if ($row['mode'] !== 'vignette') { |
|
| 607 | + return ''; |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + return generer_objet_url($row['id_document'], 'document', '', '', null, '', $connect); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -622,66 +622,66 @@ discard block |
||
| 622 | 622 | * @return bool|string |
| 623 | 623 | */ |
| 624 | 624 | function calcul_exposer($id, $prim, $reference, $parent, $type, string $connect = '') { |
| 625 | - static $exposer = []; |
|
| 626 | - |
|
| 627 | - // Que faut-il exposer ? Tous les elements de $reference |
|
| 628 | - // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 629 | - // qu'une fois (par squelette) et on conserve le resultat |
|
| 630 | - // en static. |
|
| 631 | - if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 632 | - $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 633 | - // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 634 | - // il n'est donc pas utile |
|
| 635 | - $parent = 0; |
|
| 636 | - if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 637 | - $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 638 | - if (isset($enfants[$type])) { |
|
| 639 | - foreach ($enfants[$type] as $t) { |
|
| 640 | - if ( |
|
| 641 | - isset($reference[$t]) |
|
| 642 | - // cas de la reference donnee dynamiquement par la pagination |
|
| 643 | - || isset($reference["@$t"]) |
|
| 644 | - ) { |
|
| 645 | - $type = $t; |
|
| 646 | - $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 647 | - continue; |
|
| 648 | - } |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - $exposer[$m][$type] = []; |
|
| 653 | - if ($principal) { |
|
| 654 | - $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 655 | - foreach ($principaux as $principal) { |
|
| 656 | - $exposer[$m][$type][$principal] = true; |
|
| 657 | - if ($type == 'id_mot') { |
|
| 658 | - if (!$parent) { |
|
| 659 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . (int) $principal, '', '', '', '', $connect); |
|
| 660 | - } |
|
| 661 | - if ($parent) { |
|
| 662 | - $exposer[$m]['id_groupe'][$parent] = true; |
|
| 663 | - } |
|
| 664 | - } else { |
|
| 665 | - if ($type != 'id_groupe') { |
|
| 666 | - if (!$parent) { |
|
| 667 | - if ($type == 'id_rubrique') { |
|
| 668 | - $parent = $principal; |
|
| 669 | - } |
|
| 670 | - if ($type == 'id_article') { |
|
| 671 | - $parent = quete_rubrique($principal, $connect); |
|
| 672 | - } |
|
| 673 | - } |
|
| 674 | - do { |
|
| 675 | - $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 676 | - } while ($parent = quete_parent($parent, $connect)); |
|
| 677 | - } |
|
| 678 | - } |
|
| 679 | - } |
|
| 680 | - } |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - // And the winner is... |
|
| 684 | - return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 625 | + static $exposer = []; |
|
| 626 | + |
|
| 627 | + // Que faut-il exposer ? Tous les elements de $reference |
|
| 628 | + // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 629 | + // qu'une fois (par squelette) et on conserve le resultat |
|
| 630 | + // en static. |
|
| 631 | + if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 632 | + $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 633 | + // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 634 | + // il n'est donc pas utile |
|
| 635 | + $parent = 0; |
|
| 636 | + if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 637 | + $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 638 | + if (isset($enfants[$type])) { |
|
| 639 | + foreach ($enfants[$type] as $t) { |
|
| 640 | + if ( |
|
| 641 | + isset($reference[$t]) |
|
| 642 | + // cas de la reference donnee dynamiquement par la pagination |
|
| 643 | + || isset($reference["@$t"]) |
|
| 644 | + ) { |
|
| 645 | + $type = $t; |
|
| 646 | + $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 647 | + continue; |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + $exposer[$m][$type] = []; |
|
| 653 | + if ($principal) { |
|
| 654 | + $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 655 | + foreach ($principaux as $principal) { |
|
| 656 | + $exposer[$m][$type][$principal] = true; |
|
| 657 | + if ($type == 'id_mot') { |
|
| 658 | + if (!$parent) { |
|
| 659 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . (int) $principal, '', '', '', '', $connect); |
|
| 660 | + } |
|
| 661 | + if ($parent) { |
|
| 662 | + $exposer[$m]['id_groupe'][$parent] = true; |
|
| 663 | + } |
|
| 664 | + } else { |
|
| 665 | + if ($type != 'id_groupe') { |
|
| 666 | + if (!$parent) { |
|
| 667 | + if ($type == 'id_rubrique') { |
|
| 668 | + $parent = $principal; |
|
| 669 | + } |
|
| 670 | + if ($type == 'id_article') { |
|
| 671 | + $parent = quete_rubrique($principal, $connect); |
|
| 672 | + } |
|
| 673 | + } |
|
| 674 | + do { |
|
| 675 | + $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 676 | + } while ($parent = quete_parent($parent, $connect)); |
|
| 677 | + } |
|
| 678 | + } |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | + |
|
| 683 | + // And the winner is... |
|
| 684 | + return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -696,23 +696,23 @@ discard block |
||
| 696 | 696 | * @return int |
| 697 | 697 | */ |
| 698 | 698 | function quete_debut_pagination($primary, $valeur, $pas, $iter) { |
| 699 | - // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 700 | - // ou composee, mais verifions |
|
| 701 | - if (!$primary || preg_match('/[,\s]/', $primary)) { |
|
| 702 | - return 0; |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - $pos = 0; |
|
| 706 | - while (($row = $iter->fetch()) && $row[$primary] != $valeur) { |
|
| 707 | - $pos++; |
|
| 708 | - } |
|
| 709 | - // si on a pas trouve |
|
| 710 | - if (!$row || $row[$primary] != $valeur) { |
|
| 711 | - return 0; |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - // sinon, calculer le bon numero de page |
|
| 715 | - return floor($pos / $pas) * $pas; |
|
| 699 | + // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 700 | + // ou composee, mais verifions |
|
| 701 | + if (!$primary || preg_match('/[,\s]/', $primary)) { |
|
| 702 | + return 0; |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + $pos = 0; |
|
| 706 | + while (($row = $iter->fetch()) && $row[$primary] != $valeur) { |
|
| 707 | + $pos++; |
|
| 708 | + } |
|
| 709 | + // si on a pas trouve |
|
| 710 | + if (!$row || $row[$primary] != $valeur) { |
|
| 711 | + return 0; |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + // sinon, calculer le bon numero de page |
|
| 715 | + return floor($pos / $pas) * $pas; |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /** |
@@ -722,8 +722,8 @@ discard block |
||
| 722 | 722 | * @return boolean |
| 723 | 723 | */ |
| 724 | 724 | function is_whereable(mixed $value): bool { |
| 725 | - if (is_array($value) && count($value)) { |
|
| 726 | - return true; |
|
| 727 | - } |
|
| 728 | - return is_scalar($value) && strlen($value); |
|
| 725 | + if (is_array($value) && count($value)) { |
|
| 726 | + return true; |
|
| 727 | + } |
|
| 728 | + return is_scalar($value) && strlen($value); |
|
| 729 | 729 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | return sql_getfetsel( |
| 36 | 36 | 'virtuel', |
| 37 | 37 | 'spip_articles', |
| 38 | - ['id_article=' . (int) $id_article, "statut='publie'"], |
|
| 38 | + ['id_article='.(int) $id_article, "statut='publie'"], |
|
| 39 | 39 | '', |
| 40 | 40 | '', |
| 41 | 41 | '', |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $cache_quete[$connect][$table][$id] = sql_fetsel( |
| 79 | 79 | $cache_quete[$connect][$table]['_select'], |
| 80 | 80 | $table, |
| 81 | - $cache_quete[$connect][$table]['_id'] . '=' . (int) $id, |
|
| 81 | + $cache_quete[$connect][$table]['_id'].'='.(int) $id, |
|
| 82 | 82 | '', |
| 83 | 83 | '', |
| 84 | 84 | '', |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | return |
| 170 | 170 | (isset($GLOBALS['meta']['date_prochain_postdate']) |
| 171 | 171 | && $GLOBALS['meta']['date_prochain_postdate'] > time()) |
| 172 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 172 | + ? "$champ_date<".sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 173 | 173 | : '1=1'; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | && ($id_table = reset($objet)) |
| 229 | 229 | && ($objet = objet_type($id_table)) |
| 230 | 230 | ) { |
| 231 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 231 | + $w = "$mstatut<>".sql_quote($v); |
|
| 232 | 232 | |
| 233 | 233 | // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
| 234 | 234 | // sinon l’auteur en session |
@@ -242,22 +242,22 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // dans ce cas (admin en general), pas de filtrage sur ce statut |
| 245 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 245 | + if (!autoriser('previsualiser'.$v, $objet, '', $id_auteur)) { |
|
| 246 | 246 | // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
| 247 | 247 | if (!$id_auteur) { |
| 248 | 248 | $where[] = $w; |
| 249 | 249 | } else { |
| 250 | 250 | $primary = id_table_objet($objet); |
| 251 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 251 | + $where[] = "($w OR $id_table.$primary IN (".sql_get_select( |
|
| 252 | 252 | 'ssss.id_objet', |
| 253 | 253 | 'spip_auteurs_liens AS ssss', |
| 254 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . (int) $id_auteur, |
|
| 254 | + 'ssss.objet='.sql_quote($objet).' AND ssss.id_auteur='.(int) $id_auteur, |
|
| 255 | 255 | '', |
| 256 | 256 | '', |
| 257 | 257 | '', |
| 258 | 258 | '', |
| 259 | 259 | $serveur |
| 260 | - ) . '))'; |
|
| 260 | + ).'))'; |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | } // ignorer ce statut si on ne sait pas comment le filtrer |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @return array|bool|null |
| 296 | 296 | */ |
| 297 | 297 | function quete_fichier($id_document, $serveur = '') { |
| 298 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 298 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document='.(int) $id_document), '', [], '', '', $serveur); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @return array|bool |
| 307 | 307 | */ |
| 308 | 308 | function quete_document($id_document, $serveur = '') { |
| 309 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 309 | + return sql_fetsel('*', 'spip_documents', ('id_document='.(int) $id_document), '', [], '', '', $serveur); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return array|bool|null |
| 318 | 318 | */ |
| 319 | 319 | function quete_meta($nom, $serveur) { |
| 320 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 320 | + return sql_getfetsel('valeur', 'spip_meta', 'nom='.sql_quote($nom), '', '', '', '', $serveur); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -368,9 +368,9 @@ discard block |
||
| 368 | 368 | // qui permet de distinguer le changement de logo |
| 369 | 369 | // et placer un expire sur le dossier IMG/ |
| 370 | 370 | $res = [ |
| 371 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 372 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 373 | - ($taille ? ' ' . $taille[3] : ('')) |
|
| 371 | + $on['chemin'].($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 372 | + ($off ? $off['chemin'].($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 373 | + ($taille ? ' '.$taille[3] : ('')) |
|
| 374 | 374 | ]; |
| 375 | 375 | $res['src'] = $res[0]; |
| 376 | 376 | $res['logo_on'] = $res[0]; |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | if ( |
| 481 | 481 | strcmp((string) $logo, (string) _DIR_PLUGINS) == 0 |
| 482 | 482 | || strcmp((string) $logo, (string) _DIR_PLUGINS_DIST) == 0 |
| 483 | - || strcmp((string) $logo, _DIR_RACINE . 'prive/') == 0 |
|
| 483 | + || strcmp((string) $logo, _DIR_RACINE.'prive/') == 0 |
|
| 484 | 484 | ) { |
| 485 | 485 | return $logo; |
| 486 | 486 | } |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | $exposer[$m][$type][$principal] = true; |
| 657 | 657 | if ($type == 'id_mot') { |
| 658 | 658 | if (!$parent) { |
| 659 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . (int) $principal, '', '', '', '', $connect); |
|
| 659 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot='.(int) $principal, '', '', '', '', $connect); |
|
| 660 | 660 | } |
| 661 | 661 | if ($parent) { |
| 662 | 662 | $exposer[$m]['id_groupe'][$parent] = true; |
@@ -10,35 +10,35 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // rien sauf les "~" et "-," |
| 17 | 17 | |
| 18 | 18 | function typographie_en_dist($letexte) { |
| 19 | 19 | |
| 20 | - // zouli apostrophe |
|
| 21 | - $letexte = str_replace("'", '’', (string) $letexte); |
|
| 22 | - |
|
| 23 | - $cherche1 = [ |
|
| 24 | - '/ --?,/S' |
|
| 25 | - ]; |
|
| 26 | - $remplace1 = [ |
|
| 27 | - '~\0' |
|
| 28 | - ]; |
|
| 29 | - $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 30 | - |
|
| 31 | - $letexte = str_replace(' ', '~', $letexte); |
|
| 32 | - $letexte = preg_replace('/ *~+ */', '~', $letexte); |
|
| 33 | - |
|
| 34 | - $cherche2 = [ |
|
| 35 | - '/([^-\n]|^)--([^-]|$)/', |
|
| 36 | - '/~/' |
|
| 37 | - ]; |
|
| 38 | - $remplace2 = [ |
|
| 39 | - '\1—\2', |
|
| 40 | - ' ' |
|
| 41 | - ]; |
|
| 42 | - |
|
| 43 | - return preg_replace($cherche2, $remplace2, $letexte); |
|
| 20 | + // zouli apostrophe |
|
| 21 | + $letexte = str_replace("'", '’', (string) $letexte); |
|
| 22 | + |
|
| 23 | + $cherche1 = [ |
|
| 24 | + '/ --?,/S' |
|
| 25 | + ]; |
|
| 26 | + $remplace1 = [ |
|
| 27 | + '~\0' |
|
| 28 | + ]; |
|
| 29 | + $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 30 | + |
|
| 31 | + $letexte = str_replace(' ', '~', $letexte); |
|
| 32 | + $letexte = preg_replace('/ *~+ */', '~', $letexte); |
|
| 33 | + |
|
| 34 | + $cherche2 = [ |
|
| 35 | + '/([^-\n]|^)--([^-]|$)/', |
|
| 36 | + '/~/' |
|
| 37 | + ]; |
|
| 38 | + $remplace2 = [ |
|
| 39 | + '\1—\2', |
|
| 40 | + ' ' |
|
| 41 | + ]; |
|
| 42 | + |
|
| 43 | + return preg_replace($cherche2, $remplace2, $letexte); |
|
| 44 | 44 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | define('_PHP_MAX', '8.2.99'); |
| 37 | 37 | |
| 38 | 38 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 39 | - /** le nom du repertoire ecrire/ */ |
|
| 40 | - define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 39 | + /** le nom du repertoire ecrire/ */ |
|
| 40 | + define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** Chemin relatif pour aller dans ecrire |
| 44 | 44 | * vide si on est dans ecrire, 'ecrire/' sinon */ |
| 45 | 45 | define( |
| 46 | - '_DIR_RESTREINT', |
|
| 47 | - (is_dir(_DIR_RESTREINT_ABS) ? _DIR_RESTREINT_ABS : '') |
|
| 46 | + '_DIR_RESTREINT', |
|
| 47 | + (is_dir(_DIR_RESTREINT_ABS) ? _DIR_RESTREINT_ABS : '') |
|
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | 50 | /** Chemin relatif pour aller à la racine */ |
@@ -61,28 +61,28 @@ discard block |
||
| 61 | 61 | # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas) |
| 62 | 62 | # mais on peut les mettre ailleurs et changer completement les noms |
| 63 | 63 | if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) { |
| 64 | - /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 65 | - define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 64 | + /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 65 | + define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 66 | 66 | } |
| 67 | 67 | if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) { |
| 68 | - /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 69 | - define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 68 | + /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 69 | + define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 70 | 70 | } |
| 71 | 71 | if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) { |
| 72 | - /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 73 | - define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 72 | + /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 73 | + define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 74 | 74 | } |
| 75 | 75 | if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) { |
| 76 | - /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 77 | - define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 76 | + /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 77 | + define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // inclure l'ecran de securite si il n'a pas été inclus en prepend php |
| 81 | 81 | if ( |
| 82 | - !defined('_ECRAN_SECURITE') |
|
| 83 | - && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 82 | + !defined('_ECRAN_SECURITE') |
|
| 83 | + && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 84 | 84 | ) { |
| 85 | - include $f; |
|
| 85 | + include $f; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // et on peut lancer l'autoloader |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | // Icones |
| 92 | 92 | if (!defined('_NOM_IMG_PACK')) { |
| 93 | - /** Nom du dossier images */ |
|
| 94 | - define('_NOM_IMG_PACK', 'images/'); |
|
| 93 | + /** Nom du dossier images */ |
|
| 94 | + define('_NOM_IMG_PACK', 'images/'); |
|
| 95 | 95 | } |
| 96 | 96 | /** le chemin http (relatif) vers les images standard */ |
| 97 | 97 | define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
| 101 | 101 | |
| 102 | 102 | if (!defined('_JAVASCRIPT')) { |
| 103 | - /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 104 | - define('_JAVASCRIPT', 'javascript/'); |
|
| 103 | + /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 104 | + define('_JAVASCRIPT', 'javascript/'); |
|
| 105 | 105 | } // utilisable avec #CHEMIN et find_in_path |
| 106 | 106 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 107 | 107 | define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
@@ -109,28 +109,28 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | /** Le nom du fichier de personnalisation */ |
| 111 | 111 | if (!defined('_NOM_CONFIG')) { |
| 112 | - define('_NOM_CONFIG', 'mes_options'); |
|
| 112 | + define('_NOM_CONFIG', 'mes_options'); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // Son emplacement absolu si on le trouve |
| 116 | 116 | if ( |
| 117 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 118 | - || @file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php') |
|
| 117 | + @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 118 | + || @file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php') |
|
| 119 | 119 | ) { |
| 120 | - /** Emplacement absolu du fichier d'option */ |
|
| 121 | - define('_FILE_OPTIONS', $f); |
|
| 120 | + /** Emplacement absolu du fichier d'option */ |
|
| 121 | + define('_FILE_OPTIONS', $f); |
|
| 122 | 122 | } else { |
| 123 | - define('_FILE_OPTIONS', ''); |
|
| 123 | + define('_FILE_OPTIONS', ''); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | if (!defined('MODULES_IDIOMES')) { |
| 127 | - /** |
|
| 128 | - * Modules par défaut pour la traduction. |
|
| 129 | - * |
|
| 130 | - * Constante utilisée par le compilateur et le décompilateur |
|
| 131 | - * sa valeur etant traitée par inc_traduire_dist |
|
| 132 | - */ |
|
| 133 | - define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 127 | + /** |
|
| 128 | + * Modules par défaut pour la traduction. |
|
| 129 | + * |
|
| 130 | + * Constante utilisée par le compilateur et le décompilateur |
|
| 131 | + * sa valeur etant traitée par inc_traduire_dist |
|
| 132 | + */ |
|
| 133 | + define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // *** Fin des define *** // |
@@ -140,30 +140,30 @@ discard block |
||
| 140 | 140 | * Détecteur de robot d'indexation |
| 141 | 141 | */ |
| 142 | 142 | if (!defined('_IS_BOT')) { |
| 143 | - define( |
|
| 144 | - '_IS_BOT', |
|
| 145 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 146 | - && preg_match( |
|
| 147 | - // mots generiques |
|
| 148 | - ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 149 | - // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 150 | - . 'MSIE 6\.0|' |
|
| 151 | - // UA plus cibles |
|
| 152 | - . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 153 | - . ',i', |
|
| 154 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 143 | + define( |
|
| 144 | + '_IS_BOT', |
|
| 145 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 146 | + && preg_match( |
|
| 147 | + // mots generiques |
|
| 148 | + ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 149 | + // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 150 | + . 'MSIE 6\.0|' |
|
| 151 | + // UA plus cibles |
|
| 152 | + . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 153 | + . ',i', |
|
| 154 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | if (!defined('_IS_CLI')) { |
| 160 | - define( |
|
| 161 | - '_IS_CLI', |
|
| 162 | - !isset($_SERVER['HTTP_HOST']) |
|
| 163 | - && !strlen((string) $_SERVER['DOCUMENT_ROOT']) |
|
| 164 | - && !empty($_SERVER['argv']) |
|
| 165 | - && empty($_SERVER['REQUEST_METHOD']) |
|
| 166 | - ); |
|
| 160 | + define( |
|
| 161 | + '_IS_CLI', |
|
| 162 | + !isset($_SERVER['HTTP_HOST']) |
|
| 163 | + && !strlen((string) $_SERVER['DOCUMENT_ROOT']) |
|
| 164 | + && !empty($_SERVER['argv']) |
|
| 165 | + && empty($_SERVER['REQUEST_METHOD']) |
|
| 166 | + ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // *** Parametrage par defaut de SPIP *** |
@@ -175,61 +175,61 @@ discard block |
||
| 175 | 175 | // Ne pas les rendre indefinies. |
| 176 | 176 | |
| 177 | 177 | global |
| 178 | - $nombre_de_logs, |
|
| 179 | - $taille_des_logs, |
|
| 180 | - $table_prefix, |
|
| 181 | - $cookie_prefix, |
|
| 182 | - $dossier_squelettes, |
|
| 183 | - $filtrer_javascript, |
|
| 184 | - $type_urls, |
|
| 185 | - $debut_date_publication, |
|
| 186 | - $ip, |
|
| 187 | - $mysql_rappel_connexion, |
|
| 188 | - $mysql_rappel_nom_base, |
|
| 189 | - $test_i18n, |
|
| 190 | - $ignore_auth_http, |
|
| 191 | - $ignore_remote_user, |
|
| 192 | - $derniere_modif_invalide, |
|
| 193 | - $home_server, |
|
| 194 | - $help_server, |
|
| 195 | - $url_glossaire_externe, |
|
| 196 | - $tex_server, |
|
| 197 | - $traiter_math, |
|
| 198 | - $xhtml, |
|
| 199 | - $xml_indent, |
|
| 200 | - $source_vignettes, |
|
| 201 | - $formats_logos, |
|
| 202 | - $controler_dates_rss, |
|
| 203 | - $spip_pipeline, |
|
| 204 | - $spip_matrice, |
|
| 205 | - $plugins, |
|
| 206 | - $surcharges, |
|
| 207 | - $exceptions_des_tables, |
|
| 208 | - $tables_principales, |
|
| 209 | - $table_des_tables, |
|
| 210 | - $tables_auxiliaires, |
|
| 211 | - $table_primary, |
|
| 212 | - $table_date, |
|
| 213 | - $table_titre, |
|
| 214 | - $tables_jointures, |
|
| 215 | - $liste_des_statuts, |
|
| 216 | - $liste_des_etats, |
|
| 217 | - $liste_des_authentifications, |
|
| 218 | - $spip_version_branche, |
|
| 219 | - $spip_version_code, |
|
| 220 | - $spip_version_base, |
|
| 221 | - $spip_sql_version, |
|
| 222 | - $spip_version_affichee, |
|
| 223 | - $visiteur_session, |
|
| 224 | - $auteur_session, |
|
| 225 | - $connect_statut, |
|
| 226 | - $connect_toutes_rubriques, |
|
| 227 | - $hash_recherche, |
|
| 228 | - $hash_recherche_strict, |
|
| 229 | - $ldap_present, |
|
| 230 | - $meta, |
|
| 231 | - $connect_id_rubrique, |
|
| 232 | - $puce; |
|
| 178 | + $nombre_de_logs, |
|
| 179 | + $taille_des_logs, |
|
| 180 | + $table_prefix, |
|
| 181 | + $cookie_prefix, |
|
| 182 | + $dossier_squelettes, |
|
| 183 | + $filtrer_javascript, |
|
| 184 | + $type_urls, |
|
| 185 | + $debut_date_publication, |
|
| 186 | + $ip, |
|
| 187 | + $mysql_rappel_connexion, |
|
| 188 | + $mysql_rappel_nom_base, |
|
| 189 | + $test_i18n, |
|
| 190 | + $ignore_auth_http, |
|
| 191 | + $ignore_remote_user, |
|
| 192 | + $derniere_modif_invalide, |
|
| 193 | + $home_server, |
|
| 194 | + $help_server, |
|
| 195 | + $url_glossaire_externe, |
|
| 196 | + $tex_server, |
|
| 197 | + $traiter_math, |
|
| 198 | + $xhtml, |
|
| 199 | + $xml_indent, |
|
| 200 | + $source_vignettes, |
|
| 201 | + $formats_logos, |
|
| 202 | + $controler_dates_rss, |
|
| 203 | + $spip_pipeline, |
|
| 204 | + $spip_matrice, |
|
| 205 | + $plugins, |
|
| 206 | + $surcharges, |
|
| 207 | + $exceptions_des_tables, |
|
| 208 | + $tables_principales, |
|
| 209 | + $table_des_tables, |
|
| 210 | + $tables_auxiliaires, |
|
| 211 | + $table_primary, |
|
| 212 | + $table_date, |
|
| 213 | + $table_titre, |
|
| 214 | + $tables_jointures, |
|
| 215 | + $liste_des_statuts, |
|
| 216 | + $liste_des_etats, |
|
| 217 | + $liste_des_authentifications, |
|
| 218 | + $spip_version_branche, |
|
| 219 | + $spip_version_code, |
|
| 220 | + $spip_version_base, |
|
| 221 | + $spip_sql_version, |
|
| 222 | + $spip_version_affichee, |
|
| 223 | + $visiteur_session, |
|
| 224 | + $auteur_session, |
|
| 225 | + $connect_statut, |
|
| 226 | + $connect_toutes_rubriques, |
|
| 227 | + $hash_recherche, |
|
| 228 | + $hash_recherche_strict, |
|
| 229 | + $ldap_present, |
|
| 230 | + $meta, |
|
| 231 | + $connect_id_rubrique, |
|
| 232 | + $puce; |
|
| 233 | 233 | |
| 234 | 234 | # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log |
| 235 | 235 | $nombre_de_logs = 4; |
@@ -284,48 +284,48 @@ discard block |
||
| 284 | 284 | // Prendre en compte les entetes HTTP_X_FORWARDED_XX |
| 285 | 285 | // |
| 286 | 286 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
| 287 | - if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 288 | - $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 289 | - } |
|
| 290 | - if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 291 | - $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 292 | - } |
|
| 287 | + if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 288 | + $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 289 | + } |
|
| 290 | + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 291 | + $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 292 | + } |
|
| 293 | 293 | } |
| 294 | 294 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 295 | - if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) && is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 296 | - $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 297 | - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 298 | - $_SERVER['HTTPS'] = 'on'; |
|
| 299 | - if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 300 | - $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 305 | - if (str_contains((string) $host, ',')) { |
|
| 306 | - $h = explode(',', (string) $host); |
|
| 307 | - $host = trim(reset($h)); |
|
| 308 | - } |
|
| 309 | - // securite sur le contenu de l'entete |
|
| 310 | - $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 311 | - $_SERVER['HTTP_HOST'] = $host; |
|
| 295 | + if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) && is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 296 | + $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 297 | + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 298 | + $_SERVER['HTTPS'] = 'on'; |
|
| 299 | + if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 300 | + $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 305 | + if (str_contains((string) $host, ',')) { |
|
| 306 | + $h = explode(',', (string) $host); |
|
| 307 | + $host = trim(reset($h)); |
|
| 308 | + } |
|
| 309 | + // securite sur le contenu de l'entete |
|
| 310 | + $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 311 | + $_SERVER['HTTP_HOST'] = $host; |
|
| 312 | 312 | } |
| 313 | 313 | // |
| 314 | 314 | // On note le numero IP du client dans la variable $ip |
| 315 | 315 | // |
| 316 | 316 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 317 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 318 | - if (str_contains((string) $ip, ',')) { |
|
| 319 | - $ip = explode(',', (string) $ip); |
|
| 320 | - $ip = reset($ip); |
|
| 321 | - } |
|
| 322 | - // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 323 | - if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 324 | - $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 325 | - } |
|
| 317 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 318 | + if (str_contains((string) $ip, ',')) { |
|
| 319 | + $ip = explode(',', (string) $ip); |
|
| 320 | + $ip = reset($ip); |
|
| 321 | + } |
|
| 322 | + // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 323 | + if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 324 | + $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 325 | + } |
|
| 326 | 326 | } |
| 327 | 327 | if (isset($_SERVER['REMOTE_ADDR'])) { |
| 328 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 328 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la |
@@ -410,24 +410,24 @@ discard block |
||
| 410 | 410 | |
| 411 | 411 | // Liste des statuts. |
| 412 | 412 | $liste_des_statuts = [ |
| 413 | - 'info_administrateurs' => '0minirezo', |
|
| 414 | - 'info_redacteurs' => '1comite', |
|
| 415 | - 'info_visiteurs' => '6forum', |
|
| 416 | - 'texte_statut_poubelle' => '5poubelle' |
|
| 413 | + 'info_administrateurs' => '0minirezo', |
|
| 414 | + 'info_redacteurs' => '1comite', |
|
| 415 | + 'info_visiteurs' => '6forum', |
|
| 416 | + 'texte_statut_poubelle' => '5poubelle' |
|
| 417 | 417 | ]; |
| 418 | 418 | |
| 419 | 419 | $liste_des_etats = [ |
| 420 | - 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 421 | - 'texte_statut_propose_evaluation' => 'prop', |
|
| 422 | - 'texte_statut_publie' => 'publie', |
|
| 423 | - 'texte_statut_poubelle' => 'poubelle', |
|
| 424 | - 'texte_statut_refuse' => 'refuse' |
|
| 420 | + 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 421 | + 'texte_statut_propose_evaluation' => 'prop', |
|
| 422 | + 'texte_statut_publie' => 'publie', |
|
| 423 | + 'texte_statut_poubelle' => 'poubelle', |
|
| 424 | + 'texte_statut_refuse' => 'refuse' |
|
| 425 | 425 | ]; |
| 426 | 426 | |
| 427 | 427 | // liste des methodes d'authentifications |
| 428 | 428 | $liste_des_authentifications = [ |
| 429 | - 'spip' => 'spip', |
|
| 430 | - 'ldap' => 'ldap' |
|
| 429 | + 'spip' => 'spip', |
|
| 430 | + 'ldap' => 'ldap' |
|
| 431 | 431 | ]; |
| 432 | 432 | |
| 433 | 433 | // Experimental : pour supprimer systematiquement l'affichage des numeros |
@@ -477,12 +477,12 @@ discard block |
||
| 477 | 477 | // Definition personnelles eventuelles |
| 478 | 478 | |
| 479 | 479 | if (_FILE_OPTIONS) { |
| 480 | - include_once _FILE_OPTIONS; |
|
| 480 | + include_once _FILE_OPTIONS; |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | if (!defined('SPIP_ERREUR_REPORT')) { |
| 484 | - /** Masquer les warning */ |
|
| 485 | - define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 484 | + /** Masquer les warning */ |
|
| 485 | + define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 486 | 486 | } |
| 487 | 487 | error_reporting(SPIP_ERREUR_REPORT); |
| 488 | 488 | |
@@ -495,10 +495,10 @@ discard block |
||
| 495 | 495 | // ===> on execute en neutralisant les messages d'erreur |
| 496 | 496 | |
| 497 | 497 | spip_initialisation_core( |
| 498 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 498 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 499 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 500 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 501 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 502 | 502 | ); |
| 503 | 503 | |
| 504 | 504 | |
@@ -508,71 +508,71 @@ discard block |
||
| 508 | 508 | // donc il faut avoir tout fini ici avant de charger les plugins |
| 509 | 509 | |
| 510 | 510 | if (@is_readable(_CACHE_PLUGINS_OPT) && @is_readable(_CACHE_PLUGINS_PATH)) { |
| 511 | - // chargement optimise precompile |
|
| 512 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 511 | + // chargement optimise precompile |
|
| 512 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 513 | 513 | } else { |
| 514 | - spip_initialisation_suite(); |
|
| 515 | - include_spip('inc/plugin'); |
|
| 516 | - // generer les fichiers php precompiles |
|
| 517 | - // de chargement des plugins et des pipelines |
|
| 518 | - actualise_plugins_actifs(); |
|
| 514 | + spip_initialisation_suite(); |
|
| 515 | + include_spip('inc/plugin'); |
|
| 516 | + // generer les fichiers php precompiles |
|
| 517 | + // de chargement des plugins et des pipelines |
|
| 518 | + actualise_plugins_actifs(); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | // Initialisations non critiques surchargeables par les plugins |
| 522 | 522 | spip_initialisation_suite(); |
| 523 | 523 | |
| 524 | 524 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 525 | - /** niveau maxi d'enregistrement des logs */ |
|
| 526 | - define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 525 | + /** niveau maxi d'enregistrement des logs */ |
|
| 526 | + define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | if (!defined('_OUTILS_DEVELOPPEURS')) { |
| 530 | - /** Activer des outils pour développeurs ? */ |
|
| 531 | - define('_OUTILS_DEVELOPPEURS', false); |
|
| 530 | + /** Activer des outils pour développeurs ? */ |
|
| 531 | + define('_OUTILS_DEVELOPPEURS', false); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | // charger systematiquement inc/autoriser dans l'espace restreint |
| 535 | 535 | if (test_espace_prive()) { |
| 536 | - include_spip('inc/autoriser'); |
|
| 536 | + include_spip('inc/autoriser'); |
|
| 537 | 537 | } |
| 538 | 538 | // |
| 539 | 539 | // Installer Spip si pas installe... sauf si justement on est en train |
| 540 | 540 | // |
| 541 | 541 | if ( |
| 542 | - !(_FILE_CONNECT |
|
| 543 | - || autoriser_sans_cookie(_request('exec')) |
|
| 544 | - || _request('action') == 'cookie' |
|
| 545 | - || _request('action') == 'converser' |
|
| 546 | - || _request('action') == 'test_dirs') |
|
| 542 | + !(_FILE_CONNECT |
|
| 543 | + || autoriser_sans_cookie(_request('exec')) |
|
| 544 | + || _request('action') == 'cookie' |
|
| 545 | + || _request('action') == 'converser' |
|
| 546 | + || _request('action') == 'test_dirs') |
|
| 547 | 547 | ) { |
| 548 | - // Si on peut installer, on lance illico |
|
| 549 | - if (test_espace_prive()) { |
|
| 550 | - include_spip('inc/headers'); |
|
| 551 | - redirige_url_ecrire('install'); |
|
| 552 | - } else { |
|
| 553 | - // Si on est dans le site public, dire que qq s'en occupe |
|
| 554 | - include_spip('inc/lang'); |
|
| 555 | - utiliser_langue_visiteur(); |
|
| 556 | - include_spip('inc/minipres'); |
|
| 557 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 558 | - exit; |
|
| 559 | - } |
|
| 560 | - // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 548 | + // Si on peut installer, on lance illico |
|
| 549 | + if (test_espace_prive()) { |
|
| 550 | + include_spip('inc/headers'); |
|
| 551 | + redirige_url_ecrire('install'); |
|
| 552 | + } else { |
|
| 553 | + // Si on est dans le site public, dire que qq s'en occupe |
|
| 554 | + include_spip('inc/lang'); |
|
| 555 | + utiliser_langue_visiteur(); |
|
| 556 | + include_spip('inc/minipres'); |
|
| 557 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 558 | + exit; |
|
| 559 | + } |
|
| 560 | + // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | // memoriser un tri sessionne eventuel |
| 564 | 564 | if ( |
| 565 | - isset($_REQUEST['var_memotri']) |
|
| 566 | - && ($t = $_REQUEST['var_memotri']) |
|
| 567 | - && (str_starts_with((string) $t, 'trisession') || str_starts_with((string) $t, 'senssession')) |
|
| 565 | + isset($_REQUEST['var_memotri']) |
|
| 566 | + && ($t = $_REQUEST['var_memotri']) |
|
| 567 | + && (str_starts_with((string) $t, 'trisession') || str_starts_with((string) $t, 'senssession')) |
|
| 568 | 568 | ) { |
| 569 | - if (!function_exists('session_set')) { |
|
| 570 | - include_spip('inc/session'); |
|
| 571 | - } |
|
| 572 | - $t = preg_replace(',\W,', '_', (string) $t); |
|
| 573 | - if ($v = _request($t)) { |
|
| 574 | - session_set($t, $v); |
|
| 575 | - } |
|
| 569 | + if (!function_exists('session_set')) { |
|
| 570 | + include_spip('inc/session'); |
|
| 571 | + } |
|
| 572 | + $t = preg_replace(',\W,', '_', (string) $t); |
|
| 573 | + if ($v = _request($t)) { |
|
| 574 | + session_set($t, $v); |
|
| 575 | + } |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -582,22 +582,22 @@ discard block |
||
| 582 | 582 | * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite |
| 583 | 583 | */ |
| 584 | 584 | if (!defined('_HEADER_COMPOSED_BY')) { |
| 585 | - define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 585 | + define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 586 | 586 | } |
| 587 | 587 | if (!headers_sent() && _HEADER_COMPOSED_BY) { |
| 588 | - if (!defined('_HEADER_VARY')) { |
|
| 589 | - define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 590 | - } |
|
| 591 | - if (_HEADER_VARY) { |
|
| 592 | - header(_HEADER_VARY); |
|
| 593 | - } |
|
| 594 | - if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
|
| 595 | - include_spip('inc/filtres_mini'); |
|
| 596 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 597 | - } else { |
|
| 598 | - // header minimal |
|
| 599 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 600 | - } |
|
| 588 | + if (!defined('_HEADER_VARY')) { |
|
| 589 | + define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 590 | + } |
|
| 591 | + if (_HEADER_VARY) { |
|
| 592 | + header(_HEADER_VARY); |
|
| 593 | + } |
|
| 594 | + if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
|
| 595 | + include_spip('inc/filtres_mini'); |
|
| 596 | + header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 597 | + } else { |
|
| 598 | + // header minimal |
|
| 599 | + header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 600 | + } |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | define('_DIR_RACINE', _DIR_RESTREINT ? '' : '../'); |
| 52 | 52 | |
| 53 | 53 | /** chemin absolu vers la racine */ |
| 54 | -define('_ROOT_RACINE', dirname(__DIR__) . '/'); |
|
| 54 | +define('_ROOT_RACINE', dirname(__DIR__).'/'); |
|
| 55 | 55 | /** chemin absolu vers le repertoire de travail */ |
| 56 | -define('_ROOT_CWD', getcwd() . '/'); |
|
| 56 | +define('_ROOT_CWD', getcwd().'/'); |
|
| 57 | 57 | /** chemin absolu vers ecrire */ |
| 58 | -define('_ROOT_RESTREINT', _ROOT_CWD . _DIR_RESTREINT); |
|
| 58 | +define('_ROOT_RESTREINT', _ROOT_CWD._DIR_RESTREINT); |
|
| 59 | 59 | |
| 60 | 60 | # Le nom des 4 repertoires modifiables par les scripts lances par httpd |
| 61 | 61 | # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas) |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | // inclure l'ecran de securite si il n'a pas été inclus en prepend php |
| 81 | 81 | if ( |
| 82 | 82 | !defined('_ECRAN_SECURITE') |
| 83 | - && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 83 | + && @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES.'ecran_securite.php') |
|
| 84 | 84 | ) { |
| 85 | 85 | include $f; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // et on peut lancer l'autoloader |
| 89 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 89 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 90 | 90 | |
| 91 | 91 | // Icones |
| 92 | 92 | if (!defined('_NOM_IMG_PACK')) { |
@@ -94,17 +94,17 @@ discard block |
||
| 94 | 94 | define('_NOM_IMG_PACK', 'images/'); |
| 95 | 95 | } |
| 96 | 96 | /** le chemin http (relatif) vers les images standard */ |
| 97 | -define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
|
| 97 | +define('_DIR_IMG_PACK', (_DIR_RACINE.'prive/'._NOM_IMG_PACK)); |
|
| 98 | 98 | |
| 99 | 99 | /** le chemin php (absolu) vers les images standard (pour hebergement centralise) */ |
| 100 | -define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
|
| 100 | +define('_ROOT_IMG_PACK', dirname(__DIR__).'/prive/'._NOM_IMG_PACK); |
|
| 101 | 101 | |
| 102 | 102 | if (!defined('_JAVASCRIPT')) { |
| 103 | 103 | /** Nom du repertoire des bibliotheques JavaScript */ |
| 104 | 104 | define('_JAVASCRIPT', 'javascript/'); |
| 105 | 105 | } // utilisable avec #CHEMIN et find_in_path |
| 106 | 106 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 107 | -define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
|
| 107 | +define('_DIR_JAVASCRIPT', (_DIR_RACINE.'prive/'._JAVASCRIPT)); |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | /** Le nom du fichier de personnalisation */ |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | // Son emplacement absolu si on le trouve |
| 116 | 116 | if ( |
| 117 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 118 | - || @file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php') |
|
| 117 | + @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES._NOM_CONFIG.'.php') |
|
| 118 | + || @file_exists($f = _ROOT_RESTREINT._NOM_CONFIG.'.php') |
|
| 119 | 119 | ) { |
| 120 | 120 | /** Emplacement absolu du fichier d'option */ |
| 121 | 121 | define('_FILE_OPTIONS', $f); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | // UA plus cibles |
| 152 | 152 | . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
| 153 | 153 | . ',i', |
| 154 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 154 | + (string) $_SERVER['HTTP_USER_AGENT'] |
|
| 155 | 155 | ) |
| 156 | 156 | ); |
| 157 | 157 | } |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | # la matrice standard (fichiers definissant les fonctions a inclure) |
| 394 | 394 | $spip_matrice = []; |
| 395 | 395 | # les plugins a activer |
| 396 | -$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 396 | +$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 397 | 397 | # les surcharges de include_spip() |
| 398 | 398 | $surcharges = []; // format 'inc_truc' => '/plugins/chose/inc_truc2.php' |
| 399 | 399 | |
@@ -471,8 +471,8 @@ discard block |
||
| 471 | 471 | // |
| 472 | 472 | // Charger les fonctions liees aux serveurs Http et Sql. |
| 473 | 473 | // |
| 474 | -require_once _ROOT_RESTREINT . 'inc/utils.php'; |
|
| 475 | -require_once _ROOT_RESTREINT . 'base/connect_sql.php'; |
|
| 474 | +require_once _ROOT_RESTREINT.'inc/utils.php'; |
|
| 475 | +require_once _ROOT_RESTREINT.'base/connect_sql.php'; |
|
| 476 | 476 | |
| 477 | 477 | // Definition personnelles eventuelles |
| 478 | 478 | |
@@ -495,10 +495,10 @@ discard block |
||
| 495 | 495 | // ===> on execute en neutralisant les messages d'erreur |
| 496 | 496 | |
| 497 | 497 | spip_initialisation_core( |
| 498 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 498 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 499 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 500 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 501 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 502 | 502 | ); |
| 503 | 503 | |
| 504 | 504 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | include_spip('inc/lang'); |
| 555 | 555 | utiliser_langue_visiteur(); |
| 556 | 556 | include_spip('inc/minipres'); |
| 557 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 557 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>"._T('info_travaux_texte').'</p>', ['status' => 503]); |
|
| 558 | 558 | exit; |
| 559 | 559 | } |
| 560 | 560 | // autrement c'est une install ad hoc (spikini...), on sait pas faire |
@@ -593,12 +593,12 @@ discard block |
||
| 593 | 593 | } |
| 594 | 594 | if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
| 595 | 595 | include_spip('inc/filtres_mini'); |
| 596 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 596 | + header(_HEADER_COMPOSED_BY." $spip_version_affichee @ www.spip.net + ".url_absolue(_DIR_VAR.'config.txt')); |
|
| 597 | 597 | } else { |
| 598 | 598 | // header minimal |
| 599 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 599 | + header(_HEADER_COMPOSED_BY.' @ www.spip.net'); |
|
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
| 604 | -spip_log($methode . ' ' . self() . ' - ' . _FILE_CONNECT, _LOG_DEBUG); |
|
| 604 | +spip_log($methode.' '.self().' - '._FILE_CONNECT, _LOG_DEBUG); |
|
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -34,26 +34,26 @@ discard block |
||
| 34 | 34 | **/ |
| 35 | 35 | function genie_optimiser_dist($t) { |
| 36 | 36 | |
| 37 | - optimiser_base_une_table(); |
|
| 38 | - optimiser_base(); |
|
| 39 | - optimiser_caches_contextes(); |
|
| 37 | + optimiser_base_une_table(); |
|
| 38 | + optimiser_base(); |
|
| 39 | + optimiser_caches_contextes(); |
|
| 40 | 40 | |
| 41 | - // la date souhaitee pour le tour suivant = apres-demain a 4h du mat ; |
|
| 42 | - // sachant qu'on a un delai de 48h, on renvoie aujourd'hui a 4h du mat |
|
| 43 | - // avec une periode de flou entre 2h et 6h pour ne pas saturer un hebergeur |
|
| 44 | - // qui aurait beaucoup de sites SPIP |
|
| 45 | - return -(mktime(2, 0, 0) + random_int(0, 3600 * 4)); |
|
| 41 | + // la date souhaitee pour le tour suivant = apres-demain a 4h du mat ; |
|
| 42 | + // sachant qu'on a un delai de 48h, on renvoie aujourd'hui a 4h du mat |
|
| 43 | + // avec une periode de flou entre 2h et 6h pour ne pas saturer un hebergeur |
|
| 44 | + // qui aurait beaucoup de sites SPIP |
|
| 45 | + return -(mktime(2, 0, 0) + random_int(0, 3600 * 4)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Vider les contextes ajax de plus de 48h |
| 50 | 50 | */ |
| 51 | 51 | function optimiser_caches_contextes() { |
| 52 | - sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 53 | - if (is_dir($d = _DIR_CACHE . 'contextes')) { |
|
| 54 | - include_spip('inc/invalideur'); |
|
| 55 | - purger_repertoire($d, ['mtime' => time() - 48 * 3600, 'limit' => 10000]); |
|
| 56 | - } |
|
| 52 | + sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 53 | + if (is_dir($d = _DIR_CACHE . 'contextes')) { |
|
| 54 | + include_spip('inc/invalideur'); |
|
| 55 | + purger_repertoire($d, ['mtime' => time() - 48 * 3600, 'limit' => 10000]); |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return void |
| 69 | 69 | **/ |
| 70 | 70 | function optimiser_base($attente = 86400) { |
| 71 | - optimiser_base_disparus($attente); |
|
| 71 | + optimiser_base_disparus($attente); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -85,28 +85,28 @@ discard block |
||
| 85 | 85 | **/ |
| 86 | 86 | function optimiser_base_une_table() { |
| 87 | 87 | |
| 88 | - $tables = []; |
|
| 89 | - $result = sql_showbase(); |
|
| 90 | - |
|
| 91 | - // on n'optimise qu'une seule table a chaque fois, |
|
| 92 | - // pour ne pas vautrer le systeme |
|
| 93 | - // lire http://dev.mysql.com/doc/refman/5.0/fr/optimize-table.html |
|
| 94 | - while ($row = sql_fetch($result)) { |
|
| 95 | - $tables[] = array_shift($row); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - spip_log('optimiser_base_une_table ' . json_encode($tables, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 99 | - if ($tables) { |
|
| 100 | - $table_op = (int) (lire_config('optimiser_table', 0) + 1) % count($tables); |
|
| 101 | - ecrire_config('optimiser_table', $table_op); |
|
| 102 | - $q = $tables[$table_op]; |
|
| 103 | - spip_log("optimiser_base_une_table : debut d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 104 | - if (sql_optimize($q)) { |
|
| 105 | - spip_log("optimiser_base_une_table : fin d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 106 | - } else { |
|
| 107 | - spip_log("optimiser_base_une_table : Pas d'optimiseur necessaire", 'genie' . _LOG_DEBUG); |
|
| 108 | - } |
|
| 109 | - } |
|
| 88 | + $tables = []; |
|
| 89 | + $result = sql_showbase(); |
|
| 90 | + |
|
| 91 | + // on n'optimise qu'une seule table a chaque fois, |
|
| 92 | + // pour ne pas vautrer le systeme |
|
| 93 | + // lire http://dev.mysql.com/doc/refman/5.0/fr/optimize-table.html |
|
| 94 | + while ($row = sql_fetch($result)) { |
|
| 95 | + $tables[] = array_shift($row); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + spip_log('optimiser_base_une_table ' . json_encode($tables, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 99 | + if ($tables) { |
|
| 100 | + $table_op = (int) (lire_config('optimiser_table', 0) + 1) % count($tables); |
|
| 101 | + ecrire_config('optimiser_table', $table_op); |
|
| 102 | + $q = $tables[$table_op]; |
|
| 103 | + spip_log("optimiser_base_une_table : debut d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 104 | + if (sql_optimize($q)) { |
|
| 105 | + spip_log("optimiser_base_une_table : fin d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 106 | + } else { |
|
| 107 | + spip_log("optimiser_base_une_table : Pas d'optimiseur necessaire", 'genie' . _LOG_DEBUG); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
@@ -132,18 +132,18 @@ discard block |
||
| 132 | 132 | * Nombre de suppressions |
| 133 | 133 | **/ |
| 134 | 134 | function optimiser_sansref($table, $id, $sel, $and = '') { |
| 135 | - $in = []; |
|
| 136 | - while ($row = sql_fetch($sel)) { |
|
| 137 | - $in[$row['id']] = true; |
|
| 138 | - } |
|
| 139 | - sql_free($sel); |
|
| 140 | - |
|
| 141 | - if ($in) { |
|
| 142 | - sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 143 | - spip_log("optimiser_sansref: Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in)), 'genie' . _LOG_DEBUG); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return count($in); |
|
| 135 | + $in = []; |
|
| 136 | + while ($row = sql_fetch($sel)) { |
|
| 137 | + $in[$row['id']] = true; |
|
| 138 | + } |
|
| 139 | + sql_free($sel); |
|
| 140 | + |
|
| 141 | + if ($in) { |
|
| 142 | + sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 143 | + spip_log("optimiser_sansref: Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in)), 'genie' . _LOG_DEBUG); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return count($in); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -165,81 +165,81 @@ discard block |
||
| 165 | 165 | **/ |
| 166 | 166 | function optimiser_base_disparus($attente = 86400) { |
| 167 | 167 | |
| 168 | - # format = 20060610110141, si on veut forcer une optimisation tout de suite |
|
| 169 | - $mydate = date('Y-m-d H:i:s', time() - $attente); |
|
| 170 | - $mydate_quote = sql_quote($mydate); |
|
| 168 | + # format = 20060610110141, si on veut forcer une optimisation tout de suite |
|
| 169 | + $mydate = date('Y-m-d H:i:s', time() - $attente); |
|
| 170 | + $mydate_quote = sql_quote($mydate); |
|
| 171 | 171 | |
| 172 | - $n = 0; |
|
| 172 | + $n = 0; |
|
| 173 | 173 | |
| 174 | - // |
|
| 175 | - // Rubriques |
|
| 176 | - // |
|
| 174 | + // |
|
| 175 | + // Rubriques |
|
| 176 | + // |
|
| 177 | 177 | |
| 178 | - # les articles qui sont dans une id_rubrique inexistante |
|
| 179 | - # attention on controle id_rubrique>0 pour ne pas tuer les articles |
|
| 180 | - # specialement affectes a une rubrique non-existante (plugin, |
|
| 181 | - # cf. https://core.spip.net/issues/1549 ) |
|
| 182 | - $res = sql_select( |
|
| 183 | - 'A.id_article AS id', |
|
| 184 | - 'spip_articles AS A |
|
| 178 | + # les articles qui sont dans une id_rubrique inexistante |
|
| 179 | + # attention on controle id_rubrique>0 pour ne pas tuer les articles |
|
| 180 | + # specialement affectes a une rubrique non-existante (plugin, |
|
| 181 | + # cf. https://core.spip.net/issues/1549 ) |
|
| 182 | + $res = sql_select( |
|
| 183 | + 'A.id_article AS id', |
|
| 184 | + 'spip_articles AS A |
|
| 185 | 185 | LEFT JOIN spip_rubriques AS R |
| 186 | 186 | ON A.id_rubrique=R.id_rubrique', |
| 187 | - "A.id_rubrique > 0 |
|
| 187 | + "A.id_rubrique > 0 |
|
| 188 | 188 | AND R.id_rubrique IS NULL |
| 189 | 189 | AND A.maj < $mydate_quote" |
| 190 | - ); |
|
| 190 | + ); |
|
| 191 | 191 | |
| 192 | - $n += optimiser_sansref('spip_articles', 'id_article', $res); |
|
| 192 | + $n += optimiser_sansref('spip_articles', 'id_article', $res); |
|
| 193 | 193 | |
| 194 | - // les articles a la poubelle |
|
| 195 | - sql_delete('spip_articles', "statut='poubelle' AND maj < $mydate_quote"); |
|
| 194 | + // les articles a la poubelle |
|
| 195 | + sql_delete('spip_articles', "statut='poubelle' AND maj < $mydate_quote"); |
|
| 196 | 196 | |
| 197 | - // |
|
| 198 | - // Auteurs |
|
| 199 | - // |
|
| 197 | + // |
|
| 198 | + // Auteurs |
|
| 199 | + // |
|
| 200 | 200 | |
| 201 | - include_spip('action/editer_liens'); |
|
| 202 | - // optimiser les liens de tous les auteurs vers des objets effaces |
|
| 203 | - // et depuis des auteurs effaces |
|
| 204 | - $n += objet_optimiser_liens(['auteur' => '*'], '*'); |
|
| 201 | + include_spip('action/editer_liens'); |
|
| 202 | + // optimiser les liens de tous les auteurs vers des objets effaces |
|
| 203 | + // et depuis des auteurs effaces |
|
| 204 | + $n += objet_optimiser_liens(['auteur' => '*'], '*'); |
|
| 205 | 205 | |
| 206 | - # effacer les auteurs poubelle qui ne sont lies a rien |
|
| 207 | - $res = sql_select( |
|
| 208 | - 'A.id_auteur AS id', |
|
| 209 | - 'spip_auteurs AS A |
|
| 206 | + # effacer les auteurs poubelle qui ne sont lies a rien |
|
| 207 | + $res = sql_select( |
|
| 208 | + 'A.id_auteur AS id', |
|
| 209 | + 'spip_auteurs AS A |
|
| 210 | 210 | LEFT JOIN spip_auteurs_liens AS L |
| 211 | 211 | ON L.id_auteur=A.id_auteur', |
| 212 | - "L.id_auteur IS NULL |
|
| 212 | + "L.id_auteur IS NULL |
|
| 213 | 213 | AND A.statut='5poubelle' AND A.maj < $mydate_quote" |
| 214 | - ); |
|
| 215 | - |
|
| 216 | - $n += optimiser_sansref('spip_auteurs', 'id_auteur', $res); |
|
| 217 | - |
|
| 218 | - # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
|
| 219 | - # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
|
| 220 | - if (!defined('_AUTEURS_DELAI_REJET_NOUVEAU')) { |
|
| 221 | - define('_AUTEURS_DELAI_REJET_NOUVEAU', 45 * 24 * 3600); |
|
| 222 | - } |
|
| 223 | - sql_delete('spip_auteurs', "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - (int) _AUTEURS_DELAI_REJET_NOUVEAU))); |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
|
| 227 | - * |
|
| 228 | - * L'index 'data' est un entier indiquant le nombre d'optimisations |
|
| 229 | - * qui ont été réalisées (par exemple le nombre de suppressions faites) |
|
| 230 | - * et qui doit être incrémenté par les fonctions |
|
| 231 | - * utilisant ce pipeline si elles suppriment des éléments. |
|
| 232 | - * |
|
| 233 | - * @pipeline_appel optimiser_base_disparus |
|
| 234 | - */ |
|
| 235 | - $n = pipeline('optimiser_base_disparus', [ |
|
| 236 | - 'args' => [ |
|
| 237 | - 'attente' => $attente, |
|
| 238 | - 'date' => $mydate |
|
| 239 | - ], |
|
| 240 | - 'data' => $n |
|
| 241 | - ]); |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - spip_log("optimiser_base_disparus : {$n} lien(s) mort(s)", 'genie' . _LOG_DEBUG); |
|
| 214 | + ); |
|
| 215 | + |
|
| 216 | + $n += optimiser_sansref('spip_auteurs', 'id_auteur', $res); |
|
| 217 | + |
|
| 218 | + # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
|
| 219 | + # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
|
| 220 | + if (!defined('_AUTEURS_DELAI_REJET_NOUVEAU')) { |
|
| 221 | + define('_AUTEURS_DELAI_REJET_NOUVEAU', 45 * 24 * 3600); |
|
| 222 | + } |
|
| 223 | + sql_delete('spip_auteurs', "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - (int) _AUTEURS_DELAI_REJET_NOUVEAU))); |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
|
| 227 | + * |
|
| 228 | + * L'index 'data' est un entier indiquant le nombre d'optimisations |
|
| 229 | + * qui ont été réalisées (par exemple le nombre de suppressions faites) |
|
| 230 | + * et qui doit être incrémenté par les fonctions |
|
| 231 | + * utilisant ce pipeline si elles suppriment des éléments. |
|
| 232 | + * |
|
| 233 | + * @pipeline_appel optimiser_base_disparus |
|
| 234 | + */ |
|
| 235 | + $n = pipeline('optimiser_base_disparus', [ |
|
| 236 | + 'args' => [ |
|
| 237 | + 'attente' => $attente, |
|
| 238 | + 'date' => $mydate |
|
| 239 | + ], |
|
| 240 | + 'data' => $n |
|
| 241 | + ]); |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + spip_log("optimiser_base_disparus : {$n} lien(s) mort(s)", 'genie' . _LOG_DEBUG); |
|
| 245 | 245 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function optimiser_caches_contextes() { |
| 52 | 52 | sous_repertoire(_DIR_CACHE, 'contextes'); |
| 53 | - if (is_dir($d = _DIR_CACHE . 'contextes')) { |
|
| 53 | + if (is_dir($d = _DIR_CACHE.'contextes')) { |
|
| 54 | 54 | include_spip('inc/invalideur'); |
| 55 | 55 | purger_repertoire($d, ['mtime' => time() - 48 * 3600, 'limit' => 10000]); |
| 56 | 56 | } |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | $tables[] = array_shift($row); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - spip_log('optimiser_base_une_table ' . json_encode($tables, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 98 | + spip_log('optimiser_base_une_table '.json_encode($tables, JSON_THROW_ON_ERROR), 'genie'._LOG_DEBUG); |
|
| 99 | 99 | if ($tables) { |
| 100 | 100 | $table_op = (int) (lire_config('optimiser_table', 0) + 1) % count($tables); |
| 101 | 101 | ecrire_config('optimiser_table', $table_op); |
| 102 | 102 | $q = $tables[$table_op]; |
| 103 | - spip_log("optimiser_base_une_table : debut d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 103 | + spip_log("optimiser_base_une_table : debut d'optimisation de la table $q", 'genie'._LOG_DEBUG); |
|
| 104 | 104 | if (sql_optimize($q)) { |
| 105 | - spip_log("optimiser_base_une_table : fin d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 105 | + spip_log("optimiser_base_une_table : fin d'optimisation de la table $q", 'genie'._LOG_DEBUG); |
|
| 106 | 106 | } else { |
| 107 | - spip_log("optimiser_base_une_table : Pas d'optimiseur necessaire", 'genie' . _LOG_DEBUG); |
|
| 107 | + spip_log("optimiser_base_une_table : Pas d'optimiseur necessaire", 'genie'._LOG_DEBUG); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | sql_free($sel); |
| 140 | 140 | |
| 141 | 141 | if ($in) { |
| 142 | - sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 143 | - spip_log("optimiser_sansref: Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in)), 'genie' . _LOG_DEBUG); |
|
| 142 | + sql_delete($table, sql_in($id, array_keys($in)).($and ? " AND $and" : '')); |
|
| 143 | + spip_log("optimiser_sansref: Numeros des entrees $id supprimees dans la table $table: ".implode(', ', array_keys($in)), 'genie'._LOG_DEBUG); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return count($in); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | if (!defined('_AUTEURS_DELAI_REJET_NOUVEAU')) { |
| 221 | 221 | define('_AUTEURS_DELAI_REJET_NOUVEAU', 45 * 24 * 3600); |
| 222 | 222 | } |
| 223 | - sql_delete('spip_auteurs', "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - (int) _AUTEURS_DELAI_REJET_NOUVEAU))); |
|
| 223 | + sql_delete('spip_auteurs', "statut='nouveau' AND maj < ".sql_quote(date('Y-m-d', time() - (int) _AUTEURS_DELAI_REJET_NOUVEAU))); |
|
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | 226 | * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
@@ -241,5 +241,5 @@ discard block |
||
| 241 | 241 | ]); |
| 242 | 242 | |
| 243 | 243 | |
| 244 | - spip_log("optimiser_base_disparus : {$n} lien(s) mort(s)", 'genie' . _LOG_DEBUG); |
|
| 244 | + spip_log("optimiser_base_disparus : {$n} lien(s) mort(s)", 'genie'._LOG_DEBUG); |
|
| 245 | 245 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | * @return int |
| 27 | 27 | */ |
| 28 | 28 | function genie_mise_a_jour_dist($t) { |
| 29 | - include_spip('inc/meta'); |
|
| 30 | - $maj = info_maj($GLOBALS['spip_version_branche']); |
|
| 31 | - ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : '', 'non'); |
|
| 29 | + include_spip('inc/meta'); |
|
| 30 | + $maj = info_maj($GLOBALS['spip_version_branche']); |
|
| 31 | + ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : '', 'non'); |
|
| 32 | 32 | |
| 33 | - mise_a_jour_ecran_securite(); |
|
| 33 | + mise_a_jour_ecran_securite(); |
|
| 34 | 34 | |
| 35 | - spip_log('Verification version SPIP : ' . ($maj ?: 'version a jour'), 'verifie_maj'); |
|
| 35 | + spip_log('Verification version SPIP : ' . ($maj ?: 'version a jour'), 'verifie_maj'); |
|
| 36 | 36 | |
| 37 | - return 1; |
|
| 37 | + return 1; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // TODO : fournir une URL sur spip.net pour maitriser la diffusion d'une nouvelle version de l'ecran via l'update auto |
@@ -51,46 +51,46 @@ discard block |
||
| 51 | 51 | * ou de ne repondre une 304 que si le md5 est bon |
| 52 | 52 | */ |
| 53 | 53 | function mise_a_jour_ecran_securite() { |
| 54 | - // TODO : url https avec verification du certificat |
|
| 55 | - return; |
|
| 56 | - |
|
| 57 | - // si l'ecran n'est pas deja present ou pas updatable, sortir |
|
| 58 | - if ( |
|
| 59 | - !_URL_ECRAN_SECURITE |
|
| 60 | - || !file_exists($filename = _DIR_ETC . 'ecran_securite.php') |
|
| 61 | - || !is_writable($filename) |
|
| 62 | - || !($last_modified = filemtime($filename)) |
|
| 63 | - || !($md5 = md5_file($filename)) |
|
| 64 | - ) { |
|
| 65 | - return false; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - include_spip('inc/distant'); |
|
| 69 | - $tmp_file = _DIR_TMP . 'ecran_securite.php'; |
|
| 70 | - $url = parametre_url(_URL_ECRAN_SECURITE, 'md5', $md5); |
|
| 71 | - $url = parametre_url($url, 'vspip', $GLOBALS['spip_version_branche']); |
|
| 72 | - $res = recuperer_url($url, [ |
|
| 73 | - 'if_modified_since' => $last_modified, |
|
| 74 | - 'file' => $tmp_file |
|
| 75 | - ]); |
|
| 76 | - |
|
| 77 | - // si il y a une version plus recente que l'on a recu correctement |
|
| 78 | - if ( |
|
| 79 | - $res['status'] == 200 |
|
| 80 | - && $res['length'] |
|
| 81 | - && ($tmp_file = $res['file']) |
|
| 82 | - ) { |
|
| 83 | - if ($md5 !== md5_file($tmp_file)) { |
|
| 84 | - // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale |
|
| 85 | - include_once $tmp_file; |
|
| 86 | - // ok, on le copie a la place de l'ecran existant |
|
| 87 | - // en backupant l'ecran avant, au cas ou |
|
| 88 | - @copy($filename, $filename . '-bck-' . date('Y-m-d-His', $last_modified)); |
|
| 89 | - @rename($tmp_file, $filename); |
|
| 90 | - } else { |
|
| 91 | - @unlink($tmp_file); |
|
| 92 | - } |
|
| 93 | - } |
|
| 54 | + // TODO : url https avec verification du certificat |
|
| 55 | + return; |
|
| 56 | + |
|
| 57 | + // si l'ecran n'est pas deja present ou pas updatable, sortir |
|
| 58 | + if ( |
|
| 59 | + !_URL_ECRAN_SECURITE |
|
| 60 | + || !file_exists($filename = _DIR_ETC . 'ecran_securite.php') |
|
| 61 | + || !is_writable($filename) |
|
| 62 | + || !($last_modified = filemtime($filename)) |
|
| 63 | + || !($md5 = md5_file($filename)) |
|
| 64 | + ) { |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + include_spip('inc/distant'); |
|
| 69 | + $tmp_file = _DIR_TMP . 'ecran_securite.php'; |
|
| 70 | + $url = parametre_url(_URL_ECRAN_SECURITE, 'md5', $md5); |
|
| 71 | + $url = parametre_url($url, 'vspip', $GLOBALS['spip_version_branche']); |
|
| 72 | + $res = recuperer_url($url, [ |
|
| 73 | + 'if_modified_since' => $last_modified, |
|
| 74 | + 'file' => $tmp_file |
|
| 75 | + ]); |
|
| 76 | + |
|
| 77 | + // si il y a une version plus recente que l'on a recu correctement |
|
| 78 | + if ( |
|
| 79 | + $res['status'] == 200 |
|
| 80 | + && $res['length'] |
|
| 81 | + && ($tmp_file = $res['file']) |
|
| 82 | + ) { |
|
| 83 | + if ($md5 !== md5_file($tmp_file)) { |
|
| 84 | + // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale |
|
| 85 | + include_once $tmp_file; |
|
| 86 | + // ok, on le copie a la place de l'ecran existant |
|
| 87 | + // en backupant l'ecran avant, au cas ou |
|
| 88 | + @copy($filename, $filename . '-bck-' . date('Y-m-d-His', $last_modified)); |
|
| 89 | + @rename($tmp_file, $filename); |
|
| 90 | + } else { |
|
| 91 | + @unlink($tmp_file); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -106,28 +106,28 @@ discard block |
||
| 106 | 106 | * @return string |
| 107 | 107 | */ |
| 108 | 108 | function info_maj(string $version): string { |
| 109 | - include_spip('inc/plugin'); |
|
| 110 | - |
|
| 111 | - // API V1 |
|
| 112 | - $contenu = info_maj_cache(); |
|
| 113 | - if (!$contenu) { |
|
| 114 | - return ''; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - $maj = info_maj_versions($version, array_keys($contenu['versions'] ?? [])); |
|
| 118 | - if (!$maj['mineure'] && !$maj['majeure']) { |
|
| 119 | - return ''; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $message = []; |
|
| 123 | - if ($maj['mineure']) { |
|
| 124 | - $message[] = _T('nouvelle_version_spip', ['version' => $maj['mineure']]); |
|
| 125 | - } |
|
| 126 | - if ($maj['majeure']) { |
|
| 127 | - $message[] = _T('nouvelle_version_spip_majeure', ['version' => $maj['majeure']]); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return '<a class="info_maj_spip" href="https://www.spip.net/fr_update" title="' . $maj['mineure'] . '">' . implode(' | ', $message) . '</a>'; |
|
| 109 | + include_spip('inc/plugin'); |
|
| 110 | + |
|
| 111 | + // API V1 |
|
| 112 | + $contenu = info_maj_cache(); |
|
| 113 | + if (!$contenu) { |
|
| 114 | + return ''; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + $maj = info_maj_versions($version, array_keys($contenu['versions'] ?? [])); |
|
| 118 | + if (!$maj['mineure'] && !$maj['majeure']) { |
|
| 119 | + return ''; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $message = []; |
|
| 123 | + if ($maj['mineure']) { |
|
| 124 | + $message[] = _T('nouvelle_version_spip', ['version' => $maj['mineure']]); |
|
| 125 | + } |
|
| 126 | + if ($maj['majeure']) { |
|
| 127 | + $message[] = _T('nouvelle_version_spip_majeure', ['version' => $maj['majeure']]); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return '<a class="info_maj_spip" href="https://www.spip.net/fr_update" title="' . $maj['mineure'] . '">' . implode(' | ', $message) . '</a>'; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -142,34 +142,34 @@ discard block |
||
| 142 | 142 | * @return array|null Contenu du fichier de cache de l'info de maj de SPIP. |
| 143 | 143 | */ |
| 144 | 144 | function info_maj_cache(): ?array { |
| 145 | - $contenu = ''; |
|
| 146 | - $options = []; |
|
| 147 | - $nom = _DIR_CACHE . _VERSIONS_LISTE; |
|
| 148 | - if (file_exists($nom)) { |
|
| 149 | - $contenu = file_get_contents($nom); |
|
| 150 | - $options['if_modified_since'] = filemtime($nom); |
|
| 151 | - } |
|
| 152 | - include_spip('inc/distant'); |
|
| 153 | - $res = recuperer_url_cache(_VERSIONS_SERVEUR, $options); |
|
| 154 | - |
|
| 155 | - // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 156 | - if ($res && $res['page']) { |
|
| 157 | - $contenu = $res['page']; |
|
| 158 | - ecrire_fichier($nom, $contenu); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - if (!$contenu) { |
|
| 162 | - return null; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - try { |
|
| 166 | - $json = json_decode((string) $contenu, true, 512, JSON_THROW_ON_ERROR); |
|
| 167 | - } catch (JsonException $e) { |
|
| 168 | - spip_log('Failed to parse Json data : ' . $e->getMessage(), 'verifie_maj'); |
|
| 169 | - return null; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - return $json; |
|
| 145 | + $contenu = ''; |
|
| 146 | + $options = []; |
|
| 147 | + $nom = _DIR_CACHE . _VERSIONS_LISTE; |
|
| 148 | + if (file_exists($nom)) { |
|
| 149 | + $contenu = file_get_contents($nom); |
|
| 150 | + $options['if_modified_since'] = filemtime($nom); |
|
| 151 | + } |
|
| 152 | + include_spip('inc/distant'); |
|
| 153 | + $res = recuperer_url_cache(_VERSIONS_SERVEUR, $options); |
|
| 154 | + |
|
| 155 | + // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 156 | + if ($res && $res['page']) { |
|
| 157 | + $contenu = $res['page']; |
|
| 158 | + ecrire_fichier($nom, $contenu); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + if (!$contenu) { |
|
| 162 | + return null; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + try { |
|
| 166 | + $json = json_decode((string) $contenu, true, 512, JSON_THROW_ON_ERROR); |
|
| 167 | + } catch (JsonException $e) { |
|
| 168 | + spip_log('Failed to parse Json data : ' . $e->getMessage(), 'verifie_maj'); |
|
| 169 | + return null; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + return $json; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -184,40 +184,40 @@ discard block |
||
| 184 | 184 | * @return array<string, string> Version mineure supérieure, version majeure supérieure |
| 185 | 185 | */ |
| 186 | 186 | function info_maj_versions(string $version, array $versions): array { |
| 187 | - $maj = ['mineure' => '', 'majeure' => '']; |
|
| 188 | - if (!$version) { |
|
| 189 | - return $maj; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - // pas de version dev |
|
| 193 | - $versions = array_diff($versions, ['dev']); |
|
| 194 | - |
|
| 195 | - // branche en cours d'utilisation |
|
| 196 | - $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2)); |
|
| 197 | - |
|
| 198 | - foreach ($versions as $v) { |
|
| 199 | - [$maj2, $min2, $rev2] = explode('.', $v); |
|
| 200 | - $branche_maj = $maj2 . '.' . $min2; |
|
| 201 | - $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 202 | - $is_version_stable = is_numeric($rev2); |
|
| 203 | - // d'abord les mises à jour de la même branche (version mineure) |
|
| 204 | - if ( |
|
| 205 | - spip_version_compare($version, $version_maj, '<') |
|
| 206 | - && spip_version_compare($maj['mineure'], $version_maj, '<') |
|
| 207 | - && spip_version_compare($branche, $branche_maj, '=') |
|
| 208 | - ) { |
|
| 209 | - $maj['mineure'] = $version_maj; |
|
| 210 | - } |
|
| 211 | - // puis les mises à jours majeures |
|
| 212 | - if ( |
|
| 213 | - $is_version_stable |
|
| 214 | - && spip_version_compare($version, $version_maj, '<') |
|
| 215 | - && spip_version_compare($maj['majeure'], $version_maj, '<') |
|
| 216 | - && spip_version_compare($branche, $branche_maj, '<') |
|
| 217 | - ) { |
|
| 218 | - $maj['majeure'] = $version_maj; |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - return $maj; |
|
| 187 | + $maj = ['mineure' => '', 'majeure' => '']; |
|
| 188 | + if (!$version) { |
|
| 189 | + return $maj; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + // pas de version dev |
|
| 193 | + $versions = array_diff($versions, ['dev']); |
|
| 194 | + |
|
| 195 | + // branche en cours d'utilisation |
|
| 196 | + $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2)); |
|
| 197 | + |
|
| 198 | + foreach ($versions as $v) { |
|
| 199 | + [$maj2, $min2, $rev2] = explode('.', $v); |
|
| 200 | + $branche_maj = $maj2 . '.' . $min2; |
|
| 201 | + $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 202 | + $is_version_stable = is_numeric($rev2); |
|
| 203 | + // d'abord les mises à jour de la même branche (version mineure) |
|
| 204 | + if ( |
|
| 205 | + spip_version_compare($version, $version_maj, '<') |
|
| 206 | + && spip_version_compare($maj['mineure'], $version_maj, '<') |
|
| 207 | + && spip_version_compare($branche, $branche_maj, '=') |
|
| 208 | + ) { |
|
| 209 | + $maj['mineure'] = $version_maj; |
|
| 210 | + } |
|
| 211 | + // puis les mises à jours majeures |
|
| 212 | + if ( |
|
| 213 | + $is_version_stable |
|
| 214 | + && spip_version_compare($version, $version_maj, '<') |
|
| 215 | + && spip_version_compare($maj['majeure'], $version_maj, '<') |
|
| 216 | + && spip_version_compare($branche, $branche_maj, '<') |
|
| 217 | + ) { |
|
| 218 | + $maj['majeure'] = $version_maj; |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + return $maj; |
|
| 223 | 223 | } |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | function genie_mise_a_jour_dist($t) { |
| 29 | 29 | include_spip('inc/meta'); |
| 30 | 30 | $maj = info_maj($GLOBALS['spip_version_branche']); |
| 31 | - ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : '', 'non'); |
|
| 31 | + ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche']."|$maj") : '', 'non'); |
|
| 32 | 32 | |
| 33 | 33 | mise_a_jour_ecran_securite(); |
| 34 | 34 | |
| 35 | - spip_log('Verification version SPIP : ' . ($maj ?: 'version a jour'), 'verifie_maj'); |
|
| 35 | + spip_log('Verification version SPIP : '.($maj ?: 'version a jour'), 'verifie_maj'); |
|
| 36 | 36 | |
| 37 | 37 | return 1; |
| 38 | 38 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | // si l'ecran n'est pas deja present ou pas updatable, sortir |
| 58 | 58 | if ( |
| 59 | 59 | !_URL_ECRAN_SECURITE |
| 60 | - || !file_exists($filename = _DIR_ETC . 'ecran_securite.php') |
|
| 60 | + || !file_exists($filename = _DIR_ETC.'ecran_securite.php') |
|
| 61 | 61 | || !is_writable($filename) |
| 62 | 62 | || !($last_modified = filemtime($filename)) |
| 63 | 63 | || !($md5 = md5_file($filename)) |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | include_spip('inc/distant'); |
| 69 | - $tmp_file = _DIR_TMP . 'ecran_securite.php'; |
|
| 69 | + $tmp_file = _DIR_TMP.'ecran_securite.php'; |
|
| 70 | 70 | $url = parametre_url(_URL_ECRAN_SECURITE, 'md5', $md5); |
| 71 | 71 | $url = parametre_url($url, 'vspip', $GLOBALS['spip_version_branche']); |
| 72 | 72 | $res = recuperer_url($url, [ |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | include_once $tmp_file; |
| 86 | 86 | // ok, on le copie a la place de l'ecran existant |
| 87 | 87 | // en backupant l'ecran avant, au cas ou |
| 88 | - @copy($filename, $filename . '-bck-' . date('Y-m-d-His', $last_modified)); |
|
| 88 | + @copy($filename, $filename.'-bck-'.date('Y-m-d-His', $last_modified)); |
|
| 89 | 89 | @rename($tmp_file, $filename); |
| 90 | 90 | } else { |
| 91 | 91 | @unlink($tmp_file); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $message[] = _T('nouvelle_version_spip_majeure', ['version' => $maj['majeure']]); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - return '<a class="info_maj_spip" href="https://www.spip.net/fr_update" title="' . $maj['mineure'] . '">' . implode(' | ', $message) . '</a>'; |
|
| 130 | + return '<a class="info_maj_spip" href="https://www.spip.net/fr_update" title="'.$maj['mineure'].'">'.implode(' | ', $message).'</a>'; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | function info_maj_cache(): ?array { |
| 145 | 145 | $contenu = ''; |
| 146 | 146 | $options = []; |
| 147 | - $nom = _DIR_CACHE . _VERSIONS_LISTE; |
|
| 147 | + $nom = _DIR_CACHE._VERSIONS_LISTE; |
|
| 148 | 148 | if (file_exists($nom)) { |
| 149 | 149 | $contenu = file_get_contents($nom); |
| 150 | 150 | $options['if_modified_since'] = filemtime($nom); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | try { |
| 166 | 166 | $json = json_decode((string) $contenu, true, 512, JSON_THROW_ON_ERROR); |
| 167 | 167 | } catch (JsonException $e) { |
| 168 | - spip_log('Failed to parse Json data : ' . $e->getMessage(), 'verifie_maj'); |
|
| 168 | + spip_log('Failed to parse Json data : '.$e->getMessage(), 'verifie_maj'); |
|
| 169 | 169 | return null; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | foreach ($versions as $v) { |
| 199 | 199 | [$maj2, $min2, $rev2] = explode('.', $v); |
| 200 | - $branche_maj = $maj2 . '.' . $min2; |
|
| 201 | - $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 200 | + $branche_maj = $maj2.'.'.$min2; |
|
| 201 | + $version_maj = $maj2.'.'.$min2.'.'.$rev2; |
|
| 202 | 202 | $is_version_stable = is_numeric($rev2); |
| 203 | 203 | // d'abord les mises à jour de la même branche (version mineure) |
| 204 | 204 | if ( |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function genie_maintenance_dist($t) { |
| 36 | 36 | |
| 37 | - // (re)mettre .htaccess avec deny from all |
|
| 38 | - // dans les deux repertoires dits inaccessibles par http |
|
| 39 | - include_spip('inc/acces'); |
|
| 40 | - verifier_htaccess(_DIR_ETC); |
|
| 41 | - verifier_htaccess(_DIR_TMP); |
|
| 42 | - verifier_htaccess(_DIR_VENDOR); |
|
| 37 | + // (re)mettre .htaccess avec deny from all |
|
| 38 | + // dans les deux repertoires dits inaccessibles par http |
|
| 39 | + include_spip('inc/acces'); |
|
| 40 | + verifier_htaccess(_DIR_ETC); |
|
| 41 | + verifier_htaccess(_DIR_TMP); |
|
| 42 | + verifier_htaccess(_DIR_VENDOR); |
|
| 43 | 43 | |
| 44 | - // Verifier qu'aucune table n'est crashee |
|
| 45 | - if (!_request('reinstall')) { |
|
| 46 | - verifier_crash_tables(); |
|
| 47 | - } |
|
| 44 | + // Verifier qu'aucune table n'est crashee |
|
| 45 | + if (!_request('reinstall')) { |
|
| 46 | + verifier_crash_tables(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return 1; |
|
| 49 | + return 1; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -63,33 +63,33 @@ discard block |
||
| 63 | 63 | * des tables qui ont crashé. |
| 64 | 64 | */ |
| 65 | 65 | function verifier_crash_tables() { |
| 66 | - if (spip_connect()) { |
|
| 67 | - include_spip('base/serial'); |
|
| 68 | - include_spip('base/auxiliaires'); |
|
| 69 | - $crash = []; |
|
| 70 | - foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 71 | - foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 72 | - if ( |
|
| 73 | - !sql_select('*', $table, '', '', '', 1) |
|
| 74 | - && !defined('spip_interdire_cache') |
|
| 75 | - ) { # cas "LOST CONNECTION" |
|
| 76 | - $crash[] = $table; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - #$crash[] = 'test'; |
|
| 81 | - if ($crash) { |
|
| 82 | - ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 83 | - spip_log('crash des tables', 'err'); |
|
| 84 | - spip_log($crash, 'err'); |
|
| 85 | - } else { |
|
| 86 | - effacer_meta('message_crash_tables'); |
|
| 87 | - } |
|
| 66 | + if (spip_connect()) { |
|
| 67 | + include_spip('base/serial'); |
|
| 68 | + include_spip('base/auxiliaires'); |
|
| 69 | + $crash = []; |
|
| 70 | + foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 71 | + foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 72 | + if ( |
|
| 73 | + !sql_select('*', $table, '', '', '', 1) |
|
| 74 | + && !defined('spip_interdire_cache') |
|
| 75 | + ) { # cas "LOST CONNECTION" |
|
| 76 | + $crash[] = $table; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + #$crash[] = 'test'; |
|
| 81 | + if ($crash) { |
|
| 82 | + ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 83 | + spip_log('crash des tables', 'err'); |
|
| 84 | + spip_log($crash, 'err'); |
|
| 85 | + } else { |
|
| 86 | + effacer_meta('message_crash_tables'); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - return $crash; |
|
| 90 | - } |
|
| 89 | + return $crash; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return false; |
|
| 92 | + return false; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -105,16 +105,16 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function message_crash_tables() { |
| 108 | - if ($crash = verifier_crash_tables()) { |
|
| 109 | - return |
|
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . implode(', ', $crash) . '</tt><br />' |
|
| 112 | - . generer_form_ecrire( |
|
| 113 | - 'base_repair', |
|
| 114 | - _T('texte_crash_base'), |
|
| 115 | - '', |
|
| 116 | - _T('bouton_tenter_recuperation') |
|
| 117 | - ); |
|
| 118 | - } |
|
| 119 | - return ''; |
|
| 108 | + if ($crash = verifier_crash_tables()) { |
|
| 109 | + return |
|
| 110 | + '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | + . ' <tt>' . implode(', ', $crash) . '</tt><br />' |
|
| 112 | + . generer_form_ecrire( |
|
| 113 | + 'base_repair', |
|
| 114 | + _T('texte_crash_base'), |
|
| 115 | + '', |
|
| 116 | + _T('bouton_tenter_recuperation') |
|
| 117 | + ); |
|
| 118 | + } |
|
| 119 | + return ''; |
|
| 120 | 120 | } |
@@ -107,8 +107,8 @@ |
||
| 107 | 107 | function message_crash_tables() { |
| 108 | 108 | if ($crash = verifier_crash_tables()) { |
| 109 | 109 | return |
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . implode(', ', $crash) . '</tt><br />' |
|
| 110 | + '<strong>'._T('texte_recuperer_base').'</strong><br />' |
|
| 111 | + . ' <tt>'.implode(', ', $crash).'</tt><br />' |
|
| 112 | 112 | . generer_form_ecrire( |
| 113 | 113 | 'base_repair', |
| 114 | 114 | _T('texte_crash_base'), |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -31,35 +31,35 @@ discard block |
||
| 31 | 31 | * @return int |
| 32 | 32 | */ |
| 33 | 33 | function genie_mail_dist($t) { |
| 34 | - $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 35 | - $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 34 | + $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 35 | + $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 36 | 36 | |
| 37 | - $now = time(); |
|
| 38 | - if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) { |
|
| 39 | - ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now - (3600 * 24 * $jours_neuf))); |
|
| 40 | - } |
|
| 37 | + $now = time(); |
|
| 38 | + if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) { |
|
| 39 | + ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now - (3600 * 24 * $jours_neuf))); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $page = recuperer_fond( |
|
| 43 | - 'nouveautes', |
|
| 44 | - ['date' => $GLOBALS['meta']['dernier_envoi_neuf'], 'jours_neuf' => $jours_neuf], |
|
| 45 | - ['raw' => true] |
|
| 46 | - ); |
|
| 42 | + $page = recuperer_fond( |
|
| 43 | + 'nouveautes', |
|
| 44 | + ['date' => $GLOBALS['meta']['dernier_envoi_neuf'], 'jours_neuf' => $jours_neuf], |
|
| 45 | + ['raw' => true] |
|
| 46 | + ); |
|
| 47 | 47 | |
| 48 | - if (strlen(trim((string) $page['texte']))) { |
|
| 49 | - // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 50 | - $headers = ''; |
|
| 51 | - if (isset($page['entetes']) && (is_countable($page['entetes']) ? count($page['entetes']) : 0)) { |
|
| 52 | - foreach ($page['entetes'] as $k => $v) { |
|
| 53 | - $headers .= (strlen((string) $v) ? "$k: $v" : $k) . "\n"; |
|
| 54 | - } |
|
| 55 | - } |
|
| 48 | + if (strlen(trim((string) $page['texte']))) { |
|
| 49 | + // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 50 | + $headers = ''; |
|
| 51 | + if (isset($page['entetes']) && (is_countable($page['entetes']) ? count($page['entetes']) : 0)) { |
|
| 52 | + foreach ($page['entetes'] as $k => $v) { |
|
| 53 | + $headers .= (strlen((string) $v) ? "$k: $v" : $k) . "\n"; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - include_spip('inc/notifications'); |
|
| 58 | - notifications_envoyer_mails($adresse_neuf, $page['texte'], '', '', $headers); |
|
| 59 | - ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now)); |
|
| 60 | - } else { |
|
| 61 | - spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 62 | - } |
|
| 57 | + include_spip('inc/notifications'); |
|
| 58 | + notifications_envoyer_mails($adresse_neuf, $page['texte'], '', '', $headers); |
|
| 59 | + ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now)); |
|
| 60 | + } else { |
|
| 61 | + spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return 1; |
|
| 64 | + return 1; |
|
| 65 | 65 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | $headers = ''; |
| 51 | 51 | if (isset($page['entetes']) && (is_countable($page['entetes']) ? count($page['entetes']) : 0)) { |
| 52 | 52 | foreach ($page['entetes'] as $k => $v) { |
| 53 | - $headers .= (strlen((string) $v) ? "$k: $v" : $k) . "\n"; |
|
| 53 | + $headers .= (strlen((string) $v) ? "$k: $v" : $k)."\n"; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -20,188 +20,188 @@ |
||
| 20 | 20 | // par souci de compatiilite). |
| 21 | 21 | |
| 22 | 22 | if (isset($GLOBALS['_INC_PUBLIC']) && $GLOBALS['_INC_PUBLIC']) { |
| 23 | - echo recuperer_fond($fond, $contexte_inclus, [], _request('connect') ?? ''); |
|
| 23 | + echo recuperer_fond($fond, $contexte_inclus, [], _request('connect') ?? ''); |
|
| 24 | 24 | } else { |
| 25 | - $GLOBALS['_INC_PUBLIC'] = 1; |
|
| 26 | - define('_PIPELINE_SUFFIX', test_espace_prive() ? '_prive' : ''); |
|
| 27 | - |
|
| 28 | - // Faut-il initialiser SPIP ? (oui dans le cas general) |
|
| 29 | - if (!defined('_DIR_RESTREINT_ABS')) { |
|
| 30 | - if ( |
|
| 31 | - defined('_DIR_RESTREINT') |
|
| 32 | - && @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 33 | - ) { |
|
| 34 | - include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 35 | - } else { |
|
| 36 | - die('inc_version absent ?'); |
|
| 37 | - } |
|
| 38 | - } // $fond defini dans le fichier d'appel ? |
|
| 39 | - |
|
| 40 | - else { |
|
| 41 | - if (isset($fond) && !_request('fond')) { |
|
| 42 | - } // fond demande dans l'url par page=xxxx ? |
|
| 43 | - else { |
|
| 44 | - if (isset($_GET[_SPIP_PAGE])) { |
|
| 45 | - $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 46 | - |
|
| 47 | - // Securite |
|
| 48 | - if ( |
|
| 49 | - strstr($fond, '/') |
|
| 50 | - && !(isset($GLOBALS['visiteur_session']) && include_spip('inc/autoriser') && autoriser('webmestre')) |
|
| 51 | - ) { |
|
| 52 | - include_spip('inc/minipres'); |
|
| 53 | - echo minipres(); |
|
| 54 | - exit; |
|
| 55 | - } |
|
| 56 | - // l'argument Page a priorite sur l'argument action |
|
| 57 | - // le cas se presente a cause des RewriteRule d'Apache |
|
| 58 | - // qui permettent d'ajouter un argument dans la QueryString |
|
| 59 | - // mais pas d'en retirer un en conservant les autres. |
|
| 60 | - if (isset($_GET['action']) && $_GET['action'] === $fond) { |
|
| 61 | - unset($_GET['action']); |
|
| 62 | - } |
|
| 63 | - # sinon, fond par defaut |
|
| 64 | - } else { |
|
| 65 | - // sinon fond par defaut (cf. assembler.php) |
|
| 66 | - $fond = pipeline('detecter_fond_par_defaut', ''); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $tableau_des_temps = []; |
|
| 72 | - |
|
| 73 | - // Particularites de certains squelettes |
|
| 74 | - if ($fond == 'login') { |
|
| 75 | - $forcer_lang = true; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if ( |
|
| 79 | - isset($forcer_lang) && $forcer_lang && $forcer_lang !== 'non' |
|
| 80 | - && !_request('action') |
|
| 81 | - && $_SERVER['REQUEST_METHOD'] != 'POST' |
|
| 82 | - ) { |
|
| 83 | - include_spip('inc/lang'); |
|
| 84 | - verifier_lang_url(); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $lang = isset($_GET['lang']) ? lang_select($_GET['lang']) : ''; |
|
| 88 | - |
|
| 89 | - // Charger l'aiguilleur des traitements derogatoires |
|
| 90 | - // (action en base SQL, formulaires CVT, AJax) |
|
| 91 | - if (_request('action') || _request('var_ajax') || _request('formulaire_action')) { |
|
| 92 | - include_spip('public/aiguiller'); |
|
| 93 | - if ( |
|
| 94 | - // cas des appels actions ?action=xxx |
|
| 95 | - traiter_appels_actions() |
|
| 96 | - // cas des hits ajax sur les inclusions ajax |
|
| 97 | - || traiter_appels_inclusions_ajax() |
|
| 98 | - // cas des formulaires charger/verifier/traiter |
|
| 99 | - || traiter_formulaires_dynamiques() |
|
| 100 | - ) { |
|
| 101 | - // lancer les taches sur affichage final, comme le cron |
|
| 102 | - // mais sans rien afficher |
|
| 103 | - $GLOBALS['html'] = false; // ne rien afficher |
|
| 104 | - pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 105 | - exit; // le hit est fini ! |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // Il y a du texte a produire, charger le metteur en page |
|
| 110 | - include_spip('public/assembler'); |
|
| 111 | - $page = assembler($fond, _request('connect') ?? ''); |
|
| 112 | - |
|
| 113 | - if (isset($page['status'])) { |
|
| 114 | - include_spip('inc/headers'); |
|
| 115 | - http_response_code($page['status']); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // Content-Type ? |
|
| 119 | - if (!isset($page['entetes']['Content-Type'])) { |
|
| 120 | - $charset = $GLOBALS['meta']['charset'] ?? 'utf-8'; |
|
| 121 | - $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 122 | - $html = true; |
|
| 123 | - } else { |
|
| 124 | - $html = preg_match(',^\s*text/html,', (string) $page['entetes']['Content-Type']); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - // Tester si on est admin et il y a des choses supplementaires a dire |
|
| 128 | - // type tableau pour y mettre des choses au besoin. |
|
| 129 | - $debug = (_request('var_mode') == 'debug' || $tableau_des_temps) ? [1] : []; |
|
| 130 | - |
|
| 131 | - // affiche-t-on les boutons d'administration ? voir f_admin() |
|
| 132 | - $affiche_boutons_admin = ($html && ( |
|
| 133 | - isset($_COOKIE['spip_admin']) && (!isset($flag_preserver) || !$flag_preserver) |
|
| 134 | - || $debug && include_spip('inc/autoriser') && autoriser('debug') |
|
| 135 | - || defined('_VAR_PREVIEW') && _VAR_PREVIEW) |
|
| 136 | - ); |
|
| 137 | - |
|
| 138 | - if ($affiche_boutons_admin) { |
|
| 139 | - include_spip('balise/formulaire_admin'); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - // Execution de la page calculee |
|
| 144 | - |
|
| 145 | - // traitements sur les entetes avant envoi |
|
| 146 | - // peut servir pour le plugin de stats |
|
| 147 | - $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - // eval $page et affecte $res |
|
| 151 | - include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 152 | - envoyer_entetes($page['entetes']); |
|
| 153 | - if ($res === false) { |
|
| 154 | - include_spip('inc/autoriser'); |
|
| 155 | - $err = _T('zbug_erreur_execution_page'); |
|
| 156 | - if (autoriser('webmestre')) { |
|
| 157 | - $err .= "\n<hr />\n" |
|
| 158 | - . highlight_string($page['codephp'], true) |
|
| 159 | - . "\n<hr />\n"; |
|
| 160 | - } |
|
| 161 | - $msg = [$err]; |
|
| 162 | - erreur_squelette($msg); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // |
|
| 166 | - // Envoyer le resultat apres post-traitements |
|
| 167 | - // |
|
| 168 | - // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
|
| 169 | - // cf. public/assembler.php) |
|
| 170 | - echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 171 | - |
|
| 172 | - if ($lang) { |
|
| 173 | - lang_select(); |
|
| 174 | - } |
|
| 175 | - // l'affichage de la page a pu lever des erreurs (inclusion manquante) |
|
| 176 | - // il faut tester a nouveau |
|
| 177 | - $debug = (_request('var_mode') == 'debug' || $tableau_des_temps) ? [1] : []; |
|
| 178 | - |
|
| 179 | - // Appel au debusqueur en cas d'erreurs ou de demande de trace |
|
| 180 | - // at last |
|
| 181 | - if ($debug) { |
|
| 182 | - // en cas d'erreur, retester l'affichage |
|
| 183 | - if ($html && ($affiche_boutons_admin || $debug)) { |
|
| 184 | - $var_mode_affiche = _request('var_mode_affiche'); |
|
| 185 | - $var_mode_objet = _request('var_mode_objet'); |
|
| 186 | - $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ''); |
|
| 187 | - echo erreur_squelette(false); |
|
| 188 | - } |
|
| 189 | - } else { |
|
| 190 | - if ( |
|
| 191 | - isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 192 | - && $GLOBALS['meta']['date_prochain_postdate'] <= time() |
|
| 193 | - ) { |
|
| 194 | - include_spip('inc/rubriques'); |
|
| 195 | - calculer_prochain_postdate(true); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // Effectuer une tache de fond ? |
|
| 199 | - // si _DIRECT_CRON_FORCE est present, on force l'appel |
|
| 200 | - if (defined('_DIRECT_CRON_FORCE')) { |
|
| 201 | - cron(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - // sauver le cache chemin si necessaire |
|
| 205 | - save_path_cache(); |
|
| 206 | - } |
|
| 25 | + $GLOBALS['_INC_PUBLIC'] = 1; |
|
| 26 | + define('_PIPELINE_SUFFIX', test_espace_prive() ? '_prive' : ''); |
|
| 27 | + |
|
| 28 | + // Faut-il initialiser SPIP ? (oui dans le cas general) |
|
| 29 | + if (!defined('_DIR_RESTREINT_ABS')) { |
|
| 30 | + if ( |
|
| 31 | + defined('_DIR_RESTREINT') |
|
| 32 | + && @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 33 | + ) { |
|
| 34 | + include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 35 | + } else { |
|
| 36 | + die('inc_version absent ?'); |
|
| 37 | + } |
|
| 38 | + } // $fond defini dans le fichier d'appel ? |
|
| 39 | + |
|
| 40 | + else { |
|
| 41 | + if (isset($fond) && !_request('fond')) { |
|
| 42 | + } // fond demande dans l'url par page=xxxx ? |
|
| 43 | + else { |
|
| 44 | + if (isset($_GET[_SPIP_PAGE])) { |
|
| 45 | + $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 46 | + |
|
| 47 | + // Securite |
|
| 48 | + if ( |
|
| 49 | + strstr($fond, '/') |
|
| 50 | + && !(isset($GLOBALS['visiteur_session']) && include_spip('inc/autoriser') && autoriser('webmestre')) |
|
| 51 | + ) { |
|
| 52 | + include_spip('inc/minipres'); |
|
| 53 | + echo minipres(); |
|
| 54 | + exit; |
|
| 55 | + } |
|
| 56 | + // l'argument Page a priorite sur l'argument action |
|
| 57 | + // le cas se presente a cause des RewriteRule d'Apache |
|
| 58 | + // qui permettent d'ajouter un argument dans la QueryString |
|
| 59 | + // mais pas d'en retirer un en conservant les autres. |
|
| 60 | + if (isset($_GET['action']) && $_GET['action'] === $fond) { |
|
| 61 | + unset($_GET['action']); |
|
| 62 | + } |
|
| 63 | + # sinon, fond par defaut |
|
| 64 | + } else { |
|
| 65 | + // sinon fond par defaut (cf. assembler.php) |
|
| 66 | + $fond = pipeline('detecter_fond_par_defaut', ''); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $tableau_des_temps = []; |
|
| 72 | + |
|
| 73 | + // Particularites de certains squelettes |
|
| 74 | + if ($fond == 'login') { |
|
| 75 | + $forcer_lang = true; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if ( |
|
| 79 | + isset($forcer_lang) && $forcer_lang && $forcer_lang !== 'non' |
|
| 80 | + && !_request('action') |
|
| 81 | + && $_SERVER['REQUEST_METHOD'] != 'POST' |
|
| 82 | + ) { |
|
| 83 | + include_spip('inc/lang'); |
|
| 84 | + verifier_lang_url(); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $lang = isset($_GET['lang']) ? lang_select($_GET['lang']) : ''; |
|
| 88 | + |
|
| 89 | + // Charger l'aiguilleur des traitements derogatoires |
|
| 90 | + // (action en base SQL, formulaires CVT, AJax) |
|
| 91 | + if (_request('action') || _request('var_ajax') || _request('formulaire_action')) { |
|
| 92 | + include_spip('public/aiguiller'); |
|
| 93 | + if ( |
|
| 94 | + // cas des appels actions ?action=xxx |
|
| 95 | + traiter_appels_actions() |
|
| 96 | + // cas des hits ajax sur les inclusions ajax |
|
| 97 | + || traiter_appels_inclusions_ajax() |
|
| 98 | + // cas des formulaires charger/verifier/traiter |
|
| 99 | + || traiter_formulaires_dynamiques() |
|
| 100 | + ) { |
|
| 101 | + // lancer les taches sur affichage final, comme le cron |
|
| 102 | + // mais sans rien afficher |
|
| 103 | + $GLOBALS['html'] = false; // ne rien afficher |
|
| 104 | + pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 105 | + exit; // le hit est fini ! |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // Il y a du texte a produire, charger le metteur en page |
|
| 110 | + include_spip('public/assembler'); |
|
| 111 | + $page = assembler($fond, _request('connect') ?? ''); |
|
| 112 | + |
|
| 113 | + if (isset($page['status'])) { |
|
| 114 | + include_spip('inc/headers'); |
|
| 115 | + http_response_code($page['status']); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // Content-Type ? |
|
| 119 | + if (!isset($page['entetes']['Content-Type'])) { |
|
| 120 | + $charset = $GLOBALS['meta']['charset'] ?? 'utf-8'; |
|
| 121 | + $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 122 | + $html = true; |
|
| 123 | + } else { |
|
| 124 | + $html = preg_match(',^\s*text/html,', (string) $page['entetes']['Content-Type']); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + // Tester si on est admin et il y a des choses supplementaires a dire |
|
| 128 | + // type tableau pour y mettre des choses au besoin. |
|
| 129 | + $debug = (_request('var_mode') == 'debug' || $tableau_des_temps) ? [1] : []; |
|
| 130 | + |
|
| 131 | + // affiche-t-on les boutons d'administration ? voir f_admin() |
|
| 132 | + $affiche_boutons_admin = ($html && ( |
|
| 133 | + isset($_COOKIE['spip_admin']) && (!isset($flag_preserver) || !$flag_preserver) |
|
| 134 | + || $debug && include_spip('inc/autoriser') && autoriser('debug') |
|
| 135 | + || defined('_VAR_PREVIEW') && _VAR_PREVIEW) |
|
| 136 | + ); |
|
| 137 | + |
|
| 138 | + if ($affiche_boutons_admin) { |
|
| 139 | + include_spip('balise/formulaire_admin'); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + // Execution de la page calculee |
|
| 144 | + |
|
| 145 | + // traitements sur les entetes avant envoi |
|
| 146 | + // peut servir pour le plugin de stats |
|
| 147 | + $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + // eval $page et affecte $res |
|
| 151 | + include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 152 | + envoyer_entetes($page['entetes']); |
|
| 153 | + if ($res === false) { |
|
| 154 | + include_spip('inc/autoriser'); |
|
| 155 | + $err = _T('zbug_erreur_execution_page'); |
|
| 156 | + if (autoriser('webmestre')) { |
|
| 157 | + $err .= "\n<hr />\n" |
|
| 158 | + . highlight_string($page['codephp'], true) |
|
| 159 | + . "\n<hr />\n"; |
|
| 160 | + } |
|
| 161 | + $msg = [$err]; |
|
| 162 | + erreur_squelette($msg); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // |
|
| 166 | + // Envoyer le resultat apres post-traitements |
|
| 167 | + // |
|
| 168 | + // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
|
| 169 | + // cf. public/assembler.php) |
|
| 170 | + echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 171 | + |
|
| 172 | + if ($lang) { |
|
| 173 | + lang_select(); |
|
| 174 | + } |
|
| 175 | + // l'affichage de la page a pu lever des erreurs (inclusion manquante) |
|
| 176 | + // il faut tester a nouveau |
|
| 177 | + $debug = (_request('var_mode') == 'debug' || $tableau_des_temps) ? [1] : []; |
|
| 178 | + |
|
| 179 | + // Appel au debusqueur en cas d'erreurs ou de demande de trace |
|
| 180 | + // at last |
|
| 181 | + if ($debug) { |
|
| 182 | + // en cas d'erreur, retester l'affichage |
|
| 183 | + if ($html && ($affiche_boutons_admin || $debug)) { |
|
| 184 | + $var_mode_affiche = _request('var_mode_affiche'); |
|
| 185 | + $var_mode_objet = _request('var_mode_objet'); |
|
| 186 | + $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ''); |
|
| 187 | + echo erreur_squelette(false); |
|
| 188 | + } |
|
| 189 | + } else { |
|
| 190 | + if ( |
|
| 191 | + isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 192 | + && $GLOBALS['meta']['date_prochain_postdate'] <= time() |
|
| 193 | + ) { |
|
| 194 | + include_spip('inc/rubriques'); |
|
| 195 | + calculer_prochain_postdate(true); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // Effectuer une tache de fond ? |
|
| 199 | + // si _DIRECT_CRON_FORCE est present, on force l'appel |
|
| 200 | + if (defined('_DIRECT_CRON_FORCE')) { |
|
| 201 | + cron(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + // sauver le cache chemin si necessaire |
|
| 205 | + save_path_cache(); |
|
| 206 | + } |
|
| 207 | 207 | } |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 30 | 30 | if ( |
| 31 | 31 | defined('_DIR_RESTREINT') |
| 32 | - && @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 32 | + && @file_exists(_ROOT_RESTREINT.'inc_version.php') |
|
| 33 | 33 | ) { |
| 34 | - include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 34 | + include_once _ROOT_RESTREINT.'inc_version.php'; |
|
| 35 | 35 | } else { |
| 36 | 36 | die('inc_version absent ?'); |
| 37 | 37 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } // fond demande dans l'url par page=xxxx ? |
| 43 | 43 | else { |
| 44 | 44 | if (isset($_GET[_SPIP_PAGE])) { |
| 45 | - $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 45 | + $fond = (string) $_GET[_SPIP_PAGE]; |
|
| 46 | 46 | |
| 47 | 47 | // Securite |
| 48 | 48 | if ( |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | // lancer les taches sur affichage final, comme le cron |
| 102 | 102 | // mais sans rien afficher |
| 103 | 103 | $GLOBALS['html'] = false; // ne rien afficher |
| 104 | - pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 104 | + pipeline('affichage_final'._PIPELINE_SUFFIX, ''); |
|
| 105 | 105 | exit; // le hit est fini ! |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | // Content-Type ? |
| 119 | 119 | if (!isset($page['entetes']['Content-Type'])) { |
| 120 | 120 | $charset = $GLOBALS['meta']['charset'] ?? 'utf-8'; |
| 121 | - $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 121 | + $page['entetes']['Content-Type'] = 'text/html; charset='.$charset; |
|
| 122 | 122 | $html = true; |
| 123 | 123 | } else { |
| 124 | 124 | $html = preg_match(',^\s*text/html,', (string) $page['entetes']['Content-Type']); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | // traitements sur les entetes avant envoi |
| 146 | 146 | // peut servir pour le plugin de stats |
| 147 | - $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 147 | + $page['entetes'] = pipeline('affichage_entetes_final'._PIPELINE_SUFFIX, $page['entetes']); |
|
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | // eval $page et affecte $res |
| 151 | - include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 151 | + include _ROOT_RESTREINT.'public/evaluer_page.php'; |
|
| 152 | 152 | envoyer_entetes($page['entetes']); |
| 153 | 153 | if ($res === false) { |
| 154 | 154 | include_spip('inc/autoriser'); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | // |
| 168 | 168 | // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
| 169 | 169 | // cf. public/assembler.php) |
| 170 | - echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 170 | + echo pipeline('affichage_final'._PIPELINE_SUFFIX, $page['texte']); |
|
| 171 | 171 | |
| 172 | 172 | if ($lang) { |
| 173 | 173 | lang_select(); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | if ($html && ($affiche_boutons_admin || $debug)) { |
| 184 | 184 | $var_mode_affiche = _request('var_mode_affiche'); |
| 185 | 185 | $var_mode_objet = _request('var_mode_objet'); |
| 186 | - $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ''); |
|
| 186 | + $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet.'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ''); |
|
| 187 | 187 | echo erreur_squelette(false); |
| 188 | 188 | } |
| 189 | 189 | } else { |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Formulaires |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/filtres'); |
@@ -34,26 +34,26 @@ discard block |
||
| 34 | 34 | * @see spip_htmlspecialchars() |
| 35 | 35 | */ |
| 36 | 36 | function protege_champ(mixed $valeur, $max_prof = 128) { |
| 37 | - if (is_array($valeur)) { |
|
| 38 | - if ($max_prof > 0) { |
|
| 39 | - return array_map( |
|
| 40 | - fn($v) => protege_champ($v, $max_prof - 1), |
|
| 41 | - $valeur |
|
| 42 | - ); |
|
| 43 | - } |
|
| 44 | - // si on dépasse la prof max on tronque |
|
| 45 | - return []; |
|
| 46 | - } elseif ($valeur === null) { |
|
| 47 | - return $valeur; |
|
| 48 | - } elseif (is_bool($valeur)) { |
|
| 49 | - return $valeur ? '1' : ''; |
|
| 50 | - } elseif (is_string($valeur) && $valeur) { |
|
| 51 | - if (strpbrk($valeur, "&\"'<>") !== false) { |
|
| 52 | - return spip_htmlspecialchars($valeur, ENT_QUOTES); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $valeur; |
|
| 37 | + if (is_array($valeur)) { |
|
| 38 | + if ($max_prof > 0) { |
|
| 39 | + return array_map( |
|
| 40 | + fn($v) => protege_champ($v, $max_prof - 1), |
|
| 41 | + $valeur |
|
| 42 | + ); |
|
| 43 | + } |
|
| 44 | + // si on dépasse la prof max on tronque |
|
| 45 | + return []; |
|
| 46 | + } elseif ($valeur === null) { |
|
| 47 | + return $valeur; |
|
| 48 | + } elseif (is_bool($valeur)) { |
|
| 49 | + return $valeur ? '1' : ''; |
|
| 50 | + } elseif (is_string($valeur) && $valeur) { |
|
| 51 | + if (strpbrk($valeur, "&\"'<>") !== false) { |
|
| 52 | + return spip_htmlspecialchars($valeur, ENT_QUOTES); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $valeur; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * - false : pas de squelette trouvé |
| 68 | 68 | **/ |
| 69 | 69 | function existe_formulaire($form) { |
| 70 | - $form = str_starts_with($form, 'FORMULAIRE_') ? strtolower(substr($form, 11)) : strtolower($form); |
|
| 70 | + $form = str_starts_with($form, 'FORMULAIRE_') ? strtolower(substr($form, 11)) : strtolower($form); |
|
| 71 | 71 | |
| 72 | - if (!$form) { |
|
| 73 | - return ''; |
|
| 74 | - } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 72 | + if (!$form) { |
|
| 73 | + return ''; |
|
| 74 | + } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 75 | 75 | |
| 76 | - return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 76 | + return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -82,30 +82,30 @@ discard block |
||
| 82 | 82 | * @return false|array |
| 83 | 83 | */ |
| 84 | 84 | function test_formulaire_inclus_par_modele() { |
| 85 | - $trace = debug_backtrace(0, 20); |
|
| 86 | - $trace_fonctions = array_column($trace, 'function'); |
|
| 87 | - $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 88 | - |
|
| 89 | - // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 90 | - if ( |
|
| 91 | - function_exists('arguments_balise_dyn_depuis_modele') |
|
| 92 | - && ($form = arguments_balise_dyn_depuis_modele(null, 'read')) |
|
| 93 | - && in_array('balise_formulaire__dyn', $trace_fonctions) |
|
| 94 | - ) { |
|
| 95 | - $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 96 | - if ($trace[$k]['args'][0] === $form) { |
|
| 97 | - return $trace[$k]['args']; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 102 | - // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 103 | - if (in_array('eval', $trace_fonctions) && in_array('inclure_modele', $trace_fonctions)) { |
|
| 104 | - $k = array_search('inclure_modele', $trace_fonctions); |
|
| 105 | - // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 106 | - return $trace[$k - 1]['args'][1]['args']; |
|
| 107 | - } |
|
| 108 | - return false; |
|
| 85 | + $trace = debug_backtrace(0, 20); |
|
| 86 | + $trace_fonctions = array_column($trace, 'function'); |
|
| 87 | + $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 88 | + |
|
| 89 | + // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 90 | + if ( |
|
| 91 | + function_exists('arguments_balise_dyn_depuis_modele') |
|
| 92 | + && ($form = arguments_balise_dyn_depuis_modele(null, 'read')) |
|
| 93 | + && in_array('balise_formulaire__dyn', $trace_fonctions) |
|
| 94 | + ) { |
|
| 95 | + $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 96 | + if ($trace[$k]['args'][0] === $form) { |
|
| 97 | + return $trace[$k]['args']; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 102 | + // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 103 | + if (in_array('eval', $trace_fonctions) && in_array('inclure_modele', $trace_fonctions)) { |
|
| 104 | + $k = array_search('inclure_modele', $trace_fonctions); |
|
| 105 | + // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 106 | + return $trace[$k - 1]['args'][1]['args']; |
|
| 107 | + } |
|
| 108 | + return false; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -120,19 +120,19 @@ discard block |
||
| 120 | 120 | **/ |
| 121 | 121 | function balise_FORMULAIRE__dist($p) { |
| 122 | 122 | |
| 123 | - // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 124 | - // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 125 | - if (existe_formulaire($p->nom_champ) === false) { |
|
| 126 | - $p->code = "''"; |
|
| 127 | - $p->interdire_scripts = false; |
|
| 123 | + // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 124 | + // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 125 | + if (existe_formulaire($p->nom_champ) === false) { |
|
| 126 | + $p->code = "''"; |
|
| 127 | + $p->interdire_scripts = false; |
|
| 128 | 128 | |
| 129 | - return $p; |
|
| 130 | - } |
|
| 129 | + return $p; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - // sinon renvoyer un code php dynamique |
|
| 133 | - $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 132 | + // sinon renvoyer un code php dynamique |
|
| 133 | + $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 134 | 134 | |
| 135 | - return $p; |
|
| 135 | + return $p; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -152,17 +152,17 @@ discard block |
||
| 152 | 152 | * - string : texte à afficher directement |
| 153 | 153 | */ |
| 154 | 154 | function balise_FORMULAIRE__dyn($form, ...$args) { |
| 155 | - $form = existe_formulaire($form); |
|
| 156 | - if (!$form) { |
|
| 157 | - return ''; |
|
| 158 | - } |
|
| 155 | + $form = existe_formulaire($form); |
|
| 156 | + if (!$form) { |
|
| 157 | + return ''; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 161 | - if (!is_array($contexte)) { |
|
| 162 | - return $contexte; |
|
| 163 | - } |
|
| 160 | + $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 161 | + if (!is_array($contexte)) { |
|
| 162 | + return $contexte; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - return ["formulaires/$form", 3600, $contexte]; |
|
| 165 | + return ["formulaires/$form", 3600, $contexte]; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -177,85 +177,85 @@ discard block |
||
| 177 | 177 | * string: Formulaire non applicable (message d’explication) |
| 178 | 178 | **/ |
| 179 | 179 | function balise_FORMULAIRE__contexte($form, $args) { |
| 180 | - // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 181 | - // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 182 | - // si poste, on recupere les erreurs |
|
| 183 | - |
|
| 184 | - $je_suis_poste = false; |
|
| 185 | - if ( |
|
| 186 | - ($post_form = _request('formulaire_action')) |
|
| 187 | - && $post_form == $form |
|
| 188 | - && ($p = _request('formulaire_action_args')) |
|
| 189 | - && is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 190 | - ) { |
|
| 191 | - // enlever le faux attribut de langue masque |
|
| 192 | - array_shift($p); |
|
| 193 | - if (formulaire__identifier($form, $args, $p)) { |
|
| 194 | - $je_suis_poste = true; |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - $editable = true; |
|
| 199 | - $erreurs = $post = []; |
|
| 200 | - if ($je_suis_poste) { |
|
| 201 | - $post = traiter_formulaires_dynamiques(true); |
|
| 202 | - $e = "erreurs_$form"; |
|
| 203 | - $erreurs = $post[$e] ?? []; |
|
| 204 | - $editable = "editable_$form"; |
|
| 205 | - $editable = (!isset($post[$e])) |
|
| 206 | - || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 207 | - || (isset($post[$editable]) && $post[$editable]); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 211 | - |
|
| 212 | - // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 213 | - // C'est plus fort qu'editable qui est gere par le squelette |
|
| 214 | - // Idealement $valeur doit etre alors un message explicatif. |
|
| 215 | - if (!is_array($valeurs)) { |
|
| 216 | - return is_string($valeurs) ? $valeurs : ''; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 220 | - // ou une action vide si elle ne sert pas |
|
| 221 | - $action = $valeurs['action'] ?? self('&', true); |
|
| 222 | - // bug IEx : si action finit par / |
|
| 223 | - // IE croit que le <form ... action=../ > est autoferme |
|
| 224 | - if (str_ends_with((string) $action, '/')) { |
|
| 225 | - // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 226 | - $action .= '#'; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - // recuperer la saisie en cours si erreurs |
|
| 230 | - // seulement si c'est ce formulaire qui est poste |
|
| 231 | - // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 232 | - $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 233 | - foreach (array_keys($valeurs) as $champ) { |
|
| 234 | - if ($champ[0] !== '_' && !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 235 | - if ($dispo && ($v = _request($champ)) !== null) { |
|
| 236 | - $valeurs[$champ] = $v; |
|
| 237 | - } |
|
| 238 | - // nettoyer l'url des champs qui vont etre saisis |
|
| 239 | - if ($action) { |
|
| 240 | - $action = parametre_url($action, $champ, ''); |
|
| 241 | - } |
|
| 242 | - // proteger les ' et les " dans les champs que l'on va injecter |
|
| 243 | - $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - if ($action) { |
|
| 248 | - // nettoyer l'url |
|
| 249 | - $action = parametre_url($action, 'formulaire_action', ''); |
|
| 250 | - $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 251 | - $action = parametre_url($action, 'formulaire_action_sign', ''); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * @deprecated 4.0 |
|
| 256 | - * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide |
|
| 257 | - */ |
|
| 258 | - /* |
|
| 180 | + // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 181 | + // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 182 | + // si poste, on recupere les erreurs |
|
| 183 | + |
|
| 184 | + $je_suis_poste = false; |
|
| 185 | + if ( |
|
| 186 | + ($post_form = _request('formulaire_action')) |
|
| 187 | + && $post_form == $form |
|
| 188 | + && ($p = _request('formulaire_action_args')) |
|
| 189 | + && is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 190 | + ) { |
|
| 191 | + // enlever le faux attribut de langue masque |
|
| 192 | + array_shift($p); |
|
| 193 | + if (formulaire__identifier($form, $args, $p)) { |
|
| 194 | + $je_suis_poste = true; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + $editable = true; |
|
| 199 | + $erreurs = $post = []; |
|
| 200 | + if ($je_suis_poste) { |
|
| 201 | + $post = traiter_formulaires_dynamiques(true); |
|
| 202 | + $e = "erreurs_$form"; |
|
| 203 | + $erreurs = $post[$e] ?? []; |
|
| 204 | + $editable = "editable_$form"; |
|
| 205 | + $editable = (!isset($post[$e])) |
|
| 206 | + || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 207 | + || (isset($post[$editable]) && $post[$editable]); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 211 | + |
|
| 212 | + // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 213 | + // C'est plus fort qu'editable qui est gere par le squelette |
|
| 214 | + // Idealement $valeur doit etre alors un message explicatif. |
|
| 215 | + if (!is_array($valeurs)) { |
|
| 216 | + return is_string($valeurs) ? $valeurs : ''; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 220 | + // ou une action vide si elle ne sert pas |
|
| 221 | + $action = $valeurs['action'] ?? self('&', true); |
|
| 222 | + // bug IEx : si action finit par / |
|
| 223 | + // IE croit que le <form ... action=../ > est autoferme |
|
| 224 | + if (str_ends_with((string) $action, '/')) { |
|
| 225 | + // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 226 | + $action .= '#'; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // recuperer la saisie en cours si erreurs |
|
| 230 | + // seulement si c'est ce formulaire qui est poste |
|
| 231 | + // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 232 | + $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 233 | + foreach (array_keys($valeurs) as $champ) { |
|
| 234 | + if ($champ[0] !== '_' && !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 235 | + if ($dispo && ($v = _request($champ)) !== null) { |
|
| 236 | + $valeurs[$champ] = $v; |
|
| 237 | + } |
|
| 238 | + // nettoyer l'url des champs qui vont etre saisis |
|
| 239 | + if ($action) { |
|
| 240 | + $action = parametre_url($action, $champ, ''); |
|
| 241 | + } |
|
| 242 | + // proteger les ' et les " dans les champs que l'on va injecter |
|
| 243 | + $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + if ($action) { |
|
| 248 | + // nettoyer l'url |
|
| 249 | + $action = parametre_url($action, 'formulaire_action', ''); |
|
| 250 | + $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 251 | + $action = parametre_url($action, 'formulaire_action_sign', ''); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * @deprecated 4.0 |
|
| 256 | + * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide |
|
| 257 | + */ |
|
| 258 | + /* |
|
| 259 | 259 | if (isset($valeurs['_action'])) { |
| 260 | 260 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 261 | 261 | $secu = $securiser_action(reset($valeurs['_action']), end($valeurs['_action']), '', -1); |
@@ -265,59 +265,59 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | */ |
| 267 | 267 | |
| 268 | - // empiler la lang en tant que premier argument implicite du CVT |
|
| 269 | - // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 270 | - array_unshift($args, $GLOBALS['spip_lang']); |
|
| 271 | - |
|
| 272 | - $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 273 | - $valeurs['erreurs'] = $erreurs; |
|
| 274 | - $valeurs['action'] = $action; |
|
| 275 | - $valeurs['form'] = $form; |
|
| 276 | - |
|
| 277 | - $valeurs['formulaire_sign'] = ''; |
|
| 278 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 279 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 280 | - $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 281 | - $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - if (!isset($valeurs['id'])) { |
|
| 285 | - $valeurs['id'] = 'new'; |
|
| 286 | - } |
|
| 287 | - // editable peut venir de charger() ou de traiter() sinon |
|
| 288 | - if (!isset($valeurs['editable'])) { |
|
| 289 | - $valeurs['editable'] = $editable; |
|
| 290 | - } |
|
| 291 | - // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 292 | - $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 293 | - |
|
| 294 | - if ($je_suis_poste) { |
|
| 295 | - $valeurs['message_erreur'] = ''; |
|
| 296 | - if (isset($erreurs['message_erreur'])) { |
|
| 297 | - $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - $valeurs['message_ok'] = ''; |
|
| 301 | - if (isset($post["message_ok_$form"])) { |
|
| 302 | - $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 303 | - } elseif (isset($erreurs['message_ok'])) { |
|
| 304 | - $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 308 | - // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 309 | - // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 310 | - if (html5_permis()) { |
|
| 311 | - foreach ($erreurs as $k => $v) { |
|
| 312 | - if (is_string($v) && strlen(trim($v)) && !str_starts_with((string) $k, '_')) { |
|
| 313 | - // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 314 | - $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - return $valeurs; |
|
| 268 | + // empiler la lang en tant que premier argument implicite du CVT |
|
| 269 | + // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 270 | + array_unshift($args, $GLOBALS['spip_lang']); |
|
| 271 | + |
|
| 272 | + $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 273 | + $valeurs['erreurs'] = $erreurs; |
|
| 274 | + $valeurs['action'] = $action; |
|
| 275 | + $valeurs['form'] = $form; |
|
| 276 | + |
|
| 277 | + $valeurs['formulaire_sign'] = ''; |
|
| 278 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 279 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 280 | + $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 281 | + $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + if (!isset($valeurs['id'])) { |
|
| 285 | + $valeurs['id'] = 'new'; |
|
| 286 | + } |
|
| 287 | + // editable peut venir de charger() ou de traiter() sinon |
|
| 288 | + if (!isset($valeurs['editable'])) { |
|
| 289 | + $valeurs['editable'] = $editable; |
|
| 290 | + } |
|
| 291 | + // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 292 | + $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 293 | + |
|
| 294 | + if ($je_suis_poste) { |
|
| 295 | + $valeurs['message_erreur'] = ''; |
|
| 296 | + if (isset($erreurs['message_erreur'])) { |
|
| 297 | + $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + $valeurs['message_ok'] = ''; |
|
| 301 | + if (isset($post["message_ok_$form"])) { |
|
| 302 | + $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 303 | + } elseif (isset($erreurs['message_ok'])) { |
|
| 304 | + $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 308 | + // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 309 | + // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 310 | + if (html5_permis()) { |
|
| 311 | + foreach ($erreurs as $k => $v) { |
|
| 312 | + if (is_string($v) && strlen(trim($v)) && !str_starts_with((string) $k, '_')) { |
|
| 313 | + // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 314 | + $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + return $valeurs; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -329,51 +329,51 @@ discard block |
||
| 329 | 329 | * @return array |
| 330 | 330 | */ |
| 331 | 331 | function formulaire__charger($form, $args, $poste) { |
| 332 | - if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 333 | - $valeurs = $charger_valeurs(...$args); |
|
| 334 | - } else { |
|
| 335 | - $valeurs = []; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - $valeurs = pipeline( |
|
| 339 | - 'formulaire_charger', |
|
| 340 | - [ |
|
| 341 | - 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 342 | - 'data' => $valeurs |
|
| 343 | - ] |
|
| 344 | - ); |
|
| 345 | - |
|
| 346 | - // prise en charge CVT multi etape |
|
| 347 | - if (is_array($valeurs) && isset($valeurs['_etapes'])) { |
|
| 348 | - include_spip('inc/cvt_multietapes'); |
|
| 349 | - $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 350 | - ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 351 | - $valeurs |
|
| 352 | - ); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 356 | - if (is_array($valeurs)) { |
|
| 357 | - if (!isset($valeurs['_pipelines'])) { |
|
| 358 | - $valeurs['_pipelines'] = []; |
|
| 359 | - } |
|
| 360 | - // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 361 | - // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 362 | - if (isset($valeurs['_pipeline'])) { |
|
| 363 | - $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 364 | - $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 365 | - |
|
| 366 | - $pipelines = [$pipe => $args]; |
|
| 367 | - $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 371 | - // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 372 | - // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 373 | - $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return $valeurs; |
|
| 332 | + if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 333 | + $valeurs = $charger_valeurs(...$args); |
|
| 334 | + } else { |
|
| 335 | + $valeurs = []; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + $valeurs = pipeline( |
|
| 339 | + 'formulaire_charger', |
|
| 340 | + [ |
|
| 341 | + 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 342 | + 'data' => $valeurs |
|
| 343 | + ] |
|
| 344 | + ); |
|
| 345 | + |
|
| 346 | + // prise en charge CVT multi etape |
|
| 347 | + if (is_array($valeurs) && isset($valeurs['_etapes'])) { |
|
| 348 | + include_spip('inc/cvt_multietapes'); |
|
| 349 | + $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 350 | + ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 351 | + $valeurs |
|
| 352 | + ); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 356 | + if (is_array($valeurs)) { |
|
| 357 | + if (!isset($valeurs['_pipelines'])) { |
|
| 358 | + $valeurs['_pipelines'] = []; |
|
| 359 | + } |
|
| 360 | + // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 361 | + // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 362 | + if (isset($valeurs['_pipeline'])) { |
|
| 363 | + $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 364 | + $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 365 | + |
|
| 366 | + $pipelines = [$pipe => $args]; |
|
| 367 | + $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 371 | + // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 372 | + // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 373 | + $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return $valeurs; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /** |
@@ -392,9 +392,9 @@ discard block |
||
| 392 | 392 | * @return bool |
| 393 | 393 | */ |
| 394 | 394 | function formulaire__identifier($form, $args, $p) { |
| 395 | - if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 396 | - return $identifier_args(...$args) === $identifier_args(...$p); |
|
| 397 | - } |
|
| 395 | + if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 396 | + return $identifier_args(...$args) === $identifier_args(...$p); |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - return $args === $p; |
|
| 399 | + return $args === $p; |
|
| 400 | 400 | } |
@@ -311,7 +311,7 @@ |
||
| 311 | 311 | foreach ($erreurs as $k => $v) { |
| 312 | 312 | if (is_string($v) && strlen(trim($v)) && !str_starts_with((string) $k, '_')) { |
| 313 | 313 | // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
| 314 | - $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 314 | + $valeurs['erreurs'][$k] = "<span role='alert'>".$erreurs[$k].'</span>'; |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | } |