Completed
Push — spip-3.0 ( cd2822...016705 )
by cam
08:31
created
ecrire/auth/sha256.inc.php 4 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.
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.
Braces   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -155,7 +155,9 @@  discard block
 block discarded – undo
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) {
159
+						    $byteSize = 16;
160
+						}
159 161
 					}
160 162
 					return $chars;
161 163
 				}
@@ -165,36 +167,32 @@  discard block
 block discarded – undo
165 167
 					$len = strlen($c);
166 168
 					$bytes = 0;
167 169
 
168
-					if ($index >= $len)
169
-						return false;
170
+					if ($index >= $len) {
171
+											return false;
172
+					}
170 173
 
171 174
 					$h = ord($c{$index});
172 175
 
173 176
 					if ($h <= 0x7F) {
174 177
 						$bytes = 1;
175 178
 						return $h;
176
-					}
177
-					else if ($h < 0xC2){
179
+					} else if ($h < 0xC2){
178 180
 						// pas utf mais renvoyer quand meme ce qu'on a
179 181
 						$bytes = 1;
180 182
 						return $h;
181
-					}
182
-					else if ($h <= 0xDF && $index < $len - 1) {
183
+					} else if ($h <= 0xDF && $index < $len - 1) {
183 184
 						$bytes = 2;
184 185
 						return ($h & 0x1F) <<  6 | (ord($c{$index + 1}) & 0x3F);
185
-					}
186
-					else if ($h <= 0xEF && $index < $len - 2) {
186
+					} else if ($h <= 0xEF && $index < $len - 2) {
187 187
 						$bytes = 3;
188 188
 						return ($h & 0x0F) << 12 | (ord($c{$index + 1}) & 0x3F) << 6
189 189
 																		 | (ord($c{$index + 2}) & 0x3F);
190
-					}
191
-					else if ($h <= 0xF4 && $index < $len - 3) {
190
+					} else if ($h <= 0xF4 && $index < $len - 3) {
192 191
 						$bytes = 4;
193 192
 						return ($h & 0x0F) << 18 | (ord($c{$index + 1}) & 0x3F) << 12
194 193
 																		 | (ord($c{$index + 2}) & 0x3F) << 6
195 194
 																		 | (ord($c{$index + 3}) & 0x3F);
196
-					}
197
-					else {
195
+					} else {
198 196
 						// pas utf mais renvoyer quand meme ce qu'on a
199 197
 						$bytes = 1;
200 198
 						return $h;
@@ -222,8 +220,9 @@  discard block
 block discarded – undo
222 220
 					$split = array();
223 221
 					while (count($a)>$n) {
224 222
 						$s = array();
225
-						for($i = 0;$i<$n;$i++)
226
-							$s[] = array_shift($a);
223
+						for($i = 0;$i<$n;$i++) {
224
+													$s[] = array_shift($a);
225
+						}
227 226
 						$split[] = $s;
228 227
 					}
229 228
 					if (count($a)){
Please login to merge, or discard this patch.
ecrire/balise/logo_.php 4 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.
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.
Braces   +30 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11 11
 \***************************************************************************/
12 12
 
13
-if (!defined('_ECRIRE_INC_VERSION')) return;
13
+if (!defined('_ECRIRE_INC_VERSION')) {
14
+    return;
15
+}
14 16
 
15 17
 //
16 18
 // Fonction des balises #LOGO_XXXX
@@ -31,8 +33,9 @@  discard block
 block discarded – undo
31 33
 	}
32 34
 
33 35
 	$id_objet = id_table_objet($type);
34
-	if (!isset($_id_objet) OR !$_id_objet)
35
-		$_id_objet = champ_sql($id_objet, $p);
36
+	if (!isset($_id_objet) OR !$_id_objet) {
37
+			$_id_objet = champ_sql($id_objet, $p);
38
+	}
36 39
 
37 40
 	$fichier = ($p->etoile === '**') ? -1 : 0;
38 41
 	$coord = array();
@@ -45,14 +48,16 @@  discard block
 block discarded – undo
45 48
 		foreach($params as $a) {
46 49
 			if ($a[0]->type === 'texte') {
47 50
 				$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;
51
+				if (is_numeric($n)) {
52
+									$coord[]= $n;
53
+				} elseif (in_array($n,array('top','left','right','center','bottom'))) {
54
+									$align = $n;
55
+				} elseif (in_array($n,array('auto','icone','apercu','vignette'))) {
56
+									$mode_logo = $n;
57
+				}
58
+			} else {
59
+			    $lien =  calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
54 60
 			}
55
-			else $lien =  calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
56 61
 
57 62
 		}
58 63
 	}
