Completed
Pull Request — master (#40)
by
unknown
04:13
created
ecrire/action/tester_taille.php 1 patch
Indentation   +77 added lines, -77 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
 include_spip('inc/headers');
24 24
 
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
  *     Sortie du buffer
36 36
  **/
37 37
 function action_tester_taille_error_handler($output) {
38
-	// on est ici, donc echec lors de la creation de l'image
39
-	if (!empty($GLOBALS['redirect'])) {
40
-		return redirige_formulaire($GLOBALS['redirect']);
41
-	}
38
+    // on est ici, donc echec lors de la creation de l'image
39
+    if (!empty($GLOBALS['redirect'])) {
40
+        return redirige_formulaire($GLOBALS['redirect']);
41
+    }
42 42
 
43
-	return $output;
43
+    return $output;
44 44
 }
45 45
 
46 46
 
@@ -58,75 +58,75 @@  discard block
 block discarded – undo
58 58
  **/
59 59
 function action_tester_taille_dist() {
60 60
 
61
-	if (!autoriser('configurer')) {
62
-		return;
63
-	}
64
-
65
-	$taille = _request('arg');
66
-	$taille = explode('-', $taille);
67
-
68
-	$GLOBALS['taille_max'] = end($taille);
69
-	$GLOBALS['taille_min'] = 0;
70
-	if (count($taille) > 1) {
71
-		$GLOBALS['taille_min'] = reset($taille);
72
-	}
73
-
74
-	// si l'intervalle est assez petit, on garde la valeur min
75
-	if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) {
76
-		$t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']);
77
-		if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) {
78
-			$t = $t * 0.9; // marge de securite
79
-			echo round($t / 1000000, 3) . ' Mpx';
80
-		} else {
81
-			// c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue"
82
-			$t = 0;
83
-			echo "&infin;";
84
-		}
85
-		ecrire_meta('max_taille_vignettes', $t, 'non');
86
-		die();
87
-	}
88
-
89
-	$taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2);
90
-
91
-	include_spip('inc/filtres');
92
-	// des inclusions representatives d'un hit prive et/ou public pour la conso memoire
93
-	include_spip('public/assembler');
94
-	include_spip('public/balises');
95
-	include_spip('public/boucles');
96
-	include_spip('public/cacher');
97
-	include_spip('public/compiler');
98
-	include_spip('public/composer');
99
-	include_spip('public/criteres');
100
-	include_spip('public/interfaces');
101
-	include_spip('public/parametrer');
102
-	include_spip('public/phraser_html');
103
-	include_spip('public/references');
104
-
105
-	include_spip('inc/presentation');
106
-	include_spip('inc/charsets');
107
-	include_spip('inc/documents');
108
-	include_spip('inc/header');
109
-	propre("<doc1>"); // charger propre avec le trairement d'un modele
110
-
111
-	$i = _request('i') + 1;
112
-	$image_source = chemin_image("test.png");
113
-	$GLOBALS['redirect'] = generer_url_action("tester_taille",
114
-		"i=$i&arg=" . $GLOBALS['taille_min'] . "-" . $GLOBALS['taille_test']);
115
-
116
-	ob_start('action_tester_taille_error_handler');
117
-	filtrer('image_recadre', $image_source, $taille, $taille);
118
-	$GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-" . $GLOBALS['taille_max']);
119
-
120
-	// si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee
121
-	// si $GLOBALS['taille_min']==0 (car on est au premier coup)
122
-	if ($GLOBALS['taille_min'] == 0) {
123
-		$taille = $GLOBALS['taille_max'];
124
-		filtrer('image_recadre', $image_source, $taille, $taille);
125
-		$GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-" . $GLOBALS['taille_max']);
126
-	}
127
-	ob_end_clean();
128
-
129
-
130
-	// on est ici, donc pas de plantage
131
-	echo redirige_formulaire($GLOBALS['redirect']);
61
+    if (!autoriser('configurer')) {
62
+        return;
63
+    }
64
+
65
+    $taille = _request('arg');
66
+    $taille = explode('-', $taille);
67
+
68
+    $GLOBALS['taille_max'] = end($taille);
69
+    $GLOBALS['taille_min'] = 0;
70
+    if (count($taille) > 1) {
71
+        $GLOBALS['taille_min'] = reset($taille);
72
+    }
73
+
74
+    // si l'intervalle est assez petit, on garde la valeur min
75
+    if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) {
76
+        $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']);
77
+        if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) {
78
+            $t = $t * 0.9; // marge de securite
79
+            echo round($t / 1000000, 3) . ' Mpx';
80
+        } else {
81
+            // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue"
82
+            $t = 0;
83
+            echo "&infin;";
84
+        }
85
+        ecrire_meta('max_taille_vignettes', $t, 'non');
86
+        die();
87
+    }
88
+
89
+    $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2);
90
+
91
+    include_spip('inc/filtres');
92
+    // des inclusions representatives d'un hit prive et/ou public pour la conso memoire
93
+    include_spip('public/assembler');
94
+    include_spip('public/balises');
95
+    include_spip('public/boucles');
96
+    include_spip('public/cacher');
97
+    include_spip('public/compiler');
98
+    include_spip('public/composer');
99
+    include_spip('public/criteres');
100
+    include_spip('public/interfaces');
101
+    include_spip('public/parametrer');
102
+    include_spip('public/phraser_html');
103
+    include_spip('public/references');
104
+
105
+    include_spip('inc/presentation');
106
+    include_spip('inc/charsets');
107
+    include_spip('inc/documents');
108
+    include_spip('inc/header');
109
+    propre("<doc1>"); // charger propre avec le trairement d'un modele
110
+
111
+    $i = _request('i') + 1;
112
+    $image_source = chemin_image("test.png");
113
+    $GLOBALS['redirect'] = generer_url_action("tester_taille",
114
+        "i=$i&arg=" . $GLOBALS['taille_min'] . "-" . $GLOBALS['taille_test']);
115
+
116
+    ob_start('action_tester_taille_error_handler');
117
+    filtrer('image_recadre', $image_source, $taille, $taille);
118
+    $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-" . $GLOBALS['taille_max']);
119
+
120
+    // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee
121
+    // si $GLOBALS['taille_min']==0 (car on est au premier coup)
122
+    if ($GLOBALS['taille_min'] == 0) {
123
+        $taille = $GLOBALS['taille_max'];
124
+        filtrer('image_recadre', $image_source, $taille, $taille);
125
+        $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-" . $GLOBALS['taille_max']);
126
+    }
127
+    ob_end_clean();
128
+
129
+
130
+    // on est ici, donc pas de plantage
131
+    echo redirige_formulaire($GLOBALS['redirect']);
132 132
 }
