Completed
Push — spip-3.0 ( 484b62...e817f1 )
by cam
34:33
created
ecrire/auth/sha256.inc.php 2 patches
Doc Comments   +33 added lines patch added patch discarded remove patch
@@ -135,15 +135,41 @@  discard block
 block discarded – undo
135 135
             return (int)$x >> (int)$n;
136 136
         }
137 137
 
138
+        /**
139
+         * @param integer $n
140
+         */
138 141
         function ROTR($x, $n) { return (int)(($this->SHR($x, $n) | ($x << (32-$n)) & 0xFFFFFFFF)); }
142
+
143
+        /**
144
+         * @param integer $x
145
+         * @param integer $y
146
+         * @param integer $z
147
+         */
139 148
         function Ch($x, $y, $z) { return ($x & $y) ^ ((~$x) & $z); }
149
+
150
+        /**
151
+         * @param integer $x
152
+         * @param integer $y
153
+         * @param integer $z
154
+         */
140 155
         function Maj($x, $y, $z) { return ($x & $y) ^ ($x & $z) ^ ($y & $z); }
156
+
157
+        /**
158
+         * @param integer $x
159
+         */
141 160
         function Sigma0($x) { return (int) ($this->ROTR($x, 2)^$this->ROTR($x, 13)^$this->ROTR($x, 22)); }
161
+
162
+        /**
163
+         * @param integer $x
164
+         */
142 165
         function Sigma1($x) { return (int) ($this->ROTR($x, 6)^$this->ROTR($x, 11)^$this->ROTR($x, 25)); }
143 166
         function sigma_0($x) { return (int) ($this->ROTR($x, 7)^$this->ROTR($x, 18)^$this->SHR($x, 3)); }
144 167
         function sigma_1($x) { return (int) ($this->ROTR($x, 17)^$this->ROTR($x, 19)^$this->SHR($x, 10)); }
145 168
 
146 169
 
170
+				/**
171
+				 * @param integer $byteSize
172
+				 */
147 173
 				function string2ordUTF8($s,&$byteSize){
148 174
 					$chars = array();
149 175
 					// par defaut sur 8bits
@@ -219,6 +245,9 @@  discard block
 block discarded – undo
219 245
 					return $bin;
220 246
 				}
221 247
 
