Completed
Push — master ( a89a62...abdc2a )
by cam
01:31
created
ecrire/install/etape_2.php 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -11,166 +11,166 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('base/abstract_sql');
18 18
 
19 19
 function install_etape_2_dist() {
20
-	$adresse_db = defined('_INSTALL_HOST_DB')
21
-		? _INSTALL_HOST_DB
22
-		: _request('adresse_db');
20
+    $adresse_db = defined('_INSTALL_HOST_DB')
21
+        ? _INSTALL_HOST_DB
22
+        : _request('adresse_db');
23 23
 
24
-	if (preg_match(',(.*):(.*),', $adresse_db, $r)) {
25
-		[, $adresse_db, $port] = $r;
26
-	} else {
27
-		$port = '';
28
-	}
24
+    if (preg_match(',(.*):(.*),', $adresse_db, $r)) {
25
+        [, $adresse_db, $port] = $r;
26
+    } else {
27
+        $port = '';
28
+    }
29 29
 
30
-	$login_db = defined('_INSTALL_USER_DB')
31
-		? _INSTALL_USER_DB
32
-		: _request('login_db');
30
+    $login_db = defined('_INSTALL_USER_DB')
31
+        ? _INSTALL_USER_DB
32
+        : _request('login_db');
33 33
 
34
-	$pass_db = defined('_INSTALL_PASS_DB')
35
-		? _INSTALL_PASS_DB
36
-		: _request('pass_db');
34
+    $pass_db = defined('_INSTALL_PASS_DB')
35
+        ? _INSTALL_PASS_DB
36
+        : _request('pass_db');
37 37
 
38
-	$server_db = defined('_INSTALL_SERVER_DB')
39
-		? _INSTALL_SERVER_DB
40
-		: _request('server_db');
38
+    $server_db = defined('_INSTALL_SERVER_DB')
39
+        ? _INSTALL_SERVER_DB
40
+        : _request('server_db');
41 41
 
42
-	$name_db = defined('_INSTALL_NAME_DB')
43
-		? _INSTALL_NAME_DB
44
-		: '';
42
+    $name_db = defined('_INSTALL_NAME_DB')
43
+        ? _INSTALL_NAME_DB
44
+        : '';
45 45
 
46
-	$chmod = _request('chmod');
46
+    $chmod = _request('chmod');
47 47
 
48
-	$link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db);
49
-	$GLOBALS['connexions'][$server_db] = $link;
48
+    $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db);
49
+    $GLOBALS['connexions'][$server_db] = $link;
50 50
 
51
-	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
52
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
51
+    $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
52
+        = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
53 53
 
54
-	echo install_debut_html();
54
+    echo install_debut_html();
55 55
 
56 56
 // prenons toutes les dispositions possibles pour que rien ne s'affiche !
57 57
 
58
-	/*
58
+    /*
59 59
 	 * /!\ sqlite3/PDO : erreur sur join(', ', $link)
60 60
 	 * L'objet PDO ne peut pas etre transformee en chaine
61 61
 	 * Un echo $link ne fonctionne pas non plus
62 62
 	 * Il faut utiliser par exemple print_r($link)
63 63
 	 */
64
-	//echo "\n<!--\n", join(', ', $link), " $login_db ";
65
-	$db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0;
66
-	//echo join(', ', $GLOBALS['connexions'][$server_db]);
67
-	//echo "\n-->\n";
64
+    //echo "\n<!--\n", join(', ', $link), " $login_db ";
65
+    $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0;
66
+    //echo join(', ', $GLOBALS['connexions'][$server_db]);
67
+    //echo "\n-->\n";
68 68
 
69
-	if (($db_connect == '0') && $link) {
70
-		echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>';
71
-		echo info_progression_etape(2, 'etape_', 'install/');
69
+    if (($db_connect == '0') && $link) {
70
+        echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>';
71
+        echo info_progression_etape(2, 'etape_', 'install/');
72 72
 
73
-		echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true));
73
+        echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true));
74 74
 
75
-		echo "\n", '<!-- ', sql_version($server_db), ' -->';
76
-		[$checked, $res] = install_etape_2_bases($login_db, $server_db);
75
+        echo "\n", '<!-- ', sql_version($server_db), ' -->';
76
+        [$checked, $res] = install_etape_2_bases($login_db, $server_db);
77 77
 
78
-		$hidden = (defined('_SPIP_CHMOD')
79
-				? ''
80
-				: ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />"))
81
-			. predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db);
78
+        $hidden = (defined('_SPIP_CHMOD')
79
+                ? ''
80
+                : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />"))
81
+            . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db);
82 82
 
83
-		echo install_etape_2_form($hidden, $checked, $res, 3);
84
-	} else {
85
-		echo info_progression_etape(1, 'etape_', 'install/', true);
83
+        echo install_etape_2_form($hidden, $checked, $res, 3);
84
+    } else {
85
+        echo info_progression_etape(1, 'etape_', 'install/', true);
86 86
 
87
-		echo "<div class='error'>";
88
-		echo info_etape(_T('info_connexion_base'));
89
-		echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>';
90
-		echo '<p>' . _T('avis_connexion_echec_2') . '</p>';
87
+        echo "<div class='error'>";
88
+        echo info_etape(_T('info_connexion_base'));
89
+        echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>';
90
+        echo '<p>' . _T('avis_connexion_echec_2') . '</p>';
91 91
 
92
-		echo "<p style='font-size: small;'>",
93
-		_T('avis_connexion_echec_3'),
94
-		'</p></div>';
95
-	}
92
+        echo "<p style='font-size: small;'>",
93
+        _T('avis_connexion_echec_3'),
94
+        '</p></div>';
95
+    }
96 96
 
97
-	echo install_fin_html();
97
+    echo install_fin_html();
98 98
 }
99 99
 
100 100
 // Liste les bases accessibles,
101 101
 // avec une heuristique pour preselectionner la plus probable
102 102
 
103 103
 function install_etape_2_bases($login_db, $server_db) {
104
-	$res = install_etape_liste_bases($server_db, $login_db);
105
-	if ($res) {
106
-		[$checked, $bases] = $res;
107
-
108
-		return [
109
-			$checked,
110
-			"<label for='choix_db'><b>"
111
-			. _T('texte_choix_base_2')
112
-			. '</b><br />'
113
-			. _T('texte_choix_base_3')
114
-			. '</label>'
115
-			. "<ul>\n<li>"
116
-			. join("</li>\n<li>", $bases)
117
-			. "</li>\n</ul><p>"
118
-			. _T('info_ou')
119
-			. ' '
120
-		];
121
-	}
122
-	$res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b>
104
+    $res = install_etape_liste_bases($server_db, $login_db);
105
+    if ($res) {
106
+        [$checked, $bases] = $res;
107
+
108
+        return [
109
+            $checked,
110
+            "<label for='choix_db'><b>"
111
+            . _T('texte_choix_base_2')
112
+            . '</b><br />'
113
+            . _T('texte_choix_base_3')
114
+            . '</label>'
115
+            . "<ul>\n<li>"
116
+            . join("</li>\n<li>", $bases)
117
+            . "</li>\n</ul><p>"
118
+            . _T('info_ou')
119
+            . ' '
120
+        ];
121
+    }
122
+    $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b>
123 123
 		' . _T('avis_lecture_noms_bases_2') . '<p>';
124 124
 
125
-	$checked = false;
126
-	if ($login_db) {
127
-		// Si un login comporte un point, le nom de la base est plus
128
-		// probablement le login sans le point -- testons pour savoir
129
-		$test_base = $login_db;
130
-		$ok = sql_selectdb($test_base, $server_db);
131
-		$test_base2 = str_replace('.', '_', $test_base);
132
-		if (sql_selectdb($test_base2, $server_db)) {
133
-			$test_base = $test_base2;
134
-			$ok = true;
135
-		}
136
-
137
-		if ($ok) {
138
-			$res .= _T('avis_lecture_noms_bases_3')
139
-				. '<ul>'
140
-				. '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />"
141
-				. "<label for='stand'>" . $test_base . "</label></li>\n"
142
-				. '</ul>'
143
-				. '<p>' . _T('info_ou') . ' ';
144
-			$checked = true;
145
-		}
146
-	}
147
-
148
-	return [$checked, $res];
125
+    $checked = false;
126
+    if ($login_db) {
127
+        // Si un login comporte un point, le nom de la base est plus
128
+        // probablement le login sans le point -- testons pour savoir
129
+        $test_base = $login_db;
130
+        $ok = sql_selectdb($test_base, $server_db);
131
+        $test_base2 = str_replace('.', '_', $test_base);
132
+        if (sql_selectdb($test_base2, $server_db)) {
133
+            $test_base = $test_base2;
134
+            $ok = true;
135
+        }
136
+
137
+        if ($ok) {
138
+            $res .= _T('avis_lecture_noms_bases_3')
139
+                . '<ul>'
140
+                . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />"
141
+                . "<label for='stand'>" . $test_base . "</label></li>\n"
142
+                . '</ul>'
143
+                . '<p>' . _T('info_ou') . ' ';
144
+            $checked = true;
145
+        }
146
+    }
147
+
148
+    return [$checked, $res];
149 149
 }
