Completed
Push — master ( 3fe97a...7569f9 )
by cam
02:24
created
ecrire/action/session.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -31,16 +31,16 @@  discard block
 block discarded – undo
31 31
  *   Envoyer en réponse : json contenant toutes les variables publiques de la session
32 32
  **/
33 33
 function action_session_dist() {
34
-	if (
35
-		($var = _request('var'))
36
-		&& preg_match(',^[a-z_0-9-]+$,i', (string) $var)
37
-		&& $_SERVER['REQUEST_METHOD'] == 'POST'
38
-	) {
39
-		include_spip('inc/session');
40
-		session_set('session_' . $var, $val = _request('val'));
41
-		#spip_log("autosave:$var:$val",'autosave');
42
-	}
34
+    if (
35
+        ($var = _request('var'))
36
+        && preg_match(',^[a-z_0-9-]+$,i', (string) $var)
37
+        && $_SERVER['REQUEST_METHOD'] == 'POST'
38
+    ) {
39
+        include_spip('inc/session');
40
+        session_set('session_' . $var, $val = _request('val'));
41
+        #spip_log("autosave:$var:$val",'autosave');
42
+    }
43 43
 
44
-	# TODO: mode lecture de session ; n'afficher que ce qu'il faut
45
-	#echo json_encode($GLOBALS['visiteur_session']);
44
+    # TODO: mode lecture de session ; n'afficher que ce qu'il faut
45
+    #echo json_encode($GLOBALS['visiteur_session']);
46 46
 }
Please login to merge, or discard this patch.
ecrire/action/redirect.php 1 patch
Indentation   +69 added lines, -69 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
 /**
@@ -35,53 +35,53 @@  discard block
 block discarded – undo
35 35
  *   ```
36 36
  **/
37 37
 function action_redirect_dist() {
38
-	$type = _request('type');
39
-	$id = (int) _request('id');
40
-	$page = false;
38
+    $type = _request('type');
39
+    $id = (int) _request('id');
40
+    $page = false;
41 41
 
42
-	// verifier le type ou page transmis
43
-	if (!preg_match('/^\w+$/', (string) $type)) {
44
-		$page = _request('page');
45
-		if (!preg_match('/^\w+$/', (string) $page)) {
46
-			return;
47
-		}
48
-	}
42
+    // verifier le type ou page transmis
43
+    if (!preg_match('/^\w+$/', (string) $type)) {
44
+        $page = _request('page');
45
+        if (!preg_match('/^\w+$/', (string) $page)) {
46
+            return;
47
+        }
48
+    }
49 49
 
50
-	$var_mode = _request('var_mode');
51
-	// forcer la mise a jour de l'url de cet objet !
52
-	if ($var_mode && !defined('_VAR_URLS')) {
53
-		define('_VAR_URLS', true);
54
-	}
50
+    $var_mode = _request('var_mode');
51
+    // forcer la mise a jour de l'url de cet objet !
52
+    if ($var_mode && !defined('_VAR_URLS')) {
53
+        define('_VAR_URLS', true);
54
+    }
55 55
 
56
-	$url = $page
57
-		? generer_url_public($page, '', true)
58
-		: calculer_url_redirect_entite($type, $id, $var_mode);
56
+    $url = $page
57
+        ? generer_url_public($page, '', true)
58
+        : calculer_url_redirect_entite($type, $id, $var_mode);
59 59
 
60
-	$status = '302';
61
-	if ($url) {
62
-		if ($var_mode) {
63
-			$url = parametre_url($url, 'var_mode', $var_mode, '&');
64
-		}
60
+    $status = '302';
61
+    if ($url) {
62
+        if ($var_mode) {
63
+            $url = parametre_url($url, 'var_mode', $var_mode, '&');
64
+        }
65 65
 
66
-		if (
67
-			$var_mode == 'preview'
68
-			&& defined('_PREVIEW_TOKEN')
69
-			&& _PREVIEW_TOKEN
70
-			&& autoriser('previsualiser')
71
-		) {
72
-			include_spip('inc/securiser_action');
73
-			$token = calculer_token_previsu($url);
74
-			$url = parametre_url($url, 'var_previewtoken', $token);
75
-		}
66
+        if (
67
+            $var_mode == 'preview'
68
+            && defined('_PREVIEW_TOKEN')
69
+            && _PREVIEW_TOKEN
70
+            && autoriser('previsualiser')
71
+        ) {
72
+            include_spip('inc/securiser_action');
73
+            $token = calculer_token_previsu($url);
74
+            $url = parametre_url($url, 'var_previewtoken', $token);
75
+        }
76 76
 
77
-		if (_request('status') && _request('status') == '301') {
78
-			$status = '301';
79
-		}
80
-	} else {
81
-		$url = generer_url_public('404', '', true);
82
-	}
77
+        if (_request('status') && _request('status') == '301') {
78
+            $status = '301';
79
+        }
80
+    } else {
81
+        $url = generer_url_public('404', '', true);
82
+    }
83 83
 
84
-	redirige_par_entete(str_replace('&', '&', (string) $url), '', $status);
84
+    redirige_par_entete(str_replace('&', '&', (string) $url), '', $status);
85 85
 }
86 86
 
87 87
 /**
@@ -96,35 +96,35 @@  discard block
 block discarded – undo
96 96
  * @return string|null
97 97
  */
98 98
 function calculer_url_redirect_entite($type, $id, $var_mode) {
99
-	$desc = null;
100
-	$publie = null;
101
-	$url = null;
102
-	// invalider le cache à chaque modif en bdd
103
-	$date = 0;
104
-	if (isset($GLOBALS['meta']['derniere_modif'])) {
105
-		$date = $GLOBALS['meta']['derniere_modif'];
106
-	}
107
-	$key = "url-$date-$type-$id";
99
+    $desc = null;
100
+    $publie = null;
101
+    $url = null;
102
+    // invalider le cache à chaque modif en bdd
103
+    $date = 0;
104
+    if (isset($GLOBALS['meta']['derniere_modif'])) {
105
+        $date = $GLOBALS['meta']['derniere_modif'];
106
+    }
107
+    $key = "url-$date-$type-$id";
108 108
 
109
-	// Obtenir l’url et si elle est publié du cache memoization
110
-	if (function_exists('cache_get') && ($desc = cache_get($key))) {
111
-		[$url, $publie] = $desc;
112
-	}
113
-	// Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie
114
-	if (empty($desc) || $var_mode) {
115
-		$publie = objet_test_si_publie($type, $id);
116
-		$url = generer_objet_url_absolue($id, $type, '', '', true);
117
-		if (function_exists('cache_set')) {
118
-			cache_set($key, [$url, $publie], 3600);
119
-		}
120
-	}
109
+    // Obtenir l’url et si elle est publié du cache memoization
110
+    if (function_exists('cache_get') && ($desc = cache_get($key))) {
111
+        [$url, $publie] = $desc;
112
+    }
113
+    // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie
114
+    if (empty($desc) || $var_mode) {
115
+        $publie = objet_test_si_publie($type, $id);
116
+        $url = generer_objet_url_absolue($id, $type, '', '', true);
117
+        if (function_exists('cache_set')) {
118
+            cache_set($key, [$url, $publie], 3600);
119
+        }
120
+    }
121 121
 
122
-	// On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation
123
-	if ($publie) {
124
-		return $url;
125
-	} elseif (defined('_VAR_PREVIEW') && _VAR_PREVIEW && autoriser('voir', $type, $id)) {
126
-		return $url;
127
-	}
122
+    // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation
123
+    if ($publie) {
124
+        return $url;
125
+    } elseif (defined('_VAR_PREVIEW') && _VAR_PREVIEW && autoriser('voir', $type, $id)) {
126
+        return $url;
127
+    }
128 128
 
129
-	return;
129
+    return;
130 130
 }
Please login to merge, or discard this patch.
ecrire/action/confirmer_email.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
  * @return void
28 28
  */
29 29
 function action_confirmer_email_dist() {
30
-	$securiser_action = charger_fonction('securiser_action', 'inc');
31
-	$arg = $securiser_action();
30
+    $securiser_action = charger_fonction('securiser_action', 'inc');
31
+    $arg = $securiser_action();
32 32
 
33
-	include_spip('inc/filtres');
34
-	if ($GLOBALS['visiteur_session']['id_auteur'] && email_valide($arg)) {
35
-		include_spip('action/editer_auteur');
36
-		auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], ['email' => $arg]);
37
-	}
38
-	// verifier avant de rediriger pour invalider le message de confirmation
39
-	// si ca n'a pas marche
40
-	if (
41
-		($redirect = _request('redirect')) && !$arg == sql_getfetsel(
42
-			'email',
43
-			'spip_auteurs',
44
-			'id_auteur=' . (int) $GLOBALS['visiteur_session']
45
-		)
46
-	) {
47
-		$GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', '');
48
-	}
33
+    include_spip('inc/filtres');
34
+    if ($GLOBALS['visiteur_session']['id_auteur'] && email_valide($arg)) {
35
+        include_spip('action/editer_auteur');
36
+        auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], ['email' => $arg]);
37
+    }
38
+    // verifier avant de rediriger pour invalider le message de confirmation
39
+    // si ca n'a pas marche
40
+    if (
41
+        ($redirect = _request('redirect')) && !$arg == sql_getfetsel(
42
+            'email',
43
+            'spip_auteurs',
44
+            'id_auteur=' . (int) $GLOBALS['visiteur_session']
45
+        )
46
+    ) {
47
+        $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', '');
48
+    }
49 49
 }
Please login to merge, or discard this patch.
ecrire/action/debloquer_edition.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
  */
31 31
 function action_debloquer_edition_dist() {
32 32
 
33
-	$securiser_action = charger_fonction('securiser_action', 'inc');
34
-	$arg = $securiser_action();
33
+    $securiser_action = charger_fonction('securiser_action', 'inc');
34
+    $arg = $securiser_action();
35 35
 
36
-	if ($arg) {
37
-		include_spip('inc/drapeau_edition');
38
-		if ($arg == 'tous') {
39
-			debloquer_tous($GLOBALS['visiteur_session']['id_auteur']);
40
-		} else {
41
-			$arg = explode('-', (string) $arg);
42
-			[$objet, $id_objet] = $arg;
43
-			debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet);
44
-		}
45
-	}
36
+    if ($arg) {
37
+        include_spip('inc/drapeau_edition');
38
+        if ($arg == 'tous') {
39
+            debloquer_tous($GLOBALS['visiteur_session']['id_auteur']);
40
+        } else {
41
+            $arg = explode('-', (string) $arg);
42
+            [$objet, $id_objet] = $arg;
43
+            debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet);
44
+        }
45
+    }
46 46
 }
Please login to merge, or discard this patch.
ecrire/action/calculer_taille_cache.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Cache
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 
@@ -30,41 +30,41 @@  discard block
 block discarded – undo
30 30
  *     de l'action sécurisée.
31 31
  */
32 32
 function action_calculer_taille_cache_dist($arg = null) {
33
-	if (is_null($arg)) {
34
-		$securiser_action = charger_fonction('securiser_action', 'inc');
35
-		$arg = $securiser_action();
36
-	}
37
-	include_spip('inc/filtres');
33
+    if (is_null($arg)) {
34
+        $securiser_action = charger_fonction('securiser_action', 'inc');
35
+        $arg = $securiser_action();
36
+    }
37
+    include_spip('inc/filtres');
38 38
 
39
-	if ($arg == 'images') {
40
-		$taille = calculer_taille_dossier(_DIR_VAR);
41
-		$res = _T(
42
-			'ecrire:taille_cache_image',
43
-			[
44
-				'dir' => joli_repertoire(_DIR_VAR),
45
-				'taille' => '<b>' . (taille_en_octets($taille) > 0 ? taille_en_octets($taille) : '0 octet') . '</b>'
46
-			]
47
-		);
48
-	} else {
49
-		include_spip('inc/invalideur');
50
-		$taille =
51
-			calculer_taille_dossier(_DIR_CACHE_XML)
52
-			+ calculer_taille_dossier(_DIR_CACHE . 'skel/')
53
-			+ calculer_taille_dossier(_DIR_CACHE . 'wheels/')
54
-			+ calculer_taille_dossier(_DIR_CACHE . 'contextes/');
55
-		$taille += (int) taille_du_cache();
56
-		if ($taille <= 150000) {
57
-			$res = _T('taille_cache_vide');
58
-		} elseif ($taille <= 1024 * 1024) {
59
-			$res = _T('taille_cache_moins_de', ['octets' => taille_en_octets(1024 * 1024)]);
60
-		} else {
61
-			$res = _T('taille_cache_octets', ['octets' => taille_en_octets($taille)]);
62
-		}
63
-		$res = "<b>$res</b>";
64
-	}
39
+    if ($arg == 'images') {
40
+        $taille = calculer_taille_dossier(_DIR_VAR);
41
+        $res = _T(
42
+            'ecrire:taille_cache_image',
43
+            [
44
+                'dir' => joli_repertoire(_DIR_VAR),
45
+                'taille' => '<b>' . (taille_en_octets($taille) > 0 ? taille_en_octets($taille) : '0 octet') . '</b>'
46
+            ]
47
+        );
48
+    } else {
49
+        include_spip('inc/invalideur');
50
+        $taille =
51
+            calculer_taille_dossier(_DIR_CACHE_XML)
52
+            + calculer_taille_dossier(_DIR_CACHE . 'skel/')
53
+            + calculer_taille_dossier(_DIR_CACHE . 'wheels/')
54
+            + calculer_taille_dossier(_DIR_CACHE . 'contextes/');
55
+        $taille += (int) taille_du_cache();
56
+        if ($taille <= 150000) {
57
+            $res = _T('taille_cache_vide');
58
+        } elseif ($taille <= 1024 * 1024) {
59
+            $res = _T('taille_cache_moins_de', ['octets' => taille_en_octets(1024 * 1024)]);
60
+        } else {
61
+            $res = _T('taille_cache_octets', ['octets' => taille_en_octets($taille)]);
62
+        }
63
+        $res = "<b>$res</b>";
64
+    }
65 65
 
66
-	$res = "<p>$res</p>";
67
-	ajax_retour($res);
66
+    $res = "<p>$res</p>";
67
+    ajax_retour($res);
68 68
 }
