Completed
Pull Request — master (#36)
by
unknown
06:08
created
ecrire/balise/logo_.php 1 patch
Indentation   +115 added lines, -115 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
 
@@ -54,84 +54,84 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function balise_LOGO__dist($p) {
56 56
 
57
-	preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs);
58
-	$type = strtolower($regs[1]);
59
-	$suite_logo = $regs[2];
60
-
61
-	// cas de #LOGO_SITE_SPIP
62
-	if ($type == 'site_spip') {
63
-		$type = 'site';
64
-		$_id_objet = "\"'0'\"";
65
-	}
66
-
67
-	$id_objet = id_table_objet($type);
68
-	if (!isset($_id_objet)) {
69
-		$_id_objet = champ_sql($id_objet, $p);
70
-	}
71
-
72
-	$fichier = ($p->etoile === '**') ? -1 : 0;
73
-	$coord = array();
74
-	$align = $lien = '';
75
-	$mode_logo = '';
76
-
77
-	if ($p->param and !$p->param[0][0]) {
78
-		$params = $p->param[0];
79
-		array_shift($params);
80
-		foreach ($params as $a) {
81
-			if ($a[0]->type === 'texte') {
82
-				$n = $a[0]->texte;
83
-				if (is_numeric($n)) {
84
-					$coord[] = $n;
85
-				} elseif (in_array($n, array('top', 'left', 'right', 'center', 'bottom'))) {
86
-					$align = $n;
87
-				} elseif (in_array($n, array('auto', 'icone', 'apercu', 'vignette'))) {
88
-					$mode_logo = $n;
89
-				}
90
-			} else {
91
-				$lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
92
-			}
93
-		}
94
-	}
95
-
96
-	$coord_x = !$coord ? 0 : intval(array_shift($coord));
97
-	$coord_y = !$coord ? 0 : intval(array_shift($coord));
98
-
99
-	if ($p->etoile === '*') {
100
-		include_spip('balise/url_');
101
-		$lien = generer_generer_url_arg($type, $p, $_id_objet);
102
-	}
103
-
104
-	$connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : '';
105
-	if ($type == 'document') {
106
-		$qconnect = _q($connect);
107
-		$doc = "quete_document($_id_objet, $qconnect)";
108
-		if ($fichier) {
109
-			$code = "quete_logo_file($doc, $qconnect)";
110
-		} else {
111
-			$code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
112
-		}
113
-		// (x=non-faux ? y : '') pour affecter x en retournant y
114
-		if ($p->descr['documents']) {
115
-			$code = '(($doublons["documents"] .= ",". '
116
-				. $_id_objet
117
-				. ") ? $code : '')";
118
-		}
119
-	} elseif ($connect) {
120
-		$code = "''";
121
-		spip_log('Les logos distants ne sont pas prevus');
122
-	} else {
123
-		$code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
124
-	}
125
-
126
-	// demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
127
-	if ($coord_x or $coord_y) {
128
-		$code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))";
129
-	}
130
-
131
-	$p->code = $code;
132
-	$p->interdire_scripts = false;
133
-
134
-	return $p;
57
+    preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs);
58
+    $type = strtolower($regs[1]);
59
+    $suite_logo = $regs[2];
60
+
61
+    // cas de #LOGO_SITE_SPIP
62
+    if ($type == 'site_spip') {
63
+        $type = 'site';
64
+        $_id_objet = "\"'0'\"";
65
+    }
66
+
67
+    $id_objet = id_table_objet($type);
68
+    if (!isset($_id_objet)) {
69
+        $_id_objet = champ_sql($id_objet, $p);
70
+    }
71
+
72
+    $fichier = ($p->etoile === '**') ? -1 : 0;
73
+    $coord = array();
74
+    $align = $lien = '';
75
+    $mode_logo = '';
76
+
77
+    if ($p->param and !$p->param[0][0]) {
78
+        $params = $p->param[0];
79
+        array_shift($params);
80
+        foreach ($params as $a) {
81
+            if ($a[0]->type === 'texte') {
82
+                $n = $a[0]->texte;
83
+                if (is_numeric($n)) {
84
+                    $coord[] = $n;
85
+                } elseif (in_array($n, array('top', 'left', 'right', 'center', 'bottom'))) {
86
+                    $align = $n;
87
+                } elseif (in_array($n, array('auto', 'icone', 'apercu', 'vignette'))) {
88
+                    $mode_logo = $n;
89
+                }
90
+            } else {
91
+                $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
92
+            }
93
+        }
94
+    }
95
+
96
+    $coord_x = !$coord ? 0 : intval(array_shift($coord));
97
+    $coord_y = !$coord ? 0 : intval(array_shift($coord));
98
+
99
+    if ($p->etoile === '*') {
100
+        include_spip('balise/url_');
101
+        $lien = generer_generer_url_arg($type, $p, $_id_objet);
102
+    }
103
+
104
+    $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : '';
105
+    if ($type == 'document') {
106
+        $qconnect = _q($connect);
107
+        $doc = "quete_document($_id_objet, $qconnect)";
108
+        if ($fichier) {
109
+            $code = "quete_logo_file($doc, $qconnect)";
110
+        } else {
111
+            $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
112
+        }
113
+        // (x=non-faux ? y : '') pour affecter x en retournant y
114
+        if ($p->descr['documents']) {
115
+            $code = '(($doublons["documents"] .= ",". '
116
+                . $_id_objet
117
+                . ") ? $code : '')";
118
+        }
119
+    } elseif ($connect) {
120
+        $code = "''";
121
+        spip_log('Les logos distants ne sont pas prevus');
122
+    } else {
123
+        $code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
124
+    }
125
+
126
+    // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
127
+    if ($coord_x or $coord_y) {
128
+        $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))";
129
+    }
130
+
131
+    $p->code = $code;
132
+    $p->interdire_scripts = false;
133
+
134
+    return $p;
135 135
 }
136 136
 
137 137
 /**
@@ -158,41 +158,41 @@  discard block
 block discarded – undo
158 158
  *     Code compilé retournant le chemin du logo ou le code HTML du logo.
159 159
  **/
160 160
 function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite) {
161
-	$code = "quete_logo('$id_objet', '" .
162
-		(($suite == '_SURVOL') ? 'off' :
163
-			(($suite == '_NORMAL') ? 'on' : 'ON')) .
164
-		"', $_id_objet," .
165
-		(($suite == '_RUBRIQUE') ?
166
-			champ_sql('id_rubrique', $p) :
167
-			(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
168
-		', ' . intval($fichier) . ')';
169
-
170
-	if ($fichier) {
171
-		return $code;
172
-	}
173
-
174
-	// class spip_logos a supprimer ulterieurement (transition douce vers spip_logo)
175
-	// cf http://core.spip.net/issues/2483
176
-	$class = 'spip_logo ';
177
-	if ($align) {
178
-		$class .= "spip_logo_$align ";
179
-	}
180
-	$class .= 'spip_logos';
181
-	$style = '';
182
-	if (in_array($align, array('left', 'right'))) {
183
-		$style = "float:$align";
184
-		$align = '';
185
-	}
186
-	$code = "\n((!is_array(\$l = $code)) ? '':\n (" .
187
-		'"<img class=\"' . $class . '\" alt=\"\"' .
188
-		($style ? " style=\\\"$style\\\"" : '') .
189
-		($align ? " align=\\\"$align\\\"" : '') .
190
-		' src=\"$l[0]\"" . $l[2] .  ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))';
191
-
192
-	if (!$lien) {
193
-		return $code;
194
-	}
195
-
196
-	return ('(strlen($logo=' . $code . ')?\'<a href="\' .' . $lien . ' . \'">\' . $logo . \'</a>\':\'\')');
161
+    $code = "quete_logo('$id_objet', '" .
162
+        (($suite == '_SURVOL') ? 'off' :
163
+            (($suite == '_NORMAL') ? 'on' : 'ON')) .
164
+        "', $_id_objet," .
165
+        (($suite == '_RUBRIQUE') ?
166
+            champ_sql('id_rubrique', $p) :
167
+            (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
168
+        ', ' . intval($fichier) . ')';
169
+
170
+    if ($fichier) {
171
+        return $code;
172
+    }
173
+
174
+    // class spip_logos a supprimer ulterieurement (transition douce vers spip_logo)
175
+    // cf http://core.spip.net/issues/2483
176
+    $class = 'spip_logo ';
177
+    if ($align) {
178
+        $class .= "spip_logo_$align ";
179
+    }
180
+    $class .= 'spip_logos';
181
+    $style = '';
182
+    if (in_array($align, array('left', 'right'))) {
183
+        $style = "float:$align";
184
+        $align = '';
185
+    }
186
+    $code = "\n((!is_array(\$l = $code)) ? '':\n (" .
187
+        '"<img class=\"' . $class . '\" alt=\"\"' .
188
+        ($style ? " style=\\\"$style\\\"" : '') .
189
+        ($align ? " align=\\\"$align\\\"" : '') .
190
+        ' src=\"$l[0]\"" . $l[2] .  ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))';
191
+
192
+    if (!$lien) {
193
+        return $code;
194
+    }
195
+
196
+    return ('(strlen($logo=' . $code . ')?\'<a href="\' .' . $lien . ' . \'">\' . $logo . \'</a>\':\'\')');
197 197
 
198 198
 }
Please login to merge, or discard this patch.
ecrire/balise/url_.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  **/
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 /**
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
  *     Code compilé
38 38
  **/
39 39
 function generer_generer_url($type, $p) {
40
-	$_id = interprete_argument_balise(1, $p);
40
+    $_id = interprete_argument_balise(1, $p);
41 41
 
42
-	if (!$_id) {
43
-		$primary = id_table_objet($type);
44
-		$_id = champ_sql($primary, $p);
45
-	}
42
+    if (!$_id) {
43
+        $primary = id_table_objet($type);
44
+        $_id = champ_sql($primary, $p);
45
+    }
46 46
 
47
-	return generer_generer_url_arg($type, $p, $_id);
47
+    return generer_generer_url_arg($type, $p, $_id);
48 48
 }
49 49
 
50 50
 /**
@@ -73,29 +73,29 @@  discard block
 block discarded – undo
73 73
  *     Code compilé
74 74
  **/
75 75
 function generer_generer_url_arg($type, $p, $_id) {
76
-	if ($s = trouver_nom_serveur_distant($p)) {
77
-
78
-		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
79
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
80
-			return $f($type, $_id, $s);
81
-		}
82
-		if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
83
-			return null;
84
-		}
85
-		$s = _q($s);
86
-		# exception des urls de documents sur un serveur distant...
87
-		if ($type == 'document') {
88
-			return
89
-				"quete_meta('adresse_site', $s) . '/' .\n\t" .
90
-				"quete_meta('dir_img', $s) . \n\t" .
91
-				"quete_fichier($_id,$s)";
92
-		}
93
-		$s = ", '', '', $s, quete_meta('type_urls', $s)";
94
-	} else {
95
-		$s = ", '', '', true";
96
-	}
97
-
98
-	return "urlencode_1738(generer_url_entite($_id, '$type'$s))";
76
+    if ($s = trouver_nom_serveur_distant($p)) {
77
+
78
+        // si une fonction de generation des url a ete definie pour ce connect l'utiliser
79
+        if (function_exists($f = 'generer_generer_url_' . $s)) {
80
+            return $f($type, $_id, $s);
81
+        }
82
+        if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
83
+            return null;
84
+        }
85
+        $s = _q($s);
86
+        # exception des urls de documents sur un serveur distant...
87
+        if ($type == 'document') {
88
+            return
89
+                "quete_meta('adresse_site', $s) . '/' .\n\t" .
90
+                "quete_meta('dir_img', $s) . \n\t" .
91
+                "quete_fichier($_id,$s)";
92
+        }
93
+        $s = ", '', '', $s, quete_meta('type_urls', $s)";
94
+    } else {
95
+        $s = ", '', '', true";
96
+    }
97
+
98
+    return "urlencode_1738(generer_url_entite($_id, '$type'$s))";
99 99
 }
100 100
 
101 101
 
@@ -120,27 +120,27 @@  discard block
 block discarded – undo
120 120
  */
121 121
 function balise_URL__dist($p) {
122 122
 
123
-	$nom = $p->nom_champ;
124
-	if ($nom === 'URL_') {
125
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' URL_'));
126
-		erreur_squelette($msg, $p);
127
-		$p->interdire_scripts = false;
128
-
129
-		return $p;
130
-	} elseif ($f = charger_fonction($nom, 'balise', true)) {
131
-		return $f($p);
132
-	} else {
133
-		$nom = strtolower($nom);
134
-		$code = generer_generer_url(substr($nom, 4), $p);
135
-		$code = champ_sql($nom, $p, $code);
136
-		$p->code = $code;
137
-		if (!$p->etoile) {
138
-			$p->code = "vider_url($code)";
139
-		}
140
-		$p->interdire_scripts = false;
141
-
142
-		return $p;
143
-	}
123
+    $nom = $p->nom_champ;
124
+    if ($nom === 'URL_') {
125
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' URL_'));
126
+        erreur_squelette($msg, $p);
127
+        $p->interdire_scripts = false;
128
+
129
+        return $p;
130
+    } elseif ($f = charger_fonction($nom, 'balise', true)) {
131
+        return $f($p);
132
+    } else {
133
+        $nom = strtolower($nom);
134
+        $code = generer_generer_url(substr($nom, 4), $p);
135
+        $code = champ_sql($nom, $p, $code);
136
+        $p->code = $code;
137
+        if (!$p->etoile) {
138
+            $p->code = "vider_url($code)";
139
+        }
140
+        $p->interdire_scripts = false;
141
+
142
+        return $p;
143
+    }
144 144
 }