150 150
 
151 151
 function install_etape_2_form($hidden, $checked, $res, $etape) {
152
-	return generer_form_ecrire('install', (
153
-		"\n<input type='hidden' name='etape' value='$etape' />"
154
-		. $hidden
155
-		. (defined('_INSTALL_NAME_DB')
156
-			? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>'
157
-			: "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n"
158
-			. $res
159
-			. "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'"
160
-			. ($checked ? '' : " checked='checked'")
161
-			. " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>"
162
-			. "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n"
163
-		)
164
-
165
-		. ((defined('_INSTALL_TABLE_PREFIX')
166
-			or $GLOBALS['table_prefix'] != 'spip')
167
-			? '<h3>' . _T('install_table_prefix_hebergeur') . '  <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>'
168
-			: '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n"
169
-			. "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>'
170
-			. "\n<input type='text' id='tprefix' name='tprefix' class='text' value='"
171
-			. 'spip' # valeur par defaut
172
-			. "' size='20' /></p></fieldset>"
173
-		)
174
-
175
-		. bouton_suivant()));
152
+    return generer_form_ecrire('install', (
153
+        "\n<input type='hidden' name='etape' value='$etape' />"
154
+        . $hidden
155
+        . (defined('_INSTALL_NAME_DB')
156
+            ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>'
157
+            : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n"
158
+            . $res
159
+            . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'"
160
+            . ($checked ? '' : " checked='checked'")
161
+            . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>"
162
+            . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n"
163
+        )
164
+
165
+        . ((defined('_INSTALL_TABLE_PREFIX')
166
+            or $GLOBALS['table_prefix'] != 'spip')
167
+            ? '<h3>' . _T('install_table_prefix_hebergeur') . '  <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>'
168
+            : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n"
169
+            . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>'
170
+            . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='"
171
+            . 'spip' # valeur par defaut
172
+            . "' size='20' /></p></fieldset>"
173
+        )
174
+
175
+        . bouton_suivant()));
176 176
 }
Please login to merge, or discard this patch.
ecrire/install/etape_4.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,69 +11,69 @@
 block discarded – undo
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');
18 18
 
19 19
 function install_etape_4_dist() {
20 20
 
21
-	// creer le repertoire cache, qui sert partout !
22
-	if (!@file_exists(_DIR_CACHE)) {
23
-		$rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE);
24
-		$rep = sous_repertoire(_DIR_TMP, $rep, true, true);
25
-	}
21
+    // creer le repertoire cache, qui sert partout !
22
+    if (!@file_exists(_DIR_CACHE)) {
23
+        $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE);
24
+        $rep = sous_repertoire(_DIR_TMP, $rep, true, true);
25
+    }
26 26
 
27 27
 
28
-	echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
29
-	echo info_progression_etape(4, 'etape_', 'install/');
28
+    echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
29
+    echo info_progression_etape(4, 'etape_', 'install/');
30 30
 
31
-	echo "<div class='success'><b>"
32
-		. _T('info_derniere_etape')
33
-		. '</b><p>'
34
-		. _T('info_utilisation_spip')
35
-		. '</p></div>';
31
+    echo "<div class='success'><b>"
32
+        . _T('info_derniere_etape')
33
+        . '</b><p>'
34
+        . _T('info_utilisation_spip')
35
+        . '</p></div>';
36 36
 
37 37
 
38
-	echo '<p>'
39
-		. _T(
40
-			'plugin_info_plugins_dist_1',
41
-			['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>']
42
-		)
43
-		. '</p>';
38
+    echo '<p>'
39
+        . _T(
40
+            'plugin_info_plugins_dist_1',
41
+            ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>']
42
+        )
43
+        . '</p>';
44 44
 
45
-	// installer les extensions
46
-	include_spip('inc/plugin');
47
-	$afficher = charger_fonction('afficher_liste', 'plugins');
48
-	echo $afficher(
49
-		self(),
50
-		liste_plugin_files(_DIR_PLUGINS_DIST),
51
-		[],
52
-		[],
53
-		_DIR_PLUGINS_DIST,
54
-		'afficher_nom_plugin'
55
-	);
45
+    // installer les extensions
46
+    include_spip('inc/plugin');
47
+    $afficher = charger_fonction('afficher_liste', 'plugins');
48
+    echo $afficher(
49
+        self(),
50
+        liste_plugin_files(_DIR_PLUGINS_DIST),
51
+        [],
52
+        [],
53
+        _DIR_PLUGINS_DIST,
54
+        'afficher_nom_plugin'
55
+    );
56 56
 
57
-	// si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape
58
-	// car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour)
59
-	// au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin
60
-	// et procede alors a l'installation
61
-	if (
62
-		!isset($GLOBALS['meta']['version_installee'])
63
-		or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee'])))
64
-	) {
65
-		plugin_installes_meta();
66
-	}
57
+    // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape
58
+    // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour)
59
+    // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin
60
+    // et procede alors a l'installation
61
+    if (
62
+        !isset($GLOBALS['meta']['version_installee'])
63
+        or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee'])))
64
+    ) {
65
+        plugin_installes_meta();
66
+    }
67 67
 
68
-	// mettre a jour si necessaire l'adresse du site
69
-	// securite si on arrive plus a se loger
70
-	include_spip('inc/config');
71
-	appliquer_adresse_site('');
68
+    // mettre a jour si necessaire l'adresse du site
69
+    // securite si on arrive plus a se loger
70
+    include_spip('inc/config');
71
+    appliquer_adresse_site('');
72 72
 
73
-	// aller a la derniere etape qui clos l'install et redirige
74
-	$suite = "\n<input type='hidden' name='etape' value='fin' />"
75
-		. bouton_suivant(_T('login_espace_prive'));
73
+    // aller a la derniere etape qui clos l'install et redirige
74
+    $suite = "\n<input type='hidden' name='etape' value='fin' />"
75
+        . bouton_suivant(_T('login_espace_prive'));
76 76
 
77
-	echo generer_form_ecrire('install', $suite);
78
-	echo install_fin_html();
77
+    echo generer_form_ecrire('install', $suite);
78
+    echo install_fin_html();
79 79
 }
Please login to merge, or discard this patch.
ecrire/install/etape_ldap5.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -11,84 +11,84 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/headers');
17 17
 include_spip('auth/ldap');
18 18
 
19 19
 function install_etape_ldap5_dist() {
20
-	etape_ldap5_save();
21
-	etape_ldap5_suite();
20
+    etape_ldap5_save();
21
+    etape_ldap5_suite();
22 22
 }
23 23
 
