@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | * Description de la boucle complétée des champs |
| 39 | 39 | */ |
| 40 | 40 | function iterateur_POUR_dist($b) { |
| 41 | - $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 42 | - $b->show = [ |
|
| 43 | - 'field' => [ |
|
| 44 | - 'cle' => 'STRING', |
|
| 45 | - 'valeur' => 'STRING', |
|
| 46 | - ] |
|
| 47 | - ]; |
|
| 41 | + $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 42 | + $b->show = [ |
|
| 43 | + 'field' => [ |
|
| 44 | + 'cle' => 'STRING', |
|
| 45 | + 'valeur' => 'STRING', |
|
| 46 | + ] |
|
| 47 | + ]; |
|
| 48 | 48 | |
| 49 | - return $b; |
|
| 49 | + return $b; |
|
| 50 | 50 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | * Description de la boucle complétée des champs |
| 39 | 39 | */ |
| 40 | 40 | function iterateur_php_dist($b, $iteratorName) { |
| 41 | - $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 42 | - $b->show = [ |
|
| 43 | - 'field' => [ |
|
| 44 | - 'cle' => 'STRING', |
|
| 45 | - 'valeur' => 'STRING', |
|
| 46 | - ] |
|
| 47 | - ]; |
|
| 48 | - |
|
| 49 | - foreach (get_class_methods($iteratorName) as $method) { |
|
| 50 | - $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return $b; |
|
| 41 | + $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 42 | + $b->show = [ |
|
| 43 | + 'field' => [ |
|
| 44 | + 'cle' => 'STRING', |
|
| 45 | + 'valeur' => 'STRING', |
|
| 46 | + ] |
|
| 47 | + ]; |
|
| 48 | + |
|
| 49 | + foreach (get_class_methods($iteratorName) as $method) { |
|
| 50 | + $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return $b; |
|
| 54 | 54 | } |
@@ -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 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // passer en minuscules (cf les balises de formulaires) |
| 80 | 80 | // et inclure le fichier |
| 81 | 81 | if ( |
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | + !$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 83 | 83 | // si le fichier truc/machin/nom.php n'existe pas, |
| 84 | 84 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 85 | 85 | and strlen(dirname($dossier)) and dirname($dossier) != '.' |
@@ -98,19 +98,19 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Echec : message d'erreur |
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 102 | 102 | ($inc ? '' : " (fichier $d absent de $dossier)")); |
| 103 | 103 | |
| 104 | 104 | include_spip('inc/minipres'); |
| 105 | 105 | echo minipres( |
| 106 | 106 | _T('forum_titre_erreur'), |
| 107 | 107 | $inc ? |
| 108 | - _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 108 | + _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($f).'</code>']) |
|
| 109 | 109 | . '<br />' |
| 110 | - . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 110 | + . _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($g).'</code>']) |
|
| 111 | 111 | : |
| 112 | - _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 113 | - ['all_inline' => true,'status' => 404] |
|
| 112 | + _T('fichier_introuvable', ['fichier' => '<code>'.spip_htmlentities($d).'</code>']), |
|
| 113 | + ['all_inline' => true, 'status' => 404] |
|
| 114 | 114 | ); |
| 115 | 115 | exit; |
| 116 | 116 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * - string : chemin du fichier trouvé |
| 157 | 157 | **/ |
| 158 | 158 | function include_spip($f, $include = true) { |
| 159 | - return find_in_path($f . '.php', '', $include); |
|
| 159 | + return find_in_path($f.'.php', '', $include); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * - string : chemin du fichier trouvé |
| 177 | 177 | **/ |
| 178 | 178 | function require_spip($f) { |
| 179 | - return find_in_path($f . '.php', '', 'required'); |
|
| 179 | + return find_in_path($f.'.php', '', 'required'); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | // donc il faut l'inclure "en globals" |
| 194 | 194 | if ($f = find_in_path('mes_fonctions.php')) { |
| 195 | 195 | global $dossier_squelettes; |
| 196 | - include_once(_ROOT_CWD . $f); |
|
| 196 | + include_once(_ROOT_CWD.$f); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // appliquer notre fonction si elle existe |
| 301 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 301 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 302 | 302 | if (function_exists($fonc)) { |
| 303 | 303 | $val = $fonc($val); |
| 304 | 304 | } // plantage ? |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | function spip_log($message = null, $name = null) { |
| 364 | 364 | static $pre = []; |
| 365 | 365 | static $log; |
| 366 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 366 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 367 | 367 | if (!isset($regs[1]) or !$logname = $regs[1]) { |
| 368 | 368 | $logname = null; |
| 369 | 369 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | if (!is_string($message)) { |
| 392 | 392 | $message = print_r($message, true); |
| 393 | 393 | } |
| 394 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 394 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | foreach ($regexp as $r => $e) { |
| 598 | 598 | $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e)); |
| 599 | 599 | } |
| 600 | - $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,'; |
|
| 600 | + $regexp = ',^('.implode('|', $regexp).'[[]?[]]?)(=.*)?$,'; |
|
| 601 | 601 | $ajouts = array_flip(explode('|', $c)); |
| 602 | 602 | $u = is_array($v) ? $v : rawurlencode((string) $v); |
| 603 | 603 | $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 625 | 625 | // pour un tableau ce sera fait dans la prochaine boucle |
| 626 | 626 | elseif (substr($r[1], -2) != '[]') { |
| 627 | - $url[$n] = $r[1] . '=' . $u; |
|
| 627 | + $url[$n] = $r[1].'='.$u; |
|
| 628 | 628 | unset($ajouts[$r[1]]); |
| 629 | 629 | } |
| 630 | 630 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -645,11 +645,11 @@ discard block |
||
| 645 | 645 | } elseif ($testv) { |
| 646 | 646 | foreach ($ajouts as $k => $n) { |
| 647 | 647 | if (!is_array($v)) { |
| 648 | - $url[] = $k . '=' . $u; |
|
| 648 | + $url[] = $k.'='.$u; |
|
| 649 | 649 | } else { |
| 650 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 650 | + $id = (substr($k, -2) == '[]') ? $k : ($k.'[]'); |
|
| 651 | 651 | foreach ($v as $w) { |
| 652 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 652 | + $url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | } |
@@ -660,10 +660,10 @@ discard block |
||
| 660 | 660 | |
| 661 | 661 | // recomposer l'adresse |
| 662 | 662 | if ($url) { |
| 663 | - $a .= '?' . join($sep, $url); |
|
| 663 | + $a .= '?'.join($sep, $url); |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - return $a . $ancre; |
|
| 666 | + return $a.$ancre; |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | /** |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | translitteration($ancre) |
| 694 | 694 | ); |
| 695 | 695 | } |
| 696 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 696 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | /** |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | * @return bool |
| 810 | 810 | */ |
| 811 | 811 | function test_plugin_actif($plugin) { |
| 812 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 812 | + return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
@@ -941,7 +941,7 @@ discard block |
||
| 941 | 941 | $value = interdire_scripts($value, -1); |
| 942 | 942 | } |
| 943 | 943 | if (!empty($options['class'])) { |
| 944 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 944 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 945 | 945 | } |
| 946 | 946 | $text = str_replace("@$name@", $value, $text); |
| 947 | 947 | unset($args[$name]); |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | // Si des variables n'ont pas ete inserees, le signaler |
| 951 | 951 | // (chaines de langues pas a jour) |
| 952 | 952 | if ($args) { |
| 953 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 953 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 954 | 954 | } |
| 955 | 955 | } |
| 956 | 956 | |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | function joli_repertoire($rep) { |
| 975 | 975 | $a = substr($rep, 0, 1); |
| 976 | 976 | if ($a <> '.' and $a <> '/') { |
| 977 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 977 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 978 | 978 | } |
| 979 | 979 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 980 | 980 | |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | $p -= ($x * 1000); |
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1031 | + return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1032 | 1032 | } |
| 1033 | 1033 | } |
| 1034 | 1034 | |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | if ($taches and count($taches) and !spip_connect()) { |
| 1096 | 1096 | return false; |
| 1097 | 1097 | } |
| 1098 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1098 | + spip_log('cron !', 'jq'._LOG_DEBUG); |
|
| 1099 | 1099 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 1100 | 1100 | return $genie($taches); |
| 1101 | 1101 | } |
@@ -1199,7 +1199,7 @@ discard block |
||
| 1199 | 1199 | |
| 1200 | 1200 | if ($queue_next_job_time == -1) { |
| 1201 | 1201 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 1202 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1202 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt'); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | // utiliser un cache memoire si dispo |
| 1205 | 1205 | if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
@@ -1268,8 +1268,8 @@ discard block |
||
| 1268 | 1268 | $src = ''; |
| 1269 | 1269 | } |
| 1270 | 1270 | if ($script) { |
| 1271 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1272 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1271 | + $script = ("/*<![CDATA[*/\n". |
|
| 1272 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 1273 | 1273 | '/*]]>*/'); |
| 1274 | 1274 | } |
| 1275 | 1275 | if ($noscript) { |
@@ -1355,13 +1355,13 @@ discard block |
||
| 1355 | 1355 | if ($path_base == null) { |
| 1356 | 1356 | // Chemin standard depuis l'espace public |
| 1357 | 1357 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 1358 | - _DIR_RACINE . ':' . |
|
| 1359 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1360 | - _DIR_RACINE . 'prive/:' . |
|
| 1358 | + _DIR_RACINE.':'. |
|
| 1359 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 1360 | + _DIR_RACINE.'prive/:'. |
|
| 1361 | 1361 | _DIR_RESTREINT; |
| 1362 | 1362 | // Ajouter squelettes/ |
| 1363 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1364 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1363 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 1364 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 1365 | 1365 | } |
| 1366 | 1366 | foreach (explode(':', $path) as $dir) { |
| 1367 | 1367 | if (strlen($dir) and substr($dir, -1) != '/') { |
@@ -1373,7 +1373,7 @@ discard block |
||
| 1373 | 1373 | // Et le(s) dossier(s) des squelettes nommes |
| 1374 | 1374 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1375 | 1375 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1376 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1376 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 1377 | 1377 | } |
| 1378 | 1378 | } |
| 1379 | 1379 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
@@ -1384,7 +1384,7 @@ discard block |
||
| 1384 | 1384 | |
| 1385 | 1385 | if (is_array($dir_path) or strlen($dir_path)) { |
| 1386 | 1386 | $tete = ''; |
| 1387 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1387 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') { |
|
| 1388 | 1388 | $tete = array_shift($path_base); |
| 1389 | 1389 | } |
| 1390 | 1390 | $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
@@ -1405,7 +1405,7 @@ discard block |
||
| 1405 | 1405 | // Et le(s) dossier(s) des squelettes nommes |
| 1406 | 1406 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1407 | 1407 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1408 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1408 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/'); |
|
| 1409 | 1409 | } |
| 1410 | 1410 | } |
| 1411 | 1411 | |
@@ -1476,14 +1476,14 @@ discard block |
||
| 1476 | 1476 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 1477 | 1477 | if ( |
| 1478 | 1478 | preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 1479 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1479 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg' |
|
| 1480 | 1480 | and $f = find_in_theme("$file_svg_generique") |
| 1481 | 1481 | ) { |
| 1482 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1482 | + if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) { |
|
| 1483 | 1483 | return $themefiles["$subdir$file"] = $fsize; |
| 1484 | 1484 | } |
| 1485 | 1485 | else { |
| 1486 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1486 | + return $themefiles["$subdir$file"] = "$f?".$m[1].'px'; |
|
| 1487 | 1487 | } |
| 1488 | 1488 | } |
| 1489 | 1489 | |
@@ -1493,7 +1493,7 @@ discard block |
||
| 1493 | 1493 | return $themefiles["$subdir$file"] = $f; |
| 1494 | 1494 | } |
| 1495 | 1495 | } |
| 1496 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1496 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 1497 | 1497 | |
| 1498 | 1498 | return $themefiles["$subdir$file"] = ''; |
| 1499 | 1499 | } |
@@ -1601,8 +1601,8 @@ discard block |
||
| 1601 | 1601 | return false; |
| 1602 | 1602 | } |
| 1603 | 1603 | if ($include and !isset($inc[$dirname][$file])) { |
| 1604 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1605 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1604 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1605 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1606 | 1606 | } |
| 1607 | 1607 | |
| 1608 | 1608 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
@@ -1615,14 +1615,14 @@ discard block |
||
| 1615 | 1615 | } |
| 1616 | 1616 | |
| 1617 | 1617 | foreach (creer_chemin() as $dir) { |
| 1618 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1619 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1618 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 1619 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 1620 | 1620 | } |
| 1621 | 1621 | if ($dirs[$a]) { |
| 1622 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1622 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 1623 | 1623 | if ($include and !isset($inc[$dirname][$file])) { |
| 1624 | - include_once _ROOT_CWD . $a; |
|
| 1625 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1624 | + include_once _ROOT_CWD.$a; |
|
| 1625 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1626 | 1626 | } |
| 1627 | 1627 | if (!defined('_SAUVER_CHEMIN')) { |
| 1628 | 1628 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
@@ -1632,7 +1632,7 @@ discard block |
||
| 1632 | 1632 | define('_SAUVER_CHEMIN', true); |
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1635 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 1636 | 1636 | } |
| 1637 | 1637 | } |
| 1638 | 1638 | } |
@@ -1658,7 +1658,7 @@ discard block |
||
| 1658 | 1658 | define('_SAUVER_CHEMIN', true); |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1661 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | 1664 | function clear_path_cache() { |
@@ -1728,12 +1728,12 @@ discard block |
||
| 1728 | 1728 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 1729 | 1729 | // on a pas encore inclus flock.php |
| 1730 | 1730 | if (!function_exists('preg_files')) { |
| 1731 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1731 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | 1734 | // Parcourir le chemin |
| 1735 | 1735 | foreach (creer_chemin() as $d) { |
| 1736 | - $f = $d . $dir; |
|
| 1736 | + $f = $d.$dir; |
|
| 1737 | 1737 | if (@is_dir($f)) { |
| 1738 | 1738 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
| 1739 | 1739 | foreach ($liste as $chemin) { |
@@ -1783,9 +1783,9 @@ discard block |
||
| 1783 | 1783 | if ($type === 'defaut') { |
| 1784 | 1784 | $objet = objet_type($quoi); |
| 1785 | 1785 | if ( |
| 1786 | - $f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1786 | + $f = charger_fonction('generer_'.$objet.'_url', 'urls', true) |
|
| 1787 | 1787 | // deprecated |
| 1788 | - or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1788 | + or $f = charger_fonction('generer_url_'.$objet, 'urls', true) |
|
| 1789 | 1789 | ) { |
| 1790 | 1790 | return $f; |
| 1791 | 1791 | } |
@@ -1798,7 +1798,7 @@ discard block |
||
| 1798 | 1798 | } |
| 1799 | 1799 | |
| 1800 | 1800 | // inclure le module d'url |
| 1801 | - include_spip('urls/' . $url_type); |
|
| 1801 | + include_spip('urls/'.$url_type); |
|
| 1802 | 1802 | |
| 1803 | 1803 | switch ($quoi) { |
| 1804 | 1804 | case 'page': |
@@ -1951,8 +1951,8 @@ discard block |
||
| 1951 | 1951 | include_spip('base/connect_sql'); |
| 1952 | 1952 | $id_type = id_table_objet($entite, $public); |
| 1953 | 1953 | |
| 1954 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1955 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1954 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1955 | + . '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1956 | 1956 | . (!$args ? '' : "&$args") |
| 1957 | 1957 | . (!$ancre ? '' : "#$ancre"); |
| 1958 | 1958 | } |
@@ -2127,7 +2127,7 @@ discard block |
||
| 2127 | 2127 | !empty($_SERVER['QUERY_STRING']) |
| 2128 | 2128 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2129 | 2129 | ) { |
| 2130 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2130 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2131 | 2131 | } |
| 2132 | 2132 | } |
| 2133 | 2133 | } |
@@ -2165,9 +2165,9 @@ discard block |
||
| 2165 | 2165 | array_shift($myself); |
| 2166 | 2166 | $myself = implode('/', $myself); |
| 2167 | 2167 | } |
| 2168 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2168 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 2169 | 2169 | |
| 2170 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2170 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 2171 | 2171 | |
| 2172 | 2172 | return $url; |
| 2173 | 2173 | } |
@@ -2206,16 +2206,16 @@ discard block |
||
| 2206 | 2206 | function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) { |
| 2207 | 2207 | $script ??= ''; |
| 2208 | 2208 | if (!$rel) { |
| 2209 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2209 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 2210 | 2210 | } else { |
| 2211 | 2211 | if (!is_string($rel)) { |
| 2212 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2212 | + $rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT; |
|
| 2213 | 2213 | } |
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | 2216 | [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
| 2217 | 2217 | if ($script and ($script <> 'accueil' or $rel)) { |
| 2218 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2218 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 2219 | 2219 | } elseif ($args) { |
| 2220 | 2220 | $args = "?$args"; |
| 2221 | 2221 | } |
@@ -2223,7 +2223,7 @@ discard block |
||
| 2223 | 2223 | $args .= "#$ancre"; |
| 2224 | 2224 | } |
| 2225 | 2225 | |
| 2226 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2226 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2227 | 2227 | } |
| 2228 | 2228 | |
| 2229 | 2229 | // |
@@ -2305,10 +2305,10 @@ discard block |
||
| 2305 | 2305 | $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
| 2306 | 2306 | } |
| 2307 | 2307 | if ($args) { |
| 2308 | - $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2308 | + $action .= (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 2309 | 2309 | } |
| 2310 | 2310 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 2311 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2311 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2312 | 2312 | } |
| 2313 | 2313 | |
| 2314 | 2314 | if (!$no_entities) { |
@@ -2320,7 +2320,7 @@ discard block |
||
| 2320 | 2320 | |
| 2321 | 2321 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2322 | 2322 | |
| 2323 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2323 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 2324 | 2324 | } |
| 2325 | 2325 | |
| 2326 | 2326 | // Pour les formulaires en methode POST, |
@@ -2355,8 +2355,7 @@ discard block |
||
| 2355 | 2355 | . "><div>\n" |
| 2356 | 2356 | . "<input type='hidden' name='exec' value='$script1' />" |
| 2357 | 2357 | . $corps |
| 2358 | - . (!$submit ? '' : |
|
| 2359 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2358 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>')) |
|
| 2360 | 2359 | . "</div></form>\n"; |
| 2361 | 2360 | } |
| 2362 | 2361 | |
@@ -2381,14 +2380,14 @@ discard block |
||
| 2381 | 2380 | ? generer_url_ecrire(_request('exec')) |
| 2382 | 2381 | : generer_url_public(); |
| 2383 | 2382 | |
| 2384 | - return "\n<form action='" . |
|
| 2385 | - $h . |
|
| 2386 | - "'" . |
|
| 2387 | - $atts . |
|
| 2388 | - ">\n" . |
|
| 2389 | - '<div>' . |
|
| 2390 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2391 | - $corps . |
|
| 2383 | + return "\n<form action='". |
|
| 2384 | + $h. |
|
| 2385 | + "'". |
|
| 2386 | + $atts. |
|
| 2387 | + ">\n". |
|
| 2388 | + '<div>'. |
|
| 2389 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 2390 | + $corps. |
|
| 2392 | 2391 | '</div></form>'; |
| 2393 | 2392 | } |
| 2394 | 2393 | |
@@ -2416,7 +2415,7 @@ discard block |
||
| 2416 | 2415 | : generer_url_public('', '', false, false); |
| 2417 | 2416 | $url = parametre_url($url, 'action', $script); |
| 2418 | 2417 | if ($args) { |
| 2419 | - $url .= quote_amp('&' . $args); |
|
| 2418 | + $url .= quote_amp('&'.$args); |
|
| 2420 | 2419 | } |
| 2421 | 2420 | |
| 2422 | 2421 | if ($no_entities) { |
@@ -2450,9 +2449,9 @@ discard block |
||
| 2450 | 2449 | } |
| 2451 | 2450 | $url = |
| 2452 | 2451 | (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
| 2453 | - . $script . '/' |
|
| 2452 | + . $script.'/' |
|
| 2454 | 2453 | . ($path ? trim($path, '/') : '') |
| 2455 | - . ($args ? '?' . quote_amp($args) : ''); |
|
| 2454 | + . ($args ? '?'.quote_amp($args) : ''); |
|
| 2456 | 2455 | |
| 2457 | 2456 | if ($no_entities) { |
| 2458 | 2457 | $url = str_replace('&', '&', $url); |
@@ -2501,22 +2500,22 @@ discard block |
||
| 2501 | 2500 | |
| 2502 | 2501 | // le nom du repertoire plugins/ activables/desactivables |
| 2503 | 2502 | if (!defined('_DIR_PLUGINS')) { |
| 2504 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2503 | + define('_DIR_PLUGINS', _DIR_RACINE.'plugins/'); |
|
| 2505 | 2504 | } |
| 2506 | 2505 | |
| 2507 | 2506 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 2508 | 2507 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 2509 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2508 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/'); |
|
| 2510 | 2509 | } |
| 2511 | 2510 | |
| 2512 | 2511 | // le nom du repertoire des librairies |
| 2513 | 2512 | if (!defined('_DIR_LIB')) { |
| 2514 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2513 | + define('_DIR_LIB', _DIR_RACINE.'lib/'); |
|
| 2515 | 2514 | } |
| 2516 | 2515 | |
| 2517 | 2516 | // répertoire des libs via Composer |
| 2518 | 2517 | if (!defined('_DIR_VENDOR')) { |
| 2519 | - define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 2518 | + define('_DIR_VENDOR', _DIR_RACINE.'vendor/'); |
|
| 2520 | 2519 | } |
| 2521 | 2520 | |
| 2522 | 2521 | if (!defined('_DIR_IMG')) { |
@@ -2526,29 +2525,29 @@ discard block |
||
| 2526 | 2525 | define('_DIR_LOGOS', $pa); |
| 2527 | 2526 | } |
| 2528 | 2527 | if (!defined('_DIR_IMG_ICONES')) { |
| 2529 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2528 | + define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/'); |
|
| 2530 | 2529 | } |
| 2531 | 2530 | |
| 2532 | 2531 | if (!defined('_DIR_DUMP')) { |
| 2533 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2532 | + define('_DIR_DUMP', $ti.'dump/'); |
|
| 2534 | 2533 | } |
| 2535 | 2534 | if (!defined('_DIR_SESSIONS')) { |
| 2536 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2535 | + define('_DIR_SESSIONS', $ti.'sessions/'); |
|
| 2537 | 2536 | } |
| 2538 | 2537 | if (!defined('_DIR_TRANSFERT')) { |
| 2539 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2538 | + define('_DIR_TRANSFERT', $ti.'upload/'); |
|
| 2540 | 2539 | } |
| 2541 | 2540 | if (!defined('_DIR_CACHE')) { |
| 2542 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2541 | + define('_DIR_CACHE', $ti.'cache/'); |
|
| 2543 | 2542 | } |
| 2544 | 2543 | if (!defined('_DIR_CACHE_XML')) { |
| 2545 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2544 | + define('_DIR_CACHE_XML', _DIR_CACHE.'xml/'); |
|
| 2546 | 2545 | } |
| 2547 | 2546 | if (!defined('_DIR_SKELS')) { |
| 2548 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2547 | + define('_DIR_SKELS', _DIR_CACHE.'skel/'); |
|
| 2549 | 2548 | } |
| 2550 | 2549 | if (!defined('_DIR_AIDE')) { |
| 2551 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2550 | + define('_DIR_AIDE', _DIR_CACHE.'aide/'); |
|
| 2552 | 2551 | } |
| 2553 | 2552 | if (!defined('_DIR_TMP')) { |
| 2554 | 2553 | define('_DIR_TMP', $ti); |
@@ -2577,27 +2576,27 @@ discard block |
||
| 2577 | 2576 | // Declaration des fichiers |
| 2578 | 2577 | |
| 2579 | 2578 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 2580 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2579 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php'); |
|
| 2581 | 2580 | } |
| 2582 | 2581 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 2583 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2582 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php'); |
|
| 2584 | 2583 | } |
| 2585 | 2584 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 2586 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2585 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php'); |
|
| 2587 | 2586 | } |
| 2588 | 2587 | if (!defined('_CACHE_PIPELINES')) { |
| 2589 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2588 | + define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php'); |
|
| 2590 | 2589 | } |
| 2591 | 2590 | if (!defined('_CACHE_CHEMIN')) { |
| 2592 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2591 | + define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt'); |
|
| 2593 | 2592 | } |
| 2594 | 2593 | |
| 2595 | 2594 | # attention .php obligatoire pour ecrire_fichier_securise |
| 2596 | 2595 | if (!defined('_FILE_META')) { |
| 2597 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2596 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 2598 | 2597 | } |
| 2599 | 2598 | if (!defined('_DIR_LOG')) { |
| 2600 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2599 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 2601 | 2600 | } |
| 2602 | 2601 | if (!defined('_FILE_LOG')) { |
| 2603 | 2602 | define('_FILE_LOG', 'spip'); |
@@ -2614,8 +2613,8 @@ discard block |
||
| 2614 | 2613 | if (!defined('_FILE_CONNECT')) { |
| 2615 | 2614 | define( |
| 2616 | 2615 | '_FILE_CONNECT', |
| 2617 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2618 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2616 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 2617 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 2619 | 2618 | : false)) |
| 2620 | 2619 | ); |
| 2621 | 2620 | } |
@@ -2627,7 +2626,7 @@ discard block |
||
| 2627 | 2626 | if (!defined('_FILE_CHMOD')) { |
| 2628 | 2627 | define( |
| 2629 | 2628 | '_FILE_CHMOD', |
| 2630 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2629 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 2631 | 2630 | : false) |
| 2632 | 2631 | ); |
| 2633 | 2632 | } |
@@ -2640,10 +2639,10 @@ discard block |
||
| 2640 | 2639 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 2641 | 2640 | } |
| 2642 | 2641 | if (!defined('_FILE_CONNECT_TMP')) { |
| 2643 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2642 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 2644 | 2643 | } |
| 2645 | 2644 | if (!defined('_FILE_CHMOD_TMP')) { |
| 2646 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2645 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 2647 | 2646 | } |
| 2648 | 2647 | |
| 2649 | 2648 | // Definition des droits d'acces en ecriture |
@@ -2661,13 +2660,13 @@ discard block |
||
| 2661 | 2660 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 2662 | 2661 | } |
| 2663 | 2662 | if (!defined('_ROOT_PLUGINS')) { |
| 2664 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2663 | + define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/'); |
|
| 2665 | 2664 | } |
| 2666 | 2665 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 2667 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2666 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/'); |
|
| 2668 | 2667 | } |
| 2669 | 2668 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 2670 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2669 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2671 | 2670 | } |
| 2672 | 2671 | |
| 2673 | 2672 | // La taille des Log |
@@ -2704,7 +2703,7 @@ discard block |
||
| 2704 | 2703 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 2705 | 2704 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 2706 | 2705 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 2707 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2706 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 2708 | 2707 | |
| 2709 | 2708 | // charger tout de suite le path et son cache |
| 2710 | 2709 | load_path_cache(); |
@@ -2740,7 +2739,7 @@ discard block |
||
| 2740 | 2739 | !empty($_SERVER['QUERY_STRING']) |
| 2741 | 2740 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2742 | 2741 | ) { |
| 2743 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2742 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2744 | 2743 | } |
| 2745 | 2744 | } |
| 2746 | 2745 | |
@@ -2776,7 +2775,7 @@ discard block |
||
| 2776 | 2775 | ) { |
| 2777 | 2776 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 2778 | 2777 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 2779 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2778 | + $uri_ref = ($uri_ref['path'] ?? '').'/'; |
|
| 2780 | 2779 | } else { |
| 2781 | 2780 | $uri_ref = ''; |
| 2782 | 2781 | } |
@@ -2870,7 +2869,7 @@ discard block |
||
| 2870 | 2869 | } |
| 2871 | 2870 | if (!defined('_CACHE_RUBRIQUES')) { |
| 2872 | 2871 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 2873 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2872 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2874 | 2873 | } |
| 2875 | 2874 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 2876 | 2875 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -3092,7 +3091,7 @@ discard block |
||
| 3092 | 3091 | } |
| 3093 | 3092 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 3094 | 3093 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 3095 | - . ' ' . _VAR_MODE); |
|
| 3094 | + . ' '._VAR_MODE); |
|
| 3096 | 3095 | } |
| 3097 | 3096 | } // pas autorise ? |
| 3098 | 3097 | else { |
@@ -3107,7 +3106,7 @@ discard block |
||
| 3107 | 3106 | if (strpos($self, 'page=login') === false) { |
| 3108 | 3107 | include_spip('inc/headers'); |
| 3109 | 3108 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 3110 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3109 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 3111 | 3110 | } |
| 3112 | 3111 | } |
| 3113 | 3112 | // sinon tant pis |
@@ -3157,10 +3156,10 @@ discard block |
||
| 3157 | 3156 | **/ |
| 3158 | 3157 | function verifier_visiteur() { |
| 3159 | 3158 | @spip_initialisation_core( |
| 3160 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3161 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3162 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3163 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3159 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 3160 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 3161 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3162 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3164 | 3163 | ); |
| 3165 | 3164 | |
| 3166 | 3165 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -3193,7 +3192,7 @@ discard block |
||
| 3193 | 3192 | } |
| 3194 | 3193 | |
| 3195 | 3194 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
| 3196 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3195 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 3197 | 3196 | $session = charger_fonction('session', 'inc'); |
| 3198 | 3197 | if ($session()) { |
| 3199 | 3198 | return $GLOBALS['visiteur_session']['statut']; |
@@ -3273,7 +3272,7 @@ discard block |
||
| 3273 | 3272 | 'definir_session', |
| 3274 | 3273 | $GLOBALS['visiteur_session'] |
| 3275 | 3274 | ? serialize($GLOBALS['visiteur_session']) |
| 3276 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3275 | + . '_'.@$_COOKIE['spip_session'] |
|
| 3277 | 3276 | : '' |
| 3278 | 3277 | ); |
| 3279 | 3278 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -3321,8 +3320,8 @@ discard block |
||
| 3321 | 3320 | foreach ($cookies_masques as $k) { |
| 3322 | 3321 | if (!empty($_COOKIE[$k])) { |
| 3323 | 3322 | $cookies_backup[$k] = $_COOKIE[$k]; |
| 3324 | - $_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []); |
|
| 3325 | - $_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []); |
|
| 3323 | + $_SERVER['HTTP_COOKIE'] = str_replace("$k=".$_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []); |
|
| 3324 | + $_ENV['HTTP_COOKIE'] = str_replace("$k=".$_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []); |
|
| 3326 | 3325 | $_COOKIE[$k] = $mask; |
| 3327 | 3326 | } |
| 3328 | 3327 | } |
@@ -3440,11 +3439,11 @@ discard block |
||
| 3440 | 3439 | $GLOBALS['_INC_PUBLIC']++; |
| 3441 | 3440 | |
| 3442 | 3441 | // fix #4235 |
| 3443 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3442 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3444 | 3443 | |
| 3445 | 3444 | |
| 3446 | 3445 | foreach (is_array($fond) ? $fond : [$fond] as $f) { |
| 3447 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3446 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3448 | 3447 | |
| 3449 | 3448 | $page = evaluer_fond($f, $contexte, $connect); |
| 3450 | 3449 | if ($page === '') { |
@@ -3529,7 +3528,7 @@ discard block |
||
| 3529 | 3528 | * @return array|string |
| 3530 | 3529 | */ |
| 3531 | 3530 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3532 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3531 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 3533 | 3532 | if (!$pathinfo) { |
| 3534 | 3533 | return $f; |
| 3535 | 3534 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -47,71 +47,71 @@ discard block |
||
| 47 | 47 | * Nom de la fonction, ou false. |
| 48 | 48 | */ |
| 49 | 49 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 50 | - static $echecs = []; |
|
| 51 | - |
|
| 52 | - if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 53 | - $dossier .= '/'; |
|
| 54 | - } |
|
| 55 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 56 | - |
|
| 57 | - if (function_exists($f)) { |
|
| 58 | - return $f; |
|
| 59 | - } |
|
| 60 | - if (function_exists($g = $f . '_dist')) { |
|
| 61 | - return $g; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - if (isset($echecs[$f])) { |
|
| 65 | - return $echecs[$f]; |
|
| 66 | - } |
|
| 67 | - // Sinon charger le fichier de declaration si plausible |
|
| 68 | - |
|
| 69 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 70 | - if ($continue) { |
|
| 71 | - return false; |
|
| 72 | - } //appel interne, on passe |
|
| 73 | - include_spip('inc/minipres'); |
|
| 74 | - echo minipres(); |
|
| 75 | - exit; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // passer en minuscules (cf les balises de formulaires) |
|
| 79 | - // et inclure le fichier |
|
| 80 | - if ( |
|
| 81 | - !$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( |
|
| 105 | - _T('forum_titre_erreur'), |
|
| 106 | - $inc ? |
|
| 107 | - _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 108 | - . '<br />' |
|
| 109 | - . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 110 | - : |
|
| 111 | - _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 112 | - ['all_inline' => true,'status' => 404] |
|
| 113 | - ); |
|
| 114 | - exit; |
|
| 50 | + static $echecs = []; |
|
| 51 | + |
|
| 52 | + if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 53 | + $dossier .= '/'; |
|
| 54 | + } |
|
| 55 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 56 | + |
|
| 57 | + if (function_exists($f)) { |
|
| 58 | + return $f; |
|
| 59 | + } |
|
| 60 | + if (function_exists($g = $f . '_dist')) { |
|
| 61 | + return $g; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + if (isset($echecs[$f])) { |
|
| 65 | + return $echecs[$f]; |
|
| 66 | + } |
|
| 67 | + // Sinon charger le fichier de declaration si plausible |
|
| 68 | + |
|
| 69 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 70 | + if ($continue) { |
|
| 71 | + return false; |
|
| 72 | + } //appel interne, on passe |
|
| 73 | + include_spip('inc/minipres'); |
|
| 74 | + echo minipres(); |
|
| 75 | + exit; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // passer en minuscules (cf les balises de formulaires) |
|
| 79 | + // et inclure le fichier |
|
| 80 | + if ( |
|
| 81 | + !$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( |
|
| 105 | + _T('forum_titre_erreur'), |
|
| 106 | + $inc ? |
|
| 107 | + _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 108 | + . '<br />' |
|
| 109 | + . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 110 | + : |
|
| 111 | + _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 112 | + ['all_inline' => true,'status' => 404] |
|
| 113 | + ); |
|
| 114 | + exit; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -121,17 +121,17 @@ discard block |
||
| 121 | 121 | * @return bool |
| 122 | 122 | */ |
| 123 | 123 | function include_once_check($file) { |
| 124 | - if (file_exists($file)) { |
|
| 125 | - include_once $file; |
|
| 124 | + if (file_exists($file)) { |
|
| 125 | + include_once $file; |
|
| 126 | 126 | |
| 127 | - return true; |
|
| 128 | - } |
|
| 129 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 130 | - $crash = ($crash ?: []); |
|
| 131 | - $crash[$file] = true; |
|
| 132 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 127 | + return true; |
|
| 128 | + } |
|
| 129 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 130 | + $crash = ($crash ?: []); |
|
| 131 | + $crash[$file] = true; |
|
| 132 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 133 | 133 | |
| 134 | - return false; |
|
| 134 | + return false; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * - string : chemin du fichier trouvé |
| 156 | 156 | **/ |
| 157 | 157 | function include_spip($f, $include = true) { |
| 158 | - return find_in_path($f . '.php', '', $include); |
|
| 158 | + return find_in_path($f . '.php', '', $include); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * - string : chemin du fichier trouvé |
| 176 | 176 | **/ |
| 177 | 177 | function require_spip($f) { |
| 178 | - return find_in_path($f . '.php', '', 'required'); |
|
| 178 | + return find_in_path($f . '.php', '', 'required'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | |
@@ -184,27 +184,27 @@ discard block |
||
| 184 | 184 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 185 | 185 | */ |
| 186 | 186 | function include_fichiers_fonctions() { |
| 187 | - static $done = false; |
|
| 188 | - if (!$done) { |
|
| 189 | - include_spip('inc/lang'); |
|
| 190 | - |
|
| 191 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 192 | - // donc il faut l'inclure "en globals" |
|
| 193 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 194 | - global $dossier_squelettes; |
|
| 195 | - include_once(_ROOT_CWD . $f); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 199 | - // chargement optimise precompile |
|
| 200 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 201 | - } |
|
| 202 | - if (test_espace_prive()) { |
|
| 203 | - include_spip('inc/filtres_ecrire'); |
|
| 204 | - } |
|
| 205 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 206 | - $done = true; |
|
| 207 | - } |
|
| 187 | + static $done = false; |
|
| 188 | + if (!$done) { |
|
| 189 | + include_spip('inc/lang'); |
|
| 190 | + |
|
| 191 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 192 | + // donc il faut l'inclure "en globals" |
|
| 193 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 194 | + global $dossier_squelettes; |
|
| 195 | + include_once(_ROOT_CWD . $f); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 199 | + // chargement optimise precompile |
|
| 200 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 201 | + } |
|
| 202 | + if (test_espace_prive()) { |
|
| 203 | + include_spip('inc/filtres_ecrire'); |
|
| 204 | + } |
|
| 205 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 206 | + $done = true; |
|
| 207 | + } |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -230,23 +230,23 @@ discard block |
||
| 230 | 230 | * Les paramètres du pipeline modifiés |
| 231 | 231 | **/ |
| 232 | 232 | function minipipe($fonc, &$val) { |
| 233 | - // fonction |
|
| 234 | - if (function_exists($fonc)) { |
|
| 235 | - $val = $fonc($val); |
|
| 236 | - } // Class::Methode |
|
| 237 | - else { |
|
| 238 | - if ( |
|
| 239 | - preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 240 | - and $methode = [$regs[1], $regs[2]] |
|
| 241 | - and is_callable($methode) |
|
| 242 | - ) { |
|
| 243 | - $val = $methode($val); |
|
| 244 | - } else { |
|
| 245 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return $val; |
|
| 233 | + // fonction |
|
| 234 | + if (function_exists($fonc)) { |
|
| 235 | + $val = $fonc($val); |
|
| 236 | + } // Class::Methode |
|
| 237 | + else { |
|
| 238 | + if ( |
|
| 239 | + preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 240 | + and $methode = [$regs[1], $regs[2]] |
|
| 241 | + and is_callable($methode) |
|
| 242 | + ) { |
|
| 243 | + $val = $methode($val); |
|
| 244 | + } else { |
|
| 245 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return $val; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -277,46 +277,46 @@ discard block |
||
| 277 | 277 | * Résultat |
| 278 | 278 | */ |
| 279 | 279 | function pipeline($action, $val = null) { |
| 280 | - static $charger; |
|
| 281 | - |
|
| 282 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 283 | - if (!$charger) { |
|
| 284 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 285 | - include_spip('inc/plugin'); |
|
| 286 | - // generer les fichiers php precompiles |
|
| 287 | - // de chargement des plugins et des pipelines |
|
| 288 | - actualise_plugins_actifs(); |
|
| 289 | - if (!($ok = @is_readable($charger))) { |
|
| 290 | - spip_log("fichier $charger pas cree"); |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - if ($ok) { |
|
| 295 | - include_once $charger; |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - // appliquer notre fonction si elle existe |
|
| 300 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 301 | - if (function_exists($fonc)) { |
|
| 302 | - $val = $fonc($val); |
|
| 303 | - } // plantage ? |
|
| 304 | - else { |
|
| 305 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - // si le flux est une table avec 2 cle args&data |
|
| 309 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 310 | - // array_key_exists pour php 4.1.0 |
|
| 311 | - if ( |
|
| 312 | - is_array($val) |
|
| 313 | - and count($val) == 2 |
|
| 314 | - and (array_key_exists('data', $val)) |
|
| 315 | - ) { |
|
| 316 | - $val = $val['data']; |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - return $val; |
|
| 280 | + static $charger; |
|
| 281 | + |
|
| 282 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 283 | + if (!$charger) { |
|
| 284 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 285 | + include_spip('inc/plugin'); |
|
| 286 | + // generer les fichiers php precompiles |
|
| 287 | + // de chargement des plugins et des pipelines |
|
| 288 | + actualise_plugins_actifs(); |
|
| 289 | + if (!($ok = @is_readable($charger))) { |
|
| 290 | + spip_log("fichier $charger pas cree"); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + if ($ok) { |
|
| 295 | + include_once $charger; |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + // appliquer notre fonction si elle existe |
|
| 300 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 301 | + if (function_exists($fonc)) { |
|
| 302 | + $val = $fonc($val); |
|
| 303 | + } // plantage ? |
|
| 304 | + else { |
|
| 305 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + // si le flux est une table avec 2 cle args&data |
|
| 309 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 310 | + // array_key_exists pour php 4.1.0 |
|
| 311 | + if ( |
|
| 312 | + is_array($val) |
|
| 313 | + and count($val) == 2 |
|
| 314 | + and (array_key_exists('data', $val)) |
|
| 315 | + ) { |
|
| 316 | + $val = $val['data']; |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + return $val; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -360,38 +360,38 @@ discard block |
||
| 360 | 360 | * paramètre est planté pour cause de compatibilité ascendante. |
| 361 | 361 | */ |
| 362 | 362 | function spip_log($message = null, $name = null) { |
| 363 | - static $pre = []; |
|
| 364 | - static $log; |
|
| 365 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 366 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 367 | - $logname = null; |
|
| 368 | - } |
|
| 369 | - if (!isset($regs[2])) { |
|
| 370 | - $niveau = _LOG_INFO; |
|
| 371 | - } |
|
| 372 | - else { |
|
| 373 | - $niveau = intval($regs[2]); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 377 | - if (!$pre) { |
|
| 378 | - $pre = [ |
|
| 379 | - _LOG_HS => 'HS:', |
|
| 380 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 381 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 382 | - _LOG_ERREUR => 'ERREUR:', |
|
| 383 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 384 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 385 | - _LOG_INFO => 'info:', |
|
| 386 | - _LOG_DEBUG => 'debug:' |
|
| 387 | - ]; |
|
| 388 | - $log = charger_fonction('log', 'inc'); |
|
| 389 | - } |
|
| 390 | - if (!is_string($message)) { |
|
| 391 | - $message = print_r($message, true); |
|
| 392 | - } |
|
| 393 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 394 | - } |
|
| 363 | + static $pre = []; |
|
| 364 | + static $log; |
|
| 365 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 366 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 367 | + $logname = null; |
|
| 368 | + } |
|
| 369 | + if (!isset($regs[2])) { |
|
| 370 | + $niveau = _LOG_INFO; |
|
| 371 | + } |
|
| 372 | + else { |
|
| 373 | + $niveau = intval($regs[2]); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 377 | + if (!$pre) { |
|
| 378 | + $pre = [ |
|
| 379 | + _LOG_HS => 'HS:', |
|
| 380 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 381 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 382 | + _LOG_ERREUR => 'ERREUR:', |
|
| 383 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 384 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 385 | + _LOG_INFO => 'info:', |
|
| 386 | + _LOG_DEBUG => 'debug:' |
|
| 387 | + ]; |
|
| 388 | + $log = charger_fonction('log', 'inc'); |
|
| 389 | + } |
|
| 390 | + if (!is_string($message)) { |
|
| 391 | + $message = print_r($message, true); |
|
| 392 | + } |
|
| 393 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 394 | + } |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | /** |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | * @param array $opt Tableau d'options |
| 403 | 403 | **/ |
| 404 | 404 | function journal($phrase, $opt = []) { |
| 405 | - $journal = charger_fonction('journal', 'inc'); |
|
| 406 | - $journal($phrase, $opt); |
|
| 405 | + $journal = charger_fonction('journal', 'inc'); |
|
| 406 | + $journal($phrase, $opt); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | |
@@ -422,37 +422,37 @@ discard block |
||
| 422 | 422 | **/ |
| 423 | 423 | function _request($var, $c = false) { |
| 424 | 424 | |
| 425 | - if (is_array($c)) { |
|
| 426 | - return $c[$var] ?? null; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - if (isset($_GET[$var])) { |
|
| 430 | - $a = $_GET[$var]; |
|
| 431 | - } elseif (isset($_POST[$var])) { |
|
| 432 | - $a = $_POST[$var]; |
|
| 433 | - } else { |
|
| 434 | - return null; |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - // Si on est en ajax et en POST tout a ete encode |
|
| 438 | - // via encodeURIComponent, il faut donc repasser |
|
| 439 | - // dans le charset local... |
|
| 440 | - if ( |
|
| 441 | - defined('_AJAX') |
|
| 442 | - and _AJAX |
|
| 443 | - and isset($GLOBALS['meta']['charset']) |
|
| 444 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 445 | - and is_string($a) |
|
| 446 | - // check rapide mais pas fiable |
|
| 447 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 448 | - // check fiable |
|
| 449 | - and include_spip('inc/charsets') |
|
| 450 | - and is_utf8($a) |
|
| 451 | - ) { |
|
| 452 | - return importer_charset($a, 'utf-8'); |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - return $a; |
|
| 425 | + if (is_array($c)) { |
|
| 426 | + return $c[$var] ?? null; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + if (isset($_GET[$var])) { |
|
| 430 | + $a = $_GET[$var]; |
|
| 431 | + } elseif (isset($_POST[$var])) { |
|
| 432 | + $a = $_POST[$var]; |
|
| 433 | + } else { |
|
| 434 | + return null; |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + // Si on est en ajax et en POST tout a ete encode |
|
| 438 | + // via encodeURIComponent, il faut donc repasser |
|
| 439 | + // dans le charset local... |
|
| 440 | + if ( |
|
| 441 | + defined('_AJAX') |
|
| 442 | + and _AJAX |
|
| 443 | + and isset($GLOBALS['meta']['charset']) |
|
| 444 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 445 | + and is_string($a) |
|
| 446 | + // check rapide mais pas fiable |
|
| 447 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 448 | + // check fiable |
|
| 449 | + and include_spip('inc/charsets') |
|
| 450 | + and is_utf8($a) |
|
| 451 | + ) { |
|
| 452 | + return importer_charset($a, 'utf-8'); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + return $a; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | |
@@ -470,22 +470,22 @@ discard block |
||
| 470 | 470 | * - false sinon |
| 471 | 471 | **/ |
| 472 | 472 | function set_request($var, $val = null, $c = false) { |
| 473 | - if (is_array($c)) { |
|
| 474 | - unset($c[$var]); |
|
| 475 | - if ($val !== null) { |
|
| 476 | - $c[$var] = $val; |
|
| 477 | - } |
|
| 473 | + if (is_array($c)) { |
|
| 474 | + unset($c[$var]); |
|
| 475 | + if ($val !== null) { |
|
| 476 | + $c[$var] = $val; |
|
| 477 | + } |
|
| 478 | 478 | |
| 479 | - return $c; |
|
| 480 | - } |
|
| 479 | + return $c; |
|
| 480 | + } |
|
| 481 | 481 | |
| 482 | - unset($_GET[$var]); |
|
| 483 | - unset($_POST[$var]); |
|
| 484 | - if ($val !== null) { |
|
| 485 | - $_GET[$var] = $val; |
|
| 486 | - } |
|
| 482 | + unset($_GET[$var]); |
|
| 483 | + unset($_POST[$var]); |
|
| 484 | + if ($val !== null) { |
|
| 485 | + $_GET[$var] = $val; |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | - return false; # n'affecte pas $c |
|
| 488 | + return false; # n'affecte pas $c |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -505,25 +505,25 @@ discard block |
||
| 505 | 505 | * @return array|mixed|string |
| 506 | 506 | */ |
| 507 | 507 | function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') { |
| 508 | - if (is_array($value)) { |
|
| 509 | - if ($key == '*') { |
|
| 510 | - $key = array_keys($value); |
|
| 511 | - } |
|
| 512 | - if (!is_array($key)) { |
|
| 513 | - $key = [$key]; |
|
| 514 | - } |
|
| 515 | - foreach ($key as $k) { |
|
| 516 | - if (!empty($value[$k])) { |
|
| 517 | - $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - return $value; |
|
| 521 | - } |
|
| 522 | - // si la valeur vient des GET ou POST on la sanitize |
|
| 523 | - if (!empty($value) and $value == _request($key)) { |
|
| 524 | - $value = $sanitize_function($value); |
|
| 525 | - } |
|
| 526 | - return $value; |
|
| 508 | + if (is_array($value)) { |
|
| 509 | + if ($key == '*') { |
|
| 510 | + $key = array_keys($value); |
|
| 511 | + } |
|
| 512 | + if (!is_array($key)) { |
|
| 513 | + $key = [$key]; |
|
| 514 | + } |
|
| 515 | + foreach ($key as $k) { |
|
| 516 | + if (!empty($value[$k])) { |
|
| 517 | + $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + return $value; |
|
| 521 | + } |
|
| 522 | + // si la valeur vient des GET ou POST on la sanitize |
|
| 523 | + if (!empty($value) and $value == _request($key)) { |
|
| 524 | + $value = $sanitize_function($value); |
|
| 525 | + } |
|
| 526 | + return $value; |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | /** |
@@ -531,23 +531,22 @@ discard block |
||
| 531 | 531 | * |
| 532 | 532 | * On est sur le web, on exclut certains protocoles, |
| 533 | 533 | * notamment 'file://', 'php://' et d'autres… |
| 534 | - |
|
| 535 | 534 | * @param string $url |
| 536 | 535 | * @return bool |
| 537 | 536 | */ |
| 538 | 537 | function tester_url_absolue($url) { |
| 539 | - $url = trim($url ?? ''); |
|
| 540 | - if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 541 | - if ( |
|
| 542 | - isset($m[1]) |
|
| 543 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 544 | - and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 545 | - ) { |
|
| 546 | - return false; |
|
| 547 | - } |
|
| 548 | - return true; |
|
| 549 | - } |
|
| 550 | - return false; |
|
| 538 | + $url = trim($url ?? ''); |
|
| 539 | + if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 540 | + if ( |
|
| 541 | + isset($m[1]) |
|
| 542 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 543 | + and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 544 | + ) { |
|
| 545 | + return false; |
|
| 546 | + } |
|
| 547 | + return true; |
|
| 548 | + } |
|
| 549 | + return false; |
|
| 551 | 550 | } |
| 552 | 551 | |
| 553 | 552 | /** |
@@ -569,100 +568,100 @@ discard block |
||
| 569 | 568 | * @return string URL |
| 570 | 569 | */ |
| 571 | 570 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 572 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 573 | - if (strpos($c, '|') !== false and is_null($v)) { |
|
| 574 | - return null; |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - // lever l'#ancre |
|
| 578 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 579 | - $url = $r[1]; |
|
| 580 | - $ancre = $r[2]; |
|
| 581 | - } else { |
|
| 582 | - $ancre = ''; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - // eclater |
|
| 586 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 587 | - |
|
| 588 | - // recuperer la base |
|
| 589 | - $a = array_shift($url); |
|
| 590 | - if (!$a) { |
|
| 591 | - $a = './'; |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - // preparer la regexp de maniere securisee |
|
| 595 | - $regexp = explode('|', $c); |
|
| 596 | - foreach ($regexp as $r => $e) { |
|
| 597 | - $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e)); |
|
| 598 | - } |
|
| 599 | - $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,'; |
|
| 600 | - $ajouts = array_flip(explode('|', $c)); |
|
| 601 | - $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 602 | - $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 603 | - $v_read = null; |
|
| 604 | - // lire les variables et agir |
|
| 605 | - foreach ($url as $n => $val) { |
|
| 606 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 607 | - $r = array_pad($r, 3, null); |
|
| 608 | - if ($v === null) { |
|
| 609 | - // c'est un tableau, on memorise les valeurs |
|
| 610 | - if (substr($r[1], -2) == '[]') { |
|
| 611 | - if (!$v_read) { |
|
| 612 | - $v_read = []; |
|
| 613 | - } |
|
| 614 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 615 | - } // c'est un scalaire, on retourne direct |
|
| 616 | - else { |
|
| 617 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 618 | - } |
|
| 619 | - } // suppression |
|
| 620 | - elseif (!$testv) { |
|
| 621 | - unset($url[$n]); |
|
| 622 | - } |
|
| 623 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 624 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 625 | - elseif (substr($r[1], -2) != '[]') { |
|
| 626 | - $url[$n] = $r[1] . '=' . $u; |
|
| 627 | - unset($ajouts[$r[1]]); |
|
| 628 | - } |
|
| 629 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 630 | - // départ, on remplira à l'étape suivante |
|
| 631 | - else { |
|
| 632 | - unset($url[$n]); |
|
| 633 | - } |
|
| 634 | - } |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - // traiter les parametres pas encore trouves |
|
| 638 | - if ( |
|
| 639 | - $v === null |
|
| 640 | - and $args = func_get_args() |
|
| 641 | - and count($args) == 2 |
|
| 642 | - ) { |
|
| 643 | - return $v_read; // rien trouve ou un tableau |
|
| 644 | - } elseif ($testv) { |
|
| 645 | - foreach ($ajouts as $k => $n) { |
|
| 646 | - if (!is_array($v)) { |
|
| 647 | - $url[] = $k . '=' . $u; |
|
| 648 | - } else { |
|
| 649 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 650 | - foreach ($v as $w) { |
|
| 651 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 652 | - } |
|
| 653 | - } |
|
| 654 | - } |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - // eliminer les vides |
|
| 658 | - $url = array_filter($url); |
|
| 659 | - |
|
| 660 | - // recomposer l'adresse |
|
| 661 | - if ($url) { |
|
| 662 | - $a .= '?' . join($sep, $url); |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - return $a . $ancre; |
|
| 571 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 572 | + if (strpos($c, '|') !== false and is_null($v)) { |
|
| 573 | + return null; |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + // lever l'#ancre |
|
| 577 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 578 | + $url = $r[1]; |
|
| 579 | + $ancre = $r[2]; |
|
| 580 | + } else { |
|
| 581 | + $ancre = ''; |
|
| 582 | + } |
|
| 583 | + |
|
| 584 | + // eclater |
|
| 585 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 586 | + |
|
| 587 | + // recuperer la base |
|
| 588 | + $a = array_shift($url); |
|
| 589 | + if (!$a) { |
|
| 590 | + $a = './'; |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + // preparer la regexp de maniere securisee |
|
| 594 | + $regexp = explode('|', $c); |
|
| 595 | + foreach ($regexp as $r => $e) { |
|
| 596 | + $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e)); |
|
| 597 | + } |
|
| 598 | + $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,'; |
|
| 599 | + $ajouts = array_flip(explode('|', $c)); |
|
| 600 | + $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 601 | + $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 602 | + $v_read = null; |
|
| 603 | + // lire les variables et agir |
|
| 604 | + foreach ($url as $n => $val) { |
|
| 605 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 606 | + $r = array_pad($r, 3, null); |
|
| 607 | + if ($v === null) { |
|
| 608 | + // c'est un tableau, on memorise les valeurs |
|
| 609 | + if (substr($r[1], -2) == '[]') { |
|
| 610 | + if (!$v_read) { |
|
| 611 | + $v_read = []; |
|
| 612 | + } |
|
| 613 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 614 | + } // c'est un scalaire, on retourne direct |
|
| 615 | + else { |
|
| 616 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 617 | + } |
|
| 618 | + } // suppression |
|
| 619 | + elseif (!$testv) { |
|
| 620 | + unset($url[$n]); |
|
| 621 | + } |
|
| 622 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 623 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 624 | + elseif (substr($r[1], -2) != '[]') { |
|
| 625 | + $url[$n] = $r[1] . '=' . $u; |
|
| 626 | + unset($ajouts[$r[1]]); |
|
| 627 | + } |
|
| 628 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 629 | + // départ, on remplira à l'étape suivante |
|
| 630 | + else { |
|
| 631 | + unset($url[$n]); |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + // traiter les parametres pas encore trouves |
|
| 637 | + if ( |
|
| 638 | + $v === null |
|
| 639 | + and $args = func_get_args() |
|
| 640 | + and count($args) == 2 |
|
| 641 | + ) { |
|
| 642 | + return $v_read; // rien trouve ou un tableau |
|
| 643 | + } elseif ($testv) { |
|
| 644 | + foreach ($ajouts as $k => $n) { |
|
| 645 | + if (!is_array($v)) { |
|
| 646 | + $url[] = $k . '=' . $u; |
|
| 647 | + } else { |
|
| 648 | + $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 649 | + foreach ($v as $w) { |
|
| 650 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + } |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + // eliminer les vides |
|
| 657 | + $url = array_filter($url); |
|
| 658 | + |
|
| 659 | + // recomposer l'adresse |
|
| 660 | + if ($url) { |
|
| 661 | + $a .= '?' . join($sep, $url); |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + return $a . $ancre; |
|
| 666 | 665 | } |
| 667 | 666 | |
| 668 | 667 | /** |
@@ -677,22 +676,22 @@ discard block |
||
| 677 | 676 | * @uses translitteration() |
| 678 | 677 | */ |
| 679 | 678 | function ancre_url(string $url, ?string $ancre = ''): string { |
| 680 | - $ancre ??= ''; |
|
| 681 | - // lever l'#ancre |
|
| 682 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 683 | - $url = $r[1]; |
|
| 684 | - } |
|
| 685 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 686 | - if (!function_exists('translitteration')) { |
|
| 687 | - include_spip('inc/charsets'); |
|
| 688 | - } |
|
| 689 | - $ancre = preg_replace( |
|
| 690 | - ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 691 | - ['', '-'], |
|
| 692 | - translitteration($ancre) |
|
| 693 | - ); |
|
| 694 | - } |
|
| 695 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 679 | + $ancre ??= ''; |
|
| 680 | + // lever l'#ancre |
|
| 681 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 682 | + $url = $r[1]; |
|
| 683 | + } |
|
| 684 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 685 | + if (!function_exists('translitteration')) { |
|
| 686 | + include_spip('inc/charsets'); |
|
| 687 | + } |
|
| 688 | + $ancre = preg_replace( |
|
| 689 | + ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 690 | + ['', '-'], |
|
| 691 | + translitteration($ancre) |
|
| 692 | + ); |
|
| 693 | + } |
|
| 694 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 696 | 695 | } |
| 697 | 696 | |
| 698 | 697 | /** |
@@ -702,16 +701,16 @@ discard block |
||
| 702 | 701 | * @return string |
| 703 | 702 | */ |
| 704 | 703 | function nettoyer_uri($reset = null) { |
| 705 | - static $done = false; |
|
| 706 | - static $propre = ''; |
|
| 707 | - if (!is_null($reset)) { |
|
| 708 | - return $propre = $reset; |
|
| 709 | - } |
|
| 710 | - if ($done) { |
|
| 711 | - return $propre; |
|
| 712 | - } |
|
| 713 | - $done = true; |
|
| 714 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 704 | + static $done = false; |
|
| 705 | + static $propre = ''; |
|
| 706 | + if (!is_null($reset)) { |
|
| 707 | + return $propre = $reset; |
|
| 708 | + } |
|
| 709 | + if ($done) { |
|
| 710 | + return $propre; |
|
| 711 | + } |
|
| 712 | + $done = true; |
|
| 713 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 715 | 714 | } |
| 716 | 715 | |
| 717 | 716 | /** |
@@ -723,16 +722,16 @@ discard block |
||
| 723 | 722 | * @return string |
| 724 | 723 | */ |
| 725 | 724 | function nettoyer_uri_var($request_uri) { |
| 726 | - $uri1 = $request_uri; |
|
| 727 | - do { |
|
| 728 | - $uri = $uri1; |
|
| 729 | - $uri1 = preg_replace( |
|
| 730 | - ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 731 | - '\1', |
|
| 732 | - $uri |
|
| 733 | - ); |
|
| 734 | - } while ($uri <> $uri1); |
|
| 735 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 725 | + $uri1 = $request_uri; |
|
| 726 | + do { |
|
| 727 | + $uri = $uri1; |
|
| 728 | + $uri1 = preg_replace( |
|
| 729 | + ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 730 | + '\1', |
|
| 731 | + $uri |
|
| 732 | + ); |
|
| 733 | + } while ($uri <> $uri1); |
|
| 734 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 736 | 735 | } |
| 737 | 736 | |
| 738 | 737 | |
@@ -746,48 +745,48 @@ discard block |
||
| 746 | 745 | * URL vers soi-même |
| 747 | 746 | **/ |
| 748 | 747 | function self($amp = '&', $root = false) { |
| 749 | - $url = nettoyer_uri(); |
|
| 750 | - if ( |
|
| 751 | - !$root |
|
| 752 | - and ( |
|
| 753 | - // si pas de profondeur on peut tronquer |
|
| 754 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 755 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 756 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 757 | - ) { |
|
| 758 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 759 | - } |
|
| 760 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 761 | - foreach ($_POST as $v => $c) { |
|
| 762 | - if (substr($v, 0, 3) == 'id_') { |
|
| 763 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 764 | - } |
|
| 765 | - } |
|
| 766 | - |
|
| 767 | - // supprimer les variables sans interet |
|
| 768 | - if (test_espace_prive()) { |
|
| 769 | - $url = preg_replace(',([?&])(' |
|
| 770 | - . 'lang|show_docs|' |
|
| 771 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 772 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 773 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 774 | - } |
|
| 775 | - |
|
| 776 | - // eviter les hacks |
|
| 777 | - include_spip('inc/filtres_mini'); |
|
| 778 | - $url = spip_htmlspecialchars($url); |
|
| 779 | - |
|
| 780 | - $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 781 | - |
|
| 782 | - // & ? |
|
| 783 | - if ($amp != '&') { |
|
| 784 | - $url = str_replace('&', $amp, $url); |
|
| 785 | - } |
|
| 786 | - |
|
| 787 | - // Si ca demarre par ? ou vide, donner './' |
|
| 788 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 789 | - |
|
| 790 | - return $url; |
|
| 748 | + $url = nettoyer_uri(); |
|
| 749 | + if ( |
|
| 750 | + !$root |
|
| 751 | + and ( |
|
| 752 | + // si pas de profondeur on peut tronquer |
|
| 753 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 754 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 755 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 756 | + ) { |
|
| 757 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 758 | + } |
|
| 759 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 760 | + foreach ($_POST as $v => $c) { |
|
| 761 | + if (substr($v, 0, 3) == 'id_') { |
|
| 762 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 763 | + } |
|
| 764 | + } |
|
| 765 | + |
|
| 766 | + // supprimer les variables sans interet |
|
| 767 | + if (test_espace_prive()) { |
|
| 768 | + $url = preg_replace(',([?&])(' |
|
| 769 | + . 'lang|show_docs|' |
|
| 770 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 771 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 772 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + // eviter les hacks |
|
| 776 | + include_spip('inc/filtres_mini'); |
|
| 777 | + $url = spip_htmlspecialchars($url); |
|
| 778 | + |
|
| 779 | + $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 780 | + |
|
| 781 | + // & ? |
|
| 782 | + if ($amp != '&') { |
|
| 783 | + $url = str_replace('&', $amp, $url); |
|
| 784 | + } |
|
| 785 | + |
|
| 786 | + // Si ca demarre par ? ou vide, donner './' |
|
| 787 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 788 | + |
|
| 789 | + return $url; |
|
| 791 | 790 | } |
| 792 | 791 | |
| 793 | 792 | |
@@ -798,7 +797,7 @@ discard block |
||
| 798 | 797 | * true si c'est le cas, false sinon. |
| 799 | 798 | */ |
| 800 | 799 | function test_espace_prive() { |
| 801 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 800 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 802 | 801 | } |
| 803 | 802 | |
| 804 | 803 | /** |
@@ -808,7 +807,7 @@ discard block |
||
| 808 | 807 | * @return bool |
| 809 | 808 | */ |
| 810 | 809 | function test_plugin_actif($plugin) { |
| 811 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 810 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 812 | 811 | } |
| 813 | 812 | |
| 814 | 813 | /** |
@@ -839,52 +838,52 @@ discard block |
||
| 839 | 838 | * texte |
| 840 | 839 | */ |
| 841 | 840 | function _T($texte, $args = [], $options = []) { |
| 842 | - static $traduire = false; |
|
| 843 | - $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 844 | - if ($options) { |
|
| 845 | - // support de l'ancien argument $class |
|
| 846 | - if (is_string($options)) { |
|
| 847 | - $options = ['class' => $options]; |
|
| 848 | - } |
|
| 849 | - $o = array_merge($o, $options); |
|
| 850 | - } |
|
| 851 | - |
|
| 852 | - if (!$traduire) { |
|
| 853 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 854 | - include_spip('inc/lang'); |
|
| 855 | - } |
|
| 856 | - |
|
| 857 | - // On peut passer explicitement la langue dans le tableau |
|
| 858 | - // On utilise le même nom de variable que la globale |
|
| 859 | - if (isset($args['spip_lang'])) { |
|
| 860 | - $lang = $args['spip_lang']; |
|
| 861 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 862 | - unset($args['spip_lang']); |
|
| 863 | - } // Sinon on prend la langue du contexte |
|
| 864 | - else { |
|
| 865 | - $lang = $GLOBALS['spip_lang']; |
|
| 866 | - } |
|
| 867 | - $text = $traduire($texte, $lang); |
|
| 868 | - |
|
| 869 | - if ($text === null || !strlen($text)) { |
|
| 870 | - if (!$o['force']) { |
|
| 871 | - return ''; |
|
| 872 | - } |
|
| 873 | - |
|
| 874 | - $text = $texte; |
|
| 875 | - |
|
| 876 | - // pour les chaines non traduites, assurer un service minimum |
|
| 877 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 878 | - $n = strpos($text, ':'); |
|
| 879 | - if ($n !== false) { |
|
| 880 | - $text = substr($text, $n + 1); |
|
| 881 | - } |
|
| 882 | - $text = str_replace('_', ' ', $text); |
|
| 883 | - } |
|
| 884 | - $o['class'] = null; |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - return _L($text, $args, $o); |
|
| 841 | + static $traduire = false; |
|
| 842 | + $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 843 | + if ($options) { |
|
| 844 | + // support de l'ancien argument $class |
|
| 845 | + if (is_string($options)) { |
|
| 846 | + $options = ['class' => $options]; |
|
| 847 | + } |
|
| 848 | + $o = array_merge($o, $options); |
|
| 849 | + } |
|
| 850 | + |
|
| 851 | + if (!$traduire) { |
|
| 852 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 853 | + include_spip('inc/lang'); |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + // On peut passer explicitement la langue dans le tableau |
|
| 857 | + // On utilise le même nom de variable que la globale |
|
| 858 | + if (isset($args['spip_lang'])) { |
|
| 859 | + $lang = $args['spip_lang']; |
|
| 860 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 861 | + unset($args['spip_lang']); |
|
| 862 | + } // Sinon on prend la langue du contexte |
|
| 863 | + else { |
|
| 864 | + $lang = $GLOBALS['spip_lang']; |
|
| 865 | + } |
|
| 866 | + $text = $traduire($texte, $lang); |
|
| 867 | + |
|
| 868 | + if ($text === null || !strlen($text)) { |
|
| 869 | + if (!$o['force']) { |
|
| 870 | + return ''; |
|
| 871 | + } |
|
| 872 | + |
|
| 873 | + $text = $texte; |
|
| 874 | + |
|
| 875 | + // pour les chaines non traduites, assurer un service minimum |
|
| 876 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 877 | + $n = strpos($text, ':'); |
|
| 878 | + if ($n !== false) { |
|
| 879 | + $text = substr($text, $n + 1); |
|
| 880 | + } |
|
| 881 | + $text = str_replace('_', ' ', $text); |
|
| 882 | + } |
|
| 883 | + $o['class'] = null; |
|
| 884 | + } |
|
| 885 | + |
|
| 886 | + return _L($text, $args, $o); |
|
| 888 | 887 | } |
| 889 | 888 | |
| 890 | 889 | |
@@ -911,53 +910,53 @@ discard block |
||
| 911 | 910 | * texte |
| 912 | 911 | */ |
| 913 | 912 | function _L($text, $args = [], $options = []) { |
| 914 | - $f = $text; |
|
| 915 | - $defaut_options = [ |
|
| 916 | - 'class' => null, |
|
| 917 | - 'sanitize' => true, |
|
| 918 | - ]; |
|
| 919 | - // support de l'ancien argument $class |
|
| 920 | - if ($options and is_string($options)) { |
|
| 921 | - $options = ['class' => $options]; |
|
| 922 | - } |
|
| 923 | - if (is_array($options)) { |
|
| 924 | - $options += $defaut_options; |
|
| 925 | - } else { |
|
| 926 | - $options = $defaut_options; |
|
| 927 | - } |
|
| 928 | - |
|
| 929 | - if (is_array($args) and count($args)) { |
|
| 930 | - if (!function_exists('interdire_scripts')) { |
|
| 931 | - include_spip('inc/texte'); |
|
| 932 | - } |
|
| 933 | - if (!function_exists('echapper_html_suspect')) { |
|
| 934 | - include_spip('inc/texte_mini'); |
|
| 935 | - } |
|
| 936 | - foreach ($args as $name => $value) { |
|
| 937 | - if (strpos($text, (string) "@$name@") !== false) { |
|
| 938 | - if ($options['sanitize']) { |
|
| 939 | - $value = echapper_html_suspect($value); |
|
| 940 | - $value = interdire_scripts($value, -1); |
|
| 941 | - } |
|
| 942 | - if (!empty($options['class'])) { |
|
| 943 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 944 | - } |
|
| 945 | - $text = str_replace("@$name@", $value, $text); |
|
| 946 | - unset($args[$name]); |
|
| 947 | - } |
|
| 948 | - } |
|
| 949 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 950 | - // (chaines de langues pas a jour) |
|
| 951 | - if ($args) { |
|
| 952 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 953 | - } |
|
| 954 | - } |
|
| 955 | - |
|
| 956 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 957 | - return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 958 | - } else { |
|
| 959 | - return $text; |
|
| 960 | - } |
|
| 913 | + $f = $text; |
|
| 914 | + $defaut_options = [ |
|
| 915 | + 'class' => null, |
|
| 916 | + 'sanitize' => true, |
|
| 917 | + ]; |
|
| 918 | + // support de l'ancien argument $class |
|
| 919 | + if ($options and is_string($options)) { |
|
| 920 | + $options = ['class' => $options]; |
|
| 921 | + } |
|
| 922 | + if (is_array($options)) { |
|
| 923 | + $options += $defaut_options; |
|
| 924 | + } else { |
|
| 925 | + $options = $defaut_options; |
|
| 926 | + } |
|
| 927 | + |
|
| 928 | + if (is_array($args) and count($args)) { |
|
| 929 | + if (!function_exists('interdire_scripts')) { |
|
| 930 | + include_spip('inc/texte'); |
|
| 931 | + } |
|
| 932 | + if (!function_exists('echapper_html_suspect')) { |
|
| 933 | + include_spip('inc/texte_mini'); |
|
| 934 | + } |
|
| 935 | + foreach ($args as $name => $value) { |
|
| 936 | + if (strpos($text, (string) "@$name@") !== false) { |
|
| 937 | + if ($options['sanitize']) { |
|
| 938 | + $value = echapper_html_suspect($value); |
|
| 939 | + $value = interdire_scripts($value, -1); |
|
| 940 | + } |
|
| 941 | + if (!empty($options['class'])) { |
|
| 942 | + $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 943 | + } |
|
| 944 | + $text = str_replace("@$name@", $value, $text); |
|
| 945 | + unset($args[$name]); |
|
| 946 | + } |
|
| 947 | + } |
|
| 948 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 949 | + // (chaines de langues pas a jour) |
|
| 950 | + if ($args) { |
|
| 951 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 952 | + } |
|
| 953 | + } |
|
| 954 | + |
|
| 955 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 956 | + return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 957 | + } else { |
|
| 958 | + return $text; |
|
| 959 | + } |
|
| 961 | 960 | } |
| 962 | 961 | |
| 963 | 962 | |
@@ -971,13 +970,13 @@ discard block |
||
| 971 | 970 | * @return string |
| 972 | 971 | */ |
| 973 | 972 | function joli_repertoire($rep) { |
| 974 | - $a = substr($rep, 0, 1); |
|
| 975 | - if ($a <> '.' and $a <> '/') { |
|
| 976 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 977 | - } |
|
| 978 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 973 | + $a = substr($rep, 0, 1); |
|
| 974 | + if ($a <> '.' and $a <> '/') { |
|
| 975 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 976 | + } |
|
| 977 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 979 | 978 | |
| 980 | - return $rep; |
|
| 979 | + return $rep; |
|
| 981 | 980 | } |
| 982 | 981 | |
| 983 | 982 | |
@@ -1002,54 +1001,54 @@ discard block |
||
| 1002 | 1001 | * @return float|int|string|void |
| 1003 | 1002 | */ |
| 1004 | 1003 | function spip_timer($t = 'rien', $raw = false) { |
| 1005 | - static $time; |
|
| 1006 | - $a = time(); |
|
| 1007 | - $b = microtime(); |
|
| 1008 | - // microtime peut contenir les microsecondes et le temps |
|
| 1009 | - $b = explode(' ', $b); |
|
| 1010 | - if (count($b) == 2) { |
|
| 1011 | - $a = end($b); |
|
| 1012 | - } // plus precis ! |
|
| 1013 | - $b = reset($b); |
|
| 1014 | - if (!isset($time[$t])) { |
|
| 1015 | - $time[$t] = $a + $b; |
|
| 1016 | - } else { |
|
| 1017 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 1018 | - unset($time[$t]); |
|
| 1004 | + static $time; |
|
| 1005 | + $a = time(); |
|
| 1006 | + $b = microtime(); |
|
| 1007 | + // microtime peut contenir les microsecondes et le temps |
|
| 1008 | + $b = explode(' ', $b); |
|
| 1009 | + if (count($b) == 2) { |
|
| 1010 | + $a = end($b); |
|
| 1011 | + } // plus precis ! |
|
| 1012 | + $b = reset($b); |
|
| 1013 | + if (!isset($time[$t])) { |
|
| 1014 | + $time[$t] = $a + $b; |
|
| 1015 | + } else { |
|
| 1016 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 1017 | + unset($time[$t]); |
|
| 1019 | 1018 | # echo "'$p'";exit; |
| 1020 | - if ($raw) { |
|
| 1021 | - return $p; |
|
| 1022 | - } |
|
| 1023 | - if ($p < 1000) { |
|
| 1024 | - $s = ''; |
|
| 1025 | - } else { |
|
| 1026 | - $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1027 | - $p -= ($x * 1000); |
|
| 1028 | - } |
|
| 1019 | + if ($raw) { |
|
| 1020 | + return $p; |
|
| 1021 | + } |
|
| 1022 | + if ($p < 1000) { |
|
| 1023 | + $s = ''; |
|
| 1024 | + } else { |
|
| 1025 | + $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1026 | + $p -= ($x * 1000); |
|
| 1027 | + } |
|
| 1029 | 1028 | |
| 1030 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1031 | - } |
|
| 1029 | + return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1030 | + } |
|
| 1032 | 1031 | } |
| 1033 | 1032 | |
| 1034 | 1033 | |
| 1035 | 1034 | // Renvoie False si un fichier n'est pas plus vieux que $duree secondes, |
| 1036 | 1035 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 1037 | 1036 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 1038 | - if ($duree) { |
|
| 1039 | - clearstatcache(); |
|
| 1040 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1041 | - return false; |
|
| 1042 | - } |
|
| 1043 | - } |
|
| 1044 | - if ($touch !== false) { |
|
| 1045 | - if (!@touch($fichier)) { |
|
| 1046 | - spip_unlink($fichier); |
|
| 1047 | - @touch($fichier); |
|
| 1048 | - }; |
|
| 1049 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1050 | - } |
|
| 1037 | + if ($duree) { |
|
| 1038 | + clearstatcache(); |
|
| 1039 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1040 | + return false; |
|
| 1041 | + } |
|
| 1042 | + } |
|
| 1043 | + if ($touch !== false) { |
|
| 1044 | + if (!@touch($fichier)) { |
|
| 1045 | + spip_unlink($fichier); |
|
| 1046 | + @touch($fichier); |
|
| 1047 | + }; |
|
| 1048 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1049 | + } |
|
| 1051 | 1050 | |
| 1052 | - return true; |
|
| 1051 | + return true; |
|
| 1053 | 1052 | } |
| 1054 | 1053 | |
| 1055 | 1054 | |
@@ -1060,11 +1059,11 @@ discard block |
||
| 1060 | 1059 | * @uses cron() |
| 1061 | 1060 | **/ |
| 1062 | 1061 | function action_cron() { |
| 1063 | - include_spip('inc/headers'); |
|
| 1064 | - http_response_code(204); // No Content |
|
| 1065 | - header('Connection: close'); |
|
| 1066 | - define('_DIRECT_CRON_FORCE', true); |
|
| 1067 | - cron(); |
|
| 1062 | + include_spip('inc/headers'); |
|
| 1063 | + http_response_code(204); // No Content |
|
| 1064 | + header('Connection: close'); |
|
| 1065 | + define('_DIRECT_CRON_FORCE', true); |
|
| 1066 | + cron(); |
|
| 1068 | 1067 | } |
| 1069 | 1068 | |
| 1070 | 1069 | /** |
@@ -1080,26 +1079,26 @@ discard block |
||
| 1080 | 1079 | * True si la tache a pu être effectuée |
| 1081 | 1080 | */ |
| 1082 | 1081 | function cron($taches = [], $taches_old = []) { |
| 1083 | - // si pas en mode cron force, laisser tomber. |
|
| 1084 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1085 | - return false; |
|
| 1086 | - } |
|
| 1087 | - if (!is_array($taches)) { |
|
| 1088 | - $taches = $taches_old; |
|
| 1089 | - } // compat anciens appels |
|
| 1090 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1091 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1092 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1093 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1094 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1095 | - return false; |
|
| 1096 | - } |
|
| 1097 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1098 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1099 | - return $genie($taches); |
|
| 1100 | - } |
|
| 1101 | - |
|
| 1102 | - return false; |
|
| 1082 | + // si pas en mode cron force, laisser tomber. |
|
| 1083 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1084 | + return false; |
|
| 1085 | + } |
|
| 1086 | + if (!is_array($taches)) { |
|
| 1087 | + $taches = $taches_old; |
|
| 1088 | + } // compat anciens appels |
|
| 1089 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1090 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1091 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1092 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1093 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1094 | + return false; |
|
| 1095 | + } |
|
| 1096 | + spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1097 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1098 | + return $genie($taches); |
|
| 1099 | + } |
|
| 1100 | + |
|
| 1101 | + return false; |
|
| 1103 | 1102 | } |
| 1104 | 1103 | |
| 1105 | 1104 | /** |
@@ -1131,17 +1130,17 @@ discard block |
||
| 1131 | 1130 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1132 | 1131 | */ |
| 1133 | 1132 | function job_queue_add( |
| 1134 | - $function, |
|
| 1135 | - $description, |
|
| 1136 | - $arguments = [], |
|
| 1137 | - $file = '', |
|
| 1138 | - $no_duplicate = false, |
|
| 1139 | - $time = 0, |
|
| 1140 | - $priority = 0 |
|
| 1133 | + $function, |
|
| 1134 | + $description, |
|
| 1135 | + $arguments = [], |
|
| 1136 | + $file = '', |
|
| 1137 | + $no_duplicate = false, |
|
| 1138 | + $time = 0, |
|
| 1139 | + $priority = 0 |
|
| 1141 | 1140 | ) { |
| 1142 | - include_spip('inc/queue'); |
|
| 1141 | + include_spip('inc/queue'); |
|
| 1143 | 1142 | |
| 1144 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1143 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1145 | 1144 | } |
| 1146 | 1145 | |
| 1147 | 1146 | /** |
@@ -1152,9 +1151,9 @@ discard block |
||
| 1152 | 1151 | * @return bool |
| 1153 | 1152 | */ |
| 1154 | 1153 | function job_queue_remove($id_job) { |
| 1155 | - include_spip('inc/queue'); |
|
| 1154 | + include_spip('inc/queue'); |
|
| 1156 | 1155 | |
| 1157 | - return queue_remove_job($id_job); |
|
| 1156 | + return queue_remove_job($id_job); |
|
| 1158 | 1157 | } |
| 1159 | 1158 | |
| 1160 | 1159 | /** |
@@ -1167,9 +1166,9 @@ discard block |
||
| 1167 | 1166 | * or an array of simple array to link multiples objet in one time |
| 1168 | 1167 | */ |
| 1169 | 1168 | function job_queue_link($id_job, $objets) { |
| 1170 | - include_spip('inc/queue'); |
|
| 1169 | + include_spip('inc/queue'); |
|
| 1171 | 1170 | |
| 1172 | - return queue_link_job($id_job, $objets); |
|
| 1171 | + return queue_link_job($id_job, $objets); |
|
| 1173 | 1172 | } |
| 1174 | 1173 | |
| 1175 | 1174 | |
@@ -1189,36 +1188,36 @@ discard block |
||
| 1189 | 1188 | * - `null` si la queue n'est pas encore initialisée |
| 1190 | 1189 | */ |
| 1191 | 1190 | function queue_sleep_time_to_next_job($force = null) { |
| 1192 | - static $queue_next_job_time = -1; |
|
| 1193 | - if ($force === true) { |
|
| 1194 | - $queue_next_job_time = -1; |
|
| 1195 | - } elseif ($force) { |
|
| 1196 | - $queue_next_job_time = $force; |
|
| 1197 | - } |
|
| 1198 | - |
|
| 1199 | - if ($queue_next_job_time == -1) { |
|
| 1200 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1201 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1202 | - } |
|
| 1203 | - // utiliser un cache memoire si dispo |
|
| 1204 | - if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1205 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1206 | - } else { |
|
| 1207 | - $queue_next_job_time = null; |
|
| 1208 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1209 | - $queue_next_job_time = intval($contenu); |
|
| 1210 | - } |
|
| 1211 | - } |
|
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - if (is_null($queue_next_job_time)) { |
|
| 1215 | - return null; |
|
| 1216 | - } |
|
| 1217 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1218 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1219 | - } |
|
| 1220 | - |
|
| 1221 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1191 | + static $queue_next_job_time = -1; |
|
| 1192 | + if ($force === true) { |
|
| 1193 | + $queue_next_job_time = -1; |
|
| 1194 | + } elseif ($force) { |
|
| 1195 | + $queue_next_job_time = $force; |
|
| 1196 | + } |
|
| 1197 | + |
|
| 1198 | + if ($queue_next_job_time == -1) { |
|
| 1199 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1200 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1201 | + } |
|
| 1202 | + // utiliser un cache memoire si dispo |
|
| 1203 | + if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1204 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1205 | + } else { |
|
| 1206 | + $queue_next_job_time = null; |
|
| 1207 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1208 | + $queue_next_job_time = intval($contenu); |
|
| 1209 | + } |
|
| 1210 | + } |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + if (is_null($queue_next_job_time)) { |
|
| 1214 | + return null; |
|
| 1215 | + } |
|
| 1216 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1217 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1218 | + } |
|
| 1219 | + |
|
| 1220 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1222 | 1221 | } |
| 1223 | 1222 | |
| 1224 | 1223 | |
@@ -1230,11 +1229,11 @@ discard block |
||
| 1230 | 1229 | * @return string |
| 1231 | 1230 | */ |
| 1232 | 1231 | function quote_amp($u) { |
| 1233 | - return preg_replace( |
|
| 1234 | - '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1235 | - '&', |
|
| 1236 | - $u |
|
| 1237 | - ); |
|
| 1232 | + return preg_replace( |
|
| 1233 | + '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1234 | + '&', |
|
| 1235 | + $u |
|
| 1236 | + ); |
|
| 1238 | 1237 | } |
| 1239 | 1238 | |
| 1240 | 1239 | |
@@ -1257,27 +1256,27 @@ discard block |
||
| 1257 | 1256 | * Balise HTML `<script>` et son contenu |
| 1258 | 1257 | **/ |
| 1259 | 1258 | function http_script($script, $src = '', $noscript = '') { |
| 1260 | - static $done = []; |
|
| 1259 | + static $done = []; |
|
| 1261 | 1260 | |
| 1262 | - if ($src && !isset($done[$src])) { |
|
| 1263 | - $done[$src] = true; |
|
| 1264 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1265 | - $src = " src='$src'"; |
|
| 1266 | - } else { |
|
| 1267 | - $src = ''; |
|
| 1268 | - } |
|
| 1269 | - if ($script) { |
|
| 1270 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1271 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1272 | - '/*]]>*/'); |
|
| 1273 | - } |
|
| 1274 | - if ($noscript) { |
|
| 1275 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1276 | - } |
|
| 1261 | + if ($src && !isset($done[$src])) { |
|
| 1262 | + $done[$src] = true; |
|
| 1263 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1264 | + $src = " src='$src'"; |
|
| 1265 | + } else { |
|
| 1266 | + $src = ''; |
|
| 1267 | + } |
|
| 1268 | + if ($script) { |
|
| 1269 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1270 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1271 | + '/*]]>*/'); |
|
| 1272 | + } |
|
| 1273 | + if ($noscript) { |
|
| 1274 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1275 | + } |
|
| 1277 | 1276 | |
| 1278 | - return ($src or $script or $noscript) |
|
| 1279 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1280 | - : ''; |
|
| 1277 | + return ($src or $script or $noscript) |
|
| 1278 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1279 | + : ''; |
|
| 1281 | 1280 | } |
| 1282 | 1281 | |
| 1283 | 1282 | |
@@ -1312,7 +1311,7 @@ discard block |
||
| 1312 | 1311 | * texte échappé |
| 1313 | 1312 | **/ |
| 1314 | 1313 | function texte_script(string $texte): string { |
| 1315 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1314 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1316 | 1315 | } |
| 1317 | 1316 | |
| 1318 | 1317 | |
@@ -1349,68 +1348,68 @@ discard block |
||
| 1349 | 1348 | * Liste des chemins, par ordre de priorité. |
| 1350 | 1349 | **/ |
| 1351 | 1350 | function _chemin($dir_path = null) { |
| 1352 | - static $path_base = null; |
|
| 1353 | - static $path_full = null; |
|
| 1354 | - if ($path_base == null) { |
|
| 1355 | - // Chemin standard depuis l'espace public |
|
| 1356 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1357 | - _DIR_RACINE . ':' . |
|
| 1358 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1359 | - _DIR_RACINE . 'prive/:' . |
|
| 1360 | - _DIR_RESTREINT; |
|
| 1361 | - // Ajouter squelettes/ |
|
| 1362 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1363 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1364 | - } |
|
| 1365 | - foreach (explode(':', $path) as $dir) { |
|
| 1366 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1367 | - $dir .= '/'; |
|
| 1368 | - } |
|
| 1369 | - $path_base[] = $dir; |
|
| 1370 | - } |
|
| 1371 | - $path_full = $path_base; |
|
| 1372 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1373 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1374 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1375 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1376 | - } |
|
| 1377 | - } |
|
| 1378 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1379 | - } |
|
| 1380 | - if ($dir_path === null) { |
|
| 1381 | - return $path_full; |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1385 | - $tete = ''; |
|
| 1386 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1387 | - $tete = array_shift($path_base); |
|
| 1388 | - } |
|
| 1389 | - $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1390 | - $dirs = array_reverse($dirs); |
|
| 1391 | - foreach ($dirs as $dir_path) { |
|
| 1392 | - if (substr($dir_path, -1) != '/') { |
|
| 1393 | - $dir_path .= '/'; |
|
| 1394 | - } |
|
| 1395 | - if (!in_array($dir_path, $path_base)) { |
|
| 1396 | - array_unshift($path_base, $dir_path); |
|
| 1397 | - } |
|
| 1398 | - } |
|
| 1399 | - if (strlen($tete)) { |
|
| 1400 | - array_unshift($path_base, $tete); |
|
| 1401 | - } |
|
| 1402 | - } |
|
| 1403 | - $path_full = $path_base; |
|
| 1404 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1405 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1406 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1407 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1408 | - } |
|
| 1409 | - } |
|
| 1410 | - |
|
| 1411 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1412 | - |
|
| 1413 | - return $path_full; |
|
| 1351 | + static $path_base = null; |
|
| 1352 | + static $path_full = null; |
|
| 1353 | + if ($path_base == null) { |
|
| 1354 | + // Chemin standard depuis l'espace public |
|
| 1355 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1356 | + _DIR_RACINE . ':' . |
|
| 1357 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1358 | + _DIR_RACINE . 'prive/:' . |
|
| 1359 | + _DIR_RESTREINT; |
|
| 1360 | + // Ajouter squelettes/ |
|
| 1361 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1362 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1363 | + } |
|
| 1364 | + foreach (explode(':', $path) as $dir) { |
|
| 1365 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1366 | + $dir .= '/'; |
|
| 1367 | + } |
|
| 1368 | + $path_base[] = $dir; |
|
| 1369 | + } |
|
| 1370 | + $path_full = $path_base; |
|
| 1371 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1372 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1373 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1374 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1375 | + } |
|
| 1376 | + } |
|
| 1377 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1378 | + } |
|
| 1379 | + if ($dir_path === null) { |
|
| 1380 | + return $path_full; |
|
| 1381 | + } |
|
| 1382 | + |
|
| 1383 | + if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1384 | + $tete = ''; |
|
| 1385 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1386 | + $tete = array_shift($path_base); |
|
| 1387 | + } |
|
| 1388 | + $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1389 | + $dirs = array_reverse($dirs); |
|
| 1390 | + foreach ($dirs as $dir_path) { |
|
| 1391 | + if (substr($dir_path, -1) != '/') { |
|
| 1392 | + $dir_path .= '/'; |
|
| 1393 | + } |
|
| 1394 | + if (!in_array($dir_path, $path_base)) { |
|
| 1395 | + array_unshift($path_base, $dir_path); |
|
| 1396 | + } |
|
| 1397 | + } |
|
| 1398 | + if (strlen($tete)) { |
|
| 1399 | + array_unshift($path_base, $tete); |
|
| 1400 | + } |
|
| 1401 | + } |
|
| 1402 | + $path_full = $path_base; |
|
| 1403 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1404 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1405 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1406 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1407 | + } |
|
| 1408 | + } |
|
| 1409 | + |
|
| 1410 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1411 | + |
|
| 1412 | + return $path_full; |
|
| 1414 | 1413 | } |
| 1415 | 1414 | |
| 1416 | 1415 | /** |
@@ -1423,17 +1422,17 @@ discard block |
||
| 1423 | 1422 | * @return array Liste de chemins |
| 1424 | 1423 | **/ |
| 1425 | 1424 | function creer_chemin() { |
| 1426 | - $path_a = _chemin(); |
|
| 1427 | - static $c = ''; |
|
| 1425 | + $path_a = _chemin(); |
|
| 1426 | + static $c = ''; |
|
| 1428 | 1427 | |
| 1429 | - // on calcule le chemin si le dossier skel a change |
|
| 1430 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1431 | - // assurer le non plantage lors de la montee de version : |
|
| 1432 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1433 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1434 | - } |
|
| 1428 | + // on calcule le chemin si le dossier skel a change |
|
| 1429 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1430 | + // assurer le non plantage lors de la montee de version : |
|
| 1431 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1432 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1433 | + } |
|
| 1435 | 1434 | |
| 1436 | - return $path_a; |
|
| 1435 | + return $path_a; |
|
| 1437 | 1436 | } |
| 1438 | 1437 | |
| 1439 | 1438 | |
@@ -1445,61 +1444,61 @@ discard block |
||
| 1445 | 1444 | * @return string[] Nom des thèmes. |
| 1446 | 1445 | */ |
| 1447 | 1446 | function lister_themes_prives(): array { |
| 1448 | - static $themes = null; |
|
| 1449 | - if (is_null($themes)) { |
|
| 1450 | - // si pas encore definie |
|
| 1451 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1452 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1453 | - } |
|
| 1454 | - $themes = [_SPIP_THEME_PRIVE]; |
|
| 1455 | - // Lors d'une installation neuve, prefs n'est pas definie ; sinon, c'est un tableau sérialisé |
|
| 1456 | - // FIXME: Aussitôt après une demande d'inscription, $prefs vaut une chaine statut_tmp; |
|
| 1457 | - $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 1458 | - if (is_string($prefs) and (stripos($prefs, 'a:') === 0)) { |
|
| 1459 | - $prefs = unserialize($prefs); |
|
| 1460 | - } else { |
|
| 1461 | - $prefs = []; |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - $theme = $prefs['theme'] ?? $GLOBALS['theme_prive_defaut'] ?? null; |
|
| 1465 | - if ($theme and $theme !== _SPIP_THEME_PRIVE) { |
|
| 1466 | - // placer le theme choisi en tete |
|
| 1467 | - array_unshift($themes, $theme); |
|
| 1468 | - } |
|
| 1469 | - } |
|
| 1470 | - |
|
| 1471 | - return $themes; |
|
| 1447 | + static $themes = null; |
|
| 1448 | + if (is_null($themes)) { |
|
| 1449 | + // si pas encore definie |
|
| 1450 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1451 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1452 | + } |
|
| 1453 | + $themes = [_SPIP_THEME_PRIVE]; |
|
| 1454 | + // Lors d'une installation neuve, prefs n'est pas definie ; sinon, c'est un tableau sérialisé |
|
| 1455 | + // FIXME: Aussitôt après une demande d'inscription, $prefs vaut une chaine statut_tmp; |
|
| 1456 | + $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 1457 | + if (is_string($prefs) and (stripos($prefs, 'a:') === 0)) { |
|
| 1458 | + $prefs = unserialize($prefs); |
|
| 1459 | + } else { |
|
| 1460 | + $prefs = []; |
|
| 1461 | + } |
|
| 1462 | + |
|
| 1463 | + $theme = $prefs['theme'] ?? $GLOBALS['theme_prive_defaut'] ?? null; |
|
| 1464 | + if ($theme and $theme !== _SPIP_THEME_PRIVE) { |
|
| 1465 | + // placer le theme choisi en tete |
|
| 1466 | + array_unshift($themes, $theme); |
|
| 1467 | + } |
|
| 1468 | + } |
|
| 1469 | + |
|
| 1470 | + return $themes; |
|
| 1472 | 1471 | } |
| 1473 | 1472 | |
| 1474 | 1473 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1475 | - static $themefiles = []; |
|
| 1476 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1477 | - return $themefiles["$subdir$file"]; |
|
| 1478 | - } |
|
| 1479 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1480 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1481 | - if ( |
|
| 1482 | - preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1483 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1484 | - and $f = find_in_theme("$file_svg_generique") |
|
| 1485 | - ) { |
|
| 1486 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1487 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1488 | - } |
|
| 1489 | - else { |
|
| 1490 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1491 | - } |
|
| 1492 | - } |
|
| 1493 | - |
|
| 1494 | - $themes = lister_themes_prives(); |
|
| 1495 | - foreach ($themes as $theme) { |
|
| 1496 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1497 | - return $themefiles["$subdir$file"] = $f; |
|
| 1498 | - } |
|
| 1499 | - } |
|
| 1500 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1501 | - |
|
| 1502 | - return $themefiles["$subdir$file"] = ''; |
|
| 1474 | + static $themefiles = []; |
|
| 1475 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1476 | + return $themefiles["$subdir$file"]; |
|
| 1477 | + } |
|
| 1478 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1479 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1480 | + if ( |
|
| 1481 | + preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1482 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1483 | + and $f = find_in_theme("$file_svg_generique") |
|
| 1484 | + ) { |
|
| 1485 | + if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1486 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1487 | + } |
|
| 1488 | + else { |
|
| 1489 | + return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1490 | + } |
|
| 1491 | + } |
|
| 1492 | + |
|
| 1493 | + $themes = lister_themes_prives(); |
|
| 1494 | + foreach ($themes as $theme) { |
|
| 1495 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1496 | + return $themefiles["$subdir$file"] = $f; |
|
| 1497 | + } |
|
| 1498 | + } |
|
| 1499 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1500 | + |
|
| 1501 | + return $themefiles["$subdir$file"] = ''; |
|
| 1503 | 1502 | } |
| 1504 | 1503 | |
| 1505 | 1504 | |
@@ -1523,31 +1522,31 @@ discard block |
||
| 1523 | 1522 | * sinon chaîne vide. |
| 1524 | 1523 | **/ |
| 1525 | 1524 | function chemin_image($icone) { |
| 1526 | - static $icone_renommer; |
|
| 1527 | - if ($p = strpos($icone, '?')) { |
|
| 1528 | - $icone = substr($icone, 0, $p); |
|
| 1529 | - } |
|
| 1530 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1531 | - if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1532 | - return $icone; |
|
| 1533 | - } |
|
| 1534 | - |
|
| 1535 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1536 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1537 | - return $f; |
|
| 1538 | - } |
|
| 1539 | - // sinon passer par le module de renommage |
|
| 1540 | - if (is_null($icone_renommer)) { |
|
| 1541 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1542 | - } |
|
| 1543 | - if ($icone_renommer) { |
|
| 1544 | - [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1545 | - if (file_exists($icone)) { |
|
| 1546 | - return $icone; |
|
| 1547 | - } |
|
| 1548 | - } |
|
| 1549 | - |
|
| 1550 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1525 | + static $icone_renommer; |
|
| 1526 | + if ($p = strpos($icone, '?')) { |
|
| 1527 | + $icone = substr($icone, 0, $p); |
|
| 1528 | + } |
|
| 1529 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1530 | + if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1531 | + return $icone; |
|
| 1532 | + } |
|
| 1533 | + |
|
| 1534 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1535 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1536 | + return $f; |
|
| 1537 | + } |
|
| 1538 | + // sinon passer par le module de renommage |
|
| 1539 | + if (is_null($icone_renommer)) { |
|
| 1540 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1541 | + } |
|
| 1542 | + if ($icone_renommer) { |
|
| 1543 | + [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1544 | + if (file_exists($icone)) { |
|
| 1545 | + return $icone; |
|
| 1546 | + } |
|
| 1547 | + } |
|
| 1548 | + |
|
| 1549 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1551 | 1550 | } |
| 1552 | 1551 | |
| 1553 | 1552 | // |
@@ -1585,128 +1584,128 @@ discard block |
||
| 1585 | 1584 | * - false : fichier introuvable |
| 1586 | 1585 | **/ |
| 1587 | 1586 | function find_in_path($file, $dirname = '', $include = false) { |
| 1588 | - static $dirs = []; |
|
| 1589 | - static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1590 | - static $c = ''; |
|
| 1591 | - |
|
| 1592 | - if (!$file and !strlen($file)) { |
|
| 1593 | - return false; |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - // on calcule le chemin si le dossier skel a change |
|
| 1597 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1598 | - // assurer le non plantage lors de la montee de version : |
|
| 1599 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1600 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1601 | - } |
|
| 1602 | - |
|
| 1603 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1604 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1605 | - return false; |
|
| 1606 | - } |
|
| 1607 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1608 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1609 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1610 | - } |
|
| 1611 | - |
|
| 1612 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - $a = strrpos($file, '/'); |
|
| 1616 | - if ($a !== false) { |
|
| 1617 | - $dirname .= substr($file, 0, ++$a); |
|
| 1618 | - $file = substr($file, $a); |
|
| 1619 | - } |
|
| 1620 | - |
|
| 1621 | - foreach (creer_chemin() as $dir) { |
|
| 1622 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1623 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1624 | - } |
|
| 1625 | - if ($dirs[$a]) { |
|
| 1626 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1627 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1628 | - include_once _ROOT_CWD . $a; |
|
| 1629 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 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 $a; |
|
| 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] = $a; |
|
| 1640 | - } |
|
| 1641 | - } |
|
| 1642 | - } |
|
| 1643 | - |
|
| 1644 | - if ($include) { |
|
| 1645 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1646 | - if ($include === 'required') { |
|
| 1647 | - echo '<pre>', |
|
| 1648 | - '<strong>Erreur Fatale</strong><br />'; |
|
| 1649 | - if (function_exists('debug_print_backtrace')) { |
|
| 1650 | - debug_print_backtrace(); |
|
| 1651 | - } |
|
| 1652 | - echo '</pre>'; |
|
| 1653 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1654 | - } |
|
| 1655 | - } |
|
| 1656 | - |
|
| 1657 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1658 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1659 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1660 | - return false; |
|
| 1661 | - } |
|
| 1662 | - define('_SAUVER_CHEMIN', true); |
|
| 1663 | - } |
|
| 1664 | - |
|
| 1665 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1587 | + static $dirs = []; |
|
| 1588 | + static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1589 | + static $c = ''; |
|
| 1590 | + |
|
| 1591 | + if (!$file and !strlen($file)) { |
|
| 1592 | + return false; |
|
| 1593 | + } |
|
| 1594 | + |
|
| 1595 | + // on calcule le chemin si le dossier skel a change |
|
| 1596 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1597 | + // assurer le non plantage lors de la montee de version : |
|
| 1598 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1599 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1600 | + } |
|
| 1601 | + |
|
| 1602 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1603 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1604 | + return false; |
|
| 1605 | + } |
|
| 1606 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1607 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1608 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1609 | + } |
|
| 1610 | + |
|
| 1611 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1612 | + } |
|
| 1613 | + |
|
| 1614 | + $a = strrpos($file, '/'); |
|
| 1615 | + if ($a !== false) { |
|
| 1616 | + $dirname .= substr($file, 0, ++$a); |
|
| 1617 | + $file = substr($file, $a); |
|
| 1618 | + } |
|
| 1619 | + |
|
| 1620 | + foreach (creer_chemin() as $dir) { |
|
| 1621 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1622 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1623 | + } |
|
| 1624 | + if ($dirs[$a]) { |
|
| 1625 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1626 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1627 | + include_once _ROOT_CWD . $a; |
|
| 1628 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1629 | + } |
|
| 1630 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1631 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1632 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1633 | + return $a; |
|
| 1634 | + } |
|
| 1635 | + define('_SAUVER_CHEMIN', true); |
|
| 1636 | + } |
|
| 1637 | + |
|
| 1638 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1639 | + } |
|
| 1640 | + } |
|
| 1641 | + } |
|
| 1642 | + |
|
| 1643 | + if ($include) { |
|
| 1644 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1645 | + if ($include === 'required') { |
|
| 1646 | + echo '<pre>', |
|
| 1647 | + '<strong>Erreur Fatale</strong><br />'; |
|
| 1648 | + if (function_exists('debug_print_backtrace')) { |
|
| 1649 | + debug_print_backtrace(); |
|
| 1650 | + } |
|
| 1651 | + echo '</pre>'; |
|
| 1652 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1653 | + } |
|
| 1654 | + } |
|
| 1655 | + |
|
| 1656 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1657 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1658 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1659 | + return false; |
|
| 1660 | + } |
|
| 1661 | + define('_SAUVER_CHEMIN', true); |
|
| 1662 | + } |
|
| 1663 | + |
|
| 1664 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1666 | 1665 | } |
| 1667 | 1666 | |
| 1668 | 1667 | function clear_path_cache() { |
| 1669 | - $GLOBALS['path_files'] = []; |
|
| 1670 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1668 | + $GLOBALS['path_files'] = []; |
|
| 1669 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1671 | 1670 | } |
| 1672 | 1671 | |
| 1673 | 1672 | function load_path_cache() { |
| 1674 | - // charger le path des plugins |
|
| 1675 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1676 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1677 | - } |
|
| 1678 | - $GLOBALS['path_files'] = []; |
|
| 1679 | - // si le visiteur est admin, |
|
| 1680 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1681 | - if ( |
|
| 1682 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1683 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1684 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1685 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1686 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1687 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1688 | - !_request('var_mode') |
|
| 1689 | - ) { |
|
| 1690 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1691 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1692 | - // mais si semble corrompu on relit avec un verrou |
|
| 1693 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1694 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1695 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1696 | - $GLOBALS['path_files'] = []; |
|
| 1697 | - } |
|
| 1698 | - } |
|
| 1699 | - } |
|
| 1700 | - } |
|
| 1673 | + // charger le path des plugins |
|
| 1674 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1675 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1676 | + } |
|
| 1677 | + $GLOBALS['path_files'] = []; |
|
| 1678 | + // si le visiteur est admin, |
|
| 1679 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1680 | + if ( |
|
| 1681 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1682 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1683 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1684 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1685 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1686 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1687 | + !_request('var_mode') |
|
| 1688 | + ) { |
|
| 1689 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1690 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1691 | + // mais si semble corrompu on relit avec un verrou |
|
| 1692 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1693 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1694 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1695 | + $GLOBALS['path_files'] = []; |
|
| 1696 | + } |
|
| 1697 | + } |
|
| 1698 | + } |
|
| 1699 | + } |
|
| 1701 | 1700 | } |
| 1702 | 1701 | |
| 1703 | 1702 | function save_path_cache() { |
| 1704 | - if ( |
|
| 1705 | - defined('_SAUVER_CHEMIN') |
|
| 1706 | - and _SAUVER_CHEMIN |
|
| 1707 | - ) { |
|
| 1708 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1709 | - } |
|
| 1703 | + if ( |
|
| 1704 | + defined('_SAUVER_CHEMIN') |
|
| 1705 | + and _SAUVER_CHEMIN |
|
| 1706 | + ) { |
|
| 1707 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1708 | + } |
|
| 1710 | 1709 | } |
| 1711 | 1710 | |
| 1712 | 1711 | |
@@ -1726,33 +1725,33 @@ discard block |
||
| 1726 | 1725 | * @return array |
| 1727 | 1726 | */ |
| 1728 | 1727 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1729 | - $liste_fichiers = []; |
|
| 1730 | - $maxfiles = 10000; |
|
| 1731 | - |
|
| 1732 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1733 | - // on a pas encore inclus flock.php |
|
| 1734 | - if (!function_exists('preg_files')) { |
|
| 1735 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1736 | - } |
|
| 1737 | - |
|
| 1738 | - // Parcourir le chemin |
|
| 1739 | - foreach (creer_chemin() as $d) { |
|
| 1740 | - $f = $d . $dir; |
|
| 1741 | - if (@is_dir($f)) { |
|
| 1742 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1743 | - foreach ($liste as $chemin) { |
|
| 1744 | - $nom = basename($chemin); |
|
| 1745 | - // ne prendre que les fichiers pas deja trouves |
|
| 1746 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1747 | - // les autres sont donc masques |
|
| 1748 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1749 | - $liste_fichiers[$nom] = $chemin; |
|
| 1750 | - } |
|
| 1751 | - } |
|
| 1752 | - } |
|
| 1753 | - } |
|
| 1754 | - |
|
| 1755 | - return $liste_fichiers; |
|
| 1728 | + $liste_fichiers = []; |
|
| 1729 | + $maxfiles = 10000; |
|
| 1730 | + |
|
| 1731 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1732 | + // on a pas encore inclus flock.php |
|
| 1733 | + if (!function_exists('preg_files')) { |
|
| 1734 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1735 | + } |
|
| 1736 | + |
|
| 1737 | + // Parcourir le chemin |
|
| 1738 | + foreach (creer_chemin() as $d) { |
|
| 1739 | + $f = $d . $dir; |
|
| 1740 | + if (@is_dir($f)) { |
|
| 1741 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1742 | + foreach ($liste as $chemin) { |
|
| 1743 | + $nom = basename($chemin); |
|
| 1744 | + // ne prendre que les fichiers pas deja trouves |
|
| 1745 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1746 | + // les autres sont donc masques |
|
| 1747 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1748 | + $liste_fichiers[$nom] = $chemin; |
|
| 1749 | + } |
|
| 1750 | + } |
|
| 1751 | + } |
|
| 1752 | + } |
|
| 1753 | + |
|
| 1754 | + return $liste_fichiers; |
|
| 1756 | 1755 | } |
| 1757 | 1756 | |
| 1758 | 1757 | /** |
@@ -1764,17 +1763,17 @@ discard block |
||
| 1764 | 1763 | * @return bool |
| 1765 | 1764 | */ |
| 1766 | 1765 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1767 | - static $autsanscookie = ['install', 'base_repair']; |
|
| 1766 | + static $autsanscookie = ['install', 'base_repair']; |
|
| 1768 | 1767 | |
| 1769 | - if (in_array($nom, $autsanscookie)) { |
|
| 1770 | - if (test_espace_prive()) { |
|
| 1771 | - include_spip('base/connect_sql'); |
|
| 1772 | - if (!$strict or !spip_connect()) { |
|
| 1773 | - return true; |
|
| 1774 | - } |
|
| 1775 | - } |
|
| 1776 | - } |
|
| 1777 | - return false; |
|
| 1768 | + if (in_array($nom, $autsanscookie)) { |
|
| 1769 | + if (test_espace_prive()) { |
|
| 1770 | + include_spip('base/connect_sql'); |
|
| 1771 | + if (!$strict or !spip_connect()) { |
|
| 1772 | + return true; |
|
| 1773 | + } |
|
| 1774 | + } |
|
| 1775 | + } |
|
| 1776 | + return false; |
|
| 1778 | 1777 | } |
| 1779 | 1778 | |
| 1780 | 1779 | /** |
@@ -1784,60 +1783,60 @@ discard block |
||
| 1784 | 1783 | * @return string |
| 1785 | 1784 | */ |
| 1786 | 1785 | function charger_fonction_url(string $quoi, string $type = '') { |
| 1787 | - if ($type === 'defaut') { |
|
| 1788 | - $objet = objet_type($quoi); |
|
| 1789 | - if ( |
|
| 1790 | - $f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1791 | - // deprecated |
|
| 1792 | - or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1793 | - ) { |
|
| 1794 | - return $f; |
|
| 1795 | - } |
|
| 1796 | - return ''; |
|
| 1797 | - } |
|
| 1798 | - |
|
| 1799 | - $url_type = $type; |
|
| 1800 | - if (!$url_type) { |
|
| 1801 | - $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1802 | - } |
|
| 1803 | - |
|
| 1804 | - // inclure le module d'url |
|
| 1805 | - include_spip('urls/' . $url_type); |
|
| 1806 | - |
|
| 1807 | - switch ($quoi) { |
|
| 1808 | - case 'page': |
|
| 1809 | - if ( |
|
| 1810 | - function_exists($f = "urls_{$url_type}_generer_url_page") |
|
| 1811 | - or function_exists($f .= '_dist') |
|
| 1812 | - // ou une fonction custom utilisateur independante du type d'url |
|
| 1813 | - or function_exists($f = 'generer_url_page') |
|
| 1814 | - or function_exists($f .= '_dist') |
|
| 1815 | - ) { |
|
| 1816 | - return $f; |
|
| 1817 | - } |
|
| 1818 | - // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 1819 | - return ''; |
|
| 1820 | - case 'objet': |
|
| 1821 | - case 'decoder': |
|
| 1822 | - default: |
|
| 1823 | - $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 1824 | - if ( |
|
| 1825 | - function_exists($f = "urls_{$url_type}_{$fquoi}") |
|
| 1826 | - or function_exists($f .= '_dist') |
|
| 1827 | - ) { |
|
| 1828 | - return $f; |
|
| 1829 | - } |
|
| 1830 | - // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 1831 | - // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 1832 | - if ($f = charger_fonction($url_type, 'urls', true)) { |
|
| 1833 | - return $f; |
|
| 1834 | - } |
|
| 1835 | - // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement |
|
| 1836 | - if (!$type and $url_type !== 'page') { |
|
| 1837 | - return charger_fonction_url($quoi, 'page'); |
|
| 1838 | - } |
|
| 1839 | - return ''; |
|
| 1840 | - } |
|
| 1786 | + if ($type === 'defaut') { |
|
| 1787 | + $objet = objet_type($quoi); |
|
| 1788 | + if ( |
|
| 1789 | + $f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1790 | + // deprecated |
|
| 1791 | + or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1792 | + ) { |
|
| 1793 | + return $f; |
|
| 1794 | + } |
|
| 1795 | + return ''; |
|
| 1796 | + } |
|
| 1797 | + |
|
| 1798 | + $url_type = $type; |
|
| 1799 | + if (!$url_type) { |
|
| 1800 | + $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1801 | + } |
|
| 1802 | + |
|
| 1803 | + // inclure le module d'url |
|
| 1804 | + include_spip('urls/' . $url_type); |
|
| 1805 | + |
|
| 1806 | + switch ($quoi) { |
|
| 1807 | + case 'page': |
|
| 1808 | + if ( |
|
| 1809 | + function_exists($f = "urls_{$url_type}_generer_url_page") |
|
| 1810 | + or function_exists($f .= '_dist') |
|
| 1811 | + // ou une fonction custom utilisateur independante du type d'url |
|
| 1812 | + or function_exists($f = 'generer_url_page') |
|
| 1813 | + or function_exists($f .= '_dist') |
|
| 1814 | + ) { |
|
| 1815 | + return $f; |
|
| 1816 | + } |
|
| 1817 | + // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 1818 | + return ''; |
|
| 1819 | + case 'objet': |
|
| 1820 | + case 'decoder': |
|
| 1821 | + default: |
|
| 1822 | + $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 1823 | + if ( |
|
| 1824 | + function_exists($f = "urls_{$url_type}_{$fquoi}") |
|
| 1825 | + or function_exists($f .= '_dist') |
|
| 1826 | + ) { |
|
| 1827 | + return $f; |
|
| 1828 | + } |
|
| 1829 | + // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 1830 | + // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 1831 | + if ($f = charger_fonction($url_type, 'urls', true)) { |
|
| 1832 | + return $f; |
|
| 1833 | + } |
|
| 1834 | + // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement |
|
| 1835 | + if (!$type and $url_type !== 'page') { |
|
| 1836 | + return charger_fonction_url($quoi, 'page'); |
|
| 1837 | + } |
|
| 1838 | + return ''; |
|
| 1839 | + } |
|
| 1841 | 1840 | } |
| 1842 | 1841 | |
| 1843 | 1842 | |
@@ -1863,48 +1862,48 @@ discard block |
||
| 1863 | 1862 | * url codee ou fonction de decodage |
| 1864 | 1863 | */ |
| 1865 | 1864 | function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string { |
| 1866 | - if ($public === null) { |
|
| 1867 | - $public = !test_espace_prive(); |
|
| 1868 | - } |
|
| 1869 | - $id = intval($id); |
|
| 1870 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1871 | - |
|
| 1872 | - if (!$public) { |
|
| 1873 | - if (!$entite) { |
|
| 1874 | - return ''; |
|
| 1875 | - } |
|
| 1876 | - if (!function_exists('generer_objet_url_ecrire')) { |
|
| 1877 | - include_spip('inc/urls'); |
|
| 1878 | - } |
|
| 1879 | - $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect); |
|
| 1880 | - } else { |
|
| 1881 | - $f = charger_fonction_url('objet', $type ?? ''); |
|
| 1882 | - |
|
| 1883 | - // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 1884 | - // @see charger_fonction_url |
|
| 1885 | - if (!$entite) { |
|
| 1886 | - return $f; |
|
| 1887 | - } |
|
| 1888 | - |
|
| 1889 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1890 | - // base distante |
|
| 1891 | - if ( |
|
| 1892 | - $connect |
|
| 1893 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1894 | - ) { |
|
| 1895 | - $f = $g; |
|
| 1896 | - } |
|
| 1897 | - |
|
| 1898 | - $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect); |
|
| 1899 | - } |
|
| 1900 | - if ($res) { |
|
| 1901 | - return $res; |
|
| 1902 | - } |
|
| 1903 | - |
|
| 1904 | - // On a ete gentil mais la .... |
|
| 1905 | - spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR); |
|
| 1906 | - |
|
| 1907 | - return ''; |
|
| 1865 | + if ($public === null) { |
|
| 1866 | + $public = !test_espace_prive(); |
|
| 1867 | + } |
|
| 1868 | + $id = intval($id); |
|
| 1869 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1870 | + |
|
| 1871 | + if (!$public) { |
|
| 1872 | + if (!$entite) { |
|
| 1873 | + return ''; |
|
| 1874 | + } |
|
| 1875 | + if (!function_exists('generer_objet_url_ecrire')) { |
|
| 1876 | + include_spip('inc/urls'); |
|
| 1877 | + } |
|
| 1878 | + $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect); |
|
| 1879 | + } else { |
|
| 1880 | + $f = charger_fonction_url('objet', $type ?? ''); |
|
| 1881 | + |
|
| 1882 | + // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 1883 | + // @see charger_fonction_url |
|
| 1884 | + if (!$entite) { |
|
| 1885 | + return $f; |
|
| 1886 | + } |
|
| 1887 | + |
|
| 1888 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1889 | + // base distante |
|
| 1890 | + if ( |
|
| 1891 | + $connect |
|
| 1892 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1893 | + ) { |
|
| 1894 | + $f = $g; |
|
| 1895 | + } |
|
| 1896 | + |
|
| 1897 | + $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect); |
|
| 1898 | + } |
|
| 1899 | + if ($res) { |
|
| 1900 | + return $res; |
|
| 1901 | + } |
|
| 1902 | + |
|
| 1903 | + // On a ete gentil mais la .... |
|
| 1904 | + spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR); |
|
| 1905 | + |
|
| 1906 | + return ''; |
|
| 1908 | 1907 | } |
| 1909 | 1908 | |
| 1910 | 1909 | /** |
@@ -1912,10 +1911,10 @@ discard block |
||
| 1912 | 1911 | * @see generer_objet_url |
| 1913 | 1912 | */ |
| 1914 | 1913 | function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1915 | - if ($public and is_string($public)) { |
|
| 1916 | - return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
|
| 1917 | - } |
|
| 1918 | - return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? ''); |
|
| 1914 | + if ($public and is_string($public)) { |
|
| 1915 | + return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
|
| 1916 | + } |
|
| 1917 | + return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? ''); |
|
| 1919 | 1918 | } |
| 1920 | 1919 | |
| 1921 | 1920 | /** |
@@ -1927,19 +1926,19 @@ discard block |
||
| 1927 | 1926 | * @return string |
| 1928 | 1927 | */ |
| 1929 | 1928 | function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string { |
| 1930 | - $id = intval($id); |
|
| 1931 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1932 | - $url = generer_url_ecrire($exec, $args); |
|
| 1933 | - if (intval($id)) { |
|
| 1934 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1935 | - } else { |
|
| 1936 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1937 | - } |
|
| 1938 | - if ($ancre) { |
|
| 1939 | - $url = ancre_url($url, $ancre); |
|
| 1940 | - } |
|
| 1929 | + $id = intval($id); |
|
| 1930 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1931 | + $url = generer_url_ecrire($exec, $args); |
|
| 1932 | + if (intval($id)) { |
|
| 1933 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1934 | + } else { |
|
| 1935 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1936 | + } |
|
| 1937 | + if ($ancre) { |
|
| 1938 | + $url = ancre_url($url, $ancre); |
|
| 1939 | + } |
|
| 1941 | 1940 | |
| 1942 | - return $url; |
|
| 1941 | + return $url; |
|
| 1943 | 1942 | } |
| 1944 | 1943 | |
| 1945 | 1944 | /** |
@@ -1947,18 +1946,18 @@ discard block |
||
| 1947 | 1946 | * @see generer_objet_url_ecrire_edit |
| 1948 | 1947 | */ |
| 1949 | 1948 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 1950 | - return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
|
| 1949 | + return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
|
| 1951 | 1950 | } |
| 1952 | 1951 | |
| 1953 | 1952 | |
| 1954 | 1953 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1955 | - include_spip('base/connect_sql'); |
|
| 1956 | - $id_type = id_table_objet($entite, $public); |
|
| 1954 | + include_spip('base/connect_sql'); |
|
| 1955 | + $id_type = id_table_objet($entite, $public); |
|
| 1957 | 1956 | |
| 1958 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1959 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1960 | - . (!$args ? '' : "&$args") |
|
| 1961 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1957 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1958 | + . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1959 | + . (!$args ? '' : "&$args") |
|
| 1960 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1962 | 1961 | } |
| 1963 | 1962 | |
| 1964 | 1963 | |
@@ -1969,18 +1968,18 @@ discard block |
||
| 1969 | 1968 | * @return string |
| 1970 | 1969 | */ |
| 1971 | 1970 | function urlencode_1738($url) { |
| 1972 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1973 | - $uri = ''; |
|
| 1974 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1975 | - if (ord($a = $url[$i]) > 127) { |
|
| 1976 | - $a = rawurlencode($a); |
|
| 1977 | - } |
|
| 1978 | - $uri .= $a; |
|
| 1979 | - } |
|
| 1980 | - $url = $uri; |
|
| 1981 | - } |
|
| 1971 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1972 | + $uri = ''; |
|
| 1973 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1974 | + if (ord($a = $url[$i]) > 127) { |
|
| 1975 | + $a = rawurlencode($a); |
|
| 1976 | + } |
|
| 1977 | + $uri .= $a; |
|
| 1978 | + } |
|
| 1979 | + $url = $uri; |
|
| 1980 | + } |
|
| 1982 | 1981 | |
| 1983 | - return quote_amp($url); |
|
| 1982 | + return quote_amp($url); |
|
| 1984 | 1983 | } |
| 1985 | 1984 | |
| 1986 | 1985 | /** |
@@ -1996,14 +1995,14 @@ discard block |
||
| 1996 | 1995 | * @return string |
| 1997 | 1996 | */ |
| 1998 | 1997 | function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string { |
| 1999 | - $id = intval($id); |
|
| 2000 | - $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect); |
|
| 2001 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 2002 | - include_spip('inc/filtres_mini'); |
|
| 2003 | - $h = url_absolue($h); |
|
| 2004 | - } |
|
| 1998 | + $id = intval($id); |
|
| 1999 | + $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect); |
|
| 2000 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 2001 | + include_spip('inc/filtres_mini'); |
|
| 2002 | + $h = url_absolue($h); |
|
| 2003 | + } |
|
| 2005 | 2004 | |
| 2006 | - return $h; |
|
| 2005 | + return $h; |
|
| 2007 | 2006 | } |
| 2008 | 2007 | |
| 2009 | 2008 | /** |
@@ -2011,7 +2010,7 @@ discard block |
||
| 2011 | 2010 | * @see generer_objet_url_absolue |
| 2012 | 2011 | */ |
| 2013 | 2012 | function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) { |
| 2014 | - return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? ''); |
|
| 2013 | + return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? ''); |
|
| 2015 | 2014 | } |
| 2016 | 2015 | |
| 2017 | 2016 | |
@@ -2027,11 +2026,11 @@ discard block |
||
| 2027 | 2026 | * true si la valeur est considérée active ; false sinon. |
| 2028 | 2027 | **/ |
| 2029 | 2028 | function test_valeur_serveur($truc) { |
| 2030 | - if (!$truc) { |
|
| 2031 | - return false; |
|
| 2032 | - } |
|
| 2029 | + if (!$truc) { |
|
| 2030 | + return false; |
|
| 2031 | + } |
|
| 2033 | 2032 | |
| 2034 | - return (strtolower($truc) !== 'off'); |
|
| 2033 | + return (strtolower($truc) !== 'off'); |
|
| 2035 | 2034 | } |
| 2036 | 2035 | |
| 2037 | 2036 | // |
@@ -2059,89 +2058,89 @@ discard block |
||
| 2059 | 2058 | */ |
| 2060 | 2059 | function url_de_base($profondeur = null) { |
| 2061 | 2060 | |
| 2062 | - static $url = []; |
|
| 2063 | - if (is_array($profondeur)) { |
|
| 2064 | - return $url = $profondeur; |
|
| 2065 | - } |
|
| 2066 | - if ($profondeur === false) { |
|
| 2067 | - return $url; |
|
| 2068 | - } |
|
| 2069 | - |
|
| 2070 | - if (is_null($profondeur)) { |
|
| 2071 | - $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 2072 | - } |
|
| 2073 | - |
|
| 2074 | - if (isset($url[$profondeur])) { |
|
| 2075 | - return $url[$profondeur]; |
|
| 2076 | - } |
|
| 2077 | - |
|
| 2078 | - $http = 'http'; |
|
| 2079 | - |
|
| 2080 | - if ( |
|
| 2081 | - isset($_SERVER['SCRIPT_URI']) |
|
| 2082 | - and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 2083 | - ) { |
|
| 2084 | - $http = 'https'; |
|
| 2085 | - } elseif ( |
|
| 2086 | - isset($_SERVER['HTTPS']) |
|
| 2087 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 2088 | - ) { |
|
| 2089 | - $http = 'https'; |
|
| 2090 | - } |
|
| 2091 | - |
|
| 2092 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 2093 | - if ($host = $_SERVER['HTTP_HOST'] ?? null) { |
|
| 2094 | - // Filtrer $host pour proteger d'attaques d'entete HTTP |
|
| 2095 | - $host = (filter_var($host, FILTER_SANITIZE_URL) ?: null); |
|
| 2096 | - } |
|
| 2097 | - |
|
| 2098 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 2099 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2100 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 2101 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 2102 | - $http = $scheme; |
|
| 2103 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 2104 | - } |
|
| 2105 | - } |
|
| 2106 | - if ( |
|
| 2107 | - isset($_SERVER['SERVER_PORT']) |
|
| 2108 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 2109 | - and strpos($host, ':') == false |
|
| 2110 | - ) { |
|
| 2111 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2112 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 2113 | - } |
|
| 2114 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2115 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2116 | - } |
|
| 2117 | - if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2118 | - $host .= ":$port"; |
|
| 2119 | - } |
|
| 2120 | - if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2121 | - $host .= ":$port"; |
|
| 2122 | - } |
|
| 2123 | - } |
|
| 2124 | - |
|
| 2125 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 2126 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2127 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2128 | - } else { |
|
| 2129 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2130 | - if ( |
|
| 2131 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2132 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2133 | - ) { |
|
| 2134 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2135 | - } |
|
| 2136 | - } |
|
| 2137 | - } |
|
| 2138 | - |
|
| 2139 | - // Et nettoyer l'url |
|
| 2140 | - $GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: ''); |
|
| 2141 | - |
|
| 2142 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2143 | - |
|
| 2144 | - return $url[$profondeur]; |
|
| 2061 | + static $url = []; |
|
| 2062 | + if (is_array($profondeur)) { |
|
| 2063 | + return $url = $profondeur; |
|
| 2064 | + } |
|
| 2065 | + if ($profondeur === false) { |
|
| 2066 | + return $url; |
|
| 2067 | + } |
|
| 2068 | + |
|
| 2069 | + if (is_null($profondeur)) { |
|
| 2070 | + $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 2071 | + } |
|
| 2072 | + |
|
| 2073 | + if (isset($url[$profondeur])) { |
|
| 2074 | + return $url[$profondeur]; |
|
| 2075 | + } |
|
| 2076 | + |
|
| 2077 | + $http = 'http'; |
|
| 2078 | + |
|
| 2079 | + if ( |
|
| 2080 | + isset($_SERVER['SCRIPT_URI']) |
|
| 2081 | + and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 2082 | + ) { |
|
| 2083 | + $http = 'https'; |
|
| 2084 | + } elseif ( |
|
| 2085 | + isset($_SERVER['HTTPS']) |
|
| 2086 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 2087 | + ) { |
|
| 2088 | + $http = 'https'; |
|
| 2089 | + } |
|
| 2090 | + |
|
| 2091 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 2092 | + if ($host = $_SERVER['HTTP_HOST'] ?? null) { |
|
| 2093 | + // Filtrer $host pour proteger d'attaques d'entete HTTP |
|
| 2094 | + $host = (filter_var($host, FILTER_SANITIZE_URL) ?: null); |
|
| 2095 | + } |
|
| 2096 | + |
|
| 2097 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 2098 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2099 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 2100 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 2101 | + $http = $scheme; |
|
| 2102 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 2103 | + } |
|
| 2104 | + } |
|
| 2105 | + if ( |
|
| 2106 | + isset($_SERVER['SERVER_PORT']) |
|
| 2107 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 2108 | + and strpos($host, ':') == false |
|
| 2109 | + ) { |
|
| 2110 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2111 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 2112 | + } |
|
| 2113 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2114 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2115 | + } |
|
| 2116 | + if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2117 | + $host .= ":$port"; |
|
| 2118 | + } |
|
| 2119 | + if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2120 | + $host .= ":$port"; |
|
| 2121 | + } |
|
| 2122 | + } |
|
| 2123 | + |
|
| 2124 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 2125 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2126 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2127 | + } else { |
|
| 2128 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2129 | + if ( |
|
| 2130 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2131 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2132 | + ) { |
|
| 2133 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2134 | + } |
|
| 2135 | + } |
|
| 2136 | + } |
|
| 2137 | + |
|
| 2138 | + // Et nettoyer l'url |
|
| 2139 | + $GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: ''); |
|
| 2140 | + |
|
| 2141 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2142 | + |
|
| 2143 | + return $url[$profondeur]; |
|
| 2145 | 2144 | } |
| 2146 | 2145 | |
| 2147 | 2146 | /** |
@@ -2154,26 +2153,26 @@ discard block |
||
| 2154 | 2153 | * @return string |
| 2155 | 2154 | */ |
| 2156 | 2155 | function url_de_($http, $host, $request, $prof = 0) { |
| 2157 | - $prof = max($prof, 0); |
|
| 2156 | + $prof = max($prof, 0); |
|
| 2158 | 2157 | |
| 2159 | - $myself = ltrim($request, '/'); |
|
| 2160 | - # supprimer la chaine de GET |
|
| 2161 | - [$myself] = explode('?', $myself); |
|
| 2162 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2163 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2164 | - if (strpos($myself, '://') !== false) { |
|
| 2165 | - $myself = explode('://', $myself); |
|
| 2166 | - array_shift($myself); |
|
| 2167 | - $myself = implode('://', $myself); |
|
| 2168 | - $myself = explode('/', $myself); |
|
| 2169 | - array_shift($myself); |
|
| 2170 | - $myself = implode('/', $myself); |
|
| 2171 | - } |
|
| 2172 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2158 | + $myself = ltrim($request, '/'); |
|
| 2159 | + # supprimer la chaine de GET |
|
| 2160 | + [$myself] = explode('?', $myself); |
|
| 2161 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2162 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2163 | + if (strpos($myself, '://') !== false) { |
|
| 2164 | + $myself = explode('://', $myself); |
|
| 2165 | + array_shift($myself); |
|
| 2166 | + $myself = implode('://', $myself); |
|
| 2167 | + $myself = explode('/', $myself); |
|
| 2168 | + array_shift($myself); |
|
| 2169 | + $myself = implode('/', $myself); |
|
| 2170 | + } |
|
| 2171 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2173 | 2172 | |
| 2174 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2173 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2175 | 2174 | |
| 2176 | - return $url; |
|
| 2175 | + return $url; |
|
| 2177 | 2176 | } |
| 2178 | 2177 | |
| 2179 | 2178 | |
@@ -2208,26 +2207,26 @@ discard block |
||
| 2208 | 2207 | * @return string URL |
| 2209 | 2208 | **/ |
| 2210 | 2209 | function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) { |
| 2211 | - $script ??= ''; |
|
| 2212 | - if (!$rel) { |
|
| 2213 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2214 | - } else { |
|
| 2215 | - if (!is_string($rel)) { |
|
| 2216 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2217 | - } |
|
| 2218 | - } |
|
| 2219 | - |
|
| 2220 | - [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2221 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2222 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2223 | - } elseif ($args) { |
|
| 2224 | - $args = "?$args"; |
|
| 2225 | - } |
|
| 2226 | - if ($ancre) { |
|
| 2227 | - $args .= "#$ancre"; |
|
| 2228 | - } |
|
| 2229 | - |
|
| 2230 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2210 | + $script ??= ''; |
|
| 2211 | + if (!$rel) { |
|
| 2212 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2213 | + } else { |
|
| 2214 | + if (!is_string($rel)) { |
|
| 2215 | + $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2216 | + } |
|
| 2217 | + } |
|
| 2218 | + |
|
| 2219 | + [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2220 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2221 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2222 | + } elseif ($args) { |
|
| 2223 | + $args = "?$args"; |
|
| 2224 | + } |
|
| 2225 | + if ($ancre) { |
|
| 2226 | + $args .= "#$ancre"; |
|
| 2227 | + } |
|
| 2228 | + |
|
| 2229 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2231 | 2230 | } |
| 2232 | 2231 | |
| 2233 | 2232 | // |
@@ -2249,15 +2248,15 @@ discard block |
||
| 2249 | 2248 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2250 | 2249 | **/ |
| 2251 | 2250 | function get_spip_script($default = '') { |
| 2252 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2253 | - return 'spip.php'; |
|
| 2254 | - } |
|
| 2255 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2256 | - if (_SPIP_SCRIPT) { |
|
| 2257 | - return _SPIP_SCRIPT; |
|
| 2258 | - } else { |
|
| 2259 | - return $default; |
|
| 2260 | - } |
|
| 2251 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2252 | + return 'spip.php'; |
|
| 2253 | + } |
|
| 2254 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2255 | + if (_SPIP_SCRIPT) { |
|
| 2256 | + return _SPIP_SCRIPT; |
|
| 2257 | + } else { |
|
| 2258 | + return $default; |
|
| 2259 | + } |
|
| 2261 | 2260 | } |
| 2262 | 2261 | |
| 2263 | 2262 | /** |
@@ -2286,45 +2285,45 @@ discard block |
||
| 2286 | 2285 | * @return string URL |
| 2287 | 2286 | **/ |
| 2288 | 2287 | function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') { |
| 2289 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2290 | - // standardiser vers la nouvelle API |
|
| 2291 | - |
|
| 2292 | - if (is_array($args)) { |
|
| 2293 | - $args = http_build_query($args); |
|
| 2294 | - } |
|
| 2295 | - |
|
| 2296 | - $url = ''; |
|
| 2297 | - if ($f = charger_fonction_url('page')) { |
|
| 2298 | - $url = $f($script, $args); |
|
| 2299 | - if ($url and !$rel) { |
|
| 2300 | - include_spip('inc/filtres_mini'); |
|
| 2301 | - $url = url_absolue($url); |
|
| 2302 | - } |
|
| 2303 | - } |
|
| 2304 | - if (!$url) { |
|
| 2305 | - if (!$action) { |
|
| 2306 | - $action = get_spip_script(); |
|
| 2307 | - } |
|
| 2308 | - if ($script) { |
|
| 2309 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2310 | - } |
|
| 2311 | - if ($args) { |
|
| 2312 | - $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2313 | - } |
|
| 2314 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2315 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2316 | - } |
|
| 2317 | - |
|
| 2318 | - if (!$no_entities) { |
|
| 2319 | - $url = quote_amp($url); |
|
| 2320 | - } |
|
| 2321 | - |
|
| 2322 | - return $url; |
|
| 2288 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2289 | + // standardiser vers la nouvelle API |
|
| 2290 | + |
|
| 2291 | + if (is_array($args)) { |
|
| 2292 | + $args = http_build_query($args); |
|
| 2293 | + } |
|
| 2294 | + |
|
| 2295 | + $url = ''; |
|
| 2296 | + if ($f = charger_fonction_url('page')) { |
|
| 2297 | + $url = $f($script, $args); |
|
| 2298 | + if ($url and !$rel) { |
|
| 2299 | + include_spip('inc/filtres_mini'); |
|
| 2300 | + $url = url_absolue($url); |
|
| 2301 | + } |
|
| 2302 | + } |
|
| 2303 | + if (!$url) { |
|
| 2304 | + if (!$action) { |
|
| 2305 | + $action = get_spip_script(); |
|
| 2306 | + } |
|
| 2307 | + if ($script) { |
|
| 2308 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2309 | + } |
|
| 2310 | + if ($args) { |
|
| 2311 | + $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2312 | + } |
|
| 2313 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2314 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2315 | + } |
|
| 2316 | + |
|
| 2317 | + if (!$no_entities) { |
|
| 2318 | + $url = quote_amp($url); |
|
| 2319 | + } |
|
| 2320 | + |
|
| 2321 | + return $url; |
|
| 2323 | 2322 | } |
| 2324 | 2323 | |
| 2325 | 2324 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2326 | 2325 | |
| 2327 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2326 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2328 | 2327 | } |
| 2329 | 2328 | |
| 2330 | 2329 | // Pour les formulaires en methode POST, |
@@ -2349,19 +2348,19 @@ discard block |
||
| 2349 | 2348 | **/ |
| 2350 | 2349 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2351 | 2350 | |
| 2352 | - $script1 = explode('&', $script); |
|
| 2353 | - $script1 = reset($script1); |
|
| 2351 | + $script1 = explode('&', $script); |
|
| 2352 | + $script1 = reset($script1); |
|
| 2354 | 2353 | |
| 2355 | - return "<form action='" |
|
| 2356 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2357 | - . "' " |
|
| 2358 | - . ($atts ?: " method='post'") |
|
| 2359 | - . "><div>\n" |
|
| 2360 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2361 | - . $corps |
|
| 2362 | - . (!$submit ? '' : |
|
| 2363 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2364 | - . "</div></form>\n"; |
|
| 2354 | + return "<form action='" |
|
| 2355 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2356 | + . "' " |
|
| 2357 | + . ($atts ?: " method='post'") |
|
| 2358 | + . "><div>\n" |
|
| 2359 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2360 | + . $corps |
|
| 2361 | + . (!$submit ? '' : |
|
| 2362 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2363 | + . "</div></form>\n"; |
|
| 2365 | 2364 | } |
| 2366 | 2365 | |
| 2367 | 2366 | /** |
@@ -2378,22 +2377,22 @@ discard block |
||
| 2378 | 2377 | * @return string |
| 2379 | 2378 | */ |
| 2380 | 2379 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2381 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2382 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2383 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2384 | - $h = (_DIR_RACINE and !$public) |
|
| 2385 | - ? generer_url_ecrire(_request('exec')) |
|
| 2386 | - : generer_url_public(); |
|
| 2380 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2381 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2382 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2383 | + $h = (_DIR_RACINE and !$public) |
|
| 2384 | + ? generer_url_ecrire(_request('exec')) |
|
| 2385 | + : generer_url_public(); |
|
| 2387 | 2386 | |
| 2388 | - return "\n<form action='" . |
|
| 2389 | - $h . |
|
| 2390 | - "'" . |
|
| 2391 | - $atts . |
|
| 2392 | - ">\n" . |
|
| 2393 | - '<div>' . |
|
| 2394 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2395 | - $corps . |
|
| 2396 | - '</div></form>'; |
|
| 2387 | + return "\n<form action='" . |
|
| 2388 | + $h . |
|
| 2389 | + "'" . |
|
| 2390 | + $atts . |
|
| 2391 | + ">\n" . |
|
| 2392 | + '<div>' . |
|
| 2393 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2394 | + $corps . |
|
| 2395 | + '</div></form>'; |
|
| 2397 | 2396 | } |
| 2398 | 2397 | |
| 2399 | 2398 | /** |
@@ -2412,22 +2411,22 @@ discard block |
||
| 2412 | 2411 | * URL |
| 2413 | 2412 | */ |
| 2414 | 2413 | function generer_url_action($script, $args = '', $no_entities = false, $public = false) { |
| 2415 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2416 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2417 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2418 | - $url = (_DIR_RACINE and !$public) |
|
| 2419 | - ? generer_url_ecrire(_request('exec')) |
|
| 2420 | - : generer_url_public('', '', false, false); |
|
| 2421 | - $url = parametre_url($url, 'action', $script); |
|
| 2422 | - if ($args) { |
|
| 2423 | - $url .= quote_amp('&' . $args); |
|
| 2424 | - } |
|
| 2414 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2415 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2416 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2417 | + $url = (_DIR_RACINE and !$public) |
|
| 2418 | + ? generer_url_ecrire(_request('exec')) |
|
| 2419 | + : generer_url_public('', '', false, false); |
|
| 2420 | + $url = parametre_url($url, 'action', $script); |
|
| 2421 | + if ($args) { |
|
| 2422 | + $url .= quote_amp('&' . $args); |
|
| 2423 | + } |
|
| 2425 | 2424 | |
| 2426 | - if ($no_entities) { |
|
| 2427 | - $url = str_replace('&', '&', $url); |
|
| 2428 | - } |
|
| 2425 | + if ($no_entities) { |
|
| 2426 | + $url = str_replace('&', '&', $url); |
|
| 2427 | + } |
|
| 2429 | 2428 | |
| 2430 | - return $url; |
|
| 2429 | + return $url; |
|
| 2431 | 2430 | } |
| 2432 | 2431 | |
| 2433 | 2432 | |
@@ -2446,23 +2445,23 @@ discard block |
||
| 2446 | 2445 | * URL |
| 2447 | 2446 | */ |
| 2448 | 2447 | function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) { |
| 2449 | - if (is_null($public)) { |
|
| 2450 | - $public = (_DIR_RACINE ? false : ''); |
|
| 2451 | - } |
|
| 2452 | - if (substr($script, -4) !== '.api') { |
|
| 2453 | - $script .= '.api'; |
|
| 2454 | - } |
|
| 2455 | - $url = |
|
| 2456 | - (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
|
| 2457 | - . $script . '/' |
|
| 2458 | - . ($path ? trim($path, '/') : '') |
|
| 2459 | - . ($args ? '?' . quote_amp($args) : ''); |
|
| 2448 | + if (is_null($public)) { |
|
| 2449 | + $public = (_DIR_RACINE ? false : ''); |
|
| 2450 | + } |
|
| 2451 | + if (substr($script, -4) !== '.api') { |
|
| 2452 | + $script .= '.api'; |
|
| 2453 | + } |
|
| 2454 | + $url = |
|
| 2455 | + (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
|
| 2456 | + . $script . '/' |
|
| 2457 | + . ($path ? trim($path, '/') : '') |
|
| 2458 | + . ($args ? '?' . quote_amp($args) : ''); |
|
| 2460 | 2459 | |
| 2461 | - if ($no_entities) { |
|
| 2462 | - $url = str_replace('&', '&', $url); |
|
| 2463 | - } |
|
| 2460 | + if ($no_entities) { |
|
| 2461 | + $url = str_replace('&', '&', $url); |
|
| 2462 | + } |
|
| 2464 | 2463 | |
| 2465 | - return $url; |
|
| 2464 | + return $url; |
|
| 2466 | 2465 | } |
| 2467 | 2466 | |
| 2468 | 2467 | |
@@ -2475,8 +2474,8 @@ discard block |
||
| 2475 | 2474 | * @param string $ta Répertoire temporaire accessible |
| 2476 | 2475 | */ |
| 2477 | 2476 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2478 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2479 | - spip_initialisation_suite(); |
|
| 2477 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2478 | + spip_initialisation_suite(); |
|
| 2480 | 2479 | } |
| 2481 | 2480 | |
| 2482 | 2481 | /** |
@@ -2496,315 +2495,315 @@ discard block |
||
| 2496 | 2495 | * @param string $ta Répertoire temporaire accessible |
| 2497 | 2496 | */ |
| 2498 | 2497 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2499 | - static $too_late = 0; |
|
| 2500 | - if ($too_late++) { |
|
| 2501 | - return; |
|
| 2502 | - } |
|
| 2503 | - |
|
| 2504 | - // Declaration des repertoires |
|
| 2505 | - |
|
| 2506 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2507 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2508 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2509 | - } |
|
| 2510 | - |
|
| 2511 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2512 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2513 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2514 | - } |
|
| 2515 | - |
|
| 2516 | - // le nom du repertoire des librairies |
|
| 2517 | - if (!defined('_DIR_LIB')) { |
|
| 2518 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2519 | - } |
|
| 2520 | - |
|
| 2521 | - // répertoire des libs via Composer |
|
| 2522 | - if (!defined('_DIR_VENDOR')) { |
|
| 2523 | - define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 2524 | - } |
|
| 2525 | - |
|
| 2526 | - if (!defined('_DIR_IMG')) { |
|
| 2527 | - define('_DIR_IMG', $pa); |
|
| 2528 | - } |
|
| 2529 | - if (!defined('_DIR_LOGOS')) { |
|
| 2530 | - define('_DIR_LOGOS', $pa); |
|
| 2531 | - } |
|
| 2532 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2533 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2534 | - } |
|
| 2535 | - |
|
| 2536 | - if (!defined('_DIR_DUMP')) { |
|
| 2537 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2538 | - } |
|
| 2539 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2540 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2541 | - } |
|
| 2542 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2543 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2544 | - } |
|
| 2545 | - if (!defined('_DIR_CACHE')) { |
|
| 2546 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2547 | - } |
|
| 2548 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2549 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2550 | - } |
|
| 2551 | - if (!defined('_DIR_SKELS')) { |
|
| 2552 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2553 | - } |
|
| 2554 | - if (!defined('_DIR_AIDE')) { |
|
| 2555 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2556 | - } |
|
| 2557 | - if (!defined('_DIR_TMP')) { |
|
| 2558 | - define('_DIR_TMP', $ti); |
|
| 2559 | - } |
|
| 2560 | - |
|
| 2561 | - if (!defined('_DIR_VAR')) { |
|
| 2562 | - define('_DIR_VAR', $ta); |
|
| 2563 | - } |
|
| 2564 | - |
|
| 2565 | - if (!defined('_DIR_ETC')) { |
|
| 2566 | - define('_DIR_ETC', $pi); |
|
| 2567 | - } |
|
| 2568 | - if (!defined('_DIR_CONNECT')) { |
|
| 2569 | - define('_DIR_CONNECT', $pi); |
|
| 2570 | - } |
|
| 2571 | - if (!defined('_DIR_CHMOD')) { |
|
| 2572 | - define('_DIR_CHMOD', $pi); |
|
| 2573 | - } |
|
| 2574 | - |
|
| 2575 | - if (!isset($GLOBALS['test_dirs'])) { |
|
| 2576 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2577 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2578 | - $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2579 | - } |
|
| 2580 | - |
|
| 2581 | - // Declaration des fichiers |
|
| 2582 | - |
|
| 2583 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2584 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2585 | - } |
|
| 2586 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2587 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2588 | - } |
|
| 2589 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2590 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2591 | - } |
|
| 2592 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2593 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2594 | - } |
|
| 2595 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2596 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2597 | - } |
|
| 2598 | - |
|
| 2599 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2600 | - if (!defined('_FILE_META')) { |
|
| 2601 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2602 | - } |
|
| 2603 | - if (!defined('_DIR_LOG')) { |
|
| 2604 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2605 | - } |
|
| 2606 | - if (!defined('_FILE_LOG')) { |
|
| 2607 | - define('_FILE_LOG', 'spip'); |
|
| 2608 | - } |
|
| 2609 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2610 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2611 | - } |
|
| 2612 | - |
|
| 2613 | - // Le fichier de connexion a la base de donnees |
|
| 2614 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2615 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2616 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2617 | - } |
|
| 2618 | - if (!defined('_FILE_CONNECT')) { |
|
| 2619 | - define( |
|
| 2620 | - '_FILE_CONNECT', |
|
| 2621 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2622 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2623 | - : false)) |
|
| 2624 | - ); |
|
| 2625 | - } |
|
| 2626 | - |
|
| 2627 | - // Le fichier de reglages des droits |
|
| 2628 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2629 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2630 | - } |
|
| 2631 | - if (!defined('_FILE_CHMOD')) { |
|
| 2632 | - define( |
|
| 2633 | - '_FILE_CHMOD', |
|
| 2634 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2635 | - : false) |
|
| 2636 | - ); |
|
| 2637 | - } |
|
| 2638 | - |
|
| 2639 | - if (!defined('_FILE_LDAP')) { |
|
| 2640 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2641 | - } |
|
| 2642 | - |
|
| 2643 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2644 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2645 | - } |
|
| 2646 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2647 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2648 | - } |
|
| 2649 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2650 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2651 | - } |
|
| 2652 | - |
|
| 2653 | - // Definition des droits d'acces en ecriture |
|
| 2654 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2655 | - include_once _FILE_CHMOD; |
|
| 2656 | - } |
|
| 2657 | - |
|
| 2658 | - // Se mefier des fichiers mal remplis! |
|
| 2659 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2660 | - define('_SPIP_CHMOD', 0777); |
|
| 2661 | - } |
|
| 2662 | - |
|
| 2663 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2664 | - /** Le charset par défaut lors de l'installation */ |
|
| 2665 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2666 | - } |
|
| 2667 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2668 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2669 | - } |
|
| 2670 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2671 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2672 | - } |
|
| 2673 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2674 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2675 | - } |
|
| 2676 | - |
|
| 2677 | - // La taille des Log |
|
| 2678 | - if (!defined('_MAX_LOG')) { |
|
| 2679 | - define('_MAX_LOG', 100); |
|
| 2680 | - } |
|
| 2681 | - |
|
| 2682 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2683 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2684 | - if (isset($_SERVER['SERVER_SOFTWARE']) and str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) { |
|
| 2685 | - if (!defined('_OS_SERVEUR')) { |
|
| 2686 | - define('_OS_SERVEUR', 'windows'); |
|
| 2687 | - } |
|
| 2688 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2689 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2690 | - } // utiliser le flock php |
|
| 2691 | - } else { |
|
| 2692 | - if (!defined('_OS_SERVEUR')) { |
|
| 2693 | - define('_OS_SERVEUR', ''); |
|
| 2694 | - } |
|
| 2695 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2696 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2697 | - } // utiliser le flock php |
|
| 2698 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2699 | - } |
|
| 2700 | - |
|
| 2701 | - // Langue par defaut |
|
| 2702 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2703 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2704 | - } |
|
| 2705 | - |
|
| 2706 | - // |
|
| 2707 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2708 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2709 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2710 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2711 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2712 | - |
|
| 2713 | - // charger tout de suite le path et son cache |
|
| 2714 | - load_path_cache(); |
|
| 2715 | - |
|
| 2716 | - // *********** traiter les variables ************ |
|
| 2717 | - |
|
| 2718 | - // |
|
| 2719 | - // Securite |
|
| 2720 | - // |
|
| 2721 | - |
|
| 2722 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2723 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2724 | - die(); |
|
| 2725 | - } |
|
| 2726 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2727 | - spip_desinfecte($_GET); |
|
| 2728 | - spip_desinfecte($_POST); |
|
| 2729 | - spip_desinfecte($_COOKIE); |
|
| 2730 | - spip_desinfecte($_REQUEST); |
|
| 2731 | - |
|
| 2732 | - // appliquer le cookie_prefix |
|
| 2733 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2734 | - include_spip('inc/cookie'); |
|
| 2735 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2736 | - } |
|
| 2737 | - |
|
| 2738 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2739 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2740 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2741 | - } else { |
|
| 2742 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2743 | - if ( |
|
| 2744 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2745 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2746 | - ) { |
|
| 2747 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2748 | - } |
|
| 2749 | - } |
|
| 2750 | - |
|
| 2751 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2752 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2753 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2754 | - } |
|
| 2755 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2756 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2757 | - } |
|
| 2758 | - |
|
| 2759 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2760 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2761 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2762 | - $inc_meta(); |
|
| 2763 | - |
|
| 2764 | - // nombre de repertoires depuis la racine |
|
| 2765 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2766 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2767 | - // le calcul est faux) |
|
| 2768 | - if (!_DIR_RESTREINT) { |
|
| 2769 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2770 | - } else { |
|
| 2771 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2772 | - $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2773 | - if ( |
|
| 2774 | - !$uri_ref |
|
| 2775 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2776 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2777 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2778 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2779 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2780 | - ) { |
|
| 2781 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2782 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2783 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2784 | - } else { |
|
| 2785 | - $uri_ref = ''; |
|
| 2786 | - } |
|
| 2787 | - } |
|
| 2788 | - if (!$uri or !$uri_ref) { |
|
| 2789 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2790 | - } else { |
|
| 2791 | - $GLOBALS['profondeur_url'] = max( |
|
| 2792 | - 0, |
|
| 2793 | - substr_count($uri[0], '/') |
|
| 2794 | - - substr_count($uri_ref, '/') |
|
| 2795 | - ); |
|
| 2796 | - } |
|
| 2797 | - } |
|
| 2798 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2799 | - if (_FILE_CONNECT) { |
|
| 2800 | - if ( |
|
| 2801 | - verifier_visiteur() == '0minirezo' |
|
| 2802 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2803 | - and !isset($_COOKIE['spip_admin']) |
|
| 2804 | - ) { |
|
| 2805 | - clear_path_cache(); |
|
| 2806 | - } |
|
| 2807 | - } |
|
| 2498 | + static $too_late = 0; |
|
| 2499 | + if ($too_late++) { |
|
| 2500 | + return; |
|
| 2501 | + } |
|
| 2502 | + |
|
| 2503 | + // Declaration des repertoires |
|
| 2504 | + |
|
| 2505 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2506 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2507 | + define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2508 | + } |
|
| 2509 | + |
|
| 2510 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2511 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2512 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2513 | + } |
|
| 2514 | + |
|
| 2515 | + // le nom du repertoire des librairies |
|
| 2516 | + if (!defined('_DIR_LIB')) { |
|
| 2517 | + define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2518 | + } |
|
| 2519 | + |
|
| 2520 | + // répertoire des libs via Composer |
|
| 2521 | + if (!defined('_DIR_VENDOR')) { |
|
| 2522 | + define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 2523 | + } |
|
| 2524 | + |
|
| 2525 | + if (!defined('_DIR_IMG')) { |
|
| 2526 | + define('_DIR_IMG', $pa); |
|
| 2527 | + } |
|
| 2528 | + if (!defined('_DIR_LOGOS')) { |
|
| 2529 | + define('_DIR_LOGOS', $pa); |
|
| 2530 | + } |
|
| 2531 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2532 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2533 | + } |
|
| 2534 | + |
|
| 2535 | + if (!defined('_DIR_DUMP')) { |
|
| 2536 | + define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2537 | + } |
|
| 2538 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2539 | + define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2540 | + } |
|
| 2541 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2542 | + define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2543 | + } |
|
| 2544 | + if (!defined('_DIR_CACHE')) { |
|
| 2545 | + define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2546 | + } |
|
| 2547 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2548 | + define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2549 | + } |
|
| 2550 | + if (!defined('_DIR_SKELS')) { |
|
| 2551 | + define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2552 | + } |
|
| 2553 | + if (!defined('_DIR_AIDE')) { |
|
| 2554 | + define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2555 | + } |
|
| 2556 | + if (!defined('_DIR_TMP')) { |
|
| 2557 | + define('_DIR_TMP', $ti); |
|
| 2558 | + } |
|
| 2559 | + |
|
| 2560 | + if (!defined('_DIR_VAR')) { |
|
| 2561 | + define('_DIR_VAR', $ta); |
|
| 2562 | + } |
|
| 2563 | + |
|
| 2564 | + if (!defined('_DIR_ETC')) { |
|
| 2565 | + define('_DIR_ETC', $pi); |
|
| 2566 | + } |
|
| 2567 | + if (!defined('_DIR_CONNECT')) { |
|
| 2568 | + define('_DIR_CONNECT', $pi); |
|
| 2569 | + } |
|
| 2570 | + if (!defined('_DIR_CHMOD')) { |
|
| 2571 | + define('_DIR_CHMOD', $pi); |
|
| 2572 | + } |
|
| 2573 | + |
|
| 2574 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 2575 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2576 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2577 | + $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2578 | + } |
|
| 2579 | + |
|
| 2580 | + // Declaration des fichiers |
|
| 2581 | + |
|
| 2582 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2583 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2584 | + } |
|
| 2585 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2586 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2587 | + } |
|
| 2588 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2589 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2590 | + } |
|
| 2591 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2592 | + define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2593 | + } |
|
| 2594 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2595 | + define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2596 | + } |
|
| 2597 | + |
|
| 2598 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2599 | + if (!defined('_FILE_META')) { |
|
| 2600 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2601 | + } |
|
| 2602 | + if (!defined('_DIR_LOG')) { |
|
| 2603 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2604 | + } |
|
| 2605 | + if (!defined('_FILE_LOG')) { |
|
| 2606 | + define('_FILE_LOG', 'spip'); |
|
| 2607 | + } |
|
| 2608 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2609 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2610 | + } |
|
| 2611 | + |
|
| 2612 | + // Le fichier de connexion a la base de donnees |
|
| 2613 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2614 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2615 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2616 | + } |
|
| 2617 | + if (!defined('_FILE_CONNECT')) { |
|
| 2618 | + define( |
|
| 2619 | + '_FILE_CONNECT', |
|
| 2620 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2621 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2622 | + : false)) |
|
| 2623 | + ); |
|
| 2624 | + } |
|
| 2625 | + |
|
| 2626 | + // Le fichier de reglages des droits |
|
| 2627 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2628 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2629 | + } |
|
| 2630 | + if (!defined('_FILE_CHMOD')) { |
|
| 2631 | + define( |
|
| 2632 | + '_FILE_CHMOD', |
|
| 2633 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2634 | + : false) |
|
| 2635 | + ); |
|
| 2636 | + } |
|
| 2637 | + |
|
| 2638 | + if (!defined('_FILE_LDAP')) { |
|
| 2639 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2640 | + } |
|
| 2641 | + |
|
| 2642 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2643 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2644 | + } |
|
| 2645 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2646 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2647 | + } |
|
| 2648 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2649 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2650 | + } |
|
| 2651 | + |
|
| 2652 | + // Definition des droits d'acces en ecriture |
|
| 2653 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2654 | + include_once _FILE_CHMOD; |
|
| 2655 | + } |
|
| 2656 | + |
|
| 2657 | + // Se mefier des fichiers mal remplis! |
|
| 2658 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2659 | + define('_SPIP_CHMOD', 0777); |
|
| 2660 | + } |
|
| 2661 | + |
|
| 2662 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2663 | + /** Le charset par défaut lors de l'installation */ |
|
| 2664 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2665 | + } |
|
| 2666 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2667 | + define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2668 | + } |
|
| 2669 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2670 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2671 | + } |
|
| 2672 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2673 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2674 | + } |
|
| 2675 | + |
|
| 2676 | + // La taille des Log |
|
| 2677 | + if (!defined('_MAX_LOG')) { |
|
| 2678 | + define('_MAX_LOG', 100); |
|
| 2679 | + } |
|
| 2680 | + |
|
| 2681 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2682 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2683 | + if (isset($_SERVER['SERVER_SOFTWARE']) and str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) { |
|
| 2684 | + if (!defined('_OS_SERVEUR')) { |
|
| 2685 | + define('_OS_SERVEUR', 'windows'); |
|
| 2686 | + } |
|
| 2687 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2688 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2689 | + } // utiliser le flock php |
|
| 2690 | + } else { |
|
| 2691 | + if (!defined('_OS_SERVEUR')) { |
|
| 2692 | + define('_OS_SERVEUR', ''); |
|
| 2693 | + } |
|
| 2694 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2695 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2696 | + } // utiliser le flock php |
|
| 2697 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2698 | + } |
|
| 2699 | + |
|
| 2700 | + // Langue par defaut |
|
| 2701 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2702 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2703 | + } |
|
| 2704 | + |
|
| 2705 | + // |
|
| 2706 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2707 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2708 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2709 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2710 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2711 | + |
|
| 2712 | + // charger tout de suite le path et son cache |
|
| 2713 | + load_path_cache(); |
|
| 2714 | + |
|
| 2715 | + // *********** traiter les variables ************ |
|
| 2716 | + |
|
| 2717 | + // |
|
| 2718 | + // Securite |
|
| 2719 | + // |
|
| 2720 | + |
|
| 2721 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2722 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2723 | + die(); |
|
| 2724 | + } |
|
| 2725 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2726 | + spip_desinfecte($_GET); |
|
| 2727 | + spip_desinfecte($_POST); |
|
| 2728 | + spip_desinfecte($_COOKIE); |
|
| 2729 | + spip_desinfecte($_REQUEST); |
|
| 2730 | + |
|
| 2731 | + // appliquer le cookie_prefix |
|
| 2732 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2733 | + include_spip('inc/cookie'); |
|
| 2734 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2735 | + } |
|
| 2736 | + |
|
| 2737 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2738 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2739 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2740 | + } else { |
|
| 2741 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2742 | + if ( |
|
| 2743 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2744 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2745 | + ) { |
|
| 2746 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2747 | + } |
|
| 2748 | + } |
|
| 2749 | + |
|
| 2750 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2751 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2752 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2753 | + } |
|
| 2754 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2755 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2756 | + } |
|
| 2757 | + |
|
| 2758 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2759 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2760 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2761 | + $inc_meta(); |
|
| 2762 | + |
|
| 2763 | + // nombre de repertoires depuis la racine |
|
| 2764 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2765 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2766 | + // le calcul est faux) |
|
| 2767 | + if (!_DIR_RESTREINT) { |
|
| 2768 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2769 | + } else { |
|
| 2770 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2771 | + $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2772 | + if ( |
|
| 2773 | + !$uri_ref |
|
| 2774 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2775 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2776 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2777 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2778 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2779 | + ) { |
|
| 2780 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2781 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2782 | + $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2783 | + } else { |
|
| 2784 | + $uri_ref = ''; |
|
| 2785 | + } |
|
| 2786 | + } |
|
| 2787 | + if (!$uri or !$uri_ref) { |
|
| 2788 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2789 | + } else { |
|
| 2790 | + $GLOBALS['profondeur_url'] = max( |
|
| 2791 | + 0, |
|
| 2792 | + substr_count($uri[0], '/') |
|
| 2793 | + - substr_count($uri_ref, '/') |
|
| 2794 | + ); |
|
| 2795 | + } |
|
| 2796 | + } |
|
| 2797 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2798 | + if (_FILE_CONNECT) { |
|
| 2799 | + if ( |
|
| 2800 | + verifier_visiteur() == '0minirezo' |
|
| 2801 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2802 | + and !isset($_COOKIE['spip_admin']) |
|
| 2803 | + ) { |
|
| 2804 | + clear_path_cache(); |
|
| 2805 | + } |
|
| 2806 | + } |
|
| 2808 | 2807 | } |
| 2809 | 2808 | |
| 2810 | 2809 | /** |
@@ -2813,157 +2812,157 @@ discard block |
||
| 2813 | 2812 | * |
| 2814 | 2813 | */ |
| 2815 | 2814 | function spip_initialisation_suite() { |
| 2816 | - static $too_late = 0; |
|
| 2817 | - if ($too_late++) { |
|
| 2818 | - return; |
|
| 2819 | - } |
|
| 2820 | - |
|
| 2821 | - // taille mini des login |
|
| 2822 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2823 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2824 | - } |
|
| 2825 | - |
|
| 2826 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2827 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2828 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2829 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2830 | - |
|
| 2831 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2832 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2833 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2834 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2835 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2836 | - |
|
| 2837 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2838 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2839 | - } |
|
| 2840 | - |
|
| 2841 | - // largeur maximale des images dans l'administration |
|
| 2842 | - if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2843 | - define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2844 | - } |
|
| 2845 | - |
|
| 2846 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2847 | - if (!defined('_IMG_QUALITE')) { |
|
| 2848 | - define('_IMG_QUALITE', 85); |
|
| 2849 | - } # valeur par defaut |
|
| 2850 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2851 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2852 | - } # surcharge pour la lib GD |
|
| 2853 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2854 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2855 | - } # surcharge pour imagick en ligne de commande |
|
| 2856 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2857 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2858 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2859 | - } # surcharge pour imagick en PHP |
|
| 2860 | - |
|
| 2861 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2862 | - define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2863 | - } // poids en octet |
|
| 2864 | - |
|
| 2865 | - // qq chaines standard |
|
| 2866 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2867 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2868 | - } |
|
| 2869 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2870 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2871 | - } |
|
| 2872 | - if (!defined('_SPIP_DUMP')) { |
|
| 2873 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2874 | - } |
|
| 2875 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2876 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2877 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2878 | - } |
|
| 2879 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2880 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2881 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2882 | - } |
|
| 2883 | - |
|
| 2884 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2885 | - /** |
|
| 2886 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2887 | - * @var int Nombre de caractères */ |
|
| 2888 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2889 | - } |
|
| 2890 | - |
|
| 2891 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2892 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2893 | - } |
|
| 2894 | - |
|
| 2895 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2896 | - /** Définit le doctype de l’espace privé */ |
|
| 2897 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2898 | - } |
|
| 2899 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2900 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2901 | - define( |
|
| 2902 | - '_DOCTYPE_AIDE', |
|
| 2903 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2904 | - ); |
|
| 2905 | - } |
|
| 2906 | - |
|
| 2907 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2908 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2909 | - * le script de l'espace public, alias index.php */ |
|
| 2910 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2911 | - } |
|
| 2912 | - if (!defined('_SPIP_PAGE')) { |
|
| 2913 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2914 | - define('_SPIP_PAGE', 'page'); |
|
| 2915 | - } |
|
| 2916 | - |
|
| 2917 | - // le script de l'espace prive |
|
| 2918 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2919 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2920 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2921 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2922 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2923 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2924 | - } else { |
|
| 2925 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2926 | - } |
|
| 2927 | - } |
|
| 2928 | - |
|
| 2929 | - |
|
| 2930 | - if (!defined('_SPIP_AJAX')) { |
|
| 2931 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2932 | - ? 1 |
|
| 2933 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2934 | - } |
|
| 2935 | - |
|
| 2936 | - // La requete est-elle en ajax ? |
|
| 2937 | - if (!defined('_AJAX')) { |
|
| 2938 | - define( |
|
| 2939 | - '_AJAX', |
|
| 2940 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2941 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2942 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2943 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2944 | - ) |
|
| 2945 | - 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 |
|
| 2946 | - ); |
|
| 2947 | - } |
|
| 2948 | - |
|
| 2949 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2950 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2951 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2952 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2953 | - define( |
|
| 2954 | - '_IMG_GD_MAX_PIXELS', |
|
| 2955 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2956 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2957 | - : 0 |
|
| 2958 | - ); |
|
| 2959 | - } |
|
| 2960 | - |
|
| 2961 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2962 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2963 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2964 | - } |
|
| 2965 | - |
|
| 2966 | - init_var_mode(); |
|
| 2815 | + static $too_late = 0; |
|
| 2816 | + if ($too_late++) { |
|
| 2817 | + return; |
|
| 2818 | + } |
|
| 2819 | + |
|
| 2820 | + // taille mini des login |
|
| 2821 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2822 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2823 | + } |
|
| 2824 | + |
|
| 2825 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2826 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2827 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2828 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2829 | + |
|
| 2830 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2831 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2832 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2833 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2834 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2835 | + |
|
| 2836 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2837 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2838 | + } |
|
| 2839 | + |
|
| 2840 | + // largeur maximale des images dans l'administration |
|
| 2841 | + if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2842 | + define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2843 | + } |
|
| 2844 | + |
|
| 2845 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2846 | + if (!defined('_IMG_QUALITE')) { |
|
| 2847 | + define('_IMG_QUALITE', 85); |
|
| 2848 | + } # valeur par defaut |
|
| 2849 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2850 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2851 | + } # surcharge pour la lib GD |
|
| 2852 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2853 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2854 | + } # surcharge pour imagick en ligne de commande |
|
| 2855 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2856 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2857 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2858 | + } # surcharge pour imagick en PHP |
|
| 2859 | + |
|
| 2860 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2861 | + define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2862 | + } // poids en octet |
|
| 2863 | + |
|
| 2864 | + // qq chaines standard |
|
| 2865 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2866 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2867 | + } |
|
| 2868 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2869 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2870 | + } |
|
| 2871 | + if (!defined('_SPIP_DUMP')) { |
|
| 2872 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2873 | + } |
|
| 2874 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2875 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2876 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2877 | + } |
|
| 2878 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2879 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2880 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2881 | + } |
|
| 2882 | + |
|
| 2883 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2884 | + /** |
|
| 2885 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2886 | + * @var int Nombre de caractères */ |
|
| 2887 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2888 | + } |
|
| 2889 | + |
|
| 2890 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2891 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2892 | + } |
|
| 2893 | + |
|
| 2894 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2895 | + /** Définit le doctype de l’espace privé */ |
|
| 2896 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2897 | + } |
|
| 2898 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2899 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2900 | + define( |
|
| 2901 | + '_DOCTYPE_AIDE', |
|
| 2902 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2903 | + ); |
|
| 2904 | + } |
|
| 2905 | + |
|
| 2906 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2907 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2908 | + * le script de l'espace public, alias index.php */ |
|
| 2909 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2910 | + } |
|
| 2911 | + if (!defined('_SPIP_PAGE')) { |
|
| 2912 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2913 | + define('_SPIP_PAGE', 'page'); |
|
| 2914 | + } |
|
| 2915 | + |
|
| 2916 | + // le script de l'espace prive |
|
| 2917 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2918 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2919 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2920 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2921 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2922 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2923 | + } else { |
|
| 2924 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2925 | + } |
|
| 2926 | + } |
|
| 2927 | + |
|
| 2928 | + |
|
| 2929 | + if (!defined('_SPIP_AJAX')) { |
|
| 2930 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2931 | + ? 1 |
|
| 2932 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2933 | + } |
|
| 2934 | + |
|
| 2935 | + // La requete est-elle en ajax ? |
|
| 2936 | + if (!defined('_AJAX')) { |
|
| 2937 | + define( |
|
| 2938 | + '_AJAX', |
|
| 2939 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2940 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2941 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2942 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2943 | + ) |
|
| 2944 | + 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 |
|
| 2945 | + ); |
|
| 2946 | + } |
|
| 2947 | + |
|
| 2948 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2949 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2950 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2951 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2952 | + define( |
|
| 2953 | + '_IMG_GD_MAX_PIXELS', |
|
| 2954 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2955 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2956 | + : 0 |
|
| 2957 | + ); |
|
| 2958 | + } |
|
| 2959 | + |
|
| 2960 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2961 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2962 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2963 | + } |
|
| 2964 | + |
|
| 2965 | + init_var_mode(); |
|
| 2967 | 2966 | } |
| 2968 | 2967 | |
| 2969 | 2968 | /** |
@@ -2997,136 +2996,136 @@ discard block |
||
| 2997 | 2996 | * ` var_mode` (calcul ou recalcul). |
| 2998 | 2997 | */ |
| 2999 | 2998 | function init_var_mode() { |
| 3000 | - static $done = false; |
|
| 3001 | - if (!$done) { |
|
| 3002 | - if (isset($_GET['var_mode'])) { |
|
| 3003 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 3004 | - // tout le monde peut calcul/recalcul |
|
| 3005 | - if (!defined('_VAR_MODE')) { |
|
| 3006 | - if (in_array('recalcul', $var_mode)) { |
|
| 3007 | - define('_VAR_MODE', 'recalcul'); |
|
| 3008 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 3009 | - define('_VAR_MODE', 'calcul'); |
|
| 3010 | - } |
|
| 3011 | - } |
|
| 3012 | - $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 3013 | - if ($var_mode) { |
|
| 3014 | - include_spip('inc/autoriser'); |
|
| 3015 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 3016 | - if ( |
|
| 3017 | - autoriser( |
|
| 3018 | - ($_GET['var_mode'] == 'preview') |
|
| 3019 | - ? 'previsualiser' |
|
| 3020 | - : 'debug' |
|
| 3021 | - ) |
|
| 3022 | - ) { |
|
| 3023 | - if (in_array('traduction', $var_mode)) { |
|
| 3024 | - // forcer le calcul pour passer dans traduire |
|
| 3025 | - if (!defined('_VAR_MODE')) { |
|
| 3026 | - define('_VAR_MODE', 'calcul'); |
|
| 3027 | - } |
|
| 3028 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 3029 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3030 | - define('_VAR_NOCACHE', true); |
|
| 3031 | - } |
|
| 3032 | - $var_mode = array_diff($var_mode, ['traduction']); |
|
| 3033 | - } |
|
| 3034 | - if (in_array('preview', $var_mode)) { |
|
| 3035 | - // basculer sur les criteres de preview dans les boucles |
|
| 3036 | - if (!defined('_VAR_PREVIEW')) { |
|
| 3037 | - define('_VAR_PREVIEW', true); |
|
| 3038 | - } |
|
| 3039 | - // forcer le calcul |
|
| 3040 | - if (!defined('_VAR_MODE')) { |
|
| 3041 | - define('_VAR_MODE', 'calcul'); |
|
| 3042 | - } |
|
| 3043 | - // et ne pas enregistrer de cache |
|
| 3044 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3045 | - define('_VAR_NOCACHE', true); |
|
| 3046 | - } |
|
| 3047 | - $var_mode = array_diff($var_mode, ['preview']); |
|
| 3048 | - } |
|
| 3049 | - if (in_array('inclure', $var_mode)) { |
|
| 3050 | - // forcer le compilo et ignorer les caches existants |
|
| 3051 | - if (!defined('_VAR_MODE')) { |
|
| 3052 | - define('_VAR_MODE', 'calcul'); |
|
| 3053 | - } |
|
| 3054 | - if (!defined('_VAR_INCLURE')) { |
|
| 3055 | - define('_VAR_INCLURE', true); |
|
| 3056 | - } |
|
| 3057 | - // et ne pas enregistrer de cache |
|
| 3058 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3059 | - define('_VAR_NOCACHE', true); |
|
| 3060 | - } |
|
| 3061 | - $var_mode = array_diff($var_mode, ['inclure']); |
|
| 3062 | - } |
|
| 3063 | - if (in_array('urls', $var_mode)) { |
|
| 3064 | - // forcer le compilo et ignorer les caches existants |
|
| 3065 | - if (!defined('_VAR_MODE')) { |
|
| 3066 | - define('_VAR_MODE', 'calcul'); |
|
| 3067 | - } |
|
| 3068 | - if (!defined('_VAR_URLS')) { |
|
| 3069 | - define('_VAR_URLS', true); |
|
| 3070 | - } |
|
| 3071 | - $var_mode = array_diff($var_mode, ['urls']); |
|
| 3072 | - } |
|
| 3073 | - if (in_array('images', $var_mode)) { |
|
| 3074 | - // forcer le compilo et ignorer les caches existants |
|
| 3075 | - if (!defined('_VAR_MODE')) { |
|
| 3076 | - define('_VAR_MODE', 'calcul'); |
|
| 3077 | - } |
|
| 3078 | - // indiquer qu'on doit recalculer les images |
|
| 3079 | - if (!defined('_VAR_IMAGES')) { |
|
| 3080 | - define('_VAR_IMAGES', true); |
|
| 3081 | - } |
|
| 3082 | - $var_mode = array_diff($var_mode, ['images']); |
|
| 3083 | - } |
|
| 3084 | - if (in_array('debug', $var_mode)) { |
|
| 3085 | - if (!defined('_VAR_MODE')) { |
|
| 3086 | - define('_VAR_MODE', 'debug'); |
|
| 3087 | - } |
|
| 3088 | - // et ne pas enregistrer de cache |
|
| 3089 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3090 | - define('_VAR_NOCACHE', true); |
|
| 3091 | - } |
|
| 3092 | - $var_mode = array_diff($var_mode, ['debug']); |
|
| 3093 | - } |
|
| 3094 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 3095 | - define('_VAR_MODE', reset($var_mode)); |
|
| 3096 | - } |
|
| 3097 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 3098 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 3099 | - . ' ' . _VAR_MODE); |
|
| 3100 | - } |
|
| 3101 | - } // pas autorise ? |
|
| 3102 | - else { |
|
| 3103 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 3104 | - if ( |
|
| 3105 | - !$GLOBALS['visiteur_session'] |
|
| 3106 | - and !empty($_SERVER['HTTP_HOST']) |
|
| 3107 | - and !empty($_SERVER['REQUEST_METHOD']) |
|
| 3108 | - and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 3109 | - ) { |
|
| 3110 | - $self = self('&', true); |
|
| 3111 | - if (strpos($self, 'page=login') === false) { |
|
| 3112 | - include_spip('inc/headers'); |
|
| 3113 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3114 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3115 | - } |
|
| 3116 | - } |
|
| 3117 | - // sinon tant pis |
|
| 3118 | - } |
|
| 3119 | - } |
|
| 3120 | - } |
|
| 3121 | - if (!defined('_VAR_MODE')) { |
|
| 3122 | - /** |
|
| 3123 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 3124 | - * @see init_var_mode() |
|
| 3125 | - */ |
|
| 3126 | - define('_VAR_MODE', false); |
|
| 3127 | - } |
|
| 3128 | - $done = true; |
|
| 3129 | - } |
|
| 2999 | + static $done = false; |
|
| 3000 | + if (!$done) { |
|
| 3001 | + if (isset($_GET['var_mode'])) { |
|
| 3002 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 3003 | + // tout le monde peut calcul/recalcul |
|
| 3004 | + if (!defined('_VAR_MODE')) { |
|
| 3005 | + if (in_array('recalcul', $var_mode)) { |
|
| 3006 | + define('_VAR_MODE', 'recalcul'); |
|
| 3007 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 3008 | + define('_VAR_MODE', 'calcul'); |
|
| 3009 | + } |
|
| 3010 | + } |
|
| 3011 | + $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 3012 | + if ($var_mode) { |
|
| 3013 | + include_spip('inc/autoriser'); |
|
| 3014 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 3015 | + if ( |
|
| 3016 | + autoriser( |
|
| 3017 | + ($_GET['var_mode'] == 'preview') |
|
| 3018 | + ? 'previsualiser' |
|
| 3019 | + : 'debug' |
|
| 3020 | + ) |
|
| 3021 | + ) { |
|
| 3022 | + if (in_array('traduction', $var_mode)) { |
|
| 3023 | + // forcer le calcul pour passer dans traduire |
|
| 3024 | + if (!defined('_VAR_MODE')) { |
|
| 3025 | + define('_VAR_MODE', 'calcul'); |
|
| 3026 | + } |
|
| 3027 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 3028 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3029 | + define('_VAR_NOCACHE', true); |
|
| 3030 | + } |
|
| 3031 | + $var_mode = array_diff($var_mode, ['traduction']); |
|
| 3032 | + } |
|
| 3033 | + if (in_array('preview', $var_mode)) { |
|
| 3034 | + // basculer sur les criteres de preview dans les boucles |
|
| 3035 | + if (!defined('_VAR_PREVIEW')) { |
|
| 3036 | + define('_VAR_PREVIEW', true); |
|
| 3037 | + } |
|
| 3038 | + // forcer le calcul |
|
| 3039 | + if (!defined('_VAR_MODE')) { |
|
| 3040 | + define('_VAR_MODE', 'calcul'); |
|
| 3041 | + } |
|
| 3042 | + // et ne pas enregistrer de cache |
|
| 3043 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3044 | + define('_VAR_NOCACHE', true); |
|
| 3045 | + } |
|
| 3046 | + $var_mode = array_diff($var_mode, ['preview']); |
|
| 3047 | + } |
|
| 3048 | + if (in_array('inclure', $var_mode)) { |
|
| 3049 | + // forcer le compilo et ignorer les caches existants |
|
| 3050 | + if (!defined('_VAR_MODE')) { |
|
| 3051 | + define('_VAR_MODE', 'calcul'); |
|
| 3052 | + } |
|
| 3053 | + if (!defined('_VAR_INCLURE')) { |
|
| 3054 | + define('_VAR_INCLURE', true); |
|
| 3055 | + } |
|
| 3056 | + // et ne pas enregistrer de cache |
|
| 3057 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3058 | + define('_VAR_NOCACHE', true); |
|
| 3059 | + } |
|
| 3060 | + $var_mode = array_diff($var_mode, ['inclure']); |
|
| 3061 | + } |
|
| 3062 | + if (in_array('urls', $var_mode)) { |
|
| 3063 | + // forcer le compilo et ignorer les caches existants |
|
| 3064 | + if (!defined('_VAR_MODE')) { |
|
| 3065 | + define('_VAR_MODE', 'calcul'); |
|
| 3066 | + } |
|
| 3067 | + if (!defined('_VAR_URLS')) { |
|
| 3068 | + define('_VAR_URLS', true); |
|
| 3069 | + } |
|
| 3070 | + $var_mode = array_diff($var_mode, ['urls']); |
|
| 3071 | + } |
|
| 3072 | + if (in_array('images', $var_mode)) { |
|
| 3073 | + // forcer le compilo et ignorer les caches existants |
|
| 3074 | + if (!defined('_VAR_MODE')) { |
|
| 3075 | + define('_VAR_MODE', 'calcul'); |
|
| 3076 | + } |
|
| 3077 | + // indiquer qu'on doit recalculer les images |
|
| 3078 | + if (!defined('_VAR_IMAGES')) { |
|
| 3079 | + define('_VAR_IMAGES', true); |
|
| 3080 | + } |
|
| 3081 | + $var_mode = array_diff($var_mode, ['images']); |
|
| 3082 | + } |
|
| 3083 | + if (in_array('debug', $var_mode)) { |
|
| 3084 | + if (!defined('_VAR_MODE')) { |
|
| 3085 | + define('_VAR_MODE', 'debug'); |
|
| 3086 | + } |
|
| 3087 | + // et ne pas enregistrer de cache |
|
| 3088 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3089 | + define('_VAR_NOCACHE', true); |
|
| 3090 | + } |
|
| 3091 | + $var_mode = array_diff($var_mode, ['debug']); |
|
| 3092 | + } |
|
| 3093 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 3094 | + define('_VAR_MODE', reset($var_mode)); |
|
| 3095 | + } |
|
| 3096 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 3097 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 3098 | + . ' ' . _VAR_MODE); |
|
| 3099 | + } |
|
| 3100 | + } // pas autorise ? |
|
| 3101 | + else { |
|
| 3102 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 3103 | + if ( |
|
| 3104 | + !$GLOBALS['visiteur_session'] |
|
| 3105 | + and !empty($_SERVER['HTTP_HOST']) |
|
| 3106 | + and !empty($_SERVER['REQUEST_METHOD']) |
|
| 3107 | + and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 3108 | + ) { |
|
| 3109 | + $self = self('&', true); |
|
| 3110 | + if (strpos($self, 'page=login') === false) { |
|
| 3111 | + include_spip('inc/headers'); |
|
| 3112 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3113 | + redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3114 | + } |
|
| 3115 | + } |
|
| 3116 | + // sinon tant pis |
|
| 3117 | + } |
|
| 3118 | + } |
|
| 3119 | + } |
|
| 3120 | + if (!defined('_VAR_MODE')) { |
|
| 3121 | + /** |
|
| 3122 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 3123 | + * @see init_var_mode() |
|
| 3124 | + */ |
|
| 3125 | + define('_VAR_MODE', false); |
|
| 3126 | + } |
|
| 3127 | + $done = true; |
|
| 3128 | + } |
|
| 3130 | 3129 | } |
| 3131 | 3130 | |
| 3132 | 3131 | /** |
@@ -3138,16 +3137,16 @@ discard block |
||
| 3138 | 3137 | * @param bool $deep = true : appliquer récursivement |
| 3139 | 3138 | **/ |
| 3140 | 3139 | function spip_desinfecte(&$t, $deep = true) { |
| 3141 | - foreach ($t as $key => $val) { |
|
| 3142 | - if (is_string($t[$key])) { |
|
| 3143 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3144 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 3145 | - else { |
|
| 3146 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3147 | - spip_desinfecte($t[$key], $deep); |
|
| 3148 | - } |
|
| 3149 | - } |
|
| 3150 | - } |
|
| 3140 | + foreach ($t as $key => $val) { |
|
| 3141 | + if (is_string($t[$key])) { |
|
| 3142 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3143 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 3144 | + else { |
|
| 3145 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3146 | + spip_desinfecte($t[$key], $deep); |
|
| 3147 | + } |
|
| 3148 | + } |
|
| 3149 | + } |
|
| 3151 | 3150 | } |
| 3152 | 3151 | |
| 3153 | 3152 | /** |
@@ -3160,64 +3159,64 @@ discard block |
||
| 3160 | 3159 | * @return string|0|false |
| 3161 | 3160 | **/ |
| 3162 | 3161 | function verifier_visiteur() { |
| 3163 | - @spip_initialisation_core( |
|
| 3164 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3165 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3166 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3167 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3168 | - ); |
|
| 3169 | - |
|
| 3170 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3171 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3172 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 3173 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3174 | - $variables_session = ['session_nom', 'session_email']; |
|
| 3175 | - foreach ($variables_session as $var) { |
|
| 3176 | - if (_request($var) !== null) { |
|
| 3177 | - $init = true; |
|
| 3178 | - break; |
|
| 3179 | - } |
|
| 3180 | - } |
|
| 3181 | - if (isset($init)) { |
|
| 3182 | - #@spip_initialisation_suite(); |
|
| 3183 | - $session = charger_fonction('session', 'inc'); |
|
| 3184 | - $session(); |
|
| 3185 | - include_spip('inc/texte'); |
|
| 3186 | - foreach ($variables_session as $var) { |
|
| 3187 | - if (($a = _request($var)) !== null) { |
|
| 3188 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3189 | - } |
|
| 3190 | - } |
|
| 3191 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3192 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3193 | - } |
|
| 3194 | - $session($GLOBALS['visiteur_session']); |
|
| 3195 | - |
|
| 3196 | - return 0; |
|
| 3197 | - } |
|
| 3198 | - |
|
| 3199 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3200 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3201 | - $session = charger_fonction('session', 'inc'); |
|
| 3202 | - if ($session()) { |
|
| 3203 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3204 | - } |
|
| 3205 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3206 | - include_spip('inc/auth'); |
|
| 3207 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3208 | - } |
|
| 3209 | - if ($h) { |
|
| 3210 | - $GLOBALS['visiteur_session'] = $h; |
|
| 3211 | - |
|
| 3212 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3213 | - } |
|
| 3214 | - } |
|
| 3215 | - |
|
| 3216 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3217 | - include_spip('inc/lang'); |
|
| 3218 | - utiliser_langue_visiteur(); |
|
| 3219 | - |
|
| 3220 | - return false; |
|
| 3162 | + @spip_initialisation_core( |
|
| 3163 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3164 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3165 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3166 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3167 | + ); |
|
| 3168 | + |
|
| 3169 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3170 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3171 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 3172 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3173 | + $variables_session = ['session_nom', 'session_email']; |
|
| 3174 | + foreach ($variables_session as $var) { |
|
| 3175 | + if (_request($var) !== null) { |
|
| 3176 | + $init = true; |
|
| 3177 | + break; |
|
| 3178 | + } |
|
| 3179 | + } |
|
| 3180 | + if (isset($init)) { |
|
| 3181 | + #@spip_initialisation_suite(); |
|
| 3182 | + $session = charger_fonction('session', 'inc'); |
|
| 3183 | + $session(); |
|
| 3184 | + include_spip('inc/texte'); |
|
| 3185 | + foreach ($variables_session as $var) { |
|
| 3186 | + if (($a = _request($var)) !== null) { |
|
| 3187 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3188 | + } |
|
| 3189 | + } |
|
| 3190 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3191 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3192 | + } |
|
| 3193 | + $session($GLOBALS['visiteur_session']); |
|
| 3194 | + |
|
| 3195 | + return 0; |
|
| 3196 | + } |
|
| 3197 | + |
|
| 3198 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3199 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3200 | + $session = charger_fonction('session', 'inc'); |
|
| 3201 | + if ($session()) { |
|
| 3202 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3203 | + } |
|
| 3204 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3205 | + include_spip('inc/auth'); |
|
| 3206 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3207 | + } |
|
| 3208 | + if ($h) { |
|
| 3209 | + $GLOBALS['visiteur_session'] = $h; |
|
| 3210 | + |
|
| 3211 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3212 | + } |
|
| 3213 | + } |
|
| 3214 | + |
|
| 3215 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3216 | + include_spip('inc/lang'); |
|
| 3217 | + utiliser_langue_visiteur(); |
|
| 3218 | + |
|
| 3219 | + return false; |
|
| 3221 | 3220 | } |
| 3222 | 3221 | |
| 3223 | 3222 | |
@@ -3240,21 +3239,21 @@ discard block |
||
| 3240 | 3239 | * - string Langue utilisée. |
| 3241 | 3240 | **/ |
| 3242 | 3241 | function lang_select($lang = null) { |
| 3243 | - static $pile_langues = []; |
|
| 3244 | - if (!function_exists('changer_langue')) { |
|
| 3245 | - include_spip('inc/lang'); |
|
| 3246 | - } |
|
| 3247 | - if ($lang === null) { |
|
| 3248 | - $lang = array_pop($pile_langues); |
|
| 3249 | - } else { |
|
| 3250 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3251 | - } |
|
| 3252 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3253 | - return $lang; |
|
| 3254 | - } |
|
| 3255 | - changer_langue($lang); |
|
| 3242 | + static $pile_langues = []; |
|
| 3243 | + if (!function_exists('changer_langue')) { |
|
| 3244 | + include_spip('inc/lang'); |
|
| 3245 | + } |
|
| 3246 | + if ($lang === null) { |
|
| 3247 | + $lang = array_pop($pile_langues); |
|
| 3248 | + } else { |
|
| 3249 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3250 | + } |
|
| 3251 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3252 | + return $lang; |
|
| 3253 | + } |
|
| 3254 | + changer_langue($lang); |
|
| 3256 | 3255 | |
| 3257 | - return $lang; |
|
| 3256 | + return $lang; |
|
| 3258 | 3257 | } |
| 3259 | 3258 | |
| 3260 | 3259 | /** |
@@ -3271,20 +3270,20 @@ discard block |
||
| 3271 | 3270 | * Identifiant de la session |
| 3272 | 3271 | **/ |
| 3273 | 3272 | function spip_session($force = false) { |
| 3274 | - static $session; |
|
| 3275 | - if ($force or !isset($session)) { |
|
| 3276 | - $s = pipeline( |
|
| 3277 | - 'definir_session', |
|
| 3278 | - $GLOBALS['visiteur_session'] |
|
| 3279 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3280 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3281 | - : '' |
|
| 3282 | - ); |
|
| 3283 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3284 | - } |
|
| 3273 | + static $session; |
|
| 3274 | + if ($force or !isset($session)) { |
|
| 3275 | + $s = pipeline( |
|
| 3276 | + 'definir_session', |
|
| 3277 | + $GLOBALS['visiteur_session'] |
|
| 3278 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3279 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3280 | + : '' |
|
| 3281 | + ); |
|
| 3282 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3283 | + } |
|
| 3285 | 3284 | |
| 3286 | - #spip_log('session: '.$session); |
|
| 3287 | - return $session; |
|
| 3285 | + #spip_log('session: '.$session); |
|
| 3286 | + return $session; |
|
| 3288 | 3287 | } |
| 3289 | 3288 | |
| 3290 | 3289 | |
@@ -3303,9 +3302,9 @@ discard block |
||
| 3303 | 3302 | * Lien sur une icone d'aide |
| 3304 | 3303 | **/ |
| 3305 | 3304 | function aider($aide = '', $distante = false) { |
| 3306 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3305 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3307 | 3306 | |
| 3308 | - return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3307 | + return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3309 | 3308 | } |
| 3310 | 3309 | |
| 3311 | 3310 | /** |
@@ -3315,35 +3314,35 @@ discard block |
||
| 3315 | 3314 | */ |
| 3316 | 3315 | function exec_info_dist() { |
| 3317 | 3316 | |
| 3318 | - include_spip('inc/autoriser'); |
|
| 3319 | - if (autoriser('phpinfos')) { |
|
| 3320 | - $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3321 | - $cookies_backup = []; |
|
| 3322 | - $server_backup = ['HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? []]; |
|
| 3323 | - $env_backup = ['HTTP_COOKIE' => $_ENV['HTTP_COOKIE'] ?? []]; |
|
| 3324 | - $mask = '******************************'; |
|
| 3325 | - foreach ($cookies_masques as $k) { |
|
| 3326 | - if (!empty($_COOKIE[$k])) { |
|
| 3327 | - $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3328 | - $_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []); |
|
| 3329 | - $_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []); |
|
| 3330 | - $_COOKIE[$k] = $mask; |
|
| 3331 | - } |
|
| 3332 | - } |
|
| 3333 | - phpinfo(); |
|
| 3334 | - foreach ($cookies_backup as $k => $v) { |
|
| 3335 | - $_COOKIE[$k] = $v; |
|
| 3336 | - } |
|
| 3337 | - foreach ($server_backup as $k => $v) { |
|
| 3338 | - $_SERVER[$k] = $v; |
|
| 3339 | - } |
|
| 3340 | - foreach ($env_backup as $k => $v) { |
|
| 3341 | - $_ENV[$k] = $v; |
|
| 3342 | - } |
|
| 3343 | - } else { |
|
| 3344 | - include_spip('inc/filtres'); |
|
| 3345 | - sinon_interdire_acces(); |
|
| 3346 | - } |
|
| 3317 | + include_spip('inc/autoriser'); |
|
| 3318 | + if (autoriser('phpinfos')) { |
|
| 3319 | + $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3320 | + $cookies_backup = []; |
|
| 3321 | + $server_backup = ['HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? []]; |
|
| 3322 | + $env_backup = ['HTTP_COOKIE' => $_ENV['HTTP_COOKIE'] ?? []]; |
|
| 3323 | + $mask = '******************************'; |
|
| 3324 | + foreach ($cookies_masques as $k) { |
|
| 3325 | + if (!empty($_COOKIE[$k])) { |
|
| 3326 | + $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3327 | + $_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []); |
|
| 3328 | + $_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []); |
|
| 3329 | + $_COOKIE[$k] = $mask; |
|
| 3330 | + } |
|
| 3331 | + } |
|
| 3332 | + phpinfo(); |
|
| 3333 | + foreach ($cookies_backup as $k => $v) { |
|
| 3334 | + $_COOKIE[$k] = $v; |
|
| 3335 | + } |
|
| 3336 | + foreach ($server_backup as $k => $v) { |
|
| 3337 | + $_SERVER[$k] = $v; |
|
| 3338 | + } |
|
| 3339 | + foreach ($env_backup as $k => $v) { |
|
| 3340 | + $_ENV[$k] = $v; |
|
| 3341 | + } |
|
| 3342 | + } else { |
|
| 3343 | + include_spip('inc/filtres'); |
|
| 3344 | + sinon_interdire_acces(); |
|
| 3345 | + } |
|
| 3347 | 3346 | } |
| 3348 | 3347 | |
| 3349 | 3348 | /** |
@@ -3363,13 +3362,13 @@ discard block |
||
| 3363 | 3362 | * - string si $message à false. |
| 3364 | 3363 | **/ |
| 3365 | 3364 | function erreur_squelette($message = '', $lieu = '') { |
| 3366 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3367 | - if (is_array($lieu)) { |
|
| 3368 | - include_spip('public/compiler'); |
|
| 3369 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3370 | - } |
|
| 3365 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3366 | + if (is_array($lieu)) { |
|
| 3367 | + include_spip('public/compiler'); |
|
| 3368 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3369 | + } |
|
| 3371 | 3370 | |
| 3372 | - return $debusquer($message, $lieu); |
|
| 3371 | + return $debusquer($message, $lieu); |
|
| 3373 | 3372 | } |
| 3374 | 3373 | |
| 3375 | 3374 | /** |
@@ -3406,108 +3405,108 @@ discard block |
||
| 3406 | 3405 | * - ou tableau d'information sur le squelette. |
| 3407 | 3406 | */ |
| 3408 | 3407 | function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') { |
| 3409 | - if (!function_exists('evaluer_fond')) { |
|
| 3410 | - include_spip('public/assembler'); |
|
| 3411 | - } |
|
| 3412 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3413 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3414 | - if (!is_array($options)) { |
|
| 3415 | - $options = ['trim' => $options]; |
|
| 3416 | - } |
|
| 3417 | - if (!isset($options['trim'])) { |
|
| 3418 | - $options['trim'] = true; |
|
| 3419 | - } |
|
| 3420 | - |
|
| 3421 | - if (isset($contexte['connect'])) { |
|
| 3422 | - $connect = $contexte['connect']; |
|
| 3423 | - unset($contexte['connect']); |
|
| 3424 | - } |
|
| 3425 | - |
|
| 3426 | - $texte = ''; |
|
| 3427 | - $pages = []; |
|
| 3428 | - $lang_select = ''; |
|
| 3429 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3430 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3431 | - if (!isset($contexte['lang'])) { |
|
| 3432 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3433 | - } |
|
| 3434 | - |
|
| 3435 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3436 | - $lang_select = lang_select($contexte['lang']); |
|
| 3437 | - } |
|
| 3438 | - } |
|
| 3439 | - |
|
| 3440 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3441 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3442 | - } |
|
| 3443 | - |
|
| 3444 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3445 | - |
|
| 3446 | - // fix #4235 |
|
| 3447 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3448 | - |
|
| 3449 | - |
|
| 3450 | - foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3451 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3452 | - |
|
| 3453 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3454 | - if ($page === '') { |
|
| 3455 | - $c = $options['compil'] ?? ''; |
|
| 3456 | - $a = ['fichier' => $f]; |
|
| 3457 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3458 | - erreur_squelette($erreur, $c); |
|
| 3459 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3460 | - $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3461 | - } |
|
| 3462 | - |
|
| 3463 | - $page = pipeline('recuperer_fond', [ |
|
| 3464 | - 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3465 | - 'data' => $page |
|
| 3466 | - ]); |
|
| 3467 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3468 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3469 | - include_spip('inc/filtres'); |
|
| 3470 | - } |
|
| 3471 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3472 | - array_merge( |
|
| 3473 | - $contexte, |
|
| 3474 | - ['fond' => $f], |
|
| 3475 | - ($connect ? ['connect' => $connect] : []) |
|
| 3476 | - ), |
|
| 3477 | - '', |
|
| 3478 | - $page['texte'], |
|
| 3479 | - $options['ajax'] |
|
| 3480 | - ); |
|
| 3481 | - } |
|
| 3482 | - |
|
| 3483 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3484 | - $pages[] = $page; |
|
| 3485 | - } else { |
|
| 3486 | - $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte']; |
|
| 3487 | - } |
|
| 3488 | - |
|
| 3489 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3490 | - if (isset($page['invalideurs']['session'])) { |
|
| 3491 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3492 | - } |
|
| 3493 | - } |
|
| 3494 | - |
|
| 3495 | - // restaurer le sessionnement du contexte appelant, |
|
| 3496 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3497 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3498 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3499 | - } |
|
| 3500 | - |
|
| 3501 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3502 | - |
|
| 3503 | - if ($lang_select) { |
|
| 3504 | - lang_select(); |
|
| 3505 | - } |
|
| 3506 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3507 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3508 | - } else { |
|
| 3509 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3510 | - } |
|
| 3408 | + if (!function_exists('evaluer_fond')) { |
|
| 3409 | + include_spip('public/assembler'); |
|
| 3410 | + } |
|
| 3411 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3412 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3413 | + if (!is_array($options)) { |
|
| 3414 | + $options = ['trim' => $options]; |
|
| 3415 | + } |
|
| 3416 | + if (!isset($options['trim'])) { |
|
| 3417 | + $options['trim'] = true; |
|
| 3418 | + } |
|
| 3419 | + |
|
| 3420 | + if (isset($contexte['connect'])) { |
|
| 3421 | + $connect = $contexte['connect']; |
|
| 3422 | + unset($contexte['connect']); |
|
| 3423 | + } |
|
| 3424 | + |
|
| 3425 | + $texte = ''; |
|
| 3426 | + $pages = []; |
|
| 3427 | + $lang_select = ''; |
|
| 3428 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3429 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3430 | + if (!isset($contexte['lang'])) { |
|
| 3431 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3432 | + } |
|
| 3433 | + |
|
| 3434 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3435 | + $lang_select = lang_select($contexte['lang']); |
|
| 3436 | + } |
|
| 3437 | + } |
|
| 3438 | + |
|
| 3439 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3440 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3441 | + } |
|
| 3442 | + |
|
| 3443 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3444 | + |
|
| 3445 | + // fix #4235 |
|
| 3446 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3447 | + |
|
| 3448 | + |
|
| 3449 | + foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3450 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3451 | + |
|
| 3452 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3453 | + if ($page === '') { |
|
| 3454 | + $c = $options['compil'] ?? ''; |
|
| 3455 | + $a = ['fichier' => $f]; |
|
| 3456 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3457 | + erreur_squelette($erreur, $c); |
|
| 3458 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3459 | + $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3460 | + } |
|
| 3461 | + |
|
| 3462 | + $page = pipeline('recuperer_fond', [ |
|
| 3463 | + 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3464 | + 'data' => $page |
|
| 3465 | + ]); |
|
| 3466 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3467 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3468 | + include_spip('inc/filtres'); |
|
| 3469 | + } |
|
| 3470 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3471 | + array_merge( |
|
| 3472 | + $contexte, |
|
| 3473 | + ['fond' => $f], |
|
| 3474 | + ($connect ? ['connect' => $connect] : []) |
|
| 3475 | + ), |
|
| 3476 | + '', |
|
| 3477 | + $page['texte'], |
|
| 3478 | + $options['ajax'] |
|
| 3479 | + ); |
|
| 3480 | + } |
|
| 3481 | + |
|
| 3482 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3483 | + $pages[] = $page; |
|
| 3484 | + } else { |
|
| 3485 | + $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte']; |
|
| 3486 | + } |
|
| 3487 | + |
|
| 3488 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3489 | + if (isset($page['invalideurs']['session'])) { |
|
| 3490 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3491 | + } |
|
| 3492 | + } |
|
| 3493 | + |
|
| 3494 | + // restaurer le sessionnement du contexte appelant, |
|
| 3495 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3496 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3497 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3498 | + } |
|
| 3499 | + |
|
| 3500 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3501 | + |
|
| 3502 | + if ($lang_select) { |
|
| 3503 | + lang_select(); |
|
| 3504 | + } |
|
| 3505 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3506 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3507 | + } else { |
|
| 3508 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3509 | + } |
|
| 3511 | 3510 | } |
| 3512 | 3511 | |
| 3513 | 3512 | /** |
@@ -3517,7 +3516,7 @@ discard block |
||
| 3517 | 3516 | * @return string |
| 3518 | 3517 | */ |
| 3519 | 3518 | function trouve_modele($nom) { |
| 3520 | - return trouver_fond($nom, 'modeles/'); |
|
| 3519 | + return trouver_fond($nom, 'modeles/'); |
|
| 3521 | 3520 | } |
| 3522 | 3521 | |
| 3523 | 3522 | /** |
@@ -3533,21 +3532,21 @@ discard block |
||
| 3533 | 3532 | * @return array|string |
| 3534 | 3533 | */ |
| 3535 | 3534 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3536 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3537 | - if (!$pathinfo) { |
|
| 3538 | - return $f; |
|
| 3539 | - } |
|
| 3540 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3541 | - $p = pathinfo($f); |
|
| 3542 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3543 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3544 | - } |
|
| 3545 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3546 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3547 | - } |
|
| 3548 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3535 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3536 | + if (!$pathinfo) { |
|
| 3537 | + return $f; |
|
| 3538 | + } |
|
| 3539 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3540 | + $p = pathinfo($f); |
|
| 3541 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3542 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3543 | + } |
|
| 3544 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3545 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3546 | + } |
|
| 3547 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3549 | 3548 | |
| 3550 | - return $p; |
|
| 3549 | + return $p; |
|
| 3551 | 3550 | } |
| 3552 | 3551 | |
| 3553 | 3552 | /** |
@@ -3567,21 +3566,21 @@ discard block |
||
| 3567 | 3566 | * Nom de l'exec, sinon chaîne vide. |
| 3568 | 3567 | **/ |
| 3569 | 3568 | function tester_url_ecrire($nom) { |
| 3570 | - static $exec = []; |
|
| 3571 | - if (isset($exec[$nom])) { |
|
| 3572 | - return $exec[$nom]; |
|
| 3573 | - } |
|
| 3574 | - // tester si c'est une page en squelette |
|
| 3575 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3576 | - return $exec[$nom] = 'fond'; |
|
| 3577 | - } // echafaudage d'un fond ! |
|
| 3578 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3579 | - return $exec[$nom] = 'fond'; |
|
| 3580 | - } |
|
| 3581 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3582 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3583 | - // et des define intrusifs potentiels |
|
| 3584 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3569 | + static $exec = []; |
|
| 3570 | + if (isset($exec[$nom])) { |
|
| 3571 | + return $exec[$nom]; |
|
| 3572 | + } |
|
| 3573 | + // tester si c'est une page en squelette |
|
| 3574 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3575 | + return $exec[$nom] = 'fond'; |
|
| 3576 | + } // echafaudage d'un fond ! |
|
| 3577 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3578 | + return $exec[$nom] = 'fond'; |
|
| 3579 | + } |
|
| 3580 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3581 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3582 | + // et des define intrusifs potentiels |
|
| 3583 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3585 | 3584 | } |
| 3586 | 3585 | |
| 3587 | 3586 | /** |
@@ -3591,37 +3590,37 @@ discard block |
||
| 3591 | 3590 | * true si la constante _VERSION_HTML n'est pas définie ou égale à html5 |
| 3592 | 3591 | **/ |
| 3593 | 3592 | function html5_permis() { |
| 3594 | - return (!defined('_VERSION_HTML') |
|
| 3595 | - or _VERSION_HTML !== 'html4'); |
|
| 3593 | + return (!defined('_VERSION_HTML') |
|
| 3594 | + or _VERSION_HTML !== 'html4'); |
|
| 3596 | 3595 | } |
| 3597 | 3596 | |
| 3598 | 3597 | /** |
| 3599 | 3598 | * Lister les formats image acceptes par les lib et fonctions images |
| 3600 | 3599 | */ |
| 3601 | 3600 | function formats_image_acceptables(?bool $gd = null, bool $svg_allowed = true): array { |
| 3602 | - $formats = null; |
|
| 3603 | - if (!is_null($gd)) { |
|
| 3604 | - $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3605 | - if (isset($GLOBALS['meta'][$config])) { |
|
| 3606 | - $formats = $GLOBALS['meta'][$config]; |
|
| 3607 | - $formats = explode(',', $formats); |
|
| 3608 | - $formats = array_filter($formats); |
|
| 3609 | - $formats = array_map('trim', $formats); |
|
| 3610 | - } |
|
| 3611 | - } |
|
| 3612 | - if (is_null($formats)) { |
|
| 3613 | - include_spip('inc/filtres_images_lib_mini'); |
|
| 3614 | - $formats = _image_extensions_acceptees_en_entree(); |
|
| 3615 | - } |
|
| 3616 | - |
|
| 3617 | - if ($svg_allowed) { |
|
| 3618 | - if (!in_array('svg', $formats)) { |
|
| 3619 | - $formats[] = 'svg'; |
|
| 3620 | - } |
|
| 3621 | - } else { |
|
| 3622 | - $formats = array_diff($formats, ['svg']); |
|
| 3623 | - } |
|
| 3624 | - return $formats; |
|
| 3601 | + $formats = null; |
|
| 3602 | + if (!is_null($gd)) { |
|
| 3603 | + $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3604 | + if (isset($GLOBALS['meta'][$config])) { |
|
| 3605 | + $formats = $GLOBALS['meta'][$config]; |
|
| 3606 | + $formats = explode(',', $formats); |
|
| 3607 | + $formats = array_filter($formats); |
|
| 3608 | + $formats = array_map('trim', $formats); |
|
| 3609 | + } |
|
| 3610 | + } |
|
| 3611 | + if (is_null($formats)) { |
|
| 3612 | + include_spip('inc/filtres_images_lib_mini'); |
|
| 3613 | + $formats = _image_extensions_acceptees_en_entree(); |
|
| 3614 | + } |
|
| 3615 | + |
|
| 3616 | + if ($svg_allowed) { |
|
| 3617 | + if (!in_array('svg', $formats)) { |
|
| 3618 | + $formats[] = 'svg'; |
|
| 3619 | + } |
|
| 3620 | + } else { |
|
| 3621 | + $formats = array_diff($formats, ['svg']); |
|
| 3622 | + } |
|
| 3623 | + return $formats; |
|
| 3625 | 3624 | } |
| 3626 | 3625 | |
| 3627 | 3626 | /** |
@@ -3630,20 +3629,20 @@ discard block |
||
| 3630 | 3629 | * @return array|bool |
| 3631 | 3630 | */ |
| 3632 | 3631 | function spip_getimagesize($fichier) { |
| 3633 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3634 | - include_spip('inc/svg'); |
|
| 3635 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3636 | - [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3637 | - $imagesize = [ |
|
| 3638 | - $width, |
|
| 3639 | - $height, |
|
| 3640 | - IMAGETYPE_SVG, |
|
| 3641 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3642 | - 'mime' => 'image/svg+xml' |
|
| 3643 | - ]; |
|
| 3644 | - } |
|
| 3645 | - } |
|
| 3646 | - return $imagesize; |
|
| 3632 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3633 | + include_spip('inc/svg'); |
|
| 3634 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3635 | + [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3636 | + $imagesize = [ |
|
| 3637 | + $width, |
|
| 3638 | + $height, |
|
| 3639 | + IMAGETYPE_SVG, |
|
| 3640 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3641 | + 'mime' => 'image/svg+xml' |
|
| 3642 | + ]; |
|
| 3643 | + } |
|
| 3644 | + } |
|
| 3645 | + return $imagesize; |
|
| 3647 | 3646 | } |
| 3648 | 3647 | |
| 3649 | 3648 | /** |
@@ -3657,19 +3656,19 @@ discard block |
||
| 3657 | 3656 | * @param string $statut |
| 3658 | 3657 | */ |
| 3659 | 3658 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3660 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3661 | - if ( |
|
| 3662 | - !$alertes |
|
| 3663 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3664 | - ) { |
|
| 3665 | - $alertes = []; |
|
| 3666 | - } |
|
| 3659 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3660 | + if ( |
|
| 3661 | + !$alertes |
|
| 3662 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3663 | + ) { |
|
| 3664 | + $alertes = []; |
|
| 3665 | + } |
|
| 3667 | 3666 | |
| 3668 | - if (!isset($alertes[$statut])) { |
|
| 3669 | - $alertes[$statut] = []; |
|
| 3670 | - } |
|
| 3671 | - $alertes[$statut][$nom] = $message; |
|
| 3672 | - ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3667 | + if (!isset($alertes[$statut])) { |
|
| 3668 | + $alertes[$statut] = []; |
|
| 3669 | + } |
|
| 3670 | + $alertes[$statut][$nom] = $message; |
|
| 3671 | + ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3673 | 3672 | } |
| 3674 | 3673 | |
| 3675 | 3674 | /** |
@@ -3683,10 +3682,10 @@ discard block |
||
| 3683 | 3682 | * @return string|string[] |
| 3684 | 3683 | */ |
| 3685 | 3684 | function spip_sanitize_classname($classes) { |
| 3686 | - if (is_array($classes)) { |
|
| 3687 | - return array_map('spip_sanitize_classname', $classes); |
|
| 3688 | - } |
|
| 3689 | - return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3685 | + if (is_array($classes)) { |
|
| 3686 | + return array_map('spip_sanitize_classname', $classes); |
|
| 3687 | + } |
|
| 3688 | + return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3690 | 3689 | } |
| 3691 | 3690 | |
| 3692 | 3691 | |
@@ -3711,32 +3710,32 @@ discard block |
||
| 3711 | 3710 | * Avec operateur : bool. |
| 3712 | 3711 | **/ |
| 3713 | 3712 | function spip_version_compare($v1, $v2, $op = null) { |
| 3714 | - $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3715 | - $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3716 | - $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3717 | - $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3718 | - |
|
| 3719 | - $v1 = explode('.', $v1); |
|
| 3720 | - $v2 = explode('.', $v2); |
|
| 3721 | - // $v1 est toujours une version, donc sans etoile |
|
| 3722 | - while (count($v1) < count($v2)) { |
|
| 3723 | - $v1[] = '0'; |
|
| 3724 | - } |
|
| 3725 | - |
|
| 3726 | - // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3727 | - $etoile = false; |
|
| 3728 | - foreach ($v1 as $k => $v) { |
|
| 3729 | - if (!isset($v2[$k])) { |
|
| 3730 | - $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3731 | - } else { |
|
| 3732 | - if ($v2[$k] == '*') { |
|
| 3733 | - $etoile = true; |
|
| 3734 | - $v2[$k] = $v; |
|
| 3735 | - } |
|
| 3736 | - } |
|
| 3737 | - } |
|
| 3738 | - $v1 = implode('.', $v1); |
|
| 3739 | - $v2 = implode('.', $v2); |
|
| 3740 | - |
|
| 3741 | - return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3713 | + $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3714 | + $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3715 | + $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3716 | + $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3717 | + |
|
| 3718 | + $v1 = explode('.', $v1); |
|
| 3719 | + $v2 = explode('.', $v2); |
|
| 3720 | + // $v1 est toujours une version, donc sans etoile |
|
| 3721 | + while (count($v1) < count($v2)) { |
|
| 3722 | + $v1[] = '0'; |
|
| 3723 | + } |
|
| 3724 | + |
|
| 3725 | + // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3726 | + $etoile = false; |
|
| 3727 | + foreach ($v1 as $k => $v) { |
|
| 3728 | + if (!isset($v2[$k])) { |
|
| 3729 | + $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3730 | + } else { |
|
| 3731 | + if ($v2[$k] == '*') { |
|
| 3732 | + $etoile = true; |
|
| 3733 | + $v2[$k] = $v; |
|
| 3734 | + } |
|
| 3735 | + } |
|
| 3736 | + } |
|
| 3737 | + $v1 = implode('.', $v1); |
|
| 3738 | + $v2 = implode('.', $v2); |
|
| 3739 | + |
|
| 3740 | + return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3742 | 3741 | } |
@@ -368,8 +368,7 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | if (!isset($regs[2])) { |
| 370 | 370 | $niveau = _LOG_INFO; |
| 371 | - } |
|
| 372 | - else { |
|
| 371 | + } else { |
|
| 373 | 372 | $niveau = intval($regs[2]); |
| 374 | 373 | } |
| 375 | 374 | |
@@ -1485,8 +1484,7 @@ discard block |
||
| 1485 | 1484 | ) { |
| 1486 | 1485 | if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
| 1487 | 1486 | return $themefiles["$subdir$file"] = $fsize; |
| 1488 | - } |
|
| 1489 | - else { |
|
| 1487 | + } else { |
|
| 1490 | 1488 | return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
| 1491 | 1489 | } |
| 1492 | 1490 | } |
@@ -9,12 +9,12 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class Condition extends Data |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Obtenir les données de la boucle CONDITION. |
|
| 14 | - * |
|
| 15 | - * @param array $command |
|
| 16 | - */ |
|
| 17 | - protected function select($command) { |
|
| 18 | - $this->tableau = [0 => 1]; |
|
| 19 | - } |
|
| 12 | + /** |
|
| 13 | + * Obtenir les données de la boucle CONDITION. |
|
| 14 | + * |
|
| 15 | + * @param array $command |
|
| 16 | + */ |
|
| 17 | + protected function select($command) { |
|
| 18 | + $this->tableau = [0 => 1]; |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -7,367 +7,367 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Boucle |
| 9 | 9 | { |
| 10 | - /** Type de noeud */ |
|
| 11 | - public string $type = 'boucle'; |
|
| 12 | - |
|
| 13 | - /** Identifiant de la boucle */ |
|
| 14 | - public string $id_boucle; |
|
| 15 | - |
|
| 16 | - /** Identifiant de la boucle parente */ |
|
| 17 | - public string $id_parent = ''; |
|
| 18 | - |
|
| 19 | - /** Un nom explicite qui peut être affecté manuellement à certaines boucles générées */ |
|
| 20 | - public string $nom = ''; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Partie avant toujours affichee |
|
| 24 | - * |
|
| 25 | - * @var string|array |
|
| 26 | - */ |
|
| 27 | - public $preaff = ''; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Partie optionnelle avant |
|
| 31 | - * |
|
| 32 | - * @var string|array |
|
| 33 | - */ |
|
| 34 | - public $avant = ''; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Pour chaque élément |
|
| 38 | - * |
|
| 39 | - * @var string|array |
|
| 40 | - */ |
|
| 41 | - public $milieu = ''; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Partie optionnelle après |
|
| 45 | - * |
|
| 46 | - * @var string|array |
|
| 47 | - */ |
|
| 48 | - public $apres = ''; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Partie alternative, si pas de résultat dans la boucle |
|
| 52 | - * |
|
| 53 | - * @var string|array |
|
| 54 | - */ |
|
| 55 | - public $altern = ''; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Partie apres toujours affichee |
|
| 59 | - * |
|
| 60 | - * @var string|array |
|
| 61 | - */ |
|
| 62 | - public $postaff = ''; |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * La boucle doit-elle sélectionner la langue ? |
|
| 67 | - * |
|
| 68 | - * Valeurs : '', 'oui', 'non' |
|
| 69 | - */ |
|
| 70 | - public string $lang_select = ''; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 74 | - * |
|
| 75 | - * FIXME: un seul typage (string ?) |
|
| 76 | - * |
|
| 77 | - * @var string|false|null |
|
| 78 | - */ |
|
| 79 | - public $type_requete = null; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * La table est elle optionnelle ? |
|
| 83 | - * |
|
| 84 | - * Si oui, aucune erreur ne sera générée si la table demandée n'est pas présente |
|
| 85 | - */ |
|
| 86 | - public bool $table_optionnelle = false; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Nom du fichier de connexion |
|
| 90 | - */ |
|
| 91 | - public string $sql_serveur = ''; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Paramètres de la boucle |
|
| 95 | - * |
|
| 96 | - * Description des paramètres passés à la boucle, qui servent ensuite |
|
| 97 | - * au calcul des critères |
|
| 98 | - * |
|
| 99 | - * FIXME: type unique. |
|
| 100 | - * @var false|array |
|
| 101 | - * - false: erreur de syntaxe |
|
| 102 | - */ |
|
| 103 | - public $param = []; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Critères de la boucle |
|
| 107 | - * |
|
| 108 | - * FIXME: type array unique. |
|
| 109 | - * |
|
| 110 | - * @var string|Critere[] |
|
| 111 | - * - string: phrasage (code brut). Il reste si erreur de critère |
|
| 112 | - * - array: analyse correcte des critères... |
|
| 113 | - */ |
|
| 114 | - public $criteres = []; |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Textes insérés entre 2 éléments de boucle (critère inter) |
|
| 118 | - * |
|
| 119 | - * @var string[] |
|
| 120 | - */ |
|
| 121 | - public array $separateur = []; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Liste des jointures possibles avec cette table |
|
| 125 | - * |
|
| 126 | - * Les jointures par défaut de la table sont complétées en priorité |
|
| 127 | - * des jointures déclarées explicitement sur la boucle |
|
| 128 | - * |
|
| 129 | - * @see base_trouver_table_dist() |
|
| 130 | - */ |
|
| 131 | - public array $jointures = []; |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Jointures explicites avec cette table |
|
| 135 | - * |
|
| 136 | - * Ces jointures sont utilisées en priorité par rapport aux jointures |
|
| 137 | - * normales possibles pour retrouver les colonnes demandées extérieures |
|
| 138 | - * à la boucle. |
|
| 139 | - * |
|
| 140 | - * @var string|bool |
|
| 141 | - */ |
|
| 142 | - public $jointures_explicites = false; |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Nom de la variable PHP stockant le noms de doublons utilisés "$doublons_index" |
|
| 146 | - */ |
|
| 147 | - public string $doublons = ''; |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Code PHP ajouté au début de chaque itération de boucle. |
|
| 151 | - * |
|
| 152 | - * Utilisé entre autre par les critères {pagination}, {n-a,b}, {a/b}... |
|
| 153 | - */ |
|
| 154 | - public string $partie = ''; |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Nombre de divisions de la boucle, d'éléments à afficher, |
|
| 158 | - * ou de soustractions d'éléments à faire |
|
| 159 | - * |
|
| 160 | - * Dans les critères limitant le nombre d'éléments affichés |
|
| 161 | - * {a,b}, {a,n-b}, {a/b}, {pagination b}, b est affecté à total_parties. |
|
| 162 | - */ |
|
| 163 | - public string $total_parties = ''; |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Code PHP ajouté avant l'itération de boucle. |
|
| 167 | - * |
|
| 168 | - * Utilisé entre autre par les critères {pagination}, {a,b}, {a/b} |
|
| 169 | - * pour initialiser les variables de début et de fin d'itération. |
|
| 170 | - */ |
|
| 171 | - public string $mode_partie = ''; |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Identifiant d'une boucle qui appelle celle-ci de manière récursive |
|
| 175 | - * |
|
| 176 | - * Si une boucle est appelée de manière récursive quelque part par |
|
| 177 | - * une autre boucle comme <BOUCLE_rec(boucle_identifiant) />, cette |
|
| 178 | - * boucle (identifiant) reçoit dans cette propriété l'identifiant |
|
| 179 | - * de l'appelant (rec) |
|
| 180 | - */ |
|
| 181 | - public string $externe = ''; |
|
| 182 | - |
|
| 183 | - // champs pour la construction de la requete SQL |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Liste des champs à récupérer par la boucle |
|
| 187 | - * |
|
| 188 | - * Expression 'table.nom_champ' ou calculée 'nom_champ AS x' |
|
| 189 | - * |
|
| 190 | - * @var string[] |
|
| 191 | - */ |
|
| 192 | - public array $select = []; |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Liste des alias / tables SQL utilisées dans la boucle |
|
| 196 | - * |
|
| 197 | - * L'index est un identifiant (xx dans spip_xx assez souvent) qui servira |
|
| 198 | - * d'alias au nom de la table ; la valeur est le nom de la table SQL désirée. |
|
| 199 | - * |
|
| 200 | - * L'index 0 peut définir le type de sources de données de l'itérateur DATA |
|
| 201 | - * |
|
| 202 | - * @var string[] |
|
| 203 | - */ |
|
| 204 | - public array $from = []; |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Liste des alias / type de jointures utilisées dans la boucle |
|
| 208 | - * |
|
| 209 | - * L'index est le nom d'alias (comme pour la propriété $from), et la valeur |
|
| 210 | - * un type de jointure parmi 'INNER', 'LEFT', 'RIGHT', 'OUTER'. |
|
| 211 | - * |
|
| 212 | - * Lorsque le type n'est pas déclaré pour un alias, c'est 'INNER' |
|
| 213 | - * qui sera utilisé par défaut (créant donc un INNER JOIN). |
|
| 214 | - * |
|
| 215 | - * @var string[] |
|
| 216 | - */ |
|
| 217 | - public array $from_type = []; |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Liste des conditions WHERE de la boucle |
|
| 221 | - * |
|
| 222 | - * Permet de restreindre les éléments retournés par une boucle |
|
| 223 | - * en fonctions des conditions transmises dans ce tableau. |
|
| 224 | - * |
|
| 225 | - * Ce tableau peut avoir plusieurs niveaux de profondeur. |
|
| 226 | - * |
|
| 227 | - * Les éléments du premier niveau sont reliés par des AND, donc |
|
| 228 | - * chaque élément ajouté directement au where par |
|
| 229 | - * $boucle->where[] = array(...) ou $boucle->where[] = "'expression'" |
|
| 230 | - * est une condition AND en plus. |
|
| 231 | - * |
|
| 232 | - * Par contre, lorsqu'on indique un tableau, il peut décrire des relations |
|
| 233 | - * internes différentes. Soit $expr un tableau d'expressions quelconques de 3 valeurs : |
|
| 234 | - * $expr = array(operateur, val1, val2) |
|
| 235 | - * |
|
| 236 | - * Ces 3 valeurs sont des expressions PHP. L'index 0 désigne l'opérateur |
|
| 237 | - * à réaliser tel que : |
|
| 238 | - * |
|
| 239 | - * - "'='" , "'>='", "'<'", "'IN'", "'REGEXP'", "'LIKE'", ... : |
|
| 240 | - * val1 et val2 sont des champs et valeurs à utiliser dans la comparaison |
|
| 241 | - * suivant cet ordre : "val1 operateur val2". |
|
| 242 | - * Exemple : $boucle->where[] = array("'='", "'articles.statut'", "'\"publie\"'"); |
|
| 243 | - * - "'AND'", "'OR'", "'NOT'" : |
|
| 244 | - * dans ce cas val1 et val2 sont également des expressions |
|
| 245 | - * de comparaison complètes, et peuvent être eux-même des tableaux comme $expr |
|
| 246 | - * Exemples : |
|
| 247 | - * $boucle->where[] = array("'OR'", $expr1, $expr2); |
|
| 248 | - * $boucle->where[] = array("'NOT'", $expr); // val2 n'existe pas avec NOT |
|
| 249 | - * |
|
| 250 | - * D'autres noms sont possibles pour l'opérateur (le nombre de valeurs diffère) : |
|
| 251 | - * - "'SELF'", "'SUBSELECT'" : indiquent des sous requêtes |
|
| 252 | - * - "'?'" : indique une condition à faire évaluer (val1 ? val2 : val3) |
|
| 253 | - */ |
|
| 254 | - public array $where = []; |
|
| 255 | - |
|
| 256 | - public array $join = []; |
|
| 257 | - public array $having = []; |
|
| 258 | - public $limit = ''; |
|
| 259 | - public array $group = []; |
|
| 260 | - public array $order = []; |
|
| 261 | - public array $default_order = []; |
|
| 262 | - public string $date = 'date'; |
|
| 263 | - public string $hash = ''; |
|
| 264 | - public $in = ''; |
|
| 265 | - public bool $sous_requete = false; |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Code PHP qui sera ajouté en tout début de la fonction de boucle |
|
| 269 | - * |
|
| 270 | - * Il sert à insérer le code calculant une hierarchie |
|
| 271 | - */ |
|
| 272 | - public string $hierarchie = ''; |
|
| 273 | - |
|
| 274 | - // champs pour la construction du corps PHP |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * Description des sources de données de la boucle |
|
| 278 | - * |
|
| 279 | - * Description des données de la boucle issu de trouver_table |
|
| 280 | - * dans le cadre de l'itérateur SQL et contenant au moins l'index 'field'. |
|
| 281 | - * |
|
| 282 | - * @see base_trouver_table_dist() |
|
| 283 | - */ |
|
| 284 | - public array $show = []; |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * Nom de la table SQL principale de la boucle, sans son préfixe |
|
| 288 | - */ |
|
| 289 | - public string $id_table = ''; |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Nom de la clé primaire de la table SQL principale de la boucle |
|
| 293 | - */ |
|
| 294 | - public string $primary = ''; |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Code PHP compilé de la boucle |
|
| 298 | - * |
|
| 299 | - * FIXME: un seul type (string ?) |
|
| 300 | - * |
|
| 301 | - * - false: boucle fautive ? |
|
| 302 | - * |
|
| 303 | - * @var string|false |
|
| 304 | - */ |
|
| 305 | - public $return = ''; |
|
| 306 | - |
|
| 307 | - public $numrows = false; |
|
| 308 | - public $cptrows = false; |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * Description du squelette |
|
| 312 | - * |
|
| 313 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 314 | - * |
|
| 315 | - * Peut contenir les index : |
|
| 316 | - * |
|
| 317 | - * - nom : Nom du fichier de cache |
|
| 318 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 319 | - * - sourcefile : Chemin du squelette |
|
| 320 | - * - squelette : Code du squelette |
|
| 321 | - * - id_mere : Identifiant de la boucle parente |
|
| 322 | - * - documents : Pour embed et img dans les textes |
|
| 323 | - * - session : Pour un cache sessionné par auteur |
|
| 324 | - * - niv : Niveau de tabulation |
|
| 325 | - */ |
|
| 326 | - public array $descr = []; |
|
| 327 | - |
|
| 328 | - /** Numéro de ligne dans le code source du squelette */ |
|
| 329 | - public int $ligne = 0; |
|
| 330 | - |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * table pour stocker les modificateurs de boucle tels que tout, plat ..., |
|
| 334 | - * utilisable par les plugins egalement |
|
| 335 | - * |
|
| 336 | - * @var array<string, mixed> |
|
| 337 | - */ |
|
| 338 | - public array $modificateur = []; |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * Type d'itérateur utilisé pour cette boucle |
|
| 342 | - * |
|
| 343 | - * - 'SQL' dans le cadre d'une boucle sur une table SQL |
|
| 344 | - * - 'DATA' pour l'itérateur DATA, ... |
|
| 345 | - * |
|
| 346 | - * @var string |
|
| 347 | - */ |
|
| 348 | - public string $iterateur = ''; // type d'iterateur |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * @var array $debug Textes qui seront insérés dans l’entête de boucle du mode debug |
|
| 352 | - */ |
|
| 353 | - public array $debug = []; |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * Index de la boucle dont le champ présent dans cette boucle est originaire, |
|
| 357 | - * notamment si le champ a été trouve dans une boucle parente |
|
| 358 | - * |
|
| 359 | - * Tableau nom du champ => index de boucle |
|
| 360 | - */ |
|
| 361 | - public array $index_champ = []; |
|
| 362 | - |
|
| 363 | - /** Résultat de la compilation (?) (sert au débusqueur) */ |
|
| 364 | - public string $code = ''; |
|
| 365 | - |
|
| 366 | - /** Source des filtres (compatibilité) (?) */ |
|
| 367 | - public array $fonctions = []; |
|
| 368 | - |
|
| 369 | - // obsoletes, conserves provisoirement pour compatibilite |
|
| 370 | - public $tout = false; |
|
| 371 | - public $plat = false; |
|
| 372 | - public $lien = false; |
|
| 10 | + /** Type de noeud */ |
|
| 11 | + public string $type = 'boucle'; |
|
| 12 | + |
|
| 13 | + /** Identifiant de la boucle */ |
|
| 14 | + public string $id_boucle; |
|
| 15 | + |
|
| 16 | + /** Identifiant de la boucle parente */ |
|
| 17 | + public string $id_parent = ''; |
|
| 18 | + |
|
| 19 | + /** Un nom explicite qui peut être affecté manuellement à certaines boucles générées */ |
|
| 20 | + public string $nom = ''; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Partie avant toujours affichee |
|
| 24 | + * |
|
| 25 | + * @var string|array |
|
| 26 | + */ |
|
| 27 | + public $preaff = ''; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Partie optionnelle avant |
|
| 31 | + * |
|
| 32 | + * @var string|array |
|
| 33 | + */ |
|
| 34 | + public $avant = ''; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Pour chaque élément |
|
| 38 | + * |
|
| 39 | + * @var string|array |
|
| 40 | + */ |
|
| 41 | + public $milieu = ''; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Partie optionnelle après |
|
| 45 | + * |
|
| 46 | + * @var string|array |
|
| 47 | + */ |
|
| 48 | + public $apres = ''; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Partie alternative, si pas de résultat dans la boucle |
|
| 52 | + * |
|
| 53 | + * @var string|array |
|
| 54 | + */ |
|
| 55 | + public $altern = ''; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Partie apres toujours affichee |
|
| 59 | + * |
|
| 60 | + * @var string|array |
|
| 61 | + */ |
|
| 62 | + public $postaff = ''; |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * La boucle doit-elle sélectionner la langue ? |
|
| 67 | + * |
|
| 68 | + * Valeurs : '', 'oui', 'non' |
|
| 69 | + */ |
|
| 70 | + public string $lang_select = ''; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 74 | + * |
|
| 75 | + * FIXME: un seul typage (string ?) |
|
| 76 | + * |
|
| 77 | + * @var string|false|null |
|
| 78 | + */ |
|
| 79 | + public $type_requete = null; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * La table est elle optionnelle ? |
|
| 83 | + * |
|
| 84 | + * Si oui, aucune erreur ne sera générée si la table demandée n'est pas présente |
|
| 85 | + */ |
|
| 86 | + public bool $table_optionnelle = false; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Nom du fichier de connexion |
|
| 90 | + */ |
|
| 91 | + public string $sql_serveur = ''; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Paramètres de la boucle |
|
| 95 | + * |
|
| 96 | + * Description des paramètres passés à la boucle, qui servent ensuite |
|
| 97 | + * au calcul des critères |
|
| 98 | + * |
|
| 99 | + * FIXME: type unique. |
|
| 100 | + * @var false|array |
|
| 101 | + * - false: erreur de syntaxe |
|
| 102 | + */ |
|
| 103 | + public $param = []; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Critères de la boucle |
|
| 107 | + * |
|
| 108 | + * FIXME: type array unique. |
|
| 109 | + * |
|
| 110 | + * @var string|Critere[] |
|
| 111 | + * - string: phrasage (code brut). Il reste si erreur de critère |
|
| 112 | + * - array: analyse correcte des critères... |
|
| 113 | + */ |
|
| 114 | + public $criteres = []; |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Textes insérés entre 2 éléments de boucle (critère inter) |
|
| 118 | + * |
|
| 119 | + * @var string[] |
|
| 120 | + */ |
|
| 121 | + public array $separateur = []; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Liste des jointures possibles avec cette table |
|
| 125 | + * |
|
| 126 | + * Les jointures par défaut de la table sont complétées en priorité |
|
| 127 | + * des jointures déclarées explicitement sur la boucle |
|
| 128 | + * |
|
| 129 | + * @see base_trouver_table_dist() |
|
| 130 | + */ |
|
| 131 | + public array $jointures = []; |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Jointures explicites avec cette table |
|
| 135 | + * |
|
| 136 | + * Ces jointures sont utilisées en priorité par rapport aux jointures |
|
| 137 | + * normales possibles pour retrouver les colonnes demandées extérieures |
|
| 138 | + * à la boucle. |
|
| 139 | + * |
|
| 140 | + * @var string|bool |
|
| 141 | + */ |
|
| 142 | + public $jointures_explicites = false; |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Nom de la variable PHP stockant le noms de doublons utilisés "$doublons_index" |
|
| 146 | + */ |
|
| 147 | + public string $doublons = ''; |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Code PHP ajouté au début de chaque itération de boucle. |
|
| 151 | + * |
|
| 152 | + * Utilisé entre autre par les critères {pagination}, {n-a,b}, {a/b}... |
|
| 153 | + */ |
|
| 154 | + public string $partie = ''; |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Nombre de divisions de la boucle, d'éléments à afficher, |
|
| 158 | + * ou de soustractions d'éléments à faire |
|
| 159 | + * |
|
| 160 | + * Dans les critères limitant le nombre d'éléments affichés |
|
| 161 | + * {a,b}, {a,n-b}, {a/b}, {pagination b}, b est affecté à total_parties. |
|
| 162 | + */ |
|
| 163 | + public string $total_parties = ''; |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Code PHP ajouté avant l'itération de boucle. |
|
| 167 | + * |
|
| 168 | + * Utilisé entre autre par les critères {pagination}, {a,b}, {a/b} |
|
| 169 | + * pour initialiser les variables de début et de fin d'itération. |
|
| 170 | + */ |
|
| 171 | + public string $mode_partie = ''; |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Identifiant d'une boucle qui appelle celle-ci de manière récursive |
|
| 175 | + * |
|
| 176 | + * Si une boucle est appelée de manière récursive quelque part par |
|
| 177 | + * une autre boucle comme <BOUCLE_rec(boucle_identifiant) />, cette |
|
| 178 | + * boucle (identifiant) reçoit dans cette propriété l'identifiant |
|
| 179 | + * de l'appelant (rec) |
|
| 180 | + */ |
|
| 181 | + public string $externe = ''; |
|
| 182 | + |
|
| 183 | + // champs pour la construction de la requete SQL |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Liste des champs à récupérer par la boucle |
|
| 187 | + * |
|
| 188 | + * Expression 'table.nom_champ' ou calculée 'nom_champ AS x' |
|
| 189 | + * |
|
| 190 | + * @var string[] |
|
| 191 | + */ |
|
| 192 | + public array $select = []; |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Liste des alias / tables SQL utilisées dans la boucle |
|
| 196 | + * |
|
| 197 | + * L'index est un identifiant (xx dans spip_xx assez souvent) qui servira |
|
| 198 | + * d'alias au nom de la table ; la valeur est le nom de la table SQL désirée. |
|
| 199 | + * |
|
| 200 | + * L'index 0 peut définir le type de sources de données de l'itérateur DATA |
|
| 201 | + * |
|
| 202 | + * @var string[] |
|
| 203 | + */ |
|
| 204 | + public array $from = []; |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Liste des alias / type de jointures utilisées dans la boucle |
|
| 208 | + * |
|
| 209 | + * L'index est le nom d'alias (comme pour la propriété $from), et la valeur |
|
| 210 | + * un type de jointure parmi 'INNER', 'LEFT', 'RIGHT', 'OUTER'. |
|
| 211 | + * |
|
| 212 | + * Lorsque le type n'est pas déclaré pour un alias, c'est 'INNER' |
|
| 213 | + * qui sera utilisé par défaut (créant donc un INNER JOIN). |
|
| 214 | + * |
|
| 215 | + * @var string[] |
|
| 216 | + */ |
|
| 217 | + public array $from_type = []; |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Liste des conditions WHERE de la boucle |
|
| 221 | + * |
|
| 222 | + * Permet de restreindre les éléments retournés par une boucle |
|
| 223 | + * en fonctions des conditions transmises dans ce tableau. |
|
| 224 | + * |
|
| 225 | + * Ce tableau peut avoir plusieurs niveaux de profondeur. |
|
| 226 | + * |
|
| 227 | + * Les éléments du premier niveau sont reliés par des AND, donc |
|
| 228 | + * chaque élément ajouté directement au where par |
|
| 229 | + * $boucle->where[] = array(...) ou $boucle->where[] = "'expression'" |
|
| 230 | + * est une condition AND en plus. |
|
| 231 | + * |
|
| 232 | + * Par contre, lorsqu'on indique un tableau, il peut décrire des relations |
|
| 233 | + * internes différentes. Soit $expr un tableau d'expressions quelconques de 3 valeurs : |
|
| 234 | + * $expr = array(operateur, val1, val2) |
|
| 235 | + * |
|
| 236 | + * Ces 3 valeurs sont des expressions PHP. L'index 0 désigne l'opérateur |
|
| 237 | + * à réaliser tel que : |
|
| 238 | + * |
|
| 239 | + * - "'='" , "'>='", "'<'", "'IN'", "'REGEXP'", "'LIKE'", ... : |
|
| 240 | + * val1 et val2 sont des champs et valeurs à utiliser dans la comparaison |
|
| 241 | + * suivant cet ordre : "val1 operateur val2". |
|
| 242 | + * Exemple : $boucle->where[] = array("'='", "'articles.statut'", "'\"publie\"'"); |
|
| 243 | + * - "'AND'", "'OR'", "'NOT'" : |
|
| 244 | + * dans ce cas val1 et val2 sont également des expressions |
|
| 245 | + * de comparaison complètes, et peuvent être eux-même des tableaux comme $expr |
|
| 246 | + * Exemples : |
|
| 247 | + * $boucle->where[] = array("'OR'", $expr1, $expr2); |
|
| 248 | + * $boucle->where[] = array("'NOT'", $expr); // val2 n'existe pas avec NOT |
|
| 249 | + * |
|
| 250 | + * D'autres noms sont possibles pour l'opérateur (le nombre de valeurs diffère) : |
|
| 251 | + * - "'SELF'", "'SUBSELECT'" : indiquent des sous requêtes |
|
| 252 | + * - "'?'" : indique une condition à faire évaluer (val1 ? val2 : val3) |
|
| 253 | + */ |
|
| 254 | + public array $where = []; |
|
| 255 | + |
|
| 256 | + public array $join = []; |
|
| 257 | + public array $having = []; |
|
| 258 | + public $limit = ''; |
|
| 259 | + public array $group = []; |
|
| 260 | + public array $order = []; |
|
| 261 | + public array $default_order = []; |
|
| 262 | + public string $date = 'date'; |
|
| 263 | + public string $hash = ''; |
|
| 264 | + public $in = ''; |
|
| 265 | + public bool $sous_requete = false; |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Code PHP qui sera ajouté en tout début de la fonction de boucle |
|
| 269 | + * |
|
| 270 | + * Il sert à insérer le code calculant une hierarchie |
|
| 271 | + */ |
|
| 272 | + public string $hierarchie = ''; |
|
| 273 | + |
|
| 274 | + // champs pour la construction du corps PHP |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Description des sources de données de la boucle |
|
| 278 | + * |
|
| 279 | + * Description des données de la boucle issu de trouver_table |
|
| 280 | + * dans le cadre de l'itérateur SQL et contenant au moins l'index 'field'. |
|
| 281 | + * |
|
| 282 | + * @see base_trouver_table_dist() |
|
| 283 | + */ |
|
| 284 | + public array $show = []; |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * Nom de la table SQL principale de la boucle, sans son préfixe |
|
| 288 | + */ |
|
| 289 | + public string $id_table = ''; |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Nom de la clé primaire de la table SQL principale de la boucle |
|
| 293 | + */ |
|
| 294 | + public string $primary = ''; |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Code PHP compilé de la boucle |
|
| 298 | + * |
|
| 299 | + * FIXME: un seul type (string ?) |
|
| 300 | + * |
|
| 301 | + * - false: boucle fautive ? |
|
| 302 | + * |
|
| 303 | + * @var string|false |
|
| 304 | + */ |
|
| 305 | + public $return = ''; |
|
| 306 | + |
|
| 307 | + public $numrows = false; |
|
| 308 | + public $cptrows = false; |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * Description du squelette |
|
| 312 | + * |
|
| 313 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 314 | + * |
|
| 315 | + * Peut contenir les index : |
|
| 316 | + * |
|
| 317 | + * - nom : Nom du fichier de cache |
|
| 318 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 319 | + * - sourcefile : Chemin du squelette |
|
| 320 | + * - squelette : Code du squelette |
|
| 321 | + * - id_mere : Identifiant de la boucle parente |
|
| 322 | + * - documents : Pour embed et img dans les textes |
|
| 323 | + * - session : Pour un cache sessionné par auteur |
|
| 324 | + * - niv : Niveau de tabulation |
|
| 325 | + */ |
|
| 326 | + public array $descr = []; |
|
| 327 | + |
|
| 328 | + /** Numéro de ligne dans le code source du squelette */ |
|
| 329 | + public int $ligne = 0; |
|
| 330 | + |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * table pour stocker les modificateurs de boucle tels que tout, plat ..., |
|
| 334 | + * utilisable par les plugins egalement |
|
| 335 | + * |
|
| 336 | + * @var array<string, mixed> |
|
| 337 | + */ |
|
| 338 | + public array $modificateur = []; |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * Type d'itérateur utilisé pour cette boucle |
|
| 342 | + * |
|
| 343 | + * - 'SQL' dans le cadre d'une boucle sur une table SQL |
|
| 344 | + * - 'DATA' pour l'itérateur DATA, ... |
|
| 345 | + * |
|
| 346 | + * @var string |
|
| 347 | + */ |
|
| 348 | + public string $iterateur = ''; // type d'iterateur |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * @var array $debug Textes qui seront insérés dans l’entête de boucle du mode debug |
|
| 352 | + */ |
|
| 353 | + public array $debug = []; |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * Index de la boucle dont le champ présent dans cette boucle est originaire, |
|
| 357 | + * notamment si le champ a été trouve dans une boucle parente |
|
| 358 | + * |
|
| 359 | + * Tableau nom du champ => index de boucle |
|
| 360 | + */ |
|
| 361 | + public array $index_champ = []; |
|
| 362 | + |
|
| 363 | + /** Résultat de la compilation (?) (sert au débusqueur) */ |
|
| 364 | + public string $code = ''; |
|
| 365 | + |
|
| 366 | + /** Source des filtres (compatibilité) (?) */ |
|
| 367 | + public array $fonctions = []; |
|
| 368 | + |
|
| 369 | + // obsoletes, conserves provisoirement pour compatibilite |
|
| 370 | + public $tout = false; |
|
| 371 | + public $plat = false; |
|
| 372 | + public $lien = false; |
|
| 373 | 373 | } |
@@ -7,63 +7,63 @@ |
||
| 7 | 7 | **/ |
| 8 | 8 | class Inclure |
| 9 | 9 | { |
| 10 | - /** Type de noeud */ |
|
| 11 | - public string $type = 'include'; |
|
| 10 | + /** Type de noeud */ |
|
| 11 | + public string $type = 'include'; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Nom d'un fichier inclu |
|
| 15 | - * |
|
| 16 | - * - Objet Texte si inclusion d'un autre squelette |
|
| 17 | - * - chaîne si inclusion d'un fichier PHP directement |
|
| 18 | - * |
|
| 19 | - * @var string|Texte |
|
| 20 | - */ |
|
| 21 | - public $texte; |
|
| 13 | + /** |
|
| 14 | + * Nom d'un fichier inclu |
|
| 15 | + * |
|
| 16 | + * - Objet Texte si inclusion d'un autre squelette |
|
| 17 | + * - chaîne si inclusion d'un fichier PHP directement |
|
| 18 | + * |
|
| 19 | + * @var string|Texte |
|
| 20 | + */ |
|
| 21 | + public $texte; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Inutilisé, propriété générique de l'AST |
|
| 25 | - * |
|
| 26 | - * @var string|array |
|
| 27 | - */ |
|
| 28 | - public $avant = ''; |
|
| 23 | + /** |
|
| 24 | + * Inutilisé, propriété générique de l'AST |
|
| 25 | + * |
|
| 26 | + * @var string|array |
|
| 27 | + */ |
|
| 28 | + public $avant = ''; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Inutilisé, propriété générique de l'AST |
|
| 32 | - * |
|
| 33 | - * @var string|array |
|
| 34 | - */ |
|
| 35 | - public $apres = ''; |
|
| 30 | + /** |
|
| 31 | + * Inutilisé, propriété générique de l'AST |
|
| 32 | + * |
|
| 33 | + * @var string|array |
|
| 34 | + */ |
|
| 35 | + public $apres = ''; |
|
| 36 | 36 | |
| 37 | - /** Numéro de ligne dans le code source du squelette */ |
|
| 38 | - public int $ligne = 0; |
|
| 37 | + /** Numéro de ligne dans le code source du squelette */ |
|
| 38 | + public int $ligne = 0; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Valeurs des paramètres |
|
| 42 | - * |
|
| 43 | - * FIXME: type unique. |
|
| 44 | - * @var false|array |
|
| 45 | - * - false: erreur de syntaxe |
|
| 46 | - */ |
|
| 47 | - public $param = []; |
|
| 40 | + /** |
|
| 41 | + * Valeurs des paramètres |
|
| 42 | + * |
|
| 43 | + * FIXME: type unique. |
|
| 44 | + * @var false|array |
|
| 45 | + * - false: erreur de syntaxe |
|
| 46 | + */ |
|
| 47 | + public $param = []; |
|
| 48 | 48 | |
| 49 | - /** Source des filtres (compatibilité) (?) */ |
|
| 50 | - public array $fonctions = []; |
|
| 49 | + /** Source des filtres (compatibilité) (?) */ |
|
| 50 | + public array $fonctions = []; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Description du squelette |
|
| 54 | - * |
|
| 55 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 56 | - * |
|
| 57 | - * Peut contenir les index : |
|
| 58 | - * |
|
| 59 | - * - nom : Nom du fichier de cache |
|
| 60 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 61 | - * - sourcefile : Chemin du squelette |
|
| 62 | - * - squelette : Code du squelette |
|
| 63 | - * - id_mere : Identifiant de la boucle parente |
|
| 64 | - * - documents : Pour embed et img dans les textes |
|
| 65 | - * - session : Pour un cache sessionné par auteur |
|
| 66 | - * - niv : Niveau de tabulation |
|
| 67 | - */ |
|
| 68 | - public array $descr = []; |
|
| 52 | + /** |
|
| 53 | + * Description du squelette |
|
| 54 | + * |
|
| 55 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 56 | + * |
|
| 57 | + * Peut contenir les index : |
|
| 58 | + * |
|
| 59 | + * - nom : Nom du fichier de cache |
|
| 60 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 61 | + * - sourcefile : Chemin du squelette |
|
| 62 | + * - squelette : Code du squelette |
|
| 63 | + * - id_mere : Identifiant de la boucle parente |
|
| 64 | + * - documents : Pour embed et img dans les textes |
|
| 65 | + * - session : Pour un cache sessionné par auteur |
|
| 66 | + * - niv : Niveau de tabulation |
|
| 67 | + */ |
|
| 68 | + public array $descr = []; |
|
| 69 | 69 | } |
@@ -7,30 +7,30 @@ |
||
| 7 | 7 | **/ |
| 8 | 8 | class Texte |
| 9 | 9 | { |
| 10 | - /** Type de noeud */ |
|
| 11 | - public string $type = 'texte'; |
|
| 10 | + /** Type de noeud */ |
|
| 11 | + public string $type = 'texte'; |
|
| 12 | 12 | |
| 13 | - /** Le texte */ |
|
| 14 | - public string $texte; |
|
| 13 | + /** Le texte */ |
|
| 14 | + public string $texte; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Contenu avant le texte. |
|
| 18 | - * |
|
| 19 | - * Vide ou apostrophe simple ou double si le texte en était entouré |
|
| 20 | - * |
|
| 21 | - * @var string|array |
|
| 22 | - */ |
|
| 23 | - public $avant = ''; |
|
| 16 | + /** |
|
| 17 | + * Contenu avant le texte. |
|
| 18 | + * |
|
| 19 | + * Vide ou apostrophe simple ou double si le texte en était entouré |
|
| 20 | + * |
|
| 21 | + * @var string|array |
|
| 22 | + */ |
|
| 23 | + public $avant = ''; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Contenu après le texte. |
|
| 27 | - * |
|
| 28 | - * Vide ou apostrophe simple ou double si le texte en était entouré |
|
| 29 | - * |
|
| 30 | - * @var string|array |
|
| 31 | - */ |
|
| 32 | - public $apres = ''; |
|
| 25 | + /** |
|
| 26 | + * Contenu après le texte. |
|
| 27 | + * |
|
| 28 | + * Vide ou apostrophe simple ou double si le texte en était entouré |
|
| 29 | + * |
|
| 30 | + * @var string|array |
|
| 31 | + */ |
|
| 32 | + public $apres = ''; |
|
| 33 | 33 | |
| 34 | - /** Numéro de ligne dans le code source du squelette */ |
|
| 35 | - public int $ligne = 0; |
|
| 34 | + /** Numéro de ligne dans le code source du squelette */ |
|
| 35 | + public int $ligne = 0; |
|
| 36 | 36 | } |
@@ -9,16 +9,16 @@ |
||
| 9 | 9 | **/ |
| 10 | 10 | class Polyglotte |
| 11 | 11 | { |
| 12 | - /** Type de noeud */ |
|
| 13 | - public string $type = 'polyglotte'; |
|
| 12 | + /** Type de noeud */ |
|
| 13 | + public string $type = 'polyglotte'; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Tableau des traductions possibles classées par langue |
|
| 17 | - * |
|
| 18 | - * Tableau code de langue => texte |
|
| 19 | - */ |
|
| 20 | - public array $traductions = []; |
|
| 15 | + /** |
|
| 16 | + * Tableau des traductions possibles classées par langue |
|
| 17 | + * |
|
| 18 | + * Tableau code de langue => texte |
|
| 19 | + */ |
|
| 20 | + public array $traductions = []; |
|
| 21 | 21 | |
| 22 | - /** Numéro de ligne dans le code source du squelette */ |
|
| 23 | - public int $ligne = 0; |
|
| 22 | + /** Numéro de ligne dans le code source du squelette */ |
|
| 23 | + public int $ligne = 0; |
|
| 24 | 24 | } |
@@ -14,33 +14,33 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Contexte |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Description du squelette |
|
| 19 | - * |
|
| 20 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 21 | - * |
|
| 22 | - * Peut contenir les index : |
|
| 23 | - * |
|
| 24 | - * - nom : Nom du fichier de cache |
|
| 25 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 26 | - * - sourcefile : Chemin du squelette |
|
| 27 | - * - squelette : Code du squelette |
|
| 28 | - * - id_mere : Identifiant de la boucle parente |
|
| 29 | - * - documents : Pour embed et img dans les textes |
|
| 30 | - * - session : Pour un cache sessionné par auteur |
|
| 31 | - * - niv : Niveau de tabulation |
|
| 32 | - */ |
|
| 33 | - public array $descr = []; |
|
| 17 | + /** |
|
| 18 | + * Description du squelette |
|
| 19 | + * |
|
| 20 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 21 | + * |
|
| 22 | + * Peut contenir les index : |
|
| 23 | + * |
|
| 24 | + * - nom : Nom du fichier de cache |
|
| 25 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 26 | + * - sourcefile : Chemin du squelette |
|
| 27 | + * - squelette : Code du squelette |
|
| 28 | + * - id_mere : Identifiant de la boucle parente |
|
| 29 | + * - documents : Pour embed et img dans les textes |
|
| 30 | + * - session : Pour un cache sessionné par auteur |
|
| 31 | + * - niv : Niveau de tabulation |
|
| 32 | + */ |
|
| 33 | + public array $descr = []; |
|
| 34 | 34 | |
| 35 | - /** Identifiant de la boucle */ |
|
| 36 | - public string $id_boucle = ''; |
|
| 35 | + /** Identifiant de la boucle */ |
|
| 36 | + public string $id_boucle = ''; |
|
| 37 | 37 | |
| 38 | - /** Numéro de ligne dans le code source du squelette */ |
|
| 39 | - public int $ligne = 0; |
|
| 38 | + /** Numéro de ligne dans le code source du squelette */ |
|
| 39 | + public int $ligne = 0; |
|
| 40 | 40 | |
| 41 | - /** Langue d'exécution */ |
|
| 42 | - public string $lang = ''; |
|
| 41 | + /** Langue d'exécution */ |
|
| 42 | + public string $lang = ''; |
|
| 43 | 43 | |
| 44 | - /** Résultat de la compilation: toujours une expression PHP */ |
|
| 45 | - public string $code = ''; |
|
| 44 | + /** Résultat de la compilation: toujours une expression PHP */ |
|
| 45 | + public string $code = ''; |
|
| 46 | 46 | } |