@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @package SPIP\Core\Compilateur\References |
| 20 | 20 | **/ |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | * - '' si une référence explicite incorrecte est envoyée |
| 45 | 45 | */ |
| 46 | 46 | function index_boucle($p) { |
| 47 | - if (strlen($p->nom_boucle)) { |
|
| 48 | - // retourne l’index explicite demandé s’il existe |
|
| 49 | - if (!empty($p->boucles[$p->nom_boucle])) { |
|
| 50 | - return $p->nom_boucle; |
|
| 51 | - } |
|
| 52 | - return ''; |
|
| 53 | - } |
|
| 54 | - return $p->id_boucle; |
|
| 47 | + if (strlen($p->nom_boucle)) { |
|
| 48 | + // retourne l’index explicite demandé s’il existe |
|
| 49 | + if (!empty($p->boucles[$p->nom_boucle])) { |
|
| 50 | + return $p->nom_boucle; |
|
| 51 | + } |
|
| 52 | + return ''; |
|
| 53 | + } |
|
| 54 | + return $p->id_boucle; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -74,17 +74,17 @@ discard block |
||
| 74 | 74 | * - '' si une référence explicite incorrecte est envoyée |
| 75 | 75 | */ |
| 76 | 76 | function index_boucle_mere($p) { |
| 77 | - if (strlen($p->nom_boucle)) { |
|
| 78 | - // retourne l’index explicite demandé s’il existe |
|
| 79 | - if (!empty($p->boucles[$p->nom_boucle])) { |
|
| 80 | - return $p->nom_boucle; |
|
| 81 | - } |
|
| 82 | - return ''; |
|
| 83 | - } |
|
| 84 | - if (!empty($p->descr['id_mere'])) { |
|
| 85 | - return $p->descr['id_mere']; |
|
| 86 | - } |
|
| 87 | - return ''; |
|
| 77 | + if (strlen($p->nom_boucle)) { |
|
| 78 | + // retourne l’index explicite demandé s’il existe |
|
| 79 | + if (!empty($p->boucles[$p->nom_boucle])) { |
|
| 80 | + return $p->nom_boucle; |
|
| 81 | + } |
|
| 82 | + return ''; |
|
| 83 | + } |
|
| 84 | + if (!empty($p->descr['id_mere'])) { |
|
| 85 | + return $p->descr['id_mere']; |
|
| 86 | + } |
|
| 87 | + return ''; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -118,74 +118,74 @@ discard block |
||
| 118 | 118 | * Code PHP pour obtenir le champ SQL |
| 119 | 119 | */ |
| 120 | 120 | function index_pile( |
| 121 | - $idb, |
|
| 122 | - $nom_champ, |
|
| 123 | - &$boucles, |
|
| 124 | - $explicite = '', |
|
| 125 | - $defaut = null, |
|
| 126 | - $remonte_pile = true, |
|
| 127 | - $select = true |
|
| 121 | + $idb, |
|
| 122 | + $nom_champ, |
|
| 123 | + &$boucles, |
|
| 124 | + $explicite = '', |
|
| 125 | + $defaut = null, |
|
| 126 | + $remonte_pile = true, |
|
| 127 | + $select = true |
|
| 128 | 128 | ) { |
| 129 | - if (!is_string($defaut)) { |
|
| 130 | - $defaut = '($Pile[0][\'' . strtolower($nom_champ) . '\'] ?? null)'; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - $idb_origine = $idb; |
|
| 134 | - $nom_champ_origine = $nom_champ; |
|
| 135 | - |
|
| 136 | - $i = 0; |
|
| 137 | - if (strlen($explicite)) { |
|
| 138 | - // Recherche d'un champ dans un etage superieur |
|
| 139 | - while (($idb !== $explicite) && ($idb !== '')) { |
|
| 140 | - # spip_log("Cherchexpl: $nom_champ '$explicite' '$idb' '$i'"); |
|
| 141 | - $i++; |
|
| 142 | - $idb = $boucles[$idb]->id_parent; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - # spip_log("Cherche: $nom_champ a partir de '$idb'"); |
|
| 147 | - $nom_champ = strtolower($nom_champ); |
|
| 148 | - $conditionnel = []; |
|
| 149 | - // attention: entre la boucle nommee 0, "" et le tableau vide, |
|
| 150 | - // il y a incoherences qu'il vaut mieux eviter |
|
| 151 | - while (isset($boucles[$idb])) { |
|
| 152 | - $joker = true; |
|
| 153 | - // modifie $joker si tous les champs sont autorisés. |
|
| 154 | - // $t = le select pour le champ, si on l'a trouvé (ou si joker) |
|
| 155 | - // $c = le nom du champ demandé |
|
| 156 | - [$t, $c] = index_tables_en_pile($idb, $nom_champ, $boucles, $joker); |
|
| 157 | - if ($t) { |
|
| 158 | - if ($select and !in_array($t, $boucles[$idb]->select)) { |
|
| 159 | - $boucles[$idb]->select[] = $t; |
|
| 160 | - } |
|
| 161 | - // renseigner la boucle source de ce champ pour les traitements |
|
| 162 | - $boucles[$idb_origine]->index_champ[$nom_champ_origine] = $idb; |
|
| 163 | - $champ = '$Pile[$SP' . ($i ? "-$i" : '') . '][\'' . $c . '\']'; |
|
| 164 | - if (!$joker) { |
|
| 165 | - return index_compose($conditionnel, $champ); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // tant que l'on trouve des tables avec joker, on continue |
|
| 169 | - // avec la boucle parente et on conditionne à l'exécution |
|
| 170 | - // la présence du champ. Si le champ existe à l'exécution |
|
| 171 | - // dans une boucle, il est pris, sinon on le cherche dans le parent... |
|
| 172 | - $conditionnel[] = "isset($champ)?$champ"; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - if ($remonte_pile) { |
|
| 176 | - # spip_log("On remonte vers $i"); |
|
| 177 | - // Sinon on remonte d'un cran |
|
| 178 | - $idb = $boucles[$idb]->id_parent; |
|
| 179 | - $i++; |
|
| 180 | - } else { |
|
| 181 | - $idb = null; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - # spip_log("Pas vu $nom_champ"); |
|
| 186 | - // esperons qu'il y sera |
|
| 187 | - // ou qu'on a fourni une valeur par "defaut" plus pertinent |
|
| 188 | - return index_compose($conditionnel, $defaut); |
|
| 129 | + if (!is_string($defaut)) { |
|
| 130 | + $defaut = '($Pile[0][\'' . strtolower($nom_champ) . '\'] ?? null)'; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + $idb_origine = $idb; |
|
| 134 | + $nom_champ_origine = $nom_champ; |
|
| 135 | + |
|
| 136 | + $i = 0; |
|
| 137 | + if (strlen($explicite)) { |
|
| 138 | + // Recherche d'un champ dans un etage superieur |
|
| 139 | + while (($idb !== $explicite) && ($idb !== '')) { |
|
| 140 | + # spip_log("Cherchexpl: $nom_champ '$explicite' '$idb' '$i'"); |
|
| 141 | + $i++; |
|
| 142 | + $idb = $boucles[$idb]->id_parent; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + # spip_log("Cherche: $nom_champ a partir de '$idb'"); |
|
| 147 | + $nom_champ = strtolower($nom_champ); |
|
| 148 | + $conditionnel = []; |
|
| 149 | + // attention: entre la boucle nommee 0, "" et le tableau vide, |
|
| 150 | + // il y a incoherences qu'il vaut mieux eviter |
|
| 151 | + while (isset($boucles[$idb])) { |
|
| 152 | + $joker = true; |
|
| 153 | + // modifie $joker si tous les champs sont autorisés. |
|
| 154 | + // $t = le select pour le champ, si on l'a trouvé (ou si joker) |
|
| 155 | + // $c = le nom du champ demandé |
|
| 156 | + [$t, $c] = index_tables_en_pile($idb, $nom_champ, $boucles, $joker); |
|
| 157 | + if ($t) { |
|
| 158 | + if ($select and !in_array($t, $boucles[$idb]->select)) { |
|
| 159 | + $boucles[$idb]->select[] = $t; |
|
| 160 | + } |
|
| 161 | + // renseigner la boucle source de ce champ pour les traitements |
|
| 162 | + $boucles[$idb_origine]->index_champ[$nom_champ_origine] = $idb; |
|
| 163 | + $champ = '$Pile[$SP' . ($i ? "-$i" : '') . '][\'' . $c . '\']'; |
|
| 164 | + if (!$joker) { |
|
| 165 | + return index_compose($conditionnel, $champ); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // tant que l'on trouve des tables avec joker, on continue |
|
| 169 | + // avec la boucle parente et on conditionne à l'exécution |
|
| 170 | + // la présence du champ. Si le champ existe à l'exécution |
|
| 171 | + // dans une boucle, il est pris, sinon on le cherche dans le parent... |
|
| 172 | + $conditionnel[] = "isset($champ)?$champ"; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + if ($remonte_pile) { |
|
| 176 | + # spip_log("On remonte vers $i"); |
|
| 177 | + // Sinon on remonte d'un cran |
|
| 178 | + $idb = $boucles[$idb]->id_parent; |
|
| 179 | + $i++; |
|
| 180 | + } else { |
|
| 181 | + $idb = null; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + # spip_log("Pas vu $nom_champ"); |
|
| 186 | + // esperons qu'il y sera |
|
| 187 | + // ou qu'on a fourni une valeur par "defaut" plus pertinent |
|
| 188 | + return index_compose($conditionnel, $defaut); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -199,12 +199,12 @@ discard block |
||
| 199 | 199 | * @return string Code PHP complet de recherche d'un champ |
| 200 | 200 | */ |
| 201 | 201 | function index_compose($conditionnel, $defaut) { |
| 202 | - while ($c = array_pop($conditionnel)) { |
|
| 203 | - // si on passe defaut = '', ne pas générer d'erreur de compilation. |
|
| 204 | - $defaut = "($c:(" . ($defaut ?: "''") . '))'; |
|
| 205 | - } |
|
| 202 | + while ($c = array_pop($conditionnel)) { |
|
| 203 | + // si on passe defaut = '', ne pas générer d'erreur de compilation. |
|
| 204 | + $defaut = "($c:(" . ($defaut ?: "''") . '))'; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - return $defaut; |
|
| 207 | + return $defaut; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -240,97 +240,97 @@ discard block |
||
| 240 | 240 | **/ |
| 241 | 241 | function index_tables_en_pile($idb, $nom_champ, &$boucles, &$joker) { |
| 242 | 242 | |
| 243 | - $r = $boucles[$idb]->type_requete; |
|
| 244 | - // boucle recursive, c'est foutu... |
|
| 245 | - if ($r == TYPE_RECURSIF) { |
|
| 246 | - return []; |
|
| 247 | - } |
|
| 248 | - if (!$r) { |
|
| 249 | - $joker = false; // indiquer a l'appelant |
|
| 250 | - # continuer pour chercher l'erreur suivante |
|
| 251 | - return ["'#" . $r . ':' . $nom_champ . "'", '']; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $desc = $boucles[$idb]->show; |
|
| 255 | - // le nom du champ est il une exception de la table ? un alias ? |
|
| 256 | - $excep = $GLOBALS['exceptions_des_tables'][$r] ?? ''; |
|
| 257 | - if ($excep) { |
|
| 258 | - $excep = $excep[$nom_champ] ?? ''; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // il y a un alias connu pour ce champ |
|
| 262 | - if ($excep) { |
|
| 263 | - $joker = false; // indiquer a l'appelant |
|
| 264 | - return index_exception($boucles[$idb], $desc, $nom_champ, $excep); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - // le champ existe dans la table, on le prend. |
|
| 268 | - if (isset($desc['field'][$nom_champ])) { |
|
| 269 | - $t = $boucles[$idb]->id_table ?? ''; |
|
| 270 | - $joker = false; // indiquer a l'appelant |
|
| 271 | - // note: dans certains cas ('valeur' d’une boucle DATA, sans id_table), retourne ['.valeur', 'valeur'] … |
|
| 272 | - return ["$t.$nom_champ", $nom_champ]; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - // Tous les champs sont-ils acceptés ? |
|
| 276 | - // Si oui, on retourne le champ, et on lève le flag joker |
|
| 277 | - // C'est le cas des itérateurs DATA qui acceptent tout |
|
| 278 | - // et testent la présence du champ à l'exécution et non à la compilation |
|
| 279 | - // car ils ne connaissent pas ici leurs contenus. |
|
| 280 | - if ( |
|
| 281 | - /*$joker AND */ |
|
| 282 | - isset($desc['field']['*']) |
|
| 283 | - ) { |
|
| 284 | - $joker = true; // indiquer a l'appelant |
|
| 285 | - return [$nom_champ, $nom_champ]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - $joker = false; // indiquer a l'appelant |
|
| 289 | - |
|
| 290 | - // la table de jointure est explicitement indiquée (rubrique.titre) |
|
| 291 | - if (preg_match('/^(.*)\.(.*)$/', $nom_champ, $r)) { |
|
| 292 | - [, $_table, $_nom_champ] = $r; |
|
| 293 | - if ($cle = trouver_jointure_champ($_nom_champ, $boucles[$idb], [$_table])) { |
|
| 294 | - $_alias = $cle . '_' . $_nom_champ; |
|
| 295 | - return index_exception( |
|
| 296 | - $boucles[$idb], |
|
| 297 | - $desc, |
|
| 298 | - $_alias, |
|
| 299 | - [$_table, $_nom_champ] |
|
| 300 | - ); |
|
| 301 | - } |
|
| 302 | - return ['', '']; |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - // pas d'alias, pas de champ, pas de joker... |
|
| 306 | - // tenter via une jointure... |
|
| 307 | - |
|
| 308 | - // regarder si le champ est deja dans une jointure existante |
|
| 309 | - // sinon, si il y a des joitures explicites, la construire |
|
| 310 | - if (!$t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->from, $boucles[$idb])) { |
|
| 311 | - if ($boucles[$idb]->jointures_explicites) { |
|
| 312 | - // [todo] Ne pas lancer que lorsque il y a des jointures explicites !!!! |
|
| 313 | - // fonctionnel, il suffit d'utiliser $boucles[$idb]->jointures au lieu de jointures_explicites |
|
| 314 | - // mais est-ce ce qu'on veut ? |
|
| 315 | - $jointures = preg_split('/\s+/', $boucles[$idb]->jointures_explicites); |
|
| 316 | - if ($cle = trouver_jointure_champ($nom_champ, $boucles[$idb], $jointures)) { |
|
| 317 | - $t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->from, $boucles[$idb]); |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - if ($t) { |
|
| 323 | - // si on a trouvé une jointure possible, on fait comme |
|
| 324 | - // si c'était une exception pour le champ demandé |
|
| 325 | - return index_exception( |
|
| 326 | - $boucles[$idb], |
|
| 327 | - $desc, |
|
| 328 | - $nom_champ, |
|
| 329 | - [$t[1]['id_table'], reset($t[2])] |
|
| 330 | - ); |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - return ['', '']; |
|
| 243 | + $r = $boucles[$idb]->type_requete; |
|
| 244 | + // boucle recursive, c'est foutu... |
|
| 245 | + if ($r == TYPE_RECURSIF) { |
|
| 246 | + return []; |
|
| 247 | + } |
|
| 248 | + if (!$r) { |
|
| 249 | + $joker = false; // indiquer a l'appelant |
|
| 250 | + # continuer pour chercher l'erreur suivante |
|
| 251 | + return ["'#" . $r . ':' . $nom_champ . "'", '']; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $desc = $boucles[$idb]->show; |
|
| 255 | + // le nom du champ est il une exception de la table ? un alias ? |
|
| 256 | + $excep = $GLOBALS['exceptions_des_tables'][$r] ?? ''; |
|
| 257 | + if ($excep) { |
|
| 258 | + $excep = $excep[$nom_champ] ?? ''; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // il y a un alias connu pour ce champ |
|
| 262 | + if ($excep) { |
|
| 263 | + $joker = false; // indiquer a l'appelant |
|
| 264 | + return index_exception($boucles[$idb], $desc, $nom_champ, $excep); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + // le champ existe dans la table, on le prend. |
|
| 268 | + if (isset($desc['field'][$nom_champ])) { |
|
| 269 | + $t = $boucles[$idb]->id_table ?? ''; |
|
| 270 | + $joker = false; // indiquer a l'appelant |
|
| 271 | + // note: dans certains cas ('valeur' d’une boucle DATA, sans id_table), retourne ['.valeur', 'valeur'] … |
|
| 272 | + return ["$t.$nom_champ", $nom_champ]; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + // Tous les champs sont-ils acceptés ? |
|
| 276 | + // Si oui, on retourne le champ, et on lève le flag joker |
|
| 277 | + // C'est le cas des itérateurs DATA qui acceptent tout |
|
| 278 | + // et testent la présence du champ à l'exécution et non à la compilation |
|
| 279 | + // car ils ne connaissent pas ici leurs contenus. |
|
| 280 | + if ( |
|
| 281 | + /*$joker AND */ |
|
| 282 | + isset($desc['field']['*']) |
|
| 283 | + ) { |
|
| 284 | + $joker = true; // indiquer a l'appelant |
|
| 285 | + return [$nom_champ, $nom_champ]; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + $joker = false; // indiquer a l'appelant |
|
| 289 | + |
|
| 290 | + // la table de jointure est explicitement indiquée (rubrique.titre) |
|
| 291 | + if (preg_match('/^(.*)\.(.*)$/', $nom_champ, $r)) { |
|
| 292 | + [, $_table, $_nom_champ] = $r; |
|
| 293 | + if ($cle = trouver_jointure_champ($_nom_champ, $boucles[$idb], [$_table])) { |
|
| 294 | + $_alias = $cle . '_' . $_nom_champ; |
|
| 295 | + return index_exception( |
|
| 296 | + $boucles[$idb], |
|
| 297 | + $desc, |
|
| 298 | + $_alias, |
|
| 299 | + [$_table, $_nom_champ] |
|
| 300 | + ); |
|
| 301 | + } |
|
| 302 | + return ['', '']; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + // pas d'alias, pas de champ, pas de joker... |
|
| 306 | + // tenter via une jointure... |
|
| 307 | + |
|
| 308 | + // regarder si le champ est deja dans une jointure existante |
|
| 309 | + // sinon, si il y a des joitures explicites, la construire |
|
| 310 | + if (!$t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->from, $boucles[$idb])) { |
|
| 311 | + if ($boucles[$idb]->jointures_explicites) { |
|
| 312 | + // [todo] Ne pas lancer que lorsque il y a des jointures explicites !!!! |
|
| 313 | + // fonctionnel, il suffit d'utiliser $boucles[$idb]->jointures au lieu de jointures_explicites |
|
| 314 | + // mais est-ce ce qu'on veut ? |
|
| 315 | + $jointures = preg_split('/\s+/', $boucles[$idb]->jointures_explicites); |
|
| 316 | + if ($cle = trouver_jointure_champ($nom_champ, $boucles[$idb], $jointures)) { |
|
| 317 | + $t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->from, $boucles[$idb]); |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + if ($t) { |
|
| 323 | + // si on a trouvé une jointure possible, on fait comme |
|
| 324 | + // si c'était une exception pour le champ demandé |
|
| 325 | + return index_exception( |
|
| 326 | + $boucles[$idb], |
|
| 327 | + $desc, |
|
| 328 | + $nom_champ, |
|
| 329 | + [$t[1]['id_table'], reset($t[2])] |
|
| 330 | + ); |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + return ['', '']; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | |
@@ -358,52 +358,52 @@ discard block |
||
| 358 | 358 | * est une expression pour le SELECT de la boucle du style "mots.titre AS titre_mot" |
| 359 | 359 | **/ |
| 360 | 360 | function index_exception(&$boucle, $desc, $nom_champ, $excep) { |
| 361 | - static $trouver_table; |
|
| 362 | - if (!$trouver_table) { |
|
| 363 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - if (is_array($excep)) { |
|
| 367 | - // permettre aux plugins de gerer eux meme des jointures derogatoire ingerables |
|
| 368 | - $t = null; |
|
| 369 | - if (count($excep) == 3) { |
|
| 370 | - $index_exception_derogatoire = array_pop($excep); |
|
| 371 | - $t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep); |
|
| 372 | - } |
|
| 373 | - if ($t == null) { |
|
| 374 | - [$e, $x] = $excep; #PHP4 affecte de gauche a droite |
|
| 375 | - $excep = $x; #PHP5 de droite a gauche ! |
|
| 376 | - $j = $trouver_table($e, $boucle->sql_serveur); |
|
| 377 | - if (!$j) { |
|
| 378 | - return ['', '']; |
|
| 379 | - } |
|
| 380 | - $e = $j['table']; |
|
| 381 | - if (!$t = array_search($e, $boucle->from)) { |
|
| 382 | - $k = $j['key']['PRIMARY KEY']; |
|
| 383 | - if (strpos($k, ',')) { |
|
| 384 | - $l = (preg_split('/\s*,\s*/', $k)); |
|
| 385 | - $k = $desc['key']['PRIMARY KEY']; |
|
| 386 | - if (!in_array($k, $l)) { |
|
| 387 | - spip_log("jointure impossible $e " . join(',', $l)); |
|
| 388 | - |
|
| 389 | - return ['', '']; |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - $k = [$boucle->id_table, [$e], $k]; |
|
| 393 | - fabrique_jointures($boucle, [$k]); |
|
| 394 | - $t = array_search($e, $boucle->from); |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - } else { |
|
| 398 | - $t = $boucle->id_table; |
|
| 399 | - } |
|
| 400 | - // demander a SQL de gerer le synonyme |
|
| 401 | - // ca permet que excep soit dynamique (Cedric, 2/3/06) |
|
| 402 | - if ($excep != $nom_champ) { |
|
| 403 | - $excep .= ' AS ' . $nom_champ; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - return ["$t.$excep", $nom_champ]; |
|
| 361 | + static $trouver_table; |
|
| 362 | + if (!$trouver_table) { |
|
| 363 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + if (is_array($excep)) { |
|
| 367 | + // permettre aux plugins de gerer eux meme des jointures derogatoire ingerables |
|
| 368 | + $t = null; |
|
| 369 | + if (count($excep) == 3) { |
|
| 370 | + $index_exception_derogatoire = array_pop($excep); |
|
| 371 | + $t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep); |
|
| 372 | + } |
|
| 373 | + if ($t == null) { |
|
| 374 | + [$e, $x] = $excep; #PHP4 affecte de gauche a droite |
|
| 375 | + $excep = $x; #PHP5 de droite a gauche ! |
|
| 376 | + $j = $trouver_table($e, $boucle->sql_serveur); |
|
| 377 | + if (!$j) { |
|
| 378 | + return ['', '']; |
|
| 379 | + } |
|
| 380 | + $e = $j['table']; |
|
| 381 | + if (!$t = array_search($e, $boucle->from)) { |
|
| 382 | + $k = $j['key']['PRIMARY KEY']; |
|
| 383 | + if (strpos($k, ',')) { |
|
| 384 | + $l = (preg_split('/\s*,\s*/', $k)); |
|
| 385 | + $k = $desc['key']['PRIMARY KEY']; |
|
| 386 | + if (!in_array($k, $l)) { |
|
| 387 | + spip_log("jointure impossible $e " . join(',', $l)); |
|
| 388 | + |
|
| 389 | + return ['', '']; |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + $k = [$boucle->id_table, [$e], $k]; |
|
| 393 | + fabrique_jointures($boucle, [$k]); |
|
| 394 | + $t = array_search($e, $boucle->from); |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + } else { |
|
| 398 | + $t = $boucle->id_table; |
|
| 399 | + } |
|
| 400 | + // demander a SQL de gerer le synonyme |
|
| 401 | + // ca permet que excep soit dynamique (Cedric, 2/3/06) |
|
| 402 | + if ($excep != $nom_champ) { |
|
| 403 | + $excep .= ' AS ' . $nom_champ; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + return ["$t.$excep", $nom_champ]; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * Code PHP pour retrouver le champ |
| 429 | 429 | */ |
| 430 | 430 | function champ_sql($champ, $p, $defaut = null, $remonte_pile = true) { |
| 431 | - return index_pile($p->id_boucle, $champ, $p->boucles, $p->nom_boucle, $defaut, $remonte_pile); |
|
| 431 | + return index_pile($p->id_boucle, $champ, $p->boucles, $p->nom_boucle, $defaut, $remonte_pile); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | |
@@ -448,9 +448,9 @@ discard block |
||
| 448 | 448 | * Code PHP pour d'exécution de la balise et de ses filtres |
| 449 | 449 | **/ |
| 450 | 450 | function calculer_champ($p) { |
| 451 | - $p = calculer_balise($p->nom_champ, $p); |
|
| 451 | + $p = calculer_balise($p->nom_champ, $p); |
|
| 452 | 452 | |
| 453 | - return applique_filtres($p); |
|
| 453 | + return applique_filtres($p); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | |
@@ -487,26 +487,26 @@ discard block |
||
| 487 | 487 | **/ |
| 488 | 488 | function calculer_balise(string $nom, Champ $p): Champ { |
| 489 | 489 | |
| 490 | - // S'agit-t-il d'une balise_XXXX[_dist]() ? |
|
| 491 | - if ($f = charger_fonction($nom, 'balise', true)) { |
|
| 492 | - $p->balise_calculee = true; |
|
| 493 | - $res = $f($p); |
|
| 494 | - if ($res !== null and is_object($res)) { |
|
| 495 | - return $res; |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - // Certaines des balises comportant un _ sont generiques |
|
| 500 | - if ($balise_generique = chercher_balise_generique($nom)) { |
|
| 501 | - $res = $balise_generique['fonction_generique']($p); |
|
| 502 | - if ($res !== null and is_object($res)) { |
|
| 503 | - return $res; |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - $f = charger_fonction('DEFAUT', 'calculer_balise'); |
|
| 508 | - |
|
| 509 | - return $f($nom, $p); |
|
| 490 | + // S'agit-t-il d'une balise_XXXX[_dist]() ? |
|
| 491 | + if ($f = charger_fonction($nom, 'balise', true)) { |
|
| 492 | + $p->balise_calculee = true; |
|
| 493 | + $res = $f($p); |
|
| 494 | + if ($res !== null and is_object($res)) { |
|
| 495 | + return $res; |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + // Certaines des balises comportant un _ sont generiques |
|
| 500 | + if ($balise_generique = chercher_balise_generique($nom)) { |
|
| 501 | + $res = $balise_generique['fonction_generique']($p); |
|
| 502 | + if ($res !== null and is_object($res)) { |
|
| 503 | + return $res; |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + $f = charger_fonction('DEFAUT', 'calculer_balise'); |
|
| 508 | + |
|
| 509 | + return $f($nom, $p); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | |
@@ -534,37 +534,37 @@ discard block |
||
| 534 | 534 | **/ |
| 535 | 535 | function calculer_balise_DEFAUT_dist($nom, $p) { |
| 536 | 536 | |
| 537 | - // ca pourrait etre un champ SQL homonyme, |
|
| 538 | - $p->code = index_pile($p->id_boucle, $nom, $p->boucles, $p->nom_boucle); |
|
| 539 | - |
|
| 540 | - // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour |
|
| 541 | - // il faut recracher {...} quand ce n'est finalement pas des args |
|
| 542 | - if ($p->fonctions and (!$p->fonctions[0][0]) and $p->fonctions[0][1]) { |
|
| 543 | - $code = addslashes($p->fonctions[0][1]); |
|
| 544 | - $p->code .= " . '$code'"; |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - // ne pas passer le filtre securite sur les id_xxx |
|
| 548 | - if (strpos($nom, 'ID_') === 0) { |
|
| 549 | - $p->interdire_scripts = false; |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - // Compatibilite ascendante avec les couleurs html (#FEFEFE) : |
|
| 553 | - // SI le champ SQL n'est pas trouve |
|
| 554 | - // ET si la balise a une forme de couleur |
|
| 555 | - // ET s'il n'y a ni filtre ni etoile |
|
| 556 | - // ALORS retourner la couleur. |
|
| 557 | - // Ca permet si l'on veut vraiment de recuperer [(#ACCEDE*)] |
|
| 558 | - if ( |
|
| 559 | - preg_match('/^[A-F]{1,6}$/i', $nom) |
|
| 560 | - and !$p->etoile |
|
| 561 | - and !$p->fonctions |
|
| 562 | - ) { |
|
| 563 | - $p->code = "'#$nom'"; |
|
| 564 | - $p->interdire_scripts = false; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - return $p; |
|
| 537 | + // ca pourrait etre un champ SQL homonyme, |
|
| 538 | + $p->code = index_pile($p->id_boucle, $nom, $p->boucles, $p->nom_boucle); |
|
| 539 | + |
|
| 540 | + // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour |
|
| 541 | + // il faut recracher {...} quand ce n'est finalement pas des args |
|
| 542 | + if ($p->fonctions and (!$p->fonctions[0][0]) and $p->fonctions[0][1]) { |
|
| 543 | + $code = addslashes($p->fonctions[0][1]); |
|
| 544 | + $p->code .= " . '$code'"; |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + // ne pas passer le filtre securite sur les id_xxx |
|
| 548 | + if (strpos($nom, 'ID_') === 0) { |
|
| 549 | + $p->interdire_scripts = false; |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + // Compatibilite ascendante avec les couleurs html (#FEFEFE) : |
|
| 553 | + // SI le champ SQL n'est pas trouve |
|
| 554 | + // ET si la balise a une forme de couleur |
|
| 555 | + // ET s'il n'y a ni filtre ni etoile |
|
| 556 | + // ALORS retourner la couleur. |
|
| 557 | + // Ca permet si l'on veut vraiment de recuperer [(#ACCEDE*)] |
|
| 558 | + if ( |
|
| 559 | + preg_match('/^[A-F]{1,6}$/i', $nom) |
|
| 560 | + and !$p->etoile |
|
| 561 | + and !$p->fonctions |
|
| 562 | + ) { |
|
| 563 | + $p->code = "'#$nom'"; |
|
| 564 | + $p->interdire_scripts = false; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + return $p; |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | |
@@ -613,53 +613,53 @@ discard block |
||
| 613 | 613 | **/ |
| 614 | 614 | function calculer_balise_dynamique($p, $nom, $l, $supp = []) { |
| 615 | 615 | |
| 616 | - if (!balise_distante_interdite($p)) { |
|
| 617 | - $p->code = "''"; |
|
| 618 | - |
|
| 619 | - return $p; |
|
| 620 | - } |
|
| 621 | - // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour |
|
| 622 | - // il faut recracher {...} quand ce n'est finalement pas des args |
|
| 623 | - if ($p->fonctions and (!$p->fonctions[0][0]) and $p->fonctions[0][1]) { |
|
| 624 | - $p->fonctions = []; |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - if ($p->param and ($c = $p->param[0])) { |
|
| 628 | - // liste d'arguments commence toujours par la chaine vide |
|
| 629 | - array_shift($c); |
|
| 630 | - // construire la liste d'arguments comme pour un filtre |
|
| 631 | - $param = compose_filtres_args($p, $c, ','); |
|
| 632 | - } else { |
|
| 633 | - $param = ''; |
|
| 634 | - } |
|
| 635 | - $collecte = collecter_balise_dynamique($l, $p, $nom); |
|
| 636 | - |
|
| 637 | - $dans_un_modele = false; |
|
| 638 | - if (!empty($p->descr['sourcefile']) |
|
| 639 | - and $f = $p->descr['sourcefile'] |
|
| 640 | - and basename(dirname($f)) === 'modeles' |
|
| 641 | - ) { |
|
| 642 | - $dans_un_modele = true; |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - // un modele est toujours inséré en texte dans son contenant |
|
| 646 | - // donc si on est dans le public avec un cache on va perdre le dynamisme |
|
| 647 | - // et on risque de mettre en cache les valeurs pre-remplies du formulaire |
|
| 648 | - // on passe donc par une fonction proxy qui si besoin va collecter les arguments |
|
| 649 | - // et injecter le PHP qui va appeler la fonction pour generer le formulaire au lieu de directement la fonction |
|
| 650 | - // (dans l'espace prive on a pas de cache, donc pas de soucis (et un leak serait moins grave)) |
|
| 651 | - $p->code = sprintf( |
|
| 652 | - $dans_un_modele ? CODE_EXECUTER_BALISE_MODELE : CODE_EXECUTER_BALISE, |
|
| 653 | - $nom, |
|
| 654 | - join(',', $collecte), |
|
| 655 | - ($collecte ? $param : substr($param, 1)), # virer la virgule |
|
| 656 | - memoriser_contexte_compil($p), |
|
| 657 | - (!$supp ? '' : (', ' . join(',', $supp))) |
|
| 658 | - ); |
|
| 659 | - |
|
| 660 | - $p->interdire_scripts = false; |
|
| 661 | - |
|
| 662 | - return $p; |
|
| 616 | + if (!balise_distante_interdite($p)) { |
|
| 617 | + $p->code = "''"; |
|
| 618 | + |
|
| 619 | + return $p; |
|
| 620 | + } |
|
| 621 | + // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour |
|
| 622 | + // il faut recracher {...} quand ce n'est finalement pas des args |
|
| 623 | + if ($p->fonctions and (!$p->fonctions[0][0]) and $p->fonctions[0][1]) { |
|
| 624 | + $p->fonctions = []; |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + if ($p->param and ($c = $p->param[0])) { |
|
| 628 | + // liste d'arguments commence toujours par la chaine vide |
|
| 629 | + array_shift($c); |
|
| 630 | + // construire la liste d'arguments comme pour un filtre |
|
| 631 | + $param = compose_filtres_args($p, $c, ','); |
|
| 632 | + } else { |
|
| 633 | + $param = ''; |
|
| 634 | + } |
|
| 635 | + $collecte = collecter_balise_dynamique($l, $p, $nom); |
|
| 636 | + |
|
| 637 | + $dans_un_modele = false; |
|
| 638 | + if (!empty($p->descr['sourcefile']) |
|
| 639 | + and $f = $p->descr['sourcefile'] |
|
| 640 | + and basename(dirname($f)) === 'modeles' |
|
| 641 | + ) { |
|
| 642 | + $dans_un_modele = true; |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + // un modele est toujours inséré en texte dans son contenant |
|
| 646 | + // donc si on est dans le public avec un cache on va perdre le dynamisme |
|
| 647 | + // et on risque de mettre en cache les valeurs pre-remplies du formulaire |
|
| 648 | + // on passe donc par une fonction proxy qui si besoin va collecter les arguments |
|
| 649 | + // et injecter le PHP qui va appeler la fonction pour generer le formulaire au lieu de directement la fonction |
|
| 650 | + // (dans l'espace prive on a pas de cache, donc pas de soucis (et un leak serait moins grave)) |
|
| 651 | + $p->code = sprintf( |
|
| 652 | + $dans_un_modele ? CODE_EXECUTER_BALISE_MODELE : CODE_EXECUTER_BALISE, |
|
| 653 | + $nom, |
|
| 654 | + join(',', $collecte), |
|
| 655 | + ($collecte ? $param : substr($param, 1)), # virer la virgule |
|
| 656 | + memoriser_contexte_compil($p), |
|
| 657 | + (!$supp ? '' : (', ' . join(',', $supp))) |
|
| 658 | + ); |
|
| 659 | + |
|
| 660 | + $p->interdire_scripts = false; |
|
| 661 | + |
|
| 662 | + return $p; |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | |
@@ -689,17 +689,17 @@ discard block |
||
| 689 | 689 | * Liste des codes PHP d'éxecution des balises collectées |
| 690 | 690 | **/ |
| 691 | 691 | function collecter_balise_dynamique(array $l, Champ &$p, string $nom): array { |
| 692 | - $args = []; |
|
| 693 | - foreach ($l as $c) { |
|
| 694 | - if ($c === null) { |
|
| 695 | - $args[] = 'null'; |
|
| 696 | - } else { |
|
| 697 | - $x = calculer_balise($c, $p); |
|
| 698 | - $args[] = $x->code; |
|
| 699 | - } |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - return $args; |
|
| 692 | + $args = []; |
|
| 693 | + foreach ($l as $c) { |
|
| 694 | + if ($c === null) { |
|
| 695 | + $args[] = 'null'; |
|
| 696 | + } else { |
|
| 697 | + $x = calculer_balise($c, $p); |
|
| 698 | + $args[] = $x->code; |
|
| 699 | + } |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + return $args; |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | |
@@ -714,22 +714,22 @@ discard block |
||
| 714 | 714 | * Nom de la connexion |
| 715 | 715 | **/ |
| 716 | 716 | function trouver_nom_serveur_distant($p) { |
| 717 | - $nom = $p->id_boucle; |
|
| 718 | - if ( |
|
| 719 | - $nom |
|
| 720 | - and isset($p->boucles[$nom]) |
|
| 721 | - ) { |
|
| 722 | - $s = $p->boucles[$nom]->sql_serveur; |
|
| 723 | - if ( |
|
| 724 | - strlen($s) |
|
| 725 | - and strlen($serveur = strtolower($s)) |
|
| 726 | - and !in_array($serveur, $GLOBALS['exception_des_connect']) |
|
| 727 | - ) { |
|
| 728 | - return $serveur; |
|
| 729 | - } |
|
| 730 | - } |
|
| 731 | - |
|
| 732 | - return ''; |
|
| 717 | + $nom = $p->id_boucle; |
|
| 718 | + if ( |
|
| 719 | + $nom |
|
| 720 | + and isset($p->boucles[$nom]) |
|
| 721 | + ) { |
|
| 722 | + $s = $p->boucles[$nom]->sql_serveur; |
|
| 723 | + if ( |
|
| 724 | + strlen($s) |
|
| 725 | + and strlen($serveur = strtolower($s)) |
|
| 726 | + and !in_array($serveur, $GLOBALS['exception_des_connect']) |
|
| 727 | + ) { |
|
| 728 | + return $serveur; |
|
| 729 | + } |
|
| 730 | + } |
|
| 731 | + |
|
| 732 | + return ''; |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | |
@@ -753,15 +753,15 @@ discard block |
||
| 753 | 753 | * - false : La balise est interdite car le serveur est distant |
| 754 | 754 | **/ |
| 755 | 755 | function balise_distante_interdite($p) { |
| 756 | - $nom = $p->id_boucle; |
|
| 756 | + $nom = $p->id_boucle; |
|
| 757 | 757 | |
| 758 | - if ($nom and trouver_nom_serveur_distant($p)) { |
|
| 759 | - spip_log($nom . ':' . $p->nom_champ . ' ' . _T('zbug_distant_interdit')); |
|
| 758 | + if ($nom and trouver_nom_serveur_distant($p)) { |
|
| 759 | + spip_log($nom . ':' . $p->nom_champ . ' ' . _T('zbug_distant_interdit')); |
|
| 760 | 760 | |
| 761 | - return false; |
|
| 762 | - } |
|
| 761 | + return false; |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | - return true; |
|
| 764 | + return true; |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | |
@@ -771,84 +771,84 @@ discard block |
||
| 771 | 771 | // |
| 772 | 772 | function champs_traitements($p) { |
| 773 | 773 | |
| 774 | - if (isset($GLOBALS['table_des_traitements'][$p->nom_champ])) { |
|
| 775 | - $ps = $GLOBALS['table_des_traitements'][$p->nom_champ]; |
|
| 776 | - } else { |
|
| 777 | - // quand on utilise un traitement catch-all * |
|
| 778 | - // celui-ci ne s'applique pas sur les balises calculees qui peuvent gerer |
|
| 779 | - // leur propre securite |
|
| 780 | - if (!$p->balise_calculee) { |
|
| 781 | - $ps = $GLOBALS['table_des_traitements']['*']; |
|
| 782 | - } else { |
|
| 783 | - $ps = false; |
|
| 784 | - } |
|
| 785 | - } |
|
| 786 | - |
|
| 787 | - if (is_array($ps)) { |
|
| 788 | - // Recuperer le type de boucle (articles, DATA) et la table SQL sur laquelle elle porte |
|
| 789 | - $idb = index_boucle($p); |
|
| 790 | - // si le champ a ete trouve dans une boucle parente sa source est renseignee ici |
|
| 791 | - if (!empty($p->boucles[$idb]->index_champ[$p->nom_champ])) { |
|
| 792 | - $idb = $p->boucles[$idb]->index_champ[$p->nom_champ]; |
|
| 793 | - } |
|
| 794 | - |
|
| 795 | - // mais on peut aussi etre hors boucle. Se mefier. |
|
| 796 | - $type_requete = $p->boucles[$idb]->type_requete ?? false; |
|
| 797 | - $table_sql = $p->boucles[$idb]->show['table_sql'] ?? false; |
|
| 798 | - |
|
| 799 | - // bien prendre en compte les alias de boucles (hierarchie => rubrique, syndication => syncdic, etc.) |
|
| 800 | - if ($type_requete and isset($GLOBALS['table_des_tables'][$type_requete])) { |
|
| 801 | - $type_alias = $type_requete; |
|
| 802 | - $type_requete = $GLOBALS['table_des_tables'][$type_requete]; |
|
| 803 | - } else { |
|
| 804 | - $type_alias = false; |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - // le traitement peut n'etre defini que pour une table en particulier "spip_articles" |
|
| 808 | - if ($table_sql and isset($ps[$table_sql])) { |
|
| 809 | - $ps = $ps[$table_sql]; |
|
| 810 | - } // ou pour une boucle en particulier "DATA","articles" |
|
| 811 | - elseif ($type_requete and isset($ps[$type_requete])) { |
|
| 812 | - $ps = $ps[$type_requete]; |
|
| 813 | - } // ou pour une boucle utilisant un alias ("hierarchie") |
|
| 814 | - elseif ($type_alias and isset($ps[$type_alias])) { |
|
| 815 | - $ps = $ps[$type_alias]; |
|
| 816 | - } // ou pour indifféremment quelle que soit la boucle |
|
| 817 | - elseif (isset($ps[0])) { |
|
| 818 | - $ps = $ps[0]; |
|
| 819 | - } else { |
|
| 820 | - $ps = false; |
|
| 821 | - } |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - if (!$ps) { |
|
| 825 | - return $p->code; |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - // Si une boucle DOCUMENTS{doublons} est presente dans le squelette, |
|
| 829 | - // ou si in INCLURE contient {doublons} |
|
| 830 | - // on insere une fonction de remplissage du tableau des doublons |
|
| 831 | - // dans les filtres propre() ou typo() |
|
| 832 | - // (qui traitent les raccourcis <docXX> referencant les docs) |
|
| 833 | - |
|
| 834 | - if ( |
|
| 835 | - isset($p->descr['documents']) |
|
| 836 | - and |
|
| 837 | - $p->descr['documents'] |
|
| 838 | - and ( |
|
| 839 | - (strpos($ps, 'propre') !== false) |
|
| 840 | - or |
|
| 841 | - (strpos($ps, 'typo') !== false) |
|
| 842 | - ) |
|
| 843 | - ) { |
|
| 844 | - $ps = 'traiter_doublons_documents($doublons, ' . $ps . ')'; |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - // La protection des champs par |safehtml est assuree par les extensions |
|
| 848 | - // dans la declaration des traitements des champs sensibles |
|
| 849 | - |
|
| 850 | - // Remplacer enfin le placeholder %s par le vrai code de la balise |
|
| 851 | - return str_replace('%s', $p->code, $ps); |
|
| 774 | + if (isset($GLOBALS['table_des_traitements'][$p->nom_champ])) { |
|
| 775 | + $ps = $GLOBALS['table_des_traitements'][$p->nom_champ]; |
|
| 776 | + } else { |
|
| 777 | + // quand on utilise un traitement catch-all * |
|
| 778 | + // celui-ci ne s'applique pas sur les balises calculees qui peuvent gerer |
|
| 779 | + // leur propre securite |
|
| 780 | + if (!$p->balise_calculee) { |
|
| 781 | + $ps = $GLOBALS['table_des_traitements']['*']; |
|
| 782 | + } else { |
|
| 783 | + $ps = false; |
|
| 784 | + } |
|
| 785 | + } |
|
| 786 | + |
|
| 787 | + if (is_array($ps)) { |
|
| 788 | + // Recuperer le type de boucle (articles, DATA) et la table SQL sur laquelle elle porte |
|
| 789 | + $idb = index_boucle($p); |
|
| 790 | + // si le champ a ete trouve dans une boucle parente sa source est renseignee ici |
|
| 791 | + if (!empty($p->boucles[$idb]->index_champ[$p->nom_champ])) { |
|
| 792 | + $idb = $p->boucles[$idb]->index_champ[$p->nom_champ]; |
|
| 793 | + } |
|
| 794 | + |
|
| 795 | + // mais on peut aussi etre hors boucle. Se mefier. |
|
| 796 | + $type_requete = $p->boucles[$idb]->type_requete ?? false; |
|
| 797 | + $table_sql = $p->boucles[$idb]->show['table_sql'] ?? false; |
|
| 798 | + |
|
| 799 | + // bien prendre en compte les alias de boucles (hierarchie => rubrique, syndication => syncdic, etc.) |
|
| 800 | + if ($type_requete and isset($GLOBALS['table_des_tables'][$type_requete])) { |
|
| 801 | + $type_alias = $type_requete; |
|
| 802 | + $type_requete = $GLOBALS['table_des_tables'][$type_requete]; |
|
| 803 | + } else { |
|
| 804 | + $type_alias = false; |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + // le traitement peut n'etre defini que pour une table en particulier "spip_articles" |
|
| 808 | + if ($table_sql and isset($ps[$table_sql])) { |
|
| 809 | + $ps = $ps[$table_sql]; |
|
| 810 | + } // ou pour une boucle en particulier "DATA","articles" |
|
| 811 | + elseif ($type_requete and isset($ps[$type_requete])) { |
|
| 812 | + $ps = $ps[$type_requete]; |
|
| 813 | + } // ou pour une boucle utilisant un alias ("hierarchie") |
|
| 814 | + elseif ($type_alias and isset($ps[$type_alias])) { |
|
| 815 | + $ps = $ps[$type_alias]; |
|
| 816 | + } // ou pour indifféremment quelle que soit la boucle |
|
| 817 | + elseif (isset($ps[0])) { |
|
| 818 | + $ps = $ps[0]; |
|
| 819 | + } else { |
|
| 820 | + $ps = false; |
|
| 821 | + } |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + if (!$ps) { |
|
| 825 | + return $p->code; |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + // Si une boucle DOCUMENTS{doublons} est presente dans le squelette, |
|
| 829 | + // ou si in INCLURE contient {doublons} |
|
| 830 | + // on insere une fonction de remplissage du tableau des doublons |
|
| 831 | + // dans les filtres propre() ou typo() |
|
| 832 | + // (qui traitent les raccourcis <docXX> referencant les docs) |
|
| 833 | + |
|
| 834 | + if ( |
|
| 835 | + isset($p->descr['documents']) |
|
| 836 | + and |
|
| 837 | + $p->descr['documents'] |
|
| 838 | + and ( |
|
| 839 | + (strpos($ps, 'propre') !== false) |
|
| 840 | + or |
|
| 841 | + (strpos($ps, 'typo') !== false) |
|
| 842 | + ) |
|
| 843 | + ) { |
|
| 844 | + $ps = 'traiter_doublons_documents($doublons, ' . $ps . ')'; |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + // La protection des champs par |safehtml est assuree par les extensions |
|
| 848 | + // dans la declaration des traitements des champs sensibles |
|
| 849 | + |
|
| 850 | + // Remplacer enfin le placeholder %s par le vrai code de la balise |
|
| 851 | + return str_replace('%s', $p->code, $ps); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | |
@@ -860,110 +860,110 @@ discard block |
||
| 860 | 860 | // |
| 861 | 861 | function applique_filtres($p) { |
| 862 | 862 | |
| 863 | - // Traitements standards (cf. supra) |
|
| 864 | - if ($p->etoile == '') { |
|
| 865 | - $code = champs_traitements($p); |
|
| 866 | - } else { |
|
| 867 | - $code = $p->code; |
|
| 868 | - } |
|
| 863 | + // Traitements standards (cf. supra) |
|
| 864 | + if ($p->etoile == '') { |
|
| 865 | + $code = champs_traitements($p); |
|
| 866 | + } else { |
|
| 867 | + $code = $p->code; |
|
| 868 | + } |
|
| 869 | 869 | |
| 870 | - // Appliquer les filtres perso |
|
| 871 | - if ($p->param) { |
|
| 872 | - $code = compose_filtres($p, $code); |
|
| 873 | - } |
|
| 870 | + // Appliquer les filtres perso |
|
| 871 | + if ($p->param) { |
|
| 872 | + $code = compose_filtres($p, $code); |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | - // S'il y a un lien avec la session, ajouter un code qui levera |
|
| 876 | - // un drapeau dans la structure d'invalidation $Cache |
|
| 877 | - if (isset($p->descr['session'])) { |
|
| 878 | - $code = "invalideur_session(\$Cache, $code)"; |
|
| 879 | - } |
|
| 875 | + // S'il y a un lien avec la session, ajouter un code qui levera |
|
| 876 | + // un drapeau dans la structure d'invalidation $Cache |
|
| 877 | + if (isset($p->descr['session'])) { |
|
| 878 | + $code = "invalideur_session(\$Cache, $code)"; |
|
| 879 | + } |
|
| 880 | 880 | |
| 881 | - $code = sandbox_composer_interdire_scripts($code, $p); |
|
| 881 | + $code = sandbox_composer_interdire_scripts($code, $p); |
|
| 882 | 882 | |
| 883 | - return $code; |
|
| 883 | + return $code; |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | // Cf. function pipeline dans ecrire/inc_utils.php |
| 887 | 887 | function compose_filtres(&$p, $code) { |
| 888 | 888 | |
| 889 | - $image_miette = false; |
|
| 890 | - foreach ($p->param as $filtre) { |
|
| 891 | - $fonc = array_shift($filtre); |
|
| 892 | - if (!$fonc) { |
|
| 893 | - continue; |
|
| 894 | - } // normalement qu'au premier tour. |
|
| 895 | - $is_filtre_image = ((substr($fonc, 0, 6) == 'image_') and $fonc != 'image_graver'); |
|
| 896 | - if ($image_miette and !$is_filtre_image) { |
|
| 897 | - // il faut graver maintenant car apres le filtre en cours |
|
| 898 | - // on est pas sur d'avoir encore le nom du fichier dans le pipe |
|
| 899 | - $code = "filtrer('image_graver', $code)"; |
|
| 900 | - $image_miette = false; |
|
| 901 | - } |
|
| 902 | - |
|
| 903 | - // recuperer les arguments du filtre, |
|
| 904 | - // a separer par "," ou ":" dans le cas du filtre "?{a,b}" |
|
| 905 | - $countfiltre = is_countable($filtre) ? count($filtre) : 0; |
|
| 906 | - if ($fonc !== '?') { |
|
| 907 | - $sep = ','; |
|
| 908 | - } else { |
|
| 909 | - $sep = ':'; |
|
| 910 | - // |?{a,b} *doit* avoir exactement 2 arguments ; on les force |
|
| 911 | - if ($countfiltre != 2) { |
|
| 912 | - $filtre = [$filtre[0] ?? '', $filtre[1] ?? '']; |
|
| 913 | - $countfiltre = 2; |
|
| 914 | - } |
|
| 915 | - } |
|
| 916 | - $arglist = compose_filtres_args($p, $filtre, $sep); |
|
| 917 | - $logique = filtre_logique($fonc, $code, substr($arglist, 1)); |
|
| 918 | - if ($logique) { |
|
| 919 | - $code = $logique; |
|
| 920 | - } else { |
|
| 921 | - $code = sandbox_composer_filtre($fonc, $code, $arglist, $p, $countfiltre); |
|
| 922 | - if ($is_filtre_image) { |
|
| 923 | - $image_miette = true; |
|
| 924 | - } |
|
| 925 | - } |
|
| 926 | - } |
|
| 927 | - // ramasser les images intermediaires inutiles et graver l'image finale |
|
| 928 | - if ($image_miette) { |
|
| 929 | - $code = "filtrer('image_graver',$code)"; |
|
| 930 | - } |
|
| 931 | - |
|
| 932 | - return $code; |
|
| 889 | + $image_miette = false; |
|
| 890 | + foreach ($p->param as $filtre) { |
|
| 891 | + $fonc = array_shift($filtre); |
|
| 892 | + if (!$fonc) { |
|
| 893 | + continue; |
|
| 894 | + } // normalement qu'au premier tour. |
|
| 895 | + $is_filtre_image = ((substr($fonc, 0, 6) == 'image_') and $fonc != 'image_graver'); |
|
| 896 | + if ($image_miette and !$is_filtre_image) { |
|
| 897 | + // il faut graver maintenant car apres le filtre en cours |
|
| 898 | + // on est pas sur d'avoir encore le nom du fichier dans le pipe |
|
| 899 | + $code = "filtrer('image_graver', $code)"; |
|
| 900 | + $image_miette = false; |
|
| 901 | + } |
|
| 902 | + |
|
| 903 | + // recuperer les arguments du filtre, |
|
| 904 | + // a separer par "," ou ":" dans le cas du filtre "?{a,b}" |
|
| 905 | + $countfiltre = is_countable($filtre) ? count($filtre) : 0; |
|
| 906 | + if ($fonc !== '?') { |
|
| 907 | + $sep = ','; |
|
| 908 | + } else { |
|
| 909 | + $sep = ':'; |
|
| 910 | + // |?{a,b} *doit* avoir exactement 2 arguments ; on les force |
|
| 911 | + if ($countfiltre != 2) { |
|
| 912 | + $filtre = [$filtre[0] ?? '', $filtre[1] ?? '']; |
|
| 913 | + $countfiltre = 2; |
|
| 914 | + } |
|
| 915 | + } |
|
| 916 | + $arglist = compose_filtres_args($p, $filtre, $sep); |
|
| 917 | + $logique = filtre_logique($fonc, $code, substr($arglist, 1)); |
|
| 918 | + if ($logique) { |
|
| 919 | + $code = $logique; |
|
| 920 | + } else { |
|
| 921 | + $code = sandbox_composer_filtre($fonc, $code, $arglist, $p, $countfiltre); |
|
| 922 | + if ($is_filtre_image) { |
|
| 923 | + $image_miette = true; |
|
| 924 | + } |
|
| 925 | + } |
|
| 926 | + } |
|
| 927 | + // ramasser les images intermediaires inutiles et graver l'image finale |
|
| 928 | + if ($image_miette) { |
|
| 929 | + $code = "filtrer('image_graver',$code)"; |
|
| 930 | + } |
|
| 931 | + |
|
| 932 | + return $code; |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | // Filtres et,ou,oui,non,sinon,xou,xor,and,or,not,yes |
| 936 | 936 | // et comparateurs |
| 937 | 937 | function filtre_logique($fonc, $code, $arg) { |
| 938 | 938 | |
| 939 | - switch (true) { |
|
| 940 | - case in_array($fonc, $GLOBALS['table_criteres_infixes']): |
|
| 941 | - return "($code $fonc $arg)"; |
|
| 942 | - case ($fonc == 'and') or ($fonc == 'et'): |
|
| 943 | - return "((($code) AND ($arg)) ?' ' :'')"; |
|
| 944 | - case ($fonc == 'or') or ($fonc == 'ou'): |
|
| 945 | - return "((($code) OR ($arg)) ?' ' :'')"; |
|
| 946 | - case ($fonc == 'xor') or ($fonc == 'xou'): |
|
| 947 | - return "((($code) XOR ($arg)) ?' ' :'')"; |
|
| 948 | - case ($fonc == 'sinon'): |
|
| 949 | - return "(((\$a = $code) OR (is_string(\$a) AND strlen(\$a))) ? \$a : $arg)"; |
|
| 950 | - case ($fonc == 'not') or ($fonc == 'non'): |
|
| 951 | - return "(($code) ?'' :' ')"; |
|
| 952 | - case ($fonc == 'yes') or ($fonc == 'oui'): |
|
| 953 | - return "(($code) ?' ' :'')"; |
|
| 954 | - } |
|
| 955 | - |
|
| 956 | - return ''; |
|
| 939 | + switch (true) { |
|
| 940 | + case in_array($fonc, $GLOBALS['table_criteres_infixes']): |
|
| 941 | + return "($code $fonc $arg)"; |
|
| 942 | + case ($fonc == 'and') or ($fonc == 'et'): |
|
| 943 | + return "((($code) AND ($arg)) ?' ' :'')"; |
|
| 944 | + case ($fonc == 'or') or ($fonc == 'ou'): |
|
| 945 | + return "((($code) OR ($arg)) ?' ' :'')"; |
|
| 946 | + case ($fonc == 'xor') or ($fonc == 'xou'): |
|
| 947 | + return "((($code) XOR ($arg)) ?' ' :'')"; |
|
| 948 | + case ($fonc == 'sinon'): |
|
| 949 | + return "(((\$a = $code) OR (is_string(\$a) AND strlen(\$a))) ? \$a : $arg)"; |
|
| 950 | + case ($fonc == 'not') or ($fonc == 'non'): |
|
| 951 | + return "(($code) ?'' :' ')"; |
|
| 952 | + case ($fonc == 'yes') or ($fonc == 'oui'): |
|
| 953 | + return "(($code) ?' ' :'')"; |
|
| 954 | + } |
|
| 955 | + |
|
| 956 | + return ''; |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | function compose_filtres_args($p, $args, $sep) { |
| 960 | - $arglist = ''; |
|
| 961 | - foreach ($args as $arg) { |
|
| 962 | - $arglist .= $sep . |
|
| 963 | - calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle); |
|
| 964 | - } |
|
| 960 | + $arglist = ''; |
|
| 961 | + foreach ($args as $arg) { |
|
| 962 | + $arglist .= $sep . |
|
| 963 | + calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle); |
|
| 964 | + } |
|
| 965 | 965 | |
| 966 | - return $arglist; |
|
| 966 | + return $arglist; |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | |
@@ -981,15 +981,15 @@ discard block |
||
| 981 | 981 | **/ |
| 982 | 982 | function calculer_argument_precedent($idb, $nom_champ, &$boucles, $defaut = null) { |
| 983 | 983 | |
| 984 | - // si recursif, forcer l'extraction du champ SQL mais ignorer le code |
|
| 985 | - if ($boucles[$idb]->externe) { |
|
| 986 | - index_pile($idb, $nom_champ, $boucles, '', $defaut); |
|
| 987 | - // retourner $Pile[$SP] et pas $Pile[0] si recursion en 1ere boucle |
|
| 988 | - // on ignore le defaut fourni dans ce cas |
|
| 989 | - $defaut = "(\$Pile[\$SP]['$nom_champ'] ?? null)"; |
|
| 990 | - } |
|
| 984 | + // si recursif, forcer l'extraction du champ SQL mais ignorer le code |
|
| 985 | + if ($boucles[$idb]->externe) { |
|
| 986 | + index_pile($idb, $nom_champ, $boucles, '', $defaut); |
|
| 987 | + // retourner $Pile[$SP] et pas $Pile[0] si recursion en 1ere boucle |
|
| 988 | + // on ignore le defaut fourni dans ce cas |
|
| 989 | + $defaut = "(\$Pile[\$SP]['$nom_champ'] ?? null)"; |
|
| 990 | + } |
|
| 991 | 991 | |
| 992 | - return index_pile($boucles[$idb]->id_parent, $nom_champ, $boucles, '', $defaut); |
|
| 992 | + return index_pile($boucles[$idb]->id_parent, $nom_champ, $boucles, '', $defaut); |
|
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | // |
@@ -1003,30 +1003,30 @@ discard block |
||
| 1003 | 1003 | // |
| 1004 | 1004 | |
| 1005 | 1005 | function rindex_pile($p, $champ, $motif) { |
| 1006 | - $n = 0; |
|
| 1007 | - $b = $p->id_boucle; |
|
| 1008 | - $p->code = ''; |
|
| 1009 | - while ($b != '') { |
|
| 1010 | - foreach ($p->boucles[$b]->criteres as $critere) { |
|
| 1011 | - if ($critere->op == $motif) { |
|
| 1012 | - $p->code = '$Pile[$SP' . (($n == 0) ? '' : "-$n") . |
|
| 1013 | - "]['$champ']"; |
|
| 1014 | - $b = ''; |
|
| 1015 | - break 2; |
|
| 1016 | - } |
|
| 1017 | - } |
|
| 1018 | - $n++; |
|
| 1019 | - $b = $p->boucles[$b]->id_parent; |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - // si on est hors d'une boucle de {recherche}, cette balise est vide |
|
| 1023 | - if (!$p->code) { |
|
| 1024 | - $p->code = "''"; |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - $p->interdire_scripts = false; |
|
| 1028 | - |
|
| 1029 | - return $p; |
|
| 1006 | + $n = 0; |
|
| 1007 | + $b = $p->id_boucle; |
|
| 1008 | + $p->code = ''; |
|
| 1009 | + while ($b != '') { |
|
| 1010 | + foreach ($p->boucles[$b]->criteres as $critere) { |
|
| 1011 | + if ($critere->op == $motif) { |
|
| 1012 | + $p->code = '$Pile[$SP' . (($n == 0) ? '' : "-$n") . |
|
| 1013 | + "]['$champ']"; |
|
| 1014 | + $b = ''; |
|
| 1015 | + break 2; |
|
| 1016 | + } |
|
| 1017 | + } |
|
| 1018 | + $n++; |
|
| 1019 | + $b = $p->boucles[$b]->id_parent; |
|
| 1020 | + } |
|
| 1021 | + |
|
| 1022 | + // si on est hors d'une boucle de {recherche}, cette balise est vide |
|
| 1023 | + if (!$p->code) { |
|
| 1024 | + $p->code = "''"; |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + $p->interdire_scripts = false; |
|
| 1028 | + |
|
| 1029 | + return $p; |
|
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | 1032 | /** |
@@ -1036,7 +1036,7 @@ discard block |
||
| 1036 | 1036 | * @return string Nom de la balise, avec indication de boucle explicite si présent. |
| 1037 | 1037 | */ |
| 1038 | 1038 | function zbug_presenter_champ($p, $champ = '') { |
| 1039 | - $balise = $champ ?: $p->nom_champ; |
|
| 1040 | - $explicite = $p->nom_boucle ? $p->nom_boucle . ':' : ''; |
|
| 1041 | - return "#{$explicite}{$balise}"; |
|
| 1039 | + $balise = $champ ?: $p->nom_champ; |
|
| 1040 | + $explicite = $p->nom_boucle ? $p->nom_boucle . ':' : ''; |
|
| 1041 | + return "#{$explicite}{$balise}"; |
|
| 1042 | 1042 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $select = true |
| 128 | 128 | ) { |
| 129 | 129 | if (!is_string($defaut)) { |
| 130 | - $defaut = '($Pile[0][\'' . strtolower($nom_champ) . '\'] ?? null)'; |
|
| 130 | + $defaut = '($Pile[0][\''.strtolower($nom_champ).'\'] ?? null)'; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $idb_origine = $idb; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | // renseigner la boucle source de ce champ pour les traitements |
| 162 | 162 | $boucles[$idb_origine]->index_champ[$nom_champ_origine] = $idb; |
| 163 | - $champ = '$Pile[$SP' . ($i ? "-$i" : '') . '][\'' . $c . '\']'; |
|
| 163 | + $champ = '$Pile[$SP'.($i ? "-$i" : '').'][\''.$c.'\']'; |
|
| 164 | 164 | if (!$joker) { |
| 165 | 165 | return index_compose($conditionnel, $champ); |
| 166 | 166 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | function index_compose($conditionnel, $defaut) { |
| 202 | 202 | while ($c = array_pop($conditionnel)) { |
| 203 | 203 | // si on passe defaut = '', ne pas générer d'erreur de compilation. |
| 204 | - $defaut = "($c:(" . ($defaut ?: "''") . '))'; |
|
| 204 | + $defaut = "($c:(".($defaut ?: "''").'))'; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | return $defaut; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | if (!$r) { |
| 249 | 249 | $joker = false; // indiquer a l'appelant |
| 250 | 250 | # continuer pour chercher l'erreur suivante |
| 251 | - return ["'#" . $r . ':' . $nom_champ . "'", '']; |
|
| 251 | + return ["'#".$r.':'.$nom_champ."'", '']; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | $desc = $boucles[$idb]->show; |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | if (preg_match('/^(.*)\.(.*)$/', $nom_champ, $r)) { |
| 292 | 292 | [, $_table, $_nom_champ] = $r; |
| 293 | 293 | if ($cle = trouver_jointure_champ($_nom_champ, $boucles[$idb], [$_table])) { |
| 294 | - $_alias = $cle . '_' . $_nom_champ; |
|
| 294 | + $_alias = $cle.'_'.$_nom_champ; |
|
| 295 | 295 | return index_exception( |
| 296 | 296 | $boucles[$idb], |
| 297 | 297 | $desc, |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | $t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep); |
| 372 | 372 | } |
| 373 | 373 | if ($t == null) { |
| 374 | - [$e, $x] = $excep; #PHP4 affecte de gauche a droite |
|
| 375 | - $excep = $x; #PHP5 de droite a gauche ! |
|
| 374 | + [$e, $x] = $excep; #PHP4 affecte de gauche a droite |
|
| 375 | + $excep = $x; #PHP5 de droite a gauche ! |
|
| 376 | 376 | $j = $trouver_table($e, $boucle->sql_serveur); |
| 377 | 377 | if (!$j) { |
| 378 | 378 | return ['', '']; |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | $l = (preg_split('/\s*,\s*/', $k)); |
| 385 | 385 | $k = $desc['key']['PRIMARY KEY']; |
| 386 | 386 | if (!in_array($k, $l)) { |
| 387 | - spip_log("jointure impossible $e " . join(',', $l)); |
|
| 387 | + spip_log("jointure impossible $e ".join(',', $l)); |
|
| 388 | 388 | |
| 389 | 389 | return ['', '']; |
| 390 | 390 | } |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | // demander a SQL de gerer le synonyme |
| 401 | 401 | // ca permet que excep soit dynamique (Cedric, 2/3/06) |
| 402 | 402 | if ($excep != $nom_champ) { |
| 403 | - $excep .= ' AS ' . $nom_champ; |
|
| 403 | + $excep .= ' AS '.$nom_champ; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | return ["$t.$excep", $nom_champ]; |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | join(',', $collecte), |
| 655 | 655 | ($collecte ? $param : substr($param, 1)), # virer la virgule |
| 656 | 656 | memoriser_contexte_compil($p), |
| 657 | - (!$supp ? '' : (', ' . join(',', $supp))) |
|
| 657 | + (!$supp ? '' : (', '.join(',', $supp))) |
|
| 658 | 658 | ); |
| 659 | 659 | |
| 660 | 660 | $p->interdire_scripts = false; |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | * @return array |
| 689 | 689 | * Liste des codes PHP d'éxecution des balises collectées |
| 690 | 690 | **/ |
| 691 | -function collecter_balise_dynamique(array $l, Champ &$p, string $nom): array { |
|
| 691 | +function collecter_balise_dynamique(array $l, Champ & $p, string $nom): array { |
|
| 692 | 692 | $args = []; |
| 693 | 693 | foreach ($l as $c) { |
| 694 | 694 | if ($c === null) { |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | $nom = $p->id_boucle; |
| 757 | 757 | |
| 758 | 758 | if ($nom and trouver_nom_serveur_distant($p)) { |
| 759 | - spip_log($nom . ':' . $p->nom_champ . ' ' . _T('zbug_distant_interdit')); |
|
| 759 | + spip_log($nom.':'.$p->nom_champ.' '._T('zbug_distant_interdit')); |
|
| 760 | 760 | |
| 761 | 761 | return false; |
| 762 | 762 | } |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | (strpos($ps, 'typo') !== false) |
| 842 | 842 | ) |
| 843 | 843 | ) { |
| 844 | - $ps = 'traiter_doublons_documents($doublons, ' . $ps . ')'; |
|
| 844 | + $ps = 'traiter_doublons_documents($doublons, '.$ps.')'; |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | // La protection des champs par |safehtml est assuree par les extensions |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | function compose_filtres_args($p, $args, $sep) { |
| 960 | 960 | $arglist = ''; |
| 961 | 961 | foreach ($args as $arg) { |
| 962 | - $arglist .= $sep . |
|
| 962 | + $arglist .= $sep. |
|
| 963 | 963 | calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle); |
| 964 | 964 | } |
| 965 | 965 | |
@@ -1009,7 +1009,7 @@ discard block |
||
| 1009 | 1009 | while ($b != '') { |
| 1010 | 1010 | foreach ($p->boucles[$b]->criteres as $critere) { |
| 1011 | 1011 | if ($critere->op == $motif) { |
| 1012 | - $p->code = '$Pile[$SP' . (($n == 0) ? '' : "-$n") . |
|
| 1012 | + $p->code = '$Pile[$SP'.(($n == 0) ? '' : "-$n"). |
|
| 1013 | 1013 | "]['$champ']"; |
| 1014 | 1014 | $b = ''; |
| 1015 | 1015 | break 2; |
@@ -1037,6 +1037,6 @@ discard block |
||
| 1037 | 1037 | */ |
| 1038 | 1038 | function zbug_presenter_champ($p, $champ = '') { |
| 1039 | 1039 | $balise = $champ ?: $p->nom_champ; |
| 1040 | - $explicite = $p->nom_boucle ? $p->nom_boucle . ':' : ''; |
|
| 1040 | + $explicite = $p->nom_boucle ? $p->nom_boucle.':' : ''; |
|
| 1041 | 1041 | return "#{$explicite}{$balise}"; |
| 1042 | 1042 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @package SPIP\Core\Public\Styliser |
| 20 | 20 | **/ |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -29,193 +29,193 @@ discard block |
||
| 29 | 29 | * @return array Données modifiées du pipeline |
| 30 | 30 | */ |
| 31 | 31 | function public_styliser_par_z_dist($flux) { |
| 32 | - static $prefix_path = null; |
|
| 33 | - static $prefix_length; |
|
| 34 | - static $z_blocs; |
|
| 35 | - static $apl_constant; |
|
| 36 | - static $page; |
|
| 37 | - static $disponible = []; |
|
| 38 | - static $echafauder; |
|
| 39 | - static $prepend = ''; |
|
| 40 | - |
|
| 41 | - if (!isset($prefix_path)) { |
|
| 42 | - $z_blocs = z_blocs(test_espace_prive()); |
|
| 43 | - if (test_espace_prive()) { |
|
| 44 | - $prefix_path = 'prive/squelettes/'; |
|
| 45 | - $prefix_length = strlen($prefix_path); |
|
| 46 | - $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD'; |
|
| 47 | - $page = 'exec'; |
|
| 48 | - $echafauder = charger_fonction('echafauder', 'prive', true); |
|
| 49 | - define('_ZCORE_EXCLURE_PATH', ''); |
|
| 50 | - } else { |
|
| 51 | - $prefix_path = ''; |
|
| 52 | - $prefix_length = 0; |
|
| 53 | - $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
|
| 54 | - $page = _SPIP_PAGE; |
|
| 55 | - $echafauder = charger_fonction('echafauder', 'public', true); |
|
| 56 | - define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim( |
|
| 57 | - _DIR_PLUGIN_DIST, |
|
| 58 | - '/' |
|
| 59 | - ) : '')); |
|
| 60 | - } |
|
| 61 | - $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ''); |
|
| 62 | - } |
|
| 63 | - $z_contenu = reset($z_blocs); // contenu par defaut |
|
| 64 | - |
|
| 65 | - $fond = $flux['args']['fond']; |
|
| 66 | - |
|
| 67 | - if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) { |
|
| 68 | - $fond = substr($fond, $prefix_length); |
|
| 69 | - $squelette = $flux['data']; |
|
| 70 | - $ext = $flux['args']['ext']; |
|
| 71 | - // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax |
|
| 72 | - if ( |
|
| 73 | - defined('_Z_AJAX_PARALLEL_LOAD_OK') |
|
| 74 | - and $dir = explode('/', $fond) |
|
| 75 | - and count($dir) == 2 // pas un sous repertoire |
|
| 76 | - and $dir = reset($dir) |
|
| 77 | - and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
|
| 78 | - and defined($apl_constant) |
|
| 79 | - and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
|
| 80 | - and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 81 | - ) { |
|
| 82 | - $flux['data'] = $pipe; |
|
| 83 | - |
|
| 84 | - return $flux; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // surcharger aussi les squelettes venant de squelettes-dist/ |
|
| 88 | - if ($squelette and !z_fond_valide($squelette)) { |
|
| 89 | - $squelette = ''; |
|
| 90 | - $echafauder = ''; |
|
| 91 | - } |
|
| 92 | - if ($prepend) { |
|
| 93 | - $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 94 | - if ($squelette) { |
|
| 95 | - $flux['data'] = $squelette; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // gerer les squelettes non trouves |
|
| 100 | - // -> router vers les /dist.html |
|
| 101 | - // ou scaffolding ou page automatique les contenus |
|
| 102 | - if (!$squelette) { |
|
| 103 | - // si on est sur un ?page=XX non trouve |
|
| 104 | - if ( |
|
| 105 | - (isset($flux['args']['contexte'][$page]) |
|
| 106 | - and $flux['args']['contexte'][$page] == $fond) |
|
| 107 | - or (isset($flux['args']['contexte']['type-page']) |
|
| 108 | - and $flux['args']['contexte']['type-page'] == $fond) |
|
| 109 | - or ($fond == 'sommaire' |
|
| 110 | - and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page])) |
|
| 111 | - ) { |
|
| 112 | - // si on est sur un ?page=XX non trouve |
|
| 113 | - // se brancher sur contenu/xx si il existe |
|
| 114 | - // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
|
| 115 | - if (!isset($disponible[$fond])) { |
|
| 116 | - $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ($disponible[$fond]) { |
|
| 120 | - $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // echafaudage : |
|
| 125 | - // si c'est un fond de contenu d'un objet en base |
|
| 126 | - // generer un fond automatique a la volee pour les webmestres |
|
| 127 | - elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) { |
|
| 128 | - $type = substr($fond, strlen($z_contenu) + 1); |
|
| 129 | - if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 130 | - $type = $flux['args']['contexte'][$page]; |
|
| 131 | - } |
|
| 132 | - if (!isset($disponible[$type])) { |
|
| 133 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 134 | - } |
|
| 135 | - if (is_string($disponible[$type])) { |
|
| 136 | - $flux['data'] = $disponible[$type]; |
|
| 137 | - } elseif ( |
|
| 138 | - $echafauder |
|
| 139 | - and include_spip('inc/autoriser') |
|
| 140 | - and isset($GLOBALS['visiteur_session']['statut']) // performance |
|
| 141 | - and autoriser('echafauder', $type) |
|
| 142 | - and $is = $disponible[$type] |
|
| 143 | - and is_array($is) |
|
| 144 | - ) { |
|
| 145 | - $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
|
| 146 | - } else { |
|
| 147 | - $flux['data'] = ($disponible['404'] = z_contenu_disponible( |
|
| 148 | - $prefix_path . $prepend, |
|
| 149 | - $z_contenu, |
|
| 150 | - '404', |
|
| 151 | - $ext, |
|
| 152 | - $echafauder |
|
| 153 | - )); |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - // sinon, si on demande un fond non trouve dans un des autres blocs |
|
| 158 | - // et si il y a bien un contenu correspondant ou echafaudable |
|
| 159 | - // se rabbatre sur le dist.html du bloc concerne |
|
| 160 | - else { |
|
| 161 | - if ( |
|
| 162 | - $dir = explode('/', $fond) |
|
| 163 | - and $dir = reset($dir) |
|
| 164 | - and $dir !== $z_contenu |
|
| 165 | - and in_array($dir, $z_blocs) |
|
| 166 | - ) { |
|
| 167 | - $type = substr($fond, strlen("$dir/")); |
|
| 168 | - if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 169 | - $type = $flux['args']['contexte'][$page]; |
|
| 170 | - } |
|
| 171 | - if ($type !== 'page' and !isset($disponible[$type])) { |
|
| 172 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 173 | - } |
|
| 174 | - if ($type == 'page' or $disponible[$type]) { |
|
| 175 | - $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - $squelette = $flux['data']; |
|
| 180 | - } |
|
| 181 | - // layout specifiques par type et compositions : |
|
| 182 | - // body-article.html |
|
| 183 | - // body-sommaire.html |
|
| 184 | - // pour des raisons de perfo, les declinaisons doivent etre dans le |
|
| 185 | - // meme dossier que body.html |
|
| 186 | - if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) { |
|
| 187 | - if ( |
|
| 188 | - isset($flux['args']['contexte']['type-page']) |
|
| 189 | - and ( |
|
| 190 | - (isset($flux['args']['contexte']['composition']) |
|
| 191 | - and file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page'] . '-' . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 192 | - or |
|
| 193 | - file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 194 | - ) |
|
| 195 | - ) { |
|
| 196 | - $flux['data'] = $f; |
|
| 197 | - } |
|
| 198 | - } elseif ( |
|
| 199 | - $fond == 'structure' |
|
| 200 | - and z_sanitize_var_zajax() |
|
| 201 | - and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 202 | - ) { |
|
| 203 | - $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 204 | - } // chercher le fond correspondant a la composition |
|
| 205 | - elseif ( |
|
| 206 | - isset($flux['args']['contexte']['composition']) |
|
| 207 | - and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond)) |
|
| 208 | - and $dir = substr($fond, $prefix_length) |
|
| 209 | - and $dir = explode('/', $dir) |
|
| 210 | - and $dir = reset($dir) |
|
| 211 | - and in_array($dir, $z_blocs) |
|
| 212 | - and $f = find_in_path($prefix_path . $prepend . $fond . '-' . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 213 | - ) { |
|
| 214 | - $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - return $flux; |
|
| 32 | + static $prefix_path = null; |
|
| 33 | + static $prefix_length; |
|
| 34 | + static $z_blocs; |
|
| 35 | + static $apl_constant; |
|
| 36 | + static $page; |
|
| 37 | + static $disponible = []; |
|
| 38 | + static $echafauder; |
|
| 39 | + static $prepend = ''; |
|
| 40 | + |
|
| 41 | + if (!isset($prefix_path)) { |
|
| 42 | + $z_blocs = z_blocs(test_espace_prive()); |
|
| 43 | + if (test_espace_prive()) { |
|
| 44 | + $prefix_path = 'prive/squelettes/'; |
|
| 45 | + $prefix_length = strlen($prefix_path); |
|
| 46 | + $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD'; |
|
| 47 | + $page = 'exec'; |
|
| 48 | + $echafauder = charger_fonction('echafauder', 'prive', true); |
|
| 49 | + define('_ZCORE_EXCLURE_PATH', ''); |
|
| 50 | + } else { |
|
| 51 | + $prefix_path = ''; |
|
| 52 | + $prefix_length = 0; |
|
| 53 | + $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
|
| 54 | + $page = _SPIP_PAGE; |
|
| 55 | + $echafauder = charger_fonction('echafauder', 'public', true); |
|
| 56 | + define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim( |
|
| 57 | + _DIR_PLUGIN_DIST, |
|
| 58 | + '/' |
|
| 59 | + ) : '')); |
|
| 60 | + } |
|
| 61 | + $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ''); |
|
| 62 | + } |
|
| 63 | + $z_contenu = reset($z_blocs); // contenu par defaut |
|
| 64 | + |
|
| 65 | + $fond = $flux['args']['fond']; |
|
| 66 | + |
|
| 67 | + if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) { |
|
| 68 | + $fond = substr($fond, $prefix_length); |
|
| 69 | + $squelette = $flux['data']; |
|
| 70 | + $ext = $flux['args']['ext']; |
|
| 71 | + // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax |
|
| 72 | + if ( |
|
| 73 | + defined('_Z_AJAX_PARALLEL_LOAD_OK') |
|
| 74 | + and $dir = explode('/', $fond) |
|
| 75 | + and count($dir) == 2 // pas un sous repertoire |
|
| 76 | + and $dir = reset($dir) |
|
| 77 | + and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
|
| 78 | + and defined($apl_constant) |
|
| 79 | + and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
|
| 80 | + and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 81 | + ) { |
|
| 82 | + $flux['data'] = $pipe; |
|
| 83 | + |
|
| 84 | + return $flux; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // surcharger aussi les squelettes venant de squelettes-dist/ |
|
| 88 | + if ($squelette and !z_fond_valide($squelette)) { |
|
| 89 | + $squelette = ''; |
|
| 90 | + $echafauder = ''; |
|
| 91 | + } |
|
| 92 | + if ($prepend) { |
|
| 93 | + $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 94 | + if ($squelette) { |
|
| 95 | + $flux['data'] = $squelette; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // gerer les squelettes non trouves |
|
| 100 | + // -> router vers les /dist.html |
|
| 101 | + // ou scaffolding ou page automatique les contenus |
|
| 102 | + if (!$squelette) { |
|
| 103 | + // si on est sur un ?page=XX non trouve |
|
| 104 | + if ( |
|
| 105 | + (isset($flux['args']['contexte'][$page]) |
|
| 106 | + and $flux['args']['contexte'][$page] == $fond) |
|
| 107 | + or (isset($flux['args']['contexte']['type-page']) |
|
| 108 | + and $flux['args']['contexte']['type-page'] == $fond) |
|
| 109 | + or ($fond == 'sommaire' |
|
| 110 | + and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page])) |
|
| 111 | + ) { |
|
| 112 | + // si on est sur un ?page=XX non trouve |
|
| 113 | + // se brancher sur contenu/xx si il existe |
|
| 114 | + // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
|
| 115 | + if (!isset($disponible[$fond])) { |
|
| 116 | + $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ($disponible[$fond]) { |
|
| 120 | + $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // echafaudage : |
|
| 125 | + // si c'est un fond de contenu d'un objet en base |
|
| 126 | + // generer un fond automatique a la volee pour les webmestres |
|
| 127 | + elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) { |
|
| 128 | + $type = substr($fond, strlen($z_contenu) + 1); |
|
| 129 | + if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 130 | + $type = $flux['args']['contexte'][$page]; |
|
| 131 | + } |
|
| 132 | + if (!isset($disponible[$type])) { |
|
| 133 | + $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 134 | + } |
|
| 135 | + if (is_string($disponible[$type])) { |
|
| 136 | + $flux['data'] = $disponible[$type]; |
|
| 137 | + } elseif ( |
|
| 138 | + $echafauder |
|
| 139 | + and include_spip('inc/autoriser') |
|
| 140 | + and isset($GLOBALS['visiteur_session']['statut']) // performance |
|
| 141 | + and autoriser('echafauder', $type) |
|
| 142 | + and $is = $disponible[$type] |
|
| 143 | + and is_array($is) |
|
| 144 | + ) { |
|
| 145 | + $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
|
| 146 | + } else { |
|
| 147 | + $flux['data'] = ($disponible['404'] = z_contenu_disponible( |
|
| 148 | + $prefix_path . $prepend, |
|
| 149 | + $z_contenu, |
|
| 150 | + '404', |
|
| 151 | + $ext, |
|
| 152 | + $echafauder |
|
| 153 | + )); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + // sinon, si on demande un fond non trouve dans un des autres blocs |
|
| 158 | + // et si il y a bien un contenu correspondant ou echafaudable |
|
| 159 | + // se rabbatre sur le dist.html du bloc concerne |
|
| 160 | + else { |
|
| 161 | + if ( |
|
| 162 | + $dir = explode('/', $fond) |
|
| 163 | + and $dir = reset($dir) |
|
| 164 | + and $dir !== $z_contenu |
|
| 165 | + and in_array($dir, $z_blocs) |
|
| 166 | + ) { |
|
| 167 | + $type = substr($fond, strlen("$dir/")); |
|
| 168 | + if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 169 | + $type = $flux['args']['contexte'][$page]; |
|
| 170 | + } |
|
| 171 | + if ($type !== 'page' and !isset($disponible[$type])) { |
|
| 172 | + $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 173 | + } |
|
| 174 | + if ($type == 'page' or $disponible[$type]) { |
|
| 175 | + $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + $squelette = $flux['data']; |
|
| 180 | + } |
|
| 181 | + // layout specifiques par type et compositions : |
|
| 182 | + // body-article.html |
|
| 183 | + // body-sommaire.html |
|
| 184 | + // pour des raisons de perfo, les declinaisons doivent etre dans le |
|
| 185 | + // meme dossier que body.html |
|
| 186 | + if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) { |
|
| 187 | + if ( |
|
| 188 | + isset($flux['args']['contexte']['type-page']) |
|
| 189 | + and ( |
|
| 190 | + (isset($flux['args']['contexte']['composition']) |
|
| 191 | + and file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page'] . '-' . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 192 | + or |
|
| 193 | + file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 194 | + ) |
|
| 195 | + ) { |
|
| 196 | + $flux['data'] = $f; |
|
| 197 | + } |
|
| 198 | + } elseif ( |
|
| 199 | + $fond == 'structure' |
|
| 200 | + and z_sanitize_var_zajax() |
|
| 201 | + and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 202 | + ) { |
|
| 203 | + $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 204 | + } // chercher le fond correspondant a la composition |
|
| 205 | + elseif ( |
|
| 206 | + isset($flux['args']['contexte']['composition']) |
|
| 207 | + and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond)) |
|
| 208 | + and $dir = substr($fond, $prefix_length) |
|
| 209 | + and $dir = explode('/', $dir) |
|
| 210 | + and $dir = reset($dir) |
|
| 211 | + and in_array($dir, $z_blocs) |
|
| 212 | + and $f = find_in_path($prefix_path . $prepend . $fond . '-' . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 213 | + ) { |
|
| 214 | + $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + return $flux; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -225,18 +225,18 @@ discard block |
||
| 225 | 225 | * @return array |
| 226 | 226 | */ |
| 227 | 227 | function z_blocs($espace_prive = false) { |
| 228 | - if ($espace_prive) { |
|
| 229 | - return ($GLOBALS['z_blocs_ecrire'] ?? [ |
|
| 230 | - 'contenu', |
|
| 231 | - 'navigation', |
|
| 232 | - 'extra', |
|
| 233 | - 'head', |
|
| 234 | - 'hierarchie', |
|
| 235 | - 'top' |
|
| 236 | - ]); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - return ($GLOBALS['z_blocs'] ?? ['contenu']); |
|
| 228 | + if ($espace_prive) { |
|
| 229 | + return ($GLOBALS['z_blocs_ecrire'] ?? [ |
|
| 230 | + 'contenu', |
|
| 231 | + 'navigation', |
|
| 232 | + 'extra', |
|
| 233 | + 'head', |
|
| 234 | + 'hierarchie', |
|
| 235 | + 'top' |
|
| 236 | + ]); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + return ($GLOBALS['z_blocs'] ?? ['contenu']); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | * @return mixed |
| 252 | 252 | */ |
| 253 | 253 | function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) { |
| 254 | - if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
|
| 255 | - return $d; |
|
| 256 | - } |
|
| 254 | + if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
|
| 255 | + return $d; |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - return $echafauder ? z_echafaudable($type) : false; |
|
| 258 | + return $echafauder ? z_echafaudable($type) : false; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -269,14 +269,14 @@ discard block |
||
| 269 | 269 | * `true` si on peut l'utiliser, `false` sinon. |
| 270 | 270 | **/ |
| 271 | 271 | function z_fond_valide($squelette) { |
| 272 | - if ( |
|
| 273 | - !_ZCORE_EXCLURE_PATH |
|
| 274 | - or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 275 | - ) { |
|
| 276 | - return true; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - return false; |
|
| 272 | + if ( |
|
| 273 | + !_ZCORE_EXCLURE_PATH |
|
| 274 | + or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 275 | + ) { |
|
| 276 | + return true; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + return false; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | * @return string |
| 295 | 295 | */ |
| 296 | 296 | function z_trouver_bloc($prefix_path, $bloc, $fond, $ext) { |
| 297 | - if ( |
|
| 298 | - (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f)) |
|
| 299 | - or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f)) |
|
| 300 | - ) { |
|
| 301 | - return substr($f, 0, -strlen(".$ext")); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - return ''; |
|
| 297 | + if ( |
|
| 298 | + (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f)) |
|
| 299 | + or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f)) |
|
| 300 | + ) { |
|
| 301 | + return substr($f, 0, -strlen(".$ext")); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + return ''; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -313,52 +313,52 @@ discard block |
||
| 313 | 313 | * @return bool |
| 314 | 314 | */ |
| 315 | 315 | function z_echafaudable($type) { |
| 316 | - static $pages = null; |
|
| 317 | - static $echafaudable = []; |
|
| 318 | - if (isset($echafaudable[$type])) { |
|
| 319 | - return $echafaudable[$type]; |
|
| 320 | - } |
|
| 321 | - if (preg_match(',[^\w],', $type)) { |
|
| 322 | - return $echafaudable[$type] = false; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - if (test_espace_prive()) { |
|
| 326 | - if (!function_exists('trouver_objet_exec')) { |
|
| 327 | - include_spip('inc/pipelines_ecrire'); |
|
| 328 | - } |
|
| 329 | - if ($e = trouver_objet_exec($type)) { |
|
| 330 | - return $echafaudable[$type] = [$e['table'], $e['table_objet_sql'], $e]; |
|
| 331 | - } else { |
|
| 332 | - // peut etre c'est un exec=types qui liste tous les objets "type" |
|
| 333 | - if ( |
|
| 334 | - ($t = objet_type($type, false)) !== $type |
|
| 335 | - and $e = trouver_objet_exec($t) |
|
| 336 | - ) { |
|
| 337 | - return $echafaudable[$type] = [$e['table'], $e['table_objet_sql'], $t]; |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - } else { |
|
| 341 | - if (is_null($pages)) { |
|
| 342 | - $pages = []; |
|
| 343 | - $liste = lister_tables_objets_sql(); |
|
| 344 | - foreach ($liste as $t => $d) { |
|
| 345 | - if ($d['page']) { |
|
| 346 | - $pages[$d['page']] = [$d['table_objet'], $t]; |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - if (!isset($pages[$type])) { |
|
| 351 | - return $echafaudable[$type] = false; |
|
| 352 | - } |
|
| 353 | - if ((is_countable($pages[$type]) ? count($pages[$type]) : 0) == 2) { |
|
| 354 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 355 | - $pages[$type][] = $trouver_table(reset($pages[$type])); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - return $echafaudable[$type] = $pages[$type]; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - return $echafaudable[$type] = false; |
|
| 316 | + static $pages = null; |
|
| 317 | + static $echafaudable = []; |
|
| 318 | + if (isset($echafaudable[$type])) { |
|
| 319 | + return $echafaudable[$type]; |
|
| 320 | + } |
|
| 321 | + if (preg_match(',[^\w],', $type)) { |
|
| 322 | + return $echafaudable[$type] = false; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + if (test_espace_prive()) { |
|
| 326 | + if (!function_exists('trouver_objet_exec')) { |
|
| 327 | + include_spip('inc/pipelines_ecrire'); |
|
| 328 | + } |
|
| 329 | + if ($e = trouver_objet_exec($type)) { |
|
| 330 | + return $echafaudable[$type] = [$e['table'], $e['table_objet_sql'], $e]; |
|
| 331 | + } else { |
|
| 332 | + // peut etre c'est un exec=types qui liste tous les objets "type" |
|
| 333 | + if ( |
|
| 334 | + ($t = objet_type($type, false)) !== $type |
|
| 335 | + and $e = trouver_objet_exec($t) |
|
| 336 | + ) { |
|
| 337 | + return $echafaudable[$type] = [$e['table'], $e['table_objet_sql'], $t]; |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + } else { |
|
| 341 | + if (is_null($pages)) { |
|
| 342 | + $pages = []; |
|
| 343 | + $liste = lister_tables_objets_sql(); |
|
| 344 | + foreach ($liste as $t => $d) { |
|
| 345 | + if ($d['page']) { |
|
| 346 | + $pages[$d['page']] = [$d['table_objet'], $t]; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + if (!isset($pages[$type])) { |
|
| 351 | + return $echafaudable[$type] = false; |
|
| 352 | + } |
|
| 353 | + if ((is_countable($pages[$type]) ? count($pages[$type]) : 0) == 2) { |
|
| 354 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 355 | + $pages[$type][] = $trouver_table(reset($pages[$type])); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + return $echafaudable[$type] = $pages[$type]; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + return $echafaudable[$type] = false; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | |
@@ -375,46 +375,46 @@ discard block |
||
| 375 | 375 | * @return string |
| 376 | 376 | */ |
| 377 | 377 | function prive_echafauder_dist($exec, $table, $table_sql, $desc_exec, $ext) { |
| 378 | - $scaffold = ''; |
|
| 379 | - |
|
| 380 | - // page objet ou objet_edit |
|
| 381 | - if (is_array($desc_exec)) { |
|
| 382 | - $type = $desc_exec['type']; |
|
| 383 | - $primary = $desc_exec['id_table_objet']; |
|
| 384 | - |
|
| 385 | - if ($desc_exec['edition'] === false) { |
|
| 386 | - $fond = 'objet'; |
|
| 387 | - } else { |
|
| 388 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 389 | - $desc = $trouver_table($table_sql); |
|
| 390 | - if (isset($desc['field']['id_rubrique'])) { |
|
| 391 | - $fond = 'objet_edit'; |
|
| 392 | - } else { |
|
| 393 | - $fond = 'objet_edit.sans_rubrique'; |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - $dir = z_blocs(test_espace_prive()); |
|
| 397 | - $dir = reset($dir); |
|
| 398 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ',objet=' . $type . ',id_objet=#' . strtoupper($primary) . ',env}>'; |
|
| 399 | - } // page objets |
|
| 400 | - elseif ($type = $desc_exec and !str_contains($type, '/')) { |
|
| 401 | - $dir = z_blocs(test_espace_prive()); |
|
| 402 | - $dir = reset($dir); |
|
| 403 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ',env} />'; |
|
| 404 | - } |
|
| 405 | - // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
|
| 406 | - // et objet et tire de $table |
|
| 407 | - elseif ($fond = $desc_exec) { |
|
| 408 | - $dir = md5(dirname($fond)); |
|
| 409 | - $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ',env} />'; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - $base_dir = sous_repertoire(_DIR_CACHE, 'scaffold', false); |
|
| 413 | - $base_dir = sous_repertoire($base_dir, $dir, false); |
|
| 414 | - $f = $base_dir . "$exec"; |
|
| 415 | - ecrire_fichier("$f.$ext", $scaffold); |
|
| 416 | - |
|
| 417 | - return $f; |
|
| 378 | + $scaffold = ''; |
|
| 379 | + |
|
| 380 | + // page objet ou objet_edit |
|
| 381 | + if (is_array($desc_exec)) { |
|
| 382 | + $type = $desc_exec['type']; |
|
| 383 | + $primary = $desc_exec['id_table_objet']; |
|
| 384 | + |
|
| 385 | + if ($desc_exec['edition'] === false) { |
|
| 386 | + $fond = 'objet'; |
|
| 387 | + } else { |
|
| 388 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 389 | + $desc = $trouver_table($table_sql); |
|
| 390 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 391 | + $fond = 'objet_edit'; |
|
| 392 | + } else { |
|
| 393 | + $fond = 'objet_edit.sans_rubrique'; |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + $dir = z_blocs(test_espace_prive()); |
|
| 397 | + $dir = reset($dir); |
|
| 398 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ',objet=' . $type . ',id_objet=#' . strtoupper($primary) . ',env}>'; |
|
| 399 | + } // page objets |
|
| 400 | + elseif ($type = $desc_exec and !str_contains($type, '/')) { |
|
| 401 | + $dir = z_blocs(test_espace_prive()); |
|
| 402 | + $dir = reset($dir); |
|
| 403 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ',env} />'; |
|
| 404 | + } |
|
| 405 | + // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
|
| 406 | + // et objet et tire de $table |
|
| 407 | + elseif ($fond = $desc_exec) { |
|
| 408 | + $dir = md5(dirname($fond)); |
|
| 409 | + $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ',env} />'; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + $base_dir = sous_repertoire(_DIR_CACHE, 'scaffold', false); |
|
| 413 | + $base_dir = sous_repertoire($base_dir, $dir, false); |
|
| 414 | + $f = $base_dir . "$exec"; |
|
| 415 | + ecrire_fichier("$f.$ext", $scaffold); |
|
| 416 | + |
|
| 417 | + return $f; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -423,17 +423,17 @@ discard block |
||
| 423 | 423 | * @return bool|string |
| 424 | 424 | */ |
| 425 | 425 | function z_sanitize_var_zajax() { |
| 426 | - $z_ajax = _request('var_zajax'); |
|
| 427 | - if (!$z_ajax) { |
|
| 428 | - return false; |
|
| 429 | - } |
|
| 430 | - if ( |
|
| 431 | - !$z_blocs = z_blocs(test_espace_prive()) |
|
| 432 | - or !in_array($z_ajax, $z_blocs) |
|
| 433 | - ) { |
|
| 434 | - set_request('var_zajax'); // enlever cette demande incongrue |
|
| 435 | - $z_ajax = false; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - return $z_ajax; |
|
| 426 | + $z_ajax = _request('var_zajax'); |
|
| 427 | + if (!$z_ajax) { |
|
| 428 | + return false; |
|
| 429 | + } |
|
| 430 | + if ( |
|
| 431 | + !$z_blocs = z_blocs(test_espace_prive()) |
|
| 432 | + or !in_array($z_ajax, $z_blocs) |
|
| 433 | + ) { |
|
| 434 | + set_request('var_zajax'); // enlever cette demande incongrue |
|
| 435 | + $z_ajax = false; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + return $z_ajax; |
|
| 439 | 439 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
| 54 | 54 | $page = _SPIP_PAGE; |
| 55 | 55 | $echafauder = charger_fonction('echafauder', 'public', true); |
| 56 | - define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim( |
|
| 56 | + define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist'.(defined('_DIR_PLUGIN_DIST') ? '|\b'.rtrim( |
|
| 57 | 57 | _DIR_PLUGIN_DIST, |
| 58 | 58 | '/' |
| 59 | 59 | ) : '')); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
| 78 | 78 | and defined($apl_constant) |
| 79 | 79 | and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
| 80 | - and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 80 | + and $pipe = z_trouver_bloc($prefix_path.$prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 81 | 81 | ) { |
| 82 | 82 | $flux['data'] = $pipe; |
| 83 | 83 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $echafauder = ''; |
| 91 | 91 | } |
| 92 | 92 | if ($prepend) { |
| 93 | - $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 93 | + $squelette = substr(find_in_path($prefix_path.$prepend."$fond.$ext"), 0, -strlen(".$ext")); |
|
| 94 | 94 | if ($squelette) { |
| 95 | 95 | $flux['data'] = $squelette; |
| 96 | 96 | } |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | // se brancher sur contenu/xx si il existe |
| 114 | 114 | // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
| 115 | 115 | if (!isset($disponible[$fond])) { |
| 116 | - $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 116 | + $disponible[$fond] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if ($disponible[$fond]) { |
| 120 | - $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 120 | + $flux['data'] = substr(find_in_path($prefix_path."page.$ext"), 0, -strlen(".$ext")); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $type = $flux['args']['contexte'][$page]; |
| 131 | 131 | } |
| 132 | 132 | if (!isset($disponible[$type])) { |
| 133 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 133 | + $disponible[$type] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 134 | 134 | } |
| 135 | 135 | if (is_string($disponible[$type])) { |
| 136 | 136 | $flux['data'] = $disponible[$type]; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
| 146 | 146 | } else { |
| 147 | 147 | $flux['data'] = ($disponible['404'] = z_contenu_disponible( |
| 148 | - $prefix_path . $prepend, |
|
| 148 | + $prefix_path.$prepend, |
|
| 149 | 149 | $z_contenu, |
| 150 | 150 | '404', |
| 151 | 151 | $ext, |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | $type = $flux['args']['contexte'][$page]; |
| 170 | 170 | } |
| 171 | 171 | if ($type !== 'page' and !isset($disponible[$type])) { |
| 172 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 172 | + $disponible[$type] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 173 | 173 | } |
| 174 | 174 | if ($type == 'page' or $disponible[$type]) { |
| 175 | - $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 175 | + $flux['data'] = z_trouver_bloc($prefix_path.$prepend, $dir, 'dist', $ext); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | isset($flux['args']['contexte']['type-page']) |
| 189 | 189 | and ( |
| 190 | 190 | (isset($flux['args']['contexte']['composition']) |
| 191 | - and file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page'] . '-' . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 191 | + and file_exists(($f = $squelette.'-'.$flux['args']['contexte']['type-page'].'-'.$flux['args']['contexte']['composition']).".$ext")) |
|
| 192 | 192 | or |
| 193 | - file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 193 | + file_exists(($f = $squelette.'-'.$flux['args']['contexte']['type-page']).".$ext") |
|
| 194 | 194 | ) |
| 195 | 195 | ) { |
| 196 | 196 | $flux['data'] = $f; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } elseif ( |
| 199 | 199 | $fond == 'structure' |
| 200 | 200 | and z_sanitize_var_zajax() |
| 201 | - and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 201 | + and $f = find_in_path($prefix_path.$prepend.'ajax'.".$ext") |
|
| 202 | 202 | ) { |
| 203 | 203 | $flux['data'] = substr($f, 0, -strlen(".$ext")); |
| 204 | 204 | } // chercher le fond correspondant a la composition |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | and $dir = explode('/', $dir) |
| 210 | 210 | and $dir = reset($dir) |
| 211 | 211 | and in_array($dir, $z_blocs) |
| 212 | - and $f = find_in_path($prefix_path . $prepend . $fond . '-' . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 212 | + and $f = find_in_path($prefix_path.$prepend.$fond.'-'.$flux['args']['contexte']['composition'].".$ext") |
|
| 213 | 213 | ) { |
| 214 | 214 | $flux['data'] = substr($f, 0, -strlen(".$ext")); |
| 215 | 215 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | function z_fond_valide($squelette) { |
| 272 | 272 | if ( |
| 273 | 273 | !_ZCORE_EXCLURE_PATH |
| 274 | - or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 274 | + or !preg_match(',('._ZCORE_EXCLURE_PATH.')/,', $squelette) |
|
| 275 | 275 | ) { |
| 276 | 276 | return true; |
| 277 | 277 | } |
@@ -395,23 +395,23 @@ discard block |
||
| 395 | 395 | } |
| 396 | 396 | $dir = z_blocs(test_espace_prive()); |
| 397 | 397 | $dir = reset($dir); |
| 398 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ',objet=' . $type . ',id_objet=#' . strtoupper($primary) . ',env}>'; |
|
| 398 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/".$fond.',objet='.$type.',id_objet=#'.strtoupper($primary).',env}>'; |
|
| 399 | 399 | } // page objets |
| 400 | 400 | elseif ($type = $desc_exec and !str_contains($type, '/')) { |
| 401 | 401 | $dir = z_blocs(test_espace_prive()); |
| 402 | 402 | $dir = reset($dir); |
| 403 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ',env} />'; |
|
| 403 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=".$type.',env} />'; |
|
| 404 | 404 | } |
| 405 | 405 | // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
| 406 | 406 | // et objet et tire de $table |
| 407 | 407 | elseif ($fond = $desc_exec) { |
| 408 | 408 | $dir = md5(dirname($fond)); |
| 409 | - $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ',env} />'; |
|
| 409 | + $scaffold = "<INCLURE{fond=$fond,objet=".objet_type($table).',env} />'; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | $base_dir = sous_repertoire(_DIR_CACHE, 'scaffold', false); |
| 413 | 413 | $base_dir = sous_repertoire($base_dir, $dir, false); |
| 414 | - $f = $base_dir . "$exec"; |
|
| 414 | + $f = $base_dir."$exec"; |
|
| 415 | 415 | ecrire_fichier("$f.$ext", $scaffold); |
| 416 | 416 | |
| 417 | 417 | return $f; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | **/ |
| 24 | 24 | |
| 25 | 25 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 26 | - return; |
|
| 26 | + return; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | * texte |
| 42 | 42 | */ |
| 43 | 43 | function sandbox_composer_texte($texte, &$p) { |
| 44 | - $code = "'" . str_replace(['\\', "'"], ['\\\\', "\\'"], $texte) . "'"; |
|
| 44 | + $code = "'" . str_replace(['\\', "'"], ['\\\\', "\\'"], $texte) . "'"; |
|
| 45 | 45 | |
| 46 | - return $code; |
|
| 46 | + return $code; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
@@ -59,42 +59,42 @@ discard block |
||
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | 61 | function sandbox_composer_filtre($fonc, $code, $arglist, &$p, $nb_arg_droite = 1000): string { |
| 62 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 63 | - $code = "filtrer('$fonc',$code$arglist)"; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - // le filtre est defini sous forme de fonction ou de methode |
|
| 67 | - // par ex. dans inc_texte, inc_filtres ou mes_fonctions |
|
| 68 | - elseif ($f = chercher_filtre($fonc)) { |
|
| 69 | - // cas particulier : le filtre |set doit acceder a la $Pile |
|
| 70 | - // proto: filtre_set(&$Pile, $val, $args...) |
|
| 71 | - if (strpbrk($f, ':')) { // Class::method |
|
| 72 | - $refl = new ReflectionMethod($f); |
|
| 73 | - } else { |
|
| 74 | - $refl = new ReflectionFunction($f); |
|
| 75 | - } |
|
| 76 | - $refs = $refl->getParameters(); |
|
| 77 | - if (isset($refs[0]) and $refs[0]->name == 'Pile') { |
|
| 78 | - $code = "$f(\$Pile,$code$arglist)"; |
|
| 79 | - $nb_arg_gauche = 2; // la balise à laquelle s'applique le filtre + $Pile |
|
| 80 | - } else { |
|
| 81 | - $code = "$f($code$arglist)"; |
|
| 82 | - $nb_arg_gauche = 1; // la balise à laquelle s'applique le filtre |
|
| 83 | - } |
|
| 84 | - $nb_args_f = $nb_arg_gauche + $nb_arg_droite; |
|
| 85 | - $min_f = $refl->getNumberOfRequiredParameters(); |
|
| 86 | - if (($nb_args_f < $min_f)) { |
|
| 87 | - $msg_args = ['filtre' => texte_script($fonc), 'nb' => $min_f - $nb_args_f]; |
|
| 88 | - erreur_squelette([ 'zbug_erreur_filtre_nbarg_min', $msg_args], $p); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - // le filtre n'existe pas, |
|
| 92 | - // on le notifie |
|
| 93 | - else { |
|
| 94 | - erreur_squelette(['zbug_erreur_filtre', ['filtre' => texte_script($fonc)]], $p); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return $code; |
|
| 62 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 63 | + $code = "filtrer('$fonc',$code$arglist)"; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + // le filtre est defini sous forme de fonction ou de methode |
|
| 67 | + // par ex. dans inc_texte, inc_filtres ou mes_fonctions |
|
| 68 | + elseif ($f = chercher_filtre($fonc)) { |
|
| 69 | + // cas particulier : le filtre |set doit acceder a la $Pile |
|
| 70 | + // proto: filtre_set(&$Pile, $val, $args...) |
|
| 71 | + if (strpbrk($f, ':')) { // Class::method |
|
| 72 | + $refl = new ReflectionMethod($f); |
|
| 73 | + } else { |
|
| 74 | + $refl = new ReflectionFunction($f); |
|
| 75 | + } |
|
| 76 | + $refs = $refl->getParameters(); |
|
| 77 | + if (isset($refs[0]) and $refs[0]->name == 'Pile') { |
|
| 78 | + $code = "$f(\$Pile,$code$arglist)"; |
|
| 79 | + $nb_arg_gauche = 2; // la balise à laquelle s'applique le filtre + $Pile |
|
| 80 | + } else { |
|
| 81 | + $code = "$f($code$arglist)"; |
|
| 82 | + $nb_arg_gauche = 1; // la balise à laquelle s'applique le filtre |
|
| 83 | + } |
|
| 84 | + $nb_args_f = $nb_arg_gauche + $nb_arg_droite; |
|
| 85 | + $min_f = $refl->getNumberOfRequiredParameters(); |
|
| 86 | + if (($nb_args_f < $min_f)) { |
|
| 87 | + $msg_args = ['filtre' => texte_script($fonc), 'nb' => $min_f - $nb_args_f]; |
|
| 88 | + erreur_squelette([ 'zbug_erreur_filtre_nbarg_min', $msg_args], $p); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + // le filtre n'existe pas, |
|
| 92 | + // on le notifie |
|
| 93 | + else { |
|
| 94 | + erreur_squelette(['zbug_erreur_filtre', ['filtre' => texte_script($fonc)]], $p); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return $code; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Calculer un <INCLURE(xx.php)> |
@@ -117,15 +117,15 @@ discard block |
||
| 117 | 117 | * @return string |
| 118 | 118 | */ |
| 119 | 119 | function sandbox_composer_inclure_php($fichier, &$p, $_contexte) { |
| 120 | - $compil = texte_script(memoriser_contexte_compil($p)); |
|
| 121 | - // si inexistant, on essaiera a l'execution |
|
| 122 | - if ($path = find_in_path($fichier)) { |
|
| 123 | - $path = "\"$path\""; |
|
| 124 | - } else { |
|
| 125 | - $path = "find_in_path(\"$fichier\")"; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil, $_contexte); |
|
| 120 | + $compil = texte_script(memoriser_contexte_compil($p)); |
|
| 121 | + // si inexistant, on essaiera a l'execution |
|
| 122 | + if ($path = find_in_path($fichier)) { |
|
| 123 | + $path = "\"$path\""; |
|
| 124 | + } else { |
|
| 125 | + $path = "find_in_path(\"$fichier\")"; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil, $_contexte); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -137,20 +137,20 @@ discard block |
||
| 137 | 137 | * @return string |
| 138 | 138 | */ |
| 139 | 139 | function sandbox_composer_interdire_scripts($code, &$p) { |
| 140 | - // Securite |
|
| 141 | - if ( |
|
| 142 | - $p->interdire_scripts |
|
| 143 | - and $p->etoile != '**' |
|
| 144 | - ) { |
|
| 145 | - if (!preg_match("/^sinon[(](.*),'([^']*)'[)]$/", $code, $r)) { |
|
| 146 | - $code = "interdire_scripts($code)"; |
|
| 147 | - } else { |
|
| 148 | - $code = interdire_scripts($r[2]); |
|
| 149 | - $code = "sinon(interdire_scripts($r[1]),'$code')"; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return $code; |
|
| 140 | + // Securite |
|
| 141 | + if ( |
|
| 142 | + $p->interdire_scripts |
|
| 143 | + and $p->etoile != '**' |
|
| 144 | + ) { |
|
| 145 | + if (!preg_match("/^sinon[(](.*),'([^']*)'[)]$/", $code, $r)) { |
|
| 146 | + $code = "interdire_scripts($code)"; |
|
| 147 | + } else { |
|
| 148 | + $code = interdire_scripts($r[2]); |
|
| 149 | + $code = "sinon(interdire_scripts($r[1]),'$code')"; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $code; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -169,30 +169,30 @@ discard block |
||
| 169 | 169 | * @return mixed|string |
| 170 | 170 | */ |
| 171 | 171 | function sandbox_filtrer_squelette($skel, $corps, $filtres) { |
| 172 | - $series_filtres = func_get_args(); |
|
| 173 | - array_shift($series_filtres);// skel |
|
| 174 | - array_shift($series_filtres);// corps |
|
| 175 | - |
|
| 176 | - // proteger les <INCLUDE> et tous les morceaux de php licites |
|
| 177 | - if ($skel['process_ins'] == 'php') { |
|
| 178 | - $corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - // recuperer les couples de remplacement |
|
| 182 | - $replace = echapper_php_callback(); |
|
| 183 | - |
|
| 184 | - foreach ($series_filtres as $filtres) { |
|
| 185 | - if (is_countable($filtres) ? count($filtres) : 0) { |
|
| 186 | - foreach ($filtres as $filtre) { |
|
| 187 | - if ($filtre and $f = chercher_filtre($filtre)) { |
|
| 188 | - $corps = $f($corps); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - // restaurer les echappements |
|
| 195 | - return str_replace($replace[0], $replace[1], $corps); |
|
| 172 | + $series_filtres = func_get_args(); |
|
| 173 | + array_shift($series_filtres);// skel |
|
| 174 | + array_shift($series_filtres);// corps |
|
| 175 | + |
|
| 176 | + // proteger les <INCLUDE> et tous les morceaux de php licites |
|
| 177 | + if ($skel['process_ins'] == 'php') { |
|
| 178 | + $corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + // recuperer les couples de remplacement |
|
| 182 | + $replace = echapper_php_callback(); |
|
| 183 | + |
|
| 184 | + foreach ($series_filtres as $filtres) { |
|
| 185 | + if (is_countable($filtres) ? count($filtres) : 0) { |
|
| 186 | + foreach ($filtres as $filtre) { |
|
| 187 | + if ($filtre and $f = chercher_filtre($filtre)) { |
|
| 188 | + $corps = $f($corps); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + // restaurer les echappements |
|
| 195 | + return str_replace($replace[0], $replace[1], $corps); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
@@ -211,21 +211,21 @@ discard block |
||
| 211 | 211 | * - array : Liste( liste des codes PHP, liste des substitutions ) |
| 212 | 212 | **/ |
| 213 | 213 | function echapper_php_callback($r = null) { |
| 214 | - static $src = []; |
|
| 215 | - static $dst = []; |
|
| 214 | + static $src = []; |
|
| 215 | + static $dst = []; |
|
| 216 | 216 | |
| 217 | - // si on recoit un tableau, on est en mode echappement |
|
| 218 | - // on enregistre le code a echapper dans dst, et le code echappe dans src |
|
| 219 | - if (is_array($r)) { |
|
| 220 | - $dst[] = $r[0]; |
|
| 217 | + // si on recoit un tableau, on est en mode echappement |
|
| 218 | + // on enregistre le code a echapper dans dst, et le code echappe dans src |
|
| 219 | + if (is_array($r)) { |
|
| 220 | + $dst[] = $r[0]; |
|
| 221 | 221 | |
| 222 | - return $src[] = '___' . md5($r[0]) . '___'; |
|
| 223 | - } |
|
| 222 | + return $src[] = '___' . md5($r[0]) . '___'; |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - // si on recoit pas un tableau, on renvoit les couples de substitution |
|
| 226 | - // et on RAZ les remplacements |
|
| 227 | - $r = [$src, $dst]; |
|
| 228 | - $src = $dst = []; |
|
| 225 | + // si on recoit pas un tableau, on renvoit les couples de substitution |
|
| 226 | + // et on RAZ les remplacements |
|
| 227 | + $r = [$src, $dst]; |
|
| 228 | + $src = $dst = []; |
|
| 229 | 229 | |
| 230 | - return $r; |
|
| 230 | + return $r; |
|
| 231 | 231 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * texte |
| 42 | 42 | */ |
| 43 | 43 | function sandbox_composer_texte($texte, &$p) { |
| 44 | - $code = "'" . str_replace(['\\', "'"], ['\\\\', "\\'"], $texte) . "'"; |
|
| 44 | + $code = "'".str_replace(['\\', "'"], ['\\\\', "\\'"], $texte)."'"; |
|
| 45 | 45 | |
| 46 | 46 | return $code; |
| 47 | 47 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $min_f = $refl->getNumberOfRequiredParameters(); |
| 86 | 86 | if (($nb_args_f < $min_f)) { |
| 87 | 87 | $msg_args = ['filtre' => texte_script($fonc), 'nb' => $min_f - $nb_args_f]; |
| 88 | - erreur_squelette([ 'zbug_erreur_filtre_nbarg_min', $msg_args], $p); |
|
| 88 | + erreur_squelette(['zbug_erreur_filtre_nbarg_min', $msg_args], $p); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | // le filtre n'existe pas, |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function sandbox_filtrer_squelette($skel, $corps, $filtres) { |
| 172 | 172 | $series_filtres = func_get_args(); |
| 173 | - array_shift($series_filtres);// skel |
|
| 174 | - array_shift($series_filtres);// corps |
|
| 173 | + array_shift($series_filtres); // skel |
|
| 174 | + array_shift($series_filtres); // corps |
|
| 175 | 175 | |
| 176 | 176 | // proteger les <INCLUDE> et tous les morceaux de php licites |
| 177 | 177 | if ($skel['process_ins'] == 'php') { |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | if (is_array($r)) { |
| 220 | 220 | $dst[] = $r[0]; |
| 221 | 221 | |
| 222 | - return $src[] = '___' . md5($r[0]) . '___'; |
|
| 222 | + return $src[] = '___'.md5($r[0]).'___'; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // si on recoit pas un tableau, on renvoit les couples de substitution |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -39,15 +39,15 @@ discard block |
||
| 39 | 39 | define('_PHP_MAX', '8.2.99'); |
| 40 | 40 | |
| 41 | 41 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 42 | - /** le nom du repertoire ecrire/ */ |
|
| 43 | - define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 42 | + /** le nom du repertoire ecrire/ */ |
|
| 43 | + define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** Chemin relatif pour aller dans ecrire |
| 47 | 47 | * vide si on est dans ecrire, 'ecrire/' sinon */ |
| 48 | 48 | define( |
| 49 | - '_DIR_RESTREINT', |
|
| 50 | - (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 49 | + '_DIR_RESTREINT', |
|
| 50 | + (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | /** Chemin relatif pour aller à la racine */ |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | // Icones |
| 64 | 64 | if (!defined('_NOM_IMG_PACK')) { |
| 65 | - /** Nom du dossier images */ |
|
| 66 | - define('_NOM_IMG_PACK', 'images/'); |
|
| 65 | + /** Nom du dossier images */ |
|
| 66 | + define('_NOM_IMG_PACK', 'images/'); |
|
| 67 | 67 | } |
| 68 | 68 | /** le chemin http (relatif) vers les images standard */ |
| 69 | 69 | define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
| 73 | 73 | |
| 74 | 74 | if (!defined('_JAVASCRIPT')) { |
| 75 | - /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 76 | - define('_JAVASCRIPT', 'javascript/'); |
|
| 75 | + /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 76 | + define('_JAVASCRIPT', 'javascript/'); |
|
| 77 | 77 | } // utilisable avec #CHEMIN et find_in_path |
| 78 | 78 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 79 | 79 | define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
@@ -83,47 +83,47 @@ discard block |
||
| 83 | 83 | # mais on peut les mettre ailleurs et changer completement les noms |
| 84 | 84 | |
| 85 | 85 | if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) { |
| 86 | - /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 87 | - define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 86 | + /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 87 | + define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 88 | 88 | } |
| 89 | 89 | if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) { |
| 90 | - /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 91 | - define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 90 | + /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 91 | + define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 92 | 92 | } |
| 93 | 93 | if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) { |
| 94 | - /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 95 | - define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 94 | + /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 95 | + define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 96 | 96 | } |
| 97 | 97 | if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) { |
| 98 | - /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 99 | - define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 98 | + /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 99 | + define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | /** Le nom du fichier de personnalisation */ |
| 104 | 104 | if (!defined('_NOM_CONFIG')) { |
| 105 | - define('_NOM_CONFIG', 'mes_options'); |
|
| 105 | + define('_NOM_CONFIG', 'mes_options'); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Son emplacement absolu si on le trouve |
| 109 | 109 | if ( |
| 110 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 111 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 110 | + @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 111 | + or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 112 | 112 | ) { |
| 113 | - /** Emplacement absolu du fichier d'option */ |
|
| 114 | - define('_FILE_OPTIONS', $f); |
|
| 113 | + /** Emplacement absolu du fichier d'option */ |
|
| 114 | + define('_FILE_OPTIONS', $f); |
|
| 115 | 115 | } else { |
| 116 | - define('_FILE_OPTIONS', ''); |
|
| 116 | + define('_FILE_OPTIONS', ''); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if (!defined('MODULES_IDIOMES')) { |
| 120 | - /** |
|
| 121 | - * Modules par défaut pour la traduction. |
|
| 122 | - * |
|
| 123 | - * Constante utilisée par le compilateur et le décompilateur |
|
| 124 | - * sa valeur etant traitée par inc_traduire_dist |
|
| 125 | - */ |
|
| 126 | - define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 120 | + /** |
|
| 121 | + * Modules par défaut pour la traduction. |
|
| 122 | + * |
|
| 123 | + * Constante utilisée par le compilateur et le décompilateur |
|
| 124 | + * sa valeur etant traitée par inc_traduire_dist |
|
| 125 | + */ |
|
| 126 | + define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // *** Fin des define *** // |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // inclure l'ecran de securite |
| 133 | 133 | if ( |
| 134 | - !defined('_ECRAN_SECURITE') |
|
| 135 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 134 | + !defined('_ECRAN_SECURITE') |
|
| 135 | + and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 136 | 136 | ) { |
| 137 | - include $f; |
|
| 137 | + include $f; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | |
@@ -142,30 +142,30 @@ discard block |
||
| 142 | 142 | * Détecteur de robot d'indexation |
| 143 | 143 | */ |
| 144 | 144 | if (!defined('_IS_BOT')) { |
| 145 | - define( |
|
| 146 | - '_IS_BOT', |
|
| 147 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 148 | - and preg_match( |
|
| 149 | - // mots generiques |
|
| 150 | - ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 151 | - // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 152 | - . 'MSIE 6\.0|' |
|
| 153 | - // UA plus cibles |
|
| 154 | - . '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' |
|
| 155 | - . ',i', |
|
| 156 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 157 | - ) |
|
| 158 | - ); |
|
| 145 | + define( |
|
| 146 | + '_IS_BOT', |
|
| 147 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 148 | + and preg_match( |
|
| 149 | + // mots generiques |
|
| 150 | + ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 151 | + // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 152 | + . 'MSIE 6\.0|' |
|
| 153 | + // UA plus cibles |
|
| 154 | + . '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' |
|
| 155 | + . ',i', |
|
| 156 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 157 | + ) |
|
| 158 | + ); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | if (!defined('_IS_CLI')) { |
| 162 | - define( |
|
| 163 | - '_IS_CLI', |
|
| 164 | - !isset($_SERVER['HTTP_HOST']) |
|
| 165 | - and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 166 | - and !empty($_SERVER['argv']) |
|
| 167 | - and empty($_SERVER['REQUEST_METHOD']) |
|
| 168 | - ); |
|
| 162 | + define( |
|
| 163 | + '_IS_CLI', |
|
| 164 | + !isset($_SERVER['HTTP_HOST']) |
|
| 165 | + and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 166 | + and !empty($_SERVER['argv']) |
|
| 167 | + and empty($_SERVER['REQUEST_METHOD']) |
|
| 168 | + ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // *** Parametrage par defaut de SPIP *** |
@@ -177,61 +177,61 @@ discard block |
||
| 177 | 177 | // Ne pas les rendre indefinies. |
| 178 | 178 | |
| 179 | 179 | global |
| 180 | - $nombre_de_logs, |
|
| 181 | - $taille_des_logs, |
|
| 182 | - $table_prefix, |
|
| 183 | - $cookie_prefix, |
|
| 184 | - $dossier_squelettes, |
|
| 185 | - $filtrer_javascript, |
|
| 186 | - $type_urls, |
|
| 187 | - $debut_date_publication, |
|
| 188 | - $ip, |
|
| 189 | - $mysql_rappel_connexion, |
|
| 190 | - $mysql_rappel_nom_base, |
|
| 191 | - $test_i18n, |
|
| 192 | - $ignore_auth_http, |
|
| 193 | - $ignore_remote_user, |
|
| 194 | - $derniere_modif_invalide, |
|
| 195 | - $home_server, |
|
| 196 | - $help_server, |
|
| 197 | - $url_glossaire_externe, |
|
| 198 | - $tex_server, |
|
| 199 | - $traiter_math, |
|
| 200 | - $xhtml, |
|
| 201 | - $xml_indent, |
|
| 202 | - $source_vignettes, |
|
| 203 | - $formats_logos, |
|
| 204 | - $controler_dates_rss, |
|
| 205 | - $spip_pipeline, |
|
| 206 | - $spip_matrice, |
|
| 207 | - $plugins, |
|
| 208 | - $surcharges, |
|
| 209 | - $exceptions_des_tables, |
|
| 210 | - $tables_principales, |
|
| 211 | - $table_des_tables, |
|
| 212 | - $tables_auxiliaires, |
|
| 213 | - $table_primary, |
|
| 214 | - $table_date, |
|
| 215 | - $table_titre, |
|
| 216 | - $tables_jointures, |
|
| 217 | - $liste_des_statuts, |
|
| 218 | - $liste_des_etats, |
|
| 219 | - $liste_des_authentifications, |
|
| 220 | - $spip_version_branche, |
|
| 221 | - $spip_version_code, |
|
| 222 | - $spip_version_base, |
|
| 223 | - $spip_sql_version, |
|
| 224 | - $spip_version_affichee, |
|
| 225 | - $visiteur_session, |
|
| 226 | - $auteur_session, |
|
| 227 | - $connect_statut, |
|
| 228 | - $connect_toutes_rubriques, |
|
| 229 | - $hash_recherche, |
|
| 230 | - $hash_recherche_strict, |
|
| 231 | - $ldap_present, |
|
| 232 | - $meta, |
|
| 233 | - $connect_id_rubrique, |
|
| 234 | - $puce; |
|
| 180 | + $nombre_de_logs, |
|
| 181 | + $taille_des_logs, |
|
| 182 | + $table_prefix, |
|
| 183 | + $cookie_prefix, |
|
| 184 | + $dossier_squelettes, |
|
| 185 | + $filtrer_javascript, |
|
| 186 | + $type_urls, |
|
| 187 | + $debut_date_publication, |
|
| 188 | + $ip, |
|
| 189 | + $mysql_rappel_connexion, |
|
| 190 | + $mysql_rappel_nom_base, |
|
| 191 | + $test_i18n, |
|
| 192 | + $ignore_auth_http, |
|
| 193 | + $ignore_remote_user, |
|
| 194 | + $derniere_modif_invalide, |
|
| 195 | + $home_server, |
|
| 196 | + $help_server, |
|
| 197 | + $url_glossaire_externe, |
|
| 198 | + $tex_server, |
|
| 199 | + $traiter_math, |
|
| 200 | + $xhtml, |
|
| 201 | + $xml_indent, |
|
| 202 | + $source_vignettes, |
|
| 203 | + $formats_logos, |
|
| 204 | + $controler_dates_rss, |
|
| 205 | + $spip_pipeline, |
|
| 206 | + $spip_matrice, |
|
| 207 | + $plugins, |
|
| 208 | + $surcharges, |
|
| 209 | + $exceptions_des_tables, |
|
| 210 | + $tables_principales, |
|
| 211 | + $table_des_tables, |
|
| 212 | + $tables_auxiliaires, |
|
| 213 | + $table_primary, |
|
| 214 | + $table_date, |
|
| 215 | + $table_titre, |
|
| 216 | + $tables_jointures, |
|
| 217 | + $liste_des_statuts, |
|
| 218 | + $liste_des_etats, |
|
| 219 | + $liste_des_authentifications, |
|
| 220 | + $spip_version_branche, |
|
| 221 | + $spip_version_code, |
|
| 222 | + $spip_version_base, |
|
| 223 | + $spip_sql_version, |
|
| 224 | + $spip_version_affichee, |
|
| 225 | + $visiteur_session, |
|
| 226 | + $auteur_session, |
|
| 227 | + $connect_statut, |
|
| 228 | + $connect_toutes_rubriques, |
|
| 229 | + $hash_recherche, |
|
| 230 | + $hash_recherche_strict, |
|
| 231 | + $ldap_present, |
|
| 232 | + $meta, |
|
| 233 | + $connect_id_rubrique, |
|
| 234 | + $puce; |
|
| 235 | 235 | |
| 236 | 236 | # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log |
| 237 | 237 | $nombre_de_logs = 4; |
@@ -286,48 +286,48 @@ discard block |
||
| 286 | 286 | // Prendre en compte les entetes HTTP_X_FORWARDED_XX |
| 287 | 287 | // |
| 288 | 288 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
| 289 | - if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 290 | - $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 291 | - } |
|
| 292 | - if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 293 | - $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 294 | - } |
|
| 289 | + if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 290 | + $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 291 | + } |
|
| 292 | + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 293 | + $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 294 | + } |
|
| 295 | 295 | } |
| 296 | 296 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 297 | - if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 298 | - $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 299 | - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 300 | - $_SERVER['HTTPS'] = 'on'; |
|
| 301 | - if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 302 | - $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 307 | - if (strpos($host, ',') !== false) { |
|
| 308 | - $h = explode(',', $host); |
|
| 309 | - $host = trim(reset($h)); |
|
| 310 | - } |
|
| 311 | - // securite sur le contenu de l'entete |
|
| 312 | - $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 313 | - $_SERVER['HTTP_HOST'] = $host; |
|
| 297 | + if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 298 | + $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 299 | + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 300 | + $_SERVER['HTTPS'] = 'on'; |
|
| 301 | + if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 302 | + $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 307 | + if (strpos($host, ',') !== false) { |
|
| 308 | + $h = explode(',', $host); |
|
| 309 | + $host = trim(reset($h)); |
|
| 310 | + } |
|
| 311 | + // securite sur le contenu de l'entete |
|
| 312 | + $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 313 | + $_SERVER['HTTP_HOST'] = $host; |
|
| 314 | 314 | } |
| 315 | 315 | // |
| 316 | 316 | // On note le numero IP du client dans la variable $ip |
| 317 | 317 | // |
| 318 | 318 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 319 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 320 | - if (strpos($ip, ',') !== false) { |
|
| 321 | - $ip = explode(',', $ip); |
|
| 322 | - $ip = reset($ip); |
|
| 323 | - } |
|
| 324 | - // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 325 | - if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 326 | - $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 327 | - } |
|
| 319 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 320 | + if (strpos($ip, ',') !== false) { |
|
| 321 | + $ip = explode(',', $ip); |
|
| 322 | + $ip = reset($ip); |
|
| 323 | + } |
|
| 324 | + // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 325 | + if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 326 | + $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 327 | + } |
|
| 328 | 328 | } |
| 329 | 329 | if (isset($_SERVER['REMOTE_ADDR'])) { |
| 330 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 330 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la |
@@ -412,24 +412,24 @@ discard block |
||
| 412 | 412 | |
| 413 | 413 | // Liste des statuts. |
| 414 | 414 | $liste_des_statuts = [ |
| 415 | - 'info_administrateurs' => '0minirezo', |
|
| 416 | - 'info_redacteurs' => '1comite', |
|
| 417 | - 'info_visiteurs' => '6forum', |
|
| 418 | - 'texte_statut_poubelle' => '5poubelle' |
|
| 415 | + 'info_administrateurs' => '0minirezo', |
|
| 416 | + 'info_redacteurs' => '1comite', |
|
| 417 | + 'info_visiteurs' => '6forum', |
|
| 418 | + 'texte_statut_poubelle' => '5poubelle' |
|
| 419 | 419 | ]; |
| 420 | 420 | |
| 421 | 421 | $liste_des_etats = [ |
| 422 | - 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 423 | - 'texte_statut_propose_evaluation' => 'prop', |
|
| 424 | - 'texte_statut_publie' => 'publie', |
|
| 425 | - 'texte_statut_poubelle' => 'poubelle', |
|
| 426 | - 'texte_statut_refuse' => 'refuse' |
|
| 422 | + 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 423 | + 'texte_statut_propose_evaluation' => 'prop', |
|
| 424 | + 'texte_statut_publie' => 'publie', |
|
| 425 | + 'texte_statut_poubelle' => 'poubelle', |
|
| 426 | + 'texte_statut_refuse' => 'refuse' |
|
| 427 | 427 | ]; |
| 428 | 428 | |
| 429 | 429 | // liste des methodes d'authentifications |
| 430 | 430 | $liste_des_authentifications = [ |
| 431 | - 'spip' => 'spip', |
|
| 432 | - 'ldap' => 'ldap' |
|
| 431 | + 'spip' => 'spip', |
|
| 432 | + 'ldap' => 'ldap' |
|
| 433 | 433 | ]; |
| 434 | 434 | |
| 435 | 435 | // Experimental : pour supprimer systematiquement l'affichage des numeros |
@@ -479,12 +479,12 @@ discard block |
||
| 479 | 479 | // Definition personnelles eventuelles |
| 480 | 480 | |
| 481 | 481 | if (_FILE_OPTIONS) { |
| 482 | - include_once _FILE_OPTIONS; |
|
| 482 | + include_once _FILE_OPTIONS; |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | if (!defined('SPIP_ERREUR_REPORT')) { |
| 486 | - /** Masquer les warning */ |
|
| 487 | - define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 486 | + /** Masquer les warning */ |
|
| 487 | + define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 488 | 488 | } |
| 489 | 489 | error_reporting(SPIP_ERREUR_REPORT); |
| 490 | 490 | |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | // ===> on execute en neutralisant les messages d'erreur |
| 498 | 498 | |
| 499 | 499 | spip_initialisation_core( |
| 500 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 502 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 503 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 500 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 501 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 502 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 503 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 504 | 504 | ); |
| 505 | 505 | |
| 506 | 506 | |
@@ -510,70 +510,70 @@ discard block |
||
| 510 | 510 | // donc il faut avoir tout fini ici avant de charger les plugins |
| 511 | 511 | |
| 512 | 512 | if (@is_readable(_CACHE_PLUGINS_OPT) and @is_readable(_CACHE_PLUGINS_PATH)) { |
| 513 | - // chargement optimise precompile |
|
| 514 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 513 | + // chargement optimise precompile |
|
| 514 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 515 | 515 | } else { |
| 516 | - spip_initialisation_suite(); |
|
| 517 | - include_spip('inc/plugin'); |
|
| 518 | - // generer les fichiers php precompiles |
|
| 519 | - // de chargement des plugins et des pipelines |
|
| 520 | - actualise_plugins_actifs(); |
|
| 516 | + spip_initialisation_suite(); |
|
| 517 | + include_spip('inc/plugin'); |
|
| 518 | + // generer les fichiers php precompiles |
|
| 519 | + // de chargement des plugins et des pipelines |
|
| 520 | + actualise_plugins_actifs(); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | // Initialisations non critiques surchargeables par les plugins |
| 524 | 524 | spip_initialisation_suite(); |
| 525 | 525 | |
| 526 | 526 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 527 | - /** niveau maxi d'enregistrement des logs */ |
|
| 528 | - define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 527 | + /** niveau maxi d'enregistrement des logs */ |
|
| 528 | + define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | if (!defined('_OUTILS_DEVELOPPEURS')) { |
| 532 | - /** Activer des outils pour développeurs ? */ |
|
| 533 | - define('_OUTILS_DEVELOPPEURS', false); |
|
| 532 | + /** Activer des outils pour développeurs ? */ |
|
| 533 | + define('_OUTILS_DEVELOPPEURS', false); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | // charger systematiquement inc/autoriser dans l'espace restreint |
| 537 | 537 | if (test_espace_prive()) { |
| 538 | - include_spip('inc/autoriser'); |
|
| 538 | + include_spip('inc/autoriser'); |
|
| 539 | 539 | } |
| 540 | 540 | // |
| 541 | 541 | // Installer Spip si pas installe... sauf si justement on est en train |
| 542 | 542 | // |
| 543 | 543 | if ( |
| 544 | - !(_FILE_CONNECT |
|
| 545 | - or autoriser_sans_cookie(_request('exec')) |
|
| 546 | - or _request('action') == 'cookie' |
|
| 547 | - or _request('action') == 'converser' |
|
| 548 | - or _request('action') == 'test_dirs') |
|
| 544 | + !(_FILE_CONNECT |
|
| 545 | + or autoriser_sans_cookie(_request('exec')) |
|
| 546 | + or _request('action') == 'cookie' |
|
| 547 | + or _request('action') == 'converser' |
|
| 548 | + or _request('action') == 'test_dirs') |
|
| 549 | 549 | ) { |
| 550 | - // Si on peut installer, on lance illico |
|
| 551 | - if (test_espace_prive()) { |
|
| 552 | - include_spip('inc/headers'); |
|
| 553 | - redirige_url_ecrire('install'); |
|
| 554 | - } else { |
|
| 555 | - // Si on est dans le site public, dire que qq s'en occupe |
|
| 556 | - include_spip('inc/minipres'); |
|
| 557 | - utiliser_langue_visiteur(); |
|
| 558 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 559 | - exit; |
|
| 560 | - } |
|
| 561 | - // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 550 | + // Si on peut installer, on lance illico |
|
| 551 | + if (test_espace_prive()) { |
|
| 552 | + include_spip('inc/headers'); |
|
| 553 | + redirige_url_ecrire('install'); |
|
| 554 | + } else { |
|
| 555 | + // Si on est dans le site public, dire que qq s'en occupe |
|
| 556 | + include_spip('inc/minipres'); |
|
| 557 | + utiliser_langue_visiteur(); |
|
| 558 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 559 | + exit; |
|
| 560 | + } |
|
| 561 | + // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | // memoriser un tri sessionne eventuel |
| 565 | 565 | if ( |
| 566 | - isset($_REQUEST['var_memotri']) |
|
| 567 | - and $t = $_REQUEST['var_memotri'] |
|
| 568 | - and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 566 | + isset($_REQUEST['var_memotri']) |
|
| 567 | + and $t = $_REQUEST['var_memotri'] |
|
| 568 | + and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 569 | 569 | ) { |
| 570 | - if (!function_exists('session_set')) { |
|
| 571 | - include_spip('inc/session'); |
|
| 572 | - } |
|
| 573 | - $t = preg_replace(',\W,', '_', $t); |
|
| 574 | - if ($v = _request($t)) { |
|
| 575 | - session_set($t, $v); |
|
| 576 | - } |
|
| 570 | + if (!function_exists('session_set')) { |
|
| 571 | + include_spip('inc/session'); |
|
| 572 | + } |
|
| 573 | + $t = preg_replace(',\W,', '_', $t); |
|
| 574 | + if ($v = _request($t)) { |
|
| 575 | + session_set($t, $v); |
|
| 576 | + } |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | /** |
@@ -583,22 +583,22 @@ discard block |
||
| 583 | 583 | * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite |
| 584 | 584 | */ |
| 585 | 585 | if (!defined('_HEADER_COMPOSED_BY')) { |
| 586 | - define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 586 | + define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 587 | 587 | } |
| 588 | 588 | if (!headers_sent() and _HEADER_COMPOSED_BY) { |
| 589 | - if (!defined('_HEADER_VARY')) { |
|
| 590 | - define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 591 | - } |
|
| 592 | - if (_HEADER_VARY) { |
|
| 593 | - header(_HEADER_VARY); |
|
| 594 | - } |
|
| 595 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 596 | - include_spip('inc/filtres_mini'); |
|
| 597 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 598 | - } else { |
|
| 599 | - // header minimal |
|
| 600 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 601 | - } |
|
| 589 | + if (!defined('_HEADER_VARY')) { |
|
| 590 | + define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 591 | + } |
|
| 592 | + if (_HEADER_VARY) { |
|
| 593 | + header(_HEADER_VARY); |
|
| 594 | + } |
|
| 595 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 596 | + include_spip('inc/filtres_mini'); |
|
| 597 | + header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 598 | + } else { |
|
| 599 | + // header minimal |
|
| 600 | + header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 601 | + } |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * Ce programme est un logiciel libre distribué sous licence GNU/GPL. * |
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 12 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Initialisation de SPIP |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | define('_DIR_RACINE', _DIR_RESTREINT ? '' : '../'); |
| 54 | 54 | |
| 55 | 55 | /** chemin absolu vers la racine */ |
| 56 | -define('_ROOT_RACINE', dirname(__DIR__) . '/'); |
|
| 56 | +define('_ROOT_RACINE', dirname(__DIR__).'/'); |
|
| 57 | 57 | /** chemin absolu vers le repertoire de travail */ |
| 58 | -define('_ROOT_CWD', getcwd() . '/'); |
|
| 58 | +define('_ROOT_CWD', getcwd().'/'); |
|
| 59 | 59 | /** chemin absolu vers ecrire */ |
| 60 | -define('_ROOT_RESTREINT', _ROOT_CWD . _DIR_RESTREINT); |
|
| 60 | +define('_ROOT_RESTREINT', _ROOT_CWD._DIR_RESTREINT); |
|
| 61 | 61 | |
| 62 | 62 | // Icones |
| 63 | 63 | if (!defined('_NOM_IMG_PACK')) { |
@@ -65,17 +65,17 @@ discard block |
||
| 65 | 65 | define('_NOM_IMG_PACK', 'images/'); |
| 66 | 66 | } |
| 67 | 67 | /** le chemin http (relatif) vers les images standard */ |
| 68 | -define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
|
| 68 | +define('_DIR_IMG_PACK', (_DIR_RACINE.'prive/'._NOM_IMG_PACK)); |
|
| 69 | 69 | |
| 70 | 70 | /** le chemin php (absolu) vers les images standard (pour hebergement centralise) */ |
| 71 | -define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
|
| 71 | +define('_ROOT_IMG_PACK', dirname(__DIR__).'/prive/'._NOM_IMG_PACK); |
|
| 72 | 72 | |
| 73 | 73 | if (!defined('_JAVASCRIPT')) { |
| 74 | 74 | /** Nom du repertoire des bibliotheques JavaScript */ |
| 75 | 75 | define('_JAVASCRIPT', 'javascript/'); |
| 76 | 76 | } // utilisable avec #CHEMIN et find_in_path |
| 77 | 77 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 78 | -define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
|
| 78 | +define('_DIR_JAVASCRIPT', (_DIR_RACINE.'prive/'._JAVASCRIPT)); |
|
| 79 | 79 | |
| 80 | 80 | # Le nom des 4 repertoires modifiables par les scripts lances par httpd |
| 81 | 81 | # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas) |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // Son emplacement absolu si on le trouve |
| 108 | 108 | if ( |
| 109 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 110 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 109 | + @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES._NOM_CONFIG.'.php') |
|
| 110 | + or (@file_exists($f = _ROOT_RESTREINT._NOM_CONFIG.'.php')) |
|
| 111 | 111 | ) { |
| 112 | 112 | /** Emplacement absolu du fichier d'option */ |
| 113 | 113 | define('_FILE_OPTIONS', $f); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | // inclure l'ecran de securite |
| 132 | 132 | if ( |
| 133 | 133 | !defined('_ECRAN_SECURITE') |
| 134 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 134 | + and @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES.'ecran_securite.php') |
|
| 135 | 135 | ) { |
| 136 | 136 | include $f; |
| 137 | 137 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // UA plus cibles |
| 153 | 153 | . '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' |
| 154 | 154 | . ',i', |
| 155 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | + (string) $_SERVER['HTTP_USER_AGENT'] |
|
| 156 | 156 | ) |
| 157 | 157 | ); |
| 158 | 158 | } |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | # la matrice standard (fichiers definissant les fonctions a inclure) |
| 395 | 395 | $spip_matrice = []; |
| 396 | 396 | # les plugins a activer |
| 397 | -$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 397 | +$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 398 | 398 | # les surcharges de include_spip() |
| 399 | 399 | $surcharges = []; // format 'inc_truc' => '/plugins/chose/inc_truc2.php' |
| 400 | 400 | |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | // |
| 473 | 473 | // Charger les fonctions liees aux serveurs Http et Sql. |
| 474 | 474 | // |
| 475 | -require_once _ROOT_RESTREINT . 'inc/utils.php'; |
|
| 476 | -require_once _ROOT_RESTREINT . 'base/connect_sql.php'; |
|
| 475 | +require_once _ROOT_RESTREINT.'inc/utils.php'; |
|
| 476 | +require_once _ROOT_RESTREINT.'base/connect_sql.php'; |
|
| 477 | 477 | |
| 478 | 478 | // Definition personnelles eventuelles |
| 479 | 479 | |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | // ===> on execute en neutralisant les messages d'erreur |
| 497 | 497 | |
| 498 | 498 | spip_initialisation_core( |
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 499 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 503 | 503 | ); |
| 504 | 504 | |
| 505 | 505 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | // Si on est dans le site public, dire que qq s'en occupe |
| 555 | 555 | include_spip('inc/minipres'); |
| 556 | 556 | utiliser_langue_visiteur(); |
| 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']) or !$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); |
|
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if (!defined('_DATA_SOURCE_MAX_SIZE')) { |
| 26 | - define('_DATA_SOURCE_MAX_SIZE', 2 * 1_048_576); |
|
| 26 | + define('_DATA_SOURCE_MAX_SIZE', 2 * 1_048_576); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | * Description de la boucle complétée des champs |
| 45 | 45 | */ |
| 46 | 46 | function iterateur_DATA_dist($b) { |
| 47 | - $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 48 | - $b->show = [ |
|
| 49 | - 'field' => [ |
|
| 50 | - 'cle' => 'STRING', |
|
| 51 | - 'valeur' => 'STRING', |
|
| 52 | - '*' => 'ALL' // Champ joker * |
|
| 53 | - ] |
|
| 54 | - ]; |
|
| 55 | - $b->select[] = '.valeur'; |
|
| 56 | - |
|
| 57 | - return $b; |
|
| 47 | + $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 48 | + $b->show = [ |
|
| 49 | + 'field' => [ |
|
| 50 | + 'cle' => 'STRING', |
|
| 51 | + 'valeur' => 'STRING', |
|
| 52 | + '*' => 'ALL' // Champ joker * |
|
| 53 | + ] |
|
| 54 | + ]; |
|
| 55 | + $b->select[] = '.valeur'; |
|
| 56 | + |
|
| 57 | + return $b; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return array |
| 70 | 70 | */ |
| 71 | 71 | function inc_file_to_array_dist($data) { |
| 72 | - return preg_split('/\r?\n/', $data); |
|
| 72 | + return preg_split('/\r?\n/', $data); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | * @return array |
| 79 | 79 | */ |
| 80 | 80 | function inc_plugins_to_array_dist() { |
| 81 | - include_spip('inc/plugin'); |
|
| 81 | + include_spip('inc/plugin'); |
|
| 82 | 82 | |
| 83 | - return liste_chemin_plugin_actifs(); |
|
| 83 | + return liste_chemin_plugin_actifs(); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return array |
| 91 | 91 | */ |
| 92 | 92 | function inc_xml_to_array_dist($data) { |
| 93 | - return @XMLObjectToArray(new SimpleXmlIterator($data)); |
|
| 93 | + return @XMLObjectToArray(new SimpleXmlIterator($data)); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | */ |
| 104 | 104 | function inc_object_to_array($object) { |
| 105 | - if (!is_object($object) && !is_array($object)) { |
|
| 106 | - return $object; |
|
| 107 | - } |
|
| 108 | - if (is_object($object)) { |
|
| 109 | - $object = get_object_vars($object); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - return array_map('inc_object_to_array', $object); |
|
| 105 | + if (!is_object($object) && !is_array($object)) { |
|
| 106 | + return $object; |
|
| 107 | + } |
|
| 108 | + if (is_object($object)) { |
|
| 109 | + $object = get_object_vars($object); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + return array_map('inc_object_to_array', $object); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | * @return array|bool |
| 120 | 120 | */ |
| 121 | 121 | function inc_sql_to_array_dist($data) { |
| 122 | - # sortir le connecteur de $data |
|
| 123 | - preg_match(',^(?:(\w+):)?(.*)$,Sm', $data, $v); |
|
| 124 | - $serveur = (string)$v[1]; |
|
| 125 | - $req = trim($v[2]); |
|
| 126 | - if ($s = sql_query($req, $serveur)) { |
|
| 127 | - $r = []; |
|
| 128 | - while ($t = sql_fetch($s)) { |
|
| 129 | - $r[] = $t; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - return $r; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - return false; |
|
| 122 | + # sortir le connecteur de $data |
|
| 123 | + preg_match(',^(?:(\w+):)?(.*)$,Sm', $data, $v); |
|
| 124 | + $serveur = (string)$v[1]; |
|
| 125 | + $req = trim($v[2]); |
|
| 126 | + if ($s = sql_query($req, $serveur)) { |
|
| 127 | + $r = []; |
|
| 128 | + while ($t = sql_fetch($s)) { |
|
| 129 | + $r[] = $t; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + return $r; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + return false; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -142,13 +142,13 @@ discard block |
||
| 142 | 142 | * @return array|bool |
| 143 | 143 | */ |
| 144 | 144 | function inc_json_to_array_dist($data) { |
| 145 | - try { |
|
| 146 | - $json = json_decode($data, true, 512, JSON_THROW_ON_ERROR); |
|
| 147 | - } catch (JsonException $e) { |
|
| 148 | - $json = null; |
|
| 149 | - spip_log('Failed to parse Json data : ' . $e->getMessage(), _LOG_INFO); |
|
| 150 | - } |
|
| 151 | - return is_array($json) ? (array) $json : []; |
|
| 145 | + try { |
|
| 146 | + $json = json_decode($data, true, 512, JSON_THROW_ON_ERROR); |
|
| 147 | + } catch (JsonException $e) { |
|
| 148 | + $json = null; |
|
| 149 | + spip_log('Failed to parse Json data : ' . $e->getMessage(), _LOG_INFO); |
|
| 150 | + } |
|
| 151 | + return is_array($json) ? (array) $json : []; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -158,30 +158,30 @@ discard block |
||
| 158 | 158 | * @return array|bool |
| 159 | 159 | */ |
| 160 | 160 | function inc_csv_to_array_dist($data) { |
| 161 | - include_spip('inc/csv'); |
|
| 162 | - [$entete, $csv] = analyse_csv($data); |
|
| 163 | - array_unshift($csv, $entete); |
|
| 164 | - |
|
| 165 | - include_spip('inc/charsets'); |
|
| 166 | - $i = 1; |
|
| 167 | - foreach ($entete as $k => $v) { |
|
| 168 | - if (trim($v) == '') { |
|
| 169 | - $v = 'col' . $i; |
|
| 170 | - } // reperer des eventuelles cases vides |
|
| 171 | - if (is_numeric($v) and $v < 0) { |
|
| 172 | - $v = '__' . $v; |
|
| 173 | - } // ne pas risquer d'ecraser une cle numerique |
|
| 174 | - if (is_numeric($v)) { |
|
| 175 | - $v = '_' . $v; |
|
| 176 | - } // ne pas risquer d'ecraser une cle numerique |
|
| 177 | - $v = strtolower(preg_replace(',\W+,', '_', translitteration($v))); |
|
| 178 | - foreach ($csv as &$item) { |
|
| 179 | - $item[$v] = &$item[$k]; |
|
| 180 | - } |
|
| 181 | - $i++; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - return $csv; |
|
| 161 | + include_spip('inc/csv'); |
|
| 162 | + [$entete, $csv] = analyse_csv($data); |
|
| 163 | + array_unshift($csv, $entete); |
|
| 164 | + |
|
| 165 | + include_spip('inc/charsets'); |
|
| 166 | + $i = 1; |
|
| 167 | + foreach ($entete as $k => $v) { |
|
| 168 | + if (trim($v) == '') { |
|
| 169 | + $v = 'col' . $i; |
|
| 170 | + } // reperer des eventuelles cases vides |
|
| 171 | + if (is_numeric($v) and $v < 0) { |
|
| 172 | + $v = '__' . $v; |
|
| 173 | + } // ne pas risquer d'ecraser une cle numerique |
|
| 174 | + if (is_numeric($v)) { |
|
| 175 | + $v = '_' . $v; |
|
| 176 | + } // ne pas risquer d'ecraser une cle numerique |
|
| 177 | + $v = strtolower(preg_replace(',\W+,', '_', translitteration($v))); |
|
| 178 | + foreach ($csv as &$item) { |
|
| 179 | + $item[$v] = &$item[$k]; |
|
| 180 | + } |
|
| 181 | + $i++; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + return $csv; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | * @return array|bool |
| 192 | 192 | */ |
| 193 | 193 | function inc_rss_to_array_dist($data) { |
| 194 | - $tableau = null; |
|
| 195 | - include_spip('inc/syndic'); |
|
| 196 | - if (is_array($rss = analyser_backend($data))) { |
|
| 197 | - $tableau = $rss; |
|
| 198 | - } |
|
| 194 | + $tableau = null; |
|
| 195 | + include_spip('inc/syndic'); |
|
| 196 | + if (is_array($rss = analyser_backend($data))) { |
|
| 197 | + $tableau = $rss; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - return $tableau; |
|
| 200 | + return $tableau; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | * @return array|bool |
| 208 | 208 | */ |
| 209 | 209 | function inc_atom_to_array_dist($data) { |
| 210 | - $rss_to_array = charger_fonction('rss_to_array', 'inc'); |
|
| 210 | + $rss_to_array = charger_fonction('rss_to_array', 'inc'); |
|
| 211 | 211 | |
| 212 | - return $rss_to_array($data); |
|
| 212 | + return $rss_to_array($data); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -220,12 +220,12 @@ discard block |
||
| 220 | 220 | * @return array|bool |
| 221 | 221 | */ |
| 222 | 222 | function inc_glob_to_array_dist($data) { |
| 223 | - $a = glob( |
|
| 224 | - $data, |
|
| 225 | - GLOB_MARK | GLOB_NOSORT | GLOB_BRACE |
|
| 226 | - ); |
|
| 223 | + $a = glob( |
|
| 224 | + $data, |
|
| 225 | + GLOB_MARK | GLOB_NOSORT | GLOB_BRACE |
|
| 226 | + ); |
|
| 227 | 227 | |
| 228 | - return $a ?: []; |
|
| 228 | + return $a ?: []; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -236,14 +236,14 @@ discard block |
||
| 236 | 236 | * @throws Exception |
| 237 | 237 | */ |
| 238 | 238 | function inc_yaml_to_array_dist($data) { |
| 239 | - include_spip('inc/yaml-mini'); |
|
| 240 | - if (!function_exists('yaml_decode')) { |
|
| 241 | - throw new Exception('YAML: impossible de trouver la fonction yaml_decode'); |
|
| 239 | + include_spip('inc/yaml-mini'); |
|
| 240 | + if (!function_exists('yaml_decode')) { |
|
| 241 | + throw new Exception('YAML: impossible de trouver la fonction yaml_decode'); |
|
| 242 | 242 | |
| 243 | - return false; |
|
| 244 | - } |
|
| 243 | + return false; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - return yaml_decode($data); |
|
| 246 | + return yaml_decode($data); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @return array|bool |
| 259 | 259 | */ |
| 260 | 260 | function inc_pregfiles_to_array_dist($dir, $regexp = -1, $limit = 10000) { |
| 261 | - return (array)preg_files($dir, $regexp, $limit); |
|
| 261 | + return (array)preg_files($dir, $regexp, $limit); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -270,23 +270,23 @@ discard block |
||
| 270 | 270 | * @return array|bool |
| 271 | 271 | */ |
| 272 | 272 | function inc_ls_to_array_dist($data) { |
| 273 | - $glob_to_array = charger_fonction('glob_to_array', 'inc'); |
|
| 274 | - $a = $glob_to_array($data); |
|
| 275 | - foreach ($a as &$v) { |
|
| 276 | - $b = (array)@stat($v); |
|
| 277 | - foreach ($b as $k => $ignore) { |
|
| 278 | - if (is_numeric($k)) { |
|
| 279 | - unset($b[$k]); |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - $b['file'] = preg_replace('`/$`', '', $v) ; |
|
| 283 | - $v = array_merge( |
|
| 284 | - pathinfo($v), |
|
| 285 | - $b |
|
| 286 | - ); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - return $a; |
|
| 273 | + $glob_to_array = charger_fonction('glob_to_array', 'inc'); |
|
| 274 | + $a = $glob_to_array($data); |
|
| 275 | + foreach ($a as &$v) { |
|
| 276 | + $b = (array)@stat($v); |
|
| 277 | + foreach ($b as $k => $ignore) { |
|
| 278 | + if (is_numeric($k)) { |
|
| 279 | + unset($b[$k]); |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + $b['file'] = preg_replace('`/$`', '', $v) ; |
|
| 283 | + $v = array_merge( |
|
| 284 | + pathinfo($v), |
|
| 285 | + $b |
|
| 286 | + ); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + return $a; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -296,25 +296,25 @@ discard block |
||
| 296 | 296 | * @return array|bool |
| 297 | 297 | */ |
| 298 | 298 | function XMLObjectToArray($object) { |
| 299 | - $xml_array = []; |
|
| 300 | - for ($object->rewind(); $object->valid(); $object->next()) { |
|
| 301 | - if (array_key_exists($key = $object->key(), $xml_array)) { |
|
| 302 | - $key .= '-' . uniqid(); |
|
| 303 | - } |
|
| 304 | - $vars = get_object_vars($object->current()); |
|
| 305 | - if (isset($vars['@attributes'])) { |
|
| 306 | - foreach ($vars['@attributes'] as $k => $v) { |
|
| 307 | - $xml_array[$key][$k] = $v; |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - if ($object->hasChildren()) { |
|
| 311 | - $xml_array[$key][] = XMLObjectToArray( |
|
| 312 | - $object->current() |
|
| 313 | - ); |
|
| 314 | - } else { |
|
| 315 | - $xml_array[$key][] = strval($object->current()); |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - return $xml_array; |
|
| 299 | + $xml_array = []; |
|
| 300 | + for ($object->rewind(); $object->valid(); $object->next()) { |
|
| 301 | + if (array_key_exists($key = $object->key(), $xml_array)) { |
|
| 302 | + $key .= '-' . uniqid(); |
|
| 303 | + } |
|
| 304 | + $vars = get_object_vars($object->current()); |
|
| 305 | + if (isset($vars['@attributes'])) { |
|
| 306 | + foreach ($vars['@attributes'] as $k => $v) { |
|
| 307 | + $xml_array[$key][$k] = $v; |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + if ($object->hasChildren()) { |
|
| 311 | + $xml_array[$key][] = XMLObjectToArray( |
|
| 312 | + $object->current() |
|
| 313 | + ); |
|
| 314 | + } else { |
|
| 315 | + $xml_array[$key][] = strval($object->current()); |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + return $xml_array; |
|
| 320 | 320 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | function inc_sql_to_array_dist($data) { |
| 122 | 122 | # sortir le connecteur de $data |
| 123 | 123 | preg_match(',^(?:(\w+):)?(.*)$,Sm', $data, $v); |
| 124 | - $serveur = (string)$v[1]; |
|
| 124 | + $serveur = (string) $v[1]; |
|
| 125 | 125 | $req = trim($v[2]); |
| 126 | 126 | if ($s = sql_query($req, $serveur)) { |
| 127 | 127 | $r = []; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $json = json_decode($data, true, 512, JSON_THROW_ON_ERROR); |
| 147 | 147 | } catch (JsonException $e) { |
| 148 | 148 | $json = null; |
| 149 | - spip_log('Failed to parse Json data : ' . $e->getMessage(), _LOG_INFO); |
|
| 149 | + spip_log('Failed to parse Json data : '.$e->getMessage(), _LOG_INFO); |
|
| 150 | 150 | } |
| 151 | 151 | return is_array($json) ? (array) $json : []; |
| 152 | 152 | } |
@@ -166,13 +166,13 @@ discard block |
||
| 166 | 166 | $i = 1; |
| 167 | 167 | foreach ($entete as $k => $v) { |
| 168 | 168 | if (trim($v) == '') { |
| 169 | - $v = 'col' . $i; |
|
| 169 | + $v = 'col'.$i; |
|
| 170 | 170 | } // reperer des eventuelles cases vides |
| 171 | 171 | if (is_numeric($v) and $v < 0) { |
| 172 | - $v = '__' . $v; |
|
| 172 | + $v = '__'.$v; |
|
| 173 | 173 | } // ne pas risquer d'ecraser une cle numerique |
| 174 | 174 | if (is_numeric($v)) { |
| 175 | - $v = '_' . $v; |
|
| 175 | + $v = '_'.$v; |
|
| 176 | 176 | } // ne pas risquer d'ecraser une cle numerique |
| 177 | 177 | $v = strtolower(preg_replace(',\W+,', '_', translitteration($v))); |
| 178 | 178 | foreach ($csv as &$item) { |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @return array|bool |
| 259 | 259 | */ |
| 260 | 260 | function inc_pregfiles_to_array_dist($dir, $regexp = -1, $limit = 10000) { |
| 261 | - return (array)preg_files($dir, $regexp, $limit); |
|
| 261 | + return (array) preg_files($dir, $regexp, $limit); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | $glob_to_array = charger_fonction('glob_to_array', 'inc'); |
| 274 | 274 | $a = $glob_to_array($data); |
| 275 | 275 | foreach ($a as &$v) { |
| 276 | - $b = (array)@stat($v); |
|
| 276 | + $b = (array) @stat($v); |
|
| 277 | 277 | foreach ($b as $k => $ignore) { |
| 278 | 278 | if (is_numeric($k)) { |
| 279 | 279 | unset($b[$k]); |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | - $b['file'] = preg_replace('`/$`', '', $v) ; |
|
| 282 | + $b['file'] = preg_replace('`/$`', '', $v); |
|
| 283 | 283 | $v = array_merge( |
| 284 | 284 | pathinfo($v), |
| 285 | 285 | $b |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $xml_array = []; |
| 300 | 300 | for ($object->rewind(); $object->valid(); $object->next()) { |
| 301 | 301 | if (array_key_exists($key = $object->key(), $xml_array)) { |
| 302 | - $key .= '-' . uniqid(); |
|
| 302 | + $key .= '-'.uniqid(); |
|
| 303 | 303 | } |
| 304 | 304 | $vars = get_object_vars($object->current()); |
| 305 | 305 | if (isset($vars['@attributes'])) { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | include_spip('iterateur/data'); |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | * Description de la boucle complétée des champs |
| 38 | 38 | */ |
| 39 | 39 | function iterateur_CONDITION_dist($b) { |
| 40 | - $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 41 | - $b->show = [ |
|
| 42 | - 'field' => [] |
|
| 43 | - ]; |
|
| 40 | + $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 41 | + $b->show = [ |
|
| 42 | + 'field' => [] |
|
| 43 | + ]; |
|
| 44 | 44 | |
| 45 | - return $b; |
|
| 45 | + return $b; |
|
| 46 | 46 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | * Description de la boucle complétée des champs |
| 39 | 39 | */ |
| 40 | 40 | function iterateur_POUR_dist($b) { |
| 41 | - $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 42 | - $b->show = [ |
|
| 43 | - 'field' => [ |
|
| 44 | - 'cle' => 'STRING', |
|
| 45 | - 'valeur' => 'STRING', |
|
| 46 | - ] |
|
| 47 | - ]; |
|
| 41 | + $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 42 | + $b->show = [ |
|
| 43 | + 'field' => [ |
|
| 44 | + 'cle' => 'STRING', |
|
| 45 | + 'valeur' => 'STRING', |
|
| 46 | + ] |
|
| 47 | + ]; |
|
| 48 | 48 | |
| 49 | - return $b; |
|
| 49 | + return $b; |
|
| 50 | 50 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | * Description de la boucle complétée des champs |
| 39 | 39 | */ |
| 40 | 40 | function iterateur_php_dist($b, $iteratorName) { |
| 41 | - $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 42 | - $b->show = [ |
|
| 43 | - 'field' => [ |
|
| 44 | - 'cle' => 'STRING', |
|
| 45 | - 'valeur' => 'STRING', |
|
| 46 | - ] |
|
| 47 | - ]; |
|
| 48 | - |
|
| 49 | - foreach (get_class_methods($iteratorName) as $method) { |
|
| 50 | - $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return $b; |
|
| 41 | + $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 42 | + $b->show = [ |
|
| 43 | + 'field' => [ |
|
| 44 | + 'cle' => 'STRING', |
|
| 45 | + 'valeur' => 'STRING', |
|
| 46 | + ] |
|
| 47 | + ]; |
|
| 48 | + |
|
| 49 | + foreach (get_class_methods($iteratorName) as $method) { |
|
| 50 | + $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return $b; |
|
| 54 | 54 | } |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Pipelines |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | if (test_espace_prive()) { |
| 22 | - include_spip('inc/pipelines_ecrire'); |
|
| 22 | + include_spip('inc/pipelines_ecrire'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -45,28 +45,28 @@ discard block |
||
| 45 | 45 | * @return string Contenu qui sera inséré dans le head HTML |
| 46 | 46 | **/ |
| 47 | 47 | function f_jQuery($texte) { |
| 48 | - $x = ''; |
|
| 49 | - $jquery_plugins = pipeline( |
|
| 50 | - 'jquery_plugins', |
|
| 51 | - [ |
|
| 52 | - 'javascript/jquery.js', |
|
| 53 | - 'javascript/jquery.form.js', |
|
| 54 | - 'javascript/jquery.autosave.js', |
|
| 55 | - 'javascript/jquery.placeholder-label.js', |
|
| 56 | - 'javascript/ajaxCallback.js', |
|
| 57 | - 'javascript/js.cookie.js', |
|
| 58 | - ] |
|
| 59 | - ); |
|
| 60 | - foreach (array_unique($jquery_plugins) as $script) { |
|
| 61 | - if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 62 | - $script = timestamp($script); |
|
| 63 | - $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 64 | - } |
|
| 65 | - } |
|
| 48 | + $x = ''; |
|
| 49 | + $jquery_plugins = pipeline( |
|
| 50 | + 'jquery_plugins', |
|
| 51 | + [ |
|
| 52 | + 'javascript/jquery.js', |
|
| 53 | + 'javascript/jquery.form.js', |
|
| 54 | + 'javascript/jquery.autosave.js', |
|
| 55 | + 'javascript/jquery.placeholder-label.js', |
|
| 56 | + 'javascript/ajaxCallback.js', |
|
| 57 | + 'javascript/js.cookie.js', |
|
| 58 | + ] |
|
| 59 | + ); |
|
| 60 | + foreach (array_unique($jquery_plugins) as $script) { |
|
| 61 | + if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 62 | + $script = timestamp($script); |
|
| 63 | + $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - $texte = $x . $texte; |
|
| 67 | + $texte = $x . $texte; |
|
| 68 | 68 | |
| 69 | - return $texte; |
|
| 69 | + return $texte; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
@@ -85,28 +85,28 @@ discard block |
||
| 85 | 85 | * @return string Contenu de la page envoyée au navigateur |
| 86 | 86 | **/ |
| 87 | 87 | function f_surligne($texte) { |
| 88 | - if (!$GLOBALS['html']) { |
|
| 89 | - return $texte; |
|
| 90 | - } |
|
| 91 | - $rech = _request('var_recherche'); |
|
| 92 | - if ( |
|
| 93 | - !$rech |
|
| 94 | - and (!defined('_SURLIGNE_RECHERCHE_REFERERS') |
|
| 95 | - or !_SURLIGNE_RECHERCHE_REFERERS |
|
| 96 | - or !isset($_SERVER['HTTP_REFERER'])) |
|
| 97 | - ) { |
|
| 98 | - return $texte; |
|
| 99 | - } |
|
| 100 | - include_spip('inc/surligne'); |
|
| 88 | + if (!$GLOBALS['html']) { |
|
| 89 | + return $texte; |
|
| 90 | + } |
|
| 91 | + $rech = _request('var_recherche'); |
|
| 92 | + if ( |
|
| 93 | + !$rech |
|
| 94 | + and (!defined('_SURLIGNE_RECHERCHE_REFERERS') |
|
| 95 | + or !_SURLIGNE_RECHERCHE_REFERERS |
|
| 96 | + or !isset($_SERVER['HTTP_REFERER'])) |
|
| 97 | + ) { |
|
| 98 | + return $texte; |
|
| 99 | + } |
|
| 100 | + include_spip('inc/surligne'); |
|
| 101 | 101 | |
| 102 | - if (isset($_SERVER['HTTP_REFERER'])) { |
|
| 103 | - $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
|
| 104 | - } |
|
| 105 | - if ($rech) { |
|
| 106 | - $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
|
| 107 | - } |
|
| 102 | + if (isset($_SERVER['HTTP_REFERER'])) { |
|
| 103 | + $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
|
| 104 | + } |
|
| 105 | + if ($rech) { |
|
| 106 | + $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - return surligner_mots($texte, $rech); |
|
| 109 | + return surligner_mots($texte, $rech); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -123,33 +123,33 @@ discard block |
||
| 123 | 123 | * @return string Contenu de la page envoyée au navigateur |
| 124 | 124 | **/ |
| 125 | 125 | function f_tidy($texte) { |
| 126 | - /** |
|
| 127 | - * Indentation à faire ? |
|
| 128 | - * |
|
| 129 | - * - true : actif. |
|
| 130 | - * - false par défaut. |
|
| 131 | - */ |
|
| 126 | + /** |
|
| 127 | + * Indentation à faire ? |
|
| 128 | + * |
|
| 129 | + * - true : actif. |
|
| 130 | + * - false par défaut. |
|
| 131 | + */ |
|
| 132 | 132 | |
| 133 | - if ( |
|
| 134 | - $GLOBALS['xhtml'] # tidy demande |
|
| 135 | - and $GLOBALS['html'] # verifie que la page avait l'entete text/html |
|
| 136 | - and strlen($texte) |
|
| 137 | - and !headers_sent() |
|
| 138 | - ) { |
|
| 139 | - # Compatibilite ascendante |
|
| 140 | - if (!is_string($GLOBALS['xhtml'])) { |
|
| 141 | - $GLOBALS['xhtml'] = 'tidy'; |
|
| 142 | - } |
|
| 133 | + if ( |
|
| 134 | + $GLOBALS['xhtml'] # tidy demande |
|
| 135 | + and $GLOBALS['html'] # verifie que la page avait l'entete text/html |
|
| 136 | + and strlen($texte) |
|
| 137 | + and !headers_sent() |
|
| 138 | + ) { |
|
| 139 | + # Compatibilite ascendante |
|
| 140 | + if (!is_string($GLOBALS['xhtml'])) { |
|
| 141 | + $GLOBALS['xhtml'] = 'tidy'; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { |
|
| 145 | - spip_log("tidy absent, l'indenteur SPIP le remplace"); |
|
| 146 | - $f = charger_fonction('sax', 'xml'); |
|
| 147 | - } |
|
| 144 | + if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { |
|
| 145 | + spip_log("tidy absent, l'indenteur SPIP le remplace"); |
|
| 146 | + $f = charger_fonction('sax', 'xml'); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - return $f($texte); |
|
| 150 | - } |
|
| 149 | + return $f($texte); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - return $texte; |
|
| 152 | + return $texte; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -168,21 +168,21 @@ discard block |
||
| 168 | 168 | * @return string Contenu de la page envoyée au navigateur |
| 169 | 169 | **/ |
| 170 | 170 | function f_insert_head($texte) { |
| 171 | - if (!$GLOBALS['html']) { |
|
| 172 | - return $texte; |
|
| 173 | - } |
|
| 174 | - include_spip('public/admin'); // pour strripos |
|
| 171 | + if (!$GLOBALS['html']) { |
|
| 172 | + return $texte; |
|
| 173 | + } |
|
| 174 | + include_spip('public/admin'); // pour strripos |
|
| 175 | 175 | |
| 176 | - ($pos = stripos($texte, '</head>')) |
|
| 177 | - || ($pos = stripos($texte, '<body>')) |
|
| 178 | - || ($pos = 0); |
|
| 176 | + ($pos = stripos($texte, '</head>')) |
|
| 177 | + || ($pos = stripos($texte, '<body>')) |
|
| 178 | + || ($pos = 0); |
|
| 179 | 179 | |
| 180 | - if (!str_contains(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
|
| 181 | - $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 182 | - $texte = substr_replace($texte, $insert, $pos, 0); |
|
| 183 | - } |
|
| 180 | + if (!str_contains(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
|
| 181 | + $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 182 | + $texte = substr_replace($texte, $insert, $pos, 0); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return $texte; |
|
| 185 | + return $texte; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -198,34 +198,34 @@ discard block |
||
| 198 | 198 | * @return string Contenu de la page envoyée au navigateur |
| 199 | 199 | **/ |
| 200 | 200 | function f_admin($texte) { |
| 201 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { |
|
| 202 | - include_spip('inc/filtres'); // pour http_img_pack |
|
| 203 | - $x = "<div class='spip-previsu' " |
|
| 204 | - . http_style_background('preview-32.png', '', 32) |
|
| 205 | - . '>' |
|
| 206 | - . _T('previsualisation') |
|
| 207 | - . '</div>'; |
|
| 208 | - if (!$pos = stripos($texte, '</body>')) { |
|
| 209 | - $pos = strlen($texte); |
|
| 210 | - } |
|
| 211 | - $texte = substr_replace($texte, $x, $pos, 0); |
|
| 212 | - // pas de preview en fenetre enfant |
|
| 213 | - $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>"; |
|
| 214 | - if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
|
| 215 | - $pos = -1; |
|
| 216 | - } |
|
| 217 | - $texte = substr_replace($texte, $x, $pos + 1, 0); |
|
| 218 | - } |
|
| 201 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { |
|
| 202 | + include_spip('inc/filtres'); // pour http_img_pack |
|
| 203 | + $x = "<div class='spip-previsu' " |
|
| 204 | + . http_style_background('preview-32.png', '', 32) |
|
| 205 | + . '>' |
|
| 206 | + . _T('previsualisation') |
|
| 207 | + . '</div>'; |
|
| 208 | + if (!$pos = stripos($texte, '</body>')) { |
|
| 209 | + $pos = strlen($texte); |
|
| 210 | + } |
|
| 211 | + $texte = substr_replace($texte, $x, $pos, 0); |
|
| 212 | + // pas de preview en fenetre enfant |
|
| 213 | + $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>"; |
|
| 214 | + if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
|
| 215 | + $pos = -1; |
|
| 216 | + } |
|
| 217 | + $texte = substr_replace($texte, $x, $pos + 1, 0); |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
|
| 221 | - include_spip('public/admin'); |
|
| 222 | - $texte = affiche_boutons_admin($texte); |
|
| 223 | - } |
|
| 224 | - if (_request('var_mode') == 'noajax') { |
|
| 225 | - $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); |
|
| 226 | - } |
|
| 220 | + if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
|
| 221 | + include_spip('public/admin'); |
|
| 222 | + $texte = affiche_boutons_admin($texte); |
|
| 223 | + } |
|
| 224 | + if (_request('var_mode') == 'noajax') { |
|
| 225 | + $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - return $texte; |
|
| 228 | + return $texte; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -243,11 +243,11 @@ discard block |
||
| 243 | 243 | * @return array $flux Description et contenu de l'inclusion |
| 244 | 244 | **/ |
| 245 | 245 | function f_recuperer_fond($flux) { |
| 246 | - if (!test_espace_prive()) { |
|
| 247 | - return $flux; |
|
| 248 | - } |
|
| 246 | + if (!test_espace_prive()) { |
|
| 247 | + return $flux; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - return f_afficher_blocs_ecrire($flux); |
|
| 250 | + return f_afficher_blocs_ecrire($flux); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -261,30 +261,30 @@ discard block |
||
| 261 | 261 | * @return string Contenu de la page envoyée au navigateur |
| 262 | 262 | */ |
| 263 | 263 | function f_queue($texte) { |
| 264 | - // eviter une inclusion si rien a faire |
|
| 265 | - if ( |
|
| 266 | - _request('action') == 'cron' |
|
| 267 | - or queue_sleep_time_to_next_job() > 0 |
|
| 268 | - or defined('_DEBUG_BLOCK_QUEUE') |
|
| 269 | - ) { |
|
| 270 | - return $texte; |
|
| 271 | - } |
|
| 264 | + // eviter une inclusion si rien a faire |
|
| 265 | + if ( |
|
| 266 | + _request('action') == 'cron' |
|
| 267 | + or queue_sleep_time_to_next_job() > 0 |
|
| 268 | + or defined('_DEBUG_BLOCK_QUEUE') |
|
| 269 | + ) { |
|
| 270 | + return $texte; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - include_spip('inc/queue'); |
|
| 274 | - $code = queue_affichage_cron(); |
|
| 273 | + include_spip('inc/queue'); |
|
| 274 | + $code = queue_affichage_cron(); |
|
| 275 | 275 | |
| 276 | - // si rien a afficher |
|
| 277 | - // ou si on est pas dans une page html, on ne sait rien faire de mieux |
|
| 278 | - if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) { |
|
| 279 | - return $texte; |
|
| 280 | - } |
|
| 276 | + // si rien a afficher |
|
| 277 | + // ou si on est pas dans une page html, on ne sait rien faire de mieux |
|
| 278 | + if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) { |
|
| 279 | + return $texte; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
|
| 283 | - if (($p = strpos($texte, '</body>')) !== false) { |
|
| 284 | - $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 285 | - } else { |
|
| 286 | - $texte .= $code; |
|
| 287 | - } |
|
| 282 | + // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
|
| 283 | + if (($p = strpos($texte, '</body>')) !== false) { |
|
| 284 | + $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 285 | + } else { |
|
| 286 | + $texte .= $code; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - return $texte; |
|
| 289 | + return $texte; |
|
| 290 | 290 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $texte = $x . $texte; |
|
| 67 | + $texte = $x.$texte; |
|
| 68 | 68 | |
| 69 | 69 | return $texte; |
| 70 | 70 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | || ($pos = 0); |
| 179 | 179 | |
| 180 | 180 | if (!str_contains(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
| 181 | - $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 181 | + $insert = "\n".pipeline('insert_head', '<!-- f_insert_head -->')."\n"; |
|
| 182 | 182 | $texte = substr_replace($texte, $insert, $pos, 0); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | $texte = substr_replace($texte, $x, $pos, 0); |
| 212 | 212 | // pas de preview en fenetre enfant |
| 213 | - $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>"; |
|
| 213 | + $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='".addslashes($GLOBALS['meta']['adresse_site'])."';}</script>"; |
|
| 214 | 214 | if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
| 215 | 215 | $pos = -1; |
| 216 | 216 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
| 283 | 283 | if (($p = strpos($texte, '</body>')) !== false) { |
| 284 | - $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 284 | + $texte = substr($texte, 0, $p).$code.substr($texte, $p); |
|
| 285 | 285 | } else { |
| 286 | 286 | $texte .= $code; |
| 287 | 287 | } |