248
+				/**
249
+				 * @param integer $n
250
+				 */
222 251
 				function array_split($a, $n) {
223 252
 					$split = array();
224 253
 					while (count($a)>$n) {
@@ -434,6 +463,10 @@  discard block
 block discarded – undo
434 463
 if (!function_exists('hash'))
435 464
 {
436 465
     define('_NO_HASH_DEFINED',true);
466
+
467
+    /**
468
+     * @param string $algo
469
+     */
437 470
     function hash($algo, $data)
438 471
     {
439 472
         if (empty($algo) || !is_string($algo) || !is_string($data)) {
Please login to merge, or discard this patch.
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         // php 4 - 5 compatable class properties
74 74
         var     $toUpper;
75 75
         var     $platform;
76
-				var		  $bytesString = 16;
76
+                var		  $bytesString = 16;
77 77
 
78 78
         // Php 4 - 6 compatable constructor
79 79
         function nanoSha2($toUpper = false) {
@@ -144,94 +144,94 @@  discard block
 block discarded – undo
144 144
         function sigma_1($x) { return (int) ($this->ROTR($x, 17)^$this->ROTR($x, 19)^$this->SHR($x, 10)); }
145 145
 
146 146
 
147
-				function string2ordUTF8($s,&$byteSize){
148
-					$chars = array();
149
-					// par defaut sur 8bits
150
-					$byteSize = 8;
151
-					$i = 0;
152
-					while ($i<strlen($s)){
153
-						$chars[] = $this->ordUTF8($s, $i, $bytes);
154
-						$i+=$bytes;
155
-						// mais si un char necessite 16bits, on passe tout sur 16
156
-						// sinon on ne concorde pas avec le lecture de la chaine en js
157
-						// et le sha256 js
158
-						if ($bytes>1) $byteSize = 16;
159
-					}
160
-					return $chars;
161
-				}
162
-
163
-				function ordUTF8($c, $index = 0, &$bytes)
164
-				{
165
-					$len = strlen($c);
166
-					$bytes = 0;
167
-
168
-					if ($index >= $len)
169
-						return false;
170
-
171
-					$h = ord($c{$index});
172
-
173
-					if ($h <= 0x7F) {
174
-						$bytes = 1;
175
-						return $h;
176
-					}
177
-					else if ($h < 0xC2){
178
-						// pas utf mais renvoyer quand meme ce qu'on a
179
-						$bytes = 1;
180
-						return $h;
181
-					}
182
-					else if ($h <= 0xDF && $index < $len - 1) {
183
-						$bytes = 2;
184
-						return ($h & 0x1F) <<  6 | (ord($c{$index + 1}) & 0x3F);
185
-					}
186
-					else if ($h <= 0xEF && $index < $len - 2) {
187
-						$bytes = 3;
188
-						return ($h & 0x0F) << 12 | (ord($c{$index + 1}) & 0x3F) << 6
189
-																		 | (ord($c{$index + 2}) & 0x3F);
190
-					}
191
-					else if ($h <= 0xF4 && $index < $len - 3) {
192
-						$bytes = 4;
193
-						return ($h & 0x0F) << 18 | (ord($c{$index + 1}) & 0x3F) << 12
194
-																		 | (ord($c{$index + 2}) & 0x3F) << 6
195
-																		 | (ord($c{$index + 3}) & 0x3F);
196
-					}
197
-					else {
198
-						// pas utf mais renvoyer quand meme ce qu'on a
199
-						$bytes = 1;
200
-						return $h;
201
-					}
202
-				}
203
-
204
-				function string2binint ($str,$npad=512) {
205
-					$bin = array();
206
-					$ords = $this->string2ordUTF8($str,$this->bytesString);
207
-					$npad = $npad/$this->bytesString;
208
-					$length = count($ords);
209
-					$ords[] = 0x80; // append the "1" bit followed by 7 0's
210
-					$pad = ceil(($length+1+32/$this->bytesString)/$npad)*$npad-32/$this->bytesString;
211
-					$ords = array_pad($ords,$pad,0);
212
-					$mask = (1 << $this->bytesString) - 1;
213
-					for($i = 0; $i < count($ords) * $this->bytesString; $i += $this->bytesString) {
214
-						if (!isset($bin[$i>>5])) { $bin[$i>>5] = 0; } // pour eviter des notices.
215
-						$bin[$i>>5] |= ($ords[$i / $this->bytesString] & $mask) << (24 - $i%32);
216
-					}
217
-					$bin[] = $length*$this->bytesString;
218
-					return $bin;
219
-				}
220
-
221
-				function array_split($a, $n) {
222
-					$split = array();
223
-					while (count($a)>$n) {
224
-						$s = array();
225
-						for($i = 0;$i<$n;$i++)
226
-							$s[] = array_shift($a);
227
-						$split[] = $s;
228
-					}
229
-					if (count($a)){
230
-						$a = array_pad($a,$n,0);
231
-						$split[] = $a;
232
-					}
233
-					return $split;
234
-				}
147
+                function string2ordUTF8($s,&$byteSize){
148
+                    $chars = array();
149
+                    // par defaut sur 8bits
150
+                    $byteSize = 8;
151
+                    $i = 0;
152
+                    while ($i<strlen($s)){
153
+                        $chars[] = $this->ordUTF8($s, $i, $bytes);
154
+                        $i+=$bytes;
155
+                        // mais si un char necessite 16bits, on passe tout sur 16
156
+                        // sinon on ne concorde pas avec le lecture de la chaine en js
157
+                        // et le sha256 js
158
+                        if ($bytes>1) $byteSize = 16;
159
+                    }
160
+                    return $chars;
161
+                }
162
+
163
+                function ordUTF8($c, $index = 0, &$bytes)
164
+                {
165
+                    $len = strlen($c);
166
+                    $bytes = 0;
167
+
168
+                    if ($index >= $len)
169
+                        return false;
170
+
171
+                    $h = ord($c{$index});
172
+
173
+                    if ($h <= 0x7F) {
174
+                        $bytes = 1;
175
+                        return $h;
176
+                    }
177
+                    else if ($h < 0xC2){
178
+                        // pas utf mais renvoyer quand meme ce qu'on a
179
+                        $bytes = 1;
180
+                        return $h;
181
+                    }
182
+                    else if ($h <= 0xDF && $index < $len - 1) {
183
+                        $bytes = 2;
184
+                        return ($h & 0x1F) <<  6 | (ord($c{$index + 1}) & 0x3F);
185
+                    }
186
+                    else if ($h <= 0xEF && $index < $len - 2) {
187
+                        $bytes = 3;
188
+                        return ($h & 0x0F) << 12 | (ord($c{$index + 1}) & 0x3F) << 6
189
+                                                                            | (ord($c{$index + 2}) & 0x3F);
190
+                    }
191
+                    else if ($h <= 0xF4 && $index < $len - 3) {
192
+                        $bytes = 4;
193
+                        return ($h & 0x0F) << 18 | (ord($c{$index + 1}) & 0x3F) << 12
194
+                                                                            | (ord($c{$index + 2}) & 0x3F) << 6
195
+                                                                            | (ord($c{$index + 3}) & 0x3F);
196
+                    }
197
+                    else {
198
+                        // pas utf mais renvoyer quand meme ce qu'on a
199
+                        $bytes = 1;
200
+                        return $h;
201
+                    }
202
+                }
203
+
204
+                function string2binint ($str,$npad=512) {
205
+                    $bin = array();
206
+                    $ords = $this->string2ordUTF8($str,$this->bytesString);
207
+                    $npad = $npad/$this->bytesString;
208
+                    $length = count($ords);
209
+                    $ords[] = 0x80; // append the "1" bit followed by 7 0's
210
+                    $pad = ceil(($length+1+32/$this->bytesString)/$npad)*$npad-32/$this->bytesString;
211
+                    $ords = array_pad($ords,$pad,0);
212
+                    $mask = (1 << $this->bytesString) - 1;
213
+                    for($i = 0; $i < count($ords) * $this->bytesString; $i += $this->bytesString) {
214
+                        if (!isset($bin[$i>>5])) { $bin[$i>>5] = 0; } // pour eviter des notices.
215
+                        $bin[$i>>5] |= ($ords[$i / $this->bytesString] & $mask) << (24 - $i%32);
216
+                    }
217
+                    $bin[] = $length*$this->bytesString;
218
+                    return $bin;
219
+                }
220
+
221
+                function array_split($a, $n) {
222
+                    $split = array();
223
+                    while (count($a)>$n) {
224
+                        $s = array();
225
+                        for($i = 0;$i<$n;$i++)
226
+                            $s[] = array_shift($a);
227
+                        $split[] = $s;
228
+                    }
229
+                    if (count($a)){
230
+                        $a = array_pad($a,$n,0);
231
+                        $split[] = $a;
232
+                    }
233
+                    return $split;
234
+                }
235 235
 
236 236
         /**
237 237
          * Process and return the hash.
@@ -261,27 +261,27 @@  discard block
 block discarded – undo
261 261
              *  of the first sixtyfour prime numbers.
262 262
              */
263 263
             $K = array((int)0x428a2f98, (int)0x71374491, (int)0xb5c0fbcf,
264
-                       (int)0xe9b5dba5, (int)0x3956c25b, (int)0x59f111f1,
265
-                       (int)0x923f82a4, (int)0xab1c5ed5, (int)0xd807aa98,
266
-                       (int)0x12835b01, (int)0x243185be, (int)0x550c7dc3,
267
-                       (int)0x72be5d74, (int)0x80deb1fe, (int)0x9bdc06a7,
268
-                       (int)0xc19bf174, (int)0xe49b69c1, (int)0xefbe4786,
269
-                       (int)0x0fc19dc6, (int)0x240ca1cc, (int)0x2de92c6f,
270
-                       (int)0x4a7484aa, (int)0x5cb0a9dc, (int)0x76f988da,
271
-                       (int)0x983e5152, (int)0xa831c66d, (int)0xb00327c8,
272
-                       (int)0xbf597fc7, (int)0xc6e00bf3, (int)0xd5a79147,
273
-                       (int)0x06ca6351, (int)0x14292967, (int)0x27b70a85,
274
-                       (int)0x2e1b2138, (int)0x4d2c6dfc, (int)0x53380d13,
275
-                       (int)0x650a7354, (int)0x766a0abb, (int)0x81c2c92e,
276
-                       (int)0x92722c85, (int)0xa2bfe8a1, (int)0xa81a664b,
277
-                       (int)0xc24b8b70, (int)0xc76c51a3, (int)0xd192e819,
278
-                       (int)0xd6990624, (int)0xf40e3585, (int)0x106aa070,
279
-                       (int)0x19a4c116, (int)0x1e376c08, (int)0x2748774c,
280
-                       (int)0x34b0bcb5, (int)0x391c0cb3, (int)0x4ed8aa4a,
281
-                       (int)0x5b9cca4f, (int)0x682e6ff3, (int)0x748f82ee,
282
-                       (int)0x78a5636f, (int)0x84c87814, (int)0x8cc70208,
283
-                       (int)0x90befffa, (int)0xa4506ceb, (int)0xbef9a3f7,
284
-                       (int)0xc67178f2);
264
+                        (int)0xe9b5dba5, (int)0x3956c25b, (int)0x59f111f1,
265
+                        (int)0x923f82a4, (int)0xab1c5ed5, (int)0xd807aa98,
266
+                        (int)0x12835b01, (int)0x243185be, (int)0x550c7dc3,
267
+                        (int)0x72be5d74, (int)0x80deb1fe, (int)0x9bdc06a7,
268
+                        (int)0xc19bf174, (int)0xe49b69c1, (int)0xefbe4786,
269
+                        (int)0x0fc19dc6, (int)0x240ca1cc, (int)0x2de92c6f,
270
+                        (int)0x4a7484aa, (int)0x5cb0a9dc, (int)0x76f988da,
271
+                        (int)0x983e5152, (int)0xa831c66d, (int)0xb00327c8,
272
+                        (int)0xbf597fc7, (int)0xc6e00bf3, (int)0xd5a79147,
273
+                        (int)0x06ca6351, (int)0x14292967, (int)0x27b70a85,
274
+                        (int)0x2e1b2138, (int)0x4d2c6dfc, (int)0x53380d13,
275
+                        (int)0x650a7354, (int)0x766a0abb, (int)0x81c2c92e,
276
+                        (int)0x92722c85, (int)0xa2bfe8a1, (int)0xa81a664b,
277
+                        (int)0xc24b8b70, (int)0xc76c51a3, (int)0xd192e819,
278
+                        (int)0xd6990624, (int)0xf40e3585, (int)0x106aa070,
279
+                        (int)0x19a4c116, (int)0x1e376c08, (int)0x2748774c,
280
+                        (int)0x34b0bcb5, (int)0x391c0cb3, (int)0x4ed8aa4a,
281
+                        (int)0x5b9cca4f, (int)0x682e6ff3, (int)0x748f82ee,
282
+                        (int)0x78a5636f, (int)0x84c87814, (int)0x8cc70208,
283
+                        (int)0x90befffa, (int)0xa4506ceb, (int)0xbef9a3f7,
284
+                        (int)0xc67178f2);
285 285
 
286 286
             // Pre-processing: Padding the string
287 287
             $binStr = $this->string2binint($str,512);
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     function str_split($string, $split_length = 1)
384 384
     {
385
-	      $result = array();
385
+            $result = array();
386 386
         $sign = ($split_length < 0) ? -1 : 1;
387 387
         $strlen = strlen($string);
388 388
         $split_length = abs($split_length);
Please login to merge, or discard this patch.
ecrire/balise/logo_.php 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -96,6 +96,13 @@
 block discarded – undo
96 96
 	return $p;
97 97
 }
98 98
 
99
+/**
100
+ * @param string $id_objet
101
+ * @param string $_id_objet
102
+ * @param string $type
103
+ * @param integer $fichier
104
+ * @param string $suite
105
+ */
99 106
 function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite)
100 107
 {
101 108
 	$code = "quete_logo('$id_objet', '" .
Please login to merge, or discard this patch.
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -20,102 +20,102 @@
 block discarded – undo
20 20
 // http://doc.spip.org/@balise_LOGO__dist
21 21
 function balise_LOGO__dist ($p) {
22 22
 
23
-	preg_match(",^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i", $p->nom_champ, $regs);
24
-	$type = strtolower($regs[1]);
25
-	$suite_logo = $regs[2];
26
-
27
-	// cas de #LOGO_SITE_SPIP
28
-	if ($type == 'site_spip') {
29
-		$type = 'site';
30
-		$_id_objet = "\"'0'\"";
31
-	}
32
-
33
-	$id_objet = id_table_objet($type);
34
-	if (!isset($_id_objet) OR !$_id_objet)
35
-		$_id_objet = champ_sql($id_objet, $p);
36
-
37
-	$fichier = ($p->etoile === '**') ? -1 : 0;
38
-	$coord = array();
39
-	$align = $lien = '';
40
-	$mode_logo = '';
41
-
42
-	if ($p->param AND !$p->param[0][0]) {
43
-		$params = $p->param[0];
44
-		array_shift($params);
45
-		foreach($params as $a) {
46
-			if ($a[0]->type === 'texte') {
47
-				$n = $a[0]->texte;
48
-				if (is_numeric($n))
49
-					$coord[]= $n;
50
-				elseif (in_array($n,array('top','left','right','center','bottom')))
51
-					$align = $n;
52
-				elseif (in_array($n,array('auto','icone','apercu','vignette')))
53
-					$mode_logo = $n;
54
-			}
55
-			else $lien =  calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
56
-
57
-		}
58
-	}
59
-
60
-	$coord_x = !$coord  ? 0 : intval(array_shift($coord));
61
-	$coord_y = !$coord  ? 0 : intval(array_shift($coord));
23
+    preg_match(",^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i", $p->nom_champ, $regs);
24
+    $type = strtolower($regs[1]);
25
+    $suite_logo = $regs[2];
26
+
27
+    // cas de #LOGO_SITE_SPIP
28
+    if ($type == 'site_spip') {
29
+        $type = 'site';
30
+        $_id_objet = "\"'0'\"";
31
+    }
32
+
33
+    $id_objet = id_table_objet($type);
34
+    if (!isset($_id_objet) OR !$_id_objet)
35
+        $_id_objet = champ_sql($id_objet, $p);
36
+
37
+    $fichier = ($p->etoile === '**') ? -1 : 0;
38
+    $coord = array();
39
+    $align = $lien = '';
40
+    $mode_logo = '';
41
+
42
+    if ($p->param AND !$p->param[0][0]) {
43
+        $params = $p->param[0];
44
+        array_shift($params);
45
+        foreach($params as $a) {
46
+            if ($a[0]->type === 'texte') {
47
+                $n = $a[0]->texte;
48
+                if (is_numeric($n))
49
+                    $coord[]= $n;
50
+                elseif (in_array($n,array('top','left','right','center','bottom')))
51
+                    $align = $n;
52
+                elseif (in_array($n,array('auto','icone','apercu','vignette')))
53
+                    $mode_logo = $n;
54
+            }
55
+            else $lien =  calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
56
+
57
+        }
58
+    }
59
+
60
+    $coord_x = !$coord  ? 0 : intval(array_shift($coord));
61
+    $coord_y = !$coord  ? 0 : intval(array_shift($coord));
62 62
 	
63
-	if ($p->etoile === '*') {
64
-		include_spip('balise/url_');
65
-		$lien = generer_generer_url_arg($type, $p, $_id_objet);
66
-	}
67
-
68
-	$connect = $p->id_boucle ?$p->boucles[$p->id_boucle]->sql_serveur :'';
69
-	if ($type == 'document') {
70
-		$qconnect = _q($connect);
71
-		$doc = "quete_document($_id_objet, $qconnect)";
72
-		if ($fichier)
73
-			$code = "quete_logo_file($doc, $qconnect)";
74
-		else $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
75
-		// (x=non-faux ? y : '') pour affecter x en retournant y
76
-		if ($p->descr['documents'])
77
-		  $code = '(($doublons["documents"] .= ",". '
78
-		    . $_id_objet
79
-		    . ") ? $code : '')";
80
-	}
81
-	elseif ($connect) {
82
-		$code = "''";
83
-		spip_log("Les logos distants ne sont pas prevus");
84
-	} else {
85
-		$code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
86
-	}
87
-
88
-	// demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
89
-	if ($coord_x OR $coord_y) {
90
-		$code = "filtrer('image_graver',filtrer('image_reduire',".$code.", '$coord_x', '$coord_y'))"; 
91
-	} 
92
-
93
-	$p->code = $code;
94
-	$p->interdire_scripts = false;
95
-	return $p;
63
+    if ($p->etoile === '*') {
64
+        include_spip('balise/url_');
65
+        $lien = generer_generer_url_arg($type, $p, $_id_objet);
66
+    }
67
+
68
+    $connect = $p->id_boucle ?$p->boucles[$p->id_boucle]->sql_serveur :'';
69
+    if ($type == 'document') {
70
+        $qconnect = _q($connect);
71
+        $doc = "quete_document($_id_objet, $qconnect)";
72
+        if ($fichier)
73
+            $code = "quete_logo_file($doc, $qconnect)";
74
+        else $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
75
+        // (x=non-faux ? y : '') pour affecter x en retournant y
76
+        if ($p->descr['documents'])
77
+            $code = '(($doublons["documents"] .= ",". '
78
+            . $_id_objet
79
+            . ") ? $code : '')";
80
+    }
81
+    elseif ($connect) {
82
+        $code = "''";
83
+        spip_log("Les logos distants ne sont pas prevus");
84
+    } else {
85
+        $code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
86
+    }
87
+
88
+    // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
89
+    if ($coord_x OR $coord_y) {
90
+        $code = "filtrer('image_graver',filtrer('image_reduire',".$code.", '$coord_x', '$coord_y'))"; 
91
+    } 
92
+
93
+    $p->code = $code;
94
+    $p->interdire_scripts = false;
95
+    return $p;
96 96
 }
97 97
 
98 98
 function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite)
99 99
 {
100
-	$code = "quete_logo('$id_objet', '" .
101
-		(($suite == '_SURVOL') ? 'off' : 
102
-		(($suite == '_NORMAL') ? 'on' : 'ON')) .
103
-		"', $_id_objet," .
104
-		(($suite == '_RUBRIQUE') ? 
105
-		champ_sql("id_rubrique", $p) :
106
-		(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
107
-		", " . intval($fichier) . ")";
100
+    $code = "quete_logo('$id_objet', '" .
101
+        (($suite == '_SURVOL') ? 'off' : 
102
+        (($suite == '_NORMAL') ? 'on' : 'ON')) .
103
+        "', $_id_objet," .
104
+        (($suite == '_RUBRIQUE') ? 
105
+        champ_sql("id_rubrique", $p) :
106
+        (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
107
+        ", " . intval($fichier) . ")";
108 108
 
109
-	if ($fichier) return $code;
109
+    if ($fichier) return $code;
110 110
 
111
-	$code = "\n((!is_array(\$l = $code)) ? '':\n (" .
112
-		     '"<img class=\"spip_logos\" alt=\"\"' .
113
-		    ($align ? " align=\\\"$align\\\"" : '')
114
-		    . ' src=\"$l[0]\"" . $l[2] .  ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))';
111
+    $code = "\n((!is_array(\$l = $code)) ? '':\n (" .
112
+                '"<img class=\"spip_logos\" alt=\"\"' .
113
+            ($align ? " align=\\\"$align\\\"" : '')
114
+            . ' src=\"$l[0]\"" . $l[2] .  ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))';
115 115
 
116
-	if (!$lien) return $code;
116
+    if (!$lien) return $code;
117 117
 
118
-	return ('(strlen($logo='.$code.')?\'<a href="\' .' . $lien . ' . \'">\' . $logo . \'</a>\':\'\')');
118
+    return ('(strlen($logo='.$code.')?\'<a href="\' .' . $lien . ' . \'">\' . $logo . \'</a>\':\'\')');
119 119
 
120 120
 }
121 121
 
Please login to merge, or discard this patch.
ecrire/balise/menu_lang_ecrire.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -37,6 +37,9 @@
 block discarded – undo
37 37
 }
38 38
 
39 39
 // http://doc.spip.org/@menu_lang_pour_tous
40
+/**
41
+ * @param string $nom
42
+ */
40 43
 function menu_lang_pour_tous($nom, $default) {
41 44
 	include_spip('inc/lang');
42 45
 
Please login to merge, or discard this patch.
ecrire/base/upgrade.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -231,6 +231,9 @@
 block discarded – undo
231 231
 
232 232
 // pour versions <= 1.926
233 233
 // http://doc.spip.org/@upgrade_vers
234
+/**
235
+ * @param double $version
236
+ */
234 237
 function upgrade_vers($version, $version_installee, $version_cible = 0){
235 238
 	return ($version_installee<$version
236 239
 		AND (($version_cible>=$version) OR ($version_cible==0))
Please login to merge, or discard this patch.
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -30,38 +30,38 @@  discard block
 block discarded – undo
30 30
  */
31 31
 function base_upgrade_dist($titre='', $reprise='')
32 32
 {
33
-	if (!$titre) return; // anti-testeur automatique
34
-	if ($GLOBALS['spip_version_base']!=$GLOBALS['meta']['version_installee']) {
35
-		if (!is_numeric(_request('reinstall'))) {
36
-			include_spip('base/create');
37
-			spip_log("recree les tables eventuellement disparues","maj."._LOG_INFO_IMPORTANTE);
38
-			creer_base();
39
-		}
33
+    if (!$titre) return; // anti-testeur automatique
34
+    if ($GLOBALS['spip_version_base']!=$GLOBALS['meta']['version_installee']) {
35
+        if (!is_numeric(_request('reinstall'))) {
36
+            include_spip('base/create');
37
+            spip_log("recree les tables eventuellement disparues","maj."._LOG_INFO_IMPORTANTE);
38
+            creer_base();
39
+        }
40 40
 		
41
-		// quand on rentre par ici, c'est toujours une mise a jour de SPIP
42
-		// lancement de l'upgrade SPIP
43
-		$res = maj_base();
41
+        // quand on rentre par ici, c'est toujours une mise a jour de SPIP
42
+        // lancement de l'upgrade SPIP
43
+        $res = maj_base();
44 44
 
45
-		if ($res) {
46
-			// on arrete tout ici !
47
-			exit;
48
-		}
49
-	}
50
-	spip_log("Fin de mise a jour SQL. Debut m-a-j acces et config","maj."._LOG_INFO_IMPORTANTE);
45
+        if ($res) {
46
+            // on arrete tout ici !
47
+            exit;
48
+        }
49
+    }
50
+    spip_log("Fin de mise a jour SQL. Debut m-a-j acces et config","maj."._LOG_INFO_IMPORTANTE);
51 51
 	
52
-	// supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
53
-	@spip_unlink(_CACHE_RUBRIQUES);
54
-	@spip_unlink(_CACHE_PIPELINES);
55
-	@spip_unlink(_CACHE_PLUGINS_PATH);
56
-	@spip_unlink(_CACHE_PLUGINS_OPT);
57
-	@spip_unlink(_CACHE_PLUGINS_FCT);
58
-	@spip_unlink(_CACHE_CHEMIN);
59
-	@spip_unlink(_DIR_TMP."plugin_xml_cache.gz");
52
+    // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
53
+    @spip_unlink(_CACHE_RUBRIQUES);
54
+    @spip_unlink(_CACHE_PIPELINES);
55
+    @spip_unlink(_CACHE_PLUGINS_PATH);
56
+    @spip_unlink(_CACHE_PLUGINS_OPT);
57
+    @spip_unlink(_CACHE_PLUGINS_FCT);
58
+    @spip_unlink(_CACHE_CHEMIN);
59
+    @spip_unlink(_DIR_TMP."plugin_xml_cache.gz");
60 60
 
61
-	include_spip('inc/auth');
62
-	auth_synchroniser_distant();
63
-	$config = charger_fonction('config', 'inc');
64
-	$config();
61
+    include_spip('inc/auth');
62
+    auth_synchroniser_distant();
63
+    $config = charger_fonction('config', 'inc');
64
+    $config();
65 65
 }
66 66
 
67 67
 /**
@@ -74,63 +74,63 @@  discard block
 block discarded – undo
74 74
  * @return array|bool
75 75
  */
76 76
 function maj_base($version_cible = 0, $redirect = '') {
77
-	global $spip_version_base;
77
+    global $spip_version_base;
78 78
 
79
-	$version_installee = @$GLOBALS['meta']['version_installee'];
80
-	//
81
-	// Si version nulle ou inexistante, c'est une nouvelle installation
82
-	//   => ne pas passer par le processus de mise a jour.
83
-	// De meme en cas de version superieure: ca devait etre un test,
84
-	// il y a eu le message d'avertissement il doit savoir ce qu'il fait
85
-	//
86
-	// version_installee = 1.702; quand on a besoin de forcer une MAJ
79
+    $version_installee = @$GLOBALS['meta']['version_installee'];
80
+    //
81
+    // Si version nulle ou inexistante, c'est une nouvelle installation
82
+    //   => ne pas passer par le processus de mise a jour.
83
+    // De meme en cas de version superieure: ca devait etre un test,
84
+    // il y a eu le message d'avertissement il doit savoir ce qu'il fait
85
+    //
86
+    // version_installee = 1.702; quand on a besoin de forcer une MAJ
87 87
 	
88
-	spip_log("Version anterieure: $version_installee. Courante: $spip_version_base","maj."._LOG_INFO_IMPORTANTE);
89
-	if (!$version_installee OR ($spip_version_base < $version_installee)) {
90
-		sql_replace('spip_meta', 
91
-		      array('nom' => 'version_installee',
92
-			    'valeur' => $spip_version_base,
93
-			    'impt' => 'non'));
94
-		return false;
95
-	}
96
-	if (!upgrade_test()) return true;
88
+    spip_log("Version anterieure: $version_installee. Courante: $spip_version_base","maj."._LOG_INFO_IMPORTANTE);
89
+    if (!$version_installee OR ($spip_version_base < $version_installee)) {
90
+        sql_replace('spip_meta', 
91
+                array('nom' => 'version_installee',
92
+                'valeur' => $spip_version_base,
93
+                'impt' => 'non'));
94
+        return false;
95
+    }
96
+    if (!upgrade_test()) return true;
97 97
 	
98
-	$cible = ($version_cible ? $version_cible : $spip_version_base);
98
+    $cible = ($version_cible ? $version_cible : $spip_version_base);
99 99
 
100
-	if ($version_installee <= 1.926) {
101
-		$n = floor($version_installee * 10);
102
-		while ($n < 19) {
103
-			$nom  = sprintf("v%03d",$n);
104
-			$f = charger_fonction($nom, 'maj', true);
105
-			if ($f) {
106
-				spip_log( "$f repercute les modifications de la version " . ($n/10),"maj."._LOG_INFO_IMPORTANTE);
107
-				$f($version_installee, $spip_version_base);
108
-			} else spip_log( "pas de fonction pour la maj $n $nom","maj."._LOG_INFO_IMPORTANTE);
109
-			$n++;
110
-		}
111
-		include_spip('maj/v019_pre193');
112
-		v019_pre193($version_installee, $version_cible);
113
-	}
114
-	if ($version_installee < 2000) {
115
-		if ($version_installee < 2)
116
-			$version_installee = $version_installee*1000;
117
-		include_spip('maj/v019');
118
-	}
119
-	if ($cible < 2)
120
-		$cible = $cible*1000;
100
+    if ($version_installee <= 1.926) {
101
+        $n = floor($version_installee * 10);
102
+        while ($n < 19) {
103
+            $nom  = sprintf("v%03d",$n);
104
+            $f = charger_fonction($nom, 'maj', true);
105
+            if ($f) {
106
+                spip_log( "$f repercute les modifications de la version " . ($n/10),"maj."._LOG_INFO_IMPORTANTE);
107
+                $f($version_installee, $spip_version_base);
108
+            } else spip_log( "pas de fonction pour la maj $n $nom","maj."._LOG_INFO_IMPORTANTE);
109
+            $n++;
110
+        }
111
+        include_spip('maj/v019_pre193');
112
+        v019_pre193($version_installee, $version_cible);
113
+    }
114
+    if ($version_installee < 2000) {
115
+        if ($version_installee < 2)
116
+            $version_installee = $version_installee*1000;
117
+        include_spip('maj/v019');
118
+    }
119
+    if ($cible < 2)
120
+        $cible = $cible*1000;
121 121
 
122
-	include_spip('maj/svn10000');
123
-	ksort($GLOBALS['maj']);
124
-	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee','meta', $redirect, true);
125
-	if ($res) {
126
-		if (!is_array($res))
127
-			spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
128
-		else {
129
-			echo _T('avis_operation_echec') . ' ' . join(' ', $res);
130
-			echo install_fin_html();
131
-		}
132
-	}
133
-	return $res;
122
+    include_spip('maj/svn10000');
123
+    ksort($GLOBALS['maj']);
124
+    $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee','meta', $redirect, true);
125
+    if ($res) {
126
+        if (!is_array($res))
127
+            spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
128
+        else {
129
+            echo _T('avis_operation_echec') . ' ' . join(' ', $res);
130
+            echo install_fin_html();
131
+        }
132
+    }
133
+    return $res;
134 134
 }
135 135
 
136 136
 /**
@@ -166,48 +166,48 @@  discard block
 block discarded – undo
166 166
  */
167 167
 function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta='meta'){
168 168
 
169
-	if ($table_meta!=='meta')
170
-		lire_metas($table_meta);
171
-	if ( (!isset($GLOBALS[$table_meta][$nom_meta_base_version]) )
172
-			|| (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version],$version_cible,'='))){
169
+    if ($table_meta!=='meta')
170
+        lire_metas($table_meta);
171
+    if ( (!isset($GLOBALS[$table_meta][$nom_meta_base_version]) )
172
+            || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version],$version_cible,'='))){
173 173
 
174
-		// $maj['create'] contient les directives propres a la premiere creation de base
175
-		// c'est une operation derogatoire qui fait aboutir directement dans la version_cible
176
-		if (isset($maj['create'])){
177
-			if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])){
178
-				// installation : on ne fait que l'operation create
179
-				$maj = array("init"=>$maj['create']);
180
-				// et on lui ajoute un appel a inc/config
181
-				// pour creer les metas par defaut
182
-				$config = charger_fonction('config','inc');
183
-				$maj[$version_cible] = array(array($config));
184
-			}
185
-			// dans tous les cas enlever cet index du tableau
186
-			unset($maj['create']);
187
-		}
188
-		// si init, deja dans le bon ordre
189
-		if (!isset($maj['init'])){
190
-			include_spip('inc/plugin'); // pour spip_version_compare
191
-			uksort($maj,'spip_version_compare');
192
-		}
174
+        // $maj['create'] contient les directives propres a la premiere creation de base
175
+        // c'est une operation derogatoire qui fait aboutir directement dans la version_cible
176
+        if (isset($maj['create'])){
177
+            if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])){
178
+                // installation : on ne fait que l'operation create
179
+                $maj = array("init"=>$maj['create']);
180
+                // et on lui ajoute un appel a inc/config
181
+                // pour creer les metas par defaut
182
+                $config = charger_fonction('config','inc');
183
+                $maj[$version_cible] = array(array($config));
184
+            }
185
+            // dans tous les cas enlever cet index du tableau
186
+            unset($maj['create']);
187
+        }
188
+        // si init, deja dans le bon ordre
189
+        if (!isset($maj['init'])){
190
+            include_spip('inc/plugin'); // pour spip_version_compare
191
+            uksort($maj,'spip_version_compare');
192
+        }
193 193
 
194
-		// la redirection se fait par defaut sur la page d'administration des plugins
195
-		// sauf lorsque nous sommes sur l'installation de SPIP
196
-		// ou define _REDIRECT_MAJ_PLUGIN
197
-		$redirect = (defined('_REDIRECT_MAJ_PLUGIN')?_REDIRECT_MAJ_PLUGIN:generer_url_ecrire('admin_plugin'));
198
-		if (defined('_ECRIRE_INSTALL')) {
199
-			$redirect = parametre_url(generer_url_ecrire('install'),'etape', _request('etape'));
200
-		}
194
+        // la redirection se fait par defaut sur la page d'administration des plugins
195
+        // sauf lorsque nous sommes sur l'installation de SPIP
196
+        // ou define _REDIRECT_MAJ_PLUGIN
197
+        $redirect = (defined('_REDIRECT_MAJ_PLUGIN')?_REDIRECT_MAJ_PLUGIN:generer_url_ecrire('admin_plugin'));
198
+        if (defined('_ECRIRE_INSTALL')) {
199
+            $redirect = parametre_url(generer_url_ecrire('install'),'etape', _request('etape'));
200
+        }
201 201
 		
202
-		$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
203
-		if ($res) {
204
-			if (!is_array($res))
205
-				spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
206
-			else {
207
-				echo "<p>"._T('avis_operation_echec') . ' ' . join(' ', $res)."</p>";
208
-			}
209
-		}
210
-	}
202
+        $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
203
+        if ($res) {
204
+            if (!is_array($res))
205
+                spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
206
+            else {
207
+                echo "<p>"._T('avis_operation_echec') . ' ' . join(' ', $res)."</p>";
208
+            }
209
+        }
210
+    }
211 211
 }
