Completed
Push — master ( 84a206...dea3a3 )
by cam
01:06
created
ecrire/inc/install.php 1 patch
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = '<' . "?php\n"
47
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
-		. $texte
49
-		. '?' . '>';
46
+    $texte = '<' . "?php\n"
47
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
+        . $texte
49
+        . '?' . '>';
50 50
 
51
-	ecrire_fichier($nom, $texte);
51
+    ecrire_fichier($nom, $texte);
52 52
 }
53 53
 
54 54
 
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
  *
78 78
  **/
79 79
 function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') {
80
-	$adr = addcslashes($adr, "'\\");
81
-	$port = addcslashes($port, "'\\");
82
-	$login = addcslashes($login, "'\\");
83
-	$pass = addcslashes($pass, "'\\");
84
-	$base = addcslashes($base, "'\\");
85
-	$type = addcslashes($type, "'\\");
86
-	$pref = addcslashes($pref, "'\\");
87
-	$ldap = addcslashes($ldap, "'\\");
88
-	$charset = addcslashes($charset, "'\\");
89
-
90
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
-	. 'spip_connect_db('
92
-	. "'$adr','$port','$login','$pass','$base'"
93
-	. ",'$type', '$pref','$ldap','$charset');\n";
80
+    $adr = addcslashes($adr, "'\\");
81
+    $port = addcslashes($port, "'\\");
82
+    $login = addcslashes($login, "'\\");
83
+    $pass = addcslashes($pass, "'\\");
84
+    $base = addcslashes($base, "'\\");
85
+    $type = addcslashes($type, "'\\");
86
+    $pref = addcslashes($pref, "'\\");
87
+    $ldap = addcslashes($ldap, "'\\");
88
+    $charset = addcslashes($charset, "'\\");
89
+
90
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
+    . 'spip_connect_db('
92
+    . "'$adr','$port','$login','$pass','$base'"
93
+    . ",'$type', '$pref','$ldap','$charset');\n";
94 94
 }
95 95
 
96 96
 
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
  *     Tableau des informations sur la connexion
107 107
  **/
108 108
 function analyse_fichier_connection($file) {
109
-	$s = @join('', file($file));
110
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
-		array_shift($regs);
112
-
113
-		return $regs;
114
-	} else {
115
-		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
117
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
-		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
120
-			array_shift($regs);
121
-			array_shift($regs);
122
-
123
-			return $regs;
124
-		}
125
-	}
126
-	spip_log("$file n'est pas un fichier de connexion");
127
-
128
-	return [];
109
+    $s = @join('', file($file));
110
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
+        array_shift($regs);
112
+
113
+        return $regs;
114
+    } else {
115
+        $ar = '\s*\'([^\']*)\'';
116
+        $r = '\s*,' . $ar;
117
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
+        if (preg_match($r, $s, $regs)) {
119
+            $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
120
+            array_shift($regs);
121
+            array_shift($regs);
122
+
123
+            return $regs;
124
+        }
125
+    }
126
+    spip_log("$file n'est pas un fichier de connexion");
127
+
128
+    return [];
129 129
 }
130 130
 
131 131
 /**
@@ -142,67 +142,67 @@  discard block
 block discarded – undo
142 142
  *     Liste des noms de connecteurs
143 143
  **/
144 144
 function bases_referencees($exclu = '') {
145
-	$tables = [];
146
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
-		if ($f != $exclu and analyse_fichier_connection($f)) {
148
-			$tables[] = basename($f, '.php');
149
-		}
150
-	}
151
-
152
-	return $tables;
145
+    $tables = [];
146
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
+        if ($f != $exclu and analyse_fichier_connection($f)) {
148
+            $tables[] = basename($f, '.php');
149
+        }
150
+    }
151
+
152
+    return $tables;
153 153
 }
154 154
 
155 155
 
156 156
 function install_mode_appel($server_db, $tout = true) {
157
-	return ($server_db != 'mysql') ? ''
158
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
-			. test_sql_mode_mysql($server_db));
157
+    return ($server_db != 'mysql') ? ''
158
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
+            . test_sql_mode_mysql($server_db));
160 160
 }
161 161
 
162 162
 //