24 24
 function etape_ldap5_save() {
25
-	$conn = null;
26
-	if (!@file_exists(_FILE_CONNECT_TMP)) {
27
-		redirige_url_ecrire('install');
28
-	}
25
+    $conn = null;
26
+    if (!@file_exists(_FILE_CONNECT_TMP)) {
27
+        redirige_url_ecrire('install');
28
+    }
29 29
 
30
-	ecrire_meta('ldap_statut_import', _request('statut_ldap'));
30
+    ecrire_meta('ldap_statut_import', _request('statut_ldap'));
31 31
 
32
-	lire_fichier(_FILE_CONNECT_TMP, $conn);
32
+    lire_fichier(_FILE_CONNECT_TMP, $conn);
33 33
 
34
-	if ($p = strpos($conn, "'');")) {
35
-		ecrire_fichier(
36
-			_FILE_CONNECT_TMP,
37
-			substr($conn, 0, $p + 1)
38
-			. _FILE_LDAP
39
-			. substr($conn, $p + 1)
40
-		);
41
-	}
34
+    if ($p = strpos($conn, "'');")) {
35
+        ecrire_fichier(
36
+            _FILE_CONNECT_TMP,
37
+            substr($conn, 0, $p + 1)
38
+            . _FILE_LDAP
39
+            . substr($conn, $p + 1)
40
+        );
41
+    }
42 42
 
43
-	$adresse_ldap = addcslashes(_request('adresse_ldap'), "'\\");
44
-	$login_ldap = addcslashes(_request('login_ldap'), "'\\");
45
-	$pass_ldap = addcslashes(_request('pass_ldap'), "'\\");
46
-	$port_ldap = addcslashes(_request('port_ldap'), "'\\");
47
-	$tls_ldap = addcslashes(_request('tls_ldap'), "'\\");
48
-	$protocole_ldap = addcslashes(_request('protocole_ldap'), "'\\");
49
-	$base_ldap = addcslashes(_request('base_ldap'), "'\\");
50
-	$base_ldap_text = addcslashes(_request('base_ldap_text'), "'\\");
43
+    $adresse_ldap = addcslashes(_request('adresse_ldap'), "'\\");
44
+    $login_ldap = addcslashes(_request('login_ldap'), "'\\");
45
+    $pass_ldap = addcslashes(_request('pass_ldap'), "'\\");
46
+    $port_ldap = addcslashes(_request('port_ldap'), "'\\");
47
+    $tls_ldap = addcslashes(_request('tls_ldap'), "'\\");
48
+    $protocole_ldap = addcslashes(_request('protocole_ldap'), "'\\");
49
+    $base_ldap = addcslashes(_request('base_ldap'), "'\\");
50
+    $base_ldap_text = addcslashes(_request('base_ldap_text'), "'\\");
51 51
 
52
-	$conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n"
53
-		. "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n"
54
-		. "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n"
55
-		. (($tls_ldap != 'oui') ? '' :
56
-			"@ldap_start_tls(\$GLOBALS['ldap_link']);\n")
57
-		. "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n";
52
+    $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n"
53
+        . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n"
54
+        . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n"
55
+        . (($tls_ldap != 'oui') ? '' :
56
+            "@ldap_start_tls(\$GLOBALS['ldap_link']);\n")
57
+        . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n";
58 58
 
59
-	$champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [];
60
-	$res = '';
61
-	foreach ($champs as $champ => $v) {
62
-		$nom = 'ldap_' . $champ;
63
-		$val = trim(_request($nom));
64
-		if (preg_match('/^\w*$/', $val)) {
65
-			if ($val) {
66
-				$val = _q($val);
67
-			}
68
-		} else {
69
-			$val = 'array(' . _q(preg_split('/\W+/', $val)) . ')';
70
-		};
71
-		if ($val) {
72
-			$res .= "'$champ' => " . $val . ',';
73
-		}
74
-	}
75
-	$conn .= "\$GLOBALS['ldap_champs'] = array($res);\n";
59
+    $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [];
60
+    $res = '';
61
+    foreach ($champs as $champ => $v) {
62
+        $nom = 'ldap_' . $champ;
63
+        $val = trim(_request($nom));
64
+        if (preg_match('/^\w*$/', $val)) {
65
+            if ($val) {
66
+                $val = _q($val);
67
+            }
68
+        } else {
69
+            $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')';
70
+        };
71
+        if ($val) {
72
+            $res .= "'$champ' => " . $val . ',';
73
+        }
74
+    }
75
+    $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n";
76 76
 
77
-	install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn);
77
+    install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn);
78 78
 }
79 79
 
80 80
 function etape_ldap5_suite() {
81
-	echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
81
+    echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
82 82
 
83
-	echo info_etape(
84
-		_T('info_ldap_ok'),
85
-		info_progression_etape(5, 'etape_ldap', 'install/')
86
-	);
83
+    echo info_etape(
84
+        _T('info_ldap_ok'),
85
+        info_progression_etape(5, 'etape_ldap', 'install/')
86
+    );
87 87
 
88
-	echo generer_form_ecrire('install', (
89
-		"<input type='hidden' name='etape' value='3' />" .
90
-		"<input type='hidden' name='ldap_present' value='true' />"
91
-		. bouton_suivant()));
88
+    echo generer_form_ecrire('install', (
89
+        "<input type='hidden' name='etape' value='3' />" .
90
+        "<input type='hidden' name='ldap_present' value='true' />"
91
+        . bouton_suivant()));
92 92
 
93
-	echo install_fin_html();
93
+    echo install_fin_html();
94 94
 }
Please login to merge, or discard this patch.
prive/formulaires/configurer_relayeur.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -11,140 +11,140 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/presentation');
17 17
 include_spip('inc/config');
18 18
 
19 19
 function formulaires_configurer_relayeur_charger_dist() {
20
-	$valeurs = [
21
-		'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')),
22
-		'http_noproxy' => lire_config('http_noproxy', ''),
23
-		'test_proxy' => 'https://www.spip.net/',
24
-	];
20
+    $valeurs = [
21
+        'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')),
22
+        'http_noproxy' => lire_config('http_noproxy', ''),
23
+        'test_proxy' => 'https://www.spip.net/',
24
+    ];
25 25
 
26
-	return $valeurs;
26
+    return $valeurs;
27 27
 }
28 28
 
29 29
 function formulaires_configurer_relayeur_verifier_dist() {
30
-	$erreurs = [];
31
-	$http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', ''));
32
-	$http_noproxy = _request('http_noproxy');
33
-
34
-	if ($http_proxy and !tester_url_absolue($http_proxy)) {
35
-		$erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme');
36
-	}
37
-
38
-	if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) {
39
-		if (!$http_proxy) {
40
-			$erreurs['http_proxy'] = _T('info_obligatoire');
41
-		} else {
42
-			include_spip('inc/distant');
43
-			$test_proxy = _request('test_proxy');
44
-			$t = parse_url($test_proxy);
45
-			if (!@$t['host']) {
46
-				$erreurs['test_proxy'] = _T('info_adresse_non_indiquee');
47
-			} else {
48
-				include_spip('inc/texte'); // pour aide, couper, lang
49
-				$info = '';
50
-				if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) {
51
-					$info = '<strong>' . _T('page_pas_proxy') . '</strong><br />';
52
-				}
53
-
54
-				// il faut fausser le proxy actuel pour faire le test !
55
-				$cur_http_proxy = $GLOBALS['meta']['http_proxy'];
56
-				$cur_http_noproxy = $GLOBALS['meta']['http_noproxy'];
57
-				$GLOBALS['meta']['http_proxy'] = $http_proxy;
58
-				$GLOBALS['meta']['http_noproxy'] = $http_noproxy;
59
-				$page = recuperer_url($test_proxy, ['transcoder' => true]);
60
-				$page = $page['page'] ?? '';
61
-				$GLOBALS['meta']['http_proxy'] = $cur_http_proxy;
62
-				$GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy;
63
-				if ($page) {
64
-					$erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>';
65
-					$erreurs['message_erreur'] = '';
66
-				} else {
67
-					$erreurs['message_erreur'] = $info . _T(
68
-						'info_impossible_lire_page',
69
-						['test_proxy' => "<tt>$test_proxy</tt>"]
70
-					)
71
-						. ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.'
72
-						. aider('confhttpproxy');
73
-				}
74
-			}
75
-		}
76
-	}
77
-
78
-	return $erreurs;
30
+    $erreurs = [];
31
+    $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', ''));
32
+    $http_noproxy = _request('http_noproxy');
33
+
34
+    if ($http_proxy and !tester_url_absolue($http_proxy)) {
35
+        $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme');
36
+    }
37
+
38
+    if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) {
39
+        if (!$http_proxy) {
40
+            $erreurs['http_proxy'] = _T('info_obligatoire');
41
+        } else {
42
+            include_spip('inc/distant');
43
+            $test_proxy = _request('test_proxy');
44
+            $t = parse_url($test_proxy);
45
+            if (!@$t['host']) {
46
+                $erreurs['test_proxy'] = _T('info_adresse_non_indiquee');
47
+            } else {
48
+                include_spip('inc/texte'); // pour aide, couper, lang
49
+                $info = '';
50
+                if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) {
51
+                    $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />';
52
+                }
53
+
54
+                // il faut fausser le proxy actuel pour faire le test !
55
+                $cur_http_proxy = $GLOBALS['meta']['http_proxy'];
56
+                $cur_http_noproxy = $GLOBALS['meta']['http_noproxy'];
57
+                $GLOBALS['meta']['http_proxy'] = $http_proxy;
58
+                $GLOBALS['meta']['http_noproxy'] = $http_noproxy;
59
+                $page = recuperer_url($test_proxy, ['transcoder' => true]);
60
+                $page = $page['page'] ?? '';
61
+                $GLOBALS['meta']['http_proxy'] = $cur_http_proxy;
62
+                $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy;
63
+                if ($page) {
64
+                    $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>';
65
+                    $erreurs['message_erreur'] = '';
66
+                } else {
67
+                    $erreurs['message_erreur'] = $info . _T(
68
+                        'info_impossible_lire_page',
69
+                        ['test_proxy' => "<tt>$test_proxy</tt>"]
70
+                    )
71
+                        . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.'
72
+                        . aider('confhttpproxy');
73
+                }
74
+            }
75
+        }
76
+    }
77
+
78
+    return $erreurs;
79 79
 }