212 212
 
213 213
 /**
@@ -221,17 +221,17 @@  discard block
 block discarded – undo
221 221
  * @return void
222 222
  */
223 223
 function relance_maj($meta,$table,$redirect=''){
224
-	include_spip('inc/headers');
225
-	if (!$redirect){
226
-		// recuperer la valeur installee en cours
227
-		// on la tronque numeriquement, elle ne sert pas reellement
228
-		// sauf pour verifier que ce n'est pas oui ou non
229
-		// sinon is_numeric va echouer sur un numero de version 1.2.3
230
-		$installee = intval($GLOBALS[$table][$meta]);
231
-		$redirect = generer_url_ecrire('upgrade',"reinstall=$installee&meta=$meta&table=$table",true);
232
-	}
233
-	echo redirige_formulaire($redirect);
234
-	exit();
224
+    include_spip('inc/headers');
225
+    if (!$redirect){
226
+        // recuperer la valeur installee en cours
227
+        // on la tronque numeriquement, elle ne sert pas reellement
228
+        // sauf pour verifier que ce n'est pas oui ou non
229
+        // sinon is_numeric va echouer sur un numero de version 1.2.3
230
+        $installee = intval($GLOBALS[$table][$meta]);
231
+        $redirect = generer_url_ecrire('upgrade',"reinstall=$installee&meta=$meta&table=$table",true);
232
+    }
233
+    echo redirige_formulaire($redirect);
234
+    exit();
235 235
 }
236 236
 
237 237
 /**
@@ -244,21 +244,21 @@  discard block
 block discarded – undo
244 244
  * @return
245 245
  */