163 163
 // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-)
164 164
 // (sert a l'etape 1 de l'installation)
165 165
 function tester_compatibilite_hebergement() {
166
-	$err = [];
167
-
168
-	$p = phpversion();
169
-	if (version_compare($p, _PHP_MIN, '<')) {
170
-		$err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
171
-	}
172
-
173
-	// Si on n'a pas la bonne version de PHP, c'est la fin
174
-	if ($err) {
175
-		die("<div class='error'>"
176
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
177
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
178
-	}
179
-
180
-	// Il faut une base de donnees tout de meme ...
181
-	$serveurs = install_select_serveur();
182
-	if (!$serveurs) {
183
-		$err[] = _T('install_extension_php_obligatoire')
184
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
185
-			. "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
186
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
187
-	}
188
-
189
-	// et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0)
190
-	if ($a = @ini_get('mbstring.func_overload')) {
191
-		$err[] = _T('install_extension_mbstring')
192
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
193
-	}
194
-
195
-	if ($err) {
196
-		echo "<div class='error'>"
197
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
198
-		foreach ($err as $e) {
199
-			echo "<li><strong>$e</strong></li>\n";
200
-		}
201
-
202
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
203
-		# de forcer malgre tout (pour tester, ou si bug de detection)
204
-		echo "</ul></div>\n";
205
-	}
166
+    $err = [];
167
+
168
+    $p = phpversion();
169
+    if (version_compare($p, _PHP_MIN, '<')) {
170
+        $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
171
+    }
172
+
173
+    // Si on n'a pas la bonne version de PHP, c'est la fin
174
+    if ($err) {
175
+        die("<div class='error'>"
176
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
177
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
178
+    }
179
+
180
+    // Il faut une base de donnees tout de meme ...
181
+    $serveurs = install_select_serveur();
182
+    if (!$serveurs) {
183
+        $err[] = _T('install_extension_php_obligatoire')
184
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
185
+            . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
186
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
187
+    }
188
+
189
+    // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0)
190
+    if ($a = @ini_get('mbstring.func_overload')) {
191
+        $err[] = _T('install_extension_mbstring')
192
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
193
+    }
194
+
195
+    if ($err) {
196
+        echo "<div class='error'>"
197
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
198
+        foreach ($err as $e) {
199
+            echo "<li><strong>$e</strong></li>\n";
200
+        }
201
+
202
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
203
+        # de forcer malgre tout (pour tester, ou si bug de detection)
204
+        echo "</ul></div>\n";
205
+    }
206 206
 }
207 207
 
208 208
 
@@ -212,23 +212,23 @@  discard block
 block discarded – undo
212 212
  * @note superflu ??
213 213
  */
214 214
 function login_hebergeur() {
215
-	$base_hebergeur = 'localhost'; # par defaut
215
+    $base_hebergeur = 'localhost'; # par defaut
216 216
 
217
-	// Free
218
-	if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
219
-		$base_hebergeur = 'sql.free.fr';
220
-		$login_hebergeur = $regs[1];
221
-	} else {
222
-		$login_hebergeur = '';
223
-	}
217
+    // Free
218
+    if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
219
+        $base_hebergeur = 'sql.free.fr';
220
+        $login_hebergeur = $regs[1];
221
+    } else {
222
+        $login_hebergeur = '';
223
+    }
224 224
 
225
-	return [$base_hebergeur, $login_hebergeur];
225
+    return [$base_hebergeur, $login_hebergeur];
226 226
 }
227 227
 
228 228
 
229 229
 function info_etape($titre, $complement = '') {
230
-	return '<h2>' . $titre . "</h2>\n" .
231
-	($complement ? '' . $complement . "\n" : '');
230
+    return '<h2>' . $titre . "</h2>\n" .
231
+    ($complement ? '' . $complement . "\n" : '');
232 232
 }
233 233
 
234 234
 /**
@@ -238,154 +238,154 @@  discard block
 block discarded – undo
238 238
  * @return string Code HTML du bouton
239 239
  **/
