@@ -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 | |
@@ -177,26 +177,26 @@ discard block |
||
| 177 | 177 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 178 | 178 | */ |
| 179 | 179 | function include_fichiers_fonctions() { |
| 180 | - static $done = false; |
|
| 181 | - if (!$done) { |
|
| 182 | - include_spip('inc/lang'); |
|
| 180 | + static $done = false; |
|
| 181 | + if (!$done) { |
|
| 182 | + include_spip('inc/lang'); |
|
| 183 | 183 | |
| 184 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 185 | - // donc il faut l'inclure "en globals" |
|
| 186 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 187 | - global $dossier_squelettes; |
|
| 188 | - include_once(_ROOT_CWD . $f); |
|
| 189 | - } |
|
| 184 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 185 | + // donc il faut l'inclure "en globals" |
|
| 186 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 187 | + global $dossier_squelettes; |
|
| 188 | + include_once(_ROOT_CWD . $f); |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 192 | - // chargement optimise precompile |
|
| 193 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 194 | - } |
|
| 195 | - if (test_espace_prive()) { |
|
| 196 | - include_spip('inc/filtres_ecrire'); |
|
| 197 | - } |
|
| 198 | - $done = true; |
|
| 199 | - } |
|
| 191 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 192 | + // chargement optimise precompile |
|
| 193 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 194 | + } |
|
| 195 | + if (test_espace_prive()) { |
|
| 196 | + include_spip('inc/filtres_ecrire'); |
|
| 197 | + } |
|
| 198 | + $done = true; |
|
| 199 | + } |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -222,22 +222,22 @@ discard block |
||
| 222 | 222 | * Les paramètres du pipeline modifiés |
| 223 | 223 | **/ |
| 224 | 224 | function minipipe($fonc, &$val) { |
| 225 | - // fonction |
|
| 226 | - if (function_exists($fonc)) { |
|
| 227 | - $val = call_user_func($fonc, $val); |
|
| 228 | - } // Class::Methode |
|
| 229 | - else { |
|
| 230 | - if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 231 | - and $methode = array($regs[1], $regs[2]) |
|
| 232 | - and is_callable($methode) |
|
| 233 | - ) { |
|
| 234 | - $val = call_user_func($methode, $val); |
|
| 235 | - } else { |
|
| 236 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 237 | - } |
|
| 238 | - } |
|
| 225 | + // fonction |
|
| 226 | + if (function_exists($fonc)) { |
|
| 227 | + $val = call_user_func($fonc, $val); |
|
| 228 | + } // Class::Methode |
|
| 229 | + else { |
|
| 230 | + if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 231 | + and $methode = array($regs[1], $regs[2]) |
|
| 232 | + and is_callable($methode) |
|
| 233 | + ) { |
|
| 234 | + $val = call_user_func($methode, $val); |
|
| 235 | + } else { |
|
| 236 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - return $val; |
|
| 240 | + return $val; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -268,45 +268,45 @@ discard block |
||
| 268 | 268 | * Résultat |
| 269 | 269 | */ |
| 270 | 270 | function pipeline($action, $val = null) { |
| 271 | - static $charger; |
|
| 272 | - |
|
| 273 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 274 | - if (!$charger) { |
|
| 275 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 276 | - include_spip('inc/plugin'); |
|
| 277 | - // generer les fichiers php precompiles |
|
| 278 | - // de chargement des plugins et des pipelines |
|
| 279 | - actualise_plugins_actifs(); |
|
| 280 | - if (!($ok = @is_readable($charger))) { |
|
| 281 | - spip_log("fichier $charger pas cree"); |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - if ($ok) { |
|
| 286 | - include_once $charger; |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - // appliquer notre fonction si elle existe |
|
| 291 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 292 | - if (function_exists($fonc)) { |
|
| 293 | - $val = $fonc($val); |
|
| 294 | - } // plantage ? |
|
| 295 | - else { |
|
| 296 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - // si le flux est une table avec 2 cle args&data |
|
| 300 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 301 | - // array_key_exists pour php 4.1.0 |
|
| 302 | - if (is_array($val) |
|
| 303 | - and count($val) == 2 |
|
| 304 | - and (array_key_exists('data', $val)) |
|
| 305 | - ) { |
|
| 306 | - $val = $val['data']; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - return $val; |
|
| 271 | + static $charger; |
|
| 272 | + |
|
| 273 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 274 | + if (!$charger) { |
|
| 275 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 276 | + include_spip('inc/plugin'); |
|
| 277 | + // generer les fichiers php precompiles |
|
| 278 | + // de chargement des plugins et des pipelines |
|
| 279 | + actualise_plugins_actifs(); |
|
| 280 | + if (!($ok = @is_readable($charger))) { |
|
| 281 | + spip_log("fichier $charger pas cree"); |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + if ($ok) { |
|
| 286 | + include_once $charger; |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + // appliquer notre fonction si elle existe |
|
| 291 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 292 | + if (function_exists($fonc)) { |
|
| 293 | + $val = $fonc($val); |
|
| 294 | + } // plantage ? |
|
| 295 | + else { |
|
| 296 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + // si le flux est une table avec 2 cle args&data |
|
| 300 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 301 | + // array_key_exists pour php 4.1.0 |
|
| 302 | + if (is_array($val) |
|
| 303 | + and count($val) == 2 |
|
| 304 | + and (array_key_exists('data', $val)) |
|
| 305 | + ) { |
|
| 306 | + $val = $val['data']; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + return $val; |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -350,35 +350,35 @@ discard block |
||
| 350 | 350 | * paramètre est planté pour cause de compatibilité ascendante. |
| 351 | 351 | */ |
| 352 | 352 | function spip_log($message = null, $name = null) { |
| 353 | - static $pre = array(); |
|
| 354 | - static $log; |
|
| 355 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 356 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 357 | - $logname = null; |
|
| 358 | - } |
|
| 359 | - if (!isset($regs[2]) or !$niveau = $regs[2]) { |
|
| 360 | - $niveau = _LOG_INFO; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 364 | - if (!$pre) { |
|
| 365 | - $pre = array( |
|
| 366 | - _LOG_HS => 'HS:', |
|
| 367 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 368 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 369 | - _LOG_ERREUR => 'ERREUR:', |
|
| 370 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 371 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 372 | - _LOG_INFO => 'info:', |
|
| 373 | - _LOG_DEBUG => 'debug:' |
|
| 374 | - ); |
|
| 375 | - $log = charger_fonction('log', 'inc'); |
|
| 376 | - } |
|
| 377 | - if (!is_string($message)) { |
|
| 378 | - $message = print_r($message, true); |
|
| 379 | - } |
|
| 380 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 381 | - } |
|
| 353 | + static $pre = array(); |
|
| 354 | + static $log; |
|
| 355 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 356 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 357 | + $logname = null; |
|
| 358 | + } |
|
| 359 | + if (!isset($regs[2]) or !$niveau = $regs[2]) { |
|
| 360 | + $niveau = _LOG_INFO; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 364 | + if (!$pre) { |
|
| 365 | + $pre = array( |
|
| 366 | + _LOG_HS => 'HS:', |
|
| 367 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 368 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 369 | + _LOG_ERREUR => 'ERREUR:', |
|
| 370 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 371 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 372 | + _LOG_INFO => 'info:', |
|
| 373 | + _LOG_DEBUG => 'debug:' |
|
| 374 | + ); |
|
| 375 | + $log = charger_fonction('log', 'inc'); |
|
| 376 | + } |
|
| 377 | + if (!is_string($message)) { |
|
| 378 | + $message = print_r($message, true); |
|
| 379 | + } |
|
| 380 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 381 | + } |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
@@ -389,8 +389,8 @@ discard block |
||
| 389 | 389 | * @param array $opt Tableau d'options |
| 390 | 390 | **/ |
| 391 | 391 | function journal($phrase, $opt = array()) { |
| 392 | - $journal = charger_fonction('journal', 'inc'); |
|
| 393 | - $journal($phrase, $opt); |
|
| 392 | + $journal = charger_fonction('journal', 'inc'); |
|
| 393 | + $journal($phrase, $opt); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | |
@@ -409,36 +409,36 @@ discard block |
||
| 409 | 409 | **/ |
| 410 | 410 | function _request($var, $c = false) { |
| 411 | 411 | |
| 412 | - if (is_array($c)) { |
|
| 413 | - return isset($c[$var]) ? $c[$var] : null; |
|
| 414 | - } |
|
| 412 | + if (is_array($c)) { |
|
| 413 | + return isset($c[$var]) ? $c[$var] : null; |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - if (isset($_GET[$var])) { |
|
| 417 | - $a = $_GET[$var]; |
|
| 418 | - } elseif (isset($_POST[$var])) { |
|
| 419 | - $a = $_POST[$var]; |
|
| 420 | - } else { |
|
| 421 | - return null; |
|
| 422 | - } |
|
| 416 | + if (isset($_GET[$var])) { |
|
| 417 | + $a = $_GET[$var]; |
|
| 418 | + } elseif (isset($_POST[$var])) { |
|
| 419 | + $a = $_POST[$var]; |
|
| 420 | + } else { |
|
| 421 | + return null; |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - // Si on est en ajax et en POST tout a ete encode |
|
| 425 | - // via encodeURIComponent, il faut donc repasser |
|
| 426 | - // dans le charset local... |
|
| 427 | - if (defined('_AJAX') |
|
| 428 | - and _AJAX |
|
| 429 | - and isset($GLOBALS['meta']['charset']) |
|
| 430 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 431 | - and is_string($a) |
|
| 432 | - // check rapide mais pas fiable |
|
| 433 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 434 | - // check fiable |
|
| 435 | - and include_spip('inc/charsets') |
|
| 436 | - and is_utf8($a) |
|
| 437 | - ) { |
|
| 438 | - return importer_charset($a, 'utf-8'); |
|
| 439 | - } |
|
| 424 | + // Si on est en ajax et en POST tout a ete encode |
|
| 425 | + // via encodeURIComponent, il faut donc repasser |
|
| 426 | + // dans le charset local... |
|
| 427 | + if (defined('_AJAX') |
|
| 428 | + and _AJAX |
|
| 429 | + and isset($GLOBALS['meta']['charset']) |
|
| 430 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 431 | + and is_string($a) |
|
| 432 | + // check rapide mais pas fiable |
|
| 433 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 434 | + // check fiable |
|
| 435 | + and include_spip('inc/charsets') |
|
| 436 | + and is_utf8($a) |
|
| 437 | + ) { |
|
| 438 | + return importer_charset($a, 'utf-8'); |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | - return $a; |
|
| 441 | + return $a; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | |
@@ -456,22 +456,22 @@ discard block |
||
| 456 | 456 | * - false sinon |
| 457 | 457 | **/ |
| 458 | 458 | function set_request($var, $val = null, $c = false) { |
| 459 | - if (is_array($c)) { |
|
| 460 | - unset($c[$var]); |
|
| 461 | - if ($val !== null) { |
|
| 462 | - $c[$var] = $val; |
|
| 463 | - } |
|
| 459 | + if (is_array($c)) { |
|
| 460 | + unset($c[$var]); |
|
| 461 | + if ($val !== null) { |
|
| 462 | + $c[$var] = $val; |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - return $c; |
|
| 466 | - } |
|
| 465 | + return $c; |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - unset($_GET[$var]); |
|
| 469 | - unset($_POST[$var]); |
|
| 470 | - if ($val !== null) { |
|
| 471 | - $_GET[$var] = $val; |
|
| 472 | - } |
|
| 468 | + unset($_GET[$var]); |
|
| 469 | + unset($_POST[$var]); |
|
| 470 | + if ($val !== null) { |
|
| 471 | + $_GET[$var] = $val; |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | - return false; # n'affecte pas $c |
|
| 474 | + return false; # n'affecte pas $c |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -491,25 +491,25 @@ discard block |
||
| 491 | 491 | * @return array|mixed|string |
| 492 | 492 | */ |
| 493 | 493 | function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') { |
| 494 | - if (is_array($value)) { |
|
| 495 | - if ($key=='*') { |
|
| 496 | - $key = array_keys($value); |
|
| 497 | - } |
|
| 498 | - if (!is_array($key)) { |
|
| 499 | - $key = [$key]; |
|
| 500 | - } |
|
| 501 | - foreach ($key as $k) { |
|
| 502 | - if (!empty($value[$k])) { |
|
| 503 | - $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - return $value; |
|
| 507 | - } |
|
| 508 | - // si la valeur vient des GET ou POST on la sanitize |
|
| 509 | - if (!empty($value) and $value == _request($key)) { |
|
| 510 | - $value = $sanitize_function($value); |
|
| 511 | - } |
|
| 512 | - return $value; |
|
| 494 | + if (is_array($value)) { |
|
| 495 | + if ($key=='*') { |
|
| 496 | + $key = array_keys($value); |
|
| 497 | + } |
|
| 498 | + if (!is_array($key)) { |
|
| 499 | + $key = [$key]; |
|
| 500 | + } |
|
| 501 | + foreach ($key as $k) { |
|
| 502 | + if (!empty($value[$k])) { |
|
| 503 | + $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + return $value; |
|
| 507 | + } |
|
| 508 | + // si la valeur vient des GET ou POST on la sanitize |
|
| 509 | + if (!empty($value) and $value == _request($key)) { |
|
| 510 | + $value = $sanitize_function($value); |
|
| 511 | + } |
|
| 512 | + return $value; |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** |
@@ -517,23 +517,22 @@ discard block |
||
| 517 | 517 | * |
| 518 | 518 | * On est sur le web, on exclut certains protocoles, |
| 519 | 519 | * notamment 'file://', 'php://' et d'autres… |
| 520 | - |
|
| 521 | 520 | * @param string $url |
| 522 | 521 | * @return bool |
| 523 | 522 | */ |
| 524 | 523 | function tester_url_absolue($url) { |
| 525 | - $url = trim($url); |
|
| 526 | - if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 527 | - if ( |
|
| 528 | - isset($m[1]) |
|
| 529 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 530 | - and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 531 | - ) { |
|
| 532 | - return false; |
|
| 533 | - } |
|
| 534 | - return true; |
|
| 535 | - } |
|
| 536 | - return false; |
|
| 524 | + $url = trim($url); |
|
| 525 | + if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 526 | + if ( |
|
| 527 | + isset($m[1]) |
|
| 528 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 529 | + and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 530 | + ) { |
|
| 531 | + return false; |
|
| 532 | + } |
|
| 533 | + return true; |
|
| 534 | + } |
|
| 535 | + return false; |
|
| 537 | 536 | } |
| 538 | 537 | |
| 539 | 538 | /** |
@@ -555,94 +554,94 @@ discard block |
||
| 555 | 554 | * @return string URL |
| 556 | 555 | */ |
| 557 | 556 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 558 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 559 | - if (strpos($c, "|") !== false and is_null($v)) { |
|
| 560 | - return null; |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - // lever l'#ancre |
|
| 564 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 565 | - $url = $r[1]; |
|
| 566 | - $ancre = $r[2]; |
|
| 567 | - } else { |
|
| 568 | - $ancre = ''; |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - // eclater |
|
| 572 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 573 | - |
|
| 574 | - // recuperer la base |
|
| 575 | - $a = array_shift($url); |
|
| 576 | - if (!$a) { |
|
| 577 | - $a = './'; |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 581 | - $ajouts = array_flip(explode('|', $c)); |
|
| 582 | - $u = is_array($v) ? $v : rawurlencode($v); |
|
| 583 | - $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 584 | - $v_read = null; |
|
| 585 | - // lire les variables et agir |
|
| 586 | - foreach ($url as $n => $val) { |
|
| 587 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 588 | - $r = array_pad($r, 3, null); |
|
| 589 | - if ($v === null) { |
|
| 590 | - // c'est un tableau, on memorise les valeurs |
|
| 591 | - if (substr($r[1], -2) == "[]") { |
|
| 592 | - if (!$v_read) { |
|
| 593 | - $v_read = array(); |
|
| 594 | - } |
|
| 595 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 596 | - } // c'est un scalaire, on retourne direct |
|
| 597 | - else { |
|
| 598 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 599 | - } |
|
| 600 | - } // suppression |
|
| 601 | - elseif (!$testv) { |
|
| 602 | - unset($url[$n]); |
|
| 603 | - } |
|
| 604 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 605 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 606 | - elseif (substr($r[1], -2) != '[]') { |
|
| 607 | - $url[$n] = $r[1] . '=' . $u; |
|
| 608 | - unset($ajouts[$r[1]]); |
|
| 609 | - } |
|
| 610 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 611 | - // départ, on remplira à l'étape suivante |
|
| 612 | - else { |
|
| 613 | - unset($url[$n]); |
|
| 614 | - } |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - // traiter les parametres pas encore trouves |
|
| 619 | - if ($v === null |
|
| 620 | - and $args = func_get_args() |
|
| 621 | - and count($args) == 2 |
|
| 622 | - ) { |
|
| 623 | - return $v_read; // rien trouve ou un tableau |
|
| 624 | - } elseif ($testv) { |
|
| 625 | - foreach ($ajouts as $k => $n) { |
|
| 626 | - if (!is_array($v)) { |
|
| 627 | - $url[] = $k . '=' . $u; |
|
| 628 | - } else { |
|
| 629 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 630 | - foreach ($v as $w) { |
|
| 631 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 632 | - } |
|
| 633 | - } |
|
| 634 | - } |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - // eliminer les vides |
|
| 638 | - $url = array_filter($url); |
|
| 639 | - |
|
| 640 | - // recomposer l'adresse |
|
| 641 | - if ($url) { |
|
| 642 | - $a .= '?' . join($sep, $url); |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - return $a . $ancre; |
|
| 557 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 558 | + if (strpos($c, "|") !== false and is_null($v)) { |
|
| 559 | + return null; |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + // lever l'#ancre |
|
| 563 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 564 | + $url = $r[1]; |
|
| 565 | + $ancre = $r[2]; |
|
| 566 | + } else { |
|
| 567 | + $ancre = ''; |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + // eclater |
|
| 571 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 572 | + |
|
| 573 | + // recuperer la base |
|
| 574 | + $a = array_shift($url); |
|
| 575 | + if (!$a) { |
|
| 576 | + $a = './'; |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 580 | + $ajouts = array_flip(explode('|', $c)); |
|
| 581 | + $u = is_array($v) ? $v : rawurlencode($v); |
|
| 582 | + $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 583 | + $v_read = null; |
|
| 584 | + // lire les variables et agir |
|
| 585 | + foreach ($url as $n => $val) { |
|
| 586 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 587 | + $r = array_pad($r, 3, null); |
|
| 588 | + if ($v === null) { |
|
| 589 | + // c'est un tableau, on memorise les valeurs |
|
| 590 | + if (substr($r[1], -2) == "[]") { |
|
| 591 | + if (!$v_read) { |
|
| 592 | + $v_read = array(); |
|
| 593 | + } |
|
| 594 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 595 | + } // c'est un scalaire, on retourne direct |
|
| 596 | + else { |
|
| 597 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 598 | + } |
|
| 599 | + } // suppression |
|
| 600 | + elseif (!$testv) { |
|
| 601 | + unset($url[$n]); |
|
| 602 | + } |
|
| 603 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 604 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 605 | + elseif (substr($r[1], -2) != '[]') { |
|
| 606 | + $url[$n] = $r[1] . '=' . $u; |
|
| 607 | + unset($ajouts[$r[1]]); |
|
| 608 | + } |
|
| 609 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 610 | + // départ, on remplira à l'étape suivante |
|
| 611 | + else { |
|
| 612 | + unset($url[$n]); |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + // traiter les parametres pas encore trouves |
|
| 618 | + if ($v === null |
|
| 619 | + and $args = func_get_args() |
|
| 620 | + and count($args) == 2 |
|
| 621 | + ) { |
|
| 622 | + return $v_read; // rien trouve ou un tableau |
|
| 623 | + } elseif ($testv) { |
|
| 624 | + foreach ($ajouts as $k => $n) { |
|
| 625 | + if (!is_array($v)) { |
|
| 626 | + $url[] = $k . '=' . $u; |
|
| 627 | + } else { |
|
| 628 | + $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 629 | + foreach ($v as $w) { |
|
| 630 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 631 | + } |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + // eliminer les vides |
|
| 637 | + $url = array_filter($url); |
|
| 638 | + |
|
| 639 | + // recomposer l'adresse |
|
| 640 | + if ($url) { |
|
| 641 | + $a .= '?' . join($sep, $url); |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + return $a . $ancre; |
|
| 646 | 645 | } |
| 647 | 646 | |
| 648 | 647 | /** |
@@ -660,21 +659,21 @@ discard block |
||
| 660 | 659 | * @return string |
| 661 | 660 | */ |
| 662 | 661 | function ancre_url($url, $ancre) { |
| 663 | - // lever l'#ancre |
|
| 664 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 665 | - $url = $r[1]; |
|
| 666 | - } |
|
| 667 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 668 | - if (!function_exists('translitteration')) { |
|
| 669 | - include_spip('inc/charsets'); |
|
| 670 | - } |
|
| 671 | - $ancre = preg_replace( |
|
| 672 | - array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 673 | - array('', '-'), |
|
| 674 | - translitteration($ancre) |
|
| 675 | - ); |
|
| 676 | - } |
|
| 677 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 662 | + // lever l'#ancre |
|
| 663 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 664 | + $url = $r[1]; |
|
| 665 | + } |
|
| 666 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 667 | + if (!function_exists('translitteration')) { |
|
| 668 | + include_spip('inc/charsets'); |
|
| 669 | + } |
|
| 670 | + $ancre = preg_replace( |
|
| 671 | + array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 672 | + array('', '-'), |
|
| 673 | + translitteration($ancre) |
|
| 674 | + ); |
|
| 675 | + } |
|
| 676 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 678 | 677 | } |
| 679 | 678 | |
| 680 | 679 | /** |
@@ -684,16 +683,16 @@ discard block |
||
| 684 | 683 | * @return string |
| 685 | 684 | */ |
| 686 | 685 | function nettoyer_uri($reset = null) { |
| 687 | - static $done = false; |
|
| 688 | - static $propre = ''; |
|
| 689 | - if (!is_null($reset)) { |
|
| 690 | - return $propre = $reset; |
|
| 691 | - } |
|
| 692 | - if ($done) { |
|
| 693 | - return $propre; |
|
| 694 | - } |
|
| 695 | - $done = true; |
|
| 696 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 686 | + static $done = false; |
|
| 687 | + static $propre = ''; |
|
| 688 | + if (!is_null($reset)) { |
|
| 689 | + return $propre = $reset; |
|
| 690 | + } |
|
| 691 | + if ($done) { |
|
| 692 | + return $propre; |
|
| 693 | + } |
|
| 694 | + $done = true; |
|
| 695 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 697 | 696 | } |
| 698 | 697 | |
| 699 | 698 | /** |
@@ -705,13 +704,13 @@ discard block |
||
| 705 | 704 | * @return string |
| 706 | 705 | */ |
| 707 | 706 | function nettoyer_uri_var($request_uri) { |
| 708 | - $uri1 = $request_uri; |
|
| 709 | - do { |
|
| 710 | - $uri = $uri1; |
|
| 711 | - $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 712 | - '\1', $uri); |
|
| 713 | - } while ($uri <> $uri1); |
|
| 714 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 707 | + $uri1 = $request_uri; |
|
| 708 | + do { |
|
| 709 | + $uri = $uri1; |
|
| 710 | + $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 711 | + '\1', $uri); |
|
| 712 | + } while ($uri <> $uri1); |
|
| 713 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 715 | 714 | } |
| 716 | 715 | |
| 717 | 716 | |
@@ -725,47 +724,47 @@ discard block |
||
| 725 | 724 | * URL vers soi-même |
| 726 | 725 | **/ |
| 727 | 726 | function self($amp = '&', $root = false) { |
| 728 | - $url = nettoyer_uri(); |
|
| 729 | - if (!$root |
|
| 730 | - and ( |
|
| 731 | - // si pas de profondeur on peut tronquer |
|
| 732 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 733 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 734 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 735 | - ) { |
|
| 736 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 737 | - } |
|
| 738 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 739 | - foreach ($_POST as $v => $c) { |
|
| 740 | - if (substr($v, 0, 3) == 'id_') { |
|
| 741 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 742 | - } |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - // supprimer les variables sans interet |
|
| 746 | - if (test_espace_prive()) { |
|
| 747 | - $url = preg_replace(',([?&])(' |
|
| 748 | - . 'lang|show_docs|' |
|
| 749 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 750 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 751 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 752 | - } |
|
| 753 | - |
|
| 754 | - // eviter les hacks |
|
| 755 | - include_spip('inc/filtres_mini'); |
|
| 756 | - $url = spip_htmlspecialchars($url); |
|
| 727 | + $url = nettoyer_uri(); |
|
| 728 | + if (!$root |
|
| 729 | + and ( |
|
| 730 | + // si pas de profondeur on peut tronquer |
|
| 731 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 732 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 733 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 734 | + ) { |
|
| 735 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 736 | + } |
|
| 737 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 738 | + foreach ($_POST as $v => $c) { |
|
| 739 | + if (substr($v, 0, 3) == 'id_') { |
|
| 740 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + // supprimer les variables sans interet |
|
| 745 | + if (test_espace_prive()) { |
|
| 746 | + $url = preg_replace(',([?&])(' |
|
| 747 | + . 'lang|show_docs|' |
|
| 748 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 749 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 750 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + // eviter les hacks |
|
| 754 | + include_spip('inc/filtres_mini'); |
|
| 755 | + $url = spip_htmlspecialchars($url); |
|
| 757 | 756 | |
| 758 | - $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 757 | + $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 759 | 758 | |
| 760 | - // & ? |
|
| 761 | - if ($amp != '&') { |
|
| 762 | - $url = str_replace('&', $amp, $url); |
|
| 763 | - } |
|
| 759 | + // & ? |
|
| 760 | + if ($amp != '&') { |
|
| 761 | + $url = str_replace('&', $amp, $url); |
|
| 762 | + } |
|
| 764 | 763 | |
| 765 | - // Si ca demarre par ? ou vide, donner './' |
|
| 766 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 764 | + // Si ca demarre par ? ou vide, donner './' |
|
| 765 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 767 | 766 | |
| 768 | - return $url; |
|
| 767 | + return $url; |
|
| 769 | 768 | } |
| 770 | 769 | |
| 771 | 770 | |
@@ -776,7 +775,7 @@ discard block |
||
| 776 | 775 | * true si c'est le cas, false sinon. |
| 777 | 776 | */ |
| 778 | 777 | function test_espace_prive() { |
| 779 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 778 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 780 | 779 | } |
| 781 | 780 | |
| 782 | 781 | /** |
@@ -786,7 +785,7 @@ discard block |
||
| 786 | 785 | * @return bool |
| 787 | 786 | */ |
| 788 | 787 | function test_plugin_actif($plugin) { |
| 789 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 788 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 790 | 789 | } |
| 791 | 790 | |
| 792 | 791 | /** |
@@ -817,51 +816,51 @@ discard block |
||
| 817 | 816 | * Texte |
| 818 | 817 | */ |
| 819 | 818 | function _T($texte, $args = array(), $options = array()) { |
| 820 | - static $traduire = false; |
|
| 821 | - $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 822 | - if ($options) { |
|
| 823 | - // support de l'ancien argument $class |
|
| 824 | - if (is_string($options)) { |
|
| 825 | - $options = array('class' => $options); |
|
| 826 | - } |
|
| 827 | - $o = array_merge($o, $options); |
|
| 828 | - } |
|
| 819 | + static $traduire = false; |
|
| 820 | + $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 821 | + if ($options) { |
|
| 822 | + // support de l'ancien argument $class |
|
| 823 | + if (is_string($options)) { |
|
| 824 | + $options = array('class' => $options); |
|
| 825 | + } |
|
| 826 | + $o = array_merge($o, $options); |
|
| 827 | + } |
|
| 829 | 828 | |
| 830 | - if (!$traduire) { |
|
| 831 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 832 | - include_spip('inc/lang'); |
|
| 833 | - } |
|
| 829 | + if (!$traduire) { |
|
| 830 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 831 | + include_spip('inc/lang'); |
|
| 832 | + } |
|
| 834 | 833 | |
| 835 | - // On peut passer explicitement la langue dans le tableau |
|
| 836 | - // On utilise le même nom de variable que la globale |
|
| 837 | - if (isset($args['spip_lang'])) { |
|
| 838 | - $lang = $args['spip_lang']; |
|
| 839 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 840 | - unset($args['spip_lang']); |
|
| 841 | - } // Sinon on prend la langue du contexte |
|
| 842 | - else { |
|
| 843 | - $lang = $GLOBALS['spip_lang']; |
|
| 844 | - } |
|
| 845 | - $text = $traduire($texte, $lang); |
|
| 834 | + // On peut passer explicitement la langue dans le tableau |
|
| 835 | + // On utilise le même nom de variable que la globale |
|
| 836 | + if (isset($args['spip_lang'])) { |
|
| 837 | + $lang = $args['spip_lang']; |
|
| 838 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 839 | + unset($args['spip_lang']); |
|
| 840 | + } // Sinon on prend la langue du contexte |
|
| 841 | + else { |
|
| 842 | + $lang = $GLOBALS['spip_lang']; |
|
| 843 | + } |
|
| 844 | + $text = $traduire($texte, $lang); |
|
| 846 | 845 | |
| 847 | - if (!strlen($text)) { |
|
| 848 | - if (!$o['force']) { |
|
| 849 | - return ''; |
|
| 850 | - } |
|
| 846 | + if (!strlen($text)) { |
|
| 847 | + if (!$o['force']) { |
|
| 848 | + return ''; |
|
| 849 | + } |
|
| 851 | 850 | |
| 852 | - $text = $texte; |
|
| 851 | + $text = $texte; |
|
| 853 | 852 | |
| 854 | - // pour les chaines non traduites, assurer un service minimum |
|
| 855 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 856 | - $text = str_replace('_', ' ', |
|
| 857 | - (($n = strpos($text, ':')) === false ? $texte : |
|
| 858 | - substr($texte, $n + 1))); |
|
| 859 | - } |
|
| 860 | - $o['class'] = null; |
|
| 853 | + // pour les chaines non traduites, assurer un service minimum |
|
| 854 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 855 | + $text = str_replace('_', ' ', |
|
| 856 | + (($n = strpos($text, ':')) === false ? $texte : |
|
| 857 | + substr($texte, $n + 1))); |
|
| 858 | + } |
|
| 859 | + $o['class'] = null; |
|
| 861 | 860 | |
| 862 | - } |
|
| 861 | + } |
|
| 863 | 862 | |
| 864 | - return _L($text, $args, $o); |
|
| 863 | + return _L($text, $args, $o); |
|
| 865 | 864 | |
| 866 | 865 | } |
| 867 | 866 | |
@@ -889,53 +888,53 @@ discard block |
||
| 889 | 888 | * Texte |
| 890 | 889 | */ |
| 891 | 890 | function _L($text, $args = array(), $options = array()) { |
| 892 | - $f = $text; |
|
| 893 | - $defaut_options = array( |
|
| 894 | - 'class' => null, |
|
| 895 | - 'sanitize' => true, |
|
| 896 | - ); |
|
| 897 | - // support de l'ancien argument $class |
|
| 898 | - if ($options and is_string($options)) { |
|
| 899 | - $options = array('class' => $options); |
|
| 900 | - } |
|
| 901 | - if (is_array($options)) { |
|
| 902 | - $options += $defaut_options; |
|
| 903 | - } else { |
|
| 904 | - $options = $defaut_options; |
|
| 905 | - } |
|
| 906 | - |
|
| 907 | - if (is_array($args) and count($args)) { |
|
| 908 | - if (!function_exists('interdire_scripts')) { |
|
| 909 | - include_spip('inc/texte'); |
|
| 910 | - } |
|
| 911 | - if (!function_exists('echapper_html_suspect')) { |
|
| 912 | - include_spip('inc/texte_mini'); |
|
| 913 | - } |
|
| 914 | - foreach ($args as $name => $value) { |
|
| 915 | - if (strpos($text, "@$name@") !== false) { |
|
| 916 | - if ($options['sanitize']) { |
|
| 917 | - $value = echapper_html_suspect($value); |
|
| 918 | - $value = interdire_scripts($value, -1); |
|
| 919 | - } |
|
| 920 | - if (!empty($options['class'])) { |
|
| 921 | - $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 922 | - } |
|
| 923 | - $text = str_replace("@$name@", $value, $text); |
|
| 924 | - unset($args[$name]); |
|
| 925 | - } |
|
| 926 | - } |
|
| 927 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 928 | - // (chaines de langues pas a jour) |
|
| 929 | - if ($args) { |
|
| 930 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 931 | - } |
|
| 932 | - } |
|
| 933 | - |
|
| 934 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 935 | - return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 936 | - } else { |
|
| 937 | - return $text; |
|
| 938 | - } |
|
| 891 | + $f = $text; |
|
| 892 | + $defaut_options = array( |
|
| 893 | + 'class' => null, |
|
| 894 | + 'sanitize' => true, |
|
| 895 | + ); |
|
| 896 | + // support de l'ancien argument $class |
|
| 897 | + if ($options and is_string($options)) { |
|
| 898 | + $options = array('class' => $options); |
|
| 899 | + } |
|
| 900 | + if (is_array($options)) { |
|
| 901 | + $options += $defaut_options; |
|
| 902 | + } else { |
|
| 903 | + $options = $defaut_options; |
|
| 904 | + } |
|
| 905 | + |
|
| 906 | + if (is_array($args) and count($args)) { |
|
| 907 | + if (!function_exists('interdire_scripts')) { |
|
| 908 | + include_spip('inc/texte'); |
|
| 909 | + } |
|
| 910 | + if (!function_exists('echapper_html_suspect')) { |
|
| 911 | + include_spip('inc/texte_mini'); |
|
| 912 | + } |
|
| 913 | + foreach ($args as $name => $value) { |
|
| 914 | + if (strpos($text, "@$name@") !== false) { |
|
| 915 | + if ($options['sanitize']) { |
|
| 916 | + $value = echapper_html_suspect($value); |
|
| 917 | + $value = interdire_scripts($value, -1); |
|
| 918 | + } |
|
| 919 | + if (!empty($options['class'])) { |
|
| 920 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 921 | + } |
|
| 922 | + $text = str_replace("@$name@", $value, $text); |
|
| 923 | + unset($args[$name]); |
|
| 924 | + } |
|
| 925 | + } |
|
| 926 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 927 | + // (chaines de langues pas a jour) |
|
| 928 | + if ($args) { |
|
| 929 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 930 | + } |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 934 | + return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 935 | + } else { |
|
| 936 | + return $text; |
|
| 937 | + } |
|
| 939 | 938 | } |
| 940 | 939 | |
| 941 | 940 | |
@@ -949,13 +948,13 @@ discard block |
||
| 949 | 948 | * @return string |
| 950 | 949 | */ |
| 951 | 950 | function joli_repertoire($rep) { |
| 952 | - $a = substr($rep, 0, 1); |
|
| 953 | - if ($a <> '.' and $a <> '/') { |
|
| 954 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 955 | - } |
|
| 956 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 951 | + $a = substr($rep, 0, 1); |
|
| 952 | + if ($a <> '.' and $a <> '/') { |
|
| 953 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 954 | + } |
|
| 955 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 957 | 956 | |
| 958 | - return $rep; |
|
| 957 | + return $rep; |
|
| 959 | 958 | } |
| 960 | 959 | |
| 961 | 960 | |
@@ -980,33 +979,33 @@ discard block |
||
| 980 | 979 | * @return float|int|string|void |
| 981 | 980 | */ |
| 982 | 981 | function spip_timer($t = 'rien', $raw = false) { |
| 983 | - static $time; |
|
| 984 | - $a = time(); |
|
| 985 | - $b = microtime(); |
|
| 986 | - // microtime peut contenir les microsecondes et le temps |
|
| 987 | - $b = explode(' ', $b); |
|
| 988 | - if (count($b) == 2) { |
|
| 989 | - $a = end($b); |
|
| 990 | - } // plus precis ! |
|
| 991 | - $b = reset($b); |
|
| 992 | - if (!isset($time[$t])) { |
|
| 993 | - $time[$t] = $a + $b; |
|
| 994 | - } else { |
|
| 995 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 996 | - unset($time[$t]); |
|
| 982 | + static $time; |
|
| 983 | + $a = time(); |
|
| 984 | + $b = microtime(); |
|
| 985 | + // microtime peut contenir les microsecondes et le temps |
|
| 986 | + $b = explode(' ', $b); |
|
| 987 | + if (count($b) == 2) { |
|
| 988 | + $a = end($b); |
|
| 989 | + } // plus precis ! |
|
| 990 | + $b = reset($b); |
|
| 991 | + if (!isset($time[$t])) { |
|
| 992 | + $time[$t] = $a + $b; |
|
| 993 | + } else { |
|
| 994 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 995 | + unset($time[$t]); |
|
| 997 | 996 | # echo "'$p'";exit; |
| 998 | - if ($raw) { |
|
| 999 | - return $p; |
|
| 1000 | - } |
|
| 1001 | - if ($p < 1000) { |
|
| 1002 | - $s = ''; |
|
| 1003 | - } else { |
|
| 1004 | - $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 1005 | - $p -= ($x * 1000); |
|
| 1006 | - } |
|
| 997 | + if ($raw) { |
|
| 998 | + return $p; |
|
| 999 | + } |
|
| 1000 | + if ($p < 1000) { |
|
| 1001 | + $s = ''; |
|
| 1002 | + } else { |
|
| 1003 | + $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 1004 | + $p -= ($x * 1000); |
|
| 1005 | + } |
|
| 1007 | 1006 | |
| 1008 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1009 | - } |
|
| 1007 | + return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1008 | + } |
|
| 1010 | 1009 | } |
| 1011 | 1010 | |
| 1012 | 1011 | |
@@ -1014,21 +1013,21 @@ discard block |
||
| 1014 | 1013 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 1015 | 1014 | // https://code.spip.net/@spip_touch |
| 1016 | 1015 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 1017 | - if ($duree) { |
|
| 1018 | - clearstatcache(); |
|
| 1019 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1020 | - return false; |
|
| 1021 | - } |
|
| 1022 | - } |
|
| 1023 | - if ($touch !== false) { |
|
| 1024 | - if (!@touch($fichier)) { |
|
| 1025 | - spip_unlink($fichier); |
|
| 1026 | - @touch($fichier); |
|
| 1027 | - }; |
|
| 1028 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1029 | - } |
|
| 1016 | + if ($duree) { |
|
| 1017 | + clearstatcache(); |
|
| 1018 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1019 | + return false; |
|
| 1020 | + } |
|
| 1021 | + } |
|
| 1022 | + if ($touch !== false) { |
|
| 1023 | + if (!@touch($fichier)) { |
|
| 1024 | + spip_unlink($fichier); |
|
| 1025 | + @touch($fichier); |
|
| 1026 | + }; |
|
| 1027 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1028 | + } |
|
| 1030 | 1029 | |
| 1031 | - return true; |
|
| 1030 | + return true; |
|
| 1032 | 1031 | } |
| 1033 | 1032 | |
| 1034 | 1033 | |
@@ -1040,11 +1039,11 @@ discard block |
||
| 1040 | 1039 | * @uses cron() |
| 1041 | 1040 | **/ |
| 1042 | 1041 | function action_cron() { |
| 1043 | - include_spip('inc/headers'); |
|
| 1044 | - http_status(204); // No Content |
|
| 1045 | - header("Connection: close"); |
|
| 1046 | - define('_DIRECT_CRON_FORCE', true); |
|
| 1047 | - cron(); |
|
| 1042 | + include_spip('inc/headers'); |
|
| 1043 | + http_status(204); // No Content |
|
| 1044 | + header("Connection: close"); |
|
| 1045 | + define('_DIRECT_CRON_FORCE', true); |
|
| 1046 | + cron(); |
|
| 1048 | 1047 | } |
| 1049 | 1048 | |
| 1050 | 1049 | /** |
@@ -1060,26 +1059,26 @@ discard block |
||
| 1060 | 1059 | * True si la tache a pu être effectuée |
| 1061 | 1060 | */ |
| 1062 | 1061 | function cron($taches = array(), $taches_old = array()) { |
| 1063 | - // si pas en mode cron force, laisser tomber. |
|
| 1064 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1065 | - return false; |
|
| 1066 | - } |
|
| 1067 | - if (!is_array($taches)) { |
|
| 1068 | - $taches = $taches_old; |
|
| 1069 | - } // compat anciens appels |
|
| 1070 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1071 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1072 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1073 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1074 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1075 | - return false; |
|
| 1076 | - } |
|
| 1077 | - spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1078 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1079 | - return $genie($taches); |
|
| 1080 | - } |
|
| 1081 | - |
|
| 1082 | - return false; |
|
| 1062 | + // si pas en mode cron force, laisser tomber. |
|
| 1063 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1064 | + return false; |
|
| 1065 | + } |
|
| 1066 | + if (!is_array($taches)) { |
|
| 1067 | + $taches = $taches_old; |
|
| 1068 | + } // compat anciens appels |
|
| 1069 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1070 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1071 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1072 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1073 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1074 | + return false; |
|
| 1075 | + } |
|
| 1076 | + spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1077 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1078 | + return $genie($taches); |
|
| 1079 | + } |
|
| 1080 | + |
|
| 1081 | + return false; |
|
| 1083 | 1082 | } |
| 1084 | 1083 | |
| 1085 | 1084 | /** |
@@ -1111,17 +1110,17 @@ discard block |
||
| 1111 | 1110 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1112 | 1111 | */ |
| 1113 | 1112 | function job_queue_add( |
| 1114 | - $function, |
|
| 1115 | - $description, |
|
| 1116 | - $arguments = array(), |
|
| 1117 | - $file = '', |
|
| 1118 | - $no_duplicate = false, |
|
| 1119 | - $time = 0, |
|
| 1120 | - $priority = 0 |
|
| 1113 | + $function, |
|
| 1114 | + $description, |
|
| 1115 | + $arguments = array(), |
|
| 1116 | + $file = '', |
|
| 1117 | + $no_duplicate = false, |
|
| 1118 | + $time = 0, |
|
| 1119 | + $priority = 0 |
|
| 1121 | 1120 | ) { |
| 1122 | - include_spip('inc/queue'); |
|
| 1121 | + include_spip('inc/queue'); |
|
| 1123 | 1122 | |
| 1124 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1123 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1125 | 1124 | } |
| 1126 | 1125 | |
| 1127 | 1126 | /** |
@@ -1132,9 +1131,9 @@ discard block |
||
| 1132 | 1131 | * @return bool |
| 1133 | 1132 | */ |
| 1134 | 1133 | function job_queue_remove($id_job) { |
| 1135 | - include_spip('inc/queue'); |
|
| 1134 | + include_spip('inc/queue'); |
|
| 1136 | 1135 | |
| 1137 | - return queue_remove_job($id_job); |
|
| 1136 | + return queue_remove_job($id_job); |
|
| 1138 | 1137 | } |
| 1139 | 1138 | |
| 1140 | 1139 | /** |
@@ -1147,9 +1146,9 @@ discard block |
||
| 1147 | 1146 | * or an array of simple array to link multiples objet in one time |
| 1148 | 1147 | */ |
| 1149 | 1148 | function job_queue_link($id_job, $objets) { |
| 1150 | - include_spip('inc/queue'); |
|
| 1149 | + include_spip('inc/queue'); |
|
| 1151 | 1150 | |
| 1152 | - return queue_link_job($id_job, $objets); |
|
| 1151 | + return queue_link_job($id_job, $objets); |
|
| 1153 | 1152 | } |
| 1154 | 1153 | |
| 1155 | 1154 | |
@@ -1169,36 +1168,36 @@ discard block |
||
| 1169 | 1168 | * - `null` si la queue n'est pas encore initialisée |
| 1170 | 1169 | */ |
| 1171 | 1170 | function queue_sleep_time_to_next_job($force = null) { |
| 1172 | - static $queue_next_job_time = -1; |
|
| 1173 | - if ($force === true) { |
|
| 1174 | - $queue_next_job_time = -1; |
|
| 1175 | - } elseif ($force) { |
|
| 1176 | - $queue_next_job_time = $force; |
|
| 1177 | - } |
|
| 1178 | - |
|
| 1179 | - if ($queue_next_job_time == -1) { |
|
| 1180 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1181 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1182 | - } |
|
| 1183 | - // utiliser un cache memoire si dispo |
|
| 1184 | - if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1185 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1186 | - } else { |
|
| 1187 | - $queue_next_job_time = null; |
|
| 1188 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1189 | - $queue_next_job_time = intval($contenu); |
|
| 1190 | - } |
|
| 1191 | - } |
|
| 1192 | - } |
|
| 1193 | - |
|
| 1194 | - if (is_null($queue_next_job_time)) { |
|
| 1195 | - return null; |
|
| 1196 | - } |
|
| 1197 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1198 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1199 | - } |
|
| 1200 | - |
|
| 1201 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1171 | + static $queue_next_job_time = -1; |
|
| 1172 | + if ($force === true) { |
|
| 1173 | + $queue_next_job_time = -1; |
|
| 1174 | + } elseif ($force) { |
|
| 1175 | + $queue_next_job_time = $force; |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + if ($queue_next_job_time == -1) { |
|
| 1179 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1180 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1181 | + } |
|
| 1182 | + // utiliser un cache memoire si dispo |
|
| 1183 | + if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1184 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1185 | + } else { |
|
| 1186 | + $queue_next_job_time = null; |
|
| 1187 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1188 | + $queue_next_job_time = intval($contenu); |
|
| 1189 | + } |
|
| 1190 | + } |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + if (is_null($queue_next_job_time)) { |
|
| 1194 | + return null; |
|
| 1195 | + } |
|
| 1196 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1197 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1198 | + } |
|
| 1199 | + |
|
| 1200 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1202 | 1201 | } |
| 1203 | 1202 | |
| 1204 | 1203 | |
@@ -1210,9 +1209,9 @@ discard block |
||
| 1210 | 1209 | * @return string |
| 1211 | 1210 | */ |
| 1212 | 1211 | function quote_amp($u) { |
| 1213 | - return preg_replace( |
|
| 1214 | - "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1215 | - "&", $u); |
|
| 1212 | + return preg_replace( |
|
| 1213 | + "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1214 | + "&", $u); |
|
| 1216 | 1215 | } |
| 1217 | 1216 | |
| 1218 | 1217 | |
@@ -1235,27 +1234,27 @@ discard block |
||
| 1235 | 1234 | * Balise HTML `<script>` et son contenu |
| 1236 | 1235 | **/ |
| 1237 | 1236 | function http_script($script, $src = '', $noscript = '') { |
| 1238 | - static $done = array(); |
|
| 1237 | + static $done = array(); |
|
| 1239 | 1238 | |
| 1240 | - if ($src && !isset($done[$src])) { |
|
| 1241 | - $done[$src] = true; |
|
| 1242 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1243 | - $src = " src='$src'"; |
|
| 1244 | - } else { |
|
| 1245 | - $src = ''; |
|
| 1246 | - } |
|
| 1247 | - if ($script) { |
|
| 1248 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1249 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1250 | - "/*]]>*/"); |
|
| 1251 | - } |
|
| 1252 | - if ($noscript) { |
|
| 1253 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1254 | - } |
|
| 1239 | + if ($src && !isset($done[$src])) { |
|
| 1240 | + $done[$src] = true; |
|
| 1241 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1242 | + $src = " src='$src'"; |
|
| 1243 | + } else { |
|
| 1244 | + $src = ''; |
|
| 1245 | + } |
|
| 1246 | + if ($script) { |
|
| 1247 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1248 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1249 | + "/*]]>*/"); |
|
| 1250 | + } |
|
| 1251 | + if ($noscript) { |
|
| 1252 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1253 | + } |
|
| 1255 | 1254 | |
| 1256 | - return ($src or $script or $noscript) |
|
| 1257 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1258 | - : ''; |
|
| 1255 | + return ($src or $script or $noscript) |
|
| 1256 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1257 | + : ''; |
|
| 1259 | 1258 | } |
| 1260 | 1259 | |
| 1261 | 1260 | |
@@ -1290,7 +1289,7 @@ discard block |
||
| 1290 | 1289 | * Texte échappé |
| 1291 | 1290 | **/ |
| 1292 | 1291 | function texte_script($texte) { |
| 1293 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1292 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1294 | 1293 | } |
| 1295 | 1294 | |
| 1296 | 1295 | |
@@ -1327,69 +1326,69 @@ discard block |
||
| 1327 | 1326 | * Liste des chemins, par ordre de priorité. |
| 1328 | 1327 | **/ |
| 1329 | 1328 | function _chemin($dir_path = null) { |
| 1330 | - static $path_base = null; |
|
| 1331 | - static $path_full = null; |
|
| 1332 | - if ($path_base == null) { |
|
| 1333 | - // Chemin standard depuis l'espace public |
|
| 1334 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1335 | - _DIR_RACINE . ':' . |
|
| 1336 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1337 | - _DIR_RACINE . 'prive/:' . |
|
| 1338 | - _DIR_RESTREINT; |
|
| 1339 | - // Ajouter squelettes/ |
|
| 1340 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1341 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1342 | - } |
|
| 1343 | - foreach (explode(':', $path) as $dir) { |
|
| 1344 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1345 | - $dir .= "/"; |
|
| 1346 | - } |
|
| 1347 | - $path_base[] = $dir; |
|
| 1348 | - } |
|
| 1349 | - $path_full = $path_base; |
|
| 1350 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1351 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1352 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1353 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1354 | - } |
|
| 1355 | - } |
|
| 1356 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1357 | - } |
|
| 1358 | - if ($dir_path === null) { |
|
| 1359 | - return $path_full; |
|
| 1360 | - } |
|
| 1361 | - |
|
| 1362 | - if (strlen($dir_path)) { |
|
| 1363 | - $tete = ""; |
|
| 1364 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1365 | - $tete = array_shift($path_base); |
|
| 1366 | - } |
|
| 1367 | - $dirs = array_reverse(explode(':', $dir_path)); |
|
| 1368 | - foreach ($dirs as $dir_path) { |
|
| 1369 | - #if ($dir_path{0}!='/') |
|
| 1370 | - # $dir_path = $dir_path; |
|
| 1371 | - if (substr($dir_path, -1) != '/') { |
|
| 1372 | - $dir_path .= "/"; |
|
| 1373 | - } |
|
| 1374 | - if (!in_array($dir_path, $path_base)) { |
|
| 1375 | - array_unshift($path_base, $dir_path); |
|
| 1376 | - } |
|
| 1377 | - } |
|
| 1378 | - if (strlen($tete)) { |
|
| 1379 | - array_unshift($path_base, $tete); |
|
| 1380 | - } |
|
| 1381 | - } |
|
| 1382 | - $path_full = $path_base; |
|
| 1383 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1384 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1385 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1386 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1387 | - } |
|
| 1388 | - } |
|
| 1389 | - |
|
| 1390 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1391 | - |
|
| 1392 | - return $path_full; |
|
| 1329 | + static $path_base = null; |
|
| 1330 | + static $path_full = null; |
|
| 1331 | + if ($path_base == null) { |
|
| 1332 | + // Chemin standard depuis l'espace public |
|
| 1333 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1334 | + _DIR_RACINE . ':' . |
|
| 1335 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1336 | + _DIR_RACINE . 'prive/:' . |
|
| 1337 | + _DIR_RESTREINT; |
|
| 1338 | + // Ajouter squelettes/ |
|
| 1339 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1340 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1341 | + } |
|
| 1342 | + foreach (explode(':', $path) as $dir) { |
|
| 1343 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1344 | + $dir .= "/"; |
|
| 1345 | + } |
|
| 1346 | + $path_base[] = $dir; |
|
| 1347 | + } |
|
| 1348 | + $path_full = $path_base; |
|
| 1349 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1350 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1351 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1352 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1353 | + } |
|
| 1354 | + } |
|
| 1355 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1356 | + } |
|
| 1357 | + if ($dir_path === null) { |
|
| 1358 | + return $path_full; |
|
| 1359 | + } |
|
| 1360 | + |
|
| 1361 | + if (strlen($dir_path)) { |
|
| 1362 | + $tete = ""; |
|
| 1363 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1364 | + $tete = array_shift($path_base); |
|
| 1365 | + } |
|
| 1366 | + $dirs = array_reverse(explode(':', $dir_path)); |
|
| 1367 | + foreach ($dirs as $dir_path) { |
|
| 1368 | + #if ($dir_path{0}!='/') |
|
| 1369 | + # $dir_path = $dir_path; |
|
| 1370 | + if (substr($dir_path, -1) != '/') { |
|
| 1371 | + $dir_path .= "/"; |
|
| 1372 | + } |
|
| 1373 | + if (!in_array($dir_path, $path_base)) { |
|
| 1374 | + array_unshift($path_base, $dir_path); |
|
| 1375 | + } |
|
| 1376 | + } |
|
| 1377 | + if (strlen($tete)) { |
|
| 1378 | + array_unshift($path_base, $tete); |
|
| 1379 | + } |
|
| 1380 | + } |
|
| 1381 | + $path_full = $path_base; |
|
| 1382 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1383 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1384 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1385 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1386 | + } |
|
| 1387 | + } |
|
| 1388 | + |
|
| 1389 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1390 | + |
|
| 1391 | + return $path_full; |
|
| 1393 | 1392 | } |
| 1394 | 1393 | |
| 1395 | 1394 | /** |
@@ -1402,76 +1401,76 @@ discard block |
||
| 1402 | 1401 | * @return array Liste de chemins |
| 1403 | 1402 | **/ |
| 1404 | 1403 | function creer_chemin() { |
| 1405 | - $path_a = _chemin(); |
|
| 1406 | - static $c = ''; |
|
| 1404 | + $path_a = _chemin(); |
|
| 1405 | + static $c = ''; |
|
| 1407 | 1406 | |
| 1408 | - // on calcule le chemin si le dossier skel a change |
|
| 1409 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1410 | - // assurer le non plantage lors de la montee de version : |
|
| 1411 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1412 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1413 | - } |
|
| 1407 | + // on calcule le chemin si le dossier skel a change |
|
| 1408 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1409 | + // assurer le non plantage lors de la montee de version : |
|
| 1410 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1411 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1412 | + } |
|
| 1414 | 1413 | |
| 1415 | - return $path_a; |
|
| 1414 | + return $path_a; |
|
| 1416 | 1415 | } |
| 1417 | 1416 | |
| 1418 | 1417 | |
| 1419 | 1418 | function lister_themes_prives() { |
| 1420 | - static $themes = null; |
|
| 1421 | - if (is_null($themes)) { |
|
| 1422 | - // si pas encore definie |
|
| 1423 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1424 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1425 | - } |
|
| 1426 | - $themes = array(_SPIP_THEME_PRIVE); |
|
| 1427 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1428 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1429 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1430 | - } else { |
|
| 1431 | - $prefs = array(); |
|
| 1432 | - } |
|
| 1433 | - if (is_string($prefs)) { |
|
| 1434 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1435 | - } |
|
| 1436 | - if ( |
|
| 1437 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1438 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1439 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1440 | - ) { |
|
| 1441 | - array_unshift($themes, $theme); |
|
| 1442 | - } // placer le theme choisi en tete |
|
| 1443 | - } |
|
| 1444 | - |
|
| 1445 | - return $themes; |
|
| 1419 | + static $themes = null; |
|
| 1420 | + if (is_null($themes)) { |
|
| 1421 | + // si pas encore definie |
|
| 1422 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1423 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1424 | + } |
|
| 1425 | + $themes = array(_SPIP_THEME_PRIVE); |
|
| 1426 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1427 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1428 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1429 | + } else { |
|
| 1430 | + $prefs = array(); |
|
| 1431 | + } |
|
| 1432 | + if (is_string($prefs)) { |
|
| 1433 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1434 | + } |
|
| 1435 | + if ( |
|
| 1436 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1437 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1438 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1439 | + ) { |
|
| 1440 | + array_unshift($themes, $theme); |
|
| 1441 | + } // placer le theme choisi en tete |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + return $themes; |
|
| 1446 | 1445 | } |
| 1447 | 1446 | |
| 1448 | 1447 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1449 | - static $themefiles = array(); |
|
| 1450 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1451 | - return $themefiles["$subdir$file"]; |
|
| 1452 | - } |
|
| 1453 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1454 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1455 | - if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1456 | - and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1457 | - and $f = find_in_theme("$file_svg_generique")) { |
|
| 1458 | - if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1459 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1460 | - } |
|
| 1461 | - else { |
|
| 1462 | - return $themefiles["$subdir$file"] = "$f?".$m[1]."px"; |
|
| 1463 | - } |
|
| 1464 | - } |
|
| 1465 | - |
|
| 1466 | - $themes = lister_themes_prives(); |
|
| 1467 | - foreach ($themes as $theme) { |
|
| 1468 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1469 | - return $themefiles["$subdir$file"] = $f; |
|
| 1470 | - } |
|
| 1471 | - } |
|
| 1472 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1473 | - |
|
| 1474 | - return $themefiles["$subdir$file"] = ""; |
|
| 1448 | + static $themefiles = array(); |
|
| 1449 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1450 | + return $themefiles["$subdir$file"]; |
|
| 1451 | + } |
|
| 1452 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1453 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1454 | + if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1455 | + and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1456 | + and $f = find_in_theme("$file_svg_generique")) { |
|
| 1457 | + if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1458 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1459 | + } |
|
| 1460 | + else { |
|
| 1461 | + return $themefiles["$subdir$file"] = "$f?".$m[1]."px"; |
|
| 1462 | + } |
|
| 1463 | + } |
|
| 1464 | + |
|
| 1465 | + $themes = lister_themes_prives(); |
|
| 1466 | + foreach ($themes as $theme) { |
|
| 1467 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1468 | + return $themefiles["$subdir$file"] = $f; |
|
| 1469 | + } |
|
| 1470 | + } |
|
| 1471 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1472 | + |
|
| 1473 | + return $themefiles["$subdir$file"] = ""; |
|
| 1475 | 1474 | } |
| 1476 | 1475 | |
| 1477 | 1476 | |
@@ -1495,31 +1494,31 @@ discard block |
||
| 1495 | 1494 | * sinon chaîne vide. |
| 1496 | 1495 | **/ |
| 1497 | 1496 | function chemin_image($icone) { |
| 1498 | - static $icone_renommer; |
|
| 1499 | - if ($p = strpos($icone, '?')) { |
|
| 1500 | - $icone = substr($icone,0, $p); |
|
| 1501 | - } |
|
| 1502 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1503 | - if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1504 | - return $icone; |
|
| 1505 | - } |
|
| 1506 | - |
|
| 1507 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1508 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1509 | - return $f; |
|
| 1510 | - } |
|
| 1511 | - // sinon passer par le module de renommage |
|
| 1512 | - if (is_null($icone_renommer)) { |
|
| 1513 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1514 | - } |
|
| 1515 | - if ($icone_renommer) { |
|
| 1516 | - list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1517 | - if (file_exists($icone)) { |
|
| 1518 | - return $icone; |
|
| 1519 | - } |
|
| 1520 | - } |
|
| 1521 | - |
|
| 1522 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1497 | + static $icone_renommer; |
|
| 1498 | + if ($p = strpos($icone, '?')) { |
|
| 1499 | + $icone = substr($icone,0, $p); |
|
| 1500 | + } |
|
| 1501 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1502 | + if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1503 | + return $icone; |
|
| 1504 | + } |
|
| 1505 | + |
|
| 1506 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1507 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1508 | + return $f; |
|
| 1509 | + } |
|
| 1510 | + // sinon passer par le module de renommage |
|
| 1511 | + if (is_null($icone_renommer)) { |
|
| 1512 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1513 | + } |
|
| 1514 | + if ($icone_renommer) { |
|
| 1515 | + list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1516 | + if (file_exists($icone)) { |
|
| 1517 | + return $icone; |
|
| 1518 | + } |
|
| 1519 | + } |
|
| 1520 | + |
|
| 1521 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1523 | 1522 | } |
| 1524 | 1523 | |
| 1525 | 1524 | // |
@@ -1557,127 +1556,127 @@ discard block |
||
| 1557 | 1556 | * - false : fichier introuvable |
| 1558 | 1557 | **/ |
| 1559 | 1558 | function find_in_path($file, $dirname = '', $include = false) { |
| 1560 | - static $dirs = array(); |
|
| 1561 | - static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1562 | - static $c = ''; |
|
| 1563 | - |
|
| 1564 | - if (!$file and !strlen($file)) { |
|
| 1565 | - return false; |
|
| 1566 | - } |
|
| 1567 | - |
|
| 1568 | - // on calcule le chemin si le dossier skel a change |
|
| 1569 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1570 | - // assurer le non plantage lors de la montee de version : |
|
| 1571 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1572 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1573 | - } |
|
| 1574 | - |
|
| 1575 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1576 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1577 | - return false; |
|
| 1578 | - } |
|
| 1579 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1580 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1581 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1585 | - } |
|
| 1586 | - |
|
| 1587 | - $a = strrpos($file, '/'); |
|
| 1588 | - if ($a !== false) { |
|
| 1589 | - $dirname .= substr($file, 0, ++$a); |
|
| 1590 | - $file = substr($file, $a); |
|
| 1591 | - } |
|
| 1592 | - |
|
| 1593 | - foreach (creer_chemin() as $dir) { |
|
| 1594 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1595 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1596 | - } |
|
| 1597 | - if ($dirs[$a]) { |
|
| 1598 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1599 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1600 | - include_once _ROOT_CWD . $a; |
|
| 1601 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1602 | - } |
|
| 1603 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1604 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1605 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1606 | - return $a; |
|
| 1607 | - } |
|
| 1608 | - define('_SAUVER_CHEMIN', true); |
|
| 1609 | - } |
|
| 1610 | - |
|
| 1611 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1612 | - } |
|
| 1613 | - } |
|
| 1614 | - } |
|
| 1615 | - |
|
| 1616 | - if ($include) { |
|
| 1617 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1618 | - if ($include === 'required') { |
|
| 1619 | - echo '<pre>', |
|
| 1620 | - "<strong>Erreur Fatale</strong><br />"; |
|
| 1621 | - if (function_exists('debug_print_backtrace')) { |
|
| 1622 | - echo debug_print_backtrace(); |
|
| 1623 | - } |
|
| 1624 | - echo '</pre>'; |
|
| 1625 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1626 | - } |
|
| 1627 | - } |
|
| 1628 | - |
|
| 1629 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1630 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1631 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1632 | - return false; |
|
| 1633 | - } |
|
| 1634 | - define('_SAUVER_CHEMIN', true); |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1559 | + static $dirs = array(); |
|
| 1560 | + static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1561 | + static $c = ''; |
|
| 1562 | + |
|
| 1563 | + if (!$file and !strlen($file)) { |
|
| 1564 | + return false; |
|
| 1565 | + } |
|
| 1566 | + |
|
| 1567 | + // on calcule le chemin si le dossier skel a change |
|
| 1568 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1569 | + // assurer le non plantage lors de la montee de version : |
|
| 1570 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1571 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1572 | + } |
|
| 1573 | + |
|
| 1574 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1575 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1576 | + return false; |
|
| 1577 | + } |
|
| 1578 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1579 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1580 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1584 | + } |
|
| 1585 | + |
|
| 1586 | + $a = strrpos($file, '/'); |
|
| 1587 | + if ($a !== false) { |
|
| 1588 | + $dirname .= substr($file, 0, ++$a); |
|
| 1589 | + $file = substr($file, $a); |
|
| 1590 | + } |
|
| 1591 | + |
|
| 1592 | + foreach (creer_chemin() as $dir) { |
|
| 1593 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1594 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1595 | + } |
|
| 1596 | + if ($dirs[$a]) { |
|
| 1597 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1598 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1599 | + include_once _ROOT_CWD . $a; |
|
| 1600 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1601 | + } |
|
| 1602 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1603 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1604 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1605 | + return $a; |
|
| 1606 | + } |
|
| 1607 | + define('_SAUVER_CHEMIN', true); |
|
| 1608 | + } |
|
| 1609 | + |
|
| 1610 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1611 | + } |
|
| 1612 | + } |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + if ($include) { |
|
| 1616 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1617 | + if ($include === 'required') { |
|
| 1618 | + echo '<pre>', |
|
| 1619 | + "<strong>Erreur Fatale</strong><br />"; |
|
| 1620 | + if (function_exists('debug_print_backtrace')) { |
|
| 1621 | + echo debug_print_backtrace(); |
|
| 1622 | + } |
|
| 1623 | + echo '</pre>'; |
|
| 1624 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1625 | + } |
|
| 1626 | + } |
|
| 1627 | + |
|
| 1628 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1629 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1630 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1631 | + return false; |
|
| 1632 | + } |
|
| 1633 | + define('_SAUVER_CHEMIN', true); |
|
| 1634 | + } |
|
| 1635 | + |
|
| 1636 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1638 | 1637 | } |
| 1639 | 1638 | |
| 1640 | 1639 | function clear_path_cache() { |
| 1641 | - $GLOBALS['path_files'] = array(); |
|
| 1642 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1640 | + $GLOBALS['path_files'] = array(); |
|
| 1641 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1643 | 1642 | } |
| 1644 | 1643 | |
| 1645 | 1644 | function load_path_cache() { |
| 1646 | - // charger le path des plugins |
|
| 1647 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1648 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1649 | - } |
|
| 1650 | - $GLOBALS['path_files'] = array(); |
|
| 1651 | - // si le visiteur est admin, |
|
| 1652 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1653 | - if ( |
|
| 1654 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1655 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1656 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1657 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1658 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1659 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1660 | - !_request('var_mode') |
|
| 1661 | - ) { |
|
| 1662 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1663 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1664 | - // mais si semble corrompu on relit avec un verrou |
|
| 1665 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1666 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1667 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1668 | - $GLOBALS['path_files'] = array(); |
|
| 1669 | - } |
|
| 1670 | - } |
|
| 1671 | - } |
|
| 1672 | - } |
|
| 1645 | + // charger le path des plugins |
|
| 1646 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1647 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1648 | + } |
|
| 1649 | + $GLOBALS['path_files'] = array(); |
|
| 1650 | + // si le visiteur est admin, |
|
| 1651 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1652 | + if ( |
|
| 1653 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1654 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1655 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1656 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1657 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1658 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1659 | + !_request('var_mode') |
|
| 1660 | + ) { |
|
| 1661 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1662 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1663 | + // mais si semble corrompu on relit avec un verrou |
|
| 1664 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1665 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1666 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1667 | + $GLOBALS['path_files'] = array(); |
|
| 1668 | + } |
|
| 1669 | + } |
|
| 1670 | + } |
|
| 1671 | + } |
|
| 1673 | 1672 | } |
| 1674 | 1673 | |
| 1675 | 1674 | function save_path_cache() { |
| 1676 | - if (defined('_SAUVER_CHEMIN') |
|
| 1677 | - and _SAUVER_CHEMIN |
|
| 1678 | - ) { |
|
| 1679 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1680 | - } |
|
| 1675 | + if (defined('_SAUVER_CHEMIN') |
|
| 1676 | + and _SAUVER_CHEMIN |
|
| 1677 | + ) { |
|
| 1678 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1679 | + } |
|
| 1681 | 1680 | } |
| 1682 | 1681 | |
| 1683 | 1682 | |
@@ -1697,33 +1696,33 @@ discard block |
||
| 1697 | 1696 | * @return array |
| 1698 | 1697 | */ |
| 1699 | 1698 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1700 | - $liste_fichiers = array(); |
|
| 1701 | - $maxfiles = 10000; |
|
| 1702 | - |
|
| 1703 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1704 | - // on a pas encore inclus flock.php |
|
| 1705 | - if (!function_exists('preg_files')) { |
|
| 1706 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1707 | - } |
|
| 1708 | - |
|
| 1709 | - // Parcourir le chemin |
|
| 1710 | - foreach (creer_chemin() as $d) { |
|
| 1711 | - $f = $d . $dir; |
|
| 1712 | - if (@is_dir($f)) { |
|
| 1713 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1714 | - foreach ($liste as $chemin) { |
|
| 1715 | - $nom = basename($chemin); |
|
| 1716 | - // ne prendre que les fichiers pas deja trouves |
|
| 1717 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1718 | - // les autres sont donc masques |
|
| 1719 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1720 | - $liste_fichiers[$nom] = $chemin; |
|
| 1721 | - } |
|
| 1722 | - } |
|
| 1723 | - } |
|
| 1724 | - } |
|
| 1725 | - |
|
| 1726 | - return $liste_fichiers; |
|
| 1699 | + $liste_fichiers = array(); |
|
| 1700 | + $maxfiles = 10000; |
|
| 1701 | + |
|
| 1702 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1703 | + // on a pas encore inclus flock.php |
|
| 1704 | + if (!function_exists('preg_files')) { |
|
| 1705 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1706 | + } |
|
| 1707 | + |
|
| 1708 | + // Parcourir le chemin |
|
| 1709 | + foreach (creer_chemin() as $d) { |
|
| 1710 | + $f = $d . $dir; |
|
| 1711 | + if (@is_dir($f)) { |
|
| 1712 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1713 | + foreach ($liste as $chemin) { |
|
| 1714 | + $nom = basename($chemin); |
|
| 1715 | + // ne prendre que les fichiers pas deja trouves |
|
| 1716 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1717 | + // les autres sont donc masques |
|
| 1718 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1719 | + $liste_fichiers[$nom] = $chemin; |
|
| 1720 | + } |
|
| 1721 | + } |
|
| 1722 | + } |
|
| 1723 | + } |
|
| 1724 | + |
|
| 1725 | + return $liste_fichiers; |
|
| 1727 | 1726 | } |
| 1728 | 1727 | |
| 1729 | 1728 | /** |
@@ -1735,17 +1734,17 @@ discard block |
||
| 1735 | 1734 | * @return bool |
| 1736 | 1735 | */ |
| 1737 | 1736 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1738 | - static $autsanscookie = array('install', 'base_repair'); |
|
| 1737 | + static $autsanscookie = array('install', 'base_repair'); |
|
| 1739 | 1738 | |
| 1740 | - if (in_array($nom, $autsanscookie)) { |
|
| 1741 | - if (test_espace_prive()){ |
|
| 1742 | - include_spip('base/connect_sql'); |
|
| 1743 | - if (!$strict or !spip_connect()){ |
|
| 1744 | - return true; |
|
| 1745 | - } |
|
| 1746 | - } |
|
| 1747 | - } |
|
| 1748 | - return false; |
|
| 1739 | + if (in_array($nom, $autsanscookie)) { |
|
| 1740 | + if (test_espace_prive()){ |
|
| 1741 | + include_spip('base/connect_sql'); |
|
| 1742 | + if (!$strict or !spip_connect()){ |
|
| 1743 | + return true; |
|
| 1744 | + } |
|
| 1745 | + } |
|
| 1746 | + } |
|
| 1747 | + return false; |
|
| 1749 | 1748 | } |
| 1750 | 1749 | |
| 1751 | 1750 | /** |
@@ -1771,99 +1770,99 @@ discard block |
||
| 1771 | 1770 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip) |
| 1772 | 1771 | */ |
| 1773 | 1772 | function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1774 | - if ($public === null) { |
|
| 1775 | - $public = !test_espace_prive(); |
|
| 1776 | - } |
|
| 1777 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1778 | - |
|
| 1779 | - if (!$public) { |
|
| 1780 | - if (!$entite) { |
|
| 1781 | - return ''; |
|
| 1782 | - } |
|
| 1783 | - if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1784 | - include_spip('inc/urls'); |
|
| 1785 | - } |
|
| 1786 | - $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1787 | - } else { |
|
| 1788 | - if ($type === null) { |
|
| 1789 | - $type = (isset($GLOBALS['type_urls'])) |
|
| 1790 | - ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1791 | - : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1792 | - ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1793 | - } |
|
| 1794 | - |
|
| 1795 | - $f = charger_fonction($type, 'urls', true); |
|
| 1796 | - // se rabattre sur les urls page si les urls perso non dispo |
|
| 1797 | - if (!$f) { |
|
| 1798 | - $f = charger_fonction('page', 'urls', true); |
|
| 1799 | - } |
|
| 1800 | - |
|
| 1801 | - // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1802 | - // sinon on veut effectuer le passage id ==> URL |
|
| 1803 | - if (!$entite) { |
|
| 1804 | - return $f; |
|
| 1805 | - } |
|
| 1806 | - |
|
| 1807 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1808 | - // base distante |
|
| 1809 | - if (is_string($public) |
|
| 1810 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1811 | - ) { |
|
| 1812 | - $f = $g; |
|
| 1813 | - } |
|
| 1814 | - |
|
| 1815 | - $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1816 | - |
|
| 1817 | - } |
|
| 1818 | - if ($res) { |
|
| 1819 | - return $res; |
|
| 1820 | - } |
|
| 1821 | - // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1822 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1823 | - if (!function_exists($f .= '_dist')) { |
|
| 1824 | - $f = ''; |
|
| 1825 | - } |
|
| 1826 | - } |
|
| 1827 | - if ($f) { |
|
| 1828 | - $url = $f($id, $args, $ancre); |
|
| 1829 | - if (strlen($args)) { |
|
| 1830 | - $url .= strstr($url, '?') |
|
| 1831 | - ? '&' . $args |
|
| 1832 | - : '?' . $args; |
|
| 1833 | - } |
|
| 1834 | - |
|
| 1835 | - return $url; |
|
| 1836 | - } |
|
| 1837 | - // On a ete gentil mais la .... |
|
| 1838 | - spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1839 | - |
|
| 1840 | - return ''; |
|
| 1773 | + if ($public === null) { |
|
| 1774 | + $public = !test_espace_prive(); |
|
| 1775 | + } |
|
| 1776 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1777 | + |
|
| 1778 | + if (!$public) { |
|
| 1779 | + if (!$entite) { |
|
| 1780 | + return ''; |
|
| 1781 | + } |
|
| 1782 | + if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1783 | + include_spip('inc/urls'); |
|
| 1784 | + } |
|
| 1785 | + $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1786 | + } else { |
|
| 1787 | + if ($type === null) { |
|
| 1788 | + $type = (isset($GLOBALS['type_urls'])) |
|
| 1789 | + ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1790 | + : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1791 | + ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1792 | + } |
|
| 1793 | + |
|
| 1794 | + $f = charger_fonction($type, 'urls', true); |
|
| 1795 | + // se rabattre sur les urls page si les urls perso non dispo |
|
| 1796 | + if (!$f) { |
|
| 1797 | + $f = charger_fonction('page', 'urls', true); |
|
| 1798 | + } |
|
| 1799 | + |
|
| 1800 | + // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1801 | + // sinon on veut effectuer le passage id ==> URL |
|
| 1802 | + if (!$entite) { |
|
| 1803 | + return $f; |
|
| 1804 | + } |
|
| 1805 | + |
|
| 1806 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1807 | + // base distante |
|
| 1808 | + if (is_string($public) |
|
| 1809 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1810 | + ) { |
|
| 1811 | + $f = $g; |
|
| 1812 | + } |
|
| 1813 | + |
|
| 1814 | + $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1815 | + |
|
| 1816 | + } |
|
| 1817 | + if ($res) { |
|
| 1818 | + return $res; |
|
| 1819 | + } |
|
| 1820 | + // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1821 | + if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1822 | + if (!function_exists($f .= '_dist')) { |
|
| 1823 | + $f = ''; |
|
| 1824 | + } |
|
| 1825 | + } |
|
| 1826 | + if ($f) { |
|
| 1827 | + $url = $f($id, $args, $ancre); |
|
| 1828 | + if (strlen($args)) { |
|
| 1829 | + $url .= strstr($url, '?') |
|
| 1830 | + ? '&' . $args |
|
| 1831 | + : '?' . $args; |
|
| 1832 | + } |
|
| 1833 | + |
|
| 1834 | + return $url; |
|
| 1835 | + } |
|
| 1836 | + // On a ete gentil mais la .... |
|
| 1837 | + spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1838 | + |
|
| 1839 | + return ''; |
|
| 1841 | 1840 | } |
| 1842 | 1841 | |
| 1843 | 1842 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 1844 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1845 | - $url = generer_url_ecrire($exec, $args); |
|
| 1846 | - if (intval($id)) { |
|
| 1847 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1848 | - } else { |
|
| 1849 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1850 | - } |
|
| 1851 | - if ($ancre) { |
|
| 1852 | - $url = ancre_url($url, $ancre); |
|
| 1853 | - } |
|
| 1843 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1844 | + $url = generer_url_ecrire($exec, $args); |
|
| 1845 | + if (intval($id)) { |
|
| 1846 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1847 | + } else { |
|
| 1848 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1849 | + } |
|
| 1850 | + if ($ancre) { |
|
| 1851 | + $url = ancre_url($url, $ancre); |
|
| 1852 | + } |
|
| 1854 | 1853 | |
| 1855 | - return $url; |
|
| 1854 | + return $url; |
|
| 1856 | 1855 | } |
| 1857 | 1856 | |
| 1858 | 1857 | // https://code.spip.net/@urls_connect_dist |
| 1859 | 1858 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1860 | - include_spip('base/connect_sql'); |
|
| 1861 | - $id_type = id_table_objet($entite, $public); |
|
| 1859 | + include_spip('base/connect_sql'); |
|
| 1860 | + $id_type = id_table_objet($entite, $public); |
|
| 1862 | 1861 | |
| 1863 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1864 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1865 | - . (!$args ? '' : "&$args") |
|
| 1866 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1862 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1863 | + . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1864 | + . (!$args ? '' : "&$args") |
|
| 1865 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1867 | 1866 | } |
| 1868 | 1867 | |
| 1869 | 1868 | |
@@ -1874,32 +1873,32 @@ discard block |
||
| 1874 | 1873 | * @return string |
| 1875 | 1874 | */ |
| 1876 | 1875 | function urlencode_1738($url) { |
| 1877 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1878 | - $uri = ''; |
|
| 1879 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1880 | - if (ord($a = $url[$i]) > 127) { |
|
| 1881 | - $a = rawurlencode($a); |
|
| 1882 | - } |
|
| 1883 | - $uri .= $a; |
|
| 1884 | - } |
|
| 1885 | - $url = $uri; |
|
| 1886 | - } |
|
| 1876 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1877 | + $uri = ''; |
|
| 1878 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1879 | + if (ord($a = $url[$i]) > 127) { |
|
| 1880 | + $a = rawurlencode($a); |
|
| 1881 | + } |
|
| 1882 | + $uri .= $a; |
|
| 1883 | + } |
|
| 1884 | + $url = $uri; |
|
| 1885 | + } |
|
| 1887 | 1886 | |
| 1888 | - return quote_amp($url); |
|
| 1887 | + return quote_amp($url); |
|
| 1889 | 1888 | } |
| 1890 | 1889 | |
| 1891 | 1890 | // https://code.spip.net/@generer_url_entite_absolue |
| 1892 | 1891 | function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { |
| 1893 | - if (!$connect) { |
|
| 1894 | - $connect = true; |
|
| 1895 | - } |
|
| 1896 | - $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1897 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1898 | - include_spip('inc/filtres_mini'); |
|
| 1899 | - $h = url_absolue($h); |
|
| 1900 | - } |
|
| 1892 | + if (!$connect) { |
|
| 1893 | + $connect = true; |
|
| 1894 | + } |
|
| 1895 | + $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1896 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1897 | + include_spip('inc/filtres_mini'); |
|
| 1898 | + $h = url_absolue($h); |
|
| 1899 | + } |
|
| 1901 | 1900 | |
| 1902 | - return $h; |
|
| 1901 | + return $h; |
|
| 1903 | 1902 | } |
| 1904 | 1903 | |
| 1905 | 1904 | |
@@ -1915,11 +1914,11 @@ discard block |
||
| 1915 | 1914 | * true si la valeur est considérée active ; false sinon. |
| 1916 | 1915 | **/ |
| 1917 | 1916 | function test_valeur_serveur($truc) { |
| 1918 | - if (!$truc) { |
|
| 1919 | - return false; |
|
| 1920 | - } |
|
| 1917 | + if (!$truc) { |
|
| 1918 | + return false; |
|
| 1919 | + } |
|
| 1921 | 1920 | |
| 1922 | - return (strtolower($truc) !== 'off'); |
|
| 1921 | + return (strtolower($truc) !== 'off'); |
|
| 1923 | 1922 | } |
| 1924 | 1923 | |
| 1925 | 1924 | // |
@@ -1947,80 +1946,80 @@ discard block |
||
| 1947 | 1946 | */ |
| 1948 | 1947 | function url_de_base($profondeur = null) { |
| 1949 | 1948 | |
| 1950 | - static $url = array(); |
|
| 1951 | - if (is_array($profondeur)) { |
|
| 1952 | - return $url = $profondeur; |
|
| 1953 | - } |
|
| 1954 | - if ($profondeur === false) { |
|
| 1955 | - return $url; |
|
| 1956 | - } |
|
| 1957 | - |
|
| 1958 | - if (is_null($profondeur)) { |
|
| 1959 | - $profondeur = $GLOBALS['profondeur_url']; |
|
| 1960 | - } |
|
| 1961 | - |
|
| 1962 | - if (isset($url[$profondeur])) { |
|
| 1963 | - return $url[$profondeur]; |
|
| 1964 | - } |
|
| 1965 | - |
|
| 1966 | - $http = 'http'; |
|
| 1967 | - |
|
| 1968 | - if ( |
|
| 1969 | - isset($_SERVER["SCRIPT_URI"]) |
|
| 1970 | - and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1971 | - ) { |
|
| 1972 | - $http = 'https'; |
|
| 1973 | - } elseif ( |
|
| 1974 | - isset($_SERVER['HTTPS']) |
|
| 1975 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1976 | - ) { |
|
| 1977 | - $http = 'https'; |
|
| 1978 | - } |
|
| 1979 | - |
|
| 1980 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 1981 | - $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1982 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1983 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1984 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 1985 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1986 | - $http = $scheme; |
|
| 1987 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 1988 | - } |
|
| 1989 | - } |
|
| 1990 | - if (isset($_SERVER['SERVER_PORT']) |
|
| 1991 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 1992 | - and strpos($host, ":") == false |
|
| 1993 | - ) { |
|
| 1994 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1995 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 1996 | - } |
|
| 1997 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 1998 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 1999 | - } |
|
| 2000 | - if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2001 | - $host .= ":$port"; |
|
| 2002 | - } |
|
| 2003 | - if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2004 | - $host .= ":$port"; |
|
| 2005 | - } |
|
| 2006 | - } |
|
| 2007 | - |
|
| 2008 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 2009 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2010 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2011 | - } else { |
|
| 2012 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2013 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 2014 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2015 | - ) { |
|
| 2016 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2017 | - } |
|
| 2018 | - } |
|
| 2019 | - } |
|
| 2020 | - |
|
| 2021 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2022 | - |
|
| 2023 | - return $url[$profondeur]; |
|
| 1949 | + static $url = array(); |
|
| 1950 | + if (is_array($profondeur)) { |
|
| 1951 | + return $url = $profondeur; |
|
| 1952 | + } |
|
| 1953 | + if ($profondeur === false) { |
|
| 1954 | + return $url; |
|
| 1955 | + } |
|
| 1956 | + |
|
| 1957 | + if (is_null($profondeur)) { |
|
| 1958 | + $profondeur = $GLOBALS['profondeur_url']; |
|
| 1959 | + } |
|
| 1960 | + |
|
| 1961 | + if (isset($url[$profondeur])) { |
|
| 1962 | + return $url[$profondeur]; |
|
| 1963 | + } |
|
| 1964 | + |
|
| 1965 | + $http = 'http'; |
|
| 1966 | + |
|
| 1967 | + if ( |
|
| 1968 | + isset($_SERVER["SCRIPT_URI"]) |
|
| 1969 | + and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1970 | + ) { |
|
| 1971 | + $http = 'https'; |
|
| 1972 | + } elseif ( |
|
| 1973 | + isset($_SERVER['HTTPS']) |
|
| 1974 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1975 | + ) { |
|
| 1976 | + $http = 'https'; |
|
| 1977 | + } |
|
| 1978 | + |
|
| 1979 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 1980 | + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1981 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1982 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1983 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 1984 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1985 | + $http = $scheme; |
|
| 1986 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 1987 | + } |
|
| 1988 | + } |
|
| 1989 | + if (isset($_SERVER['SERVER_PORT']) |
|
| 1990 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 1991 | + and strpos($host, ":") == false |
|
| 1992 | + ) { |
|
| 1993 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1994 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 1995 | + } |
|
| 1996 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 1997 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 1998 | + } |
|
| 1999 | + if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2000 | + $host .= ":$port"; |
|
| 2001 | + } |
|
| 2002 | + if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2003 | + $host .= ":$port"; |
|
| 2004 | + } |
|
| 2005 | + } |
|
| 2006 | + |
|
| 2007 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 2008 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2009 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2010 | + } else { |
|
| 2011 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2012 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 2013 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2014 | + ) { |
|
| 2015 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2016 | + } |
|
| 2017 | + } |
|
| 2018 | + } |
|
| 2019 | + |
|
| 2020 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2021 | + |
|
| 2022 | + return $url[$profondeur]; |
|
| 2024 | 2023 | } |
| 2025 | 2024 | |
| 2026 | 2025 | /** |
@@ -2033,26 +2032,26 @@ discard block |
||
| 2033 | 2032 | * @return string |
| 2034 | 2033 | */ |
| 2035 | 2034 | function url_de_($http, $host, $request, $prof = 0) { |
| 2036 | - $prof = max($prof, 0); |
|
| 2035 | + $prof = max($prof, 0); |
|
| 2037 | 2036 | |
| 2038 | - $myself = ltrim($request, '/'); |
|
| 2039 | - # supprimer la chaine de GET |
|
| 2040 | - list($myself) = explode('?', $myself); |
|
| 2041 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2042 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2043 | - if (strpos($myself,'://') !== false) { |
|
| 2044 | - $myself = explode('://',$myself); |
|
| 2045 | - array_shift($myself); |
|
| 2046 | - $myself = implode('://',$myself); |
|
| 2047 | - $myself = explode('/',$myself); |
|
| 2048 | - array_shift($myself); |
|
| 2049 | - $myself = implode('/',$myself); |
|
| 2050 | - } |
|
| 2051 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2037 | + $myself = ltrim($request, '/'); |
|
| 2038 | + # supprimer la chaine de GET |
|
| 2039 | + list($myself) = explode('?', $myself); |
|
| 2040 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2041 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2042 | + if (strpos($myself,'://') !== false) { |
|
| 2043 | + $myself = explode('://',$myself); |
|
| 2044 | + array_shift($myself); |
|
| 2045 | + $myself = implode('://',$myself); |
|
| 2046 | + $myself = explode('/',$myself); |
|
| 2047 | + array_shift($myself); |
|
| 2048 | + $myself = implode('/',$myself); |
|
| 2049 | + } |
|
| 2050 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2052 | 2051 | |
| 2053 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2052 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2054 | 2053 | |
| 2055 | - return $url; |
|
| 2054 | + return $url; |
|
| 2056 | 2055 | } |
| 2057 | 2056 | |
| 2058 | 2057 | |
@@ -2087,26 +2086,26 @@ discard block |
||
| 2087 | 2086 | * @return string URL |
| 2088 | 2087 | **/ |
| 2089 | 2088 | function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
| 2090 | - if (!$rel) { |
|
| 2091 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2092 | - } else { |
|
| 2093 | - if (!is_string($rel)) { |
|
| 2094 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2095 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2096 | - } |
|
| 2097 | - } |
|
| 2098 | - |
|
| 2099 | - list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2100 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2101 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2102 | - } elseif ($args) { |
|
| 2103 | - $args = "?$args"; |
|
| 2104 | - } |
|
| 2105 | - if ($ancre) { |
|
| 2106 | - $args .= "#$ancre"; |
|
| 2107 | - } |
|
| 2108 | - |
|
| 2109 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2089 | + if (!$rel) { |
|
| 2090 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2091 | + } else { |
|
| 2092 | + if (!is_string($rel)) { |
|
| 2093 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2094 | + ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2095 | + } |
|
| 2096 | + } |
|
| 2097 | + |
|
| 2098 | + list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2099 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2100 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2101 | + } elseif ($args) { |
|
| 2102 | + $args = "?$args"; |
|
| 2103 | + } |
|
| 2104 | + if ($ancre) { |
|
| 2105 | + $args .= "#$ancre"; |
|
| 2106 | + } |
|
| 2107 | + |
|
| 2108 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2110 | 2109 | } |
| 2111 | 2110 | |
| 2112 | 2111 | // |
@@ -2128,12 +2127,12 @@ discard block |
||
| 2128 | 2127 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2129 | 2128 | **/ |
| 2130 | 2129 | function get_spip_script($default = '') { |
| 2131 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2132 | - if (_SPIP_SCRIPT) { |
|
| 2133 | - return _SPIP_SCRIPT; |
|
| 2134 | - } else { |
|
| 2135 | - return $default; |
|
| 2136 | - } |
|
| 2130 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2131 | + if (_SPIP_SCRIPT) { |
|
| 2132 | + return _SPIP_SCRIPT; |
|
| 2133 | + } else { |
|
| 2134 | + return $default; |
|
| 2135 | + } |
|
| 2137 | 2136 | } |
| 2138 | 2137 | |
| 2139 | 2138 | /** |
@@ -2162,39 +2161,39 @@ discard block |
||
| 2162 | 2161 | * @return string URL |
| 2163 | 2162 | **/ |
| 2164 | 2163 | function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') { |
| 2165 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2166 | - // standardiser vers la nouvelle API |
|
| 2167 | - |
|
| 2168 | - if (!$action) { |
|
| 2169 | - $action = get_spip_script(); |
|
| 2170 | - } |
|
| 2171 | - if ($script) { |
|
| 2172 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2173 | - } |
|
| 2174 | - |
|
| 2175 | - if ($args) { |
|
| 2176 | - if (is_array($args)) { |
|
| 2177 | - $r = ''; |
|
| 2178 | - foreach ($args as $k => $v) { |
|
| 2179 | - $r .= '&' . $k . '=' . $v; |
|
| 2180 | - } |
|
| 2181 | - $args = substr($r, 1); |
|
| 2182 | - } |
|
| 2183 | - $action .= |
|
| 2184 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2185 | - } |
|
| 2186 | - if (!$no_entities) { |
|
| 2187 | - $action = quote_amp($action); |
|
| 2188 | - } |
|
| 2189 | - |
|
| 2190 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2191 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2164 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2165 | + // standardiser vers la nouvelle API |
|
| 2166 | + |
|
| 2167 | + if (!$action) { |
|
| 2168 | + $action = get_spip_script(); |
|
| 2169 | + } |
|
| 2170 | + if ($script) { |
|
| 2171 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2172 | + } |
|
| 2173 | + |
|
| 2174 | + if ($args) { |
|
| 2175 | + if (is_array($args)) { |
|
| 2176 | + $r = ''; |
|
| 2177 | + foreach ($args as $k => $v) { |
|
| 2178 | + $r .= '&' . $k . '=' . $v; |
|
| 2179 | + } |
|
| 2180 | + $args = substr($r, 1); |
|
| 2181 | + } |
|
| 2182 | + $action .= |
|
| 2183 | + (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2184 | + } |
|
| 2185 | + if (!$no_entities) { |
|
| 2186 | + $action = quote_amp($action); |
|
| 2187 | + } |
|
| 2188 | + |
|
| 2189 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2190 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2192 | 2191 | } |
| 2193 | 2192 | |
| 2194 | 2193 | // https://code.spip.net/@generer_url_prive |
| 2195 | 2194 | function generer_url_prive($script, $args = "", $no_entities = false) { |
| 2196 | 2195 | |
| 2197 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2196 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2198 | 2197 | } |
| 2199 | 2198 | |
| 2200 | 2199 | // Pour les formulaires en methode POST, |
@@ -2219,19 +2218,19 @@ discard block |
||
| 2219 | 2218 | **/ |
| 2220 | 2219 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2221 | 2220 | |
| 2222 | - $script1 = explode('&', $script); |
|
| 2223 | - $script1 = reset($script1); |
|
| 2221 | + $script1 = explode('&', $script); |
|
| 2222 | + $script1 = reset($script1); |
|
| 2224 | 2223 | |
| 2225 | - return "<form action='" |
|
| 2226 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2227 | - . "' " |
|
| 2228 | - . ($atts ? $atts : " method='post'") |
|
| 2229 | - . "><div>\n" |
|
| 2230 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2231 | - . $corps |
|
| 2232 | - . (!$submit ? '' : |
|
| 2233 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2234 | - . "</div></form>\n"; |
|
| 2224 | + return "<form action='" |
|
| 2225 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2226 | + . "' " |
|
| 2227 | + . ($atts ? $atts : " method='post'") |
|
| 2228 | + . "><div>\n" |
|
| 2229 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2230 | + . $corps |
|
| 2231 | + . (!$submit ? '' : |
|
| 2232 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2233 | + . "</div></form>\n"; |
|
| 2235 | 2234 | } |
| 2236 | 2235 | |
| 2237 | 2236 | /** |
@@ -2248,22 +2247,22 @@ discard block |
||
| 2248 | 2247 | * @return string |
| 2249 | 2248 | */ |
| 2250 | 2249 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2251 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2252 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2253 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2254 | - $h = (_DIR_RACINE and !$public) |
|
| 2255 | - ? generer_url_ecrire(_request('exec')) |
|
| 2256 | - : generer_url_public(); |
|
| 2250 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2251 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2252 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2253 | + $h = (_DIR_RACINE and !$public) |
|
| 2254 | + ? generer_url_ecrire(_request('exec')) |
|
| 2255 | + : generer_url_public(); |
|
| 2257 | 2256 | |
| 2258 | - return "\n<form action='" . |
|
| 2259 | - $h . |
|
| 2260 | - "'" . |
|
| 2261 | - $atts . |
|
| 2262 | - ">\n" . |
|
| 2263 | - "<div>" . |
|
| 2264 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2265 | - $corps . |
|
| 2266 | - "</div></form>"; |
|
| 2257 | + return "\n<form action='" . |
|
| 2258 | + $h . |
|
| 2259 | + "'" . |
|
| 2260 | + $atts . |
|
| 2261 | + ">\n" . |
|
| 2262 | + "<div>" . |
|
| 2263 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2264 | + $corps . |
|
| 2265 | + "</div></form>"; |
|
| 2267 | 2266 | } |
| 2268 | 2267 | |
| 2269 | 2268 | /** |
@@ -2282,22 +2281,22 @@ discard block |
||
| 2282 | 2281 | * URL |
| 2283 | 2282 | */ |
| 2284 | 2283 | function generer_url_action($script, $args = "", $no_entities = false, $public = false) { |
| 2285 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2286 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2287 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2288 | - $url = (_DIR_RACINE and !$public) |
|
| 2289 | - ? generer_url_ecrire(_request('exec')) |
|
| 2290 | - : generer_url_public('', '', false, false); |
|
| 2291 | - $url = parametre_url($url, 'action', $script); |
|
| 2292 | - if ($args) { |
|
| 2293 | - $url .= quote_amp('&' . $args); |
|
| 2294 | - } |
|
| 2284 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2285 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2286 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2287 | + $url = (_DIR_RACINE and !$public) |
|
| 2288 | + ? generer_url_ecrire(_request('exec')) |
|
| 2289 | + : generer_url_public('', '', false, false); |
|
| 2290 | + $url = parametre_url($url, 'action', $script); |
|
| 2291 | + if ($args) { |
|
| 2292 | + $url .= quote_amp('&' . $args); |
|
| 2293 | + } |
|
| 2295 | 2294 | |
| 2296 | - if ($no_entities) { |
|
| 2297 | - $url = str_replace('&', '&', $url); |
|
| 2298 | - } |
|
| 2295 | + if ($no_entities) { |
|
| 2296 | + $url = str_replace('&', '&', $url); |
|
| 2297 | + } |
|
| 2299 | 2298 | |
| 2300 | - return $url; |
|
| 2299 | + return $url; |
|
| 2301 | 2300 | } |
| 2302 | 2301 | |
| 2303 | 2302 | |
@@ -2310,8 +2309,8 @@ discard block |
||
| 2310 | 2309 | * @param string $ta Répertoire temporaire accessible |
| 2311 | 2310 | */ |
| 2312 | 2311 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2313 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2314 | - spip_initialisation_suite(); |
|
| 2312 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2313 | + spip_initialisation_suite(); |
|
| 2315 | 2314 | } |
| 2316 | 2315 | |
| 2317 | 2316 | /** |
@@ -2331,315 +2330,315 @@ discard block |
||
| 2331 | 2330 | * @param string $ta Répertoire temporaire accessible |
| 2332 | 2331 | */ |
| 2333 | 2332 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2334 | - static $too_late = 0; |
|
| 2335 | - if ($too_late++) { |
|
| 2336 | - return; |
|
| 2337 | - } |
|
| 2338 | - |
|
| 2339 | - // Declaration des repertoires |
|
| 2340 | - |
|
| 2341 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2342 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2343 | - define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2344 | - } |
|
| 2345 | - |
|
| 2346 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2347 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2348 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2349 | - } |
|
| 2350 | - |
|
| 2351 | - // le nom du repertoire des librairies |
|
| 2352 | - if (!defined('_DIR_LIB')) { |
|
| 2353 | - define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2354 | - } |
|
| 2355 | - |
|
| 2356 | - if (!defined('_DIR_IMG')) { |
|
| 2357 | - define('_DIR_IMG', $pa); |
|
| 2358 | - } |
|
| 2359 | - if (!defined('_DIR_LOGOS')) { |
|
| 2360 | - define('_DIR_LOGOS', $pa); |
|
| 2361 | - } |
|
| 2362 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2363 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2364 | - } |
|
| 2365 | - |
|
| 2366 | - if (!defined('_DIR_DUMP')) { |
|
| 2367 | - define('_DIR_DUMP', $ti . "dump/"); |
|
| 2368 | - } |
|
| 2369 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2370 | - define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2371 | - } |
|
| 2372 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2373 | - define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2374 | - } |
|
| 2375 | - if (!defined('_DIR_CACHE')) { |
|
| 2376 | - define('_DIR_CACHE', $ti . "cache/"); |
|
| 2377 | - } |
|
| 2378 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2379 | - define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2380 | - } |
|
| 2381 | - if (!defined('_DIR_SKELS')) { |
|
| 2382 | - define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2383 | - } |
|
| 2384 | - if (!defined('_DIR_AIDE')) { |
|
| 2385 | - define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2386 | - } |
|
| 2387 | - if (!defined('_DIR_TMP')) { |
|
| 2388 | - define('_DIR_TMP', $ti); |
|
| 2389 | - } |
|
| 2390 | - |
|
| 2391 | - if (!defined('_DIR_VAR')) { |
|
| 2392 | - define('_DIR_VAR', $ta); |
|
| 2393 | - } |
|
| 2394 | - |
|
| 2395 | - if (!defined('_DIR_ETC')) { |
|
| 2396 | - define('_DIR_ETC', $pi); |
|
| 2397 | - } |
|
| 2398 | - if (!defined('_DIR_CONNECT')) { |
|
| 2399 | - define('_DIR_CONNECT', $pi); |
|
| 2400 | - } |
|
| 2401 | - if (!defined('_DIR_CHMOD')) { |
|
| 2402 | - define('_DIR_CHMOD', $pi); |
|
| 2403 | - } |
|
| 2404 | - |
|
| 2405 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 2406 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2407 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2408 | - { |
|
| 2409 | - $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2410 | - } |
|
| 2411 | - |
|
| 2412 | - // Declaration des fichiers |
|
| 2413 | - |
|
| 2414 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2415 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2416 | - } |
|
| 2417 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2418 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2419 | - } |
|
| 2420 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2421 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2422 | - } |
|
| 2423 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2424 | - define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2425 | - } |
|
| 2426 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2427 | - define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2428 | - } |
|
| 2429 | - |
|
| 2430 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2431 | - if (!defined('_FILE_META')) { |
|
| 2432 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2433 | - } |
|
| 2434 | - if (!defined('_DIR_LOG')) { |
|
| 2435 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2436 | - } |
|
| 2437 | - if (!defined('_FILE_LOG')) { |
|
| 2438 | - define('_FILE_LOG', 'spip'); |
|
| 2439 | - } |
|
| 2440 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2441 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2442 | - } |
|
| 2443 | - |
|
| 2444 | - // Le fichier de connexion a la base de donnees |
|
| 2445 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2446 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2447 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2448 | - } |
|
| 2449 | - if (!defined('_FILE_CONNECT')) { |
|
| 2450 | - define('_FILE_CONNECT', |
|
| 2451 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2452 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2453 | - : false))); |
|
| 2454 | - } |
|
| 2455 | - |
|
| 2456 | - // Le fichier de reglages des droits |
|
| 2457 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2458 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2459 | - } |
|
| 2460 | - if (!defined('_FILE_CHMOD')) { |
|
| 2461 | - define('_FILE_CHMOD', |
|
| 2462 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2463 | - : false)); |
|
| 2464 | - } |
|
| 2465 | - |
|
| 2466 | - if (!defined('_FILE_LDAP')) { |
|
| 2467 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2468 | - } |
|
| 2469 | - |
|
| 2470 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2471 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2472 | - } |
|
| 2473 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2474 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2475 | - } |
|
| 2476 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2477 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2478 | - } |
|
| 2479 | - |
|
| 2480 | - // Definition des droits d'acces en ecriture |
|
| 2481 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2482 | - include_once _FILE_CHMOD; |
|
| 2483 | - } |
|
| 2484 | - |
|
| 2485 | - // Se mefier des fichiers mal remplis! |
|
| 2486 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2487 | - define('_SPIP_CHMOD', 0777); |
|
| 2488 | - } |
|
| 2489 | - |
|
| 2490 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2491 | - /** Le charset par défaut lors de l'installation */ |
|
| 2492 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2493 | - } |
|
| 2494 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2495 | - define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2496 | - } |
|
| 2497 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2498 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2499 | - } |
|
| 2500 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2501 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2502 | - } |
|
| 2503 | - |
|
| 2504 | - // La taille des Log |
|
| 2505 | - if (!defined('_MAX_LOG')) { |
|
| 2506 | - define('_MAX_LOG', 100); |
|
| 2507 | - } |
|
| 2508 | - |
|
| 2509 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2510 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2511 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2512 | - if (!defined('_OS_SERVEUR')) { |
|
| 2513 | - define('_OS_SERVEUR', 'windows'); |
|
| 2514 | - } |
|
| 2515 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2516 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2517 | - } // utiliser le flock php |
|
| 2518 | - } else { |
|
| 2519 | - if (!defined('_OS_SERVEUR')) { |
|
| 2520 | - define('_OS_SERVEUR', ''); |
|
| 2521 | - } |
|
| 2522 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2523 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2524 | - } // utiliser le flock php |
|
| 2525 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2526 | - } |
|
| 2527 | - |
|
| 2528 | - // Langue par defaut |
|
| 2529 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2530 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2531 | - } |
|
| 2532 | - |
|
| 2533 | - // |
|
| 2534 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2535 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2536 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2537 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2538 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2539 | - |
|
| 2540 | - // charger tout de suite le path et son cache |
|
| 2541 | - load_path_cache(); |
|
| 2542 | - |
|
| 2543 | - // *********** traiter les variables ************ |
|
| 2544 | - |
|
| 2545 | - // |
|
| 2546 | - // Securite |
|
| 2547 | - // |
|
| 2548 | - |
|
| 2549 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2550 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2551 | - die(); |
|
| 2552 | - } |
|
| 2553 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2554 | - spip_desinfecte($_GET); |
|
| 2555 | - spip_desinfecte($_POST); |
|
| 2556 | - spip_desinfecte($_COOKIE); |
|
| 2557 | - spip_desinfecte($_REQUEST); |
|
| 2558 | - |
|
| 2559 | - // appliquer le cookie_prefix |
|
| 2560 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2561 | - include_spip('inc/cookie'); |
|
| 2562 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2563 | - } |
|
| 2564 | - |
|
| 2565 | - // |
|
| 2566 | - // Capacites php (en fonction de la version) |
|
| 2567 | - // |
|
| 2568 | - $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2569 | - && function_exists("ini_get") |
|
| 2570 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2571 | - $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2572 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2573 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2574 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2575 | - |
|
| 2576 | - |
|
| 2577 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2578 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2579 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2580 | - } else { |
|
| 2581 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2582 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 2583 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2584 | - ) { |
|
| 2585 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2586 | - } |
|
| 2587 | - } |
|
| 2588 | - |
|
| 2589 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2590 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2591 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2592 | - } |
|
| 2593 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2594 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2595 | - } |
|
| 2596 | - |
|
| 2597 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2598 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2599 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2600 | - $inc_meta(); |
|
| 2601 | - |
|
| 2602 | - // nombre de repertoires depuis la racine |
|
| 2603 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2604 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2605 | - // le calcul est faux) |
|
| 2606 | - if (!_DIR_RESTREINT) { |
|
| 2607 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2608 | - } else { |
|
| 2609 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2610 | - $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2611 | - if (!$uri_ref |
|
| 2612 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2613 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2614 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2615 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2616 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2617 | - ) { |
|
| 2618 | - |
|
| 2619 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2620 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2621 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2622 | - } else { |
|
| 2623 | - $uri_ref = ""; |
|
| 2624 | - } |
|
| 2625 | - } |
|
| 2626 | - if (!$uri or !$uri_ref) { |
|
| 2627 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2628 | - } else { |
|
| 2629 | - $GLOBALS['profondeur_url'] = max(0, |
|
| 2630 | - substr_count($uri[0], '/') |
|
| 2631 | - - substr_count($uri_ref, '/')); |
|
| 2632 | - } |
|
| 2633 | - } |
|
| 2634 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2635 | - if (_FILE_CONNECT) { |
|
| 2636 | - if (verifier_visiteur() == '0minirezo' |
|
| 2637 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2638 | - and !isset($_COOKIE['spip_admin']) |
|
| 2639 | - ) { |
|
| 2640 | - clear_path_cache(); |
|
| 2641 | - } |
|
| 2642 | - } |
|
| 2333 | + static $too_late = 0; |
|
| 2334 | + if ($too_late++) { |
|
| 2335 | + return; |
|
| 2336 | + } |
|
| 2337 | + |
|
| 2338 | + // Declaration des repertoires |
|
| 2339 | + |
|
| 2340 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2341 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2342 | + define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2343 | + } |
|
| 2344 | + |
|
| 2345 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2346 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2347 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2348 | + } |
|
| 2349 | + |
|
| 2350 | + // le nom du repertoire des librairies |
|
| 2351 | + if (!defined('_DIR_LIB')) { |
|
| 2352 | + define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2353 | + } |
|
| 2354 | + |
|
| 2355 | + if (!defined('_DIR_IMG')) { |
|
| 2356 | + define('_DIR_IMG', $pa); |
|
| 2357 | + } |
|
| 2358 | + if (!defined('_DIR_LOGOS')) { |
|
| 2359 | + define('_DIR_LOGOS', $pa); |
|
| 2360 | + } |
|
| 2361 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2362 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2363 | + } |
|
| 2364 | + |
|
| 2365 | + if (!defined('_DIR_DUMP')) { |
|
| 2366 | + define('_DIR_DUMP', $ti . "dump/"); |
|
| 2367 | + } |
|
| 2368 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2369 | + define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2370 | + } |
|
| 2371 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2372 | + define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2373 | + } |
|
| 2374 | + if (!defined('_DIR_CACHE')) { |
|
| 2375 | + define('_DIR_CACHE', $ti . "cache/"); |
|
| 2376 | + } |
|
| 2377 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2378 | + define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2379 | + } |
|
| 2380 | + if (!defined('_DIR_SKELS')) { |
|
| 2381 | + define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2382 | + } |
|
| 2383 | + if (!defined('_DIR_AIDE')) { |
|
| 2384 | + define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2385 | + } |
|
| 2386 | + if (!defined('_DIR_TMP')) { |
|
| 2387 | + define('_DIR_TMP', $ti); |
|
| 2388 | + } |
|
| 2389 | + |
|
| 2390 | + if (!defined('_DIR_VAR')) { |
|
| 2391 | + define('_DIR_VAR', $ta); |
|
| 2392 | + } |
|
| 2393 | + |
|
| 2394 | + if (!defined('_DIR_ETC')) { |
|
| 2395 | + define('_DIR_ETC', $pi); |
|
| 2396 | + } |
|
| 2397 | + if (!defined('_DIR_CONNECT')) { |
|
| 2398 | + define('_DIR_CONNECT', $pi); |
|
| 2399 | + } |
|
| 2400 | + if (!defined('_DIR_CHMOD')) { |
|
| 2401 | + define('_DIR_CHMOD', $pi); |
|
| 2402 | + } |
|
| 2403 | + |
|
| 2404 | + if (!isset($GLOBALS['test_dirs'])) |
|
| 2405 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2406 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2407 | + { |
|
| 2408 | + $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2409 | + } |
|
| 2410 | + |
|
| 2411 | + // Declaration des fichiers |
|
| 2412 | + |
|
| 2413 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2414 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2415 | + } |
|
| 2416 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2417 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2418 | + } |
|
| 2419 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2420 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2421 | + } |
|
| 2422 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2423 | + define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2424 | + } |
|
| 2425 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2426 | + define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2427 | + } |
|
| 2428 | + |
|
| 2429 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2430 | + if (!defined('_FILE_META')) { |
|
| 2431 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2432 | + } |
|
| 2433 | + if (!defined('_DIR_LOG')) { |
|
| 2434 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2435 | + } |
|
| 2436 | + if (!defined('_FILE_LOG')) { |
|
| 2437 | + define('_FILE_LOG', 'spip'); |
|
| 2438 | + } |
|
| 2439 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2440 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2441 | + } |
|
| 2442 | + |
|
| 2443 | + // Le fichier de connexion a la base de donnees |
|
| 2444 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2445 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2446 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2447 | + } |
|
| 2448 | + if (!defined('_FILE_CONNECT')) { |
|
| 2449 | + define('_FILE_CONNECT', |
|
| 2450 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2451 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2452 | + : false))); |
|
| 2453 | + } |
|
| 2454 | + |
|
| 2455 | + // Le fichier de reglages des droits |
|
| 2456 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2457 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2458 | + } |
|
| 2459 | + if (!defined('_FILE_CHMOD')) { |
|
| 2460 | + define('_FILE_CHMOD', |
|
| 2461 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2462 | + : false)); |
|
| 2463 | + } |
|
| 2464 | + |
|
| 2465 | + if (!defined('_FILE_LDAP')) { |
|
| 2466 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2467 | + } |
|
| 2468 | + |
|
| 2469 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2470 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2471 | + } |
|
| 2472 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2473 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2474 | + } |
|
| 2475 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2476 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2477 | + } |
|
| 2478 | + |
|
| 2479 | + // Definition des droits d'acces en ecriture |
|
| 2480 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2481 | + include_once _FILE_CHMOD; |
|
| 2482 | + } |
|
| 2483 | + |
|
| 2484 | + // Se mefier des fichiers mal remplis! |
|
| 2485 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2486 | + define('_SPIP_CHMOD', 0777); |
|
| 2487 | + } |
|
| 2488 | + |
|
| 2489 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2490 | + /** Le charset par défaut lors de l'installation */ |
|
| 2491 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2492 | + } |
|
| 2493 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2494 | + define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2495 | + } |
|
| 2496 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2497 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2498 | + } |
|
| 2499 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2500 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2501 | + } |
|
| 2502 | + |
|
| 2503 | + // La taille des Log |
|
| 2504 | + if (!defined('_MAX_LOG')) { |
|
| 2505 | + define('_MAX_LOG', 100); |
|
| 2506 | + } |
|
| 2507 | + |
|
| 2508 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2509 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2510 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2511 | + if (!defined('_OS_SERVEUR')) { |
|
| 2512 | + define('_OS_SERVEUR', 'windows'); |
|
| 2513 | + } |
|
| 2514 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2515 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2516 | + } // utiliser le flock php |
|
| 2517 | + } else { |
|
| 2518 | + if (!defined('_OS_SERVEUR')) { |
|
| 2519 | + define('_OS_SERVEUR', ''); |
|
| 2520 | + } |
|
| 2521 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2522 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2523 | + } // utiliser le flock php |
|
| 2524 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2525 | + } |
|
| 2526 | + |
|
| 2527 | + // Langue par defaut |
|
| 2528 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2529 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2530 | + } |
|
| 2531 | + |
|
| 2532 | + // |
|
| 2533 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2534 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2535 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2536 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2537 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2538 | + |
|
| 2539 | + // charger tout de suite le path et son cache |
|
| 2540 | + load_path_cache(); |
|
| 2541 | + |
|
| 2542 | + // *********** traiter les variables ************ |
|
| 2543 | + |
|
| 2544 | + // |
|
| 2545 | + // Securite |
|
| 2546 | + // |
|
| 2547 | + |
|
| 2548 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2549 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2550 | + die(); |
|
| 2551 | + } |
|
| 2552 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2553 | + spip_desinfecte($_GET); |
|
| 2554 | + spip_desinfecte($_POST); |
|
| 2555 | + spip_desinfecte($_COOKIE); |
|
| 2556 | + spip_desinfecte($_REQUEST); |
|
| 2557 | + |
|
| 2558 | + // appliquer le cookie_prefix |
|
| 2559 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2560 | + include_spip('inc/cookie'); |
|
| 2561 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2562 | + } |
|
| 2563 | + |
|
| 2564 | + // |
|
| 2565 | + // Capacites php (en fonction de la version) |
|
| 2566 | + // |
|
| 2567 | + $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2568 | + && function_exists("ini_get") |
|
| 2569 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2570 | + $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2571 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2572 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2573 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2574 | + |
|
| 2575 | + |
|
| 2576 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2577 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2578 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2579 | + } else { |
|
| 2580 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2581 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 2582 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2583 | + ) { |
|
| 2584 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2585 | + } |
|
| 2586 | + } |
|
| 2587 | + |
|
| 2588 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2589 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2590 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2591 | + } |
|
| 2592 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2593 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2594 | + } |
|
| 2595 | + |
|
| 2596 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2597 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2598 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2599 | + $inc_meta(); |
|
| 2600 | + |
|
| 2601 | + // nombre de repertoires depuis la racine |
|
| 2602 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2603 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2604 | + // le calcul est faux) |
|
| 2605 | + if (!_DIR_RESTREINT) { |
|
| 2606 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2607 | + } else { |
|
| 2608 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2609 | + $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2610 | + if (!$uri_ref |
|
| 2611 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2612 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2613 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2614 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2615 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2616 | + ) { |
|
| 2617 | + |
|
| 2618 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2619 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2620 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2621 | + } else { |
|
| 2622 | + $uri_ref = ""; |
|
| 2623 | + } |
|
| 2624 | + } |
|
| 2625 | + if (!$uri or !$uri_ref) { |
|
| 2626 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2627 | + } else { |
|
| 2628 | + $GLOBALS['profondeur_url'] = max(0, |
|
| 2629 | + substr_count($uri[0], '/') |
|
| 2630 | + - substr_count($uri_ref, '/')); |
|
| 2631 | + } |
|
| 2632 | + } |
|
| 2633 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2634 | + if (_FILE_CONNECT) { |
|
| 2635 | + if (verifier_visiteur() == '0minirezo' |
|
| 2636 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2637 | + and !isset($_COOKIE['spip_admin']) |
|
| 2638 | + ) { |
|
| 2639 | + clear_path_cache(); |
|
| 2640 | + } |
|
| 2641 | + } |
|
| 2643 | 2642 | |
| 2644 | 2643 | } |
| 2645 | 2644 | |
@@ -2649,174 +2648,174 @@ discard block |
||
| 2649 | 2648 | * |
| 2650 | 2649 | */ |
| 2651 | 2650 | function spip_initialisation_suite() { |
| 2652 | - static $too_late = 0; |
|
| 2653 | - if ($too_late++) { |
|
| 2654 | - return; |
|
| 2655 | - } |
|
| 2656 | - |
|
| 2657 | - // taille mini des login |
|
| 2658 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2659 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2660 | - } |
|
| 2661 | - |
|
| 2662 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2663 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2664 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2665 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2666 | - |
|
| 2667 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2668 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2669 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2670 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2671 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2672 | - |
|
| 2673 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2674 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2675 | - } |
|
| 2676 | - |
|
| 2677 | - |
|
| 2678 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2679 | - if (!defined('_IMG_QUALITE')) { |
|
| 2680 | - define('_IMG_QUALITE', 85); |
|
| 2681 | - } # valeur par defaut |
|
| 2682 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2683 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2684 | - } # surcharge pour la lib GD |
|
| 2685 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2686 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2687 | - } # surcharge pour imagick en ligne de commande |
|
| 2688 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2689 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2690 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2691 | - } # surcharge pour imagick en PHP |
|
| 2692 | - |
|
| 2693 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2694 | - define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2695 | - } // poids en octet |
|
| 2696 | - |
|
| 2697 | - // qq chaines standard |
|
| 2698 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2699 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2700 | - } |
|
| 2701 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2702 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2703 | - } |
|
| 2704 | - if (!defined('_SPIP_DUMP')) { |
|
| 2705 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2706 | - } |
|
| 2707 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2708 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2709 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2710 | - } |
|
| 2711 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2712 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2713 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2714 | - } |
|
| 2715 | - |
|
| 2716 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2717 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2718 | - } |
|
| 2719 | - |
|
| 2720 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2721 | - /** Définit le doctype de l’espace privé */ |
|
| 2722 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2723 | - } |
|
| 2724 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2725 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2726 | - define('_DOCTYPE_AIDE', |
|
| 2727 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2728 | - } |
|
| 2729 | - |
|
| 2730 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2731 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2732 | - * le script de l'espace public, alias index.php */ |
|
| 2733 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2734 | - } |
|
| 2735 | - if (!defined('_SPIP_PAGE')) { |
|
| 2736 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2737 | - define('_SPIP_PAGE', 'page'); |
|
| 2738 | - } |
|
| 2739 | - |
|
| 2740 | - // le script de l'espace prive |
|
| 2741 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2742 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2743 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2744 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2745 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2746 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2747 | - } else { |
|
| 2748 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2749 | - } |
|
| 2750 | - } |
|
| 2751 | - |
|
| 2752 | - |
|
| 2753 | - if (!defined('_SPIP_AJAX')) { |
|
| 2754 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2755 | - ? 1 |
|
| 2756 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2757 | - } |
|
| 2758 | - |
|
| 2759 | - // La requete est-elle en ajax ? |
|
| 2760 | - if (!defined('_AJAX')) { |
|
| 2761 | - define('_AJAX', |
|
| 2762 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2763 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2764 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2765 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2766 | - ) |
|
| 2767 | - 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 |
|
| 2768 | - ); |
|
| 2769 | - } |
|
| 2770 | - |
|
| 2771 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2772 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2773 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2774 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2775 | - define('_IMG_GD_MAX_PIXELS', |
|
| 2776 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2777 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2778 | - : 0); |
|
| 2779 | - } |
|
| 2780 | - |
|
| 2781 | - if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2782 | - define('_MEMORY_LIMIT_MIN', 16); |
|
| 2783 | - } // en Mo |
|
| 2784 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2785 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2786 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2787 | - if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2788 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2789 | - $unit = strtolower(substr($memory, -1)); |
|
| 2790 | - $memory = substr($memory, 0, -1); |
|
| 2791 | - switch ($unit) { |
|
| 2792 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2793 | - case 'g': |
|
| 2794 | - $memory *= 1024; |
|
| 2795 | - case 'm': |
|
| 2796 | - $memory *= 1024; |
|
| 2797 | - case 'k': |
|
| 2798 | - $memory *= 1024; |
|
| 2799 | - } |
|
| 2800 | - if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2801 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2802 | - if (trim(ini_get('memory_limit')) != $m) { |
|
| 2803 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2804 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2805 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2806 | - } |
|
| 2807 | - } |
|
| 2808 | - } else { |
|
| 2809 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2810 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2811 | - } |
|
| 2812 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2813 | - } |
|
| 2814 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2815 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2816 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2817 | - } |
|
| 2818 | - |
|
| 2819 | - init_var_mode(); |
|
| 2651 | + static $too_late = 0; |
|
| 2652 | + if ($too_late++) { |
|
| 2653 | + return; |
|
| 2654 | + } |
|
| 2655 | + |
|
| 2656 | + // taille mini des login |
|
| 2657 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2658 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2659 | + } |
|
| 2660 | + |
|
| 2661 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2662 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2663 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2664 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2665 | + |
|
| 2666 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2667 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2668 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2669 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2670 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2671 | + |
|
| 2672 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2673 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2674 | + } |
|
| 2675 | + |
|
| 2676 | + |
|
| 2677 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2678 | + if (!defined('_IMG_QUALITE')) { |
|
| 2679 | + define('_IMG_QUALITE', 85); |
|
| 2680 | + } # valeur par defaut |
|
| 2681 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2682 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2683 | + } # surcharge pour la lib GD |
|
| 2684 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2685 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2686 | + } # surcharge pour imagick en ligne de commande |
|
| 2687 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2688 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2689 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2690 | + } # surcharge pour imagick en PHP |
|
| 2691 | + |
|
| 2692 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2693 | + define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2694 | + } // poids en octet |
|
| 2695 | + |
|
| 2696 | + // qq chaines standard |
|
| 2697 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2698 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2699 | + } |
|
| 2700 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2701 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2702 | + } |
|
| 2703 | + if (!defined('_SPIP_DUMP')) { |
|
| 2704 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2705 | + } |
|
| 2706 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2707 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2708 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2709 | + } |
|
| 2710 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2711 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2712 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2713 | + } |
|
| 2714 | + |
|
| 2715 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2716 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2717 | + } |
|
| 2718 | + |
|
| 2719 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2720 | + /** Définit le doctype de l’espace privé */ |
|
| 2721 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2722 | + } |
|
| 2723 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2724 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2725 | + define('_DOCTYPE_AIDE', |
|
| 2726 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2727 | + } |
|
| 2728 | + |
|
| 2729 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2730 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2731 | + * le script de l'espace public, alias index.php */ |
|
| 2732 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2733 | + } |
|
| 2734 | + if (!defined('_SPIP_PAGE')) { |
|
| 2735 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2736 | + define('_SPIP_PAGE', 'page'); |
|
| 2737 | + } |
|
| 2738 | + |
|
| 2739 | + // le script de l'espace prive |
|
| 2740 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2741 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2742 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2743 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2744 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2745 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2746 | + } else { |
|
| 2747 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2748 | + } |
|
| 2749 | + } |
|
| 2750 | + |
|
| 2751 | + |
|
| 2752 | + if (!defined('_SPIP_AJAX')) { |
|
| 2753 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2754 | + ? 1 |
|
| 2755 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2756 | + } |
|
| 2757 | + |
|
| 2758 | + // La requete est-elle en ajax ? |
|
| 2759 | + if (!defined('_AJAX')) { |
|
| 2760 | + define('_AJAX', |
|
| 2761 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2762 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2763 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2764 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2765 | + ) |
|
| 2766 | + 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 |
|
| 2767 | + ); |
|
| 2768 | + } |
|
| 2769 | + |
|
| 2770 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2771 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2772 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2773 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2774 | + define('_IMG_GD_MAX_PIXELS', |
|
| 2775 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2776 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2777 | + : 0); |
|
| 2778 | + } |
|
| 2779 | + |
|
| 2780 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2781 | + define('_MEMORY_LIMIT_MIN', 16); |
|
| 2782 | + } // en Mo |
|
| 2783 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2784 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2785 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2786 | + if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2787 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2788 | + $unit = strtolower(substr($memory, -1)); |
|
| 2789 | + $memory = substr($memory, 0, -1); |
|
| 2790 | + switch ($unit) { |
|
| 2791 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2792 | + case 'g': |
|
| 2793 | + $memory *= 1024; |
|
| 2794 | + case 'm': |
|
| 2795 | + $memory *= 1024; |
|
| 2796 | + case 'k': |
|
| 2797 | + $memory *= 1024; |
|
| 2798 | + } |
|
| 2799 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2800 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2801 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 2802 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2803 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2804 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2805 | + } |
|
| 2806 | + } |
|
| 2807 | + } else { |
|
| 2808 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2809 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2810 | + } |
|
| 2811 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2812 | + } |
|
| 2813 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2814 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2815 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2816 | + } |
|
| 2817 | + |
|
| 2818 | + init_var_mode(); |
|
| 2820 | 2819 | } |
| 2821 | 2820 | |
| 2822 | 2821 | /** |
@@ -2850,129 +2849,129 @@ discard block |
||
| 2850 | 2849 | * ` var_mode` (calcul ou recalcul). |
| 2851 | 2850 | */ |
| 2852 | 2851 | function init_var_mode() { |
| 2853 | - static $done = false; |
|
| 2854 | - if (!$done) { |
|
| 2855 | - |
|
| 2856 | - if (isset($_GET['var_mode'])) { |
|
| 2857 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 2858 | - // tout le monde peut calcul/recalcul |
|
| 2859 | - if (!defined('_VAR_MODE')) { |
|
| 2860 | - if (in_array('recalcul', $var_mode)) { |
|
| 2861 | - define('_VAR_MODE', 'recalcul'); |
|
| 2862 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 2863 | - define('_VAR_MODE', 'calcul'); |
|
| 2864 | - } |
|
| 2865 | - } |
|
| 2866 | - $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2867 | - if ($var_mode) { |
|
| 2868 | - include_spip('inc/autoriser'); |
|
| 2869 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2870 | - if (autoriser( |
|
| 2871 | - ($_GET['var_mode'] == 'preview') |
|
| 2872 | - ? 'previsualiser' |
|
| 2873 | - : 'debug' |
|
| 2874 | - )) { |
|
| 2875 | - if (in_array('traduction', $var_mode)) { |
|
| 2876 | - // forcer le calcul pour passer dans traduire |
|
| 2877 | - if (!defined('_VAR_MODE')) { |
|
| 2878 | - define('_VAR_MODE', 'calcul'); |
|
| 2879 | - } |
|
| 2880 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2881 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2882 | - define('_VAR_NOCACHE', true); |
|
| 2883 | - } |
|
| 2884 | - $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2885 | - } |
|
| 2886 | - if (in_array('preview', $var_mode)) { |
|
| 2887 | - // basculer sur les criteres de preview dans les boucles |
|
| 2888 | - if (!defined('_VAR_PREVIEW')) { |
|
| 2889 | - define('_VAR_PREVIEW', true); |
|
| 2890 | - } |
|
| 2891 | - // forcer le calcul |
|
| 2892 | - if (!defined('_VAR_MODE')) { |
|
| 2893 | - define('_VAR_MODE', 'calcul'); |
|
| 2894 | - } |
|
| 2895 | - // et ne pas enregistrer de cache |
|
| 2896 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2897 | - define('_VAR_NOCACHE', true); |
|
| 2898 | - } |
|
| 2899 | - $var_mode = array_diff($var_mode, array('preview')); |
|
| 2900 | - } |
|
| 2901 | - if (in_array('inclure', $var_mode)) { |
|
| 2902 | - // forcer le compilo et ignorer les caches existants |
|
| 2903 | - if (!defined('_VAR_MODE')) { |
|
| 2904 | - define('_VAR_MODE', 'calcul'); |
|
| 2905 | - } |
|
| 2906 | - if (!defined('_VAR_INCLURE')) { |
|
| 2907 | - define('_VAR_INCLURE', true); |
|
| 2908 | - } |
|
| 2909 | - // et ne pas enregistrer de cache |
|
| 2910 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2911 | - define('_VAR_NOCACHE', true); |
|
| 2912 | - } |
|
| 2913 | - $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2914 | - } |
|
| 2915 | - if (in_array('urls', $var_mode)) { |
|
| 2916 | - // forcer le compilo et ignorer les caches existants |
|
| 2917 | - if (!defined('_VAR_MODE')) { |
|
| 2918 | - define('_VAR_MODE', 'calcul'); |
|
| 2919 | - } |
|
| 2920 | - if (!defined('_VAR_URLS')) { |
|
| 2921 | - define('_VAR_URLS', true); |
|
| 2922 | - } |
|
| 2923 | - $var_mode = array_diff($var_mode, array('urls')); |
|
| 2924 | - } |
|
| 2925 | - if (in_array('images', $var_mode)) { |
|
| 2926 | - // forcer le compilo et ignorer les caches existants |
|
| 2927 | - if (!defined('_VAR_MODE')) { |
|
| 2928 | - define('_VAR_MODE', 'calcul'); |
|
| 2929 | - } |
|
| 2930 | - // indiquer qu'on doit recalculer les images |
|
| 2931 | - if (!defined('_VAR_IMAGES')) { |
|
| 2932 | - define('_VAR_IMAGES', true); |
|
| 2933 | - } |
|
| 2934 | - $var_mode = array_diff($var_mode, array('images')); |
|
| 2935 | - } |
|
| 2936 | - if (in_array('debug', $var_mode)) { |
|
| 2937 | - if (!defined('_VAR_MODE')) { |
|
| 2938 | - define('_VAR_MODE', 'debug'); |
|
| 2939 | - } |
|
| 2940 | - // et ne pas enregistrer de cache |
|
| 2941 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2942 | - define('_VAR_NOCACHE', true); |
|
| 2943 | - } |
|
| 2944 | - $var_mode = array_diff($var_mode, array('debug')); |
|
| 2945 | - } |
|
| 2946 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2947 | - define('_VAR_MODE', reset($var_mode)); |
|
| 2948 | - } |
|
| 2949 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2950 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2951 | - . " " . _VAR_MODE); |
|
| 2952 | - } |
|
| 2953 | - } // pas autorise ? |
|
| 2954 | - else { |
|
| 2955 | - // si on n'est pas connecte on se redirige |
|
| 2956 | - if (!$GLOBALS['visiteur_session']) { |
|
| 2957 | - include_spip('inc/headers'); |
|
| 2958 | - redirige_par_entete(generer_url_public('login', |
|
| 2959 | - 'url=' . rawurlencode( |
|
| 2960 | - parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
|
| 2961 | - ), true)); |
|
| 2962 | - } |
|
| 2963 | - // sinon tant pis |
|
| 2964 | - } |
|
| 2965 | - } |
|
| 2966 | - } |
|
| 2967 | - if (!defined('_VAR_MODE')) { |
|
| 2968 | - /** |
|
| 2969 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 2970 | - * @see init_var_mode() |
|
| 2971 | - */ |
|
| 2972 | - define('_VAR_MODE', false); |
|
| 2973 | - } |
|
| 2974 | - $done = true; |
|
| 2975 | - } |
|
| 2852 | + static $done = false; |
|
| 2853 | + if (!$done) { |
|
| 2854 | + |
|
| 2855 | + if (isset($_GET['var_mode'])) { |
|
| 2856 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 2857 | + // tout le monde peut calcul/recalcul |
|
| 2858 | + if (!defined('_VAR_MODE')) { |
|
| 2859 | + if (in_array('recalcul', $var_mode)) { |
|
| 2860 | + define('_VAR_MODE', 'recalcul'); |
|
| 2861 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 2862 | + define('_VAR_MODE', 'calcul'); |
|
| 2863 | + } |
|
| 2864 | + } |
|
| 2865 | + $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2866 | + if ($var_mode) { |
|
| 2867 | + include_spip('inc/autoriser'); |
|
| 2868 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2869 | + if (autoriser( |
|
| 2870 | + ($_GET['var_mode'] == 'preview') |
|
| 2871 | + ? 'previsualiser' |
|
| 2872 | + : 'debug' |
|
| 2873 | + )) { |
|
| 2874 | + if (in_array('traduction', $var_mode)) { |
|
| 2875 | + // forcer le calcul pour passer dans traduire |
|
| 2876 | + if (!defined('_VAR_MODE')) { |
|
| 2877 | + define('_VAR_MODE', 'calcul'); |
|
| 2878 | + } |
|
| 2879 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2880 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2881 | + define('_VAR_NOCACHE', true); |
|
| 2882 | + } |
|
| 2883 | + $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2884 | + } |
|
| 2885 | + if (in_array('preview', $var_mode)) { |
|
| 2886 | + // basculer sur les criteres de preview dans les boucles |
|
| 2887 | + if (!defined('_VAR_PREVIEW')) { |
|
| 2888 | + define('_VAR_PREVIEW', true); |
|
| 2889 | + } |
|
| 2890 | + // forcer le calcul |
|
| 2891 | + if (!defined('_VAR_MODE')) { |
|
| 2892 | + define('_VAR_MODE', 'calcul'); |
|
| 2893 | + } |
|
| 2894 | + // et ne pas enregistrer de cache |
|
| 2895 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2896 | + define('_VAR_NOCACHE', true); |
|
| 2897 | + } |
|
| 2898 | + $var_mode = array_diff($var_mode, array('preview')); |
|
| 2899 | + } |
|
| 2900 | + if (in_array('inclure', $var_mode)) { |
|
| 2901 | + // forcer le compilo et ignorer les caches existants |
|
| 2902 | + if (!defined('_VAR_MODE')) { |
|
| 2903 | + define('_VAR_MODE', 'calcul'); |
|
| 2904 | + } |
|
| 2905 | + if (!defined('_VAR_INCLURE')) { |
|
| 2906 | + define('_VAR_INCLURE', true); |
|
| 2907 | + } |
|
| 2908 | + // et ne pas enregistrer de cache |
|
| 2909 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2910 | + define('_VAR_NOCACHE', true); |
|
| 2911 | + } |
|
| 2912 | + $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2913 | + } |
|
| 2914 | + if (in_array('urls', $var_mode)) { |
|
| 2915 | + // forcer le compilo et ignorer les caches existants |
|
| 2916 | + if (!defined('_VAR_MODE')) { |
|
| 2917 | + define('_VAR_MODE', 'calcul'); |
|
| 2918 | + } |
|
| 2919 | + if (!defined('_VAR_URLS')) { |
|
| 2920 | + define('_VAR_URLS', true); |
|
| 2921 | + } |
|
| 2922 | + $var_mode = array_diff($var_mode, array('urls')); |
|
| 2923 | + } |
|
| 2924 | + if (in_array('images', $var_mode)) { |
|
| 2925 | + // forcer le compilo et ignorer les caches existants |
|
| 2926 | + if (!defined('_VAR_MODE')) { |
|
| 2927 | + define('_VAR_MODE', 'calcul'); |
|
| 2928 | + } |
|
| 2929 | + // indiquer qu'on doit recalculer les images |
|
| 2930 | + if (!defined('_VAR_IMAGES')) { |
|
| 2931 | + define('_VAR_IMAGES', true); |
|
| 2932 | + } |
|
| 2933 | + $var_mode = array_diff($var_mode, array('images')); |
|
| 2934 | + } |
|
| 2935 | + if (in_array('debug', $var_mode)) { |
|
| 2936 | + if (!defined('_VAR_MODE')) { |
|
| 2937 | + define('_VAR_MODE', 'debug'); |
|
| 2938 | + } |
|
| 2939 | + // et ne pas enregistrer de cache |
|
| 2940 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2941 | + define('_VAR_NOCACHE', true); |
|
| 2942 | + } |
|
| 2943 | + $var_mode = array_diff($var_mode, array('debug')); |
|
| 2944 | + } |
|
| 2945 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2946 | + define('_VAR_MODE', reset($var_mode)); |
|
| 2947 | + } |
|
| 2948 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2949 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2950 | + . " " . _VAR_MODE); |
|
| 2951 | + } |
|
| 2952 | + } // pas autorise ? |
|
| 2953 | + else { |
|
| 2954 | + // si on n'est pas connecte on se redirige |
|
| 2955 | + if (!$GLOBALS['visiteur_session']) { |
|
| 2956 | + include_spip('inc/headers'); |
|
| 2957 | + redirige_par_entete(generer_url_public('login', |
|
| 2958 | + 'url=' . rawurlencode( |
|
| 2959 | + parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
|
| 2960 | + ), true)); |
|
| 2961 | + } |
|
| 2962 | + // sinon tant pis |
|
| 2963 | + } |
|
| 2964 | + } |
|
| 2965 | + } |
|
| 2966 | + if (!defined('_VAR_MODE')) { |
|
| 2967 | + /** |
|
| 2968 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 2969 | + * @see init_var_mode() |
|
| 2970 | + */ |
|
| 2971 | + define('_VAR_MODE', false); |
|
| 2972 | + } |
|
| 2973 | + $done = true; |
|
| 2974 | + } |
|
| 2976 | 2975 | } |
| 2977 | 2976 | |
| 2978 | 2977 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
@@ -2980,85 +2979,85 @@ discard block |
||
| 2980 | 2979 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 2981 | 2980 | // https://code.spip.net/@spip_desinfecte |
| 2982 | 2981 | function spip_desinfecte(&$t, $deep = true) { |
| 2983 | - foreach ($t as $key => $val) { |
|
| 2984 | - if (is_string($t[$key])) { |
|
| 2985 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 2986 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 2987 | - else { |
|
| 2988 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 2989 | - spip_desinfecte($t[$key], $deep); |
|
| 2990 | - } |
|
| 2991 | - } |
|
| 2992 | - } |
|
| 2982 | + foreach ($t as $key => $val) { |
|
| 2983 | + if (is_string($t[$key])) { |
|
| 2984 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 2985 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 2986 | + else { |
|
| 2987 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 2988 | + spip_desinfecte($t[$key], $deep); |
|
| 2989 | + } |
|
| 2990 | + } |
|
| 2991 | + } |
|
| 2993 | 2992 | } |
| 2994 | 2993 | |
| 2995 | 2994 | // retourne le statut du visiteur s'il s'annonce |
| 2996 | 2995 | |
| 2997 | 2996 | // https://code.spip.net/@verifier_visiteur |
| 2998 | 2997 | function verifier_visiteur() { |
| 2999 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 3000 | - // il faut forcer l'init si ce n'est fait |
|
| 3001 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3002 | - // certaines constantes |
|
| 3003 | - @spip_initialisation_core( |
|
| 3004 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3005 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3006 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3007 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3008 | - ); |
|
| 3009 | - |
|
| 3010 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3011 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3012 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 3013 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3014 | - $variables_session = array('session_nom', 'session_email'); |
|
| 3015 | - foreach ($variables_session as $var) { |
|
| 3016 | - if (_request($var) !== null) { |
|
| 3017 | - $init = true; |
|
| 3018 | - break; |
|
| 3019 | - } |
|
| 3020 | - } |
|
| 3021 | - if (isset($init)) { |
|
| 3022 | - #@spip_initialisation_suite(); |
|
| 3023 | - $session = charger_fonction('session', 'inc'); |
|
| 3024 | - $session(); |
|
| 3025 | - include_spip('inc/texte'); |
|
| 3026 | - foreach ($variables_session as $var) { |
|
| 3027 | - if (($a = _request($var)) !== null) { |
|
| 3028 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3029 | - } |
|
| 3030 | - } |
|
| 3031 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3032 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3033 | - } |
|
| 3034 | - $session($GLOBALS['visiteur_session']); |
|
| 3035 | - |
|
| 3036 | - return 0; |
|
| 3037 | - } |
|
| 3038 | - |
|
| 3039 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3040 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3041 | - |
|
| 3042 | - $session = charger_fonction('session', 'inc'); |
|
| 3043 | - if ($session()) { |
|
| 3044 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3045 | - } |
|
| 3046 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3047 | - include_spip('inc/auth'); |
|
| 3048 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3049 | - } |
|
| 3050 | - if ($h) { |
|
| 3051 | - $GLOBALS['visiteur_session'] = $h; |
|
| 3052 | - |
|
| 3053 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3054 | - } |
|
| 3055 | - } |
|
| 3056 | - |
|
| 3057 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3058 | - include_spip('inc/lang'); |
|
| 3059 | - utiliser_langue_visiteur(); |
|
| 3060 | - |
|
| 3061 | - return false; |
|
| 2998 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 2999 | + // il faut forcer l'init si ce n'est fait |
|
| 3000 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3001 | + // certaines constantes |
|
| 3002 | + @spip_initialisation_core( |
|
| 3003 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3004 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3005 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3006 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3007 | + ); |
|
| 3008 | + |
|
| 3009 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3010 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3011 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 3012 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3013 | + $variables_session = array('session_nom', 'session_email'); |
|
| 3014 | + foreach ($variables_session as $var) { |
|
| 3015 | + if (_request($var) !== null) { |
|
| 3016 | + $init = true; |
|
| 3017 | + break; |
|
| 3018 | + } |
|
| 3019 | + } |
|
| 3020 | + if (isset($init)) { |
|
| 3021 | + #@spip_initialisation_suite(); |
|
| 3022 | + $session = charger_fonction('session', 'inc'); |
|
| 3023 | + $session(); |
|
| 3024 | + include_spip('inc/texte'); |
|
| 3025 | + foreach ($variables_session as $var) { |
|
| 3026 | + if (($a = _request($var)) !== null) { |
|
| 3027 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3028 | + } |
|
| 3029 | + } |
|
| 3030 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3031 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3032 | + } |
|
| 3033 | + $session($GLOBALS['visiteur_session']); |
|
| 3034 | + |
|
| 3035 | + return 0; |
|
| 3036 | + } |
|
| 3037 | + |
|
| 3038 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3039 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3040 | + |
|
| 3041 | + $session = charger_fonction('session', 'inc'); |
|
| 3042 | + if ($session()) { |
|
| 3043 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3044 | + } |
|
| 3045 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3046 | + include_spip('inc/auth'); |
|
| 3047 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3048 | + } |
|
| 3049 | + if ($h) { |
|
| 3050 | + $GLOBALS['visiteur_session'] = $h; |
|
| 3051 | + |
|
| 3052 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3053 | + } |
|
| 3054 | + } |
|
| 3055 | + |
|
| 3056 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3057 | + include_spip('inc/lang'); |
|
| 3058 | + utiliser_langue_visiteur(); |
|
| 3059 | + |
|
| 3060 | + return false; |
|
| 3062 | 3061 | } |
| 3063 | 3062 | |
| 3064 | 3063 | |
@@ -3081,21 +3080,21 @@ discard block |
||
| 3081 | 3080 | * - string Langue utilisée. |
| 3082 | 3081 | **/ |
| 3083 | 3082 | function lang_select($lang = null) { |
| 3084 | - static $pile_langues = array(); |
|
| 3085 | - if (!function_exists('changer_langue')) { |
|
| 3086 | - include_spip('inc/lang'); |
|
| 3087 | - } |
|
| 3088 | - if ($lang === null) { |
|
| 3089 | - $lang = array_pop($pile_langues); |
|
| 3090 | - } else { |
|
| 3091 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3092 | - } |
|
| 3093 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3094 | - return $lang; |
|
| 3095 | - } |
|
| 3096 | - changer_langue($lang); |
|
| 3083 | + static $pile_langues = array(); |
|
| 3084 | + if (!function_exists('changer_langue')) { |
|
| 3085 | + include_spip('inc/lang'); |
|
| 3086 | + } |
|
| 3087 | + if ($lang === null) { |
|
| 3088 | + $lang = array_pop($pile_langues); |
|
| 3089 | + } else { |
|
| 3090 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3091 | + } |
|
| 3092 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3093 | + return $lang; |
|
| 3094 | + } |
|
| 3095 | + changer_langue($lang); |
|
| 3097 | 3096 | |
| 3098 | - return $lang; |
|
| 3097 | + return $lang; |
|
| 3099 | 3098 | } |
| 3100 | 3099 | |
| 3101 | 3100 | /** |
@@ -3112,19 +3111,19 @@ discard block |
||
| 3112 | 3111 | * Identifiant de la session |
| 3113 | 3112 | **/ |
| 3114 | 3113 | function spip_session($force = false) { |
| 3115 | - static $session; |
|
| 3116 | - if ($force or !isset($session)) { |
|
| 3117 | - $s = pipeline('definir_session', |
|
| 3118 | - $GLOBALS['visiteur_session'] |
|
| 3119 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3120 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3121 | - : '' |
|
| 3122 | - ); |
|
| 3123 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3124 | - } |
|
| 3114 | + static $session; |
|
| 3115 | + if ($force or !isset($session)) { |
|
| 3116 | + $s = pipeline('definir_session', |
|
| 3117 | + $GLOBALS['visiteur_session'] |
|
| 3118 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3119 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3120 | + : '' |
|
| 3121 | + ); |
|
| 3122 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3123 | + } |
|
| 3125 | 3124 | |
| 3126 | - #spip_log('session: '.$session); |
|
| 3127 | - return $session; |
|
| 3125 | + #spip_log('session: '.$session); |
|
| 3126 | + return $session; |
|
| 3128 | 3127 | } |
| 3129 | 3128 | |
| 3130 | 3129 | |
@@ -3143,9 +3142,9 @@ discard block |
||
| 3143 | 3142 | * Lien sur une icone d'aide |
| 3144 | 3143 | **/ |
| 3145 | 3144 | function aider($aide = '', $distante = false) { |
| 3146 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3145 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3147 | 3146 | |
| 3148 | - return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3147 | + return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3149 | 3148 | } |
| 3150 | 3149 | |
| 3151 | 3150 | /** |
@@ -3155,24 +3154,24 @@ discard block |
||
| 3155 | 3154 | */ |
| 3156 | 3155 | function exec_info_dist() { |
| 3157 | 3156 | |
| 3158 | - include_spip('inc/autoriser'); |
|
| 3159 | - if (autoriser('phpinfos')) { |
|
| 3160 | - $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3161 | - $cookies_backup = []; |
|
| 3162 | - foreach ($cookies_masques as $k) { |
|
| 3163 | - if (!empty($_COOKIE[$k])) { |
|
| 3164 | - $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3165 | - $_COOKIE[$k] = '******************************'; |
|
| 3166 | - } |
|
| 3167 | - } |
|
| 3168 | - phpinfo(); |
|
| 3169 | - foreach ($cookies_backup as $k => $v) { |
|
| 3170 | - $_COOKIE[$k] = $v; |
|
| 3171 | - } |
|
| 3172 | - } else { |
|
| 3173 | - include_spip('inc/filtres'); |
|
| 3174 | - sinon_interdire_acces(); |
|
| 3175 | - } |
|
| 3157 | + include_spip('inc/autoriser'); |
|
| 3158 | + if (autoriser('phpinfos')) { |
|
| 3159 | + $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3160 | + $cookies_backup = []; |
|
| 3161 | + foreach ($cookies_masques as $k) { |
|
| 3162 | + if (!empty($_COOKIE[$k])) { |
|
| 3163 | + $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3164 | + $_COOKIE[$k] = '******************************'; |
|
| 3165 | + } |
|
| 3166 | + } |
|
| 3167 | + phpinfo(); |
|
| 3168 | + foreach ($cookies_backup as $k => $v) { |
|
| 3169 | + $_COOKIE[$k] = $v; |
|
| 3170 | + } |
|
| 3171 | + } else { |
|
| 3172 | + include_spip('inc/filtres'); |
|
| 3173 | + sinon_interdire_acces(); |
|
| 3174 | + } |
|
| 3176 | 3175 | } |
| 3177 | 3176 | |
| 3178 | 3177 | /** |
@@ -3192,13 +3191,13 @@ discard block |
||
| 3192 | 3191 | * - string si $message à false. |
| 3193 | 3192 | **/ |
| 3194 | 3193 | function erreur_squelette($message = '', $lieu = '') { |
| 3195 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3196 | - if (is_array($lieu)) { |
|
| 3197 | - include_spip('public/compiler'); |
|
| 3198 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3199 | - } |
|
| 3194 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3195 | + if (is_array($lieu)) { |
|
| 3196 | + include_spip('public/compiler'); |
|
| 3197 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3198 | + } |
|
| 3200 | 3199 | |
| 3201 | - return $debusquer($message, $lieu); |
|
| 3200 | + return $debusquer($message, $lieu); |
|
| 3202 | 3201 | } |
| 3203 | 3202 | |
| 3204 | 3203 | /** |
@@ -3235,109 +3234,109 @@ discard block |
||
| 3235 | 3234 | * - ou tableau d'information sur le squelette. |
| 3236 | 3235 | */ |
| 3237 | 3236 | function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') { |
| 3238 | - if (!function_exists('evaluer_fond')) { |
|
| 3239 | - include_spip('public/assembler'); |
|
| 3240 | - } |
|
| 3241 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3242 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3243 | - if (!is_array($options)) { |
|
| 3244 | - $options = array('trim' => $options); |
|
| 3245 | - } |
|
| 3246 | - if (!isset($options['trim'])) { |
|
| 3247 | - $options['trim'] = true; |
|
| 3248 | - } |
|
| 3249 | - |
|
| 3250 | - if (isset($contexte['connect'])) { |
|
| 3251 | - $connect = $contexte['connect']; |
|
| 3252 | - unset($contexte['connect']); |
|
| 3253 | - } |
|
| 3254 | - |
|
| 3255 | - $texte = ""; |
|
| 3256 | - $pages = array(); |
|
| 3257 | - $lang_select = ''; |
|
| 3258 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3259 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3260 | - if (!isset($contexte['lang'])) { |
|
| 3261 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3262 | - } |
|
| 3263 | - |
|
| 3264 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3265 | - $lang_select = lang_select($contexte['lang']); |
|
| 3266 | - } |
|
| 3267 | - } |
|
| 3268 | - |
|
| 3269 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3270 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3271 | - } |
|
| 3272 | - |
|
| 3273 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3274 | - |
|
| 3275 | - // fix #4235 |
|
| 3276 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3277 | - |
|
| 3278 | - |
|
| 3279 | - foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3237 | + if (!function_exists('evaluer_fond')) { |
|
| 3238 | + include_spip('public/assembler'); |
|
| 3239 | + } |
|
| 3240 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3241 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3242 | + if (!is_array($options)) { |
|
| 3243 | + $options = array('trim' => $options); |
|
| 3244 | + } |
|
| 3245 | + if (!isset($options['trim'])) { |
|
| 3246 | + $options['trim'] = true; |
|
| 3247 | + } |
|
| 3248 | + |
|
| 3249 | + if (isset($contexte['connect'])) { |
|
| 3250 | + $connect = $contexte['connect']; |
|
| 3251 | + unset($contexte['connect']); |
|
| 3252 | + } |
|
| 3253 | + |
|
| 3254 | + $texte = ""; |
|
| 3255 | + $pages = array(); |
|
| 3256 | + $lang_select = ''; |
|
| 3257 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3258 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3259 | + if (!isset($contexte['lang'])) { |
|
| 3260 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3261 | + } |
|
| 3262 | + |
|
| 3263 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3264 | + $lang_select = lang_select($contexte['lang']); |
|
| 3265 | + } |
|
| 3266 | + } |
|
| 3267 | + |
|
| 3268 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3269 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3270 | + } |
|
| 3271 | + |
|
| 3272 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3273 | + |
|
| 3274 | + // fix #4235 |
|
| 3275 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3276 | + |
|
| 3277 | + |
|
| 3278 | + foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3280 | 3279 | |
| 3281 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3282 | - |
|
| 3283 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3284 | - if ($page === '') { |
|
| 3285 | - $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3286 | - $a = array('fichier' => $f); |
|
| 3287 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3288 | - erreur_squelette($erreur, $c); |
|
| 3289 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3290 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3291 | - } |
|
| 3292 | - |
|
| 3293 | - $page = pipeline('recuperer_fond', array( |
|
| 3294 | - 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3295 | - 'data' => $page |
|
| 3296 | - )); |
|
| 3297 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3298 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3299 | - include_spip('inc/filtres'); |
|
| 3300 | - } |
|
| 3301 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3302 | - array_merge( |
|
| 3303 | - $contexte, |
|
| 3304 | - array('fond' => $f), |
|
| 3305 | - ($connect ? array('connect' => $connect) : array()) |
|
| 3306 | - ), |
|
| 3307 | - '', |
|
| 3308 | - $page['texte'], |
|
| 3309 | - $options['ajax'] |
|
| 3310 | - ); |
|
| 3311 | - } |
|
| 3312 | - |
|
| 3313 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3314 | - $pages[] = $page; |
|
| 3315 | - } else { |
|
| 3316 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3317 | - } |
|
| 3280 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3281 | + |
|
| 3282 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3283 | + if ($page === '') { |
|
| 3284 | + $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3285 | + $a = array('fichier' => $f); |
|
| 3286 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3287 | + erreur_squelette($erreur, $c); |
|
| 3288 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3289 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3290 | + } |
|
| 3291 | + |
|
| 3292 | + $page = pipeline('recuperer_fond', array( |
|
| 3293 | + 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3294 | + 'data' => $page |
|
| 3295 | + )); |
|
| 3296 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3297 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3298 | + include_spip('inc/filtres'); |
|
| 3299 | + } |
|
| 3300 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3301 | + array_merge( |
|
| 3302 | + $contexte, |
|
| 3303 | + array('fond' => $f), |
|
| 3304 | + ($connect ? array('connect' => $connect) : array()) |
|
| 3305 | + ), |
|
| 3306 | + '', |
|
| 3307 | + $page['texte'], |
|
| 3308 | + $options['ajax'] |
|
| 3309 | + ); |
|
| 3310 | + } |
|
| 3311 | + |
|
| 3312 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3313 | + $pages[] = $page; |
|
| 3314 | + } else { |
|
| 3315 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3316 | + } |
|
| 3318 | 3317 | |
| 3319 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3320 | - if (isset($page['invalideurs']['session'])){ |
|
| 3321 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3322 | - } |
|
| 3323 | - } |
|
| 3318 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3319 | + if (isset($page['invalideurs']['session'])){ |
|
| 3320 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3321 | + } |
|
| 3322 | + } |
|
| 3324 | 3323 | |
| 3325 | - // restaurer le sessionnement du contexte appelant, |
|
| 3326 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3327 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3328 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3329 | - } |
|
| 3324 | + // restaurer le sessionnement du contexte appelant, |
|
| 3325 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3326 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3327 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3328 | + } |
|
| 3330 | 3329 | |
| 3331 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3330 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3332 | 3331 | |
| 3333 | - if ($lang_select) { |
|
| 3334 | - lang_select(); |
|
| 3335 | - } |
|
| 3336 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3337 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3338 | - } else { |
|
| 3339 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3340 | - } |
|
| 3332 | + if ($lang_select) { |
|
| 3333 | + lang_select(); |
|
| 3334 | + } |
|
| 3335 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3336 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3337 | + } else { |
|
| 3338 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3339 | + } |
|
| 3341 | 3340 | } |
| 3342 | 3341 | |
| 3343 | 3342 | /** |
@@ -3347,7 +3346,7 @@ discard block |
||
| 3347 | 3346 | * @return string |
| 3348 | 3347 | */ |
| 3349 | 3348 | function trouve_modele($nom) { |
| 3350 | - return trouver_fond($nom, 'modeles/'); |
|
| 3349 | + return trouver_fond($nom, 'modeles/'); |
|
| 3351 | 3350 | } |
| 3352 | 3351 | |
| 3353 | 3352 | /** |
@@ -3363,21 +3362,21 @@ discard block |
||
| 3363 | 3362 | * @return array|string |
| 3364 | 3363 | */ |
| 3365 | 3364 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3366 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3367 | - if (!$pathinfo) { |
|
| 3368 | - return $f; |
|
| 3369 | - } |
|
| 3370 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3371 | - $p = pathinfo($f); |
|
| 3372 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3373 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3374 | - } |
|
| 3375 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3376 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3377 | - } |
|
| 3378 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3365 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3366 | + if (!$pathinfo) { |
|
| 3367 | + return $f; |
|
| 3368 | + } |
|
| 3369 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3370 | + $p = pathinfo($f); |
|
| 3371 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3372 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3373 | + } |
|
| 3374 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3375 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3376 | + } |
|
| 3377 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3379 | 3378 | |
| 3380 | - return $p; |
|
| 3379 | + return $p; |
|
| 3381 | 3380 | } |
| 3382 | 3381 | |
| 3383 | 3382 | /** |
@@ -3398,24 +3397,24 @@ discard block |
||
| 3398 | 3397 | * Nom de l'exec, sinon chaîne vide. |
| 3399 | 3398 | **/ |
| 3400 | 3399 | function tester_url_ecrire($nom) { |
| 3401 | - static $exec = array(); |
|
| 3402 | - if (isset($exec[$nom])) { |
|
| 3403 | - return $exec[$nom]; |
|
| 3404 | - } |
|
| 3405 | - // tester si c'est une page en squelette |
|
| 3406 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3407 | - return $exec[$nom] = 'fond'; |
|
| 3408 | - } // compat skels orthogonaux version precedente |
|
| 3409 | - elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3410 | - return $exec[$nom] = 'fond_monobloc'; |
|
| 3411 | - } // echafaudage d'un fond ! |
|
| 3412 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3413 | - return $exec[$nom] = 'fond'; |
|
| 3414 | - } |
|
| 3415 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3416 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3417 | - // et des define intrusifs potentiels |
|
| 3418 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3400 | + static $exec = array(); |
|
| 3401 | + if (isset($exec[$nom])) { |
|
| 3402 | + return $exec[$nom]; |
|
| 3403 | + } |
|
| 3404 | + // tester si c'est une page en squelette |
|
| 3405 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3406 | + return $exec[$nom] = 'fond'; |
|
| 3407 | + } // compat skels orthogonaux version precedente |
|
| 3408 | + elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3409 | + return $exec[$nom] = 'fond_monobloc'; |
|
| 3410 | + } // echafaudage d'un fond ! |
|
| 3411 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3412 | + return $exec[$nom] = 'fond'; |
|
| 3413 | + } |
|
| 3414 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3415 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3416 | + // et des define intrusifs potentiels |
|
| 3417 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3419 | 3418 | } |
| 3420 | 3419 | |
| 3421 | 3420 | |
@@ -3431,10 +3430,10 @@ discard block |
||
| 3431 | 3430 | * @return bool true si le module est chargé |
| 3432 | 3431 | **/ |
| 3433 | 3432 | function charger_php_extension($module) { |
| 3434 | - if (extension_loaded($module)) { |
|
| 3435 | - return true; |
|
| 3436 | - } |
|
| 3437 | - return false; |
|
| 3433 | + if (extension_loaded($module)) { |
|
| 3434 | + return true; |
|
| 3435 | + } |
|
| 3436 | + return false; |
|
| 3438 | 3437 | } |
| 3439 | 3438 | |
| 3440 | 3439 | |
@@ -3445,8 +3444,8 @@ discard block |
||
| 3445 | 3444 | * true si la constante _VERSION_HTML n'est pas définie ou égale à html5 |
| 3446 | 3445 | **/ |
| 3447 | 3446 | function html5_permis() { |
| 3448 | - return (!defined('_VERSION_HTML') |
|
| 3449 | - or _VERSION_HTML === 'html5'); |
|
| 3447 | + return (!defined('_VERSION_HTML') |
|
| 3448 | + or _VERSION_HTML === 'html5'); |
|
| 3450 | 3449 | } |
| 3451 | 3450 | |
| 3452 | 3451 | /** |
@@ -3456,30 +3455,30 @@ discard block |
||
| 3456 | 3455 | * @return array |
| 3457 | 3456 | */ |
| 3458 | 3457 | function formats_image_acceptables($gd = null, $svg_allowed = true) { |
| 3459 | - $formats = null; |
|
| 3460 | - if (!is_null($gd)) { |
|
| 3461 | - $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3462 | - if (isset($GLOBALS['meta'][$config])) { |
|
| 3463 | - $formats = $GLOBALS['meta'][$config]; |
|
| 3464 | - $formats = explode(',', $formats); |
|
| 3465 | - $formats = array_filter($formats); |
|
| 3466 | - $formats = array_map('trim', $formats); |
|
| 3467 | - } |
|
| 3468 | - } |
|
| 3469 | - if (is_null($formats)) { |
|
| 3470 | - include_spip('inc/filtres_images_lib_mini'); |
|
| 3471 | - $formats = _image_extensions_acceptees_en_entree(); |
|
| 3472 | - } |
|
| 3473 | - |
|
| 3474 | - if ($svg_allowed) { |
|
| 3475 | - if (!in_array('svg', $formats)) { |
|
| 3476 | - $formats[] = 'svg'; |
|
| 3477 | - } |
|
| 3478 | - } |
|
| 3479 | - else { |
|
| 3480 | - $formats = array_diff($formats, ['svg']); |
|
| 3481 | - } |
|
| 3482 | - return $formats; |
|
| 3458 | + $formats = null; |
|
| 3459 | + if (!is_null($gd)) { |
|
| 3460 | + $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3461 | + if (isset($GLOBALS['meta'][$config])) { |
|
| 3462 | + $formats = $GLOBALS['meta'][$config]; |
|
| 3463 | + $formats = explode(',', $formats); |
|
| 3464 | + $formats = array_filter($formats); |
|
| 3465 | + $formats = array_map('trim', $formats); |
|
| 3466 | + } |
|
| 3467 | + } |
|
| 3468 | + if (is_null($formats)) { |
|
| 3469 | + include_spip('inc/filtres_images_lib_mini'); |
|
| 3470 | + $formats = _image_extensions_acceptees_en_entree(); |
|
| 3471 | + } |
|
| 3472 | + |
|
| 3473 | + if ($svg_allowed) { |
|
| 3474 | + if (!in_array('svg', $formats)) { |
|
| 3475 | + $formats[] = 'svg'; |
|
| 3476 | + } |
|
| 3477 | + } |
|
| 3478 | + else { |
|
| 3479 | + $formats = array_diff($formats, ['svg']); |
|
| 3480 | + } |
|
| 3481 | + return $formats; |
|
| 3483 | 3482 | } |
| 3484 | 3483 | |
| 3485 | 3484 | /** |
@@ -3488,21 +3487,21 @@ discard block |
||
| 3488 | 3487 | * @return array|bool |
| 3489 | 3488 | */ |
| 3490 | 3489 | function spip_getimagesize($fichier) { |
| 3491 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3490 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3492 | 3491 | |
| 3493 | - include_spip("inc/svg"); |
|
| 3494 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3495 | - list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs); |
|
| 3496 | - $imagesize = [ |
|
| 3497 | - $width, |
|
| 3498 | - $height, |
|
| 3499 | - IMAGETYPE_SVG, |
|
| 3500 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3501 | - "mime" => "image/svg+xml" |
|
| 3502 | - ]; |
|
| 3503 | - } |
|
| 3504 | - } |
|
| 3505 | - return $imagesize; |
|
| 3492 | + include_spip("inc/svg"); |
|
| 3493 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3494 | + list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs); |
|
| 3495 | + $imagesize = [ |
|
| 3496 | + $width, |
|
| 3497 | + $height, |
|
| 3498 | + IMAGETYPE_SVG, |
|
| 3499 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3500 | + "mime" => "image/svg+xml" |
|
| 3501 | + ]; |
|
| 3502 | + } |
|
| 3503 | + } |
|
| 3504 | + return $imagesize; |
|
| 3506 | 3505 | } |
| 3507 | 3506 | |
| 3508 | 3507 | |
@@ -3522,7 +3521,7 @@ discard block |
||
| 3522 | 3521 | * @return mixed Valeur de la meta. |
| 3523 | 3522 | **/ |
| 3524 | 3523 | function lire_meta($nom) { |
| 3525 | - return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3524 | + return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3526 | 3525 | } |
| 3527 | 3526 | |
| 3528 | 3527 | |
@@ -3544,130 +3543,130 @@ discard block |
||
| 3544 | 3543 | * @param string $statut |
| 3545 | 3544 | */ |
| 3546 | 3545 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3547 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3548 | - if (!$alertes |
|
| 3549 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3550 | - ) { |
|
| 3551 | - $alertes = array(); |
|
| 3552 | - } |
|
| 3546 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3547 | + if (!$alertes |
|
| 3548 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3549 | + ) { |
|
| 3550 | + $alertes = array(); |
|
| 3551 | + } |
|
| 3553 | 3552 | |
| 3554 | - if (!isset($alertes[$statut])) { |
|
| 3555 | - $alertes[$statut] = array(); |
|
| 3556 | - } |
|
| 3557 | - $alertes[$statut][$nom] = $message; |
|
| 3558 | - ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3553 | + if (!isset($alertes[$statut])) { |
|
| 3554 | + $alertes[$statut] = array(); |
|
| 3555 | + } |
|
| 3556 | + $alertes[$statut][$nom] = $message; |
|
| 3557 | + ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3559 | 3558 | } |
| 3560 | 3559 | |
| 3561 | 3560 | if (PHP_VERSION_ID < 50500) { |
| 3562 | - if (!function_exists('array_column')) { |
|
| 3563 | - /** |
|
| 3564 | - * Returns the values from a single column of the input array, identified by |
|
| 3565 | - * the $columnKey. |
|
| 3566 | - * |
|
| 3567 | - * Optionally, you may provide an $indexKey to index the values in the returned |
|
| 3568 | - * array by the values from the $indexKey column in the input array. |
|
| 3569 | - * |
|
| 3570 | - * @link http://php.net/manual/fr/function.array-column.php |
|
| 3571 | - * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php |
|
| 3572 | - * @copyright Copyright (c) Ben Ramsey (http://benramsey.com) |
|
| 3573 | - * @license http://opensource.org/licenses/MIT MIT |
|
| 3574 | - * |
|
| 3575 | - * @param array $input A multi-dimensional array (record set) from which to pull |
|
| 3576 | - * a column of values. |
|
| 3577 | - * @param mixed $columnKey The column of values to return. This value may be the |
|
| 3578 | - * integer key of the column you wish to retrieve, or it |
|
| 3579 | - * may be the string key name for an associative array. |
|
| 3580 | - * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
|
| 3581 | - * the returned array. This value may be the integer key |
|
| 3582 | - * of the column, or it may be the string key name. |
|
| 3583 | - * @return array |
|
| 3584 | - */ |
|
| 3585 | - function array_column($input = null, $columnKey = null, $indexKey = null) |
|
| 3586 | - { |
|
| 3587 | - // Using func_get_args() in order to check for proper number of |
|
| 3588 | - // parameters and trigger errors exactly as the built-in array_column() |
|
| 3589 | - // does in PHP 5.5. |
|
| 3590 | - $argc = func_num_args(); |
|
| 3591 | - $params = func_get_args(); |
|
| 3592 | - |
|
| 3593 | - if ($argc < 2) { |
|
| 3594 | - trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 3595 | - return null; |
|
| 3596 | - } |
|
| 3597 | - |
|
| 3598 | - if (!is_array($params[0])) { |
|
| 3599 | - trigger_error( |
|
| 3600 | - 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
| 3601 | - E_USER_WARNING |
|
| 3602 | - ); |
|
| 3603 | - return null; |
|
| 3604 | - } |
|
| 3605 | - |
|
| 3606 | - if (!is_int($params[1]) |
|
| 3607 | - && !is_float($params[1]) |
|
| 3608 | - && !is_string($params[1]) |
|
| 3609 | - && $params[1] !== null |
|
| 3610 | - && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 3611 | - ) { |
|
| 3612 | - trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 3613 | - return false; |
|
| 3614 | - } |
|
| 3615 | - |
|
| 3616 | - if (isset($params[2]) |
|
| 3617 | - && !is_int($params[2]) |
|
| 3618 | - && !is_float($params[2]) |
|
| 3619 | - && !is_string($params[2]) |
|
| 3620 | - && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 3621 | - ) { |
|
| 3622 | - trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 3623 | - return false; |
|
| 3624 | - } |
|
| 3625 | - |
|
| 3626 | - $paramsInput = $params[0]; |
|
| 3627 | - $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 3628 | - |
|
| 3629 | - $paramsIndexKey = null; |
|
| 3630 | - if (isset($params[2])) { |
|
| 3631 | - if (is_float($params[2]) || is_int($params[2])) { |
|
| 3632 | - $paramsIndexKey = (int) $params[2]; |
|
| 3633 | - } else { |
|
| 3634 | - $paramsIndexKey = (string) $params[2]; |
|
| 3635 | - } |
|
| 3636 | - } |
|
| 3637 | - |
|
| 3638 | - $resultArray = array(); |
|
| 3639 | - |
|
| 3640 | - foreach ($paramsInput as $row) { |
|
| 3641 | - $key = $value = null; |
|
| 3642 | - $keySet = $valueSet = false; |
|
| 3643 | - |
|
| 3644 | - if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 3645 | - $keySet = true; |
|
| 3646 | - $key = (string) $row[$paramsIndexKey]; |
|
| 3647 | - } |
|
| 3648 | - |
|
| 3649 | - if ($paramsColumnKey === null) { |
|
| 3650 | - $valueSet = true; |
|
| 3651 | - $value = $row; |
|
| 3652 | - } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 3653 | - $valueSet = true; |
|
| 3654 | - $value = $row[$paramsColumnKey]; |
|
| 3655 | - } |
|
| 3656 | - |
|
| 3657 | - if ($valueSet) { |
|
| 3658 | - if ($keySet) { |
|
| 3659 | - $resultArray[$key] = $value; |
|
| 3660 | - } else { |
|
| 3661 | - $resultArray[] = $value; |
|
| 3662 | - } |
|
| 3663 | - } |
|
| 3664 | - |
|
| 3665 | - } |
|
| 3666 | - |
|
| 3667 | - return $resultArray; |
|
| 3668 | - } |
|
| 3669 | - |
|
| 3670 | - } |
|
| 3561 | + if (!function_exists('array_column')) { |
|
| 3562 | + /** |
|
| 3563 | + * Returns the values from a single column of the input array, identified by |
|
| 3564 | + * the $columnKey. |
|
| 3565 | + * |
|
| 3566 | + * Optionally, you may provide an $indexKey to index the values in the returned |
|
| 3567 | + * array by the values from the $indexKey column in the input array. |
|
| 3568 | + * |
|
| 3569 | + * @link http://php.net/manual/fr/function.array-column.php |
|
| 3570 | + * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php |
|
| 3571 | + * @copyright Copyright (c) Ben Ramsey (http://benramsey.com) |
|
| 3572 | + * @license http://opensource.org/licenses/MIT MIT |
|
| 3573 | + * |
|
| 3574 | + * @param array $input A multi-dimensional array (record set) from which to pull |
|
| 3575 | + * a column of values. |
|
| 3576 | + * @param mixed $columnKey The column of values to return. This value may be the |
|
| 3577 | + * integer key of the column you wish to retrieve, or it |
|
| 3578 | + * may be the string key name for an associative array. |
|
| 3579 | + * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
|
| 3580 | + * the returned array. This value may be the integer key |
|
| 3581 | + * of the column, or it may be the string key name. |
|
| 3582 | + * @return array |
|
| 3583 | + */ |
|
| 3584 | + function array_column($input = null, $columnKey = null, $indexKey = null) |
|
| 3585 | + { |
|
| 3586 | + // Using func_get_args() in order to check for proper number of |
|
| 3587 | + // parameters and trigger errors exactly as the built-in array_column() |
|
| 3588 | + // does in PHP 5.5. |
|
| 3589 | + $argc = func_num_args(); |
|
| 3590 | + $params = func_get_args(); |
|
| 3591 | + |
|
| 3592 | + if ($argc < 2) { |
|
| 3593 | + trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 3594 | + return null; |
|
| 3595 | + } |
|
| 3596 | + |
|
| 3597 | + if (!is_array($params[0])) { |
|
| 3598 | + trigger_error( |
|
| 3599 | + 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
| 3600 | + E_USER_WARNING |
|
| 3601 | + ); |
|
| 3602 | + return null; |
|
| 3603 | + } |
|
| 3604 | + |
|
| 3605 | + if (!is_int($params[1]) |
|
| 3606 | + && !is_float($params[1]) |
|
| 3607 | + && !is_string($params[1]) |
|
| 3608 | + && $params[1] !== null |
|
| 3609 | + && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 3610 | + ) { |
|
| 3611 | + trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 3612 | + return false; |
|
| 3613 | + } |
|
| 3614 | + |
|
| 3615 | + if (isset($params[2]) |
|
| 3616 | + && !is_int($params[2]) |
|
| 3617 | + && !is_float($params[2]) |
|
| 3618 | + && !is_string($params[2]) |
|
| 3619 | + && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 3620 | + ) { |
|
| 3621 | + trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 3622 | + return false; |
|
| 3623 | + } |
|
| 3624 | + |
|
| 3625 | + $paramsInput = $params[0]; |
|
| 3626 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 3627 | + |
|
| 3628 | + $paramsIndexKey = null; |
|
| 3629 | + if (isset($params[2])) { |
|
| 3630 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 3631 | + $paramsIndexKey = (int) $params[2]; |
|
| 3632 | + } else { |
|
| 3633 | + $paramsIndexKey = (string) $params[2]; |
|
| 3634 | + } |
|
| 3635 | + } |
|
| 3636 | + |
|
| 3637 | + $resultArray = array(); |
|
| 3638 | + |
|
| 3639 | + foreach ($paramsInput as $row) { |
|
| 3640 | + $key = $value = null; |
|
| 3641 | + $keySet = $valueSet = false; |
|
| 3642 | + |
|
| 3643 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 3644 | + $keySet = true; |
|
| 3645 | + $key = (string) $row[$paramsIndexKey]; |
|
| 3646 | + } |
|
| 3647 | + |
|
| 3648 | + if ($paramsColumnKey === null) { |
|
| 3649 | + $valueSet = true; |
|
| 3650 | + $value = $row; |
|
| 3651 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 3652 | + $valueSet = true; |
|
| 3653 | + $value = $row[$paramsColumnKey]; |
|
| 3654 | + } |
|
| 3655 | + |
|
| 3656 | + if ($valueSet) { |
|
| 3657 | + if ($keySet) { |
|
| 3658 | + $resultArray[$key] = $value; |
|
| 3659 | + } else { |
|
| 3660 | + $resultArray[] = $value; |
|
| 3661 | + } |
|
| 3662 | + } |
|
| 3663 | + |
|
| 3664 | + } |
|
| 3665 | + |
|
| 3666 | + return $resultArray; |
|
| 3667 | + } |
|
| 3668 | + |
|
| 3669 | + } |
|
| 3671 | 3670 | } |
| 3672 | 3671 | |
| 3673 | 3672 | /** |
@@ -3681,8 +3680,8 @@ discard block |
||
| 3681 | 3680 | * @return string|string[] |
| 3682 | 3681 | */ |
| 3683 | 3682 | function spip_sanitize_classname($classes) { |
| 3684 | - if (is_array($classes)) { |
|
| 3685 | - return array_map('spip_sanitize_classname', $classes); |
|
| 3686 | - } |
|
| 3687 | - return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes); |
|
| 3683 | + if (is_array($classes)) { |
|
| 3684 | + return array_map('spip_sanitize_classname', $classes); |
|
| 3685 | + } |
|
| 3686 | + return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes); |
|
| 3688 | 3687 | } |