Please login to merge, or discard this patch.
ecrire/action/supprimer_lien.php 1 patch
Indentation   +9 added lines, -9 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,14 +35,14 @@  discard block
 block discarded – undo
35 35
  * @return void
36 36
  */
37 37
 function action_supprimer_lien_dist($arg = null) {
38
-	if (is_null($arg)) {
39
-		$securiser_action = charger_fonction('securiser_action', 'inc');
40
-		$arg = $securiser_action();
41
-	}
38
+    if (is_null($arg)) {
39
+        $securiser_action = charger_fonction('securiser_action', 'inc');
40
+        $arg = $securiser_action();
41
+    }
42 42
 
43
-	$arg = explode("-", $arg);
44
-	list($objet_source, $ids, $objet_lie, $idl) = $arg;
43
+    $arg = explode("-", $arg);
44
+    list($objet_source, $ids, $objet_lie, $idl) = $arg;
45 45
 
46
-	include_spip('action/editer_liens');
47
-	objet_dissocier(array($objet_source => $ids), array($objet_lie => $idl));
46
+    include_spip('action/editer_liens');
47
+    objet_dissocier(array($objet_source => $ids), array($objet_lie => $idl));
48 48
 }
Please login to merge, or discard this patch.
ecrire/action/editer_article.php 1 patch
Indentation   +301 added lines, -301 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,36 +40,36 @@  discard block
 block discarded – undo
40 40
  *     Liste (identifiant de l'article, Texte d'erreur éventuel)
41 41
  */
42 42
 function action_editer_article_dist($arg = null) {
43
-	include_spip('inc/autoriser');
44
-	$err = "";
45
-	if (is_null($arg)) {
46
-		$securiser_action = charger_fonction('securiser_action', 'inc');
47
-		$arg = $securiser_action();
48
-	}
49
-
50
-	// si id_article n'est pas un nombre, c'est une creation 
51
-	// mais on verifie qu'on a toutes les donnees qu'il faut.
52
-	if (!$id_article = intval($arg)) {
53
-		$id_parent = _request('id_parent');
54
-		if (!$id_parent) {
55
-			$err = _L("creation interdite d'un article sans rubrique");
56
-		} elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) {
57
-			$err = _T("info_creerdansrubrique_non_autorise");
58
-		} else {
59
-			$id_article = article_inserer($id_parent);
60
-		}
61
-	}
62
-
63
-	// Enregistre l'envoi dans la BD
64
-	if ($id_article > 0) {
65
-		$err = article_modifier($id_article);
66
-	}
67
-
68
-	if ($err) {
69
-		spip_log("echec editeur article: $err", _LOG_ERREUR);
70
-	}
71
-
72
-	return array($id_article, $err);
43
+    include_spip('inc/autoriser');
44
+    $err = "";
45
+    if (is_null($arg)) {
46
+        $securiser_action = charger_fonction('securiser_action', 'inc');
47
+        $arg = $securiser_action();
48
+    }
49
+
50
+    // si id_article n'est pas un nombre, c'est une creation 
51
+    // mais on verifie qu'on a toutes les donnees qu'il faut.
52
+    if (!$id_article = intval($arg)) {
53
+        $id_parent = _request('id_parent');
54
+        if (!$id_parent) {
55
+            $err = _L("creation interdite d'un article sans rubrique");
56
+        } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) {
57
+            $err = _T("info_creerdansrubrique_non_autorise");
58
+        } else {
59
+            $id_article = article_inserer($id_parent);
60
+        }
61
+    }
62
+
63
+    // Enregistre l'envoi dans la BD
64
+    if ($id_article > 0) {
65
+        $err = article_modifier($id_article);
66
+    }
67
+
68
+    if ($err) {
69
+        spip_log("echec editeur article: $err", _LOG_ERREUR);
70
+    }
71
+
72
+    return array($id_article, $err);
73 73
 }
74 74
 
75 75
 /**
@@ -91,46 +91,46 @@  discard block
 block discarded – undo
91 91
  */
92 92
 function article_modifier($id_article, $set = null) {
93 93
 
94
-	// unifier $texte en cas de texte trop long
95
-	trop_longs_articles();
96
-
97
-	include_spip('inc/modifier');
98
-	include_spip('inc/filtres');
99
-	$c = collecter_requests(
100
-	// white list
101
-		objet_info('article', 'champs_editables'),
102
-		// black list
103
-		array('date', 'statut', 'id_parent'),
104
-		// donnees eventuellement fournies
105
-		$set
106
-	);
107
-
108
-	// Si l'article est publie, invalider les caches et demander sa reindexation
109
-	$t = sql_getfetsel("statut", "spip_articles", "id_article=" . intval($id_article));
110
-	$invalideur = $indexation = false;
111
-	if ($t == 'publie') {
112
-		$invalideur = "id='article/$id_article'";
113
-		$indexation = true;
114
-	}
115
-
116
-	if ($err = objet_modifier_champs('article', $id_article,
117
-		array(
118
-			'data' => $set,
119
-			'nonvide' => array('titre' => _T('info_nouvel_article') . " " . _T('info_numero_abbreviation') . $id_article),
120
-			'invalideur' => $invalideur,
121
-			'indexation' => $indexation,
122
-			'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif
123
-		),
124
-		$c)
125
-	) {
126
-		return $err;
127
-	}
128
-
129
-	// Modification de statut, changement de rubrique ?
130
-	$c = collecter_requests(array('date', 'statut', 'id_parent'), array(), $set);
131
-	$err = article_instituer($id_article, $c);
132
-
133
-	return $err;
94
+    // unifier $texte en cas de texte trop long
95
+    trop_longs_articles();
96
+
97
+    include_spip('inc/modifier');
98
+    include_spip('inc/filtres');
99
+    $c = collecter_requests(
100
+    // white list
101
+        objet_info('article', 'champs_editables'),
102
+        // black list
103
+        array('date', 'statut', 'id_parent'),
104
+        // donnees eventuellement fournies
105
+        $set
106
+    );
107
+
108
+    // Si l'article est publie, invalider les caches et demander sa reindexation
109
+    $t = sql_getfetsel("statut", "spip_articles", "id_article=" . intval($id_article));
110
+    $invalideur = $indexation = false;
111
+    if ($t == 'publie') {
112
+        $invalideur = "id='article/$id_article'";
113
+        $indexation = true;
114
+    }
115
+
116
+    if ($err = objet_modifier_champs('article', $id_article,
117
+        array(
118
+            'data' => $set,
119
+            'nonvide' => array('titre' => _T('info_nouvel_article') . " " . _T('info_numero_abbreviation') . $id_article),
120
+            'invalideur' => $invalideur,
121
+            'indexation' => $indexation,
122
+            'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif
123
+        ),
124
+        $c)
125
+    ) {
126
+        return $err;
127
+    }
128
+
129
+    // Modification de statut, changement de rubrique ?
130
+    $c = collecter_requests(array('date', 'statut', 'id_parent'), array(), $set);
131
+    $err = article_instituer($id_article, $c);
132
+
133
+    return $err;
134 134
 }