240 240
 function bouton_suivant($code = '') {
241
-	if ($code == '') {
242
-		$code = _T('bouton_suivant');
243
-	}
244
-	static $suivant = 0;
245
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
246
-	$suivant += 1;
247
-
248
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
249
-	$code .
250
-	" >>\" /></p>\n";
241
+    if ($code == '') {
242
+        $code = _T('bouton_suivant');
243
+    }
244
+    static $suivant = 0;
245
+    $id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
246
+    $suivant += 1;
247
+
248
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
249
+    $code .
250
+    " >>\" /></p>\n";
251 251
 }
252 252
 
253 253
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
254
-	$intitule_etat = [];
255
-	//$en_cours = _request('etape')?_request('etape'):"";
256
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
257
-	$debut = 1;
258
-	$etat = 'ok';
259
-	$last = count($liste);
254
+    $intitule_etat = [];
255
+    //$en_cours = _request('etape')?_request('etape'):"";
256
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
257
+    $debut = 1;
258
+    $etat = 'ok';
259
+    $last = count($liste);
260 260
 //	$texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo'));
261 261
 
262
-	$intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
263
-	$intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
264
-	$intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
265
-	$intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
262
+    $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
263
+    $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
264
+    $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
265
+    $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
266 266
 
267
-	$intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
268
-	$intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
269
-	$intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
270
-	$intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
271
-	$intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
267
+    $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
268
+    $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
269
+    $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
270
+    $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
271
+    $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
272 272
 
273 273
 //	$aff_etapes = "<span id='etapes'>";
274 274
 
275
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
276
-
277
-	foreach ($liste as $etape => $fichier) {
278
-		if ($debut < $last) {
279
-			if ($debut == $en_cours && $erreur) {
280
-				$class = 'on erreur';
281
-			} else {
282
-				if ($debut == $en_cours) {
283
-					$class = 'on';
284
-				} else {
285
-					if ($debut > $en_cours) {
286
-						$class = 'prochains';
287
-					} else {
288
-						$class = 'valides';
289
-					}
290
-				}
291
-			}
292
-
293
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
294
-			$aff_etapes .= ($debut == $en_cours) ? '<strong>' : '';
295
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
296
-			$aff_etapes .= $intitule_etat["$phase"][$debut];
297
-			$aff_etapes .= ($debut == $en_cours) ? '</strong>' : '';
298
-			$aff_etapes .= '</div></li>';
299
-		}
300
-		$debut++;
301
-	}
302
-	$aff_etapes .= '</ul>';
303
-	$aff_etapes .= "<br class='nettoyeur' />\n";
304
-
305
-	return $aff_etapes;
275
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
276
+
277
+    foreach ($liste as $etape => $fichier) {
278
+        if ($debut < $last) {
279
+            if ($debut == $en_cours && $erreur) {
280
+                $class = 'on erreur';
281
+            } else {
282
+                if ($debut == $en_cours) {
283
+                    $class = 'on';
284
+                } else {
285
+                    if ($debut > $en_cours) {
286
+                        $class = 'prochains';
287
+                    } else {
288
+                        $class = 'valides';
289
+                    }
290
+                }
291
+            }
292
+
293
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
294
+            $aff_etapes .= ($debut == $en_cours) ? '<strong>' : '';
295
+            $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
296
+            $aff_etapes .= $intitule_etat["$phase"][$debut];
297
+            $aff_etapes .= ($debut == $en_cours) ? '</strong>' : '';
298
+            $aff_etapes .= '</div></li>';
299
+        }
300
+        $debut++;
301
+    }
302
+    $aff_etapes .= '</ul>';
303
+    $aff_etapes .= "<br class='nettoyeur' />\n";
304
+
305
+    return $aff_etapes;
306 306
 }
307 307
 
308 308
 
309 309
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
310
-	return "<fieldset>\n" .
311
-	$avant .
312
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
313
-	fieldset_champs($champs) .
314
-	$apres .
315
-	"</fieldset>\n";
310
+    return "<fieldset>\n" .
311
+    $avant .
312
+    ($legend ? '<legend>' . $legend . "</legend>\n" : '') .
313
+    fieldset_champs($champs) .
314
+    $apres .
315
+    "</fieldset>\n";
316 316
 }
317 317
 
