@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -48,63 +48,63 @@ discard block |
||
| 48 | 48 | * Nom de la fonction, ou false. |
| 49 | 49 | */ |
| 50 | 50 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 51 | - static $echecs = array(); |
|
| 52 | - |
|
| 53 | - if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | - $dossier .= '/'; |
|
| 55 | - } |
|
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | - |
|
| 58 | - if (function_exists($f)) { |
|
| 59 | - return $f; |
|
| 60 | - } |
|
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 62 | - return $g; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if (isset($echecs[$f])) { |
|
| 66 | - return $echecs[$f]; |
|
| 67 | - } |
|
| 68 | - // Sinon charger le fichier de declaration si plausible |
|
| 69 | - |
|
| 70 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | - if ($continue) { |
|
| 72 | - return false; |
|
| 73 | - } //appel interne, on passe |
|
| 74 | - include_spip('inc/minipres'); |
|
| 75 | - echo minipres(); |
|
| 76 | - exit; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // passer en minuscules (cf les balises de formulaires) |
|
| 80 | - // et inclure le fichier |
|
| 81 | - if (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | - // si le fichier truc/machin/nom.php n'existe pas, |
|
| 83 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 84 | - and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 85 | - ) { |
|
| 86 | - include_spip(substr($dossier, 0, -1)); |
|
| 87 | - } |
|
| 88 | - if (function_exists($f)) { |
|
| 89 | - return $f; |
|
| 90 | - } |
|
| 91 | - if (function_exists($g)) { |
|
| 92 | - return $g; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if ($continue) { |
|
| 96 | - return $echecs[$f] = false; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // Echec : message d'erreur |
|
| 100 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | - ($inc ? "" : " (fichier $d absent de $dossier)")); |
|
| 102 | - |
|
| 103 | - include_spip('inc/minipres'); |
|
| 104 | - echo minipres(_T('forum_titre_erreur'), |
|
| 105 | - _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | - array('all_inline'=>true,'status'=>404)); |
|
| 107 | - exit; |
|
| 51 | + static $echecs = array(); |
|
| 52 | + |
|
| 53 | + if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | + $dossier .= '/'; |
|
| 55 | + } |
|
| 56 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | + |
|
| 58 | + if (function_exists($f)) { |
|
| 59 | + return $f; |
|
| 60 | + } |
|
| 61 | + if (function_exists($g = $f . '_dist')) { |
|
| 62 | + return $g; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if (isset($echecs[$f])) { |
|
| 66 | + return $echecs[$f]; |
|
| 67 | + } |
|
| 68 | + // Sinon charger le fichier de declaration si plausible |
|
| 69 | + |
|
| 70 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | + if ($continue) { |
|
| 72 | + return false; |
|
| 73 | + } //appel interne, on passe |
|
| 74 | + include_spip('inc/minipres'); |
|
| 75 | + echo minipres(); |
|
| 76 | + exit; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // passer en minuscules (cf les balises de formulaires) |
|
| 80 | + // et inclure le fichier |
|
| 81 | + if (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | + // si le fichier truc/machin/nom.php n'existe pas, |
|
| 83 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 84 | + and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 85 | + ) { |
|
| 86 | + include_spip(substr($dossier, 0, -1)); |
|
| 87 | + } |
|
| 88 | + if (function_exists($f)) { |
|
| 89 | + return $f; |
|
| 90 | + } |
|
| 91 | + if (function_exists($g)) { |
|
| 92 | + return $g; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if ($continue) { |
|
| 96 | + return $echecs[$f] = false; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // Echec : message d'erreur |
|
| 100 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | + ($inc ? "" : " (fichier $d absent de $dossier)")); |
|
| 102 | + |
|
| 103 | + include_spip('inc/minipres'); |
|
| 104 | + echo minipres(_T('forum_titre_erreur'), |
|
| 105 | + _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | + array('all_inline'=>true,'status'=>404)); |
|
| 107 | + exit; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -114,17 +114,17 @@ discard block |
||
| 114 | 114 | * @return bool |
| 115 | 115 | */ |
| 116 | 116 | function include_once_check($file) { |
| 117 | - if (file_exists($file)) { |
|
| 118 | - include_once $file; |
|
| 117 | + if (file_exists($file)) { |
|
| 118 | + include_once $file; |
|
| 119 | 119 | |
| 120 | - return true; |
|
| 121 | - } |
|
| 122 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 123 | - $crash = ($crash ? $crash : array()); |
|
| 124 | - $crash[$file] = true; |
|
| 125 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 120 | + return true; |
|
| 121 | + } |
|
| 122 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 123 | + $crash = ($crash ? $crash : array()); |
|
| 124 | + $crash[$file] = true; |
|
| 125 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 126 | 126 | |
| 127 | - return false; |
|
| 127 | + return false; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * - string : chemin du fichier trouvé |
| 149 | 149 | **/ |
| 150 | 150 | function include_spip($f, $include = true) { |
| 151 | - return find_in_path($f . '.php', '', $include); |
|
| 151 | + return find_in_path($f . '.php', '', $include); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * - string : chemin du fichier trouvé |
| 169 | 169 | **/ |
| 170 | 170 | function require_spip($f) { |
| 171 | - return find_in_path($f . '.php', '', 'required'); |
|
| 171 | + return find_in_path($f . '.php', '', 'required'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -194,22 +194,22 @@ discard block |
||
| 194 | 194 | * Les paramètres du pipeline modifiés |
| 195 | 195 | **/ |
| 196 | 196 | function minipipe($fonc, &$val) { |
| 197 | - // fonction |
|
| 198 | - if (function_exists($fonc)) { |
|
| 199 | - $val = call_user_func($fonc, $val); |
|
| 200 | - } // Class::Methode |
|
| 201 | - else { |
|
| 202 | - if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 203 | - and $methode = array($regs[1], $regs[2]) |
|
| 204 | - and is_callable($methode) |
|
| 205 | - ) { |
|
| 206 | - $val = call_user_func($methode, $val); |
|
| 207 | - } else { |
|
| 208 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 209 | - } |
|
| 210 | - } |
|
| 197 | + // fonction |
|
| 198 | + if (function_exists($fonc)) { |
|
| 199 | + $val = call_user_func($fonc, $val); |
|
| 200 | + } // Class::Methode |
|
| 201 | + else { |
|
| 202 | + if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 203 | + and $methode = array($regs[1], $regs[2]) |
|
| 204 | + and is_callable($methode) |
|
| 205 | + ) { |
|
| 206 | + $val = call_user_func($methode, $val); |
|
| 207 | + } else { |
|
| 208 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - return $val; |
|
| 212 | + return $val; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -240,45 +240,45 @@ discard block |
||
| 240 | 240 | * Résultat |
| 241 | 241 | */ |
| 242 | 242 | function pipeline($action, $val = null) { |
| 243 | - static $charger; |
|
| 244 | - |
|
| 245 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 246 | - if (!$charger) { |
|
| 247 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 248 | - include_spip('inc/plugin'); |
|
| 249 | - // generer les fichiers php precompiles |
|
| 250 | - // de chargement des plugins et des pipelines |
|
| 251 | - actualise_plugins_actifs(); |
|
| 252 | - if (!($ok = @is_readable($charger))) { |
|
| 253 | - spip_log("fichier $charger pas cree"); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if ($ok) { |
|
| 258 | - include_once $charger; |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - // appliquer notre fonction si elle existe |
|
| 263 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 264 | - if (function_exists($fonc)) { |
|
| 265 | - $val = $fonc($val); |
|
| 266 | - } // plantage ? |
|
| 267 | - else { |
|
| 268 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - // si le flux est une table avec 2 cle args&data |
|
| 272 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 273 | - // array_key_exists pour php 4.1.0 |
|
| 274 | - if (is_array($val) |
|
| 275 | - and count($val) == 2 |
|
| 276 | - and (array_key_exists('data', $val)) |
|
| 277 | - ) { |
|
| 278 | - $val = $val['data']; |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - return $val; |
|
| 243 | + static $charger; |
|
| 244 | + |
|
| 245 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 246 | + if (!$charger) { |
|
| 247 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 248 | + include_spip('inc/plugin'); |
|
| 249 | + // generer les fichiers php precompiles |
|
| 250 | + // de chargement des plugins et des pipelines |
|
| 251 | + actualise_plugins_actifs(); |
|
| 252 | + if (!($ok = @is_readable($charger))) { |
|
| 253 | + spip_log("fichier $charger pas cree"); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if ($ok) { |
|
| 258 | + include_once $charger; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + // appliquer notre fonction si elle existe |
|
| 263 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 264 | + if (function_exists($fonc)) { |
|
| 265 | + $val = $fonc($val); |
|
| 266 | + } // plantage ? |
|
| 267 | + else { |
|
| 268 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + // si le flux est une table avec 2 cle args&data |
|
| 272 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 273 | + // array_key_exists pour php 4.1.0 |
|
| 274 | + if (is_array($val) |
|
| 275 | + and count($val) == 2 |
|
| 276 | + and (array_key_exists('data', $val)) |
|
| 277 | + ) { |
|
| 278 | + $val = $val['data']; |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + return $val; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -322,35 +322,35 @@ discard block |
||
| 322 | 322 | * paramètre est planté pour cause de compatibilité ascendante. |
| 323 | 323 | */ |
| 324 | 324 | function spip_log($message = null, $name = null) { |
| 325 | - static $pre = array(); |
|
| 326 | - static $log; |
|
| 327 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 328 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 329 | - $logname = null; |
|
| 330 | - } |
|
| 331 | - if (!isset($regs[2]) or !$niveau = $regs[2]) { |
|
| 332 | - $niveau = _LOG_INFO; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 336 | - if (!$pre) { |
|
| 337 | - $pre = array( |
|
| 338 | - _LOG_HS => 'HS:', |
|
| 339 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 340 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 341 | - _LOG_ERREUR => 'ERREUR:', |
|
| 342 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 343 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 344 | - _LOG_INFO => 'info:', |
|
| 345 | - _LOG_DEBUG => 'debug:' |
|
| 346 | - ); |
|
| 347 | - $log = charger_fonction('log', 'inc'); |
|
| 348 | - } |
|
| 349 | - if (!is_string($message)) { |
|
| 350 | - $message = print_r($message, true); |
|
| 351 | - } |
|
| 352 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 353 | - } |
|
| 325 | + static $pre = array(); |
|
| 326 | + static $log; |
|
| 327 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 328 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 329 | + $logname = null; |
|
| 330 | + } |
|
| 331 | + if (!isset($regs[2]) or !$niveau = $regs[2]) { |
|
| 332 | + $niveau = _LOG_INFO; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 336 | + if (!$pre) { |
|
| 337 | + $pre = array( |
|
| 338 | + _LOG_HS => 'HS:', |
|
| 339 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 340 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 341 | + _LOG_ERREUR => 'ERREUR:', |
|
| 342 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 343 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 344 | + _LOG_INFO => 'info:', |
|
| 345 | + _LOG_DEBUG => 'debug:' |
|
| 346 | + ); |
|
| 347 | + $log = charger_fonction('log', 'inc'); |
|
| 348 | + } |
|
| 349 | + if (!is_string($message)) { |
|
| 350 | + $message = print_r($message, true); |
|
| 351 | + } |
|
| 352 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 353 | + } |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
@@ -361,8 +361,8 @@ discard block |
||
| 361 | 361 | * @param array $opt Tableau d'options |
| 362 | 362 | **/ |
| 363 | 363 | function journal($phrase, $opt = array()) { |
| 364 | - $journal = charger_fonction('journal', 'inc'); |
|
| 365 | - $journal($phrase, $opt); |
|
| 364 | + $journal = charger_fonction('journal', 'inc'); |
|
| 365 | + $journal($phrase, $opt); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | |
@@ -381,36 +381,36 @@ discard block |
||
| 381 | 381 | **/ |
| 382 | 382 | function _request($var, $c = false) { |
| 383 | 383 | |
| 384 | - if (is_array($c)) { |
|
| 385 | - return isset($c[$var]) ? $c[$var] : null; |
|
| 386 | - } |
|
| 384 | + if (is_array($c)) { |
|
| 385 | + return isset($c[$var]) ? $c[$var] : null; |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - if (isset($_GET[$var])) { |
|
| 389 | - $a = $_GET[$var]; |
|
| 390 | - } elseif (isset($_POST[$var])) { |
|
| 391 | - $a = $_POST[$var]; |
|
| 392 | - } else { |
|
| 393 | - return null; |
|
| 394 | - } |
|
| 388 | + if (isset($_GET[$var])) { |
|
| 389 | + $a = $_GET[$var]; |
|
| 390 | + } elseif (isset($_POST[$var])) { |
|
| 391 | + $a = $_POST[$var]; |
|
| 392 | + } else { |
|
| 393 | + return null; |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - // Si on est en ajax et en POST tout a ete encode |
|
| 397 | - // via encodeURIComponent, il faut donc repasser |
|
| 398 | - // dans le charset local... |
|
| 399 | - if (defined('_AJAX') |
|
| 400 | - and _AJAX |
|
| 401 | - and isset($GLOBALS['meta']['charset']) |
|
| 402 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 403 | - and is_string($a) |
|
| 404 | - // check rapide mais pas fiable |
|
| 405 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 406 | - // check fiable |
|
| 407 | - and include_spip('inc/charsets') |
|
| 408 | - and is_utf8($a) |
|
| 409 | - ) { |
|
| 410 | - return importer_charset($a, 'utf-8'); |
|
| 411 | - } |
|
| 396 | + // Si on est en ajax et en POST tout a ete encode |
|
| 397 | + // via encodeURIComponent, il faut donc repasser |
|
| 398 | + // dans le charset local... |
|
| 399 | + if (defined('_AJAX') |
|
| 400 | + and _AJAX |
|
| 401 | + and isset($GLOBALS['meta']['charset']) |
|
| 402 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 403 | + and is_string($a) |
|
| 404 | + // check rapide mais pas fiable |
|
| 405 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 406 | + // check fiable |
|
| 407 | + and include_spip('inc/charsets') |
|
| 408 | + and is_utf8($a) |
|
| 409 | + ) { |
|
| 410 | + return importer_charset($a, 'utf-8'); |
|
| 411 | + } |
|
| 412 | 412 | |
| 413 | - return $a; |
|
| 413 | + return $a; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
@@ -428,22 +428,22 @@ discard block |
||
| 428 | 428 | * - false sinon |
| 429 | 429 | **/ |
| 430 | 430 | function set_request($var, $val = null, $c = false) { |
| 431 | - if (is_array($c)) { |
|
| 432 | - unset($c[$var]); |
|
| 433 | - if ($val !== null) { |
|
| 434 | - $c[$var] = $val; |
|
| 435 | - } |
|
| 431 | + if (is_array($c)) { |
|
| 432 | + unset($c[$var]); |
|
| 433 | + if ($val !== null) { |
|
| 434 | + $c[$var] = $val; |
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | - return $c; |
|
| 438 | - } |
|
| 437 | + return $c; |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | - unset($_GET[$var]); |
|
| 441 | - unset($_POST[$var]); |
|
| 442 | - if ($val !== null) { |
|
| 443 | - $_GET[$var] = $val; |
|
| 444 | - } |
|
| 440 | + unset($_GET[$var]); |
|
| 441 | + unset($_POST[$var]); |
|
| 442 | + if ($val !== null) { |
|
| 443 | + $_GET[$var] = $val; |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | - return false; # n'affecte pas $c |
|
| 446 | + return false; # n'affecte pas $c |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | |
@@ -452,23 +452,22 @@ discard block |
||
| 452 | 452 | * |
| 453 | 453 | * On est sur le web, on exclut certains protocoles, |
| 454 | 454 | * notamment 'file://', 'php://' et d'autres… |
| 455 | - |
|
| 456 | 455 | * @param string $url |
| 457 | 456 | * @return bool |
| 458 | 457 | */ |
| 459 | 458 | function tester_url_absolue($url) { |
| 460 | - $url = trim($url); |
|
| 461 | - if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 462 | - if ( |
|
| 463 | - isset($m[1]) |
|
| 464 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 465 | - and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 466 | - ) { |
|
| 467 | - return false; |
|
| 468 | - } |
|
| 469 | - return true; |
|
| 470 | - } |
|
| 471 | - return false; |
|
| 459 | + $url = trim($url); |
|
| 460 | + if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 461 | + if ( |
|
| 462 | + isset($m[1]) |
|
| 463 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 464 | + and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 465 | + ) { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 468 | + return true; |
|
| 469 | + } |
|
| 470 | + return false; |
|
| 472 | 471 | } |
| 473 | 472 | |
| 474 | 473 | /** |
@@ -490,94 +489,94 @@ discard block |
||
| 490 | 489 | * @return string URL |
| 491 | 490 | */ |
| 492 | 491 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 493 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 494 | - if (strpos($c, "|") !== false and is_null($v)) { |
|
| 495 | - return null; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - // lever l'#ancre |
|
| 499 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 500 | - $url = $r[1]; |
|
| 501 | - $ancre = $r[2]; |
|
| 502 | - } else { |
|
| 503 | - $ancre = ''; |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - // eclater |
|
| 507 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 508 | - |
|
| 509 | - // recuperer la base |
|
| 510 | - $a = array_shift($url); |
|
| 511 | - if (!$a) { |
|
| 512 | - $a = './'; |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 516 | - $ajouts = array_flip(explode('|', $c)); |
|
| 517 | - $u = is_array($v) ? $v : rawurlencode($v); |
|
| 518 | - $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 519 | - $v_read = null; |
|
| 520 | - // lire les variables et agir |
|
| 521 | - foreach ($url as $n => $val) { |
|
| 522 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 523 | - $r = array_pad($r, 3, null); |
|
| 524 | - if ($v === null) { |
|
| 525 | - // c'est un tableau, on memorise les valeurs |
|
| 526 | - if (substr($r[1], -2) == "[]") { |
|
| 527 | - if (!$v_read) { |
|
| 528 | - $v_read = array(); |
|
| 529 | - } |
|
| 530 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 531 | - } // c'est un scalaire, on retourne direct |
|
| 532 | - else { |
|
| 533 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 534 | - } |
|
| 535 | - } // suppression |
|
| 536 | - elseif (!$testv) { |
|
| 537 | - unset($url[$n]); |
|
| 538 | - } |
|
| 539 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 540 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 541 | - elseif (substr($r[1], -2) != '[]') { |
|
| 542 | - $url[$n] = $r[1] . '=' . $u; |
|
| 543 | - unset($ajouts[$r[1]]); |
|
| 544 | - } |
|
| 545 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 546 | - // départ, on remplira à l'étape suivante |
|
| 547 | - else { |
|
| 548 | - unset($url[$n]); |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - // traiter les parametres pas encore trouves |
|
| 554 | - if ($v === null |
|
| 555 | - and $args = func_get_args() |
|
| 556 | - and count($args) == 2 |
|
| 557 | - ) { |
|
| 558 | - return $v_read; // rien trouve ou un tableau |
|
| 559 | - } elseif ($testv) { |
|
| 560 | - foreach ($ajouts as $k => $n) { |
|
| 561 | - if (!is_array($v)) { |
|
| 562 | - $url[] = $k . '=' . $u; |
|
| 563 | - } else { |
|
| 564 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 565 | - foreach ($v as $w) { |
|
| 566 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 567 | - } |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - // eliminer les vides |
|
| 573 | - $url = array_filter($url); |
|
| 574 | - |
|
| 575 | - // recomposer l'adresse |
|
| 576 | - if ($url) { |
|
| 577 | - $a .= '?' . join($sep, $url); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - return $a . $ancre; |
|
| 492 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 493 | + if (strpos($c, "|") !== false and is_null($v)) { |
|
| 494 | + return null; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + // lever l'#ancre |
|
| 498 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 499 | + $url = $r[1]; |
|
| 500 | + $ancre = $r[2]; |
|
| 501 | + } else { |
|
| 502 | + $ancre = ''; |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + // eclater |
|
| 506 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 507 | + |
|
| 508 | + // recuperer la base |
|
| 509 | + $a = array_shift($url); |
|
| 510 | + if (!$a) { |
|
| 511 | + $a = './'; |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 515 | + $ajouts = array_flip(explode('|', $c)); |
|
| 516 | + $u = is_array($v) ? $v : rawurlencode($v); |
|
| 517 | + $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 518 | + $v_read = null; |
|
| 519 | + // lire les variables et agir |
|
| 520 | + foreach ($url as $n => $val) { |
|
| 521 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 522 | + $r = array_pad($r, 3, null); |
|
| 523 | + if ($v === null) { |
|
| 524 | + // c'est un tableau, on memorise les valeurs |
|
| 525 | + if (substr($r[1], -2) == "[]") { |
|
| 526 | + if (!$v_read) { |
|
| 527 | + $v_read = array(); |
|
| 528 | + } |
|
| 529 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 530 | + } // c'est un scalaire, on retourne direct |
|
| 531 | + else { |
|
| 532 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 533 | + } |
|
| 534 | + } // suppression |
|
| 535 | + elseif (!$testv) { |
|
| 536 | + unset($url[$n]); |
|
| 537 | + } |
|
| 538 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 539 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 540 | + elseif (substr($r[1], -2) != '[]') { |
|
| 541 | + $url[$n] = $r[1] . '=' . $u; |
|
| 542 | + unset($ajouts[$r[1]]); |
|
| 543 | + } |
|
| 544 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 545 | + // départ, on remplira à l'étape suivante |
|
| 546 | + else { |
|
| 547 | + unset($url[$n]); |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + // traiter les parametres pas encore trouves |
|
| 553 | + if ($v === null |
|
| 554 | + and $args = func_get_args() |
|
| 555 | + and count($args) == 2 |
|
| 556 | + ) { |
|
| 557 | + return $v_read; // rien trouve ou un tableau |
|
| 558 | + } elseif ($testv) { |
|
| 559 | + foreach ($ajouts as $k => $n) { |
|
| 560 | + if (!is_array($v)) { |
|
| 561 | + $url[] = $k . '=' . $u; |
|
| 562 | + } else { |
|
| 563 | + $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 564 | + foreach ($v as $w) { |
|
| 565 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 566 | + } |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + // eliminer les vides |
|
| 572 | + $url = array_filter($url); |
|
| 573 | + |
|
| 574 | + // recomposer l'adresse |
|
| 575 | + if ($url) { |
|
| 576 | + $a .= '?' . join($sep, $url); |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + return $a . $ancre; |
|
| 581 | 580 | } |
| 582 | 581 | |
| 583 | 582 | /** |
@@ -595,21 +594,21 @@ discard block |
||
| 595 | 594 | * @return string |
| 596 | 595 | */ |
| 597 | 596 | function ancre_url($url, $ancre) { |
| 598 | - // lever l'#ancre |
|
| 599 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 600 | - $url = $r[1]; |
|
| 601 | - } |
|
| 602 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 603 | - if (!function_exists('translitteration')) { |
|
| 604 | - include_spip('inc/charsets'); |
|
| 605 | - } |
|
| 606 | - $ancre = preg_replace( |
|
| 607 | - array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 608 | - array('', '-'), |
|
| 609 | - translitteration($ancre) |
|
| 610 | - ); |
|
| 611 | - } |
|
| 612 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 597 | + // lever l'#ancre |
|
| 598 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 599 | + $url = $r[1]; |
|
| 600 | + } |
|
| 601 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 602 | + if (!function_exists('translitteration')) { |
|
| 603 | + include_spip('inc/charsets'); |
|
| 604 | + } |
|
| 605 | + $ancre = preg_replace( |
|
| 606 | + array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 607 | + array('', '-'), |
|
| 608 | + translitteration($ancre) |
|
| 609 | + ); |
|
| 610 | + } |
|
| 611 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 613 | 612 | } |
| 614 | 613 | |
| 615 | 614 | /** |
@@ -619,16 +618,16 @@ discard block |
||
| 619 | 618 | * @return string |
| 620 | 619 | */ |
| 621 | 620 | function nettoyer_uri($reset = null) { |
| 622 | - static $done = false; |
|
| 623 | - static $propre = ''; |
|
| 624 | - if (!is_null($reset)) { |
|
| 625 | - return $propre = $reset; |
|
| 626 | - } |
|
| 627 | - if ($done) { |
|
| 628 | - return $propre; |
|
| 629 | - } |
|
| 630 | - $done = true; |
|
| 631 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 621 | + static $done = false; |
|
| 622 | + static $propre = ''; |
|
| 623 | + if (!is_null($reset)) { |
|
| 624 | + return $propre = $reset; |
|
| 625 | + } |
|
| 626 | + if ($done) { |
|
| 627 | + return $propre; |
|
| 628 | + } |
|
| 629 | + $done = true; |
|
| 630 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 632 | 631 | } |
| 633 | 632 | |
| 634 | 633 | /** |
@@ -640,13 +639,13 @@ discard block |
||
| 640 | 639 | * @return string |
| 641 | 640 | */ |
| 642 | 641 | function nettoyer_uri_var($request_uri) { |
| 643 | - $uri1 = $request_uri; |
|
| 644 | - do { |
|
| 645 | - $uri = $uri1; |
|
| 646 | - $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 647 | - '\1', $uri); |
|
| 648 | - } while ($uri <> $uri1); |
|
| 649 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 642 | + $uri1 = $request_uri; |
|
| 643 | + do { |
|
| 644 | + $uri = $uri1; |
|
| 645 | + $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 646 | + '\1', $uri); |
|
| 647 | + } while ($uri <> $uri1); |
|
| 648 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 650 | 649 | } |
| 651 | 650 | |
| 652 | 651 | |
@@ -660,47 +659,47 @@ discard block |
||
| 660 | 659 | * URL vers soi-même |
| 661 | 660 | **/ |
| 662 | 661 | function self($amp = '&', $root = false) { |
| 663 | - $url = nettoyer_uri(); |
|
| 664 | - if (!$root |
|
| 665 | - and ( |
|
| 666 | - // si pas de profondeur on peut tronquer |
|
| 667 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 668 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 669 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 670 | - ) { |
|
| 671 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 672 | - } |
|
| 673 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 674 | - foreach ($_POST as $v => $c) { |
|
| 675 | - if (substr($v, 0, 3) == 'id_') { |
|
| 676 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 677 | - } |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - // supprimer les variables sans interet |
|
| 681 | - if (test_espace_prive()) { |
|
| 682 | - $url = preg_replace(',([?&])(' |
|
| 683 | - . 'lang|show_docs|' |
|
| 684 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 685 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 686 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - // eviter les hacks |
|
| 690 | - include_spip('inc/filtres_mini'); |
|
| 691 | - $url = spip_htmlspecialchars($url); |
|
| 662 | + $url = nettoyer_uri(); |
|
| 663 | + if (!$root |
|
| 664 | + and ( |
|
| 665 | + // si pas de profondeur on peut tronquer |
|
| 666 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 667 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 668 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 669 | + ) { |
|
| 670 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 671 | + } |
|
| 672 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 673 | + foreach ($_POST as $v => $c) { |
|
| 674 | + if (substr($v, 0, 3) == 'id_') { |
|
| 675 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 676 | + } |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + // supprimer les variables sans interet |
|
| 680 | + if (test_espace_prive()) { |
|
| 681 | + $url = preg_replace(',([?&])(' |
|
| 682 | + . 'lang|show_docs|' |
|
| 683 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 684 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 685 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + // eviter les hacks |
|
| 689 | + include_spip('inc/filtres_mini'); |
|
| 690 | + $url = spip_htmlspecialchars($url); |
|
| 692 | 691 | |
| 693 | - $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 692 | + $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 694 | 693 | |
| 695 | - // & ? |
|
| 696 | - if ($amp != '&') { |
|
| 697 | - $url = str_replace('&', $amp, $url); |
|
| 698 | - } |
|
| 694 | + // & ? |
|
| 695 | + if ($amp != '&') { |
|
| 696 | + $url = str_replace('&', $amp, $url); |
|
| 697 | + } |
|
| 699 | 698 | |
| 700 | - // Si ca demarre par ? ou vide, donner './' |
|
| 701 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 699 | + // Si ca demarre par ? ou vide, donner './' |
|
| 700 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 702 | 701 | |
| 703 | - return $url; |
|
| 702 | + return $url; |
|
| 704 | 703 | } |
| 705 | 704 | |
| 706 | 705 | |
@@ -711,7 +710,7 @@ discard block |
||
| 711 | 710 | * true si c'est le cas, false sinon. |
| 712 | 711 | */ |
| 713 | 712 | function test_espace_prive() { |
| 714 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 713 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 715 | 714 | } |
| 716 | 715 | |
| 717 | 716 | /** |
@@ -721,7 +720,7 @@ discard block |
||
| 721 | 720 | * @return bool |
| 722 | 721 | */ |
| 723 | 722 | function test_plugin_actif($plugin) { |
| 724 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 723 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 725 | 724 | } |
| 726 | 725 | |
| 727 | 726 | /** |
@@ -752,51 +751,51 @@ discard block |
||
| 752 | 751 | * Texte |
| 753 | 752 | */ |
| 754 | 753 | function _T($texte, $args = array(), $options = array()) { |
| 755 | - static $traduire = false; |
|
| 756 | - $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 757 | - if ($options) { |
|
| 758 | - // support de l'ancien argument $class |
|
| 759 | - if (is_string($options)) { |
|
| 760 | - $options = array('class' => $options); |
|
| 761 | - } |
|
| 762 | - $o = array_merge($o, $options); |
|
| 763 | - } |
|
| 754 | + static $traduire = false; |
|
| 755 | + $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 756 | + if ($options) { |
|
| 757 | + // support de l'ancien argument $class |
|
| 758 | + if (is_string($options)) { |
|
| 759 | + $options = array('class' => $options); |
|
| 760 | + } |
|
| 761 | + $o = array_merge($o, $options); |
|
| 762 | + } |
|
| 764 | 763 | |
| 765 | - if (!$traduire) { |
|
| 766 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 767 | - include_spip('inc/lang'); |
|
| 768 | - } |
|
| 764 | + if (!$traduire) { |
|
| 765 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 766 | + include_spip('inc/lang'); |
|
| 767 | + } |
|
| 769 | 768 | |
| 770 | - // On peut passer explicitement la langue dans le tableau |
|
| 771 | - // On utilise le même nom de variable que la globale |
|
| 772 | - if (isset($args['spip_lang'])) { |
|
| 773 | - $lang = $args['spip_lang']; |
|
| 774 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 775 | - unset($args['spip_lang']); |
|
| 776 | - } // Sinon on prend la langue du contexte |
|
| 777 | - else { |
|
| 778 | - $lang = $GLOBALS['spip_lang']; |
|
| 779 | - } |
|
| 780 | - $text = $traduire($texte, $lang); |
|
| 769 | + // On peut passer explicitement la langue dans le tableau |
|
| 770 | + // On utilise le même nom de variable que la globale |
|
| 771 | + if (isset($args['spip_lang'])) { |
|
| 772 | + $lang = $args['spip_lang']; |
|
| 773 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 774 | + unset($args['spip_lang']); |
|
| 775 | + } // Sinon on prend la langue du contexte |
|
| 776 | + else { |
|
| 777 | + $lang = $GLOBALS['spip_lang']; |
|
| 778 | + } |
|
| 779 | + $text = $traduire($texte, $lang); |
|
| 781 | 780 | |
| 782 | - if (!strlen($text)) { |
|
| 783 | - if (!$o['force']) { |
|
| 784 | - return ''; |
|
| 785 | - } |
|
| 781 | + if (!strlen($text)) { |
|
| 782 | + if (!$o['force']) { |
|
| 783 | + return ''; |
|
| 784 | + } |
|
| 786 | 785 | |
| 787 | - $text = $texte; |
|
| 786 | + $text = $texte; |
|
| 788 | 787 | |
| 789 | - // pour les chaines non traduites, assurer un service minimum |
|
| 790 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 791 | - $text = str_replace('_', ' ', |
|
| 792 | - (($n = strpos($text, ':')) === false ? $texte : |
|
| 793 | - substr($texte, $n + 1))); |
|
| 794 | - } |
|
| 795 | - $o['class'] = null; |
|
| 788 | + // pour les chaines non traduites, assurer un service minimum |
|
| 789 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 790 | + $text = str_replace('_', ' ', |
|
| 791 | + (($n = strpos($text, ':')) === false ? $texte : |
|
| 792 | + substr($texte, $n + 1))); |
|
| 793 | + } |
|
| 794 | + $o['class'] = null; |
|
| 796 | 795 | |
| 797 | - } |
|
| 796 | + } |
|
| 798 | 797 | |
| 799 | - return _L($text, $args, $o); |
|
| 798 | + return _L($text, $args, $o); |
|
| 800 | 799 | |
| 801 | 800 | } |
| 802 | 801 | |
@@ -824,53 +823,53 @@ discard block |
||
| 824 | 823 | * Texte |
| 825 | 824 | */ |
| 826 | 825 | function _L($text, $args = array(), $options = array()) { |
| 827 | - $f = $text; |
|
| 828 | - $defaut_options = array( |
|
| 829 | - 'class' => null, |
|
| 830 | - 'sanitize' => true, |
|
| 831 | - ); |
|
| 832 | - // support de l'ancien argument $class |
|
| 833 | - if ($options and is_string($options)) { |
|
| 834 | - $options = array('class' => $options); |
|
| 835 | - } |
|
| 836 | - if (is_array($options)) { |
|
| 837 | - $options += $defaut_options; |
|
| 838 | - } else { |
|
| 839 | - $options = $defaut_options; |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - if (is_array($args) and count($args)) { |
|
| 843 | - if (!function_exists('interdire_scripts')) { |
|
| 844 | - include_spip('inc/texte'); |
|
| 845 | - } |
|
| 846 | - if (!function_exists('echapper_html_suspect')) { |
|
| 847 | - include_spip('inc/texte_mini'); |
|
| 848 | - } |
|
| 849 | - foreach ($args as $name => $value) { |
|
| 850 | - if (strpos($text, "@$name@") !== false) { |
|
| 851 | - if ($options['sanitize']) { |
|
| 852 | - $value = echapper_html_suspect($value); |
|
| 853 | - $value = interdire_scripts($value, -1); |
|
| 854 | - } |
|
| 855 | - if (!empty($options['class'])) { |
|
| 856 | - $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 857 | - } |
|
| 858 | - $text = str_replace("@$name@", $value, $text); |
|
| 859 | - unset($args[$name]); |
|
| 860 | - } |
|
| 861 | - } |
|
| 862 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 863 | - // (chaines de langues pas a jour) |
|
| 864 | - if ($args) { |
|
| 865 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 866 | - } |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 870 | - return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 871 | - } else { |
|
| 872 | - return $text; |
|
| 873 | - } |
|
| 826 | + $f = $text; |
|
| 827 | + $defaut_options = array( |
|
| 828 | + 'class' => null, |
|
| 829 | + 'sanitize' => true, |
|
| 830 | + ); |
|
| 831 | + // support de l'ancien argument $class |
|
| 832 | + if ($options and is_string($options)) { |
|
| 833 | + $options = array('class' => $options); |
|
| 834 | + } |
|
| 835 | + if (is_array($options)) { |
|
| 836 | + $options += $defaut_options; |
|
| 837 | + } else { |
|
| 838 | + $options = $defaut_options; |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + if (is_array($args) and count($args)) { |
|
| 842 | + if (!function_exists('interdire_scripts')) { |
|
| 843 | + include_spip('inc/texte'); |
|
| 844 | + } |
|
| 845 | + if (!function_exists('echapper_html_suspect')) { |
|
| 846 | + include_spip('inc/texte_mini'); |
|
| 847 | + } |
|
| 848 | + foreach ($args as $name => $value) { |
|
| 849 | + if (strpos($text, "@$name@") !== false) { |
|
| 850 | + if ($options['sanitize']) { |
|
| 851 | + $value = echapper_html_suspect($value); |
|
| 852 | + $value = interdire_scripts($value, -1); |
|
| 853 | + } |
|
| 854 | + if (!empty($options['class'])) { |
|
| 855 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 856 | + } |
|
| 857 | + $text = str_replace("@$name@", $value, $text); |
|
| 858 | + unset($args[$name]); |
|
| 859 | + } |
|
| 860 | + } |
|
| 861 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 862 | + // (chaines de langues pas a jour) |
|
| 863 | + if ($args) { |
|
| 864 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 869 | + return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 870 | + } else { |
|
| 871 | + return $text; |
|
| 872 | + } |
|
| 874 | 873 | } |
| 875 | 874 | |
| 876 | 875 | |
@@ -884,13 +883,13 @@ discard block |
||
| 884 | 883 | * @return string |
| 885 | 884 | */ |
| 886 | 885 | function joli_repertoire($rep) { |
| 887 | - $a = substr($rep, 0, 1); |
|
| 888 | - if ($a <> '.' and $a <> '/') { |
|
| 889 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 890 | - } |
|
| 891 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 886 | + $a = substr($rep, 0, 1); |
|
| 887 | + if ($a <> '.' and $a <> '/') { |
|
| 888 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 889 | + } |
|
| 890 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 892 | 891 | |
| 893 | - return $rep; |
|
| 892 | + return $rep; |
|
| 894 | 893 | } |
| 895 | 894 | |
| 896 | 895 | |
@@ -915,33 +914,33 @@ discard block |
||
| 915 | 914 | * @return float|int|string|void |
| 916 | 915 | */ |
| 917 | 916 | function spip_timer($t = 'rien', $raw = false) { |
| 918 | - static $time; |
|
| 919 | - $a = time(); |
|
| 920 | - $b = microtime(); |
|
| 921 | - // microtime peut contenir les microsecondes et le temps |
|
| 922 | - $b = explode(' ', $b); |
|
| 923 | - if (count($b) == 2) { |
|
| 924 | - $a = end($b); |
|
| 925 | - } // plus precis ! |
|
| 926 | - $b = reset($b); |
|
| 927 | - if (!isset($time[$t])) { |
|
| 928 | - $time[$t] = $a + $b; |
|
| 929 | - } else { |
|
| 930 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 931 | - unset($time[$t]); |
|
| 917 | + static $time; |
|
| 918 | + $a = time(); |
|
| 919 | + $b = microtime(); |
|
| 920 | + // microtime peut contenir les microsecondes et le temps |
|
| 921 | + $b = explode(' ', $b); |
|
| 922 | + if (count($b) == 2) { |
|
| 923 | + $a = end($b); |
|
| 924 | + } // plus precis ! |
|
| 925 | + $b = reset($b); |
|
| 926 | + if (!isset($time[$t])) { |
|
| 927 | + $time[$t] = $a + $b; |
|
| 928 | + } else { |
|
| 929 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 930 | + unset($time[$t]); |
|
| 932 | 931 | # echo "'$p'";exit; |
| 933 | - if ($raw) { |
|
| 934 | - return $p; |
|
| 935 | - } |
|
| 936 | - if ($p < 1000) { |
|
| 937 | - $s = ''; |
|
| 938 | - } else { |
|
| 939 | - $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 940 | - $p -= ($x * 1000); |
|
| 941 | - } |
|
| 932 | + if ($raw) { |
|
| 933 | + return $p; |
|
| 934 | + } |
|
| 935 | + if ($p < 1000) { |
|
| 936 | + $s = ''; |
|
| 937 | + } else { |
|
| 938 | + $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 939 | + $p -= ($x * 1000); |
|
| 940 | + } |
|
| 942 | 941 | |
| 943 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 944 | - } |
|
| 942 | + return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 943 | + } |
|
| 945 | 944 | } |
| 946 | 945 | |
| 947 | 946 | |
@@ -949,21 +948,21 @@ discard block |
||
| 949 | 948 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 950 | 949 | // http://code.spip.net/@spip_touch |
| 951 | 950 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 952 | - if ($duree) { |
|
| 953 | - clearstatcache(); |
|
| 954 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 955 | - return false; |
|
| 956 | - } |
|
| 957 | - } |
|
| 958 | - if ($touch !== false) { |
|
| 959 | - if (!@touch($fichier)) { |
|
| 960 | - spip_unlink($fichier); |
|
| 961 | - @touch($fichier); |
|
| 962 | - }; |
|
| 963 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 964 | - } |
|
| 951 | + if ($duree) { |
|
| 952 | + clearstatcache(); |
|
| 953 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 954 | + return false; |
|
| 955 | + } |
|
| 956 | + } |
|
| 957 | + if ($touch !== false) { |
|
| 958 | + if (!@touch($fichier)) { |
|
| 959 | + spip_unlink($fichier); |
|
| 960 | + @touch($fichier); |
|
| 961 | + }; |
|
| 962 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 963 | + } |
|
| 965 | 964 | |
| 966 | - return true; |
|
| 965 | + return true; |
|
| 967 | 966 | } |
| 968 | 967 | |
| 969 | 968 | |
@@ -975,11 +974,11 @@ discard block |
||
| 975 | 974 | * @uses cron() |
| 976 | 975 | **/ |
| 977 | 976 | function action_cron() { |
| 978 | - include_spip('inc/headers'); |
|
| 979 | - http_status(204); // No Content |
|
| 980 | - header("Connection: close"); |
|
| 981 | - define('_DIRECT_CRON_FORCE', true); |
|
| 982 | - cron(); |
|
| 977 | + include_spip('inc/headers'); |
|
| 978 | + http_status(204); // No Content |
|
| 979 | + header("Connection: close"); |
|
| 980 | + define('_DIRECT_CRON_FORCE', true); |
|
| 981 | + cron(); |
|
| 983 | 982 | } |
| 984 | 983 | |
| 985 | 984 | /** |
@@ -995,26 +994,26 @@ discard block |
||
| 995 | 994 | * True si la tache a pu être effectuée |
| 996 | 995 | */ |
| 997 | 996 | function cron($taches = array(), $taches_old = array()) { |
| 998 | - // si pas en mode cron force, laisser tomber. |
|
| 999 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1000 | - return false; |
|
| 1001 | - } |
|
| 1002 | - if (!is_array($taches)) { |
|
| 1003 | - $taches = $taches_old; |
|
| 1004 | - } // compat anciens appels |
|
| 1005 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1006 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1007 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1008 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1009 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1010 | - return false; |
|
| 1011 | - } |
|
| 1012 | - spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1013 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1014 | - return $genie($taches); |
|
| 1015 | - } |
|
| 1016 | - |
|
| 1017 | - return false; |
|
| 997 | + // si pas en mode cron force, laisser tomber. |
|
| 998 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 999 | + return false; |
|
| 1000 | + } |
|
| 1001 | + if (!is_array($taches)) { |
|
| 1002 | + $taches = $taches_old; |
|
| 1003 | + } // compat anciens appels |
|
| 1004 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1005 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1006 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1007 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1008 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1009 | + return false; |
|
| 1010 | + } |
|
| 1011 | + spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1012 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1013 | + return $genie($taches); |
|
| 1014 | + } |
|
| 1015 | + |
|
| 1016 | + return false; |
|
| 1018 | 1017 | } |
| 1019 | 1018 | |
| 1020 | 1019 | /** |
@@ -1046,17 +1045,17 @@ discard block |
||
| 1046 | 1045 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1047 | 1046 | */ |
| 1048 | 1047 | function job_queue_add( |
| 1049 | - $function, |
|
| 1050 | - $description, |
|
| 1051 | - $arguments = array(), |
|
| 1052 | - $file = '', |
|
| 1053 | - $no_duplicate = false, |
|
| 1054 | - $time = 0, |
|
| 1055 | - $priority = 0 |
|
| 1048 | + $function, |
|
| 1049 | + $description, |
|
| 1050 | + $arguments = array(), |
|
| 1051 | + $file = '', |
|
| 1052 | + $no_duplicate = false, |
|
| 1053 | + $time = 0, |
|
| 1054 | + $priority = 0 |
|
| 1056 | 1055 | ) { |
| 1057 | - include_spip('inc/queue'); |
|
| 1056 | + include_spip('inc/queue'); |
|
| 1058 | 1057 | |
| 1059 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1058 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1060 | 1059 | } |
| 1061 | 1060 | |
| 1062 | 1061 | /** |
@@ -1067,9 +1066,9 @@ discard block |
||
| 1067 | 1066 | * @return bool |
| 1068 | 1067 | */ |
| 1069 | 1068 | function job_queue_remove($id_job) { |
| 1070 | - include_spip('inc/queue'); |
|
| 1069 | + include_spip('inc/queue'); |
|
| 1071 | 1070 | |
| 1072 | - return queue_remove_job($id_job); |
|
| 1071 | + return queue_remove_job($id_job); |
|
| 1073 | 1072 | } |
| 1074 | 1073 | |
| 1075 | 1074 | /** |
@@ -1082,9 +1081,9 @@ discard block |
||
| 1082 | 1081 | * or an array of simple array to link multiples objet in one time |
| 1083 | 1082 | */ |
| 1084 | 1083 | function job_queue_link($id_job, $objets) { |
| 1085 | - include_spip('inc/queue'); |
|
| 1084 | + include_spip('inc/queue'); |
|
| 1086 | 1085 | |
| 1087 | - return queue_link_job($id_job, $objets); |
|
| 1086 | + return queue_link_job($id_job, $objets); |
|
| 1088 | 1087 | } |
| 1089 | 1088 | |
| 1090 | 1089 | |
@@ -1104,36 +1103,36 @@ discard block |
||
| 1104 | 1103 | * - `null` si la queue n'est pas encore initialisée |
| 1105 | 1104 | */ |
| 1106 | 1105 | function queue_sleep_time_to_next_job($force = null) { |
| 1107 | - static $queue_next_job_time = -1; |
|
| 1108 | - if ($force === true) { |
|
| 1109 | - $queue_next_job_time = -1; |
|
| 1110 | - } elseif ($force) { |
|
| 1111 | - $queue_next_job_time = $force; |
|
| 1112 | - } |
|
| 1113 | - |
|
| 1114 | - if ($queue_next_job_time == -1) { |
|
| 1115 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1116 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1117 | - } |
|
| 1118 | - // utiliser un cache memoire si dispo |
|
| 1119 | - if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1120 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1121 | - } else { |
|
| 1122 | - $queue_next_job_time = null; |
|
| 1123 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1124 | - $queue_next_job_time = intval($contenu); |
|
| 1125 | - } |
|
| 1126 | - } |
|
| 1127 | - } |
|
| 1128 | - |
|
| 1129 | - if (is_null($queue_next_job_time)) { |
|
| 1130 | - return null; |
|
| 1131 | - } |
|
| 1132 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1133 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1134 | - } |
|
| 1135 | - |
|
| 1136 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1106 | + static $queue_next_job_time = -1; |
|
| 1107 | + if ($force === true) { |
|
| 1108 | + $queue_next_job_time = -1; |
|
| 1109 | + } elseif ($force) { |
|
| 1110 | + $queue_next_job_time = $force; |
|
| 1111 | + } |
|
| 1112 | + |
|
| 1113 | + if ($queue_next_job_time == -1) { |
|
| 1114 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1115 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1116 | + } |
|
| 1117 | + // utiliser un cache memoire si dispo |
|
| 1118 | + if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1119 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1120 | + } else { |
|
| 1121 | + $queue_next_job_time = null; |
|
| 1122 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1123 | + $queue_next_job_time = intval($contenu); |
|
| 1124 | + } |
|
| 1125 | + } |
|
| 1126 | + } |
|
| 1127 | + |
|
| 1128 | + if (is_null($queue_next_job_time)) { |
|
| 1129 | + return null; |
|
| 1130 | + } |
|
| 1131 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1132 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1137 | 1136 | } |
| 1138 | 1137 | |
| 1139 | 1138 | |
@@ -1145,9 +1144,9 @@ discard block |
||
| 1145 | 1144 | * @return string |
| 1146 | 1145 | */ |
| 1147 | 1146 | function quote_amp($u) { |
| 1148 | - return preg_replace( |
|
| 1149 | - "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1150 | - "&", $u); |
|
| 1147 | + return preg_replace( |
|
| 1148 | + "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1149 | + "&", $u); |
|
| 1151 | 1150 | } |
| 1152 | 1151 | |
| 1153 | 1152 | |
@@ -1170,27 +1169,27 @@ discard block |
||
| 1170 | 1169 | * Balise HTML `<script>` et son contenu |
| 1171 | 1170 | **/ |
| 1172 | 1171 | function http_script($script, $src = '', $noscript = '') { |
| 1173 | - static $done = array(); |
|
| 1172 | + static $done = array(); |
|
| 1174 | 1173 | |
| 1175 | - if ($src && !isset($done[$src])) { |
|
| 1176 | - $done[$src] = true; |
|
| 1177 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1178 | - $src = " src='$src'"; |
|
| 1179 | - } else { |
|
| 1180 | - $src = ''; |
|
| 1181 | - } |
|
| 1182 | - if ($script) { |
|
| 1183 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1184 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1185 | - "/*]]>*/"); |
|
| 1186 | - } |
|
| 1187 | - if ($noscript) { |
|
| 1188 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1189 | - } |
|
| 1174 | + if ($src && !isset($done[$src])) { |
|
| 1175 | + $done[$src] = true; |
|
| 1176 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1177 | + $src = " src='$src'"; |
|
| 1178 | + } else { |
|
| 1179 | + $src = ''; |
|
| 1180 | + } |
|
| 1181 | + if ($script) { |
|
| 1182 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1183 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1184 | + "/*]]>*/"); |
|
| 1185 | + } |
|
| 1186 | + if ($noscript) { |
|
| 1187 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1188 | + } |
|
| 1190 | 1189 | |
| 1191 | - return ($src or $script or $noscript) |
|
| 1192 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1193 | - : ''; |
|
| 1190 | + return ($src or $script or $noscript) |
|
| 1191 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1192 | + : ''; |
|
| 1194 | 1193 | } |
| 1195 | 1194 | |
| 1196 | 1195 | |
@@ -1225,7 +1224,7 @@ discard block |
||
| 1225 | 1224 | * Texte échappé |
| 1226 | 1225 | **/ |
| 1227 | 1226 | function texte_script($texte) { |
| 1228 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1227 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1229 | 1228 | } |
| 1230 | 1229 | |
| 1231 | 1230 | |
@@ -1262,69 +1261,69 @@ discard block |
||
| 1262 | 1261 | * Liste des chemins, par ordre de priorité. |
| 1263 | 1262 | **/ |
| 1264 | 1263 | function _chemin($dir_path = null) { |
| 1265 | - static $path_base = null; |
|
| 1266 | - static $path_full = null; |
|
| 1267 | - if ($path_base == null) { |
|
| 1268 | - // Chemin standard depuis l'espace public |
|
| 1269 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1270 | - _DIR_RACINE . ':' . |
|
| 1271 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1272 | - _DIR_RACINE . 'prive/:' . |
|
| 1273 | - _DIR_RESTREINT; |
|
| 1274 | - // Ajouter squelettes/ |
|
| 1275 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1276 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1277 | - } |
|
| 1278 | - foreach (explode(':', $path) as $dir) { |
|
| 1279 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1280 | - $dir .= "/"; |
|
| 1281 | - } |
|
| 1282 | - $path_base[] = $dir; |
|
| 1283 | - } |
|
| 1284 | - $path_full = $path_base; |
|
| 1285 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1286 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1287 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1288 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1289 | - } |
|
| 1290 | - } |
|
| 1291 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1292 | - } |
|
| 1293 | - if ($dir_path === null) { |
|
| 1294 | - return $path_full; |
|
| 1295 | - } |
|
| 1296 | - |
|
| 1297 | - if (strlen($dir_path)) { |
|
| 1298 | - $tete = ""; |
|
| 1299 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1300 | - $tete = array_shift($path_base); |
|
| 1301 | - } |
|
| 1302 | - $dirs = array_reverse(explode(':', $dir_path)); |
|
| 1303 | - foreach ($dirs as $dir_path) { |
|
| 1304 | - #if ($dir_path{0}!='/') |
|
| 1305 | - # $dir_path = $dir_path; |
|
| 1306 | - if (substr($dir_path, -1) != '/') { |
|
| 1307 | - $dir_path .= "/"; |
|
| 1308 | - } |
|
| 1309 | - if (!in_array($dir_path, $path_base)) { |
|
| 1310 | - array_unshift($path_base, $dir_path); |
|
| 1311 | - } |
|
| 1312 | - } |
|
| 1313 | - if (strlen($tete)) { |
|
| 1314 | - array_unshift($path_base, $tete); |
|
| 1315 | - } |
|
| 1316 | - } |
|
| 1317 | - $path_full = $path_base; |
|
| 1318 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1319 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1320 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1321 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1322 | - } |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1326 | - |
|
| 1327 | - return $path_full; |
|
| 1264 | + static $path_base = null; |
|
| 1265 | + static $path_full = null; |
|
| 1266 | + if ($path_base == null) { |
|
| 1267 | + // Chemin standard depuis l'espace public |
|
| 1268 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1269 | + _DIR_RACINE . ':' . |
|
| 1270 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1271 | + _DIR_RACINE . 'prive/:' . |
|
| 1272 | + _DIR_RESTREINT; |
|
| 1273 | + // Ajouter squelettes/ |
|
| 1274 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1275 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1276 | + } |
|
| 1277 | + foreach (explode(':', $path) as $dir) { |
|
| 1278 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1279 | + $dir .= "/"; |
|
| 1280 | + } |
|
| 1281 | + $path_base[] = $dir; |
|
| 1282 | + } |
|
| 1283 | + $path_full = $path_base; |
|
| 1284 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1285 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1286 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1287 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1288 | + } |
|
| 1289 | + } |
|
| 1290 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1291 | + } |
|
| 1292 | + if ($dir_path === null) { |
|
| 1293 | + return $path_full; |
|
| 1294 | + } |
|
| 1295 | + |
|
| 1296 | + if (strlen($dir_path)) { |
|
| 1297 | + $tete = ""; |
|
| 1298 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1299 | + $tete = array_shift($path_base); |
|
| 1300 | + } |
|
| 1301 | + $dirs = array_reverse(explode(':', $dir_path)); |
|
| 1302 | + foreach ($dirs as $dir_path) { |
|
| 1303 | + #if ($dir_path{0}!='/') |
|
| 1304 | + # $dir_path = $dir_path; |
|
| 1305 | + if (substr($dir_path, -1) != '/') { |
|
| 1306 | + $dir_path .= "/"; |
|
| 1307 | + } |
|
| 1308 | + if (!in_array($dir_path, $path_base)) { |
|
| 1309 | + array_unshift($path_base, $dir_path); |
|
| 1310 | + } |
|
| 1311 | + } |
|
| 1312 | + if (strlen($tete)) { |
|
| 1313 | + array_unshift($path_base, $tete); |
|
| 1314 | + } |
|
| 1315 | + } |
|
| 1316 | + $path_full = $path_base; |
|
| 1317 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1318 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1319 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1320 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1321 | + } |
|
| 1322 | + } |
|
| 1323 | + |
|
| 1324 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1325 | + |
|
| 1326 | + return $path_full; |
|
| 1328 | 1327 | } |
| 1329 | 1328 | |
| 1330 | 1329 | /** |
@@ -1337,63 +1336,63 @@ discard block |
||
| 1337 | 1336 | * @return array Liste de chemins |
| 1338 | 1337 | **/ |
| 1339 | 1338 | function creer_chemin() { |
| 1340 | - $path_a = _chemin(); |
|
| 1341 | - static $c = ''; |
|
| 1339 | + $path_a = _chemin(); |
|
| 1340 | + static $c = ''; |
|
| 1342 | 1341 | |
| 1343 | - // on calcule le chemin si le dossier skel a change |
|
| 1344 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1345 | - // assurer le non plantage lors de la montee de version : |
|
| 1346 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1347 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1348 | - } |
|
| 1342 | + // on calcule le chemin si le dossier skel a change |
|
| 1343 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1344 | + // assurer le non plantage lors de la montee de version : |
|
| 1345 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1346 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1347 | + } |
|
| 1349 | 1348 | |
| 1350 | - return $path_a; |
|
| 1349 | + return $path_a; |
|
| 1351 | 1350 | } |
| 1352 | 1351 | |
| 1353 | 1352 | |
| 1354 | 1353 | function lister_themes_prives() { |
| 1355 | - static $themes = null; |
|
| 1356 | - if (is_null($themes)) { |
|
| 1357 | - // si pas encore definie |
|
| 1358 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1359 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1360 | - } |
|
| 1361 | - $themes = array(_SPIP_THEME_PRIVE); |
|
| 1362 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1363 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1364 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1365 | - } else { |
|
| 1366 | - $prefs = array(); |
|
| 1367 | - } |
|
| 1368 | - if (is_string($prefs)) { |
|
| 1369 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1370 | - } |
|
| 1371 | - if ( |
|
| 1372 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1373 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1374 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1375 | - ) { |
|
| 1376 | - array_unshift($themes, $theme); |
|
| 1377 | - } // placer le theme choisi en tete |
|
| 1378 | - } |
|
| 1379 | - |
|
| 1380 | - return $themes; |
|
| 1354 | + static $themes = null; |
|
| 1355 | + if (is_null($themes)) { |
|
| 1356 | + // si pas encore definie |
|
| 1357 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1358 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1359 | + } |
|
| 1360 | + $themes = array(_SPIP_THEME_PRIVE); |
|
| 1361 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1362 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1363 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1364 | + } else { |
|
| 1365 | + $prefs = array(); |
|
| 1366 | + } |
|
| 1367 | + if (is_string($prefs)) { |
|
| 1368 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1369 | + } |
|
| 1370 | + if ( |
|
| 1371 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1372 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1373 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1374 | + ) { |
|
| 1375 | + array_unshift($themes, $theme); |
|
| 1376 | + } // placer le theme choisi en tete |
|
| 1377 | + } |
|
| 1378 | + |
|
| 1379 | + return $themes; |
|
| 1381 | 1380 | } |
| 1382 | 1381 | |
| 1383 | 1382 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1384 | - static $themefiles = array(); |
|
| 1385 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1386 | - return $themefiles["$subdir$file"]; |
|
| 1387 | - } |
|
| 1388 | - $themes = lister_themes_prives(); |
|
| 1389 | - foreach ($themes as $theme) { |
|
| 1390 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1391 | - return $themefiles["$subdir$file"] = $f; |
|
| 1392 | - } |
|
| 1393 | - } |
|
| 1394 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1383 | + static $themefiles = array(); |
|
| 1384 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1385 | + return $themefiles["$subdir$file"]; |
|
| 1386 | + } |
|
| 1387 | + $themes = lister_themes_prives(); |
|
| 1388 | + foreach ($themes as $theme) { |
|
| 1389 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1390 | + return $themefiles["$subdir$file"] = $f; |
|
| 1391 | + } |
|
| 1392 | + } |
|
| 1393 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1395 | 1394 | |
| 1396 | - return $themefiles["$subdir$file"] = ""; |
|
| 1395 | + return $themefiles["$subdir$file"] = ""; |
|
| 1397 | 1396 | } |
| 1398 | 1397 | |
| 1399 | 1398 | |
@@ -1417,28 +1416,28 @@ discard block |
||
| 1417 | 1416 | * sinon chaîne vide. |
| 1418 | 1417 | **/ |
| 1419 | 1418 | function chemin_image($icone) { |
| 1420 | - static $icone_renommer; |
|
| 1421 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1422 | - if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1423 | - return $icone; |
|
| 1424 | - } |
|
| 1425 | - |
|
| 1426 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1427 | - if (preg_match(',[.](png|gif|jpg|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1428 | - return $f; |
|
| 1429 | - } |
|
| 1430 | - // sinon passer par le module de renommage |
|
| 1431 | - if (is_null($icone_renommer)) { |
|
| 1432 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1433 | - } |
|
| 1434 | - if ($icone_renommer) { |
|
| 1435 | - list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1436 | - if (file_exists($icone)) { |
|
| 1437 | - return $icone; |
|
| 1438 | - } |
|
| 1439 | - } |
|
| 1440 | - |
|
| 1441 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1419 | + static $icone_renommer; |
|
| 1420 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1421 | + if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1422 | + return $icone; |
|
| 1423 | + } |
|
| 1424 | + |
|
| 1425 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1426 | + if (preg_match(',[.](png|gif|jpg|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1427 | + return $f; |
|
| 1428 | + } |
|
| 1429 | + // sinon passer par le module de renommage |
|
| 1430 | + if (is_null($icone_renommer)) { |
|
| 1431 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1432 | + } |
|
| 1433 | + if ($icone_renommer) { |
|
| 1434 | + list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1435 | + if (file_exists($icone)) { |
|
| 1436 | + return $icone; |
|
| 1437 | + } |
|
| 1438 | + } |
|
| 1439 | + |
|
| 1440 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1442 | 1441 | } |
| 1443 | 1442 | |
| 1444 | 1443 | // |
@@ -1476,123 +1475,123 @@ discard block |
||
| 1476 | 1475 | * - false : fichier introuvable |
| 1477 | 1476 | **/ |
| 1478 | 1477 | function find_in_path($file, $dirname = '', $include = false) { |
| 1479 | - static $dirs = array(); |
|
| 1480 | - static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743 |
|
| 1481 | - static $c = ''; |
|
| 1482 | - |
|
| 1483 | - // on calcule le chemin si le dossier skel a change |
|
| 1484 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1485 | - // assurer le non plantage lors de la montee de version : |
|
| 1486 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1487 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1488 | - } |
|
| 1489 | - |
|
| 1490 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1491 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1492 | - return false; |
|
| 1493 | - } |
|
| 1494 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1495 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1496 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1497 | - } |
|
| 1498 | - |
|
| 1499 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1500 | - } |
|
| 1501 | - |
|
| 1502 | - $a = strrpos($file, '/'); |
|
| 1503 | - if ($a !== false) { |
|
| 1504 | - $dirname .= substr($file, 0, ++$a); |
|
| 1505 | - $file = substr($file, $a); |
|
| 1506 | - } |
|
| 1507 | - |
|
| 1508 | - foreach (creer_chemin() as $dir) { |
|
| 1509 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1510 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1511 | - } |
|
| 1512 | - if ($dirs[$a]) { |
|
| 1513 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1514 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1515 | - include_once _ROOT_CWD . $a; |
|
| 1516 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1517 | - } |
|
| 1518 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1519 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1520 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1521 | - return $a; |
|
| 1522 | - } |
|
| 1523 | - define('_SAUVER_CHEMIN', true); |
|
| 1524 | - } |
|
| 1525 | - |
|
| 1526 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1527 | - } |
|
| 1528 | - } |
|
| 1529 | - } |
|
| 1530 | - |
|
| 1531 | - if ($include) { |
|
| 1532 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1533 | - if ($include === 'required') { |
|
| 1534 | - echo '<pre>', |
|
| 1535 | - "<strong>Erreur Fatale</strong><br />"; |
|
| 1536 | - if (function_exists('debug_print_backtrace')) { |
|
| 1537 | - echo debug_print_backtrace(); |
|
| 1538 | - } |
|
| 1539 | - echo '</pre>'; |
|
| 1540 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1541 | - } |
|
| 1542 | - } |
|
| 1543 | - |
|
| 1544 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1545 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1546 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1547 | - return false; |
|
| 1548 | - } |
|
| 1549 | - define('_SAUVER_CHEMIN', true); |
|
| 1550 | - } |
|
| 1551 | - |
|
| 1552 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1478 | + static $dirs = array(); |
|
| 1479 | + static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743 |
|
| 1480 | + static $c = ''; |
|
| 1481 | + |
|
| 1482 | + // on calcule le chemin si le dossier skel a change |
|
| 1483 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1484 | + // assurer le non plantage lors de la montee de version : |
|
| 1485 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1486 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1487 | + } |
|
| 1488 | + |
|
| 1489 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1490 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1491 | + return false; |
|
| 1492 | + } |
|
| 1493 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1494 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1495 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1496 | + } |
|
| 1497 | + |
|
| 1498 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1499 | + } |
|
| 1500 | + |
|
| 1501 | + $a = strrpos($file, '/'); |
|
| 1502 | + if ($a !== false) { |
|
| 1503 | + $dirname .= substr($file, 0, ++$a); |
|
| 1504 | + $file = substr($file, $a); |
|
| 1505 | + } |
|
| 1506 | + |
|
| 1507 | + foreach (creer_chemin() as $dir) { |
|
| 1508 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1509 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1510 | + } |
|
| 1511 | + if ($dirs[$a]) { |
|
| 1512 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1513 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1514 | + include_once _ROOT_CWD . $a; |
|
| 1515 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1516 | + } |
|
| 1517 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1518 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1519 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1520 | + return $a; |
|
| 1521 | + } |
|
| 1522 | + define('_SAUVER_CHEMIN', true); |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1526 | + } |
|
| 1527 | + } |
|
| 1528 | + } |
|
| 1529 | + |
|
| 1530 | + if ($include) { |
|
| 1531 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1532 | + if ($include === 'required') { |
|
| 1533 | + echo '<pre>', |
|
| 1534 | + "<strong>Erreur Fatale</strong><br />"; |
|
| 1535 | + if (function_exists('debug_print_backtrace')) { |
|
| 1536 | + echo debug_print_backtrace(); |
|
| 1537 | + } |
|
| 1538 | + echo '</pre>'; |
|
| 1539 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1540 | + } |
|
| 1541 | + } |
|
| 1542 | + |
|
| 1543 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1544 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1545 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1546 | + return false; |
|
| 1547 | + } |
|
| 1548 | + define('_SAUVER_CHEMIN', true); |
|
| 1549 | + } |
|
| 1550 | + |
|
| 1551 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1553 | 1552 | } |
| 1554 | 1553 | |
| 1555 | 1554 | function clear_path_cache() { |
| 1556 | - $GLOBALS['path_files'] = array(); |
|
| 1557 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1555 | + $GLOBALS['path_files'] = array(); |
|
| 1556 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1558 | 1557 | } |
| 1559 | 1558 | |
| 1560 | 1559 | function load_path_cache() { |
| 1561 | - // charger le path des plugins |
|
| 1562 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1563 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1564 | - } |
|
| 1565 | - $GLOBALS['path_files'] = array(); |
|
| 1566 | - // si le visiteur est admin, |
|
| 1567 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1568 | - if ( |
|
| 1569 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1570 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1571 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1572 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1573 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1574 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1575 | - !_request('var_mode') |
|
| 1576 | - ) { |
|
| 1577 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1578 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1579 | - // mais si semble corrompu on relit avec un verrou |
|
| 1580 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1581 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1582 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1583 | - $GLOBALS['path_files'] = array(); |
|
| 1584 | - } |
|
| 1585 | - } |
|
| 1586 | - } |
|
| 1587 | - } |
|
| 1560 | + // charger le path des plugins |
|
| 1561 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1562 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1563 | + } |
|
| 1564 | + $GLOBALS['path_files'] = array(); |
|
| 1565 | + // si le visiteur est admin, |
|
| 1566 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1567 | + if ( |
|
| 1568 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1569 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1570 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1571 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1572 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1573 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1574 | + !_request('var_mode') |
|
| 1575 | + ) { |
|
| 1576 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1577 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1578 | + // mais si semble corrompu on relit avec un verrou |
|
| 1579 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1580 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1581 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1582 | + $GLOBALS['path_files'] = array(); |
|
| 1583 | + } |
|
| 1584 | + } |
|
| 1585 | + } |
|
| 1586 | + } |
|
| 1588 | 1587 | } |
| 1589 | 1588 | |
| 1590 | 1589 | function save_path_cache() { |
| 1591 | - if (defined('_SAUVER_CHEMIN') |
|
| 1592 | - and _SAUVER_CHEMIN |
|
| 1593 | - ) { |
|
| 1594 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1595 | - } |
|
| 1590 | + if (defined('_SAUVER_CHEMIN') |
|
| 1591 | + and _SAUVER_CHEMIN |
|
| 1592 | + ) { |
|
| 1593 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1594 | + } |
|
| 1596 | 1595 | } |
| 1597 | 1596 | |
| 1598 | 1597 | |
@@ -1612,33 +1611,33 @@ discard block |
||
| 1612 | 1611 | * @return array |
| 1613 | 1612 | */ |
| 1614 | 1613 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1615 | - $liste_fichiers = array(); |
|
| 1616 | - $maxfiles = 10000; |
|
| 1617 | - |
|
| 1618 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1619 | - // on a pas encore inclus flock.php |
|
| 1620 | - if (!function_exists('preg_files')) { |
|
| 1621 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1622 | - } |
|
| 1623 | - |
|
| 1624 | - // Parcourir le chemin |
|
| 1625 | - foreach (creer_chemin() as $d) { |
|
| 1626 | - $f = $d . $dir; |
|
| 1627 | - if (@is_dir($f)) { |
|
| 1628 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1629 | - foreach ($liste as $chemin) { |
|
| 1630 | - $nom = basename($chemin); |
|
| 1631 | - // ne prendre que les fichiers pas deja trouves |
|
| 1632 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1633 | - // les autres sont donc masques |
|
| 1634 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1635 | - $liste_fichiers[$nom] = $chemin; |
|
| 1636 | - } |
|
| 1637 | - } |
|
| 1638 | - } |
|
| 1639 | - } |
|
| 1640 | - |
|
| 1641 | - return $liste_fichiers; |
|
| 1614 | + $liste_fichiers = array(); |
|
| 1615 | + $maxfiles = 10000; |
|
| 1616 | + |
|
| 1617 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1618 | + // on a pas encore inclus flock.php |
|
| 1619 | + if (!function_exists('preg_files')) { |
|
| 1620 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1621 | + } |
|
| 1622 | + |
|
| 1623 | + // Parcourir le chemin |
|
| 1624 | + foreach (creer_chemin() as $d) { |
|
| 1625 | + $f = $d . $dir; |
|
| 1626 | + if (@is_dir($f)) { |
|
| 1627 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1628 | + foreach ($liste as $chemin) { |
|
| 1629 | + $nom = basename($chemin); |
|
| 1630 | + // ne prendre que les fichiers pas deja trouves |
|
| 1631 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1632 | + // les autres sont donc masques |
|
| 1633 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1634 | + $liste_fichiers[$nom] = $chemin; |
|
| 1635 | + } |
|
| 1636 | + } |
|
| 1637 | + } |
|
| 1638 | + } |
|
| 1639 | + |
|
| 1640 | + return $liste_fichiers; |
|
| 1642 | 1641 | } |
| 1643 | 1642 | |
| 1644 | 1643 | /** |
@@ -1650,17 +1649,17 @@ discard block |
||
| 1650 | 1649 | * @return bool |
| 1651 | 1650 | */ |
| 1652 | 1651 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1653 | - static $autsanscookie = array('install', 'base_repair'); |
|
| 1652 | + static $autsanscookie = array('install', 'base_repair'); |
|
| 1654 | 1653 | |
| 1655 | - if (in_array($nom, $autsanscookie)) { |
|
| 1656 | - if (test_espace_prive()){ |
|
| 1657 | - include_spip('base/connect_sql'); |
|
| 1658 | - if (!$strict or !spip_connect()){ |
|
| 1659 | - return true; |
|
| 1660 | - } |
|
| 1661 | - } |
|
| 1662 | - } |
|
| 1663 | - return false; |
|
| 1654 | + if (in_array($nom, $autsanscookie)) { |
|
| 1655 | + if (test_espace_prive()){ |
|
| 1656 | + include_spip('base/connect_sql'); |
|
| 1657 | + if (!$strict or !spip_connect()){ |
|
| 1658 | + return true; |
|
| 1659 | + } |
|
| 1660 | + } |
|
| 1661 | + } |
|
| 1662 | + return false; |
|
| 1664 | 1663 | } |
| 1665 | 1664 | |
| 1666 | 1665 | /** |
@@ -1686,99 +1685,99 @@ discard block |
||
| 1686 | 1685 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip) |
| 1687 | 1686 | */ |
| 1688 | 1687 | function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1689 | - if ($public === null) { |
|
| 1690 | - $public = !test_espace_prive(); |
|
| 1691 | - } |
|
| 1692 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1693 | - |
|
| 1694 | - if (!$public) { |
|
| 1695 | - if (!$entite) { |
|
| 1696 | - return ''; |
|
| 1697 | - } |
|
| 1698 | - if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1699 | - include_spip('inc/urls'); |
|
| 1700 | - } |
|
| 1701 | - $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1702 | - } else { |
|
| 1703 | - if ($type === null) { |
|
| 1704 | - $type = (isset($GLOBALS['type_urls'])) |
|
| 1705 | - ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1706 | - : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1707 | - ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1708 | - } |
|
| 1709 | - |
|
| 1710 | - $f = charger_fonction($type, 'urls', true); |
|
| 1711 | - // se rabattre sur les urls page si les urls perso non dispo |
|
| 1712 | - if (!$f) { |
|
| 1713 | - $f = charger_fonction('page', 'urls', true); |
|
| 1714 | - } |
|
| 1715 | - |
|
| 1716 | - // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1717 | - // sinon on veut effectuer le passage id ==> URL |
|
| 1718 | - if (!$entite) { |
|
| 1719 | - return $f; |
|
| 1720 | - } |
|
| 1721 | - |
|
| 1722 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1723 | - // base distante |
|
| 1724 | - if (is_string($public) |
|
| 1725 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1726 | - ) { |
|
| 1727 | - $f = $g; |
|
| 1728 | - } |
|
| 1729 | - |
|
| 1730 | - $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1731 | - |
|
| 1732 | - } |
|
| 1733 | - if ($res) { |
|
| 1734 | - return $res; |
|
| 1735 | - } |
|
| 1736 | - // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1737 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1738 | - if (!function_exists($f .= '_dist')) { |
|
| 1739 | - $f = ''; |
|
| 1740 | - } |
|
| 1741 | - } |
|
| 1742 | - if ($f) { |
|
| 1743 | - $url = $f($id, $args, $ancre); |
|
| 1744 | - if (strlen($args)) { |
|
| 1745 | - $url .= strstr($url, '?') |
|
| 1746 | - ? '&' . $args |
|
| 1747 | - : '?' . $args; |
|
| 1748 | - } |
|
| 1749 | - |
|
| 1750 | - return $url; |
|
| 1751 | - } |
|
| 1752 | - // On a ete gentil mais la .... |
|
| 1753 | - spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1754 | - |
|
| 1755 | - return ''; |
|
| 1688 | + if ($public === null) { |
|
| 1689 | + $public = !test_espace_prive(); |
|
| 1690 | + } |
|
| 1691 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1692 | + |
|
| 1693 | + if (!$public) { |
|
| 1694 | + if (!$entite) { |
|
| 1695 | + return ''; |
|
| 1696 | + } |
|
| 1697 | + if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1698 | + include_spip('inc/urls'); |
|
| 1699 | + } |
|
| 1700 | + $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1701 | + } else { |
|
| 1702 | + if ($type === null) { |
|
| 1703 | + $type = (isset($GLOBALS['type_urls'])) |
|
| 1704 | + ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1705 | + : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1706 | + ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1707 | + } |
|
| 1708 | + |
|
| 1709 | + $f = charger_fonction($type, 'urls', true); |
|
| 1710 | + // se rabattre sur les urls page si les urls perso non dispo |
|
| 1711 | + if (!$f) { |
|
| 1712 | + $f = charger_fonction('page', 'urls', true); |
|
| 1713 | + } |
|
| 1714 | + |
|
| 1715 | + // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1716 | + // sinon on veut effectuer le passage id ==> URL |
|
| 1717 | + if (!$entite) { |
|
| 1718 | + return $f; |
|
| 1719 | + } |
|
| 1720 | + |
|
| 1721 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1722 | + // base distante |
|
| 1723 | + if (is_string($public) |
|
| 1724 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1725 | + ) { |
|
| 1726 | + $f = $g; |
|
| 1727 | + } |
|
| 1728 | + |
|
| 1729 | + $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1730 | + |
|
| 1731 | + } |
|
| 1732 | + if ($res) { |
|
| 1733 | + return $res; |
|
| 1734 | + } |
|
| 1735 | + // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1736 | + if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1737 | + if (!function_exists($f .= '_dist')) { |
|
| 1738 | + $f = ''; |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1741 | + if ($f) { |
|
| 1742 | + $url = $f($id, $args, $ancre); |
|
| 1743 | + if (strlen($args)) { |
|
| 1744 | + $url .= strstr($url, '?') |
|
| 1745 | + ? '&' . $args |
|
| 1746 | + : '?' . $args; |
|
| 1747 | + } |
|
| 1748 | + |
|
| 1749 | + return $url; |
|
| 1750 | + } |
|
| 1751 | + // On a ete gentil mais la .... |
|
| 1752 | + spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1753 | + |
|
| 1754 | + return ''; |
|
| 1756 | 1755 | } |
| 1757 | 1756 | |
| 1758 | 1757 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 1759 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1760 | - $url = generer_url_ecrire($exec, $args); |
|
| 1761 | - if (intval($id)) { |
|
| 1762 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1763 | - } else { |
|
| 1764 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1765 | - } |
|
| 1766 | - if ($ancre) { |
|
| 1767 | - $url = ancre_url($url, $ancre); |
|
| 1768 | - } |
|
| 1758 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1759 | + $url = generer_url_ecrire($exec, $args); |
|
| 1760 | + if (intval($id)) { |
|
| 1761 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1762 | + } else { |
|
| 1763 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1764 | + } |
|
| 1765 | + if ($ancre) { |
|
| 1766 | + $url = ancre_url($url, $ancre); |
|
| 1767 | + } |
|
| 1769 | 1768 | |
| 1770 | - return $url; |
|
| 1769 | + return $url; |
|
| 1771 | 1770 | } |
| 1772 | 1771 | |
| 1773 | 1772 | // http://code.spip.net/@urls_connect_dist |
| 1774 | 1773 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1775 | - include_spip('base/connect_sql'); |
|
| 1776 | - $id_type = id_table_objet($entite, $public); |
|
| 1774 | + include_spip('base/connect_sql'); |
|
| 1775 | + $id_type = id_table_objet($entite, $public); |
|
| 1777 | 1776 | |
| 1778 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1779 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1780 | - . (!$args ? '' : "&$args") |
|
| 1781 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1777 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1778 | + . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1779 | + . (!$args ? '' : "&$args") |
|
| 1780 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1782 | 1781 | } |
| 1783 | 1782 | |
| 1784 | 1783 | |
@@ -1789,32 +1788,32 @@ discard block |
||
| 1789 | 1788 | * @return string |
| 1790 | 1789 | */ |
| 1791 | 1790 | function urlencode_1738($url) { |
| 1792 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1793 | - $uri = ''; |
|
| 1794 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1795 | - if (ord($a = $url[$i]) > 127) { |
|
| 1796 | - $a = rawurlencode($a); |
|
| 1797 | - } |
|
| 1798 | - $uri .= $a; |
|
| 1799 | - } |
|
| 1800 | - $url = $uri; |
|
| 1801 | - } |
|
| 1791 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1792 | + $uri = ''; |
|
| 1793 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1794 | + if (ord($a = $url[$i]) > 127) { |
|
| 1795 | + $a = rawurlencode($a); |
|
| 1796 | + } |
|
| 1797 | + $uri .= $a; |
|
| 1798 | + } |
|
| 1799 | + $url = $uri; |
|
| 1800 | + } |
|
| 1802 | 1801 | |
| 1803 | - return quote_amp($url); |
|
| 1802 | + return quote_amp($url); |
|
| 1804 | 1803 | } |
| 1805 | 1804 | |
| 1806 | 1805 | // http://code.spip.net/@generer_url_entite_absolue |
| 1807 | 1806 | function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { |
| 1808 | - if (!$connect) { |
|
| 1809 | - $connect = true; |
|
| 1810 | - } |
|
| 1811 | - $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1812 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1813 | - include_spip('inc/filtres_mini'); |
|
| 1814 | - $h = url_absolue($h); |
|
| 1815 | - } |
|
| 1807 | + if (!$connect) { |
|
| 1808 | + $connect = true; |
|
| 1809 | + } |
|
| 1810 | + $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1811 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1812 | + include_spip('inc/filtres_mini'); |
|
| 1813 | + $h = url_absolue($h); |
|
| 1814 | + } |
|
| 1816 | 1815 | |
| 1817 | - return $h; |
|
| 1816 | + return $h; |
|
| 1818 | 1817 | } |
| 1819 | 1818 | |
| 1820 | 1819 | |
@@ -1830,11 +1829,11 @@ discard block |
||
| 1830 | 1829 | * true si la valeur est considérée active ; false sinon. |
| 1831 | 1830 | **/ |
| 1832 | 1831 | function test_valeur_serveur($truc) { |
| 1833 | - if (!$truc) { |
|
| 1834 | - return false; |
|
| 1835 | - } |
|
| 1832 | + if (!$truc) { |
|
| 1833 | + return false; |
|
| 1834 | + } |
|
| 1836 | 1835 | |
| 1837 | - return (strtolower($truc) !== 'off'); |
|
| 1836 | + return (strtolower($truc) !== 'off'); |
|
| 1838 | 1837 | } |
| 1839 | 1838 | |
| 1840 | 1839 | // |
@@ -1862,80 +1861,80 @@ discard block |
||
| 1862 | 1861 | */ |
| 1863 | 1862 | function url_de_base($profondeur = null) { |
| 1864 | 1863 | |
| 1865 | - static $url = array(); |
|
| 1866 | - if (is_array($profondeur)) { |
|
| 1867 | - return $url = $profondeur; |
|
| 1868 | - } |
|
| 1869 | - if ($profondeur === false) { |
|
| 1870 | - return $url; |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - if (is_null($profondeur)) { |
|
| 1874 | - $profondeur = $GLOBALS['profondeur_url']; |
|
| 1875 | - } |
|
| 1876 | - |
|
| 1877 | - if (isset($url[$profondeur])) { |
|
| 1878 | - return $url[$profondeur]; |
|
| 1879 | - } |
|
| 1880 | - |
|
| 1881 | - $http = 'http'; |
|
| 1882 | - |
|
| 1883 | - if ( |
|
| 1884 | - isset($_SERVER["SCRIPT_URI"]) |
|
| 1885 | - and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1886 | - ) { |
|
| 1887 | - $http = 'https'; |
|
| 1888 | - } elseif ( |
|
| 1889 | - isset($_SERVER['HTTPS']) |
|
| 1890 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1891 | - ) { |
|
| 1892 | - $http = 'https'; |
|
| 1893 | - } |
|
| 1894 | - |
|
| 1895 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 1896 | - $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1897 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1898 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1899 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 1900 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1901 | - $http = $scheme; |
|
| 1902 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 1903 | - } |
|
| 1904 | - } |
|
| 1905 | - if (isset($_SERVER['SERVER_PORT']) |
|
| 1906 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 1907 | - and strpos($host, ":") == false |
|
| 1908 | - ) { |
|
| 1909 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1910 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 1911 | - } |
|
| 1912 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 1913 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 1914 | - } |
|
| 1915 | - if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 1916 | - $host .= ":$port"; |
|
| 1917 | - } |
|
| 1918 | - if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 1919 | - $host .= ":$port"; |
|
| 1920 | - } |
|
| 1921 | - } |
|
| 1922 | - |
|
| 1923 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 1924 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 1925 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 1926 | - } else { |
|
| 1927 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 1928 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 1929 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 1930 | - ) { |
|
| 1931 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 1932 | - } |
|
| 1933 | - } |
|
| 1934 | - } |
|
| 1935 | - |
|
| 1936 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 1937 | - |
|
| 1938 | - return $url[$profondeur]; |
|
| 1864 | + static $url = array(); |
|
| 1865 | + if (is_array($profondeur)) { |
|
| 1866 | + return $url = $profondeur; |
|
| 1867 | + } |
|
| 1868 | + if ($profondeur === false) { |
|
| 1869 | + return $url; |
|
| 1870 | + } |
|
| 1871 | + |
|
| 1872 | + if (is_null($profondeur)) { |
|
| 1873 | + $profondeur = $GLOBALS['profondeur_url']; |
|
| 1874 | + } |
|
| 1875 | + |
|
| 1876 | + if (isset($url[$profondeur])) { |
|
| 1877 | + return $url[$profondeur]; |
|
| 1878 | + } |
|
| 1879 | + |
|
| 1880 | + $http = 'http'; |
|
| 1881 | + |
|
| 1882 | + if ( |
|
| 1883 | + isset($_SERVER["SCRIPT_URI"]) |
|
| 1884 | + and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1885 | + ) { |
|
| 1886 | + $http = 'https'; |
|
| 1887 | + } elseif ( |
|
| 1888 | + isset($_SERVER['HTTPS']) |
|
| 1889 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1890 | + ) { |
|
| 1891 | + $http = 'https'; |
|
| 1892 | + } |
|
| 1893 | + |
|
| 1894 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 1895 | + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1896 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1897 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1898 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 1899 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1900 | + $http = $scheme; |
|
| 1901 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 1902 | + } |
|
| 1903 | + } |
|
| 1904 | + if (isset($_SERVER['SERVER_PORT']) |
|
| 1905 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 1906 | + and strpos($host, ":") == false |
|
| 1907 | + ) { |
|
| 1908 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1909 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 1910 | + } |
|
| 1911 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 1912 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 1913 | + } |
|
| 1914 | + if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 1915 | + $host .= ":$port"; |
|
| 1916 | + } |
|
| 1917 | + if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 1918 | + $host .= ":$port"; |
|
| 1919 | + } |
|
| 1920 | + } |
|
| 1921 | + |
|
| 1922 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 1923 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 1924 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 1925 | + } else { |
|
| 1926 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 1927 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 1928 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 1929 | + ) { |
|
| 1930 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 1931 | + } |
|
| 1932 | + } |
|
| 1933 | + } |
|
| 1934 | + |
|
| 1935 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 1936 | + |
|
| 1937 | + return $url[$profondeur]; |
|
| 1939 | 1938 | } |
| 1940 | 1939 | |
| 1941 | 1940 | /** |
@@ -1948,26 +1947,26 @@ discard block |
||
| 1948 | 1947 | * @return string |
| 1949 | 1948 | */ |
| 1950 | 1949 | function url_de_($http, $host, $request, $prof = 0) { |
| 1951 | - $prof = max($prof, 0); |
|
| 1950 | + $prof = max($prof, 0); |
|
| 1952 | 1951 | |
| 1953 | - $myself = ltrim($request, '/'); |
|
| 1954 | - # supprimer la chaine de GET |
|
| 1955 | - list($myself) = explode('?', $myself); |
|
| 1956 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 1957 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 1958 | - if (strpos($myself,'://') !== false) { |
|
| 1959 | - $myself = explode('://',$myself); |
|
| 1960 | - array_shift($myself); |
|
| 1961 | - $myself = implode('://',$myself); |
|
| 1962 | - $myself = explode('/',$myself); |
|
| 1963 | - array_shift($myself); |
|
| 1964 | - $myself = implode('/',$myself); |
|
| 1965 | - } |
|
| 1966 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 1952 | + $myself = ltrim($request, '/'); |
|
| 1953 | + # supprimer la chaine de GET |
|
| 1954 | + list($myself) = explode('?', $myself); |
|
| 1955 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 1956 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 1957 | + if (strpos($myself,'://') !== false) { |
|
| 1958 | + $myself = explode('://',$myself); |
|
| 1959 | + array_shift($myself); |
|
| 1960 | + $myself = implode('://',$myself); |
|
| 1961 | + $myself = explode('/',$myself); |
|
| 1962 | + array_shift($myself); |
|
| 1963 | + $myself = implode('/',$myself); |
|
| 1964 | + } |
|
| 1965 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 1967 | 1966 | |
| 1968 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 1967 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 1969 | 1968 | |
| 1970 | - return $url; |
|
| 1969 | + return $url; |
|
| 1971 | 1970 | } |
| 1972 | 1971 | |
| 1973 | 1972 | |
@@ -2002,26 +2001,26 @@ discard block |
||
| 2002 | 2001 | * @return string URL |
| 2003 | 2002 | **/ |
| 2004 | 2003 | function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
| 2005 | - if (!$rel) { |
|
| 2006 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2007 | - } else { |
|
| 2008 | - if (!is_string($rel)) { |
|
| 2009 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2010 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2011 | - } |
|
| 2012 | - } |
|
| 2013 | - |
|
| 2014 | - list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2015 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2016 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2017 | - } elseif ($args) { |
|
| 2018 | - $args = "?$args"; |
|
| 2019 | - } |
|
| 2020 | - if ($ancre) { |
|
| 2021 | - $args .= "#$ancre"; |
|
| 2022 | - } |
|
| 2023 | - |
|
| 2024 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2004 | + if (!$rel) { |
|
| 2005 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2006 | + } else { |
|
| 2007 | + if (!is_string($rel)) { |
|
| 2008 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2009 | + ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2010 | + } |
|
| 2011 | + } |
|
| 2012 | + |
|
| 2013 | + list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2014 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2015 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2016 | + } elseif ($args) { |
|
| 2017 | + $args = "?$args"; |
|
| 2018 | + } |
|
| 2019 | + if ($ancre) { |
|
| 2020 | + $args .= "#$ancre"; |
|
| 2021 | + } |
|
| 2022 | + |
|
| 2023 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2025 | 2024 | } |
| 2026 | 2025 | |
| 2027 | 2026 | // |
@@ -2043,12 +2042,12 @@ discard block |
||
| 2043 | 2042 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2044 | 2043 | **/ |
| 2045 | 2044 | function get_spip_script($default = '') { |
| 2046 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2047 | - if (_SPIP_SCRIPT) { |
|
| 2048 | - return _SPIP_SCRIPT; |
|
| 2049 | - } else { |
|
| 2050 | - return $default; |
|
| 2051 | - } |
|
| 2045 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2046 | + if (_SPIP_SCRIPT) { |
|
| 2047 | + return _SPIP_SCRIPT; |
|
| 2048 | + } else { |
|
| 2049 | + return $default; |
|
| 2050 | + } |
|
| 2052 | 2051 | } |
| 2053 | 2052 | |
| 2054 | 2053 | /** |
@@ -2077,39 +2076,39 @@ discard block |
||
| 2077 | 2076 | * @return string URL |
| 2078 | 2077 | **/ |
| 2079 | 2078 | function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') { |
| 2080 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2081 | - // standardiser vers la nouvelle API |
|
| 2082 | - |
|
| 2083 | - if (!$action) { |
|
| 2084 | - $action = get_spip_script(); |
|
| 2085 | - } |
|
| 2086 | - if ($script) { |
|
| 2087 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2088 | - } |
|
| 2089 | - |
|
| 2090 | - if ($args) { |
|
| 2091 | - if (is_array($args)) { |
|
| 2092 | - $r = ''; |
|
| 2093 | - foreach ($args as $k => $v) { |
|
| 2094 | - $r .= '&' . $k . '=' . $v; |
|
| 2095 | - } |
|
| 2096 | - $args = substr($r, 1); |
|
| 2097 | - } |
|
| 2098 | - $action .= |
|
| 2099 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2100 | - } |
|
| 2101 | - if (!$no_entities) { |
|
| 2102 | - $action = quote_amp($action); |
|
| 2103 | - } |
|
| 2104 | - |
|
| 2105 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2106 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2079 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2080 | + // standardiser vers la nouvelle API |
|
| 2081 | + |
|
| 2082 | + if (!$action) { |
|
| 2083 | + $action = get_spip_script(); |
|
| 2084 | + } |
|
| 2085 | + if ($script) { |
|
| 2086 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2087 | + } |
|
| 2088 | + |
|
| 2089 | + if ($args) { |
|
| 2090 | + if (is_array($args)) { |
|
| 2091 | + $r = ''; |
|
| 2092 | + foreach ($args as $k => $v) { |
|
| 2093 | + $r .= '&' . $k . '=' . $v; |
|
| 2094 | + } |
|
| 2095 | + $args = substr($r, 1); |
|
| 2096 | + } |
|
| 2097 | + $action .= |
|
| 2098 | + (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2099 | + } |
|
| 2100 | + if (!$no_entities) { |
|
| 2101 | + $action = quote_amp($action); |
|
| 2102 | + } |
|
| 2103 | + |
|
| 2104 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2105 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2107 | 2106 | } |
| 2108 | 2107 | |
| 2109 | 2108 | // http://code.spip.net/@generer_url_prive |
| 2110 | 2109 | function generer_url_prive($script, $args = "", $no_entities = false) { |
| 2111 | 2110 | |
| 2112 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2111 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2113 | 2112 | } |
| 2114 | 2113 | |
| 2115 | 2114 | // Pour les formulaires en methode POST, |
@@ -2134,19 +2133,19 @@ discard block |
||
| 2134 | 2133 | **/ |
| 2135 | 2134 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2136 | 2135 | |
| 2137 | - $script1 = explode('&', $script); |
|
| 2138 | - $script1 = reset($script1); |
|
| 2136 | + $script1 = explode('&', $script); |
|
| 2137 | + $script1 = reset($script1); |
|
| 2139 | 2138 | |
| 2140 | - return "<form action='" |
|
| 2141 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2142 | - . "' " |
|
| 2143 | - . ($atts ? $atts : " method='post'") |
|
| 2144 | - . "><div>\n" |
|
| 2145 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2146 | - . $corps |
|
| 2147 | - . (!$submit ? '' : |
|
| 2148 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2149 | - . "</div></form>\n"; |
|
| 2139 | + return "<form action='" |
|
| 2140 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2141 | + . "' " |
|
| 2142 | + . ($atts ? $atts : " method='post'") |
|
| 2143 | + . "><div>\n" |
|
| 2144 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2145 | + . $corps |
|
| 2146 | + . (!$submit ? '' : |
|
| 2147 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2148 | + . "</div></form>\n"; |
|
| 2150 | 2149 | } |
| 2151 | 2150 | |
| 2152 | 2151 | /** |
@@ -2163,22 +2162,22 @@ discard block |
||
| 2163 | 2162 | * @return string |
| 2164 | 2163 | */ |
| 2165 | 2164 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2166 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2167 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2168 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2169 | - $h = (_DIR_RACINE and !$public) |
|
| 2170 | - ? generer_url_ecrire(_request('exec')) |
|
| 2171 | - : generer_url_public(); |
|
| 2165 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2166 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2167 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2168 | + $h = (_DIR_RACINE and !$public) |
|
| 2169 | + ? generer_url_ecrire(_request('exec')) |
|
| 2170 | + : generer_url_public(); |
|
| 2172 | 2171 | |
| 2173 | - return "\n<form action='" . |
|
| 2174 | - $h . |
|
| 2175 | - "'" . |
|
| 2176 | - $atts . |
|
| 2177 | - ">\n" . |
|
| 2178 | - "<div>" . |
|
| 2179 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2180 | - $corps . |
|
| 2181 | - "</div></form>"; |
|
| 2172 | + return "\n<form action='" . |
|
| 2173 | + $h . |
|
| 2174 | + "'" . |
|
| 2175 | + $atts . |
|
| 2176 | + ">\n" . |
|
| 2177 | + "<div>" . |
|
| 2178 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2179 | + $corps . |
|
| 2180 | + "</div></form>"; |
|
| 2182 | 2181 | } |
| 2183 | 2182 | |
| 2184 | 2183 | /** |
@@ -2197,22 +2196,22 @@ discard block |
||
| 2197 | 2196 | * URL |
| 2198 | 2197 | */ |
| 2199 | 2198 | function generer_url_action($script, $args = "", $no_entities = false, $public = false) { |
| 2200 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2201 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2202 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2203 | - $url = (_DIR_RACINE and !$public) |
|
| 2204 | - ? generer_url_ecrire(_request('exec')) |
|
| 2205 | - : generer_url_public('', '', false, false); |
|
| 2206 | - $url = parametre_url($url, 'action', $script); |
|
| 2207 | - if ($args) { |
|
| 2208 | - $url .= quote_amp('&' . $args); |
|
| 2209 | - } |
|
| 2199 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2200 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2201 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2202 | + $url = (_DIR_RACINE and !$public) |
|
| 2203 | + ? generer_url_ecrire(_request('exec')) |
|
| 2204 | + : generer_url_public('', '', false, false); |
|
| 2205 | + $url = parametre_url($url, 'action', $script); |
|
| 2206 | + if ($args) { |
|
| 2207 | + $url .= quote_amp('&' . $args); |
|
| 2208 | + } |
|
| 2210 | 2209 | |
| 2211 | - if ($no_entities) { |
|
| 2212 | - $url = str_replace('&', '&', $url); |
|
| 2213 | - } |
|
| 2210 | + if ($no_entities) { |
|
| 2211 | + $url = str_replace('&', '&', $url); |
|
| 2212 | + } |
|
| 2214 | 2213 | |
| 2215 | - return $url; |
|
| 2214 | + return $url; |
|
| 2216 | 2215 | } |
| 2217 | 2216 | |
| 2218 | 2217 | |
@@ -2225,8 +2224,8 @@ discard block |
||
| 2225 | 2224 | * @param string $ta Répertoire temporaire accessible |
| 2226 | 2225 | */ |
| 2227 | 2226 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2228 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2229 | - spip_initialisation_suite(); |
|
| 2227 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2228 | + spip_initialisation_suite(); |
|
| 2230 | 2229 | } |
| 2231 | 2230 | |
| 2232 | 2231 | /** |
@@ -2246,315 +2245,315 @@ discard block |
||
| 2246 | 2245 | * @param string $ta Répertoire temporaire accessible |
| 2247 | 2246 | */ |
| 2248 | 2247 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2249 | - static $too_late = 0; |
|
| 2250 | - if ($too_late++) { |
|
| 2251 | - return; |
|
| 2252 | - } |
|
| 2253 | - |
|
| 2254 | - // Declaration des repertoires |
|
| 2255 | - |
|
| 2256 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2257 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2258 | - define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2259 | - } |
|
| 2260 | - |
|
| 2261 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2262 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2263 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2264 | - } |
|
| 2265 | - |
|
| 2266 | - // le nom du repertoire des librairies |
|
| 2267 | - if (!defined('_DIR_LIB')) { |
|
| 2268 | - define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2269 | - } |
|
| 2270 | - |
|
| 2271 | - if (!defined('_DIR_IMG')) { |
|
| 2272 | - define('_DIR_IMG', $pa); |
|
| 2273 | - } |
|
| 2274 | - if (!defined('_DIR_LOGOS')) { |
|
| 2275 | - define('_DIR_LOGOS', $pa); |
|
| 2276 | - } |
|
| 2277 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2278 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2279 | - } |
|
| 2280 | - |
|
| 2281 | - if (!defined('_DIR_DUMP')) { |
|
| 2282 | - define('_DIR_DUMP', $ti . "dump/"); |
|
| 2283 | - } |
|
| 2284 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2285 | - define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2286 | - } |
|
| 2287 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2288 | - define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2289 | - } |
|
| 2290 | - if (!defined('_DIR_CACHE')) { |
|
| 2291 | - define('_DIR_CACHE', $ti . "cache/"); |
|
| 2292 | - } |
|
| 2293 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2294 | - define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2295 | - } |
|
| 2296 | - if (!defined('_DIR_SKELS')) { |
|
| 2297 | - define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2298 | - } |
|
| 2299 | - if (!defined('_DIR_AIDE')) { |
|
| 2300 | - define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2301 | - } |
|
| 2302 | - if (!defined('_DIR_TMP')) { |
|
| 2303 | - define('_DIR_TMP', $ti); |
|
| 2304 | - } |
|
| 2305 | - |
|
| 2306 | - if (!defined('_DIR_VAR')) { |
|
| 2307 | - define('_DIR_VAR', $ta); |
|
| 2308 | - } |
|
| 2309 | - |
|
| 2310 | - if (!defined('_DIR_ETC')) { |
|
| 2311 | - define('_DIR_ETC', $pi); |
|
| 2312 | - } |
|
| 2313 | - if (!defined('_DIR_CONNECT')) { |
|
| 2314 | - define('_DIR_CONNECT', $pi); |
|
| 2315 | - } |
|
| 2316 | - if (!defined('_DIR_CHMOD')) { |
|
| 2317 | - define('_DIR_CHMOD', $pi); |
|
| 2318 | - } |
|
| 2319 | - |
|
| 2320 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 2321 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2322 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2323 | - { |
|
| 2324 | - $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2325 | - } |
|
| 2326 | - |
|
| 2327 | - // Declaration des fichiers |
|
| 2328 | - |
|
| 2329 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2330 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2331 | - } |
|
| 2332 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2333 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2334 | - } |
|
| 2335 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2336 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2337 | - } |
|
| 2338 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2339 | - define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2340 | - } |
|
| 2341 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2342 | - define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2343 | - } |
|
| 2344 | - |
|
| 2345 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2346 | - if (!defined('_FILE_META')) { |
|
| 2347 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2348 | - } |
|
| 2349 | - if (!defined('_DIR_LOG')) { |
|
| 2350 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2351 | - } |
|
| 2352 | - if (!defined('_FILE_LOG')) { |
|
| 2353 | - define('_FILE_LOG', 'spip'); |
|
| 2354 | - } |
|
| 2355 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2356 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2357 | - } |
|
| 2358 | - |
|
| 2359 | - // Le fichier de connexion a la base de donnees |
|
| 2360 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2361 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2362 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2363 | - } |
|
| 2364 | - if (!defined('_FILE_CONNECT')) { |
|
| 2365 | - define('_FILE_CONNECT', |
|
| 2366 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2367 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2368 | - : false))); |
|
| 2369 | - } |
|
| 2370 | - |
|
| 2371 | - // Le fichier de reglages des droits |
|
| 2372 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2373 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2374 | - } |
|
| 2375 | - if (!defined('_FILE_CHMOD')) { |
|
| 2376 | - define('_FILE_CHMOD', |
|
| 2377 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2378 | - : false)); |
|
| 2379 | - } |
|
| 2380 | - |
|
| 2381 | - if (!defined('_FILE_LDAP')) { |
|
| 2382 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2383 | - } |
|
| 2384 | - |
|
| 2385 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2386 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2387 | - } |
|
| 2388 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2389 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2390 | - } |
|
| 2391 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2392 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2393 | - } |
|
| 2394 | - |
|
| 2395 | - // Definition des droits d'acces en ecriture |
|
| 2396 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2397 | - include_once _FILE_CHMOD; |
|
| 2398 | - } |
|
| 2399 | - |
|
| 2400 | - // Se mefier des fichiers mal remplis! |
|
| 2401 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2402 | - define('_SPIP_CHMOD', 0777); |
|
| 2403 | - } |
|
| 2404 | - |
|
| 2405 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2406 | - /** Le charset par défaut lors de l'installation */ |
|
| 2407 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2408 | - } |
|
| 2409 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2410 | - define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2411 | - } |
|
| 2412 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2413 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2414 | - } |
|
| 2415 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2416 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2417 | - } |
|
| 2418 | - |
|
| 2419 | - // La taille des Log |
|
| 2420 | - if (!defined('_MAX_LOG')) { |
|
| 2421 | - define('_MAX_LOG', 100); |
|
| 2422 | - } |
|
| 2423 | - |
|
| 2424 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2425 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2426 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2427 | - if (!defined('_OS_SERVEUR')) { |
|
| 2428 | - define('_OS_SERVEUR', 'windows'); |
|
| 2429 | - } |
|
| 2430 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2431 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2432 | - } // utiliser le flock php |
|
| 2433 | - } else { |
|
| 2434 | - if (!defined('_OS_SERVEUR')) { |
|
| 2435 | - define('_OS_SERVEUR', ''); |
|
| 2436 | - } |
|
| 2437 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2438 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2439 | - } // utiliser le flock php |
|
| 2440 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2441 | - } |
|
| 2442 | - |
|
| 2443 | - // Langue par defaut |
|
| 2444 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2445 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2446 | - } |
|
| 2447 | - |
|
| 2448 | - // |
|
| 2449 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2450 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2451 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2452 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2453 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2454 | - |
|
| 2455 | - // charger tout de suite le path et son cache |
|
| 2456 | - load_path_cache(); |
|
| 2457 | - |
|
| 2458 | - // *********** traiter les variables ************ |
|
| 2459 | - |
|
| 2460 | - // |
|
| 2461 | - // Securite |
|
| 2462 | - // |
|
| 2463 | - |
|
| 2464 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2465 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2466 | - die(); |
|
| 2467 | - } |
|
| 2468 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2469 | - spip_desinfecte($_GET); |
|
| 2470 | - spip_desinfecte($_POST); |
|
| 2471 | - spip_desinfecte($_COOKIE); |
|
| 2472 | - spip_desinfecte($_REQUEST); |
|
| 2473 | - |
|
| 2474 | - // appliquer le cookie_prefix |
|
| 2475 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2476 | - include_spip('inc/cookie'); |
|
| 2477 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2478 | - } |
|
| 2479 | - |
|
| 2480 | - // |
|
| 2481 | - // Capacites php (en fonction de la version) |
|
| 2482 | - // |
|
| 2483 | - $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2484 | - && function_exists("ini_get") |
|
| 2485 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2486 | - $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2487 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2488 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2489 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2490 | - |
|
| 2491 | - |
|
| 2492 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2493 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2494 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2495 | - } else { |
|
| 2496 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2497 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 2498 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2499 | - ) { |
|
| 2500 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2501 | - } |
|
| 2502 | - } |
|
| 2503 | - |
|
| 2504 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2505 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2506 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2507 | - } |
|
| 2508 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2509 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2510 | - } |
|
| 2511 | - |
|
| 2512 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2513 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2514 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2515 | - $inc_meta(); |
|
| 2516 | - |
|
| 2517 | - // nombre de repertoires depuis la racine |
|
| 2518 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2519 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2520 | - // le calcul est faux) |
|
| 2521 | - if (!_DIR_RESTREINT) { |
|
| 2522 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2523 | - } else { |
|
| 2524 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2525 | - $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2526 | - if (!$uri_ref |
|
| 2527 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2528 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2529 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2530 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2531 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2532 | - ) { |
|
| 2533 | - |
|
| 2534 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2535 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2536 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2537 | - } else { |
|
| 2538 | - $uri_ref = ""; |
|
| 2539 | - } |
|
| 2540 | - } |
|
| 2541 | - if (!$uri or !$uri_ref) { |
|
| 2542 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2543 | - } else { |
|
| 2544 | - $GLOBALS['profondeur_url'] = max(0, |
|
| 2545 | - substr_count($uri[0], '/') |
|
| 2546 | - - substr_count($uri_ref, '/')); |
|
| 2547 | - } |
|
| 2548 | - } |
|
| 2549 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2550 | - if (_FILE_CONNECT) { |
|
| 2551 | - if (verifier_visiteur() == '0minirezo' |
|
| 2552 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2553 | - and !isset($_COOKIE['spip_admin']) |
|
| 2554 | - ) { |
|
| 2555 | - clear_path_cache(); |
|
| 2556 | - } |
|
| 2557 | - } |
|
| 2248 | + static $too_late = 0; |
|
| 2249 | + if ($too_late++) { |
|
| 2250 | + return; |
|
| 2251 | + } |
|
| 2252 | + |
|
| 2253 | + // Declaration des repertoires |
|
| 2254 | + |
|
| 2255 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2256 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2257 | + define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2258 | + } |
|
| 2259 | + |
|
| 2260 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2261 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2262 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2263 | + } |
|
| 2264 | + |
|
| 2265 | + // le nom du repertoire des librairies |
|
| 2266 | + if (!defined('_DIR_LIB')) { |
|
| 2267 | + define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2268 | + } |
|
| 2269 | + |
|
| 2270 | + if (!defined('_DIR_IMG')) { |
|
| 2271 | + define('_DIR_IMG', $pa); |
|
| 2272 | + } |
|
| 2273 | + if (!defined('_DIR_LOGOS')) { |
|
| 2274 | + define('_DIR_LOGOS', $pa); |
|
| 2275 | + } |
|
| 2276 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2277 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2278 | + } |
|
| 2279 | + |
|
| 2280 | + if (!defined('_DIR_DUMP')) { |
|
| 2281 | + define('_DIR_DUMP', $ti . "dump/"); |
|
| 2282 | + } |
|
| 2283 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2284 | + define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2285 | + } |
|
| 2286 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2287 | + define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2288 | + } |
|
| 2289 | + if (!defined('_DIR_CACHE')) { |
|
| 2290 | + define('_DIR_CACHE', $ti . "cache/"); |
|
| 2291 | + } |
|
| 2292 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2293 | + define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2294 | + } |
|
| 2295 | + if (!defined('_DIR_SKELS')) { |
|
| 2296 | + define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2297 | + } |
|
| 2298 | + if (!defined('_DIR_AIDE')) { |
|
| 2299 | + define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2300 | + } |
|
| 2301 | + if (!defined('_DIR_TMP')) { |
|
| 2302 | + define('_DIR_TMP', $ti); |
|
| 2303 | + } |
|
| 2304 | + |
|
| 2305 | + if (!defined('_DIR_VAR')) { |
|
| 2306 | + define('_DIR_VAR', $ta); |
|
| 2307 | + } |
|
| 2308 | + |
|
| 2309 | + if (!defined('_DIR_ETC')) { |
|
| 2310 | + define('_DIR_ETC', $pi); |
|
| 2311 | + } |
|
| 2312 | + if (!defined('_DIR_CONNECT')) { |
|
| 2313 | + define('_DIR_CONNECT', $pi); |
|
| 2314 | + } |
|
| 2315 | + if (!defined('_DIR_CHMOD')) { |
|
| 2316 | + define('_DIR_CHMOD', $pi); |
|
| 2317 | + } |
|
| 2318 | + |
|
| 2319 | + if (!isset($GLOBALS['test_dirs'])) |
|
| 2320 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2321 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2322 | + { |
|
| 2323 | + $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2324 | + } |
|
| 2325 | + |
|
| 2326 | + // Declaration des fichiers |
|
| 2327 | + |
|
| 2328 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2329 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2330 | + } |
|
| 2331 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2332 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2333 | + } |
|
| 2334 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2335 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2336 | + } |
|
| 2337 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2338 | + define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2339 | + } |
|
| 2340 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2341 | + define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2342 | + } |
|
| 2343 | + |
|
| 2344 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2345 | + if (!defined('_FILE_META')) { |
|
| 2346 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2347 | + } |
|
| 2348 | + if (!defined('_DIR_LOG')) { |
|
| 2349 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2350 | + } |
|
| 2351 | + if (!defined('_FILE_LOG')) { |
|
| 2352 | + define('_FILE_LOG', 'spip'); |
|
| 2353 | + } |
|
| 2354 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2355 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2356 | + } |
|
| 2357 | + |
|
| 2358 | + // Le fichier de connexion a la base de donnees |
|
| 2359 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2360 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2361 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2362 | + } |
|
| 2363 | + if (!defined('_FILE_CONNECT')) { |
|
| 2364 | + define('_FILE_CONNECT', |
|
| 2365 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2366 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2367 | + : false))); |
|
| 2368 | + } |
|
| 2369 | + |
|
| 2370 | + // Le fichier de reglages des droits |
|
| 2371 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2372 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2373 | + } |
|
| 2374 | + if (!defined('_FILE_CHMOD')) { |
|
| 2375 | + define('_FILE_CHMOD', |
|
| 2376 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2377 | + : false)); |
|
| 2378 | + } |
|
| 2379 | + |
|
| 2380 | + if (!defined('_FILE_LDAP')) { |
|
| 2381 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2382 | + } |
|
| 2383 | + |
|
| 2384 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2385 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2386 | + } |
|
| 2387 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2388 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2389 | + } |
|
| 2390 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2391 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2392 | + } |
|
| 2393 | + |
|
| 2394 | + // Definition des droits d'acces en ecriture |
|
| 2395 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2396 | + include_once _FILE_CHMOD; |
|
| 2397 | + } |
|
| 2398 | + |
|
| 2399 | + // Se mefier des fichiers mal remplis! |
|
| 2400 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2401 | + define('_SPIP_CHMOD', 0777); |
|
| 2402 | + } |
|
| 2403 | + |
|
| 2404 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2405 | + /** Le charset par défaut lors de l'installation */ |
|
| 2406 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2407 | + } |
|
| 2408 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2409 | + define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2410 | + } |
|
| 2411 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2412 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2413 | + } |
|
| 2414 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2415 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2416 | + } |
|
| 2417 | + |
|
| 2418 | + // La taille des Log |
|
| 2419 | + if (!defined('_MAX_LOG')) { |
|
| 2420 | + define('_MAX_LOG', 100); |
|
| 2421 | + } |
|
| 2422 | + |
|
| 2423 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2424 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2425 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2426 | + if (!defined('_OS_SERVEUR')) { |
|
| 2427 | + define('_OS_SERVEUR', 'windows'); |
|
| 2428 | + } |
|
| 2429 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2430 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2431 | + } // utiliser le flock php |
|
| 2432 | + } else { |
|
| 2433 | + if (!defined('_OS_SERVEUR')) { |
|
| 2434 | + define('_OS_SERVEUR', ''); |
|
| 2435 | + } |
|
| 2436 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2437 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2438 | + } // utiliser le flock php |
|
| 2439 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2440 | + } |
|
| 2441 | + |
|
| 2442 | + // Langue par defaut |
|
| 2443 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2444 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2445 | + } |
|
| 2446 | + |
|
| 2447 | + // |
|
| 2448 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2449 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2450 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2451 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2452 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2453 | + |
|
| 2454 | + // charger tout de suite le path et son cache |
|
| 2455 | + load_path_cache(); |
|
| 2456 | + |
|
| 2457 | + // *********** traiter les variables ************ |
|
| 2458 | + |
|
| 2459 | + // |
|
| 2460 | + // Securite |
|
| 2461 | + // |
|
| 2462 | + |
|
| 2463 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2464 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2465 | + die(); |
|
| 2466 | + } |
|
| 2467 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2468 | + spip_desinfecte($_GET); |
|
| 2469 | + spip_desinfecte($_POST); |
|
| 2470 | + spip_desinfecte($_COOKIE); |
|
| 2471 | + spip_desinfecte($_REQUEST); |
|
| 2472 | + |
|
| 2473 | + // appliquer le cookie_prefix |
|
| 2474 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2475 | + include_spip('inc/cookie'); |
|
| 2476 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2477 | + } |
|
| 2478 | + |
|
| 2479 | + // |
|
| 2480 | + // Capacites php (en fonction de la version) |
|
| 2481 | + // |
|
| 2482 | + $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2483 | + && function_exists("ini_get") |
|
| 2484 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2485 | + $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2486 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2487 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2488 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2489 | + |
|
| 2490 | + |
|
| 2491 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2492 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2493 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2494 | + } else { |
|
| 2495 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2496 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 2497 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2498 | + ) { |
|
| 2499 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2500 | + } |
|
| 2501 | + } |
|
| 2502 | + |
|
| 2503 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2504 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2505 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2506 | + } |
|
| 2507 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2508 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2509 | + } |
|
| 2510 | + |
|
| 2511 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2512 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2513 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2514 | + $inc_meta(); |
|
| 2515 | + |
|
| 2516 | + // nombre de repertoires depuis la racine |
|
| 2517 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2518 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2519 | + // le calcul est faux) |
|
| 2520 | + if (!_DIR_RESTREINT) { |
|
| 2521 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2522 | + } else { |
|
| 2523 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2524 | + $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2525 | + if (!$uri_ref |
|
| 2526 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2527 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2528 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2529 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2530 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2531 | + ) { |
|
| 2532 | + |
|
| 2533 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2534 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2535 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2536 | + } else { |
|
| 2537 | + $uri_ref = ""; |
|
| 2538 | + } |
|
| 2539 | + } |
|
| 2540 | + if (!$uri or !$uri_ref) { |
|
| 2541 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2542 | + } else { |
|
| 2543 | + $GLOBALS['profondeur_url'] = max(0, |
|
| 2544 | + substr_count($uri[0], '/') |
|
| 2545 | + - substr_count($uri_ref, '/')); |
|
| 2546 | + } |
|
| 2547 | + } |
|
| 2548 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2549 | + if (_FILE_CONNECT) { |
|
| 2550 | + if (verifier_visiteur() == '0minirezo' |
|
| 2551 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2552 | + and !isset($_COOKIE['spip_admin']) |
|
| 2553 | + ) { |
|
| 2554 | + clear_path_cache(); |
|
| 2555 | + } |
|
| 2556 | + } |
|
| 2558 | 2557 | |
| 2559 | 2558 | } |
| 2560 | 2559 | |
@@ -2564,174 +2563,174 @@ discard block |
||
| 2564 | 2563 | * |
| 2565 | 2564 | */ |
| 2566 | 2565 | function spip_initialisation_suite() { |
| 2567 | - static $too_late = 0; |
|
| 2568 | - if ($too_late++) { |
|
| 2569 | - return; |
|
| 2570 | - } |
|
| 2571 | - |
|
| 2572 | - // taille mini des login |
|
| 2573 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2574 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2575 | - } |
|
| 2576 | - |
|
| 2577 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2578 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2579 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2580 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2581 | - |
|
| 2582 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2583 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2584 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2585 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2586 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2587 | - |
|
| 2588 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2589 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2590 | - } |
|
| 2591 | - |
|
| 2592 | - |
|
| 2593 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2594 | - if (!defined('_IMG_QUALITE')) { |
|
| 2595 | - define('_IMG_QUALITE', 85); |
|
| 2596 | - } # valeur par defaut |
|
| 2597 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2598 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2599 | - } # surcharge pour la lib GD |
|
| 2600 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2601 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2602 | - } # surcharge pour imagick en ligne de commande |
|
| 2603 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2604 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2605 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2606 | - } # surcharge pour imagick en PHP |
|
| 2607 | - |
|
| 2608 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2609 | - define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2610 | - } // poids en octet |
|
| 2611 | - |
|
| 2612 | - // qq chaines standard |
|
| 2613 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2614 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2615 | - } |
|
| 2616 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2617 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2618 | - } |
|
| 2619 | - if (!defined('_SPIP_DUMP')) { |
|
| 2620 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2621 | - } |
|
| 2622 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2623 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2624 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2625 | - } |
|
| 2626 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2627 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2628 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2629 | - } |
|
| 2630 | - |
|
| 2631 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2632 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2633 | - } |
|
| 2634 | - |
|
| 2635 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2636 | - /** Définit le doctype de l’espace privé */ |
|
| 2637 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2638 | - } |
|
| 2639 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2640 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2641 | - define('_DOCTYPE_AIDE', |
|
| 2642 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2643 | - } |
|
| 2644 | - |
|
| 2645 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2646 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2647 | - * le script de l'espace public, alias index.php */ |
|
| 2648 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2649 | - } |
|
| 2650 | - if (!defined('_SPIP_PAGE')) { |
|
| 2651 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2652 | - define('_SPIP_PAGE', 'page'); |
|
| 2653 | - } |
|
| 2654 | - |
|
| 2655 | - // le script de l'espace prive |
|
| 2656 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2657 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2658 | - // meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html |
|
| 2659 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2660 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2661 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2662 | - } else { |
|
| 2663 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2664 | - } |
|
| 2665 | - } |
|
| 2666 | - |
|
| 2667 | - |
|
| 2668 | - if (!defined('_SPIP_AJAX')) { |
|
| 2669 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2670 | - ? 1 |
|
| 2671 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2672 | - } |
|
| 2673 | - |
|
| 2674 | - // La requete est-elle en ajax ? |
|
| 2675 | - if (!defined('_AJAX')) { |
|
| 2676 | - define('_AJAX', |
|
| 2677 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2678 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2679 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2680 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2681 | - ) |
|
| 2682 | - and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2683 | - ); |
|
| 2684 | - } |
|
| 2685 | - |
|
| 2686 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2687 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2688 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2689 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2690 | - define('_IMG_GD_MAX_PIXELS', |
|
| 2691 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2692 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2693 | - : 0); |
|
| 2694 | - } |
|
| 2695 | - |
|
| 2696 | - if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2697 | - define('_MEMORY_LIMIT_MIN', 16); |
|
| 2698 | - } // en Mo |
|
| 2699 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2700 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2701 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2702 | - if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2703 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2704 | - $unit = strtolower(substr($memory, -1)); |
|
| 2705 | - $memory = substr($memory, 0, -1); |
|
| 2706 | - switch ($unit) { |
|
| 2707 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2708 | - case 'g': |
|
| 2709 | - $memory *= 1024; |
|
| 2710 | - case 'm': |
|
| 2711 | - $memory *= 1024; |
|
| 2712 | - case 'k': |
|
| 2713 | - $memory *= 1024; |
|
| 2714 | - } |
|
| 2715 | - if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2716 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2717 | - if (trim(ini_get('memory_limit')) != $m) { |
|
| 2718 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2719 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2720 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2721 | - } |
|
| 2722 | - } |
|
| 2723 | - } else { |
|
| 2724 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2725 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2726 | - } |
|
| 2727 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2728 | - } |
|
| 2729 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2730 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2731 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2732 | - } |
|
| 2733 | - |
|
| 2734 | - init_var_mode(); |
|
| 2566 | + static $too_late = 0; |
|
| 2567 | + if ($too_late++) { |
|
| 2568 | + return; |
|
| 2569 | + } |
|
| 2570 | + |
|
| 2571 | + // taille mini des login |
|
| 2572 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2573 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2574 | + } |
|
| 2575 | + |
|
| 2576 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2577 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2578 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2579 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2580 | + |
|
| 2581 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2582 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2583 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2584 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2585 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2586 | + |
|
| 2587 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2588 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2589 | + } |
|
| 2590 | + |
|
| 2591 | + |
|
| 2592 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2593 | + if (!defined('_IMG_QUALITE')) { |
|
| 2594 | + define('_IMG_QUALITE', 85); |
|
| 2595 | + } # valeur par defaut |
|
| 2596 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2597 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2598 | + } # surcharge pour la lib GD |
|
| 2599 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2600 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2601 | + } # surcharge pour imagick en ligne de commande |
|
| 2602 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2603 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2604 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2605 | + } # surcharge pour imagick en PHP |
|
| 2606 | + |
|
| 2607 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2608 | + define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2609 | + } // poids en octet |
|
| 2610 | + |
|
| 2611 | + // qq chaines standard |
|
| 2612 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2613 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2614 | + } |
|
| 2615 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2616 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2617 | + } |
|
| 2618 | + if (!defined('_SPIP_DUMP')) { |
|
| 2619 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2620 | + } |
|
| 2621 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2622 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2623 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2624 | + } |
|
| 2625 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2626 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2627 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2628 | + } |
|
| 2629 | + |
|
| 2630 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2631 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2632 | + } |
|
| 2633 | + |
|
| 2634 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2635 | + /** Définit le doctype de l’espace privé */ |
|
| 2636 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2637 | + } |
|
| 2638 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2639 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2640 | + define('_DOCTYPE_AIDE', |
|
| 2641 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2642 | + } |
|
| 2643 | + |
|
| 2644 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2645 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2646 | + * le script de l'espace public, alias index.php */ |
|
| 2647 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2648 | + } |
|
| 2649 | + if (!defined('_SPIP_PAGE')) { |
|
| 2650 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2651 | + define('_SPIP_PAGE', 'page'); |
|
| 2652 | + } |
|
| 2653 | + |
|
| 2654 | + // le script de l'espace prive |
|
| 2655 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2656 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2657 | + // meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html |
|
| 2658 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2659 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2660 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2661 | + } else { |
|
| 2662 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2663 | + } |
|
| 2664 | + } |
|
| 2665 | + |
|
| 2666 | + |
|
| 2667 | + if (!defined('_SPIP_AJAX')) { |
|
| 2668 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2669 | + ? 1 |
|
| 2670 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2671 | + } |
|
| 2672 | + |
|
| 2673 | + // La requete est-elle en ajax ? |
|
| 2674 | + if (!defined('_AJAX')) { |
|
| 2675 | + define('_AJAX', |
|
| 2676 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2677 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2678 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2679 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2680 | + ) |
|
| 2681 | + and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2682 | + ); |
|
| 2683 | + } |
|
| 2684 | + |
|
| 2685 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2686 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2687 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2688 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2689 | + define('_IMG_GD_MAX_PIXELS', |
|
| 2690 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2691 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2692 | + : 0); |
|
| 2693 | + } |
|
| 2694 | + |
|
| 2695 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2696 | + define('_MEMORY_LIMIT_MIN', 16); |
|
| 2697 | + } // en Mo |
|
| 2698 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2699 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2700 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2701 | + if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2702 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2703 | + $unit = strtolower(substr($memory, -1)); |
|
| 2704 | + $memory = substr($memory, 0, -1); |
|
| 2705 | + switch ($unit) { |
|
| 2706 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2707 | + case 'g': |
|
| 2708 | + $memory *= 1024; |
|
| 2709 | + case 'm': |
|
| 2710 | + $memory *= 1024; |
|
| 2711 | + case 'k': |
|
| 2712 | + $memory *= 1024; |
|
| 2713 | + } |
|
| 2714 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2715 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2716 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 2717 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2718 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2719 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2720 | + } |
|
| 2721 | + } |
|
| 2722 | + } else { |
|
| 2723 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2724 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2725 | + } |
|
| 2726 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2727 | + } |
|
| 2728 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2729 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2730 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2731 | + } |
|
| 2732 | + |
|
| 2733 | + init_var_mode(); |
|
| 2735 | 2734 | } |
| 2736 | 2735 | |
| 2737 | 2736 | /** |
@@ -2765,129 +2764,129 @@ discard block |
||
| 2765 | 2764 | * ` var_mode` (calcul ou recalcul). |
| 2766 | 2765 | */ |
| 2767 | 2766 | function init_var_mode() { |
| 2768 | - static $done = false; |
|
| 2769 | - if (!$done) { |
|
| 2770 | - |
|
| 2771 | - if (isset($_GET['var_mode'])) { |
|
| 2772 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 2773 | - // tout le monde peut calcul/recalcul |
|
| 2774 | - if (!defined('_VAR_MODE')) { |
|
| 2775 | - if (in_array('recalcul', $var_mode)) { |
|
| 2776 | - define('_VAR_MODE', 'recalcul'); |
|
| 2777 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 2778 | - define('_VAR_MODE', 'calcul'); |
|
| 2779 | - } |
|
| 2780 | - } |
|
| 2781 | - $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2782 | - if ($var_mode) { |
|
| 2783 | - include_spip('inc/autoriser'); |
|
| 2784 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2785 | - if (autoriser( |
|
| 2786 | - ($_GET['var_mode'] == 'preview') |
|
| 2787 | - ? 'previsualiser' |
|
| 2788 | - : 'debug' |
|
| 2789 | - )) { |
|
| 2790 | - if (in_array('traduction', $var_mode)) { |
|
| 2791 | - // forcer le calcul pour passer dans traduire |
|
| 2792 | - if (!defined('_VAR_MODE')) { |
|
| 2793 | - define('_VAR_MODE', 'calcul'); |
|
| 2794 | - } |
|
| 2795 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2796 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2797 | - define('_VAR_NOCACHE', true); |
|
| 2798 | - } |
|
| 2799 | - $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2800 | - } |
|
| 2801 | - if (in_array('preview', $var_mode)) { |
|
| 2802 | - // basculer sur les criteres de preview dans les boucles |
|
| 2803 | - if (!defined('_VAR_PREVIEW')) { |
|
| 2804 | - define('_VAR_PREVIEW', true); |
|
| 2805 | - } |
|
| 2806 | - // forcer le calcul |
|
| 2807 | - if (!defined('_VAR_MODE')) { |
|
| 2808 | - define('_VAR_MODE', 'calcul'); |
|
| 2809 | - } |
|
| 2810 | - // et ne pas enregistrer de cache |
|
| 2811 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2812 | - define('_VAR_NOCACHE', true); |
|
| 2813 | - } |
|
| 2814 | - $var_mode = array_diff($var_mode, array('preview')); |
|
| 2815 | - } |
|
| 2816 | - if (in_array('inclure', $var_mode)) { |
|
| 2817 | - // forcer le compilo et ignorer les caches existants |
|
| 2818 | - if (!defined('_VAR_MODE')) { |
|
| 2819 | - define('_VAR_MODE', 'calcul'); |
|
| 2820 | - } |
|
| 2821 | - if (!defined('_VAR_INCLURE')) { |
|
| 2822 | - define('_VAR_INCLURE', true); |
|
| 2823 | - } |
|
| 2824 | - // et ne pas enregistrer de cache |
|
| 2825 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2826 | - define('_VAR_NOCACHE', true); |
|
| 2827 | - } |
|
| 2828 | - $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2829 | - } |
|
| 2830 | - if (in_array('urls', $var_mode)) { |
|
| 2831 | - // forcer le compilo et ignorer les caches existants |
|
| 2832 | - if (!defined('_VAR_MODE')) { |
|
| 2833 | - define('_VAR_MODE', 'calcul'); |
|
| 2834 | - } |
|
| 2835 | - if (!defined('_VAR_URLS')) { |
|
| 2836 | - define('_VAR_URLS', true); |
|
| 2837 | - } |
|
| 2838 | - $var_mode = array_diff($var_mode, array('urls')); |
|
| 2839 | - } |
|
| 2840 | - if (in_array('images', $var_mode)) { |
|
| 2841 | - // forcer le compilo et ignorer les caches existants |
|
| 2842 | - if (!defined('_VAR_MODE')) { |
|
| 2843 | - define('_VAR_MODE', 'calcul'); |
|
| 2844 | - } |
|
| 2845 | - // indiquer qu'on doit recalculer les images |
|
| 2846 | - if (!defined('_VAR_IMAGES')) { |
|
| 2847 | - define('_VAR_IMAGES', true); |
|
| 2848 | - } |
|
| 2849 | - $var_mode = array_diff($var_mode, array('images')); |
|
| 2850 | - } |
|
| 2851 | - if (in_array('debug', $var_mode)) { |
|
| 2852 | - if (!defined('_VAR_MODE')) { |
|
| 2853 | - define('_VAR_MODE', 'debug'); |
|
| 2854 | - } |
|
| 2855 | - // et ne pas enregistrer de cache |
|
| 2856 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2857 | - define('_VAR_NOCACHE', true); |
|
| 2858 | - } |
|
| 2859 | - $var_mode = array_diff($var_mode, array('debug')); |
|
| 2860 | - } |
|
| 2861 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2862 | - define('_VAR_MODE', reset($var_mode)); |
|
| 2863 | - } |
|
| 2864 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2865 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2866 | - . " " . _VAR_MODE); |
|
| 2867 | - } |
|
| 2868 | - } // pas autorise ? |
|
| 2869 | - else { |
|
| 2870 | - // si on n'est pas connecte on se redirige |
|
| 2871 | - if (!$GLOBALS['visiteur_session']) { |
|
| 2872 | - include_spip('inc/headers'); |
|
| 2873 | - redirige_par_entete(generer_url_public('login', |
|
| 2874 | - 'url=' . rawurlencode( |
|
| 2875 | - parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
|
| 2876 | - ), true)); |
|
| 2877 | - } |
|
| 2878 | - // sinon tant pis |
|
| 2879 | - } |
|
| 2880 | - } |
|
| 2881 | - } |
|
| 2882 | - if (!defined('_VAR_MODE')) { |
|
| 2883 | - /** |
|
| 2884 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 2885 | - * @see init_var_mode() |
|
| 2886 | - */ |
|
| 2887 | - define('_VAR_MODE', false); |
|
| 2888 | - } |
|
| 2889 | - $done = true; |
|
| 2890 | - } |
|
| 2767 | + static $done = false; |
|
| 2768 | + if (!$done) { |
|
| 2769 | + |
|
| 2770 | + if (isset($_GET['var_mode'])) { |
|
| 2771 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 2772 | + // tout le monde peut calcul/recalcul |
|
| 2773 | + if (!defined('_VAR_MODE')) { |
|
| 2774 | + if (in_array('recalcul', $var_mode)) { |
|
| 2775 | + define('_VAR_MODE', 'recalcul'); |
|
| 2776 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 2777 | + define('_VAR_MODE', 'calcul'); |
|
| 2778 | + } |
|
| 2779 | + } |
|
| 2780 | + $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2781 | + if ($var_mode) { |
|
| 2782 | + include_spip('inc/autoriser'); |
|
| 2783 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2784 | + if (autoriser( |
|
| 2785 | + ($_GET['var_mode'] == 'preview') |
|
| 2786 | + ? 'previsualiser' |
|
| 2787 | + : 'debug' |
|
| 2788 | + )) { |
|
| 2789 | + if (in_array('traduction', $var_mode)) { |
|
| 2790 | + // forcer le calcul pour passer dans traduire |
|
| 2791 | + if (!defined('_VAR_MODE')) { |
|
| 2792 | + define('_VAR_MODE', 'calcul'); |
|
| 2793 | + } |
|
| 2794 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2795 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2796 | + define('_VAR_NOCACHE', true); |
|
| 2797 | + } |
|
| 2798 | + $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2799 | + } |
|
| 2800 | + if (in_array('preview', $var_mode)) { |
|
| 2801 | + // basculer sur les criteres de preview dans les boucles |
|
| 2802 | + if (!defined('_VAR_PREVIEW')) { |
|
| 2803 | + define('_VAR_PREVIEW', true); |
|
| 2804 | + } |
|
| 2805 | + // forcer le calcul |
|
| 2806 | + if (!defined('_VAR_MODE')) { |
|
| 2807 | + define('_VAR_MODE', 'calcul'); |
|
| 2808 | + } |
|
| 2809 | + // et ne pas enregistrer de cache |
|
| 2810 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2811 | + define('_VAR_NOCACHE', true); |
|
| 2812 | + } |
|
| 2813 | + $var_mode = array_diff($var_mode, array('preview')); |
|
| 2814 | + } |
|
| 2815 | + if (in_array('inclure', $var_mode)) { |
|
| 2816 | + // forcer le compilo et ignorer les caches existants |
|
| 2817 | + if (!defined('_VAR_MODE')) { |
|
| 2818 | + define('_VAR_MODE', 'calcul'); |
|
| 2819 | + } |
|
| 2820 | + if (!defined('_VAR_INCLURE')) { |
|
| 2821 | + define('_VAR_INCLURE', true); |
|
| 2822 | + } |
|
| 2823 | + // et ne pas enregistrer de cache |
|
| 2824 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2825 | + define('_VAR_NOCACHE', true); |
|
| 2826 | + } |
|
| 2827 | + $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2828 | + } |
|
| 2829 | + if (in_array('urls', $var_mode)) { |
|
| 2830 | + // forcer le compilo et ignorer les caches existants |
|
| 2831 | + if (!defined('_VAR_MODE')) { |
|
| 2832 | + define('_VAR_MODE', 'calcul'); |
|
| 2833 | + } |
|
| 2834 | + if (!defined('_VAR_URLS')) { |
|
| 2835 | + define('_VAR_URLS', true); |
|
| 2836 | + } |
|
| 2837 | + $var_mode = array_diff($var_mode, array('urls')); |
|
| 2838 | + } |
|
| 2839 | + if (in_array('images', $var_mode)) { |
|
| 2840 | + // forcer le compilo et ignorer les caches existants |
|
| 2841 | + if (!defined('_VAR_MODE')) { |
|
| 2842 | + define('_VAR_MODE', 'calcul'); |
|
| 2843 | + } |
|
| 2844 | + // indiquer qu'on doit recalculer les images |
|
| 2845 | + if (!defined('_VAR_IMAGES')) { |
|
| 2846 | + define('_VAR_IMAGES', true); |
|
| 2847 | + } |
|
| 2848 | + $var_mode = array_diff($var_mode, array('images')); |
|
| 2849 | + } |
|
| 2850 | + if (in_array('debug', $var_mode)) { |
|
| 2851 | + if (!defined('_VAR_MODE')) { |
|
| 2852 | + define('_VAR_MODE', 'debug'); |
|
| 2853 | + } |
|
| 2854 | + // et ne pas enregistrer de cache |
|
| 2855 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2856 | + define('_VAR_NOCACHE', true); |
|
| 2857 | + } |
|
| 2858 | + $var_mode = array_diff($var_mode, array('debug')); |
|
| 2859 | + } |
|
| 2860 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2861 | + define('_VAR_MODE', reset($var_mode)); |
|
| 2862 | + } |
|
| 2863 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2864 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2865 | + . " " . _VAR_MODE); |
|
| 2866 | + } |
|
| 2867 | + } // pas autorise ? |
|
| 2868 | + else { |
|
| 2869 | + // si on n'est pas connecte on se redirige |
|
| 2870 | + if (!$GLOBALS['visiteur_session']) { |
|
| 2871 | + include_spip('inc/headers'); |
|
| 2872 | + redirige_par_entete(generer_url_public('login', |
|
| 2873 | + 'url=' . rawurlencode( |
|
| 2874 | + parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
|
| 2875 | + ), true)); |
|
| 2876 | + } |
|
| 2877 | + // sinon tant pis |
|
| 2878 | + } |
|
| 2879 | + } |
|
| 2880 | + } |
|
| 2881 | + if (!defined('_VAR_MODE')) { |
|
| 2882 | + /** |
|
| 2883 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 2884 | + * @see init_var_mode() |
|
| 2885 | + */ |
|
| 2886 | + define('_VAR_MODE', false); |
|
| 2887 | + } |
|
| 2888 | + $done = true; |
|
| 2889 | + } |
|
| 2891 | 2890 | } |
| 2892 | 2891 | |
| 2893 | 2892 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
@@ -2895,93 +2894,93 @@ discard block |
||
| 2895 | 2894 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 2896 | 2895 | // http://code.spip.net/@spip_desinfecte |
| 2897 | 2896 | function spip_desinfecte(&$t, $deep = true) { |
| 2898 | - static $magic_quotes; |
|
| 2899 | - if (!isset($magic_quotes)) { |
|
| 2900 | - $magic_quotes = @get_magic_quotes_gpc(); |
|
| 2901 | - } |
|
| 2902 | - |
|
| 2903 | - foreach ($t as $key => $val) { |
|
| 2904 | - if (is_string($t[$key])) { |
|
| 2905 | - if ($magic_quotes) { |
|
| 2906 | - $t[$key] = stripslashes($t[$key]); |
|
| 2907 | - } |
|
| 2908 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 2909 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 2910 | - else { |
|
| 2911 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 2912 | - spip_desinfecte($t[$key], $deep); |
|
| 2913 | - } |
|
| 2914 | - } |
|
| 2915 | - } |
|
| 2897 | + static $magic_quotes; |
|
| 2898 | + if (!isset($magic_quotes)) { |
|
| 2899 | + $magic_quotes = @get_magic_quotes_gpc(); |
|
| 2900 | + } |
|
| 2901 | + |
|
| 2902 | + foreach ($t as $key => $val) { |
|
| 2903 | + if (is_string($t[$key])) { |
|
| 2904 | + if ($magic_quotes) { |
|
| 2905 | + $t[$key] = stripslashes($t[$key]); |
|
| 2906 | + } |
|
| 2907 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 2908 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 2909 | + else { |
|
| 2910 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 2911 | + spip_desinfecte($t[$key], $deep); |
|
| 2912 | + } |
|
| 2913 | + } |
|
| 2914 | + } |
|
| 2916 | 2915 | } |
| 2917 | 2916 | |
| 2918 | 2917 | // retourne le statut du visiteur s'il s'annonce |
| 2919 | 2918 | |
| 2920 | 2919 | // http://code.spip.net/@verifier_visiteur |
| 2921 | 2920 | function verifier_visiteur() { |
| 2922 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 2923 | - // il faut forcer l'init si ce n'est fait |
|
| 2924 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 2925 | - // certaines constantes |
|
| 2926 | - @spip_initialisation_core( |
|
| 2927 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 2928 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 2929 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 2930 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 2931 | - ); |
|
| 2932 | - |
|
| 2933 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 2934 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 2935 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 2936 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 2937 | - $variables_session = array('session_nom', 'session_email'); |
|
| 2938 | - foreach ($variables_session as $var) { |
|
| 2939 | - if (_request($var) !== null) { |
|
| 2940 | - $init = true; |
|
| 2941 | - break; |
|
| 2942 | - } |
|
| 2943 | - } |
|
| 2944 | - if (isset($init)) { |
|
| 2945 | - #@spip_initialisation_suite(); |
|
| 2946 | - $session = charger_fonction('session', 'inc'); |
|
| 2947 | - $session(); |
|
| 2948 | - include_spip('inc/texte'); |
|
| 2949 | - foreach ($variables_session as $var) { |
|
| 2950 | - if (($a = _request($var)) !== null) { |
|
| 2951 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 2952 | - } |
|
| 2953 | - } |
|
| 2954 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 2955 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2956 | - } |
|
| 2957 | - $session($GLOBALS['visiteur_session']); |
|
| 2958 | - |
|
| 2959 | - return 0; |
|
| 2960 | - } |
|
| 2961 | - |
|
| 2962 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 2963 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 2964 | - |
|
| 2965 | - $session = charger_fonction('session', 'inc'); |
|
| 2966 | - if ($session()) { |
|
| 2967 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 2968 | - } |
|
| 2969 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 2970 | - include_spip('inc/auth'); |
|
| 2971 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 2972 | - } |
|
| 2973 | - if ($h) { |
|
| 2974 | - $GLOBALS['visiteur_session'] = $h; |
|
| 2975 | - |
|
| 2976 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 2977 | - } |
|
| 2978 | - } |
|
| 2979 | - |
|
| 2980 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 2981 | - include_spip('inc/lang'); |
|
| 2982 | - utiliser_langue_visiteur(); |
|
| 2983 | - |
|
| 2984 | - return false; |
|
| 2921 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 2922 | + // il faut forcer l'init si ce n'est fait |
|
| 2923 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 2924 | + // certaines constantes |
|
| 2925 | + @spip_initialisation_core( |
|
| 2926 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 2927 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 2928 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 2929 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 2930 | + ); |
|
| 2931 | + |
|
| 2932 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 2933 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 2934 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 2935 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 2936 | + $variables_session = array('session_nom', 'session_email'); |
|
| 2937 | + foreach ($variables_session as $var) { |
|
| 2938 | + if (_request($var) !== null) { |
|
| 2939 | + $init = true; |
|
| 2940 | + break; |
|
| 2941 | + } |
|
| 2942 | + } |
|
| 2943 | + if (isset($init)) { |
|
| 2944 | + #@spip_initialisation_suite(); |
|
| 2945 | + $session = charger_fonction('session', 'inc'); |
|
| 2946 | + $session(); |
|
| 2947 | + include_spip('inc/texte'); |
|
| 2948 | + foreach ($variables_session as $var) { |
|
| 2949 | + if (($a = _request($var)) !== null) { |
|
| 2950 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 2951 | + } |
|
| 2952 | + } |
|
| 2953 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 2954 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2955 | + } |
|
| 2956 | + $session($GLOBALS['visiteur_session']); |
|
| 2957 | + |
|
| 2958 | + return 0; |
|
| 2959 | + } |
|
| 2960 | + |
|
| 2961 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 2962 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 2963 | + |
|
| 2964 | + $session = charger_fonction('session', 'inc'); |
|
| 2965 | + if ($session()) { |
|
| 2966 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 2967 | + } |
|
| 2968 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 2969 | + include_spip('inc/auth'); |
|
| 2970 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 2971 | + } |
|
| 2972 | + if ($h) { |
|
| 2973 | + $GLOBALS['visiteur_session'] = $h; |
|
| 2974 | + |
|
| 2975 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 2976 | + } |
|
| 2977 | + } |
|
| 2978 | + |
|
| 2979 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 2980 | + include_spip('inc/lang'); |
|
| 2981 | + utiliser_langue_visiteur(); |
|
| 2982 | + |
|
| 2983 | + return false; |
|
| 2985 | 2984 | } |
| 2986 | 2985 | |
| 2987 | 2986 | |
@@ -3004,21 +3003,21 @@ discard block |
||
| 3004 | 3003 | * - string Langue utilisée. |
| 3005 | 3004 | **/ |
| 3006 | 3005 | function lang_select($lang = null) { |
| 3007 | - static $pile_langues = array(); |
|
| 3008 | - if (!function_exists('changer_langue')) { |
|
| 3009 | - include_spip('inc/lang'); |
|
| 3010 | - } |
|
| 3011 | - if ($lang === null) { |
|
| 3012 | - $lang = array_pop($pile_langues); |
|
| 3013 | - } else { |
|
| 3014 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3015 | - } |
|
| 3016 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3017 | - return $lang; |
|
| 3018 | - } |
|
| 3019 | - changer_langue($lang); |
|
| 3006 | + static $pile_langues = array(); |
|
| 3007 | + if (!function_exists('changer_langue')) { |
|
| 3008 | + include_spip('inc/lang'); |
|
| 3009 | + } |
|
| 3010 | + if ($lang === null) { |
|
| 3011 | + $lang = array_pop($pile_langues); |
|
| 3012 | + } else { |
|
| 3013 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3014 | + } |
|
| 3015 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3016 | + return $lang; |
|
| 3017 | + } |
|
| 3018 | + changer_langue($lang); |
|
| 3020 | 3019 | |
| 3021 | - return $lang; |
|
| 3020 | + return $lang; |
|
| 3022 | 3021 | } |
| 3023 | 3022 | |
| 3024 | 3023 | /** |
@@ -3035,19 +3034,19 @@ discard block |
||
| 3035 | 3034 | * Identifiant de la session |
| 3036 | 3035 | **/ |
| 3037 | 3036 | function spip_session($force = false) { |
| 3038 | - static $session; |
|
| 3039 | - if ($force or !isset($session)) { |
|
| 3040 | - $s = pipeline('definir_session', |
|
| 3041 | - $GLOBALS['visiteur_session'] |
|
| 3042 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3043 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3044 | - : '' |
|
| 3045 | - ); |
|
| 3046 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3047 | - } |
|
| 3037 | + static $session; |
|
| 3038 | + if ($force or !isset($session)) { |
|
| 3039 | + $s = pipeline('definir_session', |
|
| 3040 | + $GLOBALS['visiteur_session'] |
|
| 3041 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3042 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3043 | + : '' |
|
| 3044 | + ); |
|
| 3045 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3046 | + } |
|
| 3048 | 3047 | |
| 3049 | - #spip_log('session: '.$session); |
|
| 3050 | - return $session; |
|
| 3048 | + #spip_log('session: '.$session); |
|
| 3049 | + return $session; |
|
| 3051 | 3050 | } |
| 3052 | 3051 | |
| 3053 | 3052 | |
@@ -3066,9 +3065,9 @@ discard block |
||
| 3066 | 3065 | * Lien sur une icone d'aide |
| 3067 | 3066 | **/ |
| 3068 | 3067 | function aider($aide = '', $distante = false) { |
| 3069 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3068 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3070 | 3069 | |
| 3071 | - return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3070 | + return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3072 | 3071 | } |
| 3073 | 3072 | |
| 3074 | 3073 | /** |
@@ -3078,13 +3077,13 @@ discard block |
||
| 3078 | 3077 | */ |
| 3079 | 3078 | function exec_info_dist() { |
| 3080 | 3079 | |
| 3081 | - include_spip('inc/autoriser'); |
|
| 3082 | - if (autoriser('webmestre')) { |
|
| 3083 | - phpinfo(); |
|
| 3084 | - } else { |
|
| 3085 | - include_spip('inc/filtres'); |
|
| 3086 | - sinon_interdire_acces(); |
|
| 3087 | - } |
|
| 3080 | + include_spip('inc/autoriser'); |
|
| 3081 | + if (autoriser('webmestre')) { |
|
| 3082 | + phpinfo(); |
|
| 3083 | + } else { |
|
| 3084 | + include_spip('inc/filtres'); |
|
| 3085 | + sinon_interdire_acces(); |
|
| 3086 | + } |
|
| 3088 | 3087 | } |
| 3089 | 3088 | |
| 3090 | 3089 | /** |
@@ -3104,13 +3103,13 @@ discard block |
||
| 3104 | 3103 | * - string si $message à false. |
| 3105 | 3104 | **/ |
| 3106 | 3105 | function erreur_squelette($message = '', $lieu = '') { |
| 3107 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3108 | - if (is_array($lieu)) { |
|
| 3109 | - include_spip('public/compiler'); |
|
| 3110 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3111 | - } |
|
| 3106 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3107 | + if (is_array($lieu)) { |
|
| 3108 | + include_spip('public/compiler'); |
|
| 3109 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3110 | + } |
|
| 3112 | 3111 | |
| 3113 | - return $debusquer($message, $lieu); |
|
| 3112 | + return $debusquer($message, $lieu); |
|
| 3114 | 3113 | } |
| 3115 | 3114 | |
| 3116 | 3115 | /** |
@@ -3147,109 +3146,109 @@ discard block |
||
| 3147 | 3146 | * - ou tableau d'information sur le squelette. |
| 3148 | 3147 | */ |
| 3149 | 3148 | function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') { |
| 3150 | - if (!function_exists('evaluer_fond')) { |
|
| 3151 | - include_spip('public/assembler'); |
|
| 3152 | - } |
|
| 3153 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3154 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3155 | - if (!is_array($options)) { |
|
| 3156 | - $options = array('trim' => $options); |
|
| 3157 | - } |
|
| 3158 | - if (!isset($options['trim'])) { |
|
| 3159 | - $options['trim'] = true; |
|
| 3160 | - } |
|
| 3161 | - |
|
| 3162 | - if (isset($contexte['connect'])) { |
|
| 3163 | - $connect = $contexte['connect']; |
|
| 3164 | - unset($contexte['connect']); |
|
| 3165 | - } |
|
| 3166 | - |
|
| 3167 | - $texte = ""; |
|
| 3168 | - $pages = array(); |
|
| 3169 | - $lang_select = ''; |
|
| 3170 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3171 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3172 | - if (!isset($contexte['lang'])) { |
|
| 3173 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3174 | - } |
|
| 3175 | - |
|
| 3176 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3177 | - $lang_select = lang_select($contexte['lang']); |
|
| 3178 | - } |
|
| 3179 | - } |
|
| 3180 | - |
|
| 3181 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3182 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3183 | - } |
|
| 3184 | - |
|
| 3185 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3186 | - |
|
| 3187 | - // fix #4235 |
|
| 3188 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3189 | - |
|
| 3190 | - |
|
| 3191 | - foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3149 | + if (!function_exists('evaluer_fond')) { |
|
| 3150 | + include_spip('public/assembler'); |
|
| 3151 | + } |
|
| 3152 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3153 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3154 | + if (!is_array($options)) { |
|
| 3155 | + $options = array('trim' => $options); |
|
| 3156 | + } |
|
| 3157 | + if (!isset($options['trim'])) { |
|
| 3158 | + $options['trim'] = true; |
|
| 3159 | + } |
|
| 3160 | + |
|
| 3161 | + if (isset($contexte['connect'])) { |
|
| 3162 | + $connect = $contexte['connect']; |
|
| 3163 | + unset($contexte['connect']); |
|
| 3164 | + } |
|
| 3165 | + |
|
| 3166 | + $texte = ""; |
|
| 3167 | + $pages = array(); |
|
| 3168 | + $lang_select = ''; |
|
| 3169 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3170 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3171 | + if (!isset($contexte['lang'])) { |
|
| 3172 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3173 | + } |
|
| 3174 | + |
|
| 3175 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3176 | + $lang_select = lang_select($contexte['lang']); |
|
| 3177 | + } |
|
| 3178 | + } |
|
| 3179 | + |
|
| 3180 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3181 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3182 | + } |
|
| 3183 | + |
|
| 3184 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3185 | + |
|
| 3186 | + // fix #4235 |
|
| 3187 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3188 | + |
|
| 3189 | + |
|
| 3190 | + foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3192 | 3191 | |
| 3193 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3194 | - |
|
| 3195 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3196 | - if ($page === '') { |
|
| 3197 | - $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3198 | - $a = array('fichier' => $f); |
|
| 3199 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3200 | - erreur_squelette($erreur, $c); |
|
| 3201 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3202 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3203 | - } |
|
| 3204 | - |
|
| 3205 | - $page = pipeline('recuperer_fond', array( |
|
| 3206 | - 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3207 | - 'data' => $page |
|
| 3208 | - )); |
|
| 3209 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3210 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3211 | - include_spip('inc/filtres'); |
|
| 3212 | - } |
|
| 3213 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3214 | - array_merge( |
|
| 3215 | - $contexte, |
|
| 3216 | - array('fond' => $f), |
|
| 3217 | - ($connect ? array('connect' => $connect) : array()) |
|
| 3218 | - ), |
|
| 3219 | - '', |
|
| 3220 | - $page['texte'], |
|
| 3221 | - $options['ajax'] |
|
| 3222 | - ); |
|
| 3223 | - } |
|
| 3224 | - |
|
| 3225 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3226 | - $pages[] = $page; |
|
| 3227 | - } else { |
|
| 3228 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3229 | - } |
|
| 3192 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3193 | + |
|
| 3194 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3195 | + if ($page === '') { |
|
| 3196 | + $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3197 | + $a = array('fichier' => $f); |
|
| 3198 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3199 | + erreur_squelette($erreur, $c); |
|
| 3200 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3201 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3202 | + } |
|
| 3203 | + |
|
| 3204 | + $page = pipeline('recuperer_fond', array( |
|
| 3205 | + 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3206 | + 'data' => $page |
|
| 3207 | + )); |
|
| 3208 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3209 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3210 | + include_spip('inc/filtres'); |
|
| 3211 | + } |
|
| 3212 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3213 | + array_merge( |
|
| 3214 | + $contexte, |
|
| 3215 | + array('fond' => $f), |
|
| 3216 | + ($connect ? array('connect' => $connect) : array()) |
|
| 3217 | + ), |
|
| 3218 | + '', |
|
| 3219 | + $page['texte'], |
|
| 3220 | + $options['ajax'] |
|
| 3221 | + ); |
|
| 3222 | + } |
|
| 3223 | + |
|
| 3224 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3225 | + $pages[] = $page; |
|
| 3226 | + } else { |
|
| 3227 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3228 | + } |
|
| 3230 | 3229 | |
| 3231 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3232 | - if (isset($page['invalideurs']['session'])){ |
|
| 3233 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3234 | - } |
|
| 3235 | - } |
|
| 3230 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3231 | + if (isset($page['invalideurs']['session'])){ |
|
| 3232 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3233 | + } |
|
| 3234 | + } |
|
| 3236 | 3235 | |
| 3237 | - // restaurer le sessionnement du contexte appelant, |
|
| 3238 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3239 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3240 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3241 | - } |
|
| 3236 | + // restaurer le sessionnement du contexte appelant, |
|
| 3237 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3238 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3239 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3240 | + } |
|
| 3242 | 3241 | |
| 3243 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3242 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3244 | 3243 | |
| 3245 | - if ($lang_select) { |
|
| 3246 | - lang_select(); |
|
| 3247 | - } |
|
| 3248 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3249 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3250 | - } else { |
|
| 3251 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3252 | - } |
|
| 3244 | + if ($lang_select) { |
|
| 3245 | + lang_select(); |
|
| 3246 | + } |
|
| 3247 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3248 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3249 | + } else { |
|
| 3250 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3251 | + } |
|
| 3253 | 3252 | } |
| 3254 | 3253 | |
| 3255 | 3254 | /** |
@@ -3259,7 +3258,7 @@ discard block |
||
| 3259 | 3258 | * @return string |
| 3260 | 3259 | */ |
| 3261 | 3260 | function trouve_modele($nom) { |
| 3262 | - return trouver_fond($nom, 'modeles/'); |
|
| 3261 | + return trouver_fond($nom, 'modeles/'); |
|
| 3263 | 3262 | } |
| 3264 | 3263 | |
| 3265 | 3264 | /** |
@@ -3275,21 +3274,21 @@ discard block |
||
| 3275 | 3274 | * @return array|string |
| 3276 | 3275 | */ |
| 3277 | 3276 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3278 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3279 | - if (!$pathinfo) { |
|
| 3280 | - return $f; |
|
| 3281 | - } |
|
| 3282 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3283 | - $p = pathinfo($f); |
|
| 3284 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3285 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3286 | - } |
|
| 3287 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3288 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3289 | - } |
|
| 3290 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3277 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3278 | + if (!$pathinfo) { |
|
| 3279 | + return $f; |
|
| 3280 | + } |
|
| 3281 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3282 | + $p = pathinfo($f); |
|
| 3283 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3284 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3285 | + } |
|
| 3286 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3287 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3288 | + } |
|
| 3289 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3291 | 3290 | |
| 3292 | - return $p; |
|
| 3291 | + return $p; |
|
| 3293 | 3292 | } |
| 3294 | 3293 | |
| 3295 | 3294 | /** |
@@ -3310,24 +3309,24 @@ discard block |
||
| 3310 | 3309 | * Nom de l'exec, sinon chaîne vide. |
| 3311 | 3310 | **/ |
| 3312 | 3311 | function tester_url_ecrire($nom) { |
| 3313 | - static $exec = array(); |
|
| 3314 | - if (isset($exec[$nom])) { |
|
| 3315 | - return $exec[$nom]; |
|
| 3316 | - } |
|
| 3317 | - // tester si c'est une page en squelette |
|
| 3318 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3319 | - return $exec[$nom] = 'fond'; |
|
| 3320 | - } // compat skels orthogonaux version precedente |
|
| 3321 | - elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3322 | - return $exec[$nom] = 'fond_monobloc'; |
|
| 3323 | - } // echafaudage d'un fond ! |
|
| 3324 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3325 | - return $exec[$nom] = 'fond'; |
|
| 3326 | - } |
|
| 3327 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3328 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3329 | - // et des define intrusifs potentiels |
|
| 3330 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3312 | + static $exec = array(); |
|
| 3313 | + if (isset($exec[$nom])) { |
|
| 3314 | + return $exec[$nom]; |
|
| 3315 | + } |
|
| 3316 | + // tester si c'est une page en squelette |
|
| 3317 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3318 | + return $exec[$nom] = 'fond'; |
|
| 3319 | + } // compat skels orthogonaux version precedente |
|
| 3320 | + elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3321 | + return $exec[$nom] = 'fond_monobloc'; |
|
| 3322 | + } // echafaudage d'un fond ! |
|
| 3323 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3324 | + return $exec[$nom] = 'fond'; |
|
| 3325 | + } |
|
| 3326 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3327 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3328 | + // et des define intrusifs potentiels |
|
| 3329 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3331 | 3330 | } |
| 3332 | 3331 | |
| 3333 | 3332 | |
@@ -3343,10 +3342,10 @@ discard block |
||
| 3343 | 3342 | * @return bool true si le module est chargé |
| 3344 | 3343 | **/ |
| 3345 | 3344 | function charger_php_extension($module) { |
| 3346 | - if (extension_loaded($module)) { |
|
| 3347 | - return true; |
|
| 3348 | - } |
|
| 3349 | - return false; |
|
| 3345 | + if (extension_loaded($module)) { |
|
| 3346 | + return true; |
|
| 3347 | + } |
|
| 3348 | + return false; |
|
| 3350 | 3349 | } |
| 3351 | 3350 | |
| 3352 | 3351 | |
@@ -3357,8 +3356,8 @@ discard block |
||
| 3357 | 3356 | * true si et seulement si la configuration autorise le code HTML5 sur le site public |
| 3358 | 3357 | **/ |
| 3359 | 3358 | function html5_permis() { |
| 3360 | - return (isset($GLOBALS['meta']['version_html_max']) |
|
| 3361 | - and ('html5' == $GLOBALS['meta']['version_html_max'])); |
|
| 3359 | + return (isset($GLOBALS['meta']['version_html_max']) |
|
| 3360 | + and ('html5' == $GLOBALS['meta']['version_html_max'])); |
|
| 3362 | 3361 | } |
| 3363 | 3362 | |
| 3364 | 3363 | /** |
@@ -3368,17 +3367,17 @@ discard block |
||
| 3368 | 3367 | * @return array |
| 3369 | 3368 | */ |
| 3370 | 3369 | function formats_image_acceptables($gd = false, $svg_allowed = true) { |
| 3371 | - $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3372 | - $formats = (isset($GLOBALS['meta'][$config]) ? $GLOBALS['meta'][$config] : 'png,gif,jpg'); |
|
| 3373 | - $formats = explode(',', $formats); |
|
| 3374 | - $formats = array_filter($formats); |
|
| 3375 | - $formats = array_map('trim', $formats); |
|
| 3370 | + $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3371 | + $formats = (isset($GLOBALS['meta'][$config]) ? $GLOBALS['meta'][$config] : 'png,gif,jpg'); |
|
| 3372 | + $formats = explode(',', $formats); |
|
| 3373 | + $formats = array_filter($formats); |
|
| 3374 | + $formats = array_map('trim', $formats); |
|
| 3376 | 3375 | |
| 3377 | - if ($svg_allowed) { |
|
| 3378 | - $formats[] = 'svg'; |
|
| 3379 | - } |
|
| 3376 | + if ($svg_allowed) { |
|
| 3377 | + $formats[] = 'svg'; |
|
| 3378 | + } |
|
| 3380 | 3379 | |
| 3381 | - return $formats; |
|
| 3380 | + return $formats; |
|
| 3382 | 3381 | } |
| 3383 | 3382 | |
| 3384 | 3383 | /** |
@@ -3387,40 +3386,40 @@ discard block |
||
| 3387 | 3386 | * @return array|bool |
| 3388 | 3387 | */ |
| 3389 | 3388 | function spip_getimagesize($fichier) { |
| 3390 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3391 | - |
|
| 3392 | - include_spip("inc/svg"); |
|
| 3393 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3394 | - $width = 350; // default width |
|
| 3395 | - $height = 150; // default height |
|
| 3396 | - if (isset($attrs['width']) |
|
| 3397 | - and $w = svg_dimension_to_pixels($attrs['width']) |
|
| 3398 | - and isset($attrs['height']) |
|
| 3399 | - and $h = svg_dimension_to_pixels($attrs['height'])) { |
|
| 3400 | - $width = $w; |
|
| 3401 | - $height = $h; |
|
| 3402 | - } |
|
| 3403 | - elseif (isset($attrs['viewBox'])) { |
|
| 3404 | - $viewbox = trim($attrs['viewBox']); |
|
| 3405 | - $viewbox = preg_replace(",\s+,", " ", $viewbox); |
|
| 3406 | - $viewbox = explode(" ", $viewbox); |
|
| 3407 | - if (count($viewbox) === 4 |
|
| 3408 | - and $w = svg_dimension_to_pixels($viewbox[2]) |
|
| 3409 | - and $h = svg_dimension_to_pixels($viewbox[3])) { |
|
| 3410 | - $width = $w; |
|
| 3411 | - $height = $h; |
|
| 3412 | - } |
|
| 3413 | - } |
|
| 3414 | - $imagesize = [ |
|
| 3415 | - $width, |
|
| 3416 | - $height, |
|
| 3417 | - IMAGETYPE_SVG, |
|
| 3418 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3419 | - "mime" => "image/svg+xml" |
|
| 3420 | - ]; |
|
| 3421 | - } |
|
| 3422 | - } |
|
| 3423 | - return $imagesize; |
|
| 3389 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3390 | + |
|
| 3391 | + include_spip("inc/svg"); |
|
| 3392 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3393 | + $width = 350; // default width |
|
| 3394 | + $height = 150; // default height |
|
| 3395 | + if (isset($attrs['width']) |
|
| 3396 | + and $w = svg_dimension_to_pixels($attrs['width']) |
|
| 3397 | + and isset($attrs['height']) |
|
| 3398 | + and $h = svg_dimension_to_pixels($attrs['height'])) { |
|
| 3399 | + $width = $w; |
|
| 3400 | + $height = $h; |
|
| 3401 | + } |
|
| 3402 | + elseif (isset($attrs['viewBox'])) { |
|
| 3403 | + $viewbox = trim($attrs['viewBox']); |
|
| 3404 | + $viewbox = preg_replace(",\s+,", " ", $viewbox); |
|
| 3405 | + $viewbox = explode(" ", $viewbox); |
|
| 3406 | + if (count($viewbox) === 4 |
|
| 3407 | + and $w = svg_dimension_to_pixels($viewbox[2]) |
|
| 3408 | + and $h = svg_dimension_to_pixels($viewbox[3])) { |
|
| 3409 | + $width = $w; |
|
| 3410 | + $height = $h; |
|
| 3411 | + } |
|
| 3412 | + } |
|
| 3413 | + $imagesize = [ |
|
| 3414 | + $width, |
|
| 3415 | + $height, |
|
| 3416 | + IMAGETYPE_SVG, |
|
| 3417 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3418 | + "mime" => "image/svg+xml" |
|
| 3419 | + ]; |
|
| 3420 | + } |
|
| 3421 | + } |
|
| 3422 | + return $imagesize; |
|
| 3424 | 3423 | } |
| 3425 | 3424 | |
| 3426 | 3425 | |
@@ -3440,7 +3439,7 @@ discard block |
||
| 3440 | 3439 | * @return mixed Valeur de la meta. |
| 3441 | 3440 | **/ |
| 3442 | 3441 | function lire_meta($nom) { |
| 3443 | - return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3442 | + return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3444 | 3443 | } |
| 3445 | 3444 | |
| 3446 | 3445 | |
@@ -3462,128 +3461,128 @@ discard block |
||
| 3462 | 3461 | * @param string $statut |
| 3463 | 3462 | */ |
| 3464 | 3463 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3465 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3466 | - if (!$alertes |
|
| 3467 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3468 | - ) { |
|
| 3469 | - $alertes = array(); |
|
| 3470 | - } |
|
| 3464 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3465 | + if (!$alertes |
|
| 3466 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3467 | + ) { |
|
| 3468 | + $alertes = array(); |
|
| 3469 | + } |
|
| 3471 | 3470 | |
| 3472 | - if (!isset($alertes[$statut])) { |
|
| 3473 | - $alertes[$statut] = array(); |
|
| 3474 | - } |
|
| 3475 | - $alertes[$statut][$nom] = $message; |
|
| 3476 | - ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3471 | + if (!isset($alertes[$statut])) { |
|
| 3472 | + $alertes[$statut] = array(); |
|
| 3473 | + } |
|
| 3474 | + $alertes[$statut][$nom] = $message; |
|
| 3475 | + ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3477 | 3476 | } |
| 3478 | 3477 | |
| 3479 | 3478 | if (PHP_VERSION_ID < 50500) { |
| 3480 | - if (!function_exists('array_column')) { |
|
| 3481 | - /** |
|
| 3482 | - * Returns the values from a single column of the input array, identified by |
|
| 3483 | - * the $columnKey. |
|
| 3484 | - * |
|
| 3485 | - * Optionally, you may provide an $indexKey to index the values in the returned |
|
| 3486 | - * array by the values from the $indexKey column in the input array. |
|
| 3487 | - * |
|
| 3488 | - * @link http://php.net/manual/fr/function.array-column.php |
|
| 3489 | - * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php |
|
| 3490 | - * @copyright Copyright (c) Ben Ramsey (http://benramsey.com) |
|
| 3491 | - * @license http://opensource.org/licenses/MIT MIT |
|
| 3492 | - * |
|
| 3493 | - * @param array $input A multi-dimensional array (record set) from which to pull |
|
| 3494 | - * a column of values. |
|
| 3495 | - * @param mixed $columnKey The column of values to return. This value may be the |
|
| 3496 | - * integer key of the column you wish to retrieve, or it |
|
| 3497 | - * may be the string key name for an associative array. |
|
| 3498 | - * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
|
| 3499 | - * the returned array. This value may be the integer key |
|
| 3500 | - * of the column, or it may be the string key name. |
|
| 3501 | - * @return array |
|
| 3502 | - */ |
|
| 3503 | - function array_column($input = null, $columnKey = null, $indexKey = null) |
|
| 3504 | - { |
|
| 3505 | - // Using func_get_args() in order to check for proper number of |
|
| 3506 | - // parameters and trigger errors exactly as the built-in array_column() |
|
| 3507 | - // does in PHP 5.5. |
|
| 3508 | - $argc = func_num_args(); |
|
| 3509 | - $params = func_get_args(); |
|
| 3510 | - |
|
| 3511 | - if ($argc < 2) { |
|
| 3512 | - trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 3513 | - return null; |
|
| 3514 | - } |
|
| 3515 | - |
|
| 3516 | - if (!is_array($params[0])) { |
|
| 3517 | - trigger_error( |
|
| 3518 | - 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
| 3519 | - E_USER_WARNING |
|
| 3520 | - ); |
|
| 3521 | - return null; |
|
| 3522 | - } |
|
| 3523 | - |
|
| 3524 | - if (!is_int($params[1]) |
|
| 3525 | - && !is_float($params[1]) |
|
| 3526 | - && !is_string($params[1]) |
|
| 3527 | - && $params[1] !== null |
|
| 3528 | - && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 3529 | - ) { |
|
| 3530 | - trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 3531 | - return false; |
|
| 3532 | - } |
|
| 3533 | - |
|
| 3534 | - if (isset($params[2]) |
|
| 3535 | - && !is_int($params[2]) |
|
| 3536 | - && !is_float($params[2]) |
|
| 3537 | - && !is_string($params[2]) |
|
| 3538 | - && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 3539 | - ) { |
|
| 3540 | - trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 3541 | - return false; |
|
| 3542 | - } |
|
| 3543 | - |
|
| 3544 | - $paramsInput = $params[0]; |
|
| 3545 | - $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 3546 | - |
|
| 3547 | - $paramsIndexKey = null; |
|
| 3548 | - if (isset($params[2])) { |
|
| 3549 | - if (is_float($params[2]) || is_int($params[2])) { |
|
| 3550 | - $paramsIndexKey = (int) $params[2]; |
|
| 3551 | - } else { |
|
| 3552 | - $paramsIndexKey = (string) $params[2]; |
|
| 3553 | - } |
|
| 3554 | - } |
|
| 3555 | - |
|
| 3556 | - $resultArray = array(); |
|
| 3557 | - |
|
| 3558 | - foreach ($paramsInput as $row) { |
|
| 3559 | - $key = $value = null; |
|
| 3560 | - $keySet = $valueSet = false; |
|
| 3561 | - |
|
| 3562 | - if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 3563 | - $keySet = true; |
|
| 3564 | - $key = (string) $row[$paramsIndexKey]; |
|
| 3565 | - } |
|
| 3566 | - |
|
| 3567 | - if ($paramsColumnKey === null) { |
|
| 3568 | - $valueSet = true; |
|
| 3569 | - $value = $row; |
|
| 3570 | - } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 3571 | - $valueSet = true; |
|
| 3572 | - $value = $row[$paramsColumnKey]; |
|
| 3573 | - } |
|
| 3574 | - |
|
| 3575 | - if ($valueSet) { |
|
| 3576 | - if ($keySet) { |
|
| 3577 | - $resultArray[$key] = $value; |
|
| 3578 | - } else { |
|
| 3579 | - $resultArray[] = $value; |
|
| 3580 | - } |
|
| 3581 | - } |
|
| 3582 | - |
|
| 3583 | - } |
|
| 3584 | - |
|
| 3585 | - return $resultArray; |
|
| 3586 | - } |
|
| 3587 | - |
|
| 3588 | - } |
|
| 3479 | + if (!function_exists('array_column')) { |
|
| 3480 | + /** |
|
| 3481 | + * Returns the values from a single column of the input array, identified by |
|
| 3482 | + * the $columnKey. |
|
| 3483 | + * |
|
| 3484 | + * Optionally, you may provide an $indexKey to index the values in the returned |
|
| 3485 | + * array by the values from the $indexKey column in the input array. |
|
| 3486 | + * |
|
| 3487 | + * @link http://php.net/manual/fr/function.array-column.php |
|
| 3488 | + * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php |
|
| 3489 | + * @copyright Copyright (c) Ben Ramsey (http://benramsey.com) |
|
| 3490 | + * @license http://opensource.org/licenses/MIT MIT |
|
| 3491 | + * |
|
| 3492 | + * @param array $input A multi-dimensional array (record set) from which to pull |
|
| 3493 | + * a column of values. |
|
| 3494 | + * @param mixed $columnKey The column of values to return. This value may be the |
|
| 3495 | + * integer key of the column you wish to retrieve, or it |
|
| 3496 | + * may be the string key name for an associative array. |
|
| 3497 | + * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
|
| 3498 | + * the returned array. This value may be the integer key |
|
| 3499 | + * of the column, or it may be the string key name. |
|
| 3500 | + * @return array |
|
| 3501 | + */ |
|
| 3502 | + function array_column($input = null, $columnKey = null, $indexKey = null) |
|
| 3503 | + { |
|
| 3504 | + // Using func_get_args() in order to check for proper number of |
|
| 3505 | + // parameters and trigger errors exactly as the built-in array_column() |
|
| 3506 | + // does in PHP 5.5. |
|
| 3507 | + $argc = func_num_args(); |
|
| 3508 | + $params = func_get_args(); |
|
| 3509 | + |
|
| 3510 | + if ($argc < 2) { |
|
| 3511 | + trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 3512 | + return null; |
|
| 3513 | + } |
|
| 3514 | + |
|
| 3515 | + if (!is_array($params[0])) { |
|
| 3516 | + trigger_error( |
|
| 3517 | + 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
| 3518 | + E_USER_WARNING |
|
| 3519 | + ); |
|
| 3520 | + return null; |
|
| 3521 | + } |
|
| 3522 | + |
|
| 3523 | + if (!is_int($params[1]) |
|
| 3524 | + && !is_float($params[1]) |
|
| 3525 | + && !is_string($params[1]) |
|
| 3526 | + && $params[1] !== null |
|
| 3527 | + && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 3528 | + ) { |
|
| 3529 | + trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 3530 | + return false; |
|
| 3531 | + } |
|
| 3532 | + |
|
| 3533 | + if (isset($params[2]) |
|
| 3534 | + && !is_int($params[2]) |
|
| 3535 | + && !is_float($params[2]) |
|
| 3536 | + && !is_string($params[2]) |
|
| 3537 | + && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 3538 | + ) { |
|
| 3539 | + trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 3540 | + return false; |
|
| 3541 | + } |
|
| 3542 | + |
|
| 3543 | + $paramsInput = $params[0]; |
|
| 3544 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 3545 | + |
|
| 3546 | + $paramsIndexKey = null; |
|
| 3547 | + if (isset($params[2])) { |
|
| 3548 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 3549 | + $paramsIndexKey = (int) $params[2]; |
|
| 3550 | + } else { |
|
| 3551 | + $paramsIndexKey = (string) $params[2]; |
|
| 3552 | + } |
|
| 3553 | + } |
|
| 3554 | + |
|
| 3555 | + $resultArray = array(); |
|
| 3556 | + |
|
| 3557 | + foreach ($paramsInput as $row) { |
|
| 3558 | + $key = $value = null; |
|
| 3559 | + $keySet = $valueSet = false; |
|
| 3560 | + |
|
| 3561 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 3562 | + $keySet = true; |
|
| 3563 | + $key = (string) $row[$paramsIndexKey]; |
|
| 3564 | + } |
|
| 3565 | + |
|
| 3566 | + if ($paramsColumnKey === null) { |
|
| 3567 | + $valueSet = true; |
|
| 3568 | + $value = $row; |
|
| 3569 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 3570 | + $valueSet = true; |
|
| 3571 | + $value = $row[$paramsColumnKey]; |
|
| 3572 | + } |
|
| 3573 | + |
|
| 3574 | + if ($valueSet) { |
|
| 3575 | + if ($keySet) { |
|
| 3576 | + $resultArray[$key] = $value; |
|
| 3577 | + } else { |
|
| 3578 | + $resultArray[] = $value; |
|
| 3579 | + } |
|
| 3580 | + } |
|
| 3581 | + |
|
| 3582 | + } |
|
| 3583 | + |
|
| 3584 | + return $resultArray; |
|
| 3585 | + } |
|
| 3586 | + |
|
| 3587 | + } |
|
| 3589 | 3588 | } |