80 80
 
81 81
 function formulaires_configurer_relayeur_traiter_dist() {
82
-	$res = ['editable' => true];
82
+    $res = ['editable' => true];
83 83
 
84
-	$http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', ''));
85
-	$http_noproxy = _request('http_noproxy');
86
-	if ($http_proxy !== null) {
87
-		ecrire_meta('http_proxy', $http_proxy);
88
-	}
84
+    $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', ''));
85
+    $http_noproxy = _request('http_noproxy');
86
+    if ($http_proxy !== null) {
87
+        ecrire_meta('http_proxy', $http_proxy);
88
+    }
89 89
 
90
-	if ($http_noproxy !== null) {
91
-		ecrire_meta('http_noproxy', $http_noproxy);
92
-	}
90
+    if ($http_noproxy !== null) {
91
+        ecrire_meta('http_noproxy', $http_noproxy);
92
+    }
93 93
 
94
-	$res['message_ok'] = _T('config_info_enregistree');
94
+    $res['message_ok'] = _T('config_info_enregistree');
95 95
 
96
-	return $res;
96
+    return $res;
97 97
 }
98 98
 
99 99
 function relayeur_saisie_ou_config($http_proxy, $default) {
100
-	// http_proxy : ne pas prendre en compte la modif si le password est '****'
101
-	if (preg_match(',:\*\*\*\*@,', $http_proxy)) {
102
-		$http_proxy = $default;
103
-	}
100
+    // http_proxy : ne pas prendre en compte la modif si le password est '****'
101
+    if (preg_match(',:\*\*\*\*@,', $http_proxy)) {
102
+        $http_proxy = $default;
103
+    }
104 104
 
105
-	return $http_proxy;
105
+    return $http_proxy;
106 106
 }
107 107
 
108 108
 // Function glue_url : le pendant de parse_url
109 109
 function glue_url($url) {
110
-	if (!is_array($url)) {
111
-		return false;
112
-	}
113
-	// scheme
114
-	$uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : '';
115
-	// user & pass
116
-	if (!empty($url['user'])) {
117
-		$uri .= $url['user'] . ':' . $url['pass'] . '@';
118
-	}
119
-	// host
120
-	$uri .= $url['host'];
121
-	// port
122
-	$port = (!empty($url['port'])) ? ':' . $url['port'] : '';
123
-	$uri .= $port;
124
-	// path
125
-	$uri .= $url['path'];
110
+    if (!is_array($url)) {
111
+        return false;
112
+    }
113
+    // scheme
114
+    $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : '';
115
+    // user & pass
116
+    if (!empty($url['user'])) {
117
+        $uri .= $url['user'] . ':' . $url['pass'] . '@';
118
+    }
119
+    // host
120
+    $uri .= $url['host'];
121
+    // port
122
+    $port = (!empty($url['port'])) ? ':' . $url['port'] : '';
123
+    $uri .= $port;
124
+    // path
125
+    $uri .= $url['path'];
126 126
 // fragment or query
127
-	if (isset($url['fragment'])) {
128
-		$uri .= '#' . $url['fragment'];
129
-	} elseif (isset($url['query'])) {
130
-		$uri .= '?' . $url['query'];
131
-	}
127
+    if (isset($url['fragment'])) {
128
+        $uri .= '#' . $url['fragment'];
129
+    } elseif (isset($url['query'])) {
130
+        $uri .= '?' . $url['query'];
131
+    }
132 132
 
133
-	return $uri;
133
+    return $uri;
134 134
 }
135 135
 
136 136
 
137 137
 // Ne pas afficher la partie 'password' du proxy
138 138
 function no_password_proxy_url($http_proxy) {
139
-	if (
140
-		$http_proxy
141
-		and $p = @parse_url($http_proxy)
142
-		and isset($p['pass'])
143
-		and $p['pass']
144
-	) {
145
-		$p['pass'] = '****';
146
-		$http_proxy = glue_url($p);
147
-	}
148
-
149
-	return $http_proxy;
139
+    if (
140
+        $http_proxy
141
+        and $p = @parse_url($http_proxy)
142
+        and isset($p['pass'])
143
+        and $p['pass']
144
+    ) {
145
+        $p['pass'] = '****';
146
+        $http_proxy = glue_url($p);
147
+    }
148
+
149
+    return $http_proxy;
150 150
 }
Please login to merge, or discard this patch.
ecrire/balise/formulaire_admin.php 1 patch
Indentation   +148 added lines, -148 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
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *     Pile complétée du code compilé
43 43
  **/
44 44
 function balise_FORMULAIRE_ADMIN($p) {
45
-	return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
45
+    return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
46 46
 }
47 47
 
48 48
 /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  *   - chaîne vide sinon.
60 60
  */
61 61
 function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
62
-	return $args;
62
+    return $args;
63 63
 }
64 64
 
65 65
 
@@ -84,66 +84,66 @@  discard block
 block discarded – undo
84 84
  **/
85 85
 function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') {
86 86
 
87
-	static $dejafait = false;
87
+    static $dejafait = false;
88 88
 
89
-	if (empty($_COOKIE['spip_admin'])) {
90
-		return '';
91
-	}
89
+    if (empty($_COOKIE['spip_admin'])) {
90
+        return '';
91
+    }
92 92
 
93
-	if (!is_array($debug)) {
94
-		if ($dejafait) {
95
-			return '';
96
-		}
97
-	} else {
98
-		if ($dejafait) {
99
-			if (empty($debug['sourcefile'])) {
100
-				return '';
101
-			}
102
-			foreach ($debug['sourcefile'] as $k => $v) {
103
-				if (strpos($v, 'administration.') !== false) {
104
-					if (isset($debug['resultat'][$k . 'tout'])) {
105
-						return $debug['resultat'][$k . 'tout'];
106
-					}
107
-				}
108
-			}
93
+    if (!is_array($debug)) {
94
+        if ($dejafait) {
95
+            return '';
96
+        }
97
+    } else {
98
+        if ($dejafait) {
99
+            if (empty($debug['sourcefile'])) {
100
+                return '';
101
+            }
102
+            foreach ($debug['sourcefile'] as $k => $v) {
103
+                if (strpos($v, 'administration.') !== false) {
104
+                    if (isset($debug['resultat'][$k . 'tout'])) {
105
+                        return $debug['resultat'][$k . 'tout'];
106
+                    }
107
+                }
108
+            }
109 109
 
110
-			return '';
111
-		}
112
-	}
110
+            return '';
111
+        }
112
+    }
113 113
 
114
-	include_spip('inc/autoriser');
115
-	include_spip('base/abstract_sql');
114
+    include_spip('inc/autoriser');
115
+    include_spip('base/abstract_sql');
116 116
 
117 117
 
118
-	$dejafait = true;
118
+    $dejafait = true;
119 119
 
120
-	// Preparer le #ENV des boutons
120
+    // Preparer le #ENV des boutons
121 121
 
122
-	$env = admin_objet();
122
+    $env = admin_objet();
123 123
 
124
-	// Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
-	if (!$env) {
126
-		$env['ecrire'] = _DIR_RESTREINT_ABS;
127
-	}
124
+    // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
+    if (!$env) {
126
+        $env['ecrire'] = _DIR_RESTREINT_ABS;
127
+    }
128 128
 
129
-	$env['divclass'] = $float;
130
-	$env['lang'] = admin_lang();
131
-	$env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
-	$env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug());
133
-	$env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
-	$env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
129
+    $env['divclass'] = $float;
130
+    $env['lang'] = admin_lang();
131
+    $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
+    $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug());
133
+    $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
+    $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
135 135
 