@@ -69,16 +74,18 @@  discard block
 block discarded – undo
69 74
 	if ($type == 'document') {
70 75
 		$qconnect = _q($connect);
71 76
 		$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)";
77
+		if ($fichier) {
78
+					$code = "quete_logo_file($doc, $qconnect)";
79
+		} else {
80
+		    $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
81
+		}
75 82
 		// (x=non-faux ? y : '') pour affecter x en retournant y
76
-		if ($p->descr['documents'])
77
-		  $code = '(($doublons["documents"] .= ",". '
83
+		if ($p->descr['documents']) {
84
+				  $code = '(($doublons["documents"] .= ",". '
78 85
 		    . $_id_objet
79 86
 		    . ") ? $code : '')";
80
-	}
81
-	elseif ($connect) {
87
+		}
88
+	} elseif ($connect) {
82 89
 		$code = "''";
83 90
 		spip_log("Les logos distants ne sont pas prevus");
84 91
 	} else {
@@ -106,14 +113,18 @@  discard block
 block discarded – undo
106 113
 		(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
107 114
 		", " . intval($fichier) . ")";
108 115
 
109
-	if ($fichier) return $code;
116
+	if ($fichier) {
117
+	    return $code;
118
+	}
110 119
 
111 120
 	$code = "\n((!is_array(\$l = $code)) ? '':\n (" .
112 121
 		     '"<img class=\"spip_logos\" alt=\"\"' .
113 122
 		    ($align ? " align=\\\"$align\\\"" : '')
114 123
 		    . ' src=\"$l[0]\"" . $l[2] .  ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))';
115 124
 
116
-	if (!$lien) return $code;
125
+	if (!$lien) {
126
+	    return $code;
127
+	}
117 128
 
118 129
 	return ('(strlen($logo='.$code.')?\'<a href="\' .' . $lien . ' . \'">\' . $logo . \'</a>\':\'\')');
119 130
 
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 4 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.
Braces   +59 added lines, -36 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11 11
 \***************************************************************************/
12 12
 
13
-if (!defined('_ECRIRE_INC_VERSION')) return;
13
+if (!defined('_ECRIRE_INC_VERSION')) {
14
+    return;
15
+}
14 16
 
15 17
 /**
16 18
  * Programme de mise a jour des tables SQL lors d'un chgt de version.
@@ -30,7 +32,10 @@  discard block
 block discarded – undo
30 32
  */
31 33
 function base_upgrade_dist($titre='', $reprise='')
32 34
 {
33
-	if (!$titre) return; // anti-testeur automatique
35
+	if (!$titre) {
36
+	    return;
37
+	}
38
+	// anti-testeur automatique
34 39
 	if ($GLOBALS['spip_version_base']!=$GLOBALS['meta']['version_installee']) {
35 40
 		if (!is_numeric(_request('reinstall'))) {
36 41
 			include_spip('base/create');
@@ -93,7 +98,9 @@  discard block
 block discarded – undo
93 98
 			    'impt' => 'non'));
94 99
 		return false;
95 100
 	}
96
-	if (!upgrade_test()) return true;
101
+	if (!upgrade_test()) {
102
+	    return true;
103
+	}
97 104
 	
98 105
 	$cible = ($version_cible ? $version_cible : $spip_version_base);
99 106
 
@@ -105,27 +112,31 @@  discard block
 block discarded – undo
105 112
 			if ($f) {
106 113
 				spip_log( "$f repercute les modifications de la version " . ($n/10),"maj."._LOG_INFO_IMPORTANTE);
107 114
 				$f($version_installee, $spip_version_base);
108
-			} else spip_log( "pas de fonction pour la maj $n $nom","maj."._LOG_INFO_IMPORTANTE);
115
+			} else {
116
+			    spip_log( "pas de fonction pour la maj $n $nom","maj."._LOG_INFO_IMPORTANTE);
117
+			}
109 118
 			$n++;
110 119
 		}
111 120
 		include_spip('maj/v019_pre193');
112 121
 		v019_pre193($version_installee, $version_cible);
113 122
 	}
114 123
 	if ($version_installee < 2000) {
115
-		if ($version_installee < 2)
116
-			$version_installee = $version_installee*1000;
124
+		if ($version_installee < 2) {
125
+					$version_installee = $version_installee*1000;
126
+		}
117 127
 		include_spip('maj/v019');
118 128
 	}
119
-	if ($cible < 2)
120
-		$cible = $cible*1000;
129
+	if ($cible < 2) {
130
+			$cible = $cible*1000;
131
+	}
121 132
 
