Completed
Push — master ( 3a7980...c8fa57 )
by cam
04:18
created
prive/formulaires/editer_article.php 1 patch
Indentation   +100 added lines, -100 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/actions');
@@ -46,33 +46,33 @@  discard block
 block discarded – undo
46 46
  *     Environnement du formulaire
47 47
  **/
48 48
 function formulaires_editer_article_charger_dist(
49
-	$id_article = 'new',
50
-	$id_rubrique = 0,
51
-	$retour = '',
52
-	$lier_trad = 0,
53
-	$config_fonc = 'articles_edit_config',
54
-	$row = array(),
55
-	$hidden = ''
49
+    $id_article = 'new',
50
+    $id_rubrique = 0,
51
+    $retour = '',
52
+    $lier_trad = 0,
53
+    $config_fonc = 'articles_edit_config',
54
+    $row = array(),
55
+    $hidden = ''
56 56
 ) {
57
-	$valeurs = formulaires_editer_objet_charger(
58
-		'article',
59
-		$id_article,
60
-		$id_rubrique,
61
-		$lier_trad,
62
-		$retour,
63
-		$config_fonc,
64
-		$row,
65
-		$hidden
66
-	);
67
-
68
-	if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) {
69
-		$valeurs['editable'] = '';
70
-	}
71
-
72
-	// il faut enlever l'id_rubrique car la saisie se fait sur id_parent
73
-	// et id_rubrique peut etre passe dans l'url comme rubrique parent initiale
74
-	// et sera perdue si elle est supposee saisie
75
-	return $valeurs;
57
+    $valeurs = formulaires_editer_objet_charger(
58
+        'article',
59
+        $id_article,
60
+        $id_rubrique,
61
+        $lier_trad,
62
+        $retour,
63
+        $config_fonc,
64
+        $row,
65
+        $hidden
66
+    );
67
+
68
+    if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) {
69
+        $valeurs['editable'] = '';
70
+    }
71
+
72
+    // il faut enlever l'id_rubrique car la saisie se fait sur id_parent
73
+    // et id_rubrique peut etre passe dans l'url comme rubrique parent initiale
74
+    // et sera perdue si elle est supposee saisie
75
+    return $valeurs;
76 76
 }
77 77
 
78 78
 /**
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
  *     Hash du formulaire
98 98
  */
99 99
 function formulaires_editer_article_identifier_dist(
100
-	$id_article = 'new',
101
-	$id_rubrique = 0,
102
-	$retour = '',
103
-	$lier_trad = 0,
104
-	$config_fonc = 'articles_edit_config',
105
-	$row = array(),
106
-	$hidden = ''
100
+    $id_article = 'new',
101
+    $id_rubrique = 0,
102
+    $retour = '',
103
+    $lier_trad = 0,
104
+    $config_fonc = 'articles_edit_config',
105
+    $row = array(),
106
+    $hidden = ''
107 107
 ) {
108
-	return serialize(array(intval($id_article), $lier_trad));
108
+    return serialize(array(intval($id_article), $lier_trad));
109 109
 }
110 110
 
111 111
 /**
@@ -117,15 +117,15 @@  discard block
 block discarded – undo
117 117
  *     Configuration pour le formulaire
118 118
  */
119 119
 function articles_edit_config($row) {
120
-	global $spip_lang;
120
+    global $spip_lang;
121 121
 
122
-	$config = $GLOBALS['meta'];
123
-	$config['lignes'] = 8;
124
-	$config['langue'] = $spip_lang;
122
+    $config = $GLOBALS['meta'];
123
+    $config['lignes'] = 8;
124
+    $config['langue'] = $spip_lang;
125 125
 
126
-	$config['restreint'] = ($row['statut'] == 'publie');
126
+    $config['restreint'] = ($row['statut'] == 'publie');
127 127
 
128
-	return $config;
128
+    return $config;
129 129
 }
130 130
 
131 131
 /**
@@ -151,42 +151,42 @@  discard block
 block discarded – undo
151 151
  *     Erreurs du formulaire
152 152
  **/
153 153
 function formulaires_editer_article_verifier_dist(
154
-	$id_article = 'new',
155
-	$id_rubrique = 0,
156
-	$retour = '',
157
-	$lier_trad = 0,
158
-	$config_fonc = 'articles_edit_config',
159
-	$row = array(),
160
-	$hidden = ''
154
+    $id_article = 'new',
155
+    $id_rubrique = 0,
156
+    $retour = '',
157
+    $lier_trad = 0,
158
+    $config_fonc = 'articles_edit_config',
159
+    $row = array(),
160
+    $hidden = ''
161 161
 ) {
162
-	// auto-renseigner le titre si il n'existe pas
163
-	titre_automatique('titre', array('descriptif', 'chapo', 'texte'));
164
-	if (!_request('id_parent') and !intval($id_article)) {
165
-		$valeurs = formulaires_editer_objet_charger(
166
-			'article',
167
-			$id_article,
168
-			$id_rubrique,
169
-			$lier_trad,
170
-			$retour,
171
-			$config_fonc,
172
-			$row,
173
-			$hidden
174
-		);
175
-		set_request('id_parent', $valeurs['id_parent']);
176
-	}
177
-	// on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide
178
-	$erreurs = formulaires_editer_objet_verifier('article', $id_article, array('id_parent'));
179
-	// si on utilise le formulaire dans le public
180
-	if (!function_exists('autoriser')) {
181
-		include_spip('inc/autoriser');
182
-	}
183
-	if (!isset($erreurs['id_parent'])
184
-		and !autoriser('creerarticledans', 'rubrique', _request('id_parent'))
185
-	) {
186
-		$erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise');
187
-	}
188
-
189
-	return $erreurs;
162
+    // auto-renseigner le titre si il n'existe pas
163
+    titre_automatique('titre', array('descriptif', 'chapo', 'texte'));
164
+    if (!_request('id_parent') and !intval($id_article)) {
165
+        $valeurs = formulaires_editer_objet_charger(
166
+            'article',
167
+            $id_article,
168
+            $id_rubrique,
169
+            $lier_trad,
170
+            $retour,
171
+            $config_fonc,
172
+            $row,
173
+            $hidden
174
+        );
175
+        set_request('id_parent', $valeurs['id_parent']);
176
+    }
177
+    // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide
178
+    $erreurs = formulaires_editer_objet_verifier('article', $id_article, array('id_parent'));
179
+    // si on utilise le formulaire dans le public
180
+    if (!function_exists('autoriser')) {
181
+        include_spip('inc/autoriser');
182
+    }
183
+    if (!isset($erreurs['id_parent'])
184
+        and !autoriser('creerarticledans', 'rubrique', _request('id_parent'))
185
+    ) {
186
+        $erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise');
187
+    }
188
+
189
+    return $erreurs;
190 190
 }
191 191
 
192 192
 /**
@@ -212,29 +212,29 @@  discard block
 block discarded – undo
212 212
  *     Retours des traitements
213 213
  **/
214 214
 function formulaires_editer_article_traiter_dist(
215
-	$id_article = 'new',
216
-	$id_rubrique = 0,
217
-	$retour = '',
218
-	$lier_trad = 0,
219
-	$config_fonc = 'articles_edit_config',
220
-	$row = array(),
221
-	$hidden = ''
215
+    $id_article = 'new',
216
+    $id_rubrique = 0,
217
+    $retour = '',
218
+    $lier_trad = 0,
219
+    $config_fonc = 'articles_edit_config',
220
+    $row = array(),
221
+    $hidden = ''
222 222
 ) {
223
-	// ici on ignore changer_lang qui est poste en cas de trad,
224
-	// car l'heuristique du choix de la langue est pris en charge par article_inserer
225
-	// en fonction de la config du site et de la rubrique choisie
226
-	if (!$lier_trad) {
227
-		set_request('changer_lang');
228
-	}
229
-
230
-	return formulaires_editer_objet_traiter(
231
-		'article',
232
-		$id_article,
233
-		$id_rubrique,
234
-		$lier_trad,
235
-		$retour,
236
-		$config_fonc,
237
-		$row,
238
-		$hidden
239
-	);
223
+    // ici on ignore changer_lang qui est poste en cas de trad,
224
+    // car l'heuristique du choix de la langue est pris en charge par article_inserer
225
+    // en fonction de la config du site et de la rubrique choisie
226
+    if (!$lier_trad) {
227
+        set_request('changer_lang');
228
+    }
229
+
230
+    return formulaires_editer_objet_traiter(
231
+        'article',
232
+        $id_article,
233
+        $id_rubrique,
234
+        $lier_trad,
235
+        $retour,
236
+        $config_fonc,
237
+        $row,
238
+        $hidden
239
+    );
240 240
 }
Please login to merge, or discard this patch.
ecrire/inc/recherche_to_array.php 2 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -12,243 +12,243 @@
 block discarded – undo
12 12
 
13 13
 
14 14
 if (!defined('_ECRIRE_INC_VERSION')) {
15
-	return;
15
+    return;
16 16
 }
17 17
 
18 18
 
19 19
 // methodes sql
20 20
 function inc_recherche_to_array_dist($recherche, $options = array()) {
21 21
 
22
-	// options par defaut
23
-	$options = array_merge(
24
-		array(
25
-			'score' => true,
26
-			'champs' => false,
27
-			'toutvoir' => false,
28
-			'matches' => false,
29
-			'jointures' => false
30
-		),
31
-		$options
32
-	);
33
-
34
-	include_spip('inc/rechercher');
35
-	include_spip('inc/autoriser');
36
-
37
-	$requete = array(
38
-		"SELECT" => array(),
39
-		"FROM" => array(),
40
-		"WHERE" => array(),
41
-		"GROUPBY" => array(),
42
-		"ORDERBY" => array(),
43
-		"LIMIT" => "",
44
-		"HAVING" => array()
45
-	);
46
-
47
-	$table = sinon($options['table'], 'article');
48
-	if ($options['champs']) {
49
-		$champs = $options['champs'];
50
-	} else {
51
-		$l = liste_des_champs();
52
-		$champs = $l['article'];
53
-	}
54
-	$serveur = $options['serveur'];
55
-
56
-	list($methode, $q, $preg) = expression_recherche($recherche, $options);
57
-
58
-	$jointures = $options['jointures']
59
-		? liste_des_jointures()
60
-		: array();
61
-
62
-	$_id_table = id_table_objet($table);
63
-
64
-	// c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
65
-	// (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
66
-	if (strpos($_id_table, ",") !== false) {
67
-		$_id_table = explode(',', $_id_table);
68
-		$_id_table = reset($_id_table);
69
-	}
70
-
71
-	$requete['SELECT'][] = "t." . $_id_table;
72
-	$a = array();
73
-	// Recherche fulltext
74
-	foreach ($champs as $champ => $poids) {
75
-		if (is_array($champ)) {
76
-			spip_log("requetes imbriquees interdites");
77
-		} else {
78
-			if (strpos($champ, ".") === false) {
79
-				$champ = "t.$champ";
80
-			}
81
-			$requete['SELECT'][] = $champ;
82
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
83
-		}
84
-	}
85
-	if ($a) {
86
-		$requete['WHERE'][] = join(" OR ", $a);
87
-	}
88
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
89
-
90
-	$results = array();
91
-
92
-	$s = sql_select(
93
-		$requete['SELECT'], $requete['FROM'], $requete['WHERE'],
94
-		implode(" ", $requete['GROUPBY']),
95
-		$requete['ORDERBY'], $requete['LIMIT'],
96
-		$requete['HAVING'], $serveur
97
-	);
98
-
99
-	while ($t = sql_fetch($s, $serveur)
100
-		and (!isset($t['score']) or $t['score'] > 0)) {
101
-		$id = intval($t[$_id_table]);
102
-
103
-		if ($options['toutvoir']
104
-			or autoriser('voir', $table, $id)
105
-		) {
106
-			// indiquer les champs concernes
107
-			$champs_vus = array();
108
-			$score = 0;
109
-			$matches = array();
110
-
111
-			$vu = false;
112
-			foreach ($champs as $champ => $poids) {
113
-				$champ = explode('.', $champ);
114
-				$champ = end($champ);
115
-				// translitteration_rapide uniquement si on est deja en utf-8
116
-				$value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
117
-				if ($n =
118
-					($options['score'] || $options['matches'])
119
-						? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
120
-						: preg_match($preg, $value)
121
-				) {
122
-					$vu = true;
123
-
124
-					if ($options['champs']) {
125
-						$champs_vus[$champ] = $t[$champ];
126
-					}
127
-					if ($options['score']) {
128
-						// compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
129
-						$score += $poids * strlen(implode('',array_column($regs, 0)));
130
-					}
131
-
132
-					if ($options['matches']) {
133
-						$matches[$champ] = $regs;
134
-					}
135
-
136
-					if (!$options['champs']
137
-						and !$options['score']
138
-						and !$options['matches']
139
-					) {
140
-						break;
141
-					}
142
-				}
143
-			}
144
-
145
-			if ($vu) {
146
-				if (!isset($results)) {
147
-					$results = array();
148
-				}
149
-				$results[$id] = array();
150
-				if ($champs_vus) {
151
-					$results[$id]['champs'] = $champs_vus;
152
-				}
153
-				if ($score) {
154
-					$results[$id]['score'] = $score;
155
-				}
156
-				if ($matches) {
157
-					$results[$id]['matches'] = $matches;
158
-				}
159
-			}
160
-		}
161
-	}
162
-
163
-
164
-	// Gerer les donnees associees
165
-	// ici on est un peu naze : pas capables de reconstruire une jointure complexe
166
-	// on ne sait passer que par table de laison en 1 coup
167
-	if (isset($jointures[$table])
168
-		and $joints = recherche_en_base(
169
-			$recherche,
170
-			$jointures[$table],
171
-			array_merge($options, array('jointures' => false))
172
-		)
173
-	) {
174
-		include_spip('action/editer_liens');
175
-		$trouver_table = charger_fonction('trouver_table', 'base');
176
-		$cle_depart = id_table_objet($table);
177
-		$table_depart = table_objet($table, $serveur);
178
-		$desc_depart = $trouver_table($table_depart, $serveur);
179
-		$depart_associable = objet_associable($table);
180
-		foreach ($joints as $table_liee => $ids_trouves) {
181
-			// on peut definir une fonction de recherche jointe pour regler les cas particuliers
182
-			if (
183
-			!(
184
-				$rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}", "inc", true)
185
-				or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}", "inc", true)
186
-				or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie", "inc", true)
187
-			)
188
-			) {
189
-				$cle_arrivee = id_table_objet($table_liee);
190
-				$table_arrivee = table_objet($table_liee, $serveur);
191
-				$desc_arrivee = $trouver_table($table_arrivee, $serveur);
192
-				// cas simple : $cle_depart dans la table_liee
193
-				if (isset($desc_arrivee['field'][$cle_depart])) {
194
-					$s = sql_select("$cle_depart, $cle_arrivee", $desc_arrivee['table_sql'],
195
-						sql_in($cle_arrivee, array_keys($ids_trouves)), '', '', '', '', $serveur);
196
-				} // cas simple : $cle_arrivee dans la table
197
-				elseif (isset($desc_depart['field'][$cle_arrivee])) {
198
-					$s = sql_select("$cle_depart, $cle_arrivee", $desc_depart['table_sql'],
199
-						sql_in($cle_arrivee, array_keys($ids_trouves)), '', '', '', '', $serveur);
200
-				}
201
-				// sinon cherchons une table de liaison
202
-				// cas recherche principale article, objet lie document : passer par spip_documents_liens
203
-				elseif ($l = objet_associable($table_liee)) {
204
-					list($primary, $table_liens) = $l;
205
-					$s = sql_select("id_objet as $cle_depart, $primary as $cle_arrivee", $table_liens,
206
-						array("objet='$table'", sql_in($primary, array_keys($ids_trouves))), '', '', '', '', $serveur);
207
-				} // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
208
-				elseif ($l = $depart_associable) {
209
-					list($primary, $table_liens) = $l;
210
-					$s = sql_select("$primary as $cle_depart, id_objet as $cle_arrivee", $table_liens,
211
-						array("objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))), '', '', '', '', $serveur);
212
-				} // cas table de liaison generique spip_xxx_yyy
213
-				elseif ($t = $trouver_table($table_arrivee . "_" . $table_depart, $serveur)
214
-					or $t = $trouver_table($table_depart . "_" . $table_arrivee, $serveur)
215
-				) {
216
-					$s = sql_select("$cle_depart,$cle_arrivee", $t["table_sql"], sql_in($cle_arrivee, array_keys($ids_trouves)),
217
-						'', '', '', '', $serveur);
218
-				}
219
-			} else {
220
-				list($cle_depart, $cle_arrivee, $s) = $rechercher_joints($table, $table_liee, array_keys($ids_trouves),
221
-					$serveur);
222
-			}
223
-
224
-			while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
225
-				$id = $t[$cle_depart];
226
-				$joint = $ids_trouves[$t[$cle_arrivee]];
227
-				if (!isset($results)) {
228
-					$results = array();
229
-				}
230
-				if (!isset($results[$id])) {
231
-					$results[$id] = array();
232
-				}
233
-				if (isset($joint['score']) and $joint['score']) {
234
-					if (!isset($results[$id]['score'])) {
235
-						$results[$id]['score'] = 0;
236
-					}
237
-					$results[$id]['score'] += $joint['score'];
238
-				}
239
-				if (isset($joint['champs']) and $joint['champs']) {
240
-					foreach ($joint['champs'] as $c => $val) {
241
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
242
-					}
243
-				}
244
-				if (isset($joint['matches']) and $joint['matches']) {
245
-					foreach ($joint['matches'] as $c => $val) {
246
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
247
-					}
248
-				}
249
-			}
250
-		}
251
-	}
252
-
253
-	return $results;
22
+    // options par defaut
23
+    $options = array_merge(
24
+        array(
25
+            'score' => true,
26
+            'champs' => false,
27
+            'toutvoir' => false,
28
+            'matches' => false,
29
+            'jointures' => false
30
+        ),
31
+        $options
32
+    );
33
+
34
+    include_spip('inc/rechercher');
35
+    include_spip('inc/autoriser');
36
+
37
+    $requete = array(
38
+        "SELECT" => array(),
39
+        "FROM" => array(),
40
+        "WHERE" => array(),
41
+        "GROUPBY" => array(),
42
+        "ORDERBY" => array(),
43
+        "LIMIT" => "",
44
+        "HAVING" => array()
45
+    );
46
+
47
+    $table = sinon($options['table'], 'article');
48
+    if ($options['champs']) {
49
+        $champs = $options['champs'];
50
+    } else {
51
+        $l = liste_des_champs();
52
+        $champs = $l['article'];
53
+    }
54
+    $serveur = $options['serveur'];
55
+
56
+    list($methode, $q, $preg) = expression_recherche($recherche, $options);
57
+
58
+    $jointures = $options['jointures']
59
+        ? liste_des_jointures()
60
+        : array();
61
+
62
+    $_id_table = id_table_objet($table);
63
+
64
+    // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
65
+    // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
66
+    if (strpos($_id_table, ",") !== false) {
67
+        $_id_table = explode(',', $_id_table);
68
+        $_id_table = reset($_id_table);
69
+    }
70
+
71
+    $requete['SELECT'][] = "t." . $_id_table;
72
+    $a = array();
73
+    // Recherche fulltext
74
+    foreach ($champs as $champ => $poids) {
75
+        if (is_array($champ)) {
76
+            spip_log("requetes imbriquees interdites");
77
+        } else {
78
+            if (strpos($champ, ".") === false) {
79
+                $champ = "t.$champ";
80
+            }
81
+            $requete['SELECT'][] = $champ;
82
+            $a[] = $champ . ' ' . $methode . ' ' . $q;
83
+        }
84
+    }
85
+    if ($a) {
86
+        $requete['WHERE'][] = join(" OR ", $a);
87
+    }
88
+    $requete['FROM'][] = table_objet_sql($table) . ' AS t';
89
+
90
+    $results = array();
91
+
92
+    $s = sql_select(
93
+        $requete['SELECT'], $requete['FROM'], $requete['WHERE'],
94
+        implode(" ", $requete['GROUPBY']),
95
+        $requete['ORDERBY'], $requete['LIMIT'],
96
+        $requete['HAVING'], $serveur
97
+    );
98
+
99
+    while ($t = sql_fetch($s, $serveur)
100
+        and (!isset($t['score']) or $t['score'] > 0)) {
101
+        $id = intval($t[$_id_table]);
102
+
103
+        if ($options['toutvoir']
104
+            or autoriser('voir', $table, $id)
105
+        ) {
106
+            // indiquer les champs concernes
107
+            $champs_vus = array();
108
+            $score = 0;
109
+            $matches = array();
110
+
111
+            $vu = false;
112
+            foreach ($champs as $champ => $poids) {
113
+                $champ = explode('.', $champ);
114
+                $champ = end($champ);
115
+                // translitteration_rapide uniquement si on est deja en utf-8
116
+                $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
117
+                if ($n =
118
+                    ($options['score'] || $options['matches'])
119
+                        ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
120
+                        : preg_match($preg, $value)
121
+                ) {
122
+                    $vu = true;
123
+
124
+                    if ($options['champs']) {
125
+                        $champs_vus[$champ] = $t[$champ];
126
+                    }
127
+                    if ($options['score']) {
128
+                        // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
129
+                        $score += $poids * strlen(implode('',array_column($regs, 0)));
130
+                    }
131
+
132
+                    if ($options['matches']) {
133
+                        $matches[$champ] = $regs;
134
+                    }
135
+
136
+                    if (!$options['champs']
137
+                        and !$options['score']
138
+                        and !$options['matches']
139
+                    ) {
140
+                        break;
141
+                    }
142
+                }
143
+            }
144
+
145
+            if ($vu) {
146
+                if (!isset($results)) {
147
+                    $results = array();
148
+                }
149
+                $results[$id] = array();
150
+                if ($champs_vus) {
151
+                    $results[$id]['champs'] = $champs_vus;
152
+                }
153
+                if ($score) {
154
+                    $results[$id]['score'] = $score;
155
+                }
156
+                if ($matches) {
157
+                    $results[$id]['matches'] = $matches;
158
+                }
159
+            }
160
+        }
161
+    }
162
+
163
+
164
+    // Gerer les donnees associees
165
+    // ici on est un peu naze : pas capables de reconstruire une jointure complexe
166
+    // on ne sait passer que par table de laison en 1 coup
167
+    if (isset($jointures[$table])
168
+        and $joints = recherche_en_base(
169
+            $recherche,
170
+            $jointures[$table],
171
+            array_merge($options, array('jointures' => false))
172
+        )
173
+    ) {
174
+        include_spip('action/editer_liens');
175
+        $trouver_table = charger_fonction('trouver_table', 'base');
176
+        $cle_depart = id_table_objet($table);
177
+        $table_depart = table_objet($table, $serveur);
178
+        $desc_depart = $trouver_table($table_depart, $serveur);
179
+        $depart_associable = objet_associable($table);
180
+        foreach ($joints as $table_liee => $ids_trouves) {
181
+            // on peut definir une fonction de recherche jointe pour regler les cas particuliers
182
+            if (
183
+            !(
184
+                $rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}", "inc", true)
185
+                or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}", "inc", true)
186
+                or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie", "inc", true)
187
+            )
188
+            ) {
189
+                $cle_arrivee = id_table_objet($table_liee);
190
+                $table_arrivee = table_objet($table_liee, $serveur);
191
+                $desc_arrivee = $trouver_table($table_arrivee, $serveur);
192
+                // cas simple : $cle_depart dans la table_liee
193
+                if (isset($desc_arrivee['field'][$cle_depart])) {
194
+                    $s = sql_select("$cle_depart, $cle_arrivee", $desc_arrivee['table_sql'],
195
+                        sql_in($cle_arrivee, array_keys($ids_trouves)), '', '', '', '', $serveur);
196
+                } // cas simple : $cle_arrivee dans la table
197
+                elseif (isset($desc_depart['field'][$cle_arrivee])) {
198
+                    $s = sql_select("$cle_depart, $cle_arrivee", $desc_depart['table_sql'],
199
+                        sql_in($cle_arrivee, array_keys($ids_trouves)), '', '', '', '', $serveur);
200
+                }
201
+                // sinon cherchons une table de liaison
202
+                // cas recherche principale article, objet lie document : passer par spip_documents_liens
203
+                elseif ($l = objet_associable($table_liee)) {
204
+                    list($primary, $table_liens) = $l;
205
+                    $s = sql_select("id_objet as $cle_depart, $primary as $cle_arrivee", $table_liens,
206
+                        array("objet='$table'", sql_in($primary, array_keys($ids_trouves))), '', '', '', '', $serveur);
207
+                } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
208
+                elseif ($l = $depart_associable) {
209
+                    list($primary, $table_liens) = $l;
210
+                    $s = sql_select("$primary as $cle_depart, id_objet as $cle_arrivee", $table_liens,
211
+                        array("objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))), '', '', '', '', $serveur);
212
+                } // cas table de liaison generique spip_xxx_yyy
213
+                elseif ($t = $trouver_table($table_arrivee . "_" . $table_depart, $serveur)
214
+                    or $t = $trouver_table($table_depart . "_" . $table_arrivee, $serveur)
215
+                ) {
216
+                    $s = sql_select("$cle_depart,$cle_arrivee", $t["table_sql"], sql_in($cle_arrivee, array_keys($ids_trouves)),
217
+                        '', '', '', '', $serveur);
218
+                }
219
+            } else {
220
+                list($cle_depart, $cle_arrivee, $s) = $rechercher_joints($table, $table_liee, array_keys($ids_trouves),
221
+                    $serveur);
222
+            }
223
+
224
+            while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
225
+                $id = $t[$cle_depart];
226
+                $joint = $ids_trouves[$t[$cle_arrivee]];
227
+                if (!isset($results)) {
228
+                    $results = array();
229
+                }
230
+                if (!isset($results[$id])) {
231
+                    $results[$id] = array();
232
+                }
233
+                if (isset($joint['score']) and $joint['score']) {
234
+                    if (!isset($results[$id]['score'])) {
235
+                        $results[$id]['score'] = 0;
236
+                    }
237
+                    $results[$id]['score'] += $joint['score'];
238
+                }
239
+                if (isset($joint['champs']) and $joint['champs']) {
240
+                    foreach ($joint['champs'] as $c => $val) {
241
+                        $results[$id]['champs'][$table_liee . '.' . $c] = $val;
242
+                    }
243
+                }
244
+                if (isset($joint['matches']) and $joint['matches']) {
245
+                    foreach ($joint['matches'] as $c => $val) {
246
+                        $results[$id]['matches'][$table_liee . '.' . $c] = $val;
247
+                    }
248
+                }
249
+            }
250
+        }
251
+    }
252
+
253
+    return $results;
254 254
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$_id_table = reset($_id_table);
69 69
 	}
