Completed
Push — develop ( 923a1c...1e9876 )
by Maxim
47s queued 29s
created
manager/media/browser/mcpuk/lib/class_gd.php 3 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -1,44 +1,44 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc GD extension class
6
-  *   @package KCFinder
7
-  *   @version 2.51
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010, 2011 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc GD extension class
6
+ *   @package KCFinder
7
+ *   @version 2.51
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010, 2011 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class gd {
16 16
 
17
-  /** GD resource
18
-    * @var resource */
17
+    /** GD resource
18
+     * @var resource */
19 19
     protected $image;
20 20
 
21
-  /** Image width
22
-    * @var integer */
21
+    /** Image width
22
+     * @var integer */
23 23
     protected $width;
24 24
 
25
-  /** Image height
26
-    * @var integer */
25
+    /** Image height
26
+     * @var integer */
27 27
     protected $height;
28 28
 
29
-  /** Init error
30
-    * @var bool */
29
+    /** Init error
30
+     * @var bool */
31 31
     public $init_error = false;
32 32
 
33
-  /** Last builded image type constant (IMAGETYPE_XXX)
34
-    * @var integer */
33
+    /** Last builded image type constant (IMAGETYPE_XXX)
34
+     * @var integer */
35 35
     public $type;
36 36
 
37
-  /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height.
38
-    * Returns FALSE on failure. The only one parameter $image can be an instance of this class,
39
-    * a GD resource, an array(width, height) or path to image file.
40
-    * @param mixed $image
41
-    * @return array */
37
+    /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height.
38
+     * Returns FALSE on failure. The only one parameter $image can be an instance of this class,
39
+     * a GD resource, an array(width, height) or path to image file.
40
+     * @param mixed $image
41
+     * @return array */
42 42
 
43 43
     protected function build_image($image) {
44 44
 
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
         return $return;
88 88
     }
89 89
 
90
-  /** Parameter $image can be:
91
-    *   1. An instance of this class (copy instance).
92
-    *   2. A GD resource.
93
-    *   3. An array with two elements. First - width, second - height. Create a blank image.
94
-    *   4. A filename string. Get image form file.
95
-    * The non-required parameter $bigger_size is the bigger dimension (width or height) the image
96
-    * will be resized to. The other dimension (height or width) will be calculated autamaticaly
97
-    * @param mixed $image
98
-    * @param integer $bigger_size
99
-    * @return gd */
90
+    /** Parameter $image can be:
91
+     *   1. An instance of this class (copy instance).
92
+     *   2. A GD resource.
93
+     *   3. An array with two elements. First - width, second - height. Create a blank image.
94
+     *   4. A filename string. Get image form file.
95
+     * The non-required parameter $bigger_size is the bigger dimension (width or height) the image
96
+     * will be resized to. The other dimension (height or width) will be calculated autamaticaly
97
+     * @param mixed $image
98
+     * @param integer $bigger_size
99
+     * @return gd */
100 100
 
101 101
     public function __construct($image, $bigger_size=null) {
102 102
         $this->image = $this->width = $this->height = null;
@@ -123,30 +123,30 @@  discard block
 block discarded – undo
123 123
         }
124 124
     }
125 125
 
126
-  /** Returns the GD resource
127
-    * @return resource */
126
+    /** Returns the GD resource
127
+     * @return resource */
128 128
 
129 129
     public function get_image() {
130 130
         return $this->image;
131 131
     }
132 132
 
133
-  /** Returns the image width
134
-    * @return integer */
133
+    /** Returns the image width
134
+     * @return integer */
135 135
 
136 136
     public function get_width() {
137 137
         return $this->width;
138 138
     }
139 139
 
140
-  /** Returns the image height
141
-    * @return integer */
140
+    /** Returns the image height
141
+     * @return integer */
142 142
 
143 143
     public function get_height() {
144 144
         return $this->height;
145 145
     }
146 146
 
147
-  /** Returns calculated proportional width from the given height
148
-    * @param integer $resized_height
149
-    * @return integer */
147
+    /** Returns calculated proportional width from the given height
148
+     * @param integer $resized_height
149
+     * @return integer */
150 150
 
151 151
     public function get_prop_width($resized_height) {
152 152
         $width = intval(($this->width * $resized_height) / $this->height);
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
         return $width;
155 155
     }
156 156
 
157
-  /** Returns calculated proportional height from the given width
158
-    * @param integer $resized_width
159
-    * @return integer */
157
+    /** Returns calculated proportional height from the given width
158
+     * @param integer $resized_width
159
+     * @return integer */
160 160
 
161 161
     public function get_prop_height($resized_width) {
162 162
         $height = intval(($this->height * $resized_width) / $this->width);
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
         return $height;
165 165
     }
166 166
 
167
-  /** Returns an array with calculated proportional width & height.
168
-    * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes.
169
-    * The other dimension (height or width) will be calculated autamaticaly
170
-    * @param integer $bigger_size
171
-    * @return array */
167
+    /** Returns an array with calculated proportional width & height.
168
+     * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes.
169
+     * The other dimension (height or width) will be calculated autamaticaly
170
+     * @param integer $bigger_size
171
+     * @return array */
172 172
 
173 173
     public function get_prop_size($bigger_size) {
174 174
 
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
         return array($width, $height);
187 187
     }
188 188
 
189
-  /** Resize image. Returns TRUE on success or FALSE on failure
190
-    * @param integer $width
191
-    * @param integer $height
192
-    * @return bool */
189
+    /** Resize image. Returns TRUE on success or FALSE on failure
190
+     * @param integer $width
191
+     * @param integer $height
192
+     * @return bool */
193 193
 
194 194
     public function resize($width, $height) {
195 195
         if (!$width) $width = 1;
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
         );
204 204
     }
205 205
 
206
-  /** Resize the given image source (GD, gd object or image file path) to fit in the own image.
207
-    * The outside ares will be cropped out. Returns TRUE on success or FALSE on failure
208
-    * @param mixed $src
209
-    * @return bool */
206
+    /** Resize the given image source (GD, gd object or image file path) to fit in the own image.
207
+     * The outside ares will be cropped out. Returns TRUE on success or FALSE on failure
208
+     * @param mixed $src
209
+     * @return bool */
210 210
 
211 211
     public function resize_crop($src) {
212 212
         $image_details = $this->build_image($src);
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
             return false;
234 234
     }
235 235
 
236
-  /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure
237
-    * @param integer $width
238
-    * @param integer $height
239
-    * @return bool */
236
+    /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure
237
+     * @param integer $width
238
+     * @param integer $height
239
+     * @return bool */
240 240
 
241 241
     public function resize_fit($width, $height) {
242 242
         if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
         return $this->resize($width, $height);
251 251
     }
252 252
 
253
-  /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height.
254
-    * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik,
255
-    * no samo po edno (x ili y) izmerenie
256
-    * @param integer $width
257
-    * @param integer $height
258
-    * @return bool */
253
+    /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height.
254
+     * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik,
255
+     * no samo po edno (x ili y) izmerenie
256
+     * @param integer $width
257
+     * @param integer $height
258
+     * @return bool */
259 259
 
260 260
     public function resize_overflow($width, $height) {
261 261
 
@@ -368,30 +368,30 @@  discard block
 block discarded – undo
368 368
 
369 369
 
370 370
 
371
-			/*** gif transparent fix - 1.10.2013 ***/
371
+            /*** gif transparent fix - 1.10.2013 ***/
372 372
 
373
-			$transindex = imagecolortransparent($src);
374
-			$palletsize = imagecolorstotal($src);
375
-			if($transindex >= 0 && $transindex < $palletsize) {
376
-				$transcol = imagecolorsforindex($src, $transindex);
373
+            $transindex = imagecolortransparent($src);
374
+            $palletsize = imagecolorstotal($src);
375
+            if($transindex >= 0 && $transindex < $palletsize) {
376
+                $transcol = imagecolorsforindex($src, $transindex);
377 377
 
378
-			/*** end gif transparent fix ***/
378
+            /*** end gif transparent fix ***/
379 379
 
380
-				$transindex = imagecolorallocatealpha($this->image, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
381
-				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382
-				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383
-				imagecolortransparent($this->image, $transindex);
384
-				for($y=0; $y<$dst_h; ++$y)
385
-					for($x=0; $x<$dst_w; ++$x)
386
-						if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
387
-				imagetruecolortopalette($this->image, true, 255);
388
-			}
389
-			else {
390
-				$transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
391
-				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent);
392
-				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
393
-			}
394
-			return $this->image;
380
+                $transindex = imagecolorallocatealpha($this->image, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
381
+                imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382
+                imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383
+                imagecolortransparent($this->image, $transindex);
384
+                for($y=0; $y<$dst_h; ++$y)
385
+                    for($x=0; $x<$dst_w; ++$x)
386
+                        if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
387
+                imagetruecolortopalette($this->image, true, 255);
388
+            }
389
+            else {
390
+                $transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
391
+                imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent);
392
+                imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
393
+            }
394
+            return $this->image;
395 395
 
396 396
         } else
