@@ -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,27 +177,27 @@ 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'); |
|
| 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 | - } |
|
| 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 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 199 | - $done = true; |
|
| 200 | - } |
|
| 180 | + static $done = false; |
|
| 181 | + if (!$done) { |
|
| 182 | + include_spip('inc/lang'); |
|
| 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 | + } |
|
| 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 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 199 | + $done = true; |
|
| 200 | + } |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -223,22 +223,22 @@ discard block |
||
| 223 | 223 | * Les paramètres du pipeline modifiés |
| 224 | 224 | **/ |
| 225 | 225 | function minipipe($fonc, &$val) { |
| 226 | - // fonction |
|
| 227 | - if (function_exists($fonc)) { |
|
| 228 | - $val = call_user_func($fonc, $val); |
|
| 229 | - } // Class::Methode |
|
| 230 | - else { |
|
| 231 | - if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 232 | - and $methode = array($regs[1], $regs[2]) |
|
| 233 | - and is_callable($methode) |
|
| 234 | - ) { |
|
| 235 | - $val = call_user_func($methode, $val); |
|
| 236 | - } else { |
|
| 237 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 238 | - } |
|
| 239 | - } |
|
| 226 | + // fonction |
|
| 227 | + if (function_exists($fonc)) { |
|
| 228 | + $val = call_user_func($fonc, $val); |
|
| 229 | + } // Class::Methode |
|
| 230 | + else { |
|
| 231 | + if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 232 | + and $methode = array($regs[1], $regs[2]) |
|
| 233 | + and is_callable($methode) |
|
| 234 | + ) { |
|
| 235 | + $val = call_user_func($methode, $val); |
|
| 236 | + } else { |
|
| 237 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - return $val; |
|
| 241 | + return $val; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -269,45 +269,45 @@ discard block |
||
| 269 | 269 | * Résultat |
| 270 | 270 | */ |
| 271 | 271 | function pipeline($action, $val = null) { |
| 272 | - static $charger; |
|
| 273 | - |
|
| 274 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 275 | - if (!$charger) { |
|
| 276 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 277 | - include_spip('inc/plugin'); |
|
| 278 | - // generer les fichiers php precompiles |
|
| 279 | - // de chargement des plugins et des pipelines |
|
| 280 | - actualise_plugins_actifs(); |
|
| 281 | - if (!($ok = @is_readable($charger))) { |
|
| 282 | - spip_log("fichier $charger pas cree"); |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - if ($ok) { |
|
| 287 | - include_once $charger; |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - // appliquer notre fonction si elle existe |
|
| 292 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 293 | - if (function_exists($fonc)) { |
|
| 294 | - $val = $fonc($val); |
|
| 295 | - } // plantage ? |
|
| 296 | - else { |
|
| 297 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - // si le flux est une table avec 2 cle args&data |
|
| 301 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 302 | - // array_key_exists pour php 4.1.0 |
|
| 303 | - if (is_array($val) |
|
| 304 | - and count($val) == 2 |
|
| 305 | - and (array_key_exists('data', $val)) |
|
| 306 | - ) { |
|
| 307 | - $val = $val['data']; |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - return $val; |
|
| 272 | + static $charger; |
|
| 273 | + |
|
| 274 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 275 | + if (!$charger) { |
|
| 276 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 277 | + include_spip('inc/plugin'); |
|
| 278 | + // generer les fichiers php precompiles |
|
| 279 | + // de chargement des plugins et des pipelines |
|
| 280 | + actualise_plugins_actifs(); |
|
| 281 | + if (!($ok = @is_readable($charger))) { |
|
| 282 | + spip_log("fichier $charger pas cree"); |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + if ($ok) { |
|
| 287 | + include_once $charger; |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + // appliquer notre fonction si elle existe |
|
| 292 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 293 | + if (function_exists($fonc)) { |
|
| 294 | + $val = $fonc($val); |
|
| 295 | + } // plantage ? |
|
| 296 | + else { |
|
| 297 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + // si le flux est une table avec 2 cle args&data |
|
| 301 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 302 | + // array_key_exists pour php 4.1.0 |
|
| 303 | + if (is_array($val) |
|
| 304 | + and count($val) == 2 |
|
| 305 | + and (array_key_exists('data', $val)) |
|
| 306 | + ) { |
|
| 307 | + $val = $val['data']; |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + return $val; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -351,38 +351,38 @@ discard block |
||
| 351 | 351 | * paramètre est planté pour cause de compatibilité ascendante. |
| 352 | 352 | */ |
| 353 | 353 | function spip_log($message = null, $name = null) { |
| 354 | - static $pre = array(); |
|
| 355 | - static $log; |
|
| 356 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 357 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 358 | - $logname = null; |
|
| 359 | - } |
|
| 360 | - if (!isset($regs[2])) { |
|
| 361 | - $niveau = _LOG_INFO; |
|
| 362 | - } |
|
| 363 | - else { |
|
| 364 | - $niveau = intval($regs[2]); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 368 | - if (!$pre) { |
|
| 369 | - $pre = array( |
|
| 370 | - _LOG_HS => 'HS:', |
|
| 371 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 372 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 373 | - _LOG_ERREUR => 'ERREUR:', |
|
| 374 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 375 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 376 | - _LOG_INFO => 'info:', |
|
| 377 | - _LOG_DEBUG => 'debug:' |
|
| 378 | - ); |
|
| 379 | - $log = charger_fonction('log', 'inc'); |
|
| 380 | - } |
|
| 381 | - if (!is_string($message)) { |
|
| 382 | - $message = print_r($message, true); |
|
| 383 | - } |
|
| 384 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 385 | - } |
|
| 354 | + static $pre = array(); |
|
| 355 | + static $log; |
|
| 356 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 357 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 358 | + $logname = null; |
|
| 359 | + } |
|
| 360 | + if (!isset($regs[2])) { |
|
| 361 | + $niveau = _LOG_INFO; |
|
| 362 | + } |
|
| 363 | + else { |
|
| 364 | + $niveau = intval($regs[2]); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 368 | + if (!$pre) { |
|
| 369 | + $pre = array( |
|
| 370 | + _LOG_HS => 'HS:', |
|
| 371 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 372 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 373 | + _LOG_ERREUR => 'ERREUR:', |
|
| 374 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 375 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 376 | + _LOG_INFO => 'info:', |
|
| 377 | + _LOG_DEBUG => 'debug:' |
|
| 378 | + ); |
|
| 379 | + $log = charger_fonction('log', 'inc'); |
|
| 380 | + } |
|
| 381 | + if (!is_string($message)) { |
|
| 382 | + $message = print_r($message, true); |
|
| 383 | + } |
|
| 384 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -393,8 +393,8 @@ discard block |
||
| 393 | 393 | * @param array $opt Tableau d'options |
| 394 | 394 | **/ |
| 395 | 395 | function journal($phrase, $opt = array()) { |
| 396 | - $journal = charger_fonction('journal', 'inc'); |
|
| 397 | - $journal($phrase, $opt); |
|
| 396 | + $journal = charger_fonction('journal', 'inc'); |
|
| 397 | + $journal($phrase, $opt); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | |
@@ -413,36 +413,36 @@ discard block |
||
| 413 | 413 | **/ |
| 414 | 414 | function _request($var, $c = false) { |
| 415 | 415 | |
| 416 | - if (is_array($c)) { |
|
| 417 | - return isset($c[$var]) ? $c[$var] : null; |
|
| 418 | - } |
|
| 416 | + if (is_array($c)) { |
|
| 417 | + return isset($c[$var]) ? $c[$var] : null; |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - if (isset($_GET[$var])) { |
|
| 421 | - $a = $_GET[$var]; |
|
| 422 | - } elseif (isset($_POST[$var])) { |
|
| 423 | - $a = $_POST[$var]; |
|
| 424 | - } else { |
|
| 425 | - return null; |
|
| 426 | - } |
|
| 420 | + if (isset($_GET[$var])) { |
|
| 421 | + $a = $_GET[$var]; |
|
| 422 | + } elseif (isset($_POST[$var])) { |
|
| 423 | + $a = $_POST[$var]; |
|
| 424 | + } else { |
|
| 425 | + return null; |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | - // Si on est en ajax et en POST tout a ete encode |
|
| 429 | - // via encodeURIComponent, il faut donc repasser |
|
| 430 | - // dans le charset local... |
|
| 431 | - if (defined('_AJAX') |
|
| 432 | - and _AJAX |
|
| 433 | - and isset($GLOBALS['meta']['charset']) |
|
| 434 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 435 | - and is_string($a) |
|
| 436 | - // check rapide mais pas fiable |
|
| 437 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 438 | - // check fiable |
|
| 439 | - and include_spip('inc/charsets') |
|
| 440 | - and is_utf8($a) |
|
| 441 | - ) { |
|
| 442 | - return importer_charset($a, 'utf-8'); |
|
| 443 | - } |
|
| 428 | + // Si on est en ajax et en POST tout a ete encode |
|
| 429 | + // via encodeURIComponent, il faut donc repasser |
|
| 430 | + // dans le charset local... |
|
| 431 | + if (defined('_AJAX') |
|
| 432 | + and _AJAX |
|
| 433 | + and isset($GLOBALS['meta']['charset']) |
|
| 434 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 435 | + and is_string($a) |
|
| 436 | + // check rapide mais pas fiable |
|
| 437 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 438 | + // check fiable |
|
| 439 | + and include_spip('inc/charsets') |
|
| 440 | + and is_utf8($a) |
|
| 441 | + ) { |
|
| 442 | + return importer_charset($a, 'utf-8'); |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - return $a; |
|
| 445 | + return $a; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | |
@@ -460,22 +460,22 @@ discard block |
||
| 460 | 460 | * - false sinon |
| 461 | 461 | **/ |
| 462 | 462 | function set_request($var, $val = null, $c = false) { |
| 463 | - if (is_array($c)) { |
|
| 464 | - unset($c[$var]); |
|
| 465 | - if ($val !== null) { |
|
| 466 | - $c[$var] = $val; |
|
| 467 | - } |
|
| 463 | + if (is_array($c)) { |
|
| 464 | + unset($c[$var]); |
|
| 465 | + if ($val !== null) { |
|
| 466 | + $c[$var] = $val; |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - return $c; |
|
| 470 | - } |
|
| 469 | + return $c; |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - unset($_GET[$var]); |
|
| 473 | - unset($_POST[$var]); |
|
| 474 | - if ($val !== null) { |
|
| 475 | - $_GET[$var] = $val; |
|
| 476 | - } |
|
| 472 | + unset($_GET[$var]); |
|
| 473 | + unset($_POST[$var]); |
|
| 474 | + if ($val !== null) { |
|
| 475 | + $_GET[$var] = $val; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - return false; # n'affecte pas $c |
|
| 478 | + return false; # n'affecte pas $c |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -495,25 +495,25 @@ discard block |
||
| 495 | 495 | * @return array|mixed|string |
| 496 | 496 | */ |
| 497 | 497 | function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') { |
| 498 | - if (is_array($value)) { |
|
| 499 | - if ($key=='*') { |
|
| 500 | - $key = array_keys($value); |
|
| 501 | - } |
|
| 502 | - if (!is_array($key)) { |
|
| 503 | - $key = [$key]; |
|
| 504 | - } |
|
| 505 | - foreach ($key as $k) { |
|
| 506 | - if (!empty($value[$k])) { |
|
| 507 | - $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 508 | - } |
|
| 509 | - } |
|
| 510 | - return $value; |
|
| 511 | - } |
|
| 512 | - // si la valeur vient des GET ou POST on la sanitize |
|
| 513 | - if (!empty($value) and $value == _request($key)) { |
|
| 514 | - $value = $sanitize_function($value); |
|
| 515 | - } |
|
| 516 | - return $value; |
|
| 498 | + if (is_array($value)) { |
|
| 499 | + if ($key=='*') { |
|
| 500 | + $key = array_keys($value); |
|
| 501 | + } |
|
| 502 | + if (!is_array($key)) { |
|
| 503 | + $key = [$key]; |
|
| 504 | + } |
|
| 505 | + foreach ($key as $k) { |
|
| 506 | + if (!empty($value[$k])) { |
|
| 507 | + $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 508 | + } |
|
| 509 | + } |
|
| 510 | + return $value; |
|
| 511 | + } |
|
| 512 | + // si la valeur vient des GET ou POST on la sanitize |
|
| 513 | + if (!empty($value) and $value == _request($key)) { |
|
| 514 | + $value = $sanitize_function($value); |
|
| 515 | + } |
|
| 516 | + return $value; |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -521,23 +521,22 @@ discard block |
||
| 521 | 521 | * |
| 522 | 522 | * On est sur le web, on exclut certains protocoles, |
| 523 | 523 | * notamment 'file://', 'php://' et d'autres… |
| 524 | - |
|
| 525 | 524 | * @param string $url |
| 526 | 525 | * @return bool |
| 527 | 526 | */ |
| 528 | 527 | function tester_url_absolue($url) { |
| 529 | - $url = trim($url); |
|
| 530 | - if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 531 | - if ( |
|
| 532 | - isset($m[1]) |
|
| 533 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 534 | - and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 535 | - ) { |
|
| 536 | - return false; |
|
| 537 | - } |
|
| 538 | - return true; |
|
| 539 | - } |
|
| 540 | - return false; |
|
| 528 | + $url = trim($url); |
|
| 529 | + if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 530 | + if ( |
|
| 531 | + isset($m[1]) |
|
| 532 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 533 | + and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 534 | + ) { |
|
| 535 | + return false; |
|
| 536 | + } |
|
| 537 | + return true; |
|
| 538 | + } |
|
| 539 | + return false; |
|
| 541 | 540 | } |
| 542 | 541 | |
| 543 | 542 | /** |
@@ -559,94 +558,94 @@ discard block |
||
| 559 | 558 | * @return string URL |
| 560 | 559 | */ |
| 561 | 560 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 562 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 563 | - if (strpos($c, "|") !== false and is_null($v)) { |
|
| 564 | - return null; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - // lever l'#ancre |
|
| 568 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 569 | - $url = $r[1]; |
|
| 570 | - $ancre = $r[2]; |
|
| 571 | - } else { |
|
| 572 | - $ancre = ''; |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - // eclater |
|
| 576 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 577 | - |
|
| 578 | - // recuperer la base |
|
| 579 | - $a = array_shift($url); |
|
| 580 | - if (!$a) { |
|
| 581 | - $a = './'; |
|
| 582 | - } |
|
| 583 | - |
|
| 584 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 585 | - $ajouts = array_flip(explode('|', $c)); |
|
| 586 | - $u = is_array($v) ? $v : rawurlencode($v); |
|
| 587 | - $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 588 | - $v_read = null; |
|
| 589 | - // lire les variables et agir |
|
| 590 | - foreach ($url as $n => $val) { |
|
| 591 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 592 | - $r = array_pad($r, 3, null); |
|
| 593 | - if ($v === null) { |
|
| 594 | - // c'est un tableau, on memorise les valeurs |
|
| 595 | - if (substr($r[1], -2) == "[]") { |
|
| 596 | - if (!$v_read) { |
|
| 597 | - $v_read = array(); |
|
| 598 | - } |
|
| 599 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 600 | - } // c'est un scalaire, on retourne direct |
|
| 601 | - else { |
|
| 602 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 603 | - } |
|
| 604 | - } // suppression |
|
| 605 | - elseif (!$testv) { |
|
| 606 | - unset($url[$n]); |
|
| 607 | - } |
|
| 608 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 609 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 610 | - elseif (substr($r[1], -2) != '[]') { |
|
| 611 | - $url[$n] = $r[1] . '=' . $u; |
|
| 612 | - unset($ajouts[$r[1]]); |
|
| 613 | - } |
|
| 614 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 615 | - // départ, on remplira à l'étape suivante |
|
| 616 | - else { |
|
| 617 | - unset($url[$n]); |
|
| 618 | - } |
|
| 619 | - } |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - // traiter les parametres pas encore trouves |
|
| 623 | - if ($v === null |
|
| 624 | - and $args = func_get_args() |
|
| 625 | - and count($args) == 2 |
|
| 626 | - ) { |
|
| 627 | - return $v_read; // rien trouve ou un tableau |
|
| 628 | - } elseif ($testv) { |
|
| 629 | - foreach ($ajouts as $k => $n) { |
|
| 630 | - if (!is_array($v)) { |
|
| 631 | - $url[] = $k . '=' . $u; |
|
| 632 | - } else { |
|
| 633 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 634 | - foreach ($v as $w) { |
|
| 635 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 636 | - } |
|
| 637 | - } |
|
| 638 | - } |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - // eliminer les vides |
|
| 642 | - $url = array_filter($url); |
|
| 643 | - |
|
| 644 | - // recomposer l'adresse |
|
| 645 | - if ($url) { |
|
| 646 | - $a .= '?' . join($sep, $url); |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - return $a . $ancre; |
|
| 561 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 562 | + if (strpos($c, "|") !== false and is_null($v)) { |
|
| 563 | + return null; |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + // lever l'#ancre |
|
| 567 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 568 | + $url = $r[1]; |
|
| 569 | + $ancre = $r[2]; |
|
| 570 | + } else { |
|
| 571 | + $ancre = ''; |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + // eclater |
|
| 575 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 576 | + |
|
| 577 | + // recuperer la base |
|
| 578 | + $a = array_shift($url); |
|
| 579 | + if (!$a) { |
|
| 580 | + $a = './'; |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 584 | + $ajouts = array_flip(explode('|', $c)); |
|
| 585 | + $u = is_array($v) ? $v : rawurlencode($v); |
|
| 586 | + $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 587 | + $v_read = null; |
|
| 588 | + // lire les variables et agir |
|
| 589 | + foreach ($url as $n => $val) { |
|
| 590 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 591 | + $r = array_pad($r, 3, null); |
|
| 592 | + if ($v === null) { |
|
| 593 | + // c'est un tableau, on memorise les valeurs |
|
| 594 | + if (substr($r[1], -2) == "[]") { |
|
| 595 | + if (!$v_read) { |
|
| 596 | + $v_read = array(); |
|
| 597 | + } |
|
| 598 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 599 | + } // c'est un scalaire, on retourne direct |
|
| 600 | + else { |
|
| 601 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 602 | + } |
|
| 603 | + } // suppression |
|
| 604 | + elseif (!$testv) { |
|
| 605 | + unset($url[$n]); |
|
| 606 | + } |
|
| 607 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 608 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 609 | + elseif (substr($r[1], -2) != '[]') { |
|
| 610 | + $url[$n] = $r[1] . '=' . $u; |
|
| 611 | + unset($ajouts[$r[1]]); |
|
| 612 | + } |
|
| 613 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 614 | + // départ, on remplira à l'étape suivante |
|
| 615 | + else { |
|
| 616 | + unset($url[$n]); |
|
| 617 | + } |
|
| 618 | + } |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + // traiter les parametres pas encore trouves |
|
| 622 | + if ($v === null |
|
| 623 | + and $args = func_get_args() |
|
| 624 | + and count($args) == 2 |
|
| 625 | + ) { |
|
| 626 | + return $v_read; // rien trouve ou un tableau |
|
| 627 | + } elseif ($testv) { |
|
| 628 | + foreach ($ajouts as $k => $n) { |
|
| 629 | + if (!is_array($v)) { |
|
| 630 | + $url[] = $k . '=' . $u; |
|
| 631 | + } else { |
|
| 632 | + $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 633 | + foreach ($v as $w) { |
|
| 634 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | + } |
|
| 638 | + } |
|
| 639 | + |
|
| 640 | + // eliminer les vides |
|
| 641 | + $url = array_filter($url); |
|
| 642 | + |
|
| 643 | + // recomposer l'adresse |
|
| 644 | + if ($url) { |
|
| 645 | + $a .= '?' . join($sep, $url); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + return $a . $ancre; |
|
| 650 | 649 | } |
| 651 | 650 | |
| 652 | 651 | /** |
@@ -664,21 +663,21 @@ discard block |
||
| 664 | 663 | * @return string |
| 665 | 664 | */ |
| 666 | 665 | function ancre_url($url, $ancre) { |
| 667 | - // lever l'#ancre |
|
| 668 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 669 | - $url = $r[1]; |
|
| 670 | - } |
|
| 671 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 672 | - if (!function_exists('translitteration')) { |
|
| 673 | - include_spip('inc/charsets'); |
|
| 674 | - } |
|
| 675 | - $ancre = preg_replace( |
|
| 676 | - array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 677 | - array('', '-'), |
|
| 678 | - translitteration($ancre) |
|
| 679 | - ); |
|
| 680 | - } |
|
| 681 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 666 | + // lever l'#ancre |
|
| 667 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 668 | + $url = $r[1]; |
|
| 669 | + } |
|
| 670 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 671 | + if (!function_exists('translitteration')) { |
|
| 672 | + include_spip('inc/charsets'); |
|
| 673 | + } |
|
| 674 | + $ancre = preg_replace( |
|
| 675 | + array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 676 | + array('', '-'), |
|
| 677 | + translitteration($ancre) |
|
| 678 | + ); |
|
| 679 | + } |
|
| 680 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 682 | 681 | } |
| 683 | 682 | |
| 684 | 683 | /** |
@@ -688,16 +687,16 @@ discard block |
||
| 688 | 687 | * @return string |
| 689 | 688 | */ |
| 690 | 689 | function nettoyer_uri($reset = null) { |
| 691 | - static $done = false; |
|
| 692 | - static $propre = ''; |
|
| 693 | - if (!is_null($reset)) { |
|
| 694 | - return $propre = $reset; |
|
| 695 | - } |
|
| 696 | - if ($done) { |
|
| 697 | - return $propre; |
|
| 698 | - } |
|
| 699 | - $done = true; |
|
| 700 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 690 | + static $done = false; |
|
| 691 | + static $propre = ''; |
|
| 692 | + if (!is_null($reset)) { |
|
| 693 | + return $propre = $reset; |
|
| 694 | + } |
|
| 695 | + if ($done) { |
|
| 696 | + return $propre; |
|
| 697 | + } |
|
| 698 | + $done = true; |
|
| 699 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 701 | 700 | } |
| 702 | 701 | |
| 703 | 702 | /** |
@@ -709,13 +708,13 @@ discard block |
||
| 709 | 708 | * @return string |
| 710 | 709 | */ |
| 711 | 710 | function nettoyer_uri_var($request_uri) { |
| 712 | - $uri1 = $request_uri; |
|
| 713 | - do { |
|
| 714 | - $uri = $uri1; |
|
| 715 | - $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 716 | - '\1', $uri); |
|
| 717 | - } while ($uri <> $uri1); |
|
| 718 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 711 | + $uri1 = $request_uri; |
|
| 712 | + do { |
|
| 713 | + $uri = $uri1; |
|
| 714 | + $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 715 | + '\1', $uri); |
|
| 716 | + } while ($uri <> $uri1); |
|
| 717 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 719 | 718 | } |
| 720 | 719 | |
| 721 | 720 | |
@@ -729,47 +728,47 @@ discard block |
||
| 729 | 728 | * URL vers soi-même |
| 730 | 729 | **/ |
| 731 | 730 | function self($amp = '&', $root = false) { |
| 732 | - $url = nettoyer_uri(); |
|
| 733 | - if (!$root |
|
| 734 | - and ( |
|
| 735 | - // si pas de profondeur on peut tronquer |
|
| 736 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 737 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 738 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 739 | - ) { |
|
| 740 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 741 | - } |
|
| 742 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 743 | - foreach ($_POST as $v => $c) { |
|
| 744 | - if (substr($v, 0, 3) == 'id_') { |
|
| 745 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - |
|
| 749 | - // supprimer les variables sans interet |
|
| 750 | - if (test_espace_prive()) { |
|
| 751 | - $url = preg_replace(',([?&])(' |
|
| 752 | - . 'lang|show_docs|' |
|
| 753 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 754 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 755 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - // eviter les hacks |
|
| 759 | - include_spip('inc/filtres_mini'); |
|
| 760 | - $url = spip_htmlspecialchars($url); |
|
| 731 | + $url = nettoyer_uri(); |
|
| 732 | + if (!$root |
|
| 733 | + and ( |
|
| 734 | + // si pas de profondeur on peut tronquer |
|
| 735 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 736 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 737 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 738 | + ) { |
|
| 739 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 740 | + } |
|
| 741 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 742 | + foreach ($_POST as $v => $c) { |
|
| 743 | + if (substr($v, 0, 3) == 'id_') { |
|
| 744 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + // supprimer les variables sans interet |
|
| 749 | + if (test_espace_prive()) { |
|
| 750 | + $url = preg_replace(',([?&])(' |
|
| 751 | + . 'lang|show_docs|' |
|
| 752 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 753 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 754 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 755 | + } |
|
| 756 | + |
|
| 757 | + // eviter les hacks |
|
| 758 | + include_spip('inc/filtres_mini'); |
|
| 759 | + $url = spip_htmlspecialchars($url); |
|
| 761 | 760 | |
| 762 | - $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 761 | + $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 763 | 762 | |
| 764 | - // & ? |
|
| 765 | - if ($amp != '&') { |
|
| 766 | - $url = str_replace('&', $amp, $url); |
|
| 767 | - } |
|
| 763 | + // & ? |
|
| 764 | + if ($amp != '&') { |
|
| 765 | + $url = str_replace('&', $amp, $url); |
|
| 766 | + } |
|
| 768 | 767 | |
| 769 | - // Si ca demarre par ? ou vide, donner './' |
|
| 770 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 768 | + // Si ca demarre par ? ou vide, donner './' |
|
| 769 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 771 | 770 | |
| 772 | - return $url; |
|
| 771 | + return $url; |
|
| 773 | 772 | } |
| 774 | 773 | |
| 775 | 774 | |
@@ -780,7 +779,7 @@ discard block |
||
| 780 | 779 | * true si c'est le cas, false sinon. |
| 781 | 780 | */ |
| 782 | 781 | function test_espace_prive() { |
| 783 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 782 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 784 | 783 | } |
| 785 | 784 | |
| 786 | 785 | /** |
@@ -790,7 +789,7 @@ discard block |
||
| 790 | 789 | * @return bool |
| 791 | 790 | */ |
| 792 | 791 | function test_plugin_actif($plugin) { |
| 793 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 792 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 794 | 793 | } |
| 795 | 794 | |
| 796 | 795 | /** |
@@ -821,51 +820,51 @@ discard block |
||
| 821 | 820 | * Texte |
| 822 | 821 | */ |
| 823 | 822 | function _T($texte, $args = array(), $options = array()) { |
| 824 | - static $traduire = false; |
|
| 825 | - $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 826 | - if ($options) { |
|
| 827 | - // support de l'ancien argument $class |
|
| 828 | - if (is_string($options)) { |
|
| 829 | - $options = array('class' => $options); |
|
| 830 | - } |
|
| 831 | - $o = array_merge($o, $options); |
|
| 832 | - } |
|
| 823 | + static $traduire = false; |
|
| 824 | + $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 825 | + if ($options) { |
|
| 826 | + // support de l'ancien argument $class |
|
| 827 | + if (is_string($options)) { |
|
| 828 | + $options = array('class' => $options); |
|
| 829 | + } |
|
| 830 | + $o = array_merge($o, $options); |
|
| 831 | + } |
|
| 833 | 832 | |
| 834 | - if (!$traduire) { |
|
| 835 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 836 | - include_spip('inc/lang'); |
|
| 837 | - } |
|
| 833 | + if (!$traduire) { |
|
| 834 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 835 | + include_spip('inc/lang'); |
|
| 836 | + } |
|
| 838 | 837 | |
| 839 | - // On peut passer explicitement la langue dans le tableau |
|
| 840 | - // On utilise le même nom de variable que la globale |
|
| 841 | - if (isset($args['spip_lang'])) { |
|
| 842 | - $lang = $args['spip_lang']; |
|
| 843 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 844 | - unset($args['spip_lang']); |
|
| 845 | - } // Sinon on prend la langue du contexte |
|
| 846 | - else { |
|
| 847 | - $lang = $GLOBALS['spip_lang']; |
|
| 848 | - } |
|
| 849 | - $text = $traduire($texte, $lang); |
|
| 838 | + // On peut passer explicitement la langue dans le tableau |
|
| 839 | + // On utilise le même nom de variable que la globale |
|
| 840 | + if (isset($args['spip_lang'])) { |
|
| 841 | + $lang = $args['spip_lang']; |
|
| 842 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 843 | + unset($args['spip_lang']); |
|
| 844 | + } // Sinon on prend la langue du contexte |
|
| 845 | + else { |
|
| 846 | + $lang = $GLOBALS['spip_lang']; |
|
| 847 | + } |
|
| 848 | + $text = $traduire($texte, $lang); |
|
| 850 | 849 | |
| 851 | - if (!strlen($text)) { |
|
| 852 | - if (!$o['force']) { |
|
| 853 | - return ''; |
|
| 854 | - } |
|
| 850 | + if (!strlen($text)) { |
|
| 851 | + if (!$o['force']) { |
|
| 852 | + return ''; |
|
| 853 | + } |
|
| 855 | 854 | |
| 856 | - $text = $texte; |
|
| 855 | + $text = $texte; |
|
| 857 | 856 | |
| 858 | - // pour les chaines non traduites, assurer un service minimum |
|
| 859 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 860 | - $text = str_replace('_', ' ', |
|
| 861 | - (($n = strpos($text, ':')) === false ? $texte : |
|
| 862 | - substr($texte, $n + 1))); |
|
| 863 | - } |
|
| 864 | - $o['class'] = null; |
|
| 857 | + // pour les chaines non traduites, assurer un service minimum |
|
| 858 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 859 | + $text = str_replace('_', ' ', |
|
| 860 | + (($n = strpos($text, ':')) === false ? $texte : |
|
| 861 | + substr($texte, $n + 1))); |
|
| 862 | + } |
|
| 863 | + $o['class'] = null; |
|
| 865 | 864 | |
| 866 | - } |
|
| 865 | + } |
|
| 867 | 866 | |
| 868 | - return _L($text, $args, $o); |
|
| 867 | + return _L($text, $args, $o); |
|
| 869 | 868 | |
| 870 | 869 | } |
| 871 | 870 | |
@@ -893,53 +892,53 @@ discard block |
||
| 893 | 892 | * Texte |
| 894 | 893 | */ |
| 895 | 894 | function _L($text, $args = array(), $options = array()) { |
| 896 | - $f = $text; |
|
| 897 | - $defaut_options = array( |
|
| 898 | - 'class' => null, |
|
| 899 | - 'sanitize' => true, |
|
| 900 | - ); |
|
| 901 | - // support de l'ancien argument $class |
|
| 902 | - if ($options and is_string($options)) { |
|
| 903 | - $options = array('class' => $options); |
|
| 904 | - } |
|
| 905 | - if (is_array($options)) { |
|
| 906 | - $options += $defaut_options; |
|
| 907 | - } else { |
|
| 908 | - $options = $defaut_options; |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - if (is_array($args) and count($args)) { |
|
| 912 | - if (!function_exists('interdire_scripts')) { |
|
| 913 | - include_spip('inc/texte'); |
|
| 914 | - } |
|
| 915 | - if (!function_exists('echapper_html_suspect')) { |
|
| 916 | - include_spip('inc/texte_mini'); |
|
| 917 | - } |
|
| 918 | - foreach ($args as $name => $value) { |
|
| 919 | - if (strpos($text, "@$name@") !== false) { |
|
| 920 | - if ($options['sanitize']) { |
|
| 921 | - $value = echapper_html_suspect($value); |
|
| 922 | - $value = interdire_scripts($value, -1); |
|
| 923 | - } |
|
| 924 | - if (!empty($options['class'])) { |
|
| 925 | - $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 926 | - } |
|
| 927 | - $text = str_replace("@$name@", $value, $text); |
|
| 928 | - unset($args[$name]); |
|
| 929 | - } |
|
| 930 | - } |
|
| 931 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 932 | - // (chaines de langues pas a jour) |
|
| 933 | - if ($args) { |
|
| 934 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 935 | - } |
|
| 936 | - } |
|
| 937 | - |
|
| 938 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 939 | - return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 940 | - } else { |
|
| 941 | - return $text; |
|
| 942 | - } |
|
| 895 | + $f = $text; |
|
| 896 | + $defaut_options = array( |
|
| 897 | + 'class' => null, |
|
| 898 | + 'sanitize' => true, |
|
| 899 | + ); |
|
| 900 | + // support de l'ancien argument $class |
|
| 901 | + if ($options and is_string($options)) { |
|
| 902 | + $options = array('class' => $options); |
|
| 903 | + } |
|
| 904 | + if (is_array($options)) { |
|
| 905 | + $options += $defaut_options; |
|
| 906 | + } else { |
|
| 907 | + $options = $defaut_options; |
|
| 908 | + } |
|
| 909 | + |
|
| 910 | + if (is_array($args) and count($args)) { |
|
| 911 | + if (!function_exists('interdire_scripts')) { |
|
| 912 | + include_spip('inc/texte'); |
|
| 913 | + } |
|
| 914 | + if (!function_exists('echapper_html_suspect')) { |
|
| 915 | + include_spip('inc/texte_mini'); |
|
| 916 | + } |
|
| 917 | + foreach ($args as $name => $value) { |
|
| 918 | + if (strpos($text, "@$name@") !== false) { |
|
| 919 | + if ($options['sanitize']) { |
|
| 920 | + $value = echapper_html_suspect($value); |
|
| 921 | + $value = interdire_scripts($value, -1); |
|
| 922 | + } |
|
| 923 | + if (!empty($options['class'])) { |
|
| 924 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 925 | + } |
|
| 926 | + $text = str_replace("@$name@", $value, $text); |
|
| 927 | + unset($args[$name]); |
|
| 928 | + } |
|
| 929 | + } |
|
| 930 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 931 | + // (chaines de langues pas a jour) |
|
| 932 | + if ($args) { |
|
| 933 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 934 | + } |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 938 | + return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 939 | + } else { |
|
| 940 | + return $text; |
|
| 941 | + } |
|
| 943 | 942 | } |
| 944 | 943 | |
| 945 | 944 | |
@@ -953,13 +952,13 @@ discard block |
||
| 953 | 952 | * @return string |
| 954 | 953 | */ |
| 955 | 954 | function joli_repertoire($rep) { |
| 956 | - $a = substr($rep, 0, 1); |
|
| 957 | - if ($a <> '.' and $a <> '/') { |
|
| 958 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 959 | - } |
|
| 960 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 955 | + $a = substr($rep, 0, 1); |
|
| 956 | + if ($a <> '.' and $a <> '/') { |
|
| 957 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 958 | + } |
|
| 959 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 961 | 960 | |
| 962 | - return $rep; |
|
| 961 | + return $rep; |
|
| 963 | 962 | } |
| 964 | 963 | |
| 965 | 964 | |
@@ -984,33 +983,33 @@ discard block |
||
| 984 | 983 | * @return float|int|string|void |
| 985 | 984 | */ |
| 986 | 985 | function spip_timer($t = 'rien', $raw = false) { |
| 987 | - static $time; |
|
| 988 | - $a = time(); |
|
| 989 | - $b = microtime(); |
|
| 990 | - // microtime peut contenir les microsecondes et le temps |
|
| 991 | - $b = explode(' ', $b); |
|
| 992 | - if (count($b) == 2) { |
|
| 993 | - $a = end($b); |
|
| 994 | - } // plus precis ! |
|
| 995 | - $b = reset($b); |
|
| 996 | - if (!isset($time[$t])) { |
|
| 997 | - $time[$t] = $a + $b; |
|
| 998 | - } else { |
|
| 999 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 1000 | - unset($time[$t]); |
|
| 986 | + static $time; |
|
| 987 | + $a = time(); |
|
| 988 | + $b = microtime(); |
|
| 989 | + // microtime peut contenir les microsecondes et le temps |
|
| 990 | + $b = explode(' ', $b); |
|
| 991 | + if (count($b) == 2) { |
|
| 992 | + $a = end($b); |
|
| 993 | + } // plus precis ! |
|
| 994 | + $b = reset($b); |
|
| 995 | + if (!isset($time[$t])) { |
|
| 996 | + $time[$t] = $a + $b; |
|
| 997 | + } else { |
|
| 998 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 999 | + unset($time[$t]); |
|
| 1001 | 1000 | # echo "'$p'";exit; |
| 1002 | - if ($raw) { |
|
| 1003 | - return $p; |
|
| 1004 | - } |
|
| 1005 | - if ($p < 1000) { |
|
| 1006 | - $s = ''; |
|
| 1007 | - } else { |
|
| 1008 | - $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 1009 | - $p -= ($x * 1000); |
|
| 1010 | - } |
|
| 1001 | + if ($raw) { |
|
| 1002 | + return $p; |
|
| 1003 | + } |
|
| 1004 | + if ($p < 1000) { |
|
| 1005 | + $s = ''; |
|
| 1006 | + } else { |
|
| 1007 | + $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 1008 | + $p -= ($x * 1000); |
|
| 1009 | + } |
|
| 1011 | 1010 | |
| 1012 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1013 | - } |
|
| 1011 | + return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1012 | + } |
|
| 1014 | 1013 | } |
| 1015 | 1014 | |
| 1016 | 1015 | |
@@ -1018,21 +1017,21 @@ discard block |
||
| 1018 | 1017 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 1019 | 1018 | // https://code.spip.net/@spip_touch |
| 1020 | 1019 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 1021 | - if ($duree) { |
|
| 1022 | - clearstatcache(); |
|
| 1023 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1024 | - return false; |
|
| 1025 | - } |
|
| 1026 | - } |
|
| 1027 | - if ($touch !== false) { |
|
| 1028 | - if (!@touch($fichier)) { |
|
| 1029 | - spip_unlink($fichier); |
|
| 1030 | - @touch($fichier); |
|
| 1031 | - }; |
|
| 1032 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1033 | - } |
|
| 1020 | + if ($duree) { |
|
| 1021 | + clearstatcache(); |
|
| 1022 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1023 | + return false; |
|
| 1024 | + } |
|
| 1025 | + } |
|
| 1026 | + if ($touch !== false) { |
|
| 1027 | + if (!@touch($fichier)) { |
|
| 1028 | + spip_unlink($fichier); |
|
| 1029 | + @touch($fichier); |
|
| 1030 | + }; |
|
| 1031 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1032 | + } |
|
| 1034 | 1033 | |
| 1035 | - return true; |
|
| 1034 | + return true; |
|
| 1036 | 1035 | } |
| 1037 | 1036 | |
| 1038 | 1037 | |
@@ -1044,11 +1043,11 @@ discard block |
||
| 1044 | 1043 | * @uses cron() |
| 1045 | 1044 | **/ |
| 1046 | 1045 | function action_cron() { |
| 1047 | - include_spip('inc/headers'); |
|
| 1048 | - http_status(204); // No Content |
|
| 1049 | - header("Connection: close"); |
|
| 1050 | - define('_DIRECT_CRON_FORCE', true); |
|
| 1051 | - cron(); |
|
| 1046 | + include_spip('inc/headers'); |
|
| 1047 | + http_status(204); // No Content |
|
| 1048 | + header("Connection: close"); |
|
| 1049 | + define('_DIRECT_CRON_FORCE', true); |
|
| 1050 | + cron(); |
|
| 1052 | 1051 | } |
| 1053 | 1052 | |
| 1054 | 1053 | /** |
@@ -1064,26 +1063,26 @@ discard block |
||
| 1064 | 1063 | * True si la tache a pu être effectuée |
| 1065 | 1064 | */ |
| 1066 | 1065 | function cron($taches = array(), $taches_old = array()) { |
| 1067 | - // si pas en mode cron force, laisser tomber. |
|
| 1068 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1069 | - return false; |
|
| 1070 | - } |
|
| 1071 | - if (!is_array($taches)) { |
|
| 1072 | - $taches = $taches_old; |
|
| 1073 | - } // compat anciens appels |
|
| 1074 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1075 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1076 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1077 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1078 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1079 | - return false; |
|
| 1080 | - } |
|
| 1081 | - spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1082 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1083 | - return $genie($taches); |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - return false; |
|
| 1066 | + // si pas en mode cron force, laisser tomber. |
|
| 1067 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1068 | + return false; |
|
| 1069 | + } |
|
| 1070 | + if (!is_array($taches)) { |
|
| 1071 | + $taches = $taches_old; |
|
| 1072 | + } // compat anciens appels |
|
| 1073 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1074 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1075 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1076 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1077 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1078 | + return false; |
|
| 1079 | + } |
|
| 1080 | + spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1081 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1082 | + return $genie($taches); |
|
| 1083 | + } |
|
| 1084 | + |
|
| 1085 | + return false; |
|
| 1087 | 1086 | } |
| 1088 | 1087 | |
| 1089 | 1088 | /** |
@@ -1115,17 +1114,17 @@ discard block |
||
| 1115 | 1114 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1116 | 1115 | */ |
| 1117 | 1116 | function job_queue_add( |
| 1118 | - $function, |
|
| 1119 | - $description, |
|
| 1120 | - $arguments = array(), |
|
| 1121 | - $file = '', |
|
| 1122 | - $no_duplicate = false, |
|
| 1123 | - $time = 0, |
|
| 1124 | - $priority = 0 |
|
| 1117 | + $function, |
|
| 1118 | + $description, |
|
| 1119 | + $arguments = array(), |
|
| 1120 | + $file = '', |
|
| 1121 | + $no_duplicate = false, |
|
| 1122 | + $time = 0, |
|
| 1123 | + $priority = 0 |
|
| 1125 | 1124 | ) { |
| 1126 | - include_spip('inc/queue'); |
|
| 1125 | + include_spip('inc/queue'); |
|
| 1127 | 1126 | |
| 1128 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1127 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1129 | 1128 | } |
| 1130 | 1129 | |
| 1131 | 1130 | /** |
@@ -1136,9 +1135,9 @@ discard block |
||
| 1136 | 1135 | * @return bool |
| 1137 | 1136 | */ |
| 1138 | 1137 | function job_queue_remove($id_job) { |
| 1139 | - include_spip('inc/queue'); |
|
| 1138 | + include_spip('inc/queue'); |
|
| 1140 | 1139 | |
| 1141 | - return queue_remove_job($id_job); |
|
| 1140 | + return queue_remove_job($id_job); |
|
| 1142 | 1141 | } |
| 1143 | 1142 | |
| 1144 | 1143 | /** |
@@ -1151,9 +1150,9 @@ discard block |
||
| 1151 | 1150 | * or an array of simple array to link multiples objet in one time |
| 1152 | 1151 | */ |
| 1153 | 1152 | function job_queue_link($id_job, $objets) { |
| 1154 | - include_spip('inc/queue'); |
|
| 1153 | + include_spip('inc/queue'); |
|
| 1155 | 1154 | |
| 1156 | - return queue_link_job($id_job, $objets); |
|
| 1155 | + return queue_link_job($id_job, $objets); |
|
| 1157 | 1156 | } |
| 1158 | 1157 | |
| 1159 | 1158 | |
@@ -1173,36 +1172,36 @@ discard block |
||
| 1173 | 1172 | * - `null` si la queue n'est pas encore initialisée |
| 1174 | 1173 | */ |
| 1175 | 1174 | function queue_sleep_time_to_next_job($force = null) { |
| 1176 | - static $queue_next_job_time = -1; |
|
| 1177 | - if ($force === true) { |
|
| 1178 | - $queue_next_job_time = -1; |
|
| 1179 | - } elseif ($force) { |
|
| 1180 | - $queue_next_job_time = $force; |
|
| 1181 | - } |
|
| 1182 | - |
|
| 1183 | - if ($queue_next_job_time == -1) { |
|
| 1184 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1185 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1186 | - } |
|
| 1187 | - // utiliser un cache memoire si dispo |
|
| 1188 | - if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1189 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1190 | - } else { |
|
| 1191 | - $queue_next_job_time = null; |
|
| 1192 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1193 | - $queue_next_job_time = intval($contenu); |
|
| 1194 | - } |
|
| 1195 | - } |
|
| 1196 | - } |
|
| 1197 | - |
|
| 1198 | - if (is_null($queue_next_job_time)) { |
|
| 1199 | - return null; |
|
| 1200 | - } |
|
| 1201 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1202 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1203 | - } |
|
| 1204 | - |
|
| 1205 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1175 | + static $queue_next_job_time = -1; |
|
| 1176 | + if ($force === true) { |
|
| 1177 | + $queue_next_job_time = -1; |
|
| 1178 | + } elseif ($force) { |
|
| 1179 | + $queue_next_job_time = $force; |
|
| 1180 | + } |
|
| 1181 | + |
|
| 1182 | + if ($queue_next_job_time == -1) { |
|
| 1183 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1184 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1185 | + } |
|
| 1186 | + // utiliser un cache memoire si dispo |
|
| 1187 | + if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1188 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1189 | + } else { |
|
| 1190 | + $queue_next_job_time = null; |
|
| 1191 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1192 | + $queue_next_job_time = intval($contenu); |
|
| 1193 | + } |
|
| 1194 | + } |
|
| 1195 | + } |
|
| 1196 | + |
|
| 1197 | + if (is_null($queue_next_job_time)) { |
|
| 1198 | + return null; |
|
| 1199 | + } |
|
| 1200 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1201 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1202 | + } |
|
| 1203 | + |
|
| 1204 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1206 | 1205 | } |
| 1207 | 1206 | |
| 1208 | 1207 | |
@@ -1214,9 +1213,9 @@ discard block |
||
| 1214 | 1213 | * @return string |
| 1215 | 1214 | */ |
| 1216 | 1215 | function quote_amp($u) { |
| 1217 | - return preg_replace( |
|
| 1218 | - "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1219 | - "&", $u); |
|
| 1216 | + return preg_replace( |
|
| 1217 | + "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1218 | + "&", $u); |
|
| 1220 | 1219 | } |
| 1221 | 1220 | |
| 1222 | 1221 | |
@@ -1239,27 +1238,27 @@ discard block |
||
| 1239 | 1238 | * Balise HTML `<script>` et son contenu |
| 1240 | 1239 | **/ |
| 1241 | 1240 | function http_script($script, $src = '', $noscript = '') { |
| 1242 | - static $done = array(); |
|
| 1241 | + static $done = array(); |
|
| 1243 | 1242 | |
| 1244 | - if ($src && !isset($done[$src])) { |
|
| 1245 | - $done[$src] = true; |
|
| 1246 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1247 | - $src = " src='$src'"; |
|
| 1248 | - } else { |
|
| 1249 | - $src = ''; |
|
| 1250 | - } |
|
| 1251 | - if ($script) { |
|
| 1252 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1253 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1254 | - "/*]]>*/"); |
|
| 1255 | - } |
|
| 1256 | - if ($noscript) { |
|
| 1257 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1258 | - } |
|
| 1243 | + if ($src && !isset($done[$src])) { |
|
| 1244 | + $done[$src] = true; |
|
| 1245 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1246 | + $src = " src='$src'"; |
|
| 1247 | + } else { |
|
| 1248 | + $src = ''; |
|
| 1249 | + } |
|
| 1250 | + if ($script) { |
|
| 1251 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1252 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1253 | + "/*]]>*/"); |
|
| 1254 | + } |
|
| 1255 | + if ($noscript) { |
|
| 1256 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1257 | + } |
|
| 1259 | 1258 | |
| 1260 | - return ($src or $script or $noscript) |
|
| 1261 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1262 | - : ''; |
|
| 1259 | + return ($src or $script or $noscript) |
|
| 1260 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1261 | + : ''; |
|
| 1263 | 1262 | } |
| 1264 | 1263 | |
| 1265 | 1264 | |
@@ -1294,7 +1293,7 @@ discard block |
||
| 1294 | 1293 | * Texte échappé |
| 1295 | 1294 | **/ |
| 1296 | 1295 | function texte_script($texte) { |
| 1297 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1296 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1298 | 1297 | } |
| 1299 | 1298 | |
| 1300 | 1299 | |
@@ -1331,68 +1330,68 @@ discard block |
||
| 1331 | 1330 | * Liste des chemins, par ordre de priorité. |
| 1332 | 1331 | **/ |
| 1333 | 1332 | function _chemin($dir_path = null) { |
| 1334 | - static $path_base = null; |
|
| 1335 | - static $path_full = null; |
|
| 1336 | - if ($path_base == null) { |
|
| 1337 | - // Chemin standard depuis l'espace public |
|
| 1338 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1339 | - _DIR_RACINE . ':' . |
|
| 1340 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1341 | - _DIR_RACINE . 'prive/:' . |
|
| 1342 | - _DIR_RESTREINT; |
|
| 1343 | - // Ajouter squelettes/ |
|
| 1344 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1345 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1346 | - } |
|
| 1347 | - foreach (explode(':', $path) as $dir) { |
|
| 1348 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1349 | - $dir .= "/"; |
|
| 1350 | - } |
|
| 1351 | - $path_base[] = $dir; |
|
| 1352 | - } |
|
| 1353 | - $path_full = $path_base; |
|
| 1354 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1355 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1356 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1357 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1358 | - } |
|
| 1359 | - } |
|
| 1360 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1361 | - } |
|
| 1362 | - if ($dir_path === null) { |
|
| 1363 | - return $path_full; |
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1367 | - $tete = ""; |
|
| 1368 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1369 | - $tete = array_shift($path_base); |
|
| 1370 | - } |
|
| 1371 | - $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1372 | - $dirs = array_reverse($dirs); |
|
| 1373 | - foreach ($dirs as $dir_path) { |
|
| 1374 | - if (substr($dir_path, -1) != '/') { |
|
| 1375 | - $dir_path .= "/"; |
|
| 1376 | - } |
|
| 1377 | - if (!in_array($dir_path, $path_base)) { |
|
| 1378 | - array_unshift($path_base, $dir_path); |
|
| 1379 | - } |
|
| 1380 | - } |
|
| 1381 | - if (strlen($tete)) { |
|
| 1382 | - array_unshift($path_base, $tete); |
|
| 1383 | - } |
|
| 1384 | - } |
|
| 1385 | - $path_full = $path_base; |
|
| 1386 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1387 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1388 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1389 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1390 | - } |
|
| 1391 | - } |
|
| 1392 | - |
|
| 1393 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1394 | - |
|
| 1395 | - return $path_full; |
|
| 1333 | + static $path_base = null; |
|
| 1334 | + static $path_full = null; |
|
| 1335 | + if ($path_base == null) { |
|
| 1336 | + // Chemin standard depuis l'espace public |
|
| 1337 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1338 | + _DIR_RACINE . ':' . |
|
| 1339 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1340 | + _DIR_RACINE . 'prive/:' . |
|
| 1341 | + _DIR_RESTREINT; |
|
| 1342 | + // Ajouter squelettes/ |
|
| 1343 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1344 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1345 | + } |
|
| 1346 | + foreach (explode(':', $path) as $dir) { |
|
| 1347 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1348 | + $dir .= "/"; |
|
| 1349 | + } |
|
| 1350 | + $path_base[] = $dir; |
|
| 1351 | + } |
|
| 1352 | + $path_full = $path_base; |
|
| 1353 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1354 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1355 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1356 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1357 | + } |
|
| 1358 | + } |
|
| 1359 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1360 | + } |
|
| 1361 | + if ($dir_path === null) { |
|
| 1362 | + return $path_full; |
|
| 1363 | + } |
|
| 1364 | + |
|
| 1365 | + if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1366 | + $tete = ""; |
|
| 1367 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1368 | + $tete = array_shift($path_base); |
|
| 1369 | + } |
|
| 1370 | + $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1371 | + $dirs = array_reverse($dirs); |
|
| 1372 | + foreach ($dirs as $dir_path) { |
|
| 1373 | + if (substr($dir_path, -1) != '/') { |
|
| 1374 | + $dir_path .= "/"; |
|
| 1375 | + } |
|
| 1376 | + if (!in_array($dir_path, $path_base)) { |
|
| 1377 | + array_unshift($path_base, $dir_path); |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1380 | + if (strlen($tete)) { |
|
| 1381 | + array_unshift($path_base, $tete); |
|
| 1382 | + } |
|
| 1383 | + } |
|
| 1384 | + $path_full = $path_base; |
|
| 1385 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1386 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1387 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1388 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1389 | + } |
|
| 1390 | + } |
|
| 1391 | + |
|
| 1392 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1393 | + |
|
| 1394 | + return $path_full; |
|
| 1396 | 1395 | } |
| 1397 | 1396 | |
| 1398 | 1397 | /** |
@@ -1405,76 +1404,76 @@ discard block |
||
| 1405 | 1404 | * @return array Liste de chemins |
| 1406 | 1405 | **/ |
| 1407 | 1406 | function creer_chemin() { |
| 1408 | - $path_a = _chemin(); |
|
| 1409 | - static $c = ''; |
|
| 1407 | + $path_a = _chemin(); |
|
| 1408 | + static $c = ''; |
|
| 1410 | 1409 | |
| 1411 | - // on calcule le chemin si le dossier skel a change |
|
| 1412 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1413 | - // assurer le non plantage lors de la montee de version : |
|
| 1414 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1415 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1416 | - } |
|
| 1410 | + // on calcule le chemin si le dossier skel a change |
|
| 1411 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1412 | + // assurer le non plantage lors de la montee de version : |
|
| 1413 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1414 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1415 | + } |
|
| 1417 | 1416 | |
| 1418 | - return $path_a; |
|
| 1417 | + return $path_a; |
|
| 1419 | 1418 | } |
| 1420 | 1419 | |
| 1421 | 1420 | |
| 1422 | 1421 | function lister_themes_prives() { |
| 1423 | - static $themes = null; |
|
| 1424 | - if (is_null($themes)) { |
|
| 1425 | - // si pas encore definie |
|
| 1426 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1427 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1428 | - } |
|
| 1429 | - $themes = array(_SPIP_THEME_PRIVE); |
|
| 1430 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1431 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1432 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1433 | - } else { |
|
| 1434 | - $prefs = array(); |
|
| 1435 | - } |
|
| 1436 | - if (is_string($prefs)) { |
|
| 1437 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1438 | - } |
|
| 1439 | - if ( |
|
| 1440 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1441 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1442 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1443 | - ) { |
|
| 1444 | - array_unshift($themes, $theme); |
|
| 1445 | - } // placer le theme choisi en tete |
|
| 1446 | - } |
|
| 1447 | - |
|
| 1448 | - return $themes; |
|
| 1422 | + static $themes = null; |
|
| 1423 | + if (is_null($themes)) { |
|
| 1424 | + // si pas encore definie |
|
| 1425 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1426 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1427 | + } |
|
| 1428 | + $themes = array(_SPIP_THEME_PRIVE); |
|
| 1429 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1430 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1431 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1432 | + } else { |
|
| 1433 | + $prefs = array(); |
|
| 1434 | + } |
|
| 1435 | + if (is_string($prefs)) { |
|
| 1436 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1437 | + } |
|
| 1438 | + if ( |
|
| 1439 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1440 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1441 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1442 | + ) { |
|
| 1443 | + array_unshift($themes, $theme); |
|
| 1444 | + } // placer le theme choisi en tete |
|
| 1445 | + } |
|
| 1446 | + |
|
| 1447 | + return $themes; |
|
| 1449 | 1448 | } |
| 1450 | 1449 | |
| 1451 | 1450 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1452 | - static $themefiles = array(); |
|
| 1453 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1454 | - return $themefiles["$subdir$file"]; |
|
| 1455 | - } |
|
| 1456 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1457 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1458 | - if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1459 | - and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1460 | - and $f = find_in_theme("$file_svg_generique")) { |
|
| 1461 | - if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1462 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1463 | - } |
|
| 1464 | - else { |
|
| 1465 | - return $themefiles["$subdir$file"] = "$f?".$m[1]."px"; |
|
| 1466 | - } |
|
| 1467 | - } |
|
| 1468 | - |
|
| 1469 | - $themes = lister_themes_prives(); |
|
| 1470 | - foreach ($themes as $theme) { |
|
| 1471 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1472 | - return $themefiles["$subdir$file"] = $f; |
|
| 1473 | - } |
|
| 1474 | - } |
|
| 1475 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1476 | - |
|
| 1477 | - return $themefiles["$subdir$file"] = ""; |
|
| 1451 | + static $themefiles = array(); |
|
| 1452 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1453 | + return $themefiles["$subdir$file"]; |
|
| 1454 | + } |
|
| 1455 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1456 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1457 | + if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1458 | + and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1459 | + and $f = find_in_theme("$file_svg_generique")) { |
|
| 1460 | + if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1461 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1462 | + } |
|
| 1463 | + else { |
|
| 1464 | + return $themefiles["$subdir$file"] = "$f?".$m[1]."px"; |
|
| 1465 | + } |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + $themes = lister_themes_prives(); |
|
| 1469 | + foreach ($themes as $theme) { |
|
| 1470 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1471 | + return $themefiles["$subdir$file"] = $f; |
|
| 1472 | + } |
|
| 1473 | + } |
|
| 1474 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1475 | + |
|
| 1476 | + return $themefiles["$subdir$file"] = ""; |
|
| 1478 | 1477 | } |
| 1479 | 1478 | |
| 1480 | 1479 | |
@@ -1498,31 +1497,31 @@ discard block |
||
| 1498 | 1497 | * sinon chaîne vide. |
| 1499 | 1498 | **/ |
| 1500 | 1499 | function chemin_image($icone) { |
| 1501 | - static $icone_renommer; |
|
| 1502 | - if ($p = strpos($icone, '?')) { |
|
| 1503 | - $icone = substr($icone,0, $p); |
|
| 1504 | - } |
|
| 1505 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1506 | - if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1507 | - return $icone; |
|
| 1508 | - } |
|
| 1509 | - |
|
| 1510 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1511 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1512 | - return $f; |
|
| 1513 | - } |
|
| 1514 | - // sinon passer par le module de renommage |
|
| 1515 | - if (is_null($icone_renommer)) { |
|
| 1516 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1517 | - } |
|
| 1518 | - if ($icone_renommer) { |
|
| 1519 | - list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1520 | - if (file_exists($icone)) { |
|
| 1521 | - return $icone; |
|
| 1522 | - } |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1500 | + static $icone_renommer; |
|
| 1501 | + if ($p = strpos($icone, '?')) { |
|
| 1502 | + $icone = substr($icone,0, $p); |
|
| 1503 | + } |
|
| 1504 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1505 | + if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1506 | + return $icone; |
|
| 1507 | + } |
|
| 1508 | + |
|
| 1509 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1510 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1511 | + return $f; |
|
| 1512 | + } |
|
| 1513 | + // sinon passer par le module de renommage |
|
| 1514 | + if (is_null($icone_renommer)) { |
|
| 1515 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1516 | + } |
|
| 1517 | + if ($icone_renommer) { |
|
| 1518 | + list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1519 | + if (file_exists($icone)) { |
|
| 1520 | + return $icone; |
|
| 1521 | + } |
|
| 1522 | + } |
|
| 1523 | + |
|
| 1524 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1526 | 1525 | } |
| 1527 | 1526 | |
| 1528 | 1527 | // |
@@ -1560,127 +1559,127 @@ discard block |
||
| 1560 | 1559 | * - false : fichier introuvable |
| 1561 | 1560 | **/ |
| 1562 | 1561 | function find_in_path($file, $dirname = '', $include = false) { |
| 1563 | - static $dirs = array(); |
|
| 1564 | - static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1565 | - static $c = ''; |
|
| 1566 | - |
|
| 1567 | - if (!$file and !strlen($file)) { |
|
| 1568 | - return false; |
|
| 1569 | - } |
|
| 1570 | - |
|
| 1571 | - // on calcule le chemin si le dossier skel a change |
|
| 1572 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1573 | - // assurer le non plantage lors de la montee de version : |
|
| 1574 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1575 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1576 | - } |
|
| 1577 | - |
|
| 1578 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1579 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1580 | - return false; |
|
| 1581 | - } |
|
| 1582 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1583 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1584 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1585 | - } |
|
| 1586 | - |
|
| 1587 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1588 | - } |
|
| 1589 | - |
|
| 1590 | - $a = strrpos($file, '/'); |
|
| 1591 | - if ($a !== false) { |
|
| 1592 | - $dirname .= substr($file, 0, ++$a); |
|
| 1593 | - $file = substr($file, $a); |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - foreach (creer_chemin() as $dir) { |
|
| 1597 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1598 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1599 | - } |
|
| 1600 | - if ($dirs[$a]) { |
|
| 1601 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1602 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1603 | - include_once _ROOT_CWD . $a; |
|
| 1604 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1605 | - } |
|
| 1606 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1607 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1608 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1609 | - return $a; |
|
| 1610 | - } |
|
| 1611 | - define('_SAUVER_CHEMIN', true); |
|
| 1612 | - } |
|
| 1613 | - |
|
| 1614 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1615 | - } |
|
| 1616 | - } |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - if ($include) { |
|
| 1620 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1621 | - if ($include === 'required') { |
|
| 1622 | - echo '<pre>', |
|
| 1623 | - "<strong>Erreur Fatale</strong><br />"; |
|
| 1624 | - if (function_exists('debug_print_backtrace')) { |
|
| 1625 | - echo debug_print_backtrace(); |
|
| 1626 | - } |
|
| 1627 | - echo '</pre>'; |
|
| 1628 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1629 | - } |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1633 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1634 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1635 | - return false; |
|
| 1636 | - } |
|
| 1637 | - define('_SAUVER_CHEMIN', true); |
|
| 1638 | - } |
|
| 1639 | - |
|
| 1640 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1562 | + static $dirs = array(); |
|
| 1563 | + static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1564 | + static $c = ''; |
|
| 1565 | + |
|
| 1566 | + if (!$file and !strlen($file)) { |
|
| 1567 | + return false; |
|
| 1568 | + } |
|
| 1569 | + |
|
| 1570 | + // on calcule le chemin si le dossier skel a change |
|
| 1571 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1572 | + // assurer le non plantage lors de la montee de version : |
|
| 1573 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1574 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1575 | + } |
|
| 1576 | + |
|
| 1577 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1578 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1579 | + return false; |
|
| 1580 | + } |
|
| 1581 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1582 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1583 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1584 | + } |
|
| 1585 | + |
|
| 1586 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1587 | + } |
|
| 1588 | + |
|
| 1589 | + $a = strrpos($file, '/'); |
|
| 1590 | + if ($a !== false) { |
|
| 1591 | + $dirname .= substr($file, 0, ++$a); |
|
| 1592 | + $file = substr($file, $a); |
|
| 1593 | + } |
|
| 1594 | + |
|
| 1595 | + foreach (creer_chemin() as $dir) { |
|
| 1596 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1597 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1598 | + } |
|
| 1599 | + if ($dirs[$a]) { |
|
| 1600 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1601 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1602 | + include_once _ROOT_CWD . $a; |
|
| 1603 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1604 | + } |
|
| 1605 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1606 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1607 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1608 | + return $a; |
|
| 1609 | + } |
|
| 1610 | + define('_SAUVER_CHEMIN', true); |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1614 | + } |
|
| 1615 | + } |
|
| 1616 | + } |
|
| 1617 | + |
|
| 1618 | + if ($include) { |
|
| 1619 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1620 | + if ($include === 'required') { |
|
| 1621 | + echo '<pre>', |
|
| 1622 | + "<strong>Erreur Fatale</strong><br />"; |
|
| 1623 | + if (function_exists('debug_print_backtrace')) { |
|
| 1624 | + echo debug_print_backtrace(); |
|
| 1625 | + } |
|
| 1626 | + echo '</pre>'; |
|
| 1627 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1628 | + } |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1632 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1633 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1634 | + return false; |
|
| 1635 | + } |
|
| 1636 | + define('_SAUVER_CHEMIN', true); |
|
| 1637 | + } |
|
| 1638 | + |
|
| 1639 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1641 | 1640 | } |
| 1642 | 1641 | |
| 1643 | 1642 | function clear_path_cache() { |
| 1644 | - $GLOBALS['path_files'] = array(); |
|
| 1645 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1643 | + $GLOBALS['path_files'] = array(); |
|
| 1644 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1646 | 1645 | } |
| 1647 | 1646 | |
| 1648 | 1647 | function load_path_cache() { |
| 1649 | - // charger le path des plugins |
|
| 1650 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1651 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1652 | - } |
|
| 1653 | - $GLOBALS['path_files'] = array(); |
|
| 1654 | - // si le visiteur est admin, |
|
| 1655 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1656 | - if ( |
|
| 1657 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1658 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1659 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1660 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1661 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1662 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1663 | - !_request('var_mode') |
|
| 1664 | - ) { |
|
| 1665 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1666 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1667 | - // mais si semble corrompu on relit avec un verrou |
|
| 1668 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1669 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1670 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1671 | - $GLOBALS['path_files'] = array(); |
|
| 1672 | - } |
|
| 1673 | - } |
|
| 1674 | - } |
|
| 1675 | - } |
|
| 1648 | + // charger le path des plugins |
|
| 1649 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1650 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1651 | + } |
|
| 1652 | + $GLOBALS['path_files'] = array(); |
|
| 1653 | + // si le visiteur est admin, |
|
| 1654 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1655 | + if ( |
|
| 1656 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1657 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1658 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1659 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1660 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1661 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1662 | + !_request('var_mode') |
|
| 1663 | + ) { |
|
| 1664 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1665 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1666 | + // mais si semble corrompu on relit avec un verrou |
|
| 1667 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1668 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1669 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1670 | + $GLOBALS['path_files'] = array(); |
|
| 1671 | + } |
|
| 1672 | + } |
|
| 1673 | + } |
|
| 1674 | + } |
|
| 1676 | 1675 | } |
| 1677 | 1676 | |
| 1678 | 1677 | function save_path_cache() { |
| 1679 | - if (defined('_SAUVER_CHEMIN') |
|
| 1680 | - and _SAUVER_CHEMIN |
|
| 1681 | - ) { |
|
| 1682 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1683 | - } |
|
| 1678 | + if (defined('_SAUVER_CHEMIN') |
|
| 1679 | + and _SAUVER_CHEMIN |
|
| 1680 | + ) { |
|
| 1681 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1682 | + } |
|
| 1684 | 1683 | } |
| 1685 | 1684 | |
| 1686 | 1685 | |
@@ -1700,33 +1699,33 @@ discard block |
||
| 1700 | 1699 | * @return array |
| 1701 | 1700 | */ |
| 1702 | 1701 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1703 | - $liste_fichiers = array(); |
|
| 1704 | - $maxfiles = 10000; |
|
| 1705 | - |
|
| 1706 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1707 | - // on a pas encore inclus flock.php |
|
| 1708 | - if (!function_exists('preg_files')) { |
|
| 1709 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1710 | - } |
|
| 1711 | - |
|
| 1712 | - // Parcourir le chemin |
|
| 1713 | - foreach (creer_chemin() as $d) { |
|
| 1714 | - $f = $d . $dir; |
|
| 1715 | - if (@is_dir($f)) { |
|
| 1716 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1717 | - foreach ($liste as $chemin) { |
|
| 1718 | - $nom = basename($chemin); |
|
| 1719 | - // ne prendre que les fichiers pas deja trouves |
|
| 1720 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1721 | - // les autres sont donc masques |
|
| 1722 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1723 | - $liste_fichiers[$nom] = $chemin; |
|
| 1724 | - } |
|
| 1725 | - } |
|
| 1726 | - } |
|
| 1727 | - } |
|
| 1728 | - |
|
| 1729 | - return $liste_fichiers; |
|
| 1702 | + $liste_fichiers = array(); |
|
| 1703 | + $maxfiles = 10000; |
|
| 1704 | + |
|
| 1705 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1706 | + // on a pas encore inclus flock.php |
|
| 1707 | + if (!function_exists('preg_files')) { |
|
| 1708 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1709 | + } |
|
| 1710 | + |
|
| 1711 | + // Parcourir le chemin |
|
| 1712 | + foreach (creer_chemin() as $d) { |
|
| 1713 | + $f = $d . $dir; |
|
| 1714 | + if (@is_dir($f)) { |
|
| 1715 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1716 | + foreach ($liste as $chemin) { |
|
| 1717 | + $nom = basename($chemin); |
|
| 1718 | + // ne prendre que les fichiers pas deja trouves |
|
| 1719 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1720 | + // les autres sont donc masques |
|
| 1721 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1722 | + $liste_fichiers[$nom] = $chemin; |
|
| 1723 | + } |
|
| 1724 | + } |
|
| 1725 | + } |
|
| 1726 | + } |
|
| 1727 | + |
|
| 1728 | + return $liste_fichiers; |
|
| 1730 | 1729 | } |
| 1731 | 1730 | |
| 1732 | 1731 | /** |
@@ -1738,17 +1737,17 @@ discard block |
||
| 1738 | 1737 | * @return bool |
| 1739 | 1738 | */ |
| 1740 | 1739 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1741 | - static $autsanscookie = array('install', 'base_repair'); |
|
| 1740 | + static $autsanscookie = array('install', 'base_repair'); |
|
| 1742 | 1741 | |
| 1743 | - if (in_array($nom, $autsanscookie)) { |
|
| 1744 | - if (test_espace_prive()){ |
|
| 1745 | - include_spip('base/connect_sql'); |
|
| 1746 | - if (!$strict or !spip_connect()){ |
|
| 1747 | - return true; |
|
| 1748 | - } |
|
| 1749 | - } |
|
| 1750 | - } |
|
| 1751 | - return false; |
|
| 1742 | + if (in_array($nom, $autsanscookie)) { |
|
| 1743 | + if (test_espace_prive()){ |
|
| 1744 | + include_spip('base/connect_sql'); |
|
| 1745 | + if (!$strict or !spip_connect()){ |
|
| 1746 | + return true; |
|
| 1747 | + } |
|
| 1748 | + } |
|
| 1749 | + } |
|
| 1750 | + return false; |
|
| 1752 | 1751 | } |
| 1753 | 1752 | |
| 1754 | 1753 | /** |
@@ -1774,99 +1773,99 @@ discard block |
||
| 1774 | 1773 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip) |
| 1775 | 1774 | */ |
| 1776 | 1775 | function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1777 | - if ($public === null) { |
|
| 1778 | - $public = !test_espace_prive(); |
|
| 1779 | - } |
|
| 1780 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1781 | - |
|
| 1782 | - if (!$public) { |
|
| 1783 | - if (!$entite) { |
|
| 1784 | - return ''; |
|
| 1785 | - } |
|
| 1786 | - if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1787 | - include_spip('inc/urls'); |
|
| 1788 | - } |
|
| 1789 | - $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1790 | - } else { |
|
| 1791 | - if ($type === null) { |
|
| 1792 | - $type = (isset($GLOBALS['type_urls'])) |
|
| 1793 | - ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1794 | - : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1795 | - ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1796 | - } |
|
| 1797 | - |
|
| 1798 | - $f = charger_fonction($type, 'urls', true); |
|
| 1799 | - // se rabattre sur les urls page si les urls perso non dispo |
|
| 1800 | - if (!$f) { |
|
| 1801 | - $f = charger_fonction('page', 'urls', true); |
|
| 1802 | - } |
|
| 1803 | - |
|
| 1804 | - // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1805 | - // sinon on veut effectuer le passage id ==> URL |
|
| 1806 | - if (!$entite) { |
|
| 1807 | - return $f; |
|
| 1808 | - } |
|
| 1809 | - |
|
| 1810 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1811 | - // base distante |
|
| 1812 | - if (is_string($public) |
|
| 1813 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1814 | - ) { |
|
| 1815 | - $f = $g; |
|
| 1816 | - } |
|
| 1817 | - |
|
| 1818 | - $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1819 | - |
|
| 1820 | - } |
|
| 1821 | - if ($res) { |
|
| 1822 | - return $res; |
|
| 1823 | - } |
|
| 1824 | - // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1825 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1826 | - if (!function_exists($f .= '_dist')) { |
|
| 1827 | - $f = ''; |
|
| 1828 | - } |
|
| 1829 | - } |
|
| 1830 | - if ($f) { |
|
| 1831 | - $url = $f($id, $args, $ancre); |
|
| 1832 | - if (strlen($args)) { |
|
| 1833 | - $url .= strstr($url, '?') |
|
| 1834 | - ? '&' . $args |
|
| 1835 | - : '?' . $args; |
|
| 1836 | - } |
|
| 1837 | - |
|
| 1838 | - return $url; |
|
| 1839 | - } |
|
| 1840 | - // On a ete gentil mais la .... |
|
| 1841 | - spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1842 | - |
|
| 1843 | - return ''; |
|
| 1776 | + if ($public === null) { |
|
| 1777 | + $public = !test_espace_prive(); |
|
| 1778 | + } |
|
| 1779 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1780 | + |
|
| 1781 | + if (!$public) { |
|
| 1782 | + if (!$entite) { |
|
| 1783 | + return ''; |
|
| 1784 | + } |
|
| 1785 | + if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1786 | + include_spip('inc/urls'); |
|
| 1787 | + } |
|
| 1788 | + $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1789 | + } else { |
|
| 1790 | + if ($type === null) { |
|
| 1791 | + $type = (isset($GLOBALS['type_urls'])) |
|
| 1792 | + ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1793 | + : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1794 | + ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1795 | + } |
|
| 1796 | + |
|
| 1797 | + $f = charger_fonction($type, 'urls', true); |
|
| 1798 | + // se rabattre sur les urls page si les urls perso non dispo |
|
| 1799 | + if (!$f) { |
|
| 1800 | + $f = charger_fonction('page', 'urls', true); |
|
| 1801 | + } |
|
| 1802 | + |
|
| 1803 | + // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1804 | + // sinon on veut effectuer le passage id ==> URL |
|
| 1805 | + if (!$entite) { |
|
| 1806 | + return $f; |
|
| 1807 | + } |
|
| 1808 | + |
|
| 1809 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1810 | + // base distante |
|
| 1811 | + if (is_string($public) |
|
| 1812 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1813 | + ) { |
|
| 1814 | + $f = $g; |
|
| 1815 | + } |
|
| 1816 | + |
|
| 1817 | + $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1818 | + |
|
| 1819 | + } |
|
| 1820 | + if ($res) { |
|
| 1821 | + return $res; |
|
| 1822 | + } |
|
| 1823 | + // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1824 | + if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1825 | + if (!function_exists($f .= '_dist')) { |
|
| 1826 | + $f = ''; |
|
| 1827 | + } |
|
| 1828 | + } |
|
| 1829 | + if ($f) { |
|
| 1830 | + $url = $f($id, $args, $ancre); |
|
| 1831 | + if (strlen($args)) { |
|
| 1832 | + $url .= strstr($url, '?') |
|
| 1833 | + ? '&' . $args |
|
| 1834 | + : '?' . $args; |
|
| 1835 | + } |
|
| 1836 | + |
|
| 1837 | + return $url; |
|
| 1838 | + } |
|
| 1839 | + // On a ete gentil mais la .... |
|
| 1840 | + spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1841 | + |
|
| 1842 | + return ''; |
|
| 1844 | 1843 | } |
| 1845 | 1844 | |
| 1846 | 1845 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 1847 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1848 | - $url = generer_url_ecrire($exec, $args); |
|
| 1849 | - if (intval($id)) { |
|
| 1850 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1851 | - } else { |
|
| 1852 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1853 | - } |
|
| 1854 | - if ($ancre) { |
|
| 1855 | - $url = ancre_url($url, $ancre); |
|
| 1856 | - } |
|
| 1846 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1847 | + $url = generer_url_ecrire($exec, $args); |
|
| 1848 | + if (intval($id)) { |
|
| 1849 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1850 | + } else { |
|
| 1851 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1852 | + } |
|
| 1853 | + if ($ancre) { |
|
| 1854 | + $url = ancre_url($url, $ancre); |
|
| 1855 | + } |
|
| 1857 | 1856 | |
| 1858 | - return $url; |
|
| 1857 | + return $url; |
|
| 1859 | 1858 | } |
| 1860 | 1859 | |
| 1861 | 1860 | // https://code.spip.net/@urls_connect_dist |
| 1862 | 1861 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1863 | - include_spip('base/connect_sql'); |
|
| 1864 | - $id_type = id_table_objet($entite, $public); |
|
| 1862 | + include_spip('base/connect_sql'); |
|
| 1863 | + $id_type = id_table_objet($entite, $public); |
|
| 1865 | 1864 | |
| 1866 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1867 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1868 | - . (!$args ? '' : "&$args") |
|
| 1869 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1865 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1866 | + . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1867 | + . (!$args ? '' : "&$args") |
|
| 1868 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1870 | 1869 | } |
| 1871 | 1870 | |
| 1872 | 1871 | |
@@ -1877,32 +1876,32 @@ discard block |
||
| 1877 | 1876 | * @return string |
| 1878 | 1877 | */ |
| 1879 | 1878 | function urlencode_1738($url) { |
| 1880 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1881 | - $uri = ''; |
|
| 1882 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1883 | - if (ord($a = $url[$i]) > 127) { |
|
| 1884 | - $a = rawurlencode($a); |
|
| 1885 | - } |
|
| 1886 | - $uri .= $a; |
|
| 1887 | - } |
|
| 1888 | - $url = $uri; |
|
| 1889 | - } |
|
| 1879 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1880 | + $uri = ''; |
|
| 1881 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1882 | + if (ord($a = $url[$i]) > 127) { |
|
| 1883 | + $a = rawurlencode($a); |
|
| 1884 | + } |
|
| 1885 | + $uri .= $a; |
|
| 1886 | + } |
|
| 1887 | + $url = $uri; |
|
| 1888 | + } |
|
| 1890 | 1889 | |
| 1891 | - return quote_amp($url); |
|
| 1890 | + return quote_amp($url); |
|
| 1892 | 1891 | } |
| 1893 | 1892 | |
| 1894 | 1893 | // https://code.spip.net/@generer_url_entite_absolue |
| 1895 | 1894 | function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { |
| 1896 | - if (!$connect) { |
|
| 1897 | - $connect = true; |
|
| 1898 | - } |
|
| 1899 | - $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1900 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1901 | - include_spip('inc/filtres_mini'); |
|
| 1902 | - $h = url_absolue($h); |
|
| 1903 | - } |
|
| 1895 | + if (!$connect) { |
|
| 1896 | + $connect = true; |
|
| 1897 | + } |
|
| 1898 | + $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1899 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1900 | + include_spip('inc/filtres_mini'); |
|
| 1901 | + $h = url_absolue($h); |
|
| 1902 | + } |
|
| 1904 | 1903 | |
| 1905 | - return $h; |
|
| 1904 | + return $h; |
|
| 1906 | 1905 | } |
| 1907 | 1906 | |
| 1908 | 1907 | |
@@ -1918,11 +1917,11 @@ discard block |
||
| 1918 | 1917 | * true si la valeur est considérée active ; false sinon. |
| 1919 | 1918 | **/ |
| 1920 | 1919 | function test_valeur_serveur($truc) { |
| 1921 | - if (!$truc) { |
|
| 1922 | - return false; |
|
| 1923 | - } |
|
| 1920 | + if (!$truc) { |
|
| 1921 | + return false; |
|
| 1922 | + } |
|
| 1924 | 1923 | |
| 1925 | - return (strtolower($truc) !== 'off'); |
|
| 1924 | + return (strtolower($truc) !== 'off'); |
|
| 1926 | 1925 | } |
| 1927 | 1926 | |
| 1928 | 1927 | // |
@@ -1950,80 +1949,80 @@ discard block |
||
| 1950 | 1949 | */ |
| 1951 | 1950 | function url_de_base($profondeur = null) { |
| 1952 | 1951 | |
| 1953 | - static $url = array(); |
|
| 1954 | - if (is_array($profondeur)) { |
|
| 1955 | - return $url = $profondeur; |
|
| 1956 | - } |
|
| 1957 | - if ($profondeur === false) { |
|
| 1958 | - return $url; |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - if (is_null($profondeur)) { |
|
| 1962 | - $profondeur = $GLOBALS['profondeur_url']; |
|
| 1963 | - } |
|
| 1964 | - |
|
| 1965 | - if (isset($url[$profondeur])) { |
|
| 1966 | - return $url[$profondeur]; |
|
| 1967 | - } |
|
| 1968 | - |
|
| 1969 | - $http = 'http'; |
|
| 1970 | - |
|
| 1971 | - if ( |
|
| 1972 | - isset($_SERVER["SCRIPT_URI"]) |
|
| 1973 | - and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1974 | - ) { |
|
| 1975 | - $http = 'https'; |
|
| 1976 | - } elseif ( |
|
| 1977 | - isset($_SERVER['HTTPS']) |
|
| 1978 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1979 | - ) { |
|
| 1980 | - $http = 'https'; |
|
| 1981 | - } |
|
| 1982 | - |
|
| 1983 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 1984 | - $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1985 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1986 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1987 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 1988 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1989 | - $http = $scheme; |
|
| 1990 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 1991 | - } |
|
| 1992 | - } |
|
| 1993 | - if (isset($_SERVER['SERVER_PORT']) |
|
| 1994 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 1995 | - and strpos($host, ":") == false |
|
| 1996 | - ) { |
|
| 1997 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1998 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 1999 | - } |
|
| 2000 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2001 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2002 | - } |
|
| 2003 | - if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2004 | - $host .= ":$port"; |
|
| 2005 | - } |
|
| 2006 | - if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2007 | - $host .= ":$port"; |
|
| 2008 | - } |
|
| 2009 | - } |
|
| 2010 | - |
|
| 2011 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 2012 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2013 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2014 | - } else { |
|
| 2015 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2016 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 2017 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2018 | - ) { |
|
| 2019 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2020 | - } |
|
| 2021 | - } |
|
| 2022 | - } |
|
| 2023 | - |
|
| 2024 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2025 | - |
|
| 2026 | - return $url[$profondeur]; |
|
| 1952 | + static $url = array(); |
|
| 1953 | + if (is_array($profondeur)) { |
|
| 1954 | + return $url = $profondeur; |
|
| 1955 | + } |
|
| 1956 | + if ($profondeur === false) { |
|
| 1957 | + return $url; |
|
| 1958 | + } |
|
| 1959 | + |
|
| 1960 | + if (is_null($profondeur)) { |
|
| 1961 | + $profondeur = $GLOBALS['profondeur_url']; |
|
| 1962 | + } |
|
| 1963 | + |
|
| 1964 | + if (isset($url[$profondeur])) { |
|
| 1965 | + return $url[$profondeur]; |
|
| 1966 | + } |
|
| 1967 | + |
|
| 1968 | + $http = 'http'; |
|
| 1969 | + |
|
| 1970 | + if ( |
|
| 1971 | + isset($_SERVER["SCRIPT_URI"]) |
|
| 1972 | + and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1973 | + ) { |
|
| 1974 | + $http = 'https'; |
|
| 1975 | + } elseif ( |
|
| 1976 | + isset($_SERVER['HTTPS']) |
|
| 1977 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1978 | + ) { |
|
| 1979 | + $http = 'https'; |
|
| 1980 | + } |
|
| 1981 | + |
|
| 1982 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 1983 | + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1984 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1985 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1986 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 1987 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1988 | + $http = $scheme; |
|
| 1989 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 1990 | + } |
|
| 1991 | + } |
|
| 1992 | + if (isset($_SERVER['SERVER_PORT']) |
|
| 1993 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 1994 | + and strpos($host, ":") == false |
|
| 1995 | + ) { |
|
| 1996 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1997 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 1998 | + } |
|
| 1999 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2000 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2001 | + } |
|
| 2002 | + if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2003 | + $host .= ":$port"; |
|
| 2004 | + } |
|
| 2005 | + if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2006 | + $host .= ":$port"; |
|
| 2007 | + } |
|
| 2008 | + } |
|
| 2009 | + |
|
| 2010 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 2011 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2012 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2013 | + } else { |
|
| 2014 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2015 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 2016 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2017 | + ) { |
|
| 2018 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2019 | + } |
|
| 2020 | + } |
|
| 2021 | + } |
|
| 2022 | + |
|
| 2023 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2024 | + |
|
| 2025 | + return $url[$profondeur]; |
|
| 2027 | 2026 | } |
| 2028 | 2027 | |
| 2029 | 2028 | /** |
@@ -2036,26 +2035,26 @@ discard block |
||
| 2036 | 2035 | * @return string |
| 2037 | 2036 | */ |
| 2038 | 2037 | function url_de_($http, $host, $request, $prof = 0) { |
| 2039 | - $prof = max($prof, 0); |
|
| 2038 | + $prof = max($prof, 0); |
|
| 2040 | 2039 | |
| 2041 | - $myself = ltrim($request, '/'); |
|
| 2042 | - # supprimer la chaine de GET |
|
| 2043 | - list($myself) = explode('?', $myself); |
|
| 2044 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2045 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2046 | - if (strpos($myself,'://') !== false) { |
|
| 2047 | - $myself = explode('://',$myself); |
|
| 2048 | - array_shift($myself); |
|
| 2049 | - $myself = implode('://',$myself); |
|
| 2050 | - $myself = explode('/',$myself); |
|
| 2051 | - array_shift($myself); |
|
| 2052 | - $myself = implode('/',$myself); |
|
| 2053 | - } |
|
| 2054 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2040 | + $myself = ltrim($request, '/'); |
|
| 2041 | + # supprimer la chaine de GET |
|
| 2042 | + list($myself) = explode('?', $myself); |
|
| 2043 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2044 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2045 | + if (strpos($myself,'://') !== false) { |
|
| 2046 | + $myself = explode('://',$myself); |
|
| 2047 | + array_shift($myself); |
|
| 2048 | + $myself = implode('://',$myself); |
|
| 2049 | + $myself = explode('/',$myself); |
|
| 2050 | + array_shift($myself); |
|
| 2051 | + $myself = implode('/',$myself); |
|
| 2052 | + } |
|
| 2053 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2055 | 2054 | |
| 2056 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2055 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2057 | 2056 | |
| 2058 | - return $url; |
|
| 2057 | + return $url; |
|
| 2059 | 2058 | } |
| 2060 | 2059 | |
| 2061 | 2060 | |
@@ -2090,26 +2089,26 @@ discard block |
||
| 2090 | 2089 | * @return string URL |
| 2091 | 2090 | **/ |
| 2092 | 2091 | function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
| 2093 | - if (!$rel) { |
|
| 2094 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2095 | - } else { |
|
| 2096 | - if (!is_string($rel)) { |
|
| 2097 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2098 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2099 | - } |
|
| 2100 | - } |
|
| 2101 | - |
|
| 2102 | - list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2103 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2104 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2105 | - } elseif ($args) { |
|
| 2106 | - $args = "?$args"; |
|
| 2107 | - } |
|
| 2108 | - if ($ancre) { |
|
| 2109 | - $args .= "#$ancre"; |
|
| 2110 | - } |
|
| 2111 | - |
|
| 2112 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2092 | + if (!$rel) { |
|
| 2093 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2094 | + } else { |
|
| 2095 | + if (!is_string($rel)) { |
|
| 2096 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2097 | + ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2098 | + } |
|
| 2099 | + } |
|
| 2100 | + |
|
| 2101 | + list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2102 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2103 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2104 | + } elseif ($args) { |
|
| 2105 | + $args = "?$args"; |
|
| 2106 | + } |
|
| 2107 | + if ($ancre) { |
|
| 2108 | + $args .= "#$ancre"; |
|
| 2109 | + } |
|
| 2110 | + |
|
| 2111 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2113 | 2112 | } |
| 2114 | 2113 | |
| 2115 | 2114 | // |
@@ -2131,12 +2130,12 @@ discard block |
||
| 2131 | 2130 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2132 | 2131 | **/ |
| 2133 | 2132 | function get_spip_script($default = '') { |
| 2134 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2135 | - if (_SPIP_SCRIPT) { |
|
| 2136 | - return _SPIP_SCRIPT; |
|
| 2137 | - } else { |
|
| 2138 | - return $default; |
|
| 2139 | - } |
|
| 2133 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2134 | + if (_SPIP_SCRIPT) { |
|
| 2135 | + return _SPIP_SCRIPT; |
|
| 2136 | + } else { |
|
| 2137 | + return $default; |
|
| 2138 | + } |
|
| 2140 | 2139 | } |
| 2141 | 2140 | |
| 2142 | 2141 | /** |
@@ -2165,39 +2164,39 @@ discard block |
||
| 2165 | 2164 | * @return string URL |
| 2166 | 2165 | **/ |
| 2167 | 2166 | function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') { |
| 2168 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2169 | - // standardiser vers la nouvelle API |
|
| 2170 | - |
|
| 2171 | - if (!$action) { |
|
| 2172 | - $action = get_spip_script(); |
|
| 2173 | - } |
|
| 2174 | - if ($script) { |
|
| 2175 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2176 | - } |
|
| 2177 | - |
|
| 2178 | - if ($args) { |
|
| 2179 | - if (is_array($args)) { |
|
| 2180 | - $r = ''; |
|
| 2181 | - foreach ($args as $k => $v) { |
|
| 2182 | - $r .= '&' . $k . '=' . $v; |
|
| 2183 | - } |
|
| 2184 | - $args = substr($r, 1); |
|
| 2185 | - } |
|
| 2186 | - $action .= |
|
| 2187 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2188 | - } |
|
| 2189 | - if (!$no_entities) { |
|
| 2190 | - $action = quote_amp($action); |
|
| 2191 | - } |
|
| 2192 | - |
|
| 2193 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2194 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2167 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2168 | + // standardiser vers la nouvelle API |
|
| 2169 | + |
|
| 2170 | + if (!$action) { |
|
| 2171 | + $action = get_spip_script(); |
|
| 2172 | + } |
|
| 2173 | + if ($script) { |
|
| 2174 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2175 | + } |
|
| 2176 | + |
|
| 2177 | + if ($args) { |
|
| 2178 | + if (is_array($args)) { |
|
| 2179 | + $r = ''; |
|
| 2180 | + foreach ($args as $k => $v) { |
|
| 2181 | + $r .= '&' . $k . '=' . $v; |
|
| 2182 | + } |
|
| 2183 | + $args = substr($r, 1); |
|
| 2184 | + } |
|
| 2185 | + $action .= |
|
| 2186 | + (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2187 | + } |
|
| 2188 | + if (!$no_entities) { |
|
| 2189 | + $action = quote_amp($action); |
|
| 2190 | + } |
|
| 2191 | + |
|
| 2192 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2193 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2195 | 2194 | } |
| 2196 | 2195 | |
| 2197 | 2196 | // https://code.spip.net/@generer_url_prive |
| 2198 | 2197 | function generer_url_prive($script, $args = "", $no_entities = false) { |
| 2199 | 2198 | |
| 2200 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2199 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2201 | 2200 | } |
| 2202 | 2201 | |
| 2203 | 2202 | // Pour les formulaires en methode POST, |
@@ -2222,19 +2221,19 @@ discard block |
||
| 2222 | 2221 | **/ |
| 2223 | 2222 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2224 | 2223 | |
| 2225 | - $script1 = explode('&', $script); |
|
| 2226 | - $script1 = reset($script1); |
|
| 2224 | + $script1 = explode('&', $script); |
|
| 2225 | + $script1 = reset($script1); |
|
| 2227 | 2226 | |
| 2228 | - return "<form action='" |
|
| 2229 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2230 | - . "' " |
|
| 2231 | - . ($atts ? $atts : " method='post'") |
|
| 2232 | - . "><div>\n" |
|
| 2233 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2234 | - . $corps |
|
| 2235 | - . (!$submit ? '' : |
|
| 2236 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2237 | - . "</div></form>\n"; |
|
| 2227 | + return "<form action='" |
|
| 2228 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2229 | + . "' " |
|
| 2230 | + . ($atts ? $atts : " method='post'") |
|
| 2231 | + . "><div>\n" |
|
| 2232 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2233 | + . $corps |
|
| 2234 | + . (!$submit ? '' : |
|
| 2235 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2236 | + . "</div></form>\n"; |
|
| 2238 | 2237 | } |
| 2239 | 2238 | |
| 2240 | 2239 | /** |
@@ -2251,22 +2250,22 @@ discard block |
||
| 2251 | 2250 | * @return string |
| 2252 | 2251 | */ |
| 2253 | 2252 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2254 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2255 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2256 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2257 | - $h = (_DIR_RACINE and !$public) |
|
| 2258 | - ? generer_url_ecrire(_request('exec')) |
|
| 2259 | - : generer_url_public(); |
|
| 2253 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2254 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2255 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2256 | + $h = (_DIR_RACINE and !$public) |
|
| 2257 | + ? generer_url_ecrire(_request('exec')) |
|
| 2258 | + : generer_url_public(); |
|
| 2260 | 2259 | |
| 2261 | - return "\n<form action='" . |
|
| 2262 | - $h . |
|
| 2263 | - "'" . |
|
| 2264 | - $atts . |
|
| 2265 | - ">\n" . |
|
| 2266 | - "<div>" . |
|
| 2267 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2268 | - $corps . |
|
| 2269 | - "</div></form>"; |
|
| 2260 | + return "\n<form action='" . |
|
| 2261 | + $h . |
|
| 2262 | + "'" . |
|
| 2263 | + $atts . |
|
| 2264 | + ">\n" . |
|
| 2265 | + "<div>" . |
|
| 2266 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2267 | + $corps . |
|
| 2268 | + "</div></form>"; |
|
| 2270 | 2269 | } |
| 2271 | 2270 | |
| 2272 | 2271 | /** |
@@ -2285,22 +2284,22 @@ discard block |
||
| 2285 | 2284 | * URL |
| 2286 | 2285 | */ |
| 2287 | 2286 | function generer_url_action($script, $args = "", $no_entities = false, $public = false) { |
| 2288 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2289 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2290 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2291 | - $url = (_DIR_RACINE and !$public) |
|
| 2292 | - ? generer_url_ecrire(_request('exec')) |
|
| 2293 | - : generer_url_public('', '', false, false); |
|
| 2294 | - $url = parametre_url($url, 'action', $script); |
|
| 2295 | - if ($args) { |
|
| 2296 | - $url .= quote_amp('&' . $args); |
|
| 2297 | - } |
|
| 2287 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2288 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2289 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2290 | + $url = (_DIR_RACINE and !$public) |
|
| 2291 | + ? generer_url_ecrire(_request('exec')) |
|
| 2292 | + : generer_url_public('', '', false, false); |
|
| 2293 | + $url = parametre_url($url, 'action', $script); |
|
| 2294 | + if ($args) { |
|
| 2295 | + $url .= quote_amp('&' . $args); |
|
| 2296 | + } |
|
| 2298 | 2297 | |
| 2299 | - if ($no_entities) { |
|
| 2300 | - $url = str_replace('&', '&', $url); |
|
| 2301 | - } |
|
| 2298 | + if ($no_entities) { |
|
| 2299 | + $url = str_replace('&', '&', $url); |
|
| 2300 | + } |
|
| 2302 | 2301 | |
| 2303 | - return $url; |
|
| 2302 | + return $url; |
|
| 2304 | 2303 | } |
| 2305 | 2304 | |
| 2306 | 2305 | |
@@ -2313,8 +2312,8 @@ discard block |
||
| 2313 | 2312 | * @param string $ta Répertoire temporaire accessible |
| 2314 | 2313 | */ |
| 2315 | 2314 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2316 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2317 | - spip_initialisation_suite(); |
|
| 2315 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2316 | + spip_initialisation_suite(); |
|
| 2318 | 2317 | } |
| 2319 | 2318 | |
| 2320 | 2319 | /** |
@@ -2334,315 +2333,315 @@ discard block |
||
| 2334 | 2333 | * @param string $ta Répertoire temporaire accessible |
| 2335 | 2334 | */ |
| 2336 | 2335 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2337 | - static $too_late = 0; |
|
| 2338 | - if ($too_late++) { |
|
| 2339 | - return; |
|
| 2340 | - } |
|
| 2341 | - |
|
| 2342 | - // Declaration des repertoires |
|
| 2343 | - |
|
| 2344 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2345 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2346 | - define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2347 | - } |
|
| 2348 | - |
|
| 2349 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2350 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2351 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2352 | - } |
|
| 2353 | - |
|
| 2354 | - // le nom du repertoire des librairies |
|
| 2355 | - if (!defined('_DIR_LIB')) { |
|
| 2356 | - define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2357 | - } |
|
| 2358 | - |
|
| 2359 | - if (!defined('_DIR_IMG')) { |
|
| 2360 | - define('_DIR_IMG', $pa); |
|
| 2361 | - } |
|
| 2362 | - if (!defined('_DIR_LOGOS')) { |
|
| 2363 | - define('_DIR_LOGOS', $pa); |
|
| 2364 | - } |
|
| 2365 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2366 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2367 | - } |
|
| 2368 | - |
|
| 2369 | - if (!defined('_DIR_DUMP')) { |
|
| 2370 | - define('_DIR_DUMP', $ti . "dump/"); |
|
| 2371 | - } |
|
| 2372 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2373 | - define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2374 | - } |
|
| 2375 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2376 | - define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2377 | - } |
|
| 2378 | - if (!defined('_DIR_CACHE')) { |
|
| 2379 | - define('_DIR_CACHE', $ti . "cache/"); |
|
| 2380 | - } |
|
| 2381 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2382 | - define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2383 | - } |
|
| 2384 | - if (!defined('_DIR_SKELS')) { |
|
| 2385 | - define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2386 | - } |
|
| 2387 | - if (!defined('_DIR_AIDE')) { |
|
| 2388 | - define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2389 | - } |
|
| 2390 | - if (!defined('_DIR_TMP')) { |
|
| 2391 | - define('_DIR_TMP', $ti); |
|
| 2392 | - } |
|
| 2393 | - |
|
| 2394 | - if (!defined('_DIR_VAR')) { |
|
| 2395 | - define('_DIR_VAR', $ta); |
|
| 2396 | - } |
|
| 2397 | - |
|
| 2398 | - if (!defined('_DIR_ETC')) { |
|
| 2399 | - define('_DIR_ETC', $pi); |
|
| 2400 | - } |
|
| 2401 | - if (!defined('_DIR_CONNECT')) { |
|
| 2402 | - define('_DIR_CONNECT', $pi); |
|
| 2403 | - } |
|
| 2404 | - if (!defined('_DIR_CHMOD')) { |
|
| 2405 | - define('_DIR_CHMOD', $pi); |
|
| 2406 | - } |
|
| 2407 | - |
|
| 2408 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 2409 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2410 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2411 | - { |
|
| 2412 | - $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2413 | - } |
|
| 2414 | - |
|
| 2415 | - // Declaration des fichiers |
|
| 2416 | - |
|
| 2417 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2418 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2419 | - } |
|
| 2420 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2421 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2422 | - } |
|
| 2423 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2424 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2425 | - } |
|
| 2426 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2427 | - define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2428 | - } |
|
| 2429 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2430 | - define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2431 | - } |
|
| 2432 | - |
|
| 2433 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2434 | - if (!defined('_FILE_META')) { |
|
| 2435 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2436 | - } |
|
| 2437 | - if (!defined('_DIR_LOG')) { |
|
| 2438 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2439 | - } |
|
| 2440 | - if (!defined('_FILE_LOG')) { |
|
| 2441 | - define('_FILE_LOG', 'spip'); |
|
| 2442 | - } |
|
| 2443 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2444 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2445 | - } |
|
| 2446 | - |
|
| 2447 | - // Le fichier de connexion a la base de donnees |
|
| 2448 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2449 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2450 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2451 | - } |
|
| 2452 | - if (!defined('_FILE_CONNECT')) { |
|
| 2453 | - define('_FILE_CONNECT', |
|
| 2454 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2455 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2456 | - : false))); |
|
| 2457 | - } |
|
| 2458 | - |
|
| 2459 | - // Le fichier de reglages des droits |
|
| 2460 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2461 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2462 | - } |
|
| 2463 | - if (!defined('_FILE_CHMOD')) { |
|
| 2464 | - define('_FILE_CHMOD', |
|
| 2465 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2466 | - : false)); |
|
| 2467 | - } |
|
| 2468 | - |
|
| 2469 | - if (!defined('_FILE_LDAP')) { |
|
| 2470 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2471 | - } |
|
| 2472 | - |
|
| 2473 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2474 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2475 | - } |
|
| 2476 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2477 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2478 | - } |
|
| 2479 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2480 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2481 | - } |
|
| 2482 | - |
|
| 2483 | - // Definition des droits d'acces en ecriture |
|
| 2484 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2485 | - include_once _FILE_CHMOD; |
|
| 2486 | - } |
|
| 2487 | - |
|
| 2488 | - // Se mefier des fichiers mal remplis! |
|
| 2489 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2490 | - define('_SPIP_CHMOD', 0777); |
|
| 2491 | - } |
|
| 2492 | - |
|
| 2493 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2494 | - /** Le charset par défaut lors de l'installation */ |
|
| 2495 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2496 | - } |
|
| 2497 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2498 | - define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2499 | - } |
|
| 2500 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2501 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2502 | - } |
|
| 2503 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2504 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2505 | - } |
|
| 2506 | - |
|
| 2507 | - // La taille des Log |
|
| 2508 | - if (!defined('_MAX_LOG')) { |
|
| 2509 | - define('_MAX_LOG', 100); |
|
| 2510 | - } |
|
| 2511 | - |
|
| 2512 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2513 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2514 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2515 | - if (!defined('_OS_SERVEUR')) { |
|
| 2516 | - define('_OS_SERVEUR', 'windows'); |
|
| 2517 | - } |
|
| 2518 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2519 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2520 | - } // utiliser le flock php |
|
| 2521 | - } else { |
|
| 2522 | - if (!defined('_OS_SERVEUR')) { |
|
| 2523 | - define('_OS_SERVEUR', ''); |
|
| 2524 | - } |
|
| 2525 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2526 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2527 | - } // utiliser le flock php |
|
| 2528 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2529 | - } |
|
| 2530 | - |
|
| 2531 | - // Langue par defaut |
|
| 2532 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2533 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2534 | - } |
|
| 2535 | - |
|
| 2536 | - // |
|
| 2537 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2538 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2539 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2540 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2541 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2542 | - |
|
| 2543 | - // charger tout de suite le path et son cache |
|
| 2544 | - load_path_cache(); |
|
| 2545 | - |
|
| 2546 | - // *********** traiter les variables ************ |
|
| 2547 | - |
|
| 2548 | - // |
|
| 2549 | - // Securite |
|
| 2550 | - // |
|
| 2551 | - |
|
| 2552 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2553 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2554 | - die(); |
|
| 2555 | - } |
|
| 2556 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2557 | - spip_desinfecte($_GET); |
|
| 2558 | - spip_desinfecte($_POST); |
|
| 2559 | - spip_desinfecte($_COOKIE); |
|
| 2560 | - spip_desinfecte($_REQUEST); |
|
| 2561 | - |
|
| 2562 | - // appliquer le cookie_prefix |
|
| 2563 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2564 | - include_spip('inc/cookie'); |
|
| 2565 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2566 | - } |
|
| 2567 | - |
|
| 2568 | - // |
|
| 2569 | - // Capacites php (en fonction de la version) |
|
| 2570 | - // |
|
| 2571 | - $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2572 | - && function_exists("ini_get") |
|
| 2573 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2574 | - $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2575 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2576 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2577 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2578 | - |
|
| 2579 | - |
|
| 2580 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2581 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2582 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2583 | - } else { |
|
| 2584 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2585 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 2586 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2587 | - ) { |
|
| 2588 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2589 | - } |
|
| 2590 | - } |
|
| 2591 | - |
|
| 2592 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2593 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2594 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2595 | - } |
|
| 2596 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2597 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2598 | - } |
|
| 2599 | - |
|
| 2600 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2601 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2602 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2603 | - $inc_meta(); |
|
| 2604 | - |
|
| 2605 | - // nombre de repertoires depuis la racine |
|
| 2606 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2607 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2608 | - // le calcul est faux) |
|
| 2609 | - if (!_DIR_RESTREINT) { |
|
| 2610 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2611 | - } else { |
|
| 2612 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2613 | - $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2614 | - if (!$uri_ref |
|
| 2615 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2616 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2617 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2618 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2619 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2620 | - ) { |
|
| 2621 | - |
|
| 2622 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2623 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2624 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2625 | - } else { |
|
| 2626 | - $uri_ref = ""; |
|
| 2627 | - } |
|
| 2628 | - } |
|
| 2629 | - if (!$uri or !$uri_ref) { |
|
| 2630 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2631 | - } else { |
|
| 2632 | - $GLOBALS['profondeur_url'] = max(0, |
|
| 2633 | - substr_count($uri[0], '/') |
|
| 2634 | - - substr_count($uri_ref, '/')); |
|
| 2635 | - } |
|
| 2636 | - } |
|
| 2637 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2638 | - if (_FILE_CONNECT) { |
|
| 2639 | - if (verifier_visiteur() == '0minirezo' |
|
| 2640 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2641 | - and !isset($_COOKIE['spip_admin']) |
|
| 2642 | - ) { |
|
| 2643 | - clear_path_cache(); |
|
| 2644 | - } |
|
| 2645 | - } |
|
| 2336 | + static $too_late = 0; |
|
| 2337 | + if ($too_late++) { |
|
| 2338 | + return; |
|
| 2339 | + } |
|
| 2340 | + |
|
| 2341 | + // Declaration des repertoires |
|
| 2342 | + |
|
| 2343 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2344 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2345 | + define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2346 | + } |
|
| 2347 | + |
|
| 2348 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2349 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2350 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2351 | + } |
|
| 2352 | + |
|
| 2353 | + // le nom du repertoire des librairies |
|
| 2354 | + if (!defined('_DIR_LIB')) { |
|
| 2355 | + define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2356 | + } |
|
| 2357 | + |
|
| 2358 | + if (!defined('_DIR_IMG')) { |
|
| 2359 | + define('_DIR_IMG', $pa); |
|
| 2360 | + } |
|
| 2361 | + if (!defined('_DIR_LOGOS')) { |
|
| 2362 | + define('_DIR_LOGOS', $pa); |
|
| 2363 | + } |
|
| 2364 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2365 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2366 | + } |
|
| 2367 | + |
|
| 2368 | + if (!defined('_DIR_DUMP')) { |
|
| 2369 | + define('_DIR_DUMP', $ti . "dump/"); |
|
| 2370 | + } |
|
| 2371 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2372 | + define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2373 | + } |
|
| 2374 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2375 | + define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2376 | + } |
|
| 2377 | + if (!defined('_DIR_CACHE')) { |
|
| 2378 | + define('_DIR_CACHE', $ti . "cache/"); |
|
| 2379 | + } |
|
| 2380 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2381 | + define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2382 | + } |
|
| 2383 | + if (!defined('_DIR_SKELS')) { |
|
| 2384 | + define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2385 | + } |
|
| 2386 | + if (!defined('_DIR_AIDE')) { |
|
| 2387 | + define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2388 | + } |
|
| 2389 | + if (!defined('_DIR_TMP')) { |
|
| 2390 | + define('_DIR_TMP', $ti); |
|
| 2391 | + } |
|
| 2392 | + |
|
| 2393 | + if (!defined('_DIR_VAR')) { |
|
| 2394 | + define('_DIR_VAR', $ta); |
|
| 2395 | + } |
|
| 2396 | + |
|
| 2397 | + if (!defined('_DIR_ETC')) { |
|
| 2398 | + define('_DIR_ETC', $pi); |
|
| 2399 | + } |
|
| 2400 | + if (!defined('_DIR_CONNECT')) { |
|
| 2401 | + define('_DIR_CONNECT', $pi); |
|
| 2402 | + } |
|
| 2403 | + if (!defined('_DIR_CHMOD')) { |
|
| 2404 | + define('_DIR_CHMOD', $pi); |
|
| 2405 | + } |
|
| 2406 | + |
|
| 2407 | + if (!isset($GLOBALS['test_dirs'])) |
|
| 2408 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2409 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2410 | + { |
|
| 2411 | + $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2412 | + } |
|
| 2413 | + |
|
| 2414 | + // Declaration des fichiers |
|
| 2415 | + |
|
| 2416 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2417 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2418 | + } |
|
| 2419 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2420 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2421 | + } |
|
| 2422 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2423 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2424 | + } |
|
| 2425 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2426 | + define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2427 | + } |
|
| 2428 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2429 | + define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2430 | + } |
|
| 2431 | + |
|
| 2432 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2433 | + if (!defined('_FILE_META')) { |
|
| 2434 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2435 | + } |
|
| 2436 | + if (!defined('_DIR_LOG')) { |
|
| 2437 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2438 | + } |
|
| 2439 | + if (!defined('_FILE_LOG')) { |
|
| 2440 | + define('_FILE_LOG', 'spip'); |
|
| 2441 | + } |
|
| 2442 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2443 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2444 | + } |
|
| 2445 | + |
|
| 2446 | + // Le fichier de connexion a la base de donnees |
|
| 2447 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2448 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2449 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2450 | + } |
|
| 2451 | + if (!defined('_FILE_CONNECT')) { |
|
| 2452 | + define('_FILE_CONNECT', |
|
| 2453 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2454 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2455 | + : false))); |
|
| 2456 | + } |
|
| 2457 | + |
|
| 2458 | + // Le fichier de reglages des droits |
|
| 2459 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2460 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2461 | + } |
|
| 2462 | + if (!defined('_FILE_CHMOD')) { |
|
| 2463 | + define('_FILE_CHMOD', |
|
| 2464 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2465 | + : false)); |
|
| 2466 | + } |
|
| 2467 | + |
|
| 2468 | + if (!defined('_FILE_LDAP')) { |
|
| 2469 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2470 | + } |
|
| 2471 | + |
|
| 2472 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2473 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2474 | + } |
|
| 2475 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2476 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2477 | + } |
|
| 2478 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2479 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2480 | + } |
|
| 2481 | + |
|
| 2482 | + // Definition des droits d'acces en ecriture |
|
| 2483 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2484 | + include_once _FILE_CHMOD; |
|
| 2485 | + } |
|
| 2486 | + |
|
| 2487 | + // Se mefier des fichiers mal remplis! |
|
| 2488 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2489 | + define('_SPIP_CHMOD', 0777); |
|
| 2490 | + } |
|
| 2491 | + |
|
| 2492 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2493 | + /** Le charset par défaut lors de l'installation */ |
|
| 2494 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2495 | + } |
|
| 2496 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2497 | + define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2498 | + } |
|
| 2499 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2500 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2501 | + } |
|
| 2502 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2503 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2504 | + } |
|
| 2505 | + |
|
| 2506 | + // La taille des Log |
|
| 2507 | + if (!defined('_MAX_LOG')) { |
|
| 2508 | + define('_MAX_LOG', 100); |
|
| 2509 | + } |
|
| 2510 | + |
|
| 2511 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2512 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2513 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2514 | + if (!defined('_OS_SERVEUR')) { |
|
| 2515 | + define('_OS_SERVEUR', 'windows'); |
|
| 2516 | + } |
|
| 2517 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2518 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2519 | + } // utiliser le flock php |
|
| 2520 | + } else { |
|
| 2521 | + if (!defined('_OS_SERVEUR')) { |
|
| 2522 | + define('_OS_SERVEUR', ''); |
|
| 2523 | + } |
|
| 2524 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2525 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2526 | + } // utiliser le flock php |
|
| 2527 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2528 | + } |
|
| 2529 | + |
|
| 2530 | + // Langue par defaut |
|
| 2531 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2532 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2533 | + } |
|
| 2534 | + |
|
| 2535 | + // |
|
| 2536 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2537 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2538 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2539 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2540 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2541 | + |
|
| 2542 | + // charger tout de suite le path et son cache |
|
| 2543 | + load_path_cache(); |
|
| 2544 | + |
|
| 2545 | + // *********** traiter les variables ************ |
|
| 2546 | + |
|
| 2547 | + // |
|
| 2548 | + // Securite |
|
| 2549 | + // |
|
| 2550 | + |
|
| 2551 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2552 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2553 | + die(); |
|
| 2554 | + } |
|
| 2555 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2556 | + spip_desinfecte($_GET); |
|
| 2557 | + spip_desinfecte($_POST); |
|
| 2558 | + spip_desinfecte($_COOKIE); |
|
| 2559 | + spip_desinfecte($_REQUEST); |
|
| 2560 | + |
|
| 2561 | + // appliquer le cookie_prefix |
|
| 2562 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2563 | + include_spip('inc/cookie'); |
|
| 2564 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2565 | + } |
|
| 2566 | + |
|
| 2567 | + // |
|
| 2568 | + // Capacites php (en fonction de la version) |
|
| 2569 | + // |
|
| 2570 | + $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2571 | + && function_exists("ini_get") |
|
| 2572 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2573 | + $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2574 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2575 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2576 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2577 | + |
|
| 2578 | + |
|
| 2579 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2580 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2581 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2582 | + } else { |
|
| 2583 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2584 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 2585 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2586 | + ) { |
|
| 2587 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2588 | + } |
|
| 2589 | + } |
|
| 2590 | + |
|
| 2591 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2592 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2593 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2594 | + } |
|
| 2595 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2596 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2597 | + } |
|
| 2598 | + |
|
| 2599 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2600 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2601 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2602 | + $inc_meta(); |
|
| 2603 | + |
|
| 2604 | + // nombre de repertoires depuis la racine |
|
| 2605 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2606 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2607 | + // le calcul est faux) |
|
| 2608 | + if (!_DIR_RESTREINT) { |
|
| 2609 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2610 | + } else { |
|
| 2611 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2612 | + $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2613 | + if (!$uri_ref |
|
| 2614 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2615 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2616 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2617 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2618 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2619 | + ) { |
|
| 2620 | + |
|
| 2621 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2622 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2623 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2624 | + } else { |
|
| 2625 | + $uri_ref = ""; |
|
| 2626 | + } |
|
| 2627 | + } |
|
| 2628 | + if (!$uri or !$uri_ref) { |
|
| 2629 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2630 | + } else { |
|
| 2631 | + $GLOBALS['profondeur_url'] = max(0, |
|
| 2632 | + substr_count($uri[0], '/') |
|
| 2633 | + - substr_count($uri_ref, '/')); |
|
| 2634 | + } |
|
| 2635 | + } |
|
| 2636 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2637 | + if (_FILE_CONNECT) { |
|
| 2638 | + if (verifier_visiteur() == '0minirezo' |
|
| 2639 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2640 | + and !isset($_COOKIE['spip_admin']) |
|
| 2641 | + ) { |
|
| 2642 | + clear_path_cache(); |
|
| 2643 | + } |
|
| 2644 | + } |
|
| 2646 | 2645 | |
| 2647 | 2646 | } |
| 2648 | 2647 | |
@@ -2652,181 +2651,181 @@ discard block |
||
| 2652 | 2651 | * |
| 2653 | 2652 | */ |
| 2654 | 2653 | function spip_initialisation_suite() { |
| 2655 | - static $too_late = 0; |
|
| 2656 | - if ($too_late++) { |
|
| 2657 | - return; |
|
| 2658 | - } |
|
| 2659 | - |
|
| 2660 | - // taille mini des login |
|
| 2661 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2662 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2663 | - } |
|
| 2664 | - |
|
| 2665 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2666 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2667 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2668 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2669 | - |
|
| 2670 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2671 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2672 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2673 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2674 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2675 | - |
|
| 2676 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2677 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2678 | - } |
|
| 2679 | - |
|
| 2680 | - |
|
| 2681 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2682 | - if (!defined('_IMG_QUALITE')) { |
|
| 2683 | - define('_IMG_QUALITE', 85); |
|
| 2684 | - } # valeur par defaut |
|
| 2685 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2686 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2687 | - } # surcharge pour la lib GD |
|
| 2688 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2689 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2690 | - } # surcharge pour imagick en ligne de commande |
|
| 2691 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2692 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2693 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2694 | - } # surcharge pour imagick en PHP |
|
| 2695 | - |
|
| 2696 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2697 | - define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2698 | - } // poids en octet |
|
| 2699 | - |
|
| 2700 | - // qq chaines standard |
|
| 2701 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2702 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2703 | - } |
|
| 2704 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2705 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2706 | - } |
|
| 2707 | - if (!defined('_SPIP_DUMP')) { |
|
| 2708 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2709 | - } |
|
| 2710 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2711 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2712 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2713 | - } |
|
| 2714 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2715 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2716 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2717 | - } |
|
| 2718 | - |
|
| 2719 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2720 | - /** |
|
| 2721 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2722 | - * @var int Nombre de caractères */ |
|
| 2723 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2724 | - } |
|
| 2725 | - |
|
| 2726 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2727 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2728 | - } |
|
| 2729 | - |
|
| 2730 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2731 | - /** Définit le doctype de l’espace privé */ |
|
| 2732 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2733 | - } |
|
| 2734 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2735 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2736 | - define('_DOCTYPE_AIDE', |
|
| 2737 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2738 | - } |
|
| 2739 | - |
|
| 2740 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2741 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2742 | - * le script de l'espace public, alias index.php */ |
|
| 2743 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2744 | - } |
|
| 2745 | - if (!defined('_SPIP_PAGE')) { |
|
| 2746 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2747 | - define('_SPIP_PAGE', 'page'); |
|
| 2748 | - } |
|
| 2749 | - |
|
| 2750 | - // le script de l'espace prive |
|
| 2751 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2752 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2753 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2754 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2755 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2756 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2757 | - } else { |
|
| 2758 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2759 | - } |
|
| 2760 | - } |
|
| 2761 | - |
|
| 2762 | - |
|
| 2763 | - if (!defined('_SPIP_AJAX')) { |
|
| 2764 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2765 | - ? 1 |
|
| 2766 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2767 | - } |
|
| 2768 | - |
|
| 2769 | - // La requete est-elle en ajax ? |
|
| 2770 | - if (!defined('_AJAX')) { |
|
| 2771 | - define('_AJAX', |
|
| 2772 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2773 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2774 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2775 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2776 | - ) |
|
| 2777 | - 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 |
|
| 2778 | - ); |
|
| 2779 | - } |
|
| 2780 | - |
|
| 2781 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2782 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2783 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2784 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2785 | - define('_IMG_GD_MAX_PIXELS', |
|
| 2786 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2787 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2788 | - : 0); |
|
| 2789 | - } |
|
| 2790 | - |
|
| 2791 | - if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2792 | - define('_MEMORY_LIMIT_MIN', 16); |
|
| 2793 | - } // en Mo |
|
| 2794 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2795 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2796 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2797 | - if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2798 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2799 | - $unit = strtolower(substr($memory, -1)); |
|
| 2800 | - $memory = substr($memory, 0, -1); |
|
| 2801 | - switch ($unit) { |
|
| 2802 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2803 | - case 'g': |
|
| 2804 | - $memory *= 1024; |
|
| 2805 | - case 'm': |
|
| 2806 | - $memory *= 1024; |
|
| 2807 | - case 'k': |
|
| 2808 | - $memory *= 1024; |
|
| 2809 | - } |
|
| 2810 | - if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2811 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2812 | - if (trim(ini_get('memory_limit')) != $m) { |
|
| 2813 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2814 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2815 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2816 | - } |
|
| 2817 | - } |
|
| 2818 | - } else { |
|
| 2819 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2820 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2821 | - } |
|
| 2822 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2823 | - } |
|
| 2824 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2825 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2826 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2827 | - } |
|
| 2828 | - |
|
| 2829 | - init_var_mode(); |
|
| 2654 | + static $too_late = 0; |
|
| 2655 | + if ($too_late++) { |
|
| 2656 | + return; |
|
| 2657 | + } |
|
| 2658 | + |
|
| 2659 | + // taille mini des login |
|
| 2660 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2661 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2662 | + } |
|
| 2663 | + |
|
| 2664 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2665 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2666 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2667 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2668 | + |
|
| 2669 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2670 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2671 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2672 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2673 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2674 | + |
|
| 2675 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2676 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2677 | + } |
|
| 2678 | + |
|
| 2679 | + |
|
| 2680 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2681 | + if (!defined('_IMG_QUALITE')) { |
|
| 2682 | + define('_IMG_QUALITE', 85); |
|
| 2683 | + } # valeur par defaut |
|
| 2684 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2685 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2686 | + } # surcharge pour la lib GD |
|
| 2687 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2688 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2689 | + } # surcharge pour imagick en ligne de commande |
|
| 2690 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2691 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2692 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2693 | + } # surcharge pour imagick en PHP |
|
| 2694 | + |
|
| 2695 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2696 | + define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2697 | + } // poids en octet |
|
| 2698 | + |
|
| 2699 | + // qq chaines standard |
|
| 2700 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2701 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2702 | + } |
|
| 2703 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2704 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2705 | + } |
|
| 2706 | + if (!defined('_SPIP_DUMP')) { |
|
| 2707 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2708 | + } |
|
| 2709 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2710 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2711 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2712 | + } |
|
| 2713 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2714 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2715 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2716 | + } |
|
| 2717 | + |
|
| 2718 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2719 | + /** |
|
| 2720 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2721 | + * @var int Nombre de caractères */ |
|
| 2722 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2723 | + } |
|
| 2724 | + |
|
| 2725 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2726 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2727 | + } |
|
| 2728 | + |
|
| 2729 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2730 | + /** Définit le doctype de l’espace privé */ |
|
| 2731 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2732 | + } |
|
| 2733 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2734 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2735 | + define('_DOCTYPE_AIDE', |
|
| 2736 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2737 | + } |
|
| 2738 | + |
|
| 2739 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2740 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2741 | + * le script de l'espace public, alias index.php */ |
|
| 2742 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2743 | + } |
|
| 2744 | + if (!defined('_SPIP_PAGE')) { |
|
| 2745 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2746 | + define('_SPIP_PAGE', 'page'); |
|
| 2747 | + } |
|
| 2748 | + |
|
| 2749 | + // le script de l'espace prive |
|
| 2750 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2751 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2752 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2753 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2754 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2755 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2756 | + } else { |
|
| 2757 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2758 | + } |
|
| 2759 | + } |
|
| 2760 | + |
|
| 2761 | + |
|
| 2762 | + if (!defined('_SPIP_AJAX')) { |
|
| 2763 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2764 | + ? 1 |
|
| 2765 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2766 | + } |
|
| 2767 | + |
|
| 2768 | + // La requete est-elle en ajax ? |
|
| 2769 | + if (!defined('_AJAX')) { |
|
| 2770 | + define('_AJAX', |
|
| 2771 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2772 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2773 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2774 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2775 | + ) |
|
| 2776 | + 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 |
|
| 2777 | + ); |
|
| 2778 | + } |
|
| 2779 | + |
|
| 2780 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2781 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2782 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2783 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2784 | + define('_IMG_GD_MAX_PIXELS', |
|
| 2785 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2786 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2787 | + : 0); |
|
| 2788 | + } |
|
| 2789 | + |
|
| 2790 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2791 | + define('_MEMORY_LIMIT_MIN', 16); |
|
| 2792 | + } // en Mo |
|
| 2793 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2794 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2795 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2796 | + if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2797 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2798 | + $unit = strtolower(substr($memory, -1)); |
|
| 2799 | + $memory = substr($memory, 0, -1); |
|
| 2800 | + switch ($unit) { |
|
| 2801 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2802 | + case 'g': |
|
| 2803 | + $memory *= 1024; |
|
| 2804 | + case 'm': |
|
| 2805 | + $memory *= 1024; |
|
| 2806 | + case 'k': |
|
| 2807 | + $memory *= 1024; |
|
| 2808 | + } |
|
| 2809 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2810 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2811 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 2812 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2813 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2814 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2815 | + } |
|
| 2816 | + } |
|
| 2817 | + } else { |
|
| 2818 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2819 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2820 | + } |
|
| 2821 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2822 | + } |
|
| 2823 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2824 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2825 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2826 | + } |
|
| 2827 | + |
|
| 2828 | + init_var_mode(); |
|
| 2830 | 2829 | } |
| 2831 | 2830 | |
| 2832 | 2831 | /** |
@@ -2860,133 +2859,133 @@ discard block |
||
| 2860 | 2859 | * ` var_mode` (calcul ou recalcul). |
| 2861 | 2860 | */ |
| 2862 | 2861 | function init_var_mode() { |
| 2863 | - static $done = false; |
|
| 2864 | - if (!$done) { |
|
| 2865 | - |
|
| 2866 | - if (isset($_GET['var_mode'])) { |
|
| 2867 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 2868 | - // tout le monde peut calcul/recalcul |
|
| 2869 | - if (!defined('_VAR_MODE')) { |
|
| 2870 | - if (in_array('recalcul', $var_mode)) { |
|
| 2871 | - define('_VAR_MODE', 'recalcul'); |
|
| 2872 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 2873 | - define('_VAR_MODE', 'calcul'); |
|
| 2874 | - } |
|
| 2875 | - } |
|
| 2876 | - $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2877 | - if ($var_mode) { |
|
| 2878 | - include_spip('inc/autoriser'); |
|
| 2879 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2880 | - if (autoriser( |
|
| 2881 | - ($_GET['var_mode'] == 'preview') |
|
| 2882 | - ? 'previsualiser' |
|
| 2883 | - : 'debug' |
|
| 2884 | - )) { |
|
| 2885 | - if (in_array('traduction', $var_mode)) { |
|
| 2886 | - // forcer le calcul pour passer dans traduire |
|
| 2887 | - if (!defined('_VAR_MODE')) { |
|
| 2888 | - define('_VAR_MODE', 'calcul'); |
|
| 2889 | - } |
|
| 2890 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2891 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2892 | - define('_VAR_NOCACHE', true); |
|
| 2893 | - } |
|
| 2894 | - $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2895 | - } |
|
| 2896 | - if (in_array('preview', $var_mode)) { |
|
| 2897 | - // basculer sur les criteres de preview dans les boucles |
|
| 2898 | - if (!defined('_VAR_PREVIEW')) { |
|
| 2899 | - define('_VAR_PREVIEW', true); |
|
| 2900 | - } |
|
| 2901 | - // forcer le calcul |
|
| 2902 | - if (!defined('_VAR_MODE')) { |
|
| 2903 | - define('_VAR_MODE', 'calcul'); |
|
| 2904 | - } |
|
| 2905 | - // et ne pas enregistrer de cache |
|
| 2906 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2907 | - define('_VAR_NOCACHE', true); |
|
| 2908 | - } |
|
| 2909 | - $var_mode = array_diff($var_mode, array('preview')); |
|
| 2910 | - } |
|
| 2911 | - if (in_array('inclure', $var_mode)) { |
|
| 2912 | - // forcer le compilo et ignorer les caches existants |
|
| 2913 | - if (!defined('_VAR_MODE')) { |
|
| 2914 | - define('_VAR_MODE', 'calcul'); |
|
| 2915 | - } |
|
| 2916 | - if (!defined('_VAR_INCLURE')) { |
|
| 2917 | - define('_VAR_INCLURE', true); |
|
| 2918 | - } |
|
| 2919 | - // et ne pas enregistrer de cache |
|
| 2920 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2921 | - define('_VAR_NOCACHE', true); |
|
| 2922 | - } |
|
| 2923 | - $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2924 | - } |
|
| 2925 | - if (in_array('urls', $var_mode)) { |
|
| 2926 | - // forcer le compilo et ignorer les caches existants |
|
| 2927 | - if (!defined('_VAR_MODE')) { |
|
| 2928 | - define('_VAR_MODE', 'calcul'); |
|
| 2929 | - } |
|
| 2930 | - if (!defined('_VAR_URLS')) { |
|
| 2931 | - define('_VAR_URLS', true); |
|
| 2932 | - } |
|
| 2933 | - $var_mode = array_diff($var_mode, array('urls')); |
|
| 2934 | - } |
|
| 2935 | - if (in_array('images', $var_mode)) { |
|
| 2936 | - // forcer le compilo et ignorer les caches existants |
|
| 2937 | - if (!defined('_VAR_MODE')) { |
|
| 2938 | - define('_VAR_MODE', 'calcul'); |
|
| 2939 | - } |
|
| 2940 | - // indiquer qu'on doit recalculer les images |
|
| 2941 | - if (!defined('_VAR_IMAGES')) { |
|
| 2942 | - define('_VAR_IMAGES', true); |
|
| 2943 | - } |
|
| 2944 | - $var_mode = array_diff($var_mode, array('images')); |
|
| 2945 | - } |
|
| 2946 | - if (in_array('debug', $var_mode)) { |
|
| 2947 | - if (!defined('_VAR_MODE')) { |
|
| 2948 | - define('_VAR_MODE', 'debug'); |
|
| 2949 | - } |
|
| 2950 | - // et ne pas enregistrer de cache |
|
| 2951 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2952 | - define('_VAR_NOCACHE', true); |
|
| 2953 | - } |
|
| 2954 | - $var_mode = array_diff($var_mode, array('debug')); |
|
| 2955 | - } |
|
| 2956 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2957 | - define('_VAR_MODE', reset($var_mode)); |
|
| 2958 | - } |
|
| 2959 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2960 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2961 | - . " " . _VAR_MODE); |
|
| 2962 | - } |
|
| 2963 | - } // pas autorise ? |
|
| 2964 | - else { |
|
| 2965 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 2966 | - if (!$GLOBALS['visiteur_session'] |
|
| 2967 | - and !empty($_SERVER['HTTP_HOST']) |
|
| 2968 | - and !empty($_SERVER['REQUEST_METHOD']) |
|
| 2969 | - and $_SERVER['REQUEST_METHOD'] === 'GET') { |
|
| 2970 | - $self = self('&', true); |
|
| 2971 | - if (strpos($self, 'page=login') === false) { |
|
| 2972 | - include_spip('inc/headers'); |
|
| 2973 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 2974 | - redirige_par_entete(generer_url_public('login','url=' . rawurlencode($redirect), true)); |
|
| 2975 | - } |
|
| 2976 | - } |
|
| 2977 | - // sinon tant pis |
|
| 2978 | - } |
|
| 2979 | - } |
|
| 2980 | - } |
|
| 2981 | - if (!defined('_VAR_MODE')) { |
|
| 2982 | - /** |
|
| 2983 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 2984 | - * @see init_var_mode() |
|
| 2985 | - */ |
|
| 2986 | - define('_VAR_MODE', false); |
|
| 2987 | - } |
|
| 2988 | - $done = true; |
|
| 2989 | - } |
|
| 2862 | + static $done = false; |
|
| 2863 | + if (!$done) { |
|
| 2864 | + |
|
| 2865 | + if (isset($_GET['var_mode'])) { |
|
| 2866 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 2867 | + // tout le monde peut calcul/recalcul |
|
| 2868 | + if (!defined('_VAR_MODE')) { |
|
| 2869 | + if (in_array('recalcul', $var_mode)) { |
|
| 2870 | + define('_VAR_MODE', 'recalcul'); |
|
| 2871 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 2872 | + define('_VAR_MODE', 'calcul'); |
|
| 2873 | + } |
|
| 2874 | + } |
|
| 2875 | + $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2876 | + if ($var_mode) { |
|
| 2877 | + include_spip('inc/autoriser'); |
|
| 2878 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2879 | + if (autoriser( |
|
| 2880 | + ($_GET['var_mode'] == 'preview') |
|
| 2881 | + ? 'previsualiser' |
|
| 2882 | + : 'debug' |
|
| 2883 | + )) { |
|
| 2884 | + if (in_array('traduction', $var_mode)) { |
|
| 2885 | + // forcer le calcul pour passer dans traduire |
|
| 2886 | + if (!defined('_VAR_MODE')) { |
|
| 2887 | + define('_VAR_MODE', 'calcul'); |
|
| 2888 | + } |
|
| 2889 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2890 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2891 | + define('_VAR_NOCACHE', true); |
|
| 2892 | + } |
|
| 2893 | + $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2894 | + } |
|
| 2895 | + if (in_array('preview', $var_mode)) { |
|
| 2896 | + // basculer sur les criteres de preview dans les boucles |
|
| 2897 | + if (!defined('_VAR_PREVIEW')) { |
|
| 2898 | + define('_VAR_PREVIEW', true); |
|
| 2899 | + } |
|
| 2900 | + // forcer le calcul |
|
| 2901 | + if (!defined('_VAR_MODE')) { |
|
| 2902 | + define('_VAR_MODE', 'calcul'); |
|
| 2903 | + } |
|
| 2904 | + // et ne pas enregistrer de cache |
|
| 2905 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2906 | + define('_VAR_NOCACHE', true); |
|
| 2907 | + } |
|
| 2908 | + $var_mode = array_diff($var_mode, array('preview')); |
|
| 2909 | + } |
|
| 2910 | + if (in_array('inclure', $var_mode)) { |
|
| 2911 | + // forcer le compilo et ignorer les caches existants |
|
| 2912 | + if (!defined('_VAR_MODE')) { |
|
| 2913 | + define('_VAR_MODE', 'calcul'); |
|
| 2914 | + } |
|
| 2915 | + if (!defined('_VAR_INCLURE')) { |
|
| 2916 | + define('_VAR_INCLURE', true); |
|
| 2917 | + } |
|
| 2918 | + // et ne pas enregistrer de cache |
|
| 2919 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2920 | + define('_VAR_NOCACHE', true); |
|
| 2921 | + } |
|
| 2922 | + $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2923 | + } |
|
| 2924 | + if (in_array('urls', $var_mode)) { |
|
| 2925 | + // forcer le compilo et ignorer les caches existants |
|
| 2926 | + if (!defined('_VAR_MODE')) { |
|
| 2927 | + define('_VAR_MODE', 'calcul'); |
|
| 2928 | + } |
|
| 2929 | + if (!defined('_VAR_URLS')) { |
|
| 2930 | + define('_VAR_URLS', true); |
|
| 2931 | + } |
|
| 2932 | + $var_mode = array_diff($var_mode, array('urls')); |
|
| 2933 | + } |
|
| 2934 | + if (in_array('images', $var_mode)) { |
|
| 2935 | + // forcer le compilo et ignorer les caches existants |
|
| 2936 | + if (!defined('_VAR_MODE')) { |
|
| 2937 | + define('_VAR_MODE', 'calcul'); |
|
| 2938 | + } |
|
| 2939 | + // indiquer qu'on doit recalculer les images |
|
| 2940 | + if (!defined('_VAR_IMAGES')) { |
|
| 2941 | + define('_VAR_IMAGES', true); |
|
| 2942 | + } |
|
| 2943 | + $var_mode = array_diff($var_mode, array('images')); |
|
| 2944 | + } |
|
| 2945 | + if (in_array('debug', $var_mode)) { |
|
| 2946 | + if (!defined('_VAR_MODE')) { |
|
| 2947 | + define('_VAR_MODE', 'debug'); |
|
| 2948 | + } |
|
| 2949 | + // et ne pas enregistrer de cache |
|
| 2950 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2951 | + define('_VAR_NOCACHE', true); |
|
| 2952 | + } |
|
| 2953 | + $var_mode = array_diff($var_mode, array('debug')); |
|
| 2954 | + } |
|
| 2955 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2956 | + define('_VAR_MODE', reset($var_mode)); |
|
| 2957 | + } |
|
| 2958 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2959 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2960 | + . " " . _VAR_MODE); |
|
| 2961 | + } |
|
| 2962 | + } // pas autorise ? |
|
| 2963 | + else { |
|
| 2964 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 2965 | + if (!$GLOBALS['visiteur_session'] |
|
| 2966 | + and !empty($_SERVER['HTTP_HOST']) |
|
| 2967 | + and !empty($_SERVER['REQUEST_METHOD']) |
|
| 2968 | + and $_SERVER['REQUEST_METHOD'] === 'GET') { |
|
| 2969 | + $self = self('&', true); |
|
| 2970 | + if (strpos($self, 'page=login') === false) { |
|
| 2971 | + include_spip('inc/headers'); |
|
| 2972 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 2973 | + redirige_par_entete(generer_url_public('login','url=' . rawurlencode($redirect), true)); |
|
| 2974 | + } |
|
| 2975 | + } |
|
| 2976 | + // sinon tant pis |
|
| 2977 | + } |
|
| 2978 | + } |
|
| 2979 | + } |
|
| 2980 | + if (!defined('_VAR_MODE')) { |
|
| 2981 | + /** |
|
| 2982 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 2983 | + * @see init_var_mode() |
|
| 2984 | + */ |
|
| 2985 | + define('_VAR_MODE', false); |
|
| 2986 | + } |
|
| 2987 | + $done = true; |
|
| 2988 | + } |
|
| 2990 | 2989 | } |
| 2991 | 2990 | |
| 2992 | 2991 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
@@ -2994,85 +2993,85 @@ discard block |
||
| 2994 | 2993 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 2995 | 2994 | // https://code.spip.net/@spip_desinfecte |
| 2996 | 2995 | function spip_desinfecte(&$t, $deep = true) { |
| 2997 | - foreach ($t as $key => $val) { |
|
| 2998 | - if (is_string($t[$key])) { |
|
| 2999 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3000 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 3001 | - else { |
|
| 3002 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3003 | - spip_desinfecte($t[$key], $deep); |
|
| 3004 | - } |
|
| 3005 | - } |
|
| 3006 | - } |
|
| 2996 | + foreach ($t as $key => $val) { |
|
| 2997 | + if (is_string($t[$key])) { |
|
| 2998 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 2999 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 3000 | + else { |
|
| 3001 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3002 | + spip_desinfecte($t[$key], $deep); |
|
| 3003 | + } |
|
| 3004 | + } |
|
| 3005 | + } |
|
| 3007 | 3006 | } |
| 3008 | 3007 | |
| 3009 | 3008 | // retourne le statut du visiteur s'il s'annonce |
| 3010 | 3009 | |
| 3011 | 3010 | // https://code.spip.net/@verifier_visiteur |
| 3012 | 3011 | function verifier_visiteur() { |
| 3013 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 3014 | - // il faut forcer l'init si ce n'est fait |
|
| 3015 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3016 | - // certaines constantes |
|
| 3017 | - @spip_initialisation_core( |
|
| 3018 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3019 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3020 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3021 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3022 | - ); |
|
| 3023 | - |
|
| 3024 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3025 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3026 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 3027 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3028 | - $variables_session = array('session_nom', 'session_email'); |
|
| 3029 | - foreach ($variables_session as $var) { |
|
| 3030 | - if (_request($var) !== null) { |
|
| 3031 | - $init = true; |
|
| 3032 | - break; |
|
| 3033 | - } |
|
| 3034 | - } |
|
| 3035 | - if (isset($init)) { |
|
| 3036 | - #@spip_initialisation_suite(); |
|
| 3037 | - $session = charger_fonction('session', 'inc'); |
|
| 3038 | - $session(); |
|
| 3039 | - include_spip('inc/texte'); |
|
| 3040 | - foreach ($variables_session as $var) { |
|
| 3041 | - if (($a = _request($var)) !== null) { |
|
| 3042 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3043 | - } |
|
| 3044 | - } |
|
| 3045 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3046 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3047 | - } |
|
| 3048 | - $session($GLOBALS['visiteur_session']); |
|
| 3049 | - |
|
| 3050 | - return 0; |
|
| 3051 | - } |
|
| 3052 | - |
|
| 3053 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3054 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3055 | - |
|
| 3056 | - $session = charger_fonction('session', 'inc'); |
|
| 3057 | - if ($session()) { |
|
| 3058 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3059 | - } |
|
| 3060 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3061 | - include_spip('inc/auth'); |
|
| 3062 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3063 | - } |
|
| 3064 | - if ($h) { |
|
| 3065 | - $GLOBALS['visiteur_session'] = $h; |
|
| 3066 | - |
|
| 3067 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3068 | - } |
|
| 3069 | - } |
|
| 3070 | - |
|
| 3071 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3072 | - include_spip('inc/lang'); |
|
| 3073 | - utiliser_langue_visiteur(); |
|
| 3074 | - |
|
| 3075 | - return false; |
|
| 3012 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 3013 | + // il faut forcer l'init si ce n'est fait |
|
| 3014 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3015 | + // certaines constantes |
|
| 3016 | + @spip_initialisation_core( |
|
| 3017 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3018 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3019 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3020 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3021 | + ); |
|
| 3022 | + |
|
| 3023 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3024 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3025 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 3026 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3027 | + $variables_session = array('session_nom', 'session_email'); |
|
| 3028 | + foreach ($variables_session as $var) { |
|
| 3029 | + if (_request($var) !== null) { |
|
| 3030 | + $init = true; |
|
| 3031 | + break; |
|
| 3032 | + } |
|
| 3033 | + } |
|
| 3034 | + if (isset($init)) { |
|
| 3035 | + #@spip_initialisation_suite(); |
|
| 3036 | + $session = charger_fonction('session', 'inc'); |
|
| 3037 | + $session(); |
|
| 3038 | + include_spip('inc/texte'); |
|
| 3039 | + foreach ($variables_session as $var) { |
|
| 3040 | + if (($a = _request($var)) !== null) { |
|
| 3041 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3042 | + } |
|
| 3043 | + } |
|
| 3044 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3045 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3046 | + } |
|
| 3047 | + $session($GLOBALS['visiteur_session']); |
|
| 3048 | + |
|
| 3049 | + return 0; |
|
| 3050 | + } |
|
| 3051 | + |
|
| 3052 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3053 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3054 | + |
|
| 3055 | + $session = charger_fonction('session', 'inc'); |
|
| 3056 | + if ($session()) { |
|
| 3057 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3058 | + } |
|
| 3059 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3060 | + include_spip('inc/auth'); |
|
| 3061 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3062 | + } |
|
| 3063 | + if ($h) { |
|
| 3064 | + $GLOBALS['visiteur_session'] = $h; |
|
| 3065 | + |
|
| 3066 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3067 | + } |
|
| 3068 | + } |
|
| 3069 | + |
|
| 3070 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3071 | + include_spip('inc/lang'); |
|
| 3072 | + utiliser_langue_visiteur(); |
|
| 3073 | + |
|
| 3074 | + return false; |
|
| 3076 | 3075 | } |
| 3077 | 3076 | |
| 3078 | 3077 | |
@@ -3095,21 +3094,21 @@ discard block |
||
| 3095 | 3094 | * - string Langue utilisée. |
| 3096 | 3095 | **/ |
| 3097 | 3096 | function lang_select($lang = null) { |
| 3098 | - static $pile_langues = array(); |
|
| 3099 | - if (!function_exists('changer_langue')) { |
|
| 3100 | - include_spip('inc/lang'); |
|
| 3101 | - } |
|
| 3102 | - if ($lang === null) { |
|
| 3103 | - $lang = array_pop($pile_langues); |
|
| 3104 | - } else { |
|
| 3105 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3106 | - } |
|
| 3107 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3108 | - return $lang; |
|
| 3109 | - } |
|
| 3110 | - changer_langue($lang); |
|
| 3097 | + static $pile_langues = array(); |
|
| 3098 | + if (!function_exists('changer_langue')) { |
|
| 3099 | + include_spip('inc/lang'); |
|
| 3100 | + } |
|
| 3101 | + if ($lang === null) { |
|
| 3102 | + $lang = array_pop($pile_langues); |
|
| 3103 | + } else { |
|
| 3104 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3105 | + } |
|
| 3106 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3107 | + return $lang; |
|
| 3108 | + } |
|
| 3109 | + changer_langue($lang); |
|
| 3111 | 3110 | |
| 3112 | - return $lang; |
|
| 3111 | + return $lang; |
|
| 3113 | 3112 | } |
| 3114 | 3113 | |
| 3115 | 3114 | /** |
@@ -3126,19 +3125,19 @@ discard block |
||
| 3126 | 3125 | * Identifiant de la session |
| 3127 | 3126 | **/ |
| 3128 | 3127 | function spip_session($force = false) { |
| 3129 | - static $session; |
|
| 3130 | - if ($force or !isset($session)) { |
|
| 3131 | - $s = pipeline('definir_session', |
|
| 3132 | - $GLOBALS['visiteur_session'] |
|
| 3133 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3134 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3135 | - : '' |
|
| 3136 | - ); |
|
| 3137 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3138 | - } |
|
| 3128 | + static $session; |
|
| 3129 | + if ($force or !isset($session)) { |
|
| 3130 | + $s = pipeline('definir_session', |
|
| 3131 | + $GLOBALS['visiteur_session'] |
|
| 3132 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3133 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3134 | + : '' |
|
| 3135 | + ); |
|
| 3136 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3137 | + } |
|
| 3139 | 3138 | |
| 3140 | - #spip_log('session: '.$session); |
|
| 3141 | - return $session; |
|
| 3139 | + #spip_log('session: '.$session); |
|
| 3140 | + return $session; |
|
| 3142 | 3141 | } |
| 3143 | 3142 | |
| 3144 | 3143 | |
@@ -3157,9 +3156,9 @@ discard block |
||
| 3157 | 3156 | * Lien sur une icone d'aide |
| 3158 | 3157 | **/ |
| 3159 | 3158 | function aider($aide = '', $distante = false) { |
| 3160 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3159 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3161 | 3160 | |
| 3162 | - return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3161 | + return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3163 | 3162 | } |
| 3164 | 3163 | |
| 3165 | 3164 | /** |
@@ -3169,24 +3168,24 @@ discard block |
||
| 3169 | 3168 | */ |
| 3170 | 3169 | function exec_info_dist() { |
| 3171 | 3170 | |
| 3172 | - include_spip('inc/autoriser'); |
|
| 3173 | - if (autoriser('phpinfos')) { |
|
| 3174 | - $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3175 | - $cookies_backup = []; |
|
| 3176 | - foreach ($cookies_masques as $k) { |
|
| 3177 | - if (!empty($_COOKIE[$k])) { |
|
| 3178 | - $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3179 | - $_COOKIE[$k] = '******************************'; |
|
| 3180 | - } |
|
| 3181 | - } |
|
| 3182 | - phpinfo(); |
|
| 3183 | - foreach ($cookies_backup as $k => $v) { |
|
| 3184 | - $_COOKIE[$k] = $v; |
|
| 3185 | - } |
|
| 3186 | - } else { |
|
| 3187 | - include_spip('inc/filtres'); |
|
| 3188 | - sinon_interdire_acces(); |
|
| 3189 | - } |
|
| 3171 | + include_spip('inc/autoriser'); |
|
| 3172 | + if (autoriser('phpinfos')) { |
|
| 3173 | + $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3174 | + $cookies_backup = []; |
|
| 3175 | + foreach ($cookies_masques as $k) { |
|
| 3176 | + if (!empty($_COOKIE[$k])) { |
|
| 3177 | + $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3178 | + $_COOKIE[$k] = '******************************'; |
|
| 3179 | + } |
|
| 3180 | + } |
|
| 3181 | + phpinfo(); |
|
| 3182 | + foreach ($cookies_backup as $k => $v) { |
|
| 3183 | + $_COOKIE[$k] = $v; |
|
| 3184 | + } |
|
| 3185 | + } else { |
|
| 3186 | + include_spip('inc/filtres'); |
|
| 3187 | + sinon_interdire_acces(); |
|
| 3188 | + } |
|
| 3190 | 3189 | } |
| 3191 | 3190 | |
| 3192 | 3191 | /** |
@@ -3206,13 +3205,13 @@ discard block |
||
| 3206 | 3205 | * - string si $message à false. |
| 3207 | 3206 | **/ |
| 3208 | 3207 | function erreur_squelette($message = '', $lieu = '') { |
| 3209 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3210 | - if (is_array($lieu)) { |
|
| 3211 | - include_spip('public/compiler'); |
|
| 3212 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3213 | - } |
|
| 3208 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3209 | + if (is_array($lieu)) { |
|
| 3210 | + include_spip('public/compiler'); |
|
| 3211 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3212 | + } |
|
| 3214 | 3213 | |
| 3215 | - return $debusquer($message, $lieu); |
|
| 3214 | + return $debusquer($message, $lieu); |
|
| 3216 | 3215 | } |
| 3217 | 3216 | |
| 3218 | 3217 | /** |
@@ -3249,109 +3248,109 @@ discard block |
||
| 3249 | 3248 | * - ou tableau d'information sur le squelette. |
| 3250 | 3249 | */ |
| 3251 | 3250 | function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') { |
| 3252 | - if (!function_exists('evaluer_fond')) { |
|
| 3253 | - include_spip('public/assembler'); |
|
| 3254 | - } |
|
| 3255 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3256 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3257 | - if (!is_array($options)) { |
|
| 3258 | - $options = array('trim' => $options); |
|
| 3259 | - } |
|
| 3260 | - if (!isset($options['trim'])) { |
|
| 3261 | - $options['trim'] = true; |
|
| 3262 | - } |
|
| 3263 | - |
|
| 3264 | - if (isset($contexte['connect'])) { |
|
| 3265 | - $connect = $contexte['connect']; |
|
| 3266 | - unset($contexte['connect']); |
|
| 3267 | - } |
|
| 3268 | - |
|
| 3269 | - $texte = ""; |
|
| 3270 | - $pages = array(); |
|
| 3271 | - $lang_select = ''; |
|
| 3272 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3273 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3274 | - if (!isset($contexte['lang'])) { |
|
| 3275 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3276 | - } |
|
| 3277 | - |
|
| 3278 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3279 | - $lang_select = lang_select($contexte['lang']); |
|
| 3280 | - } |
|
| 3281 | - } |
|
| 3282 | - |
|
| 3283 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3284 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3285 | - } |
|
| 3286 | - |
|
| 3287 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3288 | - |
|
| 3289 | - // fix #4235 |
|
| 3290 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3291 | - |
|
| 3292 | - |
|
| 3293 | - foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3251 | + if (!function_exists('evaluer_fond')) { |
|
| 3252 | + include_spip('public/assembler'); |
|
| 3253 | + } |
|
| 3254 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3255 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3256 | + if (!is_array($options)) { |
|
| 3257 | + $options = array('trim' => $options); |
|
| 3258 | + } |
|
| 3259 | + if (!isset($options['trim'])) { |
|
| 3260 | + $options['trim'] = true; |
|
| 3261 | + } |
|
| 3262 | + |
|
| 3263 | + if (isset($contexte['connect'])) { |
|
| 3264 | + $connect = $contexte['connect']; |
|
| 3265 | + unset($contexte['connect']); |
|
| 3266 | + } |
|
| 3267 | + |
|
| 3268 | + $texte = ""; |
|
| 3269 | + $pages = array(); |
|
| 3270 | + $lang_select = ''; |
|
| 3271 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3272 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3273 | + if (!isset($contexte['lang'])) { |
|
| 3274 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3275 | + } |
|
| 3276 | + |
|
| 3277 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3278 | + $lang_select = lang_select($contexte['lang']); |
|
| 3279 | + } |
|
| 3280 | + } |
|
| 3281 | + |
|
| 3282 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3283 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3284 | + } |
|
| 3285 | + |
|
| 3286 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3287 | + |
|
| 3288 | + // fix #4235 |
|
| 3289 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3290 | + |
|
| 3291 | + |
|
| 3292 | + foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3294 | 3293 | |
| 3295 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3296 | - |
|
| 3297 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3298 | - if ($page === '') { |
|
| 3299 | - $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3300 | - $a = array('fichier' => $f); |
|
| 3301 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3302 | - erreur_squelette($erreur, $c); |
|
| 3303 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3304 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3305 | - } |
|
| 3306 | - |
|
| 3307 | - $page = pipeline('recuperer_fond', array( |
|
| 3308 | - 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3309 | - 'data' => $page |
|
| 3310 | - )); |
|
| 3311 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3312 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3313 | - include_spip('inc/filtres'); |
|
| 3314 | - } |
|
| 3315 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3316 | - array_merge( |
|
| 3317 | - $contexte, |
|
| 3318 | - array('fond' => $f), |
|
| 3319 | - ($connect ? array('connect' => $connect) : array()) |
|
| 3320 | - ), |
|
| 3321 | - '', |
|
| 3322 | - $page['texte'], |
|
| 3323 | - $options['ajax'] |
|
| 3324 | - ); |
|
| 3325 | - } |
|
| 3326 | - |
|
| 3327 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3328 | - $pages[] = $page; |
|
| 3329 | - } else { |
|
| 3330 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3331 | - } |
|
| 3294 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3295 | + |
|
| 3296 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3297 | + if ($page === '') { |
|
| 3298 | + $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3299 | + $a = array('fichier' => $f); |
|
| 3300 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3301 | + erreur_squelette($erreur, $c); |
|
| 3302 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3303 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3304 | + } |
|
| 3305 | + |
|
| 3306 | + $page = pipeline('recuperer_fond', array( |
|
| 3307 | + 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3308 | + 'data' => $page |
|
| 3309 | + )); |
|
| 3310 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3311 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3312 | + include_spip('inc/filtres'); |
|
| 3313 | + } |
|
| 3314 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3315 | + array_merge( |
|
| 3316 | + $contexte, |
|
| 3317 | + array('fond' => $f), |
|
| 3318 | + ($connect ? array('connect' => $connect) : array()) |
|
| 3319 | + ), |
|
| 3320 | + '', |
|
| 3321 | + $page['texte'], |
|
| 3322 | + $options['ajax'] |
|
| 3323 | + ); |
|
| 3324 | + } |
|
| 3325 | + |
|
| 3326 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3327 | + $pages[] = $page; |
|
| 3328 | + } else { |
|
| 3329 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3330 | + } |
|
| 3332 | 3331 | |
| 3333 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3334 | - if (isset($page['invalideurs']['session'])){ |
|
| 3335 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3336 | - } |
|
| 3337 | - } |
|
| 3332 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3333 | + if (isset($page['invalideurs']['session'])){ |
|
| 3334 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3335 | + } |
|
| 3336 | + } |
|
| 3338 | 3337 | |
| 3339 | - // restaurer le sessionnement du contexte appelant, |
|
| 3340 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3341 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3342 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3343 | - } |
|
| 3338 | + // restaurer le sessionnement du contexte appelant, |
|
| 3339 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3340 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3341 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3342 | + } |
|
| 3344 | 3343 | |
| 3345 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3344 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3346 | 3345 | |
| 3347 | - if ($lang_select) { |
|
| 3348 | - lang_select(); |
|
| 3349 | - } |
|
| 3350 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3351 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3352 | - } else { |
|
| 3353 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3354 | - } |
|
| 3346 | + if ($lang_select) { |
|
| 3347 | + lang_select(); |
|
| 3348 | + } |
|
| 3349 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3350 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3351 | + } else { |
|
| 3352 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3353 | + } |
|
| 3355 | 3354 | } |
| 3356 | 3355 | |
| 3357 | 3356 | /** |
@@ -3361,7 +3360,7 @@ discard block |
||
| 3361 | 3360 | * @return string |
| 3362 | 3361 | */ |
| 3363 | 3362 | function trouve_modele($nom) { |
| 3364 | - return trouver_fond($nom, 'modeles/'); |
|
| 3363 | + return trouver_fond($nom, 'modeles/'); |
|
| 3365 | 3364 | } |
| 3366 | 3365 | |
| 3367 | 3366 | /** |
@@ -3377,21 +3376,21 @@ discard block |
||
| 3377 | 3376 | * @return array|string |
| 3378 | 3377 | */ |
| 3379 | 3378 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3380 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3381 | - if (!$pathinfo) { |
|
| 3382 | - return $f; |
|
| 3383 | - } |
|
| 3384 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3385 | - $p = pathinfo($f); |
|
| 3386 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3387 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3388 | - } |
|
| 3389 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3390 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3391 | - } |
|
| 3392 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3379 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3380 | + if (!$pathinfo) { |
|
| 3381 | + return $f; |
|
| 3382 | + } |
|
| 3383 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3384 | + $p = pathinfo($f); |
|
| 3385 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3386 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3387 | + } |
|
| 3388 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3389 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3390 | + } |
|
| 3391 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3393 | 3392 | |
| 3394 | - return $p; |
|
| 3393 | + return $p; |
|
| 3395 | 3394 | } |
| 3396 | 3395 | |
| 3397 | 3396 | /** |
@@ -3412,24 +3411,24 @@ discard block |
||
| 3412 | 3411 | * Nom de l'exec, sinon chaîne vide. |
| 3413 | 3412 | **/ |
| 3414 | 3413 | function tester_url_ecrire($nom) { |
| 3415 | - static $exec = array(); |
|
| 3416 | - if (isset($exec[$nom])) { |
|
| 3417 | - return $exec[$nom]; |
|
| 3418 | - } |
|
| 3419 | - // tester si c'est une page en squelette |
|
| 3420 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3421 | - return $exec[$nom] = 'fond'; |
|
| 3422 | - } // compat skels orthogonaux version precedente |
|
| 3423 | - elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3424 | - return $exec[$nom] = 'fond_monobloc'; |
|
| 3425 | - } // echafaudage d'un fond ! |
|
| 3426 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3427 | - return $exec[$nom] = 'fond'; |
|
| 3428 | - } |
|
| 3429 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3430 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3431 | - // et des define intrusifs potentiels |
|
| 3432 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3414 | + static $exec = array(); |
|
| 3415 | + if (isset($exec[$nom])) { |
|
| 3416 | + return $exec[$nom]; |
|
| 3417 | + } |
|
| 3418 | + // tester si c'est une page en squelette |
|
| 3419 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3420 | + return $exec[$nom] = 'fond'; |
|
| 3421 | + } // compat skels orthogonaux version precedente |
|
| 3422 | + elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3423 | + return $exec[$nom] = 'fond_monobloc'; |
|
| 3424 | + } // echafaudage d'un fond ! |
|
| 3425 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3426 | + return $exec[$nom] = 'fond'; |
|
| 3427 | + } |
|
| 3428 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3429 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3430 | + // et des define intrusifs potentiels |
|
| 3431 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3433 | 3432 | } |
| 3434 | 3433 | |
| 3435 | 3434 | |
@@ -3445,10 +3444,10 @@ discard block |
||
| 3445 | 3444 | * @return bool true si le module est chargé |
| 3446 | 3445 | **/ |
| 3447 | 3446 | function charger_php_extension($module) { |
| 3448 | - if (extension_loaded($module)) { |
|
| 3449 | - return true; |
|
| 3450 | - } |
|
| 3451 | - return false; |
|
| 3447 | + if (extension_loaded($module)) { |
|
| 3448 | + return true; |
|
| 3449 | + } |
|
| 3450 | + return false; |
|
| 3452 | 3451 | } |
| 3453 | 3452 | |
| 3454 | 3453 | |
@@ -3459,8 +3458,8 @@ discard block |
||
| 3459 | 3458 | * true si la constante _VERSION_HTML n'est pas définie ou égale à html5 |
| 3460 | 3459 | **/ |
| 3461 | 3460 | function html5_permis() { |
| 3462 | - return (!defined('_VERSION_HTML') |
|
| 3463 | - or _VERSION_HTML !== 'html4'); |
|
| 3461 | + return (!defined('_VERSION_HTML') |
|
| 3462 | + or _VERSION_HTML !== 'html4'); |
|
| 3464 | 3463 | } |
| 3465 | 3464 | |
| 3466 | 3465 | /** |
@@ -3470,30 +3469,30 @@ discard block |
||
| 3470 | 3469 | * @return array |
| 3471 | 3470 | */ |
| 3472 | 3471 | function formats_image_acceptables($gd = null, $svg_allowed = true) { |
| 3473 | - $formats = null; |
|
| 3474 | - if (!is_null($gd)) { |
|
| 3475 | - $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3476 | - if (isset($GLOBALS['meta'][$config])) { |
|
| 3477 | - $formats = $GLOBALS['meta'][$config]; |
|
| 3478 | - $formats = explode(',', $formats); |
|
| 3479 | - $formats = array_filter($formats); |
|
| 3480 | - $formats = array_map('trim', $formats); |
|
| 3481 | - } |
|
| 3482 | - } |
|
| 3483 | - if (is_null($formats)) { |
|
| 3484 | - include_spip('inc/filtres_images_lib_mini'); |
|
| 3485 | - $formats = _image_extensions_acceptees_en_entree(); |
|
| 3486 | - } |
|
| 3487 | - |
|
| 3488 | - if ($svg_allowed) { |
|
| 3489 | - if (!in_array('svg', $formats)) { |
|
| 3490 | - $formats[] = 'svg'; |
|
| 3491 | - } |
|
| 3492 | - } |
|
| 3493 | - else { |
|
| 3494 | - $formats = array_diff($formats, ['svg']); |
|
| 3495 | - } |
|
| 3496 | - return $formats; |
|
| 3472 | + $formats = null; |
|
| 3473 | + if (!is_null($gd)) { |
|
| 3474 | + $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3475 | + if (isset($GLOBALS['meta'][$config])) { |
|
| 3476 | + $formats = $GLOBALS['meta'][$config]; |
|
| 3477 | + $formats = explode(',', $formats); |
|
| 3478 | + $formats = array_filter($formats); |
|
| 3479 | + $formats = array_map('trim', $formats); |
|
| 3480 | + } |
|
| 3481 | + } |
|
| 3482 | + if (is_null($formats)) { |
|
| 3483 | + include_spip('inc/filtres_images_lib_mini'); |
|
| 3484 | + $formats = _image_extensions_acceptees_en_entree(); |
|
| 3485 | + } |
|
| 3486 | + |
|
| 3487 | + if ($svg_allowed) { |
|
| 3488 | + if (!in_array('svg', $formats)) { |
|
| 3489 | + $formats[] = 'svg'; |
|
| 3490 | + } |
|
| 3491 | + } |
|
| 3492 | + else { |
|
| 3493 | + $formats = array_diff($formats, ['svg']); |
|
| 3494 | + } |
|
| 3495 | + return $formats; |
|
| 3497 | 3496 | } |
| 3498 | 3497 | |
| 3499 | 3498 | /** |
@@ -3502,21 +3501,21 @@ discard block |
||
| 3502 | 3501 | * @return array|bool |
| 3503 | 3502 | */ |
| 3504 | 3503 | function spip_getimagesize($fichier) { |
| 3505 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3504 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3506 | 3505 | |
| 3507 | - include_spip("inc/svg"); |
|
| 3508 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3509 | - list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs); |
|
| 3510 | - $imagesize = [ |
|
| 3511 | - $width, |
|
| 3512 | - $height, |
|
| 3513 | - IMAGETYPE_SVG, |
|
| 3514 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3515 | - "mime" => "image/svg+xml" |
|
| 3516 | - ]; |
|
| 3517 | - } |
|
| 3518 | - } |
|
| 3519 | - return $imagesize; |
|
| 3506 | + include_spip("inc/svg"); |
|
| 3507 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3508 | + list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs); |
|
| 3509 | + $imagesize = [ |
|
| 3510 | + $width, |
|
| 3511 | + $height, |
|
| 3512 | + IMAGETYPE_SVG, |
|
| 3513 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3514 | + "mime" => "image/svg+xml" |
|
| 3515 | + ]; |
|
| 3516 | + } |
|
| 3517 | + } |
|
| 3518 | + return $imagesize; |
|
| 3520 | 3519 | } |
| 3521 | 3520 | |
| 3522 | 3521 | |
@@ -3536,7 +3535,7 @@ discard block |
||
| 3536 | 3535 | * @return mixed Valeur de la meta. |
| 3537 | 3536 | **/ |
| 3538 | 3537 | function lire_meta($nom) { |
| 3539 | - return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3538 | + return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3540 | 3539 | } |
| 3541 | 3540 | |
| 3542 | 3541 | |
@@ -3558,18 +3557,18 @@ discard block |
||
| 3558 | 3557 | * @param string $statut |
| 3559 | 3558 | */ |
| 3560 | 3559 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3561 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3562 | - if (!$alertes |
|
| 3563 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3564 | - ) { |
|
| 3565 | - $alertes = array(); |
|
| 3566 | - } |
|
| 3560 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3561 | + if (!$alertes |
|
| 3562 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3563 | + ) { |
|
| 3564 | + $alertes = array(); |
|
| 3565 | + } |
|
| 3567 | 3566 | |
| 3568 | - if (!isset($alertes[$statut])) { |
|
| 3569 | - $alertes[$statut] = array(); |
|
| 3570 | - } |
|
| 3571 | - $alertes[$statut][$nom] = $message; |
|
| 3572 | - ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3567 | + if (!isset($alertes[$statut])) { |
|
| 3568 | + $alertes[$statut] = array(); |
|
| 3569 | + } |
|
| 3570 | + $alertes[$statut][$nom] = $message; |
|
| 3571 | + ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3573 | 3572 | } |
| 3574 | 3573 | |
| 3575 | 3574 | /** |
@@ -3583,10 +3582,10 @@ discard block |
||
| 3583 | 3582 | * @return string|string[] |
| 3584 | 3583 | */ |
| 3585 | 3584 | function spip_sanitize_classname($classes) { |
| 3586 | - if (is_array($classes)) { |
|
| 3587 | - return array_map('spip_sanitize_classname', $classes); |
|
| 3588 | - } |
|
| 3589 | - return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes); |
|
| 3585 | + if (is_array($classes)) { |
|
| 3586 | + return array_map('spip_sanitize_classname', $classes); |
|
| 3587 | + } |
|
| 3588 | + return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes); |
|
| 3590 | 3589 | } |
| 3591 | 3590 | |
| 3592 | 3591 | |
@@ -3611,32 +3610,32 @@ discard block |
||
| 3611 | 3610 | * Avec operateur : bool. |
| 3612 | 3611 | **/ |
| 3613 | 3612 | function spip_version_compare($v1, $v2, $op = null) { |
| 3614 | - $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3615 | - $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3616 | - $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3617 | - $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3618 | - |
|
| 3619 | - $v1 = explode('.', $v1); |
|
| 3620 | - $v2 = explode('.', $v2); |
|
| 3621 | - // $v1 est toujours une version, donc sans etoile |
|
| 3622 | - while (count($v1) < count($v2)) { |
|
| 3623 | - $v1[] = '0'; |
|
| 3624 | - } |
|
| 3625 | - |
|
| 3626 | - // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3627 | - $etoile = false; |
|
| 3628 | - foreach ($v1 as $k => $v) { |
|
| 3629 | - if (!isset($v2[$k])) { |
|
| 3630 | - $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3631 | - } else { |
|
| 3632 | - if ($v2[$k] == '*') { |
|
| 3633 | - $etoile = true; |
|
| 3634 | - $v2[$k] = $v; |
|
| 3635 | - } |
|
| 3636 | - } |
|
| 3637 | - } |
|
| 3638 | - $v1 = implode('.', $v1); |
|
| 3639 | - $v2 = implode('.', $v2); |
|
| 3640 | - |
|
| 3641 | - return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3613 | + $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3614 | + $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3615 | + $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3616 | + $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3617 | + |
|
| 3618 | + $v1 = explode('.', $v1); |
|
| 3619 | + $v2 = explode('.', $v2); |
|
| 3620 | + // $v1 est toujours une version, donc sans etoile |
|
| 3621 | + while (count($v1) < count($v2)) { |
|
| 3622 | + $v1[] = '0'; |
|
| 3623 | + } |
|
| 3624 | + |
|
| 3625 | + // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3626 | + $etoile = false; |
|
| 3627 | + foreach ($v1 as $k => $v) { |
|
| 3628 | + if (!isset($v2[$k])) { |
|
| 3629 | + $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3630 | + } else { |
|
| 3631 | + if ($v2[$k] == '*') { |
|
| 3632 | + $etoile = true; |
|
| 3633 | + $v2[$k] = $v; |
|
| 3634 | + } |
|
| 3635 | + } |
|
| 3636 | + } |
|
| 3637 | + $v1 = implode('.', $v1); |
|
| 3638 | + $v2 = implode('.', $v2); |
|
| 3639 | + |
|
| 3640 | + return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3642 | 3641 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | if (strlen($dossier) and substr($dossier, -1) != '/') { |
| 54 | 54 | $dossier .= '/'; |
| 55 | 55 | } |
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 56 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 57 | 57 | |
| 58 | 58 | if (function_exists($f)) { |
| 59 | 59 | return $f; |
| 60 | 60 | } |
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 61 | + if (function_exists($g = $f.'_dist')) { |
|
| 62 | 62 | return $g; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // passer en minuscules (cf les balises de formulaires) |
| 80 | 80 | // et inclure le fichier |
| 81 | - if (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 81 | + if (!$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 82 | 82 | // si le fichier truc/machin/nom.php n'existe pas, |
| 83 | 83 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 84 | 84 | and strlen(dirname($dossier)) and dirname($dossier) != '.' |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Echec : message d'erreur |
| 100 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 100 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 101 | 101 | ($inc ? "" : " (fichier $d absent de $dossier)")); |
| 102 | 102 | |
| 103 | 103 | include_spip('inc/minipres'); |
| 104 | 104 | echo minipres(_T('forum_titre_erreur'), |
| 105 | - _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | - array('all_inline'=>true,'status'=>404)); |
|
| 105 | + _T('fichier_introuvable', array('fichier' => '<b>'.spip_htmlentities($d).'</b>')), |
|
| 106 | + array('all_inline'=>true, 'status'=>404)); |
|
| 107 | 107 | exit; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * - string : chemin du fichier trouvé |
| 149 | 149 | **/ |
| 150 | 150 | function include_spip($f, $include = true) { |
| 151 | - return find_in_path($f . '.php', '', $include); |
|
| 151 | + return find_in_path($f.'.php', '', $include); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * - string : chemin du fichier trouvé |
| 169 | 169 | **/ |
| 170 | 170 | function require_spip($f) { |
| 171 | - return find_in_path($f . '.php', '', 'required'); |
|
| 171 | + return find_in_path($f.'.php', '', 'required'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | // donc il faut l'inclure "en globals" |
| 186 | 186 | if ($f = find_in_path('mes_fonctions.php')) { |
| 187 | 187 | global $dossier_squelettes; |
| 188 | - include_once(_ROOT_CWD . $f); |
|
| 188 | + include_once(_ROOT_CWD.$f); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // appliquer notre fonction si elle existe |
| 292 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 292 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 293 | 293 | if (function_exists($fonc)) { |
| 294 | 294 | $val = $fonc($val); |
| 295 | 295 | } // plantage ? |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | function spip_log($message = null, $name = null) { |
| 354 | 354 | static $pre = array(); |
| 355 | 355 | static $log; |
| 356 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 356 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 357 | 357 | if (!isset($regs[1]) or !$logname = $regs[1]) { |
| 358 | 358 | $logname = null; |
| 359 | 359 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | if (!is_string($message)) { |
| 382 | 382 | $message = print_r($message, true); |
| 383 | 383 | } |
| 384 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 384 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
@@ -494,9 +494,9 @@ discard block |
||
| 494 | 494 | * @param string $sanitize_function |
| 495 | 495 | * @return array|mixed|string |
| 496 | 496 | */ |
| 497 | -function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') { |
|
| 497 | +function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') { |
|
| 498 | 498 | if (is_array($value)) { |
| 499 | - if ($key=='*') { |
|
| 499 | + if ($key == '*') { |
|
| 500 | 500 | $key = array_keys($value); |
| 501 | 501 | } |
| 502 | 502 | if (!is_array($key)) { |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | $a = './'; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 584 | + $regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; |
|
| 585 | 585 | $ajouts = array_flip(explode('|', $c)); |
| 586 | 586 | $u = is_array($v) ? $v : rawurlencode($v); |
| 587 | 587 | $testv = (is_array($v) ? count($v) : strlen($v)); |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 609 | 609 | // pour un tableau ce sera fait dans la prochaine boucle |
| 610 | 610 | elseif (substr($r[1], -2) != '[]') { |
| 611 | - $url[$n] = $r[1] . '=' . $u; |
|
| 611 | + $url[$n] = $r[1].'='.$u; |
|
| 612 | 612 | unset($ajouts[$r[1]]); |
| 613 | 613 | } |
| 614 | 614 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -628,11 +628,11 @@ discard block |
||
| 628 | 628 | } elseif ($testv) { |
| 629 | 629 | foreach ($ajouts as $k => $n) { |
| 630 | 630 | if (!is_array($v)) { |
| 631 | - $url[] = $k . '=' . $u; |
|
| 631 | + $url[] = $k.'='.$u; |
|
| 632 | 632 | } else { |
| 633 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 633 | + $id = (substr($k, -2) == '[]') ? $k : ($k."[]"); |
|
| 634 | 634 | foreach ($v as $w) { |
| 635 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 635 | + $url[] = $id.'='.(is_array($w) ? 'Array' : $w); |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | } |
@@ -643,10 +643,10 @@ discard block |
||
| 643 | 643 | |
| 644 | 644 | // recomposer l'adresse |
| 645 | 645 | if ($url) { |
| 646 | - $a .= '?' . join($sep, $url); |
|
| 646 | + $a .= '?'.join($sep, $url); |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - return $a . $ancre; |
|
| 649 | + return $a.$ancre; |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | /** |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | translitteration($ancre) |
| 679 | 679 | ); |
| 680 | 680 | } |
| 681 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 681 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | /** |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * @return bool |
| 791 | 791 | */ |
| 792 | 792 | function test_plugin_actif($plugin) { |
| 793 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 793 | + return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /** |
@@ -858,8 +858,7 @@ discard block |
||
| 858 | 858 | // pour les chaines non traduites, assurer un service minimum |
| 859 | 859 | if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
| 860 | 860 | $text = str_replace('_', ' ', |
| 861 | - (($n = strpos($text, ':')) === false ? $texte : |
|
| 862 | - substr($texte, $n + 1))); |
|
| 861 | + (($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1))); |
|
| 863 | 862 | } |
| 864 | 863 | $o['class'] = null; |
| 865 | 864 | |
@@ -931,7 +930,7 @@ discard block |
||
| 931 | 930 | // Si des variables n'ont pas ete inserees, le signaler |
| 932 | 931 | // (chaines de langues pas a jour) |
| 933 | 932 | if ($args) { |
| 934 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 933 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 935 | 934 | } |
| 936 | 935 | } |
| 937 | 936 | |
@@ -955,7 +954,7 @@ discard block |
||
| 955 | 954 | function joli_repertoire($rep) { |
| 956 | 955 | $a = substr($rep, 0, 1); |
| 957 | 956 | if ($a <> '.' and $a <> '/') { |
| 958 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 957 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 959 | 958 | } |
| 960 | 959 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 961 | 960 | |
@@ -1009,7 +1008,7 @@ discard block |
||
| 1009 | 1008 | $p -= ($x * 1000); |
| 1010 | 1009 | } |
| 1011 | 1010 | |
| 1012 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1011 | + return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1013 | 1012 | } |
| 1014 | 1013 | } |
| 1015 | 1014 | |
@@ -1078,7 +1077,7 @@ discard block |
||
| 1078 | 1077 | if ($taches and count($taches) and !spip_connect()) { |
| 1079 | 1078 | return false; |
| 1080 | 1079 | } |
| 1081 | - spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1080 | + spip_log("cron !", 'jq'._LOG_DEBUG); |
|
| 1082 | 1081 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 1083 | 1082 | return $genie($taches); |
| 1084 | 1083 | } |
@@ -1182,7 +1181,7 @@ discard block |
||
| 1182 | 1181 | |
| 1183 | 1182 | if ($queue_next_job_time == -1) { |
| 1184 | 1183 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 1185 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1184 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt"); |
|
| 1186 | 1185 | } |
| 1187 | 1186 | // utiliser un cache memoire si dispo |
| 1188 | 1187 | if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
@@ -1249,8 +1248,8 @@ discard block |
||
| 1249 | 1248 | $src = ''; |
| 1250 | 1249 | } |
| 1251 | 1250 | if ($script) { |
| 1252 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1253 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1251 | + $script = ("/*<![CDATA[*/\n". |
|
| 1252 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 1254 | 1253 | "/*]]>*/"); |
| 1255 | 1254 | } |
| 1256 | 1255 | if ($noscript) { |
@@ -1336,13 +1335,13 @@ discard block |
||
| 1336 | 1335 | if ($path_base == null) { |
| 1337 | 1336 | // Chemin standard depuis l'espace public |
| 1338 | 1337 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 1339 | - _DIR_RACINE . ':' . |
|
| 1340 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1341 | - _DIR_RACINE . 'prive/:' . |
|
| 1338 | + _DIR_RACINE.':'. |
|
| 1339 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 1340 | + _DIR_RACINE.'prive/:'. |
|
| 1342 | 1341 | _DIR_RESTREINT; |
| 1343 | 1342 | // Ajouter squelettes/ |
| 1344 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1345 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1343 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 1344 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 1346 | 1345 | } |
| 1347 | 1346 | foreach (explode(':', $path) as $dir) { |
| 1348 | 1347 | if (strlen($dir) and substr($dir, -1) != '/') { |
@@ -1354,7 +1353,7 @@ discard block |
||
| 1354 | 1353 | // Et le(s) dossier(s) des squelettes nommes |
| 1355 | 1354 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1356 | 1355 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1357 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1356 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 1358 | 1357 | } |
| 1359 | 1358 | } |
| 1360 | 1359 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
@@ -1365,7 +1364,7 @@ discard block |
||
| 1365 | 1364 | |
| 1366 | 1365 | if (is_array($dir_path) or strlen($dir_path)) { |
| 1367 | 1366 | $tete = ""; |
| 1368 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1367 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') { |
|
| 1369 | 1368 | $tete = array_shift($path_base); |
| 1370 | 1369 | } |
| 1371 | 1370 | $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
@@ -1386,7 +1385,7 @@ discard block |
||
| 1386 | 1385 | // Et le(s) dossier(s) des squelettes nommes |
| 1387 | 1386 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1388 | 1387 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1389 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1388 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/'); |
|
| 1390 | 1389 | } |
| 1391 | 1390 | } |
| 1392 | 1391 | |
@@ -1456,9 +1455,9 @@ discard block |
||
| 1456 | 1455 | // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
| 1457 | 1456 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 1458 | 1457 | if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 1459 | - and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1458 | + and $file_svg_generique = substr($file, 0, -strlen($m[0]))."-xx.svg" |
|
| 1460 | 1459 | and $f = find_in_theme("$file_svg_generique")) { |
| 1461 | - if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1460 | + if ($fsize = substr($f, 0, -6).$m[1].".svg" and file_exists($fsize)) { |
|
| 1462 | 1461 | return $themefiles["$subdir$file"] = $fsize; |
| 1463 | 1462 | } |
| 1464 | 1463 | else { |
@@ -1472,7 +1471,7 @@ discard block |
||
| 1472 | 1471 | return $themefiles["$subdir$file"] = $f; |
| 1473 | 1472 | } |
| 1474 | 1473 | } |
| 1475 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1474 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 1476 | 1475 | |
| 1477 | 1476 | return $themefiles["$subdir$file"] = ""; |
| 1478 | 1477 | } |
@@ -1500,7 +1499,7 @@ discard block |
||
| 1500 | 1499 | function chemin_image($icone) { |
| 1501 | 1500 | static $icone_renommer; |
| 1502 | 1501 | if ($p = strpos($icone, '?')) { |
| 1503 | - $icone = substr($icone,0, $p); |
|
| 1502 | + $icone = substr($icone, 0, $p); |
|
| 1504 | 1503 | } |
| 1505 | 1504 | // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
| 1506 | 1505 | if (strpos($icone, "/") !== false and file_exists($icone)) { |
@@ -1580,8 +1579,8 @@ discard block |
||
| 1580 | 1579 | return false; |
| 1581 | 1580 | } |
| 1582 | 1581 | if ($include and !isset($inc[$dirname][$file])) { |
| 1583 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1584 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1582 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1583 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1585 | 1584 | } |
| 1586 | 1585 | |
| 1587 | 1586 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
@@ -1594,14 +1593,14 @@ discard block |
||
| 1594 | 1593 | } |
| 1595 | 1594 | |
| 1596 | 1595 | foreach (creer_chemin() as $dir) { |
| 1597 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1598 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1596 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 1597 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 1599 | 1598 | } |
| 1600 | 1599 | if ($dirs[$a]) { |
| 1601 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1600 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 1602 | 1601 | if ($include and !isset($inc[$dirname][$file])) { |
| 1603 | - include_once _ROOT_CWD . $a; |
|
| 1604 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1602 | + include_once _ROOT_CWD.$a; |
|
| 1603 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1605 | 1604 | } |
| 1606 | 1605 | if (!defined('_SAUVER_CHEMIN')) { |
| 1607 | 1606 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
@@ -1611,7 +1610,7 @@ discard block |
||
| 1611 | 1610 | define('_SAUVER_CHEMIN', true); |
| 1612 | 1611 | } |
| 1613 | 1612 | |
| 1614 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1613 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 1615 | 1614 | } |
| 1616 | 1615 | } |
| 1617 | 1616 | } |
@@ -1637,7 +1636,7 @@ discard block |
||
| 1637 | 1636 | define('_SAUVER_CHEMIN', true); |
| 1638 | 1637 | } |
| 1639 | 1638 | |
| 1640 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1639 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1641 | 1640 | } |
| 1642 | 1641 | |
| 1643 | 1642 | function clear_path_cache() { |
@@ -1706,12 +1705,12 @@ discard block |
||
| 1706 | 1705 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 1707 | 1706 | // on a pas encore inclus flock.php |
| 1708 | 1707 | if (!function_exists('preg_files')) { |
| 1709 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1708 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1710 | 1709 | } |
| 1711 | 1710 | |
| 1712 | 1711 | // Parcourir le chemin |
| 1713 | 1712 | foreach (creer_chemin() as $d) { |
| 1714 | - $f = $d . $dir; |
|
| 1713 | + $f = $d.$dir; |
|
| 1715 | 1714 | if (@is_dir($f)) { |
| 1716 | 1715 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
| 1717 | 1716 | foreach ($liste as $chemin) { |
@@ -1741,9 +1740,9 @@ discard block |
||
| 1741 | 1740 | static $autsanscookie = array('install', 'base_repair'); |
| 1742 | 1741 | |
| 1743 | 1742 | if (in_array($nom, $autsanscookie)) { |
| 1744 | - if (test_espace_prive()){ |
|
| 1743 | + if (test_espace_prive()) { |
|
| 1745 | 1744 | include_spip('base/connect_sql'); |
| 1746 | - if (!$strict or !spip_connect()){ |
|
| 1745 | + if (!$strict or !spip_connect()) { |
|
| 1747 | 1746 | return true; |
| 1748 | 1747 | } |
| 1749 | 1748 | } |
@@ -1822,7 +1821,7 @@ discard block |
||
| 1822 | 1821 | return $res; |
| 1823 | 1822 | } |
| 1824 | 1823 | // Sinon c'est un raccourci ou compat SPIP < 2 |
| 1825 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1824 | + if (!function_exists($f = 'generer_url_'.$entite)) { |
|
| 1826 | 1825 | if (!function_exists($f .= '_dist')) { |
| 1827 | 1826 | $f = ''; |
| 1828 | 1827 | } |
@@ -1831,8 +1830,8 @@ discard block |
||
| 1831 | 1830 | $url = $f($id, $args, $ancre); |
| 1832 | 1831 | if (strlen($args)) { |
| 1833 | 1832 | $url .= strstr($url, '?') |
| 1834 | - ? '&' . $args |
|
| 1835 | - : '?' . $args; |
|
| 1833 | + ? '&'.$args |
|
| 1834 | + : '?'.$args; |
|
| 1836 | 1835 | } |
| 1837 | 1836 | |
| 1838 | 1837 | return $url; |
@@ -1863,8 +1862,8 @@ discard block |
||
| 1863 | 1862 | include_spip('base/connect_sql'); |
| 1864 | 1863 | $id_type = id_table_objet($entite, $public); |
| 1865 | 1864 | |
| 1866 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1867 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1865 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1866 | + . "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1868 | 1867 | . (!$args ? '' : "&$args") |
| 1869 | 1868 | . (!$ancre ? '' : "#$ancre"); |
| 1870 | 1869 | } |
@@ -2016,7 +2015,7 @@ discard block |
||
| 2016 | 2015 | if (!empty($_SERVER['QUERY_STRING']) |
| 2017 | 2016 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2018 | 2017 | ) { |
| 2019 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2018 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2020 | 2019 | } |
| 2021 | 2020 | } |
| 2022 | 2021 | } |
@@ -2043,17 +2042,17 @@ discard block |
||
| 2043 | 2042 | list($myself) = explode('?', $myself); |
| 2044 | 2043 | // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
| 2045 | 2044 | // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
| 2046 | - if (strpos($myself,'://') !== false) { |
|
| 2047 | - $myself = explode('://',$myself); |
|
| 2045 | + if (strpos($myself, '://') !== false) { |
|
| 2046 | + $myself = explode('://', $myself); |
|
| 2048 | 2047 | array_shift($myself); |
| 2049 | - $myself = implode('://',$myself); |
|
| 2050 | - $myself = explode('/',$myself); |
|
| 2048 | + $myself = implode('://', $myself); |
|
| 2049 | + $myself = explode('/', $myself); |
|
| 2051 | 2050 | array_shift($myself); |
| 2052 | - $myself = implode('/',$myself); |
|
| 2051 | + $myself = implode('/', $myself); |
|
| 2053 | 2052 | } |
| 2054 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2053 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 2055 | 2054 | |
| 2056 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2055 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 2057 | 2056 | |
| 2058 | 2057 | return $url; |
| 2059 | 2058 | } |
@@ -2091,17 +2090,17 @@ discard block |
||
| 2091 | 2090 | **/ |
| 2092 | 2091 | function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
| 2093 | 2092 | if (!$rel) { |
| 2094 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2093 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 2095 | 2094 | } else { |
| 2096 | 2095 | if (!is_string($rel)) { |
| 2097 | 2096 | $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
| 2098 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2097 | + ('./'._SPIP_ECRIRE_SCRIPT); |
|
| 2099 | 2098 | } |
| 2100 | 2099 | } |
| 2101 | 2100 | |
| 2102 | 2101 | list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
| 2103 | 2102 | if ($script and ($script <> 'accueil' or $rel)) { |
| 2104 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2103 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 2105 | 2104 | } elseif ($args) { |
| 2106 | 2105 | $args = "?$args"; |
| 2107 | 2106 | } |
@@ -2109,7 +2108,7 @@ discard block |
||
| 2109 | 2108 | $args .= "#$ancre"; |
| 2110 | 2109 | } |
| 2111 | 2110 | |
| 2112 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2111 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2113 | 2112 | } |
| 2114 | 2113 | |
| 2115 | 2114 | // |
@@ -2179,25 +2178,25 @@ discard block |
||
| 2179 | 2178 | if (is_array($args)) { |
| 2180 | 2179 | $r = ''; |
| 2181 | 2180 | foreach ($args as $k => $v) { |
| 2182 | - $r .= '&' . $k . '=' . $v; |
|
| 2181 | + $r .= '&'.$k.'='.$v; |
|
| 2183 | 2182 | } |
| 2184 | 2183 | $args = substr($r, 1); |
| 2185 | 2184 | } |
| 2186 | 2185 | $action .= |
| 2187 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2186 | + (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 2188 | 2187 | } |
| 2189 | 2188 | if (!$no_entities) { |
| 2190 | 2189 | $action = quote_amp($action); |
| 2191 | 2190 | } |
| 2192 | 2191 | |
| 2193 | 2192 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 2194 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2193 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2195 | 2194 | } |
| 2196 | 2195 | |
| 2197 | 2196 | // https://code.spip.net/@generer_url_prive |
| 2198 | 2197 | function generer_url_prive($script, $args = "", $no_entities = false) { |
| 2199 | 2198 | |
| 2200 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2199 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 2201 | 2200 | } |
| 2202 | 2201 | |
| 2203 | 2202 | // Pour les formulaires en methode POST, |
@@ -2232,8 +2231,7 @@ discard block |
||
| 2232 | 2231 | . "><div>\n" |
| 2233 | 2232 | . "<input type='hidden' name='exec' value='$script1' />" |
| 2234 | 2233 | . $corps |
| 2235 | - . (!$submit ? '' : |
|
| 2236 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2234 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) |
|
| 2237 | 2235 | . "</div></form>\n"; |
| 2238 | 2236 | } |
| 2239 | 2237 | |
@@ -2258,14 +2256,14 @@ discard block |
||
| 2258 | 2256 | ? generer_url_ecrire(_request('exec')) |
| 2259 | 2257 | : generer_url_public(); |
| 2260 | 2258 | |
| 2261 | - return "\n<form action='" . |
|
| 2262 | - $h . |
|
| 2263 | - "'" . |
|
| 2264 | - $atts . |
|
| 2265 | - ">\n" . |
|
| 2266 | - "<div>" . |
|
| 2267 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2268 | - $corps . |
|
| 2259 | + return "\n<form action='". |
|
| 2260 | + $h. |
|
| 2261 | + "'". |
|
| 2262 | + $atts. |
|
| 2263 | + ">\n". |
|
| 2264 | + "<div>". |
|
| 2265 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 2266 | + $corps. |
|
| 2269 | 2267 | "</div></form>"; |
| 2270 | 2268 | } |
| 2271 | 2269 | |
@@ -2293,7 +2291,7 @@ discard block |
||
| 2293 | 2291 | : generer_url_public('', '', false, false); |
| 2294 | 2292 | $url = parametre_url($url, 'action', $script); |
| 2295 | 2293 | if ($args) { |
| 2296 | - $url .= quote_amp('&' . $args); |
|
| 2294 | + $url .= quote_amp('&'.$args); |
|
| 2297 | 2295 | } |
| 2298 | 2296 | |
| 2299 | 2297 | if ($no_entities) { |
@@ -2343,17 +2341,17 @@ discard block |
||
| 2343 | 2341 | |
| 2344 | 2342 | // le nom du repertoire plugins/ activables/desactivables |
| 2345 | 2343 | if (!defined('_DIR_PLUGINS')) { |
| 2346 | - define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2344 | + define('_DIR_PLUGINS', _DIR_RACINE."plugins/"); |
|
| 2347 | 2345 | } |
| 2348 | 2346 | |
| 2349 | 2347 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 2350 | 2348 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 2351 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2349 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/"); |
|
| 2352 | 2350 | } |
| 2353 | 2351 | |
| 2354 | 2352 | // le nom du repertoire des librairies |
| 2355 | 2353 | if (!defined('_DIR_LIB')) { |
| 2356 | - define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2354 | + define('_DIR_LIB', _DIR_RACINE."lib/"); |
|
| 2357 | 2355 | } |
| 2358 | 2356 | |
| 2359 | 2357 | if (!defined('_DIR_IMG')) { |
@@ -2363,29 +2361,29 @@ discard block |
||
| 2363 | 2361 | define('_DIR_LOGOS', $pa); |
| 2364 | 2362 | } |
| 2365 | 2363 | if (!defined('_DIR_IMG_ICONES')) { |
| 2366 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2364 | + define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/"); |
|
| 2367 | 2365 | } |
| 2368 | 2366 | |
| 2369 | 2367 | if (!defined('_DIR_DUMP')) { |
| 2370 | - define('_DIR_DUMP', $ti . "dump/"); |
|
| 2368 | + define('_DIR_DUMP', $ti."dump/"); |
|
| 2371 | 2369 | } |
| 2372 | 2370 | if (!defined('_DIR_SESSIONS')) { |
| 2373 | - define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2371 | + define('_DIR_SESSIONS', $ti."sessions/"); |
|
| 2374 | 2372 | } |
| 2375 | 2373 | if (!defined('_DIR_TRANSFERT')) { |
| 2376 | - define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2374 | + define('_DIR_TRANSFERT', $ti."upload/"); |
|
| 2377 | 2375 | } |
| 2378 | 2376 | if (!defined('_DIR_CACHE')) { |
| 2379 | - define('_DIR_CACHE', $ti . "cache/"); |
|
| 2377 | + define('_DIR_CACHE', $ti."cache/"); |
|
| 2380 | 2378 | } |
| 2381 | 2379 | if (!defined('_DIR_CACHE_XML')) { |
| 2382 | - define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2380 | + define('_DIR_CACHE_XML', _DIR_CACHE."xml/"); |
|
| 2383 | 2381 | } |
| 2384 | 2382 | if (!defined('_DIR_SKELS')) { |
| 2385 | - define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2383 | + define('_DIR_SKELS', _DIR_CACHE."skel/"); |
|
| 2386 | 2384 | } |
| 2387 | 2385 | if (!defined('_DIR_AIDE')) { |
| 2388 | - define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2386 | + define('_DIR_AIDE', _DIR_CACHE."aide/"); |
|
| 2389 | 2387 | } |
| 2390 | 2388 | if (!defined('_DIR_TMP')) { |
| 2391 | 2389 | define('_DIR_TMP', $ti); |
@@ -2415,27 +2413,27 @@ discard block |
||
| 2415 | 2413 | // Declaration des fichiers |
| 2416 | 2414 | |
| 2417 | 2415 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 2418 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2416 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php"); |
|
| 2419 | 2417 | } |
| 2420 | 2418 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 2421 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2419 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php"); |
|
| 2422 | 2420 | } |
| 2423 | 2421 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 2424 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2422 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php"); |
|
| 2425 | 2423 | } |
| 2426 | 2424 | if (!defined('_CACHE_PIPELINES')) { |
| 2427 | - define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2425 | + define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 2428 | 2426 | } |
| 2429 | 2427 | if (!defined('_CACHE_CHEMIN')) { |
| 2430 | - define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2428 | + define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 2431 | 2429 | } |
| 2432 | 2430 | |
| 2433 | 2431 | # attention .php obligatoire pour ecrire_fichier_securise |
| 2434 | 2432 | if (!defined('_FILE_META')) { |
| 2435 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2433 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 2436 | 2434 | } |
| 2437 | 2435 | if (!defined('_DIR_LOG')) { |
| 2438 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2436 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 2439 | 2437 | } |
| 2440 | 2438 | if (!defined('_FILE_LOG')) { |
| 2441 | 2439 | define('_FILE_LOG', 'spip'); |
@@ -2451,8 +2449,8 @@ discard block |
||
| 2451 | 2449 | } |
| 2452 | 2450 | if (!defined('_FILE_CONNECT')) { |
| 2453 | 2451 | define('_FILE_CONNECT', |
| 2454 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2455 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2452 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 2453 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 2456 | 2454 | : false))); |
| 2457 | 2455 | } |
| 2458 | 2456 | |
@@ -2462,7 +2460,7 @@ discard block |
||
| 2462 | 2460 | } |
| 2463 | 2461 | if (!defined('_FILE_CHMOD')) { |
| 2464 | 2462 | define('_FILE_CHMOD', |
| 2465 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2463 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 2466 | 2464 | : false)); |
| 2467 | 2465 | } |
| 2468 | 2466 | |
@@ -2474,10 +2472,10 @@ discard block |
||
| 2474 | 2472 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 2475 | 2473 | } |
| 2476 | 2474 | if (!defined('_FILE_CONNECT_TMP')) { |
| 2477 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2475 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 2478 | 2476 | } |
| 2479 | 2477 | if (!defined('_FILE_CHMOD_TMP')) { |
| 2480 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2478 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 2481 | 2479 | } |
| 2482 | 2480 | |
| 2483 | 2481 | // Definition des droits d'acces en ecriture |
@@ -2495,13 +2493,13 @@ discard block |
||
| 2495 | 2493 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 2496 | 2494 | } |
| 2497 | 2495 | if (!defined('_ROOT_PLUGINS')) { |
| 2498 | - define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2496 | + define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/"); |
|
| 2499 | 2497 | } |
| 2500 | 2498 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 2501 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2499 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/"); |
|
| 2502 | 2500 | } |
| 2503 | 2501 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 2504 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2502 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2505 | 2503 | } |
| 2506 | 2504 | |
| 2507 | 2505 | // La taille des Log |
@@ -2538,7 +2536,7 @@ discard block |
||
| 2538 | 2536 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 2539 | 2537 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 2540 | 2538 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 2541 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2539 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 2542 | 2540 | |
| 2543 | 2541 | // charger tout de suite le path et son cache |
| 2544 | 2542 | load_path_cache(); |
@@ -2585,7 +2583,7 @@ discard block |
||
| 2585 | 2583 | if (!empty($_SERVER['QUERY_STRING']) |
| 2586 | 2584 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2587 | 2585 | ) { |
| 2588 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2586 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2589 | 2587 | } |
| 2590 | 2588 | } |
| 2591 | 2589 | |
@@ -2621,7 +2619,7 @@ discard block |
||
| 2621 | 2619 | |
| 2622 | 2620 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 2623 | 2621 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 2624 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2622 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '').'/'; |
|
| 2625 | 2623 | } else { |
| 2626 | 2624 | $uri_ref = ""; |
| 2627 | 2625 | } |
@@ -2709,7 +2707,7 @@ discard block |
||
| 2709 | 2707 | } |
| 2710 | 2708 | if (!defined('_CACHE_RUBRIQUES')) { |
| 2711 | 2709 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 2712 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2710 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2713 | 2711 | } |
| 2714 | 2712 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 2715 | 2713 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -2808,7 +2806,7 @@ discard block |
||
| 2808 | 2806 | $memory *= 1024; |
| 2809 | 2807 | } |
| 2810 | 2808 | if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
| 2811 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2809 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M'); |
|
| 2812 | 2810 | if (trim(ini_get('memory_limit')) != $m) { |
| 2813 | 2811 | if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
| 2814 | 2812 | define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
@@ -2958,7 +2956,7 @@ discard block |
||
| 2958 | 2956 | } |
| 2959 | 2957 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 2960 | 2958 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 2961 | - . " " . _VAR_MODE); |
|
| 2959 | + . " "._VAR_MODE); |
|
| 2962 | 2960 | } |
| 2963 | 2961 | } // pas autorise ? |
| 2964 | 2962 | else { |
@@ -2971,7 +2969,7 @@ discard block |
||
| 2971 | 2969 | if (strpos($self, 'page=login') === false) { |
| 2972 | 2970 | include_spip('inc/headers'); |
| 2973 | 2971 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 2974 | - redirige_par_entete(generer_url_public('login','url=' . rawurlencode($redirect), true)); |
|
| 2972 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 2975 | 2973 | } |
| 2976 | 2974 | } |
| 2977 | 2975 | // sinon tant pis |
@@ -3015,10 +3013,10 @@ discard block |
||
| 3015 | 3013 | // mais on risque de perturber des plugins en initialisant trop tot |
| 3016 | 3014 | // certaines constantes |
| 3017 | 3015 | @spip_initialisation_core( |
| 3018 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3019 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3020 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3021 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3016 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 3017 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 3018 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3019 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3022 | 3020 | ); |
| 3023 | 3021 | |
| 3024 | 3022 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -3051,7 +3049,7 @@ discard block |
||
| 3051 | 3049 | } |
| 3052 | 3050 | |
| 3053 | 3051 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
| 3054 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3052 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 3055 | 3053 | |
| 3056 | 3054 | $session = charger_fonction('session', 'inc'); |
| 3057 | 3055 | if ($session()) { |
@@ -3131,7 +3129,7 @@ discard block |
||
| 3131 | 3129 | $s = pipeline('definir_session', |
| 3132 | 3130 | $GLOBALS['visiteur_session'] |
| 3133 | 3131 | ? serialize($GLOBALS['visiteur_session']) |
| 3134 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3132 | + . '_'.@$_COOKIE['spip_session'] |
|
| 3135 | 3133 | : '' |
| 3136 | 3134 | ); |
| 3137 | 3135 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -3287,12 +3285,12 @@ discard block |
||
| 3287 | 3285 | $GLOBALS['_INC_PUBLIC']++; |
| 3288 | 3286 | |
| 3289 | 3287 | // fix #4235 |
| 3290 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3288 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3291 | 3289 | |
| 3292 | 3290 | |
| 3293 | 3291 | foreach (is_array($fond) ? $fond : array($fond) as $f) { |
| 3294 | 3292 | |
| 3295 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3293 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3296 | 3294 | |
| 3297 | 3295 | $page = evaluer_fond($f, $contexte, $connect); |
| 3298 | 3296 | if ($page === '') { |
@@ -3331,7 +3329,7 @@ discard block |
||
| 3331 | 3329 | } |
| 3332 | 3330 | |
| 3333 | 3331 | // contamination de la session appelante, pour les inclusions statiques |
| 3334 | - if (isset($page['invalideurs']['session'])){ |
|
| 3332 | + if (isset($page['invalideurs']['session'])) { |
|
| 3335 | 3333 | $cache_utilise_session_appelant = $page['invalideurs']['session']; |
| 3336 | 3334 | } |
| 3337 | 3335 | } |
@@ -3377,7 +3375,7 @@ discard block |
||
| 3377 | 3375 | * @return array|string |
| 3378 | 3376 | */ |
| 3379 | 3377 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3380 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3378 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 3381 | 3379 | if (!$pathinfo) { |
| 3382 | 3380 | return $f; |
| 3383 | 3381 | } |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -47,26 +47,26 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | **/ |
| 49 | 49 | function liste_plugin_files($dir_plugins = null) { |
| 50 | - static $plugin_files = array(); |
|
| 51 | - if (is_null($dir_plugins)) { |
|
| 52 | - $dir_plugins = _DIR_PLUGINS; |
|
| 53 | - } |
|
| 54 | - if (!isset($plugin_files[$dir_plugins]) |
|
| 55 | - or count($plugin_files[$dir_plugins]) == 0 |
|
| 56 | - ) { |
|
| 57 | - $plugin_files[$dir_plugins] = array(); |
|
| 58 | - foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 59 | - $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - sort($plugin_files[$dir_plugins]); |
|
| 63 | - // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 64 | - // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 65 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 66 | - $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - return $plugin_files[$dir_plugins]; |
|
| 50 | + static $plugin_files = array(); |
|
| 51 | + if (is_null($dir_plugins)) { |
|
| 52 | + $dir_plugins = _DIR_PLUGINS; |
|
| 53 | + } |
|
| 54 | + if (!isset($plugin_files[$dir_plugins]) |
|
| 55 | + or count($plugin_files[$dir_plugins]) == 0 |
|
| 56 | + ) { |
|
| 57 | + $plugin_files[$dir_plugins] = array(); |
|
| 58 | + foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 59 | + $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + sort($plugin_files[$dir_plugins]); |
|
| 63 | + // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 64 | + // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 65 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 66 | + $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + return $plugin_files[$dir_plugins]; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -82,44 +82,44 @@ discard block |
||
| 82 | 82 | * Liste complète des répeertoires |
| 83 | 83 | **/ |
| 84 | 84 | function fast_find_plugin_dirs($dir, $max_prof = 100) { |
| 85 | - $fichiers = array(); |
|
| 86 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 87 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 88 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 89 | - if ($dir == '') { |
|
| 90 | - $dir = '.'; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if (!is_dir($dir)) { |
|
| 94 | - return $fichiers; |
|
| 95 | - } |
|
| 96 | - if (is_plugin_dir($dir, '')) { |
|
| 97 | - $fichiers[] = $dir; |
|
| 98 | - |
|
| 99 | - return $fichiers; |
|
| 100 | - } |
|
| 101 | - if ($max_prof <= 0) { |
|
| 102 | - return $fichiers; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $subdirs = array(); |
|
| 106 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 107 | - while (($f = readdir($d)) !== false) { |
|
| 108 | - if ($f[0] != '.' # ignorer . .. .svn etc |
|
| 109 | - and $f != 'CVS' |
|
| 110 | - and is_dir($f = "$dir/$f") |
|
| 111 | - ) { |
|
| 112 | - $subdirs[] = $f; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - closedir($d); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - foreach ($subdirs as $d) { |
|
| 119 | - $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - return $fichiers; |
|
| 85 | + $fichiers = array(); |
|
| 86 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 87 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 88 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 89 | + if ($dir == '') { |
|
| 90 | + $dir = '.'; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if (!is_dir($dir)) { |
|
| 94 | + return $fichiers; |
|
| 95 | + } |
|
| 96 | + if (is_plugin_dir($dir, '')) { |
|
| 97 | + $fichiers[] = $dir; |
|
| 98 | + |
|
| 99 | + return $fichiers; |
|
| 100 | + } |
|
| 101 | + if ($max_prof <= 0) { |
|
| 102 | + return $fichiers; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $subdirs = array(); |
|
| 106 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 107 | + while (($f = readdir($d)) !== false) { |
|
| 108 | + if ($f[0] != '.' # ignorer . .. .svn etc |
|
| 109 | + and $f != 'CVS' |
|
| 110 | + and is_dir($f = "$dir/$f") |
|
| 111 | + ) { |
|
| 112 | + $subdirs[] = $f; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + closedir($d); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + foreach ($subdirs as $d) { |
|
| 119 | + $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + return $fichiers; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -140,27 +140,27 @@ discard block |
||
| 140 | 140 | **/ |
| 141 | 141 | function is_plugin_dir($dir, $dir_plugins = null) { |
| 142 | 142 | |
| 143 | - if (is_array($dir)) { |
|
| 144 | - foreach ($dir as $k => $d) { |
|
| 145 | - if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 146 | - unset($dir[$k]); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - return $dir; |
|
| 151 | - } |
|
| 152 | - if (is_null($dir_plugins)) { |
|
| 153 | - $dir_plugins = _DIR_PLUGINS; |
|
| 154 | - } |
|
| 155 | - $search = array("$dir_plugins$dir/paquet.xml"); |
|
| 156 | - |
|
| 157 | - foreach ($search as $s) { |
|
| 158 | - if (file_exists($s)) { |
|
| 159 | - return $dir; |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - return ''; |
|
| 143 | + if (is_array($dir)) { |
|
| 144 | + foreach ($dir as $k => $d) { |
|
| 145 | + if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 146 | + unset($dir[$k]); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + return $dir; |
|
| 151 | + } |
|
| 152 | + if (is_null($dir_plugins)) { |
|
| 153 | + $dir_plugins = _DIR_PLUGINS; |
|
| 154 | + } |
|
| 155 | + $search = array("$dir_plugins$dir/paquet.xml"); |
|
| 156 | + |
|
| 157 | + foreach ($search as $s) { |
|
| 158 | + if (file_exists($s)) { |
|
| 159 | + return $dir; |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + return ''; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** Regexp d'extraction des informations d'un intervalle de compatibilité */ |
@@ -187,51 +187,51 @@ discard block |
||
| 187 | 187 | **/ |
| 188 | 188 | function plugin_version_compatible($intervalle, $version, $avec_quoi = '') { |
| 189 | 189 | |
| 190 | - if (!strlen($intervalle)) { |
|
| 191 | - return true; |
|
| 192 | - } |
|
| 193 | - if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 194 | - return false; |
|
| 195 | - } |
|
| 196 | - // Extraction des bornes et traitement de * pour la borne sup : |
|
| 197 | - // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 198 | - $minimum = $regs[1]; |
|
| 199 | - $maximum = $regs[2]; |
|
| 200 | - |
|
| 201 | - // si une version SPIP de compatibilité a été définie (dans |
|
| 202 | - // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 203 | - // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 204 | - // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 205 | - // entre plugins) |
|
| 206 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 207 | - if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 208 | - return true; |
|
| 209 | - } |
|
| 210 | - // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 211 | - // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - $minimum_inc = $intervalle[0] == "["; |
|
| 215 | - $maximum_inc = substr($intervalle, -1) == "]"; |
|
| 216 | - |
|
| 217 | - if (strlen($minimum)) { |
|
| 218 | - if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 219 | - return false; |
|
| 220 | - } |
|
| 221 | - if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 222 | - return false; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - if (strlen($maximum)) { |
|
| 226 | - if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 227 | - return false; |
|
| 228 | - } |
|
| 229 | - if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 230 | - return false; |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return true; |
|
| 190 | + if (!strlen($intervalle)) { |
|
| 191 | + return true; |
|
| 192 | + } |
|
| 193 | + if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 194 | + return false; |
|
| 195 | + } |
|
| 196 | + // Extraction des bornes et traitement de * pour la borne sup : |
|
| 197 | + // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 198 | + $minimum = $regs[1]; |
|
| 199 | + $maximum = $regs[2]; |
|
| 200 | + |
|
| 201 | + // si une version SPIP de compatibilité a été définie (dans |
|
| 202 | + // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 203 | + // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 204 | + // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 205 | + // entre plugins) |
|
| 206 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 207 | + if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 208 | + return true; |
|
| 209 | + } |
|
| 210 | + // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 211 | + // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + $minimum_inc = $intervalle[0] == "["; |
|
| 215 | + $maximum_inc = substr($intervalle, -1) == "]"; |
|
| 216 | + |
|
| 217 | + if (strlen($minimum)) { |
|
| 218 | + if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 221 | + if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 222 | + return false; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + if (strlen($maximum)) { |
|
| 226 | + if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 227 | + return false; |
|
| 228 | + } |
|
| 229 | + if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 230 | + return false; |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + return true; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -248,62 +248,62 @@ discard block |
||
| 248 | 248 | * @return array |
| 249 | 249 | */ |
| 250 | 250 | function liste_plugin_valides($liste_plug, $force = false) { |
| 251 | - $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 252 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 253 | - $infos = array( |
|
| 254 | - // lister les extensions qui sont automatiquement actives |
|
| 255 | - '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 256 | - '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 257 | - ); |
|
| 258 | - |
|
| 259 | - // creer une premiere liste non ordonnee mais qui ne retient |
|
| 260 | - // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 261 | - $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 262 | - $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 263 | - $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array(); |
|
| 264 | - $liste_non_classee = array( |
|
| 265 | - 'SPIP' => array( |
|
| 266 | - 'nom' => 'SPIP', |
|
| 267 | - 'etat' => 'stable', |
|
| 268 | - 'version' => $GLOBALS['spip_version_branche'], |
|
| 269 | - 'dir_type' => '_DIR_RESTREINT', |
|
| 270 | - 'dir' => '', |
|
| 271 | - ) |
|
| 272 | - ); |
|
| 273 | - |
|
| 274 | - $invalides = array(); |
|
| 275 | - foreach ($liste_ext as $plug) { |
|
| 276 | - if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 277 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - foreach ($liste_plug as $plug) { |
|
| 281 | - if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 282 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 283 | - if (is_array($r)) { |
|
| 284 | - $invalides = array_merge($invalides, $r); |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 290 | - $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 291 | - foreach ($liste_plug as $plug) { |
|
| 292 | - if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 293 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 294 | - if (is_array($r)) { |
|
| 295 | - $invalides = array_merge($invalides, $r); |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - plugin_fixer_procure($liste_non_classee, $infos); |
|
| 302 | - |
|
| 303 | - // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 304 | - $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 305 | - |
|
| 306 | - return array($infos, $liste_non_classee, $invalides); |
|
| 251 | + $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 252 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 253 | + $infos = array( |
|
| 254 | + // lister les extensions qui sont automatiquement actives |
|
| 255 | + '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 256 | + '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 257 | + ); |
|
| 258 | + |
|
| 259 | + // creer une premiere liste non ordonnee mais qui ne retient |
|
| 260 | + // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 261 | + $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 262 | + $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 263 | + $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array(); |
|
| 264 | + $liste_non_classee = array( |
|
| 265 | + 'SPIP' => array( |
|
| 266 | + 'nom' => 'SPIP', |
|
| 267 | + 'etat' => 'stable', |
|
| 268 | + 'version' => $GLOBALS['spip_version_branche'], |
|
| 269 | + 'dir_type' => '_DIR_RESTREINT', |
|
| 270 | + 'dir' => '', |
|
| 271 | + ) |
|
| 272 | + ); |
|
| 273 | + |
|
| 274 | + $invalides = array(); |
|
| 275 | + foreach ($liste_ext as $plug) { |
|
| 276 | + if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 277 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + foreach ($liste_plug as $plug) { |
|
| 281 | + if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 282 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 283 | + if (is_array($r)) { |
|
| 284 | + $invalides = array_merge($invalides, $r); |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 290 | + $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 291 | + foreach ($liste_plug as $plug) { |
|
| 292 | + if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 293 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 294 | + if (is_array($r)) { |
|
| 295 | + $invalides = array_merge($invalides, $r); |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + plugin_fixer_procure($liste_non_classee, $infos); |
|
| 302 | + |
|
| 303 | + // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 304 | + $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 305 | + |
|
| 306 | + return array($infos, $liste_non_classee, $invalides); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -323,29 +323,29 @@ discard block |
||
| 323 | 323 | * array description short si on ne le retient pas (pour memorisation dans une table des erreurs) |
| 324 | 324 | */ |
| 325 | 325 | function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) { |
| 326 | - $i = $infos[$dir_type][$plug]; |
|
| 327 | - $p = strtoupper($i['prefix']); |
|
| 328 | - $short_desc = array( |
|
| 329 | - 'nom' => $i['nom'], |
|
| 330 | - 'etat' => $i['etat'], |
|
| 331 | - 'version' => $i['version'], |
|
| 332 | - 'dir' => $plug, |
|
| 333 | - 'dir_type' => $dir_type |
|
| 334 | - ); |
|
| 335 | - if (isset($i['erreur']) and $i['erreur']) { |
|
| 336 | - $short_desc['erreur'] = $i['erreur']; |
|
| 337 | - return array($p=>$short_desc); |
|
| 338 | - } |
|
| 339 | - if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 340 | - return array($p=>$short_desc); |
|
| 341 | - } |
|
| 342 | - if (!isset($liste[$p]) |
|
| 343 | - or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 344 | - ) { |
|
| 345 | - $liste[$p] = $short_desc; |
|
| 346 | - } |
|
| 347 | - // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 348 | - return $p; |
|
| 326 | + $i = $infos[$dir_type][$plug]; |
|
| 327 | + $p = strtoupper($i['prefix']); |
|
| 328 | + $short_desc = array( |
|
| 329 | + 'nom' => $i['nom'], |
|
| 330 | + 'etat' => $i['etat'], |
|
| 331 | + 'version' => $i['version'], |
|
| 332 | + 'dir' => $plug, |
|
| 333 | + 'dir_type' => $dir_type |
|
| 334 | + ); |
|
| 335 | + if (isset($i['erreur']) and $i['erreur']) { |
|
| 336 | + $short_desc['erreur'] = $i['erreur']; |
|
| 337 | + return array($p=>$short_desc); |
|
| 338 | + } |
|
| 339 | + if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 340 | + return array($p=>$short_desc); |
|
| 341 | + } |
|
| 342 | + if (!isset($liste[$p]) |
|
| 343 | + or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 344 | + ) { |
|
| 345 | + $liste[$p] = $short_desc; |
|
| 346 | + } |
|
| 347 | + // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 348 | + return $p; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -361,46 +361,46 @@ discard block |
||
| 361 | 361 | * @param array $infos |
| 362 | 362 | */ |
| 363 | 363 | function plugin_fixer_procure(&$liste, &$infos) { |
| 364 | - foreach ($liste as $p => $resume) { |
|
| 365 | - $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 366 | - if (isset($i['procure']) and $i['procure']) { |
|
| 367 | - foreach ($i['procure'] as $procure) { |
|
| 368 | - $p = strtoupper($procure['nom']); |
|
| 369 | - $dir = $resume['dir']; |
|
| 370 | - if ($dir) { |
|
| 371 | - $dir .= "/"; |
|
| 372 | - } |
|
| 373 | - $dir .= "procure:" . $procure['nom']; |
|
| 374 | - |
|
| 375 | - $procure['etat'] = '?'; |
|
| 376 | - $procure['dir_type'] = $resume['dir_type']; |
|
| 377 | - $procure['dir'] = $dir; |
|
| 378 | - |
|
| 379 | - // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 380 | - // on ajoute cette version a la liste |
|
| 381 | - if (!isset($liste[$p]) |
|
| 382 | - or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 383 | - ) { |
|
| 384 | - $liste[$p] = $procure; |
|
| 385 | - |
|
| 386 | - // on fournit une information minimale pour ne pas perturber la compilation |
|
| 387 | - $infos[$resume['dir_type']][$dir] = array( |
|
| 388 | - 'prefix' => $procure['nom'], |
|
| 389 | - 'nom' => $procure['nom'], |
|
| 390 | - 'etat' => $procure['etat'], |
|
| 391 | - 'version' => $procure['version'], |
|
| 392 | - 'chemin' => array(), |
|
| 393 | - 'necessite' => array(), |
|
| 394 | - 'utilise' => array(), |
|
| 395 | - 'lib' => array(), |
|
| 396 | - 'menu' => array(), |
|
| 397 | - 'onglet' => array(), |
|
| 398 | - 'procure' => array(), |
|
| 399 | - ); |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - } |
|
| 364 | + foreach ($liste as $p => $resume) { |
|
| 365 | + $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 366 | + if (isset($i['procure']) and $i['procure']) { |
|
| 367 | + foreach ($i['procure'] as $procure) { |
|
| 368 | + $p = strtoupper($procure['nom']); |
|
| 369 | + $dir = $resume['dir']; |
|
| 370 | + if ($dir) { |
|
| 371 | + $dir .= "/"; |
|
| 372 | + } |
|
| 373 | + $dir .= "procure:" . $procure['nom']; |
|
| 374 | + |
|
| 375 | + $procure['etat'] = '?'; |
|
| 376 | + $procure['dir_type'] = $resume['dir_type']; |
|
| 377 | + $procure['dir'] = $dir; |
|
| 378 | + |
|
| 379 | + // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 380 | + // on ajoute cette version a la liste |
|
| 381 | + if (!isset($liste[$p]) |
|
| 382 | + or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 383 | + ) { |
|
| 384 | + $liste[$p] = $procure; |
|
| 385 | + |
|
| 386 | + // on fournit une information minimale pour ne pas perturber la compilation |
|
| 387 | + $infos[$resume['dir_type']][$dir] = array( |
|
| 388 | + 'prefix' => $procure['nom'], |
|
| 389 | + 'nom' => $procure['nom'], |
|
| 390 | + 'etat' => $procure['etat'], |
|
| 391 | + 'version' => $procure['version'], |
|
| 392 | + 'chemin' => array(), |
|
| 393 | + 'necessite' => array(), |
|
| 394 | + 'utilise' => array(), |
|
| 395 | + 'lib' => array(), |
|
| 396 | + 'menu' => array(), |
|
| 397 | + 'onglet' => array(), |
|
| 398 | + 'procure' => array(), |
|
| 399 | + ); |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -414,19 +414,19 @@ discard block |
||
| 414 | 414 | * @return array |
| 415 | 415 | */ |
| 416 | 416 | function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) { |
| 417 | - foreach ($liste as $prefix => $infos) { |
|
| 418 | - if (!$dir_plugins |
|
| 419 | - or ( |
|
| 420 | - defined($infos['dir_type']) |
|
| 421 | - and constant($infos['dir_type']) == $dir_plugins) |
|
| 422 | - ) { |
|
| 423 | - $liste[$prefix] = $infos['dir']; |
|
| 424 | - } else { |
|
| 425 | - unset($liste[$prefix]); |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - return $liste; |
|
| 417 | + foreach ($liste as $prefix => $infos) { |
|
| 418 | + if (!$dir_plugins |
|
| 419 | + or ( |
|
| 420 | + defined($infos['dir_type']) |
|
| 421 | + and constant($infos['dir_type']) == $dir_plugins) |
|
| 422 | + ) { |
|
| 423 | + $liste[$prefix] = $infos['dir']; |
|
| 424 | + } else { |
|
| 425 | + unset($liste[$prefix]); |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + return $liste; |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -441,9 +441,9 @@ discard block |
||
| 441 | 441 | * @return array |
| 442 | 442 | */ |
| 443 | 443 | function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) { |
| 444 | - include_spip('plugins/installer'); |
|
| 444 | + include_spip('plugins/installer'); |
|
| 445 | 445 | |
| 446 | - return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 446 | + return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -474,53 +474,53 @@ discard block |
||
| 474 | 474 | * qui n'ont pas satisfait leurs dépendances |
| 475 | 475 | **/ |
| 476 | 476 | function plugin_trier($infos, $liste_non_classee) { |
| 477 | - $toute_la_liste = $liste_non_classee; |
|
| 478 | - $liste = $ordre = array(); |
|
| 479 | - $count = 0; |
|
| 480 | - |
|
| 481 | - while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 482 | - #echo "tour::";var_dump($liste_non_classee); |
|
| 483 | - $count = $c; |
|
| 484 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 485 | - $plug = $resume['dir']; |
|
| 486 | - $dir_type = $resume['dir_type']; |
|
| 487 | - $info1 = $infos[$dir_type][$plug]; |
|
| 488 | - // si des plugins sont necessaires, |
|
| 489 | - // on ne peut inserer qu'apres eux |
|
| 490 | - foreach ($info1['necessite'] as $need) { |
|
| 491 | - $nom = strtoupper($need['nom']); |
|
| 492 | - $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 493 | - if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 494 | - $info1 = false; |
|
| 495 | - break; |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - if (!$info1) { |
|
| 499 | - continue; |
|
| 500 | - } |
|
| 501 | - // idem si des plugins sont utiles, |
|
| 502 | - // sauf si ils sont de toute facon absents de la liste |
|
| 503 | - foreach ($info1['utilise'] as $need) { |
|
| 504 | - $nom = strtoupper($need['nom']); |
|
| 505 | - $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 506 | - if (isset($toute_la_liste[$nom])) { |
|
| 507 | - if (!isset($liste[$nom]) or |
|
| 508 | - !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 509 | - ) { |
|
| 510 | - $info1 = false; |
|
| 511 | - break; |
|
| 512 | - } |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - if ($info1) { |
|
| 516 | - $ordre[$p] = $info1; |
|
| 517 | - $liste[$p] = $liste_non_classee[$p]; |
|
| 518 | - unset($liste_non_classee[$p]); |
|
| 519 | - } |
|
| 520 | - } |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - return array($liste, $ordre, $liste_non_classee); |
|
| 477 | + $toute_la_liste = $liste_non_classee; |
|
| 478 | + $liste = $ordre = array(); |
|
| 479 | + $count = 0; |
|
| 480 | + |
|
| 481 | + while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 482 | + #echo "tour::";var_dump($liste_non_classee); |
|
| 483 | + $count = $c; |
|
| 484 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 485 | + $plug = $resume['dir']; |
|
| 486 | + $dir_type = $resume['dir_type']; |
|
| 487 | + $info1 = $infos[$dir_type][$plug]; |
|
| 488 | + // si des plugins sont necessaires, |
|
| 489 | + // on ne peut inserer qu'apres eux |
|
| 490 | + foreach ($info1['necessite'] as $need) { |
|
| 491 | + $nom = strtoupper($need['nom']); |
|
| 492 | + $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 493 | + if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 494 | + $info1 = false; |
|
| 495 | + break; |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + if (!$info1) { |
|
| 499 | + continue; |
|
| 500 | + } |
|
| 501 | + // idem si des plugins sont utiles, |
|
| 502 | + // sauf si ils sont de toute facon absents de la liste |
|
| 503 | + foreach ($info1['utilise'] as $need) { |
|
| 504 | + $nom = strtoupper($need['nom']); |
|
| 505 | + $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 506 | + if (isset($toute_la_liste[$nom])) { |
|
| 507 | + if (!isset($liste[$nom]) or |
|
| 508 | + !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 509 | + ) { |
|
| 510 | + $info1 = false; |
|
| 511 | + break; |
|
| 512 | + } |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + if ($info1) { |
|
| 516 | + $ordre[$p] = $info1; |
|
| 517 | + $liste[$p] = $liste_non_classee[$p]; |
|
| 518 | + unset($liste_non_classee[$p]); |
|
| 519 | + } |
|
| 520 | + } |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + return array($liste, $ordre, $liste_non_classee); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
@@ -537,40 +537,40 @@ discard block |
||
| 537 | 537 | * Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent |
| 538 | 538 | **/ |
| 539 | 539 | function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = array()) { |
| 540 | - static $erreurs = array(); |
|
| 541 | - |
|
| 542 | - if (!is_array($liste)) { |
|
| 543 | - $liste = array(); |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 547 | - $liste = array_diff_key($liste, $liste_non_classee); |
|
| 548 | - |
|
| 549 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 550 | - $dir_type = $resume['dir_type']; |
|
| 551 | - $plug = $resume['dir']; |
|
| 552 | - $k = $infos[$dir_type][$plug]; |
|
| 553 | - |
|
| 554 | - $plug = constant($dir_type) . $plug; |
|
| 555 | - if (!isset($msg[$p])) { |
|
| 556 | - if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 557 | - $msg[$p] = array($resume['erreur']); |
|
| 558 | - } |
|
| 559 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 560 | - $msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')); |
|
| 561 | - } |
|
| 562 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 563 | - $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 564 | - } |
|
| 565 | - } else { |
|
| 566 | - foreach ($msg[$p] as $c => $l) { |
|
| 567 | - $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - $erreurs[$plug] = $msg[$p]; |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 540 | + static $erreurs = array(); |
|
| 541 | + |
|
| 542 | + if (!is_array($liste)) { |
|
| 543 | + $liste = array(); |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 547 | + $liste = array_diff_key($liste, $liste_non_classee); |
|
| 548 | + |
|
| 549 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 550 | + $dir_type = $resume['dir_type']; |
|
| 551 | + $plug = $resume['dir']; |
|
| 552 | + $k = $infos[$dir_type][$plug]; |
|
| 553 | + |
|
| 554 | + $plug = constant($dir_type) . $plug; |
|
| 555 | + if (!isset($msg[$p])) { |
|
| 556 | + if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 557 | + $msg[$p] = array($resume['erreur']); |
|
| 558 | + } |
|
| 559 | + elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 560 | + $msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')); |
|
| 561 | + } |
|
| 562 | + elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 563 | + $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 564 | + } |
|
| 565 | + } else { |
|
| 566 | + foreach ($msg[$p] as $c => $l) { |
|
| 567 | + $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + $erreurs[$plug] = $msg[$p]; |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | /** |
@@ -585,25 +585,25 @@ discard block |
||
| 585 | 585 | * - Liste des erreurs ou code HTML des erreurs |
| 586 | 586 | **/ |
| 587 | 587 | function plugin_donne_erreurs($raw = false, $raz = true) { |
| 588 | - if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 589 | - return $raw ? array() : ''; |
|
| 590 | - } |
|
| 591 | - $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 592 | - // Compat ancienne version |
|
| 593 | - if (!$list) { |
|
| 594 | - $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 595 | - } elseif (!$raw) { |
|
| 596 | - foreach ($list as $plug => $msg) { |
|
| 597 | - $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 598 | - . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>"; |
|
| 599 | - } |
|
| 600 | - $list = "<ul>" . join("\n", $list) . "</ul>"; |
|
| 601 | - } |
|
| 602 | - if ($raz) { |
|
| 603 | - effacer_meta('plugin_erreur_activation'); |
|
| 604 | - } |
|
| 605 | - |
|
| 606 | - return $list; |
|
| 588 | + if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 589 | + return $raw ? array() : ''; |
|
| 590 | + } |
|
| 591 | + $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 592 | + // Compat ancienne version |
|
| 593 | + if (!$list) { |
|
| 594 | + $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 595 | + } elseif (!$raw) { |
|
| 596 | + foreach ($list as $plug => $msg) { |
|
| 597 | + $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 598 | + . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>"; |
|
| 599 | + } |
|
| 600 | + $list = "<ul>" . join("\n", $list) . "</ul>"; |
|
| 601 | + } |
|
| 602 | + if ($raz) { |
|
| 603 | + effacer_meta('plugin_erreur_activation'); |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + return $list; |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
@@ -623,21 +623,21 @@ discard block |
||
| 623 | 623 | * |
| 624 | 624 | **/ |
| 625 | 625 | function plugin_necessite($n, $liste, $balise = 'necessite') { |
| 626 | - $msg = array(); |
|
| 627 | - foreach ($n as $need) { |
|
| 628 | - $id = strtoupper($need['nom']); |
|
| 629 | - $r = plugin_controler_necessite( |
|
| 630 | - $liste, |
|
| 631 | - $id, |
|
| 632 | - isset($need['compatibilite']) ? $need['compatibilite'] : '', |
|
| 633 | - $balise |
|
| 634 | - ); |
|
| 635 | - if ($r) { |
|
| 636 | - $msg[] = $r; |
|
| 637 | - } |
|
| 638 | - } |
|
| 639 | - |
|
| 640 | - return $msg; |
|
| 626 | + $msg = array(); |
|
| 627 | + foreach ($n as $need) { |
|
| 628 | + $id = strtoupper($need['nom']); |
|
| 629 | + $r = plugin_controler_necessite( |
|
| 630 | + $liste, |
|
| 631 | + $id, |
|
| 632 | + isset($need['compatibilite']) ? $need['compatibilite'] : '', |
|
| 633 | + $balise |
|
| 634 | + ); |
|
| 635 | + if ($r) { |
|
| 636 | + $msg[] = $r; |
|
| 637 | + } |
|
| 638 | + } |
|
| 639 | + |
|
| 640 | + return $msg; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -659,16 +659,16 @@ discard block |
||
| 659 | 659 | * Message d'erreur lorsque la dépendance est absente. |
| 660 | 660 | **/ |
| 661 | 661 | function plugin_controler_necessite($liste, $nom, $intervalle, $balise) { |
| 662 | - if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 663 | - return ''; |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - return plugin_message_incompatibilite( |
|
| 667 | - $intervalle, |
|
| 668 | - (isset($liste[$nom]) ? $liste[$nom]['version'] : ""), |
|
| 669 | - $nom, |
|
| 670 | - $balise |
|
| 671 | - ); |
|
| 662 | + if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 663 | + return ''; |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + return plugin_message_incompatibilite( |
|
| 667 | + $intervalle, |
|
| 668 | + (isset($liste[$nom]) ? $liste[$nom]['version'] : ""), |
|
| 669 | + $nom, |
|
| 670 | + $balise |
|
| 671 | + ); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -685,70 +685,70 @@ discard block |
||
| 685 | 685 | */ |
| 686 | 686 | function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) { |
| 687 | 687 | |
| 688 | - // prendre en compte les erreurs de dépendances à PHP |
|
| 689 | - // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 690 | - $type = 'plugin'; |
|
| 691 | - if ($nom === 'SPIP') { |
|
| 692 | - $type = 'spip'; |
|
| 693 | - } elseif ($nom === 'PHP') { |
|
| 694 | - $type = 'php'; |
|
| 695 | - } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 696 | - $type = 'extension_php'; |
|
| 697 | - list(,$nom) = explode(':', $nom, 2); |
|
| 698 | - } |
|
| 699 | - |
|
| 700 | - if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 701 | - $minimum = $regs[1]; |
|
| 702 | - $maximum = $regs[2]; |
|
| 703 | - |
|
| 704 | - $minimum_inclus = $intervalle[0] == "["; |
|
| 705 | - $maximum_inclus = substr($intervalle, -1) == "]"; |
|
| 706 | - |
|
| 707 | - if (strlen($minimum)) { |
|
| 708 | - if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 709 | - return _T("plugin_${balise}_${type}", array( |
|
| 710 | - 'plugin' => $nom, |
|
| 711 | - 'version' => ' ≥ ' . $minimum |
|
| 712 | - )); |
|
| 713 | - } |
|
| 714 | - if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 715 | - return _T("plugin_${balise}_${type}", array( |
|
| 716 | - 'plugin' => $nom, |
|
| 717 | - 'version' => ' > ' . $minimum |
|
| 718 | - )); |
|
| 719 | - } |
|
| 720 | - } |
|
| 721 | - |
|
| 722 | - if (strlen($maximum)) { |
|
| 723 | - if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 724 | - return _T("plugin_${balise}_${type}", array( |
|
| 725 | - 'plugin' => $nom, |
|
| 726 | - 'version' => ' ≤ ' . $maximum |
|
| 727 | - )); |
|
| 728 | - } |
|
| 729 | - if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 730 | - return _T("plugin_${balise}_plugin", array( |
|
| 731 | - 'plugin' => $nom, |
|
| 732 | - 'version' => ' < ' . $maximum |
|
| 733 | - )); |
|
| 734 | - } |
|
| 735 | - } |
|
| 736 | - } |
|
| 737 | - |
|
| 738 | - // note : il ne peut pas y avoir d'erreur sur |
|
| 739 | - // - un 'utilise' sans version. |
|
| 740 | - // - un 'php' sans version. |
|
| 741 | - return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom)); |
|
| 688 | + // prendre en compte les erreurs de dépendances à PHP |
|
| 689 | + // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 690 | + $type = 'plugin'; |
|
| 691 | + if ($nom === 'SPIP') { |
|
| 692 | + $type = 'spip'; |
|
| 693 | + } elseif ($nom === 'PHP') { |
|
| 694 | + $type = 'php'; |
|
| 695 | + } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 696 | + $type = 'extension_php'; |
|
| 697 | + list(,$nom) = explode(':', $nom, 2); |
|
| 698 | + } |
|
| 699 | + |
|
| 700 | + if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 701 | + $minimum = $regs[1]; |
|
| 702 | + $maximum = $regs[2]; |
|
| 703 | + |
|
| 704 | + $minimum_inclus = $intervalle[0] == "["; |
|
| 705 | + $maximum_inclus = substr($intervalle, -1) == "]"; |
|
| 706 | + |
|
| 707 | + if (strlen($minimum)) { |
|
| 708 | + if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 709 | + return _T("plugin_${balise}_${type}", array( |
|
| 710 | + 'plugin' => $nom, |
|
| 711 | + 'version' => ' ≥ ' . $minimum |
|
| 712 | + )); |
|
| 713 | + } |
|
| 714 | + if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 715 | + return _T("plugin_${balise}_${type}", array( |
|
| 716 | + 'plugin' => $nom, |
|
| 717 | + 'version' => ' > ' . $minimum |
|
| 718 | + )); |
|
| 719 | + } |
|
| 720 | + } |
|
| 721 | + |
|
| 722 | + if (strlen($maximum)) { |
|
| 723 | + if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 724 | + return _T("plugin_${balise}_${type}", array( |
|
| 725 | + 'plugin' => $nom, |
|
| 726 | + 'version' => ' ≤ ' . $maximum |
|
| 727 | + )); |
|
| 728 | + } |
|
| 729 | + if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 730 | + return _T("plugin_${balise}_plugin", array( |
|
| 731 | + 'plugin' => $nom, |
|
| 732 | + 'version' => ' < ' . $maximum |
|
| 733 | + )); |
|
| 734 | + } |
|
| 735 | + } |
|
| 736 | + } |
|
| 737 | + |
|
| 738 | + // note : il ne peut pas y avoir d'erreur sur |
|
| 739 | + // - un 'utilise' sans version. |
|
| 740 | + // - un 'php' sans version. |
|
| 741 | + return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom)); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | |
| 745 | 745 | function plugin_controler_lib($lib, $url) { |
| 746 | - /* Feature sortie du core, voir STP |
|
| 746 | + /* Feature sortie du core, voir STP |
|
| 747 | 747 | * if ($url) { |
| 748 | 748 | include_spip('inc/charger_plugin'); |
| 749 | 749 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 750 | 750 | }*/ |
| 751 | - return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>"; |
|
| 751 | + return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>"; |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | * true si il y a eu des modifications sur la liste des plugins actifs, false sinon |
| 764 | 764 | **/ |
| 765 | 765 | function actualise_plugins_actifs($pipe_recherche = false) { |
| 766 | - return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 766 | + return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | |
@@ -790,113 +790,113 @@ discard block |
||
| 790 | 790 | **/ |
| 791 | 791 | function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') { |
| 792 | 792 | |
| 793 | - // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 794 | - $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 795 | - |
|
| 796 | - // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 797 | - if (!$cache and !spip_connect()) { |
|
| 798 | - return false; |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - if ($operation != 'raz') { |
|
| 802 | - $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 803 | - $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 804 | - if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 805 | - $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 806 | - $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 807 | - $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 808 | - } |
|
| 809 | - // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 810 | - // on les reinjecte ici |
|
| 811 | - if (isset($GLOBALS['meta']['plugin_attente']) |
|
| 812 | - and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 813 | - ) { |
|
| 814 | - $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - if ($operation == 'ajoute') { |
|
| 818 | - $plugin = array_merge($plugin_valides, $plugin); |
|
| 819 | - } elseif ($operation == 'enleve') { |
|
| 820 | - $plugin = array_diff($plugin_valides, $plugin); |
|
| 821 | - } else { |
|
| 822 | - $plugin = $plugin_valides; |
|
| 823 | - } |
|
| 824 | - } |
|
| 825 | - $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : ''; |
|
| 826 | - |
|
| 827 | - // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 828 | - if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) { |
|
| 829 | - $plugin = $ajouter_dependances($plugin); |
|
| 830 | - } |
|
| 831 | - |
|
| 832 | - // recharger le xml des plugins a activer |
|
| 833 | - // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 834 | - // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 835 | - // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 836 | - // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 837 | - list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true); |
|
| 838 | - // trouver l'ordre d'activation |
|
| 839 | - list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste); |
|
| 840 | - if ($invalides or $reste) { |
|
| 841 | - plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - // Ignorer les plugins necessitant une lib absente |
|
| 845 | - // et preparer la meta d'entete Http |
|
| 846 | - $err = $msg = $header = array(); |
|
| 847 | - foreach ($plugin_valides as $p => $resume) { |
|
| 848 | - // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 849 | - if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 850 | - $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : ""); |
|
| 851 | - } |
|
| 852 | - if ($resume['dir']) { |
|
| 853 | - foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 854 | - if (!find_in_path($l['nom'], 'lib/')) { |
|
| 855 | - $err[$p] = $resume; |
|
| 856 | - $msg[$p][] = $l; |
|
| 857 | - unset($plugin_valides[$p]); |
|
| 858 | - } |
|
| 859 | - } |
|
| 860 | - } |
|
| 861 | - } |
|
| 862 | - if ($err) { |
|
| 863 | - plugins_erreurs($err, '', $infos, $msg); |
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 867 | - effacer_meta('message_crash_plugins'); |
|
| 868 | - } |
|
| 869 | - ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 870 | - $liste = array_diff_key($liste, $plugin_valides); |
|
| 871 | - ecrire_meta('plugin_attente', serialize($liste)); |
|
| 872 | - $header = strtolower(implode(",", $header)); |
|
| 873 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 874 | - ecrire_fichier(_DIR_VAR . "config.txt", |
|
| 875 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header); |
|
| 876 | - } else { |
|
| 877 | - @unlink(_DIR_VAR . "config.txt"); |
|
| 878 | - } |
|
| 879 | - // generer charger_plugins_chemin.php |
|
| 880 | - plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 881 | - // generer les fichiers |
|
| 882 | - // - charger_plugins_options.php |
|
| 883 | - // - charger_plugins_fonctions.php |
|
| 884 | - plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 885 | - // charger les chemins des plugins et les fichiers d'options |
|
| 886 | - // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 887 | - plugins_amorcer_plugins_actifs(); |
|
| 888 | - // mise a jour de la matrice des pipelines |
|
| 889 | - $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 890 | - // generer le fichier _CACHE_PIPELINE |
|
| 891 | - pipeline_precompile($prepend_code); |
|
| 892 | - |
|
| 893 | - if (spip_connect()) { |
|
| 894 | - // lancer et initialiser les nouveaux crons ! |
|
| 895 | - include_spip('inc/genie'); |
|
| 896 | - genie_queue_watch_dist(); |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 793 | + // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 794 | + $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 795 | + |
|
| 796 | + // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 797 | + if (!$cache and !spip_connect()) { |
|
| 798 | + return false; |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + if ($operation != 'raz') { |
|
| 802 | + $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 803 | + $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 804 | + if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 805 | + $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 806 | + $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 807 | + $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 808 | + } |
|
| 809 | + // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 810 | + // on les reinjecte ici |
|
| 811 | + if (isset($GLOBALS['meta']['plugin_attente']) |
|
| 812 | + and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 813 | + ) { |
|
| 814 | + $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + if ($operation == 'ajoute') { |
|
| 818 | + $plugin = array_merge($plugin_valides, $plugin); |
|
| 819 | + } elseif ($operation == 'enleve') { |
|
| 820 | + $plugin = array_diff($plugin_valides, $plugin); |
|
| 821 | + } else { |
|
| 822 | + $plugin = $plugin_valides; |
|
| 823 | + } |
|
| 824 | + } |
|
| 825 | + $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : ''; |
|
| 826 | + |
|
| 827 | + // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 828 | + if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) { |
|
| 829 | + $plugin = $ajouter_dependances($plugin); |
|
| 830 | + } |
|
| 831 | + |
|
| 832 | + // recharger le xml des plugins a activer |
|
| 833 | + // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 834 | + // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 835 | + // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 836 | + // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 837 | + list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true); |
|
| 838 | + // trouver l'ordre d'activation |
|
| 839 | + list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste); |
|
| 840 | + if ($invalides or $reste) { |
|
| 841 | + plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + // Ignorer les plugins necessitant une lib absente |
|
| 845 | + // et preparer la meta d'entete Http |
|
| 846 | + $err = $msg = $header = array(); |
|
| 847 | + foreach ($plugin_valides as $p => $resume) { |
|
| 848 | + // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 849 | + if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 850 | + $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : ""); |
|
| 851 | + } |
|
| 852 | + if ($resume['dir']) { |
|
| 853 | + foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 854 | + if (!find_in_path($l['nom'], 'lib/')) { |
|
| 855 | + $err[$p] = $resume; |
|
| 856 | + $msg[$p][] = $l; |
|
| 857 | + unset($plugin_valides[$p]); |
|
| 858 | + } |
|
| 859 | + } |
|
| 860 | + } |
|
| 861 | + } |
|
| 862 | + if ($err) { |
|
| 863 | + plugins_erreurs($err, '', $infos, $msg); |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 867 | + effacer_meta('message_crash_plugins'); |
|
| 868 | + } |
|
| 869 | + ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 870 | + $liste = array_diff_key($liste, $plugin_valides); |
|
| 871 | + ecrire_meta('plugin_attente', serialize($liste)); |
|
| 872 | + $header = strtolower(implode(",", $header)); |
|
| 873 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 874 | + ecrire_fichier(_DIR_VAR . "config.txt", |
|
| 875 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header); |
|
| 876 | + } else { |
|
| 877 | + @unlink(_DIR_VAR . "config.txt"); |
|
| 878 | + } |
|
| 879 | + // generer charger_plugins_chemin.php |
|
| 880 | + plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 881 | + // generer les fichiers |
|
| 882 | + // - charger_plugins_options.php |
|
| 883 | + // - charger_plugins_fonctions.php |
|
| 884 | + plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 885 | + // charger les chemins des plugins et les fichiers d'options |
|
| 886 | + // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 887 | + plugins_amorcer_plugins_actifs(); |
|
| 888 | + // mise a jour de la matrice des pipelines |
|
| 889 | + $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 890 | + // generer le fichier _CACHE_PIPELINE |
|
| 891 | + pipeline_precompile($prepend_code); |
|
| 892 | + |
|
| 893 | + if (spip_connect()) { |
|
| 894 | + // lancer et initialiser les nouveaux crons ! |
|
| 895 | + include_spip('inc/genie'); |
|
| 896 | + genie_queue_watch_dist(); |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -915,68 +915,68 @@ discard block |
||
| 915 | 915 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 916 | 916 | **/ |
| 917 | 917 | function plugins_precompile_chemin($plugin_valides, $ordre) { |
| 918 | - $chemins = [ |
|
| 919 | - 'public' => [], |
|
| 920 | - 'prive' => [] |
|
| 921 | - ]; |
|
| 922 | - $contenu = ""; |
|
| 923 | - foreach ($ordre as $p => $info) { |
|
| 924 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 925 | - if (isset($plugin_valides[$p])) { |
|
| 926 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 927 | - $plug = $plugin_valides[$p]['dir']; |
|
| 928 | - // definir le plugin, donc le path avant l'include du fichier options |
|
| 929 | - // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 930 | - |
|
| 931 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 932 | - |
|
| 933 | - $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 934 | - if ( |
|
| 935 | - $prefix !== "SPIP" |
|
| 936 | - and strpos($dir, ":") === false // exclure le cas des procure: |
|
| 937 | - ) { |
|
| 938 | - $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 939 | - if (!$info['chemin']) { |
|
| 940 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 941 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 942 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 943 | - $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 944 | - } |
|
| 945 | - } |
|
| 946 | - else{ |
|
| 947 | - foreach ($info['chemin'] as $chemin) { |
|
| 948 | - if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'], |
|
| 949 | - $GLOBALS['spip_version_branche'], 'spip') |
|
| 950 | - ) { |
|
| 951 | - $dir = $chemin['path']; |
|
| 952 | - if (strlen($dir) and $dir[0] == "/") { |
|
| 953 | - $dir = substr($dir, 1); |
|
| 954 | - } |
|
| 955 | - if (strlen($dir) and $dir == "./") { |
|
| 956 | - $dir = ''; |
|
| 957 | - } |
|
| 958 | - if (strlen($dir)) { |
|
| 959 | - $dir = rtrim($dir, '/') . '/'; |
|
| 960 | - } |
|
| 961 | - if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 962 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 963 | - } |
|
| 964 | - if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 965 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 966 | - } |
|
| 967 | - } |
|
| 968 | - } |
|
| 969 | - } |
|
| 970 | - } |
|
| 971 | - } |
|
| 972 | - } |
|
| 973 | - if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 974 | - $contenu .= "if (_DIR_RESTREINT) _chemin([" . implode(',', |
|
| 975 | - array_reverse($chemins['public'])) . "]);\n" |
|
| 976 | - . "else _chemin([" . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 918 | + $chemins = [ |
|
| 919 | + 'public' => [], |
|
| 920 | + 'prive' => [] |
|
| 921 | + ]; |
|
| 922 | + $contenu = ""; |
|
| 923 | + foreach ($ordre as $p => $info) { |
|
| 924 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 925 | + if (isset($plugin_valides[$p])) { |
|
| 926 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 927 | + $plug = $plugin_valides[$p]['dir']; |
|
| 928 | + // definir le plugin, donc le path avant l'include du fichier options |
|
| 929 | + // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 930 | + |
|
| 931 | + $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 932 | + |
|
| 933 | + $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 934 | + if ( |
|
| 935 | + $prefix !== "SPIP" |
|
| 936 | + and strpos($dir, ":") === false // exclure le cas des procure: |
|
| 937 | + ) { |
|
| 938 | + $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 939 | + if (!$info['chemin']) { |
|
| 940 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 941 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 942 | + if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 943 | + $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 944 | + } |
|
| 945 | + } |
|
| 946 | + else{ |
|
| 947 | + foreach ($info['chemin'] as $chemin) { |
|
| 948 | + if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'], |
|
| 949 | + $GLOBALS['spip_version_branche'], 'spip') |
|
| 950 | + ) { |
|
| 951 | + $dir = $chemin['path']; |
|
| 952 | + if (strlen($dir) and $dir[0] == "/") { |
|
| 953 | + $dir = substr($dir, 1); |
|
| 954 | + } |
|
| 955 | + if (strlen($dir) and $dir == "./") { |
|
| 956 | + $dir = ''; |
|
| 957 | + } |
|
| 958 | + if (strlen($dir)) { |
|
| 959 | + $dir = rtrim($dir, '/') . '/'; |
|
| 960 | + } |
|
| 961 | + if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 962 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 963 | + } |
|
| 964 | + if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 965 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 966 | + } |
|
| 967 | + } |
|
| 968 | + } |
|
| 969 | + } |
|
| 970 | + } |
|
| 971 | + } |
|
| 972 | + } |
|
| 973 | + if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 974 | + $contenu .= "if (_DIR_RESTREINT) _chemin([" . implode(',', |
|
| 975 | + array_reverse($chemins['public'])) . "]);\n" |
|
| 976 | + . "else _chemin([" . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
@@ -994,65 +994,65 @@ discard block |
||
| 994 | 994 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 995 | 995 | **/ |
| 996 | 996 | function plugins_precompile_xxxtions($plugin_valides, $ordre) { |
| 997 | - $contenu = array('options' => '', 'fonctions' => ''); |
|
| 998 | - $boutons = array(); |
|
| 999 | - $onglets = array(); |
|
| 1000 | - $sign = ""; |
|
| 1001 | - |
|
| 1002 | - foreach ($ordre as $p => $info) { |
|
| 1003 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1004 | - if (isset($plugin_valides[$p])) { |
|
| 1005 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1006 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1007 | - $dir = constant($dir_type); |
|
| 1008 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1009 | - if ($info['menu']) { |
|
| 1010 | - $boutons = array_merge($boutons, $info['menu']); |
|
| 1011 | - } |
|
| 1012 | - if ($info['onglet']) { |
|
| 1013 | - $onglets = array_merge($onglets, $info['onglet']); |
|
| 1014 | - } |
|
| 1015 | - foreach ($contenu as $charge => $v) { |
|
| 1016 | - // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1017 | - // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1018 | - // donc ni sa relecture, ni sa detection |
|
| 1019 | - if (!isset($info[$charge]) |
|
| 1020 | - and $dir // exclure le cas du plugin "SPIP" |
|
| 1021 | - and strpos($dir, ":") === false // exclure le cas des procure: |
|
| 1022 | - and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1023 | - ) { |
|
| 1024 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) { |
|
| 1025 | - $info[$charge] = array($file); |
|
| 1026 | - } |
|
| 1027 | - } |
|
| 1028 | - if (isset($info[$charge])) { |
|
| 1029 | - $files = $info[$charge]; |
|
| 1030 | - foreach ($files as $k => $file) { |
|
| 1031 | - // on genere un if file_exists devant chaque include |
|
| 1032 | - // pour pouvoir garder le meme niveau d'erreur general |
|
| 1033 | - $file = trim($file); |
|
| 1034 | - if (!is_readable("$dir$plug/$file") |
|
| 1035 | - // uniquement pour les paquet.xml |
|
| 1036 | - and file_exists("$dir$plug/paquet.xml") |
|
| 1037 | - ) { |
|
| 1038 | - unset($info[$charge][$k]); |
|
| 1039 | - } else { |
|
| 1040 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1041 | - $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1042 | - } |
|
| 1043 | - } |
|
| 1044 | - } |
|
| 1045 | - } |
|
| 1046 | - $sign .= md5(serialize($info)); |
|
| 1047 | - } |
|
| 1048 | - } |
|
| 1049 | - |
|
| 1050 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1051 | - $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons) |
|
| 1052 | - . plugin_ongletbouton("onglets_plugins", $onglets); |
|
| 1053 | - |
|
| 1054 | - ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1055 | - ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 997 | + $contenu = array('options' => '', 'fonctions' => ''); |
|
| 998 | + $boutons = array(); |
|
| 999 | + $onglets = array(); |
|
| 1000 | + $sign = ""; |
|
| 1001 | + |
|
| 1002 | + foreach ($ordre as $p => $info) { |
|
| 1003 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1004 | + if (isset($plugin_valides[$p])) { |
|
| 1005 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1006 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1007 | + $dir = constant($dir_type); |
|
| 1008 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1009 | + if ($info['menu']) { |
|
| 1010 | + $boutons = array_merge($boutons, $info['menu']); |
|
| 1011 | + } |
|
| 1012 | + if ($info['onglet']) { |
|
| 1013 | + $onglets = array_merge($onglets, $info['onglet']); |
|
| 1014 | + } |
|
| 1015 | + foreach ($contenu as $charge => $v) { |
|
| 1016 | + // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1017 | + // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1018 | + // donc ni sa relecture, ni sa detection |
|
| 1019 | + if (!isset($info[$charge]) |
|
| 1020 | + and $dir // exclure le cas du plugin "SPIP" |
|
| 1021 | + and strpos($dir, ":") === false // exclure le cas des procure: |
|
| 1022 | + and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1023 | + ) { |
|
| 1024 | + if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) { |
|
| 1025 | + $info[$charge] = array($file); |
|
| 1026 | + } |
|
| 1027 | + } |
|
| 1028 | + if (isset($info[$charge])) { |
|
| 1029 | + $files = $info[$charge]; |
|
| 1030 | + foreach ($files as $k => $file) { |
|
| 1031 | + // on genere un if file_exists devant chaque include |
|
| 1032 | + // pour pouvoir garder le meme niveau d'erreur general |
|
| 1033 | + $file = trim($file); |
|
| 1034 | + if (!is_readable("$dir$plug/$file") |
|
| 1035 | + // uniquement pour les paquet.xml |
|
| 1036 | + and file_exists("$dir$plug/paquet.xml") |
|
| 1037 | + ) { |
|
| 1038 | + unset($info[$charge][$k]); |
|
| 1039 | + } else { |
|
| 1040 | + $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1041 | + $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1042 | + } |
|
| 1043 | + } |
|
| 1044 | + } |
|
| 1045 | + } |
|
| 1046 | + $sign .= md5(serialize($info)); |
|
| 1047 | + } |
|
| 1048 | + } |
|
| 1049 | + |
|
| 1050 | + $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1051 | + $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons) |
|
| 1052 | + . plugin_ongletbouton("onglets_plugins", $onglets); |
|
| 1053 | + |
|
| 1054 | + ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1055 | + ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | /** |
@@ -1071,24 +1071,24 @@ discard block |
||
| 1071 | 1071 | * @return string Code php |
| 1072 | 1072 | */ |
| 1073 | 1073 | function plugin_ongletbouton($nom, $val) { |
| 1074 | - if (!$val) { |
|
| 1075 | - $val = array(); |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - $val = serialize($val); |
|
| 1079 | - $md5 = md5($val); |
|
| 1080 | - |
|
| 1081 | - if (!defined("_UPDATED_$nom")) { |
|
| 1082 | - define("_UPDATED_$nom", $val); |
|
| 1083 | - define("_UPDATED_md5_$nom", $md5); |
|
| 1084 | - } |
|
| 1085 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1086 | - |
|
| 1087 | - return |
|
| 1088 | - "if (!function_exists('$nom')) {\n" |
|
| 1089 | - . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1090 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1091 | - . "}\n"; |
|
| 1074 | + if (!$val) { |
|
| 1075 | + $val = array(); |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + $val = serialize($val); |
|
| 1079 | + $md5 = md5($val); |
|
| 1080 | + |
|
| 1081 | + if (!defined("_UPDATED_$nom")) { |
|
| 1082 | + define("_UPDATED_$nom", $val); |
|
| 1083 | + define("_UPDATED_md5_$nom", $md5); |
|
| 1084 | + } |
|
| 1085 | + $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1086 | + |
|
| 1087 | + return |
|
| 1088 | + "if (!function_exists('$nom')) {\n" |
|
| 1089 | + . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1090 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1091 | + . "}\n"; |
|
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | /** |
@@ -1103,15 +1103,15 @@ discard block |
||
| 1103 | 1103 | **/ |
| 1104 | 1104 | function plugins_amorcer_plugins_actifs() { |
| 1105 | 1105 | |
| 1106 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1107 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1108 | - } |
|
| 1106 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1107 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1108 | + } |
|
| 1109 | 1109 | |
| 1110 | - if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1111 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 1112 | - } else { |
|
| 1113 | - spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT); |
|
| 1114 | - } |
|
| 1110 | + if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1111 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 1112 | + } else { |
|
| 1113 | + spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT); |
|
| 1114 | + } |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | /** |
@@ -1134,136 +1134,136 @@ discard block |
||
| 1134 | 1134 | * Couples (nom du pipeline => Code PHP à insérer au début du pipeline) |
| 1135 | 1135 | **/ |
| 1136 | 1136 | function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) { |
| 1137 | - static $liste_pipe_manquants = array(); |
|
| 1138 | - if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1139 | - $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1140 | - } |
|
| 1141 | - |
|
| 1142 | - $prepend_code = array(); |
|
| 1143 | - |
|
| 1144 | - foreach ($ordre as $p => $info) { |
|
| 1145 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1146 | - if (isset($plugin_valides[$p])) { |
|
| 1147 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1148 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1149 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1150 | - $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_"); |
|
| 1151 | - if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1152 | - foreach ($info['pipeline'] as $pipe) { |
|
| 1153 | - $nom = $pipe['nom']; |
|
| 1154 | - if (isset($pipe['action'])) { |
|
| 1155 | - $action = $pipe['action']; |
|
| 1156 | - } else { |
|
| 1157 | - $action = $nom; |
|
| 1158 | - } |
|
| 1159 | - $nomlower = strtolower($nom); |
|
| 1160 | - if ($nomlower != $nom |
|
| 1161 | - and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1162 | - and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1163 | - ) { |
|
| 1164 | - $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1165 | - unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1166 | - } |
|
| 1167 | - $nom = $nomlower; |
|
| 1168 | - // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1169 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel |
|
| 1170 | - { |
|
| 1171 | - $GLOBALS['spip_pipeline'][$nom] = ""; |
|
| 1172 | - } |
|
| 1173 | - if ($action) { |
|
| 1174 | - if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) { |
|
| 1175 | - $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1", |
|
| 1176 | - $GLOBALS['spip_pipeline'][$nom], 1); |
|
| 1177 | - } |
|
| 1178 | - if (isset($pipe['inclure'])) { |
|
| 1179 | - $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1180 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1181 | - } |
|
| 1182 | - } |
|
| 1183 | - } |
|
| 1184 | - } |
|
| 1185 | - if (isset($info['genie']) and count($info['genie'])) { |
|
| 1186 | - if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1187 | - $prepend_code['taches_generales_cron'] = ""; |
|
| 1188 | - } |
|
| 1189 | - foreach ($info['genie'] as $genie) { |
|
| 1190 | - $nom = $prefix . $genie['nom']; |
|
| 1191 | - $periode = max(60, intval($genie['periode'])); |
|
| 1192 | - if (charger_fonction($nom, "genie", true)) { |
|
| 1193 | - $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1194 | - } else { |
|
| 1195 | - spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1196 | - } |
|
| 1197 | - } |
|
| 1198 | - } |
|
| 1199 | - if (isset($info['style']) and count($info['style'])) { |
|
| 1200 | - if (!isset($prepend_code['insert_head_css'])) { |
|
| 1201 | - $prepend_code['insert_head_css'] = ""; |
|
| 1202 | - } |
|
| 1203 | - if (!isset($prepend_code['header_prive_css'])) { |
|
| 1204 | - $prepend_code['header_prive_css'] = ""; |
|
| 1205 | - } |
|
| 1206 | - foreach ($info['style'] as $style) { |
|
| 1207 | - if (isset($style['path']) and $style['path']) { |
|
| 1208 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1209 | - } else { |
|
| 1210 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1211 | - } |
|
| 1212 | - $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1213 | - if (isset($style['media']) and strlen($style['media'])) { |
|
| 1214 | - $code .= " media=\"" . addslashes($style['media']) . "\""; |
|
| 1215 | - } |
|
| 1216 | - $code .= "/>';\n"; |
|
| 1217 | - if ($style['type'] != 'prive') { |
|
| 1218 | - $prepend_code['insert_head_css'] .= $code; |
|
| 1219 | - } |
|
| 1220 | - if ($style['type'] != 'public') { |
|
| 1221 | - $prepend_code['header_prive_css'] .= $code; |
|
| 1222 | - } |
|
| 1223 | - } |
|
| 1224 | - } |
|
| 1225 | - if (!isset($prepend_code['insert_head'])) { |
|
| 1226 | - $prepend_code['insert_head'] = ""; |
|
| 1227 | - } |
|
| 1228 | - if (!isset($prepend_code['header_prive'])) { |
|
| 1229 | - $prepend_code['header_prive'] = ""; |
|
| 1230 | - } |
|
| 1231 | - if (isset($info['script']) and count($info['script'])) { |
|
| 1232 | - foreach ($info['script'] as $script) { |
|
| 1233 | - if (isset($script['path']) and $script['path']) { |
|
| 1234 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1235 | - } else { |
|
| 1236 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1237 | - } |
|
| 1238 | - $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1239 | - if ($script['type'] != 'prive') { |
|
| 1240 | - $prepend_code['insert_head'] .= $code; |
|
| 1241 | - } |
|
| 1242 | - if ($script['type'] != 'public') { |
|
| 1243 | - $prepend_code['header_prive'] .= $code; |
|
| 1244 | - } |
|
| 1245 | - } |
|
| 1246 | - } |
|
| 1247 | - } |
|
| 1248 | - } |
|
| 1249 | - |
|
| 1250 | - $prepend_code['insert_head'] = |
|
| 1251 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1252 | - . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1253 | - . $prepend_code['insert_head']; |
|
| 1254 | - $prepend_code['header_prive'] = |
|
| 1255 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1256 | - . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1257 | - . $prepend_code['header_prive']; |
|
| 1258 | - |
|
| 1259 | - // on ajoute les pipe qui ont ete recenses manquants |
|
| 1260 | - foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1261 | - if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1262 | - $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1263 | - } |
|
| 1264 | - } |
|
| 1265 | - |
|
| 1266 | - return $prepend_code; |
|
| 1137 | + static $liste_pipe_manquants = array(); |
|
| 1138 | + if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1139 | + $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1140 | + } |
|
| 1141 | + |
|
| 1142 | + $prepend_code = array(); |
|
| 1143 | + |
|
| 1144 | + foreach ($ordre as $p => $info) { |
|
| 1145 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1146 | + if (isset($plugin_valides[$p])) { |
|
| 1147 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1148 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1149 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1150 | + $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_"); |
|
| 1151 | + if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1152 | + foreach ($info['pipeline'] as $pipe) { |
|
| 1153 | + $nom = $pipe['nom']; |
|
| 1154 | + if (isset($pipe['action'])) { |
|
| 1155 | + $action = $pipe['action']; |
|
| 1156 | + } else { |
|
| 1157 | + $action = $nom; |
|
| 1158 | + } |
|
| 1159 | + $nomlower = strtolower($nom); |
|
| 1160 | + if ($nomlower != $nom |
|
| 1161 | + and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1162 | + and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1163 | + ) { |
|
| 1164 | + $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1165 | + unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1166 | + } |
|
| 1167 | + $nom = $nomlower; |
|
| 1168 | + // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1169 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel |
|
| 1170 | + { |
|
| 1171 | + $GLOBALS['spip_pipeline'][$nom] = ""; |
|
| 1172 | + } |
|
| 1173 | + if ($action) { |
|
| 1174 | + if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) { |
|
| 1175 | + $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1", |
|
| 1176 | + $GLOBALS['spip_pipeline'][$nom], 1); |
|
| 1177 | + } |
|
| 1178 | + if (isset($pipe['inclure'])) { |
|
| 1179 | + $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1180 | + "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1181 | + } |
|
| 1182 | + } |
|
| 1183 | + } |
|
| 1184 | + } |
|
| 1185 | + if (isset($info['genie']) and count($info['genie'])) { |
|
| 1186 | + if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1187 | + $prepend_code['taches_generales_cron'] = ""; |
|
| 1188 | + } |
|
| 1189 | + foreach ($info['genie'] as $genie) { |
|
| 1190 | + $nom = $prefix . $genie['nom']; |
|
| 1191 | + $periode = max(60, intval($genie['periode'])); |
|
| 1192 | + if (charger_fonction($nom, "genie", true)) { |
|
| 1193 | + $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1194 | + } else { |
|
| 1195 | + spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1196 | + } |
|
| 1197 | + } |
|
| 1198 | + } |
|
| 1199 | + if (isset($info['style']) and count($info['style'])) { |
|
| 1200 | + if (!isset($prepend_code['insert_head_css'])) { |
|
| 1201 | + $prepend_code['insert_head_css'] = ""; |
|
| 1202 | + } |
|
| 1203 | + if (!isset($prepend_code['header_prive_css'])) { |
|
| 1204 | + $prepend_code['header_prive_css'] = ""; |
|
| 1205 | + } |
|
| 1206 | + foreach ($info['style'] as $style) { |
|
| 1207 | + if (isset($style['path']) and $style['path']) { |
|
| 1208 | + $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1209 | + } else { |
|
| 1210 | + $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1211 | + } |
|
| 1212 | + $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1213 | + if (isset($style['media']) and strlen($style['media'])) { |
|
| 1214 | + $code .= " media=\"" . addslashes($style['media']) . "\""; |
|
| 1215 | + } |
|
| 1216 | + $code .= "/>';\n"; |
|
| 1217 | + if ($style['type'] != 'prive') { |
|
| 1218 | + $prepend_code['insert_head_css'] .= $code; |
|
| 1219 | + } |
|
| 1220 | + if ($style['type'] != 'public') { |
|
| 1221 | + $prepend_code['header_prive_css'] .= $code; |
|
| 1222 | + } |
|
| 1223 | + } |
|
| 1224 | + } |
|
| 1225 | + if (!isset($prepend_code['insert_head'])) { |
|
| 1226 | + $prepend_code['insert_head'] = ""; |
|
| 1227 | + } |
|
| 1228 | + if (!isset($prepend_code['header_prive'])) { |
|
| 1229 | + $prepend_code['header_prive'] = ""; |
|
| 1230 | + } |
|
| 1231 | + if (isset($info['script']) and count($info['script'])) { |
|
| 1232 | + foreach ($info['script'] as $script) { |
|
| 1233 | + if (isset($script['path']) and $script['path']) { |
|
| 1234 | + $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1235 | + } else { |
|
| 1236 | + $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1237 | + } |
|
| 1238 | + $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1239 | + if ($script['type'] != 'prive') { |
|
| 1240 | + $prepend_code['insert_head'] .= $code; |
|
| 1241 | + } |
|
| 1242 | + if ($script['type'] != 'public') { |
|
| 1243 | + $prepend_code['header_prive'] .= $code; |
|
| 1244 | + } |
|
| 1245 | + } |
|
| 1246 | + } |
|
| 1247 | + } |
|
| 1248 | + } |
|
| 1249 | + |
|
| 1250 | + $prepend_code['insert_head'] = |
|
| 1251 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1252 | + . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1253 | + . $prepend_code['insert_head']; |
|
| 1254 | + $prepend_code['header_prive'] = |
|
| 1255 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1256 | + . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1257 | + . $prepend_code['header_prive']; |
|
| 1258 | + |
|
| 1259 | + // on ajoute les pipe qui ont ete recenses manquants |
|
| 1260 | + foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1261 | + if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1262 | + $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1263 | + } |
|
| 1264 | + } |
|
| 1265 | + |
|
| 1266 | + return $prepend_code; |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | /** |
@@ -1290,62 +1290,62 @@ discard block |
||
| 1290 | 1290 | **/ |
| 1291 | 1291 | function pipeline_precompile($prepend_code = array()) { |
| 1292 | 1292 | |
| 1293 | - $all_pipes = $all_pipes_end = ''; |
|
| 1294 | - if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1295 | - $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1296 | - unset($GLOBALS['spip_pipeline']['all']); |
|
| 1297 | - $all_pipes = trim(array_shift($a)); |
|
| 1298 | - if ($all_pipes) { |
|
| 1299 | - $all_pipes = '|' . ltrim($a, '|'); |
|
| 1300 | - } |
|
| 1301 | - if (count($a)) { |
|
| 1302 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1303 | - } |
|
| 1304 | - } |
|
| 1305 | - $content = ""; |
|
| 1306 | - foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1307 | - $s_inc = ""; |
|
| 1308 | - $s_call = ""; |
|
| 1309 | - if ($all_pipes) { |
|
| 1310 | - $pipeline = preg_replace(",(\|\||$),", "$all_pipes\\1", $pipeline, 1); |
|
| 1311 | - } |
|
| 1312 | - if ($all_pipes_end) { |
|
| 1313 | - $pipeline .= $all_pipes_end; |
|
| 1314 | - } |
|
| 1315 | - $pipe = array_filter(explode('|', $pipeline)); |
|
| 1316 | - // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1317 | - foreach ($pipe as $fonc) { |
|
| 1318 | - $fonc = trim($fonc); |
|
| 1319 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1320 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1321 | - $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1322 | - $file = "'$file'"; |
|
| 1323 | - // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1324 | - if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) { |
|
| 1325 | - $dir = $regs[1]; |
|
| 1326 | - $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1327 | - if (defined($root_dir)) { |
|
| 1328 | - $dir = $root_dir; |
|
| 1329 | - } |
|
| 1330 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1331 | - $file = str_replace("''.", "", $file); |
|
| 1332 | - $file = str_replace(constant($dir), '', $file); |
|
| 1333 | - } |
|
| 1334 | - $s_inc .= "include_once_check($file);\n"; |
|
| 1335 | - } |
|
| 1336 | - } |
|
| 1337 | - if (strlen($s_inc)) { |
|
| 1338 | - $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1339 | - } |
|
| 1340 | - $content .= "// Pipeline $action \n" |
|
| 1341 | - . "function execute_pipeline_$action(&\$val){\n" |
|
| 1342 | - . $s_inc |
|
| 1343 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1344 | - . $s_call |
|
| 1345 | - . "return \$val;\n}\n"; |
|
| 1346 | - } |
|
| 1347 | - ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1348 | - clear_path_cache(); |
|
| 1293 | + $all_pipes = $all_pipes_end = ''; |
|
| 1294 | + if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1295 | + $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1296 | + unset($GLOBALS['spip_pipeline']['all']); |
|
| 1297 | + $all_pipes = trim(array_shift($a)); |
|
| 1298 | + if ($all_pipes) { |
|
| 1299 | + $all_pipes = '|' . ltrim($a, '|'); |
|
| 1300 | + } |
|
| 1301 | + if (count($a)) { |
|
| 1302 | + $all_pipes_end = '||' . array_shift($a); |
|
| 1303 | + } |
|
| 1304 | + } |
|
| 1305 | + $content = ""; |
|
| 1306 | + foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1307 | + $s_inc = ""; |
|
| 1308 | + $s_call = ""; |
|
| 1309 | + if ($all_pipes) { |
|
| 1310 | + $pipeline = preg_replace(",(\|\||$),", "$all_pipes\\1", $pipeline, 1); |
|
| 1311 | + } |
|
| 1312 | + if ($all_pipes_end) { |
|
| 1313 | + $pipeline .= $all_pipes_end; |
|
| 1314 | + } |
|
| 1315 | + $pipe = array_filter(explode('|', $pipeline)); |
|
| 1316 | + // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1317 | + foreach ($pipe as $fonc) { |
|
| 1318 | + $fonc = trim($fonc); |
|
| 1319 | + $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1320 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1321 | + $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1322 | + $file = "'$file'"; |
|
| 1323 | + // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1324 | + if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) { |
|
| 1325 | + $dir = $regs[1]; |
|
| 1326 | + $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1327 | + if (defined($root_dir)) { |
|
| 1328 | + $dir = $root_dir; |
|
| 1329 | + } |
|
| 1330 | + $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1331 | + $file = str_replace("''.", "", $file); |
|
| 1332 | + $file = str_replace(constant($dir), '', $file); |
|
| 1333 | + } |
|
| 1334 | + $s_inc .= "include_once_check($file);\n"; |
|
| 1335 | + } |
|
| 1336 | + } |
|
| 1337 | + if (strlen($s_inc)) { |
|
| 1338 | + $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1339 | + } |
|
| 1340 | + $content .= "// Pipeline $action \n" |
|
| 1341 | + . "function execute_pipeline_$action(&\$val){\n" |
|
| 1342 | + . $s_inc |
|
| 1343 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1344 | + . $s_call |
|
| 1345 | + . "return \$val;\n}\n"; |
|
| 1346 | + } |
|
| 1347 | + ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1348 | + clear_path_cache(); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | |
@@ -1358,12 +1358,12 @@ discard block |
||
| 1358 | 1358 | * true si le plugin est actif, false sinon |
| 1359 | 1359 | **/ |
| 1360 | 1360 | function plugin_est_installe($plug_path) { |
| 1361 | - $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array(); |
|
| 1362 | - if (!$plugin_installes) { |
|
| 1363 | - return false; |
|
| 1364 | - } |
|
| 1361 | + $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array(); |
|
| 1362 | + if (!$plugin_installes) { |
|
| 1363 | + return false; |
|
| 1364 | + } |
|
| 1365 | 1365 | |
| 1366 | - return in_array($plug_path, $plugin_installes); |
|
| 1366 | + return in_array($plug_path, $plugin_installes); |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | 1369 | |
@@ -1376,37 +1376,37 @@ discard block |
||
| 1376 | 1376 | * @uses plugins_installer_dist() |
| 1377 | 1377 | **/ |
| 1378 | 1378 | function plugin_installes_meta() { |
| 1379 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1380 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 1381 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1385 | - $meta_plug_installes = array(); |
|
| 1386 | - foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1387 | - if ($plug = $resume['dir']) { |
|
| 1388 | - $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1389 | - if ($infos) { |
|
| 1390 | - if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1391 | - $meta_plug_installes[] = $plug; |
|
| 1392 | - } |
|
| 1393 | - if (is_array($infos)) { |
|
| 1394 | - list($ok, $trace) = $infos['install_test']; |
|
| 1395 | - include_spip('inc/filtres_boites'); |
|
| 1396 | - echo "<div class='install-plugins svp_retour'>" |
|
| 1397 | - . boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))), |
|
| 1398 | - ($ok ? 'success' : 'error')) |
|
| 1399 | - . $trace |
|
| 1400 | - . "<div class='result'>" |
|
| 1401 | - . ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec")) |
|
| 1402 | - . "</div>" |
|
| 1403 | - . boite_fermer() |
|
| 1404 | - . "</div>"; |
|
| 1405 | - } |
|
| 1406 | - } |
|
| 1407 | - } |
|
| 1408 | - } |
|
| 1409 | - ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1379 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1380 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 1381 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1385 | + $meta_plug_installes = array(); |
|
| 1386 | + foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1387 | + if ($plug = $resume['dir']) { |
|
| 1388 | + $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1389 | + if ($infos) { |
|
| 1390 | + if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1391 | + $meta_plug_installes[] = $plug; |
|
| 1392 | + } |
|
| 1393 | + if (is_array($infos)) { |
|
| 1394 | + list($ok, $trace) = $infos['install_test']; |
|
| 1395 | + include_spip('inc/filtres_boites'); |
|
| 1396 | + echo "<div class='install-plugins svp_retour'>" |
|
| 1397 | + . boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))), |
|
| 1398 | + ($ok ? 'success' : 'error')) |
|
| 1399 | + . $trace |
|
| 1400 | + . "<div class='result'>" |
|
| 1401 | + . ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec")) |
|
| 1402 | + . "</div>" |
|
| 1403 | + . boite_fermer() |
|
| 1404 | + . "</div>"; |
|
| 1405 | + } |
|
| 1406 | + } |
|
| 1407 | + } |
|
| 1408 | + } |
|
| 1409 | + ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | 1412 | /** |
@@ -1420,29 +1420,29 @@ discard block |
||
| 1420 | 1420 | * Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante |
| 1421 | 1421 | **/ |
| 1422 | 1422 | function ecrire_fichier_php($nom, $contenu, $comment = '') { |
| 1423 | - if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1424 | - $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1425 | - } |
|
| 1426 | - |
|
| 1427 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1428 | - // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1429 | - // si pas de modif on ne touche pas au fichier initial |
|
| 1430 | - if (file_exists($nom)) { |
|
| 1431 | - if (substr($nom, -4) == '.php') { |
|
| 1432 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1433 | - } |
|
| 1434 | - else { |
|
| 1435 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1436 | - } |
|
| 1437 | - file_put_contents($fichier_tmp, $contenu); |
|
| 1438 | - if(md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1439 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1440 | - @unlink($fichier_tmp); |
|
| 1441 | - return; |
|
| 1442 | - } |
|
| 1443 | - @unlink($fichier_tmp); |
|
| 1444 | - } |
|
| 1445 | - ecrire_fichier($nom, $contenu); |
|
| 1446 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1447 | - spip_clear_opcode_cache(realpath($nom)); |
|
| 1423 | + if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1424 | + $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1425 | + } |
|
| 1426 | + |
|
| 1427 | + $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1428 | + // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1429 | + // si pas de modif on ne touche pas au fichier initial |
|
| 1430 | + if (file_exists($nom)) { |
|
| 1431 | + if (substr($nom, -4) == '.php') { |
|
| 1432 | + $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1433 | + } |
|
| 1434 | + else { |
|
| 1435 | + $fichier_tmp = $nom . '.tmp'; |
|
| 1436 | + } |
|
| 1437 | + file_put_contents($fichier_tmp, $contenu); |
|
| 1438 | + if(md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1439 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1440 | + @unlink($fichier_tmp); |
|
| 1441 | + return; |
|
| 1442 | + } |
|
| 1443 | + @unlink($fichier_tmp); |
|
| 1444 | + } |
|
| 1445 | + ecrire_fichier($nom, $contenu); |
|
| 1446 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1447 | + spip_clear_opcode_cache(realpath($nom)); |
|
| 1448 | 1448 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | if ($dir) { |
| 371 | 371 | $dir .= "/"; |
| 372 | 372 | } |
| 373 | - $dir .= "procure:" . $procure['nom']; |
|
| 373 | + $dir .= "procure:".$procure['nom']; |
|
| 374 | 374 | |
| 375 | 375 | $procure['etat'] = '?'; |
| 376 | 376 | $procure['dir_type'] = $resume['dir_type']; |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | $plug = $resume['dir']; |
| 552 | 552 | $k = $infos[$dir_type][$plug]; |
| 553 | 553 | |
| 554 | - $plug = constant($dir_type) . $plug; |
|
| 554 | + $plug = constant($dir_type).$plug; |
|
| 555 | 555 | if (!isset($msg[$p])) { |
| 556 | 556 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 557 | 557 | $msg[$p] = array($resume['erreur']); |
@@ -594,10 +594,10 @@ discard block |
||
| 594 | 594 | $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation']; |
| 595 | 595 | } elseif (!$raw) { |
| 596 | 596 | foreach ($list as $plug => $msg) { |
| 597 | - $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 598 | - . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>"; |
|
| 597 | + $list[$plug] = "<li>"._T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 598 | + . "<ul><li>".implode("</li><li>", $msg)."</li></ul></li>"; |
|
| 599 | 599 | } |
| 600 | - $list = "<ul>" . join("\n", $list) . "</ul>"; |
|
| 600 | + $list = "<ul>".join("\n", $list)."</ul>"; |
|
| 601 | 601 | } |
| 602 | 602 | if ($raz) { |
| 603 | 603 | effacer_meta('plugin_erreur_activation'); |
@@ -708,13 +708,13 @@ discard block |
||
| 708 | 708 | if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
| 709 | 709 | return _T("plugin_${balise}_${type}", array( |
| 710 | 710 | 'plugin' => $nom, |
| 711 | - 'version' => ' ≥ ' . $minimum |
|
| 711 | + 'version' => ' ≥ '.$minimum |
|
| 712 | 712 | )); |
| 713 | 713 | } |
| 714 | 714 | if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
| 715 | 715 | return _T("plugin_${balise}_${type}", array( |
| 716 | 716 | 'plugin' => $nom, |
| 717 | - 'version' => ' > ' . $minimum |
|
| 717 | + 'version' => ' > '.$minimum |
|
| 718 | 718 | )); |
| 719 | 719 | } |
| 720 | 720 | } |
@@ -723,13 +723,13 @@ discard block |
||
| 723 | 723 | if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
| 724 | 724 | return _T("plugin_${balise}_${type}", array( |
| 725 | 725 | 'plugin' => $nom, |
| 726 | - 'version' => ' ≤ ' . $maximum |
|
| 726 | + 'version' => ' ≤ '.$maximum |
|
| 727 | 727 | )); |
| 728 | 728 | } |
| 729 | 729 | if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
| 730 | 730 | return _T("plugin_${balise}_plugin", array( |
| 731 | 731 | 'plugin' => $nom, |
| 732 | - 'version' => ' < ' . $maximum |
|
| 732 | + 'version' => ' < '.$maximum |
|
| 733 | 733 | )); |
| 734 | 734 | } |
| 735 | 735 | } |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | include_spip('inc/charger_plugin'); |
| 749 | 749 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 750 | 750 | }*/ |
| 751 | - return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>"; |
|
| 751 | + return _T('plugin_necessite_lib', array('lib' => $lib))." <a href='$url'>$url</a>"; |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | foreach ($plugin_valides as $p => $resume) { |
| 848 | 848 | // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
| 849 | 849 | if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
| 850 | - $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : ""); |
|
| 850 | + $header[] = $p.($resume['version'] ? "(".$resume['version'].")" : ""); |
|
| 851 | 851 | } |
| 852 | 852 | if ($resume['dir']) { |
| 853 | 853 | foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
@@ -871,10 +871,10 @@ discard block |
||
| 871 | 871 | ecrire_meta('plugin_attente', serialize($liste)); |
| 872 | 872 | $header = strtolower(implode(",", $header)); |
| 873 | 873 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 874 | - ecrire_fichier(_DIR_VAR . "config.txt", |
|
| 875 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header); |
|
| 874 | + ecrire_fichier(_DIR_VAR."config.txt", |
|
| 875 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP").' '.$GLOBALS['spip_version_affichee']." @ www.spip.net + ".$header); |
|
| 876 | 876 | } else { |
| 877 | - @unlink(_DIR_VAR . "config.txt"); |
|
| 877 | + @unlink(_DIR_VAR."config.txt"); |
|
| 878 | 878 | } |
| 879 | 879 | // generer charger_plugins_chemin.php |
| 880 | 880 | plugins_precompile_chemin($plugin_valides, $ordre); |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | // definir le plugin, donc le path avant l'include du fichier options |
| 929 | 929 | // permet de faire des include_spip pour attraper un inc_ du plugin |
| 930 | 930 | |
| 931 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 931 | + $dir = $dir_type.".'".$plug."/'"; |
|
| 932 | 932 | |
| 933 | 933 | $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
| 934 | 934 | if ( |
@@ -939,11 +939,11 @@ discard block |
||
| 939 | 939 | if (!$info['chemin']) { |
| 940 | 940 | $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
| 941 | 941 | $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
| 942 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 942 | + if (is_dir(constant($dir_type).$plug.'/squelettes/')) { |
|
| 943 | 943 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 944 | 944 | } |
| 945 | 945 | } |
| 946 | - else{ |
|
| 946 | + else { |
|
| 947 | 947 | foreach ($info['chemin'] as $chemin) { |
| 948 | 948 | if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'], |
| 949 | 949 | $GLOBALS['spip_version_branche'], 'spip') |
@@ -956,13 +956,13 @@ discard block |
||
| 956 | 956 | $dir = ''; |
| 957 | 957 | } |
| 958 | 958 | if (strlen($dir)) { |
| 959 | - $dir = rtrim($dir, '/') . '/'; |
|
| 959 | + $dir = rtrim($dir, '/').'/'; |
|
| 960 | 960 | } |
| 961 | 961 | if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
| 962 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 962 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ""); |
|
| 963 | 963 | } |
| 964 | 964 | if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
| 965 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 965 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ""); |
|
| 966 | 966 | } |
| 967 | 967 | } |
| 968 | 968 | } |
@@ -971,9 +971,9 @@ discard block |
||
| 971 | 971 | } |
| 972 | 972 | } |
| 973 | 973 | if (count($chemins['public']) or count($chemins['prive'])) { |
| 974 | - $contenu .= "if (_DIR_RESTREINT) _chemin([" . implode(',', |
|
| 975 | - array_reverse($chemins['public'])) . "]);\n" |
|
| 976 | - . "else _chemin([" . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 974 | + $contenu .= "if (_DIR_RESTREINT) _chemin([".implode(',', |
|
| 975 | + array_reverse($chemins['public']))."]);\n" |
|
| 976 | + . "else _chemin([".implode(',', array_reverse($chemins['prive']))."]);\n"; |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | and strpos($dir, ":") === false // exclure le cas des procure: |
| 1022 | 1022 | and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
| 1023 | 1023 | ) { |
| 1024 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) { |
|
| 1024 | + if (is_readable("$dir$plug/".($file = $info['prefix']."_".$charge.".php"))) { |
|
| 1025 | 1025 | $info[$charge] = array($file); |
| 1026 | 1026 | } |
| 1027 | 1027 | } |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | ) { |
| 1038 | 1038 | unset($info[$charge][$k]); |
| 1039 | 1039 | } else { |
| 1040 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1040 | + $_file = $root_dir_type.".'$plug/$file'"; |
|
| 1041 | 1041 | $contenu[$charge] .= "include_once_check($_file);\n"; |
| 1042 | 1042 | } |
| 1043 | 1043 | } |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | } |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1050 | + $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options']; |
|
| 1051 | 1051 | $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons) |
| 1052 | 1052 | . plugin_ongletbouton("onglets_plugins", $onglets); |
| 1053 | 1053 | |
@@ -1082,12 +1082,12 @@ discard block |
||
| 1082 | 1082 | define("_UPDATED_$nom", $val); |
| 1083 | 1083 | define("_UPDATED_md5_$nom", $md5); |
| 1084 | 1084 | } |
| 1085 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1085 | + $val = "unserialize('".str_replace("'", "\'", $val)."')"; |
|
| 1086 | 1086 | |
| 1087 | 1087 | return |
| 1088 | 1088 | "if (!function_exists('$nom')) {\n" |
| 1089 | 1089 | . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
| 1090 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1090 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 1091 | 1091 | . "}\n"; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | if (@is_readable(_CACHE_PLUGINS_OPT)) { |
| 1111 | 1111 | include_once(_CACHE_PLUGINS_OPT); |
| 1112 | 1112 | } else { |
| 1113 | - spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT); |
|
| 1113 | + spip_log("pipelines desactives: impossible de produire "._CACHE_PLUGINS_OPT); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | } |
| 1116 | 1116 | |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | $dir_type = $plugin_valides[$p]['dir_type']; |
| 1148 | 1148 | $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
| 1149 | 1149 | $plug = $plugin_valides[$p]['dir']; |
| 1150 | - $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_"); |
|
| 1150 | + $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix']."_"); |
|
| 1151 | 1151 | if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
| 1152 | 1152 | foreach ($info['pipeline'] as $pipe) { |
| 1153 | 1153 | $nom = $pipe['nom']; |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | } |
| 1178 | 1178 | if (isset($pipe['inclure'])) { |
| 1179 | 1179 | $GLOBALS['spip_matrice']["$prefix$action"] = |
| 1180 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1180 | + "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 1181 | 1181 | } |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | $prepend_code['taches_generales_cron'] = ""; |
| 1188 | 1188 | } |
| 1189 | 1189 | foreach ($info['genie'] as $genie) { |
| 1190 | - $nom = $prefix . $genie['nom']; |
|
| 1190 | + $nom = $prefix.$genie['nom']; |
|
| 1191 | 1191 | $periode = max(60, intval($genie['periode'])); |
| 1192 | 1192 | if (charger_fonction($nom, "genie", true)) { |
| 1193 | 1193 | $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
@@ -1205,13 +1205,13 @@ discard block |
||
| 1205 | 1205 | } |
| 1206 | 1206 | foreach ($info['style'] as $style) { |
| 1207 | 1207 | if (isset($style['path']) and $style['path']) { |
| 1208 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1208 | + $code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) "; |
|
| 1209 | 1209 | } else { |
| 1210 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1210 | + $code = "if (\$f='".addslashes($style['url'])."') "; |
|
| 1211 | 1211 | } |
| 1212 | 1212 | $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
| 1213 | 1213 | if (isset($style['media']) and strlen($style['media'])) { |
| 1214 | - $code .= " media=\"" . addslashes($style['media']) . "\""; |
|
| 1214 | + $code .= " media=\"".addslashes($style['media'])."\""; |
|
| 1215 | 1215 | } |
| 1216 | 1216 | $code .= "/>';\n"; |
| 1217 | 1217 | if ($style['type'] != 'prive') { |
@@ -1231,9 +1231,9 @@ discard block |
||
| 1231 | 1231 | if (isset($info['script']) and count($info['script'])) { |
| 1232 | 1232 | foreach ($info['script'] as $script) { |
| 1233 | 1233 | if (isset($script['path']) and $script['path']) { |
| 1234 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1234 | + $code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) "; |
|
| 1235 | 1235 | } else { |
| 1236 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1236 | + $code = "if (\$f='".addslashes($script['url'])."') "; |
|
| 1237 | 1237 | } |
| 1238 | 1238 | $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
| 1239 | 1239 | if ($script['type'] != 'prive') { |
@@ -1296,10 +1296,10 @@ discard block |
||
| 1296 | 1296 | unset($GLOBALS['spip_pipeline']['all']); |
| 1297 | 1297 | $all_pipes = trim(array_shift($a)); |
| 1298 | 1298 | if ($all_pipes) { |
| 1299 | - $all_pipes = '|' . ltrim($a, '|'); |
|
| 1299 | + $all_pipes = '|'.ltrim($a, '|'); |
|
| 1300 | 1300 | } |
| 1301 | 1301 | if (count($a)) { |
| 1302 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1302 | + $all_pipes_end = '||'.array_shift($a); |
|
| 1303 | 1303 | } |
| 1304 | 1304 | } |
| 1305 | 1305 | $content = ""; |
@@ -1316,7 +1316,7 @@ discard block |
||
| 1316 | 1316 | // Eclater le pipeline en filtres et appliquer chaque filtre |
| 1317 | 1317 | foreach ($pipe as $fonc) { |
| 1318 | 1318 | $fonc = trim($fonc); |
| 1319 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1319 | + $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 1320 | 1320 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 1321 | 1321 | $file = $GLOBALS['spip_matrice'][$fonc]; |
| 1322 | 1322 | $file = "'$file'"; |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | if (defined($root_dir)) { |
| 1328 | 1328 | $dir = $root_dir; |
| 1329 | 1329 | } |
| 1330 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1330 | + $file = str_replace($regs[0], "'.".$dir.".'", $file); |
|
| 1331 | 1331 | $file = str_replace("''.", "", $file); |
| 1332 | 1332 | $file = str_replace(constant($dir), '', $file); |
| 1333 | 1333 | } |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | $content .= "// Pipeline $action \n" |
| 1341 | 1341 | . "function execute_pipeline_$action(&\$val){\n" |
| 1342 | 1342 | . $s_inc |
| 1343 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1343 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '') |
|
| 1344 | 1344 | . $s_call |
| 1345 | 1345 | . "return \$val;\n}\n"; |
| 1346 | 1346 | } |
@@ -1424,18 +1424,18 @@ discard block |
||
| 1424 | 1424 | $GLOBALS['fichier_php_compile_recent'] = 0; |
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1427 | + $contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>'; |
|
| 1428 | 1428 | // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
| 1429 | 1429 | // si pas de modif on ne touche pas au fichier initial |
| 1430 | 1430 | if (file_exists($nom)) { |
| 1431 | 1431 | if (substr($nom, -4) == '.php') { |
| 1432 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1432 | + $fichier_tmp = substr($nom, 0, -4).'.tmp.php'; |
|
| 1433 | 1433 | } |
| 1434 | 1434 | else { |
| 1435 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1435 | + $fichier_tmp = $nom.'.tmp'; |
|
| 1436 | 1436 | } |
| 1437 | 1437 | file_put_contents($fichier_tmp, $contenu); |
| 1438 | - if(md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1438 | + if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1439 | 1439 | $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
| 1440 | 1440 | @unlink($fichier_tmp); |
| 1441 | 1441 | return; |
@@ -555,11 +555,9 @@ discard block |
||
| 555 | 555 | if (!isset($msg[$p])) { |
| 556 | 556 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 557 | 557 | $msg[$p] = array($resume['erreur']); |
| 558 | - } |
|
| 559 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 558 | + } elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 560 | 559 | $msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')); |
| 561 | - } |
|
| 562 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 560 | + } elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 563 | 561 | $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
| 564 | 562 | } |
| 565 | 563 | } else { |
@@ -942,8 +940,7 @@ discard block |
||
| 942 | 940 | if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
| 943 | 941 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 944 | 942 | } |
| 945 | - } |
|
| 946 | - else{ |
|
| 943 | + } else{ |
|
| 947 | 944 | foreach ($info['chemin'] as $chemin) { |
| 948 | 945 | if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'], |
| 949 | 946 | $GLOBALS['spip_version_branche'], 'spip') |
@@ -1166,10 +1163,12 @@ discard block |
||
| 1166 | 1163 | } |
| 1167 | 1164 | $nom = $nomlower; |
| 1168 | 1165 | // une action vide est une declaration qui ne doit pas etre compilee ! |
| 1169 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel |
|
| 1166 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) { |
|
| 1167 | + // creer le pipeline eventuel |
|
| 1170 | 1168 | { |
| 1171 | 1169 | $GLOBALS['spip_pipeline'][$nom] = ""; |
| 1172 | 1170 | } |
| 1171 | + } |
|
| 1173 | 1172 | if ($action) { |
| 1174 | 1173 | if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) { |
| 1175 | 1174 | $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1", |
@@ -1430,8 +1429,7 @@ discard block |
||
| 1430 | 1429 | if (file_exists($nom)) { |
| 1431 | 1430 | if (substr($nom, -4) == '.php') { |
| 1432 | 1431 | $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
| 1433 | - } |
|
| 1434 | - else { |
|
| 1432 | + } else { |
|
| 1435 | 1433 | $fichier_tmp = $nom . '.tmp'; |
| 1436 | 1434 | } |
| 1437 | 1435 | file_put_contents($fichier_tmp, $contenu); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -25,63 +25,63 @@ discard block |
||
| 25 | 25 | * @return array |
| 26 | 26 | */ |
| 27 | 27 | function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) { |
| 28 | - static $process = array( // tableau constant |
|
| 29 | - 'debut' => 'paquet_debutElement', |
|
| 30 | - 'fin' => 'paquet_finElement', |
|
| 31 | - 'text' => 'paquet_textElement' |
|
| 32 | - ); |
|
| 33 | - |
|
| 34 | - $valider_xml = charger_fonction('valider', 'xml'); |
|
| 35 | - $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', "utf-8"); |
|
| 36 | - if (!$vxml->err) { |
|
| 37 | - // On veut toutes les variantes selon la version de SPIP |
|
| 38 | - if (!$plug) { |
|
| 39 | - return $vxml->versions; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - // compatibilite avec l'existant: |
|
| 43 | - $tree = $vxml->versions['0']; |
|
| 44 | - |
|
| 45 | - // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca. |
|
| 46 | - if (isset($tree['']) and !strlen($tree[''])) { |
|
| 47 | - unset($tree['']); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - $tree['slogan'] = $tree['prefix'] . "_slogan"; |
|
| 51 | - $tree['description'] = $tree['prefix'] . "_description"; |
|
| 52 | - paquet_readable_files($tree, "$dir_plugins$plug/"); |
|
| 53 | - if (!$tree['chemin']) { |
|
| 54 | - $tree['chemin'] = array(); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans |
|
| 58 | - // la structure d'infos du paquet en fonction de la version spip courante |
|
| 59 | - if (count($vxml->versions) > 1) { |
|
| 60 | - $vspip = $GLOBALS['spip_version_branche']; |
|
| 61 | - foreach ($vxml->versions as $_compatibilite => $_version) { |
|
| 62 | - if (($_version['balise'] == 'spip') |
|
| 63 | - and (plugin_version_compatible($_compatibilite, $vspip, 'spip')) |
|
| 64 | - ) { |
|
| 65 | - // on merge les sous-balises de la balise spip compatible avec celles de la |
|
| 66 | - // balise paquet |
|
| 67 | - foreach ($_version as $_index => $_balise) { |
|
| 68 | - if ($_index and $_index != 'balise') { |
|
| 69 | - $tree[$_index] = array_merge($tree[$_index], $_balise); |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - return $tree; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // Prendre les messages d'erreur sans les numeros de lignes |
|
| 80 | - $msg = array_map('array_shift', $vxml->err); |
|
| 81 | - $t = _T('plugins_erreur', array('plugins' => $plug)); |
|
| 82 | - array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . "</li></ul>"); |
|
| 83 | - |
|
| 84 | - return array('erreur' => $msg); |
|
| 28 | + static $process = array( // tableau constant |
|
| 29 | + 'debut' => 'paquet_debutElement', |
|
| 30 | + 'fin' => 'paquet_finElement', |
|
| 31 | + 'text' => 'paquet_textElement' |
|
| 32 | + ); |
|
| 33 | + |
|
| 34 | + $valider_xml = charger_fonction('valider', 'xml'); |
|
| 35 | + $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', "utf-8"); |
|
| 36 | + if (!$vxml->err) { |
|
| 37 | + // On veut toutes les variantes selon la version de SPIP |
|
| 38 | + if (!$plug) { |
|
| 39 | + return $vxml->versions; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + // compatibilite avec l'existant: |
|
| 43 | + $tree = $vxml->versions['0']; |
|
| 44 | + |
|
| 45 | + // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca. |
|
| 46 | + if (isset($tree['']) and !strlen($tree[''])) { |
|
| 47 | + unset($tree['']); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + $tree['slogan'] = $tree['prefix'] . "_slogan"; |
|
| 51 | + $tree['description'] = $tree['prefix'] . "_description"; |
|
| 52 | + paquet_readable_files($tree, "$dir_plugins$plug/"); |
|
| 53 | + if (!$tree['chemin']) { |
|
| 54 | + $tree['chemin'] = array(); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans |
|
| 58 | + // la structure d'infos du paquet en fonction de la version spip courante |
|
| 59 | + if (count($vxml->versions) > 1) { |
|
| 60 | + $vspip = $GLOBALS['spip_version_branche']; |
|
| 61 | + foreach ($vxml->versions as $_compatibilite => $_version) { |
|
| 62 | + if (($_version['balise'] == 'spip') |
|
| 63 | + and (plugin_version_compatible($_compatibilite, $vspip, 'spip')) |
|
| 64 | + ) { |
|
| 65 | + // on merge les sous-balises de la balise spip compatible avec celles de la |
|
| 66 | + // balise paquet |
|
| 67 | + foreach ($_version as $_index => $_balise) { |
|
| 68 | + if ($_index and $_index != 'balise') { |
|
| 69 | + $tree[$_index] = array_merge($tree[$_index], $_balise); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + return $tree; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // Prendre les messages d'erreur sans les numeros de lignes |
|
| 80 | + $msg = array_map('array_shift', $vxml->err); |
|
| 81 | + $t = _T('plugins_erreur', array('plugins' => $plug)); |
|
| 82 | + array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . "</li></ul>"); |
|
| 83 | + |
|
| 84 | + return array('erreur' => $msg); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | 95 | function paquet_readable_files(&$tree, $dir) { |
| 96 | - $prefix = strtolower($tree['prefix']); |
|
| 96 | + $prefix = strtolower($tree['prefix']); |
|
| 97 | 97 | |
| 98 | - $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? array($f) : array(); |
|
| 99 | - $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? array($f) : array(); |
|
| 100 | - $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? array($f) : array(); |
|
| 98 | + $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? array($f) : array(); |
|
| 99 | + $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? array($f) : array(); |
|
| 100 | + $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? array($f) : array(); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -114,35 +114,35 @@ discard block |
||
| 114 | 114 | * @param array $attrs |
| 115 | 115 | */ |
| 116 | 116 | function paquet_debutElement($phraseur, $name, $attrs) { |
| 117 | - xml_debutElement($phraseur, $name, $attrs); |
|
| 118 | - if ($phraseur->err) { |
|
| 119 | - return; |
|
| 120 | - } |
|
| 121 | - if (($name == 'paquet') or ($name == 'spip')) { |
|
| 122 | - if ($name == 'spip') { |
|
| 123 | - $n = $attrs['compatibilite']; |
|
| 124 | - $attrs = array(); |
|
| 125 | - } else { |
|
| 126 | - $n = '0'; |
|
| 127 | - $phraseur->contenu['paquet'] = $attrs; |
|
| 128 | - $attrs['menu'] = array(); |
|
| 129 | - $attrs['chemin'] = array(); |
|
| 130 | - $attrs['necessite'] = array(); |
|
| 131 | - $attrs['lib'] = array(); |
|
| 132 | - $attrs['onglet'] = array(); |
|
| 133 | - $attrs['procure'] = array(); |
|
| 134 | - $attrs['pipeline'] = array(); |
|
| 135 | - $attrs['utilise'] = array(); |
|
| 136 | - $attrs['style'] = array(); |
|
| 137 | - $attrs['script'] = array(); |
|
| 138 | - $attrs['genie'] = array(); |
|
| 139 | - } |
|
| 140 | - $phraseur->contenu['compatible'] = $n; |
|
| 141 | - $phraseur->versions[$phraseur->contenu['compatible']] = $attrs; |
|
| 142 | - } else { |
|
| 143 | - $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs; |
|
| 144 | - } |
|
| 145 | - $phraseur->versions[$phraseur->contenu['compatible']][''] = ''; |
|
| 117 | + xml_debutElement($phraseur, $name, $attrs); |
|
| 118 | + if ($phraseur->err) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 121 | + if (($name == 'paquet') or ($name == 'spip')) { |
|
| 122 | + if ($name == 'spip') { |
|
| 123 | + $n = $attrs['compatibilite']; |
|
| 124 | + $attrs = array(); |
|
| 125 | + } else { |
|
| 126 | + $n = '0'; |
|
| 127 | + $phraseur->contenu['paquet'] = $attrs; |
|
| 128 | + $attrs['menu'] = array(); |
|
| 129 | + $attrs['chemin'] = array(); |
|
| 130 | + $attrs['necessite'] = array(); |
|
| 131 | + $attrs['lib'] = array(); |
|
| 132 | + $attrs['onglet'] = array(); |
|
| 133 | + $attrs['procure'] = array(); |
|
| 134 | + $attrs['pipeline'] = array(); |
|
| 135 | + $attrs['utilise'] = array(); |
|
| 136 | + $attrs['style'] = array(); |
|
| 137 | + $attrs['script'] = array(); |
|
| 138 | + $attrs['genie'] = array(); |
|
| 139 | + } |
|
| 140 | + $phraseur->contenu['compatible'] = $n; |
|
| 141 | + $phraseur->versions[$phraseur->contenu['compatible']] = $attrs; |
|
| 142 | + } else { |
|
| 143 | + $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs; |
|
| 144 | + } |
|
| 145 | + $phraseur->versions[$phraseur->contenu['compatible']][''] = ''; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | * @param string $data |
| 155 | 155 | */ |
| 156 | 156 | function paquet_textElement($phraseur, $data) { |
| 157 | - xml_textElement($phraseur, $data); |
|
| 158 | - if ($phraseur->err or !(trim($data))) { |
|
| 159 | - return; |
|
| 160 | - } |
|
| 161 | - $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data; |
|
| 157 | + xml_textElement($phraseur, $data); |
|
| 158 | + if ($phraseur->err or !(trim($data))) { |
|
| 159 | + return; |
|
| 160 | + } |
|
| 161 | + $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -170,32 +170,32 @@ discard block |
||
| 170 | 170 | * @param string $name |
| 171 | 171 | */ |
| 172 | 172 | function paquet_finElement($phraseur, $name) { |
| 173 | - if ($phraseur->err) { |
|
| 174 | - return; |
|
| 175 | - } |
|
| 176 | - $n = $phraseur->contenu['compatible']; |
|
| 177 | - |
|
| 178 | - if (isset($phraseur->versions[$n][$name][0]) and is_array($phraseur->versions[$n][$name][0])) { |
|
| 179 | - $attrs = $phraseur->versions[$n][$name][0]; |
|
| 180 | - unset($phraseur->versions[$n][$name][0]); |
|
| 181 | - } else { |
|
| 182 | - $attrs = array(); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $texte = trim($phraseur->versions[$n]['']); |
|
| 186 | - $phraseur->versions[$n][''] = ''; |
|
| 187 | - |
|
| 188 | - $f = 'info_paquet_' . $name; |
|
| 189 | - if (function_exists($f)) { |
|
| 190 | - $f($phraseur, $attrs, $texte); |
|
| 191 | - } elseif (!$attrs) { |
|
| 192 | - $phraseur->versions[$n][$name] = $texte; |
|
| 193 | - } else { |
|
| 194 | - // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici |
|
| 195 | - $phraseur->versions[$n][$name][$attrs['nom']] = $attrs; |
|
| 196 | - # echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]); |
|
| 197 | - } |
|
| 198 | - xml_finElement($phraseur, $name, $attrs); |
|
| 173 | + if ($phraseur->err) { |
|
| 174 | + return; |
|
| 175 | + } |
|
| 176 | + $n = $phraseur->contenu['compatible']; |
|
| 177 | + |
|
| 178 | + if (isset($phraseur->versions[$n][$name][0]) and is_array($phraseur->versions[$n][$name][0])) { |
|
| 179 | + $attrs = $phraseur->versions[$n][$name][0]; |
|
| 180 | + unset($phraseur->versions[$n][$name][0]); |
|
| 181 | + } else { |
|
| 182 | + $attrs = array(); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $texte = trim($phraseur->versions[$n]['']); |
|
| 186 | + $phraseur->versions[$n][''] = ''; |
|
| 187 | + |
|
| 188 | + $f = 'info_paquet_' . $name; |
|
| 189 | + if (function_exists($f)) { |
|
| 190 | + $f($phraseur, $attrs, $texte); |
|
| 191 | + } elseif (!$attrs) { |
|
| 192 | + $phraseur->versions[$n][$name] = $texte; |
|
| 193 | + } else { |
|
| 194 | + // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici |
|
| 195 | + $phraseur->versions[$n][$name][$attrs['nom']] = $attrs; |
|
| 196 | + # echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]); |
|
| 197 | + } |
|
| 198 | + xml_finElement($phraseur, $name, $attrs); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -207,13 +207,13 @@ discard block |
||
| 207 | 207 | * @param string $texte |
| 208 | 208 | */ |
| 209 | 209 | function info_paquet_licence($phraseur, $attrs, $texte) { |
| 210 | - if (isset($attrs['lien'])) { |
|
| 211 | - $lien = $attrs['lien']; |
|
| 212 | - } else { |
|
| 213 | - $lien = ''; |
|
| 214 | - } |
|
| 215 | - $n = $phraseur->contenu['compatible']; |
|
| 216 | - $phraseur->versions[$n]['licence'][] = array('nom' => $texte, 'url' => $lien); |
|
| 210 | + if (isset($attrs['lien'])) { |
|
| 211 | + $lien = $attrs['lien']; |
|
| 212 | + } else { |
|
| 213 | + $lien = ''; |
|
| 214 | + } |
|
| 215 | + $n = $phraseur->contenu['compatible']; |
|
| 216 | + $phraseur->versions[$n]['licence'][] = array('nom' => $texte, 'url' => $lien); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -225,14 +225,14 @@ discard block |
||
| 225 | 225 | * @param string $texte |
| 226 | 226 | */ |
| 227 | 227 | function info_paquet_chemin($phraseur, $attrs, $texte) { |
| 228 | - $n = $phraseur->contenu['compatible']; |
|
| 229 | - if (isset($attrs['path'])) { |
|
| 230 | - if (isset($attrs['type'])) { |
|
| 231 | - $phraseur->versions[$n]['chemin'][] = array('path' => $attrs['path'], 'type' => $attrs['type']); |
|
| 232 | - } else { |
|
| 233 | - $phraseur->versions[$n]['chemin'][] = array('path' => $attrs['path']); |
|
| 234 | - } |
|
| 235 | - } |
|
| 228 | + $n = $phraseur->contenu['compatible']; |
|
| 229 | + if (isset($attrs['path'])) { |
|
| 230 | + if (isset($attrs['type'])) { |
|
| 231 | + $phraseur->versions[$n]['chemin'][] = array('path' => $attrs['path'], 'type' => $attrs['type']); |
|
| 232 | + } else { |
|
| 233 | + $phraseur->versions[$n]['chemin'][] = array('path' => $attrs['path']); |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -246,24 +246,24 @@ discard block |
||
| 246 | 246 | * @param string $texte |
| 247 | 247 | */ |
| 248 | 248 | function info_paquet_auteur($phraseur, $attrs, $texte) { |
| 249 | - # echo 'auteur ', $texte; var_dump($attrs); |
|
| 250 | - if (isset($attrs['mail'])) { |
|
| 251 | - if (strpos($attrs['mail'], '@')) { |
|
| 252 | - $attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']); |
|
| 253 | - } |
|
| 254 | - $mail = $attrs['mail']; |
|
| 255 | - } else { |
|
| 256 | - $mail = ''; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - if (isset($attrs['lien'])) { |
|
| 260 | - $lien = $attrs['lien']; |
|
| 261 | - } else { |
|
| 262 | - $lien = ''; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - $n = $phraseur->contenu['compatible']; |
|
| 266 | - $phraseur->versions[$n]['auteur'][] = array('nom' => $texte, 'url' => $lien, 'mail' => $mail); |
|
| 249 | + # echo 'auteur ', $texte; var_dump($attrs); |
|
| 250 | + if (isset($attrs['mail'])) { |
|
| 251 | + if (strpos($attrs['mail'], '@')) { |
|
| 252 | + $attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']); |
|
| 253 | + } |
|
| 254 | + $mail = $attrs['mail']; |
|
| 255 | + } else { |
|
| 256 | + $mail = ''; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + if (isset($attrs['lien'])) { |
|
| 260 | + $lien = $attrs['lien']; |
|
| 261 | + } else { |
|
| 262 | + $lien = ''; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + $n = $phraseur->contenu['compatible']; |
|
| 266 | + $phraseur->versions[$n]['auteur'][] = array('nom' => $texte, 'url' => $lien, 'mail' => $mail); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -276,14 +276,14 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | function info_paquet_credit($phraseur, $attrs, $texte) { |
| 278 | 278 | |
| 279 | - if (isset($attrs['lien'])) { |
|
| 280 | - $lien = $attrs['lien']; |
|
| 281 | - } else { |
|
| 282 | - $lien = ''; |
|
| 283 | - } |
|
| 279 | + if (isset($attrs['lien'])) { |
|
| 280 | + $lien = $attrs['lien']; |
|
| 281 | + } else { |
|
| 282 | + $lien = ''; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - $n = $phraseur->contenu['compatible']; |
|
| 286 | - $phraseur->versions[$n]['credit'][] = array('nom' => $texte, 'url' => $lien); |
|
| 285 | + $n = $phraseur->contenu['compatible']; |
|
| 286 | + $phraseur->versions[$n]['credit'][] = array('nom' => $texte, 'url' => $lien); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | * @param string $texte |
| 296 | 296 | */ |
| 297 | 297 | function info_paquet_copyright($phraseur, $attrs, $texte) { |
| 298 | - $n = $phraseur->contenu['compatible']; |
|
| 299 | - $phraseur->versions[$n]['copyright'][] = $texte; |
|
| 298 | + $n = $phraseur->contenu['compatible']; |
|
| 299 | + $phraseur->versions[$n]['copyright'][] = $texte; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | * @param string $texte |
| 309 | 309 | */ |
| 310 | 310 | function info_paquet_paquet($phraseur, $attrs, $texte) { |
| 311 | - $n = 0; |
|
| 312 | - $phraseur->versions[$n]['dtd'] = "paquet"; |
|
| 313 | - $phraseur->versions[$n]['balise'] = "paquet"; |
|
| 311 | + $n = 0; |
|
| 312 | + $phraseur->versions[$n]['dtd'] = "paquet"; |
|
| 313 | + $phraseur->versions[$n]['balise'] = "paquet"; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * @param string $texte |
| 323 | 323 | **/ |
| 324 | 324 | function info_paquet_traduire($phraseur, $attrs, $texte) { |
| 325 | - $n = $phraseur->contenu['compatible']; |
|
| 326 | - $phraseur->versions[$n]['traduire'][] = $attrs; |
|
| 325 | + $n = $phraseur->contenu['compatible']; |
|
| 326 | + $phraseur->versions[$n]['traduire'][] = $attrs; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -335,8 +335,8 @@ discard block |
||
| 335 | 335 | * @param string $texte |
| 336 | 336 | */ |
| 337 | 337 | function info_paquet_spip($phraseur, $attrs, $texte) { |
| 338 | - $n = $phraseur->contenu['compatible']; |
|
| 339 | - $phraseur->versions[$n]['balise'] = "spip"; |
|
| 338 | + $n = $phraseur->contenu['compatible']; |
|
| 339 | + $phraseur->versions[$n]['balise'] = "spip"; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | * @param string $texte |
| 349 | 349 | */ |
| 350 | 350 | function info_paquet_pipeline($phraseur, $attrs, $texte) { |
| 351 | - $n = $phraseur->contenu['compatible']; |
|
| 352 | - $phraseur->versions[$n]['pipeline'][] = $attrs; |
|
| 351 | + $n = $phraseur->contenu['compatible']; |
|
| 352 | + $phraseur->versions[$n]['pipeline'][] = $attrs; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | |
@@ -362,23 +362,23 @@ discard block |
||
| 362 | 362 | * @param string $texte |
| 363 | 363 | */ |
| 364 | 364 | function info_paquet_style($phraseur, $attrs, $texte) { |
| 365 | - $lien = $chemin = $type = $media = ''; |
|
| 366 | - |
|
| 367 | - include_spip('inc/utils'); |
|
| 368 | - if (tester_url_absolue($attrs['source'])) { |
|
| 369 | - $lien = $attrs['source']; |
|
| 370 | - } else { |
|
| 371 | - $chemin = $attrs['source']; |
|
| 372 | - } |
|
| 373 | - if (isset($attrs['type'])) { |
|
| 374 | - $type = $attrs['type']; |
|
| 375 | - } |
|
| 376 | - if (isset($attrs['media'])) { |
|
| 377 | - $media = $attrs['media']; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - $n = $phraseur->contenu['compatible']; |
|
| 381 | - $phraseur->versions[$n]['style'][] = array('url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media); |
|
| 365 | + $lien = $chemin = $type = $media = ''; |
|
| 366 | + |
|
| 367 | + include_spip('inc/utils'); |
|
| 368 | + if (tester_url_absolue($attrs['source'])) { |
|
| 369 | + $lien = $attrs['source']; |
|
| 370 | + } else { |
|
| 371 | + $chemin = $attrs['source']; |
|
| 372 | + } |
|
| 373 | + if (isset($attrs['type'])) { |
|
| 374 | + $type = $attrs['type']; |
|
| 375 | + } |
|
| 376 | + if (isset($attrs['media'])) { |
|
| 377 | + $media = $attrs['media']; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + $n = $phraseur->contenu['compatible']; |
|
| 381 | + $phraseur->versions[$n]['style'][] = array('url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | |
@@ -391,20 +391,20 @@ discard block |
||
| 391 | 391 | * @param string $texte |
| 392 | 392 | */ |
| 393 | 393 | function info_paquet_script($phraseur, $attrs, $texte) { |
| 394 | - $lien = $chemin = $type = $media = ''; |
|
| 395 | - |
|
| 396 | - include_spip('inc/utils'); |
|
| 397 | - if (tester_url_absolue($attrs['source'])) { |
|
| 398 | - $lien = $attrs['source']; |
|
| 399 | - } else { |
|
| 400 | - $chemin = $attrs['source']; |
|
| 401 | - } |
|
| 402 | - if (isset($attrs['type'])) { |
|
| 403 | - $type = $attrs['type']; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - $n = $phraseur->contenu['compatible']; |
|
| 407 | - $phraseur->versions[$n]['script'][] = array('url' => $lien, 'path' => $chemin, 'type' => $type); |
|
| 394 | + $lien = $chemin = $type = $media = ''; |
|
| 395 | + |
|
| 396 | + include_spip('inc/utils'); |
|
| 397 | + if (tester_url_absolue($attrs['source'])) { |
|
| 398 | + $lien = $attrs['source']; |
|
| 399 | + } else { |
|
| 400 | + $chemin = $attrs['source']; |
|
| 401 | + } |
|
| 402 | + if (isset($attrs['type'])) { |
|
| 403 | + $type = $attrs['type']; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + $n = $phraseur->contenu['compatible']; |
|
| 407 | + $phraseur->versions[$n]['script'][] = array('url' => $lien, 'path' => $chemin, 'type' => $type); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -415,6 +415,6 @@ discard block |
||
| 415 | 415 | * @param string $texte |
| 416 | 416 | */ |
| 417 | 417 | function info_paquet_genie($phraseur, $attrs, $texte) { |
| 418 | - $n = $phraseur->contenu['compatible']; |
|
| 419 | - $phraseur->versions[$n]['genie'][] = $attrs; |
|
| 418 | + $n = $phraseur->contenu['compatible']; |
|
| 419 | + $phraseur->versions[$n]['genie'][] = $attrs; |
|
| 420 | 420 | } |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | unset($tree['']); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $tree['slogan'] = $tree['prefix'] . "_slogan"; |
|
| 51 | - $tree['description'] = $tree['prefix'] . "_description"; |
|
| 50 | + $tree['slogan'] = $tree['prefix']."_slogan"; |
|
| 51 | + $tree['description'] = $tree['prefix']."_description"; |
|
| 52 | 52 | paquet_readable_files($tree, "$dir_plugins$plug/"); |
| 53 | 53 | if (!$tree['chemin']) { |
| 54 | 54 | $tree['chemin'] = array(); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // Prendre les messages d'erreur sans les numeros de lignes |
| 80 | 80 | $msg = array_map('array_shift', $vxml->err); |
| 81 | 81 | $t = _T('plugins_erreur', array('plugins' => $plug)); |
| 82 | - array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . "</li></ul>"); |
|
| 82 | + array_unshift($msg, $t." <ul class='erreur_xml'><li>".reset($msg)."</li></ul>"); |
|
| 83 | 83 | |
| 84 | 84 | return array('erreur' => $msg); |
| 85 | 85 | } |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | function paquet_readable_files(&$tree, $dir) { |
| 96 | 96 | $prefix = strtolower($tree['prefix']); |
| 97 | 97 | |
| 98 | - $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? array($f) : array(); |
|
| 99 | - $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? array($f) : array(); |
|
| 100 | - $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? array($f) : array(); |
|
| 98 | + $tree['options'] = (is_readable($dir.$f = ($prefix.'_options.php'))) ? array($f) : array(); |
|
| 99 | + $tree['fonctions'] = (is_readable($dir.$f = ($prefix.'_fonctions.php'))) ? array($f) : array(); |
|
| 100 | + $tree['install'] = (is_readable($dir.$f = ($prefix.'_administrations.php'))) ? array($f) : array(); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $texte = trim($phraseur->versions[$n]['']); |
| 186 | 186 | $phraseur->versions[$n][''] = ''; |
| 187 | 187 | |
| 188 | - $f = 'info_paquet_' . $name; |
|
| 188 | + $f = 'info_paquet_'.$name; |
|
| 189 | 189 | if (function_exists($f)) { |
| 190 | 190 | $f($phraseur, $attrs, $texte); |
| 191 | 191 | } elseif (!$attrs) { |