70 70
 
71
-	$requete['SELECT'][] = "t." . $_id_table;
71
+	$requete['SELECT'][] = "t.".$_id_table;
72 72
 	$a = array();
73 73
 	// Recherche fulltext
74 74
 	foreach ($champs as $champ => $poids) {
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 				$champ = "t.$champ";
80 80
 			}
81 81
 			$requete['SELECT'][] = $champ;
82
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
82
+			$a[] = $champ.' '.$methode.' '.$q;
83 83
 		}
84 84
 	}
85 85
 	if ($a) {
86 86
 		$requete['WHERE'][] = join(" OR ", $a);
87 87
 	}
88
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
88
+	$requete['FROM'][] = table_objet_sql($table).' AS t';
89 89
 
90 90
 	$results = array();
91 91
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 					}
127 127
 					if ($options['score']) {
128 128
 						// compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
129
-						$score += $poids * strlen(implode('',array_column($regs, 0)));
129
+						$score += $poids * strlen(implode('', array_column($regs, 0)));
130 130
 					}
131 131
 
132 132
 					if ($options['matches']) {
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 					$s = sql_select("$primary as $cle_depart, id_objet as $cle_arrivee", $table_liens,
211 211
 						array("objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))), '', '', '', '', $serveur);
212 212
 				} // cas table de liaison generique spip_xxx_yyy
213
-				elseif ($t = $trouver_table($table_arrivee . "_" . $table_depart, $serveur)
214
-					or $t = $trouver_table($table_depart . "_" . $table_arrivee, $serveur)
213
+				elseif ($t = $trouver_table($table_arrivee."_".$table_depart, $serveur)
214
+					or $t = $trouver_table($table_depart."_".$table_arrivee, $serveur)
215 215
 				) {
216 216
 					$s = sql_select("$cle_depart,$cle_arrivee", $t["table_sql"], sql_in($cle_arrivee, array_keys($ids_trouves)),
217 217
 						'', '', '', '', $serveur);
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 				}
239 239
 				if (isset($joint['champs']) and $joint['champs']) {
240 240
 					foreach ($joint['champs'] as $c => $val) {
241
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
241
+						$results[$id]['champs'][$table_liee.'.'.$c] = $val;
242 242
 					}
243 243
 				}
244 244
 				if (isset($joint['matches']) and $joint['matches']) {
245 245
 					foreach ($joint['matches'] as $c => $val) {
246
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
246
+						$results[$id]['matches'][$table_liee.'.'.$c] = $val;
247 247
 					}
248 248
 				}
249 249
 			}
Please login to merge, or discard this patch.
config/ecran_securite.php 2 patches
Indentation   +424 added lines, -424 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * Test utilisateur
16 16
  */
17 17
 if (isset($_GET['test_ecran_securite'])) {
18
-	$ecran_securite_raison = 'test ' . _ECRAN_SECURITE;
18
+    $ecran_securite_raison = 'test ' . _ECRAN_SECURITE;
19 19
 }
20 20
 
21 21
 if (file_exists($f = __DIR__ . DIRECTORY_SEPARATOR  . 'ecran_securite_options.php')) {
22
-	include ($f);
22
+    include ($f);
23 23
 }
24 24
 
25 25
 /*
@@ -29,222 +29,222 @@  discard block
 block discarded – undo
29 29
  * le load depasse ECRAN_SECURITE_LOAD)
30 30
  */
31 31
 if (!defined('_IS_BOT') and isset($_GET['var_isbot'])) {
32
-	define('_IS_BOT', $_GET['var_isbot'] ? true : false);
32
+    define('_IS_BOT', $_GET['var_isbot'] ? true : false);
33 33
 }
34 34
 
35 35
 /*
36 36
  * Détecteur de robot d'indexation
37 37
  */
38 38
 if (!defined('_IS_BOT')) {
39
-	define(
40
-		'_IS_BOT',
41
-		isset($_SERVER['HTTP_USER_AGENT'])
42
-			and preg_match(
43
-				','
44
-					. implode('|', array(
45
-						// mots generiques
46
-						'bot',
47
-						'slurp',
48
-						'crawler',
49
-						'crwlr',
50
-						'java',
51
-						'monitoring',
52
-						'spider',
53
-						'webvac',
54
-						'yandex',
55
-						'MSIE 6\.0', // botnet 99,9% du temps
56
-						// UA plus cibles
57
-						'200please',
58
-						'80legs',
59
-						'a6-indexer',
60
-						'aboundex',
61
-						'accoona',
62
-						'acrylicapps',
63
-						'addthis',
64
-						'adressendeutschland',
65
-						'alexa',
66
-						'altavista',
67
-						'analyticsseo',
68
-						'antennapod',
69
-						'arachnys',
70
-						'archive',
71
-						'argclrint',
72
-						'aspseek',
73
-						'baidu',
74
-						'begunadvertising',
75
-						'bing',
76
-						'bloglines',
77
-						'buck',
78
-						'browsershots',
79
-						'bubing',
80
-						'butterfly',
81
-						'changedetection',
82
-						'charlotte',
83
-						'chilkat',
84
-						'china',
85
-						'coccoc',
86
-						'crowsnest',
87
-						'dataminr',
88
-						'daumoa',
89
-						'dlvr\.it',
90
-						'dlweb',
91
-						'drupal',
92
-						'ec2linkfinder',
93
-						'eset\.com',
94
-						'estyle',
95
-						'exalead',
96
-						'ezooms',
97
-						'facebookexternalhit',
98
-						'facebookplatform',
99
-						'fairshare',
100
-						'feedfetcher',
101
-						'feedfetcher-google',
102
-						'feedly',
103
-						'fetch',
104
-						'flipboardproxy',
105
-						'genieo',
106
-						'google',
107
-						'go-http-client',
108
-						'grapeshot',
109
-						'hatena-useragent',
110
-						'head',
111
-						'hosttracker',
112
-						'hubspot',
113
-						'ia_archiver',
114
-						'ichiro',
115
-						'iltrovatore-setaccio',
116
-						'immediatenet',
117
-						'ina',
118
-						'inoreader',
119
-						'infegyatlas',
120
-						'infohelfer',
121
-						'instapaper',
122
-						'jabse',
123
-						'james',
124
-						'jersey',
125
-						'kumkie',
126
-						'linkdex',
127
-						'linkfluence',
128
-						'linkwalker',
129
-						'litefinder',
130
-						'loadimpactpageanalyzer',
131
-						'ltx71',
132
-						'luminate',
133
-						'lycos',
134
-						'lycosa',
135
-						'mediapartners-google',
136
-						'msai',
137
-						'myapp',
138
-						'nativehost',
139
-						'najdi',
140
-						'netcraftsurveyagent',
141
-						'netestate',
142
-						'netseer',
143
-						'netnewswire',
144
-						'newspaper',
145
-						'newsblur',
146
-						'nuhk',
147
-						'nuzzel',
148
-						'okhttp',
149
-						'otmedia',
150
-						'owlin',
151
-						'owncloud',
152
-						'panscient',
153
-						'paper\.li',
154
-						'parsijoo',
155
-						'protopage',
156
-						'plukkie',
157
-						'proximic',
158
-						'pubsub',
159
-						'python',
160
-						'qirina',
161
-						'qoshe',
162
-						'qualidator',
163
-						'qwantify',
164
-						'rambler',
165
-						'readability',
166
-						'ruby',
167
-						'sbsearch',
168
-						'scoop\.it',
169
-						'scooter',
170
-						'scoutjet',
171
-						'scrapy',
172
-						'scrubby',
173
-						'scrubbybloglines',
174
-						'shareaholic',
175
-						'shopwiki',
176
-						'simplepie',
177
-						'sistrix',
178
-						'sitechecker',
179
-						'siteexplorer',
180
-						'snapshot',
181
-						'sogou',
182
-						'special_archiver',
183
-						'speedy',
184
-						'spinn3r',
185
-						'spreadtrum',
186
-						'steeler',
187
-						'subscriber',
188
-						'suma',
189
-						'superdownloads',
190
-						'svenska-webbsido',
191
-						'teoma',
192
-						'the knowledge AI',
193
-						'thumbshots',
194
-						'tineye',
195
-						'traackr',
196
-						'trendiction',
197
-						'trendsmap',
198
-						'tweetedtimes',
199
-						'tweetmeme',
200
-						'universalfeedparser',
201
-						'uaslinkchecker',
202
-						'undrip',
203
-						'unwindfetchor',
204
-						'upday',
205
-						'vedma',
206
-						'vkshare',
207
-						'vm',
208
-						'wch',
209
-						'webalta',
210
-						'webcookies',
211
-						'webparser',
212
-						'webthumbnail',
213
-						'wesee',
214
-						'wise-guys',
215
-						'woko',
216
-						'wordpress',
217
-						'wotbox',
218
-						'y!j-bri',
219
-						'y!j-bro',
220
-						'y!j-brw',
221
-						'y!j-bsc',
222
-						'yahoo',
223
-						'yahoo!',
224
-						'yahooysmcm',
225
-						'ymobactus',
226
-						'yats',
227
-						'yeti',
228
-						'zeerch'
229
-					)) . ',i',
230
-				(string)$_SERVER['HTTP_USER_AGENT']
231
-			)
232
-	);
39
+    define(
40
+        '_IS_BOT',
41
+        isset($_SERVER['HTTP_USER_AGENT'])
42
+            and preg_match(
43
+                ','
44
+                    . implode('|', array(
45
+                        // mots generiques
46
+                        'bot',
47
+                        'slurp',
48
+                        'crawler',
49
+                        'crwlr',
50
+                        'java',
51
+                        'monitoring',
52
+                        'spider',
53
+                        'webvac',
54
+                        'yandex',
55
+                        'MSIE 6\.0', // botnet 99,9% du temps
56
+                        // UA plus cibles
57
+                        '200please',
58
+                        '80legs',
59
+                        'a6-indexer',
60
+                        'aboundex',
61
+                        'accoona',
62
+                        'acrylicapps',
63
+                        'addthis',
64
+                        'adressendeutschland',
65
+                        'alexa',
66
+                        'altavista',
67
+                        'analyticsseo',
68
+                        'antennapod',
69
+                        'arachnys',
70
+                        'archive',
71
+                        'argclrint',
72
+                        'aspseek',
73
+                        'baidu',
74
+                        'begunadvertising',
75
+                        'bing',
76
+                        'bloglines',
77
+                        'buck',
78
+                        'browsershots',
79
+                        'bubing',
80
+                        'butterfly',
81
+                        'changedetection',
82
+                        'charlotte',
83
+                        'chilkat',
84
+                        'china',
85
+                        'coccoc',
86
+                        'crowsnest',
87
+                        'dataminr',
88
+                        'daumoa',
89
+                        'dlvr\.it',
90
+                        'dlweb',
91
+                        'drupal',
92
+                        'ec2linkfinder',
93
+                        'eset\.com',
94
+                        'estyle',
95
+                        'exalead',
96
+                        'ezooms',
97
+                        'facebookexternalhit',
98
+                        'facebookplatform',
99
+                        'fairshare',
100
+                        'feedfetcher',
101
+                        'feedfetcher-google',
102
+                        'feedly',
103
+                        'fetch',
104
+                        'flipboardproxy',
105
+                        'genieo',
106
+                        'google',
107
+                        'go-http-client',
108
+                        'grapeshot',
109
+                        'hatena-useragent',
110
+                        'head',
111
+                        'hosttracker',
112
+                        'hubspot',
113
+                        'ia_archiver',
114
+                        'ichiro',
115
+                        'iltrovatore-setaccio',
116
+                        'immediatenet',
117
+                        'ina',
118
+                        'inoreader',
119
+                        'infegyatlas',
120
+                        'infohelfer',
121
+                        'instapaper',
122
+                        'jabse',
123
+                        'james',
124
+                        'jersey',
125
+                        'kumkie',
126
+                        'linkdex',
127
+                        'linkfluence',
128
+                        'linkwalker',
129
+                        'litefinder',
130
+                        'loadimpactpageanalyzer',
131
+                        'ltx71',
132
+                        'luminate',
133
+                        'lycos',
134
+                        'lycosa',
135
+                        'mediapartners-google',
136
+                        'msai',
137
+                        'myapp',
138
+                        'nativehost',
139
+                        'najdi',
140
+                        'netcraftsurveyagent',
141
+                        'netestate',
142
+                        'netseer',
143
+                        'netnewswire',
144
+                        'newspaper',
145
+                        'newsblur',
146
+                        'nuhk',
147
+                        'nuzzel',
148
+                        'okhttp',
149
+                        'otmedia',
150
+                        'owlin',
151
+                        'owncloud',
152
+                        'panscient',
153
+                        'paper\.li',
154
+                        'parsijoo',
155
+                        'protopage',
156
+                        'plukkie',
157
+                        'proximic',
158
+                        'pubsub',
159
+                        'python',
160
+                        'qirina',
161
+                        'qoshe',
162
+                        'qualidator',
163
+                        'qwantify',
164
+                        'rambler',
165
+                        'readability',
166
+                        'ruby',
167
+                        'sbsearch',
168
+                        'scoop\.it',
169
+                        'scooter',
170
+                        'scoutjet',
171
+                        'scrapy',
172
+                        'scrubby',
173
+                        'scrubbybloglines',
174
+                        'shareaholic',
175
+                        'shopwiki',
176
+                        'simplepie',
177
+                        'sistrix',
178
+                        'sitechecker',
179
+                        'siteexplorer',
180
+                        'snapshot',
181
+                        'sogou',
182
+                        'special_archiver',
183
+                        'speedy',
184
+                        'spinn3r',
185
+                        'spreadtrum',
186
+                        'steeler',
187
+                        'subscriber',
188
+                        'suma',
189
+                        'superdownloads',
190
+                        'svenska-webbsido',
191
+                        'teoma',
192
+                        'the knowledge AI',
193
+                        'thumbshots',
194
+                        'tineye',
195
+                        'traackr',
196
+                        'trendiction',
197
+                        'trendsmap',
198
+                        'tweetedtimes',
199
+                        'tweetmeme',
200
+                        'universalfeedparser',
201
+                        'uaslinkchecker',
202
+                        'undrip',
203
+                        'unwindfetchor',
204
+                        'upday',
205
+                        'vedma',
206
+                        'vkshare',
207
+                        'vm',
208
+                        'wch',
209
+                        'webalta',
210
+                        'webcookies',
211
+                        'webparser',
212
+                        'webthumbnail',
213
+                        'wesee',
214
+                        'wise-guys',
215
+                        'woko',
216
+                        'wordpress',
217
+                        'wotbox',
218
+                        'y!j-bri',
219
+                        'y!j-bro',
220
+                        'y!j-brw',
221
+                        'y!j-bsc',
222
+                        'yahoo',
223
+                        'yahoo!',
224
+                        'yahooysmcm',
225
+                        'ymobactus',
226
+                        'yats',
227
+                        'yeti',
228
+                        'zeerch'
229
+                    )) . ',i',
230
+                (string)$_SERVER['HTTP_USER_AGENT']
231
+            )
232
+    );
233 233
 }
234 234
 if (!defined('_IS_BOT_FRIEND')) {
235
-	define(
236
-		'_IS_BOT_FRIEND',
237
-		isset($_SERVER['HTTP_USER_AGENT'])
238
-			and preg_match(
239
-				',' . implode('|', array(
240
-					'facebookexternalhit',
241
-					'twitterbot',
242
-					'flipboardproxy',
243
-					'wordpress'
244
-				)) . ',i',
245
-				(string)$_SERVER['HTTP_USER_AGENT']
246
-			)
247
-	);
235
+    define(
236
+        '_IS_BOT_FRIEND',
237
+        isset($_SERVER['HTTP_USER_AGENT'])
238
+            and preg_match(
239
+                ',' . implode('|', array(
240
+                    'facebookexternalhit',
241
+                    'twitterbot',
242
+                    'flipboardproxy',
243
+                    'wordpress'
244
+                )) . ',i',
245
+                (string)$_SERVER['HTTP_USER_AGENT']
246
+            )
247
+    );
248 248
 }
249 249
 
250 250
 /*
@@ -256,28 +256,28 @@  discard block
 block discarded – undo
256 256
  */
257 257
 $_exceptions = array('id_table', 'id_base', 'id_parent', 'id_article_pdf');
258 258
 foreach ($_GET as $var => $val) {
259
-	if (
260
-		$_GET[$var] and strncmp($var, "id_", 3) == 0
261
-		and !in_array($var, $_exceptions)
262
-	) {
263
-		$_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]);
264
-	}
259
+    if (
260
+        $_GET[$var] and strncmp($var, "id_", 3) == 0
261
+        and !in_array($var, $_exceptions)
262
+    ) {
263
+        $_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]);
264
+    }
265 265
 }
266 266
 foreach ($_POST as $var => $val) {
267
-	if (
268
-		$_POST[$var] and strncmp($var, "id_", 3) == 0
269
-		and !in_array($var, $_exceptions)
270
-	) {
271
-		$_POST[$var] = is_array($_POST[$var]) ? @array_map('intval', $_POST[$var]) : intval($_POST[$var]);
272
-	}
267
+    if (
268
+        $_POST[$var] and strncmp($var, "id_", 3) == 0
269
+        and !in_array($var, $_exceptions)
270
+    ) {
271
+        $_POST[$var] = is_array($_POST[$var]) ? @array_map('intval', $_POST[$var]) : intval($_POST[$var]);
272
+    }
273 273
 }
274 274
 foreach ($GLOBALS as $var => $val) {
275
-	if (
276
-		$GLOBALS[$var] and strncmp($var, "id_", 3) == 0
277
-		and !in_array($var, $_exceptions)
278
-	) {
279
-		$GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]);
280
-	}
275
+    if (
276
+        $GLOBALS[$var] and strncmp($var, "id_", 3) == 0
277
+        and !in_array($var, $_exceptions)
278
+    ) {
279
+        $GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]);
280
+    }
281 281
 }
282 282
 
283 283
 /*
@@ -290,116 +290,116 @@  discard block
 block discarded – undo
290 290
  * Contrôle de quelques variables (XSS)
291 291
  */
292 292
 foreach (array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
293
-	if (isset($_GET[$var])) {
294
-		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
295
-	}
296
-	if (isset($_POST[$var])) {
297
-		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
298
-	}
293
+    if (isset($_GET[$var])) {
294
+        $_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
295
+    }
296
+    if (isset($_POST[$var])) {
297
+        $_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
298
+    }
299 299
 }