122 133
 	include_spip('maj/svn10000');
123 134
 	ksort($GLOBALS['maj']);
124 135
 	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee','meta', $redirect, true);
125 136
 	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 {
137
+		if (!is_array($res)) {
138
+					spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
139
+		} else {
129 140
 			echo _T('avis_operation_echec') . ' ' . join(' ', $res);
130 141
 			echo install_fin_html();
131 142
 		}
@@ -166,8 +177,9 @@  discard block
 block discarded – undo
166 177
  */
167 178
 function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta='meta'){
168 179
 
169
-	if ($table_meta!=='meta')
170
-		lire_metas($table_meta);
180
+	if ($table_meta!=='meta') {
181
+			lire_metas($table_meta);
182
+	}
171 183
 	if ( (!isset($GLOBALS[$table_meta][$nom_meta_base_version]) )
172 184
 			|| (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version],$version_cible,'='))){
173 185
 
@@ -201,9 +213,9 @@  discard block
 block discarded – undo
201 213
 		
202 214
 		$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
203 215
 		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 {
216
+			if (!is_array($res)) {
217
+							spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
218
+			} else {
207 219
 				echo "<p>"._T('avis_operation_echec') . ' ' . join(' ', $res)."</p>";
208 220
 			}
209 221
 		}
@@ -245,7 +257,9 @@  discard block
 block discarded – undo
245 257
  */
246 258
 function maj_debut_page($installee,$meta,$table){
247 259
 	static $done = false;
248
-	if ($done) return;
260
+	if ($done) {
261
+	    return;
262
+	}
249 263
 	include_spip('inc/minipres');
250 264
 	@ini_set("zlib.output_compression","0"); // pour permettre l'affichage au fur et a mesure
251 265
 	$timeout = _UPGRADE_TIME_OUT*2;
@@ -315,17 +329,22 @@  discard block
 block discarded – undo
315 329
 		if ($v=='init' OR
316 330
 			(spip_version_compare($v,$installee,'>')
317 331
 			AND spip_version_compare($v,$cible,'<='))) {
318
-			if ($debut_page)
319
-				maj_debut_page($v,$meta,$table);
332
+			if ($debut_page) {
333
+							maj_debut_page($v,$meta,$table);
334
+			}
320 335
 			echo "MAJ $v";
321 336
 			$etape = serie_alter($v, $maj[$v], $meta, $table, $redirect);
322 337
 			$trouver_table(''); // vider le cache des descriptions de table
323 338
 			# echec sur une etape en cours ?
324 339
 			# on sort
325
-			if ($etape) return array($v, $etape);
340
+			if ($etape) {
341
+			    return array($v, $etape);
342
+			}
326 343
 			$n = time() - $time;
327 344
 			spip_log( "$table $meta: $v en $n secondes",'maj.'._LOG_INFO_IMPORTANTE);
328
-			if ($meta) ecrire_meta($meta, $installee=$v,'oui', $table);
345
+			if ($meta) {
346
+			    ecrire_meta($meta, $installee=$v,'oui', $table);
347
+			}
329 348
 			echo "<br />";
330 349
 		}
331 350
 		if (time() >= _TIME_OUT) {
@@ -335,7 +354,9 @@  discard block
 block discarded – undo
335 354
 	$trouver_table(''); // vider le cache des descriptions de table
336 355
 	// indispensable pour les chgt de versions qui n'ecrivent pas en base
337 356
 	// tant pis pour la redondance eventuelle avec ci-dessus
338
-	if ($meta) ecrire_meta($meta, $cible,'oui',$table);
357
+	if ($meta) {
358
+	    ecrire_meta($meta, $cible,'oui',$table);
359
+	}
339 360
 	spip_log( "MAJ terminee. $meta: $installee",'maj.'._LOG_INFO_IMPORTANTE);
340 361
 	return array();
341 362
 }
@@ -373,8 +394,9 @@  discard block
 block discarded – undo
373 394
 				// mais pour les fonctions complexes,
374 395
 				// il faut les rejouer jusqu'a achevement.
375 396
 				// 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);
397
+				if (strncmp($f,"sql_",4)==0) {
398
+									ecrire_meta($meta2, $i+1, 'non', $table);
399
+				}
378 400
 				echo " <span title='$i'>.</span>";
379 401
 				call_user_func_array($f, $r);
380 402
 				// si temps imparti depasse, on relance sans ecrire en meta
@@ -384,12 +406,12 @@  discard block
 block discarded – undo
384 406
 				}
385 407
 				ecrire_meta($meta2, $i+1, 'non', $table);
386 408
 				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);