136
-	if (empty($GLOBALS['use_cache'])) {
137
-		$env['use_cache'] = ' *';
138
-	}
136
+    if (empty($GLOBALS['use_cache'])) {
137
+        $env['use_cache'] = ' *';
138
+    }
139 139
 
140
-	if (isset($debug['validation'])) {
141
-		$env['xhtml_error'] = $debug['validation'];
142
-	}
140
+    if (isset($debug['validation'])) {
141
+        $env['xhtml_error'] = $debug['validation'];
142
+    }
143 143
 
144
-	$env['_pipelines']['formulaire_admin'] = [];
144
+    $env['_pipelines']['formulaire_admin'] = [];
145 145
 
146
-	return ['formulaires/administration', 0, $env];
146
+    return ['formulaires/administration', 0, $env];
147 147
 }
148 148
 
149 149
 
@@ -161,47 +161,47 @@  discard block
 block discarded – undo
161 161
  *     Tableau de l'environnement calculé
162 162
  **/
163 163
 function admin_objet() {
164
-	include_spip('inc/urls');
165
-	$env = [];
166
-
167
-	$trouver_table = charger_fonction('trouver_table', 'base');
168
-	$objets = urls_liste_objets(false);
169
-	$objets = array_diff($objets, ['rubrique']);
170
-	$objets = array_reverse($objets);
171
-	array_unshift($objets, 'rubrique');
172
-	foreach ($objets as $obj) {
173
-		$type = $obj;
174
-		if (
175
-			$type == objet_type($type, false)
176
-			and $_id_type = id_table_objet($type)
177
-			and isset($GLOBALS['contexte'][$_id_type])
178
-			and $id = $GLOBALS['contexte'][$_id_type]
179
-			and !is_array($id)
180
-			and $id = intval($id)
181
-			and $desc = $trouver_table(table_objet_sql($type))
182
-		) {
183
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
184
-			if ($id) {
185
-				$env[$_id_type] = $id;
186
-				$env['objet'] = $type;
187
-				$env['id_objet'] = $id;
188
-				$env['voir_' . $obj] =
189
-					str_replace('&amp;', '&', generer_objet_url($id, $obj, '', '', false));
190
-				if (
191
-					isset($desc['field']['id_rubrique'])
192
-					and $type != 'rubrique'
193
-				) {
194
-					unset($env['id_rubrique']);
195
-					unset($env['voir_rubrique']);
196
-					if (admin_preview($type, $id, $desc)) {
197
-						$env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
198
-					}
199
-				}
200
-			}
201
-		}
202
-	}
203
-
204
-	return $env;
164
+    include_spip('inc/urls');
165
+    $env = [];
166
+
167
+    $trouver_table = charger_fonction('trouver_table', 'base');
168
+    $objets = urls_liste_objets(false);
169
+    $objets = array_diff($objets, ['rubrique']);
170
+    $objets = array_reverse($objets);
171
+    array_unshift($objets, 'rubrique');
172
+    foreach ($objets as $obj) {
173
+        $type = $obj;
174
+        if (
175
+            $type == objet_type($type, false)
176
+            and $_id_type = id_table_objet($type)
177
+            and isset($GLOBALS['contexte'][$_id_type])
178
+            and $id = $GLOBALS['contexte'][$_id_type]
179
+            and !is_array($id)
180
+            and $id = intval($id)
181
+            and $desc = $trouver_table(table_objet_sql($type))
182
+        ) {
183
+            $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
184
+            if ($id) {
185
+                $env[$_id_type] = $id;
186
+                $env['objet'] = $type;
187
+                $env['id_objet'] = $id;
188
+                $env['voir_' . $obj] =
189
+                    str_replace('&amp;', '&', generer_objet_url($id, $obj, '', '', false));
190
+                if (
191
+                    isset($desc['field']['id_rubrique'])
192
+                    and $type != 'rubrique'
193
+                ) {
194
+                    unset($env['id_rubrique']);
195
+                    unset($env['voir_rubrique']);
196
+                    if (admin_preview($type, $id, $desc)) {
197
+                        $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
198
+                    }
199
+                }
200
+            }
201
+        }
202
+    }
203
+
204
+    return $env;
205 205
 }
206 206
 
207 207
 
@@ -219,30 +219,30 @@  discard block
 block discarded – undo
219 219
  *     - Tableau d'un élément sinon.
220 220
  **/
221 221
 function admin_preview($type, $id, $desc = null) {
222
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
223
-		return '';
224
-	}
225
-
226
-	if (!$desc) {
227
-		$trouver_table = charger_fonction('trouver_table', 'base');
228
-		$desc = $trouver_table(table_objet_sql($type));
229
-	}
230
-	if (!$desc or !isset($desc['field']['statut'])) {
231
-		return '';
232
-	}
233
-
234
-	include_spip('inc/autoriser');
235
-	if (!autoriser('previsualiser')) {
236
-		return '';
237
-	}
238
-
239
-	$notpub = sql_in('statut', ['prop', 'prive']);
240
-
241
-	if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
243
-	}
244
-
245
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
222
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
223
+        return '';
224
+    }
225
+
226
+    if (!$desc) {
227
+        $trouver_table = charger_fonction('trouver_table', 'base');
228
+        $desc = $trouver_table(table_objet_sql($type));
229
+    }
230
+    if (!$desc or !isset($desc['field']['statut'])) {
231
+        return '';
232
+    }
233
+
234
+    include_spip('inc/autoriser');
235
+    if (!autoriser('previsualiser')) {
236
+        return '';
237
+    }
238
+
239
+    $notpub = sql_in('statut', ['prop', 'prive']);
240
+
241
+    if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
+        $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
243
+    }
244
+
245
+    return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
246 246
 }
247 247
 
248 248
 
@@ -253,25 +253,25 @@  discard block
 block discarded – undo
253 253
  *     Code de langue
254 254
  **/
255 255
 function admin_lang() {
256
-	$alang = '';
257
-	if (!empty($_COOKIE['spip_admin'])) {
258
-		$email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
-		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
260
-		if (!$alang) {
261
-			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
262
-		}
263
-	}
264
-	if (!$alang) {
265
-		return '';
266
-	}
267
-
268
-	$l = lang_select($alang);
269
-	$alang = $GLOBALS['spip_lang'];
270
-	if ($l) {
271
-		lang_select();
272
-	}
273
-
274
-	return $alang;
256
+    $alang = '';
257
+    if (!empty($_COOKIE['spip_admin'])) {
258
+        $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
+        $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
260
+        if (!$alang) {
261
+            $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
262
+        }
263
+    }
264
+    if (!$alang) {
265
+        return '';
266
+    }
267
+
268
+    $l = lang_select($alang);
269
+    $alang = $GLOBALS['spip_lang'];
270
+    if ($l) {
271
+        lang_select();
272
+    }
273
+
274
+    return $alang;
275 275
 }
276 276
 
277 277
 /**
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
  **/