246 246
 function maj_debut_page($installee,$meta,$table){
247
-	static $done = false;
248
-	if ($done) return;
249
-	include_spip('inc/minipres');
250
-	@ini_set("zlib.output_compression","0"); // pour permettre l'affichage au fur et a mesure
251
-	$timeout = _UPGRADE_TIME_OUT*2;
252
-	$titre = _T('titre_page_upgrade');
253
-	$balise_img = charger_filtre('balise_img');
254
-	$titre .= $balise_img(chemin_image('searching.gif'));
255
-	echo ( install_debut_html($titre));
256
-	// script de rechargement auto sur timeout
257
-	$redirect = generer_url_ecrire('upgrade',"reinstall=$installee&meta=$meta&table=$table",true);
258
-	echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout*1000).")");
259
-	echo "<div style='text-align: left'>\n";
260
-	ob_flush();flush();
261
-	$done = true;
247
+    static $done = false;
248
+    if ($done) return;
249
+    include_spip('inc/minipres');
250
+    @ini_set("zlib.output_compression","0"); // pour permettre l'affichage au fur et a mesure
251
+    $timeout = _UPGRADE_TIME_OUT*2;
252
+    $titre = _T('titre_page_upgrade');
253
+    $balise_img = charger_filtre('balise_img');
254
+    $titre .= $balise_img(chemin_image('searching.gif'));
255
+    echo ( install_debut_html($titre));
256
+    // script de rechargement auto sur timeout
257
+    $redirect = generer_url_ecrire('upgrade',"reinstall=$installee&meta=$meta&table=$table",true);
258
+    echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout*1000).")");
259
+    echo "<div style='text-align: left'>\n";
260
+    ob_flush();flush();
261
+    $done = true;
262 262
 }
263 263
 
264 264
 define('_UPGRADE_TIME_OUT', 20);
@@ -298,46 +298,46 @@  discard block
 block discarded – undo
298 298
  */
299 299
 function maj_while($installee, $cible, $maj, $meta='', $table='meta', $redirect='', $debut_page = false)
300 300
 {
301
-	# inclusions pour que les procedures d'upgrade disposent des fonctions de base
302
-	include_spip('base/create');
303
-	include_spip('base/abstract_sql');
304
-	$trouver_table = charger_fonction('trouver_table','base');
305
-	include_spip('inc/plugin'); // pour spip_version_compare
306
-	$n = 0;
307
-	$time = time();
308
-	// definir le timeout qui peut etre utilise dans les fonctions
309
-	// de maj qui durent trop longtemps
310
-	define('_TIME_OUT',$time+_UPGRADE_TIME_OUT);
301
+    # inclusions pour que les procedures d'upgrade disposent des fonctions de base
302
+    include_spip('base/create');
303
+    include_spip('base/abstract_sql');
304
+    $trouver_table = charger_fonction('trouver_table','base');
305
+    include_spip('inc/plugin'); // pour spip_version_compare
306
+    $n = 0;
307
+    $time = time();
308
+    // definir le timeout qui peut etre utilise dans les fonctions
309
+    // de maj qui durent trop longtemps
310
+    define('_TIME_OUT',$time+_UPGRADE_TIME_OUT);
311 311
 
312
-	reset($maj);
313
-	while (list($v,)=each($maj)) {
314
-		// si une maj pour cette version
315
-		if ($v=='init' OR
316
-			(spip_version_compare($v,$installee,'>')
317
-			AND spip_version_compare($v,$cible,'<='))) {
318
-			if ($debut_page)
319
-				maj_debut_page($v,$meta,$table);
320
-			echo "MAJ $v";
321
-			$etape = serie_alter($v, $maj[$v], $meta, $table, $redirect);
322
-			$trouver_table(''); // vider le cache des descriptions de table
323
-			# echec sur une etape en cours ?
324
-			# on sort
325
-			if ($etape) return array($v, $etape);
326
-			$n = time() - $time;
327
-			spip_log( "$table $meta: $v en $n secondes",'maj.'._LOG_INFO_IMPORTANTE);
328
-			if ($meta) ecrire_meta($meta, $installee=$v,'oui', $table);
329
-			echo "<br />";
330
-		}
331
-		if (time() >= _TIME_OUT) {
332
-			relance_maj($meta,$table,$redirect);
333
-		}
334
-	}
335
-	$trouver_table(''); // vider le cache des descriptions de table
336
-	// indispensable pour les chgt de versions qui n'ecrivent pas en base
337
-	// tant pis pour la redondance eventuelle avec ci-dessus
338
-	if ($meta) ecrire_meta($meta, $cible,'oui',$table);
339
-	spip_log( "MAJ terminee. $meta: $installee",'maj.'._LOG_INFO_IMPORTANTE);
340
-	return array();
312
+    reset($maj);
313
+    while (list($v,)=each($maj)) {
314
+        // si une maj pour cette version
315
+        if ($v=='init' OR
316
+            (spip_version_compare($v,$installee,'>')
317
+            AND spip_version_compare($v,$cible,'<='))) {
318
+            if ($debut_page)
319
+                maj_debut_page($v,$meta,$table);
320
+            echo "MAJ $v";
321
+            $etape = serie_alter($v, $maj[$v], $meta, $table, $redirect);
322
+            $trouver_table(''); // vider le cache des descriptions de table
323
+            # echec sur une etape en cours ?
324
+            # on sort
325
+            if ($etape) return array($v, $etape);
326
+            $n = time() - $time;
327
+            spip_log( "$table $meta: $v en $n secondes",'maj.'._LOG_INFO_IMPORTANTE);
328
+            if ($meta) ecrire_meta($meta, $installee=$v,'oui', $table);
329
+            echo "<br />";
330
+        }
331
+        if (time() >= _TIME_OUT) {
332
+            relance_maj($meta,$table,$redirect);
333
+        }
334
+    }
335
+    $trouver_table(''); // vider le cache des descriptions de table
336
+    // indispensable pour les chgt de versions qui n'ecrivent pas en base
337
+    // tant pis pour la redondance eventuelle avec ci-dessus
338
+    if ($meta) ecrire_meta($meta, $cible,'oui',$table);
339
+    spip_log( "MAJ terminee. $meta: $installee",'maj.'._LOG_INFO_IMPORTANTE);
340
+    return array();
341 341
 }
342 342
 
343 343
 /**
@@ -359,45 +359,45 @@  discard block
 block discarded – undo
359 359
  * @return int
360 360
  */