409
+			} else {
410
+				if (!is_array($r)) {
411
+									spip_log("maj $i format incorrect","maj."._LOG_ERREUR);
412
+				} else {
413
+									spip_log("maj $i fonction $f non definie","maj."._LOG_ERREUR);
414
+				}
393 415
 				// en cas d'erreur serieuse, on s'arrete
394 416
 				// mais on permet de passer par dessus en rechargeant la page.
395 417
 				return $i+1;
@@ -408,9 +430,10 @@  discard block
 block discarded – undo
408 430
 // http://doc.spip.org/@upgrade_types_documents
409 431
 function upgrade_types_documents() {
410 432
 	if (include_spip('base/medias')
411
-	AND function_exists('creer_base_types_doc'))
412
-		creer_base_types_doc();
413
-}
433
+	AND function_exists('creer_base_types_doc')) {
434
+			creer_base_types_doc();
435
+	}
436
+	}
414 437
 
415 438
 // http://doc.spip.org/@upgrade_test
416 439
 function upgrade_test() {
@@ -431,9 +454,9 @@  discard block
 block discarded – undo
431 454
 // http://doc.spip.org/@maj_version
432 455
 function maj_version ($version, $test = true) {
433 456
 	if ($test) {
434
-		if ($version>=1.922)
435
-			ecrire_meta('version_installee', $version, 'oui');
436
-		else {
457
+		if ($version>=1.922) {
458
+					ecrire_meta('version_installee', $version, 'oui');
459
+		} else {
437 460
 			// on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
438 461
 			$GLOBALS['meta']['version_installee'] = $version;
439 462
 			sql_updateq('spip_meta',  array('valeur' => $version), "nom=" . sql_quote('version_installee') );
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 4 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.
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.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11 11
 \***************************************************************************/
12 12
 
13
-if (!defined('_ECRIRE_INC_VERSION')) return;
13
+if (!defined('_ECRIRE_INC_VERSION')) {
14
+    return;
15
+}
14 16
 
15 17
 /**
16 18
  * Verifier si une mise a jour est disponible
@@ -53,11 +55,14 @@  discard block
 block discarded – undo
53 55
 		list(, $maj2, $min2,, $rev2) = $v;
54 56
 		$version_maj = $maj2 . '.' . $min2 . '.' . $rev2;
55 57
 		if ((spip_version_compare($version, $version_maj, '<'))
56
-		AND (spip_version_compare($page, $version_maj, '<')))
57
-			$page = $version_maj;
58
+		AND (spip_version_compare($page, $version_maj, '<'))) {
59
+					$page = $version_maj;
60
+		}
58 61
 	}
59 62
 
60
-	if (!$page) return "";
63
+	if (!$page) {
64
+	    return "";
65
+	}
61 66
 	return "<a class='info_maj_spip' href='"._VERSIONS_SERVEUR."$dir' title='$page'>" .
62 67
 		_T('nouvelle_version_spip',array('version'=>$page)) .
63 68
 	    '</a>';
@@ -71,14 +76,18 @@  discard block
 block discarded – undo
71 76
 function info_maj_cache($nom, $dir, $page='')
72 77
 {
73 78
 	$re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">';
74
-	if (preg_match("/$re/", $page)) return $page;
79
+	if (preg_match("/$re/", $page)) {
80
+	    return $page;
81
+	}
75 82
 
76 83
 	$url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE;
77 84
 	$a = file_exists($nom) ? filemtime($nom) : '';
78 85
 	include_spip('inc/distant');
79 86
 	$res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '',false, $a);
80 87
 	// Si rien de neuf (ou inaccessible), garder l'ancienne
81
-	if ($res) list(, $page) = $res;
88
+	if ($res) {
89
+	    list(, $page) = $res;
90
+	}
82 91
 	// Placer l'indicateur de fraicheur
83 92
 	$page = preg_replace('/^<archives.*?>/', $re, $page);
84 93
 	sous_repertoire(_DIR_CACHE_XML);
Please login to merge, or discard this patch.
ecrire/inc/filtres_images_mini.php 4 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.
Braces   +56 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11 11
 \***************************************************************************/
12 12
 
13
-if (!defined('_ECRIRE_INC_VERSION')) return;
13
+if (!defined('_ECRIRE_INC_VERSION')) {
14
+    return;
15
+}
14 16
 include_spip('inc/filtres_images_lib_mini'); // par precaution
15 17
 
16 18
 // http://doc.spip.org/@couleur_html_to_hex
@@ -18,8 +20,9 @@  discard block
 block discarded – undo
18 20
 	$couleurs_html=array(
19 21
 		'aqua'=>'00FFFF','black'=>'000000','blue'=>'0000FF','fuchsia'=>'FF00FF','gray'=>'808080','green'=>'008000','lime'=>'00FF00','maroon'=>'800000',
20 22
 		'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
+	if (isset($couleurs_html[$lc=strtolower($couleur)])) {
24
+			return $couleurs_html[$lc];
25
+	}
23 26
 	return $couleur;
24 27
 }
25 28
 
@@ -55,11 +58,14 @@  discard block
 block discarded – undo
55 58
 // dans la fonction image_filtrer
56 59
 // http://doc.spip.org/@image_select
57 60
 function image_select($img,$width_min=0, $height_min=0, $width_max=10000, $height_max=1000){
58
-	if (!$img) return $img;
61
+	if (!$img) {
62
+	    return $img;
63
+	}
59 64
 	list ($h,$l) = taille_image($img);
60 65
 	$select = true;
61
-	if ($l<$width_min OR $l>$width_max OR $h<$height_min OR $h>$height_max)
62
-		$select = false;
66
+	if ($l<$width_min OR $l>$width_max OR $h<$height_min OR $h>$height_max) {
67
+			$select = false;
68
+	}
63 69
 
64 70
 	$class = extraire_attribut($img,'class');
65 71
 	$p = strpos($class,'no_image_filtrer');
@@ -77,19 +83,28 @@  discard block
 block discarded – undo
77 83
 
78 84
 // http://doc.spip.org/@image_passe_partout
79 85
 function image_passe_partout($img,$taille_x = -1, $taille_y = -1,$force = false,$cherche_image=false,$process='AUTO'){
80
-	if (!$img) return '';
86
+	if (!$img) {
87
+	    return '';
88
+	}
81 89
 	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 '';
90
+	if ($taille_x == -1) {
91
+			$taille_x = isset($GLOBALS['meta']['taille_preview'])?$GLOBALS['meta']['taille_preview']:150;
92
+	}
93
+	if ($taille_y == -1) {
94
+			$taille_y = $taille_x;
95
+	}
96
+
97
+	if ($taille_x == 0 AND $taille_y > 0) {
98
+			$taille_x = 1;
99
+	}
100
+	# {0,300} -> c'est 300 qui compte
101
+	elseif ($taille_x > 0 AND $taille_y == 0) {
102
+			$taille_y = 1;
103
+	}
104
+	# {300,0} -> c'est 300 qui compte
105
+	elseif ($taille_x == 0 AND $taille_y == 0) {
106
+			return '';
107
+	}
93 108
 	
94 109
 	list($destWidth,$destHeight,$ratio) = ratio_passe_partout($largeur,$hauteur,$taille_x,$taille_y);
95 110
 	$fonction = array('image_passe_partout', func_get_args());
@@ -100,17 +115,24 @@  discard block
 block discarded – undo
100 115
 function image_reduire($img, $taille = -1, $taille_y = -1, $force=false, $cherche_image=false, $process='AUTO') {
101 116
 	// Determiner la taille x,y maxi
102 117
 	// 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 '';
118
+	if ($taille == -1) {
119
+			$taille = (isset($GLOBALS['meta']['taille_preview']) AND intval($GLOBALS['meta']['taille_preview']))?intval($GLOBALS['meta']['taille_preview']):150;
120
+	}
121
+	if ($taille_y == -1) {
122
+			$taille_y = $taille;
123
+	}
124
+
125
+	if ($taille == 0 AND $taille_y > 0) {
126
+			$taille = 10000;
127
+	}
128
+	# {0,300} -> c'est 300 qui compte
129
+	elseif ($taille > 0 AND $taille_y == 0) {
130
+			$taille_y = 10000;
131
+	}
132
+	# {300,0} -> c'est 300 qui compte
133
+	elseif ($taille == 0 AND $taille_y == 0) {
134
+			return '';
135
+	}
114 136
 
115 137
 	$fonction = array('image_reduire', func_get_args());
116 138
 	return process_image_reduire($fonction,$img,$taille,$taille_y,$force,$cherche_image,$process);
@@ -124,8 +146,11 @@  discard block
 block discarded – undo
124 146
 	$l = round($largeur/$val);
125 147
 	$h = round($hauteur/$val);
126 148
 	
127
-	if ($l > $h) $h = 0;
128
-	else $l = 0;
149
+	if ($l > $h) {
150
+	    $h = 0;
151
+	} else {
152
+	    $l = 0;
153
+	}
129 154
 	
130 155
 	$img = image_reduire($img, $l, $h, $force);
131 156
 
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 4 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.
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.
Braces   +42 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,23 +11,28 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 
14
-if (!defined('_ECRIRE_INC_VERSION')) return;
14
+if (!defined('_ECRIRE_INC_VERSION')) {
15
+    return;
16
+}
15 17
 
16 18
 // envoyer le navigateur sur une nouvelle adresse
17 19
 // en evitant les attaques par la redirection (souvent indique par 1 $_GET)
18 20
 
19 21
 // http://doc.spip.org/@redirige_par_entete
20 22
 function redirige_par_entete($url, $equiv='', $status = 302) {
21
-	if (!in_array($status,array(301,302)))
22
-		$status = 302;
23
+	if (!in_array($status,array(301,302))) {
24
+			$status = 302;
25
+	}
23 26
 
24 27
 	$url = trim(strtr($url, "\n\r", "  "));
25 28
 	# en theorie on devrait faire ca tout le temps, mais quand la chaine
26 29
 	# 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;
30
+	if ($url[0]=='?') {
31
+			$url = url_de_base().$url;
32
+	}
33
+	if ($url[0]=='#') {
34
+			$url = self('&').$url;
35
+	}
31 36
 	# si profondeur non nulle et url relative, il faut la passer en absolue
32 37
 	if ($GLOBALS['profondeur_url']>(_DIR_RESTREINT?1:2)
33 38
 		AND !preg_match(",^(\w+:)?//,",$url)){
@@ -35,11 +40,13 @@  discard block
 block discarded – undo
35 40
 		$url = url_absolue($url);
36 41
 	}
37 42
 
38
-	if ($x = _request('transformer_xml'))
39
-		$url = parametre_url($url, 'transformer_xml', $x, '&');
43
+	if ($x = _request('transformer_xml')) {
44
+			$url = parametre_url($url, 'transformer_xml', $x, '&');
45
+	}
40 46
 
41
-	if (defined('_AJAX') AND _AJAX)
42
-		$url = parametre_url($url, 'var_ajax_redir', 1, '&');
47
+	if (defined('_AJAX') AND _AJAX) {
48
+			$url = parametre_url($url, 'var_ajax_redir', 1, '&');
49
+	}
43 50
 		
44 51
 	// ne pas laisser passer n'importe quoi dans l'url
45 52
 	$url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
@@ -47,8 +54,9 @@  discard block
 block discarded – undo
47 54
 	if (
48 55
 		(preg_match(",data:,i",$url) AND preg_match("/base64\s*,/i",$url))
49 56
 		OR preg_match(",(javascript|mailto):,i",$url)
50
-		)
51
-		$url ="./";
57
+		) {
58
+			$url ="./";
59
+	}
52 60
 
53 61
 	// Il n'y a que sous Apache que setcookie puis redirection fonctionne
54 62
   include_spip('inc/cookie');
@@ -60,8 +68,9 @@  discard block
 block discarded – undo
60 68
 		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
61 69
 	}
62 70
 	include_spip('inc/lang');
63
-	if ($status!=302)
64
-		http_status($status);
71
+	if ($status!=302) {
72
+			http_status($status);
73
+	}
65 74
 	echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n",
66 75
 	  html_lang_attributes(),'
67 76
 <head>',
@@ -95,33 +104,35 @@  discard block
 block discarded – undo
95 104
 		"<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
96 105
 		// et rien dans le message ok
97 106
 		'');
98
-	}
99
-	else {
107
+	} else {
100 108
 		// ne pas laisser passer n'importe quoi dans l'url
101 109
 		$url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
102 110
 
103 111
 		$url = strtr($url, "\n\r", "  ");
104 112
 		# en theorie on devrait faire ca tout le temps, mais quand la chaine
105 113
 		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
106
-		if ($url[0]=='?')
107
-			$url = url_de_base().$url;
114
+		if ($url[0]=='?') {
115
+					$url = url_de_base().$url;
116
+		}
108 117
 		$url = str_replace('&amp;','&',$url);
109 118
 		spip_log("redirige formulaire ajax: $url");
110 119
 		include_spip('inc/filtres');
111
-		if ($format=='ajaxform')
112
-			return array(
120
+		if ($format=='ajaxform') {
121
+					return array(
113 122
 			// on renvoie un lien masque qui sera traite par ajaxCallback.js
114 123
 			'<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
115 124
 			// et un message au cas ou
116 125
 			'<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'
117 126
 			);
118
-		else // format message texte, tout en js inline
127
+		} else {
128
+		    // format message texte, tout en js inline
119 129
 			return
120 130
 		// ie poste les formulaires dans une iframe, il faut donc rediriger son parent
121 131
 		"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
122 132
 		. http_img_pack('searching.gif','')
123 133
 		. '<br />'
124 134
 		. '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
135
+		}
125 136
 	}
126 137
 }
127 138
 
@@ -145,14 +156,17 @@  discard block
 block discarded – undo
145 156
 		503 => '503 Service Unavailable'
146 157
 	);
147 158
 
148
-	if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return;
159
+	if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) {
160
+	    return;
161
+	}
149 162
 
150 163
 	$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
-}
164
+	if ($php_cgi) {
165
+			header("Status: ".$status_string[$status]);
166
+	} else {
167
+			header("HTTP/1.0 ".$status_string[$status]);
168
+	}
169
+	}
156 170
 
157 171
 // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache
158 172
 // http://doc.spip.org/@http_no_cache
Please login to merge, or discard this patch.
ecrire/inc/meta.php 4 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.
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.
Braces   +44 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11 11
 \***************************************************************************/
12 12
 
13
-if (!defined('_ECRIRE_INC_VERSION')) return;
13
+if (!defined('_ECRIRE_INC_VERSION')) {
14
+    return;
15
+}
14 16
 
15 17
 // Les parametres generaux du site sont dans une table SQL;
16 18
 // Recopie dans le tableau PHP global meta, car on en a souvent besoin
@@ -28,14 +30,18 @@  discard block
 block discarded – undo
28 30
 	if ((_request('exec')!=='install' OR !test_espace_prive())
29 31
 	AND $new = jeune_fichier($cache, _META_CACHE_TIME)
30 32
 	AND lire_fichier_securise($cache, $meta)
31
-	AND $meta = @unserialize($meta))
32
-		$GLOBALS[$table] = $meta;
33
+	AND $meta = @unserialize($meta)) {
34
+			$GLOBALS[$table] = $meta;
35
+	}
33 36
 
