@@ -11,129 +11,129 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP |
| 18 | 18 | |
| 19 | 19 | function decompiler_boucle($struct, $fmt = '', $prof = 0) { |
| 20 | - $nom = $struct->id_boucle; |
|
| 21 | - $preaff = decompiler_($struct->preaff, $fmt, $prof); |
|
| 22 | - $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 23 | - $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 24 | - $altern = decompiler_($struct->altern, $fmt, $prof); |
|
| 25 | - $milieu = decompiler_($struct->milieu, $fmt, $prof); |
|
| 26 | - $postaff = decompiler_($struct->postaff, $fmt, $prof); |
|
| 27 | - |
|
| 28 | - $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
|
| 29 | - $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 30 | - $struct->table_optionnelle); |
|
| 31 | - |
|
| 32 | - if ($struct->jointures_explicites) { |
|
| 33 | - $type .= " " . $struct->jointures_explicites; |
|
| 34 | - } |
|
| 35 | - if ($struct->table_optionnelle) { |
|
| 36 | - $type .= "?"; |
|
| 37 | - } |
|
| 38 | - // Revoir le cas de la boucle recursive |
|
| 39 | - |
|
| 40 | - $crit = $struct->param; |
|
| 41 | - if ($crit and !is_array($crit[0])) { |
|
| 42 | - $type = strtolower($type) . array_shift($crit); |
|
| 43 | - } |
|
| 44 | - $crit = decompiler_criteres($struct, $fmt, $prof); |
|
| 45 | - |
|
| 46 | - $f = 'format_boucle_' . $fmt; |
|
| 47 | - |
|
| 48 | - return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof); |
|
| 20 | + $nom = $struct->id_boucle; |
|
| 21 | + $preaff = decompiler_($struct->preaff, $fmt, $prof); |
|
| 22 | + $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 23 | + $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 24 | + $altern = decompiler_($struct->altern, $fmt, $prof); |
|
| 25 | + $milieu = decompiler_($struct->milieu, $fmt, $prof); |
|
| 26 | + $postaff = decompiler_($struct->postaff, $fmt, $prof); |
|
| 27 | + |
|
| 28 | + $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
|
| 29 | + $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 30 | + $struct->table_optionnelle); |
|
| 31 | + |
|
| 32 | + if ($struct->jointures_explicites) { |
|
| 33 | + $type .= " " . $struct->jointures_explicites; |
|
| 34 | + } |
|
| 35 | + if ($struct->table_optionnelle) { |
|
| 36 | + $type .= "?"; |
|
| 37 | + } |
|
| 38 | + // Revoir le cas de la boucle recursive |
|
| 39 | + |
|
| 40 | + $crit = $struct->param; |
|
| 41 | + if ($crit and !is_array($crit[0])) { |
|
| 42 | + $type = strtolower($type) . array_shift($crit); |
|
| 43 | + } |
|
| 44 | + $crit = decompiler_criteres($struct, $fmt, $prof); |
|
| 45 | + |
|
| 46 | + $f = 'format_boucle_' . $fmt; |
|
| 47 | + |
|
| 48 | + return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | function decompiler_include($struct, $fmt = '', $prof = 0) { |
| 52 | - $res = array(); |
|
| 53 | - foreach ($struct->param ? $struct->param : array() as $couple) { |
|
| 54 | - array_shift($couple); |
|
| 55 | - foreach ($couple as $v) { |
|
| 56 | - $res[] = decompiler_($v, $fmt, $prof); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 60 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 61 | - $f = 'format_inclure_' . $fmt; |
|
| 62 | - |
|
| 63 | - return $f($file, $res, $prof); |
|
| 52 | + $res = array(); |
|
| 53 | + foreach ($struct->param ? $struct->param : array() as $couple) { |
|
| 54 | + array_shift($couple); |
|
| 55 | + foreach ($couple as $v) { |
|
| 56 | + $res[] = decompiler_($v, $fmt, $prof); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + $file = is_string($struct->texte) ? $struct->texte : |
|
| 60 | + decompiler_($struct->texte, $fmt, $prof); |
|
| 61 | + $f = 'format_inclure_' . $fmt; |
|
| 62 | + |
|
| 63 | + return $f($file, $res, $prof); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | function decompiler_texte($struct, $fmt = '', $prof = 0) { |
| 67 | - $f = 'format_texte_' . $fmt; |
|
| 67 | + $f = 'format_texte_' . $fmt; |
|
| 68 | 68 | |
| 69 | - return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
|
| 69 | + return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | function decompiler_polyglotte($struct, $fmt = '', $prof = 0) { |
| 73 | - $f = 'format_polyglotte_' . $fmt; |
|
| 73 | + $f = 'format_polyglotte_' . $fmt; |
|
| 74 | 74 | |
| 75 | - return $f($struct->traductions, $prof); |
|
| 75 | + return $f($struct->traductions, $prof); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function decompiler_idiome($struct, $fmt = '', $prof = 0) { |
| 79 | - $args = array(); |
|
| 80 | - foreach ($struct->arg as $k => $v) { |
|
| 81 | - $args[$k] = public_decompiler($v, $fmt, $prof); |
|
| 82 | - } |
|
| 79 | + $args = array(); |
|
| 80 | + foreach ($struct->arg as $k => $v) { |
|
| 81 | + $args[$k] = public_decompiler($v, $fmt, $prof); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 84 | + $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 85 | 85 | |
| 86 | - $f = 'format_idiome_' . $fmt; |
|
| 86 | + $f = 'format_idiome_' . $fmt; |
|
| 87 | 87 | |
| 88 | - return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
|
| 88 | + return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function decompiler_champ($struct, $fmt = '', $prof = 0) { |
| 92 | - $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 93 | - $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 94 | - $args = $filtres = ''; |
|
| 95 | - if ($p = $struct->param) { |
|
| 96 | - if ($p[0][0] === '') { |
|
| 97 | - $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 98 | - } |
|
| 99 | - $filtres = decompiler_liste($p, $fmt, $prof); |
|
| 100 | - } |
|
| 101 | - $f = 'format_champ_' . $fmt; |
|
| 102 | - |
|
| 103 | - return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
|
| 92 | + $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 93 | + $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 94 | + $args = $filtres = ''; |
|
| 95 | + if ($p = $struct->param) { |
|
| 96 | + if ($p[0][0] === '') { |
|
| 97 | + $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 98 | + } |
|
| 99 | + $filtres = decompiler_liste($p, $fmt, $prof); |
|
| 100 | + } |
|
| 101 | + $f = 'format_champ_' . $fmt; |
|
| 102 | + |
|
| 103 | + return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | function decompiler_liste($sources, $fmt = '', $prof = 0) { |
| 107 | - if (!is_array($sources)) { |
|
| 108 | - return ''; |
|
| 109 | - } |
|
| 110 | - $f = 'format_liste_' . $fmt; |
|
| 111 | - $res = ''; |
|
| 112 | - foreach ($sources as $arg) { |
|
| 113 | - if (!is_array($arg)) { |
|
| 114 | - continue; // ne devrait pas arriver. |
|
| 115 | - } else { |
|
| 116 | - $r = array_shift($arg); |
|
| 117 | - } |
|
| 118 | - $args = array(); |
|
| 119 | - foreach ($arg as $v) { |
|
| 120 | - // cas des arguments entoures de ' ou " |
|
| 121 | - if ((count($v) == 1) |
|
| 122 | - and $v[0]->type == 'texte' |
|
| 123 | - and (strlen($v[0]->apres) == 1) |
|
| 124 | - and $v[0]->apres == $v[0]->avant |
|
| 125 | - ) { |
|
| 126 | - $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 127 | - } else { |
|
| 128 | - $args[] = decompiler_($v, $fmt, 0 - $prof); |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - if (($r !== '') or $args) { |
|
| 132 | - $res .= $f($r, $args, $prof); |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - return $res; |
|
| 107 | + if (!is_array($sources)) { |
|
| 108 | + return ''; |
|
| 109 | + } |
|
| 110 | + $f = 'format_liste_' . $fmt; |
|
| 111 | + $res = ''; |
|
| 112 | + foreach ($sources as $arg) { |
|
| 113 | + if (!is_array($arg)) { |
|
| 114 | + continue; // ne devrait pas arriver. |
|
| 115 | + } else { |
|
| 116 | + $r = array_shift($arg); |
|
| 117 | + } |
|
| 118 | + $args = array(); |
|
| 119 | + foreach ($arg as $v) { |
|
| 120 | + // cas des arguments entoures de ' ou " |
|
| 121 | + if ((count($v) == 1) |
|
| 122 | + and $v[0]->type == 'texte' |
|
| 123 | + and (strlen($v[0]->apres) == 1) |
|
| 124 | + and $v[0]->apres == $v[0]->avant |
|
| 125 | + ) { |
|
| 126 | + $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 127 | + } else { |
|
| 128 | + $args[] = decompiler_($v, $fmt, 0 - $prof); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + if (($r !== '') or $args) { |
|
| 132 | + $res .= $f($r, $args, $prof); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + return $res; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Decompilation des criteres: on triche et on deroge: |
@@ -141,91 +141,91 @@ discard block |
||
| 141 | 141 | // - le champ apres signale le critere {"separateur"} ou {'separateur'} |
| 142 | 142 | // - les champs sont implicitement etendus (crochets implicites mais interdits) |
| 143 | 143 | function decompiler_criteres($boucle, $fmt = '', $prof = 0) { |
| 144 | - $sources = $boucle->param; |
|
| 145 | - if (!is_array($sources)) { |
|
| 146 | - return ''; |
|
| 147 | - } |
|
| 148 | - $res = ''; |
|
| 149 | - $f = 'format_critere_' . $fmt; |
|
| 150 | - foreach ($sources as $crit) { |
|
| 151 | - if (!is_array($crit)) { |
|
| 152 | - continue; |
|
| 153 | - } // boucle recursive |
|
| 154 | - array_shift($crit); |
|
| 155 | - $args = array(); |
|
| 156 | - foreach ($crit as $i => $v) { |
|
| 157 | - if ((count($v) == 1) |
|
| 158 | - and $v[0]->type == 'texte' |
|
| 159 | - and $v[0]->apres |
|
| 160 | - ) { |
|
| 161 | - $args[] = array(array('texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 162 | - } else { |
|
| 163 | - $res2 = array(); |
|
| 164 | - foreach ($v as $k => $p) { |
|
| 165 | - if (isset($p->type) |
|
| 166 | - and function_exists($d = 'decompiler_' . $p->type) |
|
| 167 | - ) { |
|
| 168 | - $r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]); |
|
| 169 | - $res2[] = array($p->type, $r); |
|
| 170 | - } else { |
|
| 171 | - spip_log("critere $i / $k mal forme"); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - $args[] = $res2; |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - $res .= $f($args); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return $res; |
|
| 144 | + $sources = $boucle->param; |
|
| 145 | + if (!is_array($sources)) { |
|
| 146 | + return ''; |
|
| 147 | + } |
|
| 148 | + $res = ''; |
|
| 149 | + $f = 'format_critere_' . $fmt; |
|
| 150 | + foreach ($sources as $crit) { |
|
| 151 | + if (!is_array($crit)) { |
|
| 152 | + continue; |
|
| 153 | + } // boucle recursive |
|
| 154 | + array_shift($crit); |
|
| 155 | + $args = array(); |
|
| 156 | + foreach ($crit as $i => $v) { |
|
| 157 | + if ((count($v) == 1) |
|
| 158 | + and $v[0]->type == 'texte' |
|
| 159 | + and $v[0]->apres |
|
| 160 | + ) { |
|
| 161 | + $args[] = array(array('texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 162 | + } else { |
|
| 163 | + $res2 = array(); |
|
| 164 | + foreach ($v as $k => $p) { |
|
| 165 | + if (isset($p->type) |
|
| 166 | + and function_exists($d = 'decompiler_' . $p->type) |
|
| 167 | + ) { |
|
| 168 | + $r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]); |
|
| 169 | + $res2[] = array($p->type, $r); |
|
| 170 | + } else { |
|
| 171 | + spip_log("critere $i / $k mal forme"); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + $args[] = $res2; |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + $res .= $f($args); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return $res; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | function decompiler_($liste, $fmt = '', $prof = 0) { |
| 185 | - if (!is_array($liste)) { |
|
| 186 | - return ''; |
|
| 187 | - } |
|
| 188 | - $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1); |
|
| 189 | - $contenu = array(); |
|
| 190 | - foreach ($liste as $k => $p) { |
|
| 191 | - if (!isset($p->type)) { |
|
| 192 | - continue; |
|
| 193 | - } #?????? |
|
| 194 | - $d = 'decompiler_' . $p->type; |
|
| 195 | - $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false; |
|
| 196 | - // Forcer le champ etendu si son source (pas les reecritures) |
|
| 197 | - // contenait des args et s'il est suivi d'espaces, |
|
| 198 | - // le champ simple les eliminant est un bug helas perenne. |
|
| 199 | - |
|
| 200 | - if ($next |
|
| 201 | - and ($next->type == 'texte') |
|
| 202 | - and $p->type == 'champ' |
|
| 203 | - and !$p->apres |
|
| 204 | - and !$p->avant |
|
| 205 | - and $p->fonctions |
|
| 206 | - ) { |
|
| 207 | - $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
|
| 208 | - if ($n) { |
|
| 209 | - $champ = new Texte; |
|
| 210 | - $champ->texte = substr($next->texte, 0, $n); |
|
| 211 | - $champ->ligne = $p->ligne; |
|
| 212 | - $p->apres = array($champ); |
|
| 213 | - $next->texte = substr($next->texte, $n); |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
|
| 217 | - |
|
| 218 | - } |
|
| 219 | - $f = 'format_suite_' . $fmt; |
|
| 220 | - |
|
| 221 | - return $f($contenu); |
|
| 185 | + if (!is_array($liste)) { |
|
| 186 | + return ''; |
|
| 187 | + } |
|
| 188 | + $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1); |
|
| 189 | + $contenu = array(); |
|
| 190 | + foreach ($liste as $k => $p) { |
|
| 191 | + if (!isset($p->type)) { |
|
| 192 | + continue; |
|
| 193 | + } #?????? |
|
| 194 | + $d = 'decompiler_' . $p->type; |
|
| 195 | + $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false; |
|
| 196 | + // Forcer le champ etendu si son source (pas les reecritures) |
|
| 197 | + // contenait des args et s'il est suivi d'espaces, |
|
| 198 | + // le champ simple les eliminant est un bug helas perenne. |
|
| 199 | + |
|
| 200 | + if ($next |
|
| 201 | + and ($next->type == 'texte') |
|
| 202 | + and $p->type == 'champ' |
|
| 203 | + and !$p->apres |
|
| 204 | + and !$p->avant |
|
| 205 | + and $p->fonctions |
|
| 206 | + ) { |
|
| 207 | + $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
|
| 208 | + if ($n) { |
|
| 209 | + $champ = new Texte; |
|
| 210 | + $champ->texte = substr($next->texte, 0, $n); |
|
| 211 | + $champ->ligne = $p->ligne; |
|
| 212 | + $p->apres = array($champ); |
|
| 213 | + $next->texte = substr($next->texte, $n); |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
|
| 217 | + |
|
| 218 | + } |
|
| 219 | + $f = 'format_suite_' . $fmt; |
|
| 220 | + |
|
| 221 | + return $f($contenu); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') { |
| 225 | - if (!include_spip('public/format_' . $fmt)) { |
|
| 226 | - return "'$fmt'?"; |
|
| 227 | - } |
|
| 228 | - $f = 'decompiler_' . $quoi; |
|
| 225 | + if (!include_spip('public/format_' . $fmt)) { |
|
| 226 | + return "'$fmt'?"; |
|
| 227 | + } |
|
| 228 | + $f = 'decompiler_' . $quoi; |
|
| 229 | 229 | |
| 230 | - return $f($liste, $fmt, $prof); |
|
| 230 | + return $f($liste, $fmt, $prof); |
|
| 231 | 231 | } |
@@ -26,11 +26,10 @@ discard block |
||
| 26 | 26 | $postaff = decompiler_($struct->postaff, $fmt, $prof); |
| 27 | 27 | |
| 28 | 28 | $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
| 29 | - $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 30 | - $struct->table_optionnelle); |
|
| 29 | + $type .= ($struct->type_requete ? $struct->type_requete : $struct->table_optionnelle); |
|
| 31 | 30 | |
| 32 | 31 | if ($struct->jointures_explicites) { |
| 33 | - $type .= " " . $struct->jointures_explicites; |
|
| 32 | + $type .= " ".$struct->jointures_explicites; |
|
| 34 | 33 | } |
| 35 | 34 | if ($struct->table_optionnelle) { |
| 36 | 35 | $type .= "?"; |
@@ -39,11 +38,11 @@ discard block |
||
| 39 | 38 | |
| 40 | 39 | $crit = $struct->param; |
| 41 | 40 | if ($crit and !is_array($crit[0])) { |
| 42 | - $type = strtolower($type) . array_shift($crit); |
|
| 41 | + $type = strtolower($type).array_shift($crit); |
|
| 43 | 42 | } |
| 44 | 43 | $crit = decompiler_criteres($struct, $fmt, $prof); |
| 45 | 44 | |
| 46 | - $f = 'format_boucle_' . $fmt; |
|
| 45 | + $f = 'format_boucle_'.$fmt; |
|
| 47 | 46 | |
| 48 | 47 | return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof); |
| 49 | 48 | } |
@@ -56,21 +55,20 @@ discard block |
||
| 56 | 55 | $res[] = decompiler_($v, $fmt, $prof); |
| 57 | 56 | } |
| 58 | 57 | } |
| 59 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 60 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 61 | - $f = 'format_inclure_' . $fmt; |
|
| 58 | + $file = is_string($struct->texte) ? $struct->texte : decompiler_($struct->texte, $fmt, $prof); |
|
| 59 | + $f = 'format_inclure_'.$fmt; |
|
| 62 | 60 | |
| 63 | 61 | return $f($file, $res, $prof); |
| 64 | 62 | } |
| 65 | 63 | |
| 66 | 64 | function decompiler_texte($struct, $fmt = '', $prof = 0) { |
| 67 | - $f = 'format_texte_' . $fmt; |
|
| 65 | + $f = 'format_texte_'.$fmt; |
|
| 68 | 66 | |
| 69 | 67 | return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
| 70 | 68 | } |
| 71 | 69 | |
| 72 | 70 | function decompiler_polyglotte($struct, $fmt = '', $prof = 0) { |
| 73 | - $f = 'format_polyglotte_' . $fmt; |
|
| 71 | + $f = 'format_polyglotte_'.$fmt; |
|
| 74 | 72 | |
| 75 | 73 | return $f($struct->traductions, $prof); |
| 76 | 74 | } |
@@ -83,7 +81,7 @@ discard block |
||
| 83 | 81 | |
| 84 | 82 | $filtres = decompiler_liste($struct->param, $fmt, $prof); |
| 85 | 83 | |
| 86 | - $f = 'format_idiome_' . $fmt; |
|
| 84 | + $f = 'format_idiome_'.$fmt; |
|
| 87 | 85 | |
| 88 | 86 | return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
| 89 | 87 | } |
@@ -98,7 +96,7 @@ discard block |
||
| 98 | 96 | } |
| 99 | 97 | $filtres = decompiler_liste($p, $fmt, $prof); |
| 100 | 98 | } |
| 101 | - $f = 'format_champ_' . $fmt; |
|
| 99 | + $f = 'format_champ_'.$fmt; |
|
| 102 | 100 | |
| 103 | 101 | return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
| 104 | 102 | } |
@@ -107,7 +105,7 @@ discard block |
||
| 107 | 105 | if (!is_array($sources)) { |
| 108 | 106 | return ''; |
| 109 | 107 | } |
| 110 | - $f = 'format_liste_' . $fmt; |
|
| 108 | + $f = 'format_liste_'.$fmt; |
|
| 111 | 109 | $res = ''; |
| 112 | 110 | foreach ($sources as $arg) { |
| 113 | 111 | if (!is_array($arg)) { |
@@ -123,7 +121,7 @@ discard block |
||
| 123 | 121 | and (strlen($v[0]->apres) == 1) |
| 124 | 122 | and $v[0]->apres == $v[0]->avant |
| 125 | 123 | ) { |
| 126 | - $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 124 | + $args[] = $v[0]->avant.$v[0]->texte.$v[0]->apres; |
|
| 127 | 125 | } else { |
| 128 | 126 | $args[] = decompiler_($v, $fmt, 0 - $prof); |
| 129 | 127 | } |
@@ -146,7 +144,7 @@ discard block |
||
| 146 | 144 | return ''; |
| 147 | 145 | } |
| 148 | 146 | $res = ''; |
| 149 | - $f = 'format_critere_' . $fmt; |
|
| 147 | + $f = 'format_critere_'.$fmt; |
|
| 150 | 148 | foreach ($sources as $crit) { |
| 151 | 149 | if (!is_array($crit)) { |
| 152 | 150 | continue; |
@@ -158,12 +156,12 @@ discard block |
||
| 158 | 156 | and $v[0]->type == 'texte' |
| 159 | 157 | and $v[0]->apres |
| 160 | 158 | ) { |
| 161 | - $args[] = array(array('texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 159 | + $args[] = array(array('texte', ($v[0]->apres.$v[0]->texte.$v[0]->apres))); |
|
| 162 | 160 | } else { |
| 163 | 161 | $res2 = array(); |
| 164 | 162 | foreach ($v as $k => $p) { |
| 165 | 163 | if (isset($p->type) |
| 166 | - and function_exists($d = 'decompiler_' . $p->type) |
|
| 164 | + and function_exists($d = 'decompiler_'.$p->type) |
|
| 167 | 165 | ) { |
| 168 | 166 | $r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]); |
| 169 | 167 | $res2[] = array($p->type, $r); |
@@ -191,7 +189,7 @@ discard block |
||
| 191 | 189 | if (!isset($p->type)) { |
| 192 | 190 | continue; |
| 193 | 191 | } #?????? |
| 194 | - $d = 'decompiler_' . $p->type; |
|
| 192 | + $d = 'decompiler_'.$p->type; |
|
| 195 | 193 | $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false; |
| 196 | 194 | // Forcer le champ etendu si son source (pas les reecritures) |
| 197 | 195 | // contenait des args et s'il est suivi d'espaces, |
@@ -216,16 +214,16 @@ discard block |
||
| 216 | 214 | $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
| 217 | 215 | |
| 218 | 216 | } |
| 219 | - $f = 'format_suite_' . $fmt; |
|
| 217 | + $f = 'format_suite_'.$fmt; |
|
| 220 | 218 | |
| 221 | 219 | return $f($contenu); |
| 222 | 220 | } |
| 223 | 221 | |
| 224 | 222 | function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') { |
| 225 | - if (!include_spip('public/format_' . $fmt)) { |
|
| 223 | + if (!include_spip('public/format_'.$fmt)) { |
|
| 226 | 224 | return "'$fmt'?"; |
| 227 | 225 | } |
| 228 | - $f = 'decompiler_' . $quoi; |
|
| 226 | + $f = 'decompiler_'.$quoi; |
|
| 229 | 227 | |
| 230 | 228 | return $f($liste, $fmt, $prof); |
| 231 | 229 | } |
@@ -20,20 +20,20 @@ |
||
| 20 | 20 | $var_auth = $auth(); |
| 21 | 21 | |
| 22 | 22 | if ($var_auth !== '') { |
| 23 | - if (!is_int($var_auth)) { |
|
| 24 | - // si l'authentifie' n'a pas acces a l'espace de redac |
|
| 25 | - // c'est qu'on voulait forcer sa reconnaissance en tant que visiteur. |
|
| 26 | - // On reexecute pour deboucher sur le include public. |
|
| 27 | - // autrement on insiste |
|
| 28 | - if (is_array($var_auth)) { |
|
| 29 | - $var_auth = '../?' . $_SERVER['QUERY_STRING']; |
|
| 30 | - spip_setcookie('spip_session', $_COOKIE['spip_session'], [ |
|
| 31 | - 'expires' => time() + 3600 * 24 * 14 |
|
| 32 | - ]); |
|
| 33 | - } |
|
| 34 | - include_spip('inc/headers'); |
|
| 35 | - redirige_formulaire($var_auth); |
|
| 36 | - } |
|
| 23 | + if (!is_int($var_auth)) { |
|
| 24 | + // si l'authentifie' n'a pas acces a l'espace de redac |
|
| 25 | + // c'est qu'on voulait forcer sa reconnaissance en tant que visiteur. |
|
| 26 | + // On reexecute pour deboucher sur le include public. |
|
| 27 | + // autrement on insiste |
|
| 28 | + if (is_array($var_auth)) { |
|
| 29 | + $var_auth = '../?' . $_SERVER['QUERY_STRING']; |
|
| 30 | + spip_setcookie('spip_session', $_COOKIE['spip_session'], [ |
|
| 31 | + 'expires' => time() + 3600 * 24 * 14 |
|
| 32 | + ]); |
|
| 33 | + } |
|
| 34 | + include_spip('inc/headers'); |
|
| 35 | + redirige_formulaire($var_auth); |
|
| 36 | + } |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // En somme, est prive' ce qui est publiquement nomme'... |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | // On reexecute pour deboucher sur le include public. |
| 27 | 27 | // autrement on insiste |
| 28 | 28 | if (is_array($var_auth)) { |
| 29 | - $var_auth = '../?' . $_SERVER['QUERY_STRING']; |
|
| 29 | + $var_auth = '../?'.$_SERVER['QUERY_STRING']; |
|
| 30 | 30 | spip_setcookie('spip_session', $_COOKIE['spip_session'], [ |
| 31 | 31 | 'expires' => time() + 3600 * 24 * 14 |
| 32 | 32 | ]); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | * @return bool|null|void |
| 41 | 41 | */ |
| 42 | 42 | function inc_session_dist($auteur = false) { |
| 43 | - if (is_numeric($auteur)) { |
|
| 44 | - return supprimer_sessions($auteur, $auteur > 0); |
|
| 45 | - } else { |
|
| 46 | - if (is_array($auteur)) { |
|
| 47 | - return ajouter_session($auteur); |
|
| 48 | - } else { |
|
| 49 | - return verifier_session($auteur); |
|
| 50 | - } |
|
| 51 | - } |
|
| 43 | + if (is_numeric($auteur)) { |
|
| 44 | + return supprimer_sessions($auteur, $auteur > 0); |
|
| 45 | + } else { |
|
| 46 | + if (is_array($auteur)) { |
|
| 47 | + return ajouter_session($auteur); |
|
| 48 | + } else { |
|
| 49 | + return verifier_session($auteur); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -77,36 +77,36 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function supprimer_sessions($id_auteur, $toutes = true, $actives = true) { |
| 79 | 79 | |
| 80 | - $nb_files = 0; |
|
| 81 | - $nb_max_files = (defined('_MAX_NB_SESSIONS_OUVERTES') ? _MAX_NB_SESSIONS_OUVERTES : 1000); |
|
| 82 | - spip_log("supprimer sessions auteur $id_auteur", "session"); |
|
| 83 | - if ($toutes or $id_auteur !== $GLOBALS['visiteur_session']['id_auteur']) { |
|
| 84 | - if ($dir = opendir(_DIR_SESSIONS)) { |
|
| 85 | - $t = $_SERVER['REQUEST_TIME'] - (4*_RENOUVELLE_ALEA); // 48h par defaut |
|
| 86 | - $t_short = $_SERVER['REQUEST_TIME'] - max(_RENOUVELLE_ALEA/4,3*3600); // 3h par defaut |
|
| 87 | - $t = time() - (4 * _RENOUVELLE_ALEA); |
|
| 88 | - while (($f = readdir($dir)) !== false) { |
|
| 89 | - $nb_files++; |
|
| 90 | - if (preg_match(",^[^\d-]*(-?\d+)_\w{32}\.php[3]?$,", $f, $regs)) { |
|
| 91 | - $f = _DIR_SESSIONS . $f; |
|
| 92 | - if (($actives and $regs[1] == $id_auteur) or ($t > filemtime($f))) { |
|
| 93 | - spip_unlink($f); |
|
| 94 | - } |
|
| 95 | - // si il y a trop de sessions ouvertes, on purge les sessions anonymes de plus de 3H |
|
| 96 | - // cf http://core.spip.org/issues/3276 |
|
| 97 | - elseif ($nb_files>$nb_max_files and !intval($regs[1]) and ($t_short > filemtime($f))) { |
|
| 98 | - spip_unlink($f); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - } else { |
|
| 104 | - verifier_session(); |
|
| 105 | - spip_unlink(fichier_session('alea_ephemere', true)); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // forcer le recalcul de la session courante |
|
| 109 | - spip_session(true); |
|
| 80 | + $nb_files = 0; |
|
| 81 | + $nb_max_files = (defined('_MAX_NB_SESSIONS_OUVERTES') ? _MAX_NB_SESSIONS_OUVERTES : 1000); |
|
| 82 | + spip_log("supprimer sessions auteur $id_auteur", "session"); |
|
| 83 | + if ($toutes or $id_auteur !== $GLOBALS['visiteur_session']['id_auteur']) { |
|
| 84 | + if ($dir = opendir(_DIR_SESSIONS)) { |
|
| 85 | + $t = $_SERVER['REQUEST_TIME'] - (4*_RENOUVELLE_ALEA); // 48h par defaut |
|
| 86 | + $t_short = $_SERVER['REQUEST_TIME'] - max(_RENOUVELLE_ALEA/4,3*3600); // 3h par defaut |
|
| 87 | + $t = time() - (4 * _RENOUVELLE_ALEA); |
|
| 88 | + while (($f = readdir($dir)) !== false) { |
|
| 89 | + $nb_files++; |
|
| 90 | + if (preg_match(",^[^\d-]*(-?\d+)_\w{32}\.php[3]?$,", $f, $regs)) { |
|
| 91 | + $f = _DIR_SESSIONS . $f; |
|
| 92 | + if (($actives and $regs[1] == $id_auteur) or ($t > filemtime($f))) { |
|
| 93 | + spip_unlink($f); |
|
| 94 | + } |
|
| 95 | + // si il y a trop de sessions ouvertes, on purge les sessions anonymes de plus de 3H |
|
| 96 | + // cf http://core.spip.org/issues/3276 |
|
| 97 | + elseif ($nb_files>$nb_max_files and !intval($regs[1]) and ($t_short > filemtime($f))) { |
|
| 98 | + spip_unlink($f); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + } else { |
|
| 104 | + verifier_session(); |
|
| 105 | + spip_unlink(fichier_session('alea_ephemere', true)); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // forcer le recalcul de la session courante |
|
| 109 | + spip_session(true); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -124,122 +124,122 @@ discard block |
||
| 124 | 124 | * @return bool|string |
| 125 | 125 | */ |
| 126 | 126 | function ajouter_session($auteur) { |
| 127 | - // Si le client a deja une session valide pour son id_auteur |
|
| 128 | - // on conserve le meme fichier |
|
| 129 | - |
|
| 130 | - // Attention un visiteur peut avoir une session et un id=0, |
|
| 131 | - // => ne pas melanger les sessions des differents visiteurs |
|
| 132 | - $id_auteur = isset($auteur['id_auteur']) ? intval($auteur['id_auteur']) : 0; |
|
| 133 | - |
|
| 134 | - // Si ce n'est pas un inscrit (les inscrits ont toujours des choses en session) |
|
| 135 | - // on va vérifier s'il y a vraiment des choses à écrire |
|
| 136 | - if (!$id_auteur) { |
|
| 137 | - // On supprime les données de base pour voir le contenu réel de la session |
|
| 138 | - $auteur_verif = $auteur; |
|
| 139 | - if (isset($auteur_verif['id_auteur'])) { |
|
| 140 | - unset($auteur_verif['id_auteur']); |
|
| 141 | - } |
|
| 142 | - if (isset($auteur_verif['hash_env'])) { |
|
| 143 | - unset($auteur_verif['hash_env']); |
|
| 144 | - } |
|
| 145 | - if (isset($auteur_verif['ip_change'])) { |
|
| 146 | - unset($auteur_verif['ip_change']); |
|
| 147 | - } |
|
| 148 | - if (isset($auteur_verif['date_session'])) { |
|
| 149 | - unset($auteur_verif['date_session']); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // Les variables vraiment nulle ne sont pas à prendre en compte non plus |
|
| 153 | - foreach ($auteur_verif as $variable => $valeur) { |
|
| 154 | - if ($valeur === null) { |
|
| 155 | - unset($auteur_verif[$variable]); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - // Si après ça la session est vide alors on supprime l'éventuel fichier et on arrête là |
|
| 160 | - if (!$auteur_verif) { |
|
| 161 | - if (isset($_COOKIE['spip_session']) and isset($_SESSION[$_COOKIE['spip_session']])) { |
|
| 162 | - unset($_SESSION[$_COOKIE['spip_session']]); |
|
| 163 | - } |
|
| 164 | - if (isset($_COOKIE['spip_session'])) { |
|
| 165 | - unset($_COOKIE['spip_session']); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - return false; |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - if (!isset($_COOKIE['spip_session']) |
|
| 173 | - or !preg_match(',^' . $id_auteur . '_,', $_COOKIE['spip_session']) |
|
| 174 | - ) { |
|
| 175 | - $_COOKIE['spip_session'] = $id_auteur . '_' . md5(uniqid(rand(), true)); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // Maintenant on sait qu'on a des choses à écrire |
|
| 179 | - // On s'assure d'avoir au moins ces valeurs |
|
| 180 | - $auteur['id_auteur'] = $id_auteur; |
|
| 181 | - if (!isset($auteur['hash_env'])) { |
|
| 182 | - $auteur['hash_env'] = hash_env(); |
|
| 183 | - } |
|
| 184 | - if (!isset($auteur['ip_change'])) { |
|
| 185 | - $auteur['ip_change'] = false; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - if (!isset($auteur['date_session'])) { |
|
| 189 | - $auteur['date_session'] = time(); |
|
| 190 | - } |
|
| 191 | - if (isset($auteur['prefs']) |
|
| 192 | - and is_string($auteur['prefs']) |
|
| 193 | - and $prefs = @unserialize($auteur['prefs'])) { |
|
| 194 | - $auteur['prefs'] = $prefs; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $fichier_session = ""; |
|
| 198 | - |
|
| 199 | - // les sessions anonymes sont stockees dans $_SESSION |
|
| 200 | - if (!$id_auteur) { |
|
| 201 | - spip_php_session_start(); |
|
| 202 | - $_SESSION[$_COOKIE['spip_session']] = preparer_ecriture_session($auteur); |
|
| 203 | - } else { |
|
| 204 | - $fichier_session = fichier_session('alea_ephemere'); |
|
| 205 | - if (!ecrire_fichier_session($fichier_session, $auteur)) { |
|
| 206 | - spip_log('Echec ecriture fichier session ' . $fichier_session, "session" . _LOG_HS); |
|
| 207 | - include_spip('inc/minipres'); |
|
| 208 | - echo minipres(); |
|
| 209 | - exit; |
|
| 210 | - } |
|
| 211 | - // verifier et limiter le nombre maxi de sessions |
|
| 212 | - // https://core.spip.net/issues/3807 |
|
| 213 | - lister_sessions_auteur($id_auteur); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - // poser le cookie de session SPIP |
|
| 217 | - include_spip('inc/cookie'); |
|
| 218 | - $duree = definir_duree_cookie_session($auteur); |
|
| 219 | - spip_setcookie( 'spip_session', $_COOKIE['spip_session'], [ |
|
| 220 | - 'expires' => time() + $duree |
|
| 221 | - ]); |
|
| 222 | - spip_log("ajoute session $fichier_session cookie $duree", "session"); |
|
| 223 | - |
|
| 224 | - // Si on est admin, poser le cookie de correspondance |
|
| 225 | - if (!function_exists('autoriser')) { |
|
| 226 | - include_spip('inc/autoriser'); |
|
| 227 | - } |
|
| 228 | - if (autoriser('ecrire','','',$auteur) and _DUREE_COOKIE_ADMIN) { |
|
| 229 | - spip_setcookie('spip_admin', '@' . ($auteur['email'] ?: $auteur['login']), [ |
|
| 230 | - 'expires' => time() + max(_DUREE_COOKIE_ADMIN, $duree) |
|
| 231 | - ]); |
|
| 232 | - } // sinon le supprimer ... |
|
| 233 | - else { |
|
| 234 | - spip_setcookie('spip_admin', '', [ |
|
| 235 | - 'expires' => 1 |
|
| 236 | - ]); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - # on en profite pour purger les vieilles sessions anonymes abandonnees |
|
| 240 | - # supprimer_sessions(0, true, false); |
|
| 241 | - |
|
| 242 | - return $_COOKIE['spip_session']; |
|
| 127 | + // Si le client a deja une session valide pour son id_auteur |
|
| 128 | + // on conserve le meme fichier |
|
| 129 | + |
|
| 130 | + // Attention un visiteur peut avoir une session et un id=0, |
|
| 131 | + // => ne pas melanger les sessions des differents visiteurs |
|
| 132 | + $id_auteur = isset($auteur['id_auteur']) ? intval($auteur['id_auteur']) : 0; |
|
| 133 | + |
|
| 134 | + // Si ce n'est pas un inscrit (les inscrits ont toujours des choses en session) |
|
| 135 | + // on va vérifier s'il y a vraiment des choses à écrire |
|
| 136 | + if (!$id_auteur) { |
|
| 137 | + // On supprime les données de base pour voir le contenu réel de la session |
|
| 138 | + $auteur_verif = $auteur; |
|
| 139 | + if (isset($auteur_verif['id_auteur'])) { |
|
| 140 | + unset($auteur_verif['id_auteur']); |
|
| 141 | + } |
|
| 142 | + if (isset($auteur_verif['hash_env'])) { |
|
| 143 | + unset($auteur_verif['hash_env']); |
|
| 144 | + } |
|
| 145 | + if (isset($auteur_verif['ip_change'])) { |
|
| 146 | + unset($auteur_verif['ip_change']); |
|
| 147 | + } |
|
| 148 | + if (isset($auteur_verif['date_session'])) { |
|
| 149 | + unset($auteur_verif['date_session']); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // Les variables vraiment nulle ne sont pas à prendre en compte non plus |
|
| 153 | + foreach ($auteur_verif as $variable => $valeur) { |
|
| 154 | + if ($valeur === null) { |
|
| 155 | + unset($auteur_verif[$variable]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + // Si après ça la session est vide alors on supprime l'éventuel fichier et on arrête là |
|
| 160 | + if (!$auteur_verif) { |
|
| 161 | + if (isset($_COOKIE['spip_session']) and isset($_SESSION[$_COOKIE['spip_session']])) { |
|
| 162 | + unset($_SESSION[$_COOKIE['spip_session']]); |
|
| 163 | + } |
|
| 164 | + if (isset($_COOKIE['spip_session'])) { |
|
| 165 | + unset($_COOKIE['spip_session']); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + return false; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + if (!isset($_COOKIE['spip_session']) |
|
| 173 | + or !preg_match(',^' . $id_auteur . '_,', $_COOKIE['spip_session']) |
|
| 174 | + ) { |
|
| 175 | + $_COOKIE['spip_session'] = $id_auteur . '_' . md5(uniqid(rand(), true)); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // Maintenant on sait qu'on a des choses à écrire |
|
| 179 | + // On s'assure d'avoir au moins ces valeurs |
|
| 180 | + $auteur['id_auteur'] = $id_auteur; |
|
| 181 | + if (!isset($auteur['hash_env'])) { |
|
| 182 | + $auteur['hash_env'] = hash_env(); |
|
| 183 | + } |
|
| 184 | + if (!isset($auteur['ip_change'])) { |
|
| 185 | + $auteur['ip_change'] = false; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + if (!isset($auteur['date_session'])) { |
|
| 189 | + $auteur['date_session'] = time(); |
|
| 190 | + } |
|
| 191 | + if (isset($auteur['prefs']) |
|
| 192 | + and is_string($auteur['prefs']) |
|
| 193 | + and $prefs = @unserialize($auteur['prefs'])) { |
|
| 194 | + $auteur['prefs'] = $prefs; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $fichier_session = ""; |
|
| 198 | + |
|
| 199 | + // les sessions anonymes sont stockees dans $_SESSION |
|
| 200 | + if (!$id_auteur) { |
|
| 201 | + spip_php_session_start(); |
|
| 202 | + $_SESSION[$_COOKIE['spip_session']] = preparer_ecriture_session($auteur); |
|
| 203 | + } else { |
|
| 204 | + $fichier_session = fichier_session('alea_ephemere'); |
|
| 205 | + if (!ecrire_fichier_session($fichier_session, $auteur)) { |
|
| 206 | + spip_log('Echec ecriture fichier session ' . $fichier_session, "session" . _LOG_HS); |
|
| 207 | + include_spip('inc/minipres'); |
|
| 208 | + echo minipres(); |
|
| 209 | + exit; |
|
| 210 | + } |
|
| 211 | + // verifier et limiter le nombre maxi de sessions |
|
| 212 | + // https://core.spip.net/issues/3807 |
|
| 213 | + lister_sessions_auteur($id_auteur); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + // poser le cookie de session SPIP |
|
| 217 | + include_spip('inc/cookie'); |
|
| 218 | + $duree = definir_duree_cookie_session($auteur); |
|
| 219 | + spip_setcookie( 'spip_session', $_COOKIE['spip_session'], [ |
|
| 220 | + 'expires' => time() + $duree |
|
| 221 | + ]); |
|
| 222 | + spip_log("ajoute session $fichier_session cookie $duree", "session"); |
|
| 223 | + |
|
| 224 | + // Si on est admin, poser le cookie de correspondance |
|
| 225 | + if (!function_exists('autoriser')) { |
|
| 226 | + include_spip('inc/autoriser'); |
|
| 227 | + } |
|
| 228 | + if (autoriser('ecrire','','',$auteur) and _DUREE_COOKIE_ADMIN) { |
|
| 229 | + spip_setcookie('spip_admin', '@' . ($auteur['email'] ?: $auteur['login']), [ |
|
| 230 | + 'expires' => time() + max(_DUREE_COOKIE_ADMIN, $duree) |
|
| 231 | + ]); |
|
| 232 | + } // sinon le supprimer ... |
|
| 233 | + else { |
|
| 234 | + spip_setcookie('spip_admin', '', [ |
|
| 235 | + 'expires' => 1 |
|
| 236 | + ]); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + # on en profite pour purger les vieilles sessions anonymes abandonnees |
|
| 240 | + # supprimer_sessions(0, true, false); |
|
| 241 | + |
|
| 242 | + return $_COOKIE['spip_session']; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -259,15 +259,15 @@ discard block |
||
| 259 | 259 | * Durée en secondes |
| 260 | 260 | **/ |
| 261 | 261 | function definir_duree_cookie_session($auteur) { |
| 262 | - $coef = 2; |
|
| 263 | - if (isset($auteur['cookie'])) { |
|
| 264 | - if (is_numeric($auteur['cookie'])) { |
|
| 265 | - $coef = $auteur['cookie']; |
|
| 266 | - } else { |
|
| 267 | - $coef = 20; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - return (int)(_RENOUVELLE_ALEA * $coef); |
|
| 262 | + $coef = 2; |
|
| 263 | + if (isset($auteur['cookie'])) { |
|
| 264 | + if (is_numeric($auteur['cookie'])) { |
|
| 265 | + $coef = $auteur['cookie']; |
|
| 266 | + } else { |
|
| 267 | + $coef = 20; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + return (int)(_RENOUVELLE_ALEA * $coef); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -287,90 +287,90 @@ discard block |
||
| 287 | 287 | * @return bool|int|null |
| 288 | 288 | */ |
| 289 | 289 | function verifier_session($change = false) { |
| 290 | - // si pas de cookie, c'est fichu |
|
| 291 | - if (!isset($_COOKIE['spip_session'])) { |
|
| 292 | - return false; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - $fichier_session = ""; |
|
| 296 | - |
|
| 297 | - // est-ce une session anonyme ? |
|
| 298 | - if (!intval($_COOKIE['spip_session'])) { |
|
| 299 | - spip_php_session_start(); |
|
| 300 | - if (!isset($_SESSION[$_COOKIE['spip_session']]) or !is_array($_SESSION[$_COOKIE['spip_session']])) { |
|
| 301 | - return false; |
|
| 302 | - } |
|
| 303 | - $GLOBALS['visiteur_session'] = $_SESSION[$_COOKIE['spip_session']]; |
|
| 304 | - } else { |
|
| 305 | - // Tester avec alea courant |
|
| 306 | - $fichier_session = fichier_session('alea_ephemere', true); |
|
| 307 | - if ($fichier_session and @file_exists($fichier_session)) { |
|
| 308 | - include($fichier_session); |
|
| 309 | - } else { |
|
| 310 | - // Sinon, tester avec alea precedent |
|
| 311 | - $fichier_session = fichier_session('alea_ephemere_ancien', true); |
|
| 312 | - if (!$fichier_session or !@file_exists($fichier_session)) { |
|
| 313 | - return false; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - // Renouveler la session avec l'alea courant |
|
| 317 | - include($fichier_session); |
|
| 318 | - spip_log('renouvelle session ' . $GLOBALS['visiteur_session']['id_auteur'], "session"); |
|
| 319 | - spip_unlink($fichier_session); |
|
| 320 | - ajouter_session($GLOBALS['visiteur_session']); |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - // Compatibilite ascendante : auteur_session est visiteur_session si |
|
| 325 | - // c'est un auteur SPIP authentifie (tandis qu'un visiteur_session peut |
|
| 326 | - // n'etre qu'identifie, sans aucune authentification). |
|
| 327 | - |
|
| 328 | - if (isset($GLOBALS['visiteur_session']['id_auteur']) and $GLOBALS['visiteur_session']['id_auteur']) { |
|
| 329 | - $GLOBALS['auteur_session'] = &$GLOBALS['visiteur_session']; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - |
|
| 333 | - // Si l'adresse IP change, inc/presentation mettra une balise image |
|
| 334 | - // avec un URL de rappel demandant a changer le nom de la session. |
|
| 335 | - // Seul celui qui a l'IP d'origine est rejoue |
|
| 336 | - // ainsi un eventuel voleur de cookie ne pourrait pas deconnecter |
|
| 337 | - // sa victime, mais se ferait deconnecter par elle. |
|
| 338 | - if (hash_env() != $GLOBALS['visiteur_session']['hash_env']) { |
|
| 339 | - if (!$GLOBALS['visiteur_session']['ip_change']) { |
|
| 340 | - define('_SESSION_REJOUER', true); |
|
| 341 | - $GLOBALS['visiteur_session']['ip_change'] = true; |
|
| 342 | - ajouter_session($GLOBALS['visiteur_session']); |
|
| 343 | - } else { |
|
| 344 | - if ($change) { |
|
| 345 | - spip_log("session non rejouee, vol de cookie ?", "session"); |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - } else { |
|
| 349 | - if ($change) { |
|
| 350 | - spip_log("rejoue session $fichier_session " . $_COOKIE['spip_session'], "session"); |
|
| 351 | - if ($fichier_session) { |
|
| 352 | - spip_unlink($fichier_session); |
|
| 353 | - } |
|
| 354 | - $GLOBALS['visiteur_session']['ip_change'] = false; |
|
| 355 | - unset($_COOKIE['spip_session']); |
|
| 356 | - ajouter_session($GLOBALS['visiteur_session']); |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - // Si la session a ete initiee il y a trop longtemps, elle est annulee |
|
| 361 | - if (isset($GLOBALS['visiteur_session']) |
|
| 362 | - and defined('_AGE_SESSION_MAX') |
|
| 363 | - and _AGE_SESSION_MAX > 0 |
|
| 364 | - and time() - @$GLOBALS['visiteur_session']['date_session'] > _AGE_SESSION_MAX |
|
| 365 | - ) { |
|
| 366 | - unset($GLOBALS['visiteur_session']); |
|
| 367 | - |
|
| 368 | - return false; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - return is_numeric($GLOBALS['visiteur_session']['id_auteur']) |
|
| 372 | - ? $GLOBALS['visiteur_session']['id_auteur'] |
|
| 373 | - : null; |
|
| 290 | + // si pas de cookie, c'est fichu |
|
| 291 | + if (!isset($_COOKIE['spip_session'])) { |
|
| 292 | + return false; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + $fichier_session = ""; |
|
| 296 | + |
|
| 297 | + // est-ce une session anonyme ? |
|
| 298 | + if (!intval($_COOKIE['spip_session'])) { |
|
| 299 | + spip_php_session_start(); |
|
| 300 | + if (!isset($_SESSION[$_COOKIE['spip_session']]) or !is_array($_SESSION[$_COOKIE['spip_session']])) { |
|
| 301 | + return false; |
|
| 302 | + } |
|
| 303 | + $GLOBALS['visiteur_session'] = $_SESSION[$_COOKIE['spip_session']]; |
|
| 304 | + } else { |
|
| 305 | + // Tester avec alea courant |
|
| 306 | + $fichier_session = fichier_session('alea_ephemere', true); |
|
| 307 | + if ($fichier_session and @file_exists($fichier_session)) { |
|
| 308 | + include($fichier_session); |
|
| 309 | + } else { |
|
| 310 | + // Sinon, tester avec alea precedent |
|
| 311 | + $fichier_session = fichier_session('alea_ephemere_ancien', true); |
|
| 312 | + if (!$fichier_session or !@file_exists($fichier_session)) { |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + // Renouveler la session avec l'alea courant |
|
| 317 | + include($fichier_session); |
|
| 318 | + spip_log('renouvelle session ' . $GLOBALS['visiteur_session']['id_auteur'], "session"); |
|
| 319 | + spip_unlink($fichier_session); |
|
| 320 | + ajouter_session($GLOBALS['visiteur_session']); |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + // Compatibilite ascendante : auteur_session est visiteur_session si |
|
| 325 | + // c'est un auteur SPIP authentifie (tandis qu'un visiteur_session peut |
|
| 326 | + // n'etre qu'identifie, sans aucune authentification). |
|
| 327 | + |
|
| 328 | + if (isset($GLOBALS['visiteur_session']['id_auteur']) and $GLOBALS['visiteur_session']['id_auteur']) { |
|
| 329 | + $GLOBALS['auteur_session'] = &$GLOBALS['visiteur_session']; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + |
|
| 333 | + // Si l'adresse IP change, inc/presentation mettra une balise image |
|
| 334 | + // avec un URL de rappel demandant a changer le nom de la session. |
|
| 335 | + // Seul celui qui a l'IP d'origine est rejoue |
|
| 336 | + // ainsi un eventuel voleur de cookie ne pourrait pas deconnecter |
|
| 337 | + // sa victime, mais se ferait deconnecter par elle. |
|
| 338 | + if (hash_env() != $GLOBALS['visiteur_session']['hash_env']) { |
|
| 339 | + if (!$GLOBALS['visiteur_session']['ip_change']) { |
|
| 340 | + define('_SESSION_REJOUER', true); |
|
| 341 | + $GLOBALS['visiteur_session']['ip_change'] = true; |
|
| 342 | + ajouter_session($GLOBALS['visiteur_session']); |
|
| 343 | + } else { |
|
| 344 | + if ($change) { |
|
| 345 | + spip_log("session non rejouee, vol de cookie ?", "session"); |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + } else { |
|
| 349 | + if ($change) { |
|
| 350 | + spip_log("rejoue session $fichier_session " . $_COOKIE['spip_session'], "session"); |
|
| 351 | + if ($fichier_session) { |
|
| 352 | + spip_unlink($fichier_session); |
|
| 353 | + } |
|
| 354 | + $GLOBALS['visiteur_session']['ip_change'] = false; |
|
| 355 | + unset($_COOKIE['spip_session']); |
|
| 356 | + ajouter_session($GLOBALS['visiteur_session']); |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + // Si la session a ete initiee il y a trop longtemps, elle est annulee |
|
| 361 | + if (isset($GLOBALS['visiteur_session']) |
|
| 362 | + and defined('_AGE_SESSION_MAX') |
|
| 363 | + and _AGE_SESSION_MAX > 0 |
|
| 364 | + and time() - @$GLOBALS['visiteur_session']['date_session'] > _AGE_SESSION_MAX |
|
| 365 | + ) { |
|
| 366 | + unset($GLOBALS['visiteur_session']); |
|
| 367 | + |
|
| 368 | + return false; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + return is_numeric($GLOBALS['visiteur_session']['id_auteur']) |
|
| 372 | + ? $GLOBALS['visiteur_session']['id_auteur'] |
|
| 373 | + : null; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | * Valeur, si trouvée, `null` sinon. |
| 386 | 386 | */ |
| 387 | 387 | function session_get($nom) { |
| 388 | - return isset($GLOBALS['visiteur_session'][$nom]) ? $GLOBALS['visiteur_session'][$nom] : null; |
|
| 388 | + return isset($GLOBALS['visiteur_session'][$nom]) ? $GLOBALS['visiteur_session'][$nom] : null; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | |
@@ -401,32 +401,32 @@ discard block |
||
| 401 | 401 | * @return void|array |
| 402 | 402 | */ |
| 403 | 403 | function session_set($nom, $val = null) { |
| 404 | - static $remove = array(); |
|
| 405 | - static $actualiser_sessions = false; |
|
| 406 | - if ($nom === false) { |
|
| 407 | - return $remove; |
|
| 408 | - } |
|
| 409 | - if (is_null($val)) { |
|
| 410 | - // rien a faire |
|
| 411 | - if (!isset($GLOBALS['visiteur_session'][$nom])) { |
|
| 412 | - return; |
|
| 413 | - } |
|
| 414 | - unset($GLOBALS['visiteur_session'][$nom]); |
|
| 415 | - $remove[] = $nom; |
|
| 416 | - } else { |
|
| 417 | - // On ajoute la valeur dans la globale |
|
| 418 | - $GLOBALS['visiteur_session'][$nom] = $val; |
|
| 419 | - if ($remove) { |
|
| 420 | - $remove = array_diff($remove, array($nom)); |
|
| 421 | - } |
|
| 422 | - } |
|
| 423 | - if (!$actualiser_sessions) { |
|
| 424 | - // il faut creer la session si on en a pas, la premiere fois |
|
| 425 | - ajouter_session($GLOBALS['visiteur_session']); |
|
| 426 | - // in register la fonction qui mettra a jour toutes les sessions en fin de hit |
|
| 427 | - register_shutdown_function('terminer_actualiser_sessions'); |
|
| 428 | - $actualiser_sessions = true; |
|
| 429 | - } |
|
| 404 | + static $remove = array(); |
|
| 405 | + static $actualiser_sessions = false; |
|
| 406 | + if ($nom === false) { |
|
| 407 | + return $remove; |
|
| 408 | + } |
|
| 409 | + if (is_null($val)) { |
|
| 410 | + // rien a faire |
|
| 411 | + if (!isset($GLOBALS['visiteur_session'][$nom])) { |
|
| 412 | + return; |
|
| 413 | + } |
|
| 414 | + unset($GLOBALS['visiteur_session'][$nom]); |
|
| 415 | + $remove[] = $nom; |
|
| 416 | + } else { |
|
| 417 | + // On ajoute la valeur dans la globale |
|
| 418 | + $GLOBALS['visiteur_session'][$nom] = $val; |
|
| 419 | + if ($remove) { |
|
| 420 | + $remove = array_diff($remove, array($nom)); |
|
| 421 | + } |
|
| 422 | + } |
|
| 423 | + if (!$actualiser_sessions) { |
|
| 424 | + // il faut creer la session si on en a pas, la premiere fois |
|
| 425 | + ajouter_session($GLOBALS['visiteur_session']); |
|
| 426 | + // in register la fonction qui mettra a jour toutes les sessions en fin de hit |
|
| 427 | + register_shutdown_function('terminer_actualiser_sessions'); |
|
| 428 | + $actualiser_sessions = true; |
|
| 429 | + } |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -435,12 +435,12 @@ discard block |
||
| 435 | 435 | * @uses actualiser_sessions() |
| 436 | 436 | */ |
| 437 | 437 | function terminer_actualiser_sessions() { |
| 438 | - // se remettre dans le dossier de travail au cas ou Apache a change |
|
| 439 | - chdir(_ROOT_CWD); |
|
| 440 | - // recuperer les variables a effacer |
|
| 441 | - $remove = session_set(false); |
|
| 442 | - // mettre a jour toutes les sessions |
|
| 443 | - actualiser_sessions($GLOBALS['visiteur_session'], $remove); |
|
| 438 | + // se remettre dans le dossier de travail au cas ou Apache a change |
|
| 439 | + chdir(_ROOT_CWD); |
|
| 440 | + // recuperer les variables a effacer |
|
| 441 | + $remove = session_set(false); |
|
| 442 | + // mettre a jour toutes les sessions |
|
| 443 | + actualiser_sessions($GLOBALS['visiteur_session'], $remove); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | |
@@ -465,82 +465,82 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function actualiser_sessions($auteur, $supprimer_cles = array()) { |
| 467 | 467 | |
| 468 | - $id_auteur = isset($auteur['id_auteur']) ? intval($auteur['id_auteur']) : 0; |
|
| 469 | - $id_auteur_courant = isset($GLOBALS['visiteur_session']['id_auteur']) ? intval($GLOBALS['visiteur_session']['id_auteur']) : 0; |
|
| 470 | - |
|
| 471 | - // si l'auteur est celui de la session courante, verifier/creer la session si besoin |
|
| 472 | - $fichier_session_courante = ""; |
|
| 473 | - if ($id_auteur == $id_auteur_courant) { |
|
| 474 | - $auteur = array_merge($GLOBALS['visiteur_session'], $auteur); |
|
| 475 | - ajouter_session($auteur); |
|
| 476 | - if ($id_auteur) { |
|
| 477 | - $fichier_session_courante = fichier_session('alea_ephemere'); |
|
| 478 | - } |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - // si session anonyme on ne fait rien d'autre ici : les sessions anonymes sont non partagees |
|
| 482 | - if (!$id_auteur) { |
|
| 483 | - return; |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - // les préférences sont désérialisées, toujours. |
|
| 487 | - // [fixme] Le champ 'prefs' sert aussi à l’inscription |
|
| 488 | - if (isset($auteur['prefs']) and is_string($auteur['prefs'])) { |
|
| 489 | - $auteur['prefs'] = @unserialize($auteur['prefs']); |
|
| 490 | - if (!is_array($auteur['prefs'])) { |
|
| 491 | - $auteur['prefs'] = []; |
|
| 492 | - } |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - // memoriser l'auteur courant (celui qui modifie la fiche) |
|
| 496 | - $sauve = $GLOBALS['visiteur_session']; |
|
| 497 | - |
|
| 498 | - // .. mettre a jour les sessions de l'auteur cible |
|
| 499 | - // attention au $ final pour ne pas risquer d'embarquer un .php.jeton temporaire |
|
| 500 | - // cree par une ecriture concurente d'une session (fichier atomique temporaire) |
|
| 501 | - $sessions = lister_sessions_auteur($id_auteur); |
|
| 502 | - |
|
| 503 | - // 1ere passe : lire et fusionner les sessions |
|
| 504 | - foreach ($sessions as $session) { |
|
| 505 | - $GLOBALS['visiteur_session'] = array(); |
|
| 506 | - // a pu etre supprime entre le preg initial et le moment ou l'on arrive la (concurrence) |
|
| 507 | - if ($session !== $fichier_session_courante |
|
| 508 | - and @file_exists($session) |
|
| 509 | - ) { |
|
| 510 | - include $session; # $GLOBALS['visiteur_session'] est alors l'auteur cible |
|
| 511 | - |
|
| 512 | - $auteur = array_merge($GLOBALS['visiteur_session'], $auteur); |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - // supprimer les eventuelles cles dont on ne veut plus |
|
| 517 | - foreach ($supprimer_cles as $cle) { |
|
| 518 | - unset($auteur[$cle]); |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - $auteur_session = preparer_ecriture_session($auteur); |
|
| 522 | - |
|
| 523 | - // seconde passe : ecrire les sessions qui ne sont pas a jour |
|
| 524 | - foreach ($sessions as $session) { |
|
| 525 | - $GLOBALS['visiteur_session'] = array(); |
|
| 526 | - // a pu etre supprime entre le preg initial et le moment ou l'on arrive la (concurrence) |
|
| 527 | - if (@file_exists($session)) { |
|
| 528 | - include $session; # $GLOBALS['visiteur_session'] est alors l'auteur cible |
|
| 529 | - |
|
| 530 | - // est-ce que cette session est a mettre a jour ? |
|
| 531 | - if ($auteur_session != $GLOBALS['visiteur_session']) { |
|
| 532 | - ecrire_fichier_session($session, $auteur); |
|
| 533 | - } |
|
| 534 | - } |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - if ($id_auteur == $id_auteur_courant) { |
|
| 538 | - $GLOBALS['visiteur_session'] = $auteur; |
|
| 539 | - $GLOBALS['auteur_session'] = &$GLOBALS['visiteur_session']; |
|
| 540 | - } else { |
|
| 541 | - // restaurer l'auteur courant |
|
| 542 | - $GLOBALS['visiteur_session'] = $sauve; |
|
| 543 | - } |
|
| 468 | + $id_auteur = isset($auteur['id_auteur']) ? intval($auteur['id_auteur']) : 0; |
|
| 469 | + $id_auteur_courant = isset($GLOBALS['visiteur_session']['id_auteur']) ? intval($GLOBALS['visiteur_session']['id_auteur']) : 0; |
|
| 470 | + |
|
| 471 | + // si l'auteur est celui de la session courante, verifier/creer la session si besoin |
|
| 472 | + $fichier_session_courante = ""; |
|
| 473 | + if ($id_auteur == $id_auteur_courant) { |
|
| 474 | + $auteur = array_merge($GLOBALS['visiteur_session'], $auteur); |
|
| 475 | + ajouter_session($auteur); |
|
| 476 | + if ($id_auteur) { |
|
| 477 | + $fichier_session_courante = fichier_session('alea_ephemere'); |
|
| 478 | + } |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + // si session anonyme on ne fait rien d'autre ici : les sessions anonymes sont non partagees |
|
| 482 | + if (!$id_auteur) { |
|
| 483 | + return; |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + // les préférences sont désérialisées, toujours. |
|
| 487 | + // [fixme] Le champ 'prefs' sert aussi à l’inscription |
|
| 488 | + if (isset($auteur['prefs']) and is_string($auteur['prefs'])) { |
|
| 489 | + $auteur['prefs'] = @unserialize($auteur['prefs']); |
|
| 490 | + if (!is_array($auteur['prefs'])) { |
|
| 491 | + $auteur['prefs'] = []; |
|
| 492 | + } |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + // memoriser l'auteur courant (celui qui modifie la fiche) |
|
| 496 | + $sauve = $GLOBALS['visiteur_session']; |
|
| 497 | + |
|
| 498 | + // .. mettre a jour les sessions de l'auteur cible |
|
| 499 | + // attention au $ final pour ne pas risquer d'embarquer un .php.jeton temporaire |
|
| 500 | + // cree par une ecriture concurente d'une session (fichier atomique temporaire) |
|
| 501 | + $sessions = lister_sessions_auteur($id_auteur); |
|
| 502 | + |
|
| 503 | + // 1ere passe : lire et fusionner les sessions |
|
| 504 | + foreach ($sessions as $session) { |
|
| 505 | + $GLOBALS['visiteur_session'] = array(); |
|
| 506 | + // a pu etre supprime entre le preg initial et le moment ou l'on arrive la (concurrence) |
|
| 507 | + if ($session !== $fichier_session_courante |
|
| 508 | + and @file_exists($session) |
|
| 509 | + ) { |
|
| 510 | + include $session; # $GLOBALS['visiteur_session'] est alors l'auteur cible |
|
| 511 | + |
|
| 512 | + $auteur = array_merge($GLOBALS['visiteur_session'], $auteur); |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + // supprimer les eventuelles cles dont on ne veut plus |
|
| 517 | + foreach ($supprimer_cles as $cle) { |
|
| 518 | + unset($auteur[$cle]); |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + $auteur_session = preparer_ecriture_session($auteur); |
|
| 522 | + |
|
| 523 | + // seconde passe : ecrire les sessions qui ne sont pas a jour |
|
| 524 | + foreach ($sessions as $session) { |
|
| 525 | + $GLOBALS['visiteur_session'] = array(); |
|
| 526 | + // a pu etre supprime entre le preg initial et le moment ou l'on arrive la (concurrence) |
|
| 527 | + if (@file_exists($session)) { |
|
| 528 | + include $session; # $GLOBALS['visiteur_session'] est alors l'auteur cible |
|
| 529 | + |
|
| 530 | + // est-ce que cette session est a mettre a jour ? |
|
| 531 | + if ($auteur_session != $GLOBALS['visiteur_session']) { |
|
| 532 | + ecrire_fichier_session($session, $auteur); |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + if ($id_auteur == $id_auteur_courant) { |
|
| 538 | + $GLOBALS['visiteur_session'] = $auteur; |
|
| 539 | + $GLOBALS['auteur_session'] = &$GLOBALS['visiteur_session']; |
|
| 540 | + } else { |
|
| 541 | + // restaurer l'auteur courant |
|
| 542 | + $GLOBALS['visiteur_session'] = $sauve; |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | 545 | } |
| 546 | 546 | |
@@ -555,46 +555,46 @@ discard block |
||
| 555 | 555 | */ |
| 556 | 556 | function lister_sessions_auteur($id_auteur, $nb_max = null) { |
| 557 | 557 | |
| 558 | - if (is_null($nb_max)) { |
|
| 559 | - if (!defined('_NB_SESSIONS_MAX')) { |
|
| 560 | - define('_NB_SESSIONS_MAX', 100); |
|
| 561 | - } |
|
| 562 | - $nb_max = _NB_SESSIONS_MAX; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - // liste des sessions |
|
| 566 | - $sessions = preg_files(_DIR_SESSIONS, '/' . $id_auteur . '_.*\.php$'); |
|
| 567 | - |
|
| 568 | - // si on en a plus que la limite, supprimer les plus vieilles |
|
| 569 | - // si ce ne sont pas des sessions anonymes car elles sont alors chacune differentes |
|
| 570 | - if ($id_auteur |
|
| 571 | - and count($sessions) > $nb_max) { |
|
| 572 | - |
|
| 573 | - // limiter le nombre de sessions ouvertes par un auteur |
|
| 574 | - // filemtime sur les sessions |
|
| 575 | - $sessions = array_flip($sessions); |
|
| 576 | - |
|
| 577 | - // 1ere passe : lire les filemtime |
|
| 578 | - foreach ($sessions as $session => $z) { |
|
| 579 | - if ($d = @filemtime($session) |
|
| 580 | - ) { |
|
| 581 | - $sessions[$session] = $d; |
|
| 582 | - } else { |
|
| 583 | - $sessions[$session] = 0; |
|
| 584 | - } |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - // les plus anciennes en premier |
|
| 588 | - asort($sessions); |
|
| 589 | - |
|
| 590 | - $sessions = array_keys($sessions); |
|
| 591 | - while (count($sessions) > $nb_max) { |
|
| 592 | - $session = array_shift($sessions); |
|
| 593 | - @unlink($session); |
|
| 594 | - } |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - return $sessions; |
|
| 558 | + if (is_null($nb_max)) { |
|
| 559 | + if (!defined('_NB_SESSIONS_MAX')) { |
|
| 560 | + define('_NB_SESSIONS_MAX', 100); |
|
| 561 | + } |
|
| 562 | + $nb_max = _NB_SESSIONS_MAX; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + // liste des sessions |
|
| 566 | + $sessions = preg_files(_DIR_SESSIONS, '/' . $id_auteur . '_.*\.php$'); |
|
| 567 | + |
|
| 568 | + // si on en a plus que la limite, supprimer les plus vieilles |
|
| 569 | + // si ce ne sont pas des sessions anonymes car elles sont alors chacune differentes |
|
| 570 | + if ($id_auteur |
|
| 571 | + and count($sessions) > $nb_max) { |
|
| 572 | + |
|
| 573 | + // limiter le nombre de sessions ouvertes par un auteur |
|
| 574 | + // filemtime sur les sessions |
|
| 575 | + $sessions = array_flip($sessions); |
|
| 576 | + |
|
| 577 | + // 1ere passe : lire les filemtime |
|
| 578 | + foreach ($sessions as $session => $z) { |
|
| 579 | + if ($d = @filemtime($session) |
|
| 580 | + ) { |
|
| 581 | + $sessions[$session] = $d; |
|
| 582 | + } else { |
|
| 583 | + $sessions[$session] = 0; |
|
| 584 | + } |
|
| 585 | + } |
|
| 586 | + |
|
| 587 | + // les plus anciennes en premier |
|
| 588 | + asort($sessions); |
|
| 589 | + |
|
| 590 | + $sessions = array_keys($sessions); |
|
| 591 | + while (count($sessions) > $nb_max) { |
|
| 592 | + $session = array_shift($sessions); |
|
| 593 | + @unlink($session); |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + return $sessions; |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | |
@@ -608,26 +608,26 @@ discard block |
||
| 608 | 608 | * @return array |
| 609 | 609 | */ |
| 610 | 610 | function preparer_ecriture_session($auteur) { |
| 611 | - $row = $auteur; |
|
| 612 | - |
|
| 613 | - // ne pas enregistrer ces elements de securite |
|
| 614 | - // dans le fichier de session |
|
| 615 | - unset($auteur['pass']); |
|
| 616 | - unset($auteur['htpass']); |
|
| 617 | - unset($auteur['low_sec']); |
|
| 618 | - unset($auteur['alea_actuel']); |
|
| 619 | - unset($auteur['alea_futur']); |
|
| 620 | - |
|
| 621 | - $auteur = pipeline('preparer_fichier_session', array('args' => array('row' => $row), 'data' => $auteur)); |
|
| 622 | - |
|
| 623 | - // ne pas enregistrer les valeurs vraiment nulle dans le fichier |
|
| 624 | - foreach ($auteur as $variable => $valeur) { |
|
| 625 | - if ($valeur === null) { |
|
| 626 | - unset($auteur[$variable]); |
|
| 627 | - } |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - return $auteur; |
|
| 611 | + $row = $auteur; |
|
| 612 | + |
|
| 613 | + // ne pas enregistrer ces elements de securite |
|
| 614 | + // dans le fichier de session |
|
| 615 | + unset($auteur['pass']); |
|
| 616 | + unset($auteur['htpass']); |
|
| 617 | + unset($auteur['low_sec']); |
|
| 618 | + unset($auteur['alea_actuel']); |
|
| 619 | + unset($auteur['alea_futur']); |
|
| 620 | + |
|
| 621 | + $auteur = pipeline('preparer_fichier_session', array('args' => array('row' => $row), 'data' => $auteur)); |
|
| 622 | + |
|
| 623 | + // ne pas enregistrer les valeurs vraiment nulle dans le fichier |
|
| 624 | + foreach ($auteur as $variable => $valeur) { |
|
| 625 | + if ($valeur === null) { |
|
| 626 | + unset($auteur[$variable]); |
|
| 627 | + } |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + return $auteur; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | /** |
@@ -639,17 +639,17 @@ discard block |
||
| 639 | 639 | */ |
| 640 | 640 | function ecrire_fichier_session($fichier, $auteur) { |
| 641 | 641 | |
| 642 | - $auteur = preparer_ecriture_session($auteur); |
|
| 642 | + $auteur = preparer_ecriture_session($auteur); |
|
| 643 | 643 | |
| 644 | - // enregistrer les autres donnees du visiteur |
|
| 645 | - $texte = "<" . "?php\n"; |
|
| 646 | - foreach ($auteur as $var => $val) { |
|
| 647 | - $texte .= '$GLOBALS[\'visiteur_session\'][' . var_export($var, true) . '] = ' |
|
| 648 | - . var_export($val, true) . ";\n"; |
|
| 649 | - } |
|
| 650 | - $texte .= "?" . ">\n"; |
|
| 644 | + // enregistrer les autres donnees du visiteur |
|
| 645 | + $texte = "<" . "?php\n"; |
|
| 646 | + foreach ($auteur as $var => $val) { |
|
| 647 | + $texte .= '$GLOBALS[\'visiteur_session\'][' . var_export($var, true) . '] = ' |
|
| 648 | + . var_export($val, true) . ";\n"; |
|
| 649 | + } |
|
| 650 | + $texte .= "?" . ">\n"; |
|
| 651 | 651 | |
| 652 | - return ecrire_fichier($fichier, $texte); |
|
| 652 | + return ecrire_fichier($fichier, $texte); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | |
@@ -662,23 +662,23 @@ discard block |
||
| 662 | 662 | */ |
| 663 | 663 | function fichier_session($alea, $tantpis = false) { |
| 664 | 664 | |
| 665 | - include_spip('inc/acces'); |
|
| 666 | - charger_aleas(); |
|
| 665 | + include_spip('inc/acces'); |
|
| 666 | + charger_aleas(); |
|
| 667 | 667 | |
| 668 | - if (empty($GLOBALS['meta'][$alea])) { |
|
| 669 | - if (!$tantpis) { |
|
| 670 | - spip_log("fichier session ($tantpis): $alea indisponible", "session"); |
|
| 671 | - include_spip('inc/minipres'); |
|
| 672 | - echo minipres(); |
|
| 673 | - } |
|
| 668 | + if (empty($GLOBALS['meta'][$alea])) { |
|
| 669 | + if (!$tantpis) { |
|
| 670 | + spip_log("fichier session ($tantpis): $alea indisponible", "session"); |
|
| 671 | + include_spip('inc/minipres'); |
|
| 672 | + echo minipres(); |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - return ''; // echec mais $tanpis |
|
| 676 | - } else { |
|
| 677 | - $repertoire = sous_repertoire(_DIR_SESSIONS, '', false, $tantpis); |
|
| 678 | - $c = $_COOKIE['spip_session']; |
|
| 675 | + return ''; // echec mais $tanpis |
|
| 676 | + } else { |
|
| 677 | + $repertoire = sous_repertoire(_DIR_SESSIONS, '', false, $tantpis); |
|
| 678 | + $c = $_COOKIE['spip_session']; |
|
| 679 | 679 | |
| 680 | - return $repertoire . intval($c) . '_' . md5($c . ' ' . $GLOBALS['meta'][$alea]) . '.php'; |
|
| 681 | - } |
|
| 680 | + return $repertoire . intval($c) . '_' . md5($c . ' ' . $GLOBALS['meta'][$alea]) . '.php'; |
|
| 681 | + } |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | * @return string |
| 696 | 696 | */ |
| 697 | 697 | function rejouer_session() { |
| 698 | - return '<img src="' . generer_url_action('cookie', 'change_session=oui', true) . '" width="0" height="0" alt="" />'; |
|
| 698 | + return '<img src="' . generer_url_action('cookie', 'change_session=oui', true) . '" width="0" height="0" alt="" />'; |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | |
@@ -705,12 +705,12 @@ discard block |
||
| 705 | 705 | * @return string |
| 706 | 706 | */ |
| 707 | 707 | function hash_env() { |
| 708 | - static $res = ''; |
|
| 709 | - if ($res) { |
|
| 710 | - return $res; |
|
| 711 | - } |
|
| 708 | + static $res = ''; |
|
| 709 | + if ($res) { |
|
| 710 | + return $res; |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | - return $res = md5($GLOBALS['ip'] . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')); |
|
| 713 | + return $res = md5($GLOBALS['ip'] . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')); |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | |
@@ -722,11 +722,11 @@ discard block |
||
| 722 | 722 | * @return bool True si une session PHP est ouverte. |
| 723 | 723 | **/ |
| 724 | 724 | function spip_php_session_start() { |
| 725 | - if (!is_php_session_started()) { |
|
| 726 | - return session_start(); |
|
| 727 | - } |
|
| 725 | + if (!is_php_session_started()) { |
|
| 726 | + return session_start(); |
|
| 727 | + } |
|
| 728 | 728 | |
| 729 | - return true; |
|
| 729 | + return true; |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
@@ -736,9 +736,9 @@ discard block |
||
| 736 | 736 | * @return bool true si une session PHP est active |
| 737 | 737 | **/ |
| 738 | 738 | function is_php_session_started() { |
| 739 | - if (php_sapi_name() !== 'cli') { |
|
| 740 | - return session_status() === PHP_SESSION_ACTIVE ? true : false; |
|
| 741 | - } |
|
| 739 | + if (php_sapi_name() !== 'cli') { |
|
| 740 | + return session_status() === PHP_SESSION_ACTIVE ? true : false; |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - return false; |
|
| 743 | + return false; |
|
| 744 | 744 | } |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | spip_log("supprimer sessions auteur $id_auteur", "session"); |
| 83 | 83 | if ($toutes or $id_auteur !== $GLOBALS['visiteur_session']['id_auteur']) { |
| 84 | 84 | if ($dir = opendir(_DIR_SESSIONS)) { |
| 85 | - $t = $_SERVER['REQUEST_TIME'] - (4*_RENOUVELLE_ALEA); // 48h par defaut |
|
| 86 | - $t_short = $_SERVER['REQUEST_TIME'] - max(_RENOUVELLE_ALEA/4,3*3600); // 3h par defaut |
|
| 85 | + $t = $_SERVER['REQUEST_TIME'] - (4 * _RENOUVELLE_ALEA); // 48h par defaut |
|
| 86 | + $t_short = $_SERVER['REQUEST_TIME'] - max(_RENOUVELLE_ALEA / 4, 3 * 3600); // 3h par defaut |
|
| 87 | 87 | $t = time() - (4 * _RENOUVELLE_ALEA); |
| 88 | 88 | while (($f = readdir($dir)) !== false) { |
| 89 | 89 | $nb_files++; |
| 90 | 90 | if (preg_match(",^[^\d-]*(-?\d+)_\w{32}\.php[3]?$,", $f, $regs)) { |
| 91 | - $f = _DIR_SESSIONS . $f; |
|
| 91 | + $f = _DIR_SESSIONS.$f; |
|
| 92 | 92 | if (($actives and $regs[1] == $id_auteur) or ($t > filemtime($f))) { |
| 93 | 93 | spip_unlink($f); |
| 94 | 94 | } |
| 95 | 95 | // si il y a trop de sessions ouvertes, on purge les sessions anonymes de plus de 3H |
| 96 | 96 | // cf http://core.spip.org/issues/3276 |
| 97 | - elseif ($nb_files>$nb_max_files and !intval($regs[1]) and ($t_short > filemtime($f))) { |
|
| 97 | + elseif ($nb_files > $nb_max_files and !intval($regs[1]) and ($t_short > filemtime($f))) { |
|
| 98 | 98 | spip_unlink($f); |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | if (!isset($_COOKIE['spip_session']) |
| 173 | - or !preg_match(',^' . $id_auteur . '_,', $_COOKIE['spip_session']) |
|
| 173 | + or !preg_match(',^'.$id_auteur.'_,', $_COOKIE['spip_session']) |
|
| 174 | 174 | ) { |
| 175 | - $_COOKIE['spip_session'] = $id_auteur . '_' . md5(uniqid(rand(), true)); |
|
| 175 | + $_COOKIE['spip_session'] = $id_auteur.'_'.md5(uniqid(rand(), true)); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // Maintenant on sait qu'on a des choses à écrire |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | } else { |
| 204 | 204 | $fichier_session = fichier_session('alea_ephemere'); |
| 205 | 205 | if (!ecrire_fichier_session($fichier_session, $auteur)) { |
| 206 | - spip_log('Echec ecriture fichier session ' . $fichier_session, "session" . _LOG_HS); |
|
| 206 | + spip_log('Echec ecriture fichier session '.$fichier_session, "session"._LOG_HS); |
|
| 207 | 207 | include_spip('inc/minipres'); |
| 208 | 208 | echo minipres(); |
| 209 | 209 | exit; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | // poser le cookie de session SPIP |
| 217 | 217 | include_spip('inc/cookie'); |
| 218 | 218 | $duree = definir_duree_cookie_session($auteur); |
| 219 | - spip_setcookie( 'spip_session', $_COOKIE['spip_session'], [ |
|
| 219 | + spip_setcookie('spip_session', $_COOKIE['spip_session'], [ |
|
| 220 | 220 | 'expires' => time() + $duree |
| 221 | 221 | ]); |
| 222 | 222 | spip_log("ajoute session $fichier_session cookie $duree", "session"); |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | if (!function_exists('autoriser')) { |
| 226 | 226 | include_spip('inc/autoriser'); |
| 227 | 227 | } |
| 228 | - if (autoriser('ecrire','','',$auteur) and _DUREE_COOKIE_ADMIN) { |
|
| 229 | - spip_setcookie('spip_admin', '@' . ($auteur['email'] ?: $auteur['login']), [ |
|
| 228 | + if (autoriser('ecrire', '', '', $auteur) and _DUREE_COOKIE_ADMIN) { |
|
| 229 | + spip_setcookie('spip_admin', '@'.($auteur['email'] ?: $auteur['login']), [ |
|
| 230 | 230 | 'expires' => time() + max(_DUREE_COOKIE_ADMIN, $duree) |
| 231 | 231 | ]); |
| 232 | 232 | } // sinon le supprimer ... |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $coef = 20; |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | - return (int)(_RENOUVELLE_ALEA * $coef); |
|
| 270 | + return (int) (_RENOUVELLE_ALEA * $coef); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | // Renouveler la session avec l'alea courant |
| 317 | 317 | include($fichier_session); |
| 318 | - spip_log('renouvelle session ' . $GLOBALS['visiteur_session']['id_auteur'], "session"); |
|
| 318 | + spip_log('renouvelle session '.$GLOBALS['visiteur_session']['id_auteur'], "session"); |
|
| 319 | 319 | spip_unlink($fichier_session); |
| 320 | 320 | ajouter_session($GLOBALS['visiteur_session']); |
| 321 | 321 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | } |
| 348 | 348 | } else { |
| 349 | 349 | if ($change) { |
| 350 | - spip_log("rejoue session $fichier_session " . $_COOKIE['spip_session'], "session"); |
|
| 350 | + spip_log("rejoue session $fichier_session ".$_COOKIE['spip_session'], "session"); |
|
| 351 | 351 | if ($fichier_session) { |
| 352 | 352 | spip_unlink($fichier_session); |
| 353 | 353 | } |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | // liste des sessions |
| 566 | - $sessions = preg_files(_DIR_SESSIONS, '/' . $id_auteur . '_.*\.php$'); |
|
| 566 | + $sessions = preg_files(_DIR_SESSIONS, '/'.$id_auteur.'_.*\.php$'); |
|
| 567 | 567 | |
| 568 | 568 | // si on en a plus que la limite, supprimer les plus vieilles |
| 569 | 569 | // si ce ne sont pas des sessions anonymes car elles sont alors chacune differentes |
@@ -642,12 +642,12 @@ discard block |
||
| 642 | 642 | $auteur = preparer_ecriture_session($auteur); |
| 643 | 643 | |
| 644 | 644 | // enregistrer les autres donnees du visiteur |
| 645 | - $texte = "<" . "?php\n"; |
|
| 645 | + $texte = "<"."?php\n"; |
|
| 646 | 646 | foreach ($auteur as $var => $val) { |
| 647 | - $texte .= '$GLOBALS[\'visiteur_session\'][' . var_export($var, true) . '] = ' |
|
| 648 | - . var_export($val, true) . ";\n"; |
|
| 647 | + $texte .= '$GLOBALS[\'visiteur_session\']['.var_export($var, true).'] = ' |
|
| 648 | + . var_export($val, true).";\n"; |
|
| 649 | 649 | } |
| 650 | - $texte .= "?" . ">\n"; |
|
| 650 | + $texte .= "?".">\n"; |
|
| 651 | 651 | |
| 652 | 652 | return ecrire_fichier($fichier, $texte); |
| 653 | 653 | } |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | $repertoire = sous_repertoire(_DIR_SESSIONS, '', false, $tantpis); |
| 678 | 678 | $c = $_COOKIE['spip_session']; |
| 679 | 679 | |
| 680 | - return $repertoire . intval($c) . '_' . md5($c . ' ' . $GLOBALS['meta'][$alea]) . '.php'; |
|
| 680 | + return $repertoire.intval($c).'_'.md5($c.' '.$GLOBALS['meta'][$alea]).'.php'; |
|
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | * @return string |
| 696 | 696 | */ |
| 697 | 697 | function rejouer_session() { |
| 698 | - return '<img src="' . generer_url_action('cookie', 'change_session=oui', true) . '" width="0" height="0" alt="" />'; |
|
| 698 | + return '<img src="'.generer_url_action('cookie', 'change_session=oui', true).'" width="0" height="0" alt="" />'; |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | return $res; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - return $res = md5($GLOBALS['ip'] . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')); |
|
| 713 | + return $res = md5($GLOBALS['ip'].(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')); |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | |
@@ -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 | |
@@ -52,62 +52,62 @@ discard block |
||
| 52 | 52 | * cookie sécurisé ou non ? |
| 53 | 53 | **/ |
| 54 | 54 | function spip_setcookie($name = '', $value = '', $options = []) { |
| 55 | - static $to_secure_list = ['spip_session']; |
|
| 56 | - |
|
| 57 | - if (!is_array($options)) { |
|
| 58 | - // anciens paramètres : |
|
| 59 | - # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '') |
|
| 60 | - $opt = func_get_args(); |
|
| 61 | - $opt = array_slice($opt, 2); |
|
| 62 | - $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !); |
|
| 63 | - if (isset($opt[0])) { |
|
| 64 | - $options['expires'] = $opt[0]; |
|
| 65 | - } |
|
| 66 | - if (isset($opt[1])) { |
|
| 67 | - $options['path'] = $opt[1]; |
|
| 68 | - } |
|
| 69 | - if (isset($opt[2])) { |
|
| 70 | - $options['domain'] = $opt[2]; |
|
| 71 | - } |
|
| 72 | - if (isset($opt[3])) { |
|
| 73 | - $options['secure'] = $opt[3]; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $name = preg_replace('/^spip_/', $GLOBALS['cookie_prefix'] . '_', $name); |
|
| 78 | - |
|
| 79 | - // expires |
|
| 80 | - if (!isset($options['expires'])) { |
|
| 81 | - $options['expires'] = 0; |
|
| 82 | - } |
|
| 83 | - if (!isset($options['path']) or $options['path'] === 'AUTO') { |
|
| 84 | - if (defined('_COOKIE_PATH')) { |
|
| 85 | - $options['path'] = _COOKIE_PATH; |
|
| 86 | - } else { |
|
| 87 | - $options['path'] = preg_replace(',^\w+://[^/]*,', '', url_de_base()); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - if (empty($options['domain']) and defined('_COOKIE_DOMAIN') and _COOKIE_DOMAIN) { |
|
| 91 | - $options['domain'] = _COOKIE_DOMAIN; |
|
| 92 | - } |
|
| 93 | - if (in_array($name, $to_secure_list)) { |
|
| 94 | - if (empty($options['secure']) and defined('_COOKIE_SECURE') and _COOKIE_SECURE) { |
|
| 95 | - $options['secure'] = true; |
|
| 96 | - } |
|
| 97 | - if (empty($options['httponly'])) { |
|
| 98 | - $options['httponly'] = true; |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - if (empty($options['samesite'])) { |
|
| 102 | - $options['samesite'] = 'Lax'; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies"); |
|
| 106 | - $a = @setcookie($name, $value, $options); |
|
| 107 | - |
|
| 108 | - spip_cookie_envoye(true); |
|
| 109 | - |
|
| 110 | - return $a; |
|
| 55 | + static $to_secure_list = ['spip_session']; |
|
| 56 | + |
|
| 57 | + if (!is_array($options)) { |
|
| 58 | + // anciens paramètres : |
|
| 59 | + # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '') |
|
| 60 | + $opt = func_get_args(); |
|
| 61 | + $opt = array_slice($opt, 2); |
|
| 62 | + $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !); |
|
| 63 | + if (isset($opt[0])) { |
|
| 64 | + $options['expires'] = $opt[0]; |
|
| 65 | + } |
|
| 66 | + if (isset($opt[1])) { |
|
| 67 | + $options['path'] = $opt[1]; |
|
| 68 | + } |
|
| 69 | + if (isset($opt[2])) { |
|
| 70 | + $options['domain'] = $opt[2]; |
|
| 71 | + } |
|
| 72 | + if (isset($opt[3])) { |
|
| 73 | + $options['secure'] = $opt[3]; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $name = preg_replace('/^spip_/', $GLOBALS['cookie_prefix'] . '_', $name); |
|
| 78 | + |
|
| 79 | + // expires |
|
| 80 | + if (!isset($options['expires'])) { |
|
| 81 | + $options['expires'] = 0; |
|
| 82 | + } |
|
| 83 | + if (!isset($options['path']) or $options['path'] === 'AUTO') { |
|
| 84 | + if (defined('_COOKIE_PATH')) { |
|
| 85 | + $options['path'] = _COOKIE_PATH; |
|
| 86 | + } else { |
|
| 87 | + $options['path'] = preg_replace(',^\w+://[^/]*,', '', url_de_base()); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + if (empty($options['domain']) and defined('_COOKIE_DOMAIN') and _COOKIE_DOMAIN) { |
|
| 91 | + $options['domain'] = _COOKIE_DOMAIN; |
|
| 92 | + } |
|
| 93 | + if (in_array($name, $to_secure_list)) { |
|
| 94 | + if (empty($options['secure']) and defined('_COOKIE_SECURE') and _COOKIE_SECURE) { |
|
| 95 | + $options['secure'] = true; |
|
| 96 | + } |
|
| 97 | + if (empty($options['httponly'])) { |
|
| 98 | + $options['httponly'] = true; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + if (empty($options['samesite'])) { |
|
| 102 | + $options['samesite'] = 'Lax'; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies"); |
|
| 106 | + $a = @setcookie($name, $value, $options); |
|
| 107 | + |
|
| 108 | + spip_cookie_envoye(true); |
|
| 109 | + |
|
| 110 | + return $a; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | * @return bool |
| 124 | 124 | **/ |
| 125 | 125 | function spip_cookie_envoye($set = '') { |
| 126 | - static $envoye = false; |
|
| 127 | - if ($set) { |
|
| 128 | - $envoye = true; |
|
| 129 | - } |
|
| 126 | + static $envoye = false; |
|
| 127 | + if ($set) { |
|
| 128 | + $envoye = true; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - return $envoye; |
|
| 131 | + return $envoye; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -147,21 +147,21 @@ discard block |
||
| 147 | 147 | * Préfixe des cookies de SPIP |
| 148 | 148 | **/ |
| 149 | 149 | function recuperer_cookies_spip($cookie_prefix) { |
| 150 | - $prefix_long = strlen($cookie_prefix); |
|
| 151 | - |
|
| 152 | - foreach ($_COOKIE as $name => $value) { |
|
| 153 | - if (substr($name, 0, 5) == 'spip_' && substr($name, 0, $prefix_long) != $cookie_prefix) { |
|
| 154 | - unset($_COOKIE[$name]); |
|
| 155 | - unset($GLOBALS[$name]); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - foreach ($_COOKIE as $name => $value) { |
|
| 159 | - if (substr($name, 0, $prefix_long) == $cookie_prefix) { |
|
| 160 | - $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name); |
|
| 161 | - $_COOKIE[$spipname] = $value; |
|
| 162 | - $GLOBALS[$spipname] = $value; |
|
| 163 | - } |
|
| 164 | - } |
|
| 150 | + $prefix_long = strlen($cookie_prefix); |
|
| 151 | + |
|
| 152 | + foreach ($_COOKIE as $name => $value) { |
|
| 153 | + if (substr($name, 0, 5) == 'spip_' && substr($name, 0, $prefix_long) != $cookie_prefix) { |
|
| 154 | + unset($_COOKIE[$name]); |
|
| 155 | + unset($GLOBALS[$name]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + foreach ($_COOKIE as $name => $value) { |
|
| 159 | + if (substr($name, 0, $prefix_long) == $cookie_prefix) { |
|
| 160 | + $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name); |
|
| 161 | + $_COOKIE[$spipname] = $value; |
|
| 162 | + $GLOBALS[$spipname] = $value; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
@@ -181,18 +181,18 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | **/ |
| 183 | 183 | function exec_test_ajax_dist() { |
| 184 | - switch (_request('js')) { |
|
| 185 | - // on est appele par <noscript> |
|
| 186 | - case -1: |
|
| 187 | - spip_setcookie('spip_accepte_ajax', -1); |
|
| 188 | - include_spip('inc/headers'); |
|
| 189 | - redirige_par_entete(chemin_image('puce-orange-anim.gif')); |
|
| 190 | - break; |
|
| 191 | - |
|
| 192 | - // ou par ajax |
|
| 193 | - case 1: |
|
| 194 | - default: |
|
| 195 | - spip_setcookie('spip_accepte_ajax', 1); |
|
| 196 | - break; |
|
| 197 | - } |
|
| 184 | + switch (_request('js')) { |
|
| 185 | + // on est appele par <noscript> |
|
| 186 | + case -1: |
|
| 187 | + spip_setcookie('spip_accepte_ajax', -1); |
|
| 188 | + include_spip('inc/headers'); |
|
| 189 | + redirige_par_entete(chemin_image('puce-orange-anim.gif')); |
|
| 190 | + break; |
|
| 191 | + |
|
| 192 | + // ou par ajax |
|
| 193 | + case 1: |
|
| 194 | + default: |
|
| 195 | + spip_setcookie('spip_accepte_ajax', 1); |
|
| 196 | + break; |
|
| 197 | + } |
|
| 198 | 198 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $name = preg_replace('/^spip_/', $GLOBALS['cookie_prefix'] . '_', $name); |
|
| 77 | + $name = preg_replace('/^spip_/', $GLOBALS['cookie_prefix'].'_', $name); |
|
| 78 | 78 | |
| 79 | 79 | // expires |
| 80 | 80 | if (!isset($options['expires'])) { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | foreach ($_COOKIE as $name => $value) { |
| 159 | 159 | if (substr($name, 0, $prefix_long) == $cookie_prefix) { |
| 160 | - $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name); |
|
| 160 | + $spipname = preg_replace('/^'.$cookie_prefix.'_/', 'spip_', $name); |
|
| 161 | 161 | $_COOKIE[$spipname] = $value; |
| 162 | 162 | $GLOBALS[$spipname] = $value; |
| 163 | 163 | } |
@@ -234,6 +234,9 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | // https://code.spip.net/@info_etape |
| 237 | +/** |
|
| 238 | + * @param string $titre |
|
| 239 | + */ |
|
| 237 | 240 | function info_etape($titre, $complement = '') { |
| 238 | 241 | return "<h2>" . $titre . "</h2>\n" . |
| 239 | 242 | ($complement ? "" . $complement . "\n" : ''); |
@@ -259,6 +262,11 @@ discard block |
||
| 259 | 262 | } |
| 260 | 263 | |
| 261 | 264 | // https://code.spip.net/@info_progression_etape |
| 265 | +/** |
|
| 266 | + * @param integer $en_cours |
|
| 267 | + * @param string $phase |
|
| 268 | + * @param string $dir |
|
| 269 | + */ |
|
| 262 | 270 | function info_progression_etape($en_cours, $phase, $dir, $erreur = false) { |
| 263 | 271 | //$en_cours = _request('etape')?_request('etape'):""; |
| 264 | 272 | $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
@@ -315,6 +323,9 @@ discard block |
||
| 315 | 323 | |
| 316 | 324 | |
| 317 | 325 | // https://code.spip.net/@fieldset |
| 326 | +/** |
|
| 327 | + * @param string $legend |
|
| 328 | + */ |
|
| 318 | 329 | function fieldset($legend, $champs = array(), $apres = '', $avant = '') { |
| 319 | 330 | return "<fieldset>\n" . |
| 320 | 331 | $avant . |
@@ -382,6 +393,10 @@ discard block |
||
| 382 | 393 | } |
| 383 | 394 | |
| 384 | 395 | // https://code.spip.net/@install_connexion_form |
| 396 | +/** |
|
| 397 | + * @param string[] $pass |
|
| 398 | + * @param integer $etape |
|
| 399 | + */ |
|
| 385 | 400 | function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) { |
| 386 | 401 | $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
| 387 | 402 | |
@@ -559,6 +574,9 @@ discard block |
||
| 559 | 574 | return array($checked, $bases); |
| 560 | 575 | } |
| 561 | 576 | |
| 577 | +/** |
|
| 578 | + * @param string[] $hidden |
|
| 579 | + */ |
|
| 562 | 580 | function install_propager($hidden) { |
| 563 | 581 | $res = ''; |
| 564 | 582 | foreach ($hidden as $k) { |
@@ -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 | |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | **/ |
| 45 | 45 | function install_fichier_connexion($nom, $texte) { |
| 46 | - $texte = "<" . "?php\n" |
|
| 47 | - . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 48 | - . $texte |
|
| 49 | - . "?" . ">"; |
|
| 46 | + $texte = "<" . "?php\n" |
|
| 47 | + . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 48 | + . $texte |
|
| 49 | + . "?" . ">"; |
|
| 50 | 50 | |
| 51 | - ecrire_fichier($nom, $texte); |
|
| 51 | + ecrire_fichier($nom, $texte); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -77,20 +77,20 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | **/ |
| 79 | 79 | function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') { |
| 80 | - $adr = addcslashes($adr, "'\\"); |
|
| 81 | - $port = addcslashes($port, "'\\"); |
|
| 82 | - $login = addcslashes($login, "'\\"); |
|
| 83 | - $pass = addcslashes($pass, "'\\"); |
|
| 84 | - $base = addcslashes($base, "'\\"); |
|
| 85 | - $type = addcslashes($type, "'\\"); |
|
| 86 | - $pref = addcslashes($pref, "'\\"); |
|
| 87 | - $ldap = addcslashes($ldap, "'\\"); |
|
| 88 | - $charset = addcslashes($charset, "'\\"); |
|
| 89 | - |
|
| 90 | - return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 91 | - . "spip_connect_db(" |
|
| 92 | - . "'$adr','$port','$login','$pass','$base'" |
|
| 93 | - . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 80 | + $adr = addcslashes($adr, "'\\"); |
|
| 81 | + $port = addcslashes($port, "'\\"); |
|
| 82 | + $login = addcslashes($login, "'\\"); |
|
| 83 | + $pass = addcslashes($pass, "'\\"); |
|
| 84 | + $base = addcslashes($base, "'\\"); |
|
| 85 | + $type = addcslashes($type, "'\\"); |
|
| 86 | + $pref = addcslashes($pref, "'\\"); |
|
| 87 | + $ldap = addcslashes($ldap, "'\\"); |
|
| 88 | + $charset = addcslashes($charset, "'\\"); |
|
| 89 | + |
|
| 90 | + return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 91 | + . "spip_connect_db(" |
|
| 92 | + . "'$adr','$port','$login','$pass','$base'" |
|
| 93 | + . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -106,26 +106,26 @@ discard block |
||
| 106 | 106 | * Tableau des informations sur la connexion |
| 107 | 107 | **/ |
| 108 | 108 | function analyse_fichier_connection($file) { |
| 109 | - $s = @join('', file($file)); |
|
| 110 | - if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 111 | - array_shift($regs); |
|
| 112 | - |
|
| 113 | - return $regs; |
|
| 114 | - } else { |
|
| 115 | - $ar = '\s*\'([^\']*)\''; |
|
| 116 | - $r = '\s*,' . $ar; |
|
| 117 | - $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 118 | - if (preg_match($r, $s, $regs)) { |
|
| 119 | - $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";"); |
|
| 120 | - array_shift($regs); |
|
| 121 | - array_shift($regs); |
|
| 122 | - |
|
| 123 | - return $regs; |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - spip_log("$file n'est pas un fichier de connexion"); |
|
| 127 | - |
|
| 128 | - return array(); |
|
| 109 | + $s = @join('', file($file)); |
|
| 110 | + if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 111 | + array_shift($regs); |
|
| 112 | + |
|
| 113 | + return $regs; |
|
| 114 | + } else { |
|
| 115 | + $ar = '\s*\'([^\']*)\''; |
|
| 116 | + $r = '\s*,' . $ar; |
|
| 117 | + $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 118 | + if (preg_match($r, $s, $regs)) { |
|
| 119 | + $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";"); |
|
| 120 | + array_shift($regs); |
|
| 121 | + array_shift($regs); |
|
| 122 | + |
|
| 123 | + return $regs; |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + spip_log("$file n'est pas un fichier de connexion"); |
|
| 127 | + |
|
| 128 | + return array(); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -142,21 +142,21 @@ discard block |
||
| 142 | 142 | * Liste des noms de connecteurs |
| 143 | 143 | **/ |
| 144 | 144 | function bases_referencees($exclu = '') { |
| 145 | - $tables = array(); |
|
| 146 | - foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 147 | - if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 148 | - $tables[] = basename($f, '.php'); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $tables; |
|
| 145 | + $tables = array(); |
|
| 146 | + foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 147 | + if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 148 | + $tables[] = basename($f, '.php'); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $tables; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | function install_mode_appel($server_db, $tout = true) { |
| 157 | - return ($server_db != 'mysql') ? '' |
|
| 158 | - : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 159 | - . test_sql_mode_mysql($server_db)); |
|
| 157 | + return ($server_db != 'mysql') ? '' |
|
| 158 | + : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 159 | + . test_sql_mode_mysql($server_db)); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // |
@@ -164,52 +164,52 @@ discard block |
||
| 164 | 164 | // (sert a l'etape 1 de l'installation) |
| 165 | 165 | // https://code.spip.net/@tester_compatibilite_hebergement |
| 166 | 166 | function tester_compatibilite_hebergement() { |
| 167 | - $err = array(); |
|
| 168 | - |
|
| 169 | - $p = phpversion(); |
|
| 170 | - if (version_compare($p, _PHP_MIN, '<')) { |
|
| 171 | - $err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN)); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 175 | - if ($err) { |
|
| 176 | - die("<div class='error'>" |
|
| 177 | - . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 178 | - . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - // Il faut une base de donnees tout de meme ... |
|
| 182 | - $serveurs = install_select_serveur(); |
|
| 183 | - if (!$serveurs) { |
|
| 184 | - $err[] = _T('install_extension_php_obligatoire') |
|
| 185 | - . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 186 | - . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 187 | - . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // et il faut preg |
|
| 191 | - if (!function_exists('preg_match_all')) { |
|
| 192 | - $err[] = _T('install_extension_php_obligatoire') |
|
| 193 | - . " <a href='http://se.php.net/pcre'>PCRE</a>"; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - // et surtout pas ce mbstring.overload |
|
| 197 | - if ($a = @ini_get('mbstring.func_overload')) { |
|
| 198 | - $err[] = _T('install_extension_mbstring') |
|
| 199 | - . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - if ($err) { |
|
| 203 | - echo "<div class='error'>" |
|
| 204 | - . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 205 | - foreach ($err as $e) { |
|
| 206 | - echo "<li><strong>$e</strong></li>\n"; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 210 | - # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 211 | - echo "</ul></div>\n"; |
|
| 212 | - } |
|
| 167 | + $err = array(); |
|
| 168 | + |
|
| 169 | + $p = phpversion(); |
|
| 170 | + if (version_compare($p, _PHP_MIN, '<')) { |
|
| 171 | + $err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN)); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 175 | + if ($err) { |
|
| 176 | + die("<div class='error'>" |
|
| 177 | + . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 178 | + . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + // Il faut une base de donnees tout de meme ... |
|
| 182 | + $serveurs = install_select_serveur(); |
|
| 183 | + if (!$serveurs) { |
|
| 184 | + $err[] = _T('install_extension_php_obligatoire') |
|
| 185 | + . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 186 | + . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 187 | + . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // et il faut preg |
|
| 191 | + if (!function_exists('preg_match_all')) { |
|
| 192 | + $err[] = _T('install_extension_php_obligatoire') |
|
| 193 | + . " <a href='http://se.php.net/pcre'>PCRE</a>"; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + // et surtout pas ce mbstring.overload |
|
| 197 | + if ($a = @ini_get('mbstring.func_overload')) { |
|
| 198 | + $err[] = _T('install_extension_mbstring') |
|
| 199 | + . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + if ($err) { |
|
| 203 | + echo "<div class='error'>" |
|
| 204 | + . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 205 | + foreach ($err as $e) { |
|
| 206 | + echo "<li><strong>$e</strong></li>\n"; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 210 | + # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 211 | + echo "</ul></div>\n"; |
|
| 212 | + } |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -219,24 +219,24 @@ discard block |
||
| 219 | 219 | * @note superflu ?? |
| 220 | 220 | */ |
| 221 | 221 | function login_hebergeur() { |
| 222 | - $base_hebergeur = 'localhost'; # par defaut |
|
| 222 | + $base_hebergeur = 'localhost'; # par defaut |
|
| 223 | 223 | |
| 224 | - // Free |
|
| 225 | - if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 226 | - $base_hebergeur = 'sql.free.fr'; |
|
| 227 | - $login_hebergeur = $regs[1]; |
|
| 228 | - } else { |
|
| 229 | - $login_hebergeur = ''; |
|
| 230 | - } |
|
| 224 | + // Free |
|
| 225 | + if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 226 | + $base_hebergeur = 'sql.free.fr'; |
|
| 227 | + $login_hebergeur = $regs[1]; |
|
| 228 | + } else { |
|
| 229 | + $login_hebergeur = ''; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - return array($base_hebergeur, $login_hebergeur); |
|
| 232 | + return array($base_hebergeur, $login_hebergeur); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | // https://code.spip.net/@info_etape |
| 237 | 237 | function info_etape($titre, $complement = '') { |
| 238 | - return "<h2>" . $titre . "</h2>\n" . |
|
| 239 | - ($complement ? "" . $complement . "\n" : ''); |
|
| 238 | + return "<h2>" . $titre . "</h2>\n" . |
|
| 239 | + ($complement ? "" . $complement . "\n" : ''); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -246,155 +246,155 @@ discard block |
||
| 246 | 246 | * @return string Code HTML du bouton |
| 247 | 247 | **/ |
| 248 | 248 | function bouton_suivant($code = '') { |
| 249 | - if ($code == '') { |
|
| 250 | - $code = _T('bouton_suivant'); |
|
| 251 | - } |
|
| 252 | - static $suivant = 0; |
|
| 253 | - $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 254 | - $suivant += 1; |
|
| 255 | - |
|
| 256 | - return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 257 | - $code . |
|
| 258 | - " >>\" /></p>\n"; |
|
| 249 | + if ($code == '') { |
|
| 250 | + $code = _T('bouton_suivant'); |
|
| 251 | + } |
|
| 252 | + static $suivant = 0; |
|
| 253 | + $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 254 | + $suivant += 1; |
|
| 255 | + |
|
| 256 | + return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 257 | + $code . |
|
| 258 | + " >>\" /></p>\n"; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // https://code.spip.net/@info_progression_etape |
| 262 | 262 | function info_progression_etape($en_cours, $phase, $dir, $erreur = false) { |
| 263 | - //$en_cours = _request('etape')?_request('etape'):""; |
|
| 264 | - $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 265 | - $debut = 1; |
|
| 266 | - $etat = "ok"; |
|
| 267 | - $last = count($liste); |
|
| 263 | + //$en_cours = _request('etape')?_request('etape'):""; |
|
| 264 | + $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 265 | + $debut = 1; |
|
| 266 | + $etat = "ok"; |
|
| 267 | + $last = count($liste); |
|
| 268 | 268 | // $texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo')); |
| 269 | 269 | |
| 270 | - $intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee')); |
|
| 271 | - $intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 272 | - $intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles')); |
|
| 273 | - $intitule_etat["etape_"][4] = typo(_T('info_derniere_etape')); |
|
| 270 | + $intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee')); |
|
| 271 | + $intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 272 | + $intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles')); |
|
| 273 | + $intitule_etat["etape_"][4] = typo(_T('info_derniere_etape')); |
|
| 274 | 274 | |
| 275 | - $intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap')); |
|
| 276 | - $intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap')); |
|
| 277 | - $intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1')); |
|
| 278 | - $intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap')); |
|
| 279 | - $intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok')); |
|
| 275 | + $intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap')); |
|
| 276 | + $intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap')); |
|
| 277 | + $intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1')); |
|
| 278 | + $intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap')); |
|
| 279 | + $intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok')); |
|
| 280 | 280 | |
| 281 | 281 | // $aff_etapes = "<span id='etapes'>"; |
| 282 | 282 | |
| 283 | - $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 284 | - |
|
| 285 | - foreach ($liste as $etape => $fichier) { |
|
| 286 | - if ($debut < $last) { |
|
| 287 | - if ($debut == $en_cours && $erreur) { |
|
| 288 | - $class = "on erreur"; |
|
| 289 | - } else { |
|
| 290 | - if ($debut == $en_cours) { |
|
| 291 | - $class = "on"; |
|
| 292 | - } else { |
|
| 293 | - if ($debut > $en_cours) { |
|
| 294 | - $class = "prochains"; |
|
| 295 | - } else { |
|
| 296 | - $class = "valides"; |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 302 | - $aff_etapes .= ($debut == $en_cours) ? "<strong>" : ''; |
|
| 303 | - $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 304 | - $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 305 | - $aff_etapes .= ($debut == $en_cours) ? "</strong>" : ''; |
|
| 306 | - $aff_etapes .= "</div></li>"; |
|
| 307 | - } |
|
| 308 | - $debut++; |
|
| 309 | - } |
|
| 310 | - $aff_etapes .= "</ul>"; |
|
| 311 | - $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 312 | - |
|
| 313 | - return $aff_etapes; |
|
| 283 | + $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 284 | + |
|
| 285 | + foreach ($liste as $etape => $fichier) { |
|
| 286 | + if ($debut < $last) { |
|
| 287 | + if ($debut == $en_cours && $erreur) { |
|
| 288 | + $class = "on erreur"; |
|
| 289 | + } else { |
|
| 290 | + if ($debut == $en_cours) { |
|
| 291 | + $class = "on"; |
|
| 292 | + } else { |
|
| 293 | + if ($debut > $en_cours) { |
|
| 294 | + $class = "prochains"; |
|
| 295 | + } else { |
|
| 296 | + $class = "valides"; |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 302 | + $aff_etapes .= ($debut == $en_cours) ? "<strong>" : ''; |
|
| 303 | + $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 304 | + $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 305 | + $aff_etapes .= ($debut == $en_cours) ? "</strong>" : ''; |
|
| 306 | + $aff_etapes .= "</div></li>"; |
|
| 307 | + } |
|
| 308 | + $debut++; |
|
| 309 | + } |
|
| 310 | + $aff_etapes .= "</ul>"; |
|
| 311 | + $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 312 | + |
|
| 313 | + return $aff_etapes; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | |
| 317 | 317 | // https://code.spip.net/@fieldset |
| 318 | 318 | function fieldset($legend, $champs = array(), $apres = '', $avant = '') { |
| 319 | - return "<fieldset>\n" . |
|
| 320 | - $avant . |
|
| 321 | - ($legend ? "<legend>" . $legend . "</legend>\n" : '') . |
|
| 322 | - fieldset_champs($champs) . |
|
| 323 | - $apres . |
|
| 324 | - "</fieldset>\n"; |
|
| 319 | + return "<fieldset>\n" . |
|
| 320 | + $avant . |
|
| 321 | + ($legend ? "<legend>" . $legend . "</legend>\n" : '') . |
|
| 322 | + fieldset_champs($champs) . |
|
| 323 | + $apres . |
|
| 324 | + "</fieldset>\n"; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | function fieldset_champs($champs = array()) { |
| 328 | - $fieldset = ''; |
|
| 329 | - foreach ($champs as $nom => $contenu) { |
|
| 330 | - $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 331 | - $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 332 | - if (isset($contenu['alternatives'])) { |
|
| 333 | - $fieldset .= $contenu['label'] . "\n"; |
|
| 334 | - foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 335 | - $fieldset .= "<input type='radio' name='" . $nom . |
|
| 336 | - "' id='$nom-$valeur' value='$valeur'" |
|
| 337 | - . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 338 | - . "/>\n"; |
|
| 339 | - $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 340 | - } |
|
| 341 | - $fieldset .= "<br />\n"; |
|
| 342 | - } else { |
|
| 343 | - $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 344 | - $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 345 | - . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 346 | - . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "") |
|
| 347 | - . " />\n"; |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - return $fieldset; |
|
| 328 | + $fieldset = ''; |
|
| 329 | + foreach ($champs as $nom => $contenu) { |
|
| 330 | + $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 331 | + $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 332 | + if (isset($contenu['alternatives'])) { |
|
| 333 | + $fieldset .= $contenu['label'] . "\n"; |
|
| 334 | + foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 335 | + $fieldset .= "<input type='radio' name='" . $nom . |
|
| 336 | + "' id='$nom-$valeur' value='$valeur'" |
|
| 337 | + . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 338 | + . "/>\n"; |
|
| 339 | + $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 340 | + } |
|
| 341 | + $fieldset .= "<br />\n"; |
|
| 342 | + } else { |
|
| 343 | + $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 344 | + $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 345 | + . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 346 | + . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "") |
|
| 347 | + . " />\n"; |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + return $fieldset; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | function install_select_serveur() { |
| 355 | - $options = array(); |
|
| 356 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 357 | - $d = opendir($dir); |
|
| 358 | - if (!$d) { |
|
| 359 | - return array(); |
|
| 360 | - } |
|
| 361 | - while (($f = readdir($d)) !== false) { |
|
| 362 | - if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 363 | - and is_readable($f = $dir . $f) |
|
| 364 | - ) { |
|
| 365 | - require_once($f); |
|
| 366 | - $s = $s[1]; |
|
| 367 | - $v = 'spip_versions_' . $s; |
|
| 368 | - if (function_exists($v) and $v()) { |
|
| 369 | - $titre = _T("install_select_type_$s"); |
|
| 370 | - // proposer mysql par defaut si dispo |
|
| 371 | - $checked = ($s == 'mysql' ? " checked='checked'" : ""); |
|
| 372 | - $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 373 | - . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>"; |
|
| 374 | - } else { |
|
| 375 | - spip_log("$s: portage indisponible"); |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - sort($options); |
|
| 380 | - |
|
| 381 | - return $options; |
|
| 355 | + $options = array(); |
|
| 356 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 357 | + $d = opendir($dir); |
|
| 358 | + if (!$d) { |
|
| 359 | + return array(); |
|
| 360 | + } |
|
| 361 | + while (($f = readdir($d)) !== false) { |
|
| 362 | + if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 363 | + and is_readable($f = $dir . $f) |
|
| 364 | + ) { |
|
| 365 | + require_once($f); |
|
| 366 | + $s = $s[1]; |
|
| 367 | + $v = 'spip_versions_' . $s; |
|
| 368 | + if (function_exists($v) and $v()) { |
|
| 369 | + $titre = _T("install_select_type_$s"); |
|
| 370 | + // proposer mysql par defaut si dispo |
|
| 371 | + $checked = ($s == 'mysql' ? " checked='checked'" : ""); |
|
| 372 | + $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 373 | + . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>"; |
|
| 374 | + } else { |
|
| 375 | + spip_log("$s: portage indisponible"); |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + sort($options); |
|
| 380 | + |
|
| 381 | + return $options; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | // https://code.spip.net/@install_connexion_form |
| 385 | 385 | function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) { |
| 386 | - $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 387 | - |
|
| 388 | - return generer_form_ecrire('install', ( |
|
| 389 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 390 | - . $hidden |
|
| 391 | - . (_request('echec') ? |
|
| 392 | - ("<p><b>" . _T('avis_connexion_echec_1') . |
|
| 393 | - "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>") |
|
| 394 | - : "") |
|
| 395 | - |
|
| 396 | - . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 397 | - . http_script(' |
|
| 386 | + $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 387 | + |
|
| 388 | + return generer_form_ecrire('install', ( |
|
| 389 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 390 | + . $hidden |
|
| 391 | + . (_request('echec') ? |
|
| 392 | + ("<p><b>" . _T('avis_connexion_echec_1') . |
|
| 393 | + "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>") |
|
| 394 | + : "") |
|
| 395 | + |
|
| 396 | + . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 397 | + . http_script(' |
|
| 398 | 398 | jQuery(function($) { |
| 399 | 399 | $details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur"); |
| 400 | 400 | $("input[type=hidden][name=server_db]").each(function(){ |
@@ -427,67 +427,67 @@ discard block |
||
| 427 | 427 | }); |
| 428 | 428 | });') |
| 429 | 429 | |
| 430 | - . ($server_db |
|
| 431 | - ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 432 | - . (($predef[0]) |
|
| 433 | - ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 434 | - : '') |
|
| 435 | - : ('<fieldset><legend>' |
|
| 436 | - . _T('install_select_type_db') |
|
| 437 | - . "</legend>" |
|
| 438 | - . '<p class="explication">' |
|
| 439 | - . _T('install_types_db_connus') |
|
| 440 | - // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 441 | - // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 442 | - . '</p>' |
|
| 443 | - . "\n<div class='p'>\n<ul>\n" |
|
| 444 | - . join("\n", install_select_serveur()) |
|
| 445 | - . "\n</ul>\n</div></fieldset>") |
|
| 446 | - ) |
|
| 447 | - . '<div id="install_adresse_base_hebergeur">' |
|
| 448 | - . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 449 | - . ($predef[1] |
|
| 450 | - ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 451 | - : fieldset(_T('entree_base_donnee_1'), |
|
| 452 | - array( |
|
| 453 | - 'adresse_db' => array( |
|
| 454 | - 'label' => $db[1], |
|
| 455 | - 'valeur' => $db[0] |
|
| 456 | - ), |
|
| 457 | - ) |
|
| 458 | - ) |
|
| 459 | - ) |
|
| 460 | - . '</div>' |
|
| 461 | - |
|
| 462 | - . '<div id="install_login_base_hebergeur">' |
|
| 463 | - . ($predef[2] |
|
| 464 | - ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 465 | - : fieldset(_T('entree_login_connexion_1'), |
|
| 466 | - array( |
|
| 467 | - 'login_db' => array( |
|
| 468 | - 'label' => $login[1], |
|
| 469 | - 'valeur' => $login[0] |
|
| 470 | - ), |
|
| 471 | - ) |
|
| 472 | - ) |
|
| 473 | - ) |
|
| 474 | - . '</div>' |
|
| 475 | - |
|
| 476 | - . '<div id="install_pass_base_hebergeur">' |
|
| 477 | - . ($predef[3] |
|
| 478 | - ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 479 | - : fieldset(_T('entree_mot_passe_1'), |
|
| 480 | - array( |
|
| 481 | - 'pass_db' => array( |
|
| 482 | - 'label' => $pass[1], |
|
| 483 | - 'valeur' => $pass[0] |
|
| 484 | - ), |
|
| 485 | - ) |
|
| 486 | - ) |
|
| 487 | - ) |
|
| 488 | - . '</div>' |
|
| 489 | - |
|
| 490 | - . bouton_suivant())); |
|
| 430 | + . ($server_db |
|
| 431 | + ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 432 | + . (($predef[0]) |
|
| 433 | + ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 434 | + : '') |
|
| 435 | + : ('<fieldset><legend>' |
|
| 436 | + . _T('install_select_type_db') |
|
| 437 | + . "</legend>" |
|
| 438 | + . '<p class="explication">' |
|
| 439 | + . _T('install_types_db_connus') |
|
| 440 | + // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 441 | + // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 442 | + . '</p>' |
|
| 443 | + . "\n<div class='p'>\n<ul>\n" |
|
| 444 | + . join("\n", install_select_serveur()) |
|
| 445 | + . "\n</ul>\n</div></fieldset>") |
|
| 446 | + ) |
|
| 447 | + . '<div id="install_adresse_base_hebergeur">' |
|
| 448 | + . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 449 | + . ($predef[1] |
|
| 450 | + ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 451 | + : fieldset(_T('entree_base_donnee_1'), |
|
| 452 | + array( |
|
| 453 | + 'adresse_db' => array( |
|
| 454 | + 'label' => $db[1], |
|
| 455 | + 'valeur' => $db[0] |
|
| 456 | + ), |
|
| 457 | + ) |
|
| 458 | + ) |
|
| 459 | + ) |
|
| 460 | + . '</div>' |
|
| 461 | + |
|
| 462 | + . '<div id="install_login_base_hebergeur">' |
|
| 463 | + . ($predef[2] |
|
| 464 | + ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 465 | + : fieldset(_T('entree_login_connexion_1'), |
|
| 466 | + array( |
|
| 467 | + 'login_db' => array( |
|
| 468 | + 'label' => $login[1], |
|
| 469 | + 'valeur' => $login[0] |
|
| 470 | + ), |
|
| 471 | + ) |
|
| 472 | + ) |
|
| 473 | + ) |
|
| 474 | + . '</div>' |
|
| 475 | + |
|
| 476 | + . '<div id="install_pass_base_hebergeur">' |
|
| 477 | + . ($predef[3] |
|
| 478 | + ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 479 | + : fieldset(_T('entree_mot_passe_1'), |
|
| 480 | + array( |
|
| 481 | + 'pass_db' => array( |
|
| 482 | + 'label' => $pass[1], |
|
| 483 | + 'valeur' => $pass[0] |
|
| 484 | + ), |
|
| 485 | + ) |
|
| 486 | + ) |
|
| 487 | + ) |
|
| 488 | + . '</div>' |
|
| 489 | + |
|
| 490 | + . bouton_suivant())); |
|
| 491 | 491 | |
| 492 | 492 | } |
| 493 | 493 | |
@@ -496,75 +496,75 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | // https://code.spip.net/@predef_ou_cache |
| 498 | 498 | function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) { |
| 499 | - return ((defined('_INSTALL_HOST_DB')) |
|
| 500 | - ? '' |
|
| 501 | - : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . "\" />" |
|
| 502 | - ) |
|
| 503 | - . ((defined('_INSTALL_USER_DB')) |
|
| 504 | - ? '' |
|
| 505 | - : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />" |
|
| 506 | - ) |
|
| 507 | - . ((defined('_INSTALL_PASS_DB')) |
|
| 508 | - ? '' |
|
| 509 | - : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />" |
|
| 510 | - ) |
|
| 511 | - |
|
| 512 | - . ((defined('_INSTALL_SERVER_DB')) |
|
| 513 | - ? '' |
|
| 514 | - : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />" |
|
| 515 | - ); |
|
| 499 | + return ((defined('_INSTALL_HOST_DB')) |
|
| 500 | + ? '' |
|
| 501 | + : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . "\" />" |
|
| 502 | + ) |
|
| 503 | + . ((defined('_INSTALL_USER_DB')) |
|
| 504 | + ? '' |
|
| 505 | + : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />" |
|
| 506 | + ) |
|
| 507 | + . ((defined('_INSTALL_PASS_DB')) |
|
| 508 | + ? '' |
|
| 509 | + : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />" |
|
| 510 | + ) |
|
| 511 | + |
|
| 512 | + . ((defined('_INSTALL_SERVER_DB')) |
|
| 513 | + ? '' |
|
| 514 | + : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />" |
|
| 515 | + ); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // presentation des bases existantes |
| 519 | 519 | |
| 520 | 520 | // https://code.spip.net/@install_etape_liste_bases |
| 521 | 521 | function install_etape_liste_bases($server_db, $login_db, $disabled = array()) { |
| 522 | - $bases = $checked = array(); |
|
| 523 | - $noms = sql_listdbs($server_db); |
|
| 524 | - if (!$noms) { |
|
| 525 | - return ''; |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - foreach ($noms as $nom) { |
|
| 529 | - $id = spip_htmlspecialchars($nom); |
|
| 530 | - $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 531 | - $base = " name=\"choix_db\" value=\"" |
|
| 532 | - . $nom |
|
| 533 | - . '"' |
|
| 534 | - . $dis |
|
| 535 | - . " type='radio' id='$id'"; |
|
| 536 | - $label = "<label for='$id'>" |
|
| 537 | - . ($dis ? "<i>$nom</i>" : $nom) |
|
| 538 | - . "</label>"; |
|
| 539 | - |
|
| 540 | - if (!$checked and !$dis and |
|
| 541 | - (($nom == $login_db) or |
|
| 542 | - ($GLOBALS['table_prefix'] == $nom)) |
|
| 543 | - ) { |
|
| 544 | - $checked = "<input$base checked='checked' />\n$label"; |
|
| 545 | - } else { |
|
| 546 | - $bases[] = "<input$base />\n$label"; |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - if (!$bases && !$checked) { |
|
| 551 | - return false; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - if ($checked) { |
|
| 555 | - array_unshift($bases, $checked); |
|
| 556 | - $checked = true; |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - return array($checked, $bases); |
|
| 522 | + $bases = $checked = array(); |
|
| 523 | + $noms = sql_listdbs($server_db); |
|
| 524 | + if (!$noms) { |
|
| 525 | + return ''; |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + foreach ($noms as $nom) { |
|
| 529 | + $id = spip_htmlspecialchars($nom); |
|
| 530 | + $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 531 | + $base = " name=\"choix_db\" value=\"" |
|
| 532 | + . $nom |
|
| 533 | + . '"' |
|
| 534 | + . $dis |
|
| 535 | + . " type='radio' id='$id'"; |
|
| 536 | + $label = "<label for='$id'>" |
|
| 537 | + . ($dis ? "<i>$nom</i>" : $nom) |
|
| 538 | + . "</label>"; |
|
| 539 | + |
|
| 540 | + if (!$checked and !$dis and |
|
| 541 | + (($nom == $login_db) or |
|
| 542 | + ($GLOBALS['table_prefix'] == $nom)) |
|
| 543 | + ) { |
|
| 544 | + $checked = "<input$base checked='checked' />\n$label"; |
|
| 545 | + } else { |
|
| 546 | + $bases[] = "<input$base />\n$label"; |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + if (!$bases && !$checked) { |
|
| 551 | + return false; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + if ($checked) { |
|
| 555 | + array_unshift($bases, $checked); |
|
| 556 | + $checked = true; |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + return array($checked, $bases); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | function install_propager($hidden) { |
| 563 | - $res = ''; |
|
| 564 | - foreach ($hidden as $k) { |
|
| 565 | - $v = spip_htmlentities(_request($k)); |
|
| 566 | - $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 567 | - } |
|
| 563 | + $res = ''; |
|
| 564 | + foreach ($hidden as $k) { |
|
| 565 | + $v = spip_htmlentities(_request($k)); |
|
| 566 | + $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | - return $res; |
|
| 569 | + return $res; |
|
| 570 | 570 | } |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | **/ |
| 45 | 45 | function install_fichier_connexion($nom, $texte) { |
| 46 | - $texte = "<" . "?php\n" |
|
| 46 | + $texte = "<"."?php\n" |
|
| 47 | 47 | . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
| 48 | 48 | . $texte |
| 49 | - . "?" . ">"; |
|
| 49 | + . "?".">"; |
|
| 50 | 50 | |
| 51 | 51 | ecrire_fichier($nom, $texte); |
| 52 | 52 | } |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | return $regs; |
| 114 | 114 | } else { |
| 115 | 115 | $ar = '\s*\'([^\']*)\''; |
| 116 | - $r = '\s*,' . $ar; |
|
| 116 | + $r = '\s*,'.$ar; |
|
| 117 | 117 | $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
| 118 | 118 | if (preg_match($r, $s, $regs)) { |
| 119 | - $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";"); |
|
| 119 | + $regs[2] = $regs[1].(!$regs[2] ? '' : ":".$regs[2].";"); |
|
| 120 | 120 | array_shift($regs); |
| 121 | 121 | array_shift($regs); |
| 122 | 122 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | // Si on n'a pas la bonne version de PHP, c'est la fin |
| 175 | 175 | if ($err) { |
| 176 | 176 | die("<div class='error'>" |
| 177 | - . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 177 | + . "<h3>"._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>" |
|
| 178 | 178 | . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | if ($err) { |
| 203 | 203 | echo "<div class='error'>" |
| 204 | - . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 204 | + . "<h3>"._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>"; |
|
| 205 | 205 | foreach ($err as $e) { |
| 206 | 206 | echo "<li><strong>$e</strong></li>\n"; |
| 207 | 207 | } |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | // https://code.spip.net/@info_etape |
| 237 | 237 | function info_etape($titre, $complement = '') { |
| 238 | - return "<h2>" . $titre . "</h2>\n" . |
|
| 239 | - ($complement ? "" . $complement . "\n" : ''); |
|
| 238 | + return "<h2>".$titre."</h2>\n". |
|
| 239 | + ($complement ? "".$complement."\n" : ''); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -250,18 +250,18 @@ discard block |
||
| 250 | 250 | $code = _T('bouton_suivant'); |
| 251 | 251 | } |
| 252 | 252 | static $suivant = 0; |
| 253 | - $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 253 | + $id = 'suivant'.(($suivant > 0) ? strval($suivant) : ''); |
|
| 254 | 254 | $suivant += 1; |
| 255 | 255 | |
| 256 | - return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 257 | - $code . |
|
| 256 | + return "\n<p class='boutons suivant'><input id='".$id."' type='submit'\nvalue=\"". |
|
| 257 | + $code. |
|
| 258 | 258 | " >>\" /></p>\n"; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // https://code.spip.net/@info_progression_etape |
| 262 | 262 | function info_progression_etape($en_cours, $phase, $dir, $erreur = false) { |
| 263 | 263 | //$en_cours = _request('etape')?_request('etape'):""; |
| 264 | - $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 264 | + $liste = find_all_in_path($dir, $phase.'(([0-9])+|fin)[.]php$'); |
|
| 265 | 265 | $debut = 1; |
| 266 | 266 | $etat = "ok"; |
| 267 | 267 | $last = count($liste); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | $aff_etapes .= "<li class='$class'><div class='fond'>"; |
| 302 | 302 | $aff_etapes .= ($debut == $en_cours) ? "<strong>" : ''; |
| 303 | - $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 303 | + $aff_etapes .= "<em>"._T('etape')." </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 304 | 304 | $aff_etapes .= $intitule_etat["$phase"][$debut]; |
| 305 | 305 | $aff_etapes .= ($debut == $en_cours) ? "</strong>" : ''; |
| 306 | 306 | $aff_etapes .= "</div></li>"; |
@@ -316,11 +316,11 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // https://code.spip.net/@fieldset |
| 318 | 318 | function fieldset($legend, $champs = array(), $apres = '', $avant = '') { |
| 319 | - return "<fieldset>\n" . |
|
| 320 | - $avant . |
|
| 321 | - ($legend ? "<legend>" . $legend . "</legend>\n" : '') . |
|
| 322 | - fieldset_champs($champs) . |
|
| 323 | - $apres . |
|
| 319 | + return "<fieldset>\n". |
|
| 320 | + $avant. |
|
| 321 | + ($legend ? "<legend>".$legend."</legend>\n" : ''). |
|
| 322 | + fieldset_champs($champs). |
|
| 323 | + $apres. |
|
| 324 | 324 | "</fieldset>\n"; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -330,18 +330,18 @@ discard block |
||
| 330 | 330 | $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
| 331 | 331 | $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
| 332 | 332 | if (isset($contenu['alternatives'])) { |
| 333 | - $fieldset .= $contenu['label'] . "\n"; |
|
| 333 | + $fieldset .= $contenu['label']."\n"; |
|
| 334 | 334 | foreach ($contenu['alternatives'] as $valeur => $label) { |
| 335 | - $fieldset .= "<input type='radio' name='" . $nom . |
|
| 335 | + $fieldset .= "<input type='radio' name='".$nom. |
|
| 336 | 336 | "' id='$nom-$valeur' value='$valeur'" |
| 337 | 337 | . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
| 338 | 338 | . "/>\n"; |
| 339 | - $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 339 | + $fieldset .= "<label for='$nom-$valeur'>".$label."</label>\n"; |
|
| 340 | 340 | } |
| 341 | 341 | $fieldset .= "<br />\n"; |
| 342 | 342 | } else { |
| 343 | - $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 344 | - $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 343 | + $fieldset .= "<label for='".$nom."'>".$contenu['label']."</label>\n"; |
|
| 344 | + $fieldset .= "<input ".$class."type='".$type."' id='".$nom."' name='".$nom."'\nvalue='".$contenu['valeur']."'" |
|
| 345 | 345 | . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
| 346 | 346 | . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "") |
| 347 | 347 | . " />\n"; |
@@ -353,24 +353,24 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | function install_select_serveur() { |
| 355 | 355 | $options = array(); |
| 356 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 356 | + $dir = _DIR_RESTREINT.'req/'; |
|
| 357 | 357 | $d = opendir($dir); |
| 358 | 358 | if (!$d) { |
| 359 | 359 | return array(); |
| 360 | 360 | } |
| 361 | 361 | while (($f = readdir($d)) !== false) { |
| 362 | 362 | if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
| 363 | - and is_readable($f = $dir . $f) |
|
| 363 | + and is_readable($f = $dir.$f) |
|
| 364 | 364 | ) { |
| 365 | 365 | require_once($f); |
| 366 | 366 | $s = $s[1]; |
| 367 | - $v = 'spip_versions_' . $s; |
|
| 367 | + $v = 'spip_versions_'.$s; |
|
| 368 | 368 | if (function_exists($v) and $v()) { |
| 369 | 369 | $titre = _T("install_select_type_$s"); |
| 370 | 370 | // proposer mysql par defaut si dispo |
| 371 | 371 | $checked = ($s == 'mysql' ? " checked='checked'" : ""); |
| 372 | 372 | $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
| 373 | - . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>"; |
|
| 373 | + . "<label for='$s'>".($titre ? $titre : $s)."</label></li>"; |
|
| 374 | 374 | } else { |
| 375 | 375 | spip_log("$s: portage indisponible"); |
| 376 | 376 | } |
@@ -389,8 +389,8 @@ discard block |
||
| 389 | 389 | "\n<input type='hidden' name='etape' value='$etape' />" |
| 390 | 390 | . $hidden |
| 391 | 391 | . (_request('echec') ? |
| 392 | - ("<p><b>" . _T('avis_connexion_echec_1') . |
|
| 393 | - "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>") |
|
| 392 | + ("<p><b>"._T('avis_connexion_echec_1'). |
|
| 393 | + "</b></p><p>"._T('avis_connexion_echec_2')."</p><p style='font-size: small;'>"._T('avis_connexion_echec_3')."</p>") |
|
| 394 | 394 | : "") |
| 395 | 395 | |
| 396 | 396 | . ($jquery ? http_script('', 'jquery.js') : '') |
@@ -428,9 +428,9 @@ discard block |
||
| 428 | 428 | });') |
| 429 | 429 | |
| 430 | 430 | . ($server_db |
| 431 | - ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 431 | + ? '<input type="hidden" name="server_db" value="'.$server_db.'" />' |
|
| 432 | 432 | . (($predef[0]) |
| 433 | - ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 433 | + ? ('<h3>'._T('install_serveur_hebergeur').'</h3>') |
|
| 434 | 434 | : '') |
| 435 | 435 | : ('<fieldset><legend>' |
| 436 | 436 | . _T('install_select_type_db') |
@@ -445,9 +445,9 @@ discard block |
||
| 445 | 445 | . "\n</ul>\n</div></fieldset>") |
| 446 | 446 | ) |
| 447 | 447 | . '<div id="install_adresse_base_hebergeur">' |
| 448 | - . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 448 | + . '<p>'._T('texte_connexion_mysql').'</p>' |
|
| 449 | 449 | . ($predef[1] |
| 450 | - ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 450 | + ? '<h3>'._T('install_adresse_base_hebergeur').'</h3>' |
|
| 451 | 451 | : fieldset(_T('entree_base_donnee_1'), |
| 452 | 452 | array( |
| 453 | 453 | 'adresse_db' => array( |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | . '<div id="install_login_base_hebergeur">' |
| 463 | 463 | . ($predef[2] |
| 464 | - ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 464 | + ? '<h3>'._T('install_login_base_hebergeur').'</h3>' |
|
| 465 | 465 | : fieldset(_T('entree_login_connexion_1'), |
| 466 | 466 | array( |
| 467 | 467 | 'login_db' => array( |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | . '<div id="install_pass_base_hebergeur">' |
| 477 | 477 | . ($predef[3] |
| 478 | - ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 478 | + ? '<h3>'._T('install_pass_base_hebergeur').'</h3>' |
|
| 479 | 479 | : fieldset(_T('entree_mot_passe_1'), |
| 480 | 480 | array( |
| 481 | 481 | 'pass_db' => array( |
@@ -498,20 +498,20 @@ discard block |
||
| 498 | 498 | function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) { |
| 499 | 499 | return ((defined('_INSTALL_HOST_DB')) |
| 500 | 500 | ? '' |
| 501 | - : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . "\" />" |
|
| 501 | + : "\n<input type='hidden' name='adresse_db' value=\"".spip_htmlspecialchars($adresse_db)."\" />" |
|
| 502 | 502 | ) |
| 503 | 503 | . ((defined('_INSTALL_USER_DB')) |
| 504 | 504 | ? '' |
| 505 | - : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />" |
|
| 505 | + : "\n<input type='hidden' name='login_db' value=\"".spip_htmlspecialchars($login_db)."\" />" |
|
| 506 | 506 | ) |
| 507 | 507 | . ((defined('_INSTALL_PASS_DB')) |
| 508 | 508 | ? '' |
| 509 | - : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />" |
|
| 509 | + : "\n<input type='hidden' name='pass_db' value=\"".spip_htmlspecialchars($pass_db)."\" />" |
|
| 510 | 510 | ) |
| 511 | 511 | |
| 512 | 512 | . ((defined('_INSTALL_SERVER_DB')) |
| 513 | 513 | ? '' |
| 514 | - : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />" |
|
| 514 | + : "\n<input type='hidden' name='server_db' value=\"".spip_htmlspecialchars($server_db)."\" />" |
|
| 515 | 515 | ); |
| 516 | 516 | } |
| 517 | 517 | |
@@ -42,6 +42,9 @@ discard block |
||
| 42 | 42 | define('_RACCOURCI_LIEN', "/\[([^][]*?([[]\w*[]][^][]*)*)->(>?)([^]]*)\]/msS"); |
| 43 | 43 | |
| 44 | 44 | // https://code.spip.net/@expanser_liens |
| 45 | +/** |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 45 | 48 | function expanser_liens($t, $connect = '', $env = array()) { |
| 46 | 49 | |
| 47 | 50 | $t = pipeline('pre_liens', $t); |
@@ -56,6 +59,9 @@ discard block |
||
| 56 | 59 | // Meme analyse mais pour eliminer les liens |
| 57 | 60 | // et ne laisser que leur titre, a expliciter si ce n'est fait |
| 58 | 61 | // https://code.spip.net/@nettoyer_raccourcis_typo |
| 62 | +/** |
|
| 63 | + * @param string $texte |
|
| 64 | + */ |
|
| 59 | 65 | function nettoyer_raccourcis_typo($texte, $connect = '') { |
| 60 | 66 | return $texte; |
| 61 | 67 | } |
@@ -96,6 +102,9 @@ discard block |
||
| 96 | 102 | // 'url': seulement U (i.e. generer_url_RACCOURCI) |
| 97 | 103 | |
| 98 | 104 | // https://code.spip.net/@calculer_url |
| 105 | +/** |
|
| 106 | + * @return string |
|
| 107 | + */ |
|
| 99 | 108 | function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 100 | 109 | $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
| 101 | 110 | |
@@ -256,7 +265,7 @@ discard block |
||
| 256 | 265 | * @param int $id Identifiant de l'objet |
| 257 | 266 | * @param string $type Type d'objet |
| 258 | 267 | * @param string|null $connect Connecteur SQL utilisé |
| 259 | - * @return array { |
|
| 268 | + * @return string { |
|
| 260 | 269 | * @var string $titre Titre si présent, sinon '' |
| 261 | 270 | * @var string $lang Langue si présente, sinon '' |
| 262 | 271 | * } |
@@ -302,6 +311,9 @@ discard block |
||
| 302 | 311 | define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
| 303 | 312 | |
| 304 | 313 | // https://code.spip.net/@traiter_modeles |
| 314 | +/** |
|
| 315 | + * @return string |
|
| 316 | + */ |
|
| 305 | 317 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) { |
| 306 | 318 | // preserver la compatibilite : true = recherche des documents |
| 307 | 319 | if ($doublons === true) { |
@@ -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_spip('base/abstract_sql'); |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | // |
| 24 | 24 | |
| 25 | 25 | function inc_lien_dist( |
| 26 | - $lien, |
|
| 27 | - $texte = '', |
|
| 28 | - $class = '', |
|
| 29 | - $title = '', |
|
| 30 | - $hlang = '', |
|
| 31 | - $rel = '', |
|
| 32 | - $connect = '', |
|
| 33 | - $env = array() |
|
| 26 | + $lien, |
|
| 27 | + $texte = '', |
|
| 28 | + $class = '', |
|
| 29 | + $title = '', |
|
| 30 | + $hlang = '', |
|
| 31 | + $rel = '', |
|
| 32 | + $connect = '', |
|
| 33 | + $env = array() |
|
| 34 | 34 | ) { |
| 35 | - return $lien; |
|
| 35 | + return $lien; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
@@ -44,30 +44,30 @@ discard block |
||
| 44 | 44 | // https://code.spip.net/@expanser_liens |
| 45 | 45 | function expanser_liens($t, $connect = '', $env = array()) { |
| 46 | 46 | |
| 47 | - $t = pipeline('pre_liens', $t); |
|
| 47 | + $t = pipeline('pre_liens', $t); |
|
| 48 | 48 | |
| 49 | - // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 50 | - // de remettre le texte d'origine dans les parametres du modele |
|
| 51 | - $t = traiter_modeles($t, false, false, $connect); |
|
| 49 | + // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 50 | + // de remettre le texte d'origine dans les parametres du modele |
|
| 51 | + $t = traiter_modeles($t, false, false, $connect); |
|
| 52 | 52 | |
| 53 | - return $t; |
|
| 53 | + return $t; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Meme analyse mais pour eliminer les liens |
| 57 | 57 | // et ne laisser que leur titre, a expliciter si ce n'est fait |
| 58 | 58 | // https://code.spip.net/@nettoyer_raccourcis_typo |
| 59 | 59 | function nettoyer_raccourcis_typo($texte, $connect = '') { |
| 60 | - return $texte; |
|
| 60 | + return $texte; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Repere dans la partie texte d'un raccourci [texte->...] |
| 64 | 64 | // la langue et la bulle eventuelles |
| 65 | 65 | // https://code.spip.net/@traiter_raccourci_lien_atts |
| 66 | 66 | function traiter_raccourci_lien_atts($texte) { |
| 67 | - $bulle = ''; |
|
| 68 | - $hlang = ''; |
|
| 67 | + $bulle = ''; |
|
| 68 | + $hlang = ''; |
|
| 69 | 69 | |
| 70 | - return array(trim($texte), $bulle, $hlang); |
|
| 70 | + return array(trim($texte), $bulle, $hlang); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/'); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | function virtuel_redirige($virtuel, $url = false) { |
| 86 | - return $virtuel; |
|
| 86 | + return $virtuel; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Cherche un lien du type [->raccourci 123] |
@@ -97,114 +97,114 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | // https://code.spip.net/@calculer_url |
| 99 | 99 | function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 100 | - $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 100 | + $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 101 | 101 | |
| 102 | - return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 102 | + return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
| 106 | 106 | |
| 107 | 107 | // https://code.spip.net/@traiter_lien_explicite |
| 108 | 108 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 109 | - if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 110 | - return ($pour != 'tout') ? '' : array('', '', '', ''); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $lien = entites_html(trim($ref)); |
|
| 114 | - |
|
| 115 | - // Liens explicites |
|
| 116 | - if (!$texte) { |
|
| 117 | - $texte = str_replace('"', '', $lien); |
|
| 118 | - // evite l'affichage de trops longues urls. |
|
| 119 | - $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 120 | - $texte = $lien_court($texte); |
|
| 121 | - if ($echappe_typo) { |
|
| 122 | - $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // petites corrections d'URL |
|
| 127 | - if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 128 | - $lien = "http://" . $lien; |
|
| 129 | - } else { |
|
| 130 | - if (strpos($lien, "@") && email_valide($lien)) { |
|
| 131 | - if (!$texte) { |
|
| 132 | - $texte = $lien; |
|
| 133 | - } |
|
| 134 | - $lien = "mailto:" . $lien; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ($pour == 'url') { |
|
| 139 | - return $lien; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - if ($pour == 'titre') { |
|
| 143 | - return $texte; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return array('url' => $lien, 'titre' => $texte); |
|
| 109 | + if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 110 | + return ($pour != 'tout') ? '' : array('', '', '', ''); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $lien = entites_html(trim($ref)); |
|
| 114 | + |
|
| 115 | + // Liens explicites |
|
| 116 | + if (!$texte) { |
|
| 117 | + $texte = str_replace('"', '', $lien); |
|
| 118 | + // evite l'affichage de trops longues urls. |
|
| 119 | + $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 120 | + $texte = $lien_court($texte); |
|
| 121 | + if ($echappe_typo) { |
|
| 122 | + $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // petites corrections d'URL |
|
| 127 | + if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 128 | + $lien = "http://" . $lien; |
|
| 129 | + } else { |
|
| 130 | + if (strpos($lien, "@") && email_valide($lien)) { |
|
| 131 | + if (!$texte) { |
|
| 132 | + $texte = $lien; |
|
| 133 | + } |
|
| 134 | + $lien = "mailto:" . $lien; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ($pour == 'url') { |
|
| 139 | + return $lien; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + if ($pour == 'titre') { |
|
| 143 | + return $texte; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return array('url' => $lien, 'titre' => $texte); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') { |
| 150 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 151 | - $url = $f($texte, $id); |
|
| 152 | - } else { |
|
| 153 | - $url = glossaire_std($texte); |
|
| 154 | - } |
|
| 150 | + if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 151 | + $url = $f($texte, $id); |
|
| 152 | + } else { |
|
| 153 | + $url = glossaire_std($texte); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - return $url; |
|
| 156 | + return $url; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // https://code.spip.net/@traiter_lien_implicite |
| 160 | 160 | function traiter_lien_implicite($ref, $texte = '', $pour = 'url', $connect = '') { |
| 161 | - if (!($match = typer_raccourci($ref))) { |
|
| 162 | - return false; |
|
| 163 | - } |
|
| 164 | - @list($type, , $id, , $args, , $ancre) = $match; |
|
| 165 | - // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 166 | - // la page locale du site, mais directement sur le site lui-meme |
|
| 167 | - if ($f = charger_fonction("implicite_$type", "liens", true)) { |
|
| 168 | - $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 169 | - } |
|
| 170 | - if (!$url) { |
|
| 171 | - $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 172 | - } |
|
| 173 | - if (!$url) { |
|
| 174 | - return false; |
|
| 175 | - } |
|
| 176 | - if (is_array($url)) { |
|
| 177 | - @list($type, $id) = $url; |
|
| 178 | - $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 179 | - } |
|
| 180 | - if ($pour === 'url') { |
|
| 181 | - return $url; |
|
| 182 | - } |
|
| 183 | - $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 184 | - if ($r) { |
|
| 185 | - $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 186 | - } |
|
| 187 | - if ($texte = trim($texte)) { |
|
| 188 | - $r['titre'] = $texte; |
|
| 189 | - } |
|
| 190 | - if (!@$r['titre']) { |
|
| 191 | - $r['titre'] = _T($type) . " $id"; |
|
| 192 | - } |
|
| 193 | - if ($pour == 'titre') { |
|
| 194 | - return $r['titre']; |
|
| 195 | - } |
|
| 196 | - $r['url'] = $url; |
|
| 197 | - |
|
| 198 | - // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 199 | - if ($type == 'document' |
|
| 200 | - and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
|
| 201 | - "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 202 | - '', '', '', '', $connect) |
|
| 203 | - ) { |
|
| 204 | - $r['mime'] = $mime; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - return $r; |
|
| 161 | + if (!($match = typer_raccourci($ref))) { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | + @list($type, , $id, , $args, , $ancre) = $match; |
|
| 165 | + // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 166 | + // la page locale du site, mais directement sur le site lui-meme |
|
| 167 | + if ($f = charger_fonction("implicite_$type", "liens", true)) { |
|
| 168 | + $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 169 | + } |
|
| 170 | + if (!$url) { |
|
| 171 | + $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 172 | + } |
|
| 173 | + if (!$url) { |
|
| 174 | + return false; |
|
| 175 | + } |
|
| 176 | + if (is_array($url)) { |
|
| 177 | + @list($type, $id) = $url; |
|
| 178 | + $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 179 | + } |
|
| 180 | + if ($pour === 'url') { |
|
| 181 | + return $url; |
|
| 182 | + } |
|
| 183 | + $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 184 | + if ($r) { |
|
| 185 | + $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 186 | + } |
|
| 187 | + if ($texte = trim($texte)) { |
|
| 188 | + $r['titre'] = $texte; |
|
| 189 | + } |
|
| 190 | + if (!@$r['titre']) { |
|
| 191 | + $r['titre'] = _T($type) . " $id"; |
|
| 192 | + } |
|
| 193 | + if ($pour == 'titre') { |
|
| 194 | + return $r['titre']; |
|
| 195 | + } |
|
| 196 | + $r['url'] = $url; |
|
| 197 | + |
|
| 198 | + // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 199 | + if ($type == 'document' |
|
| 200 | + and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
|
| 201 | + "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 202 | + '', '', '', '', $connect) |
|
| 203 | + ) { |
|
| 204 | + $r['mime'] = $mime; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + return $r; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes |
@@ -213,41 +213,41 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | // https://code.spip.net/@typer_raccourci |
| 215 | 215 | function typer_raccourci($lien) { |
| 216 | - if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 217 | - return array(); |
|
| 218 | - } |
|
| 219 | - $f = $match[1]; |
|
| 220 | - // valeur par defaut et alias historiques |
|
| 221 | - if (!$f) { |
|
| 222 | - $f = 'article'; |
|
| 223 | - } else { |
|
| 224 | - if ($f == 'art') { |
|
| 225 | - $f = 'article'; |
|
| 226 | - } else { |
|
| 227 | - if ($f == 'br') { |
|
| 228 | - $f = 'breve'; |
|
| 229 | - } else { |
|
| 230 | - if ($f == 'rub') { |
|
| 231 | - $f = 'rubrique'; |
|
| 232 | - } else { |
|
| 233 | - if ($f == 'aut') { |
|
| 234 | - $f = 'auteur'; |
|
| 235 | - } else { |
|
| 236 | - if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 237 | - $f = 'document'; |
|
| 238 | - } else { |
|
| 239 | - if (preg_match('/^br..?ve$/S', $f)) { |
|
| 240 | - $f = 'breve'; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } # accents :( |
|
| 248 | - $match[0] = $f; |
|
| 249 | - |
|
| 250 | - return $match; |
|
| 216 | + if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 217 | + return array(); |
|
| 218 | + } |
|
| 219 | + $f = $match[1]; |
|
| 220 | + // valeur par defaut et alias historiques |
|
| 221 | + if (!$f) { |
|
| 222 | + $f = 'article'; |
|
| 223 | + } else { |
|
| 224 | + if ($f == 'art') { |
|
| 225 | + $f = 'article'; |
|
| 226 | + } else { |
|
| 227 | + if ($f == 'br') { |
|
| 228 | + $f = 'breve'; |
|
| 229 | + } else { |
|
| 230 | + if ($f == 'rub') { |
|
| 231 | + $f = 'rubrique'; |
|
| 232 | + } else { |
|
| 233 | + if ($f == 'aut') { |
|
| 234 | + $f = 'auteur'; |
|
| 235 | + } else { |
|
| 236 | + if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 237 | + $f = 'document'; |
|
| 238 | + } else { |
|
| 239 | + if (preg_match('/^br..?ve$/S', $f)) { |
|
| 240 | + $f = 'breve'; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } # accents :( |
|
| 248 | + $match[0] = $f; |
|
| 249 | + |
|
| 250 | + return $match; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -262,25 +262,25 @@ discard block |
||
| 262 | 262 | * } |
| 263 | 263 | **/ |
| 264 | 264 | function traiter_raccourci_titre($id, $type, $connect = null) { |
| 265 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 266 | - $desc = $trouver_table(table_objet($type)); |
|
| 267 | - if (!($desc and $s = $desc['titre'])) { |
|
| 268 | - return array(); |
|
| 269 | - } |
|
| 270 | - $_id = $desc['key']['PRIMARY KEY']; |
|
| 271 | - $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 272 | - if (!$r) { |
|
| 273 | - return array(); |
|
| 274 | - } |
|
| 275 | - $r['titre'] = supprimer_numero($r['titre']); |
|
| 276 | - if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 277 | - $r['titre'] = $r['surnom']; |
|
| 278 | - } |
|
| 279 | - if (!isset($r['lang'])) { |
|
| 280 | - $r['lang'] = ''; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - return $r; |
|
| 265 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 266 | + $desc = $trouver_table(table_objet($type)); |
|
| 267 | + if (!($desc and $s = $desc['titre'])) { |
|
| 268 | + return array(); |
|
| 269 | + } |
|
| 270 | + $_id = $desc['key']['PRIMARY KEY']; |
|
| 271 | + $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 272 | + if (!$r) { |
|
| 273 | + return array(); |
|
| 274 | + } |
|
| 275 | + $r['titre'] = supprimer_numero($r['titre']); |
|
| 276 | + if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 277 | + $r['titre'] = $r['surnom']; |
|
| 278 | + } |
|
| 279 | + if (!isset($r['lang'])) { |
|
| 280 | + $r['lang'] = ''; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + return $r; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // traite les modeles (dans la fonction typo), en remplacant |
@@ -292,115 +292,115 @@ discard block |
||
| 292 | 292 | // https://code.spip.net/@traiter_modeles |
| 293 | 293 | |
| 294 | 294 | define('_RACCOURCI_MODELE', |
| 295 | - '(<([a-z_-]{3,})' # <modele |
|
| 296 | - . '\s*([0-9]*)\s*' # id |
|
| 297 | - . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 298 | - . '\s*/?' . '>)' # fin du modele > |
|
| 299 | - . '\s*(<\/a>)?' # eventuel </a> |
|
| 295 | + '(<([a-z_-]{3,})' # <modele |
|
| 296 | + . '\s*([0-9]*)\s*' # id |
|
| 297 | + . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 298 | + . '\s*/?' . '>)' # fin du modele > |
|
| 299 | + . '\s*(<\/a>)?' # eventuel </a> |
|
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | 302 | define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
| 303 | 303 | |
| 304 | 304 | // https://code.spip.net/@traiter_modeles |
| 305 | 305 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) { |
| 306 | - // preserver la compatibilite : true = recherche des documents |
|
| 307 | - if ($doublons === true) { |
|
| 308 | - $doublons = array('documents' => array('doc', 'emb', 'img')); |
|
| 309 | - } |
|
| 310 | - // detecter les modeles (rapide) |
|
| 311 | - if (strpos($texte, "<") !== false and |
|
| 312 | - preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 313 | - ) { |
|
| 314 | - include_spip('public/assembler'); |
|
| 315 | - $wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true); |
|
| 316 | - foreach ($matches as $match) { |
|
| 317 | - // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 318 | - |
|
| 319 | - $a = strpos($texte, $match[0]); |
|
| 320 | - preg_match(_RACCOURCI_MODELE_DEBUT, |
|
| 321 | - substr($texte, $a), $regs); |
|
| 322 | - $regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 323 | - list(, $mod, $type, $id, $params, $fin) = $regs; |
|
| 324 | - if ($fin and |
|
| 325 | - preg_match('/<a\s[^<>]*>\s*$/i', |
|
| 326 | - substr($texte, 0, $a), $r) |
|
| 327 | - ) { |
|
| 328 | - $lien = array( |
|
| 329 | - 'href' => extraire_attribut($r[0], 'href'), |
|
| 330 | - 'class' => extraire_attribut($r[0], 'class'), |
|
| 331 | - 'mime' => extraire_attribut($r[0], 'type'), |
|
| 332 | - 'title' => extraire_attribut($r[0], 'title'), |
|
| 333 | - 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 334 | - ); |
|
| 335 | - $n = strlen($r[0]); |
|
| 336 | - $a -= $n; |
|
| 337 | - $cherche = $n + strlen($regs[0]); |
|
| 338 | - } else { |
|
| 339 | - $lien = false; |
|
| 340 | - $cherche = strlen($mod); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - // calculer le modele |
|
| 344 | - # hack indexation |
|
| 345 | - if ($doublons) { |
|
| 346 | - $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 347 | - } # version normale |
|
| 348 | - else { |
|
| 349 | - // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 350 | - // dans les parametres, plutot que les liens echappes |
|
| 351 | - if (!is_null($liens)) { |
|
| 352 | - $params = str_replace($liens[0], $liens[1], $params); |
|
| 353 | - } |
|
| 354 | - $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 355 | - // en cas d'echec, |
|
| 356 | - // si l'objet demande a une url, |
|
| 357 | - // creer un petit encadre vers elle |
|
| 358 | - if ($modele === false) { |
|
| 359 | - if (!$lien) { |
|
| 360 | - $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 361 | - } |
|
| 362 | - if ($lien) { |
|
| 363 | - $modele = '<a href="' |
|
| 364 | - . $lien['url'] |
|
| 365 | - . '" class="spip_modele' |
|
| 366 | - . '">' |
|
| 367 | - . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 368 | - . "</a>"; |
|
| 369 | - } else { |
|
| 370 | - $modele = ""; |
|
| 371 | - if (test_espace_prive()) { |
|
| 372 | - $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 373 | - if (!is_null($liens)) { |
|
| 374 | - $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - // le remplacer dans le texte |
|
| 380 | - if ($modele !== false) { |
|
| 381 | - $modele = protege_js_modeles($modele); |
|
| 382 | - if ($wrap_embed_html) { |
|
| 383 | - $modele = $wrap_embed_html($mod, $modele); |
|
| 384 | - } |
|
| 385 | - $rempl = code_echappement($modele, $echap); |
|
| 386 | - $texte = substr($texte, 0, $a) |
|
| 387 | - . $rempl |
|
| 388 | - . substr($texte, $a + $cherche); |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - // hack pour tout l'espace prive |
|
| 393 | - if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 394 | - foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) { |
|
| 395 | - if (in_array($type, $modeles)) { |
|
| 396 | - $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - return $texte; |
|
| 306 | + // preserver la compatibilite : true = recherche des documents |
|
| 307 | + if ($doublons === true) { |
|
| 308 | + $doublons = array('documents' => array('doc', 'emb', 'img')); |
|
| 309 | + } |
|
| 310 | + // detecter les modeles (rapide) |
|
| 311 | + if (strpos($texte, "<") !== false and |
|
| 312 | + preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 313 | + ) { |
|
| 314 | + include_spip('public/assembler'); |
|
| 315 | + $wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true); |
|
| 316 | + foreach ($matches as $match) { |
|
| 317 | + // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 318 | + |
|
| 319 | + $a = strpos($texte, $match[0]); |
|
| 320 | + preg_match(_RACCOURCI_MODELE_DEBUT, |
|
| 321 | + substr($texte, $a), $regs); |
|
| 322 | + $regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 323 | + list(, $mod, $type, $id, $params, $fin) = $regs; |
|
| 324 | + if ($fin and |
|
| 325 | + preg_match('/<a\s[^<>]*>\s*$/i', |
|
| 326 | + substr($texte, 0, $a), $r) |
|
| 327 | + ) { |
|
| 328 | + $lien = array( |
|
| 329 | + 'href' => extraire_attribut($r[0], 'href'), |
|
| 330 | + 'class' => extraire_attribut($r[0], 'class'), |
|
| 331 | + 'mime' => extraire_attribut($r[0], 'type'), |
|
| 332 | + 'title' => extraire_attribut($r[0], 'title'), |
|
| 333 | + 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 334 | + ); |
|
| 335 | + $n = strlen($r[0]); |
|
| 336 | + $a -= $n; |
|
| 337 | + $cherche = $n + strlen($regs[0]); |
|
| 338 | + } else { |
|
| 339 | + $lien = false; |
|
| 340 | + $cherche = strlen($mod); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + // calculer le modele |
|
| 344 | + # hack indexation |
|
| 345 | + if ($doublons) { |
|
| 346 | + $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 347 | + } # version normale |
|
| 348 | + else { |
|
| 349 | + // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 350 | + // dans les parametres, plutot que les liens echappes |
|
| 351 | + if (!is_null($liens)) { |
|
| 352 | + $params = str_replace($liens[0], $liens[1], $params); |
|
| 353 | + } |
|
| 354 | + $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 355 | + // en cas d'echec, |
|
| 356 | + // si l'objet demande a une url, |
|
| 357 | + // creer un petit encadre vers elle |
|
| 358 | + if ($modele === false) { |
|
| 359 | + if (!$lien) { |
|
| 360 | + $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 361 | + } |
|
| 362 | + if ($lien) { |
|
| 363 | + $modele = '<a href="' |
|
| 364 | + . $lien['url'] |
|
| 365 | + . '" class="spip_modele' |
|
| 366 | + . '">' |
|
| 367 | + . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 368 | + . "</a>"; |
|
| 369 | + } else { |
|
| 370 | + $modele = ""; |
|
| 371 | + if (test_espace_prive()) { |
|
| 372 | + $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 373 | + if (!is_null($liens)) { |
|
| 374 | + $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + // le remplacer dans le texte |
|
| 380 | + if ($modele !== false) { |
|
| 381 | + $modele = protege_js_modeles($modele); |
|
| 382 | + if ($wrap_embed_html) { |
|
| 383 | + $modele = $wrap_embed_html($mod, $modele); |
|
| 384 | + } |
|
| 385 | + $rempl = code_echappement($modele, $echap); |
|
| 386 | + $texte = substr($texte, 0, $a) |
|
| 387 | + . $rempl |
|
| 388 | + . substr($texte, $a + $cherche); |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + // hack pour tout l'espace prive |
|
| 393 | + if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 394 | + foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) { |
|
| 395 | + if (in_array($type, $modeles)) { |
|
| 396 | + $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + return $texte; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | // |
| 409 | 409 | // https://code.spip.net/@traiter_raccourci_ancre |
| 410 | 410 | function traiter_raccourci_ancre($letexte) { |
| 411 | - return $letexte; |
|
| 411 | + return $letexte; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // https://code.spip.net/@traiter_raccourci_glossaire |
| 415 | 415 | function traiter_raccourci_glossaire($texte) { |
| 416 | - return $texte; |
|
| 416 | + return $texte; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | // https://code.spip.net/@glossaire_std |
| 420 | 420 | function glossaire_std($terme) { |
| 421 | - return $terme; |
|
| 421 | + return $terme; |
|
| 422 | 422 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | -define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
|
| 105 | +define('_EXTRAIRE_LIEN', ',^\s*(?:'._PROTOCOLES_STD.'):?/?/?\s*$,iS'); |
|
| 106 | 106 | |
| 107 | 107 | // https://code.spip.net/@traiter_lien_explicite |
| 108 | 108 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | $lien_court = charger_fonction('lien_court', 'inc'); |
| 120 | 120 | $texte = $lien_court($texte); |
| 121 | 121 | if ($echappe_typo) { |
| 122 | - $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 122 | + $texte = "<html>".quote_amp($texte)."</html>"; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // petites corrections d'URL |
| 127 | 127 | if (preg_match('/^www\.[^@]+$/S', $lien)) { |
| 128 | - $lien = "http://" . $lien; |
|
| 128 | + $lien = "http://".$lien; |
|
| 129 | 129 | } else { |
| 130 | 130 | if (strpos($lien, "@") && email_valide($lien)) { |
| 131 | 131 | if (!$texte) { |
| 132 | 132 | $texte = $lien; |
| 133 | 133 | } |
| 134 | - $lien = "mailto:" . $lien; |
|
| 134 | + $lien = "mailto:".$lien; |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') { |
| 150 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 150 | + if (function_exists($f = 'glossaire_'.$ancre)) { |
|
| 151 | 151 | $url = $f($texte, $id); |
| 152 | 152 | } else { |
| 153 | 153 | $url = glossaire_std($texte); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | if (!($match = typer_raccourci($ref))) { |
| 162 | 162 | return false; |
| 163 | 163 | } |
| 164 | - @list($type, , $id, , $args, , $ancre) = $match; |
|
| 164 | + @list($type,, $id,, $args,, $ancre) = $match; |
|
| 165 | 165 | // attention dans le cas des sites le lien doit pointer non pas sur |
| 166 | 166 | // la page locale du site, mais directement sur le site lui-meme |
| 167 | 167 | if ($f = charger_fonction("implicite_$type", "liens", true)) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $r['titre'] = $texte; |
| 189 | 189 | } |
| 190 | 190 | if (!@$r['titre']) { |
| 191 | - $r['titre'] = _T($type) . " $id"; |
|
| 191 | + $r['titre'] = _T($type)." $id"; |
|
| 192 | 192 | } |
| 193 | 193 | if ($pour == 'titre') { |
| 194 | 194 | return $r['titre']; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
| 199 | 199 | if ($type == 'document' |
| 200 | 200 | and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
| 201 | - "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 201 | + "extension IN (".sql_get_select("extension", "spip_documents", "id_document=".sql_quote($id)).")", |
|
| 202 | 202 | '', '', '', '', $connect) |
| 203 | 203 | ) { |
| 204 | 204 | $r['mime'] = $mime; |
@@ -295,11 +295,11 @@ discard block |
||
| 295 | 295 | '(<([a-z_-]{3,})' # <modele |
| 296 | 296 | . '\s*([0-9]*)\s*' # id |
| 297 | 297 | . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
| 298 | - . '\s*/?' . '>)' # fin du modele > |
|
| 298 | + . '\s*/?'.'>)' # fin du modele > |
|
| 299 | 299 | . '\s*(<\/a>)?' # eventuel </a> |
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | -define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
|
| 302 | +define('_RACCOURCI_MODELE_DEBUT', '@^'._RACCOURCI_MODELE.'@isS'); |
|
| 303 | 303 | |
| 304 | 304 | // https://code.spip.net/@traiter_modeles |
| 305 | 305 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) { |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | if (test_espace_prive()) { |
| 372 | 372 | $modele = entites_html(substr($texte, $a, $cherche)); |
| 373 | 373 | if (!is_null($liens)) { |
| 374 | - $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 374 | + $modele = "<pre>".str_replace($liens[0], $liens[1], $modele)."</pre>"; |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
@@ -21,6 +21,9 @@ |
||
| 21 | 21 | // |
| 22 | 22 | |
| 23 | 23 | // https://code.spip.net/@image_math |
| 24 | +/** |
|
| 25 | + * @param string $tex |
|
| 26 | + */ |
|
| 24 | 27 | function produire_image_math($tex) { |
| 25 | 28 | |
| 26 | 29 | switch ($GLOBALS['traiter_math']) { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | // |
| 15 | 15 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 16 | - return; |
|
| 16 | + return; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | // |
@@ -23,56 +23,56 @@ discard block |
||
| 23 | 23 | // https://code.spip.net/@image_math |
| 24 | 24 | function produire_image_math($tex) { |
| 25 | 25 | |
| 26 | - switch ($GLOBALS['traiter_math']) { |
|
| 27 | - // Attention: mathml desactiv'e pour l'instant |
|
| 28 | - case 'mathml': |
|
| 29 | - $ext = '.xhtml'; |
|
| 30 | - $server = $GLOBALS['mathml_server']; |
|
| 31 | - break; |
|
| 32 | - case 'tex': |
|
| 33 | - $ext = '.png'; |
|
| 34 | - $server = $GLOBALS['tex_server']; |
|
| 35 | - break; |
|
| 36 | - default: |
|
| 37 | - return $tex; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 41 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 42 | - @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 43 | - } |
|
| 44 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - if (!@file_exists($fichier)) { |
|
| 48 | - // Aller chercher l'image sur le serveur |
|
| 49 | - if ($server) { |
|
| 50 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 51 | - include_spip('inc/distant'); |
|
| 52 | - recuperer_page($url, $fichier); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - // Composer la reponse selon presence ou non de l'image |
|
| 58 | - $tex = entites_html($tex); |
|
| 59 | - if (@file_exists($fichier)) { |
|
| 60 | - |
|
| 61 | - // MathML |
|
| 62 | - if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 63 | - return implode("", file($fichier)); |
|
| 64 | - } // TeX |
|
| 65 | - else { |
|
| 66 | - list(, , , $size) = @spip_getimagesize($fichier); |
|
| 67 | - $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 68 | - |
|
| 69 | - return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - } else // pas de fichier |
|
| 73 | - { |
|
| 74 | - return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 75 | - } |
|
| 26 | + switch ($GLOBALS['traiter_math']) { |
|
| 27 | + // Attention: mathml desactiv'e pour l'instant |
|
| 28 | + case 'mathml': |
|
| 29 | + $ext = '.xhtml'; |
|
| 30 | + $server = $GLOBALS['mathml_server']; |
|
| 31 | + break; |
|
| 32 | + case 'tex': |
|
| 33 | + $ext = '.png'; |
|
| 34 | + $server = $GLOBALS['tex_server']; |
|
| 35 | + break; |
|
| 36 | + default: |
|
| 37 | + return $tex; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 41 | + if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 42 | + @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 43 | + } |
|
| 44 | + $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + if (!@file_exists($fichier)) { |
|
| 48 | + // Aller chercher l'image sur le serveur |
|
| 49 | + if ($server) { |
|
| 50 | + spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 51 | + include_spip('inc/distant'); |
|
| 52 | + recuperer_page($url, $fichier); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + // Composer la reponse selon presence ou non de l'image |
|
| 58 | + $tex = entites_html($tex); |
|
| 59 | + if (@file_exists($fichier)) { |
|
| 60 | + |
|
| 61 | + // MathML |
|
| 62 | + if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 63 | + return implode("", file($fichier)); |
|
| 64 | + } // TeX |
|
| 65 | + else { |
|
| 66 | + list(, , , $size) = @spip_getimagesize($fichier); |
|
| 67 | + $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 68 | + |
|
| 69 | + return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + } else // pas de fichier |
|
| 73 | + { |
|
| 74 | + return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
@@ -108,46 +108,46 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | function traiter_math($letexte, $source = '', $defaire_amp = false) { |
| 110 | 110 | |
| 111 | - $texte_a_voir = $letexte; |
|
| 112 | - while (($debut = strpos($texte_a_voir, "<math>")) !== false) { |
|
| 113 | - if (!$fin = strpos($texte_a_voir, "</math>")) { |
|
| 114 | - $fin = strlen($texte_a_voir); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 118 | - $texte_milieu = substr($texte_a_voir, |
|
| 119 | - $debut + strlen("<math>"), $fin - $debut - strlen("<math>")); |
|
| 120 | - $texte_fin = substr($texte_a_voir, |
|
| 121 | - $fin + strlen("</math>"), strlen($texte_a_voir)); |
|
| 122 | - |
|
| 123 | - // Les doubles $$x^2$$ en mode 'div' |
|
| 124 | - while ((preg_match(",[$][$]([^$]+)[$][$],", $texte_milieu, $regs))) { |
|
| 125 | - $expression = $regs[1]; |
|
| 126 | - if ($defaire_amp) { |
|
| 127 | - $expression = str_replace('&', '&', $expression); |
|
| 128 | - } |
|
| 129 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 130 | - $pos = strpos($texte_milieu, $regs[0]); |
|
| 131 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 132 | - . code_echappement($echap, $source) |
|
| 133 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // Les simples $x^2$ en mode 'span' |
|
| 137 | - while ((preg_match(",[$]([^$]+)[$],", $texte_milieu, $regs))) { |
|
| 138 | - $expression = $regs[1]; |
|
| 139 | - if ($defaire_amp) { |
|
| 140 | - $expression = str_replace('&', '&', $expression); |
|
| 141 | - } |
|
| 142 | - $echap = produire_image_math($expression); |
|
| 143 | - $pos = strpos($texte_milieu, $regs[0]); |
|
| 144 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 145 | - . code_echappement($echap, $source) |
|
| 146 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $texte_a_voir; |
|
| 111 | + $texte_a_voir = $letexte; |
|
| 112 | + while (($debut = strpos($texte_a_voir, "<math>")) !== false) { |
|
| 113 | + if (!$fin = strpos($texte_a_voir, "</math>")) { |
|
| 114 | + $fin = strlen($texte_a_voir); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 118 | + $texte_milieu = substr($texte_a_voir, |
|
| 119 | + $debut + strlen("<math>"), $fin - $debut - strlen("<math>")); |
|
| 120 | + $texte_fin = substr($texte_a_voir, |
|
| 121 | + $fin + strlen("</math>"), strlen($texte_a_voir)); |
|
| 122 | + |
|
| 123 | + // Les doubles $$x^2$$ en mode 'div' |
|
| 124 | + while ((preg_match(",[$][$]([^$]+)[$][$],", $texte_milieu, $regs))) { |
|
| 125 | + $expression = $regs[1]; |
|
| 126 | + if ($defaire_amp) { |
|
| 127 | + $expression = str_replace('&', '&', $expression); |
|
| 128 | + } |
|
| 129 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 130 | + $pos = strpos($texte_milieu, $regs[0]); |
|
| 131 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 132 | + . code_echappement($echap, $source) |
|
| 133 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // Les simples $x^2$ en mode 'span' |
|
| 137 | + while ((preg_match(",[$]([^$]+)[$],", $texte_milieu, $regs))) { |
|
| 138 | + $expression = $regs[1]; |
|
| 139 | + if ($defaire_amp) { |
|
| 140 | + $expression = str_replace('&', '&', $expression); |
|
| 141 | + } |
|
| 142 | + $echap = produire_image_math($expression); |
|
| 143 | + $pos = strpos($texte_milieu, $regs[0]); |
|
| 144 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 145 | + . code_echappement($echap, $source) |
|
| 146 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $texte_a_voir; |
|
| 153 | 153 | } |
@@ -38,16 +38,16 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // Regarder dans le repertoire local des images TeX et blocs MathML |
| 41 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 41 | + if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/')) { |
|
| 42 | 42 | @mkdir($dir_tex, _SPIP_CHMOD); |
| 43 | 43 | } |
| 44 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 44 | + $fichier = $dir_tex.md5(trim($tex)).$ext; |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | if (!@file_exists($fichier)) { |
| 48 | 48 | // Aller chercher l'image sur le serveur |
| 49 | 49 | if ($server) { |
| 50 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 50 | + spip_log($url = $server.'?'.rawurlencode($tex)); |
|
| 51 | 51 | include_spip('inc/distant'); |
| 52 | 52 | recuperer_page($url, $fichier); |
| 53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | return implode("", file($fichier)); |
| 64 | 64 | } // TeX |
| 65 | 65 | else { |
| 66 | - list(, , , $size) = @spip_getimagesize($fichier); |
|
| 66 | + list(,,, $size) = @spip_getimagesize($fichier); |
|
| 67 | 67 | $alt = "alt=\"$tex\" title=\"$tex\""; |
| 68 | 68 | |
| 69 | 69 | return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | if ($defaire_amp) { |
| 127 | 127 | $expression = str_replace('&', '&', $expression); |
| 128 | 128 | } |
| 129 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 129 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">".produire_image_math($expression)."</p>\n"; |
|
| 130 | 130 | $pos = strpos($texte_milieu, $regs[0]); |
| 131 | 131 | $texte_milieu = substr($texte_milieu, 0, $pos) |
| 132 | 132 | . code_echappement($echap, $source) |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | . substr($texte_milieu, $pos + strlen($regs[0])); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 149 | + $texte_a_voir = $texte_debut.$texte_milieu.$texte_fin; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return $texte_a_voir; |
@@ -248,6 +248,9 @@ |
||
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@install_premier_auteur |
| 251 | +/** |
|
| 252 | + * @param string $hidden |
|
| 253 | + */ |
|
| 251 | 254 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 252 | 255 | return info_progression_etape(3, 'etape_', 'install/') . |
| 253 | 256 | info_etape( |
@@ -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_spip('inc/headers'); |
@@ -20,199 +20,199 @@ discard block |
||
| 20 | 20 | // https://code.spip.net/@install_bases |
| 21 | 21 | function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) { |
| 22 | 22 | |
| 23 | - // Prefix des tables : |
|
| 24 | - // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 25 | - // a partir de ce qui est envoye a l'installation |
|
| 26 | - if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 27 | - $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 28 | - ? $GLOBALS['table_prefix'] |
|
| 29 | - : preparer_prefixe_tables(_request('tprefix')); |
|
| 30 | - // S'il est vide on remet spip |
|
| 31 | - if (!$table_prefix) { |
|
| 32 | - $table_prefix = 'spip'; |
|
| 33 | - } |
|
| 34 | - } else { |
|
| 35 | - $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 39 | - list(, $adresse_db, $port) = $r; |
|
| 40 | - } else { |
|
| 41 | - $port = ''; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $GLOBALS['connexions'][$server_db] |
|
| 45 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 46 | - |
|
| 47 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 48 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 49 | - |
|
| 50 | - $fquery = sql_serveur('query', $server_db); |
|
| 51 | - if ($choix_db == 'new_spip') { |
|
| 52 | - $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 53 | - if (preg_match($re, $sel_db)) { |
|
| 54 | - $ok = sql_create_base($sel_db, $server_db); |
|
| 55 | - if (!$ok) { |
|
| 56 | - $re = "Impossible de creer la base $re"; |
|
| 57 | - spip_log($re); |
|
| 58 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 59 | - } |
|
| 60 | - } else { |
|
| 61 | - $re = "Le nom de la base doit correspondre a $re"; |
|
| 62 | - spip_log($re); |
|
| 63 | - |
|
| 64 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 69 | - // un sql_mode |
|
| 70 | - install_mode_appel($server_db, false); |
|
| 71 | - $GLOBALS['connexions'][$server_db] |
|
| 72 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 73 | - |
|
| 74 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 75 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 76 | - |
|
| 77 | - // Completer le tableau decrivant la connexion |
|
| 78 | - |
|
| 79 | - $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 80 | - $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 81 | - |
|
| 82 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 83 | - if ($old) { |
|
| 84 | - $old = sql_fetch($old, $server_db); |
|
| 85 | - } |
|
| 86 | - if (!$old) { |
|
| 87 | - // Si possible, demander au serveur d'envoyer les textes |
|
| 88 | - // dans le codage std de SPIP, |
|
| 89 | - $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 90 | - |
|
| 91 | - if ($charset) { |
|
| 92 | - sql_set_charset($charset['charset'], $server_db); |
|
| 93 | - $GLOBALS['meta']['charset_sql_base'] = |
|
| 94 | - $charset['charset']; |
|
| 95 | - $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 96 | - $charset['collation']; |
|
| 97 | - $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 98 | - $charset['charset']; |
|
| 99 | - $charsetbase = $charset['charset']; |
|
| 100 | - } else { |
|
| 101 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 102 | - $charsetbase = 'standard'; |
|
| 103 | - } |
|
| 104 | - spip_log("Creation des tables. Codage $charsetbase"); |
|
| 105 | - creer_base($server_db); // AT LAST |
|
| 106 | - // memoriser avec quel charset on l'a creee |
|
| 107 | - |
|
| 108 | - if ($charset) { |
|
| 109 | - $t = array( |
|
| 110 | - 'nom' => 'charset_sql_base', |
|
| 111 | - 'valeur' => $charset['charset'], |
|
| 112 | - 'impt' => 'non' |
|
| 113 | - ); |
|
| 114 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 115 | - $t['nom'] = 'charset_collation_sql_base'; |
|
| 116 | - $t['valeur'] = $charset['collation']; |
|
| 117 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 118 | - $t['nom'] = 'charset_sql_connexion'; |
|
| 119 | - $t['valeur'] = $charset['charset']; |
|
| 120 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 121 | - } |
|
| 122 | - $t = array( |
|
| 123 | - 'nom' => 'version_installee', |
|
| 124 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 125 | - 'impt' => 'non' |
|
| 126 | - ); |
|
| 127 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 128 | - $t['nom'] = 'nouvelle_install'; |
|
| 129 | - $t['valeur'] = 1; |
|
| 130 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 131 | - // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 132 | - if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 133 | - @sql_insertq( |
|
| 134 | - 'spip_meta', |
|
| 135 | - array('nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']), |
|
| 136 | - '', |
|
| 137 | - $server_db |
|
| 138 | - ); |
|
| 139 | - } |
|
| 140 | - } else { |
|
| 141 | - // pour recreer les tables disparues au besoin |
|
| 142 | - spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 143 | - creer_base($server_db); |
|
| 144 | - $fupdateq = sql_serveur('updateq', $server_db); |
|
| 145 | - |
|
| 146 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 147 | - |
|
| 148 | - if ($r) { |
|
| 149 | - $r = sql_fetch($r, $server_db); |
|
| 150 | - } |
|
| 151 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 152 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 153 | - $fupdateq( |
|
| 154 | - 'spip_meta', |
|
| 155 | - array('valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'), |
|
| 156 | - "nom='version_installee'", |
|
| 157 | - '', |
|
| 158 | - $server_db |
|
| 159 | - ); |
|
| 160 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 161 | - } |
|
| 162 | - // eliminer la derniere operation d'admin mal terminee |
|
| 163 | - // notamment la mise a jour |
|
| 164 | - @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // recuperer le charset de la connexion dans les meta |
|
| 168 | - $charset = ''; |
|
| 169 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 170 | - if ($r) { |
|
| 171 | - $r = sql_fetch($r, $server_db); |
|
| 172 | - } |
|
| 173 | - if ($r) { |
|
| 174 | - $charset = $r['valeur']; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $ligne_rappel = install_mode_appel($server_db); |
|
| 178 | - |
|
| 179 | - $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 180 | - if (!$result_ok) { |
|
| 181 | - return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ($chmod_db) { |
|
| 185 | - install_fichier_connexion( |
|
| 186 | - _FILE_CHMOD_TMP, |
|
| 187 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 188 | - ); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - // si ce fichier existe a cette etape c'est qu'il provient |
|
| 192 | - // d'une installation qui ne l'a pas cree correctement. |
|
| 193 | - // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 194 | - |
|
| 195 | - if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 196 | - spip_unlink(_FILE_CONNECT); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - install_fichier_connexion( |
|
| 200 | - _FILE_CONNECT_TMP, |
|
| 201 | - $ligne_rappel |
|
| 202 | - . install_connexion( |
|
| 203 | - $adresse_db, |
|
| 204 | - $port, |
|
| 205 | - $login_db, |
|
| 206 | - $pass_db, |
|
| 207 | - $sel_db, |
|
| 208 | - $server_db, |
|
| 209 | - $table_prefix, |
|
| 210 | - '', |
|
| 211 | - $charset |
|
| 212 | - ) |
|
| 213 | - ); |
|
| 214 | - |
|
| 215 | - return ''; |
|
| 23 | + // Prefix des tables : |
|
| 24 | + // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 25 | + // a partir de ce qui est envoye a l'installation |
|
| 26 | + if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 27 | + $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 28 | + ? $GLOBALS['table_prefix'] |
|
| 29 | + : preparer_prefixe_tables(_request('tprefix')); |
|
| 30 | + // S'il est vide on remet spip |
|
| 31 | + if (!$table_prefix) { |
|
| 32 | + $table_prefix = 'spip'; |
|
| 33 | + } |
|
| 34 | + } else { |
|
| 35 | + $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 39 | + list(, $adresse_db, $port) = $r; |
|
| 40 | + } else { |
|
| 41 | + $port = ''; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $GLOBALS['connexions'][$server_db] |
|
| 45 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 46 | + |
|
| 47 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 48 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 49 | + |
|
| 50 | + $fquery = sql_serveur('query', $server_db); |
|
| 51 | + if ($choix_db == 'new_spip') { |
|
| 52 | + $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 53 | + if (preg_match($re, $sel_db)) { |
|
| 54 | + $ok = sql_create_base($sel_db, $server_db); |
|
| 55 | + if (!$ok) { |
|
| 56 | + $re = "Impossible de creer la base $re"; |
|
| 57 | + spip_log($re); |
|
| 58 | + return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 59 | + } |
|
| 60 | + } else { |
|
| 61 | + $re = "Le nom de la base doit correspondre a $re"; |
|
| 62 | + spip_log($re); |
|
| 63 | + |
|
| 64 | + return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 69 | + // un sql_mode |
|
| 70 | + install_mode_appel($server_db, false); |
|
| 71 | + $GLOBALS['connexions'][$server_db] |
|
| 72 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 73 | + |
|
| 74 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 75 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 76 | + |
|
| 77 | + // Completer le tableau decrivant la connexion |
|
| 78 | + |
|
| 79 | + $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 80 | + $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 81 | + |
|
| 82 | + $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 83 | + if ($old) { |
|
| 84 | + $old = sql_fetch($old, $server_db); |
|
| 85 | + } |
|
| 86 | + if (!$old) { |
|
| 87 | + // Si possible, demander au serveur d'envoyer les textes |
|
| 88 | + // dans le codage std de SPIP, |
|
| 89 | + $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 90 | + |
|
| 91 | + if ($charset) { |
|
| 92 | + sql_set_charset($charset['charset'], $server_db); |
|
| 93 | + $GLOBALS['meta']['charset_sql_base'] = |
|
| 94 | + $charset['charset']; |
|
| 95 | + $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 96 | + $charset['collation']; |
|
| 97 | + $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 98 | + $charset['charset']; |
|
| 99 | + $charsetbase = $charset['charset']; |
|
| 100 | + } else { |
|
| 101 | + spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 102 | + $charsetbase = 'standard'; |
|
| 103 | + } |
|
| 104 | + spip_log("Creation des tables. Codage $charsetbase"); |
|
| 105 | + creer_base($server_db); // AT LAST |
|
| 106 | + // memoriser avec quel charset on l'a creee |
|
| 107 | + |
|
| 108 | + if ($charset) { |
|
| 109 | + $t = array( |
|
| 110 | + 'nom' => 'charset_sql_base', |
|
| 111 | + 'valeur' => $charset['charset'], |
|
| 112 | + 'impt' => 'non' |
|
| 113 | + ); |
|
| 114 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 115 | + $t['nom'] = 'charset_collation_sql_base'; |
|
| 116 | + $t['valeur'] = $charset['collation']; |
|
| 117 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 118 | + $t['nom'] = 'charset_sql_connexion'; |
|
| 119 | + $t['valeur'] = $charset['charset']; |
|
| 120 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 121 | + } |
|
| 122 | + $t = array( |
|
| 123 | + 'nom' => 'version_installee', |
|
| 124 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 125 | + 'impt' => 'non' |
|
| 126 | + ); |
|
| 127 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 128 | + $t['nom'] = 'nouvelle_install'; |
|
| 129 | + $t['valeur'] = 1; |
|
| 130 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 131 | + // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 132 | + if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 133 | + @sql_insertq( |
|
| 134 | + 'spip_meta', |
|
| 135 | + array('nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']), |
|
| 136 | + '', |
|
| 137 | + $server_db |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | + } else { |
|
| 141 | + // pour recreer les tables disparues au besoin |
|
| 142 | + spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 143 | + creer_base($server_db); |
|
| 144 | + $fupdateq = sql_serveur('updateq', $server_db); |
|
| 145 | + |
|
| 146 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 147 | + |
|
| 148 | + if ($r) { |
|
| 149 | + $r = sql_fetch($r, $server_db); |
|
| 150 | + } |
|
| 151 | + $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 152 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 153 | + $fupdateq( |
|
| 154 | + 'spip_meta', |
|
| 155 | + array('valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'), |
|
| 156 | + "nom='version_installee'", |
|
| 157 | + '', |
|
| 158 | + $server_db |
|
| 159 | + ); |
|
| 160 | + spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 161 | + } |
|
| 162 | + // eliminer la derniere operation d'admin mal terminee |
|
| 163 | + // notamment la mise a jour |
|
| 164 | + @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // recuperer le charset de la connexion dans les meta |
|
| 168 | + $charset = ''; |
|
| 169 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 170 | + if ($r) { |
|
| 171 | + $r = sql_fetch($r, $server_db); |
|
| 172 | + } |
|
| 173 | + if ($r) { |
|
| 174 | + $charset = $r['valeur']; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $ligne_rappel = install_mode_appel($server_db); |
|
| 178 | + |
|
| 179 | + $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 180 | + if (!$result_ok) { |
|
| 181 | + return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ($chmod_db) { |
|
| 185 | + install_fichier_connexion( |
|
| 186 | + _FILE_CHMOD_TMP, |
|
| 187 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 188 | + ); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + // si ce fichier existe a cette etape c'est qu'il provient |
|
| 192 | + // d'une installation qui ne l'a pas cree correctement. |
|
| 193 | + // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 194 | + |
|
| 195 | + if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 196 | + spip_unlink(_FILE_CONNECT); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + install_fichier_connexion( |
|
| 200 | + _FILE_CONNECT_TMP, |
|
| 201 | + $ligne_rappel |
|
| 202 | + . install_connexion( |
|
| 203 | + $adresse_db, |
|
| 204 | + $port, |
|
| 205 | + $login_db, |
|
| 206 | + $pass_db, |
|
| 207 | + $sel_db, |
|
| 208 | + $server_db, |
|
| 209 | + $table_prefix, |
|
| 210 | + '', |
|
| 211 | + $charset |
|
| 212 | + ) |
|
| 213 | + ); |
|
| 214 | + |
|
| 215 | + return ''; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -227,169 +227,169 @@ discard block |
||
| 227 | 227 | * @return string Le préfixe corrigé |
| 228 | 228 | */ |
| 229 | 229 | function preparer_prefixe_tables($prefixe) { |
| 230 | - return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 230 | + return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // https://code.spip.net/@install_propose_ldap |
| 234 | 234 | function install_propose_ldap() { |
| 235 | - return generer_form_ecrire('install', ( |
|
| 236 | - fieldset( |
|
| 237 | - _T('info_authentification_externe'), |
|
| 238 | - array( |
|
| 239 | - 'etape' => array( |
|
| 240 | - 'label' => _T('texte_annuaire_ldap_1'), |
|
| 241 | - 'valeur' => 'ldap1', |
|
| 242 | - 'hidden' => true |
|
| 243 | - ) |
|
| 244 | - ), |
|
| 245 | - bouton_suivant(_T('bouton_acces_ldap')) |
|
| 246 | - ))); |
|
| 235 | + return generer_form_ecrire('install', ( |
|
| 236 | + fieldset( |
|
| 237 | + _T('info_authentification_externe'), |
|
| 238 | + array( |
|
| 239 | + 'etape' => array( |
|
| 240 | + 'label' => _T('texte_annuaire_ldap_1'), |
|
| 241 | + 'valeur' => 'ldap1', |
|
| 242 | + 'hidden' => true |
|
| 243 | + ) |
|
| 244 | + ), |
|
| 245 | + bouton_suivant(_T('bouton_acces_ldap')) |
|
| 246 | + ))); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@install_premier_auteur |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 252 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 253 | - info_etape( |
|
| 254 | - _T('info_informations_personnelles'), |
|
| 255 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | - aider('install5', true) . |
|
| 257 | - '<p>' . |
|
| 258 | - ($auteur_obligatoire ? |
|
| 259 | - '' |
|
| 260 | - : |
|
| 261 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 262 | - ) |
|
| 263 | - ) |
|
| 264 | - . generer_form_ecrire('install', ( |
|
| 265 | - "\n<input type='hidden' name='etape' value='3b' />" |
|
| 266 | - . $hidden |
|
| 267 | - . fieldset( |
|
| 268 | - _T('info_identification_publique'), |
|
| 269 | - array( |
|
| 270 | - 'nom' => array( |
|
| 271 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 272 | - 'valeur' => $nom, |
|
| 273 | - 'required' => $auteur_obligatoire, |
|
| 274 | - ), |
|
| 275 | - 'email' => array( |
|
| 276 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 277 | - 'valeur' => $email, |
|
| 278 | - ) |
|
| 279 | - ) |
|
| 280 | - ) |
|
| 281 | - |
|
| 282 | - . fieldset( |
|
| 283 | - _T('entree_identifiants_connexion'), |
|
| 284 | - array( |
|
| 285 | - 'login' => array( |
|
| 286 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 287 | - 'info_login_trop_court_car_pluriel', |
|
| 288 | - array('nb' => _LOGIN_TROP_COURT) |
|
| 289 | - ) . "\n", |
|
| 290 | - 'valeur' => $login, |
|
| 291 | - 'required' => $auteur_obligatoire, |
|
| 292 | - ), |
|
| 293 | - 'pass' => array( |
|
| 294 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 295 | - 'info_passe_trop_court_car_pluriel', |
|
| 296 | - array('nb' => _PASS_LONGUEUR_MINI) |
|
| 297 | - ) . "\n", |
|
| 298 | - 'valeur' => $pass, |
|
| 299 | - 'required' => $auteur_obligatoire, |
|
| 300 | - ), |
|
| 301 | - 'pass_verif' => array( |
|
| 302 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 303 | - 'valeur' => $pass, |
|
| 304 | - 'required' => $auteur_obligatoire, |
|
| 305 | - ) |
|
| 306 | - ) |
|
| 307 | - ) |
|
| 308 | - . bouton_suivant())); |
|
| 252 | + return info_progression_etape(3, 'etape_', 'install/') . |
|
| 253 | + info_etape( |
|
| 254 | + _T('info_informations_personnelles'), |
|
| 255 | + '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | + aider('install5', true) . |
|
| 257 | + '<p>' . |
|
| 258 | + ($auteur_obligatoire ? |
|
| 259 | + '' |
|
| 260 | + : |
|
| 261 | + _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 262 | + ) |
|
| 263 | + ) |
|
| 264 | + . generer_form_ecrire('install', ( |
|
| 265 | + "\n<input type='hidden' name='etape' value='3b' />" |
|
| 266 | + . $hidden |
|
| 267 | + . fieldset( |
|
| 268 | + _T('info_identification_publique'), |
|
| 269 | + array( |
|
| 270 | + 'nom' => array( |
|
| 271 | + 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 272 | + 'valeur' => $nom, |
|
| 273 | + 'required' => $auteur_obligatoire, |
|
| 274 | + ), |
|
| 275 | + 'email' => array( |
|
| 276 | + 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 277 | + 'valeur' => $email, |
|
| 278 | + ) |
|
| 279 | + ) |
|
| 280 | + ) |
|
| 281 | + |
|
| 282 | + . fieldset( |
|
| 283 | + _T('entree_identifiants_connexion'), |
|
| 284 | + array( |
|
| 285 | + 'login' => array( |
|
| 286 | + 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 287 | + 'info_login_trop_court_car_pluriel', |
|
| 288 | + array('nb' => _LOGIN_TROP_COURT) |
|
| 289 | + ) . "\n", |
|
| 290 | + 'valeur' => $login, |
|
| 291 | + 'required' => $auteur_obligatoire, |
|
| 292 | + ), |
|
| 293 | + 'pass' => array( |
|
| 294 | + 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 295 | + 'info_passe_trop_court_car_pluriel', |
|
| 296 | + array('nb' => _PASS_LONGUEUR_MINI) |
|
| 297 | + ) . "\n", |
|
| 298 | + 'valeur' => $pass, |
|
| 299 | + 'required' => $auteur_obligatoire, |
|
| 300 | + ), |
|
| 301 | + 'pass_verif' => array( |
|
| 302 | + 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 303 | + 'valeur' => $pass, |
|
| 304 | + 'required' => $auteur_obligatoire, |
|
| 305 | + ) |
|
| 306 | + ) |
|
| 307 | + ) |
|
| 308 | + . bouton_suivant())); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // https://code.spip.net/@install_etape_3_dist |
| 312 | 312 | function install_etape_3_dist() { |
| 313 | - $ldap_present = _request('ldap_present'); |
|
| 314 | - |
|
| 315 | - if (!$ldap_present) { |
|
| 316 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 317 | - ? _INSTALL_HOST_DB |
|
| 318 | - : _request('adresse_db'); |
|
| 319 | - |
|
| 320 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 321 | - ? _INSTALL_USER_DB |
|
| 322 | - : _request('login_db'); |
|
| 323 | - |
|
| 324 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 325 | - ? _INSTALL_PASS_DB |
|
| 326 | - : _request('pass_db'); |
|
| 327 | - |
|
| 328 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 329 | - ? _INSTALL_SERVER_DB |
|
| 330 | - : _request('server_db'); |
|
| 331 | - |
|
| 332 | - $chmod_db = defined('_SPIP_CHMOD') |
|
| 333 | - ? _SPIP_CHMOD |
|
| 334 | - : _request('chmod'); |
|
| 335 | - |
|
| 336 | - $choix_db = defined('_INSTALL_NAME_DB') |
|
| 337 | - ? _INSTALL_NAME_DB |
|
| 338 | - : _request('choix_db'); |
|
| 339 | - |
|
| 340 | - $sel_db = ($choix_db == 'new_spip') |
|
| 341 | - ? _request('table_new') : $choix_db; |
|
| 342 | - |
|
| 343 | - $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 344 | - |
|
| 345 | - if ($res) { |
|
| 346 | - $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 347 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 348 | - . $res |
|
| 349 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 350 | - . '</div>'; |
|
| 351 | - } |
|
| 352 | - } else { |
|
| 353 | - $res = ''; |
|
| 354 | - list($adresse_db, $login_db, $pass_db, $sel_db, $server_db) = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 355 | - $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - if (!$res) { |
|
| 359 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 360 | - include(_FILE_CONNECT_TMP); |
|
| 361 | - } else { |
|
| 362 | - redirige_url_ecrire('install'); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 366 | - include(_FILE_CHMOD_TMP); |
|
| 367 | - } else { |
|
| 368 | - redirige_url_ecrire('install'); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 372 | - . (defined('_INSTALL_NAME_DB') ? '' |
|
| 373 | - : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 374 | - |
|
| 375 | - $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 376 | - |
|
| 377 | - $res = "<div class='success'><b>" |
|
| 378 | - . _T('info_base_installee') |
|
| 379 | - . '</b></div>' |
|
| 380 | - . install_premier_auteur( |
|
| 381 | - _request('email'), |
|
| 382 | - _request('login'), |
|
| 383 | - _request('nom'), |
|
| 384 | - _request('pass'), |
|
| 385 | - $hidden, |
|
| 386 | - $auteur_obligatoire |
|
| 387 | - ) |
|
| 388 | - . (($ldap_present or !function_exists('ldap_connect')) |
|
| 389 | - ? '' : install_propose_ldap()); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - echo install_debut_html(); |
|
| 393 | - echo $res; |
|
| 394 | - echo install_fin_html(); |
|
| 313 | + $ldap_present = _request('ldap_present'); |
|
| 314 | + |
|
| 315 | + if (!$ldap_present) { |
|
| 316 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 317 | + ? _INSTALL_HOST_DB |
|
| 318 | + : _request('adresse_db'); |
|
| 319 | + |
|
| 320 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 321 | + ? _INSTALL_USER_DB |
|
| 322 | + : _request('login_db'); |
|
| 323 | + |
|
| 324 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 325 | + ? _INSTALL_PASS_DB |
|
| 326 | + : _request('pass_db'); |
|
| 327 | + |
|
| 328 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 329 | + ? _INSTALL_SERVER_DB |
|
| 330 | + : _request('server_db'); |
|
| 331 | + |
|
| 332 | + $chmod_db = defined('_SPIP_CHMOD') |
|
| 333 | + ? _SPIP_CHMOD |
|
| 334 | + : _request('chmod'); |
|
| 335 | + |
|
| 336 | + $choix_db = defined('_INSTALL_NAME_DB') |
|
| 337 | + ? _INSTALL_NAME_DB |
|
| 338 | + : _request('choix_db'); |
|
| 339 | + |
|
| 340 | + $sel_db = ($choix_db == 'new_spip') |
|
| 341 | + ? _request('table_new') : $choix_db; |
|
| 342 | + |
|
| 343 | + $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 344 | + |
|
| 345 | + if ($res) { |
|
| 346 | + $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 347 | + . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 348 | + . $res |
|
| 349 | + . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 350 | + . '</div>'; |
|
| 351 | + } |
|
| 352 | + } else { |
|
| 353 | + $res = ''; |
|
| 354 | + list($adresse_db, $login_db, $pass_db, $sel_db, $server_db) = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 355 | + $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + if (!$res) { |
|
| 359 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 360 | + include(_FILE_CONNECT_TMP); |
|
| 361 | + } else { |
|
| 362 | + redirige_url_ecrire('install'); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 366 | + include(_FILE_CHMOD_TMP); |
|
| 367 | + } else { |
|
| 368 | + redirige_url_ecrire('install'); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 372 | + . (defined('_INSTALL_NAME_DB') ? '' |
|
| 373 | + : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 374 | + |
|
| 375 | + $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 376 | + |
|
| 377 | + $res = "<div class='success'><b>" |
|
| 378 | + . _T('info_base_installee') |
|
| 379 | + . '</b></div>' |
|
| 380 | + . install_premier_auteur( |
|
| 381 | + _request('email'), |
|
| 382 | + _request('login'), |
|
| 383 | + _request('nom'), |
|
| 384 | + _request('pass'), |
|
| 385 | + $hidden, |
|
| 386 | + $auteur_obligatoire |
|
| 387 | + ) |
|
| 388 | + . (($ldap_present or !function_exists('ldap_connect')) |
|
| 389 | + ? '' : install_propose_ldap()); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + echo install_debut_html(); |
|
| 393 | + echo $res; |
|
| 394 | + echo install_fin_html(); |
|
| 395 | 395 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
| 46 | 46 | |
| 47 | 47 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 48 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 48 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 49 | 49 | |
| 50 | 50 | $fquery = sql_serveur('query', $server_db); |
| 51 | 51 | if ($choix_db == 'new_spip') { |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | if (!$ok) { |
| 56 | 56 | $re = "Impossible de creer la base $re"; |
| 57 | 57 | spip_log($re); |
| 58 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 58 | + return '<p>'._T('avis_connexion_erreur_creer_base')."</p><!--\n$re\n-->"; |
|
| 59 | 59 | } |
| 60 | 60 | } else { |
| 61 | 61 | $re = "Le nom de la base doit correspondre a $re"; |
| 62 | 62 | spip_log($re); |
| 63 | 63 | |
| 64 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 64 | + return '<p>'._T('avis_connexion_erreur_nom_base')."</p><!--\n$re\n-->"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
| 73 | 73 | |
| 74 | 74 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 75 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 75 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 76 | 76 | |
| 77 | 77 | // Completer le tableau decrivant la connexion |
| 78 | 78 | |
| 79 | 79 | $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
| 80 | 80 | $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
| 81 | 81 | |
| 82 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 82 | + $old = sql_showbase($table_prefix.'_meta', $server_db); |
|
| 83 | 83 | if ($old) { |
| 84 | 84 | $old = sql_fetch($old, $server_db); |
| 85 | 85 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $charset['charset']; |
| 99 | 99 | $charsetbase = $charset['charset']; |
| 100 | 100 | } else { |
| 101 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 101 | + spip_log(_DEFAULT_CHARSET.' inconnu du serveur SQL'); |
|
| 102 | 102 | $charsetbase = 'standard'; |
| 103 | 103 | } |
| 104 | 104 | spip_log("Creation des tables. Codage $charsetbase"); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | if ($r) { |
| 149 | 149 | $r = sql_fetch($r, $server_db); |
| 150 | 150 | } |
| 151 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 151 | + $version_installee = !$r ? 0 : (double) $r['valeur']; |
|
| 152 | 152 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 153 | 153 | $fupdateq( |
| 154 | 154 | 'spip_meta', |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | '', |
| 158 | 158 | $server_db |
| 159 | 159 | ); |
| 160 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 160 | + spip_log('nouvelle version installee: '.$GLOBALS['spip_version_base']); |
|
| 161 | 161 | } |
| 162 | 162 | // eliminer la derniere operation d'admin mal terminee |
| 163 | 163 | // notamment la mise a jour |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | if ($chmod_db) { |
| 185 | 185 | install_fichier_connexion( |
| 186 | 186 | _FILE_CHMOD_TMP, |
| 187 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 187 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', ".sprintf('0%3o', $chmod_db).");\n" |
|
| 188 | 188 | ); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -249,16 +249,16 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@install_premier_auteur |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 252 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 252 | + return info_progression_etape(3, 'etape_', 'install/'). |
|
| 253 | 253 | info_etape( |
| 254 | 254 | _T('info_informations_personnelles'), |
| 255 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | - aider('install5', true) . |
|
| 257 | - '<p>' . |
|
| 255 | + '<b>'._T('texte_informations_personnelles_1').'</b>'. |
|
| 256 | + aider('install5', true). |
|
| 257 | + '<p>'. |
|
| 258 | 258 | ($auteur_obligatoire ? |
| 259 | 259 | '' |
| 260 | 260 | : |
| 261 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 261 | + _T('texte_informations_personnelles_2').' '._T('info_laisser_champs_vides') |
|
| 262 | 262 | ) |
| 263 | 263 | ) |
| 264 | 264 | . generer_form_ecrire('install', ( |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | _T('info_identification_publique'), |
| 269 | 269 | array( |
| 270 | 270 | 'nom' => array( |
| 271 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 271 | + 'label' => '<b>'._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n", |
|
| 272 | 272 | 'valeur' => $nom, |
| 273 | 273 | 'required' => $auteur_obligatoire, |
| 274 | 274 | ), |
| 275 | 275 | 'email' => array( |
| 276 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 276 | + 'label' => '<b>'._T('entree_adresse_email')."</b>\n", |
|
| 277 | 277 | 'valeur' => $email, |
| 278 | 278 | ) |
| 279 | 279 | ) |
@@ -283,23 +283,23 @@ discard block |
||
| 283 | 283 | _T('entree_identifiants_connexion'), |
| 284 | 284 | array( |
| 285 | 285 | 'login' => array( |
| 286 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 286 | + 'label' => '<b>'._T('entree_login')."</b><br />\n"._T( |
|
| 287 | 287 | 'info_login_trop_court_car_pluriel', |
| 288 | 288 | array('nb' => _LOGIN_TROP_COURT) |
| 289 | - ) . "\n", |
|
| 289 | + )."\n", |
|
| 290 | 290 | 'valeur' => $login, |
| 291 | 291 | 'required' => $auteur_obligatoire, |
| 292 | 292 | ), |
| 293 | 293 | 'pass' => array( |
| 294 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 294 | + 'label' => '<b>'._T('entree_mot_passe')."</b><br />\n"._T( |
|
| 295 | 295 | 'info_passe_trop_court_car_pluriel', |
| 296 | 296 | array('nb' => _PASS_LONGUEUR_MINI) |
| 297 | - ) . "\n", |
|
| 297 | + )."\n", |
|
| 298 | 298 | 'valeur' => $pass, |
| 299 | 299 | 'required' => $auteur_obligatoire, |
| 300 | 300 | ), |
| 301 | 301 | 'pass_verif' => array( |
| 302 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 302 | + 'label' => '<b>'._T('info_confirmer_passe')."</b><br />\n", |
|
| 303 | 303 | 'valeur' => $pass, |
| 304 | 304 | 'required' => $auteur_obligatoire, |
| 305 | 305 | ) |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | if ($res) { |
| 346 | 346 | $res = info_progression_etape(2, 'etape_', 'install/', true) |
| 347 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 347 | + . "<div class='error'><h3>"._T('avis_operation_echec').'</h3>' |
|
| 348 | 348 | . $res |
| 349 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 349 | + . '<p>'._T('texte_operation_echec').'</p>' |
|
| 350 | 350 | . '</div>'; |
| 351 | 351 | } |
| 352 | 352 | } else { |
@@ -121,6 +121,10 @@ discard block |
||
| 121 | 121 | // checkbox pour activer ou desactiver |
| 122 | 122 | // si ce n'est pas une extension |
| 123 | 123 | |
| 124 | +/** |
|
| 125 | + * @param integer $id_input |
|
| 126 | + * @param string $file |
|
| 127 | + */ |
|
| 124 | 128 | function plugin_checkbox($id_input, $file, $actif) { |
| 125 | 129 | $name = substr(md5($file), 0, 16); |
| 126 | 130 | |
@@ -185,6 +189,9 @@ discard block |
||
| 185 | 189 | . "</div>"; |
| 186 | 190 | } |
| 187 | 191 | |
| 192 | +/** |
|
| 193 | + * @param string $nom |
|
| 194 | + */ |
|
| 188 | 195 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 189 | 196 | if (!$dir_plugins) { |
| 190 | 197 | $dir_plugins = _DIR_PLUGINS; |
@@ -221,6 +228,9 @@ discard block |
||
| 221 | 228 | } |
| 222 | 229 | |
| 223 | 230 | // https://code.spip.net/@plugin_propre |
| 231 | +/** |
|
| 232 | + * @return string |
|
| 233 | + */ |
|
| 224 | 234 | function plugin_propre($texte, $module = '',$propre='propre') { |
| 225 | 235 | // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
| 226 | 236 | if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
@@ -233,6 +243,9 @@ discard block |
||
| 233 | 243 | return $propre($texte); |
| 234 | 244 | } |
| 235 | 245 | |
| 246 | +/** |
|
| 247 | + * @return string |
|
| 248 | + */ |
|
| 236 | 249 | function plugin_typo($texte, $module = '') { |
| 237 | 250 | return plugin_propre($texte, $module, 'typo'); |
| 238 | 251 | } |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | $class_li .= " error"; |
| 57 | 57 | $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
| 58 | 58 | _T('plugin_info_erreur_xml')) |
| 59 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 59 | + . "<div class='erreur'>".join('<br >', $info['erreur'])."</div>"; |
|
| 60 | 60 | $checkable = false; |
| 61 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 61 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file])) { |
|
| 62 | 62 | $class_li .= " error"; |
| 63 | 63 | $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
| 64 | 64 | " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
| 65 | - . "<div class='erreur'>" . implode("<br />", |
|
| 66 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 65 | + . "<div class='erreur'>".implode("<br />", |
|
| 66 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file])."</div>"; |
|
| 67 | 67 | } else { |
| 68 | 68 | $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
| 69 | 69 | } |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | // numerotons les occurrences d'un meme prefix |
| 72 | 72 | $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
| 73 | 73 | |
| 74 | - $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 74 | + $class_li .= ($actif ? " actif" : "").($expose ? " on" : ""); |
|
| 75 | 75 | |
| 76 | 76 | return "<li id='$prefix$id' class='$class_li'>" |
| 77 | 77 | . ((!$checkable and !$checked) |
| 78 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 78 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins.$plug_file, $checked)) |
|
| 79 | 79 | . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
| 80 | 80 | . $cfg |
| 81 | 81 | . $erreur |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | $prefix = strtolower($infos['prefix']); |
| 94 | 94 | // si paquet.xml fournit un squelette, le prendre |
| 95 | 95 | if (isset($infos['config']) and $infos['config']) { |
| 96 | - return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 96 | + return recuperer_fond("$dir$nom/".$infos['config'], |
|
| 97 | 97 | array( |
| 98 | - 'script' => 'configurer_' . $prefix, |
|
| 98 | + 'script' => 'configurer_'.$prefix, |
|
| 99 | 99 | 'nom' => $nom |
| 100 | 100 | )); |
| 101 | 101 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | // sinon prendre le squelette std sur le nom std |
| 114 | 114 | return recuperer_fond("prive/squelettes/inclure/cfg", |
| 115 | 115 | array( |
| 116 | - 'script' => 'configurer_' . $prefix, |
|
| 116 | + 'script' => 'configurer_'.$prefix, |
|
| 117 | 117 | 'nom' => $nom |
| 118 | 118 | )); |
| 119 | 119 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | . "<input type='checkbox' name='s$name' id='label_$id_input'" |
| 129 | 129 | . ($actif ? " checked='checked'" : "") |
| 130 | 130 | . " class='checkbox' value='O' />" |
| 131 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 131 | + . "\n<label for='label_$id_input'>"._T('activer_plugin')."</label>" |
|
| 132 | 132 | . "</div>"; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | . "<h3><a href='$url' rel='info'>" |
| 177 | 177 | . $nom |
| 178 | 178 | . "</a></h3>" |
| 179 | - . " <span class='version'>" . $info['version'] . "</span>" |
|
| 179 | + . " <span class='version'>".$info['version']."</span>" |
|
| 180 | 180 | . " <span class='etat'> - " |
| 181 | 181 | . plugin_etat_en_clair($info['etat']) |
| 182 | 182 | . "</span>" |
| 183 | - . "<div class='short'>" . $slogan . "</div>" |
|
| 183 | + . "<div class='short'>".$slogan."</div>" |
|
| 184 | 184 | . $i |
| 185 | 185 | . "</div>"; |
| 186 | 186 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $text2 = _T('info_desinstaller_plugin'); |
| 196 | 196 | $file = basename($plug_file); |
| 197 | 197 | |
| 198 | - return "<div class='actions'>[" . |
|
| 198 | + return "<div class='actions'>[". |
|
| 199 | 199 | "<a href='$action' |
| 200 | 200 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 201 | 201 | . $text |
@@ -217,17 +217,17 @@ discard block |
||
| 217 | 217 | $etat = 'developpement'; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - return _T('plugin_etat_' . $etat); |
|
| 220 | + return _T('plugin_etat_'.$etat); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // https://code.spip.net/@plugin_propre |
| 224 | -function plugin_propre($texte, $module = '',$propre='propre') { |
|
| 224 | +function plugin_propre($texte, $module = '', $propre = 'propre') { |
|
| 225 | 225 | // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
| 226 | 226 | if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
| 227 | 227 | $module = substr($module, strlen(_DIR_RACINE)); |
| 228 | 228 | } |
| 229 | 229 | if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
| 230 | - $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 230 | + $texte = _T(($module ? "$module:" : '').$texte, array(), array('force' => false)); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | return $propre($texte); |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | if (isset($info['documentation']) |
| 260 | 260 | and $lien = $info['documentation'] |
| 261 | 261 | ) { |
| 262 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 262 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>"._T('en_savoir_plus').'</a></em></p>'; |
|
| 263 | 263 | } |
| 264 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 264 | + $s .= "<dd class='desc'>".$description."</dd>\n"; |
|
| 265 | 265 | |
| 266 | 266 | if (isset($info['auteur'])) { |
| 267 | 267 | if (is_array($info['auteur'])) { |
@@ -271,15 +271,15 @@ discard block |
||
| 271 | 271 | $a = trim($info['auteur']); |
| 272 | 272 | } |
| 273 | 273 | if ($a) { |
| 274 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 275 | - $dir)) . "</dd>\n"; |
|
| 274 | + $s .= "<dt class='auteurs'>"._T('public:par_auteur')."</dt><dd class='auteurs'>".PtoBR(propre($a, |
|
| 275 | + $dir))."</dd>\n"; |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | if (isset($info['credit'])) { |
| 280 | 280 | if ($a = formater_credits($info['credit'], ', ')) { |
| 281 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 282 | - $dir)) . "</dd>\n"; |
|
| 281 | + $s .= "<dt class='credits'>"._T('plugin_info_credit')."</dt><dd class='credits'>".PtoBR(propre($a, |
|
| 282 | + $dir))."</dd>\n"; |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
@@ -291,8 +291,8 @@ discard block |
||
| 291 | 291 | $a = trim($info['licence']); |
| 292 | 292 | } |
| 293 | 293 | if ($a) { |
| 294 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 295 | - $dir)) . "</dd>\n"; |
|
| 294 | + $s .= "<dt class='licence'>"._T('intitule_licence')."</dt><dd class='licence'>".PtoBR(propre($a, |
|
| 295 | + $dir))."</dd>\n"; |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
@@ -303,23 +303,22 @@ discard block |
||
| 303 | 303 | // |
| 304 | 304 | $infotech = array(); |
| 305 | 305 | |
| 306 | - $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 306 | + $version = "<dt>"._T('version')."</dt><dd>".$info['version']; |
|
| 307 | 307 | // Version VCS |
| 308 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 309 | - $version .= ' ' . $vcs; |
|
| 308 | + if ($vcs = version_vcs_courante($dir_plugins.$plug_file)) { |
|
| 309 | + $version .= ' '.$vcs; |
|
| 310 | 310 | } |
| 311 | 311 | $version .= "</dd>"; |
| 312 | 312 | $infotech[] = $version; |
| 313 | - $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 313 | + $infotech[] = "<dt>"._T('repertoire_plugins')."</dt><dd>".joli_repertoire("$dir_plugins$plug_file")."</dd>"; |
|
| 314 | 314 | // source zip le cas echeant |
| 315 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 315 | + $infotech[] = (lire_fichier($dir_plugins.$plug_file.'/install.log', $log) |
|
| 316 | 316 | and preg_match(',^source:(.*)$,m', $log, $r)) |
| 317 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 317 | + ? '<dt>'._T('plugin_source').'</dt><dd>'.trim($r[1])."</dd>" |
|
| 318 | 318 | : ''; |
| 319 | 319 | |
| 320 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 321 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 322 | - array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 320 | + $infotech[] = !$info['necessite'] ? '' : ('<dt>'._T('plugin_info_necessite').'</dt><dd>'.join(' ', |
|
| 321 | + array_map('array_shift', $info['necessite'])).'</dd>'); |
|
| 323 | 322 | |
| 324 | 323 | $s .= "<dl class='tech'>" |
| 325 | 324 | . join('', $infotech) |
@@ -340,8 +339,8 @@ discard block |
||
| 340 | 339 | $texte .= |
| 341 | 340 | (!is_array($_credit)) |
| 342 | 341 | ? PtoBR(propre($_credit)) |
| 343 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 344 | - $_credit['nom'] . |
|
| 342 | + : ($_credit['url'] ? '<a href="'.$_credit['url'].'">' : ''). |
|
| 343 | + $_credit['nom']. |
|
| 345 | 344 | ($_credit['url'] ? '</a>' : ''); |
| 346 | 345 | } |
| 347 | 346 | |
@@ -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 | include_spip('inc/charsets'); |
| 23 | 23 | include_spip('inc/texte'); |
@@ -25,189 +25,189 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // https://code.spip.net/@ligne_plug |
| 27 | 27 | function plugins_afficher_plugin_dist( |
| 28 | - $url_page, |
|
| 29 | - $plug_file, |
|
| 30 | - $checked, |
|
| 31 | - $actif, |
|
| 32 | - $expose = false, |
|
| 33 | - $class_li = "item", |
|
| 34 | - $dir_plugins = _DIR_PLUGINS |
|
| 28 | + $url_page, |
|
| 29 | + $plug_file, |
|
| 30 | + $checked, |
|
| 31 | + $actif, |
|
| 32 | + $expose = false, |
|
| 33 | + $class_li = "item", |
|
| 34 | + $dir_plugins = _DIR_PLUGINS |
|
| 35 | 35 | ) { |
| 36 | 36 | |
| 37 | - static $id_input = 0; |
|
| 38 | - static $versions = array(); |
|
| 39 | - |
|
| 40 | - $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 41 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 42 | - $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 43 | - $prefix = $info['prefix']; |
|
| 44 | - $cfg = ""; |
|
| 45 | - $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 46 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 47 | - $erreur = ""; |
|
| 48 | - |
|
| 49 | - if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 50 | - $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 51 | - $erreur = http_img_pack("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err'", |
|
| 52 | - _T('plugin_info_non_compatible_spip')); |
|
| 53 | - $class_li .= " disabled"; |
|
| 54 | - $checkable = false; |
|
| 55 | - } elseif (isset($info['erreur'])) { |
|
| 56 | - $class_li .= " error"; |
|
| 57 | - $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
|
| 58 | - _T('plugin_info_erreur_xml')) |
|
| 59 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 60 | - $checkable = false; |
|
| 61 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 62 | - $class_li .= " error"; |
|
| 63 | - $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
|
| 64 | - " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
|
| 65 | - . "<div class='erreur'>" . implode("<br />", |
|
| 66 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 67 | - } else { |
|
| 68 | - $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // numerotons les occurrences d'un meme prefix |
|
| 72 | - $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 73 | - |
|
| 74 | - $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 75 | - |
|
| 76 | - return "<li id='$prefix$id' class='$class_li'>" |
|
| 77 | - . ((!$checkable and !$checked) |
|
| 78 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 79 | - . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 80 | - . $cfg |
|
| 81 | - . $erreur |
|
| 82 | - . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 83 | - ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 84 | - . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 85 | - . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 86 | - . "</div>" |
|
| 87 | - . "</li>"; |
|
| 37 | + static $id_input = 0; |
|
| 38 | + static $versions = array(); |
|
| 39 | + |
|
| 40 | + $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 41 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 42 | + $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 43 | + $prefix = $info['prefix']; |
|
| 44 | + $cfg = ""; |
|
| 45 | + $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 46 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 47 | + $erreur = ""; |
|
| 48 | + |
|
| 49 | + if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 50 | + $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 51 | + $erreur = http_img_pack("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err'", |
|
| 52 | + _T('plugin_info_non_compatible_spip')); |
|
| 53 | + $class_li .= " disabled"; |
|
| 54 | + $checkable = false; |
|
| 55 | + } elseif (isset($info['erreur'])) { |
|
| 56 | + $class_li .= " error"; |
|
| 57 | + $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
|
| 58 | + _T('plugin_info_erreur_xml')) |
|
| 59 | + . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 60 | + $checkable = false; |
|
| 61 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 62 | + $class_li .= " error"; |
|
| 63 | + $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
|
| 64 | + " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
|
| 65 | + . "<div class='erreur'>" . implode("<br />", |
|
| 66 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 67 | + } else { |
|
| 68 | + $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // numerotons les occurrences d'un meme prefix |
|
| 72 | + $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 73 | + |
|
| 74 | + $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 75 | + |
|
| 76 | + return "<li id='$prefix$id' class='$class_li'>" |
|
| 77 | + . ((!$checkable and !$checked) |
|
| 78 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 79 | + . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 80 | + . $cfg |
|
| 81 | + . $erreur |
|
| 82 | + . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 83 | + ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 84 | + . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 85 | + . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 86 | + . "</div>" |
|
| 87 | + . "</li>"; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | function plugin_bouton_config($nom, $infos, $dir) { |
| 91 | - // la verification se base sur le filesystem |
|
| 92 | - // il faut donc n'utiliser que des minuscules, par convention |
|
| 93 | - $prefix = strtolower($infos['prefix']); |
|
| 94 | - // si paquet.xml fournit un squelette, le prendre |
|
| 95 | - if (isset($infos['config']) and $infos['config']) { |
|
| 96 | - return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 97 | - array( |
|
| 98 | - 'script' => 'configurer_' . $prefix, |
|
| 99 | - 'nom' => $nom |
|
| 100 | - )); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // si le plugin CFG est la, l'essayer |
|
| 104 | - if (defined('_DIR_PLUGIN_CFG')) { |
|
| 105 | - if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 106 | - { |
|
| 107 | - if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
|
| 108 | - return "<div class='cfg_link'>$cfg</div>"; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // sinon prendre le squelette std sur le nom std |
|
| 114 | - return recuperer_fond("prive/squelettes/inclure/cfg", |
|
| 115 | - array( |
|
| 116 | - 'script' => 'configurer_' . $prefix, |
|
| 117 | - 'nom' => $nom |
|
| 118 | - )); |
|
| 91 | + // la verification se base sur le filesystem |
|
| 92 | + // il faut donc n'utiliser que des minuscules, par convention |
|
| 93 | + $prefix = strtolower($infos['prefix']); |
|
| 94 | + // si paquet.xml fournit un squelette, le prendre |
|
| 95 | + if (isset($infos['config']) and $infos['config']) { |
|
| 96 | + return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 97 | + array( |
|
| 98 | + 'script' => 'configurer_' . $prefix, |
|
| 99 | + 'nom' => $nom |
|
| 100 | + )); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // si le plugin CFG est la, l'essayer |
|
| 104 | + if (defined('_DIR_PLUGIN_CFG')) { |
|
| 105 | + if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 106 | + { |
|
| 107 | + if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
|
| 108 | + return "<div class='cfg_link'>$cfg</div>"; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // sinon prendre le squelette std sur le nom std |
|
| 114 | + return recuperer_fond("prive/squelettes/inclure/cfg", |
|
| 115 | + array( |
|
| 116 | + 'script' => 'configurer_' . $prefix, |
|
| 117 | + 'nom' => $nom |
|
| 118 | + )); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // checkbox pour activer ou desactiver |
| 122 | 122 | // si ce n'est pas une extension |
| 123 | 123 | |
| 124 | 124 | function plugin_checkbox($id_input, $file, $actif) { |
| 125 | - $name = substr(md5($file), 0, 16); |
|
| 126 | - |
|
| 127 | - return "<div class='check'>\n" |
|
| 128 | - . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 129 | - . ($actif ? " checked='checked'" : "") |
|
| 130 | - . " class='checkbox' value='O' />" |
|
| 131 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 132 | - . "</div>"; |
|
| 125 | + $name = substr(md5($file), 0, 16); |
|
| 126 | + |
|
| 127 | + return "<div class='check'>\n" |
|
| 128 | + . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 129 | + . ($actif ? " checked='checked'" : "") |
|
| 130 | + . " class='checkbox' value='O' />" |
|
| 131 | + . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 132 | + . "</div>"; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | function plugin_nom($info, $dir_plugins, $plug_file) { |
| 136 | - $prefix = $info['prefix']; |
|
| 137 | - $dir = "$dir_plugins$plug_file"; |
|
| 138 | - // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 139 | - if ($info['dtd'] == "paquet") { |
|
| 140 | - $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 141 | - if (!$nom) { |
|
| 142 | - $nom = typo($info['nom']); |
|
| 143 | - } |
|
| 144 | - } else { |
|
| 145 | - $nom = typo(attribut_html($info['nom'])); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return trim($nom); |
|
| 136 | + $prefix = $info['prefix']; |
|
| 137 | + $dir = "$dir_plugins$plug_file"; |
|
| 138 | + // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 139 | + if ($info['dtd'] == "paquet") { |
|
| 140 | + $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 141 | + if (!$nom) { |
|
| 142 | + $nom = typo($info['nom']); |
|
| 143 | + } |
|
| 144 | + } else { |
|
| 145 | + $nom = typo(attribut_html($info['nom'])); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return trim($nom); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Cartouche Resume |
| 152 | 152 | function plugin_resume($info, $dir_plugins, $plug_file, $url_page) { |
| 153 | - $prefix = $info['prefix']; |
|
| 154 | - $dir = "$dir_plugins$plug_file"; |
|
| 155 | - $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 156 | - // une seule ligne dans le slogan : couper si besoin |
|
| 157 | - if (($p = strpos($slogan, "<br />")) !== false) { |
|
| 158 | - $slogan = substr($slogan, 0, $p); |
|
| 159 | - } |
|
| 160 | - // couper par securite |
|
| 161 | - $slogan = couper($slogan, 80); |
|
| 162 | - |
|
| 163 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 164 | - |
|
| 165 | - $url = parametre_url($url_page, "plugin", substr($dir, strlen(_DIR_RACINE))); |
|
| 166 | - |
|
| 167 | - $icon_class = 'icon'; |
|
| 168 | - $img = ''; |
|
| 169 | - if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 170 | - if ($img = chemin_image("$dir/$i")) { |
|
| 171 | - $img = http_img_pack($img, '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - if (!$img) { |
|
| 175 | - $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
|
| 176 | - $icon_class .= ' no-logo'; |
|
| 177 | - } |
|
| 178 | - else { |
|
| 153 | + $prefix = $info['prefix']; |
|
| 154 | + $dir = "$dir_plugins$plug_file"; |
|
| 155 | + $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 156 | + // une seule ligne dans le slogan : couper si besoin |
|
| 157 | + if (($p = strpos($slogan, "<br />")) !== false) { |
|
| 158 | + $slogan = substr($slogan, 0, $p); |
|
| 159 | + } |
|
| 160 | + // couper par securite |
|
| 161 | + $slogan = couper($slogan, 80); |
|
| 162 | + |
|
| 163 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 164 | + |
|
| 165 | + $url = parametre_url($url_page, "plugin", substr($dir, strlen(_DIR_RACINE))); |
|
| 166 | + |
|
| 167 | + $icon_class = 'icon'; |
|
| 168 | + $img = ''; |
|
| 169 | + if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 170 | + if ($img = chemin_image("$dir/$i")) { |
|
| 171 | + $img = http_img_pack($img, '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + if (!$img) { |
|
| 175 | + $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
|
| 176 | + $icon_class .= ' no-logo'; |
|
| 177 | + } |
|
| 178 | + else { |
|
| 179 | 179 | # $img = "<img src='$img' width='32' height='32' alt='' />"; |
| 180 | - } |
|
| 181 | - $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 182 | - |
|
| 183 | - return "<div class='resume'>" |
|
| 184 | - . "<h3><a href='$url' rel='info'>" |
|
| 185 | - . $nom |
|
| 186 | - . "</a></h3>" |
|
| 187 | - . " <span class='version'>" . $info['version'] . "</span>" |
|
| 188 | - . " <span class='etat'> - " |
|
| 189 | - . plugin_etat_en_clair($info['etat']) |
|
| 190 | - . "</span>" |
|
| 191 | - . "<div class='short'>" . $slogan . "</div>" |
|
| 192 | - . $i |
|
| 193 | - . "</div>"; |
|
| 180 | + } |
|
| 181 | + $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 182 | + |
|
| 183 | + return "<div class='resume'>" |
|
| 184 | + . "<h3><a href='$url' rel='info'>" |
|
| 185 | + . $nom |
|
| 186 | + . "</a></h3>" |
|
| 187 | + . " <span class='version'>" . $info['version'] . "</span>" |
|
| 188 | + . " <span class='etat'> - " |
|
| 189 | + . plugin_etat_en_clair($info['etat']) |
|
| 190 | + . "</span>" |
|
| 191 | + . "<div class='short'>" . $slogan . "</div>" |
|
| 192 | + . $i |
|
| 193 | + . "</div>"; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 197 | - if (!$dir_plugins) { |
|
| 198 | - $dir_plugins = _DIR_PLUGINS; |
|
| 199 | - } |
|
| 197 | + if (!$dir_plugins) { |
|
| 198 | + $dir_plugins = _DIR_PLUGINS; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 202 | - $text = _T('bouton_desinstaller'); |
|
| 203 | - $text2 = _T('info_desinstaller_plugin'); |
|
| 204 | - $file = basename($plug_file); |
|
| 201 | + $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 202 | + $text = _T('bouton_desinstaller'); |
|
| 203 | + $text2 = _T('info_desinstaller_plugin'); |
|
| 204 | + $file = basename($plug_file); |
|
| 205 | 205 | |
| 206 | - return "<div class='actions'>[" . |
|
| 207 | - "<a href='$action' |
|
| 206 | + return "<div class='actions'>[" . |
|
| 207 | + "<a href='$action' |
|
| 208 | 208 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 209 | - . $text |
|
| 210 | - . "</a>]</div>"; |
|
| 209 | + . $text |
|
| 210 | + . "</a>]</div>"; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -221,137 +221,137 @@ discard block |
||
| 221 | 221 | * Traduction de l'état dans la langue en cours |
| 222 | 222 | **/ |
| 223 | 223 | function plugin_etat_en_clair($etat) { |
| 224 | - if (!in_array($etat, array('stable', 'test', 'experimental'))) { |
|
| 225 | - $etat = 'developpement'; |
|
| 226 | - } |
|
| 224 | + if (!in_array($etat, array('stable', 'test', 'experimental'))) { |
|
| 225 | + $etat = 'developpement'; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - return _T('plugin_etat_' . $etat); |
|
| 228 | + return _T('plugin_etat_' . $etat); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // https://code.spip.net/@plugin_propre |
| 232 | 232 | function plugin_propre($texte, $module = '',$propre='propre') { |
| 233 | - // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 234 | - if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 235 | - $module = substr($module, strlen(_DIR_RACINE)); |
|
| 236 | - } |
|
| 237 | - if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
|
| 238 | - $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return $propre($texte); |
|
| 233 | + // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 234 | + if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 235 | + $module = substr($module, strlen(_DIR_RACINE)); |
|
| 236 | + } |
|
| 237 | + if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
|
| 238 | + $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return $propre($texte); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function plugin_typo($texte, $module = '') { |
| 245 | - return plugin_propre($texte, $module, 'typo'); |
|
| 245 | + return plugin_propre($texte, $module, 'typo'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | // https://code.spip.net/@affiche_bloc_plugin |
| 250 | 250 | function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) { |
| 251 | - if (!$dir_plugins) { |
|
| 252 | - $dir_plugins = _DIR_PLUGINS; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $prefix = $info['prefix']; |
|
| 256 | - $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 257 | - |
|
| 258 | - $s = ""; |
|
| 259 | - // TODO: le traiter_multi ici n'est pas beau |
|
| 260 | - // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 261 | - // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 262 | - $description = ""; |
|
| 263 | - if (isset($info['description'])) { |
|
| 264 | - $description = plugin_propre($info['description'], $dir); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - if (isset($info['documentation']) |
|
| 268 | - and $lien = $info['documentation'] |
|
| 269 | - ) { |
|
| 270 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 271 | - } |
|
| 272 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 273 | - |
|
| 274 | - if (isset($info['auteur'])) { |
|
| 275 | - if (is_array($info['auteur'])) { |
|
| 276 | - $a = formater_credits($info['auteur'], ', '); |
|
| 277 | - } // pour compat mais ne doit plus arriver |
|
| 278 | - else { |
|
| 279 | - $a = trim($info['auteur']); |
|
| 280 | - } |
|
| 281 | - if ($a) { |
|
| 282 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 283 | - $dir)) . "</dd>\n"; |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - if (isset($info['credit'])) { |
|
| 288 | - if ($a = formater_credits($info['credit'], ', ')) { |
|
| 289 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 290 | - $dir)) . "</dd>\n"; |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - if (isset($info['licence'])) { |
|
| 295 | - if (is_array($info['licence'])) { |
|
| 296 | - $a = formater_credits($info['licence'], ', '); |
|
| 297 | - } // pour compat mais ne doit plus arriver |
|
| 298 | - else { |
|
| 299 | - $a = trim($info['licence']); |
|
| 300 | - } |
|
| 301 | - if ($a) { |
|
| 302 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 303 | - $dir)) . "</dd>\n"; |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - $s = "<dl class='description'>$s</dl>"; |
|
| 308 | - |
|
| 309 | - // |
|
| 310 | - // Ajouter les infos techniques |
|
| 311 | - // |
|
| 312 | - $infotech = array(); |
|
| 313 | - |
|
| 314 | - $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 315 | - // Version VCS |
|
| 316 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 317 | - $version .= ' ' . $vcs; |
|
| 318 | - } |
|
| 319 | - $version .= "</dd>"; |
|
| 320 | - $infotech[] = $version; |
|
| 321 | - $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 322 | - // source zip le cas echeant |
|
| 323 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 324 | - and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 325 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 326 | - : ''; |
|
| 327 | - |
|
| 328 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 329 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 330 | - array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 331 | - |
|
| 332 | - $s .= "<dl class='tech'>" |
|
| 333 | - . join('', $infotech) |
|
| 334 | - . "</dl>"; |
|
| 335 | - |
|
| 336 | - |
|
| 337 | - return $s; |
|
| 251 | + if (!$dir_plugins) { |
|
| 252 | + $dir_plugins = _DIR_PLUGINS; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $prefix = $info['prefix']; |
|
| 256 | + $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 257 | + |
|
| 258 | + $s = ""; |
|
| 259 | + // TODO: le traiter_multi ici n'est pas beau |
|
| 260 | + // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 261 | + // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 262 | + $description = ""; |
|
| 263 | + if (isset($info['description'])) { |
|
| 264 | + $description = plugin_propre($info['description'], $dir); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if (isset($info['documentation']) |
|
| 268 | + and $lien = $info['documentation'] |
|
| 269 | + ) { |
|
| 270 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 271 | + } |
|
| 272 | + $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 273 | + |
|
| 274 | + if (isset($info['auteur'])) { |
|
| 275 | + if (is_array($info['auteur'])) { |
|
| 276 | + $a = formater_credits($info['auteur'], ', '); |
|
| 277 | + } // pour compat mais ne doit plus arriver |
|
| 278 | + else { |
|
| 279 | + $a = trim($info['auteur']); |
|
| 280 | + } |
|
| 281 | + if ($a) { |
|
| 282 | + $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 283 | + $dir)) . "</dd>\n"; |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + if (isset($info['credit'])) { |
|
| 288 | + if ($a = formater_credits($info['credit'], ', ')) { |
|
| 289 | + $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 290 | + $dir)) . "</dd>\n"; |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + if (isset($info['licence'])) { |
|
| 295 | + if (is_array($info['licence'])) { |
|
| 296 | + $a = formater_credits($info['licence'], ', '); |
|
| 297 | + } // pour compat mais ne doit plus arriver |
|
| 298 | + else { |
|
| 299 | + $a = trim($info['licence']); |
|
| 300 | + } |
|
| 301 | + if ($a) { |
|
| 302 | + $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 303 | + $dir)) . "</dd>\n"; |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + $s = "<dl class='description'>$s</dl>"; |
|
| 308 | + |
|
| 309 | + // |
|
| 310 | + // Ajouter les infos techniques |
|
| 311 | + // |
|
| 312 | + $infotech = array(); |
|
| 313 | + |
|
| 314 | + $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 315 | + // Version VCS |
|
| 316 | + if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 317 | + $version .= ' ' . $vcs; |
|
| 318 | + } |
|
| 319 | + $version .= "</dd>"; |
|
| 320 | + $infotech[] = $version; |
|
| 321 | + $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 322 | + // source zip le cas echeant |
|
| 323 | + $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 324 | + and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 325 | + ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 326 | + : ''; |
|
| 327 | + |
|
| 328 | + $infotech[] = !$info['necessite'] ? '' : |
|
| 329 | + ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 330 | + array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 331 | + |
|
| 332 | + $s .= "<dl class='tech'>" |
|
| 333 | + . join('', $infotech) |
|
| 334 | + . "</dl>"; |
|
| 335 | + |
|
| 336 | + |
|
| 337 | + return $s; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | function formater_credits($infos, $sep = ', ') { |
| 341 | - $texte = ''; |
|
| 342 | - |
|
| 343 | - foreach ($infos as $_credit) { |
|
| 344 | - if ($texte) { |
|
| 345 | - $texte .= $sep; |
|
| 346 | - } |
|
| 347 | - // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 348 | - $texte .= |
|
| 349 | - (!is_array($_credit)) |
|
| 350 | - ? PtoBR(propre($_credit)) |
|
| 351 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 352 | - $_credit['nom'] . |
|
| 353 | - ($_credit['url'] ? '</a>' : ''); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - return $texte; |
|
| 341 | + $texte = ''; |
|
| 342 | + |
|
| 343 | + foreach ($infos as $_credit) { |
|
| 344 | + if ($texte) { |
|
| 345 | + $texte .= $sep; |
|
| 346 | + } |
|
| 347 | + // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 348 | + $texte .= |
|
| 349 | + (!is_array($_credit)) |
|
| 350 | + ? PtoBR(propre($_credit)) |
|
| 351 | + : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 352 | + $_credit['nom'] . |
|
| 353 | + ($_credit['url'] ? '</a>' : ''); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + return $texte; |
|
| 357 | 357 | } |
@@ -102,10 +102,12 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | // si le plugin CFG est la, l'essayer |
| 104 | 104 | if (defined('_DIR_PLUGIN_CFG')) { |
| 105 | - if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 105 | + if (include_spip('inc/cfg')) { |
|
| 106 | + // test CFG version >= 1.0.5 |
|
| 106 | 107 | { |
| 107 | 108 | if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
| 108 | 109 | return "<div class='cfg_link'>$cfg</div>"; |
| 110 | + } |
|
| 109 | 111 | } |
| 110 | 112 | } |
| 111 | 113 | } |
@@ -174,8 +176,7 @@ discard block |
||
| 174 | 176 | if (!$img) { |
| 175 | 177 | $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
| 176 | 178 | $icon_class .= ' no-logo'; |
| 177 | - } |
|
| 178 | - else { |
|
| 179 | + } else { |
|
| 179 | 180 | # $img = "<img src='$img' width='32' height='32' alt='' />"; |
| 180 | 181 | } |
| 181 | 182 | $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |