@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $role = $roles['roles']['defaut']; |
| 151 | 151 | } |
| 152 | 152 | // where |
| 153 | - $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 153 | + $cond = ["$colonne_role=".sql_quote($role)]; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | return [$role, $colonne_role, $cond]; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | if ($colonne_role) { |
| 186 | 186 | // on ajoute la condition du role aux autres conditions. |
| 187 | 187 | if ($role != '*') { |
| 188 | - $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 188 | + $cond[] = "$colonne_role=".sql_quote($role); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $all = sql_allfetsel( |
| 370 | 370 | "DISTINCT $colone_role", |
| 371 | 371 | $l, |
| 372 | - 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 372 | + 'objet='.sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 373 | 373 | ); |
| 374 | 374 | $done[$hash] = array_map('reset', $all); |
| 375 | 375 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 31 | - return; |
|
| 31 | + return; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
@@ -48,55 +48,55 @@ discard block |
||
| 48 | 48 | * array : description des roles applicables dans 3 index : colonne, titres, roles |
| 49 | 49 | **/ |
| 50 | 50 | function roles_presents($objet, $objet_destination = '') { |
| 51 | - $desc = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 52 | - |
|
| 53 | - // pas de liste de roles, on sort |
|
| 54 | - if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) { |
|
| 55 | - return false; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - // on vérifie que la table de liaison existe |
|
| 59 | - include_spip('action/editer_liens'); |
|
| 60 | - if (!$lien = objet_associable($objet)) { |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role') |
|
| 65 | - $colonne = $desc['roles_colonne'] ?? 'role'; |
|
| 66 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 67 | - [, $table_lien] = $lien; |
|
| 68 | - $desc_lien = $trouver_table($table_lien); |
|
| 69 | - if (!isset($desc_lien['field'][$colonne])) { |
|
| 70 | - return false; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - // sur quoi peuvent s'appliquer nos rôles |
|
| 74 | - if (!$application = $desc['roles_objets']) { |
|
| 75 | - return false; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // destination presente, on restreint si possible |
|
| 79 | - if ($objet_destination) { |
|
| 80 | - $objet_destination = table_objet($objet_destination); |
|
| 81 | - |
|
| 82 | - // pour l'objet |
|
| 83 | - if (isset($application[$objet_destination])) { |
|
| 84 | - $application = $application[$objet_destination]; |
|
| 85 | - // sinon pour tous les objets |
|
| 86 | - } elseif (isset($application['*'])) { |
|
| 87 | - $application = $application['*']; |
|
| 88 | - } // sinon tant pis |
|
| 89 | - else { |
|
| 90 | - return false; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - // tout est ok |
|
| 95 | - return [ |
|
| 96 | - 'titres' => $titres, |
|
| 97 | - 'roles' => $application, |
|
| 98 | - 'colonne' => $colonne |
|
| 99 | - ]; |
|
| 51 | + $desc = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 52 | + |
|
| 53 | + // pas de liste de roles, on sort |
|
| 54 | + if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) { |
|
| 55 | + return false; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + // on vérifie que la table de liaison existe |
|
| 59 | + include_spip('action/editer_liens'); |
|
| 60 | + if (!$lien = objet_associable($objet)) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role') |
|
| 65 | + $colonne = $desc['roles_colonne'] ?? 'role'; |
|
| 66 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 67 | + [, $table_lien] = $lien; |
|
| 68 | + $desc_lien = $trouver_table($table_lien); |
|
| 69 | + if (!isset($desc_lien['field'][$colonne])) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // sur quoi peuvent s'appliquer nos rôles |
|
| 74 | + if (!$application = $desc['roles_objets']) { |
|
| 75 | + return false; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // destination presente, on restreint si possible |
|
| 79 | + if ($objet_destination) { |
|
| 80 | + $objet_destination = table_objet($objet_destination); |
|
| 81 | + |
|
| 82 | + // pour l'objet |
|
| 83 | + if (isset($application[$objet_destination])) { |
|
| 84 | + $application = $application[$objet_destination]; |
|
| 85 | + // sinon pour tous les objets |
|
| 86 | + } elseif (isset($application['*'])) { |
|
| 87 | + $application = $application['*']; |
|
| 88 | + } // sinon tant pis |
|
| 89 | + else { |
|
| 90 | + return false; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + // tout est ok |
|
| 95 | + return [ |
|
| 96 | + 'titres' => $titres, |
|
| 97 | + 'roles' => $application, |
|
| 98 | + 'colonne' => $colonne |
|
| 99 | + ]; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | * Nom de la colonne, sinon vide |
| 111 | 111 | **/ |
| 112 | 112 | function roles_colonne($objet, $objet_destination) { |
| 113 | - if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 114 | - return $roles['colonne']; |
|
| 115 | - } |
|
| 113 | + if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 114 | + return $roles['colonne']; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - return ''; |
|
| 117 | + return ''; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -136,24 +136,24 @@ discard block |
||
| 136 | 136 | * Liste ('', '', array()) sinon. |
| 137 | 137 | **/ |
| 138 | 138 | function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = []) { |
| 139 | - // si des rôles sont possibles, on les utilise |
|
| 140 | - $role = $colonne_role = ''; # role défini |
|
| 141 | - // condition du where par defaut |
|
| 142 | - $cond = []; |
|
| 143 | - if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 144 | - $colonne_role = $roles['colonne']; |
|
| 145 | - // qu'il n'est pas défini |
|
| 146 | - if ( |
|
| 147 | - !isset($qualif[$colonne_role]) |
|
| 148 | - or !($role = $qualif[$colonne_role]) |
|
| 149 | - ) { |
|
| 150 | - $role = $roles['roles']['defaut']; |
|
| 151 | - } |
|
| 152 | - // where |
|
| 153 | - $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return [$role, $colonne_role, $cond]; |
|
| 139 | + // si des rôles sont possibles, on les utilise |
|
| 140 | + $role = $colonne_role = ''; # role défini |
|
| 141 | + // condition du where par defaut |
|
| 142 | + $cond = []; |
|
| 143 | + if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 144 | + $colonne_role = $roles['colonne']; |
|
| 145 | + // qu'il n'est pas défini |
|
| 146 | + if ( |
|
| 147 | + !isset($qualif[$colonne_role]) |
|
| 148 | + or !($role = $qualif[$colonne_role]) |
|
| 149 | + ) { |
|
| 150 | + $role = $roles['roles']['defaut']; |
|
| 151 | + } |
|
| 152 | + // where |
|
| 153 | + $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return [$role, $colonne_role, $cond]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -175,21 +175,21 @@ discard block |
||
| 175 | 175 | * Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé) |
| 176 | 176 | **/ |
| 177 | 177 | function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) { |
| 178 | - // role par défaut, colonne |
|
| 179 | - [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet); |
|
| 178 | + // role par défaut, colonne |
|
| 179 | + [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet); |
|
| 180 | 180 | |
| 181 | - // chercher d'eventuels rôles transmis |
|
| 182 | - $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut)); |
|
| 183 | - unset($cond['role']); // cette condition est particuliere... |
|
| 181 | + // chercher d'eventuels rôles transmis |
|
| 182 | + $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut)); |
|
| 183 | + unset($cond['role']); // cette condition est particuliere... |
|
| 184 | 184 | |
| 185 | - if ($colonne_role) { |
|
| 186 | - // on ajoute la condition du role aux autres conditions. |
|
| 187 | - if ($role != '*') { |
|
| 188 | - $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 189 | - } |
|
| 190 | - } |
|
| 185 | + if ($colonne_role) { |
|
| 186 | + // on ajoute la condition du role aux autres conditions. |
|
| 187 | + if ($role != '*') { |
|
| 188 | + $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - return [$cond, $colonne_role, $role]; |
|
| 192 | + return [$cond, $colonne_role, $role]; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -211,28 +211,28 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function roles_complets($objet_source, $objet, $id_objet, $objet_lien) { |
| 213 | 213 | |
| 214 | - $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 215 | - // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 216 | - if ($presents === false) { |
|
| 217 | - return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - // types de roles possibles |
|
| 221 | - $roles_possibles = $presents['roles']['roles']['choix']; |
|
| 222 | - // couples id / roles |
|
| 223 | - $ids = $presents['ids']; |
|
| 224 | - |
|
| 225 | - // pour chaque groupe, on fait le diff entre tous les roles possibles |
|
| 226 | - // et les roles attribués à l'élément : s'il en reste, c'est que l'élément |
|
| 227 | - // n'est pas complet |
|
| 228 | - $complets = []; |
|
| 229 | - foreach ($ids as $id => $roles_presents) { |
|
| 230 | - if (!array_diff($roles_possibles, $roles_presents)) { |
|
| 231 | - $complets[] = $id; |
|
| 232 | - } |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - return $complets; |
|
| 214 | + $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 215 | + // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 216 | + if ($presents === false) { |
|
| 217 | + return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + // types de roles possibles |
|
| 221 | + $roles_possibles = $presents['roles']['roles']['choix']; |
|
| 222 | + // couples id / roles |
|
| 223 | + $ids = $presents['ids']; |
|
| 224 | + |
|
| 225 | + // pour chaque groupe, on fait le diff entre tous les roles possibles |
|
| 226 | + // et les roles attribués à l'élément : s'il en reste, c'est que l'élément |
|
| 227 | + // n'est pas complet |
|
| 228 | + $complets = []; |
|
| 229 | + foreach ($ids as $id => $roles_presents) { |
|
| 230 | + if (!array_diff($roles_possibles, $roles_presents)) { |
|
| 231 | + $complets[] = $id; |
|
| 232 | + } |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + return $complets; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -249,17 +249,17 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) { |
| 251 | 251 | |
| 252 | - $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 253 | - // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 254 | - if ($presents === false) { |
|
| 255 | - return []; |
|
| 256 | - } |
|
| 252 | + $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 253 | + // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 254 | + if ($presents === false) { |
|
| 255 | + return []; |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - if (!isset($presents['ids'][$id_objet_source])) { |
|
| 259 | - return []; |
|
| 260 | - } |
|
| 258 | + if (!isset($presents['ids'][$id_objet_source])) { |
|
| 259 | + return []; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - return $presents['ids'][$id_objet_source]; |
|
| 262 | + return $presents['ids'][$id_objet_source]; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | |
@@ -287,47 +287,47 @@ discard block |
||
| 287 | 287 | * - False si pas de role déclarés |
| 288 | 288 | */ |
| 289 | 289 | function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) { |
| 290 | - static $done = []; |
|
| 291 | - |
|
| 292 | - // stocker le résultat |
|
| 293 | - $hash = "$objet_source-$objet-$id_objet-$objet_lien"; |
|
| 294 | - if (isset($done[$hash])) { |
|
| 295 | - return $done[$hash]; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - // pas de roles sur ces objets, on sort |
|
| 299 | - $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 300 | - if (!$roles) { |
|
| 301 | - return $done[$hash] = false; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // inspiré de lister_objets_lies() |
|
| 305 | - if ($objet_lien == $objet) { |
|
| 306 | - $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']); |
|
| 307 | - } else { |
|
| 308 | - $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]); |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - // types de roles possibles |
|
| 312 | - $roles_possibles = $roles['roles']['choix']; |
|
| 313 | - // colonne du role |
|
| 314 | - $colonne = $roles['colonne']; |
|
| 315 | - |
|
| 316 | - // on recupere par id, et role existant |
|
| 317 | - $ids = []; |
|
| 318 | - while ($row = array_shift($res)) { |
|
| 319 | - $id = $row[$objet_source]; |
|
| 320 | - if (!isset($ids[$id])) { |
|
| 321 | - $ids[$id] = []; |
|
| 322 | - } |
|
| 323 | - // tableau des roles présents |
|
| 324 | - $ids[$id][] = $row[$colonne]; |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - return $done[$hash] = [ |
|
| 328 | - 'roles' => $roles, |
|
| 329 | - 'ids' => $ids |
|
| 330 | - ]; |
|
| 290 | + static $done = []; |
|
| 291 | + |
|
| 292 | + // stocker le résultat |
|
| 293 | + $hash = "$objet_source-$objet-$id_objet-$objet_lien"; |
|
| 294 | + if (isset($done[$hash])) { |
|
| 295 | + return $done[$hash]; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + // pas de roles sur ces objets, on sort |
|
| 299 | + $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 300 | + if (!$roles) { |
|
| 301 | + return $done[$hash] = false; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // inspiré de lister_objets_lies() |
|
| 305 | + if ($objet_lien == $objet) { |
|
| 306 | + $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']); |
|
| 307 | + } else { |
|
| 308 | + $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]); |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + // types de roles possibles |
|
| 312 | + $roles_possibles = $roles['roles']['choix']; |
|
| 313 | + // colonne du role |
|
| 314 | + $colonne = $roles['colonne']; |
|
| 315 | + |
|
| 316 | + // on recupere par id, et role existant |
|
| 317 | + $ids = []; |
|
| 318 | + while ($row = array_shift($res)) { |
|
| 319 | + $id = $row[$objet_source]; |
|
| 320 | + if (!isset($ids[$id])) { |
|
| 321 | + $ids[$id] = []; |
|
| 322 | + } |
|
| 323 | + // tableau des roles présents |
|
| 324 | + $ids[$id][] = $row[$colonne]; |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + return $done[$hash] = [ |
|
| 328 | + 'roles' => $roles, |
|
| 329 | + 'ids' => $ids |
|
| 330 | + ]; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | |
@@ -345,33 +345,33 @@ discard block |
||
| 345 | 345 | * - false si pas de role déclarés |
| 346 | 346 | */ |
| 347 | 347 | function roles_connus_en_base($objet_source, $objet, $objet_lien) { |
| 348 | - static $done = []; |
|
| 349 | - |
|
| 350 | - // stocker le résultat |
|
| 351 | - $hash = "$objet_source-$objet-$objet_lien"; |
|
| 352 | - if (isset($done[$hash])) { |
|
| 353 | - return $done[$hash]; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - if (!$lien = objet_associable($objet_lien)) { |
|
| 357 | - return $done[$hash] = false; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - // pas de roles sur ces objets, on sort |
|
| 361 | - $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 362 | - if (!$roles) { |
|
| 363 | - return $done[$hash] = false; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - [$primary, $l] = $lien; |
|
| 367 | - $colone_role = $roles['colonne']; |
|
| 368 | - |
|
| 369 | - $all = sql_allfetsel( |
|
| 370 | - "DISTINCT $colone_role", |
|
| 371 | - $l, |
|
| 372 | - 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 373 | - ); |
|
| 374 | - $done[$hash] = array_map('reset', $all); |
|
| 375 | - |
|
| 376 | - return $done[$hash]; |
|
| 348 | + static $done = []; |
|
| 349 | + |
|
| 350 | + // stocker le résultat |
|
| 351 | + $hash = "$objet_source-$objet-$objet_lien"; |
|
| 352 | + if (isset($done[$hash])) { |
|
| 353 | + return $done[$hash]; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + if (!$lien = objet_associable($objet_lien)) { |
|
| 357 | + return $done[$hash] = false; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + // pas de roles sur ces objets, on sort |
|
| 361 | + $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 362 | + if (!$roles) { |
|
| 363 | + return $done[$hash] = false; |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + [$primary, $l] = $lien; |
|
| 367 | + $colone_role = $roles['colonne']; |
|
| 368 | + |
|
| 369 | + $all = sql_allfetsel( |
|
| 370 | + "DISTINCT $colone_role", |
|
| 371 | + $l, |
|
| 372 | + 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 373 | + ); |
|
| 374 | + $done[$hash] = array_map('reset', $all); |
|
| 375 | + |
|
| 376 | + return $done[$hash]; |
|
| 377 | 377 | } |
@@ -364,8 +364,7 @@ discard block |
||
| 364 | 364 | } |
| 365 | 365 | if (!isset($regs[2])) { |
| 366 | 366 | $niveau = _LOG_INFO; |
| 367 | - } |
|
| 368 | - else { |
|
| 367 | + } else { |
|
| 369 | 368 | $niveau = intval($regs[2]); |
| 370 | 369 | } |
| 371 | 370 | |
@@ -1475,8 +1474,7 @@ discard block |
||
| 1475 | 1474 | ) { |
| 1476 | 1475 | if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
| 1477 | 1476 | return $themefiles["$subdir$file"] = $fsize; |
| 1478 | - } |
|
| 1479 | - else { |
|
| 1477 | + } else { |
|
| 1480 | 1478 | return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
| 1481 | 1479 | } |
| 1482 | 1480 | } |
@@ -3496,8 +3494,7 @@ discard block |
||
| 3496 | 3494 | if (!in_array('svg', $formats)) { |
| 3497 | 3495 | $formats[] = 'svg'; |
| 3498 | 3496 | } |
| 3499 | - } |
|
| 3500 | - else { |
|
| 3497 | + } else { |
|
| 3501 | 3498 | $formats = array_diff($formats, ['svg']); |
| 3502 | 3499 | } |
| 3503 | 3500 | return $formats; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -48,71 +48,71 @@ discard block |
||
| 48 | 48 | * Nom de la fonction, ou false. |
| 49 | 49 | */ |
| 50 | 50 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 51 | - static $echecs = []; |
|
| 52 | - |
|
| 53 | - if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | - $dossier .= '/'; |
|
| 55 | - } |
|
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | - |
|
| 58 | - if (function_exists($f)) { |
|
| 59 | - return $f; |
|
| 60 | - } |
|
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 62 | - return $g; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if (isset($echecs[$f])) { |
|
| 66 | - return $echecs[$f]; |
|
| 67 | - } |
|
| 68 | - // Sinon charger le fichier de declaration si plausible |
|
| 69 | - |
|
| 70 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | - if ($continue) { |
|
| 72 | - return false; |
|
| 73 | - } //appel interne, on passe |
|
| 74 | - include_spip('inc/minipres'); |
|
| 75 | - echo minipres(); |
|
| 76 | - exit; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // passer en minuscules (cf les balises de formulaires) |
|
| 80 | - // et inclure le fichier |
|
| 81 | - if ( |
|
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 83 | - // si le fichier truc/machin/nom.php n'existe pas, |
|
| 84 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 85 | - and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 86 | - ) { |
|
| 87 | - include_spip(substr($dossier, 0, -1)); |
|
| 88 | - } |
|
| 89 | - if (function_exists($f)) { |
|
| 90 | - return $f; |
|
| 91 | - } |
|
| 92 | - if (function_exists($g)) { |
|
| 93 | - return $g; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if ($continue) { |
|
| 97 | - return $echecs[$f] = false; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // Echec : message d'erreur |
|
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 102 | - ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 103 | - |
|
| 104 | - include_spip('inc/minipres'); |
|
| 105 | - echo minipres( |
|
| 106 | - _T('forum_titre_erreur'), |
|
| 107 | - $inc ? |
|
| 108 | - _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 109 | - . '<br />' |
|
| 110 | - . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 111 | - : |
|
| 112 | - _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 113 | - ['all_inline' => true,'status' => 404] |
|
| 114 | - ); |
|
| 115 | - exit; |
|
| 51 | + static $echecs = []; |
|
| 52 | + |
|
| 53 | + if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | + $dossier .= '/'; |
|
| 55 | + } |
|
| 56 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | + |
|
| 58 | + if (function_exists($f)) { |
|
| 59 | + return $f; |
|
| 60 | + } |
|
| 61 | + if (function_exists($g = $f . '_dist')) { |
|
| 62 | + return $g; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if (isset($echecs[$f])) { |
|
| 66 | + return $echecs[$f]; |
|
| 67 | + } |
|
| 68 | + // Sinon charger le fichier de declaration si plausible |
|
| 69 | + |
|
| 70 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | + if ($continue) { |
|
| 72 | + return false; |
|
| 73 | + } //appel interne, on passe |
|
| 74 | + include_spip('inc/minipres'); |
|
| 75 | + echo minipres(); |
|
| 76 | + exit; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // passer en minuscules (cf les balises de formulaires) |
|
| 80 | + // et inclure le fichier |
|
| 81 | + if ( |
|
| 82 | + !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 83 | + // si le fichier truc/machin/nom.php n'existe pas, |
|
| 84 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 85 | + and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 86 | + ) { |
|
| 87 | + include_spip(substr($dossier, 0, -1)); |
|
| 88 | + } |
|
| 89 | + if (function_exists($f)) { |
|
| 90 | + return $f; |
|
| 91 | + } |
|
| 92 | + if (function_exists($g)) { |
|
| 93 | + return $g; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if ($continue) { |
|
| 97 | + return $echecs[$f] = false; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // Echec : message d'erreur |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 102 | + ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 103 | + |
|
| 104 | + include_spip('inc/minipres'); |
|
| 105 | + echo minipres( |
|
| 106 | + _T('forum_titre_erreur'), |
|
| 107 | + $inc ? |
|
| 108 | + _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 109 | + . '<br />' |
|
| 110 | + . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 111 | + : |
|
| 112 | + _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 113 | + ['all_inline' => true,'status' => 404] |
|
| 114 | + ); |
|
| 115 | + exit; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | * @return bool |
| 123 | 123 | */ |
| 124 | 124 | function include_once_check($file) { |
| 125 | - if (file_exists($file)) { |
|
| 126 | - include_once $file; |
|
| 125 | + if (file_exists($file)) { |
|
| 126 | + include_once $file; |
|
| 127 | 127 | |
| 128 | - return true; |
|
| 129 | - } |
|
| 130 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 131 | - $crash = ($crash ?: []); |
|
| 132 | - $crash[$file] = true; |
|
| 133 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 128 | + return true; |
|
| 129 | + } |
|
| 130 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 131 | + $crash = ($crash ?: []); |
|
| 132 | + $crash[$file] = true; |
|
| 133 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 134 | 134 | |
| 135 | - return false; |
|
| 135 | + return false; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * - string : chemin du fichier trouvé |
| 157 | 157 | **/ |
| 158 | 158 | function include_spip($f, $include = true) { |
| 159 | - return find_in_path($f . '.php', '', $include); |
|
| 159 | + return find_in_path($f . '.php', '', $include); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * - string : chemin du fichier trouvé |
| 177 | 177 | **/ |
| 178 | 178 | function require_spip($f) { |
| 179 | - return find_in_path($f . '.php', '', 'required'); |
|
| 179 | + return find_in_path($f . '.php', '', 'required'); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
@@ -185,27 +185,27 @@ discard block |
||
| 185 | 185 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 186 | 186 | */ |
| 187 | 187 | function include_fichiers_fonctions() { |
| 188 | - static $done = false; |
|
| 189 | - if (!$done) { |
|
| 190 | - include_spip('inc/lang'); |
|
| 191 | - |
|
| 192 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 193 | - // donc il faut l'inclure "en globals" |
|
| 194 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 195 | - global $dossier_squelettes; |
|
| 196 | - include_once(_ROOT_CWD . $f); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 200 | - // chargement optimise precompile |
|
| 201 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 202 | - } |
|
| 203 | - if (test_espace_prive()) { |
|
| 204 | - include_spip('inc/filtres_ecrire'); |
|
| 205 | - } |
|
| 206 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 207 | - $done = true; |
|
| 208 | - } |
|
| 188 | + static $done = false; |
|
| 189 | + if (!$done) { |
|
| 190 | + include_spip('inc/lang'); |
|
| 191 | + |
|
| 192 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 193 | + // donc il faut l'inclure "en globals" |
|
| 194 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 195 | + global $dossier_squelettes; |
|
| 196 | + include_once(_ROOT_CWD . $f); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 200 | + // chargement optimise precompile |
|
| 201 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 202 | + } |
|
| 203 | + if (test_espace_prive()) { |
|
| 204 | + include_spip('inc/filtres_ecrire'); |
|
| 205 | + } |
|
| 206 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 207 | + $done = true; |
|
| 208 | + } |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -231,23 +231,23 @@ discard block |
||
| 231 | 231 | * Les paramètres du pipeline modifiés |
| 232 | 232 | **/ |
| 233 | 233 | function minipipe($fonc, &$val) { |
| 234 | - // fonction |
|
| 235 | - if (function_exists($fonc)) { |
|
| 236 | - $val = $fonc($val); |
|
| 237 | - } // Class::Methode |
|
| 238 | - else { |
|
| 239 | - if ( |
|
| 240 | - preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 241 | - and $methode = [$regs[1], $regs[2]] |
|
| 242 | - and is_callable($methode) |
|
| 243 | - ) { |
|
| 244 | - $val = $methode($val); |
|
| 245 | - } else { |
|
| 246 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - return $val; |
|
| 234 | + // fonction |
|
| 235 | + if (function_exists($fonc)) { |
|
| 236 | + $val = $fonc($val); |
|
| 237 | + } // Class::Methode |
|
| 238 | + else { |
|
| 239 | + if ( |
|
| 240 | + preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 241 | + and $methode = [$regs[1], $regs[2]] |
|
| 242 | + and is_callable($methode) |
|
| 243 | + ) { |
|
| 244 | + $val = $methode($val); |
|
| 245 | + } else { |
|
| 246 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + return $val; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -278,46 +278,46 @@ discard block |
||
| 278 | 278 | * Résultat |
| 279 | 279 | */ |
| 280 | 280 | function pipeline($action, $val = null) { |
| 281 | - static $charger; |
|
| 282 | - |
|
| 283 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 284 | - if (!$charger) { |
|
| 285 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 286 | - include_spip('inc/plugin'); |
|
| 287 | - // generer les fichiers php precompiles |
|
| 288 | - // de chargement des plugins et des pipelines |
|
| 289 | - actualise_plugins_actifs(); |
|
| 290 | - if (!($ok = @is_readable($charger))) { |
|
| 291 | - spip_log("fichier $charger pas cree"); |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - if ($ok) { |
|
| 296 | - include_once $charger; |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - // appliquer notre fonction si elle existe |
|
| 301 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 302 | - if (function_exists($fonc)) { |
|
| 303 | - $val = $fonc($val); |
|
| 304 | - } // plantage ? |
|
| 305 | - else { |
|
| 306 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - // si le flux est une table avec 2 cle args&data |
|
| 310 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 311 | - // array_key_exists pour php 4.1.0 |
|
| 312 | - if ( |
|
| 313 | - is_array($val) |
|
| 314 | - and count($val) == 2 |
|
| 315 | - and (array_key_exists('data', $val)) |
|
| 316 | - ) { |
|
| 317 | - $val = $val['data']; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - return $val; |
|
| 281 | + static $charger; |
|
| 282 | + |
|
| 283 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 284 | + if (!$charger) { |
|
| 285 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 286 | + include_spip('inc/plugin'); |
|
| 287 | + // generer les fichiers php precompiles |
|
| 288 | + // de chargement des plugins et des pipelines |
|
| 289 | + actualise_plugins_actifs(); |
|
| 290 | + if (!($ok = @is_readable($charger))) { |
|
| 291 | + spip_log("fichier $charger pas cree"); |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + if ($ok) { |
|
| 296 | + include_once $charger; |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + // appliquer notre fonction si elle existe |
|
| 301 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 302 | + if (function_exists($fonc)) { |
|
| 303 | + $val = $fonc($val); |
|
| 304 | + } // plantage ? |
|
| 305 | + else { |
|
| 306 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + // si le flux est une table avec 2 cle args&data |
|
| 310 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 311 | + // array_key_exists pour php 4.1.0 |
|
| 312 | + if ( |
|
| 313 | + is_array($val) |
|
| 314 | + and count($val) == 2 |
|
| 315 | + and (array_key_exists('data', $val)) |
|
| 316 | + ) { |
|
| 317 | + $val = $val['data']; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + return $val; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -361,38 +361,38 @@ discard block |
||
| 361 | 361 | * paramètre est planté pour cause de compatibilité ascendante. |
| 362 | 362 | */ |
| 363 | 363 | function spip_log($message = null, $name = null) { |
| 364 | - static $pre = []; |
|
| 365 | - static $log; |
|
| 366 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 367 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 368 | - $logname = null; |
|
| 369 | - } |
|
| 370 | - if (!isset($regs[2])) { |
|
| 371 | - $niveau = _LOG_INFO; |
|
| 372 | - } |
|
| 373 | - else { |
|
| 374 | - $niveau = intval($regs[2]); |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 378 | - if (!$pre) { |
|
| 379 | - $pre = [ |
|
| 380 | - _LOG_HS => 'HS:', |
|
| 381 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 382 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 383 | - _LOG_ERREUR => 'ERREUR:', |
|
| 384 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 385 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 386 | - _LOG_INFO => 'info:', |
|
| 387 | - _LOG_DEBUG => 'debug:' |
|
| 388 | - ]; |
|
| 389 | - $log = charger_fonction('log', 'inc'); |
|
| 390 | - } |
|
| 391 | - if (!is_string($message)) { |
|
| 392 | - $message = print_r($message, true); |
|
| 393 | - } |
|
| 394 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 395 | - } |
|
| 364 | + static $pre = []; |
|
| 365 | + static $log; |
|
| 366 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 367 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 368 | + $logname = null; |
|
| 369 | + } |
|
| 370 | + if (!isset($regs[2])) { |
|
| 371 | + $niveau = _LOG_INFO; |
|
| 372 | + } |
|
| 373 | + else { |
|
| 374 | + $niveau = intval($regs[2]); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 378 | + if (!$pre) { |
|
| 379 | + $pre = [ |
|
| 380 | + _LOG_HS => 'HS:', |
|
| 381 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 382 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 383 | + _LOG_ERREUR => 'ERREUR:', |
|
| 384 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 385 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 386 | + _LOG_INFO => 'info:', |
|
| 387 | + _LOG_DEBUG => 'debug:' |
|
| 388 | + ]; |
|
| 389 | + $log = charger_fonction('log', 'inc'); |
|
| 390 | + } |
|
| 391 | + if (!is_string($message)) { |
|
| 392 | + $message = print_r($message, true); |
|
| 393 | + } |
|
| 394 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 395 | + } |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | * @param array $opt Tableau d'options |
| 404 | 404 | **/ |
| 405 | 405 | function journal($phrase, $opt = []) { |
| 406 | - $journal = charger_fonction('journal', 'inc'); |
|
| 407 | - $journal($phrase, $opt); |
|
| 406 | + $journal = charger_fonction('journal', 'inc'); |
|
| 407 | + $journal($phrase, $opt); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | |
@@ -423,37 +423,37 @@ discard block |
||
| 423 | 423 | **/ |
| 424 | 424 | function _request($var, $c = false) { |
| 425 | 425 | |
| 426 | - if (is_array($c)) { |
|
| 427 | - return $c[$var] ?? null; |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - if (isset($_GET[$var])) { |
|
| 431 | - $a = $_GET[$var]; |
|
| 432 | - } elseif (isset($_POST[$var])) { |
|
| 433 | - $a = $_POST[$var]; |
|
| 434 | - } else { |
|
| 435 | - return null; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - // Si on est en ajax et en POST tout a ete encode |
|
| 439 | - // via encodeURIComponent, il faut donc repasser |
|
| 440 | - // dans le charset local... |
|
| 441 | - if ( |
|
| 442 | - defined('_AJAX') |
|
| 443 | - and _AJAX |
|
| 444 | - and isset($GLOBALS['meta']['charset']) |
|
| 445 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 446 | - and is_string($a) |
|
| 447 | - // check rapide mais pas fiable |
|
| 448 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 449 | - // check fiable |
|
| 450 | - and include_spip('inc/charsets') |
|
| 451 | - and is_utf8($a) |
|
| 452 | - ) { |
|
| 453 | - return importer_charset($a, 'utf-8'); |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - return $a; |
|
| 426 | + if (is_array($c)) { |
|
| 427 | + return $c[$var] ?? null; |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + if (isset($_GET[$var])) { |
|
| 431 | + $a = $_GET[$var]; |
|
| 432 | + } elseif (isset($_POST[$var])) { |
|
| 433 | + $a = $_POST[$var]; |
|
| 434 | + } else { |
|
| 435 | + return null; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + // Si on est en ajax et en POST tout a ete encode |
|
| 439 | + // via encodeURIComponent, il faut donc repasser |
|
| 440 | + // dans le charset local... |
|
| 441 | + if ( |
|
| 442 | + defined('_AJAX') |
|
| 443 | + and _AJAX |
|
| 444 | + and isset($GLOBALS['meta']['charset']) |
|
| 445 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 446 | + and is_string($a) |
|
| 447 | + // check rapide mais pas fiable |
|
| 448 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 449 | + // check fiable |
|
| 450 | + and include_spip('inc/charsets') |
|
| 451 | + and is_utf8($a) |
|
| 452 | + ) { |
|
| 453 | + return importer_charset($a, 'utf-8'); |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + return $a; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | |
@@ -471,22 +471,22 @@ discard block |
||
| 471 | 471 | * - false sinon |
| 472 | 472 | **/ |
| 473 | 473 | function set_request($var, $val = null, $c = false) { |
| 474 | - if (is_array($c)) { |
|
| 475 | - unset($c[$var]); |
|
| 476 | - if ($val !== null) { |
|
| 477 | - $c[$var] = $val; |
|
| 478 | - } |
|
| 474 | + if (is_array($c)) { |
|
| 475 | + unset($c[$var]); |
|
| 476 | + if ($val !== null) { |
|
| 477 | + $c[$var] = $val; |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - return $c; |
|
| 481 | - } |
|
| 480 | + return $c; |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - unset($_GET[$var]); |
|
| 484 | - unset($_POST[$var]); |
|
| 485 | - if ($val !== null) { |
|
| 486 | - $_GET[$var] = $val; |
|
| 487 | - } |
|
| 483 | + unset($_GET[$var]); |
|
| 484 | + unset($_POST[$var]); |
|
| 485 | + if ($val !== null) { |
|
| 486 | + $_GET[$var] = $val; |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - return false; # n'affecte pas $c |
|
| 489 | + return false; # n'affecte pas $c |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -506,25 +506,25 @@ discard block |
||
| 506 | 506 | * @return array|mixed|string |
| 507 | 507 | */ |
| 508 | 508 | function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') { |
| 509 | - if (is_array($value)) { |
|
| 510 | - if ($key == '*') { |
|
| 511 | - $key = array_keys($value); |
|
| 512 | - } |
|
| 513 | - if (!is_array($key)) { |
|
| 514 | - $key = [$key]; |
|
| 515 | - } |
|
| 516 | - foreach ($key as $k) { |
|
| 517 | - if (!empty($value[$k])) { |
|
| 518 | - $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 519 | - } |
|
| 520 | - } |
|
| 521 | - return $value; |
|
| 522 | - } |
|
| 523 | - // si la valeur vient des GET ou POST on la sanitize |
|
| 524 | - if (!empty($value) and $value == _request($key)) { |
|
| 525 | - $value = $sanitize_function($value); |
|
| 526 | - } |
|
| 527 | - return $value; |
|
| 509 | + if (is_array($value)) { |
|
| 510 | + if ($key == '*') { |
|
| 511 | + $key = array_keys($value); |
|
| 512 | + } |
|
| 513 | + if (!is_array($key)) { |
|
| 514 | + $key = [$key]; |
|
| 515 | + } |
|
| 516 | + foreach ($key as $k) { |
|
| 517 | + if (!empty($value[$k])) { |
|
| 518 | + $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 519 | + } |
|
| 520 | + } |
|
| 521 | + return $value; |
|
| 522 | + } |
|
| 523 | + // si la valeur vient des GET ou POST on la sanitize |
|
| 524 | + if (!empty($value) and $value == _request($key)) { |
|
| 525 | + $value = $sanitize_function($value); |
|
| 526 | + } |
|
| 527 | + return $value; |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | /** |
@@ -532,23 +532,22 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | * On est sur le web, on exclut certains protocoles, |
| 534 | 534 | * notamment 'file://', 'php://' et d'autres… |
| 535 | - |
|
| 536 | 535 | * @param string $url |
| 537 | 536 | * @return bool |
| 538 | 537 | */ |
| 539 | 538 | function tester_url_absolue($url) { |
| 540 | - $url = trim($url ?? ''); |
|
| 541 | - if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 542 | - if ( |
|
| 543 | - isset($m[1]) |
|
| 544 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 545 | - and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 546 | - ) { |
|
| 547 | - return false; |
|
| 548 | - } |
|
| 549 | - return true; |
|
| 550 | - } |
|
| 551 | - return false; |
|
| 539 | + $url = trim($url ?? ''); |
|
| 540 | + if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 541 | + if ( |
|
| 542 | + isset($m[1]) |
|
| 543 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 544 | + and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 545 | + ) { |
|
| 546 | + return false; |
|
| 547 | + } |
|
| 548 | + return true; |
|
| 549 | + } |
|
| 550 | + return false; |
|
| 552 | 551 | } |
| 553 | 552 | |
| 554 | 553 | /** |
@@ -570,95 +569,95 @@ discard block |
||
| 570 | 569 | * @return string URL |
| 571 | 570 | */ |
| 572 | 571 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 573 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 574 | - if (strpos($c, '|') !== false and is_null($v)) { |
|
| 575 | - return null; |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - // lever l'#ancre |
|
| 579 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 580 | - $url = $r[1]; |
|
| 581 | - $ancre = $r[2]; |
|
| 582 | - } else { |
|
| 583 | - $ancre = ''; |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - // eclater |
|
| 587 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 588 | - |
|
| 589 | - // recuperer la base |
|
| 590 | - $a = array_shift($url); |
|
| 591 | - if (!$a) { |
|
| 592 | - $a = './'; |
|
| 593 | - } |
|
| 594 | - |
|
| 595 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 596 | - $ajouts = array_flip(explode('|', $c)); |
|
| 597 | - $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 598 | - $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 599 | - $v_read = null; |
|
| 600 | - // lire les variables et agir |
|
| 601 | - foreach ($url as $n => $val) { |
|
| 602 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 603 | - $r = array_pad($r, 3, null); |
|
| 604 | - if ($v === null) { |
|
| 605 | - // c'est un tableau, on memorise les valeurs |
|
| 606 | - if (substr($r[1], -2) == '[]') { |
|
| 607 | - if (!$v_read) { |
|
| 608 | - $v_read = []; |
|
| 609 | - } |
|
| 610 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 611 | - } // c'est un scalaire, on retourne direct |
|
| 612 | - else { |
|
| 613 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 614 | - } |
|
| 615 | - } // suppression |
|
| 616 | - elseif (!$testv) { |
|
| 617 | - unset($url[$n]); |
|
| 618 | - } |
|
| 619 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 620 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 621 | - elseif (substr($r[1], -2) != '[]') { |
|
| 622 | - $url[$n] = $r[1] . '=' . $u; |
|
| 623 | - unset($ajouts[$r[1]]); |
|
| 624 | - } |
|
| 625 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 626 | - // départ, on remplira à l'étape suivante |
|
| 627 | - else { |
|
| 628 | - unset($url[$n]); |
|
| 629 | - } |
|
| 630 | - } |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - // traiter les parametres pas encore trouves |
|
| 634 | - if ( |
|
| 635 | - $v === null |
|
| 636 | - and $args = func_get_args() |
|
| 637 | - and count($args) == 2 |
|
| 638 | - ) { |
|
| 639 | - return $v_read; // rien trouve ou un tableau |
|
| 640 | - } elseif ($testv) { |
|
| 641 | - foreach ($ajouts as $k => $n) { |
|
| 642 | - if (!is_array($v)) { |
|
| 643 | - $url[] = $k . '=' . $u; |
|
| 644 | - } else { |
|
| 645 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 646 | - foreach ($v as $w) { |
|
| 647 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 648 | - } |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - // eliminer les vides |
|
| 654 | - $url = array_filter($url); |
|
| 655 | - |
|
| 656 | - // recomposer l'adresse |
|
| 657 | - if ($url) { |
|
| 658 | - $a .= '?' . join($sep, $url); |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - return $a . $ancre; |
|
| 572 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 573 | + if (strpos($c, '|') !== false and is_null($v)) { |
|
| 574 | + return null; |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + // lever l'#ancre |
|
| 578 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 579 | + $url = $r[1]; |
|
| 580 | + $ancre = $r[2]; |
|
| 581 | + } else { |
|
| 582 | + $ancre = ''; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + // eclater |
|
| 586 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 587 | + |
|
| 588 | + // recuperer la base |
|
| 589 | + $a = array_shift($url); |
|
| 590 | + if (!$a) { |
|
| 591 | + $a = './'; |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 595 | + $ajouts = array_flip(explode('|', $c)); |
|
| 596 | + $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 597 | + $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 598 | + $v_read = null; |
|
| 599 | + // lire les variables et agir |
|
| 600 | + foreach ($url as $n => $val) { |
|
| 601 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 602 | + $r = array_pad($r, 3, null); |
|
| 603 | + if ($v === null) { |
|
| 604 | + // c'est un tableau, on memorise les valeurs |
|
| 605 | + if (substr($r[1], -2) == '[]') { |
|
| 606 | + if (!$v_read) { |
|
| 607 | + $v_read = []; |
|
| 608 | + } |
|
| 609 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 610 | + } // c'est un scalaire, on retourne direct |
|
| 611 | + else { |
|
| 612 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 613 | + } |
|
| 614 | + } // suppression |
|
| 615 | + elseif (!$testv) { |
|
| 616 | + unset($url[$n]); |
|
| 617 | + } |
|
| 618 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 619 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 620 | + elseif (substr($r[1], -2) != '[]') { |
|
| 621 | + $url[$n] = $r[1] . '=' . $u; |
|
| 622 | + unset($ajouts[$r[1]]); |
|
| 623 | + } |
|
| 624 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 625 | + // départ, on remplira à l'étape suivante |
|
| 626 | + else { |
|
| 627 | + unset($url[$n]); |
|
| 628 | + } |
|
| 629 | + } |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + // traiter les parametres pas encore trouves |
|
| 633 | + if ( |
|
| 634 | + $v === null |
|
| 635 | + and $args = func_get_args() |
|
| 636 | + and count($args) == 2 |
|
| 637 | + ) { |
|
| 638 | + return $v_read; // rien trouve ou un tableau |
|
| 639 | + } elseif ($testv) { |
|
| 640 | + foreach ($ajouts as $k => $n) { |
|
| 641 | + if (!is_array($v)) { |
|
| 642 | + $url[] = $k . '=' . $u; |
|
| 643 | + } else { |
|
| 644 | + $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 645 | + foreach ($v as $w) { |
|
| 646 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + |
|
| 652 | + // eliminer les vides |
|
| 653 | + $url = array_filter($url); |
|
| 654 | + |
|
| 655 | + // recomposer l'adresse |
|
| 656 | + if ($url) { |
|
| 657 | + $a .= '?' . join($sep, $url); |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + return $a . $ancre; |
|
| 662 | 661 | } |
| 663 | 662 | |
| 664 | 663 | /** |
@@ -676,21 +675,21 @@ discard block |
||
| 676 | 675 | * @return string |
| 677 | 676 | */ |
| 678 | 677 | function ancre_url($url, $ancre) { |
| 679 | - // lever l'#ancre |
|
| 680 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 681 | - $url = $r[1]; |
|
| 682 | - } |
|
| 683 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 684 | - if (!function_exists('translitteration')) { |
|
| 685 | - include_spip('inc/charsets'); |
|
| 686 | - } |
|
| 687 | - $ancre = preg_replace( |
|
| 688 | - ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 689 | - ['', '-'], |
|
| 690 | - translitteration($ancre) |
|
| 691 | - ); |
|
| 692 | - } |
|
| 693 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 678 | + // lever l'#ancre |
|
| 679 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 680 | + $url = $r[1]; |
|
| 681 | + } |
|
| 682 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 683 | + if (!function_exists('translitteration')) { |
|
| 684 | + include_spip('inc/charsets'); |
|
| 685 | + } |
|
| 686 | + $ancre = preg_replace( |
|
| 687 | + ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 688 | + ['', '-'], |
|
| 689 | + translitteration($ancre) |
|
| 690 | + ); |
|
| 691 | + } |
|
| 692 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 694 | 693 | } |
| 695 | 694 | |
| 696 | 695 | /** |
@@ -700,16 +699,16 @@ discard block |
||
| 700 | 699 | * @return string |
| 701 | 700 | */ |
| 702 | 701 | function nettoyer_uri($reset = null) { |
| 703 | - static $done = false; |
|
| 704 | - static $propre = ''; |
|
| 705 | - if (!is_null($reset)) { |
|
| 706 | - return $propre = $reset; |
|
| 707 | - } |
|
| 708 | - if ($done) { |
|
| 709 | - return $propre; |
|
| 710 | - } |
|
| 711 | - $done = true; |
|
| 712 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 702 | + static $done = false; |
|
| 703 | + static $propre = ''; |
|
| 704 | + if (!is_null($reset)) { |
|
| 705 | + return $propre = $reset; |
|
| 706 | + } |
|
| 707 | + if ($done) { |
|
| 708 | + return $propre; |
|
| 709 | + } |
|
| 710 | + $done = true; |
|
| 711 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 713 | 712 | } |
| 714 | 713 | |
| 715 | 714 | /** |
@@ -721,16 +720,16 @@ discard block |
||
| 721 | 720 | * @return string |
| 722 | 721 | */ |
| 723 | 722 | function nettoyer_uri_var($request_uri) { |
| 724 | - $uri1 = $request_uri; |
|
| 725 | - do { |
|
| 726 | - $uri = $uri1; |
|
| 727 | - $uri1 = preg_replace( |
|
| 728 | - ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 729 | - '\1', |
|
| 730 | - $uri |
|
| 731 | - ); |
|
| 732 | - } while ($uri <> $uri1); |
|
| 733 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 723 | + $uri1 = $request_uri; |
|
| 724 | + do { |
|
| 725 | + $uri = $uri1; |
|
| 726 | + $uri1 = preg_replace( |
|
| 727 | + ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 728 | + '\1', |
|
| 729 | + $uri |
|
| 730 | + ); |
|
| 731 | + } while ($uri <> $uri1); |
|
| 732 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 734 | 733 | } |
| 735 | 734 | |
| 736 | 735 | |
@@ -744,48 +743,48 @@ discard block |
||
| 744 | 743 | * URL vers soi-même |
| 745 | 744 | **/ |
| 746 | 745 | function self($amp = '&', $root = false) { |
| 747 | - $url = nettoyer_uri(); |
|
| 748 | - if ( |
|
| 749 | - !$root |
|
| 750 | - and ( |
|
| 751 | - // si pas de profondeur on peut tronquer |
|
| 752 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 753 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 754 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 755 | - ) { |
|
| 756 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 757 | - } |
|
| 758 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 759 | - foreach ($_POST as $v => $c) { |
|
| 760 | - if (substr($v, 0, 3) == 'id_') { |
|
| 761 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 762 | - } |
|
| 763 | - } |
|
| 764 | - |
|
| 765 | - // supprimer les variables sans interet |
|
| 766 | - if (test_espace_prive()) { |
|
| 767 | - $url = preg_replace(',([?&])(' |
|
| 768 | - . 'lang|show_docs|' |
|
| 769 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 770 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 771 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - // eviter les hacks |
|
| 775 | - include_spip('inc/filtres_mini'); |
|
| 776 | - $url = spip_htmlspecialchars($url); |
|
| 777 | - |
|
| 778 | - $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 779 | - |
|
| 780 | - // & ? |
|
| 781 | - if ($amp != '&') { |
|
| 782 | - $url = str_replace('&', $amp, $url); |
|
| 783 | - } |
|
| 784 | - |
|
| 785 | - // Si ca demarre par ? ou vide, donner './' |
|
| 786 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 787 | - |
|
| 788 | - return $url; |
|
| 746 | + $url = nettoyer_uri(); |
|
| 747 | + if ( |
|
| 748 | + !$root |
|
| 749 | + and ( |
|
| 750 | + // si pas de profondeur on peut tronquer |
|
| 751 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 752 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 753 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 754 | + ) { |
|
| 755 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 756 | + } |
|
| 757 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 758 | + foreach ($_POST as $v => $c) { |
|
| 759 | + if (substr($v, 0, 3) == 'id_') { |
|
| 760 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + // supprimer les variables sans interet |
|
| 765 | + if (test_espace_prive()) { |
|
| 766 | + $url = preg_replace(',([?&])(' |
|
| 767 | + . 'lang|show_docs|' |
|
| 768 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 769 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 770 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 771 | + } |
|
| 772 | + |
|
| 773 | + // eviter les hacks |
|
| 774 | + include_spip('inc/filtres_mini'); |
|
| 775 | + $url = spip_htmlspecialchars($url); |
|
| 776 | + |
|
| 777 | + $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 778 | + |
|
| 779 | + // & ? |
|
| 780 | + if ($amp != '&') { |
|
| 781 | + $url = str_replace('&', $amp, $url); |
|
| 782 | + } |
|
| 783 | + |
|
| 784 | + // Si ca demarre par ? ou vide, donner './' |
|
| 785 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 786 | + |
|
| 787 | + return $url; |
|
| 789 | 788 | } |
| 790 | 789 | |
| 791 | 790 | |
@@ -796,7 +795,7 @@ discard block |
||
| 796 | 795 | * true si c'est le cas, false sinon. |
| 797 | 796 | */ |
| 798 | 797 | function test_espace_prive() { |
| 799 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 798 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 800 | 799 | } |
| 801 | 800 | |
| 802 | 801 | /** |
@@ -806,7 +805,7 @@ discard block |
||
| 806 | 805 | * @return bool |
| 807 | 806 | */ |
| 808 | 807 | function test_plugin_actif($plugin) { |
| 809 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 808 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 810 | 809 | } |
| 811 | 810 | |
| 812 | 811 | /** |
@@ -837,52 +836,52 @@ discard block |
||
| 837 | 836 | * Texte |
| 838 | 837 | */ |
| 839 | 838 | function _T($texte, $args = [], $options = []) { |
| 840 | - static $traduire = false; |
|
| 841 | - $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 842 | - if ($options) { |
|
| 843 | - // support de l'ancien argument $class |
|
| 844 | - if (is_string($options)) { |
|
| 845 | - $options = ['class' => $options]; |
|
| 846 | - } |
|
| 847 | - $o = array_merge($o, $options); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - if (!$traduire) { |
|
| 851 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 852 | - include_spip('inc/lang'); |
|
| 853 | - } |
|
| 854 | - |
|
| 855 | - // On peut passer explicitement la langue dans le tableau |
|
| 856 | - // On utilise le même nom de variable que la globale |
|
| 857 | - if (isset($args['spip_lang'])) { |
|
| 858 | - $lang = $args['spip_lang']; |
|
| 859 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 860 | - unset($args['spip_lang']); |
|
| 861 | - } // Sinon on prend la langue du contexte |
|
| 862 | - else { |
|
| 863 | - $lang = $GLOBALS['spip_lang']; |
|
| 864 | - } |
|
| 865 | - $text = $traduire($texte, $lang); |
|
| 866 | - |
|
| 867 | - if ($text === null || !strlen($text)) { |
|
| 868 | - if (!$o['force']) { |
|
| 869 | - return ''; |
|
| 870 | - } |
|
| 871 | - |
|
| 872 | - $text = $texte; |
|
| 873 | - |
|
| 874 | - // pour les chaines non traduites, assurer un service minimum |
|
| 875 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 876 | - $n = strpos($text, ':'); |
|
| 877 | - if ($n !== false) { |
|
| 878 | - $text = substr($text, $n + 1); |
|
| 879 | - } |
|
| 880 | - $text = str_replace('_', ' ', $text); |
|
| 881 | - } |
|
| 882 | - $o['class'] = null; |
|
| 883 | - } |
|
| 884 | - |
|
| 885 | - return _L($text, $args, $o); |
|
| 839 | + static $traduire = false; |
|
| 840 | + $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 841 | + if ($options) { |
|
| 842 | + // support de l'ancien argument $class |
|
| 843 | + if (is_string($options)) { |
|
| 844 | + $options = ['class' => $options]; |
|
| 845 | + } |
|
| 846 | + $o = array_merge($o, $options); |
|
| 847 | + } |
|
| 848 | + |
|
| 849 | + if (!$traduire) { |
|
| 850 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 851 | + include_spip('inc/lang'); |
|
| 852 | + } |
|
| 853 | + |
|
| 854 | + // On peut passer explicitement la langue dans le tableau |
|
| 855 | + // On utilise le même nom de variable que la globale |
|
| 856 | + if (isset($args['spip_lang'])) { |
|
| 857 | + $lang = $args['spip_lang']; |
|
| 858 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 859 | + unset($args['spip_lang']); |
|
| 860 | + } // Sinon on prend la langue du contexte |
|
| 861 | + else { |
|
| 862 | + $lang = $GLOBALS['spip_lang']; |
|
| 863 | + } |
|
| 864 | + $text = $traduire($texte, $lang); |
|
| 865 | + |
|
| 866 | + if ($text === null || !strlen($text)) { |
|
| 867 | + if (!$o['force']) { |
|
| 868 | + return ''; |
|
| 869 | + } |
|
| 870 | + |
|
| 871 | + $text = $texte; |
|
| 872 | + |
|
| 873 | + // pour les chaines non traduites, assurer un service minimum |
|
| 874 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 875 | + $n = strpos($text, ':'); |
|
| 876 | + if ($n !== false) { |
|
| 877 | + $text = substr($text, $n + 1); |
|
| 878 | + } |
|
| 879 | + $text = str_replace('_', ' ', $text); |
|
| 880 | + } |
|
| 881 | + $o['class'] = null; |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + return _L($text, $args, $o); |
|
| 886 | 885 | } |
| 887 | 886 | |
| 888 | 887 | |
@@ -909,53 +908,53 @@ discard block |
||
| 909 | 908 | * Texte |
| 910 | 909 | */ |
| 911 | 910 | function _L($text, $args = [], $options = []) { |
| 912 | - $f = $text; |
|
| 913 | - $defaut_options = [ |
|
| 914 | - 'class' => null, |
|
| 915 | - 'sanitize' => true, |
|
| 916 | - ]; |
|
| 917 | - // support de l'ancien argument $class |
|
| 918 | - if ($options and is_string($options)) { |
|
| 919 | - $options = ['class' => $options]; |
|
| 920 | - } |
|
| 921 | - if (is_array($options)) { |
|
| 922 | - $options += $defaut_options; |
|
| 923 | - } else { |
|
| 924 | - $options = $defaut_options; |
|
| 925 | - } |
|
| 926 | - |
|
| 927 | - if (is_array($args) and count($args)) { |
|
| 928 | - if (!function_exists('interdire_scripts')) { |
|
| 929 | - include_spip('inc/texte'); |
|
| 930 | - } |
|
| 931 | - if (!function_exists('echapper_html_suspect')) { |
|
| 932 | - include_spip('inc/texte_mini'); |
|
| 933 | - } |
|
| 934 | - foreach ($args as $name => $value) { |
|
| 935 | - if (strpos($text, (string) "@$name@") !== false) { |
|
| 936 | - if ($options['sanitize']) { |
|
| 937 | - $value = echapper_html_suspect($value); |
|
| 938 | - $value = interdire_scripts($value, -1); |
|
| 939 | - } |
|
| 940 | - if (!empty($options['class'])) { |
|
| 941 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 942 | - } |
|
| 943 | - $text = str_replace("@$name@", $value, $text); |
|
| 944 | - unset($args[$name]); |
|
| 945 | - } |
|
| 946 | - } |
|
| 947 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 948 | - // (chaines de langues pas a jour) |
|
| 949 | - if ($args) { |
|
| 950 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 951 | - } |
|
| 952 | - } |
|
| 953 | - |
|
| 954 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 955 | - return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 956 | - } else { |
|
| 957 | - return $text; |
|
| 958 | - } |
|
| 911 | + $f = $text; |
|
| 912 | + $defaut_options = [ |
|
| 913 | + 'class' => null, |
|
| 914 | + 'sanitize' => true, |
|
| 915 | + ]; |
|
| 916 | + // support de l'ancien argument $class |
|
| 917 | + if ($options and is_string($options)) { |
|
| 918 | + $options = ['class' => $options]; |
|
| 919 | + } |
|
| 920 | + if (is_array($options)) { |
|
| 921 | + $options += $defaut_options; |
|
| 922 | + } else { |
|
| 923 | + $options = $defaut_options; |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + if (is_array($args) and count($args)) { |
|
| 927 | + if (!function_exists('interdire_scripts')) { |
|
| 928 | + include_spip('inc/texte'); |
|
| 929 | + } |
|
| 930 | + if (!function_exists('echapper_html_suspect')) { |
|
| 931 | + include_spip('inc/texte_mini'); |
|
| 932 | + } |
|
| 933 | + foreach ($args as $name => $value) { |
|
| 934 | + if (strpos($text, (string) "@$name@") !== false) { |
|
| 935 | + if ($options['sanitize']) { |
|
| 936 | + $value = echapper_html_suspect($value); |
|
| 937 | + $value = interdire_scripts($value, -1); |
|
| 938 | + } |
|
| 939 | + if (!empty($options['class'])) { |
|
| 940 | + $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 941 | + } |
|
| 942 | + $text = str_replace("@$name@", $value, $text); |
|
| 943 | + unset($args[$name]); |
|
| 944 | + } |
|
| 945 | + } |
|
| 946 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 947 | + // (chaines de langues pas a jour) |
|
| 948 | + if ($args) { |
|
| 949 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 950 | + } |
|
| 951 | + } |
|
| 952 | + |
|
| 953 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 954 | + return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 955 | + } else { |
|
| 956 | + return $text; |
|
| 957 | + } |
|
| 959 | 958 | } |
| 960 | 959 | |
| 961 | 960 | |
@@ -969,13 +968,13 @@ discard block |
||
| 969 | 968 | * @return string |
| 970 | 969 | */ |
| 971 | 970 | function joli_repertoire($rep) { |
| 972 | - $a = substr($rep, 0, 1); |
|
| 973 | - if ($a <> '.' and $a <> '/') { |
|
| 974 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 975 | - } |
|
| 976 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 971 | + $a = substr($rep, 0, 1); |
|
| 972 | + if ($a <> '.' and $a <> '/') { |
|
| 973 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 974 | + } |
|
| 975 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 977 | 976 | |
| 978 | - return $rep; |
|
| 977 | + return $rep; |
|
| 979 | 978 | } |
| 980 | 979 | |
| 981 | 980 | |
@@ -1000,54 +999,54 @@ discard block |
||
| 1000 | 999 | * @return float|int|string|void |
| 1001 | 1000 | */ |
| 1002 | 1001 | function spip_timer($t = 'rien', $raw = false) { |
| 1003 | - static $time; |
|
| 1004 | - $a = time(); |
|
| 1005 | - $b = microtime(); |
|
| 1006 | - // microtime peut contenir les microsecondes et le temps |
|
| 1007 | - $b = explode(' ', $b); |
|
| 1008 | - if (count($b) == 2) { |
|
| 1009 | - $a = end($b); |
|
| 1010 | - } // plus precis ! |
|
| 1011 | - $b = reset($b); |
|
| 1012 | - if (!isset($time[$t])) { |
|
| 1013 | - $time[$t] = $a + $b; |
|
| 1014 | - } else { |
|
| 1015 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 1016 | - unset($time[$t]); |
|
| 1002 | + static $time; |
|
| 1003 | + $a = time(); |
|
| 1004 | + $b = microtime(); |
|
| 1005 | + // microtime peut contenir les microsecondes et le temps |
|
| 1006 | + $b = explode(' ', $b); |
|
| 1007 | + if (count($b) == 2) { |
|
| 1008 | + $a = end($b); |
|
| 1009 | + } // plus precis ! |
|
| 1010 | + $b = reset($b); |
|
| 1011 | + if (!isset($time[$t])) { |
|
| 1012 | + $time[$t] = $a + $b; |
|
| 1013 | + } else { |
|
| 1014 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 1015 | + unset($time[$t]); |
|
| 1017 | 1016 | # echo "'$p'";exit; |
| 1018 | - if ($raw) { |
|
| 1019 | - return $p; |
|
| 1020 | - } |
|
| 1021 | - if ($p < 1000) { |
|
| 1022 | - $s = ''; |
|
| 1023 | - } else { |
|
| 1024 | - $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1025 | - $p -= ($x * 1000); |
|
| 1026 | - } |
|
| 1017 | + if ($raw) { |
|
| 1018 | + return $p; |
|
| 1019 | + } |
|
| 1020 | + if ($p < 1000) { |
|
| 1021 | + $s = ''; |
|
| 1022 | + } else { |
|
| 1023 | + $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1024 | + $p -= ($x * 1000); |
|
| 1025 | + } |
|
| 1027 | 1026 | |
| 1028 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1029 | - } |
|
| 1027 | + return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1028 | + } |
|
| 1030 | 1029 | } |
| 1031 | 1030 | |
| 1032 | 1031 | |
| 1033 | 1032 | // Renvoie False si un fichier n'est pas plus vieux que $duree secondes, |
| 1034 | 1033 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 1035 | 1034 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 1036 | - if ($duree) { |
|
| 1037 | - clearstatcache(); |
|
| 1038 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1039 | - return false; |
|
| 1040 | - } |
|
| 1041 | - } |
|
| 1042 | - if ($touch !== false) { |
|
| 1043 | - if (!@touch($fichier)) { |
|
| 1044 | - spip_unlink($fichier); |
|
| 1045 | - @touch($fichier); |
|
| 1046 | - }; |
|
| 1047 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1048 | - } |
|
| 1035 | + if ($duree) { |
|
| 1036 | + clearstatcache(); |
|
| 1037 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1038 | + return false; |
|
| 1039 | + } |
|
| 1040 | + } |
|
| 1041 | + if ($touch !== false) { |
|
| 1042 | + if (!@touch($fichier)) { |
|
| 1043 | + spip_unlink($fichier); |
|
| 1044 | + @touch($fichier); |
|
| 1045 | + }; |
|
| 1046 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1047 | + } |
|
| 1049 | 1048 | |
| 1050 | - return true; |
|
| 1049 | + return true; |
|
| 1051 | 1050 | } |
| 1052 | 1051 | |
| 1053 | 1052 | |
@@ -1058,11 +1057,11 @@ discard block |
||
| 1058 | 1057 | * @uses cron() |
| 1059 | 1058 | **/ |
| 1060 | 1059 | function action_cron() { |
| 1061 | - include_spip('inc/headers'); |
|
| 1062 | - http_response_code(204); // No Content |
|
| 1063 | - header('Connection: close'); |
|
| 1064 | - define('_DIRECT_CRON_FORCE', true); |
|
| 1065 | - cron(); |
|
| 1060 | + include_spip('inc/headers'); |
|
| 1061 | + http_response_code(204); // No Content |
|
| 1062 | + header('Connection: close'); |
|
| 1063 | + define('_DIRECT_CRON_FORCE', true); |
|
| 1064 | + cron(); |
|
| 1066 | 1065 | } |
| 1067 | 1066 | |
| 1068 | 1067 | /** |
@@ -1078,26 +1077,26 @@ discard block |
||
| 1078 | 1077 | * True si la tache a pu être effectuée |
| 1079 | 1078 | */ |
| 1080 | 1079 | function cron($taches = [], $taches_old = []) { |
| 1081 | - // si pas en mode cron force, laisser tomber. |
|
| 1082 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1083 | - return false; |
|
| 1084 | - } |
|
| 1085 | - if (!is_array($taches)) { |
|
| 1086 | - $taches = $taches_old; |
|
| 1087 | - } // compat anciens appels |
|
| 1088 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1089 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1090 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1091 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1092 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1093 | - return false; |
|
| 1094 | - } |
|
| 1095 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1096 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1097 | - return $genie($taches); |
|
| 1098 | - } |
|
| 1099 | - |
|
| 1100 | - return false; |
|
| 1080 | + // si pas en mode cron force, laisser tomber. |
|
| 1081 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1082 | + return false; |
|
| 1083 | + } |
|
| 1084 | + if (!is_array($taches)) { |
|
| 1085 | + $taches = $taches_old; |
|
| 1086 | + } // compat anciens appels |
|
| 1087 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1088 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1089 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1090 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1091 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1092 | + return false; |
|
| 1093 | + } |
|
| 1094 | + spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1095 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1096 | + return $genie($taches); |
|
| 1097 | + } |
|
| 1098 | + |
|
| 1099 | + return false; |
|
| 1101 | 1100 | } |
| 1102 | 1101 | |
| 1103 | 1102 | /** |
@@ -1129,17 +1128,17 @@ discard block |
||
| 1129 | 1128 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1130 | 1129 | */ |
| 1131 | 1130 | function job_queue_add( |
| 1132 | - $function, |
|
| 1133 | - $description, |
|
| 1134 | - $arguments = [], |
|
| 1135 | - $file = '', |
|
| 1136 | - $no_duplicate = false, |
|
| 1137 | - $time = 0, |
|
| 1138 | - $priority = 0 |
|
| 1131 | + $function, |
|
| 1132 | + $description, |
|
| 1133 | + $arguments = [], |
|
| 1134 | + $file = '', |
|
| 1135 | + $no_duplicate = false, |
|
| 1136 | + $time = 0, |
|
| 1137 | + $priority = 0 |
|
| 1139 | 1138 | ) { |
| 1140 | - include_spip('inc/queue'); |
|
| 1139 | + include_spip('inc/queue'); |
|
| 1141 | 1140 | |
| 1142 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1141 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1143 | 1142 | } |
| 1144 | 1143 | |
| 1145 | 1144 | /** |
@@ -1150,9 +1149,9 @@ discard block |
||
| 1150 | 1149 | * @return bool |
| 1151 | 1150 | */ |
| 1152 | 1151 | function job_queue_remove($id_job) { |
| 1153 | - include_spip('inc/queue'); |
|
| 1152 | + include_spip('inc/queue'); |
|
| 1154 | 1153 | |
| 1155 | - return queue_remove_job($id_job); |
|
| 1154 | + return queue_remove_job($id_job); |
|
| 1156 | 1155 | } |
| 1157 | 1156 | |
| 1158 | 1157 | /** |
@@ -1165,9 +1164,9 @@ discard block |
||
| 1165 | 1164 | * or an array of simple array to link multiples objet in one time |
| 1166 | 1165 | */ |
| 1167 | 1166 | function job_queue_link($id_job, $objets) { |
| 1168 | - include_spip('inc/queue'); |
|
| 1167 | + include_spip('inc/queue'); |
|
| 1169 | 1168 | |
| 1170 | - return queue_link_job($id_job, $objets); |
|
| 1169 | + return queue_link_job($id_job, $objets); |
|
| 1171 | 1170 | } |
| 1172 | 1171 | |
| 1173 | 1172 | |
@@ -1187,36 +1186,36 @@ discard block |
||
| 1187 | 1186 | * - `null` si la queue n'est pas encore initialisée |
| 1188 | 1187 | */ |
| 1189 | 1188 | function queue_sleep_time_to_next_job($force = null) { |
| 1190 | - static $queue_next_job_time = -1; |
|
| 1191 | - if ($force === true) { |
|
| 1192 | - $queue_next_job_time = -1; |
|
| 1193 | - } elseif ($force) { |
|
| 1194 | - $queue_next_job_time = $force; |
|
| 1195 | - } |
|
| 1196 | - |
|
| 1197 | - if ($queue_next_job_time == -1) { |
|
| 1198 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1199 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1200 | - } |
|
| 1201 | - // utiliser un cache memoire si dispo |
|
| 1202 | - if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1203 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1204 | - } else { |
|
| 1205 | - $queue_next_job_time = null; |
|
| 1206 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1207 | - $queue_next_job_time = intval($contenu); |
|
| 1208 | - } |
|
| 1209 | - } |
|
| 1210 | - } |
|
| 1211 | - |
|
| 1212 | - if (is_null($queue_next_job_time)) { |
|
| 1213 | - return null; |
|
| 1214 | - } |
|
| 1215 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1216 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1217 | - } |
|
| 1218 | - |
|
| 1219 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1189 | + static $queue_next_job_time = -1; |
|
| 1190 | + if ($force === true) { |
|
| 1191 | + $queue_next_job_time = -1; |
|
| 1192 | + } elseif ($force) { |
|
| 1193 | + $queue_next_job_time = $force; |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + if ($queue_next_job_time == -1) { |
|
| 1197 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1198 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1199 | + } |
|
| 1200 | + // utiliser un cache memoire si dispo |
|
| 1201 | + if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1202 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1203 | + } else { |
|
| 1204 | + $queue_next_job_time = null; |
|
| 1205 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1206 | + $queue_next_job_time = intval($contenu); |
|
| 1207 | + } |
|
| 1208 | + } |
|
| 1209 | + } |
|
| 1210 | + |
|
| 1211 | + if (is_null($queue_next_job_time)) { |
|
| 1212 | + return null; |
|
| 1213 | + } |
|
| 1214 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1215 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1216 | + } |
|
| 1217 | + |
|
| 1218 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1220 | 1219 | } |
| 1221 | 1220 | |
| 1222 | 1221 | |
@@ -1228,11 +1227,11 @@ discard block |
||
| 1228 | 1227 | * @return string |
| 1229 | 1228 | */ |
| 1230 | 1229 | function quote_amp($u) { |
| 1231 | - return preg_replace( |
|
| 1232 | - '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1233 | - '&', |
|
| 1234 | - $u |
|
| 1235 | - ); |
|
| 1230 | + return preg_replace( |
|
| 1231 | + '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1232 | + '&', |
|
| 1233 | + $u |
|
| 1234 | + ); |
|
| 1236 | 1235 | } |
| 1237 | 1236 | |
| 1238 | 1237 | |
@@ -1255,27 +1254,27 @@ discard block |
||
| 1255 | 1254 | * Balise HTML `<script>` et son contenu |
| 1256 | 1255 | **/ |
| 1257 | 1256 | function http_script($script, $src = '', $noscript = '') { |
| 1258 | - static $done = []; |
|
| 1257 | + static $done = []; |
|
| 1259 | 1258 | |
| 1260 | - if ($src && !isset($done[$src])) { |
|
| 1261 | - $done[$src] = true; |
|
| 1262 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1263 | - $src = " src='$src'"; |
|
| 1264 | - } else { |
|
| 1265 | - $src = ''; |
|
| 1266 | - } |
|
| 1267 | - if ($script) { |
|
| 1268 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1269 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1270 | - '/*]]>*/'); |
|
| 1271 | - } |
|
| 1272 | - if ($noscript) { |
|
| 1273 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1274 | - } |
|
| 1259 | + if ($src && !isset($done[$src])) { |
|
| 1260 | + $done[$src] = true; |
|
| 1261 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1262 | + $src = " src='$src'"; |
|
| 1263 | + } else { |
|
| 1264 | + $src = ''; |
|
| 1265 | + } |
|
| 1266 | + if ($script) { |
|
| 1267 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1268 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1269 | + '/*]]>*/'); |
|
| 1270 | + } |
|
| 1271 | + if ($noscript) { |
|
| 1272 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1273 | + } |
|
| 1275 | 1274 | |
| 1276 | - return ($src or $script or $noscript) |
|
| 1277 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1278 | - : ''; |
|
| 1275 | + return ($src or $script or $noscript) |
|
| 1276 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1277 | + : ''; |
|
| 1279 | 1278 | } |
| 1280 | 1279 | |
| 1281 | 1280 | |
@@ -1310,7 +1309,7 @@ discard block |
||
| 1310 | 1309 | * Texte échappé |
| 1311 | 1310 | **/ |
| 1312 | 1311 | function texte_script(string $texte): string { |
| 1313 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1312 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1314 | 1313 | } |
| 1315 | 1314 | |
| 1316 | 1315 | |
@@ -1347,68 +1346,68 @@ discard block |
||
| 1347 | 1346 | * Liste des chemins, par ordre de priorité. |
| 1348 | 1347 | **/ |
| 1349 | 1348 | function _chemin($dir_path = null) { |
| 1350 | - static $path_base = null; |
|
| 1351 | - static $path_full = null; |
|
| 1352 | - if ($path_base == null) { |
|
| 1353 | - // Chemin standard depuis l'espace public |
|
| 1354 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1355 | - _DIR_RACINE . ':' . |
|
| 1356 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1357 | - _DIR_RACINE . 'prive/:' . |
|
| 1358 | - _DIR_RESTREINT; |
|
| 1359 | - // Ajouter squelettes/ |
|
| 1360 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1361 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1362 | - } |
|
| 1363 | - foreach (explode(':', $path) as $dir) { |
|
| 1364 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1365 | - $dir .= '/'; |
|
| 1366 | - } |
|
| 1367 | - $path_base[] = $dir; |
|
| 1368 | - } |
|
| 1369 | - $path_full = $path_base; |
|
| 1370 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1371 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1372 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1373 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1374 | - } |
|
| 1375 | - } |
|
| 1376 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1377 | - } |
|
| 1378 | - if ($dir_path === null) { |
|
| 1379 | - return $path_full; |
|
| 1380 | - } |
|
| 1381 | - |
|
| 1382 | - if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1383 | - $tete = ''; |
|
| 1384 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1385 | - $tete = array_shift($path_base); |
|
| 1386 | - } |
|
| 1387 | - $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1388 | - $dirs = array_reverse($dirs); |
|
| 1389 | - foreach ($dirs as $dir_path) { |
|
| 1390 | - if (substr($dir_path, -1) != '/') { |
|
| 1391 | - $dir_path .= '/'; |
|
| 1392 | - } |
|
| 1393 | - if (!in_array($dir_path, $path_base)) { |
|
| 1394 | - array_unshift($path_base, $dir_path); |
|
| 1395 | - } |
|
| 1396 | - } |
|
| 1397 | - if (strlen($tete)) { |
|
| 1398 | - array_unshift($path_base, $tete); |
|
| 1399 | - } |
|
| 1400 | - } |
|
| 1401 | - $path_full = $path_base; |
|
| 1402 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1403 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1404 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1405 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1406 | - } |
|
| 1407 | - } |
|
| 1408 | - |
|
| 1409 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1410 | - |
|
| 1411 | - return $path_full; |
|
| 1349 | + static $path_base = null; |
|
| 1350 | + static $path_full = null; |
|
| 1351 | + if ($path_base == null) { |
|
| 1352 | + // Chemin standard depuis l'espace public |
|
| 1353 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1354 | + _DIR_RACINE . ':' . |
|
| 1355 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1356 | + _DIR_RACINE . 'prive/:' . |
|
| 1357 | + _DIR_RESTREINT; |
|
| 1358 | + // Ajouter squelettes/ |
|
| 1359 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1360 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1361 | + } |
|
| 1362 | + foreach (explode(':', $path) as $dir) { |
|
| 1363 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1364 | + $dir .= '/'; |
|
| 1365 | + } |
|
| 1366 | + $path_base[] = $dir; |
|
| 1367 | + } |
|
| 1368 | + $path_full = $path_base; |
|
| 1369 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1370 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1371 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1372 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1373 | + } |
|
| 1374 | + } |
|
| 1375 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1376 | + } |
|
| 1377 | + if ($dir_path === null) { |
|
| 1378 | + return $path_full; |
|
| 1379 | + } |
|
| 1380 | + |
|
| 1381 | + if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1382 | + $tete = ''; |
|
| 1383 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1384 | + $tete = array_shift($path_base); |
|
| 1385 | + } |
|
| 1386 | + $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1387 | + $dirs = array_reverse($dirs); |
|
| 1388 | + foreach ($dirs as $dir_path) { |
|
| 1389 | + if (substr($dir_path, -1) != '/') { |
|
| 1390 | + $dir_path .= '/'; |
|
| 1391 | + } |
|
| 1392 | + if (!in_array($dir_path, $path_base)) { |
|
| 1393 | + array_unshift($path_base, $dir_path); |
|
| 1394 | + } |
|
| 1395 | + } |
|
| 1396 | + if (strlen($tete)) { |
|
| 1397 | + array_unshift($path_base, $tete); |
|
| 1398 | + } |
|
| 1399 | + } |
|
| 1400 | + $path_full = $path_base; |
|
| 1401 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1402 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1403 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1404 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1405 | + } |
|
| 1406 | + } |
|
| 1407 | + |
|
| 1408 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1409 | + |
|
| 1410 | + return $path_full; |
|
| 1412 | 1411 | } |
| 1413 | 1412 | |
| 1414 | 1413 | /** |
@@ -1421,78 +1420,78 @@ discard block |
||
| 1421 | 1420 | * @return array Liste de chemins |
| 1422 | 1421 | **/ |
| 1423 | 1422 | function creer_chemin() { |
| 1424 | - $path_a = _chemin(); |
|
| 1425 | - static $c = ''; |
|
| 1423 | + $path_a = _chemin(); |
|
| 1424 | + static $c = ''; |
|
| 1426 | 1425 | |
| 1427 | - // on calcule le chemin si le dossier skel a change |
|
| 1428 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1429 | - // assurer le non plantage lors de la montee de version : |
|
| 1430 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1431 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1432 | - } |
|
| 1426 | + // on calcule le chemin si le dossier skel a change |
|
| 1427 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1428 | + // assurer le non plantage lors de la montee de version : |
|
| 1429 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1430 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1431 | + } |
|
| 1433 | 1432 | |
| 1434 | - return $path_a; |
|
| 1433 | + return $path_a; |
|
| 1435 | 1434 | } |
| 1436 | 1435 | |
| 1437 | 1436 | |
| 1438 | 1437 | function lister_themes_prives() { |
| 1439 | - static $themes = null; |
|
| 1440 | - if (is_null($themes)) { |
|
| 1441 | - // si pas encore definie |
|
| 1442 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1443 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1444 | - } |
|
| 1445 | - $themes = [_SPIP_THEME_PRIVE]; |
|
| 1446 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1447 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1448 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1449 | - } else { |
|
| 1450 | - $prefs = []; |
|
| 1451 | - } |
|
| 1452 | - if (is_string($prefs)) { |
|
| 1453 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1454 | - } |
|
| 1455 | - if ( |
|
| 1456 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1457 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1458 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1459 | - ) { |
|
| 1460 | - array_unshift($themes, $theme); |
|
| 1461 | - } // placer le theme choisi en tete |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - return $themes; |
|
| 1438 | + static $themes = null; |
|
| 1439 | + if (is_null($themes)) { |
|
| 1440 | + // si pas encore definie |
|
| 1441 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1442 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1443 | + } |
|
| 1444 | + $themes = [_SPIP_THEME_PRIVE]; |
|
| 1445 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1446 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1447 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1448 | + } else { |
|
| 1449 | + $prefs = []; |
|
| 1450 | + } |
|
| 1451 | + if (is_string($prefs)) { |
|
| 1452 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1453 | + } |
|
| 1454 | + if ( |
|
| 1455 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1456 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1457 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1458 | + ) { |
|
| 1459 | + array_unshift($themes, $theme); |
|
| 1460 | + } // placer le theme choisi en tete |
|
| 1461 | + } |
|
| 1462 | + |
|
| 1463 | + return $themes; |
|
| 1465 | 1464 | } |
| 1466 | 1465 | |
| 1467 | 1466 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1468 | - static $themefiles = []; |
|
| 1469 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1470 | - return $themefiles["$subdir$file"]; |
|
| 1471 | - } |
|
| 1472 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1473 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1474 | - if ( |
|
| 1475 | - preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1476 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1477 | - and $f = find_in_theme("$file_svg_generique") |
|
| 1478 | - ) { |
|
| 1479 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1480 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1481 | - } |
|
| 1482 | - else { |
|
| 1483 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1484 | - } |
|
| 1485 | - } |
|
| 1486 | - |
|
| 1487 | - $themes = lister_themes_prives(); |
|
| 1488 | - foreach ($themes as $theme) { |
|
| 1489 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1490 | - return $themefiles["$subdir$file"] = $f; |
|
| 1491 | - } |
|
| 1492 | - } |
|
| 1493 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1494 | - |
|
| 1495 | - return $themefiles["$subdir$file"] = ''; |
|
| 1467 | + static $themefiles = []; |
|
| 1468 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1469 | + return $themefiles["$subdir$file"]; |
|
| 1470 | + } |
|
| 1471 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1472 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1473 | + if ( |
|
| 1474 | + preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1475 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1476 | + and $f = find_in_theme("$file_svg_generique") |
|
| 1477 | + ) { |
|
| 1478 | + if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1479 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1480 | + } |
|
| 1481 | + else { |
|
| 1482 | + return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1483 | + } |
|
| 1484 | + } |
|
| 1485 | + |
|
| 1486 | + $themes = lister_themes_prives(); |
|
| 1487 | + foreach ($themes as $theme) { |
|
| 1488 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1489 | + return $themefiles["$subdir$file"] = $f; |
|
| 1490 | + } |
|
| 1491 | + } |
|
| 1492 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1493 | + |
|
| 1494 | + return $themefiles["$subdir$file"] = ''; |
|
| 1496 | 1495 | } |
| 1497 | 1496 | |
| 1498 | 1497 | |
@@ -1516,31 +1515,31 @@ discard block |
||
| 1516 | 1515 | * sinon chaîne vide. |
| 1517 | 1516 | **/ |
| 1518 | 1517 | function chemin_image($icone) { |
| 1519 | - static $icone_renommer; |
|
| 1520 | - if ($p = strpos($icone, '?')) { |
|
| 1521 | - $icone = substr($icone, 0, $p); |
|
| 1522 | - } |
|
| 1523 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1524 | - if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1525 | - return $icone; |
|
| 1526 | - } |
|
| 1527 | - |
|
| 1528 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1529 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1530 | - return $f; |
|
| 1531 | - } |
|
| 1532 | - // sinon passer par le module de renommage |
|
| 1533 | - if (is_null($icone_renommer)) { |
|
| 1534 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1535 | - } |
|
| 1536 | - if ($icone_renommer) { |
|
| 1537 | - [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1538 | - if (file_exists($icone)) { |
|
| 1539 | - return $icone; |
|
| 1540 | - } |
|
| 1541 | - } |
|
| 1542 | - |
|
| 1543 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1518 | + static $icone_renommer; |
|
| 1519 | + if ($p = strpos($icone, '?')) { |
|
| 1520 | + $icone = substr($icone, 0, $p); |
|
| 1521 | + } |
|
| 1522 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1523 | + if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1524 | + return $icone; |
|
| 1525 | + } |
|
| 1526 | + |
|
| 1527 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1528 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1529 | + return $f; |
|
| 1530 | + } |
|
| 1531 | + // sinon passer par le module de renommage |
|
| 1532 | + if (is_null($icone_renommer)) { |
|
| 1533 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1534 | + } |
|
| 1535 | + if ($icone_renommer) { |
|
| 1536 | + [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1537 | + if (file_exists($icone)) { |
|
| 1538 | + return $icone; |
|
| 1539 | + } |
|
| 1540 | + } |
|
| 1541 | + |
|
| 1542 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1544 | 1543 | } |
| 1545 | 1544 | |
| 1546 | 1545 | // |
@@ -1578,128 +1577,128 @@ discard block |
||
| 1578 | 1577 | * - false : fichier introuvable |
| 1579 | 1578 | **/ |
| 1580 | 1579 | function find_in_path($file, $dirname = '', $include = false) { |
| 1581 | - static $dirs = []; |
|
| 1582 | - static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1583 | - static $c = ''; |
|
| 1584 | - |
|
| 1585 | - if (!$file and !strlen($file)) { |
|
| 1586 | - return false; |
|
| 1587 | - } |
|
| 1588 | - |
|
| 1589 | - // on calcule le chemin si le dossier skel a change |
|
| 1590 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1591 | - // assurer le non plantage lors de la montee de version : |
|
| 1592 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1593 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1597 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1598 | - return false; |
|
| 1599 | - } |
|
| 1600 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1601 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1602 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1603 | - } |
|
| 1604 | - |
|
| 1605 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1606 | - } |
|
| 1607 | - |
|
| 1608 | - $a = strrpos($file, '/'); |
|
| 1609 | - if ($a !== false) { |
|
| 1610 | - $dirname .= substr($file, 0, ++$a); |
|
| 1611 | - $file = substr($file, $a); |
|
| 1612 | - } |
|
| 1613 | - |
|
| 1614 | - foreach (creer_chemin() as $dir) { |
|
| 1615 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1616 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1617 | - } |
|
| 1618 | - if ($dirs[$a]) { |
|
| 1619 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1620 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1621 | - include_once _ROOT_CWD . $a; |
|
| 1622 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1623 | - } |
|
| 1624 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1625 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1626 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1627 | - return $a; |
|
| 1628 | - } |
|
| 1629 | - define('_SAUVER_CHEMIN', true); |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1633 | - } |
|
| 1634 | - } |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - if ($include) { |
|
| 1638 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1639 | - if ($include === 'required') { |
|
| 1640 | - echo '<pre>', |
|
| 1641 | - '<strong>Erreur Fatale</strong><br />'; |
|
| 1642 | - if (function_exists('debug_print_backtrace')) { |
|
| 1643 | - echo debug_print_backtrace(); |
|
| 1644 | - } |
|
| 1645 | - echo '</pre>'; |
|
| 1646 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1647 | - } |
|
| 1648 | - } |
|
| 1649 | - |
|
| 1650 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1651 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1652 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1653 | - return false; |
|
| 1654 | - } |
|
| 1655 | - define('_SAUVER_CHEMIN', true); |
|
| 1656 | - } |
|
| 1657 | - |
|
| 1658 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1580 | + static $dirs = []; |
|
| 1581 | + static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1582 | + static $c = ''; |
|
| 1583 | + |
|
| 1584 | + if (!$file and !strlen($file)) { |
|
| 1585 | + return false; |
|
| 1586 | + } |
|
| 1587 | + |
|
| 1588 | + // on calcule le chemin si le dossier skel a change |
|
| 1589 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1590 | + // assurer le non plantage lors de la montee de version : |
|
| 1591 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1592 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1593 | + } |
|
| 1594 | + |
|
| 1595 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1596 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1597 | + return false; |
|
| 1598 | + } |
|
| 1599 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1600 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1601 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1602 | + } |
|
| 1603 | + |
|
| 1604 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1605 | + } |
|
| 1606 | + |
|
| 1607 | + $a = strrpos($file, '/'); |
|
| 1608 | + if ($a !== false) { |
|
| 1609 | + $dirname .= substr($file, 0, ++$a); |
|
| 1610 | + $file = substr($file, $a); |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + foreach (creer_chemin() as $dir) { |
|
| 1614 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1615 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1616 | + } |
|
| 1617 | + if ($dirs[$a]) { |
|
| 1618 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1619 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1620 | + include_once _ROOT_CWD . $a; |
|
| 1621 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1622 | + } |
|
| 1623 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1624 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1625 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1626 | + return $a; |
|
| 1627 | + } |
|
| 1628 | + define('_SAUVER_CHEMIN', true); |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1632 | + } |
|
| 1633 | + } |
|
| 1634 | + } |
|
| 1635 | + |
|
| 1636 | + if ($include) { |
|
| 1637 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1638 | + if ($include === 'required') { |
|
| 1639 | + echo '<pre>', |
|
| 1640 | + '<strong>Erreur Fatale</strong><br />'; |
|
| 1641 | + if (function_exists('debug_print_backtrace')) { |
|
| 1642 | + echo debug_print_backtrace(); |
|
| 1643 | + } |
|
| 1644 | + echo '</pre>'; |
|
| 1645 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1646 | + } |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1650 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1651 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1652 | + return false; |
|
| 1653 | + } |
|
| 1654 | + define('_SAUVER_CHEMIN', true); |
|
| 1655 | + } |
|
| 1656 | + |
|
| 1657 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1659 | 1658 | } |
| 1660 | 1659 | |
| 1661 | 1660 | function clear_path_cache() { |
| 1662 | - $GLOBALS['path_files'] = []; |
|
| 1663 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1661 | + $GLOBALS['path_files'] = []; |
|
| 1662 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1664 | 1663 | } |
| 1665 | 1664 | |
| 1666 | 1665 | function load_path_cache() { |
| 1667 | - // charger le path des plugins |
|
| 1668 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1669 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1670 | - } |
|
| 1671 | - $GLOBALS['path_files'] = []; |
|
| 1672 | - // si le visiteur est admin, |
|
| 1673 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1674 | - if ( |
|
| 1675 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1676 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1677 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1678 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1679 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1680 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1681 | - !_request('var_mode') |
|
| 1682 | - ) { |
|
| 1683 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1684 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1685 | - // mais si semble corrompu on relit avec un verrou |
|
| 1686 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1687 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1688 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1689 | - $GLOBALS['path_files'] = []; |
|
| 1690 | - } |
|
| 1691 | - } |
|
| 1692 | - } |
|
| 1693 | - } |
|
| 1666 | + // charger le path des plugins |
|
| 1667 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1668 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1669 | + } |
|
| 1670 | + $GLOBALS['path_files'] = []; |
|
| 1671 | + // si le visiteur est admin, |
|
| 1672 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1673 | + if ( |
|
| 1674 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1675 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1676 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1677 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1678 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1679 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1680 | + !_request('var_mode') |
|
| 1681 | + ) { |
|
| 1682 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1683 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1684 | + // mais si semble corrompu on relit avec un verrou |
|
| 1685 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1686 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1687 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1688 | + $GLOBALS['path_files'] = []; |
|
| 1689 | + } |
|
| 1690 | + } |
|
| 1691 | + } |
|
| 1692 | + } |
|
| 1694 | 1693 | } |
| 1695 | 1694 | |
| 1696 | 1695 | function save_path_cache() { |
| 1697 | - if ( |
|
| 1698 | - defined('_SAUVER_CHEMIN') |
|
| 1699 | - and _SAUVER_CHEMIN |
|
| 1700 | - ) { |
|
| 1701 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1702 | - } |
|
| 1696 | + if ( |
|
| 1697 | + defined('_SAUVER_CHEMIN') |
|
| 1698 | + and _SAUVER_CHEMIN |
|
| 1699 | + ) { |
|
| 1700 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1701 | + } |
|
| 1703 | 1702 | } |
| 1704 | 1703 | |
| 1705 | 1704 | |
@@ -1719,33 +1718,33 @@ discard block |
||
| 1719 | 1718 | * @return array |
| 1720 | 1719 | */ |
| 1721 | 1720 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1722 | - $liste_fichiers = []; |
|
| 1723 | - $maxfiles = 10000; |
|
| 1724 | - |
|
| 1725 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1726 | - // on a pas encore inclus flock.php |
|
| 1727 | - if (!function_exists('preg_files')) { |
|
| 1728 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1729 | - } |
|
| 1730 | - |
|
| 1731 | - // Parcourir le chemin |
|
| 1732 | - foreach (creer_chemin() as $d) { |
|
| 1733 | - $f = $d . $dir; |
|
| 1734 | - if (@is_dir($f)) { |
|
| 1735 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1736 | - foreach ($liste as $chemin) { |
|
| 1737 | - $nom = basename($chemin); |
|
| 1738 | - // ne prendre que les fichiers pas deja trouves |
|
| 1739 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1740 | - // les autres sont donc masques |
|
| 1741 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1742 | - $liste_fichiers[$nom] = $chemin; |
|
| 1743 | - } |
|
| 1744 | - } |
|
| 1745 | - } |
|
| 1746 | - } |
|
| 1747 | - |
|
| 1748 | - return $liste_fichiers; |
|
| 1721 | + $liste_fichiers = []; |
|
| 1722 | + $maxfiles = 10000; |
|
| 1723 | + |
|
| 1724 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1725 | + // on a pas encore inclus flock.php |
|
| 1726 | + if (!function_exists('preg_files')) { |
|
| 1727 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1728 | + } |
|
| 1729 | + |
|
| 1730 | + // Parcourir le chemin |
|
| 1731 | + foreach (creer_chemin() as $d) { |
|
| 1732 | + $f = $d . $dir; |
|
| 1733 | + if (@is_dir($f)) { |
|
| 1734 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1735 | + foreach ($liste as $chemin) { |
|
| 1736 | + $nom = basename($chemin); |
|
| 1737 | + // ne prendre que les fichiers pas deja trouves |
|
| 1738 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1739 | + // les autres sont donc masques |
|
| 1740 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1741 | + $liste_fichiers[$nom] = $chemin; |
|
| 1742 | + } |
|
| 1743 | + } |
|
| 1744 | + } |
|
| 1745 | + } |
|
| 1746 | + |
|
| 1747 | + return $liste_fichiers; |
|
| 1749 | 1748 | } |
| 1750 | 1749 | |
| 1751 | 1750 | /** |
@@ -1757,17 +1756,17 @@ discard block |
||
| 1757 | 1756 | * @return bool |
| 1758 | 1757 | */ |
| 1759 | 1758 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1760 | - static $autsanscookie = ['install', 'base_repair']; |
|
| 1759 | + static $autsanscookie = ['install', 'base_repair']; |
|
| 1761 | 1760 | |
| 1762 | - if (in_array($nom, $autsanscookie)) { |
|
| 1763 | - if (test_espace_prive()) { |
|
| 1764 | - include_spip('base/connect_sql'); |
|
| 1765 | - if (!$strict or !spip_connect()) { |
|
| 1766 | - return true; |
|
| 1767 | - } |
|
| 1768 | - } |
|
| 1769 | - } |
|
| 1770 | - return false; |
|
| 1761 | + if (in_array($nom, $autsanscookie)) { |
|
| 1762 | + if (test_espace_prive()) { |
|
| 1763 | + include_spip('base/connect_sql'); |
|
| 1764 | + if (!$strict or !spip_connect()) { |
|
| 1765 | + return true; |
|
| 1766 | + } |
|
| 1767 | + } |
|
| 1768 | + } |
|
| 1769 | + return false; |
|
| 1771 | 1770 | } |
| 1772 | 1771 | |
| 1773 | 1772 | /** |
@@ -1777,60 +1776,60 @@ discard block |
||
| 1777 | 1776 | * @return string |
| 1778 | 1777 | */ |
| 1779 | 1778 | function charger_fonction_url(string $quoi, string $type = '') { |
| 1780 | - if ($type === 'defaut') { |
|
| 1781 | - $objet = objet_type($quoi); |
|
| 1782 | - if ( |
|
| 1783 | - $f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1784 | - // deprecated |
|
| 1785 | - or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1786 | - ) { |
|
| 1787 | - return $f; |
|
| 1788 | - } |
|
| 1789 | - return ''; |
|
| 1790 | - } |
|
| 1791 | - |
|
| 1792 | - $url_type = $type; |
|
| 1793 | - if (!$url_type) { |
|
| 1794 | - $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1795 | - } |
|
| 1796 | - |
|
| 1797 | - // inclure le module d'url |
|
| 1798 | - include_spip('urls/' . $url_type); |
|
| 1799 | - |
|
| 1800 | - switch ($quoi) { |
|
| 1801 | - case 'page': |
|
| 1802 | - if ( |
|
| 1803 | - function_exists($f = "urls_{$url_type}_generer_url_page") |
|
| 1804 | - or function_exists($f .= '_dist') |
|
| 1805 | - // ou une fonction custom utilisateur independante du type d'url |
|
| 1806 | - or function_exists($f = 'generer_url_page') |
|
| 1807 | - or function_exists($f .= '_dist') |
|
| 1808 | - ) { |
|
| 1809 | - return $f; |
|
| 1810 | - } |
|
| 1811 | - // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 1812 | - return ''; |
|
| 1813 | - case 'objet': |
|
| 1814 | - case 'decoder': |
|
| 1815 | - default: |
|
| 1816 | - $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 1817 | - if ( |
|
| 1818 | - function_exists($f = "urls_{$url_type}_{$fquoi}") |
|
| 1819 | - or function_exists($f .= '_dist') |
|
| 1820 | - ) { |
|
| 1821 | - return $f; |
|
| 1822 | - } |
|
| 1823 | - // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 1824 | - // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 1825 | - if ($f = charger_fonction($url_type, 'urls', true)) { |
|
| 1826 | - return $f; |
|
| 1827 | - } |
|
| 1828 | - // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement |
|
| 1829 | - if (!$type and $url_type !== 'page') { |
|
| 1830 | - return charger_fonction_url($quoi, 'page'); |
|
| 1831 | - } |
|
| 1832 | - return ''; |
|
| 1833 | - } |
|
| 1779 | + if ($type === 'defaut') { |
|
| 1780 | + $objet = objet_type($quoi); |
|
| 1781 | + if ( |
|
| 1782 | + $f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1783 | + // deprecated |
|
| 1784 | + or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1785 | + ) { |
|
| 1786 | + return $f; |
|
| 1787 | + } |
|
| 1788 | + return ''; |
|
| 1789 | + } |
|
| 1790 | + |
|
| 1791 | + $url_type = $type; |
|
| 1792 | + if (!$url_type) { |
|
| 1793 | + $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1794 | + } |
|
| 1795 | + |
|
| 1796 | + // inclure le module d'url |
|
| 1797 | + include_spip('urls/' . $url_type); |
|
| 1798 | + |
|
| 1799 | + switch ($quoi) { |
|
| 1800 | + case 'page': |
|
| 1801 | + if ( |
|
| 1802 | + function_exists($f = "urls_{$url_type}_generer_url_page") |
|
| 1803 | + or function_exists($f .= '_dist') |
|
| 1804 | + // ou une fonction custom utilisateur independante du type d'url |
|
| 1805 | + or function_exists($f = 'generer_url_page') |
|
| 1806 | + or function_exists($f .= '_dist') |
|
| 1807 | + ) { |
|
| 1808 | + return $f; |
|
| 1809 | + } |
|
| 1810 | + // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 1811 | + return ''; |
|
| 1812 | + case 'objet': |
|
| 1813 | + case 'decoder': |
|
| 1814 | + default: |
|
| 1815 | + $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 1816 | + if ( |
|
| 1817 | + function_exists($f = "urls_{$url_type}_{$fquoi}") |
|
| 1818 | + or function_exists($f .= '_dist') |
|
| 1819 | + ) { |
|
| 1820 | + return $f; |
|
| 1821 | + } |
|
| 1822 | + // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 1823 | + // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 1824 | + if ($f = charger_fonction($url_type, 'urls', true)) { |
|
| 1825 | + return $f; |
|
| 1826 | + } |
|
| 1827 | + // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement |
|
| 1828 | + if (!$type and $url_type !== 'page') { |
|
| 1829 | + return charger_fonction_url($quoi, 'page'); |
|
| 1830 | + } |
|
| 1831 | + return ''; |
|
| 1832 | + } |
|
| 1834 | 1833 | } |
| 1835 | 1834 | |
| 1836 | 1835 | |
@@ -1859,48 +1858,48 @@ discard block |
||
| 1859 | 1858 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_spip_url et une fonction generer_spip_url_ecrire) |
| 1860 | 1859 | */ |
| 1861 | 1860 | function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string { |
| 1862 | - if ($public === null) { |
|
| 1863 | - $public = !test_espace_prive(); |
|
| 1864 | - } |
|
| 1865 | - $id = intval($id); |
|
| 1866 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1867 | - |
|
| 1868 | - if (!$public) { |
|
| 1869 | - if (!$entite) { |
|
| 1870 | - return ''; |
|
| 1871 | - } |
|
| 1872 | - if (!function_exists('generer_objet_url_ecrire')) { |
|
| 1873 | - include_spip('inc/urls'); |
|
| 1874 | - } |
|
| 1875 | - $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect); |
|
| 1876 | - } else { |
|
| 1877 | - $f = charger_fonction_url('objet', $type ?? ''); |
|
| 1878 | - |
|
| 1879 | - // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 1880 | - // @see charger_fonction_url |
|
| 1881 | - if (!$entite) { |
|
| 1882 | - return $f; |
|
| 1883 | - } |
|
| 1884 | - |
|
| 1885 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1886 | - // base distante |
|
| 1887 | - if ( |
|
| 1888 | - $connect |
|
| 1889 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1890 | - ) { |
|
| 1891 | - $f = $g; |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect); |
|
| 1895 | - } |
|
| 1896 | - if ($res) { |
|
| 1897 | - return $res; |
|
| 1898 | - } |
|
| 1899 | - |
|
| 1900 | - // On a ete gentil mais la .... |
|
| 1901 | - spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR); |
|
| 1902 | - |
|
| 1903 | - return ''; |
|
| 1861 | + if ($public === null) { |
|
| 1862 | + $public = !test_espace_prive(); |
|
| 1863 | + } |
|
| 1864 | + $id = intval($id); |
|
| 1865 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1866 | + |
|
| 1867 | + if (!$public) { |
|
| 1868 | + if (!$entite) { |
|
| 1869 | + return ''; |
|
| 1870 | + } |
|
| 1871 | + if (!function_exists('generer_objet_url_ecrire')) { |
|
| 1872 | + include_spip('inc/urls'); |
|
| 1873 | + } |
|
| 1874 | + $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect); |
|
| 1875 | + } else { |
|
| 1876 | + $f = charger_fonction_url('objet', $type ?? ''); |
|
| 1877 | + |
|
| 1878 | + // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 1879 | + // @see charger_fonction_url |
|
| 1880 | + if (!$entite) { |
|
| 1881 | + return $f; |
|
| 1882 | + } |
|
| 1883 | + |
|
| 1884 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1885 | + // base distante |
|
| 1886 | + if ( |
|
| 1887 | + $connect |
|
| 1888 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1889 | + ) { |
|
| 1890 | + $f = $g; |
|
| 1891 | + } |
|
| 1892 | + |
|
| 1893 | + $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect); |
|
| 1894 | + } |
|
| 1895 | + if ($res) { |
|
| 1896 | + return $res; |
|
| 1897 | + } |
|
| 1898 | + |
|
| 1899 | + // On a ete gentil mais la .... |
|
| 1900 | + spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR); |
|
| 1901 | + |
|
| 1902 | + return ''; |
|
| 1904 | 1903 | } |
| 1905 | 1904 | |
| 1906 | 1905 | /** |
@@ -1908,10 +1907,10 @@ discard block |
||
| 1908 | 1907 | * @see generer_objet_url |
| 1909 | 1908 | */ |
| 1910 | 1909 | function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1911 | - if ($public and is_string($public)) { |
|
| 1912 | - return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
|
| 1913 | - } |
|
| 1914 | - return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? ''); |
|
| 1910 | + if ($public and is_string($public)) { |
|
| 1911 | + return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
|
| 1912 | + } |
|
| 1913 | + return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? ''); |
|
| 1915 | 1914 | } |
| 1916 | 1915 | |
| 1917 | 1916 | /** |
@@ -1923,19 +1922,19 @@ discard block |
||
| 1923 | 1922 | * @return string |
| 1924 | 1923 | */ |
| 1925 | 1924 | function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string { |
| 1926 | - $id = intval($id); |
|
| 1927 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1928 | - $url = generer_url_ecrire($exec, $args); |
|
| 1929 | - if (intval($id)) { |
|
| 1930 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1931 | - } else { |
|
| 1932 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1933 | - } |
|
| 1934 | - if ($ancre) { |
|
| 1935 | - $url = ancre_url($url, $ancre); |
|
| 1936 | - } |
|
| 1925 | + $id = intval($id); |
|
| 1926 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1927 | + $url = generer_url_ecrire($exec, $args); |
|
| 1928 | + if (intval($id)) { |
|
| 1929 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1930 | + } else { |
|
| 1931 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1932 | + } |
|
| 1933 | + if ($ancre) { |
|
| 1934 | + $url = ancre_url($url, $ancre); |
|
| 1935 | + } |
|
| 1937 | 1936 | |
| 1938 | - return $url; |
|
| 1937 | + return $url; |
|
| 1939 | 1938 | } |
| 1940 | 1939 | |
| 1941 | 1940 | /** |
@@ -1943,18 +1942,18 @@ discard block |
||
| 1943 | 1942 | * @see generer_objet_url_ecrire_edit |
| 1944 | 1943 | */ |
| 1945 | 1944 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 1946 | - return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
|
| 1945 | + return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
|
| 1947 | 1946 | } |
| 1948 | 1947 | |
| 1949 | 1948 | |
| 1950 | 1949 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1951 | - include_spip('base/connect_sql'); |
|
| 1952 | - $id_type = id_table_objet($entite, $public); |
|
| 1950 | + include_spip('base/connect_sql'); |
|
| 1951 | + $id_type = id_table_objet($entite, $public); |
|
| 1953 | 1952 | |
| 1954 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1955 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1956 | - . (!$args ? '' : "&$args") |
|
| 1957 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1953 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1954 | + . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1955 | + . (!$args ? '' : "&$args") |
|
| 1956 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1958 | 1957 | } |
| 1959 | 1958 | |
| 1960 | 1959 | |
@@ -1965,18 +1964,18 @@ discard block |
||
| 1965 | 1964 | * @return string |
| 1966 | 1965 | */ |
| 1967 | 1966 | function urlencode_1738($url) { |
| 1968 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1969 | - $uri = ''; |
|
| 1970 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1971 | - if (ord($a = $url[$i]) > 127) { |
|
| 1972 | - $a = rawurlencode($a); |
|
| 1973 | - } |
|
| 1974 | - $uri .= $a; |
|
| 1975 | - } |
|
| 1976 | - $url = $uri; |
|
| 1977 | - } |
|
| 1967 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1968 | + $uri = ''; |
|
| 1969 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1970 | + if (ord($a = $url[$i]) > 127) { |
|
| 1971 | + $a = rawurlencode($a); |
|
| 1972 | + } |
|
| 1973 | + $uri .= $a; |
|
| 1974 | + } |
|
| 1975 | + $url = $uri; |
|
| 1976 | + } |
|
| 1978 | 1977 | |
| 1979 | - return quote_amp($url); |
|
| 1978 | + return quote_amp($url); |
|
| 1980 | 1979 | } |
| 1981 | 1980 | |
| 1982 | 1981 | /** |
@@ -1992,14 +1991,14 @@ discard block |
||
| 1992 | 1991 | * @return string |
| 1993 | 1992 | */ |
| 1994 | 1993 | function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string { |
| 1995 | - $id = intval($id); |
|
| 1996 | - $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect); |
|
| 1997 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1998 | - include_spip('inc/filtres_mini'); |
|
| 1999 | - $h = url_absolue($h); |
|
| 2000 | - } |
|
| 1994 | + $id = intval($id); |
|
| 1995 | + $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect); |
|
| 1996 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1997 | + include_spip('inc/filtres_mini'); |
|
| 1998 | + $h = url_absolue($h); |
|
| 1999 | + } |
|
| 2001 | 2000 | |
| 2002 | - return $h; |
|
| 2001 | + return $h; |
|
| 2003 | 2002 | } |
| 2004 | 2003 | |
| 2005 | 2004 | /** |
@@ -2007,7 +2006,7 @@ discard block |
||
| 2007 | 2006 | * @see generer_objet_url_absolue |
| 2008 | 2007 | */ |
| 2009 | 2008 | function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) { |
| 2010 | - return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect); |
|
| 2009 | + return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect); |
|
| 2011 | 2010 | } |
| 2012 | 2011 | |
| 2013 | 2012 | |
@@ -2023,11 +2022,11 @@ discard block |
||
| 2023 | 2022 | * true si la valeur est considérée active ; false sinon. |
| 2024 | 2023 | **/ |
| 2025 | 2024 | function test_valeur_serveur($truc) { |
| 2026 | - if (!$truc) { |
|
| 2027 | - return false; |
|
| 2028 | - } |
|
| 2025 | + if (!$truc) { |
|
| 2026 | + return false; |
|
| 2027 | + } |
|
| 2029 | 2028 | |
| 2030 | - return (strtolower($truc) !== 'off'); |
|
| 2029 | + return (strtolower($truc) !== 'off'); |
|
| 2031 | 2030 | } |
| 2032 | 2031 | |
| 2033 | 2032 | // |
@@ -2055,82 +2054,82 @@ discard block |
||
| 2055 | 2054 | */ |
| 2056 | 2055 | function url_de_base($profondeur = null) { |
| 2057 | 2056 | |
| 2058 | - static $url = []; |
|
| 2059 | - if (is_array($profondeur)) { |
|
| 2060 | - return $url = $profondeur; |
|
| 2061 | - } |
|
| 2062 | - if ($profondeur === false) { |
|
| 2063 | - return $url; |
|
| 2064 | - } |
|
| 2065 | - |
|
| 2066 | - if (is_null($profondeur)) { |
|
| 2067 | - $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 2068 | - } |
|
| 2069 | - |
|
| 2070 | - if (isset($url[$profondeur])) { |
|
| 2071 | - return $url[$profondeur]; |
|
| 2072 | - } |
|
| 2073 | - |
|
| 2074 | - $http = 'http'; |
|
| 2075 | - |
|
| 2076 | - if ( |
|
| 2077 | - isset($_SERVER['SCRIPT_URI']) |
|
| 2078 | - and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 2079 | - ) { |
|
| 2080 | - $http = 'https'; |
|
| 2081 | - } elseif ( |
|
| 2082 | - isset($_SERVER['HTTPS']) |
|
| 2083 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 2084 | - ) { |
|
| 2085 | - $http = 'https'; |
|
| 2086 | - } |
|
| 2087 | - |
|
| 2088 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 2089 | - $host = $_SERVER['HTTP_HOST'] ?? null; |
|
| 2090 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 2091 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2092 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 2093 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 2094 | - $http = $scheme; |
|
| 2095 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 2096 | - } |
|
| 2097 | - } |
|
| 2098 | - if ( |
|
| 2099 | - isset($_SERVER['SERVER_PORT']) |
|
| 2100 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 2101 | - and strpos($host, ':') == false |
|
| 2102 | - ) { |
|
| 2103 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2104 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 2105 | - } |
|
| 2106 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2107 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2108 | - } |
|
| 2109 | - if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2110 | - $host .= ":$port"; |
|
| 2111 | - } |
|
| 2112 | - if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2113 | - $host .= ":$port"; |
|
| 2114 | - } |
|
| 2115 | - } |
|
| 2116 | - |
|
| 2117 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 2118 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2119 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2120 | - } else { |
|
| 2121 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2122 | - if ( |
|
| 2123 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2124 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2125 | - ) { |
|
| 2126 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2127 | - } |
|
| 2128 | - } |
|
| 2129 | - } |
|
| 2130 | - |
|
| 2131 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2132 | - |
|
| 2133 | - return $url[$profondeur]; |
|
| 2057 | + static $url = []; |
|
| 2058 | + if (is_array($profondeur)) { |
|
| 2059 | + return $url = $profondeur; |
|
| 2060 | + } |
|
| 2061 | + if ($profondeur === false) { |
|
| 2062 | + return $url; |
|
| 2063 | + } |
|
| 2064 | + |
|
| 2065 | + if (is_null($profondeur)) { |
|
| 2066 | + $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 2067 | + } |
|
| 2068 | + |
|
| 2069 | + if (isset($url[$profondeur])) { |
|
| 2070 | + return $url[$profondeur]; |
|
| 2071 | + } |
|
| 2072 | + |
|
| 2073 | + $http = 'http'; |
|
| 2074 | + |
|
| 2075 | + if ( |
|
| 2076 | + isset($_SERVER['SCRIPT_URI']) |
|
| 2077 | + and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 2078 | + ) { |
|
| 2079 | + $http = 'https'; |
|
| 2080 | + } elseif ( |
|
| 2081 | + isset($_SERVER['HTTPS']) |
|
| 2082 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 2083 | + ) { |
|
| 2084 | + $http = 'https'; |
|
| 2085 | + } |
|
| 2086 | + |
|
| 2087 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 2088 | + $host = $_SERVER['HTTP_HOST'] ?? null; |
|
| 2089 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 2090 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2091 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 2092 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 2093 | + $http = $scheme; |
|
| 2094 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 2095 | + } |
|
| 2096 | + } |
|
| 2097 | + if ( |
|
| 2098 | + isset($_SERVER['SERVER_PORT']) |
|
| 2099 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 2100 | + and strpos($host, ':') == false |
|
| 2101 | + ) { |
|
| 2102 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2103 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 2104 | + } |
|
| 2105 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2106 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2107 | + } |
|
| 2108 | + if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2109 | + $host .= ":$port"; |
|
| 2110 | + } |
|
| 2111 | + if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2112 | + $host .= ":$port"; |
|
| 2113 | + } |
|
| 2114 | + } |
|
| 2115 | + |
|
| 2116 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 2117 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2118 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2119 | + } else { |
|
| 2120 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2121 | + if ( |
|
| 2122 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2123 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2124 | + ) { |
|
| 2125 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2126 | + } |
|
| 2127 | + } |
|
| 2128 | + } |
|
| 2129 | + |
|
| 2130 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2131 | + |
|
| 2132 | + return $url[$profondeur]; |
|
| 2134 | 2133 | } |
| 2135 | 2134 | |
| 2136 | 2135 | /** |
@@ -2143,26 +2142,26 @@ discard block |
||
| 2143 | 2142 | * @return string |
| 2144 | 2143 | */ |
| 2145 | 2144 | function url_de_($http, $host, $request, $prof = 0) { |
| 2146 | - $prof = max($prof, 0); |
|
| 2145 | + $prof = max($prof, 0); |
|
| 2147 | 2146 | |
| 2148 | - $myself = ltrim($request, '/'); |
|
| 2149 | - # supprimer la chaine de GET |
|
| 2150 | - [$myself] = explode('?', $myself); |
|
| 2151 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2152 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2153 | - if (strpos($myself, '://') !== false) { |
|
| 2154 | - $myself = explode('://', $myself); |
|
| 2155 | - array_shift($myself); |
|
| 2156 | - $myself = implode('://', $myself); |
|
| 2157 | - $myself = explode('/', $myself); |
|
| 2158 | - array_shift($myself); |
|
| 2159 | - $myself = implode('/', $myself); |
|
| 2160 | - } |
|
| 2161 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2147 | + $myself = ltrim($request, '/'); |
|
| 2148 | + # supprimer la chaine de GET |
|
| 2149 | + [$myself] = explode('?', $myself); |
|
| 2150 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2151 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2152 | + if (strpos($myself, '://') !== false) { |
|
| 2153 | + $myself = explode('://', $myself); |
|
| 2154 | + array_shift($myself); |
|
| 2155 | + $myself = implode('://', $myself); |
|
| 2156 | + $myself = explode('/', $myself); |
|
| 2157 | + array_shift($myself); |
|
| 2158 | + $myself = implode('/', $myself); |
|
| 2159 | + } |
|
| 2160 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2162 | 2161 | |
| 2163 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2162 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2164 | 2163 | |
| 2165 | - return $url; |
|
| 2164 | + return $url; |
|
| 2166 | 2165 | } |
| 2167 | 2166 | |
| 2168 | 2167 | |
@@ -2197,26 +2196,26 @@ discard block |
||
| 2197 | 2196 | * @return string URL |
| 2198 | 2197 | **/ |
| 2199 | 2198 | function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) { |
| 2200 | - $script ??= ''; |
|
| 2201 | - if (!$rel) { |
|
| 2202 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2203 | - } else { |
|
| 2204 | - if (!is_string($rel)) { |
|
| 2205 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2206 | - } |
|
| 2207 | - } |
|
| 2208 | - |
|
| 2209 | - [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2210 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2211 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2212 | - } elseif ($args) { |
|
| 2213 | - $args = "?$args"; |
|
| 2214 | - } |
|
| 2215 | - if ($ancre) { |
|
| 2216 | - $args .= "#$ancre"; |
|
| 2217 | - } |
|
| 2218 | - |
|
| 2219 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2199 | + $script ??= ''; |
|
| 2200 | + if (!$rel) { |
|
| 2201 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2202 | + } else { |
|
| 2203 | + if (!is_string($rel)) { |
|
| 2204 | + $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2205 | + } |
|
| 2206 | + } |
|
| 2207 | + |
|
| 2208 | + [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2209 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2210 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2211 | + } elseif ($args) { |
|
| 2212 | + $args = "?$args"; |
|
| 2213 | + } |
|
| 2214 | + if ($ancre) { |
|
| 2215 | + $args .= "#$ancre"; |
|
| 2216 | + } |
|
| 2217 | + |
|
| 2218 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2220 | 2219 | } |
| 2221 | 2220 | |
| 2222 | 2221 | // |
@@ -2238,15 +2237,15 @@ discard block |
||
| 2238 | 2237 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2239 | 2238 | **/ |
| 2240 | 2239 | function get_spip_script($default = '') { |
| 2241 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2242 | - return 'spip.php'; |
|
| 2243 | - } |
|
| 2244 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2245 | - if (_SPIP_SCRIPT) { |
|
| 2246 | - return _SPIP_SCRIPT; |
|
| 2247 | - } else { |
|
| 2248 | - return $default; |
|
| 2249 | - } |
|
| 2240 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2241 | + return 'spip.php'; |
|
| 2242 | + } |
|
| 2243 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2244 | + if (_SPIP_SCRIPT) { |
|
| 2245 | + return _SPIP_SCRIPT; |
|
| 2246 | + } else { |
|
| 2247 | + return $default; |
|
| 2248 | + } |
|
| 2250 | 2249 | } |
| 2251 | 2250 | |
| 2252 | 2251 | /** |
@@ -2275,45 +2274,45 @@ discard block |
||
| 2275 | 2274 | * @return string URL |
| 2276 | 2275 | **/ |
| 2277 | 2276 | function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') { |
| 2278 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2279 | - // standardiser vers la nouvelle API |
|
| 2280 | - |
|
| 2281 | - if (is_array($args)) { |
|
| 2282 | - $args = http_build_query($args); |
|
| 2283 | - } |
|
| 2284 | - |
|
| 2285 | - $url = ''; |
|
| 2286 | - if ($f = charger_fonction_url('page')) { |
|
| 2287 | - $url = $f($script, $args); |
|
| 2288 | - if ($url and !$rel) { |
|
| 2289 | - include_spip('inc/filtres_mini'); |
|
| 2290 | - $url = url_absolue($url); |
|
| 2291 | - } |
|
| 2292 | - } |
|
| 2293 | - if (!$url) { |
|
| 2294 | - if (!$action) { |
|
| 2295 | - $action = get_spip_script(); |
|
| 2296 | - } |
|
| 2297 | - if ($script) { |
|
| 2298 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2299 | - } |
|
| 2300 | - if ($args) { |
|
| 2301 | - $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2302 | - } |
|
| 2303 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2304 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2305 | - } |
|
| 2306 | - |
|
| 2307 | - if (!$no_entities) { |
|
| 2308 | - $url = quote_amp($url); |
|
| 2309 | - } |
|
| 2310 | - |
|
| 2311 | - return $url; |
|
| 2277 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2278 | + // standardiser vers la nouvelle API |
|
| 2279 | + |
|
| 2280 | + if (is_array($args)) { |
|
| 2281 | + $args = http_build_query($args); |
|
| 2282 | + } |
|
| 2283 | + |
|
| 2284 | + $url = ''; |
|
| 2285 | + if ($f = charger_fonction_url('page')) { |
|
| 2286 | + $url = $f($script, $args); |
|
| 2287 | + if ($url and !$rel) { |
|
| 2288 | + include_spip('inc/filtres_mini'); |
|
| 2289 | + $url = url_absolue($url); |
|
| 2290 | + } |
|
| 2291 | + } |
|
| 2292 | + if (!$url) { |
|
| 2293 | + if (!$action) { |
|
| 2294 | + $action = get_spip_script(); |
|
| 2295 | + } |
|
| 2296 | + if ($script) { |
|
| 2297 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2298 | + } |
|
| 2299 | + if ($args) { |
|
| 2300 | + $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2301 | + } |
|
| 2302 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2303 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2304 | + } |
|
| 2305 | + |
|
| 2306 | + if (!$no_entities) { |
|
| 2307 | + $url = quote_amp($url); |
|
| 2308 | + } |
|
| 2309 | + |
|
| 2310 | + return $url; |
|
| 2312 | 2311 | } |
| 2313 | 2312 | |
| 2314 | 2313 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2315 | 2314 | |
| 2316 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2315 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2317 | 2316 | } |
| 2318 | 2317 | |
| 2319 | 2318 | // Pour les formulaires en methode POST, |
@@ -2338,19 +2337,19 @@ discard block |
||
| 2338 | 2337 | **/ |
| 2339 | 2338 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2340 | 2339 | |
| 2341 | - $script1 = explode('&', $script); |
|
| 2342 | - $script1 = reset($script1); |
|
| 2340 | + $script1 = explode('&', $script); |
|
| 2341 | + $script1 = reset($script1); |
|
| 2343 | 2342 | |
| 2344 | - return "<form action='" |
|
| 2345 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2346 | - . "' " |
|
| 2347 | - . ($atts ?: " method='post'") |
|
| 2348 | - . "><div>\n" |
|
| 2349 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2350 | - . $corps |
|
| 2351 | - . (!$submit ? '' : |
|
| 2352 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2353 | - . "</div></form>\n"; |
|
| 2343 | + return "<form action='" |
|
| 2344 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2345 | + . "' " |
|
| 2346 | + . ($atts ?: " method='post'") |
|
| 2347 | + . "><div>\n" |
|
| 2348 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2349 | + . $corps |
|
| 2350 | + . (!$submit ? '' : |
|
| 2351 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2352 | + . "</div></form>\n"; |
|
| 2354 | 2353 | } |
| 2355 | 2354 | |
| 2356 | 2355 | /** |
@@ -2367,22 +2366,22 @@ discard block |
||
| 2367 | 2366 | * @return string |
| 2368 | 2367 | */ |
| 2369 | 2368 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2370 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2371 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2372 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2373 | - $h = (_DIR_RACINE and !$public) |
|
| 2374 | - ? generer_url_ecrire(_request('exec')) |
|
| 2375 | - : generer_url_public(); |
|
| 2369 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2370 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2371 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2372 | + $h = (_DIR_RACINE and !$public) |
|
| 2373 | + ? generer_url_ecrire(_request('exec')) |
|
| 2374 | + : generer_url_public(); |
|
| 2376 | 2375 | |
| 2377 | - return "\n<form action='" . |
|
| 2378 | - $h . |
|
| 2379 | - "'" . |
|
| 2380 | - $atts . |
|
| 2381 | - ">\n" . |
|
| 2382 | - '<div>' . |
|
| 2383 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2384 | - $corps . |
|
| 2385 | - '</div></form>'; |
|
| 2376 | + return "\n<form action='" . |
|
| 2377 | + $h . |
|
| 2378 | + "'" . |
|
| 2379 | + $atts . |
|
| 2380 | + ">\n" . |
|
| 2381 | + '<div>' . |
|
| 2382 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2383 | + $corps . |
|
| 2384 | + '</div></form>'; |
|
| 2386 | 2385 | } |
| 2387 | 2386 | |
| 2388 | 2387 | /** |
@@ -2401,22 +2400,22 @@ discard block |
||
| 2401 | 2400 | * URL |
| 2402 | 2401 | */ |
| 2403 | 2402 | function generer_url_action($script, $args = '', $no_entities = false, $public = false) { |
| 2404 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2405 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2406 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2407 | - $url = (_DIR_RACINE and !$public) |
|
| 2408 | - ? generer_url_ecrire(_request('exec')) |
|
| 2409 | - : generer_url_public('', '', false, false); |
|
| 2410 | - $url = parametre_url($url, 'action', $script); |
|
| 2411 | - if ($args) { |
|
| 2412 | - $url .= quote_amp('&' . $args); |
|
| 2413 | - } |
|
| 2403 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2404 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2405 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2406 | + $url = (_DIR_RACINE and !$public) |
|
| 2407 | + ? generer_url_ecrire(_request('exec')) |
|
| 2408 | + : generer_url_public('', '', false, false); |
|
| 2409 | + $url = parametre_url($url, 'action', $script); |
|
| 2410 | + if ($args) { |
|
| 2411 | + $url .= quote_amp('&' . $args); |
|
| 2412 | + } |
|
| 2414 | 2413 | |
| 2415 | - if ($no_entities) { |
|
| 2416 | - $url = str_replace('&', '&', $url); |
|
| 2417 | - } |
|
| 2414 | + if ($no_entities) { |
|
| 2415 | + $url = str_replace('&', '&', $url); |
|
| 2416 | + } |
|
| 2418 | 2417 | |
| 2419 | - return $url; |
|
| 2418 | + return $url; |
|
| 2420 | 2419 | } |
| 2421 | 2420 | |
| 2422 | 2421 | |
@@ -2435,23 +2434,23 @@ discard block |
||
| 2435 | 2434 | * URL |
| 2436 | 2435 | */ |
| 2437 | 2436 | function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) { |
| 2438 | - if (is_null($public)) { |
|
| 2439 | - $public = (_DIR_RACINE ? false : ''); |
|
| 2440 | - } |
|
| 2441 | - if (substr($script, -4) !== '.api') { |
|
| 2442 | - $script .= '.api'; |
|
| 2443 | - } |
|
| 2444 | - $url = |
|
| 2445 | - (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
|
| 2446 | - . $script . '/' |
|
| 2447 | - . ($path ? trim($path, '/') : '') |
|
| 2448 | - . ($args ? '?' . quote_amp($args) : ''); |
|
| 2437 | + if (is_null($public)) { |
|
| 2438 | + $public = (_DIR_RACINE ? false : ''); |
|
| 2439 | + } |
|
| 2440 | + if (substr($script, -4) !== '.api') { |
|
| 2441 | + $script .= '.api'; |
|
| 2442 | + } |
|
| 2443 | + $url = |
|
| 2444 | + (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
|
| 2445 | + . $script . '/' |
|
| 2446 | + . ($path ? trim($path, '/') : '') |
|
| 2447 | + . ($args ? '?' . quote_amp($args) : ''); |
|
| 2449 | 2448 | |
| 2450 | - if ($no_entities) { |
|
| 2451 | - $url = str_replace('&', '&', $url); |
|
| 2452 | - } |
|
| 2449 | + if ($no_entities) { |
|
| 2450 | + $url = str_replace('&', '&', $url); |
|
| 2451 | + } |
|
| 2453 | 2452 | |
| 2454 | - return $url; |
|
| 2453 | + return $url; |
|
| 2455 | 2454 | } |
| 2456 | 2455 | |
| 2457 | 2456 | |
@@ -2464,8 +2463,8 @@ discard block |
||
| 2464 | 2463 | * @param string $ta Répertoire temporaire accessible |
| 2465 | 2464 | */ |
| 2466 | 2465 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2467 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2468 | - spip_initialisation_suite(); |
|
| 2466 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2467 | + spip_initialisation_suite(); |
|
| 2469 | 2468 | } |
| 2470 | 2469 | |
| 2471 | 2470 | /** |
@@ -2485,322 +2484,322 @@ discard block |
||
| 2485 | 2484 | * @param string $ta Répertoire temporaire accessible |
| 2486 | 2485 | */ |
| 2487 | 2486 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2488 | - static $too_late = 0; |
|
| 2489 | - if ($too_late++) { |
|
| 2490 | - return; |
|
| 2491 | - } |
|
| 2492 | - |
|
| 2493 | - // Declaration des repertoires |
|
| 2494 | - |
|
| 2495 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2496 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2497 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2498 | - } |
|
| 2499 | - |
|
| 2500 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2501 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2502 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2503 | - } |
|
| 2504 | - |
|
| 2505 | - // le nom du repertoire des librairies |
|
| 2506 | - if (!defined('_DIR_LIB')) { |
|
| 2507 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2508 | - } |
|
| 2509 | - |
|
| 2510 | - if (!defined('_DIR_IMG')) { |
|
| 2511 | - define('_DIR_IMG', $pa); |
|
| 2512 | - } |
|
| 2513 | - if (!defined('_DIR_LOGOS')) { |
|
| 2514 | - define('_DIR_LOGOS', $pa); |
|
| 2515 | - } |
|
| 2516 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2517 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2518 | - } |
|
| 2519 | - |
|
| 2520 | - if (!defined('_DIR_DUMP')) { |
|
| 2521 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2522 | - } |
|
| 2523 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2524 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2525 | - } |
|
| 2526 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2527 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2528 | - } |
|
| 2529 | - if (!defined('_DIR_CACHE')) { |
|
| 2530 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2531 | - } |
|
| 2532 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2533 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2534 | - } |
|
| 2535 | - if (!defined('_DIR_SKELS')) { |
|
| 2536 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2537 | - } |
|
| 2538 | - if (!defined('_DIR_AIDE')) { |
|
| 2539 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2540 | - } |
|
| 2541 | - if (!defined('_DIR_TMP')) { |
|
| 2542 | - define('_DIR_TMP', $ti); |
|
| 2543 | - } |
|
| 2544 | - |
|
| 2545 | - if (!defined('_DIR_VAR')) { |
|
| 2546 | - define('_DIR_VAR', $ta); |
|
| 2547 | - } |
|
| 2548 | - |
|
| 2549 | - if (!defined('_DIR_ETC')) { |
|
| 2550 | - define('_DIR_ETC', $pi); |
|
| 2551 | - } |
|
| 2552 | - if (!defined('_DIR_CONNECT')) { |
|
| 2553 | - define('_DIR_CONNECT', $pi); |
|
| 2554 | - } |
|
| 2555 | - if (!defined('_DIR_CHMOD')) { |
|
| 2556 | - define('_DIR_CHMOD', $pi); |
|
| 2557 | - } |
|
| 2558 | - |
|
| 2559 | - if (!isset($GLOBALS['test_dirs'])) { |
|
| 2560 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2561 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2562 | - $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2563 | - } |
|
| 2564 | - |
|
| 2565 | - // Declaration des fichiers |
|
| 2566 | - |
|
| 2567 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2568 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2569 | - } |
|
| 2570 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2571 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2572 | - } |
|
| 2573 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2574 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2575 | - } |
|
| 2576 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2577 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2578 | - } |
|
| 2579 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2580 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2581 | - } |
|
| 2582 | - |
|
| 2583 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2584 | - if (!defined('_FILE_META')) { |
|
| 2585 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2586 | - } |
|
| 2587 | - if (!defined('_DIR_LOG')) { |
|
| 2588 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2589 | - } |
|
| 2590 | - if (!defined('_FILE_LOG')) { |
|
| 2591 | - define('_FILE_LOG', 'spip'); |
|
| 2592 | - } |
|
| 2593 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2594 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2595 | - } |
|
| 2596 | - |
|
| 2597 | - // Le fichier de connexion a la base de donnees |
|
| 2598 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2599 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2600 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2601 | - } |
|
| 2602 | - if (!defined('_FILE_CONNECT')) { |
|
| 2603 | - define( |
|
| 2604 | - '_FILE_CONNECT', |
|
| 2605 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2606 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2607 | - : false)) |
|
| 2608 | - ); |
|
| 2609 | - } |
|
| 2610 | - |
|
| 2611 | - // Le fichier de reglages des droits |
|
| 2612 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2613 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2614 | - } |
|
| 2615 | - if (!defined('_FILE_CHMOD')) { |
|
| 2616 | - define( |
|
| 2617 | - '_FILE_CHMOD', |
|
| 2618 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2619 | - : false) |
|
| 2620 | - ); |
|
| 2621 | - } |
|
| 2622 | - |
|
| 2623 | - if (!defined('_FILE_LDAP')) { |
|
| 2624 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2625 | - } |
|
| 2626 | - |
|
| 2627 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2628 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2629 | - } |
|
| 2630 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2631 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2632 | - } |
|
| 2633 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2634 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2635 | - } |
|
| 2636 | - |
|
| 2637 | - // Definition des droits d'acces en ecriture |
|
| 2638 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2639 | - include_once _FILE_CHMOD; |
|
| 2640 | - } |
|
| 2641 | - |
|
| 2642 | - // Se mefier des fichiers mal remplis! |
|
| 2643 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2644 | - define('_SPIP_CHMOD', 0777); |
|
| 2645 | - } |
|
| 2646 | - |
|
| 2647 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2648 | - /** Le charset par défaut lors de l'installation */ |
|
| 2649 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2650 | - } |
|
| 2651 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2652 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2653 | - } |
|
| 2654 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2655 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2656 | - } |
|
| 2657 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2658 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2659 | - } |
|
| 2660 | - |
|
| 2661 | - // La taille des Log |
|
| 2662 | - if (!defined('_MAX_LOG')) { |
|
| 2663 | - define('_MAX_LOG', 100); |
|
| 2664 | - } |
|
| 2665 | - |
|
| 2666 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2667 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2668 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2669 | - if (!defined('_OS_SERVEUR')) { |
|
| 2670 | - define('_OS_SERVEUR', 'windows'); |
|
| 2671 | - } |
|
| 2672 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2673 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2674 | - } // utiliser le flock php |
|
| 2675 | - } else { |
|
| 2676 | - if (!defined('_OS_SERVEUR')) { |
|
| 2677 | - define('_OS_SERVEUR', ''); |
|
| 2678 | - } |
|
| 2679 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2680 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2681 | - } // utiliser le flock php |
|
| 2682 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2683 | - } |
|
| 2684 | - |
|
| 2685 | - // Langue par defaut |
|
| 2686 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2687 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2688 | - } |
|
| 2689 | - |
|
| 2690 | - // |
|
| 2691 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2692 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2693 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2694 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2695 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2696 | - |
|
| 2697 | - // charger tout de suite le path et son cache |
|
| 2698 | - load_path_cache(); |
|
| 2699 | - |
|
| 2700 | - // *********** traiter les variables ************ |
|
| 2701 | - |
|
| 2702 | - // |
|
| 2703 | - // Securite |
|
| 2704 | - // |
|
| 2705 | - |
|
| 2706 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2707 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2708 | - die(); |
|
| 2709 | - } |
|
| 2710 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2711 | - spip_desinfecte($_GET); |
|
| 2712 | - spip_desinfecte($_POST); |
|
| 2713 | - spip_desinfecte($_COOKIE); |
|
| 2714 | - spip_desinfecte($_REQUEST); |
|
| 2715 | - |
|
| 2716 | - // appliquer le cookie_prefix |
|
| 2717 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2718 | - include_spip('inc/cookie'); |
|
| 2719 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2720 | - } |
|
| 2721 | - |
|
| 2722 | - // |
|
| 2723 | - // Capacites php (en fonction de la version) |
|
| 2724 | - // |
|
| 2725 | - $GLOBALS['flag_ob'] = (function_exists('ob_start') |
|
| 2726 | - && function_exists('ini_get') |
|
| 2727 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2728 | - $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name'); |
|
| 2729 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ''); |
|
| 2730 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2731 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2732 | - |
|
| 2733 | - |
|
| 2734 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2735 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2736 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2737 | - } else { |
|
| 2738 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2739 | - if ( |
|
| 2740 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2741 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2742 | - ) { |
|
| 2743 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2744 | - } |
|
| 2745 | - } |
|
| 2746 | - |
|
| 2747 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2748 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2749 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2750 | - } |
|
| 2751 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2752 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2753 | - } |
|
| 2754 | - |
|
| 2755 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2756 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2757 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2758 | - $inc_meta(); |
|
| 2759 | - |
|
| 2760 | - // nombre de repertoires depuis la racine |
|
| 2761 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2762 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2763 | - // le calcul est faux) |
|
| 2764 | - if (!_DIR_RESTREINT) { |
|
| 2765 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2766 | - } else { |
|
| 2767 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2768 | - $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2769 | - if ( |
|
| 2770 | - !$uri_ref |
|
| 2771 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2772 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2773 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2774 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2775 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2776 | - ) { |
|
| 2777 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2778 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2779 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2780 | - } else { |
|
| 2781 | - $uri_ref = ''; |
|
| 2782 | - } |
|
| 2783 | - } |
|
| 2784 | - if (!$uri or !$uri_ref) { |
|
| 2785 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2786 | - } else { |
|
| 2787 | - $GLOBALS['profondeur_url'] = max( |
|
| 2788 | - 0, |
|
| 2789 | - substr_count($uri[0], '/') |
|
| 2790 | - - substr_count($uri_ref, '/') |
|
| 2791 | - ); |
|
| 2792 | - } |
|
| 2793 | - } |
|
| 2794 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2795 | - if (_FILE_CONNECT) { |
|
| 2796 | - if ( |
|
| 2797 | - verifier_visiteur() == '0minirezo' |
|
| 2798 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2799 | - and !isset($_COOKIE['spip_admin']) |
|
| 2800 | - ) { |
|
| 2801 | - clear_path_cache(); |
|
| 2802 | - } |
|
| 2803 | - } |
|
| 2487 | + static $too_late = 0; |
|
| 2488 | + if ($too_late++) { |
|
| 2489 | + return; |
|
| 2490 | + } |
|
| 2491 | + |
|
| 2492 | + // Declaration des repertoires |
|
| 2493 | + |
|
| 2494 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2495 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2496 | + define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2497 | + } |
|
| 2498 | + |
|
| 2499 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2500 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2501 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2502 | + } |
|
| 2503 | + |
|
| 2504 | + // le nom du repertoire des librairies |
|
| 2505 | + if (!defined('_DIR_LIB')) { |
|
| 2506 | + define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2507 | + } |
|
| 2508 | + |
|
| 2509 | + if (!defined('_DIR_IMG')) { |
|
| 2510 | + define('_DIR_IMG', $pa); |
|
| 2511 | + } |
|
| 2512 | + if (!defined('_DIR_LOGOS')) { |
|
| 2513 | + define('_DIR_LOGOS', $pa); |
|
| 2514 | + } |
|
| 2515 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2516 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2517 | + } |
|
| 2518 | + |
|
| 2519 | + if (!defined('_DIR_DUMP')) { |
|
| 2520 | + define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2521 | + } |
|
| 2522 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2523 | + define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2524 | + } |
|
| 2525 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2526 | + define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2527 | + } |
|
| 2528 | + if (!defined('_DIR_CACHE')) { |
|
| 2529 | + define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2530 | + } |
|
| 2531 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2532 | + define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2533 | + } |
|
| 2534 | + if (!defined('_DIR_SKELS')) { |
|
| 2535 | + define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2536 | + } |
|
| 2537 | + if (!defined('_DIR_AIDE')) { |
|
| 2538 | + define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2539 | + } |
|
| 2540 | + if (!defined('_DIR_TMP')) { |
|
| 2541 | + define('_DIR_TMP', $ti); |
|
| 2542 | + } |
|
| 2543 | + |
|
| 2544 | + if (!defined('_DIR_VAR')) { |
|
| 2545 | + define('_DIR_VAR', $ta); |
|
| 2546 | + } |
|
| 2547 | + |
|
| 2548 | + if (!defined('_DIR_ETC')) { |
|
| 2549 | + define('_DIR_ETC', $pi); |
|
| 2550 | + } |
|
| 2551 | + if (!defined('_DIR_CONNECT')) { |
|
| 2552 | + define('_DIR_CONNECT', $pi); |
|
| 2553 | + } |
|
| 2554 | + if (!defined('_DIR_CHMOD')) { |
|
| 2555 | + define('_DIR_CHMOD', $pi); |
|
| 2556 | + } |
|
| 2557 | + |
|
| 2558 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 2559 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2560 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2561 | + $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2562 | + } |
|
| 2563 | + |
|
| 2564 | + // Declaration des fichiers |
|
| 2565 | + |
|
| 2566 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2567 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2568 | + } |
|
| 2569 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2570 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2571 | + } |
|
| 2572 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2573 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2574 | + } |
|
| 2575 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2576 | + define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2577 | + } |
|
| 2578 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2579 | + define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2580 | + } |
|
| 2581 | + |
|
| 2582 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2583 | + if (!defined('_FILE_META')) { |
|
| 2584 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2585 | + } |
|
| 2586 | + if (!defined('_DIR_LOG')) { |
|
| 2587 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2588 | + } |
|
| 2589 | + if (!defined('_FILE_LOG')) { |
|
| 2590 | + define('_FILE_LOG', 'spip'); |
|
| 2591 | + } |
|
| 2592 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2593 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2594 | + } |
|
| 2595 | + |
|
| 2596 | + // Le fichier de connexion a la base de donnees |
|
| 2597 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2598 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2599 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2600 | + } |
|
| 2601 | + if (!defined('_FILE_CONNECT')) { |
|
| 2602 | + define( |
|
| 2603 | + '_FILE_CONNECT', |
|
| 2604 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2605 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2606 | + : false)) |
|
| 2607 | + ); |
|
| 2608 | + } |
|
| 2609 | + |
|
| 2610 | + // Le fichier de reglages des droits |
|
| 2611 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2612 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2613 | + } |
|
| 2614 | + if (!defined('_FILE_CHMOD')) { |
|
| 2615 | + define( |
|
| 2616 | + '_FILE_CHMOD', |
|
| 2617 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2618 | + : false) |
|
| 2619 | + ); |
|
| 2620 | + } |
|
| 2621 | + |
|
| 2622 | + if (!defined('_FILE_LDAP')) { |
|
| 2623 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2624 | + } |
|
| 2625 | + |
|
| 2626 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2627 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2628 | + } |
|
| 2629 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2630 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2631 | + } |
|
| 2632 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2633 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2634 | + } |
|
| 2635 | + |
|
| 2636 | + // Definition des droits d'acces en ecriture |
|
| 2637 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2638 | + include_once _FILE_CHMOD; |
|
| 2639 | + } |
|
| 2640 | + |
|
| 2641 | + // Se mefier des fichiers mal remplis! |
|
| 2642 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2643 | + define('_SPIP_CHMOD', 0777); |
|
| 2644 | + } |
|
| 2645 | + |
|
| 2646 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2647 | + /** Le charset par défaut lors de l'installation */ |
|
| 2648 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2649 | + } |
|
| 2650 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2651 | + define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2652 | + } |
|
| 2653 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2654 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2655 | + } |
|
| 2656 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2657 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2658 | + } |
|
| 2659 | + |
|
| 2660 | + // La taille des Log |
|
| 2661 | + if (!defined('_MAX_LOG')) { |
|
| 2662 | + define('_MAX_LOG', 100); |
|
| 2663 | + } |
|
| 2664 | + |
|
| 2665 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2666 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2667 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2668 | + if (!defined('_OS_SERVEUR')) { |
|
| 2669 | + define('_OS_SERVEUR', 'windows'); |
|
| 2670 | + } |
|
| 2671 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2672 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2673 | + } // utiliser le flock php |
|
| 2674 | + } else { |
|
| 2675 | + if (!defined('_OS_SERVEUR')) { |
|
| 2676 | + define('_OS_SERVEUR', ''); |
|
| 2677 | + } |
|
| 2678 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2679 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2680 | + } // utiliser le flock php |
|
| 2681 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2682 | + } |
|
| 2683 | + |
|
| 2684 | + // Langue par defaut |
|
| 2685 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2686 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2687 | + } |
|
| 2688 | + |
|
| 2689 | + // |
|
| 2690 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2691 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2692 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2693 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2694 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2695 | + |
|
| 2696 | + // charger tout de suite le path et son cache |
|
| 2697 | + load_path_cache(); |
|
| 2698 | + |
|
| 2699 | + // *********** traiter les variables ************ |
|
| 2700 | + |
|
| 2701 | + // |
|
| 2702 | + // Securite |
|
| 2703 | + // |
|
| 2704 | + |
|
| 2705 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2706 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2707 | + die(); |
|
| 2708 | + } |
|
| 2709 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2710 | + spip_desinfecte($_GET); |
|
| 2711 | + spip_desinfecte($_POST); |
|
| 2712 | + spip_desinfecte($_COOKIE); |
|
| 2713 | + spip_desinfecte($_REQUEST); |
|
| 2714 | + |
|
| 2715 | + // appliquer le cookie_prefix |
|
| 2716 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2717 | + include_spip('inc/cookie'); |
|
| 2718 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2719 | + } |
|
| 2720 | + |
|
| 2721 | + // |
|
| 2722 | + // Capacites php (en fonction de la version) |
|
| 2723 | + // |
|
| 2724 | + $GLOBALS['flag_ob'] = (function_exists('ob_start') |
|
| 2725 | + && function_exists('ini_get') |
|
| 2726 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2727 | + $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name'); |
|
| 2728 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ''); |
|
| 2729 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2730 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2731 | + |
|
| 2732 | + |
|
| 2733 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2734 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2735 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2736 | + } else { |
|
| 2737 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2738 | + if ( |
|
| 2739 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2740 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2741 | + ) { |
|
| 2742 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2743 | + } |
|
| 2744 | + } |
|
| 2745 | + |
|
| 2746 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2747 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2748 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2749 | + } |
|
| 2750 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2751 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2752 | + } |
|
| 2753 | + |
|
| 2754 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2755 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2756 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2757 | + $inc_meta(); |
|
| 2758 | + |
|
| 2759 | + // nombre de repertoires depuis la racine |
|
| 2760 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2761 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2762 | + // le calcul est faux) |
|
| 2763 | + if (!_DIR_RESTREINT) { |
|
| 2764 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2765 | + } else { |
|
| 2766 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2767 | + $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2768 | + if ( |
|
| 2769 | + !$uri_ref |
|
| 2770 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2771 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2772 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2773 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2774 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2775 | + ) { |
|
| 2776 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2777 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2778 | + $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2779 | + } else { |
|
| 2780 | + $uri_ref = ''; |
|
| 2781 | + } |
|
| 2782 | + } |
|
| 2783 | + if (!$uri or !$uri_ref) { |
|
| 2784 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2785 | + } else { |
|
| 2786 | + $GLOBALS['profondeur_url'] = max( |
|
| 2787 | + 0, |
|
| 2788 | + substr_count($uri[0], '/') |
|
| 2789 | + - substr_count($uri_ref, '/') |
|
| 2790 | + ); |
|
| 2791 | + } |
|
| 2792 | + } |
|
| 2793 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2794 | + if (_FILE_CONNECT) { |
|
| 2795 | + if ( |
|
| 2796 | + verifier_visiteur() == '0minirezo' |
|
| 2797 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2798 | + and !isset($_COOKIE['spip_admin']) |
|
| 2799 | + ) { |
|
| 2800 | + clear_path_cache(); |
|
| 2801 | + } |
|
| 2802 | + } |
|
| 2804 | 2803 | } |
| 2805 | 2804 | |
| 2806 | 2805 | /** |
@@ -2809,157 +2808,157 @@ discard block |
||
| 2809 | 2808 | * |
| 2810 | 2809 | */ |
| 2811 | 2810 | function spip_initialisation_suite() { |
| 2812 | - static $too_late = 0; |
|
| 2813 | - if ($too_late++) { |
|
| 2814 | - return; |
|
| 2815 | - } |
|
| 2816 | - |
|
| 2817 | - // taille mini des login |
|
| 2818 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2819 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2820 | - } |
|
| 2821 | - |
|
| 2822 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2823 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2824 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2825 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2826 | - |
|
| 2827 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2828 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2829 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2830 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2831 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2832 | - |
|
| 2833 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2834 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2835 | - } |
|
| 2836 | - |
|
| 2837 | - // largeur maximale des images dans l'administration |
|
| 2838 | - if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2839 | - define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2840 | - } |
|
| 2841 | - |
|
| 2842 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2843 | - if (!defined('_IMG_QUALITE')) { |
|
| 2844 | - define('_IMG_QUALITE', 85); |
|
| 2845 | - } # valeur par defaut |
|
| 2846 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2847 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2848 | - } # surcharge pour la lib GD |
|
| 2849 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2850 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2851 | - } # surcharge pour imagick en ligne de commande |
|
| 2852 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2853 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2854 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2855 | - } # surcharge pour imagick en PHP |
|
| 2856 | - |
|
| 2857 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2858 | - define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2859 | - } // poids en octet |
|
| 2860 | - |
|
| 2861 | - // qq chaines standard |
|
| 2862 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2863 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2864 | - } |
|
| 2865 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2866 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2867 | - } |
|
| 2868 | - if (!defined('_SPIP_DUMP')) { |
|
| 2869 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2870 | - } |
|
| 2871 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2872 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2873 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2874 | - } |
|
| 2875 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2876 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2877 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2878 | - } |
|
| 2879 | - |
|
| 2880 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2881 | - /** |
|
| 2882 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2883 | - * @var int Nombre de caractères */ |
|
| 2884 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2885 | - } |
|
| 2886 | - |
|
| 2887 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2888 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2889 | - } |
|
| 2890 | - |
|
| 2891 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2892 | - /** Définit le doctype de l’espace privé */ |
|
| 2893 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2894 | - } |
|
| 2895 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2896 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2897 | - define( |
|
| 2898 | - '_DOCTYPE_AIDE', |
|
| 2899 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2900 | - ); |
|
| 2901 | - } |
|
| 2902 | - |
|
| 2903 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2904 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2905 | - * le script de l'espace public, alias index.php */ |
|
| 2906 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2907 | - } |
|
| 2908 | - if (!defined('_SPIP_PAGE')) { |
|
| 2909 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2910 | - define('_SPIP_PAGE', 'page'); |
|
| 2911 | - } |
|
| 2912 | - |
|
| 2913 | - // le script de l'espace prive |
|
| 2914 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2915 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2916 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2917 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2918 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2919 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2920 | - } else { |
|
| 2921 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2922 | - } |
|
| 2923 | - } |
|
| 2924 | - |
|
| 2925 | - |
|
| 2926 | - if (!defined('_SPIP_AJAX')) { |
|
| 2927 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2928 | - ? 1 |
|
| 2929 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2930 | - } |
|
| 2931 | - |
|
| 2932 | - // La requete est-elle en ajax ? |
|
| 2933 | - if (!defined('_AJAX')) { |
|
| 2934 | - define( |
|
| 2935 | - '_AJAX', |
|
| 2936 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2937 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2938 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2939 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2940 | - ) |
|
| 2941 | - and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2942 | - ); |
|
| 2943 | - } |
|
| 2944 | - |
|
| 2945 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2946 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2947 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2948 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2949 | - define( |
|
| 2950 | - '_IMG_GD_MAX_PIXELS', |
|
| 2951 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2952 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2953 | - : 0 |
|
| 2954 | - ); |
|
| 2955 | - } |
|
| 2956 | - |
|
| 2957 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2958 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2959 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2960 | - } |
|
| 2961 | - |
|
| 2962 | - init_var_mode(); |
|
| 2811 | + static $too_late = 0; |
|
| 2812 | + if ($too_late++) { |
|
| 2813 | + return; |
|
| 2814 | + } |
|
| 2815 | + |
|
| 2816 | + // taille mini des login |
|
| 2817 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2818 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2819 | + } |
|
| 2820 | + |
|
| 2821 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2822 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2823 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2824 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2825 | + |
|
| 2826 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2827 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2828 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2829 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2830 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2831 | + |
|
| 2832 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2833 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2834 | + } |
|
| 2835 | + |
|
| 2836 | + // largeur maximale des images dans l'administration |
|
| 2837 | + if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2838 | + define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2839 | + } |
|
| 2840 | + |
|
| 2841 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2842 | + if (!defined('_IMG_QUALITE')) { |
|
| 2843 | + define('_IMG_QUALITE', 85); |
|
| 2844 | + } # valeur par defaut |
|
| 2845 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2846 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2847 | + } # surcharge pour la lib GD |
|
| 2848 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2849 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2850 | + } # surcharge pour imagick en ligne de commande |
|
| 2851 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2852 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2853 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2854 | + } # surcharge pour imagick en PHP |
|
| 2855 | + |
|
| 2856 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2857 | + define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2858 | + } // poids en octet |
|
| 2859 | + |
|
| 2860 | + // qq chaines standard |
|
| 2861 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2862 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2863 | + } |
|
| 2864 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2865 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2866 | + } |
|
| 2867 | + if (!defined('_SPIP_DUMP')) { |
|
| 2868 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2869 | + } |
|
| 2870 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2871 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2872 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2873 | + } |
|
| 2874 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2875 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2876 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2877 | + } |
|
| 2878 | + |
|
| 2879 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2880 | + /** |
|
| 2881 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2882 | + * @var int Nombre de caractères */ |
|
| 2883 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2884 | + } |
|
| 2885 | + |
|
| 2886 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2887 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2888 | + } |
|
| 2889 | + |
|
| 2890 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2891 | + /** Définit le doctype de l’espace privé */ |
|
| 2892 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2893 | + } |
|
| 2894 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2895 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2896 | + define( |
|
| 2897 | + '_DOCTYPE_AIDE', |
|
| 2898 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2899 | + ); |
|
| 2900 | + } |
|
| 2901 | + |
|
| 2902 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2903 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2904 | + * le script de l'espace public, alias index.php */ |
|
| 2905 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2906 | + } |
|
| 2907 | + if (!defined('_SPIP_PAGE')) { |
|
| 2908 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2909 | + define('_SPIP_PAGE', 'page'); |
|
| 2910 | + } |
|
| 2911 | + |
|
| 2912 | + // le script de l'espace prive |
|
| 2913 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2914 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2915 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2916 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2917 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2918 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2919 | + } else { |
|
| 2920 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2921 | + } |
|
| 2922 | + } |
|
| 2923 | + |
|
| 2924 | + |
|
| 2925 | + if (!defined('_SPIP_AJAX')) { |
|
| 2926 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2927 | + ? 1 |
|
| 2928 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2929 | + } |
|
| 2930 | + |
|
| 2931 | + // La requete est-elle en ajax ? |
|
| 2932 | + if (!defined('_AJAX')) { |
|
| 2933 | + define( |
|
| 2934 | + '_AJAX', |
|
| 2935 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2936 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2937 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2938 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2939 | + ) |
|
| 2940 | + and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2941 | + ); |
|
| 2942 | + } |
|
| 2943 | + |
|
| 2944 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2945 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2946 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2947 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2948 | + define( |
|
| 2949 | + '_IMG_GD_MAX_PIXELS', |
|
| 2950 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2951 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2952 | + : 0 |
|
| 2953 | + ); |
|
| 2954 | + } |
|
| 2955 | + |
|
| 2956 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2957 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2958 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2959 | + } |
|
| 2960 | + |
|
| 2961 | + init_var_mode(); |
|
| 2963 | 2962 | } |
| 2964 | 2963 | |
| 2965 | 2964 | /** |
@@ -2993,219 +2992,219 @@ discard block |
||
| 2993 | 2992 | * ` var_mode` (calcul ou recalcul). |
| 2994 | 2993 | */ |
| 2995 | 2994 | function init_var_mode() { |
| 2996 | - static $done = false; |
|
| 2997 | - if (!$done) { |
|
| 2998 | - if (isset($_GET['var_mode'])) { |
|
| 2999 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 3000 | - // tout le monde peut calcul/recalcul |
|
| 3001 | - if (!defined('_VAR_MODE')) { |
|
| 3002 | - if (in_array('recalcul', $var_mode)) { |
|
| 3003 | - define('_VAR_MODE', 'recalcul'); |
|
| 3004 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 3005 | - define('_VAR_MODE', 'calcul'); |
|
| 3006 | - } |
|
| 3007 | - } |
|
| 3008 | - $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 3009 | - if ($var_mode) { |
|
| 3010 | - include_spip('inc/autoriser'); |
|
| 3011 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 3012 | - if ( |
|
| 3013 | - autoriser( |
|
| 3014 | - ($_GET['var_mode'] == 'preview') |
|
| 3015 | - ? 'previsualiser' |
|
| 3016 | - : 'debug' |
|
| 3017 | - ) |
|
| 3018 | - ) { |
|
| 3019 | - if (in_array('traduction', $var_mode)) { |
|
| 3020 | - // forcer le calcul pour passer dans traduire |
|
| 3021 | - if (!defined('_VAR_MODE')) { |
|
| 3022 | - define('_VAR_MODE', 'calcul'); |
|
| 3023 | - } |
|
| 3024 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 3025 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3026 | - define('_VAR_NOCACHE', true); |
|
| 3027 | - } |
|
| 3028 | - $var_mode = array_diff($var_mode, ['traduction']); |
|
| 3029 | - } |
|
| 3030 | - if (in_array('preview', $var_mode)) { |
|
| 3031 | - // basculer sur les criteres de preview dans les boucles |
|
| 3032 | - if (!defined('_VAR_PREVIEW')) { |
|
| 3033 | - define('_VAR_PREVIEW', true); |
|
| 3034 | - } |
|
| 3035 | - // forcer le calcul |
|
| 3036 | - if (!defined('_VAR_MODE')) { |
|
| 3037 | - define('_VAR_MODE', 'calcul'); |
|
| 3038 | - } |
|
| 3039 | - // et ne pas enregistrer de cache |
|
| 3040 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3041 | - define('_VAR_NOCACHE', true); |
|
| 3042 | - } |
|
| 3043 | - $var_mode = array_diff($var_mode, ['preview']); |
|
| 3044 | - } |
|
| 3045 | - if (in_array('inclure', $var_mode)) { |
|
| 3046 | - // forcer le compilo et ignorer les caches existants |
|
| 3047 | - if (!defined('_VAR_MODE')) { |
|
| 3048 | - define('_VAR_MODE', 'calcul'); |
|
| 3049 | - } |
|
| 3050 | - if (!defined('_VAR_INCLURE')) { |
|
| 3051 | - define('_VAR_INCLURE', true); |
|
| 3052 | - } |
|
| 3053 | - // et ne pas enregistrer de cache |
|
| 3054 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3055 | - define('_VAR_NOCACHE', true); |
|
| 3056 | - } |
|
| 3057 | - $var_mode = array_diff($var_mode, ['inclure']); |
|
| 3058 | - } |
|
| 3059 | - if (in_array('urls', $var_mode)) { |
|
| 3060 | - // forcer le compilo et ignorer les caches existants |
|
| 3061 | - if (!defined('_VAR_MODE')) { |
|
| 3062 | - define('_VAR_MODE', 'calcul'); |
|
| 3063 | - } |
|
| 3064 | - if (!defined('_VAR_URLS')) { |
|
| 3065 | - define('_VAR_URLS', true); |
|
| 3066 | - } |
|
| 3067 | - $var_mode = array_diff($var_mode, ['urls']); |
|
| 3068 | - } |
|
| 3069 | - if (in_array('images', $var_mode)) { |
|
| 3070 | - // forcer le compilo et ignorer les caches existants |
|
| 3071 | - if (!defined('_VAR_MODE')) { |
|
| 3072 | - define('_VAR_MODE', 'calcul'); |
|
| 3073 | - } |
|
| 3074 | - // indiquer qu'on doit recalculer les images |
|
| 3075 | - if (!defined('_VAR_IMAGES')) { |
|
| 3076 | - define('_VAR_IMAGES', true); |
|
| 3077 | - } |
|
| 3078 | - $var_mode = array_diff($var_mode, ['images']); |
|
| 3079 | - } |
|
| 3080 | - if (in_array('debug', $var_mode)) { |
|
| 3081 | - if (!defined('_VAR_MODE')) { |
|
| 3082 | - define('_VAR_MODE', 'debug'); |
|
| 3083 | - } |
|
| 3084 | - // et ne pas enregistrer de cache |
|
| 3085 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3086 | - define('_VAR_NOCACHE', true); |
|
| 3087 | - } |
|
| 3088 | - $var_mode = array_diff($var_mode, ['debug']); |
|
| 3089 | - } |
|
| 3090 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 3091 | - define('_VAR_MODE', reset($var_mode)); |
|
| 3092 | - } |
|
| 3093 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 3094 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 3095 | - . ' ' . _VAR_MODE); |
|
| 3096 | - } |
|
| 3097 | - } // pas autorise ? |
|
| 3098 | - else { |
|
| 3099 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 3100 | - if ( |
|
| 3101 | - !$GLOBALS['visiteur_session'] |
|
| 3102 | - and !empty($_SERVER['HTTP_HOST']) |
|
| 3103 | - and !empty($_SERVER['REQUEST_METHOD']) |
|
| 3104 | - and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 3105 | - ) { |
|
| 3106 | - $self = self('&', true); |
|
| 3107 | - if (strpos($self, 'page=login') === false) { |
|
| 3108 | - include_spip('inc/headers'); |
|
| 3109 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3110 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3111 | - } |
|
| 3112 | - } |
|
| 3113 | - // sinon tant pis |
|
| 3114 | - } |
|
| 3115 | - } |
|
| 3116 | - } |
|
| 3117 | - if (!defined('_VAR_MODE')) { |
|
| 3118 | - /** |
|
| 3119 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 3120 | - * @see init_var_mode() |
|
| 3121 | - */ |
|
| 3122 | - define('_VAR_MODE', false); |
|
| 3123 | - } |
|
| 3124 | - $done = true; |
|
| 3125 | - } |
|
| 2995 | + static $done = false; |
|
| 2996 | + if (!$done) { |
|
| 2997 | + if (isset($_GET['var_mode'])) { |
|
| 2998 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 2999 | + // tout le monde peut calcul/recalcul |
|
| 3000 | + if (!defined('_VAR_MODE')) { |
|
| 3001 | + if (in_array('recalcul', $var_mode)) { |
|
| 3002 | + define('_VAR_MODE', 'recalcul'); |
|
| 3003 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 3004 | + define('_VAR_MODE', 'calcul'); |
|
| 3005 | + } |
|
| 3006 | + } |
|
| 3007 | + $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 3008 | + if ($var_mode) { |
|
| 3009 | + include_spip('inc/autoriser'); |
|
| 3010 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 3011 | + if ( |
|
| 3012 | + autoriser( |
|
| 3013 | + ($_GET['var_mode'] == 'preview') |
|
| 3014 | + ? 'previsualiser' |
|
| 3015 | + : 'debug' |
|
| 3016 | + ) |
|
| 3017 | + ) { |
|
| 3018 | + if (in_array('traduction', $var_mode)) { |
|
| 3019 | + // forcer le calcul pour passer dans traduire |
|
| 3020 | + if (!defined('_VAR_MODE')) { |
|
| 3021 | + define('_VAR_MODE', 'calcul'); |
|
| 3022 | + } |
|
| 3023 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 3024 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3025 | + define('_VAR_NOCACHE', true); |
|
| 3026 | + } |
|
| 3027 | + $var_mode = array_diff($var_mode, ['traduction']); |
|
| 3028 | + } |
|
| 3029 | + if (in_array('preview', $var_mode)) { |
|
| 3030 | + // basculer sur les criteres de preview dans les boucles |
|
| 3031 | + if (!defined('_VAR_PREVIEW')) { |
|
| 3032 | + define('_VAR_PREVIEW', true); |
|
| 3033 | + } |
|
| 3034 | + // forcer le calcul |
|
| 3035 | + if (!defined('_VAR_MODE')) { |
|
| 3036 | + define('_VAR_MODE', 'calcul'); |
|
| 3037 | + } |
|
| 3038 | + // et ne pas enregistrer de cache |
|
| 3039 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3040 | + define('_VAR_NOCACHE', true); |
|
| 3041 | + } |
|
| 3042 | + $var_mode = array_diff($var_mode, ['preview']); |
|
| 3043 | + } |
|
| 3044 | + if (in_array('inclure', $var_mode)) { |
|
| 3045 | + // forcer le compilo et ignorer les caches existants |
|
| 3046 | + if (!defined('_VAR_MODE')) { |
|
| 3047 | + define('_VAR_MODE', 'calcul'); |
|
| 3048 | + } |
|
| 3049 | + if (!defined('_VAR_INCLURE')) { |
|
| 3050 | + define('_VAR_INCLURE', true); |
|
| 3051 | + } |
|
| 3052 | + // et ne pas enregistrer de cache |
|
| 3053 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3054 | + define('_VAR_NOCACHE', true); |
|
| 3055 | + } |
|
| 3056 | + $var_mode = array_diff($var_mode, ['inclure']); |
|
| 3057 | + } |
|
| 3058 | + if (in_array('urls', $var_mode)) { |
|
| 3059 | + // forcer le compilo et ignorer les caches existants |
|
| 3060 | + if (!defined('_VAR_MODE')) { |
|
| 3061 | + define('_VAR_MODE', 'calcul'); |
|
| 3062 | + } |
|
| 3063 | + if (!defined('_VAR_URLS')) { |
|
| 3064 | + define('_VAR_URLS', true); |
|
| 3065 | + } |
|
| 3066 | + $var_mode = array_diff($var_mode, ['urls']); |
|
| 3067 | + } |
|
| 3068 | + if (in_array('images', $var_mode)) { |
|
| 3069 | + // forcer le compilo et ignorer les caches existants |
|
| 3070 | + if (!defined('_VAR_MODE')) { |
|
| 3071 | + define('_VAR_MODE', 'calcul'); |
|
| 3072 | + } |
|
| 3073 | + // indiquer qu'on doit recalculer les images |
|
| 3074 | + if (!defined('_VAR_IMAGES')) { |
|
| 3075 | + define('_VAR_IMAGES', true); |
|
| 3076 | + } |
|
| 3077 | + $var_mode = array_diff($var_mode, ['images']); |
|
| 3078 | + } |
|
| 3079 | + if (in_array('debug', $var_mode)) { |
|
| 3080 | + if (!defined('_VAR_MODE')) { |
|
| 3081 | + define('_VAR_MODE', 'debug'); |
|
| 3082 | + } |
|
| 3083 | + // et ne pas enregistrer de cache |
|
| 3084 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3085 | + define('_VAR_NOCACHE', true); |
|
| 3086 | + } |
|
| 3087 | + $var_mode = array_diff($var_mode, ['debug']); |
|
| 3088 | + } |
|
| 3089 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 3090 | + define('_VAR_MODE', reset($var_mode)); |
|
| 3091 | + } |
|
| 3092 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 3093 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 3094 | + . ' ' . _VAR_MODE); |
|
| 3095 | + } |
|
| 3096 | + } // pas autorise ? |
|
| 3097 | + else { |
|
| 3098 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 3099 | + if ( |
|
| 3100 | + !$GLOBALS['visiteur_session'] |
|
| 3101 | + and !empty($_SERVER['HTTP_HOST']) |
|
| 3102 | + and !empty($_SERVER['REQUEST_METHOD']) |
|
| 3103 | + and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 3104 | + ) { |
|
| 3105 | + $self = self('&', true); |
|
| 3106 | + if (strpos($self, 'page=login') === false) { |
|
| 3107 | + include_spip('inc/headers'); |
|
| 3108 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3109 | + redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3110 | + } |
|
| 3111 | + } |
|
| 3112 | + // sinon tant pis |
|
| 3113 | + } |
|
| 3114 | + } |
|
| 3115 | + } |
|
| 3116 | + if (!defined('_VAR_MODE')) { |
|
| 3117 | + /** |
|
| 3118 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 3119 | + * @see init_var_mode() |
|
| 3120 | + */ |
|
| 3121 | + define('_VAR_MODE', false); |
|
| 3122 | + } |
|
| 3123 | + $done = true; |
|
| 3124 | + } |
|
| 3126 | 3125 | } |
| 3127 | 3126 | |
| 3128 | 3127 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
| 3129 | 3128 | // supprimer aussi les eventuels caracteres nuls %00, qui peuvent tromper |
| 3130 | 3129 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 3131 | 3130 | function spip_desinfecte(&$t, $deep = true) { |
| 3132 | - foreach ($t as $key => $val) { |
|
| 3133 | - if (is_string($t[$key])) { |
|
| 3134 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3135 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 3136 | - else { |
|
| 3137 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3138 | - spip_desinfecte($t[$key], $deep); |
|
| 3139 | - } |
|
| 3140 | - } |
|
| 3141 | - } |
|
| 3131 | + foreach ($t as $key => $val) { |
|
| 3132 | + if (is_string($t[$key])) { |
|
| 3133 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3134 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 3135 | + else { |
|
| 3136 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3137 | + spip_desinfecte($t[$key], $deep); |
|
| 3138 | + } |
|
| 3139 | + } |
|
| 3140 | + } |
|
| 3142 | 3141 | } |
| 3143 | 3142 | |
| 3144 | 3143 | // retourne le statut du visiteur s'il s'annonce |
| 3145 | 3144 | |
| 3146 | 3145 | function verifier_visiteur() { |
| 3147 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 3148 | - // il faut forcer l'init si ce n'est fait |
|
| 3149 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3150 | - // certaines constantes |
|
| 3151 | - @spip_initialisation_core( |
|
| 3152 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3153 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3154 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3155 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3156 | - ); |
|
| 3157 | - |
|
| 3158 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3159 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3160 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 3161 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3162 | - $variables_session = ['session_nom', 'session_email']; |
|
| 3163 | - foreach ($variables_session as $var) { |
|
| 3164 | - if (_request($var) !== null) { |
|
| 3165 | - $init = true; |
|
| 3166 | - break; |
|
| 3167 | - } |
|
| 3168 | - } |
|
| 3169 | - if (isset($init)) { |
|
| 3170 | - #@spip_initialisation_suite(); |
|
| 3171 | - $session = charger_fonction('session', 'inc'); |
|
| 3172 | - $session(); |
|
| 3173 | - include_spip('inc/texte'); |
|
| 3174 | - foreach ($variables_session as $var) { |
|
| 3175 | - if (($a = _request($var)) !== null) { |
|
| 3176 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3177 | - } |
|
| 3178 | - } |
|
| 3179 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3180 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3181 | - } |
|
| 3182 | - $session($GLOBALS['visiteur_session']); |
|
| 3183 | - |
|
| 3184 | - return 0; |
|
| 3185 | - } |
|
| 3186 | - |
|
| 3187 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3188 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3189 | - $session = charger_fonction('session', 'inc'); |
|
| 3190 | - if ($session()) { |
|
| 3191 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3192 | - } |
|
| 3193 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3194 | - include_spip('inc/auth'); |
|
| 3195 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3196 | - } |
|
| 3197 | - if ($h) { |
|
| 3198 | - $GLOBALS['visiteur_session'] = $h; |
|
| 3199 | - |
|
| 3200 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3201 | - } |
|
| 3202 | - } |
|
| 3203 | - |
|
| 3204 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3205 | - include_spip('inc/lang'); |
|
| 3206 | - utiliser_langue_visiteur(); |
|
| 3207 | - |
|
| 3208 | - return false; |
|
| 3146 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 3147 | + // il faut forcer l'init si ce n'est fait |
|
| 3148 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3149 | + // certaines constantes |
|
| 3150 | + @spip_initialisation_core( |
|
| 3151 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3152 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3153 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3154 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3155 | + ); |
|
| 3156 | + |
|
| 3157 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3158 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3159 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 3160 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3161 | + $variables_session = ['session_nom', 'session_email']; |
|
| 3162 | + foreach ($variables_session as $var) { |
|
| 3163 | + if (_request($var) !== null) { |
|
| 3164 | + $init = true; |
|
| 3165 | + break; |
|
| 3166 | + } |
|
| 3167 | + } |
|
| 3168 | + if (isset($init)) { |
|
| 3169 | + #@spip_initialisation_suite(); |
|
| 3170 | + $session = charger_fonction('session', 'inc'); |
|
| 3171 | + $session(); |
|
| 3172 | + include_spip('inc/texte'); |
|
| 3173 | + foreach ($variables_session as $var) { |
|
| 3174 | + if (($a = _request($var)) !== null) { |
|
| 3175 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3176 | + } |
|
| 3177 | + } |
|
| 3178 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3179 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3180 | + } |
|
| 3181 | + $session($GLOBALS['visiteur_session']); |
|
| 3182 | + |
|
| 3183 | + return 0; |
|
| 3184 | + } |
|
| 3185 | + |
|
| 3186 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3187 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3188 | + $session = charger_fonction('session', 'inc'); |
|
| 3189 | + if ($session()) { |
|
| 3190 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3191 | + } |
|
| 3192 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3193 | + include_spip('inc/auth'); |
|
| 3194 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3195 | + } |
|
| 3196 | + if ($h) { |
|
| 3197 | + $GLOBALS['visiteur_session'] = $h; |
|
| 3198 | + |
|
| 3199 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3200 | + } |
|
| 3201 | + } |
|
| 3202 | + |
|
| 3203 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3204 | + include_spip('inc/lang'); |
|
| 3205 | + utiliser_langue_visiteur(); |
|
| 3206 | + |
|
| 3207 | + return false; |
|
| 3209 | 3208 | } |
| 3210 | 3209 | |
| 3211 | 3210 | |
@@ -3228,21 +3227,21 @@ discard block |
||
| 3228 | 3227 | * - string Langue utilisée. |
| 3229 | 3228 | **/ |
| 3230 | 3229 | function lang_select($lang = null) { |
| 3231 | - static $pile_langues = []; |
|
| 3232 | - if (!function_exists('changer_langue')) { |
|
| 3233 | - include_spip('inc/lang'); |
|
| 3234 | - } |
|
| 3235 | - if ($lang === null) { |
|
| 3236 | - $lang = array_pop($pile_langues); |
|
| 3237 | - } else { |
|
| 3238 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3239 | - } |
|
| 3240 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3241 | - return $lang; |
|
| 3242 | - } |
|
| 3243 | - changer_langue($lang); |
|
| 3230 | + static $pile_langues = []; |
|
| 3231 | + if (!function_exists('changer_langue')) { |
|
| 3232 | + include_spip('inc/lang'); |
|
| 3233 | + } |
|
| 3234 | + if ($lang === null) { |
|
| 3235 | + $lang = array_pop($pile_langues); |
|
| 3236 | + } else { |
|
| 3237 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3238 | + } |
|
| 3239 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3240 | + return $lang; |
|
| 3241 | + } |
|
| 3242 | + changer_langue($lang); |
|
| 3244 | 3243 | |
| 3245 | - return $lang; |
|
| 3244 | + return $lang; |
|
| 3246 | 3245 | } |
| 3247 | 3246 | |
| 3248 | 3247 | /** |
@@ -3259,20 +3258,20 @@ discard block |
||
| 3259 | 3258 | * Identifiant de la session |
| 3260 | 3259 | **/ |
| 3261 | 3260 | function spip_session($force = false) { |
| 3262 | - static $session; |
|
| 3263 | - if ($force or !isset($session)) { |
|
| 3264 | - $s = pipeline( |
|
| 3265 | - 'definir_session', |
|
| 3266 | - $GLOBALS['visiteur_session'] |
|
| 3267 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3268 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3269 | - : '' |
|
| 3270 | - ); |
|
| 3271 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3272 | - } |
|
| 3261 | + static $session; |
|
| 3262 | + if ($force or !isset($session)) { |
|
| 3263 | + $s = pipeline( |
|
| 3264 | + 'definir_session', |
|
| 3265 | + $GLOBALS['visiteur_session'] |
|
| 3266 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3267 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3268 | + : '' |
|
| 3269 | + ); |
|
| 3270 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3271 | + } |
|
| 3273 | 3272 | |
| 3274 | - #spip_log('session: '.$session); |
|
| 3275 | - return $session; |
|
| 3273 | + #spip_log('session: '.$session); |
|
| 3274 | + return $session; |
|
| 3276 | 3275 | } |
| 3277 | 3276 | |
| 3278 | 3277 | |
@@ -3291,9 +3290,9 @@ discard block |
||
| 3291 | 3290 | * Lien sur une icone d'aide |
| 3292 | 3291 | **/ |
| 3293 | 3292 | function aider($aide = '', $distante = false) { |
| 3294 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3293 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3295 | 3294 | |
| 3296 | - return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3295 | + return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3297 | 3296 | } |
| 3298 | 3297 | |
| 3299 | 3298 | /** |
@@ -3303,24 +3302,24 @@ discard block |
||
| 3303 | 3302 | */ |
| 3304 | 3303 | function exec_info_dist() { |
| 3305 | 3304 | |
| 3306 | - include_spip('inc/autoriser'); |
|
| 3307 | - if (autoriser('phpinfos')) { |
|
| 3308 | - $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3309 | - $cookies_backup = []; |
|
| 3310 | - foreach ($cookies_masques as $k) { |
|
| 3311 | - if (!empty($_COOKIE[$k])) { |
|
| 3312 | - $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3313 | - $_COOKIE[$k] = '******************************'; |
|
| 3314 | - } |
|
| 3315 | - } |
|
| 3316 | - phpinfo(); |
|
| 3317 | - foreach ($cookies_backup as $k => $v) { |
|
| 3318 | - $_COOKIE[$k] = $v; |
|
| 3319 | - } |
|
| 3320 | - } else { |
|
| 3321 | - include_spip('inc/filtres'); |
|
| 3322 | - sinon_interdire_acces(); |
|
| 3323 | - } |
|
| 3305 | + include_spip('inc/autoriser'); |
|
| 3306 | + if (autoriser('phpinfos')) { |
|
| 3307 | + $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3308 | + $cookies_backup = []; |
|
| 3309 | + foreach ($cookies_masques as $k) { |
|
| 3310 | + if (!empty($_COOKIE[$k])) { |
|
| 3311 | + $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3312 | + $_COOKIE[$k] = '******************************'; |
|
| 3313 | + } |
|
| 3314 | + } |
|
| 3315 | + phpinfo(); |
|
| 3316 | + foreach ($cookies_backup as $k => $v) { |
|
| 3317 | + $_COOKIE[$k] = $v; |
|
| 3318 | + } |
|
| 3319 | + } else { |
|
| 3320 | + include_spip('inc/filtres'); |
|
| 3321 | + sinon_interdire_acces(); |
|
| 3322 | + } |
|
| 3324 | 3323 | } |
| 3325 | 3324 | |
| 3326 | 3325 | /** |
@@ -3340,13 +3339,13 @@ discard block |
||
| 3340 | 3339 | * - string si $message à false. |
| 3341 | 3340 | **/ |
| 3342 | 3341 | function erreur_squelette($message = '', $lieu = '') { |
| 3343 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3344 | - if (is_array($lieu)) { |
|
| 3345 | - include_spip('public/compiler'); |
|
| 3346 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3347 | - } |
|
| 3342 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3343 | + if (is_array($lieu)) { |
|
| 3344 | + include_spip('public/compiler'); |
|
| 3345 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3346 | + } |
|
| 3348 | 3347 | |
| 3349 | - return $debusquer($message, $lieu); |
|
| 3348 | + return $debusquer($message, $lieu); |
|
| 3350 | 3349 | } |
| 3351 | 3350 | |
| 3352 | 3351 | /** |
@@ -3383,108 +3382,108 @@ discard block |
||
| 3383 | 3382 | * - ou tableau d'information sur le squelette. |
| 3384 | 3383 | */ |
| 3385 | 3384 | function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') { |
| 3386 | - if (!function_exists('evaluer_fond')) { |
|
| 3387 | - include_spip('public/assembler'); |
|
| 3388 | - } |
|
| 3389 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3390 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3391 | - if (!is_array($options)) { |
|
| 3392 | - $options = ['trim' => $options]; |
|
| 3393 | - } |
|
| 3394 | - if (!isset($options['trim'])) { |
|
| 3395 | - $options['trim'] = true; |
|
| 3396 | - } |
|
| 3397 | - |
|
| 3398 | - if (isset($contexte['connect'])) { |
|
| 3399 | - $connect = $contexte['connect']; |
|
| 3400 | - unset($contexte['connect']); |
|
| 3401 | - } |
|
| 3402 | - |
|
| 3403 | - $texte = ''; |
|
| 3404 | - $pages = []; |
|
| 3405 | - $lang_select = ''; |
|
| 3406 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3407 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3408 | - if (!isset($contexte['lang'])) { |
|
| 3409 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3410 | - } |
|
| 3411 | - |
|
| 3412 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3413 | - $lang_select = lang_select($contexte['lang']); |
|
| 3414 | - } |
|
| 3415 | - } |
|
| 3416 | - |
|
| 3417 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3418 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3419 | - } |
|
| 3420 | - |
|
| 3421 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3422 | - |
|
| 3423 | - // fix #4235 |
|
| 3424 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3425 | - |
|
| 3426 | - |
|
| 3427 | - foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3428 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3429 | - |
|
| 3430 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3431 | - if ($page === '') { |
|
| 3432 | - $c = $options['compil'] ?? ''; |
|
| 3433 | - $a = ['fichier' => $f]; |
|
| 3434 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3435 | - erreur_squelette($erreur, $c); |
|
| 3436 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3437 | - $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3438 | - } |
|
| 3439 | - |
|
| 3440 | - $page = pipeline('recuperer_fond', [ |
|
| 3441 | - 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3442 | - 'data' => $page |
|
| 3443 | - ]); |
|
| 3444 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3445 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3446 | - include_spip('inc/filtres'); |
|
| 3447 | - } |
|
| 3448 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3449 | - array_merge( |
|
| 3450 | - $contexte, |
|
| 3451 | - ['fond' => $f], |
|
| 3452 | - ($connect ? ['connect' => $connect] : []) |
|
| 3453 | - ), |
|
| 3454 | - '', |
|
| 3455 | - $page['texte'], |
|
| 3456 | - $options['ajax'] |
|
| 3457 | - ); |
|
| 3458 | - } |
|
| 3459 | - |
|
| 3460 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3461 | - $pages[] = $page; |
|
| 3462 | - } else { |
|
| 3463 | - $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte']; |
|
| 3464 | - } |
|
| 3465 | - |
|
| 3466 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3467 | - if (isset($page['invalideurs']['session'])) { |
|
| 3468 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3469 | - } |
|
| 3470 | - } |
|
| 3471 | - |
|
| 3472 | - // restaurer le sessionnement du contexte appelant, |
|
| 3473 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3474 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3475 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3476 | - } |
|
| 3477 | - |
|
| 3478 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3479 | - |
|
| 3480 | - if ($lang_select) { |
|
| 3481 | - lang_select(); |
|
| 3482 | - } |
|
| 3483 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3484 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3485 | - } else { |
|
| 3486 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3487 | - } |
|
| 3385 | + if (!function_exists('evaluer_fond')) { |
|
| 3386 | + include_spip('public/assembler'); |
|
| 3387 | + } |
|
| 3388 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3389 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3390 | + if (!is_array($options)) { |
|
| 3391 | + $options = ['trim' => $options]; |
|
| 3392 | + } |
|
| 3393 | + if (!isset($options['trim'])) { |
|
| 3394 | + $options['trim'] = true; |
|
| 3395 | + } |
|
| 3396 | + |
|
| 3397 | + if (isset($contexte['connect'])) { |
|
| 3398 | + $connect = $contexte['connect']; |
|
| 3399 | + unset($contexte['connect']); |
|
| 3400 | + } |
|
| 3401 | + |
|
| 3402 | + $texte = ''; |
|
| 3403 | + $pages = []; |
|
| 3404 | + $lang_select = ''; |
|
| 3405 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3406 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3407 | + if (!isset($contexte['lang'])) { |
|
| 3408 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3409 | + } |
|
| 3410 | + |
|
| 3411 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3412 | + $lang_select = lang_select($contexte['lang']); |
|
| 3413 | + } |
|
| 3414 | + } |
|
| 3415 | + |
|
| 3416 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3417 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3418 | + } |
|
| 3419 | + |
|
| 3420 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3421 | + |
|
| 3422 | + // fix #4235 |
|
| 3423 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3424 | + |
|
| 3425 | + |
|
| 3426 | + foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3427 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3428 | + |
|
| 3429 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3430 | + if ($page === '') { |
|
| 3431 | + $c = $options['compil'] ?? ''; |
|
| 3432 | + $a = ['fichier' => $f]; |
|
| 3433 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3434 | + erreur_squelette($erreur, $c); |
|
| 3435 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3436 | + $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3437 | + } |
|
| 3438 | + |
|
| 3439 | + $page = pipeline('recuperer_fond', [ |
|
| 3440 | + 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3441 | + 'data' => $page |
|
| 3442 | + ]); |
|
| 3443 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3444 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3445 | + include_spip('inc/filtres'); |
|
| 3446 | + } |
|
| 3447 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3448 | + array_merge( |
|
| 3449 | + $contexte, |
|
| 3450 | + ['fond' => $f], |
|
| 3451 | + ($connect ? ['connect' => $connect] : []) |
|
| 3452 | + ), |
|
| 3453 | + '', |
|
| 3454 | + $page['texte'], |
|
| 3455 | + $options['ajax'] |
|
| 3456 | + ); |
|
| 3457 | + } |
|
| 3458 | + |
|
| 3459 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3460 | + $pages[] = $page; |
|
| 3461 | + } else { |
|
| 3462 | + $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte']; |
|
| 3463 | + } |
|
| 3464 | + |
|
| 3465 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3466 | + if (isset($page['invalideurs']['session'])) { |
|
| 3467 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3468 | + } |
|
| 3469 | + } |
|
| 3470 | + |
|
| 3471 | + // restaurer le sessionnement du contexte appelant, |
|
| 3472 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3473 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3474 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3475 | + } |
|
| 3476 | + |
|
| 3477 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3478 | + |
|
| 3479 | + if ($lang_select) { |
|
| 3480 | + lang_select(); |
|
| 3481 | + } |
|
| 3482 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3483 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3484 | + } else { |
|
| 3485 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3486 | + } |
|
| 3488 | 3487 | } |
| 3489 | 3488 | |
| 3490 | 3489 | /** |
@@ -3494,7 +3493,7 @@ discard block |
||
| 3494 | 3493 | * @return string |
| 3495 | 3494 | */ |
| 3496 | 3495 | function trouve_modele($nom) { |
| 3497 | - return trouver_fond($nom, 'modeles/'); |
|
| 3496 | + return trouver_fond($nom, 'modeles/'); |
|
| 3498 | 3497 | } |
| 3499 | 3498 | |
| 3500 | 3499 | /** |
@@ -3510,21 +3509,21 @@ discard block |
||
| 3510 | 3509 | * @return array|string |
| 3511 | 3510 | */ |
| 3512 | 3511 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3513 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3514 | - if (!$pathinfo) { |
|
| 3515 | - return $f; |
|
| 3516 | - } |
|
| 3517 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3518 | - $p = pathinfo($f); |
|
| 3519 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3520 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3521 | - } |
|
| 3522 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3523 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3524 | - } |
|
| 3525 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3512 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3513 | + if (!$pathinfo) { |
|
| 3514 | + return $f; |
|
| 3515 | + } |
|
| 3516 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3517 | + $p = pathinfo($f); |
|
| 3518 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3519 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3520 | + } |
|
| 3521 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3522 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3523 | + } |
|
| 3524 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3526 | 3525 | |
| 3527 | - return $p; |
|
| 3526 | + return $p; |
|
| 3528 | 3527 | } |
| 3529 | 3528 | |
| 3530 | 3529 | /** |
@@ -3544,21 +3543,21 @@ discard block |
||
| 3544 | 3543 | * Nom de l'exec, sinon chaîne vide. |
| 3545 | 3544 | **/ |
| 3546 | 3545 | function tester_url_ecrire($nom) { |
| 3547 | - static $exec = []; |
|
| 3548 | - if (isset($exec[$nom])) { |
|
| 3549 | - return $exec[$nom]; |
|
| 3550 | - } |
|
| 3551 | - // tester si c'est une page en squelette |
|
| 3552 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3553 | - return $exec[$nom] = 'fond'; |
|
| 3554 | - } // echafaudage d'un fond ! |
|
| 3555 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3556 | - return $exec[$nom] = 'fond'; |
|
| 3557 | - } |
|
| 3558 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3559 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3560 | - // et des define intrusifs potentiels |
|
| 3561 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3546 | + static $exec = []; |
|
| 3547 | + if (isset($exec[$nom])) { |
|
| 3548 | + return $exec[$nom]; |
|
| 3549 | + } |
|
| 3550 | + // tester si c'est une page en squelette |
|
| 3551 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3552 | + return $exec[$nom] = 'fond'; |
|
| 3553 | + } // echafaudage d'un fond ! |
|
| 3554 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3555 | + return $exec[$nom] = 'fond'; |
|
| 3556 | + } |
|
| 3557 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3558 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3559 | + // et des define intrusifs potentiels |
|
| 3560 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3562 | 3561 | } |
| 3563 | 3562 | |
| 3564 | 3563 | /** |
@@ -3568,8 +3567,8 @@ discard block |
||
| 3568 | 3567 | * true si la constante _VERSION_HTML n'est pas définie ou égale à html5 |
| 3569 | 3568 | **/ |
| 3570 | 3569 | function html5_permis() { |
| 3571 | - return (!defined('_VERSION_HTML') |
|
| 3572 | - or _VERSION_HTML !== 'html4'); |
|
| 3570 | + return (!defined('_VERSION_HTML') |
|
| 3571 | + or _VERSION_HTML !== 'html4'); |
|
| 3573 | 3572 | } |
| 3574 | 3573 | |
| 3575 | 3574 | /** |
@@ -3579,30 +3578,30 @@ discard block |
||
| 3579 | 3578 | * @return array |
| 3580 | 3579 | */ |
| 3581 | 3580 | function formats_image_acceptables($gd = null, $svg_allowed = true) { |
| 3582 | - $formats = null; |
|
| 3583 | - if (!is_null($gd)) { |
|
| 3584 | - $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3585 | - if (isset($GLOBALS['meta'][$config])) { |
|
| 3586 | - $formats = $GLOBALS['meta'][$config]; |
|
| 3587 | - $formats = explode(',', $formats); |
|
| 3588 | - $formats = array_filter($formats); |
|
| 3589 | - $formats = array_map('trim', $formats); |
|
| 3590 | - } |
|
| 3591 | - } |
|
| 3592 | - if (is_null($formats)) { |
|
| 3593 | - include_spip('inc/filtres_images_lib_mini'); |
|
| 3594 | - $formats = _image_extensions_acceptees_en_entree(); |
|
| 3595 | - } |
|
| 3596 | - |
|
| 3597 | - if ($svg_allowed) { |
|
| 3598 | - if (!in_array('svg', $formats)) { |
|
| 3599 | - $formats[] = 'svg'; |
|
| 3600 | - } |
|
| 3601 | - } |
|
| 3602 | - else { |
|
| 3603 | - $formats = array_diff($formats, ['svg']); |
|
| 3604 | - } |
|
| 3605 | - return $formats; |
|
| 3581 | + $formats = null; |
|
| 3582 | + if (!is_null($gd)) { |
|
| 3583 | + $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3584 | + if (isset($GLOBALS['meta'][$config])) { |
|
| 3585 | + $formats = $GLOBALS['meta'][$config]; |
|
| 3586 | + $formats = explode(',', $formats); |
|
| 3587 | + $formats = array_filter($formats); |
|
| 3588 | + $formats = array_map('trim', $formats); |
|
| 3589 | + } |
|
| 3590 | + } |
|
| 3591 | + if (is_null($formats)) { |
|
| 3592 | + include_spip('inc/filtres_images_lib_mini'); |
|
| 3593 | + $formats = _image_extensions_acceptees_en_entree(); |
|
| 3594 | + } |
|
| 3595 | + |
|
| 3596 | + if ($svg_allowed) { |
|
| 3597 | + if (!in_array('svg', $formats)) { |
|
| 3598 | + $formats[] = 'svg'; |
|
| 3599 | + } |
|
| 3600 | + } |
|
| 3601 | + else { |
|
| 3602 | + $formats = array_diff($formats, ['svg']); |
|
| 3603 | + } |
|
| 3604 | + return $formats; |
|
| 3606 | 3605 | } |
| 3607 | 3606 | |
| 3608 | 3607 | /** |
@@ -3611,20 +3610,20 @@ discard block |
||
| 3611 | 3610 | * @return array|bool |
| 3612 | 3611 | */ |
| 3613 | 3612 | function spip_getimagesize($fichier) { |
| 3614 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3615 | - include_spip('inc/svg'); |
|
| 3616 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3617 | - [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3618 | - $imagesize = [ |
|
| 3619 | - $width, |
|
| 3620 | - $height, |
|
| 3621 | - IMAGETYPE_SVG, |
|
| 3622 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3623 | - 'mime' => 'image/svg+xml' |
|
| 3624 | - ]; |
|
| 3625 | - } |
|
| 3626 | - } |
|
| 3627 | - return $imagesize; |
|
| 3613 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3614 | + include_spip('inc/svg'); |
|
| 3615 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3616 | + [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3617 | + $imagesize = [ |
|
| 3618 | + $width, |
|
| 3619 | + $height, |
|
| 3620 | + IMAGETYPE_SVG, |
|
| 3621 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3622 | + 'mime' => 'image/svg+xml' |
|
| 3623 | + ]; |
|
| 3624 | + } |
|
| 3625 | + } |
|
| 3626 | + return $imagesize; |
|
| 3628 | 3627 | } |
| 3629 | 3628 | |
| 3630 | 3629 | /** |
@@ -3638,19 +3637,19 @@ discard block |
||
| 3638 | 3637 | * @param string $statut |
| 3639 | 3638 | */ |
| 3640 | 3639 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3641 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3642 | - if ( |
|
| 3643 | - !$alertes |
|
| 3644 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3645 | - ) { |
|
| 3646 | - $alertes = []; |
|
| 3647 | - } |
|
| 3640 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3641 | + if ( |
|
| 3642 | + !$alertes |
|
| 3643 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3644 | + ) { |
|
| 3645 | + $alertes = []; |
|
| 3646 | + } |
|
| 3648 | 3647 | |
| 3649 | - if (!isset($alertes[$statut])) { |
|
| 3650 | - $alertes[$statut] = []; |
|
| 3651 | - } |
|
| 3652 | - $alertes[$statut][$nom] = $message; |
|
| 3653 | - ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3648 | + if (!isset($alertes[$statut])) { |
|
| 3649 | + $alertes[$statut] = []; |
|
| 3650 | + } |
|
| 3651 | + $alertes[$statut][$nom] = $message; |
|
| 3652 | + ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3654 | 3653 | } |
| 3655 | 3654 | |
| 3656 | 3655 | /** |
@@ -3664,10 +3663,10 @@ discard block |
||
| 3664 | 3663 | * @return string|string[] |
| 3665 | 3664 | */ |
| 3666 | 3665 | function spip_sanitize_classname($classes) { |
| 3667 | - if (is_array($classes)) { |
|
| 3668 | - return array_map('spip_sanitize_classname', $classes); |
|
| 3669 | - } |
|
| 3670 | - return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3666 | + if (is_array($classes)) { |
|
| 3667 | + return array_map('spip_sanitize_classname', $classes); |
|
| 3668 | + } |
|
| 3669 | + return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3671 | 3670 | } |
| 3672 | 3671 | |
| 3673 | 3672 | |
@@ -3692,32 +3691,32 @@ discard block |
||
| 3692 | 3691 | * Avec operateur : bool. |
| 3693 | 3692 | **/ |
| 3694 | 3693 | function spip_version_compare($v1, $v2, $op = null) { |
| 3695 | - $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3696 | - $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3697 | - $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3698 | - $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3699 | - |
|
| 3700 | - $v1 = explode('.', $v1); |
|
| 3701 | - $v2 = explode('.', $v2); |
|
| 3702 | - // $v1 est toujours une version, donc sans etoile |
|
| 3703 | - while (count($v1) < count($v2)) { |
|
| 3704 | - $v1[] = '0'; |
|
| 3705 | - } |
|
| 3706 | - |
|
| 3707 | - // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3708 | - $etoile = false; |
|
| 3709 | - foreach ($v1 as $k => $v) { |
|
| 3710 | - if (!isset($v2[$k])) { |
|
| 3711 | - $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3712 | - } else { |
|
| 3713 | - if ($v2[$k] == '*') { |
|
| 3714 | - $etoile = true; |
|
| 3715 | - $v2[$k] = $v; |
|
| 3716 | - } |
|
| 3717 | - } |
|
| 3718 | - } |
|
| 3719 | - $v1 = implode('.', $v1); |
|
| 3720 | - $v2 = implode('.', $v2); |
|
| 3721 | - |
|
| 3722 | - return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3694 | + $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3695 | + $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3696 | + $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3697 | + $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3698 | + |
|
| 3699 | + $v1 = explode('.', $v1); |
|
| 3700 | + $v2 = explode('.', $v2); |
|
| 3701 | + // $v1 est toujours une version, donc sans etoile |
|
| 3702 | + while (count($v1) < count($v2)) { |
|
| 3703 | + $v1[] = '0'; |
|
| 3704 | + } |
|
| 3705 | + |
|
| 3706 | + // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3707 | + $etoile = false; |
|
| 3708 | + foreach ($v1 as $k => $v) { |
|
| 3709 | + if (!isset($v2[$k])) { |
|
| 3710 | + $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3711 | + } else { |
|
| 3712 | + if ($v2[$k] == '*') { |
|
| 3713 | + $etoile = true; |
|
| 3714 | + $v2[$k] = $v; |
|
| 3715 | + } |
|
| 3716 | + } |
|
| 3717 | + } |
|
| 3718 | + $v1 = implode('.', $v1); |
|
| 3719 | + $v2 = implode('.', $v2); |
|
| 3720 | + |
|
| 3721 | + return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3723 | 3722 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | if (strlen($dossier) and substr($dossier, -1) != '/') { |
| 54 | 54 | $dossier .= '/'; |
| 55 | 55 | } |
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 56 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 57 | 57 | |
| 58 | 58 | if (function_exists($f)) { |
| 59 | 59 | return $f; |
| 60 | 60 | } |
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 61 | + if (function_exists($g = $f.'_dist')) { |
|
| 62 | 62 | return $g; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // passer en minuscules (cf les balises de formulaires) |
| 80 | 80 | // et inclure le fichier |
| 81 | 81 | if ( |
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | + !$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 83 | 83 | // si le fichier truc/machin/nom.php n'existe pas, |
| 84 | 84 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 85 | 85 | and strlen(dirname($dossier)) and dirname($dossier) != '.' |
@@ -98,19 +98,19 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Echec : message d'erreur |
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 102 | 102 | ($inc ? '' : " (fichier $d absent de $dossier)")); |
| 103 | 103 | |
| 104 | 104 | include_spip('inc/minipres'); |
| 105 | 105 | echo minipres( |
| 106 | 106 | _T('forum_titre_erreur'), |
| 107 | 107 | $inc ? |
| 108 | - _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 108 | + _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($f).'</code>']) |
|
| 109 | 109 | . '<br />' |
| 110 | - . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 110 | + . _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($g).'</code>']) |
|
| 111 | 111 | : |
| 112 | - _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 113 | - ['all_inline' => true,'status' => 404] |
|
| 112 | + _T('fichier_introuvable', ['fichier' => '<code>'.spip_htmlentities($d).'</code>']), |
|
| 113 | + ['all_inline' => true, 'status' => 404] |
|
| 114 | 114 | ); |
| 115 | 115 | exit; |
| 116 | 116 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * - string : chemin du fichier trouvé |
| 157 | 157 | **/ |
| 158 | 158 | function include_spip($f, $include = true) { |
| 159 | - return find_in_path($f . '.php', '', $include); |
|
| 159 | + return find_in_path($f.'.php', '', $include); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * - string : chemin du fichier trouvé |
| 177 | 177 | **/ |
| 178 | 178 | function require_spip($f) { |
| 179 | - return find_in_path($f . '.php', '', 'required'); |
|
| 179 | + return find_in_path($f.'.php', '', 'required'); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | // donc il faut l'inclure "en globals" |
| 194 | 194 | if ($f = find_in_path('mes_fonctions.php')) { |
| 195 | 195 | global $dossier_squelettes; |
| 196 | - include_once(_ROOT_CWD . $f); |
|
| 196 | + include_once(_ROOT_CWD.$f); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // appliquer notre fonction si elle existe |
| 301 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 301 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 302 | 302 | if (function_exists($fonc)) { |
| 303 | 303 | $val = $fonc($val); |
| 304 | 304 | } // plantage ? |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | function spip_log($message = null, $name = null) { |
| 364 | 364 | static $pre = []; |
| 365 | 365 | static $log; |
| 366 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 366 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 367 | 367 | if (!isset($regs[1]) or !$logname = $regs[1]) { |
| 368 | 368 | $logname = null; |
| 369 | 369 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | if (!is_string($message)) { |
| 392 | 392 | $message = print_r($message, true); |
| 393 | 393 | } |
| 394 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 394 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | $a = './'; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 595 | + $regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; |
|
| 596 | 596 | $ajouts = array_flip(explode('|', $c)); |
| 597 | 597 | $u = is_array($v) ? $v : rawurlencode((string) $v); |
| 598 | 598 | $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 620 | 620 | // pour un tableau ce sera fait dans la prochaine boucle |
| 621 | 621 | elseif (substr($r[1], -2) != '[]') { |
| 622 | - $url[$n] = $r[1] . '=' . $u; |
|
| 622 | + $url[$n] = $r[1].'='.$u; |
|
| 623 | 623 | unset($ajouts[$r[1]]); |
| 624 | 624 | } |
| 625 | 625 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -640,11 +640,11 @@ discard block |
||
| 640 | 640 | } elseif ($testv) { |
| 641 | 641 | foreach ($ajouts as $k => $n) { |
| 642 | 642 | if (!is_array($v)) { |
| 643 | - $url[] = $k . '=' . $u; |
|
| 643 | + $url[] = $k.'='.$u; |
|
| 644 | 644 | } else { |
| 645 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 645 | + $id = (substr($k, -2) == '[]') ? $k : ($k.'[]'); |
|
| 646 | 646 | foreach ($v as $w) { |
| 647 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 647 | + $url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | } |
@@ -655,10 +655,10 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | // recomposer l'adresse |
| 657 | 657 | if ($url) { |
| 658 | - $a .= '?' . join($sep, $url); |
|
| 658 | + $a .= '?'.join($sep, $url); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - return $a . $ancre; |
|
| 661 | + return $a.$ancre; |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | /** |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | translitteration($ancre) |
| 691 | 691 | ); |
| 692 | 692 | } |
| 693 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 693 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | * @return bool |
| 807 | 807 | */ |
| 808 | 808 | function test_plugin_actif($plugin) { |
| 809 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 809 | + return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | /** |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | $value = interdire_scripts($value, -1); |
| 939 | 939 | } |
| 940 | 940 | if (!empty($options['class'])) { |
| 941 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 941 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 942 | 942 | } |
| 943 | 943 | $text = str_replace("@$name@", $value, $text); |
| 944 | 944 | unset($args[$name]); |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | // Si des variables n'ont pas ete inserees, le signaler |
| 948 | 948 | // (chaines de langues pas a jour) |
| 949 | 949 | if ($args) { |
| 950 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 950 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | |
@@ -971,7 +971,7 @@ discard block |
||
| 971 | 971 | function joli_repertoire($rep) { |
| 972 | 972 | $a = substr($rep, 0, 1); |
| 973 | 973 | if ($a <> '.' and $a <> '/') { |
| 974 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 974 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 975 | 975 | } |
| 976 | 976 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 977 | 977 | |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | $p -= ($x * 1000); |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1028 | + return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1029 | 1029 | } |
| 1030 | 1030 | } |
| 1031 | 1031 | |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | if ($taches and count($taches) and !spip_connect()) { |
| 1093 | 1093 | return false; |
| 1094 | 1094 | } |
| 1095 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1095 | + spip_log('cron !', 'jq'._LOG_DEBUG); |
|
| 1096 | 1096 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 1097 | 1097 | return $genie($taches); |
| 1098 | 1098 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | |
| 1197 | 1197 | if ($queue_next_job_time == -1) { |
| 1198 | 1198 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 1199 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1199 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt'); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | // utiliser un cache memoire si dispo |
| 1202 | 1202 | if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
@@ -1265,8 +1265,8 @@ discard block |
||
| 1265 | 1265 | $src = ''; |
| 1266 | 1266 | } |
| 1267 | 1267 | if ($script) { |
| 1268 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1269 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1268 | + $script = ("/*<![CDATA[*/\n". |
|
| 1269 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 1270 | 1270 | '/*]]>*/'); |
| 1271 | 1271 | } |
| 1272 | 1272 | if ($noscript) { |
@@ -1352,13 +1352,13 @@ discard block |
||
| 1352 | 1352 | if ($path_base == null) { |
| 1353 | 1353 | // Chemin standard depuis l'espace public |
| 1354 | 1354 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 1355 | - _DIR_RACINE . ':' . |
|
| 1356 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1357 | - _DIR_RACINE . 'prive/:' . |
|
| 1355 | + _DIR_RACINE.':'. |
|
| 1356 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 1357 | + _DIR_RACINE.'prive/:'. |
|
| 1358 | 1358 | _DIR_RESTREINT; |
| 1359 | 1359 | // Ajouter squelettes/ |
| 1360 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1361 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1360 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 1361 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 1362 | 1362 | } |
| 1363 | 1363 | foreach (explode(':', $path) as $dir) { |
| 1364 | 1364 | if (strlen($dir) and substr($dir, -1) != '/') { |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | // Et le(s) dossier(s) des squelettes nommes |
| 1371 | 1371 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1372 | 1372 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1373 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1373 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 1374 | 1374 | } |
| 1375 | 1375 | } |
| 1376 | 1376 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | |
| 1382 | 1382 | if (is_array($dir_path) or strlen($dir_path)) { |
| 1383 | 1383 | $tete = ''; |
| 1384 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1384 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') { |
|
| 1385 | 1385 | $tete = array_shift($path_base); |
| 1386 | 1386 | } |
| 1387 | 1387 | $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
@@ -1402,7 +1402,7 @@ discard block |
||
| 1402 | 1402 | // Et le(s) dossier(s) des squelettes nommes |
| 1403 | 1403 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1404 | 1404 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1405 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1405 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/'); |
|
| 1406 | 1406 | } |
| 1407 | 1407 | } |
| 1408 | 1408 | |
@@ -1473,14 +1473,14 @@ discard block |
||
| 1473 | 1473 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 1474 | 1474 | if ( |
| 1475 | 1475 | preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 1476 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1476 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg' |
|
| 1477 | 1477 | and $f = find_in_theme("$file_svg_generique") |
| 1478 | 1478 | ) { |
| 1479 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1479 | + if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) { |
|
| 1480 | 1480 | return $themefiles["$subdir$file"] = $fsize; |
| 1481 | 1481 | } |
| 1482 | 1482 | else { |
| 1483 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1483 | + return $themefiles["$subdir$file"] = "$f?".$m[1].'px'; |
|
| 1484 | 1484 | } |
| 1485 | 1485 | } |
| 1486 | 1486 | |
@@ -1490,7 +1490,7 @@ discard block |
||
| 1490 | 1490 | return $themefiles["$subdir$file"] = $f; |
| 1491 | 1491 | } |
| 1492 | 1492 | } |
| 1493 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1493 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 1494 | 1494 | |
| 1495 | 1495 | return $themefiles["$subdir$file"] = ''; |
| 1496 | 1496 | } |
@@ -1598,8 +1598,8 @@ discard block |
||
| 1598 | 1598 | return false; |
| 1599 | 1599 | } |
| 1600 | 1600 | if ($include and !isset($inc[$dirname][$file])) { |
| 1601 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1602 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1601 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1602 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1603 | 1603 | } |
| 1604 | 1604 | |
| 1605 | 1605 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
@@ -1612,14 +1612,14 @@ discard block |
||
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | 1614 | foreach (creer_chemin() as $dir) { |
| 1615 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1616 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1615 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 1616 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 1617 | 1617 | } |
| 1618 | 1618 | if ($dirs[$a]) { |
| 1619 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1619 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 1620 | 1620 | if ($include and !isset($inc[$dirname][$file])) { |
| 1621 | - include_once _ROOT_CWD . $a; |
|
| 1622 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1621 | + include_once _ROOT_CWD.$a; |
|
| 1622 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1623 | 1623 | } |
| 1624 | 1624 | if (!defined('_SAUVER_CHEMIN')) { |
| 1625 | 1625 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
@@ -1629,7 +1629,7 @@ discard block |
||
| 1629 | 1629 | define('_SAUVER_CHEMIN', true); |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1632 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 1633 | 1633 | } |
| 1634 | 1634 | } |
| 1635 | 1635 | } |
@@ -1655,7 +1655,7 @@ discard block |
||
| 1655 | 1655 | define('_SAUVER_CHEMIN', true); |
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1658 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | 1661 | function clear_path_cache() { |
@@ -1725,12 +1725,12 @@ discard block |
||
| 1725 | 1725 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 1726 | 1726 | // on a pas encore inclus flock.php |
| 1727 | 1727 | if (!function_exists('preg_files')) { |
| 1728 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1728 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | 1731 | // Parcourir le chemin |
| 1732 | 1732 | foreach (creer_chemin() as $d) { |
| 1733 | - $f = $d . $dir; |
|
| 1733 | + $f = $d.$dir; |
|
| 1734 | 1734 | if (@is_dir($f)) { |
| 1735 | 1735 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
| 1736 | 1736 | foreach ($liste as $chemin) { |
@@ -1780,9 +1780,9 @@ discard block |
||
| 1780 | 1780 | if ($type === 'defaut') { |
| 1781 | 1781 | $objet = objet_type($quoi); |
| 1782 | 1782 | if ( |
| 1783 | - $f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1783 | + $f = charger_fonction('generer_'.$objet.'_url', 'urls', true) |
|
| 1784 | 1784 | // deprecated |
| 1785 | - or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1785 | + or $f = charger_fonction('generer_url_'.$objet, 'urls', true) |
|
| 1786 | 1786 | ) { |
| 1787 | 1787 | return $f; |
| 1788 | 1788 | } |
@@ -1795,7 +1795,7 @@ discard block |
||
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | 1797 | // inclure le module d'url |
| 1798 | - include_spip('urls/' . $url_type); |
|
| 1798 | + include_spip('urls/'.$url_type); |
|
| 1799 | 1799 | |
| 1800 | 1800 | switch ($quoi) { |
| 1801 | 1801 | case 'page': |
@@ -1951,8 +1951,8 @@ discard block |
||
| 1951 | 1951 | include_spip('base/connect_sql'); |
| 1952 | 1952 | $id_type = id_table_objet($entite, $public); |
| 1953 | 1953 | |
| 1954 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1955 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1954 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1955 | + . '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1956 | 1956 | . (!$args ? '' : "&$args") |
| 1957 | 1957 | . (!$ancre ? '' : "#$ancre"); |
| 1958 | 1958 | } |
@@ -2123,7 +2123,7 @@ discard block |
||
| 2123 | 2123 | !empty($_SERVER['QUERY_STRING']) |
| 2124 | 2124 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2125 | 2125 | ) { |
| 2126 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2126 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2127 | 2127 | } |
| 2128 | 2128 | } |
| 2129 | 2129 | } |
@@ -2158,9 +2158,9 @@ discard block |
||
| 2158 | 2158 | array_shift($myself); |
| 2159 | 2159 | $myself = implode('/', $myself); |
| 2160 | 2160 | } |
| 2161 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2161 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 2162 | 2162 | |
| 2163 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2163 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 2164 | 2164 | |
| 2165 | 2165 | return $url; |
| 2166 | 2166 | } |
@@ -2199,16 +2199,16 @@ discard block |
||
| 2199 | 2199 | function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) { |
| 2200 | 2200 | $script ??= ''; |
| 2201 | 2201 | if (!$rel) { |
| 2202 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2202 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 2203 | 2203 | } else { |
| 2204 | 2204 | if (!is_string($rel)) { |
| 2205 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2205 | + $rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT; |
|
| 2206 | 2206 | } |
| 2207 | 2207 | } |
| 2208 | 2208 | |
| 2209 | 2209 | [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
| 2210 | 2210 | if ($script and ($script <> 'accueil' or $rel)) { |
| 2211 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2211 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 2212 | 2212 | } elseif ($args) { |
| 2213 | 2213 | $args = "?$args"; |
| 2214 | 2214 | } |
@@ -2216,7 +2216,7 @@ discard block |
||
| 2216 | 2216 | $args .= "#$ancre"; |
| 2217 | 2217 | } |
| 2218 | 2218 | |
| 2219 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2219 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2220 | 2220 | } |
| 2221 | 2221 | |
| 2222 | 2222 | // |
@@ -2298,10 +2298,10 @@ discard block |
||
| 2298 | 2298 | $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
| 2299 | 2299 | } |
| 2300 | 2300 | if ($args) { |
| 2301 | - $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2301 | + $action .= (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 2302 | 2302 | } |
| 2303 | 2303 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 2304 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2304 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2305 | 2305 | } |
| 2306 | 2306 | |
| 2307 | 2307 | if (!$no_entities) { |
@@ -2313,7 +2313,7 @@ discard block |
||
| 2313 | 2313 | |
| 2314 | 2314 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2315 | 2315 | |
| 2316 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2316 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 2317 | 2317 | } |
| 2318 | 2318 | |
| 2319 | 2319 | // Pour les formulaires en methode POST, |
@@ -2348,8 +2348,7 @@ discard block |
||
| 2348 | 2348 | . "><div>\n" |
| 2349 | 2349 | . "<input type='hidden' name='exec' value='$script1' />" |
| 2350 | 2350 | . $corps |
| 2351 | - . (!$submit ? '' : |
|
| 2352 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2351 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>')) |
|
| 2353 | 2352 | . "</div></form>\n"; |
| 2354 | 2353 | } |
| 2355 | 2354 | |
@@ -2374,14 +2373,14 @@ discard block |
||
| 2374 | 2373 | ? generer_url_ecrire(_request('exec')) |
| 2375 | 2374 | : generer_url_public(); |
| 2376 | 2375 | |
| 2377 | - return "\n<form action='" . |
|
| 2378 | - $h . |
|
| 2379 | - "'" . |
|
| 2380 | - $atts . |
|
| 2381 | - ">\n" . |
|
| 2382 | - '<div>' . |
|
| 2383 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2384 | - $corps . |
|
| 2376 | + return "\n<form action='". |
|
| 2377 | + $h. |
|
| 2378 | + "'". |
|
| 2379 | + $atts. |
|
| 2380 | + ">\n". |
|
| 2381 | + '<div>'. |
|
| 2382 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 2383 | + $corps. |
|
| 2385 | 2384 | '</div></form>'; |
| 2386 | 2385 | } |
| 2387 | 2386 | |
@@ -2409,7 +2408,7 @@ discard block |
||
| 2409 | 2408 | : generer_url_public('', '', false, false); |
| 2410 | 2409 | $url = parametre_url($url, 'action', $script); |
| 2411 | 2410 | if ($args) { |
| 2412 | - $url .= quote_amp('&' . $args); |
|
| 2411 | + $url .= quote_amp('&'.$args); |
|
| 2413 | 2412 | } |
| 2414 | 2413 | |
| 2415 | 2414 | if ($no_entities) { |
@@ -2443,9 +2442,9 @@ discard block |
||
| 2443 | 2442 | } |
| 2444 | 2443 | $url = |
| 2445 | 2444 | (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
| 2446 | - . $script . '/' |
|
| 2445 | + . $script.'/' |
|
| 2447 | 2446 | . ($path ? trim($path, '/') : '') |
| 2448 | - . ($args ? '?' . quote_amp($args) : ''); |
|
| 2447 | + . ($args ? '?'.quote_amp($args) : ''); |
|
| 2449 | 2448 | |
| 2450 | 2449 | if ($no_entities) { |
| 2451 | 2450 | $url = str_replace('&', '&', $url); |
@@ -2494,17 +2493,17 @@ discard block |
||
| 2494 | 2493 | |
| 2495 | 2494 | // le nom du repertoire plugins/ activables/desactivables |
| 2496 | 2495 | if (!defined('_DIR_PLUGINS')) { |
| 2497 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2496 | + define('_DIR_PLUGINS', _DIR_RACINE.'plugins/'); |
|
| 2498 | 2497 | } |
| 2499 | 2498 | |
| 2500 | 2499 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 2501 | 2500 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 2502 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2501 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/'); |
|
| 2503 | 2502 | } |
| 2504 | 2503 | |
| 2505 | 2504 | // le nom du repertoire des librairies |
| 2506 | 2505 | if (!defined('_DIR_LIB')) { |
| 2507 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2506 | + define('_DIR_LIB', _DIR_RACINE.'lib/'); |
|
| 2508 | 2507 | } |
| 2509 | 2508 | |
| 2510 | 2509 | if (!defined('_DIR_IMG')) { |
@@ -2514,29 +2513,29 @@ discard block |
||
| 2514 | 2513 | define('_DIR_LOGOS', $pa); |
| 2515 | 2514 | } |
| 2516 | 2515 | if (!defined('_DIR_IMG_ICONES')) { |
| 2517 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2516 | + define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/'); |
|
| 2518 | 2517 | } |
| 2519 | 2518 | |
| 2520 | 2519 | if (!defined('_DIR_DUMP')) { |
| 2521 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2520 | + define('_DIR_DUMP', $ti.'dump/'); |
|
| 2522 | 2521 | } |
| 2523 | 2522 | if (!defined('_DIR_SESSIONS')) { |
| 2524 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2523 | + define('_DIR_SESSIONS', $ti.'sessions/'); |
|
| 2525 | 2524 | } |
| 2526 | 2525 | if (!defined('_DIR_TRANSFERT')) { |
| 2527 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2526 | + define('_DIR_TRANSFERT', $ti.'upload/'); |
|
| 2528 | 2527 | } |
| 2529 | 2528 | if (!defined('_DIR_CACHE')) { |
| 2530 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2529 | + define('_DIR_CACHE', $ti.'cache/'); |
|
| 2531 | 2530 | } |
| 2532 | 2531 | if (!defined('_DIR_CACHE_XML')) { |
| 2533 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2532 | + define('_DIR_CACHE_XML', _DIR_CACHE.'xml/'); |
|
| 2534 | 2533 | } |
| 2535 | 2534 | if (!defined('_DIR_SKELS')) { |
| 2536 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2535 | + define('_DIR_SKELS', _DIR_CACHE.'skel/'); |
|
| 2537 | 2536 | } |
| 2538 | 2537 | if (!defined('_DIR_AIDE')) { |
| 2539 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2538 | + define('_DIR_AIDE', _DIR_CACHE.'aide/'); |
|
| 2540 | 2539 | } |
| 2541 | 2540 | if (!defined('_DIR_TMP')) { |
| 2542 | 2541 | define('_DIR_TMP', $ti); |
@@ -2565,27 +2564,27 @@ discard block |
||
| 2565 | 2564 | // Declaration des fichiers |
| 2566 | 2565 | |
| 2567 | 2566 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 2568 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2567 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php'); |
|
| 2569 | 2568 | } |
| 2570 | 2569 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 2571 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2570 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php'); |
|
| 2572 | 2571 | } |
| 2573 | 2572 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 2574 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2573 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php'); |
|
| 2575 | 2574 | } |
| 2576 | 2575 | if (!defined('_CACHE_PIPELINES')) { |
| 2577 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2576 | + define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php'); |
|
| 2578 | 2577 | } |
| 2579 | 2578 | if (!defined('_CACHE_CHEMIN')) { |
| 2580 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2579 | + define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt'); |
|
| 2581 | 2580 | } |
| 2582 | 2581 | |
| 2583 | 2582 | # attention .php obligatoire pour ecrire_fichier_securise |
| 2584 | 2583 | if (!defined('_FILE_META')) { |
| 2585 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2584 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 2586 | 2585 | } |
| 2587 | 2586 | if (!defined('_DIR_LOG')) { |
| 2588 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2587 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 2589 | 2588 | } |
| 2590 | 2589 | if (!defined('_FILE_LOG')) { |
| 2591 | 2590 | define('_FILE_LOG', 'spip'); |
@@ -2602,8 +2601,8 @@ discard block |
||
| 2602 | 2601 | if (!defined('_FILE_CONNECT')) { |
| 2603 | 2602 | define( |
| 2604 | 2603 | '_FILE_CONNECT', |
| 2605 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2606 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2604 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 2605 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 2607 | 2606 | : false)) |
| 2608 | 2607 | ); |
| 2609 | 2608 | } |
@@ -2615,7 +2614,7 @@ discard block |
||
| 2615 | 2614 | if (!defined('_FILE_CHMOD')) { |
| 2616 | 2615 | define( |
| 2617 | 2616 | '_FILE_CHMOD', |
| 2618 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2617 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 2619 | 2618 | : false) |
| 2620 | 2619 | ); |
| 2621 | 2620 | } |
@@ -2628,10 +2627,10 @@ discard block |
||
| 2628 | 2627 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 2629 | 2628 | } |
| 2630 | 2629 | if (!defined('_FILE_CONNECT_TMP')) { |
| 2631 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2630 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 2632 | 2631 | } |
| 2633 | 2632 | if (!defined('_FILE_CHMOD_TMP')) { |
| 2634 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2633 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 2635 | 2634 | } |
| 2636 | 2635 | |
| 2637 | 2636 | // Definition des droits d'acces en ecriture |
@@ -2649,13 +2648,13 @@ discard block |
||
| 2649 | 2648 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 2650 | 2649 | } |
| 2651 | 2650 | if (!defined('_ROOT_PLUGINS')) { |
| 2652 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2651 | + define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/'); |
|
| 2653 | 2652 | } |
| 2654 | 2653 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 2655 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2654 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/'); |
|
| 2656 | 2655 | } |
| 2657 | 2656 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 2658 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2657 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2659 | 2658 | } |
| 2660 | 2659 | |
| 2661 | 2660 | // La taille des Log |
@@ -2692,7 +2691,7 @@ discard block |
||
| 2692 | 2691 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 2693 | 2692 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 2694 | 2693 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 2695 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2694 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 2696 | 2695 | |
| 2697 | 2696 | // charger tout de suite le path et son cache |
| 2698 | 2697 | load_path_cache(); |
@@ -2740,7 +2739,7 @@ discard block |
||
| 2740 | 2739 | !empty($_SERVER['QUERY_STRING']) |
| 2741 | 2740 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2742 | 2741 | ) { |
| 2743 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2742 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2744 | 2743 | } |
| 2745 | 2744 | } |
| 2746 | 2745 | |
@@ -2776,7 +2775,7 @@ discard block |
||
| 2776 | 2775 | ) { |
| 2777 | 2776 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 2778 | 2777 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 2779 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2778 | + $uri_ref = ($uri_ref['path'] ?? '').'/'; |
|
| 2780 | 2779 | } else { |
| 2781 | 2780 | $uri_ref = ''; |
| 2782 | 2781 | } |
@@ -2870,7 +2869,7 @@ discard block |
||
| 2870 | 2869 | } |
| 2871 | 2870 | if (!defined('_CACHE_RUBRIQUES')) { |
| 2872 | 2871 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 2873 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2872 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2874 | 2873 | } |
| 2875 | 2874 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 2876 | 2875 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -3092,7 +3091,7 @@ discard block |
||
| 3092 | 3091 | } |
| 3093 | 3092 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 3094 | 3093 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 3095 | - . ' ' . _VAR_MODE); |
|
| 3094 | + . ' '._VAR_MODE); |
|
| 3096 | 3095 | } |
| 3097 | 3096 | } // pas autorise ? |
| 3098 | 3097 | else { |
@@ -3107,7 +3106,7 @@ discard block |
||
| 3107 | 3106 | if (strpos($self, 'page=login') === false) { |
| 3108 | 3107 | include_spip('inc/headers'); |
| 3109 | 3108 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 3110 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3109 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 3111 | 3110 | } |
| 3112 | 3111 | } |
| 3113 | 3112 | // sinon tant pis |
@@ -3149,10 +3148,10 @@ discard block |
||
| 3149 | 3148 | // mais on risque de perturber des plugins en initialisant trop tot |
| 3150 | 3149 | // certaines constantes |
| 3151 | 3150 | @spip_initialisation_core( |
| 3152 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3153 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3154 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3155 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3151 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 3152 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 3153 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3154 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3156 | 3155 | ); |
| 3157 | 3156 | |
| 3158 | 3157 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -3185,7 +3184,7 @@ discard block |
||
| 3185 | 3184 | } |
| 3186 | 3185 | |
| 3187 | 3186 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
| 3188 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3187 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 3189 | 3188 | $session = charger_fonction('session', 'inc'); |
| 3190 | 3189 | if ($session()) { |
| 3191 | 3190 | return $GLOBALS['visiteur_session']['statut']; |
@@ -3265,7 +3264,7 @@ discard block |
||
| 3265 | 3264 | 'definir_session', |
| 3266 | 3265 | $GLOBALS['visiteur_session'] |
| 3267 | 3266 | ? serialize($GLOBALS['visiteur_session']) |
| 3268 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3267 | + . '_'.@$_COOKIE['spip_session'] |
|
| 3269 | 3268 | : '' |
| 3270 | 3269 | ); |
| 3271 | 3270 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -3421,11 +3420,11 @@ discard block |
||
| 3421 | 3420 | $GLOBALS['_INC_PUBLIC']++; |
| 3422 | 3421 | |
| 3423 | 3422 | // fix #4235 |
| 3424 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3423 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3425 | 3424 | |
| 3426 | 3425 | |
| 3427 | 3426 | foreach (is_array($fond) ? $fond : [$fond] as $f) { |
| 3428 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3427 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3429 | 3428 | |
| 3430 | 3429 | $page = evaluer_fond($f, $contexte, $connect); |
| 3431 | 3430 | if ($page === '') { |
@@ -3510,7 +3509,7 @@ discard block |
||
| 3510 | 3509 | * @return array|string |
| 3511 | 3510 | */ |
| 3512 | 3511 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3513 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3512 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 3514 | 3513 | if (!$pathinfo) { |
| 3515 | 3514 | return $f; |
| 3516 | 3515 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
| 147 | 147 | $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
| 148 | 148 | . $data[$root] |
| 149 | - . '</option>' . "\n"; |
|
| 149 | + . '</option>'."\n"; |
|
| 150 | 150 | } else { |
| 151 | 151 | $r = ''; |
| 152 | 152 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // et voila le travail |
| 177 | - return $r . $sous; |
|
| 177 | + return $r.$sous; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | while ($r = sql_fetch($q)) { |
| 222 | 222 | if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
| 223 | 223 | // titre largeur maxi a 50 |
| 224 | - $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 224 | + $titre = couper(supprimer_tags(typo($r['titre'])).' ', 50); |
|
| 225 | 225 | if ( |
| 226 | 226 | $GLOBALS['meta']['multi_rubriques'] == 'oui' |
| 227 | 227 | and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
| 228 | 228 | ) { |
| 229 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 229 | + $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 230 | 230 | } |
| 231 | 231 | $data[$r['id_rubrique']] = $titre; |
| 232 | 232 | $enfants[$r['id_parent']][] = $r['id_rubrique']; |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
| 254 | 254 | |
| 255 | 255 | if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
| 256 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 256 | + $r = "<input$att type='hidden' value='".$r[1]."' />".$r[2]; |
|
| 257 | 257 | } else { |
| 258 | - $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 258 | + $r = '<select'.$att." size='1'>\n$opt</select>\n"; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | # message pour neuneus (a supprimer ?) |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 298 | 298 | |
| 299 | 299 | if ($id_rubrique) { |
| 300 | - $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 300 | + $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 301 | 301 | } else { |
| 302 | 302 | if ($type == 'auteur') { |
| 303 | 303 | $titre = ' '; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
| 310 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 310 | + $init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'"; |
|
| 311 | 311 | |
| 312 | 312 | $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
| 313 | 313 | . (!$idem ? '' : "&exclus=$idem") |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | . " jQuery(this).toggleClass('toggled'); " |
| 357 | 357 | . "return charger_node_url_si_vide('" |
| 358 | 358 | . $url |
| 359 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 359 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>" |
|
| 360 | 360 | . $img_icone |
| 361 | 361 | . "</a><img src='" |
| 362 | 362 | . chemin_image('loader.svg') |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!defined('_SPIP_SELECT_RUBRIQUES')) { |
| 25 | - /** |
|
| 26 | - * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | - * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | - * mettre 100000 pour desactiver ajax |
|
| 29 | - */ |
|
| 30 | - define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 25 | + /** |
|
| 26 | + * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | + * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | + * mettre 100000 pour desactiver ajax |
|
| 29 | + */ |
|
| 30 | + define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | * Code HTML du sélecteur |
| 56 | 56 | **/ |
| 57 | 57 | function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 58 | - if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // Mode sans Ajax : |
|
| 63 | - // - soit parce que le cookie ajax n'est pas la |
|
| 64 | - // - soit parce qu'il y a peu de rubriques |
|
| 65 | - if ( |
|
| 66 | - _SPIP_AJAX < 1 |
|
| 67 | - or $type == 'breve' |
|
| 68 | - or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 69 | - ) { |
|
| 70 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 71 | - } else { |
|
| 72 | - return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 73 | - } |
|
| 58 | + if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // Mode sans Ajax : |
|
| 63 | + // - soit parce que le cookie ajax n'est pas la |
|
| 64 | + // - soit parce qu'il y a peu de rubriques |
|
| 65 | + if ( |
|
| 66 | + _SPIP_AJAX < 1 |
|
| 67 | + or $type == 'breve' |
|
| 68 | + or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 69 | + ) { |
|
| 70 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 71 | + } else { |
|
| 72 | + return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // compatibilite pour extensions qui utilisaient l'ancien nom |
@@ -87,17 +87,17 @@ discard block |
||
| 87 | 87 | **/ |
| 88 | 88 | function style_menu_rubriques($i) { |
| 89 | 89 | |
| 90 | - $espace = ''; |
|
| 91 | - $style = ''; |
|
| 92 | - for ($count = 1; $count <= $i; $count++) { |
|
| 93 | - $espace .= ' '; |
|
| 94 | - } |
|
| 95 | - if ($i == 1) { |
|
| 96 | - $espace = ''; |
|
| 97 | - } |
|
| 98 | - $class = "niveau_$i"; |
|
| 99 | - |
|
| 100 | - return [$class, $style, $espace]; |
|
| 90 | + $espace = ''; |
|
| 91 | + $style = ''; |
|
| 92 | + for ($count = 1; $count <= $i; $count++) { |
|
| 93 | + $espace .= ' '; |
|
| 94 | + } |
|
| 95 | + if ($i == 1) { |
|
| 96 | + $espace = ''; |
|
| 97 | + } |
|
| 98 | + $class = "niveau_$i"; |
|
| 99 | + |
|
| 100 | + return [$class, $style, $espace]; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -121,60 +121,60 @@ discard block |
||
| 121 | 121 | * Code HTML du sélecteur |
| 122 | 122 | **/ |
| 123 | 123 | function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) { |
| 124 | - static $decalage_secteur; |
|
| 125 | - |
|
| 126 | - // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | - if ( |
|
| 128 | - $exclus > 0 |
|
| 129 | - and $root == $exclus |
|
| 130 | - ) { |
|
| 131 | - return ''; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 135 | - |
|
| 136 | - // selected ? |
|
| 137 | - $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 138 | - |
|
| 139 | - // le style en fonction de la profondeur |
|
| 140 | - [$class, $style, $espace] = style_menu_rubriques($niv); |
|
| 141 | - |
|
| 142 | - $class .= ' selec_rub'; |
|
| 143 | - |
|
| 144 | - // creer l'<option> pour la rubrique $root |
|
| 145 | - |
|
| 146 | - if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
|
| 147 | - $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | - . $data[$root] |
|
| 149 | - . '</option>' . "\n"; |
|
| 150 | - } else { |
|
| 151 | - $r = ''; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - // et le sous-menu pour ses enfants |
|
| 155 | - $sous = ''; |
|
| 156 | - if (isset($enfants[$root])) { |
|
| 157 | - foreach ($enfants[$root] as $sousrub) { |
|
| 158 | - $sous .= sous_menu_rubriques( |
|
| 159 | - $id_rubrique, |
|
| 160 | - $sousrub, |
|
| 161 | - $niv + 1, |
|
| 162 | - $data, |
|
| 163 | - $enfants, |
|
| 164 | - $exclus, |
|
| 165 | - $restreint, |
|
| 166 | - $type |
|
| 167 | - ); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 172 | - if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 173 | - return $sous; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - // et voila le travail |
|
| 177 | - return $r . $sous; |
|
| 124 | + static $decalage_secteur; |
|
| 125 | + |
|
| 126 | + // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | + if ( |
|
| 128 | + $exclus > 0 |
|
| 129 | + and $root == $exclus |
|
| 130 | + ) { |
|
| 131 | + return ''; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 135 | + |
|
| 136 | + // selected ? |
|
| 137 | + $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 138 | + |
|
| 139 | + // le style en fonction de la profondeur |
|
| 140 | + [$class, $style, $espace] = style_menu_rubriques($niv); |
|
| 141 | + |
|
| 142 | + $class .= ' selec_rub'; |
|
| 143 | + |
|
| 144 | + // creer l'<option> pour la rubrique $root |
|
| 145 | + |
|
| 146 | + if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
|
| 147 | + $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | + . $data[$root] |
|
| 149 | + . '</option>' . "\n"; |
|
| 150 | + } else { |
|
| 151 | + $r = ''; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + // et le sous-menu pour ses enfants |
|
| 155 | + $sous = ''; |
|
| 156 | + if (isset($enfants[$root])) { |
|
| 157 | + foreach ($enfants[$root] as $sousrub) { |
|
| 158 | + $sous .= sous_menu_rubriques( |
|
| 159 | + $id_rubrique, |
|
| 160 | + $sousrub, |
|
| 161 | + $niv + 1, |
|
| 162 | + $data, |
|
| 163 | + $enfants, |
|
| 164 | + $exclus, |
|
| 165 | + $restreint, |
|
| 166 | + $type |
|
| 167 | + ); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 172 | + if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 173 | + return $sous; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + // et voila le travail |
|
| 177 | + return $r . $sous; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -195,75 +195,75 @@ discard block |
||
| 195 | 195 | * Code HTML du sélecteur |
| 196 | 196 | **/ |
| 197 | 197 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) { |
| 198 | - $enfants = []; |
|
| 199 | - $data = []; |
|
| 200 | - if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 201 | - $data[0] = _T('info_racine_site'); |
|
| 202 | - } |
|
| 203 | - # premier choix = neant |
|
| 204 | - # si auteur (rubriques restreintes) |
|
| 205 | - # ou si creation avec id_rubrique=0 |
|
| 206 | - elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 207 | - $data[0] = ' '; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // |
|
| 211 | - // creer une structure contenant toute l'arborescence |
|
| 212 | - // |
|
| 213 | - |
|
| 214 | - include_spip('base/abstract_sql'); |
|
| 215 | - $q = sql_select( |
|
| 216 | - 'id_rubrique, id_parent, titre, statut, lang, langue_choisie', |
|
| 217 | - 'spip_rubriques', |
|
| 218 | - ($type == 'breve' ? ' id_parent=0 ' : ''), |
|
| 219 | - '', |
|
| 220 | - '0+titre,titre' |
|
| 221 | - ); |
|
| 222 | - while ($r = sql_fetch($q)) { |
|
| 223 | - if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 224 | - // titre largeur maxi a 50 |
|
| 225 | - $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 226 | - if ( |
|
| 227 | - $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 228 | - and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
|
| 229 | - ) { |
|
| 230 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 231 | - } |
|
| 232 | - $data[$r['id_rubrique']] = $titre; |
|
| 233 | - $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 234 | - if ($id_rubrique == $r['id_rubrique']) { |
|
| 235 | - $id_parent = $r['id_parent']; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // si une seule rubrique comme choix possible, |
|
| 241 | - // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 242 | - // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 243 | - if ( |
|
| 244 | - count($data) == 2 |
|
| 245 | - and isset($data[0]) |
|
| 246 | - and !in_array($type, ['auteur', 'rubrique']) |
|
| 247 | - and !$id_rubrique |
|
| 248 | - ) { |
|
| 249 | - unset($data[0]); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 254 | - $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 255 | - |
|
| 256 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 257 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 258 | - } else { |
|
| 259 | - $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - # message pour neuneus (a supprimer ?) |
|
| 198 | + $enfants = []; |
|
| 199 | + $data = []; |
|
| 200 | + if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 201 | + $data[0] = _T('info_racine_site'); |
|
| 202 | + } |
|
| 203 | + # premier choix = neant |
|
| 204 | + # si auteur (rubriques restreintes) |
|
| 205 | + # ou si creation avec id_rubrique=0 |
|
| 206 | + elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 207 | + $data[0] = ' '; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // |
|
| 211 | + // creer une structure contenant toute l'arborescence |
|
| 212 | + // |
|
| 213 | + |
|
| 214 | + include_spip('base/abstract_sql'); |
|
| 215 | + $q = sql_select( |
|
| 216 | + 'id_rubrique, id_parent, titre, statut, lang, langue_choisie', |
|
| 217 | + 'spip_rubriques', |
|
| 218 | + ($type == 'breve' ? ' id_parent=0 ' : ''), |
|
| 219 | + '', |
|
| 220 | + '0+titre,titre' |
|
| 221 | + ); |
|
| 222 | + while ($r = sql_fetch($q)) { |
|
| 223 | + if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 224 | + // titre largeur maxi a 50 |
|
| 225 | + $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 226 | + if ( |
|
| 227 | + $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 228 | + and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
|
| 229 | + ) { |
|
| 230 | + $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 231 | + } |
|
| 232 | + $data[$r['id_rubrique']] = $titre; |
|
| 233 | + $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 234 | + if ($id_rubrique == $r['id_rubrique']) { |
|
| 235 | + $id_parent = $r['id_parent']; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // si une seule rubrique comme choix possible, |
|
| 241 | + // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 242 | + // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 243 | + if ( |
|
| 244 | + count($data) == 2 |
|
| 245 | + and isset($data[0]) |
|
| 246 | + and !in_array($type, ['auteur', 'rubrique']) |
|
| 247 | + and !$id_rubrique |
|
| 248 | + ) { |
|
| 249 | + unset($data[0]); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 254 | + $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 255 | + |
|
| 256 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 257 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 258 | + } else { |
|
| 259 | + $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + # message pour neuneus (a supprimer ?) |
|
| 263 | 263 | # if ($type != 'auteur' AND $type != 'breve') |
| 264 | 264 | # $r .= "\n<br />"._T('texte_rappel_selection_champs'); |
| 265 | 265 | |
| 266 | - return $r; |
|
| 266 | + return $r; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -297,26 +297,26 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 299 | 299 | |
| 300 | - if ($id_rubrique) { |
|
| 301 | - $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 302 | - } else { |
|
| 303 | - if ($type == 'auteur') { |
|
| 304 | - $titre = ' '; |
|
| 305 | - } else { |
|
| 306 | - $titre = _T('info_racine_site'); |
|
| 307 | - } |
|
| 308 | - } |
|
| 300 | + if ($id_rubrique) { |
|
| 301 | + $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 302 | + } else { |
|
| 303 | + if ($type == 'auteur') { |
|
| 304 | + $titre = ' '; |
|
| 305 | + } else { |
|
| 306 | + $titre = _T('info_racine_site'); |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 311 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 310 | + $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 311 | + $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 312 | 312 | |
| 313 | - $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 314 | - . (!$idem ? '' : "&exclus=$idem") |
|
| 315 | - . ($restreint ? '' : '&racine=oui') |
|
| 316 | - . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 313 | + $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 314 | + . (!$idem ? '' : "&exclus=$idem") |
|
| 315 | + . ($restreint ? '' : '&racine=oui') |
|
| 316 | + . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 317 | 317 | |
| 318 | 318 | |
| 319 | - return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 319 | + return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -346,30 +346,30 @@ discard block |
||
| 346 | 346 | * Code HTML du sélecteur de rubrique AJAX |
| 347 | 347 | **/ |
| 348 | 348 | function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) { |
| 349 | - $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 350 | - // si icone de recherche on embed le svg |
|
| 351 | - $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 352 | - $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur')); |
|
| 353 | - |
|
| 354 | - return |
|
| 355 | - "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 356 | - . $js |
|
| 357 | - . " jQuery(this).toggleClass('toggled'); " |
|
| 358 | - . "return charger_node_url_si_vide('" |
|
| 359 | - . $url |
|
| 360 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 361 | - . $img_icone |
|
| 362 | - . "</a><img src='" |
|
| 363 | - . chemin_image('loader.svg') |
|
| 364 | - . "' class='loader' id='img_" |
|
| 365 | - . $idom |
|
| 366 | - . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 367 | - . "<input id='titreparent' name='titreparent' class='text'" |
|
| 368 | - . $init |
|
| 369 | - . ' />' |
|
| 370 | - . "<input type='hidden' id='$name' name='$name' value='" |
|
| 371 | - . $id |
|
| 372 | - . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 373 | - . $idom |
|
| 374 | - . "'\nstyle='display: none;'></div>"; |
|
| 349 | + $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 350 | + // si icone de recherche on embed le svg |
|
| 351 | + $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 352 | + $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur')); |
|
| 353 | + |
|
| 354 | + return |
|
| 355 | + "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 356 | + . $js |
|
| 357 | + . " jQuery(this).toggleClass('toggled'); " |
|
| 358 | + . "return charger_node_url_si_vide('" |
|
| 359 | + . $url |
|
| 360 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 361 | + . $img_icone |
|
| 362 | + . "</a><img src='" |
|
| 363 | + . chemin_image('loader.svg') |
|
| 364 | + . "' class='loader' id='img_" |
|
| 365 | + . $idom |
|
| 366 | + . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 367 | + . "<input id='titreparent' name='titreparent' class='text'" |
|
| 368 | + . $init |
|
| 369 | + . ' />' |
|
| 370 | + . "<input type='hidden' id='$name' name='$name' value='" |
|
| 371 | + . $id |
|
| 372 | + . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 373 | + . $idom |
|
| 374 | + . "'\nstyle='display: none;'></div>"; |
|
| 375 | 375 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | renouvelle_alea(); |
| 66 | 66 | $new = false; |
| 67 | 67 | } else { |
| 68 | - spip_log("impossible d'ecrire dans " . $cache); |
|
| 68 | + spip_log("impossible d'ecrire dans ".$cache); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | // et refaire le cache si on a du lire en base |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | if (!isset($touch[$table])) { |
| 167 | 167 | touch_meta($antidate, $table); |
| 168 | 168 | } |
| 169 | - sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | + sql_delete('spip_'.$table, "nom='$nom'", '', 'continue'); |
|
| 170 | 170 | unset($GLOBALS[$table][$nom]); |
| 171 | 171 | if (!isset($touch[$table])) { |
| 172 | 172 | touch_meta($antidate, $table); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | 199 | include_spip('base/abstract_sql'); |
| 200 | - $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | + $res = sql_select('*', 'spip_'.$table, 'nom='.sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 201 | 201 | // table pas encore installee, travailler en php seulement |
| 202 | 202 | if (!$res) { |
| 203 | 203 | $GLOBALS[$table][$nom] = $valeur; |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | $r['impt'] = sql_quote($importable, '', 'text'); |
| 232 | 232 | } |
| 233 | 233 | if ($row) { |
| 234 | - sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | + sql_update('spip_'.$table, $r, 'nom='.sql_quote($nom)); |
|
| 235 | 235 | } else { |
| 236 | - sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | + sql_insert('spip_'.$table, '('.join(',', array_keys($r)).')', '('.join(',', array_values($r)).')'); |
|
| 237 | 237 | } |
| 238 | 238 | if (!isset($touch[$table])) { |
| 239 | 239 | touch_meta($antidate, $table); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * Nom du fichier cache |
| 251 | 251 | **/ |
| 252 | 252 | function cache_meta($table = 'meta') { |
| 253 | - return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 253 | + return ($table == 'meta') ? _FILE_META : (_DIR_CACHE.$table.'.php'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | // Les parametres generaux du site sont dans une table SQL; |
@@ -27,51 +27,51 @@ discard block |
||
| 27 | 27 | define('_META_CACHE_TIME', 1 << 24); |
| 28 | 28 | |
| 29 | 29 | function inc_meta_dist($table = 'meta') { |
| 30 | - $new = null; |
|
| 31 | - // Lire les meta, en cache si present, valide et lisible |
|
| 32 | - // en cas d'install ne pas faire confiance au meta_cache eventuel |
|
| 33 | - $cache = cache_meta($table); |
|
| 30 | + $new = null; |
|
| 31 | + // Lire les meta, en cache si present, valide et lisible |
|
| 32 | + // en cas d'install ne pas faire confiance au meta_cache eventuel |
|
| 33 | + $cache = cache_meta($table); |
|
| 34 | 34 | |
| 35 | - if ( |
|
| 36 | - (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) |
|
| 37 | - and $new = jeune_fichier($cache, _META_CACHE_TIME) |
|
| 38 | - and lire_fichier_securise($cache, $meta) |
|
| 39 | - and $meta = @unserialize($meta) |
|
| 40 | - ) { |
|
| 41 | - $GLOBALS[$table] = $meta; |
|
| 42 | - } |
|
| 35 | + if ( |
|
| 36 | + (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) |
|
| 37 | + and $new = jeune_fichier($cache, _META_CACHE_TIME) |
|
| 38 | + and lire_fichier_securise($cache, $meta) |
|
| 39 | + and $meta = @unserialize($meta) |
|
| 40 | + ) { |
|
| 41 | + $GLOBALS[$table] = $meta; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - if ( |
|
| 45 | - isset($GLOBALS[$table]['touch']) |
|
| 46 | - and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME) |
|
| 47 | - ) { |
|
| 48 | - $GLOBALS[$table] = []; |
|
| 49 | - } |
|
| 50 | - // sinon lire en base |
|
| 51 | - if (!$GLOBALS[$table]) { |
|
| 52 | - $new = !lire_metas($table); |
|
| 53 | - } |
|
| 44 | + if ( |
|
| 45 | + isset($GLOBALS[$table]['touch']) |
|
| 46 | + and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME) |
|
| 47 | + ) { |
|
| 48 | + $GLOBALS[$table] = []; |
|
| 49 | + } |
|
| 50 | + // sinon lire en base |
|
| 51 | + if (!$GLOBALS[$table]) { |
|
| 52 | + $new = !lire_metas($table); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // renouveller l'alea general si trop vieux ou sur demande explicite |
|
| 56 | - if ( |
|
| 57 | - (test_espace_prive() || isset($_GET['renouvelle_alea'])) |
|
| 58 | - and $GLOBALS[$table] |
|
| 59 | - and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0)) |
|
| 60 | - ) { |
|
| 61 | - // si on n'a pas l'acces en ecriture sur le cache, |
|
| 62 | - // ne pas renouveller l'alea sinon le cache devient faux |
|
| 63 | - if (supprimer_fichier($cache)) { |
|
| 64 | - include_spip('inc/acces'); |
|
| 65 | - renouvelle_alea(); |
|
| 66 | - $new = false; |
|
| 67 | - } else { |
|
| 68 | - spip_log("impossible d'ecrire dans " . $cache); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - // et refaire le cache si on a du lire en base |
|
| 72 | - if (!$new) { |
|
| 73 | - touch_meta(false, $table); |
|
| 74 | - } |
|
| 55 | + // renouveller l'alea general si trop vieux ou sur demande explicite |
|
| 56 | + if ( |
|
| 57 | + (test_espace_prive() || isset($_GET['renouvelle_alea'])) |
|
| 58 | + and $GLOBALS[$table] |
|
| 59 | + and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0)) |
|
| 60 | + ) { |
|
| 61 | + // si on n'a pas l'acces en ecriture sur le cache, |
|
| 62 | + // ne pas renouveller l'alea sinon le cache devient faux |
|
| 63 | + if (supprimer_fichier($cache)) { |
|
| 64 | + include_spip('inc/acces'); |
|
| 65 | + renouvelle_alea(); |
|
| 66 | + $new = false; |
|
| 67 | + } else { |
|
| 68 | + spip_log("impossible d'ecrire dans " . $cache); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + // et refaire le cache si on a du lire en base |
|
| 72 | + if (!$new) { |
|
| 73 | + touch_meta(false, $table); |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // fonctions aussi appelees a l'install ==> spip_query en premiere requete |
@@ -79,39 +79,39 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | function lire_metas($table = 'meta') { |
| 81 | 81 | |
| 82 | - if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
|
| 83 | - include_spip('base/abstract_sql'); |
|
| 84 | - $GLOBALS[$table] = []; |
|
| 85 | - while ($row = sql_fetch($result)) { |
|
| 86 | - $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 87 | - } |
|
| 88 | - sql_free($result); |
|
| 82 | + if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
|
| 83 | + include_spip('base/abstract_sql'); |
|
| 84 | + $GLOBALS[$table] = []; |
|
| 85 | + while ($row = sql_fetch($result)) { |
|
| 86 | + $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 87 | + } |
|
| 88 | + sql_free($result); |
|
| 89 | 89 | |
| 90 | - if ( |
|
| 91 | - !isset($GLOBALS[$table]['charset']) |
|
| 92 | - or !$GLOBALS[$table]['charset'] |
|
| 93 | - or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
|
| 94 | - ) { |
|
| 95 | - ecrire_meta('charset', _DEFAULT_CHARSET, null, $table); |
|
| 96 | - } |
|
| 90 | + if ( |
|
| 91 | + !isset($GLOBALS[$table]['charset']) |
|
| 92 | + or !$GLOBALS[$table]['charset'] |
|
| 93 | + or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
|
| 94 | + ) { |
|
| 95 | + ecrire_meta('charset', _DEFAULT_CHARSET, null, $table); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - // noter cette table de configuration dans les meta de SPIP |
|
| 99 | - if ($table !== 'meta') { |
|
| 100 | - $liste = []; |
|
| 101 | - if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 102 | - $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 103 | - } |
|
| 104 | - if (!$liste) { |
|
| 105 | - $liste = []; |
|
| 106 | - } |
|
| 107 | - if (!in_array($table, $liste)) { |
|
| 108 | - $liste[] = $table; |
|
| 109 | - ecrire_meta('tables_config', serialize($liste)); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 98 | + // noter cette table de configuration dans les meta de SPIP |
|
| 99 | + if ($table !== 'meta') { |
|
| 100 | + $liste = []; |
|
| 101 | + if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 102 | + $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 103 | + } |
|
| 104 | + if (!$liste) { |
|
| 105 | + $liste = []; |
|
| 106 | + } |
|
| 107 | + if (!in_array($table, $liste)) { |
|
| 108 | + $liste[] = $table; |
|
| 109 | + ecrire_meta('tables_config', serialize($liste)); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return $GLOBALS[$table] ?? null; |
|
| 114 | + return $GLOBALS[$table] ?? null; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -125,22 +125,22 @@ discard block |
||
| 125 | 125 | * Table SQL d'enregistrement des meta. |
| 126 | 126 | **/ |
| 127 | 127 | function touch_meta($antidate = false, $table = 'meta') { |
| 128 | - $file = cache_meta($table); |
|
| 129 | - if (!$antidate or !@touch($file, $antidate)) { |
|
| 130 | - $r = $GLOBALS[$table] ?? []; |
|
| 131 | - if ($table == 'meta') { |
|
| 132 | - unset($r['alea_ephemere']); |
|
| 133 | - unset($r['alea_ephemere_ancien']); |
|
| 134 | - // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables |
|
| 135 | - // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
|
| 136 | - // meme si son squelette est en cache |
|
| 137 | - //unset($r['secret_du_site']); |
|
| 138 | - if ($antidate) { |
|
| 139 | - $r['touch'] = $antidate; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - ecrire_fichier_securise($file, serialize($r)); |
|
| 143 | - } |
|
| 128 | + $file = cache_meta($table); |
|
| 129 | + if (!$antidate or !@touch($file, $antidate)) { |
|
| 130 | + $r = $GLOBALS[$table] ?? []; |
|
| 131 | + if ($table == 'meta') { |
|
| 132 | + unset($r['alea_ephemere']); |
|
| 133 | + unset($r['alea_ephemere_ancien']); |
|
| 134 | + // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables |
|
| 135 | + // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
|
| 136 | + // meme si son squelette est en cache |
|
| 137 | + //unset($r['secret_du_site']); |
|
| 138 | + if ($antidate) { |
|
| 139 | + $r['touch'] = $antidate; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + ecrire_fichier_securise($file, serialize($r)); |
|
| 143 | + } |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -156,21 +156,21 @@ discard block |
||
| 156 | 156 | * Table SQL d'enregistrement de la meta. |
| 157 | 157 | **/ |
| 158 | 158 | function effacer_meta($nom, $table = 'meta') { |
| 159 | - // section critique sur le cache: |
|
| 160 | - // l'invalider avant et apres la MAJ de la BD |
|
| 161 | - // c'est un peu moins bien qu'un vrai verrou mais ca suffira |
|
| 162 | - // et utiliser une statique pour eviter des acces disques a repetition |
|
| 163 | - static $touch = []; |
|
| 164 | - $antidate = time() - (_META_CACHE_TIME << 4); |
|
| 165 | - if (!isset($touch[$table])) { |
|
| 166 | - touch_meta($antidate, $table); |
|
| 167 | - } |
|
| 168 | - sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | - unset($GLOBALS[$table][$nom]); |
|
| 170 | - if (!isset($touch[$table])) { |
|
| 171 | - touch_meta($antidate, $table); |
|
| 172 | - $touch[$table] = false; |
|
| 173 | - } |
|
| 159 | + // section critique sur le cache: |
|
| 160 | + // l'invalider avant et apres la MAJ de la BD |
|
| 161 | + // c'est un peu moins bien qu'un vrai verrou mais ca suffira |
|
| 162 | + // et utiliser une statique pour eviter des acces disques a repetition |
|
| 163 | + static $touch = []; |
|
| 164 | + $antidate = time() - (_META_CACHE_TIME << 4); |
|
| 165 | + if (!isset($touch[$table])) { |
|
| 166 | + touch_meta($antidate, $table); |
|
| 167 | + } |
|
| 168 | + sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | + unset($GLOBALS[$table][$nom]); |
|
| 170 | + if (!isset($touch[$table])) { |
|
| 171 | + touch_meta($antidate, $table); |
|
| 172 | + $touch[$table] = false; |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -191,53 +191,53 @@ discard block |
||
| 191 | 191 | **/ |
| 192 | 192 | function ecrire_meta($nom, $valeur, $importable = null, $table = 'meta') { |
| 193 | 193 | |
| 194 | - static $touch = []; |
|
| 195 | - if (!$nom) { |
|
| 196 | - return; |
|
| 197 | - } |
|
| 198 | - include_spip('base/abstract_sql'); |
|
| 199 | - $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | - // table pas encore installee, travailler en php seulement |
|
| 201 | - if (!$res) { |
|
| 202 | - $GLOBALS[$table][$nom] = $valeur; |
|
| 194 | + static $touch = []; |
|
| 195 | + if (!$nom) { |
|
| 196 | + return; |
|
| 197 | + } |
|
| 198 | + include_spip('base/abstract_sql'); |
|
| 199 | + $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | + // table pas encore installee, travailler en php seulement |
|
| 201 | + if (!$res) { |
|
| 202 | + $GLOBALS[$table][$nom] = $valeur; |
|
| 203 | 203 | |
| 204 | - return; |
|
| 205 | - } |
|
| 206 | - $row = sql_fetch($res); |
|
| 207 | - sql_free($res); |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | + $row = sql_fetch($res); |
|
| 207 | + sql_free($res); |
|
| 208 | 208 | |
| 209 | - // ne pas invalider le cache si affectation a l'identique |
|
| 210 | - // (tant pis si impt aurait du changer) |
|
| 211 | - if ( |
|
| 212 | - $row and $valeur == $row['valeur'] |
|
| 213 | - and isset($GLOBALS[$table][$nom]) |
|
| 214 | - and $GLOBALS[$table][$nom] == $valeur |
|
| 215 | - ) { |
|
| 216 | - return; |
|
| 217 | - } |
|
| 209 | + // ne pas invalider le cache si affectation a l'identique |
|
| 210 | + // (tant pis si impt aurait du changer) |
|
| 211 | + if ( |
|
| 212 | + $row and $valeur == $row['valeur'] |
|
| 213 | + and isset($GLOBALS[$table][$nom]) |
|
| 214 | + and $GLOBALS[$table][$nom] == $valeur |
|
| 215 | + ) { |
|
| 216 | + return; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - $GLOBALS[$table][$nom] = $valeur; |
|
| 220 | - // cf effacer pour comprendre le double touch |
|
| 221 | - $antidate = time() - (_META_CACHE_TIME << 1); |
|
| 222 | - if (!isset($touch[$table])) { |
|
| 223 | - touch_meta($antidate, $table); |
|
| 224 | - } |
|
| 225 | - $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')]; |
|
| 226 | - // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
|
| 227 | - // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot |
|
| 228 | - // de lecture des descriptions des tables |
|
| 229 | - if ($importable and isset($row['impt'])) { |
|
| 230 | - $r['impt'] = sql_quote($importable, '', 'text'); |
|
| 231 | - } |
|
| 232 | - if ($row) { |
|
| 233 | - sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | - } else { |
|
| 235 | - sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | - } |
|
| 237 | - if (!isset($touch[$table])) { |
|
| 238 | - touch_meta($antidate, $table); |
|
| 239 | - $touch[$table] = false; |
|
| 240 | - } |
|
| 219 | + $GLOBALS[$table][$nom] = $valeur; |
|
| 220 | + // cf effacer pour comprendre le double touch |
|
| 221 | + $antidate = time() - (_META_CACHE_TIME << 1); |
|
| 222 | + if (!isset($touch[$table])) { |
|
| 223 | + touch_meta($antidate, $table); |
|
| 224 | + } |
|
| 225 | + $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')]; |
|
| 226 | + // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
|
| 227 | + // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot |
|
| 228 | + // de lecture des descriptions des tables |
|
| 229 | + if ($importable and isset($row['impt'])) { |
|
| 230 | + $r['impt'] = sql_quote($importable, '', 'text'); |
|
| 231 | + } |
|
| 232 | + if ($row) { |
|
| 233 | + sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | + } else { |
|
| 235 | + sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | + } |
|
| 237 | + if (!isset($touch[$table])) { |
|
| 238 | + touch_meta($antidate, $table); |
|
| 239 | + $touch[$table] = false; |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * Nom du fichier cache |
| 250 | 250 | **/ |
| 251 | 251 | function cache_meta($table = 'meta') { |
| 252 | - return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 252 | + return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | * @param string $table |
| 259 | 259 | */ |
| 260 | 260 | function installer_table_meta($table) { |
| 261 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 262 | - if (!$trouver_table("spip_$table")) { |
|
| 263 | - include_spip('base/auxiliaires'); |
|
| 264 | - include_spip('base/create'); |
|
| 265 | - creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false); |
|
| 266 | - $trouver_table(''); |
|
| 267 | - } |
|
| 268 | - lire_metas($table); |
|
| 261 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 262 | + if (!$trouver_table("spip_$table")) { |
|
| 263 | + include_spip('base/auxiliaires'); |
|
| 264 | + include_spip('base/create'); |
|
| 265 | + creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false); |
|
| 266 | + $trouver_table(''); |
|
| 267 | + } |
|
| 268 | + lire_metas($table); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -277,47 +277,47 @@ discard block |
||
| 277 | 277 | * @param bool $force |
| 278 | 278 | */ |
| 279 | 279 | function supprimer_table_meta($table, $force = false) { |
| 280 | - if ($table !== 'meta') { |
|
| 281 | - // Vérifier le contenu restant de la table |
|
| 282 | - $nb_variables = sql_countsel("spip_$table"); |
|
| 280 | + if ($table !== 'meta') { |
|
| 281 | + // Vérifier le contenu restant de la table |
|
| 282 | + $nb_variables = sql_countsel("spip_$table"); |
|
| 283 | 283 | |
| 284 | - // Supprimer si : |
|
| 285 | - // - la table est vide |
|
| 286 | - // - ou limitée à la variable charset |
|
| 287 | - // - ou qu'on force la suppression |
|
| 288 | - if ( |
|
| 289 | - $force |
|
| 290 | - or !$nb_variables |
|
| 291 | - or ( |
|
| 292 | - ($nb_variables == 1) |
|
| 293 | - and isset($GLOBALS[$table]['charset']) |
|
| 294 | - ) |
|
| 295 | - ) { |
|
| 296 | - // Supprimer la table des globaleset de la base |
|
| 297 | - unset($GLOBALS[$table]); |
|
| 298 | - sql_drop_table("spip_$table"); |
|
| 299 | - // Supprimer le fichier cache |
|
| 300 | - include_spip('inc/flock'); |
|
| 301 | - $cache = cache_meta($table); |
|
| 302 | - supprimer_fichier($cache); |
|
| 284 | + // Supprimer si : |
|
| 285 | + // - la table est vide |
|
| 286 | + // - ou limitée à la variable charset |
|
| 287 | + // - ou qu'on force la suppression |
|
| 288 | + if ( |
|
| 289 | + $force |
|
| 290 | + or !$nb_variables |
|
| 291 | + or ( |
|
| 292 | + ($nb_variables == 1) |
|
| 293 | + and isset($GLOBALS[$table]['charset']) |
|
| 294 | + ) |
|
| 295 | + ) { |
|
| 296 | + // Supprimer la table des globaleset de la base |
|
| 297 | + unset($GLOBALS[$table]); |
|
| 298 | + sql_drop_table("spip_$table"); |
|
| 299 | + // Supprimer le fichier cache |
|
| 300 | + include_spip('inc/flock'); |
|
| 301 | + $cache = cache_meta($table); |
|
| 302 | + supprimer_fichier($cache); |
|
| 303 | 303 | |
| 304 | - // vider le cache des tables |
|
| 305 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 306 | - $trouver_table(''); |
|
| 304 | + // vider le cache des tables |
|
| 305 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 306 | + $trouver_table(''); |
|
| 307 | 307 | |
| 308 | - // Supprimer la table de la liste des tables de configuration autres que spip_meta |
|
| 309 | - if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 310 | - $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 311 | - $cle = array_search($table, $liste); |
|
| 312 | - if ($cle !== false) { |
|
| 313 | - unset($liste[$cle]); |
|
| 314 | - if ($liste) { |
|
| 315 | - ecrire_meta('tables_config', serialize($liste)); |
|
| 316 | - } else { |
|
| 317 | - effacer_meta('tables_config'); |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 308 | + // Supprimer la table de la liste des tables de configuration autres que spip_meta |
|
| 309 | + if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 310 | + $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 311 | + $cle = array_search($table, $liste); |
|
| 312 | + if ($cle !== false) { |
|
| 313 | + unset($liste[$cle]); |
|
| 314 | + if ($liste) { |
|
| 315 | + ecrire_meta('tables_config', serialize($liste)); |
|
| 316 | + } else { |
|
| 317 | + effacer_meta('tables_config'); |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | 323 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | function generer_generer_url_arg($type, $p, $_id) { |
| 76 | 76 | if ($s = trouver_nom_serveur_distant($p)) { |
| 77 | 77 | // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
| 78 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 78 | + if (function_exists($f = 'generer_generer_url_'.$s)) { |
|
| 79 | 79 | return $f($type, $_id, $s); |
| 80 | 80 | } |
| 81 | 81 | if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | # exception des urls de documents sur un serveur distant... |
| 86 | 86 | if ($type == 'document') { |
| 87 | 87 | return |
| 88 | - "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | - "quete_meta('dir_img', $s) . \n\t" . |
|
| 88 | + "quete_meta('adresse_site', $s) . '/' .\n\t". |
|
| 89 | + "quete_meta('dir_img', $s) . \n\t". |
|
| 90 | 90 | "quete_fichier($_id,$s)"; |
| 91 | 91 | } |
| 92 | 92 | $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | function balise_URL_SITE_SPIP_dist($p) { |
| 232 | 232 | $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
| 233 | - $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 233 | + $p->code = 'spip_htmlspecialchars('.$p->code.')'; |
|
| 234 | 234 | $p->interdire_scripts = false; |
| 235 | 235 | |
| 236 | 236 | return $p; |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | if ($s = trouver_nom_serveur_distant($p)) { |
| 272 | 272 | // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
| 273 | 273 | // elle devra aussi traiter le cas derogatoire type=page |
| 274 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 274 | + if (function_exists($f = 'generer_generer_url_'.$s)) { |
|
| 275 | 275 | if ($args and $args !== "''") { |
| 276 | 276 | $code .= ", $args"; |
| 277 | 277 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $p->code = $code; |
| 280 | 280 | return $p; |
| 281 | 281 | } |
| 282 | - $s = 'connect=' . addslashes($s); |
|
| 282 | + $s = 'connect='.addslashes($s); |
|
| 283 | 283 | $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $code = "generer_url_public($code, $args$noentities)"; |
| 295 | 295 | } |
| 296 | 296 | $p->code = $code; |
| 297 | - spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 297 | + spip_log("Calcul url page : connect vaut $s ca donne :".$p->code." args $args", _LOG_INFO); |
|
| 298 | 298 | |
| 299 | 299 | #$p->interdire_scripts = true; |
| 300 | 300 | return $p; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $fonc .= ",$args$noentities"; |
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | - $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 341 | + $p->code = 'generer_url_ecrire('.$fonc.')'; |
|
| 342 | 342 | $p->interdire_scripts = false; |
| 343 | 343 | |
| 344 | 344 | return $p; |
@@ -373,17 +373,17 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $args = interprete_argument_balise(2, $p); |
| 375 | 375 | if ($args != "''" && $args !== null) { |
| 376 | - $p->code .= ',' . $args; |
|
| 376 | + $p->code .= ','.$args; |
|
| 377 | 377 | } |
| 378 | 378 | $redirect = interprete_argument_balise(3, $p); |
| 379 | 379 | if ($redirect != "''" && $redirect !== null) { |
| 380 | 380 | if ($args == "''" || $args === null) { |
| 381 | 381 | $p->code .= ",''"; |
| 382 | 382 | } |
| 383 | - $p->code .= ',' . $redirect; |
|
| 383 | + $p->code .= ','.$redirect; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 386 | + $p->code = 'generer_action_auteur('.$p->code.')'; |
|
| 387 | 387 | $p->interdire_scripts = false; |
| 388 | 388 | |
| 389 | 389 | return $p; |
@@ -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 | /** |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * Code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function generer_generer_url($type, $p) { |
| 40 | - $_id = interprete_argument_balise(1, $p); |
|
| 40 | + $_id = interprete_argument_balise(1, $p); |
|
| 41 | 41 | |
| 42 | - if (!$_id) { |
|
| 43 | - $primary = id_table_objet($type); |
|
| 44 | - $_id = champ_sql($primary, $p); |
|
| 45 | - } |
|
| 42 | + if (!$_id) { |
|
| 43 | + $primary = id_table_objet($type); |
|
| 44 | + $_id = champ_sql($primary, $p); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return generer_generer_url_arg($type, $p, $_id); |
|
| 47 | + return generer_generer_url_arg($type, $p, $_id); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -73,28 +73,28 @@ discard block |
||
| 73 | 73 | * Code compilé |
| 74 | 74 | **/ |
| 75 | 75 | function generer_generer_url_arg($type, $p, $_id) { |
| 76 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 77 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 78 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 79 | - return $f($type, $_id, $s); |
|
| 80 | - } |
|
| 81 | - if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
|
| 82 | - return null; |
|
| 83 | - } |
|
| 84 | - $s = _q($s); |
|
| 85 | - # exception des urls de documents sur un serveur distant... |
|
| 86 | - if ($type == 'document') { |
|
| 87 | - return |
|
| 88 | - "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | - "quete_meta('dir_img', $s) . \n\t" . |
|
| 90 | - "quete_fichier($_id,$s)"; |
|
| 91 | - } |
|
| 92 | - $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 93 | - } else { |
|
| 94 | - $s = ", '', '', true"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 76 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 77 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 78 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 79 | + return $f($type, $_id, $s); |
|
| 80 | + } |
|
| 81 | + if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
|
| 82 | + return null; |
|
| 83 | + } |
|
| 84 | + $s = _q($s); |
|
| 85 | + # exception des urls de documents sur un serveur distant... |
|
| 86 | + if ($type == 'document') { |
|
| 87 | + return |
|
| 88 | + "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | + "quete_meta('dir_img', $s) . \n\t" . |
|
| 90 | + "quete_fichier($_id,$s)"; |
|
| 91 | + } |
|
| 92 | + $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 93 | + } else { |
|
| 94 | + $s = ", '', '', true"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -119,27 +119,27 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function balise_URL__dist($p) { |
| 121 | 121 | |
| 122 | - $nom = $p->nom_champ; |
|
| 123 | - if ($nom === 'URL_') { |
|
| 124 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 125 | - erreur_squelette($msg, $p); |
|
| 126 | - $p->interdire_scripts = false; |
|
| 127 | - |
|
| 128 | - return $p; |
|
| 129 | - } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 130 | - return $f($p); |
|
| 131 | - } else { |
|
| 132 | - $nom = strtolower($nom); |
|
| 133 | - $code = generer_generer_url(substr($nom, 4), $p); |
|
| 134 | - $code = champ_sql($nom, $p, $code); |
|
| 135 | - $p->code = $code; |
|
| 136 | - if (!$p->etoile) { |
|
| 137 | - $p->code = "vider_url($code)"; |
|
| 138 | - } |
|
| 139 | - $p->interdire_scripts = false; |
|
| 140 | - |
|
| 141 | - return $p; |
|
| 142 | - } |
|
| 122 | + $nom = $p->nom_champ; |
|
| 123 | + if ($nom === 'URL_') { |
|
| 124 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 125 | + erreur_squelette($msg, $p); |
|
| 126 | + $p->interdire_scripts = false; |
|
| 127 | + |
|
| 128 | + return $p; |
|
| 129 | + } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 130 | + return $f($p); |
|
| 131 | + } else { |
|
| 132 | + $nom = strtolower($nom); |
|
| 133 | + $code = generer_generer_url(substr($nom, 4), $p); |
|
| 134 | + $code = champ_sql($nom, $p, $code); |
|
| 135 | + $p->code = $code; |
|
| 136 | + if (!$p->etoile) { |
|
| 137 | + $p->code = "vider_url($code)"; |
|
| 138 | + } |
|
| 139 | + $p->interdire_scripts = false; |
|
| 140 | + |
|
| 141 | + return $p; |
|
| 142 | + } |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -163,20 +163,20 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | function balise_URL_ARTICLE_dist($p) { |
| 165 | 165 | |
| 166 | - // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 167 | - if ($p->type_requete == 'syndic_articles') { |
|
| 168 | - $code = champ_sql('url', $p); |
|
| 169 | - } else { |
|
| 170 | - $code = generer_generer_url('article', $p); |
|
| 171 | - } |
|
| 166 | + // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 167 | + if ($p->type_requete == 'syndic_articles') { |
|
| 168 | + $code = champ_sql('url', $p); |
|
| 169 | + } else { |
|
| 170 | + $code = generer_generer_url('article', $p); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $p->code = $code; |
|
| 174 | - if (!$p->etoile) { |
|
| 175 | - $p->code = "vider_url($code)"; |
|
| 176 | - } |
|
| 177 | - $p->interdire_scripts = false; |
|
| 173 | + $p->code = $code; |
|
| 174 | + if (!$p->etoile) { |
|
| 175 | + $p->code = "vider_url($code)"; |
|
| 176 | + } |
|
| 177 | + $p->interdire_scripts = false; |
|
| 178 | 178 | |
| 179 | - return $p; |
|
| 179 | + return $p; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -196,21 +196,21 @@ discard block |
||
| 196 | 196 | * Pile complétée par le code à générer |
| 197 | 197 | */ |
| 198 | 198 | function balise_URL_SITE_dist($p) { |
| 199 | - $code = champ_sql('url_site', $p, ''); |
|
| 200 | - if (!$code) { |
|
| 201 | - $code = generer_generer_url('site', $p); |
|
| 202 | - if ($code === null) { |
|
| 203 | - return null; |
|
| 204 | - } |
|
| 205 | - } else { |
|
| 206 | - if (!$p->etoile) { |
|
| 207 | - $code = "calculer_url($code,'','url', \$connect)"; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - $p->code = $code; |
|
| 211 | - $p->interdire_scripts = false; |
|
| 212 | - |
|
| 213 | - return $p; |
|
| 199 | + $code = champ_sql('url_site', $p, ''); |
|
| 200 | + if (!$code) { |
|
| 201 | + $code = generer_generer_url('site', $p); |
|
| 202 | + if ($code === null) { |
|
| 203 | + return null; |
|
| 204 | + } |
|
| 205 | + } else { |
|
| 206 | + if (!$p->etoile) { |
|
| 207 | + $code = "calculer_url($code,'','url', \$connect)"; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + $p->code = $code; |
|
| 211 | + $p->interdire_scripts = false; |
|
| 212 | + |
|
| 213 | + return $p; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Autres balises URL_*, qui ne concernent pas une table |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | * Pile complétée par le code à générer |
| 230 | 230 | */ |
| 231 | 231 | function balise_URL_SITE_SPIP_dist($p) { |
| 232 | - $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 233 | - $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 234 | - $p->interdire_scripts = false; |
|
| 232 | + $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 233 | + $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 234 | + $p->interdire_scripts = false; |
|
| 235 | 235 | |
| 236 | - return $p; |
|
| 236 | + return $p; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
@@ -262,42 +262,42 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function balise_URL_PAGE_dist($p) { |
| 264 | 264 | |
| 265 | - $code = interprete_argument_balise(1, $p); |
|
| 266 | - $args = interprete_argument_balise(2, $p); |
|
| 267 | - if ($args == null) { |
|
| 268 | - $args = "''"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 272 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 273 | - // elle devra aussi traiter le cas derogatoire type=page |
|
| 274 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 275 | - if ($args and $args !== "''") { |
|
| 276 | - $code .= ", $args"; |
|
| 277 | - } |
|
| 278 | - $code = $f('page', $code, $s); |
|
| 279 | - $p->code = $code; |
|
| 280 | - return $p; |
|
| 281 | - } |
|
| 282 | - $s = 'connect=' . addslashes($s); |
|
| 283 | - $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - if (!$code) { |
|
| 287 | - $noentities = $p->etoile ? "'&'" : ''; |
|
| 288 | - $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 289 | - } else { |
|
| 290 | - if (!$args) { |
|
| 291 | - $args = "''"; |
|
| 292 | - } |
|
| 293 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 294 | - $code = "generer_url_public($code, $args$noentities)"; |
|
| 295 | - } |
|
| 296 | - $p->code = $code; |
|
| 297 | - spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 298 | - |
|
| 299 | - #$p->interdire_scripts = true; |
|
| 300 | - return $p; |
|
| 265 | + $code = interprete_argument_balise(1, $p); |
|
| 266 | + $args = interprete_argument_balise(2, $p); |
|
| 267 | + if ($args == null) { |
|
| 268 | + $args = "''"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 272 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 273 | + // elle devra aussi traiter le cas derogatoire type=page |
|
| 274 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 275 | + if ($args and $args !== "''") { |
|
| 276 | + $code .= ", $args"; |
|
| 277 | + } |
|
| 278 | + $code = $f('page', $code, $s); |
|
| 279 | + $p->code = $code; |
|
| 280 | + return $p; |
|
| 281 | + } |
|
| 282 | + $s = 'connect=' . addslashes($s); |
|
| 283 | + $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + if (!$code) { |
|
| 287 | + $noentities = $p->etoile ? "'&'" : ''; |
|
| 288 | + $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 289 | + } else { |
|
| 290 | + if (!$args) { |
|
| 291 | + $args = "''"; |
|
| 292 | + } |
|
| 293 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 294 | + $code = "generer_url_public($code, $args$noentities)"; |
|
| 295 | + } |
|
| 296 | + $p->code = $code; |
|
| 297 | + spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 298 | + |
|
| 299 | + #$p->interdire_scripts = true; |
|
| 300 | + return $p; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
@@ -324,24 +324,24 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | function balise_URL_ECRIRE_dist($p) { |
| 326 | 326 | |
| 327 | - $code = interprete_argument_balise(1, $p); |
|
| 328 | - if (!$code) { |
|
| 329 | - $fonc = "''"; |
|
| 330 | - } else { |
|
| 331 | - $fonc = $code; |
|
| 332 | - $args = interprete_argument_balise(2, $p); |
|
| 333 | - if ($args === null) { |
|
| 334 | - $args = "''"; |
|
| 335 | - } |
|
| 336 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 337 | - if (($args != "''") or $noentities) { |
|
| 338 | - $fonc .= ",$args$noentities"; |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 342 | - $p->interdire_scripts = false; |
|
| 343 | - |
|
| 344 | - return $p; |
|
| 327 | + $code = interprete_argument_balise(1, $p); |
|
| 328 | + if (!$code) { |
|
| 329 | + $fonc = "''"; |
|
| 330 | + } else { |
|
| 331 | + $fonc = $code; |
|
| 332 | + $args = interprete_argument_balise(2, $p); |
|
| 333 | + if ($args === null) { |
|
| 334 | + $args = "''"; |
|
| 335 | + } |
|
| 336 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 337 | + if (($args != "''") or $noentities) { |
|
| 338 | + $fonc .= ",$args$noentities"; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 342 | + $p->interdire_scripts = false; |
|
| 343 | + |
|
| 344 | + return $p; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
@@ -367,24 +367,24 @@ discard block |
||
| 367 | 367 | * Pile complétée par le code à générer |
| 368 | 368 | */ |
| 369 | 369 | function balise_URL_ACTION_AUTEUR_dist($p) { |
| 370 | - $p->descr['session'] = true; |
|
| 371 | - |
|
| 372 | - $p->code = interprete_argument_balise(1, $p); |
|
| 373 | - |
|
| 374 | - $args = interprete_argument_balise(2, $p); |
|
| 375 | - if ($args != "''" && $args !== null) { |
|
| 376 | - $p->code .= ',' . $args; |
|
| 377 | - } |
|
| 378 | - $redirect = interprete_argument_balise(3, $p); |
|
| 379 | - if ($redirect != "''" && $redirect !== null) { |
|
| 380 | - if ($args == "''" || $args === null) { |
|
| 381 | - $p->code .= ",''"; |
|
| 382 | - } |
|
| 383 | - $p->code .= ',' . $redirect; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 387 | - $p->interdire_scripts = false; |
|
| 388 | - |
|
| 389 | - return $p; |
|
| 370 | + $p->descr['session'] = true; |
|
| 371 | + |
|
| 372 | + $p->code = interprete_argument_balise(1, $p); |
|
| 373 | + |
|
| 374 | + $args = interprete_argument_balise(2, $p); |
|
| 375 | + if ($args != "''" && $args !== null) { |
|
| 376 | + $p->code .= ',' . $args; |
|
| 377 | + } |
|
| 378 | + $redirect = interprete_argument_balise(3, $p); |
|
| 379 | + if ($redirect != "''" && $redirect !== null) { |
|
| 380 | + if ($args == "''" || $args === null) { |
|
| 381 | + $p->code .= ",''"; |
|
| 382 | + } |
|
| 383 | + $p->code .= ',' . $redirect; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 387 | + $p->interdire_scripts = false; |
|
| 388 | + |
|
| 389 | + return $p; |
|
| 390 | 390 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * Pile complétée du code compilé |
| 42 | 42 | **/ |
| 43 | 43 | function balise_FORMULAIRE_ECRIRE_AUTEUR($p) { |
| 44 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 44 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -59,44 +59,44 @@ discard block |
||
| 59 | 59 | * - chaîne vide sinon (erreur ou non affichage). |
| 60 | 60 | */ |
| 61 | 61 | function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) { |
| 62 | - include_spip('inc/filtres'); |
|
| 63 | - // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 64 | - $id = intval($args[1]); |
|
| 65 | - if (!$args[0] and !$id) { |
|
| 66 | - $msg = [ |
|
| 67 | - 'zbug_champ_hors_motif', |
|
| 68 | - [ |
|
| 69 | - 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 70 | - 'motif' => 'AUTEURS/ARTICLES' |
|
| 71 | - ] |
|
| 72 | - ]; |
|
| 62 | + include_spip('inc/filtres'); |
|
| 63 | + // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 64 | + $id = intval($args[1]); |
|
| 65 | + if (!$args[0] and !$id) { |
|
| 66 | + $msg = [ |
|
| 67 | + 'zbug_champ_hors_motif', |
|
| 68 | + [ |
|
| 69 | + 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 70 | + 'motif' => 'AUTEURS/ARTICLES' |
|
| 71 | + ] |
|
| 72 | + ]; |
|
| 73 | 73 | |
| 74 | - erreur_squelette($msg, $context_compil); |
|
| 74 | + erreur_squelette($msg, $context_compil); |
|
| 75 | 75 | |
| 76 | - return ''; |
|
| 77 | - } |
|
| 78 | - // Si on est dans un contexte article, |
|
| 79 | - // sortir tous les mails des auteurs de l'article |
|
| 80 | - if (!$args[0] and $id) { |
|
| 81 | - $r = ''; |
|
| 82 | - $s = sql_allfetsel( |
|
| 83 | - 'email', |
|
| 84 | - 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 85 | - "A.email != '' AND L.id_objet=$id" |
|
| 86 | - ); |
|
| 87 | - foreach ($s as $row) { |
|
| 88 | - if (email_valide($row['email'])) { |
|
| 89 | - $r .= ', ' . $row['email']; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - $args[2] = substr($r, 2); |
|
| 93 | - } |
|
| 76 | + return ''; |
|
| 77 | + } |
|
| 78 | + // Si on est dans un contexte article, |
|
| 79 | + // sortir tous les mails des auteurs de l'article |
|
| 80 | + if (!$args[0] and $id) { |
|
| 81 | + $r = ''; |
|
| 82 | + $s = sql_allfetsel( |
|
| 83 | + 'email', |
|
| 84 | + 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 85 | + "A.email != '' AND L.id_objet=$id" |
|
| 86 | + ); |
|
| 87 | + foreach ($s as $row) { |
|
| 88 | + if (email_valide($row['email'])) { |
|
| 89 | + $r .= ', ' . $row['email']; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + $args[2] = substr($r, 2); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 96 | - if (!$args[2] or !email_valide($args[2])) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 95 | + // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 96 | + if (!$args[2] or !email_valide($args[2])) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - // OK |
|
| 101 | - return $args; |
|
| 100 | + // OK |
|
| 101 | + return $args; |
|
| 102 | 102 | } |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | ); |
| 87 | 87 | foreach ($s as $row) { |
| 88 | 88 | if (email_valide($row['email'])) { |
| 89 | - $r .= ', ' . $row['email']; |
|
| 89 | + $r .= ', '.$row['email']; |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | $args[2] = substr($r, 2); |
@@ -11,134 +11,134 @@ |
||
| 11 | 11 | // plage invalide en iso-8859-1 mais souvent utilisee quand meme (windows) |
| 12 | 12 | // cf. http://openweb.eu.org/articles/caracteres_illegaux/ |
| 13 | 13 | // voir aussi copie de ces valeurs dans inc/charsets.php |
| 14 | - 128 => 8364, |
|
| 15 | - 129 => 129 /* ?? */, |
|
| 16 | - 130 => 8218, |
|
| 17 | - 131 => 402, |
|
| 18 | - 132 => 8222, |
|
| 19 | - 133 => 8230, |
|
| 20 | - 134 => 8224, |
|
| 21 | - 135 => 8225, |
|
| 22 | - 136 => 710, |
|
| 23 | - 137 => 8240, |
|
| 24 | - 138 => 352, |
|
| 25 | - 139 => 8249, |
|
| 26 | - 140 => 338, |
|
| 27 | - 141 => 141 /* ?? */, |
|
| 28 | - 142 => 381, |
|
| 29 | - 143 => 143 /* ?? */, |
|
| 30 | - 144 => 144 /* ?? */, |
|
| 31 | - 145 => 8216, |
|
| 32 | - 146 => 8217, |
|
| 33 | - 147 => 8220, |
|
| 34 | - 148 => 8221, |
|
| 35 | - 149 => 8226, |
|
| 36 | - 150 => 8211, |
|
| 37 | - 151 => 8212, |
|
| 38 | - 152 => 732, |
|
| 39 | - 153 => 8482, |
|
| 40 | - 154 => 353, |
|
| 41 | - 155 => 8250, |
|
| 42 | - 156 => 339, |
|
| 43 | - 157 => 157 /* ?? */, |
|
| 44 | - 158 => 382, |
|
| 45 | - 159 => 376, |
|
| 14 | + 128 => 8364, |
|
| 15 | + 129 => 129 /* ?? */, |
|
| 16 | + 130 => 8218, |
|
| 17 | + 131 => 402, |
|
| 18 | + 132 => 8222, |
|
| 19 | + 133 => 8230, |
|
| 20 | + 134 => 8224, |
|
| 21 | + 135 => 8225, |
|
| 22 | + 136 => 710, |
|
| 23 | + 137 => 8240, |
|
| 24 | + 138 => 352, |
|
| 25 | + 139 => 8249, |
|
| 26 | + 140 => 338, |
|
| 27 | + 141 => 141 /* ?? */, |
|
| 28 | + 142 => 381, |
|
| 29 | + 143 => 143 /* ?? */, |
|
| 30 | + 144 => 144 /* ?? */, |
|
| 31 | + 145 => 8216, |
|
| 32 | + 146 => 8217, |
|
| 33 | + 147 => 8220, |
|
| 34 | + 148 => 8221, |
|
| 35 | + 149 => 8226, |
|
| 36 | + 150 => 8211, |
|
| 37 | + 151 => 8212, |
|
| 38 | + 152 => 732, |
|
| 39 | + 153 => 8482, |
|
| 40 | + 154 => 353, |
|
| 41 | + 155 => 8250, |
|
| 42 | + 156 => 339, |
|
| 43 | + 157 => 157 /* ?? */, |
|
| 44 | + 158 => 382, |
|
| 45 | + 159 => 376, |
|
| 46 | 46 | |
| 47 | - 160 => 160, |
|
| 48 | - 161 => 161, |
|
| 49 | - 162 => 162, |
|
| 50 | - 163 => 163, |
|
| 51 | - 164 => 164, |
|
| 52 | - 165 => 165, |
|
| 53 | - 166 => 166, |
|
| 54 | - 167 => 167, |
|
| 55 | - 168 => 168, |
|
| 56 | - 169 => 169, |
|
| 57 | - 170 => 170, |
|
| 58 | - 171 => 171, |
|
| 59 | - 172 => 172, |
|
| 60 | - 173 => 173, |
|
| 61 | - 174 => 174, |
|
| 62 | - 175 => 175, |
|
| 63 | - 176 => 176, |
|
| 64 | - 177 => 177, |
|
| 65 | - 178 => 178, |
|
| 66 | - 179 => 179, |
|
| 67 | - 180 => 180, |
|
| 68 | - 181 => 181, |
|
| 69 | - 182 => 182, |
|
| 70 | - 183 => 183, |
|
| 71 | - 184 => 184, |
|
| 72 | - 185 => 185, |
|
| 73 | - 186 => 186, |
|
| 74 | - 187 => 187, |
|
| 75 | - 188 => 188, |
|
| 76 | - 189 => 189, |
|
| 77 | - 190 => 190, |
|
| 78 | - 191 => 191, |
|
| 79 | - 192 => 192, |
|
| 80 | - 193 => 193, |
|
| 81 | - 194 => 194, |
|
| 82 | - 195 => 195, |
|
| 83 | - 196 => 196, |
|
| 84 | - 197 => 197, |
|
| 85 | - 198 => 198, |
|
| 86 | - 199 => 199, |
|
| 87 | - 200 => 200, |
|
| 88 | - 201 => 201, |
|
| 89 | - 202 => 202, |
|
| 90 | - 203 => 203, |
|
| 91 | - 204 => 204, |
|
| 92 | - 205 => 205, |
|
| 93 | - 206 => 206, |
|
| 94 | - 207 => 207, |
|
| 95 | - 208 => 208, |
|
| 96 | - 209 => 209, |
|
| 97 | - 210 => 210, |
|
| 98 | - 211 => 211, |
|
| 99 | - 212 => 212, |
|
| 100 | - 213 => 213, |
|
| 101 | - 214 => 214, |
|
| 102 | - 215 => 215, |
|
| 103 | - 216 => 216, |
|
| 104 | - 217 => 217, |
|
| 105 | - 218 => 218, |
|
| 106 | - 219 => 219, |
|
| 107 | - 220 => 220, |
|
| 108 | - 221 => 221, |
|
| 109 | - 222 => 222, |
|
| 110 | - 223 => 223, |
|
| 111 | - 224 => 224, |
|
| 112 | - 225 => 225, |
|
| 113 | - 226 => 226, |
|
| 114 | - 227 => 227, |
|
| 115 | - 228 => 228, |
|
| 116 | - 229 => 229, |
|
| 117 | - 230 => 230, |
|
| 118 | - 231 => 231, |
|
| 119 | - 232 => 232, |
|
| 120 | - 233 => 233, |
|
| 121 | - 234 => 234, |
|
| 122 | - 235 => 235, |
|
| 123 | - 236 => 236, |
|
| 124 | - 237 => 237, |
|
| 125 | - 238 => 238, |
|
| 126 | - 239 => 239, |
|
| 127 | - 240 => 240, |
|
| 128 | - 241 => 241, |
|
| 129 | - 242 => 242, |
|
| 130 | - 243 => 243, |
|
| 131 | - 244 => 244, |
|
| 132 | - 245 => 245, |
|
| 133 | - 246 => 246, |
|
| 134 | - 247 => 247, |
|
| 135 | - 248 => 248, |
|
| 136 | - 249 => 249, |
|
| 137 | - 250 => 250, |
|
| 138 | - 251 => 251, |
|
| 139 | - 252 => 252, |
|
| 140 | - 253 => 253, |
|
| 141 | - 254 => 254, |
|
| 142 | - 255 => 255 |
|
| 47 | + 160 => 160, |
|
| 48 | + 161 => 161, |
|
| 49 | + 162 => 162, |
|
| 50 | + 163 => 163, |
|
| 51 | + 164 => 164, |
|
| 52 | + 165 => 165, |
|
| 53 | + 166 => 166, |
|
| 54 | + 167 => 167, |
|
| 55 | + 168 => 168, |
|
| 56 | + 169 => 169, |
|
| 57 | + 170 => 170, |
|
| 58 | + 171 => 171, |
|
| 59 | + 172 => 172, |
|
| 60 | + 173 => 173, |
|
| 61 | + 174 => 174, |
|
| 62 | + 175 => 175, |
|
| 63 | + 176 => 176, |
|
| 64 | + 177 => 177, |
|
| 65 | + 178 => 178, |
|
| 66 | + 179 => 179, |
|
| 67 | + 180 => 180, |
|
| 68 | + 181 => 181, |
|
| 69 | + 182 => 182, |
|
| 70 | + 183 => 183, |
|
| 71 | + 184 => 184, |
|
| 72 | + 185 => 185, |
|
| 73 | + 186 => 186, |
|
| 74 | + 187 => 187, |
|
| 75 | + 188 => 188, |
|
| 76 | + 189 => 189, |
|
| 77 | + 190 => 190, |
|
| 78 | + 191 => 191, |
|
| 79 | + 192 => 192, |
|
| 80 | + 193 => 193, |
|
| 81 | + 194 => 194, |
|
| 82 | + 195 => 195, |
|
| 83 | + 196 => 196, |
|
| 84 | + 197 => 197, |
|
| 85 | + 198 => 198, |
|
| 86 | + 199 => 199, |
|
| 87 | + 200 => 200, |
|
| 88 | + 201 => 201, |
|
| 89 | + 202 => 202, |
|
| 90 | + 203 => 203, |
|
| 91 | + 204 => 204, |
|
| 92 | + 205 => 205, |
|
| 93 | + 206 => 206, |
|
| 94 | + 207 => 207, |
|
| 95 | + 208 => 208, |
|
| 96 | + 209 => 209, |
|
| 97 | + 210 => 210, |
|
| 98 | + 211 => 211, |
|
| 99 | + 212 => 212, |
|
| 100 | + 213 => 213, |
|
| 101 | + 214 => 214, |
|
| 102 | + 215 => 215, |
|
| 103 | + 216 => 216, |
|
| 104 | + 217 => 217, |
|
| 105 | + 218 => 218, |
|
| 106 | + 219 => 219, |
|
| 107 | + 220 => 220, |
|
| 108 | + 221 => 221, |
|
| 109 | + 222 => 222, |
|
| 110 | + 223 => 223, |
|
| 111 | + 224 => 224, |
|
| 112 | + 225 => 225, |
|
| 113 | + 226 => 226, |
|
| 114 | + 227 => 227, |
|
| 115 | + 228 => 228, |
|
| 116 | + 229 => 229, |
|
| 117 | + 230 => 230, |
|
| 118 | + 231 => 231, |
|
| 119 | + 232 => 232, |
|
| 120 | + 233 => 233, |
|
| 121 | + 234 => 234, |
|
| 122 | + 235 => 235, |
|
| 123 | + 236 => 236, |
|
| 124 | + 237 => 237, |
|
| 125 | + 238 => 238, |
|
| 126 | + 239 => 239, |
|
| 127 | + 240 => 240, |
|
| 128 | + 241 => 241, |
|
| 129 | + 242 => 242, |
|
| 130 | + 243 => 243, |
|
| 131 | + 244 => 244, |
|
| 132 | + 245 => 245, |
|
| 133 | + 246 => 246, |
|
| 134 | + 247 => 247, |
|
| 135 | + 248 => 248, |
|
| 136 | + 249 => 249, |
|
| 137 | + 250 => 250, |
|
| 138 | + 251 => 251, |
|
| 139 | + 252 => 252, |
|
| 140 | + 253 => 253, |
|
| 141 | + 254 => 254, |
|
| 142 | + 255 => 255 |
|
| 143 | 143 | |
| 144 | 144 | ]; |
@@ -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 | load_charset('iso-8859-1'); |
@@ -27,61 +27,61 @@ discard block |
||
| 27 | 27 | $trans = $GLOBALS['CHARSET']['iso-8859-1']; |
| 28 | 28 | |
| 29 | 29 | $mod = [ |
| 30 | - 0xA0 => 0x00A0, |
|
| 31 | - 0xA4 => 0x00A4, |
|
| 32 | - 0xAC => 0x060C, |
|
| 33 | - 0xAD => 0x00AD, |
|
| 34 | - 0xBB => 0x061B, |
|
| 35 | - 0xBF => 0x061F, |
|
| 36 | - 0xC1 => 0x0621, |
|
| 37 | - 0xC2 => 0x0622, |
|
| 38 | - 0xC3 => 0x0623, |
|
| 39 | - 0xC4 => 0x0624, |
|
| 40 | - 0xC5 => 0x0625, |
|
| 41 | - 0xC6 => 0x0626, |
|
| 42 | - 0xC7 => 0x0627, |
|
| 43 | - 0xC8 => 0x0628, |
|
| 44 | - 0xC9 => 0x0629, |
|
| 45 | - 0xCA => 0x062A, |
|
| 46 | - 0xCB => 0x062B, |
|
| 47 | - 0xCC => 0x062C, |
|
| 48 | - 0xCD => 0x062D, |
|
| 49 | - 0xCE => 0x062E, |
|
| 50 | - 0xCF => 0x062F, |
|
| 51 | - 0xD0 => 0x0630, |
|
| 52 | - 0xD1 => 0x0631, |
|
| 53 | - 0xD2 => 0x0632, |
|
| 54 | - 0xD3 => 0x0633, |
|
| 55 | - 0xD4 => 0x0634, |
|
| 56 | - 0xD5 => 0x0635, |
|
| 57 | - 0xD6 => 0x0636, |
|
| 58 | - 0xD7 => 0x0637, |
|
| 59 | - 0xD8 => 0x0638, |
|
| 60 | - 0xD9 => 0x0639, |
|
| 61 | - 0xDA => 0x063A, |
|
| 62 | - 0xE0 => 0x0640, |
|
| 63 | - 0xE1 => 0x0641, |
|
| 64 | - 0xE2 => 0x0642, |
|
| 65 | - 0xE3 => 0x0643, |
|
| 66 | - 0xE4 => 0x0644, |
|
| 67 | - 0xE5 => 0x0645, |
|
| 68 | - 0xE6 => 0x0646, |
|
| 69 | - 0xE7 => 0x0647, |
|
| 70 | - 0xE8 => 0x0648, |
|
| 71 | - 0xE9 => 0x0649, |
|
| 72 | - 0xEA => 0x064A, |
|
| 73 | - 0xEB => 0x064B, |
|
| 74 | - 0xEC => 0x064C, |
|
| 75 | - 0xED => 0x064D, |
|
| 76 | - 0xEE => 0x064E, |
|
| 77 | - 0xEF => 0x064F, |
|
| 78 | - 0xF0 => 0x0650, |
|
| 79 | - 0xF1 => 0x0651, |
|
| 80 | - 0xF2 => 0x0652 |
|
| 30 | + 0xA0 => 0x00A0, |
|
| 31 | + 0xA4 => 0x00A4, |
|
| 32 | + 0xAC => 0x060C, |
|
| 33 | + 0xAD => 0x00AD, |
|
| 34 | + 0xBB => 0x061B, |
|
| 35 | + 0xBF => 0x061F, |
|
| 36 | + 0xC1 => 0x0621, |
|
| 37 | + 0xC2 => 0x0622, |
|
| 38 | + 0xC3 => 0x0623, |
|
| 39 | + 0xC4 => 0x0624, |
|
| 40 | + 0xC5 => 0x0625, |
|
| 41 | + 0xC6 => 0x0626, |
|
| 42 | + 0xC7 => 0x0627, |
|
| 43 | + 0xC8 => 0x0628, |
|
| 44 | + 0xC9 => 0x0629, |
|
| 45 | + 0xCA => 0x062A, |
|
| 46 | + 0xCB => 0x062B, |
|
| 47 | + 0xCC => 0x062C, |
|
| 48 | + 0xCD => 0x062D, |
|
| 49 | + 0xCE => 0x062E, |
|
| 50 | + 0xCF => 0x062F, |
|
| 51 | + 0xD0 => 0x0630, |
|
| 52 | + 0xD1 => 0x0631, |
|
| 53 | + 0xD2 => 0x0632, |
|
| 54 | + 0xD3 => 0x0633, |
|
| 55 | + 0xD4 => 0x0634, |
|
| 56 | + 0xD5 => 0x0635, |
|
| 57 | + 0xD6 => 0x0636, |
|
| 58 | + 0xD7 => 0x0637, |
|
| 59 | + 0xD8 => 0x0638, |
|
| 60 | + 0xD9 => 0x0639, |
|
| 61 | + 0xDA => 0x063A, |
|
| 62 | + 0xE0 => 0x0640, |
|
| 63 | + 0xE1 => 0x0641, |
|
| 64 | + 0xE2 => 0x0642, |
|
| 65 | + 0xE3 => 0x0643, |
|
| 66 | + 0xE4 => 0x0644, |
|
| 67 | + 0xE5 => 0x0645, |
|
| 68 | + 0xE6 => 0x0646, |
|
| 69 | + 0xE7 => 0x0647, |
|
| 70 | + 0xE8 => 0x0648, |
|
| 71 | + 0xE9 => 0x0649, |
|
| 72 | + 0xEA => 0x064A, |
|
| 73 | + 0xEB => 0x064B, |
|
| 74 | + 0xEC => 0x064C, |
|
| 75 | + 0xED => 0x064D, |
|
| 76 | + 0xEE => 0x064E, |
|
| 77 | + 0xEF => 0x064F, |
|
| 78 | + 0xF0 => 0x0650, |
|
| 79 | + 0xF1 => 0x0651, |
|
| 80 | + 0xF2 => 0x0652 |
|
| 81 | 81 | ]; |
| 82 | 82 | |
| 83 | 83 | foreach ($mod as $num => $val) { |
| 84 | - $trans[$num] = $val; |
|
| 84 | + $trans[$num] = $val; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $GLOBALS['CHARSET']['iso-8859-6'] = $trans; |
@@ -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 | load_charset('translit'); |
@@ -28,151 +28,151 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $translit_c = [ |
| 30 | 30 | // vietnamien |
| 31 | - 225 => "a'", |
|
| 32 | - 224 => 'a`', |
|
| 33 | - 7843 => 'a?', |
|
| 34 | - 227 => 'a~', |
|
| 35 | - 7841 => 'a.', |
|
| 36 | - 226 => 'a^', |
|
| 37 | - 7845 => "a^'", |
|
| 38 | - 7847 => 'a^`', |
|
| 39 | - 7849 => 'a^?', |
|
| 40 | - 7851 => 'a^~', |
|
| 41 | - 7853 => 'a^.', |
|
| 42 | - 259 => 'a(', |
|
| 43 | - 7855 => "a('", |
|
| 44 | - 7857 => 'a(`', |
|
| 45 | - 7859 => 'a(?', |
|
| 46 | - 7861 => 'a(~', |
|
| 47 | - 7863 => 'a(.', |
|
| 48 | - 193 => "A'", |
|
| 49 | - 192 => 'A`', |
|
| 50 | - 7842 => 'A?', |
|
| 51 | - 195 => 'A~', |
|
| 52 | - 7840 => 'A.', |
|
| 53 | - 194 => 'A^', |
|
| 54 | - 7844 => "A^'", |
|
| 55 | - 7846 => 'A^`', |
|
| 56 | - 7848 => 'A^?', |
|
| 57 | - 7850 => 'A^~', |
|
| 58 | - 7852 => 'A^.', |
|
| 59 | - 258 => 'A(', |
|
| 60 | - 7854 => "A('", |
|
| 61 | - 7856 => 'A(`', |
|
| 62 | - 7858 => 'A(?', |
|
| 63 | - 7860 => 'A(~', |
|
| 64 | - 7862 => 'A(.', |
|
| 65 | - 233 => "e'", |
|
| 66 | - 232 => 'e`', |
|
| 67 | - 7867 => 'e?', |
|
| 68 | - 7869 => 'e~', |
|
| 69 | - 7865 => 'e.', |
|
| 70 | - 234 => 'e^', |
|
| 71 | - 7871 => "e^'", |
|
| 72 | - 7873 => 'e^`', |
|
| 73 | - 7875 => 'e^?', |
|
| 74 | - 7877 => 'e^~', |
|
| 75 | - 7879 => 'e^.', |
|
| 76 | - 201 => "E'", |
|
| 77 | - 200 => 'E`', |
|
| 78 | - 7866 => 'E?', |
|
| 79 | - 7868 => 'E~', |
|
| 80 | - 7864 => 'E.', |
|
| 81 | - 202 => 'E^', |
|
| 82 | - 7870 => "E^'", |
|
| 83 | - 7872 => 'E^`', |
|
| 84 | - 7874 => 'E^?', |
|
| 85 | - 7876 => 'E^~', |
|
| 86 | - 7878 => 'E^.', |
|
| 87 | - 237 => "i'", |
|
| 88 | - 236 => 'i`', |
|
| 89 | - 7881 => 'i?', |
|
| 90 | - 297 => 'i~', |
|
| 91 | - 7883 => 'i.', |
|
| 92 | - 205 => "I'", |
|
| 93 | - 204 => 'I`', |
|
| 94 | - 7880 => 'I?', |
|
| 95 | - 296 => 'I~', |
|
| 96 | - 7882 => 'I.', |
|
| 97 | - 243 => "o'", |
|
| 98 | - 242 => 'o`', |
|
| 99 | - 7887 => 'o?', |
|
| 100 | - 245 => 'o~', |
|
| 101 | - 7885 => 'o.', |
|
| 102 | - 244 => 'o^', |
|
| 103 | - 7889 => "o^'", |
|
| 104 | - 7891 => 'o^`', |
|
| 105 | - 7893 => 'o^?', |
|
| 106 | - 7895 => 'o^~', |
|
| 107 | - 7897 => 'o^.', |
|
| 108 | - 417 => 'o+', |
|
| 109 | - 7899 => "o+'", |
|
| 110 | - 7901 => 'o+`', |
|
| 111 | - 7903 => 'o+?', |
|
| 112 | - 7905 => 'o+~', |
|
| 113 | - 7907 => 'o+.', |
|
| 114 | - 211 => "O'", |
|
| 115 | - 210 => 'O`', |
|
| 116 | - 7886 => 'O?', |
|
| 117 | - 213 => 'O~', |
|
| 118 | - 7884 => 'O.', |
|
| 119 | - 212 => 'O^', |
|
| 120 | - 7888 => "O^'", |
|
| 121 | - 7890 => 'O^`', |
|
| 122 | - 7892 => 'O^?', |
|
| 123 | - 7894 => 'O^~', |
|
| 124 | - 7896 => 'O^.', |
|
| 125 | - 416 => 'O+', |
|
| 126 | - 7898 => "O+'", |
|
| 127 | - 7900 => 'O+`', |
|
| 128 | - 7902 => 'O+?', |
|
| 129 | - 7904 => 'O+~', |
|
| 130 | - 7906 => 'O+.', |
|
| 131 | - 250 => "u'", |
|
| 132 | - 249 => 'u`', |
|
| 133 | - 7911 => 'u?', |
|
| 134 | - 361 => 'u~', |
|
| 135 | - 7909 => 'u.', |
|
| 136 | - 432 => 'u+', |
|
| 137 | - 7913 => "u+'", |
|
| 138 | - 7915 => 'u+`', |
|
| 139 | - 7917 => 'u+?', |
|
| 140 | - 7919 => 'u+~', |
|
| 141 | - 7921 => 'u+.', |
|
| 142 | - 218 => "U'", |
|
| 143 | - 217 => 'U`', |
|
| 144 | - 7910 => 'U?', |
|
| 145 | - 360 => 'U~', |
|
| 146 | - 7908 => 'U.', |
|
| 147 | - 431 => 'U+', |
|
| 148 | - 7912 => "U+'", |
|
| 149 | - 7914 => 'U+`', |
|
| 150 | - 7916 => 'U+?', |
|
| 151 | - 7918 => 'U+~', |
|
| 152 | - 7920 => 'U+.', |
|
| 153 | - 253 => "y'", |
|
| 154 | - 7923 => 'y`', |
|
| 155 | - 7927 => 'y?', |
|
| 156 | - 7929 => 'y~', |
|
| 157 | - 7925 => 'y.', |
|
| 158 | - 221 => "Y'", |
|
| 159 | - 7922 => 'Y`', |
|
| 160 | - 7926 => 'Y?', |
|
| 161 | - 7928 => 'Y~', |
|
| 162 | - 7924 => 'Y.', |
|
| 163 | - 273 => 'd-', |
|
| 164 | - 208 => 'D-', |
|
| 31 | + 225 => "a'", |
|
| 32 | + 224 => 'a`', |
|
| 33 | + 7843 => 'a?', |
|
| 34 | + 227 => 'a~', |
|
| 35 | + 7841 => 'a.', |
|
| 36 | + 226 => 'a^', |
|
| 37 | + 7845 => "a^'", |
|
| 38 | + 7847 => 'a^`', |
|
| 39 | + 7849 => 'a^?', |
|
| 40 | + 7851 => 'a^~', |
|
| 41 | + 7853 => 'a^.', |
|
| 42 | + 259 => 'a(', |
|
| 43 | + 7855 => "a('", |
|
| 44 | + 7857 => 'a(`', |
|
| 45 | + 7859 => 'a(?', |
|
| 46 | + 7861 => 'a(~', |
|
| 47 | + 7863 => 'a(.', |
|
| 48 | + 193 => "A'", |
|
| 49 | + 192 => 'A`', |
|
| 50 | + 7842 => 'A?', |
|
| 51 | + 195 => 'A~', |
|
| 52 | + 7840 => 'A.', |
|
| 53 | + 194 => 'A^', |
|
| 54 | + 7844 => "A^'", |
|
| 55 | + 7846 => 'A^`', |
|
| 56 | + 7848 => 'A^?', |
|
| 57 | + 7850 => 'A^~', |
|
| 58 | + 7852 => 'A^.', |
|
| 59 | + 258 => 'A(', |
|
| 60 | + 7854 => "A('", |
|
| 61 | + 7856 => 'A(`', |
|
| 62 | + 7858 => 'A(?', |
|
| 63 | + 7860 => 'A(~', |
|
| 64 | + 7862 => 'A(.', |
|
| 65 | + 233 => "e'", |
|
| 66 | + 232 => 'e`', |
|
| 67 | + 7867 => 'e?', |
|
| 68 | + 7869 => 'e~', |
|
| 69 | + 7865 => 'e.', |
|
| 70 | + 234 => 'e^', |
|
| 71 | + 7871 => "e^'", |
|
| 72 | + 7873 => 'e^`', |
|
| 73 | + 7875 => 'e^?', |
|
| 74 | + 7877 => 'e^~', |
|
| 75 | + 7879 => 'e^.', |
|
| 76 | + 201 => "E'", |
|
| 77 | + 200 => 'E`', |
|
| 78 | + 7866 => 'E?', |
|
| 79 | + 7868 => 'E~', |
|
| 80 | + 7864 => 'E.', |
|
| 81 | + 202 => 'E^', |
|
| 82 | + 7870 => "E^'", |
|
| 83 | + 7872 => 'E^`', |
|
| 84 | + 7874 => 'E^?', |
|
| 85 | + 7876 => 'E^~', |
|
| 86 | + 7878 => 'E^.', |
|
| 87 | + 237 => "i'", |
|
| 88 | + 236 => 'i`', |
|
| 89 | + 7881 => 'i?', |
|
| 90 | + 297 => 'i~', |
|
| 91 | + 7883 => 'i.', |
|
| 92 | + 205 => "I'", |
|
| 93 | + 204 => 'I`', |
|
| 94 | + 7880 => 'I?', |
|
| 95 | + 296 => 'I~', |
|
| 96 | + 7882 => 'I.', |
|
| 97 | + 243 => "o'", |
|
| 98 | + 242 => 'o`', |
|
| 99 | + 7887 => 'o?', |
|
| 100 | + 245 => 'o~', |
|
| 101 | + 7885 => 'o.', |
|
| 102 | + 244 => 'o^', |
|
| 103 | + 7889 => "o^'", |
|
| 104 | + 7891 => 'o^`', |
|
| 105 | + 7893 => 'o^?', |
|
| 106 | + 7895 => 'o^~', |
|
| 107 | + 7897 => 'o^.', |
|
| 108 | + 417 => 'o+', |
|
| 109 | + 7899 => "o+'", |
|
| 110 | + 7901 => 'o+`', |
|
| 111 | + 7903 => 'o+?', |
|
| 112 | + 7905 => 'o+~', |
|
| 113 | + 7907 => 'o+.', |
|
| 114 | + 211 => "O'", |
|
| 115 | + 210 => 'O`', |
|
| 116 | + 7886 => 'O?', |
|
| 117 | + 213 => 'O~', |
|
| 118 | + 7884 => 'O.', |
|
| 119 | + 212 => 'O^', |
|
| 120 | + 7888 => "O^'", |
|
| 121 | + 7890 => 'O^`', |
|
| 122 | + 7892 => 'O^?', |
|
| 123 | + 7894 => 'O^~', |
|
| 124 | + 7896 => 'O^.', |
|
| 125 | + 416 => 'O+', |
|
| 126 | + 7898 => "O+'", |
|
| 127 | + 7900 => 'O+`', |
|
| 128 | + 7902 => 'O+?', |
|
| 129 | + 7904 => 'O+~', |
|
| 130 | + 7906 => 'O+.', |
|
| 131 | + 250 => "u'", |
|
| 132 | + 249 => 'u`', |
|
| 133 | + 7911 => 'u?', |
|
| 134 | + 361 => 'u~', |
|
| 135 | + 7909 => 'u.', |
|
| 136 | + 432 => 'u+', |
|
| 137 | + 7913 => "u+'", |
|
| 138 | + 7915 => 'u+`', |
|
| 139 | + 7917 => 'u+?', |
|
| 140 | + 7919 => 'u+~', |
|
| 141 | + 7921 => 'u+.', |
|
| 142 | + 218 => "U'", |
|
| 143 | + 217 => 'U`', |
|
| 144 | + 7910 => 'U?', |
|
| 145 | + 360 => 'U~', |
|
| 146 | + 7908 => 'U.', |
|
| 147 | + 431 => 'U+', |
|
| 148 | + 7912 => "U+'", |
|
| 149 | + 7914 => 'U+`', |
|
| 150 | + 7916 => 'U+?', |
|
| 151 | + 7918 => 'U+~', |
|
| 152 | + 7920 => 'U+.', |
|
| 153 | + 253 => "y'", |
|
| 154 | + 7923 => 'y`', |
|
| 155 | + 7927 => 'y?', |
|
| 156 | + 7929 => 'y~', |
|
| 157 | + 7925 => 'y.', |
|
| 158 | + 221 => "Y'", |
|
| 159 | + 7922 => 'Y`', |
|
| 160 | + 7926 => 'Y?', |
|
| 161 | + 7928 => 'Y~', |
|
| 162 | + 7924 => 'Y.', |
|
| 163 | + 273 => 'd-', |
|
| 164 | + 208 => 'D-', |
|
| 165 | 165 | |
| 166 | 166 | // allemand |
| 167 | - 228 => 'ae', |
|
| 168 | - 246 => 'oe', |
|
| 169 | - 252 => 'ue', |
|
| 170 | - 196 => 'Ae', |
|
| 171 | - 214 => 'Oe', |
|
| 172 | - 220 => 'Ue' |
|
| 167 | + 228 => 'ae', |
|
| 168 | + 246 => 'oe', |
|
| 169 | + 252 => 'ue', |
|
| 170 | + 196 => 'Ae', |
|
| 171 | + 214 => 'Oe', |
|
| 172 | + 220 => 'Ue' |
|
| 173 | 173 | ]; |
| 174 | 174 | |
| 175 | 175 | foreach ($translit_c as $u => $t) { |
| 176 | - $trans[$u] = $t; |
|
| 176 | + $trans[$u] = $t; |
|
| 177 | 177 | } |
| 178 | 178 | $GLOBALS['CHARSET']['translitcomplexe'] = $trans; |