300 300
 
301 301
 /*
302 302
  * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
303 303
  */
304 304
 if (isset($_SERVER['REQUEST_URI'])) {
305
-	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
306
-		$file = addslashes((string)$_GET['file']);
307
-	}
305
+    if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
306
+        $file = addslashes((string)$_GET['file']);
307
+    }
308 308
 }
309 309
 
310 310
 /*
311 311
  * Pas d'inscription abusive
312 312
  */
313 313
 if (
314
-	isset($_REQUEST['mode']) and isset($_REQUEST['page'])
315
-	and !in_array($_REQUEST['mode'], array("6forum", "1comite"))
316
-	and $_REQUEST['page'] == "identifiants"
314
+    isset($_REQUEST['mode']) and isset($_REQUEST['page'])
315
+    and !in_array($_REQUEST['mode'], array("6forum", "1comite"))
316
+    and $_REQUEST['page'] == "identifiants"
317 317
 ) {
318
-	$ecran_securite_raison = "identifiants";
318
+    $ecran_securite_raison = "identifiants";
319 319
 }
320 320
 
321 321
 /*
322 322
  * Agenda joue à l'injection php
323 323
  */
324 324
 if (
325
-	isset($_REQUEST['partie_cal'])
326
-	and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])
325
+    isset($_REQUEST['partie_cal'])
326
+    and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])
327 327
 ) {
328
-	$ecran_securite_raison = "partie_cal";
328
+    $ecran_securite_raison = "partie_cal";
329 329
 }
330 330
 if (
331
-	isset($_REQUEST['echelle'])
332
-	and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])
331
+    isset($_REQUEST['echelle'])
332
+    and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])
333 333
 ) {
334
-	$ecran_securite_raison = "echelle";
334
+    $ecran_securite_raison = "echelle";
335 335
 }
336 336
 
337 337
 /*
338 338
  * Espace privé
339 339
  */
340 340
 if (
341
-	isset($_REQUEST['exec'])
342
-	and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])
341
+    isset($_REQUEST['exec'])
342
+    and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])
343 343
 ) {
344
-	$ecran_securite_raison = "exec";
344
+    $ecran_securite_raison = "exec";
345 345
 }
346 346
 if (
347
-	isset($_REQUEST['cherche_auteur'])
348
-	and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])
347
+    isset($_REQUEST['cherche_auteur'])
348
+    and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])
349 349
 ) {
350
-	$ecran_securite_raison = "cherche_auteur";
350
+    $ecran_securite_raison = "cherche_auteur";
351 351
 }
352 352
 if (
353
-	isset($_REQUEST['exec'])
354
-	and $_REQUEST['exec'] == 'auteurs'
355
-	and isset($_REQUEST['recherche'])
356
-	and preg_match(',[<],', (string)$_REQUEST['recherche'])
353
+    isset($_REQUEST['exec'])
354
+    and $_REQUEST['exec'] == 'auteurs'
355
+    and isset($_REQUEST['recherche'])
356
+    and preg_match(',[<],', (string)$_REQUEST['recherche'])
357 357
 ) {
358
-	$ecran_securite_raison = "recherche";
358
+    $ecran_securite_raison = "recherche";
359 359
 }
360 360
 if (
361
-	isset($_REQUEST['exec'])
362
-	and $_REQUEST['exec'] == 'info_plugin'
363
-	and isset($_REQUEST['plugin'])
364
-	and preg_match(',[<],', (string)$_REQUEST['plugin'])
361
+    isset($_REQUEST['exec'])
362
+    and $_REQUEST['exec'] == 'info_plugin'
363
+    and isset($_REQUEST['plugin'])
364
+    and preg_match(',[<],', (string)$_REQUEST['plugin'])
365 365
 ) {
366
-	$ecran_securite_raison = "plugin";
366
+    $ecran_securite_raison = "plugin";
367 367
 }
368 368
 if (
369
-	isset($_REQUEST['exec'])
370
-	and $_REQUEST['exec'] == 'puce_statut'
371
-	and isset($_REQUEST['id'])
372
-	and !intval($_REQUEST['id'])
369
+    isset($_REQUEST['exec'])
370
+    and $_REQUEST['exec'] == 'puce_statut'
371
+    and isset($_REQUEST['id'])
372
+    and !intval($_REQUEST['id'])
373 373
 ) {
374
-	$ecran_securite_raison = "puce_statut";
374
+    $ecran_securite_raison = "puce_statut";
375 375
 }
376 376
 if (
377
-	isset($_REQUEST['action'])
378
-	and $_REQUEST['action'] == 'configurer'
377
+    isset($_REQUEST['action'])
378
+    and $_REQUEST['action'] == 'configurer'
379 379
 ) {
380
-	if (
381
-		@file_exists('inc_version.php')
382
-		or @file_exists('ecrire/inc_version.php')
383
-	) {
384
-		function action_configurer() {
385
-			include_spip('inc/autoriser');
386
-			if (!autoriser('configurer', _request('configuration'))) {
387
-				include_spip('inc/minipres');
388
-				echo minipres(_T('info_acces_interdit'));
389
-				exit;
390
-			}
391
-			require _DIR_RESTREINT . 'action/configurer.php';
392
-			action_configurer_dist();
393
-		}
394
-	}
380
+    if (
381
+        @file_exists('inc_version.php')
382
+        or @file_exists('ecrire/inc_version.php')
383
+    ) {
384
+        function action_configurer() {
385
+            include_spip('inc/autoriser');
386
+            if (!autoriser('configurer', _request('configuration'))) {
387
+                include_spip('inc/minipres');
388
+                echo minipres(_T('info_acces_interdit'));
389
+                exit;
390
+            }
391
+            require _DIR_RESTREINT . 'action/configurer.php';
392
+            action_configurer_dist();
393
+        }
394
+    }
395 395
 }
396 396
 if (
397
-	isset($_REQUEST['action'])
398
-	and $_REQUEST['action'] == 'ordonner_liens_documents'
399
-	and isset($_REQUEST['ordre'])
400
-	and is_string($_REQUEST['ordre'])
397
+    isset($_REQUEST['action'])
398
+    and $_REQUEST['action'] == 'ordonner_liens_documents'
399
+    and isset($_REQUEST['ordre'])
400
+    and is_string($_REQUEST['ordre'])
401 401
 ) {
402
-	$ecran_securite_raison = "ordre a la chaine";
402
+    $ecran_securite_raison = "ordre a la chaine";
403 403
 }
404 404
 
405 405
 
@@ -407,29 +407,29 @@  discard block
 block discarded – undo
407 407
  * Bloque les requêtes contenant %00 (manipulation d'include)
408 408
  */
409 409
 if (strpos(
410
-	(function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc())
411
-		? stripslashes(serialize($_REQUEST))
412
-		: serialize($_REQUEST),
413
-	chr(0)
410
+    (function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc())
411
+        ? stripslashes(serialize($_REQUEST))
412
+        : serialize($_REQUEST),
413
+    chr(0)
414 414
 ) !== false) {
415
-	$ecran_securite_raison = "%00";
415
+    $ecran_securite_raison = "%00";
416 416
 }
417 417
 
418 418
 /*
419 419
  * Bloque les requêtes fond=formulaire_
420 420
  */
421 421
 if (
422
-	isset($_REQUEST['fond'])
423
-	and preg_match(',^formulaire_,i', $_REQUEST['fond'])
422
+    isset($_REQUEST['fond'])
423
+    and preg_match(',^formulaire_,i', $_REQUEST['fond'])
424 424
 ) {
425
-	$ecran_securite_raison = "fond=formulaire_";
425
+    $ecran_securite_raison = "fond=formulaire_";
426 426
 }
427 427
 
428 428
 /*
429 429
  * Bloque les requêtes du type ?GLOBALS[type_urls]=toto (bug vieux php)
430 430
  */
431 431
 if (isset($_REQUEST['GLOBALS'])) {
432
-	$ecran_securite_raison = "GLOBALS[GLOBALS]";
432
+    $ecran_securite_raison = "GLOBALS[GLOBALS]";
433 433
 }
434 434
 
435 435
 /*
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
  * les paginations entremélées
439 439
  */
440 440
 if (_IS_BOT) {
441
-	if (
442
-		(isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
443
-		or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
444
-		or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_'))
445
-		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
446
-	) {
447
-		$ecran_securite_raison = "robot agenda/double pagination";
448
-	}
441
+    if (
442
+        (isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
443
+        or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
444
+        or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_'))
445
+        or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
446
+    ) {
447
+        $ecran_securite_raison = "robot agenda/double pagination";
448
+    }
449 449
 }
450 450
 
451 451
 /*
@@ -453,82 +453,82 @@  discard block
 block discarded – undo
453 453
  * Bloque un XSS sur une page inexistante
454 454
  */
455 455
 if (isset($_REQUEST['page'])) {
456
-	if ($_REQUEST['page'] == 'test_cfg') {
457
-		$ecran_securite_raison = "test_cfg";
458
-	}
459
-	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) {
460
-		$ecran_securite_raison = "xsspage";
461
-	}
462
-	if (
463
-		$_REQUEST['page'] == '404'
464
-		and isset($_REQUEST['erreur'])
465
-	) {
466
-		$ecran_securite_raison = "xss404";
467
-	}
456
+    if ($_REQUEST['page'] == 'test_cfg') {
457
+        $ecran_securite_raison = "test_cfg";
458
+    }
459
+    if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) {
460
+        $ecran_securite_raison = "xsspage";
461
+    }
462
+    if (
463
+        $_REQUEST['page'] == '404'
464
+        and isset($_REQUEST['erreur'])
465
+    ) {
466
+        $ecran_securite_raison = "xss404";
467
+    }
468 468
 }
469 469
 
470 470
 /*
471 471
  * XSS par array
472 472
  */
473 473
 foreach (array('var_login') as $var) {
474
-	if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) {
475
-		$ecran_securite_raison = "xss " . $var;
476
-	}
474
+    if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) {
475
+        $ecran_securite_raison = "xss " . $var;
476
+    }
477 477
 }
478 478
 
479 479
 /*
480 480
  * Parade antivirale contre un cheval de troie
481 481
  */
482 482
 if (!function_exists('tmp_lkojfghx')) {
483
-	function tmp_lkojfghx() {}
484
-	function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) {
485
-		// si jamais on est arrivé ici sur une erreur php
486
-		// et qu'un autre gestionnaire d'erreur est défini, l'appeller
487
-		if ($b && $GLOBALS['tmp_xhgfjokl']) {
488
-			call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
489
-		}
490
-	}
483
+    function tmp_lkojfghx() {}
484
+    function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) {
485
+        // si jamais on est arrivé ici sur une erreur php
486
+        // et qu'un autre gestionnaire d'erreur est défini, l'appeller
487
+        if ($b && $GLOBALS['tmp_xhgfjokl']) {
488
+            call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
489
+        }
490
+    }
491 491
 }
492 492
 if (isset($_POST['tmp_lkojfghx3'])) {
493
-	$ecran_securite_raison = "gumblar";
493
+    $ecran_securite_raison = "gumblar";
494 494
 }
495 495
 
496 496
 /*
497 497
  * Outils XML mal sécurisés < 2.0.9
498 498
  */
499 499
 if (isset($_REQUEST['transformer_xml'])) {
500
-	$ecran_securite_raison = "transformer_xml";
500
+    $ecran_securite_raison = "transformer_xml";
501 501
 }
502 502
 
503 503
 /*
504 504
  * Outils XML mal sécurisés again
505 505
  */
506 506
 if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec'] == 'valider_xml') {
507
-	$url = trim($_REQUEST['var_url']);
508
-	if (
509
-		strncmp($url, '/', 1) == 0
510
-		or (($p = strpos($url, '..')) !== false and strpos($url, '..', $p + 3) !== false)
511
-		or (($p = strpos($url, '..')) !== false and strpos($url, 'IMG', $p + 3) !== false)
512
-		or (strpos($url, '://') !== false or strpos($url, ':\\') !== false)
513
-	) {
514
-		$ecran_securite_raison = 'URL interdite pour var_url';
515
-	}
507
+    $url = trim($_REQUEST['var_url']);
508
+    if (
509
+        strncmp($url, '/', 1) == 0
510
+        or (($p = strpos($url, '..')) !== false and strpos($url, '..', $p + 3) !== false)
511
+        or (($p = strpos($url, '..')) !== false and strpos($url, 'IMG', $p + 3) !== false)
512
+        or (strpos($url, '://') !== false or strpos($url, ':\\') !== false)
513
+    ) {
514
+        $ecran_securite_raison = 'URL interdite pour var_url';
515
+    }
516 516
 }
517 517
 
518 518
 /*
519 519
  * Sauvegarde mal securisée < 2.0.9
520 520
  */
521 521
 if (
522
-	isset($_REQUEST['nom_sauvegarde'])
523
-	and strstr((string)$_REQUEST['nom_sauvegarde'], '/')
522
+    isset($_REQUEST['nom_sauvegarde'])
523
+    and strstr((string)$_REQUEST['nom_sauvegarde'], '/')
524 524
 ) {
525
-	$ecran_securite_raison = 'nom_sauvegarde manipulee';
525
+    $ecran_securite_raison = 'nom_sauvegarde manipulee';
526 526
 }
527 527
 if (
528
-	isset($_REQUEST['znom_sauvegarde'])
529
-	and strstr((string)$_REQUEST['znom_sauvegarde'], '/')
528
+    isset($_REQUEST['znom_sauvegarde'])
529
+    and strstr((string)$_REQUEST['znom_sauvegarde'], '/')
530 530
 ) {
531
-	$ecran_securite_raison = 'znom_sauvegarde manipulee';
531
+    $ecran_securite_raison = 'znom_sauvegarde manipulee';
532 532
 }
533 533
 
534 534
 
@@ -537,57 +537,57 @@  discard block
 block discarded – undo
537 537
  * on vérifie 'page' pour ne pas bloquer ... drupal
538 538
  */
539 539
 if (
540
-	isset($_REQUEST['op']) and isset($_REQUEST['page'])
541
-	and $_REQUEST['op'] !== preg_replace('/[^\-\w]/', '', $_REQUEST['op'])
540
+    isset($_REQUEST['op']) and isset($_REQUEST['page'])
541
+    and $_REQUEST['op'] !== preg_replace('/[^\-\w]/', '', $_REQUEST['op'])
542 542
 ) {
543
-	$ecran_securite_raison = 'op';
543
+    $ecran_securite_raison = 'op';
544 544
 }
545 545
 
546 546
 /*
547 547
  * Forms & Table ne se méfiait pas assez des uploads de fichiers
548 548
  */
549 549
 if (count($_FILES)) {
550
-	foreach ($_FILES as $k => $v) {
551
-		if (
552
-			preg_match(',^fichier_\d+$,', $k)
553
-			and preg_match(',\.php,i', $v['name'])
554
-		) {
555
-			unset($_FILES[$k]);
556
-		}
557
-	}
550
+    foreach ($_FILES as $k => $v) {
551
+        if (
552
+            preg_match(',^fichier_\d+$,', $k)
553
+            and preg_match(',\.php,i', $v['name'])
554
+        ) {
555
+            unset($_FILES[$k]);
556
+        }
557
+    }
558 558
 }
559 559
 /*
560 560
  * et Contact trop laxiste avec une variable externe
561 561
  * on bloque pas le post pour eviter de perdre des donnees mais on unset la variable et c'est tout
562 562
  */
563 563
 if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']) {
564
-	unset($_REQUEST['pj_enregistrees_nom']);
565
-	unset($_GET['pj_enregistrees_nom']);
566
-	unset($_POST['pj_enregistrees_nom']);
564
+    unset($_REQUEST['pj_enregistrees_nom']);
565
+    unset($_GET['pj_enregistrees_nom']);
566
+    unset($_POST['pj_enregistrees_nom']);
567 567
 }
568 568
 
569 569
 /*
570 570
  * reinstall=oui un peu trop permissif
571 571
  */
572 572
 if (
573
-	isset($_REQUEST['reinstall'])
574
-	and $_REQUEST['reinstall'] == 'oui'
573
+    isset($_REQUEST['reinstall'])
574
+    and $_REQUEST['reinstall'] == 'oui'
575 575
 ) {
576
-	$ecran_securite_raison = 'reinstall=oui';
576
+    $ecran_securite_raison = 'reinstall=oui';
577 577
 }
578 578
 
579 579
 /*
580 580
  * Pas d'action pendant l'install
581 581
  */
582 582
 if (isset($_REQUEST['exec']) and $_REQUEST['exec'] === 'install' and isset($_REQUEST['action'])) {
583
-	$ecran_securite_raison = 'install&action impossibles';
583
+    $ecran_securite_raison = 'install&action impossibles';
584 584
 }
585 585
 
586 586
 /*
587 587
  * Échappement xss referer
588 588
  */
589 589
 if (isset($_SERVER['HTTP_REFERER'])) {
590
-	$_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
590
+    $_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
591 591
 }
592 592
 
593 593
 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
  * Echappement HTTP_X_FORWARDED_HOST
596 596
  */
597 597
 if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
598
-	$_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
598
+    $_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
599 599
 }
600 600
 
601 601
 
@@ -603,9 +603,9 @@  discard block
 block discarded – undo
603 603
  * Pas d'erreur dans l'erreur
604 604
  */
605 605
 if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['page'] === 'login') {
606
-	if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) {
607
-		$ecran_securite_raison = 'var_erreur incorrecte';
608
-	}
606
+    if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) {
607
+        $ecran_securite_raison = 'var_erreur incorrecte';
608
+    }
609 609
 }
610 610
 
611 611
 
@@ -613,53 +613,53 @@  discard block
 block discarded – undo
613 613
  * Réinjection des clés en html dans l'admin r19561
614 614
  */
615 615
 if (
616
-	(isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false)
617
-	or isset($_REQUEST['var_memotri'])
616
+    (isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false)
617
+    or isset($_REQUEST['var_memotri'])
618 618
 ) {
619
-	$zzzz = implode("", array_keys($_REQUEST));
620
-	if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) {
621
-		$ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
622
-	}
619
+    $zzzz = implode("", array_keys($_REQUEST));
620
+    if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) {
621
+        $ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
622
+    }
623 623
 }
624 624
 
625 625
 /*
626 626
  * Injection par connect
627 627
  */
628 628
 if (
629
-	isset($_REQUEST['connect'])
630
-	// cas qui permettent de sortir d'un commentaire PHP
631
-	and (
632
-		strpos($_REQUEST['connect'], "?") !== false
633
-		or strpos($_REQUEST['connect'], "<") !== false
634
-		or strpos($_REQUEST['connect'], ">") !== false
635
-		or strpos($_REQUEST['connect'], "\n") !== false
636
-		or strpos($_REQUEST['connect'], "\r") !== false
637
-	)
629
+    isset($_REQUEST['connect'])
630
+    // cas qui permettent de sortir d'un commentaire PHP
631
+    and (
632
+        strpos($_REQUEST['connect'], "?") !== false
633
+        or strpos($_REQUEST['connect'], "<") !== false
634
+        or strpos($_REQUEST['connect'], ">") !== false
635
+        or strpos($_REQUEST['connect'], "\n") !== false
636
+        or strpos($_REQUEST['connect'], "\r") !== false
637
+    )
638 638
 ) {
639
-	$ecran_securite_raison = "malformed connect argument";
639
+    $ecran_securite_raison = "malformed connect argument";
640 640
 }
641 641
 
642 642
 /*
643 643
  * S'il y a une raison de mourir, mourons
644 644
  */
645 645
 if (isset($ecran_securite_raison)) {
646
-	header("HTTP/1.0 403 Forbidden");
647
-	header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
648
-	header("Cache-Control: no-cache, must-revalidate");
649
-	header("Pragma: no-cache");
650
-	header("Content-Type: text/html");
651
-	header("Connection: close");
652
-	die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>");
646
+    header("HTTP/1.0 403 Forbidden");
647
+    header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
648
+    header("Cache-Control: no-cache, must-revalidate");
649
+    header("Pragma: no-cache");
650
+    header("Content-Type: text/html");
651
+    header("Connection: close");
652
+    die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>");
653 653
 }
654 654
 
655 655
 /*
656 656
  * Un filtre filtrer_entites securise
657 657
  */
658 658
 if (!function_exists('filtre_filtrer_entites_dist')) {
659
-	function filtre_filtrer_entites_dist($t) {
660
-		include_spip('inc/texte');
661
-		return interdire_scripts(filtrer_entites($t));
662
-	}
659
+    function filtre_filtrer_entites_dist($t) {
660
+        include_spip('inc/texte');
661
+        return interdire_scripts(filtrer_entites($t));
662
+    }
663 663
 }
664 664
 
665 665
 
@@ -673,35 +673,35 @@  discard block
 block discarded – undo
673 673
  * Bloque les bots quand le load déborde
674 674
  */
675 675
 if (!defined('_ECRAN_SECURITE_LOAD')) {
676
-	define('_ECRAN_SECURITE_LOAD', 4);
676
+    define('_ECRAN_SECURITE_LOAD', 4);
677 677
 }
678 678
 
679 679
 if (
680
-	defined('_ECRAN_SECURITE_LOAD')
681
-	and _ECRAN_SECURITE_LOAD > 0
682
-	and _IS_BOT
683
-	and !_IS_BOT_FRIEND
684
-	and $_SERVER['REQUEST_METHOD'] === 'GET'
685
-	and (
686
-		(function_exists('sys_getloadavg')
687
-			and $load = sys_getloadavg()
688
-			and is_array($load)
689
-			and $load = array_shift($load))
690
-		or
691
-		(@is_readable('/proc/loadavg')
692
-			and $load = file_get_contents('/proc/loadavg')
693
-			and $load = floatval($load))
694
-	)
695
-	and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite
696
-	and rand(0, $load * $load) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD
680
+    defined('_ECRAN_SECURITE_LOAD')
681
+    and _ECRAN_SECURITE_LOAD > 0
682
+    and _IS_BOT
683
+    and !_IS_BOT_FRIEND
684
+    and $_SERVER['REQUEST_METHOD'] === 'GET'
685
+    and (
686
+        (function_exists('sys_getloadavg')
687
+            and $load = sys_getloadavg()
688
+            and is_array($load)
689
+            and $load = array_shift($load))
690
+        or
691
+        (@is_readable('/proc/loadavg')
692
+            and $load = file_get_contents('/proc/loadavg')
693
+            and $load = floatval($load))
694
+    )
695
+    and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite
696
+    and rand(0, $load * $load) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD
697 697
 ) {
698
-	//https://webmasters.stackexchange.com/questions/65674/should-i-return-a-429-or-503-status-code-to-a-bot
699
-	header("HTTP/1.0 429 Too Many Requests");
700
-	header("Retry-After: 300");
701
-	header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
702
-	header("Cache-Control: no-cache, must-revalidate");
703
-	header("Pragma: no-cache");
704
-	header("Content-Type: text/html");
705
-	header("Connection: close");
706
-	die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>");
698
+    //https://webmasters.stackexchange.com/questions/65674/should-i-return-a-429-or-503-status-code-to-a-bot
699
+    header("HTTP/1.0 429 Too Many Requests");
700
+    header("Retry-After: 300");
701
+    header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
702
+    header("Cache-Control: no-cache, must-revalidate");
703
+    header("Pragma: no-cache");
704
+    header("Content-Type: text/html");
705
+    header("Connection: close");
706
+    die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>");
707 707
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
  * Test utilisateur
16 16
  */
17 17
 if (isset($_GET['test_ecran_securite'])) {
18
-	$ecran_securite_raison = 'test ' . _ECRAN_SECURITE;
18
+	$ecran_securite_raison = 'test '._ECRAN_SECURITE;
19 19
 }
20 20
 
21
-if (file_exists($f = __DIR__ . DIRECTORY_SEPARATOR  . 'ecran_securite_options.php')) {
21
+if (file_exists($f = __DIR__.DIRECTORY_SEPARATOR.'ecran_securite_options.php')) {
22 22
 	include ($f);
23 23
 }
24 24
 
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 						'yats',
227 227
 						'yeti',
228 228
 						'zeerch'
229
-					)) . ',i',
230
-				(string)$_SERVER['HTTP_USER_AGENT']
229
+					)).',i',
230
+				(string) $_SERVER['HTTP_USER_AGENT']
231 231
 			)
232 232
 	);
233 233
 }
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 		'_IS_BOT_FRIEND',
237 237
 		isset($_SERVER['HTTP_USER_AGENT'])
238 238
 			and preg_match(
239
-				',' . implode('|', array(
239
+				','.implode('|', array(
240 240
 					'facebookexternalhit',
241 241
 					'twitterbot',
242 242
 					'flipboardproxy',
243 243
 					'wordpress'
244
-				)) . ',i',
245
-				(string)$_SERVER['HTTP_USER_AGENT']
244
+				)).',i',
245
+				(string) $_SERVER['HTTP_USER_AGENT']
246 246
 			)
247 247
 	);
248 248
 }
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
  */
292 292
 foreach (array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
293 293
 	if (isset($_GET[$var])) {
294
-		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
294
+		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string) $_GET[$var]);
295 295
 	}
296 296
 	if (isset($_POST[$var])) {
297
-		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
297
+		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string) $_POST[$var]);
298 298
 	}
299 299
 }
300 300
 
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
  * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
303 303
  */
304 304
 if (isset($_SERVER['REQUEST_URI'])) {
305
-	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
306
-		$file = addslashes((string)$_GET['file']);
305
+	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string) $_SERVER['REQUEST_URI'])) {
306
+		$file = addslashes((string) $_GET['file']);
307 307
 	}
308 308
 }
309 309
 
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
  */
324 324
 if (
325 325
 	isset($_REQUEST['partie_cal'])
326
-	and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])
326
+	and $_REQUEST['partie_cal'] !== htmlentities((string) $_REQUEST['partie_cal'])
327 327
 ) {
328 328
 	$ecran_securite_raison = "partie_cal";
329 329
 }
330 330
 if (
331 331
 	isset($_REQUEST['echelle'])
332
-	and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])
332
+	and $_REQUEST['echelle'] !== htmlentities((string) $_REQUEST['echelle'])
333 333
 ) {
334 334
 	$ecran_securite_raison = "echelle";
335 335
 }
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
  */
340 340
 if (
341 341
 	isset($_REQUEST['exec'])
342
-	and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])
342
+	and !preg_match(',^[\w-]+$,', (string) $_REQUEST['exec'])
343 343
 ) {
344 344
 	$ecran_securite_raison = "exec";
345 345
 }
346 346
 if (
347 347
 	isset($_REQUEST['cherche_auteur'])
348
-	and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])
348
+	and preg_match(',[<],', (string) $_REQUEST['cherche_auteur'])
349 349
 ) {
350 350
 	$ecran_securite_raison = "cherche_auteur";
351 351
 }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 	isset($_REQUEST['exec'])
354 354
 	and $_REQUEST['exec'] == 'auteurs'
355 355
 	and isset($_REQUEST['recherche'])
356
-	and preg_match(',[<],', (string)$_REQUEST['recherche'])
356
+	and preg_match(',[<],', (string) $_REQUEST['recherche'])
357 357
 ) {
358 358
 	$ecran_securite_raison = "recherche";
359 359
 }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	isset($_REQUEST['exec'])
362 362
 	and $_REQUEST['exec'] == 'info_plugin'
363 363
 	and isset($_REQUEST['plugin'])
364
-	and preg_match(',[<],', (string)$_REQUEST['plugin'])
364
+	and preg_match(',[<],', (string) $_REQUEST['plugin'])
365 365
 ) {
366 366
 	$ecran_securite_raison = "plugin";
367 367
 }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 				echo minipres(_T('info_acces_interdit'));
389 389
 				exit;
390 390
 			}
391
-			require _DIR_RESTREINT . 'action/configurer.php';
391
+			require _DIR_RESTREINT.'action/configurer.php';
392 392
 			action_configurer_dist();
393 393
 		}
394 394
 	}
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 if (_IS_BOT) {
441 441
 	if (
442 442
 		(isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
443
-		or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
444
-		or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_'))
445
-		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
443
+		or (strpos((string) $_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string) $_SERVER['REQUEST_URI']))
444
+		or (isset($_REQUEST['calendrier_annee']) and strpos((string) $_SERVER['REQUEST_URI'], 'debut_'))
445
+		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string) $_SERVER['REQUEST_URI']))
446 446
 	) {
447 447
 		$ecran_securite_raison = "robot agenda/double pagination";
448 448
 	}
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	if ($_REQUEST['page'] == 'test_cfg') {
457 457
 		$ecran_securite_raison = "test_cfg";
458 458
 	}
459
-	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) {
459
+	if ($_REQUEST['page'] !== htmlspecialchars((string) $_REQUEST['page'])) {
460 460
 		$ecran_securite_raison = "xsspage";
461 461
 	}
462 462
 	if (
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
  */
473 473
 foreach (array('var_login') as $var) {
474 474
 	if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) {
475
-		$ecran_securite_raison = "xss " . $var;
475
+		$ecran_securite_raison = "xss ".$var;
476 476
 	}
477 477
 }
478 478
 
@@ -520,13 +520,13 @@  discard block
 block discarded – undo
520 520
  */
521 521
 if (
522 522
 	isset($_REQUEST['nom_sauvegarde'])
523
-	and strstr((string)$_REQUEST['nom_sauvegarde'], '/')
523
+	and strstr((string) $_REQUEST['nom_sauvegarde'], '/')
524 524
 ) {
525 525
 	$ecran_securite_raison = 'nom_sauvegarde manipulee';
526 526
 }
527 527
 if (
528 528
 	isset($_REQUEST['znom_sauvegarde'])
529
-	and strstr((string)$_REQUEST['znom_sauvegarde'], '/')
529
+	and strstr((string) $_REQUEST['znom_sauvegarde'], '/')
530 530
 ) {
531 531
 	$ecran_securite_raison = 'znom_sauvegarde manipulee';
532 532
 }
Please login to merge, or discard this patch.
ecrire/inc/minipres.php 3 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Minipres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/headers');
@@ -46,61 +46,61 @@  discard block
 block discarded – undo
46 46
  */
47 47
 function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) {
48 48
 
49
-	utiliser_langue_visiteur();
50
-
51
-	http_no_cache();
52
-
53
-	if ($titre == 'AUTO') {
54
-		$titre = _T('info_installation_systeme_publication');
55
-	}
56
-
57
-	# le charset est en utf-8, pour recuperer le nom comme il faut
58
-	# lors de l'installation
59
-	if (!headers_sent()) {
60
-		header('Content-Type: text/html; charset=utf-8');
61
-	}
62
-
63
-	$css = "";
64
-	$files = array('reset.css', 'clear.css', 'minipres.css');
65
-	if ($all_inline) {
66
-		// inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande)
67
-		foreach ($files as $name) {
68
-			$file = direction_css(find_in_theme($name));
69
-			if (function_exists("compacte")) {
70
-				$file = compacte($file);
71
-			} else {
72
-				$file = url_absolue_css($file); // precaution
73
-			}
74
-			lire_fichier($file, $c);
75
-			$css .= $c;
76
-		}
77
-		$css = "<style type='text/css'>" . $css . "</style>";
78
-	} else {
79
-		foreach ($files as $name) {
80
-			$file = direction_css(find_in_theme($name));
81
-			$css .= "<link rel='stylesheet' href='$file' type='text/css' />\n";
82
-		}
83
-	}
84
-
85
-	// au cas ou minipres() est appele avant spip_initialisation_suite()
86
-	if (!defined('_DOCTYPE_ECRIRE')) {
87
-		define('_DOCTYPE_ECRIRE', '');
88
-	}
89
-
90
-	return _DOCTYPE_ECRIRE .
91
-	html_lang_attributes() .
92
-	"<head>\n" .
93
-	"<title>" .
94
-	textebrut($titre) .
95
-	"</title>\n" .
96
-	"<meta name='viewport' content='width=device-width' />\n" .
97
-	$css .
98
-	"</head>
49
+    utiliser_langue_visiteur();
50
+
51
+    http_no_cache();
52
+
53
+    if ($titre == 'AUTO') {
54
+        $titre = _T('info_installation_systeme_publication');
55
+    }
56
+
57
+    # le charset est en utf-8, pour recuperer le nom comme il faut
58
+    # lors de l'installation
59
+    if (!headers_sent()) {
60
+        header('Content-Type: text/html; charset=utf-8');
61
+    }
62
+
63
+    $css = "";
64
+    $files = array('reset.css', 'clear.css', 'minipres.css');
65
+    if ($all_inline) {
66
+        // inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande)
67
+        foreach ($files as $name) {
68
+            $file = direction_css(find_in_theme($name));
69
+            if (function_exists("compacte")) {
70
+                $file = compacte($file);
71
+            } else {
72
+                $file = url_absolue_css($file); // precaution
73
+            }
74
+            lire_fichier($file, $c);
75
+            $css .= $c;
76
+        }
77
+        $css = "<style type='text/css'>" . $css . "</style>";
78
+    } else {
79
+        foreach ($files as $name) {
80
+            $file = direction_css(find_in_theme($name));
81
+            $css .= "<link rel='stylesheet' href='$file' type='text/css' />\n";
82
+        }
83
+    }
84
+
85
+    // au cas ou minipres() est appele avant spip_initialisation_suite()
86
+    if (!defined('_DOCTYPE_ECRIRE')) {
87
+        define('_DOCTYPE_ECRIRE', '');
88
+    }
89
+
90
+    return _DOCTYPE_ECRIRE .
91
+    html_lang_attributes() .
92
+    "<head>\n" .
93
+    "<title>" .
94
+    textebrut($titre) .
95
+    "</title>\n" .
96
+    "<meta name='viewport' content='width=device-width' />\n" .
97
+    $css .
98
+    "</head>
99 99
 <body" . $onLoad . " class='minipres'>
100 100
 	<div id='minipres'>
101 101
 	<h1>" .
102
-	$titre .
103
-	"</h1>
102
+    $titre .
103
+    "</h1>
104 104
 	<div>\n";
105 105
 }
106 106
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
  * @return string Code HTML
111 111
  */
112 112
 function install_fin_html() {
113
-	return "\n\t</div>\n\t</div>\n</body>\n</html>";
113
+    return "\n\t</div>\n\t</div>\n</body>\n</html>";
114 114
 }
115 115
 
116 116
 
@@ -148,76 +148,76 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function minipres($titre = '', $corps = "", $options = array()) {
150 150
 
151
-	// compat signature old
152
-	// minipres($titre='', $corps="", $onload='', $all_inline = false)
153
-	$args = func_get_args();
154
-	if (isset($args[2]) and is_string($args[2])) {
155
-		$options = array('onload' => $args[2]);
156
-	}
157
-	if (isset($args[3])) {
158
-		$options['all_inline'] = $args[3];
159
-	}
160
-
161
-	$options = array_merge(array(
162
-		'onload' => '',
163
-		'all_inline' => false,
164
-	), $options);
165
-
166
-	if (!defined('_AJAX')) {
167
-		define('_AJAX', false);
168
-	} // par securite
169
-	if (!$titre) {
170
-		if (!isset($options['status'])) {
171
-			$options['status'] = 403;
172
-		}
173
-		if (!$titre = _request('action')
174
-			and !$titre = _request('exec')
175
-			and !$titre = _request('page')
176
-		) {
177
-			$titre = '?';
178
-		}
179
-
180
-		$titre = spip_htmlspecialchars($titre);
181
-
182
-		$titre = ($titre == 'install')
183
-			? _T('avis_espace_interdit')
184
-			: $titre . '&nbsp;: ' . _T('info_acces_interdit');
185
-
186
-		$statut = isset($GLOBALS['visiteur_session']['statut']) ? $GLOBALS['visiteur_session']['statut'] : '';
187
-		$nom = isset($GLOBALS['visiteur_session']['nom']) ? $GLOBALS['visiteur_session']['nom'] : '';
188
-
189
-		if ($statut != '0minirezo') {
190
-			$titre = _T('info_acces_interdit');
191
-		}
192
-
193
-		if ($statut AND test_espace_prive()) {
194
-			$corps = bouton_action(_T('public:accueil_site'),generer_url_ecrire('accueil'));
195
-		}
196
-		elseif (!empty($_COOKIE['spip_admin'])) {
197
-			$corps = bouton_action(_T('public:lien_connecter'),generer_url_public('login'));
198
-		}
199
-		else {
200
-			$corps = bouton_action(_T('public:accueil_site'),$GLOBALS['meta']['adresse_site']);
201
-		}
202
-		$corps = "<div class='boutons'>$corps</div>";
203
-		spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
204
-	}
205
-
206
-	if (!_AJAX) {
207
-		if (isset($options['status'])) {
208
-			http_status($options['status']);
209
-		}
210
-
211
-		return install_debut_html($titre, $options['onload'], $options['all_inline'])
212
-		. $corps
213
-		. install_fin_html();
214
-	} else {
215
-		include_spip('inc/headers');
216
-		include_spip('inc/actions');
217
-		$url = self('&', true);
218
-		foreach ($_POST as $v => $c) {
219
-			$url = parametre_url($url, $v, $c, '&');
220
-		}
221
-		ajax_retour("<div>" . $titre . redirige_formulaire($url) . "</div>", false);
222
-	}
151
+    // compat signature old
152
+    // minipres($titre='', $corps="", $onload='', $all_inline = false)
153
+    $args = func_get_args();
154
+    if (isset($args[2]) and is_string($args[2])) {
155
+        $options = array('onload' => $args[2]);
156
+    }
157
+    if (isset($args[3])) {
158
+        $options['all_inline'] = $args[3];
159
+    }
160
+
161
+    $options = array_merge(array(
162
+        'onload' => '',
163
+        'all_inline' => false,
164
+    ), $options);
165
+
166
+    if (!defined('_AJAX')) {
167
+        define('_AJAX', false);
168
+    } // par securite
169
+    if (!$titre) {
170
+        if (!isset($options['status'])) {
171
+            $options['status'] = 403;
172
+        }
173
+        if (!$titre = _request('action')
174
+            and !$titre = _request('exec')
175
+            and !$titre = _request('page')
176
+        ) {
177
+            $titre = '?';
178
+        }
179
+
180
+        $titre = spip_htmlspecialchars($titre);
181
+
182
+        $titre = ($titre == 'install')
183
+            ? _T('avis_espace_interdit')
184
+            : $titre . '&nbsp;: ' . _T('info_acces_interdit');
185
+
186
+        $statut = isset($GLOBALS['visiteur_session']['statut']) ? $GLOBALS['visiteur_session']['statut'] : '';
187
+        $nom = isset($GLOBALS['visiteur_session']['nom']) ? $GLOBALS['visiteur_session']['nom'] : '';
188
+
189
+        if ($statut != '0minirezo') {
190
+            $titre = _T('info_acces_interdit');
191
+        }
192
+
193
+        if ($statut AND test_espace_prive()) {
194
+            $corps = bouton_action(_T('public:accueil_site'),generer_url_ecrire('accueil'));
195
+        }
196
+        elseif (!empty($_COOKIE['spip_admin'])) {
197
+            $corps = bouton_action(_T('public:lien_connecter'),generer_url_public('login'));
198
+        }
199
+        else {
200
+            $corps = bouton_action(_T('public:accueil_site'),$GLOBALS['meta']['adresse_site']);
201
+        }
202
+        $corps = "<div class='boutons'>$corps</div>";
203
+        spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
204
+    }
205
+
206
+    if (!_AJAX) {
207
+        if (isset($options['status'])) {
208
+            http_status($options['status']);
209
+        }
210
+
211
+        return install_debut_html($titre, $options['onload'], $options['all_inline'])
212
+        . $corps
213
+        . install_fin_html();
214
+    } else {
215
+        include_spip('inc/headers');
216
+        include_spip('inc/actions');
217
+        $url = self('&', true);
218
+        foreach ($_POST as $v => $c) {
219
+            $url = parametre_url($url, $v, $c, '&');
220
+        }
221
+        ajax_retour("<div>" . $titre . redirige_formulaire($url) . "</div>", false);
222
+    }
223 223
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			lire_fichier($file, $c);
75 75
 			$css .= $c;
76 76
 		}
77
-		$css = "<style type='text/css'>" . $css . "</style>";
77
+		$css = "<style type='text/css'>".$css."</style>";
78 78
 	} else {
79 79
 		foreach ($files as $name) {
80 80
 			$file = direction_css(find_in_theme($name));
@@ -87,19 +87,19 @@  discard block
 block discarded – undo
87 87
 		define('_DOCTYPE_ECRIRE', '');
88 88
 	}
89 89
 
90
-	return _DOCTYPE_ECRIRE .
91
-	html_lang_attributes() .
92
-	"<head>\n" .
93
-	"<title>" .
94
-	textebrut($titre) .
95
-	"</title>\n" .
96
-	"<meta name='viewport' content='width=device-width' />\n" .
97
-	$css .
90
+	return _DOCTYPE_ECRIRE.
91
+	html_lang_attributes().
92
+	"<head>\n".
93
+	"<title>".
94
+	textebrut($titre).
95
+	"</title>\n".
96
+	"<meta name='viewport' content='width=device-width' />\n".
97
+	$css.
98 98
 	"</head>
99
-<body" . $onLoad . " class='minipres'>
99
+<body" . $onLoad." class='minipres'>
100 100
 	<div id='minipres'>
101 101
 	<h1>" .
102
-	$titre .
102
+	$titre.
103 103
 	"</h1>
104 104
 	<div>\n";
105 105
 }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
 		$titre = ($titre == 'install')
183 183
 			? _T('avis_espace_interdit')
184
-			: $titre . '&nbsp;: ' . _T('info_acces_interdit');
184
+			: $titre.'&nbsp;: '._T('info_acces_interdit');
185 185
 
186 186
 		$statut = isset($GLOBALS['visiteur_session']['statut']) ? $GLOBALS['visiteur_session']['statut'] : '';
187 187
 		$nom = isset($GLOBALS['visiteur_session']['nom']) ? $GLOBALS['visiteur_session']['nom'] : '';
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
 		}
192 192
 
193 193
 		if ($statut AND test_espace_prive()) {
194
-			$corps = bouton_action(_T('public:accueil_site'),generer_url_ecrire('accueil'));
194
+			$corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil'));
195 195
 		}
196 196
 		elseif (!empty($_COOKIE['spip_admin'])) {
197
-			$corps = bouton_action(_T('public:lien_connecter'),generer_url_public('login'));
197
+			$corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login'));
198 198
 		}
199 199
 		else {
200
-			$corps = bouton_action(_T('public:accueil_site'),$GLOBALS['meta']['adresse_site']);
200
+			$corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
201 201
 		}
202 202
 		$corps = "<div class='boutons'>$corps</div>";
203
-		spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
203
+		spip_log($nom." $titre ".$_SERVER['REQUEST_URI']);
204 204
 	}
205 205
 
206 206
 	if (!_AJAX) {
@@ -218,6 +218,6 @@  discard block
 block discarded – undo
218 218
 		foreach ($_POST as $v => $c) {
219 219
 			$url = parametre_url($url, $v, $c, '&');
220 220
 		}
221
-		ajax_retour("<div>" . $titre . redirige_formulaire($url) . "</div>", false);
221
+		ajax_retour("<div>".$titre.redirige_formulaire($url)."</div>", false);
222 222
 	}
223 223
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -192,11 +192,9 @@
 block discarded – undo
192 192
 
193 193
 		if ($statut AND test_espace_prive()) {
194 194
 			$corps = bouton_action(_T('public:accueil_site'),generer_url_ecrire('accueil'));
195
-		}
196
-		elseif (!empty($_COOKIE['spip_admin'])) {
195
+		} elseif (!empty($_COOKIE['spip_admin'])) {
197 196
 			$corps = bouton_action(_T('public:lien_connecter'),generer_url_public('login'));
198
-		}
199
-		else {
197
+		} else {
200 198
 			$corps = bouton_action(_T('public:accueil_site'),$GLOBALS['meta']['adresse_site']);
201 199
 		}
202 200
 		$corps = "<div class='boutons'>$corps</div>";
Please login to merge, or discard this patch.
ecrire/inc/securiser_action.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
  * @param string $titre
78 78
  * @param string $titre_bouton
79 79
  * @param string|null $url_action
80
- * @return bool
80
+ * @return boolean|null
81 81
  */