361 361
 function serie_alter($serie, $q = array(), $meta='', $table='meta', $redirect='') {
362
-	$meta2 = $meta . '_maj_' . $serie;
363
-	$etape = intval(@$GLOBALS[$table][$meta2]);
364
-	foreach ($q as $i => $r) {
365
-		if ($i >= $etape) {
366
-			$msg = "maj $table $meta2 etape $i";
367
-			if (is_array($r)
368
-			  AND function_exists($f = array_shift($r))) {
369
-				spip_log( "$msg: $f " . join(',',$r),'maj.'._LOG_INFO_IMPORTANTE);
370
-				// pour les fonctions atomiques sql_xx
371
-				// on enregistre le meta avant de lancer la fonction,
372
-				// de maniere a eviter de boucler sur timeout
373
-				// mais pour les fonctions complexes,
374
-				// il faut les rejouer jusqu'a achevement.
375
-				// C'est a elle d'assurer qu'elles progressent a chaque rappel
376
-				if (strncmp($f,"sql_",4)==0)
377
-					ecrire_meta($meta2, $i+1, 'non', $table);
378
-				echo " <span title='$i'>.</span>";
379
-				call_user_func_array($f, $r);
380
-				// si temps imparti depasse, on relance sans ecrire en meta
381
-				// car on est peut etre sorti sur timeout si c'est une fonction longue
382
-				if (time() >= _TIME_OUT) {
383
-					relance_maj($meta,$table,$redirect);
384
-				}
385
-				ecrire_meta($meta2, $i+1, 'non', $table);
386
-				spip_log( "$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE);
387
-			}
388
-			else {
389
-				if (!is_array($r))
390
-					spip_log("maj $i format incorrect","maj."._LOG_ERREUR);
391
-				else
392
-					spip_log("maj $i fonction $f non definie","maj."._LOG_ERREUR);
393
-				// en cas d'erreur serieuse, on s'arrete
394
-				// mais on permet de passer par dessus en rechargeant la page.
395
-				return $i+1;
396
-			}
397
-		}
398
-	}
399
-	effacer_meta($meta2, $table);
400
-	return 0;
362
+    $meta2 = $meta . '_maj_' . $serie;
363
+    $etape = intval(@$GLOBALS[$table][$meta2]);
364
+    foreach ($q as $i => $r) {
365
+        if ($i >= $etape) {
366
+            $msg = "maj $table $meta2 etape $i";
367
+            if (is_array($r)
368
+              AND function_exists($f = array_shift($r))) {
369
+                spip_log( "$msg: $f " . join(',',$r),'maj.'._LOG_INFO_IMPORTANTE);
370
+                // pour les fonctions atomiques sql_xx
371
+                // on enregistre le meta avant de lancer la fonction,
372
+                // de maniere a eviter de boucler sur timeout
373
+                // mais pour les fonctions complexes,
374
+                // il faut les rejouer jusqu'a achevement.
375
+                // C'est a elle d'assurer qu'elles progressent a chaque rappel
376
+                if (strncmp($f,"sql_",4)==0)
377
+                    ecrire_meta($meta2, $i+1, 'non', $table);
378
+                echo " <span title='$i'>.</span>";
379
+                call_user_func_array($f, $r);
380
+                // si temps imparti depasse, on relance sans ecrire en meta
381
+                // car on est peut etre sorti sur timeout si c'est une fonction longue
382
+                if (time() >= _TIME_OUT) {
383
+                    relance_maj($meta,$table,$redirect);
384
+                }
385
+                ecrire_meta($meta2, $i+1, 'non', $table);
386
+                spip_log( "$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE);
387
+            }
388
+            else {
389
+                if (!is_array($r))
390
+                    spip_log("maj $i format incorrect","maj."._LOG_ERREUR);
391
+                else
392
+                    spip_log("maj $i fonction $f non definie","maj."._LOG_ERREUR);
393
+                // en cas d'erreur serieuse, on s'arrete
394
+                // mais on permet de passer par dessus en rechargeant la page.
395
+                return $i+1;
396
+            }
397
+        }
398
+    }
399
+    effacer_meta($meta2, $table);
400
+    return 0;
401 401
 }
402 402
 
403 403
 
@@ -407,49 +407,49 @@  discard block
 block discarded – undo
407 407
 
408 408
 // http://doc.spip.org/@upgrade_types_documents
409 409
 function upgrade_types_documents() {
410
-	if (include_spip('base/medias')
411
-	AND function_exists('creer_base_types_doc'))
412
-		creer_base_types_doc();
410
+    if (include_spip('base/medias')
411
+    AND function_exists('creer_base_types_doc'))
412
+        creer_base_types_doc();
413 413
 }
414 414
 
415 415
 // http://doc.spip.org/@upgrade_test
416 416
 function upgrade_test() {
417
-	sql_drop_table("spip_test", true);
418
-	sql_create("spip_test", array('a' => 'int'));
419
-	sql_alter("TABLE spip_test ADD b INT");
420
-	sql_insertq('spip_test', array('b' => 1), array('field'=>array('b' => 'int')));
421
-	$result = sql_select('b', "spip_test");
422
-	// ne pas garder le resultat de la requete sinon sqlite3 
423
-	// ne peut pas supprimer la table spip_test lors du sql_alter qui suit
424
-	// car cette table serait alors 'verouillee'
425
-	$result = $result?true:false; 
426
-	sql_alter("TABLE spip_test DROP b");
427
-	return $result;
417
+    sql_drop_table("spip_test", true);
418
+    sql_create("spip_test", array('a' => 'int'));
419
+    sql_alter("TABLE spip_test ADD b INT");
420
+    sql_insertq('spip_test', array('b' => 1), array('field'=>array('b' => 'int')));
421
+    $result = sql_select('b', "spip_test");
422
+    // ne pas garder le resultat de la requete sinon sqlite3 
423
+    // ne peut pas supprimer la table spip_test lors du sql_alter qui suit
424
+    // car cette table serait alors 'verouillee'
425
+    $result = $result?true:false; 
426
+    sql_alter("TABLE spip_test DROP b");
427
+    return $result;
428 428
 }
429 429
 
430 430
 // pour versions <= 1.926
431 431
 // http://doc.spip.org/@maj_version
432 432
 function maj_version ($version, $test = true) {
433
-	if ($test) {
434
-		if ($version>=1.922)
435
-			ecrire_meta('version_installee', $version, 'oui');
436
-		else {
437
-			// on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
438
-			$GLOBALS['meta']['version_installee'] = $version;
439
-			sql_updateq('spip_meta',  array('valeur' => $version), "nom=" . sql_quote('version_installee') );
440
-		}
441
-		spip_log( "mise a jour de la base en $version","maj."._LOG_INFO_IMPORTANTE);
442
-	} else {
443
-		echo _T('alerte_maj_impossible', array('version' => $version));
444
-		exit;
445
-	}
433
+    if ($test) {
434
+        if ($version>=1.922)
435
+            ecrire_meta('version_installee', $version, 'oui');
436
+        else {
437
+            // on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
438
+            $GLOBALS['meta']['version_installee'] = $version;
439
+            sql_updateq('spip_meta',  array('valeur' => $version), "nom=" . sql_quote('version_installee') );
440
+        }
441
+        spip_log( "mise a jour de la base en $version","maj."._LOG_INFO_IMPORTANTE);
442
+    } else {
443
+        echo _T('alerte_maj_impossible', array('version' => $version));
444
+        exit;
445
+    }
446 446
 }
447 447
 
448 448
 // pour versions <= 1.926
449 449
 // http://doc.spip.org/@upgrade_vers
450 450
 function upgrade_vers($version, $version_installee, $version_cible = 0){
451
-	return ($version_installee<$version
452
-		AND (($version_cible>=$version) OR ($version_cible==0))
453
-	);
451
+    return ($version_installee<$version
452
+        AND (($version_cible>=$version) OR ($version_cible==0))
453
+    );
454 454
 }
455 455
 ?>
Please login to merge, or discard this patch.
ecrire/genie/mise_a_jour.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -34,6 +34,10 @@  discard block
 block discarded – undo
34 34
 define('_VERSIONS_SERVEUR', 'http://files.spip.org/');
35 35
 define('_VERSIONS_LISTE', 'archives.xml');
36 36
 
37
+/**
38
+ * @param string $dir
39
+ * @param string $file
40
+ */
37 41
 function info_maj ($dir, $file, $version){
38 42
 	include_spip('inc/plugin');
39 43
 	
@@ -67,6 +71,11 @@  discard block
 block discarded – undo
67 71
 // on teste la nouveaute par If-Modified-Since,
68 72
 // et seulement quand celui-ci a change' pour limiter les acces HTTP
69 73
 
74
+/**
75
+ * @param string $nom
76
+ *
77
+ * @return string
78
+ */
70 79
 function info_maj_cache($nom, $dir, $page='')
71 80
 {
72 81
 	$re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">';
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
  * @return int
20 20
  */
21 21
 function genie_mise_a_jour_dist($t) {
22
-	include_spip('inc/meta');
23
-	$maj = info_maj ('spip', 'SPIP', $GLOBALS['spip_version_branche']);
24
-	ecrire_meta('info_maj_spip',$maj?($GLOBALS['spip_version_branche']."|$maj"):"",'non');
22
+    include_spip('inc/meta');
23
+    $maj = info_maj ('spip', 'SPIP', $GLOBALS['spip_version_branche']);
24
+    ecrire_meta('info_maj_spip',$maj?($GLOBALS['spip_version_branche']."|$maj"):"",'non');
25 25
 
26
-	spip_log("Verification version SPIP : ".($maj?$maj:"version a jour"),"verifie_maj");
27
-	return 1;
26
+    spip_log("Verification version SPIP : ".($maj?$maj:"version a jour"),"verifie_maj");
27
+    return 1;
28 28
 }
29 29
 
30 30
 
@@ -35,32 +35,32 @@  discard block
 block discarded – undo
35 35
 define('_VERSIONS_LISTE', 'archives.xml');
36 36
 
37 37
 function info_maj ($dir, $file, $version){
38
-	include_spip('inc/plugin');
38
+    include_spip('inc/plugin');
39 39
 	
40
-	list($maj,$min,$rev) = preg_split('/\D+/', $version);
40
+    list($maj,$min,$rev) = preg_split('/\D+/', $version);
41 41
 
42
-	$nom = _DIR_CACHE_XML . _VERSIONS_LISTE;
43
-	$page = !file_exists($nom) ? '' : file_get_contents($nom);
44
-	$page = info_maj_cache($nom, $dir, $page);
42
+    $nom = _DIR_CACHE_XML . _VERSIONS_LISTE;
43
+    $page = !file_exists($nom) ? '' : file_get_contents($nom);
44
+    $page = info_maj_cache($nom, $dir, $page);
45 45
 
46
-	// reperer toutes les versions de numero majeur superieur ou egal
47
-	// (a revoir quand on arrivera a SPIP V10 ...)
48
-	$p = substr("0123456789", intval($maj));
49
-	$p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i';
50
-	preg_match_all($p, $page, $m,  PREG_SET_ORDER);
51
-	$page = '';
52
-	foreach ($m as $v) {
53
-		list(, $maj2, $min2,, $rev2) = $v;
54
-		$version_maj = $maj2 . '.' . $min2 . '.' . $rev2;
55
-		if ((spip_version_compare($version, $version_maj, '<'))
56
-		AND (spip_version_compare($page, $version_maj, '<')))
57
-			$page = $version_maj;
58
-	}
46
+    // reperer toutes les versions de numero majeur superieur ou egal
47
+    // (a revoir quand on arrivera a SPIP V10 ...)
48
+    $p = substr("0123456789", intval($maj));
49
+    $p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i';
50
+    preg_match_all($p, $page, $m,  PREG_SET_ORDER);
51
+    $page = '';
52
+    foreach ($m as $v) {
53
+        list(, $maj2, $min2,, $rev2) = $v;
54
+        $version_maj = $maj2 . '.' . $min2 . '.' . $rev2;
55
+        if ((spip_version_compare($version, $version_maj, '<'))
56
+        AND (spip_version_compare($page, $version_maj, '<')))
57
+            $page = $version_maj;
58
+    }
59 59
 
60
-	if (!$page) return "";
61
-	return "<a class='info_maj_spip' href='"._VERSIONS_SERVEUR."$dir' title='$page'>" .
62
-		_T('nouvelle_version_spip',array('version'=>$page)) .
63
-	    '</a>';
60
+    if (!$page) return "";
61
+    return "<a class='info_maj_spip' href='"._VERSIONS_SERVEUR."$dir' title='$page'>" .
62
+        _T('nouvelle_version_spip',array('version'=>$page)) .
63
+        '</a>';
64 64
 }
65 65
 
66 66
 // Verifie que la liste $page des versions dans le fichier $nom est a jour
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
 
71 71
 function info_maj_cache($nom, $dir, $page='')
72 72
 {
73
-	$re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">';
74
-	if (preg_match("/$re/", $page)) return $page;
73
+    $re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">';
74
+    if (preg_match("/$re/", $page)) return $page;
75 75
 
76
-	$url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE;
77
-	$a = file_exists($nom) ? filemtime($nom) : '';
78
-	include_spip('inc/distant');
79
-	$res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '',false, $a);
80
-	// Si rien de neuf (ou inaccessible), garder l'ancienne
81
-	if ($res) list(, $page) = $res;
82
-	// Placer l'indicateur de fraicheur
83
-	$page = preg_replace('/^<archives.*?>/', $re, $page);
84
-	sous_repertoire(_DIR_CACHE_XML);
85
-	ecrire_fichier($nom, $page);
86
-	return $page;
76
+    $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE;
77
+    $a = file_exists($nom) ? filemtime($nom) : '';
78
+    include_spip('inc/distant');
79
+    $res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '',false, $a);
80
+    // Si rien de neuf (ou inaccessible), garder l'ancienne
81
+    if ($res) list(, $page) = $res;
82
+    // Placer l'indicateur de fraicheur
83
+    $page = preg_replace('/^<archives.*?>/', $re, $page);
84
+    sous_repertoire(_DIR_CACHE_XML);
85
+    ecrire_fichier($nom, $page);
86
+    return $page;
87 87
 }
88 88
 
89 89
 ?>
Please login to merge, or discard this patch.
ecrire/inc/filtres_images_mini.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -14,6 +14,9 @@
 block discarded – undo
14 14
 include_spip('inc/filtres_images_lib_mini'); // par precaution
15 15
 
16 16
 // http://doc.spip.org/@couleur_html_to_hex
17
+/**
18
+ * @param string $couleur
19
+ */
17 20
 function couleur_html_to_hex($couleur){
18 21
 	$couleurs_html=array(
19 22
 		'aqua'=>'00FFFF','black'=>'000000','blue'=>'0000FF','fuchsia'=>'FF00FF','gray'=>'808080','green'=>'008000','lime'=>'00FF00','maroon'=>'800000',
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -15,38 +15,38 @@  discard block
 block discarded – undo
15 15
 
16 16
 // http://doc.spip.org/@couleur_html_to_hex
17 17
 function couleur_html_to_hex($couleur){
18
-	$couleurs_html=array(
19
-		'aqua'=>'00FFFF','black'=>'000000','blue'=>'0000FF','fuchsia'=>'FF00FF','gray'=>'808080','green'=>'008000','lime'=>'00FF00','maroon'=>'800000',
20
-		'navy'=>'000080','olive'=>'808000','purple'=>'800080','red'=>'FF0000','silver'=>'C0C0C0','teal'=>'008080','white'=>'FFFFFF','yellow'=>'FFFF00');
21
-	if (isset($couleurs_html[$lc=strtolower($couleur)]))
22
-		return $couleurs_html[$lc];
23
-	return $couleur;
18
+    $couleurs_html=array(
19
+        'aqua'=>'00FFFF','black'=>'000000','blue'=>'0000FF','fuchsia'=>'FF00FF','gray'=>'808080','green'=>'008000','lime'=>'00FF00','maroon'=>'800000',
20
+        'navy'=>'000080','olive'=>'808000','purple'=>'800080','red'=>'FF0000','silver'=>'C0C0C0','teal'=>'008080','white'=>'FFFFFF','yellow'=>'FFFF00');
21
+    if (isset($couleurs_html[$lc=strtolower($couleur)]))
22
+        return $couleurs_html[$lc];
23
+    return $couleur;
24 24
 }
25 25
 
26 26
 // http://doc.spip.org/@couleur_foncer
27 27
 function couleur_foncer ($couleur, $coeff=0.5) {
28
-	$couleurs = _couleur_hex_to_dec($couleur);
28
+    $couleurs = _couleur_hex_to_dec($couleur);
29 29
 
30
-	$red = $couleurs["red"] - round(($couleurs["red"])*$coeff);
31
-	$green = $couleurs["green"] - round(($couleurs["green"])*$coeff);
32
-	$blue = $couleurs["blue"] - round(($couleurs["blue"])*$coeff);
30
+    $red = $couleurs["red"] - round(($couleurs["red"])*$coeff);
31
+    $green = $couleurs["green"] - round(($couleurs["green"])*$coeff);
32
+    $blue = $couleurs["blue"] - round(($couleurs["blue"])*$coeff);
33 33
 
34
-	$couleur = _couleur_dec_to_hex($red, $green, $blue);
34
+    $couleur = _couleur_dec_to_hex($red, $green, $blue);
35 35
 	
36
-	return $couleur;
36
+    return $couleur;
37 37
 }
38 38
 
39 39
 // http://doc.spip.org/@couleur_eclaircir
40 40
 function couleur_eclaircir ($couleur, $coeff=0.5) {
41
-	$couleurs = _couleur_hex_to_dec($couleur);
41
+    $couleurs = _couleur_hex_to_dec($couleur);
42 42
 
43
-	$red = $couleurs["red"] + round((255 - $couleurs["red"])*$coeff);
44
-	$green = $couleurs["green"] + round((255 - $couleurs["green"])*$coeff);
45
-	$blue = $couleurs["blue"] + round((255 - $couleurs["blue"])*$coeff);
43
+    $red = $couleurs["red"] + round((255 - $couleurs["red"])*$coeff);
44
+    $green = $couleurs["green"] + round((255 - $couleurs["green"])*$coeff);
45
+    $blue = $couleurs["blue"] + round((255 - $couleurs["blue"])*$coeff);
46 46
 
47
-	$couleur = _couleur_dec_to_hex($red, $green, $blue);
47
+    $couleur = _couleur_dec_to_hex($red, $green, $blue);
48 48
 	
49
-	return $couleur;
49
+    return $couleur;
50 50
 
51 51
 }
52 52
 
@@ -55,81 +55,81 @@  discard block
 block discarded – undo
55 55
 // dans la fonction image_filtrer
56 56
 // http://doc.spip.org/@image_select
57 57
 function image_select($img,$width_min=0, $height_min=0, $width_max=10000, $height_max=1000){
58
-	if (!$img) return $img;
59
-	list ($h,$l) = taille_image($img);
60
-	$select = true;
61
-	if ($l<$width_min OR $l>$width_max OR $h<$height_min OR $h>$height_max)
62
-		$select = false;
63
-
64
-	$class = extraire_attribut($img,'class');
65
-	$p = strpos($class,'no_image_filtrer');
66
-	if (($select==false) AND ($p===FALSE)){
67
-		$class .= " no_image_filtrer";
68
-		$img = inserer_attribut($img,'class',$class);
69
-	}
70
-	if (($select==true) AND ($p!==FALSE)){
71
-		$class = preg_replace(",\s*no_image_filtrer,","",$class);
72
-		$img = inserer_attribut($img,'class',$class);
73
-	}
74
-	return $img;
58
+    if (!$img) return $img;
59
+    list ($h,$l) = taille_image($img);
60
+    $select = true;
61
+    if ($l<$width_min OR $l>$width_max OR $h<$height_min OR $h>$height_max)
62
+        $select = false;
63
+
64
+    $class = extraire_attribut($img,'class');
65
+    $p = strpos($class,'no_image_filtrer');
66
+    if (($select==false) AND ($p===FALSE)){
67
+        $class .= " no_image_filtrer";
68
+        $img = inserer_attribut($img,'class',$class);
69
+    }
70
+    if (($select==true) AND ($p!==FALSE)){
71
+        $class = preg_replace(",\s*no_image_filtrer,","",$class);
72
+        $img = inserer_attribut($img,'class',$class);
73
+    }
74
+    return $img;
75 75
 }
76 76
 
77 77
 
78 78
 // http://doc.spip.org/@image_passe_partout
79 79
 function image_passe_partout($img,$taille_x = -1, $taille_y = -1,$force = false,$cherche_image=false,$process='AUTO'){
80
-	if (!$img) return '';
81
-	list ($hauteur,$largeur) = taille_image($img);
82
-	if ($taille_x == -1)
83
-		$taille_x = isset($GLOBALS['meta']['taille_preview'])?$GLOBALS['meta']['taille_preview']:150;
84
-	if ($taille_y == -1)
85
-		$taille_y = $taille_x;
86
-
87
-	if ($taille_x == 0 AND $taille_y > 0)
88
-		$taille_x = 1; # {0,300} -> c'est 300 qui compte
89
-	elseif ($taille_x > 0 AND $taille_y == 0)
90
-		$taille_y = 1; # {300,0} -> c'est 300 qui compte
91
-	elseif ($taille_x == 0 AND $taille_y == 0)
92
-		return '';
80
+    if (!$img) return '';
81
+    list ($hauteur,$largeur) = taille_image($img);
82
+    if ($taille_x == -1)
83
+        $taille_x = isset($GLOBALS['meta']['taille_preview'])?$GLOBALS['meta']['taille_preview']:150;
84
+    if ($taille_y == -1)
85
+        $taille_y = $taille_x;
86
+
87
+    if ($taille_x == 0 AND $taille_y > 0)
88
+        $taille_x = 1; # {0,300} -> c'est 300 qui compte
89
+    elseif ($taille_x > 0 AND $taille_y == 0)
90
+        $taille_y = 1; # {300,0} -> c'est 300 qui compte
91
+    elseif ($taille_x == 0 AND $taille_y == 0)
92
+        return '';
93 93
 	
94
-	list($destWidth,$destHeight,$ratio) = ratio_passe_partout($largeur,$hauteur,$taille_x,$taille_y);
95
-	$fonction = array('image_passe_partout', func_get_args());
96
-	return process_image_reduire($fonction,$img,$destWidth,$destHeight,$force,$cherche_image,$process);
94
+    list($destWidth,$destHeight,$ratio) = ratio_passe_partout($largeur,$hauteur,$taille_x,$taille_y);
95
+    $fonction = array('image_passe_partout', func_get_args());
96
+    return process_image_reduire($fonction,$img,$destWidth,$destHeight,$force,$cherche_image,$process);
97 97
 }
98 98
 
99 99
 // http://doc.spip.org/@image_reduire
100 100
 function image_reduire($img, $taille = -1, $taille_y = -1, $force=false, $cherche_image=false, $process='AUTO') {
101
-	// Determiner la taille x,y maxi
102
-	// prendre le reglage de previsu par defaut
103
-	if ($taille == -1)
104
-		$taille = (isset($GLOBALS['meta']['taille_preview']) AND intval($GLOBALS['meta']['taille_preview']))?intval($GLOBALS['meta']['taille_preview']):150;
105
-	if ($taille_y == -1)
106
-		$taille_y = $taille;
107
-
108
-	if ($taille == 0 AND $taille_y > 0)
109
-		$taille = 10000; # {0,300} -> c'est 300 qui compte
110
-	elseif ($taille > 0 AND $taille_y == 0)
111
-		$taille_y = 10000; # {300,0} -> c'est 300 qui compte
112
-	elseif ($taille == 0 AND $taille_y == 0)
113
-		return '';
114
-
115
-	$fonction = array('image_reduire', func_get_args());
116
-	return process_image_reduire($fonction,$img,$taille,$taille_y,$force,$cherche_image,$process);
101
+    // Determiner la taille x,y maxi
102
+    // prendre le reglage de previsu par defaut
103
+    if ($taille == -1)
104
+        $taille = (isset($GLOBALS['meta']['taille_preview']) AND intval($GLOBALS['meta']['taille_preview']))?intval($GLOBALS['meta']['taille_preview']):150;
105
+    if ($taille_y == -1)
106
+        $taille_y = $taille;
107
+
108
+    if ($taille == 0 AND $taille_y > 0)
109
+        $taille = 10000; # {0,300} -> c'est 300 qui compte
110
+    elseif ($taille > 0 AND $taille_y == 0)
111
+        $taille_y = 10000; # {300,0} -> c'est 300 qui compte
112
+    elseif ($taille == 0 AND $taille_y == 0)
113
+        return '';
114
+
115
+    $fonction = array('image_reduire', func_get_args());
116
+    return process_image_reduire($fonction,$img,$taille,$taille_y,$force,$cherche_image,$process);
117 117
 }
118 118
 
119 119
 // Reduire une image d'un certain facteur
120 120
 // http://doc.spip.org/@image_reduire_par
121 121
 function image_reduire_par ($img, $val=1, $force=false) {
122
-	list ($hauteur,$largeur) = taille_image($img);
122
+    list ($hauteur,$largeur) = taille_image($img);
123 123
 
124
-	$l = round($largeur/$val);
125
-	$h = round($hauteur/$val);
124
+    $l = round($largeur/$val);
125
+    $h = round($hauteur/$val);
126 126
 	
127
-	if ($l > $h) $h = 0;
128
-	else $l = 0;
127
+    if ($l > $h) $h = 0;
128
+    else $l = 0;
129 129
 	
130
-	$img = image_reduire($img, $l, $h, $force);
130
+    $img = image_reduire($img, $l, $h, $force);
131 131
 
132
-	return $img;
132
+    return $img;
133 133
 }
134 134
 
135 135
 ?>
Please login to merge, or discard this patch.
ecrire/inc/headers.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -125,6 +125,9 @@
 block discarded – undo
125 125
 }
126 126
 
127 127
 // http://doc.spip.org/@http_status
128
+/**
129
+ * @param integer $status
130
+ */
128 131
 function http_status($status) {
129 132
 	global $REDIRECT_STATUS, $flag_sapi_name;
130 133
 	static $status_string = array(
Please login to merge, or discard this patch.
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -18,160 +18,160 @@
 block discarded – undo
18 18
 
19 19
 // http://doc.spip.org/@redirige_par_entete
20 20
 function redirige_par_entete($url, $equiv='', $status = 302) {
21
-	if (!in_array($status,array(301,302)))
22
-		$status = 302;
23
-
24
-	$url = trim(strtr($url, "\n\r", "  "));
25
-	# en theorie on devrait faire ca tout le temps, mais quand la chaine
26
-	# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
27
-	if ($url[0]=='?')
28
-		$url = url_de_base().$url;
29
-	if ($url[0]=='#')
30
-		$url = self('&').$url;
31
-	# si profondeur non nulle et url relative, il faut la passer en absolue
32
-	if ($GLOBALS['profondeur_url']>(_DIR_RESTREINT?1:2)
33
-		AND !preg_match(",^(\w+:)?//,",$url)){
34
-		include_spip("inc/filtres_mini");
35
-		$url = url_absolue($url);
36
-	}
37
-
38
-	if ($x = _request('transformer_xml'))
39
-		$url = parametre_url($url, 'transformer_xml', $x, '&');
40
-
41
-	if (defined('_AJAX') AND _AJAX)
42
-		$url = parametre_url($url, 'var_ajax_redir', 1, '&');
21
+    if (!in_array($status,array(301,302)))
22
+        $status = 302;
23
+
24
+    $url = trim(strtr($url, "\n\r", "  "));
25
+    # en theorie on devrait faire ca tout le temps, mais quand la chaine
26
+    # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
27
+    if ($url[0]=='?')
28
+        $url = url_de_base().$url;
29
+    if ($url[0]=='#')
30
+        $url = self('&').$url;
31
+    # si profondeur non nulle et url relative, il faut la passer en absolue
32
+    if ($GLOBALS['profondeur_url']>(_DIR_RESTREINT?1:2)
33
+        AND !preg_match(",^(\w+:)?//,",$url)){
34
+        include_spip("inc/filtres_mini");
35
+        $url = url_absolue($url);
36
+    }
37
+
38
+    if ($x = _request('transformer_xml'))
39
+        $url = parametre_url($url, 'transformer_xml', $x, '&');
40
+
41
+    if (defined('_AJAX') AND _AJAX)
42
+        $url = parametre_url($url, 'var_ajax_redir', 1, '&');
43 43
 		
44
-	// ne pas laisser passer n'importe quoi dans l'url
45
-	$url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
46
-	// interdire les url inline avec des pseudo-protocoles :
47
-	if (
48
-		(preg_match(",data:,i",$url) AND preg_match("/base64\s*,/i",$url))
49
-		OR preg_match(",(javascript|mailto):,i",$url)
50
-		)
51
-		$url ="./";
52
-
53
-	// Il n'y a que sous Apache que setcookie puis redirection fonctionne
54
-  include_spip('inc/cookie');
55
-	if ((!$equiv AND !spip_cookie_envoye()) OR ((strncmp("Apache", $_SERVER['SERVER_SOFTWARE'],6)==0) OR defined('_SERVER_APACHE'))) {
56
-		@header("Location: " . $url);
57
-		$equiv="";
58
-	} else {
59
-		@header("Refresh: 0; url=" . $url);
60
-		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
61
-	}
62
-	include_spip('inc/lang');
63
-	if ($status!=302)
64
-		http_status($status);
65
-	echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n",
66
-	  html_lang_attributes(),'
44
+    // ne pas laisser passer n'importe quoi dans l'url
45
+    $url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
46
+    // interdire les url inline avec des pseudo-protocoles :
47
+    if (
48
+        (preg_match(",data:,i",$url) AND preg_match("/base64\s*,/i",$url))
49
+        OR preg_match(",(javascript|mailto):,i",$url)
50
+        )
51
+        $url ="./";
52
+
53
+    // Il n'y a que sous Apache que setcookie puis redirection fonctionne
54
+    include_spip('inc/cookie');
55
+    if ((!$equiv AND !spip_cookie_envoye()) OR ((strncmp("Apache", $_SERVER['SERVER_SOFTWARE'],6)==0) OR defined('_SERVER_APACHE'))) {
56
+        @header("Location: " . $url);
57
+        $equiv="";
58
+    } else {
59
+        @header("Refresh: 0; url=" . $url);
60
+        $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
61
+    }
62
+    include_spip('inc/lang');
63
+    if ($status!=302)
64
+        http_status($status);
65
+    echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n",
66
+        html_lang_attributes(),'
67 67
 <head>',
68
-	  $equiv,'
68
+        $equiv,'
69 69
 <title>HTTP '.$status.'</title>
70 70
 </head>
71 71
 <body>
72 72
 <h1>HTTP '.$status.'</h1>
73 73
 <a href="',
74
-	  quote_amp($url),
75
-	  '">',
76
-	  _T('navigateur_pas_redirige'),
77
-	  '</a></body></html>';
74
+        quote_amp($url),
75
+        '">',
76
+        _T('navigateur_pas_redirige'),
77
+        '</a></body></html>';
78 78
 
79
-	spip_log("redirige $status: $url");
79
+    spip_log("redirige $status: $url");
80 80
 
81
-	exit;
81
+    exit;
82 82
 }
83 83
 
84 84
 // http://doc.spip.org/@redirige_formulaire
85 85
 function redirige_formulaire($url, $equiv = '', $format='message') {
86
-	if (!_AJAX
87
-	AND !headers_sent()
88
-	AND !_request('var_ajax')) {
89
-		redirige_par_entete(str_replace('&amp;','&',$url), $equiv);
90
-	}
91
-	// si c'est une ancre, fixer simplement le window.location.hash
92
-	elseif($format=='ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i',$url)) {
93
-		return array(
94
-		// on renvoie un lien masque qui sera traite par ajaxCallback.js
95
-		"<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
96
-		// et rien dans le message ok
97
-		'');
98
-	}
99
-	else {
100
-		// ne pas laisser passer n'importe quoi dans l'url
101
-		$url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
102
-
103
-		$url = strtr($url, "\n\r", "  ");
104
-		# en theorie on devrait faire ca tout le temps, mais quand la chaine
105
-		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
106
-		if ($url[0]=='?')
107
-			$url = url_de_base().$url;
108
-		$url = str_replace('&amp;','&',$url);
109
-		spip_log("redirige formulaire ajax: $url");
110
-		include_spip('inc/filtres');
111
-		if ($format=='ajaxform')
112
-			return array(
113
-			// on renvoie un lien masque qui sera traite par ajaxCallback.js
114
-			'<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
115
-			// et un message au cas ou
116
-			'<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'
117
-			);
118
-		else // format message texte, tout en js inline
119
-			return
120
-		// ie poste les formulaires dans une iframe, il faut donc rediriger son parent
121
-		"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
122
-		. http_img_pack('searching.gif','')
123
-		. '<br />'
124
-		. '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
125
-	}
86
+    if (!_AJAX
87
+    AND !headers_sent()
88
+    AND !_request('var_ajax')) {
89
+        redirige_par_entete(str_replace('&amp;','&',$url), $equiv);
90
+    }
91
+    // si c'est une ancre, fixer simplement le window.location.hash
92
+    elseif($format=='ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i',$url)) {
93
+        return array(
94
+        // on renvoie un lien masque qui sera traite par ajaxCallback.js
95
+        "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
96
+        // et rien dans le message ok
97
+        '');
98
+    }
99
+    else {
100
+        // ne pas laisser passer n'importe quoi dans l'url
101
+        $url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
102
+
103
+        $url = strtr($url, "\n\r", "  ");
104
+        # en theorie on devrait faire ca tout le temps, mais quand la chaine
105
+        # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
106
+        if ($url[0]=='?')
107
+            $url = url_de_base().$url;
108
+        $url = str_replace('&amp;','&',$url);
109
+        spip_log("redirige formulaire ajax: $url");
110
+        include_spip('inc/filtres');
111
+        if ($format=='ajaxform')
112
+            return array(
113
+            // on renvoie un lien masque qui sera traite par ajaxCallback.js
114
+            '<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
115
+            // et un message au cas ou
116
+            '<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'
117
+            );
118
+        else // format message texte, tout en js inline
119
+            return
120
+        // ie poste les formulaires dans une iframe, il faut donc rediriger son parent
121
+        "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
122
+        . http_img_pack('searching.gif','')
123
+        . '<br />'
124
+        . '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
125
+    }
126 126
 }
127 127
 
128 128
 // http://doc.spip.org/@redirige_url_ecrire
129 129
 function redirige_url_ecrire($script='', $args='', $equiv='') {
130
-	return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
130
+    return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
131 131
 }
132 132
 
133 133
 // http://doc.spip.org/@http_status
134 134
 function http_status($status) {
135
-	global $REDIRECT_STATUS, $flag_sapi_name;
136
-	static $status_string = array(
137
-		200 => '200 OK',
138
-		204 => '204 No Content',
139
-		301 => '301 Moved Permanently',
140
-		302 => '302 Found',
141
-		304 => '304 Not Modified',
142
-		401 => '401 Unauthorized',
143
-		403 => '403 Forbidden',
144
-		404 => '404 Not Found',
145
-		503 => '503 Service Unavailable'
146
-	);
147
-
148
-	if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return;
149
-
150
-	$php_cgi = ($flag_sapi_name AND preg_match(",cgi,i", @php_sapi_name()));
151
-	if ($php_cgi)
152
-		header("Status: ".$status_string[$status]);
153
-	else
154
-		header("HTTP/1.0 ".$status_string[$status]);
135
+    global $REDIRECT_STATUS, $flag_sapi_name;
136
+    static $status_string = array(
137
+        200 => '200 OK',
138
+        204 => '204 No Content',
139
+        301 => '301 Moved Permanently',
140
+        302 => '302 Found',
141
+        304 => '304 Not Modified',
142
+        401 => '401 Unauthorized',
143
+        403 => '403 Forbidden',
144
+        404 => '404 Not Found',
145
+        503 => '503 Service Unavailable'
146
+    );
147
+
148
+    if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return;
149
+
150
+    $php_cgi = ($flag_sapi_name AND preg_match(",cgi,i", @php_sapi_name()));
151
+    if ($php_cgi)
152
+        header("Status: ".$status_string[$status]);
153
+    else
154
+        header("HTTP/1.0 ".$status_string[$status]);
155 155
 }
156 156
 
157 157
 // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache
158 158
 // http://doc.spip.org/@http_no_cache
159 159
 function http_no_cache() {
160
-	if (headers_sent())
161
-		{ spip_log("http_no_cache arrive trop tard"); return;}
162
-	$charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
163
-
164
-	// selon http://developer.apple.com/internet/safari/faq.html#anchor5
165
-	// il faudrait aussi pour Safari
166
-	// header("Cache-Control: post-check=0, pre-check=0", false)
167
-	// mais ca ne respecte pas
168
-	// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
169
-
170
-	header("Content-Type: text/html; charset=$charset");
171
-	header("Expires: 0");
172
-	header("Last-Modified: " .gmdate("D, d M Y H:i:s"). " GMT");
173
-	header("Cache-Control: no-cache, must-revalidate");
174
-	header("Pragma: no-cache");
160
+    if (headers_sent())
161
+        { spip_log("http_no_cache arrive trop tard"); return;}
162
+    $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
163
+
164
+    // selon http://developer.apple.com/internet/safari/faq.html#anchor5
165
+    // il faudrait aussi pour Safari
166
+    // header("Cache-Control: post-check=0, pre-check=0", false)
167
+    // mais ca ne respecte pas
168
+    // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
169
+
170
+    header("Content-Type: text/html; charset=$charset");
171
+    header("Expires: 0");
172
+    header("Last-Modified: " .gmdate("D, d M Y H:i:s"). " GMT");
173
+    header("Cache-Control: no-cache, must-revalidate");
174
+    header("Pragma: no-cache");
175 175
 }
176 176
 
177 177
 ?>
Please login to merge, or discard this patch.
ecrire/inc/meta.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -107,6 +107,9 @@
 block discarded – undo
107 107
 }
108 108
 
109 109
 // http://doc.spip.org/@ecrire_meta
110
+/**
111
+ * @param string $importable
112
+ */
110 113
 function ecrire_meta($nom, $valeur, $importable = NULL, $table='meta') {
111 114
 
112 115
 	static $touch = array();
Please login to merge, or discard this patch.
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -21,36 +21,36 @@  discard block
 block discarded – undo
21 21
 // http://doc.spip.org/@inc_meta_dist
22 22
 function inc_meta_dist($table='meta')
23 23
 {
24
-	// Lire les meta, en cache si present, valide et lisible
25
-	// en cas d'install ne pas faire confiance au meta_cache eventuel
26
-	$cache = cache_meta($table);
27
-
28
-	if ((_request('exec')!=='install' OR !test_espace_prive())
29
-	AND $new = jeune_fichier($cache, _META_CACHE_TIME)
30
-	AND lire_fichier_securise($cache, $meta)
31
-	AND $meta = @unserialize($meta))
32
-		$GLOBALS[$table] = $meta;
33
-
34
-	if (isset($GLOBALS[$table]['touch']) 
35
-	AND ($GLOBALS[$table]['touch']<time()-_META_CACHE_TIME))
36
-		$GLOBALS[$table] = array();
37
-	// sinon lire en base
38
-	if (!$GLOBALS[$table]) $new = !lire_metas($table);
39
-
40
-	// renouveller l'alea general si trop vieux ou sur demande explicite
41
-	if ((test_espace_prive() || isset($_GET['renouvelle_alea']))
42
-	AND $GLOBALS[$table]
43
-	AND (time() > _RENOUVELLE_ALEA + $GLOBALS['meta']['alea_ephemere_date'])) {
44
-		// si on n'a pas l'acces en ecriture sur le cache,
45
-		// ne pas renouveller l'alea sinon le cache devient faux
46
-		if (supprimer_fichier($cache)) {
47
-			include_spip('inc/acces');
48
-			renouvelle_alea();
49
-			$new = false; 
50
-		} else spip_log("impossible d'ecrire dans " . $cache);
51
-	}
52
-	// et refaire le cache si on a du lire en base
53
-	if (!$new) touch_meta(false, $table);
24
+    // Lire les meta, en cache si present, valide et lisible
25
+    // en cas d'install ne pas faire confiance au meta_cache eventuel
26
+    $cache = cache_meta($table);
27
+
28
+    if ((_request('exec')!=='install' OR !test_espace_prive())
29
+    AND $new = jeune_fichier($cache, _META_CACHE_TIME)
30
+    AND lire_fichier_securise($cache, $meta)
31
+    AND $meta = @unserialize($meta))
32
+        $GLOBALS[$table] = $meta;
33
+
34
+    if (isset($GLOBALS[$table]['touch']) 
35
+    AND ($GLOBALS[$table]['touch']<time()-_META_CACHE_TIME))
36
+        $GLOBALS[$table] = array();
37
+    // sinon lire en base
38
+    if (!$GLOBALS[$table]) $new = !lire_metas($table);
39
+
40
+    // renouveller l'alea general si trop vieux ou sur demande explicite
41
+    if ((test_espace_prive() || isset($_GET['renouvelle_alea']))
42
+    AND $GLOBALS[$table]
43
+    AND (time() > _RENOUVELLE_ALEA + $GLOBALS['meta']['alea_ephemere_date'])) {
44
+        // si on n'a pas l'acces en ecriture sur le cache,
45
+        // ne pas renouveller l'alea sinon le cache devient faux
46
+        if (supprimer_fichier($cache)) {
47
+            include_spip('inc/acces');
48
+            renouvelle_alea();
49
+            $new = false; 
50
+        } else spip_log("impossible d'ecrire dans " . $cache);
51
+    }
52
+    // et refaire le cache si on a du lire en base
53
+    if (!$new) touch_meta(false, $table);
54 54
 }
55 55
 
56 56
 // fonctions aussi appelees a l'install ==> spip_query en premiere requete 
@@ -59,101 +59,101 @@  discard block
 block discarded – undo
59 59
 // http://doc.spip.org/@lire_metas
60 60
 function lire_metas($table='meta') {
61 61
 
62
-	if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
63
-		include_spip('base/abstract_sql');
64
-		$GLOBALS[$table] = array();
65
-		while ($row = sql_fetch($result))
66
-			$GLOBALS[$table][$row['nom']] = $row['valeur'];
62
+    if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
63
+        include_spip('base/abstract_sql');
64
+        $GLOBALS[$table] = array();
65
+        while ($row = sql_fetch($result))
66
+            $GLOBALS[$table][$row['nom']] = $row['valeur'];
67 67
         sql_free($result);
68 68
 
69
-		if (!$GLOBALS[$table]['charset']
70
-		  OR $GLOBALS[$table]['charset']=='_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
71
-		)
72
-			ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table);
73
-
74
-		// noter cette table de configuration dans les meta de SPIP
75
-		if ($table!=='meta') {
76
-			$liste = unserialize($GLOBALS['meta']['tables_config']);
77
-			if (!$liste)
78
-				$liste = array();
79
-			if (!in_array($table, $liste)) {
80
-				$liste[] = $table;
81
-				ecrire_meta('tables_config', serialize($liste));
82
-			}
83
-		}
84
-	}
85
-	return $GLOBALS[$table];
69
+        if (!$GLOBALS[$table]['charset']
70
+          OR $GLOBALS[$table]['charset']=='_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
71
+        )
72
+            ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table);
73
+
74
+        // noter cette table de configuration dans les meta de SPIP
75
+        if ($table!=='meta') {
76
+            $liste = unserialize($GLOBALS['meta']['tables_config']);
77
+            if (!$liste)
78
+                $liste = array();
79
+            if (!in_array($table, $liste)) {
80
+                $liste[] = $table;
81
+                ecrire_meta('tables_config', serialize($liste));
82
+            }
83
+        }
84
+    }
85
+    return $GLOBALS[$table];
86 86
 }
