Completed
Push — master ( 3caaa9...7e8601 )
by cam
01:42
created
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.
ecrire/install/etape_chmod.php 1 patch
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 if (defined('_TEST_DIRS')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 define('_TEST_DIRS', '1');
21 21
 
@@ -26,42 +26,42 @@  discard block
 block discarded – undo
26 26
 // Tente d'ecrire
27 27
 //
28 28
 function test_ecrire($my_dir) {
29
-	static $chmod = 0;
30
-
31
-	$ok = false;
32
-	$script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF'];
33
-	$self = basename($script);
34
-	$uid = @fileowner('.');
35
-	$uid2 = @fileowner($self);
36
-	$gid = @filegroup('.');
37
-	$gid2 = @filegroup($self);
38
-	$perms = @fileperms($self);
39
-
40
-	// Comparer l'appartenance d'un fichier cree par PHP
41
-	// avec celle du script et du repertoire courant
42
-	if (!$chmod) {
43
-		@rmdir('test');
44
-		spip_unlink('test'); // effacer au cas ou
45
-		@touch('test');
46
-		if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) {
47
-			$chmod = 0700;
48
-		} else {
49
-			if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) {
50
-				$chmod = 0770;
51
-			} else {
52
-				$chmod = 0777;
53
-			}
54
-		}
55
-		// Appliquer de plus les droits d'acces du script
56
-		if ($perms > 0) {
57
-			$perms = ($perms & 0777) | (($perms & 0444) >> 2);
58
-			$chmod |= $perms;
59
-		}
60
-		spip_unlink('test');
61
-	}
62
-	$ok = is_dir($my_dir) && is_writable($my_dir);
63
-
64
-	return $ok ? $chmod : false;
29
+    static $chmod = 0;
30
+
31
+    $ok = false;
32
+    $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF'];
33
+    $self = basename($script);
34
+    $uid = @fileowner('.');
35
+    $uid2 = @fileowner($self);
36
+    $gid = @filegroup('.');
37
+    $gid2 = @filegroup($self);
38
+    $perms = @fileperms($self);
39
+
40
+    // Comparer l'appartenance d'un fichier cree par PHP
41
+    // avec celle du script et du repertoire courant
42
+    if (!$chmod) {
43
+        @rmdir('test');
44
+        spip_unlink('test'); // effacer au cas ou
45
+        @touch('test');
46
+        if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) {
47
+            $chmod = 0700;
48
+        } else {
49
+            if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) {
50
+                $chmod = 0770;
51
+            } else {
52
+                $chmod = 0777;
53
+            }
54
+        }
55
+        // Appliquer de plus les droits d'acces du script
56
+        if ($perms > 0) {
57
+            $perms = ($perms & 0777) | (($perms & 0444) >> 2);
58
+            $chmod |= $perms;
59
+        }
60
+        spip_unlink('test');
61
+    }
62
+    $ok = is_dir($my_dir) && is_writable($my_dir);
63
+
64
+    return $ok ? $chmod : false;
65 65
 }
66 66
 
67 67
 //
@@ -71,84 +71,84 @@  discard block
 block discarded – undo
71 71
 