282 282
 function admin_valider() {
283 283
 
284
-	return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285
-		(parametre_url(self(), 'var_mode', 'debug', '&')
286
-			. '&var_mode_affiche=validation') :
287
-		('http://validator.w3.org/check?uri='
288
-			. rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
284
+    return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285
+        (parametre_url(self(), 'var_mode', 'debug', '&')
286
+            . '&var_mode_affiche=validation') :
287
+        ('http://validator.w3.org/check?uri='
288
+            . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
289 289
 }
290 290
 
291 291
 /**
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
  * @return string
295 295
  **/
296 296
 function admin_debug() {
297
-	return ((
298
-			(isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
299
-			or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
300
-			or (
301
-				defined('_VAR_MODE') and _VAR_MODE == 'debug'
302
-				and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
303
-			)
304
-		) and autoriser('debug')
305
-	)
306
-		? parametre_url(self(), 'var_mode', 'debug', '&') : '';
297
+    return ((
298
+            (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
299
+            or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
300
+            or (
301
+                defined('_VAR_MODE') and _VAR_MODE == 'debug'
302
+                and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
303
+            )
304
+        ) and autoriser('debug')
305
+    )
306
+        ? parametre_url(self(), 'var_mode', 'debug', '&') : '';
307 307
 }
Please login to merge, or discard this patch.
ecrire/balise/info_.php 1 patch
Indentation   +23 added lines, -23 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
 /**
@@ -40,29 +40,29 @@  discard block
 block discarded – undo
40 40
  *     Pile complétée par le code à générer
41 41
  */
42 42
 function balise_INFO__dist($p) {
43
-	$info = $p->nom_champ;
44
-	$type_objet = interprete_argument_balise(1, $p);
45
-	$id_objet = interprete_argument_balise(2, $p);
46
-	if ($info === 'INFO_' or !$type_objet or !$id_objet) {
47
-		$msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']);
48
-		erreur_squelette($msg, $p);
49
-		$p->interdire_scripts = true;
43
+    $info = $p->nom_champ;
44
+    $type_objet = interprete_argument_balise(1, $p);
45
+    $id_objet = interprete_argument_balise(2, $p);
46
+    if ($info === 'INFO_' or !$type_objet or !$id_objet) {
47
+        $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']);
48
+        erreur_squelette($msg, $p);
49
+        $p->interdire_scripts = true;
50 50
 
51
-		return $p;
52
-	} else {
53
-		// Récupérer tous les params à la suite de objet et id_objet
54
-		$_params = '[';
55
-		$nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus
56
-		for ($i = 3; $i < $nb_params; $i++) {
57
-			$_params .= interprete_argument_balise($i, $p) . ',';
58
-		}
59
-		$_params .= ']';
51
+        return $p;
52
+    } else {
53
+        // Récupérer tous les params à la suite de objet et id_objet
54
+        $_params = '[';
55
+        $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus
56
+        for ($i = 3; $i < $nb_params; $i++) {
57
+            $_params .= interprete_argument_balise($i, $p) . ',';
58
+        }
59
+        $_params .= ']';
60 60
 
61
-		$info_sql = strtolower(substr($info, 5));
62
-		$code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)";
63
-		$p->code = champ_sql($info, $p, $code);
64
-		$p->interdire_scripts = true;
61
+        $info_sql = strtolower(substr($info, 5));
62
+        $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)";
63
+        $p->code = champ_sql($info, $p, $code);
64
+        $p->interdire_scripts = true;
65 65
 
66
-		return $p;
67
-	}
66
+        return $p;
67
+    }
68 68
 }
Please login to merge, or discard this patch.
ecrire/action/menu_rubriques.php 1 patch
Indentation   +156 added lines, -156 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
 include_spip('inc/autoriser');
@@ -35,42 +35,42 @@  discard block
 block discarded – undo
35 35
  **/
36 36
 function action_menu_rubriques_dist() {
37 37
 
38
-	// si pas acces a ecrire, pas acces au menu
39
-	// on renvoi un 401 qui fait echouer la requete ajax silencieusement
40
-	if (!autoriser('ecrire')) {
41
-		$retour =
42
-		'<ul class="deroulant__sous-menu" data-profondeur="1">' .
43
-			'<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
44
-				'<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
45
-					'<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
46
-				'</a>' .
47
-			'</li>' .
48
-		'</ul>';
49
-		include_spip('inc/actions');
50
-		ajax_retour($retour);
51
-		exit;
52
-	}
53
-
54
-	if ($date = intval(_request('date'))) {
55
-		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
56
-	}
57
-
58
-	$r = gen_liste_rubriques();
59
-	if (
60
-		!$r
61
-		and isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
62
-		and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
63
-	) {
64
-		include_spip('inc/headers');
65
-		header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
66
-		http_response_code(304);
67
-		exit;
68
-	} else {
69
-		include_spip('inc/actions');
70
-		$ret = menu_rubriques();
71
-		ajax_retour($ret);
72
-		exit;
73
-	}
38
+    // si pas acces a ecrire, pas acces au menu
39
+    // on renvoi un 401 qui fait echouer la requete ajax silencieusement
40
+    if (!autoriser('ecrire')) {
41
+        $retour =
42
+        '<ul class="deroulant__sous-menu" data-profondeur="1">' .
43
+            '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
44
+                '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
45
+                    '<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
46
+                '</a>' .
47
+            '</li>' .
48
+        '</ul>';
49
+        include_spip('inc/actions');
50
+        ajax_retour($retour);
51
+        exit;
52
+    }
53
+
54
+    if ($date = intval(_request('date'))) {
55
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
56
+    }
57
+
58
+    $r = gen_liste_rubriques();
59
+    if (
60
+        !$r
61
+        and isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
62
+        and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
63
+    ) {
64
+        include_spip('inc/headers');
65
+        header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
66
+        http_response_code(304);
67
+        exit;
68
+    } else {
69
+        include_spip('inc/actions');
70
+        $ret = menu_rubriques();
71
+        ajax_retour($ret);
72
+        exit;
73
+    }
74 74
 }
75 75
 
76 76
 /**
@@ -84,44 +84,44 @@  discard block
 block discarded – undo
84 84
  *     Code HTML présentant la liste des rubriques
85 85
  **/
86 86
 function menu_rubriques($complet = true) {
87
-	$ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
88
-		. '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
89
-		. '<span class="libelle">' . _T('info_tout_site') . '</span>'
90
-		. '</a>'
91
-		. '</li>';
92
-
93
-	if (!$complet) {
94
-		return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
95
-	}
96
-
97
-	if (!isset($GLOBALS['db_art_cache'])) {
98
-		gen_liste_rubriques();
99
-	}
100
-	$arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
101
-
102
-	$total_lignes = $i = sizeof($arr_low);
103
-
104
-	if ($i > 0) {
105
-		$nb_col = min(8, ceil($total_lignes / 30));
106
-		if ($nb_col <= 1) {
107
-			$nb_col = ceil($total_lignes / 10);
108
-		}
109
-		foreach ($arr_low as $id_rubrique => $titre_rubrique) {
110
-			if (autoriser('voir', 'rubrique', $id_rubrique)) {
111
-				$ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
112
-				$i++;
113
-			}
114
-		}
115
-
116
-		$class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
117
-		$ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">"
118
-			. $ret
119
-			. "\n</ul>\n";
120
-	} else {
121
-		$ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
122
-	}
123
-
124
-	return $ret;
87
+    $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
88
+        . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
89
+        . '<span class="libelle">' . _T('info_tout_site') . '</span>'
90
+        . '</a>'
91
+        . '</li>';
92
+
93
+    if (!$complet) {
94
+        return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
95
+    }
96
+
97
+    if (!isset($GLOBALS['db_art_cache'])) {
98
+        gen_liste_rubriques();
99
+    }
100
+    $arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
101
+
102
+    $total_lignes = $i = sizeof($arr_low);
103
+
104
+    if ($i > 0) {
105
+        $nb_col = min(8, ceil($total_lignes / 30));
106
+        if ($nb_col <= 1) {
107
+            $nb_col = ceil($total_lignes / 10);
108
+        }
109
+        foreach ($arr_low as $id_rubrique => $titre_rubrique) {
110
+            if (autoriser('voir', 'rubrique', $id_rubrique)) {
111
+                $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
112
+                $i++;
113
+            }
114
+        }
115
+
116
+        $class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
117
+        $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">"
118
+            . $ret
119
+            . "\n</ul>\n";
120
+    } else {
121
+        $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
122
+    }
123
+
124
+    return $ret;
125 125
 }
126 126
 
127 127
 /**
@@ -142,48 +142,48 @@  discard block
 block discarded – undo
142 142
  *     Code HTML présentant la liste des rubriques
143 143
  **/
144 144
 function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) {
145
-	static $zmax = 6;
146
-	$profondeur_next = $profondeur + 1;
147
-
148
-	$nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
149
-		. '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
150
-		. "</a>\n";
151
-
152
-	// Limiter volontairement le nombre de sous-menus
153
-	if (!(--$zmax)) {
154
-		$zmax++;
155
-
156
-		return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
157
-	}
158
-
159
-	$arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
160
-	$i = sizeof($arr_rub);
161
-	if (!$i) {
162
-		$zmax++;
163
-
164
-		return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
165
-	}
166
-
167
-
168
-	$nb_col = 1;
169
-	if ($nb_rub = count($arr_rub)) {
170
-		$nb_col = min(10, max(1, ceil($nb_rub / 10)));
171
-	}
172
-	$class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
173
-	$ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">"
174
-	 . $nav
175
-	 . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">";
176
-	foreach ($arr_rub as $id_rub => $titre_rub) {
177
-		if (autoriser('voir', 'rubrique', $id_rub)) {
178
-			$titre = supprimer_numero(typo($titre_rub));
179
-			$ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next);
180
-			$i++;
181
-		}
182
-	}
183
-	$ret .= "</ul></li>\n";
184
-	$zmax++;
185
-
186
-	return $ret;
145
+    static $zmax = 6;
146
+    $profondeur_next = $profondeur + 1;
147
+
148
+    $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
149
+        . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
150
+        . "</a>\n";
151
+
152
+    // Limiter volontairement le nombre de sous-menus
153
+    if (!(--$zmax)) {
154
+        $zmax++;
155
+
156
+        return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
157
+    }
158
+
159
+    $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
160
+    $i = sizeof($arr_rub);
161
+    if (!$i) {
162
+        $zmax++;
163
+
164
+        return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
165
+    }
166
+
167
+
168
+    $nb_col = 1;
169
+    if ($nb_rub = count($arr_rub)) {
170
+        $nb_col = min(10, max(1, ceil($nb_rub / 10)));
171
+    }
172
+    $class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
173
+    $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">"
174
+        . $nav
175
+        . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">";
176
+    foreach ($arr_rub as $id_rub => $titre_rub) {
177
+        if (autoriser('voir', 'rubrique', $id_rub)) {
178
+            $titre = supprimer_numero(typo($titre_rub));
179
+            $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next);
180
+            $i++;
181
+        }
182
+    }
183
+    $ret .= "</ul></li>\n";
184
+    $zmax++;
185
+
186
+    return $ret;
187 187
 }