69 69
 
70 70
 
@@ -75,28 +75,28 @@  discard block
 block discarded – undo
75 75
  * @return int Taille en octets
76 76
  */
77 77
 function calculer_taille_dossier($dir) {
78
-	if (!is_dir($dir) || !is_readable($dir)) {
79
-		return 0;
80
-	}
81
-	$handle = opendir($dir);
82
-	if (!$handle) {
83
-		return 0;
84
-	}
85
-	$taille = 0;
86
-	while (($fichier = @readdir($handle)) !== false) {
87
-		// Eviter ".", "..", ".htaccess", etc.
88
-		if ($fichier[0] == '.') {
89
-			continue;
90
-		}
91
-		if (is_file($d = "$dir/$fichier")) {
92
-			$taille += filesize($d);
93
-		} else {
94
-			if (is_dir($d)) {
95
-				$taille += calculer_taille_dossier($d);
96
-			}
97
-		}
98
-	}
99
-	closedir($handle);
78
+    if (!is_dir($dir) || !is_readable($dir)) {
79
+        return 0;
80
+    }
81
+    $handle = opendir($dir);
82
+    if (!$handle) {
83
+        return 0;
84
+    }
85
+    $taille = 0;
86
+    while (($fichier = @readdir($handle)) !== false) {
87
+        // Eviter ".", "..", ".htaccess", etc.
88
+        if ($fichier[0] == '.') {
89
+            continue;
90
+        }
91
+        if (is_file($d = "$dir/$fichier")) {
92
+            $taille += filesize($d);
93
+        } else {
94
+            if (is_dir($d)) {
95
+                $taille += calculer_taille_dossier($d);
96
+            }
97
+        }
98
+    }
99
+    closedir($handle);
100 100
 
101
-	return $taille;
101
+    return $taille;
102 102
 }
Please login to merge, or discard this patch.
ecrire/action/confirmer_inscription.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -27,51 +27,51 @@  discard block
 block discarded – undo
27 27
  * @return void
28 28
  */