135 135
 
136 136
 /**
@@ -166,90 +166,90 @@  discard block
 block discarded – undo
166 166
  */
167 167
 function article_inserer($id_rubrique, $set = null) {
168 168
 
169
-	// Si id_rubrique vaut 0 ou n'est pas definie, creer l'article
170
-	// dans la premiere rubrique racine
171
-	if (!$id_rubrique = intval($id_rubrique)) {
172
-		$row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0", '', '0+titre,titre', "1");
173
-		$id_rubrique = $row['id_rubrique'];
174
-	} else {
175
-		$row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=$id_rubrique");
176
-	}
177
-
178
-	// eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue 
179
-	// cas de id_rubrique = -1 par exemple avec plugin "pages"
180
-	$id_secteur = isset($row['id_secteur']) ? $row['id_secteur'] : 0;
181
-
182
-	$lang_rub = $row['lang'];
183
-
184
-	$lang = "";
185
-	$choisie = 'non';
186
-	// La langue a la creation : si les liens de traduction sont autorises
187
-	// dans les rubriques, on essaie avec la langue de l'auteur,
188
-	// ou a defaut celle de la rubrique
189
-	// Sinon c'est la langue de la rubrique qui est choisie + heritee
190
-	if (!empty($GLOBALS['meta']['multi_objets']) and in_array('spip_articles',
191
-			explode(',', $GLOBALS['meta']['multi_objets']))
192
-	) {
193
-		lang_select($GLOBALS['visiteur_session']['lang']);
194
-		if (in_array($GLOBALS['spip_lang'],
195
-			explode(',', $GLOBALS['meta']['langues_multilingue']))) {
196
-			$lang = $GLOBALS['spip_lang'];
197
-			$choisie = 'oui';
198
-		}
199
-	}
200
-
201
-	if (!$lang) {
202
-		$choisie = 'non';
203
-		$lang = $lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site'];
204
-	}
205
-
206
-	$champs = array(
207
-		'id_rubrique' => $id_rubrique,
208
-		'id_secteur' => $id_secteur,
209
-		'statut' => 'prepa',
210
-		'date' => date('Y-m-d H:i:s'),
211
-		'lang' => $lang,
212
-		'langue_choisie' => $choisie
213
-	);
214
-
215
-	if ($set) {
216
-		$champs = array_merge($champs, $set);
217
-	}
218
-
219
-	// Envoyer aux plugins
220
-	$champs = pipeline('pre_insertion',
221
-		array(
222
-			'args' => array(
223
-				'table' => 'spip_articles',
224
-			),
225
-			'data' => $champs
226
-		)
227
-	);
228
-
229
-	$id_article = sql_insertq("spip_articles", $champs);
230
-
231
-	// controler si le serveur n'a pas renvoye une erreur
232
-	if ($id_article > 0) {
233
-		$id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ?
234
-			$GLOBALS['visiteur_session']['id_auteur']
235
-			: _request('id_auteur'));
236
-		if ($id_auteur) {
237
-			include_spip('action/editer_auteur');
238
-			auteur_associer($id_auteur, array('article' => $id_article));
239
-		}
240
-	}
241
-
242
-	pipeline('post_insertion',
243
-		array(
244
-			'args' => array(
245
-				'table' => 'spip_articles',
246
-				'id_objet' => $id_article
247
-			),
248
-			'data' => $champs
249
-		)
250
-	);
251
-
252
-	return $id_article;
169
+    // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article
170
+    // dans la premiere rubrique racine
171
+    if (!$id_rubrique = intval($id_rubrique)) {
172
+        $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0", '', '0+titre,titre', "1");
173
+        $id_rubrique = $row['id_rubrique'];
174
+    } else {
175
+        $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=$id_rubrique");
176
+    }
177
+
178
+    // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue 
179
+    // cas de id_rubrique = -1 par exemple avec plugin "pages"
180
+    $id_secteur = isset($row['id_secteur']) ? $row['id_secteur'] : 0;
181
+
182
+    $lang_rub = $row['lang'];
183
+
184
+    $lang = "";
185
+    $choisie = 'non';
186
+    // La langue a la creation : si les liens de traduction sont autorises
187
+    // dans les rubriques, on essaie avec la langue de l'auteur,
188
+    // ou a defaut celle de la rubrique
189
+    // Sinon c'est la langue de la rubrique qui est choisie + heritee
190
+    if (!empty($GLOBALS['meta']['multi_objets']) and in_array('spip_articles',
191
+            explode(',', $GLOBALS['meta']['multi_objets']))
192
+    ) {
193
+        lang_select($GLOBALS['visiteur_session']['lang']);
194
+        if (in_array($GLOBALS['spip_lang'],
195
+            explode(',', $GLOBALS['meta']['langues_multilingue']))) {
196
+            $lang = $GLOBALS['spip_lang'];
197
+            $choisie = 'oui';
198
+        }
199
+    }
200
+
201
+    if (!$lang) {
202
+        $choisie = 'non';
203
+        $lang = $lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site'];
204
+    }
205
+
206
+    $champs = array(
207
+        'id_rubrique' => $id_rubrique,
208
+        'id_secteur' => $id_secteur,
209
+        'statut' => 'prepa',
210
+        'date' => date('Y-m-d H:i:s'),
211
+        'lang' => $lang,
212
+        'langue_choisie' => $choisie
213
+    );
214
+
215
+    if ($set) {
216
+        $champs = array_merge($champs, $set);
217
+    }
218
+
219
+    // Envoyer aux plugins
220
+    $champs = pipeline('pre_insertion',
221
+        array(
222
+            'args' => array(
223
+                'table' => 'spip_articles',
224
+            ),
225
+            'data' => $champs
226
+        )
227
+    );
228
+
229
+    $id_article = sql_insertq("spip_articles", $champs);
230
+
231
+    // controler si le serveur n'a pas renvoye une erreur
232
+    if ($id_article > 0) {
233
+        $id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ?
234
+            $GLOBALS['visiteur_session']['id_auteur']
235
+            : _request('id_auteur'));
236
+        if ($id_auteur) {
237
+            include_spip('action/editer_auteur');
238
+            auteur_associer($id_auteur, array('article' => $id_article));
239
+        }
240
+    }
241
+
242
+    pipeline('post_insertion',
243
+        array(
244
+            'args' => array(
245
+                'table' => 'spip_articles',
246
+                'id_objet' => $id_article
247
+            ),
248
+            'data' => $champs
249
+        )
250
+    );
251
+
252
+    return $id_article;
253 253
 }
254 254
 
255 255
 
@@ -277,120 +277,120 @@  discard block
 block discarded – undo