318 318
 function fieldset_champs($champs = []) {
319
-	$fieldset = '';
320
-	foreach ($champs as $nom => $contenu) {
321
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
322
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
323
-		if (isset($contenu['alternatives'])) {
324
-			$fieldset .= $contenu['label'] . "\n";
325
-			foreach ($contenu['alternatives'] as $valeur => $label) {
326
-				$fieldset .= "<input type='radio' name='" . $nom .
327
-					"' id='$nom-$valeur' value='$valeur'"
328
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
329
-					. "/>\n";
330
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
331
-			}
332
-			$fieldset .= "<br />\n";
333
-		} else {
334
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
335
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
336
-				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
337
-				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
338
-				. " />\n";
339
-		}
340
-	}
341
-
342
-	return $fieldset;
319
+    $fieldset = '';
320
+    foreach ($champs as $nom => $contenu) {
321
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
322
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
323
+        if (isset($contenu['alternatives'])) {
324
+            $fieldset .= $contenu['label'] . "\n";
325
+            foreach ($contenu['alternatives'] as $valeur => $label) {
326
+                $fieldset .= "<input type='radio' name='" . $nom .
327
+                    "' id='$nom-$valeur' value='$valeur'"
328
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
329
+                    . "/>\n";
330
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
331
+            }
332
+            $fieldset .= "<br />\n";
333
+        } else {
334
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
335
+            $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
336
+                . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
337
+                . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
338
+                . " />\n";
339
+        }
340
+    }
341
+
342
+    return $fieldset;
343 343
 }
344 344
 
345 345
 function install_select_serveur() {
346
-	$options = [];
347
-	$dir = _DIR_RESTREINT . 'req/';
348
-	$d = opendir($dir);
349
-	if (!$d) {
350
-		return [];
351
-	}
352
-	while (($f = readdir($d)) !== false) {
353
-		if (
354
-			(preg_match('/^(.*)[.]php$/', $f, $s))
355
-			and is_readable($f = $dir . $f)
356
-		) {
357
-			require_once($f);
358
-			$s = $s[1];
359
-			$v = 'spip_versions_' . $s;
360
-			if (function_exists($v) and $v()) {
361
-				$titre = _T("install_select_type_$s");
362
-				// proposer mysql par defaut si dispo
363
-				$checked = ($s == 'mysql' ? " checked='checked'" : '');
364
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
365
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
366
-			} else {
367
-				spip_log("$s: portage indisponible");
368
-			}
369
-		}
370
-	}
371
-	sort($options);
372
-
373
-	return $options;
346
+    $options = [];
347
+    $dir = _DIR_RESTREINT . 'req/';
348
+    $d = opendir($dir);
349
+    if (!$d) {
350
+        return [];
351
+    }
352
+    while (($f = readdir($d)) !== false) {
353
+        if (
354
+            (preg_match('/^(.*)[.]php$/', $f, $s))
355
+            and is_readable($f = $dir . $f)
356
+        ) {
357
+            require_once($f);
358
+            $s = $s[1];
359
+            $v = 'spip_versions_' . $s;
360
+            if (function_exists($v) and $v()) {
361
+                $titre = _T("install_select_type_$s");
362
+                // proposer mysql par defaut si dispo
363
+                $checked = ($s == 'mysql' ? " checked='checked'" : '');
364
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
365
+                    . "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
366
+            } else {
367
+                spip_log("$s: portage indisponible");
368
+            }
369
+        }
370
+    }
371
+    sort($options);
372
+
373
+    return $options;
374 374
 }
375 375
 