34 37
 	if (isset($GLOBALS[$table]['touch']) 
35
-	AND ($GLOBALS[$table]['touch']<time()-_META_CACHE_TIME))
36
-		$GLOBALS[$table] = array();
38
+	AND ($GLOBALS[$table]['touch']<time()-_META_CACHE_TIME)) {
39
+			$GLOBALS[$table] = array();
40
+	}
37 41
 	// sinon lire en base
38
-	if (!$GLOBALS[$table]) $new = !lire_metas($table);
42
+	if (!$GLOBALS[$table]) {
43
+	    $new = !lire_metas($table);
44
+	}
39 45
 
40 46
 	// renouveller l'alea general si trop vieux ou sur demande explicite
41 47
 	if ((test_espace_prive() || isset($_GET['renouvelle_alea']))
@@ -47,11 +53,15 @@  discard block
 block discarded – undo
47 53
 			include_spip('inc/acces');
48 54
 			renouvelle_alea();
49 55
 			$new = false; 
50
-		} else spip_log("impossible d'ecrire dans " . $cache);
56
+		} else {
57
+		    spip_log("impossible d'ecrire dans " . $cache);
58
+		}
51 59
 	}
52 60
 	// et refaire le cache si on a du lire en base
53
-	if (!$new) touch_meta(false, $table);
54
-}
61
+	if (!$new) {
62
+	    touch_meta(false, $table);
63
+	}
64
+	}
55 65
 