277 277
  */
278 278
 function article_instituer($id_article, $c, $calcul_rub = true) {
279 279
 
280
-	include_spip('inc/autoriser');
281
-	include_spip('inc/rubriques');
282
-	include_spip('inc/modifier');
283
-
284
-	$row = sql_fetsel("statut, date, id_rubrique", "spip_articles", "id_article=$id_article");
285
-	$id_rubrique = $row['id_rubrique'];
286
-	$statut_ancien = $statut = $row['statut'];
287
-	$date_ancienne = $date = $row['date'];
288
-	$champs = array();
289
-
290
-	$d = isset($c['date']) ? $c['date'] : null;
291
-	$s = isset($c['statut']) ? $c['statut'] : $statut;
292
-
293
-	// cf autorisations dans inc/instituer_article
294
-	if ($s != $statut or ($d and $d != $date)) {
295
-		if (autoriser('publierdans', 'rubrique', $id_rubrique)) {
296
-			$statut = $champs['statut'] = $s;
297
-		} else {
298
-			if (autoriser('modifier', 'article', $id_article) and $s != 'publie') {
299
-				$statut = $champs['statut'] = $s;
300
-			} else {
301
-				spip_log("editer_article $id_article refus " . join(' ', $c));
302
-			}
303
-		}
304
-
305
-		// En cas de publication, fixer la date a "maintenant"
306
-		// sauf si $c commande autre chose
307
-		// ou si l'article est deja date dans le futur
308
-		// En cas de proposition d'un article (mais pas depublication), idem
309
-		if ($champs['statut'] == 'publie'
310
-			or ($champs['statut'] == 'prop' and ($d or !in_array($statut_ancien, array('publie', 'prop'))))
311
-		) {
312
-			if ($d or strtotime($d = $date) > time()) {
313
-				$champs['date'] = $date = $d;
314
-			} else {
315
-				$champs['date'] = $date = date('Y-m-d H:i:s');
316
-			}
317
-		}
318
-	}
319
-
320
-	// Verifier que la rubrique demandee existe et est differente
321
-	// de la rubrique actuelle
322
-	if (isset($c['id_parent'])
323
-		and $id_parent = $c['id_parent']
324
-		and $id_parent != $id_rubrique
325
-		and (sql_fetsel('1', "spip_rubriques", "id_rubrique=" . intval($id_parent)))
326
-	) {
327
-		$champs['id_rubrique'] = $id_parent;
328
-
329
-		// si l'article etait publie
330
-		// et que le demandeur n'est pas admin de la rubrique de destination
331
-		// repasser l'article en statut 'propose'.
332
-		if ($statut == 'publie'
333
-			and !autoriser('publierdans', 'rubrique', $id_parent)
334
-		) {
335
-			$champs['statut'] = 'prop';
336
-		}
337
-	}
338
-
339
-	// Envoyer aux plugins
340
-	$champs = pipeline('pre_edition',
341
-		array(
342
-			'args' => array(
343
-				'table' => 'spip_articles',
344
-				'id_objet' => $id_article,
345
-				'action' => 'instituer',
346
-				'statut_ancien' => $statut_ancien,
347
-				'date_ancienne' => $date_ancienne,
348
-			),
349
-			'data' => $champs
350
-		)
351
-	);
352
-
353
-	if (!count($champs)) {
354
-		return '';
355
-	}
356
-
357
-	// Envoyer les modifs.
358
-	editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub);
359
-
360
-	// Invalider les caches
361
-	include_spip('inc/invalideur');
362
-	suivre_invalideur("id='article/$id_article'");
363
-
364
-	if ($date) {
365
-		$t = strtotime($date);
366
-		$p = @$GLOBALS['meta']['date_prochain_postdate'];
367
-		if ($t > time() and (!$p or ($t < $p))) {
368
-			ecrire_meta('date_prochain_postdate', $t);
369
-		}
370
-	}
371
-
372
-	// Pipeline
373
-	pipeline('post_edition',
374
-		array(
375
-			'args' => array(
376
-				'table' => 'spip_articles',
377
-				'id_objet' => $id_article,
378
-				'action' => 'instituer',
379
-				'statut_ancien' => $statut_ancien,
380
-				'date_ancienne' => $date_ancienne,
381
-			),
382
-			'data' => $champs
383
-		)
384
-	);
385
-
386
-	// Notifications
387
-	if ($notifications = charger_fonction('notifications', 'inc')) {
388
-		$notifications('instituerarticle', $id_article,
389
-			array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne)
390
-		);
391
-	}
392
-
393
-	return ''; // pas d'erreur
280
+    include_spip('inc/autoriser');
281
+    include_spip('inc/rubriques');
282
+    include_spip('inc/modifier');
283
+
284
+    $row = sql_fetsel("statut, date, id_rubrique", "spip_articles", "id_article=$id_article");
285
+    $id_rubrique = $row['id_rubrique'];
286
+    $statut_ancien = $statut = $row['statut'];
287
+    $date_ancienne = $date = $row['date'];
288
+    $champs = array();
289
+
290
+    $d = isset($c['date']) ? $c['date'] : null;
291
+    $s = isset($c['statut']) ? $c['statut'] : $statut;
292
+
293
+    // cf autorisations dans inc/instituer_article
294
+    if ($s != $statut or ($d and $d != $date)) {
295
+        if (autoriser('publierdans', 'rubrique', $id_rubrique)) {
296
+            $statut = $champs['statut'] = $s;
297
+        } else {
298
+            if (autoriser('modifier', 'article', $id_article) and $s != 'publie') {
299
+                $statut = $champs['statut'] = $s;
300
+            } else {
301
+                spip_log("editer_article $id_article refus " . join(' ', $c));
302
+            }
303
+        }
304
+
305
+        // En cas de publication, fixer la date a "maintenant"
306
+        // sauf si $c commande autre chose
307
+        // ou si l'article est deja date dans le futur
308
+        // En cas de proposition d'un article (mais pas depublication), idem
309
+        if ($champs['statut'] == 'publie'
310
+            or ($champs['statut'] == 'prop' and ($d or !in_array($statut_ancien, array('publie', 'prop'))))
311
+        ) {
312
+            if ($d or strtotime($d = $date) > time()) {
313
+                $champs['date'] = $date = $d;
314
+            } else {
315
+                $champs['date'] = $date = date('Y-m-d H:i:s');
316
+            }
317
+        }
318
+    }
319
+
320
+    // Verifier que la rubrique demandee existe et est differente
321
+    // de la rubrique actuelle
322
+    if (isset($c['id_parent'])
323
+        and $id_parent = $c['id_parent']
324
+        and $id_parent != $id_rubrique
325
+        and (sql_fetsel('1', "spip_rubriques", "id_rubrique=" . intval($id_parent)))
326
+    ) {
327
+        $champs['id_rubrique'] = $id_parent;
328
+
329
+        // si l'article etait publie
330
+        // et que le demandeur n'est pas admin de la rubrique de destination
331
+        // repasser l'article en statut 'propose'.
332
+        if ($statut == 'publie'
333
+            and !autoriser('publierdans', 'rubrique', $id_parent)
334
+        ) {
335
+            $champs['statut'] = 'prop';
336
+        }
337
+    }
338
+
339
+    // Envoyer aux plugins
340
+    $champs = pipeline('pre_edition',
341
+        array(
342
+            'args' => array(
343
+                'table' => 'spip_articles',
344
+                'id_objet' => $id_article,
345
+                'action' => 'instituer',
346
+                'statut_ancien' => $statut_ancien,
347
+                'date_ancienne' => $date_ancienne,
348
+            ),
349
+            'data' => $champs
350
+        )
351
+    );
352
+
353
+    if (!count($champs)) {
354
+        return '';
355
+    }
356
+
357
+    // Envoyer les modifs.
358
+    editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub);
359
+
360
+    // Invalider les caches
361
+    include_spip('inc/invalideur');
362
+    suivre_invalideur("id='article/$id_article'");
363
+
364
+    if ($date) {
365
+        $t = strtotime($date);
366
+        $p = @$GLOBALS['meta']['date_prochain_postdate'];
367
+        if ($t > time() and (!$p or ($t < $p))) {
368
+            ecrire_meta('date_prochain_postdate', $t);
369
+        }
370
+    }
371
+
372
+    // Pipeline
373
+    pipeline('post_edition',
374
+        array(
375
+            'args' => array(
376
+                'table' => 'spip_articles',
377
+                'id_objet' => $id_article,
378
+                'action' => 'instituer',
379
+                'statut_ancien' => $statut_ancien,
380
+                'date_ancienne' => $date_ancienne,
381
+            ),
382
+            'data' => $champs
383
+        )
384
+    );
385
+
386
+    // Notifications
387
+    if ($notifications = charger_fonction('notifications', 'inc')) {
388
+        $notifications('instituerarticle', $id_article,
389
+            array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne)
390
+        );
391
+    }
392
+
393
+    return ''; // pas d'erreur
394 394
 }