376 376
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
377
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
378
-
379
-	return generer_form_ecrire('install', (
380
-		"\n<input type='hidden' name='etape' value='$etape' />"
381
-		. $hidden
382
-		. (_request('echec') ?
383
-			('<p><b>' . _T('avis_connexion_echec_1') .
384
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
385
-			: '')
386
-
387
-		. ($jquery ? http_script('', 'jquery.js') : '')
388
-		. http_script('
377
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
378
+
379
+    return generer_form_ecrire('install', (
380
+        "\n<input type='hidden' name='etape' value='$etape' />"
381
+        . $hidden
382
+        . (_request('echec') ?
383
+            ('<p><b>' . _T('avis_connexion_echec_1') .
384
+                '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
385
+            : '')
386
+
387
+        . ($jquery ? http_script('', 'jquery.js') : '')
388
+        . http_script('
389 389
 		jQuery(function($) {
390 390
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
391 391
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -418,145 +418,145 @@  discard block
 block discarded – undo
418 418
 			});
419 419
 		});')
420 420
 
421
-		. ($server_db
422
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
423
-			. (($predef[0])
424
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
425
-				: '')
426
-			: ('<fieldset><legend>'
427
-				. _T('install_select_type_db')
428
-				. '</legend>'
429
-				. '<p class="explication">'
430
-				. _T('install_types_db_connus')
431
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
432
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
433
-				. '</p>'
434
-				. "\n<div class='p'>\n<ul>\n"
435
-				. join("\n", install_select_serveur())
436
-				. "\n</ul>\n</div></fieldset>")
437
-		)
438
-		. '<div id="install_adresse_base_hebergeur">'
439
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
440
-		. ($predef[1]
441
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
442
-			: fieldset(
443
-				_T('entree_base_donnee_1'),
444
-				[
445
-					'adresse_db' => [
446
-						'label' => $db[1],
447
-						'valeur' => $db[0]
448
-					],
449
-				]
450
-			)
451
-		)
452
-		. '</div>'
453
-
454
-		. '<div id="install_login_base_hebergeur">'
455
-		. ($predef[2]
456
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
457
-			: fieldset(
458
-				_T('entree_login_connexion_1'),
459
-				[
460
-					'login_db' => [
461
-						'label' => $login[1],
462
-						'valeur' => $login[0]
463
-					],
464
-				]
465
-			)
466
-		)
467
-		. '</div>'
468
-
469
-		. '<div id="install_pass_base_hebergeur">'
470
-		. ($predef[3]
471
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
472
-			: fieldset(
473
-				_T('entree_mot_passe_1'),
474
-				[
475
-					'pass_db' => [
476
-						'label' => $pass[1],
477
-						'valeur' => $pass[0]
478
-					],
479
-				]
480
-			)
481
-		)
482
-		. '</div>'
483
-
484
-		. bouton_suivant()));
421
+        . ($server_db
422
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
423
+            . (($predef[0])
424
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
425
+                : '')
426
+            : ('<fieldset><legend>'
427
+                . _T('install_select_type_db')
428
+                . '</legend>'
429
+                . '<p class="explication">'
430
+                . _T('install_types_db_connus')
431
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
432
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
433
+                . '</p>'
434
+                . "\n<div class='p'>\n<ul>\n"
435
+                . join("\n", install_select_serveur())
436
+                . "\n</ul>\n</div></fieldset>")
437
+        )
438
+        . '<div id="install_adresse_base_hebergeur">'
439
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
440
+        . ($predef[1]
441
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
442
+            : fieldset(
443
+                _T('entree_base_donnee_1'),
444
+                [
445
+                    'adresse_db' => [
446
+                        'label' => $db[1],
447
+                        'valeur' => $db[0]
448
+                    ],
449
+                ]
450
+            )
451
+        )
452
+        . '</div>'
453
+
454
+        . '<div id="install_login_base_hebergeur">'
455
+        . ($predef[2]
456
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
457
+            : fieldset(
458
+                _T('entree_login_connexion_1'),
459
+                [
460
+                    'login_db' => [
461
+                        'label' => $login[1],
462
+                        'valeur' => $login[0]
463
+                    ],
464
+                ]
465
+            )
466
+        )
467
+        . '</div>'
468
+
469
+        . '<div id="install_pass_base_hebergeur">'
470
+        . ($predef[3]
471
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
472
+            : fieldset(
473
+                _T('entree_mot_passe_1'),
474
+                [
475
+                    'pass_db' => [
476
+                        'label' => $pass[1],
477
+                        'valeur' => $pass[0]
478
+                    ],
479
+                ]
480
+            )
481
+        )
482
+        . '</div>'
483
+
484
+        . bouton_suivant()));
485 485
 }
486 486
 
487 487
 // 4 valeurs qu'on reconduit d'un script a l'autre
488 488
 // sauf s'ils sont predefinis.
489 489
 
490 490
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
491
-	return ((defined('_INSTALL_HOST_DB'))
492
-		? ''
493
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
494
-	)
495
-	. ((defined('_INSTALL_USER_DB'))
496
-		? ''
497
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
498
-	)
499
-	. ((defined('_INSTALL_PASS_DB'))
500
-		? ''
501
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
502
-	)
503
-
504
-	. ((defined('_INSTALL_SERVER_DB'))
505
-		? ''
506
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
507
-	);
491
+    return ((defined('_INSTALL_HOST_DB'))
492
+        ? ''
493
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
494
+    )
495
+    . ((defined('_INSTALL_USER_DB'))
496
+        ? ''
497
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
498
+    )
499
+    . ((defined('_INSTALL_PASS_DB'))
500
+        ? ''
501
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
502
+    )
503
+
504
+    . ((defined('_INSTALL_SERVER_DB'))
505
+        ? ''
506
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
507
+    );
508 508
 }