145 145
 
146 146
 /**
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
  */
165 165
 function balise_URL_ARTICLE_dist($p) {
166 166
 
167
-	// Cas particulier des boucles (SYNDIC_ARTICLES)
168
-	if ($p->type_requete == 'syndic_articles') {
169
-		$code = champ_sql('url', $p);
170
-	} else {
171
-		$code = generer_generer_url('article', $p);
172
-	}
167
+    // Cas particulier des boucles (SYNDIC_ARTICLES)
168
+    if ($p->type_requete == 'syndic_articles') {
169
+        $code = champ_sql('url', $p);
170
+    } else {
171
+        $code = generer_generer_url('article', $p);
172
+    }
173 173
 
174
-	$p->code = $code;
175
-	if (!$p->etoile) {
176
-		$p->code = "vider_url($code)";
177
-	}
178
-	$p->interdire_scripts = false;
174
+    $p->code = $code;
175
+    if (!$p->etoile) {
176
+        $p->code = "vider_url($code)";
177
+    }
178
+    $p->interdire_scripts = false;
179 179
 
180
-	return $p;
180
+    return $p;
181 181
 }
182 182
 
183 183
 /**
@@ -197,21 +197,21 @@  discard block
 block discarded – undo
197 197
  *     Pile complétée par le code à générer
198 198
  */
199 199
 function balise_URL_SITE_dist($p) {
200
-	$code = champ_sql('url_site', $p);
201
-	if (strpos($code, '@$Pile[0]') !== false) {
202
-		$code = generer_generer_url('site', $p);
203
-		if ($code === null) {
204
-			return null;
205
-		}
206
-	} else {
207
-		if (!$p->etoile) {
208
-			$code = "calculer_url($code,'','url', \$connect)";
209
-		}
210
-	}
211
-	$p->code = $code;
212
-	$p->interdire_scripts = false;
213
-
214
-	return $p;
200
+    $code = champ_sql('url_site', $p);
201
+    if (strpos($code, '@$Pile[0]') !== false) {
202
+        $code = generer_generer_url('site', $p);
203
+        if ($code === null) {
204
+            return null;
205
+        }
206
+    } else {
207
+        if (!$p->etoile) {
208
+            $code = "calculer_url($code,'','url', \$connect)";
209
+        }
210
+    }
211
+    $p->code = $code;
212
+    $p->interdire_scripts = false;
213
+
214
+    return $p;
215 215
 }
216 216
 
217 217
 // Autres balises URL_*, qui ne concernent pas une table
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
  *     Pile complétée par le code à générer
231 231
  */
232 232
 function balise_URL_SITE_SPIP_dist($p) {
233
-	$p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
234
-	$p->code = "spip_htmlspecialchars(" . $p->code . ")";
235
-	$p->interdire_scripts = false;
233
+    $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
234
+    $p->code = "spip_htmlspecialchars(" . $p->code . ")";
235
+    $p->interdire_scripts = false;
236 236
 
237
-	return $p;
237
+    return $p;
238 238
 }
239 239
 
240 240
 
@@ -263,42 +263,42 @@  discard block
 block discarded – undo
263 263
  */
264 264
 function balise_URL_PAGE_dist($p) {
265 265
 
266
-	$code = interprete_argument_balise(1, $p);
267
-	$args = interprete_argument_balise(2, $p);
268
-	if ($args == null) {
269
-		$args = "''";
270
-	}
271
-
272
-	if ($s = trouver_nom_serveur_distant($p)) {
273
-		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
274
-		// elle devra aussi traiter le cas derogatoire type=page
275
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
276
-			if ($args and $args !== "''") {
277
-				$code .= ", $args";
278
-			}
279
-			$code = $f('page', $code, $s);
280
-
281
-			return $p;
282
-		}
283
-		$s = 'connect=' . addslashes($s);
284
-		$args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
285
-	}
286
-
287
-	if (!$code) {
288
-		$noentities = $p->etoile ? "'&'" : '';
289
-		$code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
290
-	} else {
291
-		if (!$args) {
292
-			$args = "''";
293
-		}
294
-		$noentities = $p->etoile ? ", true" : '';
295
-		$code = "generer_url_public($code, $args$noentities)";
296
-	}
297
-	$p->code = $code;
298
-	spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
299
-
300
-	#$p->interdire_scripts = true;
301
-	return $p;
266
+    $code = interprete_argument_balise(1, $p);
267
+    $args = interprete_argument_balise(2, $p);
268
+    if ($args == null) {
269
+        $args = "''";
270
+    }
271
+
272
+    if ($s = trouver_nom_serveur_distant($p)) {
273
+        // si une fonction de generation des url a ete definie pour ce connect l'utiliser
274
+        // elle devra aussi traiter le cas derogatoire type=page
275
+        if (function_exists($f = 'generer_generer_url_' . $s)) {
276
+            if ($args and $args !== "''") {
277
+                $code .= ", $args";
278
+            }
279
+            $code = $f('page', $code, $s);
280
+
281
+            return $p;
282
+        }
283
+        $s = 'connect=' . addslashes($s);
284
+        $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
285
+    }
286
+
287
+    if (!$code) {
288
+        $noentities = $p->etoile ? "'&'" : '';
289
+        $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
290
+    } else {
291
+        if (!$args) {
292
+            $args = "''";
293
+        }
294
+        $noentities = $p->etoile ? ", true" : '';
295
+        $code = "generer_url_public($code, $args$noentities)";
296
+    }
297
+    $p->code = $code;
298
+    spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
299
+
300
+    #$p->interdire_scripts = true;
301
+    return $p;
302 302
 }
303 303
 
304 304
 
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
  */
326 326
 function balise_URL_ECRIRE_dist($p) {
327 327
 
328
-	$code = interprete_argument_balise(1, $p);
329
-	if (!$code) {
330
-		$fonc = "''";
331
-	} else {
332
-		$fonc = $code;
333
-		$args = interprete_argument_balise(2, $p);
334
-		if ($args === null) {
335
-			$args = "''";
336
-		}
337
-		$noentities = $p->etoile ? ", true" : '';
338
-		if (($args != "''") or $noentities) {
339
-			$fonc .= ",$args$noentities";
340
-		}
341
-	}
342
-	$p->code = 'generer_url_ecrire(' . $fonc . ')';
343
-	$p->interdire_scripts = false;
344
-
345
-	return $p;
328
+    $code = interprete_argument_balise(1, $p);
329
+    if (!$code) {
330
+        $fonc = "''";
331
+    } else {
332
+        $fonc = $code;
333
+        $args = interprete_argument_balise(2, $p);
334
+        if ($args === null) {
335
+            $args = "''";
336
+        }
337
+        $noentities = $p->etoile ? ", true" : '';
338
+        if (($args != "''") or $noentities) {
339
+            $fonc .= ",$args$noentities";
340
+        }
341
+    }
342
+    $p->code = 'generer_url_ecrire(' . $fonc . ')';
343
+    $p->interdire_scripts = false;
344
+
345
+    return $p;
346 346
 }
347 347
 
348 348
 
@@ -368,23 +368,23 @@  discard block
 block discarded – undo
368 368
  *     Pile complétée par le code à générer
369 369
  */
370 370
 function balise_URL_ACTION_AUTEUR_dist($p) {
371
-	$p->descr['session'] = true;
372
-
373
-	$p->code = interprete_argument_balise(1, $p);
374
-	$args = interprete_argument_balise(2, $p);
375
-	if ($args != "''" && $args !== null) {
376
-		$p->code .= "," . $args;
377
-	}
378
-	$redirect = interprete_argument_balise(3, $p);
379
-	if ($redirect != "''" && $redirect !== null) {
380
-		if ($args == "''" || $args === null) {
381
-			$p->code .= ",''";
382
-		}
383
-		$p->code .= "," . $redirect;
384
-	}
385
-
386
-	$p->code = "generer_action_auteur(" . $p->code . ")";
387
-	$p->interdire_scripts = false;
388
-
389
-	return $p;
371
+    $p->descr['session'] = true;
372
+
373
+    $p->code = interprete_argument_balise(1, $p);
374
+    $args = interprete_argument_balise(2, $p);
375
+    if ($args != "''" && $args !== null) {
376
+        $p->code .= "," . $args;
377
+    }
378
+    $redirect = interprete_argument_balise(3, $p);
379
+    if ($redirect != "''" && $redirect !== null) {
380
+        if ($args == "''" || $args === null) {
381
+            $p->code .= ",''";
382
+        }
383
+        $p->code .= "," . $redirect;
384
+    }
385
+
386
+    $p->code = "generer_action_auteur(" . $p->code . ")";
387
+    $p->interdire_scripts = false;
388
+
389
+    return $p;
390 390
 }
Please login to merge, or discard this patch.
ecrire/balise/menu_lang.php 1 patch
Indentation   +8 added lines, -8 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
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
  *     Pile complétée du code compilé
38 38
  **/
39 39
 function balise_MENU_LANG($p) {
40
-	return calculer_balise_dynamique($p, 'MENU_LANG', array('lang'));
40
+    return calculer_balise_dynamique($p, 'MENU_LANG', array('lang'));
41 41
 }
42 42
 
43 43
 /**
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
  *   Liste (lang) des arguments collectés et fournis.
56 56
  */
57 57
 function balise_MENU_LANG_stat($args, $context_compil) {
58
-	if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) {
59
-		return '';
60
-	}
58
+    if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) {
59
+        return '';
60
+    }
61 61
 
62
-	return $args;
62
+    return $args;
63 63
 }
64 64
 
65 65
 /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
  *     Liste : Chemin du squelette, durée du cache, contexte
76 76
  **/
77 77
 function balise_MENU_LANG_dyn($opt) {
78
-	include_spip('balise/menu_lang_ecrire');
78
+    include_spip('balise/menu_lang_ecrire');
79 79
 
80
-	return menu_lang_pour_tous('var_lang', $opt);
80
+    return menu_lang_pour_tous('var_lang', $opt);
81 81
 }
Please login to merge, or discard this patch.
ecrire/balise/formulaire_admin.php 1 patch
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *     Pile complétée du code compilé
43 43
  **/
44 44
 function balise_FORMULAIRE_ADMIN($p) {
45
-	return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', array());
45
+    return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', array());
46 46
 }
47 47
 
48 48
 /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  *   - chaîne vide sinon.
60 60
  */
61 61
 function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
62
-	return $args;
62
+    return $args;
63 63
 }
64 64
 
65 65
 
@@ -84,66 +84,66 @@  discard block
 block discarded – undo
84 84
  **/
85 85
 function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') {
86 86
 
87
-	static $dejafait = false;
87
+    static $dejafait = false;
88 88
 
89
-	if (!@$_COOKIE['spip_admin']) {
90
-		return '';
91
-	}
89
+    if (!@$_COOKIE['spip_admin']) {
90
+        return '';
91
+    }
92 92
 
