@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!defined('_DATA_SOURCE_MAX_SIZE')) { |
| 24 | - define('_DATA_SOURCE_MAX_SIZE', 2 * 1048576); |
|
| 24 | + define('_DATA_SOURCE_MAX_SIZE', 2 * 1048576); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | |
@@ -42,17 +42,17 @@ discard block |
||
| 42 | 42 | * Description de la boucle complétée des champs |
| 43 | 43 | */ |
| 44 | 44 | function iterateur_DATA_dist($b) { |
| 45 | - $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 46 | - $b->show = [ |
|
| 47 | - 'field' => [ |
|
| 48 | - 'cle' => 'STRING', |
|
| 49 | - 'valeur' => 'STRING', |
|
| 50 | - '*' => 'ALL' // Champ joker * |
|
| 51 | - ] |
|
| 52 | - ]; |
|
| 53 | - $b->select[] = '.valeur'; |
|
| 54 | - |
|
| 55 | - return $b; |
|
| 45 | + $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 46 | + $b->show = [ |
|
| 47 | + 'field' => [ |
|
| 48 | + 'cle' => 'STRING', |
|
| 49 | + 'valeur' => 'STRING', |
|
| 50 | + '*' => 'ALL' // Champ joker * |
|
| 51 | + ] |
|
| 52 | + ]; |
|
| 53 | + $b->select[] = '.valeur'; |
|
| 54 | + |
|
| 55 | + return $b; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
@@ -62,522 +62,522 @@ discard block |
||
| 62 | 62 | * Pour itérer sur des données quelconques (transformables en tableau) |
| 63 | 63 | */ |
| 64 | 64 | class IterateurDATA implements Iterator { |
| 65 | - /** |
|
| 66 | - * tableau de donnees |
|
| 67 | - * |
|
| 68 | - * @var array |
|
| 69 | - */ |
|
| 70 | - protected $tableau = []; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Conditions de filtrage |
|
| 74 | - * ie criteres de selection |
|
| 75 | - * |
|
| 76 | - * @var array |
|
| 77 | - */ |
|
| 78 | - protected $filtre = []; |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Cle courante |
|
| 83 | - * |
|
| 84 | - * @var null |
|
| 85 | - */ |
|
| 86 | - protected $cle = null; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Valeur courante |
|
| 90 | - * |
|
| 91 | - * @var null |
|
| 92 | - */ |
|
| 93 | - protected $valeur = null; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Erreur presente ? |
|
| 97 | - * |
|
| 98 | - * @var bool |
|
| 99 | - **/ |
|
| 100 | - public $err = false; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Calcul du total des elements |
|
| 104 | - * |
|
| 105 | - * @var int|null |
|
| 106 | - **/ |
|
| 107 | - public $total = null; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Constructeur |
|
| 111 | - * |
|
| 112 | - * @param $command |
|
| 113 | - * @param array $info |
|
| 114 | - */ |
|
| 115 | - public function __construct($command, $info = []) { |
|
| 116 | - $this->type = 'DATA'; |
|
| 117 | - $this->command = $command; |
|
| 118 | - $this->info = $info; |
|
| 119 | - |
|
| 120 | - $this->select($command); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Revenir au depart |
|
| 125 | - * |
|
| 126 | - * @return void |
|
| 127 | - */ |
|
| 128 | - public function rewind() { |
|
| 129 | - reset($this->tableau); |
|
| 130 | - $this->cle = key($this->tableau); |
|
| 131 | - $this->valeur = current($this->tableau); |
|
| 132 | - next($this->tableau); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Déclarer les critères exceptions |
|
| 137 | - * |
|
| 138 | - * @return array |
|
| 139 | - */ |
|
| 140 | - public function exception_des_criteres() { |
|
| 141 | - return ['tableau']; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Récupérer depuis le cache si possible |
|
| 146 | - * |
|
| 147 | - * @param string $cle |
|
| 148 | - * @return mixed |
|
| 149 | - */ |
|
| 150 | - protected function cache_get($cle) { |
|
| 151 | - if (!$cle) { |
|
| 152 | - return; |
|
| 153 | - } |
|
| 154 | - # utiliser memoization si dispo |
|
| 155 | - if (!function_exists('cache_get')) { |
|
| 156 | - return; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - return cache_get($cle); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * Stocker en cache si possible |
|
| 164 | - * |
|
| 165 | - * @param string $cle |
|
| 166 | - * @param int $ttl |
|
| 167 | - * @param null|mixed $valeur |
|
| 168 | - * @return bool |
|
| 169 | - */ |
|
| 170 | - protected function cache_set($cle, $ttl, $valeur = null) { |
|
| 171 | - if (!$cle) { |
|
| 172 | - return; |
|
| 173 | - } |
|
| 174 | - if (is_null($valeur)) { |
|
| 175 | - $valeur = $this->tableau; |
|
| 176 | - } |
|
| 177 | - # utiliser memoization si dispo |
|
| 178 | - if (!function_exists('cache_set')) { |
|
| 179 | - return; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - return cache_set( |
|
| 183 | - $cle, |
|
| 184 | - [ |
|
| 185 | - 'data' => $valeur, |
|
| 186 | - 'time' => time(), |
|
| 187 | - 'ttl' => $ttl |
|
| 188 | - ], |
|
| 189 | - 3600 + $ttl |
|
| 190 | - ); |
|
| 191 | - # conserver le cache 1h de plus que la validite demandee, |
|
| 192 | - # pour le cas ou le serveur distant ne reponde plus |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Aller chercher les données de la boucle DATA |
|
| 197 | - * |
|
| 198 | - * @throws Exception |
|
| 199 | - * @param array $command |
|
| 200 | - * @return void |
|
| 201 | - */ |
|
| 202 | - protected function select($command) { |
|
| 203 | - |
|
| 204 | - // l'iterateur DATA peut etre appele en passant (data:type) |
|
| 205 | - // le type se retrouve dans la commande 'from' |
|
| 206 | - // dans ce cas la le critere {source}, si present, n'a pas besoin du 1er argument |
|
| 207 | - if (isset($this->command['from'][0])) { |
|
| 208 | - if (isset($this->command['source']) and is_array($this->command['source'])) { |
|
| 209 | - array_unshift($this->command['source'], $this->command['sourcemode']); |
|
| 210 | - } |
|
| 211 | - $this->command['sourcemode'] = $this->command['from'][0]; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - // cherchons differents moyens de creer le tableau de donnees |
|
| 215 | - // les commandes connues pour l'iterateur DATA |
|
| 216 | - // sont : {tableau #ARRAY} ; {cle=...} ; {valeur=...} |
|
| 217 | - |
|
| 218 | - // {source format, [URL], [arg2]...} |
|
| 219 | - if ( |
|
| 220 | - isset($this->command['source']) |
|
| 221 | - and isset($this->command['sourcemode']) |
|
| 222 | - ) { |
|
| 223 | - $this->select_source(); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - // Critere {liste X1, X2, X3} |
|
| 227 | - if (isset($this->command['liste'])) { |
|
| 228 | - $this->select_liste(); |
|
| 229 | - } |
|
| 230 | - if (isset($this->command['enum'])) { |
|
| 231 | - $this->select_enum(); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - // Si a ce stade on n'a pas de table, il y a un bug |
|
| 235 | - if (!is_array($this->tableau)) { |
|
| 236 | - $this->err = true; |
|
| 237 | - spip_log('erreur datasource ' . var_export($command, true)); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // {datapath query.results} |
|
| 241 | - // extraire le chemin "query.results" du tableau de donnees |
|
| 242 | - if ( |
|
| 243 | - !$this->err |
|
| 244 | - and isset($this->command['datapath']) |
|
| 245 | - and is_array($this->command['datapath']) |
|
| 246 | - ) { |
|
| 247 | - $this->select_datapath(); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - // tri {par x} |
|
| 251 | - if ($this->command['orderby']) { |
|
| 252 | - $this->select_orderby(); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - // grouper les resultats {fusion /x/y/z} ; |
|
| 256 | - if ($this->command['groupby']) { |
|
| 257 | - $this->select_groupby(); |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - $this->rewind(); |
|
| 261 | - #var_dump($this->tableau); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * Aller chercher les donnees de la boucle DATA |
|
| 267 | - * depuis une source |
|
| 268 | - * {source format, [URL], [arg2]...} |
|
| 269 | - */ |
|
| 270 | - protected function select_source() { |
|
| 271 | - # un peu crado : avant de charger le cache il faut charger |
|
| 272 | - # les class indispensables, sinon PHP ne saura pas gerer |
|
| 273 | - # l'objet en cache ; cf plugins/icalendar |
|
| 274 | - # perf : pas de fonction table_to_array ! (table est deja un array) |
|
| 275 | - if ( |
|
| 276 | - isset($this->command['sourcemode']) |
|
| 277 | - and !in_array($this->command['sourcemode'], ['table', 'array', 'tableau']) |
|
| 278 | - ) { |
|
| 279 | - charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - # le premier argument peut etre un array, une URL etc. |
|
| 283 | - $src = $this->command['source'][0]; |
|
| 284 | - |
|
| 285 | - # avons-nous un cache dispo ? |
|
| 286 | - $cle = null; |
|
| 287 | - if (is_string($src)) { |
|
| 288 | - $cle = 'datasource_' . md5($this->command['sourcemode'] . ':' . var_export($this->command['source'], true)); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - $cache = $this->cache_get($cle); |
|
| 292 | - if (isset($this->command['datacache'])) { |
|
| 293 | - $ttl = intval($this->command['datacache']); |
|
| 294 | - } |
|
| 295 | - if ( |
|
| 296 | - $cache |
|
| 297 | - and ($cache['time'] + (isset($ttl) ? $ttl : $cache['ttl']) |
|
| 298 | - > time()) |
|
| 299 | - and !(_request('var_mode') === 'recalcul' |
|
| 300 | - and include_spip('inc/autoriser') |
|
| 301 | - and autoriser('recalcul') |
|
| 302 | - ) |
|
| 303 | - ) { |
|
| 304 | - $this->tableau = $cache['data']; |
|
| 305 | - } else { |
|
| 306 | - try { |
|
| 307 | - if ( |
|
| 308 | - isset($this->command['sourcemode']) |
|
| 309 | - and in_array( |
|
| 310 | - $this->command['sourcemode'], |
|
| 311 | - ['table', 'array', 'tableau'] |
|
| 312 | - ) |
|
| 313 | - ) { |
|
| 314 | - if ( |
|
| 315 | - is_array($a = $src) |
|
| 316 | - or (is_string($a) |
|
| 317 | - and $a = str_replace('"', '"', $a) # fragile! |
|
| 318 | - and is_array($a = @unserialize($a))) |
|
| 319 | - ) { |
|
| 320 | - $this->tableau = $a; |
|
| 321 | - } |
|
| 322 | - } else { |
|
| 323 | - $data = $src; |
|
| 324 | - if (is_string($src)) { |
|
| 325 | - if (tester_url_absolue($src)) { |
|
| 326 | - include_spip('inc/distant'); |
|
| 327 | - $data = recuperer_url($src, ['taille_max' => _DATA_SOURCE_MAX_SIZE]); |
|
| 328 | - $data = $data['page'] ?? ''; |
|
| 329 | - if (!$data) { |
|
| 330 | - throw new Exception('404'); |
|
| 331 | - } |
|
| 332 | - if (!isset($ttl)) { |
|
| 333 | - $ttl = 24 * 3600; |
|
| 334 | - } |
|
| 335 | - } elseif (@is_dir($src)) { |
|
| 336 | - $data = $src; |
|
| 337 | - } elseif (@is_readable($src) && @is_file($src)) { |
|
| 338 | - $data = spip_file_get_contents($src); |
|
| 339 | - } |
|
| 340 | - if (!isset($ttl)) { |
|
| 341 | - $ttl = 10; |
|
| 342 | - } |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - if ( |
|
| 346 | - !$this->err |
|
| 347 | - and $data_to_array = charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true) |
|
| 348 | - ) { |
|
| 349 | - $args = $this->command['source']; |
|
| 350 | - $args[0] = $data; |
|
| 351 | - if (is_array($a = $data_to_array(...$args))) { |
|
| 352 | - $this->tableau = $a; |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - if (!is_array($this->tableau)) { |
|
| 358 | - $this->err = true; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - if (!$this->err and isset($ttl) and $ttl > 0) { |
|
| 362 | - $this->cache_set($cle, $ttl); |
|
| 363 | - } |
|
| 364 | - } catch (Exception $e) { |
|
| 365 | - $e = $e->getMessage(); |
|
| 366 | - $err = sprintf( |
|
| 367 | - "[%s, %s] $e", |
|
| 368 | - $src, |
|
| 369 | - $this->command['sourcemode'] |
|
| 370 | - ); |
|
| 371 | - erreur_squelette([$err, []]); |
|
| 372 | - $this->err = true; |
|
| 373 | - } |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - # en cas d'erreur, utiliser le cache si encore dispo |
|
| 377 | - if ( |
|
| 378 | - $this->err |
|
| 379 | - and $cache |
|
| 380 | - ) { |
|
| 381 | - $this->tableau = $cache['data']; |
|
| 382 | - $this->err = false; |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * Retourne un tableau donne depuis un critère liste |
|
| 389 | - * |
|
| 390 | - * Critère `{liste X1, X2, X3}` |
|
| 391 | - * |
|
| 392 | - * @see critere_DATA_liste_dist() |
|
| 393 | - * |
|
| 394 | - **/ |
|
| 395 | - protected function select_liste() { |
|
| 396 | - # s'il n'y a qu'une valeur dans la liste, sans doute une #BALISE |
|
| 397 | - if (!isset($this->command['liste'][1])) { |
|
| 398 | - if (!is_array($this->command['liste'][0])) { |
|
| 399 | - $this->command['liste'] = explode(',', $this->command['liste'][0]); |
|
| 400 | - } else { |
|
| 401 | - $this->command['liste'] = $this->command['liste'][0]; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - $this->tableau = $this->command['liste']; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * Retourne un tableau donne depuis un critere liste |
|
| 409 | - * Critere {enum Xmin, Xmax} |
|
| 410 | - * |
|
| 411 | - **/ |
|
| 412 | - protected function select_enum() { |
|
| 413 | - # s'il n'y a qu'une valeur dans la liste, sans doute une #BALISE |
|
| 414 | - if (!isset($this->command['enum'][1])) { |
|
| 415 | - if (!is_array($this->command['enum'][0])) { |
|
| 416 | - $this->command['enum'] = explode(',', $this->command['enum'][0]); |
|
| 417 | - } else { |
|
| 418 | - $this->command['enum'] = $this->command['enum'][0]; |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - if (count($this->command['enum']) >= 3) { |
|
| 422 | - $enum = range( |
|
| 423 | - array_shift($this->command['enum']), |
|
| 424 | - array_shift($this->command['enum']), |
|
| 425 | - array_shift($this->command['enum']) |
|
| 426 | - ); |
|
| 427 | - } else { |
|
| 428 | - $enum = range(array_shift($this->command['enum']), array_shift($this->command['enum'])); |
|
| 429 | - } |
|
| 430 | - $this->tableau = $enum; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * extraire le chemin "query.results" du tableau de donnees |
|
| 436 | - * {datapath query.results} |
|
| 437 | - * |
|
| 438 | - **/ |
|
| 439 | - protected function select_datapath() { |
|
| 440 | - $base = reset($this->command['datapath']); |
|
| 441 | - if (strlen($base = ltrim(trim($base), '/'))) { |
|
| 442 | - $this->tableau = table_valeur($this->tableau, $base); |
|
| 443 | - if (!is_array($this->tableau)) { |
|
| 444 | - $this->tableau = []; |
|
| 445 | - $this->err = true; |
|
| 446 | - spip_log("datapath '$base' absent"); |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - /** |
|
| 452 | - * Ordonner les resultats |
|
| 453 | - * {par x} |
|
| 454 | - * |
|
| 455 | - **/ |
|
| 456 | - protected function select_orderby() { |
|
| 457 | - $sortfunc = ''; |
|
| 458 | - $aleas = 0; |
|
| 459 | - foreach ($this->command['orderby'] as $tri) { |
|
| 460 | - // virer le / initial pour les criteres de la forme {par /xx} |
|
| 461 | - if (preg_match(',^\.?([/\w]+)( DESC)?$,iS', ltrim($tri, '/'), $r)) { |
|
| 462 | - $r = array_pad($r, 3, null); |
|
| 463 | - |
|
| 464 | - // tri par cle |
|
| 465 | - if ($r[1] == 'cle') { |
|
| 466 | - if (isset($r[2]) and $r[2]) { |
|
| 467 | - krsort($this->tableau); |
|
| 468 | - } else { |
|
| 469 | - ksort($this->tableau); |
|
| 470 | - } |
|
| 471 | - } # {par hasard} |
|
| 472 | - else { |
|
| 473 | - if ($r[1] == 'hasard') { |
|
| 474 | - $k = array_keys($this->tableau); |
|
| 475 | - shuffle($k); |
|
| 476 | - $v = []; |
|
| 477 | - foreach ($k as $cle) { |
|
| 478 | - $v[$cle] = $this->tableau[$cle]; |
|
| 479 | - } |
|
| 480 | - $this->tableau = $v; |
|
| 481 | - } else { |
|
| 482 | - # {par valeur} |
|
| 483 | - if ($r[1] == 'valeur') { |
|
| 484 | - $tv = '%s'; |
|
| 485 | - } # {par valeur/xx/yy} ?? |
|
| 486 | - else { |
|
| 487 | - $tv = 'table_valeur(%s, ' . var_export($r[1], true) . ')'; |
|
| 488 | - } |
|
| 489 | - $sortfunc .= ' |
|
| 65 | + /** |
|
| 66 | + * tableau de donnees |
|
| 67 | + * |
|
| 68 | + * @var array |
|
| 69 | + */ |
|
| 70 | + protected $tableau = []; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Conditions de filtrage |
|
| 74 | + * ie criteres de selection |
|
| 75 | + * |
|
| 76 | + * @var array |
|
| 77 | + */ |
|
| 78 | + protected $filtre = []; |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Cle courante |
|
| 83 | + * |
|
| 84 | + * @var null |
|
| 85 | + */ |
|
| 86 | + protected $cle = null; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Valeur courante |
|
| 90 | + * |
|
| 91 | + * @var null |
|
| 92 | + */ |
|
| 93 | + protected $valeur = null; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Erreur presente ? |
|
| 97 | + * |
|
| 98 | + * @var bool |
|
| 99 | + **/ |
|
| 100 | + public $err = false; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Calcul du total des elements |
|
| 104 | + * |
|
| 105 | + * @var int|null |
|
| 106 | + **/ |
|
| 107 | + public $total = null; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Constructeur |
|
| 111 | + * |
|
| 112 | + * @param $command |
|
| 113 | + * @param array $info |
|
| 114 | + */ |
|
| 115 | + public function __construct($command, $info = []) { |
|
| 116 | + $this->type = 'DATA'; |
|
| 117 | + $this->command = $command; |
|
| 118 | + $this->info = $info; |
|
| 119 | + |
|
| 120 | + $this->select($command); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Revenir au depart |
|
| 125 | + * |
|
| 126 | + * @return void |
|
| 127 | + */ |
|
| 128 | + public function rewind() { |
|
| 129 | + reset($this->tableau); |
|
| 130 | + $this->cle = key($this->tableau); |
|
| 131 | + $this->valeur = current($this->tableau); |
|
| 132 | + next($this->tableau); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Déclarer les critères exceptions |
|
| 137 | + * |
|
| 138 | + * @return array |
|
| 139 | + */ |
|
| 140 | + public function exception_des_criteres() { |
|
| 141 | + return ['tableau']; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Récupérer depuis le cache si possible |
|
| 146 | + * |
|
| 147 | + * @param string $cle |
|
| 148 | + * @return mixed |
|
| 149 | + */ |
|
| 150 | + protected function cache_get($cle) { |
|
| 151 | + if (!$cle) { |
|
| 152 | + return; |
|
| 153 | + } |
|
| 154 | + # utiliser memoization si dispo |
|
| 155 | + if (!function_exists('cache_get')) { |
|
| 156 | + return; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + return cache_get($cle); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Stocker en cache si possible |
|
| 164 | + * |
|
| 165 | + * @param string $cle |
|
| 166 | + * @param int $ttl |
|
| 167 | + * @param null|mixed $valeur |
|
| 168 | + * @return bool |
|
| 169 | + */ |
|
| 170 | + protected function cache_set($cle, $ttl, $valeur = null) { |
|
| 171 | + if (!$cle) { |
|
| 172 | + return; |
|
| 173 | + } |
|
| 174 | + if (is_null($valeur)) { |
|
| 175 | + $valeur = $this->tableau; |
|
| 176 | + } |
|
| 177 | + # utiliser memoization si dispo |
|
| 178 | + if (!function_exists('cache_set')) { |
|
| 179 | + return; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + return cache_set( |
|
| 183 | + $cle, |
|
| 184 | + [ |
|
| 185 | + 'data' => $valeur, |
|
| 186 | + 'time' => time(), |
|
| 187 | + 'ttl' => $ttl |
|
| 188 | + ], |
|
| 189 | + 3600 + $ttl |
|
| 190 | + ); |
|
| 191 | + # conserver le cache 1h de plus que la validite demandee, |
|
| 192 | + # pour le cas ou le serveur distant ne reponde plus |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Aller chercher les données de la boucle DATA |
|
| 197 | + * |
|
| 198 | + * @throws Exception |
|
| 199 | + * @param array $command |
|
| 200 | + * @return void |
|
| 201 | + */ |
|
| 202 | + protected function select($command) { |
|
| 203 | + |
|
| 204 | + // l'iterateur DATA peut etre appele en passant (data:type) |
|
| 205 | + // le type se retrouve dans la commande 'from' |
|
| 206 | + // dans ce cas la le critere {source}, si present, n'a pas besoin du 1er argument |
|
| 207 | + if (isset($this->command['from'][0])) { |
|
| 208 | + if (isset($this->command['source']) and is_array($this->command['source'])) { |
|
| 209 | + array_unshift($this->command['source'], $this->command['sourcemode']); |
|
| 210 | + } |
|
| 211 | + $this->command['sourcemode'] = $this->command['from'][0]; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + // cherchons differents moyens de creer le tableau de donnees |
|
| 215 | + // les commandes connues pour l'iterateur DATA |
|
| 216 | + // sont : {tableau #ARRAY} ; {cle=...} ; {valeur=...} |
|
| 217 | + |
|
| 218 | + // {source format, [URL], [arg2]...} |
|
| 219 | + if ( |
|
| 220 | + isset($this->command['source']) |
|
| 221 | + and isset($this->command['sourcemode']) |
|
| 222 | + ) { |
|
| 223 | + $this->select_source(); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + // Critere {liste X1, X2, X3} |
|
| 227 | + if (isset($this->command['liste'])) { |
|
| 228 | + $this->select_liste(); |
|
| 229 | + } |
|
| 230 | + if (isset($this->command['enum'])) { |
|
| 231 | + $this->select_enum(); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + // Si a ce stade on n'a pas de table, il y a un bug |
|
| 235 | + if (!is_array($this->tableau)) { |
|
| 236 | + $this->err = true; |
|
| 237 | + spip_log('erreur datasource ' . var_export($command, true)); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // {datapath query.results} |
|
| 241 | + // extraire le chemin "query.results" du tableau de donnees |
|
| 242 | + if ( |
|
| 243 | + !$this->err |
|
| 244 | + and isset($this->command['datapath']) |
|
| 245 | + and is_array($this->command['datapath']) |
|
| 246 | + ) { |
|
| 247 | + $this->select_datapath(); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + // tri {par x} |
|
| 251 | + if ($this->command['orderby']) { |
|
| 252 | + $this->select_orderby(); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + // grouper les resultats {fusion /x/y/z} ; |
|
| 256 | + if ($this->command['groupby']) { |
|
| 257 | + $this->select_groupby(); |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + $this->rewind(); |
|
| 261 | + #var_dump($this->tableau); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Aller chercher les donnees de la boucle DATA |
|
| 267 | + * depuis une source |
|
| 268 | + * {source format, [URL], [arg2]...} |
|
| 269 | + */ |
|
| 270 | + protected function select_source() { |
|
| 271 | + # un peu crado : avant de charger le cache il faut charger |
|
| 272 | + # les class indispensables, sinon PHP ne saura pas gerer |
|
| 273 | + # l'objet en cache ; cf plugins/icalendar |
|
| 274 | + # perf : pas de fonction table_to_array ! (table est deja un array) |
|
| 275 | + if ( |
|
| 276 | + isset($this->command['sourcemode']) |
|
| 277 | + and !in_array($this->command['sourcemode'], ['table', 'array', 'tableau']) |
|
| 278 | + ) { |
|
| 279 | + charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + # le premier argument peut etre un array, une URL etc. |
|
| 283 | + $src = $this->command['source'][0]; |
|
| 284 | + |
|
| 285 | + # avons-nous un cache dispo ? |
|
| 286 | + $cle = null; |
|
| 287 | + if (is_string($src)) { |
|
| 288 | + $cle = 'datasource_' . md5($this->command['sourcemode'] . ':' . var_export($this->command['source'], true)); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + $cache = $this->cache_get($cle); |
|
| 292 | + if (isset($this->command['datacache'])) { |
|
| 293 | + $ttl = intval($this->command['datacache']); |
|
| 294 | + } |
|
| 295 | + if ( |
|
| 296 | + $cache |
|
| 297 | + and ($cache['time'] + (isset($ttl) ? $ttl : $cache['ttl']) |
|
| 298 | + > time()) |
|
| 299 | + and !(_request('var_mode') === 'recalcul' |
|
| 300 | + and include_spip('inc/autoriser') |
|
| 301 | + and autoriser('recalcul') |
|
| 302 | + ) |
|
| 303 | + ) { |
|
| 304 | + $this->tableau = $cache['data']; |
|
| 305 | + } else { |
|
| 306 | + try { |
|
| 307 | + if ( |
|
| 308 | + isset($this->command['sourcemode']) |
|
| 309 | + and in_array( |
|
| 310 | + $this->command['sourcemode'], |
|
| 311 | + ['table', 'array', 'tableau'] |
|
| 312 | + ) |
|
| 313 | + ) { |
|
| 314 | + if ( |
|
| 315 | + is_array($a = $src) |
|
| 316 | + or (is_string($a) |
|
| 317 | + and $a = str_replace('"', '"', $a) # fragile! |
|
| 318 | + and is_array($a = @unserialize($a))) |
|
| 319 | + ) { |
|
| 320 | + $this->tableau = $a; |
|
| 321 | + } |
|
| 322 | + } else { |
|
| 323 | + $data = $src; |
|
| 324 | + if (is_string($src)) { |
|
| 325 | + if (tester_url_absolue($src)) { |
|
| 326 | + include_spip('inc/distant'); |
|
| 327 | + $data = recuperer_url($src, ['taille_max' => _DATA_SOURCE_MAX_SIZE]); |
|
| 328 | + $data = $data['page'] ?? ''; |
|
| 329 | + if (!$data) { |
|
| 330 | + throw new Exception('404'); |
|
| 331 | + } |
|
| 332 | + if (!isset($ttl)) { |
|
| 333 | + $ttl = 24 * 3600; |
|
| 334 | + } |
|
| 335 | + } elseif (@is_dir($src)) { |
|
| 336 | + $data = $src; |
|
| 337 | + } elseif (@is_readable($src) && @is_file($src)) { |
|
| 338 | + $data = spip_file_get_contents($src); |
|
| 339 | + } |
|
| 340 | + if (!isset($ttl)) { |
|
| 341 | + $ttl = 10; |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + if ( |
|
| 346 | + !$this->err |
|
| 347 | + and $data_to_array = charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true) |
|
| 348 | + ) { |
|
| 349 | + $args = $this->command['source']; |
|
| 350 | + $args[0] = $data; |
|
| 351 | + if (is_array($a = $data_to_array(...$args))) { |
|
| 352 | + $this->tableau = $a; |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + if (!is_array($this->tableau)) { |
|
| 358 | + $this->err = true; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + if (!$this->err and isset($ttl) and $ttl > 0) { |
|
| 362 | + $this->cache_set($cle, $ttl); |
|
| 363 | + } |
|
| 364 | + } catch (Exception $e) { |
|
| 365 | + $e = $e->getMessage(); |
|
| 366 | + $err = sprintf( |
|
| 367 | + "[%s, %s] $e", |
|
| 368 | + $src, |
|
| 369 | + $this->command['sourcemode'] |
|
| 370 | + ); |
|
| 371 | + erreur_squelette([$err, []]); |
|
| 372 | + $this->err = true; |
|
| 373 | + } |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + # en cas d'erreur, utiliser le cache si encore dispo |
|
| 377 | + if ( |
|
| 378 | + $this->err |
|
| 379 | + and $cache |
|
| 380 | + ) { |
|
| 381 | + $this->tableau = $cache['data']; |
|
| 382 | + $this->err = false; |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * Retourne un tableau donne depuis un critère liste |
|
| 389 | + * |
|
| 390 | + * Critère `{liste X1, X2, X3}` |
|
| 391 | + * |
|
| 392 | + * @see critere_DATA_liste_dist() |
|
| 393 | + * |
|
| 394 | + **/ |
|
| 395 | + protected function select_liste() { |
|
| 396 | + # s'il n'y a qu'une valeur dans la liste, sans doute une #BALISE |
|
| 397 | + if (!isset($this->command['liste'][1])) { |
|
| 398 | + if (!is_array($this->command['liste'][0])) { |
|
| 399 | + $this->command['liste'] = explode(',', $this->command['liste'][0]); |
|
| 400 | + } else { |
|
| 401 | + $this->command['liste'] = $this->command['liste'][0]; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + $this->tableau = $this->command['liste']; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * Retourne un tableau donne depuis un critere liste |
|
| 409 | + * Critere {enum Xmin, Xmax} |
|
| 410 | + * |
|
| 411 | + **/ |
|
| 412 | + protected function select_enum() { |
|
| 413 | + # s'il n'y a qu'une valeur dans la liste, sans doute une #BALISE |
|
| 414 | + if (!isset($this->command['enum'][1])) { |
|
| 415 | + if (!is_array($this->command['enum'][0])) { |
|
| 416 | + $this->command['enum'] = explode(',', $this->command['enum'][0]); |
|
| 417 | + } else { |
|
| 418 | + $this->command['enum'] = $this->command['enum'][0]; |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + if (count($this->command['enum']) >= 3) { |
|
| 422 | + $enum = range( |
|
| 423 | + array_shift($this->command['enum']), |
|
| 424 | + array_shift($this->command['enum']), |
|
| 425 | + array_shift($this->command['enum']) |
|
| 426 | + ); |
|
| 427 | + } else { |
|
| 428 | + $enum = range(array_shift($this->command['enum']), array_shift($this->command['enum'])); |
|
| 429 | + } |
|
| 430 | + $this->tableau = $enum; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * extraire le chemin "query.results" du tableau de donnees |
|
| 436 | + * {datapath query.results} |
|
| 437 | + * |
|
| 438 | + **/ |
|
| 439 | + protected function select_datapath() { |
|
| 440 | + $base = reset($this->command['datapath']); |
|
| 441 | + if (strlen($base = ltrim(trim($base), '/'))) { |
|
| 442 | + $this->tableau = table_valeur($this->tableau, $base); |
|
| 443 | + if (!is_array($this->tableau)) { |
|
| 444 | + $this->tableau = []; |
|
| 445 | + $this->err = true; |
|
| 446 | + spip_log("datapath '$base' absent"); |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + /** |
|
| 452 | + * Ordonner les resultats |
|
| 453 | + * {par x} |
|
| 454 | + * |
|
| 455 | + **/ |
|
| 456 | + protected function select_orderby() { |
|
| 457 | + $sortfunc = ''; |
|
| 458 | + $aleas = 0; |
|
| 459 | + foreach ($this->command['orderby'] as $tri) { |
|
| 460 | + // virer le / initial pour les criteres de la forme {par /xx} |
|
| 461 | + if (preg_match(',^\.?([/\w]+)( DESC)?$,iS', ltrim($tri, '/'), $r)) { |
|
| 462 | + $r = array_pad($r, 3, null); |
|
| 463 | + |
|
| 464 | + // tri par cle |
|
| 465 | + if ($r[1] == 'cle') { |
|
| 466 | + if (isset($r[2]) and $r[2]) { |
|
| 467 | + krsort($this->tableau); |
|
| 468 | + } else { |
|
| 469 | + ksort($this->tableau); |
|
| 470 | + } |
|
| 471 | + } # {par hasard} |
|
| 472 | + else { |
|
| 473 | + if ($r[1] == 'hasard') { |
|
| 474 | + $k = array_keys($this->tableau); |
|
| 475 | + shuffle($k); |
|
| 476 | + $v = []; |
|
| 477 | + foreach ($k as $cle) { |
|
| 478 | + $v[$cle] = $this->tableau[$cle]; |
|
| 479 | + } |
|
| 480 | + $this->tableau = $v; |
|
| 481 | + } else { |
|
| 482 | + # {par valeur} |
|
| 483 | + if ($r[1] == 'valeur') { |
|
| 484 | + $tv = '%s'; |
|
| 485 | + } # {par valeur/xx/yy} ?? |
|
| 486 | + else { |
|
| 487 | + $tv = 'table_valeur(%s, ' . var_export($r[1], true) . ')'; |
|
| 488 | + } |
|
| 489 | + $sortfunc .= ' |
|
| 490 | 490 | $a = ' . sprintf($tv, '$aa') . '; |
| 491 | 491 | $b = ' . sprintf($tv, '$bb') . '; |
| 492 | 492 | if ($a <> $b) |
| 493 | 493 | return ($a ' . (!empty($r[2]) ? '>' : '<') . ' $b) ? -1 : 1;'; |
| 494 | - } |
|
| 495 | - } |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - if ($sortfunc) { |
|
| 500 | - $sortfunc .= "\n return 0;"; |
|
| 501 | - uasort($this->tableau, function ($aa, $bb) use ($sortfunc) { |
|
| 502 | - return eval($sortfunc); |
|
| 503 | - }); |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - |
|
| 508 | - /** |
|
| 509 | - * Grouper les resultats |
|
| 510 | - * {fusion /x/y/z} |
|
| 511 | - * |
|
| 512 | - **/ |
|
| 513 | - protected function select_groupby() { |
|
| 514 | - // virer le / initial pour les criteres de la forme {fusion /xx} |
|
| 515 | - if (strlen($fusion = ltrim($this->command['groupby'][0], '/'))) { |
|
| 516 | - $vu = []; |
|
| 517 | - foreach ($this->tableau as $k => $v) { |
|
| 518 | - $val = table_valeur($v, $fusion); |
|
| 519 | - if (isset($vu[$val])) { |
|
| 520 | - unset($this->tableau[$k]); |
|
| 521 | - } else { |
|
| 522 | - $vu[$val] = true; |
|
| 523 | - } |
|
| 524 | - } |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * L'iterateur est-il encore valide ? |
|
| 531 | - * |
|
| 532 | - * @return bool |
|
| 533 | - */ |
|
| 534 | - public function valid() { |
|
| 535 | - return !is_null($this->cle); |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Retourner la valeur |
|
| 540 | - * |
|
| 541 | - * @return null |
|
| 542 | - */ |
|
| 543 | - public function current() { |
|
| 544 | - return $this->valeur; |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * Retourner la cle |
|
| 549 | - * |
|
| 550 | - * @return null |
|
| 551 | - */ |
|
| 552 | - public function key() { |
|
| 553 | - return $this->cle; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * Passer a la valeur suivante |
|
| 558 | - * |
|
| 559 | - * @return void |
|
| 560 | - */ |
|
| 561 | - public function next() { |
|
| 562 | - if ($this->valid()) { |
|
| 563 | - $this->cle = key($this->tableau); |
|
| 564 | - $this->valeur = current($this->tableau); |
|
| 565 | - next($this->tableau); |
|
| 566 | - } |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * Compter le nombre total de resultats |
|
| 571 | - * |
|
| 572 | - * @return int |
|
| 573 | - */ |
|
| 574 | - public function count() { |
|
| 575 | - if (is_null($this->total)) { |
|
| 576 | - $this->total = count($this->tableau); |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - return $this->total; |
|
| 580 | - } |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + if ($sortfunc) { |
|
| 500 | + $sortfunc .= "\n return 0;"; |
|
| 501 | + uasort($this->tableau, function ($aa, $bb) use ($sortfunc) { |
|
| 502 | + return eval($sortfunc); |
|
| 503 | + }); |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + |
|
| 508 | + /** |
|
| 509 | + * Grouper les resultats |
|
| 510 | + * {fusion /x/y/z} |
|
| 511 | + * |
|
| 512 | + **/ |
|
| 513 | + protected function select_groupby() { |
|
| 514 | + // virer le / initial pour les criteres de la forme {fusion /xx} |
|
| 515 | + if (strlen($fusion = ltrim($this->command['groupby'][0], '/'))) { |
|
| 516 | + $vu = []; |
|
| 517 | + foreach ($this->tableau as $k => $v) { |
|
| 518 | + $val = table_valeur($v, $fusion); |
|
| 519 | + if (isset($vu[$val])) { |
|
| 520 | + unset($this->tableau[$k]); |
|
| 521 | + } else { |
|
| 522 | + $vu[$val] = true; |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * L'iterateur est-il encore valide ? |
|
| 531 | + * |
|
| 532 | + * @return bool |
|
| 533 | + */ |
|
| 534 | + public function valid() { |
|
| 535 | + return !is_null($this->cle); |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * Retourner la valeur |
|
| 540 | + * |
|
| 541 | + * @return null |
|
| 542 | + */ |
|
| 543 | + public function current() { |
|
| 544 | + return $this->valeur; |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * Retourner la cle |
|
| 549 | + * |
|
| 550 | + * @return null |
|
| 551 | + */ |
|
| 552 | + public function key() { |
|
| 553 | + return $this->cle; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * Passer a la valeur suivante |
|
| 558 | + * |
|
| 559 | + * @return void |
|
| 560 | + */ |
|
| 561 | + public function next() { |
|
| 562 | + if ($this->valid()) { |
|
| 563 | + $this->cle = key($this->tableau); |
|
| 564 | + $this->valeur = current($this->tableau); |
|
| 565 | + next($this->tableau); |
|
| 566 | + } |
|
| 567 | + } |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * Compter le nombre total de resultats |
|
| 571 | + * |
|
| 572 | + * @return int |
|
| 573 | + */ |
|
| 574 | + public function count() { |
|
| 575 | + if (is_null($this->total)) { |
|
| 576 | + $this->total = count($this->tableau); |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + return $this->total; |
|
| 580 | + } |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /* |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | * @return array |
| 592 | 592 | */ |
| 593 | 593 | function inc_file_to_array_dist($data) { |
| 594 | - return preg_split('/\r?\n/', $data); |
|
| 594 | + return preg_split('/\r?\n/', $data); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -600,9 +600,9 @@ discard block |
||
| 600 | 600 | * @return array |
| 601 | 601 | */ |
| 602 | 602 | function inc_plugins_to_array_dist() { |
| 603 | - include_spip('inc/plugin'); |
|
| 603 | + include_spip('inc/plugin'); |
|
| 604 | 604 | |
| 605 | - return liste_chemin_plugin_actifs(); |
|
| 605 | + return liste_chemin_plugin_actifs(); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | /** |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | * @return array |
| 613 | 613 | */ |
| 614 | 614 | function inc_xml_to_array_dist($data) { |
| 615 | - return @XMLObjectToArray(new SimpleXmlIterator($data)); |
|
| 615 | + return @XMLObjectToArray(new SimpleXmlIterator($data)); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | /** |
@@ -624,14 +624,14 @@ discard block |
||
| 624 | 624 | * |
| 625 | 625 | */ |
| 626 | 626 | function inc_object_to_array($object) { |
| 627 | - if (!is_object($object) && !is_array($object)) { |
|
| 628 | - return $object; |
|
| 629 | - } |
|
| 630 | - if (is_object($object)) { |
|
| 631 | - $object = get_object_vars($object); |
|
| 632 | - } |
|
| 633 | - |
|
| 634 | - return array_map('inc_object_to_array', $object); |
|
| 627 | + if (!is_object($object) && !is_array($object)) { |
|
| 628 | + return $object; |
|
| 629 | + } |
|
| 630 | + if (is_object($object)) { |
|
| 631 | + $object = get_object_vars($object); |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + return array_map('inc_object_to_array', $object); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /** |
@@ -641,20 +641,20 @@ discard block |
||
| 641 | 641 | * @return array|bool |
| 642 | 642 | */ |
| 643 | 643 | function inc_sql_to_array_dist($data) { |
| 644 | - # sortir le connecteur de $data |
|
| 645 | - preg_match(',^(?:(\w+):)?(.*)$,Sm', $data, $v); |
|
| 646 | - $serveur = (string)$v[1]; |
|
| 647 | - $req = trim($v[2]); |
|
| 648 | - if ($s = sql_query($req, $serveur)) { |
|
| 649 | - $r = []; |
|
| 650 | - while ($t = sql_fetch($s)) { |
|
| 651 | - $r[] = $t; |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - return $r; |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - return false; |
|
| 644 | + # sortir le connecteur de $data |
|
| 645 | + preg_match(',^(?:(\w+):)?(.*)$,Sm', $data, $v); |
|
| 646 | + $serveur = (string)$v[1]; |
|
| 647 | + $req = trim($v[2]); |
|
| 648 | + if ($s = sql_query($req, $serveur)) { |
|
| 649 | + $r = []; |
|
| 650 | + while ($t = sql_fetch($s)) { |
|
| 651 | + $r[] = $t; |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + return $r; |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + return false; |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
@@ -664,9 +664,9 @@ discard block |
||
| 664 | 664 | * @return array|bool |
| 665 | 665 | */ |
| 666 | 666 | function inc_json_to_array_dist($data) { |
| 667 | - if (is_array($json = json_decode($data, true))) { |
|
| 668 | - return (array)$json; |
|
| 669 | - } |
|
| 667 | + if (is_array($json = json_decode($data, true))) { |
|
| 668 | + return (array)$json; |
|
| 669 | + } |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | /** |
@@ -676,30 +676,30 @@ discard block |
||
| 676 | 676 | * @return array|bool |
| 677 | 677 | */ |
| 678 | 678 | function inc_csv_to_array_dist($data) { |
| 679 | - include_spip('inc/csv'); |
|
| 680 | - list($entete, $csv) = analyse_csv($data); |
|
| 681 | - array_unshift($csv, $entete); |
|
| 682 | - |
|
| 683 | - include_spip('inc/charsets'); |
|
| 684 | - $i = 1; |
|
| 685 | - foreach ($entete as $k => $v) { |
|
| 686 | - if (trim($v) == '') { |
|
| 687 | - $v = 'col' . $i; |
|
| 688 | - } // reperer des eventuelles cases vides |
|
| 689 | - if (is_numeric($v) and $v < 0) { |
|
| 690 | - $v = '__' . $v; |
|
| 691 | - } // ne pas risquer d'ecraser une cle numerique |
|
| 692 | - if (is_numeric($v)) { |
|
| 693 | - $v = '_' . $v; |
|
| 694 | - } // ne pas risquer d'ecraser une cle numerique |
|
| 695 | - $v = strtolower(preg_replace(',\W+,', '_', translitteration($v))); |
|
| 696 | - foreach ($csv as &$item) { |
|
| 697 | - $item[$v] = &$item[$k]; |
|
| 698 | - } |
|
| 699 | - $i++; |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - return $csv; |
|
| 679 | + include_spip('inc/csv'); |
|
| 680 | + list($entete, $csv) = analyse_csv($data); |
|
| 681 | + array_unshift($csv, $entete); |
|
| 682 | + |
|
| 683 | + include_spip('inc/charsets'); |
|
| 684 | + $i = 1; |
|
| 685 | + foreach ($entete as $k => $v) { |
|
| 686 | + if (trim($v) == '') { |
|
| 687 | + $v = 'col' . $i; |
|
| 688 | + } // reperer des eventuelles cases vides |
|
| 689 | + if (is_numeric($v) and $v < 0) { |
|
| 690 | + $v = '__' . $v; |
|
| 691 | + } // ne pas risquer d'ecraser une cle numerique |
|
| 692 | + if (is_numeric($v)) { |
|
| 693 | + $v = '_' . $v; |
|
| 694 | + } // ne pas risquer d'ecraser une cle numerique |
|
| 695 | + $v = strtolower(preg_replace(',\W+,', '_', translitteration($v))); |
|
| 696 | + foreach ($csv as &$item) { |
|
| 697 | + $item[$v] = &$item[$k]; |
|
| 698 | + } |
|
| 699 | + $i++; |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + return $csv; |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | /** |
@@ -709,12 +709,12 @@ discard block |
||
| 709 | 709 | * @return array|bool |
| 710 | 710 | */ |
| 711 | 711 | function inc_rss_to_array_dist($data) { |
| 712 | - include_spip('inc/syndic'); |
|
| 713 | - if (is_array($rss = analyser_backend($data))) { |
|
| 714 | - $tableau = $rss; |
|
| 715 | - } |
|
| 712 | + include_spip('inc/syndic'); |
|
| 713 | + if (is_array($rss = analyser_backend($data))) { |
|
| 714 | + $tableau = $rss; |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | - return $tableau; |
|
| 717 | + return $tableau; |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
@@ -724,9 +724,9 @@ discard block |
||
| 724 | 724 | * @return array|bool |
| 725 | 725 | */ |
| 726 | 726 | function inc_atom_to_array_dist($data) { |
| 727 | - $rss_to_array = charger_fonction('rss_to_array', 'inc'); |
|
| 727 | + $rss_to_array = charger_fonction('rss_to_array', 'inc'); |
|
| 728 | 728 | |
| 729 | - return $rss_to_array($data); |
|
| 729 | + return $rss_to_array($data); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
@@ -737,12 +737,12 @@ discard block |
||
| 737 | 737 | * @return array|bool |
| 738 | 738 | */ |
| 739 | 739 | function inc_glob_to_array_dist($data) { |
| 740 | - $a = glob( |
|
| 741 | - $data, |
|
| 742 | - GLOB_MARK | GLOB_NOSORT | GLOB_BRACE |
|
| 743 | - ); |
|
| 740 | + $a = glob( |
|
| 741 | + $data, |
|
| 742 | + GLOB_MARK | GLOB_NOSORT | GLOB_BRACE |
|
| 743 | + ); |
|
| 744 | 744 | |
| 745 | - return $a ? $a : []; |
|
| 745 | + return $a ? $a : []; |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | /** |
@@ -753,14 +753,14 @@ discard block |
||
| 753 | 753 | * @throws Exception |
| 754 | 754 | */ |
| 755 | 755 | function inc_yaml_to_array_dist($data) { |
| 756 | - include_spip('inc/yaml-mini'); |
|
| 757 | - if (!function_exists('yaml_decode')) { |
|
| 758 | - throw new Exception('YAML: impossible de trouver la fonction yaml_decode'); |
|
| 756 | + include_spip('inc/yaml-mini'); |
|
| 757 | + if (!function_exists('yaml_decode')) { |
|
| 758 | + throw new Exception('YAML: impossible de trouver la fonction yaml_decode'); |
|
| 759 | 759 | |
| 760 | - return false; |
|
| 761 | - } |
|
| 760 | + return false; |
|
| 761 | + } |
|
| 762 | 762 | |
| 763 | - return yaml_decode($data); |
|
| 763 | + return yaml_decode($data); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | * @return array|bool |
| 776 | 776 | */ |
| 777 | 777 | function inc_pregfiles_to_array_dist($dir, $regexp = -1, $limit = 10000) { |
| 778 | - return (array)preg_files($dir, $regexp, $limit); |
|
| 778 | + return (array)preg_files($dir, $regexp, $limit); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
@@ -787,23 +787,23 @@ discard block |
||
| 787 | 787 | * @return array|bool |
| 788 | 788 | */ |
| 789 | 789 | function inc_ls_to_array_dist($data) { |
| 790 | - $glob_to_array = charger_fonction('glob_to_array', 'inc'); |
|
| 791 | - $a = $glob_to_array($data); |
|
| 792 | - foreach ($a as &$v) { |
|
| 793 | - $b = (array)@stat($v); |
|
| 794 | - foreach ($b as $k => $ignore) { |
|
| 795 | - if (is_numeric($k)) { |
|
| 796 | - unset($b[$k]); |
|
| 797 | - } |
|
| 798 | - } |
|
| 799 | - $b['file'] = preg_replace('`/$`', '', $v) ; |
|
| 800 | - $v = array_merge( |
|
| 801 | - pathinfo($v), |
|
| 802 | - $b |
|
| 803 | - ); |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - return $a; |
|
| 790 | + $glob_to_array = charger_fonction('glob_to_array', 'inc'); |
|
| 791 | + $a = $glob_to_array($data); |
|
| 792 | + foreach ($a as &$v) { |
|
| 793 | + $b = (array)@stat($v); |
|
| 794 | + foreach ($b as $k => $ignore) { |
|
| 795 | + if (is_numeric($k)) { |
|
| 796 | + unset($b[$k]); |
|
| 797 | + } |
|
| 798 | + } |
|
| 799 | + $b['file'] = preg_replace('`/$`', '', $v) ; |
|
| 800 | + $v = array_merge( |
|
| 801 | + pathinfo($v), |
|
| 802 | + $b |
|
| 803 | + ); |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + return $a; |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | /** |
@@ -813,25 +813,25 @@ discard block |
||
| 813 | 813 | * @return array|bool |
| 814 | 814 | */ |
| 815 | 815 | function XMLObjectToArray($object) { |
| 816 | - $xml_array = []; |
|
| 817 | - for ($object->rewind(); $object->valid(); $object->next()) { |
|
| 818 | - if (array_key_exists($key = $object->key(), $xml_array)) { |
|
| 819 | - $key .= '-' . uniqid(); |
|
| 820 | - } |
|
| 821 | - $vars = get_object_vars($object->current()); |
|
| 822 | - if (isset($vars['@attributes'])) { |
|
| 823 | - foreach ($vars['@attributes'] as $k => $v) { |
|
| 824 | - $xml_array[$key][$k] = $v; |
|
| 825 | - } |
|
| 826 | - } |
|
| 827 | - if ($object->hasChildren()) { |
|
| 828 | - $xml_array[$key][] = XMLObjectToArray( |
|
| 829 | - $object->current() |
|
| 830 | - ); |
|
| 831 | - } else { |
|
| 832 | - $xml_array[$key][] = strval($object->current()); |
|
| 833 | - } |
|
| 834 | - } |
|
| 835 | - |
|
| 836 | - return $xml_array; |
|
| 816 | + $xml_array = []; |
|
| 817 | + for ($object->rewind(); $object->valid(); $object->next()) { |
|
| 818 | + if (array_key_exists($key = $object->key(), $xml_array)) { |
|
| 819 | + $key .= '-' . uniqid(); |
|
| 820 | + } |
|
| 821 | + $vars = get_object_vars($object->current()); |
|
| 822 | + if (isset($vars['@attributes'])) { |
|
| 823 | + foreach ($vars['@attributes'] as $k => $v) { |
|
| 824 | + $xml_array[$key][$k] = $v; |
|
| 825 | + } |
|
| 826 | + } |
|
| 827 | + if ($object->hasChildren()) { |
|
| 828 | + $xml_array[$key][] = XMLObjectToArray( |
|
| 829 | + $object->current() |
|
| 830 | + ); |
|
| 831 | + } else { |
|
| 832 | + $xml_array[$key][] = strval($object->current()); |
|
| 833 | + } |
|
| 834 | + } |
|
| 835 | + |
|
| 836 | + return $xml_array; |
|
| 837 | 837 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // Si a ce stade on n'a pas de table, il y a un bug |
| 235 | 235 | if (!is_array($this->tableau)) { |
| 236 | 236 | $this->err = true; |
| 237 | - spip_log('erreur datasource ' . var_export($command, true)); |
|
| 237 | + spip_log('erreur datasource '.var_export($command, true)); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // {datapath query.results} |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | isset($this->command['sourcemode']) |
| 277 | 277 | and !in_array($this->command['sourcemode'], ['table', 'array', 'tableau']) |
| 278 | 278 | ) { |
| 279 | - charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true); |
|
| 279 | + charger_fonction($this->command['sourcemode'].'_to_array', 'inc', true); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | # le premier argument peut etre un array, une URL etc. |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | # avons-nous un cache dispo ? |
| 286 | 286 | $cle = null; |
| 287 | 287 | if (is_string($src)) { |
| 288 | - $cle = 'datasource_' . md5($this->command['sourcemode'] . ':' . var_export($this->command['source'], true)); |
|
| 288 | + $cle = 'datasource_'.md5($this->command['sourcemode'].':'.var_export($this->command['source'], true)); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $cache = $this->cache_get($cle); |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | if ( |
| 346 | 346 | !$this->err |
| 347 | - and $data_to_array = charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true) |
|
| 347 | + and $data_to_array = charger_fonction($this->command['sourcemode'].'_to_array', 'inc', true) |
|
| 348 | 348 | ) { |
| 349 | 349 | $args = $this->command['source']; |
| 350 | 350 | $args[0] = $data; |
@@ -484,13 +484,13 @@ discard block |
||
| 484 | 484 | $tv = '%s'; |
| 485 | 485 | } # {par valeur/xx/yy} ?? |
| 486 | 486 | else { |
| 487 | - $tv = 'table_valeur(%s, ' . var_export($r[1], true) . ')'; |
|
| 487 | + $tv = 'table_valeur(%s, '.var_export($r[1], true).')'; |
|
| 488 | 488 | } |
| 489 | 489 | $sortfunc .= ' |
| 490 | - $a = ' . sprintf($tv, '$aa') . '; |
|
| 491 | - $b = ' . sprintf($tv, '$bb') . '; |
|
| 490 | + $a = ' . sprintf($tv, '$aa').'; |
|
| 491 | + $b = ' . sprintf($tv, '$bb').'; |
|
| 492 | 492 | if ($a <> $b) |
| 493 | - return ($a ' . (!empty($r[2]) ? '>' : '<') . ' $b) ? -1 : 1;'; |
|
| 493 | + return ($a ' . (!empty($r[2]) ? '>' : '<').' $b) ? -1 : 1;'; |
|
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | } |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | if ($sortfunc) { |
| 500 | 500 | $sortfunc .= "\n return 0;"; |
| 501 | - uasort($this->tableau, function ($aa, $bb) use ($sortfunc) { |
|
| 501 | + uasort($this->tableau, function($aa, $bb) use ($sortfunc) { |
|
| 502 | 502 | return eval($sortfunc); |
| 503 | 503 | }); |
| 504 | 504 | } |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | function inc_sql_to_array_dist($data) { |
| 644 | 644 | # sortir le connecteur de $data |
| 645 | 645 | preg_match(',^(?:(\w+):)?(.*)$,Sm', $data, $v); |
| 646 | - $serveur = (string)$v[1]; |
|
| 646 | + $serveur = (string) $v[1]; |
|
| 647 | 647 | $req = trim($v[2]); |
| 648 | 648 | if ($s = sql_query($req, $serveur)) { |
| 649 | 649 | $r = []; |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | */ |
| 666 | 666 | function inc_json_to_array_dist($data) { |
| 667 | 667 | if (is_array($json = json_decode($data, true))) { |
| 668 | - return (array)$json; |
|
| 668 | + return (array) $json; |
|
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | |
@@ -684,13 +684,13 @@ discard block |
||
| 684 | 684 | $i = 1; |
| 685 | 685 | foreach ($entete as $k => $v) { |
| 686 | 686 | if (trim($v) == '') { |
| 687 | - $v = 'col' . $i; |
|
| 687 | + $v = 'col'.$i; |
|
| 688 | 688 | } // reperer des eventuelles cases vides |
| 689 | 689 | if (is_numeric($v) and $v < 0) { |
| 690 | - $v = '__' . $v; |
|
| 690 | + $v = '__'.$v; |
|
| 691 | 691 | } // ne pas risquer d'ecraser une cle numerique |
| 692 | 692 | if (is_numeric($v)) { |
| 693 | - $v = '_' . $v; |
|
| 693 | + $v = '_'.$v; |
|
| 694 | 694 | } // ne pas risquer d'ecraser une cle numerique |
| 695 | 695 | $v = strtolower(preg_replace(',\W+,', '_', translitteration($v))); |
| 696 | 696 | foreach ($csv as &$item) { |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | * @return array|bool |
| 776 | 776 | */ |
| 777 | 777 | function inc_pregfiles_to_array_dist($dir, $regexp = -1, $limit = 10000) { |
| 778 | - return (array)preg_files($dir, $regexp, $limit); |
|
| 778 | + return (array) preg_files($dir, $regexp, $limit); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
@@ -790,13 +790,13 @@ discard block |
||
| 790 | 790 | $glob_to_array = charger_fonction('glob_to_array', 'inc'); |
| 791 | 791 | $a = $glob_to_array($data); |
| 792 | 792 | foreach ($a as &$v) { |
| 793 | - $b = (array)@stat($v); |
|
| 793 | + $b = (array) @stat($v); |
|
| 794 | 794 | foreach ($b as $k => $ignore) { |
| 795 | 795 | if (is_numeric($k)) { |
| 796 | 796 | unset($b[$k]); |
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | - $b['file'] = preg_replace('`/$`', '', $v) ; |
|
| 799 | + $b['file'] = preg_replace('`/$`', '', $v); |
|
| 800 | 800 | $v = array_merge( |
| 801 | 801 | pathinfo($v), |
| 802 | 802 | $b |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | $xml_array = []; |
| 817 | 817 | for ($object->rewind(); $object->valid(); $object->next()) { |
| 818 | 818 | if (array_key_exists($key = $object->key(), $xml_array)) { |
| 819 | - $key .= '-' . uniqid(); |
|
| 819 | + $key .= '-'.uniqid(); |
|
| 820 | 820 | } |
| 821 | 821 | $vars = get_object_vars($object->current()); |
| 822 | 822 | if (isset($vars['@attributes'])) { |
@@ -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 | |
@@ -36,22 +36,22 @@ discard block |
||
| 36 | 36 | * Description de la boucle complétée des champs |
| 37 | 37 | */ |
| 38 | 38 | function iterateur_php_dist($b, $iteratorName) { |
| 39 | - $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 40 | - $b->show = [ |
|
| 41 | - 'field' => [ |
|
| 42 | - 'cle' => 'STRING', |
|
| 43 | - 'valeur' => 'STRING', |
|
| 44 | - ] |
|
| 45 | - ]; |
|
| 46 | - foreach (get_class_methods($iteratorName) as $method) { |
|
| 47 | - $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /* |
|
| 39 | + $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 40 | + $b->show = [ |
|
| 41 | + 'field' => [ |
|
| 42 | + 'cle' => 'STRING', |
|
| 43 | + 'valeur' => 'STRING', |
|
| 44 | + ] |
|
| 45 | + ]; |
|
| 46 | + foreach (get_class_methods($iteratorName) as $method) { |
|
| 47 | + $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /* |
|
| 51 | 51 | foreach (get_class_vars($iteratorName) as $property) { |
| 52 | 52 | $b->show['field'][ strtolower($property) ] = 'PROPERTY'; |
| 53 | 53 | } |
| 54 | 54 | */ |
| 55 | 55 | |
| 56 | - return $b; |
|
| 56 | + return $b; |
|
| 57 | 57 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('iterateur/data'); |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | * Description de la boucle complétée des champs |
| 40 | 40 | */ |
| 41 | 41 | function iterateur_POUR_dist($b) { |
| 42 | - $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 43 | - $b->show = [ |
|
| 44 | - 'field' => [ |
|
| 45 | - 'cle' => 'STRING', |
|
| 46 | - 'valeur' => 'STRING', |
|
| 47 | - ] |
|
| 48 | - ]; |
|
| 42 | + $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 43 | + $b->show = [ |
|
| 44 | + 'field' => [ |
|
| 45 | + 'cle' => 'STRING', |
|
| 46 | + 'valeur' => 'STRING', |
|
| 47 | + ] |
|
| 48 | + ]; |
|
| 49 | 49 | |
| 50 | - return $b; |
|
| 50 | + return $b; |
|
| 51 | 51 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('iterateur/data'); |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | * Description de la boucle complétée des champs |
| 36 | 36 | */ |
| 37 | 37 | function iterateur_CONDITION_dist($b) { |
| 38 | - $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 39 | - $b->show = [ |
|
| 40 | - 'field' => [] |
|
| 41 | - ]; |
|
| 38 | + $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 39 | + $b->show = [ |
|
| 40 | + 'field' => [] |
|
| 41 | + ]; |
|
| 42 | 42 | |
| 43 | - return $b; |
|
| 43 | + return $b; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | * La boucle condition n'a toujours qu'un seul élément. |
| 50 | 50 | */ |
| 51 | 51 | class IterateurCONDITION extends IterateurData { |
| 52 | - /** |
|
| 53 | - * Obtenir les données de la boucle CONDITION |
|
| 54 | - * |
|
| 55 | - * @param array $command |
|
| 56 | - **/ |
|
| 57 | - protected function select($command) { |
|
| 58 | - $this->tableau = [0 => 1]; |
|
| 59 | - } |
|
| 52 | + /** |
|
| 53 | + * Obtenir les données de la boucle CONDITION |
|
| 54 | + * |
|
| 55 | + * @param array $command |
|
| 56 | + **/ |
|
| 57 | + protected function select($command) { |
|
| 58 | + $this->tableau = [0 => 1]; |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -11,90 +11,90 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // https://code.spip.net/@install_etape_ldap1_dist |
| 18 | 18 | function install_etape_ldap1_dist() { |
| 19 | - $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 20 | - ? _INSTALL_HOST_LDAP |
|
| 21 | - : 'localhost'; |
|
| 19 | + $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 20 | + ? _INSTALL_HOST_LDAP |
|
| 21 | + : 'localhost'; |
|
| 22 | 22 | |
| 23 | - $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 24 | - ? _INSTALL_PORT_LDAP |
|
| 25 | - : 389; |
|
| 23 | + $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 24 | + ? _INSTALL_PORT_LDAP |
|
| 25 | + : 389; |
|
| 26 | 26 | |
| 27 | - $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 28 | - ? _INSTALL_TLS_LDAP |
|
| 29 | - : 'non'; |
|
| 27 | + $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 28 | + ? _INSTALL_TLS_LDAP |
|
| 29 | + : 'non'; |
|
| 30 | 30 | |
| 31 | - $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 32 | - ? _INSTALL_PROTOCOLE_LDAP |
|
| 33 | - : 3; // on essaie 2 en cas d'echec |
|
| 31 | + $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 32 | + ? _INSTALL_PROTOCOLE_LDAP |
|
| 33 | + : 3; // on essaie 2 en cas d'echec |
|
| 34 | 34 | |
| 35 | - $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 36 | - ? _INSTALL_USER_LDAP |
|
| 37 | - : ''; |
|
| 35 | + $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 36 | + ? _INSTALL_USER_LDAP |
|
| 37 | + : ''; |
|
| 38 | 38 | |
| 39 | - $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 40 | - ? _INSTALL_PASS_LDAP |
|
| 41 | - : ''; |
|
| 39 | + $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 40 | + ? _INSTALL_PASS_LDAP |
|
| 41 | + : ''; |
|
| 42 | 42 | |
| 43 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 43 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 44 | 44 | |
| 45 | - echo info_etape( |
|
| 46 | - _T('titre_connexion_ldap'), |
|
| 47 | - info_progression_etape(1, 'etape_ldap', 'install/'), |
|
| 48 | - _T('entree_informations_connexion_ldap') |
|
| 49 | - ); |
|
| 45 | + echo info_etape( |
|
| 46 | + _T('titre_connexion_ldap'), |
|
| 47 | + info_progression_etape(1, 'etape_ldap', 'install/'), |
|
| 48 | + _T('entree_informations_connexion_ldap') |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | - echo generer_form_ecrire('install', ( |
|
| 52 | - "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 53 | - . fieldset( |
|
| 54 | - _T('entree_adresse_annuaire'), |
|
| 55 | - [ |
|
| 56 | - 'adresse_ldap' => [ |
|
| 57 | - 'label' => _T('texte_adresse_annuaire_1'), |
|
| 58 | - 'valeur' => $adresse_ldap |
|
| 59 | - ], |
|
| 60 | - 'port_ldap' => [ |
|
| 61 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 62 | - 'valeur' => $port_ldap |
|
| 63 | - ], |
|
| 64 | - 'tls_ldap' => [ |
|
| 65 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 66 | - 'valeur' => $tls_ldap, |
|
| 67 | - 'alternatives' => [ |
|
| 68 | - 'non' => _T('item_non'), |
|
| 69 | - 'oui' => _T('item_oui') |
|
| 70 | - ] |
|
| 71 | - ], |
|
| 72 | - 'protocole_ldap' => [ |
|
| 73 | - 'label' => _T('protocole_ldap'), |
|
| 74 | - 'valeur' => $protocole_ldap, |
|
| 75 | - 'alternatives' => [ |
|
| 76 | - '3' => '3', |
|
| 77 | - '2' => '2' |
|
| 78 | - ] |
|
| 79 | - ] |
|
| 80 | - ] |
|
| 81 | - ) |
|
| 51 | + echo generer_form_ecrire('install', ( |
|
| 52 | + "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 53 | + . fieldset( |
|
| 54 | + _T('entree_adresse_annuaire'), |
|
| 55 | + [ |
|
| 56 | + 'adresse_ldap' => [ |
|
| 57 | + 'label' => _T('texte_adresse_annuaire_1'), |
|
| 58 | + 'valeur' => $adresse_ldap |
|
| 59 | + ], |
|
| 60 | + 'port_ldap' => [ |
|
| 61 | + 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 62 | + 'valeur' => $port_ldap |
|
| 63 | + ], |
|
| 64 | + 'tls_ldap' => [ |
|
| 65 | + 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 66 | + 'valeur' => $tls_ldap, |
|
| 67 | + 'alternatives' => [ |
|
| 68 | + 'non' => _T('item_non'), |
|
| 69 | + 'oui' => _T('item_oui') |
|
| 70 | + ] |
|
| 71 | + ], |
|
| 72 | + 'protocole_ldap' => [ |
|
| 73 | + 'label' => _T('protocole_ldap'), |
|
| 74 | + 'valeur' => $protocole_ldap, |
|
| 75 | + 'alternatives' => [ |
|
| 76 | + '3' => '3', |
|
| 77 | + '2' => '2' |
|
| 78 | + ] |
|
| 79 | + ] |
|
| 80 | + ] |
|
| 81 | + ) |
|
| 82 | 82 | |
| 83 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 84 | - . fieldset( |
|
| 85 | - _T('connexion_ldap'), |
|
| 86 | - [ |
|
| 87 | - 'login_ldap' => [ |
|
| 88 | - 'label' => _T('texte_login_ldap_1'), |
|
| 89 | - 'valeur' => $login_ldap |
|
| 90 | - ], |
|
| 91 | - 'pass_ldap' => [ |
|
| 92 | - 'label' => _T('entree_passe_ldap'), |
|
| 93 | - 'valeur' => $pass_ldap |
|
| 94 | - ] |
|
| 95 | - ] |
|
| 96 | - ) |
|
| 97 | - . bouton_suivant())); |
|
| 83 | + . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 84 | + . fieldset( |
|
| 85 | + _T('connexion_ldap'), |
|
| 86 | + [ |
|
| 87 | + 'login_ldap' => [ |
|
| 88 | + 'label' => _T('texte_login_ldap_1'), |
|
| 89 | + 'valeur' => $login_ldap |
|
| 90 | + ], |
|
| 91 | + 'pass_ldap' => [ |
|
| 92 | + 'label' => _T('entree_passe_ldap'), |
|
| 93 | + 'valeur' => $pass_ldap |
|
| 94 | + ] |
|
| 95 | + ] |
|
| 96 | + ) |
|
| 97 | + . bouton_suivant())); |
|
| 98 | 98 | |
| 99 | - echo install_fin_html(); |
|
| 99 | + echo install_fin_html(); |
|
| 100 | 100 | } |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | 'valeur' => $adresse_ldap |
| 59 | 59 | ], |
| 60 | 60 | 'port_ldap' => [ |
| 61 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 61 | + 'label' => _T('entree_port_annuaire').'<br />'._T('texte_port_annuaire'), |
|
| 62 | 62 | 'valeur' => $port_ldap |
| 63 | 63 | ], |
| 64 | 64 | 'tls_ldap' => [ |
| 65 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 65 | + 'label' => '<b>'._T('tls_ldap').'</b>', |
|
| 66 | 66 | 'valeur' => $tls_ldap, |
| 67 | 67 | 'alternatives' => [ |
| 68 | 68 | 'non' => _T('item_non'), |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ] |
| 81 | 81 | ) |
| 82 | 82 | |
| 83 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 83 | + . "\n<p>"._T('texte_acces_ldap_anonyme_1').'</p>' |
|
| 84 | 84 | . fieldset( |
| 85 | 85 | _T('connexion_ldap'), |
| 86 | 86 | [ |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | if (defined('_TEST_DIRS')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | define('_TEST_DIRS', '1'); |
| 21 | 21 | |
@@ -27,42 +27,42 @@ discard block |
||
| 27 | 27 | // |
| 28 | 28 | // https://code.spip.net/@test_ecrire |
| 29 | 29 | function test_ecrire($my_dir) { |
| 30 | - static $chmod = 0; |
|
| 31 | - |
|
| 32 | - $ok = false; |
|
| 33 | - $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 34 | - $self = basename($script); |
|
| 35 | - $uid = @fileowner('.'); |
|
| 36 | - $uid2 = @fileowner($self); |
|
| 37 | - $gid = @filegroup('.'); |
|
| 38 | - $gid2 = @filegroup($self); |
|
| 39 | - $perms = @fileperms($self); |
|
| 40 | - |
|
| 41 | - // Comparer l'appartenance d'un fichier cree par PHP |
|
| 42 | - // avec celle du script et du repertoire courant |
|
| 43 | - if (!$chmod) { |
|
| 44 | - @rmdir('test'); |
|
| 45 | - spip_unlink('test'); // effacer au cas ou |
|
| 46 | - @touch('test'); |
|
| 47 | - if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 48 | - $chmod = 0700; |
|
| 49 | - } else { |
|
| 50 | - if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 51 | - $chmod = 0770; |
|
| 52 | - } else { |
|
| 53 | - $chmod = 0777; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - // Appliquer de plus les droits d'acces du script |
|
| 57 | - if ($perms > 0) { |
|
| 58 | - $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 59 | - $chmod |= $perms; |
|
| 60 | - } |
|
| 61 | - spip_unlink('test'); |
|
| 62 | - } |
|
| 63 | - $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 64 | - |
|
| 65 | - return $ok ? $chmod : false; |
|
| 30 | + static $chmod = 0; |
|
| 31 | + |
|
| 32 | + $ok = false; |
|
| 33 | + $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 34 | + $self = basename($script); |
|
| 35 | + $uid = @fileowner('.'); |
|
| 36 | + $uid2 = @fileowner($self); |
|
| 37 | + $gid = @filegroup('.'); |
|
| 38 | + $gid2 = @filegroup($self); |
|
| 39 | + $perms = @fileperms($self); |
|
| 40 | + |
|
| 41 | + // Comparer l'appartenance d'un fichier cree par PHP |
|
| 42 | + // avec celle du script et du repertoire courant |
|
| 43 | + if (!$chmod) { |
|
| 44 | + @rmdir('test'); |
|
| 45 | + spip_unlink('test'); // effacer au cas ou |
|
| 46 | + @touch('test'); |
|
| 47 | + if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 48 | + $chmod = 0700; |
|
| 49 | + } else { |
|
| 50 | + if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 51 | + $chmod = 0770; |
|
| 52 | + } else { |
|
| 53 | + $chmod = 0777; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + // Appliquer de plus les droits d'acces du script |
|
| 57 | + if ($perms > 0) { |
|
| 58 | + $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 59 | + $chmod |= $perms; |
|
| 60 | + } |
|
| 61 | + spip_unlink('test'); |
|
| 62 | + } |
|
| 63 | + $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 64 | + |
|
| 65 | + return $ok ? $chmod : false; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // |
@@ -73,83 +73,83 @@ discard block |
||
| 73 | 73 | // https://code.spip.net/@install_etape_chmod_dist |
| 74 | 74 | function install_etape_chmod_dist() { |
| 75 | 75 | |
| 76 | - $test_dir = _request('test_dir'); |
|
| 77 | - $chmod = 0; |
|
| 78 | - |
|
| 79 | - if ($test_dir) { |
|
| 80 | - if (substr($test_dir, -1) !== '/') { |
|
| 81 | - $test_dir .= '/'; |
|
| 82 | - } |
|
| 83 | - if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 84 | - $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 85 | - } |
|
| 86 | - } else { |
|
| 87 | - if (!_FILE_CONNECT) { |
|
| 88 | - $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 89 | - $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $bad_dirs = []; |
|
| 94 | - $absent_dirs = []; |
|
| 95 | - |
|
| 96 | - foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 97 | - $test = test_ecrire($my_dir); |
|
| 98 | - if (!$test) { |
|
| 99 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 100 | - if (@file_exists($my_dir)) { |
|
| 101 | - $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 102 | - } else { |
|
| 103 | - $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 104 | - } |
|
| 105 | - } else { |
|
| 106 | - $chmod = max($chmod, $test); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - if ($bad_dirs or $absent_dirs) { |
|
| 111 | - if (!_FILE_CONNECT) { |
|
| 112 | - $titre = _T('dirs_preliminaire'); |
|
| 113 | - $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 114 | - } else { |
|
| 115 | - $titre = _T('dirs_probleme_droits'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 120 | - |
|
| 121 | - if ($bad_dirs) { |
|
| 122 | - $res .= |
|
| 123 | - _T( |
|
| 124 | - 'dirs_repertoires_suivants', |
|
| 125 | - ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
|
| 126 | - ) . |
|
| 127 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - if ($absent_dirs) { |
|
| 131 | - $res .= |
|
| 132 | - _T( |
|
| 133 | - 'dirs_repertoires_absents', |
|
| 134 | - ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
|
| 135 | - ) . |
|
| 136 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 137 | - } |
|
| 138 | - $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 139 | - |
|
| 140 | - $t = _T('login_recharger'); |
|
| 141 | - $t = (!$test_dir ? '' : |
|
| 142 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 143 | - . "<input type='hidden' name='etape' value='chmod' />" |
|
| 144 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 145 | - |
|
| 146 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 147 | - } else { |
|
| 148 | - $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 149 | - if (!$deja) { |
|
| 150 | - redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 151 | - } else { |
|
| 152 | - redirige_url_ecrire(); |
|
| 153 | - } |
|
| 154 | - } |
|
| 76 | + $test_dir = _request('test_dir'); |
|
| 77 | + $chmod = 0; |
|
| 78 | + |
|
| 79 | + if ($test_dir) { |
|
| 80 | + if (substr($test_dir, -1) !== '/') { |
|
| 81 | + $test_dir .= '/'; |
|
| 82 | + } |
|
| 83 | + if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 84 | + $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 85 | + } |
|
| 86 | + } else { |
|
| 87 | + if (!_FILE_CONNECT) { |
|
| 88 | + $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 89 | + $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $bad_dirs = []; |
|
| 94 | + $absent_dirs = []; |
|
| 95 | + |
|
| 96 | + foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 97 | + $test = test_ecrire($my_dir); |
|
| 98 | + if (!$test) { |
|
| 99 | + $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 100 | + if (@file_exists($my_dir)) { |
|
| 101 | + $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 102 | + } else { |
|
| 103 | + $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 104 | + } |
|
| 105 | + } else { |
|
| 106 | + $chmod = max($chmod, $test); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + if ($bad_dirs or $absent_dirs) { |
|
| 111 | + if (!_FILE_CONNECT) { |
|
| 112 | + $titre = _T('dirs_preliminaire'); |
|
| 113 | + $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 114 | + } else { |
|
| 115 | + $titre = _T('dirs_probleme_droits'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 120 | + |
|
| 121 | + if ($bad_dirs) { |
|
| 122 | + $res .= |
|
| 123 | + _T( |
|
| 124 | + 'dirs_repertoires_suivants', |
|
| 125 | + ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
|
| 126 | + ) . |
|
| 127 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + if ($absent_dirs) { |
|
| 131 | + $res .= |
|
| 132 | + _T( |
|
| 133 | + 'dirs_repertoires_absents', |
|
| 134 | + ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
|
| 135 | + ) . |
|
| 136 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 137 | + } |
|
| 138 | + $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 139 | + |
|
| 140 | + $t = _T('login_recharger'); |
|
| 141 | + $t = (!$test_dir ? '' : |
|
| 142 | + "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 143 | + . "<input type='hidden' name='etape' value='chmod' />" |
|
| 144 | + . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 145 | + |
|
| 146 | + echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 147 | + } else { |
|
| 148 | + $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 149 | + if (!$deja) { |
|
| 150 | + redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 151 | + } else { |
|
| 152 | + redirige_url_ecrire(); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $test_dir .= '/'; |
| 82 | 82 | } |
| 83 | 83 | if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
| 84 | - $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 84 | + $GLOBALS['test_dirs'][] = _DIR_RACINE.$test_dir; |
|
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | 87 | if (!_FILE_CONNECT) { |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
| 97 | 97 | $test = test_ecrire($my_dir); |
| 98 | 98 | if (!$test) { |
| 99 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 99 | + $m = preg_replace(',^'._DIR_RACINE.',', '', $my_dir); |
|
| 100 | 100 | if (@file_exists($my_dir)) { |
| 101 | - $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 101 | + $bad_dirs['<li>'.$m.'</li>'] = 1; |
|
| 102 | 102 | } else { |
| 103 | - $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 103 | + $absent_dirs['<li>'.$m.'</li>'] = 1; |
|
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | 106 | $chmod = max($chmod, $test); |
@@ -110,21 +110,21 @@ discard block |
||
| 110 | 110 | if ($bad_dirs or $absent_dirs) { |
| 111 | 111 | if (!_FILE_CONNECT) { |
| 112 | 112 | $titre = _T('dirs_preliminaire'); |
| 113 | - $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 113 | + $continuer = ' '._T('dirs_commencer').'.'; |
|
| 114 | 114 | } else { |
| 115 | 115 | $titre = _T('dirs_probleme_droits'); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
| 119 | - $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 119 | + $res = "<div align='right'>".menu_langues('var_lang_ecrire')."</div>\n"; |
|
| 120 | 120 | |
| 121 | 121 | if ($bad_dirs) { |
| 122 | 122 | $res .= |
| 123 | 123 | _T( |
| 124 | 124 | 'dirs_repertoires_suivants', |
| 125 | 125 | ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
| 126 | - ) . |
|
| 127 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 126 | + ). |
|
| 127 | + '<b>'._T('login_recharger').'</b>.'; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | if ($absent_dirs) { |
@@ -132,22 +132,21 @@ discard block |
||
| 132 | 132 | _T( |
| 133 | 133 | 'dirs_repertoires_absents', |
| 134 | 134 | ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
| 135 | - ) . |
|
| 136 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 135 | + ). |
|
| 136 | + '<b>'._T('login_recharger').'</b>.'; |
|
| 137 | 137 | } |
| 138 | - $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 138 | + $res = '<p>'.$continuer.$res.aider('install0', true).'</p>'; |
|
| 139 | 139 | |
| 140 | 140 | $t = _T('login_recharger'); |
| 141 | - $t = (!$test_dir ? '' : |
|
| 142 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 141 | + $t = (!$test_dir ? '' : "<input type='hidden' name='test_dir' value='".spip_htmlspecialchars($test_dir, ENT_QUOTES)."' />") |
|
| 143 | 142 | . "<input type='hidden' name='etape' value='chmod' />" |
| 144 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 143 | + . "<div style='text-align: right'><input type='submit' value='".attribut_html($t)."' /></div>"; |
|
| 145 | 144 | |
| 146 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 145 | + echo minipres($titre, $res.generer_form_ecrire('install', $t)); |
|
| 147 | 146 | } else { |
| 148 | 147 | $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
| 149 | 148 | if (!$deja) { |
| 150 | - redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 149 | + redirige_url_ecrire('install', 'etape=1&chmod='.$chmod); |
|
| 151 | 150 | } else { |
| 152 | 151 | redirige_url_ecrire(); |
| 153 | 152 | } |
@@ -11,98 +11,98 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('auth/ldap'); |
| 18 | 18 | |
| 19 | 19 | // https://code.spip.net/@install_etape_ldap4_dist |
| 20 | 20 | function install_etape_ldap4_dist() { |
| 21 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 22 | - $login_ldap = _request('login_ldap'); |
|
| 23 | - $pass_ldap = _request('pass_ldap'); |
|
| 24 | - $port_ldap = _request('port_ldap'); |
|
| 25 | - $base_ldap = _request('base_ldap'); |
|
| 26 | - $base_ldap_text = _request('base_ldap_text'); |
|
| 27 | - if (!$base_ldap) { |
|
| 28 | - $base_ldap = $base_ldap_text; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 32 | - |
|
| 33 | - $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 34 | - @ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 35 | - |
|
| 36 | - // Essayer de verifier le chemin fourni |
|
| 37 | - $r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', ''); |
|
| 38 | - $fail = (ldap_errno($ldap_link) == 32); |
|
| 39 | - |
|
| 40 | - if ($fail) { |
|
| 41 | - echo info_etape(_T('info_chemin_acces_annuaire')), |
|
| 42 | - info_progression_etape(3, 'etape_ldap', 'install/', true), |
|
| 43 | - "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'), |
|
| 44 | - ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>'; |
|
| 45 | - } else { |
|
| 46 | - info_etape(_T('info_reglage_ldap')); |
|
| 47 | - echo info_progression_etape(4, 'etape_ldap', 'install/'); |
|
| 48 | - |
|
| 49 | - $statuts = liste_statuts_ldap(); |
|
| 50 | - $statut_ldap = defined('_INSTALL_STATUT_LDAP') |
|
| 51 | - ? _INSTALL_STATUT_LDAP |
|
| 52 | - : $GLOBALS['liste_des_statuts']['info_redacteurs']; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - $res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
|
| 56 | - . "<input type='hidden' name='etape' value='ldap5' />" |
|
| 57 | - . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />" |
|
| 58 | - . fieldset( |
|
| 59 | - _T('info_statut_utilisateurs_1'), |
|
| 60 | - [ |
|
| 61 | - 'statut_ldap' => [ |
|
| 62 | - 'label' => _T('info_statut_utilisateurs_2') . '<br />', |
|
| 63 | - 'valeur' => $statut_ldap, |
|
| 64 | - 'alternatives' => $statuts |
|
| 65 | - ] |
|
| 66 | - ] |
|
| 67 | - ) |
|
| 68 | - . install_ldap_correspondances() |
|
| 69 | - . bouton_suivant(); |
|
| 70 | - |
|
| 71 | - echo generer_form_ecrire('install', $res); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - echo install_fin_html(); |
|
| 21 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 22 | + $login_ldap = _request('login_ldap'); |
|
| 23 | + $pass_ldap = _request('pass_ldap'); |
|
| 24 | + $port_ldap = _request('port_ldap'); |
|
| 25 | + $base_ldap = _request('base_ldap'); |
|
| 26 | + $base_ldap_text = _request('base_ldap_text'); |
|
| 27 | + if (!$base_ldap) { |
|
| 28 | + $base_ldap = $base_ldap_text; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 32 | + |
|
| 33 | + $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 34 | + @ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 35 | + |
|
| 36 | + // Essayer de verifier le chemin fourni |
|
| 37 | + $r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', ''); |
|
| 38 | + $fail = (ldap_errno($ldap_link) == 32); |
|
| 39 | + |
|
| 40 | + if ($fail) { |
|
| 41 | + echo info_etape(_T('info_chemin_acces_annuaire')), |
|
| 42 | + info_progression_etape(3, 'etape_ldap', 'install/', true), |
|
| 43 | + "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'), |
|
| 44 | + ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>'; |
|
| 45 | + } else { |
|
| 46 | + info_etape(_T('info_reglage_ldap')); |
|
| 47 | + echo info_progression_etape(4, 'etape_ldap', 'install/'); |
|
| 48 | + |
|
| 49 | + $statuts = liste_statuts_ldap(); |
|
| 50 | + $statut_ldap = defined('_INSTALL_STATUT_LDAP') |
|
| 51 | + ? _INSTALL_STATUT_LDAP |
|
| 52 | + : $GLOBALS['liste_des_statuts']['info_redacteurs']; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + $res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
|
| 56 | + . "<input type='hidden' name='etape' value='ldap5' />" |
|
| 57 | + . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />" |
|
| 58 | + . fieldset( |
|
| 59 | + _T('info_statut_utilisateurs_1'), |
|
| 60 | + [ |
|
| 61 | + 'statut_ldap' => [ |
|
| 62 | + 'label' => _T('info_statut_utilisateurs_2') . '<br />', |
|
| 63 | + 'valeur' => $statut_ldap, |
|
| 64 | + 'alternatives' => $statuts |
|
| 65 | + ] |
|
| 66 | + ] |
|
| 67 | + ) |
|
| 68 | + . install_ldap_correspondances() |
|
| 69 | + . bouton_suivant(); |
|
| 70 | + |
|
| 71 | + echo generer_form_ecrire('install', $res); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + echo install_fin_html(); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // https://code.spip.net/@liste_statuts_ldap |
| 78 | 78 | function liste_statuts_ldap() { |
| 79 | - $recom = [ |
|
| 80 | - 'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'), |
|
| 81 | - 'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'), |
|
| 82 | - 'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />') |
|
| 83 | - ]; |
|
| 84 | - |
|
| 85 | - $res = []; |
|
| 86 | - foreach ($GLOBALS['liste_des_statuts'] as $k => $v) { |
|
| 87 | - if (isset($recom[$k])) { |
|
| 88 | - $res[$v] = $recom[$k]; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - return $res; |
|
| 79 | + $recom = [ |
|
| 80 | + 'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'), |
|
| 81 | + 'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'), |
|
| 82 | + 'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />') |
|
| 83 | + ]; |
|
| 84 | + |
|
| 85 | + $res = []; |
|
| 86 | + foreach ($GLOBALS['liste_des_statuts'] as $k => $v) { |
|
| 87 | + if (isset($recom[$k])) { |
|
| 88 | + $res[$v] = $recom[$k]; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + return $res; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | function install_ldap_correspondances() { |
| 96 | - $champs = []; |
|
| 97 | - foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) { |
|
| 98 | - $nom = 'ldap_' . $champ; |
|
| 99 | - $val = is_array($v) ? join(',', $v) : strval($v); |
|
| 100 | - $champs[$nom] = [ |
|
| 101 | - 'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />', |
|
| 102 | - 'valeur' => $val |
|
| 103 | - ]; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return !$champs ? |
|
| 107 | - '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />'); |
|
| 96 | + $champs = []; |
|
| 97 | + foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) { |
|
| 98 | + $nom = 'ldap_' . $champ; |
|
| 99 | + $val = is_array($v) ? join(',', $v) : strval($v); |
|
| 100 | + $champs[$nom] = [ |
|
| 101 | + 'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />', |
|
| 102 | + 'valeur' => $val |
|
| 103 | + ]; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return !$champs ? |
|
| 107 | + '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />'); |
|
| 108 | 108 | } |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | if ($fail) { |
| 41 | 41 | echo info_etape(_T('info_chemin_acces_annuaire')), |
| 42 | 42 | info_progression_etape(3, 'etape_ldap', 'install/', true), |
| 43 | - "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'), |
|
| 44 | - ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>'; |
|
| 43 | + "<div class='error'><p><b>"._T('avis_operation_echec').'</b></p><p>'._T('avis_chemin_invalide_1'), |
|
| 44 | + ' (<tt>'.spip_htmlspecialchars($base_ldap).'</tt>) '._T('avis_chemin_invalide_2').'</p></div>'; |
|
| 45 | 45 | } else { |
| 46 | 46 | info_etape(_T('info_reglage_ldap')); |
| 47 | 47 | echo info_progression_etape(4, 'etape_ldap', 'install/'); |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
| 56 | 56 | . "<input type='hidden' name='etape' value='ldap5' />" |
| 57 | - . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />" |
|
| 57 | + . "<input type='hidden' name='base_ldap' value='".spip_htmlentities($base_ldap)."' />" |
|
| 58 | 58 | . fieldset( |
| 59 | 59 | _T('info_statut_utilisateurs_1'), |
| 60 | 60 | [ |
| 61 | 61 | 'statut_ldap' => [ |
| 62 | - 'label' => _T('info_statut_utilisateurs_2') . '<br />', |
|
| 62 | + 'label' => _T('info_statut_utilisateurs_2').'<br />', |
|
| 63 | 63 | 'valeur' => $statut_ldap, |
| 64 | 64 | 'alternatives' => $statuts |
| 65 | 65 | ] |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | // https://code.spip.net/@liste_statuts_ldap |
| 78 | 78 | function liste_statuts_ldap() { |
| 79 | 79 | $recom = [ |
| 80 | - 'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'), |
|
| 81 | - 'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'), |
|
| 82 | - 'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />') |
|
| 80 | + 'info_administrateurs' => ('<b>'._T('info_administrateur_1').'</b> '._T('info_administrateur_2').'<br />'), |
|
| 81 | + 'info_redacteurs' => ('<b>'._T('info_redacteur_1').'</b> '._T('info_redacteur_2').'<br />'), |
|
| 82 | + 'info_visiteurs' => ('<b>'._T('info_visiteur_1').'</b> '._T('info_visiteur_2').'<br />') |
|
| 83 | 83 | ]; |
| 84 | 84 | |
| 85 | 85 | $res = []; |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | function install_ldap_correspondances() { |
| 96 | 96 | $champs = []; |
| 97 | 97 | foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) { |
| 98 | - $nom = 'ldap_' . $champ; |
|
| 98 | + $nom = 'ldap_'.$champ; |
|
| 99 | 99 | $val = is_array($v) ? join(',', $v) : strval($v); |
| 100 | 100 | $champs[$nom] = [ |
| 101 | - 'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />', |
|
| 101 | + 'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]).'<br />', |
|
| 102 | 102 | 'valeur' => $val |
| 103 | 103 | ]; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | return !$champs ? |
| 107 | - '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />'); |
|
| 107 | + '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2').'<br /><br />'); |
|
| 108 | 108 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -20,199 +20,199 @@ discard block |
||
| 20 | 20 | // https://code.spip.net/@install_bases |
| 21 | 21 | function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) { |
| 22 | 22 | |
| 23 | - // Prefix des tables : |
|
| 24 | - // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 25 | - // a partir de ce qui est envoye a l'installation |
|
| 26 | - if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 27 | - $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 28 | - ? $GLOBALS['table_prefix'] |
|
| 29 | - : preparer_prefixe_tables(_request('tprefix')); |
|
| 30 | - // S'il est vide on remet spip |
|
| 31 | - if (!$table_prefix) { |
|
| 32 | - $table_prefix = 'spip'; |
|
| 33 | - } |
|
| 34 | - } else { |
|
| 35 | - $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 39 | - list(, $adresse_db, $port) = $r; |
|
| 40 | - } else { |
|
| 41 | - $port = ''; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $GLOBALS['connexions'][$server_db] |
|
| 45 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 46 | - |
|
| 47 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 48 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 49 | - |
|
| 50 | - $fquery = sql_serveur('query', $server_db); |
|
| 51 | - if ($choix_db == 'new_spip') { |
|
| 52 | - $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 53 | - if (preg_match($re, $sel_db)) { |
|
| 54 | - $ok = sql_create_base($sel_db, $server_db); |
|
| 55 | - if (!$ok) { |
|
| 56 | - $re = "Impossible de creer la base $re"; |
|
| 57 | - spip_log($re); |
|
| 58 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 59 | - } |
|
| 60 | - } else { |
|
| 61 | - $re = "Le nom de la base doit correspondre a $re"; |
|
| 62 | - spip_log($re); |
|
| 63 | - |
|
| 64 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 69 | - // un sql_mode |
|
| 70 | - install_mode_appel($server_db, false); |
|
| 71 | - $GLOBALS['connexions'][$server_db] |
|
| 72 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 73 | - |
|
| 74 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 75 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 76 | - |
|
| 77 | - // Completer le tableau decrivant la connexion |
|
| 78 | - |
|
| 79 | - $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 80 | - $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 81 | - |
|
| 82 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 83 | - if ($old) { |
|
| 84 | - $old = sql_fetch($old, $server_db); |
|
| 85 | - } |
|
| 86 | - if (!$old) { |
|
| 87 | - // Si possible, demander au serveur d'envoyer les textes |
|
| 88 | - // dans le codage std de SPIP, |
|
| 89 | - $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 90 | - |
|
| 91 | - if ($charset) { |
|
| 92 | - sql_set_charset($charset['charset'], $server_db); |
|
| 93 | - $GLOBALS['meta']['charset_sql_base'] = |
|
| 94 | - $charset['charset']; |
|
| 95 | - $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 96 | - $charset['collation']; |
|
| 97 | - $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 98 | - $charset['charset']; |
|
| 99 | - $charsetbase = $charset['charset']; |
|
| 100 | - } else { |
|
| 101 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 102 | - $charsetbase = 'standard'; |
|
| 103 | - } |
|
| 104 | - spip_log("Creation des tables. Codage $charsetbase"); |
|
| 105 | - creer_base($server_db); // AT LAST |
|
| 106 | - // memoriser avec quel charset on l'a creee |
|
| 107 | - |
|
| 108 | - if ($charset) { |
|
| 109 | - $t = [ |
|
| 110 | - 'nom' => 'charset_sql_base', |
|
| 111 | - 'valeur' => $charset['charset'], |
|
| 112 | - 'impt' => 'non' |
|
| 113 | - ]; |
|
| 114 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 115 | - $t['nom'] = 'charset_collation_sql_base'; |
|
| 116 | - $t['valeur'] = $charset['collation']; |
|
| 117 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 118 | - $t['nom'] = 'charset_sql_connexion'; |
|
| 119 | - $t['valeur'] = $charset['charset']; |
|
| 120 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 121 | - } |
|
| 122 | - $t = [ |
|
| 123 | - 'nom' => 'version_installee', |
|
| 124 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 125 | - 'impt' => 'non' |
|
| 126 | - ]; |
|
| 127 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 128 | - $t['nom'] = 'nouvelle_install'; |
|
| 129 | - $t['valeur'] = 1; |
|
| 130 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 131 | - // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 132 | - if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 133 | - @sql_insertq( |
|
| 134 | - 'spip_meta', |
|
| 135 | - ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 136 | - '', |
|
| 137 | - $server_db |
|
| 138 | - ); |
|
| 139 | - } |
|
| 140 | - } else { |
|
| 141 | - // pour recreer les tables disparues au besoin |
|
| 142 | - spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 143 | - creer_base($server_db); |
|
| 144 | - $fupdateq = sql_serveur('updateq', $server_db); |
|
| 145 | - |
|
| 146 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 147 | - |
|
| 148 | - if ($r) { |
|
| 149 | - $r = sql_fetch($r, $server_db); |
|
| 150 | - } |
|
| 151 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 152 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 153 | - $fupdateq( |
|
| 154 | - 'spip_meta', |
|
| 155 | - ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 156 | - "nom='version_installee'", |
|
| 157 | - '', |
|
| 158 | - $server_db |
|
| 159 | - ); |
|
| 160 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 161 | - } |
|
| 162 | - // eliminer la derniere operation d'admin mal terminee |
|
| 163 | - // notamment la mise a jour |
|
| 164 | - @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // recuperer le charset de la connexion dans les meta |
|
| 168 | - $charset = ''; |
|
| 169 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 170 | - if ($r) { |
|
| 171 | - $r = sql_fetch($r, $server_db); |
|
| 172 | - } |
|
| 173 | - if ($r) { |
|
| 174 | - $charset = $r['valeur']; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $ligne_rappel = install_mode_appel($server_db); |
|
| 178 | - |
|
| 179 | - $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 180 | - if (!$result_ok) { |
|
| 181 | - return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ($chmod_db) { |
|
| 185 | - install_fichier_connexion( |
|
| 186 | - _FILE_CHMOD_TMP, |
|
| 187 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 188 | - ); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - // si ce fichier existe a cette etape c'est qu'il provient |
|
| 192 | - // d'une installation qui ne l'a pas cree correctement. |
|
| 193 | - // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 194 | - |
|
| 195 | - if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 196 | - spip_unlink(_FILE_CONNECT); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - install_fichier_connexion( |
|
| 200 | - _FILE_CONNECT_TMP, |
|
| 201 | - $ligne_rappel |
|
| 202 | - . install_connexion( |
|
| 203 | - $adresse_db, |
|
| 204 | - $port, |
|
| 205 | - $login_db, |
|
| 206 | - $pass_db, |
|
| 207 | - $sel_db, |
|
| 208 | - $server_db, |
|
| 209 | - $table_prefix, |
|
| 210 | - '', |
|
| 211 | - $charset |
|
| 212 | - ) |
|
| 213 | - ); |
|
| 214 | - |
|
| 215 | - return ''; |
|
| 23 | + // Prefix des tables : |
|
| 24 | + // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 25 | + // a partir de ce qui est envoye a l'installation |
|
| 26 | + if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 27 | + $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 28 | + ? $GLOBALS['table_prefix'] |
|
| 29 | + : preparer_prefixe_tables(_request('tprefix')); |
|
| 30 | + // S'il est vide on remet spip |
|
| 31 | + if (!$table_prefix) { |
|
| 32 | + $table_prefix = 'spip'; |
|
| 33 | + } |
|
| 34 | + } else { |
|
| 35 | + $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 39 | + list(, $adresse_db, $port) = $r; |
|
| 40 | + } else { |
|
| 41 | + $port = ''; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $GLOBALS['connexions'][$server_db] |
|
| 45 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 46 | + |
|
| 47 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 48 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 49 | + |
|
| 50 | + $fquery = sql_serveur('query', $server_db); |
|
| 51 | + if ($choix_db == 'new_spip') { |
|
| 52 | + $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 53 | + if (preg_match($re, $sel_db)) { |
|
| 54 | + $ok = sql_create_base($sel_db, $server_db); |
|
| 55 | + if (!$ok) { |
|
| 56 | + $re = "Impossible de creer la base $re"; |
|
| 57 | + spip_log($re); |
|
| 58 | + return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 59 | + } |
|
| 60 | + } else { |
|
| 61 | + $re = "Le nom de la base doit correspondre a $re"; |
|
| 62 | + spip_log($re); |
|
| 63 | + |
|
| 64 | + return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 69 | + // un sql_mode |
|
| 70 | + install_mode_appel($server_db, false); |
|
| 71 | + $GLOBALS['connexions'][$server_db] |
|
| 72 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 73 | + |
|
| 74 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 75 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 76 | + |
|
| 77 | + // Completer le tableau decrivant la connexion |
|
| 78 | + |
|
| 79 | + $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 80 | + $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 81 | + |
|
| 82 | + $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 83 | + if ($old) { |
|
| 84 | + $old = sql_fetch($old, $server_db); |
|
| 85 | + } |
|
| 86 | + if (!$old) { |
|
| 87 | + // Si possible, demander au serveur d'envoyer les textes |
|
| 88 | + // dans le codage std de SPIP, |
|
| 89 | + $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 90 | + |
|
| 91 | + if ($charset) { |
|
| 92 | + sql_set_charset($charset['charset'], $server_db); |
|
| 93 | + $GLOBALS['meta']['charset_sql_base'] = |
|
| 94 | + $charset['charset']; |
|
| 95 | + $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 96 | + $charset['collation']; |
|
| 97 | + $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 98 | + $charset['charset']; |
|
| 99 | + $charsetbase = $charset['charset']; |
|
| 100 | + } else { |
|
| 101 | + spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 102 | + $charsetbase = 'standard'; |
|
| 103 | + } |
|
| 104 | + spip_log("Creation des tables. Codage $charsetbase"); |
|
| 105 | + creer_base($server_db); // AT LAST |
|
| 106 | + // memoriser avec quel charset on l'a creee |
|
| 107 | + |
|
| 108 | + if ($charset) { |
|
| 109 | + $t = [ |
|
| 110 | + 'nom' => 'charset_sql_base', |
|
| 111 | + 'valeur' => $charset['charset'], |
|
| 112 | + 'impt' => 'non' |
|
| 113 | + ]; |
|
| 114 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 115 | + $t['nom'] = 'charset_collation_sql_base'; |
|
| 116 | + $t['valeur'] = $charset['collation']; |
|
| 117 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 118 | + $t['nom'] = 'charset_sql_connexion'; |
|
| 119 | + $t['valeur'] = $charset['charset']; |
|
| 120 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 121 | + } |
|
| 122 | + $t = [ |
|
| 123 | + 'nom' => 'version_installee', |
|
| 124 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 125 | + 'impt' => 'non' |
|
| 126 | + ]; |
|
| 127 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 128 | + $t['nom'] = 'nouvelle_install'; |
|
| 129 | + $t['valeur'] = 1; |
|
| 130 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 131 | + // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 132 | + if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 133 | + @sql_insertq( |
|
| 134 | + 'spip_meta', |
|
| 135 | + ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 136 | + '', |
|
| 137 | + $server_db |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | + } else { |
|
| 141 | + // pour recreer les tables disparues au besoin |
|
| 142 | + spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 143 | + creer_base($server_db); |
|
| 144 | + $fupdateq = sql_serveur('updateq', $server_db); |
|
| 145 | + |
|
| 146 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 147 | + |
|
| 148 | + if ($r) { |
|
| 149 | + $r = sql_fetch($r, $server_db); |
|
| 150 | + } |
|
| 151 | + $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 152 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 153 | + $fupdateq( |
|
| 154 | + 'spip_meta', |
|
| 155 | + ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 156 | + "nom='version_installee'", |
|
| 157 | + '', |
|
| 158 | + $server_db |
|
| 159 | + ); |
|
| 160 | + spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 161 | + } |
|
| 162 | + // eliminer la derniere operation d'admin mal terminee |
|
| 163 | + // notamment la mise a jour |
|
| 164 | + @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // recuperer le charset de la connexion dans les meta |
|
| 168 | + $charset = ''; |
|
| 169 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 170 | + if ($r) { |
|
| 171 | + $r = sql_fetch($r, $server_db); |
|
| 172 | + } |
|
| 173 | + if ($r) { |
|
| 174 | + $charset = $r['valeur']; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $ligne_rappel = install_mode_appel($server_db); |
|
| 178 | + |
|
| 179 | + $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 180 | + if (!$result_ok) { |
|
| 181 | + return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ($chmod_db) { |
|
| 185 | + install_fichier_connexion( |
|
| 186 | + _FILE_CHMOD_TMP, |
|
| 187 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 188 | + ); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + // si ce fichier existe a cette etape c'est qu'il provient |
|
| 192 | + // d'une installation qui ne l'a pas cree correctement. |
|
| 193 | + // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 194 | + |
|
| 195 | + if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 196 | + spip_unlink(_FILE_CONNECT); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + install_fichier_connexion( |
|
| 200 | + _FILE_CONNECT_TMP, |
|
| 201 | + $ligne_rappel |
|
| 202 | + . install_connexion( |
|
| 203 | + $adresse_db, |
|
| 204 | + $port, |
|
| 205 | + $login_db, |
|
| 206 | + $pass_db, |
|
| 207 | + $sel_db, |
|
| 208 | + $server_db, |
|
| 209 | + $table_prefix, |
|
| 210 | + '', |
|
| 211 | + $charset |
|
| 212 | + ) |
|
| 213 | + ); |
|
| 214 | + |
|
| 215 | + return ''; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -227,169 +227,169 @@ discard block |
||
| 227 | 227 | * @return string Le préfixe corrigé |
| 228 | 228 | */ |
| 229 | 229 | function preparer_prefixe_tables($prefixe) { |
| 230 | - return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 230 | + return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // https://code.spip.net/@install_propose_ldap |
| 234 | 234 | function install_propose_ldap() { |
| 235 | - return generer_form_ecrire('install', ( |
|
| 236 | - fieldset( |
|
| 237 | - _T('info_authentification_externe'), |
|
| 238 | - [ |
|
| 239 | - 'etape' => [ |
|
| 240 | - 'label' => _T('texte_annuaire_ldap_1'), |
|
| 241 | - 'valeur' => 'ldap1', |
|
| 242 | - 'hidden' => true |
|
| 243 | - ] |
|
| 244 | - ], |
|
| 245 | - bouton_suivant(_T('bouton_acces_ldap')) |
|
| 246 | - ))); |
|
| 235 | + return generer_form_ecrire('install', ( |
|
| 236 | + fieldset( |
|
| 237 | + _T('info_authentification_externe'), |
|
| 238 | + [ |
|
| 239 | + 'etape' => [ |
|
| 240 | + 'label' => _T('texte_annuaire_ldap_1'), |
|
| 241 | + 'valeur' => 'ldap1', |
|
| 242 | + 'hidden' => true |
|
| 243 | + ] |
|
| 244 | + ], |
|
| 245 | + bouton_suivant(_T('bouton_acces_ldap')) |
|
| 246 | + ))); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@install_premier_auteur |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 252 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 253 | - info_etape( |
|
| 254 | - _T('info_informations_personnelles'), |
|
| 255 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | - aider('install5', true) . |
|
| 257 | - '<p>' . |
|
| 258 | - ($auteur_obligatoire ? |
|
| 259 | - '' |
|
| 260 | - : |
|
| 261 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 262 | - ) |
|
| 263 | - ) |
|
| 264 | - . generer_form_ecrire('install', ( |
|
| 265 | - "\n<input type='hidden' name='etape' value='3b' />" |
|
| 266 | - . $hidden |
|
| 267 | - . fieldset( |
|
| 268 | - _T('info_identification_publique'), |
|
| 269 | - [ |
|
| 270 | - 'nom' => [ |
|
| 271 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 272 | - 'valeur' => $nom, |
|
| 273 | - 'required' => $auteur_obligatoire, |
|
| 274 | - ], |
|
| 275 | - 'email' => [ |
|
| 276 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 277 | - 'valeur' => $email, |
|
| 278 | - ] |
|
| 279 | - ] |
|
| 280 | - ) |
|
| 281 | - |
|
| 282 | - . fieldset( |
|
| 283 | - _T('entree_identifiants_connexion'), |
|
| 284 | - [ |
|
| 285 | - 'login' => [ |
|
| 286 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 287 | - 'info_login_trop_court_car_pluriel', |
|
| 288 | - ['nb' => _LOGIN_TROP_COURT] |
|
| 289 | - ) . "\n", |
|
| 290 | - 'valeur' => $login, |
|
| 291 | - 'required' => $auteur_obligatoire, |
|
| 292 | - ], |
|
| 293 | - 'pass' => [ |
|
| 294 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 295 | - 'info_passe_trop_court_car_pluriel', |
|
| 296 | - ['nb' => _PASS_LONGUEUR_MINI] |
|
| 297 | - ) . "\n", |
|
| 298 | - 'valeur' => $pass, |
|
| 299 | - 'required' => $auteur_obligatoire, |
|
| 300 | - ], |
|
| 301 | - 'pass_verif' => [ |
|
| 302 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 303 | - 'valeur' => $pass, |
|
| 304 | - 'required' => $auteur_obligatoire, |
|
| 305 | - ] |
|
| 306 | - ] |
|
| 307 | - ) |
|
| 308 | - . bouton_suivant())); |
|
| 252 | + return info_progression_etape(3, 'etape_', 'install/') . |
|
| 253 | + info_etape( |
|
| 254 | + _T('info_informations_personnelles'), |
|
| 255 | + '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | + aider('install5', true) . |
|
| 257 | + '<p>' . |
|
| 258 | + ($auteur_obligatoire ? |
|
| 259 | + '' |
|
| 260 | + : |
|
| 261 | + _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 262 | + ) |
|
| 263 | + ) |
|
| 264 | + . generer_form_ecrire('install', ( |
|
| 265 | + "\n<input type='hidden' name='etape' value='3b' />" |
|
| 266 | + . $hidden |
|
| 267 | + . fieldset( |
|
| 268 | + _T('info_identification_publique'), |
|
| 269 | + [ |
|
| 270 | + 'nom' => [ |
|
| 271 | + 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 272 | + 'valeur' => $nom, |
|
| 273 | + 'required' => $auteur_obligatoire, |
|
| 274 | + ], |
|
| 275 | + 'email' => [ |
|
| 276 | + 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 277 | + 'valeur' => $email, |
|
| 278 | + ] |
|
| 279 | + ] |
|
| 280 | + ) |
|
| 281 | + |
|
| 282 | + . fieldset( |
|
| 283 | + _T('entree_identifiants_connexion'), |
|
| 284 | + [ |
|
| 285 | + 'login' => [ |
|
| 286 | + 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 287 | + 'info_login_trop_court_car_pluriel', |
|
| 288 | + ['nb' => _LOGIN_TROP_COURT] |
|
| 289 | + ) . "\n", |
|
| 290 | + 'valeur' => $login, |
|
| 291 | + 'required' => $auteur_obligatoire, |
|
| 292 | + ], |
|
| 293 | + 'pass' => [ |
|
| 294 | + 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 295 | + 'info_passe_trop_court_car_pluriel', |
|
| 296 | + ['nb' => _PASS_LONGUEUR_MINI] |
|
| 297 | + ) . "\n", |
|
| 298 | + 'valeur' => $pass, |
|
| 299 | + 'required' => $auteur_obligatoire, |
|
| 300 | + ], |
|
| 301 | + 'pass_verif' => [ |
|
| 302 | + 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 303 | + 'valeur' => $pass, |
|
| 304 | + 'required' => $auteur_obligatoire, |
|
| 305 | + ] |
|
| 306 | + ] |
|
| 307 | + ) |
|
| 308 | + . bouton_suivant())); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // https://code.spip.net/@install_etape_3_dist |
| 312 | 312 | function install_etape_3_dist() { |
| 313 | - $ldap_present = _request('ldap_present'); |
|
| 314 | - |
|
| 315 | - if (!$ldap_present) { |
|
| 316 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 317 | - ? _INSTALL_HOST_DB |
|
| 318 | - : _request('adresse_db'); |
|
| 319 | - |
|
| 320 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 321 | - ? _INSTALL_USER_DB |
|
| 322 | - : _request('login_db'); |
|
| 323 | - |
|
| 324 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 325 | - ? _INSTALL_PASS_DB |
|
| 326 | - : _request('pass_db'); |
|
| 327 | - |
|
| 328 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 329 | - ? _INSTALL_SERVER_DB |
|
| 330 | - : _request('server_db'); |
|
| 331 | - |
|
| 332 | - $chmod_db = defined('_SPIP_CHMOD') |
|
| 333 | - ? _SPIP_CHMOD |
|
| 334 | - : _request('chmod'); |
|
| 335 | - |
|
| 336 | - $choix_db = defined('_INSTALL_NAME_DB') |
|
| 337 | - ? _INSTALL_NAME_DB |
|
| 338 | - : _request('choix_db'); |
|
| 339 | - |
|
| 340 | - $sel_db = ($choix_db == 'new_spip') |
|
| 341 | - ? _request('table_new') : $choix_db; |
|
| 342 | - |
|
| 343 | - $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 344 | - |
|
| 345 | - if ($res) { |
|
| 346 | - $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 347 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 348 | - . $res |
|
| 349 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 350 | - . '</div>'; |
|
| 351 | - } |
|
| 352 | - } else { |
|
| 353 | - $res = ''; |
|
| 354 | - list($adresse_db, $login_db, $pass_db, $sel_db, $server_db) = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 355 | - $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - if (!$res) { |
|
| 359 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 360 | - include(_FILE_CONNECT_TMP); |
|
| 361 | - } else { |
|
| 362 | - redirige_url_ecrire('install'); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 366 | - include(_FILE_CHMOD_TMP); |
|
| 367 | - } else { |
|
| 368 | - redirige_url_ecrire('install'); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 372 | - . (defined('_INSTALL_NAME_DB') ? '' |
|
| 373 | - : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 374 | - |
|
| 375 | - $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 376 | - |
|
| 377 | - $res = "<div class='success'><b>" |
|
| 378 | - . _T('info_base_installee') |
|
| 379 | - . '</b></div>' |
|
| 380 | - . install_premier_auteur( |
|
| 381 | - _request('email'), |
|
| 382 | - _request('login'), |
|
| 383 | - _request('nom'), |
|
| 384 | - _request('pass'), |
|
| 385 | - $hidden, |
|
| 386 | - $auteur_obligatoire |
|
| 387 | - ) |
|
| 388 | - . (($ldap_present or !function_exists('ldap_connect')) |
|
| 389 | - ? '' : install_propose_ldap()); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - echo install_debut_html(); |
|
| 393 | - echo $res; |
|
| 394 | - echo install_fin_html(); |
|
| 313 | + $ldap_present = _request('ldap_present'); |
|
| 314 | + |
|
| 315 | + if (!$ldap_present) { |
|
| 316 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 317 | + ? _INSTALL_HOST_DB |
|
| 318 | + : _request('adresse_db'); |
|
| 319 | + |
|
| 320 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 321 | + ? _INSTALL_USER_DB |
|
| 322 | + : _request('login_db'); |
|
| 323 | + |
|
| 324 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 325 | + ? _INSTALL_PASS_DB |
|
| 326 | + : _request('pass_db'); |
|
| 327 | + |
|
| 328 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 329 | + ? _INSTALL_SERVER_DB |
|
| 330 | + : _request('server_db'); |
|
| 331 | + |
|
| 332 | + $chmod_db = defined('_SPIP_CHMOD') |
|
| 333 | + ? _SPIP_CHMOD |
|
| 334 | + : _request('chmod'); |
|
| 335 | + |
|
| 336 | + $choix_db = defined('_INSTALL_NAME_DB') |
|
| 337 | + ? _INSTALL_NAME_DB |
|
| 338 | + : _request('choix_db'); |
|
| 339 | + |
|
| 340 | + $sel_db = ($choix_db == 'new_spip') |
|
| 341 | + ? _request('table_new') : $choix_db; |
|
| 342 | + |
|
| 343 | + $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 344 | + |
|
| 345 | + if ($res) { |
|
| 346 | + $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 347 | + . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 348 | + . $res |
|
| 349 | + . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 350 | + . '</div>'; |
|
| 351 | + } |
|
| 352 | + } else { |
|
| 353 | + $res = ''; |
|
| 354 | + list($adresse_db, $login_db, $pass_db, $sel_db, $server_db) = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 355 | + $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + if (!$res) { |
|
| 359 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 360 | + include(_FILE_CONNECT_TMP); |
|
| 361 | + } else { |
|
| 362 | + redirige_url_ecrire('install'); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 366 | + include(_FILE_CHMOD_TMP); |
|
| 367 | + } else { |
|
| 368 | + redirige_url_ecrire('install'); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 372 | + . (defined('_INSTALL_NAME_DB') ? '' |
|
| 373 | + : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 374 | + |
|
| 375 | + $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 376 | + |
|
| 377 | + $res = "<div class='success'><b>" |
|
| 378 | + . _T('info_base_installee') |
|
| 379 | + . '</b></div>' |
|
| 380 | + . install_premier_auteur( |
|
| 381 | + _request('email'), |
|
| 382 | + _request('login'), |
|
| 383 | + _request('nom'), |
|
| 384 | + _request('pass'), |
|
| 385 | + $hidden, |
|
| 386 | + $auteur_obligatoire |
|
| 387 | + ) |
|
| 388 | + . (($ldap_present or !function_exists('ldap_connect')) |
|
| 389 | + ? '' : install_propose_ldap()); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + echo install_debut_html(); |
|
| 393 | + echo $res; |
|
| 394 | + echo install_fin_html(); |
|
| 395 | 395 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
| 46 | 46 | |
| 47 | 47 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 48 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 48 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 49 | 49 | |
| 50 | 50 | $fquery = sql_serveur('query', $server_db); |
| 51 | 51 | if ($choix_db == 'new_spip') { |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | if (!$ok) { |
| 56 | 56 | $re = "Impossible de creer la base $re"; |
| 57 | 57 | spip_log($re); |
| 58 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 58 | + return '<p>'._T('avis_connexion_erreur_creer_base')."</p><!--\n$re\n-->"; |
|
| 59 | 59 | } |
| 60 | 60 | } else { |
| 61 | 61 | $re = "Le nom de la base doit correspondre a $re"; |
| 62 | 62 | spip_log($re); |
| 63 | 63 | |
| 64 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 64 | + return '<p>'._T('avis_connexion_erreur_nom_base')."</p><!--\n$re\n-->"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
| 73 | 73 | |
| 74 | 74 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 75 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 75 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 76 | 76 | |
| 77 | 77 | // Completer le tableau decrivant la connexion |
| 78 | 78 | |
| 79 | 79 | $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
| 80 | 80 | $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
| 81 | 81 | |
| 82 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 82 | + $old = sql_showbase($table_prefix.'_meta', $server_db); |
|
| 83 | 83 | if ($old) { |
| 84 | 84 | $old = sql_fetch($old, $server_db); |
| 85 | 85 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $charset['charset']; |
| 99 | 99 | $charsetbase = $charset['charset']; |
| 100 | 100 | } else { |
| 101 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 101 | + spip_log(_DEFAULT_CHARSET.' inconnu du serveur SQL'); |
|
| 102 | 102 | $charsetbase = 'standard'; |
| 103 | 103 | } |
| 104 | 104 | spip_log("Creation des tables. Codage $charsetbase"); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | if ($r) { |
| 149 | 149 | $r = sql_fetch($r, $server_db); |
| 150 | 150 | } |
| 151 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 151 | + $version_installee = !$r ? 0 : (double) $r['valeur']; |
|
| 152 | 152 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 153 | 153 | $fupdateq( |
| 154 | 154 | 'spip_meta', |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | '', |
| 158 | 158 | $server_db |
| 159 | 159 | ); |
| 160 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 160 | + spip_log('nouvelle version installee: '.$GLOBALS['spip_version_base']); |
|
| 161 | 161 | } |
| 162 | 162 | // eliminer la derniere operation d'admin mal terminee |
| 163 | 163 | // notamment la mise a jour |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | if ($chmod_db) { |
| 185 | 185 | install_fichier_connexion( |
| 186 | 186 | _FILE_CHMOD_TMP, |
| 187 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 187 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', ".sprintf('0%3o', $chmod_db).");\n" |
|
| 188 | 188 | ); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -249,16 +249,16 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@install_premier_auteur |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 252 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 252 | + return info_progression_etape(3, 'etape_', 'install/'). |
|
| 253 | 253 | info_etape( |
| 254 | 254 | _T('info_informations_personnelles'), |
| 255 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | - aider('install5', true) . |
|
| 257 | - '<p>' . |
|
| 255 | + '<b>'._T('texte_informations_personnelles_1').'</b>'. |
|
| 256 | + aider('install5', true). |
|
| 257 | + '<p>'. |
|
| 258 | 258 | ($auteur_obligatoire ? |
| 259 | 259 | '' |
| 260 | 260 | : |
| 261 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 261 | + _T('texte_informations_personnelles_2').' '._T('info_laisser_champs_vides') |
|
| 262 | 262 | ) |
| 263 | 263 | ) |
| 264 | 264 | . generer_form_ecrire('install', ( |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | _T('info_identification_publique'), |
| 269 | 269 | [ |
| 270 | 270 | 'nom' => [ |
| 271 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 271 | + 'label' => '<b>'._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n", |
|
| 272 | 272 | 'valeur' => $nom, |
| 273 | 273 | 'required' => $auteur_obligatoire, |
| 274 | 274 | ], |
| 275 | 275 | 'email' => [ |
| 276 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 276 | + 'label' => '<b>'._T('entree_adresse_email')."</b>\n", |
|
| 277 | 277 | 'valeur' => $email, |
| 278 | 278 | ] |
| 279 | 279 | ] |
@@ -283,23 +283,23 @@ discard block |
||
| 283 | 283 | _T('entree_identifiants_connexion'), |
| 284 | 284 | [ |
| 285 | 285 | 'login' => [ |
| 286 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 286 | + 'label' => '<b>'._T('entree_login')."</b><br />\n"._T( |
|
| 287 | 287 | 'info_login_trop_court_car_pluriel', |
| 288 | 288 | ['nb' => _LOGIN_TROP_COURT] |
| 289 | - ) . "\n", |
|
| 289 | + )."\n", |
|
| 290 | 290 | 'valeur' => $login, |
| 291 | 291 | 'required' => $auteur_obligatoire, |
| 292 | 292 | ], |
| 293 | 293 | 'pass' => [ |
| 294 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 294 | + 'label' => '<b>'._T('entree_mot_passe')."</b><br />\n"._T( |
|
| 295 | 295 | 'info_passe_trop_court_car_pluriel', |
| 296 | 296 | ['nb' => _PASS_LONGUEUR_MINI] |
| 297 | - ) . "\n", |
|
| 297 | + )."\n", |
|
| 298 | 298 | 'valeur' => $pass, |
| 299 | 299 | 'required' => $auteur_obligatoire, |
| 300 | 300 | ], |
| 301 | 301 | 'pass_verif' => [ |
| 302 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 302 | + 'label' => '<b>'._T('info_confirmer_passe')."</b><br />\n", |
|
| 303 | 303 | 'valeur' => $pass, |
| 304 | 304 | 'required' => $auteur_obligatoire, |
| 305 | 305 | ] |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | if ($res) { |
| 346 | 346 | $res = info_progression_etape(2, 'etape_', 'install/', true) |
| 347 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 347 | + . "<div class='error'><h3>"._T('avis_operation_echec').'</h3>' |
|
| 348 | 348 | . $res |
| 349 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 349 | + . '<p>'._T('texte_operation_echec').'</p>' |
|
| 350 | 350 | . '</div>'; |
| 351 | 351 | } |
| 352 | 352 | } else { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -21,65 +21,65 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // https://code.spip.net/@install_etape_fin_dist |
| 23 | 23 | function install_etape_fin_dist() { |
| 24 | - ecrire_acces(); |
|
| 24 | + ecrire_acces(); |
|
| 25 | 25 | |
| 26 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 27 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 28 | - if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | - if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 30 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - } |
|
| 26 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 27 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 28 | + if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | + if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 30 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 36 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 37 | - spip_log("renomme $f"); |
|
| 38 | - if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | - if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 40 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 35 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 36 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 37 | + spip_log("renomme $f"); |
|
| 38 | + if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | + if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 40 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // creer le repertoire cache, qui sert partout ! |
|
| 46 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 47 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 48 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 49 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 50 | - } |
|
| 45 | + // creer le repertoire cache, qui sert partout ! |
|
| 46 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 47 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 48 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 49 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // Verifier la securite des htaccess |
|
| 53 | - // Si elle ne fonctionne pas, prevenir |
|
| 54 | - $msg = install_verifier_htaccess(); |
|
| 55 | - if ($msg) { |
|
| 56 | - $cible = _T('public:accueil_site'); |
|
| 57 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 58 | - echo minipres('AUTO', $msg . $cible); |
|
| 59 | - // ok, deboucher dans l'espace prive |
|
| 60 | - } else { |
|
| 61 | - redirige_url_ecrire('accueil'); |
|
| 62 | - } |
|
| 52 | + // Verifier la securite des htaccess |
|
| 53 | + // Si elle ne fonctionne pas, prevenir |
|
| 54 | + $msg = install_verifier_htaccess(); |
|
| 55 | + if ($msg) { |
|
| 56 | + $cible = _T('public:accueil_site'); |
|
| 57 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 58 | + echo minipres('AUTO', $msg . $cible); |
|
| 59 | + // ok, deboucher dans l'espace prive |
|
| 60 | + } else { |
|
| 61 | + redirige_url_ecrire('accueil'); |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function install_verifier_htaccess() { |
| 66 | - if ( |
|
| 67 | - verifier_htaccess(_DIR_TMP, true) |
|
| 68 | - and verifier_htaccess(_DIR_CONNECT, true) |
|
| 69 | - ) { |
|
| 70 | - return ''; |
|
| 71 | - } |
|
| 66 | + if ( |
|
| 67 | + verifier_htaccess(_DIR_TMP, true) |
|
| 68 | + and verifier_htaccess(_DIR_CONNECT, 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 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | // creer le repertoire cache, qui sert partout ! |
| 46 | 46 | // deja fait en etape 4 en principe, on garde au cas ou |
| 47 | 47 | if (!@file_exists(_DIR_CACHE)) { |
| 48 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 48 | + $rep = preg_replace(','._DIR_TMP.',', '', _DIR_CACHE); |
|
| 49 | 49 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if ($msg) { |
| 56 | 56 | $cible = _T('public:accueil_site'); |
| 57 | 57 | $cible = generer_form_ecrire('accueil', '', '', $cible); |
| 58 | - echo minipres('AUTO', $msg . $cible); |
|
| 58 | + echo minipres('AUTO', $msg.$cible); |
|
| 59 | 59 | // ok, deboucher dans l'espace prive |
| 60 | 60 | } else { |
| 61 | 61 | 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 | |