509 509
 
510 510
 // presentation des bases existantes
511 511
 
512 512
 function install_etape_liste_bases($server_db, $login_db, $disabled = []) {
513
-	$bases = $checked = [];
514
-	$noms = sql_listdbs($server_db);
515
-	if (!$noms) {
516
-		return '';
517
-	}
518
-
519
-	foreach ($noms as $nom) {
520
-		$id = spip_htmlspecialchars($nom);
521
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
522
-		$base = ' name="choix_db" value="'
523
-			. $nom
524
-			. '"'
525
-			. $dis
526
-			. " type='radio' id='$id'";
527
-		$label = "<label for='$id'>"
528
-			. ($dis ? "<i>$nom</i>" : $nom)
529
-			. '</label>';
530
-
531
-		if (
532
-			!$checked and !$dis and
533
-			(($nom == $login_db) or
534
-				($GLOBALS['table_prefix'] == $nom))
535
-		) {
536
-			$checked = "<input$base checked='checked' />\n$label";
537
-		} else {
538
-			$bases[] = "<input$base />\n$label";
539
-		}
540
-	}
541
-
542
-	if (!$bases && !$checked) {
543
-		return false;
544
-	}
545
-
546
-	if ($checked) {
547
-		array_unshift($bases, $checked);
548
-		$checked = true;
549
-	}
550
-
551
-	return [$checked, $bases];
513
+    $bases = $checked = [];
514
+    $noms = sql_listdbs($server_db);
515
+    if (!$noms) {
516
+        return '';
517
+    }
518
+
519
+    foreach ($noms as $nom) {
520
+        $id = spip_htmlspecialchars($nom);
521
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
522
+        $base = ' name="choix_db" value="'
523
+            . $nom
524
+            . '"'
525
+            . $dis
526
+            . " type='radio' id='$id'";
527
+        $label = "<label for='$id'>"
528
+            . ($dis ? "<i>$nom</i>" : $nom)
529
+            . '</label>';
530
+
531
+        if (
532
+            !$checked and !$dis and
533
+            (($nom == $login_db) or
534
+                ($GLOBALS['table_prefix'] == $nom))
535
+        ) {
536
+            $checked = "<input$base checked='checked' />\n$label";
537
+        } else {
538
+            $bases[] = "<input$base />\n$label";
539
+        }
540
+    }
541
+
542
+    if (!$bases && !$checked) {
543
+        return false;
544
+    }
545
+
546
+    if ($checked) {
547
+        array_unshift($bases, $checked);
548
+        $checked = true;
549
+    }
550
+
551
+    return [$checked, $bases];
552 552
 }
553 553
 
554 554
 function install_propager($hidden) {
555
-	$res = '';
556
-	foreach ($hidden as $k) {
557
-		$v = spip_htmlentities(_request($k));
558
-		$res .= "<input type='hidden' name='$k' value='$v' />";
559
-	}
555
+    $res = '';
556
+    foreach ($hidden as $k) {
557
+        $v = spip_htmlentities(_request($k));
558
+        $res .= "<input type='hidden' name='$k' value='$v' />";
559
+    }
560 560
 
561
-	return $res;
561
+    return $res;
562 562
 }
Please login to merge, or discard this patch.