188 188
 
189 189
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  *     Liste des rubriques enfants de la rubrique (et leur titre)
202 202
  **/
203 203
 function extraire_article($id_p, $t) {
204
-	return array_key_exists($id_p, $t) ? $t[$id_p] : [];
204
+    return array_key_exists($id_p, $t) ? $t[$id_p] : [];
205 205
 }
206 206
 
207 207
 /**
@@ -217,42 +217,42 @@  discard block
 block discarded – undo
217 217
  **/
218 218
 function gen_liste_rubriques() {
219 219
 
220
-	$cache = null;
221
-	include_spip('inc/config');
222
-	// ici, un petit fichier cache ne fait pas de mal
223
-	$last = lire_config('date_calcul_rubriques', 0);
224
-	if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
225
-		[$date, $GLOBALS['db_art_cache']] = @unserialize($cache);
226
-		if ($date == $last) {
227
-			return false;
228
-		} // c'etait en cache :-)
229
-	}
230
-	// se restreindre aux rubriques utilisees recemment +secteurs
231
-
232
-	$where = sql_in_select(
233
-		'id_rubrique',
234
-		'id_rubrique',
235
-		'spip_rubriques',
236
-		'',
237
-		'',
238
-		'id_parent=0 DESC, date DESC',
239
-		_CACHE_RUBRIQUES_MAX
240
-	);
241
-
242
-	// puis refaire la requete pour avoir l'ordre alphabetique
243
-
244
-	$res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre');
245
-
246
-	// il ne faut pas filtrer le autoriser voir ici
247
-	// car on met le resultat en cache, commun a tout le monde
248
-	$GLOBALS['db_art_cache'] = [];
249
-	while ($r = sql_fetch($res)) {
250
-		$t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
251
-		$GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
252
-	}
253
-
254
-	$t = [$last ?: time(), $GLOBALS['db_art_cache']];
255
-	ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
256
-
257
-	return true;
220
+    $cache = null;
221
+    include_spip('inc/config');
222
+    // ici, un petit fichier cache ne fait pas de mal
223
+    $last = lire_config('date_calcul_rubriques', 0);
224
+    if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
225
+        [$date, $GLOBALS['db_art_cache']] = @unserialize($cache);
226
+        if ($date == $last) {
227
+            return false;
228
+        } // c'etait en cache :-)
229
+    }
230
+    // se restreindre aux rubriques utilisees recemment +secteurs
231
+
232
+    $where = sql_in_select(
233
+        'id_rubrique',
234
+        'id_rubrique',
235
+        'spip_rubriques',
236
+        '',
237
+        '',
238
+        'id_parent=0 DESC, date DESC',
239
+        _CACHE_RUBRIQUES_MAX
240
+    );
241
+
242
+    // puis refaire la requete pour avoir l'ordre alphabetique
243
+
244
+    $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre');
245
+
246
+    // il ne faut pas filtrer le autoriser voir ici
247
+    // car on met le resultat en cache, commun a tout le monde
248
+    $GLOBALS['db_art_cache'] = [];
249
+    while ($r = sql_fetch($res)) {
250
+        $t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
251
+        $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
252
+    }
253
+
254
+    $t = [$last ?: time(), $GLOBALS['db_art_cache']];
255
+    ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
256
+
257
+    return true;
258 258
 }
Please login to merge, or discard this patch.
ecrire/action/redirect.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 /**
@@ -36,56 +36,56 @@  discard block
 block discarded – undo
36 36
  *   ```
37 37
  **/
38 38
 function action_redirect_dist() {
39
-	$type = _request('type');
40
-	$id = intval(_request('id'));
41
-	$page = false;
39
+    $type = _request('type');
40
+    $id = intval(_request('id'));
41
+    $page = false;
42 42
 
43
-	// verifier le type ou page transmis
44
-	if (!preg_match('/^\w+$/', $type)) {
45
-		$page = _request('page');
46
-		if (!preg_match('/^\w+$/', $page)) {
47
-			return;
48
-		}
49
-	}
43
+    // verifier le type ou page transmis
44
+    if (!preg_match('/^\w+$/', $type)) {
45
+        $page = _request('page');
46
+        if (!preg_match('/^\w+$/', $page)) {
47
+            return;
48
+        }
49
+    }
50 50
 
51
-	if ($var_mode = _request('var_mode')) {
52
-		// forcer la mise a jour de l'url de cet objet !
53
-		if (!defined('_VAR_URLS')) {
54
-			define('_VAR_URLS', true);
55
-		}
56
-	}
51
+    if ($var_mode = _request('var_mode')) {
52
+        // forcer la mise a jour de l'url de cet objet !
53
+        if (!defined('_VAR_URLS')) {
54
+            define('_VAR_URLS', true);
55
+        }
56
+    }
57 57
 
58
-	if ($page) {
59
-		$url = generer_url_public($page, '', true);
60
-	} else {
61
-		$url = calculer_url_redirect_entite($type, $id, $var_mode);
62
-	}
58
+    if ($page) {
59
+        $url = generer_url_public($page, '', true);
60
+    } else {
61
+        $url = calculer_url_redirect_entite($type, $id, $var_mode);
62
+    }
63 63
 
64
-	$status = '302';
65
-	if ($url) {
66
-		if ($var_mode) {
67
-			$url = parametre_url($url, 'var_mode', $var_mode, '&');
68
-		}
64
+    $status = '302';
65
+    if ($url) {
66
+        if ($var_mode) {
67
+            $url = parametre_url($url, 'var_mode', $var_mode, '&');
68
+        }
69 69
 
70
-		if (
71
-			$var_mode == 'preview'
72
-			and defined('_PREVIEW_TOKEN')
73
-			and _PREVIEW_TOKEN
74
-			and autoriser('previsualiser')
75
-		) {
76
-			include_spip('inc/securiser_action');
77
-			$token = calculer_token_previsu($url);
78
-			$url = parametre_url($url, 'var_previewtoken', $token);
79
-		}
70
+        if (
71
+            $var_mode == 'preview'
72
+            and defined('_PREVIEW_TOKEN')
73
+            and _PREVIEW_TOKEN
74
+            and autoriser('previsualiser')
75
+        ) {
76
+            include_spip('inc/securiser_action');
77
+            $token = calculer_token_previsu($url);
78
+            $url = parametre_url($url, 'var_previewtoken', $token);
79
+        }
80 80
 
81
-		if (_request('status') and _request('status') == '301') {
82
-			$status = '301';
83
-		}
84
-	} else {
85
-		$url = generer_url_public('404', '', true);
86
-	}
81
+        if (_request('status') and _request('status') == '301') {
82
+            $status = '301';
83
+        }
84
+    } else {
85
+        $url = generer_url_public('404', '', true);
86
+    }
87 87
 
88
-	redirige_par_entete(str_replace('&amp;', '&', $url), '', $status);
88
+    redirige_par_entete(str_replace('&amp;', '&', $url), '', $status);
89 89
 }
90 90
 