87 87
 
88 88
 // Mettre en cache la liste des meta, sauf les valeurs sensibles 
89 89
 // pour qu'elles ne soient pas visibiles dans un fichier.souvent en 777
90 90
 // http://doc.spip.org/@touch_meta
91 91
 function touch_meta($antidate= false, $table='meta'){
92
-	$file = cache_meta($table);
93
-	if (!$antidate OR !@touch($file, $antidate)) {
94
-		$r = $GLOBALS[$table];
95
-		unset($r['alea_ephemere']);
96
-		unset($r['alea_ephemere_ancien']);
97
-		// le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables
98
-		// mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
99
-		// meme si son squelette est en cache
100
-		//unset($r['secret_du_site']);
101
-		if ($antidate) $r['touch']= $antidate;
102
-		ecrire_fichier_securise($file, serialize($r));
103
-	}
92
+    $file = cache_meta($table);
93
+    if (!$antidate OR !@touch($file, $antidate)) {
94
+        $r = $GLOBALS[$table];
95
+        unset($r['alea_ephemere']);
96
+        unset($r['alea_ephemere_ancien']);
97
+        // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables
98
+        // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
99
+        // meme si son squelette est en cache
100
+        //unset($r['secret_du_site']);
101
+        if ($antidate) $r['touch']= $antidate;
102
+        ecrire_fichier_securise($file, serialize($r));
103
+    }
104 104
 }
