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.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                            : ((defined('_NANO_SHA2_UPPER')) ? true : false);
84 84
 
85 85
             // Deteremine if the system is 32 or 64 bit.
86
-            $tmpInt = (int)4294967295;
86
+            $tmpInt = (int) 4294967295;
87 87
             $this->platform = ($tmpInt > 0) ? 64 : 32;
88 88
         }
89 89
 
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 
95 95
             if ($x < 0) {
96 96
                 $x &= 0x7FFFFFFF;
97
-                $x = (float)$x + $mask;
97
+                $x = (float) $x + $mask;
98 98
             }
99 99
 
100 100
             if ($y < 0) {
101 101
                 $y &= 0x7FFFFFFF;
102
-                $y = (float)$y + $mask;
102
+                $y = (float) $y + $mask;
103 103
             }
104 104
 
105 105
             $r = $x + $y;
@@ -110,52 +110,52 @@  discard block
 block discarded – undo
110 110
                 }
111 111
             }
112 112
 
113
-            return (int)$r;
113
+            return (int) $r;
114 114
         }
115 115
 
116 116
         // Logical bitwise right shift (PHP default is arithmetic shift)
117 117
         function SHR($x, $n)        // x >> n
118 118
         {
119 119
             if ($n >= 32) {      // impose some limits to keep it 32-bit
120
-                return (int)0;
120
+                return (int) 0;
121 121
             }
122 122
 
123 123
             if ($n <= 0) {
124
-                return (int)$x;
124
+                return (int) $x;
125 125
             }
126 126
 
127 127
             $mask = 0x40000000;
128 128
 
129 129
             if ($x < 0) {
130 130
                 $x &= 0x7FFFFFFF;
131
-                $mask = $mask >> ($n-1);
131
+                $mask = $mask >> ($n - 1);
132 132
                 return ($x >> $n) | $mask;
133 133
             }
134 134
 
135
-            return (int)$x >> (int)$n;
135
+            return (int) $x >> (int) $n;
136 136
         }
137 137
 
138
-        function ROTR($x, $n) { return (int)(($this->SHR($x, $n) | ($x << (32-$n)) & 0xFFFFFFFF)); }
138
+        function ROTR($x, $n) { return (int) (($this->SHR($x, $n) | ($x << (32 - $n)) & 0xFFFFFFFF)); }
139 139
         function Ch($x, $y, $z) { return ($x & $y) ^ ((~$x) & $z); }
140 140
         function Maj($x, $y, $z) { return ($x & $y) ^ ($x & $z) ^ ($y & $z); }
141
-        function Sigma0($x) { return (int) ($this->ROTR($x, 2)^$this->ROTR($x, 13)^$this->ROTR($x, 22)); }
142
-        function Sigma1($x) { return (int) ($this->ROTR($x, 6)^$this->ROTR($x, 11)^$this->ROTR($x, 25)); }
143
-        function sigma_0($x) { return (int) ($this->ROTR($x, 7)^$this->ROTR($x, 18)^$this->SHR($x, 3)); }
144
-        function sigma_1($x) { return (int) ($this->ROTR($x, 17)^$this->ROTR($x, 19)^$this->SHR($x, 10)); }
141
+        function Sigma0($x) { return (int) ($this->ROTR($x, 2) ^ $this->ROTR($x, 13) ^ $this->ROTR($x, 22)); }
142
+        function Sigma1($x) { return (int) ($this->ROTR($x, 6) ^ $this->ROTR($x, 11) ^ $this->ROTR($x, 25)); }
143
+        function sigma_0($x) { return (int) ($this->ROTR($x, 7) ^ $this->ROTR($x, 18) ^ $this->SHR($x, 3)); }
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){
147
+				function string2ordUTF8($s, &$byteSize) {
148 148
 					$chars = array();
149 149
 					// par defaut sur 8bits
150 150
 					$byteSize = 8;
151 151
 					$i = 0;
152
-					while ($i<strlen($s)){
152
+					while ($i < strlen($s)) {
153 153
 						$chars[] = $this->ordUTF8($s, $i, $bytes);
154
-						$i+=$bytes;
154
+						$i += $bytes;
155 155
 						// mais si un char necessite 16bits, on passe tout sur 16
156 156
 						// sinon on ne concorde pas avec le lecture de la chaine en js
157 157
 						// et le sha256 js
158
-						if ($bytes>1) $byteSize = 16;
158
+						if ($bytes > 1) $byteSize = 16;
159 159
 					}
160 160
 					return $chars;
161 161
 				}
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 						$bytes = 1;
175 175
 						return $h;
176 176
 					}
177
-					else if ($h < 0xC2){
177
+					else if ($h < 0xC2) {
178 178
 						// pas utf mais renvoyer quand meme ce qu'on a
179 179
 						$bytes = 1;
180 180
 						return $h;
181 181
 					}
182 182
 					else if ($h <= 0xDF && $index < $len - 1) {
183 183
 						$bytes = 2;
184
-						return ($h & 0x1F) <<  6 | (ord($c{$index + 1}) & 0x3F);
184
+						return ($h & 0x1F) << 6 | (ord($c{$index + 1}) & 0x3F);
185 185
 					}
186 186
 					else if ($h <= 0xEF && $index < $len - 2) {
187 187
 						$bytes = 3;
@@ -201,33 +201,33 @@  discard block
 block discarded – undo
201 201
 					}
202 202
 				}
203 203
 
204
-				function string2binint ($str,$npad=512) {
204
+				function string2binint($str, $npad = 512) {
205 205
 					$bin = array();
206
-					$ords = $this->string2ordUTF8($str,$this->bytesString);
207
-					$npad = $npad/$this->bytesString;
206
+					$ords = $this->string2ordUTF8($str, $this->bytesString);
207
+					$npad = $npad / $this->bytesString;
208 208
 					$length = count($ords);
209 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);
210
+					$pad = ceil(($length + 1 + 32 / $this->bytesString) / $npad) * $npad - 32 / $this->bytesString;
211
+					$ords = array_pad($ords, $pad, 0);
212 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);
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 216
 					}
217
-					$bin[] = $length*$this->bytesString;
217
+					$bin[] = $length * $this->bytesString;
218 218
 					return $bin;
219 219
 				}
220 220
 