395 395
 
396 396
 /**
@@ -415,33 +415,33 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond = true) {
417 417
 
418
-	// Si on deplace l'article
419
-	//  changer aussi son secteur et sa langue (si heritee)
420
-	if (isset($champs['id_rubrique'])) {
418
+    // Si on deplace l'article
419
+    //  changer aussi son secteur et sa langue (si heritee)
420
+    if (isset($champs['id_rubrique'])) {
421 421
 
422
-		$row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=" . sql_quote($champs['id_rubrique']));
422
+        $row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=" . sql_quote($champs['id_rubrique']));
423 423
 
424
-		$langue = $row_rub['lang'];
425
-		$champs['id_secteur'] = $row_rub['id_secteur'];
426
-		if (sql_fetsel('1', 'spip_articles',
427
-			"id_article=" . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) {
428
-			$champs['lang'] = $langue;
429
-		}
430
-	}
424
+        $langue = $row_rub['lang'];
425
+        $champs['id_secteur'] = $row_rub['id_secteur'];
426
+        if (sql_fetsel('1', 'spip_articles',
427
+            "id_article=" . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) {
428
+            $champs['lang'] = $langue;
429
+        }
430
+    }
431 431
 
432
-	if (!$champs) {
433
-		return;
434
-	}
432
+    if (!$champs) {
433
+        return;
434
+    }
435 435
 
436
-	sql_updateq('spip_articles', $champs, "id_article=" . intval($id_article));
436
+    sql_updateq('spip_articles', $champs, "id_article=" . intval($id_article));
437 437
 
438
-	// Changer le statut des rubriques concernees 
438
+    // Changer le statut des rubriques concernees 
439 439
 
440
-	if ($cond) {
441
-		include_spip('inc/rubriques');
442
-		$postdate = ($GLOBALS['meta']["post_dates"] == "non" and isset($champs['date']) and (strtotime($champs['date']) < time())) ? $champs['date'] : false;
443
-		calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate);
444
-	}
440
+    if ($cond) {
441
+        include_spip('inc/rubriques');
442
+        $postdate = ($GLOBALS['meta']["post_dates"] == "non" and isset($champs['date']) and (strtotime($champs['date']) < time())) ? $champs['date'] : false;
443
+        calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate);
444
+    }
445 445
 }
446 446
 
447 447
 /**
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
  * @return void
451 451
  */
452 452
 function trop_longs_articles() {
453
-	if (is_array($plus = _request('texte_plus'))) {
454
-		foreach ($plus as $n => $t) {
455
-			$plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", "", $t);
456
-		}
457
-		set_request('texte', join('', $plus) . _request('texte'));
458
-	}
453
+    if (is_array($plus = _request('texte_plus'))) {
454
+        foreach ($plus as $n => $t) {
455
+            $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", "", $t);
456
+        }
457
+        set_request('texte', join('', $plus) . _request('texte'));
458
+    }
459 459
 }
460 460
 
461 461
 
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
  *     Chaîne contenant un texte d'erreur sinon.
481 481
  */
482 482
 function revisions_articles($id_article, $c = false) {
483
-	return article_modifier($id_article, $c);
483
+    return article_modifier($id_article, $c);
484 484
 }
485 485
 
486 486
 /**
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
  *     Chaîne contenant un texte d'erreur sinon.
502 502
  */
503 503
 function revision_article($id_article, $c = false) {
504
-	return article_modifier($id_article, $c);
504
+    return article_modifier($id_article, $c);
505 505
 }
506 506
 
507 507
 /**
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
  *     Chaîne contenant un texte d'erreur sinon.
523 523
  */
524 524
 function articles_set($id_article, $set = null) {
525
-	return article_modifier($id_article, $set);
525
+    return article_modifier($id_article, $set);
526 526
 }
527 527
 
528 528
 /**
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
  *     Identifiant du nouvel article
538 538
  */
539 539
 function insert_article($id_rubrique) {
540
-	return article_inserer($id_rubrique);
540
+    return article_inserer($id_rubrique);
541 541
 }
542 542
 
543 543
 /**
@@ -559,5 +559,5 @@  discard block
 block discarded – undo
559 559
  *     Chaîne vide
560 560
  */
561 561
 function instituer_article($id_article, $c, $calcul_rub = true) {
562
-	return article_instituer($id_article, $c, $calcul_rub);
562
+    return article_instituer($id_article, $c, $calcul_rub);
563 563
 }
Please login to merge, or discard this patch.
ecrire/action/session.php 1 patch
Indentation   +12 added lines, -12 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
 /**
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
  *   Envoyer en réponse : json contenant toutes les variables publiques de la session
33 33
  **/