93
-	if (!is_array($debug)) {
94
-		if ($dejafait) {
95
-			return '';
96
-		}
97
-	} else {
98
-		if ($dejafait) {
99
-			if (empty($debug['sourcefile'])) {
100
-				return '';
101
-			}
102
-			foreach ($debug['sourcefile'] as $k => $v) {
103
-				if (strpos($v, 'administration.') !== false) {
104
-					if (isset($debug['resultat'][$k . 'tout'])) {
105
-						return $debug['resultat'][$k . 'tout'];
106
-					}
107
-				}
108
-			}
93
+    if (!is_array($debug)) {
94
+        if ($dejafait) {
95
+            return '';
96
+        }
97
+    } else {
98
+        if ($dejafait) {
99
+            if (empty($debug['sourcefile'])) {
100
+                return '';
101
+            }
102
+            foreach ($debug['sourcefile'] as $k => $v) {
103
+                if (strpos($v, 'administration.') !== false) {
104
+                    if (isset($debug['resultat'][$k . 'tout'])) {
105
+                        return $debug['resultat'][$k . 'tout'];
106
+                    }
107
+                }
108
+            }
109 109
 
110
-			return '';
111
-		}
112
-	}
110
+            return '';
111
+        }
112
+    }
113 113
 
114
-	include_spip('inc/autoriser');
115
-	include_spip('base/abstract_sql');
114
+    include_spip('inc/autoriser');
115
+    include_spip('base/abstract_sql');
116 116
 
117 117
 
118
-	$dejafait = true;
118
+    $dejafait = true;
119 119
 
120
-	// Preparer le #ENV des boutons
120
+    // Preparer le #ENV des boutons
121 121
 
122
-	$env = admin_objet();
122
+    $env = admin_objet();
123 123
 
124
-	// Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
-	if (!$env) {
126
-		$env['ecrire'] = _DIR_RESTREINT_ABS;
127
-	}
124
+    // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
+    if (!$env) {
126
+        $env['ecrire'] = _DIR_RESTREINT_ABS;
127
+    }
128 128
 
129
-	$env['divclass'] = $float;
130
-	$env['lang'] = admin_lang();
131
-	$env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
-	$env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? "" : admin_debug());
133
-	$env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
-	$env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
129
+    $env['divclass'] = $float;
130
+    $env['lang'] = admin_lang();
131
+    $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
+    $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? "" : admin_debug());
133
+    $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
+    $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
135 135
 
136
-	if (!$GLOBALS['use_cache']) {
137
-		$env['use_cache'] = ' *';
138
-	}
136
+    if (!$GLOBALS['use_cache']) {
137
+        $env['use_cache'] = ' *';
138
+    }
139 139
 
140
-	if (isset($debug['validation'])) {
141
-		$env['xhtml_error'] = $debug['validation'];
142
-	}
140
+    if (isset($debug['validation'])) {
141
+        $env['xhtml_error'] = $debug['validation'];
142
+    }
143 143
 
144
-	$env['_pipelines']['formulaire_admin'] = array();
144
+    $env['_pipelines']['formulaire_admin'] = array();
145 145
 
146
-	return array('formulaires/administration', 0, $env);
146
+    return array('formulaires/administration', 0, $env);
147 147
 }
148 148
 
149 149
 
@@ -161,45 +161,45 @@  discard block
 block discarded – undo
161 161
  *     Tableau de l'environnement calculé
162 162
  **/
163 163
 function admin_objet() {
164
-	include_spip('inc/urls');
165
-	$env = array();
166
-
167
-	$trouver_table = charger_fonction('trouver_table', 'base');
168
-	$objets = urls_liste_objets(false);
169
-	$objets = array_diff($objets, array('rubrique'));
170
-	$objets = array_reverse($objets);
171
-	array_unshift($objets, 'rubrique');
172
-	foreach ($objets as $obj) {
173
-		$type = $obj;
174
-		if ($type == objet_type($type, false)
175
-			and $_id_type = id_table_objet($type)
176
-			and isset($GLOBALS['contexte'][$_id_type])
177
-			and $id = $GLOBALS['contexte'][$_id_type]
178
-			and !is_array($id)
179
-			and $id = intval($id)
180
-		) {
181
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
182
-			if ($id) {
183
-				$env[$_id_type] = $id;
184
-				$env['objet'] = $type;
185
-				$env['id_objet'] = $id;
186
-				$env['voir_' . $obj] =
187
-					str_replace('&amp;', '&', generer_url_entite($id, $obj, '', '', false));
188
-				if ($desc = $trouver_table(table_objet_sql($type))
189
-					and isset($desc['field']['id_rubrique'])
190
-					and $type != 'rubrique'
191
-				) {
192
-					unset($env['id_rubrique']);
193
-					unset($env['voir_rubrique']);
194
-					if (admin_preview($type, $id, $desc)) {
195
-						$env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
196
-					}
197
-				}
198
-			}
199
-		}
200
-	}
201
-
202
-	return $env;
164
+    include_spip('inc/urls');
165
+    $env = array();
166
+
167
+    $trouver_table = charger_fonction('trouver_table', 'base');
168
+    $objets = urls_liste_objets(false);
169
+    $objets = array_diff($objets, array('rubrique'));
170
+    $objets = array_reverse($objets);
171
+    array_unshift($objets, 'rubrique');
172
+    foreach ($objets as $obj) {
173
+        $type = $obj;
174
+        if ($type == objet_type($type, false)
175
+            and $_id_type = id_table_objet($type)
176
+            and isset($GLOBALS['contexte'][$_id_type])
177
+            and $id = $GLOBALS['contexte'][$_id_type]
178
+            and !is_array($id)
179
+            and $id = intval($id)
180
+        ) {
181
+            $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
182
+            if ($id) {
183
+                $env[$_id_type] = $id;
184
+                $env['objet'] = $type;
185
+                $env['id_objet'] = $id;
186
+                $env['voir_' . $obj] =
187
+                    str_replace('&amp;', '&', generer_url_entite($id, $obj, '', '', false));
188
+                if ($desc = $trouver_table(table_objet_sql($type))
189
+                    and isset($desc['field']['id_rubrique'])
190
+                    and $type != 'rubrique'
191
+                ) {
192
+                    unset($env['id_rubrique']);
193
+                    unset($env['voir_rubrique']);
194
+                    if (admin_preview($type, $id, $desc)) {
195
+                        $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
196
+                    }
197
+                }
198
+            }
199
+        }
200
+    }
201
+
202
+    return $env;
203 203
 }
204 204
 
205 205
 
@@ -217,30 +217,30 @@  discard block
 block discarded – undo
217 217
  *     - Tableau d'un élément sinon.
218 218
  **/
219 219
 function admin_preview($type, $id, $desc = null) {
220
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
221
-		return '';
222
-	}
223
-
224
-	if (!$desc) {
225
-		$trouver_table = charger_fonction('trouver_table', 'base');
226
-		$desc = $trouver_table(table_objet_sql($type));
227
-	}
228
-	if (!$desc or !isset($desc['field']['statut'])) {
229
-		return '';
230
-	}
231
-
232
-	include_spip('inc/autoriser');
233
-	if (!autoriser('previsualiser')) {
234
-		return '';
235
-	}
236
-
237
-	$notpub = sql_in("statut", array('prop', 'prive'));
238
-
239
-	if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
240
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ")";
241
-	}
242
-
243
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . "=" . $id . " AND ($notpub)");
220
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
221
+        return '';
222
+    }
223
+
224
+    if (!$desc) {
225
+        $trouver_table = charger_fonction('trouver_table', 'base');
226
+        $desc = $trouver_table(table_objet_sql($type));
227
+    }
228
+    if (!$desc or !isset($desc['field']['statut'])) {
229
+        return '';
230
+    }
231
+
232
+    include_spip('inc/autoriser');
233
+    if (!autoriser('previsualiser')) {
234
+        return '';
235
+    }
236
+
237
+    $notpub = sql_in("statut", array('prop', 'prive'));
238
+
239
+    if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
240
+        $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ")";
241
+    }
242
+
243
+    return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . "=" . $id . " AND ($notpub)");
244 244
 }
245 245
 
246 246
 
@@ -251,19 +251,19 @@  discard block
 block discarded – undo
251 251
  *     Code de langue
252 252
  **/
253 253
 function admin_lang() {
254
-	$alang = sql_getfetsel('lang', 'spip_auteurs',
255
-		"login=" . sql_quote(preg_replace(',^@,', '', @$_COOKIE['spip_admin'])));
256
-	if (!$alang) {
257
-		return '';
258
-	}
259
-
260
-	$l = lang_select($alang);
261
-	$alang = $GLOBALS['spip_lang'];
262
-	if ($l) {
263
-		lang_select();
264
-	}
265
-
266
-	return $alang;
254
+    $alang = sql_getfetsel('lang', 'spip_auteurs',
255
+        "login=" . sql_quote(preg_replace(',^@,', '', @$_COOKIE['spip_admin'])));
256
+    if (!$alang) {
257
+        return '';
258
+    }
259
+
260
+    $l = lang_select($alang);
261
+    $alang = $GLOBALS['spip_lang'];
262
+    if ($l) {
263
+        lang_select();
264
+    }
265
+
266
+    return $alang;
267 267
 }
268 268
 
269 269
 /**
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
  **/