56 66
 // fonctions aussi appelees a l'install ==> spip_query en premiere requete 
57 67
 // pour eviter l'erreur fatale (serveur non encore configure)
@@ -62,20 +72,23 @@  discard block
 block discarded – undo
62 72
 	if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
63 73
 		include_spip('base/abstract_sql');
64 74
 		$GLOBALS[$table] = array();
65
-		while ($row = sql_fetch($result))
66
-			$GLOBALS[$table][$row['nom']] = $row['valeur'];
75
+		while ($row = sql_fetch($result)) {
76
+					$GLOBALS[$table][$row['nom']] = $row['valeur'];
77
+		}
67 78
         sql_free($result);
68 79
 
69 80
 		if (!$GLOBALS[$table]['charset']
70 81
 		  OR $GLOBALS[$table]['charset']=='_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
71
-		)
72
-			ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table);
82
+		) {
83
+					ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table);
84
+		}
73 85
 
74 86
 		// noter cette table de configuration dans les meta de SPIP
75 87
 		if ($table!=='meta') {
76 88
 			$liste = unserialize($GLOBALS['meta']['tables_config']);
77
-			if (!$liste)
78
-				$liste = array();
89
+			if (!$liste) {
90
+							$liste = array();
91
+			}
79 92
 			if (!in_array($table, $liste)) {
80 93
 				$liste[] = $table;
81 94
 				ecrire_meta('tables_config', serialize($liste));
@@ -98,7 +111,9 @@  discard block
 block discarded – undo
98 111
 		// mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
99 112
 		// meme si son squelette est en cache
100 113
 		//unset($r['secret_du_site']);
101
-		if ($antidate) $r['touch']= $antidate;
114
+		if ($antidate) {
115
+		    $r['touch']= $antidate;
116
+		}
102 117
 		ecrire_fichier_securise($file, serialize($r));
103 118
 	}
104 119
 }