82 82
 function demander_confirmation_avant_action($titre, $titre_bouton, $url_action=null) {
83 83
 
@@ -351,6 +351,7 @@  discard block
 block discarded – undo
351 351
  * @param string $url Url à autoriser en prévisu
352 352
  * @param int|null id_auteur qui génère le token de prévisu. Null utilisera auteur courant.
353 353
  * @param string $alea Nom de l’alea à utiliser
354
+ * @param integer $id_auteur
354 355
  * @return string Token, de la forme "{id}*{hash}"
355 356
  */
356 357
 function calculer_token_previsu($url, $id_auteur = null, $alea = 'alea_ephemere') {
Please login to merge, or discard this patch.
Indentation   +204 added lines, -204 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
 /**
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
  * @return array|string
51 51
  */
52 52
 function inc_securiser_action_dist($action = '', $arg = '', $redirect = "", $mode = false, $att = '', $public = false) {
53
-	if ($action) {
54
-		return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public);
55
-	} else {
56
-		$arg = _request('arg');
57
-		$hash = _request('hash');
58
-		$action = _request('action') ? _request('action') : _request('formulaire_action');
59
-		if ($a = verifier_action_auteur("$action-$arg", $hash)) {
60
-			return $arg;
61
-		}
62
-		include_spip('inc/minipres');
63
-		echo minipres();
64
-		exit;
65
-	}
53
+    if ($action) {
54
+        return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public);
55
+    } else {
56
+        $arg = _request('arg');
57
+        $hash = _request('hash');
58
+        $action = _request('action') ? _request('action') : _request('formulaire_action');
59
+        if ($a = verifier_action_auteur("$action-$arg", $hash)) {
60
+            return $arg;
61
+        }
62
+        include_spip('inc/minipres');
63
+        echo minipres();
64
+        exit;
65
+    }
66 66
 }
67 67
 
68 68
 /**
@@ -81,29 +81,29 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function demander_confirmation_avant_action($titre, $titre_bouton, $url_action=null) {
83 83
 
84
-	if (!$url_action) {
85
-		$url_action = self();
86
-		$action = _request('action');
87
-		$url_action = parametre_url($url_action, 'action', $action, '&');
88
-	}
89
-	else {
90
-		$action = parametre_url($url_action, 'action');
91
-	}
92
-
93
-	$arg = parametre_url($url_action, 'arg');
94
-	$confirm = md5("$action:$arg:".realpath(__FILE__));
95
-	if (_request('confirm_action') === $confirm) {
96
-		return true;
97
-	}
98
-
99
-	$url_confirm = parametre_url($url_action, "confirm_action", $confirm, '&');
100
-	include_spip("inc/filtres");
101
-	$bouton_action = bouton_action($titre_bouton, $url_confirm);
102
-	$corps = "<div style='text-align:center;'>$bouton_action</div>";
103
-
104
-	include_spip("inc/minipres");
105
-	echo minipres($titre,$corps);
106
-	exit;
84
+    if (!$url_action) {
85
+        $url_action = self();
86
+        $action = _request('action');
87
+        $url_action = parametre_url($url_action, 'action', $action, '&');
88
+    }
89
+    else {
90
+        $action = parametre_url($url_action, 'action');
91
+    }
92
+
93
+    $arg = parametre_url($url_action, 'arg');
94
+    $confirm = md5("$action:$arg:".realpath(__FILE__));
95
+    if (_request('confirm_action') === $confirm) {
96
+        return true;
97
+    }
98
+
99
+    $url_confirm = parametre_url($url_action, "confirm_action", $confirm, '&');
100
+    include_spip("inc/filtres");
101
+    $bouton_action = bouton_action($titre_bouton, $url_confirm);
102
+    $corps = "<div style='text-align:center;'>$bouton_action</div>";
103
+
104
+    include_spip("inc/minipres");
105
+    echo minipres($titre,$corps);
106
+    exit;
107 107
 }
108 108
 
109 109
 /**
@@ -135,30 +135,30 @@  discard block
 block discarded – undo
135 135
  */
136 136
 function securiser_action_auteur($action, $arg, $redirect = "", $mode = false, $att = '', $public = false) {
137 137
 
138
-	// mode URL ou array
139
-	if (!is_string($mode)) {
140
-		$hash = calculer_action_auteur("$action-$arg", is_numeric($att) ? $att : null);
141
-
142
-		$r = rawurlencode($redirect);
143
-		if ($mode === -1) {
144
-			return array('action' => $action, 'arg' => $arg, 'hash' => $hash);
145
-		} else {
146
-			return generer_url_action($action, "arg=" . rawurlencode($arg) . "&hash=$hash" . (!$r ? '' : "&redirect=$r"),
147
-				$mode, $public);
148
-		}
149
-	}
150
-
151
-	// mode formulaire
152
-	$hash = calculer_action_auteur("$action-$arg");
153
-	$att .= " style='margin: 0px; border: 0px'";
154
-	if ($redirect) {
155
-		$redirect = "\n\t\t<input name='redirect' type='hidden' value='" . str_replace("'", '&#39;', $redirect) . "' />";
156
-	}
157
-	$mode .= $redirect . "
138
+    // mode URL ou array
139
+    if (!is_string($mode)) {
140
+        $hash = calculer_action_auteur("$action-$arg", is_numeric($att) ? $att : null);
141
+
142
+        $r = rawurlencode($redirect);
143
+        if ($mode === -1) {
144
+            return array('action' => $action, 'arg' => $arg, 'hash' => $hash);
145
+        } else {
146
+            return generer_url_action($action, "arg=" . rawurlencode($arg) . "&hash=$hash" . (!$r ? '' : "&redirect=$r"),
147
+                $mode, $public);
148
+        }
149
+    }
150
+
151
+    // mode formulaire
152
+    $hash = calculer_action_auteur("$action-$arg");
153
+    $att .= " style='margin: 0px; border: 0px'";
154
+    if ($redirect) {
155
+        $redirect = "\n\t\t<input name='redirect' type='hidden' value='" . str_replace("'", '&#39;', $redirect) . "' />";
156
+    }
157
+    $mode .= $redirect . "
158 158
 <input name='hash' type='hidden' value='$hash' />
159 159
 <input name='arg' type='hidden' value='$arg' />";
160 160
 
161
-	return generer_form_action($action, $mode, $att, $public);
161
+    return generer_form_action($action, $mode, $att, $public);
162 162
 }
163 163
 
164 164
 /**
@@ -168,47 +168,47 @@  discard block
 block discarded – undo
168 168
  * @return array
169 169
  */
170 170
 function caracteriser_auteur($id_auteur = null) {
171
-	static $caracterisation = array();
172
-
173
-	if (is_null($id_auteur) and !isset($GLOBALS['visiteur_session']['id_auteur'])) {
174
-		// si l'auteur courant n'est pas connu alors qu'il peut demander une action
175
-		// c'est une connexion par php_auth ou 1 instal, on se rabat sur le cookie.
176
-		// S'il n'avait pas le droit de realiser cette action, le hash sera faux.
177
-		if (isset($_COOKIE['spip_session'])
178
-			and (preg_match('/^(\d+)/', $_COOKIE['spip_session'], $r))
179
-		) {
180
-			return array($r[1], '');
181
-			// Necessaire aux forums anonymes.
182
-			// Pour le reste, ca echouera.
183
-		} else {
184
-			return array('0', '');
185
-		}
186
-	}
187
-	// Eviter l'acces SQL si le pass est connu de PHP
188
-	if (is_null($id_auteur)) {
189
-		$id_auteur = isset($GLOBALS['visiteur_session']['id_auteur']) ? $GLOBALS['visiteur_session']['id_auteur'] : 0;
190
-		if (isset($GLOBALS['visiteur_session']['pass']) and $GLOBALS['visiteur_session']['pass']) {
191
-			return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']);
192
-		}
193
-	}
194
-
195
-	if (isset($caracterisation[$id_auteur])) {
196
-		return $caracterisation[$id_auteur];
197
-	}
198
-
199
-	if ($id_auteur) {
200
-		include_spip('base/abstract_sql');
201
-		$t = sql_fetsel("id_auteur, pass", "spip_auteurs", "id_auteur=$id_auteur");
202
-		if ($t) {
203
-			return $caracterisation[$id_auteur] = array($t['id_auteur'], $t['pass']);
204
-		}
205
-		include_spip('inc/minipres');
206
-		echo minipres();
207
-		exit;
208
-	} // Visiteur anonyme, pour ls forums par exemple
209
-	else {
210
-		return array('0', '');
211
-	}
171
+    static $caracterisation = array();
172
+
173
+    if (is_null($id_auteur) and !isset($GLOBALS['visiteur_session']['id_auteur'])) {
174
+        // si l'auteur courant n'est pas connu alors qu'il peut demander une action
175
+        // c'est une connexion par php_auth ou 1 instal, on se rabat sur le cookie.
176
+        // S'il n'avait pas le droit de realiser cette action, le hash sera faux.
177
+        if (isset($_COOKIE['spip_session'])
178
+            and (preg_match('/^(\d+)/', $_COOKIE['spip_session'], $r))
179
+        ) {
180
+            return array($r[1], '');
181
+            // Necessaire aux forums anonymes.
182
+            // Pour le reste, ca echouera.
183
+        } else {
184
+            return array('0', '');
185
+        }
186
+    }
187
+    // Eviter l'acces SQL si le pass est connu de PHP
188
+    if (is_null($id_auteur)) {
189
+        $id_auteur = isset($GLOBALS['visiteur_session']['id_auteur']) ? $GLOBALS['visiteur_session']['id_auteur'] : 0;
190
+        if (isset($GLOBALS['visiteur_session']['pass']) and $GLOBALS['visiteur_session']['pass']) {
191
+            return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']);
192
+        }
193
+    }
194
+
195
+    if (isset($caracterisation[$id_auteur])) {
196
+        return $caracterisation[$id_auteur];
197
+    }
198
+
199
+    if ($id_auteur) {
200
+        include_spip('base/abstract_sql');
201
+        $t = sql_fetsel("id_auteur, pass", "spip_auteurs", "id_auteur=$id_auteur");
202
+        if ($t) {
203
+            return $caracterisation[$id_auteur] = array($t['id_auteur'], $t['pass']);
204
+        }
205
+        include_spip('inc/minipres');
206
+        echo minipres();
207
+        exit;
208
+    } // Visiteur anonyme, pour ls forums par exemple
209
+    else {
210
+        return array('0', '');
211
+    }
212 212
 }
213 213
 
214 214
 /**
@@ -223,28 +223,28 @@  discard block
 block discarded – undo
223 223
  * @return string
224 224
  */
225 225
 function _action_auteur($action, $id_auteur, $pass, $alea) {
226
-	static $sha = array();
227
-	if (!isset($sha[$id_auteur . $pass . $alea])) {
228
-		if (!isset($GLOBALS['meta'][$alea])) {
229
-			if (!$exec = _request('exec') or !autoriser_sans_cookie($exec)){
230
-				include_spip('inc/acces');
231
-				charger_aleas();
232
-				if (empty($GLOBALS['meta'][$alea])){
233
-					include_spip('inc/minipres');
234
-					echo minipres();
235
-					spip_log("$alea indisponible");
236
-					exit;
237
-				}
238
-			}
239
-		}
240
-		include_spip('auth/sha256.inc');
241
-		$sha[$id_auteur . $pass . $alea] = spip_sha256($id_auteur . $pass . @$GLOBALS['meta'][$alea]);
242
-	}
243
-	if (function_exists('sha1')) {
244
-		return sha1($action . $sha[$id_auteur . $pass . $alea]);
245
-	} else {
246
-		return md5($action . $sha[$id_auteur . $pass . $alea]);
247
-	}
226
+    static $sha = array();
227
+    if (!isset($sha[$id_auteur . $pass . $alea])) {
228
+        if (!isset($GLOBALS['meta'][$alea])) {
229
+            if (!$exec = _request('exec') or !autoriser_sans_cookie($exec)){
230
+                include_spip('inc/acces');
231
+                charger_aleas();
232
+                if (empty($GLOBALS['meta'][$alea])){
233
+                    include_spip('inc/minipres');
234
+                    echo minipres();
235
+                    spip_log("$alea indisponible");
236
+                    exit;
237
+                }
238
+            }
239
+        }
240
+        include_spip('auth/sha256.inc');
241
+        $sha[$id_auteur . $pass . $alea] = spip_sha256($id_auteur . $pass . @$GLOBALS['meta'][$alea]);
242
+    }
243
+    if (function_exists('sha1')) {
244
+        return sha1($action . $sha[$id_auteur . $pass . $alea]);
245
+    } else {
246
+        return md5($action . $sha[$id_auteur . $pass . $alea]);
247
+    }
248 248
 }
249 249
 
250 250
 /**
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
  * @return string
256 256
  */
257 257
 function calculer_action_auteur($action, $id_auteur = null) {
258
-	list($id_auteur, $pass) = caracteriser_auteur($id_auteur);
258
+    list($id_auteur, $pass) = caracteriser_auteur($id_auteur);
259 259
 
260
-	return _action_auteur($action, $id_auteur, $pass, 'alea_ephemere');
260
+    return _action_auteur($action, $id_auteur, $pass, 'alea_ephemere');
261 261
 }
262 262
 
263 263
 
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
  * @return bool
271 271
  */
272 272
 function verifier_action_auteur($action, $hash) {
273
-	list($id_auteur, $pass) = caracteriser_auteur();
274
-	if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere')) {
275
-		return true;
276
-	}
277
-	if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere_ancien')) {
278
-		return true;
279
-	}
280
-
281
-	return false;
273
+    list($id_auteur, $pass) = caracteriser_auteur();
274
+    if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere')) {
275
+        return true;
276
+    }
277
+    if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere_ancien')) {
278
+        return true;
279
+    }
280
+
281
+    return false;
282 282
 }
283 283
 
284 284
 //
@@ -294,25 +294,25 @@  discard block
 block discarded – undo
294 294
  * @return string
295 295
  */
296 296
 function secret_du_site() {
297
-	if (!isset($GLOBALS['meta']['secret_du_site'])) {
298
-		include_spip('base/abstract_sql');
299
-		$GLOBALS['meta']['secret_du_site'] = sql_getfetsel('valeur', 'spip_meta', "nom='secret_du_site'");
300
-	}
301
-	if (!isset($GLOBALS['meta']['secret_du_site'])
302
-		or (strlen($GLOBALS['meta']['secret_du_site']) < 64)
303
-	) {
304
-		include_spip('inc/acces');
305
-		include_spip('auth/sha256.inc');
306
-		ecrire_meta('secret_du_site',
307
-			spip_sha256(
308
-				$_SERVER["DOCUMENT_ROOT"] 
309
-				. (isset($_SERVER['SERVER_SIGNATURE']) ? $_SERVER["SERVER_SIGNATURE"] : "")
310
-				. creer_uniqid()
311
-			), 'non');
312
-		lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas
313
-	}
314
-
315
-	return $GLOBALS['meta']['secret_du_site'];
297
+    if (!isset($GLOBALS['meta']['secret_du_site'])) {
298
+        include_spip('base/abstract_sql');
299
+        $GLOBALS['meta']['secret_du_site'] = sql_getfetsel('valeur', 'spip_meta', "nom='secret_du_site'");
300
+    }
301
+    if (!isset($GLOBALS['meta']['secret_du_site'])
302
+        or (strlen($GLOBALS['meta']['secret_du_site']) < 64)
303
+    ) {
304
+        include_spip('inc/acces');
305
+        include_spip('auth/sha256.inc');
306
+        ecrire_meta('secret_du_site',
307
+            spip_sha256(
308
+                $_SERVER["DOCUMENT_ROOT"] 
309
+                . (isset($_SERVER['SERVER_SIGNATURE']) ? $_SERVER["SERVER_SIGNATURE"] : "")
310
+                . creer_uniqid()
311
+            ), 'non');
312
+        lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas
313
+    }
314
+
315
+    return $GLOBALS['meta']['secret_du_site'];
316 316
 }
317 317
 
318 318
 /**
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
  * @return string
323 323
  */
324 324
 function calculer_cle_action($action) {
325
-	if (function_exists('sha1')) {
326
-		return sha1($action . secret_du_site());
327
-	} else {
328
-		return md5($action . secret_du_site());
329
-	}
325
+    if (function_exists('sha1')) {
326
+        return sha1($action . secret_du_site());
327
+    } else {
328
+        return md5($action . secret_du_site());
329
+    }
330 330
 }
331 331
 
332 332
 /**
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
  * @return bool
338 338
  */
339 339
 function verifier_cle_action($action, $cle) {
340
-	return ($cle == calculer_cle_action($action));
340
+    return ($cle == calculer_cle_action($action));
341 341
 }
342 342
 
343 343
 
@@ -354,19 +354,19 @@  discard block
 block discarded – undo
354 354
  * @return string Token, de la forme "{id}*{hash}"
355 355
  */
356 356
 function calculer_token_previsu($url, $id_auteur = null, $alea = 'alea_ephemere') {
357
-	if (is_null($id_auteur)) {
358
-		if (!empty($GLOBALS['visiteur_session']['id_auteur'])) {
359
-			$id_auteur = $GLOBALS['visiteur_session']['id_auteur'];
360
-		}
361
-	}
362
-	if (!$id_auteur = intval($id_auteur)) {
363
-		return "";
364
-	}
365
-	// On nettoie l’URL de tous les var_.
366
-	$url = nettoyer_uri_var($url);
367
-
368
-	$token = _action_auteur('previsualiser-' . $url, $id_auteur, null, $alea);
369
-	return "$id_auteur-$token";
357
+    if (is_null($id_auteur)) {
358
+        if (!empty($GLOBALS['visiteur_session']['id_auteur'])) {
359
+            $id_auteur = $GLOBALS['visiteur_session']['id_auteur'];
360
+        }
361
+    }
362
+    if (!$id_auteur = intval($id_auteur)) {
363
+        return "";
364
+    }
365
+    // On nettoie l’URL de tous les var_.
366
+    $url = nettoyer_uri_var($url);
367
+
368
+    $token = _action_auteur('previsualiser-' . $url, $id_auteur, null, $alea);
369
+    return "$id_auteur-$token";
370 370
 }
371 371
 
372 372
 
@@ -384,31 +384,31 @@  discard block
 block discarded – undo
384 384
  *     + Tableau (id auteur, type d’objet, id_objet) sinon.
385 385
  */
386 386
 function verifier_token_previsu($token) {
387
-	// retrouver auteur / hash
388
-	$e = explode('-', $token, 2);
389
-	if (count($e) == 2 and is_numeric(reset($e))) {
390
-		$id_auteur = intval(reset($e));
391
-	} else {
392
-		return false;
393
-	}
394
-
395
-	// calculer le type et id de l’url actuelle
396
-	include_spip('inc/urls');
397
-	include_spip('inc/filtres_mini');
398
-	$url = url_absolue(self());
399
-
400
-	// verifier le token
401
-	$_token = calculer_token_previsu($url, $id_auteur, 'alea_ephemere');
402
-	if (!$_token or $token !== $_token) {
403
-		$_token = calculer_token_previsu($url, $id_auteur, 'alea_ephemere_ancien');
404
-		if (!$_token or $token !== $_token) {
405
-			return false;
406
-		}
407
-	}
408
-
409
-	return array(
410
-		'id_auteur' => $id_auteur,
411
-	);
387
+    // retrouver auteur / hash
388
+    $e = explode('-', $token, 2);
389
+    if (count($e) == 2 and is_numeric(reset($e))) {
390
+        $id_auteur = intval(reset($e));
391
+    } else {
392
+        return false;
393
+    }
394
+
395
+    // calculer le type et id de l’url actuelle
396
+    include_spip('inc/urls');
397
+    include_spip('inc/filtres_mini');
398
+    $url = url_absolue(self());
399
+
400
+    // verifier le token
401
+    $_token = calculer_token_previsu($url, $id_auteur, 'alea_ephemere');
402
+    if (!$_token or $token !== $_token) {
403
+        $_token = calculer_token_previsu($url, $id_auteur, 'alea_ephemere_ancien');
404
+        if (!$_token or $token !== $_token) {
405
+            return false;
406
+        }
407
+    }
408
+
409
+    return array(
410
+        'id_auteur' => $id_auteur,
411
+    );
412 412
 }
413 413
 
414 414
 /**
@@ -417,13 +417,13 @@  discard block
 block discarded – undo
417 417
  * @return bool|array
418 418
  */
419 419
 function decrire_token_previsu() {
420
-	static $desc = null;
421
-	if (is_null($desc)) {
422
-		if ($token = _request('var_previewtoken')) {
423
-			$desc = verifier_token_previsu($token);
424
-		} else {
425
-			$desc = false;
426
-		}
427
-	}
428
-	return $desc;
420
+    static $desc = null;
421
+    if (is_null($desc)) {
422
+        if ($token = _request('var_previewtoken')) {
423
+            $desc = verifier_token_previsu($token);
424
+        } else {
425
+            $desc = false;
426
+        }
427
+    }
428
+    return $desc;
429 429
 }
430 430
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
  * @param string|null $url_action
80 80
  * @return bool
81 81
  */
