@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | // Si a ce stade on n'a pas de table, il y a un bug |
| 164 | 164 | if (!is_array($this->tableau)) { |
| 165 | 165 | $this->err = true; |
| 166 | - spip_log('erreur datasource ' . var_export($command, true)); |
|
| 166 | + spip_log('erreur datasource '.var_export($command, true)); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // {datapath query.results} |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | isset($this->command['sourcemode']) |
| 206 | 206 | and !in_array($this->command['sourcemode'], ['table', 'array', 'tableau']) |
| 207 | 207 | ) { |
| 208 | - charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true); |
|
| 208 | + charger_fonction($this->command['sourcemode'].'_to_array', 'inc', true); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | # le premier argument peut etre un array, une URL etc. |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | # avons-nous un cache dispo ? |
| 215 | 215 | $cle = null; |
| 216 | 216 | if (is_string($src)) { |
| 217 | - $cle = 'datasource_' . md5($this->command['sourcemode'] . ':' . var_export($this->command['source'], true)); |
|
| 217 | + $cle = 'datasource_'.md5($this->command['sourcemode'].':'.var_export($this->command['source'], true)); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | $cache = $this->cache_get($cle); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | if ( |
| 274 | 274 | !$this->err |
| 275 | - and $data_to_array = charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true) |
|
| 275 | + and $data_to_array = charger_fonction($this->command['sourcemode'].'_to_array', 'inc', true) |
|
| 276 | 276 | ) { |
| 277 | 277 | $args = $this->command['source']; |
| 278 | 278 | $args[0] = $data; |
@@ -412,13 +412,13 @@ discard block |
||
| 412 | 412 | $tv = '%s'; |
| 413 | 413 | } # {par valeur/xx/yy} ?? |
| 414 | 414 | else { |
| 415 | - $tv = 'table_valeur(%s, ' . var_export($r[1], true) . ')'; |
|
| 415 | + $tv = 'table_valeur(%s, '.var_export($r[1], true).')'; |
|
| 416 | 416 | } |
| 417 | 417 | $sortfunc .= ' |
| 418 | - $a = ' . sprintf($tv, '$aa') . '; |
|
| 419 | - $b = ' . sprintf($tv, '$bb') . '; |
|
| 418 | + $a = ' . sprintf($tv, '$aa').'; |
|
| 419 | + $b = ' . sprintf($tv, '$bb').'; |
|
| 420 | 420 | if ($a <> $b) |
| 421 | - return ($a ' . (!empty($r[2]) ? '>' : '<') . ' $b) ? -1 : 1;'; |
|
| 421 | + return ($a ' . (!empty($r[2]) ? '>' : '<').' $b) ? -1 : 1;'; |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | } |
@@ -12,498 +12,498 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Data extends AbstractIterateur implements Iterator |
| 14 | 14 | { |
| 15 | - /** Tableau de données */ |
|
| 16 | - protected array $tableau = []; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * Conditions de filtrage |
|
| 20 | - * ie criteres de selection |
|
| 21 | - */ |
|
| 22 | - protected array $filtre = []; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Cle courante |
|
| 26 | - * |
|
| 27 | - * @var scalar |
|
| 28 | - */ |
|
| 29 | - protected $cle = null; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Valeur courante |
|
| 33 | - * |
|
| 34 | - * @var mixed |
|
| 35 | - */ |
|
| 36 | - protected $valeur = null; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Constructeur |
|
| 40 | - * |
|
| 41 | - * @param $command |
|
| 42 | - * @param array $info |
|
| 43 | - */ |
|
| 44 | - public function __construct(array $command, array $info = []) { |
|
| 45 | - include_spip('iterateur/data'); |
|
| 46 | - $this->type = 'DATA'; |
|
| 47 | - $this->command = $command; |
|
| 48 | - $this->info = $info; |
|
| 49 | - $this->select($command); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Revenir au depart |
|
| 54 | - * |
|
| 55 | - * @return void |
|
| 56 | - */ |
|
| 57 | - public function rewind(): void { |
|
| 58 | - reset($this->tableau); |
|
| 59 | - $this->cle = array_key_first($this->tableau); |
|
| 60 | - $this->valeur = current($this->tableau); |
|
| 61 | - next($this->tableau); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Déclarer les critères exceptions |
|
| 66 | - * |
|
| 67 | - * @return array |
|
| 68 | - */ |
|
| 69 | - public function exception_des_criteres() { |
|
| 70 | - return ['tableau']; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Récupérer depuis le cache si possible |
|
| 75 | - * |
|
| 76 | - * @param string $cle |
|
| 77 | - * @return mixed |
|
| 78 | - */ |
|
| 79 | - protected function cache_get($cle) { |
|
| 80 | - if (!$cle) { |
|
| 81 | - return; |
|
| 82 | - } |
|
| 83 | - # utiliser memoization si dispo |
|
| 84 | - if (!function_exists('cache_get')) { |
|
| 85 | - return; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return cache_get($cle); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Stocker en cache si possible |
|
| 93 | - * |
|
| 94 | - * @param string $cle |
|
| 95 | - * @param int $ttl |
|
| 96 | - * @param null|mixed $valeur |
|
| 97 | - * @return bool |
|
| 98 | - */ |
|
| 99 | - protected function cache_set($cle, $ttl, $valeur = null) { |
|
| 100 | - if (!$cle) { |
|
| 101 | - return; |
|
| 102 | - } |
|
| 103 | - if (is_null($valeur)) { |
|
| 104 | - $valeur = $this->tableau; |
|
| 105 | - } |
|
| 106 | - # utiliser memoization si dispo |
|
| 107 | - if (!function_exists('cache_set')) { |
|
| 108 | - return; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return cache_set( |
|
| 112 | - $cle, |
|
| 113 | - [ |
|
| 114 | - 'data' => $valeur, |
|
| 115 | - 'time' => time(), |
|
| 116 | - 'ttl' => $ttl |
|
| 117 | - ], |
|
| 118 | - 3600 + $ttl |
|
| 119 | - ); |
|
| 120 | - # conserver le cache 1h de plus que la validite demandee, |
|
| 121 | - # pour le cas ou le serveur distant ne reponde plus |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Aller chercher les données de la boucle DATA |
|
| 126 | - * |
|
| 127 | - * @throws Exception |
|
| 128 | - * @param array $command |
|
| 129 | - * @return void |
|
| 130 | - */ |
|
| 131 | - protected function select($command) { |
|
| 132 | - |
|
| 133 | - // l'iterateur DATA peut etre appele en passant (data:type) |
|
| 134 | - // le type se retrouve dans la commande 'from' |
|
| 135 | - // dans ce cas la le critere {source}, si present, n'a pas besoin du 1er argument |
|
| 136 | - if (isset($this->command['from'][0])) { |
|
| 137 | - if (isset($this->command['source']) and is_array($this->command['source'])) { |
|
| 138 | - array_unshift($this->command['source'], $this->command['sourcemode']); |
|
| 139 | - } |
|
| 140 | - $this->command['sourcemode'] = $this->command['from'][0]; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // cherchons differents moyens de creer le tableau de donnees |
|
| 144 | - // les commandes connues pour l'iterateur DATA |
|
| 145 | - // sont : {tableau #ARRAY} ; {cle=...} ; {valeur=...} |
|
| 146 | - |
|
| 147 | - // {source format, [URL], [arg2]...} |
|
| 148 | - if ( |
|
| 149 | - isset($this->command['source']) |
|
| 150 | - and isset($this->command['sourcemode']) |
|
| 151 | - ) { |
|
| 152 | - $this->select_source(); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - // Critere {liste X1, X2, X3} |
|
| 156 | - if (isset($this->command['liste'])) { |
|
| 157 | - $this->select_liste(); |
|
| 158 | - } |
|
| 159 | - if (isset($this->command['enum'])) { |
|
| 160 | - $this->select_enum(); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // Si a ce stade on n'a pas de table, il y a un bug |
|
| 164 | - if (!is_array($this->tableau)) { |
|
| 165 | - $this->err = true; |
|
| 166 | - spip_log('erreur datasource ' . var_export($command, true)); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - // {datapath query.results} |
|
| 170 | - // extraire le chemin "query.results" du tableau de donnees |
|
| 171 | - if ( |
|
| 172 | - !$this->err |
|
| 173 | - and isset($this->command['datapath']) |
|
| 174 | - and is_array($this->command['datapath']) |
|
| 175 | - ) { |
|
| 176 | - $this->select_datapath(); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - // tri {par x} |
|
| 180 | - if ($this->command['orderby']) { |
|
| 181 | - $this->select_orderby(); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // grouper les resultats {fusion /x/y/z} ; |
|
| 185 | - if ($this->command['groupby']) { |
|
| 186 | - $this->select_groupby(); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - $this->rewind(); |
|
| 190 | - #var_dump($this->tableau); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Aller chercher les donnees de la boucle DATA |
|
| 196 | - * depuis une source |
|
| 197 | - * {source format, [URL], [arg2]...} |
|
| 198 | - */ |
|
| 199 | - protected function select_source() { |
|
| 200 | - # un peu crado : avant de charger le cache il faut charger |
|
| 201 | - # les class indispensables, sinon PHP ne saura pas gerer |
|
| 202 | - # l'objet en cache ; cf plugins/icalendar |
|
| 203 | - # perf : pas de fonction table_to_array ! (table est deja un array) |
|
| 204 | - if ( |
|
| 205 | - isset($this->command['sourcemode']) |
|
| 206 | - and !in_array($this->command['sourcemode'], ['table', 'array', 'tableau']) |
|
| 207 | - ) { |
|
| 208 | - charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - # le premier argument peut etre un array, une URL etc. |
|
| 212 | - $src = $this->command['source'][0] ?? null; |
|
| 213 | - |
|
| 214 | - # avons-nous un cache dispo ? |
|
| 215 | - $cle = null; |
|
| 216 | - if (is_string($src)) { |
|
| 217 | - $cle = 'datasource_' . md5($this->command['sourcemode'] . ':' . var_export($this->command['source'], true)); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - $cache = $this->cache_get($cle); |
|
| 221 | - if (isset($this->command['datacache'])) { |
|
| 222 | - $ttl = intval($this->command['datacache']); |
|
| 223 | - } |
|
| 224 | - if ( |
|
| 225 | - $cache |
|
| 226 | - and ($cache['time'] + ($ttl ?? $cache['ttl']) |
|
| 227 | - > time()) |
|
| 228 | - and !(_request('var_mode') === 'recalcul' |
|
| 229 | - and include_spip('inc/autoriser') |
|
| 230 | - and autoriser('recalcul') |
|
| 231 | - ) |
|
| 232 | - ) { |
|
| 233 | - $this->tableau = $cache['data']; |
|
| 234 | - } else { |
|
| 235 | - try { |
|
| 236 | - if ( |
|
| 237 | - isset($this->command['sourcemode']) |
|
| 238 | - and in_array( |
|
| 239 | - $this->command['sourcemode'], |
|
| 240 | - ['table', 'array', 'tableau'] |
|
| 241 | - ) |
|
| 242 | - ) { |
|
| 243 | - if ( |
|
| 244 | - is_array($a = $src) |
|
| 245 | - or (is_string($a) |
|
| 246 | - and $a = str_replace('"', '"', $a) # fragile! |
|
| 247 | - and is_array($a = @unserialize($a))) |
|
| 248 | - ) { |
|
| 249 | - $this->tableau = $a; |
|
| 250 | - } |
|
| 251 | - } else { |
|
| 252 | - $data = $src; |
|
| 253 | - if (is_string($src)) { |
|
| 254 | - if (tester_url_absolue($src)) { |
|
| 255 | - include_spip('inc/distant'); |
|
| 256 | - $data = recuperer_url($src, ['taille_max' => _DATA_SOURCE_MAX_SIZE]); |
|
| 257 | - $data = $data['page'] ?? ''; |
|
| 258 | - if (!$data) { |
|
| 259 | - throw new Exception('404'); |
|
| 260 | - } |
|
| 261 | - if (!isset($ttl)) { |
|
| 262 | - $ttl = 24 * 3600; |
|
| 263 | - } |
|
| 264 | - } elseif (@is_dir($src)) { |
|
| 265 | - $data = $src; |
|
| 266 | - } elseif (@is_readable($src) && @is_file($src)) { |
|
| 267 | - $data = spip_file_get_contents($src); |
|
| 268 | - } |
|
| 269 | - if (!isset($ttl)) { |
|
| 270 | - $ttl = 10; |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - if ( |
|
| 274 | - !$this->err |
|
| 275 | - and $data_to_array = charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true) |
|
| 276 | - ) { |
|
| 277 | - $args = $this->command['source']; |
|
| 278 | - $args[0] = $data; |
|
| 279 | - if (is_array($a = $data_to_array(...$args))) { |
|
| 280 | - $this->tableau = $a; |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - if (!is_array($this->tableau)) { |
|
| 286 | - $this->err = true; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - if (!$this->err and isset($ttl) and $ttl > 0) { |
|
| 290 | - $this->cache_set($cle, $ttl); |
|
| 291 | - } |
|
| 292 | - } catch (Exception $e) { |
|
| 293 | - $e = $e->getMessage(); |
|
| 294 | - $err = sprintf( |
|
| 295 | - "[%s, %s] $e", |
|
| 296 | - $src, |
|
| 297 | - $this->command['sourcemode'] |
|
| 298 | - ); |
|
| 299 | - erreur_squelette([$err, []]); |
|
| 300 | - $this->err = true; |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - # en cas d'erreur, utiliser le cache si encore dispo |
|
| 305 | - if ( |
|
| 306 | - $this->err |
|
| 307 | - and $cache |
|
| 308 | - ) { |
|
| 309 | - $this->tableau = $cache['data']; |
|
| 310 | - $this->err = false; |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * Retourne un tableau donne depuis un critère liste |
|
| 317 | - * |
|
| 318 | - * Critère `{liste X1, X2, X3}` |
|
| 319 | - * |
|
| 320 | - * @see critere_DATA_liste_dist() |
|
| 321 | - * |
|
| 322 | - **/ |
|
| 323 | - protected function select_liste() { |
|
| 324 | - # s'il n'y a qu'une valeur dans la liste, sans doute une #BALISE |
|
| 325 | - if (!isset($this->command['liste'][1])) { |
|
| 326 | - if (!is_array($this->command['liste'][0])) { |
|
| 327 | - $this->command['liste'] = explode(',', $this->command['liste'][0]); |
|
| 328 | - } else { |
|
| 329 | - $this->command['liste'] = $this->command['liste'][0]; |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - $this->tableau = $this->command['liste']; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * Retourne un tableau donne depuis un critere liste |
|
| 337 | - * Critere {enum Xmin, Xmax} |
|
| 338 | - * |
|
| 339 | - **/ |
|
| 340 | - protected function select_enum() { |
|
| 341 | - # s'il n'y a qu'une valeur dans la liste, sans doute une #BALISE |
|
| 342 | - if (!isset($this->command['enum'][1])) { |
|
| 343 | - if (!is_array($this->command['enum'][0])) { |
|
| 344 | - $this->command['enum'] = explode(',', $this->command['enum'][0]); |
|
| 345 | - } else { |
|
| 346 | - $this->command['enum'] = $this->command['enum'][0]; |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - if ((is_countable($this->command['enum']) ? count($this->command['enum']) : 0) >= 3) { |
|
| 350 | - $enum = range( |
|
| 351 | - array_shift($this->command['enum']), |
|
| 352 | - array_shift($this->command['enum']), |
|
| 353 | - array_shift($this->command['enum']) |
|
| 354 | - ); |
|
| 355 | - } else { |
|
| 356 | - $enum = range(array_shift($this->command['enum']), array_shift($this->command['enum'])); |
|
| 357 | - } |
|
| 358 | - $this->tableau = $enum; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * extraire le chemin "query.results" du tableau de donnees |
|
| 364 | - * {datapath query.results} |
|
| 365 | - * |
|
| 366 | - **/ |
|
| 367 | - protected function select_datapath() { |
|
| 368 | - $base = reset($this->command['datapath']); |
|
| 369 | - if (strlen($base = ltrim(trim($base), '/'))) { |
|
| 370 | - $this->tableau = table_valeur($this->tableau, $base); |
|
| 371 | - if (!is_array($this->tableau)) { |
|
| 372 | - $this->tableau = []; |
|
| 373 | - $this->err = true; |
|
| 374 | - spip_log("datapath '$base' absent"); |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * Ordonner les resultats |
|
| 381 | - * {par x} |
|
| 382 | - * |
|
| 383 | - **/ |
|
| 384 | - protected function select_orderby() { |
|
| 385 | - $sortfunc = ''; |
|
| 386 | - $aleas = 0; |
|
| 387 | - foreach ($this->command['orderby'] as $tri) { |
|
| 388 | - // virer le / initial pour les criteres de la forme {par /xx} |
|
| 389 | - if (preg_match(',^\.?([/\w:_-]+)( DESC)?$,iS', ltrim($tri, '/'), $r)) { |
|
| 390 | - $r = array_pad($r, 3, null); |
|
| 391 | - |
|
| 392 | - // tri par cle |
|
| 393 | - if ($r[1] == 'cle') { |
|
| 394 | - if (isset($r[2]) and $r[2]) { |
|
| 395 | - krsort($this->tableau); |
|
| 396 | - } else { |
|
| 397 | - ksort($this->tableau); |
|
| 398 | - } |
|
| 399 | - } # {par hasard} |
|
| 400 | - else { |
|
| 401 | - if ($r[1] == 'hasard') { |
|
| 402 | - $k = array_keys($this->tableau); |
|
| 403 | - shuffle($k); |
|
| 404 | - $v = []; |
|
| 405 | - foreach ($k as $cle) { |
|
| 406 | - $v[$cle] = $this->tableau[$cle]; |
|
| 407 | - } |
|
| 408 | - $this->tableau = $v; |
|
| 409 | - } else { |
|
| 410 | - # {par valeur} |
|
| 411 | - if ($r[1] == 'valeur') { |
|
| 412 | - $tv = '%s'; |
|
| 413 | - } # {par valeur/xx/yy} ?? |
|
| 414 | - else { |
|
| 415 | - $tv = 'table_valeur(%s, ' . var_export($r[1], true) . ')'; |
|
| 416 | - } |
|
| 417 | - $sortfunc .= ' |
|
| 15 | + /** Tableau de données */ |
|
| 16 | + protected array $tableau = []; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * Conditions de filtrage |
|
| 20 | + * ie criteres de selection |
|
| 21 | + */ |
|
| 22 | + protected array $filtre = []; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Cle courante |
|
| 26 | + * |
|
| 27 | + * @var scalar |
|
| 28 | + */ |
|
| 29 | + protected $cle = null; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Valeur courante |
|
| 33 | + * |
|
| 34 | + * @var mixed |
|
| 35 | + */ |
|
| 36 | + protected $valeur = null; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Constructeur |
|
| 40 | + * |
|
| 41 | + * @param $command |
|
| 42 | + * @param array $info |
|
| 43 | + */ |
|
| 44 | + public function __construct(array $command, array $info = []) { |
|
| 45 | + include_spip('iterateur/data'); |
|
| 46 | + $this->type = 'DATA'; |
|
| 47 | + $this->command = $command; |
|
| 48 | + $this->info = $info; |
|
| 49 | + $this->select($command); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Revenir au depart |
|
| 54 | + * |
|
| 55 | + * @return void |
|
| 56 | + */ |
|
| 57 | + public function rewind(): void { |
|
| 58 | + reset($this->tableau); |
|
| 59 | + $this->cle = array_key_first($this->tableau); |
|
| 60 | + $this->valeur = current($this->tableau); |
|
| 61 | + next($this->tableau); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Déclarer les critères exceptions |
|
| 66 | + * |
|
| 67 | + * @return array |
|
| 68 | + */ |
|
| 69 | + public function exception_des_criteres() { |
|
| 70 | + return ['tableau']; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Récupérer depuis le cache si possible |
|
| 75 | + * |
|
| 76 | + * @param string $cle |
|
| 77 | + * @return mixed |
|
| 78 | + */ |
|
| 79 | + protected function cache_get($cle) { |
|
| 80 | + if (!$cle) { |
|
| 81 | + return; |
|
| 82 | + } |
|
| 83 | + # utiliser memoization si dispo |
|
| 84 | + if (!function_exists('cache_get')) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return cache_get($cle); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Stocker en cache si possible |
|
| 93 | + * |
|
| 94 | + * @param string $cle |
|
| 95 | + * @param int $ttl |
|
| 96 | + * @param null|mixed $valeur |
|
| 97 | + * @return bool |
|
| 98 | + */ |
|
| 99 | + protected function cache_set($cle, $ttl, $valeur = null) { |
|
| 100 | + if (!$cle) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | + if (is_null($valeur)) { |
|
| 104 | + $valeur = $this->tableau; |
|
| 105 | + } |
|
| 106 | + # utiliser memoization si dispo |
|
| 107 | + if (!function_exists('cache_set')) { |
|
| 108 | + return; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + return cache_set( |
|
| 112 | + $cle, |
|
| 113 | + [ |
|
| 114 | + 'data' => $valeur, |
|
| 115 | + 'time' => time(), |
|
| 116 | + 'ttl' => $ttl |
|
| 117 | + ], |
|
| 118 | + 3600 + $ttl |
|
| 119 | + ); |
|
| 120 | + # conserver le cache 1h de plus que la validite demandee, |
|
| 121 | + # pour le cas ou le serveur distant ne reponde plus |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Aller chercher les données de la boucle DATA |
|
| 126 | + * |
|
| 127 | + * @throws Exception |
|
| 128 | + * @param array $command |
|
| 129 | + * @return void |
|
| 130 | + */ |
|
| 131 | + protected function select($command) { |
|
| 132 | + |
|
| 133 | + // l'iterateur DATA peut etre appele en passant (data:type) |
|
| 134 | + // le type se retrouve dans la commande 'from' |
|
| 135 | + // dans ce cas la le critere {source}, si present, n'a pas besoin du 1er argument |
|
| 136 | + if (isset($this->command['from'][0])) { |
|
| 137 | + if (isset($this->command['source']) and is_array($this->command['source'])) { |
|
| 138 | + array_unshift($this->command['source'], $this->command['sourcemode']); |
|
| 139 | + } |
|
| 140 | + $this->command['sourcemode'] = $this->command['from'][0]; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // cherchons differents moyens de creer le tableau de donnees |
|
| 144 | + // les commandes connues pour l'iterateur DATA |
|
| 145 | + // sont : {tableau #ARRAY} ; {cle=...} ; {valeur=...} |
|
| 146 | + |
|
| 147 | + // {source format, [URL], [arg2]...} |
|
| 148 | + if ( |
|
| 149 | + isset($this->command['source']) |
|
| 150 | + and isset($this->command['sourcemode']) |
|
| 151 | + ) { |
|
| 152 | + $this->select_source(); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + // Critere {liste X1, X2, X3} |
|
| 156 | + if (isset($this->command['liste'])) { |
|
| 157 | + $this->select_liste(); |
|
| 158 | + } |
|
| 159 | + if (isset($this->command['enum'])) { |
|
| 160 | + $this->select_enum(); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // Si a ce stade on n'a pas de table, il y a un bug |
|
| 164 | + if (!is_array($this->tableau)) { |
|
| 165 | + $this->err = true; |
|
| 166 | + spip_log('erreur datasource ' . var_export($command, true)); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + // {datapath query.results} |
|
| 170 | + // extraire le chemin "query.results" du tableau de donnees |
|
| 171 | + if ( |
|
| 172 | + !$this->err |
|
| 173 | + and isset($this->command['datapath']) |
|
| 174 | + and is_array($this->command['datapath']) |
|
| 175 | + ) { |
|
| 176 | + $this->select_datapath(); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + // tri {par x} |
|
| 180 | + if ($this->command['orderby']) { |
|
| 181 | + $this->select_orderby(); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // grouper les resultats {fusion /x/y/z} ; |
|
| 185 | + if ($this->command['groupby']) { |
|
| 186 | + $this->select_groupby(); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + $this->rewind(); |
|
| 190 | + #var_dump($this->tableau); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Aller chercher les donnees de la boucle DATA |
|
| 196 | + * depuis une source |
|
| 197 | + * {source format, [URL], [arg2]...} |
|
| 198 | + */ |
|
| 199 | + protected function select_source() { |
|
| 200 | + # un peu crado : avant de charger le cache il faut charger |
|
| 201 | + # les class indispensables, sinon PHP ne saura pas gerer |
|
| 202 | + # l'objet en cache ; cf plugins/icalendar |
|
| 203 | + # perf : pas de fonction table_to_array ! (table est deja un array) |
|
| 204 | + if ( |
|
| 205 | + isset($this->command['sourcemode']) |
|
| 206 | + and !in_array($this->command['sourcemode'], ['table', 'array', 'tableau']) |
|
| 207 | + ) { |
|
| 208 | + charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + # le premier argument peut etre un array, une URL etc. |
|
| 212 | + $src = $this->command['source'][0] ?? null; |
|
| 213 | + |
|
| 214 | + # avons-nous un cache dispo ? |
|
| 215 | + $cle = null; |
|
| 216 | + if (is_string($src)) { |
|
| 217 | + $cle = 'datasource_' . md5($this->command['sourcemode'] . ':' . var_export($this->command['source'], true)); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + $cache = $this->cache_get($cle); |
|
| 221 | + if (isset($this->command['datacache'])) { |
|
| 222 | + $ttl = intval($this->command['datacache']); |
|
| 223 | + } |
|
| 224 | + if ( |
|
| 225 | + $cache |
|
| 226 | + and ($cache['time'] + ($ttl ?? $cache['ttl']) |
|
| 227 | + > time()) |
|
| 228 | + and !(_request('var_mode') === 'recalcul' |
|
| 229 | + and include_spip('inc/autoriser') |
|
| 230 | + and autoriser('recalcul') |
|
| 231 | + ) |
|
| 232 | + ) { |
|
| 233 | + $this->tableau = $cache['data']; |
|
| 234 | + } else { |
|
| 235 | + try { |
|
| 236 | + if ( |
|
| 237 | + isset($this->command['sourcemode']) |
|
| 238 | + and in_array( |
|
| 239 | + $this->command['sourcemode'], |
|
| 240 | + ['table', 'array', 'tableau'] |
|
| 241 | + ) |
|
| 242 | + ) { |
|
| 243 | + if ( |
|
| 244 | + is_array($a = $src) |
|
| 245 | + or (is_string($a) |
|
| 246 | + and $a = str_replace('"', '"', $a) # fragile! |
|
| 247 | + and is_array($a = @unserialize($a))) |
|
| 248 | + ) { |
|
| 249 | + $this->tableau = $a; |
|
| 250 | + } |
|
| 251 | + } else { |
|
| 252 | + $data = $src; |
|
| 253 | + if (is_string($src)) { |
|
| 254 | + if (tester_url_absolue($src)) { |
|
| 255 | + include_spip('inc/distant'); |
|
| 256 | + $data = recuperer_url($src, ['taille_max' => _DATA_SOURCE_MAX_SIZE]); |
|
| 257 | + $data = $data['page'] ?? ''; |
|
| 258 | + if (!$data) { |
|
| 259 | + throw new Exception('404'); |
|
| 260 | + } |
|
| 261 | + if (!isset($ttl)) { |
|
| 262 | + $ttl = 24 * 3600; |
|
| 263 | + } |
|
| 264 | + } elseif (@is_dir($src)) { |
|
| 265 | + $data = $src; |
|
| 266 | + } elseif (@is_readable($src) && @is_file($src)) { |
|
| 267 | + $data = spip_file_get_contents($src); |
|
| 268 | + } |
|
| 269 | + if (!isset($ttl)) { |
|
| 270 | + $ttl = 10; |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + if ( |
|
| 274 | + !$this->err |
|
| 275 | + and $data_to_array = charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true) |
|
| 276 | + ) { |
|
| 277 | + $args = $this->command['source']; |
|
| 278 | + $args[0] = $data; |
|
| 279 | + if (is_array($a = $data_to_array(...$args))) { |
|
| 280 | + $this->tableau = $a; |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + if (!is_array($this->tableau)) { |
|
| 286 | + $this->err = true; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + if (!$this->err and isset($ttl) and $ttl > 0) { |
|
| 290 | + $this->cache_set($cle, $ttl); |
|
| 291 | + } |
|
| 292 | + } catch (Exception $e) { |
|
| 293 | + $e = $e->getMessage(); |
|
| 294 | + $err = sprintf( |
|
| 295 | + "[%s, %s] $e", |
|
| 296 | + $src, |
|
| 297 | + $this->command['sourcemode'] |
|
| 298 | + ); |
|
| 299 | + erreur_squelette([$err, []]); |
|
| 300 | + $this->err = true; |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + # en cas d'erreur, utiliser le cache si encore dispo |
|
| 305 | + if ( |
|
| 306 | + $this->err |
|
| 307 | + and $cache |
|
| 308 | + ) { |
|
| 309 | + $this->tableau = $cache['data']; |
|
| 310 | + $this->err = false; |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * Retourne un tableau donne depuis un critère liste |
|
| 317 | + * |
|
| 318 | + * Critère `{liste X1, X2, X3}` |
|
| 319 | + * |
|
| 320 | + * @see critere_DATA_liste_dist() |
|
| 321 | + * |
|
| 322 | + **/ |
|
| 323 | + protected function select_liste() { |
|
| 324 | + # s'il n'y a qu'une valeur dans la liste, sans doute une #BALISE |
|
| 325 | + if (!isset($this->command['liste'][1])) { |
|
| 326 | + if (!is_array($this->command['liste'][0])) { |
|
| 327 | + $this->command['liste'] = explode(',', $this->command['liste'][0]); |
|
| 328 | + } else { |
|
| 329 | + $this->command['liste'] = $this->command['liste'][0]; |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + $this->tableau = $this->command['liste']; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * Retourne un tableau donne depuis un critere liste |
|
| 337 | + * Critere {enum Xmin, Xmax} |
|
| 338 | + * |
|
| 339 | + **/ |
|
| 340 | + protected function select_enum() { |
|
| 341 | + # s'il n'y a qu'une valeur dans la liste, sans doute une #BALISE |
|
| 342 | + if (!isset($this->command['enum'][1])) { |
|
| 343 | + if (!is_array($this->command['enum'][0])) { |
|
| 344 | + $this->command['enum'] = explode(',', $this->command['enum'][0]); |
|
| 345 | + } else { |
|
| 346 | + $this->command['enum'] = $this->command['enum'][0]; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + if ((is_countable($this->command['enum']) ? count($this->command['enum']) : 0) >= 3) { |
|
| 350 | + $enum = range( |
|
| 351 | + array_shift($this->command['enum']), |
|
| 352 | + array_shift($this->command['enum']), |
|
| 353 | + array_shift($this->command['enum']) |
|
| 354 | + ); |
|
| 355 | + } else { |
|
| 356 | + $enum = range(array_shift($this->command['enum']), array_shift($this->command['enum'])); |
|
| 357 | + } |
|
| 358 | + $this->tableau = $enum; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * extraire le chemin "query.results" du tableau de donnees |
|
| 364 | + * {datapath query.results} |
|
| 365 | + * |
|
| 366 | + **/ |
|
| 367 | + protected function select_datapath() { |
|
| 368 | + $base = reset($this->command['datapath']); |
|
| 369 | + if (strlen($base = ltrim(trim($base), '/'))) { |
|
| 370 | + $this->tableau = table_valeur($this->tableau, $base); |
|
| 371 | + if (!is_array($this->tableau)) { |
|
| 372 | + $this->tableau = []; |
|
| 373 | + $this->err = true; |
|
| 374 | + spip_log("datapath '$base' absent"); |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * Ordonner les resultats |
|
| 381 | + * {par x} |
|
| 382 | + * |
|
| 383 | + **/ |
|
| 384 | + protected function select_orderby() { |
|
| 385 | + $sortfunc = ''; |
|
| 386 | + $aleas = 0; |
|
| 387 | + foreach ($this->command['orderby'] as $tri) { |
|
| 388 | + // virer le / initial pour les criteres de la forme {par /xx} |
|
| 389 | + if (preg_match(',^\.?([/\w:_-]+)( DESC)?$,iS', ltrim($tri, '/'), $r)) { |
|
| 390 | + $r = array_pad($r, 3, null); |
|
| 391 | + |
|
| 392 | + // tri par cle |
|
| 393 | + if ($r[1] == 'cle') { |
|
| 394 | + if (isset($r[2]) and $r[2]) { |
|
| 395 | + krsort($this->tableau); |
|
| 396 | + } else { |
|
| 397 | + ksort($this->tableau); |
|
| 398 | + } |
|
| 399 | + } # {par hasard} |
|
| 400 | + else { |
|
| 401 | + if ($r[1] == 'hasard') { |
|
| 402 | + $k = array_keys($this->tableau); |
|
| 403 | + shuffle($k); |
|
| 404 | + $v = []; |
|
| 405 | + foreach ($k as $cle) { |
|
| 406 | + $v[$cle] = $this->tableau[$cle]; |
|
| 407 | + } |
|
| 408 | + $this->tableau = $v; |
|
| 409 | + } else { |
|
| 410 | + # {par valeur} |
|
| 411 | + if ($r[1] == 'valeur') { |
|
| 412 | + $tv = '%s'; |
|
| 413 | + } # {par valeur/xx/yy} ?? |
|
| 414 | + else { |
|
| 415 | + $tv = 'table_valeur(%s, ' . var_export($r[1], true) . ')'; |
|
| 416 | + } |
|
| 417 | + $sortfunc .= ' |
|
| 418 | 418 | $a = ' . sprintf($tv, '$aa') . '; |
| 419 | 419 | $b = ' . sprintf($tv, '$bb') . '; |
| 420 | 420 | if ($a <> $b) |
| 421 | 421 | return ($a ' . (!empty($r[2]) ? '>' : '<') . ' $b) ? -1 : 1;'; |
| 422 | - } |
|
| 423 | - } |
|
| 424 | - } |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - if ($sortfunc) { |
|
| 428 | - $sortfunc .= "\n return 0;"; |
|
| 429 | - uasort($this->tableau, fn($aa, $bb) => eval($sortfunc)); |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * Grouper les resultats |
|
| 436 | - * {fusion /x/y/z} |
|
| 437 | - * |
|
| 438 | - **/ |
|
| 439 | - protected function select_groupby() { |
|
| 440 | - // virer le / initial pour les criteres de la forme {fusion /xx} |
|
| 441 | - if (strlen($fusion = ltrim($this->command['groupby'][0], '/'))) { |
|
| 442 | - $vu = []; |
|
| 443 | - foreach ($this->tableau as $k => $v) { |
|
| 444 | - $val = table_valeur($v, $fusion); |
|
| 445 | - if (isset($vu[$val])) { |
|
| 446 | - unset($this->tableau[$k]); |
|
| 447 | - } else { |
|
| 448 | - $vu[$val] = true; |
|
| 449 | - } |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - |
|
| 455 | - /** |
|
| 456 | - * L'iterateur est-il encore valide ? |
|
| 457 | - * |
|
| 458 | - * @return bool |
|
| 459 | - */ |
|
| 460 | - public function valid(): bool { |
|
| 461 | - return !is_null($this->cle); |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - /** |
|
| 465 | - * Retourner la valeur |
|
| 466 | - * |
|
| 467 | - * @return mixed |
|
| 468 | - */ |
|
| 469 | - #[\ReturnTypeWillChange] |
|
| 470 | - public function current() { |
|
| 471 | - return $this->valeur; |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * Retourner la cle |
|
| 476 | - * |
|
| 477 | - * @return mixed |
|
| 478 | - */ |
|
| 479 | - #[\ReturnTypeWillChange] |
|
| 480 | - public function key() { |
|
| 481 | - return $this->cle; |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * Passer a la valeur suivante |
|
| 486 | - * |
|
| 487 | - * @return void |
|
| 488 | - */ |
|
| 489 | - public function next(): void { |
|
| 490 | - if ($this->valid()) { |
|
| 491 | - $this->cle = key($this->tableau); |
|
| 492 | - $this->valeur = current($this->tableau); |
|
| 493 | - next($this->tableau); |
|
| 494 | - } |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * Compter le nombre total de resultats |
|
| 499 | - * |
|
| 500 | - * @return int |
|
| 501 | - */ |
|
| 502 | - public function count() { |
|
| 503 | - if (is_null($this->total)) { |
|
| 504 | - $this->total = count($this->tableau); |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - return $this->total; |
|
| 508 | - } |
|
| 422 | + } |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + if ($sortfunc) { |
|
| 428 | + $sortfunc .= "\n return 0;"; |
|
| 429 | + uasort($this->tableau, fn($aa, $bb) => eval($sortfunc)); |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * Grouper les resultats |
|
| 436 | + * {fusion /x/y/z} |
|
| 437 | + * |
|
| 438 | + **/ |
|
| 439 | + protected function select_groupby() { |
|
| 440 | + // virer le / initial pour les criteres de la forme {fusion /xx} |
|
| 441 | + if (strlen($fusion = ltrim($this->command['groupby'][0], '/'))) { |
|
| 442 | + $vu = []; |
|
| 443 | + foreach ($this->tableau as $k => $v) { |
|
| 444 | + $val = table_valeur($v, $fusion); |
|
| 445 | + if (isset($vu[$val])) { |
|
| 446 | + unset($this->tableau[$k]); |
|
| 447 | + } else { |
|
| 448 | + $vu[$val] = true; |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + |
|
| 455 | + /** |
|
| 456 | + * L'iterateur est-il encore valide ? |
|
| 457 | + * |
|
| 458 | + * @return bool |
|
| 459 | + */ |
|
| 460 | + public function valid(): bool { |
|
| 461 | + return !is_null($this->cle); |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | + * Retourner la valeur |
|
| 466 | + * |
|
| 467 | + * @return mixed |
|
| 468 | + */ |
|
| 469 | + #[\ReturnTypeWillChange] |
|
| 470 | + public function current() { |
|
| 471 | + return $this->valeur; |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * Retourner la cle |
|
| 476 | + * |
|
| 477 | + * @return mixed |
|
| 478 | + */ |
|
| 479 | + #[\ReturnTypeWillChange] |
|
| 480 | + public function key() { |
|
| 481 | + return $this->cle; |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * Passer a la valeur suivante |
|
| 486 | + * |
|
| 487 | + * @return void |
|
| 488 | + */ |
|
| 489 | + public function next(): void { |
|
| 490 | + if ($this->valid()) { |
|
| 491 | + $this->cle = key($this->tableau); |
|
| 492 | + $this->valeur = current($this->tableau); |
|
| 493 | + next($this->tableau); |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * Compter le nombre total de resultats |
|
| 499 | + * |
|
| 500 | + * @return int |
|
| 501 | + */ |
|
| 502 | + public function count() { |
|
| 503 | + if (is_null($this->total)) { |
|
| 504 | + $this->total = count($this->tableau); |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + return $this->total; |
|
| 508 | + } |
|
| 509 | 509 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | -require_once _ROOT_RESTREINT . 'base/objets.php'; |
|
| 20 | +require_once _ROOT_RESTREINT.'base/objets.php'; |
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | // serveur externe et nom de serveur bien ecrit ? |
| 61 | 61 | if (defined('_DIR_CONNECT') |
| 62 | 62 | and preg_match('/^[\w\.]*$/', $serveur)) { |
| 63 | - $f = _DIR_CONNECT . $serveur . '.php'; |
|
| 63 | + $f = _DIR_CONNECT.$serveur.'.php'; |
|
| 64 | 64 | if (!is_readable($f) and !$install) { |
| 65 | 65 | // chercher une declaration de serveur dans le path |
| 66 | 66 | // qui peut servir à des plugins à declarer des connexions à une base sqlite |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | // chargement de la version du jeu de fonctions |
| 111 | 111 | // si pas dans le fichier par defaut |
| 112 | 112 | $type = $GLOBALS['db_ok']['type']; |
| 113 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 113 | + $jeu = 'spip_'.$type.'_functions_'.$version; |
|
| 114 | 114 | if (!isset($GLOBALS[$jeu])) { |
| 115 | - if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 115 | + if (!find_in_path($type.'_'.$version.'.php', 'req/', true)) { |
|
| 116 | 116 | spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
| 117 | 117 | |
| 118 | 118 | // ne plus reessayer |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | $connexion = spip_connect($serveur); |
| 175 | 175 | $e = sql_errno($serveur); |
| 176 | 176 | $t = ($connexion['type'] ?? 'sql'); |
| 177 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 178 | - $f = $t . $serveur; |
|
| 179 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 177 | + $m = "Erreur $e de $t: ".sql_error($serveur)."\nin ".sql_error_backtrace()."\n".trim($connexion['last']); |
|
| 178 | + $f = $t.$serveur; |
|
| 179 | + spip_log($m, $f.'.'._LOG_ERREUR); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | // si en cours d'installation ou si db=@test@ on ne pose rien |
| 263 | 263 | // car c'est un test de connexion |
| 264 | 264 | if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
| 265 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 265 | + $f = _DIR_TMP.$type.'.'.substr(md5($host.$port.$db), 0, 8).'.out'; |
|
| 266 | 266 | } elseif ($db == '@test@') { |
| 267 | 267 | $db = ''; |
| 268 | 268 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | // En cas d'indisponibilite du serveur, eviter de le bombarder |
| 302 | 302 | if ($f) { |
| 303 | 303 | @touch($f); |
| 304 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 304 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type.'.'._LOG_HS); |
|
| 305 | 305 | } |
| 306 | 306 | return null; |
| 307 | 307 | } |
@@ -398,11 +398,11 @@ discard block |
||
| 398 | 398 | } elseif (is_array($a)) { |
| 399 | 399 | return join(',', array_map('_q', $a)); |
| 400 | 400 | } elseif (is_scalar($a)) { |
| 401 | - return ("'" . addslashes($a) . "'"); |
|
| 401 | + return ("'".addslashes($a)."'"); |
|
| 402 | 402 | } elseif ($a === null) { |
| 403 | 403 | return "''"; |
| 404 | 404 | } |
| 405 | - throw new \RuntimeException('Can’t use _q with ' . gettype($a)); |
|
| 405 | + throw new \RuntimeException('Can’t use _q with '.gettype($a)); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /** |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | $next = reset($textes); |
| 454 | 454 | if ( |
| 455 | 455 | strpos($next, "'") === 0 |
| 456 | - and strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
|
| 456 | + and strpos($query_echappees, $part.$next, $currentpos) === $nextpos |
|
| 457 | 457 | ) { |
| 458 | 458 | $part .= array_shift($textes); |
| 459 | 459 | } |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | $parts[$k] = [ |
| 466 | 466 | 'texte' => $part, |
| 467 | 467 | 'position' => $nextpos, |
| 468 | - 'placeholder' => '%' . $k . '$s', |
|
| 468 | + 'placeholder' => '%'.$k.'$s', |
|
| 469 | 469 | ]; |
| 470 | 470 | $currentpos = $nextpos + strlen($part); |
| 471 | 471 | } |
@@ -68,13 +68,11 @@ discard block |
||
| 68 | 68 | $f = find_in_path("$serveur.php", 'connect/'); |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - } |
|
| 72 | - else { |
|
| 71 | + } else { |
|
| 73 | 72 | if (defined('_FILE_CONNECT') and _FILE_CONNECT) { |
| 74 | 73 | // init du serveur principal |
| 75 | 74 | $f = _FILE_CONNECT; |
| 76 | - } |
|
| 77 | - elseif ($install and defined('_FILE_CONNECT_TMP')) { |
|
| 75 | + } elseif ($install and defined('_FILE_CONNECT_TMP')) { |
|
| 78 | 76 | // installation en cours |
| 79 | 77 | $f = _FILE_CONNECT_TMP; |
| 80 | 78 | } |
@@ -87,8 +85,7 @@ discard block |
||
| 87 | 85 | if (!isset($GLOBALS['db_ok'])) { |
| 88 | 86 | spip_log("spip_connect: fichier de connexion '$f' OK mais echec connexion au serveur", _LOG_HS); |
| 89 | 87 | } |
| 90 | - } |
|
| 91 | - else { |
|
| 88 | + } else { |
|
| 92 | 89 | spip_log("spip_connect: fichier de connexion '$f' non trouve, pas de connexion serveur", _LOG_HS); |
| 93 | 90 | } |
| 94 | 91 | if (!isset($GLOBALS['db_ok'])) { |
@@ -456,8 +453,7 @@ discard block |
||
| 456 | 453 | and strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
| 457 | 454 | ) { |
| 458 | 455 | $part .= array_shift($textes); |
| 459 | - } |
|
| 460 | - else { |
|
| 456 | + } else { |
|
| 461 | 457 | break; |
| 462 | 458 | } |
| 463 | 459 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\SQL |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | require_once _ROOT_RESTREINT . 'base/objets.php'; |
| 21 | 21 | |
@@ -41,128 +41,128 @@ discard block |
||
| 41 | 41 | **/ |
| 42 | 42 | function spip_connect($serveur = '', $version = '') { |
| 43 | 43 | |
| 44 | - $serveur = !is_string($serveur) ? '' : strtolower($serveur); |
|
| 45 | - $index = $serveur ?: 0; |
|
| 46 | - if (!$version) { |
|
| 47 | - $version = $GLOBALS['spip_sql_version']; |
|
| 48 | - } |
|
| 49 | - if (isset($GLOBALS['connexions'][$index][$version])) { |
|
| 50 | - return $GLOBALS['connexions'][$index]; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - include_spip('base/abstract_sql'); |
|
| 54 | - $install = (_request('exec') == 'install'); |
|
| 55 | - |
|
| 56 | - // Premiere connexion ? |
|
| 57 | - if (!($old = isset($GLOBALS['connexions'][$index]))) { |
|
| 58 | - $f = ''; |
|
| 59 | - if ($serveur) { |
|
| 60 | - // serveur externe et nom de serveur bien ecrit ? |
|
| 61 | - if (defined('_DIR_CONNECT') |
|
| 62 | - and preg_match('/^[\w\.]*$/', $serveur)) { |
|
| 63 | - $f = _DIR_CONNECT . $serveur . '.php'; |
|
| 64 | - if (!is_readable($f) and !$install) { |
|
| 65 | - // chercher une declaration de serveur dans le path |
|
| 66 | - // qui peut servir à des plugins à declarer des connexions à une base sqlite |
|
| 67 | - // Ex: sert aux boucles POUR et au plugin-dist dump pour se connecter sur le sqlite du dump |
|
| 68 | - $f = find_in_path("$serveur.php", 'connect/'); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - else { |
|
| 73 | - if (defined('_FILE_CONNECT') and _FILE_CONNECT) { |
|
| 74 | - // init du serveur principal |
|
| 75 | - $f = _FILE_CONNECT; |
|
| 76 | - } |
|
| 77 | - elseif ($install and defined('_FILE_CONNECT_TMP')) { |
|
| 78 | - // installation en cours |
|
| 79 | - $f = _FILE_CONNECT_TMP; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - unset($GLOBALS['db_ok']); |
|
| 84 | - unset($GLOBALS['spip_connect_version']); |
|
| 85 | - if ($f and is_readable($f)) { |
|
| 86 | - include($f); |
|
| 87 | - if (!isset($GLOBALS['db_ok'])) { |
|
| 88 | - spip_log("spip_connect: fichier de connexion '$f' OK mais echec connexion au serveur", _LOG_HS); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - else { |
|
| 92 | - spip_log("spip_connect: fichier de connexion '$f' non trouve, pas de connexion serveur", _LOG_HS); |
|
| 93 | - } |
|
| 94 | - if (!isset($GLOBALS['db_ok'])) { |
|
| 95 | - // fera mieux la prochaine fois |
|
| 96 | - if ($install) { |
|
| 97 | - return false; |
|
| 98 | - } |
|
| 99 | - // ne plus reessayer si ce n'est pas l'install |
|
| 100 | - return $GLOBALS['connexions'][$index] = false; |
|
| 101 | - } |
|
| 102 | - $GLOBALS['connexions'][$index] = $GLOBALS['db_ok']; |
|
| 103 | - } |
|
| 104 | - // si la connexion a deja ete tentee mais a echoue, le dire! |
|
| 105 | - if (!$GLOBALS['connexions'][$index]) { |
|
| 106 | - return false; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // la connexion a reussi ou etait deja faite. |
|
| 110 | - // chargement de la version du jeu de fonctions |
|
| 111 | - // si pas dans le fichier par defaut |
|
| 112 | - $type = $GLOBALS['db_ok']['type']; |
|
| 113 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 114 | - if (!isset($GLOBALS[$jeu])) { |
|
| 115 | - if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 116 | - spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
|
| 117 | - |
|
| 118 | - // ne plus reessayer |
|
| 119 | - return $GLOBALS['connexions'][$index][$version] = []; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - $GLOBALS['connexions'][$index][$version] = $GLOBALS[$jeu]; |
|
| 123 | - if ($old) { |
|
| 124 | - return $GLOBALS['connexions'][$index]; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $GLOBALS['connexions'][$index]['spip_connect_version'] = $GLOBALS['spip_connect_version'] ?? 0; |
|
| 128 | - |
|
| 129 | - // initialisation de l'alphabet utilise dans les connexions SQL |
|
| 130 | - // si l'installation l'a determine. |
|
| 131 | - // Celui du serveur principal l'impose aux serveurs secondaires |
|
| 132 | - // s'ils le connaissent |
|
| 133 | - |
|
| 134 | - if (!$serveur) { |
|
| 135 | - $charset = spip_connect_main($GLOBALS[$jeu], $GLOBALS['db_ok']['charset']); |
|
| 136 | - if (!$charset) { |
|
| 137 | - unset($GLOBALS['connexions'][$index]); |
|
| 138 | - spip_log('spip_connect: absence de charset', _LOG_AVERTISSEMENT); |
|
| 139 | - |
|
| 140 | - return false; |
|
| 141 | - } |
|
| 142 | - } else { |
|
| 143 | - if ($GLOBALS['db_ok']['charset']) { |
|
| 144 | - $charset = $GLOBALS['db_ok']['charset']; |
|
| 145 | - } |
|
| 146 | - // spip_meta n'existe pas toujours dans la base |
|
| 147 | - // C'est le cas d'un dump sqlite par exemple |
|
| 148 | - elseif ( |
|
| 149 | - $GLOBALS['connexions'][$index]['spip_connect_version'] |
|
| 150 | - and sql_showtable('spip_meta', true, $serveur) |
|
| 151 | - and $r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'", '', '', '', '', $serveur) |
|
| 152 | - ) { |
|
| 153 | - $charset = $r; |
|
| 154 | - } else { |
|
| 155 | - $charset = -1; |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - if ($charset != -1) { |
|
| 159 | - $f = $GLOBALS[$jeu]['set_charset']; |
|
| 160 | - if (function_exists($f)) { |
|
| 161 | - $f($charset, $serveur); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return $GLOBALS['connexions'][$index]; |
|
| 44 | + $serveur = !is_string($serveur) ? '' : strtolower($serveur); |
|
| 45 | + $index = $serveur ?: 0; |
|
| 46 | + if (!$version) { |
|
| 47 | + $version = $GLOBALS['spip_sql_version']; |
|
| 48 | + } |
|
| 49 | + if (isset($GLOBALS['connexions'][$index][$version])) { |
|
| 50 | + return $GLOBALS['connexions'][$index]; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + include_spip('base/abstract_sql'); |
|
| 54 | + $install = (_request('exec') == 'install'); |
|
| 55 | + |
|
| 56 | + // Premiere connexion ? |
|
| 57 | + if (!($old = isset($GLOBALS['connexions'][$index]))) { |
|
| 58 | + $f = ''; |
|
| 59 | + if ($serveur) { |
|
| 60 | + // serveur externe et nom de serveur bien ecrit ? |
|
| 61 | + if (defined('_DIR_CONNECT') |
|
| 62 | + and preg_match('/^[\w\.]*$/', $serveur)) { |
|
| 63 | + $f = _DIR_CONNECT . $serveur . '.php'; |
|
| 64 | + if (!is_readable($f) and !$install) { |
|
| 65 | + // chercher une declaration de serveur dans le path |
|
| 66 | + // qui peut servir à des plugins à declarer des connexions à une base sqlite |
|
| 67 | + // Ex: sert aux boucles POUR et au plugin-dist dump pour se connecter sur le sqlite du dump |
|
| 68 | + $f = find_in_path("$serveur.php", 'connect/'); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + else { |
|
| 73 | + if (defined('_FILE_CONNECT') and _FILE_CONNECT) { |
|
| 74 | + // init du serveur principal |
|
| 75 | + $f = _FILE_CONNECT; |
|
| 76 | + } |
|
| 77 | + elseif ($install and defined('_FILE_CONNECT_TMP')) { |
|
| 78 | + // installation en cours |
|
| 79 | + $f = _FILE_CONNECT_TMP; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + unset($GLOBALS['db_ok']); |
|
| 84 | + unset($GLOBALS['spip_connect_version']); |
|
| 85 | + if ($f and is_readable($f)) { |
|
| 86 | + include($f); |
|
| 87 | + if (!isset($GLOBALS['db_ok'])) { |
|
| 88 | + spip_log("spip_connect: fichier de connexion '$f' OK mais echec connexion au serveur", _LOG_HS); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + else { |
|
| 92 | + spip_log("spip_connect: fichier de connexion '$f' non trouve, pas de connexion serveur", _LOG_HS); |
|
| 93 | + } |
|
| 94 | + if (!isset($GLOBALS['db_ok'])) { |
|
| 95 | + // fera mieux la prochaine fois |
|
| 96 | + if ($install) { |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 99 | + // ne plus reessayer si ce n'est pas l'install |
|
| 100 | + return $GLOBALS['connexions'][$index] = false; |
|
| 101 | + } |
|
| 102 | + $GLOBALS['connexions'][$index] = $GLOBALS['db_ok']; |
|
| 103 | + } |
|
| 104 | + // si la connexion a deja ete tentee mais a echoue, le dire! |
|
| 105 | + if (!$GLOBALS['connexions'][$index]) { |
|
| 106 | + return false; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // la connexion a reussi ou etait deja faite. |
|
| 110 | + // chargement de la version du jeu de fonctions |
|
| 111 | + // si pas dans le fichier par defaut |
|
| 112 | + $type = $GLOBALS['db_ok']['type']; |
|
| 113 | + $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 114 | + if (!isset($GLOBALS[$jeu])) { |
|
| 115 | + if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 116 | + spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
|
| 117 | + |
|
| 118 | + // ne plus reessayer |
|
| 119 | + return $GLOBALS['connexions'][$index][$version] = []; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + $GLOBALS['connexions'][$index][$version] = $GLOBALS[$jeu]; |
|
| 123 | + if ($old) { |
|
| 124 | + return $GLOBALS['connexions'][$index]; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $GLOBALS['connexions'][$index]['spip_connect_version'] = $GLOBALS['spip_connect_version'] ?? 0; |
|
| 128 | + |
|
| 129 | + // initialisation de l'alphabet utilise dans les connexions SQL |
|
| 130 | + // si l'installation l'a determine. |
|
| 131 | + // Celui du serveur principal l'impose aux serveurs secondaires |
|
| 132 | + // s'ils le connaissent |
|
| 133 | + |
|
| 134 | + if (!$serveur) { |
|
| 135 | + $charset = spip_connect_main($GLOBALS[$jeu], $GLOBALS['db_ok']['charset']); |
|
| 136 | + if (!$charset) { |
|
| 137 | + unset($GLOBALS['connexions'][$index]); |
|
| 138 | + spip_log('spip_connect: absence de charset', _LOG_AVERTISSEMENT); |
|
| 139 | + |
|
| 140 | + return false; |
|
| 141 | + } |
|
| 142 | + } else { |
|
| 143 | + if ($GLOBALS['db_ok']['charset']) { |
|
| 144 | + $charset = $GLOBALS['db_ok']['charset']; |
|
| 145 | + } |
|
| 146 | + // spip_meta n'existe pas toujours dans la base |
|
| 147 | + // C'est le cas d'un dump sqlite par exemple |
|
| 148 | + elseif ( |
|
| 149 | + $GLOBALS['connexions'][$index]['spip_connect_version'] |
|
| 150 | + and sql_showtable('spip_meta', true, $serveur) |
|
| 151 | + and $r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'", '', '', '', '', $serveur) |
|
| 152 | + ) { |
|
| 153 | + $charset = $r; |
|
| 154 | + } else { |
|
| 155 | + $charset = -1; |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + if ($charset != -1) { |
|
| 159 | + $f = $GLOBALS[$jeu]['set_charset']; |
|
| 160 | + if (function_exists($f)) { |
|
| 161 | + $f($charset, $serveur); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return $GLOBALS['connexions'][$index]; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -171,12 +171,12 @@ discard block |
||
| 171 | 171 | * @param string $serveur Nom du connecteur de bdd utilisé |
| 172 | 172 | **/ |
| 173 | 173 | function spip_sql_erreur($serveur = '') { |
| 174 | - $connexion = spip_connect($serveur); |
|
| 175 | - $e = sql_errno($serveur); |
|
| 176 | - $t = ($connexion['type'] ?? 'sql'); |
|
| 177 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 178 | - $f = $t . $serveur; |
|
| 179 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 174 | + $connexion = spip_connect($serveur); |
|
| 175 | + $e = sql_errno($serveur); |
|
| 176 | + $t = ($connexion['type'] ?? 'sql'); |
|
| 177 | + $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 178 | + $f = $t . $serveur; |
|
| 179 | + spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -198,23 +198,23 @@ discard block |
||
| 198 | 198 | * - array : description de la connexion, si l'instruction sql est indisponible pour cette connexion |
| 199 | 199 | **/ |
| 200 | 200 | function spip_connect_sql($version, $ins = '', $serveur = '', $continue = false) { |
| 201 | - $desc = spip_connect($serveur, $version); |
|
| 202 | - if ( |
|
| 203 | - $desc |
|
| 204 | - and $f = ($desc[$version][$ins] ?? '') |
|
| 205 | - and function_exists($f) |
|
| 206 | - ) { |
|
| 207 | - return $f; |
|
| 208 | - } |
|
| 209 | - if ($continue) { |
|
| 210 | - return $desc; |
|
| 211 | - } |
|
| 212 | - if ($ins) { |
|
| 213 | - spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR); |
|
| 214 | - } |
|
| 215 | - include_spip('inc/minipres'); |
|
| 216 | - echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 217 | - exit; |
|
| 201 | + $desc = spip_connect($serveur, $version); |
|
| 202 | + if ( |
|
| 203 | + $desc |
|
| 204 | + and $f = ($desc[$version][$ins] ?? '') |
|
| 205 | + and function_exists($f) |
|
| 206 | + ) { |
|
| 207 | + return $f; |
|
| 208 | + } |
|
| 209 | + if ($continue) { |
|
| 210 | + return $desc; |
|
| 211 | + } |
|
| 212 | + if ($ins) { |
|
| 213 | + spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR); |
|
| 214 | + } |
|
| 215 | + include_spip('inc/minipres'); |
|
| 216 | + echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 217 | + exit; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -240,70 +240,70 @@ discard block |
||
| 240 | 240 | * @return array|null Description de la connexion |
| 241 | 241 | */ |
| 242 | 242 | function spip_connect_db( |
| 243 | - $host, |
|
| 244 | - $port, |
|
| 245 | - $login, |
|
| 246 | - #[\SensitiveParameter] $pass, |
|
| 247 | - $db = '', |
|
| 248 | - $type = 'mysql', |
|
| 249 | - $prefixe = '', |
|
| 250 | - $auth = '', |
|
| 251 | - $charset = '' |
|
| 243 | + $host, |
|
| 244 | + $port, |
|
| 245 | + $login, |
|
| 246 | + #[\SensitiveParameter] $pass, |
|
| 247 | + $db = '', |
|
| 248 | + $type = 'mysql', |
|
| 249 | + $prefixe = '', |
|
| 250 | + $auth = '', |
|
| 251 | + $charset = '' |
|
| 252 | 252 | ) { |
| 253 | - // temps avant nouvelle tentative de connexion |
|
| 254 | - // suite a une connection echouee |
|
| 255 | - if (!defined('_CONNECT_RETRY_DELAY')) { |
|
| 256 | - define('_CONNECT_RETRY_DELAY', 30); |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - $f = ''; |
|
| 260 | - // un fichier de identifiant par combinaison (type,host,port,db) |
|
| 261 | - // pour ne pas declarer tout indisponible d'un coup |
|
| 262 | - // si en cours d'installation ou si db=@test@ on ne pose rien |
|
| 263 | - // car c'est un test de connexion |
|
| 264 | - if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
|
| 265 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 266 | - } elseif ($db == '@test@') { |
|
| 267 | - $db = ''; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - if ( |
|
| 271 | - $f |
|
| 272 | - and @file_exists($f) |
|
| 273 | - and (time() - @filemtime($f) < _CONNECT_RETRY_DELAY) |
|
| 274 | - ) { |
|
| 275 | - spip_log("Echec : $f recent. Pas de tentative de connexion", _LOG_HS); |
|
| 276 | - |
|
| 277 | - return null; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - if (!$prefixe) { |
|
| 281 | - $prefixe = $GLOBALS['table_prefix'] ?? $db; |
|
| 282 | - } |
|
| 283 | - $h = charger_fonction($type, 'req', true); |
|
| 284 | - if (!$h) { |
|
| 285 | - spip_log("les requetes $type ne sont pas fournies", _LOG_HS); |
|
| 286 | - |
|
| 287 | - return null; |
|
| 288 | - } |
|
| 289 | - if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) { |
|
| 290 | - if (!is_array($auth)) { |
|
| 291 | - // compatibilite version 0.7 initiale |
|
| 292 | - $g['ldap'] = $auth; |
|
| 293 | - $auth = ['ldap' => $auth]; |
|
| 294 | - } |
|
| 295 | - $g['authentification'] = $auth; |
|
| 296 | - $g['type'] = $type; |
|
| 297 | - $g['charset'] = $charset; |
|
| 298 | - |
|
| 299 | - return $GLOBALS['db_ok'] = $g; |
|
| 300 | - } |
|
| 301 | - // En cas d'indisponibilite du serveur, eviter de le bombarder |
|
| 302 | - if ($f) { |
|
| 303 | - @touch($f); |
|
| 304 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 305 | - } |
|
| 306 | - return null; |
|
| 253 | + // temps avant nouvelle tentative de connexion |
|
| 254 | + // suite a une connection echouee |
|
| 255 | + if (!defined('_CONNECT_RETRY_DELAY')) { |
|
| 256 | + define('_CONNECT_RETRY_DELAY', 30); |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + $f = ''; |
|
| 260 | + // un fichier de identifiant par combinaison (type,host,port,db) |
|
| 261 | + // pour ne pas declarer tout indisponible d'un coup |
|
| 262 | + // si en cours d'installation ou si db=@test@ on ne pose rien |
|
| 263 | + // car c'est un test de connexion |
|
| 264 | + if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
|
| 265 | + $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 266 | + } elseif ($db == '@test@') { |
|
| 267 | + $db = ''; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + if ( |
|
| 271 | + $f |
|
| 272 | + and @file_exists($f) |
|
| 273 | + and (time() - @filemtime($f) < _CONNECT_RETRY_DELAY) |
|
| 274 | + ) { |
|
| 275 | + spip_log("Echec : $f recent. Pas de tentative de connexion", _LOG_HS); |
|
| 276 | + |
|
| 277 | + return null; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + if (!$prefixe) { |
|
| 281 | + $prefixe = $GLOBALS['table_prefix'] ?? $db; |
|
| 282 | + } |
|
| 283 | + $h = charger_fonction($type, 'req', true); |
|
| 284 | + if (!$h) { |
|
| 285 | + spip_log("les requetes $type ne sont pas fournies", _LOG_HS); |
|
| 286 | + |
|
| 287 | + return null; |
|
| 288 | + } |
|
| 289 | + if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) { |
|
| 290 | + if (!is_array($auth)) { |
|
| 291 | + // compatibilite version 0.7 initiale |
|
| 292 | + $g['ldap'] = $auth; |
|
| 293 | + $auth = ['ldap' => $auth]; |
|
| 294 | + } |
|
| 295 | + $g['authentification'] = $auth; |
|
| 296 | + $g['type'] = $type; |
|
| 297 | + $g['charset'] = $charset; |
|
| 298 | + |
|
| 299 | + return $GLOBALS['db_ok'] = $g; |
|
| 300 | + } |
|
| 301 | + // En cas d'indisponibilite du serveur, eviter de le bombarder |
|
| 302 | + if ($f) { |
|
| 303 | + @touch($f); |
|
| 304 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 305 | + } |
|
| 306 | + return null; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | |
@@ -335,32 +335,32 @@ discard block |
||
| 335 | 335 | * - nom du charset sinon |
| 336 | 336 | **/ |
| 337 | 337 | function spip_connect_main($connexion, $charset_sql_connexion = '') { |
| 338 | - if ($GLOBALS['spip_connect_version'] < 0.1 and _DIR_RESTREINT) { |
|
| 339 | - include_spip('inc/headers'); |
|
| 340 | - redirige_url_ecrire('upgrade', 'reinstall=oui'); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - if (!($f = $connexion['select'])) { |
|
| 344 | - return false; |
|
| 345 | - } |
|
| 346 | - // si le charset est fourni, l'utiliser |
|
| 347 | - if ($charset_sql_connexion) { |
|
| 348 | - return $charset_sql_connexion; |
|
| 349 | - } |
|
| 350 | - // sinon on regarde la table spip_meta |
|
| 351 | - // en cas d'erreur select retourne la requette (is_string=true donc) |
|
| 352 | - if ( |
|
| 353 | - !$r = $f('valeur', 'spip_meta', "nom='charset_sql_connexion'") |
|
| 354 | - or is_string($r) |
|
| 355 | - ) { |
|
| 356 | - return false; |
|
| 357 | - } |
|
| 358 | - if (!($f = $connexion['fetch'])) { |
|
| 359 | - return false; |
|
| 360 | - } |
|
| 361 | - $r = $f($r); |
|
| 362 | - |
|
| 363 | - return (isset($r['valeur']) && $r['valeur']) ? $r['valeur'] : -1; |
|
| 338 | + if ($GLOBALS['spip_connect_version'] < 0.1 and _DIR_RESTREINT) { |
|
| 339 | + include_spip('inc/headers'); |
|
| 340 | + redirige_url_ecrire('upgrade', 'reinstall=oui'); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + if (!($f = $connexion['select'])) { |
|
| 344 | + return false; |
|
| 345 | + } |
|
| 346 | + // si le charset est fourni, l'utiliser |
|
| 347 | + if ($charset_sql_connexion) { |
|
| 348 | + return $charset_sql_connexion; |
|
| 349 | + } |
|
| 350 | + // sinon on regarde la table spip_meta |
|
| 351 | + // en cas d'erreur select retourne la requette (is_string=true donc) |
|
| 352 | + if ( |
|
| 353 | + !$r = $f('valeur', 'spip_meta', "nom='charset_sql_connexion'") |
|
| 354 | + or is_string($r) |
|
| 355 | + ) { |
|
| 356 | + return false; |
|
| 357 | + } |
|
| 358 | + if (!($f = $connexion['fetch'])) { |
|
| 359 | + return false; |
|
| 360 | + } |
|
| 361 | + $r = $f($r); |
|
| 362 | + |
|
| 363 | + return (isset($r['valeur']) && $r['valeur']) ? $r['valeur'] : -1; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /** |
@@ -376,8 +376,8 @@ discard block |
||
| 376 | 376 | * @return array |
| 377 | 377 | */ |
| 378 | 378 | function spip_connect_ldap($serveur = '') { |
| 379 | - include_spip('auth/ldap'); |
|
| 380 | - return auth_ldap_connect($serveur); |
|
| 379 | + include_spip('auth/ldap'); |
|
| 380 | + return auth_ldap_connect($serveur); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -393,16 +393,16 @@ discard block |
||
| 393 | 393 | * @return string Valeur échappée. |
| 394 | 394 | **/ |
| 395 | 395 | function _q($a): string { |
| 396 | - if (is_numeric($a)) { |
|
| 397 | - return strval($a); |
|
| 398 | - } elseif (is_array($a)) { |
|
| 399 | - return join(',', array_map('_q', $a)); |
|
| 400 | - } elseif (is_scalar($a)) { |
|
| 401 | - return ("'" . addslashes($a) . "'"); |
|
| 402 | - } elseif ($a === null) { |
|
| 403 | - return "''"; |
|
| 404 | - } |
|
| 405 | - throw new \RuntimeException('Can’t use _q with ' . gettype($a)); |
|
| 396 | + if (is_numeric($a)) { |
|
| 397 | + return strval($a); |
|
| 398 | + } elseif (is_array($a)) { |
|
| 399 | + return join(',', array_map('_q', $a)); |
|
| 400 | + } elseif (is_scalar($a)) { |
|
| 401 | + return ("'" . addslashes($a) . "'"); |
|
| 402 | + } elseif ($a === null) { |
|
| 403 | + return "''"; |
|
| 404 | + } |
|
| 405 | + throw new \RuntimeException('Can’t use _q with ' . gettype($a)); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /** |
@@ -418,75 +418,75 @@ discard block |
||
| 418 | 418 | * @return array |
| 419 | 419 | */ |
| 420 | 420 | function query_echappe_textes($query, $uniqid = null) { |
| 421 | - static $codeEchappements = null; |
|
| 422 | - if (is_null($codeEchappements) or $uniqid) { |
|
| 423 | - if (is_null($uniqid)) { |
|
| 424 | - $uniqid = uniqid(); |
|
| 425 | - } |
|
| 426 | - $uniqid = substr(md5($uniqid), 0, 4); |
|
| 427 | - $codeEchappements = ['\\\\' => "\x1@#{$uniqid}#@\x1", "\\'" => "\x2@#{$uniqid}#@\x2", '\\"' => "\x3@#{$uniqid}#@\x3", '%' => "\x4@#{$uniqid}#@\x4"]; |
|
| 428 | - } |
|
| 429 | - if ($query === null) { |
|
| 430 | - return $codeEchappements; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - // si la query contient deja des codes d'echappement on va s'emmeler les pinceaux et donc on ne touche a rien |
|
| 434 | - // ce n'est pas un cas legitime |
|
| 435 | - foreach ($codeEchappements as $codeEchappement) { |
|
| 436 | - if (strpos($query, (string) $codeEchappement) !== false) { |
|
| 437 | - return [$query, []]; |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - $query_echappees = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query); |
|
| 442 | - if (preg_match_all("/('[^']*')|(\"[^\"]*\")/S", $query_echappees, $textes)) { |
|
| 443 | - $textes = reset($textes); |
|
| 444 | - |
|
| 445 | - $parts = []; |
|
| 446 | - $currentpos = 0; |
|
| 447 | - $k = 0; |
|
| 448 | - while (count($textes)) { |
|
| 449 | - $part = array_shift($textes); |
|
| 450 | - $nextpos = strpos($query_echappees, $part, $currentpos); |
|
| 451 | - // si besoin recoller ensemble les doubles '' de sqlite (echappement des ') |
|
| 452 | - while (count($textes) and substr($part, -1) === "'") { |
|
| 453 | - $next = reset($textes); |
|
| 454 | - if ( |
|
| 455 | - strpos($next, "'") === 0 |
|
| 456 | - and strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
|
| 457 | - ) { |
|
| 458 | - $part .= array_shift($textes); |
|
| 459 | - } |
|
| 460 | - else { |
|
| 461 | - break; |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - $k++; |
|
| 465 | - $parts[$k] = [ |
|
| 466 | - 'texte' => $part, |
|
| 467 | - 'position' => $nextpos, |
|
| 468 | - 'placeholder' => '%' . $k . '$s', |
|
| 469 | - ]; |
|
| 470 | - $currentpos = $nextpos + strlen($part); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - // et on replace les parts une par une en commencant par la fin |
|
| 474 | - while ($k > 0) { |
|
| 475 | - $query_echappees = substr_replace($query_echappees, $parts[$k]['placeholder'], $parts[$k]['position'], strlen($parts[$k]['texte'])); |
|
| 476 | - $k--; |
|
| 477 | - } |
|
| 478 | - $textes = array_column($parts, 'texte'); |
|
| 479 | - } else { |
|
| 480 | - $textes = []; |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - // si il reste des quotes simples ou doubles, c'est qu'on s'est emmelle les pinceaux |
|
| 484 | - // dans le doute on ne touche a rien |
|
| 485 | - if (strpbrk($query_echappees, "'\"") !== false) { |
|
| 486 | - return [$query, []]; |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - return [$query_echappees, $textes]; |
|
| 421 | + static $codeEchappements = null; |
|
| 422 | + if (is_null($codeEchappements) or $uniqid) { |
|
| 423 | + if (is_null($uniqid)) { |
|
| 424 | + $uniqid = uniqid(); |
|
| 425 | + } |
|
| 426 | + $uniqid = substr(md5($uniqid), 0, 4); |
|
| 427 | + $codeEchappements = ['\\\\' => "\x1@#{$uniqid}#@\x1", "\\'" => "\x2@#{$uniqid}#@\x2", '\\"' => "\x3@#{$uniqid}#@\x3", '%' => "\x4@#{$uniqid}#@\x4"]; |
|
| 428 | + } |
|
| 429 | + if ($query === null) { |
|
| 430 | + return $codeEchappements; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + // si la query contient deja des codes d'echappement on va s'emmeler les pinceaux et donc on ne touche a rien |
|
| 434 | + // ce n'est pas un cas legitime |
|
| 435 | + foreach ($codeEchappements as $codeEchappement) { |
|
| 436 | + if (strpos($query, (string) $codeEchappement) !== false) { |
|
| 437 | + return [$query, []]; |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + $query_echappees = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query); |
|
| 442 | + if (preg_match_all("/('[^']*')|(\"[^\"]*\")/S", $query_echappees, $textes)) { |
|
| 443 | + $textes = reset($textes); |
|
| 444 | + |
|
| 445 | + $parts = []; |
|
| 446 | + $currentpos = 0; |
|
| 447 | + $k = 0; |
|
| 448 | + while (count($textes)) { |
|
| 449 | + $part = array_shift($textes); |
|
| 450 | + $nextpos = strpos($query_echappees, $part, $currentpos); |
|
| 451 | + // si besoin recoller ensemble les doubles '' de sqlite (echappement des ') |
|
| 452 | + while (count($textes) and substr($part, -1) === "'") { |
|
| 453 | + $next = reset($textes); |
|
| 454 | + if ( |
|
| 455 | + strpos($next, "'") === 0 |
|
| 456 | + and strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
|
| 457 | + ) { |
|
| 458 | + $part .= array_shift($textes); |
|
| 459 | + } |
|
| 460 | + else { |
|
| 461 | + break; |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + $k++; |
|
| 465 | + $parts[$k] = [ |
|
| 466 | + 'texte' => $part, |
|
| 467 | + 'position' => $nextpos, |
|
| 468 | + 'placeholder' => '%' . $k . '$s', |
|
| 469 | + ]; |
|
| 470 | + $currentpos = $nextpos + strlen($part); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + // et on replace les parts une par une en commencant par la fin |
|
| 474 | + while ($k > 0) { |
|
| 475 | + $query_echappees = substr_replace($query_echappees, $parts[$k]['placeholder'], $parts[$k]['position'], strlen($parts[$k]['texte'])); |
|
| 476 | + $k--; |
|
| 477 | + } |
|
| 478 | + $textes = array_column($parts, 'texte'); |
|
| 479 | + } else { |
|
| 480 | + $textes = []; |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + // si il reste des quotes simples ou doubles, c'est qu'on s'est emmelle les pinceaux |
|
| 484 | + // dans le doute on ne touche a rien |
|
| 485 | + if (strpbrk($query_echappees, "'\"") !== false) { |
|
| 486 | + return [$query, []]; |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + return [$query_echappees, $textes]; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -500,16 +500,16 @@ discard block |
||
| 500 | 500 | * @return string |
| 501 | 501 | */ |
| 502 | 502 | function query_reinjecte_textes($query, $textes) { |
| 503 | - // recuperer les codes echappements |
|
| 504 | - $codeEchappements = query_echappe_textes(null); |
|
| 503 | + // recuperer les codes echappements |
|
| 504 | + $codeEchappements = query_echappe_textes(null); |
|
| 505 | 505 | |
| 506 | - if (!empty($textes)) { |
|
| 507 | - $query = sprintf($query, ...$textes); |
|
| 508 | - } |
|
| 506 | + if (!empty($textes)) { |
|
| 507 | + $query = sprintf($query, ...$textes); |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | - $query = str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query); |
|
| 510 | + $query = str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query); |
|
| 511 | 511 | |
| 512 | - return $query; |
|
| 512 | + return $query; |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | **/ |
| 529 | 529 | function spip_query($query, $serveur = '') { |
| 530 | 530 | |
| 531 | - $f = spip_connect_sql($GLOBALS['spip_sql_version'], 'query', $serveur, true); |
|
| 531 | + $f = spip_connect_sql($GLOBALS['spip_sql_version'], 'query', $serveur, true); |
|
| 532 | 532 | |
| 533 | - return function_exists($f) ? $f($query, $serveur) : false; |
|
| 533 | + return function_exists($f) ? $f($query, $serveur) : false; |
|
| 534 | 534 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | define('_PHP_MAX', '8.2.99'); |
| 39 | 39 | |
| 40 | 40 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 41 | - /** le nom du repertoire ecrire/ */ |
|
| 42 | - define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 41 | + /** le nom du repertoire ecrire/ */ |
|
| 42 | + define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** Chemin relatif pour aller dans ecrire |
| 46 | 46 | * vide si on est dans ecrire, 'ecrire/' sinon */ |
| 47 | 47 | define( |
| 48 | - '_DIR_RESTREINT', |
|
| 49 | - (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 48 | + '_DIR_RESTREINT', |
|
| 49 | + (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | 52 | /** Chemin relatif pour aller à la racine */ |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | // Icones |
| 63 | 63 | if (!defined('_NOM_IMG_PACK')) { |
| 64 | - /** Nom du dossier images */ |
|
| 65 | - define('_NOM_IMG_PACK', 'images/'); |
|
| 64 | + /** Nom du dossier images */ |
|
| 65 | + define('_NOM_IMG_PACK', 'images/'); |
|
| 66 | 66 | } |
| 67 | 67 | /** le chemin http (relatif) vers les images standard */ |
| 68 | 68 | define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
| 72 | 72 | |
| 73 | 73 | if (!defined('_JAVASCRIPT')) { |
| 74 | - /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 75 | - define('_JAVASCRIPT', 'javascript/'); |
|
| 74 | + /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 75 | + define('_JAVASCRIPT', 'javascript/'); |
|
| 76 | 76 | } // utilisable avec #CHEMIN et find_in_path |
| 77 | 77 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 78 | 78 | define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
@@ -82,47 +82,47 @@ discard block |
||
| 82 | 82 | # mais on peut les mettre ailleurs et changer completement les noms |
| 83 | 83 | |
| 84 | 84 | if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) { |
| 85 | - /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 86 | - define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 85 | + /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 86 | + define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 87 | 87 | } |
| 88 | 88 | if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) { |
| 89 | - /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 90 | - define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 89 | + /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 90 | + define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 91 | 91 | } |
| 92 | 92 | if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) { |
| 93 | - /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 94 | - define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 93 | + /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 94 | + define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 95 | 95 | } |
| 96 | 96 | if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) { |
| 97 | - /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 98 | - define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 97 | + /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 98 | + define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | /** Le nom du fichier de personnalisation */ |
| 103 | 103 | if (!defined('_NOM_CONFIG')) { |
| 104 | - define('_NOM_CONFIG', 'mes_options'); |
|
| 104 | + define('_NOM_CONFIG', 'mes_options'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Son emplacement absolu si on le trouve |
| 108 | 108 | if ( |
| 109 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 110 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 109 | + @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 110 | + or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 111 | 111 | ) { |
| 112 | - /** Emplacement absolu du fichier d'option */ |
|
| 113 | - define('_FILE_OPTIONS', $f); |
|
| 112 | + /** Emplacement absolu du fichier d'option */ |
|
| 113 | + define('_FILE_OPTIONS', $f); |
|
| 114 | 114 | } else { |
| 115 | - define('_FILE_OPTIONS', ''); |
|
| 115 | + define('_FILE_OPTIONS', ''); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | if (!defined('MODULES_IDIOMES')) { |
| 119 | - /** |
|
| 120 | - * Modules par défaut pour la traduction. |
|
| 121 | - * |
|
| 122 | - * Constante utilisée par le compilateur et le décompilateur |
|
| 123 | - * sa valeur etant traitée par inc_traduire_dist |
|
| 124 | - */ |
|
| 125 | - define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 119 | + /** |
|
| 120 | + * Modules par défaut pour la traduction. |
|
| 121 | + * |
|
| 122 | + * Constante utilisée par le compilateur et le décompilateur |
|
| 123 | + * sa valeur etant traitée par inc_traduire_dist |
|
| 124 | + */ |
|
| 125 | + define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // *** Fin des define *** // |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | // inclure l'ecran de securite |
| 132 | 132 | if ( |
| 133 | - !defined('_ECRAN_SECURITE') |
|
| 134 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 133 | + !defined('_ECRAN_SECURITE') |
|
| 134 | + and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 135 | 135 | ) { |
| 136 | - include $f; |
|
| 136 | + include $f; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | |
@@ -141,30 +141,30 @@ discard block |
||
| 141 | 141 | * Détecteur de robot d'indexation |
| 142 | 142 | */ |
| 143 | 143 | if (!defined('_IS_BOT')) { |
| 144 | - define( |
|
| 145 | - '_IS_BOT', |
|
| 146 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 147 | - and preg_match( |
|
| 148 | - // mots generiques |
|
| 149 | - ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 150 | - // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 151 | - . 'MSIE 6\.0|' |
|
| 152 | - // UA plus cibles |
|
| 153 | - . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 154 | - . ',i', |
|
| 155 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 156 | - ) |
|
| 157 | - ); |
|
| 144 | + define( |
|
| 145 | + '_IS_BOT', |
|
| 146 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 147 | + and preg_match( |
|
| 148 | + // mots generiques |
|
| 149 | + ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 150 | + // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 151 | + . 'MSIE 6\.0|' |
|
| 152 | + // UA plus cibles |
|
| 153 | + . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 154 | + . ',i', |
|
| 155 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 156 | + ) |
|
| 157 | + ); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (!defined('_IS_CLI')) { |
| 161 | - define( |
|
| 162 | - '_IS_CLI', |
|
| 163 | - !isset($_SERVER['HTTP_HOST']) |
|
| 164 | - and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 165 | - and !empty($_SERVER['argv']) |
|
| 166 | - and empty($_SERVER['REQUEST_METHOD']) |
|
| 167 | - ); |
|
| 161 | + define( |
|
| 162 | + '_IS_CLI', |
|
| 163 | + !isset($_SERVER['HTTP_HOST']) |
|
| 164 | + and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 165 | + and !empty($_SERVER['argv']) |
|
| 166 | + and empty($_SERVER['REQUEST_METHOD']) |
|
| 167 | + ); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // *** Parametrage par defaut de SPIP *** |
@@ -176,61 +176,61 @@ discard block |
||
| 176 | 176 | // Ne pas les rendre indefinies. |
| 177 | 177 | |
| 178 | 178 | global |
| 179 | - $nombre_de_logs, |
|
| 180 | - $taille_des_logs, |
|
| 181 | - $table_prefix, |
|
| 182 | - $cookie_prefix, |
|
| 183 | - $dossier_squelettes, |
|
| 184 | - $filtrer_javascript, |
|
| 185 | - $type_urls, |
|
| 186 | - $debut_date_publication, |
|
| 187 | - $ip, |
|
| 188 | - $mysql_rappel_connexion, |
|
| 189 | - $mysql_rappel_nom_base, |
|
| 190 | - $test_i18n, |
|
| 191 | - $ignore_auth_http, |
|
| 192 | - $ignore_remote_user, |
|
| 193 | - $derniere_modif_invalide, |
|
| 194 | - $home_server, |
|
| 195 | - $help_server, |
|
| 196 | - $url_glossaire_externe, |
|
| 197 | - $tex_server, |
|
| 198 | - $traiter_math, |
|
| 199 | - $xhtml, |
|
| 200 | - $xml_indent, |
|
| 201 | - $source_vignettes, |
|
| 202 | - $formats_logos, |
|
| 203 | - $controler_dates_rss, |
|
| 204 | - $spip_pipeline, |
|
| 205 | - $spip_matrice, |
|
| 206 | - $plugins, |
|
| 207 | - $surcharges, |
|
| 208 | - $exceptions_des_tables, |
|
| 209 | - $tables_principales, |
|
| 210 | - $table_des_tables, |
|
| 211 | - $tables_auxiliaires, |
|
| 212 | - $table_primary, |
|
| 213 | - $table_date, |
|
| 214 | - $table_titre, |
|
| 215 | - $tables_jointures, |
|
| 216 | - $liste_des_statuts, |
|
| 217 | - $liste_des_etats, |
|
| 218 | - $liste_des_authentifications, |
|
| 219 | - $spip_version_branche, |
|
| 220 | - $spip_version_code, |
|
| 221 | - $spip_version_base, |
|
| 222 | - $spip_sql_version, |
|
| 223 | - $spip_version_affichee, |
|
| 224 | - $visiteur_session, |
|
| 225 | - $auteur_session, |
|
| 226 | - $connect_statut, |
|
| 227 | - $connect_toutes_rubriques, |
|
| 228 | - $hash_recherche, |
|
| 229 | - $hash_recherche_strict, |
|
| 230 | - $ldap_present, |
|
| 231 | - $meta, |
|
| 232 | - $connect_id_rubrique, |
|
| 233 | - $puce; |
|
| 179 | + $nombre_de_logs, |
|
| 180 | + $taille_des_logs, |
|
| 181 | + $table_prefix, |
|
| 182 | + $cookie_prefix, |
|
| 183 | + $dossier_squelettes, |
|
| 184 | + $filtrer_javascript, |
|
| 185 | + $type_urls, |
|
| 186 | + $debut_date_publication, |
|
| 187 | + $ip, |
|
| 188 | + $mysql_rappel_connexion, |
|
| 189 | + $mysql_rappel_nom_base, |
|
| 190 | + $test_i18n, |
|
| 191 | + $ignore_auth_http, |
|
| 192 | + $ignore_remote_user, |
|
| 193 | + $derniere_modif_invalide, |
|
| 194 | + $home_server, |
|
| 195 | + $help_server, |
|
| 196 | + $url_glossaire_externe, |
|
| 197 | + $tex_server, |
|
| 198 | + $traiter_math, |
|
| 199 | + $xhtml, |
|
| 200 | + $xml_indent, |
|
| 201 | + $source_vignettes, |
|
| 202 | + $formats_logos, |
|
| 203 | + $controler_dates_rss, |
|
| 204 | + $spip_pipeline, |
|
| 205 | + $spip_matrice, |
|
| 206 | + $plugins, |
|
| 207 | + $surcharges, |
|
| 208 | + $exceptions_des_tables, |
|
| 209 | + $tables_principales, |
|
| 210 | + $table_des_tables, |
|
| 211 | + $tables_auxiliaires, |
|
| 212 | + $table_primary, |
|
| 213 | + $table_date, |
|
| 214 | + $table_titre, |
|
| 215 | + $tables_jointures, |
|
| 216 | + $liste_des_statuts, |
|
| 217 | + $liste_des_etats, |
|
| 218 | + $liste_des_authentifications, |
|
| 219 | + $spip_version_branche, |
|
| 220 | + $spip_version_code, |
|
| 221 | + $spip_version_base, |
|
| 222 | + $spip_sql_version, |
|
| 223 | + $spip_version_affichee, |
|
| 224 | + $visiteur_session, |
|
| 225 | + $auteur_session, |
|
| 226 | + $connect_statut, |
|
| 227 | + $connect_toutes_rubriques, |
|
| 228 | + $hash_recherche, |
|
| 229 | + $hash_recherche_strict, |
|
| 230 | + $ldap_present, |
|
| 231 | + $meta, |
|
| 232 | + $connect_id_rubrique, |
|
| 233 | + $puce; |
|
| 234 | 234 | |
| 235 | 235 | # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log |
| 236 | 236 | $nombre_de_logs = 4; |
@@ -285,48 +285,48 @@ discard block |
||
| 285 | 285 | // Prendre en compte les entetes HTTP_X_FORWARDED_XX |
| 286 | 286 | // |
| 287 | 287 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
| 288 | - if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 289 | - $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 290 | - } |
|
| 291 | - if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 292 | - $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 293 | - } |
|
| 288 | + if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 289 | + $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 290 | + } |
|
| 291 | + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 292 | + $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 293 | + } |
|
| 294 | 294 | } |
| 295 | 295 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 296 | - if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 297 | - $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 298 | - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 299 | - $_SERVER['HTTPS'] = 'on'; |
|
| 300 | - if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 301 | - $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 306 | - if (strpos($host, ',') !== false) { |
|
| 307 | - $h = explode(',', $host); |
|
| 308 | - $host = trim(reset($h)); |
|
| 309 | - } |
|
| 310 | - // securite sur le contenu de l'entete |
|
| 311 | - $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 312 | - $_SERVER['HTTP_HOST'] = $host; |
|
| 296 | + if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 297 | + $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 298 | + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 299 | + $_SERVER['HTTPS'] = 'on'; |
|
| 300 | + if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 301 | + $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 306 | + if (strpos($host, ',') !== false) { |
|
| 307 | + $h = explode(',', $host); |
|
| 308 | + $host = trim(reset($h)); |
|
| 309 | + } |
|
| 310 | + // securite sur le contenu de l'entete |
|
| 311 | + $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 312 | + $_SERVER['HTTP_HOST'] = $host; |
|
| 313 | 313 | } |
| 314 | 314 | // |
| 315 | 315 | // On note le numero IP du client dans la variable $ip |
| 316 | 316 | // |
| 317 | 317 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 318 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 319 | - if (strpos($ip, ',') !== false) { |
|
| 320 | - $ip = explode(',', $ip); |
|
| 321 | - $ip = reset($ip); |
|
| 322 | - } |
|
| 323 | - // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 324 | - if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 325 | - $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 326 | - } |
|
| 318 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 319 | + if (strpos($ip, ',') !== false) { |
|
| 320 | + $ip = explode(',', $ip); |
|
| 321 | + $ip = reset($ip); |
|
| 322 | + } |
|
| 323 | + // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 324 | + if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 325 | + $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 326 | + } |
|
| 327 | 327 | } |
| 328 | 328 | if (isset($_SERVER['REMOTE_ADDR'])) { |
| 329 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 329 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la |
@@ -411,24 +411,24 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | // Liste des statuts. |
| 413 | 413 | $liste_des_statuts = [ |
| 414 | - 'info_administrateurs' => '0minirezo', |
|
| 415 | - 'info_redacteurs' => '1comite', |
|
| 416 | - 'info_visiteurs' => '6forum', |
|
| 417 | - 'texte_statut_poubelle' => '5poubelle' |
|
| 414 | + 'info_administrateurs' => '0minirezo', |
|
| 415 | + 'info_redacteurs' => '1comite', |
|
| 416 | + 'info_visiteurs' => '6forum', |
|
| 417 | + 'texte_statut_poubelle' => '5poubelle' |
|
| 418 | 418 | ]; |
| 419 | 419 | |
| 420 | 420 | $liste_des_etats = [ |
| 421 | - 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 422 | - 'texte_statut_propose_evaluation' => 'prop', |
|
| 423 | - 'texte_statut_publie' => 'publie', |
|
| 424 | - 'texte_statut_poubelle' => 'poubelle', |
|
| 425 | - 'texte_statut_refuse' => 'refuse' |
|
| 421 | + 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 422 | + 'texte_statut_propose_evaluation' => 'prop', |
|
| 423 | + 'texte_statut_publie' => 'publie', |
|
| 424 | + 'texte_statut_poubelle' => 'poubelle', |
|
| 425 | + 'texte_statut_refuse' => 'refuse' |
|
| 426 | 426 | ]; |
| 427 | 427 | |
| 428 | 428 | // liste des methodes d'authentifications |
| 429 | 429 | $liste_des_authentifications = [ |
| 430 | - 'spip' => 'spip', |
|
| 431 | - 'ldap' => 'ldap' |
|
| 430 | + 'spip' => 'spip', |
|
| 431 | + 'ldap' => 'ldap' |
|
| 432 | 432 | ]; |
| 433 | 433 | |
| 434 | 434 | // Experimental : pour supprimer systematiquement l'affichage des numeros |
@@ -478,12 +478,12 @@ discard block |
||
| 478 | 478 | // Definition personnelles eventuelles |
| 479 | 479 | |
| 480 | 480 | if (_FILE_OPTIONS) { |
| 481 | - include_once _FILE_OPTIONS; |
|
| 481 | + include_once _FILE_OPTIONS; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | if (!defined('SPIP_ERREUR_REPORT')) { |
| 485 | - /** Masquer les warning */ |
|
| 486 | - define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 485 | + /** Masquer les warning */ |
|
| 486 | + define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 487 | 487 | } |
| 488 | 488 | error_reporting(SPIP_ERREUR_REPORT); |
| 489 | 489 | |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | // ===> on execute en neutralisant les messages d'erreur |
| 497 | 497 | |
| 498 | 498 | spip_initialisation_core( |
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 499 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 503 | 503 | ); |
| 504 | 504 | |
| 505 | 505 | |
@@ -509,71 +509,71 @@ discard block |
||
| 509 | 509 | // donc il faut avoir tout fini ici avant de charger les plugins |
| 510 | 510 | |
| 511 | 511 | if (@is_readable(_CACHE_PLUGINS_OPT) and @is_readable(_CACHE_PLUGINS_PATH)) { |
| 512 | - // chargement optimise precompile |
|
| 513 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 512 | + // chargement optimise precompile |
|
| 513 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 514 | 514 | } else { |
| 515 | - spip_initialisation_suite(); |
|
| 516 | - include_spip('inc/plugin'); |
|
| 517 | - // generer les fichiers php precompiles |
|
| 518 | - // de chargement des plugins et des pipelines |
|
| 519 | - actualise_plugins_actifs(); |
|
| 515 | + spip_initialisation_suite(); |
|
| 516 | + include_spip('inc/plugin'); |
|
| 517 | + // generer les fichiers php precompiles |
|
| 518 | + // de chargement des plugins et des pipelines |
|
| 519 | + actualise_plugins_actifs(); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | // Initialisations non critiques surchargeables par les plugins |
| 523 | 523 | spip_initialisation_suite(); |
| 524 | 524 | |
| 525 | 525 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 526 | - /** niveau maxi d'enregistrement des logs */ |
|
| 527 | - define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 526 | + /** niveau maxi d'enregistrement des logs */ |
|
| 527 | + define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | if (!defined('_OUTILS_DEVELOPPEURS')) { |
| 531 | - /** Activer des outils pour développeurs ? */ |
|
| 532 | - define('_OUTILS_DEVELOPPEURS', false); |
|
| 531 | + /** Activer des outils pour développeurs ? */ |
|
| 532 | + define('_OUTILS_DEVELOPPEURS', false); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | // charger systematiquement inc/autoriser dans l'espace restreint |
| 536 | 536 | if (test_espace_prive()) { |
| 537 | - include_spip('inc/autoriser'); |
|
| 537 | + include_spip('inc/autoriser'); |
|
| 538 | 538 | } |
| 539 | 539 | // |
| 540 | 540 | // Installer Spip si pas installe... sauf si justement on est en train |
| 541 | 541 | // |
| 542 | 542 | if ( |
| 543 | - !(_FILE_CONNECT |
|
| 544 | - or autoriser_sans_cookie(_request('exec')) |
|
| 545 | - or _request('action') == 'cookie' |
|
| 546 | - or _request('action') == 'converser' |
|
| 547 | - or _request('action') == 'test_dirs') |
|
| 543 | + !(_FILE_CONNECT |
|
| 544 | + or autoriser_sans_cookie(_request('exec')) |
|
| 545 | + or _request('action') == 'cookie' |
|
| 546 | + or _request('action') == 'converser' |
|
| 547 | + or _request('action') == 'test_dirs') |
|
| 548 | 548 | ) { |
| 549 | - // Si on peut installer, on lance illico |
|
| 550 | - if (test_espace_prive()) { |
|
| 551 | - include_spip('inc/headers'); |
|
| 552 | - redirige_url_ecrire('install'); |
|
| 553 | - } else { |
|
| 554 | - // Si on est dans le site public, dire que qq s'en occupe |
|
| 555 | - include_spip('inc/lang'); |
|
| 556 | - utiliser_langue_visiteur(); |
|
| 557 | - include_spip('inc/minipres'); |
|
| 558 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 559 | - exit; |
|
| 560 | - } |
|
| 561 | - // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 549 | + // Si on peut installer, on lance illico |
|
| 550 | + if (test_espace_prive()) { |
|
| 551 | + include_spip('inc/headers'); |
|
| 552 | + redirige_url_ecrire('install'); |
|
| 553 | + } else { |
|
| 554 | + // Si on est dans le site public, dire que qq s'en occupe |
|
| 555 | + include_spip('inc/lang'); |
|
| 556 | + utiliser_langue_visiteur(); |
|
| 557 | + include_spip('inc/minipres'); |
|
| 558 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 559 | + exit; |
|
| 560 | + } |
|
| 561 | + // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | // memoriser un tri sessionne eventuel |
| 565 | 565 | if ( |
| 566 | - isset($_REQUEST['var_memotri']) |
|
| 567 | - and $t = $_REQUEST['var_memotri'] |
|
| 568 | - and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 566 | + isset($_REQUEST['var_memotri']) |
|
| 567 | + and $t = $_REQUEST['var_memotri'] |
|
| 568 | + and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 569 | 569 | ) { |
| 570 | - if (!function_exists('session_set')) { |
|
| 571 | - include_spip('inc/session'); |
|
| 572 | - } |
|
| 573 | - $t = preg_replace(',\W,', '_', $t); |
|
| 574 | - if ($v = _request($t)) { |
|
| 575 | - session_set($t, $v); |
|
| 576 | - } |
|
| 570 | + if (!function_exists('session_set')) { |
|
| 571 | + include_spip('inc/session'); |
|
| 572 | + } |
|
| 573 | + $t = preg_replace(',\W,', '_', $t); |
|
| 574 | + if ($v = _request($t)) { |
|
| 575 | + session_set($t, $v); |
|
| 576 | + } |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | /** |
@@ -583,22 +583,22 @@ discard block |
||
| 583 | 583 | * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite |
| 584 | 584 | */ |
| 585 | 585 | if (!defined('_HEADER_COMPOSED_BY')) { |
| 586 | - define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 586 | + define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 587 | 587 | } |
| 588 | 588 | if (!headers_sent() and _HEADER_COMPOSED_BY) { |
| 589 | - if (!defined('_HEADER_VARY')) { |
|
| 590 | - define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 591 | - } |
|
| 592 | - if (_HEADER_VARY) { |
|
| 593 | - header(_HEADER_VARY); |
|
| 594 | - } |
|
| 595 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 596 | - include_spip('inc/filtres_mini'); |
|
| 597 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 598 | - } else { |
|
| 599 | - // header minimal |
|
| 600 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 601 | - } |
|
| 589 | + if (!defined('_HEADER_VARY')) { |
|
| 590 | + define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 591 | + } |
|
| 592 | + if (_HEADER_VARY) { |
|
| 593 | + header(_HEADER_VARY); |
|
| 594 | + } |
|
| 595 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 596 | + include_spip('inc/filtres_mini'); |
|
| 597 | + header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 598 | + } else { |
|
| 599 | + // header minimal |
|
| 600 | + header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 601 | + } |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * Ce programme est un logiciel libre distribué sous licence GNU/GPL. * |
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 12 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Initialisation de SPIP |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | define('_DIR_RACINE', _DIR_RESTREINT ? '' : '../'); |
| 54 | 54 | |
| 55 | 55 | /** chemin absolu vers la racine */ |
| 56 | -define('_ROOT_RACINE', dirname(__DIR__) . '/'); |
|
| 56 | +define('_ROOT_RACINE', dirname(__DIR__).'/'); |
|
| 57 | 57 | /** chemin absolu vers le repertoire de travail */ |
| 58 | -define('_ROOT_CWD', getcwd() . '/'); |
|
| 58 | +define('_ROOT_CWD', getcwd().'/'); |
|
| 59 | 59 | /** chemin absolu vers ecrire */ |
| 60 | -define('_ROOT_RESTREINT', _ROOT_CWD . _DIR_RESTREINT); |
|
| 60 | +define('_ROOT_RESTREINT', _ROOT_CWD._DIR_RESTREINT); |
|
| 61 | 61 | |
| 62 | 62 | // Icones |
| 63 | 63 | if (!defined('_NOM_IMG_PACK')) { |
@@ -65,17 +65,17 @@ discard block |
||
| 65 | 65 | define('_NOM_IMG_PACK', 'images/'); |
| 66 | 66 | } |
| 67 | 67 | /** le chemin http (relatif) vers les images standard */ |
| 68 | -define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
|
| 68 | +define('_DIR_IMG_PACK', (_DIR_RACINE.'prive/'._NOM_IMG_PACK)); |
|
| 69 | 69 | |
| 70 | 70 | /** le chemin php (absolu) vers les images standard (pour hebergement centralise) */ |
| 71 | -define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
|
| 71 | +define('_ROOT_IMG_PACK', dirname(__DIR__).'/prive/'._NOM_IMG_PACK); |
|
| 72 | 72 | |
| 73 | 73 | if (!defined('_JAVASCRIPT')) { |
| 74 | 74 | /** Nom du repertoire des bibliotheques JavaScript */ |
| 75 | 75 | define('_JAVASCRIPT', 'javascript/'); |
| 76 | 76 | } // utilisable avec #CHEMIN et find_in_path |
| 77 | 77 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 78 | -define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
|
| 78 | +define('_DIR_JAVASCRIPT', (_DIR_RACINE.'prive/'._JAVASCRIPT)); |
|
| 79 | 79 | |
| 80 | 80 | # Le nom des 4 repertoires modifiables par les scripts lances par httpd |
| 81 | 81 | # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas) |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // Son emplacement absolu si on le trouve |
| 108 | 108 | if ( |
| 109 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 110 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 109 | + @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES._NOM_CONFIG.'.php') |
|
| 110 | + or (@file_exists($f = _ROOT_RESTREINT._NOM_CONFIG.'.php')) |
|
| 111 | 111 | ) { |
| 112 | 112 | /** Emplacement absolu du fichier d'option */ |
| 113 | 113 | define('_FILE_OPTIONS', $f); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | // inclure l'ecran de securite |
| 132 | 132 | if ( |
| 133 | 133 | !defined('_ECRAN_SECURITE') |
| 134 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 134 | + and @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES.'ecran_securite.php') |
|
| 135 | 135 | ) { |
| 136 | 136 | include $f; |
| 137 | 137 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // UA plus cibles |
| 153 | 153 | . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
| 154 | 154 | . ',i', |
| 155 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | + (string) $_SERVER['HTTP_USER_AGENT'] |
|
| 156 | 156 | ) |
| 157 | 157 | ); |
| 158 | 158 | } |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | # la matrice standard (fichiers definissant les fonctions a inclure) |
| 395 | 395 | $spip_matrice = []; |
| 396 | 396 | # les plugins a activer |
| 397 | -$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 397 | +$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 398 | 398 | # les surcharges de include_spip() |
| 399 | 399 | $surcharges = []; // format 'inc_truc' => '/plugins/chose/inc_truc2.php' |
| 400 | 400 | |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | // |
| 473 | 473 | // Charger les fonctions liees aux serveurs Http et Sql. |
| 474 | 474 | // |
| 475 | -require_once _ROOT_RESTREINT . 'inc/utils.php'; |
|
| 476 | -require_once _ROOT_RESTREINT . 'base/connect_sql.php'; |
|
| 475 | +require_once _ROOT_RESTREINT.'inc/utils.php'; |
|
| 476 | +require_once _ROOT_RESTREINT.'base/connect_sql.php'; |
|
| 477 | 477 | |
| 478 | 478 | // Definition personnelles eventuelles |
| 479 | 479 | |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | // ===> on execute en neutralisant les messages d'erreur |
| 497 | 497 | |
| 498 | 498 | spip_initialisation_core( |
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 499 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 503 | 503 | ); |
| 504 | 504 | |
| 505 | 505 | |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | include_spip('inc/lang'); |
| 556 | 556 | utiliser_langue_visiteur(); |
| 557 | 557 | include_spip('inc/minipres'); |
| 558 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 558 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>"._T('info_travaux_texte').'</p>', ['status' => 503]); |
|
| 559 | 559 | exit; |
| 560 | 560 | } |
| 561 | 561 | // autrement c'est une install ad hoc (spikini...), on sait pas faire |
@@ -594,12 +594,12 @@ discard block |
||
| 594 | 594 | } |
| 595 | 595 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 596 | 596 | include_spip('inc/filtres_mini'); |
| 597 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 597 | + header(_HEADER_COMPOSED_BY." $spip_version_affichee @ www.spip.net + ".url_absolue(_DIR_VAR.'config.txt')); |
|
| 598 | 598 | } else { |
| 599 | 599 | // header minimal |
| 600 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 600 | + header(_HEADER_COMPOSED_BY.' @ www.spip.net'); |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
| 605 | -spip_log($methode . ' ' . self() . ' - ' . _FILE_CONNECT, _LOG_DEBUG); |
|
| 605 | +spip_log($methode.' '.self().' - '._FILE_CONNECT, _LOG_DEBUG); |
|
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
| 44 | 44 | |
| 45 | 45 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 46 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 46 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 47 | 47 | |
| 48 | 48 | $fquery = sql_serveur('query', $server_db); |
| 49 | 49 | if ($choix_db == 'new_spip') { |
@@ -53,13 +53,13 @@ discard block |
||
| 53 | 53 | if (!$ok) { |
| 54 | 54 | $re = "Impossible de creer la base $re"; |
| 55 | 55 | spip_log($re); |
| 56 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 56 | + return '<p>'._T('avis_connexion_erreur_creer_base')."</p><!--\n$re\n-->"; |
|
| 57 | 57 | } |
| 58 | 58 | } else { |
| 59 | 59 | $re = "Le nom de la base doit correspondre a $re"; |
| 60 | 60 | spip_log($re); |
| 61 | 61 | |
| 62 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 62 | + return '<p>'._T('avis_connexion_erreur_nom_base')."</p><!--\n$re\n-->"; |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
| 71 | 71 | |
| 72 | 72 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 73 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 73 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 74 | 74 | |
| 75 | 75 | // Completer le tableau decrivant la connexion |
| 76 | 76 | |
| 77 | 77 | $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
| 78 | 78 | $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
| 79 | 79 | |
| 80 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 80 | + $old = sql_showbase($table_prefix.'_meta', $server_db); |
|
| 81 | 81 | if ($old) { |
| 82 | 82 | $old = sql_fetch($old, $server_db); |
| 83 | 83 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $charset['charset']; |
| 97 | 97 | $charsetbase = $charset['charset']; |
| 98 | 98 | } else { |
| 99 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 99 | + spip_log(_DEFAULT_CHARSET.' inconnu du serveur SQL'); |
|
| 100 | 100 | $charsetbase = 'standard'; |
| 101 | 101 | } |
| 102 | 102 | spip_log("Creation des tables. Codage $charsetbase"); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if ($r) { |
| 147 | 147 | $r = sql_fetch($r, $server_db); |
| 148 | 148 | } |
| 149 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 149 | + $version_installee = !$r ? 0 : (double) $r['valeur']; |
|
| 150 | 150 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 151 | 151 | $fupdateq( |
| 152 | 152 | 'spip_meta', |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | '', |
| 156 | 156 | $server_db |
| 157 | 157 | ); |
| 158 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 158 | + spip_log('nouvelle version installee: '.$GLOBALS['spip_version_base']); |
|
| 159 | 159 | } |
| 160 | 160 | // eliminer la derniere operation d'admin mal terminee |
| 161 | 161 | // notamment la mise a jour |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | if ($chmod_db) { |
| 183 | 183 | install_fichier_connexion( |
| 184 | 184 | _FILE_CHMOD_TMP, |
| 185 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 185 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', ".sprintf('0%3o', $chmod_db).");\n" |
|
| 186 | 186 | ); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -245,16 +245,16 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | function install_premier_auteur($email, $login, $nom, #[\SensitiveParameter] $pass, $hidden, $auteur_obligatoire) { |
| 248 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 248 | + return info_progression_etape(3, 'etape_', 'install/'). |
|
| 249 | 249 | info_etape( |
| 250 | 250 | _T('info_informations_personnelles'), |
| 251 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 252 | - aider('install5', true) . |
|
| 253 | - '<p>' . |
|
| 251 | + '<b>'._T('texte_informations_personnelles_1').'</b>'. |
|
| 252 | + aider('install5', true). |
|
| 253 | + '<p>'. |
|
| 254 | 254 | ($auteur_obligatoire ? |
| 255 | 255 | '' |
| 256 | 256 | : |
| 257 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 257 | + _T('texte_informations_personnelles_2').' '._T('info_laisser_champs_vides') |
|
| 258 | 258 | ) |
| 259 | 259 | ) |
| 260 | 260 | . generer_form_ecrire('install', ( |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | _T('info_identification_publique'), |
| 265 | 265 | [ |
| 266 | 266 | 'nom' => [ |
| 267 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 267 | + 'label' => '<b>'._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n", |
|
| 268 | 268 | 'valeur' => $nom, |
| 269 | 269 | 'required' => $auteur_obligatoire, |
| 270 | 270 | ], |
| 271 | 271 | 'email' => [ |
| 272 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 272 | + 'label' => '<b>'._T('entree_adresse_email')."</b>\n", |
|
| 273 | 273 | 'valeur' => $email, |
| 274 | 274 | ] |
| 275 | 275 | ] |
@@ -279,23 +279,23 @@ discard block |
||
| 279 | 279 | _T('entree_identifiants_connexion'), |
| 280 | 280 | [ |
| 281 | 281 | 'login' => [ |
| 282 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 282 | + 'label' => '<b>'._T('entree_login')."</b><br />\n"._T( |
|
| 283 | 283 | 'info_login_trop_court_car_pluriel', |
| 284 | 284 | ['nb' => _LOGIN_TROP_COURT] |
| 285 | - ) . "\n", |
|
| 285 | + )."\n", |
|
| 286 | 286 | 'valeur' => $login, |
| 287 | 287 | 'required' => $auteur_obligatoire, |
| 288 | 288 | ], |
| 289 | 289 | 'pass' => [ |
| 290 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 290 | + 'label' => '<b>'._T('entree_mot_passe')."</b><br />\n"._T( |
|
| 291 | 291 | 'info_passe_trop_court_car_pluriel', |
| 292 | 292 | ['nb' => _PASS_LONGUEUR_MINI] |
| 293 | - ) . "\n", |
|
| 293 | + )."\n", |
|
| 294 | 294 | 'valeur' => $pass, |
| 295 | 295 | 'required' => $auteur_obligatoire, |
| 296 | 296 | ], |
| 297 | 297 | 'pass_verif' => [ |
| 298 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 298 | + 'label' => '<b>'._T('info_confirmer_passe')."</b><br />\n", |
|
| 299 | 299 | 'valeur' => $pass, |
| 300 | 300 | 'required' => $auteur_obligatoire, |
| 301 | 301 | ] |
@@ -339,9 +339,9 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | if ($res) { |
| 341 | 341 | $res = info_progression_etape(2, 'etape_', 'install/', true) |
| 342 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 342 | + . "<div class='error'><h3>"._T('avis_operation_echec').'</h3>' |
|
| 343 | 343 | . $res |
| 344 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 344 | + . '<p>'._T('texte_operation_echec').'</p>' |
|
| 345 | 345 | . '</div>'; |
| 346 | 346 | } |
| 347 | 347 | } else { |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
| 367 | 367 | . (defined('_INSTALL_NAME_DB') ? '' |
| 368 | - : "\n<input type='hidden' name='sel_db' value=\"" . spip_htmlspecialchars($sel_db) . '" />'); |
|
| 368 | + : "\n<input type='hidden' name='sel_db' value=\"".spip_htmlspecialchars($sel_db).'" />'); |
|
| 369 | 369 | |
| 370 | 370 | $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
| 371 | 371 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/headers'); |
@@ -18,199 +18,199 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) { |
| 20 | 20 | |
| 21 | - // Prefix des tables : |
|
| 22 | - // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 23 | - // a partir de ce qui est envoye a l'installation |
|
| 24 | - if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 25 | - $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 26 | - ? $GLOBALS['table_prefix'] |
|
| 27 | - : preparer_prefixe_tables(_request('tprefix')); |
|
| 28 | - // S'il est vide on remet spip |
|
| 29 | - if (!$table_prefix) { |
|
| 30 | - $table_prefix = 'spip'; |
|
| 31 | - } |
|
| 32 | - } else { |
|
| 33 | - $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 37 | - [, $adresse_db, $port] = $r; |
|
| 38 | - } else { |
|
| 39 | - $port = ''; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - $GLOBALS['connexions'][$server_db] |
|
| 43 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 44 | - |
|
| 45 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 46 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 47 | - |
|
| 48 | - $fquery = sql_serveur('query', $server_db); |
|
| 49 | - if ($choix_db == 'new_spip') { |
|
| 50 | - $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 51 | - if (preg_match($re, $sel_db)) { |
|
| 52 | - $ok = sql_create_base($sel_db, $server_db); |
|
| 53 | - if (!$ok) { |
|
| 54 | - $re = "Impossible de creer la base $re"; |
|
| 55 | - spip_log($re); |
|
| 56 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 57 | - } |
|
| 58 | - } else { |
|
| 59 | - $re = "Le nom de la base doit correspondre a $re"; |
|
| 60 | - spip_log($re); |
|
| 61 | - |
|
| 62 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 67 | - // un sql_mode |
|
| 68 | - install_mode_appel($server_db, false); |
|
| 69 | - $GLOBALS['connexions'][$server_db] |
|
| 70 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 71 | - |
|
| 72 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 73 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 74 | - |
|
| 75 | - // Completer le tableau decrivant la connexion |
|
| 76 | - |
|
| 77 | - $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 78 | - $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 79 | - |
|
| 80 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 81 | - if ($old) { |
|
| 82 | - $old = sql_fetch($old, $server_db); |
|
| 83 | - } |
|
| 84 | - if (!$old) { |
|
| 85 | - // Si possible, demander au serveur d'envoyer les textes |
|
| 86 | - // dans le codage std de SPIP, |
|
| 87 | - $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 88 | - |
|
| 89 | - if ($charset) { |
|
| 90 | - sql_set_charset($charset['charset'], $server_db); |
|
| 91 | - $GLOBALS['meta']['charset_sql_base'] = |
|
| 92 | - $charset['charset']; |
|
| 93 | - $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 94 | - $charset['collation']; |
|
| 95 | - $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 96 | - $charset['charset']; |
|
| 97 | - $charsetbase = $charset['charset']; |
|
| 98 | - } else { |
|
| 99 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 100 | - $charsetbase = 'standard'; |
|
| 101 | - } |
|
| 102 | - spip_log("Creation des tables. Codage $charsetbase"); |
|
| 103 | - creer_base($server_db); // AT LAST |
|
| 104 | - // memoriser avec quel charset on l'a creee |
|
| 105 | - |
|
| 106 | - if ($charset) { |
|
| 107 | - $t = [ |
|
| 108 | - 'nom' => 'charset_sql_base', |
|
| 109 | - 'valeur' => $charset['charset'], |
|
| 110 | - 'impt' => 'non' |
|
| 111 | - ]; |
|
| 112 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 113 | - $t['nom'] = 'charset_collation_sql_base'; |
|
| 114 | - $t['valeur'] = $charset['collation']; |
|
| 115 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 116 | - $t['nom'] = 'charset_sql_connexion'; |
|
| 117 | - $t['valeur'] = $charset['charset']; |
|
| 118 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 119 | - } |
|
| 120 | - $t = [ |
|
| 121 | - 'nom' => 'version_installee', |
|
| 122 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 123 | - 'impt' => 'non' |
|
| 124 | - ]; |
|
| 125 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 126 | - $t['nom'] = 'nouvelle_install'; |
|
| 127 | - $t['valeur'] = 1; |
|
| 128 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 129 | - // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 130 | - if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 131 | - @sql_insertq( |
|
| 132 | - 'spip_meta', |
|
| 133 | - ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 134 | - [], |
|
| 135 | - $server_db |
|
| 136 | - ); |
|
| 137 | - } |
|
| 138 | - } else { |
|
| 139 | - // pour recreer les tables disparues au besoin |
|
| 140 | - spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 141 | - creer_base($server_db); |
|
| 142 | - $fupdateq = sql_serveur('updateq', $server_db); |
|
| 143 | - |
|
| 144 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 145 | - |
|
| 146 | - if ($r) { |
|
| 147 | - $r = sql_fetch($r, $server_db); |
|
| 148 | - } |
|
| 149 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 150 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 151 | - $fupdateq( |
|
| 152 | - 'spip_meta', |
|
| 153 | - ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 154 | - "nom='version_installee'", |
|
| 155 | - '', |
|
| 156 | - $server_db |
|
| 157 | - ); |
|
| 158 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 159 | - } |
|
| 160 | - // eliminer la derniere operation d'admin mal terminee |
|
| 161 | - // notamment la mise a jour |
|
| 162 | - @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // recuperer le charset de la connexion dans les meta |
|
| 166 | - $charset = ''; |
|
| 167 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 168 | - if ($r) { |
|
| 169 | - $r = sql_fetch($r, $server_db); |
|
| 170 | - } |
|
| 171 | - if ($r) { |
|
| 172 | - $charset = $r['valeur']; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - $ligne_rappel = install_mode_appel($server_db); |
|
| 176 | - |
|
| 177 | - $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 178 | - if (!$result_ok) { |
|
| 179 | - return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - if ($chmod_db) { |
|
| 183 | - install_fichier_connexion( |
|
| 184 | - _FILE_CHMOD_TMP, |
|
| 185 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 186 | - ); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - // si ce fichier existe a cette etape c'est qu'il provient |
|
| 190 | - // d'une installation qui ne l'a pas cree correctement. |
|
| 191 | - // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 192 | - |
|
| 193 | - if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 194 | - spip_unlink(_FILE_CONNECT); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - install_fichier_connexion( |
|
| 198 | - _FILE_CONNECT_TMP, |
|
| 199 | - $ligne_rappel |
|
| 200 | - . install_connexion( |
|
| 201 | - $adresse_db, |
|
| 202 | - $port, |
|
| 203 | - $login_db, |
|
| 204 | - $pass_db, |
|
| 205 | - $sel_db, |
|
| 206 | - $server_db, |
|
| 207 | - $table_prefix, |
|
| 208 | - '', |
|
| 209 | - $charset |
|
| 210 | - ) |
|
| 211 | - ); |
|
| 212 | - |
|
| 213 | - return ''; |
|
| 21 | + // Prefix des tables : |
|
| 22 | + // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 23 | + // a partir de ce qui est envoye a l'installation |
|
| 24 | + if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 25 | + $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 26 | + ? $GLOBALS['table_prefix'] |
|
| 27 | + : preparer_prefixe_tables(_request('tprefix')); |
|
| 28 | + // S'il est vide on remet spip |
|
| 29 | + if (!$table_prefix) { |
|
| 30 | + $table_prefix = 'spip'; |
|
| 31 | + } |
|
| 32 | + } else { |
|
| 33 | + $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 37 | + [, $adresse_db, $port] = $r; |
|
| 38 | + } else { |
|
| 39 | + $port = ''; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + $GLOBALS['connexions'][$server_db] |
|
| 43 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 44 | + |
|
| 45 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 46 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 47 | + |
|
| 48 | + $fquery = sql_serveur('query', $server_db); |
|
| 49 | + if ($choix_db == 'new_spip') { |
|
| 50 | + $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 51 | + if (preg_match($re, $sel_db)) { |
|
| 52 | + $ok = sql_create_base($sel_db, $server_db); |
|
| 53 | + if (!$ok) { |
|
| 54 | + $re = "Impossible de creer la base $re"; |
|
| 55 | + spip_log($re); |
|
| 56 | + return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 57 | + } |
|
| 58 | + } else { |
|
| 59 | + $re = "Le nom de la base doit correspondre a $re"; |
|
| 60 | + spip_log($re); |
|
| 61 | + |
|
| 62 | + return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 67 | + // un sql_mode |
|
| 68 | + install_mode_appel($server_db, false); |
|
| 69 | + $GLOBALS['connexions'][$server_db] |
|
| 70 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 71 | + |
|
| 72 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 73 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 74 | + |
|
| 75 | + // Completer le tableau decrivant la connexion |
|
| 76 | + |
|
| 77 | + $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 78 | + $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 79 | + |
|
| 80 | + $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 81 | + if ($old) { |
|
| 82 | + $old = sql_fetch($old, $server_db); |
|
| 83 | + } |
|
| 84 | + if (!$old) { |
|
| 85 | + // Si possible, demander au serveur d'envoyer les textes |
|
| 86 | + // dans le codage std de SPIP, |
|
| 87 | + $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 88 | + |
|
| 89 | + if ($charset) { |
|
| 90 | + sql_set_charset($charset['charset'], $server_db); |
|
| 91 | + $GLOBALS['meta']['charset_sql_base'] = |
|
| 92 | + $charset['charset']; |
|
| 93 | + $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 94 | + $charset['collation']; |
|
| 95 | + $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 96 | + $charset['charset']; |
|
| 97 | + $charsetbase = $charset['charset']; |
|
| 98 | + } else { |
|
| 99 | + spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 100 | + $charsetbase = 'standard'; |
|
| 101 | + } |
|
| 102 | + spip_log("Creation des tables. Codage $charsetbase"); |
|
| 103 | + creer_base($server_db); // AT LAST |
|
| 104 | + // memoriser avec quel charset on l'a creee |
|
| 105 | + |
|
| 106 | + if ($charset) { |
|
| 107 | + $t = [ |
|
| 108 | + 'nom' => 'charset_sql_base', |
|
| 109 | + 'valeur' => $charset['charset'], |
|
| 110 | + 'impt' => 'non' |
|
| 111 | + ]; |
|
| 112 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 113 | + $t['nom'] = 'charset_collation_sql_base'; |
|
| 114 | + $t['valeur'] = $charset['collation']; |
|
| 115 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 116 | + $t['nom'] = 'charset_sql_connexion'; |
|
| 117 | + $t['valeur'] = $charset['charset']; |
|
| 118 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 119 | + } |
|
| 120 | + $t = [ |
|
| 121 | + 'nom' => 'version_installee', |
|
| 122 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 123 | + 'impt' => 'non' |
|
| 124 | + ]; |
|
| 125 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 126 | + $t['nom'] = 'nouvelle_install'; |
|
| 127 | + $t['valeur'] = 1; |
|
| 128 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 129 | + // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 130 | + if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 131 | + @sql_insertq( |
|
| 132 | + 'spip_meta', |
|
| 133 | + ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 134 | + [], |
|
| 135 | + $server_db |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | + } else { |
|
| 139 | + // pour recreer les tables disparues au besoin |
|
| 140 | + spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 141 | + creer_base($server_db); |
|
| 142 | + $fupdateq = sql_serveur('updateq', $server_db); |
|
| 143 | + |
|
| 144 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 145 | + |
|
| 146 | + if ($r) { |
|
| 147 | + $r = sql_fetch($r, $server_db); |
|
| 148 | + } |
|
| 149 | + $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 150 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 151 | + $fupdateq( |
|
| 152 | + 'spip_meta', |
|
| 153 | + ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 154 | + "nom='version_installee'", |
|
| 155 | + '', |
|
| 156 | + $server_db |
|
| 157 | + ); |
|
| 158 | + spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 159 | + } |
|
| 160 | + // eliminer la derniere operation d'admin mal terminee |
|
| 161 | + // notamment la mise a jour |
|
| 162 | + @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // recuperer le charset de la connexion dans les meta |
|
| 166 | + $charset = ''; |
|
| 167 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 168 | + if ($r) { |
|
| 169 | + $r = sql_fetch($r, $server_db); |
|
| 170 | + } |
|
| 171 | + if ($r) { |
|
| 172 | + $charset = $r['valeur']; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + $ligne_rappel = install_mode_appel($server_db); |
|
| 176 | + |
|
| 177 | + $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 178 | + if (!$result_ok) { |
|
| 179 | + return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + if ($chmod_db) { |
|
| 183 | + install_fichier_connexion( |
|
| 184 | + _FILE_CHMOD_TMP, |
|
| 185 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 186 | + ); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + // si ce fichier existe a cette etape c'est qu'il provient |
|
| 190 | + // d'une installation qui ne l'a pas cree correctement. |
|
| 191 | + // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 192 | + |
|
| 193 | + if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 194 | + spip_unlink(_FILE_CONNECT); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + install_fichier_connexion( |
|
| 198 | + _FILE_CONNECT_TMP, |
|
| 199 | + $ligne_rappel |
|
| 200 | + . install_connexion( |
|
| 201 | + $adresse_db, |
|
| 202 | + $port, |
|
| 203 | + $login_db, |
|
| 204 | + $pass_db, |
|
| 205 | + $sel_db, |
|
| 206 | + $server_db, |
|
| 207 | + $table_prefix, |
|
| 208 | + '', |
|
| 209 | + $charset |
|
| 210 | + ) |
|
| 211 | + ); |
|
| 212 | + |
|
| 213 | + return ''; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -225,166 +225,166 @@ discard block |
||
| 225 | 225 | * @return string Le préfixe corrigé |
| 226 | 226 | */ |
| 227 | 227 | function preparer_prefixe_tables($prefixe) { |
| 228 | - return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 228 | + return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | function install_propose_ldap() { |
| 232 | - return generer_form_ecrire('install', ( |
|
| 233 | - fieldset( |
|
| 234 | - _T('info_authentification_externe'), |
|
| 235 | - [ |
|
| 236 | - 'etape' => [ |
|
| 237 | - 'label' => _T('texte_annuaire_ldap_1'), |
|
| 238 | - 'valeur' => 'ldap1', |
|
| 239 | - 'hidden' => true |
|
| 240 | - ] |
|
| 241 | - ], |
|
| 242 | - bouton_suivant(_T('bouton_acces_ldap')) |
|
| 243 | - ))); |
|
| 232 | + return generer_form_ecrire('install', ( |
|
| 233 | + fieldset( |
|
| 234 | + _T('info_authentification_externe'), |
|
| 235 | + [ |
|
| 236 | + 'etape' => [ |
|
| 237 | + 'label' => _T('texte_annuaire_ldap_1'), |
|
| 238 | + 'valeur' => 'ldap1', |
|
| 239 | + 'hidden' => true |
|
| 240 | + ] |
|
| 241 | + ], |
|
| 242 | + bouton_suivant(_T('bouton_acces_ldap')) |
|
| 243 | + ))); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | function install_premier_auteur($email, $login, $nom, #[\SensitiveParameter] $pass, $hidden, $auteur_obligatoire) { |
| 248 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 249 | - info_etape( |
|
| 250 | - _T('info_informations_personnelles'), |
|
| 251 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 252 | - aider('install5', true) . |
|
| 253 | - '<p>' . |
|
| 254 | - ($auteur_obligatoire ? |
|
| 255 | - '' |
|
| 256 | - : |
|
| 257 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 258 | - ) |
|
| 259 | - ) |
|
| 260 | - . generer_form_ecrire('install', ( |
|
| 261 | - "\n<input type='hidden' name='etape' value='3b' />" |
|
| 262 | - . $hidden |
|
| 263 | - . fieldset( |
|
| 264 | - _T('info_identification_publique'), |
|
| 265 | - [ |
|
| 266 | - 'nom' => [ |
|
| 267 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 268 | - 'valeur' => $nom, |
|
| 269 | - 'required' => $auteur_obligatoire, |
|
| 270 | - ], |
|
| 271 | - 'email' => [ |
|
| 272 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 273 | - 'valeur' => $email, |
|
| 274 | - ] |
|
| 275 | - ] |
|
| 276 | - ) |
|
| 277 | - |
|
| 278 | - . fieldset( |
|
| 279 | - _T('entree_identifiants_connexion'), |
|
| 280 | - [ |
|
| 281 | - 'login' => [ |
|
| 282 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 283 | - 'info_login_trop_court_car_pluriel', |
|
| 284 | - ['nb' => _LOGIN_TROP_COURT] |
|
| 285 | - ) . "\n", |
|
| 286 | - 'valeur' => $login, |
|
| 287 | - 'required' => $auteur_obligatoire, |
|
| 288 | - ], |
|
| 289 | - 'pass' => [ |
|
| 290 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 291 | - 'info_passe_trop_court_car_pluriel', |
|
| 292 | - ['nb' => _PASS_LONGUEUR_MINI] |
|
| 293 | - ) . "\n", |
|
| 294 | - 'valeur' => $pass, |
|
| 295 | - 'required' => $auteur_obligatoire, |
|
| 296 | - ], |
|
| 297 | - 'pass_verif' => [ |
|
| 298 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 299 | - 'valeur' => $pass, |
|
| 300 | - 'required' => $auteur_obligatoire, |
|
| 301 | - ] |
|
| 302 | - ] |
|
| 303 | - ) |
|
| 304 | - . bouton_suivant())); |
|
| 248 | + return info_progression_etape(3, 'etape_', 'install/') . |
|
| 249 | + info_etape( |
|
| 250 | + _T('info_informations_personnelles'), |
|
| 251 | + '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 252 | + aider('install5', true) . |
|
| 253 | + '<p>' . |
|
| 254 | + ($auteur_obligatoire ? |
|
| 255 | + '' |
|
| 256 | + : |
|
| 257 | + _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 258 | + ) |
|
| 259 | + ) |
|
| 260 | + . generer_form_ecrire('install', ( |
|
| 261 | + "\n<input type='hidden' name='etape' value='3b' />" |
|
| 262 | + . $hidden |
|
| 263 | + . fieldset( |
|
| 264 | + _T('info_identification_publique'), |
|
| 265 | + [ |
|
| 266 | + 'nom' => [ |
|
| 267 | + 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 268 | + 'valeur' => $nom, |
|
| 269 | + 'required' => $auteur_obligatoire, |
|
| 270 | + ], |
|
| 271 | + 'email' => [ |
|
| 272 | + 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 273 | + 'valeur' => $email, |
|
| 274 | + ] |
|
| 275 | + ] |
|
| 276 | + ) |
|
| 277 | + |
|
| 278 | + . fieldset( |
|
| 279 | + _T('entree_identifiants_connexion'), |
|
| 280 | + [ |
|
| 281 | + 'login' => [ |
|
| 282 | + 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 283 | + 'info_login_trop_court_car_pluriel', |
|
| 284 | + ['nb' => _LOGIN_TROP_COURT] |
|
| 285 | + ) . "\n", |
|
| 286 | + 'valeur' => $login, |
|
| 287 | + 'required' => $auteur_obligatoire, |
|
| 288 | + ], |
|
| 289 | + 'pass' => [ |
|
| 290 | + 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 291 | + 'info_passe_trop_court_car_pluriel', |
|
| 292 | + ['nb' => _PASS_LONGUEUR_MINI] |
|
| 293 | + ) . "\n", |
|
| 294 | + 'valeur' => $pass, |
|
| 295 | + 'required' => $auteur_obligatoire, |
|
| 296 | + ], |
|
| 297 | + 'pass_verif' => [ |
|
| 298 | + 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 299 | + 'valeur' => $pass, |
|
| 300 | + 'required' => $auteur_obligatoire, |
|
| 301 | + ] |
|
| 302 | + ] |
|
| 303 | + ) |
|
| 304 | + . bouton_suivant())); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | function install_etape_3_dist() { |
| 308 | - $ldap_present = _request('ldap_present'); |
|
| 309 | - |
|
| 310 | - if (!$ldap_present) { |
|
| 311 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 312 | - ? _INSTALL_HOST_DB |
|
| 313 | - : _request('adresse_db'); |
|
| 314 | - |
|
| 315 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 316 | - ? _INSTALL_USER_DB |
|
| 317 | - : _request('login_db'); |
|
| 318 | - |
|
| 319 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 320 | - ? _INSTALL_PASS_DB |
|
| 321 | - : _request('pass_db'); |
|
| 322 | - |
|
| 323 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 324 | - ? _INSTALL_SERVER_DB |
|
| 325 | - : _request('server_db'); |
|
| 326 | - |
|
| 327 | - $chmod_db = defined('_SPIP_CHMOD') |
|
| 328 | - ? _SPIP_CHMOD |
|
| 329 | - : _request('chmod'); |
|
| 330 | - |
|
| 331 | - $choix_db = defined('_INSTALL_NAME_DB') |
|
| 332 | - ? _INSTALL_NAME_DB |
|
| 333 | - : _request('choix_db'); |
|
| 334 | - |
|
| 335 | - $sel_db = ($choix_db == 'new_spip') |
|
| 336 | - ? _request('table_new') : $choix_db; |
|
| 337 | - |
|
| 338 | - $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 339 | - |
|
| 340 | - if ($res) { |
|
| 341 | - $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 342 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 343 | - . $res |
|
| 344 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 345 | - . '</div>'; |
|
| 346 | - } |
|
| 347 | - } else { |
|
| 348 | - $res = ''; |
|
| 349 | - [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 350 | - $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - if (!$res) { |
|
| 354 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 355 | - include(_FILE_CONNECT_TMP); |
|
| 356 | - } else { |
|
| 357 | - redirige_url_ecrire('install'); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 361 | - include(_FILE_CHMOD_TMP); |
|
| 362 | - } else { |
|
| 363 | - redirige_url_ecrire('install'); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 367 | - . (defined('_INSTALL_NAME_DB') ? '' |
|
| 368 | - : "\n<input type='hidden' name='sel_db' value=\"" . spip_htmlspecialchars($sel_db) . '" />'); |
|
| 369 | - |
|
| 370 | - $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 371 | - |
|
| 372 | - $res = "<div class='success'><b>" |
|
| 373 | - . _T('info_base_installee') |
|
| 374 | - . '</b></div>' |
|
| 375 | - . install_premier_auteur( |
|
| 376 | - _request('email'), |
|
| 377 | - _request('login'), |
|
| 378 | - _request('nom'), |
|
| 379 | - _request('pass'), |
|
| 380 | - $hidden, |
|
| 381 | - $auteur_obligatoire |
|
| 382 | - ) |
|
| 383 | - . (($ldap_present or !function_exists('ldap_connect')) |
|
| 384 | - ? '' : install_propose_ldap()); |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 389 | - echo $minipage->page($res); |
|
| 308 | + $ldap_present = _request('ldap_present'); |
|
| 309 | + |
|
| 310 | + if (!$ldap_present) { |
|
| 311 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 312 | + ? _INSTALL_HOST_DB |
|
| 313 | + : _request('adresse_db'); |
|
| 314 | + |
|
| 315 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 316 | + ? _INSTALL_USER_DB |
|
| 317 | + : _request('login_db'); |
|
| 318 | + |
|
| 319 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 320 | + ? _INSTALL_PASS_DB |
|
| 321 | + : _request('pass_db'); |
|
| 322 | + |
|
| 323 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 324 | + ? _INSTALL_SERVER_DB |
|
| 325 | + : _request('server_db'); |
|
| 326 | + |
|
| 327 | + $chmod_db = defined('_SPIP_CHMOD') |
|
| 328 | + ? _SPIP_CHMOD |
|
| 329 | + : _request('chmod'); |
|
| 330 | + |
|
| 331 | + $choix_db = defined('_INSTALL_NAME_DB') |
|
| 332 | + ? _INSTALL_NAME_DB |
|
| 333 | + : _request('choix_db'); |
|
| 334 | + |
|
| 335 | + $sel_db = ($choix_db == 'new_spip') |
|
| 336 | + ? _request('table_new') : $choix_db; |
|
| 337 | + |
|
| 338 | + $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 339 | + |
|
| 340 | + if ($res) { |
|
| 341 | + $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 342 | + . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 343 | + . $res |
|
| 344 | + . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 345 | + . '</div>'; |
|
| 346 | + } |
|
| 347 | + } else { |
|
| 348 | + $res = ''; |
|
| 349 | + [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 350 | + $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + if (!$res) { |
|
| 354 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 355 | + include(_FILE_CONNECT_TMP); |
|
| 356 | + } else { |
|
| 357 | + redirige_url_ecrire('install'); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 361 | + include(_FILE_CHMOD_TMP); |
|
| 362 | + } else { |
|
| 363 | + redirige_url_ecrire('install'); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 367 | + . (defined('_INSTALL_NAME_DB') ? '' |
|
| 368 | + : "\n<input type='hidden' name='sel_db' value=\"" . spip_htmlspecialchars($sel_db) . '" />'); |
|
| 369 | + |
|
| 370 | + $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 371 | + |
|
| 372 | + $res = "<div class='success'><b>" |
|
| 373 | + . _T('info_base_installee') |
|
| 374 | + . '</b></div>' |
|
| 375 | + . install_premier_auteur( |
|
| 376 | + _request('email'), |
|
| 377 | + _request('login'), |
|
| 378 | + _request('nom'), |
|
| 379 | + _request('pass'), |
|
| 380 | + $hidden, |
|
| 381 | + $auteur_obligatoire |
|
| 382 | + ) |
|
| 383 | + . (($ldap_present or !function_exists('ldap_connect')) |
|
| 384 | + ? '' : install_propose_ldap()); |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 389 | + echo $minipage->page($res); |
|
| 390 | 390 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
@@ -20,18 +20,18 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | function req_sqlite3_dist($addr, $port, $login, #[\SensitiveParameter] $pass, $db = '', $prefixe = '') { |
| 23 | - return req_sqlite_dist($addr, $port, $login, $pass, $db, $prefixe, $sqlite_version = 3); |
|
| 23 | + return req_sqlite_dist($addr, $port, $login, $pass, $db, $prefixe, $sqlite_version = 3); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | function spip_sqlite3_constantes() { |
| 28 | - if (!defined('SPIP_SQLITE3_ASSOC')) { |
|
| 29 | - define('SPIP_SQLITE3_ASSOC', PDO::FETCH_ASSOC); |
|
| 30 | - define('SPIP_SQLITE3_NUM', PDO::FETCH_NUM); |
|
| 31 | - define('SPIP_SQLITE3_BOTH', PDO::FETCH_BOTH); |
|
| 32 | - } |
|
| 28 | + if (!defined('SPIP_SQLITE3_ASSOC')) { |
|
| 29 | + define('SPIP_SQLITE3_ASSOC', PDO::FETCH_ASSOC); |
|
| 30 | + define('SPIP_SQLITE3_NUM', PDO::FETCH_NUM); |
|
| 31 | + define('SPIP_SQLITE3_BOTH', PDO::FETCH_BOTH); |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function spip_versions_sqlite3() { |
| 36 | - return _sqlite_charger_version(3) ? 3 : false; |
|
| 36 | + return _sqlite_charger_version(3) ? 3 : false; |
|
| 37 | 37 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -25,20 +25,20 @@ discard block |
||
| 25 | 25 | * @uses info_copyright() |
| 26 | 26 | **/ |
| 27 | 27 | function install_etape__dist() { |
| 28 | - utiliser_langue_visiteur(); |
|
| 29 | - $menu_langues = menu_langues('var_lang_ecrire'); |
|
| 30 | - if (!$menu_langues) { |
|
| 31 | - redirige_url_ecrire('install', 'etape=chmod'); |
|
| 32 | - } else { |
|
| 33 | - include_spip('inc/presentation'); // pour info_copyright |
|
| 28 | + utiliser_langue_visiteur(); |
|
| 29 | + $menu_langues = menu_langues('var_lang_ecrire'); |
|
| 30 | + if (!$menu_langues) { |
|
| 31 | + redirige_url_ecrire('install', 'etape=chmod'); |
|
| 32 | + } else { |
|
| 33 | + include_spip('inc/presentation'); // pour info_copyright |
|
| 34 | 34 | |
| 35 | - $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 36 | - "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 37 | - '<p>' . _T('install_select_langue') . '</p>' . |
|
| 38 | - '<div>' . $menu_langues . "</div>\n" . |
|
| 39 | - generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 35 | + $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 36 | + "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 37 | + '<p>' . _T('install_select_langue') . '</p>' . |
|
| 38 | + '<div>' . $menu_langues . "</div>\n" . |
|
| 39 | + generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 40 | 40 | |
| 41 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 42 | - echo $minipage->page($res); |
|
| 43 | - } |
|
| 41 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 42 | + echo $minipage->page($res); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | } else { |
| 33 | 33 | include_spip('inc/presentation'); // pour info_copyright |
| 34 | 34 | |
| 35 | - $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 36 | - "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 37 | - '<p>' . _T('install_select_langue') . '</p>' . |
|
| 38 | - '<div>' . $menu_langues . "</div>\n" . |
|
| 39 | - generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 35 | + $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='".chemin_image('logo-spip.png')."' />\n". |
|
| 36 | + "<p class='small'>".info_copyright()."</p></div>\n". |
|
| 37 | + '<p>'._T('install_select_langue').'</p>'. |
|
| 38 | + '<div>'.$menu_langues."</div>\n". |
|
| 39 | + generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />".bouton_suivant()); |
|
| 40 | 40 | |
| 41 | 41 | $minipage = new Spip\Afficher\Minipage\Installation(); |
| 42 | 42 | echo $minipage->page($res); |
@@ -10,168 +10,168 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('base/abstract_sql'); |
| 17 | 17 | |
| 18 | 18 | function install_etape_2_dist() { |
| 19 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 20 | - ? _INSTALL_HOST_DB |
|
| 21 | - : _request('adresse_db'); |
|
| 19 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 20 | + ? _INSTALL_HOST_DB |
|
| 21 | + : _request('adresse_db'); |
|
| 22 | 22 | |
| 23 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 24 | - [, $adresse_db, $port] = $r; |
|
| 25 | - } else { |
|
| 26 | - $port = ''; |
|
| 27 | - } |
|
| 23 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 24 | + [, $adresse_db, $port] = $r; |
|
| 25 | + } else { |
|
| 26 | + $port = ''; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 30 | - ? _INSTALL_USER_DB |
|
| 31 | - : _request('login_db'); |
|
| 29 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 30 | + ? _INSTALL_USER_DB |
|
| 31 | + : _request('login_db'); |
|
| 32 | 32 | |
| 33 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 34 | - ? _INSTALL_PASS_DB |
|
| 35 | - : _request('pass_db'); |
|
| 33 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 34 | + ? _INSTALL_PASS_DB |
|
| 35 | + : _request('pass_db'); |
|
| 36 | 36 | |
| 37 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 38 | - ? _INSTALL_SERVER_DB |
|
| 39 | - : _request('server_db'); |
|
| 37 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 38 | + ? _INSTALL_SERVER_DB |
|
| 39 | + : _request('server_db'); |
|
| 40 | 40 | |
| 41 | - $name_db = defined('_INSTALL_NAME_DB') |
|
| 42 | - ? _INSTALL_NAME_DB |
|
| 43 | - : ''; |
|
| 41 | + $name_db = defined('_INSTALL_NAME_DB') |
|
| 42 | + ? _INSTALL_NAME_DB |
|
| 43 | + : ''; |
|
| 44 | 44 | |
| 45 | - $chmod = _request('chmod'); |
|
| 45 | + $chmod = _request('chmod'); |
|
| 46 | 46 | |
| 47 | - $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 48 | - $GLOBALS['connexions'][$server_db] = $link; |
|
| 47 | + $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 48 | + $GLOBALS['connexions'][$server_db] = $link; |
|
| 49 | 49 | |
| 50 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 51 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 50 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 51 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 52 | 52 | |
| 53 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 54 | - echo $minipage->installDebutPage(); |
|
| 53 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 54 | + echo $minipage->installDebutPage(); |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | // prenons toutes les dispositions possibles pour que rien ne s'affiche ! |
| 58 | 58 | |
| 59 | - /* |
|
| 59 | + /* |
|
| 60 | 60 | * /!\ sqlite3/PDO : erreur sur join(', ', $link) |
| 61 | 61 | * L'objet PDO ne peut pas etre transformee en chaine |
| 62 | 62 | * Un echo $link ne fonctionne pas non plus |
| 63 | 63 | * Il faut utiliser par exemple print_r($link) |
| 64 | 64 | */ |
| 65 | - //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 66 | - $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 67 | - //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 68 | - //echo "\n-->\n"; |
|
| 65 | + //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 66 | + $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 67 | + //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 68 | + //echo "\n-->\n"; |
|
| 69 | 69 | |
| 70 | - if (($db_connect == '0') && $link) { |
|
| 71 | - echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 72 | - echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 70 | + if (($db_connect == '0') && $link) { |
|
| 71 | + echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 72 | + echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 73 | 73 | |
| 74 | - echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 74 | + echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 75 | 75 | |
| 76 | - echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 77 | - [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 76 | + echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 77 | + [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 78 | 78 | |
| 79 | - $hidden = (defined('_SPIP_CHMOD') |
|
| 80 | - ? '' |
|
| 81 | - : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 82 | - . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 79 | + $hidden = (defined('_SPIP_CHMOD') |
|
| 80 | + ? '' |
|
| 81 | + : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 82 | + . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 83 | 83 | |
| 84 | - echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 85 | - } else { |
|
| 86 | - echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 84 | + echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 85 | + } else { |
|
| 86 | + echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 87 | 87 | |
| 88 | - echo "<div class='error'>"; |
|
| 89 | - echo info_etape(_T('info_connexion_base')); |
|
| 90 | - echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 91 | - echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 88 | + echo "<div class='error'>"; |
|
| 89 | + echo info_etape(_T('info_connexion_base')); |
|
| 90 | + echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 91 | + echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 92 | 92 | |
| 93 | - echo "<p style='font-size: small;'>", |
|
| 94 | - _T('avis_connexion_echec_3'), |
|
| 95 | - '</p></div>'; |
|
| 96 | - } |
|
| 93 | + echo "<p style='font-size: small;'>", |
|
| 94 | + _T('avis_connexion_echec_3'), |
|
| 95 | + '</p></div>'; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - echo $minipage->installFinPage(); |
|
| 98 | + echo $minipage->installFinPage(); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Liste les bases accessibles, |
| 102 | 102 | // avec une heuristique pour preselectionner la plus probable |
| 103 | 103 | |
| 104 | 104 | function install_etape_2_bases($login_db, $server_db) { |
| 105 | - $res = install_etape_liste_bases($server_db, $login_db); |
|
| 106 | - if ($res) { |
|
| 107 | - [$checked, $bases] = $res; |
|
| 108 | - |
|
| 109 | - return [ |
|
| 110 | - $checked, |
|
| 111 | - "<label for='choix_db'><b>" |
|
| 112 | - . _T('texte_choix_base_2') |
|
| 113 | - . '</b><br />' |
|
| 114 | - . _T('texte_choix_base_3') |
|
| 115 | - . '</label>' |
|
| 116 | - . "<ul>\n<li>" |
|
| 117 | - . join("</li>\n<li>", $bases) |
|
| 118 | - . "</li>\n</ul><p>" |
|
| 119 | - . _T('info_ou') |
|
| 120 | - . ' ' |
|
| 121 | - ]; |
|
| 122 | - } |
|
| 123 | - $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 105 | + $res = install_etape_liste_bases($server_db, $login_db); |
|
| 106 | + if ($res) { |
|
| 107 | + [$checked, $bases] = $res; |
|
| 108 | + |
|
| 109 | + return [ |
|
| 110 | + $checked, |
|
| 111 | + "<label for='choix_db'><b>" |
|
| 112 | + . _T('texte_choix_base_2') |
|
| 113 | + . '</b><br />' |
|
| 114 | + . _T('texte_choix_base_3') |
|
| 115 | + . '</label>' |
|
| 116 | + . "<ul>\n<li>" |
|
| 117 | + . join("</li>\n<li>", $bases) |
|
| 118 | + . "</li>\n</ul><p>" |
|
| 119 | + . _T('info_ou') |
|
| 120 | + . ' ' |
|
| 121 | + ]; |
|
| 122 | + } |
|
| 123 | + $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 124 | 124 | ' . _T('avis_lecture_noms_bases_2') . '<p>'; |
| 125 | 125 | |
| 126 | - $checked = false; |
|
| 127 | - if ($login_db) { |
|
| 128 | - // Si un login comporte un point, le nom de la base est plus |
|
| 129 | - // probablement le login sans le point -- testons pour savoir |
|
| 130 | - $test_base = $login_db; |
|
| 131 | - $ok = sql_selectdb($test_base, $server_db); |
|
| 132 | - $test_base2 = str_replace('.', '_', $test_base); |
|
| 133 | - if (sql_selectdb($test_base2, $server_db)) { |
|
| 134 | - $test_base = $test_base2; |
|
| 135 | - $ok = true; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ($ok) { |
|
| 139 | - $res .= _T('avis_lecture_noms_bases_3') |
|
| 140 | - . '<ul>' |
|
| 141 | - . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 142 | - . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 143 | - . '</ul>' |
|
| 144 | - . '<p>' . _T('info_ou') . ' '; |
|
| 145 | - $checked = true; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - return [$checked, $res]; |
|
| 126 | + $checked = false; |
|
| 127 | + if ($login_db) { |
|
| 128 | + // Si un login comporte un point, le nom de la base est plus |
|
| 129 | + // probablement le login sans le point -- testons pour savoir |
|
| 130 | + $test_base = $login_db; |
|
| 131 | + $ok = sql_selectdb($test_base, $server_db); |
|
| 132 | + $test_base2 = str_replace('.', '_', $test_base); |
|
| 133 | + if (sql_selectdb($test_base2, $server_db)) { |
|
| 134 | + $test_base = $test_base2; |
|
| 135 | + $ok = true; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ($ok) { |
|
| 139 | + $res .= _T('avis_lecture_noms_bases_3') |
|
| 140 | + . '<ul>' |
|
| 141 | + . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 142 | + . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 143 | + . '</ul>' |
|
| 144 | + . '<p>' . _T('info_ou') . ' '; |
|
| 145 | + $checked = true; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + return [$checked, $res]; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | function install_etape_2_form($hidden, $checked, $res, $etape) { |
| 153 | - return generer_form_ecrire('install', ( |
|
| 154 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 155 | - . $hidden |
|
| 156 | - . (defined('_INSTALL_NAME_DB') |
|
| 157 | - ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 158 | - : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 159 | - . $res |
|
| 160 | - . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 161 | - . ($checked ? '' : " checked='checked'") |
|
| 162 | - . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 163 | - . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 164 | - ) |
|
| 165 | - |
|
| 166 | - . ((defined('_INSTALL_TABLE_PREFIX') |
|
| 167 | - or $GLOBALS['table_prefix'] != 'spip') |
|
| 168 | - ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 169 | - : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 170 | - . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 171 | - . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 172 | - . 'spip' # valeur par defaut |
|
| 173 | - . "' size='20' /></p></fieldset>" |
|
| 174 | - ) |
|
| 175 | - |
|
| 176 | - . bouton_suivant())); |
|
| 153 | + return generer_form_ecrire('install', ( |
|
| 154 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 155 | + . $hidden |
|
| 156 | + . (defined('_INSTALL_NAME_DB') |
|
| 157 | + ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 158 | + : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 159 | + . $res |
|
| 160 | + . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 161 | + . ($checked ? '' : " checked='checked'") |
|
| 162 | + . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 163 | + . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 164 | + ) |
|
| 165 | + |
|
| 166 | + . ((defined('_INSTALL_TABLE_PREFIX') |
|
| 167 | + or $GLOBALS['table_prefix'] != 'spip') |
|
| 168 | + ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 169 | + : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 170 | + . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 171 | + . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 172 | + . 'spip' # valeur par defaut |
|
| 173 | + . "' size='20' /></p></fieldset>" |
|
| 174 | + ) |
|
| 175 | + |
|
| 176 | + . bouton_suivant())); |
|
| 177 | 177 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $GLOBALS['connexions'][$server_db] = $link; |
| 49 | 49 | |
| 50 | 50 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 51 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 51 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 52 | 52 | |
| 53 | 53 | $minipage = new Spip\Afficher\Minipage\Installation(); |
| 54 | 54 | echo $minipage->installDebutPage(); |
@@ -68,18 +68,18 @@ discard block |
||
| 68 | 68 | //echo "\n-->\n"; |
| 69 | 69 | |
| 70 | 70 | if (($db_connect == '0') && $link) { |
| 71 | - echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 71 | + echo "<div class='success'><b>"._T('info_connexion_ok').'</b></div>'; |
|
| 72 | 72 | echo info_progression_etape(2, 'etape_', 'install/'); |
| 73 | 73 | |
| 74 | - echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 74 | + echo info_etape(_T('menu_aide_installation_choix_base').aider('install2', true)); |
|
| 75 | 75 | |
| 76 | 76 | echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
| 77 | 77 | [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
| 78 | 78 | |
| 79 | 79 | $hidden = (defined('_SPIP_CHMOD') |
| 80 | 80 | ? '' |
| 81 | - : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 82 | - . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 81 | + : ("\n<input type='hidden' name='chmod' value='".spip_htmlspecialchars($chmod)."' />")) |
|
| 82 | + . predef_ou_cache($adresse_db.($port ? ':'.$port : ''), $login_db, $pass_db, $server_db); |
|
| 83 | 83 | |
| 84 | 84 | echo install_etape_2_form($hidden, $checked, $res, 3); |
| 85 | 85 | } else { |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | echo "<div class='error'>"; |
| 89 | 89 | echo info_etape(_T('info_connexion_base')); |
| 90 | - echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 91 | - echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 90 | + echo '<h3>'._T('avis_connexion_echec_1').'</h3>'; |
|
| 91 | + echo '<p>'._T('avis_connexion_echec_2').'</p>'; |
|
| 92 | 92 | |
| 93 | 93 | echo "<p style='font-size: small;'>", |
| 94 | 94 | _T('avis_connexion_echec_3'), |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | . ' ' |
| 121 | 121 | ]; |
| 122 | 122 | } |
| 123 | - $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 124 | - ' . _T('avis_lecture_noms_bases_2') . '<p>'; |
|
| 123 | + $res = '<b>'._T('avis_lecture_noms_bases_1').'</b> |
|
| 124 | + ' . _T('avis_lecture_noms_bases_2').'<p>'; |
|
| 125 | 125 | |
| 126 | 126 | $checked = false; |
| 127 | 127 | if ($login_db) { |
@@ -138,10 +138,10 @@ discard block |
||
| 138 | 138 | if ($ok) { |
| 139 | 139 | $res .= _T('avis_lecture_noms_bases_3') |
| 140 | 140 | . '<ul>' |
| 141 | - . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 142 | - . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 141 | + . '<li><input name="choix_db" value="'.$test_base."\" type='radio' id='stand' checked='checked' />" |
|
| 142 | + . "<label for='stand'>".$test_base."</label></li>\n" |
|
| 143 | 143 | . '</ul>' |
| 144 | - . '<p>' . _T('info_ou') . ' '; |
|
| 144 | + . '<p>'._T('info_ou').' '; |
|
| 145 | 145 | $checked = true; |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -154,20 +154,20 @@ discard block |
||
| 154 | 154 | "\n<input type='hidden' name='etape' value='$etape' />" |
| 155 | 155 | . $hidden |
| 156 | 156 | . (defined('_INSTALL_NAME_DB') |
| 157 | - ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 158 | - : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 157 | + ? '<h3>'._T('install_nom_base_hebergeur').' <tt>'._INSTALL_NAME_DB.'</tt>'.'</h3>' |
|
| 158 | + : "\n<fieldset><legend>"._T('texte_choix_base_1')."</legend>\n" |
|
| 159 | 159 | . $res |
| 160 | 160 | . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
| 161 | 161 | . ($checked ? '' : " checked='checked'") |
| 162 | - . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 162 | + . " />\n<label for='nou'>"._T('info_creer_base')."</label></p>\n<p>" |
|
| 163 | 163 | . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
| 164 | 164 | ) |
| 165 | 165 | |
| 166 | 166 | . ((defined('_INSTALL_TABLE_PREFIX') |
| 167 | 167 | or $GLOBALS['table_prefix'] != 'spip') |
| 168 | - ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 169 | - : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 170 | - . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 168 | + ? '<h3>'._T('install_table_prefix_hebergeur').' <tt>'.$GLOBALS['table_prefix'].'</tt>'.'</h3>' |
|
| 169 | + : '<fieldset><legend>'._T('texte_choix_table_prefix')."</legend>\n" |
|
| 170 | + . "<p><label for='table_prefix'>"._T('info_table_prefix').'</label></p><p>' |
|
| 171 | 171 | . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
| 172 | 172 | . 'spip' # valeur par defaut |
| 173 | 173 | . "' size='20' /></p></fieldset>" |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/headers'); |
@@ -19,67 +19,67 @@ discard block |
||
| 19 | 19 | // Mise en place des fichiers de configuration si ce n'est fait |
| 20 | 20 | |
| 21 | 21 | function install_etape_fin_dist() { |
| 22 | - ecrire_acces(); |
|
| 22 | + ecrire_acces(); |
|
| 23 | 23 | |
| 24 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 25 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 26 | - if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 27 | - if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 29 | - } |
|
| 30 | - } |
|
| 31 | - } |
|
| 24 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 25 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 26 | + if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 27 | + if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 34 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 35 | - spip_log("renomme $f"); |
|
| 36 | - if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 37 | - if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 38 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 39 | - } |
|
| 40 | - } |
|
| 41 | - } |
|
| 33 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 34 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 35 | + spip_log("renomme $f"); |
|
| 36 | + if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 37 | + if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 38 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // creer le repertoire cache, qui sert partout ! |
|
| 44 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 45 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 46 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 47 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 48 | - } |
|
| 43 | + // creer le repertoire cache, qui sert partout ! |
|
| 44 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 45 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 46 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 47 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - // Verifier la securite des htaccess |
|
| 51 | - // Si elle ne fonctionne pas, prevenir |
|
| 52 | - $msg = install_verifier_htaccess(); |
|
| 53 | - if ($msg) { |
|
| 54 | - $cible = _T('public:accueil_site'); |
|
| 55 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 56 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 57 | - echo $minipage->page($msg . $cible); |
|
| 58 | - // ok, deboucher dans l'espace prive |
|
| 59 | - } else { |
|
| 60 | - redirige_url_ecrire('accueil'); |
|
| 61 | - } |
|
| 50 | + // Verifier la securite des htaccess |
|
| 51 | + // Si elle ne fonctionne pas, prevenir |
|
| 52 | + $msg = install_verifier_htaccess(); |
|
| 53 | + if ($msg) { |
|
| 54 | + $cible = _T('public:accueil_site'); |
|
| 55 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 56 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 57 | + echo $minipage->page($msg . $cible); |
|
| 58 | + // ok, deboucher dans l'espace prive |
|
| 59 | + } else { |
|
| 60 | + redirige_url_ecrire('accueil'); |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | function install_verifier_htaccess() { |
| 65 | - if ( |
|
| 66 | - verifier_htaccess(_DIR_TMP, true) |
|
| 67 | - and verifier_htaccess(_DIR_CONNECT, true) |
|
| 68 | - and verifier_htaccess(_DIR_VENDOR, true) |
|
| 69 | - ) { |
|
| 70 | - return ''; |
|
| 71 | - } |
|
| 65 | + if ( |
|
| 66 | + verifier_htaccess(_DIR_TMP, true) |
|
| 67 | + and verifier_htaccess(_DIR_CONNECT, true) |
|
| 68 | + and verifier_htaccess(_DIR_VENDOR, true) |
|
| 69 | + ) { |
|
| 70 | + return ''; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - $titre = _T('htaccess_inoperant'); |
|
| 73 | + $titre = _T('htaccess_inoperant'); |
|
| 74 | 74 | |
| 75 | - $averti = _T( |
|
| 76 | - 'htaccess_a_simuler', |
|
| 77 | - [ |
|
| 78 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 79 | - 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 80 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 81 | - ] |
|
| 82 | - ); |
|
| 75 | + $averti = _T( |
|
| 76 | + 'htaccess_a_simuler', |
|
| 77 | + [ |
|
| 78 | + 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 79 | + 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 80 | + 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 81 | + ] |
|
| 82 | + ); |
|
| 83 | 83 | |
| 84 | - return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 84 | + return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 85 | 85 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | // creer le repertoire cache, qui sert partout ! |
| 44 | 44 | // deja fait en etape 4 en principe, on garde au cas ou |
| 45 | 45 | if (!@file_exists(_DIR_CACHE)) { |
| 46 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 46 | + $rep = preg_replace(','._DIR_TMP.',', '', _DIR_CACHE); |
|
| 47 | 47 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $cible = _T('public:accueil_site'); |
| 55 | 55 | $cible = generer_form_ecrire('accueil', '', '', $cible); |
| 56 | 56 | $minipage = new Spip\Afficher\Minipage\Installation(); |
| 57 | - echo $minipage->page($msg . $cible); |
|
| 57 | + echo $minipage->page($msg.$cible); |
|
| 58 | 58 | // ok, deboucher dans l'espace prive |
| 59 | 59 | } else { |
| 60 | 60 | redirige_url_ecrire('accueil'); |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | $averti = _T( |
| 76 | 76 | 'htaccess_a_simuler', |
| 77 | 77 | [ |
| 78 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 78 | + 'htaccess' => '<tt>'._ACCESS_FILE_NAME.'</tt>', |
|
| 79 | 79 | 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
| 80 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 80 | + 'document_root' => '<tt>'.$_SERVER['DOCUMENT_ROOT'].'</tt>' |
|
| 81 | 81 | ] |
| 82 | 82 | ); |
| 83 | 83 | |
@@ -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 | /** |
@@ -34,46 +34,46 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function install_etape_1_dist() { |
| 36 | 36 | |
| 37 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 38 | - echo $minipage->installDebutPage(); |
|
| 37 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 38 | + echo $minipage->installDebutPage(); |
|
| 39 | 39 | |
| 40 | - // stopper en cas de grosse incompatibilite de l'hebergement |
|
| 41 | - tester_compatibilite_hebergement(); |
|
| 40 | + // stopper en cas de grosse incompatibilite de l'hebergement |
|
| 41 | + tester_compatibilite_hebergement(); |
|
| 42 | 42 | |
| 43 | - // Recuperer les anciennes donnees pour plus de facilite (si presentes) |
|
| 44 | - $s = !@is_readable(_FILE_CONNECT_TMP) ? '' |
|
| 45 | - : analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 43 | + // Recuperer les anciennes donnees pour plus de facilite (si presentes) |
|
| 44 | + $s = !@is_readable(_FILE_CONNECT_TMP) ? '' |
|
| 45 | + : analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 46 | 46 | |
| 47 | - [$adresse_db, $login_db] = $s ?: ['localhost', '']; |
|
| 47 | + [$adresse_db, $login_db] = $s ?: ['localhost', '']; |
|
| 48 | 48 | |
| 49 | - $chmod = (isset($_GET['chmod']) and preg_match(',^[0-9]+$,', $_GET['chmod'])) ? |
|
| 50 | - sprintf('%04o', $_GET['chmod']) : '0777'; |
|
| 49 | + $chmod = (isset($_GET['chmod']) and preg_match(',^[0-9]+$,', $_GET['chmod'])) ? |
|
| 50 | + sprintf('%04o', $_GET['chmod']) : '0777'; |
|
| 51 | 51 | |
| 52 | - if (@is_readable(_FILE_CHMOD_TMP)) { |
|
| 53 | - $s = @join('', @file(_FILE_CHMOD_TMP)); |
|
| 54 | - if (preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { |
|
| 55 | - $chmod = $regs[1]; |
|
| 56 | - } |
|
| 57 | - } |
|
| 52 | + if (@is_readable(_FILE_CHMOD_TMP)) { |
|
| 53 | + $s = @join('', @file(_FILE_CHMOD_TMP)); |
|
| 54 | + if (preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { |
|
| 55 | + $chmod = $regs[1]; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - $db = [$adresse_db, _T('entree_base_donnee_2')]; |
|
| 61 | - $login = [$login_db, _T('entree_login_connexion_2')]; |
|
| 62 | - $pass = ['', _T('entree_mot_passe_2')]; |
|
| 60 | + $db = [$adresse_db, _T('entree_base_donnee_2')]; |
|
| 61 | + $login = [$login_db, _T('entree_login_connexion_2')]; |
|
| 62 | + $pass = ['', _T('entree_mot_passe_2')]; |
|
| 63 | 63 | |
| 64 | - $predef = [ |
|
| 65 | - defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : '', |
|
| 66 | - defined('_INSTALL_HOST_DB'), |
|
| 67 | - defined('_INSTALL_USER_DB'), |
|
| 68 | - defined('_INSTALL_PASS_DB') |
|
| 69 | - ]; |
|
| 64 | + $predef = [ |
|
| 65 | + defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : '', |
|
| 66 | + defined('_INSTALL_HOST_DB'), |
|
| 67 | + defined('_INSTALL_USER_DB'), |
|
| 68 | + defined('_INSTALL_PASS_DB') |
|
| 69 | + ]; |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | - echo info_progression_etape(1, 'etape_', 'install/'); |
|
| 72 | + echo info_progression_etape(1, 'etape_', 'install/'); |
|
| 73 | 73 | |
| 74 | - // ces deux chaines de langues doivent etre reecrites |
|
| 74 | + // ces deux chaines de langues doivent etre reecrites |
|
| 75 | 75 | # echo info_etape(_T('info_connexion_mysql'), _T('texte_connexion_mysql').aide ("install1", true)); |
| 76 | - echo info_etape(_T('info_connexion_base_donnee')); |
|
| 77 | - echo install_connexion_form($db, $login, $pass, $predef, "\n<input type='hidden' name='chmod' value='$chmod' />", 2); |
|
| 78 | - echo $minipage->installFinPage(); |
|
| 76 | + echo info_etape(_T('info_connexion_base_donnee')); |
|
| 77 | + echo install_connexion_form($db, $login, $pass, $predef, "\n<input type='hidden' name='chmod' value='$chmod' />", 2); |
|
| 78 | + echo $minipage->installFinPage(); |
|
| 79 | 79 | } |