274 274
 function admin_valider() {
275 275
 
276
-	return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
277
-		(parametre_url(self(), 'var_mode', 'debug', '&')
278
-			. '&var_mode_affiche=validation') :
279
-		('http://validator.w3.org/check?uri='
280
-			. rawurlencode("http://" . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
276
+    return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
277
+        (parametre_url(self(), 'var_mode', 'debug', '&')
278
+            . '&var_mode_affiche=validation') :
279
+        ('http://validator.w3.org/check?uri='
280
+            . rawurlencode("http://" . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
281 281
 }
282 282
 
283 283
 /**
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
  * @return string
287 287
  **/
288 288
 function admin_debug() {
289
-	return ((
290
-			(isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
291
-			or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
292
-			or (
293
-				defined('_VAR_MODE') and _VAR_MODE == 'debug'
294
-				and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
295
-			)
296
-		) and autoriser('debug')
297
-	)
298
-		? parametre_url(self(), 'var_mode', 'debug', '&') : '';
289
+    return ((
290
+            (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
291
+            or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
292
+            or (
293
+                defined('_VAR_MODE') and _VAR_MODE == 'debug'
294
+                and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
295
+            )
296
+        ) and autoriser('debug')
297
+    )
298
+        ? parametre_url(self(), 'var_mode', 'debug', '&') : '';
299 299
 }
Please login to merge, or discard this patch.
ecrire/notifications/instituerarticle.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -8,53 +8,53 @@
 block discarded – undo
8 8
 
9 9
 
10 10
 if (!defined('_ECRIRE_INC_VERSION')) {
11
-	return;
11
+    return;
12 12
 }
13 13
 
14 14
 // Fonction appelee par divers pipelines
15 15
 // http://code.spip.net/@notifications_instituerarticle_dist
16 16
 function notifications_instituerarticle_dist($quoi, $id_article, $options) {
17 17
 
18
-	// ne devrait jamais se produire
19
-	if ($options['statut'] == $options['statut_ancien']) {
20
-		spip_log('statut inchange', 'notifications');
21
-
22
-		return;
23
-	}
24
-
25
-	include_spip('inc/texte');
26
-
27
-	$modele = '';
28
-	if ($options['statut'] == 'publie') {
29
-		if ($GLOBALS['meta']['post_dates'] == 'non'
30
-			and strtotime($options['date']) > time()
31
-		) {
32
-			$modele = 'notifications/article_valide';
33
-		} else {
34
-			$modele = 'notifications/article_publie';
35
-		}
36
-	}
37
-
38
-	if ($options['statut'] == 'prop' and $options['statut_ancien'] != 'publie') {
39
-		$modele = 'notifications/article_propose';
40
-	}
41
-
42
-	if ($modele) {
43
-		$destinataires = array();
44
-		if ($GLOBALS['meta']['suivi_edito'] == 'oui') {
45
-			$destinataires = explode(',', $GLOBALS['meta']['adresse_suivi']);
46
-		}
47
-
48
-
49
-		$destinataires = pipeline(
50
-			'notifications_destinataires',
51
-			array(
52
-				'args' => array('quoi' => $quoi, 'id' => $id_article, 'options' => $options),
53
-				'data' => $destinataires
54
-			)
55
-		);
56
-
57
-		$texte = email_notification_article($id_article, $modele);
58
-		notifications_envoyer_mails($destinataires, $texte);
59
-	}
18
+    // ne devrait jamais se produire
19
+    if ($options['statut'] == $options['statut_ancien']) {
20
+        spip_log('statut inchange', 'notifications');
21
+
22
+        return;
23
+    }
24
+
25
+    include_spip('inc/texte');
26
+
27
+    $modele = '';
28
+    if ($options['statut'] == 'publie') {
29
+        if ($GLOBALS['meta']['post_dates'] == 'non'
30
+            and strtotime($options['date']) > time()
31
+        ) {
32
+            $modele = 'notifications/article_valide';
33
+        } else {
34
+            $modele = 'notifications/article_publie';
35
+        }
36
+    }
37
+
38
+    if ($options['statut'] == 'prop' and $options['statut_ancien'] != 'publie') {
39
+        $modele = 'notifications/article_propose';
40
+    }
41
+
42
+    if ($modele) {
43
+        $destinataires = array();
44
+        if ($GLOBALS['meta']['suivi_edito'] == 'oui') {
45
+            $destinataires = explode(',', $GLOBALS['meta']['adresse_suivi']);
46
+        }
47
+
48
+
49
+        $destinataires = pipeline(
50
+            'notifications_destinataires',
51
+            array(
52
+                'args' => array('quoi' => $quoi, 'id' => $id_article, 'options' => $options),
53
+                'data' => $destinataires
54
+            )
55
+        );
56
+
57
+        $texte = email_notification_article($id_article, $modele);
58
+        notifications_envoyer_mails($destinataires, $texte);
59
+    }
60 60
 }
Please login to merge, or discard this patch.
ecrire/auth/ldap.php 1 patch
Indentation   +175 added lines, -175 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
 // Authentifie via LDAP et retourne la ligne SQL decrivant l'utilisateur si ok
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 // Attributs LDAP correspondants a ceux de SPIP, notamment pour le login
26 26
 // ne pas ecraser une definition perso dans mes_options
27 27
 if (!isset($GLOBALS['ldap_attributes']) or !is_array($GLOBALS['ldap_attributes'])) {
28
-	$GLOBALS['ldap_attributes'] = array(
29
-		'login' => array('sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'),
30
-		'nom' => "cn",
31
-		'email' => "mail",
32
-		'bio' => "description"
33
-	);
28
+    $GLOBALS['ldap_attributes'] = array(
29
+        'login' => array('sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'),
30
+        'nom' => "cn",
31
+        'email' => "mail",
32
+        'bio' => "description"
33
+    );
34 34
 }
35 35
 
36 36
 /**
@@ -56,49 +56,49 @@  discard block
 block discarded – undo
56 56
  */
57 57
 function auth_ldap_dist($login, $pass, $serveur = '', $phpauth = false) {
58 58
 
59
-	#spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent"));
60
-
61
-	// Utilisateur connu ?
62
-	// si http auth, inutile de reauthentifier: cela
63
-	// ne marchera pas avec auth http autre que basic.
64
-	$checkpass = isset($_SERVER["REMOTE_USER"]) ? false : true;
65
-	if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) {
66
-		return array();
67
-	}
68
-	$credentials_ldap = array('ldap_dn' => $dn, 'ldap_password' => $pass);
69
-
70
-	// Si l'utilisateur figure deja dans la base, y recuperer les infos
71
-	$r = sql_fetsel("*", "spip_auteurs", "login=" . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur);
72
-
73
-	if ($r) {
74
-		return array_merge($r, $credentials_ldap);
75
-	}
76
-
77
-	// sinon importer les infos depuis LDAP, 
78
-
79
-	if ($GLOBALS['meta']["ldap_statut_import"]
80
-		and $desc = auth_ldap_retrouver($dn, array(), $serveur)
81
-	) {
82
-		// rajouter le statut indique  a l'install
83
-		$desc['statut'] = $GLOBALS['meta']["ldap_statut_import"];
84
-		$desc['login'] = $login;
85
-		$desc['source'] = 'ldap';
86
-		$desc['pass'] = '';
87
-
88
-		$r = sql_insertq('spip_auteurs', $desc, '', $serveur);
89
-	}
90
-
91
-	if ($r) {
92
-		return array_merge(
93
-			$credentials_ldap,
94
-			sql_fetsel("*", "spip_auteurs", "id_auteur=" . intval($r), '', '', '', '', $serveur)
95
-		);
96
-	}
97
-
98
-	// sinon echec
99
-	spip_log("Creation de l'auteur '$login' impossible");
100
-
101
-	return array();
59
+    #spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent"));
60
+
61
+    // Utilisateur connu ?
62
+    // si http auth, inutile de reauthentifier: cela
63
+    // ne marchera pas avec auth http autre que basic.
64
+    $checkpass = isset($_SERVER["REMOTE_USER"]) ? false : true;
65
+    if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) {
66
+        return array();
67
+    }
68
+    $credentials_ldap = array('ldap_dn' => $dn, 'ldap_password' => $pass);
69
+
70
+    // Si l'utilisateur figure deja dans la base, y recuperer les infos
71
+    $r = sql_fetsel("*", "spip_auteurs", "login=" . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur);
72
+
73
+    if ($r) {
74
+        return array_merge($r, $credentials_ldap);
75
+    }
76
+
77
+    // sinon importer les infos depuis LDAP, 
78
+
79
+    if ($GLOBALS['meta']["ldap_statut_import"]
80
+        and $desc = auth_ldap_retrouver($dn, array(), $serveur)
81
+    ) {
82
+        // rajouter le statut indique  a l'install
83
+        $desc['statut'] = $GLOBALS['meta']["ldap_statut_import"];
84
+        $desc['login'] = $login;
85
+        $desc['source'] = 'ldap';
86
+        $desc['pass'] = '';
87
+
88
+        $r = sql_insertq('spip_auteurs', $desc, '', $serveur);
89
+    }
90
+
91
+    if ($r) {
92
+        return array_merge(
93
+            $credentials_ldap,
94
+            sql_fetsel("*", "spip_auteurs", "id_auteur=" . intval($r), '', '', '', '', $serveur)
95
+        );
96
+    }
97
+
98
+    // sinon echec
99
+    spip_log("Creation de l'auteur '$login' impossible");
100
+
101
+    return array();
102 102
 }
103 103
 
104 104
 /**
@@ -112,36 +112,36 @@  discard block
 block discarded – undo
112 112
  * @return array
113 113
  */
114 114
 function auth_ldap_connect($serveur = '') {
115
-	include_spip('base/connect_sql');
116
-	static $connexions_ldap = array();
117
-	if (isset($connexions_ldap[$serveur])) {
118
-		return $connexions_ldap[$serveur];
119
-	}
120
-	$connexion = spip_connect($serveur);
121
-	if (!is_array($connexion['ldap'])) {
122
-		if ($connexion['authentification']['ldap']) {
123
-			$f = _DIR_CONNECT . $connexion['authentification']['ldap'];
124
-			unset($GLOBALS['ldap_link']);
125
-			if (is_readable($f)) {
126
-				include_once($f);
127
-			};
128
-			if (isset($GLOBALS['ldap_link'])) {
129
-				$connexion['ldap'] = array(
130
-					'link' => $GLOBALS['ldap_link'],
131
-					'base' => $GLOBALS['ldap_base']
132
-				);
133
-			} else {
134
-				spip_log("connection LDAP $serveur mal definie dans $f");
135
-			}
136
-			if (isset($GLOBALS['ldap_champs'])) {
137
-				$connexion['ldap']['attributes'] = $GLOBALS['ldap_champs'];
138
-			}
139
-		} else {
140
-			spip_log("connection LDAP $serveur inconnue");
141
-		}
142
-	}
143
-
144
-	return $connexions_ldap[$serveur] = $connexion['ldap'];
115
+    include_spip('base/connect_sql');
116
+    static $connexions_ldap = array();
117
+    if (isset($connexions_ldap[$serveur])) {
118
+        return $connexions_ldap[$serveur];
119
+    }
120
+    $connexion = spip_connect($serveur);
121
+    if (!is_array($connexion['ldap'])) {
122
+        if ($connexion['authentification']['ldap']) {
123
+            $f = _DIR_CONNECT . $connexion['authentification']['ldap'];
124
+            unset($GLOBALS['ldap_link']);
125
+            if (is_readable($f)) {
126
+                include_once($f);
127
+            };
128
+            if (isset($GLOBALS['ldap_link'])) {
129
+                $connexion['ldap'] = array(
130
+                    'link' => $GLOBALS['ldap_link'],
131
+                    'base' => $GLOBALS['ldap_base']
132
+                );
133
+            } else {
134
+                spip_log("connection LDAP $serveur mal definie dans $f");
135
+            }
136
+            if (isset($GLOBALS['ldap_champs'])) {
137
+                $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs'];
138
+            }
139
+        } else {
140
+            spip_log("connection LDAP $serveur inconnue");
141
+        }
142
+    }
143
+
144
+    return $connexions_ldap[$serveur] = $connexion['ldap'];
145 145
 }
146 146
 
147 147
 /**
@@ -155,52 +155,52 @@  discard block
 block discarded – undo
155 155
  *    Le login trouvé ou chaine vide si non trouvé
156 156
  */
157 157
 function auth_ldap_search($login, $pass, $checkpass = true, $serveur = '') {
158
-	// Securite anti-injection et contre un serveur LDAP laxiste
159
-	$login_search = preg_replace("/[^-@._\s\d\w]/", "", $login);
160
-	if (!strlen($login_search) or ($checkpass and !strlen($pass))) {
161
-		return '';
162
-	}
163
-
164
-	// verifier la connexion
165
-	if (!$ldap = auth_ldap_connect($serveur)) {
166
-		return '';
167
-	}
168
-
169
-	$ldap_link = isset($ldap['link']) ? $ldap['link'] : null;
170
-	$ldap_base = isset($ldap['base']) ? $ldap['base'] : null;
171
-	$desc = isset($ldap['attributes']) && $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'] ;
172
-
173
-	$logins = is_array($desc['login']) ? $desc['login'] : array($desc['login']);
174
-
175
-	// Tenter une recherche pour essayer de retrouver le DN
176
-	foreach ($logins as $att) {
177
-		$result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", array("dn"));
178
-		$info = @ldap_get_entries($ldap_link, $result);
179
-		// Ne pas accepter les resultats si plus d'une entree
180
-		// (on veut un attribut unique)
181
-
182
-		if (is_array($info) and $info['count'] == 1) {
183
-			$dn = $info[0]['dn'];
184
-			if (!$checkpass) {
185
-				return $dn;
186
-			}
187
-			if (@ldap_bind($ldap_link, $dn, $pass)) {
188
-				return $dn;
189
-			}
190
-		}
191
-	}
192
-
193
-	if ($checkpass and !isset($dn)) {
194
-		// Si echec, essayer de deviner le DN
195
-		foreach ($logins as $att) {
196
-			$dn = "$att=$login_search, $ldap_base";
197
-			if (@ldap_bind($ldap_link, $dn, $pass)) {
198
-				return "$att=$login_search, $ldap_base";
199
-			}
200
-		}
201
-	}
202
-
203
-	return '';
158
+    // Securite anti-injection et contre un serveur LDAP laxiste
159
+    $login_search = preg_replace("/[^-@._\s\d\w]/", "", $login);
160
+    if (!strlen($login_search) or ($checkpass and !strlen($pass))) {
161
+        return '';
162
+    }
163
+
164
+    // verifier la connexion
165
+    if (!$ldap = auth_ldap_connect($serveur)) {
166
+        return '';
167
+    }
168
+
169
+    $ldap_link = isset($ldap['link']) ? $ldap['link'] : null;
170
+    $ldap_base = isset($ldap['base']) ? $ldap['base'] : null;
171
+    $desc = isset($ldap['attributes']) && $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'] ;
172
+
173
+    $logins = is_array($desc['login']) ? $desc['login'] : array($desc['login']);
174
+
175
+    // Tenter une recherche pour essayer de retrouver le DN
176
+    foreach ($logins as $att) {
177
+        $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", array("dn"));
178
+        $info = @ldap_get_entries($ldap_link, $result);
179
+        // Ne pas accepter les resultats si plus d'une entree
180
+        // (on veut un attribut unique)
181
+
182
+        if (is_array($info) and $info['count'] == 1) {
183
+            $dn = $info[0]['dn'];
184
+            if (!$checkpass) {
185
+                return $dn;
186
+            }
187
+            if (@ldap_bind($ldap_link, $dn, $pass)) {
188
+                return $dn;
189
+            }
190
+        }
191
+    }
192
+
193
+    if ($checkpass and !isset($dn)) {
194
+        // Si echec, essayer de deviner le DN
195
+        foreach ($logins as $att) {
196
+            $dn = "$att=$login_search, $ldap_base";
197
+            if (@ldap_bind($ldap_link, $dn, $pass)) {
198
+                return "$att=$login_search, $ldap_base";
199
+            }
200
+        }
201
+    }
202
+
203
+    return '';
204 204
 }
205 205
 
206 206
 /**
@@ -212,40 +212,40 @@  discard block
 block discarded – undo
212 212
  * @return array
213 213
  */
214 214
 function auth_ldap_retrouver($dn, $desc = array(), $serveur = '') {
215
-	// Lire les infos sur l'utilisateur a partir de son DN depuis LDAP
215
+    // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP
216 216
 
217
-	if (!$ldap = spip_connect_ldap($serveur)) {
218
-		spip_log("ldap $serveur injoignable");
217
+    if (!$ldap = spip_connect_ldap($serveur)) {
218
+        spip_log("ldap $serveur injoignable");
219 219
 
220
-		return array();
221
-	}
220
+        return array();
221
+    }
222 222
 
223
-	$ldap_link = $ldap['link'];
224
-	if (!$desc) {
225
-		$desc = $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'];
226
-		unset($desc['login']);
227
-	}
228
-	$result = @ldap_read($ldap_link, $dn, "objectClass=*", array_values($desc));
223
+    $ldap_link = $ldap['link'];
224
+    if (!$desc) {
225
+        $desc = $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'];
226
+        unset($desc['login']);
227
+    }
228
+    $result = @ldap_read($ldap_link, $dn, "objectClass=*", array_values($desc));
229 229
 
230
-	if (!$result) {
231
-		return array();
232
-	}
230
+    if (!$result) {
231
+        return array();
232
+    }
233 233
 
234
-	// Recuperer les donnees du premier (unique?) compte de l'auteur
235
-	$val = @ldap_get_entries($ldap_link, $result);
236
-	if (!is_array($val) or !is_array($val[0])) {
237
-		return array();
238
-	}
239
-	$val = $val[0];
234
+    // Recuperer les donnees du premier (unique?) compte de l'auteur
235
+    $val = @ldap_get_entries($ldap_link, $result);
236
+    if (!is_array($val) or !is_array($val[0])) {
237
+        return array();
238
+    }
239
+    $val = $val[0];
240 240
 
241
-	// Convertir depuis UTF-8 (jeu de caracteres par defaut)
242
-	include_spip('inc/charsets');
241
+    // Convertir depuis UTF-8 (jeu de caracteres par defaut)
242
+    include_spip('inc/charsets');
243 243
 
244
-	foreach ($desc as $k => $v) {
245
-		$desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8');
246
-	}
244
+    foreach ($desc as $k => $v) {
245
+        $desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8');
246
+    }
247 247
 
248
-	return $desc;
248
+    return $desc;
249 249
 }
250 250
 
251 251
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
  * @return string
258 258
  */
259 259
 function auth_ldap_retrouver_login($login, $serveur = '') {
260
-	return auth_ldap_search($login, '', false, $serveur) ? $login : '';
260
+    return auth_ldap_search($login, '', false, $serveur) ? $login : '';
261 261
 }
262 262
 
263 263
 /**
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
  *   Message d'erreur si login non valide, chaîne vide sinon
278 278
  */
279 279
 function auth_ldap_verifier_pass($login, $new_pass, $id_auteur = 0, $serveur = '') {
280
-	include_spip('auth/spip');
280
+    include_spip('auth/spip');
281 281
 
282
-	return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur);
282
+    return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur);
283 283
 }
284 284
 
285 285
 /**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
  *   ```
301 301
  */
302 302
 function auth_ldap_autoriser_modifier_pass($serveur = '') {
303
-	return true;
303
+    return true;
304 304
 }
305 305
 
306 306
 /**
@@ -318,23 +318,23 @@  discard block
 block discarded – undo
318 318
  *    Informe du succès ou de l'echec du changement du mot de passe
319 319
  */
320 320
 function auth_ldap_modifier_pass($login, $new_pass, $id_auteur, $serveur = '') {
321
-	if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
322
-		return false;
323
-	}
324
-	if (!$ldap = auth_ldap_connect($serveur)) {
325
-		return '';
326
-	}
327
-	$link = $ldap['link'];
328
-	include_spip("inc/session");
329
-	$dn = session_get('ldap_dn');
330
-	if ('' == $dn) {
331
-		return false;
332
-	}
333
-	if (!ldap_bind($link, $dn, session_get('ldap_password'))) {
334
-		return false;
335
-	}
336
-	$encoded_pass = "{MD5}" . base64_encode(pack("H*", md5($new_pass)));
337
-	$success = ldap_mod_replace($link, $dn, array('userPassword' => $encoded_pass));
338
-
339
-	return $success;
321
+    if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
322
+        return false;
323
+    }
324
+    if (!$ldap = auth_ldap_connect($serveur)) {
325
+        return '';
326
+    }
327
+    $link = $ldap['link'];
328
+    include_spip("inc/session");
329
+    $dn = session_get('ldap_dn');
330
+    if ('' == $dn) {
331
+        return false;
332
+    }
333
+    if (!ldap_bind($link, $dn, session_get('ldap_password'))) {
334
+        return false;
335
+    }
336
+    $encoded_pass = "{MD5}" . base64_encode(pack("H*", md5($new_pass)));
337
+    $success = ldap_mod_replace($link, $dn, array('userPassword' => $encoded_pass));
338
+
339
+    return $success;
340 340
 }