82
-function demander_confirmation_avant_action($titre, $titre_bouton, $url_action=null) {
82
+function demander_confirmation_avant_action($titre, $titre_bouton, $url_action = null) {
83 83
 
84 84
 	if (!$url_action) {
85 85
 		$url_action = self();
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	$corps = "<div style='text-align:center;'>$bouton_action</div>";
103 103
 
104 104
 	include_spip("inc/minipres");
105
-	echo minipres($titre,$corps);
105
+	echo minipres($titre, $corps);
106 106
 	exit;
107 107
 }
108 108
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		if ($mode === -1) {
144 144
 			return array('action' => $action, 'arg' => $arg, 'hash' => $hash);
145 145
 		} else {
146
-			return generer_url_action($action, "arg=" . rawurlencode($arg) . "&hash=$hash" . (!$r ? '' : "&redirect=$r"),
146
+			return generer_url_action($action, "arg=".rawurlencode($arg)."&hash=$hash".(!$r ? '' : "&redirect=$r"),
147 147
 				$mode, $public);
148 148
 		}
149 149
 	}
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	$hash = calculer_action_auteur("$action-$arg");
153 153
 	$att .= " style='margin: 0px; border: 0px'";
154 154
 	if ($redirect) {
155
-		$redirect = "\n\t\t<input name='redirect' type='hidden' value='" . str_replace("'", '&#39;', $redirect) . "' />";
155
+		$redirect = "\n\t\t<input name='redirect' type='hidden' value='".str_replace("'", '&#39;', $redirect)."' />";
156 156
 	}
157
-	$mode .= $redirect . "
157
+	$mode .= $redirect."
158 158
 <input name='hash' type='hidden' value='$hash' />
159 159
 <input name='arg' type='hidden' value='$arg' />";
160 160
 
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
  */
225 225
 function _action_auteur($action, $id_auteur, $pass, $alea) {
226 226
 	static $sha = array();
227
-	if (!isset($sha[$id_auteur . $pass . $alea])) {
227
+	if (!isset($sha[$id_auteur.$pass.$alea])) {
228 228
 		if (!isset($GLOBALS['meta'][$alea])) {
229
-			if (!$exec = _request('exec') or !autoriser_sans_cookie($exec)){
229
+			if (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) {
230 230
 				include_spip('inc/acces');
231 231
 				charger_aleas();
232
-				if (empty($GLOBALS['meta'][$alea])){
232
+				if (empty($GLOBALS['meta'][$alea])) {
233 233
 					include_spip('inc/minipres');
234 234
 					echo minipres();
235 235
 					spip_log("$alea indisponible");
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 			}
239 239
 		}
240 240
 		include_spip('auth/sha256.inc');
241
-		$sha[$id_auteur . $pass . $alea] = spip_sha256($id_auteur . $pass . @$GLOBALS['meta'][$alea]);
241
+		$sha[$id_auteur.$pass.$alea] = spip_sha256($id_auteur.$pass.@$GLOBALS['meta'][$alea]);
242 242
 	}
243 243
 	if (function_exists('sha1')) {
244
-		return sha1($action . $sha[$id_auteur . $pass . $alea]);
244
+		return sha1($action.$sha[$id_auteur.$pass.$alea]);
245 245
 	} else {
246
-		return md5($action . $sha[$id_auteur . $pass . $alea]);
246
+		return md5($action.$sha[$id_auteur.$pass.$alea]);
247 247
 	}
248 248
 }
249 249
 
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function calculer_cle_action($action) {
325 325
 	if (function_exists('sha1')) {
326
-		return sha1($action . secret_du_site());
326
+		return sha1($action.secret_du_site());
327 327
 	} else {
328
-		return md5($action . secret_du_site());
328
+		return md5($action.secret_du_site());
329 329
 	}
330 330
 }
331 331
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	// On nettoie l’URL de tous les var_.
366 366
 	$url = nettoyer_uri_var($url);
367 367
 
368
-	$token = _action_auteur('previsualiser-' . $url, $id_auteur, null, $alea);
368
+	$token = _action_auteur('previsualiser-'.$url, $id_auteur, null, $alea);
369 369
 	return "$id_auteur-$token";
370 370
 }
371 371
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@
 block discarded – undo
85 85
 		$url_action = self();
86 86
 		$action = _request('action');
87 87
 		$url_action = parametre_url($url_action, 'action', $action, '&');
88
-	}
89
-	else {
88
+	} else {
90 89
 		$action = parametre_url($url_action, 'action');
91 90
 	}
92 91
 
Please login to merge, or discard this patch.
ecrire/inc/headers.php 2 patches
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
 
@@ -38,132 +38,132 @@  discard block
 block discarded – undo
38 38
  * @param int $status Code de redirection (301 ou 302)
39 39
  **/
40 40
 function redirige_par_entete($url, $equiv = '', $status = 302) {
41
-	if (!in_array($status, array(301, 302))) {
42
-		$status = 302;
43
-	}
44
-
45
-	$url = trim(strtr($url, "\n\r", "  "));
46
-	# si l'url de redirection est relative, on la passe en absolue
47
-	if (!preg_match(",^(\w+:)?//,", $url)) {
48
-		include_spip("inc/filtres_mini");
49
-		$url = url_absolue($url);
50
-	}
51
-
52
-	if (defined('_AJAX') and _AJAX) {
53
-		$url = parametre_url($url, 'var_ajax_redir', 1, '&');
54
-	}
55
-
56
-	// ne pas laisser passer n'importe quoi dans l'url
57
-	$url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
58
-	$url = str_replace(array("\r", "\n", ' '), array('%0D', '%0A', '%20'), $url);
59
-	while (strpos($url, '%0A') !== false) {
60
-		$url = str_replace('%0A', '', $url);
61
-	}
62
-	// interdire les url inline avec des pseudo-protocoles :
63
-	if (
64
-		(preg_match(",data:,i", $url) and preg_match("/base64\s*,/i", $url))
65
-		or preg_match(",(javascript|mailto):,i", $url)
66
-	) {
67
-		$url = "./";
68
-	}
69
-
70
-	// Il n'y a que sous Apache que setcookie puis redirection fonctionne
71
-	include_spip('inc/cookie');
72
-	if (!defined('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE')) {
73
-		define('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE', '^(Apache|Cherokee|nginx)');
74
-	}
75
-	if (!defined('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE')) {
76
-		define('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE', 'Apache|Cherokee|nginx');
77
-	}
78
-	if ((!$equiv and !spip_cookie_envoye()) or (
79
-			   (!empty($_SERVER['SERVER_SOFTWARE'])
80
-				   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
81
-				   and preg_match("/"._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SOFTWARE']))
82
-			or (!empty($_SERVER['SERVER_SIGNATURE'])
83
-				   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
84
-				   and preg_match("/"._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SIGNATURE']))
85
-			or function_exists('apache_getenv')
86
-			or defined('_SERVER_APACHE')
87
-		)
88
-	) {
89
-		@header("Location: " . $url);
90
-		$equiv = "";
91
-	} else {
92
-		@header("Refresh: 0; url=" . $url);
93
-		if (isset($GLOBALS['meta']['charset'])) {
94
-			@header("Content-Type: text/html; charset=" . $GLOBALS['meta']['charset']);
95
-		}
96
-		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
97
-	}
98
-	include_spip('inc/lang');
99
-	if ($status != 302) {
100
-		http_status($status);
101
-	}
102
-	echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n",
103
-	html_lang_attributes(), '
41
+    if (!in_array($status, array(301, 302))) {
42
+        $status = 302;
43
+    }
44
+
45
+    $url = trim(strtr($url, "\n\r", "  "));
46
+    # si l'url de redirection est relative, on la passe en absolue
47
+    if (!preg_match(",^(\w+:)?//,", $url)) {
48
+        include_spip("inc/filtres_mini");
49
+        $url = url_absolue($url);
50
+    }
51
+
52
+    if (defined('_AJAX') and _AJAX) {
53
+        $url = parametre_url($url, 'var_ajax_redir', 1, '&');
54
+    }
55
+
56
+    // ne pas laisser passer n'importe quoi dans l'url
57
+    $url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
58
+    $url = str_replace(array("\r", "\n", ' '), array('%0D', '%0A', '%20'), $url);
59
+    while (strpos($url, '%0A') !== false) {
60
+        $url = str_replace('%0A', '', $url);
61
+    }
62
+    // interdire les url inline avec des pseudo-protocoles :
63
+    if (
64
+        (preg_match(",data:,i", $url) and preg_match("/base64\s*,/i", $url))
65
+        or preg_match(",(javascript|mailto):,i", $url)
66
+    ) {
67
+        $url = "./";
68
+    }
69
+
70
+    // Il n'y a que sous Apache que setcookie puis redirection fonctionne
71
+    include_spip('inc/cookie');
72
+    if (!defined('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE')) {
73
+        define('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE', '^(Apache|Cherokee|nginx)');
74
+    }
75
+    if (!defined('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE')) {
76
+        define('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE', 'Apache|Cherokee|nginx');
77
+    }
78
+    if ((!$equiv and !spip_cookie_envoye()) or (
79
+                (!empty($_SERVER['SERVER_SOFTWARE'])
80
+                   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
81
+                   and preg_match("/"._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SOFTWARE']))
82
+            or (!empty($_SERVER['SERVER_SIGNATURE'])
83
+                   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
84
+                   and preg_match("/"._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SIGNATURE']))
85
+            or function_exists('apache_getenv')
86
+            or defined('_SERVER_APACHE')
87
+        )
88
+    ) {
89
+        @header("Location: " . $url);
90
+        $equiv = "";
91
+    } else {
92
+        @header("Refresh: 0; url=" . $url);
93
+        if (isset($GLOBALS['meta']['charset'])) {
94
+            @header("Content-Type: text/html; charset=" . $GLOBALS['meta']['charset']);
95
+        }
96
+        $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
97
+    }
98
+    include_spip('inc/lang');
99
+    if ($status != 302) {
100
+        http_status($status);
101
+    }
102
+    echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n",
103
+    html_lang_attributes(), '
104 104
 <head>',
105
-	$equiv, '
105
+    $equiv, '
106 106
 <title>HTTP ' . $status . '</title>
107 107
 ' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset=' . $GLOBALS['meta']['charset'] . '">' : '') . '
108 108
 </head>
109 109
 <body>
110 110
 <h1>HTTP ' . $status . '</h1>
111 111
 <a href="',
112
-	quote_amp($url),
113
-	'">',
114
-	_T('navigateur_pas_redirige'),
115
-	'</a></body></html>';
112
+    quote_amp($url),
113
+    '">',
114
+    _T('navigateur_pas_redirige'),
115
+    '</a></body></html>';
116 116
 
117
-	spip_log("redirige $status: $url");
117
+    spip_log("redirige $status: $url");
118 118
 
119
-	exit;
119
+    exit;
120 120
 }
121 121
 
122 122
 // https://code.spip.net/@redirige_formulaire
123 123
 function redirige_formulaire($url, $equiv = '', $format = 'message') {
124
-	if (!_AJAX
125
-		and !headers_sent()
126
-		and !_request('var_ajax')
127
-	) {
128
-		redirige_par_entete(str_replace('&amp;', '&', $url), $equiv);
129
-	} // si c'est une ancre, fixer simplement le window.location.hash
130
-	elseif ($format == 'ajaxform' and preg_match(',^#[0-9a-z\-_]+$,i', $url)) {
131
-		return array(
132
-			// on renvoie un lien masque qui sera traite par ajaxCallback.js
133
-			"<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
134
-			// et rien dans le message ok
135
-			''
136
-		);
137
-	} else {
138
-		// ne pas laisser passer n'importe quoi dans l'url
139
-		$url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
140
-
141
-		$url = strtr($url, "\n\r", "  ");
142
-		# en theorie on devrait faire ca tout le temps, mais quand la chaine
143
-		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
144
-		if ($url[0] == '?') {
145
-			$url = url_de_base() . $url;
146
-		}
147
-		$url = str_replace('&amp;', '&', $url);
148
-		spip_log("redirige formulaire ajax: $url");
149
-		include_spip('inc/filtres');
150
-		if ($format == 'ajaxform') {
151
-			return array(
152
-				// on renvoie un lien masque qui sera traite par ajaxCallback.js
153
-				'<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
154
-				// et un message au cas ou
155
-				'<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
156
-			);
157
-		} else // format message texte, tout en js inline
158
-		{
159
-			return
160
-				// ie poste les formulaires dans une iframe, il faut donc rediriger son parent
161
-				"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
162
-				. http_img_pack('loader.svg', '', " class='loader'")
163
-				. '<br />'
164
-				. '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
165
-		}
166
-	}
124
+    if (!_AJAX
125
+        and !headers_sent()
126
+        and !_request('var_ajax')
127
+    ) {
128
+        redirige_par_entete(str_replace('&amp;', '&', $url), $equiv);
129
+    } // si c'est une ancre, fixer simplement le window.location.hash
130
+    elseif ($format == 'ajaxform' and preg_match(',^#[0-9a-z\-_]+$,i', $url)) {
131
+        return array(
132
+            // on renvoie un lien masque qui sera traite par ajaxCallback.js
133
+            "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
134
+            // et rien dans le message ok
135
+            ''
136
+        );
137
+    } else {
138
+        // ne pas laisser passer n'importe quoi dans l'url
139
+        $url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
140
+
141
+        $url = strtr($url, "\n\r", "  ");
142
+        # en theorie on devrait faire ca tout le temps, mais quand la chaine
143
+        # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
144
+        if ($url[0] == '?') {
145
+            $url = url_de_base() . $url;
146
+        }
147
+        $url = str_replace('&amp;', '&', $url);
148
+        spip_log("redirige formulaire ajax: $url");
149
+        include_spip('inc/filtres');
150
+        if ($format == 'ajaxform') {
151
+            return array(
152
+                // on renvoie un lien masque qui sera traite par ajaxCallback.js
153
+                '<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
154
+                // et un message au cas ou
155
+                '<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
156
+            );
157
+        } else // format message texte, tout en js inline
158
+        {
159
+            return
160
+                // ie poste les formulaires dans une iframe, il faut donc rediriger son parent
161
+                "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
162
+                . http_img_pack('loader.svg', '', " class='loader'")
163
+                . '<br />'
164
+                . '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
165
+        }
166
+    }
167 167
 }
168 168
 
169 169
 /**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
  * @return void
185 185
  **/
186 186
 function redirige_url_ecrire($script = '', $args = '', $equiv = '') {
187
-	return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
187
+    return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
188 188
 }
189 189
 
190 190
 /**
@@ -199,50 +199,50 @@  discard block
 block discarded – undo
199 199
  **/
200 200
 function http_status($status) {
201 201
 
202
-	static $status_string = array(
203
-		200 => '200 OK',
204
-		204 => '204 No Content',
205
-		301 => '301 Moved Permanently',
206
-		302 => '302 Found',
207
-		304 => '304 Not Modified',
208
-		400 => '400 Bad Request',
209
-		401 => '401 Unauthorized',
210
-		403 => '403 Forbidden',
211
-		404 => '404 Not Found',
212
-		503 => '503 Service Unavailable'
213
-	);
214
-
215
-	if (!empty($GLOBALS['REDIRECT_STATUS']) && $GLOBALS['REDIRECT_STATUS'] == $status) {
216
-		return;
217
-	}
218
-
219
-	$php_cgi = ($GLOBALS['flag_sapi_name'] and preg_match(",cgi,i", @php_sapi_name()));
220
-	if ($php_cgi) {
221
-		header("Status: " . $status_string[$status]);
222
-	} else {
223
-		header("HTTP/1.0 " . $status_string[$status]);
224
-	}
202
+    static $status_string = array(
203
+        200 => '200 OK',
204
+        204 => '204 No Content',
205
+        301 => '301 Moved Permanently',
206
+        302 => '302 Found',
207
+        304 => '304 Not Modified',
208
+        400 => '400 Bad Request',
209
+        401 => '401 Unauthorized',
210
+        403 => '403 Forbidden',
211
+        404 => '404 Not Found',
212
+        503 => '503 Service Unavailable'
213
+    );
214
+
215
+    if (!empty($GLOBALS['REDIRECT_STATUS']) && $GLOBALS['REDIRECT_STATUS'] == $status) {
216
+        return;
217
+    }
218
+
219
+    $php_cgi = ($GLOBALS['flag_sapi_name'] and preg_match(",cgi,i", @php_sapi_name()));
220
+    if ($php_cgi) {
221
+        header("Status: " . $status_string[$status]);
222
+    } else {
223
+        header("HTTP/1.0 " . $status_string[$status]);
224
+    }
225 225
 }
226 226
 
227 227
 // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache
228 228
 // https://code.spip.net/@http_no_cache
229 229
 function http_no_cache() {
230
-	if (headers_sent()) {
231
-		spip_log("http_no_cache arrive trop tard");
232
-
233
-		return;
234
-	}
235
-	$charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
236
-
237
-	// selon http://developer.apple.com/internet/safari/faq.html#anchor5
238
-	// il faudrait aussi pour Safari
239
-	// header("Cache-Control: post-check=0, pre-check=0", false)
240
-	// mais ca ne respecte pas
241
-	// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
242
-
243
-	header("Content-Type: text/html; charset=$charset");
244
-	header("Expires: 0");
245
-	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
246
-	header("Cache-Control: no-cache, must-revalidate");
247
-	header("Pragma: no-cache");
230
+    if (headers_sent()) {
231
+        spip_log("http_no_cache arrive trop tard");
232
+
233
+        return;
234
+    }
235
+    $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
236
+
237
+    // selon http://developer.apple.com/internet/safari/faq.html#anchor5
238
+    // il faudrait aussi pour Safari
239
+    // header("Cache-Control: post-check=0, pre-check=0", false)
240
+    // mais ca ne respecte pas
241
+    // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
242
+
243
+    header("Content-Type: text/html; charset=$charset");
244
+    header("Expires: 0");
245
+    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
246
+    header("Cache-Control: no-cache, must-revalidate");
247
+    header("Pragma: no-cache");
248 248
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 	if ((!$equiv and !spip_cookie_envoye()) or (
79 79
 			   (!empty($_SERVER['SERVER_SOFTWARE'])
80 80
 				   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
81
-				   and preg_match("/"._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SOFTWARE']))
81
+				   and preg_match("/"._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE."/i", $_SERVER['SERVER_SOFTWARE']))
82 82
 			or (!empty($_SERVER['SERVER_SIGNATURE'])
83 83
 				   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
84
-				   and preg_match("/"._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SIGNATURE']))
84
+				   and preg_match("/"._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE."/i", $_SERVER['SERVER_SIGNATURE']))
85 85
 			or function_exists('apache_getenv')
86 86
 			or defined('_SERVER_APACHE')
87 87
 		)
88 88
 	) {
89
-		@header("Location: " . $url);
89
+		@header("Location: ".$url);
90 90
 		$equiv = "";
91 91
 	} else {
92
-		@header("Refresh: 0; url=" . $url);
92
+		@header("Refresh: 0; url=".$url);
93 93
 		if (isset($GLOBALS['meta']['charset'])) {
94
-			@header("Content-Type: text/html; charset=" . $GLOBALS['meta']['charset']);
94
+			@header("Content-Type: text/html; charset=".$GLOBALS['meta']['charset']);
95 95
 		}
96 96
 		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
97 97
 	}
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	html_lang_attributes(), '
104 104
 <head>',
105 105
 	$equiv, '
106
-<title>HTTP ' . $status . '</title>
107
-' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset=' . $GLOBALS['meta']['charset'] . '">' : '') . '
106
+<title>HTTP ' . $status.'</title>
107
+' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset='.$GLOBALS['meta']['charset'].'">' : '').'
108 108
 </head>
109 109
 <body>
110
-<h1>HTTP ' . $status . '</h1>
110
+<h1>HTTP ' . $status.'</h1>
111 111
 <a href="',
112 112
 	quote_amp($url),
113 113
 	'">',
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		# en theorie on devrait faire ca tout le temps, mais quand la chaine
143 143
 		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
144 144
 		if ($url[0] == '?') {
145
-			$url = url_de_base() . $url;
145
+			$url = url_de_base().$url;
146 146
 		}
147 147
 		$url = str_replace('&amp;', '&', $url);
148 148
 		spip_log("redirige formulaire ajax: $url");
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 		if ($format == 'ajaxform') {
151 151
 			return array(
152 152
 				// on renvoie un lien masque qui sera traite par ajaxCallback.js
153
-				'<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
153
+				'<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
154 154
 				// et un message au cas ou
155
-				'<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
155
+				'<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'
156 156
 			);
157 157
 		} else // format message texte, tout en js inline
158 158
 		{
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 				"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
162 162
 				. http_img_pack('loader.svg', '', " class='loader'")
163 163
 				. '<br />'
164
-				. '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
164
+				. '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
165 165
 		}
166 166
 	}
167 167
 }
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 
219 219
 	$php_cgi = ($GLOBALS['flag_sapi_name'] and preg_match(",cgi,i", @php_sapi_name()));
220 220
 	if ($php_cgi) {
221
-		header("Status: " . $status_string[$status]);
221
+		header("Status: ".$status_string[$status]);
222 222
 	} else {
223
-		header("HTTP/1.0 " . $status_string[$status]);
223
+		header("HTTP/1.0 ".$status_string[$status]);
224 224
 	}
225 225
 }
226 226
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 	header("Content-Type: text/html; charset=$charset");
244 244
 	header("Expires: 0");
245
-	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
245
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
246 246
 	header("Cache-Control: no-cache, must-revalidate");
247 247
 	header("Pragma: no-cache");
248 248
 }
Please login to merge, or discard this patch.
ecrire/base/upgrade.php 2 patches
Indentation   +329 added lines, -329 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  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
 if (!defined('_UPGRADE_TIME_OUT')) {
24
-	/**
25
-	 * Durée en secondes pour relancer les scripts de mises à jour, x secondes
26
-	 * avant que la durée d'exécution du script provoque un timeout
27
-	 *
28
-	 * @var int
29
-	 **/
30
-	define('_UPGRADE_TIME_OUT', 20);
24
+    /**
25
+     * Durée en secondes pour relancer les scripts de mises à jour, x secondes
26
+     * avant que la durée d'exécution du script provoque un timeout
27
+     *
28
+     * @var int
29
+     **/
30
+    define('_UPGRADE_TIME_OUT', 20);
31 31
 }
32 32
 
33 33
 /**
@@ -50,40 +50,40 @@  discard block
 block discarded – undo
50 50
  * @return void
51 51
  */
52 52
 function base_upgrade_dist($titre = '', $reprise = '') {
53
-	if (!$titre) {
54
-		return;
55
-	} // anti-testeur automatique
56
-	if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
57
-		if (!is_numeric(_request('reinstall'))) {
58
-			include_spip('base/create');
59
-			spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE);
60
-			creer_base();
61
-		}
62
-
63
-		// quand on rentre par ici, c'est toujours une mise a jour de SPIP
64
-		// lancement de l'upgrade SPIP
65
-		$res = maj_base();
66
-
67
-		if ($res) {
68
-			// on arrete tout ici !
69
-			exit;
70
-		}
71
-	}
72
-	spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE);
73
-
74
-	// supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
75
-	@spip_unlink(_CACHE_RUBRIQUES);
76
-	@spip_unlink(_CACHE_PIPELINES);
77
-	@spip_unlink(_CACHE_PLUGINS_PATH);
78
-	@spip_unlink(_CACHE_PLUGINS_OPT);
79
-	@spip_unlink(_CACHE_PLUGINS_FCT);
80
-	@spip_unlink(_CACHE_CHEMIN);
81
-	@spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz');
82
-
83
-	include_spip('inc/auth');
84
-	auth_synchroniser_distant();
85
-	$config = charger_fonction('config', 'inc');
86
-	$config();
53
+    if (!$titre) {
54
+        return;
55
+    } // anti-testeur automatique
56
+    if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
57
+        if (!is_numeric(_request('reinstall'))) {
58
+            include_spip('base/create');
59
+            spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE);
60
+            creer_base();
61
+        }
62
+
63
+        // quand on rentre par ici, c'est toujours une mise a jour de SPIP
64
+        // lancement de l'upgrade SPIP
65
+        $res = maj_base();
66
+
67
+        if ($res) {
68
+            // on arrete tout ici !
69
+            exit;
70
+        }
71
+    }
72
+    spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE);
73
+
74
+    // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
75
+    @spip_unlink(_CACHE_RUBRIQUES);
76
+    @spip_unlink(_CACHE_PIPELINES);
77
+    @spip_unlink(_CACHE_PLUGINS_PATH);
78
+    @spip_unlink(_CACHE_PLUGINS_OPT);
79
+    @spip_unlink(_CACHE_PLUGINS_FCT);
80
+    @spip_unlink(_CACHE_CHEMIN);
81
+    @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz');
82
+
83
+    include_spip('inc/auth');
84
+    auth_synchroniser_distant();
85
+    $config = charger_fonction('config', 'inc');
86
+    $config();
87 87
 }
88 88
 
89 89
 /**
@@ -104,80 +104,80 @@  discard block
 block discarded – undo
104 104
  */
105 105
 function maj_base($version_cible = 0, $redirect = '', $debut_page = true) {
106 106
 
107
-	$version_installee = @$GLOBALS['meta']['version_installee'];
108
-	//
109
-	// Si version nulle ou inexistante, c'est une nouvelle installation
110
-	//   => ne pas passer par le processus de mise a jour.
111
-	// De meme en cas de version superieure: ca devait etre un test,
112
-	// il y a eu le message d'avertissement il doit savoir ce qu'il fait
113
-	//
114
-	// version_installee = 1.702; quand on a besoin de forcer une MAJ
115
-
116
-	spip_log(
117
-		"Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'],
118
-		'maj.' . _LOG_INFO_IMPORTANTE
119
-	);
120
-	if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
121
-		sql_replace(
122
-			'spip_meta',
123
-			array(
124
-				'nom' => 'version_installee',
125
-				'valeur' => $GLOBALS['spip_version_base'],
126
-				'impt' => 'non'
127
-			)
128
-		);
129
-		return false;
130
-	}
131
-	if (!upgrade_test()) {
132
-		return true;
133
-	}
134
-
135
-	$cible = ($version_cible ? $version_cible : $GLOBALS['spip_version_base']);
136
-
137
-	if ($version_installee <= 1.926) {
138
-		$n = floor($version_installee * 10);
139
-		while ($n < 19) {
140
-			$nom = sprintf('v%03d', $n);
141
-			$f = charger_fonction($nom, 'maj/legacy', true);
142
-			if ($f) {
143
-				spip_log("$f repercute les modifications de la version " . ($n / 10), 'maj.' . _LOG_INFO_IMPORTANTE);
144
-				$f($version_installee, $GLOBALS['spip_version_base']);
145
-			} else {
146
-				spip_log("pas de fonction pour la maj $n $nom", 'maj.' . _LOG_INFO_IMPORTANTE);
147
-			}
148
-			$n++;
149
-		}
150
-		include_spip('maj/legacy/v019_pre193');
151
-		maj_legacy_v019_pre193($version_installee, $version_cible);
152
-	}
153
-	if ($version_installee < 2000) {
154
-		if ($version_installee < 2) {
155
-			$version_installee = $version_installee * 1000;
156
-		}
157
-		include_spip('maj/legacy/v019');
158
-	}
159
-	if ($cible < 2) {
160
-		$cible = $cible * 1000;
161
-	}
162
-
163
-	if ($version_installee < 2021010100) {
164
-		include_spip('maj/legacy/svn10000');
165
-	}
166
-
167
-	include_spip('maj/2021');
168
-
169
-	ksort($GLOBALS['maj']);
170
-	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page);
171
-	if ($res) {
172
-		if (!is_array($res)) {
173
-			spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
174
-		} else {
175
-			echo _T('avis_operation_echec') . ' ' . join(' ', $res);
176
-			echo install_fin_html();
177
-		}
178
-	}
179
-
180
-	return $res;
107
+    $version_installee = @$GLOBALS['meta']['version_installee'];
108
+    //
109
+    // Si version nulle ou inexistante, c'est une nouvelle installation
110
+    //   => ne pas passer par le processus de mise a jour.
111
+    // De meme en cas de version superieure: ca devait etre un test,
112
+    // il y a eu le message d'avertissement il doit savoir ce qu'il fait
113
+    //
114
+    // version_installee = 1.702; quand on a besoin de forcer une MAJ
115
+
116
+    spip_log(
117
+        "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'],
118
+        'maj.' . _LOG_INFO_IMPORTANTE
119
+    );
120
+    if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
121
+        sql_replace(
122
+            'spip_meta',
123
+            array(
124
+                'nom' => 'version_installee',
125
+                'valeur' => $GLOBALS['spip_version_base'],
126
+                'impt' => 'non'
127
+            )
128
+        );
129
+        return false;
130
+    }
131
+    if (!upgrade_test()) {
132
+        return true;
133
+    }
134
+
135
+    $cible = ($version_cible ? $version_cible : $GLOBALS['spip_version_base']);
136
+
137
+    if ($version_installee <= 1.926) {
138
+        $n = floor($version_installee * 10);
139
+        while ($n < 19) {
140
+            $nom = sprintf('v%03d', $n);
141
+            $f = charger_fonction($nom, 'maj/legacy', true);
142
+            if ($f) {
143
+                spip_log("$f repercute les modifications de la version " . ($n / 10), 'maj.' . _LOG_INFO_IMPORTANTE);
144
+                $f($version_installee, $GLOBALS['spip_version_base']);
145
+            } else {
146
+                spip_log("pas de fonction pour la maj $n $nom", 'maj.' . _LOG_INFO_IMPORTANTE);
147
+            }
148
+            $n++;
149
+        }
150
+        include_spip('maj/legacy/v019_pre193');
151
+        maj_legacy_v019_pre193($version_installee, $version_cible);
152
+    }
153
+    if ($version_installee < 2000) {
154
+        if ($version_installee < 2) {
155
+            $version_installee = $version_installee * 1000;
156
+        }
157
+        include_spip('maj/legacy/v019');
158
+    }
159
+    if ($cible < 2) {
160
+        $cible = $cible * 1000;
161
+    }
162
+
163
+    if ($version_installee < 2021010100) {
164
+        include_spip('maj/legacy/svn10000');
165
+    }
166
+
167
+    include_spip('maj/2021');
168
+
169
+    ksort($GLOBALS['maj']);
170
+    $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page);
171
+    if ($res) {
172
+        if (!is_array($res)) {
173
+            spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
174
+        } else {
175
+            echo _T('avis_operation_echec') . ' ' . join(' ', $res);
176
+            echo install_fin_html();
177
+        }
178
+    }
179
+
180
+    return $res;
181 181
 }