221 221
 				function array_split($a, $n) {
222 222
 					$split = array();
223
-					while (count($a)>$n) {
223
+					while (count($a) > $n) {
224 224
 						$s = array();
225
-						for($i = 0;$i<$n;$i++)
225
+						for ($i = 0; $i < $n; $i++)
226 226
 							$s[] = array_shift($a);
227 227
 						$split[] = $s;
228 228
 					}
229
-					if (count($a)){
230
-						$a = array_pad($a,$n,0);
229
+					if (count($a)) {
230
+						$a = array_pad($a, $n, 0);
231 231
 						$split[] = $a;
232 232
 					}
233 233
 					return $split;
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
          */
243 243
         function hash($str, $ig_func = true)
244 244
         {
245
-            unset($binStr);     // binary representation of input string
246
-            unset($hexStr);     // 256-bit message digest in readable hex format
245
+            unset($binStr); // binary representation of input string
246
+            unset($hexStr); // 256-bit message digest in readable hex format
247 247
 
248 248
             // check for php's internal sha256 function, ignore if ig_func==true
249 249
             if ($ig_func == false) {
250
-                if (version_compare(PHP_VERSION,'5.1.2','>=') AND !defined('_NO_HASH_DEFINED')) {
250
+                if (version_compare(PHP_VERSION, '5.1.2', '>=') AND !defined('_NO_HASH_DEFINED')) {
251 251
                     return hash("sha256", $str, false);
252 252
                 } else if (function_exists('mhash') && defined('MHASH_SHA256')) {
253 253
                     return base64_encode(bin2hex(mhash(MHASH_SHA256, $str)));
@@ -260,44 +260,44 @@  discard block
 block discarded – undo
260 260
              *  first thirty-two bits of the fractional parts of the cube roots
261 261
              *  of the first sixtyfour prime numbers.
262 262
              */
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);
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);
285 285
 
286 286
             // Pre-processing: Padding the string
287
-            $binStr = $this->string2binint($str,512);
287
+            $binStr = $this->string2binint($str, 512);
288 288
 
289 289
             // Parsing the Padded Message (Break into N 512-bit blocks)
290 290
             $M = $this->array_split($binStr, 16);
291 291
 
292 292
             // Set the initial hash values
293
-            $h[0] = (int)0x6a09e667;
294
-            $h[1] = (int)0xbb67ae85;
295
-            $h[2] = (int)0x3c6ef372;
296
-            $h[3] = (int)0xa54ff53a;
297
-            $h[4] = (int)0x510e527f;
298
-            $h[5] = (int)0x9b05688c;
299
-            $h[6] = (int)0x1f83d9ab;
300
-            $h[7] = (int)0x5be0cd19;
293
+            $h[0] = (int) 0x6a09e667;
294
+            $h[1] = (int) 0xbb67ae85;
295
+            $h[2] = (int) 0x3c6ef372;
296
+            $h[3] = (int) 0xa54ff53a;
297
+            $h[4] = (int) 0x510e527f;
298
+            $h[5] = (int) 0x9b05688c;
299
+            $h[6] = (int) 0x1f83d9ab;
300
+            $h[7] = (int) 0x5be0cd19;
301 301
 
302 302
             // loop through message blocks and compute hash. ( For i=1 to N : )
303 303
             $N = count($M);
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
                 $MI = $M[$i];
308 308
 
309 309
                 // Initialize working variables
310
-                $_a = (int)$h[0];
311
-                $_b = (int)$h[1];
312
-                $_c = (int)$h[2];
313
-                $_d = (int)$h[3];
314
-                $_e = (int)$h[4];
315
-                $_f = (int)$h[5];
316
-                $_g = (int)$h[6];
317
-                $_h = (int)$h[7];
310
+                $_a = (int) $h[0];
311
+                $_b = (int) $h[1];
312
+                $_c = (int) $h[2];
313
+                $_d = (int) $h[3];
314
+                $_e = (int) $h[4];
315
+                $_f = (int) $h[5];
316
+                $_g = (int) $h[6];
317
+                $_h = (int) $h[7];
318 318
                 unset($_s0);
319 319
                 unset($_s1);
320 320
                 unset($_T1);
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
                 for (; $t < 64; $t++)
340 340
                 {
341 341
                     // Continue building the message schedule as we loop
342
-                    $_s0 = $W[($t+1)&0x0F];
342
+                    $_s0 = $W[($t + 1) & 0x0F];
343 343
                     $_s0 = $this->sigma_0($_s0);
344
-                    $_s1 = $W[($t+14)&0x0F];
344
+                    $_s1 = $W[($t + 14) & 0x0F];
345 345
                     $_s1 = $this->sigma_1($_s1);
346 346
 
347
-                    $W[$t&0xF] = $this->addmod2n($this->addmod2n($this->addmod2n($W[$t&0xF], $_s0), $_s1), $W[($t+9)&0x0F]);
347
+                    $W[$t & 0xF] = $this->addmod2n($this->addmod2n($this->addmod2n($W[$t & 0xF], $_s0), $_s1), $W[($t + 9) & 0x0F]);
348 348
 
349 349
                     // Compute hash
350
-                    $_T1 = $this->addmod2n($this->addmod2n($this->addmod2n($this->addmod2n($_h, $this->Sigma1($_e)), $this->Ch($_e, $_f, $_g)), $K[$t]), $W[$t&0xF]);
350
+                    $_T1 = $this->addmod2n($this->addmod2n($this->addmod2n($this->addmod2n($_h, $this->Sigma1($_e)), $this->Ch($_e, $_f, $_g)), $K[$t]), $W[$t & 0xF]);
351 351
                     $_T2 = $this->addmod2n($this->Sigma0($_a), $this->Maj($_a, $_b, $_c));
352 352
 
353 353
                     // Update working variables
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
             for ($i = 0; $i < $strlen; $i++)
398 398
             {
399 399
                 $i = (($sign < 0) ? $i + $length : $i);
400
-                $result[] = substr($string, $sign*$i, $length);
400
+                $result[] = substr($string, $sign * $i, $length);
401 401
                 $i--;
402 402
                 $i = (($sign < 0) ? $i : $i + $length);
403 403
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 // support to give php4 the hash() routine which abstracts this code.
435 435
 if (!function_exists('hash'))
436 436
 {
437
-    define('_NO_HASH_DEFINED',true);
437
+    define('_NO_HASH_DEFINED', true);
438 438
     function hash($algo, $data)
439 439
     {
440 440
         if (empty($algo) || !is_string($algo) || !is_string($data)) {
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.
Spacing   +18 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 //
19 19
 
20 20
 // http://doc.spip.org/@balise_LOGO__dist
21
-function balise_LOGO__dist ($p) {
21
+function balise_LOGO__dist($p) {
22 22
 
23 23
 	preg_match(",^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i", $p->nom_champ, $regs);
24 24
 	$type = strtolower($regs[1]);
@@ -42,36 +42,36 @@  discard block
 block discarded – undo
42 42
 	if ($p->param AND !$p->param[0][0]) {
43 43
 		$params = $p->param[0];
44 44
 		array_shift($params);
45
-		foreach($params as $a) {
45
+		foreach ($params as $a) {
46 46
 			if ($a[0]->type === 'texte') {
47 47
 				$n = $a[0]->texte;
48 48
 				if (is_numeric($n))
49
-					$coord[]= $n;
50
-				elseif (in_array($n,array('top','left','right','center','bottom')))
49
+					$coord[] = $n;
50
+				elseif (in_array($n, array('top', 'left', 'right', 'center', 'bottom')))
51 51
 					$align = $n;
52
-				elseif (in_array($n,array('auto','icone','apercu','vignette')))
52
+				elseif (in_array($n, array('auto', 'icone', 'apercu', 'vignette')))
53 53
 					$mode_logo = $n;
54 54
 			}
55
-			else $lien =  calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
55
+			else $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
56 56
 
57 57
 		}
58 58
 	}
59 59
 
60
-	$coord_x = !$coord  ? 0 : intval(array_shift($coord));
61
-	$coord_y = !$coord  ? 0 : intval(array_shift($coord));
60
+	$coord_x = !$coord ? 0 : intval(array_shift($coord));
61
+	$coord_y = !$coord ? 0 : intval(array_shift($coord));
62 62
 	
63 63
 	if ($p->etoile === '*') {
64 64
 		include_spip('balise/url_');
65 65
 		$lien = generer_generer_url_arg($type, $p, $_id_objet);
66 66
 	}
67 67
 
68
-	$connect = $p->id_boucle ?$p->boucles[$p->id_boucle]->sql_serveur :'';
68
+	$connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : '';
69 69
 	if ($type == 'document') {
70 70
 		$qconnect = _q($connect);
71 71
 		$doc = "quete_document($_id_objet, $qconnect)";
72 72
 		if ($fichier)
73 73
 			$code = "quete_logo_file($doc, $qconnect)";
74
-		else $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
74
+		else $code = "quete_logo_document($doc, ".($lien ? $lien : "''").", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
75 75
 		// (x=non-faux ? y : '') pour affecter x en retournant y
76 76
 		if ($p->descr['documents'])
77 77
 		  $code = '(($doublons["documents"] .= ",". '
@@ -97,25 +97,23 @@  discard block
 block discarded – undo
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," .
100
+	$code = "quete_logo('$id_objet', '".
101
+		(($suite == '_SURVOL') ? 'off' : (($suite == '_NORMAL') ? 'on' : 'ON')).
102
+		"', $_id_objet,".
104 103
 		(($suite == '_RUBRIQUE') ? 
105
-		champ_sql("id_rubrique", $p) :
106
-		(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
107
-		", " . intval($fichier) . ")";
104
+		champ_sql("id_rubrique", $p) : (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")).
105
+		", ".intval($fichier).")";
108 106
 
109 107
 	if ($fichier) return $code;
110 108
 
111
-	$code = "\n((!is_array(\$l = $code)) ? '':\n (" .
112
-		     '"<img class=\"spip_logos\" alt=\"\"' .
109
+	$code = "\n((!is_array(\$l = $code)) ? '':\n (".
110
+		     '"<img class=\"spip_logos\" alt=\"\"'.
113 111
 		    ($align ? " align=\\\"$align\\\"" : '')
114 112
 		    . ' src=\"$l[0]\"" . $l[2] .  ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))';
115 113
 
116 114
 	if (!$lien) return $code;
117 115
 
118
-	return ('(strlen($logo='.$code.')?\'<a href="\' .' . $lien . ' . \'">\' . $logo . \'</a>\':\'\')');
116
+	return ('(strlen($logo='.$code.')?\'<a href="\' .'.$lien.' . \'">\' . $logo . \'</a>\':\'\')');
119 117
 
120 118
 }
121 119
 
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.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
  * @param string $reprise
29 29
  * @return
30 30
  */
31
-function base_upgrade_dist($titre='', $reprise='')
31
+function base_upgrade_dist($titre = '', $reprise = '')
32 32
 {
33 33
 	if (!$titre) return; // anti-testeur automatique
34
-	if ($GLOBALS['spip_version_base']!=$GLOBALS['meta']['version_installee']) {
34
+	if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
35 35
 		if (!is_numeric(_request('reinstall'))) {
36 36
 			include_spip('base/create');
37
-			spip_log("recree les tables eventuellement disparues","maj."._LOG_INFO_IMPORTANTE);
37
+			spip_log("recree les tables eventuellement disparues", "maj."._LOG_INFO_IMPORTANTE);
38 38
 			creer_base();
39 39
 		}
40 40
 		
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			exit;
48 48
 		}
49 49
 	}
50
-	spip_log("Fin de mise a jour SQL. Debut m-a-j acces et config","maj."._LOG_INFO_IMPORTANTE);
50
+	spip_log("Fin de mise a jour SQL. Debut m-a-j acces et config", "maj."._LOG_INFO_IMPORTANTE);
51 51
 	
52 52
 	// supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
53 53
 	@spip_unlink(_CACHE_RUBRIQUES);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	//
86 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);
88
+	spip_log("Version anterieure: $version_installee. Courante: $spip_version_base", "maj."._LOG_INFO_IMPORTANTE);
89 89
 	if (!$version_installee OR ($spip_version_base < $version_installee)) {
90 90
 		sql_replace('spip_meta', 
91 91
 		      array('nom' => 'version_installee',
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 	if ($version_installee <= 1.926) {
101 101
 		$n = floor($version_installee * 10);
102 102
 		while ($n < 19) {
103
-			$nom  = sprintf("v%03d",$n);
103
+			$nom = sprintf("v%03d", $n);
104 104
 			$f = charger_fonction($nom, 'maj', true);
105 105
 			if ($f) {
106
-				spip_log( "$f repercute les modifications de la version " . ($n/10),"maj."._LOG_INFO_IMPORTANTE);
106
+				spip_log("$f repercute les modifications de la version ".($n / 10), "maj."._LOG_INFO_IMPORTANTE);
107 107
 				$f($version_installee, $spip_version_base);
108
-			} else spip_log( "pas de fonction pour la maj $n $nom","maj."._LOG_INFO_IMPORTANTE);
108
+			} else spip_log("pas de fonction pour la maj $n $nom", "maj."._LOG_INFO_IMPORTANTE);
109 109
 			$n++;
110 110
 		}
111 111
 		include_spip('maj/v019_pre193');
@@ -113,20 +113,20 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 	if ($version_installee < 2000) {
115 115
 		if ($version_installee < 2)
116
-			$version_installee = $version_installee*1000;
116
+			$version_installee = $version_installee * 1000;
117 117
 		include_spip('maj/v019');
118 118
 	}
119 119
 	if ($cible < 2)
120
-		$cible = $cible*1000;
120
+		$cible = $cible * 1000;
121 121
 
122 122
 	include_spip('maj/svn10000');
123 123
 	ksort($GLOBALS['maj']);
124
-	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee','meta', $redirect, true);
124
+	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, true);
125 125
 	if ($res) {
126 126
 		if (!is_array($res))
127
-			spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
127
+			spip_log("Pb d'acces SQL a la mise a jour", "maj."._LOG_INFO_ERREUR);
128 128
 		else {
129
-			echo _T('avis_operation_echec') . ' ' . join(' ', $res);
129
+			echo _T('avis_operation_echec').' '.join(' ', $res);
130 130
 			echo install_fin_html();
131 131
 		}
132 132
 	}
@@ -164,47 +164,47 @@  discard block
 block discarded – undo
164 164
  *     Nom de la table meta (sans le prefixe spip_) dans laquelle trouver la meta $nom_meta_base_version
165 165
  * @return void
166 166
  */
167
-function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta='meta'){
167
+function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') {
168 168
 
169
-	if ($table_meta!=='meta')
169
+	if ($table_meta !== 'meta')
170 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,'='))){
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 174
 		// $maj['create'] contient les directives propres a la premiere creation de base
175 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])){
176
+		if (isset($maj['create'])) {
177
+			if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) {
178 178
 				// installation : on ne fait que l'operation create
179 179
 				$maj = array("init"=>$maj['create']);
180 180
 				// et on lui ajoute un appel a inc/config
181 181
 				// pour creer les metas par defaut
182
-				$config = charger_fonction('config','inc');
182
+				$config = charger_fonction('config', 'inc');
183 183
 				$maj[$version_cible] = array(array($config));
184 184
 			}
185 185
 			// dans tous les cas enlever cet index du tableau
186 186
 			unset($maj['create']);
187 187
 		}
188 188
 		// si init, deja dans le bon ordre
189
-		if (!isset($maj['init'])){
189
+		if (!isset($maj['init'])) {
190 190
 			include_spip('inc/plugin'); // pour spip_version_compare
191
-			uksort($maj,'spip_version_compare');
191
+			uksort($maj, 'spip_version_compare');
192 192
 		}
193 193
 
194 194
 		// la redirection se fait par defaut sur la page d'administration des plugins
195 195
 		// sauf lorsque nous sommes sur l'installation de SPIP
196 196
 		// ou define _REDIRECT_MAJ_PLUGIN
197
-		$redirect = (defined('_REDIRECT_MAJ_PLUGIN')?_REDIRECT_MAJ_PLUGIN:generer_url_ecrire('admin_plugin'));
197
+		$redirect = (defined('_REDIRECT_MAJ_PLUGIN') ?_REDIRECT_MAJ_PLUGIN:generer_url_ecrire('admin_plugin'));
198 198
 		if (defined('_ECRIRE_INSTALL')) {
199
-			$redirect = parametre_url(generer_url_ecrire('install'),'etape', _request('etape'));
199
+			$redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape'));
200 200
 		}
201 201
 		
202 202
 		$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
203 203
 		if ($res) {
204 204
 			if (!is_array($res))
205
-				spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
205
+				spip_log("Pb d'acces SQL a la mise a jour", "maj."._LOG_INFO_ERREUR);
206 206
 			else {
207
-				echo "<p>"._T('avis_operation_echec') . ' ' . join(' ', $res)."</p>";
207
+				echo "<p>"._T('avis_operation_echec').' '.join(' ', $res)."</p>";
208 208
 			}
209 209
 		}
210 210
 	}
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
  * @param string $redirect
221 221
  * @return void
222 222
  */
223
-function relance_maj($meta,$table,$redirect=''){
223
+function relance_maj($meta, $table, $redirect = '') {
224 224
 	include_spip('inc/headers');
225
-	if (!$redirect){
225
+	if (!$redirect) {
226 226
 		// recuperer la valeur installee en cours
227 227
 		// on la tronque numeriquement, elle ne sert pas reellement
228 228
 		// sauf pour verifier que ce n'est pas oui ou non
229 229
 		// sinon is_numeric va echouer sur un numero de version 1.2.3
230 230
 		$installee = intval($GLOBALS[$table][$meta]);
231
-		$redirect = generer_url_ecrire('upgrade',"reinstall=$installee&meta=$meta&table=$table",true);
231
+		$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
232 232
 	}
233 233
 	echo redirige_formulaire($redirect);
234 234
 	exit();
@@ -243,21 +243,21 @@  discard block
 block discarded – undo
243 243
  * @param string $table
244 244
  * @return
245 245
  */
246
-function maj_debut_page($installee,$meta,$table){
246
+function maj_debut_page($installee, $meta, $table) {
247 247
 	static $done = false;
248 248
 	if ($done) return;
249 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;
250
+	@ini_set("zlib.output_compression", "0"); // pour permettre l'affichage au fur et a mesure
251
+	$timeout = _UPGRADE_TIME_OUT * 2;
252 252
 	$titre = _T('titre_page_upgrade');
253 253
 	$balise_img = charger_filtre('balise_img');
254 254
 	$titre .= $balise_img(chemin_image('searching.gif'));
255
-	echo ( install_debut_html($titre));
255
+	echo (install_debut_html($titre));
256 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).")");
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 259
 	echo "<div style='text-align: left'>\n";
260
-	ob_flush();flush();
260
+	ob_flush(); flush();
261 261
 	$done = true;
262 262
 }
263 263
 
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
  * @param bool $debut_page
297 297
  * @return array
298 298
  */
299
-function maj_while($installee, $cible, $maj, $meta='', $table='meta', $redirect='', $debut_page = false)
299
+function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false)
300 300
 {
301 301
 	# inclusions pour que les procedures d'upgrade disposent des fonctions de base
302 302
 	include_spip('base/create');
303 303
 	include_spip('base/abstract_sql');
304
-	$trouver_table = charger_fonction('trouver_table','base');
304
+	$trouver_table = charger_fonction('trouver_table', 'base');
305 305
 	include_spip('inc/plugin'); // pour spip_version_compare
306 306
 	$n = 0;
307 307
 	$time = time();
308 308
 	// definir le timeout qui peut etre utilise dans les fonctions
309 309
 	// de maj qui durent trop longtemps
310
-	define('_TIME_OUT',$time+_UPGRADE_TIME_OUT);
310
+	define('_TIME_OUT', $time + _UPGRADE_TIME_OUT);
311 311
 
312 312
 	reset($maj);
313
-	while (list($v,)=each($maj)) {
313
+	while (list($v,) = each($maj)) {
314 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,'<='))) {
315
+		if ($v == 'init' OR
316
+			(spip_version_compare($v, $installee, '>')
317
+			AND spip_version_compare($v, $cible, '<='))) {
318 318
 			if ($debut_page)
319
-				maj_debut_page($v,$meta,$table);
319
+				maj_debut_page($v, $meta, $table);
320 320
 			echo "MAJ $v";
321 321
 			$etape = serie_alter($v, $maj[$v], $meta, $table, $redirect);
322 322
 			$trouver_table(''); // vider le cache des descriptions de table
@@ -324,19 +324,19 @@  discard block
 block discarded – undo
324 324
 			# on sort
325 325
 			if ($etape) return array($v, $etape);
326 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);
327
+			spip_log("$table $meta: $v en $n secondes", 'maj.'._LOG_INFO_IMPORTANTE);
328
+			if ($meta) ecrire_meta($meta, $installee = $v, 'oui', $table);
329 329
 			echo "<br />";
330 330
 		}
331 331
 		if (time() >= _TIME_OUT) {
332
-			relance_maj($meta,$table,$redirect);
332
+			relance_maj($meta, $table, $redirect);
333 333
 		}
334 334
 	}
335 335
 	$trouver_table(''); // vider le cache des descriptions de table
336 336
 	// indispensable pour les chgt de versions qui n'ecrivent pas en base
337 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);
338
+	if ($meta) ecrire_meta($meta, $cible, 'oui', $table);
339
+	spip_log("MAJ terminee. $meta: $installee", 'maj.'._LOG_INFO_IMPORTANTE);
340 340
 	return array();
341 341
 }
342 342
 
@@ -358,41 +358,41 @@  discard block
 block discarded – undo
358 358
  *   url de redirection en cas d'interruption
359 359
  * @return int
360 360
  */
361
-function serie_alter($serie, $q = array(), $meta='', $table='meta', $redirect='') {
362
-	$meta2 = $meta . '_maj_' . $serie;
361
+function serie_alter($serie, $q = array(), $meta = '', $table = 'meta', $redirect = '') {
362
+	$meta2 = $meta.'_maj_'.$serie;
363 363
 	$etape = intval(@$GLOBALS[$table][$meta2]);
364 364
 	foreach ($q as $i => $r) {
365 365
 		if ($i >= $etape) {
366 366
 			$msg = "maj $table $meta2 etape $i";
367 367
 			if (is_array($r)
368 368
 			  AND function_exists($f = array_shift($r))) {
369
-				spip_log( "$msg: $f " . join(',',$r),'maj.'._LOG_INFO_IMPORTANTE);
369
+				spip_log("$msg: $f ".join(',', $r), 'maj.'._LOG_INFO_IMPORTANTE);
370 370
 				// pour les fonctions atomiques sql_xx
371 371
 				// on enregistre le meta avant de lancer la fonction,
372 372
 				// de maniere a eviter de boucler sur timeout
373 373
 				// mais pour les fonctions complexes,
374 374
 				// il faut les rejouer jusqu'a achevement.
375 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);
376
+				if (strncmp($f, "sql_", 4) == 0)
377
+					ecrire_meta($meta2, $i + 1, 'non', $table);
378 378
 				echo " <span title='$i'>.</span>";
379 379
 				call_user_func_array($f, $r);
380 380
 				// si temps imparti depasse, on relance sans ecrire en meta
381 381
 				// car on est peut etre sorti sur timeout si c'est une fonction longue
382 382
 				if (time() >= _TIME_OUT) {
383
-					relance_maj($meta,$table,$redirect);
383
+					relance_maj($meta, $table, $redirect);
384 384
 				}
385
-				ecrire_meta($meta2, $i+1, 'non', $table);
386
-				spip_log( "$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE);
385
+				ecrire_meta($meta2, $i + 1, 'non', $table);
386
+				spip_log("$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE);
387 387
 			}
388 388
 			else {
389 389
 				if (!is_array($r))
390
-					spip_log("maj $i format incorrect","maj."._LOG_ERREUR);
390
+					spip_log("maj $i format incorrect", "maj."._LOG_ERREUR);
391 391
 				else
392
-					spip_log("maj $i fonction $f non definie","maj."._LOG_ERREUR);
392
+					spip_log("maj $i fonction $f non definie", "maj."._LOG_ERREUR);
393 393
 				// en cas d'erreur serieuse, on s'arrete
394 394
 				// mais on permet de passer par dessus en rechargeant la page.
395
-				return $i+1;
395
+				return $i + 1;
396 396
 			}
397 397
 		}
398 398
 	}
@@ -422,23 +422,23 @@  discard block
 block discarded – undo
422 422
 	// ne pas garder le resultat de la requete sinon sqlite3 
423 423
 	// ne peut pas supprimer la table spip_test lors du sql_alter qui suit
424 424
 	// car cette table serait alors 'verouillee'
425
-	$result = $result?true:false; 
425
+	$result = $result ?true:false; 
426 426
 	sql_alter("TABLE spip_test DROP b");
427 427
 	return $result;
428 428
 }
429 429
 
430 430
 // pour versions <= 1.926
431 431
 // http://doc.spip.org/@maj_version
432
-function maj_version ($version, $test = true) {
432
+function maj_version($version, $test = true) {
433 433
 	if ($test) {
434
-		if ($version>=1.922)
434
+		if ($version >= 1.922)
435 435
 			ecrire_meta('version_installee', $version, 'oui');
436 436
 		else {
437 437
 			// on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
438 438
 			$GLOBALS['meta']['version_installee'] = $version;
439
-			sql_updateq('spip_meta',  array('valeur' => $version), "nom=" . sql_quote('version_installee') );
439
+			sql_updateq('spip_meta', array('valeur' => $version), "nom=".sql_quote('version_installee'));
440 440
 		}
441
-		spip_log( "mise a jour de la base en $version","maj."._LOG_INFO_IMPORTANTE);
441
+		spip_log("mise a jour de la base en $version", "maj."._LOG_INFO_IMPORTANTE);
442 442
 	} else {
443 443
 		echo _T('alerte_maj_impossible', array('version' => $version));
444 444
 		exit;
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 
448 448
 // pour versions <= 1.926
449 449
 // http://doc.spip.org/@upgrade_vers
450
-function upgrade_vers($version, $version_installee, $version_cible = 0){
451
-	return ($version_installee<$version
452
-		AND (($version_cible>=$version) OR ($version_cible==0))
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 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.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function genie_mise_a_jour_dist($t) {
22 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');
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");
26
+	spip_log("Verification version SPIP : ".($maj ? $maj : "version a jour"), "verifie_maj");
27 27
 	return 1;
28 28
 }
29 29
 
@@ -34,32 +34,32 @@  discard block
 block discarded – undo
34 34
 define('_VERSIONS_SERVEUR', 'http://files.spip.org/');
35 35
 define('_VERSIONS_LISTE', 'archives.xml');
36 36
 
37
-function info_maj ($dir, $file, $version){
37
+function info_maj($dir, $file, $version) {
38 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;
42
+	$nom = _DIR_CACHE_XML._VERSIONS_LISTE;
43 43
 	$page = !file_exists($nom) ? '' : file_get_contents($nom);
44 44
 	$page = info_maj_cache($nom, $dir, $page);
45 45
 
46 46
 	// reperer toutes les versions de numero majeur superieur ou egal
47 47
 	// (a revoir quand on arrivera a SPIP V10 ...)
48 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);
49
+	$p = ',/'.$file.'\D+(['.$p.']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i';
50
+	preg_match_all($p, $page, $m, PREG_SET_ORDER);
51 51
 	$page = '';
52 52
 	foreach ($m as $v) {
53 53
 		list(, $maj2, $min2,, $rev2) = $v;
54
-		$version_maj = $maj2 . '.' . $min2 . '.' . $rev2;
54
+		$version_maj = $maj2.'.'.$min2.'.'.$rev2;
55 55
 		if ((spip_version_compare($version, $version_maj, '<'))
56 56
 		AND (spip_version_compare($page, $version_maj, '<')))
57 57
 			$page = $version_maj;
58 58
 	}
59 59
 
60 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)) .
61
+	return "<a class='info_maj_spip' href='"._VERSIONS_SERVEUR."$dir' title='$page'>".
62
+		_T('nouvelle_version_spip', array('version'=>$page)).
63 63
 	    '</a>';
64 64
 }
65 65
 
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 // on teste la nouveaute par If-Modified-Since,
69 69
 // et seulement quand celui-ci a change' pour limiter les acces HTTP
70 70
 
71
-function info_maj_cache($nom, $dir, $page='')
71
+function info_maj_cache($nom, $dir, $page = '')
72 72
 {
73
-	$re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">';
73
+	$re = '<archives id="a'.$GLOBALS['meta']["alea_ephemere"].'">';
74 74
 	if (preg_match("/$re/", $page)) return $page;
75 75
 
76
-	$url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE;
76
+	$url = _VERSIONS_SERVEUR.$dir.'/'._VERSIONS_LISTE;
77 77
 	$a = file_exists($nom) ? filemtime($nom) : '';
78 78
 	include_spip('inc/distant');
79
-	$res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '',false, $a);
79
+	$res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '', false, $a);
80 80
 	// Si rien de neuf (ou inaccessible), garder l'ancienne
81 81
 	if ($res) list(, $page) = $res;
82 82
 	// Placer l'indicateur de fraicheur
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.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@  discard block
 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
-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)]))
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 22
 		return $couleurs_html[$lc];
23 23
 	return $couleur;
24 24
 }
25 25
 
26 26
 // http://doc.spip.org/@couleur_foncer
27
-function couleur_foncer ($couleur, $coeff=0.5) {
27
+function couleur_foncer($couleur, $coeff = 0.5) {
28 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 34
 	$couleur = _couleur_dec_to_hex($red, $green, $blue);
35 35
 	
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 }
38 38
 
39 39
 // http://doc.spip.org/@couleur_eclaircir
40
-function couleur_eclaircir ($couleur, $coeff=0.5) {
40
+function couleur_eclaircir($couleur, $coeff = 0.5) {
41 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 47
 	$couleur = _couleur_dec_to_hex($red, $green, $blue);
48 48
 	
@@ -54,33 +54,33 @@  discard block
 block discarded – undo
54 54
 // ls images exclues sont marquees d'une class no_image_filtrer qui bloque les filtres suivants
55 55
 // dans la fonction image_filtrer
56 56
 // http://doc.spip.org/@image_select
57
-function image_select($img,$width_min=0, $height_min=0, $width_max=10000, $height_max=1000){
57
+function image_select($img, $width_min = 0, $height_min = 0, $width_max = 10000, $height_max = 1000) {
58 58
 	if (!$img) return $img;
59
-	list ($h,$l) = taille_image($img);
59
+	list ($h, $l) = taille_image($img);
60 60
 	$select = true;
61
-	if ($l<$width_min OR $l>$width_max OR $h<$height_min OR $h>$height_max)
61
+	if ($l < $width_min OR $l > $width_max OR $h < $height_min OR $h > $height_max)
62 62
 		$select = false;
63 63
 
64
-	$class = extraire_attribut($img,'class');
65
-	$p = strpos($class,'no_image_filtrer');
66
-	if (($select==false) AND ($p===FALSE)){
64
+	$class = extraire_attribut($img, 'class');
65
+	$p = strpos($class, 'no_image_filtrer');
66
+	if (($select == false) AND ($p === FALSE)) {
67 67
 		$class .= " no_image_filtrer";
68
-		$img = inserer_attribut($img,'class',$class);
68
+		$img = inserer_attribut($img, 'class', $class);
69 69
 	}
70
-	if (($select==true) AND ($p!==FALSE)){
71
-		$class = preg_replace(",\s*no_image_filtrer,","",$class);
72
-		$img = inserer_attribut($img,'class',$class);
70
+	if (($select == true) AND ($p !== FALSE)) {
71
+		$class = preg_replace(",\s*no_image_filtrer,", "", $class);
72
+		$img = inserer_attribut($img, 'class', $class);
73 73
 	}
74 74
 	return $img;
75 75
 }
76 76
 
77 77
 
78 78
 // http://doc.spip.org/@image_passe_partout
79
-function image_passe_partout($img,$taille_x = -1, $taille_y = -1,$force = false,$cherche_image=false,$process='AUTO'){
79
+function image_passe_partout($img, $taille_x = -1, $taille_y = -1, $force = false, $cherche_image = false, $process = 'AUTO') {
80 80
 	if (!$img) return '';
81
-	list ($hauteur,$largeur) = taille_image($img);
81
+	list ($hauteur, $largeur) = taille_image($img);
82 82
 	if ($taille_x == -1)
83
-		$taille_x = isset($GLOBALS['meta']['taille_preview'])?$GLOBALS['meta']['taille_preview']:150;
83
+		$taille_x = isset($GLOBALS['meta']['taille_preview']) ? $GLOBALS['meta']['taille_preview'] : 150;
84 84
 	if ($taille_y == -1)
85 85
 		$taille_y = $taille_x;
86 86
 
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 	elseif ($taille_x == 0 AND $taille_y == 0)
92 92
 		return '';
93 93
 	
94
-	list($destWidth,$destHeight,$ratio) = ratio_passe_partout($largeur,$hauteur,$taille_x,$taille_y);
94
+	list($destWidth, $destHeight, $ratio) = ratio_passe_partout($largeur, $hauteur, $taille_x, $taille_y);
95 95
 	$fonction = array('image_passe_partout', func_get_args());
96
-	return process_image_reduire($fonction,$img,$destWidth,$destHeight,$force,$cherche_image,$process);
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
-function image_reduire($img, $taille = -1, $taille_y = -1, $force=false, $cherche_image=false, $process='AUTO') {
100
+function image_reduire($img, $taille = -1, $taille_y = -1, $force = false, $cherche_image = false, $process = 'AUTO') {
101 101
 	// Determiner la taille x,y maxi
102 102
 	// prendre le reglage de previsu par defaut
103 103
 	if ($taille == -1)
104
-		$taille = (isset($GLOBALS['meta']['taille_preview']) AND intval($GLOBALS['meta']['taille_preview']))?intval($GLOBALS['meta']['taille_preview']):150;
104
+		$taille = (isset($GLOBALS['meta']['taille_preview']) AND intval($GLOBALS['meta']['taille_preview'])) ?intval($GLOBALS['meta']['taille_preview']) : 150;
105 105
 	if ($taille_y == -1)
106 106
 		$taille_y = $taille;
107 107
 
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 		return '';
114 114
 
115 115
 	$fonction = array('image_reduire', func_get_args());
116
-	return process_image_reduire($fonction,$img,$taille,$taille_y,$force,$cherche_image,$process);
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
-function image_reduire_par ($img, $val=1, $force=false) {
122
-	list ($hauteur,$largeur) = taille_image($img);
121
+function image_reduire_par($img, $val = 1, $force = false) {
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 127
 	if ($l > $h) $h = 0;
128 128
 	else $l = 0;
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.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -17,20 +17,20 @@  discard block
 block discarded – undo
17 17
 // en evitant les attaques par la redirection (souvent indique par 1 $_GET)
18 18
 
19 19
 // http://doc.spip.org/@redirige_par_entete
20
-function redirige_par_entete($url, $equiv='', $status = 302) {
21
-	if (!in_array($status,array(301,302)))
20
+function redirige_par_entete($url, $equiv = '', $status = 302) {
21
+	if (!in_array($status, array(301, 302)))
22 22
 		$status = 302;
23 23
 
24 24
 	$url = trim(strtr($url, "\n\r", "  "));
25 25
 	# en theorie on devrait faire ca tout le temps, mais quand la chaine
26 26
 	# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
27
-	if ($url[0]=='?')
27
+	if ($url[0] == '?')
28 28
 		$url = url_de_base().$url;
29
-	if ($url[0]=='#')
29
+	if ($url[0] == '#')
30 30
 		$url = self('&').$url;
31 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)){
32
+	if ($GLOBALS['profondeur_url'] > (_DIR_RESTREINT ? 1 : 2)
33
+		AND !preg_match(",^(\w+:)?//,", $url)) {
34 34
 		include_spip("inc/filtres_mini");
35 35
 		$url = url_absolue($url);
36 36
 	}
@@ -42,30 +42,30 @@  discard block
 block discarded – undo
42 42
 		$url = parametre_url($url, 'var_ajax_redir', 1, '&');
43 43
 		
44 44
 	// ne pas laisser passer n'importe quoi dans l'url
45
-	$url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
45
+	$url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
46 46
 	// interdire les url inline avec des pseudo-protocoles :
47 47
 	if (
48
-		(preg_match(",data:,i",$url) AND preg_match("/base64\s*,/i",$url))
49
-		OR preg_match(",(javascript|mailto):,i",$url)
48
+		(preg_match(",data:,i", $url) AND preg_match("/base64\s*,/i", $url))
49
+		OR preg_match(",(javascript|mailto):,i", $url)
50 50
 		)
51
-		$url ="./";
51
+		$url = "./";
52 52
 
53 53
 	// Il n'y a que sous Apache que setcookie puis redirection fonctionne
54 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="";
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 58
 	} else {
59
-		@header("Refresh: 0; url=" . $url);
59
+		@header("Refresh: 0; url=".$url);
60 60
 		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
61 61
 	}
62 62
 	include_spip('inc/lang');
63
-	if ($status!=302)
63
+	if ($status != 302)
64 64
 		http_status($status);
65
-	echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n",
66
-	  html_lang_attributes(),'
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>
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 }
83 83
 
84 84
 // http://doc.spip.org/@redirige_formulaire
85
-function redirige_formulaire($url, $equiv = '', $format='message') {
85
+function redirige_formulaire($url, $equiv = '', $format = 'message') {
86 86
 	if (!_AJAX
87 87
 	AND !headers_sent()
88 88
 	AND !_request('var_ajax')) {
89
-		redirige_par_entete(str_replace('&amp;','&',$url), $equiv);
89
+		redirige_par_entete(str_replace('&amp;', '&', $url), $equiv);
90 90
 	}
91 91
 	// si c'est une ancre, fixer simplement le window.location.hash
92
-	elseif($format=='ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i',$url)) {
92
+	elseif ($format == 'ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i', $url)) {
93 93
 		return array(
94 94
 		// on renvoie un lien masque qui sera traite par ajaxCallback.js
95 95
 		"<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 	else {
100 100
 		// ne pas laisser passer n'importe quoi dans l'url
101
-		$url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
101
+		$url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
102 102
 
103 103
 		$url = strtr($url, "\n\r", "  ");
104 104
 		# en theorie on devrait faire ca tout le temps, mais quand la chaine
105 105
 		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
106
-		if ($url[0]=='?')
106
+		if ($url[0] == '?')
107 107
 			$url = url_de_base().$url;
108
-		$url = str_replace('&amp;','&',$url);
108
+		$url = str_replace('&amp;', '&', $url);
109 109
 		spip_log("redirige formulaire ajax: $url");
110 110
 		include_spip('inc/filtres');
111
-		if ($format=='ajaxform')
111
+		if ($format == 'ajaxform')
112 112
 			return array(
113 113
 			// on renvoie un lien masque qui sera traite par ajaxCallback.js
114 114
 			'<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 			return
120 120
 		// ie poste les formulaires dans une iframe, il faut donc rediriger son parent
121 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','')
122
+		. http_img_pack('searching.gif', '')
123 123
 		. '<br />'
124 124
 		. '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
125 125
 	}
126 126
 }
127 127
 
128 128
 // http://doc.spip.org/@redirige_url_ecrire
129
-function redirige_url_ecrire($script='', $args='', $equiv='') {
129
+function redirige_url_ecrire($script = '', $args = '', $equiv = '') {
130 130
 	return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
131 131
 }
132 132
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 // http://doc.spip.org/@http_no_cache
159 159
 function http_no_cache() {
160 160
 	if (headers_sent())
161
-		{ spip_log("http_no_cache arrive trop tard"); return;}
161
+		{ spip_log("http_no_cache arrive trop tard"); return; }
162 162
 	$charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
163 163
 
164 164
 	// selon http://developer.apple.com/internet/safari/faq.html#anchor5
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 	header("Content-Type: text/html; charset=$charset");
171 171
 	header("Expires: 0");
172
-	header("Last-Modified: " .gmdate("D, d M Y H:i:s"). " GMT");
172
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
173 173
 	header("Cache-Control: no-cache, must-revalidate");
174 174
 	header("Pragma: no-cache");
175 175
 }
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.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@  discard block
 block discarded – undo
16 16
 // Recopie dans le tableau PHP global meta, car on en a souvent besoin
17 17
 
18 18
 // duree maximale du cache. Le double pour l'antidater
19
-define('_META_CACHE_TIME', 1<<24);
19
+define('_META_CACHE_TIME', 1 << 24);
20 20
 
21 21
 // http://doc.spip.org/@inc_meta_dist
22
-function inc_meta_dist($table='meta')
22
+function inc_meta_dist($table = 'meta')
23 23
 {
24 24
 	// Lire les meta, en cache si present, valide et lisible
25 25
 	// en cas d'install ne pas faire confiance au meta_cache eventuel
26 26
 	$cache = cache_meta($table);
27 27
 
28
-	if ((_request('exec')!=='install' OR !test_espace_prive())
28
+	if ((_request('exec') !== 'install' OR !test_espace_prive())
29 29
 	AND $new = jeune_fichier($cache, _META_CACHE_TIME)
30 30
 	AND lire_fichier_securise($cache, $meta)
31 31
 	AND $meta = @unserialize($meta))
32 32
 		$GLOBALS[$table] = $meta;
33 33
 
34 34
 	if (isset($GLOBALS[$table]['touch']) 
35
-	AND ($GLOBALS[$table]['touch']<time()-_META_CACHE_TIME))
35
+	AND ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME))
36 36
 		$GLOBALS[$table] = array();
37 37
 	// sinon lire en base
38 38
 	if (!$GLOBALS[$table]) $new = !lire_metas($table);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			include_spip('inc/acces');
48 48
 			renouvelle_alea();
49 49
 			$new = false; 
50
-		} else spip_log("impossible d'ecrire dans " . $cache);
50
+		} else spip_log("impossible d'ecrire dans ".$cache);
51 51
 	}
52 52
 	// et refaire le cache si on a du lire en base
53 53
 	if (!$new) touch_meta(false, $table);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 // pour eviter l'erreur fatale (serveur non encore configure)
58 58
 
59 59
 // http://doc.spip.org/@lire_metas
60
-function lire_metas($table='meta') {
60
+function lire_metas($table = 'meta') {
61 61
 
62 62
 	if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
63 63
 		include_spip('base/abstract_sql');
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
         sql_free($result);
68 68
 
69 69
 		if (!$GLOBALS[$table]['charset']
70
-		  OR $GLOBALS[$table]['charset']=='_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
70
+		  OR $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
71 71
 		)
72 72
 			ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table);
73 73
 
74 74
 		// noter cette table de configuration dans les meta de SPIP
75
-		if ($table!=='meta') {
75
+		if ($table !== 'meta') {
76 76
 			$liste = unserialize($GLOBALS['meta']['tables_config']);
77 77
 			if (!$liste)
78 78
 				$liste = array();
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
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
-function touch_meta($antidate= false, $table='meta'){
91
+function touch_meta($antidate = false, $table = 'meta') {
92 92
 	$file = cache_meta($table);
93 93
 	if (!$antidate OR !@touch($file, $antidate)) {
94 94
 		$r = $GLOBALS[$table];
@@ -98,32 +98,32 @@  discard block
 block discarded – undo
98 98
 		// mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
99 99
 		// meme si son squelette est en cache
100 100
 		//unset($r['secret_du_site']);
101
-		if ($antidate) $r['touch']= $antidate;
101
+		if ($antidate) $r['touch'] = $antidate;
102 102
 		ecrire_fichier_securise($file, serialize($r));
103 103
 	}
104 104
 }
105 105
 
106 106
 // http://doc.spip.org/@effacer_meta
107
-function effacer_meta($nom, $table='meta') {
107
+function effacer_meta($nom, $table = 'meta') {
108 108
 	// section critique sur le cache:
109 109
 	// l'invalider avant et apres la MAJ de la BD
110 110
 	// c'est un peu moins bien qu'un vrai verrou mais ca suffira
111 111
 	// et utiliser une statique pour eviter des acces disques a repetition
112 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'");
113
+	$antidate = time() - (_META_CACHE_TIME << 4);
114
+	if (!isset($touch[$table])) {touch_meta($antidate, $table); }
115
+	sql_delete('spip_'.$table, "nom='$nom'");
116 116
 	unset($GLOBALS[$table][$nom]);
117
-	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false;}
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
-function ecrire_meta($nom, $valeur, $importable = NULL, $table='meta') {
121
+function ecrire_meta($nom, $valeur, $importable = NULL, $table = 'meta') {
122 122
 
123 123
 	static $touch = array();
124 124
 	if (!$nom) return;
125 125
 	include_spip('base/abstract_sql');
126
-	$res = sql_select("*",'spip_' . $table,"nom=" . sql_quote($nom),'','','','','','continue');
126
+	$res = sql_select("*", 'spip_'.$table, "nom=".sql_quote($nom), '', '', '', '', '', 'continue');
127 127
 	// table pas encore installee, travailler en php seulement
128 128
 	if (!$res) {
129 129
 		$GLOBALS[$table][$nom] = $valeur;
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 
139 139
 	$GLOBALS[$table][$nom] = $valeur;
140 140
 	// cf effacer pour comprendre le double touch
141
-	$antidate = time() - (_META_CACHE_TIME<<1);
142
-	if (!isset($touch[$table])) {touch_meta($antidate, $table);}
141
+	$antidate = time() - (_META_CACHE_TIME << 1);
142
+	if (!isset($touch[$table])) {touch_meta($antidate, $table); }
143 143
 	$r = array('nom' => $nom, 'valeur' => $valeur);
144 144
 	// Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
145 145
 	if ($importable AND isset($row['impt'])) $r['impt'] = $importable;
146 146
 	if ($row) {
147
-		sql_updateq('spip_' . $table, $r,"nom=" . sql_quote($nom));
147
+		sql_updateq('spip_'.$table, $r, "nom=".sql_quote($nom));
148 148
 	} else {
149
-		sql_insertq('spip_' . $table, $r);
149
+		sql_insertq('spip_'.$table, $r);
150 150
 	}
151
-	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false;}
151
+	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false; }
152 152
 }
153 153
 
154
-function cache_meta($table='meta')
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,7 +161,7 @@  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');
164
+	$trouver_table = charger_fonction('trouver_table', 'base');
165 165
 	if (!$trouver_table("spip_$table")) {
166 166
 		include_spip('base/auxiliaires');
167 167
 		include_spip('base/create');
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
  * @param string $table
179 179
  * @param bool $force
180 180
  */
181
-function supprimer_table_meta($table, $force=false) {
182
-	if ($table=='meta') return; // interdit !
181
+function supprimer_table_meta($table, $force = false) {
182
+	if ($table == 'meta') return; // interdit !
183 183
 
184 184
 	if ($force OR !sql_countsel("spip_$table")) {
185 185
 		unset($GLOBALS[$table]);
186 186
 		sql_drop_table("spip_$table");
187 187
 		// vider le cache des tables
188
-		$trouver_table = charger_fonction('trouver_table','base');
188
+		$trouver_table = charger_fonction('trouver_table', 'base');
189 189
 		$trouver_table('');
190 190
 	}
191 191
 }
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.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 //
20 20
 
21 21
 // http://doc.spip.org/@inc_selectionner_dist
22
-function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') {
22
+function inc_selectionner_dist($sel, $idom = "", $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') {
23 23
 
24 24
 	if ($recur) $recur = mini_hier($sel); else $sel = 0;
25 25
 
26 26
 	if ($aff_racine) {
27 27
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
28
-		$idom3 = $idom . "_selection";
28
+		$idom3 = $idom."_selection";
29 29
 
30 30
 		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
31 31
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 					textebrut(_T('info_racine_site')))),
35 35
 				"\n\r", "  ");
36 36
 
37
-		$js_func = $do . '_selection_titre';
37
+		$js_func = $do.'_selection_titre';
38 38
 		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
39 39
 
40 40
 		$aff_racine = "<div class='petite-racine item'>"
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		. "</a></div>";
50 50
 	}
51 51
 
52
-	$url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
52
+	$url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
53 53
 
54 54
 	$plonger = charger_fonction('plonger', 'inc');
55 55
 	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 // http://doc.spip.org/@construire_selectionner_hierarchie
63
-function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='')
63
+function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '')
64 64
 {
65 65
 	global $spip_lang_right;
66 66
 
67
-	$idom1 = $idom . "_champ_recherche";
68
-	$idom2 = $idom . "_principal";
69
-	$idom3 = $idom . "_selection";
70
-	$idom4 = $idom . "_col_1";
71
-	$idom5 = 'img_' . $idom4;
67
+	$idom1 = $idom."_champ_recherche";
68
+	$idom2 = $idom."_principal";
69
+	$idom3 = $idom."_selection";
70
+	$idom4 = $idom."_col_1";
71
+	$idom5 = 'img_'.$idom4;
72 72
 	$idom6 = $idom."_fonc";
73 73
 
74 74
 	return "<div id='$idom'>"
75 75
 	. "<a id='$idom6' style='visibility: hidden;'"
76
-	. ($url_init ?  "\nhref='$url_init'" : '')
76
+	. ($url_init ? "\nhref='$url_init'" : '')
77 77
 	. "></a>"
78 78
 	. "<div class='recherche_rapide_parent'>"
79 79
 	. http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	. "')\"" 
105 105
 	. " />"
106 106
 	. "\n</div>"
107
-	. ($racine?"<div>$racine</div>":"")
107
+	. ($racine ? "<div>$racine</div>" : "")
108 108
 	. "<div id='"
109 109
 	.  $idom2
110 110
 	.  "'><div id='$idom4'"
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 }
115 115
 
116 116
 // http://doc.spip.org/@mini_hier
117
-function mini_hier ($id_rubrique) {
117
+function mini_hier($id_rubrique) {
118 118
 	
119 119
 	$liste = $id_rubrique;
120 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");
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.