@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/charsets'); |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @return string Fonction PHP correspondante du filtre |
| 43 | 43 | */ |
| 44 | 44 | function charger_filtre($fonc, $default = 'filtre_identite_dist') { |
| 45 | - include_spip('public/parametrer'); // inclure les fichiers fonctions |
|
| 46 | - return chercher_filtre($fonc, $default); |
|
| 45 | + include_spip('public/parametrer'); // inclure les fichiers fonctions |
|
| 46 | + return chercher_filtre($fonc, $default); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -75,36 +75,36 @@ discard block |
||
| 75 | 75 | * Fonction PHP correspondante du filtre demandé |
| 76 | 76 | */ |
| 77 | 77 | function chercher_filtre($fonc, $default = null) { |
| 78 | - if (!$fonc) { |
|
| 79 | - return $default; |
|
| 80 | - } |
|
| 81 | - // Cas des types mime, sans confondre avec les appels de fonction de classe |
|
| 82 | - // Foo::Bar |
|
| 83 | - // qui peuvent etre avec un namespace : space\Foo::Bar |
|
| 84 | - if (preg_match(',^[\w]+/,', $fonc)) { |
|
| 85 | - $nom = preg_replace(',\W,', '_', $fonc); |
|
| 86 | - $f = chercher_filtre($nom); |
|
| 87 | - // cas du sous-type MIME sans filtre associe, passer au type: |
|
| 88 | - // si filtre_text_plain pas defini, passe a filtre_text |
|
| 89 | - if (!$f and $nom !== $fonc) { |
|
| 90 | - $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc)); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - return $f; |
|
| 94 | - } |
|
| 95 | - foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) { |
|
| 96 | - trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
|
| 97 | - // fonction ou name\space\fonction |
|
| 98 | - if (is_callable($f)) { |
|
| 99 | - return $f; |
|
| 100 | - } |
|
| 101 | - // méthode statique d'une classe Classe::methode ou name\space\Classe::methode |
|
| 102 | - elseif (false === strpos($f, '::') and is_callable(array($f))) { |
|
| 103 | - return $f; |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - return $default; |
|
| 78 | + if (!$fonc) { |
|
| 79 | + return $default; |
|
| 80 | + } |
|
| 81 | + // Cas des types mime, sans confondre avec les appels de fonction de classe |
|
| 82 | + // Foo::Bar |
|
| 83 | + // qui peuvent etre avec un namespace : space\Foo::Bar |
|
| 84 | + if (preg_match(',^[\w]+/,', $fonc)) { |
|
| 85 | + $nom = preg_replace(',\W,', '_', $fonc); |
|
| 86 | + $f = chercher_filtre($nom); |
|
| 87 | + // cas du sous-type MIME sans filtre associe, passer au type: |
|
| 88 | + // si filtre_text_plain pas defini, passe a filtre_text |
|
| 89 | + if (!$f and $nom !== $fonc) { |
|
| 90 | + $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc)); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + return $f; |
|
| 94 | + } |
|
| 95 | + foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) { |
|
| 96 | + trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
|
| 97 | + // fonction ou name\space\fonction |
|
| 98 | + if (is_callable($f)) { |
|
| 99 | + return $f; |
|
| 100 | + } |
|
| 101 | + // méthode statique d'une classe Classe::methode ou name\space\Classe::methode |
|
| 102 | + elseif (false === strpos($f, '::') and is_callable(array($f))) { |
|
| 103 | + return $f; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + return $default; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -128,20 +128,20 @@ discard block |
||
| 128 | 128 | * Chaîne vide sinon (filtre introuvable). |
| 129 | 129 | **/ |
| 130 | 130 | function appliquer_filtre($arg, $filtre, $force = null) { |
| 131 | - $f = chercher_filtre($filtre); |
|
| 132 | - if (!$f) { |
|
| 133 | - if (!$force) { |
|
| 134 | - return ''; |
|
| 135 | - } else { |
|
| 136 | - return $arg; |
|
| 137 | - } |
|
| 138 | - } |
|
| 131 | + $f = chercher_filtre($filtre); |
|
| 132 | + if (!$f) { |
|
| 133 | + if (!$force) { |
|
| 134 | + return ''; |
|
| 135 | + } else { |
|
| 136 | + return $arg; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - $args = func_get_args(); |
|
| 141 | - array_shift($args); // enlever $arg |
|
| 142 | - array_shift($args); // enlever $filtre |
|
| 143 | - array_unshift($args, $arg); // remettre $arg |
|
| 144 | - return call_user_func_array($f, $args); |
|
| 140 | + $args = func_get_args(); |
|
| 141 | + array_shift($args); // enlever $arg |
|
| 142 | + array_shift($args); // enlever $filtre |
|
| 143 | + array_unshift($args, $arg); // remettre $arg |
|
| 144 | + return call_user_func_array($f, $args); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | * Version de SPIP |
| 158 | 158 | **/ |
| 159 | 159 | function spip_version() { |
| 160 | - $version = $GLOBALS['spip_version_affichee']; |
|
| 161 | - if ($svn_revision = version_svn_courante(_DIR_RACINE)) { |
|
| 162 | - $version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']'; |
|
| 163 | - } |
|
| 160 | + $version = $GLOBALS['spip_version_affichee']; |
|
| 161 | + if ($svn_revision = version_svn_courante(_DIR_RACINE)) { |
|
| 162 | + $version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']'; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - return $version; |
|
| 165 | + return $version; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | |
@@ -181,43 +181,43 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | **/ |
| 183 | 183 | function version_svn_courante($dir) { |
| 184 | - if (!$dir) { |
|
| 185 | - $dir = '.'; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - // version installee par paquet ZIP |
|
| 189 | - if (lire_fichier($dir . '/svn.revision', $c) |
|
| 190 | - and preg_match(',Revision: (\d+),', $c, $d) |
|
| 191 | - ) { |
|
| 192 | - return intval($d[1]); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - // version installee par SVN |
|
| 196 | - if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) { |
|
| 197 | - $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 198 | - $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
|
| 199 | - if ($result) { |
|
| 200 | - $row = $result->fetchArray(); |
|
| 201 | - if ($row['changed_revision'] != "") { |
|
| 202 | - return -$row['changed_revision']; |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } else if (lire_fichier($dir . '/.svn/entries', $c) |
|
| 206 | - and ( |
|
| 207 | - (preg_match_all( |
|
| 208 | - ',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER) |
|
| 209 | - and $v = max($r1[1]) |
|
| 210 | - ) |
|
| 211 | - or |
|
| 212 | - (preg_match(',^\d.*dir[\r\n]+(\d+),ms', $c, $r1) # svn >= 1.4 |
|
| 213 | - and $v = $r1[1] |
|
| 214 | - )) |
|
| 215 | - ) { |
|
| 216 | - return -$v; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // Bug ou paquet fait main |
|
| 220 | - return 0; |
|
| 184 | + if (!$dir) { |
|
| 185 | + $dir = '.'; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + // version installee par paquet ZIP |
|
| 189 | + if (lire_fichier($dir . '/svn.revision', $c) |
|
| 190 | + and preg_match(',Revision: (\d+),', $c, $d) |
|
| 191 | + ) { |
|
| 192 | + return intval($d[1]); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + // version installee par SVN |
|
| 196 | + if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) { |
|
| 197 | + $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 198 | + $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
|
| 199 | + if ($result) { |
|
| 200 | + $row = $result->fetchArray(); |
|
| 201 | + if ($row['changed_revision'] != "") { |
|
| 202 | + return -$row['changed_revision']; |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } else if (lire_fichier($dir . '/.svn/entries', $c) |
|
| 206 | + and ( |
|
| 207 | + (preg_match_all( |
|
| 208 | + ',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER) |
|
| 209 | + and $v = max($r1[1]) |
|
| 210 | + ) |
|
| 211 | + or |
|
| 212 | + (preg_match(',^\d.*dir[\r\n]+(\d+),ms', $c, $r1) # svn >= 1.4 |
|
| 213 | + and $v = $r1[1] |
|
| 214 | + )) |
|
| 215 | + ) { |
|
| 216 | + return -$v; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // Bug ou paquet fait main |
|
| 220 | + return 0; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images |
@@ -261,18 +261,18 @@ discard block |
||
| 261 | 261 | * Code HTML retourné par le filtre |
| 262 | 262 | **/ |
| 263 | 263 | function filtrer($filtre) { |
| 264 | - $tous = func_get_args(); |
|
| 265 | - if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 266 | - return image_filtrer($tous); |
|
| 267 | - } elseif ($f = chercher_filtre($filtre)) { |
|
| 268 | - array_shift($tous); |
|
| 269 | - return call_user_func_array($f, $tous); |
|
| 270 | - } else { |
|
| 271 | - // le filtre n'existe pas, on provoque une erreur |
|
| 272 | - $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre))); |
|
| 273 | - erreur_squelette($msg); |
|
| 274 | - return ''; |
|
| 275 | - } |
|
| 264 | + $tous = func_get_args(); |
|
| 265 | + if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 266 | + return image_filtrer($tous); |
|
| 267 | + } elseif ($f = chercher_filtre($filtre)) { |
|
| 268 | + array_shift($tous); |
|
| 269 | + return call_user_func_array($f, $tous); |
|
| 270 | + } else { |
|
| 271 | + // le filtre n'existe pas, on provoque une erreur |
|
| 272 | + $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre))); |
|
| 273 | + erreur_squelette($msg); |
|
| 274 | + return ''; |
|
| 275 | + } |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | * @return bool true si on trouve le filtre dans la matrice, false sinon. |
| 290 | 290 | */ |
| 291 | 291 | function trouver_filtre_matrice($filtre) { |
| 292 | - if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) { |
|
| 293 | - find_in_path($f, '', true); |
|
| 294 | - $GLOBALS['spip_matrice'][$filtre] = true; |
|
| 295 | - } |
|
| 296 | - return !empty($GLOBALS['spip_matrice'][$filtre]); |
|
| 292 | + if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) { |
|
| 293 | + find_in_path($f, '', true); |
|
| 294 | + $GLOBALS['spip_matrice'][$filtre] = true; |
|
| 295 | + } |
|
| 296 | + return !empty($GLOBALS['spip_matrice'][$filtre]); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | * @return mixed |
| 322 | 322 | */ |
| 323 | 323 | function filtre_set(&$Pile, $val, $key, $continue = null) { |
| 324 | - $Pile['vars'][$key] = $val; |
|
| 325 | - return $continue ? $val : ''; |
|
| 324 | + $Pile['vars'][$key] = $val; |
|
| 325 | + return $continue ? $val : ''; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''. |
| 349 | 349 | */ |
| 350 | 350 | function filtre_setenv(&$Pile, $val, $key, $continue = null) { |
| 351 | - $Pile[0][$key] = $val; |
|
| 352 | - return $continue ? $val : ''; |
|
| 351 | + $Pile[0][$key] = $val; |
|
| 352 | + return $continue ? $val : ''; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
@@ -371,18 +371,18 @@ discard block |
||
| 371 | 371 | * @return mixed Retourne la valeur (sans la modifier). |
| 372 | 372 | */ |
| 373 | 373 | function filtre_debug($val, $key = null) { |
| 374 | - $debug = ( |
|
| 375 | - is_null($key) ? '' : (var_export($key, true) . " = ") |
|
| 376 | - ) . var_export($val, true); |
|
| 374 | + $debug = ( |
|
| 375 | + is_null($key) ? '' : (var_export($key, true) . " = ") |
|
| 376 | + ) . var_export($val, true); |
|
| 377 | 377 | |
| 378 | - include_spip('inc/autoriser'); |
|
| 379 | - if (autoriser('webmestre')) { |
|
| 380 | - echo "<div class='spip_debug'>\n", $debug, "</div>\n"; |
|
| 381 | - } |
|
| 378 | + include_spip('inc/autoriser'); |
|
| 379 | + if (autoriser('webmestre')) { |
|
| 380 | + echo "<div class='spip_debug'>\n", $debug, "</div>\n"; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - spip_log($debug, 'debug'); |
|
| 383 | + spip_log($debug, 'debug'); |
|
| 384 | 384 | |
| 385 | - return $val; |
|
| 385 | + return $val; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | |
@@ -410,71 +410,71 @@ discard block |
||
| 410 | 410 | * Texte qui a reçu les filtres |
| 411 | 411 | **/ |
| 412 | 412 | function image_filtrer($args) { |
| 413 | - $filtre = array_shift($args); # enlever $filtre |
|
| 414 | - $texte = array_shift($args); |
|
| 415 | - if (!strlen($texte)) { |
|
| 416 | - return; |
|
| 417 | - } |
|
| 418 | - find_in_path('filtres_images_mini.php', 'inc/', true); |
|
| 419 | - statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver |
|
| 420 | - // Cas du nom de fichier local |
|
| 421 | - if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false |
|
| 422 | - and !preg_match(',^/|[<>]|\s,S', $texte) |
|
| 423 | - and ( |
|
| 424 | - file_exists(preg_replace(',[?].*$,', '', $texte)) |
|
| 425 | - or tester_url_absolue($texte) |
|
| 426 | - ) |
|
| 427 | - ) { |
|
| 428 | - array_unshift($args, "<img src='$texte' />"); |
|
| 429 | - $res = call_user_func_array($filtre, $args); |
|
| 430 | - statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 431 | - return $res; |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - // Cas general : trier toutes les images, avec eventuellement leur <span> |
|
| 435 | - if (preg_match_all( |
|
| 436 | - ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS', |
|
| 437 | - $texte, $tags, PREG_SET_ORDER)) { |
|
| 438 | - foreach ($tags as $tag) { |
|
| 439 | - $class = extraire_attribut($tag[3], 'class'); |
|
| 440 | - if (!$class or |
|
| 441 | - (strpos($class, 'filtre_inactif') === false |
|
| 442 | - // compat historique a virer en 3.2 |
|
| 443 | - and strpos($class, 'no_image_filtrer') === false) |
|
| 444 | - ) { |
|
| 445 | - array_unshift($args, $tag[3]); |
|
| 446 | - if ($reduit = call_user_func_array($filtre, $args)) { |
|
| 447 | - // En cas de span spip_documents, modifier le style=...width: |
|
| 448 | - if ($tag[1]) { |
|
| 449 | - $w = extraire_attribut($reduit, 'width'); |
|
| 450 | - if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) { |
|
| 451 | - $w = $regs[1]; |
|
| 452 | - } |
|
| 453 | - if ($w and ($style = extraire_attribut($tag[1], 'style'))) { |
|
| 454 | - $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style); |
|
| 455 | - $replace = inserer_attribut($tag[1], 'style', $style); |
|
| 456 | - $texte = str_replace($tag[1], $replace, $texte); |
|
| 457 | - } |
|
| 458 | - } |
|
| 459 | - // traiter aussi un eventuel mouseover |
|
| 460 | - if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
|
| 461 | - if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
|
| 462 | - $srcover = $match[1]; |
|
| 463 | - array_shift($args); |
|
| 464 | - array_unshift($args, "<img src='" . $match[1] . "' />"); |
|
| 465 | - $srcover_filter = call_user_func_array($filtre, $args); |
|
| 466 | - $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
|
| 467 | - $reduit = str_replace($srcover, $srcover_filter, $reduit); |
|
| 468 | - } |
|
| 469 | - } |
|
| 470 | - $texte = str_replace($tag[3], $reduit, $texte); |
|
| 471 | - } |
|
| 472 | - array_shift($args); |
|
| 473 | - } |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 477 | - return $texte; |
|
| 413 | + $filtre = array_shift($args); # enlever $filtre |
|
| 414 | + $texte = array_shift($args); |
|
| 415 | + if (!strlen($texte)) { |
|
| 416 | + return; |
|
| 417 | + } |
|
| 418 | + find_in_path('filtres_images_mini.php', 'inc/', true); |
|
| 419 | + statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver |
|
| 420 | + // Cas du nom de fichier local |
|
| 421 | + if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false |
|
| 422 | + and !preg_match(',^/|[<>]|\s,S', $texte) |
|
| 423 | + and ( |
|
| 424 | + file_exists(preg_replace(',[?].*$,', '', $texte)) |
|
| 425 | + or tester_url_absolue($texte) |
|
| 426 | + ) |
|
| 427 | + ) { |
|
| 428 | + array_unshift($args, "<img src='$texte' />"); |
|
| 429 | + $res = call_user_func_array($filtre, $args); |
|
| 430 | + statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 431 | + return $res; |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + // Cas general : trier toutes les images, avec eventuellement leur <span> |
|
| 435 | + if (preg_match_all( |
|
| 436 | + ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS', |
|
| 437 | + $texte, $tags, PREG_SET_ORDER)) { |
|
| 438 | + foreach ($tags as $tag) { |
|
| 439 | + $class = extraire_attribut($tag[3], 'class'); |
|
| 440 | + if (!$class or |
|
| 441 | + (strpos($class, 'filtre_inactif') === false |
|
| 442 | + // compat historique a virer en 3.2 |
|
| 443 | + and strpos($class, 'no_image_filtrer') === false) |
|
| 444 | + ) { |
|
| 445 | + array_unshift($args, $tag[3]); |
|
| 446 | + if ($reduit = call_user_func_array($filtre, $args)) { |
|
| 447 | + // En cas de span spip_documents, modifier le style=...width: |
|
| 448 | + if ($tag[1]) { |
|
| 449 | + $w = extraire_attribut($reduit, 'width'); |
|
| 450 | + if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) { |
|
| 451 | + $w = $regs[1]; |
|
| 452 | + } |
|
| 453 | + if ($w and ($style = extraire_attribut($tag[1], 'style'))) { |
|
| 454 | + $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style); |
|
| 455 | + $replace = inserer_attribut($tag[1], 'style', $style); |
|
| 456 | + $texte = str_replace($tag[1], $replace, $texte); |
|
| 457 | + } |
|
| 458 | + } |
|
| 459 | + // traiter aussi un eventuel mouseover |
|
| 460 | + if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
|
| 461 | + if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
|
| 462 | + $srcover = $match[1]; |
|
| 463 | + array_shift($args); |
|
| 464 | + array_unshift($args, "<img src='" . $match[1] . "' />"); |
|
| 465 | + $srcover_filter = call_user_func_array($filtre, $args); |
|
| 466 | + $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
|
| 467 | + $reduit = str_replace($srcover, $srcover_filter, $reduit); |
|
| 468 | + } |
|
| 469 | + } |
|
| 470 | + $texte = str_replace($tag[3], $reduit, $texte); |
|
| 471 | + } |
|
| 472 | + array_shift($args); |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 477 | + return $texte; |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
@@ -489,65 +489,65 @@ discard block |
||
| 489 | 489 | **/ |
| 490 | 490 | function taille_image($img) { |
| 491 | 491 | |
| 492 | - static $largeur_img = array(), $hauteur_img = array(); |
|
| 493 | - $srcWidth = 0; |
|
| 494 | - $srcHeight = 0; |
|
| 495 | - |
|
| 496 | - $src = extraire_attribut($img, 'src'); |
|
| 497 | - |
|
| 498 | - if (!$src) { |
|
| 499 | - $src = $img; |
|
| 500 | - } else { |
|
| 501 | - $srcWidth = extraire_attribut($img, 'width'); |
|
| 502 | - $srcHeight = extraire_attribut($img, 'height'); |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 506 | - // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 507 | - if (tester_url_absolue($src)) { |
|
| 508 | - include_spip('inc/distant'); |
|
| 509 | - $fichier = copie_locale($src); |
|
| 510 | - $src = $fichier ? _DIR_RACINE . $fichier : $src; |
|
| 511 | - } |
|
| 512 | - if (($p = strpos($src, '?')) !== false) { |
|
| 513 | - $src = substr($src, 0, $p); |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - $srcsize = false; |
|
| 517 | - if (isset($largeur_img[$src])) { |
|
| 518 | - $srcWidth = $largeur_img[$src]; |
|
| 519 | - } |
|
| 520 | - if (isset($hauteur_img[$src])) { |
|
| 521 | - $srcHeight = $hauteur_img[$src]; |
|
| 522 | - } |
|
| 523 | - if (!$srcWidth or !$srcHeight) { |
|
| 524 | - |
|
| 525 | - if (file_exists($src) |
|
| 526 | - and $srcsize = spip_getimagesize($src) |
|
| 527 | - ) { |
|
| 528 | - if (!$srcWidth) { |
|
| 529 | - $largeur_img[$src] = $srcWidth = $srcsize[0]; |
|
| 530 | - } |
|
| 531 | - if (!$srcHeight) { |
|
| 532 | - $hauteur_img[$src] = $srcHeight = $srcsize[1]; |
|
| 533 | - } |
|
| 534 | - } |
|
| 535 | - // $src peut etre une reference a une image temporaire dont a n'a que le log .src |
|
| 536 | - // on s'y refere, l'image sera reconstruite en temps utile si necessaire |
|
| 537 | - elseif (@file_exists($f = "$src.src") |
|
| 538 | - and lire_fichier($f, $valeurs) |
|
| 539 | - and $valeurs = unserialize($valeurs) |
|
| 540 | - ) { |
|
| 541 | - if (!$srcWidth) { |
|
| 542 | - $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"]; |
|
| 543 | - } |
|
| 544 | - if (!$srcHeight) { |
|
| 545 | - $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"]; |
|
| 546 | - } |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - return array($srcHeight, $srcWidth); |
|
| 492 | + static $largeur_img = array(), $hauteur_img = array(); |
|
| 493 | + $srcWidth = 0; |
|
| 494 | + $srcHeight = 0; |
|
| 495 | + |
|
| 496 | + $src = extraire_attribut($img, 'src'); |
|
| 497 | + |
|
| 498 | + if (!$src) { |
|
| 499 | + $src = $img; |
|
| 500 | + } else { |
|
| 501 | + $srcWidth = extraire_attribut($img, 'width'); |
|
| 502 | + $srcHeight = extraire_attribut($img, 'height'); |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 506 | + // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 507 | + if (tester_url_absolue($src)) { |
|
| 508 | + include_spip('inc/distant'); |
|
| 509 | + $fichier = copie_locale($src); |
|
| 510 | + $src = $fichier ? _DIR_RACINE . $fichier : $src; |
|
| 511 | + } |
|
| 512 | + if (($p = strpos($src, '?')) !== false) { |
|
| 513 | + $src = substr($src, 0, $p); |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + $srcsize = false; |
|
| 517 | + if (isset($largeur_img[$src])) { |
|
| 518 | + $srcWidth = $largeur_img[$src]; |
|
| 519 | + } |
|
| 520 | + if (isset($hauteur_img[$src])) { |
|
| 521 | + $srcHeight = $hauteur_img[$src]; |
|
| 522 | + } |
|
| 523 | + if (!$srcWidth or !$srcHeight) { |
|
| 524 | + |
|
| 525 | + if (file_exists($src) |
|
| 526 | + and $srcsize = spip_getimagesize($src) |
|
| 527 | + ) { |
|
| 528 | + if (!$srcWidth) { |
|
| 529 | + $largeur_img[$src] = $srcWidth = $srcsize[0]; |
|
| 530 | + } |
|
| 531 | + if (!$srcHeight) { |
|
| 532 | + $hauteur_img[$src] = $srcHeight = $srcsize[1]; |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + // $src peut etre une reference a une image temporaire dont a n'a que le log .src |
|
| 536 | + // on s'y refere, l'image sera reconstruite en temps utile si necessaire |
|
| 537 | + elseif (@file_exists($f = "$src.src") |
|
| 538 | + and lire_fichier($f, $valeurs) |
|
| 539 | + and $valeurs = unserialize($valeurs) |
|
| 540 | + ) { |
|
| 541 | + if (!$srcWidth) { |
|
| 542 | + $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"]; |
|
| 543 | + } |
|
| 544 | + if (!$srcHeight) { |
|
| 545 | + $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"]; |
|
| 546 | + } |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + return array($srcHeight, $srcWidth); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | |
@@ -565,12 +565,12 @@ discard block |
||
| 565 | 565 | * Largeur en pixels, NULL ou 0 si aucune image. |
| 566 | 566 | **/ |
| 567 | 567 | function largeur($img) { |
| 568 | - if (!$img) { |
|
| 569 | - return; |
|
| 570 | - } |
|
| 571 | - list($h, $l) = taille_image($img); |
|
| 568 | + if (!$img) { |
|
| 569 | + return; |
|
| 570 | + } |
|
| 571 | + list($h, $l) = taille_image($img); |
|
| 572 | 572 | |
| 573 | - return $l; |
|
| 573 | + return $l; |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | /** |
@@ -587,12 +587,12 @@ discard block |
||
| 587 | 587 | * Hauteur en pixels, NULL ou 0 si aucune image. |
| 588 | 588 | **/ |
| 589 | 589 | function hauteur($img) { |
| 590 | - if (!$img) { |
|
| 591 | - return; |
|
| 592 | - } |
|
| 593 | - list($h, $l) = taille_image($img); |
|
| 590 | + if (!$img) { |
|
| 591 | + return; |
|
| 592 | + } |
|
| 593 | + list($h, $l) = taille_image($img); |
|
| 594 | 594 | |
| 595 | - return $h; |
|
| 595 | + return $h; |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | |
@@ -612,11 +612,11 @@ discard block |
||
| 612 | 612 | * @return string |
| 613 | 613 | **/ |
| 614 | 614 | function corriger_entites_html($texte) { |
| 615 | - if (strpos($texte, '&') === false) { |
|
| 616 | - return $texte; |
|
| 617 | - } |
|
| 615 | + if (strpos($texte, '&') === false) { |
|
| 616 | + return $texte; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | - return preg_replace(',&(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte); |
|
| 619 | + return preg_replace(',&(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | /** |
@@ -631,11 +631,11 @@ discard block |
||
| 631 | 631 | * @return string |
| 632 | 632 | **/ |
| 633 | 633 | function corriger_toutes_entites_html($texte) { |
| 634 | - if (strpos($texte, '&') === false) { |
|
| 635 | - return $texte; |
|
| 636 | - } |
|
| 634 | + if (strpos($texte, '&') === false) { |
|
| 635 | + return $texte; |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | - return preg_replace(',&(#?[a-z0-9]+;),iS', '&\1', $texte); |
|
| 638 | + return preg_replace(',&(#?[a-z0-9]+;),iS', '&\1', $texte); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | /** |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | * @return string |
| 646 | 646 | **/ |
| 647 | 647 | function proteger_amp($texte) { |
| 648 | - return str_replace('&', '&', $texte); |
|
| 648 | + return str_replace('&', '&', $texte); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | |
@@ -676,20 +676,20 @@ discard block |
||
| 676 | 676 | * @return mixed|string |
| 677 | 677 | */ |
| 678 | 678 | function entites_html($texte, $tout = false, $quote = true) { |
| 679 | - if (!is_string($texte) or !$texte |
|
| 680 | - or strpbrk($texte, "&\"'<>") == false |
|
| 681 | - ) { |
|
| 682 | - return $texte; |
|
| 683 | - } |
|
| 684 | - include_spip('inc/texte'); |
|
| 685 | - $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES); |
|
| 686 | - $flags |= ENT_HTML401; |
|
| 687 | - $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags); |
|
| 688 | - if ($tout) { |
|
| 689 | - return corriger_toutes_entites_html($texte); |
|
| 690 | - } else { |
|
| 691 | - return corriger_entites_html($texte); |
|
| 692 | - } |
|
| 679 | + if (!is_string($texte) or !$texte |
|
| 680 | + or strpbrk($texte, "&\"'<>") == false |
|
| 681 | + ) { |
|
| 682 | + return $texte; |
|
| 683 | + } |
|
| 684 | + include_spip('inc/texte'); |
|
| 685 | + $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES); |
|
| 686 | + $flags |= ENT_HTML401; |
|
| 687 | + $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags); |
|
| 688 | + if ($tout) { |
|
| 689 | + return corriger_toutes_entites_html($texte); |
|
| 690 | + } else { |
|
| 691 | + return corriger_entites_html($texte); |
|
| 692 | + } |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
@@ -708,37 +708,37 @@ discard block |
||
| 708 | 708 | * Texte converti |
| 709 | 709 | **/ |
| 710 | 710 | function filtrer_entites($texte) { |
| 711 | - if (strpos($texte, '&') === false) { |
|
| 712 | - return $texte; |
|
| 713 | - } |
|
| 714 | - // filtrer |
|
| 715 | - $texte = html2unicode($texte); |
|
| 716 | - // remettre le tout dans le charset cible |
|
| 717 | - $texte = unicode2charset($texte); |
|
| 718 | - // cas particulier des " et ' qu'il faut filtrer aussi |
|
| 719 | - // (on le faisait deja avec un ") |
|
| 720 | - if (strpos($texte, "&#") !== false) { |
|
| 721 | - $texte = str_replace(array("'", "'", """, """), array("'", "'", '"', '"'), $texte); |
|
| 722 | - } |
|
| 711 | + if (strpos($texte, '&') === false) { |
|
| 712 | + return $texte; |
|
| 713 | + } |
|
| 714 | + // filtrer |
|
| 715 | + $texte = html2unicode($texte); |
|
| 716 | + // remettre le tout dans le charset cible |
|
| 717 | + $texte = unicode2charset($texte); |
|
| 718 | + // cas particulier des " et ' qu'il faut filtrer aussi |
|
| 719 | + // (on le faisait deja avec un ") |
|
| 720 | + if (strpos($texte, "&#") !== false) { |
|
| 721 | + $texte = str_replace(array("'", "'", """, """), array("'", "'", '"', '"'), $texte); |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | - return $texte; |
|
| 724 | + return $texte; |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | |
| 728 | 728 | if (!function_exists('filtre_filtrer_entites_dist')) { |
| 729 | - /** |
|
| 730 | - * Version sécurisée de filtrer_entites |
|
| 731 | - * |
|
| 732 | - * @uses interdire_scripts() |
|
| 733 | - * @uses filtrer_entites() |
|
| 734 | - * |
|
| 735 | - * @param string $t |
|
| 736 | - * @return string |
|
| 737 | - */ |
|
| 738 | - function filtre_filtrer_entites_dist($t) { |
|
| 739 | - include_spip('inc/texte'); |
|
| 740 | - return interdire_scripts(filtrer_entites($t)); |
|
| 741 | - } |
|
| 729 | + /** |
|
| 730 | + * Version sécurisée de filtrer_entites |
|
| 731 | + * |
|
| 732 | + * @uses interdire_scripts() |
|
| 733 | + * @uses filtrer_entites() |
|
| 734 | + * |
|
| 735 | + * @param string $t |
|
| 736 | + * @return string |
|
| 737 | + */ |
|
| 738 | + function filtre_filtrer_entites_dist($t) { |
|
| 739 | + include_spip('inc/texte'); |
|
| 740 | + return interdire_scripts(filtrer_entites($t)); |
|
| 741 | + } |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | |
@@ -753,18 +753,18 @@ discard block |
||
| 753 | 753 | * @return string|array |
| 754 | 754 | **/ |
| 755 | 755 | function supprimer_caracteres_illegaux($texte) { |
| 756 | - static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; |
|
| 757 | - static $to = null; |
|
| 756 | + static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; |
|
| 757 | + static $to = null; |
|
| 758 | 758 | |
| 759 | - if (is_array($texte)) { |
|
| 760 | - return array_map('supprimer_caracteres_illegaux', $texte); |
|
| 761 | - } |
|
| 759 | + if (is_array($texte)) { |
|
| 760 | + return array_map('supprimer_caracteres_illegaux', $texte); |
|
| 761 | + } |
|
| 762 | 762 | |
| 763 | - if (!$to) { |
|
| 764 | - $to = str_repeat('-', strlen($from)); |
|
| 765 | - } |
|
| 763 | + if (!$to) { |
|
| 764 | + $to = str_repeat('-', strlen($from)); |
|
| 765 | + } |
|
| 766 | 766 | |
| 767 | - return strtr($texte, $from, $to); |
|
| 767 | + return strtr($texte, $from, $to); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | /** |
@@ -776,10 +776,10 @@ discard block |
||
| 776 | 776 | * @return string|array |
| 777 | 777 | **/ |
| 778 | 778 | function corriger_caracteres($texte) { |
| 779 | - $texte = corriger_caracteres_windows($texte); |
|
| 780 | - $texte = supprimer_caracteres_illegaux($texte); |
|
| 779 | + $texte = corriger_caracteres_windows($texte); |
|
| 780 | + $texte = supprimer_caracteres_illegaux($texte); |
|
| 781 | 781 | |
| 782 | - return $texte; |
|
| 782 | + return $texte; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | /** |
@@ -797,40 +797,40 @@ discard block |
||
| 797 | 797 | */ |
| 798 | 798 | function texte_backend($texte) { |
| 799 | 799 | |
| 800 | - static $apostrophe = array("’", "'"); # n'allouer qu'une fois |
|
| 800 | + static $apostrophe = array("’", "'"); # n'allouer qu'une fois |
|
| 801 | 801 | |
| 802 | - // si on a des liens ou des images, les passer en absolu |
|
| 803 | - $texte = liens_absolus($texte); |
|
| 802 | + // si on a des liens ou des images, les passer en absolu |
|
| 803 | + $texte = liens_absolus($texte); |
|
| 804 | 804 | |
| 805 | - // echapper les tags > < |
|
| 806 | - $texte = preg_replace(',&(gt|lt);,S', '&\1;', $texte); |
|
| 805 | + // echapper les tags > < |
|
| 806 | + $texte = preg_replace(',&(gt|lt);,S', '&\1;', $texte); |
|
| 807 | 807 | |
| 808 | - // importer les é |
|
| 809 | - $texte = filtrer_entites($texte); |
|
| 808 | + // importer les é |
|
| 809 | + $texte = filtrer_entites($texte); |
|
| 810 | 810 | |
| 811 | - // " -> " et tout ce genre de choses |
|
| 812 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 813 | - $texte = str_replace(" ", " ", $texte); |
|
| 814 | - $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte); |
|
| 815 | - // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
|
| 816 | - $texte = entites_html($texte, false, false); |
|
| 817 | - // mais bien echapper les double quotes ! |
|
| 818 | - $texte = str_replace('"', '"', $texte); |
|
| 811 | + // " -> " et tout ce genre de choses |
|
| 812 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 813 | + $texte = str_replace(" ", " ", $texte); |
|
| 814 | + $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte); |
|
| 815 | + // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
|
| 816 | + $texte = entites_html($texte, false, false); |
|
| 817 | + // mais bien echapper les double quotes ! |
|
| 818 | + $texte = str_replace('"', '"', $texte); |
|
| 819 | 819 | |
| 820 | - // verifier le charset |
|
| 821 | - $texte = charset2unicode($texte); |
|
| 820 | + // verifier le charset |
|
| 821 | + $texte = charset2unicode($texte); |
|
| 822 | 822 | |
| 823 | - // Caracteres problematiques en iso-latin 1 |
|
| 824 | - if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { |
|
| 825 | - $texte = str_replace(chr(156), 'œ', $texte); |
|
| 826 | - $texte = str_replace(chr(140), 'Œ', $texte); |
|
| 827 | - $texte = str_replace(chr(159), 'Ÿ', $texte); |
|
| 828 | - } |
|
| 823 | + // Caracteres problematiques en iso-latin 1 |
|
| 824 | + if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { |
|
| 825 | + $texte = str_replace(chr(156), 'œ', $texte); |
|
| 826 | + $texte = str_replace(chr(140), 'Œ', $texte); |
|
| 827 | + $texte = str_replace(chr(159), 'Ÿ', $texte); |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | - // l'apostrophe curly pose probleme a certains lecteure de RSS |
|
| 831 | - // et le caractere apostrophe alourdit les squelettes avec PHP |
|
| 832 | - // ==> on les remplace par l'entite HTML |
|
| 833 | - return str_replace($apostrophe, "'", $texte); |
|
| 830 | + // l'apostrophe curly pose probleme a certains lecteure de RSS |
|
| 831 | + // et le caractere apostrophe alourdit les squelettes avec PHP |
|
| 832 | + // ==> on les remplace par l'entite HTML |
|
| 833 | + return str_replace($apostrophe, "'", $texte); |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | /** |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | * Texte encodé et quote pour XML |
| 848 | 848 | */ |
| 849 | 849 | function texte_backendq($texte) { |
| 850 | - return addslashes(texte_backend($texte)); |
|
| 850 | + return addslashes(texte_backend($texte)); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | |
@@ -870,9 +870,9 @@ discard block |
||
| 870 | 870 | * Numéro de titre, sinon chaîne vide |
| 871 | 871 | **/ |
| 872 | 872 | function supprimer_numero($texte) { |
| 873 | - return preg_replace( |
|
| 874 | - ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 875 | - "", $texte); |
|
| 873 | + return preg_replace( |
|
| 874 | + ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 875 | + "", $texte); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | /** |
@@ -895,13 +895,13 @@ discard block |
||
| 895 | 895 | * Numéro de titre, sinon chaîne vide |
| 896 | 896 | **/ |
| 897 | 897 | function recuperer_numero($texte) { |
| 898 | - if (preg_match( |
|
| 899 | - ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 900 | - $texte, $regs)) { |
|
| 901 | - return strval($regs[1]); |
|
| 902 | - } else { |
|
| 903 | - return ''; |
|
| 904 | - } |
|
| 898 | + if (preg_match( |
|
| 899 | + ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 900 | + $texte, $regs)) { |
|
| 901 | + return strval($regs[1]); |
|
| 902 | + } else { |
|
| 903 | + return ''; |
|
| 904 | + } |
|
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | /** |
@@ -928,13 +928,13 @@ discard block |
||
| 928 | 928 | * Texte converti |
| 929 | 929 | **/ |
| 930 | 930 | function supprimer_tags($texte, $rempl = "") { |
| 931 | - $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte); |
|
| 932 | - // ne pas oublier un < final non ferme car coupe |
|
| 933 | - $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte); |
|
| 934 | - // mais qui peut aussi etre un simple signe plus petit que |
|
| 935 | - $texte = str_replace('<', '<', $texte); |
|
| 931 | + $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte); |
|
| 932 | + // ne pas oublier un < final non ferme car coupe |
|
| 933 | + $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte); |
|
| 934 | + // mais qui peut aussi etre un simple signe plus petit que |
|
| 935 | + $texte = str_replace('<', '<', $texte); |
|
| 936 | 936 | |
| 937 | - return $texte; |
|
| 937 | + return $texte; |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | /** |
@@ -957,9 +957,9 @@ discard block |
||
| 957 | 957 | * Texte converti |
| 958 | 958 | **/ |
| 959 | 959 | function echapper_tags($texte, $rempl = "") { |
| 960 | - $texte = preg_replace("/<([^>]*)>/", "<\\1>", $texte); |
|
| 960 | + $texte = preg_replace("/<([^>]*)>/", "<\\1>", $texte); |
|
| 961 | 961 | |
| 962 | - return $texte; |
|
| 962 | + return $texte; |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | /** |
@@ -980,18 +980,18 @@ discard block |
||
| 980 | 980 | * Texte converti |
| 981 | 981 | **/ |
| 982 | 982 | function textebrut($texte) { |
| 983 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 984 | - $texte = preg_replace('/\s+/S' . $u, " ", $texte); |
|
| 985 | - $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte); |
|
| 986 | - $texte = preg_replace("/^\n+/", "", $texte); |
|
| 987 | - $texte = preg_replace("/\n+$/", "", $texte); |
|
| 988 | - $texte = preg_replace("/\n +/", "\n", $texte); |
|
| 989 | - $texte = supprimer_tags($texte); |
|
| 990 | - $texte = preg_replace("/( | )+/S", " ", $texte); |
|
| 991 | - // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail... |
|
| 992 | - $texte = str_replace("’", "'", $texte); |
|
| 983 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 984 | + $texte = preg_replace('/\s+/S' . $u, " ", $texte); |
|
| 985 | + $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte); |
|
| 986 | + $texte = preg_replace("/^\n+/", "", $texte); |
|
| 987 | + $texte = preg_replace("/\n+$/", "", $texte); |
|
| 988 | + $texte = preg_replace("/\n +/", "\n", $texte); |
|
| 989 | + $texte = supprimer_tags($texte); |
|
| 990 | + $texte = preg_replace("/( | )+/S", " ", $texte); |
|
| 991 | + // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail... |
|
| 992 | + $texte = str_replace("’", "'", $texte); |
|
| 993 | 993 | |
| 994 | - return $texte; |
|
| 994 | + return $texte; |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | |
@@ -1007,17 +1007,17 @@ discard block |
||
| 1007 | 1007 | * Texte avec liens ouvrants |
| 1008 | 1008 | **/ |
| 1009 | 1009 | function liens_ouvrants($texte) { |
| 1010 | - if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
|
| 1011 | - $texte, $liens, PREG_PATTERN_ORDER)) { |
|
| 1012 | - foreach ($liens[0] as $a) { |
|
| 1013 | - $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1014 | - $ablank = inserer_attribut($a, 'rel', $rel); |
|
| 1015 | - $ablank = inserer_attribut($ablank, 'target', '_blank'); |
|
| 1016 | - $texte = str_replace($a, $ablank, $texte); |
|
| 1017 | - } |
|
| 1018 | - } |
|
| 1010 | + if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
|
| 1011 | + $texte, $liens, PREG_PATTERN_ORDER)) { |
|
| 1012 | + foreach ($liens[0] as $a) { |
|
| 1013 | + $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1014 | + $ablank = inserer_attribut($a, 'rel', $rel); |
|
| 1015 | + $ablank = inserer_attribut($ablank, 'target', '_blank'); |
|
| 1016 | + $texte = str_replace($a, $ablank, $texte); |
|
| 1017 | + } |
|
| 1018 | + } |
|
| 1019 | 1019 | |
| 1020 | - return $texte; |
|
| 1020 | + return $texte; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | /** |
@@ -1027,22 +1027,22 @@ discard block |
||
| 1027 | 1027 | * @return string |
| 1028 | 1028 | */ |
| 1029 | 1029 | function liens_nofollow($texte) { |
| 1030 | - if (stripos($texte, "<a") === false) { |
|
| 1031 | - return $texte; |
|
| 1032 | - } |
|
| 1030 | + if (stripos($texte, "<a") === false) { |
|
| 1031 | + return $texte; |
|
| 1032 | + } |
|
| 1033 | 1033 | |
| 1034 | - if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 1035 | - foreach ($regs[0] as $a) { |
|
| 1036 | - $rel = extraire_attribut($a, "rel"); |
|
| 1037 | - if (strpos($rel, "nofollow") === false) { |
|
| 1038 | - $rel = "nofollow" . ($rel ? " $rel" : ""); |
|
| 1039 | - $anofollow = inserer_attribut($a, "rel", $rel); |
|
| 1040 | - $texte = str_replace($a, $anofollow, $texte); |
|
| 1041 | - } |
|
| 1042 | - } |
|
| 1043 | - } |
|
| 1034 | + if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 1035 | + foreach ($regs[0] as $a) { |
|
| 1036 | + $rel = extraire_attribut($a, "rel"); |
|
| 1037 | + if (strpos($rel, "nofollow") === false) { |
|
| 1038 | + $rel = "nofollow" . ($rel ? " $rel" : ""); |
|
| 1039 | + $anofollow = inserer_attribut($a, "rel", $rel); |
|
| 1040 | + $texte = str_replace($a, $anofollow, $texte); |
|
| 1041 | + } |
|
| 1042 | + } |
|
| 1043 | + } |
|
| 1044 | 1044 | |
| 1045 | - return $texte; |
|
| 1045 | + return $texte; |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | /** |
@@ -1061,12 +1061,12 @@ discard block |
||
| 1061 | 1061 | * Texte sans paraghaphes |
| 1062 | 1062 | **/ |
| 1063 | 1063 | function PtoBR($texte) { |
| 1064 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1065 | - $texte = preg_replace("@</p>@iS", "\n", $texte); |
|
| 1066 | - $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte); |
|
| 1067 | - $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte); |
|
| 1064 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1065 | + $texte = preg_replace("@</p>@iS", "\n", $texte); |
|
| 1066 | + $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte); |
|
| 1067 | + $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte); |
|
| 1068 | 1068 | |
| 1069 | - return $texte; |
|
| 1069 | + return $texte; |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | |
@@ -1090,14 +1090,14 @@ discard block |
||
| 1090 | 1090 | * @return string Texte encadré du style CSS |
| 1091 | 1091 | */ |
| 1092 | 1092 | function lignes_longues($texte) { |
| 1093 | - if (!strlen(trim($texte))) { |
|
| 1094 | - return $texte; |
|
| 1095 | - } |
|
| 1096 | - include_spip('inc/texte'); |
|
| 1097 | - $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1098 | - 'div' : 'span'; |
|
| 1093 | + if (!strlen(trim($texte))) { |
|
| 1094 | + return $texte; |
|
| 1095 | + } |
|
| 1096 | + include_spip('inc/texte'); |
|
| 1097 | + $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1098 | + 'div' : 'span'; |
|
| 1099 | 1099 | |
| 1100 | - return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
|
| 1100 | + return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
@@ -1116,30 +1116,30 @@ discard block |
||
| 1116 | 1116 | * @return string Texte en majuscule |
| 1117 | 1117 | */ |
| 1118 | 1118 | function majuscules($texte) { |
| 1119 | - if (!strlen($texte)) { |
|
| 1120 | - return ''; |
|
| 1121 | - } |
|
| 1119 | + if (!strlen($texte)) { |
|
| 1120 | + return ''; |
|
| 1121 | + } |
|
| 1122 | 1122 | |
| 1123 | - // Cas du turc |
|
| 1124 | - if ($GLOBALS['spip_lang'] == 'tr') { |
|
| 1125 | - # remplacer hors des tags et des entites |
|
| 1126 | - if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) { |
|
| 1127 | - foreach ($regs as $n => $match) { |
|
| 1128 | - $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte); |
|
| 1129 | - } |
|
| 1130 | - } |
|
| 1123 | + // Cas du turc |
|
| 1124 | + if ($GLOBALS['spip_lang'] == 'tr') { |
|
| 1125 | + # remplacer hors des tags et des entites |
|
| 1126 | + if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) { |
|
| 1127 | + foreach ($regs as $n => $match) { |
|
| 1128 | + $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte); |
|
| 1129 | + } |
|
| 1130 | + } |
|
| 1131 | 1131 | |
| 1132 | - $texte = str_replace('i', 'İ', $texte); |
|
| 1132 | + $texte = str_replace('i', 'İ', $texte); |
|
| 1133 | 1133 | |
| 1134 | - if ($regs) { |
|
| 1135 | - foreach ($regs as $n => $match) { |
|
| 1136 | - $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte); |
|
| 1137 | - } |
|
| 1138 | - } |
|
| 1139 | - } |
|
| 1134 | + if ($regs) { |
|
| 1135 | + foreach ($regs as $n => $match) { |
|
| 1136 | + $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte); |
|
| 1137 | + } |
|
| 1138 | + } |
|
| 1139 | + } |
|
| 1140 | 1140 | |
| 1141 | - // Cas general |
|
| 1142 | - return "<span style='text-transform: uppercase;'>$texte</span>"; |
|
| 1141 | + // Cas general |
|
| 1142 | + return "<span style='text-transform: uppercase;'>$texte</span>"; |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | /** |
@@ -1157,29 +1157,29 @@ discard block |
||
| 1157 | 1157 | * @return string |
| 1158 | 1158 | **/ |
| 1159 | 1159 | function taille_en_octets($taille) { |
| 1160 | - if (!defined('_KILOBYTE')) { |
|
| 1161 | - /** |
|
| 1162 | - * Définit le nombre d'octets dans un Kilobyte |
|
| 1163 | - * |
|
| 1164 | - * @var int |
|
| 1165 | - **/ |
|
| 1166 | - define('_KILOBYTE', 1024); |
|
| 1167 | - } |
|
| 1160 | + if (!defined('_KILOBYTE')) { |
|
| 1161 | + /** |
|
| 1162 | + * Définit le nombre d'octets dans un Kilobyte |
|
| 1163 | + * |
|
| 1164 | + * @var int |
|
| 1165 | + **/ |
|
| 1166 | + define('_KILOBYTE', 1024); |
|
| 1167 | + } |
|
| 1168 | 1168 | |
| 1169 | - if ($taille < 1) { |
|
| 1170 | - return ''; |
|
| 1171 | - } |
|
| 1172 | - if ($taille < _KILOBYTE) { |
|
| 1173 | - $taille = _T('taille_octets', array('taille' => $taille)); |
|
| 1174 | - } elseif ($taille < _KILOBYTE * _KILOBYTE) { |
|
| 1175 | - $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1))); |
|
| 1176 | - } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) { |
|
| 1177 | - $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1))); |
|
| 1178 | - } else { |
|
| 1179 | - $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2))); |
|
| 1180 | - } |
|
| 1169 | + if ($taille < 1) { |
|
| 1170 | + return ''; |
|
| 1171 | + } |
|
| 1172 | + if ($taille < _KILOBYTE) { |
|
| 1173 | + $taille = _T('taille_octets', array('taille' => $taille)); |
|
| 1174 | + } elseif ($taille < _KILOBYTE * _KILOBYTE) { |
|
| 1175 | + $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1))); |
|
| 1176 | + } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) { |
|
| 1177 | + $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1))); |
|
| 1178 | + } else { |
|
| 1179 | + $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2))); |
|
| 1180 | + } |
|
| 1181 | 1181 | |
| 1182 | - return $taille; |
|
| 1182 | + return $taille; |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | |
@@ -1201,15 +1201,15 @@ discard block |
||
| 1201 | 1201 | * Texte prêt pour être utilisé en attribut HTML |
| 1202 | 1202 | **/ |
| 1203 | 1203 | function attribut_html($texte, $textebrut = true) { |
| 1204 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1205 | - if ($textebrut) { |
|
| 1206 | - $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte)); |
|
| 1207 | - } |
|
| 1208 | - $texte = texte_backend($texte); |
|
| 1209 | - $texte = str_replace(array("'", '"'), array(''', '"'), $texte); |
|
| 1204 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1205 | + if ($textebrut) { |
|
| 1206 | + $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte)); |
|
| 1207 | + } |
|
| 1208 | + $texte = texte_backend($texte); |
|
| 1209 | + $texte = str_replace(array("'", '"'), array(''', '"'), $texte); |
|
| 1210 | 1210 | |
| 1211 | - return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&"), |
|
| 1212 | - $texte); |
|
| 1211 | + return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&"), |
|
| 1212 | + $texte); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | |
@@ -1229,12 +1229,12 @@ discard block |
||
| 1229 | 1229 | * URL ou chaîne vide |
| 1230 | 1230 | **/ |
| 1231 | 1231 | function vider_url($url, $entites = true) { |
| 1232 | - # un message pour abs_url |
|
| 1233 | - $GLOBALS['mode_abs_url'] = 'url'; |
|
| 1234 | - $url = trim($url); |
|
| 1235 | - $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1232 | + # un message pour abs_url |
|
| 1233 | + $GLOBALS['mode_abs_url'] = 'url'; |
|
| 1234 | + $url = trim($url); |
|
| 1235 | + $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1236 | 1236 | |
| 1237 | - return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
|
| 1237 | + return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | 1240 | |
@@ -1249,10 +1249,10 @@ discard block |
||
| 1249 | 1249 | * @return string Adresse email maquillée |
| 1250 | 1250 | **/ |
| 1251 | 1251 | function antispam($texte) { |
| 1252 | - include_spip('inc/acces'); |
|
| 1253 | - $masque = creer_pass_aleatoire(3); |
|
| 1252 | + include_spip('inc/acces'); |
|
| 1253 | + $masque = creer_pass_aleatoire(3); |
|
| 1254 | 1254 | |
| 1255 | - return preg_replace("/@/", " $masque ", $texte); |
|
| 1255 | + return preg_replace("/@/", " $masque ", $texte); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | /** |
@@ -1284,12 +1284,12 @@ discard block |
||
| 1284 | 1284 | * True si on a le droit d'accès, false sinon. |
| 1285 | 1285 | **/ |
| 1286 | 1286 | function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') { |
| 1287 | - include_spip('inc/acces'); |
|
| 1288 | - if ($op) { |
|
| 1289 | - $dir .= " $op $args"; |
|
| 1290 | - } |
|
| 1287 | + include_spip('inc/acces'); |
|
| 1288 | + if ($op) { |
|
| 1289 | + $dir .= " $op $args"; |
|
| 1290 | + } |
|
| 1291 | 1291 | |
| 1292 | - return verifier_low_sec($id_auteur, $cle, $dir); |
|
| 1292 | + return verifier_low_sec($id_auteur, $cle, $dir); |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | 1295 | /** |
@@ -1314,11 +1314,11 @@ discard block |
||
| 1314 | 1314 | * Retourne $texte, sinon $sinon. |
| 1315 | 1315 | **/ |
| 1316 | 1316 | function sinon($texte, $sinon = '') { |
| 1317 | - if ($texte or (!is_array($texte) and strlen($texte))) { |
|
| 1318 | - return $texte; |
|
| 1319 | - } else { |
|
| 1320 | - return $sinon; |
|
| 1321 | - } |
|
| 1317 | + if ($texte or (!is_array($texte) and strlen($texte))) { |
|
| 1318 | + return $texte; |
|
| 1319 | + } else { |
|
| 1320 | + return $sinon; |
|
| 1321 | + } |
|
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | 1324 | /** |
@@ -1342,7 +1342,7 @@ discard block |
||
| 1342 | 1342 | * @return mixed |
| 1343 | 1343 | **/ |
| 1344 | 1344 | function choixsivide($a, $vide, $pasvide) { |
| 1345 | - return $a ? $pasvide : $vide; |
|
| 1345 | + return $a ? $pasvide : $vide; |
|
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | /** |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | * @return mixed |
| 1367 | 1367 | **/ |
| 1368 | 1368 | function choixsiegal($a1, $a2, $v, $f) { |
| 1369 | - return ($a1 == $a2) ? $v : $f; |
|
| 1369 | + return ($a1 == $a2) ? $v : $f; |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | // |
@@ -1385,13 +1385,13 @@ discard block |
||
| 1385 | 1385 | * @return string |
| 1386 | 1386 | **/ |
| 1387 | 1387 | function filtrer_ical($texte) { |
| 1388 | - #include_spip('inc/charsets'); |
|
| 1389 | - $texte = html2unicode($texte); |
|
| 1390 | - $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8'); |
|
| 1391 | - $texte = preg_replace("/\n/", " ", $texte); |
|
| 1392 | - $texte = preg_replace("/,/", "\,", $texte); |
|
| 1388 | + #include_spip('inc/charsets'); |
|
| 1389 | + $texte = html2unicode($texte); |
|
| 1390 | + $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8'); |
|
| 1391 | + $texte = preg_replace("/\n/", " ", $texte); |
|
| 1392 | + $texte = preg_replace("/,/", "\,", $texte); |
|
| 1393 | 1393 | |
| 1394 | - return $texte; |
|
| 1394 | + return $texte; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | |
@@ -1416,53 +1416,53 @@ discard block |
||
| 1416 | 1416 | * @return string |
| 1417 | 1417 | **/ |
| 1418 | 1418 | function post_autobr($texte, $delim = "\n_ ") { |
| 1419 | - if (!function_exists('echappe_html')) { |
|
| 1420 | - include_spip('inc/texte_mini'); |
|
| 1421 | - } |
|
| 1422 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 1423 | - $texte = str_replace("\r", "\n", $texte); |
|
| 1424 | - |
|
| 1425 | - if (preg_match(",\n+$,", $texte, $fin)) { |
|
| 1426 | - $texte = substr($texte, 0, -strlen($fin = $fin[0])); |
|
| 1427 | - } else { |
|
| 1428 | - $fin = ''; |
|
| 1429 | - } |
|
| 1430 | - |
|
| 1431 | - $texte = echappe_html($texte, '', true); |
|
| 1432 | - |
|
| 1433 | - // echapper les modeles |
|
| 1434 | - if (strpos($texte, "<") !== false) { |
|
| 1435 | - include_spip('inc/lien'); |
|
| 1436 | - if (defined('_PREG_MODELE')) { |
|
| 1437 | - $preg_modeles = "@" . _PREG_MODELE . "@imsS"; |
|
| 1438 | - $texte = echappe_html($texte, '', true, $preg_modeles); |
|
| 1439 | - } |
|
| 1440 | - } |
|
| 1441 | - |
|
| 1442 | - $debut = ''; |
|
| 1443 | - $suite = $texte; |
|
| 1444 | - while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1445 | - $debut .= substr($suite, 0, $t - 1); |
|
| 1446 | - $suite = substr($suite, $t); |
|
| 1447 | - $car = substr($suite, 0, 1); |
|
| 1448 | - if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}") |
|
| 1449 | - and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite)) |
|
| 1450 | - and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut) |
|
| 1451 | - ) { |
|
| 1452 | - $debut .= $delim; |
|
| 1453 | - } else { |
|
| 1454 | - $debut .= "\n"; |
|
| 1455 | - } |
|
| 1456 | - if (preg_match(",^\n+,", $suite, $regs)) { |
|
| 1457 | - $debut .= $regs[0]; |
|
| 1458 | - $suite = substr($suite, strlen($regs[0])); |
|
| 1459 | - } |
|
| 1460 | - } |
|
| 1461 | - $texte = $debut . $suite; |
|
| 1462 | - |
|
| 1463 | - $texte = echappe_retour($texte); |
|
| 1464 | - |
|
| 1465 | - return $texte . $fin; |
|
| 1419 | + if (!function_exists('echappe_html')) { |
|
| 1420 | + include_spip('inc/texte_mini'); |
|
| 1421 | + } |
|
| 1422 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 1423 | + $texte = str_replace("\r", "\n", $texte); |
|
| 1424 | + |
|
| 1425 | + if (preg_match(",\n+$,", $texte, $fin)) { |
|
| 1426 | + $texte = substr($texte, 0, -strlen($fin = $fin[0])); |
|
| 1427 | + } else { |
|
| 1428 | + $fin = ''; |
|
| 1429 | + } |
|
| 1430 | + |
|
| 1431 | + $texte = echappe_html($texte, '', true); |
|
| 1432 | + |
|
| 1433 | + // echapper les modeles |
|
| 1434 | + if (strpos($texte, "<") !== false) { |
|
| 1435 | + include_spip('inc/lien'); |
|
| 1436 | + if (defined('_PREG_MODELE')) { |
|
| 1437 | + $preg_modeles = "@" . _PREG_MODELE . "@imsS"; |
|
| 1438 | + $texte = echappe_html($texte, '', true, $preg_modeles); |
|
| 1439 | + } |
|
| 1440 | + } |
|
| 1441 | + |
|
| 1442 | + $debut = ''; |
|
| 1443 | + $suite = $texte; |
|
| 1444 | + while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1445 | + $debut .= substr($suite, 0, $t - 1); |
|
| 1446 | + $suite = substr($suite, $t); |
|
| 1447 | + $car = substr($suite, 0, 1); |
|
| 1448 | + if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}") |
|
| 1449 | + and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite)) |
|
| 1450 | + and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut) |
|
| 1451 | + ) { |
|
| 1452 | + $debut .= $delim; |
|
| 1453 | + } else { |
|
| 1454 | + $debut .= "\n"; |
|
| 1455 | + } |
|
| 1456 | + if (preg_match(",^\n+,", $suite, $regs)) { |
|
| 1457 | + $debut .= $regs[0]; |
|
| 1458 | + $suite = substr($suite, strlen($regs[0])); |
|
| 1459 | + } |
|
| 1460 | + } |
|
| 1461 | + $texte = $debut . $suite; |
|
| 1462 | + |
|
| 1463 | + $texte = echappe_retour($texte); |
|
| 1464 | + |
|
| 1465 | + return $texte . $fin; |
|
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | |
@@ -1503,46 +1503,46 @@ discard block |
||
| 1503 | 1503 | * @return string |
| 1504 | 1504 | **/ |
| 1505 | 1505 | function extraire_idiome($letexte, $lang = null, $options = array()) { |
| 1506 | - static $traduire = false; |
|
| 1507 | - if ($letexte |
|
| 1508 | - and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER) |
|
| 1509 | - ) { |
|
| 1510 | - if (!$traduire) { |
|
| 1511 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 1512 | - include_spip('inc/lang'); |
|
| 1513 | - } |
|
| 1514 | - if (!$lang) { |
|
| 1515 | - $lang = $GLOBALS['spip_lang']; |
|
| 1516 | - } |
|
| 1517 | - // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1518 | - if (is_bool($options)) { |
|
| 1519 | - $options = array('echappe_span' => $options); |
|
| 1520 | - } |
|
| 1521 | - if (!isset($options['echappe_span'])) { |
|
| 1522 | - $options = array_merge($options, array('echappe_span' => false)); |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - foreach ($regs as $reg) { |
|
| 1526 | - $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1527 | - $desc = $traduire($cle, $lang, true); |
|
| 1528 | - $l = $desc->langue; |
|
| 1529 | - // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
|
| 1530 | - if (strlen($desc->texte)) { |
|
| 1531 | - $trad = code_echappement($desc->texte, 'idiome', false); |
|
| 1532 | - if ($l !== $lang) { |
|
| 1533 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1534 | - } |
|
| 1535 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1536 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1537 | - } |
|
| 1538 | - if (!$options['echappe_span']) { |
|
| 1539 | - $trad = echappe_retour($trad, 'idiome'); |
|
| 1540 | - } |
|
| 1541 | - $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1542 | - } |
|
| 1543 | - } |
|
| 1544 | - } |
|
| 1545 | - return $letexte; |
|
| 1506 | + static $traduire = false; |
|
| 1507 | + if ($letexte |
|
| 1508 | + and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER) |
|
| 1509 | + ) { |
|
| 1510 | + if (!$traduire) { |
|
| 1511 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 1512 | + include_spip('inc/lang'); |
|
| 1513 | + } |
|
| 1514 | + if (!$lang) { |
|
| 1515 | + $lang = $GLOBALS['spip_lang']; |
|
| 1516 | + } |
|
| 1517 | + // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1518 | + if (is_bool($options)) { |
|
| 1519 | + $options = array('echappe_span' => $options); |
|
| 1520 | + } |
|
| 1521 | + if (!isset($options['echappe_span'])) { |
|
| 1522 | + $options = array_merge($options, array('echappe_span' => false)); |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + foreach ($regs as $reg) { |
|
| 1526 | + $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1527 | + $desc = $traduire($cle, $lang, true); |
|
| 1528 | + $l = $desc->langue; |
|
| 1529 | + // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
|
| 1530 | + if (strlen($desc->texte)) { |
|
| 1531 | + $trad = code_echappement($desc->texte, 'idiome', false); |
|
| 1532 | + if ($l !== $lang) { |
|
| 1533 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1534 | + } |
|
| 1535 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1536 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1537 | + } |
|
| 1538 | + if (!$options['echappe_span']) { |
|
| 1539 | + $trad = echappe_retour($trad, 'idiome'); |
|
| 1540 | + } |
|
| 1541 | + $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1542 | + } |
|
| 1543 | + } |
|
| 1544 | + } |
|
| 1545 | + return $letexte; |
|
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | 1548 | /** |
@@ -1594,64 +1594,64 @@ discard block |
||
| 1594 | 1594 | **/ |
| 1595 | 1595 | function extraire_multi($letexte, $lang = null, $options = array()) { |
| 1596 | 1596 | |
| 1597 | - if ($letexte |
|
| 1598 | - and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER) |
|
| 1599 | - ) { |
|
| 1600 | - if (!$lang) { |
|
| 1601 | - $lang = $GLOBALS['spip_lang']; |
|
| 1602 | - } |
|
| 1603 | - |
|
| 1604 | - // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1605 | - if (is_bool($options)) { |
|
| 1606 | - $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT); |
|
| 1607 | - } |
|
| 1608 | - if (!isset($options['echappe_span'])) { |
|
| 1609 | - $options = array_merge($options, array('echappe_span' => false)); |
|
| 1610 | - } |
|
| 1611 | - if (!isset($options['lang_defaut'])) { |
|
| 1612 | - $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT)); |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - include_spip('inc/lang'); |
|
| 1616 | - foreach ($regs as $reg) { |
|
| 1617 | - // chercher la version de la langue courante |
|
| 1618 | - $trads = extraire_trads($reg[1]); |
|
| 1619 | - if ($l = approcher_langue($trads, $lang)) { |
|
| 1620 | - $trad = $trads[$l]; |
|
| 1621 | - } else { |
|
| 1622 | - if ($options['lang_defaut'] == 'aucune') { |
|
| 1623 | - $trad = ''; |
|
| 1624 | - } else { |
|
| 1625 | - // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 1626 | - // ou la premiere dispo |
|
| 1627 | - // mais typographier le texte selon les regles de celle-ci |
|
| 1628 | - // Attention aux blocs multi sur plusieurs lignes |
|
| 1629 | - if (!$l = approcher_langue($trads, $options['lang_defaut'])) { |
|
| 1630 | - $l = key($trads); |
|
| 1631 | - } |
|
| 1632 | - $trad = $trads[$l]; |
|
| 1633 | - $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 1634 | - $trad = $typographie($trad); |
|
| 1635 | - // Tester si on echappe en span ou en div |
|
| 1636 | - // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 1637 | - include_spip('inc/texte'); |
|
| 1638 | - $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad)); |
|
| 1639 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1640 | - $trad = code_echappement($trad, 'multi', false, $mode); |
|
| 1641 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1642 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1643 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1644 | - } |
|
| 1645 | - if (!$options['echappe_span']) { |
|
| 1646 | - $trad = echappe_retour($trad, 'multi'); |
|
| 1647 | - } |
|
| 1648 | - } |
|
| 1649 | - } |
|
| 1650 | - $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1651 | - } |
|
| 1652 | - } |
|
| 1653 | - |
|
| 1654 | - return $letexte; |
|
| 1597 | + if ($letexte |
|
| 1598 | + and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER) |
|
| 1599 | + ) { |
|
| 1600 | + if (!$lang) { |
|
| 1601 | + $lang = $GLOBALS['spip_lang']; |
|
| 1602 | + } |
|
| 1603 | + |
|
| 1604 | + // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1605 | + if (is_bool($options)) { |
|
| 1606 | + $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT); |
|
| 1607 | + } |
|
| 1608 | + if (!isset($options['echappe_span'])) { |
|
| 1609 | + $options = array_merge($options, array('echappe_span' => false)); |
|
| 1610 | + } |
|
| 1611 | + if (!isset($options['lang_defaut'])) { |
|
| 1612 | + $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT)); |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + include_spip('inc/lang'); |
|
| 1616 | + foreach ($regs as $reg) { |
|
| 1617 | + // chercher la version de la langue courante |
|
| 1618 | + $trads = extraire_trads($reg[1]); |
|
| 1619 | + if ($l = approcher_langue($trads, $lang)) { |
|
| 1620 | + $trad = $trads[$l]; |
|
| 1621 | + } else { |
|
| 1622 | + if ($options['lang_defaut'] == 'aucune') { |
|
| 1623 | + $trad = ''; |
|
| 1624 | + } else { |
|
| 1625 | + // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 1626 | + // ou la premiere dispo |
|
| 1627 | + // mais typographier le texte selon les regles de celle-ci |
|
| 1628 | + // Attention aux blocs multi sur plusieurs lignes |
|
| 1629 | + if (!$l = approcher_langue($trads, $options['lang_defaut'])) { |
|
| 1630 | + $l = key($trads); |
|
| 1631 | + } |
|
| 1632 | + $trad = $trads[$l]; |
|
| 1633 | + $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 1634 | + $trad = $typographie($trad); |
|
| 1635 | + // Tester si on echappe en span ou en div |
|
| 1636 | + // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 1637 | + include_spip('inc/texte'); |
|
| 1638 | + $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad)); |
|
| 1639 | + $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1640 | + $trad = code_echappement($trad, 'multi', false, $mode); |
|
| 1641 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1642 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1643 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1644 | + } |
|
| 1645 | + if (!$options['echappe_span']) { |
|
| 1646 | + $trad = echappe_retour($trad, 'multi'); |
|
| 1647 | + } |
|
| 1648 | + } |
|
| 1649 | + } |
|
| 1650 | + $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1651 | + } |
|
| 1652 | + } |
|
| 1653 | + |
|
| 1654 | + return $letexte; |
|
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | 1657 | /** |
@@ -1667,20 +1667,20 @@ discard block |
||
| 1667 | 1667 | * Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué. |
| 1668 | 1668 | **/ |
| 1669 | 1669 | function extraire_trads($bloc) { |
| 1670 | - $lang = ''; |
|
| 1670 | + $lang = ''; |
|
| 1671 | 1671 | // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ |
| 1672 | 1672 | // while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) { |
| 1673 | - while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) { |
|
| 1674 | - $texte = trim($regs[1]); |
|
| 1675 | - if ($texte or $lang) { |
|
| 1676 | - $trads[$lang] = $texte; |
|
| 1677 | - } |
|
| 1678 | - $bloc = substr($bloc, strlen($regs[0])); |
|
| 1679 | - $lang = $regs[2]; |
|
| 1680 | - } |
|
| 1681 | - $trads[$lang] = $bloc; |
|
| 1673 | + while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) { |
|
| 1674 | + $texte = trim($regs[1]); |
|
| 1675 | + if ($texte or $lang) { |
|
| 1676 | + $trads[$lang] = $texte; |
|
| 1677 | + } |
|
| 1678 | + $bloc = substr($bloc, strlen($regs[0])); |
|
| 1679 | + $lang = $regs[2]; |
|
| 1680 | + } |
|
| 1681 | + $trads[$lang] = $bloc; |
|
| 1682 | 1682 | |
| 1683 | - return $trads; |
|
| 1683 | + return $trads; |
|
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | |
@@ -1691,7 +1691,7 @@ discard block |
||
| 1691 | 1691 | * @return string L'initiale en majuscule |
| 1692 | 1692 | */ |
| 1693 | 1693 | function filtre_initiale($nom) { |
| 1694 | - return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1); |
|
| 1694 | + return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1); |
|
| 1695 | 1695 | } |
| 1696 | 1696 | |
| 1697 | 1697 | |
@@ -1736,33 +1736,33 @@ discard block |
||
| 1736 | 1736 | * - null (interne) : si on empile |
| 1737 | 1737 | **/ |
| 1738 | 1738 | function unique($donnee, $famille = '', $cpt = false) { |
| 1739 | - static $mem = array(); |
|
| 1740 | - // permettre de vider la pile et de la restaurer |
|
| 1741 | - // pour le calcul de introduction... |
|
| 1742 | - if ($famille == '_spip_raz_') { |
|
| 1743 | - $tmp = $mem; |
|
| 1744 | - $mem = array(); |
|
| 1745 | - |
|
| 1746 | - return $tmp; |
|
| 1747 | - } elseif ($famille == '_spip_set_') { |
|
| 1748 | - $mem = $donnee; |
|
| 1749 | - |
|
| 1750 | - return; |
|
| 1751 | - } |
|
| 1752 | - // eviter une notice |
|
| 1753 | - if (!isset($mem[$famille])) { |
|
| 1754 | - $mem[$famille] = array(); |
|
| 1755 | - } |
|
| 1756 | - if ($cpt) { |
|
| 1757 | - return count($mem[$famille]); |
|
| 1758 | - } |
|
| 1759 | - // eviter une notice |
|
| 1760 | - if (!isset($mem[$famille][$donnee])) { |
|
| 1761 | - $mem[$famille][$donnee] = 0; |
|
| 1762 | - } |
|
| 1763 | - if (!($mem[$famille][$donnee]++)) { |
|
| 1764 | - return $donnee; |
|
| 1765 | - } |
|
| 1739 | + static $mem = array(); |
|
| 1740 | + // permettre de vider la pile et de la restaurer |
|
| 1741 | + // pour le calcul de introduction... |
|
| 1742 | + if ($famille == '_spip_raz_') { |
|
| 1743 | + $tmp = $mem; |
|
| 1744 | + $mem = array(); |
|
| 1745 | + |
|
| 1746 | + return $tmp; |
|
| 1747 | + } elseif ($famille == '_spip_set_') { |
|
| 1748 | + $mem = $donnee; |
|
| 1749 | + |
|
| 1750 | + return; |
|
| 1751 | + } |
|
| 1752 | + // eviter une notice |
|
| 1753 | + if (!isset($mem[$famille])) { |
|
| 1754 | + $mem[$famille] = array(); |
|
| 1755 | + } |
|
| 1756 | + if ($cpt) { |
|
| 1757 | + return count($mem[$famille]); |
|
| 1758 | + } |
|
| 1759 | + // eviter une notice |
|
| 1760 | + if (!isset($mem[$famille][$donnee])) { |
|
| 1761 | + $mem[$famille][$donnee] = 0; |
|
| 1762 | + } |
|
| 1763 | + if (!($mem[$famille][$donnee]++)) { |
|
| 1764 | + return $donnee; |
|
| 1765 | + } |
|
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | |
@@ -1790,18 +1790,18 @@ discard block |
||
| 1790 | 1790 | * Une des valeurs en fonction du compteur. |
| 1791 | 1791 | **/ |
| 1792 | 1792 | function alterner($i) { |
| 1793 | - // recuperer les arguments (attention fonctions un peu space) |
|
| 1794 | - $num = func_num_args(); |
|
| 1795 | - $args = func_get_args(); |
|
| 1793 | + // recuperer les arguments (attention fonctions un peu space) |
|
| 1794 | + $num = func_num_args(); |
|
| 1795 | + $args = func_get_args(); |
|
| 1796 | 1796 | |
| 1797 | - if ($num == 2 && is_array($args[1])) { |
|
| 1798 | - $args = $args[1]; |
|
| 1799 | - array_unshift($args, ''); |
|
| 1800 | - $num = count($args); |
|
| 1801 | - } |
|
| 1797 | + if ($num == 2 && is_array($args[1])) { |
|
| 1798 | + $args = $args[1]; |
|
| 1799 | + array_unshift($args, ''); |
|
| 1800 | + $num = count($args); |
|
| 1801 | + } |
|
| 1802 | 1802 | |
| 1803 | - // renvoyer le i-ieme argument, modulo le nombre d'arguments |
|
| 1804 | - return $args[(intval($i) - 1) % ($num - 1) + 1]; |
|
| 1803 | + // renvoyer le i-ieme argument, modulo le nombre d'arguments |
|
| 1804 | + return $args[(intval($i) - 1) % ($num - 1) + 1]; |
|
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | 1807 | |
@@ -1826,46 +1826,46 @@ discard block |
||
| 1826 | 1826 | * - Tableau complet (si 2e argument) |
| 1827 | 1827 | **/ |
| 1828 | 1828 | function extraire_attribut($balise, $attribut, $complet = false) { |
| 1829 | - if (is_array($balise)) { |
|
| 1830 | - array_walk( |
|
| 1831 | - $balise, |
|
| 1832 | - function(&$a, $key, $t){ |
|
| 1833 | - $a = extraire_attribut($a, $t); |
|
| 1834 | - }, |
|
| 1835 | - $attribut |
|
| 1836 | - ); |
|
| 1837 | - |
|
| 1838 | - return $balise; |
|
| 1839 | - } |
|
| 1840 | - if (preg_match( |
|
| 1841 | - ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+' |
|
| 1842 | - . $attribut |
|
| 1843 | - . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS', |
|
| 1844 | - |
|
| 1845 | - $balise, $r)) { |
|
| 1846 | - if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) { |
|
| 1847 | - $r[4] = substr($r[3], 1, -1); |
|
| 1848 | - $r[3] = $r[3][0]; |
|
| 1849 | - } elseif ($r[3] !== '') { |
|
| 1850 | - $r[4] = $r[3]; |
|
| 1851 | - $r[3] = ''; |
|
| 1852 | - } else { |
|
| 1853 | - $r[4] = trim($r[2]); |
|
| 1854 | - } |
|
| 1855 | - $att = $r[4]; |
|
| 1856 | - if (strpos($att, "&#") !== false) { |
|
| 1857 | - $att = str_replace(array("'", "'", """, """), array("'", "'", '"', '"'), $att); |
|
| 1858 | - } |
|
| 1859 | - $att = filtrer_entites($att); |
|
| 1860 | - } else { |
|
| 1861 | - $att = null; |
|
| 1862 | - } |
|
| 1863 | - |
|
| 1864 | - if ($complet) { |
|
| 1865 | - return array($att, $r); |
|
| 1866 | - } else { |
|
| 1867 | - return $att; |
|
| 1868 | - } |
|
| 1829 | + if (is_array($balise)) { |
|
| 1830 | + array_walk( |
|
| 1831 | + $balise, |
|
| 1832 | + function(&$a, $key, $t){ |
|
| 1833 | + $a = extraire_attribut($a, $t); |
|
| 1834 | + }, |
|
| 1835 | + $attribut |
|
| 1836 | + ); |
|
| 1837 | + |
|
| 1838 | + return $balise; |
|
| 1839 | + } |
|
| 1840 | + if (preg_match( |
|
| 1841 | + ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+' |
|
| 1842 | + . $attribut |
|
| 1843 | + . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS', |
|
| 1844 | + |
|
| 1845 | + $balise, $r)) { |
|
| 1846 | + if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) { |
|
| 1847 | + $r[4] = substr($r[3], 1, -1); |
|
| 1848 | + $r[3] = $r[3][0]; |
|
| 1849 | + } elseif ($r[3] !== '') { |
|
| 1850 | + $r[4] = $r[3]; |
|
| 1851 | + $r[3] = ''; |
|
| 1852 | + } else { |
|
| 1853 | + $r[4] = trim($r[2]); |
|
| 1854 | + } |
|
| 1855 | + $att = $r[4]; |
|
| 1856 | + if (strpos($att, "&#") !== false) { |
|
| 1857 | + $att = str_replace(array("'", "'", """, """), array("'", "'", '"', '"'), $att); |
|
| 1858 | + } |
|
| 1859 | + $att = filtrer_entites($att); |
|
| 1860 | + } else { |
|
| 1861 | + $att = null; |
|
| 1862 | + } |
|
| 1863 | + |
|
| 1864 | + if ($complet) { |
|
| 1865 | + return array($att, $r); |
|
| 1866 | + } else { |
|
| 1867 | + return $att; |
|
| 1868 | + } |
|
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | 1871 | /** |
@@ -1897,37 +1897,37 @@ discard block |
||
| 1897 | 1897 | * Code html modifié |
| 1898 | 1898 | **/ |
| 1899 | 1899 | function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) { |
| 1900 | - // preparer l'attribut |
|
| 1901 | - // supprimer les etc mais pas les balises html |
|
| 1902 | - // qui ont un sens dans un attribut value d'un input |
|
| 1903 | - if ($proteger) { |
|
| 1904 | - $val = attribut_html($val, false); |
|
| 1905 | - } |
|
| 1906 | - |
|
| 1907 | - // echapper les ' pour eviter tout bug |
|
| 1908 | - $val = str_replace("'", "'", $val); |
|
| 1909 | - if ($vider and strlen($val) == 0) { |
|
| 1910 | - $insert = ''; |
|
| 1911 | - } else { |
|
| 1912 | - $insert = " $attribut='$val'"; |
|
| 1913 | - } |
|
| 1914 | - |
|
| 1915 | - list($old, $r) = extraire_attribut($balise, $attribut, true); |
|
| 1916 | - |
|
| 1917 | - if ($old !== null) { |
|
| 1918 | - // Remplacer l'ancien attribut du meme nom |
|
| 1919 | - $balise = $r[1] . $insert . $r[5]; |
|
| 1920 | - } else { |
|
| 1921 | - // preferer une balise " />" (comme <img />) |
|
| 1922 | - if (preg_match(',/>,', $balise)) { |
|
| 1923 | - $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1); |
|
| 1924 | - } // sinon une balise <a ...> ... </a> |
|
| 1925 | - else { |
|
| 1926 | - $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1); |
|
| 1927 | - } |
|
| 1928 | - } |
|
| 1929 | - |
|
| 1930 | - return $balise; |
|
| 1900 | + // preparer l'attribut |
|
| 1901 | + // supprimer les etc mais pas les balises html |
|
| 1902 | + // qui ont un sens dans un attribut value d'un input |
|
| 1903 | + if ($proteger) { |
|
| 1904 | + $val = attribut_html($val, false); |
|
| 1905 | + } |
|
| 1906 | + |
|
| 1907 | + // echapper les ' pour eviter tout bug |
|
| 1908 | + $val = str_replace("'", "'", $val); |
|
| 1909 | + if ($vider and strlen($val) == 0) { |
|
| 1910 | + $insert = ''; |
|
| 1911 | + } else { |
|
| 1912 | + $insert = " $attribut='$val'"; |
|
| 1913 | + } |
|
| 1914 | + |
|
| 1915 | + list($old, $r) = extraire_attribut($balise, $attribut, true); |
|
| 1916 | + |
|
| 1917 | + if ($old !== null) { |
|
| 1918 | + // Remplacer l'ancien attribut du meme nom |
|
| 1919 | + $balise = $r[1] . $insert . $r[5]; |
|
| 1920 | + } else { |
|
| 1921 | + // preferer une balise " />" (comme <img />) |
|
| 1922 | + if (preg_match(',/>,', $balise)) { |
|
| 1923 | + $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1); |
|
| 1924 | + } // sinon une balise <a ...> ... </a> |
|
| 1925 | + else { |
|
| 1926 | + $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1); |
|
| 1927 | + } |
|
| 1928 | + } |
|
| 1929 | + |
|
| 1930 | + return $balise; |
|
| 1931 | 1931 | } |
| 1932 | 1932 | |
| 1933 | 1933 | /** |
@@ -1945,7 +1945,7 @@ discard block |
||
| 1945 | 1945 | * @return string Code HTML sans l'attribut |
| 1946 | 1946 | **/ |
| 1947 | 1947 | function vider_attribut($balise, $attribut) { |
| 1948 | - return inserer_attribut($balise, $attribut, '', false, true); |
|
| 1948 | + return inserer_attribut($balise, $attribut, '', false, true); |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | 1951 | |
@@ -1957,9 +1957,9 @@ discard block |
||
| 1957 | 1957 | * @return string |
| 1958 | 1958 | */ |
| 1959 | 1959 | function tester_config($id, $mode = '') { |
| 1960 | - include_spip('action/inscrire_auteur'); |
|
| 1960 | + include_spip('action/inscrire_auteur'); |
|
| 1961 | 1961 | |
| 1962 | - return tester_statut_inscription($mode, $id); |
|
| 1962 | + return tester_statut_inscription($mode, $id); |
|
| 1963 | 1963 | } |
| 1964 | 1964 | |
| 1965 | 1965 | // |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | * @return int $a+$b |
| 1985 | 1985 | **/ |
| 1986 | 1986 | function plus($a, $b) { |
| 1987 | - return $a + $b; |
|
| 1987 | + return $a + $b; |
|
| 1988 | 1988 | } |
| 1989 | 1989 | function strplus($a, $b) {return strize('plus', $a, $b);} |
| 1990 | 1990 | /** |
@@ -2003,7 +2003,7 @@ discard block |
||
| 2003 | 2003 | * @return int $a-$b |
| 2004 | 2004 | **/ |
| 2005 | 2005 | function moins($a, $b) { |
| 2006 | - return $a - $b; |
|
| 2006 | + return $a - $b; |
|
| 2007 | 2007 | } |
| 2008 | 2008 | function strmoins($a, $b) {return strize('moins', $a, $b);} |
| 2009 | 2009 | |
@@ -2024,7 +2024,7 @@ discard block |
||
| 2024 | 2024 | * @return int $a*$b |
| 2025 | 2025 | **/ |
| 2026 | 2026 | function mult($a, $b) { |
| 2027 | - return $a * $b; |
|
| 2027 | + return $a * $b; |
|
| 2028 | 2028 | } |
| 2029 | 2029 | function strmult($a, $b) {return strize('mult', $a, $b);} |
| 2030 | 2030 | |
@@ -2045,7 +2045,7 @@ discard block |
||
| 2045 | 2045 | * @return int $a/$b (ou 0 si $b est nul) |
| 2046 | 2046 | **/ |
| 2047 | 2047 | function div($a, $b) { |
| 2048 | - return $b ? $a / $b : 0; |
|
| 2048 | + return $b ? $a / $b : 0; |
|
| 2049 | 2049 | } |
| 2050 | 2050 | function strdiv($a, $b) {return strize('div', $a, $b);} |
| 2051 | 2051 | |
@@ -2067,7 +2067,7 @@ discard block |
||
| 2067 | 2067 | * @return int ($nb % $mod) + $add |
| 2068 | 2068 | **/ |
| 2069 | 2069 | function modulo($nb, $mod, $add = 0) { |
| 2070 | - return ($mod ? $nb % $mod : 0) + $add; |
|
| 2070 | + return ($mod ? $nb % $mod : 0) + $add; |
|
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | 2073 | |
@@ -2082,24 +2082,24 @@ discard block |
||
| 2082 | 2082 | * - true sinon |
| 2083 | 2083 | **/ |
| 2084 | 2084 | function nom_acceptable($nom) { |
| 2085 | - if (!is_string($nom)) { |
|
| 2086 | - return false; |
|
| 2087 | - } |
|
| 2088 | - if (!defined('_TAGS_NOM_AUTEUR')) { |
|
| 2089 | - define('_TAGS_NOM_AUTEUR', ''); |
|
| 2090 | - } |
|
| 2091 | - $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2092 | - foreach ($tags_acceptes as $tag) { |
|
| 2093 | - if (strlen($tag)) { |
|
| 2094 | - $remp1[] = '<' . trim($tag) . '>'; |
|
| 2095 | - $remp1[] = '</' . trim($tag) . '>'; |
|
| 2096 | - $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2097 | - $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2098 | - } |
|
| 2099 | - } |
|
| 2100 | - $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
|
| 2085 | + if (!is_string($nom)) { |
|
| 2086 | + return false; |
|
| 2087 | + } |
|
| 2088 | + if (!defined('_TAGS_NOM_AUTEUR')) { |
|
| 2089 | + define('_TAGS_NOM_AUTEUR', ''); |
|
| 2090 | + } |
|
| 2091 | + $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2092 | + foreach ($tags_acceptes as $tag) { |
|
| 2093 | + if (strlen($tag)) { |
|
| 2094 | + $remp1[] = '<' . trim($tag) . '>'; |
|
| 2095 | + $remp1[] = '</' . trim($tag) . '>'; |
|
| 2096 | + $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2097 | + $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2098 | + } |
|
| 2099 | + } |
|
| 2100 | + $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
|
| 2101 | 2101 | |
| 2102 | - return str_replace('<', '<', $v_nom) == $nom; |
|
| 2102 | + return str_replace('<', '<', $v_nom) == $nom; |
|
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | 2105 | |
@@ -2113,29 +2113,29 @@ discard block |
||
| 2113 | 2113 | * - la normalisation de la dernière adresse donnée sinon |
| 2114 | 2114 | **/ |
| 2115 | 2115 | function email_valide($adresses) { |
| 2116 | - // eviter d'injecter n'importe quoi dans preg_match |
|
| 2117 | - if (!is_string($adresses)) { |
|
| 2118 | - return false; |
|
| 2119 | - } |
|
| 2116 | + // eviter d'injecter n'importe quoi dans preg_match |
|
| 2117 | + if (!is_string($adresses)) { |
|
| 2118 | + return false; |
|
| 2119 | + } |
|
| 2120 | 2120 | |
| 2121 | - // Si c'est un spammeur autant arreter tout de suite |
|
| 2122 | - if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 2123 | - spip_log("Tentative d'injection de mail : $adresses"); |
|
| 2121 | + // Si c'est un spammeur autant arreter tout de suite |
|
| 2122 | + if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 2123 | + spip_log("Tentative d'injection de mail : $adresses"); |
|
| 2124 | 2124 | |
| 2125 | - return false; |
|
| 2126 | - } |
|
| 2125 | + return false; |
|
| 2126 | + } |
|
| 2127 | 2127 | |
| 2128 | - foreach (explode(',', $adresses) as $v) { |
|
| 2129 | - // nettoyer certains formats |
|
| 2130 | - // "Marie Toto <[email protected]>" |
|
| 2131 | - $adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v)); |
|
| 2132 | - // RFC 822 |
|
| 2133 | - if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 2134 | - return false; |
|
| 2135 | - } |
|
| 2136 | - } |
|
| 2128 | + foreach (explode(',', $adresses) as $v) { |
|
| 2129 | + // nettoyer certains formats |
|
| 2130 | + // "Marie Toto <[email protected]>" |
|
| 2131 | + $adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v)); |
|
| 2132 | + // RFC 822 |
|
| 2133 | + if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 2134 | + return false; |
|
| 2135 | + } |
|
| 2136 | + } |
|
| 2137 | 2137 | |
| 2138 | - return $adresse; |
|
| 2138 | + return $adresse; |
|
| 2139 | 2139 | } |
| 2140 | 2140 | |
| 2141 | 2141 | /** |
@@ -2149,20 +2149,20 @@ discard block |
||
| 2149 | 2149 | * @return string Texte |
| 2150 | 2150 | **/ |
| 2151 | 2151 | function afficher_enclosures($tags) { |
| 2152 | - $s = array(); |
|
| 2153 | - foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2154 | - if (extraire_attribut($tag, 'rel') == 'enclosure' |
|
| 2155 | - and $t = extraire_attribut($tag, 'href') |
|
| 2156 | - ) { |
|
| 2157 | - $s[] = preg_replace(',>[^<]+</a>,S', |
|
| 2158 | - '>' |
|
| 2159 | - . http_img_pack('attachment-16.png', $t, |
|
| 2160 | - 'title="' . attribut_html($t) . '"') |
|
| 2161 | - . '</a>', $tag); |
|
| 2162 | - } |
|
| 2163 | - } |
|
| 2152 | + $s = array(); |
|
| 2153 | + foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2154 | + if (extraire_attribut($tag, 'rel') == 'enclosure' |
|
| 2155 | + and $t = extraire_attribut($tag, 'href') |
|
| 2156 | + ) { |
|
| 2157 | + $s[] = preg_replace(',>[^<]+</a>,S', |
|
| 2158 | + '>' |
|
| 2159 | + . http_img_pack('attachment-16.png', $t, |
|
| 2160 | + 'title="' . attribut_html($t) . '"') |
|
| 2161 | + . '</a>', $tag); |
|
| 2162 | + } |
|
| 2163 | + } |
|
| 2164 | 2164 | |
| 2165 | - return join(' ', $s); |
|
| 2165 | + return join(' ', $s); |
|
| 2166 | 2166 | } |
| 2167 | 2167 | |
| 2168 | 2168 | /** |
@@ -2177,15 +2177,15 @@ discard block |
||
| 2177 | 2177 | * @return string Liens trouvés |
| 2178 | 2178 | **/ |
| 2179 | 2179 | function afficher_tags($tags, $rels = 'tag,directory') { |
| 2180 | - $s = array(); |
|
| 2181 | - foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2182 | - $rel = extraire_attribut($tag, 'rel'); |
|
| 2183 | - if (strstr(",$rels,", ",$rel,")) { |
|
| 2184 | - $s[] = $tag; |
|
| 2185 | - } |
|
| 2186 | - } |
|
| 2180 | + $s = array(); |
|
| 2181 | + foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2182 | + $rel = extraire_attribut($tag, 'rel'); |
|
| 2183 | + if (strstr(",$rels,", ",$rel,")) { |
|
| 2184 | + $s[] = $tag; |
|
| 2185 | + } |
|
| 2186 | + } |
|
| 2187 | 2187 | |
| 2188 | - return join(', ', $s); |
|
| 2188 | + return join(', ', $s); |
|
| 2189 | 2189 | } |
| 2190 | 2190 | |
| 2191 | 2191 | |
@@ -2207,21 +2207,21 @@ discard block |
||
| 2207 | 2207 | * @return string Tag HTML `<a>` avec microformat. |
| 2208 | 2208 | **/ |
| 2209 | 2209 | function enclosure2microformat($e) { |
| 2210 | - if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) { |
|
| 2211 | - $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2212 | - } |
|
| 2213 | - $type = extraire_attribut($e, 'type'); |
|
| 2214 | - if (!$length = extraire_attribut($e, 'length')) { |
|
| 2215 | - # <media:content : longeur dans fileSize. On tente. |
|
| 2216 | - $length = extraire_attribut($e, 'fileSize'); |
|
| 2217 | - } |
|
| 2218 | - $fichier = basename($url); |
|
| 2210 | + if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) { |
|
| 2211 | + $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2212 | + } |
|
| 2213 | + $type = extraire_attribut($e, 'type'); |
|
| 2214 | + if (!$length = extraire_attribut($e, 'length')) { |
|
| 2215 | + # <media:content : longeur dans fileSize. On tente. |
|
| 2216 | + $length = extraire_attribut($e, 'fileSize'); |
|
| 2217 | + } |
|
| 2218 | + $fichier = basename($url); |
|
| 2219 | 2219 | |
| 2220 | - return '<a rel="enclosure"' |
|
| 2221 | - . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2222 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2223 | - . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2224 | - . '>' . $fichier . '</a>'; |
|
| 2220 | + return '<a rel="enclosure"' |
|
| 2221 | + . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2222 | + . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2223 | + . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2224 | + . '>' . $fichier . '</a>'; |
|
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | 2227 | /** |
@@ -2239,24 +2239,24 @@ discard block |
||
| 2239 | 2239 | * @return string Tags RSS `<enclosure>`. |
| 2240 | 2240 | **/ |
| 2241 | 2241 | function microformat2enclosure($tags) { |
| 2242 | - $enclosures = array(); |
|
| 2243 | - foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2244 | - if (extraire_attribut($e, 'rel') == 'enclosure') { |
|
| 2245 | - $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2246 | - $type = extraire_attribut($e, 'type'); |
|
| 2247 | - if (!$length = intval(extraire_attribut($e, 'title'))) { |
|
| 2248 | - $length = intval(extraire_attribut($e, 'length')); |
|
| 2249 | - } # vieux data |
|
| 2250 | - $fichier = basename($url); |
|
| 2251 | - $enclosures[] = '<enclosure' |
|
| 2252 | - . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2253 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2254 | - . ($length ? ' length="' . $length . '"' : '') |
|
| 2255 | - . ' />'; |
|
| 2256 | - } |
|
| 2257 | - } |
|
| 2242 | + $enclosures = array(); |
|
| 2243 | + foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2244 | + if (extraire_attribut($e, 'rel') == 'enclosure') { |
|
| 2245 | + $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2246 | + $type = extraire_attribut($e, 'type'); |
|
| 2247 | + if (!$length = intval(extraire_attribut($e, 'title'))) { |
|
| 2248 | + $length = intval(extraire_attribut($e, 'length')); |
|
| 2249 | + } # vieux data |
|
| 2250 | + $fichier = basename($url); |
|
| 2251 | + $enclosures[] = '<enclosure' |
|
| 2252 | + . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2253 | + . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2254 | + . ($length ? ' length="' . $length . '"' : '') |
|
| 2255 | + . ' />'; |
|
| 2256 | + } |
|
| 2257 | + } |
|
| 2258 | 2258 | |
| 2259 | - return join("\n", $enclosures); |
|
| 2259 | + return join("\n", $enclosures); |
|
| 2260 | 2260 | } |
| 2261 | 2261 | |
| 2262 | 2262 | |
@@ -2272,16 +2272,16 @@ discard block |
||
| 2272 | 2272 | * @return string Tags RSS Atom `<dc:subject>`. |
| 2273 | 2273 | **/ |
| 2274 | 2274 | function tags2dcsubject($tags) { |
| 2275 | - $subjects = ''; |
|
| 2276 | - foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2277 | - if (extraire_attribut($e, rel) == 'tag') { |
|
| 2278 | - $subjects .= '<dc:subject>' |
|
| 2279 | - . texte_backend(textebrut($e)) |
|
| 2280 | - . '</dc:subject>' . "\n"; |
|
| 2281 | - } |
|
| 2282 | - } |
|
| 2275 | + $subjects = ''; |
|
| 2276 | + foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2277 | + if (extraire_attribut($e, rel) == 'tag') { |
|
| 2278 | + $subjects .= '<dc:subject>' |
|
| 2279 | + . texte_backend(textebrut($e)) |
|
| 2280 | + . '</dc:subject>' . "\n"; |
|
| 2281 | + } |
|
| 2282 | + } |
|
| 2283 | 2283 | |
| 2284 | - return $subjects; |
|
| 2284 | + return $subjects; |
|
| 2285 | 2285 | } |
| 2286 | 2286 | |
| 2287 | 2287 | /** |
@@ -2310,23 +2310,23 @@ discard block |
||
| 2310 | 2310 | * - Tableau de résultats, si tableau en entrée. |
| 2311 | 2311 | **/ |
| 2312 | 2312 | function extraire_balise($texte, $tag = 'a') { |
| 2313 | - if (is_array($texte)) { |
|
| 2314 | - array_walk( |
|
| 2315 | - $texte, |
|
| 2316 | - function(&$a, $key, $t){ |
|
| 2317 | - $a = extraire_balise($a, $t); |
|
| 2318 | - }, |
|
| 2319 | - $tag |
|
| 2320 | - ); |
|
| 2313 | + if (is_array($texte)) { |
|
| 2314 | + array_walk( |
|
| 2315 | + $texte, |
|
| 2316 | + function(&$a, $key, $t){ |
|
| 2317 | + $a = extraire_balise($a, $t); |
|
| 2318 | + }, |
|
| 2319 | + $tag |
|
| 2320 | + ); |
|
| 2321 | 2321 | |
| 2322 | - return $texte; |
|
| 2323 | - } |
|
| 2322 | + return $texte; |
|
| 2323 | + } |
|
| 2324 | 2324 | |
| 2325 | - if (preg_match( |
|
| 2326 | - ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2327 | - $texte, $regs)) { |
|
| 2328 | - return $regs[0]; |
|
| 2329 | - } |
|
| 2325 | + if (preg_match( |
|
| 2326 | + ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2327 | + $texte, $regs)) { |
|
| 2328 | + return $regs[0]; |
|
| 2329 | + } |
|
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | 2332 | /** |
@@ -2354,25 +2354,25 @@ discard block |
||
| 2354 | 2354 | * - Tableau de résultats, si tableau en entrée. |
| 2355 | 2355 | **/ |
| 2356 | 2356 | function extraire_balises($texte, $tag = 'a') { |
| 2357 | - if (is_array($texte)) { |
|
| 2358 | - array_walk( |
|
| 2359 | - $texte, |
|
| 2360 | - function(&$a, $key, $t){ |
|
| 2361 | - $a = extraire_balises($a, $t); |
|
| 2362 | - }, |
|
| 2363 | - $tag |
|
| 2364 | - ); |
|
| 2357 | + if (is_array($texte)) { |
|
| 2358 | + array_walk( |
|
| 2359 | + $texte, |
|
| 2360 | + function(&$a, $key, $t){ |
|
| 2361 | + $a = extraire_balises($a, $t); |
|
| 2362 | + }, |
|
| 2363 | + $tag |
|
| 2364 | + ); |
|
| 2365 | 2365 | |
| 2366 | - return $texte; |
|
| 2367 | - } |
|
| 2366 | + return $texte; |
|
| 2367 | + } |
|
| 2368 | 2368 | |
| 2369 | - if (preg_match_all( |
|
| 2370 | - ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2371 | - $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 2372 | - return $regs[0]; |
|
| 2373 | - } else { |
|
| 2374 | - return array(); |
|
| 2375 | - } |
|
| 2369 | + if (preg_match_all( |
|
| 2370 | + ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2371 | + $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 2372 | + return $regs[0]; |
|
| 2373 | + } else { |
|
| 2374 | + return array(); |
|
| 2375 | + } |
|
| 2376 | 2376 | } |
| 2377 | 2377 | |
| 2378 | 2378 | /** |
@@ -2401,11 +2401,11 @@ discard block |
||
| 2401 | 2401 | * - `$def` si on n'a pas transmis de tableau |
| 2402 | 2402 | **/ |
| 2403 | 2403 | function in_any($val, $vals, $def = '') { |
| 2404 | - if (!is_array($vals) and $v = unserialize($vals)) { |
|
| 2405 | - $vals = $v; |
|
| 2406 | - } |
|
| 2404 | + if (!is_array($vals) and $v = unserialize($vals)) { |
|
| 2405 | + $vals = $v; |
|
| 2406 | + } |
|
| 2407 | 2407 | |
| 2408 | - return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : '')); |
|
| 2408 | + return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : '')); |
|
| 2409 | 2409 | } |
| 2410 | 2410 | |
| 2411 | 2411 | |
@@ -2426,12 +2426,12 @@ discard block |
||
| 2426 | 2426 | * Résultat du calcul |
| 2427 | 2427 | **/ |
| 2428 | 2428 | function valeur_numerique($expr) { |
| 2429 | - $a = 0; |
|
| 2430 | - if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) { |
|
| 2431 | - eval("\$a = $expr;"); |
|
| 2432 | - } |
|
| 2429 | + $a = 0; |
|
| 2430 | + if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) { |
|
| 2431 | + eval("\$a = $expr;"); |
|
| 2432 | + } |
|
| 2433 | 2433 | |
| 2434 | - return intval($a); |
|
| 2434 | + return intval($a); |
|
| 2435 | 2435 | } |
| 2436 | 2436 | |
| 2437 | 2437 | /** |
@@ -2450,7 +2450,7 @@ discard block |
||
| 2450 | 2450 | * Retourne `$a*$b/$c` |
| 2451 | 2451 | **/ |
| 2452 | 2452 | function regledetrois($a, $b, $c) { |
| 2453 | - return round($a * $b / $c); |
|
| 2453 | + return round($a * $b / $c); |
|
| 2454 | 2454 | } |
| 2455 | 2455 | |
| 2456 | 2456 | |
@@ -2474,76 +2474,76 @@ discard block |
||
| 2474 | 2474 | **/ |
| 2475 | 2475 | function form_hidden($action) { |
| 2476 | 2476 | |
| 2477 | - $contexte = array(); |
|
| 2478 | - include_spip('inc/urls'); |
|
| 2479 | - if ($p = urls_decoder_url($action, '') |
|
| 2480 | - and reset($p) |
|
| 2481 | - ) { |
|
| 2482 | - $fond = array_shift($p); |
|
| 2483 | - if ($fond != '404') { |
|
| 2484 | - $contexte = array_shift($p); |
|
| 2485 | - $contexte['page'] = $fond; |
|
| 2486 | - $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2487 | - } |
|
| 2488 | - } |
|
| 2489 | - // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
|
| 2490 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 2491 | - unset($contexte['type']); |
|
| 2492 | - } |
|
| 2493 | - if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 2494 | - unset($contexte['type-page']); |
|
| 2495 | - } |
|
| 2496 | - |
|
| 2497 | - // on va remplir un tableau de valeurs en prenant bien soin de ne pas |
|
| 2498 | - // ecraser les elements de la forme mots[]=1&mots[]=2 |
|
| 2499 | - $values = array(); |
|
| 2500 | - |
|
| 2501 | - // d'abord avec celles de l'url |
|
| 2502 | - if (false !== ($p = strpos($action, '?'))) { |
|
| 2503 | - foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) { |
|
| 2504 | - $c = explode('=', $c, 2); |
|
| 2505 | - $var = array_shift($c); |
|
| 2506 | - $val = array_shift($c); |
|
| 2507 | - if ($var) { |
|
| 2508 | - $val = rawurldecode($val); |
|
| 2509 | - $var = rawurldecode($var); // decoder les [] eventuels |
|
| 2510 | - if (preg_match(',\[\]$,S', $var)) { |
|
| 2511 | - $values[] = array($var, $val); |
|
| 2512 | - } else { |
|
| 2513 | - if (!isset($values[$var])) { |
|
| 2514 | - $values[$var] = array($var, $val); |
|
| 2515 | - } |
|
| 2516 | - } |
|
| 2517 | - } |
|
| 2518 | - } |
|
| 2519 | - } |
|
| 2520 | - |
|
| 2521 | - // ensuite avec celles du contexte, sans doublonner ! |
|
| 2522 | - foreach ($contexte as $var => $val) { |
|
| 2523 | - if (preg_match(',\[\]$,S', $var)) { |
|
| 2524 | - $values[] = array($var, $val); |
|
| 2525 | - } else { |
|
| 2526 | - if (!isset($values[$var])) { |
|
| 2527 | - $values[$var] = array($var, $val); |
|
| 2528 | - } |
|
| 2529 | - } |
|
| 2530 | - } |
|
| 2531 | - |
|
| 2532 | - // puis on rassemble le tout |
|
| 2533 | - $hidden = array(); |
|
| 2534 | - foreach ($values as $value) { |
|
| 2535 | - list($var, $val) = $value; |
|
| 2536 | - $hidden[] = '<input name="' |
|
| 2537 | - . entites_html($var) |
|
| 2538 | - . '"' |
|
| 2539 | - . (is_null($val) |
|
| 2540 | - ? '' |
|
| 2541 | - : ' value="' . entites_html($val) . '"' |
|
| 2542 | - ) |
|
| 2543 | - . ' type="hidden"' . "\n/>"; |
|
| 2544 | - } |
|
| 2545 | - |
|
| 2546 | - return join("", $hidden); |
|
| 2477 | + $contexte = array(); |
|
| 2478 | + include_spip('inc/urls'); |
|
| 2479 | + if ($p = urls_decoder_url($action, '') |
|
| 2480 | + and reset($p) |
|
| 2481 | + ) { |
|
| 2482 | + $fond = array_shift($p); |
|
| 2483 | + if ($fond != '404') { |
|
| 2484 | + $contexte = array_shift($p); |
|
| 2485 | + $contexte['page'] = $fond; |
|
| 2486 | + $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2487 | + } |
|
| 2488 | + } |
|
| 2489 | + // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
|
| 2490 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 2491 | + unset($contexte['type']); |
|
| 2492 | + } |
|
| 2493 | + if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 2494 | + unset($contexte['type-page']); |
|
| 2495 | + } |
|
| 2496 | + |
|
| 2497 | + // on va remplir un tableau de valeurs en prenant bien soin de ne pas |
|
| 2498 | + // ecraser les elements de la forme mots[]=1&mots[]=2 |
|
| 2499 | + $values = array(); |
|
| 2500 | + |
|
| 2501 | + // d'abord avec celles de l'url |
|
| 2502 | + if (false !== ($p = strpos($action, '?'))) { |
|
| 2503 | + foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) { |
|
| 2504 | + $c = explode('=', $c, 2); |
|
| 2505 | + $var = array_shift($c); |
|
| 2506 | + $val = array_shift($c); |
|
| 2507 | + if ($var) { |
|
| 2508 | + $val = rawurldecode($val); |
|
| 2509 | + $var = rawurldecode($var); // decoder les [] eventuels |
|
| 2510 | + if (preg_match(',\[\]$,S', $var)) { |
|
| 2511 | + $values[] = array($var, $val); |
|
| 2512 | + } else { |
|
| 2513 | + if (!isset($values[$var])) { |
|
| 2514 | + $values[$var] = array($var, $val); |
|
| 2515 | + } |
|
| 2516 | + } |
|
| 2517 | + } |
|
| 2518 | + } |
|
| 2519 | + } |
|
| 2520 | + |
|
| 2521 | + // ensuite avec celles du contexte, sans doublonner ! |
|
| 2522 | + foreach ($contexte as $var => $val) { |
|
| 2523 | + if (preg_match(',\[\]$,S', $var)) { |
|
| 2524 | + $values[] = array($var, $val); |
|
| 2525 | + } else { |
|
| 2526 | + if (!isset($values[$var])) { |
|
| 2527 | + $values[$var] = array($var, $val); |
|
| 2528 | + } |
|
| 2529 | + } |
|
| 2530 | + } |
|
| 2531 | + |
|
| 2532 | + // puis on rassemble le tout |
|
| 2533 | + $hidden = array(); |
|
| 2534 | + foreach ($values as $value) { |
|
| 2535 | + list($var, $val) = $value; |
|
| 2536 | + $hidden[] = '<input name="' |
|
| 2537 | + . entites_html($var) |
|
| 2538 | + . '"' |
|
| 2539 | + . (is_null($val) |
|
| 2540 | + ? '' |
|
| 2541 | + : ' value="' . entites_html($val) . '"' |
|
| 2542 | + ) |
|
| 2543 | + . ' type="hidden"' . "\n/>"; |
|
| 2544 | + } |
|
| 2545 | + |
|
| 2546 | + return join("", $hidden); |
|
| 2547 | 2547 | } |
| 2548 | 2548 | |
| 2549 | 2549 | /** |
@@ -2561,15 +2561,15 @@ discard block |
||
| 2561 | 2561 | * Liste (première page, dernière page). |
| 2562 | 2562 | **/ |
| 2563 | 2563 | function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) { |
| 2564 | - if ($max <= 0 or $max >= $nombre) { |
|
| 2565 | - return array(1, $nombre); |
|
| 2566 | - } |
|
| 2564 | + if ($max <= 0 or $max >= $nombre) { |
|
| 2565 | + return array(1, $nombre); |
|
| 2566 | + } |
|
| 2567 | 2567 | |
| 2568 | - $premiere = max(1, $courante - floor(($max - 1) / 2)); |
|
| 2569 | - $derniere = min($nombre, $premiere + $max - 2); |
|
| 2570 | - $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere; |
|
| 2568 | + $premiere = max(1, $courante - floor(($max - 1) / 2)); |
|
| 2569 | + $derniere = min($nombre, $premiere + $max - 2); |
|
| 2570 | + $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere; |
|
| 2571 | 2571 | |
| 2572 | - return array($premiere, $derniere); |
|
| 2572 | + return array($premiere, $derniere); |
|
| 2573 | 2573 | } |
| 2574 | 2574 | |
| 2575 | 2575 | |
@@ -2591,7 +2591,7 @@ discard block |
||
| 2591 | 2591 | * - la première valeur du tableau sinon. |
| 2592 | 2592 | **/ |
| 2593 | 2593 | function filtre_reset($array) { |
| 2594 | - return !is_array($array) ? null : reset($array); |
|
| 2594 | + return !is_array($array) ? null : reset($array); |
|
| 2595 | 2595 | } |
| 2596 | 2596 | |
| 2597 | 2597 | /** |
@@ -2612,7 +2612,7 @@ discard block |
||
| 2612 | 2612 | * - la dernière valeur du tableau sinon. |
| 2613 | 2613 | **/ |
| 2614 | 2614 | function filtre_end($array) { |
| 2615 | - return !is_array($array) ? null : end($array); |
|
| 2615 | + return !is_array($array) ? null : end($array); |
|
| 2616 | 2616 | } |
| 2617 | 2617 | |
| 2618 | 2618 | /** |
@@ -2632,11 +2632,11 @@ discard block |
||
| 2632 | 2632 | * |
| 2633 | 2633 | **/ |
| 2634 | 2634 | function filtre_push($array, $val) { |
| 2635 | - if (!is_array($array) or !array_push($array, $val)) { |
|
| 2636 | - return ''; |
|
| 2637 | - } |
|
| 2635 | + if (!is_array($array) or !array_push($array, $val)) { |
|
| 2636 | + return ''; |
|
| 2637 | + } |
|
| 2638 | 2638 | |
| 2639 | - return $array; |
|
| 2639 | + return $array; |
|
| 2640 | 2640 | } |
| 2641 | 2641 | |
| 2642 | 2642 | /** |
@@ -2655,7 +2655,7 @@ discard block |
||
| 2655 | 2655 | * - `true` si la valeur existe dans le tableau, `false` sinon. |
| 2656 | 2656 | **/ |
| 2657 | 2657 | function filtre_find($array, $val) { |
| 2658 | - return (is_array($array) and in_array($val, $array)); |
|
| 2658 | + return (is_array($array) and in_array($val, $array)); |
|
| 2659 | 2659 | } |
| 2660 | 2660 | |
| 2661 | 2661 | |
@@ -2690,58 +2690,58 @@ discard block |
||
| 2690 | 2690 | * Code HTML de la pagination |
| 2691 | 2691 | **/ |
| 2692 | 2692 | function filtre_pagination_dist( |
| 2693 | - $total, |
|
| 2694 | - $nom, |
|
| 2695 | - $position, |
|
| 2696 | - $pas, |
|
| 2697 | - $liste = true, |
|
| 2698 | - $modele = '', |
|
| 2699 | - $connect = '', |
|
| 2700 | - $env = array() |
|
| 2693 | + $total, |
|
| 2694 | + $nom, |
|
| 2695 | + $position, |
|
| 2696 | + $pas, |
|
| 2697 | + $liste = true, |
|
| 2698 | + $modele = '', |
|
| 2699 | + $connect = '', |
|
| 2700 | + $env = array() |
|
| 2701 | 2701 | ) { |
| 2702 | - static $ancres = array(); |
|
| 2703 | - if ($pas < 1) { |
|
| 2704 | - return ''; |
|
| 2705 | - } |
|
| 2706 | - $ancre = 'pagination' . $nom; // #pagination_articles |
|
| 2707 | - $debut = 'debut' . $nom; // 'debut_articles' |
|
| 2708 | - |
|
| 2709 | - // n'afficher l'ancre qu'une fois |
|
| 2710 | - if (!isset($ancres[$ancre])) { |
|
| 2711 | - $bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>"; |
|
| 2712 | - } else { |
|
| 2713 | - $bloc_ancre = ''; |
|
| 2714 | - } |
|
| 2715 | - // liste = false : on ne veut que l'ancre |
|
| 2716 | - if (!$liste) { |
|
| 2717 | - return $ancres[$ancre]; |
|
| 2718 | - } |
|
| 2719 | - |
|
| 2720 | - $pagination = array( |
|
| 2721 | - 'debut' => $debut, |
|
| 2722 | - 'url' => parametre_url(self(), 'fragment', ''), // nettoyer l'id ahah eventuel |
|
| 2723 | - 'total' => $total, |
|
| 2724 | - 'position' => intval($position), |
|
| 2725 | - 'pas' => $pas, |
|
| 2726 | - 'nombre_pages' => floor(($total - 1) / $pas) + 1, |
|
| 2727 | - 'page_courante' => floor(intval($position) / $pas) + 1, |
|
| 2728 | - 'ancre' => $ancre, |
|
| 2729 | - 'bloc_ancre' => $bloc_ancre |
|
| 2730 | - ); |
|
| 2731 | - if (is_array($env)) { |
|
| 2732 | - $pagination = array_merge($env, $pagination); |
|
| 2733 | - } |
|
| 2734 | - |
|
| 2735 | - // Pas de pagination |
|
| 2736 | - if ($pagination['nombre_pages'] <= 1) { |
|
| 2737 | - return ''; |
|
| 2738 | - } |
|
| 2739 | - |
|
| 2740 | - if ($modele) { |
|
| 2741 | - $modele = '_' . $modele; |
|
| 2742 | - } |
|
| 2743 | - |
|
| 2744 | - return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect); |
|
| 2702 | + static $ancres = array(); |
|
| 2703 | + if ($pas < 1) { |
|
| 2704 | + return ''; |
|
| 2705 | + } |
|
| 2706 | + $ancre = 'pagination' . $nom; // #pagination_articles |
|
| 2707 | + $debut = 'debut' . $nom; // 'debut_articles' |
|
| 2708 | + |
|
| 2709 | + // n'afficher l'ancre qu'une fois |
|
| 2710 | + if (!isset($ancres[$ancre])) { |
|
| 2711 | + $bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>"; |
|
| 2712 | + } else { |
|
| 2713 | + $bloc_ancre = ''; |
|
| 2714 | + } |
|
| 2715 | + // liste = false : on ne veut que l'ancre |
|
| 2716 | + if (!$liste) { |
|
| 2717 | + return $ancres[$ancre]; |
|
| 2718 | + } |
|
| 2719 | + |
|
| 2720 | + $pagination = array( |
|
| 2721 | + 'debut' => $debut, |
|
| 2722 | + 'url' => parametre_url(self(), 'fragment', ''), // nettoyer l'id ahah eventuel |
|
| 2723 | + 'total' => $total, |
|
| 2724 | + 'position' => intval($position), |
|
| 2725 | + 'pas' => $pas, |
|
| 2726 | + 'nombre_pages' => floor(($total - 1) / $pas) + 1, |
|
| 2727 | + 'page_courante' => floor(intval($position) / $pas) + 1, |
|
| 2728 | + 'ancre' => $ancre, |
|
| 2729 | + 'bloc_ancre' => $bloc_ancre |
|
| 2730 | + ); |
|
| 2731 | + if (is_array($env)) { |
|
| 2732 | + $pagination = array_merge($env, $pagination); |
|
| 2733 | + } |
|
| 2734 | + |
|
| 2735 | + // Pas de pagination |
|
| 2736 | + if ($pagination['nombre_pages'] <= 1) { |
|
| 2737 | + return ''; |
|
| 2738 | + } |
|
| 2739 | + |
|
| 2740 | + if ($modele) { |
|
| 2741 | + $modele = '_' . $modele; |
|
| 2742 | + } |
|
| 2743 | + |
|
| 2744 | + return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect); |
|
| 2745 | 2745 | } |
| 2746 | 2746 | |
| 2747 | 2747 | |
@@ -2758,15 +2758,15 @@ discard block |
||
| 2758 | 2758 | * Contenu avec urls en absolus |
| 2759 | 2759 | **/ |
| 2760 | 2760 | function urls_absolues_css($contenu, $source) { |
| 2761 | - $path = suivre_lien(url_absolue($source), './'); |
|
| 2761 | + $path = suivre_lien(url_absolue($source), './'); |
|
| 2762 | 2762 | |
| 2763 | - return preg_replace_callback( |
|
| 2764 | - ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
|
| 2765 | - function($x) use ($path) { |
|
| 2766 | - return "url('" . suivre_lien($path, $x[1]) . "')"; |
|
| 2767 | - }, |
|
| 2768 | - $contenu |
|
| 2769 | - ); |
|
| 2763 | + return preg_replace_callback( |
|
| 2764 | + ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
|
| 2765 | + function($x) use ($path) { |
|
| 2766 | + return "url('" . suivre_lien($path, $x[1]) . "')"; |
|
| 2767 | + }, |
|
| 2768 | + $contenu |
|
| 2769 | + ); |
|
| 2770 | 2770 | } |
| 2771 | 2771 | |
| 2772 | 2772 | |
@@ -2795,118 +2795,118 @@ discard block |
||
| 2795 | 2795 | * Chemin du fichier CSS inversé |
| 2796 | 2796 | **/ |
| 2797 | 2797 | function direction_css($css, $voulue = '') { |
| 2798 | - if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) { |
|
| 2799 | - return $css; |
|
| 2800 | - } |
|
| 2801 | - |
|
| 2802 | - // si on a precise le sens voulu en argument, le prendre en compte |
|
| 2803 | - if ($voulue = strtolower($voulue)) { |
|
| 2804 | - if ($voulue != 'rtl' and $voulue != 'ltr') { |
|
| 2805 | - $voulue = lang_dir($voulue); |
|
| 2806 | - } |
|
| 2807 | - } else { |
|
| 2808 | - $voulue = lang_dir(); |
|
| 2809 | - } |
|
| 2810 | - |
|
| 2811 | - $r = count($r) > 1; |
|
| 2812 | - $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree |
|
| 2813 | - $dir = $r ? 'rtl' : 'ltr'; |
|
| 2814 | - $ndir = $r ? 'ltr' : 'rtl'; |
|
| 2815 | - |
|
| 2816 | - if ($voulue == $dir) { |
|
| 2817 | - return $css; |
|
| 2818 | - } |
|
| 2819 | - |
|
| 2820 | - if ( |
|
| 2821 | - // url absolue |
|
| 2822 | - preg_match(",^https?:,i", $css) |
|
| 2823 | - // ou qui contient un ? |
|
| 2824 | - or (($p = strpos($css, '?')) !== false) |
|
| 2825 | - ) { |
|
| 2826 | - $distant = true; |
|
| 2827 | - $cssf = parse_url($css); |
|
| 2828 | - $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : ""); |
|
| 2829 | - $cssf = preg_replace(',[?:&=],', "_", $cssf); |
|
| 2830 | - } else { |
|
| 2831 | - $distant = false; |
|
| 2832 | - $cssf = $css; |
|
| 2833 | - // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
|
| 2834 | - //propose (rien a faire dans ce cas) |
|
| 2835 | - $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 2836 | - if (@file_exists($f)) { |
|
| 2837 | - return $f; |
|
| 2838 | - } |
|
| 2839 | - } |
|
| 2840 | - |
|
| 2841 | - // 2. |
|
| 2842 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
|
| 2843 | - $f = $dir_var |
|
| 2844 | - . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
|
| 2845 | - . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 2846 | - |
|
| 2847 | - // la css peut etre distante (url absolue !) |
|
| 2848 | - if ($distant) { |
|
| 2849 | - include_spip('inc/distant'); |
|
| 2850 | - $res = recuperer_url($css); |
|
| 2851 | - if (!$res or !$contenu = $res['page']) { |
|
| 2852 | - return $css; |
|
| 2853 | - } |
|
| 2854 | - } else { |
|
| 2855 | - if ((@filemtime($f) > @filemtime($css)) |
|
| 2856 | - and (_VAR_MODE != 'recalcul') |
|
| 2857 | - ) { |
|
| 2858 | - return $f; |
|
| 2859 | - } |
|
| 2860 | - if (!lire_fichier($css, $contenu)) { |
|
| 2861 | - return $css; |
|
| 2862 | - } |
|
| 2863 | - } |
|
| 2864 | - |
|
| 2865 | - |
|
| 2866 | - // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands |
|
| 2867 | - include_spip("lib/csstidy/class.csstidy"); |
|
| 2868 | - $parser = new csstidy(); |
|
| 2869 | - $parser->set_cfg('optimise_shorthands', 0); |
|
| 2870 | - $parser->set_cfg('reverse_left_and_right', true); |
|
| 2871 | - $parser->parse($contenu); |
|
| 2872 | - |
|
| 2873 | - $contenu = $parser->print->plain(); |
|
| 2874 | - |
|
| 2875 | - |
|
| 2876 | - // reperer les @import auxquels il faut propager le direction_css |
|
| 2877 | - preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs); |
|
| 2878 | - $src = array(); |
|
| 2879 | - $src_direction_css = array(); |
|
| 2880 | - $src_faux_abs = array(); |
|
| 2881 | - $d = dirname($css); |
|
| 2882 | - foreach ($regs[1] as $k => $import_css) { |
|
| 2883 | - $css_direction = direction_css("$d/$import_css", $voulue); |
|
| 2884 | - // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue |
|
| 2885 | - if (substr($css_direction, 0, strlen($d) + 1) == "$d/") { |
|
| 2886 | - $css_direction = substr($css_direction, strlen($d) + 1); |
|
| 2887 | - } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
|
| 2888 | - elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
|
| 2889 | - $css_direction = substr($css_direction, strlen($dir_var)); |
|
| 2890 | - $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction; |
|
| 2891 | - $css_direction = "/@@@@@@/" . $css_direction; |
|
| 2892 | - } |
|
| 2893 | - $src[] = $regs[0][$k]; |
|
| 2894 | - $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
|
| 2895 | - } |
|
| 2896 | - $contenu = str_replace($src, $src_direction_css, $contenu); |
|
| 2897 | - |
|
| 2898 | - $contenu = urls_absolues_css($contenu, $css); |
|
| 2899 | - |
|
| 2900 | - // virer les fausses url absolues que l'on a mis dans les import |
|
| 2901 | - if (count($src_faux_abs)) { |
|
| 2902 | - $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu); |
|
| 2903 | - } |
|
| 2904 | - |
|
| 2905 | - if (!ecrire_fichier($f, $contenu)) { |
|
| 2906 | - return $css; |
|
| 2907 | - } |
|
| 2908 | - |
|
| 2909 | - return $f; |
|
| 2798 | + if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) { |
|
| 2799 | + return $css; |
|
| 2800 | + } |
|
| 2801 | + |
|
| 2802 | + // si on a precise le sens voulu en argument, le prendre en compte |
|
| 2803 | + if ($voulue = strtolower($voulue)) { |
|
| 2804 | + if ($voulue != 'rtl' and $voulue != 'ltr') { |
|
| 2805 | + $voulue = lang_dir($voulue); |
|
| 2806 | + } |
|
| 2807 | + } else { |
|
| 2808 | + $voulue = lang_dir(); |
|
| 2809 | + } |
|
| 2810 | + |
|
| 2811 | + $r = count($r) > 1; |
|
| 2812 | + $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree |
|
| 2813 | + $dir = $r ? 'rtl' : 'ltr'; |
|
| 2814 | + $ndir = $r ? 'ltr' : 'rtl'; |
|
| 2815 | + |
|
| 2816 | + if ($voulue == $dir) { |
|
| 2817 | + return $css; |
|
| 2818 | + } |
|
| 2819 | + |
|
| 2820 | + if ( |
|
| 2821 | + // url absolue |
|
| 2822 | + preg_match(",^https?:,i", $css) |
|
| 2823 | + // ou qui contient un ? |
|
| 2824 | + or (($p = strpos($css, '?')) !== false) |
|
| 2825 | + ) { |
|
| 2826 | + $distant = true; |
|
| 2827 | + $cssf = parse_url($css); |
|
| 2828 | + $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : ""); |
|
| 2829 | + $cssf = preg_replace(',[?:&=],', "_", $cssf); |
|
| 2830 | + } else { |
|
| 2831 | + $distant = false; |
|
| 2832 | + $cssf = $css; |
|
| 2833 | + // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
|
| 2834 | + //propose (rien a faire dans ce cas) |
|
| 2835 | + $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 2836 | + if (@file_exists($f)) { |
|
| 2837 | + return $f; |
|
| 2838 | + } |
|
| 2839 | + } |
|
| 2840 | + |
|
| 2841 | + // 2. |
|
| 2842 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
|
| 2843 | + $f = $dir_var |
|
| 2844 | + . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
|
| 2845 | + . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 2846 | + |
|
| 2847 | + // la css peut etre distante (url absolue !) |
|
| 2848 | + if ($distant) { |
|
| 2849 | + include_spip('inc/distant'); |
|
| 2850 | + $res = recuperer_url($css); |
|
| 2851 | + if (!$res or !$contenu = $res['page']) { |
|
| 2852 | + return $css; |
|
| 2853 | + } |
|
| 2854 | + } else { |
|
| 2855 | + if ((@filemtime($f) > @filemtime($css)) |
|
| 2856 | + and (_VAR_MODE != 'recalcul') |
|
| 2857 | + ) { |
|
| 2858 | + return $f; |
|
| 2859 | + } |
|
| 2860 | + if (!lire_fichier($css, $contenu)) { |
|
| 2861 | + return $css; |
|
| 2862 | + } |
|
| 2863 | + } |
|
| 2864 | + |
|
| 2865 | + |
|
| 2866 | + // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands |
|
| 2867 | + include_spip("lib/csstidy/class.csstidy"); |
|
| 2868 | + $parser = new csstidy(); |
|
| 2869 | + $parser->set_cfg('optimise_shorthands', 0); |
|
| 2870 | + $parser->set_cfg('reverse_left_and_right', true); |
|
| 2871 | + $parser->parse($contenu); |
|
| 2872 | + |
|
| 2873 | + $contenu = $parser->print->plain(); |
|
| 2874 | + |
|
| 2875 | + |
|
| 2876 | + // reperer les @import auxquels il faut propager le direction_css |
|
| 2877 | + preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs); |
|
| 2878 | + $src = array(); |
|
| 2879 | + $src_direction_css = array(); |
|
| 2880 | + $src_faux_abs = array(); |
|
| 2881 | + $d = dirname($css); |
|
| 2882 | + foreach ($regs[1] as $k => $import_css) { |
|
| 2883 | + $css_direction = direction_css("$d/$import_css", $voulue); |
|
| 2884 | + // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue |
|
| 2885 | + if (substr($css_direction, 0, strlen($d) + 1) == "$d/") { |
|
| 2886 | + $css_direction = substr($css_direction, strlen($d) + 1); |
|
| 2887 | + } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
|
| 2888 | + elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
|
| 2889 | + $css_direction = substr($css_direction, strlen($dir_var)); |
|
| 2890 | + $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction; |
|
| 2891 | + $css_direction = "/@@@@@@/" . $css_direction; |
|
| 2892 | + } |
|
| 2893 | + $src[] = $regs[0][$k]; |
|
| 2894 | + $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
|
| 2895 | + } |
|
| 2896 | + $contenu = str_replace($src, $src_direction_css, $contenu); |
|
| 2897 | + |
|
| 2898 | + $contenu = urls_absolues_css($contenu, $css); |
|
| 2899 | + |
|
| 2900 | + // virer les fausses url absolues que l'on a mis dans les import |
|
| 2901 | + if (count($src_faux_abs)) { |
|
| 2902 | + $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu); |
|
| 2903 | + } |
|
| 2904 | + |
|
| 2905 | + if (!ecrire_fichier($f, $contenu)) { |
|
| 2906 | + return $css; |
|
| 2907 | + } |
|
| 2908 | + |
|
| 2909 | + return $f; |
|
| 2910 | 2910 | } |
| 2911 | 2911 | |
| 2912 | 2912 | |
@@ -2929,43 +2929,43 @@ discard block |
||
| 2929 | 2929 | * - Chemin ou URL du fichier CSS source sinon. |
| 2930 | 2930 | **/ |
| 2931 | 2931 | function url_absolue_css($css) { |
| 2932 | - if (!preg_match(',\.css$,i', $css, $r)) { |
|
| 2933 | - return $css; |
|
| 2934 | - } |
|
| 2932 | + if (!preg_match(',\.css$,i', $css, $r)) { |
|
| 2933 | + return $css; |
|
| 2934 | + } |
|
| 2935 | 2935 | |
| 2936 | - $url_absolue_css = url_absolue($css); |
|
| 2936 | + $url_absolue_css = url_absolue($css); |
|
| 2937 | 2937 | |
| 2938 | - $f = basename($css, '.css'); |
|
| 2939 | - $f = sous_repertoire(_DIR_VAR, 'cache-css') |
|
| 2940 | - . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 2941 | - . '.css'; |
|
| 2938 | + $f = basename($css, '.css'); |
|
| 2939 | + $f = sous_repertoire(_DIR_VAR, 'cache-css') |
|
| 2940 | + . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 2941 | + . '.css'; |
|
| 2942 | 2942 | |
| 2943 | - if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
|
| 2944 | - return $f; |
|
| 2945 | - } |
|
| 2943 | + if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
|
| 2944 | + return $f; |
|
| 2945 | + } |
|
| 2946 | 2946 | |
| 2947 | - if ($url_absolue_css == $css) { |
|
| 2948 | - if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
|
| 2949 | - or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 2950 | - ) { |
|
| 2951 | - include_spip('inc/distant'); |
|
| 2952 | - if (!$contenu = recuperer_page($css)) { |
|
| 2953 | - return $css; |
|
| 2954 | - } |
|
| 2955 | - } |
|
| 2956 | - } elseif (!lire_fichier($css, $contenu)) { |
|
| 2957 | - return $css; |
|
| 2958 | - } |
|
| 2947 | + if ($url_absolue_css == $css) { |
|
| 2948 | + if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
|
| 2949 | + or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 2950 | + ) { |
|
| 2951 | + include_spip('inc/distant'); |
|
| 2952 | + if (!$contenu = recuperer_page($css)) { |
|
| 2953 | + return $css; |
|
| 2954 | + } |
|
| 2955 | + } |
|
| 2956 | + } elseif (!lire_fichier($css, $contenu)) { |
|
| 2957 | + return $css; |
|
| 2958 | + } |
|
| 2959 | 2959 | |
| 2960 | - // passer les url relatives a la css d'origine en url absolues |
|
| 2961 | - $contenu = urls_absolues_css($contenu, $css); |
|
| 2960 | + // passer les url relatives a la css d'origine en url absolues |
|
| 2961 | + $contenu = urls_absolues_css($contenu, $css); |
|
| 2962 | 2962 | |
| 2963 | - // ecrire la css |
|
| 2964 | - if (!ecrire_fichier($f, $contenu)) { |
|
| 2965 | - return $css; |
|
| 2966 | - } |
|
| 2963 | + // ecrire la css |
|
| 2964 | + if (!ecrire_fichier($f, $contenu)) { |
|
| 2965 | + return $css; |
|
| 2966 | + } |
|
| 2967 | 2967 | |
| 2968 | - return $f; |
|
| 2968 | + return $f; |
|
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | 2971 | |
@@ -2999,24 +2999,24 @@ discard block |
||
| 2999 | 2999 | * Valeur trouvée ou valeur par défaut. |
| 3000 | 3000 | **/ |
| 3001 | 3001 | function table_valeur($table, $cle, $defaut = '', $conserver_null = false) { |
| 3002 | - foreach (explode('/', $cle) as $k) { |
|
| 3002 | + foreach (explode('/', $cle) as $k) { |
|
| 3003 | 3003 | |
| 3004 | - $table = is_string($table) ? @unserialize($table) : $table; |
|
| 3004 | + $table = is_string($table) ? @unserialize($table) : $table; |
|
| 3005 | 3005 | |
| 3006 | - if (is_object($table)) { |
|
| 3007 | - $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut; |
|
| 3008 | - } elseif (is_array($table)) { |
|
| 3009 | - if ($conserver_null) { |
|
| 3010 | - $table = array_key_exists($k, $table) ? $table[$k] : $defaut; |
|
| 3011 | - } else { |
|
| 3012 | - $table = isset($table[$k]) ? $table[$k] : $defaut; |
|
| 3013 | - } |
|
| 3014 | - } else { |
|
| 3015 | - $table = $defaut; |
|
| 3016 | - } |
|
| 3017 | - } |
|
| 3006 | + if (is_object($table)) { |
|
| 3007 | + $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut; |
|
| 3008 | + } elseif (is_array($table)) { |
|
| 3009 | + if ($conserver_null) { |
|
| 3010 | + $table = array_key_exists($k, $table) ? $table[$k] : $defaut; |
|
| 3011 | + } else { |
|
| 3012 | + $table = isset($table[$k]) ? $table[$k] : $defaut; |
|
| 3013 | + } |
|
| 3014 | + } else { |
|
| 3015 | + $table = $defaut; |
|
| 3016 | + } |
|
| 3017 | + } |
|
| 3018 | 3018 | |
| 3019 | - return $table; |
|
| 3019 | + return $table; |
|
| 3020 | 3020 | } |
| 3021 | 3021 | |
| 3022 | 3022 | /** |
@@ -3049,22 +3049,22 @@ discard block |
||
| 3049 | 3049 | * - string : expression trouvée. |
| 3050 | 3050 | **/ |
| 3051 | 3051 | function match($texte, $expression, $modif = "UimsS", $capte = 0) { |
| 3052 | - if (intval($modif) and $capte == 0) { |
|
| 3053 | - $capte = $modif; |
|
| 3054 | - $modif = "UimsS"; |
|
| 3055 | - } |
|
| 3056 | - $expression = str_replace("\/", "/", $expression); |
|
| 3057 | - $expression = str_replace("/", "\/", $expression); |
|
| 3052 | + if (intval($modif) and $capte == 0) { |
|
| 3053 | + $capte = $modif; |
|
| 3054 | + $modif = "UimsS"; |
|
| 3055 | + } |
|
| 3056 | + $expression = str_replace("\/", "/", $expression); |
|
| 3057 | + $expression = str_replace("/", "\/", $expression); |
|
| 3058 | 3058 | |
| 3059 | - if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) { |
|
| 3060 | - if (isset($r[$capte])) { |
|
| 3061 | - return $r[$capte]; |
|
| 3062 | - } else { |
|
| 3063 | - return true; |
|
| 3064 | - } |
|
| 3065 | - } |
|
| 3059 | + if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) { |
|
| 3060 | + if (isset($r[$capte])) { |
|
| 3061 | + return $r[$capte]; |
|
| 3062 | + } else { |
|
| 3063 | + return true; |
|
| 3064 | + } |
|
| 3065 | + } |
|
| 3066 | 3066 | |
| 3067 | - return false; |
|
| 3067 | + return false; |
|
| 3068 | 3068 | } |
| 3069 | 3069 | |
| 3070 | 3070 | |
@@ -3091,10 +3091,10 @@ discard block |
||
| 3091 | 3091 | * Texte |
| 3092 | 3092 | **/ |
| 3093 | 3093 | function replace($texte, $expression, $replace = '', $modif = "UimsS") { |
| 3094 | - $expression = str_replace("\/", "/", $expression); |
|
| 3095 | - $expression = str_replace("/", "\/", $expression); |
|
| 3094 | + $expression = str_replace("\/", "/", $expression); |
|
| 3095 | + $expression = str_replace("/", "\/", $expression); |
|
| 3096 | 3096 | |
| 3097 | - return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3097 | + return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3098 | 3098 | } |
| 3099 | 3099 | |
| 3100 | 3100 | |
@@ -3112,21 +3112,21 @@ discard block |
||
| 3112 | 3112 | **/ |
| 3113 | 3113 | function traiter_doublons_documents(&$doublons, $letexte) { |
| 3114 | 3114 | |
| 3115 | - // Verifier dans le texte & les notes (pas beau, helas) |
|
| 3116 | - $t = $letexte . $GLOBALS['les_notes']; |
|
| 3115 | + // Verifier dans le texte & les notes (pas beau, helas) |
|
| 3116 | + $t = $letexte . $GLOBALS['les_notes']; |
|
| 3117 | 3117 | |
| 3118 | - if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
|
| 3119 | - and preg_match_all( |
|
| 3120 | - ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS', |
|
| 3121 | - $t, $matches, PREG_PATTERN_ORDER) |
|
| 3122 | - ) { |
|
| 3123 | - if (!isset($doublons['documents'])) { |
|
| 3124 | - $doublons['documents'] = ""; |
|
| 3125 | - } |
|
| 3126 | - $doublons['documents'] .= "," . join(',', $matches[1]); |
|
| 3127 | - } |
|
| 3118 | + if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
|
| 3119 | + and preg_match_all( |
|
| 3120 | + ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS', |
|
| 3121 | + $t, $matches, PREG_PATTERN_ORDER) |
|
| 3122 | + ) { |
|
| 3123 | + if (!isset($doublons['documents'])) { |
|
| 3124 | + $doublons['documents'] = ""; |
|
| 3125 | + } |
|
| 3126 | + $doublons['documents'] .= "," . join(',', $matches[1]); |
|
| 3127 | + } |
|
| 3128 | 3128 | |
| 3129 | - return $letexte; |
|
| 3129 | + return $letexte; |
|
| 3130 | 3130 | } |
| 3131 | 3131 | |
| 3132 | 3132 | /** |
@@ -3140,7 +3140,7 @@ discard block |
||
| 3140 | 3140 | * @return string Chaîne vide |
| 3141 | 3141 | **/ |
| 3142 | 3142 | function vide($texte) { |
| 3143 | - return ""; |
|
| 3143 | + return ""; |
|
| 3144 | 3144 | } |
| 3145 | 3145 | |
| 3146 | 3146 | // |
@@ -3169,23 +3169,23 @@ discard block |
||
| 3169 | 3169 | * Code HTML résultant |
| 3170 | 3170 | **/ |
| 3171 | 3171 | function env_to_params($env, $ignore_params = array()) { |
| 3172 | - $ignore_params = array_merge( |
|
| 3173 | - array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'), |
|
| 3174 | - $ignore_params |
|
| 3175 | - ); |
|
| 3176 | - if (!is_array($env)) { |
|
| 3177 | - $env = unserialize($env); |
|
| 3178 | - } |
|
| 3179 | - $texte = ""; |
|
| 3180 | - if ($env) { |
|
| 3181 | - foreach ($env as $i => $j) { |
|
| 3182 | - if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3183 | - $texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />"; |
|
| 3184 | - } |
|
| 3185 | - } |
|
| 3186 | - } |
|
| 3187 | - |
|
| 3188 | - return $texte; |
|
| 3172 | + $ignore_params = array_merge( |
|
| 3173 | + array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'), |
|
| 3174 | + $ignore_params |
|
| 3175 | + ); |
|
| 3176 | + if (!is_array($env)) { |
|
| 3177 | + $env = unserialize($env); |
|
| 3178 | + } |
|
| 3179 | + $texte = ""; |
|
| 3180 | + if ($env) { |
|
| 3181 | + foreach ($env as $i => $j) { |
|
| 3182 | + if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3183 | + $texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />"; |
|
| 3184 | + } |
|
| 3185 | + } |
|
| 3186 | + } |
|
| 3187 | + |
|
| 3188 | + return $texte; |
|
| 3189 | 3189 | } |
| 3190 | 3190 | |
| 3191 | 3191 | /** |
@@ -3208,23 +3208,23 @@ discard block |
||
| 3208 | 3208 | * Code HTML résultant |
| 3209 | 3209 | **/ |
| 3210 | 3210 | function env_to_attributs($env, $ignore_params = array()) { |
| 3211 | - $ignore_params = array_merge( |
|
| 3212 | - array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'), |
|
| 3213 | - $ignore_params |
|
| 3214 | - ); |
|
| 3215 | - if (!is_array($env)) { |
|
| 3216 | - $env = unserialize($env); |
|
| 3217 | - } |
|
| 3218 | - $texte = ""; |
|
| 3219 | - if ($env) { |
|
| 3220 | - foreach ($env as $i => $j) { |
|
| 3221 | - if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3222 | - $texte .= $i . "='" . $j . "' "; |
|
| 3223 | - } |
|
| 3224 | - } |
|
| 3225 | - } |
|
| 3211 | + $ignore_params = array_merge( |
|
| 3212 | + array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'), |
|
| 3213 | + $ignore_params |
|
| 3214 | + ); |
|
| 3215 | + if (!is_array($env)) { |
|
| 3216 | + $env = unserialize($env); |
|
| 3217 | + } |
|
| 3218 | + $texte = ""; |
|
| 3219 | + if ($env) { |
|
| 3220 | + foreach ($env as $i => $j) { |
|
| 3221 | + if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3222 | + $texte .= $i . "='" . $j . "' "; |
|
| 3223 | + } |
|
| 3224 | + } |
|
| 3225 | + } |
|
| 3226 | 3226 | |
| 3227 | - return $texte; |
|
| 3227 | + return $texte; |
|
| 3228 | 3228 | } |
| 3229 | 3229 | |
| 3230 | 3230 | |
@@ -3241,9 +3241,9 @@ discard block |
||
| 3241 | 3241 | * @return string Chaînes concaténés |
| 3242 | 3242 | **/ |
| 3243 | 3243 | function concat() { |
| 3244 | - $args = func_get_args(); |
|
| 3244 | + $args = func_get_args(); |
|
| 3245 | 3245 | |
| 3246 | - return join('', $args); |
|
| 3246 | + return join('', $args); |
|
| 3247 | 3247 | } |
| 3248 | 3248 | |
| 3249 | 3249 | |
@@ -3263,23 +3263,23 @@ discard block |
||
| 3263 | 3263 | * Contenu du ou des fichiers, concaténé |
| 3264 | 3264 | **/ |
| 3265 | 3265 | function charge_scripts($files, $script = true) { |
| 3266 | - $flux = ""; |
|
| 3267 | - foreach (is_array($files) ? $files : explode("|", $files) as $file) { |
|
| 3268 | - if (!is_string($file)) { |
|
| 3269 | - continue; |
|
| 3270 | - } |
|
| 3271 | - if ($script) { |
|
| 3272 | - $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : ''; |
|
| 3273 | - } |
|
| 3274 | - if ($file) { |
|
| 3275 | - $path = find_in_path($file); |
|
| 3276 | - if ($path) { |
|
| 3277 | - $flux .= spip_file_get_contents($path); |
|
| 3278 | - } |
|
| 3279 | - } |
|
| 3280 | - } |
|
| 3266 | + $flux = ""; |
|
| 3267 | + foreach (is_array($files) ? $files : explode("|", $files) as $file) { |
|
| 3268 | + if (!is_string($file)) { |
|
| 3269 | + continue; |
|
| 3270 | + } |
|
| 3271 | + if ($script) { |
|
| 3272 | + $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : ''; |
|
| 3273 | + } |
|
| 3274 | + if ($file) { |
|
| 3275 | + $path = find_in_path($file); |
|
| 3276 | + if ($path) { |
|
| 3277 | + $flux .= spip_file_get_contents($path); |
|
| 3278 | + } |
|
| 3279 | + } |
|
| 3280 | + } |
|
| 3281 | 3281 | |
| 3282 | - return $flux; |
|
| 3282 | + return $flux; |
|
| 3283 | 3283 | } |
| 3284 | 3284 | |
| 3285 | 3285 | |
@@ -3300,46 +3300,46 @@ discard block |
||
| 3300 | 3300 | * @return string |
| 3301 | 3301 | */ |
| 3302 | 3302 | function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) { |
| 3303 | - $img_file = $img; |
|
| 3304 | - if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
|
| 3305 | - $img_file = chemin_image($img); |
|
| 3306 | - } |
|
| 3307 | - else { |
|
| 3308 | - if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){ |
|
| 3309 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 3310 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 3311 | - if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
|
| 3312 | - and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg" |
|
| 3313 | - and file_exists($variante_svg_generique)) { |
|
| 3314 | - if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) { |
|
| 3315 | - $img_file = $variante_svg_size; |
|
| 3316 | - } |
|
| 3317 | - else { |
|
| 3318 | - $img_file = $variante_svg_generique; |
|
| 3319 | - } |
|
| 3320 | - } |
|
| 3321 | - } |
|
| 3322 | - } |
|
| 3323 | - if (stripos($atts, 'width') === false) { |
|
| 3324 | - // utiliser directement l'info de taille presente dans le nom |
|
| 3325 | - if ((!isset($options['utiliser_suffixe_size']) or $options['utiliser_suffixe_size'] == true) |
|
| 3326 | - and preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs) |
|
| 3327 | - ) { |
|
| 3328 | - $largeur = $hauteur = intval($regs[1]); |
|
| 3329 | - } else { |
|
| 3330 | - $taille = taille_image($img_file); |
|
| 3331 | - list($hauteur, $largeur) = $taille; |
|
| 3332 | - if (!$hauteur or !$largeur) { |
|
| 3333 | - return ""; |
|
| 3334 | - } |
|
| 3335 | - } |
|
| 3336 | - $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3337 | - } |
|
| 3338 | - |
|
| 3339 | - return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'" |
|
| 3340 | - . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3341 | - . " " . ltrim($atts) |
|
| 3342 | - . " />"; |
|
| 3303 | + $img_file = $img; |
|
| 3304 | + if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
|
| 3305 | + $img_file = chemin_image($img); |
|
| 3306 | + } |
|
| 3307 | + else { |
|
| 3308 | + if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){ |
|
| 3309 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 3310 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 3311 | + if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
|
| 3312 | + and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg" |
|
| 3313 | + and file_exists($variante_svg_generique)) { |
|
| 3314 | + if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) { |
|
| 3315 | + $img_file = $variante_svg_size; |
|
| 3316 | + } |
|
| 3317 | + else { |
|
| 3318 | + $img_file = $variante_svg_generique; |
|
| 3319 | + } |
|
| 3320 | + } |
|
| 3321 | + } |
|
| 3322 | + } |
|
| 3323 | + if (stripos($atts, 'width') === false) { |
|
| 3324 | + // utiliser directement l'info de taille presente dans le nom |
|
| 3325 | + if ((!isset($options['utiliser_suffixe_size']) or $options['utiliser_suffixe_size'] == true) |
|
| 3326 | + and preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs) |
|
| 3327 | + ) { |
|
| 3328 | + $largeur = $hauteur = intval($regs[1]); |
|
| 3329 | + } else { |
|
| 3330 | + $taille = taille_image($img_file); |
|
| 3331 | + list($hauteur, $largeur) = $taille; |
|
| 3332 | + if (!$hauteur or !$largeur) { |
|
| 3333 | + return ""; |
|
| 3334 | + } |
|
| 3335 | + } |
|
| 3336 | + $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3337 | + } |
|
| 3338 | + |
|
| 3339 | + return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'" |
|
| 3340 | + . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3341 | + . " " . ltrim($atts) |
|
| 3342 | + . " />"; |
|
| 3343 | 3343 | } |
| 3344 | 3344 | |
| 3345 | 3345 | /** |
@@ -3350,7 +3350,7 @@ discard block |
||
| 3350 | 3350 | * @return string |
| 3351 | 3351 | */ |
| 3352 | 3352 | function http_style_background($img, $att = '') { |
| 3353 | - return " style='background" . ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";'"; |
|
| 3353 | + return " style='background" . ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";'"; |
|
| 3354 | 3354 | } |
| 3355 | 3355 | |
| 3356 | 3356 | /** |
@@ -3365,8 +3365,8 @@ discard block |
||
| 3365 | 3365 | * Code HTML de la balise IMG |
| 3366 | 3366 | */ |
| 3367 | 3367 | function filtre_balise_img_dist($img, $alt = "", $class = "") { |
| 3368 | - return http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '', |
|
| 3369 | - array('chemin_image' => false, 'utiliser_suffixe_size' => false)); |
|
| 3368 | + return http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '', |
|
| 3369 | + array('chemin_image' => false, 'utiliser_suffixe_size' => false)); |
|
| 3370 | 3370 | } |
| 3371 | 3371 | |
| 3372 | 3372 | |
@@ -3382,34 +3382,34 @@ discard block |
||
| 3382 | 3382 | * @return string |
| 3383 | 3383 | */ |
| 3384 | 3384 | function filtre_balise_svg_dist($img, $alt = "", $class = "") { |
| 3385 | - if (!$file = find_in_path($img) |
|
| 3386 | - or !$svg = file_get_contents($file)) { |
|
| 3387 | - return ''; |
|
| 3388 | - } |
|
| 3389 | - |
|
| 3390 | - if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) { |
|
| 3391 | - return ''; |
|
| 3392 | - } |
|
| 3393 | - $balise_svg = $match[0]; |
|
| 3394 | - $balise_svg_source = $balise_svg; |
|
| 3395 | - // IE est toujours mon ami |
|
| 3396 | - $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
|
| 3397 | - if ($class) { |
|
| 3398 | - $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
|
| 3399 | - } |
|
| 3400 | - if ($alt){ |
|
| 3401 | - $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
|
| 3402 | - $id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4); |
|
| 3403 | - $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
|
| 3404 | - $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n"; |
|
| 3405 | - $balise_svg .= $title; |
|
| 3406 | - } |
|
| 3407 | - else { |
|
| 3408 | - $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
|
| 3409 | - } |
|
| 3410 | - $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
|
| 3411 | - |
|
| 3412 | - return $svg; |
|
| 3385 | + if (!$file = find_in_path($img) |
|
| 3386 | + or !$svg = file_get_contents($file)) { |
|
| 3387 | + return ''; |
|
| 3388 | + } |
|
| 3389 | + |
|
| 3390 | + if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) { |
|
| 3391 | + return ''; |
|
| 3392 | + } |
|
| 3393 | + $balise_svg = $match[0]; |
|
| 3394 | + $balise_svg_source = $balise_svg; |
|
| 3395 | + // IE est toujours mon ami |
|
| 3396 | + $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
|
| 3397 | + if ($class) { |
|
| 3398 | + $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
|
| 3399 | + } |
|
| 3400 | + if ($alt){ |
|
| 3401 | + $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
|
| 3402 | + $id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4); |
|
| 3403 | + $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
|
| 3404 | + $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n"; |
|
| 3405 | + $balise_svg .= $title; |
|
| 3406 | + } |
|
| 3407 | + else { |
|
| 3408 | + $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
|
| 3409 | + } |
|
| 3410 | + $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
|
| 3411 | + |
|
| 3412 | + return $svg; |
|
| 3413 | 3413 | } |
| 3414 | 3414 | |
| 3415 | 3415 | |
@@ -3432,17 +3432,17 @@ discard block |
||
| 3432 | 3432 | * Code HTML résultant |
| 3433 | 3433 | **/ |
| 3434 | 3434 | function filtre_foreach_dist($tableau, $modele = 'foreach') { |
| 3435 | - $texte = ''; |
|
| 3436 | - if (is_array($tableau)) { |
|
| 3437 | - foreach ($tableau as $k => $v) { |
|
| 3438 | - $res = recuperer_fond('modeles/' . $modele, |
|
| 3439 | - array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v))) |
|
| 3440 | - ); |
|
| 3441 | - $texte .= $res; |
|
| 3442 | - } |
|
| 3443 | - } |
|
| 3435 | + $texte = ''; |
|
| 3436 | + if (is_array($tableau)) { |
|
| 3437 | + foreach ($tableau as $k => $v) { |
|
| 3438 | + $res = recuperer_fond('modeles/' . $modele, |
|
| 3439 | + array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v))) |
|
| 3440 | + ); |
|
| 3441 | + $texte .= $res; |
|
| 3442 | + } |
|
| 3443 | + } |
|
| 3444 | 3444 | |
| 3445 | - return $texte; |
|
| 3445 | + return $texte; |
|
| 3446 | 3446 | } |
| 3447 | 3447 | |
| 3448 | 3448 | |
@@ -3467,37 +3467,37 @@ discard block |
||
| 3467 | 3467 | * - tout : retourne toutes les informations du plugin actif |
| 3468 | 3468 | **/ |
| 3469 | 3469 | function filtre_info_plugin_dist($plugin, $type_info, $reload = false) { |
| 3470 | - include_spip('inc/plugin'); |
|
| 3471 | - $plugin = strtoupper($plugin); |
|
| 3472 | - $plugins_actifs = liste_plugin_actifs(); |
|
| 3473 | - |
|
| 3474 | - if (!$plugin) { |
|
| 3475 | - return serialize(array_keys($plugins_actifs)); |
|
| 3476 | - } elseif (empty($plugins_actifs[$plugin]) and !$reload) { |
|
| 3477 | - return ''; |
|
| 3478 | - } elseif (($type_info == 'est_actif') and !$reload) { |
|
| 3479 | - return $plugins_actifs[$plugin] ? 1 : 0; |
|
| 3480 | - } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) { |
|
| 3481 | - return $plugins_actifs[$plugin][$type_info]; |
|
| 3482 | - } else { |
|
| 3483 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 3484 | - // On prend en compte les extensions |
|
| 3485 | - if (!is_dir($plugins_actifs[$plugin]['dir_type'])) { |
|
| 3486 | - $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']); |
|
| 3487 | - } else { |
|
| 3488 | - $dir_plugins = $plugins_actifs[$plugin]['dir_type']; |
|
| 3489 | - } |
|
| 3490 | - if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) { |
|
| 3491 | - return ''; |
|
| 3492 | - } |
|
| 3493 | - if ($type_info == 'tout') { |
|
| 3494 | - return $infos; |
|
| 3495 | - } elseif ($type_info == 'est_actif') { |
|
| 3496 | - return $infos ? 1 : 0; |
|
| 3497 | - } else { |
|
| 3498 | - return strval($infos[$type_info]); |
|
| 3499 | - } |
|
| 3500 | - } |
|
| 3470 | + include_spip('inc/plugin'); |
|
| 3471 | + $plugin = strtoupper($plugin); |
|
| 3472 | + $plugins_actifs = liste_plugin_actifs(); |
|
| 3473 | + |
|
| 3474 | + if (!$plugin) { |
|
| 3475 | + return serialize(array_keys($plugins_actifs)); |
|
| 3476 | + } elseif (empty($plugins_actifs[$plugin]) and !$reload) { |
|
| 3477 | + return ''; |
|
| 3478 | + } elseif (($type_info == 'est_actif') and !$reload) { |
|
| 3479 | + return $plugins_actifs[$plugin] ? 1 : 0; |
|
| 3480 | + } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) { |
|
| 3481 | + return $plugins_actifs[$plugin][$type_info]; |
|
| 3482 | + } else { |
|
| 3483 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 3484 | + // On prend en compte les extensions |
|
| 3485 | + if (!is_dir($plugins_actifs[$plugin]['dir_type'])) { |
|
| 3486 | + $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']); |
|
| 3487 | + } else { |
|
| 3488 | + $dir_plugins = $plugins_actifs[$plugin]['dir_type']; |
|
| 3489 | + } |
|
| 3490 | + if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) { |
|
| 3491 | + return ''; |
|
| 3492 | + } |
|
| 3493 | + if ($type_info == 'tout') { |
|
| 3494 | + return $infos; |
|
| 3495 | + } elseif ($type_info == 'est_actif') { |
|
| 3496 | + return $infos ? 1 : 0; |
|
| 3497 | + } else { |
|
| 3498 | + return strval($infos[$type_info]); |
|
| 3499 | + } |
|
| 3500 | + } |
|
| 3501 | 3501 | } |
| 3502 | 3502 | |
| 3503 | 3503 | |
@@ -3524,9 +3524,9 @@ discard block |
||
| 3524 | 3524 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 3525 | 3525 | */ |
| 3526 | 3526 | function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) { |
| 3527 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3527 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3528 | 3528 | |
| 3529 | - return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax); |
|
| 3529 | + return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax); |
|
| 3530 | 3530 | } |
| 3531 | 3531 | |
| 3532 | 3532 | |
@@ -3556,13 +3556,13 @@ discard block |
||
| 3556 | 3556 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 3557 | 3557 | */ |
| 3558 | 3558 | function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) { |
| 3559 | - static $puce_statut = null; |
|
| 3560 | - if (!$puce_statut) { |
|
| 3561 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3562 | - } |
|
| 3559 | + static $puce_statut = null; |
|
| 3560 | + if (!$puce_statut) { |
|
| 3561 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3562 | + } |
|
| 3563 | 3563 | |
| 3564 | - return $puce_statut($id_objet, $statut, $id_parent, $objet, false, |
|
| 3565 | - objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false); |
|
| 3564 | + return $puce_statut($id_objet, $statut, $id_parent, $objet, false, |
|
| 3565 | + objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false); |
|
| 3566 | 3566 | } |
| 3567 | 3567 | |
| 3568 | 3568 | |
@@ -3589,88 +3589,88 @@ discard block |
||
| 3589 | 3589 | * hash du contexte |
| 3590 | 3590 | */ |
| 3591 | 3591 | function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') { |
| 3592 | - if (is_string($c) |
|
| 3593 | - and @unserialize($c) !== false |
|
| 3594 | - ) { |
|
| 3595 | - $c = unserialize($c); |
|
| 3596 | - } |
|
| 3597 | - |
|
| 3598 | - // supprimer les parametres debut_x |
|
| 3599 | - // pour que la pagination ajax ne soit pas plantee |
|
| 3600 | - // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, |
|
| 3601 | - // le debut_x=0 n'existe pas, et on resterait sur 1 |
|
| 3602 | - if (is_array($c)) { |
|
| 3603 | - foreach ($c as $k => $v) { |
|
| 3604 | - if (strpos($k, 'debut_') === 0) { |
|
| 3605 | - unset($c[$k]); |
|
| 3606 | - } |
|
| 3607 | - } |
|
| 3608 | - } |
|
| 3609 | - |
|
| 3610 | - if (!function_exists('calculer_cle_action')) { |
|
| 3611 | - include_spip("inc/securiser_action"); |
|
| 3612 | - } |
|
| 3613 | - |
|
| 3614 | - $c = serialize($c); |
|
| 3615 | - $cle = calculer_cle_action($form . $c); |
|
| 3616 | - $c = "$cle:$c"; |
|
| 3617 | - |
|
| 3618 | - // on ne stocke pas les contextes dans des fichiers caches |
|
| 3619 | - // par defaut, sauf si cette configuration a ete forcee |
|
| 3620 | - // OU que la longueur de l''argument generee est plus long |
|
| 3621 | - // que ce que telere Suhosin. |
|
| 3622 | - $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX); |
|
| 3623 | - if (!$cache_contextes_ajax) { |
|
| 3624 | - $env = $c; |
|
| 3625 | - if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 3626 | - $env = gzdeflate($env); |
|
| 3627 | - // http://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287 |
|
| 3628 | - if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) { |
|
| 3629 | - $cache_contextes_ajax = true; |
|
| 3630 | - spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT); |
|
| 3631 | - } |
|
| 3632 | - } |
|
| 3633 | - $env = _xor($env); |
|
| 3634 | - $env = base64_encode($env); |
|
| 3635 | - // tester Suhosin et la valeur maximale des variables en GET... |
|
| 3636 | - if ($max_len = @ini_get('suhosin.get.max_value_length') |
|
| 3637 | - and $max_len < ($len = strlen($env)) |
|
| 3638 | - ) { |
|
| 3639 | - $cache_contextes_ajax = true; |
|
| 3640 | - spip_log("Contextes AJAX forces en fichiers !" |
|
| 3641 | - . " Cela arrive lorsque la valeur du contexte" |
|
| 3642 | - . " depasse la longueur maximale autorisee par Suhosin" |
|
| 3643 | - . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len." |
|
| 3644 | - . " Vous devriez modifier les parametres de Suhosin" |
|
| 3645 | - . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT); |
|
| 3646 | - } |
|
| 3647 | - } |
|
| 3648 | - |
|
| 3649 | - if ($cache_contextes_ajax) { |
|
| 3650 | - $dir = sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 3651 | - // stocker les contextes sur disque et ne passer qu'un hash dans l'url |
|
| 3652 | - $md5 = md5($c); |
|
| 3653 | - ecrire_fichier("$dir/c$md5", $c); |
|
| 3654 | - $env = $md5; |
|
| 3655 | - } |
|
| 3656 | - |
|
| 3657 | - if ($emboite === null) { |
|
| 3658 | - return $env; |
|
| 3659 | - } |
|
| 3660 | - if (!trim($emboite)) { |
|
| 3661 | - return ""; |
|
| 3662 | - } |
|
| 3663 | - // toujours encoder l'url source dans le bloc ajax |
|
| 3664 | - $r = self(); |
|
| 3665 | - $r = ' data-origin="' . $r . '"'; |
|
| 3666 | - $class = 'ajaxbloc'; |
|
| 3667 | - if ($ajaxid and is_string($ajaxid)) { |
|
| 3668 | - // ajaxid est normalement conforme a un nom de classe css |
|
| 3669 | - // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
|
| 3670 | - $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 3671 | - } |
|
| 3672 | - |
|
| 3673 | - return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 3592 | + if (is_string($c) |
|
| 3593 | + and @unserialize($c) !== false |
|
| 3594 | + ) { |
|
| 3595 | + $c = unserialize($c); |
|
| 3596 | + } |
|
| 3597 | + |
|
| 3598 | + // supprimer les parametres debut_x |
|
| 3599 | + // pour que la pagination ajax ne soit pas plantee |
|
| 3600 | + // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, |
|
| 3601 | + // le debut_x=0 n'existe pas, et on resterait sur 1 |
|
| 3602 | + if (is_array($c)) { |
|
| 3603 | + foreach ($c as $k => $v) { |
|
| 3604 | + if (strpos($k, 'debut_') === 0) { |
|
| 3605 | + unset($c[$k]); |
|
| 3606 | + } |
|
| 3607 | + } |
|
| 3608 | + } |
|
| 3609 | + |
|
| 3610 | + if (!function_exists('calculer_cle_action')) { |
|
| 3611 | + include_spip("inc/securiser_action"); |
|
| 3612 | + } |
|
| 3613 | + |
|
| 3614 | + $c = serialize($c); |
|
| 3615 | + $cle = calculer_cle_action($form . $c); |
|
| 3616 | + $c = "$cle:$c"; |
|
| 3617 | + |
|
| 3618 | + // on ne stocke pas les contextes dans des fichiers caches |
|
| 3619 | + // par defaut, sauf si cette configuration a ete forcee |
|
| 3620 | + // OU que la longueur de l''argument generee est plus long |
|
| 3621 | + // que ce que telere Suhosin. |
|
| 3622 | + $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX); |
|
| 3623 | + if (!$cache_contextes_ajax) { |
|
| 3624 | + $env = $c; |
|
| 3625 | + if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 3626 | + $env = gzdeflate($env); |
|
| 3627 | + // http://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287 |
|
| 3628 | + if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) { |
|
| 3629 | + $cache_contextes_ajax = true; |
|
| 3630 | + spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT); |
|
| 3631 | + } |
|
| 3632 | + } |
|
| 3633 | + $env = _xor($env); |
|
| 3634 | + $env = base64_encode($env); |
|
| 3635 | + // tester Suhosin et la valeur maximale des variables en GET... |
|
| 3636 | + if ($max_len = @ini_get('suhosin.get.max_value_length') |
|
| 3637 | + and $max_len < ($len = strlen($env)) |
|
| 3638 | + ) { |
|
| 3639 | + $cache_contextes_ajax = true; |
|
| 3640 | + spip_log("Contextes AJAX forces en fichiers !" |
|
| 3641 | + . " Cela arrive lorsque la valeur du contexte" |
|
| 3642 | + . " depasse la longueur maximale autorisee par Suhosin" |
|
| 3643 | + . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len." |
|
| 3644 | + . " Vous devriez modifier les parametres de Suhosin" |
|
| 3645 | + . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT); |
|
| 3646 | + } |
|
| 3647 | + } |
|
| 3648 | + |
|
| 3649 | + if ($cache_contextes_ajax) { |
|
| 3650 | + $dir = sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 3651 | + // stocker les contextes sur disque et ne passer qu'un hash dans l'url |
|
| 3652 | + $md5 = md5($c); |
|
| 3653 | + ecrire_fichier("$dir/c$md5", $c); |
|
| 3654 | + $env = $md5; |
|
| 3655 | + } |
|
| 3656 | + |
|
| 3657 | + if ($emboite === null) { |
|
| 3658 | + return $env; |
|
| 3659 | + } |
|
| 3660 | + if (!trim($emboite)) { |
|
| 3661 | + return ""; |
|
| 3662 | + } |
|
| 3663 | + // toujours encoder l'url source dans le bloc ajax |
|
| 3664 | + $r = self(); |
|
| 3665 | + $r = ' data-origin="' . $r . '"'; |
|
| 3666 | + $class = 'ajaxbloc'; |
|
| 3667 | + if ($ajaxid and is_string($ajaxid)) { |
|
| 3668 | + // ajaxid est normalement conforme a un nom de classe css |
|
| 3669 | + // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
|
| 3670 | + $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 3671 | + } |
|
| 3672 | + |
|
| 3673 | + return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 3674 | 3674 | } |
| 3675 | 3675 | |
| 3676 | 3676 | /** |
@@ -3690,36 +3690,36 @@ discard block |
||
| 3690 | 3690 | * - false : erreur de décodage |
| 3691 | 3691 | */ |
| 3692 | 3692 | function decoder_contexte_ajax($c, $form = '') { |
| 3693 | - if (!function_exists('calculer_cle_action')) { |
|
| 3694 | - include_spip("inc/securiser_action"); |
|
| 3695 | - } |
|
| 3696 | - if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32) |
|
| 3697 | - and $dir = sous_repertoire(_DIR_CACHE, 'contextes') |
|
| 3698 | - and lire_fichier("$dir/c$c", $contexte) |
|
| 3699 | - ) { |
|
| 3700 | - $c = $contexte; |
|
| 3701 | - } else { |
|
| 3702 | - $c = @base64_decode($c); |
|
| 3703 | - $c = _xor($c); |
|
| 3704 | - if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 3705 | - $c = @gzinflate($c); |
|
| 3706 | - } |
|
| 3707 | - } |
|
| 3708 | - |
|
| 3709 | - // extraire la signature en debut de contexte |
|
| 3710 | - // et la verifier avant de deserializer |
|
| 3711 | - // format : signature:donneesserializees |
|
| 3712 | - if ($p = strpos($c,":")){ |
|
| 3713 | - $cle = substr($c,0,$p); |
|
| 3714 | - $c = substr($c,$p+1); |
|
| 3715 | - |
|
| 3716 | - if ($cle == calculer_cle_action($form . $c)) { |
|
| 3717 | - $env = @unserialize($c); |
|
| 3718 | - return $env; |
|
| 3719 | - } |
|
| 3720 | - } |
|
| 3721 | - |
|
| 3722 | - return false; |
|
| 3693 | + if (!function_exists('calculer_cle_action')) { |
|
| 3694 | + include_spip("inc/securiser_action"); |
|
| 3695 | + } |
|
| 3696 | + if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32) |
|
| 3697 | + and $dir = sous_repertoire(_DIR_CACHE, 'contextes') |
|
| 3698 | + and lire_fichier("$dir/c$c", $contexte) |
|
| 3699 | + ) { |
|
| 3700 | + $c = $contexte; |
|
| 3701 | + } else { |
|
| 3702 | + $c = @base64_decode($c); |
|
| 3703 | + $c = _xor($c); |
|
| 3704 | + if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 3705 | + $c = @gzinflate($c); |
|
| 3706 | + } |
|
| 3707 | + } |
|
| 3708 | + |
|
| 3709 | + // extraire la signature en debut de contexte |
|
| 3710 | + // et la verifier avant de deserializer |
|
| 3711 | + // format : signature:donneesserializees |
|
| 3712 | + if ($p = strpos($c,":")){ |
|
| 3713 | + $cle = substr($c,0,$p); |
|
| 3714 | + $c = substr($c,$p+1); |
|
| 3715 | + |
|
| 3716 | + if ($cle == calculer_cle_action($form . $c)) { |
|
| 3717 | + $env = @unserialize($c); |
|
| 3718 | + return $env; |
|
| 3719 | + } |
|
| 3720 | + } |
|
| 3721 | + |
|
| 3722 | + return false; |
|
| 3723 | 3723 | } |
| 3724 | 3724 | |
| 3725 | 3725 | |
@@ -3737,20 +3737,20 @@ discard block |
||
| 3737 | 3737 | * Message décrypté ou encrypté |
| 3738 | 3738 | **/ |
| 3739 | 3739 | function _xor($message, $key = null) { |
| 3740 | - if (is_null($key)) { |
|
| 3741 | - if (!function_exists('calculer_cle_action')) { |
|
| 3742 | - include_spip("inc/securiser_action"); |
|
| 3743 | - } |
|
| 3744 | - $key = pack("H*", calculer_cle_action('_xor')); |
|
| 3745 | - } |
|
| 3740 | + if (is_null($key)) { |
|
| 3741 | + if (!function_exists('calculer_cle_action')) { |
|
| 3742 | + include_spip("inc/securiser_action"); |
|
| 3743 | + } |
|
| 3744 | + $key = pack("H*", calculer_cle_action('_xor')); |
|
| 3745 | + } |
|
| 3746 | 3746 | |
| 3747 | - $keylen = strlen($key); |
|
| 3748 | - $messagelen = strlen($message); |
|
| 3749 | - for ($i = 0; $i < $messagelen; $i++) { |
|
| 3750 | - $message[$i] = ~($message[$i] ^ $key[$i % $keylen]); |
|
| 3751 | - } |
|
| 3747 | + $keylen = strlen($key); |
|
| 3748 | + $messagelen = strlen($message); |
|
| 3749 | + for ($i = 0; $i < $messagelen; $i++) { |
|
| 3750 | + $message[$i] = ~($message[$i] ^ $key[$i % $keylen]); |
|
| 3751 | + } |
|
| 3752 | 3752 | |
| 3753 | - return $message; |
|
| 3753 | + return $message; |
|
| 3754 | 3754 | } |
| 3755 | 3755 | |
| 3756 | 3756 | /** |
@@ -3808,22 +3808,22 @@ discard block |
||
| 3808 | 3808 | * Code HTML |
| 3809 | 3809 | */ |
| 3810 | 3810 | function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') { |
| 3811 | - if ($on) { |
|
| 3812 | - $bal = "strong"; |
|
| 3813 | - $att = "class='on'"; |
|
| 3814 | - } else { |
|
| 3815 | - $bal = 'a'; |
|
| 3816 | - $att = "href='$url'" |
|
| 3817 | - . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 3818 | - . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 3819 | - . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 3820 | - . $evt; |
|
| 3821 | - } |
|
| 3822 | - if ($libelle === null) { |
|
| 3823 | - $libelle = $url; |
|
| 3824 | - } |
|
| 3811 | + if ($on) { |
|
| 3812 | + $bal = "strong"; |
|
| 3813 | + $att = "class='on'"; |
|
| 3814 | + } else { |
|
| 3815 | + $bal = 'a'; |
|
| 3816 | + $att = "href='$url'" |
|
| 3817 | + . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 3818 | + . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 3819 | + . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 3820 | + . $evt; |
|
| 3821 | + } |
|
| 3822 | + if ($libelle === null) { |
|
| 3823 | + $libelle = $url; |
|
| 3824 | + } |
|
| 3825 | 3825 | |
| 3826 | - return "<$bal $att>$libelle</$bal>"; |
|
| 3826 | + return "<$bal $att>$libelle</$bal>"; |
|
| 3827 | 3827 | } |
| 3828 | 3828 | |
| 3829 | 3829 | |
@@ -3840,18 +3840,18 @@ discard block |
||
| 3840 | 3840 | * @return string : la chaine de langue finale en utilisant la fonction _T() |
| 3841 | 3841 | */ |
| 3842 | 3842 | function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) { |
| 3843 | - if (!$nb = intval($nb)) { |
|
| 3844 | - return ""; |
|
| 3845 | - } |
|
| 3846 | - if (!is_array($vars)) { |
|
| 3847 | - return ""; |
|
| 3848 | - } |
|
| 3849 | - $vars[$var] = $nb; |
|
| 3850 | - if ($nb > 1) { |
|
| 3851 | - return _T($chaine_plusieurs, $vars); |
|
| 3852 | - } else { |
|
| 3853 | - return _T($chaine_un, $vars); |
|
| 3854 | - } |
|
| 3843 | + if (!$nb = intval($nb)) { |
|
| 3844 | + return ""; |
|
| 3845 | + } |
|
| 3846 | + if (!is_array($vars)) { |
|
| 3847 | + return ""; |
|
| 3848 | + } |
|
| 3849 | + $vars[$var] = $nb; |
|
| 3850 | + if ($nb > 1) { |
|
| 3851 | + return _T($chaine_plusieurs, $vars); |
|
| 3852 | + } else { |
|
| 3853 | + return _T($chaine_un, $vars); |
|
| 3854 | + } |
|
| 3855 | 3855 | } |
| 3856 | 3856 | |
| 3857 | 3857 | |
@@ -3876,60 +3876,60 @@ discard block |
||
| 3876 | 3876 | * @return string |
| 3877 | 3877 | */ |
| 3878 | 3878 | function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") { |
| 3879 | - if (in_array($fonction, array("del", "supprimer.gif"))) { |
|
| 3880 | - $class .= ' danger'; |
|
| 3881 | - } elseif ($fonction == "rien.gif") { |
|
| 3882 | - $fonction = ""; |
|
| 3883 | - } elseif ($fonction == "delsafe") { |
|
| 3884 | - $fonction = "del"; |
|
| 3885 | - } |
|
| 3886 | - |
|
| 3887 | - // remappage des icone : article-24.png+new => article-new-24.png |
|
| 3888 | - if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 3889 | - list($fond, $fonction) = $icone_renommer($fond, $fonction); |
|
| 3890 | - } |
|
| 3891 | - |
|
| 3892 | - // ajouter le type d'objet dans la class de l'icone |
|
| 3893 | - $class .= " " . substr(basename($fond), 0, -4); |
|
| 3894 | - |
|
| 3895 | - $alt = attribut_html($texte); |
|
| 3896 | - $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
|
| 3897 | - |
|
| 3898 | - $ajax = ""; |
|
| 3899 | - if (strpos($class, "ajax") !== false) { |
|
| 3900 | - $ajax = "ajax"; |
|
| 3901 | - if (strpos($class, "preload") !== false) { |
|
| 3902 | - $ajax .= " preload"; |
|
| 3903 | - } |
|
| 3904 | - if (strpos($class, "nocache") !== false) { |
|
| 3905 | - $ajax .= " nocache"; |
|
| 3906 | - } |
|
| 3907 | - $ajax = " class='$ajax'"; |
|
| 3908 | - } |
|
| 3909 | - |
|
| 3910 | - $size = 24; |
|
| 3911 | - if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) { |
|
| 3912 | - $size = $match[1]; |
|
| 3913 | - } |
|
| 3914 | - |
|
| 3915 | - if ($fonction) { |
|
| 3916 | - // 2 images pour composer l'icone : le fond (article) en background, |
|
| 3917 | - // la fonction (new) en image |
|
| 3918 | - $icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n" . |
|
| 3919 | - http_style_background($fond)); |
|
| 3920 | - } else { |
|
| 3921 | - $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
|
| 3922 | - } |
|
| 3923 | - |
|
| 3924 | - if ($type == 'lien') { |
|
| 3925 | - return "<span class='icone s$size $class'>" |
|
| 3926 | - . "<a href='$lien'$title$ajax$javascript>" |
|
| 3927 | - . $icone |
|
| 3928 | - . "<b>$texte</b>" |
|
| 3929 | - . "</a></span>\n"; |
|
| 3930 | - } else { |
|
| 3931 | - return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt); |
|
| 3932 | - } |
|
| 3879 | + if (in_array($fonction, array("del", "supprimer.gif"))) { |
|
| 3880 | + $class .= ' danger'; |
|
| 3881 | + } elseif ($fonction == "rien.gif") { |
|
| 3882 | + $fonction = ""; |
|
| 3883 | + } elseif ($fonction == "delsafe") { |
|
| 3884 | + $fonction = "del"; |
|
| 3885 | + } |
|
| 3886 | + |
|
| 3887 | + // remappage des icone : article-24.png+new => article-new-24.png |
|
| 3888 | + if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 3889 | + list($fond, $fonction) = $icone_renommer($fond, $fonction); |
|
| 3890 | + } |
|
| 3891 | + |
|
| 3892 | + // ajouter le type d'objet dans la class de l'icone |
|
| 3893 | + $class .= " " . substr(basename($fond), 0, -4); |
|
| 3894 | + |
|
| 3895 | + $alt = attribut_html($texte); |
|
| 3896 | + $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
|
| 3897 | + |
|
| 3898 | + $ajax = ""; |
|
| 3899 | + if (strpos($class, "ajax") !== false) { |
|
| 3900 | + $ajax = "ajax"; |
|
| 3901 | + if (strpos($class, "preload") !== false) { |
|
| 3902 | + $ajax .= " preload"; |
|
| 3903 | + } |
|
| 3904 | + if (strpos($class, "nocache") !== false) { |
|
| 3905 | + $ajax .= " nocache"; |
|
| 3906 | + } |
|
| 3907 | + $ajax = " class='$ajax'"; |
|
| 3908 | + } |
|
| 3909 | + |
|
| 3910 | + $size = 24; |
|
| 3911 | + if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) { |
|
| 3912 | + $size = $match[1]; |
|
| 3913 | + } |
|
| 3914 | + |
|
| 3915 | + if ($fonction) { |
|
| 3916 | + // 2 images pour composer l'icone : le fond (article) en background, |
|
| 3917 | + // la fonction (new) en image |
|
| 3918 | + $icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n" . |
|
| 3919 | + http_style_background($fond)); |
|
| 3920 | + } else { |
|
| 3921 | + $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
|
| 3922 | + } |
|
| 3923 | + |
|
| 3924 | + if ($type == 'lien') { |
|
| 3925 | + return "<span class='icone s$size $class'>" |
|
| 3926 | + . "<a href='$lien'$title$ajax$javascript>" |
|
| 3927 | + . $icone |
|
| 3928 | + . "<b>$texte</b>" |
|
| 3929 | + . "</a></span>\n"; |
|
| 3930 | + } else { |
|
| 3931 | + return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt); |
|
| 3932 | + } |
|
| 3933 | 3933 | } |
| 3934 | 3934 | |
| 3935 | 3935 | /** |
@@ -3953,7 +3953,7 @@ discard block |
||
| 3953 | 3953 | * Code HTML du lien |
| 3954 | 3954 | **/ |
| 3955 | 3955 | function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") { |
| 3956 | - return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript); |
|
| 3956 | + return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript); |
|
| 3957 | 3957 | } |
| 3958 | 3958 | |
| 3959 | 3959 | /** |
@@ -3988,7 +3988,7 @@ discard block |
||
| 3988 | 3988 | * Code HTML du lien |
| 3989 | 3989 | **/ |
| 3990 | 3990 | function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") { |
| 3991 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript); |
|
| 3991 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript); |
|
| 3992 | 3992 | } |
| 3993 | 3993 | |
| 3994 | 3994 | /** |
@@ -4033,7 +4033,7 @@ discard block |
||
| 4033 | 4033 | * Code HTML du lien |
| 4034 | 4034 | **/ |
| 4035 | 4035 | function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") { |
| 4036 | - return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript); |
|
| 4036 | + return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript); |
|
| 4037 | 4037 | } |
| 4038 | 4038 | |
| 4039 | 4039 | /** |
@@ -4064,7 +4064,7 @@ discard block |
||
| 4064 | 4064 | * Code HTML du lien |
| 4065 | 4065 | **/ |
| 4066 | 4066 | function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") { |
| 4067 | - return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm); |
|
| 4067 | + return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm); |
|
| 4068 | 4068 | } |
| 4069 | 4069 | |
| 4070 | 4070 | /** |
@@ -4094,7 +4094,7 @@ discard block |
||
| 4094 | 4094 | * Code HTML du lien |
| 4095 | 4095 | */ |
| 4096 | 4096 | function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") { |
| 4097 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript); |
|
| 4097 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript); |
|
| 4098 | 4098 | } |
| 4099 | 4099 | |
| 4100 | 4100 | |
@@ -4142,26 +4142,26 @@ discard block |
||
| 4142 | 4142 | * @return string Code CSS |
| 4143 | 4143 | */ |
| 4144 | 4144 | function bando_images_background() { |
| 4145 | - include_spip('inc/bandeau'); |
|
| 4146 | - // recuperer tous les boutons et leurs images |
|
| 4147 | - $boutons = definir_barre_boutons(definir_barre_contexte(), true, false); |
|
| 4145 | + include_spip('inc/bandeau'); |
|
| 4146 | + // recuperer tous les boutons et leurs images |
|
| 4147 | + $boutons = definir_barre_boutons(definir_barre_contexte(), true, false); |
|
| 4148 | 4148 | |
| 4149 | - $res = ""; |
|
| 4150 | - foreach ($boutons as $page => $detail) { |
|
| 4151 | - if ($detail->icone and strlen(trim($detail->icone))) { |
|
| 4152 | - $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}"; |
|
| 4153 | - } |
|
| 4154 | - $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones "); |
|
| 4155 | - if (is_array($detail->sousmenu)) { |
|
| 4156 | - foreach ($detail->sousmenu as $souspage => $sousdetail) { |
|
| 4157 | - if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
|
| 4158 | - $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}"; |
|
| 4159 | - } |
|
| 4160 | - } |
|
| 4161 | - } |
|
| 4162 | - } |
|
| 4149 | + $res = ""; |
|
| 4150 | + foreach ($boutons as $page => $detail) { |
|
| 4151 | + if ($detail->icone and strlen(trim($detail->icone))) { |
|
| 4152 | + $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}"; |
|
| 4153 | + } |
|
| 4154 | + $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones "); |
|
| 4155 | + if (is_array($detail->sousmenu)) { |
|
| 4156 | + foreach ($detail->sousmenu as $souspage => $sousdetail) { |
|
| 4157 | + if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
|
| 4158 | + $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}"; |
|
| 4159 | + } |
|
| 4160 | + } |
|
| 4161 | + } |
|
| 4162 | + } |
|
| 4163 | 4163 | |
| 4164 | - return $res; |
|
| 4164 | + return $res; |
|
| 4165 | 4165 | } |
| 4166 | 4166 | |
| 4167 | 4167 | /** |
@@ -4180,19 +4180,19 @@ discard block |
||
| 4180 | 4180 | * @return string |
| 4181 | 4181 | */ |
| 4182 | 4182 | function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") { |
| 4183 | - if ($confirm) { |
|
| 4184 | - $confirm = "confirm(\"" . attribut_html($confirm) . "\")"; |
|
| 4185 | - if ($callback) { |
|
| 4186 | - $callback = "$confirm?($callback):false"; |
|
| 4187 | - } else { |
|
| 4188 | - $callback = $confirm; |
|
| 4189 | - } |
|
| 4190 | - } |
|
| 4191 | - $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ""; |
|
| 4192 | - $title = $title ? " title='$title'" : ""; |
|
| 4183 | + if ($confirm) { |
|
| 4184 | + $confirm = "confirm(\"" . attribut_html($confirm) . "\")"; |
|
| 4185 | + if ($callback) { |
|
| 4186 | + $callback = "$confirm?($callback):false"; |
|
| 4187 | + } else { |
|
| 4188 | + $callback = $confirm; |
|
| 4189 | + } |
|
| 4190 | + } |
|
| 4191 | + $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ""; |
|
| 4192 | + $title = $title ? " title='$title'" : ""; |
|
| 4193 | 4193 | |
| 4194 | - return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4195 | - . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>"; |
|
| 4194 | + return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4195 | + . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>"; |
|
| 4196 | 4196 | } |
| 4197 | 4197 | |
| 4198 | 4198 | |
@@ -4204,7 +4204,7 @@ discard block |
||
| 4204 | 4204 | * @return string |
| 4205 | 4205 | */ |
| 4206 | 4206 | function tri_protege_champ($t) { |
| 4207 | - return preg_replace(',[^\s\w.+],', '', $t); |
|
| 4207 | + return preg_replace(',[^\s\w.+],', '', $t); |
|
| 4208 | 4208 | } |
| 4209 | 4209 | |
| 4210 | 4210 | /** |
@@ -4217,34 +4217,34 @@ discard block |
||
| 4217 | 4217 | * @return string |
| 4218 | 4218 | */ |
| 4219 | 4219 | function tri_champ_order($t, $from = null) { |
| 4220 | - if (strncmp($t, 'multi ', 6) == 0) { |
|
| 4221 | - return "multi"; |
|
| 4222 | - } |
|
| 4223 | - |
|
| 4224 | - $champ = $t; |
|
| 4225 | - |
|
| 4226 | - if (strncmp($t, 'num ', 4) == 0) { |
|
| 4227 | - $champ = substr($t, 4); |
|
| 4228 | - } |
|
| 4229 | - // enlever les autres espaces non evacues par tri_protege_champ |
|
| 4230 | - $champ = preg_replace(',\s,', '', $champ); |
|
| 4231 | - |
|
| 4232 | - if (is_array($from)) { |
|
| 4233 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4234 | - foreach ($from as $idt => $table_sql) { |
|
| 4235 | - if ($desc = $trouver_table($table_sql) |
|
| 4236 | - and isset($desc['field'][$champ]) |
|
| 4237 | - ) { |
|
| 4238 | - $champ = "$idt.$champ"; |
|
| 4239 | - break; |
|
| 4240 | - } |
|
| 4241 | - } |
|
| 4242 | - } |
|
| 4243 | - if (strncmp($t, 'num ', 4) == 0) { |
|
| 4244 | - return "0+$champ"; |
|
| 4245 | - } else { |
|
| 4246 | - return $champ; |
|
| 4247 | - } |
|
| 4220 | + if (strncmp($t, 'multi ', 6) == 0) { |
|
| 4221 | + return "multi"; |
|
| 4222 | + } |
|
| 4223 | + |
|
| 4224 | + $champ = $t; |
|
| 4225 | + |
|
| 4226 | + if (strncmp($t, 'num ', 4) == 0) { |
|
| 4227 | + $champ = substr($t, 4); |
|
| 4228 | + } |
|
| 4229 | + // enlever les autres espaces non evacues par tri_protege_champ |
|
| 4230 | + $champ = preg_replace(',\s,', '', $champ); |
|
| 4231 | + |
|
| 4232 | + if (is_array($from)) { |
|
| 4233 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4234 | + foreach ($from as $idt => $table_sql) { |
|
| 4235 | + if ($desc = $trouver_table($table_sql) |
|
| 4236 | + and isset($desc['field'][$champ]) |
|
| 4237 | + ) { |
|
| 4238 | + $champ = "$idt.$champ"; |
|
| 4239 | + break; |
|
| 4240 | + } |
|
| 4241 | + } |
|
| 4242 | + } |
|
| 4243 | + if (strncmp($t, 'num ', 4) == 0) { |
|
| 4244 | + return "0+$champ"; |
|
| 4245 | + } else { |
|
| 4246 | + return $champ; |
|
| 4247 | + } |
|
| 4248 | 4248 | } |
| 4249 | 4249 | |
| 4250 | 4250 | /** |
@@ -4258,18 +4258,18 @@ discard block |
||
| 4258 | 4258 | * @return string |
| 4259 | 4259 | */ |
| 4260 | 4260 | function tri_champ_select($t) { |
| 4261 | - if (strncmp($t, 'multi ', 6) == 0) { |
|
| 4262 | - $t = substr($t, 6); |
|
| 4263 | - $t = preg_replace(',\s,', '', $t); |
|
| 4264 | - $t = sql_multi($t, $GLOBALS['spip_lang']); |
|
| 4261 | + if (strncmp($t, 'multi ', 6) == 0) { |
|
| 4262 | + $t = substr($t, 6); |
|
| 4263 | + $t = preg_replace(',\s,', '', $t); |
|
| 4264 | + $t = sql_multi($t, $GLOBALS['spip_lang']); |
|
| 4265 | 4265 | |
| 4266 | - return $t; |
|
| 4267 | - } |
|
| 4268 | - if (trim($t) == 'hasard') { |
|
| 4269 | - return 'rand() AS hasard'; |
|
| 4270 | - } |
|
| 4266 | + return $t; |
|
| 4267 | + } |
|
| 4268 | + if (trim($t) == 'hasard') { |
|
| 4269 | + return 'rand() AS hasard'; |
|
| 4270 | + } |
|
| 4271 | 4271 | |
| 4272 | - return "''"; |
|
| 4272 | + return "''"; |
|
| 4273 | 4273 | } |
| 4274 | 4274 | |
| 4275 | 4275 | |
@@ -4291,78 +4291,78 @@ discard block |
||
| 4291 | 4291 | * @return string |
| 4292 | 4292 | */ |
| 4293 | 4293 | function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") { |
| 4294 | - static $trouver_table = null; |
|
| 4295 | - static $objets; |
|
| 4296 | - |
|
| 4297 | - // On verifie qu'on a tout ce qu'il faut |
|
| 4298 | - $id_objet = intval($id_objet); |
|
| 4299 | - if (!($id_objet and $type_objet and $info)) { |
|
| 4300 | - return ''; |
|
| 4301 | - } |
|
| 4302 | - |
|
| 4303 | - // si on a deja note que l'objet n'existe pas, ne pas aller plus loin |
|
| 4304 | - if (isset($objets[$type_objet]) and $objets[$type_objet] === false) { |
|
| 4305 | - return ''; |
|
| 4306 | - } |
|
| 4307 | - |
|
| 4308 | - // Si on demande l'url, on retourne direct la fonction |
|
| 4309 | - if ($info == 'url') { |
|
| 4310 | - return generer_url_entite($id_objet, $type_objet); |
|
| 4311 | - } |
|
| 4312 | - |
|
| 4313 | - // Sinon on va tout chercher dans la table et on garde en memoire |
|
| 4314 | - $demande_titre = ($info == 'titre'); |
|
| 4315 | - |
|
| 4316 | - // On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore |
|
| 4317 | - if (!isset($objets[$type_objet][$id_objet]) |
|
| 4318 | - or |
|
| 4319 | - ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre'])) |
|
| 4320 | - ) { |
|
| 4321 | - if (!$trouver_table) { |
|
| 4322 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4323 | - } |
|
| 4324 | - $desc = $trouver_table(table_objet_sql($type_objet)); |
|
| 4325 | - if (!$desc) { |
|
| 4326 | - return $objets[$type_objet] = false; |
|
| 4327 | - } |
|
| 4328 | - |
|
| 4329 | - // Si on demande le titre, on le gere en interne |
|
| 4330 | - $champ_titre = ""; |
|
| 4331 | - if ($demande_titre) { |
|
| 4332 | - // si pas de titre declare mais champ titre, il sera peuple par le select * |
|
| 4333 | - $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4334 | - } |
|
| 4335 | - include_spip('base/abstract_sql'); |
|
| 4336 | - include_spip('base/connect_sql'); |
|
| 4337 | - $objets[$type_objet][$id_objet] = sql_fetsel( |
|
| 4338 | - '*' . $champ_titre, |
|
| 4339 | - $desc['table_sql'], |
|
| 4340 | - id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4341 | - ); |
|
| 4342 | - } |
|
| 4343 | - |
|
| 4344 | - // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee |
|
| 4345 | - if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) { |
|
| 4346 | - $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]); |
|
| 4347 | - } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee |
|
| 4348 | - else { |
|
| 4349 | - if ($generer = charger_fonction("generer_${info}_entite", '', true)) { |
|
| 4350 | - $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]); |
|
| 4351 | - } // Sinon on prend directement le champ SQL tel quel |
|
| 4352 | - else { |
|
| 4353 | - $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : ''); |
|
| 4354 | - } |
|
| 4355 | - } |
|
| 4356 | - |
|
| 4357 | - // On va ensuite appliquer les traitements automatiques si besoin |
|
| 4358 | - if (!$etoile) { |
|
| 4359 | - // FIXME: on fournit un ENV minimum avec id et type et connect='' |
|
| 4360 | - // mais ce fonctionnement est a ameliorer ! |
|
| 4361 | - $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet), |
|
| 4362 | - array('id_objet' => $id_objet, 'objet' => $type_objet, '')); |
|
| 4363 | - } |
|
| 4364 | - |
|
| 4365 | - return $info_generee; |
|
| 4294 | + static $trouver_table = null; |
|
| 4295 | + static $objets; |
|
| 4296 | + |
|
| 4297 | + // On verifie qu'on a tout ce qu'il faut |
|
| 4298 | + $id_objet = intval($id_objet); |
|
| 4299 | + if (!($id_objet and $type_objet and $info)) { |
|
| 4300 | + return ''; |
|
| 4301 | + } |
|
| 4302 | + |
|
| 4303 | + // si on a deja note que l'objet n'existe pas, ne pas aller plus loin |
|
| 4304 | + if (isset($objets[$type_objet]) and $objets[$type_objet] === false) { |
|
| 4305 | + return ''; |
|
| 4306 | + } |
|
| 4307 | + |
|
| 4308 | + // Si on demande l'url, on retourne direct la fonction |
|
| 4309 | + if ($info == 'url') { |
|
| 4310 | + return generer_url_entite($id_objet, $type_objet); |
|
| 4311 | + } |
|
| 4312 | + |
|
| 4313 | + // Sinon on va tout chercher dans la table et on garde en memoire |
|
| 4314 | + $demande_titre = ($info == 'titre'); |
|
| 4315 | + |
|
| 4316 | + // On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore |
|
| 4317 | + if (!isset($objets[$type_objet][$id_objet]) |
|
| 4318 | + or |
|
| 4319 | + ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre'])) |
|
| 4320 | + ) { |
|
| 4321 | + if (!$trouver_table) { |
|
| 4322 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4323 | + } |
|
| 4324 | + $desc = $trouver_table(table_objet_sql($type_objet)); |
|
| 4325 | + if (!$desc) { |
|
| 4326 | + return $objets[$type_objet] = false; |
|
| 4327 | + } |
|
| 4328 | + |
|
| 4329 | + // Si on demande le titre, on le gere en interne |
|
| 4330 | + $champ_titre = ""; |
|
| 4331 | + if ($demande_titre) { |
|
| 4332 | + // si pas de titre declare mais champ titre, il sera peuple par le select * |
|
| 4333 | + $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4334 | + } |
|
| 4335 | + include_spip('base/abstract_sql'); |
|
| 4336 | + include_spip('base/connect_sql'); |
|
| 4337 | + $objets[$type_objet][$id_objet] = sql_fetsel( |
|
| 4338 | + '*' . $champ_titre, |
|
| 4339 | + $desc['table_sql'], |
|
| 4340 | + id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4341 | + ); |
|
| 4342 | + } |
|
| 4343 | + |
|
| 4344 | + // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee |
|
| 4345 | + if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) { |
|
| 4346 | + $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]); |
|
| 4347 | + } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee |
|
| 4348 | + else { |
|
| 4349 | + if ($generer = charger_fonction("generer_${info}_entite", '', true)) { |
|
| 4350 | + $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]); |
|
| 4351 | + } // Sinon on prend directement le champ SQL tel quel |
|
| 4352 | + else { |
|
| 4353 | + $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : ''); |
|
| 4354 | + } |
|
| 4355 | + } |
|
| 4356 | + |
|
| 4357 | + // On va ensuite appliquer les traitements automatiques si besoin |
|
| 4358 | + if (!$etoile) { |
|
| 4359 | + // FIXME: on fournit un ENV minimum avec id et type et connect='' |
|
| 4360 | + // mais ce fonctionnement est a ameliorer ! |
|
| 4361 | + $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet), |
|
| 4362 | + array('id_objet' => $id_objet, 'objet' => $type_objet, '')); |
|
| 4363 | + } |
|
| 4364 | + |
|
| 4365 | + return $info_generee; |
|
| 4366 | 4366 | } |
| 4367 | 4367 | |
| 4368 | 4368 | /** |
@@ -4376,44 +4376,44 @@ discard block |
||
| 4376 | 4376 | * @return string |
| 4377 | 4377 | */ |
| 4378 | 4378 | function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') { |
| 4379 | - if (!$champ) { |
|
| 4380 | - return $texte; |
|
| 4381 | - } |
|
| 4379 | + if (!$champ) { |
|
| 4380 | + return $texte; |
|
| 4381 | + } |
|
| 4382 | 4382 | |
| 4383 | - // On charge toujours les filtres de texte car la majorité des traitements les utilisent |
|
| 4384 | - // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc) |
|
| 4385 | - include_spip('inc/texte'); |
|
| 4383 | + // On charge toujours les filtres de texte car la majorité des traitements les utilisent |
|
| 4384 | + // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc) |
|
| 4385 | + include_spip('inc/texte'); |
|
| 4386 | 4386 | |
| 4387 | - $champ = strtoupper($champ); |
|
| 4388 | - $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false; |
|
| 4389 | - if (!$traitements or !is_array($traitements)) { |
|
| 4390 | - return $texte; |
|
| 4391 | - } |
|
| 4387 | + $champ = strtoupper($champ); |
|
| 4388 | + $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false; |
|
| 4389 | + if (!$traitements or !is_array($traitements)) { |
|
| 4390 | + return $texte; |
|
| 4391 | + } |
|
| 4392 | 4392 | |
| 4393 | - $traitement = ''; |
|
| 4394 | - if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) { |
|
| 4395 | - // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg |
|
| 4396 | - $table_objet = table_objet($table_objet); |
|
| 4397 | - if (isset($traitements[$table_objet])) { |
|
| 4398 | - $traitement = $traitements[$table_objet]; |
|
| 4399 | - } |
|
| 4400 | - } |
|
| 4401 | - if (!$traitement and isset($traitements[0])) { |
|
| 4402 | - $traitement = $traitements[0]; |
|
| 4403 | - } |
|
| 4404 | - // (sinon prendre le premier de la liste par defaut ?) |
|
| 4393 | + $traitement = ''; |
|
| 4394 | + if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) { |
|
| 4395 | + // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg |
|
| 4396 | + $table_objet = table_objet($table_objet); |
|
| 4397 | + if (isset($traitements[$table_objet])) { |
|
| 4398 | + $traitement = $traitements[$table_objet]; |
|
| 4399 | + } |
|
| 4400 | + } |
|
| 4401 | + if (!$traitement and isset($traitements[0])) { |
|
| 4402 | + $traitement = $traitements[0]; |
|
| 4403 | + } |
|
| 4404 | + // (sinon prendre le premier de la liste par defaut ?) |
|
| 4405 | 4405 | |
| 4406 | - if (!$traitement) { |
|
| 4407 | - return $texte; |
|
| 4408 | - } |
|
| 4406 | + if (!$traitement) { |
|
| 4407 | + return $texte; |
|
| 4408 | + } |
|
| 4409 | 4409 | |
| 4410 | - $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4410 | + $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4411 | 4411 | |
| 4412 | - // Fournir $connect et $Pile[0] au traitement si besoin |
|
| 4413 | - $Pile = array(0 => $env); |
|
| 4414 | - eval("\$texte = $traitement;"); |
|
| 4412 | + // Fournir $connect et $Pile[0] au traitement si besoin |
|
| 4413 | + $Pile = array(0 => $env); |
|
| 4414 | + eval("\$texte = $traitement;"); |
|
| 4415 | 4415 | |
| 4416 | - return $texte; |
|
| 4416 | + return $texte; |
|
| 4417 | 4417 | } |
| 4418 | 4418 | |
| 4419 | 4419 | |
@@ -4427,21 +4427,21 @@ discard block |
||
| 4427 | 4427 | * @return string |
| 4428 | 4428 | */ |
| 4429 | 4429 | function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) { |
| 4430 | - include_spip('inc/liens'); |
|
| 4431 | - $titre = traiter_raccourci_titre($id_objet, $objet, $connect); |
|
| 4432 | - // lorsque l'objet n'est plus declare (plugin desactive par exemple) |
|
| 4433 | - // le raccourcis n'est plus valide |
|
| 4434 | - $titre = isset($titre['titre']) ? typo($titre['titre']) : ''; |
|
| 4435 | - // on essaye avec generer_info_entite ? |
|
| 4436 | - if (!strlen($titre) and !$connect) { |
|
| 4437 | - $titre = generer_info_entite($id_objet, $objet, 'titre'); |
|
| 4438 | - } |
|
| 4439 | - if (!strlen($titre)) { |
|
| 4440 | - $titre = _T('info_sans_titre'); |
|
| 4441 | - } |
|
| 4442 | - $url = generer_url_entite($id_objet, $objet, '', '', $connect); |
|
| 4430 | + include_spip('inc/liens'); |
|
| 4431 | + $titre = traiter_raccourci_titre($id_objet, $objet, $connect); |
|
| 4432 | + // lorsque l'objet n'est plus declare (plugin desactive par exemple) |
|
| 4433 | + // le raccourcis n'est plus valide |
|
| 4434 | + $titre = isset($titre['titre']) ? typo($titre['titre']) : ''; |
|
| 4435 | + // on essaye avec generer_info_entite ? |
|
| 4436 | + if (!strlen($titre) and !$connect) { |
|
| 4437 | + $titre = generer_info_entite($id_objet, $objet, 'titre'); |
|
| 4438 | + } |
|
| 4439 | + if (!strlen($titre)) { |
|
| 4440 | + $titre = _T('info_sans_titre'); |
|
| 4441 | + } |
|
| 4442 | + $url = generer_url_entite($id_objet, $objet, '', '', $connect); |
|
| 4443 | 4443 | |
| 4444 | - return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>"; |
|
| 4444 | + return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>"; |
|
| 4445 | 4445 | } |
| 4446 | 4446 | |
| 4447 | 4447 | |
@@ -4458,15 +4458,15 @@ discard block |
||
| 4458 | 4458 | * @return string |
| 4459 | 4459 | */ |
| 4460 | 4460 | function wrap($texte, $wrap) { |
| 4461 | - $balises = extraire_balises($wrap); |
|
| 4462 | - if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
|
| 4463 | - $texte = $wrap . $texte; |
|
| 4464 | - $regs = array_reverse($regs[1]); |
|
| 4465 | - $wrap = "</" . implode("></", $regs) . ">"; |
|
| 4466 | - $texte = $texte . $wrap; |
|
| 4467 | - } |
|
| 4461 | + $balises = extraire_balises($wrap); |
|
| 4462 | + if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
|
| 4463 | + $texte = $wrap . $texte; |
|
| 4464 | + $regs = array_reverse($regs[1]); |
|
| 4465 | + $wrap = "</" . implode("></", $regs) . ">"; |
|
| 4466 | + $texte = $texte . $wrap; |
|
| 4467 | + } |
|
| 4468 | 4468 | |
| 4469 | - return $texte; |
|
| 4469 | + return $texte; |
|
| 4470 | 4470 | } |
| 4471 | 4471 | |
| 4472 | 4472 | |
@@ -4486,43 +4486,43 @@ discard block |
||
| 4486 | 4486 | * @return array|mixed|string |
| 4487 | 4487 | */ |
| 4488 | 4488 | function filtre_print_dist($u, $join = "<br />", $indent = 0) { |
| 4489 | - if (is_string($u)) { |
|
| 4490 | - $u = typo($u); |
|
| 4489 | + if (is_string($u)) { |
|
| 4490 | + $u = typo($u); |
|
| 4491 | 4491 | |
| 4492 | - return $u; |
|
| 4493 | - } |
|
| 4492 | + return $u; |
|
| 4493 | + } |
|
| 4494 | 4494 | |
| 4495 | - // caster $u en array si besoin |
|
| 4496 | - if (is_object($u)) { |
|
| 4497 | - $u = (array)$u; |
|
| 4498 | - } |
|
| 4495 | + // caster $u en array si besoin |
|
| 4496 | + if (is_object($u)) { |
|
| 4497 | + $u = (array)$u; |
|
| 4498 | + } |
|
| 4499 | 4499 | |
| 4500 | - if (is_array($u)) { |
|
| 4501 | - $out = ""; |
|
| 4502 | - // toutes les cles sont numeriques ? |
|
| 4503 | - // et aucun enfant n'est un tableau |
|
| 4504 | - // liste simple separee par des virgules |
|
| 4505 | - $numeric_keys = array_map('is_numeric', array_keys($u)); |
|
| 4506 | - $array_values = array_map('is_array', $u); |
|
| 4507 | - $object_values = array_map('is_object', $u); |
|
| 4508 | - if (array_sum($numeric_keys) == count($numeric_keys) |
|
| 4509 | - and !array_sum($array_values) |
|
| 4510 | - and !array_sum($object_values) |
|
| 4511 | - ) { |
|
| 4512 | - return join(", ", array_map('filtre_print_dist', $u)); |
|
| 4513 | - } |
|
| 4500 | + if (is_array($u)) { |
|
| 4501 | + $out = ""; |
|
| 4502 | + // toutes les cles sont numeriques ? |
|
| 4503 | + // et aucun enfant n'est un tableau |
|
| 4504 | + // liste simple separee par des virgules |
|
| 4505 | + $numeric_keys = array_map('is_numeric', array_keys($u)); |
|
| 4506 | + $array_values = array_map('is_array', $u); |
|
| 4507 | + $object_values = array_map('is_object', $u); |
|
| 4508 | + if (array_sum($numeric_keys) == count($numeric_keys) |
|
| 4509 | + and !array_sum($array_values) |
|
| 4510 | + and !array_sum($object_values) |
|
| 4511 | + ) { |
|
| 4512 | + return join(", ", array_map('filtre_print_dist', $u)); |
|
| 4513 | + } |
|
| 4514 | 4514 | |
| 4515 | - // sinon on passe a la ligne et on indente |
|
| 4516 | - $i_str = str_pad("", $indent, "Â "); |
|
| 4517 | - foreach ($u as $k => $v) { |
|
| 4518 | - $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 4519 | - } |
|
| 4515 | + // sinon on passe a la ligne et on indente |
|
| 4516 | + $i_str = str_pad("", $indent, "Â "); |
|
| 4517 | + foreach ($u as $k => $v) { |
|
| 4518 | + $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 4519 | + } |
|
| 4520 | 4520 | |
| 4521 | - return $out; |
|
| 4522 | - } |
|
| 4521 | + return $out; |
|
| 4522 | + } |
|
| 4523 | 4523 | |
| 4524 | - // on sait pas quoi faire... |
|
| 4525 | - return $u; |
|
| 4524 | + // on sait pas quoi faire... |
|
| 4525 | + return $u; |
|
| 4526 | 4526 | } |
| 4527 | 4527 | |
| 4528 | 4528 | |
@@ -4535,10 +4535,10 @@ discard block |
||
| 4535 | 4535 | * @return string |
| 4536 | 4536 | */ |
| 4537 | 4537 | function objet_info($objet, $info) { |
| 4538 | - $table = table_objet_sql($objet); |
|
| 4539 | - $infos = lister_tables_objets_sql($table); |
|
| 4538 | + $table = table_objet_sql($objet); |
|
| 4539 | + $infos = lister_tables_objets_sql($table); |
|
| 4540 | 4540 | |
| 4541 | - return (isset($infos[$info]) ? $infos[$info] : ''); |
|
| 4541 | + return (isset($infos[$info]) ? $infos[$info] : ''); |
|
| 4542 | 4542 | } |
| 4543 | 4543 | |
| 4544 | 4544 | /** |
@@ -4553,11 +4553,11 @@ discard block |
||
| 4553 | 4553 | * Texte traduit du comptage, tel que '3 articles' |
| 4554 | 4554 | */ |
| 4555 | 4555 | function objet_afficher_nb($nb, $objet) { |
| 4556 | - if (!$nb) { |
|
| 4557 | - return _T(objet_info($objet, 'info_aucun_objet')); |
|
| 4558 | - } else { |
|
| 4559 | - return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb)); |
|
| 4560 | - } |
|
| 4556 | + if (!$nb) { |
|
| 4557 | + return _T(objet_info($objet, 'info_aucun_objet')); |
|
| 4558 | + } else { |
|
| 4559 | + return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb)); |
|
| 4560 | + } |
|
| 4561 | 4561 | } |
| 4562 | 4562 | |
| 4563 | 4563 | /** |
@@ -4568,11 +4568,11 @@ discard block |
||
| 4568 | 4568 | * @return string |
| 4569 | 4569 | */ |
| 4570 | 4570 | function objet_icone($objet, $taille = 24) { |
| 4571 | - $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png"; |
|
| 4572 | - $icone = chemin_image($icone); |
|
| 4573 | - $balise_img = charger_filtre('balise_img'); |
|
| 4571 | + $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png"; |
|
| 4572 | + $icone = chemin_image($icone); |
|
| 4573 | + $balise_img = charger_filtre('balise_img'); |
|
| 4574 | 4574 | |
| 4575 | - return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet'))) : ''; |
|
| 4575 | + return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet'))) : ''; |
|
| 4576 | 4576 | } |
| 4577 | 4577 | |
| 4578 | 4578 | /** |
@@ -4593,12 +4593,12 @@ discard block |
||
| 4593 | 4593 | * @return string |
| 4594 | 4594 | */ |
| 4595 | 4595 | function objet_T($objet, $chaine, $args = array(), $options = array()){ |
| 4596 | - $chaine = explode(':',$chaine); |
|
| 4597 | - if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) { |
|
| 4598 | - return $t; |
|
| 4599 | - } |
|
| 4600 | - $chaine = implode(':',$chaine); |
|
| 4601 | - return _T($chaine, $args, $options); |
|
| 4596 | + $chaine = explode(':',$chaine); |
|
| 4597 | + if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) { |
|
| 4598 | + return $t; |
|
| 4599 | + } |
|
| 4600 | + $chaine = implode(':',$chaine); |
|
| 4601 | + return _T($chaine, $args, $options); |
|
| 4602 | 4602 | } |
| 4603 | 4603 | |
| 4604 | 4604 | /** |
@@ -4612,17 +4612,17 @@ discard block |
||
| 4612 | 4612 | * @return string Code HTML |
| 4613 | 4613 | */ |
| 4614 | 4614 | function insert_head_css_conditionnel($flux) { |
| 4615 | - if (strpos($flux, '<!-- insert_head_css -->') === false |
|
| 4616 | - and $p = strpos($flux, '<!-- insert_head -->') |
|
| 4617 | - ) { |
|
| 4618 | - // plutot avant le premier js externe (jquery) pour etre non bloquant |
|
| 4619 | - if ($p1 = stripos($flux, '<script src=') and $p1 < $p) { |
|
| 4620 | - $p = $p1; |
|
| 4621 | - } |
|
| 4622 | - $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0); |
|
| 4623 | - } |
|
| 4615 | + if (strpos($flux, '<!-- insert_head_css -->') === false |
|
| 4616 | + and $p = strpos($flux, '<!-- insert_head -->') |
|
| 4617 | + ) { |
|
| 4618 | + // plutot avant le premier js externe (jquery) pour etre non bloquant |
|
| 4619 | + if ($p1 = stripos($flux, '<script src=') and $p1 < $p) { |
|
| 4620 | + $p = $p1; |
|
| 4621 | + } |
|
| 4622 | + $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0); |
|
| 4623 | + } |
|
| 4624 | 4624 | |
| 4625 | - return $flux; |
|
| 4625 | + return $flux; |
|
| 4626 | 4626 | } |
| 4627 | 4627 | |
| 4628 | 4628 | /** |
@@ -4643,66 +4643,66 @@ discard block |
||
| 4643 | 4643 | * @return string |
| 4644 | 4644 | */ |
| 4645 | 4645 | function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') { |
| 4646 | - if (isset($contexte['format'])) { |
|
| 4647 | - $extension = $contexte['format']; |
|
| 4648 | - unset($contexte['format']); |
|
| 4649 | - } else { |
|
| 4650 | - $extension = "html"; |
|
| 4651 | - if (preg_match(',[.](css|js|json)$,', $fond, $m)) { |
|
| 4652 | - $extension = $m[1]; |
|
| 4653 | - } |
|
| 4654 | - } |
|
| 4655 | - // recuperer le contenu produit par le squelette |
|
| 4656 | - $options['raw'] = true; |
|
| 4657 | - $cache = recuperer_fond($fond, $contexte, $options, $connect); |
|
| 4658 | - |
|
| 4659 | - // calculer le nom de la css |
|
| 4660 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 4661 | - $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond)); |
|
| 4662 | - $contexte_implicite = calculer_contexte_implicite(); |
|
| 4663 | - $filename = $dir_var . $extension . "dyn-$nom_safe-" |
|
| 4664 | - . substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8) |
|
| 4665 | - . ".$extension"; |
|
| 4666 | - |
|
| 4667 | - // mettre a jour le fichier si il n'existe pas |
|
| 4668 | - // ou trop ancien |
|
| 4669 | - // le dernier fichier produit est toujours suffixe par .last |
|
| 4670 | - // et recopie sur le fichier cible uniquement si il change |
|
| 4671 | - if (!file_exists($filename) |
|
| 4672 | - or !file_exists($filename . ".last") |
|
| 4673 | - or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified']) |
|
| 4674 | - or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 4675 | - ) { |
|
| 4676 | - $contenu = $cache['texte']; |
|
| 4677 | - // passer les urls en absolu si c'est une css |
|
| 4678 | - if ($extension == "css") { |
|
| 4679 | - $contenu = urls_absolues_css($contenu, |
|
| 4680 | - test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)); |
|
| 4681 | - } |
|
| 4682 | - |
|
| 4683 | - $comment = ''; |
|
| 4684 | - // ne pas insérer de commentaire si c'est du json |
|
| 4685 | - if ($extension != "json") { |
|
| 4686 | - $comment = "/* #PRODUIRE{fond=$fond"; |
|
| 4687 | - foreach ($contexte as $k => $v) { |
|
| 4688 | - $comment .= ",$k=$v"; |
|
| 4689 | - } |
|
| 4690 | - // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
|
| 4691 | - // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
|
| 4692 | - $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 4693 | - } |
|
| 4694 | - // et ecrire le fichier |
|
| 4695 | - ecrire_fichier($filename . ".last", $comment . $contenu); |
|
| 4696 | - // regarder si on recopie |
|
| 4697 | - if (!file_exists($filename) |
|
| 4698 | - or md5_file($filename) !== md5_file($filename . ".last") |
|
| 4699 | - ) { |
|
| 4700 | - @copy($filename . ".last", $filename); |
|
| 4701 | - clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp |
|
| 4702 | - } |
|
| 4703 | - } |
|
| 4704 | - |
|
| 4705 | - return timestamp($filename); |
|
| 4646 | + if (isset($contexte['format'])) { |
|
| 4647 | + $extension = $contexte['format']; |
|
| 4648 | + unset($contexte['format']); |
|
| 4649 | + } else { |
|
| 4650 | + $extension = "html"; |
|
| 4651 | + if (preg_match(',[.](css|js|json)$,', $fond, $m)) { |
|
| 4652 | + $extension = $m[1]; |
|
| 4653 | + } |
|
| 4654 | + } |
|
| 4655 | + // recuperer le contenu produit par le squelette |
|
| 4656 | + $options['raw'] = true; |
|
| 4657 | + $cache = recuperer_fond($fond, $contexte, $options, $connect); |
|
| 4658 | + |
|
| 4659 | + // calculer le nom de la css |
|
| 4660 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 4661 | + $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond)); |
|
| 4662 | + $contexte_implicite = calculer_contexte_implicite(); |
|
| 4663 | + $filename = $dir_var . $extension . "dyn-$nom_safe-" |
|
| 4664 | + . substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8) |
|
| 4665 | + . ".$extension"; |
|
| 4666 | + |
|
| 4667 | + // mettre a jour le fichier si il n'existe pas |
|
| 4668 | + // ou trop ancien |
|
| 4669 | + // le dernier fichier produit est toujours suffixe par .last |
|
| 4670 | + // et recopie sur le fichier cible uniquement si il change |
|
| 4671 | + if (!file_exists($filename) |
|
| 4672 | + or !file_exists($filename . ".last") |
|
| 4673 | + or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified']) |
|
| 4674 | + or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 4675 | + ) { |
|
| 4676 | + $contenu = $cache['texte']; |
|
| 4677 | + // passer les urls en absolu si c'est une css |
|
| 4678 | + if ($extension == "css") { |
|
| 4679 | + $contenu = urls_absolues_css($contenu, |
|
| 4680 | + test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)); |
|
| 4681 | + } |
|
| 4682 | + |
|
| 4683 | + $comment = ''; |
|
| 4684 | + // ne pas insérer de commentaire si c'est du json |
|
| 4685 | + if ($extension != "json") { |
|
| 4686 | + $comment = "/* #PRODUIRE{fond=$fond"; |
|
| 4687 | + foreach ($contexte as $k => $v) { |
|
| 4688 | + $comment .= ",$k=$v"; |
|
| 4689 | + } |
|
| 4690 | + // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
|
| 4691 | + // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
|
| 4692 | + $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 4693 | + } |
|
| 4694 | + // et ecrire le fichier |
|
| 4695 | + ecrire_fichier($filename . ".last", $comment . $contenu); |
|
| 4696 | + // regarder si on recopie |
|
| 4697 | + if (!file_exists($filename) |
|
| 4698 | + or md5_file($filename) !== md5_file($filename . ".last") |
|
| 4699 | + ) { |
|
| 4700 | + @copy($filename . ".last", $filename); |
|
| 4701 | + clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp |
|
| 4702 | + } |
|
| 4703 | + } |
|
| 4704 | + |
|
| 4705 | + return timestamp($filename); |
|
| 4706 | 4706 | } |
| 4707 | 4707 | |
| 4708 | 4708 | /** |
@@ -4715,14 +4715,14 @@ discard block |
||
| 4715 | 4715 | * $fichier auquel on a ajouté le timestamp |
| 4716 | 4716 | */ |
| 4717 | 4717 | function timestamp($fichier) { |
| 4718 | - if (!$fichier |
|
| 4719 | - or !file_exists($fichier) |
|
| 4720 | - or !$m = filemtime($fichier) |
|
| 4721 | - ) { |
|
| 4722 | - return $fichier; |
|
| 4723 | - } |
|
| 4718 | + if (!$fichier |
|
| 4719 | + or !file_exists($fichier) |
|
| 4720 | + or !$m = filemtime($fichier) |
|
| 4721 | + ) { |
|
| 4722 | + return $fichier; |
|
| 4723 | + } |
|
| 4724 | 4724 | |
| 4725 | - return "$fichier?$m"; |
|
| 4725 | + return "$fichier?$m"; |
|
| 4726 | 4726 | } |
| 4727 | 4727 | |
| 4728 | 4728 | /** |
@@ -4732,11 +4732,11 @@ discard block |
||
| 4732 | 4732 | * @return string |
| 4733 | 4733 | */ |
| 4734 | 4734 | function supprimer_timestamp($url) { |
| 4735 | - if (strpos($url, "?") === false) { |
|
| 4736 | - return $url; |
|
| 4737 | - } |
|
| 4735 | + if (strpos($url, "?") === false) { |
|
| 4736 | + return $url; |
|
| 4737 | + } |
|
| 4738 | 4738 | |
| 4739 | - return preg_replace(",\?[[:digit:]]+$,", "", $url); |
|
| 4739 | + return preg_replace(",\?[[:digit:]]+$,", "", $url); |
|
| 4740 | 4740 | } |
| 4741 | 4741 | |
| 4742 | 4742 | /** |
@@ -4751,9 +4751,9 @@ discard block |
||
| 4751 | 4751 | * @return string |
| 4752 | 4752 | */ |
| 4753 | 4753 | function filtre_nettoyer_titre_email_dist($titre) { |
| 4754 | - include_spip('inc/envoyer_mail'); |
|
| 4754 | + include_spip('inc/envoyer_mail'); |
|
| 4755 | 4755 | |
| 4756 | - return nettoyer_titre_email($titre); |
|
| 4756 | + return nettoyer_titre_email($titre); |
|
| 4757 | 4757 | } |
| 4758 | 4758 | |
| 4759 | 4759 | /** |
@@ -4775,19 +4775,19 @@ discard block |
||
| 4775 | 4775 | * @return string |
| 4776 | 4776 | */ |
| 4777 | 4777 | function filtre_chercher_rubrique_dist( |
| 4778 | - $titre, |
|
| 4779 | - $id_objet, |
|
| 4780 | - $id_parent, |
|
| 4781 | - $objet, |
|
| 4782 | - $id_secteur, |
|
| 4783 | - $restreint, |
|
| 4784 | - $actionable = false, |
|
| 4785 | - $retour_sans_cadre = false |
|
| 4778 | + $titre, |
|
| 4779 | + $id_objet, |
|
| 4780 | + $id_parent, |
|
| 4781 | + $objet, |
|
| 4782 | + $id_secteur, |
|
| 4783 | + $restreint, |
|
| 4784 | + $actionable = false, |
|
| 4785 | + $retour_sans_cadre = false |
|
| 4786 | 4786 | ) { |
| 4787 | - include_spip('inc/filtres_ecrire'); |
|
| 4787 | + include_spip('inc/filtres_ecrire'); |
|
| 4788 | 4788 | |
| 4789 | - return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable, |
|
| 4790 | - $retour_sans_cadre); |
|
| 4789 | + return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable, |
|
| 4790 | + $retour_sans_cadre); |
|
| 4791 | 4791 | } |
| 4792 | 4792 | |
| 4793 | 4793 | /** |
@@ -4816,56 +4816,56 @@ discard block |
||
| 4816 | 4816 | * Chaîne vide si l'accès est autorisé |
| 4817 | 4817 | */ |
| 4818 | 4818 | function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) { |
| 4819 | - if ($ok) { |
|
| 4820 | - return ''; |
|
| 4821 | - } |
|
| 4822 | - |
|
| 4823 | - // Vider tous les tampons |
|
| 4824 | - $level = @ob_get_level(); |
|
| 4825 | - while ($level--) { |
|
| 4826 | - @ob_end_clean(); |
|
| 4827 | - } |
|
| 4828 | - |
|
| 4829 | - include_spip('inc/headers'); |
|
| 4830 | - |
|
| 4831 | - // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut) |
|
| 4832 | - if ($url) { |
|
| 4833 | - redirige_par_entete($url, '', $statut); |
|
| 4834 | - } |
|
| 4835 | - |
|
| 4836 | - // ecriture simplifiee avec message en 3eme argument (= statut 403) |
|
| 4837 | - if (!is_numeric($statut) and is_null($message)) { |
|
| 4838 | - $message = $statut; |
|
| 4839 | - $statut = 0; |
|
| 4840 | - } |
|
| 4841 | - if (!$message) { |
|
| 4842 | - $message = ''; |
|
| 4843 | - } |
|
| 4844 | - $statut = intval($statut); |
|
| 4845 | - |
|
| 4846 | - // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404 |
|
| 4847 | - if (test_espace_prive()) { |
|
| 4848 | - if (!$statut or !in_array($statut, array(404, 403))) { |
|
| 4849 | - $statut = 403; |
|
| 4850 | - } |
|
| 4851 | - http_status(403); |
|
| 4852 | - $echec = charger_fonction('403', 'exec'); |
|
| 4853 | - $echec($message); |
|
| 4854 | - } else { |
|
| 4855 | - // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement |
|
| 4856 | - if (!$statut) { |
|
| 4857 | - $statut = 404; |
|
| 4858 | - } |
|
| 4859 | - // Dans tous les cas on modifie l'entité avec ce qui est demandé |
|
| 4860 | - http_status($statut); |
|
| 4861 | - // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom |
|
| 4862 | - if ($statut >= 400) { |
|
| 4863 | - echo recuperer_fond("$statut", array('erreur' => $message)); |
|
| 4864 | - } |
|
| 4865 | - } |
|
| 4866 | - |
|
| 4867 | - |
|
| 4868 | - exit; |
|
| 4819 | + if ($ok) { |
|
| 4820 | + return ''; |
|
| 4821 | + } |
|
| 4822 | + |
|
| 4823 | + // Vider tous les tampons |
|
| 4824 | + $level = @ob_get_level(); |
|
| 4825 | + while ($level--) { |
|
| 4826 | + @ob_end_clean(); |
|
| 4827 | + } |
|
| 4828 | + |
|
| 4829 | + include_spip('inc/headers'); |
|
| 4830 | + |
|
| 4831 | + // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut) |
|
| 4832 | + if ($url) { |
|
| 4833 | + redirige_par_entete($url, '', $statut); |
|
| 4834 | + } |
|
| 4835 | + |
|
| 4836 | + // ecriture simplifiee avec message en 3eme argument (= statut 403) |
|
| 4837 | + if (!is_numeric($statut) and is_null($message)) { |
|
| 4838 | + $message = $statut; |
|
| 4839 | + $statut = 0; |
|
| 4840 | + } |
|
| 4841 | + if (!$message) { |
|
| 4842 | + $message = ''; |
|
| 4843 | + } |
|
| 4844 | + $statut = intval($statut); |
|
| 4845 | + |
|
| 4846 | + // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404 |
|
| 4847 | + if (test_espace_prive()) { |
|
| 4848 | + if (!$statut or !in_array($statut, array(404, 403))) { |
|
| 4849 | + $statut = 403; |
|
| 4850 | + } |
|
| 4851 | + http_status(403); |
|
| 4852 | + $echec = charger_fonction('403', 'exec'); |
|
| 4853 | + $echec($message); |
|
| 4854 | + } else { |
|
| 4855 | + // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement |
|
| 4856 | + if (!$statut) { |
|
| 4857 | + $statut = 404; |
|
| 4858 | + } |
|
| 4859 | + // Dans tous les cas on modifie l'entité avec ce qui est demandé |
|
| 4860 | + http_status($statut); |
|
| 4861 | + // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom |
|
| 4862 | + if ($statut >= 400) { |
|
| 4863 | + echo recuperer_fond("$statut", array('erreur' => $message)); |
|
| 4864 | + } |
|
| 4865 | + } |
|
| 4866 | + |
|
| 4867 | + |
|
| 4868 | + exit; |
|
| 4869 | 4869 | } |
| 4870 | 4870 | |
| 4871 | 4871 | /** |
@@ -4876,9 +4876,9 @@ discard block |
||
| 4876 | 4876 | * @return string |
| 4877 | 4877 | */ |
| 4878 | 4878 | function filtre_compacte_dist($source, $format = null) { |
| 4879 | - if (function_exists('compacte')) { |
|
| 4880 | - return compacte($source, $format); |
|
| 4881 | - } |
|
| 4879 | + if (function_exists('compacte')) { |
|
| 4880 | + return compacte($source, $format); |
|
| 4881 | + } |
|
| 4882 | 4882 | |
| 4883 | - return $source; |
|
| 4883 | + return $source; |
|
| 4884 | 4884 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | return $f; |
| 94 | 94 | } |
| 95 | - foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) { |
|
| 95 | + foreach (array('filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc) as $f) { |
|
| 96 | 96 | trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
| 97 | 97 | // fonction ou name\space\fonction |
| 98 | 98 | if (is_callable($f)) { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | function spip_version() { |
| 160 | 160 | $version = $GLOBALS['spip_version_affichee']; |
| 161 | 161 | if ($svn_revision = version_svn_courante(_DIR_RACINE)) { |
| 162 | - $version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']'; |
|
| 162 | + $version .= ($svn_revision < 0 ? ' SVN' : '').' ['.abs($svn_revision).']'; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | return $version; |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // version installee par paquet ZIP |
| 189 | - if (lire_fichier($dir . '/svn.revision', $c) |
|
| 189 | + if (lire_fichier($dir.'/svn.revision', $c) |
|
| 190 | 190 | and preg_match(',Revision: (\d+),', $c, $d) |
| 191 | 191 | ) { |
| 192 | 192 | return intval($d[1]); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // version installee par SVN |
| 196 | - if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) { |
|
| 197 | - $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 196 | + if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) { |
|
| 197 | + $db = new SQLite3($dir.'/.svn/wc.db'); |
|
| 198 | 198 | $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
| 199 | 199 | if ($result) { |
| 200 | 200 | $row = $result->fetchArray(); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | return -$row['changed_revision']; |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | - } else if (lire_fichier($dir . '/.svn/entries', $c) |
|
| 205 | + } else if (lire_fichier($dir.'/.svn/entries', $c) |
|
| 206 | 206 | and ( |
| 207 | 207 | (preg_match_all( |
| 208 | 208 | ',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER) |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images |
| 224 | 224 | // et laisser passer les fonctions personnelles baptisees image_... |
| 225 | -$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php'; |
|
| 226 | -$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php'; |
|
| 227 | -$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php'; |
|
| 228 | -$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php'; |
|
| 229 | -$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php'; |
|
| 225 | +$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php'; |
|
| 226 | +$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php'; |
|
| 227 | +$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php'; |
|
| 228 | +$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php'; |
|
| 229 | +$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php'; |
|
| 230 | 230 | |
| 231 | 231 | $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php'; |
| 232 | 232 | $GLOBALS['spip_matrice']['couleur_foncer'] = 'inc/filtres_images_mini.php'; |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | function filtre_debug($val, $key = null) { |
| 374 | 374 | $debug = ( |
| 375 | - is_null($key) ? '' : (var_export($key, true) . " = ") |
|
| 376 | - ) . var_export($val, true); |
|
| 375 | + is_null($key) ? '' : (var_export($key, true)." = ") |
|
| 376 | + ).var_export($val, true); |
|
| 377 | 377 | |
| 378 | 378 | include_spip('inc/autoriser'); |
| 379 | 379 | if (autoriser('webmestre')) { |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
| 462 | 462 | $srcover = $match[1]; |
| 463 | 463 | array_shift($args); |
| 464 | - array_unshift($args, "<img src='" . $match[1] . "' />"); |
|
| 464 | + array_unshift($args, "<img src='".$match[1]."' />"); |
|
| 465 | 465 | $srcover_filter = call_user_func_array($filtre, $args); |
| 466 | 466 | $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
| 467 | 467 | $reduit = str_replace($srcover, $srcover_filter, $reduit); |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | // " -> " et tout ce genre de choses |
| 812 | 812 | $u = $GLOBALS['meta']['pcre_u']; |
| 813 | 813 | $texte = str_replace(" ", " ", $texte); |
| 814 | - $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte); |
|
| 814 | + $texte = preg_replace('/\s{2,}/S'.$u, " ", $texte); |
|
| 815 | 815 | // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
| 816 | 816 | $texte = entites_html($texte, false, false); |
| 817 | 817 | // mais bien echapper les double quotes ! |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | **/ |
| 872 | 872 | function supprimer_numero($texte) { |
| 873 | 873 | return preg_replace( |
| 874 | - ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 874 | + ",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S", |
|
| 875 | 875 | "", $texte); |
| 876 | 876 | } |
| 877 | 877 | |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | **/ |
| 897 | 897 | function recuperer_numero($texte) { |
| 898 | 898 | if (preg_match( |
| 899 | - ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 899 | + ",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S", |
|
| 900 | 900 | $texte, $regs)) { |
| 901 | 901 | return strval($regs[1]); |
| 902 | 902 | } else { |
@@ -981,8 +981,8 @@ discard block |
||
| 981 | 981 | **/ |
| 982 | 982 | function textebrut($texte) { |
| 983 | 983 | $u = $GLOBALS['meta']['pcre_u']; |
| 984 | - $texte = preg_replace('/\s+/S' . $u, " ", $texte); |
|
| 985 | - $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte); |
|
| 984 | + $texte = preg_replace('/\s+/S'.$u, " ", $texte); |
|
| 985 | + $texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte); |
|
| 986 | 986 | $texte = preg_replace("/^\n+/", "", $texte); |
| 987 | 987 | $texte = preg_replace("/\n+$/", "", $texte); |
| 988 | 988 | $texte = preg_replace("/\n +/", "\n", $texte); |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
| 1011 | 1011 | $texte, $liens, PREG_PATTERN_ORDER)) { |
| 1012 | 1012 | foreach ($liens[0] as $a) { |
| 1013 | - $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1013 | + $rel = 'noopener noreferrer '.extraire_attribut($a, 'rel'); |
|
| 1014 | 1014 | $ablank = inserer_attribut($a, 'rel', $rel); |
| 1015 | 1015 | $ablank = inserer_attribut($ablank, 'target', '_blank'); |
| 1016 | 1016 | $texte = str_replace($a, $ablank, $texte); |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | foreach ($regs[0] as $a) { |
| 1036 | 1036 | $rel = extraire_attribut($a, "rel"); |
| 1037 | 1037 | if (strpos($rel, "nofollow") === false) { |
| 1038 | - $rel = "nofollow" . ($rel ? " $rel" : ""); |
|
| 1038 | + $rel = "nofollow".($rel ? " $rel" : ""); |
|
| 1039 | 1039 | $anofollow = inserer_attribut($a, "rel", $rel); |
| 1040 | 1040 | $texte = str_replace($a, $anofollow, $texte); |
| 1041 | 1041 | } |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | $u = $GLOBALS['meta']['pcre_u']; |
| 1065 | 1065 | $texte = preg_replace("@</p>@iS", "\n", $texte); |
| 1066 | 1066 | $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte); |
| 1067 | - $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte); |
|
| 1067 | + $texte = preg_replace("@^\s*<br />@S".$u, "", $texte); |
|
| 1068 | 1068 | |
| 1069 | 1069 | return $texte; |
| 1070 | 1070 | } |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | return $texte; |
| 1095 | 1095 | } |
| 1096 | 1096 | include_spip('inc/texte'); |
| 1097 | - $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1097 | + $tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ? |
|
| 1098 | 1098 | 'div' : 'span'; |
| 1099 | 1099 | |
| 1100 | 1100 | return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | function attribut_html($texte, $textebrut = true) { |
| 1204 | 1204 | $u = $GLOBALS['meta']['pcre_u']; |
| 1205 | 1205 | if ($textebrut) { |
| 1206 | - $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte)); |
|
| 1206 | + $texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte)); |
|
| 1207 | 1207 | } |
| 1208 | 1208 | $texte = texte_backend($texte); |
| 1209 | 1209 | $texte = str_replace(array("'", '"'), array(''', '"'), $texte); |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | # un message pour abs_url |
| 1233 | 1233 | $GLOBALS['mode_abs_url'] = 'url'; |
| 1234 | 1234 | $url = trim($url); |
| 1235 | - $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1235 | + $r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS'; |
|
| 1236 | 1236 | |
| 1237 | 1237 | return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
| 1238 | 1238 | } |
@@ -1434,14 +1434,14 @@ discard block |
||
| 1434 | 1434 | if (strpos($texte, "<") !== false) { |
| 1435 | 1435 | include_spip('inc/lien'); |
| 1436 | 1436 | if (defined('_PREG_MODELE')) { |
| 1437 | - $preg_modeles = "@" . _PREG_MODELE . "@imsS"; |
|
| 1437 | + $preg_modeles = "@"._PREG_MODELE."@imsS"; |
|
| 1438 | 1438 | $texte = echappe_html($texte, '', true, $preg_modeles); |
| 1439 | 1439 | } |
| 1440 | 1440 | } |
| 1441 | 1441 | |
| 1442 | 1442 | $debut = ''; |
| 1443 | 1443 | $suite = $texte; |
| 1444 | - while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1444 | + while ($t = strpos('-'.$suite, "\n", 1)) { |
|
| 1445 | 1445 | $debut .= substr($suite, 0, $t - 1); |
| 1446 | 1446 | $suite = substr($suite, $t); |
| 1447 | 1447 | $car = substr($suite, 0, 1); |
@@ -1458,11 +1458,11 @@ discard block |
||
| 1458 | 1458 | $suite = substr($suite, strlen($regs[0])); |
| 1459 | 1459 | } |
| 1460 | 1460 | } |
| 1461 | - $texte = $debut . $suite; |
|
| 1461 | + $texte = $debut.$suite; |
|
| 1462 | 1462 | |
| 1463 | 1463 | $texte = echappe_retour($texte); |
| 1464 | 1464 | |
| 1465 | - return $texte . $fin; |
|
| 1465 | + return $texte.$fin; |
|
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | |
@@ -1523,7 +1523,7 @@ discard block |
||
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | foreach ($regs as $reg) { |
| 1526 | - $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1526 | + $cle = ($reg[1] ? $reg[1].':' : '').$reg[2]; |
|
| 1527 | 1527 | $desc = $traduire($cle, $lang, true); |
| 1528 | 1528 | $l = $desc->langue; |
| 1529 | 1529 | // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
@@ -1636,7 +1636,7 @@ discard block |
||
| 1636 | 1636 | // il ne faut pas echapper en div si propre produit un seul paragraphe |
| 1637 | 1637 | include_spip('inc/texte'); |
| 1638 | 1638 | $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad)); |
| 1639 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1639 | + $mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1640 | 1640 | $trad = code_echappement($trad, 'multi', false, $mode); |
| 1641 | 1641 | $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
| 1642 | 1642 | if (lang_dir($l) !== lang_dir($lang)) { |
@@ -1829,7 +1829,7 @@ discard block |
||
| 1829 | 1829 | if (is_array($balise)) { |
| 1830 | 1830 | array_walk( |
| 1831 | 1831 | $balise, |
| 1832 | - function(&$a, $key, $t){ |
|
| 1832 | + function(&$a, $key, $t) { |
|
| 1833 | 1833 | $a = extraire_attribut($a, $t); |
| 1834 | 1834 | }, |
| 1835 | 1835 | $attribut |
@@ -1916,14 +1916,14 @@ discard block |
||
| 1916 | 1916 | |
| 1917 | 1917 | if ($old !== null) { |
| 1918 | 1918 | // Remplacer l'ancien attribut du meme nom |
| 1919 | - $balise = $r[1] . $insert . $r[5]; |
|
| 1919 | + $balise = $r[1].$insert.$r[5]; |
|
| 1920 | 1920 | } else { |
| 1921 | 1921 | // preferer une balise " />" (comme <img />) |
| 1922 | 1922 | if (preg_match(',/>,', $balise)) { |
| 1923 | - $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1); |
|
| 1923 | + $balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1); |
|
| 1924 | 1924 | } // sinon une balise <a ...> ... </a> |
| 1925 | 1925 | else { |
| 1926 | - $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1); |
|
| 1926 | + $balise = preg_replace(",\s?>,S", $insert.">", $balise, 1); |
|
| 1927 | 1927 | } |
| 1928 | 1928 | } |
| 1929 | 1929 | |
@@ -1965,8 +1965,8 @@ discard block |
||
| 1965 | 1965 | // |
| 1966 | 1966 | // Quelques fonctions de calcul arithmetique |
| 1967 | 1967 | // |
| 1968 | -function floatstr($a) { return str_replace(',','.',(string)floatval($a)); } |
|
| 1969 | -function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); } |
|
| 1968 | +function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); } |
|
| 1969 | +function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); } |
|
| 1970 | 1970 | |
| 1971 | 1971 | /** |
| 1972 | 1972 | * Additionne 2 nombres |
@@ -1986,7 +1986,7 @@ discard block |
||
| 1986 | 1986 | function plus($a, $b) { |
| 1987 | 1987 | return $a + $b; |
| 1988 | 1988 | } |
| 1989 | -function strplus($a, $b) {return strize('plus', $a, $b);} |
|
| 1989 | +function strplus($a, $b) {return strize('plus', $a, $b); } |
|
| 1990 | 1990 | /** |
| 1991 | 1991 | * Soustrait 2 nombres |
| 1992 | 1992 | * |
@@ -2005,7 +2005,7 @@ discard block |
||
| 2005 | 2005 | function moins($a, $b) { |
| 2006 | 2006 | return $a - $b; |
| 2007 | 2007 | } |
| 2008 | -function strmoins($a, $b) {return strize('moins', $a, $b);} |
|
| 2008 | +function strmoins($a, $b) {return strize('moins', $a, $b); } |
|
| 2009 | 2009 | |
| 2010 | 2010 | /** |
| 2011 | 2011 | * Multiplie 2 nombres |
@@ -2026,7 +2026,7 @@ discard block |
||
| 2026 | 2026 | function mult($a, $b) { |
| 2027 | 2027 | return $a * $b; |
| 2028 | 2028 | } |
| 2029 | -function strmult($a, $b) {return strize('mult', $a, $b);} |
|
| 2029 | +function strmult($a, $b) {return strize('mult', $a, $b); } |
|
| 2030 | 2030 | |
| 2031 | 2031 | /** |
| 2032 | 2032 | * Divise 2 nombres |
@@ -2047,7 +2047,7 @@ discard block |
||
| 2047 | 2047 | function div($a, $b) { |
| 2048 | 2048 | return $b ? $a / $b : 0; |
| 2049 | 2049 | } |
| 2050 | -function strdiv($a, $b) {return strize('div', $a, $b);} |
|
| 2050 | +function strdiv($a, $b) {return strize('div', $a, $b); } |
|
| 2051 | 2051 | |
| 2052 | 2052 | /** |
| 2053 | 2053 | * Retourne le modulo 2 nombres |
@@ -2088,13 +2088,13 @@ discard block |
||
| 2088 | 2088 | if (!defined('_TAGS_NOM_AUTEUR')) { |
| 2089 | 2089 | define('_TAGS_NOM_AUTEUR', ''); |
| 2090 | 2090 | } |
| 2091 | - $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2091 | + $tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR)); |
|
| 2092 | 2092 | foreach ($tags_acceptes as $tag) { |
| 2093 | 2093 | if (strlen($tag)) { |
| 2094 | - $remp1[] = '<' . trim($tag) . '>'; |
|
| 2095 | - $remp1[] = '</' . trim($tag) . '>'; |
|
| 2096 | - $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2097 | - $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2094 | + $remp1[] = '<'.trim($tag).'>'; |
|
| 2095 | + $remp1[] = '</'.trim($tag).'>'; |
|
| 2096 | + $remp2[] = '\x60'.trim($tag).'\x61'; |
|
| 2097 | + $remp2[] = '\x60/'.trim($tag).'\x61'; |
|
| 2098 | 2098 | } |
| 2099 | 2099 | } |
| 2100 | 2100 | $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
@@ -2157,7 +2157,7 @@ discard block |
||
| 2157 | 2157 | $s[] = preg_replace(',>[^<]+</a>,S', |
| 2158 | 2158 | '>' |
| 2159 | 2159 | . http_img_pack('attachment-16.png', $t, |
| 2160 | - 'title="' . attribut_html($t) . '"') |
|
| 2160 | + 'title="'.attribut_html($t).'"') |
|
| 2161 | 2161 | . '</a>', $tag); |
| 2162 | 2162 | } |
| 2163 | 2163 | } |
@@ -2218,10 +2218,10 @@ discard block |
||
| 2218 | 2218 | $fichier = basename($url); |
| 2219 | 2219 | |
| 2220 | 2220 | return '<a rel="enclosure"' |
| 2221 | - . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2222 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2223 | - . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2224 | - . '>' . $fichier . '</a>'; |
|
| 2221 | + . ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '') |
|
| 2222 | + . ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '') |
|
| 2223 | + . ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '') |
|
| 2224 | + . '>'.$fichier.'</a>'; |
|
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | 2227 | /** |
@@ -2249,9 +2249,9 @@ discard block |
||
| 2249 | 2249 | } # vieux data |
| 2250 | 2250 | $fichier = basename($url); |
| 2251 | 2251 | $enclosures[] = '<enclosure' |
| 2252 | - . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2253 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2254 | - . ($length ? ' length="' . $length . '"' : '') |
|
| 2252 | + . ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '') |
|
| 2253 | + . ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '') |
|
| 2254 | + . ($length ? ' length="'.$length.'"' : '') |
|
| 2255 | 2255 | . ' />'; |
| 2256 | 2256 | } |
| 2257 | 2257 | } |
@@ -2277,7 +2277,7 @@ discard block |
||
| 2277 | 2277 | if (extraire_attribut($e, rel) == 'tag') { |
| 2278 | 2278 | $subjects .= '<dc:subject>' |
| 2279 | 2279 | . texte_backend(textebrut($e)) |
| 2280 | - . '</dc:subject>' . "\n"; |
|
| 2280 | + . '</dc:subject>'."\n"; |
|
| 2281 | 2281 | } |
| 2282 | 2282 | } |
| 2283 | 2283 | |
@@ -2313,7 +2313,7 @@ discard block |
||
| 2313 | 2313 | if (is_array($texte)) { |
| 2314 | 2314 | array_walk( |
| 2315 | 2315 | $texte, |
| 2316 | - function(&$a, $key, $t){ |
|
| 2316 | + function(&$a, $key, $t) { |
|
| 2317 | 2317 | $a = extraire_balise($a, $t); |
| 2318 | 2318 | }, |
| 2319 | 2319 | $tag |
@@ -2357,7 +2357,7 @@ discard block |
||
| 2357 | 2357 | if (is_array($texte)) { |
| 2358 | 2358 | array_walk( |
| 2359 | 2359 | $texte, |
| 2360 | - function(&$a, $key, $t){ |
|
| 2360 | + function(&$a, $key, $t) { |
|
| 2361 | 2361 | $a = extraire_balises($a, $t); |
| 2362 | 2362 | }, |
| 2363 | 2363 | $tag |
@@ -2483,7 +2483,7 @@ discard block |
||
| 2483 | 2483 | if ($fond != '404') { |
| 2484 | 2484 | $contexte = array_shift($p); |
| 2485 | 2485 | $contexte['page'] = $fond; |
| 2486 | - $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2486 | + $action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2487 | 2487 | } |
| 2488 | 2488 | } |
| 2489 | 2489 | // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
@@ -2538,9 +2538,9 @@ discard block |
||
| 2538 | 2538 | . '"' |
| 2539 | 2539 | . (is_null($val) |
| 2540 | 2540 | ? '' |
| 2541 | - : ' value="' . entites_html($val) . '"' |
|
| 2541 | + : ' value="'.entites_html($val).'"' |
|
| 2542 | 2542 | ) |
| 2543 | - . ' type="hidden"' . "\n/>"; |
|
| 2543 | + . ' type="hidden"'."\n/>"; |
|
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | 2546 | return join("", $hidden); |
@@ -2703,12 +2703,12 @@ discard block |
||
| 2703 | 2703 | if ($pas < 1) { |
| 2704 | 2704 | return ''; |
| 2705 | 2705 | } |
| 2706 | - $ancre = 'pagination' . $nom; // #pagination_articles |
|
| 2707 | - $debut = 'debut' . $nom; // 'debut_articles' |
|
| 2706 | + $ancre = 'pagination'.$nom; // #pagination_articles |
|
| 2707 | + $debut = 'debut'.$nom; // 'debut_articles' |
|
| 2708 | 2708 | |
| 2709 | 2709 | // n'afficher l'ancre qu'une fois |
| 2710 | 2710 | if (!isset($ancres[$ancre])) { |
| 2711 | - $bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>"; |
|
| 2711 | + $bloc_ancre = $ancres[$ancre] = "<a name='".$ancre."' id='".$ancre."'></a>"; |
|
| 2712 | 2712 | } else { |
| 2713 | 2713 | $bloc_ancre = ''; |
| 2714 | 2714 | } |
@@ -2738,7 +2738,7 @@ discard block |
||
| 2738 | 2738 | } |
| 2739 | 2739 | |
| 2740 | 2740 | if ($modele) { |
| 2741 | - $modele = '_' . $modele; |
|
| 2741 | + $modele = '_'.$modele; |
|
| 2742 | 2742 | } |
| 2743 | 2743 | |
| 2744 | 2744 | return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect); |
@@ -2763,7 +2763,7 @@ discard block |
||
| 2763 | 2763 | return preg_replace_callback( |
| 2764 | 2764 | ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
| 2765 | 2765 | function($x) use ($path) { |
| 2766 | - return "url('" . suivre_lien($path, $x[1]) . "')"; |
|
| 2766 | + return "url('".suivre_lien($path, $x[1])."')"; |
|
| 2767 | 2767 | }, |
| 2768 | 2768 | $contenu |
| 2769 | 2769 | ); |
@@ -2825,14 +2825,14 @@ discard block |
||
| 2825 | 2825 | ) { |
| 2826 | 2826 | $distant = true; |
| 2827 | 2827 | $cssf = parse_url($css); |
| 2828 | - $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : ""); |
|
| 2828 | + $cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : ""); |
|
| 2829 | 2829 | $cssf = preg_replace(',[?:&=],', "_", $cssf); |
| 2830 | 2830 | } else { |
| 2831 | 2831 | $distant = false; |
| 2832 | 2832 | $cssf = $css; |
| 2833 | 2833 | // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
| 2834 | 2834 | //propose (rien a faire dans ce cas) |
| 2835 | - $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 2835 | + $f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css); |
|
| 2836 | 2836 | if (@file_exists($f)) { |
| 2837 | 2837 | return $f; |
| 2838 | 2838 | } |
@@ -2842,7 +2842,7 @@ discard block |
||
| 2842 | 2842 | $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
| 2843 | 2843 | $f = $dir_var |
| 2844 | 2844 | . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
| 2845 | - . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 2845 | + . '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css'; |
|
| 2846 | 2846 | |
| 2847 | 2847 | // la css peut etre distante (url absolue !) |
| 2848 | 2848 | if ($distant) { |
@@ -2887,8 +2887,8 @@ discard block |
||
| 2887 | 2887 | } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
| 2888 | 2888 | elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
| 2889 | 2889 | $css_direction = substr($css_direction, strlen($dir_var)); |
| 2890 | - $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction; |
|
| 2891 | - $css_direction = "/@@@@@@/" . $css_direction; |
|
| 2890 | + $src_faux_abs["/@@@@@@/".$css_direction] = $css_direction; |
|
| 2891 | + $css_direction = "/@@@@@@/".$css_direction; |
|
| 2892 | 2892 | } |
| 2893 | 2893 | $src[] = $regs[0][$k]; |
| 2894 | 2894 | $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
@@ -2937,7 +2937,7 @@ discard block |
||
| 2937 | 2937 | |
| 2938 | 2938 | $f = basename($css, '.css'); |
| 2939 | 2939 | $f = sous_repertoire(_DIR_VAR, 'cache-css') |
| 2940 | - . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 2940 | + . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f) |
|
| 2941 | 2941 | . '.css'; |
| 2942 | 2942 | |
| 2943 | 2943 | if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
@@ -2946,7 +2946,7 @@ discard block |
||
| 2946 | 2946 | |
| 2947 | 2947 | if ($url_absolue_css == $css) { |
| 2948 | 2948 | if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
| 2949 | - or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 2949 | + or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu) |
|
| 2950 | 2950 | ) { |
| 2951 | 2951 | include_spip('inc/distant'); |
| 2952 | 2952 | if (!$contenu = recuperer_page($css)) { |
@@ -3056,7 +3056,7 @@ discard block |
||
| 3056 | 3056 | $expression = str_replace("\/", "/", $expression); |
| 3057 | 3057 | $expression = str_replace("/", "\/", $expression); |
| 3058 | 3058 | |
| 3059 | - if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) { |
|
| 3059 | + if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) { |
|
| 3060 | 3060 | if (isset($r[$capte])) { |
| 3061 | 3061 | return $r[$capte]; |
| 3062 | 3062 | } else { |
@@ -3094,7 +3094,7 @@ discard block |
||
| 3094 | 3094 | $expression = str_replace("\/", "/", $expression); |
| 3095 | 3095 | $expression = str_replace("/", "\/", $expression); |
| 3096 | 3096 | |
| 3097 | - return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3097 | + return preg_replace('/'.$expression.'/'.$modif, $replace, $texte); |
|
| 3098 | 3098 | } |
| 3099 | 3099 | |
| 3100 | 3100 | |
@@ -3113,7 +3113,7 @@ discard block |
||
| 3113 | 3113 | function traiter_doublons_documents(&$doublons, $letexte) { |
| 3114 | 3114 | |
| 3115 | 3115 | // Verifier dans le texte & les notes (pas beau, helas) |
| 3116 | - $t = $letexte . $GLOBALS['les_notes']; |
|
| 3116 | + $t = $letexte.$GLOBALS['les_notes']; |
|
| 3117 | 3117 | |
| 3118 | 3118 | if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
| 3119 | 3119 | and preg_match_all( |
@@ -3123,7 +3123,7 @@ discard block |
||
| 3123 | 3123 | if (!isset($doublons['documents'])) { |
| 3124 | 3124 | $doublons['documents'] = ""; |
| 3125 | 3125 | } |
| 3126 | - $doublons['documents'] .= "," . join(',', $matches[1]); |
|
| 3126 | + $doublons['documents'] .= ",".join(',', $matches[1]); |
|
| 3127 | 3127 | } |
| 3128 | 3128 | |
| 3129 | 3129 | return $letexte; |
@@ -3180,7 +3180,7 @@ discard block |
||
| 3180 | 3180 | if ($env) { |
| 3181 | 3181 | foreach ($env as $i => $j) { |
| 3182 | 3182 | if (is_string($j) and !in_array($i, $ignore_params)) { |
| 3183 | - $texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />"; |
|
| 3183 | + $texte .= "<param name='".$i."'\n\tvalue='".$j."' />"; |
|
| 3184 | 3184 | } |
| 3185 | 3185 | } |
| 3186 | 3186 | } |
@@ -3219,7 +3219,7 @@ discard block |
||
| 3219 | 3219 | if ($env) { |
| 3220 | 3220 | foreach ($env as $i => $j) { |
| 3221 | 3221 | if (is_string($j) and !in_array($i, $ignore_params)) { |
| 3222 | - $texte .= $i . "='" . $j . "' "; |
|
| 3222 | + $texte .= $i."='".$j."' "; |
|
| 3223 | 3223 | } |
| 3224 | 3224 | } |
| 3225 | 3225 | } |
@@ -3305,13 +3305,13 @@ discard block |
||
| 3305 | 3305 | $img_file = chemin_image($img); |
| 3306 | 3306 | } |
| 3307 | 3307 | else { |
| 3308 | - if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){ |
|
| 3308 | + if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) { |
|
| 3309 | 3309 | // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
| 3310 | 3310 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 3311 | 3311 | if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
| 3312 | - and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg" |
|
| 3312 | + and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg" |
|
| 3313 | 3313 | and file_exists($variante_svg_generique)) { |
| 3314 | - if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) { |
|
| 3314 | + if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) { |
|
| 3315 | 3315 | $img_file = $variante_svg_size; |
| 3316 | 3316 | } |
| 3317 | 3317 | else { |
@@ -3333,12 +3333,12 @@ discard block |
||
| 3333 | 3333 | return ""; |
| 3334 | 3334 | } |
| 3335 | 3335 | } |
| 3336 | - $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3336 | + $atts .= " width='".$largeur."' height='".$hauteur."'"; |
|
| 3337 | 3337 | } |
| 3338 | 3338 | |
| 3339 | - return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'" |
|
| 3340 | - . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3341 | - . " " . ltrim($atts) |
|
| 3339 | + return "<img src='$img_file' alt='".attribut_html($alt ? $alt : $title)."'" |
|
| 3340 | + . ($title ? ' title="'.attribut_html($title).'"' : '') |
|
| 3341 | + . " ".ltrim($atts) |
|
| 3342 | 3342 | . " />"; |
| 3343 | 3343 | } |
| 3344 | 3344 | |
@@ -3350,7 +3350,7 @@ discard block |
||
| 3350 | 3350 | * @return string |
| 3351 | 3351 | */ |
| 3352 | 3352 | function http_style_background($img, $att = '') { |
| 3353 | - return " style='background" . ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";'"; |
|
| 3353 | + return " style='background".($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";'"; |
|
| 3354 | 3354 | } |
| 3355 | 3355 | |
| 3356 | 3356 | /** |
@@ -3365,7 +3365,7 @@ discard block |
||
| 3365 | 3365 | * Code HTML de la balise IMG |
| 3366 | 3366 | */ |
| 3367 | 3367 | function filtre_balise_img_dist($img, $alt = "", $class = "") { |
| 3368 | - return http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '', |
|
| 3368 | + return http_img_pack($img, $alt, $class ? " class='".attribut_html($class)."'" : '', '', |
|
| 3369 | 3369 | array('chemin_image' => false, 'utiliser_suffixe_size' => false)); |
| 3370 | 3370 | } |
| 3371 | 3371 | |
@@ -3397,11 +3397,11 @@ discard block |
||
| 3397 | 3397 | if ($class) { |
| 3398 | 3398 | $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
| 3399 | 3399 | } |
| 3400 | - if ($alt){ |
|
| 3400 | + if ($alt) { |
|
| 3401 | 3401 | $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
| 3402 | - $id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4); |
|
| 3402 | + $id = "img-svg-title-".substr(md5("$file:$svg:$alt"), 0, 4); |
|
| 3403 | 3403 | $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
| 3404 | - $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n"; |
|
| 3404 | + $title = "<title id=\"$id\">".entites_html($alt)."</title>\n"; |
|
| 3405 | 3405 | $balise_svg .= $title; |
| 3406 | 3406 | } |
| 3407 | 3407 | else { |
@@ -3435,7 +3435,7 @@ discard block |
||
| 3435 | 3435 | $texte = ''; |
| 3436 | 3436 | if (is_array($tableau)) { |
| 3437 | 3437 | foreach ($tableau as $k => $v) { |
| 3438 | - $res = recuperer_fond('modeles/' . $modele, |
|
| 3438 | + $res = recuperer_fond('modeles/'.$modele, |
|
| 3439 | 3439 | array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v))) |
| 3440 | 3440 | ); |
| 3441 | 3441 | $texte .= $res; |
@@ -3612,7 +3612,7 @@ discard block |
||
| 3612 | 3612 | } |
| 3613 | 3613 | |
| 3614 | 3614 | $c = serialize($c); |
| 3615 | - $cle = calculer_cle_action($form . $c); |
|
| 3615 | + $cle = calculer_cle_action($form.$c); |
|
| 3616 | 3616 | $c = "$cle:$c"; |
| 3617 | 3617 | |
| 3618 | 3618 | // on ne stocke pas les contextes dans des fichiers caches |
@@ -3662,15 +3662,15 @@ discard block |
||
| 3662 | 3662 | } |
| 3663 | 3663 | // toujours encoder l'url source dans le bloc ajax |
| 3664 | 3664 | $r = self(); |
| 3665 | - $r = ' data-origin="' . $r . '"'; |
|
| 3665 | + $r = ' data-origin="'.$r.'"'; |
|
| 3666 | 3666 | $class = 'ajaxbloc'; |
| 3667 | 3667 | if ($ajaxid and is_string($ajaxid)) { |
| 3668 | 3668 | // ajaxid est normalement conforme a un nom de classe css |
| 3669 | 3669 | // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
| 3670 | - $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 3670 | + $class .= ' ajax-id-'.entites_html($ajaxid); |
|
| 3671 | 3671 | } |
| 3672 | 3672 | |
| 3673 | - return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 3673 | + return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 3674 | 3674 | } |
| 3675 | 3675 | |
| 3676 | 3676 | /** |
@@ -3709,11 +3709,11 @@ discard block |
||
| 3709 | 3709 | // extraire la signature en debut de contexte |
| 3710 | 3710 | // et la verifier avant de deserializer |
| 3711 | 3711 | // format : signature:donneesserializees |
| 3712 | - if ($p = strpos($c,":")){ |
|
| 3713 | - $cle = substr($c,0,$p); |
|
| 3714 | - $c = substr($c,$p+1); |
|
| 3712 | + if ($p = strpos($c, ":")) { |
|
| 3713 | + $cle = substr($c, 0, $p); |
|
| 3714 | + $c = substr($c, $p + 1); |
|
| 3715 | 3715 | |
| 3716 | - if ($cle == calculer_cle_action($form . $c)) { |
|
| 3716 | + if ($cle == calculer_cle_action($form.$c)) { |
|
| 3717 | 3717 | $env = @unserialize($c); |
| 3718 | 3718 | return $env; |
| 3719 | 3719 | } |
@@ -3814,9 +3814,9 @@ discard block |
||
| 3814 | 3814 | } else { |
| 3815 | 3815 | $bal = 'a'; |
| 3816 | 3816 | $att = "href='$url'" |
| 3817 | - . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 3818 | - . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 3819 | - . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 3817 | + . ($title ? " title='".attribut_html($title)."'" : '') |
|
| 3818 | + . ($class ? " class='".attribut_html($class)."'" : '') |
|
| 3819 | + . ($rel ? " rel='".attribut_html($rel)."'" : '') |
|
| 3820 | 3820 | . $evt; |
| 3821 | 3821 | } |
| 3822 | 3822 | if ($libelle === null) { |
@@ -3890,7 +3890,7 @@ discard block |
||
| 3890 | 3890 | } |
| 3891 | 3891 | |
| 3892 | 3892 | // ajouter le type d'objet dans la class de l'icone |
| 3893 | - $class .= " " . substr(basename($fond), 0, -4); |
|
| 3893 | + $class .= " ".substr(basename($fond), 0, -4); |
|
| 3894 | 3894 | |
| 3895 | 3895 | $alt = attribut_html($texte); |
| 3896 | 3896 | $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
@@ -3915,7 +3915,7 @@ discard block |
||
| 3915 | 3915 | if ($fonction) { |
| 3916 | 3916 | // 2 images pour composer l'icone : le fond (article) en background, |
| 3917 | 3917 | // la fonction (new) en image |
| 3918 | - $icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n" . |
|
| 3918 | + $icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n". |
|
| 3919 | 3919 | http_style_background($fond)); |
| 3920 | 3920 | } else { |
| 3921 | 3921 | $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
@@ -4149,13 +4149,13 @@ discard block |
||
| 4149 | 4149 | $res = ""; |
| 4150 | 4150 | foreach ($boutons as $page => $detail) { |
| 4151 | 4151 | if ($detail->icone and strlen(trim($detail->icone))) { |
| 4152 | - $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}"; |
|
| 4152 | + $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}"; |
|
| 4153 | 4153 | } |
| 4154 | 4154 | $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones "); |
| 4155 | 4155 | if (is_array($detail->sousmenu)) { |
| 4156 | 4156 | foreach ($detail->sousmenu as $souspage => $sousdetail) { |
| 4157 | 4157 | if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
| 4158 | - $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}"; |
|
| 4158 | + $res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}"; |
|
| 4159 | 4159 | } |
| 4160 | 4160 | } |
| 4161 | 4161 | } |
@@ -4181,17 +4181,17 @@ discard block |
||
| 4181 | 4181 | */ |
| 4182 | 4182 | function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") { |
| 4183 | 4183 | if ($confirm) { |
| 4184 | - $confirm = "confirm(\"" . attribut_html($confirm) . "\")"; |
|
| 4184 | + $confirm = "confirm(\"".attribut_html($confirm)."\")"; |
|
| 4185 | 4185 | if ($callback) { |
| 4186 | 4186 | $callback = "$confirm?($callback):false"; |
| 4187 | 4187 | } else { |
| 4188 | 4188 | $callback = $confirm; |
| 4189 | 4189 | } |
| 4190 | 4190 | } |
| 4191 | - $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ""; |
|
| 4191 | + $onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : ""; |
|
| 4192 | 4192 | $title = $title ? " title='$title'" : ""; |
| 4193 | 4193 | |
| 4194 | - return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4194 | + return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url) |
|
| 4195 | 4195 | . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>"; |
| 4196 | 4196 | } |
| 4197 | 4197 | |
@@ -4330,14 +4330,14 @@ discard block |
||
| 4330 | 4330 | $champ_titre = ""; |
| 4331 | 4331 | if ($demande_titre) { |
| 4332 | 4332 | // si pas de titre declare mais champ titre, il sera peuple par le select * |
| 4333 | - $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4333 | + $champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : ''; |
|
| 4334 | 4334 | } |
| 4335 | 4335 | include_spip('base/abstract_sql'); |
| 4336 | 4336 | include_spip('base/connect_sql'); |
| 4337 | 4337 | $objets[$type_objet][$id_objet] = sql_fetsel( |
| 4338 | - '*' . $champ_titre, |
|
| 4338 | + '*'.$champ_titre, |
|
| 4339 | 4339 | $desc['table_sql'], |
| 4340 | - id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4340 | + id_table_objet($type_objet).' = '.intval($id_objet) |
|
| 4341 | 4341 | ); |
| 4342 | 4342 | } |
| 4343 | 4343 | |
@@ -4407,7 +4407,7 @@ discard block |
||
| 4407 | 4407 | return $texte; |
| 4408 | 4408 | } |
| 4409 | 4409 | |
| 4410 | - $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4410 | + $traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement); |
|
| 4411 | 4411 | |
| 4412 | 4412 | // Fournir $connect et $Pile[0] au traitement si besoin |
| 4413 | 4413 | $Pile = array(0 => $env); |
@@ -4441,7 +4441,7 @@ discard block |
||
| 4441 | 4441 | } |
| 4442 | 4442 | $url = generer_url_entite($id_objet, $objet, '', '', $connect); |
| 4443 | 4443 | |
| 4444 | - return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>"; |
|
| 4444 | + return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>"; |
|
| 4445 | 4445 | } |
| 4446 | 4446 | |
| 4447 | 4447 | |
@@ -4460,10 +4460,10 @@ discard block |
||
| 4460 | 4460 | function wrap($texte, $wrap) { |
| 4461 | 4461 | $balises = extraire_balises($wrap); |
| 4462 | 4462 | if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
| 4463 | - $texte = $wrap . $texte; |
|
| 4463 | + $texte = $wrap.$texte; |
|
| 4464 | 4464 | $regs = array_reverse($regs[1]); |
| 4465 | - $wrap = "</" . implode("></", $regs) . ">"; |
|
| 4466 | - $texte = $texte . $wrap; |
|
| 4465 | + $wrap = "</".implode("></", $regs).">"; |
|
| 4466 | + $texte = $texte.$wrap; |
|
| 4467 | 4467 | } |
| 4468 | 4468 | |
| 4469 | 4469 | return $texte; |
@@ -4494,7 +4494,7 @@ discard block |
||
| 4494 | 4494 | |
| 4495 | 4495 | // caster $u en array si besoin |
| 4496 | 4496 | if (is_object($u)) { |
| 4497 | - $u = (array)$u; |
|
| 4497 | + $u = (array) $u; |
|
| 4498 | 4498 | } |
| 4499 | 4499 | |
| 4500 | 4500 | if (is_array($u)) { |
@@ -4515,7 +4515,7 @@ discard block |
||
| 4515 | 4515 | // sinon on passe a la ligne et on indente |
| 4516 | 4516 | $i_str = str_pad("", $indent, "Â "); |
| 4517 | 4517 | foreach ($u as $k => $v) { |
| 4518 | - $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 4518 | + $out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2); |
|
| 4519 | 4519 | } |
| 4520 | 4520 | |
| 4521 | 4521 | return $out; |
@@ -4568,7 +4568,7 @@ discard block |
||
| 4568 | 4568 | * @return string |
| 4569 | 4569 | */ |
| 4570 | 4570 | function objet_icone($objet, $taille = 24) { |
| 4571 | - $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png"; |
|
| 4571 | + $icone = objet_info($objet, 'icone_objet')."-".$taille.".png"; |
|
| 4572 | 4572 | $icone = chemin_image($icone); |
| 4573 | 4573 | $balise_img = charger_filtre('balise_img'); |
| 4574 | 4574 | |
@@ -4592,12 +4592,12 @@ discard block |
||
| 4592 | 4592 | * @param array $options |
| 4593 | 4593 | * @return string |
| 4594 | 4594 | */ |
| 4595 | -function objet_T($objet, $chaine, $args = array(), $options = array()){ |
|
| 4596 | - $chaine = explode(':',$chaine); |
|
| 4597 | - if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) { |
|
| 4595 | +function objet_T($objet, $chaine, $args = array(), $options = array()) { |
|
| 4596 | + $chaine = explode(':', $chaine); |
|
| 4597 | + if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) { |
|
| 4598 | 4598 | return $t; |
| 4599 | 4599 | } |
| 4600 | - $chaine = implode(':',$chaine); |
|
| 4600 | + $chaine = implode(':', $chaine); |
|
| 4601 | 4601 | return _T($chaine, $args, $options); |
| 4602 | 4602 | } |
| 4603 | 4603 | |
@@ -4657,11 +4657,11 @@ discard block |
||
| 4657 | 4657 | $cache = recuperer_fond($fond, $contexte, $options, $connect); |
| 4658 | 4658 | |
| 4659 | 4659 | // calculer le nom de la css |
| 4660 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 4660 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension); |
|
| 4661 | 4661 | $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond)); |
| 4662 | 4662 | $contexte_implicite = calculer_contexte_implicite(); |
| 4663 | - $filename = $dir_var . $extension . "dyn-$nom_safe-" |
|
| 4664 | - . substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8) |
|
| 4663 | + $filename = $dir_var.$extension."dyn-$nom_safe-" |
|
| 4664 | + . substr(md5($fond.serialize($contexte_implicite).serialize($contexte).$connect), 0, 8) |
|
| 4665 | 4665 | . ".$extension"; |
| 4666 | 4666 | |
| 4667 | 4667 | // mettre a jour le fichier si il n'existe pas |
@@ -4669,8 +4669,8 @@ discard block |
||
| 4669 | 4669 | // le dernier fichier produit est toujours suffixe par .last |
| 4670 | 4670 | // et recopie sur le fichier cible uniquement si il change |
| 4671 | 4671 | if (!file_exists($filename) |
| 4672 | - or !file_exists($filename . ".last") |
|
| 4673 | - or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified']) |
|
| 4672 | + or !file_exists($filename.".last") |
|
| 4673 | + or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified']) |
|
| 4674 | 4674 | or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
| 4675 | 4675 | ) { |
| 4676 | 4676 | $contenu = $cache['texte']; |
@@ -4689,15 +4689,15 @@ discard block |
||
| 4689 | 4689 | } |
| 4690 | 4690 | // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
| 4691 | 4691 | // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
| 4692 | - $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 4692 | + $comment .= "}\n md5:".md5($contenu)." */\n"; |
|
| 4693 | 4693 | } |
| 4694 | 4694 | // et ecrire le fichier |
| 4695 | - ecrire_fichier($filename . ".last", $comment . $contenu); |
|
| 4695 | + ecrire_fichier($filename.".last", $comment.$contenu); |
|
| 4696 | 4696 | // regarder si on recopie |
| 4697 | 4697 | if (!file_exists($filename) |
| 4698 | - or md5_file($filename) !== md5_file($filename . ".last") |
|
| 4698 | + or md5_file($filename) !== md5_file($filename.".last") |
|
| 4699 | 4699 | ) { |
| 4700 | - @copy($filename . ".last", $filename); |
|
| 4700 | + @copy($filename.".last", $filename); |
|
| 4701 | 4701 | clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp |
| 4702 | 4702 | } |
| 4703 | 4703 | } |
@@ -3303,8 +3303,7 @@ discard block |
||
| 3303 | 3303 | $img_file = $img; |
| 3304 | 3304 | if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
| 3305 | 3305 | $img_file = chemin_image($img); |
| 3306 | - } |
|
| 3307 | - else { |
|
| 3306 | + } else { |
|
| 3308 | 3307 | if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){ |
| 3309 | 3308 | // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
| 3310 | 3309 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
@@ -3313,8 +3312,7 @@ discard block |
||
| 3313 | 3312 | and file_exists($variante_svg_generique)) { |
| 3314 | 3313 | if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) { |
| 3315 | 3314 | $img_file = $variante_svg_size; |
| 3316 | - } |
|
| 3317 | - else { |
|
| 3315 | + } else { |
|
| 3318 | 3316 | $img_file = $variante_svg_generique; |
| 3319 | 3317 | } |
| 3320 | 3318 | } |
@@ -3403,8 +3401,7 @@ discard block |
||
| 3403 | 3401 | $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
| 3404 | 3402 | $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n"; |
| 3405 | 3403 | $balise_svg .= $title; |
| 3406 | - } |
|
| 3407 | - else { |
|
| 3404 | + } else { |
|
| 3408 | 3405 | $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
| 3409 | 3406 | } |
| 3410 | 3407 | $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
@@ -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,63 +48,63 @@ 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 = array(); |
|
| 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 (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | - // si le fichier truc/machin/nom.php n'existe pas, |
|
| 83 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 84 | - and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 85 | - ) { |
|
| 86 | - include_spip(substr($dossier, 0, -1)); |
|
| 87 | - } |
|
| 88 | - if (function_exists($f)) { |
|
| 89 | - return $f; |
|
| 90 | - } |
|
| 91 | - if (function_exists($g)) { |
|
| 92 | - return $g; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if ($continue) { |
|
| 96 | - return $echecs[$f] = false; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // Echec : message d'erreur |
|
| 100 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | - ($inc ? "" : " (fichier $d absent de $dossier)")); |
|
| 102 | - |
|
| 103 | - include_spip('inc/minipres'); |
|
| 104 | - echo minipres(_T('forum_titre_erreur'), |
|
| 105 | - _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | - array('all_inline'=>true,'status'=>404)); |
|
| 107 | - exit; |
|
| 51 | + static $echecs = array(); |
|
| 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 (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | + // si le fichier truc/machin/nom.php n'existe pas, |
|
| 83 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 84 | + and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 85 | + ) { |
|
| 86 | + include_spip(substr($dossier, 0, -1)); |
|
| 87 | + } |
|
| 88 | + if (function_exists($f)) { |
|
| 89 | + return $f; |
|
| 90 | + } |
|
| 91 | + if (function_exists($g)) { |
|
| 92 | + return $g; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if ($continue) { |
|
| 96 | + return $echecs[$f] = false; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // Echec : message d'erreur |
|
| 100 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | + ($inc ? "" : " (fichier $d absent de $dossier)")); |
|
| 102 | + |
|
| 103 | + include_spip('inc/minipres'); |
|
| 104 | + echo minipres(_T('forum_titre_erreur'), |
|
| 105 | + _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | + array('all_inline'=>true,'status'=>404)); |
|
| 107 | + exit; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -114,17 +114,17 @@ discard block |
||
| 114 | 114 | * @return bool |
| 115 | 115 | */ |
| 116 | 116 | function include_once_check($file) { |
| 117 | - if (file_exists($file)) { |
|
| 118 | - include_once $file; |
|
| 117 | + if (file_exists($file)) { |
|
| 118 | + include_once $file; |
|
| 119 | 119 | |
| 120 | - return true; |
|
| 121 | - } |
|
| 122 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 123 | - $crash = ($crash ? $crash : array()); |
|
| 124 | - $crash[$file] = true; |
|
| 125 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 120 | + return true; |
|
| 121 | + } |
|
| 122 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 123 | + $crash = ($crash ? $crash : array()); |
|
| 124 | + $crash[$file] = true; |
|
| 125 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 126 | 126 | |
| 127 | - return false; |
|
| 127 | + return false; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * - string : chemin du fichier trouvé |
| 149 | 149 | **/ |
| 150 | 150 | function include_spip($f, $include = true) { |
| 151 | - return find_in_path($f . '.php', '', $include); |
|
| 151 | + return find_in_path($f . '.php', '', $include); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * - string : chemin du fichier trouvé |
| 169 | 169 | **/ |
| 170 | 170 | function require_spip($f) { |
| 171 | - return find_in_path($f . '.php', '', 'required'); |
|
| 171 | + return find_in_path($f . '.php', '', 'required'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -194,22 +194,22 @@ discard block |
||
| 194 | 194 | * Les paramètres du pipeline modifiés |
| 195 | 195 | **/ |
| 196 | 196 | function minipipe($fonc, &$val) { |
| 197 | - // fonction |
|
| 198 | - if (function_exists($fonc)) { |
|
| 199 | - $val = call_user_func($fonc, $val); |
|
| 200 | - } // Class::Methode |
|
| 201 | - else { |
|
| 202 | - if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 203 | - and $methode = array($regs[1], $regs[2]) |
|
| 204 | - and is_callable($methode) |
|
| 205 | - ) { |
|
| 206 | - $val = call_user_func($methode, $val); |
|
| 207 | - } else { |
|
| 208 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 209 | - } |
|
| 210 | - } |
|
| 197 | + // fonction |
|
| 198 | + if (function_exists($fonc)) { |
|
| 199 | + $val = call_user_func($fonc, $val); |
|
| 200 | + } // Class::Methode |
|
| 201 | + else { |
|
| 202 | + if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 203 | + and $methode = array($regs[1], $regs[2]) |
|
| 204 | + and is_callable($methode) |
|
| 205 | + ) { |
|
| 206 | + $val = call_user_func($methode, $val); |
|
| 207 | + } else { |
|
| 208 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - return $val; |
|
| 212 | + return $val; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -240,45 +240,45 @@ discard block |
||
| 240 | 240 | * Résultat |
| 241 | 241 | */ |
| 242 | 242 | function pipeline($action, $val = null) { |
| 243 | - static $charger; |
|
| 244 | - |
|
| 245 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 246 | - if (!$charger) { |
|
| 247 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 248 | - include_spip('inc/plugin'); |
|
| 249 | - // generer les fichiers php precompiles |
|
| 250 | - // de chargement des plugins et des pipelines |
|
| 251 | - actualise_plugins_actifs(); |
|
| 252 | - if (!($ok = @is_readable($charger))) { |
|
| 253 | - spip_log("fichier $charger pas cree"); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if ($ok) { |
|
| 258 | - include_once $charger; |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - // appliquer notre fonction si elle existe |
|
| 263 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 264 | - if (function_exists($fonc)) { |
|
| 265 | - $val = $fonc($val); |
|
| 266 | - } // plantage ? |
|
| 267 | - else { |
|
| 268 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - // si le flux est une table avec 2 cle args&data |
|
| 272 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 273 | - // array_key_exists pour php 4.1.0 |
|
| 274 | - if (is_array($val) |
|
| 275 | - and count($val) == 2 |
|
| 276 | - and (array_key_exists('data', $val)) |
|
| 277 | - ) { |
|
| 278 | - $val = $val['data']; |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - return $val; |
|
| 243 | + static $charger; |
|
| 244 | + |
|
| 245 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 246 | + if (!$charger) { |
|
| 247 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 248 | + include_spip('inc/plugin'); |
|
| 249 | + // generer les fichiers php precompiles |
|
| 250 | + // de chargement des plugins et des pipelines |
|
| 251 | + actualise_plugins_actifs(); |
|
| 252 | + if (!($ok = @is_readable($charger))) { |
|
| 253 | + spip_log("fichier $charger pas cree"); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if ($ok) { |
|
| 258 | + include_once $charger; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + // appliquer notre fonction si elle existe |
|
| 263 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 264 | + if (function_exists($fonc)) { |
|
| 265 | + $val = $fonc($val); |
|
| 266 | + } // plantage ? |
|
| 267 | + else { |
|
| 268 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + // si le flux est une table avec 2 cle args&data |
|
| 272 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 273 | + // array_key_exists pour php 4.1.0 |
|
| 274 | + if (is_array($val) |
|
| 275 | + and count($val) == 2 |
|
| 276 | + and (array_key_exists('data', $val)) |
|
| 277 | + ) { |
|
| 278 | + $val = $val['data']; |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + return $val; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -322,35 +322,35 @@ discard block |
||
| 322 | 322 | * paramètre est planté pour cause de compatibilité ascendante. |
| 323 | 323 | */ |
| 324 | 324 | function spip_log($message = null, $name = null) { |
| 325 | - static $pre = array(); |
|
| 326 | - static $log; |
|
| 327 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 328 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 329 | - $logname = null; |
|
| 330 | - } |
|
| 331 | - if (!isset($regs[2]) or !$niveau = $regs[2]) { |
|
| 332 | - $niveau = _LOG_INFO; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 336 | - if (!$pre) { |
|
| 337 | - $pre = array( |
|
| 338 | - _LOG_HS => 'HS:', |
|
| 339 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 340 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 341 | - _LOG_ERREUR => 'ERREUR:', |
|
| 342 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 343 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 344 | - _LOG_INFO => 'info:', |
|
| 345 | - _LOG_DEBUG => 'debug:' |
|
| 346 | - ); |
|
| 347 | - $log = charger_fonction('log', 'inc'); |
|
| 348 | - } |
|
| 349 | - if (!is_string($message)) { |
|
| 350 | - $message = print_r($message, true); |
|
| 351 | - } |
|
| 352 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 353 | - } |
|
| 325 | + static $pre = array(); |
|
| 326 | + static $log; |
|
| 327 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 328 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 329 | + $logname = null; |
|
| 330 | + } |
|
| 331 | + if (!isset($regs[2]) or !$niveau = $regs[2]) { |
|
| 332 | + $niveau = _LOG_INFO; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 336 | + if (!$pre) { |
|
| 337 | + $pre = array( |
|
| 338 | + _LOG_HS => 'HS:', |
|
| 339 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 340 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 341 | + _LOG_ERREUR => 'ERREUR:', |
|
| 342 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 343 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 344 | + _LOG_INFO => 'info:', |
|
| 345 | + _LOG_DEBUG => 'debug:' |
|
| 346 | + ); |
|
| 347 | + $log = charger_fonction('log', 'inc'); |
|
| 348 | + } |
|
| 349 | + if (!is_string($message)) { |
|
| 350 | + $message = print_r($message, true); |
|
| 351 | + } |
|
| 352 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 353 | + } |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
@@ -361,8 +361,8 @@ discard block |
||
| 361 | 361 | * @param array $opt Tableau d'options |
| 362 | 362 | **/ |
| 363 | 363 | function journal($phrase, $opt = array()) { |
| 364 | - $journal = charger_fonction('journal', 'inc'); |
|
| 365 | - $journal($phrase, $opt); |
|
| 364 | + $journal = charger_fonction('journal', 'inc'); |
|
| 365 | + $journal($phrase, $opt); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | |
@@ -381,36 +381,36 @@ discard block |
||
| 381 | 381 | **/ |
| 382 | 382 | function _request($var, $c = false) { |
| 383 | 383 | |
| 384 | - if (is_array($c)) { |
|
| 385 | - return isset($c[$var]) ? $c[$var] : null; |
|
| 386 | - } |
|
| 384 | + if (is_array($c)) { |
|
| 385 | + return isset($c[$var]) ? $c[$var] : null; |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - if (isset($_GET[$var])) { |
|
| 389 | - $a = $_GET[$var]; |
|
| 390 | - } elseif (isset($_POST[$var])) { |
|
| 391 | - $a = $_POST[$var]; |
|
| 392 | - } else { |
|
| 393 | - return null; |
|
| 394 | - } |
|
| 388 | + if (isset($_GET[$var])) { |
|
| 389 | + $a = $_GET[$var]; |
|
| 390 | + } elseif (isset($_POST[$var])) { |
|
| 391 | + $a = $_POST[$var]; |
|
| 392 | + } else { |
|
| 393 | + return null; |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - // Si on est en ajax et en POST tout a ete encode |
|
| 397 | - // via encodeURIComponent, il faut donc repasser |
|
| 398 | - // dans le charset local... |
|
| 399 | - if (defined('_AJAX') |
|
| 400 | - and _AJAX |
|
| 401 | - and isset($GLOBALS['meta']['charset']) |
|
| 402 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 403 | - and is_string($a) |
|
| 404 | - // check rapide mais pas fiable |
|
| 405 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 406 | - // check fiable |
|
| 407 | - and include_spip('inc/charsets') |
|
| 408 | - and is_utf8($a) |
|
| 409 | - ) { |
|
| 410 | - return importer_charset($a, 'utf-8'); |
|
| 411 | - } |
|
| 396 | + // Si on est en ajax et en POST tout a ete encode |
|
| 397 | + // via encodeURIComponent, il faut donc repasser |
|
| 398 | + // dans le charset local... |
|
| 399 | + if (defined('_AJAX') |
|
| 400 | + and _AJAX |
|
| 401 | + and isset($GLOBALS['meta']['charset']) |
|
| 402 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 403 | + and is_string($a) |
|
| 404 | + // check rapide mais pas fiable |
|
| 405 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 406 | + // check fiable |
|
| 407 | + and include_spip('inc/charsets') |
|
| 408 | + and is_utf8($a) |
|
| 409 | + ) { |
|
| 410 | + return importer_charset($a, 'utf-8'); |
|
| 411 | + } |
|
| 412 | 412 | |
| 413 | - return $a; |
|
| 413 | + return $a; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
@@ -428,22 +428,22 @@ discard block |
||
| 428 | 428 | * - false sinon |
| 429 | 429 | **/ |
| 430 | 430 | function set_request($var, $val = null, $c = false) { |
| 431 | - if (is_array($c)) { |
|
| 432 | - unset($c[$var]); |
|
| 433 | - if ($val !== null) { |
|
| 434 | - $c[$var] = $val; |
|
| 435 | - } |
|
| 431 | + if (is_array($c)) { |
|
| 432 | + unset($c[$var]); |
|
| 433 | + if ($val !== null) { |
|
| 434 | + $c[$var] = $val; |
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | - return $c; |
|
| 438 | - } |
|
| 437 | + return $c; |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | - unset($_GET[$var]); |
|
| 441 | - unset($_POST[$var]); |
|
| 442 | - if ($val !== null) { |
|
| 443 | - $_GET[$var] = $val; |
|
| 444 | - } |
|
| 440 | + unset($_GET[$var]); |
|
| 441 | + unset($_POST[$var]); |
|
| 442 | + if ($val !== null) { |
|
| 443 | + $_GET[$var] = $val; |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | - return false; # n'affecte pas $c |
|
| 446 | + return false; # n'affecte pas $c |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | |
@@ -452,23 +452,22 @@ discard block |
||
| 452 | 452 | * |
| 453 | 453 | * On est sur le web, on exclut certains protocoles, |
| 454 | 454 | * notamment 'file://', 'php://' et d'autres… |
| 455 | - |
|
| 456 | 455 | * @param string $url |
| 457 | 456 | * @return bool |
| 458 | 457 | */ |
| 459 | 458 | function tester_url_absolue($url) { |
| 460 | - $url = trim($url); |
|
| 461 | - if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 462 | - if ( |
|
| 463 | - isset($m[1]) |
|
| 464 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 465 | - and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 466 | - ) { |
|
| 467 | - return false; |
|
| 468 | - } |
|
| 469 | - return true; |
|
| 470 | - } |
|
| 471 | - return false; |
|
| 459 | + $url = trim($url); |
|
| 460 | + if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 461 | + if ( |
|
| 462 | + isset($m[1]) |
|
| 463 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 464 | + and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 465 | + ) { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 468 | + return true; |
|
| 469 | + } |
|
| 470 | + return false; |
|
| 472 | 471 | } |
| 473 | 472 | |
| 474 | 473 | /** |
@@ -490,94 +489,94 @@ discard block |
||
| 490 | 489 | * @return string URL |
| 491 | 490 | */ |
| 492 | 491 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 493 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 494 | - if (strpos($c, "|") !== false and is_null($v)) { |
|
| 495 | - return null; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - // lever l'#ancre |
|
| 499 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 500 | - $url = $r[1]; |
|
| 501 | - $ancre = $r[2]; |
|
| 502 | - } else { |
|
| 503 | - $ancre = ''; |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - // eclater |
|
| 507 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 508 | - |
|
| 509 | - // recuperer la base |
|
| 510 | - $a = array_shift($url); |
|
| 511 | - if (!$a) { |
|
| 512 | - $a = './'; |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 516 | - $ajouts = array_flip(explode('|', $c)); |
|
| 517 | - $u = is_array($v) ? $v : rawurlencode($v); |
|
| 518 | - $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 519 | - $v_read = null; |
|
| 520 | - // lire les variables et agir |
|
| 521 | - foreach ($url as $n => $val) { |
|
| 522 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 523 | - $r = array_pad($r, 3, null); |
|
| 524 | - if ($v === null) { |
|
| 525 | - // c'est un tableau, on memorise les valeurs |
|
| 526 | - if (substr($r[1], -2) == "[]") { |
|
| 527 | - if (!$v_read) { |
|
| 528 | - $v_read = array(); |
|
| 529 | - } |
|
| 530 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 531 | - } // c'est un scalaire, on retourne direct |
|
| 532 | - else { |
|
| 533 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 534 | - } |
|
| 535 | - } // suppression |
|
| 536 | - elseif (!$testv) { |
|
| 537 | - unset($url[$n]); |
|
| 538 | - } |
|
| 539 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 540 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 541 | - elseif (substr($r[1], -2) != '[]') { |
|
| 542 | - $url[$n] = $r[1] . '=' . $u; |
|
| 543 | - unset($ajouts[$r[1]]); |
|
| 544 | - } |
|
| 545 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 546 | - // départ, on remplira à l'étape suivante |
|
| 547 | - else { |
|
| 548 | - unset($url[$n]); |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - // traiter les parametres pas encore trouves |
|
| 554 | - if ($v === null |
|
| 555 | - and $args = func_get_args() |
|
| 556 | - and count($args) == 2 |
|
| 557 | - ) { |
|
| 558 | - return $v_read; // rien trouve ou un tableau |
|
| 559 | - } elseif ($testv) { |
|
| 560 | - foreach ($ajouts as $k => $n) { |
|
| 561 | - if (!is_array($v)) { |
|
| 562 | - $url[] = $k . '=' . $u; |
|
| 563 | - } else { |
|
| 564 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 565 | - foreach ($v as $w) { |
|
| 566 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 567 | - } |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - // eliminer les vides |
|
| 573 | - $url = array_filter($url); |
|
| 574 | - |
|
| 575 | - // recomposer l'adresse |
|
| 576 | - if ($url) { |
|
| 577 | - $a .= '?' . join($sep, $url); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - return $a . $ancre; |
|
| 492 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 493 | + if (strpos($c, "|") !== false and is_null($v)) { |
|
| 494 | + return null; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + // lever l'#ancre |
|
| 498 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 499 | + $url = $r[1]; |
|
| 500 | + $ancre = $r[2]; |
|
| 501 | + } else { |
|
| 502 | + $ancre = ''; |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + // eclater |
|
| 506 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 507 | + |
|
| 508 | + // recuperer la base |
|
| 509 | + $a = array_shift($url); |
|
| 510 | + if (!$a) { |
|
| 511 | + $a = './'; |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 515 | + $ajouts = array_flip(explode('|', $c)); |
|
| 516 | + $u = is_array($v) ? $v : rawurlencode($v); |
|
| 517 | + $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 518 | + $v_read = null; |
|
| 519 | + // lire les variables et agir |
|
| 520 | + foreach ($url as $n => $val) { |
|
| 521 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 522 | + $r = array_pad($r, 3, null); |
|
| 523 | + if ($v === null) { |
|
| 524 | + // c'est un tableau, on memorise les valeurs |
|
| 525 | + if (substr($r[1], -2) == "[]") { |
|
| 526 | + if (!$v_read) { |
|
| 527 | + $v_read = array(); |
|
| 528 | + } |
|
| 529 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 530 | + } // c'est un scalaire, on retourne direct |
|
| 531 | + else { |
|
| 532 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 533 | + } |
|
| 534 | + } // suppression |
|
| 535 | + elseif (!$testv) { |
|
| 536 | + unset($url[$n]); |
|
| 537 | + } |
|
| 538 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 539 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 540 | + elseif (substr($r[1], -2) != '[]') { |
|
| 541 | + $url[$n] = $r[1] . '=' . $u; |
|
| 542 | + unset($ajouts[$r[1]]); |
|
| 543 | + } |
|
| 544 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 545 | + // départ, on remplira à l'étape suivante |
|
| 546 | + else { |
|
| 547 | + unset($url[$n]); |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + // traiter les parametres pas encore trouves |
|
| 553 | + if ($v === null |
|
| 554 | + and $args = func_get_args() |
|
| 555 | + and count($args) == 2 |
|
| 556 | + ) { |
|
| 557 | + return $v_read; // rien trouve ou un tableau |
|
| 558 | + } elseif ($testv) { |
|
| 559 | + foreach ($ajouts as $k => $n) { |
|
| 560 | + if (!is_array($v)) { |
|
| 561 | + $url[] = $k . '=' . $u; |
|
| 562 | + } else { |
|
| 563 | + $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 564 | + foreach ($v as $w) { |
|
| 565 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 566 | + } |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + // eliminer les vides |
|
| 572 | + $url = array_filter($url); |
|
| 573 | + |
|
| 574 | + // recomposer l'adresse |
|
| 575 | + if ($url) { |
|
| 576 | + $a .= '?' . join($sep, $url); |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + return $a . $ancre; |
|
| 581 | 580 | } |
| 582 | 581 | |
| 583 | 582 | /** |
@@ -595,21 +594,21 @@ discard block |
||
| 595 | 594 | * @return string |
| 596 | 595 | */ |
| 597 | 596 | function ancre_url($url, $ancre) { |
| 598 | - // lever l'#ancre |
|
| 599 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 600 | - $url = $r[1]; |
|
| 601 | - } |
|
| 602 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 603 | - if (!function_exists('translitteration')) { |
|
| 604 | - include_spip('inc/charsets'); |
|
| 605 | - } |
|
| 606 | - $ancre = preg_replace( |
|
| 607 | - array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 608 | - array('', '-'), |
|
| 609 | - translitteration($ancre) |
|
| 610 | - ); |
|
| 611 | - } |
|
| 612 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 597 | + // lever l'#ancre |
|
| 598 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 599 | + $url = $r[1]; |
|
| 600 | + } |
|
| 601 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 602 | + if (!function_exists('translitteration')) { |
|
| 603 | + include_spip('inc/charsets'); |
|
| 604 | + } |
|
| 605 | + $ancre = preg_replace( |
|
| 606 | + array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 607 | + array('', '-'), |
|
| 608 | + translitteration($ancre) |
|
| 609 | + ); |
|
| 610 | + } |
|
| 611 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 613 | 612 | } |
| 614 | 613 | |
| 615 | 614 | /** |
@@ -619,16 +618,16 @@ discard block |
||
| 619 | 618 | * @return string |
| 620 | 619 | */ |
| 621 | 620 | function nettoyer_uri($reset = null) { |
| 622 | - static $done = false; |
|
| 623 | - static $propre = ''; |
|
| 624 | - if (!is_null($reset)) { |
|
| 625 | - return $propre = $reset; |
|
| 626 | - } |
|
| 627 | - if ($done) { |
|
| 628 | - return $propre; |
|
| 629 | - } |
|
| 630 | - $done = true; |
|
| 631 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 621 | + static $done = false; |
|
| 622 | + static $propre = ''; |
|
| 623 | + if (!is_null($reset)) { |
|
| 624 | + return $propre = $reset; |
|
| 625 | + } |
|
| 626 | + if ($done) { |
|
| 627 | + return $propre; |
|
| 628 | + } |
|
| 629 | + $done = true; |
|
| 630 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 632 | 631 | } |
| 633 | 632 | |
| 634 | 633 | /** |
@@ -640,13 +639,13 @@ discard block |
||
| 640 | 639 | * @return string |
| 641 | 640 | */ |
| 642 | 641 | function nettoyer_uri_var($request_uri) { |
| 643 | - $uri1 = $request_uri; |
|
| 644 | - do { |
|
| 645 | - $uri = $uri1; |
|
| 646 | - $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 647 | - '\1', $uri); |
|
| 648 | - } while ($uri <> $uri1); |
|
| 649 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 642 | + $uri1 = $request_uri; |
|
| 643 | + do { |
|
| 644 | + $uri = $uri1; |
|
| 645 | + $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 646 | + '\1', $uri); |
|
| 647 | + } while ($uri <> $uri1); |
|
| 648 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 650 | 649 | } |
| 651 | 650 | |
| 652 | 651 | |
@@ -660,47 +659,47 @@ discard block |
||
| 660 | 659 | * URL vers soi-même |
| 661 | 660 | **/ |
| 662 | 661 | function self($amp = '&', $root = false) { |
| 663 | - $url = nettoyer_uri(); |
|
| 664 | - if (!$root |
|
| 665 | - and ( |
|
| 666 | - // si pas de profondeur on peut tronquer |
|
| 667 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 668 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 669 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 670 | - ) { |
|
| 671 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 672 | - } |
|
| 673 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 674 | - foreach ($_POST as $v => $c) { |
|
| 675 | - if (substr($v, 0, 3) == 'id_') { |
|
| 676 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 677 | - } |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - // supprimer les variables sans interet |
|
| 681 | - if (test_espace_prive()) { |
|
| 682 | - $url = preg_replace(',([?&])(' |
|
| 683 | - . 'lang|show_docs|' |
|
| 684 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 685 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 686 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - // eviter les hacks |
|
| 690 | - include_spip('inc/filtres_mini'); |
|
| 691 | - $url = spip_htmlspecialchars($url); |
|
| 662 | + $url = nettoyer_uri(); |
|
| 663 | + if (!$root |
|
| 664 | + and ( |
|
| 665 | + // si pas de profondeur on peut tronquer |
|
| 666 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 667 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 668 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 669 | + ) { |
|
| 670 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 671 | + } |
|
| 672 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 673 | + foreach ($_POST as $v => $c) { |
|
| 674 | + if (substr($v, 0, 3) == 'id_') { |
|
| 675 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 676 | + } |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + // supprimer les variables sans interet |
|
| 680 | + if (test_espace_prive()) { |
|
| 681 | + $url = preg_replace(',([?&])(' |
|
| 682 | + . 'lang|show_docs|' |
|
| 683 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 684 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 685 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + // eviter les hacks |
|
| 689 | + include_spip('inc/filtres_mini'); |
|
| 690 | + $url = spip_htmlspecialchars($url); |
|
| 692 | 691 | |
| 693 | - $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 692 | + $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 694 | 693 | |
| 695 | - // & ? |
|
| 696 | - if ($amp != '&') { |
|
| 697 | - $url = str_replace('&', $amp, $url); |
|
| 698 | - } |
|
| 694 | + // & ? |
|
| 695 | + if ($amp != '&') { |
|
| 696 | + $url = str_replace('&', $amp, $url); |
|
| 697 | + } |
|
| 699 | 698 | |
| 700 | - // Si ca demarre par ? ou vide, donner './' |
|
| 701 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 699 | + // Si ca demarre par ? ou vide, donner './' |
|
| 700 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 702 | 701 | |
| 703 | - return $url; |
|
| 702 | + return $url; |
|
| 704 | 703 | } |
| 705 | 704 | |
| 706 | 705 | |
@@ -711,7 +710,7 @@ discard block |
||
| 711 | 710 | * true si c'est le cas, false sinon. |
| 712 | 711 | */ |
| 713 | 712 | function test_espace_prive() { |
| 714 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 713 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 715 | 714 | } |
| 716 | 715 | |
| 717 | 716 | /** |
@@ -721,7 +720,7 @@ discard block |
||
| 721 | 720 | * @return bool |
| 722 | 721 | */ |
| 723 | 722 | function test_plugin_actif($plugin) { |
| 724 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 723 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 725 | 724 | } |
| 726 | 725 | |
| 727 | 726 | /** |
@@ -752,51 +751,51 @@ discard block |
||
| 752 | 751 | * Texte |
| 753 | 752 | */ |
| 754 | 753 | function _T($texte, $args = array(), $options = array()) { |
| 755 | - static $traduire = false; |
|
| 756 | - $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 757 | - if ($options) { |
|
| 758 | - // support de l'ancien argument $class |
|
| 759 | - if (is_string($options)) { |
|
| 760 | - $options = array('class' => $options); |
|
| 761 | - } |
|
| 762 | - $o = array_merge($o, $options); |
|
| 763 | - } |
|
| 754 | + static $traduire = false; |
|
| 755 | + $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 756 | + if ($options) { |
|
| 757 | + // support de l'ancien argument $class |
|
| 758 | + if (is_string($options)) { |
|
| 759 | + $options = array('class' => $options); |
|
| 760 | + } |
|
| 761 | + $o = array_merge($o, $options); |
|
| 762 | + } |
|
| 764 | 763 | |
| 765 | - if (!$traduire) { |
|
| 766 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 767 | - include_spip('inc/lang'); |
|
| 768 | - } |
|
| 764 | + if (!$traduire) { |
|
| 765 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 766 | + include_spip('inc/lang'); |
|
| 767 | + } |
|
| 769 | 768 | |
| 770 | - // On peut passer explicitement la langue dans le tableau |
|
| 771 | - // On utilise le même nom de variable que la globale |
|
| 772 | - if (isset($args['spip_lang'])) { |
|
| 773 | - $lang = $args['spip_lang']; |
|
| 774 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 775 | - unset($args['spip_lang']); |
|
| 776 | - } // Sinon on prend la langue du contexte |
|
| 777 | - else { |
|
| 778 | - $lang = $GLOBALS['spip_lang']; |
|
| 779 | - } |
|
| 780 | - $text = $traduire($texte, $lang); |
|
| 769 | + // On peut passer explicitement la langue dans le tableau |
|
| 770 | + // On utilise le même nom de variable que la globale |
|
| 771 | + if (isset($args['spip_lang'])) { |
|
| 772 | + $lang = $args['spip_lang']; |
|
| 773 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 774 | + unset($args['spip_lang']); |
|
| 775 | + } // Sinon on prend la langue du contexte |
|
| 776 | + else { |
|
| 777 | + $lang = $GLOBALS['spip_lang']; |
|
| 778 | + } |
|
| 779 | + $text = $traduire($texte, $lang); |
|
| 781 | 780 | |
| 782 | - if (!strlen($text)) { |
|
| 783 | - if (!$o['force']) { |
|
| 784 | - return ''; |
|
| 785 | - } |
|
| 781 | + if (!strlen($text)) { |
|
| 782 | + if (!$o['force']) { |
|
| 783 | + return ''; |
|
| 784 | + } |
|
| 786 | 785 | |
| 787 | - $text = $texte; |
|
| 786 | + $text = $texte; |
|
| 788 | 787 | |
| 789 | - // pour les chaines non traduites, assurer un service minimum |
|
| 790 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 791 | - $text = str_replace('_', ' ', |
|
| 792 | - (($n = strpos($text, ':')) === false ? $texte : |
|
| 793 | - substr($texte, $n + 1))); |
|
| 794 | - } |
|
| 795 | - $o['class'] = null; |
|
| 788 | + // pour les chaines non traduites, assurer un service minimum |
|
| 789 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 790 | + $text = str_replace('_', ' ', |
|
| 791 | + (($n = strpos($text, ':')) === false ? $texte : |
|
| 792 | + substr($texte, $n + 1))); |
|
| 793 | + } |
|
| 794 | + $o['class'] = null; |
|
| 796 | 795 | |
| 797 | - } |
|
| 796 | + } |
|
| 798 | 797 | |
| 799 | - return _L($text, $args, $o); |
|
| 798 | + return _L($text, $args, $o); |
|
| 800 | 799 | |
| 801 | 800 | } |
| 802 | 801 | |
@@ -824,53 +823,53 @@ discard block |
||
| 824 | 823 | * Texte |
| 825 | 824 | */ |
| 826 | 825 | function _L($text, $args = array(), $options = array()) { |
| 827 | - $f = $text; |
|
| 828 | - $defaut_options = array( |
|
| 829 | - 'class' => null, |
|
| 830 | - 'sanitize' => true, |
|
| 831 | - ); |
|
| 832 | - // support de l'ancien argument $class |
|
| 833 | - if ($options and is_string($options)) { |
|
| 834 | - $options = array('class' => $options); |
|
| 835 | - } |
|
| 836 | - if (is_array($options)) { |
|
| 837 | - $options += $defaut_options; |
|
| 838 | - } else { |
|
| 839 | - $options = $defaut_options; |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - if (is_array($args) and count($args)) { |
|
| 843 | - if (!function_exists('interdire_scripts')) { |
|
| 844 | - include_spip('inc/texte'); |
|
| 845 | - } |
|
| 846 | - if (!function_exists('echapper_html_suspect')) { |
|
| 847 | - include_spip('inc/texte_mini'); |
|
| 848 | - } |
|
| 849 | - foreach ($args as $name => $value) { |
|
| 850 | - if (strpos($text, "@$name@") !== false) { |
|
| 851 | - if ($options['sanitize']) { |
|
| 852 | - $value = echapper_html_suspect($value); |
|
| 853 | - $value = interdire_scripts($value, -1); |
|
| 854 | - } |
|
| 855 | - if (!empty($options['class'])) { |
|
| 856 | - $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 857 | - } |
|
| 858 | - $text = str_replace("@$name@", $value, $text); |
|
| 859 | - unset($args[$name]); |
|
| 860 | - } |
|
| 861 | - } |
|
| 862 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 863 | - // (chaines de langues pas a jour) |
|
| 864 | - if ($args) { |
|
| 865 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 866 | - } |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 870 | - return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 871 | - } else { |
|
| 872 | - return $text; |
|
| 873 | - } |
|
| 826 | + $f = $text; |
|
| 827 | + $defaut_options = array( |
|
| 828 | + 'class' => null, |
|
| 829 | + 'sanitize' => true, |
|
| 830 | + ); |
|
| 831 | + // support de l'ancien argument $class |
|
| 832 | + if ($options and is_string($options)) { |
|
| 833 | + $options = array('class' => $options); |
|
| 834 | + } |
|
| 835 | + if (is_array($options)) { |
|
| 836 | + $options += $defaut_options; |
|
| 837 | + } else { |
|
| 838 | + $options = $defaut_options; |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + if (is_array($args) and count($args)) { |
|
| 842 | + if (!function_exists('interdire_scripts')) { |
|
| 843 | + include_spip('inc/texte'); |
|
| 844 | + } |
|
| 845 | + if (!function_exists('echapper_html_suspect')) { |
|
| 846 | + include_spip('inc/texte_mini'); |
|
| 847 | + } |
|
| 848 | + foreach ($args as $name => $value) { |
|
| 849 | + if (strpos($text, "@$name@") !== false) { |
|
| 850 | + if ($options['sanitize']) { |
|
| 851 | + $value = echapper_html_suspect($value); |
|
| 852 | + $value = interdire_scripts($value, -1); |
|
| 853 | + } |
|
| 854 | + if (!empty($options['class'])) { |
|
| 855 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 856 | + } |
|
| 857 | + $text = str_replace("@$name@", $value, $text); |
|
| 858 | + unset($args[$name]); |
|
| 859 | + } |
|
| 860 | + } |
|
| 861 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 862 | + // (chaines de langues pas a jour) |
|
| 863 | + if ($args) { |
|
| 864 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 869 | + return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 870 | + } else { |
|
| 871 | + return $text; |
|
| 872 | + } |
|
| 874 | 873 | } |
| 875 | 874 | |
| 876 | 875 | |
@@ -884,13 +883,13 @@ discard block |
||
| 884 | 883 | * @return string |
| 885 | 884 | */ |
| 886 | 885 | function joli_repertoire($rep) { |
| 887 | - $a = substr($rep, 0, 1); |
|
| 888 | - if ($a <> '.' and $a <> '/') { |
|
| 889 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 890 | - } |
|
| 891 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 886 | + $a = substr($rep, 0, 1); |
|
| 887 | + if ($a <> '.' and $a <> '/') { |
|
| 888 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 889 | + } |
|
| 890 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 892 | 891 | |
| 893 | - return $rep; |
|
| 892 | + return $rep; |
|
| 894 | 893 | } |
| 895 | 894 | |
| 896 | 895 | |
@@ -915,33 +914,33 @@ discard block |
||
| 915 | 914 | * @return float|int|string|void |
| 916 | 915 | */ |
| 917 | 916 | function spip_timer($t = 'rien', $raw = false) { |
| 918 | - static $time; |
|
| 919 | - $a = time(); |
|
| 920 | - $b = microtime(); |
|
| 921 | - // microtime peut contenir les microsecondes et le temps |
|
| 922 | - $b = explode(' ', $b); |
|
| 923 | - if (count($b) == 2) { |
|
| 924 | - $a = end($b); |
|
| 925 | - } // plus precis ! |
|
| 926 | - $b = reset($b); |
|
| 927 | - if (!isset($time[$t])) { |
|
| 928 | - $time[$t] = $a + $b; |
|
| 929 | - } else { |
|
| 930 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 931 | - unset($time[$t]); |
|
| 917 | + static $time; |
|
| 918 | + $a = time(); |
|
| 919 | + $b = microtime(); |
|
| 920 | + // microtime peut contenir les microsecondes et le temps |
|
| 921 | + $b = explode(' ', $b); |
|
| 922 | + if (count($b) == 2) { |
|
| 923 | + $a = end($b); |
|
| 924 | + } // plus precis ! |
|
| 925 | + $b = reset($b); |
|
| 926 | + if (!isset($time[$t])) { |
|
| 927 | + $time[$t] = $a + $b; |
|
| 928 | + } else { |
|
| 929 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 930 | + unset($time[$t]); |
|
| 932 | 931 | # echo "'$p'";exit; |
| 933 | - if ($raw) { |
|
| 934 | - return $p; |
|
| 935 | - } |
|
| 936 | - if ($p < 1000) { |
|
| 937 | - $s = ''; |
|
| 938 | - } else { |
|
| 939 | - $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 940 | - $p -= ($x * 1000); |
|
| 941 | - } |
|
| 932 | + if ($raw) { |
|
| 933 | + return $p; |
|
| 934 | + } |
|
| 935 | + if ($p < 1000) { |
|
| 936 | + $s = ''; |
|
| 937 | + } else { |
|
| 938 | + $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 939 | + $p -= ($x * 1000); |
|
| 940 | + } |
|
| 942 | 941 | |
| 943 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 944 | - } |
|
| 942 | + return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 943 | + } |
|
| 945 | 944 | } |
| 946 | 945 | |
| 947 | 946 | |
@@ -949,21 +948,21 @@ discard block |
||
| 949 | 948 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 950 | 949 | // http://code.spip.net/@spip_touch |
| 951 | 950 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 952 | - if ($duree) { |
|
| 953 | - clearstatcache(); |
|
| 954 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 955 | - return false; |
|
| 956 | - } |
|
| 957 | - } |
|
| 958 | - if ($touch !== false) { |
|
| 959 | - if (!@touch($fichier)) { |
|
| 960 | - spip_unlink($fichier); |
|
| 961 | - @touch($fichier); |
|
| 962 | - }; |
|
| 963 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 964 | - } |
|
| 951 | + if ($duree) { |
|
| 952 | + clearstatcache(); |
|
| 953 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 954 | + return false; |
|
| 955 | + } |
|
| 956 | + } |
|
| 957 | + if ($touch !== false) { |
|
| 958 | + if (!@touch($fichier)) { |
|
| 959 | + spip_unlink($fichier); |
|
| 960 | + @touch($fichier); |
|
| 961 | + }; |
|
| 962 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 963 | + } |
|
| 965 | 964 | |
| 966 | - return true; |
|
| 965 | + return true; |
|
| 967 | 966 | } |
| 968 | 967 | |
| 969 | 968 | |
@@ -975,11 +974,11 @@ discard block |
||
| 975 | 974 | * @uses cron() |
| 976 | 975 | **/ |
| 977 | 976 | function action_cron() { |
| 978 | - include_spip('inc/headers'); |
|
| 979 | - http_status(204); // No Content |
|
| 980 | - header("Connection: close"); |
|
| 981 | - define('_DIRECT_CRON_FORCE', true); |
|
| 982 | - cron(); |
|
| 977 | + include_spip('inc/headers'); |
|
| 978 | + http_status(204); // No Content |
|
| 979 | + header("Connection: close"); |
|
| 980 | + define('_DIRECT_CRON_FORCE', true); |
|
| 981 | + cron(); |
|
| 983 | 982 | } |
| 984 | 983 | |
| 985 | 984 | /** |
@@ -995,26 +994,26 @@ discard block |
||
| 995 | 994 | * True si la tache a pu être effectuée |
| 996 | 995 | */ |
| 997 | 996 | function cron($taches = array(), $taches_old = array()) { |
| 998 | - // si pas en mode cron force, laisser tomber. |
|
| 999 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1000 | - return false; |
|
| 1001 | - } |
|
| 1002 | - if (!is_array($taches)) { |
|
| 1003 | - $taches = $taches_old; |
|
| 1004 | - } // compat anciens appels |
|
| 1005 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1006 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1007 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1008 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1009 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1010 | - return false; |
|
| 1011 | - } |
|
| 1012 | - spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1013 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1014 | - return $genie($taches); |
|
| 1015 | - } |
|
| 1016 | - |
|
| 1017 | - return false; |
|
| 997 | + // si pas en mode cron force, laisser tomber. |
|
| 998 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 999 | + return false; |
|
| 1000 | + } |
|
| 1001 | + if (!is_array($taches)) { |
|
| 1002 | + $taches = $taches_old; |
|
| 1003 | + } // compat anciens appels |
|
| 1004 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1005 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1006 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1007 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1008 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1009 | + return false; |
|
| 1010 | + } |
|
| 1011 | + spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1012 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1013 | + return $genie($taches); |
|
| 1014 | + } |
|
| 1015 | + |
|
| 1016 | + return false; |
|
| 1018 | 1017 | } |
| 1019 | 1018 | |
| 1020 | 1019 | /** |
@@ -1046,17 +1045,17 @@ discard block |
||
| 1046 | 1045 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1047 | 1046 | */ |
| 1048 | 1047 | function job_queue_add( |
| 1049 | - $function, |
|
| 1050 | - $description, |
|
| 1051 | - $arguments = array(), |
|
| 1052 | - $file = '', |
|
| 1053 | - $no_duplicate = false, |
|
| 1054 | - $time = 0, |
|
| 1055 | - $priority = 0 |
|
| 1048 | + $function, |
|
| 1049 | + $description, |
|
| 1050 | + $arguments = array(), |
|
| 1051 | + $file = '', |
|
| 1052 | + $no_duplicate = false, |
|
| 1053 | + $time = 0, |
|
| 1054 | + $priority = 0 |
|
| 1056 | 1055 | ) { |
| 1057 | - include_spip('inc/queue'); |
|
| 1056 | + include_spip('inc/queue'); |
|
| 1058 | 1057 | |
| 1059 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1058 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1060 | 1059 | } |
| 1061 | 1060 | |
| 1062 | 1061 | /** |
@@ -1067,9 +1066,9 @@ discard block |
||
| 1067 | 1066 | * @return bool |
| 1068 | 1067 | */ |
| 1069 | 1068 | function job_queue_remove($id_job) { |
| 1070 | - include_spip('inc/queue'); |
|
| 1069 | + include_spip('inc/queue'); |
|
| 1071 | 1070 | |
| 1072 | - return queue_remove_job($id_job); |
|
| 1071 | + return queue_remove_job($id_job); |
|
| 1073 | 1072 | } |
| 1074 | 1073 | |
| 1075 | 1074 | /** |
@@ -1082,9 +1081,9 @@ discard block |
||
| 1082 | 1081 | * or an array of simple array to link multiples objet in one time |
| 1083 | 1082 | */ |
| 1084 | 1083 | function job_queue_link($id_job, $objets) { |
| 1085 | - include_spip('inc/queue'); |
|
| 1084 | + include_spip('inc/queue'); |
|
| 1086 | 1085 | |
| 1087 | - return queue_link_job($id_job, $objets); |
|
| 1086 | + return queue_link_job($id_job, $objets); |
|
| 1088 | 1087 | } |
| 1089 | 1088 | |
| 1090 | 1089 | |
@@ -1104,36 +1103,36 @@ discard block |
||
| 1104 | 1103 | * - `null` si la queue n'est pas encore initialisée |
| 1105 | 1104 | */ |
| 1106 | 1105 | function queue_sleep_time_to_next_job($force = null) { |
| 1107 | - static $queue_next_job_time = -1; |
|
| 1108 | - if ($force === true) { |
|
| 1109 | - $queue_next_job_time = -1; |
|
| 1110 | - } elseif ($force) { |
|
| 1111 | - $queue_next_job_time = $force; |
|
| 1112 | - } |
|
| 1113 | - |
|
| 1114 | - if ($queue_next_job_time == -1) { |
|
| 1115 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1116 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1117 | - } |
|
| 1118 | - // utiliser un cache memoire si dispo |
|
| 1119 | - if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1120 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1121 | - } else { |
|
| 1122 | - $queue_next_job_time = null; |
|
| 1123 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1124 | - $queue_next_job_time = intval($contenu); |
|
| 1125 | - } |
|
| 1126 | - } |
|
| 1127 | - } |
|
| 1128 | - |
|
| 1129 | - if (is_null($queue_next_job_time)) { |
|
| 1130 | - return null; |
|
| 1131 | - } |
|
| 1132 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1133 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1134 | - } |
|
| 1135 | - |
|
| 1136 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1106 | + static $queue_next_job_time = -1; |
|
| 1107 | + if ($force === true) { |
|
| 1108 | + $queue_next_job_time = -1; |
|
| 1109 | + } elseif ($force) { |
|
| 1110 | + $queue_next_job_time = $force; |
|
| 1111 | + } |
|
| 1112 | + |
|
| 1113 | + if ($queue_next_job_time == -1) { |
|
| 1114 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1115 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1116 | + } |
|
| 1117 | + // utiliser un cache memoire si dispo |
|
| 1118 | + if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1119 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1120 | + } else { |
|
| 1121 | + $queue_next_job_time = null; |
|
| 1122 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1123 | + $queue_next_job_time = intval($contenu); |
|
| 1124 | + } |
|
| 1125 | + } |
|
| 1126 | + } |
|
| 1127 | + |
|
| 1128 | + if (is_null($queue_next_job_time)) { |
|
| 1129 | + return null; |
|
| 1130 | + } |
|
| 1131 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1132 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1137 | 1136 | } |
| 1138 | 1137 | |
| 1139 | 1138 | |
@@ -1145,9 +1144,9 @@ discard block |
||
| 1145 | 1144 | * @return string |
| 1146 | 1145 | */ |
| 1147 | 1146 | function quote_amp($u) { |
| 1148 | - return preg_replace( |
|
| 1149 | - "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1150 | - "&", $u); |
|
| 1147 | + return preg_replace( |
|
| 1148 | + "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1149 | + "&", $u); |
|
| 1151 | 1150 | } |
| 1152 | 1151 | |
| 1153 | 1152 | |
@@ -1170,27 +1169,27 @@ discard block |
||
| 1170 | 1169 | * Balise HTML `<script>` et son contenu |
| 1171 | 1170 | **/ |
| 1172 | 1171 | function http_script($script, $src = '', $noscript = '') { |
| 1173 | - static $done = array(); |
|
| 1172 | + static $done = array(); |
|
| 1174 | 1173 | |
| 1175 | - if ($src && !isset($done[$src])) { |
|
| 1176 | - $done[$src] = true; |
|
| 1177 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1178 | - $src = " src='$src'"; |
|
| 1179 | - } else { |
|
| 1180 | - $src = ''; |
|
| 1181 | - } |
|
| 1182 | - if ($script) { |
|
| 1183 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1184 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1185 | - "/*]]>*/"); |
|
| 1186 | - } |
|
| 1187 | - if ($noscript) { |
|
| 1188 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1189 | - } |
|
| 1174 | + if ($src && !isset($done[$src])) { |
|
| 1175 | + $done[$src] = true; |
|
| 1176 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1177 | + $src = " src='$src'"; |
|
| 1178 | + } else { |
|
| 1179 | + $src = ''; |
|
| 1180 | + } |
|
| 1181 | + if ($script) { |
|
| 1182 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1183 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1184 | + "/*]]>*/"); |
|
| 1185 | + } |
|
| 1186 | + if ($noscript) { |
|
| 1187 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1188 | + } |
|
| 1190 | 1189 | |
| 1191 | - return ($src or $script or $noscript) |
|
| 1192 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1193 | - : ''; |
|
| 1190 | + return ($src or $script or $noscript) |
|
| 1191 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1192 | + : ''; |
|
| 1194 | 1193 | } |
| 1195 | 1194 | |
| 1196 | 1195 | |
@@ -1225,7 +1224,7 @@ discard block |
||
| 1225 | 1224 | * Texte échappé |
| 1226 | 1225 | **/ |
| 1227 | 1226 | function texte_script($texte) { |
| 1228 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1227 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1229 | 1228 | } |
| 1230 | 1229 | |
| 1231 | 1230 | |
@@ -1262,69 +1261,69 @@ discard block |
||
| 1262 | 1261 | * Liste des chemins, par ordre de priorité. |
| 1263 | 1262 | **/ |
| 1264 | 1263 | function _chemin($dir_path = null) { |
| 1265 | - static $path_base = null; |
|
| 1266 | - static $path_full = null; |
|
| 1267 | - if ($path_base == null) { |
|
| 1268 | - // Chemin standard depuis l'espace public |
|
| 1269 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1270 | - _DIR_RACINE . ':' . |
|
| 1271 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1272 | - _DIR_RACINE . 'prive/:' . |
|
| 1273 | - _DIR_RESTREINT; |
|
| 1274 | - // Ajouter squelettes/ |
|
| 1275 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1276 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1277 | - } |
|
| 1278 | - foreach (explode(':', $path) as $dir) { |
|
| 1279 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1280 | - $dir .= "/"; |
|
| 1281 | - } |
|
| 1282 | - $path_base[] = $dir; |
|
| 1283 | - } |
|
| 1284 | - $path_full = $path_base; |
|
| 1285 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1286 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1287 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1288 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1289 | - } |
|
| 1290 | - } |
|
| 1291 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1292 | - } |
|
| 1293 | - if ($dir_path === null) { |
|
| 1294 | - return $path_full; |
|
| 1295 | - } |
|
| 1296 | - |
|
| 1297 | - if (strlen($dir_path)) { |
|
| 1298 | - $tete = ""; |
|
| 1299 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1300 | - $tete = array_shift($path_base); |
|
| 1301 | - } |
|
| 1302 | - $dirs = array_reverse(explode(':', $dir_path)); |
|
| 1303 | - foreach ($dirs as $dir_path) { |
|
| 1304 | - #if ($dir_path{0}!='/') |
|
| 1305 | - # $dir_path = $dir_path; |
|
| 1306 | - if (substr($dir_path, -1) != '/') { |
|
| 1307 | - $dir_path .= "/"; |
|
| 1308 | - } |
|
| 1309 | - if (!in_array($dir_path, $path_base)) { |
|
| 1310 | - array_unshift($path_base, $dir_path); |
|
| 1311 | - } |
|
| 1312 | - } |
|
| 1313 | - if (strlen($tete)) { |
|
| 1314 | - array_unshift($path_base, $tete); |
|
| 1315 | - } |
|
| 1316 | - } |
|
| 1317 | - $path_full = $path_base; |
|
| 1318 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1319 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1320 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1321 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1322 | - } |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1326 | - |
|
| 1327 | - return $path_full; |
|
| 1264 | + static $path_base = null; |
|
| 1265 | + static $path_full = null; |
|
| 1266 | + if ($path_base == null) { |
|
| 1267 | + // Chemin standard depuis l'espace public |
|
| 1268 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1269 | + _DIR_RACINE . ':' . |
|
| 1270 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1271 | + _DIR_RACINE . 'prive/:' . |
|
| 1272 | + _DIR_RESTREINT; |
|
| 1273 | + // Ajouter squelettes/ |
|
| 1274 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1275 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1276 | + } |
|
| 1277 | + foreach (explode(':', $path) as $dir) { |
|
| 1278 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1279 | + $dir .= "/"; |
|
| 1280 | + } |
|
| 1281 | + $path_base[] = $dir; |
|
| 1282 | + } |
|
| 1283 | + $path_full = $path_base; |
|
| 1284 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1285 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1286 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1287 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1288 | + } |
|
| 1289 | + } |
|
| 1290 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1291 | + } |
|
| 1292 | + if ($dir_path === null) { |
|
| 1293 | + return $path_full; |
|
| 1294 | + } |
|
| 1295 | + |
|
| 1296 | + if (strlen($dir_path)) { |
|
| 1297 | + $tete = ""; |
|
| 1298 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1299 | + $tete = array_shift($path_base); |
|
| 1300 | + } |
|
| 1301 | + $dirs = array_reverse(explode(':', $dir_path)); |
|
| 1302 | + foreach ($dirs as $dir_path) { |
|
| 1303 | + #if ($dir_path{0}!='/') |
|
| 1304 | + # $dir_path = $dir_path; |
|
| 1305 | + if (substr($dir_path, -1) != '/') { |
|
| 1306 | + $dir_path .= "/"; |
|
| 1307 | + } |
|
| 1308 | + if (!in_array($dir_path, $path_base)) { |
|
| 1309 | + array_unshift($path_base, $dir_path); |
|
| 1310 | + } |
|
| 1311 | + } |
|
| 1312 | + if (strlen($tete)) { |
|
| 1313 | + array_unshift($path_base, $tete); |
|
| 1314 | + } |
|
| 1315 | + } |
|
| 1316 | + $path_full = $path_base; |
|
| 1317 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1318 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1319 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1320 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1321 | + } |
|
| 1322 | + } |
|
| 1323 | + |
|
| 1324 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1325 | + |
|
| 1326 | + return $path_full; |
|
| 1328 | 1327 | } |
| 1329 | 1328 | |
| 1330 | 1329 | /** |
@@ -1337,76 +1336,76 @@ discard block |
||
| 1337 | 1336 | * @return array Liste de chemins |
| 1338 | 1337 | **/ |
| 1339 | 1338 | function creer_chemin() { |
| 1340 | - $path_a = _chemin(); |
|
| 1341 | - static $c = ''; |
|
| 1339 | + $path_a = _chemin(); |
|
| 1340 | + static $c = ''; |
|
| 1342 | 1341 | |
| 1343 | - // on calcule le chemin si le dossier skel a change |
|
| 1344 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1345 | - // assurer le non plantage lors de la montee de version : |
|
| 1346 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1347 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1348 | - } |
|
| 1342 | + // on calcule le chemin si le dossier skel a change |
|
| 1343 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1344 | + // assurer le non plantage lors de la montee de version : |
|
| 1345 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1346 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1347 | + } |
|
| 1349 | 1348 | |
| 1350 | - return $path_a; |
|
| 1349 | + return $path_a; |
|
| 1351 | 1350 | } |
| 1352 | 1351 | |
| 1353 | 1352 | |
| 1354 | 1353 | function lister_themes_prives() { |
| 1355 | - static $themes = null; |
|
| 1356 | - if (is_null($themes)) { |
|
| 1357 | - // si pas encore definie |
|
| 1358 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1359 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1360 | - } |
|
| 1361 | - $themes = array(_SPIP_THEME_PRIVE); |
|
| 1362 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1363 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1364 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1365 | - } else { |
|
| 1366 | - $prefs = array(); |
|
| 1367 | - } |
|
| 1368 | - if (is_string($prefs)) { |
|
| 1369 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1370 | - } |
|
| 1371 | - if ( |
|
| 1372 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1373 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1374 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1375 | - ) { |
|
| 1376 | - array_unshift($themes, $theme); |
|
| 1377 | - } // placer le theme choisi en tete |
|
| 1378 | - } |
|
| 1379 | - |
|
| 1380 | - return $themes; |
|
| 1354 | + static $themes = null; |
|
| 1355 | + if (is_null($themes)) { |
|
| 1356 | + // si pas encore definie |
|
| 1357 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1358 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1359 | + } |
|
| 1360 | + $themes = array(_SPIP_THEME_PRIVE); |
|
| 1361 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1362 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1363 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1364 | + } else { |
|
| 1365 | + $prefs = array(); |
|
| 1366 | + } |
|
| 1367 | + if (is_string($prefs)) { |
|
| 1368 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1369 | + } |
|
| 1370 | + if ( |
|
| 1371 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1372 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1373 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1374 | + ) { |
|
| 1375 | + array_unshift($themes, $theme); |
|
| 1376 | + } // placer le theme choisi en tete |
|
| 1377 | + } |
|
| 1378 | + |
|
| 1379 | + return $themes; |
|
| 1381 | 1380 | } |
| 1382 | 1381 | |
| 1383 | 1382 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1384 | - static $themefiles = array(); |
|
| 1385 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1386 | - return $themefiles["$subdir$file"]; |
|
| 1387 | - } |
|
| 1388 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1389 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1390 | - if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1391 | - and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1392 | - and $f = find_in_theme("$file_svg_generique")) { |
|
| 1393 | - if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1394 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1395 | - } |
|
| 1396 | - else { |
|
| 1397 | - return $themefiles["$subdir$file"] = $f; |
|
| 1398 | - } |
|
| 1399 | - } |
|
| 1400 | - |
|
| 1401 | - $themes = lister_themes_prives(); |
|
| 1402 | - foreach ($themes as $theme) { |
|
| 1403 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1404 | - return $themefiles["$subdir$file"] = $f; |
|
| 1405 | - } |
|
| 1406 | - } |
|
| 1407 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1408 | - |
|
| 1409 | - return $themefiles["$subdir$file"] = ""; |
|
| 1383 | + static $themefiles = array(); |
|
| 1384 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1385 | + return $themefiles["$subdir$file"]; |
|
| 1386 | + } |
|
| 1387 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1388 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1389 | + if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1390 | + and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1391 | + and $f = find_in_theme("$file_svg_generique")) { |
|
| 1392 | + if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1393 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1394 | + } |
|
| 1395 | + else { |
|
| 1396 | + return $themefiles["$subdir$file"] = $f; |
|
| 1397 | + } |
|
| 1398 | + } |
|
| 1399 | + |
|
| 1400 | + $themes = lister_themes_prives(); |
|
| 1401 | + foreach ($themes as $theme) { |
|
| 1402 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1403 | + return $themefiles["$subdir$file"] = $f; |
|
| 1404 | + } |
|
| 1405 | + } |
|
| 1406 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1407 | + |
|
| 1408 | + return $themefiles["$subdir$file"] = ""; |
|
| 1410 | 1409 | } |
| 1411 | 1410 | |
| 1412 | 1411 | |
@@ -1430,28 +1429,28 @@ discard block |
||
| 1430 | 1429 | * sinon chaîne vide. |
| 1431 | 1430 | **/ |
| 1432 | 1431 | function chemin_image($icone) { |
| 1433 | - static $icone_renommer; |
|
| 1434 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1435 | - if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1436 | - return $icone; |
|
| 1437 | - } |
|
| 1438 | - |
|
| 1439 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1440 | - if (preg_match(',[.](png|gif|jpg|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1441 | - return $f; |
|
| 1442 | - } |
|
| 1443 | - // sinon passer par le module de renommage |
|
| 1444 | - if (is_null($icone_renommer)) { |
|
| 1445 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1446 | - } |
|
| 1447 | - if ($icone_renommer) { |
|
| 1448 | - list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1449 | - if (file_exists($icone)) { |
|
| 1450 | - return $icone; |
|
| 1451 | - } |
|
| 1452 | - } |
|
| 1453 | - |
|
| 1454 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1432 | + static $icone_renommer; |
|
| 1433 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1434 | + if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1435 | + return $icone; |
|
| 1436 | + } |
|
| 1437 | + |
|
| 1438 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1439 | + if (preg_match(',[.](png|gif|jpg|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1440 | + return $f; |
|
| 1441 | + } |
|
| 1442 | + // sinon passer par le module de renommage |
|
| 1443 | + if (is_null($icone_renommer)) { |
|
| 1444 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1445 | + } |
|
| 1446 | + if ($icone_renommer) { |
|
| 1447 | + list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1448 | + if (file_exists($icone)) { |
|
| 1449 | + return $icone; |
|
| 1450 | + } |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1455 | 1454 | } |
| 1456 | 1455 | |
| 1457 | 1456 | // |
@@ -1489,123 +1488,123 @@ discard block |
||
| 1489 | 1488 | * - false : fichier introuvable |
| 1490 | 1489 | **/ |
| 1491 | 1490 | function find_in_path($file, $dirname = '', $include = false) { |
| 1492 | - static $dirs = array(); |
|
| 1493 | - static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743 |
|
| 1494 | - static $c = ''; |
|
| 1495 | - |
|
| 1496 | - // on calcule le chemin si le dossier skel a change |
|
| 1497 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1498 | - // assurer le non plantage lors de la montee de version : |
|
| 1499 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1500 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1501 | - } |
|
| 1502 | - |
|
| 1503 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1504 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1505 | - return false; |
|
| 1506 | - } |
|
| 1507 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1508 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1509 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1510 | - } |
|
| 1511 | - |
|
| 1512 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1513 | - } |
|
| 1514 | - |
|
| 1515 | - $a = strrpos($file, '/'); |
|
| 1516 | - if ($a !== false) { |
|
| 1517 | - $dirname .= substr($file, 0, ++$a); |
|
| 1518 | - $file = substr($file, $a); |
|
| 1519 | - } |
|
| 1520 | - |
|
| 1521 | - foreach (creer_chemin() as $dir) { |
|
| 1522 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1523 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1524 | - } |
|
| 1525 | - if ($dirs[$a]) { |
|
| 1526 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1527 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1528 | - include_once _ROOT_CWD . $a; |
|
| 1529 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1530 | - } |
|
| 1531 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1532 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1533 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1534 | - return $a; |
|
| 1535 | - } |
|
| 1536 | - define('_SAUVER_CHEMIN', true); |
|
| 1537 | - } |
|
| 1538 | - |
|
| 1539 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1540 | - } |
|
| 1541 | - } |
|
| 1542 | - } |
|
| 1543 | - |
|
| 1544 | - if ($include) { |
|
| 1545 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1546 | - if ($include === 'required') { |
|
| 1547 | - echo '<pre>', |
|
| 1548 | - "<strong>Erreur Fatale</strong><br />"; |
|
| 1549 | - if (function_exists('debug_print_backtrace')) { |
|
| 1550 | - echo debug_print_backtrace(); |
|
| 1551 | - } |
|
| 1552 | - echo '</pre>'; |
|
| 1553 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1554 | - } |
|
| 1555 | - } |
|
| 1556 | - |
|
| 1557 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1558 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1559 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1560 | - return false; |
|
| 1561 | - } |
|
| 1562 | - define('_SAUVER_CHEMIN', true); |
|
| 1563 | - } |
|
| 1564 | - |
|
| 1565 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1491 | + static $dirs = array(); |
|
| 1492 | + static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743 |
|
| 1493 | + static $c = ''; |
|
| 1494 | + |
|
| 1495 | + // on calcule le chemin si le dossier skel a change |
|
| 1496 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1497 | + // assurer le non plantage lors de la montee de version : |
|
| 1498 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1499 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1500 | + } |
|
| 1501 | + |
|
| 1502 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1503 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1504 | + return false; |
|
| 1505 | + } |
|
| 1506 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1507 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1508 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1509 | + } |
|
| 1510 | + |
|
| 1511 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1512 | + } |
|
| 1513 | + |
|
| 1514 | + $a = strrpos($file, '/'); |
|
| 1515 | + if ($a !== false) { |
|
| 1516 | + $dirname .= substr($file, 0, ++$a); |
|
| 1517 | + $file = substr($file, $a); |
|
| 1518 | + } |
|
| 1519 | + |
|
| 1520 | + foreach (creer_chemin() as $dir) { |
|
| 1521 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1522 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1523 | + } |
|
| 1524 | + if ($dirs[$a]) { |
|
| 1525 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1526 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1527 | + include_once _ROOT_CWD . $a; |
|
| 1528 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1529 | + } |
|
| 1530 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1531 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1532 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1533 | + return $a; |
|
| 1534 | + } |
|
| 1535 | + define('_SAUVER_CHEMIN', true); |
|
| 1536 | + } |
|
| 1537 | + |
|
| 1538 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1539 | + } |
|
| 1540 | + } |
|
| 1541 | + } |
|
| 1542 | + |
|
| 1543 | + if ($include) { |
|
| 1544 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1545 | + if ($include === 'required') { |
|
| 1546 | + echo '<pre>', |
|
| 1547 | + "<strong>Erreur Fatale</strong><br />"; |
|
| 1548 | + if (function_exists('debug_print_backtrace')) { |
|
| 1549 | + echo debug_print_backtrace(); |
|
| 1550 | + } |
|
| 1551 | + echo '</pre>'; |
|
| 1552 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1553 | + } |
|
| 1554 | + } |
|
| 1555 | + |
|
| 1556 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1557 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1558 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1559 | + return false; |
|
| 1560 | + } |
|
| 1561 | + define('_SAUVER_CHEMIN', true); |
|
| 1562 | + } |
|
| 1563 | + |
|
| 1564 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1566 | 1565 | } |
| 1567 | 1566 | |
| 1568 | 1567 | function clear_path_cache() { |
| 1569 | - $GLOBALS['path_files'] = array(); |
|
| 1570 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1568 | + $GLOBALS['path_files'] = array(); |
|
| 1569 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1571 | 1570 | } |
| 1572 | 1571 | |
| 1573 | 1572 | function load_path_cache() { |
| 1574 | - // charger le path des plugins |
|
| 1575 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1576 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1577 | - } |
|
| 1578 | - $GLOBALS['path_files'] = array(); |
|
| 1579 | - // si le visiteur est admin, |
|
| 1580 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1581 | - if ( |
|
| 1582 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1583 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1584 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1585 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1586 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1587 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1588 | - !_request('var_mode') |
|
| 1589 | - ) { |
|
| 1590 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1591 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1592 | - // mais si semble corrompu on relit avec un verrou |
|
| 1593 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1594 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1595 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1596 | - $GLOBALS['path_files'] = array(); |
|
| 1597 | - } |
|
| 1598 | - } |
|
| 1599 | - } |
|
| 1600 | - } |
|
| 1573 | + // charger le path des plugins |
|
| 1574 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1575 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1576 | + } |
|
| 1577 | + $GLOBALS['path_files'] = array(); |
|
| 1578 | + // si le visiteur est admin, |
|
| 1579 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1580 | + if ( |
|
| 1581 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1582 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1583 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1584 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1585 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1586 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1587 | + !_request('var_mode') |
|
| 1588 | + ) { |
|
| 1589 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1590 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1591 | + // mais si semble corrompu on relit avec un verrou |
|
| 1592 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1593 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1594 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1595 | + $GLOBALS['path_files'] = array(); |
|
| 1596 | + } |
|
| 1597 | + } |
|
| 1598 | + } |
|
| 1599 | + } |
|
| 1601 | 1600 | } |
| 1602 | 1601 | |
| 1603 | 1602 | function save_path_cache() { |
| 1604 | - if (defined('_SAUVER_CHEMIN') |
|
| 1605 | - and _SAUVER_CHEMIN |
|
| 1606 | - ) { |
|
| 1607 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1608 | - } |
|
| 1603 | + if (defined('_SAUVER_CHEMIN') |
|
| 1604 | + and _SAUVER_CHEMIN |
|
| 1605 | + ) { |
|
| 1606 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1607 | + } |
|
| 1609 | 1608 | } |
| 1610 | 1609 | |
| 1611 | 1610 | |
@@ -1625,33 +1624,33 @@ discard block |
||
| 1625 | 1624 | * @return array |
| 1626 | 1625 | */ |
| 1627 | 1626 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1628 | - $liste_fichiers = array(); |
|
| 1629 | - $maxfiles = 10000; |
|
| 1630 | - |
|
| 1631 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1632 | - // on a pas encore inclus flock.php |
|
| 1633 | - if (!function_exists('preg_files')) { |
|
| 1634 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - // Parcourir le chemin |
|
| 1638 | - foreach (creer_chemin() as $d) { |
|
| 1639 | - $f = $d . $dir; |
|
| 1640 | - if (@is_dir($f)) { |
|
| 1641 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1642 | - foreach ($liste as $chemin) { |
|
| 1643 | - $nom = basename($chemin); |
|
| 1644 | - // ne prendre que les fichiers pas deja trouves |
|
| 1645 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1646 | - // les autres sont donc masques |
|
| 1647 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1648 | - $liste_fichiers[$nom] = $chemin; |
|
| 1649 | - } |
|
| 1650 | - } |
|
| 1651 | - } |
|
| 1652 | - } |
|
| 1653 | - |
|
| 1654 | - return $liste_fichiers; |
|
| 1627 | + $liste_fichiers = array(); |
|
| 1628 | + $maxfiles = 10000; |
|
| 1629 | + |
|
| 1630 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1631 | + // on a pas encore inclus flock.php |
|
| 1632 | + if (!function_exists('preg_files')) { |
|
| 1633 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1634 | + } |
|
| 1635 | + |
|
| 1636 | + // Parcourir le chemin |
|
| 1637 | + foreach (creer_chemin() as $d) { |
|
| 1638 | + $f = $d . $dir; |
|
| 1639 | + if (@is_dir($f)) { |
|
| 1640 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1641 | + foreach ($liste as $chemin) { |
|
| 1642 | + $nom = basename($chemin); |
|
| 1643 | + // ne prendre que les fichiers pas deja trouves |
|
| 1644 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1645 | + // les autres sont donc masques |
|
| 1646 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1647 | + $liste_fichiers[$nom] = $chemin; |
|
| 1648 | + } |
|
| 1649 | + } |
|
| 1650 | + } |
|
| 1651 | + } |
|
| 1652 | + |
|
| 1653 | + return $liste_fichiers; |
|
| 1655 | 1654 | } |
| 1656 | 1655 | |
| 1657 | 1656 | /** |
@@ -1663,17 +1662,17 @@ discard block |
||
| 1663 | 1662 | * @return bool |
| 1664 | 1663 | */ |
| 1665 | 1664 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1666 | - static $autsanscookie = array('install', 'base_repair'); |
|
| 1665 | + static $autsanscookie = array('install', 'base_repair'); |
|
| 1667 | 1666 | |
| 1668 | - if (in_array($nom, $autsanscookie)) { |
|
| 1669 | - if (test_espace_prive()){ |
|
| 1670 | - include_spip('base/connect_sql'); |
|
| 1671 | - if (!$strict or !spip_connect()){ |
|
| 1672 | - return true; |
|
| 1673 | - } |
|
| 1674 | - } |
|
| 1675 | - } |
|
| 1676 | - return false; |
|
| 1667 | + if (in_array($nom, $autsanscookie)) { |
|
| 1668 | + if (test_espace_prive()){ |
|
| 1669 | + include_spip('base/connect_sql'); |
|
| 1670 | + if (!$strict or !spip_connect()){ |
|
| 1671 | + return true; |
|
| 1672 | + } |
|
| 1673 | + } |
|
| 1674 | + } |
|
| 1675 | + return false; |
|
| 1677 | 1676 | } |
| 1678 | 1677 | |
| 1679 | 1678 | /** |
@@ -1699,99 +1698,99 @@ discard block |
||
| 1699 | 1698 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip) |
| 1700 | 1699 | */ |
| 1701 | 1700 | function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1702 | - if ($public === null) { |
|
| 1703 | - $public = !test_espace_prive(); |
|
| 1704 | - } |
|
| 1705 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1706 | - |
|
| 1707 | - if (!$public) { |
|
| 1708 | - if (!$entite) { |
|
| 1709 | - return ''; |
|
| 1710 | - } |
|
| 1711 | - if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1712 | - include_spip('inc/urls'); |
|
| 1713 | - } |
|
| 1714 | - $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1715 | - } else { |
|
| 1716 | - if ($type === null) { |
|
| 1717 | - $type = (isset($GLOBALS['type_urls'])) |
|
| 1718 | - ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1719 | - : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1720 | - ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1721 | - } |
|
| 1722 | - |
|
| 1723 | - $f = charger_fonction($type, 'urls', true); |
|
| 1724 | - // se rabattre sur les urls page si les urls perso non dispo |
|
| 1725 | - if (!$f) { |
|
| 1726 | - $f = charger_fonction('page', 'urls', true); |
|
| 1727 | - } |
|
| 1728 | - |
|
| 1729 | - // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1730 | - // sinon on veut effectuer le passage id ==> URL |
|
| 1731 | - if (!$entite) { |
|
| 1732 | - return $f; |
|
| 1733 | - } |
|
| 1734 | - |
|
| 1735 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1736 | - // base distante |
|
| 1737 | - if (is_string($public) |
|
| 1738 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1739 | - ) { |
|
| 1740 | - $f = $g; |
|
| 1741 | - } |
|
| 1742 | - |
|
| 1743 | - $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1744 | - |
|
| 1745 | - } |
|
| 1746 | - if ($res) { |
|
| 1747 | - return $res; |
|
| 1748 | - } |
|
| 1749 | - // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1750 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1751 | - if (!function_exists($f .= '_dist')) { |
|
| 1752 | - $f = ''; |
|
| 1753 | - } |
|
| 1754 | - } |
|
| 1755 | - if ($f) { |
|
| 1756 | - $url = $f($id, $args, $ancre); |
|
| 1757 | - if (strlen($args)) { |
|
| 1758 | - $url .= strstr($url, '?') |
|
| 1759 | - ? '&' . $args |
|
| 1760 | - : '?' . $args; |
|
| 1761 | - } |
|
| 1762 | - |
|
| 1763 | - return $url; |
|
| 1764 | - } |
|
| 1765 | - // On a ete gentil mais la .... |
|
| 1766 | - spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1767 | - |
|
| 1768 | - return ''; |
|
| 1701 | + if ($public === null) { |
|
| 1702 | + $public = !test_espace_prive(); |
|
| 1703 | + } |
|
| 1704 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1705 | + |
|
| 1706 | + if (!$public) { |
|
| 1707 | + if (!$entite) { |
|
| 1708 | + return ''; |
|
| 1709 | + } |
|
| 1710 | + if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1711 | + include_spip('inc/urls'); |
|
| 1712 | + } |
|
| 1713 | + $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1714 | + } else { |
|
| 1715 | + if ($type === null) { |
|
| 1716 | + $type = (isset($GLOBALS['type_urls'])) |
|
| 1717 | + ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1718 | + : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1719 | + ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1720 | + } |
|
| 1721 | + |
|
| 1722 | + $f = charger_fonction($type, 'urls', true); |
|
| 1723 | + // se rabattre sur les urls page si les urls perso non dispo |
|
| 1724 | + if (!$f) { |
|
| 1725 | + $f = charger_fonction('page', 'urls', true); |
|
| 1726 | + } |
|
| 1727 | + |
|
| 1728 | + // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1729 | + // sinon on veut effectuer le passage id ==> URL |
|
| 1730 | + if (!$entite) { |
|
| 1731 | + return $f; |
|
| 1732 | + } |
|
| 1733 | + |
|
| 1734 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1735 | + // base distante |
|
| 1736 | + if (is_string($public) |
|
| 1737 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1738 | + ) { |
|
| 1739 | + $f = $g; |
|
| 1740 | + } |
|
| 1741 | + |
|
| 1742 | + $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1743 | + |
|
| 1744 | + } |
|
| 1745 | + if ($res) { |
|
| 1746 | + return $res; |
|
| 1747 | + } |
|
| 1748 | + // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1749 | + if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1750 | + if (!function_exists($f .= '_dist')) { |
|
| 1751 | + $f = ''; |
|
| 1752 | + } |
|
| 1753 | + } |
|
| 1754 | + if ($f) { |
|
| 1755 | + $url = $f($id, $args, $ancre); |
|
| 1756 | + if (strlen($args)) { |
|
| 1757 | + $url .= strstr($url, '?') |
|
| 1758 | + ? '&' . $args |
|
| 1759 | + : '?' . $args; |
|
| 1760 | + } |
|
| 1761 | + |
|
| 1762 | + return $url; |
|
| 1763 | + } |
|
| 1764 | + // On a ete gentil mais la .... |
|
| 1765 | + spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1766 | + |
|
| 1767 | + return ''; |
|
| 1769 | 1768 | } |
| 1770 | 1769 | |
| 1771 | 1770 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 1772 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1773 | - $url = generer_url_ecrire($exec, $args); |
|
| 1774 | - if (intval($id)) { |
|
| 1775 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1776 | - } else { |
|
| 1777 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1778 | - } |
|
| 1779 | - if ($ancre) { |
|
| 1780 | - $url = ancre_url($url, $ancre); |
|
| 1781 | - } |
|
| 1771 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1772 | + $url = generer_url_ecrire($exec, $args); |
|
| 1773 | + if (intval($id)) { |
|
| 1774 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1775 | + } else { |
|
| 1776 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1777 | + } |
|
| 1778 | + if ($ancre) { |
|
| 1779 | + $url = ancre_url($url, $ancre); |
|
| 1780 | + } |
|
| 1782 | 1781 | |
| 1783 | - return $url; |
|
| 1782 | + return $url; |
|
| 1784 | 1783 | } |
| 1785 | 1784 | |
| 1786 | 1785 | // http://code.spip.net/@urls_connect_dist |
| 1787 | 1786 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1788 | - include_spip('base/connect_sql'); |
|
| 1789 | - $id_type = id_table_objet($entite, $public); |
|
| 1787 | + include_spip('base/connect_sql'); |
|
| 1788 | + $id_type = id_table_objet($entite, $public); |
|
| 1790 | 1789 | |
| 1791 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1792 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1793 | - . (!$args ? '' : "&$args") |
|
| 1794 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1790 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1791 | + . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1792 | + . (!$args ? '' : "&$args") |
|
| 1793 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1795 | 1794 | } |
| 1796 | 1795 | |
| 1797 | 1796 | |
@@ -1802,32 +1801,32 @@ discard block |
||
| 1802 | 1801 | * @return string |
| 1803 | 1802 | */ |
| 1804 | 1803 | function urlencode_1738($url) { |
| 1805 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1806 | - $uri = ''; |
|
| 1807 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1808 | - if (ord($a = $url[$i]) > 127) { |
|
| 1809 | - $a = rawurlencode($a); |
|
| 1810 | - } |
|
| 1811 | - $uri .= $a; |
|
| 1812 | - } |
|
| 1813 | - $url = $uri; |
|
| 1814 | - } |
|
| 1804 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1805 | + $uri = ''; |
|
| 1806 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1807 | + if (ord($a = $url[$i]) > 127) { |
|
| 1808 | + $a = rawurlencode($a); |
|
| 1809 | + } |
|
| 1810 | + $uri .= $a; |
|
| 1811 | + } |
|
| 1812 | + $url = $uri; |
|
| 1813 | + } |
|
| 1815 | 1814 | |
| 1816 | - return quote_amp($url); |
|
| 1815 | + return quote_amp($url); |
|
| 1817 | 1816 | } |
| 1818 | 1817 | |
| 1819 | 1818 | // http://code.spip.net/@generer_url_entite_absolue |
| 1820 | 1819 | function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { |
| 1821 | - if (!$connect) { |
|
| 1822 | - $connect = true; |
|
| 1823 | - } |
|
| 1824 | - $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1825 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1826 | - include_spip('inc/filtres_mini'); |
|
| 1827 | - $h = url_absolue($h); |
|
| 1828 | - } |
|
| 1820 | + if (!$connect) { |
|
| 1821 | + $connect = true; |
|
| 1822 | + } |
|
| 1823 | + $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1824 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1825 | + include_spip('inc/filtres_mini'); |
|
| 1826 | + $h = url_absolue($h); |
|
| 1827 | + } |
|
| 1829 | 1828 | |
| 1830 | - return $h; |
|
| 1829 | + return $h; |
|
| 1831 | 1830 | } |
| 1832 | 1831 | |
| 1833 | 1832 | |
@@ -1843,11 +1842,11 @@ discard block |
||
| 1843 | 1842 | * true si la valeur est considérée active ; false sinon. |
| 1844 | 1843 | **/ |
| 1845 | 1844 | function test_valeur_serveur($truc) { |
| 1846 | - if (!$truc) { |
|
| 1847 | - return false; |
|
| 1848 | - } |
|
| 1845 | + if (!$truc) { |
|
| 1846 | + return false; |
|
| 1847 | + } |
|
| 1849 | 1848 | |
| 1850 | - return (strtolower($truc) !== 'off'); |
|
| 1849 | + return (strtolower($truc) !== 'off'); |
|
| 1851 | 1850 | } |
| 1852 | 1851 | |
| 1853 | 1852 | // |
@@ -1875,80 +1874,80 @@ discard block |
||
| 1875 | 1874 | */ |
| 1876 | 1875 | function url_de_base($profondeur = null) { |
| 1877 | 1876 | |
| 1878 | - static $url = array(); |
|
| 1879 | - if (is_array($profondeur)) { |
|
| 1880 | - return $url = $profondeur; |
|
| 1881 | - } |
|
| 1882 | - if ($profondeur === false) { |
|
| 1883 | - return $url; |
|
| 1884 | - } |
|
| 1885 | - |
|
| 1886 | - if (is_null($profondeur)) { |
|
| 1887 | - $profondeur = $GLOBALS['profondeur_url']; |
|
| 1888 | - } |
|
| 1889 | - |
|
| 1890 | - if (isset($url[$profondeur])) { |
|
| 1891 | - return $url[$profondeur]; |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - $http = 'http'; |
|
| 1895 | - |
|
| 1896 | - if ( |
|
| 1897 | - isset($_SERVER["SCRIPT_URI"]) |
|
| 1898 | - and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1899 | - ) { |
|
| 1900 | - $http = 'https'; |
|
| 1901 | - } elseif ( |
|
| 1902 | - isset($_SERVER['HTTPS']) |
|
| 1903 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1904 | - ) { |
|
| 1905 | - $http = 'https'; |
|
| 1906 | - } |
|
| 1907 | - |
|
| 1908 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 1909 | - $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1910 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1911 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1912 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 1913 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1914 | - $http = $scheme; |
|
| 1915 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 1916 | - } |
|
| 1917 | - } |
|
| 1918 | - if (isset($_SERVER['SERVER_PORT']) |
|
| 1919 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 1920 | - and strpos($host, ":") == false |
|
| 1921 | - ) { |
|
| 1922 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1923 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 1924 | - } |
|
| 1925 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 1926 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 1927 | - } |
|
| 1928 | - if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 1929 | - $host .= ":$port"; |
|
| 1930 | - } |
|
| 1931 | - if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 1932 | - $host .= ":$port"; |
|
| 1933 | - } |
|
| 1934 | - } |
|
| 1935 | - |
|
| 1936 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 1937 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 1938 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 1939 | - } else { |
|
| 1940 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 1941 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 1942 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 1943 | - ) { |
|
| 1944 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 1945 | - } |
|
| 1946 | - } |
|
| 1947 | - } |
|
| 1948 | - |
|
| 1949 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 1950 | - |
|
| 1951 | - return $url[$profondeur]; |
|
| 1877 | + static $url = array(); |
|
| 1878 | + if (is_array($profondeur)) { |
|
| 1879 | + return $url = $profondeur; |
|
| 1880 | + } |
|
| 1881 | + if ($profondeur === false) { |
|
| 1882 | + return $url; |
|
| 1883 | + } |
|
| 1884 | + |
|
| 1885 | + if (is_null($profondeur)) { |
|
| 1886 | + $profondeur = $GLOBALS['profondeur_url']; |
|
| 1887 | + } |
|
| 1888 | + |
|
| 1889 | + if (isset($url[$profondeur])) { |
|
| 1890 | + return $url[$profondeur]; |
|
| 1891 | + } |
|
| 1892 | + |
|
| 1893 | + $http = 'http'; |
|
| 1894 | + |
|
| 1895 | + if ( |
|
| 1896 | + isset($_SERVER["SCRIPT_URI"]) |
|
| 1897 | + and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1898 | + ) { |
|
| 1899 | + $http = 'https'; |
|
| 1900 | + } elseif ( |
|
| 1901 | + isset($_SERVER['HTTPS']) |
|
| 1902 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1903 | + ) { |
|
| 1904 | + $http = 'https'; |
|
| 1905 | + } |
|
| 1906 | + |
|
| 1907 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 1908 | + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1909 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1910 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1911 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 1912 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1913 | + $http = $scheme; |
|
| 1914 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 1915 | + } |
|
| 1916 | + } |
|
| 1917 | + if (isset($_SERVER['SERVER_PORT']) |
|
| 1918 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 1919 | + and strpos($host, ":") == false |
|
| 1920 | + ) { |
|
| 1921 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1922 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 1923 | + } |
|
| 1924 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 1925 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 1926 | + } |
|
| 1927 | + if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 1928 | + $host .= ":$port"; |
|
| 1929 | + } |
|
| 1930 | + if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 1931 | + $host .= ":$port"; |
|
| 1932 | + } |
|
| 1933 | + } |
|
| 1934 | + |
|
| 1935 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 1936 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 1937 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 1938 | + } else { |
|
| 1939 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 1940 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 1941 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 1942 | + ) { |
|
| 1943 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 1944 | + } |
|
| 1945 | + } |
|
| 1946 | + } |
|
| 1947 | + |
|
| 1948 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 1949 | + |
|
| 1950 | + return $url[$profondeur]; |
|
| 1952 | 1951 | } |
| 1953 | 1952 | |
| 1954 | 1953 | /** |
@@ -1961,26 +1960,26 @@ discard block |
||
| 1961 | 1960 | * @return string |
| 1962 | 1961 | */ |
| 1963 | 1962 | function url_de_($http, $host, $request, $prof = 0) { |
| 1964 | - $prof = max($prof, 0); |
|
| 1963 | + $prof = max($prof, 0); |
|
| 1965 | 1964 | |
| 1966 | - $myself = ltrim($request, '/'); |
|
| 1967 | - # supprimer la chaine de GET |
|
| 1968 | - list($myself) = explode('?', $myself); |
|
| 1969 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 1970 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 1971 | - if (strpos($myself,'://') !== false) { |
|
| 1972 | - $myself = explode('://',$myself); |
|
| 1973 | - array_shift($myself); |
|
| 1974 | - $myself = implode('://',$myself); |
|
| 1975 | - $myself = explode('/',$myself); |
|
| 1976 | - array_shift($myself); |
|
| 1977 | - $myself = implode('/',$myself); |
|
| 1978 | - } |
|
| 1979 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 1965 | + $myself = ltrim($request, '/'); |
|
| 1966 | + # supprimer la chaine de GET |
|
| 1967 | + list($myself) = explode('?', $myself); |
|
| 1968 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 1969 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 1970 | + if (strpos($myself,'://') !== false) { |
|
| 1971 | + $myself = explode('://',$myself); |
|
| 1972 | + array_shift($myself); |
|
| 1973 | + $myself = implode('://',$myself); |
|
| 1974 | + $myself = explode('/',$myself); |
|
| 1975 | + array_shift($myself); |
|
| 1976 | + $myself = implode('/',$myself); |
|
| 1977 | + } |
|
| 1978 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 1980 | 1979 | |
| 1981 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 1980 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 1982 | 1981 | |
| 1983 | - return $url; |
|
| 1982 | + return $url; |
|
| 1984 | 1983 | } |
| 1985 | 1984 | |
| 1986 | 1985 | |
@@ -2015,26 +2014,26 @@ discard block |
||
| 2015 | 2014 | * @return string URL |
| 2016 | 2015 | **/ |
| 2017 | 2016 | function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
| 2018 | - if (!$rel) { |
|
| 2019 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2020 | - } else { |
|
| 2021 | - if (!is_string($rel)) { |
|
| 2022 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2023 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2024 | - } |
|
| 2025 | - } |
|
| 2026 | - |
|
| 2027 | - list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2028 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2029 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2030 | - } elseif ($args) { |
|
| 2031 | - $args = "?$args"; |
|
| 2032 | - } |
|
| 2033 | - if ($ancre) { |
|
| 2034 | - $args .= "#$ancre"; |
|
| 2035 | - } |
|
| 2036 | - |
|
| 2037 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2017 | + if (!$rel) { |
|
| 2018 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2019 | + } else { |
|
| 2020 | + if (!is_string($rel)) { |
|
| 2021 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2022 | + ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2023 | + } |
|
| 2024 | + } |
|
| 2025 | + |
|
| 2026 | + list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2027 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2028 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2029 | + } elseif ($args) { |
|
| 2030 | + $args = "?$args"; |
|
| 2031 | + } |
|
| 2032 | + if ($ancre) { |
|
| 2033 | + $args .= "#$ancre"; |
|
| 2034 | + } |
|
| 2035 | + |
|
| 2036 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2038 | 2037 | } |
| 2039 | 2038 | |
| 2040 | 2039 | // |
@@ -2056,12 +2055,12 @@ discard block |
||
| 2056 | 2055 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2057 | 2056 | **/ |
| 2058 | 2057 | function get_spip_script($default = '') { |
| 2059 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2060 | - if (_SPIP_SCRIPT) { |
|
| 2061 | - return _SPIP_SCRIPT; |
|
| 2062 | - } else { |
|
| 2063 | - return $default; |
|
| 2064 | - } |
|
| 2058 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2059 | + if (_SPIP_SCRIPT) { |
|
| 2060 | + return _SPIP_SCRIPT; |
|
| 2061 | + } else { |
|
| 2062 | + return $default; |
|
| 2063 | + } |
|
| 2065 | 2064 | } |
| 2066 | 2065 | |
| 2067 | 2066 | /** |
@@ -2090,39 +2089,39 @@ discard block |
||
| 2090 | 2089 | * @return string URL |
| 2091 | 2090 | **/ |
| 2092 | 2091 | function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') { |
| 2093 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2094 | - // standardiser vers la nouvelle API |
|
| 2095 | - |
|
| 2096 | - if (!$action) { |
|
| 2097 | - $action = get_spip_script(); |
|
| 2098 | - } |
|
| 2099 | - if ($script) { |
|
| 2100 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2101 | - } |
|
| 2102 | - |
|
| 2103 | - if ($args) { |
|
| 2104 | - if (is_array($args)) { |
|
| 2105 | - $r = ''; |
|
| 2106 | - foreach ($args as $k => $v) { |
|
| 2107 | - $r .= '&' . $k . '=' . $v; |
|
| 2108 | - } |
|
| 2109 | - $args = substr($r, 1); |
|
| 2110 | - } |
|
| 2111 | - $action .= |
|
| 2112 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2113 | - } |
|
| 2114 | - if (!$no_entities) { |
|
| 2115 | - $action = quote_amp($action); |
|
| 2116 | - } |
|
| 2117 | - |
|
| 2118 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2119 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2092 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2093 | + // standardiser vers la nouvelle API |
|
| 2094 | + |
|
| 2095 | + if (!$action) { |
|
| 2096 | + $action = get_spip_script(); |
|
| 2097 | + } |
|
| 2098 | + if ($script) { |
|
| 2099 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2100 | + } |
|
| 2101 | + |
|
| 2102 | + if ($args) { |
|
| 2103 | + if (is_array($args)) { |
|
| 2104 | + $r = ''; |
|
| 2105 | + foreach ($args as $k => $v) { |
|
| 2106 | + $r .= '&' . $k . '=' . $v; |
|
| 2107 | + } |
|
| 2108 | + $args = substr($r, 1); |
|
| 2109 | + } |
|
| 2110 | + $action .= |
|
| 2111 | + (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2112 | + } |
|
| 2113 | + if (!$no_entities) { |
|
| 2114 | + $action = quote_amp($action); |
|
| 2115 | + } |
|
| 2116 | + |
|
| 2117 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2118 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2120 | 2119 | } |
| 2121 | 2120 | |
| 2122 | 2121 | // http://code.spip.net/@generer_url_prive |
| 2123 | 2122 | function generer_url_prive($script, $args = "", $no_entities = false) { |
| 2124 | 2123 | |
| 2125 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2124 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2126 | 2125 | } |
| 2127 | 2126 | |
| 2128 | 2127 | // Pour les formulaires en methode POST, |
@@ -2147,19 +2146,19 @@ discard block |
||
| 2147 | 2146 | **/ |
| 2148 | 2147 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2149 | 2148 | |
| 2150 | - $script1 = explode('&', $script); |
|
| 2151 | - $script1 = reset($script1); |
|
| 2149 | + $script1 = explode('&', $script); |
|
| 2150 | + $script1 = reset($script1); |
|
| 2152 | 2151 | |
| 2153 | - return "<form action='" |
|
| 2154 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2155 | - . "' " |
|
| 2156 | - . ($atts ? $atts : " method='post'") |
|
| 2157 | - . "><div>\n" |
|
| 2158 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2159 | - . $corps |
|
| 2160 | - . (!$submit ? '' : |
|
| 2161 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2162 | - . "</div></form>\n"; |
|
| 2152 | + return "<form action='" |
|
| 2153 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2154 | + . "' " |
|
| 2155 | + . ($atts ? $atts : " method='post'") |
|
| 2156 | + . "><div>\n" |
|
| 2157 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2158 | + . $corps |
|
| 2159 | + . (!$submit ? '' : |
|
| 2160 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2161 | + . "</div></form>\n"; |
|
| 2163 | 2162 | } |
| 2164 | 2163 | |
| 2165 | 2164 | /** |
@@ -2176,22 +2175,22 @@ discard block |
||
| 2176 | 2175 | * @return string |
| 2177 | 2176 | */ |
| 2178 | 2177 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2179 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2180 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2181 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2182 | - $h = (_DIR_RACINE and !$public) |
|
| 2183 | - ? generer_url_ecrire(_request('exec')) |
|
| 2184 | - : generer_url_public(); |
|
| 2178 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2179 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2180 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2181 | + $h = (_DIR_RACINE and !$public) |
|
| 2182 | + ? generer_url_ecrire(_request('exec')) |
|
| 2183 | + : generer_url_public(); |
|
| 2185 | 2184 | |
| 2186 | - return "\n<form action='" . |
|
| 2187 | - $h . |
|
| 2188 | - "'" . |
|
| 2189 | - $atts . |
|
| 2190 | - ">\n" . |
|
| 2191 | - "<div>" . |
|
| 2192 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2193 | - $corps . |
|
| 2194 | - "</div></form>"; |
|
| 2185 | + return "\n<form action='" . |
|
| 2186 | + $h . |
|
| 2187 | + "'" . |
|
| 2188 | + $atts . |
|
| 2189 | + ">\n" . |
|
| 2190 | + "<div>" . |
|
| 2191 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2192 | + $corps . |
|
| 2193 | + "</div></form>"; |
|
| 2195 | 2194 | } |
| 2196 | 2195 | |
| 2197 | 2196 | /** |
@@ -2210,22 +2209,22 @@ discard block |
||
| 2210 | 2209 | * URL |
| 2211 | 2210 | */ |
| 2212 | 2211 | function generer_url_action($script, $args = "", $no_entities = false, $public = false) { |
| 2213 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2214 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2215 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2216 | - $url = (_DIR_RACINE and !$public) |
|
| 2217 | - ? generer_url_ecrire(_request('exec')) |
|
| 2218 | - : generer_url_public('', '', false, false); |
|
| 2219 | - $url = parametre_url($url, 'action', $script); |
|
| 2220 | - if ($args) { |
|
| 2221 | - $url .= quote_amp('&' . $args); |
|
| 2222 | - } |
|
| 2212 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2213 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2214 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2215 | + $url = (_DIR_RACINE and !$public) |
|
| 2216 | + ? generer_url_ecrire(_request('exec')) |
|
| 2217 | + : generer_url_public('', '', false, false); |
|
| 2218 | + $url = parametre_url($url, 'action', $script); |
|
| 2219 | + if ($args) { |
|
| 2220 | + $url .= quote_amp('&' . $args); |
|
| 2221 | + } |
|
| 2223 | 2222 | |
| 2224 | - if ($no_entities) { |
|
| 2225 | - $url = str_replace('&', '&', $url); |
|
| 2226 | - } |
|
| 2223 | + if ($no_entities) { |
|
| 2224 | + $url = str_replace('&', '&', $url); |
|
| 2225 | + } |
|
| 2227 | 2226 | |
| 2228 | - return $url; |
|
| 2227 | + return $url; |
|
| 2229 | 2228 | } |
| 2230 | 2229 | |
| 2231 | 2230 | |
@@ -2238,8 +2237,8 @@ discard block |
||
| 2238 | 2237 | * @param string $ta Répertoire temporaire accessible |
| 2239 | 2238 | */ |
| 2240 | 2239 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2241 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2242 | - spip_initialisation_suite(); |
|
| 2240 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2241 | + spip_initialisation_suite(); |
|
| 2243 | 2242 | } |
| 2244 | 2243 | |
| 2245 | 2244 | /** |
@@ -2259,315 +2258,315 @@ discard block |
||
| 2259 | 2258 | * @param string $ta Répertoire temporaire accessible |
| 2260 | 2259 | */ |
| 2261 | 2260 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2262 | - static $too_late = 0; |
|
| 2263 | - if ($too_late++) { |
|
| 2264 | - return; |
|
| 2265 | - } |
|
| 2266 | - |
|
| 2267 | - // Declaration des repertoires |
|
| 2268 | - |
|
| 2269 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2270 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2271 | - define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2272 | - } |
|
| 2273 | - |
|
| 2274 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2275 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2276 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2277 | - } |
|
| 2278 | - |
|
| 2279 | - // le nom du repertoire des librairies |
|
| 2280 | - if (!defined('_DIR_LIB')) { |
|
| 2281 | - define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2282 | - } |
|
| 2283 | - |
|
| 2284 | - if (!defined('_DIR_IMG')) { |
|
| 2285 | - define('_DIR_IMG', $pa); |
|
| 2286 | - } |
|
| 2287 | - if (!defined('_DIR_LOGOS')) { |
|
| 2288 | - define('_DIR_LOGOS', $pa); |
|
| 2289 | - } |
|
| 2290 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2291 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2292 | - } |
|
| 2293 | - |
|
| 2294 | - if (!defined('_DIR_DUMP')) { |
|
| 2295 | - define('_DIR_DUMP', $ti . "dump/"); |
|
| 2296 | - } |
|
| 2297 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2298 | - define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2299 | - } |
|
| 2300 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2301 | - define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2302 | - } |
|
| 2303 | - if (!defined('_DIR_CACHE')) { |
|
| 2304 | - define('_DIR_CACHE', $ti . "cache/"); |
|
| 2305 | - } |
|
| 2306 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2307 | - define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2308 | - } |
|
| 2309 | - if (!defined('_DIR_SKELS')) { |
|
| 2310 | - define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2311 | - } |
|
| 2312 | - if (!defined('_DIR_AIDE')) { |
|
| 2313 | - define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2314 | - } |
|
| 2315 | - if (!defined('_DIR_TMP')) { |
|
| 2316 | - define('_DIR_TMP', $ti); |
|
| 2317 | - } |
|
| 2318 | - |
|
| 2319 | - if (!defined('_DIR_VAR')) { |
|
| 2320 | - define('_DIR_VAR', $ta); |
|
| 2321 | - } |
|
| 2322 | - |
|
| 2323 | - if (!defined('_DIR_ETC')) { |
|
| 2324 | - define('_DIR_ETC', $pi); |
|
| 2325 | - } |
|
| 2326 | - if (!defined('_DIR_CONNECT')) { |
|
| 2327 | - define('_DIR_CONNECT', $pi); |
|
| 2328 | - } |
|
| 2329 | - if (!defined('_DIR_CHMOD')) { |
|
| 2330 | - define('_DIR_CHMOD', $pi); |
|
| 2331 | - } |
|
| 2332 | - |
|
| 2333 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 2334 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2335 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2336 | - { |
|
| 2337 | - $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2338 | - } |
|
| 2339 | - |
|
| 2340 | - // Declaration des fichiers |
|
| 2341 | - |
|
| 2342 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2343 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2344 | - } |
|
| 2345 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2346 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2347 | - } |
|
| 2348 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2349 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2350 | - } |
|
| 2351 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2352 | - define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2353 | - } |
|
| 2354 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2355 | - define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2356 | - } |
|
| 2357 | - |
|
| 2358 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2359 | - if (!defined('_FILE_META')) { |
|
| 2360 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2361 | - } |
|
| 2362 | - if (!defined('_DIR_LOG')) { |
|
| 2363 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2364 | - } |
|
| 2365 | - if (!defined('_FILE_LOG')) { |
|
| 2366 | - define('_FILE_LOG', 'spip'); |
|
| 2367 | - } |
|
| 2368 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2369 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2370 | - } |
|
| 2371 | - |
|
| 2372 | - // Le fichier de connexion a la base de donnees |
|
| 2373 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2374 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2375 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2376 | - } |
|
| 2377 | - if (!defined('_FILE_CONNECT')) { |
|
| 2378 | - define('_FILE_CONNECT', |
|
| 2379 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2380 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2381 | - : false))); |
|
| 2382 | - } |
|
| 2383 | - |
|
| 2384 | - // Le fichier de reglages des droits |
|
| 2385 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2386 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2387 | - } |
|
| 2388 | - if (!defined('_FILE_CHMOD')) { |
|
| 2389 | - define('_FILE_CHMOD', |
|
| 2390 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2391 | - : false)); |
|
| 2392 | - } |
|
| 2393 | - |
|
| 2394 | - if (!defined('_FILE_LDAP')) { |
|
| 2395 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2396 | - } |
|
| 2397 | - |
|
| 2398 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2399 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2400 | - } |
|
| 2401 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2402 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2403 | - } |
|
| 2404 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2405 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2406 | - } |
|
| 2407 | - |
|
| 2408 | - // Definition des droits d'acces en ecriture |
|
| 2409 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2410 | - include_once _FILE_CHMOD; |
|
| 2411 | - } |
|
| 2412 | - |
|
| 2413 | - // Se mefier des fichiers mal remplis! |
|
| 2414 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2415 | - define('_SPIP_CHMOD', 0777); |
|
| 2416 | - } |
|
| 2417 | - |
|
| 2418 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2419 | - /** Le charset par défaut lors de l'installation */ |
|
| 2420 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2421 | - } |
|
| 2422 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2423 | - define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2424 | - } |
|
| 2425 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2426 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2427 | - } |
|
| 2428 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2429 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2430 | - } |
|
| 2431 | - |
|
| 2432 | - // La taille des Log |
|
| 2433 | - if (!defined('_MAX_LOG')) { |
|
| 2434 | - define('_MAX_LOG', 100); |
|
| 2435 | - } |
|
| 2436 | - |
|
| 2437 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2438 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2439 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2440 | - if (!defined('_OS_SERVEUR')) { |
|
| 2441 | - define('_OS_SERVEUR', 'windows'); |
|
| 2442 | - } |
|
| 2443 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2444 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2445 | - } // utiliser le flock php |
|
| 2446 | - } else { |
|
| 2447 | - if (!defined('_OS_SERVEUR')) { |
|
| 2448 | - define('_OS_SERVEUR', ''); |
|
| 2449 | - } |
|
| 2450 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2451 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2452 | - } // utiliser le flock php |
|
| 2453 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2454 | - } |
|
| 2455 | - |
|
| 2456 | - // Langue par defaut |
|
| 2457 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2458 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2459 | - } |
|
| 2460 | - |
|
| 2461 | - // |
|
| 2462 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2463 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2464 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2465 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2466 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2467 | - |
|
| 2468 | - // charger tout de suite le path et son cache |
|
| 2469 | - load_path_cache(); |
|
| 2470 | - |
|
| 2471 | - // *********** traiter les variables ************ |
|
| 2472 | - |
|
| 2473 | - // |
|
| 2474 | - // Securite |
|
| 2475 | - // |
|
| 2476 | - |
|
| 2477 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2478 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2479 | - die(); |
|
| 2480 | - } |
|
| 2481 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2482 | - spip_desinfecte($_GET); |
|
| 2483 | - spip_desinfecte($_POST); |
|
| 2484 | - spip_desinfecte($_COOKIE); |
|
| 2485 | - spip_desinfecte($_REQUEST); |
|
| 2486 | - |
|
| 2487 | - // appliquer le cookie_prefix |
|
| 2488 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2489 | - include_spip('inc/cookie'); |
|
| 2490 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2491 | - } |
|
| 2492 | - |
|
| 2493 | - // |
|
| 2494 | - // Capacites php (en fonction de la version) |
|
| 2495 | - // |
|
| 2496 | - $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2497 | - && function_exists("ini_get") |
|
| 2498 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2499 | - $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2500 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2501 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2502 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2503 | - |
|
| 2504 | - |
|
| 2505 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2506 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2507 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2508 | - } else { |
|
| 2509 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2510 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 2511 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2512 | - ) { |
|
| 2513 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2514 | - } |
|
| 2515 | - } |
|
| 2516 | - |
|
| 2517 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2518 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2519 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2520 | - } |
|
| 2521 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2522 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2523 | - } |
|
| 2524 | - |
|
| 2525 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2526 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2527 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2528 | - $inc_meta(); |
|
| 2529 | - |
|
| 2530 | - // nombre de repertoires depuis la racine |
|
| 2531 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2532 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2533 | - // le calcul est faux) |
|
| 2534 | - if (!_DIR_RESTREINT) { |
|
| 2535 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2536 | - } else { |
|
| 2537 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2538 | - $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2539 | - if (!$uri_ref |
|
| 2540 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2541 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2542 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2543 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2544 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2545 | - ) { |
|
| 2546 | - |
|
| 2547 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2548 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2549 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2550 | - } else { |
|
| 2551 | - $uri_ref = ""; |
|
| 2552 | - } |
|
| 2553 | - } |
|
| 2554 | - if (!$uri or !$uri_ref) { |
|
| 2555 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2556 | - } else { |
|
| 2557 | - $GLOBALS['profondeur_url'] = max(0, |
|
| 2558 | - substr_count($uri[0], '/') |
|
| 2559 | - - substr_count($uri_ref, '/')); |
|
| 2560 | - } |
|
| 2561 | - } |
|
| 2562 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2563 | - if (_FILE_CONNECT) { |
|
| 2564 | - if (verifier_visiteur() == '0minirezo' |
|
| 2565 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2566 | - and !isset($_COOKIE['spip_admin']) |
|
| 2567 | - ) { |
|
| 2568 | - clear_path_cache(); |
|
| 2569 | - } |
|
| 2570 | - } |
|
| 2261 | + static $too_late = 0; |
|
| 2262 | + if ($too_late++) { |
|
| 2263 | + return; |
|
| 2264 | + } |
|
| 2265 | + |
|
| 2266 | + // Declaration des repertoires |
|
| 2267 | + |
|
| 2268 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2269 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2270 | + define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2271 | + } |
|
| 2272 | + |
|
| 2273 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2274 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2275 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2276 | + } |
|
| 2277 | + |
|
| 2278 | + // le nom du repertoire des librairies |
|
| 2279 | + if (!defined('_DIR_LIB')) { |
|
| 2280 | + define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2281 | + } |
|
| 2282 | + |
|
| 2283 | + if (!defined('_DIR_IMG')) { |
|
| 2284 | + define('_DIR_IMG', $pa); |
|
| 2285 | + } |
|
| 2286 | + if (!defined('_DIR_LOGOS')) { |
|
| 2287 | + define('_DIR_LOGOS', $pa); |
|
| 2288 | + } |
|
| 2289 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2290 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2291 | + } |
|
| 2292 | + |
|
| 2293 | + if (!defined('_DIR_DUMP')) { |
|
| 2294 | + define('_DIR_DUMP', $ti . "dump/"); |
|
| 2295 | + } |
|
| 2296 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2297 | + define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2298 | + } |
|
| 2299 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2300 | + define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2301 | + } |
|
| 2302 | + if (!defined('_DIR_CACHE')) { |
|
| 2303 | + define('_DIR_CACHE', $ti . "cache/"); |
|
| 2304 | + } |
|
| 2305 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2306 | + define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2307 | + } |
|
| 2308 | + if (!defined('_DIR_SKELS')) { |
|
| 2309 | + define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2310 | + } |
|
| 2311 | + if (!defined('_DIR_AIDE')) { |
|
| 2312 | + define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2313 | + } |
|
| 2314 | + if (!defined('_DIR_TMP')) { |
|
| 2315 | + define('_DIR_TMP', $ti); |
|
| 2316 | + } |
|
| 2317 | + |
|
| 2318 | + if (!defined('_DIR_VAR')) { |
|
| 2319 | + define('_DIR_VAR', $ta); |
|
| 2320 | + } |
|
| 2321 | + |
|
| 2322 | + if (!defined('_DIR_ETC')) { |
|
| 2323 | + define('_DIR_ETC', $pi); |
|
| 2324 | + } |
|
| 2325 | + if (!defined('_DIR_CONNECT')) { |
|
| 2326 | + define('_DIR_CONNECT', $pi); |
|
| 2327 | + } |
|
| 2328 | + if (!defined('_DIR_CHMOD')) { |
|
| 2329 | + define('_DIR_CHMOD', $pi); |
|
| 2330 | + } |
|
| 2331 | + |
|
| 2332 | + if (!isset($GLOBALS['test_dirs'])) |
|
| 2333 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2334 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2335 | + { |
|
| 2336 | + $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2337 | + } |
|
| 2338 | + |
|
| 2339 | + // Declaration des fichiers |
|
| 2340 | + |
|
| 2341 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2342 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2343 | + } |
|
| 2344 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2345 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2346 | + } |
|
| 2347 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2348 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2349 | + } |
|
| 2350 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2351 | + define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2352 | + } |
|
| 2353 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2354 | + define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2355 | + } |
|
| 2356 | + |
|
| 2357 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2358 | + if (!defined('_FILE_META')) { |
|
| 2359 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2360 | + } |
|
| 2361 | + if (!defined('_DIR_LOG')) { |
|
| 2362 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2363 | + } |
|
| 2364 | + if (!defined('_FILE_LOG')) { |
|
| 2365 | + define('_FILE_LOG', 'spip'); |
|
| 2366 | + } |
|
| 2367 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2368 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2369 | + } |
|
| 2370 | + |
|
| 2371 | + // Le fichier de connexion a la base de donnees |
|
| 2372 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2373 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2374 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2375 | + } |
|
| 2376 | + if (!defined('_FILE_CONNECT')) { |
|
| 2377 | + define('_FILE_CONNECT', |
|
| 2378 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2379 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2380 | + : false))); |
|
| 2381 | + } |
|
| 2382 | + |
|
| 2383 | + // Le fichier de reglages des droits |
|
| 2384 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2385 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2386 | + } |
|
| 2387 | + if (!defined('_FILE_CHMOD')) { |
|
| 2388 | + define('_FILE_CHMOD', |
|
| 2389 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2390 | + : false)); |
|
| 2391 | + } |
|
| 2392 | + |
|
| 2393 | + if (!defined('_FILE_LDAP')) { |
|
| 2394 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2395 | + } |
|
| 2396 | + |
|
| 2397 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2398 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2399 | + } |
|
| 2400 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2401 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2402 | + } |
|
| 2403 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2404 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2405 | + } |
|
| 2406 | + |
|
| 2407 | + // Definition des droits d'acces en ecriture |
|
| 2408 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2409 | + include_once _FILE_CHMOD; |
|
| 2410 | + } |
|
| 2411 | + |
|
| 2412 | + // Se mefier des fichiers mal remplis! |
|
| 2413 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2414 | + define('_SPIP_CHMOD', 0777); |
|
| 2415 | + } |
|
| 2416 | + |
|
| 2417 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2418 | + /** Le charset par défaut lors de l'installation */ |
|
| 2419 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2420 | + } |
|
| 2421 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2422 | + define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2423 | + } |
|
| 2424 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2425 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2426 | + } |
|
| 2427 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2428 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2429 | + } |
|
| 2430 | + |
|
| 2431 | + // La taille des Log |
|
| 2432 | + if (!defined('_MAX_LOG')) { |
|
| 2433 | + define('_MAX_LOG', 100); |
|
| 2434 | + } |
|
| 2435 | + |
|
| 2436 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2437 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2438 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2439 | + if (!defined('_OS_SERVEUR')) { |
|
| 2440 | + define('_OS_SERVEUR', 'windows'); |
|
| 2441 | + } |
|
| 2442 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2443 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2444 | + } // utiliser le flock php |
|
| 2445 | + } else { |
|
| 2446 | + if (!defined('_OS_SERVEUR')) { |
|
| 2447 | + define('_OS_SERVEUR', ''); |
|
| 2448 | + } |
|
| 2449 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2450 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2451 | + } // utiliser le flock php |
|
| 2452 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2453 | + } |
|
| 2454 | + |
|
| 2455 | + // Langue par defaut |
|
| 2456 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2457 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2458 | + } |
|
| 2459 | + |
|
| 2460 | + // |
|
| 2461 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2462 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2463 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2464 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2465 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2466 | + |
|
| 2467 | + // charger tout de suite le path et son cache |
|
| 2468 | + load_path_cache(); |
|
| 2469 | + |
|
| 2470 | + // *********** traiter les variables ************ |
|
| 2471 | + |
|
| 2472 | + // |
|
| 2473 | + // Securite |
|
| 2474 | + // |
|
| 2475 | + |
|
| 2476 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2477 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2478 | + die(); |
|
| 2479 | + } |
|
| 2480 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2481 | + spip_desinfecte($_GET); |
|
| 2482 | + spip_desinfecte($_POST); |
|
| 2483 | + spip_desinfecte($_COOKIE); |
|
| 2484 | + spip_desinfecte($_REQUEST); |
|
| 2485 | + |
|
| 2486 | + // appliquer le cookie_prefix |
|
| 2487 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2488 | + include_spip('inc/cookie'); |
|
| 2489 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2490 | + } |
|
| 2491 | + |
|
| 2492 | + // |
|
| 2493 | + // Capacites php (en fonction de la version) |
|
| 2494 | + // |
|
| 2495 | + $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2496 | + && function_exists("ini_get") |
|
| 2497 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2498 | + $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2499 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2500 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2501 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2502 | + |
|
| 2503 | + |
|
| 2504 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2505 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2506 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2507 | + } else { |
|
| 2508 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2509 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 2510 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2511 | + ) { |
|
| 2512 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2513 | + } |
|
| 2514 | + } |
|
| 2515 | + |
|
| 2516 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2517 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2518 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2519 | + } |
|
| 2520 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2521 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2522 | + } |
|
| 2523 | + |
|
| 2524 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2525 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2526 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2527 | + $inc_meta(); |
|
| 2528 | + |
|
| 2529 | + // nombre de repertoires depuis la racine |
|
| 2530 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2531 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2532 | + // le calcul est faux) |
|
| 2533 | + if (!_DIR_RESTREINT) { |
|
| 2534 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2535 | + } else { |
|
| 2536 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2537 | + $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2538 | + if (!$uri_ref |
|
| 2539 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2540 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2541 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2542 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2543 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2544 | + ) { |
|
| 2545 | + |
|
| 2546 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2547 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2548 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2549 | + } else { |
|
| 2550 | + $uri_ref = ""; |
|
| 2551 | + } |
|
| 2552 | + } |
|
| 2553 | + if (!$uri or !$uri_ref) { |
|
| 2554 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2555 | + } else { |
|
| 2556 | + $GLOBALS['profondeur_url'] = max(0, |
|
| 2557 | + substr_count($uri[0], '/') |
|
| 2558 | + - substr_count($uri_ref, '/')); |
|
| 2559 | + } |
|
| 2560 | + } |
|
| 2561 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2562 | + if (_FILE_CONNECT) { |
|
| 2563 | + if (verifier_visiteur() == '0minirezo' |
|
| 2564 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2565 | + and !isset($_COOKIE['spip_admin']) |
|
| 2566 | + ) { |
|
| 2567 | + clear_path_cache(); |
|
| 2568 | + } |
|
| 2569 | + } |
|
| 2571 | 2570 | |
| 2572 | 2571 | } |
| 2573 | 2572 | |
@@ -2577,174 +2576,174 @@ discard block |
||
| 2577 | 2576 | * |
| 2578 | 2577 | */ |
| 2579 | 2578 | function spip_initialisation_suite() { |
| 2580 | - static $too_late = 0; |
|
| 2581 | - if ($too_late++) { |
|
| 2582 | - return; |
|
| 2583 | - } |
|
| 2584 | - |
|
| 2585 | - // taille mini des login |
|
| 2586 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2587 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2588 | - } |
|
| 2589 | - |
|
| 2590 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2591 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2592 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2593 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2594 | - |
|
| 2595 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2596 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2597 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2598 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2599 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2600 | - |
|
| 2601 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2602 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2603 | - } |
|
| 2604 | - |
|
| 2605 | - |
|
| 2606 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2607 | - if (!defined('_IMG_QUALITE')) { |
|
| 2608 | - define('_IMG_QUALITE', 85); |
|
| 2609 | - } # valeur par defaut |
|
| 2610 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2611 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2612 | - } # surcharge pour la lib GD |
|
| 2613 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2614 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2615 | - } # surcharge pour imagick en ligne de commande |
|
| 2616 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2617 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2618 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2619 | - } # surcharge pour imagick en PHP |
|
| 2620 | - |
|
| 2621 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2622 | - define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2623 | - } // poids en octet |
|
| 2624 | - |
|
| 2625 | - // qq chaines standard |
|
| 2626 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2627 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2628 | - } |
|
| 2629 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2630 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2631 | - } |
|
| 2632 | - if (!defined('_SPIP_DUMP')) { |
|
| 2633 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2634 | - } |
|
| 2635 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2636 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2637 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2638 | - } |
|
| 2639 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2640 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2641 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2642 | - } |
|
| 2643 | - |
|
| 2644 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2645 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2646 | - } |
|
| 2647 | - |
|
| 2648 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2649 | - /** Définit le doctype de l’espace privé */ |
|
| 2650 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2651 | - } |
|
| 2652 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2653 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2654 | - define('_DOCTYPE_AIDE', |
|
| 2655 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2656 | - } |
|
| 2657 | - |
|
| 2658 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2659 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2660 | - * le script de l'espace public, alias index.php */ |
|
| 2661 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2662 | - } |
|
| 2663 | - if (!defined('_SPIP_PAGE')) { |
|
| 2664 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2665 | - define('_SPIP_PAGE', 'page'); |
|
| 2666 | - } |
|
| 2667 | - |
|
| 2668 | - // le script de l'espace prive |
|
| 2669 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2670 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2671 | - // meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html |
|
| 2672 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2673 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2674 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2675 | - } else { |
|
| 2676 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2677 | - } |
|
| 2678 | - } |
|
| 2679 | - |
|
| 2680 | - |
|
| 2681 | - if (!defined('_SPIP_AJAX')) { |
|
| 2682 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2683 | - ? 1 |
|
| 2684 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2685 | - } |
|
| 2686 | - |
|
| 2687 | - // La requete est-elle en ajax ? |
|
| 2688 | - if (!defined('_AJAX')) { |
|
| 2689 | - define('_AJAX', |
|
| 2690 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2691 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2692 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2693 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2694 | - ) |
|
| 2695 | - 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 |
|
| 2696 | - ); |
|
| 2697 | - } |
|
| 2698 | - |
|
| 2699 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2700 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2701 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2702 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2703 | - define('_IMG_GD_MAX_PIXELS', |
|
| 2704 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2705 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2706 | - : 0); |
|
| 2707 | - } |
|
| 2708 | - |
|
| 2709 | - if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2710 | - define('_MEMORY_LIMIT_MIN', 16); |
|
| 2711 | - } // en Mo |
|
| 2712 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2713 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2714 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2715 | - if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2716 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2717 | - $unit = strtolower(substr($memory, -1)); |
|
| 2718 | - $memory = substr($memory, 0, -1); |
|
| 2719 | - switch ($unit) { |
|
| 2720 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2721 | - case 'g': |
|
| 2722 | - $memory *= 1024; |
|
| 2723 | - case 'm': |
|
| 2724 | - $memory *= 1024; |
|
| 2725 | - case 'k': |
|
| 2726 | - $memory *= 1024; |
|
| 2727 | - } |
|
| 2728 | - if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2729 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2730 | - if (trim(ini_get('memory_limit')) != $m) { |
|
| 2731 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2732 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2733 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2734 | - } |
|
| 2735 | - } |
|
| 2736 | - } else { |
|
| 2737 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2738 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2739 | - } |
|
| 2740 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2741 | - } |
|
| 2742 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2743 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2744 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2745 | - } |
|
| 2746 | - |
|
| 2747 | - init_var_mode(); |
|
| 2579 | + static $too_late = 0; |
|
| 2580 | + if ($too_late++) { |
|
| 2581 | + return; |
|
| 2582 | + } |
|
| 2583 | + |
|
| 2584 | + // taille mini des login |
|
| 2585 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2586 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2587 | + } |
|
| 2588 | + |
|
| 2589 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2590 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2591 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2592 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2593 | + |
|
| 2594 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2595 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2596 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2597 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2598 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2599 | + |
|
| 2600 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2601 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2602 | + } |
|
| 2603 | + |
|
| 2604 | + |
|
| 2605 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2606 | + if (!defined('_IMG_QUALITE')) { |
|
| 2607 | + define('_IMG_QUALITE', 85); |
|
| 2608 | + } # valeur par defaut |
|
| 2609 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2610 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2611 | + } # surcharge pour la lib GD |
|
| 2612 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2613 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2614 | + } # surcharge pour imagick en ligne de commande |
|
| 2615 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2616 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2617 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2618 | + } # surcharge pour imagick en PHP |
|
| 2619 | + |
|
| 2620 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2621 | + define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2622 | + } // poids en octet |
|
| 2623 | + |
|
| 2624 | + // qq chaines standard |
|
| 2625 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2626 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2627 | + } |
|
| 2628 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2629 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2630 | + } |
|
| 2631 | + if (!defined('_SPIP_DUMP')) { |
|
| 2632 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2633 | + } |
|
| 2634 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2635 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2636 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2637 | + } |
|
| 2638 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2639 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2640 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2641 | + } |
|
| 2642 | + |
|
| 2643 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2644 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2645 | + } |
|
| 2646 | + |
|
| 2647 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2648 | + /** Définit le doctype de l’espace privé */ |
|
| 2649 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2650 | + } |
|
| 2651 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2652 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2653 | + define('_DOCTYPE_AIDE', |
|
| 2654 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2655 | + } |
|
| 2656 | + |
|
| 2657 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2658 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2659 | + * le script de l'espace public, alias index.php */ |
|
| 2660 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2661 | + } |
|
| 2662 | + if (!defined('_SPIP_PAGE')) { |
|
| 2663 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2664 | + define('_SPIP_PAGE', 'page'); |
|
| 2665 | + } |
|
| 2666 | + |
|
| 2667 | + // le script de l'espace prive |
|
| 2668 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2669 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2670 | + // meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html |
|
| 2671 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2672 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2673 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2674 | + } else { |
|
| 2675 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2676 | + } |
|
| 2677 | + } |
|
| 2678 | + |
|
| 2679 | + |
|
| 2680 | + if (!defined('_SPIP_AJAX')) { |
|
| 2681 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2682 | + ? 1 |
|
| 2683 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2684 | + } |
|
| 2685 | + |
|
| 2686 | + // La requete est-elle en ajax ? |
|
| 2687 | + if (!defined('_AJAX')) { |
|
| 2688 | + define('_AJAX', |
|
| 2689 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2690 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2691 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2692 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2693 | + ) |
|
| 2694 | + 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 |
|
| 2695 | + ); |
|
| 2696 | + } |
|
| 2697 | + |
|
| 2698 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2699 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2700 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2701 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2702 | + define('_IMG_GD_MAX_PIXELS', |
|
| 2703 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2704 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2705 | + : 0); |
|
| 2706 | + } |
|
| 2707 | + |
|
| 2708 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2709 | + define('_MEMORY_LIMIT_MIN', 16); |
|
| 2710 | + } // en Mo |
|
| 2711 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2712 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2713 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2714 | + if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2715 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2716 | + $unit = strtolower(substr($memory, -1)); |
|
| 2717 | + $memory = substr($memory, 0, -1); |
|
| 2718 | + switch ($unit) { |
|
| 2719 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2720 | + case 'g': |
|
| 2721 | + $memory *= 1024; |
|
| 2722 | + case 'm': |
|
| 2723 | + $memory *= 1024; |
|
| 2724 | + case 'k': |
|
| 2725 | + $memory *= 1024; |
|
| 2726 | + } |
|
| 2727 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2728 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2729 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 2730 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2731 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2732 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2733 | + } |
|
| 2734 | + } |
|
| 2735 | + } else { |
|
| 2736 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2737 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2738 | + } |
|
| 2739 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2740 | + } |
|
| 2741 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2742 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2743 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2744 | + } |
|
| 2745 | + |
|
| 2746 | + init_var_mode(); |
|
| 2748 | 2747 | } |
| 2749 | 2748 | |
| 2750 | 2749 | /** |
@@ -2778,129 +2777,129 @@ discard block |
||
| 2778 | 2777 | * ` var_mode` (calcul ou recalcul). |
| 2779 | 2778 | */ |
| 2780 | 2779 | function init_var_mode() { |
| 2781 | - static $done = false; |
|
| 2782 | - if (!$done) { |
|
| 2783 | - |
|
| 2784 | - if (isset($_GET['var_mode'])) { |
|
| 2785 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 2786 | - // tout le monde peut calcul/recalcul |
|
| 2787 | - if (!defined('_VAR_MODE')) { |
|
| 2788 | - if (in_array('recalcul', $var_mode)) { |
|
| 2789 | - define('_VAR_MODE', 'recalcul'); |
|
| 2790 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 2791 | - define('_VAR_MODE', 'calcul'); |
|
| 2792 | - } |
|
| 2793 | - } |
|
| 2794 | - $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2795 | - if ($var_mode) { |
|
| 2796 | - include_spip('inc/autoriser'); |
|
| 2797 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2798 | - if (autoriser( |
|
| 2799 | - ($_GET['var_mode'] == 'preview') |
|
| 2800 | - ? 'previsualiser' |
|
| 2801 | - : 'debug' |
|
| 2802 | - )) { |
|
| 2803 | - if (in_array('traduction', $var_mode)) { |
|
| 2804 | - // forcer le calcul pour passer dans traduire |
|
| 2805 | - if (!defined('_VAR_MODE')) { |
|
| 2806 | - define('_VAR_MODE', 'calcul'); |
|
| 2807 | - } |
|
| 2808 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2809 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2810 | - define('_VAR_NOCACHE', true); |
|
| 2811 | - } |
|
| 2812 | - $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2813 | - } |
|
| 2814 | - if (in_array('preview', $var_mode)) { |
|
| 2815 | - // basculer sur les criteres de preview dans les boucles |
|
| 2816 | - if (!defined('_VAR_PREVIEW')) { |
|
| 2817 | - define('_VAR_PREVIEW', true); |
|
| 2818 | - } |
|
| 2819 | - // forcer le calcul |
|
| 2820 | - if (!defined('_VAR_MODE')) { |
|
| 2821 | - define('_VAR_MODE', 'calcul'); |
|
| 2822 | - } |
|
| 2823 | - // et ne pas enregistrer de cache |
|
| 2824 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2825 | - define('_VAR_NOCACHE', true); |
|
| 2826 | - } |
|
| 2827 | - $var_mode = array_diff($var_mode, array('preview')); |
|
| 2828 | - } |
|
| 2829 | - if (in_array('inclure', $var_mode)) { |
|
| 2830 | - // forcer le compilo et ignorer les caches existants |
|
| 2831 | - if (!defined('_VAR_MODE')) { |
|
| 2832 | - define('_VAR_MODE', 'calcul'); |
|
| 2833 | - } |
|
| 2834 | - if (!defined('_VAR_INCLURE')) { |
|
| 2835 | - define('_VAR_INCLURE', true); |
|
| 2836 | - } |
|
| 2837 | - // et ne pas enregistrer de cache |
|
| 2838 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2839 | - define('_VAR_NOCACHE', true); |
|
| 2840 | - } |
|
| 2841 | - $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2842 | - } |
|
| 2843 | - if (in_array('urls', $var_mode)) { |
|
| 2844 | - // forcer le compilo et ignorer les caches existants |
|
| 2845 | - if (!defined('_VAR_MODE')) { |
|
| 2846 | - define('_VAR_MODE', 'calcul'); |
|
| 2847 | - } |
|
| 2848 | - if (!defined('_VAR_URLS')) { |
|
| 2849 | - define('_VAR_URLS', true); |
|
| 2850 | - } |
|
| 2851 | - $var_mode = array_diff($var_mode, array('urls')); |
|
| 2852 | - } |
|
| 2853 | - if (in_array('images', $var_mode)) { |
|
| 2854 | - // forcer le compilo et ignorer les caches existants |
|
| 2855 | - if (!defined('_VAR_MODE')) { |
|
| 2856 | - define('_VAR_MODE', 'calcul'); |
|
| 2857 | - } |
|
| 2858 | - // indiquer qu'on doit recalculer les images |
|
| 2859 | - if (!defined('_VAR_IMAGES')) { |
|
| 2860 | - define('_VAR_IMAGES', true); |
|
| 2861 | - } |
|
| 2862 | - $var_mode = array_diff($var_mode, array('images')); |
|
| 2863 | - } |
|
| 2864 | - if (in_array('debug', $var_mode)) { |
|
| 2865 | - if (!defined('_VAR_MODE')) { |
|
| 2866 | - define('_VAR_MODE', 'debug'); |
|
| 2867 | - } |
|
| 2868 | - // et ne pas enregistrer de cache |
|
| 2869 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2870 | - define('_VAR_NOCACHE', true); |
|
| 2871 | - } |
|
| 2872 | - $var_mode = array_diff($var_mode, array('debug')); |
|
| 2873 | - } |
|
| 2874 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2875 | - define('_VAR_MODE', reset($var_mode)); |
|
| 2876 | - } |
|
| 2877 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2878 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2879 | - . " " . _VAR_MODE); |
|
| 2880 | - } |
|
| 2881 | - } // pas autorise ? |
|
| 2882 | - else { |
|
| 2883 | - // si on n'est pas connecte on se redirige |
|
| 2884 | - if (!$GLOBALS['visiteur_session']) { |
|
| 2885 | - include_spip('inc/headers'); |
|
| 2886 | - redirige_par_entete(generer_url_public('login', |
|
| 2887 | - 'url=' . rawurlencode( |
|
| 2888 | - parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
|
| 2889 | - ), true)); |
|
| 2890 | - } |
|
| 2891 | - // sinon tant pis |
|
| 2892 | - } |
|
| 2893 | - } |
|
| 2894 | - } |
|
| 2895 | - if (!defined('_VAR_MODE')) { |
|
| 2896 | - /** |
|
| 2897 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 2898 | - * @see init_var_mode() |
|
| 2899 | - */ |
|
| 2900 | - define('_VAR_MODE', false); |
|
| 2901 | - } |
|
| 2902 | - $done = true; |
|
| 2903 | - } |
|
| 2780 | + static $done = false; |
|
| 2781 | + if (!$done) { |
|
| 2782 | + |
|
| 2783 | + if (isset($_GET['var_mode'])) { |
|
| 2784 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 2785 | + // tout le monde peut calcul/recalcul |
|
| 2786 | + if (!defined('_VAR_MODE')) { |
|
| 2787 | + if (in_array('recalcul', $var_mode)) { |
|
| 2788 | + define('_VAR_MODE', 'recalcul'); |
|
| 2789 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 2790 | + define('_VAR_MODE', 'calcul'); |
|
| 2791 | + } |
|
| 2792 | + } |
|
| 2793 | + $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2794 | + if ($var_mode) { |
|
| 2795 | + include_spip('inc/autoriser'); |
|
| 2796 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2797 | + if (autoriser( |
|
| 2798 | + ($_GET['var_mode'] == 'preview') |
|
| 2799 | + ? 'previsualiser' |
|
| 2800 | + : 'debug' |
|
| 2801 | + )) { |
|
| 2802 | + if (in_array('traduction', $var_mode)) { |
|
| 2803 | + // forcer le calcul pour passer dans traduire |
|
| 2804 | + if (!defined('_VAR_MODE')) { |
|
| 2805 | + define('_VAR_MODE', 'calcul'); |
|
| 2806 | + } |
|
| 2807 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2808 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2809 | + define('_VAR_NOCACHE', true); |
|
| 2810 | + } |
|
| 2811 | + $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2812 | + } |
|
| 2813 | + if (in_array('preview', $var_mode)) { |
|
| 2814 | + // basculer sur les criteres de preview dans les boucles |
|
| 2815 | + if (!defined('_VAR_PREVIEW')) { |
|
| 2816 | + define('_VAR_PREVIEW', true); |
|
| 2817 | + } |
|
| 2818 | + // forcer le calcul |
|
| 2819 | + if (!defined('_VAR_MODE')) { |
|
| 2820 | + define('_VAR_MODE', 'calcul'); |
|
| 2821 | + } |
|
| 2822 | + // et ne pas enregistrer de cache |
|
| 2823 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2824 | + define('_VAR_NOCACHE', true); |
|
| 2825 | + } |
|
| 2826 | + $var_mode = array_diff($var_mode, array('preview')); |
|
| 2827 | + } |
|
| 2828 | + if (in_array('inclure', $var_mode)) { |
|
| 2829 | + // forcer le compilo et ignorer les caches existants |
|
| 2830 | + if (!defined('_VAR_MODE')) { |
|
| 2831 | + define('_VAR_MODE', 'calcul'); |
|
| 2832 | + } |
|
| 2833 | + if (!defined('_VAR_INCLURE')) { |
|
| 2834 | + define('_VAR_INCLURE', true); |
|
| 2835 | + } |
|
| 2836 | + // et ne pas enregistrer de cache |
|
| 2837 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2838 | + define('_VAR_NOCACHE', true); |
|
| 2839 | + } |
|
| 2840 | + $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2841 | + } |
|
| 2842 | + if (in_array('urls', $var_mode)) { |
|
| 2843 | + // forcer le compilo et ignorer les caches existants |
|
| 2844 | + if (!defined('_VAR_MODE')) { |
|
| 2845 | + define('_VAR_MODE', 'calcul'); |
|
| 2846 | + } |
|
| 2847 | + if (!defined('_VAR_URLS')) { |
|
| 2848 | + define('_VAR_URLS', true); |
|
| 2849 | + } |
|
| 2850 | + $var_mode = array_diff($var_mode, array('urls')); |
|
| 2851 | + } |
|
| 2852 | + if (in_array('images', $var_mode)) { |
|
| 2853 | + // forcer le compilo et ignorer les caches existants |
|
| 2854 | + if (!defined('_VAR_MODE')) { |
|
| 2855 | + define('_VAR_MODE', 'calcul'); |
|
| 2856 | + } |
|
| 2857 | + // indiquer qu'on doit recalculer les images |
|
| 2858 | + if (!defined('_VAR_IMAGES')) { |
|
| 2859 | + define('_VAR_IMAGES', true); |
|
| 2860 | + } |
|
| 2861 | + $var_mode = array_diff($var_mode, array('images')); |
|
| 2862 | + } |
|
| 2863 | + if (in_array('debug', $var_mode)) { |
|
| 2864 | + if (!defined('_VAR_MODE')) { |
|
| 2865 | + define('_VAR_MODE', 'debug'); |
|
| 2866 | + } |
|
| 2867 | + // et ne pas enregistrer de cache |
|
| 2868 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2869 | + define('_VAR_NOCACHE', true); |
|
| 2870 | + } |
|
| 2871 | + $var_mode = array_diff($var_mode, array('debug')); |
|
| 2872 | + } |
|
| 2873 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2874 | + define('_VAR_MODE', reset($var_mode)); |
|
| 2875 | + } |
|
| 2876 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2877 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2878 | + . " " . _VAR_MODE); |
|
| 2879 | + } |
|
| 2880 | + } // pas autorise ? |
|
| 2881 | + else { |
|
| 2882 | + // si on n'est pas connecte on se redirige |
|
| 2883 | + if (!$GLOBALS['visiteur_session']) { |
|
| 2884 | + include_spip('inc/headers'); |
|
| 2885 | + redirige_par_entete(generer_url_public('login', |
|
| 2886 | + 'url=' . rawurlencode( |
|
| 2887 | + parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
|
| 2888 | + ), true)); |
|
| 2889 | + } |
|
| 2890 | + // sinon tant pis |
|
| 2891 | + } |
|
| 2892 | + } |
|
| 2893 | + } |
|
| 2894 | + if (!defined('_VAR_MODE')) { |
|
| 2895 | + /** |
|
| 2896 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 2897 | + * @see init_var_mode() |
|
| 2898 | + */ |
|
| 2899 | + define('_VAR_MODE', false); |
|
| 2900 | + } |
|
| 2901 | + $done = true; |
|
| 2902 | + } |
|
| 2904 | 2903 | } |
| 2905 | 2904 | |
| 2906 | 2905 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
@@ -2908,93 +2907,93 @@ discard block |
||
| 2908 | 2907 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 2909 | 2908 | // http://code.spip.net/@spip_desinfecte |
| 2910 | 2909 | function spip_desinfecte(&$t, $deep = true) { |
| 2911 | - static $magic_quotes; |
|
| 2912 | - if (!isset($magic_quotes)) { |
|
| 2913 | - $magic_quotes = @get_magic_quotes_gpc(); |
|
| 2914 | - } |
|
| 2915 | - |
|
| 2916 | - foreach ($t as $key => $val) { |
|
| 2917 | - if (is_string($t[$key])) { |
|
| 2918 | - if ($magic_quotes) { |
|
| 2919 | - $t[$key] = stripslashes($t[$key]); |
|
| 2920 | - } |
|
| 2921 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 2922 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 2923 | - else { |
|
| 2924 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 2925 | - spip_desinfecte($t[$key], $deep); |
|
| 2926 | - } |
|
| 2927 | - } |
|
| 2928 | - } |
|
| 2910 | + static $magic_quotes; |
|
| 2911 | + if (!isset($magic_quotes)) { |
|
| 2912 | + $magic_quotes = @get_magic_quotes_gpc(); |
|
| 2913 | + } |
|
| 2914 | + |
|
| 2915 | + foreach ($t as $key => $val) { |
|
| 2916 | + if (is_string($t[$key])) { |
|
| 2917 | + if ($magic_quotes) { |
|
| 2918 | + $t[$key] = stripslashes($t[$key]); |
|
| 2919 | + } |
|
| 2920 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 2921 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 2922 | + else { |
|
| 2923 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 2924 | + spip_desinfecte($t[$key], $deep); |
|
| 2925 | + } |
|
| 2926 | + } |
|
| 2927 | + } |
|
| 2929 | 2928 | } |
| 2930 | 2929 | |
| 2931 | 2930 | // retourne le statut du visiteur s'il s'annonce |
| 2932 | 2931 | |
| 2933 | 2932 | // http://code.spip.net/@verifier_visiteur |
| 2934 | 2933 | function verifier_visiteur() { |
| 2935 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 2936 | - // il faut forcer l'init si ce n'est fait |
|
| 2937 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 2938 | - // certaines constantes |
|
| 2939 | - @spip_initialisation_core( |
|
| 2940 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 2941 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 2942 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 2943 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 2944 | - ); |
|
| 2945 | - |
|
| 2946 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 2947 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 2948 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 2949 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 2950 | - $variables_session = array('session_nom', 'session_email'); |
|
| 2951 | - foreach ($variables_session as $var) { |
|
| 2952 | - if (_request($var) !== null) { |
|
| 2953 | - $init = true; |
|
| 2954 | - break; |
|
| 2955 | - } |
|
| 2956 | - } |
|
| 2957 | - if (isset($init)) { |
|
| 2958 | - #@spip_initialisation_suite(); |
|
| 2959 | - $session = charger_fonction('session', 'inc'); |
|
| 2960 | - $session(); |
|
| 2961 | - include_spip('inc/texte'); |
|
| 2962 | - foreach ($variables_session as $var) { |
|
| 2963 | - if (($a = _request($var)) !== null) { |
|
| 2964 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 2965 | - } |
|
| 2966 | - } |
|
| 2967 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 2968 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2969 | - } |
|
| 2970 | - $session($GLOBALS['visiteur_session']); |
|
| 2971 | - |
|
| 2972 | - return 0; |
|
| 2973 | - } |
|
| 2974 | - |
|
| 2975 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 2976 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 2977 | - |
|
| 2978 | - $session = charger_fonction('session', 'inc'); |
|
| 2979 | - if ($session()) { |
|
| 2980 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 2981 | - } |
|
| 2982 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 2983 | - include_spip('inc/auth'); |
|
| 2984 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 2985 | - } |
|
| 2986 | - if ($h) { |
|
| 2987 | - $GLOBALS['visiteur_session'] = $h; |
|
| 2988 | - |
|
| 2989 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 2990 | - } |
|
| 2991 | - } |
|
| 2992 | - |
|
| 2993 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 2994 | - include_spip('inc/lang'); |
|
| 2995 | - utiliser_langue_visiteur(); |
|
| 2996 | - |
|
| 2997 | - return false; |
|
| 2934 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 2935 | + // il faut forcer l'init si ce n'est fait |
|
| 2936 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 2937 | + // certaines constantes |
|
| 2938 | + @spip_initialisation_core( |
|
| 2939 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 2940 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 2941 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 2942 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 2943 | + ); |
|
| 2944 | + |
|
| 2945 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 2946 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 2947 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 2948 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 2949 | + $variables_session = array('session_nom', 'session_email'); |
|
| 2950 | + foreach ($variables_session as $var) { |
|
| 2951 | + if (_request($var) !== null) { |
|
| 2952 | + $init = true; |
|
| 2953 | + break; |
|
| 2954 | + } |
|
| 2955 | + } |
|
| 2956 | + if (isset($init)) { |
|
| 2957 | + #@spip_initialisation_suite(); |
|
| 2958 | + $session = charger_fonction('session', 'inc'); |
|
| 2959 | + $session(); |
|
| 2960 | + include_spip('inc/texte'); |
|
| 2961 | + foreach ($variables_session as $var) { |
|
| 2962 | + if (($a = _request($var)) !== null) { |
|
| 2963 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 2964 | + } |
|
| 2965 | + } |
|
| 2966 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 2967 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2968 | + } |
|
| 2969 | + $session($GLOBALS['visiteur_session']); |
|
| 2970 | + |
|
| 2971 | + return 0; |
|
| 2972 | + } |
|
| 2973 | + |
|
| 2974 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 2975 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 2976 | + |
|
| 2977 | + $session = charger_fonction('session', 'inc'); |
|
| 2978 | + if ($session()) { |
|
| 2979 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 2980 | + } |
|
| 2981 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 2982 | + include_spip('inc/auth'); |
|
| 2983 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 2984 | + } |
|
| 2985 | + if ($h) { |
|
| 2986 | + $GLOBALS['visiteur_session'] = $h; |
|
| 2987 | + |
|
| 2988 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 2989 | + } |
|
| 2990 | + } |
|
| 2991 | + |
|
| 2992 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 2993 | + include_spip('inc/lang'); |
|
| 2994 | + utiliser_langue_visiteur(); |
|
| 2995 | + |
|
| 2996 | + return false; |
|
| 2998 | 2997 | } |
| 2999 | 2998 | |
| 3000 | 2999 | |
@@ -3017,21 +3016,21 @@ discard block |
||
| 3017 | 3016 | * - string Langue utilisée. |
| 3018 | 3017 | **/ |
| 3019 | 3018 | function lang_select($lang = null) { |
| 3020 | - static $pile_langues = array(); |
|
| 3021 | - if (!function_exists('changer_langue')) { |
|
| 3022 | - include_spip('inc/lang'); |
|
| 3023 | - } |
|
| 3024 | - if ($lang === null) { |
|
| 3025 | - $lang = array_pop($pile_langues); |
|
| 3026 | - } else { |
|
| 3027 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3028 | - } |
|
| 3029 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3030 | - return $lang; |
|
| 3031 | - } |
|
| 3032 | - changer_langue($lang); |
|
| 3019 | + static $pile_langues = array(); |
|
| 3020 | + if (!function_exists('changer_langue')) { |
|
| 3021 | + include_spip('inc/lang'); |
|
| 3022 | + } |
|
| 3023 | + if ($lang === null) { |
|
| 3024 | + $lang = array_pop($pile_langues); |
|
| 3025 | + } else { |
|
| 3026 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3027 | + } |
|
| 3028 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3029 | + return $lang; |
|
| 3030 | + } |
|
| 3031 | + changer_langue($lang); |
|
| 3033 | 3032 | |
| 3034 | - return $lang; |
|
| 3033 | + return $lang; |
|
| 3035 | 3034 | } |
| 3036 | 3035 | |
| 3037 | 3036 | /** |
@@ -3048,19 +3047,19 @@ discard block |
||
| 3048 | 3047 | * Identifiant de la session |
| 3049 | 3048 | **/ |
| 3050 | 3049 | function spip_session($force = false) { |
| 3051 | - static $session; |
|
| 3052 | - if ($force or !isset($session)) { |
|
| 3053 | - $s = pipeline('definir_session', |
|
| 3054 | - $GLOBALS['visiteur_session'] |
|
| 3055 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3056 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3057 | - : '' |
|
| 3058 | - ); |
|
| 3059 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3060 | - } |
|
| 3050 | + static $session; |
|
| 3051 | + if ($force or !isset($session)) { |
|
| 3052 | + $s = pipeline('definir_session', |
|
| 3053 | + $GLOBALS['visiteur_session'] |
|
| 3054 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3055 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3056 | + : '' |
|
| 3057 | + ); |
|
| 3058 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3059 | + } |
|
| 3061 | 3060 | |
| 3062 | - #spip_log('session: '.$session); |
|
| 3063 | - return $session; |
|
| 3061 | + #spip_log('session: '.$session); |
|
| 3062 | + return $session; |
|
| 3064 | 3063 | } |
| 3065 | 3064 | |
| 3066 | 3065 | |
@@ -3079,9 +3078,9 @@ discard block |
||
| 3079 | 3078 | * Lien sur une icone d'aide |
| 3080 | 3079 | **/ |
| 3081 | 3080 | function aider($aide = '', $distante = false) { |
| 3082 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3081 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3083 | 3082 | |
| 3084 | - return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3083 | + return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3085 | 3084 | } |
| 3086 | 3085 | |
| 3087 | 3086 | /** |
@@ -3091,13 +3090,13 @@ discard block |
||
| 3091 | 3090 | */ |
| 3092 | 3091 | function exec_info_dist() { |
| 3093 | 3092 | |
| 3094 | - include_spip('inc/autoriser'); |
|
| 3095 | - if (autoriser('webmestre')) { |
|
| 3096 | - phpinfo(); |
|
| 3097 | - } else { |
|
| 3098 | - include_spip('inc/filtres'); |
|
| 3099 | - sinon_interdire_acces(); |
|
| 3100 | - } |
|
| 3093 | + include_spip('inc/autoriser'); |
|
| 3094 | + if (autoriser('webmestre')) { |
|
| 3095 | + phpinfo(); |
|
| 3096 | + } else { |
|
| 3097 | + include_spip('inc/filtres'); |
|
| 3098 | + sinon_interdire_acces(); |
|
| 3099 | + } |
|
| 3101 | 3100 | } |
| 3102 | 3101 | |
| 3103 | 3102 | /** |
@@ -3117,13 +3116,13 @@ discard block |
||
| 3117 | 3116 | * - string si $message à false. |
| 3118 | 3117 | **/ |
| 3119 | 3118 | function erreur_squelette($message = '', $lieu = '') { |
| 3120 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3121 | - if (is_array($lieu)) { |
|
| 3122 | - include_spip('public/compiler'); |
|
| 3123 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3124 | - } |
|
| 3119 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3120 | + if (is_array($lieu)) { |
|
| 3121 | + include_spip('public/compiler'); |
|
| 3122 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3123 | + } |
|
| 3125 | 3124 | |
| 3126 | - return $debusquer($message, $lieu); |
|
| 3125 | + return $debusquer($message, $lieu); |
|
| 3127 | 3126 | } |
| 3128 | 3127 | |
| 3129 | 3128 | /** |
@@ -3160,109 +3159,109 @@ discard block |
||
| 3160 | 3159 | * - ou tableau d'information sur le squelette. |
| 3161 | 3160 | */ |
| 3162 | 3161 | function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') { |
| 3163 | - if (!function_exists('evaluer_fond')) { |
|
| 3164 | - include_spip('public/assembler'); |
|
| 3165 | - } |
|
| 3166 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3167 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3168 | - if (!is_array($options)) { |
|
| 3169 | - $options = array('trim' => $options); |
|
| 3170 | - } |
|
| 3171 | - if (!isset($options['trim'])) { |
|
| 3172 | - $options['trim'] = true; |
|
| 3173 | - } |
|
| 3174 | - |
|
| 3175 | - if (isset($contexte['connect'])) { |
|
| 3176 | - $connect = $contexte['connect']; |
|
| 3177 | - unset($contexte['connect']); |
|
| 3178 | - } |
|
| 3179 | - |
|
| 3180 | - $texte = ""; |
|
| 3181 | - $pages = array(); |
|
| 3182 | - $lang_select = ''; |
|
| 3183 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3184 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3185 | - if (!isset($contexte['lang'])) { |
|
| 3186 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3187 | - } |
|
| 3188 | - |
|
| 3189 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3190 | - $lang_select = lang_select($contexte['lang']); |
|
| 3191 | - } |
|
| 3192 | - } |
|
| 3193 | - |
|
| 3194 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3195 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3196 | - } |
|
| 3197 | - |
|
| 3198 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3199 | - |
|
| 3200 | - // fix #4235 |
|
| 3201 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3202 | - |
|
| 3203 | - |
|
| 3204 | - foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3162 | + if (!function_exists('evaluer_fond')) { |
|
| 3163 | + include_spip('public/assembler'); |
|
| 3164 | + } |
|
| 3165 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3166 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3167 | + if (!is_array($options)) { |
|
| 3168 | + $options = array('trim' => $options); |
|
| 3169 | + } |
|
| 3170 | + if (!isset($options['trim'])) { |
|
| 3171 | + $options['trim'] = true; |
|
| 3172 | + } |
|
| 3173 | + |
|
| 3174 | + if (isset($contexte['connect'])) { |
|
| 3175 | + $connect = $contexte['connect']; |
|
| 3176 | + unset($contexte['connect']); |
|
| 3177 | + } |
|
| 3178 | + |
|
| 3179 | + $texte = ""; |
|
| 3180 | + $pages = array(); |
|
| 3181 | + $lang_select = ''; |
|
| 3182 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3183 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3184 | + if (!isset($contexte['lang'])) { |
|
| 3185 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3186 | + } |
|
| 3187 | + |
|
| 3188 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3189 | + $lang_select = lang_select($contexte['lang']); |
|
| 3190 | + } |
|
| 3191 | + } |
|
| 3192 | + |
|
| 3193 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3194 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3195 | + } |
|
| 3196 | + |
|
| 3197 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3198 | + |
|
| 3199 | + // fix #4235 |
|
| 3200 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3201 | + |
|
| 3202 | + |
|
| 3203 | + foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3205 | 3204 | |
| 3206 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3207 | - |
|
| 3208 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3209 | - if ($page === '') { |
|
| 3210 | - $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3211 | - $a = array('fichier' => $f); |
|
| 3212 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3213 | - erreur_squelette($erreur, $c); |
|
| 3214 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3215 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3216 | - } |
|
| 3217 | - |
|
| 3218 | - $page = pipeline('recuperer_fond', array( |
|
| 3219 | - 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3220 | - 'data' => $page |
|
| 3221 | - )); |
|
| 3222 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3223 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3224 | - include_spip('inc/filtres'); |
|
| 3225 | - } |
|
| 3226 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3227 | - array_merge( |
|
| 3228 | - $contexte, |
|
| 3229 | - array('fond' => $f), |
|
| 3230 | - ($connect ? array('connect' => $connect) : array()) |
|
| 3231 | - ), |
|
| 3232 | - '', |
|
| 3233 | - $page['texte'], |
|
| 3234 | - $options['ajax'] |
|
| 3235 | - ); |
|
| 3236 | - } |
|
| 3237 | - |
|
| 3238 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3239 | - $pages[] = $page; |
|
| 3240 | - } else { |
|
| 3241 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3242 | - } |
|
| 3205 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3206 | + |
|
| 3207 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3208 | + if ($page === '') { |
|
| 3209 | + $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3210 | + $a = array('fichier' => $f); |
|
| 3211 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3212 | + erreur_squelette($erreur, $c); |
|
| 3213 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3214 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3215 | + } |
|
| 3216 | + |
|
| 3217 | + $page = pipeline('recuperer_fond', array( |
|
| 3218 | + 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3219 | + 'data' => $page |
|
| 3220 | + )); |
|
| 3221 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3222 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3223 | + include_spip('inc/filtres'); |
|
| 3224 | + } |
|
| 3225 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3226 | + array_merge( |
|
| 3227 | + $contexte, |
|
| 3228 | + array('fond' => $f), |
|
| 3229 | + ($connect ? array('connect' => $connect) : array()) |
|
| 3230 | + ), |
|
| 3231 | + '', |
|
| 3232 | + $page['texte'], |
|
| 3233 | + $options['ajax'] |
|
| 3234 | + ); |
|
| 3235 | + } |
|
| 3236 | + |
|
| 3237 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3238 | + $pages[] = $page; |
|
| 3239 | + } else { |
|
| 3240 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3241 | + } |
|
| 3243 | 3242 | |
| 3244 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3245 | - if (isset($page['invalideurs']['session'])){ |
|
| 3246 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3247 | - } |
|
| 3248 | - } |
|
| 3243 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3244 | + if (isset($page['invalideurs']['session'])){ |
|
| 3245 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3246 | + } |
|
| 3247 | + } |
|
| 3249 | 3248 | |
| 3250 | - // restaurer le sessionnement du contexte appelant, |
|
| 3251 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3252 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3253 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3254 | - } |
|
| 3249 | + // restaurer le sessionnement du contexte appelant, |
|
| 3250 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3251 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3252 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3253 | + } |
|
| 3255 | 3254 | |
| 3256 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3255 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3257 | 3256 | |
| 3258 | - if ($lang_select) { |
|
| 3259 | - lang_select(); |
|
| 3260 | - } |
|
| 3261 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3262 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3263 | - } else { |
|
| 3264 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3265 | - } |
|
| 3257 | + if ($lang_select) { |
|
| 3258 | + lang_select(); |
|
| 3259 | + } |
|
| 3260 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3261 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3262 | + } else { |
|
| 3263 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3264 | + } |
|
| 3266 | 3265 | } |
| 3267 | 3266 | |
| 3268 | 3267 | /** |
@@ -3272,7 +3271,7 @@ discard block |
||
| 3272 | 3271 | * @return string |
| 3273 | 3272 | */ |
| 3274 | 3273 | function trouve_modele($nom) { |
| 3275 | - return trouver_fond($nom, 'modeles/'); |
|
| 3274 | + return trouver_fond($nom, 'modeles/'); |
|
| 3276 | 3275 | } |
| 3277 | 3276 | |
| 3278 | 3277 | /** |
@@ -3288,21 +3287,21 @@ discard block |
||
| 3288 | 3287 | * @return array|string |
| 3289 | 3288 | */ |
| 3290 | 3289 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3291 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3292 | - if (!$pathinfo) { |
|
| 3293 | - return $f; |
|
| 3294 | - } |
|
| 3295 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3296 | - $p = pathinfo($f); |
|
| 3297 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3298 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3299 | - } |
|
| 3300 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3301 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3302 | - } |
|
| 3303 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3290 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3291 | + if (!$pathinfo) { |
|
| 3292 | + return $f; |
|
| 3293 | + } |
|
| 3294 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3295 | + $p = pathinfo($f); |
|
| 3296 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3297 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3298 | + } |
|
| 3299 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3300 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3301 | + } |
|
| 3302 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3304 | 3303 | |
| 3305 | - return $p; |
|
| 3304 | + return $p; |
|
| 3306 | 3305 | } |
| 3307 | 3306 | |
| 3308 | 3307 | /** |
@@ -3323,24 +3322,24 @@ discard block |
||
| 3323 | 3322 | * Nom de l'exec, sinon chaîne vide. |
| 3324 | 3323 | **/ |
| 3325 | 3324 | function tester_url_ecrire($nom) { |
| 3326 | - static $exec = array(); |
|
| 3327 | - if (isset($exec[$nom])) { |
|
| 3328 | - return $exec[$nom]; |
|
| 3329 | - } |
|
| 3330 | - // tester si c'est une page en squelette |
|
| 3331 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3332 | - return $exec[$nom] = 'fond'; |
|
| 3333 | - } // compat skels orthogonaux version precedente |
|
| 3334 | - elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3335 | - return $exec[$nom] = 'fond_monobloc'; |
|
| 3336 | - } // echafaudage d'un fond ! |
|
| 3337 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3338 | - return $exec[$nom] = 'fond'; |
|
| 3339 | - } |
|
| 3340 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3341 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3342 | - // et des define intrusifs potentiels |
|
| 3343 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3325 | + static $exec = array(); |
|
| 3326 | + if (isset($exec[$nom])) { |
|
| 3327 | + return $exec[$nom]; |
|
| 3328 | + } |
|
| 3329 | + // tester si c'est une page en squelette |
|
| 3330 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3331 | + return $exec[$nom] = 'fond'; |
|
| 3332 | + } // compat skels orthogonaux version precedente |
|
| 3333 | + elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3334 | + return $exec[$nom] = 'fond_monobloc'; |
|
| 3335 | + } // echafaudage d'un fond ! |
|
| 3336 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3337 | + return $exec[$nom] = 'fond'; |
|
| 3338 | + } |
|
| 3339 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3340 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3341 | + // et des define intrusifs potentiels |
|
| 3342 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3344 | 3343 | } |
| 3345 | 3344 | |
| 3346 | 3345 | |
@@ -3356,10 +3355,10 @@ discard block |
||
| 3356 | 3355 | * @return bool true si le module est chargé |
| 3357 | 3356 | **/ |
| 3358 | 3357 | function charger_php_extension($module) { |
| 3359 | - if (extension_loaded($module)) { |
|
| 3360 | - return true; |
|
| 3361 | - } |
|
| 3362 | - return false; |
|
| 3358 | + if (extension_loaded($module)) { |
|
| 3359 | + return true; |
|
| 3360 | + } |
|
| 3361 | + return false; |
|
| 3363 | 3362 | } |
| 3364 | 3363 | |
| 3365 | 3364 | |
@@ -3370,8 +3369,8 @@ discard block |
||
| 3370 | 3369 | * true si et seulement si la configuration autorise le code HTML5 sur le site public |
| 3371 | 3370 | **/ |
| 3372 | 3371 | function html5_permis() { |
| 3373 | - return (isset($GLOBALS['meta']['version_html_max']) |
|
| 3374 | - and ('html5' == $GLOBALS['meta']['version_html_max'])); |
|
| 3372 | + return (isset($GLOBALS['meta']['version_html_max']) |
|
| 3373 | + and ('html5' == $GLOBALS['meta']['version_html_max'])); |
|
| 3375 | 3374 | } |
| 3376 | 3375 | |
| 3377 | 3376 | /** |
@@ -3381,17 +3380,17 @@ discard block |
||
| 3381 | 3380 | * @return array |
| 3382 | 3381 | */ |
| 3383 | 3382 | function formats_image_acceptables($gd = false, $svg_allowed = true) { |
| 3384 | - $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3385 | - $formats = (isset($GLOBALS['meta'][$config]) ? $GLOBALS['meta'][$config] : 'png,gif,jpg'); |
|
| 3386 | - $formats = explode(',', $formats); |
|
| 3387 | - $formats = array_filter($formats); |
|
| 3388 | - $formats = array_map('trim', $formats); |
|
| 3383 | + $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3384 | + $formats = (isset($GLOBALS['meta'][$config]) ? $GLOBALS['meta'][$config] : 'png,gif,jpg'); |
|
| 3385 | + $formats = explode(',', $formats); |
|
| 3386 | + $formats = array_filter($formats); |
|
| 3387 | + $formats = array_map('trim', $formats); |
|
| 3389 | 3388 | |
| 3390 | - if ($svg_allowed) { |
|
| 3391 | - $formats[] = 'svg'; |
|
| 3392 | - } |
|
| 3389 | + if ($svg_allowed) { |
|
| 3390 | + $formats[] = 'svg'; |
|
| 3391 | + } |
|
| 3393 | 3392 | |
| 3394 | - return $formats; |
|
| 3393 | + return $formats; |
|
| 3395 | 3394 | } |
| 3396 | 3395 | |
| 3397 | 3396 | /** |
@@ -3400,40 +3399,40 @@ discard block |
||
| 3400 | 3399 | * @return array|bool |
| 3401 | 3400 | */ |
| 3402 | 3401 | function spip_getimagesize($fichier) { |
| 3403 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3404 | - |
|
| 3405 | - include_spip("inc/svg"); |
|
| 3406 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3407 | - $width = 350; // default width |
|
| 3408 | - $height = 150; // default height |
|
| 3409 | - if (isset($attrs['width']) |
|
| 3410 | - and $w = svg_dimension_to_pixels($attrs['width']) |
|
| 3411 | - and isset($attrs['height']) |
|
| 3412 | - and $h = svg_dimension_to_pixels($attrs['height'])) { |
|
| 3413 | - $width = $w; |
|
| 3414 | - $height = $h; |
|
| 3415 | - } |
|
| 3416 | - elseif (isset($attrs['viewBox'])) { |
|
| 3417 | - $viewbox = trim($attrs['viewBox']); |
|
| 3418 | - $viewbox = preg_replace(",\s+,", " ", $viewbox); |
|
| 3419 | - $viewbox = explode(" ", $viewbox); |
|
| 3420 | - if (count($viewbox) === 4 |
|
| 3421 | - and $w = svg_dimension_to_pixels($viewbox[2]) |
|
| 3422 | - and $h = svg_dimension_to_pixels($viewbox[3])) { |
|
| 3423 | - $width = $w; |
|
| 3424 | - $height = $h; |
|
| 3425 | - } |
|
| 3426 | - } |
|
| 3427 | - $imagesize = [ |
|
| 3428 | - $width, |
|
| 3429 | - $height, |
|
| 3430 | - IMAGETYPE_SVG, |
|
| 3431 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3432 | - "mime" => "image/svg+xml" |
|
| 3433 | - ]; |
|
| 3434 | - } |
|
| 3435 | - } |
|
| 3436 | - return $imagesize; |
|
| 3402 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3403 | + |
|
| 3404 | + include_spip("inc/svg"); |
|
| 3405 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3406 | + $width = 350; // default width |
|
| 3407 | + $height = 150; // default height |
|
| 3408 | + if (isset($attrs['width']) |
|
| 3409 | + and $w = svg_dimension_to_pixels($attrs['width']) |
|
| 3410 | + and isset($attrs['height']) |
|
| 3411 | + and $h = svg_dimension_to_pixels($attrs['height'])) { |
|
| 3412 | + $width = $w; |
|
| 3413 | + $height = $h; |
|
| 3414 | + } |
|
| 3415 | + elseif (isset($attrs['viewBox'])) { |
|
| 3416 | + $viewbox = trim($attrs['viewBox']); |
|
| 3417 | + $viewbox = preg_replace(",\s+,", " ", $viewbox); |
|
| 3418 | + $viewbox = explode(" ", $viewbox); |
|
| 3419 | + if (count($viewbox) === 4 |
|
| 3420 | + and $w = svg_dimension_to_pixels($viewbox[2]) |
|
| 3421 | + and $h = svg_dimension_to_pixels($viewbox[3])) { |
|
| 3422 | + $width = $w; |
|
| 3423 | + $height = $h; |
|
| 3424 | + } |
|
| 3425 | + } |
|
| 3426 | + $imagesize = [ |
|
| 3427 | + $width, |
|
| 3428 | + $height, |
|
| 3429 | + IMAGETYPE_SVG, |
|
| 3430 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3431 | + "mime" => "image/svg+xml" |
|
| 3432 | + ]; |
|
| 3433 | + } |
|
| 3434 | + } |
|
| 3435 | + return $imagesize; |
|
| 3437 | 3436 | } |
| 3438 | 3437 | |
| 3439 | 3438 | |
@@ -3453,7 +3452,7 @@ discard block |
||
| 3453 | 3452 | * @return mixed Valeur de la meta. |
| 3454 | 3453 | **/ |
| 3455 | 3454 | function lire_meta($nom) { |
| 3456 | - return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3455 | + return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3457 | 3456 | } |
| 3458 | 3457 | |
| 3459 | 3458 | |
@@ -3475,128 +3474,128 @@ discard block |
||
| 3475 | 3474 | * @param string $statut |
| 3476 | 3475 | */ |
| 3477 | 3476 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3478 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3479 | - if (!$alertes |
|
| 3480 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3481 | - ) { |
|
| 3482 | - $alertes = array(); |
|
| 3483 | - } |
|
| 3477 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3478 | + if (!$alertes |
|
| 3479 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3480 | + ) { |
|
| 3481 | + $alertes = array(); |
|
| 3482 | + } |
|
| 3484 | 3483 | |
| 3485 | - if (!isset($alertes[$statut])) { |
|
| 3486 | - $alertes[$statut] = array(); |
|
| 3487 | - } |
|
| 3488 | - $alertes[$statut][$nom] = $message; |
|
| 3489 | - ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3484 | + if (!isset($alertes[$statut])) { |
|
| 3485 | + $alertes[$statut] = array(); |
|
| 3486 | + } |
|
| 3487 | + $alertes[$statut][$nom] = $message; |
|
| 3488 | + ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3490 | 3489 | } |
| 3491 | 3490 | |
| 3492 | 3491 | if (PHP_VERSION_ID < 50500) { |
| 3493 | - if (!function_exists('array_column')) { |
|
| 3494 | - /** |
|
| 3495 | - * Returns the values from a single column of the input array, identified by |
|
| 3496 | - * the $columnKey. |
|
| 3497 | - * |
|
| 3498 | - * Optionally, you may provide an $indexKey to index the values in the returned |
|
| 3499 | - * array by the values from the $indexKey column in the input array. |
|
| 3500 | - * |
|
| 3501 | - * @link http://php.net/manual/fr/function.array-column.php |
|
| 3502 | - * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php |
|
| 3503 | - * @copyright Copyright (c) Ben Ramsey (http://benramsey.com) |
|
| 3504 | - * @license http://opensource.org/licenses/MIT MIT |
|
| 3505 | - * |
|
| 3506 | - * @param array $input A multi-dimensional array (record set) from which to pull |
|
| 3507 | - * a column of values. |
|
| 3508 | - * @param mixed $columnKey The column of values to return. This value may be the |
|
| 3509 | - * integer key of the column you wish to retrieve, or it |
|
| 3510 | - * may be the string key name for an associative array. |
|
| 3511 | - * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
|
| 3512 | - * the returned array. This value may be the integer key |
|
| 3513 | - * of the column, or it may be the string key name. |
|
| 3514 | - * @return array |
|
| 3515 | - */ |
|
| 3516 | - function array_column($input = null, $columnKey = null, $indexKey = null) |
|
| 3517 | - { |
|
| 3518 | - // Using func_get_args() in order to check for proper number of |
|
| 3519 | - // parameters and trigger errors exactly as the built-in array_column() |
|
| 3520 | - // does in PHP 5.5. |
|
| 3521 | - $argc = func_num_args(); |
|
| 3522 | - $params = func_get_args(); |
|
| 3523 | - |
|
| 3524 | - if ($argc < 2) { |
|
| 3525 | - trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 3526 | - return null; |
|
| 3527 | - } |
|
| 3528 | - |
|
| 3529 | - if (!is_array($params[0])) { |
|
| 3530 | - trigger_error( |
|
| 3531 | - 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
| 3532 | - E_USER_WARNING |
|
| 3533 | - ); |
|
| 3534 | - return null; |
|
| 3535 | - } |
|
| 3536 | - |
|
| 3537 | - if (!is_int($params[1]) |
|
| 3538 | - && !is_float($params[1]) |
|
| 3539 | - && !is_string($params[1]) |
|
| 3540 | - && $params[1] !== null |
|
| 3541 | - && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 3542 | - ) { |
|
| 3543 | - trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 3544 | - return false; |
|
| 3545 | - } |
|
| 3546 | - |
|
| 3547 | - if (isset($params[2]) |
|
| 3548 | - && !is_int($params[2]) |
|
| 3549 | - && !is_float($params[2]) |
|
| 3550 | - && !is_string($params[2]) |
|
| 3551 | - && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 3552 | - ) { |
|
| 3553 | - trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 3554 | - return false; |
|
| 3555 | - } |
|
| 3556 | - |
|
| 3557 | - $paramsInput = $params[0]; |
|
| 3558 | - $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 3559 | - |
|
| 3560 | - $paramsIndexKey = null; |
|
| 3561 | - if (isset($params[2])) { |
|
| 3562 | - if (is_float($params[2]) || is_int($params[2])) { |
|
| 3563 | - $paramsIndexKey = (int) $params[2]; |
|
| 3564 | - } else { |
|
| 3565 | - $paramsIndexKey = (string) $params[2]; |
|
| 3566 | - } |
|
| 3567 | - } |
|
| 3568 | - |
|
| 3569 | - $resultArray = array(); |
|
| 3570 | - |
|
| 3571 | - foreach ($paramsInput as $row) { |
|
| 3572 | - $key = $value = null; |
|
| 3573 | - $keySet = $valueSet = false; |
|
| 3574 | - |
|
| 3575 | - if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 3576 | - $keySet = true; |
|
| 3577 | - $key = (string) $row[$paramsIndexKey]; |
|
| 3578 | - } |
|
| 3579 | - |
|
| 3580 | - if ($paramsColumnKey === null) { |
|
| 3581 | - $valueSet = true; |
|
| 3582 | - $value = $row; |
|
| 3583 | - } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 3584 | - $valueSet = true; |
|
| 3585 | - $value = $row[$paramsColumnKey]; |
|
| 3586 | - } |
|
| 3587 | - |
|
| 3588 | - if ($valueSet) { |
|
| 3589 | - if ($keySet) { |
|
| 3590 | - $resultArray[$key] = $value; |
|
| 3591 | - } else { |
|
| 3592 | - $resultArray[] = $value; |
|
| 3593 | - } |
|
| 3594 | - } |
|
| 3595 | - |
|
| 3596 | - } |
|
| 3597 | - |
|
| 3598 | - return $resultArray; |
|
| 3599 | - } |
|
| 3600 | - |
|
| 3601 | - } |
|
| 3492 | + if (!function_exists('array_column')) { |
|
| 3493 | + /** |
|
| 3494 | + * Returns the values from a single column of the input array, identified by |
|
| 3495 | + * the $columnKey. |
|
| 3496 | + * |
|
| 3497 | + * Optionally, you may provide an $indexKey to index the values in the returned |
|
| 3498 | + * array by the values from the $indexKey column in the input array. |
|
| 3499 | + * |
|
| 3500 | + * @link http://php.net/manual/fr/function.array-column.php |
|
| 3501 | + * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php |
|
| 3502 | + * @copyright Copyright (c) Ben Ramsey (http://benramsey.com) |
|
| 3503 | + * @license http://opensource.org/licenses/MIT MIT |
|
| 3504 | + * |
|
| 3505 | + * @param array $input A multi-dimensional array (record set) from which to pull |
|
| 3506 | + * a column of values. |
|
| 3507 | + * @param mixed $columnKey The column of values to return. This value may be the |
|
| 3508 | + * integer key of the column you wish to retrieve, or it |
|
| 3509 | + * may be the string key name for an associative array. |
|
| 3510 | + * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
|
| 3511 | + * the returned array. This value may be the integer key |
|
| 3512 | + * of the column, or it may be the string key name. |
|
| 3513 | + * @return array |
|
| 3514 | + */ |
|
| 3515 | + function array_column($input = null, $columnKey = null, $indexKey = null) |
|
| 3516 | + { |
|
| 3517 | + // Using func_get_args() in order to check for proper number of |
|
| 3518 | + // parameters and trigger errors exactly as the built-in array_column() |
|
| 3519 | + // does in PHP 5.5. |
|
| 3520 | + $argc = func_num_args(); |
|
| 3521 | + $params = func_get_args(); |
|
| 3522 | + |
|
| 3523 | + if ($argc < 2) { |
|
| 3524 | + trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 3525 | + return null; |
|
| 3526 | + } |
|
| 3527 | + |
|
| 3528 | + if (!is_array($params[0])) { |
|
| 3529 | + trigger_error( |
|
| 3530 | + 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
| 3531 | + E_USER_WARNING |
|
| 3532 | + ); |
|
| 3533 | + return null; |
|
| 3534 | + } |
|
| 3535 | + |
|
| 3536 | + if (!is_int($params[1]) |
|
| 3537 | + && !is_float($params[1]) |
|
| 3538 | + && !is_string($params[1]) |
|
| 3539 | + && $params[1] !== null |
|
| 3540 | + && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 3541 | + ) { |
|
| 3542 | + trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 3543 | + return false; |
|
| 3544 | + } |
|
| 3545 | + |
|
| 3546 | + if (isset($params[2]) |
|
| 3547 | + && !is_int($params[2]) |
|
| 3548 | + && !is_float($params[2]) |
|
| 3549 | + && !is_string($params[2]) |
|
| 3550 | + && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 3551 | + ) { |
|
| 3552 | + trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 3553 | + return false; |
|
| 3554 | + } |
|
| 3555 | + |
|
| 3556 | + $paramsInput = $params[0]; |
|
| 3557 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 3558 | + |
|
| 3559 | + $paramsIndexKey = null; |
|
| 3560 | + if (isset($params[2])) { |
|
| 3561 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 3562 | + $paramsIndexKey = (int) $params[2]; |
|
| 3563 | + } else { |
|
| 3564 | + $paramsIndexKey = (string) $params[2]; |
|
| 3565 | + } |
|
| 3566 | + } |
|
| 3567 | + |
|
| 3568 | + $resultArray = array(); |
|
| 3569 | + |
|
| 3570 | + foreach ($paramsInput as $row) { |
|
| 3571 | + $key = $value = null; |
|
| 3572 | + $keySet = $valueSet = false; |
|
| 3573 | + |
|
| 3574 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 3575 | + $keySet = true; |
|
| 3576 | + $key = (string) $row[$paramsIndexKey]; |
|
| 3577 | + } |
|
| 3578 | + |
|
| 3579 | + if ($paramsColumnKey === null) { |
|
| 3580 | + $valueSet = true; |
|
| 3581 | + $value = $row; |
|
| 3582 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 3583 | + $valueSet = true; |
|
| 3584 | + $value = $row[$paramsColumnKey]; |
|
| 3585 | + } |
|
| 3586 | + |
|
| 3587 | + if ($valueSet) { |
|
| 3588 | + if ($keySet) { |
|
| 3589 | + $resultArray[$key] = $value; |
|
| 3590 | + } else { |
|
| 3591 | + $resultArray[] = $value; |
|
| 3592 | + } |
|
| 3593 | + } |
|
| 3594 | + |
|
| 3595 | + } |
|
| 3596 | + |
|
| 3597 | + return $resultArray; |
|
| 3598 | + } |
|
| 3599 | + |
|
| 3600 | + } |
|
| 3602 | 3601 | } |
@@ -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 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // passer en minuscules (cf les balises de formulaires) |
| 80 | 80 | // et inclure le fichier |
| 81 | - if (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 81 | + if (!$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 82 | 82 | // si le fichier truc/machin/nom.php n'existe pas, |
| 83 | 83 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 84 | 84 | and strlen(dirname($dossier)) and dirname($dossier) != '.' |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Echec : message d'erreur |
| 100 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 100 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 101 | 101 | ($inc ? "" : " (fichier $d absent de $dossier)")); |
| 102 | 102 | |
| 103 | 103 | include_spip('inc/minipres'); |
| 104 | 104 | echo minipres(_T('forum_titre_erreur'), |
| 105 | - _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | - array('all_inline'=>true,'status'=>404)); |
|
| 105 | + _T('fichier_introuvable', array('fichier' => '<b>'.spip_htmlentities($d).'</b>')), |
|
| 106 | + array('all_inline'=>true, 'status'=>404)); |
|
| 107 | 107 | exit; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * - string : chemin du fichier trouvé |
| 149 | 149 | **/ |
| 150 | 150 | function include_spip($f, $include = true) { |
| 151 | - return find_in_path($f . '.php', '', $include); |
|
| 151 | + return find_in_path($f.'.php', '', $include); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * - string : chemin du fichier trouvé |
| 169 | 169 | **/ |
| 170 | 170 | function require_spip($f) { |
| 171 | - return find_in_path($f . '.php', '', 'required'); |
|
| 171 | + return find_in_path($f.'.php', '', 'required'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // appliquer notre fonction si elle existe |
| 263 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 263 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 264 | 264 | if (function_exists($fonc)) { |
| 265 | 265 | $val = $fonc($val); |
| 266 | 266 | } // plantage ? |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | function spip_log($message = null, $name = null) { |
| 325 | 325 | static $pre = array(); |
| 326 | 326 | static $log; |
| 327 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 327 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 328 | 328 | if (!isset($regs[1]) or !$logname = $regs[1]) { |
| 329 | 329 | $logname = null; |
| 330 | 330 | } |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | if (!is_string($message)) { |
| 350 | 350 | $message = print_r($message, true); |
| 351 | 351 | } |
| 352 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 352 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $a = './'; |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 515 | + $regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; |
|
| 516 | 516 | $ajouts = array_flip(explode('|', $c)); |
| 517 | 517 | $u = is_array($v) ? $v : rawurlencode($v); |
| 518 | 518 | $testv = (is_array($v) ? count($v) : strlen($v)); |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 540 | 540 | // pour un tableau ce sera fait dans la prochaine boucle |
| 541 | 541 | elseif (substr($r[1], -2) != '[]') { |
| 542 | - $url[$n] = $r[1] . '=' . $u; |
|
| 542 | + $url[$n] = $r[1].'='.$u; |
|
| 543 | 543 | unset($ajouts[$r[1]]); |
| 544 | 544 | } |
| 545 | 545 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -559,11 +559,11 @@ discard block |
||
| 559 | 559 | } elseif ($testv) { |
| 560 | 560 | foreach ($ajouts as $k => $n) { |
| 561 | 561 | if (!is_array($v)) { |
| 562 | - $url[] = $k . '=' . $u; |
|
| 562 | + $url[] = $k.'='.$u; |
|
| 563 | 563 | } else { |
| 564 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 564 | + $id = (substr($k, -2) == '[]') ? $k : ($k."[]"); |
|
| 565 | 565 | foreach ($v as $w) { |
| 566 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 566 | + $url[] = $id.'='.(is_array($w) ? 'Array' : $w); |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | } |
@@ -574,10 +574,10 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | // recomposer l'adresse |
| 576 | 576 | if ($url) { |
| 577 | - $a .= '?' . join($sep, $url); |
|
| 577 | + $a .= '?'.join($sep, $url); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - return $a . $ancre; |
|
| 580 | + return $a.$ancre; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /** |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | translitteration($ancre) |
| 610 | 610 | ); |
| 611 | 611 | } |
| 612 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 612 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | * @return bool |
| 722 | 722 | */ |
| 723 | 723 | function test_plugin_actif($plugin) { |
| 724 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 724 | + return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
@@ -789,8 +789,7 @@ discard block |
||
| 789 | 789 | // pour les chaines non traduites, assurer un service minimum |
| 790 | 790 | if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
| 791 | 791 | $text = str_replace('_', ' ', |
| 792 | - (($n = strpos($text, ':')) === false ? $texte : |
|
| 793 | - substr($texte, $n + 1))); |
|
| 792 | + (($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1))); |
|
| 794 | 793 | } |
| 795 | 794 | $o['class'] = null; |
| 796 | 795 | |
@@ -862,7 +861,7 @@ discard block |
||
| 862 | 861 | // Si des variables n'ont pas ete inserees, le signaler |
| 863 | 862 | // (chaines de langues pas a jour) |
| 864 | 863 | if ($args) { |
| 865 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 864 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 866 | 865 | } |
| 867 | 866 | } |
| 868 | 867 | |
@@ -886,7 +885,7 @@ discard block |
||
| 886 | 885 | function joli_repertoire($rep) { |
| 887 | 886 | $a = substr($rep, 0, 1); |
| 888 | 887 | if ($a <> '.' and $a <> '/') { |
| 889 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 888 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 890 | 889 | } |
| 891 | 890 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 892 | 891 | |
@@ -940,7 +939,7 @@ discard block |
||
| 940 | 939 | $p -= ($x * 1000); |
| 941 | 940 | } |
| 942 | 941 | |
| 943 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 942 | + return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 944 | 943 | } |
| 945 | 944 | } |
| 946 | 945 | |
@@ -1009,7 +1008,7 @@ discard block |
||
| 1009 | 1008 | if ($taches and count($taches) and !spip_connect()) { |
| 1010 | 1009 | return false; |
| 1011 | 1010 | } |
| 1012 | - spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1011 | + spip_log("cron !", 'jq'._LOG_DEBUG); |
|
| 1013 | 1012 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 1014 | 1013 | return $genie($taches); |
| 1015 | 1014 | } |
@@ -1113,7 +1112,7 @@ discard block |
||
| 1113 | 1112 | |
| 1114 | 1113 | if ($queue_next_job_time == -1) { |
| 1115 | 1114 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 1116 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1115 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt"); |
|
| 1117 | 1116 | } |
| 1118 | 1117 | // utiliser un cache memoire si dispo |
| 1119 | 1118 | if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
@@ -1180,8 +1179,8 @@ discard block |
||
| 1180 | 1179 | $src = ''; |
| 1181 | 1180 | } |
| 1182 | 1181 | if ($script) { |
| 1183 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1184 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1182 | + $script = ("/*<![CDATA[*/\n". |
|
| 1183 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 1185 | 1184 | "/*]]>*/"); |
| 1186 | 1185 | } |
| 1187 | 1186 | if ($noscript) { |
@@ -1267,13 +1266,13 @@ discard block |
||
| 1267 | 1266 | if ($path_base == null) { |
| 1268 | 1267 | // Chemin standard depuis l'espace public |
| 1269 | 1268 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 1270 | - _DIR_RACINE . ':' . |
|
| 1271 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1272 | - _DIR_RACINE . 'prive/:' . |
|
| 1269 | + _DIR_RACINE.':'. |
|
| 1270 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 1271 | + _DIR_RACINE.'prive/:'. |
|
| 1273 | 1272 | _DIR_RESTREINT; |
| 1274 | 1273 | // Ajouter squelettes/ |
| 1275 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1276 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1274 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 1275 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 1277 | 1276 | } |
| 1278 | 1277 | foreach (explode(':', $path) as $dir) { |
| 1279 | 1278 | if (strlen($dir) and substr($dir, -1) != '/') { |
@@ -1285,7 +1284,7 @@ discard block |
||
| 1285 | 1284 | // Et le(s) dossier(s) des squelettes nommes |
| 1286 | 1285 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1287 | 1286 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1288 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1287 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 1289 | 1288 | } |
| 1290 | 1289 | } |
| 1291 | 1290 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
@@ -1296,7 +1295,7 @@ discard block |
||
| 1296 | 1295 | |
| 1297 | 1296 | if (strlen($dir_path)) { |
| 1298 | 1297 | $tete = ""; |
| 1299 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1298 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') { |
|
| 1300 | 1299 | $tete = array_shift($path_base); |
| 1301 | 1300 | } |
| 1302 | 1301 | $dirs = array_reverse(explode(':', $dir_path)); |
@@ -1318,7 +1317,7 @@ discard block |
||
| 1318 | 1317 | // Et le(s) dossier(s) des squelettes nommes |
| 1319 | 1318 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1320 | 1319 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1321 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1320 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/'); |
|
| 1322 | 1321 | } |
| 1323 | 1322 | } |
| 1324 | 1323 | |
@@ -1388,9 +1387,9 @@ discard block |
||
| 1388 | 1387 | // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
| 1389 | 1388 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 1390 | 1389 | if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 1391 | - and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1390 | + and $file_svg_generique = substr($file, 0, -strlen($m[0]))."-xx.svg" |
|
| 1392 | 1391 | and $f = find_in_theme("$file_svg_generique")) { |
| 1393 | - if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1392 | + if ($fsize = substr($f, 0, -6).$m[1].".svg" and file_exists($fsize)) { |
|
| 1394 | 1393 | return $themefiles["$subdir$file"] = $fsize; |
| 1395 | 1394 | } |
| 1396 | 1395 | else { |
@@ -1404,7 +1403,7 @@ discard block |
||
| 1404 | 1403 | return $themefiles["$subdir$file"] = $f; |
| 1405 | 1404 | } |
| 1406 | 1405 | } |
| 1407 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1406 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 1408 | 1407 | |
| 1409 | 1408 | return $themefiles["$subdir$file"] = ""; |
| 1410 | 1409 | } |
@@ -1505,8 +1504,8 @@ discard block |
||
| 1505 | 1504 | return false; |
| 1506 | 1505 | } |
| 1507 | 1506 | if ($include and !isset($inc[$dirname][$file])) { |
| 1508 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1509 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1507 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1508 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1510 | 1509 | } |
| 1511 | 1510 | |
| 1512 | 1511 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
@@ -1519,14 +1518,14 @@ discard block |
||
| 1519 | 1518 | } |
| 1520 | 1519 | |
| 1521 | 1520 | foreach (creer_chemin() as $dir) { |
| 1522 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1523 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1521 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 1522 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 1524 | 1523 | } |
| 1525 | 1524 | if ($dirs[$a]) { |
| 1526 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1525 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 1527 | 1526 | if ($include and !isset($inc[$dirname][$file])) { |
| 1528 | - include_once _ROOT_CWD . $a; |
|
| 1529 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1527 | + include_once _ROOT_CWD.$a; |
|
| 1528 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1530 | 1529 | } |
| 1531 | 1530 | if (!defined('_SAUVER_CHEMIN')) { |
| 1532 | 1531 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
@@ -1536,7 +1535,7 @@ discard block |
||
| 1536 | 1535 | define('_SAUVER_CHEMIN', true); |
| 1537 | 1536 | } |
| 1538 | 1537 | |
| 1539 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1538 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 1540 | 1539 | } |
| 1541 | 1540 | } |
| 1542 | 1541 | } |
@@ -1562,7 +1561,7 @@ discard block |
||
| 1562 | 1561 | define('_SAUVER_CHEMIN', true); |
| 1563 | 1562 | } |
| 1564 | 1563 | |
| 1565 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1564 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1566 | 1565 | } |
| 1567 | 1566 | |
| 1568 | 1567 | function clear_path_cache() { |
@@ -1631,12 +1630,12 @@ discard block |
||
| 1631 | 1630 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 1632 | 1631 | // on a pas encore inclus flock.php |
| 1633 | 1632 | if (!function_exists('preg_files')) { |
| 1634 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1633 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1635 | 1634 | } |
| 1636 | 1635 | |
| 1637 | 1636 | // Parcourir le chemin |
| 1638 | 1637 | foreach (creer_chemin() as $d) { |
| 1639 | - $f = $d . $dir; |
|
| 1638 | + $f = $d.$dir; |
|
| 1640 | 1639 | if (@is_dir($f)) { |
| 1641 | 1640 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
| 1642 | 1641 | foreach ($liste as $chemin) { |
@@ -1666,9 +1665,9 @@ discard block |
||
| 1666 | 1665 | static $autsanscookie = array('install', 'base_repair'); |
| 1667 | 1666 | |
| 1668 | 1667 | if (in_array($nom, $autsanscookie)) { |
| 1669 | - if (test_espace_prive()){ |
|
| 1668 | + if (test_espace_prive()) { |
|
| 1670 | 1669 | include_spip('base/connect_sql'); |
| 1671 | - if (!$strict or !spip_connect()){ |
|
| 1670 | + if (!$strict or !spip_connect()) { |
|
| 1672 | 1671 | return true; |
| 1673 | 1672 | } |
| 1674 | 1673 | } |
@@ -1747,7 +1746,7 @@ discard block |
||
| 1747 | 1746 | return $res; |
| 1748 | 1747 | } |
| 1749 | 1748 | // Sinon c'est un raccourci ou compat SPIP < 2 |
| 1750 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1749 | + if (!function_exists($f = 'generer_url_'.$entite)) { |
|
| 1751 | 1750 | if (!function_exists($f .= '_dist')) { |
| 1752 | 1751 | $f = ''; |
| 1753 | 1752 | } |
@@ -1756,8 +1755,8 @@ discard block |
||
| 1756 | 1755 | $url = $f($id, $args, $ancre); |
| 1757 | 1756 | if (strlen($args)) { |
| 1758 | 1757 | $url .= strstr($url, '?') |
| 1759 | - ? '&' . $args |
|
| 1760 | - : '?' . $args; |
|
| 1758 | + ? '&'.$args |
|
| 1759 | + : '?'.$args; |
|
| 1761 | 1760 | } |
| 1762 | 1761 | |
| 1763 | 1762 | return $url; |
@@ -1788,8 +1787,8 @@ discard block |
||
| 1788 | 1787 | include_spip('base/connect_sql'); |
| 1789 | 1788 | $id_type = id_table_objet($entite, $public); |
| 1790 | 1789 | |
| 1791 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1792 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1790 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1791 | + . "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1793 | 1792 | . (!$args ? '' : "&$args") |
| 1794 | 1793 | . (!$ancre ? '' : "#$ancre"); |
| 1795 | 1794 | } |
@@ -1941,7 +1940,7 @@ discard block |
||
| 1941 | 1940 | if (!empty($_SERVER['QUERY_STRING']) |
| 1942 | 1941 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 1943 | 1942 | ) { |
| 1944 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 1943 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1945 | 1944 | } |
| 1946 | 1945 | } |
| 1947 | 1946 | } |
@@ -1968,17 +1967,17 @@ discard block |
||
| 1968 | 1967 | list($myself) = explode('?', $myself); |
| 1969 | 1968 | // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
| 1970 | 1969 | // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
| 1971 | - if (strpos($myself,'://') !== false) { |
|
| 1972 | - $myself = explode('://',$myself); |
|
| 1970 | + if (strpos($myself, '://') !== false) { |
|
| 1971 | + $myself = explode('://', $myself); |
|
| 1973 | 1972 | array_shift($myself); |
| 1974 | - $myself = implode('://',$myself); |
|
| 1975 | - $myself = explode('/',$myself); |
|
| 1973 | + $myself = implode('://', $myself); |
|
| 1974 | + $myself = explode('/', $myself); |
|
| 1976 | 1975 | array_shift($myself); |
| 1977 | - $myself = implode('/',$myself); |
|
| 1976 | + $myself = implode('/', $myself); |
|
| 1978 | 1977 | } |
| 1979 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 1978 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 1980 | 1979 | |
| 1981 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 1980 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 1982 | 1981 | |
| 1983 | 1982 | return $url; |
| 1984 | 1983 | } |
@@ -2016,17 +2015,17 @@ discard block |
||
| 2016 | 2015 | **/ |
| 2017 | 2016 | function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
| 2018 | 2017 | if (!$rel) { |
| 2019 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2018 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 2020 | 2019 | } else { |
| 2021 | 2020 | if (!is_string($rel)) { |
| 2022 | 2021 | $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
| 2023 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2022 | + ('./'._SPIP_ECRIRE_SCRIPT); |
|
| 2024 | 2023 | } |
| 2025 | 2024 | } |
| 2026 | 2025 | |
| 2027 | 2026 | list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
| 2028 | 2027 | if ($script and ($script <> 'accueil' or $rel)) { |
| 2029 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2028 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 2030 | 2029 | } elseif ($args) { |
| 2031 | 2030 | $args = "?$args"; |
| 2032 | 2031 | } |
@@ -2034,7 +2033,7 @@ discard block |
||
| 2034 | 2033 | $args .= "#$ancre"; |
| 2035 | 2034 | } |
| 2036 | 2035 | |
| 2037 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2036 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2038 | 2037 | } |
| 2039 | 2038 | |
| 2040 | 2039 | // |
@@ -2104,25 +2103,25 @@ discard block |
||
| 2104 | 2103 | if (is_array($args)) { |
| 2105 | 2104 | $r = ''; |
| 2106 | 2105 | foreach ($args as $k => $v) { |
| 2107 | - $r .= '&' . $k . '=' . $v; |
|
| 2106 | + $r .= '&'.$k.'='.$v; |
|
| 2108 | 2107 | } |
| 2109 | 2108 | $args = substr($r, 1); |
| 2110 | 2109 | } |
| 2111 | 2110 | $action .= |
| 2112 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2111 | + (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 2113 | 2112 | } |
| 2114 | 2113 | if (!$no_entities) { |
| 2115 | 2114 | $action = quote_amp($action); |
| 2116 | 2115 | } |
| 2117 | 2116 | |
| 2118 | 2117 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 2119 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2118 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2120 | 2119 | } |
| 2121 | 2120 | |
| 2122 | 2121 | // http://code.spip.net/@generer_url_prive |
| 2123 | 2122 | function generer_url_prive($script, $args = "", $no_entities = false) { |
| 2124 | 2123 | |
| 2125 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2124 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 2126 | 2125 | } |
| 2127 | 2126 | |
| 2128 | 2127 | // Pour les formulaires en methode POST, |
@@ -2157,8 +2156,7 @@ discard block |
||
| 2157 | 2156 | . "><div>\n" |
| 2158 | 2157 | . "<input type='hidden' name='exec' value='$script1' />" |
| 2159 | 2158 | . $corps |
| 2160 | - . (!$submit ? '' : |
|
| 2161 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2159 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) |
|
| 2162 | 2160 | . "</div></form>\n"; |
| 2163 | 2161 | } |
| 2164 | 2162 | |
@@ -2183,14 +2181,14 @@ discard block |
||
| 2183 | 2181 | ? generer_url_ecrire(_request('exec')) |
| 2184 | 2182 | : generer_url_public(); |
| 2185 | 2183 | |
| 2186 | - return "\n<form action='" . |
|
| 2187 | - $h . |
|
| 2188 | - "'" . |
|
| 2189 | - $atts . |
|
| 2190 | - ">\n" . |
|
| 2191 | - "<div>" . |
|
| 2192 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2193 | - $corps . |
|
| 2184 | + return "\n<form action='". |
|
| 2185 | + $h. |
|
| 2186 | + "'". |
|
| 2187 | + $atts. |
|
| 2188 | + ">\n". |
|
| 2189 | + "<div>". |
|
| 2190 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 2191 | + $corps. |
|
| 2194 | 2192 | "</div></form>"; |
| 2195 | 2193 | } |
| 2196 | 2194 | |
@@ -2218,7 +2216,7 @@ discard block |
||
| 2218 | 2216 | : generer_url_public('', '', false, false); |
| 2219 | 2217 | $url = parametre_url($url, 'action', $script); |
| 2220 | 2218 | if ($args) { |
| 2221 | - $url .= quote_amp('&' . $args); |
|
| 2219 | + $url .= quote_amp('&'.$args); |
|
| 2222 | 2220 | } |
| 2223 | 2221 | |
| 2224 | 2222 | if ($no_entities) { |
@@ -2268,17 +2266,17 @@ discard block |
||
| 2268 | 2266 | |
| 2269 | 2267 | // le nom du repertoire plugins/ activables/desactivables |
| 2270 | 2268 | if (!defined('_DIR_PLUGINS')) { |
| 2271 | - define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2269 | + define('_DIR_PLUGINS', _DIR_RACINE."plugins/"); |
|
| 2272 | 2270 | } |
| 2273 | 2271 | |
| 2274 | 2272 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 2275 | 2273 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 2276 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2274 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/"); |
|
| 2277 | 2275 | } |
| 2278 | 2276 | |
| 2279 | 2277 | // le nom du repertoire des librairies |
| 2280 | 2278 | if (!defined('_DIR_LIB')) { |
| 2281 | - define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2279 | + define('_DIR_LIB', _DIR_RACINE."lib/"); |
|
| 2282 | 2280 | } |
| 2283 | 2281 | |
| 2284 | 2282 | if (!defined('_DIR_IMG')) { |
@@ -2288,29 +2286,29 @@ discard block |
||
| 2288 | 2286 | define('_DIR_LOGOS', $pa); |
| 2289 | 2287 | } |
| 2290 | 2288 | if (!defined('_DIR_IMG_ICONES')) { |
| 2291 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2289 | + define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/"); |
|
| 2292 | 2290 | } |
| 2293 | 2291 | |
| 2294 | 2292 | if (!defined('_DIR_DUMP')) { |
| 2295 | - define('_DIR_DUMP', $ti . "dump/"); |
|
| 2293 | + define('_DIR_DUMP', $ti."dump/"); |
|
| 2296 | 2294 | } |
| 2297 | 2295 | if (!defined('_DIR_SESSIONS')) { |
| 2298 | - define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2296 | + define('_DIR_SESSIONS', $ti."sessions/"); |
|
| 2299 | 2297 | } |
| 2300 | 2298 | if (!defined('_DIR_TRANSFERT')) { |
| 2301 | - define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2299 | + define('_DIR_TRANSFERT', $ti."upload/"); |
|
| 2302 | 2300 | } |
| 2303 | 2301 | if (!defined('_DIR_CACHE')) { |
| 2304 | - define('_DIR_CACHE', $ti . "cache/"); |
|
| 2302 | + define('_DIR_CACHE', $ti."cache/"); |
|
| 2305 | 2303 | } |
| 2306 | 2304 | if (!defined('_DIR_CACHE_XML')) { |
| 2307 | - define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2305 | + define('_DIR_CACHE_XML', _DIR_CACHE."xml/"); |
|
| 2308 | 2306 | } |
| 2309 | 2307 | if (!defined('_DIR_SKELS')) { |
| 2310 | - define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2308 | + define('_DIR_SKELS', _DIR_CACHE."skel/"); |
|
| 2311 | 2309 | } |
| 2312 | 2310 | if (!defined('_DIR_AIDE')) { |
| 2313 | - define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2311 | + define('_DIR_AIDE', _DIR_CACHE."aide/"); |
|
| 2314 | 2312 | } |
| 2315 | 2313 | if (!defined('_DIR_TMP')) { |
| 2316 | 2314 | define('_DIR_TMP', $ti); |
@@ -2340,27 +2338,27 @@ discard block |
||
| 2340 | 2338 | // Declaration des fichiers |
| 2341 | 2339 | |
| 2342 | 2340 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 2343 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2341 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php"); |
|
| 2344 | 2342 | } |
| 2345 | 2343 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 2346 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2344 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php"); |
|
| 2347 | 2345 | } |
| 2348 | 2346 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 2349 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2347 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php"); |
|
| 2350 | 2348 | } |
| 2351 | 2349 | if (!defined('_CACHE_PIPELINES')) { |
| 2352 | - define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2350 | + define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 2353 | 2351 | } |
| 2354 | 2352 | if (!defined('_CACHE_CHEMIN')) { |
| 2355 | - define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2353 | + define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 2356 | 2354 | } |
| 2357 | 2355 | |
| 2358 | 2356 | # attention .php obligatoire pour ecrire_fichier_securise |
| 2359 | 2357 | if (!defined('_FILE_META')) { |
| 2360 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2358 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 2361 | 2359 | } |
| 2362 | 2360 | if (!defined('_DIR_LOG')) { |
| 2363 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2361 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 2364 | 2362 | } |
| 2365 | 2363 | if (!defined('_FILE_LOG')) { |
| 2366 | 2364 | define('_FILE_LOG', 'spip'); |
@@ -2376,8 +2374,8 @@ discard block |
||
| 2376 | 2374 | } |
| 2377 | 2375 | if (!defined('_FILE_CONNECT')) { |
| 2378 | 2376 | define('_FILE_CONNECT', |
| 2379 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2380 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2377 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 2378 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 2381 | 2379 | : false))); |
| 2382 | 2380 | } |
| 2383 | 2381 | |
@@ -2387,7 +2385,7 @@ discard block |
||
| 2387 | 2385 | } |
| 2388 | 2386 | if (!defined('_FILE_CHMOD')) { |
| 2389 | 2387 | define('_FILE_CHMOD', |
| 2390 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2388 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 2391 | 2389 | : false)); |
| 2392 | 2390 | } |
| 2393 | 2391 | |
@@ -2399,10 +2397,10 @@ discard block |
||
| 2399 | 2397 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 2400 | 2398 | } |
| 2401 | 2399 | if (!defined('_FILE_CONNECT_TMP')) { |
| 2402 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2400 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 2403 | 2401 | } |
| 2404 | 2402 | if (!defined('_FILE_CHMOD_TMP')) { |
| 2405 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2403 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 2406 | 2404 | } |
| 2407 | 2405 | |
| 2408 | 2406 | // Definition des droits d'acces en ecriture |
@@ -2420,13 +2418,13 @@ discard block |
||
| 2420 | 2418 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 2421 | 2419 | } |
| 2422 | 2420 | if (!defined('_ROOT_PLUGINS')) { |
| 2423 | - define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2421 | + define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/"); |
|
| 2424 | 2422 | } |
| 2425 | 2423 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 2426 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2424 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/"); |
|
| 2427 | 2425 | } |
| 2428 | 2426 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 2429 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2427 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2430 | 2428 | } |
| 2431 | 2429 | |
| 2432 | 2430 | // La taille des Log |
@@ -2463,7 +2461,7 @@ discard block |
||
| 2463 | 2461 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 2464 | 2462 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 2465 | 2463 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 2466 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2464 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 2467 | 2465 | |
| 2468 | 2466 | // charger tout de suite le path et son cache |
| 2469 | 2467 | load_path_cache(); |
@@ -2510,7 +2508,7 @@ discard block |
||
| 2510 | 2508 | if (!empty($_SERVER['QUERY_STRING']) |
| 2511 | 2509 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2512 | 2510 | ) { |
| 2513 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2511 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2514 | 2512 | } |
| 2515 | 2513 | } |
| 2516 | 2514 | |
@@ -2546,7 +2544,7 @@ discard block |
||
| 2546 | 2544 | |
| 2547 | 2545 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 2548 | 2546 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 2549 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2547 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '').'/'; |
|
| 2550 | 2548 | } else { |
| 2551 | 2549 | $uri_ref = ""; |
| 2552 | 2550 | } |
@@ -2634,7 +2632,7 @@ discard block |
||
| 2634 | 2632 | } |
| 2635 | 2633 | if (!defined('_CACHE_RUBRIQUES')) { |
| 2636 | 2634 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 2637 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2635 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2638 | 2636 | } |
| 2639 | 2637 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 2640 | 2638 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -2726,7 +2724,7 @@ discard block |
||
| 2726 | 2724 | $memory *= 1024; |
| 2727 | 2725 | } |
| 2728 | 2726 | if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
| 2729 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2727 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M'); |
|
| 2730 | 2728 | if (trim(ini_get('memory_limit')) != $m) { |
| 2731 | 2729 | if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
| 2732 | 2730 | define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
@@ -2876,7 +2874,7 @@ discard block |
||
| 2876 | 2874 | } |
| 2877 | 2875 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 2878 | 2876 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 2879 | - . " " . _VAR_MODE); |
|
| 2877 | + . " "._VAR_MODE); |
|
| 2880 | 2878 | } |
| 2881 | 2879 | } // pas autorise ? |
| 2882 | 2880 | else { |
@@ -2884,7 +2882,7 @@ discard block |
||
| 2884 | 2882 | if (!$GLOBALS['visiteur_session']) { |
| 2885 | 2883 | include_spip('inc/headers'); |
| 2886 | 2884 | redirige_par_entete(generer_url_public('login', |
| 2887 | - 'url=' . rawurlencode( |
|
| 2885 | + 'url='.rawurlencode( |
|
| 2888 | 2886 | parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
| 2889 | 2887 | ), true)); |
| 2890 | 2888 | } |
@@ -2937,10 +2935,10 @@ discard block |
||
| 2937 | 2935 | // mais on risque de perturber des plugins en initialisant trop tot |
| 2938 | 2936 | // certaines constantes |
| 2939 | 2937 | @spip_initialisation_core( |
| 2940 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 2941 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 2942 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 2943 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 2938 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 2939 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 2940 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 2941 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 2944 | 2942 | ); |
| 2945 | 2943 | |
| 2946 | 2944 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -2973,7 +2971,7 @@ discard block |
||
| 2973 | 2971 | } |
| 2974 | 2972 | |
| 2975 | 2973 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
| 2976 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 2974 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 2977 | 2975 | |
| 2978 | 2976 | $session = charger_fonction('session', 'inc'); |
| 2979 | 2977 | if ($session()) { |
@@ -3053,7 +3051,7 @@ discard block |
||
| 3053 | 3051 | $s = pipeline('definir_session', |
| 3054 | 3052 | $GLOBALS['visiteur_session'] |
| 3055 | 3053 | ? serialize($GLOBALS['visiteur_session']) |
| 3056 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3054 | + . '_'.@$_COOKIE['spip_session'] |
|
| 3057 | 3055 | : '' |
| 3058 | 3056 | ); |
| 3059 | 3057 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -3198,12 +3196,12 @@ discard block |
||
| 3198 | 3196 | $GLOBALS['_INC_PUBLIC']++; |
| 3199 | 3197 | |
| 3200 | 3198 | // fix #4235 |
| 3201 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3199 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3202 | 3200 | |
| 3203 | 3201 | |
| 3204 | 3202 | foreach (is_array($fond) ? $fond : array($fond) as $f) { |
| 3205 | 3203 | |
| 3206 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3204 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3207 | 3205 | |
| 3208 | 3206 | $page = evaluer_fond($f, $contexte, $connect); |
| 3209 | 3207 | if ($page === '') { |
@@ -3242,7 +3240,7 @@ discard block |
||
| 3242 | 3240 | } |
| 3243 | 3241 | |
| 3244 | 3242 | // contamination de la session appelante, pour les inclusions statiques |
| 3245 | - if (isset($page['invalideurs']['session'])){ |
|
| 3243 | + if (isset($page['invalideurs']['session'])) { |
|
| 3246 | 3244 | $cache_utilise_session_appelant = $page['invalideurs']['session']; |
| 3247 | 3245 | } |
| 3248 | 3246 | } |
@@ -3288,7 +3286,7 @@ discard block |
||
| 3288 | 3286 | * @return array|string |
| 3289 | 3287 | */ |
| 3290 | 3288 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3291 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3289 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 3292 | 3290 | if (!$pathinfo) { |
| 3293 | 3291 | return $f; |
| 3294 | 3292 | } |
@@ -3528,7 +3526,7 @@ discard block |
||
| 3528 | 3526 | |
| 3529 | 3527 | if (!is_array($params[0])) { |
| 3530 | 3528 | trigger_error( |
| 3531 | - 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
| 3529 | + 'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given', |
|
| 3532 | 3530 | E_USER_WARNING |
| 3533 | 3531 | ); |
| 3534 | 3532 | return null; |
@@ -1392,8 +1392,7 @@ discard block |
||
| 1392 | 1392 | and $f = find_in_theme("$file_svg_generique")) { |
| 1393 | 1393 | if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
| 1394 | 1394 | return $themefiles["$subdir$file"] = $fsize; |
| 1395 | - } |
|
| 1396 | - else { |
|
| 1395 | + } else { |
|
| 1397 | 1396 | return $themefiles["$subdir$file"] = $f; |
| 1398 | 1397 | } |
| 1399 | 1398 | } |
@@ -2330,12 +2329,13 @@ discard block |
||
| 2330 | 2329 | define('_DIR_CHMOD', $pi); |
| 2331 | 2330 | } |
| 2332 | 2331 | |
| 2333 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 2334 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2332 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 2333 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2335 | 2334 | // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
| 2336 | 2335 | { |
| 2337 | 2336 | $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
| 2338 | 2337 | } |
| 2338 | + } |
|
| 2339 | 2339 | |
| 2340 | 2340 | // Declaration des fichiers |
| 2341 | 2341 | |
@@ -3412,8 +3412,7 @@ discard block |
||
| 3412 | 3412 | and $h = svg_dimension_to_pixels($attrs['height'])) { |
| 3413 | 3413 | $width = $w; |
| 3414 | 3414 | $height = $h; |
| 3415 | - } |
|
| 3416 | - elseif (isset($attrs['viewBox'])) { |
|
| 3415 | + } elseif (isset($attrs['viewBox'])) { |
|
| 3417 | 3416 | $viewbox = trim($attrs['viewBox']); |
| 3418 | 3417 | $viewbox = preg_replace(",\s+,", " ", $viewbox); |
| 3419 | 3418 | $viewbox = explode(" ", $viewbox); |