182 182
 
183 183
 /**
@@ -219,52 +219,52 @@  discard block
 block discarded – undo
219 219
  */
220 220
 function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') {
221 221
 
222
-	if ($table_meta !== 'meta') {
223
-		installer_table_meta($table_meta);
224
-	}
225
-
226
-	$current_version = null;
227
-
228
-	if ((!isset($GLOBALS[$table_meta][$nom_meta_base_version]))
229
-		|| (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '='))
230
-	) {
231
-		// $maj['create'] contient les directives propres a la premiere creation de base
232
-		// c'est une operation derogatoire qui fait aboutir directement dans la version_cible
233
-		if (isset($maj['create'])) {
234
-			if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) {
235
-				// installation : on ne fait que l'operation create
236
-				$maj = array('init' => $maj['create']);
237
-				// et on lui ajoute un appel a inc/config
238
-				// pour creer les metas par defaut
239
-				$config = charger_fonction('config', 'inc');
240
-				$maj[$version_cible] = array(array($config));
241
-			}
242
-			// dans tous les cas enlever cet index du tableau
243
-			unset($maj['create']);
244
-		}
245
-		// si init, deja dans le bon ordre
246
-		if (!isset($maj['init'])) {
247
-			include_spip('inc/plugin'); // pour spip_version_compare
248
-			uksort($maj, 'spip_version_compare');
249
-		}
250
-
251
-		// la redirection se fait par defaut sur la page d'administration des plugins
252
-		// sauf lorsque nous sommes sur l'installation de SPIP
253
-		// ou define _REDIRECT_MAJ_PLUGIN
254
-		$redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin'));
255
-		if (defined('_ECRIRE_INSTALL')) {
256
-			$redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape'));
257
-		}
258
-
259
-		$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
260
-		if ($res) {
261
-			if (!is_array($res)) {
262
-				spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
263
-			} else {
264
-				echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>';
265
-			}
266
-		}
267
-	}
222
+    if ($table_meta !== 'meta') {
223
+        installer_table_meta($table_meta);
224
+    }
225
+
226
+    $current_version = null;
227
+
228
+    if ((!isset($GLOBALS[$table_meta][$nom_meta_base_version]))
229
+        || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '='))
230
+    ) {
231
+        // $maj['create'] contient les directives propres a la premiere creation de base
232
+        // c'est une operation derogatoire qui fait aboutir directement dans la version_cible
233
+        if (isset($maj['create'])) {
234
+            if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) {
235
+                // installation : on ne fait que l'operation create
236
+                $maj = array('init' => $maj['create']);
237
+                // et on lui ajoute un appel a inc/config
238
+                // pour creer les metas par defaut
239
+                $config = charger_fonction('config', 'inc');
240
+                $maj[$version_cible] = array(array($config));
241
+            }
242
+            // dans tous les cas enlever cet index du tableau
243
+            unset($maj['create']);
244
+        }
245
+        // si init, deja dans le bon ordre
246
+        if (!isset($maj['init'])) {
247
+            include_spip('inc/plugin'); // pour spip_version_compare
248
+            uksort($maj, 'spip_version_compare');
249
+        }
250
+
251
+        // la redirection se fait par defaut sur la page d'administration des plugins
252
+        // sauf lorsque nous sommes sur l'installation de SPIP
253
+        // ou define _REDIRECT_MAJ_PLUGIN
254
+        $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin'));
255
+        if (defined('_ECRIRE_INSTALL')) {
256
+            $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape'));
257
+        }
258
+
259
+        $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
260
+        if ($res) {
261
+            if (!is_array($res)) {
262
+                spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
263
+            } else {
264
+                echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>';
265
+            }
266
+        }
267
+    }
268 268
 }
269 269
 
270 270
 /**
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
  * @return void
282 282
  */
283 283
 function relance_maj($meta, $table, $redirect = '') {
284
-	include_spip('inc/headers');
285
-	if (!$redirect) {
286
-		// recuperer la valeur installee en cours
287
-		// on la tronque numeriquement, elle ne sert pas reellement
288
-		// sauf pour verifier que ce n'est pas oui ou non
289
-		// sinon is_numeric va echouer sur un numero de version 1.2.3
290
-		$installee = intval($GLOBALS[$table][$meta]);
291
-		$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
292
-	}
293
-	echo redirige_formulaire($redirect);
294
-	exit();
284
+    include_spip('inc/headers');
285
+    if (!$redirect) {
286
+        // recuperer la valeur installee en cours
287
+        // on la tronque numeriquement, elle ne sert pas reellement
288
+        // sauf pour verifier que ce n'est pas oui ou non
289
+        // sinon is_numeric va echouer sur un numero de version 1.2.3
290
+        $installee = intval($GLOBALS[$table][$meta]);
291
+        $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
292
+    }
293
+    echo redirige_formulaire($redirect);
294
+    exit();
295 295
 }
296 296
 
297 297
 /**
@@ -304,26 +304,26 @@  discard block
 block discarded – undo
304 304
  * @return void
305 305
  */
306 306
 function maj_debut_page($installee, $meta, $table) {
307
-	static $done = false;
308
-	if ($done) {
309
-		return;
310
-	}
311
-	include_spip('inc/minipres');
312
-	@ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure
313
-	$timeout = _UPGRADE_TIME_OUT * 2;
314
-	$titre = _T('titre_page_upgrade');
315
-	$balise_img = charger_filtre('balise_img');
316
-	$titre .= $balise_img(chemin_image('loader.svg'),'','loader');
317
-	echo(install_debut_html($titre));
318
-	// script de rechargement auto sur timeout
319
-	$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
320
-	echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')');
321
-	echo "<div style='text-align: left'>\n";
322
-	if (ob_get_level()) {
323
-		ob_flush();
324
-	}
325
-	flush();
326
-	$done = true;
307
+    static $done = false;
308
+    if ($done) {
309
+        return;
310
+    }
311
+    include_spip('inc/minipres');
312
+    @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure
313
+    $timeout = _UPGRADE_TIME_OUT * 2;
314
+    $titre = _T('titre_page_upgrade');
315
+    $balise_img = charger_filtre('balise_img');
316
+    $titre .= $balise_img(chemin_image('loader.svg'),'','loader');
317
+    echo(install_debut_html($titre));
318
+    // script de rechargement auto sur timeout
319
+    $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
320
+    echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')');
321
+    echo "<div style='text-align: left'>\n";
322
+    if (ob_get_level()) {
323
+        ob_flush();
324
+    }
325
+    flush();
326
+    $done = true;
327 327
 }
328 328
 
329 329
 
@@ -367,63 +367,63 @@  discard block
 block discarded – undo
367 367
  *    - tableau vide sinon.
368 368
  */
369 369
 function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false) {
370
-	# inclusions pour que les procedures d'upgrade disposent des fonctions de base
371
-	include_spip('base/create');
372
-	include_spip('base/abstract_sql');
373
-	$trouver_table = charger_fonction('trouver_table', 'base');
374
-	include_spip('inc/plugin'); // pour spip_version_compare
375
-	$n = 0;
376
-	$time = time();
377
-
378
-	if (!defined('_TIME_OUT')) {
379
-		/**
380
-		 * Définir le timeout qui peut-être utilisé dans les fonctions
381
-		 * de mises à jour qui durent trop longtemps
382
-		 *
383
-		 * À utiliser tel que : `if (time() >= _TIME_OUT)`
384
-		 *
385
-		 * @var int
386
-		 */
387
-		define('_TIME_OUT', $time + _UPGRADE_TIME_OUT);
388
-	}
389
-
390
-	foreach ($maj as $v => $operations) {
391
-		// si une maj pour cette version
392
-		if ($v == 'init' or
393
-			(spip_version_compare($v, $installee, '>')
394
-				and spip_version_compare($v, $cible, '<='))
395
-		) {
396
-			if ($debut_page) {
397
-				maj_debut_page($v, $meta, $table);
398
-			}
399
-			echo "MAJ $v";
400
-			$etape = serie_alter($v, $operations, $meta, $table, $redirect);
401
-			$trouver_table(''); // vider le cache des descriptions de table
402
-			# echec sur une etape en cours ?
403
-			# on sort
404
-			if ($etape) {
405
-				return array($v, $etape);
406
-			}
407
-			$n = time() - $time;
408
-			spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE);
409
-			if ($meta) {
410
-				ecrire_meta($meta, $installee = $v, 'oui', $table);
411
-			}
412
-			echo '<br />';
413
-		}
414
-		if (time() >= _TIME_OUT) {
415
-			relance_maj($meta, $table, $redirect);
416
-		}
417
-	}
418
-	$trouver_table(''); // vider le cache des descriptions de table
419
-	// indispensable pour les chgt de versions qui n'ecrivent pas en base
420
-	// tant pis pour la redondance eventuelle avec ci-dessus
421
-	if ($meta) {
422
-		ecrire_meta($meta, $cible, 'oui', $table);
423
-	}
424
-	spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE);
425
-
426
-	return array();
370
+    # inclusions pour que les procedures d'upgrade disposent des fonctions de base
371
+    include_spip('base/create');
372
+    include_spip('base/abstract_sql');
373
+    $trouver_table = charger_fonction('trouver_table', 'base');
374
+    include_spip('inc/plugin'); // pour spip_version_compare
375
+    $n = 0;
376
+    $time = time();
377
+
378
+    if (!defined('_TIME_OUT')) {
379
+        /**
380
+         * Définir le timeout qui peut-être utilisé dans les fonctions
381
+         * de mises à jour qui durent trop longtemps
382
+         *
383
+         * À utiliser tel que : `if (time() >= _TIME_OUT)`
384
+         *
385
+         * @var int
386
+         */
387
+        define('_TIME_OUT', $time + _UPGRADE_TIME_OUT);
388
+    }
389
+
390
+    foreach ($maj as $v => $operations) {
391
+        // si une maj pour cette version
392
+        if ($v == 'init' or
393
+            (spip_version_compare($v, $installee, '>')
394
+                and spip_version_compare($v, $cible, '<='))
395
+        ) {
396
+            if ($debut_page) {
397
+                maj_debut_page($v, $meta, $table);
398
+            }
399
+            echo "MAJ $v";
400
+            $etape = serie_alter($v, $operations, $meta, $table, $redirect);
401
+            $trouver_table(''); // vider le cache des descriptions de table
402
+            # echec sur une etape en cours ?
403
+            # on sort
404
+            if ($etape) {
405
+                return array($v, $etape);
406
+            }
407
+            $n = time() - $time;
408
+            spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE);
409
+            if ($meta) {
410
+                ecrire_meta($meta, $installee = $v, 'oui', $table);
411
+            }
412
+            echo '<br />';
413
+        }
414
+        if (time() >= _TIME_OUT) {
415
+            relance_maj($meta, $table, $redirect);
416
+        }
417
+    }
418
+    $trouver_table(''); // vider le cache des descriptions de table
419
+    // indispensable pour les chgt de versions qui n'ecrivent pas en base
420
+    // tant pis pour la redondance eventuelle avec ci-dessus
421
+    if ($meta) {
422
+        ecrire_meta($meta, $cible, 'oui', $table);
423
+    }
424
+    spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE);
425
+
426
+    return array();
427 427
 }
428 428
 
429 429
 /**
@@ -446,52 +446,52 @@  discard block
 block discarded – undo
446 446
  * @return int
447 447
  */
448 448
 function serie_alter($serie, $q = array(), $meta = '', $table = 'meta', $redirect = '') {
449
-	$meta2 = $meta . '_maj_' . $serie;
450
-	$etape = 0;
451
-	if (isset($GLOBALS[$table][$meta2])) {
452
-		$etape = intval($GLOBALS[$table][$meta2]);
453
-	}
454
-	foreach ($q as $i => $r) {
455
-		if ($i >= $etape) {
456
-			$msg = "maj $table $meta2 etape $i";
457
-			if (is_array($r)
458
-				and function_exists($f = array_shift($r))
459
-			) {
460
-				// note: $r (arguments de la fonction $f) peut avoir des données tabulaires
461
-				spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE);
462
-				// pour les fonctions atomiques sql_xx
463
-				// on enregistre le meta avant de lancer la fonction,
464
-				// de maniere a eviter de boucler sur timeout
465
-				// mais pour les fonctions complexes,
466
-				// il faut les rejouer jusqu'a achevement.
467
-				// C'est a elle d'assurer qu'elles progressent a chaque rappel
468
-				if (strncmp($f, 'sql_', 4) == 0) {
469
-					ecrire_meta($meta2, $i + 1, 'non', $table);
470
-				}
471
-				echo " <span title='$i'>.</span>";
472
-				call_user_func_array($f, $r);
473
-				// si temps imparti depasse, on relance sans ecrire en meta
474
-				// car on est peut etre sorti sur timeout si c'est une fonction longue
475
-				if (time() >= _TIME_OUT) {
476
-					relance_maj($meta, $table, $redirect);
477
-				}
478
-				ecrire_meta($meta2, $i + 1, 'non', $table);
479
-				spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE);
480
-			} else {
481
-				if (!is_array($r)) {
482
-					spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR);
483
-				} else {
484
-					spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR);
485
-				}
486
-				// en cas d'erreur serieuse, on s'arrete
487
-				// mais on permet de passer par dessus en rechargeant la page.
488
-				return $i + 1;
489
-			}
490
-		}
491
-	}
492
-	effacer_meta($meta2, $table);
493
-
494
-	return 0;
449
+    $meta2 = $meta . '_maj_' . $serie;
450
+    $etape = 0;
451
+    if (isset($GLOBALS[$table][$meta2])) {
452
+        $etape = intval($GLOBALS[$table][$meta2]);
453
+    }
454
+    foreach ($q as $i => $r) {
455
+        if ($i >= $etape) {
456
+            $msg = "maj $table $meta2 etape $i";
457
+            if (is_array($r)
458
+                and function_exists($f = array_shift($r))
459
+            ) {
460
+                // note: $r (arguments de la fonction $f) peut avoir des données tabulaires
461
+                spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE);
462
+                // pour les fonctions atomiques sql_xx
463
+                // on enregistre le meta avant de lancer la fonction,
464
+                // de maniere a eviter de boucler sur timeout
465
+                // mais pour les fonctions complexes,
466
+                // il faut les rejouer jusqu'a achevement.
467
+                // C'est a elle d'assurer qu'elles progressent a chaque rappel
468
+                if (strncmp($f, 'sql_', 4) == 0) {
469
+                    ecrire_meta($meta2, $i + 1, 'non', $table);
470
+                }
471
+                echo " <span title='$i'>.</span>";
472
+                call_user_func_array($f, $r);
473
+                // si temps imparti depasse, on relance sans ecrire en meta
474
+                // car on est peut etre sorti sur timeout si c'est une fonction longue
475
+                if (time() >= _TIME_OUT) {
476
+                    relance_maj($meta, $table, $redirect);
477
+                }
478
+                ecrire_meta($meta2, $i + 1, 'non', $table);
479
+                spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE);
480
+            } else {
481
+                if (!is_array($r)) {
482
+                    spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR);
483
+                } else {
484
+                    spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR);
485
+                }
486
+                // en cas d'erreur serieuse, on s'arrete
487
+                // mais on permet de passer par dessus en rechargeant la page.
488
+                return $i + 1;
489
+            }
490
+        }
491
+    }
492
+    effacer_meta($meta2, $table);
493
+
494
+    return 0;
495 495
 }
496 496
 
497 497
 
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
  *
513 513
  **/
514 514
 function upgrade_types_documents() {
515
-	if (include_spip('base/medias')
516
-		and function_exists('creer_base_types_doc')
517
-	) {
518
-		creer_base_types_doc();
519
-	}
515
+    if (include_spip('base/medias')
516
+        and function_exists('creer_base_types_doc')
517
+    ) {
518
+        creer_base_types_doc();
519
+    }
520 520
 }
521 521
 
522 522
 /**
@@ -525,18 +525,18 @@  discard block
 block discarded – undo
525 525
  * @return bool True si possible.
526 526
  **/
527 527
 function upgrade_test() {
528
-	sql_drop_table('spip_test', true);
529
-	sql_create('spip_test', array('a' => 'int'));
530
-	sql_alter('TABLE spip_test ADD b INT');
531
-	sql_insertq('spip_test', array('b' => 1), array('field' => array('b' => 'int')));
532
-	$result = sql_select('b', 'spip_test');
533
-	// ne pas garder le resultat de la requete sinon sqlite3
534
-	// ne peut pas supprimer la table spip_test lors du sql_alter qui suit
535
-	// car cette table serait alors 'verouillee'
536
-	$result = $result ? true : false;
537
-	sql_alter('TABLE spip_test DROP b');
538
-
539
-	return $result;
528
+    sql_drop_table('spip_test', true);
529
+    sql_create('spip_test', array('a' => 'int'));
530
+    sql_alter('TABLE spip_test ADD b INT');
531
+    sql_insertq('spip_test', array('b' => 1), array('field' => array('b' => 'int')));
532
+    $result = sql_select('b', 'spip_test');
533
+    // ne pas garder le resultat de la requete sinon sqlite3
534
+    // ne peut pas supprimer la table spip_test lors du sql_alter qui suit
535
+    // car cette table serait alors 'verouillee'
536
+    $result = $result ? true : false;
537
+    sql_alter('TABLE spip_test DROP b');
538
+
539
+    return $result;
540 540
 }