29 29
 function action_confirmer_inscription_dist() {
30
-	$jeton = _request('jeton');
31
-	$email = _request('email');
30
+    $jeton = _request('jeton');
31
+    $email = _request('email');
32 32
 
33
-	include_spip('action/inscrire_auteur');
34
-	if (
35
-		($auteur = auteur_verifier_jeton($jeton))
36
-		&& $auteur['email'] == $email
37
-		&& $auteur['statut'] == 'nouveau'
38
-	) {
39
-		// d'abord on confirme son statut
40
-		$auteur = confirmer_statut_inscription($auteur);
33
+    include_spip('action/inscrire_auteur');
34
+    if (
35
+        ($auteur = auteur_verifier_jeton($jeton))
36
+        && $auteur['email'] == $email
37
+        && $auteur['statut'] == 'nouveau'
38
+    ) {
39
+        // d'abord on confirme son statut
40
+        $auteur = confirmer_statut_inscription($auteur);
41 41
 
42
-		// OK c'est un nouvel inscrit qui confirme :
43
-		// on le loge => ca va confirmer son statut et c'est plus sympa
44
-		include_spip('inc/auth');
45
-		auth_loger($auteur);
42
+        // OK c'est un nouvel inscrit qui confirme :
43
+        // on le loge => ca va confirmer son statut et c'est plus sympa
44
+        include_spip('inc/auth');
45
+        auth_loger($auteur);
46 46
 
47
-		// et on efface son jeton
48
-		auteur_effacer_jeton($auteur['id_auteur']);
47
+        // et on efface son jeton
48
+        auteur_effacer_jeton($auteur['id_auteur']);
49 49
 
50
-		// si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur
51
-		// TODO: ne semble pas marcher si inscrit non visiteur, a debug
52
-		if (!_request('redirect')) {
53
-			// on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
54
-			if (autoriser('ecrire', '', '', $auteur['id_auteur'])) {
55
-				// poser un cookie admin aussi
56
-				$cookie = charger_fonction('cookie', 'action');
57
-				$cookie('@' . $GLOBALS['visiteur_session']['login']);
58
-				$GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
59
-			} else {
60
-				$GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
61
-			}
62
-		}
63
-	} else {
64
-		// lien perime :
65
-		if (!empty($GLOBALS['visiteur_session']['id_auteur'])) {
66
-			// on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
67
-			if (autoriser('ecrire', '', '', $GLOBALS['visiteur_session']['id_auteur'])) {
68
-				$GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
69
-			} else {
70
-				$GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
71
-			}
72
-		} else {
73
-			// rediriger vers la page de login si pas encore loge
74
-			$GLOBALS['redirect'] = parametre_url(generer_url_public('login', '', false), 'url', _request('redirect'));
75
-		}
76
-	}
50
+        // si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur
51
+        // TODO: ne semble pas marcher si inscrit non visiteur, a debug
52
+        if (!_request('redirect')) {
53
+            // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
54
+            if (autoriser('ecrire', '', '', $auteur['id_auteur'])) {
55
+                // poser un cookie admin aussi
56
+                $cookie = charger_fonction('cookie', 'action');
57
+                $cookie('@' . $GLOBALS['visiteur_session']['login']);
58
+                $GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
59
+            } else {
60
+                $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
61
+            }
62
+        }
63
+    } else {
64
+        // lien perime :
65
+        if (!empty($GLOBALS['visiteur_session']['id_auteur'])) {
66
+            // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
67
+            if (autoriser('ecrire', '', '', $GLOBALS['visiteur_session']['id_auteur'])) {
68
+                $GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
69
+            } else {
70
+                $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
71
+            }
72
+        } else {
73
+            // rediriger vers la page de login si pas encore loge
74
+            $GLOBALS['redirect'] = parametre_url(generer_url_public('login', '', false), 'url', _request('redirect'));
75
+        }
76
+    }
77 77
 }
Please login to merge, or discard this patch.
ecrire/action/menu_rubriques.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/autoriser');
@@ -34,42 +34,42 @@  discard block
 block discarded – undo
34 34
  **/
35 35
 function action_menu_rubriques_dist() {
36 36
 
37
-	// si pas acces a ecrire, pas acces au menu
38
-	// on renvoi un 401 qui fait echouer la requete ajax silencieusement
39
-	if (!autoriser('ecrire')) {
40
-		$retour =
41
-		'<ul class="deroulant__sous-menu" data-profondeur="1">' .
42
-			'<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
43
-				'<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
44
-					'<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
45
-				'</a>' .
46
-			'</li>' .
47
-		'</ul>';
48
-		include_spip('inc/actions');
49
-		ajax_retour($retour);
50
-		exit;
51
-	}
52
-
53
-	if ($date = (int) _request('date')) {
54
-		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
55
-	}
56
-
57
-	$r = gen_liste_rubriques();
58
-	if (
59
-		!$r
60
-		&& isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
61
-		&& !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/')
62
-	) {
63
-		include_spip('inc/headers');
64
-		header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
65
-		http_response_code(304);
66
-		exit;
67
-	} else {
68
-		include_spip('inc/actions');
69
-		$ret = menu_rubriques();
70
-		ajax_retour($ret);
71
-		exit;
72
-	}
37
+    // si pas acces a ecrire, pas acces au menu
38
+    // on renvoi un 401 qui fait echouer la requete ajax silencieusement
39
+    if (!autoriser('ecrire')) {
40
+        $retour =
41
+        '<ul class="deroulant__sous-menu" data-profondeur="1">' .
42
+            '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
43
+                '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
44
+                    '<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
45
+                '</a>' .
46
+            '</li>' .
47
+        '</ul>';
48
+        include_spip('inc/actions');
49
+        ajax_retour($retour);
50
+        exit;
51
+    }
52
+
53
+    if ($date = (int) _request('date')) {
54
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
55
+    }
56
+
57
+    $r = gen_liste_rubriques();
58
+    if (
59
+        !$r
60
+        && isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
61
+        && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/')
62
+    ) {
63
+        include_spip('inc/headers');
64
+        header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
65
+        http_response_code(304);
66
+        exit;
67
+    } else {
68
+        include_spip('inc/actions');
69
+        $ret = menu_rubriques();
70
+        ajax_retour($ret);
71
+        exit;
72
+    }
73 73
 }
