@@ -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 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $select = true |
| 125 | 125 | ) { |
| 126 | 126 | if (!is_string($defaut)) { |
| 127 | - $defaut = '($Pile[0][\'' . strtolower($nom_champ) . '\'] ?? null)'; |
|
| 127 | + $defaut = '($Pile[0][\''.strtolower($nom_champ).'\'] ?? null)'; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | $idb_origine = $idb; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | // renseigner la boucle source de ce champ pour les traitements |
| 159 | 159 | $boucles[$idb_origine]->index_champ[$nom_champ_origine] = $idb; |
| 160 | - $champ = '$Pile[$SP' . ($i ? "-$i" : '') . '][\'' . $c . '\']'; |
|
| 160 | + $champ = '$Pile[$SP'.($i ? "-$i" : '').'][\''.$c.'\']'; |
|
| 161 | 161 | if (!$joker) { |
| 162 | 162 | return index_compose($conditionnel, $champ); |
| 163 | 163 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | function index_compose($conditionnel, $defaut) { |
| 199 | 199 | while ($c = array_pop($conditionnel)) { |
| 200 | 200 | // si on passe defaut = '', ne pas générer d'erreur de compilation. |
| 201 | - $defaut = "($c:(" . ($defaut ?: "''") . '))'; |
|
| 201 | + $defaut = "($c:(".($defaut ?: "''").'))'; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | return $defaut; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | if (!$r) { |
| 246 | 246 | $joker = false; // indiquer a l'appelant |
| 247 | 247 | # continuer pour chercher l'erreur suivante |
| 248 | - return ["'#" . $r . ':' . $nom_champ . "'", '']; |
|
| 248 | + return ["'#".$r.':'.$nom_champ."'", '']; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | $desc = $boucles[$idb]->show; |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | $t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep); |
| 349 | 349 | } |
| 350 | 350 | if ($t == null) { |
| 351 | - [$e, $x] = $excep; #PHP4 affecte de gauche a droite |
|
| 352 | - $excep = $x; #PHP5 de droite a gauche ! |
|
| 351 | + [$e, $x] = $excep; #PHP4 affecte de gauche a droite |
|
| 352 | + $excep = $x; #PHP5 de droite a gauche ! |
|
| 353 | 353 | $j = $trouver_table($e, $boucle->sql_serveur); |
| 354 | 354 | if (!$j) { |
| 355 | 355 | return ['', '']; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | $l = (preg_split('/\s*,\s*/', $k)); |
| 362 | 362 | $k = $desc['key']['PRIMARY KEY']; |
| 363 | 363 | if (!in_array($k, $l)) { |
| 364 | - spip_log("jointure impossible $e " . join(',', $l)); |
|
| 364 | + spip_log("jointure impossible $e ".join(',', $l)); |
|
| 365 | 365 | |
| 366 | 366 | return ['', '']; |
| 367 | 367 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | // demander a SQL de gerer le synonyme |
| 378 | 378 | // ca permet que excep soit dynamique (Cedric, 2/3/06) |
| 379 | 379 | if ($excep != $nom_champ) { |
| 380 | - $excep .= ' AS ' . $nom_champ; |
|
| 380 | + $excep .= ' AS '.$nom_champ; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | return ["$t.$excep", $nom_champ]; |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | join(',', $collecte), |
| 612 | 612 | ($collecte ? $param : substr($param, 1)), # virer la virgule |
| 613 | 613 | memoriser_contexte_compil($p), |
| 614 | - (!$supp ? '' : (', ' . join(',', $supp))) |
|
| 614 | + (!$supp ? '' : (', '.join(',', $supp))) |
|
| 615 | 615 | ); |
| 616 | 616 | |
| 617 | 617 | $p->interdire_scripts = false; |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | $nom = $p->id_boucle; |
| 710 | 710 | |
| 711 | 711 | if ($nom and trouver_nom_serveur_distant($p)) { |
| 712 | - spip_log($nom . ':' . $p->nom_champ . ' ' . _T('zbug_distant_interdit')); |
|
| 712 | + spip_log($nom.':'.$p->nom_champ.' '._T('zbug_distant_interdit')); |
|
| 713 | 713 | |
| 714 | 714 | return false; |
| 715 | 715 | } |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | (strpos($ps, 'typo') !== false) |
| 796 | 796 | ) |
| 797 | 797 | ) { |
| 798 | - $ps = 'traiter_doublons_documents($doublons, ' . $ps . ')'; |
|
| 798 | + $ps = 'traiter_doublons_documents($doublons, '.$ps.')'; |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | // La protection des champs par |safehtml est assuree par les extensions |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | function compose_filtres_args($p, $args, $sep) { |
| 917 | 917 | $arglist = ''; |
| 918 | 918 | foreach ($args as $arg) { |
| 919 | - $arglist .= $sep . |
|
| 919 | + $arglist .= $sep. |
|
| 920 | 920 | calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle); |
| 921 | 921 | } |
| 922 | 922 | |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | while ($b != '') { |
| 968 | 968 | foreach ($p->boucles[$b]->criteres as $critere) { |
| 969 | 969 | if ($critere->op == $motif) { |
| 970 | - $p->code = '$Pile[$SP' . (($n == 0) ? '' : "-$n") . |
|
| 970 | + $p->code = '$Pile[$SP'.(($n == 0) ? '' : "-$n"). |
|
| 971 | 971 | "]['$champ']"; |
| 972 | 972 | $b = ''; |
| 973 | 973 | break 2; |
@@ -995,6 +995,6 @@ discard block |
||
| 995 | 995 | */ |
| 996 | 996 | function zbug_presenter_champ($p, $champ = '') { |
| 997 | 997 | $balise = $champ ?: $p->nom_champ; |
| 998 | - $explicite = $p->nom_boucle ? $p->nom_boucle . ':' : ''; |
|
| 998 | + $explicite = $p->nom_boucle ? $p->nom_boucle.':' : ''; |
|
| 999 | 999 | return "#{$explicite}{$balise}"; |
| 1000 | 1000 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Compilateur\References |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | * - '' si une référence explicite incorrecte est envoyée |
| 42 | 42 | */ |
| 43 | 43 | function index_boucle($p) { |
| 44 | - if (strlen($p->nom_boucle)) { |
|
| 45 | - // retourne l’index explicite demandé s’il existe |
|
| 46 | - if (!empty($p->boucles[$p->nom_boucle])) { |
|
| 47 | - return $p->nom_boucle; |
|
| 48 | - } |
|
| 49 | - return ''; |
|
| 50 | - } |
|
| 51 | - return $p->id_boucle; |
|
| 44 | + if (strlen($p->nom_boucle)) { |
|
| 45 | + // retourne l’index explicite demandé s’il existe |
|
| 46 | + if (!empty($p->boucles[$p->nom_boucle])) { |
|
| 47 | + return $p->nom_boucle; |
|
| 48 | + } |
|
| 49 | + return ''; |
|
| 50 | + } |
|
| 51 | + return $p->id_boucle; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | * - '' si une référence explicite incorrecte est envoyée |
| 72 | 72 | */ |
| 73 | 73 | function index_boucle_mere($p) { |
| 74 | - if (strlen($p->nom_boucle)) { |
|
| 75 | - // retourne l’index explicite demandé s’il existe |
|
| 76 | - if (!empty($p->boucles[$p->nom_boucle])) { |
|
| 77 | - return $p->nom_boucle; |
|
| 78 | - } |
|
| 79 | - return ''; |
|
| 80 | - } |
|
| 81 | - if (!empty($p->descr['id_mere'])) { |
|
| 82 | - return $p->descr['id_mere']; |
|
| 83 | - } |
|
| 84 | - return ''; |
|
| 74 | + if (strlen($p->nom_boucle)) { |
|
| 75 | + // retourne l’index explicite demandé s’il existe |
|
| 76 | + if (!empty($p->boucles[$p->nom_boucle])) { |
|
| 77 | + return $p->nom_boucle; |
|
| 78 | + } |
|
| 79 | + return ''; |
|
| 80 | + } |
|
| 81 | + if (!empty($p->descr['id_mere'])) { |
|
| 82 | + return $p->descr['id_mere']; |
|
| 83 | + } |
|
| 84 | + return ''; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -115,74 +115,74 @@ discard block |
||
| 115 | 115 | * Code PHP pour obtenir le champ SQL |
| 116 | 116 | */ |
| 117 | 117 | function index_pile( |
| 118 | - $idb, |
|
| 119 | - $nom_champ, |
|
| 120 | - &$boucles, |
|
| 121 | - $explicite = '', |
|
| 122 | - $defaut = null, |
|
| 123 | - $remonte_pile = true, |
|
| 124 | - $select = true |
|
| 118 | + $idb, |
|
| 119 | + $nom_champ, |
|
| 120 | + &$boucles, |
|
| 121 | + $explicite = '', |
|
| 122 | + $defaut = null, |
|
| 123 | + $remonte_pile = true, |
|
| 124 | + $select = true |
|
| 125 | 125 | ) { |
| 126 | - if (!is_string($defaut)) { |
|
| 127 | - $defaut = '($Pile[0][\'' . strtolower($nom_champ) . '\'] ?? null)'; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - $idb_origine = $idb; |
|
| 131 | - $nom_champ_origine = $nom_champ; |
|
| 132 | - |
|
| 133 | - $i = 0; |
|
| 134 | - if (strlen($explicite)) { |
|
| 135 | - // Recherche d'un champ dans un etage superieur |
|
| 136 | - while (($idb !== $explicite) && ($idb !== '')) { |
|
| 137 | - # spip_log("Cherchexpl: $nom_champ '$explicite' '$idb' '$i'"); |
|
| 138 | - $i++; |
|
| 139 | - $idb = $boucles[$idb]->id_parent; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - # spip_log("Cherche: $nom_champ a partir de '$idb'"); |
|
| 144 | - $nom_champ = strtolower($nom_champ); |
|
| 145 | - $conditionnel = []; |
|
| 146 | - // attention: entre la boucle nommee 0, "" et le tableau vide, |
|
| 147 | - // il y a incoherences qu'il vaut mieux eviter |
|
| 148 | - while (isset($boucles[$idb])) { |
|
| 149 | - $joker = true; |
|
| 150 | - // modifie $joker si tous les champs sont autorisés. |
|
| 151 | - // $t = le select pour le champ, si on l'a trouvé (ou si joker) |
|
| 152 | - // $c = le nom du champ demandé |
|
| 153 | - [$t, $c] = index_tables_en_pile($idb, $nom_champ, $boucles, $joker); |
|
| 154 | - if ($t) { |
|
| 155 | - if ($select and !in_array($t, $boucles[$idb]->select)) { |
|
| 156 | - $boucles[$idb]->select[] = $t; |
|
| 157 | - } |
|
| 158 | - // renseigner la boucle source de ce champ pour les traitements |
|
| 159 | - $boucles[$idb_origine]->index_champ[$nom_champ_origine] = $idb; |
|
| 160 | - $champ = '$Pile[$SP' . ($i ? "-$i" : '') . '][\'' . $c . '\']'; |
|
| 161 | - if (!$joker) { |
|
| 162 | - return index_compose($conditionnel, $champ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // tant que l'on trouve des tables avec joker, on continue |
|
| 166 | - // avec la boucle parente et on conditionne à l'exécution |
|
| 167 | - // la présence du champ. Si le champ existe à l'exécution |
|
| 168 | - // dans une boucle, il est pris, sinon on le cherche dans le parent... |
|
| 169 | - $conditionnel[] = "isset($champ)?$champ"; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - if ($remonte_pile) { |
|
| 173 | - # spip_log("On remonte vers $i"); |
|
| 174 | - // Sinon on remonte d'un cran |
|
| 175 | - $idb = $boucles[$idb]->id_parent; |
|
| 176 | - $i++; |
|
| 177 | - } else { |
|
| 178 | - $idb = null; |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - # spip_log("Pas vu $nom_champ"); |
|
| 183 | - // esperons qu'il y sera |
|
| 184 | - // ou qu'on a fourni une valeur par "defaut" plus pertinent |
|
| 185 | - return index_compose($conditionnel, $defaut); |
|
| 126 | + if (!is_string($defaut)) { |
|
| 127 | + $defaut = '($Pile[0][\'' . strtolower($nom_champ) . '\'] ?? null)'; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + $idb_origine = $idb; |
|
| 131 | + $nom_champ_origine = $nom_champ; |
|
| 132 | + |
|
| 133 | + $i = 0; |
|
| 134 | + if (strlen($explicite)) { |
|
| 135 | + // Recherche d'un champ dans un etage superieur |
|
| 136 | + while (($idb !== $explicite) && ($idb !== '')) { |
|
| 137 | + # spip_log("Cherchexpl: $nom_champ '$explicite' '$idb' '$i'"); |
|
| 138 | + $i++; |
|
| 139 | + $idb = $boucles[$idb]->id_parent; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + # spip_log("Cherche: $nom_champ a partir de '$idb'"); |
|
| 144 | + $nom_champ = strtolower($nom_champ); |
|
| 145 | + $conditionnel = []; |
|
| 146 | + // attention: entre la boucle nommee 0, "" et le tableau vide, |
|
| 147 | + // il y a incoherences qu'il vaut mieux eviter |
|
| 148 | + while (isset($boucles[$idb])) { |
|
| 149 | + $joker = true; |
|
| 150 | + // modifie $joker si tous les champs sont autorisés. |
|
| 151 | + // $t = le select pour le champ, si on l'a trouvé (ou si joker) |
|
| 152 | + // $c = le nom du champ demandé |
|
| 153 | + [$t, $c] = index_tables_en_pile($idb, $nom_champ, $boucles, $joker); |
|
| 154 | + if ($t) { |
|
| 155 | + if ($select and !in_array($t, $boucles[$idb]->select)) { |
|
| 156 | + $boucles[$idb]->select[] = $t; |
|
| 157 | + } |
|
| 158 | + // renseigner la boucle source de ce champ pour les traitements |
|
| 159 | + $boucles[$idb_origine]->index_champ[$nom_champ_origine] = $idb; |
|
| 160 | + $champ = '$Pile[$SP' . ($i ? "-$i" : '') . '][\'' . $c . '\']'; |
|
| 161 | + if (!$joker) { |
|
| 162 | + return index_compose($conditionnel, $champ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // tant que l'on trouve des tables avec joker, on continue |
|
| 166 | + // avec la boucle parente et on conditionne à l'exécution |
|
| 167 | + // la présence du champ. Si le champ existe à l'exécution |
|
| 168 | + // dans une boucle, il est pris, sinon on le cherche dans le parent... |
|
| 169 | + $conditionnel[] = "isset($champ)?$champ"; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + if ($remonte_pile) { |
|
| 173 | + # spip_log("On remonte vers $i"); |
|
| 174 | + // Sinon on remonte d'un cran |
|
| 175 | + $idb = $boucles[$idb]->id_parent; |
|
| 176 | + $i++; |
|
| 177 | + } else { |
|
| 178 | + $idb = null; |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + # spip_log("Pas vu $nom_champ"); |
|
| 183 | + // esperons qu'il y sera |
|
| 184 | + // ou qu'on a fourni une valeur par "defaut" plus pertinent |
|
| 185 | + return index_compose($conditionnel, $defaut); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | * @return string Code PHP complet de recherche d'un champ |
| 197 | 197 | */ |
| 198 | 198 | function index_compose($conditionnel, $defaut) { |
| 199 | - while ($c = array_pop($conditionnel)) { |
|
| 200 | - // si on passe defaut = '', ne pas générer d'erreur de compilation. |
|
| 201 | - $defaut = "($c:(" . ($defaut ?: "''") . '))'; |
|
| 202 | - } |
|
| 199 | + while ($c = array_pop($conditionnel)) { |
|
| 200 | + // si on passe defaut = '', ne pas générer d'erreur de compilation. |
|
| 201 | + $defaut = "($c:(" . ($defaut ?: "''") . '))'; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - return $defaut; |
|
| 204 | + return $defaut; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -237,77 +237,77 @@ discard block |
||
| 237 | 237 | **/ |
| 238 | 238 | function index_tables_en_pile($idb, $nom_champ, &$boucles, &$joker) { |
| 239 | 239 | |
| 240 | - $r = $boucles[$idb]->type_requete; |
|
| 241 | - // boucle recursive, c'est foutu... |
|
| 242 | - if ($r == TYPE_RECURSIF) { |
|
| 243 | - return []; |
|
| 244 | - } |
|
| 245 | - if (!$r) { |
|
| 246 | - $joker = false; // indiquer a l'appelant |
|
| 247 | - # continuer pour chercher l'erreur suivante |
|
| 248 | - return ["'#" . $r . ':' . $nom_champ . "'", '']; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - $desc = $boucles[$idb]->show; |
|
| 252 | - // le nom du champ est il une exception de la table ? un alias ? |
|
| 253 | - $excep = $GLOBALS['exceptions_des_tables'][$r] ?? ''; |
|
| 254 | - if ($excep) { |
|
| 255 | - $excep = $excep[$nom_champ] ?? ''; |
|
| 256 | - } |
|
| 257 | - if ($excep) { |
|
| 258 | - $joker = false; // indiquer a l'appelant |
|
| 259 | - return index_exception($boucles[$idb], $desc, $nom_champ, $excep); |
|
| 260 | - } // pas d'alias. Le champ existe t'il ? |
|
| 261 | - else { |
|
| 262 | - // le champ est réellement présent, on le prend. |
|
| 263 | - if (isset($desc['field'][$nom_champ])) { |
|
| 264 | - $t = $boucles[$idb]->id_table; |
|
| 265 | - $joker = false; // indiquer a l'appelant |
|
| 266 | - return ["$t.$nom_champ", $nom_champ]; |
|
| 267 | - } |
|
| 268 | - // Tous les champs sont-ils acceptés ? |
|
| 269 | - // Si oui, on retourne le champ, et on lève le flag joker |
|
| 270 | - // C'est le cas des itérateurs DATA qui acceptent tout |
|
| 271 | - // et testent la présence du champ à l'exécution et non à la compilation |
|
| 272 | - // car ils ne connaissent pas ici leurs contenus. |
|
| 273 | - elseif ( |
|
| 240 | + $r = $boucles[$idb]->type_requete; |
|
| 241 | + // boucle recursive, c'est foutu... |
|
| 242 | + if ($r == TYPE_RECURSIF) { |
|
| 243 | + return []; |
|
| 244 | + } |
|
| 245 | + if (!$r) { |
|
| 246 | + $joker = false; // indiquer a l'appelant |
|
| 247 | + # continuer pour chercher l'erreur suivante |
|
| 248 | + return ["'#" . $r . ':' . $nom_champ . "'", '']; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + $desc = $boucles[$idb]->show; |
|
| 252 | + // le nom du champ est il une exception de la table ? un alias ? |
|
| 253 | + $excep = $GLOBALS['exceptions_des_tables'][$r] ?? ''; |
|
| 254 | + if ($excep) { |
|
| 255 | + $excep = $excep[$nom_champ] ?? ''; |
|
| 256 | + } |
|
| 257 | + if ($excep) { |
|
| 258 | + $joker = false; // indiquer a l'appelant |
|
| 259 | + return index_exception($boucles[$idb], $desc, $nom_champ, $excep); |
|
| 260 | + } // pas d'alias. Le champ existe t'il ? |
|
| 261 | + else { |
|
| 262 | + // le champ est réellement présent, on le prend. |
|
| 263 | + if (isset($desc['field'][$nom_champ])) { |
|
| 264 | + $t = $boucles[$idb]->id_table; |
|
| 265 | + $joker = false; // indiquer a l'appelant |
|
| 266 | + return ["$t.$nom_champ", $nom_champ]; |
|
| 267 | + } |
|
| 268 | + // Tous les champs sont-ils acceptés ? |
|
| 269 | + // Si oui, on retourne le champ, et on lève le flag joker |
|
| 270 | + // C'est le cas des itérateurs DATA qui acceptent tout |
|
| 271 | + // et testent la présence du champ à l'exécution et non à la compilation |
|
| 272 | + // car ils ne connaissent pas ici leurs contenus. |
|
| 273 | + elseif ( |
|
| 274 | 274 | /*$joker AND */ |
| 275 | - isset($desc['field']['*']) |
|
| 276 | - ) { |
|
| 277 | - $joker = true; // indiquer a l'appelant |
|
| 278 | - return [$nom_champ, $nom_champ]; |
|
| 279 | - } |
|
| 280 | - // pas d'alias, pas de champ, pas de joker... |
|
| 281 | - // tenter via une jointure... |
|
| 282 | - else { |
|
| 283 | - $joker = false; // indiquer a l'appelant |
|
| 284 | - // regarder si le champ est deja dans une jointure existante |
|
| 285 | - // sinon, si il y a des joitures explicites, la construire |
|
| 286 | - if (!$t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->from, $boucles[$idb])) { |
|
| 287 | - if ($boucles[$idb]->jointures_explicites) { |
|
| 288 | - // [todo] Ne pas lancer que lorsque il y a des jointures explicites !!!! |
|
| 289 | - // fonctionnel, il suffit d'utiliser $boucles[$idb]->jointures au lieu de jointures_explicites |
|
| 290 | - // mais est-ce ce qu'on veut ? |
|
| 291 | - $jointures = preg_split('/\s+/', $boucles[$idb]->jointures_explicites); |
|
| 292 | - if ($cle = trouver_jointure_champ($nom_champ, $boucles[$idb], $jointures)) { |
|
| 293 | - $t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->from, $boucles[$idb]); |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - if ($t) { |
|
| 298 | - // si on a trouvé une jointure possible, on fait comme |
|
| 299 | - // si c'était une exception pour le champ demandé |
|
| 300 | - return index_exception( |
|
| 301 | - $boucles[$idb], |
|
| 302 | - $desc, |
|
| 303 | - $nom_champ, |
|
| 304 | - [$t[1]['id_table'], reset($t[2])] |
|
| 305 | - ); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - return ['', '']; |
|
| 309 | - } |
|
| 310 | - } |
|
| 275 | + isset($desc['field']['*']) |
|
| 276 | + ) { |
|
| 277 | + $joker = true; // indiquer a l'appelant |
|
| 278 | + return [$nom_champ, $nom_champ]; |
|
| 279 | + } |
|
| 280 | + // pas d'alias, pas de champ, pas de joker... |
|
| 281 | + // tenter via une jointure... |
|
| 282 | + else { |
|
| 283 | + $joker = false; // indiquer a l'appelant |
|
| 284 | + // regarder si le champ est deja dans une jointure existante |
|
| 285 | + // sinon, si il y a des joitures explicites, la construire |
|
| 286 | + if (!$t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->from, $boucles[$idb])) { |
|
| 287 | + if ($boucles[$idb]->jointures_explicites) { |
|
| 288 | + // [todo] Ne pas lancer que lorsque il y a des jointures explicites !!!! |
|
| 289 | + // fonctionnel, il suffit d'utiliser $boucles[$idb]->jointures au lieu de jointures_explicites |
|
| 290 | + // mais est-ce ce qu'on veut ? |
|
| 291 | + $jointures = preg_split('/\s+/', $boucles[$idb]->jointures_explicites); |
|
| 292 | + if ($cle = trouver_jointure_champ($nom_champ, $boucles[$idb], $jointures)) { |
|
| 293 | + $t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->from, $boucles[$idb]); |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + if ($t) { |
|
| 298 | + // si on a trouvé une jointure possible, on fait comme |
|
| 299 | + // si c'était une exception pour le champ demandé |
|
| 300 | + return index_exception( |
|
| 301 | + $boucles[$idb], |
|
| 302 | + $desc, |
|
| 303 | + $nom_champ, |
|
| 304 | + [$t[1]['id_table'], reset($t[2])] |
|
| 305 | + ); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + return ['', '']; |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | |
@@ -335,52 +335,52 @@ discard block |
||
| 335 | 335 | * est une expression pour le SELECT de la boucle du style "mots.titre AS titre_mot" |
| 336 | 336 | **/ |
| 337 | 337 | function index_exception(&$boucle, $desc, $nom_champ, $excep) { |
| 338 | - static $trouver_table; |
|
| 339 | - if (!$trouver_table) { |
|
| 340 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - if (is_array($excep)) { |
|
| 344 | - // permettre aux plugins de gerer eux meme des jointures derogatoire ingerables |
|
| 345 | - $t = null; |
|
| 346 | - if (count($excep) == 3) { |
|
| 347 | - $index_exception_derogatoire = array_pop($excep); |
|
| 348 | - $t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep); |
|
| 349 | - } |
|
| 350 | - if ($t == null) { |
|
| 351 | - [$e, $x] = $excep; #PHP4 affecte de gauche a droite |
|
| 352 | - $excep = $x; #PHP5 de droite a gauche ! |
|
| 353 | - $j = $trouver_table($e, $boucle->sql_serveur); |
|
| 354 | - if (!$j) { |
|
| 355 | - return ['', '']; |
|
| 356 | - } |
|
| 357 | - $e = $j['table']; |
|
| 358 | - if (!$t = array_search($e, $boucle->from)) { |
|
| 359 | - $k = $j['key']['PRIMARY KEY']; |
|
| 360 | - if (strpos($k, ',')) { |
|
| 361 | - $l = (preg_split('/\s*,\s*/', $k)); |
|
| 362 | - $k = $desc['key']['PRIMARY KEY']; |
|
| 363 | - if (!in_array($k, $l)) { |
|
| 364 | - spip_log("jointure impossible $e " . join(',', $l)); |
|
| 365 | - |
|
| 366 | - return ['', '']; |
|
| 367 | - } |
|
| 368 | - } |
|
| 369 | - $k = [$boucle->id_table, [$e], $k]; |
|
| 370 | - fabrique_jointures($boucle, [$k]); |
|
| 371 | - $t = array_search($e, $boucle->from); |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - } else { |
|
| 375 | - $t = $boucle->id_table; |
|
| 376 | - } |
|
| 377 | - // demander a SQL de gerer le synonyme |
|
| 378 | - // ca permet que excep soit dynamique (Cedric, 2/3/06) |
|
| 379 | - if ($excep != $nom_champ) { |
|
| 380 | - $excep .= ' AS ' . $nom_champ; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - return ["$t.$excep", $nom_champ]; |
|
| 338 | + static $trouver_table; |
|
| 339 | + if (!$trouver_table) { |
|
| 340 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + if (is_array($excep)) { |
|
| 344 | + // permettre aux plugins de gerer eux meme des jointures derogatoire ingerables |
|
| 345 | + $t = null; |
|
| 346 | + if (count($excep) == 3) { |
|
| 347 | + $index_exception_derogatoire = array_pop($excep); |
|
| 348 | + $t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep); |
|
| 349 | + } |
|
| 350 | + if ($t == null) { |
|
| 351 | + [$e, $x] = $excep; #PHP4 affecte de gauche a droite |
|
| 352 | + $excep = $x; #PHP5 de droite a gauche ! |
|
| 353 | + $j = $trouver_table($e, $boucle->sql_serveur); |
|
| 354 | + if (!$j) { |
|
| 355 | + return ['', '']; |
|
| 356 | + } |
|
| 357 | + $e = $j['table']; |
|
| 358 | + if (!$t = array_search($e, $boucle->from)) { |
|
| 359 | + $k = $j['key']['PRIMARY KEY']; |
|
| 360 | + if (strpos($k, ',')) { |
|
| 361 | + $l = (preg_split('/\s*,\s*/', $k)); |
|
| 362 | + $k = $desc['key']['PRIMARY KEY']; |
|
| 363 | + if (!in_array($k, $l)) { |
|
| 364 | + spip_log("jointure impossible $e " . join(',', $l)); |
|
| 365 | + |
|
| 366 | + return ['', '']; |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + $k = [$boucle->id_table, [$e], $k]; |
|
| 370 | + fabrique_jointures($boucle, [$k]); |
|
| 371 | + $t = array_search($e, $boucle->from); |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + } else { |
|
| 375 | + $t = $boucle->id_table; |
|
| 376 | + } |
|
| 377 | + // demander a SQL de gerer le synonyme |
|
| 378 | + // ca permet que excep soit dynamique (Cedric, 2/3/06) |
|
| 379 | + if ($excep != $nom_champ) { |
|
| 380 | + $excep .= ' AS ' . $nom_champ; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + return ["$t.$excep", $nom_champ]; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | * Code PHP pour retrouver le champ |
| 406 | 406 | */ |
| 407 | 407 | function champ_sql($champ, $p, $defaut = null, $remonte_pile = true) { |
| 408 | - return index_pile($p->id_boucle, $champ, $p->boucles, $p->nom_boucle, $defaut, $remonte_pile); |
|
| 408 | + return index_pile($p->id_boucle, $champ, $p->boucles, $p->nom_boucle, $defaut, $remonte_pile); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -425,9 +425,9 @@ discard block |
||
| 425 | 425 | * Code PHP pour d'exécution de la balise et de ses filtres |
| 426 | 426 | **/ |
| 427 | 427 | function calculer_champ($p) { |
| 428 | - $p = calculer_balise($p->nom_champ, $p); |
|
| 428 | + $p = calculer_balise($p->nom_champ, $p); |
|
| 429 | 429 | |
| 430 | - return applique_filtres($p); |
|
| 430 | + return applique_filtres($p); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | |
@@ -464,26 +464,26 @@ discard block |
||
| 464 | 464 | **/ |
| 465 | 465 | function calculer_balise(string $nom, \Champ $p): \Champ { |
| 466 | 466 | |
| 467 | - // S'agit-t-il d'une balise_XXXX[_dist]() ? |
|
| 468 | - if ($f = charger_fonction($nom, 'balise', true)) { |
|
| 469 | - $p->balise_calculee = true; |
|
| 470 | - $res = $f($p); |
|
| 471 | - if ($res !== null and is_object($res)) { |
|
| 472 | - return $res; |
|
| 473 | - } |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - // Certaines des balises comportant un _ sont generiques |
|
| 477 | - if ($balise_generique = chercher_balise_generique($nom)) { |
|
| 478 | - $res = $balise_generique['fonction_generique']($p); |
|
| 479 | - if ($res !== null and is_object($res)) { |
|
| 480 | - return $res; |
|
| 481 | - } |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - $f = charger_fonction('DEFAUT', 'calculer_balise'); |
|
| 485 | - |
|
| 486 | - return $f($nom, $p); |
|
| 467 | + // S'agit-t-il d'une balise_XXXX[_dist]() ? |
|
| 468 | + if ($f = charger_fonction($nom, 'balise', true)) { |
|
| 469 | + $p->balise_calculee = true; |
|
| 470 | + $res = $f($p); |
|
| 471 | + if ($res !== null and is_object($res)) { |
|
| 472 | + return $res; |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + // Certaines des balises comportant un _ sont generiques |
|
| 477 | + if ($balise_generique = chercher_balise_generique($nom)) { |
|
| 478 | + $res = $balise_generique['fonction_generique']($p); |
|
| 479 | + if ($res !== null and is_object($res)) { |
|
| 480 | + return $res; |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + $f = charger_fonction('DEFAUT', 'calculer_balise'); |
|
| 485 | + |
|
| 486 | + return $f($nom, $p); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | |
@@ -511,37 +511,37 @@ discard block |
||
| 511 | 511 | **/ |
| 512 | 512 | function calculer_balise_DEFAUT_dist($nom, $p) { |
| 513 | 513 | |
| 514 | - // ca pourrait etre un champ SQL homonyme, |
|
| 515 | - $p->code = index_pile($p->id_boucle, $nom, $p->boucles, $p->nom_boucle); |
|
| 516 | - |
|
| 517 | - // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour |
|
| 518 | - // il faut recracher {...} quand ce n'est finalement pas des args |
|
| 519 | - if ($p->fonctions and (!$p->fonctions[0][0]) and $p->fonctions[0][1]) { |
|
| 520 | - $code = addslashes($p->fonctions[0][1]); |
|
| 521 | - $p->code .= " . '$code'"; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - // ne pas passer le filtre securite sur les id_xxx |
|
| 525 | - if (strpos($nom, 'ID_') === 0) { |
|
| 526 | - $p->interdire_scripts = false; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - // Compatibilite ascendante avec les couleurs html (#FEFEFE) : |
|
| 530 | - // SI le champ SQL n'est pas trouve |
|
| 531 | - // ET si la balise a une forme de couleur |
|
| 532 | - // ET s'il n'y a ni filtre ni etoile |
|
| 533 | - // ALORS retourner la couleur. |
|
| 534 | - // Ca permet si l'on veut vraiment de recuperer [(#ACCEDE*)] |
|
| 535 | - if ( |
|
| 536 | - preg_match('/^[A-F]{1,6}$/i', $nom) |
|
| 537 | - and !$p->etoile |
|
| 538 | - and !$p->fonctions |
|
| 539 | - ) { |
|
| 540 | - $p->code = "'#$nom'"; |
|
| 541 | - $p->interdire_scripts = false; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - return $p; |
|
| 514 | + // ca pourrait etre un champ SQL homonyme, |
|
| 515 | + $p->code = index_pile($p->id_boucle, $nom, $p->boucles, $p->nom_boucle); |
|
| 516 | + |
|
| 517 | + // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour |
|
| 518 | + // il faut recracher {...} quand ce n'est finalement pas des args |
|
| 519 | + if ($p->fonctions and (!$p->fonctions[0][0]) and $p->fonctions[0][1]) { |
|
| 520 | + $code = addslashes($p->fonctions[0][1]); |
|
| 521 | + $p->code .= " . '$code'"; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + // ne pas passer le filtre securite sur les id_xxx |
|
| 525 | + if (strpos($nom, 'ID_') === 0) { |
|
| 526 | + $p->interdire_scripts = false; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + // Compatibilite ascendante avec les couleurs html (#FEFEFE) : |
|
| 530 | + // SI le champ SQL n'est pas trouve |
|
| 531 | + // ET si la balise a une forme de couleur |
|
| 532 | + // ET s'il n'y a ni filtre ni etoile |
|
| 533 | + // ALORS retourner la couleur. |
|
| 534 | + // Ca permet si l'on veut vraiment de recuperer [(#ACCEDE*)] |
|
| 535 | + if ( |
|
| 536 | + preg_match('/^[A-F]{1,6}$/i', $nom) |
|
| 537 | + and !$p->etoile |
|
| 538 | + and !$p->fonctions |
|
| 539 | + ) { |
|
| 540 | + $p->code = "'#$nom'"; |
|
| 541 | + $p->interdire_scripts = false; |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + return $p; |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | |
@@ -584,39 +584,39 @@ discard block |
||
| 584 | 584 | **/ |
| 585 | 585 | function calculer_balise_dynamique($p, $nom, $l, $supp = []) { |
| 586 | 586 | |
| 587 | - if (!balise_distante_interdite($p)) { |
|
| 588 | - $p->code = "''"; |
|
| 589 | - |
|
| 590 | - return $p; |
|
| 591 | - } |
|
| 592 | - // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour |
|
| 593 | - // il faut recracher {...} quand ce n'est finalement pas des args |
|
| 594 | - if ($p->fonctions and (!$p->fonctions[0][0]) and $p->fonctions[0][1]) { |
|
| 595 | - $p->fonctions = null; |
|
| 596 | - } |
|
| 597 | - |
|
| 598 | - if ($p->param and ($c = $p->param[0])) { |
|
| 599 | - // liste d'arguments commence toujours par la chaine vide |
|
| 600 | - array_shift($c); |
|
| 601 | - // construire la liste d'arguments comme pour un filtre |
|
| 602 | - $param = compose_filtres_args($p, $c, ','); |
|
| 603 | - } else { |
|
| 604 | - $param = ''; |
|
| 605 | - } |
|
| 606 | - $collecte = collecter_balise_dynamique($l, $p, $nom); |
|
| 607 | - |
|
| 608 | - $p->code = sprintf( |
|
| 609 | - CODE_EXECUTER_BALISE, |
|
| 610 | - $nom, |
|
| 611 | - join(',', $collecte), |
|
| 612 | - ($collecte ? $param : substr($param, 1)), # virer la virgule |
|
| 613 | - memoriser_contexte_compil($p), |
|
| 614 | - (!$supp ? '' : (', ' . join(',', $supp))) |
|
| 615 | - ); |
|
| 616 | - |
|
| 617 | - $p->interdire_scripts = false; |
|
| 618 | - |
|
| 619 | - return $p; |
|
| 587 | + if (!balise_distante_interdite($p)) { |
|
| 588 | + $p->code = "''"; |
|
| 589 | + |
|
| 590 | + return $p; |
|
| 591 | + } |
|
| 592 | + // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour |
|
| 593 | + // il faut recracher {...} quand ce n'est finalement pas des args |
|
| 594 | + if ($p->fonctions and (!$p->fonctions[0][0]) and $p->fonctions[0][1]) { |
|
| 595 | + $p->fonctions = null; |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + if ($p->param and ($c = $p->param[0])) { |
|
| 599 | + // liste d'arguments commence toujours par la chaine vide |
|
| 600 | + array_shift($c); |
|
| 601 | + // construire la liste d'arguments comme pour un filtre |
|
| 602 | + $param = compose_filtres_args($p, $c, ','); |
|
| 603 | + } else { |
|
| 604 | + $param = ''; |
|
| 605 | + } |
|
| 606 | + $collecte = collecter_balise_dynamique($l, $p, $nom); |
|
| 607 | + |
|
| 608 | + $p->code = sprintf( |
|
| 609 | + CODE_EXECUTER_BALISE, |
|
| 610 | + $nom, |
|
| 611 | + join(',', $collecte), |
|
| 612 | + ($collecte ? $param : substr($param, 1)), # virer la virgule |
|
| 613 | + memoriser_contexte_compil($p), |
|
| 614 | + (!$supp ? '' : (', ' . join(',', $supp))) |
|
| 615 | + ); |
|
| 616 | + |
|
| 617 | + $p->interdire_scripts = false; |
|
| 618 | + |
|
| 619 | + return $p; |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | |
@@ -646,17 +646,17 @@ discard block |
||
| 646 | 646 | * Liste des codes PHP d'éxecution des balises collectées |
| 647 | 647 | **/ |
| 648 | 648 | function collecter_balise_dynamique(array $l, \Champ &$p, string $nom): array { |
| 649 | - $args = []; |
|
| 650 | - foreach ($l as $c) { |
|
| 651 | - if ($c === null) { |
|
| 652 | - $args[] = 'null'; |
|
| 653 | - } else { |
|
| 654 | - $x = calculer_balise($c, $p); |
|
| 655 | - $args[] = $x->code; |
|
| 656 | - } |
|
| 657 | - } |
|
| 658 | - |
|
| 659 | - return $args; |
|
| 649 | + $args = []; |
|
| 650 | + foreach ($l as $c) { |
|
| 651 | + if ($c === null) { |
|
| 652 | + $args[] = 'null'; |
|
| 653 | + } else { |
|
| 654 | + $x = calculer_balise($c, $p); |
|
| 655 | + $args[] = $x->code; |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + return $args; |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | |
@@ -671,22 +671,22 @@ discard block |
||
| 671 | 671 | * Nom de la connexion |
| 672 | 672 | **/ |
| 673 | 673 | function trouver_nom_serveur_distant($p) { |
| 674 | - $nom = $p->id_boucle; |
|
| 675 | - if ( |
|
| 676 | - $nom |
|
| 677 | - and isset($p->boucles[$nom]) |
|
| 678 | - ) { |
|
| 679 | - $s = $p->boucles[$nom]->sql_serveur; |
|
| 680 | - if ( |
|
| 681 | - strlen($s) |
|
| 682 | - and strlen($serveur = strtolower($s)) |
|
| 683 | - and !in_array($serveur, $GLOBALS['exception_des_connect']) |
|
| 684 | - ) { |
|
| 685 | - return $serveur; |
|
| 686 | - } |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - return ''; |
|
| 674 | + $nom = $p->id_boucle; |
|
| 675 | + if ( |
|
| 676 | + $nom |
|
| 677 | + and isset($p->boucles[$nom]) |
|
| 678 | + ) { |
|
| 679 | + $s = $p->boucles[$nom]->sql_serveur; |
|
| 680 | + if ( |
|
| 681 | + strlen($s) |
|
| 682 | + and strlen($serveur = strtolower($s)) |
|
| 683 | + and !in_array($serveur, $GLOBALS['exception_des_connect']) |
|
| 684 | + ) { |
|
| 685 | + return $serveur; |
|
| 686 | + } |
|
| 687 | + } |
|
| 688 | + |
|
| 689 | + return ''; |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | |
@@ -710,15 +710,15 @@ discard block |
||
| 710 | 710 | * - false : La balise est interdite car le serveur est distant |
| 711 | 711 | **/ |
| 712 | 712 | function balise_distante_interdite($p) { |
| 713 | - $nom = $p->id_boucle; |
|
| 713 | + $nom = $p->id_boucle; |
|
| 714 | 714 | |
| 715 | - if ($nom and trouver_nom_serveur_distant($p)) { |
|
| 716 | - spip_log($nom . ':' . $p->nom_champ . ' ' . _T('zbug_distant_interdit')); |
|
| 715 | + if ($nom and trouver_nom_serveur_distant($p)) { |
|
| 716 | + spip_log($nom . ':' . $p->nom_champ . ' ' . _T('zbug_distant_interdit')); |
|
| 717 | 717 | |
| 718 | - return false; |
|
| 719 | - } |
|
| 718 | + return false; |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | - return true; |
|
| 721 | + return true; |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | |
@@ -728,84 +728,84 @@ discard block |
||
| 728 | 728 | // |
| 729 | 729 | function champs_traitements($p) { |
| 730 | 730 | |
| 731 | - if (isset($GLOBALS['table_des_traitements'][$p->nom_champ])) { |
|
| 732 | - $ps = $GLOBALS['table_des_traitements'][$p->nom_champ]; |
|
| 733 | - } else { |
|
| 734 | - // quand on utilise un traitement catch-all * |
|
| 735 | - // celui-ci ne s'applique pas sur les balises calculees qui peuvent gerer |
|
| 736 | - // leur propre securite |
|
| 737 | - if (!$p->balise_calculee) { |
|
| 738 | - $ps = $GLOBALS['table_des_traitements']['*']; |
|
| 739 | - } else { |
|
| 740 | - $ps = false; |
|
| 741 | - } |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - if (is_array($ps)) { |
|
| 745 | - // Recuperer le type de boucle (articles, DATA) et la table SQL sur laquelle elle porte |
|
| 746 | - $idb = index_boucle($p); |
|
| 747 | - // si le champ a ete trouve dans une boucle parente sa source est renseignee ici |
|
| 748 | - if (!empty($p->boucles[$idb]->index_champ[$p->nom_champ])) { |
|
| 749 | - $idb = $p->boucles[$idb]->index_champ[$p->nom_champ]; |
|
| 750 | - } |
|
| 751 | - |
|
| 752 | - // mais on peut aussi etre hors boucle. Se mefier. |
|
| 753 | - $type_requete = $p->boucles[$idb]->type_requete ?? false; |
|
| 754 | - $table_sql = $p->boucles[$idb]->show['table_sql'] ?? false; |
|
| 755 | - |
|
| 756 | - // bien prendre en compte les alias de boucles (hierarchie => rubrique, syndication => syncdic, etc.) |
|
| 757 | - if ($type_requete and isset($GLOBALS['table_des_tables'][$type_requete])) { |
|
| 758 | - $type_alias = $type_requete; |
|
| 759 | - $type_requete = $GLOBALS['table_des_tables'][$type_requete]; |
|
| 760 | - } else { |
|
| 761 | - $type_alias = false; |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - // le traitement peut n'etre defini que pour une table en particulier "spip_articles" |
|
| 765 | - if ($table_sql and isset($ps[$table_sql])) { |
|
| 766 | - $ps = $ps[$table_sql]; |
|
| 767 | - } // ou pour une boucle en particulier "DATA","articles" |
|
| 768 | - elseif ($type_requete and isset($ps[$type_requete])) { |
|
| 769 | - $ps = $ps[$type_requete]; |
|
| 770 | - } // ou pour une boucle utilisant un alias ("hierarchie") |
|
| 771 | - elseif ($type_alias and isset($ps[$type_alias])) { |
|
| 772 | - $ps = $ps[$type_alias]; |
|
| 773 | - } // ou pour indifféremment quelle que soit la boucle |
|
| 774 | - elseif (isset($ps[0])) { |
|
| 775 | - $ps = $ps[0]; |
|
| 776 | - } else { |
|
| 777 | - $ps = false; |
|
| 778 | - } |
|
| 779 | - } |
|
| 780 | - |
|
| 781 | - if (!$ps) { |
|
| 782 | - return $p->code; |
|
| 783 | - } |
|
| 784 | - |
|
| 785 | - // Si une boucle DOCUMENTS{doublons} est presente dans le squelette, |
|
| 786 | - // ou si in INCLURE contient {doublons} |
|
| 787 | - // on insere une fonction de remplissage du tableau des doublons |
|
| 788 | - // dans les filtres propre() ou typo() |
|
| 789 | - // (qui traitent les raccourcis <docXX> referencant les docs) |
|
| 790 | - |
|
| 791 | - if ( |
|
| 792 | - isset($p->descr['documents']) |
|
| 793 | - and |
|
| 794 | - $p->descr['documents'] |
|
| 795 | - and ( |
|
| 796 | - (strpos($ps, 'propre') !== false) |
|
| 797 | - or |
|
| 798 | - (strpos($ps, 'typo') !== false) |
|
| 799 | - ) |
|
| 800 | - ) { |
|
| 801 | - $ps = 'traiter_doublons_documents($doublons, ' . $ps . ')'; |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - // La protection des champs par |safehtml est assuree par les extensions |
|
| 805 | - // dans la declaration des traitements des champs sensibles |
|
| 806 | - |
|
| 807 | - // Remplacer enfin le placeholder %s par le vrai code de la balise |
|
| 808 | - return str_replace('%s', $p->code, $ps); |
|
| 731 | + if (isset($GLOBALS['table_des_traitements'][$p->nom_champ])) { |
|
| 732 | + $ps = $GLOBALS['table_des_traitements'][$p->nom_champ]; |
|
| 733 | + } else { |
|
| 734 | + // quand on utilise un traitement catch-all * |
|
| 735 | + // celui-ci ne s'applique pas sur les balises calculees qui peuvent gerer |
|
| 736 | + // leur propre securite |
|
| 737 | + if (!$p->balise_calculee) { |
|
| 738 | + $ps = $GLOBALS['table_des_traitements']['*']; |
|
| 739 | + } else { |
|
| 740 | + $ps = false; |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + if (is_array($ps)) { |
|
| 745 | + // Recuperer le type de boucle (articles, DATA) et la table SQL sur laquelle elle porte |
|
| 746 | + $idb = index_boucle($p); |
|
| 747 | + // si le champ a ete trouve dans une boucle parente sa source est renseignee ici |
|
| 748 | + if (!empty($p->boucles[$idb]->index_champ[$p->nom_champ])) { |
|
| 749 | + $idb = $p->boucles[$idb]->index_champ[$p->nom_champ]; |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + // mais on peut aussi etre hors boucle. Se mefier. |
|
| 753 | + $type_requete = $p->boucles[$idb]->type_requete ?? false; |
|
| 754 | + $table_sql = $p->boucles[$idb]->show['table_sql'] ?? false; |
|
| 755 | + |
|
| 756 | + // bien prendre en compte les alias de boucles (hierarchie => rubrique, syndication => syncdic, etc.) |
|
| 757 | + if ($type_requete and isset($GLOBALS['table_des_tables'][$type_requete])) { |
|
| 758 | + $type_alias = $type_requete; |
|
| 759 | + $type_requete = $GLOBALS['table_des_tables'][$type_requete]; |
|
| 760 | + } else { |
|
| 761 | + $type_alias = false; |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + // le traitement peut n'etre defini que pour une table en particulier "spip_articles" |
|
| 765 | + if ($table_sql and isset($ps[$table_sql])) { |
|
| 766 | + $ps = $ps[$table_sql]; |
|
| 767 | + } // ou pour une boucle en particulier "DATA","articles" |
|
| 768 | + elseif ($type_requete and isset($ps[$type_requete])) { |
|
| 769 | + $ps = $ps[$type_requete]; |
|
| 770 | + } // ou pour une boucle utilisant un alias ("hierarchie") |
|
| 771 | + elseif ($type_alias and isset($ps[$type_alias])) { |
|
| 772 | + $ps = $ps[$type_alias]; |
|
| 773 | + } // ou pour indifféremment quelle que soit la boucle |
|
| 774 | + elseif (isset($ps[0])) { |
|
| 775 | + $ps = $ps[0]; |
|
| 776 | + } else { |
|
| 777 | + $ps = false; |
|
| 778 | + } |
|
| 779 | + } |
|
| 780 | + |
|
| 781 | + if (!$ps) { |
|
| 782 | + return $p->code; |
|
| 783 | + } |
|
| 784 | + |
|
| 785 | + // Si une boucle DOCUMENTS{doublons} est presente dans le squelette, |
|
| 786 | + // ou si in INCLURE contient {doublons} |
|
| 787 | + // on insere une fonction de remplissage du tableau des doublons |
|
| 788 | + // dans les filtres propre() ou typo() |
|
| 789 | + // (qui traitent les raccourcis <docXX> referencant les docs) |
|
| 790 | + |
|
| 791 | + if ( |
|
| 792 | + isset($p->descr['documents']) |
|
| 793 | + and |
|
| 794 | + $p->descr['documents'] |
|
| 795 | + and ( |
|
| 796 | + (strpos($ps, 'propre') !== false) |
|
| 797 | + or |
|
| 798 | + (strpos($ps, 'typo') !== false) |
|
| 799 | + ) |
|
| 800 | + ) { |
|
| 801 | + $ps = 'traiter_doublons_documents($doublons, ' . $ps . ')'; |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + // La protection des champs par |safehtml est assuree par les extensions |
|
| 805 | + // dans la declaration des traitements des champs sensibles |
|
| 806 | + |
|
| 807 | + // Remplacer enfin le placeholder %s par le vrai code de la balise |
|
| 808 | + return str_replace('%s', $p->code, $ps); |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | |
@@ -817,110 +817,110 @@ discard block |
||
| 817 | 817 | // |
| 818 | 818 | function applique_filtres($p) { |
| 819 | 819 | |
| 820 | - // Traitements standards (cf. supra) |
|
| 821 | - if ($p->etoile == '') { |
|
| 822 | - $code = champs_traitements($p); |
|
| 823 | - } else { |
|
| 824 | - $code = $p->code; |
|
| 825 | - } |
|
| 820 | + // Traitements standards (cf. supra) |
|
| 821 | + if ($p->etoile == '') { |
|
| 822 | + $code = champs_traitements($p); |
|
| 823 | + } else { |
|
| 824 | + $code = $p->code; |
|
| 825 | + } |
|
| 826 | 826 | |
| 827 | - // Appliquer les filtres perso |
|
| 828 | - if ($p->param) { |
|
| 829 | - $code = compose_filtres($p, $code); |
|
| 830 | - } |
|
| 827 | + // Appliquer les filtres perso |
|
| 828 | + if ($p->param) { |
|
| 829 | + $code = compose_filtres($p, $code); |
|
| 830 | + } |
|
| 831 | 831 | |
| 832 | - // S'il y a un lien avec la session, ajouter un code qui levera |
|
| 833 | - // un drapeau dans la structure d'invalidation $Cache |
|
| 834 | - if (isset($p->descr['session'])) { |
|
| 835 | - $code = "invalideur_session(\$Cache, $code)"; |
|
| 836 | - } |
|
| 832 | + // S'il y a un lien avec la session, ajouter un code qui levera |
|
| 833 | + // un drapeau dans la structure d'invalidation $Cache |
|
| 834 | + if (isset($p->descr['session'])) { |
|
| 835 | + $code = "invalideur_session(\$Cache, $code)"; |
|
| 836 | + } |
|
| 837 | 837 | |
| 838 | - $code = sandbox_composer_interdire_scripts($code, $p); |
|
| 838 | + $code = sandbox_composer_interdire_scripts($code, $p); |
|
| 839 | 839 | |
| 840 | - return $code; |
|
| 840 | + return $code; |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | // Cf. function pipeline dans ecrire/inc_utils.php |
| 844 | 844 | function compose_filtres(&$p, $code) { |
| 845 | 845 | |
| 846 | - $image_miette = false; |
|
| 847 | - foreach ($p->param as $filtre) { |
|
| 848 | - $fonc = array_shift($filtre); |
|
| 849 | - if (!$fonc) { |
|
| 850 | - continue; |
|
| 851 | - } // normalement qu'au premier tour. |
|
| 852 | - $is_filtre_image = ((substr($fonc, 0, 6) == 'image_') and $fonc != 'image_graver'); |
|
| 853 | - if ($image_miette and !$is_filtre_image) { |
|
| 854 | - // il faut graver maintenant car apres le filtre en cours |
|
| 855 | - // on est pas sur d'avoir encore le nom du fichier dans le pipe |
|
| 856 | - $code = "filtrer('image_graver', $code)"; |
|
| 857 | - $image_miette = false; |
|
| 858 | - } |
|
| 859 | - |
|
| 860 | - // recuperer les arguments du filtre, |
|
| 861 | - // a separer par "," ou ":" dans le cas du filtre "?{a,b}" |
|
| 862 | - $countfiltre = is_countable($filtre) ? count($filtre) : 0; |
|
| 863 | - if ($fonc !== '?') { |
|
| 864 | - $sep = ','; |
|
| 865 | - } else { |
|
| 866 | - $sep = ':'; |
|
| 867 | - // |?{a,b} *doit* avoir exactement 2 arguments ; on les force |
|
| 868 | - if ($countfiltre != 2) { |
|
| 869 | - $filtre = [$filtre[0] ?? '', $filtre[1] ?? '']; |
|
| 870 | - $countfiltre = 2; |
|
| 871 | - } |
|
| 872 | - } |
|
| 873 | - $arglist = compose_filtres_args($p, $filtre, $sep); |
|
| 874 | - $logique = filtre_logique($fonc, $code, substr($arglist, 1)); |
|
| 875 | - if ($logique) { |
|
| 876 | - $code = $logique; |
|
| 877 | - } else { |
|
| 878 | - $code = sandbox_composer_filtre($fonc, $code, $arglist, $p, $countfiltre); |
|
| 879 | - if ($is_filtre_image) { |
|
| 880 | - $image_miette = true; |
|
| 881 | - } |
|
| 882 | - } |
|
| 883 | - } |
|
| 884 | - // ramasser les images intermediaires inutiles et graver l'image finale |
|
| 885 | - if ($image_miette) { |
|
| 886 | - $code = "filtrer('image_graver',$code)"; |
|
| 887 | - } |
|
| 888 | - |
|
| 889 | - return $code; |
|
| 846 | + $image_miette = false; |
|
| 847 | + foreach ($p->param as $filtre) { |
|
| 848 | + $fonc = array_shift($filtre); |
|
| 849 | + if (!$fonc) { |
|
| 850 | + continue; |
|
| 851 | + } // normalement qu'au premier tour. |
|
| 852 | + $is_filtre_image = ((substr($fonc, 0, 6) == 'image_') and $fonc != 'image_graver'); |
|
| 853 | + if ($image_miette and !$is_filtre_image) { |
|
| 854 | + // il faut graver maintenant car apres le filtre en cours |
|
| 855 | + // on est pas sur d'avoir encore le nom du fichier dans le pipe |
|
| 856 | + $code = "filtrer('image_graver', $code)"; |
|
| 857 | + $image_miette = false; |
|
| 858 | + } |
|
| 859 | + |
|
| 860 | + // recuperer les arguments du filtre, |
|
| 861 | + // a separer par "," ou ":" dans le cas du filtre "?{a,b}" |
|
| 862 | + $countfiltre = is_countable($filtre) ? count($filtre) : 0; |
|
| 863 | + if ($fonc !== '?') { |
|
| 864 | + $sep = ','; |
|
| 865 | + } else { |
|
| 866 | + $sep = ':'; |
|
| 867 | + // |?{a,b} *doit* avoir exactement 2 arguments ; on les force |
|
| 868 | + if ($countfiltre != 2) { |
|
| 869 | + $filtre = [$filtre[0] ?? '', $filtre[1] ?? '']; |
|
| 870 | + $countfiltre = 2; |
|
| 871 | + } |
|
| 872 | + } |
|
| 873 | + $arglist = compose_filtres_args($p, $filtre, $sep); |
|
| 874 | + $logique = filtre_logique($fonc, $code, substr($arglist, 1)); |
|
| 875 | + if ($logique) { |
|
| 876 | + $code = $logique; |
|
| 877 | + } else { |
|
| 878 | + $code = sandbox_composer_filtre($fonc, $code, $arglist, $p, $countfiltre); |
|
| 879 | + if ($is_filtre_image) { |
|
| 880 | + $image_miette = true; |
|
| 881 | + } |
|
| 882 | + } |
|
| 883 | + } |
|
| 884 | + // ramasser les images intermediaires inutiles et graver l'image finale |
|
| 885 | + if ($image_miette) { |
|
| 886 | + $code = "filtrer('image_graver',$code)"; |
|
| 887 | + } |
|
| 888 | + |
|
| 889 | + return $code; |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | // Filtres et,ou,oui,non,sinon,xou,xor,and,or,not,yes |
| 893 | 893 | // et comparateurs |
| 894 | 894 | function filtre_logique($fonc, $code, $arg) { |
| 895 | 895 | |
| 896 | - switch (true) { |
|
| 897 | - case in_array($fonc, $GLOBALS['table_criteres_infixes']): |
|
| 898 | - return "($code $fonc $arg)"; |
|
| 899 | - case ($fonc == 'and') or ($fonc == 'et'): |
|
| 900 | - return "((($code) AND ($arg)) ?' ' :'')"; |
|
| 901 | - case ($fonc == 'or') or ($fonc == 'ou'): |
|
| 902 | - return "((($code) OR ($arg)) ?' ' :'')"; |
|
| 903 | - case ($fonc == 'xor') or ($fonc == 'xou'): |
|
| 904 | - return "((($code) XOR ($arg)) ?' ' :'')"; |
|
| 905 | - case ($fonc == 'sinon'): |
|
| 906 | - return "(((\$a = $code) OR (is_string(\$a) AND strlen(\$a))) ? \$a : $arg)"; |
|
| 907 | - case ($fonc == 'not') or ($fonc == 'non'): |
|
| 908 | - return "(($code) ?'' :' ')"; |
|
| 909 | - case ($fonc == 'yes') or ($fonc == 'oui'): |
|
| 910 | - return "(($code) ?' ' :'')"; |
|
| 911 | - } |
|
| 912 | - |
|
| 913 | - return ''; |
|
| 896 | + switch (true) { |
|
| 897 | + case in_array($fonc, $GLOBALS['table_criteres_infixes']): |
|
| 898 | + return "($code $fonc $arg)"; |
|
| 899 | + case ($fonc == 'and') or ($fonc == 'et'): |
|
| 900 | + return "((($code) AND ($arg)) ?' ' :'')"; |
|
| 901 | + case ($fonc == 'or') or ($fonc == 'ou'): |
|
| 902 | + return "((($code) OR ($arg)) ?' ' :'')"; |
|
| 903 | + case ($fonc == 'xor') or ($fonc == 'xou'): |
|
| 904 | + return "((($code) XOR ($arg)) ?' ' :'')"; |
|
| 905 | + case ($fonc == 'sinon'): |
|
| 906 | + return "(((\$a = $code) OR (is_string(\$a) AND strlen(\$a))) ? \$a : $arg)"; |
|
| 907 | + case ($fonc == 'not') or ($fonc == 'non'): |
|
| 908 | + return "(($code) ?'' :' ')"; |
|
| 909 | + case ($fonc == 'yes') or ($fonc == 'oui'): |
|
| 910 | + return "(($code) ?' ' :'')"; |
|
| 911 | + } |
|
| 912 | + |
|
| 913 | + return ''; |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | function compose_filtres_args($p, $args, $sep) { |
| 917 | - $arglist = ''; |
|
| 918 | - foreach ($args as $arg) { |
|
| 919 | - $arglist .= $sep . |
|
| 920 | - calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle); |
|
| 921 | - } |
|
| 917 | + $arglist = ''; |
|
| 918 | + foreach ($args as $arg) { |
|
| 919 | + $arglist .= $sep . |
|
| 920 | + calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle); |
|
| 921 | + } |
|
| 922 | 922 | |
| 923 | - return $arglist; |
|
| 923 | + return $arglist; |
|
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | |
@@ -938,15 +938,15 @@ discard block |
||
| 938 | 938 | **/ |
| 939 | 939 | function calculer_argument_precedent($idb, $nom_champ, &$boucles, $defaut = null) { |
| 940 | 940 | |
| 941 | - // si recursif, forcer l'extraction du champ SQL mais ignorer le code |
|
| 942 | - if ($boucles[$idb]->externe) { |
|
| 943 | - index_pile($idb, $nom_champ, $boucles, '', $defaut); |
|
| 944 | - // retourner $Pile[$SP] et pas $Pile[0] si recursion en 1ere boucle |
|
| 945 | - // on ignore le defaut fourni dans ce cas |
|
| 946 | - $defaut = "(\$Pile[\$SP]['$nom_champ'] ?? null)"; |
|
| 947 | - } |
|
| 941 | + // si recursif, forcer l'extraction du champ SQL mais ignorer le code |
|
| 942 | + if ($boucles[$idb]->externe) { |
|
| 943 | + index_pile($idb, $nom_champ, $boucles, '', $defaut); |
|
| 944 | + // retourner $Pile[$SP] et pas $Pile[0] si recursion en 1ere boucle |
|
| 945 | + // on ignore le defaut fourni dans ce cas |
|
| 946 | + $defaut = "(\$Pile[\$SP]['$nom_champ'] ?? null)"; |
|
| 947 | + } |
|
| 948 | 948 | |
| 949 | - return index_pile($boucles[$idb]->id_parent, $nom_champ, $boucles, '', $defaut); |
|
| 949 | + return index_pile($boucles[$idb]->id_parent, $nom_champ, $boucles, '', $defaut); |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | // |
@@ -960,30 +960,30 @@ discard block |
||
| 960 | 960 | // |
| 961 | 961 | |
| 962 | 962 | function rindex_pile($p, $champ, $motif) { |
| 963 | - $n = 0; |
|
| 964 | - $b = $p->id_boucle; |
|
| 965 | - $p->code = ''; |
|
| 966 | - while ($b != '') { |
|
| 967 | - foreach ($p->boucles[$b]->criteres as $critere) { |
|
| 968 | - if ($critere->op == $motif) { |
|
| 969 | - $p->code = '$Pile[$SP' . (($n == 0) ? '' : "-$n") . |
|
| 970 | - "]['$champ']"; |
|
| 971 | - $b = ''; |
|
| 972 | - break 2; |
|
| 973 | - } |
|
| 974 | - } |
|
| 975 | - $n++; |
|
| 976 | - $b = $p->boucles[$b]->id_parent; |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - // si on est hors d'une boucle de {recherche}, cette balise est vide |
|
| 980 | - if (!$p->code) { |
|
| 981 | - $p->code = "''"; |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - $p->interdire_scripts = false; |
|
| 985 | - |
|
| 986 | - return $p; |
|
| 963 | + $n = 0; |
|
| 964 | + $b = $p->id_boucle; |
|
| 965 | + $p->code = ''; |
|
| 966 | + while ($b != '') { |
|
| 967 | + foreach ($p->boucles[$b]->criteres as $critere) { |
|
| 968 | + if ($critere->op == $motif) { |
|
| 969 | + $p->code = '$Pile[$SP' . (($n == 0) ? '' : "-$n") . |
|
| 970 | + "]['$champ']"; |
|
| 971 | + $b = ''; |
|
| 972 | + break 2; |
|
| 973 | + } |
|
| 974 | + } |
|
| 975 | + $n++; |
|
| 976 | + $b = $p->boucles[$b]->id_parent; |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + // si on est hors d'une boucle de {recherche}, cette balise est vide |
|
| 980 | + if (!$p->code) { |
|
| 981 | + $p->code = "''"; |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + $p->interdire_scripts = false; |
|
| 985 | + |
|
| 986 | + return $p; |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | /** |
@@ -993,7 +993,7 @@ discard block |
||
| 993 | 993 | * @return string Nom de la balise, avec indication de boucle explicite si présent. |
| 994 | 994 | */ |
| 995 | 995 | function zbug_presenter_champ($p, $champ = '') { |
| 996 | - $balise = $champ ?: $p->nom_champ; |
|
| 997 | - $explicite = $p->nom_boucle ? $p->nom_boucle . ':' : ''; |
|
| 998 | - return "#{$explicite}{$balise}"; |
|
| 996 | + $balise = $champ ?: $p->nom_champ; |
|
| 997 | + $explicite = $p->nom_boucle ? $p->nom_boucle . ':' : ''; |
|
| 998 | + return "#{$explicite}{$balise}"; |
|
| 999 | 999 | } |
@@ -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.1.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 | } |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | if ($quoi !== 'actifs') { |
| 148 | 148 | $lpf = liste_plugin_files(); |
| 149 | 149 | if ($lpf) { |
| 150 | - echo '<p>' . _T('texte_presente_plugin') . '</p>'; |
|
| 150 | + echo '<p>'._T('texte_presente_plugin').'</p>'; |
|
| 151 | 151 | } else { |
| 152 | 152 | if (!@is_dir(_DIR_PLUGINS)) { |
| 153 | - echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)]) |
|
| 154 | - . ' — ' . _T('plugin_info_automatique_creer') . '</p>'; |
|
| 153 | + echo '<p>'._T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)]) |
|
| 154 | + . ' — '._T('plugin_info_automatique_creer').'</p>'; |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | $lcpaffiche = $lpf; |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | if (defined('_DIR_PLUGINS_SUPPL')) { |
| 173 | 173 | $nb += is_countable($lcpas) ? count($lcpas) : 0; |
| 174 | 174 | } |
| 175 | - echo '<h3>' . sinon( |
|
| 175 | + echo '<h3>'.sinon( |
|
| 176 | 176 | singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
| 177 | 177 | _T('plugins_actif_aucun') |
| 178 | - ) . '</h3>'; |
|
| 178 | + ).'</h3>'; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | if (empty($format)) { |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | if ($corps) { |
| 194 | 194 | $corps .= "\n<div class='boutons' style='display:none;'>" |
| 195 | - . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 195 | + . "<input type='submit' class='submit save' value='"._T('bouton_enregistrer') |
|
| 196 | 196 | . "' />" |
| 197 | 197 | . '</div>'; |
| 198 | 198 | } |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
| 267 | 267 | . '<p>' |
| 268 | 268 | . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)]) |
| 269 | - . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 269 | + . '<br />'._T('plugin_info_plugins_dist_2') |
|
| 270 | 270 | . '</p>' |
| 271 | 271 | . $liste |
| 272 | 272 | . fin_cadre_trait_couleur() |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
| 290 | 290 | $res .= '<dl>'; |
| 291 | 291 | foreach ($libs as $lib => $rep) { |
| 292 | - $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 292 | + $res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n"; |
|
| 293 | 293 | } |
| 294 | 294 | $res .= '</dl>'; |
| 295 | 295 | $res .= fin_cadre_enfonce(); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $libs = []; |
| 309 | 309 | foreach (array_reverse(creer_chemin()) as $d) { |
| 310 | 310 | if ( |
| 311 | - is_dir($dir = $d . 'lib/') |
|
| 311 | + is_dir($dir = $d.'lib/') |
|
| 312 | 312 | and $t = opendir($dir) |
| 313 | 313 | ) { |
| 314 | 314 | while (($f = readdir($t)) !== false) { |
@@ -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 | include_spip('inc/config'); |
@@ -37,26 +37,26 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function exec_admin_plugin_dist($retour = '') { |
| 39 | 39 | |
| 40 | - if (!autoriser('configurer', '_plugins')) { |
|
| 41 | - include_spip('inc/minipres'); |
|
| 42 | - echo minipres(); |
|
| 43 | - } else { |
|
| 44 | - // on fait la verif du path avant tout, |
|
| 45 | - // et l'installation des qu'on est dans la colonne principale |
|
| 46 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 47 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 48 | - $new = actualise_plugins_actifs(); |
|
| 49 | - if ($new and _request('actualise') < 2) { |
|
| 50 | - include_spip('inc/headers'); |
|
| 51 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 52 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 53 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 54 | - } |
|
| 55 | - redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 56 | - } else { |
|
| 57 | - admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 58 | - } |
|
| 59 | - } |
|
| 40 | + if (!autoriser('configurer', '_plugins')) { |
|
| 41 | + include_spip('inc/minipres'); |
|
| 42 | + echo minipres(); |
|
| 43 | + } else { |
|
| 44 | + // on fait la verif du path avant tout, |
|
| 45 | + // et l'installation des qu'on est dans la colonne principale |
|
| 46 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 47 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 48 | + $new = actualise_plugins_actifs(); |
|
| 49 | + if ($new and _request('actualise') < 2) { |
|
| 50 | + include_spip('inc/headers'); |
|
| 51 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 52 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 53 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 54 | + } |
|
| 55 | + redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 56 | + } else { |
|
| 57 | + admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -81,132 +81,132 @@ discard block |
||
| 81 | 81 | * Format d'affichage (liste ou arborescence) |
| 82 | 82 | **/ |
| 83 | 83 | function admin_plug_args($quoi, $erreur, $format) { |
| 84 | - $lpf = null; |
|
| 85 | - $lcpas = null; |
|
| 86 | - $lcpaffichesup = null; |
|
| 87 | - if (!$quoi) { |
|
| 88 | - $quoi = 'actifs'; |
|
| 89 | - } |
|
| 90 | - // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 91 | - // format brut par plugin |
|
| 92 | - $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 93 | - // format resume mis en forme |
|
| 94 | - $erreur_activation = plugin_donne_erreurs(); |
|
| 95 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 96 | - echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin'); |
|
| 97 | - |
|
| 98 | - echo debut_gauche(); |
|
| 99 | - echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']); |
|
| 100 | - |
|
| 101 | - echo pipeline( |
|
| 102 | - 'affiche_gauche', |
|
| 103 | - [ |
|
| 104 | - 'args' => ['exec' => 'admin_plugin'], |
|
| 105 | - 'data' => afficher_librairies() |
|
| 106 | - ] |
|
| 107 | - ); |
|
| 108 | - |
|
| 109 | - echo debut_droite(); |
|
| 110 | - echo gros_titre(_T('icone_admin_plugin'), ''); |
|
| 111 | - |
|
| 112 | - // Barre d'onglets de premier niveau |
|
| 113 | - echo barre_onglets('plugins', 'plugins_actifs'); |
|
| 114 | - // Barre d'onglets de second niveau |
|
| 115 | - $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 116 | - echo debut_onglet('onglets_simple second'); |
|
| 117 | - echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2); |
|
| 118 | - echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2); |
|
| 119 | - echo fin_onglet(); |
|
| 120 | - |
|
| 121 | - // message d'erreur au retour d'une operation |
|
| 122 | - if ($erreur) { |
|
| 123 | - echo "<div class='error'>".spip_htmlspecialchars($erreur)."</div>"; |
|
| 124 | - } |
|
| 125 | - if ($erreur_activation) { |
|
| 126 | - echo "<div class='error'>$erreur_activation</div>"; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 130 | - $actifs = (array) unserialize($GLOBALS['meta']['plugin']); |
|
| 131 | - $lcpa = $actifs + (array) unserialize($GLOBALS['meta']['plugin_attente']); |
|
| 132 | - |
|
| 133 | - // Les affichages se basent sur le repertoire, pas sur le nom |
|
| 134 | - $actifs = liste_chemin_plugin($actifs, ''); |
|
| 135 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 136 | - $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL); |
|
| 137 | - } |
|
| 138 | - $lcpa = liste_chemin_plugin($lcpa); |
|
| 139 | - |
|
| 140 | - // on installe les plugins maintenant, |
|
| 141 | - // cela permet aux scripts d'install de faire des affichages (moches...) |
|
| 142 | - plugin_installes_meta(); |
|
| 143 | - |
|
| 144 | - echo "<div class='liste-plugins formulaire_spip'>"; |
|
| 145 | - echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins'); |
|
| 146 | - |
|
| 147 | - if ($quoi !== 'actifs') { |
|
| 148 | - $lpf = liste_plugin_files(); |
|
| 149 | - if ($lpf) { |
|
| 150 | - echo '<p>' . _T('texte_presente_plugin') . '</p>'; |
|
| 151 | - } else { |
|
| 152 | - if (!@is_dir(_DIR_PLUGINS)) { |
|
| 153 | - echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)]) |
|
| 154 | - . ' — ' . _T('plugin_info_automatique_creer') . '</p>'; |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - $lcpaffiche = $lpf; |
|
| 158 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 159 | - $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 160 | - } |
|
| 161 | - } else { |
|
| 162 | - // la liste |
|
| 163 | - // $quoi=='actifs' |
|
| 164 | - $lcpaffiche = $lcpa; |
|
| 165 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 166 | - $lcpaffichesup = $lcpas; |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - if ($quoi == 'actifs' or $lpf) { |
|
| 171 | - $nb = is_countable($lcpa) ? count($lcpa) : 0; |
|
| 172 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 173 | - $nb += is_countable($lcpas) ? count($lcpas) : 0; |
|
| 174 | - } |
|
| 175 | - echo '<h3>' . sinon( |
|
| 176 | - singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
|
| 177 | - _T('plugins_actif_aucun') |
|
| 178 | - ) . '</h3>'; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - if (empty($format)) { |
|
| 182 | - $format = 'liste'; |
|
| 183 | - } elseif (!in_array($format, ['liste', 'repertoires'])) { |
|
| 184 | - $format = 'repertoires'; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $afficher = charger_fonction("afficher_$format", 'plugins'); |
|
| 188 | - $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs); |
|
| 189 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 190 | - $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - if ($corps) { |
|
| 194 | - $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 195 | - . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 196 | - . "' />" |
|
| 197 | - . '</div>'; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps); |
|
| 201 | - |
|
| 202 | - echo fin_cadre_trait_couleur(); |
|
| 203 | - |
|
| 204 | - if ($quoi == 'actifs') { |
|
| 205 | - echo affiche_les_plugins_verrouilles($actifs); |
|
| 206 | - } |
|
| 207 | - echo '</div>'; |
|
| 208 | - |
|
| 209 | - echo http_script(" |
|
| 84 | + $lpf = null; |
|
| 85 | + $lcpas = null; |
|
| 86 | + $lcpaffichesup = null; |
|
| 87 | + if (!$quoi) { |
|
| 88 | + $quoi = 'actifs'; |
|
| 89 | + } |
|
| 90 | + // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 91 | + // format brut par plugin |
|
| 92 | + $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 93 | + // format resume mis en forme |
|
| 94 | + $erreur_activation = plugin_donne_erreurs(); |
|
| 95 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 96 | + echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin'); |
|
| 97 | + |
|
| 98 | + echo debut_gauche(); |
|
| 99 | + echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']); |
|
| 100 | + |
|
| 101 | + echo pipeline( |
|
| 102 | + 'affiche_gauche', |
|
| 103 | + [ |
|
| 104 | + 'args' => ['exec' => 'admin_plugin'], |
|
| 105 | + 'data' => afficher_librairies() |
|
| 106 | + ] |
|
| 107 | + ); |
|
| 108 | + |
|
| 109 | + echo debut_droite(); |
|
| 110 | + echo gros_titre(_T('icone_admin_plugin'), ''); |
|
| 111 | + |
|
| 112 | + // Barre d'onglets de premier niveau |
|
| 113 | + echo barre_onglets('plugins', 'plugins_actifs'); |
|
| 114 | + // Barre d'onglets de second niveau |
|
| 115 | + $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 116 | + echo debut_onglet('onglets_simple second'); |
|
| 117 | + echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2); |
|
| 118 | + echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2); |
|
| 119 | + echo fin_onglet(); |
|
| 120 | + |
|
| 121 | + // message d'erreur au retour d'une operation |
|
| 122 | + if ($erreur) { |
|
| 123 | + echo "<div class='error'>".spip_htmlspecialchars($erreur)."</div>"; |
|
| 124 | + } |
|
| 125 | + if ($erreur_activation) { |
|
| 126 | + echo "<div class='error'>$erreur_activation</div>"; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 130 | + $actifs = (array) unserialize($GLOBALS['meta']['plugin']); |
|
| 131 | + $lcpa = $actifs + (array) unserialize($GLOBALS['meta']['plugin_attente']); |
|
| 132 | + |
|
| 133 | + // Les affichages se basent sur le repertoire, pas sur le nom |
|
| 134 | + $actifs = liste_chemin_plugin($actifs, ''); |
|
| 135 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 136 | + $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL); |
|
| 137 | + } |
|
| 138 | + $lcpa = liste_chemin_plugin($lcpa); |
|
| 139 | + |
|
| 140 | + // on installe les plugins maintenant, |
|
| 141 | + // cela permet aux scripts d'install de faire des affichages (moches...) |
|
| 142 | + plugin_installes_meta(); |
|
| 143 | + |
|
| 144 | + echo "<div class='liste-plugins formulaire_spip'>"; |
|
| 145 | + echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins'); |
|
| 146 | + |
|
| 147 | + if ($quoi !== 'actifs') { |
|
| 148 | + $lpf = liste_plugin_files(); |
|
| 149 | + if ($lpf) { |
|
| 150 | + echo '<p>' . _T('texte_presente_plugin') . '</p>'; |
|
| 151 | + } else { |
|
| 152 | + if (!@is_dir(_DIR_PLUGINS)) { |
|
| 153 | + echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)]) |
|
| 154 | + . ' — ' . _T('plugin_info_automatique_creer') . '</p>'; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + $lcpaffiche = $lpf; |
|
| 158 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 159 | + $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 160 | + } |
|
| 161 | + } else { |
|
| 162 | + // la liste |
|
| 163 | + // $quoi=='actifs' |
|
| 164 | + $lcpaffiche = $lcpa; |
|
| 165 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 166 | + $lcpaffichesup = $lcpas; |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + if ($quoi == 'actifs' or $lpf) { |
|
| 171 | + $nb = is_countable($lcpa) ? count($lcpa) : 0; |
|
| 172 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 173 | + $nb += is_countable($lcpas) ? count($lcpas) : 0; |
|
| 174 | + } |
|
| 175 | + echo '<h3>' . sinon( |
|
| 176 | + singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
|
| 177 | + _T('plugins_actif_aucun') |
|
| 178 | + ) . '</h3>'; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + if (empty($format)) { |
|
| 182 | + $format = 'liste'; |
|
| 183 | + } elseif (!in_array($format, ['liste', 'repertoires'])) { |
|
| 184 | + $format = 'repertoires'; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $afficher = charger_fonction("afficher_$format", 'plugins'); |
|
| 188 | + $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs); |
|
| 189 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 190 | + $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + if ($corps) { |
|
| 194 | + $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 195 | + . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 196 | + . "' />" |
|
| 197 | + . '</div>'; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps); |
|
| 201 | + |
|
| 202 | + echo fin_cadre_trait_couleur(); |
|
| 203 | + |
|
| 204 | + if ($quoi == 'actifs') { |
|
| 205 | + echo affiche_les_plugins_verrouilles($actifs); |
|
| 206 | + } |
|
| 207 | + echo '</div>'; |
|
| 208 | + |
|
| 209 | + echo http_script(" |
|
| 210 | 210 | jQuery(function(){ |
| 211 | 211 | jQuery('.plugins li.item a[rel=info]').click(function(){ |
| 212 | 212 | var li = jQuery(this).parents('li').eq(0); |
@@ -232,15 +232,15 @@ discard block |
||
| 232 | 232 | }); |
| 233 | 233 | "); |
| 234 | 234 | |
| 235 | - echo pipeline( |
|
| 236 | - 'affiche_milieu', |
|
| 237 | - [ |
|
| 238 | - 'args' => ['exec' => 'admin_plugin'], |
|
| 239 | - 'data' => '' |
|
| 240 | - ] |
|
| 241 | - ); |
|
| 235 | + echo pipeline( |
|
| 236 | + 'affiche_milieu', |
|
| 237 | + [ |
|
| 238 | + 'args' => ['exec' => 'admin_plugin'], |
|
| 239 | + 'data' => '' |
|
| 240 | + ] |
|
| 241 | + ); |
|
| 242 | 242 | |
| 243 | - echo fin_gauche(), fin_page(); |
|
| 243 | + echo fin_gauche(), fin_page(); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -254,23 +254,23 @@ discard block |
||
| 254 | 254 | * Code HTML |
| 255 | 255 | **/ |
| 256 | 256 | function affiche_les_plugins_verrouilles($actifs) { |
| 257 | - if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) { |
|
| 258 | - return ''; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 262 | - $liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST); |
|
| 263 | - |
|
| 264 | - return |
|
| 265 | - "<div id='plugins_dist'>" |
|
| 266 | - . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 267 | - . '<p>' |
|
| 268 | - . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)]) |
|
| 269 | - . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 270 | - . '</p>' |
|
| 271 | - . $liste |
|
| 272 | - . fin_cadre_trait_couleur() |
|
| 273 | - . "</div>\n"; |
|
| 257 | + if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) { |
|
| 258 | + return ''; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 262 | + $liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST); |
|
| 263 | + |
|
| 264 | + return |
|
| 265 | + "<div id='plugins_dist'>" |
|
| 266 | + . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 267 | + . '<p>' |
|
| 268 | + . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)]) |
|
| 269 | + . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 270 | + . '</p>' |
|
| 271 | + . $liste |
|
| 272 | + . fin_cadre_trait_couleur() |
|
| 273 | + . "</div>\n"; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -282,19 +282,19 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | function afficher_librairies() { |
| 284 | 284 | |
| 285 | - if (!$libs = liste_librairies()) { |
|
| 286 | - return ''; |
|
| 287 | - } |
|
| 288 | - ksort($libs); |
|
| 289 | - $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
|
| 290 | - $res .= '<dl>'; |
|
| 291 | - foreach ($libs as $lib => $rep) { |
|
| 292 | - $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 293 | - } |
|
| 294 | - $res .= '</dl>'; |
|
| 295 | - $res .= fin_cadre_enfonce(); |
|
| 296 | - |
|
| 297 | - return $res; |
|
| 285 | + if (!$libs = liste_librairies()) { |
|
| 286 | + return ''; |
|
| 287 | + } |
|
| 288 | + ksort($libs); |
|
| 289 | + $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
|
| 290 | + $res .= '<dl>'; |
|
| 291 | + foreach ($libs as $lib => $rep) { |
|
| 292 | + $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 293 | + } |
|
| 294 | + $res .= '</dl>'; |
|
| 295 | + $res .= fin_cadre_enfonce(); |
|
| 296 | + |
|
| 297 | + return $res; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
@@ -305,22 +305,22 @@ discard block |
||
| 305 | 305 | * Tableau (nom de la lib => repertoire , ...) |
| 306 | 306 | */ |
| 307 | 307 | function liste_librairies() { |
| 308 | - $libs = []; |
|
| 309 | - foreach (array_reverse(creer_chemin()) as $d) { |
|
| 310 | - if ( |
|
| 311 | - is_dir($dir = $d . 'lib/') |
|
| 312 | - and $t = opendir($dir) |
|
| 313 | - ) { |
|
| 314 | - while (($f = readdir($t)) !== false) { |
|
| 315 | - if ( |
|
| 316 | - $f[0] != '.' |
|
| 317 | - and is_dir("$dir/$f") |
|
| 318 | - ) { |
|
| 319 | - $libs[$f] = $dir; |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - return $libs; |
|
| 308 | + $libs = []; |
|
| 309 | + foreach (array_reverse(creer_chemin()) as $d) { |
|
| 310 | + if ( |
|
| 311 | + is_dir($dir = $d . 'lib/') |
|
| 312 | + and $t = opendir($dir) |
|
| 313 | + ) { |
|
| 314 | + while (($f = readdir($t)) !== false) { |
|
| 315 | + if ( |
|
| 316 | + $f[0] != '.' |
|
| 317 | + and is_dir("$dir/$f") |
|
| 318 | + ) { |
|
| 319 | + $libs[$f] = $dir; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + return $libs; |
|
| 326 | 326 | } |
@@ -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 | /* |