397 397
             return false;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
     public function imagegif($filename=null) {
420 420
         if (is_null($filename) && !headers_sent())
421 421
             header("Content-Type: image/gif");
422
-			@imagesavealpha($this->image, true);
422
+            @imagesavealpha($this->image, true);
423 423
         return imagegif($this->image, $filename);
424 424
     }
425 425
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class gd {
15
+class gd{
16 16
 
17 17
   /** GD resource
18 18
     * @var resource */
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     * @param mixed $image
41 41
     * @return array */
42 42
 
43
-    protected function build_image($image) {
43
+    protected function build_image($image){
44 44
 
45 45
         if ($image instanceof gd) {
46 46
             $width = $image->get_width();
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 
59 59
         } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
60 60
             $image =
61
-                ($type == IMAGETYPE_GIF)      ? @imagecreatefromgif($image)  : (
62
-                ($type == IMAGETYPE_WBMP)     ? @imagecreatefromwbmp($image) : (
63
-                ($type == IMAGETYPE_JPEG)     ? @imagecreatefromjpeg($image) : (
61
+                ($type == IMAGETYPE_GIF) ? @imagecreatefromgif($image) : (
62
+                ($type == IMAGETYPE_WBMP) ? @imagecreatefromwbmp($image) : (
63
+                ($type == IMAGETYPE_JPEG) ? @imagecreatefromjpeg($image) : (
64 64
                 ($type == IMAGETYPE_JPEG2000) ? @imagecreatefromjpeg($image) : (
65
-                ($type == IMAGETYPE_PNG)      ? @imagecreatefrompng($image)  : (
66
-                ($type == IMAGETYPE_XBM)      ? @imagecreatefromxbm($image)  : false
65
+                ($type == IMAGETYPE_PNG) ? @imagecreatefrompng($image) : (
66
+                ($type == IMAGETYPE_XBM) ? @imagecreatefromxbm($image) : false
67 67
             )))));
68 68
 
69 69
             if ($type == IMAGETYPE_PNG)
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     * @param integer $bigger_size
99 99
     * @return gd */
100 100
 
101
-    public function __construct($image, $bigger_size=null) {
101
+    public function __construct($image, $bigger_size = null){
102 102
         $this->image = $this->width = $this->height = null;
103 103
 
104 104
         $image_details = $this->build_image($image);
@@ -126,21 +126,21 @@  discard block
 block discarded – undo
126 126
   /** Returns the GD resource
127 127
     * @return resource */
128 128
 
129
-    public function get_image() {
129
+    public function get_image(){
130 130
         return $this->image;
131 131
     }
132 132
 
133 133
   /** Returns the image width
134 134
     * @return integer */
135 135
 
136
-    public function get_width() {
136
+    public function get_width(){
137 137
         return $this->width;
138 138
     }
139 139
 
140 140
   /** Returns the image height
141 141
     * @return integer */
142 142
 
143
-    public function get_height() {
143
+    public function get_height(){
144 144
         return $this->height;
145 145
     }
146 146
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     * @param integer $resized_height
149 149
     * @return integer */
150 150
 
151
-    public function get_prop_width($resized_height) {
151
+    public function get_prop_width($resized_height){
152 152
         $width = intval(($this->width * $resized_height) / $this->height);
153 153
         if (!$width) $width = 1;
154 154
         return $width;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     * @param integer $resized_width
159 159
     * @return integer */
160 160
 
161
-    public function get_prop_height($resized_width) {
161
+    public function get_prop_height($resized_width){
162 162
         $height = intval(($this->height * $resized_width) / $this->width);
163 163
         if (!$height) $height = 1;
164 164
         return $height;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     * @param integer $bigger_size
171 171
     * @return array */
172 172
 
173
-    public function get_prop_size($bigger_size) {
173
+    public function get_prop_size($bigger_size){
174 174
 
175 175
         if ($this->width > $this->height) {
176 176
             $width = $bigger_size;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     * @param integer $height
192 192
     * @return bool */
193 193
 
194
-    public function resize($width, $height) {
194
+    public function resize($width, $height){
195 195
         if (!$width) $width = 1;
196 196
         if (!$height) $height = 1;
197 197
         return (
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
     * @param mixed $src
209 209
     * @return bool */
210 210
 
211
-    public function resize_crop($src) {
211
+    public function resize_crop($src){
212 212
         $image_details = $this->build_image($src);
213 213
 
214 214
         if ($image_details !== false) {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     * @param integer $height
239 239
     * @return bool */
240 240
 
241
-    public function resize_fit($width, $height) {
241
+    public function resize_fit($width, $height){
242 242
         if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
243 243
             return true;
244 244
         if (!$width || (($height / $width) < ($this->height / $this->width)))
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     * @param integer $height
258 258
     * @return bool */
259 259
 
260
-    public function resize_overflow($width, $height) {
260
+    public function resize_overflow($width, $height){
261 261
 
262 262
         $big = (($this->width / $this->height) > ($width / $height))
263 263
             ? ($this->width * $height) / $this->height
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         return $return;
276 276
     }
277 277
 
278
-    public function gd_color() {
278
+    public function gd_color(){
279 279
         $args = func_get_args();
280 280
 
281 281
         $expr_rgb = '/^rgb\(\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\)$/i';
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
         return imagecolorallocate($this->image, $r, $g, $b);
318 318
     }
319 319
 
320
-    public function fill_color($color) {
320
+    public function fill_color($color){
321 321
         return $this->imagefilledrectangle(0, 0, $this->width - 1, $this->height - 1, $color);
322 322
     }
323 323
 
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 
327 327
     public function imagecopy(
328 328
         $src,
329
-        $dst_x=0, $dst_y=0,
330
-        $src_x=0, $src_y=0,
331
-        $dst_w=null, $dst_h=null,
332
-        $src_w=null, $src_h=null
333
-    ) {
329
+        $dst_x = 0, $dst_y = 0,
330
+        $src_x = 0, $src_y = 0,
331
+        $dst_w = null, $dst_h = null,
332
+        $src_w = null, $src_h = null
333
+    ){
334 334
         $image_details = $this->build_image($src);
335 335
 
336 336
         if ($image_details !== false) {
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 
349 349
     public function imagecopyresampled(
350 350
         $src,
351
-        $dst_x=0, $dst_y=0,
352
-        $src_x=0, $src_y=0,
353
-        $dst_w=null, $dst_h=null,
354
-        $src_w=null, $src_h=null
355
-    ) {
351
+        $dst_x = 0, $dst_y = 0,
352
+        $src_x = 0, $src_y = 0,
353
+        $dst_w = null, $dst_h = null,
354
+        $src_w = null, $src_h = null
355
+    ){
356 356
         $image_details = $this->build_image($src);
357 357
 
358 358
         if ($image_details !== false) {
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
             if (is_null($src_w)) $src_w = $src_width - $src_x;
364 364
             if (is_null($src_h)) $src_h = $src_height - $src_y;
365 365
             imagealphablending($this->image, false);
366
-            imagesavealpha($this->image,true);
366
+            imagesavealpha($this->image, true);
367 367
 
368 368
 
369 369
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
 			$transindex = imagecolortransparent($src);
374 374
 			$palletsize = imagecolorstotal($src);
375
-			if($transindex >= 0 && $transindex < $palletsize) {
375
+			if ($transindex >= 0 && $transindex < $palletsize) {
376 376
 				$transcol = imagecolorsforindex($src, $transindex);
377 377
 
378 378
 			/*** end gif transparent fix ***/
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382 382
 				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383 383
 				imagecolortransparent($this->image, $transindex);
384
-				for($y=0; $y<$dst_h; ++$y)
385
-					for($x=0; $x<$dst_w; ++$x)
386
-						if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
384
+				for ($y = 0; $y < $dst_h; ++$y)
385
+					for ($x = 0; $x < $dst_w; ++$x)
386
+						if (((imagecolorat($this->image, $x, $y) >> 24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
387 387
 				imagetruecolortopalette($this->image, true, 255);
388 388
 			}
389 389
 			else {
@@ -397,26 +397,26 @@  discard block
 block discarded – undo
397 397
             return false;
398 398
     }
399 399
 
400
-    public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) {
400
+    public function imagefilledrectangle($x1, $y1, $x2, $y2, $color){
401 401
         $color = $this->gd_color($color);
402 402
         if ($color === false) return false;
403 403
         return imagefilledrectangle($this->image, $x1, $y1, $x2, $y2, $color);
404 404
     }
405 405
 
406
-    public function imagepng($filename=null, $quality=null, $filters=null) {
406
+    public function imagepng($filename = null, $quality = null, $filters = null){
407 407
         if (is_null($filename) && !headers_sent())
408 408
             header("Content-Type: image/png");
409 409
         @imagesavealpha($this->image, true);
410 410
         return imagepng($this->image, $filename, $quality, $filters);
411 411
     }
412 412
 
413
-    public function imagejpeg($filename=null, $quality=75) {
413
+    public function imagejpeg($filename = null, $quality = 75){
414 414
         if (is_null($filename) && !headers_sent())
415 415
             header("Content-Type: image/jpeg");
416 416
         return imagejpeg($this->image, $filename, $quality);
417 417
     }
418 418
 
419
-    public function imagegif($filename=null) {
419
+    public function imagegif($filename = null){
420 420
         if (is_null($filename) && !headers_sent())
421 421
             header("Content-Type: image/gif");
422 422
 			@imagesavealpha($this->image, true);
Please login to merge, or discard this patch.
Braces   +157 added lines, -92 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
   *      @link http://kcfinder.sunhater.com
13 13
   */
14 14
 
15
-class gd {
15
+class gd
16
+{
16 17
 
17 18
   /** GD resource
18 19
     * @var resource */
@@ -40,23 +41,24 @@  discard block
 block discarded – undo
40 41
     * @param mixed $image
41 42
     * @return array */
42 43
 
43
-    protected function build_image($image) {
44
+    protected function build_image($image)
45
+    {
44 46
 
45
-        if ($image instanceof gd) {
47
+        if ($image instanceof gd) {
46 48
             $width = $image->get_width();
47 49
             $height = $image->get_height();
48 50
             $image = $image->get_image();
49 51
 
50
-        } elseif (is_resource($image) && (get_resource_type($image) == "gd")) {
52
+        } elseif (is_resource($image) && (get_resource_type($image) == "gd")) {
51 53
             $width = @imagesx($image);
52 54
             $height = @imagesy($image);
53 55
 
54
-        } elseif (is_array($image)) {
56
+        } elseif (is_array($image)) {
55 57
             list($key, $width) = each($image);
56 58
             list($key, $height) = each($image);
57 59
             $image = imagecreatetruecolor($width, $height);
58 60
 
59
-        } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
61
+        } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
60 62
             $image =
61 63
                 ($type == IMAGETYPE_GIF)      ? @imagecreatefromgif($image)  : (
62 64
                 ($type == IMAGETYPE_WBMP)     ? @imagecreatefromwbmp($image) : (
@@ -66,8 +68,9 @@  discard block
 block discarded – undo
66 68
                 ($type == IMAGETYPE_XBM)      ? @imagecreatefromxbm($image)  : false
67 69
             )))));
68 70
 
69
-            if ($type == IMAGETYPE_PNG)
70
-                imagealphablending($image, false);
71
+            if ($type == IMAGETYPE_PNG) {
72
+                            imagealphablending($image, false);
73
+            }
71 74
         }
72 75
 
73 76
         $return = (
@@ -81,8 +84,9 @@  discard block
 block discarded – undo
81 84
             ? array($image, $width, $height)
82 85
             : false;
83 86
 
84
-        if (($return !== false) && isset($type))
85
-            $this->type = $type;
87
+        if (($return !== false) && isset($type)) {
88
+                    $this->type = $type;
89
+        }
86 90
 
87 91
         return $return;
88 92
     }
@@ -98,20 +102,22 @@  discard block
 block discarded – undo
98 102
     * @param integer $bigger_size
99 103
     * @return gd */
100 104
 
101
-    public function __construct($image, $bigger_size=null) {
105
+    public function __construct($image, $bigger_size=null)
106
+    {
102 107
         $this->image = $this->width = $this->height = null;
103 108
 
104 109
         $image_details = $this->build_image($image);
105 110
 
106
-        if ($image_details !== false)
107
-            list($this->image, $this->width, $this->height) = $image_details;
108
-        else
109
-            $this->init_error = true;
111
+        if ($image_details !== false) {
112
+                    list($this->image, $this->width, $this->height) = $image_details;
113
+        } else {
114
+                    $this->init_error = true;
115
+        }
110 116
 
111 117
         if (!is_null($this->image) &&
112 118
             !is_null($bigger_size) &&
113 119
             (preg_match('/^[1-9][0-9]*$/', $bigger_size) !== false)
114
-        ) {
120
+        ) {
115 121
             $image = $this->image;
116 122
             list($width, $height) = $this->get_prop_size($bigger_size);
117 123
             $this->image = imagecreatetruecolor($width, $height);
@@ -126,21 +132,24 @@  discard block
 block discarded – undo
126 132
   /** Returns the GD resource
127 133
     * @return resource */
128 134
 
129
-    public function get_image() {
135
+    public function get_image()
136
+    {
130 137
         return $this->image;
131 138
     }
132 139
 
133 140
   /** Returns the image width
134 141
     * @return integer */
135 142
 
136
-    public function get_width() {
143
+    public function get_width()
144
+    {
137 145
         return $this->width;
138 146
     }
139 147
 
140 148
   /** Returns the image height
141 149
     * @return integer */
142 150
 
143
-    public function get_height() {
151
+    public function get_height()
152
+    {
144 153
         return $this->height;
145 154
     }
146 155
 
@@ -148,9 +157,12 @@  discard block
 block discarded – undo
148 157
     * @param integer $resized_height
149 158
     * @return integer */
150 159
 
151
-    public function get_prop_width($resized_height) {
160
+    public function get_prop_width($resized_height)
161
+    {
152 162
         $width = intval(($this->width * $resized_height) / $this->height);
153
-        if (!$width) $width = 1;
163
+        if (!$width) {
164
+            $width = 1;
165
+        }
154 166
         return $width;
155 167
     }
156 168
 
@@ -158,9 +170,12 @@  discard block
 block discarded – undo
158 170
     * @param integer $resized_width
159 171
     * @return integer */
160 172
 
161
-    public function get_prop_height($resized_width) {
173
+    public function get_prop_height($resized_width)
174
+    {
162 175
         $height = intval(($this->height * $resized_width) / $this->width);
163
-        if (!$height) $height = 1;
176
+        if (!$height) {
177
+            $height = 1;
178
+        }
164 179
         return $height;
165 180
     }
166 181
 
@@ -170,18 +185,20 @@  discard block
 block discarded – undo
170 185
     * @param integer $bigger_size
171 186
     * @return array */
172 187
 
173
-    public function get_prop_size($bigger_size) {
188
+    public function get_prop_size($bigger_size)
189
+    {
174 190
 
175
-        if ($this->width > $this->height) {
191
+        if ($this->width > $this->height) {
176 192
             $width = $bigger_size;
177 193
             $height = $this->get_prop_height($width);
178 194
 
179
-        } elseif ($this->height > $this->width) {
195
+        } elseif ($this->height > $this->width) {
180 196
             $height = $bigger_size;
181 197
             $width = $this->get_prop_width($height);
182 198
 
183
-        } else
184
-            $width = $height = $bigger_size;
199
+        } else {
200
+                    $width = $height = $bigger_size;
201
+        }
185 202
 
186 203
         return array($width, $height);
187 204
     }
@@ -191,9 +208,14 @@  discard block
 block discarded – undo
191 208
     * @param integer $height
192 209
     * @return bool */
193 210
 
194
-    public function resize($width, $height) {
195
-        if (!$width) $width = 1;
196
-        if (!$height) $height = 1;
211
+    public function resize($width, $height)
212
+    {
213
+        if (!$width) {
214
+            $width = 1;
215
+        }
216
+        if (!$height) {
217
+            $height = 1;
218
+        }
197 219
         return (
198 220
             (false !== ($img = new gd(array($width, $height)))) &&
199 221
             $img->imagecopyresampled($this) &&
@@ -208,19 +230,20 @@  discard block
 block discarded – undo
208 230
     * @param mixed $src
209 231
     * @return bool */
210 232
 
211
-    public function resize_crop($src) {
233
+    public function resize_crop($src)
234
+    {
212 235
         $image_details = $this->build_image($src);
213 236
 
214
-        if ($image_details !== false) {
237
+        if ($image_details !== false) {
215 238
             list($src, $src_width, $src_height) = $image_details;
216 239
 
217
-            if (($src_width / $src_height) > ($this->width / $this->height)) {
240
+            if (($src_width / $src_height) > ($this->width / $this->height)) {
218 241
                 $src_w = $this->get_prop_width($src_height);
219 242
                 $src_h = $src_height;
220 243
                 $src_x = intval(($src_width - $src_w) / 2);
221 244
                 $src_y = 0;
222 245
 
223
-            } else {
246
+            } else {
224 247
                 $src_w = $src_width;
225 248
                 $src_h = $this->get_prop_height($src_width);
226 249
                 $src_x = 0;
@@ -229,8 +252,9 @@  discard block
 block discarded – undo
229 252
 
230 253
             return imagecopyresampled($this->image, $src, 0, 0, $src_x, $src_y, $this->width, $this->height, $src_w, $src_h);
231 254
 
232
-        } else
233
-            return false;
255
+        } else {
256
+                    return false;
257
+        }
234 258
     }
235 259
 
236 260
   /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure
@@ -238,15 +262,22 @@  discard block
 block discarded – undo
238 262
     * @param integer $height
239 263
     * @return bool */
240 264
 
241
-    public function resize_fit($width, $height) {
242
-        if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
243
-            return true;
244
-        if (!$width || (($height / $width) < ($this->height / $this->width)))
245
-            $width = intval(($this->width * $height) / $this->height);
246
-        elseif (!$height || (($width / $height) < ($this->width / $this->height)))
247
-            $height = intval(($this->height * $width) / $this->width);
248
-        if (!$width) $width = 1;
249
-        if (!$height) $height = 1;
265
+    public function resize_fit($width, $height)
266
+    {
267
+        if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height))) {
268
+                    return true;
269
+        }
270
+        if (!$width || (($height / $width) < ($this->height / $this->width))) {
271
+                    $width = intval(($this->width * $height) / $this->height);
272
+        } elseif (!$height || (($width / $height) < ($this->width / $this->height))) {
273
+                    $height = intval(($this->height * $width) / $this->width);
274
+        }
275
+        if (!$width) {
276
+            $width = 1;
277
+        }
278
+        if (!$height) {
279
+            $height = 1;
280
+        }
250 281
         return $this->resize($width, $height);
251 282
     }
252 283
 
@@ -257,7 +288,8 @@  discard block
 block discarded – undo
257 288
     * @param integer $height
258 289
     * @return bool */
259 290
 
260
-    public function resize_overflow($width, $height) {
291
+    public function resize_overflow($width, $height)
292
+    {
261 293
 
262 294
         $big = (($this->width / $this->height) > ($width / $height))
263 295
             ? ($this->width * $height) / $this->height
@@ -266,7 +298,7 @@  discard block
 block discarded – undo
266 298
 
267 299
         $return = ($img = new gd($this->image, $big));
268 300
 
269
-        if ($return) {
301
+        if ($return) {
270 302
             $this->image = $img->get_image();
271 303
             $this->width = $img->get_width();
272 304
             $this->height = $img->get_height();
@@ -275,7 +307,8 @@  discard block
 block discarded – undo
275 307
         return $return;
276 308
     }
277 309
 
278
-    public function gd_color() {
310
+    public function gd_color()
311
+    {
279 312
         $args = func_get_args();
280 313
 
281 314
         $expr_rgb = '/^rgb\(\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\,\s*(\d{1,3})\s*\)$/i';
@@ -283,22 +316,23 @@  discard block
 block discarded – undo
283 316
         $expr_hex2 = '/^\#?([0-9a-f])([0-9a-f])([0-9a-f])$/i';
284 317
         $expr_byte = '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/';
285 318
 
286
-        if (!isset($args[0]))
287
-            return false;
319
+        if (!isset($args[0])) {
320
+                    return false;
321
+        }
288 322
 
289
-        if (count($args[0]) == 3) {
323
+        if (count($args[0]) == 3) {
290 324
             list($r, $g, $b) = $args[0];
291 325
 
292
-        } elseif (preg_match($expr_rgb, $args[0])) {
326
+        } elseif (preg_match($expr_rgb, $args[0])) {
293 327
             list($r, $g, $b) = explode(" ", preg_replace($expr_rgb, "$1 $2 $3", $args[0]));
294 328
 
295
-        } elseif (preg_match($expr_hex1, $args[0])) {
329
+        } elseif (preg_match($expr_hex1, $args[0])) {
296 330
             list($r, $g, $b) = explode(" ", preg_replace($expr_hex1, "$1 $2 $3", $args[0]));
297 331
             $r = hexdec($r);
298 332
             $g = hexdec($g);
299 333
             $b = hexdec($b);
300 334
 
301
-        } elseif (preg_match($expr_hex2, $args[0])) {
335
+        } elseif (preg_match($expr_hex2, $args[0])) {
302 336
             list($r, $g, $b) = explode(" ", preg_replace($expr_hex2, "$1$1 $2$2 $3$3", $args[0]));
303 337
             $r = hexdec($r);
304 338
             $g = hexdec($g);
@@ -308,16 +342,18 @@  discard block
 block discarded – undo
308 342
             preg_match($expr_byte, $args[0]) &&
309 343
             preg_match($expr_byte, $args[1]) &&
310 344
             preg_match($expr_byte, $args[2])
311
-        ) {
345
+        ) {
312 346
             list($r, $g, $b) = $args;
313 347
 
314
-        } else
315
-            return false;
348
+        } else {
349
+                    return false;
350
+        }
316 351
 
317 352
         return imagecolorallocate($this->image, $r, $g, $b);
318 353
     }
319 354
 
320
-    public function fill_color($color) {
355
+    public function fill_color($color)
356
+    {
321 357
         return $this->imagefilledrectangle(0, 0, $this->width - 1, $this->height - 1, $color);
322 358
     }
323 359
 
@@ -330,20 +366,29 @@  discard block
 block discarded – undo
330 366
         $src_x=0, $src_y=0,
331 367
         $dst_w=null, $dst_h=null,
332 368
         $src_w=null, $src_h=null
333
-    ) {
369
+    ) {
334 370
         $image_details = $this->build_image($src);
335 371
 
336
-        if ($image_details !== false) {
372
+        if ($image_details !== false) {
337 373
             list($src, $src_width, $src_height) = $image_details;
338 374
 
339
-            if (is_null($dst_w)) $dst_w = $this->width - $dst_x;
340
-            if (is_null($dst_h)) $dst_h = $this->height - $dst_y;
341
-            if (is_null($src_w)) $src_w = $src_width - $src_x;
342
-            if (is_null($src_h)) $src_h = $src_height - $src_y;
375
+            if (is_null($dst_w)) {
376
+                $dst_w = $this->width - $dst_x;
377
+            }
378
+            if (is_null($dst_h)) {
379
+                $dst_h = $this->height - $dst_y;
380
+            }
381
+            if (is_null($src_w)) {
382
+                $src_w = $src_width - $src_x;
383
+            }
384
+            if (is_null($src_h)) {
385
+                $src_h = $src_height - $src_y;
386
+            }
343 387
             return imagecopy($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h);
344 388
 
345
-        } else
346
-            return false;
389
+        } else {
390
+                    return false;
391
+        }
347 392
     }
348 393
 
349 394
     public function imagecopyresampled(
@@ -352,16 +397,24 @@  discard block
 block discarded – undo
352 397
         $src_x=0, $src_y=0,
353 398
         $dst_w=null, $dst_h=null,
354 399
         $src_w=null, $src_h=null
355
-    ) {
400
+    ) {
356 401
         $image_details = $this->build_image($src);
357 402
 
358
-        if ($image_details !== false) {
403
+        if ($image_details !== false) {
359 404
             list($src, $src_width, $src_height) = $image_details;
360 405
 
361
-            if (is_null($dst_w)) $dst_w = $this->width - $dst_x;
362
-            if (is_null($dst_h)) $dst_h = $this->height - $dst_y;
363
-            if (is_null($src_w)) $src_w = $src_width - $src_x;
364
-            if (is_null($src_h)) $src_h = $src_height - $src_y;
406
+            if (is_null($dst_w)) {
407
+                $dst_w = $this->width - $dst_x;
408
+            }
409
+            if (is_null($dst_h)) {
410
+                $dst_h = $this->height - $dst_y;
411
+            }
412
+            if (is_null($src_w)) {
413
+                $src_w = $src_width - $src_x;
414
+            }
415
+            if (is_null($src_h)) {
416
+                $src_h = $src_height - $src_y;
417
+            }
365 418
             imagealphablending($this->image, false);
366 419
             imagesavealpha($this->image,true);
367 420
 
@@ -372,7 +425,7 @@  discard block
 block discarded – undo
372 425
 
373 426
 			$transindex = imagecolortransparent($src);
374 427
 			$palletsize = imagecolorstotal($src);
375
-			if($transindex >= 0 && $transindex < $palletsize) {
428
+			if($transindex >= 0 && $transindex < $palletsize) {
376 429
 				$transcol = imagecolorsforindex($src, $transindex);
377 430
 
378 431
 			/*** end gif transparent fix ***/
@@ -381,44 +434,56 @@  discard block
 block discarded – undo
381 434
 				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex);
382 435
 				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
383 436
 				imagecolortransparent($this->image, $transindex);
384
-				for($y=0; $y<$dst_h; ++$y)
385
-					for($x=0; $x<$dst_w; ++$x)
386
-						if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
437
+				for($y=0; $y<$dst_h; ++$y) {
438
+									for($x=0;
439
+				}
440
+				$x<$dst_w; ++$x) {
441
+											if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex);
442
+					}
387 443
 				imagetruecolortopalette($this->image, true, 255);
388
-			}
389
-			else {
444
+			} else {
390 445
 				$transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
391 446
 				imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent);
392 447
 				imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
393 448
 			}
394 449
 			return $this->image;
395 450
 
396
-        } else
397
-            return false;
451
+        } else {
452
+                    return false;
453
+        }
398 454
     }
399 455
 
400
-    public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) {
456
+    public function imagefilledrectangle($x1, $y1, $x2, $y2, $color)
457
+    {
401 458
         $color = $this->gd_color($color);
402
-        if ($color === false) return false;
459
+        if ($color === false) {
460
+            return false;
461
+        }
403 462
         return imagefilledrectangle($this->image, $x1, $y1, $x2, $y2, $color);
404 463
     }
405 464
 
406
-    public function imagepng($filename=null, $quality=null, $filters=null) {
407
-        if (is_null($filename) && !headers_sent())
408
-            header("Content-Type: image/png");
465
+    public function imagepng($filename=null, $quality=null, $filters=null)
466
+    {
467
+        if (is_null($filename) && !headers_sent()) {
468
+                    header("Content-Type: image/png");
469
+        }
409 470
         @imagesavealpha($this->image, true);
410 471
         return imagepng($this->image, $filename, $quality, $filters);
411 472
     }
412 473
 
413
-    public function imagejpeg($filename=null, $quality=75) {
414
-        if (is_null($filename) && !headers_sent())
415
-            header("Content-Type: image/jpeg");
474
+    public function imagejpeg($filename=null, $quality=75)
475
+    {
476
+        if (is_null($filename) && !headers_sent()) {
477
+                    header("Content-Type: image/jpeg");
478
+        }
416 479
         return imagejpeg($this->image, $filename, $quality);
417 480
     }
418 481
 
419
-    public function imagegif($filename=null) {
420
-        if (is_null($filename) && !headers_sent())
421
-            header("Content-Type: image/gif");
482
+    public function imagegif($filename=null)
483
+    {
484
+        if (is_null($filename) && !headers_sent()) {
485
+                    header("Content-Type: image/gif");
486
+        }
422 487
 			@imagesavealpha($this->image, true);
423 488
         return imagegif($this->image, $filename);
424 489
     }
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/js/browser/joiner.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,11 +23,13 @@
 block discarded – undo
23 23
 
24 24
 foreach ($files as $file) {
25 25
     $fmtime = filemtime($file);
26
-    if (!isset($mtime) || ($fmtime > $mtime))
27
-        $mtime = $fmtime;
28
-}
26
+    if (!isset($mtime) || ($fmtime > $mtime)) {
27
+            $mtime = $fmtime;
28
+    }
29
+    }
29 30
 
30 31
 httpCache::checkMTime($mtime);
31 32
 header("Content-Type: text/javascript");
32
-foreach ($files as $file)
33
+foreach ($files as $file) {
33 34
     require $file;
35
+}
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/config.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Base configuration file
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Base configuration file
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 // IMPORTANT!!! Do not remove uncommented settings in this file even if
16 16
 // you are using session configuration.
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     'dirnameChangeChars' => array(
71 71
         ' ' => "_",
72 72
         ':' => "."
73
-     ),
73
+        ),
74 74
     'mime_magic' => "",
75 75
 
76 76
     'maxImageWidth' => $modx->config['maxImageWidth'],
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/autoload.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 $modx = new DocumentParser;
27 27
 $modx->db->connect();
28 28
 startCMSSession();
29
-if(!isset($_SESSION['mgrValidated'])) {
29
+if (!isset($_SESSION['mgrValidated'])) {
30 30
         die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
31 31
 }
32 32
 define('IN_MANAGER_MODE', "true");
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 $manager_language = $modx->config['manager_language'];
36 36
 // Pass language code from MODX to KCFinder
37
-if(!file_exists("../../../includes/lang/".$manager_language.".inc.php")) {
37
+if (!file_exists("../../../includes/lang/".$manager_language.".inc.php")) {
38 38
     $manager_language = "english"; // if not set, get the english language file.
39 39
 }
40 40
 include_once "../../../includes/lang/".$manager_language.".inc.php";
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 // PHP VERSION CHECK
44 44
 if (substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.')) < 5)
45
-    die("You are using PHP " . PHP_VERSION . " when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution.");
45
+    die("You are using PHP ".PHP_VERSION." when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution.");
46 46
 
47 47
 
48 48
 // SAFE MODE CHECK
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 
53 53
 // MAGIC AUTOLOAD CLASSES FUNCTION
54
-function autoloadda9d06472ccb71b84928677ce2a6ca89($class) {
54
+function autoloadda9d06472ccb71b84928677ce2a6ca89($class){
55 55
     static $classes = null;
56 56
     if ($classes === null) {
57 57
         $classes = array(
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         );
76 76
     }
77 77
     if (isset($classes[$class])) {
78
-        require dirname(__FILE__) . $classes[$class];
78
+        require dirname(__FILE__).$classes[$class];
79 79
     }
80 80
 }
81 81
 spl_autoload_register('autoloadda9d06472ccb71b84928677ce2a6ca89', true);
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 // json_encode() IMPLEMENTATION IF JSON EXTENSION IS MISSING
85 85
 if (!function_exists("json_encode")) {
86 86
 
87
-    function kcfinder_json_string_encode($string) {
88
-        return '"' .
87
+    function kcfinder_json_string_encode($string){
88
+        return '"'.
89 89
             str_replace('/', "\\/",
90 90
             str_replace("\t", "\\t",
91 91
             str_replace("\r", "\\r",
92 92
             str_replace("\n", "\\n",
93 93
             str_replace('"', "\\\"",
94 94
             str_replace("\\", "\\\\",
95
-        $string)))))) . '"';
95
+        $string)))))).'"';
96 96
     }
97 97
 
98
-    function json_encode($data) {
98
+    function json_encode($data){
99 99
 
100 100
         if (is_array($data)) {
101 101
             $ret = array();
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
             // OBJECT
104 104
             if (array_keys($data) !== range(0, count($data) - 1)) {
105 105
                 foreach ($data as $key => $val)
106
-                    $ret[] = kcfinder_json_string_encode($key) . ':' . json_encode($val);
107
-                return "{" . implode(",", $ret) . "}";
106
+                    $ret[] = kcfinder_json_string_encode($key).':'.json_encode($val);
107
+                return "{".implode(",", $ret)."}";
108 108
 
109 109
             // ARRAY
110 110
             } else {
111 111
                 foreach ($data as $val)
112 112
                     $ret[] = json_encode($val);
113
-                return "[" . implode(",", $ret) . "]";
113
+                return "[".implode(",", $ret)."]";
114 114
             }
115 115
 
116 116
         // BOOLEAN OR NULL
Please login to merge, or discard this patch.
install/lang.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
 $install_language = "english";
17 17
 
18 18
 $_langFiles= array (
19
- "en" => "english",
20
- "bg" => "bulgarian",
21
- "cs" => "czech",
22
- "da" => "danish",
23
- "fi" => "finnish-utf8",
24
- "fr" => "francais-utf8",
25
- "de" => "german",
26
- "he" => "hebrew",
27
- "it" => "italian",
28
- "ja" => "japanese-utf8",
29
- "nl" => "nederlands-utf8",
30
- "no" => "norwegian",
31
- "fa" => "persian",
32
- "pl" => "polish-utf8",
33
- "pt" => "portuguese-br-utf8",
19
+    "en" => "english",
20
+    "bg" => "bulgarian",
21
+    "cs" => "czech",
22
+    "da" => "danish",
23
+    "fi" => "finnish-utf8",
24
+    "fr" => "francais-utf8",
25
+    "de" => "german",
26
+    "he" => "hebrew",
27
+    "it" => "italian",
28
+    "ja" => "japanese-utf8",
29
+    "nl" => "nederlands-utf8",
30
+    "no" => "norwegian",
31
+    "fa" => "persian",
32
+    "pl" => "polish-utf8",
33
+    "pt" => "portuguese-br-utf8",
34 34
 // "pt" => "portuguese",
35
- "ru" => "russian-UTF8",
36
- "es" => "spanish-utf8",
37
- "sv" => "svenska"
35
+    "ru" => "russian-UTF8",
36
+    "es" => "spanish-utf8",
37
+    "sv" => "svenska"
38 38
 );
39 39
 $_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
40 40
 if (!empty($_langFiles[$_langISO6391]))  $install_language = $_langFiles[$_langISO6391];
41 41
 
42 42
 
43 43
 if (isset($_POST['language']) && !stristr($_POST['language'],"..")) {
44
-	$install_language = $_POST['language'];
44
+    $install_language = $_POST['language'];
45 45
 } else {
46
-	if (isset($_GET['language']) && !stristr($_GET['language'],".."))
47
-		$install_language = $_GET['language'];
46
+    if (isset($_GET['language']) && !stristr($_GET['language'],".."))
47
+        $install_language = $_GET['language'];
48 48
 }
49 49
 # load language file
50 50
 require_once("lang/english.inc.php"); // As fallback
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 $manager_language = $install_language;
54 54
 
55 55
 if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'],"..")) {
56
-	$manager_language = $_POST['managerlanguage'];
56
+    $manager_language = $_POST['managerlanguage'];
57 57
 } else {
58
-	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],".."))
59
-		$manager_language = $_GET['managerlanguage'];
58
+    if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],".."))
59
+        $manager_language = $_GET['managerlanguage'];
60 60
 }
61 61
 
62 62
 foreach($_lang as $k=>$v)
63 63
 {
64
-	if(strpos($v,'[+MGR_DIR+]')!==false)
65
-		$_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
64
+    if(strpos($v,'[+MGR_DIR+]')!==false)
65
+        $_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
66 66
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
  * Filename:       /install/lang.php
11 11
  */
12 12
 
13
-$_lang = array ();
13
+$_lang = array();
14 14
 
15 15
 #default fallback language file - english
16 16
 $install_language = "english";
17 17
 
18
-$_langFiles= array (
18
+$_langFiles = array(
19 19
  "en" => "english",
20 20
  "bg" => "bulgarian",
21 21
  "cs" => "czech",
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
  "es" => "spanish-utf8",
37 37
  "sv" => "svenska"
38 38
 );
39
-$_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
39
+$_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2);
40 40
 if (!empty($_langFiles[$_langISO6391]))  $install_language = $_langFiles[$_langISO6391];
41 41
 
42 42
 
43
-if (isset($_POST['language']) && !stristr($_POST['language'],"..")) {
43
+if (isset($_POST['language']) && !stristr($_POST['language'], "..")) {
44 44
 	$install_language = $_POST['language'];
45 45
 } else {
46
-	if (isset($_GET['language']) && !stristr($_GET['language'],".."))
46
+	if (isset($_GET['language']) && !stristr($_GET['language'], ".."))
47 47
 		$install_language = $_GET['language'];
48 48
 }
49 49
 # load language file
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 
53 53
 $manager_language = $install_language;
54 54
 
55
-if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'],"..")) {
55
+if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'], "..")) {
56 56
 	$manager_language = $_POST['managerlanguage'];
57 57
 } else {
58
-	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],".."))
58
+	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'], ".."))
59 59
 		$manager_language = $_GET['managerlanguage'];
60 60
 }
61 61
 
62
-foreach($_lang as $k=>$v)
62
+foreach ($_lang as $k=>$v)
63 63
 {
64
-	if(strpos($v,'[+MGR_DIR+]')!==false)
64
+	if (strpos($v, '[+MGR_DIR+]') !== false)
65 65
 		$_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
66 66
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,15 +37,18 @@  discard block
 block discarded – undo
37 37
  "sv" => "svenska"
38 38
 );
39 39
 $_langISO6391 = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
40
-if (!empty($_langFiles[$_langISO6391]))  $install_language = $_langFiles[$_langISO6391];
40
+if (!empty($_langFiles[$_langISO6391])) {
41
+    $install_language = $_langFiles[$_langISO6391];
42
+}
41 43
 
42 44
 
43 45
 if (isset($_POST['language']) && !stristr($_POST['language'],"..")) {
44 46
 	$install_language = $_POST['language'];
45 47
 } else {
46
-	if (isset($_GET['language']) && !stristr($_GET['language'],".."))
47
-		$install_language = $_GET['language'];
48
-}
48
+	if (isset($_GET['language']) && !stristr($_GET['language'],"..")) {
49
+			$install_language = $_GET['language'];
50
+	}
51
+	}
49 52
 # load language file
50 53
 require_once("lang/english.inc.php"); // As fallback
51 54
 require_once("lang/".$install_language.".inc.php");
@@ -55,12 +58,13 @@  discard block
 block discarded – undo
55 58
 if (isset($_POST['managerlanguage']) && !stristr($_POST['managerlanguage'],"..")) {
56 59
 	$manager_language = $_POST['managerlanguage'];
57 60
 } else {
58
-	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],".."))
59
-		$manager_language = $_GET['managerlanguage'];
60
-}
61
+	if (isset($_GET['managerlanguage']) && !stristr($_GET['managerlanguage'],"..")) {
62
+			$manager_language = $_GET['managerlanguage'];
63
+	}
64
+	}
61 65
 
62
-foreach($_lang as $k=>$v)
63
-{
64
-	if(strpos($v,'[+MGR_DIR+]')!==false)
65
-		$_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
66
-}
66
+foreach($_lang as $k=>$v) {
67
+	if(strpos($v,'[+MGR_DIR+]')!==false) {
68
+			$_lang[$k] = str_replace('[+MGR_DIR+]', MGR_DIR, $v);
69
+	}
70
+	}
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 $autoloader = __DIR__.'/vendor/autoload.php';
49 49
 if (file_exists($autoloader) && is_readable($autoloader)) {
50
-	include_once($autoloader);
50
+    include_once($autoloader);
51 51
 }
52 52
 
53 53
 if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 if(is_file($base_path . 'assets/cache/siteManager.php'))
57 57
     include_once($base_path . 'assets/cache/siteManager.php');
58 58
 if(!defined('MGR_DIR') && is_dir("{$base_path}manager"))
59
-	define('MGR_DIR','manager');
59
+    define('MGR_DIR','manager');
60 60
 if(is_file($base_path . 'assets/cache/siteHostnames.php'))
61 61
     include_once($base_path . 'assets/cache/siteHostnames.php');
62 62
 if(!defined('MODX_SITE_HOSTNAMES'))
63
-	define('MODX_SITE_HOSTNAMES','');
63
+    define('MODX_SITE_HOSTNAMES','');
64 64
 
65 65
 // get start time
66 66
 $mstart = memory_get_usage();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 define("IN_PARSER_MODE", true);
86 86
 if (!defined('IN_MANAGER_MODE')) {
87
-	define("IN_MANAGER_MODE", false);
87
+    define("IN_MANAGER_MODE", false);
88 88
 }
89 89
 if (!defined('MODX_API_MODE')) {
90 90
     define('MODX_API_MODE', false);
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 
93 93
 // get the required includes
94 94
 if(!isset($database_user) || $database_user=="") {
95
-	$rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php');
96
-	// Be sure config.inc.php is there and that it contains some important values
97
-	if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
98
-		readfile('install/not_installed.tpl');
99
-		exit;
100
-	}
95
+    $rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php');
96
+    // Be sure config.inc.php is there and that it contains some important values
97
+    if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) {
98
+        readfile('install/not_installed.tpl');
99
+        exit;
100
+    }
101 101
 }
102 102
 
103 103
 // start session
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 
106 106
 // initiate a new document parser
107 107
 if (isset($coreClass) && class_exists($coreClass)) {
108
-	$modx = new $coreClass;
108
+    $modx = new $coreClass;
109 109
 }
110 110
 if (!isset($modx) || !($modx instanceof \DocumentParser)) {
111
-	include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php');
112
-	$modx = new \DocumentParser;
111
+    include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php');
112
+    $modx = new \DocumentParser;
113 113
 }
114 114
 
115 115
 // set some parser options
Please login to merge, or discard this patch.
install/sqlParser.class.php 3 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -4,138 +4,138 @@
 block discarded – undo
4 4
 // SNUFFKIN/ Alex 2004
5 5
 
6 6
 class SqlParser {
7
-	public $host;
8
-	public $dbname;
9
-	public $prefix;
10
-	public $user;
11
-	public $password;
12
-	public $mysqlErrors;
13
-	public $conn;
14
-	public $installFailed;
15
-	public $sitename;
16
-	public $adminname;
17
-	public $adminemail;
18
-	public $adminpass;
19
-	public $managerlanguage;
20
-	public $mode;
21
-	public $fileManagerPath;
22
-	public $imgPath;
23
-	public $imgUrl;
24
-	public $dbMODx;
25
-	public $dbVersion;
7
+    public $host;
8
+    public $dbname;
9
+    public $prefix;
10
+    public $user;
11
+    public $password;
12
+    public $mysqlErrors;
13
+    public $conn;
14
+    public $installFailed;
15
+    public $sitename;
16
+    public $adminname;
17
+    public $adminemail;
18
+    public $adminpass;
19
+    public $managerlanguage;
20
+    public $mode;
21
+    public $fileManagerPath;
22
+    public $imgPath;
23
+    public $imgUrl;
24
+    public $dbMODx;
25
+    public $dbVersion;
26 26
     public $connection_charset;
27 27
     public $connection_method;
28 28
     public $ignoreDuplicateErrors;
29 29
 
30
-	public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') {
31
-		$this->host = $host;
32
-		$this->dbname = $db;
33
-		$this->prefix = $prefix;
34
-		$this->user = $user;
35
-		$this->password = $password;
36
-		$this->adminpass = $adminpass;
37
-		$this->adminname = $adminname;
38
-		$this->adminemail = $adminemail;
39
-		$this->connection_charset = $connection_charset;
40
-		$this->connection_method = $connection_method;
41
-		$this->ignoreDuplicateErrors = false;
42
-		$this->managerlanguage = $managerlanguage;
30
+    public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') {
31
+        $this->host = $host;
32
+        $this->dbname = $db;
33
+        $this->prefix = $prefix;
34
+        $this->user = $user;
35
+        $this->password = $password;
36
+        $this->adminpass = $adminpass;
37
+        $this->adminname = $adminname;
38
+        $this->adminemail = $adminemail;
39
+        $this->connection_charset = $connection_charset;
40
+        $this->connection_method = $connection_method;
41
+        $this->ignoreDuplicateErrors = false;
42
+        $this->managerlanguage = $managerlanguage;
43 43
         $this->autoTemplateLogic = $auto_template_logic;
44
-	}
44
+    }
45 45
 
46
-	public function connect() {
47
-		$this->conn = mysqli_connect($this->host, $this->user, $this->password);
48
-		mysqli_select_db($this->conn, $this->dbname);
49
-		if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset);
46
+    public function connect() {
47
+        $this->conn = mysqli_connect($this->host, $this->user, $this->password);
48
+        mysqli_select_db($this->conn, $this->dbname);
49
+        if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset);
50 50
 
51
-		$this->dbVersion = 3.23; // assume version 3.23
52
-		if(function_exists("mysqli_get_server_info")) {
53
-			$ver = mysqli_get_server_info($this->conn);
54
-			$this->dbMODx 	 = version_compare($ver,"4.0.2");
55
-			$this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2]
56
-		}
51
+        $this->dbVersion = 3.23; // assume version 3.23
52
+        if(function_exists("mysqli_get_server_info")) {
53
+            $ver = mysqli_get_server_info($this->conn);
54
+            $this->dbMODx 	 = version_compare($ver,"4.0.2");
55
+            $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2]
56
+        }
57 57
 
58 58
         mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}");
59
-	}
59
+    }
60 60
 
61 61
     public function process($filename) {
62
-	    global $custom_placeholders;
63
-
64
-		// check to make sure file exists
65
-		if (!file_exists($filename)) {
66
-			$this->mysqlErrors[] = array("error" => "File '$filename' not found");
67
-			$this->installFailed = true ;
68
-			return false;
69
-		}
70
-
71
-		$fh = fopen($filename, 'r');
72
-		$idata = '';
73
-
74
-		while (!feof($fh)) {
75
-			$idata .= fread($fh, 1024);
76
-		}
77
-
78
-		fclose($fh);
79
-		$idata = str_replace("\r", '', $idata);
80
-
81
-		// check if in upgrade mode
82
-		if ($this->mode=="upd") {
83
-			// remove non-upgradeable parts
84
-			$s = strpos($idata,"non-upgrade-able[[");
85
-			$e = strpos($idata,"]]non-upgrade-able")+17;
86
-			if($s && $e) $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata);
87
-		}
88
-
89
-		// replace {} tags
90
-		$idata = str_replace('{PREFIX}', $this->prefix, $idata);
91
-		$idata = str_replace('{ADMIN}', $this->adminname, $idata);
92
-		$idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata);
93
-		$idata = str_replace('{ADMINPASS}', $this->adminpass, $idata);
94
-		$idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata);
95
-		$idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata);
96
-		$idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata);
97
-		$idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata);
98
-		$idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata);
99
-		/*$idata = str_replace('{VERSION}', $modx_version, $idata);*/
100
-
101
-		// Replace custom placeholders
102
-		foreach($custom_placeholders as $key=>$val) {
103
-			if (strpos($idata, '{'.$key.'}') !== false) {
104
-				$idata = str_replace('{'.$key.'}', $val, $idata);
105
-			}
106
-		}
107
-
108
-		$sql_array = explode("\n\n", $idata);
109
-
110
-		$num = 0;
111
-		foreach($sql_array as $sql_entry) {
112
-			$sql_do = trim($sql_entry, "\r\n; ");
113
-
114
-			if (preg_match('/^\#/', $sql_do)) continue;
115
-
116
-			// strip out comments and \n for mysql 3.x
117
-			if ($this->dbVersion <4.0) {
118
-				$sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do);
119
-				$sql_do = str_replace('\r', "", $sql_do);
120
-				$sql_do = str_replace('\n', "", $sql_do);
121
-			}
122
-
123
-
124
-			$num = $num + 1;
125
-			if ($sql_do) mysqli_query($this->conn, $sql_do);
126
-			if(mysqli_error($this->conn)) {
127
-				// Ignore duplicate and drop errors - Raymond
128
-				if ($this->ignoreDuplicateErrors){
129
-					if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue;
130
-				}
131
-				// End Ignore duplicate
132
-				$this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do);
133
-				$this->installFailed = true;
134
-			}
135
-		}
136
-	}
62
+        global $custom_placeholders;
63
+
64
+        // check to make sure file exists
65
+        if (!file_exists($filename)) {
66
+            $this->mysqlErrors[] = array("error" => "File '$filename' not found");
67
+            $this->installFailed = true ;
68
+            return false;
69
+        }
70
+
71
+        $fh = fopen($filename, 'r');
72
+        $idata = '';
73
+
74
+        while (!feof($fh)) {
75
+            $idata .= fread($fh, 1024);
76
+        }
77
+
78
+        fclose($fh);
79
+        $idata = str_replace("\r", '', $idata);
80
+
81
+        // check if in upgrade mode
82
+        if ($this->mode=="upd") {
83
+            // remove non-upgradeable parts
84
+            $s = strpos($idata,"non-upgrade-able[[");
85
+            $e = strpos($idata,"]]non-upgrade-able")+17;
86
+            if($s && $e) $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata);
87
+        }
88
+
89
+        // replace {} tags
90
+        $idata = str_replace('{PREFIX}', $this->prefix, $idata);
91
+        $idata = str_replace('{ADMIN}', $this->adminname, $idata);
92
+        $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata);
93
+        $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata);
94
+        $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata);
95
+        $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata);
96
+        $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata);
97
+        $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata);
98
+        $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata);
99
+        /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/
100
+
101
+        // Replace custom placeholders
102
+        foreach($custom_placeholders as $key=>$val) {
103
+            if (strpos($idata, '{'.$key.'}') !== false) {
104
+                $idata = str_replace('{'.$key.'}', $val, $idata);
105
+            }
106
+        }
107
+
108
+        $sql_array = explode("\n\n", $idata);
109
+
110
+        $num = 0;
111
+        foreach($sql_array as $sql_entry) {
112
+            $sql_do = trim($sql_entry, "\r\n; ");
113
+
114
+            if (preg_match('/^\#/', $sql_do)) continue;
115
+
116
+            // strip out comments and \n for mysql 3.x
117
+            if ($this->dbVersion <4.0) {
118
+                $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do);
119
+                $sql_do = str_replace('\r', "", $sql_do);
120
+                $sql_do = str_replace('\n', "", $sql_do);
121
+            }
122
+
123
+
124
+            $num = $num + 1;
125
+            if ($sql_do) mysqli_query($this->conn, $sql_do);
126
+            if(mysqli_error($this->conn)) {
127
+                // Ignore duplicate and drop errors - Raymond
128
+                if ($this->ignoreDuplicateErrors){
129
+                    if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue;
130
+                }
131
+                // End Ignore duplicate
132
+                $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do);
133
+                $this->installFailed = true;
134
+            }
135
+        }
136
+    }
137 137
 
138 138
     public function close() {
139
-		mysqli_close($this->conn);
140
-	}
139
+        mysqli_close($this->conn);
140
+    }
141 141
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 // MySQL Dump Parser
4 4
 // SNUFFKIN/ Alex 2004
5 5
 
6
-class SqlParser {
6
+class SqlParser{
7 7
 	public $host;
8 8
 	public $dbname;
9 9
 	public $prefix;
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     public $connection_method;
28 28
     public $ignoreDuplicateErrors;
29 29
 
30
-	public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') {
30
+	public function __construct($host, $user, $password, $db, $prefix = 'modx_', $adminname, $adminemail, $adminpass, $connection_charset = 'utf8', $managerlanguage = 'english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent'){
31 31
 		$this->host = $host;
32 32
 		$this->dbname = $db;
33 33
 		$this->prefix = $prefix;
@@ -43,28 +43,28 @@  discard block
 block discarded – undo
43 43
         $this->autoTemplateLogic = $auto_template_logic;
44 44
 	}
45 45
 
46
-	public function connect() {
46
+	public function connect(){
47 47
 		$this->conn = mysqli_connect($this->host, $this->user, $this->password);
48 48
 		mysqli_select_db($this->conn, $this->dbname);
49 49
 		if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset);
50 50
 
51 51
 		$this->dbVersion = 3.23; // assume version 3.23
52
-		if(function_exists("mysqli_get_server_info")) {
52
+		if (function_exists("mysqli_get_server_info")) {
53 53
 			$ver = mysqli_get_server_info($this->conn);
54
-			$this->dbMODx 	 = version_compare($ver,"4.0.2");
54
+			$this->dbMODx 	 = version_compare($ver, "4.0.2");
55 55
 			$this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2]
56 56
 		}
57 57
 
58
-        mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}");
58
+        mysqli_query($this->conn, "{$this->connection_method} {$this->connection_charset}");
59 59
 	}
60 60
 
61
-    public function process($filename) {
61
+    public function process($filename){
62 62
 	    global $custom_placeholders;
63 63
 
64 64
 		// check to make sure file exists
65 65
 		if (!file_exists($filename)) {
66 66
 			$this->mysqlErrors[] = array("error" => "File '$filename' not found");
67
-			$this->installFailed = true ;
67
+			$this->installFailed = true;
68 68
 			return false;
69 69
 		}
70 70
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 		$idata = str_replace("\r", '', $idata);
80 80
 
81 81
 		// check if in upgrade mode
82
-		if ($this->mode=="upd") {
82
+		if ($this->mode == "upd") {
83 83
 			// remove non-upgradeable parts
84
-			$s = strpos($idata,"non-upgrade-able[[");
85
-			$e = strpos($idata,"]]non-upgrade-able")+17;
86
-			if($s && $e) $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata);
84
+			$s = strpos($idata, "non-upgrade-able[[");
85
+			$e = strpos($idata, "]]non-upgrade-able") + 17;
86
+			if ($s && $e) $idata = str_replace(substr($idata, $s, $e - $s), " Removed non upgradeable items", $idata);
87 87
 		}
88 88
 
89 89
 		// replace {} tags
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		/*$idata = str_replace('{VERSION}', $modx_version, $idata);*/
100 100
 
101 101
 		// Replace custom placeholders
102
-		foreach($custom_placeholders as $key=>$val) {
102
+		foreach ($custom_placeholders as $key=>$val) {
103 103
 			if (strpos($idata, '{'.$key.'}') !== false) {
104 104
 				$idata = str_replace('{'.$key.'}', $val, $idata);
105 105
 			}
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 		$sql_array = explode("\n\n", $idata);
109 109
 
110 110
 		$num = 0;
111
-		foreach($sql_array as $sql_entry) {
111
+		foreach ($sql_array as $sql_entry) {
112 112
 			$sql_do = trim($sql_entry, "\r\n; ");
113 113
 
114 114
 			if (preg_match('/^\#/', $sql_do)) continue;
115 115
 
116 116
 			// strip out comments and \n for mysql 3.x
117
-			if ($this->dbVersion <4.0) {
118
-				$sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do);
117
+			if ($this->dbVersion < 4.0) {
118
+				$sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~", "", $sql_do);
119 119
 				$sql_do = str_replace('\r', "", $sql_do);
120 120
 				$sql_do = str_replace('\n', "", $sql_do);
121 121
 			}
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 
124 124
 			$num = $num + 1;
125 125
 			if ($sql_do) mysqli_query($this->conn, $sql_do);
126
-			if(mysqli_error($this->conn)) {
126
+			if (mysqli_error($this->conn)) {
127 127
 				// Ignore duplicate and drop errors - Raymond
128
-				if ($this->ignoreDuplicateErrors){
129
-					if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue;
128
+				if ($this->ignoreDuplicateErrors) {
129
+					if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 || mysqli_errno($this->conn) == 1091) continue;
130 130
 				}
131 131
 				// End Ignore duplicate
132 132
 				$this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		}
136 136
 	}
137 137
 
138
-    public function close() {
138
+    public function close(){
139 139
 		mysqli_close($this->conn);
140 140
 	}
141 141
 }
Please login to merge, or discard this patch.
Braces   +26 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,7 +3,8 @@  discard block
 block discarded – undo
3 3
 // MySQL Dump Parser
4 4
 // SNUFFKIN/ Alex 2004
5 5
 
6
-class SqlParser {
6
+class SqlParser
7
+{
7 8
 	public $host;
8 9
 	public $dbname;
9 10
 	public $prefix;
@@ -27,7 +28,8 @@  discard block
 block discarded – undo
27 28
     public $connection_method;
28 29
     public $ignoreDuplicateErrors;
29 30
 
30
-	public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') {
31
+	public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent')
32
+	{
31 33
 		$this->host = $host;
32 34
 		$this->dbname = $db;
33 35
 		$this->prefix = $prefix;
@@ -43,10 +45,13 @@  discard block
 block discarded – undo
43 45
         $this->autoTemplateLogic = $auto_template_logic;
44 46
 	}
45 47
 
46
-	public function connect() {
48
+	public function connect()
49
+	{
47 50
 		$this->conn = mysqli_connect($this->host, $this->user, $this->password);
48 51
 		mysqli_select_db($this->conn, $this->dbname);
49
-		if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset);
52
+		if (function_exists('mysqli_set_charset')) {
53
+		    mysqli_set_charset($this->conn, $this->connection_charset);
54
+		}
50 55
 
51 56
 		$this->dbVersion = 3.23; // assume version 3.23
52 57
 		if(function_exists("mysqli_get_server_info")) {
@@ -58,7 +63,8 @@  discard block
 block discarded – undo
58 63
         mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}");
59 64
 	}
60 65
 
61
-    public function process($filename) {
66
+    public function process($filename)
67
+    {
62 68
 	    global $custom_placeholders;
63 69
 
64 70
 		// check to make sure file exists
@@ -83,7 +89,9 @@  discard block
 block discarded – undo
83 89
 			// remove non-upgradeable parts
84 90
 			$s = strpos($idata,"non-upgrade-able[[");
85 91
 			$e = strpos($idata,"]]non-upgrade-able")+17;
86
-			if($s && $e) $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata);
92
+			if($s && $e) {
93
+			    $idata = str_replace(substr($idata,$s,$e-$s)," Removed non upgradeable items",$idata);
94
+			}
87 95
 		}
88 96
 
89 97
 		// replace {} tags
@@ -111,7 +119,9 @@  discard block
 block discarded – undo
111 119
 		foreach($sql_array as $sql_entry) {
112 120
 			$sql_do = trim($sql_entry, "\r\n; ");
113 121
 
114
-			if (preg_match('/^\#/', $sql_do)) continue;
122
+			if (preg_match('/^\#/', $sql_do)) {
123
+			    continue;
124
+			}
115 125
 
116 126
 			// strip out comments and \n for mysql 3.x
117 127
 			if ($this->dbVersion <4.0) {
@@ -122,11 +132,15 @@  discard block
 block discarded – undo
122 132
 
123 133
 
124 134
 			$num = $num + 1;
125
-			if ($sql_do) mysqli_query($this->conn, $sql_do);
135
+			if ($sql_do) {
136
+			    mysqli_query($this->conn, $sql_do);
137
+			}
126 138
 			if(mysqli_error($this->conn)) {
127 139
 				// Ignore duplicate and drop errors - Raymond
128
-				if ($this->ignoreDuplicateErrors){
129
-					if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue;
140
+				if ($this->ignoreDuplicateErrors) {
141
+					if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) {
142
+					    continue;
143
+					}
130 144
 				}
131 145
 				// End Ignore duplicate
132 146
 				$this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do);
@@ -135,7 +149,8 @@  discard block
 block discarded – undo
135 149
 		}
136 150
 	}
137 151
 
138
-    public function close() {
152
+    public function close()
153
+    {
139 154
 		mysqli_close($this->conn);
140 155
 	}
141 156
 }
Please login to merge, or discard this patch.