74 74
 
75 75
 /**
@@ -83,44 +83,44 @@  discard block
 block discarded – undo
83 83
  *     Code HTML présentant la liste des rubriques
84 84
  **/
85 85
 function menu_rubriques($complet = true) {
86
-	$ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
87
-		. '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
88
-		. '<span class="libelle">' . _T('info_tout_site') . '</span>'
89
-		. '</a>'
90
-		. '</li>';
91
-
92
-	if (!$complet) {
93
-		return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
94
-	}
95
-
96
-	if (!isset($GLOBALS['db_art_cache'])) {
97
-		gen_liste_rubriques();
98
-	}
99
-	$arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
100
-
101
-	$total_lignes = $i = count($arr_low);
102
-
103
-	if ($i > 0) {
104
-		$nb_col = min(8, ceil($total_lignes / 30));
105
-		if ($nb_col <= 1) {
106
-			$nb_col = ceil($total_lignes / 10);
107
-		}
108
-		foreach ($arr_low as $id_rubrique => $titre_rubrique) {
109
-			if (autoriser('voir', 'rubrique', $id_rubrique)) {
110
-				$ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
111
-				$i++;
112
-			}
113
-		}
114
-
115
-		$class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
116
-		$ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">"
117
-			. $ret
118
-			. "\n</ul>\n";
119
-	} else {
120
-		$ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
121
-	}
122
-
123
-	return $ret;
86
+    $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
87
+        . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
88
+        . '<span class="libelle">' . _T('info_tout_site') . '</span>'
89
+        . '</a>'
90
+        . '</li>';
91
+
92
+    if (!$complet) {
93
+        return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
94
+    }
95
+
96
+    if (!isset($GLOBALS['db_art_cache'])) {
97
+        gen_liste_rubriques();
98
+    }
99
+    $arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
100
+
101
+    $total_lignes = $i = count($arr_low);
102
+
103
+    if ($i > 0) {
104
+        $nb_col = min(8, ceil($total_lignes / 30));
105
+        if ($nb_col <= 1) {
106
+            $nb_col = ceil($total_lignes / 10);
107
+        }
108
+        foreach ($arr_low as $id_rubrique => $titre_rubrique) {
109
+            if (autoriser('voir', 'rubrique', $id_rubrique)) {
110
+                $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
111
+                $i++;
112
+            }
113
+        }
114
+
115
+        $class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
116
+        $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">"
117
+            . $ret
118
+            . "\n</ul>\n";
119
+    } else {
120
+        $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
121
+    }
122
+
123
+    return $ret;
124 124
 }
125 125
 
126 126
 /**
@@ -141,47 +141,47 @@  discard block
 block discarded – undo
141 141
  *     Code HTML présentant la liste des rubriques
142 142
  **/
143 143
 function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) {
144
-	static $zmax = 6;
145
-	$profondeur_next = $profondeur + 1;
146
-
147
-	$nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
148
-		. '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
149
-		. "</a>\n";
150
-
151
-	// Limiter volontairement le nombre de sous-menus
152
-	if (!(--$zmax)) {
153
-		$zmax++;
154
-
155
-		return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
156
-	}
157
-
158
-	$arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
159
-	$i = count($arr_rub);
160
-	if (!$i) {
161
-		$zmax++;
162
-
163
-		return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
164
-	}
165
-
166
-
167
-	$nb_col = 1;
168
-	if ($nb_rub = count($arr_rub)) {
169
-		$nb_col = min(10, max(1, ceil($nb_rub / 10)));
170
-	}
171
-	$class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
172
-	$ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">"
173
-	 . $nav
174
-	 . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">";
175
-	foreach ($arr_rub as $id_rub => $titre_rub) {
176
-		if (autoriser('voir', 'rubrique', $id_rub)) {
177
-			$titre = supprimer_numero(typo($titre_rub));
178
-			$ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next);
179
-			$i++;
180
-		}
181
-	}
182
-	$zmax++;
183
-
184
-	return $ret . "</ul></li>\n";
144
+    static $zmax = 6;
145
+    $profondeur_next = $profondeur + 1;
146
+
147
+    $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
148
+        . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
149
+        . "</a>\n";
150
+
151
+    // Limiter volontairement le nombre de sous-menus
152
+    if (!(--$zmax)) {
153
+        $zmax++;
154
+
155
+        return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
156
+    }
157
+
158
+    $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
159
+    $i = count($arr_rub);
160
+    if (!$i) {
161
+        $zmax++;
162
+
163
+        return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
164
+    }
165
+
166
+
167
+    $nb_col = 1;
168
+    if ($nb_rub = count($arr_rub)) {
169
+        $nb_col = min(10, max(1, ceil($nb_rub / 10)));
170
+    }
171
+    $class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
172
+    $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">"
173
+        . $nav
174
+        . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">";
175
+    foreach ($arr_rub as $id_rub => $titre_rub) {
176
+        if (autoriser('voir', 'rubrique', $id_rub)) {
177
+            $titre = supprimer_numero(typo($titre_rub));
178
+            $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next);
179
+            $i++;
180
+        }
181
+    }
182
+    $zmax++;
183
+
184
+    return $ret . "</ul></li>\n";
185 185
 }