34 34
 function action_session_dist() {
35
-	if ($var = _request('var')
36
-		and preg_match(',^[a-z_0-9-]+$,i', $var)
37
-	) {
38
-		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
39
-			include_spip('inc/session');
40
-			session_set('session_' . $var, $val = _request('val'));
41
-			#spip_log("autosave:$var:$val",'autosave');
42
-		}
43
-	}
35
+    if ($var = _request('var')
36
+        and preg_match(',^[a-z_0-9-]+$,i', $var)
37
+    ) {
38
+        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
39
+            include_spip('inc/session');
40
+            session_set('session_' . $var, $val = _request('val'));
41
+            #spip_log("autosave:$var:$val",'autosave');
42
+        }
43
+    }
44 44
 
45
-	# TODO: mode lecture de session ; n'afficher que ce qu'il faut
46
-	#echo json_encode($GLOBALS['visiteur_session']);
45
+    # TODO: mode lecture de session ; n'afficher que ce qu'il faut
46
+    #echo json_encode($GLOBALS['visiteur_session']);
47 47
 }
Please login to merge, or discard this patch.
ecrire/action/instituer_objet.php 1 patch
Indentation   +21 added lines, -21 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
 /**
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function action_instituer_objet_dist($arg = null) {
31 31
 
32
-	if (is_null($arg)) {
33
-		$securiser_action = charger_fonction('securiser_action', 'inc');
34
-		$arg = $securiser_action();
35
-	}
36
-
37
-	list($objet, $id_objet, $statut) = preg_split('/\W/', $arg);
38
-	if (!$statut) {
39
-		$statut = _request('statut_nouv');
40
-	} // cas POST
41
-	if (!$statut) {
42
-		return;
43
-	} // impossible mais sait-on jamais
44
-
45
-	if ($id_objet = intval($id_objet)
46
-		and autoriser('instituer', $objet, $id_objet, '', array('statut' => $statut))
47
-	) {
48
-
49
-		include_spip('action/editer_objet');
50
-		objet_modifier($objet, $id_objet, array('statut' => $statut));
51
-	}
32
+    if (is_null($arg)) {
33
+        $securiser_action = charger_fonction('securiser_action', 'inc');
34
+        $arg = $securiser_action();
35
+    }
36
+
37
+    list($objet, $id_objet, $statut) = preg_split('/\W/', $arg);
38
+    if (!$statut) {
39
+        $statut = _request('statut_nouv');
40
+    } // cas POST
41
+    if (!$statut) {
42
+        return;
43
+    } // impossible mais sait-on jamais
44
+
45
+    if ($id_objet = intval($id_objet)
46
+        and autoriser('instituer', $objet, $id_objet, '', array('statut' => $statut))
47
+    ) {
48
+
49
+        include_spip('action/editer_objet');
50
+        objet_modifier($objet, $id_objet, array('statut' => $statut));
51
+    }
52 52
 
53 53
 }
Please login to merge, or discard this patch.
ecrire/action/instituer_langue_objet.php 1 patch
Indentation   +37 added lines, -37 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
 /**
@@ -31,43 +31,43 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function action_instituer_langue_objet_dist($objet, $id, $id_rubrique, $changer_lang, $serveur='') {
34
-	if ($changer_lang) {
35
-		$table_objet_sql = table_objet_sql($objet);
36
-		$id_table_objet = id_table_objet($objet);
37
-		$trouver_table = charger_fonction('trouver_table', 'base');
38
-		$desc = $trouver_table($table_objet_sql, $serveur);
34
+    if ($changer_lang) {
35
+        $table_objet_sql = table_objet_sql($objet);
36
+        $id_table_objet = id_table_objet($objet);
37
+        $trouver_table = charger_fonction('trouver_table', 'base');
38
+        $desc = $trouver_table($table_objet_sql, $serveur);
39 39
 		
40
-		$set = array();
41
-		if (isset($desc['field']['langue_choisie'])){
42
-			$set['langue_choisie'] = 'oui';
43
-		}
40
+        $set = array();
41
+        if (isset($desc['field']['langue_choisie'])){
42
+            $set['langue_choisie'] = 'oui';
43
+        }
44 44
 		
45
-		if ($changer_lang != "herit") {
46
-			$set['lang'] = $changer_lang;
47
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id),'',$serveur);
48
-			include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
49
-			if ($table_objet_sql == 'spip_rubriques') {
50
-				calculer_langues_rubriques();
51
-			}
52
-			$langues = calculer_langues_utilisees($serveur);
53
-			ecrire_meta('langues_utilisees', $langues);
54
-		} else {
55
-			$langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
56
-			if (!$langue_parent) {
57
-				$langue_parent = $GLOBALS['meta']['langue_site'];
58
-			}
59
-			$changer_lang = $langue_parent;
60
-			$set['lang'] = $changer_lang;
61
-			if (isset($set['langue_choisie'])){
62
-				$set['langue_choisie'] = 'non';
63
-			}
64
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id),'',$serveur);
65
-			if ($table_objet_sql == 'spip_rubriques') {
66
-				include_spip('inc/rubriques');
67
-				calculer_langues_rubriques();
68
-			}
69
-		}
70
-	}
45
+        if ($changer_lang != "herit") {
46
+            $set['lang'] = $changer_lang;
47
+            sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id),'',$serveur);
48
+            include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
49
+            if ($table_objet_sql == 'spip_rubriques') {
50
+                calculer_langues_rubriques();
51
+            }
52
+            $langues = calculer_langues_utilisees($serveur);
53
+            ecrire_meta('langues_utilisees', $langues);
54
+        } else {
55
+            $langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
56
+            if (!$langue_parent) {
57
+                $langue_parent = $GLOBALS['meta']['langue_site'];
58
+            }
59
+            $changer_lang = $langue_parent;
60
+            $set['lang'] = $changer_lang;
61
+            if (isset($set['langue_choisie'])){
62
+                $set['langue_choisie'] = 'non';
63
+            }
64
+            sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id),'',$serveur);
65
+            if ($table_objet_sql == 'spip_rubriques') {
66
+                include_spip('inc/rubriques');
67
+                calculer_langues_rubriques();
68
+            }
69
+        }
70
+    }
71 71
 
72
-	return $changer_lang;
72
+    return $changer_lang;
73 73
 }
Please login to merge, or discard this patch.
ecrire/action/logout.php 1 patch
Indentation   +82 added lines, -82 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/cookie');
@@ -34,68 +34,68 @@  discard block
 block discarded – undo
34 34
  *
35 35
  */