Please login to merge, or discard this patch.
ecrire/auth/sha256.inc.php 1 patch
Indentation   +500 added lines, -500 removed lines patch added patch discarded remove patch
@@ -68,482 +68,482 @@  discard block
 block discarded – undo
68 68
  * @package SPIP\Core\Authentification\Sha256
69 69
  */
70 70
 if (!class_exists('nanoSha2')) {
71
-	/**
72
-	 * Classe de calcul d'un SHA
73
-	 */
74
-	class nanoSha2 {
75
-		// php 4 - 5 compatable class properties
76
-		/** Le résultat doit être passé en majuscule ?
77
-		 *
78
-		 * @var bool
79
-		 */
80
-		var $toUpper;
81
-		/** 32 ou 64 bits ?
82
-		 *
83
-		 * @var int
84
-		 */
85
-		var $platform;
86
-		/** bytes par caractères */
87
-		var $bytesString = 16;
88
-
89
-		/**
90
-		 * Constructor
91
-		 *
92
-		 * @param bool $toUpper
93
-		 */
94
-		function __construct($toUpper = false) {
95
-			// Determine if the caller wants upper case or not.
96
-			$this->toUpper = is_bool($toUpper)
97
-				? $toUpper
98
-				: ((defined('_NANO_SHA2_UPPER')) ? true : false);
99
-
100
-			// Deteremine if the system is 32 or 64 bit.
101
-			$tmpInt = (int)4294967295;
102
-			$this->platform = ($tmpInt > 0) ? 64 : 32;
103
-		}
104
-
105
-		/**
106
-		 * Here are the bitwise and functions as defined in FIPS180-2 Standard
107
-		 *
108
-		 * @param int $x
109
-		 * @param int $y
110
-		 * @param int $n
111
-		 * @return int
112
-		 */
113
-		function addmod2n($x, $y, $n = 4294967296)      // Z = (X + Y) mod 2^32
114
-		{
115
-			$mask = 0x80000000;
116
-
117
-			if ($x < 0) {
118
-				$x &= 0x7FFFFFFF;
119
-				$x = (float)$x+$mask;
120
-			}
121
-
122
-			if ($y < 0) {
123
-				$y &= 0x7FFFFFFF;
124
-				$y = (float)$y+$mask;
125
-			}
126
-
127
-			$r = $x+$y;
128
-
129
-			if ($r >= $n) {
130
-				while ($r >= $n) {
131
-					$r -= $n;
132
-				}
133
-			}
134
-
135
-			return (int)$r;
136
-		}
137
-
138
-		/**
139
-		 * Logical bitwise right shift (PHP default is arithmetic shift)
140
-		 *
141
-		 * @param int $x
142
-		 * @param int $n
143
-		 * return int
144
-		 */
145
-		function SHR($x, $n)        // x >> n
146
-		{
147
-			if ($n >= 32) {      // impose some limits to keep it 32-bit
148
-				return (int)0;
149
-			}
150
-
151
-			if ($n <= 0) {
152
-				return (int)$x;
153
-			}
154
-
155
-			$mask = 0x40000000;
156
-
157
-			if ($x < 0) {
158
-				$x &= 0x7FFFFFFF;
159
-				$mask = $mask >> ($n-1);
160
-
161
-				return ($x >> $n) | $mask;
162
-			}
163
-
164
-			return (int)$x >> (int)$n;
165
-		}
166
-
167
-		/** ROTR
168
-		 *
169
-		 * @param int $x
170
-		 * @param int $n
171
-		 * @return int
172
-		 */
173
-		function ROTR($x, $n) { return (int)(($this->SHR($x, $n) | ($x << (32-$n)) & 0xFFFFFFFF)); }
174
-
175
-		/** Ch
176
-		 *
177
-		 * @param int $x
178
-		 * @param int $y
179
-		 * @param int $z
180
-		 * @return int
181
-		 */
182
-		function Ch($x, $y, $z) { return ($x & $y) ^ ((~$x) & $z); }
183
-
184
-		/** Maj
185
-		 *
186
-		 * @param int $x
187
-		 * @param int $y
188
-		 * @param int $z
189
-		 * @return int
190
-		 */
191
-		function Maj($x, $y, $z) { return ($x & $y) ^ ($x & $z) ^ ($y & $z); }
192
-
193
-		/** Sigma0
194
-		 *
195
-		 * @param int $x
196
-		 * @return int
197
-		 */
198
-		function Sigma0($x) { return (int)($this->ROTR($x, 2) ^ $this->ROTR($x, 13) ^ $this->ROTR($x, 22)); }
199
-
200
-		/** Sigma1
201
-		 *
202
-		 * @param int $x
203
-		 * @return int
204
-		 */
205
-		function Sigma1($x) { return (int)($this->ROTR($x, 6) ^ $this->ROTR($x, 11) ^ $this->ROTR($x, 25)); }
206
-
207
-		/** Sigma_0
208
-		 *
209
-		 * @param int $x
210
-		 * @return int
211
-		 */
212
-		function sigma_0($x) { return (int)($this->ROTR($x, 7) ^ $this->ROTR($x, 18) ^ $this->SHR($x, 3)); }
213
-
214
-		/** Sigma_1
215
-		 *
216
-		 * @param int $x
217
-		 * @return int
218
-		 */
219
-		function sigma_1($x) { return (int)($this->ROTR($x, 17) ^ $this->ROTR($x, 19) ^ $this->SHR($x, 10)); }
220
-
221
-		/** String 2 ord UTF8
222
-		 *
223
-		 * @param string $s
224
-		 * @param int $byteSize
225
-		 * @return array
226
-		 **/
227
-		function string2ordUTF8($s, &$byteSize) {
228
-			$chars = array();
229
-			// par defaut sur 8bits
230
-			$byteSize = 8;
231
-			$i = 0;
232
-			while ($i < strlen($s)) {
233
-				$chars[] = $this->ordUTF8($s, $i, $bytes);
234
-				$i += $bytes;
235
-				// mais si un char necessite 16bits, on passe tout sur 16
236
-				// sinon on ne concorde pas avec le lecture de la chaine en js
237
-				// et le sha256 js
238
-				if ($bytes > 1) {
239
-					$byteSize = 16;
240
-				}
241
-			}
242
-
243
-			return $chars;
244
-		}
245
-
246
-		/** Ord UTF8
247
-		 *
248
-		 * @param string $c
249
-		 * @param int $index
250
-		 * @param int $bytes
251
-		 * @return unknown
252
-		 **/
253
-		function ordUTF8($c, $index = 0, &$bytes) {
254
-			$len = strlen($c);
255
-			$bytes = 0;
256
-
257
-			if ($index >= $len) {
258
-				return false;
259
-			}
260
-
261
-			$h = ord($c{$index});
262
-
263
-			if ($h <= 0x7F) {
264
-				$bytes = 1;
265
-
266
-				return $h;
267
-			} else {
268
-				if ($h < 0xC2) {
269
-					// pas utf mais renvoyer quand meme ce qu'on a
270
-					$bytes = 1;
271
-
272
-					return $h;
273
-				} else {
274
-					if ($h <= 0xDF && $index < $len-1) {
275
-						$bytes = 2;
276
-
277
-						return ($h & 0x1F) << 6 | (ord($c{$index+1}) & 0x3F);
278
-					} else {
279
-						if ($h <= 0xEF && $index < $len-2) {
280
-							$bytes = 3;
281
-
282
-							return ($h & 0x0F) << 12 | (ord($c{$index+1}) & 0x3F) << 6
283
-							| (ord($c{$index+2}) & 0x3F);
284
-						} else {
285
-							if ($h <= 0xF4 && $index < $len-3) {
286
-								$bytes = 4;
287
-
288
-								return ($h & 0x0F) << 18 | (ord($c{$index+1}) & 0x3F) << 12
289
-								| (ord($c{$index+2}) & 0x3F) << 6
290
-								| (ord($c{$index+3}) & 0x3F);
291
-							} else {
292
-								// pas utf mais renvoyer quand meme ce qu'on a
293
-								$bytes = 1;
294
-
295
-								return $h;
296
-							}
297
-						}
298
-					}
299
-				}
300
-			}
301
-		}
302
-
303
-		/** String 2 bin int
304
-		 *
305
-		 * @param string $str
306
-		 * @param int $npad
307
-		 * @return int[]
308
-		 **/
309
-		function string2binint($str, $npad = 512) {
310
-			$bin = array();
311
-			$ords = $this->string2ordUTF8($str, $this->bytesString);
312
-			$npad = $npad/$this->bytesString;
313
-			$length = count($ords);
314
-			$ords[] = 0x80; // append the "1" bit followed by 7 0's
315
-			$pad = ceil(($length+1+32/$this->bytesString)/$npad)*$npad-32/$this->bytesString;
316
-			$ords = array_pad($ords, $pad, 0);
317
-			$mask = (1 << $this->bytesString)-1;
318
-			for ($i = 0; $i < count($ords)*$this->bytesString; $i += $this->bytesString) {
319
-				if (!isset($bin[$i >> 5])) {
320
-					$bin[$i >> 5] = 0;
321
-				} // pour eviter des notices.
322
-				$bin[$i >> 5] |= ($ords[$i/$this->bytesString] & $mask) << (24-$i%32);
323
-			}
324
-			$bin[] = $length*$this->bytesString;
325
-
326
-			return $bin;
327
-		}
328
-
329
-		/** Array split
330
-		 *
331
-		 * @param array $a
332
-		 * @param int $n
333
-		 * @return array
334
-		 **/
335
-		function array_split($a, $n) {
336
-			$split = array();
337
-			while (count($a) > $n) {
338
-				$s = array();
339
-				for ($i = 0; $i < $n; $i++) {
340
-					$s[] = array_shift($a);
341
-				}
342
-				$split[] = $s;
343
-			}
344
-			if (count($a)) {
345
-				$a = array_pad($a, $n, 0);
346
-				$split[] = $a;
347
-			}
348
-
349
-			return $split;
350
-		}
351
-
352
-		/**
353
-		 * Process and return the hash.
354
-		 *
355
-		 * @param $str Input string to hash
356
-		 * @param $ig_func Option param to ignore checking for php > 5.1.2
357
-		 * @return string Hexadecimal representation of the message digest
358
-		 */
359
-		function hash($str, $ig_func = true) {
360
-			unset($binStr);     // binary representation of input string
361
-			unset($hexStr);     // 256-bit message digest in readable hex format
362
-
363
-			// check for php's internal sha256 function, ignore if ig_func==true
364
-			if ($ig_func == false) {
365
-				if (version_compare(PHP_VERSION, '5.1.2', '>=') AND !defined('_NO_HASH_DEFINED')) {
366
-					return hash("sha256", $str, false);
367
-				} else {
368
-					if (function_exists('mhash') && defined('MHASH_SHA256')) {
369
-						return base64_encode(bin2hex(mhash(MHASH_SHA256, $str)));
370
-					}
371
-				}
372
-			}
373
-
374
-			/*
71
+    /**
72
+     * Classe de calcul d'un SHA
73
+     */
74
+    class nanoSha2 {
75
+        // php 4 - 5 compatable class properties
76
+        /** Le résultat doit être passé en majuscule ?
77
+         *
78
+         * @var bool
79
+         */
80
+        var $toUpper;
81
+        /** 32 ou 64 bits ?
82
+         *
83
+         * @var int
84
+         */
85
+        var $platform;
86
+        /** bytes par caractères */
87
+        var $bytesString = 16;
88
+
89
+        /**
90
+         * Constructor
91
+         *
92
+         * @param bool $toUpper
93
+         */
94
+        function __construct($toUpper = false) {
95
+            // Determine if the caller wants upper case or not.
96
+            $this->toUpper = is_bool($toUpper)
97
+                ? $toUpper
98
+                : ((defined('_NANO_SHA2_UPPER')) ? true : false);
99
+
100
+            // Deteremine if the system is 32 or 64 bit.
101
+            $tmpInt = (int)4294967295;
102
+            $this->platform = ($tmpInt > 0) ? 64 : 32;
103
+        }
104
+
105
+        /**
106
+         * Here are the bitwise and functions as defined in FIPS180-2 Standard
107
+         *
108
+         * @param int $x
109
+         * @param int $y
110
+         * @param int $n
111
+         * @return int
112
+         */
113
+        function addmod2n($x, $y, $n = 4294967296)      // Z = (X + Y) mod 2^32
114
+        {
115
+            $mask = 0x80000000;
116
+
117
+            if ($x < 0) {
118
+                $x &= 0x7FFFFFFF;
119
+                $x = (float)$x+$mask;
120
+            }
121
+
122
+            if ($y < 0) {
123
+                $y &= 0x7FFFFFFF;
124
+                $y = (float)$y+$mask;
125
+            }
126
+
127
+            $r = $x+$y;
128
+
129
+            if ($r >= $n) {
130
+                while ($r >= $n) {
131
+                    $r -= $n;
132
+                }
133
+            }
134
+
135
+            return (int)$r;
136
+        }
137
+
138
+        /**
139
+         * Logical bitwise right shift (PHP default is arithmetic shift)
140
+         *
141
+         * @param int $x
142
+         * @param int $n
143
+         * return int
144
+         */
145
+        function SHR($x, $n)        // x >> n
146
+        {
147
+            if ($n >= 32) {      // impose some limits to keep it 32-bit
148
+                return (int)0;
149
+            }
150
+
151
+            if ($n <= 0) {
152
+                return (int)$x;
153
+            }
154
+
155
+            $mask = 0x40000000;
156
+
157
+            if ($x < 0) {
158
+                $x &= 0x7FFFFFFF;
159
+                $mask = $mask >> ($n-1);
160
+
161
+                return ($x >> $n) | $mask;
162
+            }
163
+
164
+            return (int)$x >> (int)$n;
165
+        }
166
+
167
+        /** ROTR
168
+         *
169
+         * @param int $x
170
+         * @param int $n
171
+         * @return int
172
+         */
173
+        function ROTR($x, $n) { return (int)(($this->SHR($x, $n) | ($x << (32-$n)) & 0xFFFFFFFF)); }
174
+
175
+        /** Ch
176
+         *
177
+         * @param int $x
178
+         * @param int $y
179
+         * @param int $z
180
+         * @return int
181
+         */
182
+        function Ch($x, $y, $z) { return ($x & $y) ^ ((~$x) & $z); }
183
+
184
+        /** Maj
185
+         *
186
+         * @param int $x
187
+         * @param int $y
188
+         * @param int $z
189
+         * @return int
190
+         */
191
+        function Maj($x, $y, $z) { return ($x & $y) ^ ($x & $z) ^ ($y & $z); }
192
+
193
+        /** Sigma0
194
+         *
195
+         * @param int $x
196
+         * @return int
197
+         */
198
+        function Sigma0($x) { return (int)($this->ROTR($x, 2) ^ $this->ROTR($x, 13) ^ $this->ROTR($x, 22)); }
199
+
200
+        /** Sigma1
201
+         *
202
+         * @param int $x
203
+         * @return int
204
+         */
205
+        function Sigma1($x) { return (int)($this->ROTR($x, 6) ^ $this->ROTR($x, 11) ^ $this->ROTR($x, 25)); }
206
+
207
+        /** Sigma_0
208
+         *
209
+         * @param int $x
210
+         * @return int
211
+         */
212
+        function sigma_0($x) { return (int)($this->ROTR($x, 7) ^ $this->ROTR($x, 18) ^ $this->SHR($x, 3)); }
213
+
214
+        /** Sigma_1
215
+         *
216
+         * @param int $x
217
+         * @return int
218
+         */
219
+        function sigma_1($x) { return (int)($this->ROTR($x, 17) ^ $this->ROTR($x, 19) ^ $this->SHR($x, 10)); }
220
+
221
+        /** String 2 ord UTF8
222
+         *
223
+         * @param string $s
224
+         * @param int $byteSize
225
+         * @return array
226
+         **/
227
+        function string2ordUTF8($s, &$byteSize) {
228
+            $chars = array();
229
+            // par defaut sur 8bits
230
+            $byteSize = 8;
231
+            $i = 0;
232
+            while ($i < strlen($s)) {
233
+                $chars[] = $this->ordUTF8($s, $i, $bytes);
234
+                $i += $bytes;
235
+                // mais si un char necessite 16bits, on passe tout sur 16
236
+                // sinon on ne concorde pas avec le lecture de la chaine en js
237
+                // et le sha256 js
238
+                if ($bytes > 1) {
239
+                    $byteSize = 16;
240
+                }
241
+            }
242
+
243
+            return $chars;
244
+        }
245
+
246
+        /** Ord UTF8
247
+         *
248
+         * @param string $c
249
+         * @param int $index
250
+         * @param int $bytes
251
+         * @return unknown
252
+         **/
253
+        function ordUTF8($c, $index = 0, &$bytes) {
254
+            $len = strlen($c);
255
+            $bytes = 0;
256
+
257
+            if ($index >= $len) {
258
+                return false;
259
+            }
260
+
261
+            $h = ord($c{$index});
262
+
263
+            if ($h <= 0x7F) {
264
+                $bytes = 1;
265
+
266
+                return $h;
267
+            } else {
268
+                if ($h < 0xC2) {
269
+                    // pas utf mais renvoyer quand meme ce qu'on a
270
+                    $bytes = 1;
271
+
272
+                    return $h;
273
+                } else {
274
+                    if ($h <= 0xDF && $index < $len-1) {
275
+                        $bytes = 2;
276
+
277
+                        return ($h & 0x1F) << 6 | (ord($c{$index+1}) & 0x3F);
278
+                    } else {
279
+                        if ($h <= 0xEF && $index < $len-2) {
280
+                            $bytes = 3;
281
+
282
+                            return ($h & 0x0F) << 12 | (ord($c{$index+1}) & 0x3F) << 6
283
+                            | (ord($c{$index+2}) & 0x3F);
284
+                        } else {
285
+                            if ($h <= 0xF4 && $index < $len-3) {
286
+                                $bytes = 4;
287
+
288
+                                return ($h & 0x0F) << 18 | (ord($c{$index+1}) & 0x3F) << 12
289
+                                | (ord($c{$index+2}) & 0x3F) << 6
290
+                                | (ord($c{$index+3}) & 0x3F);
291
+                            } else {
292
+                                // pas utf mais renvoyer quand meme ce qu'on a
293
+                                $bytes = 1;
294
+
295
+                                return $h;
296
+                            }
297
+                        }
298
+                    }
299
+                }
300
+            }
301
+        }
302
+
303
+        /** String 2 bin int
304
+         *
305
+         * @param string $str
306
+         * @param int $npad
307
+         * @return int[]
308
+         **/
309
+        function string2binint($str, $npad = 512) {
310
+            $bin = array();
311
+            $ords = $this->string2ordUTF8($str, $this->bytesString);
312
+            $npad = $npad/$this->bytesString;
313
+            $length = count($ords);
314
+            $ords[] = 0x80; // append the "1" bit followed by 7 0's
315
+            $pad = ceil(($length+1+32/$this->bytesString)/$npad)*$npad-32/$this->bytesString;
316
+            $ords = array_pad($ords, $pad, 0);
317
+            $mask = (1 << $this->bytesString)-1;
318
+            for ($i = 0; $i < count($ords)*$this->bytesString; $i += $this->bytesString) {
319
+                if (!isset($bin[$i >> 5])) {
320
+                    $bin[$i >> 5] = 0;
321
+                } // pour eviter des notices.
322
+                $bin[$i >> 5] |= ($ords[$i/$this->bytesString] & $mask) << (24-$i%32);
323
+            }
324
+            $bin[] = $length*$this->bytesString;
325
+
326
+            return $bin;
327
+        }
328
+
329
+        /** Array split
330
+         *
331
+         * @param array $a
332
+         * @param int $n
333
+         * @return array
334
+         **/
335
+        function array_split($a, $n) {
336
+            $split = array();
337
+            while (count($a) > $n) {
338
+                $s = array();
339
+                for ($i = 0; $i < $n; $i++) {
340
+                    $s[] = array_shift($a);
341
+                }
342
+                $split[] = $s;
343
+            }
344
+            if (count($a)) {
345
+                $a = array_pad($a, $n, 0);
346
+                $split[] = $a;
347
+            }
348
+
349
+            return $split;
350
+        }
351
+
352
+        /**
353
+         * Process and return the hash.
354
+         *
355
+         * @param $str Input string to hash
356
+         * @param $ig_func Option param to ignore checking for php > 5.1.2
357
+         * @return string Hexadecimal representation of the message digest
358
+         */
359
+        function hash($str, $ig_func = true) {
360
+            unset($binStr);     // binary representation of input string
361
+            unset($hexStr);     // 256-bit message digest in readable hex format
362
+
363
+            // check for php's internal sha256 function, ignore if ig_func==true
364
+            if ($ig_func == false) {
365
+                if (version_compare(PHP_VERSION, '5.1.2', '>=') AND !defined('_NO_HASH_DEFINED')) {
366
+                    return hash("sha256", $str, false);
367
+                } else {
368
+                    if (function_exists('mhash') && defined('MHASH_SHA256')) {
369
+                        return base64_encode(bin2hex(mhash(MHASH_SHA256, $str)));
370
+                    }
371
+                }
372
+            }
373
+
374
+            /*
375 375
 			 * SHA-256 Constants
376 376
 			 *  Sequence of sixty-four constant 32-bit words representing the
377 377
 			 *  first thirty-two bits of the fractional parts of the cube roots
378 378
 			 *  of the first sixtyfour prime numbers.
379 379
 			 */
380
-			$K = array(
381
-				(int)0x428a2f98,
382
-				(int)0x71374491,
383
-				(int)0xb5c0fbcf,
384
-				(int)0xe9b5dba5,
385
-				(int)0x3956c25b,
386
-				(int)0x59f111f1,
387
-				(int)0x923f82a4,
388
-				(int)0xab1c5ed5,
389
-				(int)0xd807aa98,
390
-				(int)0x12835b01,
391
-				(int)0x243185be,
392
-				(int)0x550c7dc3,
393
-				(int)0x72be5d74,
394
-				(int)0x80deb1fe,
395
-				(int)0x9bdc06a7,
396
-				(int)0xc19bf174,
397
-				(int)0xe49b69c1,
398
-				(int)0xefbe4786,
399
-				(int)0x0fc19dc6,
400
-				(int)0x240ca1cc,
401
-				(int)0x2de92c6f,
402
-				(int)0x4a7484aa,
403
-				(int)0x5cb0a9dc,
404
-				(int)0x76f988da,
405
-				(int)0x983e5152,
406
-				(int)0xa831c66d,
407
-				(int)0xb00327c8,
408
-				(int)0xbf597fc7,
409
-				(int)0xc6e00bf3,
410
-				(int)0xd5a79147,
411
-				(int)0x06ca6351,
412
-				(int)0x14292967,
413
-				(int)0x27b70a85,
414
-				(int)0x2e1b2138,
415
-				(int)0x4d2c6dfc,
416
-				(int)0x53380d13,
417
-				(int)0x650a7354,
418
-				(int)0x766a0abb,
419
-				(int)0x81c2c92e,
420
-				(int)0x92722c85,
421
-				(int)0xa2bfe8a1,
422
-				(int)0xa81a664b,
423
-				(int)0xc24b8b70,
424
-				(int)0xc76c51a3,
425
-				(int)0xd192e819,
426
-				(int)0xd6990624,
427
-				(int)0xf40e3585,
428
-				(int)0x106aa070,
429
-				(int)0x19a4c116,
430
-				(int)0x1e376c08,
431
-				(int)0x2748774c,
432
-				(int)0x34b0bcb5,
433
-				(int)0x391c0cb3,
434
-				(int)0x4ed8aa4a,
435
-				(int)0x5b9cca4f,
436
-				(int)0x682e6ff3,
437
-				(int)0x748f82ee,
438
-				(int)0x78a5636f,
439
-				(int)0x84c87814,
440
-				(int)0x8cc70208,
441
-				(int)0x90befffa,
442
-				(int)0xa4506ceb,
443
-				(int)0xbef9a3f7,
444
-				(int)0xc67178f2
445
-			);
446
-
447
-			// Pre-processing: Padding the string
448
-			$binStr = $this->string2binint($str, 512);
449
-
450
-			// Parsing the Padded Message (Break into N 512-bit blocks)
451
-			$M = $this->array_split($binStr, 16);
452
-
453
-			// Set the initial hash values
454
-			$h[0] = (int)0x6a09e667;
455
-			$h[1] = (int)0xbb67ae85;
456
-			$h[2] = (int)0x3c6ef372;
457
-			$h[3] = (int)0xa54ff53a;
458
-			$h[4] = (int)0x510e527f;
459
-			$h[5] = (int)0x9b05688c;
460
-			$h[6] = (int)0x1f83d9ab;
461
-			$h[7] = (int)0x5be0cd19;
462
-
463
-			// loop through message blocks and compute hash. ( For i=1 to N : )
464
-			$N = count($M);
465
-			for ($i = 0; $i < $N; $i++) {
466
-				// Break input block into 16 32bit words (message schedule prep)
467
-				$MI = $M[$i];
468
-
469
-				// Initialize working variables
470
-				$_a = (int)$h[0];
471
-				$_b = (int)$h[1];
472
-				$_c = (int)$h[2];
473
-				$_d = (int)$h[3];
474
-				$_e = (int)$h[4];
475
-				$_f = (int)$h[5];
476
-				$_g = (int)$h[6];
477
-				$_h = (int)$h[7];
478
-				unset($_s0);
479
-				unset($_s1);
480
-				unset($_T1);
481
-				unset($_T2);
482
-				$W = array();
483
-
484
-				// Compute the hash and update
485
-				for ($t = 0; $t < 16; $t++) {
486
-					// Prepare the first 16 message schedule values as we loop
487
-					$W[$t] = $MI[$t];
488
-
489
-					// Compute hash
490
-					$_T1 = $this->addmod2n($this->addmod2n($this->addmod2n($this->addmod2n($_h, $this->Sigma1($_e)),
491
-						$this->Ch($_e, $_f, $_g)), $K[$t]), $W[$t]);
492
-					$_T2 = $this->addmod2n($this->Sigma0($_a), $this->Maj($_a, $_b, $_c));
493
-
494
-					// Update working variables
495
-					$_h = $_g;
496
-					$_g = $_f;
497
-					$_f = $_e;
498
-					$_e = $this->addmod2n($_d, $_T1);
499
-					$_d = $_c;
500
-					$_c = $_b;
501
-					$_b = $_a;
502
-					$_a = $this->addmod2n($_T1, $_T2);
503
-				}
504
-
505
-				for (; $t < 64; $t++) {
506
-					// Continue building the message schedule as we loop
507
-					$_s0 = $W[($t+1) & 0x0F];
508
-					$_s0 = $this->sigma_0($_s0);
509
-					$_s1 = $W[($t+14) & 0x0F];
510
-					$_s1 = $this->sigma_1($_s1);
511
-
512
-					$W[$t & 0xF] = $this->addmod2n($this->addmod2n($this->addmod2n($W[$t & 0xF], $_s0), $_s1), $W[($t+9) & 0x0F]);
513
-
514
-					// Compute hash
515
-					$_T1 = $this->addmod2n($this->addmod2n($this->addmod2n($this->addmod2n($_h, $this->Sigma1($_e)),
516
-						$this->Ch($_e, $_f, $_g)), $K[$t]), $W[$t & 0xF]);
517
-					$_T2 = $this->addmod2n($this->Sigma0($_a), $this->Maj($_a, $_b, $_c));
518
-
519
-					// Update working variables
520
-					$_h = $_g;
521
-					$_g = $_f;
522
-					$_f = $_e;
523
-					$_e = $this->addmod2n($_d, $_T1);
524
-					$_d = $_c;
525
-					$_c = $_b;
526
-					$_b = $_a;
527
-					$_a = $this->addmod2n($_T1, $_T2);
528
-				}
529
-
530
-				$h[0] = $this->addmod2n($h[0], $_a);
531
-				$h[1] = $this->addmod2n($h[1], $_b);
532
-				$h[2] = $this->addmod2n($h[2], $_c);
533
-				$h[3] = $this->addmod2n($h[3], $_d);
534
-				$h[4] = $this->addmod2n($h[4], $_e);
535
-				$h[5] = $this->addmod2n($h[5], $_f);
536
-				$h[6] = $this->addmod2n($h[6], $_g);
537
-				$h[7] = $this->addmod2n($h[7], $_h);
538
-			}
539
-
540
-			// Convert the 32-bit words into human readable hexadecimal format.
541
-			$hexStr = sprintf("%08x%08x%08x%08x%08x%08x%08x%08x", $h[0], $h[1], $h[2], $h[3], $h[4], $h[5], $h[6], $h[7]);
542
-
543
-			return ($this->toUpper) ? strtoupper($hexStr) : $hexStr;
544
-		}
545
-
546
-	}
380
+            $K = array(
381
+                (int)0x428a2f98,
382
+                (int)0x71374491,
383
+                (int)0xb5c0fbcf,
384
+                (int)0xe9b5dba5,
385
+                (int)0x3956c25b,
386
+                (int)0x59f111f1,
387
+                (int)0x923f82a4,
388
+                (int)0xab1c5ed5,
389
+                (int)0xd807aa98,
390
+                (int)0x12835b01,
391
+                (int)0x243185be,
392
+                (int)0x550c7dc3,
393
+                (int)0x72be5d74,
394
+                (int)0x80deb1fe,
395
+                (int)0x9bdc06a7,
396
+                (int)0xc19bf174,
397
+                (int)0xe49b69c1,
398
+                (int)0xefbe4786,
399
+                (int)0x0fc19dc6,
400
+                (int)0x240ca1cc,
401
+                (int)0x2de92c6f,
402
+                (int)0x4a7484aa,
403
+                (int)0x5cb0a9dc,
404
+                (int)0x76f988da,
405
+                (int)0x983e5152,
406
+                (int)0xa831c66d,
407
+                (int)0xb00327c8,
408
+                (int)0xbf597fc7,
409
+                (int)0xc6e00bf3,
410
+                (int)0xd5a79147,
411
+                (int)0x06ca6351,
412
+                (int)0x14292967,
413
+                (int)0x27b70a85,
414
+                (int)0x2e1b2138,
415
+                (int)0x4d2c6dfc,
416
+                (int)0x53380d13,
417
+                (int)0x650a7354,
418
+                (int)0x766a0abb,
419
+                (int)0x81c2c92e,
420
+                (int)0x92722c85,
421
+                (int)0xa2bfe8a1,
422
+                (int)0xa81a664b,
423
+                (int)0xc24b8b70,
424
+                (int)0xc76c51a3,
425
+                (int)0xd192e819,
426
+                (int)0xd6990624,
427
+                (int)0xf40e3585,
428
+                (int)0x106aa070,
429
+                (int)0x19a4c116,
430
+                (int)0x1e376c08,
431
+                (int)0x2748774c,
432
+                (int)0x34b0bcb5,
433
+                (int)0x391c0cb3,
434
+                (int)0x4ed8aa4a,
435
+                (int)0x5b9cca4f,
436
+                (int)0x682e6ff3,
437
+                (int)0x748f82ee,
438
+                (int)0x78a5636f,
439
+                (int)0x84c87814,
440
+                (int)0x8cc70208,
441
+                (int)0x90befffa,
442
+                (int)0xa4506ceb,
443
+                (int)0xbef9a3f7,
444
+                (int)0xc67178f2
445
+            );
446
+
447
+            // Pre-processing: Padding the string
448
+            $binStr = $this->string2binint($str, 512);
449
+
450
+            // Parsing the Padded Message (Break into N 512-bit blocks)
451
+            $M = $this->array_split($binStr, 16);
452
+
453
+            // Set the initial hash values
454
+            $h[0] = (int)0x6a09e667;
455
+            $h[1] = (int)0xbb67ae85;
456
+            $h[2] = (int)0x3c6ef372;
457
+            $h[3] = (int)0xa54ff53a;
458
+            $h[4] = (int)0x510e527f;
459
+            $h[5] = (int)0x9b05688c;
460
+            $h[6] = (int)0x1f83d9ab;
461
+            $h[7] = (int)0x5be0cd19;
462
+
463
+            // loop through message blocks and compute hash. ( For i=1 to N : )
464
+            $N = count($M);
465
+            for ($i = 0; $i < $N; $i++) {
466
+                // Break input block into 16 32bit words (message schedule prep)
467
+                $MI = $M[$i];
468
+
469
+                // Initialize working variables
470
+                $_a = (int)$h[0];
471
+                $_b = (int)$h[1];
472
+                $_c = (int)$h[2];
473
+                $_d = (int)$h[3];
474
+                $_e = (int)$h[4];
475
+                $_f = (int)$h[5];
476
+                $_g = (int)$h[6];
477
+                $_h = (int)$h[7];
478
+                unset($_s0);
479
+                unset($_s1);
480
+                unset($_T1);
481
+                unset($_T2);
482
+                $W = array();
483
+
484
+                // Compute the hash and update
485
+                for ($t = 0; $t < 16; $t++) {
486
+                    // Prepare the first 16 message schedule values as we loop
487
+                    $W[$t] = $MI[$t];
488
+
489
+                    // Compute hash
490
+                    $_T1 = $this->addmod2n($this->addmod2n($this->addmod2n($this->addmod2n($_h, $this->Sigma1($_e)),
491
+                        $this->Ch($_e, $_f, $_g)), $K[$t]), $W[$t]);
492
+                    $_T2 = $this->addmod2n($this->Sigma0($_a), $this->Maj($_a, $_b, $_c));
493
+
494
+                    // Update working variables
495
+                    $_h = $_g;
496
+                    $_g = $_f;
497
+                    $_f = $_e;
498
+                    $_e = $this->addmod2n($_d, $_T1);
499
+                    $_d = $_c;
500
+                    $_c = $_b;
501
+                    $_b = $_a;
502
+                    $_a = $this->addmod2n($_T1, $_T2);
503
+                }
504
+
505
+                for (; $t < 64; $t++) {
506
+                    // Continue building the message schedule as we loop
507
+                    $_s0 = $W[($t+1) & 0x0F];
508
+                    $_s0 = $this->sigma_0($_s0);
509
+                    $_s1 = $W[($t+14) & 0x0F];
510
+                    $_s1 = $this->sigma_1($_s1);
511
+
512
+                    $W[$t & 0xF] = $this->addmod2n($this->addmod2n($this->addmod2n($W[$t & 0xF], $_s0), $_s1), $W[($t+9) & 0x0F]);
513
+
514
+                    // Compute hash
515
+                    $_T1 = $this->addmod2n($this->addmod2n($this->addmod2n($this->addmod2n($_h, $this->Sigma1($_e)),
516
+                        $this->Ch($_e, $_f, $_g)), $K[$t]), $W[$t & 0xF]);
517
+                    $_T2 = $this->addmod2n($this->Sigma0($_a), $this->Maj($_a, $_b, $_c));
518
+
519
+                    // Update working variables
520
+                    $_h = $_g;
521
+                    $_g = $_f;
522
+                    $_f = $_e;
523
+                    $_e = $this->addmod2n($_d, $_T1);
524
+                    $_d = $_c;
525
+                    $_c = $_b;
526
+                    $_b = $_a;
527
+                    $_a = $this->addmod2n($_T1, $_T2);
528
+                }
529
+
530
+                $h[0] = $this->addmod2n($h[0], $_a);
531
+                $h[1] = $this->addmod2n($h[1], $_b);
532
+                $h[2] = $this->addmod2n($h[2], $_c);
533
+                $h[3] = $this->addmod2n($h[3], $_d);
534
+                $h[4] = $this->addmod2n($h[4], $_e);
535
+                $h[5] = $this->addmod2n($h[5], $_f);
536
+                $h[6] = $this->addmod2n($h[6], $_g);
537
+                $h[7] = $this->addmod2n($h[7], $_h);
538
+            }
539
+
540
+            // Convert the 32-bit words into human readable hexadecimal format.
541
+            $hexStr = sprintf("%08x%08x%08x%08x%08x%08x%08x%08x", $h[0], $h[1], $h[2], $h[3], $h[4], $h[5], $h[6], $h[7]);
542
+
543
+            return ($this->toUpper) ? strtoupper($hexStr) : $hexStr;
544
+        }
545
+
546
+    }
547 547
 }