186 186
 
187 187
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
  *     Liste des rubriques enfants de la rubrique (et leur titre)
200 200
  **/
201 201
 function extraire_article($id_p, $t) {
202
-	return array_key_exists($id_p, $t) ? $t[$id_p] : [];
202
+    return array_key_exists($id_p, $t) ? $t[$id_p] : [];
203 203
 }
204 204
 
205 205
 /**
@@ -215,42 +215,42 @@  discard block
 block discarded – undo
215 215
  **/
216 216
 function gen_liste_rubriques() {
217 217
 
218
-	$cache = null;
219
-	include_spip('inc/config');
220
-	// ici, un petit fichier cache ne fait pas de mal
221
-	$last = lire_config('date_calcul_rubriques', 0);
222
-	if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
223
-		[$date, $GLOBALS['db_art_cache']] = @unserialize($cache);
224
-		if ($date == $last) {
225
-			return false;
226
-		} // c'etait en cache :-)
227
-	}
228
-	// se restreindre aux rubriques utilisees recemment +secteurs
229
-
230
-	$where = sql_in_select(
231
-		'id_rubrique',
232
-		'id_rubrique',
233
-		'spip_rubriques',
234
-		'',
235
-		'',
236
-		'id_parent=0 DESC, date DESC',
237
-		_CACHE_RUBRIQUES_MAX
238
-	);
239
-
240
-	// puis refaire la requete pour avoir l'ordre alphabetique
241
-
242
-	$res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre');
243
-
244
-	// il ne faut pas filtrer le autoriser voir ici
245
-	// car on met le resultat en cache, commun a tout le monde
246
-	$GLOBALS['db_art_cache'] = [];
247
-	while ($r = sql_fetch($res)) {
248
-		$t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
249
-		$GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
250
-	}
251
-
252
-	$t = [$last ?: time(), $GLOBALS['db_art_cache']];
253
-	ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
254
-
255
-	return true;
218
+    $cache = null;
219
+    include_spip('inc/config');
220
+    // ici, un petit fichier cache ne fait pas de mal
221
+    $last = lire_config('date_calcul_rubriques', 0);
222
+    if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
223
+        [$date, $GLOBALS['db_art_cache']] = @unserialize($cache);
224
+        if ($date == $last) {
225
+            return false;
226
+        } // c'etait en cache :-)
227
+    }
228
+    // se restreindre aux rubriques utilisees recemment +secteurs
229
+
230
+    $where = sql_in_select(
231
+        'id_rubrique',
232
+        'id_rubrique',
233
+        'spip_rubriques',
234
+        '',
235
+        '',
236
+        'id_parent=0 DESC, date DESC',
237
+        _CACHE_RUBRIQUES_MAX
238
+    );
239
+
240
+    // puis refaire la requete pour avoir l'ordre alphabetique
241
+
242
+    $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre');
243
+
244
+    // il ne faut pas filtrer le autoriser voir ici
245
+    // car on met le resultat en cache, commun a tout le monde
246
+    $GLOBALS['db_art_cache'] = [];
247
+    while ($r = sql_fetch($res)) {
248
+        $t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
249
+        $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
250
+    }
251
+
252
+    $t = [$last ?: time(), $GLOBALS['db_art_cache']];
253
+    ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
254
+
255
+    return true;
256 256
 }