541 541
 
542 542
 /**
@@ -551,19 +551,19 @@  discard block
 block discarded – undo
551 551
  * @return void
552 552
  **/
553 553
 function maj_version($version, $test = true) {
554
-	if ($test) {
555
-		if ($version >= 1.922) {
556
-			ecrire_meta('version_installee', $version, 'oui');
557
-		} else {
558
-			// on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
559
-			$GLOBALS['meta']['version_installee'] = $version;
560
-			sql_updateq('spip_meta', array('valeur' => $version), 'nom=' . sql_quote('version_installee'));
561
-		}
562
-		spip_log("mise a jour de la base en $version", 'maj.' . _LOG_INFO_IMPORTANTE);
563
-	} else {
564
-		echo _T('alerte_maj_impossible', array('version' => $version));
565
-		exit;
566
-	}
554
+    if ($test) {
555
+        if ($version >= 1.922) {
556
+            ecrire_meta('version_installee', $version, 'oui');
557
+        } else {
558
+            // on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
559
+            $GLOBALS['meta']['version_installee'] = $version;
560
+            sql_updateq('spip_meta', array('valeur' => $version), 'nom=' . sql_quote('version_installee'));
561
+        }
562
+        spip_log("mise a jour de la base en $version", 'maj.' . _LOG_INFO_IMPORTANTE);
563
+    } else {
564
+        echo _T('alerte_maj_impossible', array('version' => $version));
565
+        exit;
566
+    }
567 567
 }
568 568
 
569 569
 /**
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
  * @return bool true si la mise à jour doit se réaliser
580 580
  **/
581 581
 function upgrade_vers($version, $version_installee, $version_cible = 0) {
582
-	return ($version_installee < $version
583
-		and (($version_cible >= $version) or ($version_cible == 0))
584
-	);
582
+    return ($version_installee < $version
583
+        and (($version_cible >= $version) or ($version_cible == 0))
584
+    );
585 585
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
57 57
 		if (!is_numeric(_request('reinstall'))) {
58 58
 			include_spip('base/create');
59
-			spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE);
59
+			spip_log('recree les tables eventuellement disparues', 'maj.'._LOG_INFO_IMPORTANTE);
60 60
 			creer_base();
61 61
 		}
62 62
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			exit;
70 70
 		}
71 71
 	}
72
-	spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE);
72
+	spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.'._LOG_INFO_IMPORTANTE);
73 73
 
74 74
 	// supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
75 75
 	@spip_unlink(_CACHE_RUBRIQUES);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	@spip_unlink(_CACHE_PLUGINS_OPT);
79 79
 	@spip_unlink(_CACHE_PLUGINS_FCT);
80 80
 	@spip_unlink(_CACHE_CHEMIN);
81
-	@spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz');
81
+	@spip_unlink(_DIR_TMP.'plugin_xml_cache.gz');
82 82
 
83 83
 	include_spip('inc/auth');
84 84
 	auth_synchroniser_distant();
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	// version_installee = 1.702; quand on a besoin de forcer une MAJ
115 115
 
116 116
 	spip_log(
117
-		"Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'],
118
-		'maj.' . _LOG_INFO_IMPORTANTE
117
+		"Version anterieure: $version_installee. Courante: ".$GLOBALS['spip_version_base'],
118
+		'maj.'._LOG_INFO_IMPORTANTE
119 119
 	);
120 120
 	if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
121 121
 		sql_replace(
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 			$nom = sprintf('v%03d', $n);
141 141
 			$f = charger_fonction($nom, 'maj/legacy', true);
142 142
 			if ($f) {
143
-				spip_log("$f repercute les modifications de la version " . ($n / 10), 'maj.' . _LOG_INFO_IMPORTANTE);
143
+				spip_log("$f repercute les modifications de la version ".($n / 10), 'maj.'._LOG_INFO_IMPORTANTE);
144 144
 				$f($version_installee, $GLOBALS['spip_version_base']);
145 145
 			} else {
146
-				spip_log("pas de fonction pour la maj $n $nom", 'maj.' . _LOG_INFO_IMPORTANTE);
146
+				spip_log("pas de fonction pour la maj $n $nom", 'maj.'._LOG_INFO_IMPORTANTE);
147 147
 			}
148 148
 			$n++;
149 149
 		}
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page);
171 171
 	if ($res) {
172 172
 		if (!is_array($res)) {
173
-			spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
173
+			spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_INFO_ERREUR);
174 174
 		} else {
175
-			echo _T('avis_operation_echec') . ' ' . join(' ', $res);
175
+			echo _T('avis_operation_echec').' '.join(' ', $res);
176 176
 			echo install_fin_html();
177 177
 		}
178 178
 	}
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 		$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
260 260
 		if ($res) {
261 261
 			if (!is_array($res)) {
262
-				spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
262
+				spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_INFO_ERREUR);
263 263
 			} else {
264
-				echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>';
264
+				echo '<p>'._T('avis_operation_echec').' '.join(' ', $res).'</p>';
265 265
 			}
266 266
 		}
267 267
 	}
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 	$timeout = _UPGRADE_TIME_OUT * 2;
314 314
 	$titre = _T('titre_page_upgrade');
315 315
 	$balise_img = charger_filtre('balise_img');
316
-	$titre .= $balise_img(chemin_image('loader.svg'),'','loader');
316
+	$titre .= $balise_img(chemin_image('loader.svg'), '', 'loader');
317 317
 	echo(install_debut_html($titre));
318 318
 	// script de rechargement auto sur timeout
319 319
 	$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
320
-	echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')');
320
+	echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout * 1000).')');
321 321
 	echo "<div style='text-align: left'>\n";
322 322
 	if (ob_get_level()) {
323 323
 		ob_flush();
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 				return array($v, $etape);
406 406
 			}
407 407
 			$n = time() - $time;
408
-			spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE);
408
+			spip_log("$table $meta: $v en $n secondes", 'maj.'._LOG_INFO_IMPORTANTE);
409 409
 			if ($meta) {
410 410
 				ecrire_meta($meta, $installee = $v, 'oui', $table);
411 411
 			}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	if ($meta) {
422 422
 		ecrire_meta($meta, $cible, 'oui', $table);
423 423
 	}
424
-	spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE);
424
+	spip_log("MAJ terminee. $meta: $installee", 'maj.'._LOG_INFO_IMPORTANTE);
425 425
 
426 426
 	return array();
427 427
 }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
  * @return int
447 447
  */
448 448
 function serie_alter($serie, $q = array(), $meta = '', $table = 'meta', $redirect = '') {
449
-	$meta2 = $meta . '_maj_' . $serie;
449
+	$meta2 = $meta.'_maj_'.$serie;
450 450
 	$etape = 0;
451 451
 	if (isset($GLOBALS[$table][$meta2])) {
452 452
 		$etape = intval($GLOBALS[$table][$meta2]);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 				and function_exists($f = array_shift($r))
459 459
 			) {
460 460
 				// note: $r (arguments de la fonction $f) peut avoir des données tabulaires
461
-				spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE);
461
+				spip_log("$msg: $f ".@join(',', $r), 'maj.'._LOG_INFO_IMPORTANTE);
462 462
 				// pour les fonctions atomiques sql_xx
463 463
 				// on enregistre le meta avant de lancer la fonction,
464 464
 				// de maniere a eviter de boucler sur timeout
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 					relance_maj($meta, $table, $redirect);
477 477
 				}
478 478
 				ecrire_meta($meta2, $i + 1, 'non', $table);
479
-				spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE);
479
+				spip_log("$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE);
480 480
 			} else {
481 481
 				if (!is_array($r)) {
482
-					spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR);
482
+					spip_log("maj $i format incorrect", 'maj.'._LOG_ERREUR);
483 483
 				} else {
484
-					spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR);
484
+					spip_log("maj $i fonction $f non definie", 'maj.'._LOG_ERREUR);
485 485
 				}
486 486
 				// en cas d'erreur serieuse, on s'arrete
487 487
 				// mais on permet de passer par dessus en rechargeant la page.
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
 		} else {
558 558
 			// on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
559 559
 			$GLOBALS['meta']['version_installee'] = $version;
560
-			sql_updateq('spip_meta', array('valeur' => $version), 'nom=' . sql_quote('version_installee'));
560
+			sql_updateq('spip_meta', array('valeur' => $version), 'nom='.sql_quote('version_installee'));
561 561
 		}
562
-		spip_log("mise a jour de la base en $version", 'maj.' . _LOG_INFO_IMPORTANTE);
562
+		spip_log("mise a jour de la base en $version", 'maj.'._LOG_INFO_IMPORTANTE);
563 563
 	} else {
564 564
 		echo _T('alerte_maj_impossible', array('version' => $version));
565 565
 		exit;
Please login to merge, or discard this patch.
prive/formulaires/configurer_preferences.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  **/
22 22
 
23 23
 if (!defined('_ECRIRE_INC_VERSION')) {
24
-	return;
24
+    return;
25 25
 }
26 26
 
27 27
 /**
@@ -31,28 +31,28 @@  discard block
 block discarded – undo
31 31
  *     Environnement du formulaire
32 32
  **/
33 33
 function formulaires_configurer_preferences_charger_dist() {
34
-	// travailler sur des meta fraiches
35
-	include_spip('inc/meta');
36
-	lire_metas();
34
+    // travailler sur des meta fraiches
35
+    include_spip('inc/meta');
36
+    lire_metas();
37 37
 
38
-	$valeurs = array();
39
-	$valeurs['display_navigation'] = isset($GLOBALS['visiteur_session']['prefs']['display_navigation']) ? $GLOBALS['visiteur_session']['prefs']['display_navigation'] : 'navigation_avec_icones';
40
-	$valeurs['display_outils'] = isset($GLOBALS['visiteur_session']['prefs']['display_outils']) ? $GLOBALS['visiteur_session']['prefs']['display_outils'] : 'oui';
41
-	$valeurs['display'] = (isset($GLOBALS['visiteur_session']['prefs']['display']) and $GLOBALS['visiteur_session']['prefs']['display'] > 0) ? $GLOBALS['visiteur_session']['prefs']['display'] : 2;
42
-	$valeurs['couleur'] = (isset($GLOBALS['visiteur_session']['prefs']['couleur']) and $GLOBALS['visiteur_session']['prefs']['couleur'] > 0) ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 1;
38
+    $valeurs = array();
39
+    $valeurs['display_navigation'] = isset($GLOBALS['visiteur_session']['prefs']['display_navigation']) ? $GLOBALS['visiteur_session']['prefs']['display_navigation'] : 'navigation_avec_icones';
40
+    $valeurs['display_outils'] = isset($GLOBALS['visiteur_session']['prefs']['display_outils']) ? $GLOBALS['visiteur_session']['prefs']['display_outils'] : 'oui';
41
+    $valeurs['display'] = (isset($GLOBALS['visiteur_session']['prefs']['display']) and $GLOBALS['visiteur_session']['prefs']['display'] > 0) ? $GLOBALS['visiteur_session']['prefs']['display'] : 2;
42
+    $valeurs['couleur'] = (isset($GLOBALS['visiteur_session']['prefs']['couleur']) and $GLOBALS['visiteur_session']['prefs']['couleur'] > 0) ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 1;
43 43
 
44
-	$couleurs = charger_fonction('couleurs', 'inc');
45
-	$les_couleurs = $couleurs();
46
-	foreach ($les_couleurs as $k => $c) {
47
-		$valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr='
48
-			. $GLOBALS['spip_lang_left'] . '&'
49
-			. $couleurs($k));
50
-		$valeurs['couleurs'][$k] = $c;
51
-	}
44
+    $couleurs = charger_fonction('couleurs', 'inc');
45
+    $les_couleurs = $couleurs();
46
+    foreach ($les_couleurs as $k => $c) {
47
+        $valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr='
48
+            . $GLOBALS['spip_lang_left'] . '&'
49
+            . $couleurs($k));
50
+        $valeurs['couleurs'][$k] = $c;
51
+    }
52 52
 
53
-	$valeurs['imessage'] = $GLOBALS['visiteur_session']['imessage'];
53
+    $valeurs['imessage'] = $GLOBALS['visiteur_session']['imessage'];
54 54
 
55
-	return $valeurs;
55
+    return $valeurs;
56 56
 }
57 57
 
58 58
 /**
@@ -63,34 +63,34 @@  discard block
 block discarded – undo
63 63
  **/
64 64
 function formulaires_configurer_preferences_traiter_dist() {
65 65
 
66
-	if ($couleur = _request('couleur')) {
67
-		$couleurs = charger_fonction('couleurs', 'inc');
68
-		$les_couleurs = $couleurs(array(), true);
69
-		if (isset($les_couleurs[$couleur])) {
70
-			$GLOBALS['visiteur_session']['prefs']['couleur'] = $couleur;
71
-		}
72
-	}
73
-	if ($display = intval(_request('display'))) {
74
-		$GLOBALS['visiteur_session']['prefs']['display'] = $display;
75
-	}
76
-	if ($display_navigation = _request('display_navigation')
77
-		and in_array($display_navigation, ['navigation_sans_icone', 'navigation_avec_icones'])) {
78
-		$GLOBALS['visiteur_session']['prefs']['display_navigation'] = $display_navigation;
79
-	}
80
-	if (!is_null($display_outils = _request('display_outils'))) {
81
-		$GLOBALS['visiteur_session']['prefs']['display_outils'] = ($display_outils ? 'oui' : '');
82
-	}
66
+    if ($couleur = _request('couleur')) {
67
+        $couleurs = charger_fonction('couleurs', 'inc');
68
+        $les_couleurs = $couleurs(array(), true);
69
+        if (isset($les_couleurs[$couleur])) {
70
+            $GLOBALS['visiteur_session']['prefs']['couleur'] = $couleur;
71
+        }
72
+    }
73
+    if ($display = intval(_request('display'))) {
74
+        $GLOBALS['visiteur_session']['prefs']['display'] = $display;
75
+    }
76
+    if ($display_navigation = _request('display_navigation')
77
+        and in_array($display_navigation, ['navigation_sans_icone', 'navigation_avec_icones'])) {
78
+        $GLOBALS['visiteur_session']['prefs']['display_navigation'] = $display_navigation;
79
+    }
80
+    if (!is_null($display_outils = _request('display_outils'))) {
81
+        $GLOBALS['visiteur_session']['prefs']['display_outils'] = ($display_outils ? 'oui' : '');
82
+    }
83 83
 
84
-	if (intval($GLOBALS['visiteur_session']['id_auteur'])) {
85
-		include_spip('action/editer_auteur');
86
-		$c = array('prefs' => serialize($GLOBALS['visiteur_session']['prefs']));
84
+    if (intval($GLOBALS['visiteur_session']['id_auteur'])) {
85
+        include_spip('action/editer_auteur');
86
+        $c = array('prefs' => serialize($GLOBALS['visiteur_session']['prefs']));
87 87
 
88
-		if ($imessage = _request('imessage') and in_array($imessage, ['oui', 'non'])) {
89
-			$c['imessage'] = $imessage;
90
-		}
88
+        if ($imessage = _request('imessage') and in_array($imessage, ['oui', 'non'])) {
89
+            $c['imessage'] = $imessage;
90
+        }
91 91
 
92
-		auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c);
93
-	}
92
+        auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c);
93
+    }
94 94
 
95
-	return array('message_ok' => _T('config_info_enregistree'), 'editable' => true);
95
+    return array('message_ok' => _T('config_info_enregistree'), 'editable' => true);
96 96
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 	$les_couleurs = $couleurs();
46 46
 	foreach ($les_couleurs as $k => $c) {
47 47
 		$valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr='
48
-			. $GLOBALS['spip_lang_left'] . '&'
48
+			. $GLOBALS['spip_lang_left'].'&'
49 49
 			. $couleurs($k));
50 50
 		$valeurs['couleurs'][$k] = $c;
51 51
 	}
Please login to merge, or discard this patch.
ecrire/inc/couleurs.php 2 patches
Indentation   +59 added lines, -59 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
 /**
@@ -38,66 +38,66 @@  discard block
 block discarded – undo
38 38
  * @return array|string
39 39
  */
40 40
 function inc_couleurs_dist($choix = null, $ajouter = false) {
41
-	static $couleurs_spip = array(
42
-		// Saumon
43
-		4 => ["couleur_theme" => "#cda261"], 
44
-		// Orange
45
-		3 => ["couleur_theme" => "#fa9a00"],
46
-		// Rouge
47
-		8 => ["couleur_theme" => "#df4543"],
48
-		// Framboise
49
-		2 => ["couleur_theme" =>  "#d51b60"],
50
-		// Vert de gris
51
-		7 => ["couleur_theme" => "#999966"],
52
-		// Vert
53
-		1 => ["couleur_theme" => "#9dba00"],
54
-		//  Bleu pastel
55
-		5 => ["couleur_theme" => "#5da7c5"],
56
-		// Violet
57
-		9 => ["couleur_theme" => "#8f8fbd"],
58
-		//  Gris
59
-		6 => ["couleur_theme" => "#85909a"],
60
-		//  Gris
61
-		10 => ["couleur_theme" => "#909090"],
62
-	);
41
+    static $couleurs_spip = array(
42
+        // Saumon
43
+        4 => ["couleur_theme" => "#cda261"], 
44
+        // Orange
45
+        3 => ["couleur_theme" => "#fa9a00"],
46
+        // Rouge
47
+        8 => ["couleur_theme" => "#df4543"],
48
+        // Framboise
49
+        2 => ["couleur_theme" =>  "#d51b60"],
50
+        // Vert de gris
51
+        7 => ["couleur_theme" => "#999966"],
52
+        // Vert
53
+        1 => ["couleur_theme" => "#9dba00"],
54
+        //  Bleu pastel
55
+        5 => ["couleur_theme" => "#5da7c5"],
56
+        // Violet
57
+        9 => ["couleur_theme" => "#8f8fbd"],
58
+        //  Gris
59
+        6 => ["couleur_theme" => "#85909a"],
60
+        //  Gris
61
+        10 => ["couleur_theme" => "#909090"],
62
+    );
63 63
 
64
-	if (is_numeric($choix)) {
65
-		$c = $couleurs_spip[$choix];
66
-		// compat < SPIP 3.3
67
-		include_spip('inc/filtres_images_mini');
68
-		$c["couleur_foncee"] = $c["couleur_theme"];
69
-		$c["couleur_claire"] = '#' . couleur_eclaircir($c["couleur_theme"], .5);
64
+    if (is_numeric($choix)) {
65
+        $c = $couleurs_spip[$choix];
66
+        // compat < SPIP 3.3
67
+        include_spip('inc/filtres_images_mini');
68
+        $c["couleur_foncee"] = $c["couleur_theme"];
69
+        $c["couleur_claire"] = '#' . couleur_eclaircir($c["couleur_theme"], .5);
70 70
 
71
-		return
72
-			'couleur_theme=' . substr($c['couleur_theme'], 1)
73
-			// compat < SPIP 3.3
74
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
75
-			. '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
76
-	} else {
77
-		if (is_array($choix)) {
78
-			// compat < SPIP 3.3
79
-			$compat_spip_33 = function($c) {
80
-				if (!isset($c["couleur_theme"])) {
81
-					$c["couleur_theme"] = $c["couleur_foncee"];
82
-					unset($c["couleur_foncee"]);
83
-					unset($c["couleur_claire"]);
84
-					unset($c["couleur_lien"]);
85
-					unset($c["couleur_lien_off"]);
86
-				}
87
-				return $c;
88
-			};
89
-			if ($ajouter) {
90
-				foreach ($choix as $c) {
91
-					$couleurs_spip[] = $compat_spip_33($c);
92
-				}
71
+        return
72
+            'couleur_theme=' . substr($c['couleur_theme'], 1)
73
+            // compat < SPIP 3.3
74
+            . '&couleur_claire=' . substr($c['couleur_claire'], 1)
75
+            . '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
76
+    } else {
77
+        if (is_array($choix)) {
78
+            // compat < SPIP 3.3
79
+            $compat_spip_33 = function($c) {
80
+                if (!isset($c["couleur_theme"])) {
81
+                    $c["couleur_theme"] = $c["couleur_foncee"];
82
+                    unset($c["couleur_foncee"]);
83
+                    unset($c["couleur_claire"]);
84
+                    unset($c["couleur_lien"]);
85
+                    unset($c["couleur_lien_off"]);
86
+                }
87
+                return $c;
88
+            };
89
+            if ($ajouter) {
90
+                foreach ($choix as $c) {
91
+                    $couleurs_spip[] = $compat_spip_33($c);
92
+                }
93 93
 
94
-				return $couleurs_spip;
95
-			} else {
96
-				$choix = array_map($compat_spip_33, $choix);
97
-				return $couleurs_spip = $choix;
98
-			}
99
-		}
100
-	}
94
+                return $couleurs_spip;
95
+            } else {
96
+                $choix = array_map($compat_spip_33, $choix);
97
+                return $couleurs_spip = $choix;
98
+            }
99
+        }
100
+    }
101 101
 
102
-	return $couleurs_spip;
102
+    return $couleurs_spip;
103 103
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@
 block discarded – undo
66 66
 		// compat < SPIP 3.3
67 67
 		include_spip('inc/filtres_images_mini');
68 68
 		$c["couleur_foncee"] = $c["couleur_theme"];
69
-		$c["couleur_claire"] = '#' . couleur_eclaircir($c["couleur_theme"], .5);
69
+		$c["couleur_claire"] = '#'.couleur_eclaircir($c["couleur_theme"], .5);
70 70
 
71 71
 		return
72
-			'couleur_theme=' . substr($c['couleur_theme'], 1)
72
+			'couleur_theme='.substr($c['couleur_theme'], 1)
73 73
 			// compat < SPIP 3.3
74
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
75
-			. '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
74
+			. '&couleur_claire='.substr($c['couleur_claire'], 1)
75
+			. '&couleur_foncee='.substr($c['couleur_foncee'], 1);
76 76
 	} else {
77 77
 		if (is_array($choix)) {
78 78
 			// compat < SPIP 3.3
Please login to merge, or discard this patch.