36 36
 function action_logout_dist() {
37
-	$logout = _request('logout');
38
-	$url = securiser_redirect_action(_request('url'));
39
-	// cas particulier, logout dans l'espace public
40
-	if ($logout == 'public' and !$url) {
41
-		$url = url_de_base();
42
-	}
43
-
44
-	// seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee)
45
-	if (isset($GLOBALS['visiteur_session']['id_auteur'])
46
-		and is_numeric($GLOBALS['visiteur_session']['id_auteur'])
47
-		// des sessions anonymes avec id_auteur=0 existent, mais elle n'ont pas de statut : double check
48
-		and isset($GLOBALS['visiteur_session']['statut'])
49
-	) {
50
-
51
-		// il faut un jeton pour fermer la session (eviter les CSRF)
52
-		if (!$jeton = _request('jeton')
53
-			or !verifier_jeton_logout($jeton, $GLOBALS['visiteur_session'])
54
-		) {
55
-			$jeton = generer_jeton_logout($GLOBALS['visiteur_session']);
56
-			$action = generer_url_action("logout", "jeton=$jeton");
57
-			$action = parametre_url($action, 'logout', _request('logout'));
58
-			$action = parametre_url($action, 'url', _request('url'));
59
-			include_spip("inc/minipres");
60
-			include_spip("inc/filtres");
61
-			$texte = bouton_action(_T('spip:icone_deconnecter'), $action);
62
-			$texte = "<div class='boutons'>$texte</div>";
63
-			$texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>';
64
-			$res = minipres(_T('spip:icone_deconnecter'), $texte, '', true);
65
-			echo $res;
66
-
67
-			return;
68
-		}
69
-
70
-		include_spip('inc/auth');
71
-		auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00');
72
-		// le logout explicite vaut destruction de toutes les sessions
73
-		if (isset($_COOKIE['spip_session'])) {
74
-			$session = charger_fonction('session', 'inc');
75
-			$session($GLOBALS['visiteur_session']['id_auteur']);
76
-			spip_setcookie('spip_session', $_COOKIE['spip_session'], time() - 3600);
77
-		}
78
-		// si authentification http, et que la personne est loge,
79
-		// pour se deconnecter, il faut proposer un nouveau formulaire de connexion http
80
-		if (isset($_SERVER['PHP_AUTH_USER'])
81
-			and !$GLOBALS['ignore_auth_http']
82
-			and $GLOBALS['auth_can_disconnect']
83
-		) {
84
-			ask_php_auth(_T('login_deconnexion_ok'),
85
-				_T('login_verifiez_navigateur'),
86
-				_T('login_retour_public'),
87
-				"redirect=" . _DIR_RESTREINT_ABS,
88
-				_T('login_test_navigateur'),
89
-				true);
90
-
91
-		}
92
-	}
93
-
94
-	// Rediriger en contrant le cache navigateur (Safari3)
95
-	include_spip('inc/headers');
96
-	redirige_par_entete($url
97
-		? parametre_url($url, 'var_hasard', uniqid(rand()), '&')
98
-		: generer_url_public('login'));
37
+    $logout = _request('logout');
38
+    $url = securiser_redirect_action(_request('url'));
39
+    // cas particulier, logout dans l'espace public
40
+    if ($logout == 'public' and !$url) {
41
+        $url = url_de_base();
42
+    }
43
+
44
+    // seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee)
45
+    if (isset($GLOBALS['visiteur_session']['id_auteur'])
46
+        and is_numeric($GLOBALS['visiteur_session']['id_auteur'])
47
+        // des sessions anonymes avec id_auteur=0 existent, mais elle n'ont pas de statut : double check
48
+        and isset($GLOBALS['visiteur_session']['statut'])
49
+    ) {
50
+
51
+        // il faut un jeton pour fermer la session (eviter les CSRF)
52
+        if (!$jeton = _request('jeton')
53
+            or !verifier_jeton_logout($jeton, $GLOBALS['visiteur_session'])
54
+        ) {
55
+            $jeton = generer_jeton_logout($GLOBALS['visiteur_session']);
56
+            $action = generer_url_action("logout", "jeton=$jeton");
57
+            $action = parametre_url($action, 'logout', _request('logout'));
58
+            $action = parametre_url($action, 'url', _request('url'));
59
+            include_spip("inc/minipres");
60
+            include_spip("inc/filtres");
61
+            $texte = bouton_action(_T('spip:icone_deconnecter'), $action);
62
+            $texte = "<div class='boutons'>$texte</div>";
63
+            $texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>';
64
+            $res = minipres(_T('spip:icone_deconnecter'), $texte, '', true);
65
+            echo $res;
66
+
67
+            return;
68
+        }
69
+
70
+        include_spip('inc/auth');
71
+        auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00');
72
+        // le logout explicite vaut destruction de toutes les sessions
73
+        if (isset($_COOKIE['spip_session'])) {
74
+            $session = charger_fonction('session', 'inc');
75
+            $session($GLOBALS['visiteur_session']['id_auteur']);
76
+            spip_setcookie('spip_session', $_COOKIE['spip_session'], time() - 3600);
77
+        }
78
+        // si authentification http, et que la personne est loge,
79
+        // pour se deconnecter, il faut proposer un nouveau formulaire de connexion http
80
+        if (isset($_SERVER['PHP_AUTH_USER'])
81
+            and !$GLOBALS['ignore_auth_http']
82
+            and $GLOBALS['auth_can_disconnect']
83
+        ) {
84
+            ask_php_auth(_T('login_deconnexion_ok'),
85
+                _T('login_verifiez_navigateur'),
86
+                _T('login_retour_public'),
87
+                "redirect=" . _DIR_RESTREINT_ABS,
88
+                _T('login_test_navigateur'),
89
+                true);
90
+
91
+        }
92
+    }
93
+
94
+    // Rediriger en contrant le cache navigateur (Safari3)
95
+    include_spip('inc/headers');
96
+    redirige_par_entete($url
97
+        ? parametre_url($url, 'var_hasard', uniqid(rand()), '&')
98
+        : generer_url_public('login'));
99 99
 }
100 100
 
101 101
 /**
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
  * @return string
107 107
  */
108 108
 function generer_jeton_logout($session, $alea = null) {
109
-	if (is_null($alea)) {
110
-		include_spip('inc/acces');
111
-		$alea = charger_aleas();
112
-	}
113
-
114
-	$jeton = md5($session['date_session']
115
-		. $session['id_auteur']
116
-		. $session['statut']
117
-		. $alea
118
-	);
119
-
120
-	return $jeton;
109
+    if (is_null($alea)) {
110
+        include_spip('inc/acces');
111
+        $alea = charger_aleas();
112
+    }
113
+
114
+    $jeton = md5($session['date_session']
115
+        . $session['id_auteur']
116
+        . $session['statut']
117
+        . $alea
118
+    );
119
+
120
+    return $jeton;
121 121
 }
122 122
 