91 91
 /**
@@ -100,35 +100,35 @@  discard block
 block discarded – undo
100 100
  * @return string|null
101 101
  */
102 102
 function calculer_url_redirect_entite($type, $id, $var_mode) {
103
-	$desc = null;
104
-	$publie = null;
105
-	$url = null;
106
-	// invalider le cache à chaque modif en bdd
107
-	$date = 0;
108
-	if (isset($GLOBALS['meta']['derniere_modif'])) {
109
-		$date = $GLOBALS['meta']['derniere_modif'];
110
-	}
111
-	$key = "url-$date-$type-$id";
103
+    $desc = null;
104
+    $publie = null;
105
+    $url = null;
106
+    // invalider le cache à chaque modif en bdd
107
+    $date = 0;
108
+    if (isset($GLOBALS['meta']['derniere_modif'])) {
109
+        $date = $GLOBALS['meta']['derniere_modif'];
110
+    }
111
+    $key = "url-$date-$type-$id";
112 112
 
113
-	// Obtenir l’url et si elle est publié du cache memoization
114
-	if (function_exists('cache_get') and $desc = cache_get($key)) {
115
-		[$url, $publie] = $desc;
116
-	}
117
-	// Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie
118
-	if (empty($desc) or $var_mode) {
119
-		$publie = objet_test_si_publie($type, $id);
120
-		$url = generer_objet_url_absolue($id, $type, '', '', true);
121
-		if (function_exists('cache_set')) {
122
-			cache_set($key, [$url, $publie], 3600);
123
-		}
124
-	}
113
+    // Obtenir l’url et si elle est publié du cache memoization
114
+    if (function_exists('cache_get') and $desc = cache_get($key)) {
115
+        [$url, $publie] = $desc;
116
+    }
117
+    // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie
118
+    if (empty($desc) or $var_mode) {
119
+        $publie = objet_test_si_publie($type, $id);
120
+        $url = generer_objet_url_absolue($id, $type, '', '', true);
121
+        if (function_exists('cache_set')) {
122
+            cache_set($key, [$url, $publie], 3600);
123
+        }
124
+    }
125 125
 
126
-	// On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation
127
-	if ($publie) {
128
-		return $url;
129
-	} elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) {
130
-		return $url;
131
-	}
126
+    // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation
127
+    if ($publie) {
128
+        return $url;
129
+    } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) {
130
+        return $url;
131
+    }
132 132
 
133
-	return;
133
+    return;
134 134
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_liste.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 
@@ -27,90 +27,90 @@  discard block
 block discarded – undo
27 27
  * @return string
28 28
  */
29 29
 function plugins_afficher_liste_dist(
30
-	$url_page,
31
-	$liste_plugins,
32
-	$liste_plugins_checked,
33
-	$liste_plugins_actifs,
34
-	$dir_plugins = _DIR_PLUGINS,
35
-	$afficher_un = 'afficher_plugin'
30
+    $url_page,
31
+    $liste_plugins,
32
+    $liste_plugins_checked,
33
+    $liste_plugins_actifs,
34
+    $dir_plugins = _DIR_PLUGINS,
35
+    $afficher_un = 'afficher_plugin'
36 36
 ) {
37
-	$get_infos = charger_fonction('get_infos', 'plugins');
38
-	$ligne_plug = charger_fonction($afficher_un, 'plugins');
37
+    $get_infos = charger_fonction('get_infos', 'plugins');
38
+    $ligne_plug = charger_fonction($afficher_un, 'plugins');
39 39
 
40
-	$all_infos = $get_infos($liste_plugins, false, $dir_plugins);
40
+    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
41 41
 
42
-	$all_infos = pipeline(
43
-		'filtrer_liste_plugins',
44
-		[
45
-			'args' => [
46
-				'liste_plugins' => $liste_plugins,
47
-				'liste_plugins_checked' => $liste_plugins_checked,
48
-				'liste_plugins_actifs' => $liste_plugins_actifs,
49
-				'dir_plugins' => $dir_plugins
50
-			],
51
-			'data' => $all_infos
52
-		]
53
-	);
42
+    $all_infos = pipeline(
43
+        'filtrer_liste_plugins',
44
+        [
45
+            'args' => [
46
+                'liste_plugins' => $liste_plugins,
47
+                'liste_plugins_checked' => $liste_plugins_checked,
48
+                'liste_plugins_actifs' => $liste_plugins_actifs,
49
+                'dir_plugins' => $dir_plugins
50
+            ],
51
+            'data' => $all_infos
52
+        ]
53
+    );
54 54
 
55
-	$liste_plugins = array_flip($liste_plugins);
56
-	foreach ($liste_plugins as $chemin => $v) {
57
-		// des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
-		if (isset($all_infos[$chemin])) {
59
-			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
-		} else {
61
-			unset($liste_plugins[$chemin]);
62
-		}
63
-	}
64
-	asort($liste_plugins);
65
-	$exposed = urldecode(_request('plugin') ?? '');
55
+    $liste_plugins = array_flip($liste_plugins);
56
+    foreach ($liste_plugins as $chemin => $v) {
57
+        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
+        if (isset($all_infos[$chemin])) {
59
+            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
+        } else {
61
+            unset($liste_plugins[$chemin]);
62
+        }
63
+    }
64
+    asort($liste_plugins);
65
+    $exposed = urldecode(_request('plugin') ?? '');
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
68
-	$fast_liste_plugins_actifs = [];
69
-	$fast_liste_plugins_checked = [];
70
-	if (is_array($liste_plugins_actifs)) {
71
-		$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
-	}
73
-	if (is_array($liste_plugins_checked)) {
74
-		$fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
-	}
67
+    $block_par_lettre = false;//count($liste_plugins)>10;
68
+    $fast_liste_plugins_actifs = [];
69
+    $fast_liste_plugins_checked = [];
70
+    if (is_array($liste_plugins_actifs)) {
71
+        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
+    }
73
+    if (is_array($liste_plugins_checked)) {
74
+        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
+    }
76 76
 
77
-	$res = '';
78
-	$block = '';
79
-	$initiale = '';
80
-	$block_actif = false;
81
-	foreach ($liste_plugins as $plug => $nom) {
82
-		if (($i = substr($nom, 0, 1)) !== $initiale) {
83
-			$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
-			$initiale = $i;
85
-			$block = '';
86
-			$block_actif = false;
87
-		}
88
-		// le rep suivant
89
-		$actif = isset($fast_liste_plugins_actifs[$plug]);
90
-		$checked = isset($fast_liste_plugins_checked[$plug]);
91
-		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
93
-			$dir_plugins,
94
-			strlen(_DIR_RACINE)
95
-		) . $plug));
96
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
97
-	}
98
-	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99
-	$class = basename($dir_plugins);
77
+    $res = '';
78
+    $block = '';
79
+    $initiale = '';
80
+    $block_actif = false;
81
+    foreach ($liste_plugins as $plug => $nom) {
82
+        if (($i = substr($nom, 0, 1)) !== $initiale) {
83
+            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
+            $initiale = $i;
85
+            $block = '';
86
+            $block_actif = false;
87
+        }
88
+        // le rep suivant
89
+        $actif = isset($fast_liste_plugins_actifs[$plug]);
90
+        $checked = isset($fast_liste_plugins_checked[$plug]);
91
+        $block_actif = $block_actif | $actif;
92
+        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
93
+            $dir_plugins,
94
+            strlen(_DIR_RACINE)
95
+        ) . $plug));
96
+        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
97
+    }
98
+    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99
+    $class = basename($dir_plugins);
100 100
 
101
-	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
101
+    return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
102 102
 }
103 103
 
104 104
 
105 105
 function affiche_block_initiale($initiale, $block, $block_actif) {
106
-	if (strlen($block)) {
107
-		return "<li class='item'>"
108
-		. bouton_block_depliable($initiale, $block_actif ? true : false)
109
-		. debut_block_depliable($block_actif)
110
-		. "<ul>$block</ul>"
111
-		. fin_block()
112
-		. '</li>';
113
-	}
106
+    if (strlen($block)) {
107
+        return "<li class='item'>"
108
+        . bouton_block_depliable($initiale, $block_actif ? true : false)
109
+        . debut_block_depliable($block_actif)
110
+        . "<ul>$block</ul>"
111
+        . fin_block()
112
+        . '</li>';
113
+    }
114 114
 
115
-	return '';
115
+    return '';
116 116
 }
Please login to merge, or discard this patch.