72 72
 function install_etape_chmod_dist() {
73 73
 
74
-	$continuer = null;
75
-	$test_dir = _request('test_dir');
76
-	$chmod = 0;
77
-
78
-	if ($test_dir) {
79
-		if (substr($test_dir, -1) !== '/') {
80
-			$test_dir .= '/';
81
-		}
82
-		if (!in_array($test_dir, $GLOBALS['test_dirs'])) {
83
-			$GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir;
84
-		}
85
-	} else {
86
-		if (!_FILE_CONNECT) {
87
-			$GLOBALS['test_dirs'][] = _DIR_CONNECT;
88
-			$GLOBALS['test_dirs'][] = _DIR_CHMOD;
89
-		}
90
-	}
91
-
92
-	$bad_dirs = [];
93
-	$absent_dirs = [];
94
-
95
-	foreach ($GLOBALS['test_dirs'] as $i => $my_dir) {
96
-		$test = test_ecrire($my_dir);
97
-		if (!$test) {
98
-			$m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir);
99
-			if (@file_exists($my_dir)) {
100
-				$bad_dirs['<li>' . $m . '</li>'] = 1;
101
-			} else {
102
-				$absent_dirs['<li>' . $m . '</li>'] = 1;
103
-			}
104
-		} else {
105
-			$chmod = max($chmod, $test);
106
-		}
107
-	}
108
-
109
-	if ($bad_dirs or $absent_dirs) {
110
-		if (!_FILE_CONNECT) {
111
-			$titre = _T('dirs_preliminaire');
112
-			$continuer = ' ' . _T('dirs_commencer') . '.';
113
-		} else {
114
-			$titre = _T('dirs_probleme_droits');
115
-		}
116
-
117
-
118
-		$res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n";
119
-
120
-		if ($bad_dirs) {
121
-			$res .=
122
-				_T(
123
-					'dirs_repertoires_suivants',
124
-					['bad_dirs' => join("\n", array_keys($bad_dirs))]
125
-				) .
126
-				'<b>' . _T('login_recharger') . '</b>.';
127
-		}
128
-
129
-		if ($absent_dirs) {
130
-			$res .=
131
-				_T(
132
-					'dirs_repertoires_absents',
133
-					['bad_dirs' => join("\n", array_keys($absent_dirs))]
134
-				) .
135
-				'<b>' . _T('login_recharger') . '</b>.';
136
-		}
137
-		$res = '<p>' . $continuer . $res . aider('install0', true) . '</p>';
138
-
139
-		$t = _T('login_recharger');
140
-		$t = (!$test_dir ? '' :
141
-				"<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />")
142
-			. "<input type='hidden' name='etape' value='chmod' />"
143
-			. "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>";
144
-
145
-		echo minipres($titre, $res . generer_form_ecrire('install', $t));
146
-	} else {
147
-		$deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT));
148
-		if (!$deja) {
149
-			redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod);
150
-		} else {
151
-			redirige_url_ecrire();
152
-		}
153
-	}
74
+    $continuer = null;
75
+    $test_dir = _request('test_dir');
76
+    $chmod = 0;
77
+
78
+    if ($test_dir) {
79
+        if (substr($test_dir, -1) !== '/') {
80
+            $test_dir .= '/';
81
+        }
82
+        if (!in_array($test_dir, $GLOBALS['test_dirs'])) {
83
+            $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir;
84
+        }
85
+    } else {
86
+        if (!_FILE_CONNECT) {
87
+            $GLOBALS['test_dirs'][] = _DIR_CONNECT;
88
+            $GLOBALS['test_dirs'][] = _DIR_CHMOD;
89
+        }
90
+    }
91
+
92
+    $bad_dirs = [];
93
+    $absent_dirs = [];
94
+
95
+    foreach ($GLOBALS['test_dirs'] as $i => $my_dir) {
96
+        $test = test_ecrire($my_dir);
97
+        if (!$test) {
98
+            $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir);
99
+            if (@file_exists($my_dir)) {
100
+                $bad_dirs['<li>' . $m . '</li>'] = 1;
101
+            } else {
102
+                $absent_dirs['<li>' . $m . '</li>'] = 1;
103
+            }
104
+        } else {
105
+            $chmod = max($chmod, $test);
106
+        }
107
+    }
108
+
109
+    if ($bad_dirs or $absent_dirs) {
110
+        if (!_FILE_CONNECT) {
111
+            $titre = _T('dirs_preliminaire');
112
+            $continuer = ' ' . _T('dirs_commencer') . '.';
113
+        } else {
114
+            $titre = _T('dirs_probleme_droits');
115
+        }
116
+
117
+
118
+        $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n";
119
+
120
+        if ($bad_dirs) {
121
+            $res .=
122
+                _T(
123
+                    'dirs_repertoires_suivants',
124
+                    ['bad_dirs' => join("\n", array_keys($bad_dirs))]
125
+                ) .
126
+                '<b>' . _T('login_recharger') . '</b>.';
127
+        }
128
+
129
+        if ($absent_dirs) {
130
+            $res .=
131
+                _T(
132
+                    'dirs_repertoires_absents',
133
+                    ['bad_dirs' => join("\n", array_keys($absent_dirs))]
134
+                ) .
135
+                '<b>' . _T('login_recharger') . '</b>.';
136
+        }
137
+        $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>';
138
+
139
+        $t = _T('login_recharger');
140
+        $t = (!$test_dir ? '' :
141
+                "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />")
142
+            . "<input type='hidden' name='etape' value='chmod' />"
143
+            . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>";
144
+
145
+        echo minipres($titre, $res . generer_form_ecrire('install', $t));
146
+    } else {
147
+        $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT));
148
+        if (!$deja) {
149
+            redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod);
150
+        } else {
151
+            redirige_url_ecrire();
152
+        }
153
+    }
154 154
 }
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.
prive/formulaires/login.php 1 patch
Indentation   +249 added lines, -249 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('base/abstract_sql');
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
  *     true si espace privé, false sinon.
32 32
  **/