123 123
 /**
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
  * @return bool
132 132
  */
133 133
 function verifier_jeton_logout($jeton, $session) {
134
-	if (generer_jeton_logout($session) === $jeton) {
135
-		return true;
136
-	}
134
+    if (generer_jeton_logout($session) === $jeton) {
135
+        return true;
136
+    }
137 137
 
138
-	if (generer_jeton_logout($session, $GLOBALS['meta']['alea_ephemere_ancien']) === $jeton) {
139
-		return true;
140
-	}
138
+    if (generer_jeton_logout($session, $GLOBALS['meta']['alea_ephemere_ancien']) === $jeton) {
139
+        return true;
140
+    }
141 141
 
142
-	return false;
142
+    return false;
143 143
 }
Please login to merge, or discard this patch.
ecrire/action/forcer_job.php 1 patch
Indentation   +10 added lines, -10 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
 /**
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @return void
27 27
  */
28 28
 function action_forcer_job_dist() {
29
-	$securiser_action = charger_fonction('securiser_action', 'inc');
30
-	$id_job = $securiser_action();
29
+    $securiser_action = charger_fonction('securiser_action', 'inc');
30
+    $id_job = $securiser_action();
31 31
 
32
-	if ($id_job = intval($id_job)
33
-		and autoriser('forcer', 'job', $id_job)
34
-	) {
35
-		include_spip('inc/queue');
36
-		include_spip('inc/genie');
37
-		queue_schedule(array($id_job));
38
-	}
32
+    if ($id_job = intval($id_job)
33
+        and autoriser('forcer', 'job', $id_job)
34
+    ) {
35
+        include_spip('inc/queue');
36
+        include_spip('inc/genie');
37
+        queue_schedule(array($id_job));
38
+    }
39 39
 
40 40
 }
Please login to merge, or discard this patch.
ecrire/action/purger.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
  * @package SPIP\Core\Cache
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -39,54 +39,54 @@  discard block
 block discarded – undo
39 39
  *     de l'action sécurisée.
40 40
  */
41 41
 function action_purger_dist($arg = null) {
42
-	if (is_null($arg)) {
43
-		$securiser_action = charger_fonction('securiser_action', 'inc');
44
-		$arg = $securiser_action();
45
-	}
42
+    if (is_null($arg)) {
43
+        $securiser_action = charger_fonction('securiser_action', 'inc');
44
+        $arg = $securiser_action();
45
+    }
46 46
 
47
-	include_spip('inc/invalideur');
47
+    include_spip('inc/invalideur');
48 48
 
49
-	spip_log("purger $arg");
49
+    spip_log("purger $arg");
50 50
 
51
-	switch ($arg) {
52
-		case 'inhibe_cache':
53
-			// inhiber le cache pendant 24h
54
-			ecrire_meta('cache_inhib', $_SERVER['REQUEST_TIME'] + 24 * 3600);
55
-			break;
56
-		case 'reactive_cache':
57
-			effacer_meta('cache_inhib');
58
-			break;
51
+    switch ($arg) {
52
+        case 'inhibe_cache':
53
+            // inhiber le cache pendant 24h
54
+            ecrire_meta('cache_inhib', $_SERVER['REQUEST_TIME'] + 24 * 3600);
55
+            break;
56
+        case 'reactive_cache':
57
+            effacer_meta('cache_inhib');
58
+            break;
59 59
 
60
-		case 'cache':
61
-			supprime_invalideurs();
62
-			@spip_unlink(_CACHE_RUBRIQUES);
63
-			@spip_unlink(_CACHE_CHEMIN);
64
-			@spip_unlink(_DIR_TMP . "plugin_xml_cache.gz");
65
-			// on ne supprime que _CACHE_PLUGINS_OPT qui declenche la reconstruction des 3
66
-			// _CACHE_PIPELINES _CACHE_PLUGINS_PATH et _CACHE_PLUGINS_FCT
67
-			// pour eviter des problemes de concurence
68
-			// cf http://core.spip.net/issues/2989
69
-			//@spip_unlink(_CACHE_PIPELINES);
70
-			//@spip_unlink(_CACHE_PLUGINS_PATH);
71
-			//@spip_unlink(_CACHE_PLUGINS_FCT);
72
-			@spip_unlink(_CACHE_PLUGINS_OPT);
73
-			purger_repertoire(_DIR_CACHE, array('subdir' => true));
74
-			purger_repertoire(_DIR_AIDE);
75
-			purger_repertoire(_DIR_VAR . 'cache-css');
76
-			purger_repertoire(_DIR_VAR . 'cache-js');
77
-			break;
60
+        case 'cache':
61
+            supprime_invalideurs();
62
+            @spip_unlink(_CACHE_RUBRIQUES);
63
+            @spip_unlink(_CACHE_CHEMIN);
64
+            @spip_unlink(_DIR_TMP . "plugin_xml_cache.gz");
65
+            // on ne supprime que _CACHE_PLUGINS_OPT qui declenche la reconstruction des 3
66
+            // _CACHE_PIPELINES _CACHE_PLUGINS_PATH et _CACHE_PLUGINS_FCT
67
+            // pour eviter des problemes de concurence
68
+            // cf http://core.spip.net/issues/2989
69
+            //@spip_unlink(_CACHE_PIPELINES);
70
+            //@spip_unlink(_CACHE_PLUGINS_PATH);
71
+            //@spip_unlink(_CACHE_PLUGINS_FCT);
72
+            @spip_unlink(_CACHE_PLUGINS_OPT);
73
+            purger_repertoire(_DIR_CACHE, array('subdir' => true));
74
+            purger_repertoire(_DIR_AIDE);
75
+            purger_repertoire(_DIR_VAR . 'cache-css');
76
+            purger_repertoire(_DIR_VAR . 'cache-js');
77
+            break;
78 78
 
79
-		case 'squelettes':
80
-			purger_repertoire(_DIR_SKELS);
81
-			break;
79
+        case 'squelettes':
80
+            purger_repertoire(_DIR_SKELS);
81
+            break;
82 82
 
83
-		case 'vignettes':
84
-			purger_repertoire(_DIR_VAR, array('subdir' => true));
85
-			supprime_invalideurs();
86
-			purger_repertoire(_DIR_CACHE, array('subdir' => true));
87
-			break;
88
-	}
83
+        case 'vignettes':
84
+            purger_repertoire(_DIR_VAR, array('subdir' => true));
85
+            supprime_invalideurs();
86
+            purger_repertoire(_DIR_CACHE, array('subdir' => true));
87
+            break;
88
+    }
89 89
 
90
-	// le faire savoir aux plugins
91
-	pipeline('trig_purger', $arg);
90
+    // le faire savoir aux plugins
91
+    pipeline('trig_purger', $arg);
92 92
 }
Please login to merge, or discard this patch.