548 548
 
549 549
 /**
@@ -562,42 +562,42 @@  discard block
 block discarded – undo
562 562
  * @return string Le SHA de la chaîne
563 563
  */
564 564
 function _nano_sha256($str, $ig_func = true) {
565
-	$obj = new nanoSha2((defined('_NANO_SHA2_UPPER')) ? true : false);
565
+    $obj = new nanoSha2((defined('_NANO_SHA2_UPPER')) ? true : false);
566 566
 
567
-	return $obj->hash($str, $ig_func);
567
+    return $obj->hash($str, $ig_func);
568 568
 }
569 569
 
570 570
 // 2009-07-23: Added check for function as the Suhosin plugin adds this routine.
571 571
 if (!function_exists('sha256')) {
572
-	/**
573
-	 * Calcul du SHA256
574
-	 *
575
-	 * @param string $str Chaîne dont on veut calculer le SHA
576
-	 * @param bool $ig_func
577
-	 * @return string Le SHA de la chaîne
578
-	 */
579
-	function sha256($str, $ig_func = true) { return _nano_sha256($str, $ig_func); }
572
+    /**
573
+     * Calcul du SHA256
574
+     *
575
+     * @param string $str Chaîne dont on veut calculer le SHA
576
+     * @param bool $ig_func
577
+     * @return string Le SHA de la chaîne
578
+     */
579
+    function sha256($str, $ig_func = true) { return _nano_sha256($str, $ig_func); }
580 580
 }
