@@ -11,127 +11,127 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function format_boucle_html($preaff, $avant, $nom, $type, $crit, $corps, $apres, $altern, $postaff, $prof) { |
| 18 | - $preaff = $preaff ? "<BB$nom>$preaff" : ''; |
|
| 19 | - $avant = $avant ? "<B$nom>$avant" : ''; |
|
| 20 | - $apres = $apres ? "$apres</B$nom>" : ''; |
|
| 21 | - $altern = $altern ? "$altern<//B$nom>" : ''; |
|
| 22 | - $postaff = $postaff ? "$postaff</BB$nom>" : ''; |
|
| 23 | - if (!$corps) { |
|
| 24 | - $corps = ' />'; |
|
| 25 | - } else { |
|
| 26 | - $corps = ">$corps</BOUCLE$nom>"; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - return "$preaff$avant<BOUCLE$nom($type)$crit$corps$apres$altern$postaff"; |
|
| 18 | + $preaff = $preaff ? "<BB$nom>$preaff" : ''; |
|
| 19 | + $avant = $avant ? "<B$nom>$avant" : ''; |
|
| 20 | + $apres = $apres ? "$apres</B$nom>" : ''; |
|
| 21 | + $altern = $altern ? "$altern<//B$nom>" : ''; |
|
| 22 | + $postaff = $postaff ? "$postaff</BB$nom>" : ''; |
|
| 23 | + if (!$corps) { |
|
| 24 | + $corps = ' />'; |
|
| 25 | + } else { |
|
| 26 | + $corps = ">$corps</BOUCLE$nom>"; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + return "$preaff$avant<BOUCLE$nom($type)$crit$corps$apres$altern$postaff"; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function format_inclure_html($file, $args, $prof) { |
| 33 | - if (strpos($file, '#') === false) { |
|
| 34 | - $t = $file ? ('(' . $file . ')') : ''; |
|
| 35 | - } else { |
|
| 36 | - $t = '{fond=' . $file . '}'; |
|
| 37 | - } |
|
| 38 | - $args = !$args ? '' : ('{' . join(', ', $args) . '}'); |
|
| 39 | - |
|
| 40 | - return ('<INCLURE' . $t . $args . '>'); |
|
| 33 | + if (strpos($file, '#') === false) { |
|
| 34 | + $t = $file ? ('(' . $file . ')') : ''; |
|
| 35 | + } else { |
|
| 36 | + $t = '{fond=' . $file . '}'; |
|
| 37 | + } |
|
| 38 | + $args = !$args ? '' : ('{' . join(', ', $args) . '}'); |
|
| 39 | + |
|
| 40 | + return ('<INCLURE' . $t . $args . '>'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | function format_polyglotte_html($args, $prof) { |
| 44 | - $contenu = []; |
|
| 45 | - foreach ($args as $l => $t) { |
|
| 46 | - $contenu[] = ($l ? "[$l]" : '') . $t; |
|
| 47 | - } |
|
| 44 | + $contenu = []; |
|
| 45 | + foreach ($args as $l => $t) { |
|
| 46 | + $contenu[] = ($l ? "[$l]" : '') . $t; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return ('<multi>' . join(' ', $contenu) . '</multi>'); |
|
| 49 | + return ('<multi>' . join(' ', $contenu) . '</multi>'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function format_idiome_html($nom, $module, $args, $filtres, $prof) { |
| 53 | - foreach ($args as $k => $v) { |
|
| 54 | - $args[$k] = "$k=$v"; |
|
| 55 | - } |
|
| 56 | - $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
|
| 53 | + foreach ($args as $k => $v) { |
|
| 54 | + $args[$k] = "$k=$v"; |
|
| 55 | + } |
|
| 56 | + $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
|
| 57 | 57 | |
| 58 | - return ('<:' . ($module ? "$module:" : '') . $nom . $args . $filtres . ':>'); |
|
| 58 | + return ('<:' . ($module ? "$module:" : '') . $nom . $args . $filtres . ':>'); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) { |
| 62 | - $nom = '#' |
|
| 63 | - . ($boucle ? ($boucle . ':') : '') |
|
| 64 | - . $nom |
|
| 65 | - . $etoile |
|
| 66 | - . $args |
|
| 67 | - . $filtres; |
|
| 62 | + $nom = '#' |
|
| 63 | + . ($boucle ? ($boucle . ':') : '') |
|
| 64 | + . $nom |
|
| 65 | + . $etoile |
|
| 66 | + . $args |
|
| 67 | + . $filtres; |
|
| 68 | 68 | |
| 69 | - // Determiner si c'est un champ etendu, |
|
| 69 | + // Determiner si c'est un champ etendu, |
|
| 70 | 70 | |
| 71 | - $s = ($avant or $apres or $filtres |
|
| 72 | - or (strpos($args, '(#') !== false)); |
|
| 71 | + $s = ($avant or $apres or $filtres |
|
| 72 | + or (strpos($args, '(#') !== false)); |
|
| 73 | 73 | |
| 74 | - return ($s ? "[$avant($nom)$apres]" : $nom); |
|
| 74 | + return ($s ? "[$avant($nom)$apres]" : $nom); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | function format_critere_html($critere) { |
| 78 | - foreach ($critere as $k => $crit) { |
|
| 79 | - $crit_s = ''; |
|
| 80 | - foreach ($crit as $operande) { |
|
| 81 | - [$type, $valeur] = $operande; |
|
| 82 | - if ($type == 'champ' and $valeur[0] == '[') { |
|
| 83 | - $valeur = substr($valeur, 1, -1); |
|
| 84 | - if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) { |
|
| 85 | - $valeur = substr($valeur, 1, -1); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - $crit_s .= $valeur; |
|
| 89 | - } |
|
| 90 | - $critere[$k] = $crit_s; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - return (!$critere ? '' : ('{' . join(',', $critere) . '}')); |
|
| 78 | + foreach ($critere as $k => $crit) { |
|
| 79 | + $crit_s = ''; |
|
| 80 | + foreach ($crit as $operande) { |
|
| 81 | + [$type, $valeur] = $operande; |
|
| 82 | + if ($type == 'champ' and $valeur[0] == '[') { |
|
| 83 | + $valeur = substr($valeur, 1, -1); |
|
| 84 | + if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) { |
|
| 85 | + $valeur = substr($valeur, 1, -1); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + $crit_s .= $valeur; |
|
| 89 | + } |
|
| 90 | + $critere[$k] = $crit_s; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + return (!$critere ? '' : ('{' . join(',', $critere) . '}')); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | function format_liste_html($fonc, $args, $prof) { |
| 97 | - return ((($fonc !== '') ? "|$fonc" : $fonc) |
|
| 98 | - . (!$args ? '' : ('{' . join(',', $args) . '}'))); |
|
| 97 | + return ((($fonc !== '') ? "|$fonc" : $fonc) |
|
| 98 | + . (!$args ? '' : ('{' . join(',', $args) . '}'))); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes |
| 102 | 102 | function format_suite_html($args) { |
| 103 | - for ($i = 0; $i < (is_countable($args) ? count($args) : 0) - 1; $i++) { |
|
| 104 | - [$texte, $type] = $args[$i]; |
|
| 105 | - [$texte2, $type2] = $args[$i + 1]; |
|
| 106 | - if (!$texte or !$texte2) { |
|
| 107 | - continue; |
|
| 108 | - } |
|
| 109 | - $c1 = substr($texte, -1); |
|
| 110 | - if ($type2 !== 'texte') { |
|
| 111 | - // si un texte se termine par ( et est suivi d'un champ |
|
| 112 | - // ou assimiles, forcer la notation pleine |
|
| 113 | - if ($c1 == '(' and substr($texte2, 0, 1) == '#') { |
|
| 114 | - $args[$i + 1][0] = '[(' . $texte2 . ')]'; |
|
| 115 | - } |
|
| 116 | - } else { |
|
| 117 | - if ($type == 'texte') { |
|
| 118 | - continue; |
|
| 119 | - } |
|
| 120 | - // si un champ ou assimiles est suivi d'un texte |
|
| 121 | - // et si celui-ci commence par un caractere de champ |
|
| 122 | - // forcer la notation pleine |
|
| 123 | - if ( |
|
| 124 | - ($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|') |
|
| 125 | - or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2)) |
|
| 126 | - ) { |
|
| 127 | - $args[$i][0] = '[(' . $texte . ')]'; |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - return join('', array_map(fn($arg) => reset($arg), $args)); |
|
| 103 | + for ($i = 0; $i < (is_countable($args) ? count($args) : 0) - 1; $i++) { |
|
| 104 | + [$texte, $type] = $args[$i]; |
|
| 105 | + [$texte2, $type2] = $args[$i + 1]; |
|
| 106 | + if (!$texte or !$texte2) { |
|
| 107 | + continue; |
|
| 108 | + } |
|
| 109 | + $c1 = substr($texte, -1); |
|
| 110 | + if ($type2 !== 'texte') { |
|
| 111 | + // si un texte se termine par ( et est suivi d'un champ |
|
| 112 | + // ou assimiles, forcer la notation pleine |
|
| 113 | + if ($c1 == '(' and substr($texte2, 0, 1) == '#') { |
|
| 114 | + $args[$i + 1][0] = '[(' . $texte2 . ')]'; |
|
| 115 | + } |
|
| 116 | + } else { |
|
| 117 | + if ($type == 'texte') { |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 120 | + // si un champ ou assimiles est suivi d'un texte |
|
| 121 | + // et si celui-ci commence par un caractere de champ |
|
| 122 | + // forcer la notation pleine |
|
| 123 | + if ( |
|
| 124 | + ($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|') |
|
| 125 | + or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2)) |
|
| 126 | + ) { |
|
| 127 | + $args[$i][0] = '[(' . $texte . ')]'; |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + return join('', array_map(fn($arg) => reset($arg), $args)); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | function format_texte_html($texte) { |
| 136 | - return $texte; |
|
| 136 | + return $texte; |
|
| 137 | 137 | } |
@@ -31,36 +31,36 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | function format_inclure_html($file, $args, $prof) { |
| 33 | 33 | if (strpos($file, '#') === false) { |
| 34 | - $t = $file ? ('(' . $file . ')') : ''; |
|
| 34 | + $t = $file ? ('('.$file.')') : ''; |
|
| 35 | 35 | } else { |
| 36 | - $t = '{fond=' . $file . '}'; |
|
| 36 | + $t = '{fond='.$file.'}'; |
|
| 37 | 37 | } |
| 38 | - $args = !$args ? '' : ('{' . join(', ', $args) . '}'); |
|
| 38 | + $args = !$args ? '' : ('{'.join(', ', $args).'}'); |
|
| 39 | 39 | |
| 40 | - return ('<INCLURE' . $t . $args . '>'); |
|
| 40 | + return ('<INCLURE'.$t.$args.'>'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | function format_polyglotte_html($args, $prof) { |
| 44 | 44 | $contenu = []; |
| 45 | 45 | foreach ($args as $l => $t) { |
| 46 | - $contenu[] = ($l ? "[$l]" : '') . $t; |
|
| 46 | + $contenu[] = ($l ? "[$l]" : '').$t; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - return ('<multi>' . join(' ', $contenu) . '</multi>'); |
|
| 49 | + return ('<multi>'.join(' ', $contenu).'</multi>'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function format_idiome_html($nom, $module, $args, $filtres, $prof) { |
| 53 | 53 | foreach ($args as $k => $v) { |
| 54 | 54 | $args[$k] = "$k=$v"; |
| 55 | 55 | } |
| 56 | - $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
|
| 56 | + $args = (!$args ? '' : ('{'.join(',', $args).'}')); |
|
| 57 | 57 | |
| 58 | - return ('<:' . ($module ? "$module:" : '') . $nom . $args . $filtres . ':>'); |
|
| 58 | + return ('<:'.($module ? "$module:" : '').$nom.$args.$filtres.':>'); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) { |
| 62 | 62 | $nom = '#' |
| 63 | - . ($boucle ? ($boucle . ':') : '') |
|
| 63 | + . ($boucle ? ($boucle.':') : '') |
|
| 64 | 64 | . $nom |
| 65 | 65 | . $etoile |
| 66 | 66 | . $args |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | $critere[$k] = $crit_s; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - return (!$critere ? '' : ('{' . join(',', $critere) . '}')); |
|
| 93 | + return (!$critere ? '' : ('{'.join(',', $critere).'}')); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | function format_liste_html($fonc, $args, $prof) { |
| 97 | 97 | return ((($fonc !== '') ? "|$fonc" : $fonc) |
| 98 | - . (!$args ? '' : ('{' . join(',', $args) . '}'))); |
|
| 98 | + . (!$args ? '' : ('{'.join(',', $args).'}'))); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | // si un texte se termine par ( et est suivi d'un champ |
| 112 | 112 | // ou assimiles, forcer la notation pleine |
| 113 | 113 | if ($c1 == '(' and substr($texte2, 0, 1) == '#') { |
| 114 | - $args[$i + 1][0] = '[(' . $texte2 . ')]'; |
|
| 114 | + $args[$i + 1][0] = '[('.$texte2.')]'; |
|
| 115 | 115 | } |
| 116 | 116 | } else { |
| 117 | 117 | if ($type == 'texte') { |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | ($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|') |
| 125 | 125 | or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2)) |
| 126 | 126 | ) { |
| 127 | - $args[$i][0] = '[(' . $texte . ')]'; |
|
| 127 | + $args[$i][0] = '[('.$texte.')]'; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } else { |
| 81 | 81 | // Preparer l'appel de la fonction principale du squelette |
| 82 | 82 | |
| 83 | - spip_timer($a = 'calcul page ' . random_int(0, 1000)); |
|
| 83 | + spip_timer($a = 'calcul page '.random_int(0, 1000)); |
|
| 84 | 84 | |
| 85 | 85 | // On cree un marqueur de notes unique lie a cette composition |
| 86 | 86 | // et on enregistre l'etat courant des globales de notes... |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | try { |
| 113 | 113 | $page = $fonc(['cache' => $cache], [$contexte]); |
| 114 | 114 | } catch (Throwable $e) { |
| 115 | - $msg = _T('zbug_erreur_execution_page') . " $sourcefile"; |
|
| 116 | - $full_msg = $msg . ' | File ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 115 | + $msg = _T('zbug_erreur_execution_page')." $sourcefile"; |
|
| 116 | + $full_msg = $msg.' | File '.$e->getFile().' Line '.$e->getLine().' : '.$e->getMessage(); |
|
| 117 | 117 | $full_msg = str_replace(_ROOT_RACINE, '[…]/', $full_msg); |
| 118 | 118 | $corps = "<pre>$msg</pre>"; |
| 119 | 119 | $page = analyse_resultat_skel($fond, ['cache' => $cache], $corps, $sourcefile); |
@@ -144,17 +144,17 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $profile = spip_timer($a); |
| 146 | 146 | spip_log("calcul ($profile) [$skel] $infos" |
| 147 | - . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 147 | + . ' ('.strlen($page['texte']).' octets)'); |
|
| 148 | 148 | |
| 149 | 149 | if (defined('_CALCUL_PROFILER') and intval($profile) > _CALCUL_PROFILER) { |
| 150 | 150 | spip_log("calcul ($profile) [$skel] $infos" |
| 151 | - . ' (' . strlen($page['texte']) . ' octets) | ' . $_SERVER['REQUEST_URI'], 'profiler' . _LOG_AVERTISSEMENT); |
|
| 151 | + . ' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'], 'profiler'._LOG_AVERTISSEMENT); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | if ($debug) { |
| 155 | 155 | // si c'est ce que demande le debusqueur, lui passer la main |
| 156 | 156 | $t = strlen($page['texte']) ? $page['texte'] : ' '; |
| 157 | - $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 157 | + $GLOBALS['debug_objets']['resultat'][$fonc.'tout'] = $t; |
|
| 158 | 158 | $GLOBALS['debug_objets']['courant'] = $courant; |
| 159 | 159 | $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
| 160 | 160 | if ( |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
| 186 | 186 | $page['sourcefile'] = $sourcefile; |
| 187 | 187 | $page['texte'] = |
| 188 | - "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . '</h6>' . $page['texte'] . '</div>' |
|
| 188 | + "<div class='inclure_blocs'><h6>".$page['sourcefile'].'</h6>'.$page['texte'].'</div>' |
|
| 189 | 189 | . ($js_inclus ? '' : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
| 190 | 190 | $js_inclus = true; |
| 191 | 191 | } |
@@ -222,14 +222,14 @@ discard block |
||
| 222 | 222 | $val = ''; |
| 223 | 223 | } elseif (is_array($val)) { |
| 224 | 224 | if ($profondeur_max > 0) { |
| 225 | - $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 225 | + $val = 'array:'.count($val).'('.presenter_contexte($val, $profondeur_max - 1, 3).')'; |
|
| 226 | 226 | } else { |
| 227 | - $val = 'array:' . count($val); |
|
| 227 | + $val = 'array:'.count($val); |
|
| 228 | 228 | } |
| 229 | 229 | } elseif (is_object($val)) { |
| 230 | 230 | $val = get_class($val); |
| 231 | 231 | } elseif (strlen("$val") > 30) { |
| 232 | - $val = substr("$val", 0, 29) . '…'; |
|
| 232 | + $val = substr("$val", 0, 29).'…'; |
|
| 233 | 233 | if (strstr($val, ' ')) { |
| 234 | 234 | $val = "'$val'"; |
| 235 | 235 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | } elseif (!strlen($val)) { |
| 239 | 239 | $val = "''"; |
| 240 | 240 | } |
| 241 | - $infos[] = $var . '=' . $val; |
|
| 241 | + $infos[] = $var.'='.$val; |
|
| 242 | 242 | } |
| 243 | 243 | return join(', ', $infos); |
| 244 | 244 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | . "?php include_spip('inc/headers');redirige_par_entete('" |
| 307 | 307 | . texte_script($url) |
| 308 | 308 | . "','',$status);" |
| 309 | - . '?' . '>', |
|
| 309 | + . '?'.'>', |
|
| 310 | 310 | 'process_ins' => 'php', |
| 311 | 311 | 'status' => $status |
| 312 | 312 | ]; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_fichiers_fonctions(); |
@@ -30,177 +30,177 @@ discard block |
||
| 30 | 30 | # En cas d'erreur process_ins est absent et texte est un tableau de 2 chaines |
| 31 | 31 | |
| 32 | 32 | function public_parametrer_dist($fond, $contexte = '', $cache = '', string $connect = '') { |
| 33 | - static $composer, $styliser, $notes = null; |
|
| 34 | - $page = tester_redirection($fond, $contexte, $connect); |
|
| 35 | - if ($page) { |
|
| 36 | - return $page; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - if (isset($contexte['lang'])) { |
|
| 40 | - $lang = $contexte['lang']; |
|
| 41 | - } elseif (!isset($lang)) { |
|
| 42 | - $lang = $GLOBALS['meta']['langue_site']; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']); |
|
| 46 | - if ($select) { |
|
| 47 | - $select = lang_select($lang); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
|
| 51 | - |
|
| 52 | - if (!$styliser) { |
|
| 53 | - $styliser = charger_fonction('styliser', 'public'); |
|
| 54 | - } |
|
| 55 | - [$skel, $mime_type, $gram, $sourcefile] = |
|
| 56 | - $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
|
| 57 | - |
|
| 58 | - if ($skel) { |
|
| 59 | - // sauver le nom de l'eventuel squelette en cours d'execution |
|
| 60 | - // (recursion possible a cause des modeles) |
|
| 61 | - if ($debug) { |
|
| 62 | - $courant = $GLOBALS['debug_objets']['courant'] ?? null; |
|
| 63 | - $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - // charger le squelette en specifiant les langages cibles et source |
|
| 67 | - // au cas il faudrait le compiler (source posterieure au resultat) |
|
| 68 | - |
|
| 69 | - if (!$composer) { |
|
| 70 | - $composer = charger_fonction('composer', 'public'); |
|
| 71 | - } |
|
| 72 | - $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
|
| 73 | - } else { |
|
| 74 | - $fonc = ''; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
|
| 78 | - $page = $fonc; |
|
| 79 | - } else { |
|
| 80 | - // Preparer l'appel de la fonction principale du squelette |
|
| 81 | - |
|
| 82 | - spip_timer($a = 'calcul page ' . random_int(0, 1000)); |
|
| 83 | - |
|
| 84 | - // On cree un marqueur de notes unique lie a cette composition |
|
| 85 | - // et on enregistre l'etat courant des globales de notes... |
|
| 86 | - if (is_null($notes)) { |
|
| 87 | - $notes = charger_fonction('notes', 'inc', true); |
|
| 88 | - } |
|
| 89 | - if ($notes) { |
|
| 90 | - $notes('', 'empiler'); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // Rajouter d'office ces deux parametres |
|
| 94 | - // (mais vaudrait mieux que le compilateur sache le simuler |
|
| 95 | - // car ca interdit l'usage de criteres conditionnels dessus). |
|
| 96 | - if (!isset($contexte['date'])) { |
|
| 97 | - $contexte['date'] = date('Y-m-d H:i:s'); |
|
| 98 | - $contexte['date_default'] = true; |
|
| 99 | - } else { |
|
| 100 | - $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - if (!isset($contexte['date_redac'])) { |
|
| 104 | - $contexte['date_redac'] = date('Y-m-d H:i:s'); |
|
| 105 | - $contexte['date_redac_default'] = true; |
|
| 106 | - } else { |
|
| 107 | - $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - // Passer le nom du cache pour produire sa destruction automatique |
|
| 111 | - try { |
|
| 112 | - $page = $fonc(['cache' => $cache], [$contexte]); |
|
| 113 | - } catch (Throwable $e) { |
|
| 114 | - $msg = _T('zbug_erreur_execution_page') . " $sourcefile"; |
|
| 115 | - $full_msg = $msg . ' | File ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 116 | - $full_msg = str_replace(_ROOT_RACINE, '[…]/', $full_msg); |
|
| 117 | - $corps = "<pre>$msg</pre>"; |
|
| 118 | - $page = analyse_resultat_skel($fond, ['cache' => $cache], $corps, $sourcefile); |
|
| 119 | - erreur_squelette($full_msg); |
|
| 120 | - unset($msg, $full_msg, $corps); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // Restituer les globales de notes telles qu'elles etaient avant l'appel |
|
| 124 | - // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent* |
|
| 125 | - // etre dans son resultat, autrement elles ne seraient pas prises en |
|
| 126 | - // compte a chaque calcul d'un texte contenant un modele, mais seulement |
|
| 127 | - // quand le modele serait calcule, et on aurait des resultats incoherents) |
|
| 128 | - if ($notes) { |
|
| 129 | - $notes('', 'depiler'); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // reinjecter en dynamique la pile des notes |
|
| 133 | - // si il y a des inclure dynamiques |
|
| 134 | - // si la pile n'est pas vide |
|
| 135 | - // la generalisation de cette injection permettrait de corriger le point juste au dessus |
|
| 136 | - // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
|
| 137 | - if ($notes) { |
|
| 138 | - $page['notes'] = $notes('', 'sauver_etat'); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - // spip_log: un joli contexte |
|
| 142 | - $infos = presenter_contexte(array_filter($contexte)); |
|
| 143 | - |
|
| 144 | - $profile = spip_timer($a); |
|
| 145 | - spip_log("calcul ($profile) [$skel] $infos" |
|
| 146 | - . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 147 | - |
|
| 148 | - if (defined('_CALCUL_PROFILER') and intval($profile) > _CALCUL_PROFILER) { |
|
| 149 | - spip_log("calcul ($profile) [$skel] $infos" |
|
| 150 | - . ' (' . strlen($page['texte']) . ' octets) | ' . $_SERVER['REQUEST_URI'], 'profiler' . _LOG_AVERTISSEMENT); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - if ($debug) { |
|
| 154 | - // si c'est ce que demande le debusqueur, lui passer la main |
|
| 155 | - $t = strlen($page['texte']) ? $page['texte'] : ' '; |
|
| 156 | - $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 157 | - $GLOBALS['debug_objets']['courant'] = $courant; |
|
| 158 | - $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
|
| 159 | - if ( |
|
| 160 | - $GLOBALS['debug_objets']['sourcefile'] |
|
| 161 | - and (_request('var_mode_objet') == $fonc) |
|
| 162 | - and (_request('var_mode_affiche') == 'resultat') |
|
| 163 | - ) { |
|
| 164 | - erreur_squelette(); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - // Si #CACHE{} n'etait pas la, le mettre a $delais |
|
| 168 | - if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 169 | - // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
|
| 170 | - // si aucun #CACHE{} spécifié |
|
| 171 | - // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
|
| 172 | - // entre public et prive |
|
| 173 | - if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) { |
|
| 174 | - $page['entetes']['X-Spip-Cache'] = 0; |
|
| 175 | - } else { |
|
| 176 | - $page['entetes']['X-Spip-Cache'] = $GLOBALS['delais'] ?? 36000; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - $page['contexte'] = $contexte; |
|
| 181 | - |
|
| 182 | - // faire remonter le fichier source |
|
| 183 | - static $js_inclus = false; |
|
| 184 | - if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
|
| 185 | - $page['sourcefile'] = $sourcefile; |
|
| 186 | - $page['texte'] = |
|
| 187 | - "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . '</h6>' . $page['texte'] . '</div>' |
|
| 188 | - . ($js_inclus ? '' : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
|
| 189 | - $js_inclus = true; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - // Si un modele contenait #SESSION, on note l'info dans $page |
|
| 193 | - if (isset($GLOBALS['cache_utilise_session'])) { |
|
| 194 | - $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; |
|
| 195 | - unset($GLOBALS['cache_utilise_session']); |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - if ($select) { |
|
| 200 | - lang_select(); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - return $page; |
|
| 33 | + static $composer, $styliser, $notes = null; |
|
| 34 | + $page = tester_redirection($fond, $contexte, $connect); |
|
| 35 | + if ($page) { |
|
| 36 | + return $page; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + if (isset($contexte['lang'])) { |
|
| 40 | + $lang = $contexte['lang']; |
|
| 41 | + } elseif (!isset($lang)) { |
|
| 42 | + $lang = $GLOBALS['meta']['langue_site']; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']); |
|
| 46 | + if ($select) { |
|
| 47 | + $select = lang_select($lang); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
|
| 51 | + |
|
| 52 | + if (!$styliser) { |
|
| 53 | + $styliser = charger_fonction('styliser', 'public'); |
|
| 54 | + } |
|
| 55 | + [$skel, $mime_type, $gram, $sourcefile] = |
|
| 56 | + $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
|
| 57 | + |
|
| 58 | + if ($skel) { |
|
| 59 | + // sauver le nom de l'eventuel squelette en cours d'execution |
|
| 60 | + // (recursion possible a cause des modeles) |
|
| 61 | + if ($debug) { |
|
| 62 | + $courant = $GLOBALS['debug_objets']['courant'] ?? null; |
|
| 63 | + $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + // charger le squelette en specifiant les langages cibles et source |
|
| 67 | + // au cas il faudrait le compiler (source posterieure au resultat) |
|
| 68 | + |
|
| 69 | + if (!$composer) { |
|
| 70 | + $composer = charger_fonction('composer', 'public'); |
|
| 71 | + } |
|
| 72 | + $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
|
| 73 | + } else { |
|
| 74 | + $fonc = ''; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
|
| 78 | + $page = $fonc; |
|
| 79 | + } else { |
|
| 80 | + // Preparer l'appel de la fonction principale du squelette |
|
| 81 | + |
|
| 82 | + spip_timer($a = 'calcul page ' . random_int(0, 1000)); |
|
| 83 | + |
|
| 84 | + // On cree un marqueur de notes unique lie a cette composition |
|
| 85 | + // et on enregistre l'etat courant des globales de notes... |
|
| 86 | + if (is_null($notes)) { |
|
| 87 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 88 | + } |
|
| 89 | + if ($notes) { |
|
| 90 | + $notes('', 'empiler'); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // Rajouter d'office ces deux parametres |
|
| 94 | + // (mais vaudrait mieux que le compilateur sache le simuler |
|
| 95 | + // car ca interdit l'usage de criteres conditionnels dessus). |
|
| 96 | + if (!isset($contexte['date'])) { |
|
| 97 | + $contexte['date'] = date('Y-m-d H:i:s'); |
|
| 98 | + $contexte['date_default'] = true; |
|
| 99 | + } else { |
|
| 100 | + $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + if (!isset($contexte['date_redac'])) { |
|
| 104 | + $contexte['date_redac'] = date('Y-m-d H:i:s'); |
|
| 105 | + $contexte['date_redac_default'] = true; |
|
| 106 | + } else { |
|
| 107 | + $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + // Passer le nom du cache pour produire sa destruction automatique |
|
| 111 | + try { |
|
| 112 | + $page = $fonc(['cache' => $cache], [$contexte]); |
|
| 113 | + } catch (Throwable $e) { |
|
| 114 | + $msg = _T('zbug_erreur_execution_page') . " $sourcefile"; |
|
| 115 | + $full_msg = $msg . ' | File ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 116 | + $full_msg = str_replace(_ROOT_RACINE, '[…]/', $full_msg); |
|
| 117 | + $corps = "<pre>$msg</pre>"; |
|
| 118 | + $page = analyse_resultat_skel($fond, ['cache' => $cache], $corps, $sourcefile); |
|
| 119 | + erreur_squelette($full_msg); |
|
| 120 | + unset($msg, $full_msg, $corps); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // Restituer les globales de notes telles qu'elles etaient avant l'appel |
|
| 124 | + // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent* |
|
| 125 | + // etre dans son resultat, autrement elles ne seraient pas prises en |
|
| 126 | + // compte a chaque calcul d'un texte contenant un modele, mais seulement |
|
| 127 | + // quand le modele serait calcule, et on aurait des resultats incoherents) |
|
| 128 | + if ($notes) { |
|
| 129 | + $notes('', 'depiler'); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // reinjecter en dynamique la pile des notes |
|
| 133 | + // si il y a des inclure dynamiques |
|
| 134 | + // si la pile n'est pas vide |
|
| 135 | + // la generalisation de cette injection permettrait de corriger le point juste au dessus |
|
| 136 | + // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
|
| 137 | + if ($notes) { |
|
| 138 | + $page['notes'] = $notes('', 'sauver_etat'); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + // spip_log: un joli contexte |
|
| 142 | + $infos = presenter_contexte(array_filter($contexte)); |
|
| 143 | + |
|
| 144 | + $profile = spip_timer($a); |
|
| 145 | + spip_log("calcul ($profile) [$skel] $infos" |
|
| 146 | + . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 147 | + |
|
| 148 | + if (defined('_CALCUL_PROFILER') and intval($profile) > _CALCUL_PROFILER) { |
|
| 149 | + spip_log("calcul ($profile) [$skel] $infos" |
|
| 150 | + . ' (' . strlen($page['texte']) . ' octets) | ' . $_SERVER['REQUEST_URI'], 'profiler' . _LOG_AVERTISSEMENT); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + if ($debug) { |
|
| 154 | + // si c'est ce que demande le debusqueur, lui passer la main |
|
| 155 | + $t = strlen($page['texte']) ? $page['texte'] : ' '; |
|
| 156 | + $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 157 | + $GLOBALS['debug_objets']['courant'] = $courant; |
|
| 158 | + $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
|
| 159 | + if ( |
|
| 160 | + $GLOBALS['debug_objets']['sourcefile'] |
|
| 161 | + and (_request('var_mode_objet') == $fonc) |
|
| 162 | + and (_request('var_mode_affiche') == 'resultat') |
|
| 163 | + ) { |
|
| 164 | + erreur_squelette(); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + // Si #CACHE{} n'etait pas la, le mettre a $delais |
|
| 168 | + if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 169 | + // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
|
| 170 | + // si aucun #CACHE{} spécifié |
|
| 171 | + // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
|
| 172 | + // entre public et prive |
|
| 173 | + if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) { |
|
| 174 | + $page['entetes']['X-Spip-Cache'] = 0; |
|
| 175 | + } else { |
|
| 176 | + $page['entetes']['X-Spip-Cache'] = $GLOBALS['delais'] ?? 36000; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + $page['contexte'] = $contexte; |
|
| 181 | + |
|
| 182 | + // faire remonter le fichier source |
|
| 183 | + static $js_inclus = false; |
|
| 184 | + if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
|
| 185 | + $page['sourcefile'] = $sourcefile; |
|
| 186 | + $page['texte'] = |
|
| 187 | + "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . '</h6>' . $page['texte'] . '</div>' |
|
| 188 | + . ($js_inclus ? '' : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
|
| 189 | + $js_inclus = true; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + // Si un modele contenait #SESSION, on note l'info dans $page |
|
| 193 | + if (isset($GLOBALS['cache_utilise_session'])) { |
|
| 194 | + $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; |
|
| 195 | + unset($GLOBALS['cache_utilise_session']); |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + if ($select) { |
|
| 200 | + lang_select(); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + return $page; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -209,37 +209,37 @@ discard block |
||
| 209 | 209 | * @return string |
| 210 | 210 | */ |
| 211 | 211 | function presenter_contexte($contexte, $profondeur_max = 1, $max_lines = 0) { |
| 212 | - $infos = []; |
|
| 213 | - $line = 0; |
|
| 214 | - foreach ($contexte as $var => $val) { |
|
| 215 | - $line++; |
|
| 216 | - if ($max_lines and $max_lines < $line) { |
|
| 217 | - $infos[] = '…'; |
|
| 218 | - break; |
|
| 219 | - } |
|
| 220 | - if ($val === null) { |
|
| 221 | - $val = ''; |
|
| 222 | - } elseif (is_array($val)) { |
|
| 223 | - if ($profondeur_max > 0) { |
|
| 224 | - $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 225 | - } else { |
|
| 226 | - $val = 'array:' . count($val); |
|
| 227 | - } |
|
| 228 | - } elseif (is_object($val)) { |
|
| 229 | - $val = get_class($val); |
|
| 230 | - } elseif (strlen("$val") > 30) { |
|
| 231 | - $val = substr("$val", 0, 29) . '…'; |
|
| 232 | - if (strstr($val, ' ')) { |
|
| 233 | - $val = "'$val'"; |
|
| 234 | - } |
|
| 235 | - } elseif (strstr($val, ' ')) { |
|
| 236 | - $val = "'$val'"; |
|
| 237 | - } elseif (!strlen($val)) { |
|
| 238 | - $val = "''"; |
|
| 239 | - } |
|
| 240 | - $infos[] = $var . '=' . $val; |
|
| 241 | - } |
|
| 242 | - return join(', ', $infos); |
|
| 212 | + $infos = []; |
|
| 213 | + $line = 0; |
|
| 214 | + foreach ($contexte as $var => $val) { |
|
| 215 | + $line++; |
|
| 216 | + if ($max_lines and $max_lines < $line) { |
|
| 217 | + $infos[] = '…'; |
|
| 218 | + break; |
|
| 219 | + } |
|
| 220 | + if ($val === null) { |
|
| 221 | + $val = ''; |
|
| 222 | + } elseif (is_array($val)) { |
|
| 223 | + if ($profondeur_max > 0) { |
|
| 224 | + $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 225 | + } else { |
|
| 226 | + $val = 'array:' . count($val); |
|
| 227 | + } |
|
| 228 | + } elseif (is_object($val)) { |
|
| 229 | + $val = get_class($val); |
|
| 230 | + } elseif (strlen("$val") > 30) { |
|
| 231 | + $val = substr("$val", 0, 29) . '…'; |
|
| 232 | + if (strstr($val, ' ')) { |
|
| 233 | + $val = "'$val'"; |
|
| 234 | + } |
|
| 235 | + } elseif (strstr($val, ' ')) { |
|
| 236 | + $val = "'$val'"; |
|
| 237 | + } elseif (!strlen($val)) { |
|
| 238 | + $val = "''"; |
|
| 239 | + } |
|
| 240 | + $infos[] = $var . '=' . $val; |
|
| 241 | + } |
|
| 242 | + return join(', ', $infos); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | * @return array|bool |
| 257 | 257 | */ |
| 258 | 258 | function tester_redirection($fond, $contexte, $connect) { |
| 259 | - static $tester_redirection = null; |
|
| 260 | - if (is_null($tester_redirection)) { |
|
| 261 | - $tester_redirection = charger_fonction('tester_redirection', 'public'); |
|
| 262 | - } |
|
| 263 | - return $tester_redirection($fond, $contexte, $connect); |
|
| 259 | + static $tester_redirection = null; |
|
| 260 | + if (is_null($tester_redirection)) { |
|
| 261 | + $tester_redirection = charger_fonction('tester_redirection', 'public'); |
|
| 262 | + } |
|
| 263 | + return $tester_redirection($fond, $contexte, $connect); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
@@ -276,42 +276,42 @@ discard block |
||
| 276 | 276 | * @return array|bool |
| 277 | 277 | */ |
| 278 | 278 | function public_tester_redirection_dist($fond, $contexte, $connect) { |
| 279 | - if ( |
|
| 280 | - $fond == 'article' |
|
| 281 | - and !empty($contexte['id_article']) |
|
| 282 | - and $id_article = intval($contexte['id_article']) |
|
| 283 | - ) { |
|
| 284 | - include_spip('public/quete'); // pour quete_virtuel et ses dependances |
|
| 285 | - $m = quete_virtuel($id_article, $connect) ?? ''; |
|
| 286 | - if (strlen($m)) { |
|
| 287 | - include_spip('inc/texte'); |
|
| 288 | - // les navigateurs pataugent si l'URL est vide |
|
| 289 | - if ($url = virtuel_redirige($m, true)) { |
|
| 290 | - // passer en url absolue car cette redirection pourra |
|
| 291 | - // etre utilisee dans un contexte d'url qui change |
|
| 292 | - // y compris url arbo |
|
| 293 | - $status = 302; |
|
| 294 | - if (defined('_STATUS_REDIRECTION_VIRTUEL')) { |
|
| 295 | - $status = _STATUS_REDIRECTION_VIRTUEL; |
|
| 296 | - } |
|
| 297 | - if (!preg_match(',^\w+:,', $url)) { |
|
| 298 | - include_spip('inc/filtres_mini'); |
|
| 299 | - $url = url_absolue($url); |
|
| 300 | - } |
|
| 301 | - $url = str_replace('&', '&', $url); |
|
| 302 | - |
|
| 303 | - return [ |
|
| 304 | - 'texte' => '<' |
|
| 305 | - . "?php include_spip('inc/headers');redirige_par_entete('" |
|
| 306 | - . texte_script($url) |
|
| 307 | - . "','',$status);" |
|
| 308 | - . '?' . '>', |
|
| 309 | - 'process_ins' => 'php', |
|
| 310 | - 'status' => $status |
|
| 311 | - ]; |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - return false; |
|
| 279 | + if ( |
|
| 280 | + $fond == 'article' |
|
| 281 | + and !empty($contexte['id_article']) |
|
| 282 | + and $id_article = intval($contexte['id_article']) |
|
| 283 | + ) { |
|
| 284 | + include_spip('public/quete'); // pour quete_virtuel et ses dependances |
|
| 285 | + $m = quete_virtuel($id_article, $connect) ?? ''; |
|
| 286 | + if (strlen($m)) { |
|
| 287 | + include_spip('inc/texte'); |
|
| 288 | + // les navigateurs pataugent si l'URL est vide |
|
| 289 | + if ($url = virtuel_redirige($m, true)) { |
|
| 290 | + // passer en url absolue car cette redirection pourra |
|
| 291 | + // etre utilisee dans un contexte d'url qui change |
|
| 292 | + // y compris url arbo |
|
| 293 | + $status = 302; |
|
| 294 | + if (defined('_STATUS_REDIRECTION_VIRTUEL')) { |
|
| 295 | + $status = _STATUS_REDIRECTION_VIRTUEL; |
|
| 296 | + } |
|
| 297 | + if (!preg_match(',^\w+:,', $url)) { |
|
| 298 | + include_spip('inc/filtres_mini'); |
|
| 299 | + $url = url_absolue($url); |
|
| 300 | + } |
|
| 301 | + $url = str_replace('&', '&', $url); |
|
| 302 | + |
|
| 303 | + return [ |
|
| 304 | + 'texte' => '<' |
|
| 305 | + . "?php include_spip('inc/headers');redirige_par_entete('" |
|
| 306 | + . texte_script($url) |
|
| 307 | + . "','',$status);" |
|
| 308 | + . '?' . '>', |
|
| 309 | + 'process_ins' => 'php', |
|
| 310 | + 'status' => $status |
|
| 311 | + ]; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + return false; |
|
| 317 | 317 | } |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | define('_DIR_RACINE', _DIR_RESTREINT ? '' : '../'); |
| 52 | 52 | |
| 53 | 53 | /** chemin absolu vers la racine */ |
| 54 | -define('_ROOT_RACINE', dirname(__DIR__) . '/'); |
|
| 54 | +define('_ROOT_RACINE', dirname(__DIR__).'/'); |
|
| 55 | 55 | /** chemin absolu vers le repertoire de travail */ |
| 56 | -define('_ROOT_CWD', getcwd() . '/'); |
|
| 56 | +define('_ROOT_CWD', getcwd().'/'); |
|
| 57 | 57 | /** chemin absolu vers ecrire */ |
| 58 | -define('_ROOT_RESTREINT', _ROOT_CWD . _DIR_RESTREINT); |
|
| 58 | +define('_ROOT_RESTREINT', _ROOT_CWD._DIR_RESTREINT); |
|
| 59 | 59 | |
| 60 | 60 | // Icones |
| 61 | 61 | if (!defined('_NOM_IMG_PACK')) { |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | define('_NOM_IMG_PACK', 'images/'); |
| 64 | 64 | } |
| 65 | 65 | /** le chemin http (relatif) vers les images standard */ |
| 66 | -define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
|
| 66 | +define('_DIR_IMG_PACK', (_DIR_RACINE.'prive/'._NOM_IMG_PACK)); |
|
| 67 | 67 | |
| 68 | 68 | /** le chemin php (absolu) vers les images standard (pour hebergement centralise) */ |
| 69 | -define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
|
| 69 | +define('_ROOT_IMG_PACK', dirname(__DIR__).'/prive/'._NOM_IMG_PACK); |
|
| 70 | 70 | |
| 71 | 71 | if (!defined('_JAVASCRIPT')) { |
| 72 | 72 | /** Nom du repertoire des bibliotheques JavaScript */ |
| 73 | 73 | define('_JAVASCRIPT', 'javascript/'); |
| 74 | 74 | } // utilisable avec #CHEMIN et find_in_path |
| 75 | 75 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 76 | -define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
|
| 76 | +define('_DIR_JAVASCRIPT', (_DIR_RACINE.'prive/'._JAVASCRIPT)); |
|
| 77 | 77 | |
| 78 | 78 | # Le nom des 4 repertoires modifiables par les scripts lances par httpd |
| 79 | 79 | # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas) |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | // Son emplacement absolu si on le trouve |
| 106 | 106 | if ( |
| 107 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 108 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 107 | + @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES._NOM_CONFIG.'.php') |
|
| 108 | + or (@file_exists($f = _ROOT_RESTREINT._NOM_CONFIG.'.php')) |
|
| 109 | 109 | ) { |
| 110 | 110 | /** Emplacement absolu du fichier d'option */ |
| 111 | 111 | define('_FILE_OPTIONS', $f); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | // Inclure l'ecran de securite |
| 130 | 130 | if ( |
| 131 | 131 | !defined('_ECRAN_SECURITE') |
| 132 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 132 | + and @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES.'ecran_securite.php') |
|
| 133 | 133 | ) { |
| 134 | 134 | include $f; |
| 135 | 135 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | // UA plus cibles |
| 151 | 151 | . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
| 152 | 152 | . ',i', |
| 153 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 153 | + (string) $_SERVER['HTTP_USER_AGENT'] |
|
| 154 | 154 | ) |
| 155 | 155 | ); |
| 156 | 156 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | # la matrice standard (fichiers definissant les fonctions a inclure) |
| 393 | 393 | $spip_matrice = []; |
| 394 | 394 | # les plugins a activer |
| 395 | -$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 395 | +$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 396 | 396 | # les surcharges de include_spip() |
| 397 | 397 | $surcharges = []; // format 'inc_truc' => '/plugins/chose/inc_truc2.php' |
| 398 | 398 | |
@@ -470,8 +470,8 @@ discard block |
||
| 470 | 470 | // |
| 471 | 471 | // Charger les fonctions liees aux serveurs Http et Sql. |
| 472 | 472 | // |
| 473 | -require_once _ROOT_RESTREINT . 'inc/utils.php'; |
|
| 474 | -require_once _ROOT_RESTREINT . 'base/connect_sql.php'; |
|
| 473 | +require_once _ROOT_RESTREINT.'inc/utils.php'; |
|
| 474 | +require_once _ROOT_RESTREINT.'base/connect_sql.php'; |
|
| 475 | 475 | |
| 476 | 476 | // Definition personnelles eventuelles |
| 477 | 477 | |
@@ -494,10 +494,10 @@ discard block |
||
| 494 | 494 | // ===> on execute en neutralisant les messages d'erreur |
| 495 | 495 | |
| 496 | 496 | spip_initialisation_core( |
| 497 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 498 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 499 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 497 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 498 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 499 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 500 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 501 | 501 | ); |
| 502 | 502 | |
| 503 | 503 | |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | // Si on est dans le site public, dire que qq s'en occupe |
| 553 | 553 | include_spip('inc/minipres'); |
| 554 | 554 | utiliser_langue_visiteur(); |
| 555 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 555 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>"._T('info_travaux_texte').'</p>', ['status' => 503]); |
|
| 556 | 556 | exit; |
| 557 | 557 | } |
| 558 | 558 | // autrement c'est une install ad hoc (spikini...), on sait pas faire |
@@ -591,12 +591,12 @@ discard block |
||
| 591 | 591 | } |
| 592 | 592 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 593 | 593 | include_spip('inc/filtres_mini'); |
| 594 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 594 | + header(_HEADER_COMPOSED_BY." $spip_version_affichee @ www.spip.net + ".url_absolue(_DIR_VAR.'config.txt')); |
|
| 595 | 595 | } else { |
| 596 | 596 | // header minimal |
| 597 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 597 | + header(_HEADER_COMPOSED_BY.' @ www.spip.net'); |
|
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
| 602 | -spip_log($methode . ' ' . self() . ' - ' . _FILE_CONNECT, _LOG_DEBUG); |
|
| 602 | +spip_log($methode.' '.self().' - '._FILE_CONNECT, _LOG_DEBUG); |
|
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -37,15 +37,15 @@ discard block |
||
| 37 | 37 | define('_PHP_MAX', '8.2.99'); |
| 38 | 38 | |
| 39 | 39 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 40 | - /** le nom du repertoire ecrire/ */ |
|
| 41 | - define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 40 | + /** le nom du repertoire ecrire/ */ |
|
| 41 | + define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** Chemin relatif pour aller dans ecrire |
| 45 | 45 | * vide si on est dans ecrire, 'ecrire/' sinon */ |
| 46 | 46 | define( |
| 47 | - '_DIR_RESTREINT', |
|
| 48 | - (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 47 | + '_DIR_RESTREINT', |
|
| 48 | + (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | 51 | /** Chemin relatif pour aller à la racine */ |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // Icones |
| 62 | 62 | if (!defined('_NOM_IMG_PACK')) { |
| 63 | - /** Nom du dossier images */ |
|
| 64 | - define('_NOM_IMG_PACK', 'images/'); |
|
| 63 | + /** Nom du dossier images */ |
|
| 64 | + define('_NOM_IMG_PACK', 'images/'); |
|
| 65 | 65 | } |
| 66 | 66 | /** le chemin http (relatif) vers les images standard */ |
| 67 | 67 | define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
| 71 | 71 | |
| 72 | 72 | if (!defined('_JAVASCRIPT')) { |
| 73 | - /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 74 | - define('_JAVASCRIPT', 'javascript/'); |
|
| 73 | + /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 74 | + define('_JAVASCRIPT', 'javascript/'); |
|
| 75 | 75 | } // utilisable avec #CHEMIN et find_in_path |
| 76 | 76 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 77 | 77 | define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
@@ -81,47 +81,47 @@ discard block |
||
| 81 | 81 | # mais on peut les mettre ailleurs et changer completement les noms |
| 82 | 82 | |
| 83 | 83 | if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) { |
| 84 | - /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 85 | - define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 84 | + /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 85 | + define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 86 | 86 | } |
| 87 | 87 | if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) { |
| 88 | - /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 89 | - define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 88 | + /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 89 | + define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 90 | 90 | } |
| 91 | 91 | if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) { |
| 92 | - /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 93 | - define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 92 | + /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 93 | + define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 94 | 94 | } |
| 95 | 95 | if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) { |
| 96 | - /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 97 | - define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 96 | + /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 97 | + define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | /** Le nom du fichier de personnalisation */ |
| 102 | 102 | if (!defined('_NOM_CONFIG')) { |
| 103 | - define('_NOM_CONFIG', 'mes_options'); |
|
| 103 | + define('_NOM_CONFIG', 'mes_options'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Son emplacement absolu si on le trouve |
| 107 | 107 | if ( |
| 108 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 109 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 108 | + @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 109 | + or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 110 | 110 | ) { |
| 111 | - /** Emplacement absolu du fichier d'option */ |
|
| 112 | - define('_FILE_OPTIONS', $f); |
|
| 111 | + /** Emplacement absolu du fichier d'option */ |
|
| 112 | + define('_FILE_OPTIONS', $f); |
|
| 113 | 113 | } else { |
| 114 | - define('_FILE_OPTIONS', ''); |
|
| 114 | + define('_FILE_OPTIONS', ''); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if (!defined('MODULES_IDIOMES')) { |
| 118 | - /** |
|
| 119 | - * Modules par défaut pour la traduction. |
|
| 120 | - * |
|
| 121 | - * Constante utilisée par le compilateur et le décompilateur |
|
| 122 | - * sa valeur etant traitée par inc_traduire_dist |
|
| 123 | - */ |
|
| 124 | - define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 118 | + /** |
|
| 119 | + * Modules par défaut pour la traduction. |
|
| 120 | + * |
|
| 121 | + * Constante utilisée par le compilateur et le décompilateur |
|
| 122 | + * sa valeur etant traitée par inc_traduire_dist |
|
| 123 | + */ |
|
| 124 | + define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // *** Fin des define *** // |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | // Inclure l'ecran de securite |
| 131 | 131 | if ( |
| 132 | - !defined('_ECRAN_SECURITE') |
|
| 133 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 132 | + !defined('_ECRAN_SECURITE') |
|
| 133 | + and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 134 | 134 | ) { |
| 135 | - include $f; |
|
| 135 | + include $f; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -140,30 +140,30 @@ discard block |
||
| 140 | 140 | * Détecteur de robot d'indexation |
| 141 | 141 | */ |
| 142 | 142 | if (!defined('_IS_BOT')) { |
| 143 | - define( |
|
| 144 | - '_IS_BOT', |
|
| 145 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 146 | - and preg_match( |
|
| 147 | - // mots generiques |
|
| 148 | - ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 149 | - // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 150 | - . 'MSIE 6\.0|' |
|
| 151 | - // UA plus cibles |
|
| 152 | - . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 153 | - . ',i', |
|
| 154 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 143 | + define( |
|
| 144 | + '_IS_BOT', |
|
| 145 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 146 | + and preg_match( |
|
| 147 | + // mots generiques |
|
| 148 | + ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 149 | + // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 150 | + . 'MSIE 6\.0|' |
|
| 151 | + // UA plus cibles |
|
| 152 | + . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 153 | + . ',i', |
|
| 154 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | if (!defined('_IS_CLI')) { |
| 160 | - define( |
|
| 161 | - '_IS_CLI', |
|
| 162 | - !isset($_SERVER['HTTP_HOST']) |
|
| 163 | - and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 164 | - and !empty($_SERVER['argv']) |
|
| 165 | - and empty($_SERVER['REQUEST_METHOD']) |
|
| 166 | - ); |
|
| 160 | + define( |
|
| 161 | + '_IS_CLI', |
|
| 162 | + !isset($_SERVER['HTTP_HOST']) |
|
| 163 | + and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 164 | + and !empty($_SERVER['argv']) |
|
| 165 | + and empty($_SERVER['REQUEST_METHOD']) |
|
| 166 | + ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // *** Parametrage par defaut de SPIP *** |
@@ -175,61 +175,61 @@ discard block |
||
| 175 | 175 | // Ne pas les rendre indefinies. |
| 176 | 176 | |
| 177 | 177 | global |
| 178 | - $nombre_de_logs, |
|
| 179 | - $taille_des_logs, |
|
| 180 | - $table_prefix, |
|
| 181 | - $cookie_prefix, |
|
| 182 | - $dossier_squelettes, |
|
| 183 | - $filtrer_javascript, |
|
| 184 | - $type_urls, |
|
| 185 | - $debut_date_publication, |
|
| 186 | - $ip, |
|
| 187 | - $mysql_rappel_connexion, |
|
| 188 | - $mysql_rappel_nom_base, |
|
| 189 | - $test_i18n, |
|
| 190 | - $ignore_auth_http, |
|
| 191 | - $ignore_remote_user, |
|
| 192 | - $derniere_modif_invalide, |
|
| 193 | - $home_server, |
|
| 194 | - $help_server, |
|
| 195 | - $url_glossaire_externe, |
|
| 196 | - $tex_server, |
|
| 197 | - $traiter_math, |
|
| 198 | - $xhtml, |
|
| 199 | - $xml_indent, |
|
| 200 | - $source_vignettes, |
|
| 201 | - $formats_logos, |
|
| 202 | - $controler_dates_rss, |
|
| 203 | - $spip_pipeline, |
|
| 204 | - $spip_matrice, |
|
| 205 | - $plugins, |
|
| 206 | - $surcharges, |
|
| 207 | - $exceptions_des_tables, |
|
| 208 | - $tables_principales, |
|
| 209 | - $table_des_tables, |
|
| 210 | - $tables_auxiliaires, |
|
| 211 | - $table_primary, |
|
| 212 | - $table_date, |
|
| 213 | - $table_titre, |
|
| 214 | - $tables_jointures, |
|
| 215 | - $liste_des_statuts, |
|
| 216 | - $liste_des_etats, |
|
| 217 | - $liste_des_authentifications, |
|
| 218 | - $spip_version_branche, |
|
| 219 | - $spip_version_code, |
|
| 220 | - $spip_version_base, |
|
| 221 | - $spip_sql_version, |
|
| 222 | - $spip_version_affichee, |
|
| 223 | - $visiteur_session, |
|
| 224 | - $auteur_session, |
|
| 225 | - $connect_statut, |
|
| 226 | - $connect_toutes_rubriques, |
|
| 227 | - $hash_recherche, |
|
| 228 | - $hash_recherche_strict, |
|
| 229 | - $ldap_present, |
|
| 230 | - $meta, |
|
| 231 | - $connect_id_rubrique, |
|
| 232 | - $puce; |
|
| 178 | + $nombre_de_logs, |
|
| 179 | + $taille_des_logs, |
|
| 180 | + $table_prefix, |
|
| 181 | + $cookie_prefix, |
|
| 182 | + $dossier_squelettes, |
|
| 183 | + $filtrer_javascript, |
|
| 184 | + $type_urls, |
|
| 185 | + $debut_date_publication, |
|
| 186 | + $ip, |
|
| 187 | + $mysql_rappel_connexion, |
|
| 188 | + $mysql_rappel_nom_base, |
|
| 189 | + $test_i18n, |
|
| 190 | + $ignore_auth_http, |
|
| 191 | + $ignore_remote_user, |
|
| 192 | + $derniere_modif_invalide, |
|
| 193 | + $home_server, |
|
| 194 | + $help_server, |
|
| 195 | + $url_glossaire_externe, |
|
| 196 | + $tex_server, |
|
| 197 | + $traiter_math, |
|
| 198 | + $xhtml, |
|
| 199 | + $xml_indent, |
|
| 200 | + $source_vignettes, |
|
| 201 | + $formats_logos, |
|
| 202 | + $controler_dates_rss, |
|
| 203 | + $spip_pipeline, |
|
| 204 | + $spip_matrice, |
|
| 205 | + $plugins, |
|
| 206 | + $surcharges, |
|
| 207 | + $exceptions_des_tables, |
|
| 208 | + $tables_principales, |
|
| 209 | + $table_des_tables, |
|
| 210 | + $tables_auxiliaires, |
|
| 211 | + $table_primary, |
|
| 212 | + $table_date, |
|
| 213 | + $table_titre, |
|
| 214 | + $tables_jointures, |
|
| 215 | + $liste_des_statuts, |
|
| 216 | + $liste_des_etats, |
|
| 217 | + $liste_des_authentifications, |
|
| 218 | + $spip_version_branche, |
|
| 219 | + $spip_version_code, |
|
| 220 | + $spip_version_base, |
|
| 221 | + $spip_sql_version, |
|
| 222 | + $spip_version_affichee, |
|
| 223 | + $visiteur_session, |
|
| 224 | + $auteur_session, |
|
| 225 | + $connect_statut, |
|
| 226 | + $connect_toutes_rubriques, |
|
| 227 | + $hash_recherche, |
|
| 228 | + $hash_recherche_strict, |
|
| 229 | + $ldap_present, |
|
| 230 | + $meta, |
|
| 231 | + $connect_id_rubrique, |
|
| 232 | + $puce; |
|
| 233 | 233 | |
| 234 | 234 | # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log |
| 235 | 235 | $nombre_de_logs = 4; |
@@ -284,48 +284,48 @@ discard block |
||
| 284 | 284 | // Prendre en compte les entetes HTTP_X_FORWARDED_XX |
| 285 | 285 | // |
| 286 | 286 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
| 287 | - if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 288 | - $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 289 | - } |
|
| 290 | - if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 291 | - $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 292 | - } |
|
| 287 | + if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 288 | + $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 289 | + } |
|
| 290 | + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 291 | + $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 292 | + } |
|
| 293 | 293 | } |
| 294 | 294 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 295 | - if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 296 | - $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 297 | - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 298 | - $_SERVER['HTTPS'] = 'on'; |
|
| 299 | - if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 300 | - $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 305 | - if (strpos($host, ',') !== false) { |
|
| 306 | - $h = explode(',', $host); |
|
| 307 | - $host = trim(reset($h)); |
|
| 308 | - } |
|
| 309 | - // securite sur le contenu de l'entete |
|
| 310 | - $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 311 | - $_SERVER['HTTP_HOST'] = $host; |
|
| 295 | + if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 296 | + $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 297 | + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 298 | + $_SERVER['HTTPS'] = 'on'; |
|
| 299 | + if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 300 | + $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 305 | + if (strpos($host, ',') !== false) { |
|
| 306 | + $h = explode(',', $host); |
|
| 307 | + $host = trim(reset($h)); |
|
| 308 | + } |
|
| 309 | + // securite sur le contenu de l'entete |
|
| 310 | + $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 311 | + $_SERVER['HTTP_HOST'] = $host; |
|
| 312 | 312 | } |
| 313 | 313 | // |
| 314 | 314 | // On note le numero IP du client dans la variable $ip |
| 315 | 315 | // |
| 316 | 316 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 317 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 318 | - if (strpos($ip, ',') !== false) { |
|
| 319 | - $ip = explode(',', $ip); |
|
| 320 | - $ip = reset($ip); |
|
| 321 | - } |
|
| 322 | - // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 323 | - if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 324 | - $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 325 | - } |
|
| 317 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 318 | + if (strpos($ip, ',') !== false) { |
|
| 319 | + $ip = explode(',', $ip); |
|
| 320 | + $ip = reset($ip); |
|
| 321 | + } |
|
| 322 | + // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 323 | + if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 324 | + $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 325 | + } |
|
| 326 | 326 | } |
| 327 | 327 | if (isset($_SERVER['REMOTE_ADDR'])) { |
| 328 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 328 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la |
@@ -410,24 +410,24 @@ discard block |
||
| 410 | 410 | |
| 411 | 411 | // Liste des statuts. |
| 412 | 412 | $liste_des_statuts = [ |
| 413 | - 'info_administrateurs' => '0minirezo', |
|
| 414 | - 'info_redacteurs' => '1comite', |
|
| 415 | - 'info_visiteurs' => '6forum', |
|
| 416 | - 'texte_statut_poubelle' => '5poubelle' |
|
| 413 | + 'info_administrateurs' => '0minirezo', |
|
| 414 | + 'info_redacteurs' => '1comite', |
|
| 415 | + 'info_visiteurs' => '6forum', |
|
| 416 | + 'texte_statut_poubelle' => '5poubelle' |
|
| 417 | 417 | ]; |
| 418 | 418 | |
| 419 | 419 | $liste_des_etats = [ |
| 420 | - 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 421 | - 'texte_statut_propose_evaluation' => 'prop', |
|
| 422 | - 'texte_statut_publie' => 'publie', |
|
| 423 | - 'texte_statut_poubelle' => 'poubelle', |
|
| 424 | - 'texte_statut_refuse' => 'refuse' |
|
| 420 | + 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 421 | + 'texte_statut_propose_evaluation' => 'prop', |
|
| 422 | + 'texte_statut_publie' => 'publie', |
|
| 423 | + 'texte_statut_poubelle' => 'poubelle', |
|
| 424 | + 'texte_statut_refuse' => 'refuse' |
|
| 425 | 425 | ]; |
| 426 | 426 | |
| 427 | 427 | // liste des methodes d'authentifications |
| 428 | 428 | $liste_des_authentifications = [ |
| 429 | - 'spip' => 'spip', |
|
| 430 | - 'ldap' => 'ldap' |
|
| 429 | + 'spip' => 'spip', |
|
| 430 | + 'ldap' => 'ldap' |
|
| 431 | 431 | ]; |
| 432 | 432 | |
| 433 | 433 | // Experimental : pour supprimer systematiquement l'affichage des numeros |
@@ -477,12 +477,12 @@ discard block |
||
| 477 | 477 | // Definition personnelles eventuelles |
| 478 | 478 | |
| 479 | 479 | if (_FILE_OPTIONS) { |
| 480 | - include_once _FILE_OPTIONS; |
|
| 480 | + include_once _FILE_OPTIONS; |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | if (!defined('SPIP_ERREUR_REPORT')) { |
| 484 | - /** Masquer les warning */ |
|
| 485 | - define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 484 | + /** Masquer les warning */ |
|
| 485 | + define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 486 | 486 | } |
| 487 | 487 | error_reporting(SPIP_ERREUR_REPORT); |
| 488 | 488 | |
@@ -495,10 +495,10 @@ discard block |
||
| 495 | 495 | // ===> on execute en neutralisant les messages d'erreur |
| 496 | 496 | |
| 497 | 497 | spip_initialisation_core( |
| 498 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 498 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 499 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 500 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 501 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 502 | 502 | ); |
| 503 | 503 | |
| 504 | 504 | |
@@ -508,70 +508,70 @@ discard block |
||
| 508 | 508 | // donc il faut avoir tout fini ici avant de charger les plugins |
| 509 | 509 | |
| 510 | 510 | if (@is_readable(_CACHE_PLUGINS_OPT) and @is_readable(_CACHE_PLUGINS_PATH)) { |
| 511 | - // chargement optimise precompile |
|
| 512 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 511 | + // chargement optimise precompile |
|
| 512 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 513 | 513 | } else { |
| 514 | - spip_initialisation_suite(); |
|
| 515 | - include_spip('inc/plugin'); |
|
| 516 | - // generer les fichiers php precompiles |
|
| 517 | - // de chargement des plugins et des pipelines |
|
| 518 | - actualise_plugins_actifs(); |
|
| 514 | + spip_initialisation_suite(); |
|
| 515 | + include_spip('inc/plugin'); |
|
| 516 | + // generer les fichiers php precompiles |
|
| 517 | + // de chargement des plugins et des pipelines |
|
| 518 | + actualise_plugins_actifs(); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | // Initialisations non critiques surchargeables par les plugins |
| 522 | 522 | spip_initialisation_suite(); |
| 523 | 523 | |
| 524 | 524 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 525 | - /** niveau maxi d'enregistrement des logs */ |
|
| 526 | - define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 525 | + /** niveau maxi d'enregistrement des logs */ |
|
| 526 | + define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | if (!defined('_OUTILS_DEVELOPPEURS')) { |
| 530 | - /** Activer des outils pour développeurs ? */ |
|
| 531 | - define('_OUTILS_DEVELOPPEURS', false); |
|
| 530 | + /** Activer des outils pour développeurs ? */ |
|
| 531 | + define('_OUTILS_DEVELOPPEURS', false); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | // charger systematiquement inc/autoriser dans l'espace restreint |
| 535 | 535 | if (test_espace_prive()) { |
| 536 | - include_spip('inc/autoriser'); |
|
| 536 | + include_spip('inc/autoriser'); |
|
| 537 | 537 | } |
| 538 | 538 | // |
| 539 | 539 | // Installer Spip si pas installe... sauf si justement on est en train |
| 540 | 540 | // |
| 541 | 541 | if ( |
| 542 | - !(_FILE_CONNECT |
|
| 543 | - or autoriser_sans_cookie(_request('exec')) |
|
| 544 | - or _request('action') == 'cookie' |
|
| 545 | - or _request('action') == 'converser' |
|
| 546 | - or _request('action') == 'test_dirs') |
|
| 542 | + !(_FILE_CONNECT |
|
| 543 | + or autoriser_sans_cookie(_request('exec')) |
|
| 544 | + or _request('action') == 'cookie' |
|
| 545 | + or _request('action') == 'converser' |
|
| 546 | + or _request('action') == 'test_dirs') |
|
| 547 | 547 | ) { |
| 548 | - // Si on peut installer, on lance illico |
|
| 549 | - if (test_espace_prive()) { |
|
| 550 | - include_spip('inc/headers'); |
|
| 551 | - redirige_url_ecrire('install'); |
|
| 552 | - } else { |
|
| 553 | - // Si on est dans le site public, dire que qq s'en occupe |
|
| 554 | - include_spip('inc/minipres'); |
|
| 555 | - utiliser_langue_visiteur(); |
|
| 556 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 557 | - exit; |
|
| 558 | - } |
|
| 559 | - // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 548 | + // Si on peut installer, on lance illico |
|
| 549 | + if (test_espace_prive()) { |
|
| 550 | + include_spip('inc/headers'); |
|
| 551 | + redirige_url_ecrire('install'); |
|
| 552 | + } else { |
|
| 553 | + // Si on est dans le site public, dire que qq s'en occupe |
|
| 554 | + include_spip('inc/minipres'); |
|
| 555 | + utiliser_langue_visiteur(); |
|
| 556 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 557 | + exit; |
|
| 558 | + } |
|
| 559 | + // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | // memoriser un tri sessionne eventuel |
| 563 | 563 | if ( |
| 564 | - isset($_REQUEST['var_memotri']) |
|
| 565 | - and $t = $_REQUEST['var_memotri'] |
|
| 566 | - and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 564 | + isset($_REQUEST['var_memotri']) |
|
| 565 | + and $t = $_REQUEST['var_memotri'] |
|
| 566 | + and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 567 | 567 | ) { |
| 568 | - if (!function_exists('session_set')) { |
|
| 569 | - include_spip('inc/session'); |
|
| 570 | - } |
|
| 571 | - $t = preg_replace(',\W,', '_', $t); |
|
| 572 | - if ($v = _request($t)) { |
|
| 573 | - session_set($t, $v); |
|
| 574 | - } |
|
| 568 | + if (!function_exists('session_set')) { |
|
| 569 | + include_spip('inc/session'); |
|
| 570 | + } |
|
| 571 | + $t = preg_replace(',\W,', '_', $t); |
|
| 572 | + if ($v = _request($t)) { |
|
| 573 | + session_set($t, $v); |
|
| 574 | + } |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** |
@@ -581,22 +581,22 @@ discard block |
||
| 581 | 581 | * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite |
| 582 | 582 | */ |
| 583 | 583 | if (!defined('_HEADER_COMPOSED_BY')) { |
| 584 | - define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 584 | + define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 585 | 585 | } |
| 586 | 586 | if (!headers_sent() and _HEADER_COMPOSED_BY) { |
| 587 | - if (!defined('_HEADER_VARY')) { |
|
| 588 | - define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 589 | - } |
|
| 590 | - if (_HEADER_VARY) { |
|
| 591 | - header(_HEADER_VARY); |
|
| 592 | - } |
|
| 593 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 594 | - include_spip('inc/filtres_mini'); |
|
| 595 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 596 | - } else { |
|
| 597 | - // header minimal |
|
| 598 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 599 | - } |
|
| 587 | + if (!defined('_HEADER_VARY')) { |
|
| 588 | + define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 589 | + } |
|
| 590 | + if (_HEADER_VARY) { |
|
| 591 | + header(_HEADER_VARY); |
|
| 592 | + } |
|
| 593 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 594 | + include_spip('inc/filtres_mini'); |
|
| 595 | + header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 596 | + } else { |
|
| 597 | + // header minimal |
|
| 598 | + header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 599 | + } |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 26 | - return; |
|
| 26 | + return; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -31,25 +31,25 @@ discard block |
||
| 31 | 31 | * Réparer la base de données |
| 32 | 32 | */ |
| 33 | 33 | function exec_base_repair_dist() { |
| 34 | - $action = null; |
|
| 35 | - $ok = false; |
|
| 36 | - if (!spip_connect()) { |
|
| 37 | - $message = _T('titre_probleme_technique'); |
|
| 38 | - } else { |
|
| 39 | - $version_sql = sql_version(); |
|
| 40 | - if (!$version_sql) { |
|
| 41 | - $message = _T('avis_erreur_connexion_mysql'); |
|
| 42 | - } else { |
|
| 43 | - $message = _T('texte_requetes_echouent'); |
|
| 44 | - $ok = true; |
|
| 45 | - } |
|
| 46 | - $action = _T('texte_tenter_reparation'); |
|
| 47 | - } |
|
| 48 | - if ($ok) { |
|
| 49 | - $admin = charger_fonction('admin', 'inc'); |
|
| 50 | - echo $admin('repair', $action, $message, true); |
|
| 51 | - } else { |
|
| 52 | - include_spip('inc/minipres'); |
|
| 53 | - echo minipres(_T('titre_reparation'), "<p>$message</p>"); |
|
| 54 | - } |
|
| 34 | + $action = null; |
|
| 35 | + $ok = false; |
|
| 36 | + if (!spip_connect()) { |
|
| 37 | + $message = _T('titre_probleme_technique'); |
|
| 38 | + } else { |
|
| 39 | + $version_sql = sql_version(); |
|
| 40 | + if (!$version_sql) { |
|
| 41 | + $message = _T('avis_erreur_connexion_mysql'); |
|
| 42 | + } else { |
|
| 43 | + $message = _T('texte_requetes_echouent'); |
|
| 44 | + $ok = true; |
|
| 45 | + } |
|
| 46 | + $action = _T('texte_tenter_reparation'); |
|
| 47 | + } |
|
| 48 | + if ($ok) { |
|
| 49 | + $admin = charger_fonction('admin', 'inc'); |
|
| 50 | + echo $admin('repair', $action, $message, true); |
|
| 51 | + } else { |
|
| 52 | + include_spip('inc/minipres'); |
|
| 53 | + echo minipres(_T('titre_reparation'), "<p>$message</p>"); |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -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 | |
@@ -28,29 +28,29 @@ discard block |
||
| 28 | 28 | * Demander à mettre à jour la base de données |
| 29 | 29 | */ |
| 30 | 30 | function exec_demande_mise_a_jour_dist() { |
| 31 | - // on fait la verif du path avant tout, |
|
| 32 | - // et l'installation des qu'on est dans la colonne principale |
|
| 33 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 34 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 35 | - include_spip('inc/plugin'); |
|
| 36 | - if (actualise_plugins_actifs()) { |
|
| 37 | - include_spip('inc/headers'); |
|
| 38 | - redirige_par_entete(self()); |
|
| 39 | - } |
|
| 31 | + // on fait la verif du path avant tout, |
|
| 32 | + // et l'installation des qu'on est dans la colonne principale |
|
| 33 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 34 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 35 | + include_spip('inc/plugin'); |
|
| 36 | + if (actualise_plugins_actifs()) { |
|
| 37 | + include_spip('inc/headers'); |
|
| 38 | + redirige_par_entete(self()); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - include_spip('inc/presentation'); |
|
| 42 | - include_spip('inc/filtres_boites'); |
|
| 43 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 44 | - echo $commencer_page('', '', '', '', true, false, false); |
|
| 41 | + include_spip('inc/presentation'); |
|
| 42 | + include_spip('inc/filtres_boites'); |
|
| 43 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 44 | + echo $commencer_page('', '', '', '', true, false, false); |
|
| 45 | 45 | |
| 46 | - echo debut_grand_cadre(); |
|
| 47 | - echo boite_ouvrir(_T('info_message_technique'), 'notice'); |
|
| 48 | - echo '<p>' . _T('info_procedure_maj_version') . '</p>', |
|
| 49 | - '<p>' . _T('info_administrateur_site_01') . '</p>'; |
|
| 50 | - echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire('upgrade', 'reinstall=non')); |
|
| 51 | - echo boite_fermer(); |
|
| 52 | - // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
|
| 53 | - echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
|
| 54 | - echo fin_grand_cadre(); |
|
| 55 | - echo fin_page(); |
|
| 46 | + echo debut_grand_cadre(); |
|
| 47 | + echo boite_ouvrir(_T('info_message_technique'), 'notice'); |
|
| 48 | + echo '<p>' . _T('info_procedure_maj_version') . '</p>', |
|
| 49 | + '<p>' . _T('info_administrateur_site_01') . '</p>'; |
|
| 50 | + echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire('upgrade', 'reinstall=non')); |
|
| 51 | + echo boite_fermer(); |
|
| 52 | + // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
|
| 53 | + echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
|
| 54 | + echo fin_grand_cadre(); |
|
| 55 | + echo fin_page(); |
|
| 56 | 56 | } |
@@ -45,8 +45,8 @@ |
||
| 45 | 45 | |
| 46 | 46 | echo debut_grand_cadre(); |
| 47 | 47 | echo boite_ouvrir(_T('info_message_technique'), 'notice'); |
| 48 | - echo '<p>' . _T('info_procedure_maj_version') . '</p>', |
|
| 49 | - '<p>' . _T('info_administrateur_site_01') . '</p>'; |
|
| 48 | + echo '<p>'._T('info_procedure_maj_version').'</p>', |
|
| 49 | + '<p>'._T('info_administrateur_site_01').'</p>'; |
|
| 50 | 50 | echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire('upgrade', 'reinstall=non')); |
| 51 | 51 | echo boite_fermer(); |
| 52 | 52 | // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -25,25 +25,25 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function exec_404_dist() { |
| 27 | 27 | |
| 28 | - $exec = _request('exec'); |
|
| 28 | + $exec = _request('exec'); |
|
| 29 | 29 | |
| 30 | - $titre = "exec_$exec"; |
|
| 31 | - $navigation = ''; |
|
| 32 | - $extra = ''; |
|
| 30 | + $titre = "exec_$exec"; |
|
| 31 | + $navigation = ''; |
|
| 32 | + $extra = ''; |
|
| 33 | 33 | |
| 34 | - include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini |
|
| 35 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 36 | - echo $commencer_page($titre); |
|
| 34 | + include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini |
|
| 35 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 36 | + echo $commencer_page($titre); |
|
| 37 | 37 | |
| 38 | - echo debut_gauche(); |
|
| 39 | - echo pipeline('affiche_gauche', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 38 | + echo debut_gauche(); |
|
| 39 | + echo pipeline('affiche_gauche', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 40 | 40 | |
| 41 | - echo creer_colonne_droite(); |
|
| 42 | - echo pipeline('affiche_droite', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 41 | + echo creer_colonne_droite(); |
|
| 42 | + echo pipeline('affiche_droite', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 43 | 43 | |
| 44 | - echo debut_droite(); |
|
| 45 | - echo "<h1 class='grostitre'>" . _T('fichier_introuvable', ['fichier' => $exec]) . '</h1>'; |
|
| 46 | - echo pipeline('affiche_milieu', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 44 | + echo debut_droite(); |
|
| 45 | + echo "<h1 class='grostitre'>" . _T('fichier_introuvable', ['fichier' => $exec]) . '</h1>'; |
|
| 46 | + echo pipeline('affiche_milieu', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 47 | 47 | |
| 48 | - echo fin_gauche(), fin_page(); |
|
| 48 | + echo fin_gauche(), fin_page(); |
|
| 49 | 49 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | echo pipeline('affiche_droite', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
| 43 | 43 | |
| 44 | 44 | echo debut_droite(); |
| 45 | - echo "<h1 class='grostitre'>" . _T('fichier_introuvable', ['fichier' => $exec]) . '</h1>'; |
|
| 45 | + echo "<h1 class='grostitre'>"._T('fichier_introuvable', ['fichier' => $exec]).'</h1>'; |
|
| 46 | 46 | echo pipeline('affiche_milieu', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
| 47 | 47 | |
| 48 | 48 | echo fin_gauche(), fin_page(); |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | **/ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | include_spip('inc/acces'); |
@@ -101,93 +101,93 @@ discard block |
||
| 101 | 101 | * @return int|bool Timestamp du verrou, false si erreur |
| 102 | 102 | */ |
| 103 | 103 | function spip_nfslock($fichier, $max_age = 0) { |
| 104 | - $tries = 0; |
|
| 104 | + $tries = 0; |
|
| 105 | 105 | |
| 106 | - if (!$max_age) { |
|
| 107 | - $max_age = _DEFAULT_LOCKTIME; |
|
| 108 | - } |
|
| 109 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 106 | + if (!$max_age) { |
|
| 107 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 108 | + } |
|
| 109 | + $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | - /* |
|
| 112 | + /* |
|
| 113 | 113 | * 1. create a tmp file with a psuedo random file name. we also make |
| 114 | 114 | * tpath which is a buffer to store the full pathname of the tmp file. |
| 115 | 115 | */ |
| 116 | 116 | |
| 117 | - $id = creer_uniqid(); |
|
| 118 | - $tpath = _DIR_TMP . "slock.$id"; |
|
| 119 | - $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 120 | - if (!$tmpfd) { /* open failed */ |
|
| 121 | - @fclose($tmpfd); |
|
| 122 | - spip_unlink($tpath); |
|
| 117 | + $id = creer_uniqid(); |
|
| 118 | + $tpath = _DIR_TMP . "slock.$id"; |
|
| 119 | + $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 120 | + if (!$tmpfd) { /* open failed */ |
|
| 121 | + @fclose($tmpfd); |
|
| 122 | + spip_unlink($tpath); |
|
| 123 | 123 | |
| 124 | - return false; //NFSL_SYSF |
|
| 125 | - } |
|
| 124 | + return false; //NFSL_SYSF |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /* |
|
| 127 | + /* |
|
| 128 | 128 | * 2. make fullpath, a buffer for the full pathname of the lock file. |
| 129 | 129 | * then start looping trying to lock it |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | - while ($tries < 10) { |
|
| 133 | - /* |
|
| 132 | + while ($tries < 10) { |
|
| 133 | + /* |
|
| 134 | 134 | * 3. link tmp file to lock file. if it goes, we win and we clean |
| 135 | 135 | * up and return the st_ctime of the lock file. |
| 136 | 136 | */ |
| 137 | 137 | |
| 138 | - if (link($tpath, $lock_file) == 1) { |
|
| 139 | - spip_unlink($tpath); /* got it! */ |
|
| 140 | - @fclose($tmpfd); |
|
| 141 | - if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 142 | - spip_unlink($lock_file); |
|
| 138 | + if (link($tpath, $lock_file) == 1) { |
|
| 139 | + spip_unlink($tpath); /* got it! */ |
|
| 140 | + @fclose($tmpfd); |
|
| 141 | + if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 142 | + spip_unlink($lock_file); |
|
| 143 | 143 | |
| 144 | - return false; // (NFSL_SYSF); |
|
| 145 | - } |
|
| 144 | + return false; // (NFSL_SYSF); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - return ($our_tmp['ctime']); |
|
| 148 | - } |
|
| 147 | + return ($our_tmp['ctime']); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /* |
|
| 150 | + /* |
|
| 151 | 151 | * 4. the lock failed. check for a stale lock file, being mindful |
| 152 | 152 | * of NFS and the fact the time is set from the NFS server. we |
| 153 | 153 | * do a write on the tmp file to update its time to the server's |
| 154 | 154 | * idea of "now." |
| 155 | 155 | */ |
| 156 | 156 | |
| 157 | - $old_stat = lstat($lock_file); |
|
| 158 | - if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) { |
|
| 159 | - break; |
|
| 160 | - } /* something bogus is going on */ |
|
| 157 | + $old_stat = lstat($lock_file); |
|
| 158 | + if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) { |
|
| 159 | + break; |
|
| 160 | + } /* something bogus is going on */ |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | - if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 164 | - spip_unlink($lock_file); /* break the stale lock */ |
|
| 165 | - $tries++; |
|
| 166 | - /* It is CRITICAL that we sleep after breaking |
|
| 163 | + if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 164 | + spip_unlink($lock_file); /* break the stale lock */ |
|
| 165 | + $tries++; |
|
| 166 | + /* It is CRITICAL that we sleep after breaking |
|
| 167 | 167 | * the lock. Otherwise, we could race with |
| 168 | 168 | * another process and unlink it's newly- |
| 169 | 169 | * created file. |
| 170 | 170 | */ |
| 171 | - sleep(1 + random_int(0, 4)); |
|
| 172 | - continue; |
|
| 173 | - } |
|
| 171 | + sleep(1 + random_int(0, 4)); |
|
| 172 | + continue; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - /* |
|
| 175 | + /* |
|
| 176 | 176 | * 5. try again |
| 177 | 177 | */ |
| 178 | 178 | |
| 179 | - $tries++; |
|
| 180 | - sleep(1 + random_int(0, 4)); |
|
| 181 | - } |
|
| 179 | + $tries++; |
|
| 180 | + sleep(1 + random_int(0, 4)); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /* |
|
| 183 | + /* |
|
| 184 | 184 | * 6. give up, failure. |
| 185 | 185 | */ |
| 186 | 186 | |
| 187 | - spip_unlink($tpath); |
|
| 188 | - @fclose($tmpfd); |
|
| 187 | + spip_unlink($tpath); |
|
| 188 | + @fclose($tmpfd); |
|
| 189 | 189 | |
| 190 | - return false; //(NFSL_LOCKED); |
|
| 190 | + return false; //(NFSL_LOCKED); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -231,75 +231,75 @@ discard block |
||
| 231 | 231 | * return bool true si déverrouillé, false sinon |
| 232 | 232 | */ |
| 233 | 233 | function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) { |
| 234 | - $id = creer_uniqid(); |
|
| 235 | - if (!$max_age) { |
|
| 236 | - $max_age = _DEFAULT_LOCKTIME; |
|
| 237 | - } |
|
| 234 | + $id = creer_uniqid(); |
|
| 235 | + if (!$max_age) { |
|
| 236 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - /* |
|
| 239 | + /* |
|
| 240 | 240 | * 1. Build a temp file and stat that to get an idea of what the server |
| 241 | 241 | * thinks the current time is (our_tmp.st_ctime).. |
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | - $tpath = _DIR_TMP . "stime.$id"; |
|
| 245 | - $tmpfd = @fopen($tpath, 'w'); |
|
| 246 | - if ( |
|
| 247 | - (!$tmpfd) |
|
| 248 | - or (@fputs($tmpfd, 'zz', 2) != 2) |
|
| 249 | - or !($our_tmp = fstat($tmpfd)) |
|
| 250 | - ) { |
|
| 251 | - /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 252 | - @fclose($tmpfd); |
|
| 253 | - spip_unlink($tpath); |
|
| 244 | + $tpath = _DIR_TMP . "stime.$id"; |
|
| 245 | + $tmpfd = @fopen($tpath, 'w'); |
|
| 246 | + if ( |
|
| 247 | + (!$tmpfd) |
|
| 248 | + or (@fputs($tmpfd, 'zz', 2) != 2) |
|
| 249 | + or !($our_tmp = fstat($tmpfd)) |
|
| 250 | + ) { |
|
| 251 | + /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 252 | + @fclose($tmpfd); |
|
| 253 | + spip_unlink($tpath); |
|
| 254 | 254 | |
| 255 | - return false; //(NFSL_SYSF); |
|
| 256 | - } |
|
| 255 | + return false; //(NFSL_SYSF); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 259 | - spip_unlink($tpath); |
|
| 258 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 259 | + spip_unlink($tpath); |
|
| 260 | 260 | |
| 261 | - /* |
|
| 261 | + /* |
|
| 262 | 262 | * 2. make fullpath, a buffer for the full pathname of the lock file |
| 263 | 263 | */ |
| 264 | 264 | |
| 265 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 265 | + $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 266 | 266 | |
| 267 | - /* |
|
| 267 | + /* |
|
| 268 | 268 | * 3. If the ctime hasn't been modified, unlink the file and return. If the |
| 269 | 269 | * lock has expired, sleep the usual random interval before returning. |
| 270 | 270 | * If we didn't sleep, there could be a race if the caller immediately |
| 271 | 271 | * tries to relock the file. |
| 272 | 272 | */ |
| 273 | 273 | |
| 274 | - if ( |
|
| 275 | - ($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 276 | - && ($old_stat['ctime'] == $birth) |
|
| 277 | - ) { /* hasn't been modified since birth */ |
|
| 278 | - if (!$test) { |
|
| 279 | - spip_unlink($lock_file); |
|
| 280 | - } /* so the lock is ours to remove */ |
|
| 281 | - if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 282 | - if (!$test) { |
|
| 283 | - return false; |
|
| 284 | - } //(NFSL_LOST); |
|
| 285 | - sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - return true;//(NFSL_OK); /* success */ |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /* |
|
| 274 | + if ( |
|
| 275 | + ($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 276 | + && ($old_stat['ctime'] == $birth) |
|
| 277 | + ) { /* hasn't been modified since birth */ |
|
| 278 | + if (!$test) { |
|
| 279 | + spip_unlink($lock_file); |
|
| 280 | + } /* so the lock is ours to remove */ |
|
| 281 | + if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 282 | + if (!$test) { |
|
| 283 | + return false; |
|
| 284 | + } //(NFSL_LOST); |
|
| 285 | + sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + return true;//(NFSL_OK); /* success */ |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /* |
|
| 292 | 292 | * 4. Either ctime has been modified, or the entire lock file is missing. |
| 293 | 293 | * If the lock should still be ours, based on the ctime of the temp |
| 294 | 294 | * file, return with NFSL_STOLEN. If not, then our lock is expired and |
| 295 | 295 | * someone else has grabbed the file, so return NFSL_LOST. |
| 296 | 296 | */ |
| 297 | 297 | |
| 298 | - if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */ |
|
| 299 | - return false; |
|
| 300 | - } //(NFSL_STOLEN); |
|
| 298 | + if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */ |
|
| 299 | + return false; |
|
| 300 | + } //(NFSL_STOLEN); |
|
| 301 | 301 | |
| 302 | - return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 302 | + return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
@@ -323,5 +323,5 @@ discard block |
||
| 323 | 323 | * return bool true si déverrouillé, false sinon |
| 324 | 324 | */ |
| 325 | 325 | function spip_nfslock_test($fichier, $birth, $max_age = 0) { |
| 326 | - return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 326 | + return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 327 | 327 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if (!$max_age) { |
| 107 | 107 | $max_age = _DEFAULT_LOCKTIME; |
| 108 | 108 | } |
| 109 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 109 | + $lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | /* |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | |
| 117 | 117 | $id = creer_uniqid(); |
| 118 | - $tpath = _DIR_TMP . "slock.$id"; |
|
| 118 | + $tpath = _DIR_TMP."slock.$id"; |
|
| 119 | 119 | $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
| 120 | 120 | if (!$tmpfd) { /* open failed */ |
| 121 | 121 | @fclose($tmpfd); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * thinks the current time is (our_tmp.st_ctime).. |
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | - $tpath = _DIR_TMP . "stime.$id"; |
|
| 244 | + $tpath = _DIR_TMP."stime.$id"; |
|
| 245 | 245 | $tmpfd = @fopen($tpath, 'w'); |
| 246 | 246 | if ( |
| 247 | 247 | (!$tmpfd) |
@@ -255,14 +255,14 @@ discard block |
||
| 255 | 255 | return false; //(NFSL_SYSF); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 258 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 259 | 259 | spip_unlink($tpath); |
| 260 | 260 | |
| 261 | 261 | /* |
| 262 | 262 | * 2. make fullpath, a buffer for the full pathname of the lock file |
| 263 | 263 | */ |
| 264 | 264 | |
| 265 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 265 | + $lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8); |
|
| 266 | 266 | |
| 267 | 267 | /* |
| 268 | 268 | * 3. If the ctime hasn't been modified, unlink the file and return. If the |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | if (!$test) { |
| 283 | 283 | return false; |
| 284 | 284 | } //(NFSL_LOST); |
| 285 | - sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 285 | + sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - return true;//(NFSL_OK); /* success */ |
|
| 288 | + return true; //(NFSL_OK); /* success */ |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /* |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -33,118 +33,118 @@ discard block |
||
| 33 | 33 | **/ |
| 34 | 34 | function analyse_csv($t) { |
| 35 | 35 | |
| 36 | - // Quel est le séparateur ? |
|
| 37 | - $virg = substr_count($t, ','); |
|
| 38 | - $pvirg = substr_count($t, ';'); |
|
| 39 | - $tab = substr_count($t, "\t"); |
|
| 40 | - if ($virg > $pvirg) { |
|
| 41 | - $sep = ','; |
|
| 42 | - $hs = ','; |
|
| 43 | - } else { |
|
| 44 | - $sep = ';'; |
|
| 45 | - $hs = ';'; |
|
| 46 | - $virg = $pvirg; |
|
| 47 | - } |
|
| 48 | - // un certain nombre de tab => le séparateur est tab |
|
| 49 | - if ($tab > $virg / 10) { |
|
| 50 | - $sep = "\t"; |
|
| 51 | - $hs = "\t"; |
|
| 52 | - } |
|
| 36 | + // Quel est le séparateur ? |
|
| 37 | + $virg = substr_count($t, ','); |
|
| 38 | + $pvirg = substr_count($t, ';'); |
|
| 39 | + $tab = substr_count($t, "\t"); |
|
| 40 | + if ($virg > $pvirg) { |
|
| 41 | + $sep = ','; |
|
| 42 | + $hs = ','; |
|
| 43 | + } else { |
|
| 44 | + $sep = ';'; |
|
| 45 | + $hs = ';'; |
|
| 46 | + $virg = $pvirg; |
|
| 47 | + } |
|
| 48 | + // un certain nombre de tab => le séparateur est tab |
|
| 49 | + if ($tab > $virg / 10) { |
|
| 50 | + $sep = "\t"; |
|
| 51 | + $hs = "\t"; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - // un separateur suivi de 3 guillemets attention ! |
|
| 55 | - // attention au ; ou , suceptible d'etre confondu avec un separateur |
|
| 56 | - // on substitue un # et on remplacera a la fin |
|
| 57 | - $t = preg_replace("/([\n$sep])\"\"\"/", '\\1""#', $t); |
|
| 58 | - $t = str_replace('""', '"#', $t); |
|
| 59 | - preg_match_all('/"[^"]*"/', $t, $r); |
|
| 60 | - foreach ($r[0] as $cell) { |
|
| 61 | - $t = str_replace( |
|
| 62 | - $cell, |
|
| 63 | - str_replace( |
|
| 64 | - $sep, |
|
| 65 | - $hs, |
|
| 66 | - str_replace( |
|
| 67 | - "\n", |
|
| 68 | - '``**``', // échapper les saut de lignes, on les remettra après. |
|
| 69 | - substr($cell, 1, -1) |
|
| 70 | - ) |
|
| 71 | - ), |
|
| 72 | - $t |
|
| 73 | - ); |
|
| 74 | - } |
|
| 54 | + // un separateur suivi de 3 guillemets attention ! |
|
| 55 | + // attention au ; ou , suceptible d'etre confondu avec un separateur |
|
| 56 | + // on substitue un # et on remplacera a la fin |
|
| 57 | + $t = preg_replace("/([\n$sep])\"\"\"/", '\\1""#', $t); |
|
| 58 | + $t = str_replace('""', '"#', $t); |
|
| 59 | + preg_match_all('/"[^"]*"/', $t, $r); |
|
| 60 | + foreach ($r[0] as $cell) { |
|
| 61 | + $t = str_replace( |
|
| 62 | + $cell, |
|
| 63 | + str_replace( |
|
| 64 | + $sep, |
|
| 65 | + $hs, |
|
| 66 | + str_replace( |
|
| 67 | + "\n", |
|
| 68 | + '``**``', // échapper les saut de lignes, on les remettra après. |
|
| 69 | + substr($cell, 1, -1) |
|
| 70 | + ) |
|
| 71 | + ), |
|
| 72 | + $t |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $t = preg_replace( |
|
| 77 | - '/\r?\n/', |
|
| 78 | - "\n", |
|
| 79 | - preg_replace('/[\r\n]+/', "\n", $t) |
|
| 80 | - ); |
|
| 76 | + $t = preg_replace( |
|
| 77 | + '/\r?\n/', |
|
| 78 | + "\n", |
|
| 79 | + preg_replace('/[\r\n]+/', "\n", $t) |
|
| 80 | + ); |
|
| 81 | 81 | |
| 82 | - [$entete, $corps] = explode("\n", $t, 2); |
|
| 83 | - $caption = ''; |
|
| 84 | - // sauter la ligne de tete formee seulement de separateurs |
|
| 85 | - if (substr_count($entete, $sep) == strlen($entete)) { |
|
| 86 | - [$entete, $corps] = explode("\n", $corps, 2); |
|
| 87 | - } |
|
| 88 | - // si une seule colonne, en faire le titre |
|
| 89 | - if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) { |
|
| 90 | - $caption = "\n||" . $l[1] . '|'; |
|
| 91 | - [$entete, $corps] = explode("\n", $corps, 2); |
|
| 92 | - } |
|
| 93 | - // si premiere colonne vide, le raccourci doit quand meme produire <th... |
|
| 94 | - if ($entete[0] == $sep) { |
|
| 95 | - $entete = ' ' . $entete; |
|
| 96 | - } |
|
| 82 | + [$entete, $corps] = explode("\n", $t, 2); |
|
| 83 | + $caption = ''; |
|
| 84 | + // sauter la ligne de tete formee seulement de separateurs |
|
| 85 | + if (substr_count($entete, $sep) == strlen($entete)) { |
|
| 86 | + [$entete, $corps] = explode("\n", $corps, 2); |
|
| 87 | + } |
|
| 88 | + // si une seule colonne, en faire le titre |
|
| 89 | + if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) { |
|
| 90 | + $caption = "\n||" . $l[1] . '|'; |
|
| 91 | + [$entete, $corps] = explode("\n", $corps, 2); |
|
| 92 | + } |
|
| 93 | + // si premiere colonne vide, le raccourci doit quand meme produire <th... |
|
| 94 | + if ($entete[0] == $sep) { |
|
| 95 | + $entete = ' ' . $entete; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - $lignes = explode("\n", $corps); |
|
| 98 | + $lignes = explode("\n", $corps); |
|
| 99 | 99 | |
| 100 | - // retrait des lignes vides finales |
|
| 101 | - while ( |
|
| 102 | - count($lignes) > 0 |
|
| 103 | - and preg_match("/^$sep*$/", $lignes[count($lignes) - 1]) |
|
| 104 | - ) { |
|
| 105 | - unset($lignes[count($lignes) - 1]); |
|
| 106 | - } |
|
| 107 | - // calcul du nombre de colonne a chaque ligne |
|
| 108 | - $nbcols = []; |
|
| 109 | - $max = $mil = substr_count($entete, $sep); |
|
| 110 | - foreach ($lignes as $k => $v) { |
|
| 111 | - if ($max <> ($nbcols[$k] = substr_count($v, $sep))) { |
|
| 112 | - if ($max > $nbcols[$k]) { |
|
| 113 | - $mil = $nbcols[$k]; |
|
| 114 | - } else { |
|
| 115 | - $mil = $max; |
|
| 116 | - $max = $nbcols[$k]; |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - // Si pas le meme nombre, cadrer au nombre max |
|
| 121 | - if ($mil <> $max) { |
|
| 122 | - foreach ($nbcols as $k => $v) { |
|
| 123 | - if ($v < $max) { |
|
| 124 | - $lignes[$k] .= str_repeat($sep, $max - $v); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - // et retirer les colonnes integralement vides |
|
| 129 | - while (true) { |
|
| 130 | - $nbcols = ($entete[strlen($entete) - 1] === $sep); |
|
| 131 | - foreach ($lignes as $v) { |
|
| 132 | - $nbcols &= ($v[strlen($v) - 1] === $sep); |
|
| 133 | - } |
|
| 134 | - if (!$nbcols) { |
|
| 135 | - break; |
|
| 136 | - } |
|
| 137 | - $entete = substr($entete, 0, -1); |
|
| 138 | - foreach ($lignes as $k => $v) { |
|
| 139 | - $lignes[$k] = substr($v, 0, -1); |
|
| 140 | - } |
|
| 141 | - } |
|
| 100 | + // retrait des lignes vides finales |
|
| 101 | + while ( |
|
| 102 | + count($lignes) > 0 |
|
| 103 | + and preg_match("/^$sep*$/", $lignes[count($lignes) - 1]) |
|
| 104 | + ) { |
|
| 105 | + unset($lignes[count($lignes) - 1]); |
|
| 106 | + } |
|
| 107 | + // calcul du nombre de colonne a chaque ligne |
|
| 108 | + $nbcols = []; |
|
| 109 | + $max = $mil = substr_count($entete, $sep); |
|
| 110 | + foreach ($lignes as $k => $v) { |
|
| 111 | + if ($max <> ($nbcols[$k] = substr_count($v, $sep))) { |
|
| 112 | + if ($max > $nbcols[$k]) { |
|
| 113 | + $mil = $nbcols[$k]; |
|
| 114 | + } else { |
|
| 115 | + $mil = $max; |
|
| 116 | + $max = $nbcols[$k]; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + // Si pas le meme nombre, cadrer au nombre max |
|
| 121 | + if ($mil <> $max) { |
|
| 122 | + foreach ($nbcols as $k => $v) { |
|
| 123 | + if ($v < $max) { |
|
| 124 | + $lignes[$k] .= str_repeat($sep, $max - $v); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + // et retirer les colonnes integralement vides |
|
| 129 | + while (true) { |
|
| 130 | + $nbcols = ($entete[strlen($entete) - 1] === $sep); |
|
| 131 | + foreach ($lignes as $v) { |
|
| 132 | + $nbcols &= ($v[strlen($v) - 1] === $sep); |
|
| 133 | + } |
|
| 134 | + if (!$nbcols) { |
|
| 135 | + break; |
|
| 136 | + } |
|
| 137 | + $entete = substr($entete, 0, -1); |
|
| 138 | + foreach ($lignes as $k => $v) { |
|
| 139 | + $lignes[$k] = substr($v, 0, -1); |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - foreach ($lignes as &$l) { |
|
| 144 | - $l = str_replace('"#', '"', $l); |
|
| 145 | - $l = str_replace('``**``', "\n", $l); |
|
| 146 | - $l = explode($sep, $l); |
|
| 147 | - } |
|
| 143 | + foreach ($lignes as &$l) { |
|
| 144 | + $l = str_replace('"#', '"', $l); |
|
| 145 | + $l = str_replace('``**``', "\n", $l); |
|
| 146 | + $l = explode($sep, $l); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - return [explode($sep, $entete), $lignes, $caption]; |
|
| 149 | + return [explode($sep, $entete), $lignes, $caption]; |
|
| 150 | 150 | } |
@@ -87,12 +87,12 @@ |
||
| 87 | 87 | } |
| 88 | 88 | // si une seule colonne, en faire le titre |
| 89 | 89 | if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) { |
| 90 | - $caption = "\n||" . $l[1] . '|'; |
|
| 90 | + $caption = "\n||".$l[1].'|'; |
|
| 91 | 91 | [$entete, $corps] = explode("\n", $corps, 2); |
| 92 | 92 | } |
| 93 | 93 | // si premiere colonne vide, le raccourci doit quand meme produire <th... |
| 94 | 94 | if ($entete[0] == $sep) { |
| 95 | - $entete = ' ' . $entete; |
|
| 95 | + $entete = ' '.$entete; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $lignes = explode("\n", $corps); |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Regarder dans le repertoire local des images TeX et blocs MathML |
| 40 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | + if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/')) { |
|
| 41 | 41 | @mkdir($dir_tex, _SPIP_CHMOD); |
| 42 | 42 | } |
| 43 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | + $fichier = $dir_tex.md5(trim($tex)).$ext; |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | if (!@file_exists($fichier)) { |
| 47 | 47 | // Aller chercher l'image sur le serveur |
| 48 | 48 | if ($server) { |
| 49 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | + spip_log($url = $server.'?'.rawurlencode($tex)); |
|
| 50 | 50 | include_spip('inc/distant'); |
| 51 | 51 | recuperer_url($url, ['file' => $fichier]); |
| 52 | 52 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | return implode('', file($fichier)); |
| 62 | 62 | } // TeX |
| 63 | 63 | else { |
| 64 | - [, , , $size] = @spip_getimagesize($fichier); |
|
| 64 | + [,,, $size] = @spip_getimagesize($fichier); |
|
| 65 | 65 | $alt = "alt=\"$tex\" title=\"$tex\""; |
| 66 | 66 | |
| 67 | 67 | return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | if ($defaire_amp) { |
| 129 | 129 | $expression = str_replace('&', '&', $expression); |
| 130 | 130 | } |
| 131 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">".produire_image_math($expression)."</p>\n"; |
|
| 132 | 132 | $pos = strpos($texte_milieu, (string) $regs[0]); |
| 133 | 133 | $texte_milieu = substr($texte_milieu, 0, $pos) |
| 134 | 134 | . code_echappement($echap, $source) |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | . substr($texte_milieu, $pos + strlen($regs[0])); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | + $texte_a_voir = $texte_debut.$texte_milieu.$texte_fin; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return $texte_a_voir; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // |
@@ -21,54 +21,54 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | function produire_image_math($tex) { |
| 23 | 23 | |
| 24 | - switch ($GLOBALS['traiter_math']) { |
|
| 25 | - // Attention: mathml desactiv'e pour l'instant |
|
| 26 | - case 'mathml': |
|
| 27 | - $ext = '.xhtml'; |
|
| 28 | - $server = $GLOBALS['mathml_server']; |
|
| 29 | - break; |
|
| 30 | - case 'tex': |
|
| 31 | - $ext = '.png'; |
|
| 32 | - $server = $GLOBALS['tex_server']; |
|
| 33 | - break; |
|
| 34 | - default: |
|
| 35 | - return $tex; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 39 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | - @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 41 | - } |
|
| 42 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - if (!@file_exists($fichier)) { |
|
| 46 | - // Aller chercher l'image sur le serveur |
|
| 47 | - if ($server) { |
|
| 48 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | - include_spip('inc/distant'); |
|
| 50 | - recuperer_url($url, ['file' => $fichier]); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - // Composer la reponse selon presence ou non de l'image |
|
| 56 | - $tex = entites_html($tex); |
|
| 57 | - if (@file_exists($fichier)) { |
|
| 58 | - // MathML |
|
| 59 | - if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 60 | - return implode('', file($fichier)); |
|
| 61 | - } // TeX |
|
| 62 | - else { |
|
| 63 | - [, , , $size] = @spip_getimagesize($fichier); |
|
| 64 | - $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 65 | - |
|
| 66 | - return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 67 | - } |
|
| 68 | - } else // pas de fichier |
|
| 69 | - { |
|
| 70 | - return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 71 | - } |
|
| 24 | + switch ($GLOBALS['traiter_math']) { |
|
| 25 | + // Attention: mathml desactiv'e pour l'instant |
|
| 26 | + case 'mathml': |
|
| 27 | + $ext = '.xhtml'; |
|
| 28 | + $server = $GLOBALS['mathml_server']; |
|
| 29 | + break; |
|
| 30 | + case 'tex': |
|
| 31 | + $ext = '.png'; |
|
| 32 | + $server = $GLOBALS['tex_server']; |
|
| 33 | + break; |
|
| 34 | + default: |
|
| 35 | + return $tex; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 39 | + if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | + @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 41 | + } |
|
| 42 | + $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + if (!@file_exists($fichier)) { |
|
| 46 | + // Aller chercher l'image sur le serveur |
|
| 47 | + if ($server) { |
|
| 48 | + spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | + include_spip('inc/distant'); |
|
| 50 | + recuperer_url($url, ['file' => $fichier]); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + // Composer la reponse selon presence ou non de l'image |
|
| 56 | + $tex = entites_html($tex); |
|
| 57 | + if (@file_exists($fichier)) { |
|
| 58 | + // MathML |
|
| 59 | + if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 60 | + return implode('', file($fichier)); |
|
| 61 | + } // TeX |
|
| 62 | + else { |
|
| 63 | + [, , , $size] = @spip_getimagesize($fichier); |
|
| 64 | + $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 65 | + |
|
| 66 | + return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 67 | + } |
|
| 68 | + } else // pas de fichier |
|
| 69 | + { |
|
| 70 | + return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -103,52 +103,52 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | function traiter_math($letexte, $source = '', $defaire_amp = false) { |
| 105 | 105 | |
| 106 | - $texte_a_voir = $letexte; |
|
| 107 | - while (($debut = strpos($texte_a_voir, '<math>')) !== false) { |
|
| 108 | - if (!$fin = strpos($texte_a_voir, '</math>')) { |
|
| 109 | - $fin = strlen($texte_a_voir); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 113 | - $texte_milieu = substr( |
|
| 114 | - $texte_a_voir, |
|
| 115 | - $debut + strlen('<math>'), |
|
| 116 | - $fin - $debut - strlen('<math>') |
|
| 117 | - ); |
|
| 118 | - $texte_fin = substr( |
|
| 119 | - $texte_a_voir, |
|
| 120 | - $fin + strlen('</math>'), |
|
| 121 | - strlen($texte_a_voir) |
|
| 122 | - ); |
|
| 123 | - |
|
| 124 | - // Les doubles $$x^2$$ en mode 'div' |
|
| 125 | - while ((preg_match(',[$][$]([^$]+)[$][$],', $texte_milieu, $regs))) { |
|
| 126 | - $expression = $regs[1]; |
|
| 127 | - if ($defaire_amp) { |
|
| 128 | - $expression = str_replace('&', '&', $expression); |
|
| 129 | - } |
|
| 130 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | - $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 132 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 133 | - . code_echappement($echap, $source) |
|
| 134 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // Les simples $x^2$ en mode 'span' |
|
| 138 | - while ((preg_match(',[$]([^$]+)[$],', $texte_milieu, $regs))) { |
|
| 139 | - $expression = $regs[1]; |
|
| 140 | - if ($defaire_amp) { |
|
| 141 | - $expression = str_replace('&', '&', $expression); |
|
| 142 | - } |
|
| 143 | - $echap = produire_image_math($expression); |
|
| 144 | - $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 145 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 146 | - . code_echappement($echap, $source) |
|
| 147 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return $texte_a_voir; |
|
| 106 | + $texte_a_voir = $letexte; |
|
| 107 | + while (($debut = strpos($texte_a_voir, '<math>')) !== false) { |
|
| 108 | + if (!$fin = strpos($texte_a_voir, '</math>')) { |
|
| 109 | + $fin = strlen($texte_a_voir); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 113 | + $texte_milieu = substr( |
|
| 114 | + $texte_a_voir, |
|
| 115 | + $debut + strlen('<math>'), |
|
| 116 | + $fin - $debut - strlen('<math>') |
|
| 117 | + ); |
|
| 118 | + $texte_fin = substr( |
|
| 119 | + $texte_a_voir, |
|
| 120 | + $fin + strlen('</math>'), |
|
| 121 | + strlen($texte_a_voir) |
|
| 122 | + ); |
|
| 123 | + |
|
| 124 | + // Les doubles $$x^2$$ en mode 'div' |
|
| 125 | + while ((preg_match(',[$][$]([^$]+)[$][$],', $texte_milieu, $regs))) { |
|
| 126 | + $expression = $regs[1]; |
|
| 127 | + if ($defaire_amp) { |
|
| 128 | + $expression = str_replace('&', '&', $expression); |
|
| 129 | + } |
|
| 130 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | + $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 132 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 133 | + . code_echappement($echap, $source) |
|
| 134 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // Les simples $x^2$ en mode 'span' |
|
| 138 | + while ((preg_match(',[$]([^$]+)[$],', $texte_milieu, $regs))) { |
|
| 139 | + $expression = $regs[1]; |
|
| 140 | + if ($defaire_amp) { |
|
| 141 | + $expression = str_replace('&', '&', $expression); |
|
| 142 | + } |
|
| 143 | + $echap = produire_image_math($expression); |
|
| 144 | + $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 145 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 146 | + . code_echappement($echap, $source) |
|
| 147 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $texte_a_voir; |
|
| 154 | 154 | } |