33 33
 function is_url_prive($cible) {
34
-	include_spip('inc/filtres_mini');
35
-	$path = parse_url(tester_url_absolue($cible) ? $cible : url_absolue($cible));
36
-	$path = ($path['path'] ?? '');
34
+    include_spip('inc/filtres_mini');
35
+    $path = parse_url(tester_url_absolue($cible) ? $cible : url_absolue($cible));
36
+    $path = ($path['path'] ?? '');
37 37
 
38
-	return strncmp(substr($path, -strlen(_DIR_RESTREINT_ABS)), _DIR_RESTREINT_ABS, strlen(_DIR_RESTREINT_ABS)) == 0;
38
+    return strncmp(substr($path, -strlen(_DIR_RESTREINT_ABS)), _DIR_RESTREINT_ABS, strlen(_DIR_RESTREINT_ABS)) == 0;
39 39
 }
40 40
 
41 41
 /**
@@ -60,111 +60,111 @@  discard block
 block discarded – undo
60 60
  *     Environnement du formulaire
61 61
  **/
62 62
 function formulaires_login_charger_dist($cible = '', $options = [], $deprecated = null) {
63
-	$erreur = _request('var_erreur');
64
-
65
-	if (!is_array($options)) {
66
-		$options = [
67
-			'login' => $options,
68
-			'prive' => $deprecated
69
-		];
70
-	}
71
-
72
-	$login = (empty($options['login']) ? '' : $options['login']);
73
-	$prive = (empty($options['prive']) ? null : $options['prive']);
74
-	// conserver le fonctionnement historique
75
-	if (!isset($options['autofocus'])) {
76
-		$options['autofocus'] = true;
77
-	}
78
-
79
-	if (!$login) {
80
-		$login = strval(_request('var_login'));
81
-	}
82
-	// si on est deja identifie
83
-	if (!$login and isset($GLOBALS['visiteur_session']['email'])) {
84
-		$login = $GLOBALS['visiteur_session']['email'];
85
-	}
86
-	if (!$login and isset($GLOBALS['visiteur_session']['login'])) {
87
-		$login = $GLOBALS['visiteur_session']['login'];
88
-	}
89
-	// ou si on a un cookie admin
90
-	if (!$login) {
91
-		if (
92
-			isset($_COOKIE['spip_admin'])
93
-			and preg_match(',^@(.*)$,', $_COOKIE['spip_admin'], $regs)
94
-		) {
95
-			$login = $regs[1];
96
-		}
97
-	}
98
-
99
-	$lang = $GLOBALS['spip_lang'];
100
-	include_spip('inc/auth');
101
-	$row = auth_informer_login($login);
102
-
103
-	// retablir la langue de l'URL si forcee (on ignore la langue de l'auteur dans ce cas)
104
-	if (_request('lang') === $lang and $GLOBALS['spip_lang'] !== $lang) {
105
-		changer_langue($lang);
106
-	}
107
-
108
-	// Construire l'environnement du squelette
109
-	// Ne pas proposer de "rester connecte quelques jours"
110
-	// si la duree de l'alea est inferieure a 12 h (valeur par defaut)
111
-
112
-	$valeurs = [
113
-		'var_login' => $login,
114
-		'editable' => !$row,
115
-		'cnx' => $row['cnx'] ?? '0',
116
-		'auth_http' => login_auth_http(),
117
-		'rester_connecte' => ((_RENOUVELLE_ALEA < 12 * 3600) ? '' : ' '),
118
-		'_logo' => $row['logo'] ?? '',
119
-		'_alea_actuel' => $row['alea_actuel'] ?? '',
120
-		'_alea_futur' => $row['alea_futur'] ?? '',
121
-		'_pipeline' => 'affiche_formulaire_login', // faire passer le formulaire dans un pipe dedie pour les methodes auth
122
-		'_autofocus' => ($options['autofocus'] and $options['autofocus'] !== 'non') ? ' ' : '',
123
-	];
124
-
125
-	if ($erreur or !isset($GLOBALS['visiteur_session']['id_auteur']) or !$GLOBALS['visiteur_session']['id_auteur']) {
126
-		$valeurs['editable'] = true;
127
-	}
128
-
129
-	if (is_null($prive) ? is_url_prive($cible) : $prive) {
130
-		include_spip('inc/autoriser');
131
-		$loge = autoriser('ecrire');
132
-	} else {
133
-		$loge = (isset($GLOBALS['visiteur_session']['auth']) and $GLOBALS['visiteur_session']['auth'] != '');
134
-	}
135
-
136
-	// Si on est connecte, appeler traiter()
137
-	// et lancer la redirection si besoin
138
-	if (!$valeurs['editable'] and $loge and _request('formulaire_action') !== 'login') {
139
-		$traiter = charger_fonction('traiter', 'formulaires/login');
140
-		$res = $traiter($cible, $login, $prive);
141
-		$valeurs = array_merge($valeurs, $res);
142
-
143
-		if (isset($res['redirect']) and $res['redirect']) {
144
-			include_spip('inc/headers');
145
-			# preparer un lien pour quand redirige_formulaire ne fonctionne pas
146
-			$m = redirige_formulaire($res['redirect']);
147
-			$valeurs['_deja_loge'] = inserer_attribut(
148
-				'<a>' . _T('login_par_ici') . "</a>$m",
149
-				'href',
150
-				$res['redirect']
151
-			);
152
-		}
153
-	}
154
-	// en cas d'echec de cookie, inc_auth a renvoye vers le script de
155
-	// pose de cookie ; s'il n'est pas la, c'est echec cookie
156
-	// s'il est la, c'est probablement un bookmark sur bonjour=oui,
157
-	// et pas un echec cookie.
158
-	if ($erreur == 'cookie') {
159
-		$valeurs['echec_cookie'] = ' ';
160
-	} elseif ($erreur) {
161
-		// une erreur d'un SSO indique dans la redirection vers ici
162
-		// mais il faut se proteger de toute tentative d'injection malveilante
163
-		include_spip('inc/filtres');
164
-		$valeurs['message_erreur'] = textebrut($erreur);
165
-	}
166
-
167
-	return $valeurs;
63
+    $erreur = _request('var_erreur');
64
+
65
+    if (!is_array($options)) {
66
+        $options = [
67
+            'login' => $options,
68
+            'prive' => $deprecated
69
+        ];
70
+    }
71
+
72
+    $login = (empty($options['login']) ? '' : $options['login']);
73
+    $prive = (empty($options['prive']) ? null : $options['prive']);
74
+    // conserver le fonctionnement historique
75
+    if (!isset($options['autofocus'])) {
76
+        $options['autofocus'] = true;
77
+    }
78
+
79
+    if (!$login) {
80
+        $login = strval(_request('var_login'));
81
+    }
82
+    // si on est deja identifie
83
+    if (!$login and isset($GLOBALS['visiteur_session']['email'])) {
84
+        $login = $GLOBALS['visiteur_session']['email'];
85
+    }
86
+    if (!$login and isset($GLOBALS['visiteur_session']['login'])) {
87
+        $login = $GLOBALS['visiteur_session']['login'];
88
+    }
89
+    // ou si on a un cookie admin
90
+    if (!$login) {
91
+        if (
92
+            isset($_COOKIE['spip_admin'])
93
+            and preg_match(',^@(.*)$,', $_COOKIE['spip_admin'], $regs)
94
+        ) {
95
+            $login = $regs[1];
96
+        }
97
+    }
98
+
99
+    $lang = $GLOBALS['spip_lang'];
100
+    include_spip('inc/auth');
101
+    $row = auth_informer_login($login);
102
+
103
+    // retablir la langue de l'URL si forcee (on ignore la langue de l'auteur dans ce cas)
104
+    if (_request('lang') === $lang and $GLOBALS['spip_lang'] !== $lang) {
105
+        changer_langue($lang);
106
+    }
107
+
108
+    // Construire l'environnement du squelette
109
+    // Ne pas proposer de "rester connecte quelques jours"
110
+    // si la duree de l'alea est inferieure a 12 h (valeur par defaut)
111
+
112
+    $valeurs = [
113
+        'var_login' => $login,
114
+        'editable' => !$row,
115
+        'cnx' => $row['cnx'] ?? '0',
116
+        'auth_http' => login_auth_http(),
117
+        'rester_connecte' => ((_RENOUVELLE_ALEA < 12 * 3600) ? '' : ' '),
118
+        '_logo' => $row['logo'] ?? '',
119
+        '_alea_actuel' => $row['alea_actuel'] ?? '',
120
+        '_alea_futur' => $row['alea_futur'] ?? '',
121
+        '_pipeline' => 'affiche_formulaire_login', // faire passer le formulaire dans un pipe dedie pour les methodes auth
122
+        '_autofocus' => ($options['autofocus'] and $options['autofocus'] !== 'non') ? ' ' : '',
123
+    ];
124
+
125
+    if ($erreur or !isset($GLOBALS['visiteur_session']['id_auteur']) or !$GLOBALS['visiteur_session']['id_auteur']) {
126
+        $valeurs['editable'] = true;
127
+    }
128
+
129
+    if (is_null($prive) ? is_url_prive($cible) : $prive) {
130
+        include_spip('inc/autoriser');
131
+        $loge = autoriser('ecrire');
132
+    } else {
133
+        $loge = (isset($GLOBALS['visiteur_session']['auth']) and $GLOBALS['visiteur_session']['auth'] != '');
134
+    }
135
+
136
+    // Si on est connecte, appeler traiter()
137
+    // et lancer la redirection si besoin
138
+    if (!$valeurs['editable'] and $loge and _request('formulaire_action') !== 'login') {
139
+        $traiter = charger_fonction('traiter', 'formulaires/login');
140
+        $res = $traiter($cible, $login, $prive);
141
+        $valeurs = array_merge($valeurs, $res);
142
+
143
+        if (isset($res['redirect']) and $res['redirect']) {
144
+            include_spip('inc/headers');
145
+            # preparer un lien pour quand redirige_formulaire ne fonctionne pas
146
+            $m = redirige_formulaire($res['redirect']);
147
+            $valeurs['_deja_loge'] = inserer_attribut(
148
+                '<a>' . _T('login_par_ici') . "</a>$m",
149
+                'href',
150
+                $res['redirect']
151
+            );
152
+        }
153
+    }
154
+    // en cas d'echec de cookie, inc_auth a renvoye vers le script de
155
+    // pose de cookie ; s'il n'est pas la, c'est echec cookie
156
+    // s'il est la, c'est probablement un bookmark sur bonjour=oui,
157
+    // et pas un echec cookie.
158
+    if ($erreur == 'cookie') {
159
+        $valeurs['echec_cookie'] = ' ';
160
+    } elseif ($erreur) {
161
+        // une erreur d'un SSO indique dans la redirection vers ici
162
+        // mais il faut se proteger de toute tentative d'injection malveilante
163
+        include_spip('inc/filtres');
164
+        $valeurs['message_erreur'] = textebrut($erreur);
165
+    }
166
+
167
+    return $valeurs;
168 168
 }