581 581
 
582 582
 // support to give php4 the hash() routine which abstracts this code.
583 583
 if (!function_exists('hash')) {
584
-	define('_NO_HASH_DEFINED', true);
585
-	/**
586
-	 * Retourne le calcul d'un hachage d'une chaîne (pour PHP4)
587
-	 *
588
-	 * @param string $algo Nom de l'algorythme de hachage
589
-	 * @param string $data Chaîne à hacher
590
-	 * @return string|bool
591
-	 *     Hash de la chaîne
592
-	 *     False si pas d'algo trouvé
593
-	 */
594
-	function hash($algo, $data) {
595
-		if (empty($algo) || !is_string($algo) || !is_string($data)) {
596
-			return false;
597
-		}
598
-
599
-		if (function_exists($algo)) {
600
-			return $algo($data);
601
-		}
602
-	}
584
+    define('_NO_HASH_DEFINED', true);
585
+    /**
586
+     * Retourne le calcul d'un hachage d'une chaîne (pour PHP4)
587
+     *
588
+     * @param string $algo Nom de l'algorythme de hachage
589
+     * @param string $data Chaîne à hacher
590
+     * @return string|bool
591
+     *     Hash de la chaîne
592
+     *     False si pas d'algo trouvé
593
+     */
594
+    function hash($algo, $data) {
595
+        if (empty($algo) || !is_string($algo) || !is_string($data)) {
596
+            return false;
597
+        }
598
+
599
+        if (function_exists($algo)) {
600
+            return $algo($data);
601
+        }
602
+    }
603 603
 }