105 105
 
106 106
 // http://doc.spip.org/@effacer_meta
107 107
 function effacer_meta($nom, $table='meta') {
108
-	// section critique sur le cache:
109
-	// l'invalider avant et apres la MAJ de la BD
110
-	// c'est un peu moins bien qu'un vrai verrou mais ca suffira
111
-	// et utiliser une statique pour eviter des acces disques a repetition
112
-	static $touch = array();
113
-	$antidate = time() - (_META_CACHE_TIME<<4);
114
-	if (!isset($touch[$table])) {touch_meta($antidate, $table);}
115
-	sql_delete('spip_' . $table, "nom='$nom'");
116
-	unset($GLOBALS[$table][$nom]);
117
-	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false;}
108
+    // section critique sur le cache:
109
+    // l'invalider avant et apres la MAJ de la BD
110
+    // c'est un peu moins bien qu'un vrai verrou mais ca suffira
111
+    // et utiliser une statique pour eviter des acces disques a repetition
112
+    static $touch = array();
113
+    $antidate = time() - (_META_CACHE_TIME<<4);
114
+    if (!isset($touch[$table])) {touch_meta($antidate, $table);}
115
+    sql_delete('spip_' . $table, "nom='$nom'");
116
+    unset($GLOBALS[$table][$nom]);
117
+    if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false;}
118 118
 }
