@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // |
| 16 | 18 | // Utilitaires indispensables autour du serveur Http. |
@@ -32,19 +34,28 @@ discard block |
||
| 32 | 34 | function charger_fonction($nom, $dossier='exec', $continue=false) { |
| 33 | 35 | static $echecs = array(); |
| 34 | 36 | |
| 35 | - if (strlen($dossier) AND substr($dossier,-1) != '/') $dossier .= '/'; |
|
| 37 | + if (strlen($dossier) AND substr($dossier,-1) != '/') { |
|
| 38 | + $dossier .= '/'; |
|
| 39 | + } |
|
| 36 | 40 | $f = str_replace('/','_',$dossier) . $nom; |
| 37 | 41 | |
| 38 | - if (function_exists($f)) |
|
| 39 | - return $f; |
|
| 40 | - if (function_exists($g = $f . '_dist')) |
|
| 41 | - return $g; |
|
| 42 | + if (function_exists($f)) { |
|
| 43 | + return $f; |
|
| 44 | + } |
|
| 45 | + if (function_exists($g = $f . '_dist')) { |
|
| 46 | + return $g; |
|
| 47 | + } |
|
| 42 | 48 | |
| 43 | - if (isset($echecs[$f])) return $echecs[$f]; |
|
| 49 | + if (isset($echecs[$f])) { |
|
| 50 | + return $echecs[$f]; |
|
| 51 | + } |
|
| 44 | 52 | // Sinon charger le fichier de declaration si plausible |
| 45 | 53 | |
| 46 | 54 | if (!preg_match(',^\w+$,', $f)){ |
| 47 | - if ($continue) return false; //appel interne, on passe |
|
| 55 | + if ($continue) { |
|
| 56 | + return false; |
|
| 57 | + } |
|
| 58 | + //appel interne, on passe |
|
| 48 | 59 | include_spip('inc/minipres'); |
| 49 | 60 | echo minipres(); |
| 50 | 61 | exit; |
@@ -55,12 +66,19 @@ discard block |
||
| 55 | 66 | if (!$inc = include_spip($dossier.($d = strtolower($nom))) |
| 56 | 67 | // si le fichier truc/machin/nom.php n'existe pas, |
| 57 | 68 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 58 | - AND strlen(dirname($dossier)) AND dirname($dossier)!='.') |
|
| 59 | - include_spip(substr($dossier,0,-1)); |
|
| 60 | - if (function_exists($f)) return $f; |
|
| 61 | - if (function_exists($g)) return $g; |
|
| 69 | + AND strlen(dirname($dossier)) AND dirname($dossier)!='.') { |
|
| 70 | + include_spip(substr($dossier,0,-1)); |
|
| 71 | + } |
|
| 72 | + if (function_exists($f)) { |
|
| 73 | + return $f; |
|
| 74 | + } |
|
| 75 | + if (function_exists($g)) { |
|
| 76 | + return $g; |
|
| 77 | + } |
|
| 62 | 78 | |
| 63 | - if ($continue) return $echecs[$f] = false; |
|
| 79 | + if ($continue) { |
|
| 80 | + return $echecs[$f] = false; |
|
| 81 | + } |
|
| 64 | 82 | |
| 65 | 83 | // Echec : message d'erreur |
| 66 | 84 | spip_log("fonction $nom ($f ou $g) indisponible" . |
@@ -115,14 +133,15 @@ discard block |
||
| 115 | 133 | // http://doc.spip.org/@minipipe |
| 116 | 134 | function minipipe($fonc,&$val){ |
| 117 | 135 | // fonction |
| 118 | - if (function_exists($fonc)) |
|
| 119 | - $val = call_user_func($fonc, $val); |
|
| 136 | + if (function_exists($fonc)) { |
|
| 137 | + $val = call_user_func($fonc, $val); |
|
| 138 | + } |
|
| 120 | 139 | // Class::Methode |
| 121 | 140 | else if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
| 122 | 141 | AND $methode = array($regs[1], $regs[2]) |
| 123 | - AND is_callable($methode)) |
|
| 124 | - $val = call_user_func($methode, $val); |
|
| 125 | - else { |
|
| 142 | + AND is_callable($methode)) { |
|
| 143 | + $val = call_user_func($methode, $val); |
|
| 144 | + } else { |
|
| 126 | 145 | spip_log("Erreur - '$fonc' non definie !"); |
| 127 | 146 | } |
| 128 | 147 | return $val; |
@@ -140,8 +159,9 @@ discard block |
||
| 140 | 159 | // generer les fichiers php precompiles |
| 141 | 160 | // de chargement des plugins et des pipelines |
| 142 | 161 | actualise_plugins_actifs(); |
| 143 | - if (!($ok = @is_readable($charger))) |
|
| 144 | - spip_log("fichier $charger pas cree"); |
|
| 162 | + if (!($ok = @is_readable($charger))) { |
|
| 163 | + spip_log("fichier $charger pas cree"); |
|
| 164 | + } |
|
| 145 | 165 | } |
| 146 | 166 | |
| 147 | 167 | if ($ok) { |
@@ -164,8 +184,9 @@ discard block |
||
| 164 | 184 | // array_key_exists pour php 4.1.0 |
| 165 | 185 | if (is_array($val) |
| 166 | 186 | AND count($val)==2 |
| 167 | - AND (array_key_exists('data',$val))) |
|
| 168 | - $val = $val['data']; |
|
| 187 | + AND (array_key_exists('data',$val))) { |
|
| 188 | + $val = $val['data']; |
|
| 189 | + } |
|
| 169 | 190 | return $val; |
| 170 | 191 | } |
| 171 | 192 | |
@@ -190,10 +211,12 @@ discard block |
||
| 190 | 211 | static $pre = array(); |
| 191 | 212 | static $log; |
| 192 | 213 | preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
| 193 | - if (!isset($regs[1]) OR !$logname = $regs[1]) |
|
| 194 | - $logname = null; |
|
| 195 | - if (!isset($regs[2]) OR !$niveau = $regs[2]) |
|
| 196 | - $niveau = _LOG_INFO; |
|
| 214 | + if (!isset($regs[1]) OR !$logname = $regs[1]) { |
|
| 215 | + $logname = null; |
|
| 216 | + } |
|
| 217 | + if (!isset($regs[2]) OR !$niveau = $regs[2]) { |
|
| 218 | + $niveau = _LOG_INFO; |
|
| 219 | + } |
|
| 197 | 220 | |
| 198 | 221 | if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
| 199 | 222 | if (!$pre){ |
@@ -208,7 +231,9 @@ discard block |
||
| 208 | 231 | _LOG_DEBUG=>'debug:'); |
| 209 | 232 | $log = charger_fonction('log', 'inc'); |
| 210 | 233 | } |
| 211 | - if (!is_string($message)) $message = var_export($message, true); |
|
| 234 | + if (!is_string($message)) { |
|
| 235 | + $message = var_export($message, true); |
|
| 236 | + } |
|
| 212 | 237 | $log($pre[$niveau].' '.$message, $logname); |
| 213 | 238 | } |
| 214 | 239 | } |
@@ -226,12 +251,17 @@ discard block |
||
| 226 | 251 | // http://doc.spip.org/@_request |
| 227 | 252 | function _request($var, $c=false) { |
| 228 | 253 | |
| 229 | - if (is_array($c)) |
|
| 230 | - return isset($c[$var]) ? $c[$var] : NULL; |
|
| 254 | + if (is_array($c)) { |
|
| 255 | + return isset($c[$var]) ? $c[$var] : NULL; |
|
| 256 | + } |
|
| 231 | 257 | |
| 232 | - if (isset($_GET[$var])) $a = $_GET[$var]; |
|
| 233 | - elseif (isset($_POST[$var])) $a = $_POST[$var]; |
|
| 234 | - else return NULL; |
|
| 258 | + if (isset($_GET[$var])) { |
|
| 259 | + $a = $_GET[$var]; |
|
| 260 | + } elseif (isset($_POST[$var])) { |
|
| 261 | + $a = $_POST[$var]; |
|
| 262 | + } else { |
|
| 263 | + return NULL; |
|
| 264 | + } |
|
| 235 | 265 | |
| 236 | 266 | // Si on est en ajax et en POST tout a ete encode |
| 237 | 267 | // via encodeURIComponent, il faut donc repasser |
@@ -259,15 +289,17 @@ discard block |
||
| 259 | 289 | function set_request($var, $val = NULL, $c=false) { |
| 260 | 290 | if (is_array($c)) { |
| 261 | 291 | unset($c[$var]); |
| 262 | - if ($val !== NULL) |
|
| 263 | - $c[$var] = $val; |
|
| 292 | + if ($val !== NULL) { |
|
| 293 | + $c[$var] = $val; |
|
| 294 | + } |
|
| 264 | 295 | return $c; |
| 265 | 296 | } |
| 266 | 297 | |
| 267 | 298 | unset($_GET[$var]); |
| 268 | 299 | unset($_POST[$var]); |
| 269 | - if ($val !== NULL) |
|
| 270 | - $_GET[$var] = $val; |
|
| 300 | + if ($val !== NULL) { |
|
| 301 | + $_GET[$var] = $val; |
|
| 302 | + } |
|
| 271 | 303 | |
| 272 | 304 | return false; # n'affecte pas $c |
| 273 | 305 | } |
@@ -314,22 +346,26 @@ discard block |
||
| 314 | 346 | */ |
| 315 | 347 | function parametre_url($url, $c, $v=NULL, $sep='&') { |
| 316 | 348 | // requete erronnee : plusieurs variable dans $c et aucun $v |
| 317 | - if (strpos($c,"|")!==false AND is_null($v)) |
|
| 318 | - return null; |
|
| 349 | + if (strpos($c,"|")!==false AND is_null($v)) { |
|
| 350 | + return null; |
|
| 351 | + } |
|
| 319 | 352 | |
| 320 | 353 | // lever l'#ancre |
| 321 | 354 | if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
| 322 | 355 | $url = $r[1]; |
| 323 | 356 | $ancre = $r[2]; |
| 324 | - } else |
|
| 325 | - $ancre = ''; |
|
| 357 | + } else { |
|
| 358 | + $ancre = ''; |
|
| 359 | + } |
|
| 326 | 360 | |
| 327 | 361 | // eclater |
| 328 | 362 | $url = preg_split(',[?]|&|&,', $url); |
| 329 | 363 | |
| 330 | 364 | // recuperer la base |
| 331 | 365 | $a = array_shift($url); |
| 332 | - if (!$a) $a= './'; |
|
| 366 | + if (!$a) { |
|
| 367 | + $a= './'; |
|
| 368 | + } |
|
| 333 | 369 | |
| 334 | 370 | $regexp = ',^(' . str_replace('[]','\[\]',$c) . '[[]?[]]?)(=.*)?$,'; |
| 335 | 371 | $ajouts = array_flip(explode('|',$c)); |
@@ -357,15 +393,17 @@ discard block |
||
| 357 | 393 | // traiter les parametres pas encore trouves |
| 358 | 394 | if ($v === NULL |
| 359 | 395 | AND $args = func_get_args() |
| 360 | - AND count($args)==2) |
|
| 361 | - return $v; |
|
| 362 | - elseif ($testv) { |
|
| 396 | + AND count($args)==2) { |
|
| 397 | + return $v; |
|
| 398 | + } elseif ($testv) { |
|
| 363 | 399 | foreach($ajouts as $k => $n) { |
| 364 | - if (!is_array($v)) |
|
| 365 | - $url[] = $k .'=' . $u; |
|
| 366 | - else { |
|
| 400 | + if (!is_array($v)) { |
|
| 401 | + $url[] = $k .'=' . $u; |
|
| 402 | + } else { |
|
| 367 | 403 | $id = (substr($k,-2) == '[]') ? $k : ($k ."[]"); |
| 368 | - foreach ($v as $w) $url[]= $id .'=' . $w; |
|
| 404 | + foreach ($v as $w) { |
|
| 405 | + $url[]= $id .'=' . $w; |
|
| 406 | + } |
|
| 369 | 407 | } |
| 370 | 408 | } |
| 371 | 409 | } |
@@ -374,8 +412,9 @@ discard block |
||
| 374 | 412 | $url = array_filter($url); |
| 375 | 413 | |
| 376 | 414 | // recomposer l'adresse |
| 377 | - if ($url) |
|
| 378 | - $a .= '?' . join($sep, $url); |
|
| 415 | + if ($url) { |
|
| 416 | + $a .= '?' . join($sep, $url); |
|
| 417 | + } |
|
| 379 | 418 | |
| 380 | 419 | return $a . $ancre; |
| 381 | 420 | } |
@@ -390,8 +429,9 @@ discard block |
||
| 390 | 429 | $url = $r[1]; |
| 391 | 430 | } |
| 392 | 431 | if (preg_match('/[^-_a-zA-Z0-9]+/S',$ancre)){ |
| 393 | - if (!function_exists('translitteration')) |
|
| 394 | - include_spip('inc/charsets'); |
|
| 432 | + if (!function_exists('translitteration')) { |
|
| 433 | + include_spip('inc/charsets'); |
|
| 434 | + } |
|
| 395 | 435 | $ancre = preg_replace(array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), array('', '-'), |
| 396 | 436 | translitteration($ancre)); |
| 397 | 437 | } |
@@ -409,8 +449,12 @@ discard block |
||
| 409 | 449 | { |
| 410 | 450 | static $done = false; |
| 411 | 451 | static $propre = ''; |
| 412 | - if (!is_null($reset)) return $propre=$reset; |
|
| 413 | - if ($done) return $propre; |
|
| 452 | + if (!is_null($reset)) { |
|
| 453 | + return $propre=$reset; |
|
| 454 | + } |
|
| 455 | + if ($done) { |
|
| 456 | + return $propre; |
|
| 457 | + } |
|
| 414 | 458 | $done = true; |
| 415 | 459 | |
| 416 | 460 | $uri1 = $GLOBALS['REQUEST_URI']; |
@@ -442,12 +486,14 @@ discard block |
||
| 442 | 486 | $GLOBALS['profondeur_url']<(_DIR_RESTREINT?1:2) |
| 443 | 487 | // sinon c'est OK si _SET_HTML_BASE a ete force a false |
| 444 | 488 | OR (defined('_SET_HTML_BASE') AND !_SET_HTML_BASE)) |
| 445 | - ) |
|
| 446 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 489 | + ) { |
|
| 490 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 491 | + } |
|
| 447 | 492 | // ajouter le cas echeant les variables _POST['id_...'] |
| 448 | - foreach ($_POST as $v => $c) |
|
| 449 | - if (substr($v,0,3) == 'id_') |
|
| 493 | + foreach ($_POST as $v => $c) { |
|
| 494 | + if (substr($v,0,3) == 'id_') |
|
| 450 | 495 | $url = parametre_url($url, $v, $c, '&'); |
| 496 | + } |
|
| 451 | 497 | |
| 452 | 498 | // supprimer les variables sans interet |
| 453 | 499 | if (test_espace_prive()) { |
@@ -465,8 +511,9 @@ discard block |
||
| 465 | 511 | $url = str_replace(array("'", '"', '<', '[', ']'), array('%27', '%22', '%3C', '%5B', '%5D'), $url); |
| 466 | 512 | |
| 467 | 513 | // & ? |
| 468 | - if ($amp != '&') |
|
| 469 | - $url = str_replace('&', $amp, $url); |
|
| 514 | + if ($amp != '&') { |
|
| 515 | + $url = str_replace('&', $amp, $url); |
|
| 516 | + } |
|
| 470 | 517 | |
| 471 | 518 | // Si ca demarre par ? ou vide, donner './' |
| 472 | 519 | $url = preg_replace(',^([?].*)?$,', './\1', $url); |
@@ -507,8 +554,9 @@ discard block |
||
| 507 | 554 | $o = array('class'=>'', 'force'=>true); |
| 508 | 555 | if ($options){ |
| 509 | 556 | // support de l'ancien argument $class |
| 510 | - if (is_string($options)) |
|
| 511 | - $options = array('class'=>$options); |
|
| 557 | + if (is_string($options)) { |
|
| 558 | + $options = array('class'=>$options); |
|
| 559 | + } |
|
| 512 | 560 | $o = array_merge($o,$options); |
| 513 | 561 | } |
| 514 | 562 | |
@@ -531,16 +579,18 @@ discard block |
||
| 531 | 579 | $text = $traduire($texte, $lang); |
| 532 | 580 | |
| 533 | 581 | if (!strlen($text)){ |
| 534 | - if (!$o['force']) |
|
| 535 | - return ''; |
|
| 582 | + if (!$o['force']) { |
|
| 583 | + return ''; |
|
| 584 | + } |
|
| 536 | 585 | |
| 537 | 586 | $text = $texte; |
| 538 | 587 | |
| 539 | 588 | // pour les chaines non traduites, assurer un service minimum |
| 540 | - if (!$GLOBALS['test_i18n'] AND (_request('var_mode') != 'traduction')) |
|
| 541 | - $text = str_replace('_', ' ', |
|
| 589 | + if (!$GLOBALS['test_i18n'] AND (_request('var_mode') != 'traduction')) { |
|
| 590 | + $text = str_replace('_', ' ', |
|
| 542 | 591 | (($n = strpos($text,':')) === false ? $texte : |
| 543 | 592 | substr($texte, $n+1))); |
| 593 | + } |
|
| 544 | 594 | $o['class'] = null; |
| 545 | 595 | |
| 546 | 596 | } |
@@ -556,29 +606,34 @@ discard block |
||
| 556 | 606 | $f = $text; |
| 557 | 607 | if (is_array($args)) { |
| 558 | 608 | foreach ($args as $name => $value) { |
| 559 | - if ($class) |
|
| 560 | - $value = "<span class='$class'>$value</span>"; |
|
| 609 | + if ($class) { |
|
| 610 | + $value = "<span class='$class'>$value</span>"; |
|
| 611 | + } |
|
| 561 | 612 | $t = str_replace ("@$name@", $value, $text); |
| 562 | 613 | if ($text !== $t) {unset($args[$name]); $text = $t;} |
| 563 | 614 | } |
| 564 | 615 | // Si des variables n'ont pas ete inserees, le signaler |
| 565 | 616 | // (chaines de langues pas a jour) |
| 566 | - if ($args) spip_log("$f: variables inutilisees " . join(', ', array_keys($args)),_LOG_DEBUG); |
|
| 617 | + if ($args) { |
|
| 618 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)),_LOG_DEBUG); |
|
| 619 | + } |
|
| 567 | 620 | } |
| 568 | 621 | |
| 569 | - if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class===null) |
|
| 570 | - return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 571 | - else |
|
| 572 | - return $text; |
|
| 573 | -} |
|
| 622 | + if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class===null) { |
|
| 623 | + return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 624 | + } else { |
|
| 625 | + return $text; |
|
| 626 | + } |
|
| 627 | + } |
|
| 574 | 628 | |
| 575 | 629 | // Afficher "ecrire/data/" au lieu de "data/" dans les messages |
| 576 | 630 | // ou tmp/ au lieu de ../tmp/ |
| 577 | 631 | // http://doc.spip.org/@joli_repertoire |
| 578 | 632 | function joli_repertoire($rep) { |
| 579 | 633 | $a = substr($rep,0,1); |
| 580 | - if ($a<>'.' AND $a<>'/') |
|
| 581 | - $rep = (_DIR_RESTREINT?'':_DIR_RESTREINT_ABS).$rep; |
|
| 634 | + if ($a<>'.' AND $a<>'/') { |
|
| 635 | + $rep = (_DIR_RESTREINT?'':_DIR_RESTREINT_ABS).$rep; |
|
| 636 | + } |
|
| 582 | 637 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 583 | 638 | return $rep; |
| 584 | 639 | } |
@@ -593,7 +648,10 @@ discard block |
||
| 593 | 648 | $a=time(); $b=microtime(); |
| 594 | 649 | // microtime peut contenir les microsecondes et le temps |
| 595 | 650 | $b=explode(' ',$b); |
| 596 | - if (count($b)==2) $a = end($b); // plus precis ! |
|
| 651 | + if (count($b)==2) { |
|
| 652 | + $a = end($b); |
|
| 653 | + } |
|
| 654 | + // plus precis ! |
|
| 597 | 655 | $b = reset($b); |
| 598 | 656 | if (!isset($time[$t])) { |
| 599 | 657 | $time[$t] = $a + $b; |
@@ -601,10 +659,12 @@ discard block |
||
| 601 | 659 | $p = ($a + $b - $time[$t]) * 1000; |
| 602 | 660 | unset($time[$t]); |
| 603 | 661 | # echo "'$p'";exit; |
| 604 | - if ($raw) return $p; |
|
| 605 | - if ($p < 1000) |
|
| 606 | - $s = ''; |
|
| 607 | - else { |
|
| 662 | + if ($raw) { |
|
| 663 | + return $p; |
|
| 664 | + } |
|
| 665 | + if ($p < 1000) { |
|
| 666 | + $s = ''; |
|
| 667 | + } else { |
|
| 608 | 668 | $s = sprintf("%d ", $x = floor($p/1000)); |
| 609 | 669 | $p -= ($x*1000); |
| 610 | 670 | } |
@@ -619,8 +679,9 @@ discard block |
||
| 619 | 679 | function spip_touch($fichier, $duree=0, $touch=true) { |
| 620 | 680 | if ($duree) { |
| 621 | 681 | clearstatcache(); |
| 622 | - if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree)) |
|
| 623 | - return false; |
|
| 682 | + if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree)) { |
|
| 683 | + return false; |
|
| 684 | + } |
|
| 624 | 685 | } |
| 625 | 686 | if ($touch!==false) { |
| 626 | 687 | if (!@touch($fichier)) { spip_unlink($fichier); @touch($fichier); }; |
@@ -663,13 +724,20 @@ discard block |
||
| 663 | 724 | */ |
| 664 | 725 | function cron ($taches=array(), $taches_old= array()) { |
| 665 | 726 | // si pas en mode cron force, laisser tomber. |
| 666 | - if (!defined('_DIRECT_CRON_FORCE')) return false; |
|
| 667 | - if (!is_array($taches)) $taches = $taches_old; // compat anciens appels |
|
| 727 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 728 | + return false; |
|
| 729 | + } |
|
| 730 | + if (!is_array($taches)) { |
|
| 731 | + $taches = $taches_old; |
|
| 732 | + } |
|
| 733 | + // compat anciens appels |
|
| 668 | 734 | // si taches a inserer en base et base inaccessible, laisser tomber |
| 669 | 735 | // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
| 670 | 736 | // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
| 671 | 737 | // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
| 672 | - if ($taches AND count($taches) AND !spip_connect()) return false; |
|
| 738 | + if ($taches AND count($taches) AND !spip_connect()) { |
|
| 739 | + return false; |
|
| 740 | + } |
|
| 673 | 741 | spip_log("cron !",'jq'._LOG_DEBUG); |
| 674 | 742 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 675 | 743 | return $genie($taches); |
@@ -743,28 +811,31 @@ discard block |
||
| 743 | 811 | */ |
| 744 | 812 | function queue_sleep_time_to_next_job($force=null) { |
| 745 | 813 | static $queue_next_job_time = -1; |
| 746 | - if ($force===true) |
|
| 747 | - $queue_next_job_time = -1; |
|
| 748 | - elseif ($force) |
|
| 749 | - $queue_next_job_time = $force; |
|
| 814 | + if ($force===true) { |
|
| 815 | + $queue_next_job_time = -1; |
|
| 816 | + } elseif ($force) { |
|
| 817 | + $queue_next_job_time = $force; |
|
| 818 | + } |
|
| 750 | 819 | |
| 751 | 820 | if ($queue_next_job_time==-1) { |
| 752 | 821 | define('_JQ_NEXT_JOB_TIME_FILENAME',_DIR_TMP . "job_queue_next.txt"); |
| 753 | 822 | // utiliser un cache memoire si dispo |
| 754 | 823 | if (include_spip('inc/memoization') AND defined('_MEMOIZE_MEMORY') AND _MEMOIZE_MEMORY) { |
| 755 | 824 | $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
| 756 | - } |
|
| 757 | - else { |
|
| 825 | + } else { |
|
| 758 | 826 | $queue_next_job_time = null; |
| 759 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) |
|
| 760 | - $queue_next_job_time = intval($contenu); |
|
| 827 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 828 | + $queue_next_job_time = intval($contenu); |
|
| 829 | + } |
|
| 761 | 830 | } |
| 762 | 831 | } |
| 763 | 832 | |
| 764 | - if (is_null($queue_next_job_time)) |
|
| 765 | - return null; |
|
| 766 | - if (!$_SERVER['REQUEST_TIME']) |
|
| 767 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 833 | + if (is_null($queue_next_job_time)) { |
|
| 834 | + return null; |
|
| 835 | + } |
|
| 836 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 837 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 838 | + } |
|
| 768 | 839 | return $queue_next_job_time-$_SERVER['REQUEST_TIME']; |
| 769 | 840 | } |
| 770 | 841 | |
@@ -786,14 +857,17 @@ discard block |
||
| 786 | 857 | $done[$src] = true; |
| 787 | 858 | $src = find_in_path($src, _JAVASCRIPT); |
| 788 | 859 | $src = " src='$src'"; |
| 860 | + } else { |
|
| 861 | + $src = ''; |
|
| 789 | 862 | } |
| 790 | - else $src = ''; |
|
| 791 | - if ($script) |
|
| 792 | - $script = ("/*<![CDATA[*/\n" . |
|
| 863 | + if ($script) { |
|
| 864 | + $script = ("/*<![CDATA[*/\n" . |
|
| 793 | 865 | preg_replace(',</([^>]*)>,','<\/\1>', $script) . |
| 794 | 866 | "/*]]>*/"); |
| 795 | - if ($noscript) |
|
| 796 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 867 | + } |
|
| 868 | + if ($noscript) { |
|
| 869 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 870 | + } |
|
| 797 | 871 | |
| 798 | 872 | return ($src OR $script OR $noscript) |
| 799 | 873 | ? "<script type='text/javascript'$src>$script</script>$noscript" |
@@ -826,43 +900,53 @@ discard block |
||
| 826 | 900 | _DIR_RACINE.'prive/:'. |
| 827 | 901 | _DIR_RESTREINT; |
| 828 | 902 | // Ajouter squelettes/ |
| 829 | - if (@is_dir(_DIR_RACINE.'squelettes')) |
|
| 830 | - $path = _DIR_RACINE.'squelettes/:' . $path; |
|
| 903 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 904 | + $path = _DIR_RACINE.'squelettes/:' . $path; |
|
| 905 | + } |
|
| 831 | 906 | foreach (explode(':', $path) as $dir) { |
| 832 | - if (strlen($dir) AND substr($dir,-1) != '/') |
|
| 833 | - $dir .= "/"; |
|
| 907 | + if (strlen($dir) AND substr($dir,-1) != '/') { |
|
| 908 | + $dir .= "/"; |
|
| 909 | + } |
|
| 834 | 910 | $path_base[] = $dir; |
| 835 | 911 | } |
| 836 | 912 | $path_full = $path_base; |
| 837 | 913 | // Et le(s) dossier(s) des squelettes nommes |
| 838 | - if (strlen($GLOBALS['dossier_squelettes'])) |
|
| 839 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 914 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 915 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 840 | 916 | array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
| 917 | + } |
|
| 841 | 918 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
| 842 | 919 | } |
| 843 | - if ($dir_path===NULL) return $path_full; |
|
| 920 | + if ($dir_path===NULL) { |
|
| 921 | + return $path_full; |
|
| 922 | + } |
|
| 844 | 923 | |
| 845 | 924 | if (strlen($dir_path)){ |
| 846 | 925 | $tete = ""; |
| 847 | - if (reset($path_base)==_DIR_RACINE.'squelettes/') |
|
| 848 | - $tete = array_shift($path_base); |
|
| 926 | + if (reset($path_base)==_DIR_RACINE.'squelettes/') { |
|
| 927 | + $tete = array_shift($path_base); |
|
| 928 | + } |
|
| 849 | 929 | $dirs = array_reverse(explode(':',$dir_path)); |
| 850 | 930 | foreach($dirs as $dir_path){ |
| 851 | 931 | #if ($dir_path{0}!='/') |
| 852 | 932 | # $dir_path = $dir_path; |
| 853 | - if (substr($dir_path,-1) != '/') |
|
| 854 | - $dir_path .= "/"; |
|
| 855 | - if (!in_array($dir_path,$path_base)) |
|
| 856 | - array_unshift($path_base,$dir_path); |
|
| 933 | + if (substr($dir_path,-1) != '/') { |
|
| 934 | + $dir_path .= "/"; |
|
| 935 | + } |
|
| 936 | + if (!in_array($dir_path,$path_base)) { |
|
| 937 | + array_unshift($path_base,$dir_path); |
|
| 938 | + } |
|
| 939 | + } |
|
| 940 | + if (strlen($tete)) { |
|
| 941 | + array_unshift($path_base,$tete); |
|
| 857 | 942 | } |
| 858 | - if (strlen($tete)) |
|
| 859 | - array_unshift($path_base,$tete); |
|
| 860 | 943 | } |
| 861 | 944 | $path_full = $path_base; |
| 862 | 945 | // Et le(s) dossier(s) des squelettes nommes |
| 863 | - if (strlen($GLOBALS['dossier_squelettes'])) |
|
| 864 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 946 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 947 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 865 | 948 | array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
| 949 | + } |
|
| 866 | 950 | |
| 867 | 951 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
| 868 | 952 | return $path_full; |
@@ -887,8 +971,9 @@ discard block |
||
| 887 | 971 | static $themes = null; |
| 888 | 972 | if (is_null($themes)){ |
| 889 | 973 | // si pas encore definie |
| 890 | - if (!defined('_SPIP_THEME_PRIVE')) |
|
| 891 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 974 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 975 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 976 | + } |
|
| 892 | 977 | $themes = array(_SPIP_THEME_PRIVE); |
| 893 | 978 | // lors d'une installation neuve, prefs n'est pas definie. |
| 894 | 979 | if (isset($GLOBALS['visiteur_session']['prefs'])) { |
@@ -896,24 +981,30 @@ discard block |
||
| 896 | 981 | } else { |
| 897 | 982 | $prefs = array(); |
| 898 | 983 | } |
| 899 | - if (is_string($prefs)) |
|
| 900 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 984 | + if (is_string($prefs)) { |
|
| 985 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 986 | + } |
|
| 901 | 987 | if ( |
| 902 | 988 | ((isset($prefs['theme']) AND $theme = $prefs['theme']) |
| 903 | 989 | OR (isset($GLOBALS['theme_prive_defaut']) AND $theme = $GLOBALS['theme_prive_defaut'])) |
| 904 | - AND $theme != _SPIP_THEME_PRIVE) |
|
| 905 | - array_unshift($themes,$theme); // placer le theme choisi en tete |
|
| 990 | + AND $theme != _SPIP_THEME_PRIVE) { |
|
| 991 | + array_unshift($themes,$theme); |
|
| 992 | + } |
|
| 993 | + // placer le theme choisi en tete |
|
| 906 | 994 | } |
| 907 | 995 | return $themes; |
| 908 | 996 | } |
| 909 | 997 | |
| 910 | 998 | function find_in_theme($file, $subdir='', $include=false){ |
| 911 | 999 | static $themefiles=array(); |
| 912 | - if (isset($themefiles["$subdir$file"])) return $themefiles["$subdir$file"]; |
|
| 1000 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1001 | + return $themefiles["$subdir$file"]; |
|
| 1002 | + } |
|
| 913 | 1003 | $themes = lister_themes_prives(); |
| 914 | 1004 | foreach($themes as $theme){ |
| 915 | - if ($f = find_in_path($file,"prive/themes/$theme/$subdir",$include)) |
|
| 916 | - return $themefiles["$subdir$file"] = $f; |
|
| 1005 | + if ($f = find_in_path($file,"prive/themes/$theme/$subdir",$include)) { |
|
| 1006 | + return $themefiles["$subdir$file"] = $f; |
|
| 1007 | + } |
|
| 917 | 1008 | } |
| 918 | 1009 | spip_log("$file introuvable dans le theme prive ".reset($themes),'theme'); |
| 919 | 1010 | return $themefiles["$subdir$file"] = ""; |
@@ -928,18 +1019,23 @@ discard block |
||
| 928 | 1019 | function chemin_image($icone){ |
| 929 | 1020 | static $icone_renommer; |
| 930 | 1021 | // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
| 931 | - if (strpos($icone,"/")!==false AND file_exists($icone)) return $icone; |
|
| 1022 | + if (strpos($icone,"/")!==false AND file_exists($icone)) { |
|
| 1023 | + return $icone; |
|
| 1024 | + } |
|
| 932 | 1025 | |
| 933 | 1026 | // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
| 934 | - if (preg_match(',[.](png|gif|jpg)$,',$icone) AND $f = find_in_theme("images/$icone")) |
|
| 935 | - return $f; |
|
| 1027 | + if (preg_match(',[.](png|gif|jpg)$,',$icone) AND $f = find_in_theme("images/$icone")) { |
|
| 1028 | + return $f; |
|
| 1029 | + } |
|
| 936 | 1030 | // sinon passer par le module de renommage |
| 937 | - if (is_null($icone_renommer)) |
|
| 938 | - $icone_renommer = charger_fonction('icone_renommer','inc',true); |
|
| 1031 | + if (is_null($icone_renommer)) { |
|
| 1032 | + $icone_renommer = charger_fonction('icone_renommer','inc',true); |
|
| 1033 | + } |
|
| 939 | 1034 | if ($icone_renommer){ |
| 940 | 1035 | list($icone,$fonction) = $icone_renommer($icone,""); |
| 941 | - if (file_exists($icone)) |
|
| 942 | - return $icone; |
|
| 1036 | + if (file_exists($icone)) { |
|
| 1037 | + return $icone; |
|
| 1038 | + } |
|
| 943 | 1039 | } |
| 944 | 1040 | return find_in_path ($icone, _NOM_IMG_PACK); |
| 945 | 1041 | } |
@@ -965,8 +1061,9 @@ discard block |
||
| 965 | 1061 | } |
| 966 | 1062 | |
| 967 | 1063 | if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
| 968 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) |
|
| 969 | - return false; |
|
| 1064 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1065 | + return false; |
|
| 1066 | + } |
|
| 970 | 1067 | if ($include AND !isset($inc[$dirname][$file])) { |
| 971 | 1068 | include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
| 972 | 1069 | $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
@@ -981,8 +1078,9 @@ discard block |
||
| 981 | 1078 | } |
| 982 | 1079 | |
| 983 | 1080 | foreach(creer_chemin() as $dir) { |
| 984 | - if (!isset($dirs[$a = $dir . $dirname])) |
|
| 985 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a) ; |
|
| 1081 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1082 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a) ; |
|
| 1083 | + } |
|
| 986 | 1084 | if ($dirs[$a]) { |
| 987 | 1085 | if (file_exists(_ROOT_CWD . ($a .= $file))) { |
| 988 | 1086 | if ($include AND !isset($inc[$dirname][$file])) { |
@@ -991,7 +1089,9 @@ discard block |
||
| 991 | 1089 | } |
| 992 | 1090 | if (!defined('_SAUVER_CHEMIN')){ |
| 993 | 1091 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
| 994 | - if (is_null($GLOBALS['path_files'])) return $a; |
|
| 1092 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1093 | + return $a; |
|
| 1094 | + } |
|
| 995 | 1095 | define('_SAUVER_CHEMIN', true); |
| 996 | 1096 | } |
| 997 | 1097 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
@@ -1004,8 +1104,9 @@ discard block |
||
| 1004 | 1104 | if ($include==='required'){ |
| 1005 | 1105 | echo '<pre>', |
| 1006 | 1106 | "<strong>Erreur Fatale</strong><br />"; |
| 1007 | - if (function_exists('debug_print_backtrace')) |
|
| 1008 | - echo debug_print_backtrace(); |
|
| 1107 | + if (function_exists('debug_print_backtrace')) { |
|
| 1108 | + echo debug_print_backtrace(); |
|
| 1109 | + } |
|
| 1009 | 1110 | echo '</pre>'; |
| 1010 | 1111 | die("Erreur interne: ne peut inclure $dirname$file"); |
| 1011 | 1112 | } |
@@ -1013,7 +1114,9 @@ discard block |
||
| 1013 | 1114 | |
| 1014 | 1115 | if (!defined('_SAUVER_CHEMIN')){ |
| 1015 | 1116 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
| 1016 | - if (is_null($GLOBALS['path_files'])) return false; |
|
| 1117 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1118 | + return false; |
|
| 1119 | + } |
|
| 1017 | 1120 | define('_SAUVER_CHEMIN', true); |
| 1018 | 1121 | } |
| 1019 | 1122 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
@@ -1045,8 +1148,9 @@ discard block |
||
| 1045 | 1148 | // mais si semble corrompu on relit avec un verrou |
| 1046 | 1149 | if (!$GLOBALS['path_files']=unserialize($contenu)){ |
| 1047 | 1150 | lire_fichier(_CACHE_CHEMIN,$contenu); |
| 1048 | - if (!$GLOBALS['path_files']=unserialize($contenu)) |
|
| 1049 | - $GLOBALS['path_files'] = array(); |
|
| 1151 | + if (!$GLOBALS['path_files']=unserialize($contenu)) { |
|
| 1152 | + $GLOBALS['path_files'] = array(); |
|
| 1153 | + } |
|
| 1050 | 1154 | } |
| 1051 | 1155 | } |
| 1052 | 1156 | } |
@@ -1054,9 +1158,10 @@ discard block |
||
| 1054 | 1158 | |
| 1055 | 1159 | function save_path_cache(){ |
| 1056 | 1160 | if (defined('_SAUVER_CHEMIN') |
| 1057 | - AND _SAUVER_CHEMIN) |
|
| 1058 | - ecrire_fichier(_CACHE_CHEMIN,serialize($GLOBALS['path_files'])); |
|
| 1059 | -} |
|
| 1161 | + AND _SAUVER_CHEMIN) { |
|
| 1162 | + ecrire_fichier(_CACHE_CHEMIN,serialize($GLOBALS['path_files'])); |
|
| 1163 | + } |
|
| 1164 | + } |
|
| 1060 | 1165 | |
| 1061 | 1166 | |
| 1062 | 1167 | /** |
@@ -1084,8 +1189,9 @@ discard block |
||
| 1084 | 1189 | // ne prendre que les fichiers pas deja trouves |
| 1085 | 1190 | // car find_in_path prend le premier qu'il trouve, |
| 1086 | 1191 | // les autres sont donc masques |
| 1087 | - if (!isset($liste_fichiers[$nom])) |
|
| 1088 | - $liste_fichiers[$nom] = $chemin; |
|
| 1192 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1193 | + $liste_fichiers[$nom] = $chemin; |
|
| 1194 | + } |
|
| 1089 | 1195 | } |
| 1090 | 1196 | } |
| 1091 | 1197 | } |
@@ -1128,13 +1234,18 @@ discard block |
||
| 1128 | 1234 | */ |
| 1129 | 1235 | function generer_url_entite($id='', $entite='', $args='', $ancre='', $public=NULL, $type=NULL) |
| 1130 | 1236 | { |
| 1131 | - if ($public === NULL) $public = !test_espace_prive(); |
|
| 1237 | + if ($public === NULL) { |
|
| 1238 | + $public = !test_espace_prive(); |
|
| 1239 | + } |
|
| 1132 | 1240 | $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
| 1133 | 1241 | |
| 1134 | 1242 | if (!$public) { |
| 1135 | - if (!$entite) return ''; |
|
| 1136 | - if (!function_exists('generer_url_ecrire_objet')) |
|
| 1137 | - include_spip('inc/urls'); |
|
| 1243 | + if (!$entite) { |
|
| 1244 | + return ''; |
|
| 1245 | + } |
|
| 1246 | + if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1247 | + include_spip('inc/urls'); |
|
| 1248 | + } |
|
| 1138 | 1249 | $res = generer_url_ecrire_objet($entite,$id, $args, $ancre, false); |
| 1139 | 1250 | } else { |
| 1140 | 1251 | if ($type === NULL) { |
@@ -1146,32 +1257,42 @@ discard block |
||
| 1146 | 1257 | |
| 1147 | 1258 | $f = charger_fonction($type, 'urls', true); |
| 1148 | 1259 | // se rabattre sur les urls page si les urls perso non dispo |
| 1149 | - if (!$f) $f = charger_fonction('page', 'urls', true); |
|
| 1260 | + if (!$f) { |
|
| 1261 | + $f = charger_fonction('page', 'urls', true); |
|
| 1262 | + } |
|
| 1150 | 1263 | |
| 1151 | 1264 | // si $entite='', on veut la fonction de passage URL ==> id |
| 1152 | 1265 | // sinon on veut effectuer le passage id ==> URL |
| 1153 | - if (!$entite) return $f; |
|
| 1266 | + if (!$entite) { |
|
| 1267 | + return $f; |
|
| 1268 | + } |
|
| 1154 | 1269 | |
| 1155 | 1270 | // mais d'abord il faut tester le cas des urls sur une |
| 1156 | 1271 | // base distante |
| 1157 | 1272 | if (is_string($public) |
| 1158 | - AND $g = charger_fonction('connect', 'urls', true)) |
|
| 1159 | - $f = $g; |
|
| 1273 | + AND $g = charger_fonction('connect', 'urls', true)) { |
|
| 1274 | + $f = $g; |
|
| 1275 | + } |
|
| 1160 | 1276 | |
| 1161 | 1277 | $res = $f(intval($id), $entite, $args, $ancre, $public); |
| 1162 | 1278 | |
| 1163 | 1279 | } |
| 1164 | - if ($res) return $res; |
|
| 1280 | + if ($res) { |
|
| 1281 | + return $res; |
|
| 1282 | + } |
|
| 1165 | 1283 | // Sinon c'est un raccourci ou compat SPIP < 2 |
| 1166 | 1284 | if (!function_exists($f = 'generer_url_' . $entite)) { |
| 1167 | - if (!function_exists($f .= '_dist')) $f = ''; |
|
| 1285 | + if (!function_exists($f .= '_dist')) { |
|
| 1286 | + $f = ''; |
|
| 1287 | + } |
|
| 1168 | 1288 | } |
| 1169 | 1289 | if ($f) { |
| 1170 | 1290 | $url = $f($id, $args, $ancre); |
| 1171 | - if (strlen($args)) |
|
| 1172 | - $url .= strstr($url, '?') |
|
| 1291 | + if (strlen($args)) { |
|
| 1292 | + $url .= strstr($url, '?') |
|
| 1173 | 1293 | ? '&'.$args |
| 1174 | 1294 | : '?'.$args; |
| 1295 | + } |
|
| 1175 | 1296 | return $url; |
| 1176 | 1297 | } |
| 1177 | 1298 | // On a ete gentil mais la .... |
@@ -1182,12 +1303,14 @@ discard block |
||
| 1182 | 1303 | function generer_url_ecrire_entite_edit($id, $entite, $args='', $ancre=''){ |
| 1183 | 1304 | $exec = objet_info($entite,'url_edit'); |
| 1184 | 1305 | $url = generer_url_ecrire($exec,$args); |
| 1185 | - if (intval($id)) |
|
| 1186 | - $url = parametre_url($url,id_table_objet($entite),$id); |
|
| 1187 | - else |
|
| 1188 | - $url = parametre_url($url,'new','oui'); |
|
| 1189 | - if ($ancre) |
|
| 1190 | - $url = ancre_url($url,$ancre); |
|
| 1306 | + if (intval($id)) { |
|
| 1307 | + $url = parametre_url($url,id_table_objet($entite),$id); |
|
| 1308 | + } else { |
|
| 1309 | + $url = parametre_url($url,'new','oui'); |
|
| 1310 | + } |
|
| 1311 | + if ($ancre) { |
|
| 1312 | + $url = ancre_url($url,$ancre); |
|
| 1313 | + } |
|
| 1191 | 1314 | return $url; |
| 1192 | 1315 | } |
| 1193 | 1316 | |
@@ -1207,8 +1330,9 @@ discard block |
||
| 1207 | 1330 | if (preg_match(',[^\x00-\x7E],sS', $url)){ |
| 1208 | 1331 | $uri = ''; |
| 1209 | 1332 | for ($i=0; $i < strlen($url); $i++) { |
| 1210 | - if (ord($a = $url[$i]) > 127) |
|
| 1211 | - $a = rawurlencode($a); |
|
| 1333 | + if (ord($a = $url[$i]) > 127) { |
|
| 1334 | + $a = rawurlencode($a); |
|
| 1335 | + } |
|
| 1212 | 1336 | $uri .= $a; |
| 1213 | 1337 | } |
| 1214 | 1338 | $url = $uri; |
@@ -1219,7 +1343,9 @@ discard block |
||
| 1219 | 1343 | // http://doc.spip.org/@generer_url_entite_absolue |
| 1220 | 1344 | function generer_url_entite_absolue($id='', $entite='', $args='', $ancre='', $connect=NULL) |
| 1221 | 1345 | { |
| 1222 | - if (!$connect) $connect = true; |
|
| 1346 | + if (!$connect) { |
|
| 1347 | + $connect = true; |
|
| 1348 | + } |
|
| 1223 | 1349 | $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
| 1224 | 1350 | if (!preg_match(',^\w+:,', $h)) { |
| 1225 | 1351 | include_spip('inc/filtres_mini'); |
@@ -1232,7 +1358,9 @@ discard block |
||
| 1232 | 1358 | // variables d'environnement comme $_SERVER[HTTPS] ou ini_get(register_globals) |
| 1233 | 1359 | // http://doc.spip.org/@test_valeur_serveur |
| 1234 | 1360 | function test_valeur_serveur($truc) { |
| 1235 | - if (!$truc) return false; |
|
| 1361 | + if (!$truc) { |
|
| 1362 | + return false; |
|
| 1363 | + } |
|
| 1236 | 1364 | return (strtolower($truc) !== 'off'); |
| 1237 | 1365 | } |
| 1238 | 1366 | |
@@ -1259,13 +1387,20 @@ discard block |
||
| 1259 | 1387 | function url_de_base($profondeur=null) { |
| 1260 | 1388 | |
| 1261 | 1389 | static $url = array(); |
| 1262 | - if (is_array($profondeur)) return $url = $profondeur; |
|
| 1263 | - if ($profondeur===false) return $url; |
|
| 1390 | + if (is_array($profondeur)) { |
|
| 1391 | + return $url = $profondeur; |
|
| 1392 | + } |
|
| 1393 | + if ($profondeur===false) { |
|
| 1394 | + return $url; |
|
| 1395 | + } |
|
| 1264 | 1396 | |
| 1265 | - if (is_null($profondeur)) $profondeur = $GLOBALS['profondeur_url']; |
|
| 1397 | + if (is_null($profondeur)) { |
|
| 1398 | + $profondeur = $GLOBALS['profondeur_url']; |
|
| 1399 | + } |
|
| 1266 | 1400 | |
| 1267 | - if (isset($url[$profondeur])) |
|
| 1268 | - return $url[$profondeur]; |
|
| 1401 | + if (isset($url[$profondeur])) { |
|
| 1402 | + return $url[$profondeur]; |
|
| 1403 | + } |
|
| 1269 | 1404 | |
| 1270 | 1405 | $http = ( |
| 1271 | 1406 | (isset($_SERVER["SCRIPT_URI"]) AND |
@@ -1286,8 +1421,12 @@ discard block |
||
| 1286 | 1421 | if (isset($_SERVER['SERVER_PORT']) |
| 1287 | 1422 | AND $port=$_SERVER['SERVER_PORT'] |
| 1288 | 1423 | AND strpos($host,":")==false){ |
| 1289 | - if ($http=="http" AND $port!=80) $host.=":$port"; |
|
| 1290 | - if ($http=="https" AND $port!=443) $host.=":$port"; |
|
| 1424 | + if ($http=="http" AND $port!=80) { |
|
| 1425 | + $host.=":$port"; |
|
| 1426 | + } |
|
| 1427 | + if ($http=="https" AND $port!=443) { |
|
| 1428 | + $host.=":$port"; |
|
| 1429 | + } |
|
| 1291 | 1430 | } |
| 1292 | 1431 | if (!$GLOBALS['REQUEST_URI']){ |
| 1293 | 1432 | if (isset($_SERVER['REQUEST_URI'])) { |
@@ -1295,8 +1434,9 @@ discard block |
||
| 1295 | 1434 | } else { |
| 1296 | 1435 | $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
| 1297 | 1436 | if ($_SERVER['QUERY_STRING'] |
| 1298 | - AND !strpos($_SERVER['REQUEST_URI'], '?')) |
|
| 1299 | - $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1437 | + AND !strpos($_SERVER['REQUEST_URI'], '?')) { |
|
| 1438 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1439 | + } |
|
| 1300 | 1440 | } |
| 1301 | 1441 | } |
| 1302 | 1442 | |
@@ -1345,18 +1485,22 @@ discard block |
||
| 1345 | 1485 | |
| 1346 | 1486 | // http://doc.spip.org/@generer_url_ecrire |
| 1347 | 1487 | function generer_url_ecrire($script='', $args="", $no_entities=false, $rel=false) { |
| 1348 | - if (!$rel) |
|
| 1349 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 1350 | - else if (!is_string($rel)) |
|
| 1351 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 1488 | + if (!$rel) { |
|
| 1489 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 1490 | + } else if (!is_string($rel)) { |
|
| 1491 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 1352 | 1492 | ('./' . _SPIP_ECRIRE_SCRIPT); |
| 1493 | + } |
|
| 1353 | 1494 | |
| 1354 | 1495 | @list($script, $ancre) = explode('#', $script); |
| 1355 | - if ($script AND ($script<>'accueil' OR $rel)) |
|
| 1356 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 1357 | - elseif ($args) |
|
| 1358 | - $args ="?$args"; |
|
| 1359 | - if ($ancre) $args .= "#$ancre"; |
|
| 1496 | + if ($script AND ($script<>'accueil' OR $rel)) { |
|
| 1497 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 1498 | + } elseif ($args) { |
|
| 1499 | + $args ="?$args"; |
|
| 1500 | + } |
|
| 1501 | + if ($ancre) { |
|
| 1502 | + $args .= "#$ancre"; |
|
| 1503 | + } |
|
| 1360 | 1504 | return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
| 1361 | 1505 | } |
| 1362 | 1506 | |
@@ -1375,32 +1519,39 @@ discard block |
||
| 1375 | 1519 | // http://doc.spip.org/@get_spip_script |
| 1376 | 1520 | function get_spip_script($default='') { |
| 1377 | 1521 | # cas define('_SPIP_SCRIPT', ''); |
| 1378 | - if (_SPIP_SCRIPT) |
|
| 1379 | - return _SPIP_SCRIPT; |
|
| 1380 | - else |
|
| 1381 | - return $default; |
|
| 1382 | -} |
|
| 1522 | + if (_SPIP_SCRIPT) { |
|
| 1523 | + return _SPIP_SCRIPT; |
|
| 1524 | + } else { |
|
| 1525 | + return $default; |
|
| 1526 | + } |
|
| 1527 | + } |
|
| 1383 | 1528 | |
| 1384 | 1529 | // http://doc.spip.org/@generer_url_public |
| 1385 | 1530 | function generer_url_public($script='', $args="", $no_entities=false, $rel=true, $action='') { |
| 1386 | 1531 | // si le script est une action (spip_pass, spip_inscription), |
| 1387 | 1532 | // standardiser vers la nouvelle API |
| 1388 | 1533 | |
| 1389 | - if (!$action) $action = get_spip_script(); |
|
| 1390 | - if ($script) |
|
| 1391 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 1534 | + if (!$action) { |
|
| 1535 | + $action = get_spip_script(); |
|
| 1536 | + } |
|
| 1537 | + if ($script) { |
|
| 1538 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 1539 | + } |
|
| 1392 | 1540 | |
| 1393 | 1541 | if ($args) { |
| 1394 | 1542 | if (is_array($args)) { |
| 1395 | 1543 | $r = ''; |
| 1396 | - foreach($args as $k => $v) $r .= '&' . $k . '=' . $v; |
|
| 1544 | + foreach($args as $k => $v) { |
|
| 1545 | + $r .= '&' . $k . '=' . $v; |
|
| 1546 | + } |
|
| 1397 | 1547 | $args = substr($r,1); |
| 1398 | 1548 | } |
| 1399 | 1549 | $action .= |
| 1400 | 1550 | (strpos($action, '?') !== false ? '&' : '?') . $args; |
| 1401 | 1551 | } |
| 1402 | - if (!$no_entities) |
|
| 1403 | - $action = quote_amp($action); |
|
| 1552 | + if (!$no_entities) { |
|
| 1553 | + $action = quote_amp($action); |
|
| 1554 | + } |
|
| 1404 | 1555 | |
| 1405 | 1556 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 1406 | 1557 | return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(),'/') . preg_replace(",^/[.]/,","/","/$action")); |
@@ -1478,9 +1629,13 @@ discard block |
||
| 1478 | 1629 | ? generer_url_ecrire(_request('exec')) |
| 1479 | 1630 | : generer_url_public('','',false,false); |
| 1480 | 1631 | $url = parametre_url($url,'action',$script); |
| 1481 | - if ($args) $url .= quote_amp('&'.$args); |
|
| 1632 | + if ($args) { |
|
| 1633 | + $url .= quote_amp('&'.$args); |
|
| 1634 | + } |
|
| 1482 | 1635 | |
| 1483 | - if ($no_entities) $url = str_replace('&','&',$url); |
|
| 1636 | + if ($no_entities) { |
|
| 1637 | + $url = str_replace('&','&',$url); |
|
| 1638 | + } |
|
| 1484 | 1639 | return $url; |
| 1485 | 1640 | } |
| 1486 | 1641 | |
@@ -1514,107 +1669,204 @@ discard block |
||
| 1514 | 1669 | */ |
| 1515 | 1670 | function spip_initialisation_core($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { |
| 1516 | 1671 | static $too_late = 0; |
| 1517 | - if ($too_late++) return; |
|
| 1672 | + if ($too_late++) { |
|
| 1673 | + return; |
|
| 1674 | + } |
|
| 1518 | 1675 | |
| 1519 | 1676 | // Declaration des repertoires |
| 1520 | 1677 | |
| 1521 | 1678 | // le nom du repertoire plugins/ activables/desactivables |
| 1522 | - if (!defined('_DIR_PLUGINS')) define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 1679 | + if (!defined('_DIR_PLUGINS')) { |
|
| 1680 | + define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 1681 | + } |
|
| 1523 | 1682 | |
| 1524 | 1683 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 1525 | - if (!defined('_DIR_PLUGINS_DIST')) define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 1684 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 1685 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 1686 | + } |
|
| 1526 | 1687 | |
| 1527 | 1688 | // le nom du repertoire des librairies |
| 1528 | - if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 1689 | + if (!defined('_DIR_LIB')) { |
|
| 1690 | + define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 1691 | + } |
|
| 1529 | 1692 | |
| 1530 | - if (!defined('_DIR_IMG')) define('_DIR_IMG', $pa); |
|
| 1531 | - if (!defined('_DIR_LOGOS')) define('_DIR_LOGOS', $pa); |
|
| 1532 | - if (!defined('_DIR_IMG_ICONES')) define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 1533 | - |
|
| 1534 | - if (!defined('_DIR_DUMP')) define('_DIR_DUMP', $ti . "dump/"); |
|
| 1535 | - if (!defined('_DIR_SESSIONS')) define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 1536 | - if (!defined('_DIR_TRANSFERT')) define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 1537 | - if (!defined('_DIR_CACHE')) define('_DIR_CACHE', $ti . "cache/"); |
|
| 1538 | - if (!defined('_DIR_CACHE_XML')) define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 1539 | - if (!defined('_DIR_SKELS')) define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 1540 | - if (!defined('_DIR_AIDE')) define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 1541 | - if (!defined('_DIR_TMP')) define('_DIR_TMP', $ti); |
|
| 1542 | - |
|
| 1543 | - if (!defined('_DIR_VAR')) define('_DIR_VAR', $ta); |
|
| 1544 | - |
|
| 1545 | - if (!defined('_DIR_ETC')) define('_DIR_ETC', $pi); |
|
| 1546 | - if (!defined('_DIR_CONNECT')) define('_DIR_CONNECT', $pi); |
|
| 1547 | - if (!defined('_DIR_CHMOD')) define('_DIR_CHMOD', $pi); |
|
| 1548 | - |
|
| 1549 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 1550 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 1693 | + if (!defined('_DIR_IMG')) { |
|
| 1694 | + define('_DIR_IMG', $pa); |
|
| 1695 | + } |
|
| 1696 | + if (!defined('_DIR_LOGOS')) { |
|
| 1697 | + define('_DIR_LOGOS', $pa); |
|
| 1698 | + } |
|
| 1699 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 1700 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 1701 | + } |
|
| 1702 | + |
|
| 1703 | + if (!defined('_DIR_DUMP')) { |
|
| 1704 | + define('_DIR_DUMP', $ti . "dump/"); |
|
| 1705 | + } |
|
| 1706 | + if (!defined('_DIR_SESSIONS')) { |
|
| 1707 | + define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 1708 | + } |
|
| 1709 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 1710 | + define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 1711 | + } |
|
| 1712 | + if (!defined('_DIR_CACHE')) { |
|
| 1713 | + define('_DIR_CACHE', $ti . "cache/"); |
|
| 1714 | + } |
|
| 1715 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 1716 | + define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 1717 | + } |
|
| 1718 | + if (!defined('_DIR_SKELS')) { |
|
| 1719 | + define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 1720 | + } |
|
| 1721 | + if (!defined('_DIR_AIDE')) { |
|
| 1722 | + define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 1723 | + } |
|
| 1724 | + if (!defined('_DIR_TMP')) { |
|
| 1725 | + define('_DIR_TMP', $ti); |
|
| 1726 | + } |
|
| 1727 | + |
|
| 1728 | + if (!defined('_DIR_VAR')) { |
|
| 1729 | + define('_DIR_VAR', $ta); |
|
| 1730 | + } |
|
| 1731 | + |
|
| 1732 | + if (!defined('_DIR_ETC')) { |
|
| 1733 | + define('_DIR_ETC', $pi); |
|
| 1734 | + } |
|
| 1735 | + if (!defined('_DIR_CONNECT')) { |
|
| 1736 | + define('_DIR_CONNECT', $pi); |
|
| 1737 | + } |
|
| 1738 | + if (!defined('_DIR_CHMOD')) { |
|
| 1739 | + define('_DIR_CHMOD', $pi); |
|
| 1740 | + } |
|
| 1741 | + |
|
| 1742 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 1743 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 1551 | 1744 | // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
| 1552 | 1745 | $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
| 1746 | + } |
|
| 1553 | 1747 | |
| 1554 | 1748 | // Declaration des fichiers |
| 1555 | 1749 | |
| 1556 | - if (!defined('_CACHE_PLUGINS_PATH')) define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 1557 | - if (!defined('_CACHE_PLUGINS_OPT')) define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 1558 | - if (!defined('_CACHE_PLUGINS_FCT')) define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 1559 | - if (!defined('_CACHE_PIPELINES')) define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 1560 | - if (!defined('_CACHE_CHEMIN')) define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 1750 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 1751 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 1752 | + } |
|
| 1753 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 1754 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 1755 | + } |
|
| 1756 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 1757 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 1758 | + } |
|
| 1759 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 1760 | + define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 1761 | + } |
|
| 1762 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 1763 | + define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 1764 | + } |
|
| 1561 | 1765 | |
| 1562 | 1766 | # attention .php obligatoire pour ecrire_fichier_securise |
| 1563 | - if (!defined('_FILE_META')) define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 1564 | - if (!defined('_DIR_LOG')) define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 1565 | - if (!defined('_FILE_LOG')) define('_FILE_LOG', 'spip'); |
|
| 1566 | - if (!defined('_FILE_LOG_SUFFIX')) define('_FILE_LOG_SUFFIX', '.log'); |
|
| 1767 | + if (!defined('_FILE_META')) { |
|
| 1768 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 1769 | + } |
|
| 1770 | + if (!defined('_DIR_LOG')) { |
|
| 1771 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 1772 | + } |
|
| 1773 | + if (!defined('_FILE_LOG')) { |
|
| 1774 | + define('_FILE_LOG', 'spip'); |
|
| 1775 | + } |
|
| 1776 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 1777 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 1778 | + } |
|
| 1567 | 1779 | |
| 1568 | 1780 | // Le fichier de connexion a la base de donnees |
| 1569 | 1781 | // tient compte des anciennes versions (inc_connect...) |
| 1570 | - if (!defined('_FILE_CONNECT_INS')) define('_FILE_CONNECT_INS', 'connect'); |
|
| 1571 | - if (!defined('_FILE_CONNECT')) define('_FILE_CONNECT', |
|
| 1782 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 1783 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 1784 | + } |
|
| 1785 | + if (!defined('_FILE_CONNECT')) { |
|
| 1786 | + define('_FILE_CONNECT', |
|
| 1572 | 1787 | (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
| 1573 | 1788 | : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
| 1574 | 1789 | : false))); |
| 1790 | + } |
|
| 1575 | 1791 | |
| 1576 | 1792 | // Le fichier de reglages des droits |
| 1577 | - if (!defined('_FILE_CHMOD_INS')) define('_FILE_CHMOD_INS', 'chmod'); |
|
| 1578 | - if (!defined('_FILE_CHMOD')) define('_FILE_CHMOD', |
|
| 1793 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 1794 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 1795 | + } |
|
| 1796 | + if (!defined('_FILE_CHMOD')) { |
|
| 1797 | + define('_FILE_CHMOD', |
|
| 1579 | 1798 | (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
| 1580 | 1799 | : false)); |
| 1800 | + } |
|
| 1581 | 1801 | |
| 1582 | - if (!defined('_FILE_LDAP')) define('_FILE_LDAP', 'ldap.php'); |
|
| 1802 | + if (!defined('_FILE_LDAP')) { |
|
| 1803 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 1804 | + } |
|
| 1583 | 1805 | |
| 1584 | - if (!defined('_FILE_TMP_SUFFIX')) define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 1585 | - if (!defined('_FILE_CONNECT_TMP')) define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 1586 | - if (!defined('_FILE_CHMOD_TMP')) define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 1806 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 1807 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 1808 | + } |
|
| 1809 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 1810 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 1811 | + } |
|
| 1812 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 1813 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 1814 | + } |
|
| 1587 | 1815 | |
| 1588 | 1816 | // Definition des droits d'acces en ecriture |
| 1589 | - if (!defined('_SPIP_CHMOD') AND _FILE_CHMOD) |
|
| 1590 | - include_once _FILE_CHMOD; |
|
| 1817 | + if (!defined('_SPIP_CHMOD') AND _FILE_CHMOD) { |
|
| 1818 | + include_once _FILE_CHMOD; |
|
| 1819 | + } |
|
| 1591 | 1820 | |
| 1592 | 1821 | // Se mefier des fichiers mal remplis! |
| 1593 | - if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', 0777); |
|
| 1822 | + if (!defined('_SPIP_CHMOD')) { |
|
| 1823 | + define('_SPIP_CHMOD', 0777); |
|
| 1824 | + } |
|
| 1594 | 1825 | |
| 1595 | 1826 | // Le charset par defaut lors de l'installation |
| 1596 | - if (!defined('_DEFAULT_CHARSET')) define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 1597 | - if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 1598 | - if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 1599 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL)); |
|
| 1827 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 1828 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 1829 | + } |
|
| 1830 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 1831 | + define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 1832 | + } |
|
| 1833 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 1834 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 1835 | + } |
|
| 1836 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 1837 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL)); |
|
| 1838 | + } |
|
| 1600 | 1839 | |
| 1601 | 1840 | // La taille des Log |
| 1602 | - if (!defined('_MAX_LOG')) define('_MAX_LOG', 100); |
|
| 1841 | + if (!defined('_MAX_LOG')) { |
|
| 1842 | + define('_MAX_LOG', 100); |
|
| 1843 | + } |
|
| 1603 | 1844 | |
| 1604 | 1845 | // Sommes-nous dans l'empire du Mal ? |
| 1605 | 1846 | // (ou sous le signe du Pingouin, ascendant GNU ?) |
| 1606 | 1847 | if (strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false){ |
| 1607 | - if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', 'windows'); |
|
| 1608 | - if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1609 | - } |
|
| 1610 | - else { |
|
| 1611 | - if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', ''); |
|
| 1612 | - if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1848 | + if (!defined('_OS_SERVEUR')) { |
|
| 1849 | + define('_OS_SERVEUR', 'windows'); |
|
| 1850 | + } |
|
| 1851 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 1852 | + define('_SPIP_LOCK_MODE',1); |
|
| 1853 | + } |
|
| 1854 | + // utiliser le flock php |
|
| 1855 | + } else { |
|
| 1856 | + if (!defined('_OS_SERVEUR')) { |
|
| 1857 | + define('_OS_SERVEUR', ''); |
|
| 1858 | + } |
|
| 1859 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 1860 | + define('_SPIP_LOCK_MODE',1); |
|
| 1861 | + } |
|
| 1862 | + // utiliser le flock php |
|
| 1613 | 1863 | #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
| 1614 | 1864 | } |
| 1615 | 1865 | |
| 1616 | 1866 | // Langue par defaut |
| 1617 | - if (!defined('_LANGUE_PAR_DEFAUT')) define('_LANGUE_PAR_DEFAUT','fr'); |
|
| 1867 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 1868 | + define('_LANGUE_PAR_DEFAUT','fr'); |
|
| 1869 | + } |
|
| 1618 | 1870 | |
| 1619 | 1871 | // PHP_VERSION_ID dispo depuis PHP 5.2.7 |
| 1620 | 1872 | if (!defined('PHP_VERSION_ID')) { |
@@ -1639,7 +1891,9 @@ discard block |
||
| 1639 | 1891 | // |
| 1640 | 1892 | |
| 1641 | 1893 | // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
| 1642 | - if (isset($_REQUEST['GLOBALS'])) die(); |
|
| 1894 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 1895 | + die(); |
|
| 1896 | + } |
|
| 1643 | 1897 | // nettoyer les magic quotes \' et les caracteres nuls %00 |
| 1644 | 1898 | spip_desinfecte($_GET); |
| 1645 | 1899 | spip_desinfecte($_POST); |
@@ -1658,8 +1912,9 @@ discard block |
||
| 1658 | 1912 | // ne pas desinfecter les globales en profondeur car elle contient aussi les |
| 1659 | 1913 | // precedentes, qui seraient desinfectees 2 fois. |
| 1660 | 1914 | spip_desinfecte($GLOBALS,false); |
| 1661 | - if (include_spip('inc/php3')) |
|
| 1662 | - spip_register_globals(true); |
|
| 1915 | + if (include_spip('inc/php3')) { |
|
| 1916 | + spip_register_globals(true); |
|
| 1917 | + } |
|
| 1663 | 1918 | |
| 1664 | 1919 | $avertir_register_globals = true; |
| 1665 | 1920 | } |
@@ -1688,12 +1943,15 @@ discard block |
||
| 1688 | 1943 | } else { |
| 1689 | 1944 | $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
| 1690 | 1945 | if ($_SERVER['QUERY_STRING'] |
| 1691 | - AND !strpos($_SERVER['REQUEST_URI'], '?')) |
|
| 1692 | - $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1946 | + AND !strpos($_SERVER['REQUEST_URI'], '?')) { |
|
| 1947 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1948 | + } |
|
| 1693 | 1949 | } |
| 1694 | 1950 | |
| 1695 | 1951 | // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
| 1696 | - if (!defined('_RENOUVELLE_ALEA')) define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 1952 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 1953 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 1954 | + } |
|
| 1697 | 1955 | |
| 1698 | 1956 | // charger les meta si possible et renouveller l'alea au besoin |
| 1699 | 1957 | // charge aussi effacer_meta et ecrire_meta |
@@ -1701,16 +1959,17 @@ discard block |
||
| 1701 | 1959 | $inc_meta(); |
| 1702 | 1960 | |
| 1703 | 1961 | // on a pas pu le faire plus tot |
| 1704 | - if ($avertir_register_globals) |
|
| 1705 | - avertir_auteurs("register_globals",_L("Problème de sécurité : register_globals=on; dans php.ini à corriger.")); |
|
| 1962 | + if ($avertir_register_globals) { |
|
| 1963 | + avertir_auteurs("register_globals",_L("Problème de sécurité : register_globals=on; dans php.ini à corriger.")); |
|
| 1964 | + } |
|
| 1706 | 1965 | |
| 1707 | 1966 | // nombre de repertoires depuis la racine |
| 1708 | 1967 | // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
| 1709 | 1968 | // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
| 1710 | 1969 | // le calcul est faux) |
| 1711 | - if (!_DIR_RESTREINT) |
|
| 1712 | - $GLOBALS['profondeur_url'] = 1; |
|
| 1713 | - else { |
|
| 1970 | + if (!_DIR_RESTREINT) { |
|
| 1971 | + $GLOBALS['profondeur_url'] = 1; |
|
| 1972 | + } else { |
|
| 1714 | 1973 | $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
| 1715 | 1974 | $uri_ref = $_SERVER["SCRIPT_NAME"]; |
| 1716 | 1975 | if (!$uri_ref |
@@ -1723,13 +1982,13 @@ discard block |
||
| 1723 | 1982 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 1724 | 1983 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 1725 | 1984 | $uri_ref = $uri_ref['path'].'/'; |
| 1726 | - } |
|
| 1727 | - else |
|
| 1728 | - $uri_ref = ""; |
|
| 1985 | + } else { |
|
| 1986 | + $uri_ref = ""; |
|
| 1987 | + } |
|
| 1729 | 1988 | } |
| 1730 | - if (!$uri OR !$uri_ref) |
|
| 1731 | - $GLOBALS['profondeur_url'] = 0; |
|
| 1732 | - else { |
|
| 1989 | + if (!$uri OR !$uri_ref) { |
|
| 1990 | + $GLOBALS['profondeur_url'] = 0; |
|
| 1991 | + } else { |
|
| 1733 | 1992 | $GLOBALS['profondeur_url'] = max(0, |
| 1734 | 1993 | substr_count($uri[0], '/') |
| 1735 | 1994 | - substr_count($uri_ref,'/')); |
@@ -1739,8 +1998,9 @@ discard block |
||
| 1739 | 1998 | if (_FILE_CONNECT) { |
| 1740 | 1999 | if (verifier_visiteur()=='0minirezo' |
| 1741 | 2000 | // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
| 1742 | - AND !isset($_COOKIE['spip_admin'])) |
|
| 1743 | - clear_path_cache(); |
|
| 2001 | + AND !isset($_COOKIE['spip_admin'])) { |
|
| 2002 | + clear_path_cache(); |
|
| 2003 | + } |
|
| 1744 | 2004 | } |
| 1745 | 2005 | |
| 1746 | 2006 | } |
@@ -1752,74 +2012,140 @@ discard block |
||
| 1752 | 2012 | */ |
| 1753 | 2013 | function spip_initialisation_suite() { |
| 1754 | 2014 | static $too_late = 0; |
| 1755 | - if ($too_late++) return; |
|
| 2015 | + if ($too_late++) { |
|
| 2016 | + return; |
|
| 2017 | + } |
|
| 1756 | 2018 | |
| 1757 | 2019 | // taille mini des login |
| 1758 | - if (!defined('_LOGIN_TROP_COURT')) define('_LOGIN_TROP_COURT', 4); |
|
| 2020 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2021 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2022 | + } |
|
| 1759 | 2023 | |
| 1760 | 2024 | // la taille maxi des logos (0 : pas de limite) |
| 1761 | - if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 1762 | - if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 1763 | - if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2025 | + if (!defined('_LOGO_MAX_SIZE')) { |
|
| 2026 | + define('_LOGO_MAX_SIZE', 0); |
|
| 2027 | + } |
|
| 2028 | + # poids en ko |
|
| 2029 | + if (!defined('_LOGO_MAX_WIDTH')) { |
|
| 2030 | + define('_LOGO_MAX_WIDTH', 0); |
|
| 2031 | + } |
|
| 2032 | + # largeur en pixels |
|
| 2033 | + if (!defined('_LOGO_MAX_HEIGHT')) { |
|
| 2034 | + define('_LOGO_MAX_HEIGHT', 0); |
|
| 2035 | + } |
|
| 2036 | + # hauteur en pixels |
|
| 1764 | 2037 | |
| 1765 | - if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2038 | + if (!defined('_DOC_MAX_SIZE')) { |
|
| 2039 | + define('_DOC_MAX_SIZE', 0); |
|
| 2040 | + } |
|
| 2041 | + # poids en ko |
|
| 1766 | 2042 | |
| 1767 | - if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 1768 | - if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 1769 | - if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 1770 | - if (!defined('_PASS_LONGUEUR_MINI')) define('_PASS_LONGUEUR_MINI',6); |
|
| 2043 | + if (!defined('_IMG_MAX_SIZE')) { |
|
| 2044 | + define('_IMG_MAX_SIZE', 0); |
|
| 2045 | + } |
|
| 2046 | + # poids en ko |
|
| 2047 | + if (!defined('_IMG_MAX_WIDTH')) { |
|
| 2048 | + define('_IMG_MAX_WIDTH', 0); |
|
| 2049 | + } |
|
| 2050 | + # largeur en pixels |
|
| 2051 | + if (!defined('_IMG_MAX_HEIGHT')) { |
|
| 2052 | + define('_IMG_MAX_HEIGHT', 0); |
|
| 2053 | + } |
|
| 2054 | + # hauteur en pixels |
|
| 2055 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2056 | + define('_PASS_LONGUEUR_MINI',6); |
|
| 2057 | + } |
|
| 1771 | 2058 | |
| 1772 | 2059 | |
| 1773 | 2060 | // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
| 1774 | - if (!defined('_IMG_QUALITE')) define('_IMG_QUALITE', 85); # valeur par defaut |
|
| 1775 | - if (!defined('_IMG_GD_QUALITE')) define('_IMG_GD_QUALITE', _IMG_QUALITE); # surcharge pour la lib GD |
|
| 1776 | - if (!defined('_IMG_CONVERT_QUALITE')) define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); # surcharge pour imagick en ligne de commande |
|
| 2061 | + if (!defined('_IMG_QUALITE')) { |
|
| 2062 | + define('_IMG_QUALITE', 85); |
|
| 2063 | + } |
|
| 2064 | + # valeur par defaut |
|
| 2065 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2066 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2067 | + } |
|
| 2068 | + # surcharge pour la lib GD |
|
| 2069 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2070 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2071 | + } |
|
| 2072 | + # surcharge pour imagick en ligne de commande |
|
| 1777 | 2073 | // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
| 1778 | - if (!defined('_IMG_IMAGICK_QUALITE')) define('_IMG_IMAGICK_QUALITE', 75); # surcharge pour imagick en PHP |
|
| 2074 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2075 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2076 | + } |
|
| 2077 | + # surcharge pour imagick en PHP |
|
| 1779 | 2078 | |
| 1780 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) define('_COPIE_LOCALE_MAX_SIZE',16777216); // poids en octet |
|
| 2079 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2080 | + define('_COPIE_LOCALE_MAX_SIZE',16777216); |
|
| 2081 | + } |
|
| 2082 | + // poids en octet |
|
| 1781 | 2083 | |
| 1782 | 2084 | // qq chaines standard |
| 1783 | - if (!defined('_ACCESS_FILE_NAME')) define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 1784 | - if (!defined('_AUTH_USER_FILE')) define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 1785 | - if (!defined('_SPIP_DUMP')) define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 1786 | - if (!defined('_CACHE_RUBRIQUES')) define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 1787 | - if (!defined('_CACHE_RUBRIQUES_MAX')) define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2085 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2086 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2087 | + } |
|
| 2088 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2089 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2090 | + } |
|
| 2091 | + if (!defined('_SPIP_DUMP')) { |
|
| 2092 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2093 | + } |
|
| 2094 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2095 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2096 | + } |
|
| 2097 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2098 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2099 | + } |
|
| 1788 | 2100 | |
| 1789 | - if (!defined('_EXTENSION_SQUELETTES')) define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2101 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2102 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2103 | + } |
|
| 1790 | 2104 | |
| 1791 | - if (!defined('_DOCTYPE_ECRIRE')) define('_DOCTYPE_ECRIRE', |
|
| 2105 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2106 | + define('_DOCTYPE_ECRIRE', |
|
| 1792 | 2107 | // "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n"); |
| 1793 | 2108 | //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n"); |
| 1794 | 2109 | //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n"); |
| 1795 | 2110 | // "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 //EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\n"); |
| 1796 | 2111 | "<!DOCTYPE html>\n"); |
| 1797 | - if (!defined('_DOCTYPE_AIDE')) define('_DOCTYPE_AIDE', |
|
| 2112 | + } |
|
| 2113 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2114 | + define('_DOCTYPE_AIDE', |
|
| 1798 | 2115 | "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
| 2116 | + } |
|
| 1799 | 2117 | |
| 1800 | 2118 | // L'adresse de base du site ; on peut mettre '' si la racine est geree par |
| 1801 | 2119 | // le script de l'espace public, alias index.php |
| 1802 | - if (!defined('_SPIP_SCRIPT')) define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2120 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2121 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2122 | + } |
|
| 1803 | 2123 | // argument page, personalisable en cas de conflit avec un autre script |
| 1804 | - if (!defined('_SPIP_PAGE')) define('_SPIP_PAGE', 'page'); |
|
| 2124 | + if (!defined('_SPIP_PAGE')) { |
|
| 2125 | + define('_SPIP_PAGE', 'page'); |
|
| 2126 | + } |
|
| 1805 | 2127 | |
| 1806 | 2128 | // le script de l'espace prive |
| 1807 | 2129 | // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
| 1808 | 2130 | // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
| 1809 | 2131 | // meme pb sur thttpd cf. http://forum.spip.org/fr_184153.html |
| 1810 | 2132 | |
| 1811 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) define('_SPIP_ECRIRE_SCRIPT', // true ? #decommenter ici et commenter la |
|
| 2133 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2134 | + define('_SPIP_ECRIRE_SCRIPT', // true ? #decommenter ici et commenter la |
|
| 1812 | 2135 | preg_match(',IIS|thttpd,',$_SERVER['SERVER_SOFTWARE']) ? |
| 1813 | 2136 | 'index.php' : ''); |
| 2137 | + } |
|
| 1814 | 2138 | |
| 1815 | 2139 | |
| 1816 | - if (!defined('_SPIP_AJAX')) |
|
| 1817 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2140 | + if (!defined('_SPIP_AJAX')) { |
|
| 2141 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 1818 | 2142 | ? 1 |
| 1819 | 2143 | : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
| 2144 | + } |
|
| 1820 | 2145 | |
| 1821 | 2146 | // La requete est-elle en ajax ? |
| 1822 | - if (!defined('_AJAX')) define('_AJAX', |
|
| 2147 | + if (!defined('_AJAX')) { |
|
| 2148 | + define('_AJAX', |
|
| 1823 | 2149 | (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
| 1824 | 2150 | OR @$_REQUEST['var_ajax_redir'] # redirection 302 apres ajax jQuery |
| 1825 | 2151 | OR @$_REQUEST['var_ajaxcharset'] # compat ascendante pour plugins |
@@ -1827,16 +2153,22 @@ discard block |
||
| 1827 | 2153 | ) |
| 1828 | 2154 | AND !@$_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 |
| 1829 | 2155 | ); |
| 2156 | + } |
|
| 1830 | 2157 | |
| 1831 | 2158 | # nombre de pixels maxi pour calcul de la vignette avec gd |
| 1832 | 2159 | # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
| 1833 | 2160 | # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
| 1834 | - if (!defined('_IMG_GD_MAX_PIXELS')) define('_IMG_GD_MAX_PIXELS', |
|
| 2161 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2162 | + define('_IMG_GD_MAX_PIXELS', |
|
| 1835 | 2163 | (isset($GLOBALS['meta']['max_taille_vignettes'])&&$GLOBALS['meta']['max_taille_vignettes']<5500000) |
| 1836 | 2164 | ? $GLOBALS['meta']['max_taille_vignettes'] |
| 1837 | 2165 | : 0); |
| 2166 | + } |
|
| 1838 | 2167 | |
| 1839 | - if (!defined('_MEMORY_LIMIT_MIN')) define('_MEMORY_LIMIT_MIN',10); // en Mo |
|
| 2168 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2169 | + define('_MEMORY_LIMIT_MIN',10); |
|
| 2170 | + } |
|
| 2171 | + // en Mo |
|
| 1840 | 2172 | // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
| 1841 | 2173 | // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
| 1842 | 2174 | // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
@@ -1852,16 +2184,22 @@ discard block |
||
| 1852 | 2184 | if ($memory<_MEMORY_LIMIT_MIN*1024*1024){ |
| 1853 | 2185 | ini_set('memory_limit',$m=_MEMORY_LIMIT_MIN.'M'); |
| 1854 | 2186 | if (trim(ini_get('memory_limit'))!=$m){ |
| 1855 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2187 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2188 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); |
|
| 2189 | + } |
|
| 2190 | + // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1856 | 2191 | } |
| 1857 | 2192 | } |
| 1858 | - } |
|
| 1859 | - else |
|
| 1860 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2193 | + } else |
|
| 2194 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2195 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); |
|
| 2196 | + } |
|
| 2197 | + // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1861 | 2198 | } |
| 1862 | 2199 | // Protocoles a normaliser dans les chaines de langues |
| 1863 | - if (!defined('_PROTOCOLES_STD')) |
|
| 1864 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2200 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2201 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2202 | + } |
|
| 1865 | 2203 | |
| 1866 | 2204 | init_var_mode(); |
| 1867 | 2205 | } |
@@ -1877,7 +2215,9 @@ discard block |
||
| 1877 | 2215 | // tout le monde peut calcul/recalcul |
| 1878 | 2216 | if ($_GET['var_mode'] == 'calcul' |
| 1879 | 2217 | OR $_GET['var_mode'] == 'recalcul') { |
| 1880 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 2218 | + if (!defined('_VAR_MODE')) { |
|
| 2219 | + define('_VAR_MODE',$_GET['var_mode']); |
|
| 2220 | + } |
|
| 1881 | 2221 | } |
| 1882 | 2222 | // preview, debug, blocs, urls et images necessitent une autorisation |
| 1883 | 2223 | else if (in_array($_GET['var_mode'],array('preview','debug','inclure','urls','images','traduction'))) { |
@@ -1890,48 +2230,79 @@ discard block |
||
| 1890 | 2230 | switch($_GET['var_mode']){ |
| 1891 | 2231 | case 'traduction': |
| 1892 | 2232 | // forcer le calcul pour passer dans traduire |
| 1893 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 2233 | + if (!defined('_VAR_MODE')) { |
|
| 2234 | + define('_VAR_MODE','calcul'); |
|
| 2235 | + } |
|
| 1894 | 2236 | // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
| 1895 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 2237 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2238 | + define('_VAR_NOCACHE',true); |
|
| 2239 | + } |
|
| 1896 | 2240 | break; |
| 1897 | 2241 | case 'preview': |
| 1898 | 2242 | // basculer sur les criteres de preview dans les boucles |
| 1899 | - if (!defined('_VAR_PREVIEW')) define('_VAR_PREVIEW',true); |
|
| 2243 | + if (!defined('_VAR_PREVIEW')) { |
|
| 2244 | + define('_VAR_PREVIEW',true); |
|
| 2245 | + } |
|
| 1900 | 2246 | // forcer le calcul |
| 1901 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 2247 | + if (!defined('_VAR_MODE')) { |
|
| 2248 | + define('_VAR_MODE','calcul'); |
|
| 2249 | + } |
|
| 1902 | 2250 | // et ne pas enregistrer de cache |
| 1903 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 2251 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2252 | + define('_VAR_NOCACHE',true); |
|
| 2253 | + } |
|
| 1904 | 2254 | break; |
| 1905 | 2255 | case 'inclure': |
| 1906 | 2256 | // forcer le compilo et ignorer les caches existants |
| 1907 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1908 | - if (!defined('_VAR_INCLURE')) define('_VAR_INCLURE',true); |
|
| 2257 | + if (!defined('_VAR_MODE')) { |
|
| 2258 | + define('_VAR_MODE','calcul'); |
|
| 2259 | + } |
|
| 2260 | + if (!defined('_VAR_INCLURE')) { |
|
| 2261 | + define('_VAR_INCLURE',true); |
|
| 2262 | + } |
|
| 1909 | 2263 | // et ne pas enregistrer de cache |
| 1910 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 2264 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2265 | + define('_VAR_NOCACHE',true); |
|
| 2266 | + } |
|
| 1911 | 2267 | break; |
| 1912 | 2268 | case 'urls': |
| 1913 | 2269 | // forcer le compilo et ignorer les caches existants |
| 1914 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1915 | - if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 2270 | + if (!defined('_VAR_MODE')) { |
|
| 2271 | + define('_VAR_MODE','calcul'); |
|
| 2272 | + } |
|
| 2273 | + if (!defined('_VAR_URLS')) { |
|
| 2274 | + define('_VAR_URLS',true); |
|
| 2275 | + } |
|
| 1916 | 2276 | break; |
| 1917 | 2277 | case 'images': |
| 1918 | 2278 | // forcer le compilo et ignorer les caches existants |
| 1919 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 2279 | + if (!defined('_VAR_MODE')) { |
|
| 2280 | + define('_VAR_MODE','calcul'); |
|
| 2281 | + } |
|
| 1920 | 2282 | // indiquer qu'on doit recalculer les images |
| 1921 | - if (!defined('_VAR_IMAGES')) define('_VAR_IMAGES',true); |
|
| 2283 | + if (!defined('_VAR_IMAGES')) { |
|
| 2284 | + define('_VAR_IMAGES',true); |
|
| 2285 | + } |
|
| 1922 | 2286 | break; |
| 1923 | 2287 | case 'debug': |
| 1924 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','debug'); |
|
| 2288 | + if (!defined('_VAR_MODE')) { |
|
| 2289 | + define('_VAR_MODE','debug'); |
|
| 2290 | + } |
|
| 1925 | 2291 | // et ne pas enregistrer de cache |
| 1926 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 2292 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2293 | + define('_VAR_NOCACHE',true); |
|
| 2294 | + } |
|
| 1927 | 2295 | break; |
| 1928 | 2296 | default : |
| 1929 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 2297 | + if (!defined('_VAR_MODE')) { |
|
| 2298 | + define('_VAR_MODE',$_GET['var_mode']); |
|
| 2299 | + } |
|
| 1930 | 2300 | break; |
| 1931 | 2301 | } |
| 1932 | - if (isset($GLOBALS['visiteur_session']['nom'])) |
|
| 1933 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2302 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2303 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 1934 | 2304 | . " "._VAR_MODE); |
| 2305 | + } |
|
| 1935 | 2306 | } |
| 1936 | 2307 | // pas autorise ? |
| 1937 | 2308 | else { |
@@ -1946,7 +2317,9 @@ discard block |
||
| 1946 | 2317 | // sinon tant pis |
| 1947 | 2318 | } |
| 1948 | 2319 | } |
| 1949 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',false); |
|
| 2320 | + if (!defined('_VAR_MODE')) { |
|
| 2321 | + define('_VAR_MODE',false); |
|
| 2322 | + } |
|
| 1950 | 2323 | } |
| 1951 | 2324 | $done = true; |
| 1952 | 2325 | } |
@@ -1958,18 +2331,21 @@ discard block |
||
| 1958 | 2331 | // http://doc.spip.org/@spip_desinfecte |
| 1959 | 2332 | function spip_desinfecte(&$t,$deep = true) { |
| 1960 | 2333 | static $magic_quotes; |
| 1961 | - if (!isset($magic_quotes)) |
|
| 1962 | - $magic_quotes = @get_magic_quotes_gpc(); |
|
| 2334 | + if (!isset($magic_quotes)) { |
|
| 2335 | + $magic_quotes = @get_magic_quotes_gpc(); |
|
| 2336 | + } |
|
| 1963 | 2337 | |
| 1964 | 2338 | foreach ($t as $key => $val) { |
| 1965 | 2339 | if (is_string($t[$key])) { |
| 1966 | - if ($magic_quotes) |
|
| 1967 | - $t[$key] = stripslashes($t[$key]); |
|
| 2340 | + if ($magic_quotes) { |
|
| 2341 | + $t[$key] = stripslashes($t[$key]); |
|
| 2342 | + } |
|
| 1968 | 2343 | $t[$key] = str_replace(chr(0), '-', $t[$key]); |
| 1969 | 2344 | } |
| 1970 | 2345 | // traiter aussi les "texte_plus" de article_edit |
| 1971 | - else if ($deep AND is_array($t[$key]) AND $key!=='GLOBALS') |
|
| 1972 | - spip_desinfecte($t[$key],$deep); |
|
| 2346 | + else if ($deep AND is_array($t[$key]) AND $key!=='GLOBALS') { |
|
| 2347 | + spip_desinfecte($t[$key],$deep); |
|
| 2348 | + } |
|
| 1973 | 2349 | } |
| 1974 | 2350 | } |
| 1975 | 2351 | |
@@ -2004,11 +2380,13 @@ discard block |
||
| 2004 | 2380 | $session = charger_fonction('session', 'inc'); |
| 2005 | 2381 | $session(); |
| 2006 | 2382 | include_spip('inc/texte'); |
| 2007 | - foreach($variables_session as $var) |
|
| 2008 | - if (($a = _request($var)) !== null) |
|
| 2383 | + foreach($variables_session as $var) { |
|
| 2384 | + if (($a = _request($var)) !== null) |
|
| 2009 | 2385 | $GLOBALS['visiteur_session'][$var] = safehtml($a); |
| 2010 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) |
|
| 2011 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2386 | + } |
|
| 2387 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 2388 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2389 | + } |
|
| 2012 | 2390 | $session($GLOBALS['visiteur_session']); |
| 2013 | 2391 | return 0; |
| 2014 | 2392 | } |
@@ -2047,15 +2425,17 @@ discard block |
||
| 2047 | 2425 | // http://doc.spip.org/@lang_select |
| 2048 | 2426 | function lang_select ($lang=NULL) { |
| 2049 | 2427 | static $pile_langues = array(); |
| 2050 | - if (!function_exists('changer_langue')) |
|
| 2051 | - include_spip('inc/lang'); |
|
| 2052 | - if ($lang === NULL) |
|
| 2053 | - $lang = array_pop($pile_langues); |
|
| 2054 | - else { |
|
| 2428 | + if (!function_exists('changer_langue')) { |
|
| 2429 | + include_spip('inc/lang'); |
|
| 2430 | + } |
|
| 2431 | + if ($lang === NULL) { |
|
| 2432 | + $lang = array_pop($pile_langues); |
|
| 2433 | + } else { |
|
| 2055 | 2434 | array_push($pile_langues, $GLOBALS['spip_lang']); |
| 2056 | 2435 | } |
| 2057 | - if (isset($GLOBALS['spip_lang']) AND $lang == $GLOBALS['spip_lang']) |
|
| 2058 | - return $lang; |
|
| 2436 | + if (isset($GLOBALS['spip_lang']) AND $lang == $GLOBALS['spip_lang']) { |
|
| 2437 | + return $lang; |
|
| 2438 | + } |
|
| 2059 | 2439 | changer_langue($lang); |
| 2060 | 2440 | return $lang; |
| 2061 | 2441 | } |
@@ -2106,11 +2486,12 @@ discard block |
||
| 2106 | 2486 | // http://doc.spip.org/@exec_info_dist |
| 2107 | 2487 | function exec_info_dist() { |
| 2108 | 2488 | global $connect_statut; |
| 2109 | - if ($connect_statut == '0minirezo') |
|
| 2110 | - phpinfo(); |
|
| 2111 | - else |
|
| 2112 | - echo "pas admin"; |
|
| 2113 | -} |
|
| 2489 | + if ($connect_statut == '0minirezo') { |
|
| 2490 | + phpinfo(); |
|
| 2491 | + } else { |
|
| 2492 | + echo "pas admin"; |
|
| 2493 | + } |
|
| 2494 | + } |
|
| 2114 | 2495 | |
| 2115 | 2496 | /** |
| 2116 | 2497 | * Génère une erreur de squelette |
@@ -2169,12 +2550,17 @@ discard block |
||
| 2169 | 2550 | * ou tableau d'information sur le squelette. |
| 2170 | 2551 | */ |
| 2171 | 2552 | function recuperer_fond($fond, $contexte=array(), $options = array(), $connect='') { |
| 2172 | - if (!function_exists('evaluer_fond')) |
|
| 2173 | - include_spip('public/assembler'); |
|
| 2553 | + if (!function_exists('evaluer_fond')) { |
|
| 2554 | + include_spip('public/assembler'); |
|
| 2555 | + } |
|
| 2174 | 2556 | // assurer la compat avec l'ancienne syntaxe |
| 2175 | 2557 | // (trim etait le 3eme argument, par defaut a true) |
| 2176 | - if (!is_array($options)) $options = array('trim'=>$options); |
|
| 2177 | - if (!isset($options['trim'])) $options['trim']=true; |
|
| 2558 | + if (!is_array($options)) { |
|
| 2559 | + $options = array('trim'=>$options); |
|
| 2560 | + } |
|
| 2561 | + if (!isset($options['trim'])) { |
|
| 2562 | + $options['trim']=true; |
|
| 2563 | + } |
|
| 2178 | 2564 | |
| 2179 | 2565 | if (isset($contexte['connect'])){ |
| 2180 | 2566 | $connect = ($connect ? $connect : $contexte['connect']); |
@@ -2186,8 +2572,9 @@ discard block |
||
| 2186 | 2572 | $lang_select = ''; |
| 2187 | 2573 | if (!isset($options['etoile']) OR !$options['etoile']){ |
| 2188 | 2574 | // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
| 2189 | - if (!isset($contexte['lang'])) |
|
| 2190 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 2575 | + if (!isset($contexte['lang'])) { |
|
| 2576 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 2577 | + } |
|
| 2191 | 2578 | |
| 2192 | 2579 | if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
| 2193 | 2580 | $lang_select = lang_select($contexte['lang']); |
@@ -2212,25 +2599,30 @@ discard block |
||
| 2212 | 2599 | 'data'=>$page |
| 2213 | 2600 | )); |
| 2214 | 2601 | if (isset($options['ajax']) AND $options['ajax']){ |
| 2215 | - if (!function_exists('encoder_contexte_ajax')) |
|
| 2216 | - include_spip('inc/filtres'); |
|
| 2602 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 2603 | + include_spip('inc/filtres'); |
|
| 2604 | + } |
|
| 2217 | 2605 | $page['texte'] = encoder_contexte_ajax(array_merge($contexte,array('fond'=>$f)),'',$page['texte'], $options['ajax']); |
| 2218 | 2606 | } |
| 2219 | 2607 | |
| 2220 | - if (isset($options['raw']) AND $options['raw']) |
|
| 2221 | - $pages[] = $page; |
|
| 2222 | - else |
|
| 2223 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 2608 | + if (isset($options['raw']) AND $options['raw']) { |
|
| 2609 | + $pages[] = $page; |
|
| 2610 | + } else { |
|
| 2611 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 2612 | + } |
|
| 2224 | 2613 | } |
| 2225 | 2614 | |
| 2226 | 2615 | $GLOBALS['_INC_PUBLIC']--; |
| 2227 | 2616 | |
| 2228 | - if ($lang_select) lang_select(); |
|
| 2229 | - if (isset($options['raw']) AND $options['raw']) |
|
| 2230 | - return is_array($fond)?$pages:reset($pages); |
|
| 2231 | - else |
|
| 2232 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 2233 | -} |
|
| 2617 | + if ($lang_select) { |
|
| 2618 | + lang_select(); |
|
| 2619 | + } |
|
| 2620 | + if (isset($options['raw']) AND $options['raw']) { |
|
| 2621 | + return is_array($fond)?$pages:reset($pages); |
|
| 2622 | + } else { |
|
| 2623 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 2624 | + } |
|
| 2625 | + } |
|
| 2234 | 2626 | |
| 2235 | 2627 | /** |
| 2236 | 2628 | * Trouve un squelette dans le repertoire modeles/ |
@@ -2256,7 +2648,9 @@ discard block |
||
| 2256 | 2648 | */ |
| 2257 | 2649 | function trouver_fond($nom, $dir='', $pathinfo = false) { |
| 2258 | 2650 | $f = find_in_path($nom.'.'. _EXTENSION_SQUELETTES, $dir?rtrim($dir,'/').'/':''); |
| 2259 | - if (!$pathinfo) return $f; |
|
| 2651 | + if (!$pathinfo) { |
|
| 2652 | + return $f; |
|
| 2653 | + } |
|
| 2260 | 2654 | // renvoyer un tableau detaille si $pathinfo==true |
| 2261 | 2655 | $p = pathinfo($f); |
| 2262 | 2656 | if (!isset($p['extension']) OR !$p['extension']) { |
@@ -2271,16 +2665,21 @@ discard block |
||
| 2271 | 2665 | |
| 2272 | 2666 | function tester_url_ecrire($nom){ |
| 2273 | 2667 | static $exec=array(); |
| 2274 | - if (isset($exec[$nom])) return $exec[$nom]; |
|
| 2668 | + if (isset($exec[$nom])) { |
|
| 2669 | + return $exec[$nom]; |
|
| 2670 | + } |
|
| 2275 | 2671 | // tester si c'est une page en squelette |
| 2276 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) |
|
| 2277 | - return $exec[$nom] = 'fond'; |
|
| 2672 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 2673 | + return $exec[$nom] = 'fond'; |
|
| 2674 | + } |
|
| 2278 | 2675 | // compat skels orthogonaux version precedente |
| 2279 | - elseif (trouver_fond($nom, 'prive/exec/')) |
|
| 2280 | - return $exec[$nom] = 'fond_monobloc'; |
|
| 2676 | + elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 2677 | + return $exec[$nom] = 'fond_monobloc'; |
|
| 2678 | + } |
|
| 2281 | 2679 | // echafaudage d'un fond ! |
| 2282 | - elseif(include_spip('public/styliser_par_z') AND z_echafaudable($nom)) |
|
| 2283 | - return $exec[$nom] = 'fond'; |
|
| 2680 | + elseif(include_spip('public/styliser_par_z') AND z_echafaudable($nom)) { |
|
| 2681 | + return $exec[$nom] = 'fond'; |
|
| 2682 | + } |
|
| 2284 | 2683 | // attention, il ne faut pas inclure l'exec ici |
| 2285 | 2684 | // car sinon #URL_ECRIRE provoque des inclusions |
| 2286 | 2685 | // et des define intrusifs potentiels |
@@ -2324,13 +2723,23 @@ discard block |
||
| 2324 | 2723 | // http://doc.spip.org/@spip_fetch_array |
| 2325 | 2724 | function spip_fetch_array($r, $t=NULL) { |
| 2326 | 2725 | if (!isset($t)) { |
| 2327 | - if ($r) return sql_fetch($r); |
|
| 2726 | + if ($r) { |
|
| 2727 | + return sql_fetch($r); |
|
| 2728 | + } |
|
| 2328 | 2729 | } else { |
| 2329 | - if ($t=='SPIP_NUM') $t = MYSQL_NUM; |
|
| 2330 | - if ($t=='SPIP_BOTH') $t = MYSQL_BOTH; |
|
| 2331 | - if ($t=='SPIP_ASSOC') $t = MYSQL_ASSOC; |
|
| 2730 | + if ($t=='SPIP_NUM') { |
|
| 2731 | + $t = MYSQL_NUM; |
|
| 2732 | + } |
|
| 2733 | + if ($t=='SPIP_BOTH') { |
|
| 2734 | + $t = MYSQL_BOTH; |
|
| 2735 | + } |
|
| 2736 | + if ($t=='SPIP_ASSOC') { |
|
| 2737 | + $t = MYSQL_ASSOC; |
|
| 2738 | + } |
|
| 2332 | 2739 | spip_log("appel deprecie de spip_fetch_array(..., $t)", 'vieilles_defs'); |
| 2333 | - if ($r) return mysql_fetch_array($r, $t); |
|
| 2740 | + if ($r) { |
|
| 2741 | + return mysql_fetch_array($r, $t); |
|
| 2742 | + } |
|
| 2334 | 2743 | } |
| 2335 | 2744 | } |
| 2336 | 2745 | |
@@ -2347,11 +2756,13 @@ discard block |
||
| 2347 | 2756 | function avertir_auteurs($nom,$message, $statut=''){ |
| 2348 | 2757 | $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
| 2349 | 2758 | if (!$alertes |
| 2350 | - OR !is_array($alertes = unserialize($alertes))) |
|
| 2351 | - $alertes = array(); |
|
| 2759 | + OR !is_array($alertes = unserialize($alertes))) { |
|
| 2760 | + $alertes = array(); |
|
| 2761 | + } |
|
| 2352 | 2762 | |
| 2353 | - if (!isset($alertes[$statut])) |
|
| 2354 | - $alertes[$statut] = array(); |
|
| 2763 | + if (!isset($alertes[$statut])) { |
|
| 2764 | + $alertes[$statut] = array(); |
|
| 2765 | + } |
|
| 2355 | 2766 | $alertes[$statut][$nom] = $message; |
| 2356 | 2767 | ecrire_meta("message_alertes_auteurs",serialize($alertes)); |
| 2357 | 2768 | } |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/texte_mini'); |
| 16 | 18 | include_spip('inc/lien'); |
@@ -66,11 +68,12 @@ discard block |
||
| 66 | 68 | // afficher joliment les <script> |
| 67 | 69 | // http://doc.spip.org/@echappe_js |
| 68 | 70 | function echappe_js($t,$class=' class="echappe-js"') { |
| 69 | - if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) |
|
| 70 | - foreach ($r as $regs) |
|
| 71 | + if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 72 | + foreach ($r as $regs) |
|
| 71 | 73 | $t = str_replace($regs[0], |
| 72 | 74 | "<code$class>".nl2br(spip_htmlspecialchars($regs[0])).'</code>', |
| 73 | 75 | $t); |
| 76 | + } |
|
| 74 | 77 | return $t; |
| 75 | 78 | } |
| 76 | 79 | |
@@ -105,7 +108,9 @@ discard block |
||
| 105 | 108 | static $dejavu = array(); |
| 106 | 109 | |
| 107 | 110 | // Attention, si ce n'est pas une chaine, laisser intact |
| 108 | - if (!$arg OR !is_string($arg) OR !strstr($arg, '<')) return $arg; |
|
| 111 | + if (!$arg OR !is_string($arg) OR !strstr($arg, '<')) { |
|
| 112 | + return $arg; |
|
| 113 | + } |
|
| 109 | 114 | |
| 110 | 115 | if (is_null($mode_filtre) or !in_array($mode_filtre, array(-1, 0, 1))) { |
| 111 | 116 | $mode_filtre = $GLOBALS['filtrer_javascript']; |
@@ -127,8 +132,9 @@ discard block |
||
| 127 | 132 | // Pour le js, trois modes : parano (-1), prive (0), ok (1) |
| 128 | 133 | switch ($mode_filtre) { |
| 129 | 134 | case 0: |
| 130 | - if (!_DIR_RESTREINT) |
|
| 131 | - $t = echappe_js($t); |
|
| 135 | + if (!_DIR_RESTREINT) { |
|
| 136 | + $t = echappe_js($t); |
|
| 137 | + } |
|
| 132 | 138 | break; |
| 133 | 139 | case -1: |
| 134 | 140 | $t = echappe_js($t); |
@@ -139,10 +145,12 @@ discard block |
||
| 139 | 145 | $t = preg_replace(',<(base\b),iS', '<\1', $t); |
| 140 | 146 | |
| 141 | 147 | // Reinserer les echappements des modeles |
| 142 | - if (defined('_PROTEGE_JS_MODELES')) |
|
| 143 | - $t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES); |
|
| 144 | - if (defined('_PROTEGE_PHP_MODELES')) |
|
| 145 | - $t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES); |
|
| 148 | + if (defined('_PROTEGE_JS_MODELES')) { |
|
| 149 | + $t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES); |
|
| 150 | + } |
|
| 151 | + if (defined('_PROTEGE_PHP_MODELES')) { |
|
| 152 | + $t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES); |
|
| 153 | + } |
|
| 146 | 154 | |
| 147 | 155 | return $dejavu[$mode_filtre][$arg] = $t; |
| 148 | 156 | } |
@@ -153,7 +161,9 @@ discard block |
||
| 153 | 161 | // http://doc.spip.org/@typo |
| 154 | 162 | function typo($letexte, $echapper=true, $connect=null, $env=array()) { |
| 155 | 163 | // Plus vite ! |
| 156 | - if (!$letexte) return $letexte; |
|
| 164 | + if (!$letexte) { |
|
| 165 | + return $letexte; |
|
| 166 | + } |
|
| 157 | 167 | |
| 158 | 168 | // les appels directs a cette fonction depuis le php de l'espace |
| 159 | 169 | // prive etant historiquement ecrit sans argment $connect |
@@ -169,8 +179,9 @@ discard block |
||
| 169 | 179 | } |
| 170 | 180 | |
| 171 | 181 | // Echapper les codes <html> etc |
| 172 | - if ($echapper) |
|
| 173 | - $letexte = echappe_html($letexte, 'TYPO'); |
|
| 182 | + if ($echapper) { |
|
| 183 | + $letexte = echappe_html($letexte, 'TYPO'); |
|
| 184 | + } |
|
| 174 | 185 | |
| 175 | 186 | // |
| 176 | 187 | // Installer les modeles, notamment images et documents ; |
@@ -179,19 +190,23 @@ discard block |
||
| 179 | 190 | // cf. inc/lien |
| 180 | 191 | |
| 181 | 192 | $letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect, null, $env); |
| 182 | - if ($letexte != $mem) $echapper = true; |
|
| 193 | + if ($letexte != $mem) { |
|
| 194 | + $echapper = true; |
|
| 195 | + } |
|
| 183 | 196 | unset($mem); |
| 184 | 197 | |
| 185 | 198 | $letexte = corriger_typo($letexte); |
| 186 | 199 | $letexte = echapper_faux_tags($letexte); |
| 187 | 200 | |
| 188 | 201 | // reintegrer les echappements |
| 189 | - if ($echapper) |
|
| 190 | - $letexte = echappe_retour($letexte, 'TYPO'); |
|
| 202 | + if ($echapper) { |
|
| 203 | + $letexte = echappe_retour($letexte, 'TYPO'); |
|
| 204 | + } |
|
| 191 | 205 | |
| 192 | 206 | // Dans les appels directs hors squelette, securiser ici aussi |
| 193 | - if ($interdire_script) |
|
| 194 | - $letexte = interdire_scripts($letexte); |
|
| 207 | + if ($interdire_script) { |
|
| 208 | + $letexte = interdire_scripts($letexte); |
|
| 209 | + } |
|
| 195 | 210 | |
| 196 | 211 | // Dans l'espace prive on se mefie de tout contenu dangereux |
| 197 | 212 | // https://core.spip.net/issues/3371 |
@@ -212,7 +227,9 @@ discard block |
||
| 212 | 227 | function corriger_typo($letexte, $lang='') { |
| 213 | 228 | |
| 214 | 229 | // Plus vite ! |
| 215 | - if (!$letexte) return $letexte; |
|
| 230 | + if (!$letexte) { |
|
| 231 | + return $letexte; |
|
| 232 | + } |
|
| 216 | 233 | |
| 217 | 234 | $letexte = pipeline('pre_typo', $letexte); |
| 218 | 235 | |
@@ -239,7 +256,9 @@ discard block |
||
| 239 | 256 | $letexte = $typographie($letexte); |
| 240 | 257 | |
| 241 | 258 | // Les citations en une autre langue, s'il y a lieu |
| 242 | - if (!$e) $letexte = echappe_retour($letexte, 'multi'); |
|
| 259 | + if (!$e) { |
|
| 260 | + $letexte = echappe_retour($letexte, 'multi'); |
|
| 261 | + } |
|
| 243 | 262 | |
| 244 | 263 | // Retablir les caracteres proteges |
| 245 | 264 | $letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER); |
@@ -295,7 +314,9 @@ discard block |
||
| 295 | 314 | $interdire_script = true; |
| 296 | 315 | } |
| 297 | 316 | |
| 298 | - if (!$t) return strval($t); |
|
| 317 | + if (!$t) { |
|
| 318 | + return strval($t); |
|
| 319 | + } |
|
| 299 | 320 | |
| 300 | 321 | $t = echappe_html($t); |
| 301 | 322 | $t = expanser_liens($t,$connect, $env); |
@@ -11,7 +11,9 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | |
| 14 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 14 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 15 | + return; |
|
| 16 | +} |
|
| 15 | 17 | |
| 16 | 18 | |
| 17 | 19 | // Donne la liste des champs/tables ou l'on sait chercher/remplacer |
@@ -216,17 +218,20 @@ discard block |
||
| 216 | 218 | if (is_string($tables) |
| 217 | 219 | AND $tables != '') { |
| 218 | 220 | $toutes = array(); |
| 219 | - foreach(explode(',', $tables) as $t) |
|
| 220 | - if (isset($liste[$t])) |
|
| 221 | + foreach(explode(',', $tables) as $t) { |
|
| 222 | + if (isset($liste[$t])) |
|
| 221 | 223 | $toutes[$t] = $liste[$t]; |
| 224 | + } |
|
| 222 | 225 | $tables = $toutes; |
| 223 | 226 | unset($toutes); |
| 224 | - } else |
|
| 225 | - $tables = $liste; |
|
| 227 | + } else { |
|
| 228 | + $tables = $liste; |
|
| 229 | + } |
|
| 226 | 230 | } |
| 227 | 231 | |
| 228 | - if (!strlen($recherche) OR !count($tables)) |
|
| 229 | - return array(); |
|
| 232 | + if (!strlen($recherche) OR !count($tables)) { |
|
| 233 | + return array(); |
|
| 234 | + } |
|
| 230 | 235 | |
| 231 | 236 | include_spip('inc/autoriser'); |
| 232 | 237 | |
@@ -254,8 +259,9 @@ discard block |
||
| 254 | 259 | include_spip('inc/memoization'); |
| 255 | 260 | foreach ($tables as $table => $champs) { |
| 256 | 261 | # lock via memoization, si dispo |
| 257 | - if (function_exists('cache_lock')) |
|
| 258 | - cache_lock($lock = 'recherche '.$table.' '.$recherche); |
|
| 262 | + if (function_exists('cache_lock')) { |
|
| 263 | + cache_lock($lock = 'recherche '.$table.' '.$recherche); |
|
| 264 | + } |
|
| 259 | 265 | |
| 260 | 266 | spip_timer('rech'); |
| 261 | 267 | |
@@ -270,8 +276,9 @@ discard block |
||
| 270 | 276 | |
| 271 | 277 | spip_log("recherche $table ($recherche) : ".count($results[$table])." resultats ".spip_timer('rech'),'recherche'); |
| 272 | 278 | |
| 273 | - if (isset($lock)) |
|
| 274 | - cache_unlock($lock); |
|
| 279 | + if (isset($lock)) { |
|
| 280 | + cache_unlock($lock); |
|
| 281 | + } |
|
| 275 | 282 | } |
| 276 | 283 | |
| 277 | 284 | return $results; |
@@ -293,8 +300,9 @@ discard block |
||
| 293 | 300 | $options['champs'] = true; |
| 294 | 301 | |
| 295 | 302 | |
| 296 | - if (!is_array($tables)) |
|
| 297 | - $tables = liste_des_champs(); |
|
| 303 | + if (!is_array($tables)) { |
|
| 304 | + $tables = liste_des_champs(); |
|
| 305 | + } |
|
| 298 | 306 | |
| 299 | 307 | $results = recherche_en_base($recherche, $tables, $options); |
| 300 | 308 | |
@@ -307,17 +315,21 @@ discard block |
||
| 307 | 315 | OR autoriser('modifier', $table, $id)) { |
| 308 | 316 | $modifs = array(); |
| 309 | 317 | foreach ($x['champs'] as $key => $val) { |
| 310 | - if ($key == $_id_table) next; |
|
| 318 | + if ($key == $_id_table) { |
|
| 319 | + next; |
|
| 320 | + } |
|
| 311 | 321 | $repl = preg_replace($preg, $remplace, $val); |
| 312 | - if ($repl <> $val) |
|
| 313 | - $modifs[$key] = $repl; |
|
| 322 | + if ($repl <> $val) { |
|
| 323 | + $modifs[$key] = $repl; |
|
| 324 | + } |
|
| 314 | 325 | } |
| 315 | - if ($modifs) |
|
| 316 | - objet_modifier_champs($table, $id, |
|
| 326 | + if ($modifs) { |
|
| 327 | + objet_modifier_champs($table, $id, |
|
| 317 | 328 | array( |
| 318 | 329 | 'champs' => array_keys($modifs), |
| 319 | 330 | ), |
| 320 | 331 | $modifs); |
| 332 | + } |
|
| 321 | 333 | } |
| 322 | 334 | } |
| 323 | 335 | } |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | define('_SPIP_SELECT_RUBRIQUES', 20); /* mettre 100000 pour desactiver ajax */ |
| 16 | 18 | |
@@ -24,18 +26,20 @@ discard block |
||
| 24 | 26 | // $idem : en mode rubrique = la rubrique soi-meme |
| 25 | 27 | // http://doc.spip.org/@inc_chercher_rubrique_dist |
| 26 | 28 | function inc_chercher_rubrique_dist ($id_rubrique, $type, $restreint, $idem=0, $do='aff') { |
| 27 | - if (sql_countsel('spip_rubriques')<1) |
|
| 28 | - return ''; |
|
| 29 | + if (sql_countsel('spip_rubriques')<1) { |
|
| 30 | + return ''; |
|
| 31 | + } |
|
| 29 | 32 | |
| 30 | 33 | // Mode sans Ajax : |
| 31 | 34 | // - soit parce que le cookie ajax n'est pas la |
| 32 | 35 | // - soit parce qu'il y a peu de rubriques |
| 33 | 36 | if (_SPIP_AJAX < 1 |
| 34 | 37 | OR $type == 'breve' |
| 35 | - OR sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES) |
|
| 36 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 37 | - |
|
| 38 | - else return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 38 | + OR sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES) { |
|
| 39 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 40 | + } else { |
|
| 41 | + return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 42 | + } |
|
| 39 | 43 | |
| 40 | 44 | } |
| 41 | 45 | |
@@ -52,11 +56,13 @@ discard block |
||
| 52 | 56 | . "margin-$spip_lang_left: ".(($i-1)*16)."px;"; |
| 53 | 57 | } else { |
| 54 | 58 | $style = ''; |
| 55 | - for ($count = 0; $count <= $i; $count ++) |
|
| 56 | - $espace .= " "; |
|
| 59 | + for ($count = 0; $count <= $i; $count ++) { |
|
| 60 | + $espace .= " "; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + if ($i ==1) { |
|
| 64 | + $espace= ""; |
|
| 57 | 65 | } |
| 58 | - if ($i ==1) |
|
| 59 | - $espace= ""; |
|
| 60 | 66 | $class = "niveau_$i"; |
| 61 | 67 | return array($class,$style,$espace); |
| 62 | 68 | } |
@@ -67,7 +73,9 @@ discard block |
||
| 67 | 73 | |
| 68 | 74 | // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
| 69 | 75 | if ($exclus > 0 |
| 70 | - AND $root == $exclus) return ''; |
|
| 76 | + AND $root == $exclus) { |
|
| 77 | + return ''; |
|
| 78 | + } |
|
| 71 | 79 | |
| 72 | 80 | // en fonction du niveau faire un affichage plus ou moins kikoo |
| 73 | 81 | |
@@ -81,23 +89,29 @@ discard block |
||
| 81 | 89 | |
| 82 | 90 | // creer l'<option> pour la rubrique $root |
| 83 | 91 | |
| 84 | - if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 92 | + if (isset($data[$root])) { |
|
| 93 | + # pas de racine sauf pour les rubriques |
|
| 85 | 94 | { |
| 86 | 95 | $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
| 87 | 96 | .$data[$root] |
| 88 | 97 | .'</option>'."\n"; |
| 89 | - } else $r = ''; |
|
| 98 | + } |
|
| 99 | + } else { |
|
| 100 | + $r = ''; |
|
| 101 | + } |
|
| 90 | 102 | |
| 91 | 103 | // et le sous-menu pour ses enfants |
| 92 | 104 | $sous = ''; |
| 93 | - if (isset($enfants[$root])) |
|
| 94 | - foreach ($enfants[$root] as $sousrub) |
|
| 105 | + if (isset($enfants[$root])) { |
|
| 106 | + foreach ($enfants[$root] as $sousrub) |
|
| 95 | 107 | $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
| 96 | 108 | $niv+1, $data, $enfants, $exclus, $restreint, $type); |
| 109 | + } |
|
| 97 | 110 | |
| 98 | 111 | // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
| 99 | - if ($restreint AND $root!=$id_rubrique AND !autoriser('publierdans','rubrique',$root)) |
|
| 100 | - return $sous; |
|
| 112 | + if ($restreint AND $root!=$id_rubrique AND !autoriser('publierdans','rubrique',$root)) { |
|
| 113 | + return $sous; |
|
| 114 | + } |
|
| 101 | 115 | |
| 102 | 116 | // et voila le travail |
| 103 | 117 | return $r.$sous; |
@@ -107,13 +121,15 @@ discard block |
||
| 107 | 121 | // http://doc.spip.org/@selecteur_rubrique_html |
| 108 | 122 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) { |
| 109 | 123 | $data = array(); |
| 110 | - if ($type == 'rubrique' AND autoriser('publierdans','rubrique',0)) |
|
| 111 | - $data[0] = _T('info_racine_site'); |
|
| 124 | + if ($type == 'rubrique' AND autoriser('publierdans','rubrique',0)) { |
|
| 125 | + $data[0] = _T('info_racine_site'); |
|
| 126 | + } |
|
| 112 | 127 | # premier choix = neant |
| 113 | 128 | # si auteur (rubriques restreintes) |
| 114 | 129 | # ou si creation avec id_rubrique=0 |
| 115 | - elseif ($type == 'auteur' OR !$id_rubrique) |
|
| 116 | - $data[0] = ' '; |
|
| 130 | + elseif ($type == 'auteur' OR !$id_rubrique) { |
|
| 131 | + $data[0] = ' '; |
|
| 132 | + } |
|
| 117 | 133 | |
| 118 | 134 | // |
| 119 | 135 | // creer une structure contenant toute l'arborescence |
@@ -126,11 +142,14 @@ discard block |
||
| 126 | 142 | // titre largeur maxi a 50 |
| 127 | 143 | $titre = couper(supprimer_tags(typo($r['titre']))." ", 50); |
| 128 | 144 | if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
| 129 | - AND ($r['langue_choisie'] == "oui" OR $r['id_parent'] == 0)) |
|
| 130 | - $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 145 | + AND ($r['langue_choisie'] == "oui" OR $r['id_parent'] == 0)) { |
|
| 146 | + $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 147 | + } |
|
| 131 | 148 | $data[$r['id_rubrique']] = $titre; |
| 132 | 149 | $enfants[$r['id_parent']][] = $r['id_rubrique']; |
| 133 | - if ($id_rubrique == $r['id_rubrique']) $id_parent = $r['id_parent']; |
|
| 150 | + if ($id_rubrique == $r['id_rubrique']) { |
|
| 151 | + $id_parent = $r['id_parent']; |
|
| 152 | + } |
|
| 134 | 153 | } |
| 135 | 154 | } |
| 136 | 155 | |
@@ -140,17 +159,19 @@ discard block |
||
| 140 | 159 | if (count($data)==2 |
| 141 | 160 | AND isset($data[0]) |
| 142 | 161 | AND !in_array($type,array('auteur','rubrique')) |
| 143 | - AND !$id_rubrique) |
|
| 144 | - unset($data[0]); |
|
| 162 | + AND !$id_rubrique) { |
|
| 163 | + unset($data[0]); |
|
| 164 | + } |
|
| 145 | 165 | |
| 146 | 166 | |
| 147 | 167 | $opt = sous_menu_rubriques($id_rubrique,0, 0,$data,$enfants,$idem, $restreint, $type); |
| 148 | 168 | $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
| 149 | 169 | |
| 150 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,',$opt,$r)) |
|
| 151 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2] ; |
|
| 152 | - else |
|
| 153 | - $r = "<select".$att." size='1'>\n$opt</select>\n"; |
|
| 170 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,',$opt,$r)) { |
|
| 171 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2] ; |
|
| 172 | + } else { |
|
| 173 | + $r = "<select".$att." size='1'>\n$opt</select>\n"; |
|
| 174 | + } |
|
| 154 | 175 | |
| 155 | 176 | # message pour neuneus (a supprimer ?) |
| 156 | 177 | # if ($type != 'auteur' AND $type != 'breve') |
@@ -181,10 +202,11 @@ discard block |
||
| 181 | 202 | |
| 182 | 203 | if ($id_rubrique) { |
| 183 | 204 | $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
| 184 | - } else if ($type == 'auteur') |
|
| 185 | - $titre = ' '; |
|
| 186 | - else |
|
| 187 | - $titre = _T('info_racine_site'); |
|
| 205 | + } else if ($type == 'auteur') { |
|
| 206 | + $titre = ' '; |
|
| 207 | + } else { |
|
| 208 | + $titre = _T('info_racine_site'); |
|
| 209 | + } |
|
| 188 | 210 | |
| 189 | 211 | $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
| 190 | 212 | $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
@@ -10,9 +10,13 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | -if (!defined('_CONTEXTE_IGNORE_VARIABLES')) define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$)/"); |
|
| 17 | +if (!defined('_CONTEXTE_IGNORE_VARIABLES')) { |
|
| 18 | + define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$)/"); |
|
| 19 | +} |
|
| 16 | 20 | // |
| 17 | 21 | // calcule la page et les entetes |
| 18 | 22 | // determine le contexte donne par l'URL (en tenant compte des reecritures) |
@@ -34,14 +38,17 @@ discard block |
||
| 34 | 38 | $cacher = charger_fonction('cacher', 'public', true); |
| 35 | 39 | // Les quatre derniers parametres sont modifies par la fonction: |
| 36 | 40 | // emplacement, validite, et, s'il est valide, contenu & age |
| 37 | - if ($cacher) |
|
| 38 | - $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 39 | - else |
|
| 40 | - $use_cache = -1; |
|
| 41 | + if ($cacher) { |
|
| 42 | + $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 43 | + } else { |
|
| 44 | + $use_cache = -1; |
|
| 45 | + } |
|
| 41 | 46 | // Si un resultat est retourne, c'est un message d'impossibilite |
| 42 | 47 | if ($res) {return array('texte' => $res);} |
| 43 | 48 | |
| 44 | - if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
|
| 49 | + if (!$chemin_cache || !$lastmodified) { |
|
| 50 | + $lastmodified = time(); |
|
| 51 | + } |
|
| 45 | 52 | |
| 46 | 53 | $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
| 47 | 54 | $calculer_page = true; |
@@ -83,8 +90,7 @@ discard block |
||
| 83 | 90 | // plus necessaire si on utilise bien la fonction urls_decoder_url |
| 84 | 91 | #unset($_SERVER['REDIRECT_url_propre']); |
| 85 | 92 | #unset($_ENV['url_propre']); |
| 86 | - } |
|
| 87 | - else { |
|
| 93 | + } else { |
|
| 88 | 94 | // Compat ascendante : |
| 89 | 95 | // 1. $contexte est global |
| 90 | 96 | // (a evacuer car urls_decoder_url gere ce probleme ?) |
@@ -94,8 +100,9 @@ discard block |
||
| 94 | 100 | list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
| 95 | 101 | } |
| 96 | 102 | // squelette par defaut |
| 97 | - if (!strlen($fond)) |
|
| 98 | - $fond = 'sommaire'; |
|
| 103 | + if (!strlen($fond)) { |
|
| 104 | + $fond = 'sommaire'; |
|
| 105 | + } |
|
| 99 | 106 | |
| 100 | 107 | // produire la page : peut mettre a jour $lastmodified |
| 101 | 108 | $produire_page = charger_fonction('produire_page','public'); |
@@ -109,7 +116,9 @@ discard block |
||
| 109 | 116 | } |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | - if ($page AND $chemin_cache) $page['cache'] = $chemin_cache; |
|
| 119 | + if ($page AND $chemin_cache) { |
|
| 120 | + $page['cache'] = $chemin_cache; |
|
| 121 | + } |
|
| 113 | 122 | |
| 114 | 123 | auto_content_type($page); |
| 115 | 124 | |
@@ -140,12 +149,14 @@ discard block |
||
| 140 | 149 | // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
| 141 | 150 | if ($lastmodified |
| 142 | 151 | AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
| 143 | - AND !isset($page['entetes']["Last-Modified"])) |
|
| 144 | - $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 152 | + AND !isset($page['entetes']["Last-Modified"])) { |
|
| 153 | + $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 154 | + } |
|
| 145 | 155 | |
| 146 | 156 | // fermer la connexion apres les headers si requete HEAD |
| 147 | - if ($headers_only) |
|
| 148 | - $page['entetes']["Connection"] = "close"; |
|
| 157 | + if ($headers_only) { |
|
| 158 | + $page['entetes']["Connection"] = "close"; |
|
| 159 | + } |
|
| 149 | 160 | |
| 150 | 161 | return $page; |
| 151 | 162 | } |
@@ -162,12 +173,14 @@ discard block |
||
| 162 | 173 | |
| 163 | 174 | $contexte = array(); |
| 164 | 175 | foreach($_GET as $var => $val) { |
| 165 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 166 | - $contexte[$var] = $val; |
|
| 176 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) { |
|
| 177 | + $contexte[$var] = $val; |
|
| 178 | + } |
|
| 167 | 179 | } |
| 168 | 180 | foreach($_POST as $var => $val) { |
| 169 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 170 | - $contexte[$var] = $val; |
|
| 181 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) { |
|
| 182 | + $contexte[$var] = $val; |
|
| 183 | + } |
|
| 171 | 184 | } |
| 172 | 185 | |
| 173 | 186 | return $contexte; |
@@ -182,8 +195,9 @@ discard block |
||
| 182 | 195 | */ |
| 183 | 196 | function calculer_contexte_implicite(){ |
| 184 | 197 | static $notes = null; |
| 185 | - if (is_null($notes)) |
|
| 186 | - $notes = charger_fonction('notes','inc',true); |
|
| 198 | + if (is_null($notes)) { |
|
| 199 | + $notes = charger_fonction('notes','inc',true); |
|
| 200 | + } |
|
| 187 | 201 | $contexte_implicite = array( |
| 188 | 202 | 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
| 189 | 203 | 'host' => $_SERVER['HTTP_HOST'], |
@@ -222,14 +236,16 @@ discard block |
||
| 222 | 236 | unset($contexte['fond']); |
| 223 | 237 | $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
| 224 | 238 | $page['contexte_implicite']['cache'] = $fond; |
| 225 | - if (is_null($cacher)) |
|
| 226 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 239 | + if (is_null($cacher)) { |
|
| 240 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 241 | + } |
|
| 227 | 242 | // Les quatre derniers parametres sont modifies par la fonction: |
| 228 | 243 | // emplacement, validite, et, s'il est valide, contenu & age |
| 229 | - if ($cacher) |
|
| 230 | - $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 231 | - else |
|
| 232 | - $use_cache = -1; |
|
| 244 | + if ($cacher) { |
|
| 245 | + $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 246 | + } else { |
|
| 247 | + $use_cache = -1; |
|
| 248 | + } |
|
| 233 | 249 | // $res = message d'erreur : on sort de la |
| 234 | 250 | if ($res) {return array('texte' => $res);} |
| 235 | 251 | |
@@ -237,8 +253,9 @@ discard block |
||
| 237 | 253 | // produire la page : peut mettre a jour $lastinclude |
| 238 | 254 | // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
| 239 | 255 | if ($use_cache) { |
| 240 | - if (is_null($produire_page)) |
|
| 241 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 256 | + if (is_null($produire_page)) { |
|
| 257 | + $produire_page = charger_fonction('produire_page','public'); |
|
| 258 | + } |
|
| 242 | 259 | $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
| 243 | 260 | } |
| 244 | 261 | // dans tous les cas, mettre a jour $lastmodified |
@@ -263,8 +280,9 @@ discard block |
||
| 263 | 280 | */ |
| 264 | 281 | function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){ |
| 265 | 282 | static $parametrer,$cacher; |
| 266 | - if (!$parametrer) |
|
| 267 | - $parametrer = charger_fonction('parametrer', 'public'); |
|
| 283 | + if (!$parametrer) { |
|
| 284 | + $parametrer = charger_fonction('parametrer', 'public'); |
|
| 285 | + } |
|
| 268 | 286 | $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
| 269 | 287 | // et on l'enregistre sur le disque |
| 270 | 288 | if ($chemin_cache |
@@ -272,13 +290,15 @@ discard block |
||
| 272 | 290 | AND is_array($page) |
| 273 | 291 | AND count($page) |
| 274 | 292 | AND $page['entetes']['X-Spip-Cache'] > 0){ |
| 275 | - if (is_null($cacher)) |
|
| 276 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 293 | + if (is_null($cacher)) { |
|
| 294 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 295 | + } |
|
| 277 | 296 | $lastinclude = time(); |
| 278 | - if ($cacher) |
|
| 279 | - $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 280 | - else |
|
| 281 | - $use_cache = -1; |
|
| 297 | + if ($cacher) { |
|
| 298 | + $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 299 | + } else { |
|
| 300 | + $use_cache = -1; |
|
| 301 | + } |
|
| 282 | 302 | } |
| 283 | 303 | return $page; |
| 284 | 304 | } |
@@ -296,8 +316,10 @@ discard block |
||
| 296 | 316 | |
| 297 | 317 | function inserer_balise_dynamique($contexte_exec, $contexte_compil) |
| 298 | 318 | { |
| 299 | - if (!is_array($contexte_exec)) |
|
| 300 | - echo $contexte_exec; // message d'erreur etc |
|
| 319 | + if (!is_array($contexte_exec)) { |
|
| 320 | + echo $contexte_exec; |
|
| 321 | + } |
|
| 322 | + // message d'erreur etc |
|
| 301 | 323 | else { |
| 302 | 324 | inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
| 303 | 325 | } |
@@ -328,8 +350,9 @@ discard block |
||
| 328 | 350 | unset($page['entetes']['X-Spip-Cache']); |
| 329 | 351 | unset($page['entetes']['Content-Type']); |
| 330 | 352 | if (isset($GLOBALS['page']) AND is_array($GLOBALS['page'])) { |
| 331 | - if (!is_array($GLOBALS['page']['entetes'])) |
|
| 332 | - $GLOBALS['page']['entetes'] = array(); |
|
| 353 | + if (!is_array($GLOBALS['page']['entetes'])) { |
|
| 354 | + $GLOBALS['page']['entetes'] = array(); |
|
| 355 | + } |
|
| 333 | 356 | $GLOBALS['page']['entetes'] = |
| 334 | 357 | array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
| 335 | 358 | } |
@@ -358,17 +381,20 @@ discard block |
||
| 358 | 381 | $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
| 359 | 382 | $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
| 360 | 383 | } |
| 361 | - if ($echo) |
|
| 362 | - echo $texte; |
|
| 363 | - else |
|
| 364 | - return $texte; |
|
| 384 | + if ($echo) { |
|
| 385 | + echo $texte; |
|
| 386 | + } else { |
|
| 387 | + return $texte; |
|
| 388 | + } |
|
| 365 | 389 | |
| 366 | 390 | } |
| 367 | 391 | |
| 368 | 392 | // http://doc.spip.org/@message_page_indisponible |
| 369 | 393 | function message_page_indisponible ($page, $contexte) { |
| 370 | 394 | static $deja = false; |
| 371 | - if ($deja) return "erreur"; |
|
| 395 | + if ($deja) { |
|
| 396 | + return "erreur"; |
|
| 397 | + } |
|
| 372 | 398 | $codes = array( |
| 373 | 399 | '404' => '404 Not Found', |
| 374 | 400 | '503' => '503 Service Unavailable', |
@@ -377,8 +403,9 @@ discard block |
||
| 377 | 403 | $contexte['status'] = ($page !== false) ? '404' : '503'; |
| 378 | 404 | $contexte['code'] = $codes[$contexte['status']]; |
| 379 | 405 | $contexte['fond'] = '404'; // gere les 2 erreurs |
| 380 | - if (!isset($contexte['lang'])) |
|
| 381 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 406 | + if (!isset($contexte['lang'])) { |
|
| 407 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 408 | + } |
|
| 382 | 409 | |
| 383 | 410 | $deja = true; |
| 384 | 411 | // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
@@ -387,8 +414,9 @@ discard block |
||
| 387 | 414 | |
| 388 | 415 | // produire la page d'erreur |
| 389 | 416 | $page = inclure_page($contexte['fond'], $contexte); |
| 390 | - if (!$page) |
|
| 391 | - $page = inclure_page('404', $contexte); |
|
| 417 | + if (!$page) { |
|
| 418 | + $page = inclure_page('404', $contexte); |
|
| 419 | + } |
|
| 392 | 420 | $page['status'] = $contexte['status']; |
| 393 | 421 | |
| 394 | 422 | return $page; |
@@ -406,14 +434,17 @@ discard block |
||
| 406 | 434 | $contexte[$var] = $val; |
| 407 | 435 | } else { |
| 408 | 436 | $args = explode('=', $val); |
| 409 | - if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 437 | + if (count($args)>=2) { |
|
| 438 | + // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | 439 | $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
| 411 | - else // notation abregee |
|
| 440 | + } else { |
|
| 441 | + // notation abregee |
|
| 412 | 442 | $contexte[trim($val)] = trim($val); |
| 443 | + } |
|
| 413 | 444 | } |
| 445 | + } else { |
|
| 446 | + $contexte[$var] = $val; |
|
| 414 | 447 | } |
| 415 | - else |
|
| 416 | - $contexte[$var] = $val; |
|
| 417 | 448 | } |
| 418 | 449 | |
| 419 | 450 | return $contexte; |
@@ -424,7 +455,10 @@ discard block |
||
| 424 | 455 | function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) { |
| 425 | 456 | |
| 426 | 457 | static $compteur; |
| 427 | - if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 458 | + if (++$compteur>10) { |
|
| 459 | + return ''; |
|
| 460 | + } |
|
| 461 | + # ne pas boucler indefiniment |
|
| 428 | 462 | |
| 429 | 463 | $type = strtolower($type); |
| 430 | 464 | |
@@ -468,8 +502,9 @@ discard block |
||
| 468 | 502 | $_id = id_table_objet($type); |
| 469 | 503 | $contexte['id'] = $contexte[$_id] = $id; |
| 470 | 504 | |
| 471 | - if (isset($class)) |
|
| 472 | - $contexte['class'] = $class; |
|
| 505 | + if (isset($class)) { |
|
| 506 | + $contexte['class'] = $class; |
|
| 507 | + } |
|
| 473 | 508 | |
| 474 | 509 | // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
| 475 | 510 | if ($lien) { |
@@ -499,8 +534,9 @@ discard block |
||
| 499 | 534 | 'spip_lien_ok')) { |
| 500 | 535 | $retour = inserer_attribut($retour, 'class', |
| 501 | 536 | trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
| 502 | - } else if ($lien) |
|
| 503 | - $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 537 | + } else if ($lien) { |
|
| 538 | + $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 539 | + } |
|
| 504 | 540 | |
| 505 | 541 | $compteur--; |
| 506 | 542 | |
@@ -518,7 +554,9 @@ discard block |
||
| 518 | 554 | |
| 519 | 555 | $page = inclure_page($fond, $contexte, $connect); |
| 520 | 556 | |
| 521 | - if (!$page) return $page; |
|
| 557 | + if (!$page) { |
|
| 558 | + return $page; |
|
| 559 | + } |
|
| 522 | 560 | // eval $page et affecte $res |
| 523 | 561 | include _ROOT_RESTREINT."public/evaluer_page.php"; |
| 524 | 562 | |
@@ -528,8 +566,9 @@ discard block |
||
| 528 | 566 | // il faut bien lever ce drapeau apres avoir evalue le fond |
| 529 | 567 | // pour ne pas faire descendre le flag vers les inclusions appelees |
| 530 | 568 | if (isset($page['invalideurs']) |
| 531 | - AND isset($page['invalideurs']['session'])) |
|
| 532 | - $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 569 | + AND isset($page['invalideurs']['session'])) { |
|
| 570 | + $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 571 | + } |
|
| 533 | 572 | |
| 534 | 573 | return $page; |
| 535 | 574 | } |
@@ -539,16 +578,17 @@ discard block |
||
| 539 | 578 | function page_base_href(&$texte){ |
| 540 | 579 | static $set_html_base = null; |
| 541 | 580 | if (is_null($set_html_base)){ |
| 542 | - if (!defined('_SET_HTML_BASE')) |
|
| 543 | - // si la profondeur est superieure a 1 |
|
| 581 | + if (!defined('_SET_HTML_BASE')) { |
|
| 582 | + // si la profondeur est superieure a 1 |
|
| 544 | 583 | // est que ce n'est pas une url page ni une url action |
| 545 | 584 | // activer par defaut |
| 546 | 585 | $set_html_base = (( |
| 547 | 586 | $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
| 548 | 587 | AND _request(_SPIP_PAGE) !== 'login' |
| 549 | 588 | AND !_request('action'))?true:false); |
| 550 | - else |
|
| 551 | - $set_html_base = _SET_HTML_BASE; |
|
| 589 | + } else { |
|
| 590 | + $set_html_base = _SET_HTML_BASE; |
|
| 591 | + } |
|
| 552 | 592 | } |
| 553 | 593 | |
| 554 | 594 | if ($set_html_base |
@@ -557,25 +597,26 @@ discard block |
||
| 557 | 597 | AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
| 558 | 598 | $head = substr($texte,0,$poshead); |
| 559 | 599 | $insert = false; |
| 560 | - if (strpos($head, '<base')===false) |
|
| 561 | - $insert = true; |
|
| 562 | - else { |
|
| 600 | + if (strpos($head, '<base')===false) { |
|
| 601 | + $insert = true; |
|
| 602 | + } else { |
|
| 563 | 603 | // si aucun <base ...> n'a de href c'est bon quand meme ! |
| 564 | 604 | $insert = true; |
| 565 | 605 | include_spip('inc/filtres'); |
| 566 | 606 | $bases = extraire_balises($head,'base'); |
| 567 | - foreach ($bases as $base) |
|
| 568 | - if (extraire_attribut($base,'href')) |
|
| 607 | + foreach ($bases as $base) { |
|
| 608 | + if (extraire_attribut($base,'href')) |
|
| 569 | 609 | $insert = false; |
| 610 | + } |
|
| 570 | 611 | } |
| 571 | 612 | if ($insert) { |
| 572 | 613 | include_spip('inc/filtres_mini'); |
| 573 | 614 | // ajouter un base qui reglera tous les liens relatifs |
| 574 | 615 | $base = url_absolue('./'); |
| 575 | 616 | $bbase = "\n<base href=\"$base\" />"; |
| 576 | - if (($pos = strpos($head, '<head>')) !== false) |
|
| 577 | - $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | - elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 617 | + if (($pos = strpos($head, '<head>')) !== false) { |
|
| 618 | + $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 619 | + } elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 579 | 620 | $head = str_replace($r[0], $r[0].$bbase, $head); |
| 580 | 621 | } |
| 581 | 622 | $texte = $head . substr($texte,$poshead); |
@@ -585,10 +626,12 @@ discard block |
||
| 585 | 626 | if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { |
| 586 | 627 | $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); |
| 587 | 628 | } |
| 588 | - if (strpos($texte,"href='#")!==false) |
|
| 589 | - $texte = str_replace("href='#","href='$base#",$texte); |
|
| 590 | - if (strpos($texte, "href=\"#")!==false) |
|
| 591 | - $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 629 | + if (strpos($texte,"href='#")!==false) { |
|
| 630 | + $texte = str_replace("href='#","href='$base#",$texte); |
|
| 631 | + } |
|
| 632 | + if (strpos($texte, "href=\"#")!==false) { |
|
| 633 | + $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 634 | + } |
|
| 592 | 635 | } |
| 593 | 636 | } |
| 594 | 637 | } |
@@ -598,9 +641,10 @@ discard block |
||
| 598 | 641 | // et demarrent par X-Spip-... |
| 599 | 642 | // http://doc.spip.org/@envoyer_entetes |
| 600 | 643 | function envoyer_entetes($entetes) { |
| 601 | - foreach ($entetes as $k => $v) |
|
| 602 | - # if (strncmp($k, 'X-Spip-', 7)) |
|
| 603 | - @header(strlen($v)?"$k: $v":$k); |
|
| 604 | -} |
|
| 644 | + foreach ($entetes as $k => $v) { |
|
| 645 | + # if (strncmp($k, 'X-Spip-', 7)) |
|
| 646 | + @header(strlen($v)?"$k: $v":$k); |
|
| 647 | + } |
|
| 648 | + } |
|
| 605 | 649 | |
| 606 | 650 | ?> |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | function formulaires_configurer_transcodeur_charger_dist(){ |
| 16 | 18 | $valeurs = array( |
@@ -24,10 +26,11 @@ discard block |
||
| 24 | 26 | include_spip('inc/charsets'); |
| 25 | 27 | |
| 26 | 28 | $erreurs = array(); |
| 27 | - if (!$charset=_request('charset')) |
|
| 28 | - $erreurs['charset'] = _T('info_obligatoire'); |
|
| 29 | - elseif ($charset!='utf-8' AND !load_charset($charset)) |
|
| 30 | - $erreurs['charset'] = _T('utf8_convert_erreur_orig', array('charset' => entites_html($charset))); |
|
| 29 | + if (!$charset=_request('charset')) { |
|
| 30 | + $erreurs['charset'] = _T('info_obligatoire'); |
|
| 31 | + } elseif ($charset!='utf-8' AND !load_charset($charset)) { |
|
| 32 | + $erreurs['charset'] = _T('utf8_convert_erreur_orig', array('charset' => entites_html($charset))); |
|
| 33 | + } |
|
| 31 | 34 | |
| 32 | 35 | return $erreurs; |
| 33 | 36 | } |