169 169
 
170 170
 
@@ -179,20 +179,20 @@  discard block
 block discarded – undo
179 179
  *     - chaîne vide sinon.
180 180
  **/
181 181
 function login_auth_http() {
182
-	if (
183
-		!$GLOBALS['ignore_auth_http']
184
-		and _request('var_erreur') == 'cookie'
185
-		and (!isset($_COOKIE['spip_session']) or $_COOKIE['spip_session'] != 'test_echec_cookie')
186
-		and (($GLOBALS['flag_sapi_name'] and preg_match(',apache,i', @php_sapi_name()))
187
-			or preg_match(',^Apache.* PHP,', $_SERVER['SERVER_SOFTWARE']))
188
-		// Attention dans le cas 'intranet' la proposition de se loger
189
-		// par auth_http peut conduire a l'echec.
190
-		and !(isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW']))
191
-	) {
192
-		return generer_url_action('cookie', '', false, true);
193
-	} else {
194
-		return '';
195
-	}
182
+    if (
183
+        !$GLOBALS['ignore_auth_http']
184
+        and _request('var_erreur') == 'cookie'
185
+        and (!isset($_COOKIE['spip_session']) or $_COOKIE['spip_session'] != 'test_echec_cookie')
186
+        and (($GLOBALS['flag_sapi_name'] and preg_match(',apache,i', @php_sapi_name()))
187
+            or preg_match(',^Apache.* PHP,', $_SERVER['SERVER_SOFTWARE']))
188
+        // Attention dans le cas 'intranet' la proposition de se loger
189
+        // par auth_http peut conduire a l'echec.
190
+        and !(isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW']))
191
+    ) {
192
+        return generer_url_action('cookie', '', false, true);
193
+    } else {
194
+        return '';
195
+    }
196 196
 }
197 197
 
198 198
 
@@ -218,65 +218,65 @@  discard block
 block discarded – undo
218 218
  **/
219 219
 function formulaires_login_verifier_dist($cible = '', $options = [], $deprecated = null) {
220 220
 
221
-	$erreurs = [];
222
-	if (!is_array($options)) {
223
-		$options = [
224
-			'login' => $options,
225
-			'prive' => $deprecated
226
-		];
227
-	}
228
-
229
-	$prive = (empty($options['prive']) ? null : $options['prive']);
230
-
231
-	$session_login = _request('var_login');
232
-	$session_password = _request('password');
233
-	$session_remember = _request('session_remember');
234
-
235
-	if (!$session_login) {
236
-		# pas de login saisi !
237
-		return ['var_login' => _T('info_obligatoire')];
238
-	}
239
-
240
-	// appeler auth_identifier_login qui va :
241
-	// - renvoyer un string si echec (message d'erreur)
242
-	// - un array decrivant l'auteur identifie si possible
243
-	// - rediriger vers un SSO qui renverra in fine sur action/auth qui finira l'authentification
244
-	include_spip('inc/auth');
245
-	$auteur = auth_identifier_login($session_login, $session_password);
246
-	// on arrive ici si on ne s'est pas identifie avec un SSO
247
-	if (!is_array($auteur)) {
248
-		$erreurs = [];
249
-		if (is_string($auteur) and strlen($auteur)) {
250
-			$erreurs['var_login'] = $auteur;
251
-		}
252
-		include_spip('inc/cookie');
253
-		spip_setcookie('spip_admin', '', time() - 3600);
254
-		if (strlen($session_password)) {
255
-			$erreurs['password'] = _T('login_erreur_pass');
256
-		} else {
257
-			// sinon c'est un login en deux passe old style (ou js en panne)
258
-			// pas de message d'erreur
259
-			$erreurs['password'] = ' ';
260
-			$erreurs['message_erreur'] = '';
261
-		}
262
-
263
-		return
264
-			$erreurs;
265
-	}
266
-	// on a ete authentifie, construire la session
267
-	// en gerant la duree demandee pour son cookie
268
-	if ($session_remember !== null) {
269
-		$auteur['cookie'] = $session_remember;
270
-	}
271
-	// si la connexion est refusee on renvoi un message erreur de mot de passe
272
-	// car en donnant plus de detail on renseignerait un assaillant sur l'existence d'un compte
273
-	if (auth_loger($auteur) === false) {
274
-		$erreurs['message_erreur'] = _T('login_erreur_pass');
275
-		return $erreurs;
276
-	}
277
-
278
-	return (is_null($prive) ? is_url_prive($cible) : $prive)
279
-		? login_autoriser() : [];
221
+    $erreurs = [];
222
+    if (!is_array($options)) {
223
+        $options = [
224
+            'login' => $options,
225
+            'prive' => $deprecated
226
+        ];
227
+    }
228
+
229
+    $prive = (empty($options['prive']) ? null : $options['prive']);
230
+
231
+    $session_login = _request('var_login');
232
+    $session_password = _request('password');
233
+    $session_remember = _request('session_remember');
234
+
235
+    if (!$session_login) {
236
+        # pas de login saisi !
237
+        return ['var_login' => _T('info_obligatoire')];
238
+    }
239
+
240
+    // appeler auth_identifier_login qui va :
241
+    // - renvoyer un string si echec (message d'erreur)
242
+    // - un array decrivant l'auteur identifie si possible
243
+    // - rediriger vers un SSO qui renverra in fine sur action/auth qui finira l'authentification
244
+    include_spip('inc/auth');
245
+    $auteur = auth_identifier_login($session_login, $session_password);
246
+    // on arrive ici si on ne s'est pas identifie avec un SSO
247
+    if (!is_array($auteur)) {
248
+        $erreurs = [];
249
+        if (is_string($auteur) and strlen($auteur)) {
250
+            $erreurs['var_login'] = $auteur;
251
+        }
252
+        include_spip('inc/cookie');
253
+        spip_setcookie('spip_admin', '', time() - 3600);
254
+        if (strlen($session_password)) {
255
+            $erreurs['password'] = _T('login_erreur_pass');
256
+        } else {
257
+            // sinon c'est un login en deux passe old style (ou js en panne)
258
+            // pas de message d'erreur
259
+            $erreurs['password'] = ' ';
260
+            $erreurs['message_erreur'] = '';
261
+        }
262
+
263
+        return
264
+            $erreurs;
265
+    }
266
+    // on a ete authentifie, construire la session
267
+    // en gerant la duree demandee pour son cookie
268
+    if ($session_remember !== null) {
269
+        $auteur['cookie'] = $session_remember;
270
+    }
271
+    // si la connexion est refusee on renvoi un message erreur de mot de passe
272
+    // car en donnant plus de detail on renseignerait un assaillant sur l'existence d'un compte
273
+    if (auth_loger($auteur) === false) {
274
+        $erreurs['message_erreur'] = _T('login_erreur_pass');
275
+        return $erreurs;
276
+    }
277
+
278
+    return (is_null($prive) ? is_url_prive($cible) : $prive)
279
+        ? login_autoriser() : [];
280 280
 }
281 281
 
282 282
 /**
@@ -291,21 +291,21 @@  discard block
 block discarded – undo
291 291
  *     - tableau vide sinon.
292 292
  **/
293 293
 function login_autoriser() {
294
-	include_spip('inc/autoriser');
295
-	if (!autoriser('ecrire')) {
296
-		$h = generer_url_action('logout', 'logout=prive&url=' . urlencode(self()));
297
-
298
-		return [
299
-			'message_erreur' => '<h1>'
300
-				. _T('avis_erreur_visiteur')
301
-				. '</h1><p>'
302
-				. _T('texte_erreur_visiteur')
303
-				. "</p><p class='retour'>[<a href='$h'>"
304
-				. _T('icone_deconnecter') . '</a>]</p>'
305
-		];
306
-	}
307
-
308
-	return [];
294
+    include_spip('inc/autoriser');
295
+    if (!autoriser('ecrire')) {
296
+        $h = generer_url_action('logout', 'logout=prive&url=' . urlencode(self()));
297
+
298
+        return [
299
+            'message_erreur' => '<h1>'
300
+                . _T('avis_erreur_visiteur')
301
+                . '</h1><p>'
302
+                . _T('texte_erreur_visiteur')
303
+                . "</p><p class='retour'>[<a href='$h'>"
304
+                . _T('icone_deconnecter') . '</a>]</p>'
305
+        ];
306
+    }
307
+
308
+    return [];
309 309
 }
310 310
 
311 311
 /**
@@ -326,55 +326,55 @@  discard block
 block discarded – undo
326 326
  *     Retours du traitement
327 327
  **/
328 328
 function formulaires_login_traiter_dist($cible = '', $options = [], $deprecated = null) {
329
-	$res = [];
330
-
331
-	if (!is_array($options)) {
332
-		$options = [
333
-			'login' => $options,
334
-			'prive' => $deprecated
335
-		];
336
-	}
337
-
338
-	$login = (empty($options['login']) ? '' : $options['login']);
339
-	$prive = (empty($options['prive']) ? null : $options['prive']);
340
-
341
-	// Si on se connecte dans l'espace prive,
342
-	// ajouter "bonjour" (repere a peu pres les cookies desactives)
343
-	if (is_null($prive) ? is_url_prive($cible) : $prive) {
344
-		$cible = parametre_url($cible, 'bonjour', 'oui', '&');
345
-	}
346
-	if ($cible == '@page_auteur') {
347
-		$cible = generer_objet_url($GLOBALS['auteur_session']['id_auteur'], 'auteur');
348
-	}
349
-
350
-	if ($cible) {
351
-		$cible = parametre_url($cible, 'var_login', '', '&');
352
-
353
-		// transformer la cible absolue en cible relative
354
-		// pour pas echouer quand la meta adresse_site est foireuse
355
-		if (strncmp($cible, $u = url_de_base(), strlen($u)) == 0) {
356
-			$cible = './' . substr($cible, strlen($u));
357
-		} elseif (tester_url_absolue($cible) and !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) {
358
-			// si c'est une url absolue, refuser la redirection
359
-			// sauf si cette securite est levee volontairement par le webmestre
360
-			$cible = '';
361
-		}
362
-	}
363
-
364
-	// Si on est connecte, envoyer vers la destination
365
-	if ($cible and ($cible != self('&')) and ($cible != self())) {
366
-		$res['redirect'] = $cible;
367
-		$res['message_ok'] = inserer_attribut(
368
-			'<a>' . _T('login_par_ici') . '</a>',
369
-			'href',
370
-			$cible
371
-		);
372
-	}
373
-
374
-	// avant de rediriger il faut mettre a jour les sessions sur le disque si on a charge une session
375
-	if (function_exists('terminer_actualiser_sessions')) {
376
-		terminer_actualiser_sessions();
377
-	}
378
-
379
-	return $res;
329
+    $res = [];
330
+
331
+    if (!is_array($options)) {
332
+        $options = [
333
+            'login' => $options,
334
+            'prive' => $deprecated
335
+        ];
336
+    }
337
+
338
+    $login = (empty($options['login']) ? '' : $options['login']);
339
+    $prive = (empty($options['prive']) ? null : $options['prive']);
340
+
341
+    // Si on se connecte dans l'espace prive,
342
+    // ajouter "bonjour" (repere a peu pres les cookies desactives)
343
+    if (is_null($prive) ? is_url_prive($cible) : $prive) {
344
+        $cible = parametre_url($cible, 'bonjour', 'oui', '&');
345
+    }
346
+    if ($cible == '@page_auteur') {
347
+        $cible = generer_objet_url($GLOBALS['auteur_session']['id_auteur'], 'auteur');
348
+    }
349
+
350
+    if ($cible) {
351
+        $cible = parametre_url($cible, 'var_login', '', '&');
352
+
353
+        // transformer la cible absolue en cible relative
354
+        // pour pas echouer quand la meta adresse_site est foireuse
355
+        if (strncmp($cible, $u = url_de_base(), strlen($u)) == 0) {
356
+            $cible = './' . substr($cible, strlen($u));
357
+        } elseif (tester_url_absolue($cible) and !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) {
358
+            // si c'est une url absolue, refuser la redirection
359
+            // sauf si cette securite est levee volontairement par le webmestre
360
+            $cible = '';
361
+        }
362
+    }
363
+
364
+    // Si on est connecte, envoyer vers la destination
365
+    if ($cible and ($cible != self('&')) and ($cible != self())) {
366
+        $res['redirect'] = $cible;
367
+        $res['message_ok'] = inserer_attribut(
368
+            '<a>' . _T('login_par_ici') . '</a>',
369
+            'href',
370
+            $cible
371
+        );
372
+    }
373
+
374
+    // avant de rediriger il faut mettre a jour les sessions sur le disque si on a charge une session
375
+    if (function_exists('terminer_actualiser_sessions')) {
376
+        terminer_actualiser_sessions();
377
+    }
378
+
379
+    return $res;
380 380
 }
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/urls/page.php 1 patch
Indentation   +31 added lines, -31 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
 
17 17
 define('URLS_PAGE_EXEMPLE', 'spip.php?article12');
@@ -37,23 +37,23 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function urls_page_generer_url_objet_dist(int $id, string $objet, string $args = '', string $ancre = ''): string {
39 39
 
40
-	if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) {
41
-		$url = $generer_url_externe($id, $args, $ancre);
42
-		// une url === null indique "je ne traite pas cette url, appliquez le calcul standard"
43
-		// une url vide est une url vide, ne rien faire de plus
44
-		if (!is_null($url)) {
45
-			return $url;
46
-		}
47
-	}
40
+    if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) {
41
+        $url = $generer_url_externe($id, $args, $ancre);
42
+        // une url === null indique "je ne traite pas cette url, appliquez le calcul standard"
43
+        // une url vide est une url vide, ne rien faire de plus
44
+        if (!is_null($url)) {
45
+            return $url;
46
+        }
47
+    }
48 48
 
49
-	$url = \_debut_urls_page . $objet . \_separateur_urls_page
50
-		. $id . \_terminaison_urls_page;
49
+    $url = \_debut_urls_page . $objet . \_separateur_urls_page
50
+        . $id . \_terminaison_urls_page;
51 51
 
52
-	if ($args) {
53
-		$args = strpos($url, '?') ? "&$args" : "?$args";
54
-	}
52
+    if ($args) {
53
+        $args = strpos($url, '?') ? "&$args" : "?$args";
54
+    }
55 55
 
56
-	return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
56
+    return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
57 57
 }