604 604
\ No newline at end of file
Please login to merge, or discard this patch.
ecrire/prive.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
20 20
 $var_auth = $auth();
21 21
 
22 22
 if ($var_auth !== '') {
23
-	if (!is_int($var_auth)) {
24
-		// si l'authentifie' n'a pas acces a l'espace de redac
25
-		// c'est qu'on voulait forcer sa reconnaissance en tant que visiteur.
26
-		// On reexecute pour deboucher sur le include public.
27
-		// autrement on insiste
28
-		if (is_array($var_auth)) {
29
-			$var_auth = '../?' . $_SERVER['QUERY_STRING'];
30
-			spip_setcookie('spip_session', $_COOKIE['spip_session'], time() + 3600 * 24 * 14);
31
-		}
32
-		include_spip('inc/headers');
33
-		redirige_formulaire($var_auth);
34
-	}
23
+    if (!is_int($var_auth)) {
24
+        // si l'authentifie' n'a pas acces a l'espace de redac
25
+        // c'est qu'on voulait forcer sa reconnaissance en tant que visiteur.
26
+        // On reexecute pour deboucher sur le include public.
27
+        // autrement on insiste
28
+        if (is_array($var_auth)) {
29
+            $var_auth = '../?' . $_SERVER['QUERY_STRING'];
30
+            spip_setcookie('spip_session', $_COOKIE['spip_session'], time() + 3600 * 24 * 14);
31
+        }
32
+        include_spip('inc/headers');
33
+        redirige_formulaire($var_auth);
34
+    }
35 35
 }
36 36
 
37 37
 // En somme, est prive' ce qui est publiquement nomme'...
Please login to merge, or discard this patch.
ecrire/plugins/afficher_nom_plugin.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 include_spip('inc/texte');
@@ -19,54 +19,54 @@  discard block
 block discarded – undo
19 19
 
20 20
 // http://code.spip.net/@ligne_plug
21 21
 function plugins_afficher_nom_plugin_dist(
22
-	$url_page,
23
-	$plug_file,
24
-	$checked,
25
-	$actif,
26
-	$expose = false,
27
-	$class_li = "item",
28
-	$dir_plugins = _DIR_PLUGINS
22
+    $url_page,
23
+    $plug_file,
24
+    $checked,
25
+    $actif,
26
+    $expose = false,
27
+    $class_li = "item",
28
+    $dir_plugins = _DIR_PLUGINS
29 29
 ) {
30
-	static $id_input = 0;
31
-	static $versions = array();
30
+    static $id_input = 0;
31
+    static $versions = array();
32 32
 
33
-	$erreur = false;
34
-	$s = "";
33
+    $erreur = false;
34
+    $s = "";
35 35
 
36
-	$get_infos = charger_fonction('get_infos', 'plugins');
37
-	$info = $get_infos($plug_file, false, $dir_plugins);
36
+    $get_infos = charger_fonction('get_infos', 'plugins');
37
+    $info = $get_infos($plug_file, false, $dir_plugins);
38 38
 
39
-	// numerotons les occurences d'un meme prefix
40
-	$versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
41
-	$id = $info['prefix'] . $versions[$info['prefix']];
39
+    // numerotons les occurences d'un meme prefix
40
+    $versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
41
+    $id = $info['prefix'] . $versions[$info['prefix']];
42 42
 
43
-	$class = $class_li;
44
-	$class .= $actif ? " actif" : "";
45
-	$class .= $expose ? " on" : "";
46
-	$erreur = isset($info['erreur']);
47
-	if ($erreur) {
48
-		$class .= " error";
49
-	}
50
-	$s .= "<li id='$id' class='$class'>";
43
+    $class = $class_li;
44
+    $class .= $actif ? " actif" : "";
45
+    $class .= $expose ? " on" : "";
46
+    $erreur = isset($info['erreur']);
47
+    if ($erreur) {
48
+        $class .= " error";
49
+    }
50
+    $s .= "<li id='$id' class='$class'>";
51 51
 
52
-	// Cartouche Resume
53
-	$s .= "<div class='resume'>";
52
+    // Cartouche Resume
53
+    $s .= "<div class='resume'>";
54 54
 
55
-	$prefix = $info['prefix'];
56
-	$dir = "$dir_plugins$plug_file/lang/$prefix";
57
-	$desc = plugin_propre($info['description'], $dir);
58
-	$url_stat = parametre_url($url_page, "plugin", $dir_plugins . $plug_file);
55
+    $prefix = $info['prefix'];
56
+    $dir = "$dir_plugins$plug_file/lang/$prefix";
57
+    $desc = plugin_propre($info['description'], $dir);
58
+    $url_stat = parametre_url($url_page, "plugin", $dir_plugins . $plug_file);
59 59
 
60
-	$s .= "<strong class='nom'>" . typo($info['nom']) . "</strong>";
61
-	$s .= " <span class='version'>" . $info['version'] . "</span>";
62
-	$s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . "</span>";
63
-	$s .= "</div>";
60
+    $s .= "<strong class='nom'>" . typo($info['nom']) . "</strong>";
61
+    $s .= " <span class='version'>" . $info['version'] . "</span>";
62
+    $s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . "</span>";
63
+    $s .= "</div>";
64 64
 
65
-	if ($erreur) {
66
-		$s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>";
67
-	}
65
+    if ($erreur) {
66
+        $s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>";
67
+    }
68 68
 
69
-	$s .= "</li>";
69
+    $s .= "</li>";
70 70
 
71
-	return $s;
71
+    return $s;
72 72
 }
Please login to merge, or discard this patch.