119 119
 
120 120
 // http://doc.spip.org/@ecrire_meta
121 121
 function ecrire_meta($nom, $valeur, $importable = NULL, $table='meta') {
122 122
 
123
-	static $touch = array();
124
-	if (!$nom) return;
125
-	include_spip('base/abstract_sql');
126
-	$res = sql_select("*",'spip_' . $table,"nom=" . sql_quote($nom),'','','','','','continue');
127
-	// table pas encore installee, travailler en php seulement
128
-	if (!$res) {
129
-		$GLOBALS[$table][$nom] = $valeur;
130
-		return;
131
-	}
132
-	$row = sql_fetch($res);
123
+    static $touch = array();
124
+    if (!$nom) return;
125
+    include_spip('base/abstract_sql');
126
+    $res = sql_select("*",'spip_' . $table,"nom=" . sql_quote($nom),'','','','','','continue');
127
+    // table pas encore installee, travailler en php seulement
128
+    if (!$res) {
129
+        $GLOBALS[$table][$nom] = $valeur;
130
+        return;
131
+    }
132
+    $row = sql_fetch($res);
133 133
     sql_free($res);
134 134
 
135
-	// ne pas invalider le cache si affectation a l'identique
136
-	// (tant pis si impt aurait du changer)
137
-	if ($row AND $valeur == $row['valeur'] AND $GLOBALS[$table][$nom] == $valeur) return;
138
-
139
-	$GLOBALS[$table][$nom] = $valeur;
140
-	// cf effacer pour comprendre le double touch
141
-	$antidate = time() - (_META_CACHE_TIME<<1);
142
-	if (!isset($touch[$table])) {touch_meta($antidate, $table);}
143
-	$r = array('nom' => $nom, 'valeur' => $valeur);
144
-	// Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
145
-	if ($importable AND isset($row['impt'])) $r['impt'] = $importable;
146
-	if ($row) {
147
-		sql_updateq('spip_' . $table, $r,"nom=" . sql_quote($nom));
148
-	} else {
149
-		sql_insertq('spip_' . $table, $r);
150
-	}
151
-	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false;}
135
+    // ne pas invalider le cache si affectation a l'identique
136
+    // (tant pis si impt aurait du changer)
137
+    if ($row AND $valeur == $row['valeur'] AND $GLOBALS[$table][$nom] == $valeur) return;
138
+
139
+    $GLOBALS[$table][$nom] = $valeur;
140
+    // cf effacer pour comprendre le double touch
141
+    $antidate = time() - (_META_CACHE_TIME<<1);
142
+    if (!isset($touch[$table])) {touch_meta($antidate, $table);}
143
+    $r = array('nom' => $nom, 'valeur' => $valeur);
144
+    // Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
145
+    if ($importable AND isset($row['impt'])) $r['impt'] = $importable;
146
+    if ($row) {
147
+        sql_updateq('spip_' . $table, $r,"nom=" . sql_quote($nom));
148
+    } else {
149
+        sql_insertq('spip_' . $table, $r);
150
+    }
151
+    if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false;}
152 152
 }
153 153
 
154 154
 function cache_meta($table='meta')
155 155
 {
156
-	return ($table=='meta') ? _FILE_META : (_DIR_CACHE . $table . '.php');
156
+    return ($table=='meta') ? _FILE_META : (_DIR_CACHE . $table . '.php');
157 157
 }
158 158
 
159 159
 /**
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
  * @param string $table
162 162
  */
163 163
 function installer_table_meta($table) {
164
-	$trouver_table = charger_fonction('trouver_table','base');
165
-	if (!$trouver_table("spip_$table")) {
166
-		include_spip('base/auxiliaires');
167
-		include_spip('base/create');
168
-		creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false);
169
-		$trouver_table('');
170
-	}
171
-	lire_metas($table);
164
+    $trouver_table = charger_fonction('trouver_table','base');
165
+    if (!$trouver_table("spip_$table")) {
166
+        include_spip('base/auxiliaires');
167
+        include_spip('base/create');
168
+        creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false);
169
+        $trouver_table('');
170
+    }
171
+    lire_metas($table);
172 172
 }
173 173
 
174 174
 /**
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
  * @param bool $force
180 180
  */
181 181
 function supprimer_table_meta($table, $force=false) {
182
-	if ($table=='meta') return; // interdit !
183
-
184
-	if ($force OR !sql_countsel("spip_$table")) {
185
-		unset($GLOBALS[$table]);
186
-		sql_drop_table("spip_$table");
187
-		// vider le cache des tables
188
-		$trouver_table = charger_fonction('trouver_table','base');
189
-		$trouver_table('');
190
-	}
182
+    if ($table=='meta') return; // interdit !
183
+
184
+    if ($force OR !sql_countsel("spip_$table")) {
185
+        unset($GLOBALS[$table]);
186
+        sql_drop_table("spip_$table");
187
+        // vider le cache des tables
188
+        $trouver_table = charger_fonction('trouver_table','base');
189
+        $trouver_table('');
190
+    }
191 191
 }
192 192
 ?>
Please login to merge, or discard this patch.
ecrire/inc/selectionner.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -58,6 +58,12 @@
 block discarded – undo
58 58
 }
59 59
 
60 60
 // http://doc.spip.org/@construire_selectionner_hierarchie
61
+/**
62
+ * @param string $idom
63
+ * @param string|boolean $racine
64
+ * @param string $url
65
+ * @param string $name
66
+ */
61 67
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='')
62 68
 {
63 69
 	global $spip_lang_right;
Please login to merge, or discard this patch.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -21,106 +21,106 @@
 block discarded – undo
21 21
 // http://doc.spip.org/@inc_selectionner_dist
22 22
 function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') {
23 23
 
24
-	if ($recur) $recur = mini_hier($sel); else $sel = 0;
25
-
26
-	if ($aff_racine) {
27
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
28
-		$idom3 = $idom . "_selection";
29
-
30
-		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
31
-
32
-		$ondbClick = strtr(str_replace("'", "&#8217;",
33
-				str_replace('"', "&#34;",
34
-					textebrut(_T('info_racine_site')))),
35
-				"\n\r", "  ");
36
-
37
-		$js_func = $do . '_selection_titre';
38
-		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
39
-
40
-		$aff_racine = "<div class='petite-racine item'>"
41
-		. "<a href='#'"
42
-			. "onclick=\""
43
-			. $onClick
44
-			. "\"\nondbclick=\""
45
-			. $ondbClick
46
-			. $onClick
47
-		. "\">"
48
-		. _T("info_racine_site")
49
-		. "</a></div>";
50
-	}
51
-
52
-	$url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
53
-
54
-	$plonger = charger_fonction('plonger', 'inc');
55
-	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
56
-
57
-	// url completee par la fonction JS onkeypress_rechercher
58
-	$url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
59
-	return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
24
+    if ($recur) $recur = mini_hier($sel); else $sel = 0;
25
+
26
+    if ($aff_racine) {
27
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
28
+        $idom3 = $idom . "_selection";
29
+
30
+        $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
31
+
32
+        $ondbClick = strtr(str_replace("'", "&#8217;",
33
+                str_replace('"', "&#34;",
34
+                    textebrut(_T('info_racine_site')))),
35
+                "\n\r", "  ");
36
+
37
+        $js_func = $do . '_selection_titre';
38
+        $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
39
+
40
+        $aff_racine = "<div class='petite-racine item'>"
41
+        . "<a href='#'"
42
+            . "onclick=\""
43
+            . $onClick
44
+            . "\"\nondbclick=\""
45
+            . $ondbClick
46
+            . $onClick
47
+        . "\">"
48
+        . _T("info_racine_site")
49
+        . "</a></div>";
50
+    }
51
+
52
+    $url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
53
+
54
+    $plonger = charger_fonction('plonger', 'inc');
55
+    $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
56
+
57
+    // url completee par la fonction JS onkeypress_rechercher
58
+    $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
59
+    return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
60 60
 }
61 61
 
62 62
 // http://doc.spip.org/@construire_selectionner_hierarchie
63 63
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='')
64 64
 {
65
-	global $spip_lang_right;
66
-
67
-	$idom1 = $idom . "_champ_recherche";
68
-	$idom2 = $idom . "_principal";
69
-	$idom3 = $idom . "_selection";
70
-	$idom4 = $idom . "_col_1";
71
-	$idom5 = 'img_' . $idom4;
72
-	$idom6 = $idom."_fonc";
73
-
74
-	return "<div id='$idom'>"
75
-	. "<a id='$idom6' style='visibility: hidden;'"
76
-	. ($url_init ?  "\nhref='$url_init'" : '')
77
-	. "></a>"
78
-	. "<div class='recherche_rapide_parent'>"
79
-	. http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
80
-	. ""
81
-	. "<input style='width: 100px;float:$spip_lang_right;' type='search' id='$idom1'"
82
-	  // eliminer Return car il provoque la soumission (balise unique)
83
-	  // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
84
-	  // resultats retournes par la recherche
85
-	. "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3){return false;}\""
86
-	  // lancer la recherche apres le filtrage ci-dessus
87
-	. "\nonkeyup=\"return onkey_rechercher(this.value,"
88
-	  // la destination de la recherche
89
-	. "'$idom4'"
65
+    global $spip_lang_right;
66
+
67
+    $idom1 = $idom . "_champ_recherche";
68
+    $idom2 = $idom . "_principal";
69
+    $idom3 = $idom . "_selection";
70
+    $idom4 = $idom . "_col_1";
71
+    $idom5 = 'img_' . $idom4;
72
+    $idom6 = $idom."_fonc";
73
+
74
+    return "<div id='$idom'>"
75
+    . "<a id='$idom6' style='visibility: hidden;'"
76
+    . ($url_init ?  "\nhref='$url_init'" : '')
77
+    . "></a>"
78
+    . "<div class='recherche_rapide_parent'>"
79
+    . http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
80
+    . ""
81
+    . "<input style='width: 100px;float:$spip_lang_right;' type='search' id='$idom1'"
82
+        // eliminer Return car il provoque la soumission (balise unique)
83
+        // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
84
+        // resultats retournes par la recherche
85
+    . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3){return false;}\""
86
+        // lancer la recherche apres le filtrage ci-dessus
87
+    . "\nonkeyup=\"return onkey_rechercher(this.value,"
88
+        // la destination de la recherche
89
+    . "'$idom4'"
90 90
 #	. "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
91
-	. ",'"
92
-	  // l'url effectuant la recherche
93
-	. $url
94
-	. "',"	
95
-	  // le noeud contenant un gif anime 
96
-	  // . "'idom5'"
97
-	. "this.parentNode.previousSibling.firstChild"
98
-	. ",'"
99
-	  // la valeur de l'attribut Name a remplir
100
-	.  $name
101
-	. "','"
102
-	  // noeud invisible memorisant l'URL initiale (pour re-initialisation)
103
-	. $idom6
104
-	. "')\"" 
105
-	. " />"
106
-	. "\n</div>"
107
-	. ($racine?"<div>$racine</div>":"")
108
-	. "<div id='"
109
-	.  $idom2
110
-	.  "'><div id='$idom4'"
111
-	. " class=''>"
112
-	. $liste
113
-	. "</div></div>\n<div id='$idom3'></div></div>\n";
91
+    . ",'"
92
+        // l'url effectuant la recherche
93
+    . $url
94
+    . "',"	
95
+        // le noeud contenant un gif anime 
96
+        // . "'idom5'"
97
+    . "this.parentNode.previousSibling.firstChild"
98
+    . ",'"
99
+        // la valeur de l'attribut Name a remplir
100
+    .  $name
101
+    . "','"
102
+        // noeud invisible memorisant l'URL initiale (pour re-initialisation)
103
+    . $idom6
104
+    . "')\"" 
105
+    . " />"
106
+    . "\n</div>"
107
+    . ($racine?"<div>$racine</div>":"")
108
+    . "<div id='"
109
+    .  $idom2
110
+    .  "'><div id='$idom4'"
111
+    . " class=''>"
112
+    . $liste
113
+    . "</div></div>\n<div id='$idom3'></div></div>\n";
114 114
 }
115 115
 
116 116
 // http://doc.spip.org/@mini_hier
117 117
 function mini_hier ($id_rubrique) {
118 118
 	
119
-	$liste = $id_rubrique;
120
-	$id_rubrique = intval($id_rubrique);
121
-	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
122
-		$liste = $id_rubrique . ",$liste";
123
-	return explode(',',"0,$liste");
119
+    $liste = $id_rubrique;
120
+    $id_rubrique = intval($id_rubrique);
121
+    while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
122
+        $liste = $id_rubrique . ",$liste";
123
+    return explode(',',"0,$liste");
124 124
 }
125 125
 
126 126
 ?>
Please login to merge, or discard this patch.