@@ -121,7 +136,9 @@  discard block
 block discarded – undo
121 136
 function ecrire_meta($nom, $valeur, $importable = NULL, $table='meta') {
122 137
 
123 138
 	static $touch = array();
124
-	if (!$nom) return;
139
+	if (!$nom) {
140
+	    return;
141
+	}
125 142
 	include_spip('base/abstract_sql');
126 143
 	$res = sql_select("*",'spip_' . $table,"nom=" . sql_quote($nom),'','','','','','continue');
127 144
 	// table pas encore installee, travailler en php seulement
@@ -134,7 +151,9 @@  discard block
 block discarded – undo
134 151
 
135 152
 	// ne pas invalider le cache si affectation a l'identique
136 153
 	// (tant pis si impt aurait du changer)
137
-	if ($row AND $valeur == $row['valeur'] AND $GLOBALS[$table][$nom] == $valeur) return;
154
+	if ($row AND $valeur == $row['valeur'] AND $GLOBALS[$table][$nom] == $valeur) {
155
+	    return;
156
+	}
138 157
 
139 158
 	$GLOBALS[$table][$nom] = $valeur;
140 159
 	// cf effacer pour comprendre le double touch
@@ -142,7 +161,9 @@  discard block
 block discarded – undo
142 161
 	if (!isset($touch[$table])) {touch_meta($antidate, $table);}
143 162
 	$r = array('nom' => $nom, 'valeur' => $valeur);
144 163
 	// Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
145
-	if ($importable AND isset($row['impt'])) $r['impt'] = $importable;
164
+	if ($importable AND isset($row['impt'])) {
165
+	    $r['impt'] = $importable;
166
+	}
146 167
 	if ($row) {
147 168
 		sql_updateq('spip_' . $table, $r,"nom=" . sql_quote($nom));
148 169
 	} else {
@@ -179,7 +200,10 @@  discard block
 block discarded – undo
179 200
  * @param bool $force
180 201
  */
181 202
 function supprimer_table_meta($table, $force=false) {
182
-	if ($table=='meta') return; // interdit !
203
+	if ($table=='meta') {
204
+	    return;
205
+	}
206
+	// interdit !
183 207
 
184 208
 	if ($force OR !sql_countsel("spip_$table")) {
185 209
 		unset($GLOBALS[$table]);
Please login to merge, or discard this patch.
ecrire/inc/selectionner.php 4 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.
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.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11 11
 \***************************************************************************/
12 12
 
13
-if (!defined('_ECRIRE_INC_VERSION')) return;
13
+if (!defined('_ECRIRE_INC_VERSION')) {
14
+    return;
15
+}
14 16
 
15 17
 include_spip('inc/filtres');
16 18
 
@@ -21,7 +23,11 @@  discard block
 block discarded – undo
21 23
 // http://doc.spip.org/@inc_selectionner_dist
22 24
 function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') {
23 25
 
24
-	if ($recur) $recur = mini_hier($sel); else $sel = 0;
26
+	if ($recur) {
27
+	    $recur = mini_hier($sel);
28
+	} else {
29
+	    $sel = 0;
30
+	}
25 31
 
26 32
 	if ($aff_racine) {
27 33
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
@@ -118,8 +124,9 @@  discard block
 block discarded – undo
118 124
 	
119 125
 	$liste = $id_rubrique;
120 126
 	$id_rubrique = intval($id_rubrique);
121
-	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
122
-		$liste = $id_rubrique . ",$liste";
127
+	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) {
128
+			$liste = $id_rubrique . ",$liste";
129
+	}
123 130
 	return explode(',',"0,$liste");
124 131
 }
125 132
 
Please login to merge, or discard this patch.