58 58
 
59 59
 /**
@@ -69,27 +69,27 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function urls_page_decoder_url_dist(string $url, string $entite, array $contexte = []): array {
71 71
 
72
-	// traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
73
-	if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
74
-		return [[], '404'];
75
-	}
72
+    // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
73
+    if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
74
+        return [[], '404'];
75
+    }
76 76
 
77
-	include_spip('inc/urls');
78
-	$r = nettoyer_url_page($url, $contexte);
79
-	if ($r) {
80
-		array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici
81
-		return $r;
82
-	}
77
+    include_spip('inc/urls');
78
+    $r = nettoyer_url_page($url, $contexte);
79
+    if ($r) {
80
+        array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici
81
+        return $r;
82
+    }
83 83
 
84
-	/*
84
+    /*
85 85
 	 * Le bloc qui suit sert a faciliter les transitions depuis
86 86
 	 * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html'
87 87
 	 * Il est inutile de le recopier si vous personnalisez vos URLs
88 88
 	 * et votre .htaccess
89 89
 	 */
90
-	// Si on est revenu en mode html, mais c'est une ancienne url_propre
91
-	// on ne redirige pas, on assume le nouveau contexte (si possible)
92
-	$url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? '';
93
-	return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte);
94
-	/* Fin du bloc compatibilite url-propres */
90
+    // Si on est revenu en mode html, mais c'est une ancienne url_propre
91
+    // on ne redirige pas, on assume le nouveau contexte (si possible)
92
+    $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? '';
93
+    return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte);
94
+    /* Fin du bloc compatibilite url-propres */
95 95
 }
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.