Please login to merge, or discard this patch.
ecrire/action/auth.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function action_auth_dist() {
26 26
 
27
-	$securiser_action = charger_fonction('securiser_action', 'inc');
28
-	$arg = $securiser_action();
29
-
30
-	if (!preg_match(',^(\w+)[/](.+)$,', (string) $arg, $r)) {
31
-		spip_log("action_auth_dist $arg pas compris");
32
-	} else {
33
-		$auth_methode = $r[1];
34
-		$login = $r[2];
35
-		include_spip('inc/auth');
36
-		$res = auth_terminer_identifier_login($auth_methode, $login);
37
-
38
-		if (is_string($res)) { // Erreur
39
-			$redirect = _request('redirect');
40
-			$redirect = parametre_url($redirect, 'var_erreur', $res, '&');
41
-			include_spip('inc/headers');
42
-			redirige_par_entete($redirect);
43
-		}
44
-
45
-		// sinon on loge l'auteur identifie, et on finit (redirection automatique)
46
-		auth_loger($res);
47
-	}
27
+    $securiser_action = charger_fonction('securiser_action', 'inc');
28
+    $arg = $securiser_action();
29
+
30
+    if (!preg_match(',^(\w+)[/](.+)$,', (string) $arg, $r)) {
31
+        spip_log("action_auth_dist $arg pas compris");
32
+    } else {
33
+        $auth_methode = $r[1];
34
+        $login = $r[2];
35
+        include_spip('inc/auth');
36
+        $res = auth_terminer_identifier_login($auth_methode, $login);
37
+
38
+        if (is_string($res)) { // Erreur
39
+            $redirect = _request('redirect');
40
+            $redirect = parametre_url($redirect, 'var_erreur', $res, '&');
41
+            include_spip('inc/headers');
42
+            redirige_par_entete($redirect);
43
+        }
44
+
45
+        // sinon on loge l'auteur identifie, et on finit (redirection automatique)
46
+        auth_loger($res);
47
+    }
48 48
 }
Please login to merge, or discard this patch.
ecrire/action/desinstaller_plugin.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -31,28 +31,28 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function action_desinstaller_plugin_dist() {
33 33
 
34
-	$securiser_action = charger_fonction('securiser_action', 'inc');
35
-	$arg = $securiser_action();
36
-	[$dir_plugins, $plugin] = explode('::', (string) $arg);
37
-	$dir_type = '_DIR_PLUGINS';
38
-	if (defined('_DIR_PLUGINS_SUPPL') && $dir_plugins == _DIR_PLUGINS_SUPPL) {
39
-		$dir_type = '_DIR_PLUGINS_SUPPL';
40
-	}
41
-	$installer_plugins = charger_fonction('installer', 'plugins');
42
-	$infos = $installer_plugins($plugin, 'uninstall', $dir_type);
43
-	if ($infos && !$infos['install_test'][0]) {
44
-		include_spip('inc/plugin');
45
-		ecrire_plugin_actifs([$plugin], false, 'enleve');
46
-		$erreur = '';
47
-	} else {
48
-		$erreur = 'erreur_plugin_desinstalation_echouee';
49
-	}
50
-	if ($redirect = _request('redirect')) {
51
-		include_spip('inc/headers');
52
-		if ($erreur) {
53
-			$redirect = parametre_url($redirect, 'erreur', $erreur);
54
-		}
55
-		$redirect = str_replace('&amp;', '&', (string) $redirect);
56
-		redirige_par_entete($redirect);
57
-	}
34
+    $securiser_action = charger_fonction('securiser_action', 'inc');
35
+    $arg = $securiser_action();
36
+    [$dir_plugins, $plugin] = explode('::', (string) $arg);
37
+    $dir_type = '_DIR_PLUGINS';
38
+    if (defined('_DIR_PLUGINS_SUPPL') && $dir_plugins == _DIR_PLUGINS_SUPPL) {
39
+        $dir_type = '_DIR_PLUGINS_SUPPL';
40
+    }
41
+    $installer_plugins = charger_fonction('installer', 'plugins');
42
+    $infos = $installer_plugins($plugin, 'uninstall', $dir_type);
43
+    if ($infos && !$infos['install_test'][0]) {
44
+        include_spip('inc/plugin');
45
+        ecrire_plugin_actifs([$plugin], false, 'enleve');
46
+        $erreur = '';
47
+    } else {
48
+        $erreur = 'erreur_plugin_desinstalation_echouee';
49
+    }
50
+    if ($redirect = _request('redirect')) {
51
+        include_spip('inc/headers');
52
+        if ($erreur) {
53
+            $redirect = parametre_url($redirect, 'erreur', $erreur);
54
+        }
55
+        $redirect = str_replace('&amp;', '&', (string) $redirect);
56
+        redirige_par_entete($redirect);
57
+    }
58 58
 }
Please login to merge, or discard this patch.