Completed
Push — develop ( 0132ab...e45b08 )
by Dmytro
13:40 queued 05:11
created
manager/media/script/air-datepicker/datepicker.inc.php 1 patch
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,13 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class DATEPICKER {
2
+class DATEPICKER
3
+{
3 4
     /**
4 5
      * @return string
5 6
      */
6
-    public function getDP() {
7
+    public function getDP()
8
+    {
7 9
         $modx = evolutionCMS();
8 10
 
9 11
         $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl');
10
-        if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode();
12
+        if(!isset($modx->config['lang_code'])) {
13
+            $modx->config['lang_code'] = $this->getLangCode();
14
+        }
11 15
 		$modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy';
12 16
         return $modx->mergeSettingsContent($load_script);
13 17
     }
@@ -15,13 +19,18 @@  discard block
 block discarded – undo
15 19
     /**
16 20
      * @return string
17 21
      */
18
-    public function getLangCode() {
22
+    public function getLangCode()
23
+    {
19 24
         $modx = evolutionCMS(); global $modx_lang_attribute;
20 25
 
21
-        if(!$modx_lang_attribute) return 'en';
26
+        if(!$modx_lang_attribute) {
27
+            return 'en';
28
+        }
22 29
 
23 30
         $lc = $modx_lang_attribute;
24
-        if($lc === 'uk') return 'ru';
31
+        if($lc === 'uk') {
32
+            return 'ru';
33
+        }
25 34
         $dp_path = str_replace('\\','/',dirname(__FILE__));
26 35
 
27 36
         return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en';
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/uploader.php 1 patch
Braces   +238 added lines, -149 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 uploader {
15
+class uploader
16
+{
16 17
 
17 18
 /** Release version */
18 19
     const VERSION = "2.54";
@@ -104,17 +105,21 @@  discard block
 block discarded – undo
104 105
 /** Magic method which allows read-only access to protected or private class properties
105 106
   * @param string $property
106 107
   * @return mixed */
107
-    public function __get($property) {
108
+    public function __get($property)
109
+    {
108 110
         return property_exists($this, $property) ? $this->$property : null;
109 111
     }
110 112
 
111
-    public function __construct($modx) {
113
+    public function __construct($modx)
114
+    {
112 115
 
113 116
         //MODX
114 117
         try {
115 118
             if ($modx instanceof DocumentParser) {
116 119
                 $this->modx = $modx;
117
-            } else throw new Exception('MODX should be instance of DocumentParser');
120
+            } else {
121
+                throw new Exception('MODX should be instance of DocumentParser');
122
+            }
118 123
         } catch (Exception $e) {
119 124
             die($e->getMessage());
120 125
         }
@@ -129,26 +134,34 @@  discard block
 block discarded – undo
129 134
         // SET CMS INTEGRATION ATTRIBUTE
130 135
         if (isset($this->get['cms']) &&
131 136
             in_array($this->get['cms'], array("drupal"))
132
-        )
133
-            $this->cms = $this->get['cms'];
137
+        ) {
138
+                    $this->cms = $this->get['cms'];
139
+        }
134 140
 
135 141
 		// LINKING UPLOADED FILE
136
-        if (count($_FILES))
137
-            $this->file = &$_FILES[key($_FILES)];
142
+        if (count($_FILES)) {
143
+                    $this->file = &$_FILES[key($_FILES)];
144
+        }
138 145
 
139 146
         // LOAD DEFAULT CONFIGURATION
140 147
         require "config.php";
141 148
 
142 149
         // SETTING UP SESSION
143
-        if (isset($_CONFIG['_sessionLifetime']))
144
-            ini_set('session.gc_maxlifetime', $_CONFIG['_sessionLifetime'] * 60);
145
-        if (isset($_CONFIG['_sessionDir']))
146
-            ini_set('session.save_path', $_CONFIG['_sessionDir']);
147
-        if (isset($_CONFIG['_sessionDomain']))
148
-            ini_set('session.cookie_domain', $_CONFIG['_sessionDomain']);
150
+        if (isset($_CONFIG['_sessionLifetime'])) {
151
+                    ini_set('session.gc_maxlifetime', $_CONFIG['_sessionLifetime'] * 60);
152
+        }
153
+        if (isset($_CONFIG['_sessionDir'])) {
154
+                    ini_set('session.save_path', $_CONFIG['_sessionDir']);
155
+        }
156
+        if (isset($_CONFIG['_sessionDomain'])) {
157
+                    ini_set('session.cookie_domain', $_CONFIG['_sessionDomain']);
158
+        }
149 159
         switch ($this->cms) {
150 160
             case "drupal": break;
151
-            default: if (!session_id()) session_start(); break;
161
+            default: if (!session_id()) {
162
+                session_start();
163
+            }
164
+            break;
152 165
         }
153 166
 
154 167
         // RELOAD DEFAULT CONFIGURATION
@@ -159,31 +172,37 @@  discard block
 block discarded – undo
159 172
         if (isset($_CONFIG['_sessionVar']) &&
160 173
             is_array($_CONFIG['_sessionVar'])
161 174
         ) {
162
-            foreach ($_CONFIG['_sessionVar'] as $key => $val)
163
-                if ((substr($key, 0, 1) != "_") && isset($_CONFIG[$key]))
175
+            foreach ($_CONFIG['_sessionVar'] as $key => $val) {
176
+                            if ((substr($key, 0, 1) != "_") && isset($_CONFIG[$key]))
164 177
                     $this->config[$key] = $val;
165
-            if (!isset($this->config['_sessionVar']['self']))
166
-                $this->config['_sessionVar']['self'] = array();
178
+            }
179
+            if (!isset($this->config['_sessionVar']['self'])) {
180
+                            $this->config['_sessionVar']['self'] = array();
181
+            }
167 182
             $this->session = &$this->config['_sessionVar']['self'];
168
-        } else
169
-            $this->session = &$_SESSION;
183
+        } else {
184
+                    $this->session = &$_SESSION;
185
+        }
170 186
 
171 187
         // IMAGE DRIVER INIT
172 188
         if (isset($this->config['imageDriversPriority'])) {
173 189
             $this->config['imageDriversPriority'] =
174 190
                 text::clearWhitespaces($this->config['imageDriversPriority']);
175 191
             $driver = image::getDriver(explode(' ', $this->config['imageDriversPriority']));
176
-            if ($driver !== false)
177
-                $this->imageDriver = $driver;
192
+            if ($driver !== false) {
193
+                            $this->imageDriver = $driver;
194
+            }
178 195
         }
179 196
         if ((!isset($driver) || ($driver === false)) &&
180 197
             (image::getDriver(array($this->imageDriver)) === false)
181
-        )
182
-            die("Cannot find any of the supported PHP image extensions!");
198
+        ) {
199
+                    die("Cannot find any of the supported PHP image extensions!");
200
+        }
183 201
 
184 202
         // WATERMARK INIT
185
-        if (isset($this->config['watermark']) && is_string($this->config['watermark']))
186
-            $this->config['watermark'] = array('file' => $this->config['watermark']);
203
+        if (isset($this->config['watermark']) && is_string($this->config['watermark'])) {
204
+                    $this->config['watermark'] = array('file' => $this->config['watermark']);
205
+        }
187 206
 
188 207
         // GET TYPE DIRECTORY
189 208
         $this->types = &$this->config['types'];
@@ -197,9 +216,10 @@  discard block
 block discarded – undo
197 216
 
198 217
         // LOAD TYPE DIRECTORY SPECIFIC CONFIGURATION IF EXISTS
199 218
         if (is_array($this->types[$this->type])) {
200
-            foreach ($this->types[$this->type] as $key => $val)
201
-                if (in_array($key, $this->typeSettings))
219
+            foreach ($this->types[$this->type] as $key => $val) {
220
+                            if (in_array($key, $this->typeSettings))
202 221
                     $this->config[$key] = $val;
222
+            }
203 223
             $this->types[$this->type] = isset($this->types[$this->type]['type'])
204 224
                 ? $this->types[$this->type]['type'] : "";
205 225
         }
@@ -209,12 +229,14 @@  discard block
 block discarded – undo
209 229
         $ip = '/^' . implode('\.', array($ip, $ip, $ip, $ip)) . '$/';
210 230
         if (preg_match($ip, $_SERVER['HTTP_HOST']) ||
211 231
             preg_match('/^[^\.]+$/', $_SERVER['HTTP_HOST'])
212
-        )
213
-            $this->config['cookieDomain'] = "";
214
-        elseif (!strlen($this->config['cookieDomain']))
215
-            $this->config['cookieDomain'] = $_SERVER['HTTP_HOST'];
216
-        if (!strlen($this->config['cookiePath']))
217
-            $this->config['cookiePath'] = "/";
232
+        ) {
233
+                    $this->config['cookieDomain'] = "";
234
+        } elseif (!strlen($this->config['cookieDomain'])) {
235
+                    $this->config['cookieDomain'] = $_SERVER['HTTP_HOST'];
236
+        }
237
+        if (!strlen($this->config['cookiePath'])) {
238
+                    $this->config['cookiePath'] = "/";
239
+        }
218 240
 
219 241
         // UPLOAD FOLDER INIT
220 242
 
@@ -250,26 +272,30 @@  discard block
 block discarded – undo
250 272
             $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
251 273
             $this->typeURL = "{$this->config['uploadURL']}/{$this->type}";
252 274
         }
253
-        if (!is_dir($this->config['uploadDir']))
254
-            @mkdir($this->config['uploadDir'], $this->config['dirPerms']);
275
+        if (!is_dir($this->config['uploadDir'])) {
276
+                    @mkdir($this->config['uploadDir'], $this->config['dirPerms']);
277
+        }
255 278
 
256 279
         // HOST APPLICATIONS INIT
257
-        if (isset($this->get['CKEditorFuncNum']))
258
-            $this->opener['CKEditor']['funcNum'] = $this->get['CKEditorFuncNum'];
280
+        if (isset($this->get['CKEditorFuncNum'])) {
281
+                    $this->opener['CKEditor']['funcNum'] = $this->get['CKEditorFuncNum'];
282
+        }
259 283
         if (isset($this->get['opener']) &&
260 284
             (strtolower($this->get['opener']) == "tinymce") &&
261 285
             isset($this->config['_tinyMCEPath']) &&
262 286
             strlen($this->config['_tinyMCEPath'])
263
-        )
264
-            $this->opener['TinyMCE'] = true;
287
+        ) {
288
+                    $this->opener['TinyMCE'] = true;
289
+        }
265 290
 
266 291
         // LOCALIZATION
267
-        foreach ($this->langInputNames as $key)
268
-            if (isset($this->get[$key]) &&
292
+        foreach ($this->langInputNames as $key) {
293
+                    if (isset($this->get[$key]) &&
269 294
                 preg_match('/^[a-z][a-z\._\-]*$/i', $this->get[$key]) &&
270 295
                 file_exists("lang/" . strtolower($this->get[$key]) . ".php")
271 296
             ) {
272 297
                 $this->lang = $this->get[$key];
298
+        }
273 299
                 break;
274 300
             }
275 301
         $this->localize($this->lang);
@@ -280,31 +306,39 @@  discard block
 block discarded – undo
280 306
         ) {
281 307
             $htaccess = "{$this->config['uploadDir']}/.htaccess";
282 308
             if (!file_exists($htaccess)) {
283
-                if (!@file_put_contents($htaccess, $this->get_htaccess()))
284
-                    $this->backMsg("Cannot write to upload folder. {$this->config['uploadDir']}");
309
+                if (!@file_put_contents($htaccess, $this->get_htaccess())) {
310
+                                    $this->backMsg("Cannot write to upload folder. {$this->config['uploadDir']}");
311
+                }
285 312
             } else {
286
-                if (false === ($data = @file_get_contents($htaccess)))
287
-                    $this->backMsg("Cannot read .htaccess");
288
-                if (($data != $this->get_htaccess()) && !@file_put_contents($htaccess, $data))
289
-                    $this->backMsg("Incorrect .htaccess file. Cannot rewrite it!");
313
+                if (false === ($data = @file_get_contents($htaccess))) {
314
+                                    $this->backMsg("Cannot read .htaccess");
315
+                }
316
+                if (($data != $this->get_htaccess()) && !@file_put_contents($htaccess, $data)) {
317
+                                    $this->backMsg("Incorrect .htaccess file. Cannot rewrite it!");
318
+                }
290 319
             }
291 320
         }
292 321
 
293 322
         // CHECK & CREATE UPLOAD FOLDER
294 323
         if (!is_dir($this->typeDir)) {
295
-            if (!mkdir($this->typeDir, $this->config['dirPerms']))
296
-                $this->backMsg("Cannot create {dir} folder.", array('dir' => $this->type));
297
-        } elseif (!is_readable($this->typeDir))
298
-            $this->backMsg("Cannot read upload folder.");
324
+            if (!mkdir($this->typeDir, $this->config['dirPerms'])) {
325
+                            $this->backMsg("Cannot create {dir} folder.", array('dir' => $this->type));
326
+            }
327
+        } elseif (!is_readable($this->typeDir)) {
328
+                    $this->backMsg("Cannot read upload folder.");
329
+        }
299 330
     }
300 331
 
301
-    public function upload() {
332
+    public function upload()
333
+    {
302 334
         $config = &$this->config;
303 335
         $file = &$this->file;
304 336
         $url = $message = "";
305 337
 
306 338
         if ($config['disabled'] || !$config['access']['files']['upload']) {
307
-            if (isset($file['tmp_name'])) @unlink($file['tmp_name']);
339
+            if (isset($file['tmp_name'])) {
340
+                @unlink($file['tmp_name']);
341
+            }
308 342
             $message = $this->label("You don't have permissions to upload files.");
309 343
 
310 344
         } elseif (true === ($message = $this->checkUploadedFile())) {
@@ -315,9 +349,9 @@  discard block
 block discarded – undo
315 349
                 (false !== ($gdir = $this->checkInputDir($this->get['dir'])))
316 350
             ) {
317 351
                 $udir = path::normalize("$dir$gdir");
318
-                if (substr($udir, 0, strlen($dir)) !== $dir)
319
-                    $message = $this->label("Unknown error.");
320
-                else {
352
+                if (substr($udir, 0, strlen($dir)) !== $dir) {
353
+                                    $message = $this->label("Unknown error.");
354
+                } else {
321 355
                     $l = strlen($dir);
322 356
                     $dir = "$udir/";
323 357
                     $udir = substr($udir, $l);
@@ -325,8 +359,9 @@  discard block
 block discarded – undo
325 359
             }
326 360
 
327 361
             if (!strlen($message)) {
328
-                if (!is_dir(path::normalize($dir)))
329
-                    @mkdir(path::normalize($dir), $this->config['dirPerms'], true);
362
+                if (!is_dir(path::normalize($dir))) {
363
+                                    @mkdir(path::normalize($dir), $this->config['dirPerms'], true);
364
+                }
330 365
 
331 366
                 $filename = $this->normalizeFilename($file['name']);
332 367
                 $target = file::getInexistantFilename($dir . $filename);
@@ -334,21 +369,25 @@  discard block
 block discarded – undo
334 369
                 if (!@move_uploaded_file($file['tmp_name'], $target) &&
335 370
                     !@rename($file['tmp_name'], $target) &&
336 371
                     !@copy($file['tmp_name'], $target)
337
-                )
338
-                    $message = $this->label("Cannot move uploaded file to target folder.");
339
-                else {
340
-                    if (function_exists('chmod'))
341
-                        @chmod($target, $this->config['filePerms']);
372
+                ) {
373
+                                    $message = $this->label("Cannot move uploaded file to target folder.");
374
+                } else {
375
+                    if (function_exists('chmod')) {
376
+                                            @chmod($target, $this->config['filePerms']);
377
+                    }
342 378
                     $this->makeThumb($target);
343 379
                     $url = $this->typeURL;
344
-                    if (isset($udir)) $url .= "/$udir";
380
+                    if (isset($udir)) {
381
+                        $url .= "/$udir";
382
+                    }
345 383
                     $url .= "/" . basename($target);
346 384
                     if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)$/', $url, $patt)) {
347 385
                         list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
348 386
                         $base = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/";
349 387
                         $url = $base . path::urlPathEncode($path);
350
-                    } else
351
-                        $url = path::urlPathEncode($url);
388
+                    } else {
389
+                                            $url = path::urlPathEncode($url);
390
+                    }
352 391
                 }
353 392
             }
354 393
         }
@@ -356,16 +395,19 @@  discard block
 block discarded – undo
356 395
         if (strlen($message) &&
357 396
             isset($this->file['tmp_name']) &&
358 397
             file_exists($this->file['tmp_name'])
359
-        )
360
-            @unlink($this->file['tmp_name']);
398
+        ) {
399
+                    @unlink($this->file['tmp_name']);
400
+        }
361 401
 
362
-        if (strlen($message) && method_exists($this, 'errorMsg'))
363
-            $this->errorMsg($message);
402
+        if (strlen($message) && method_exists($this, 'errorMsg')) {
403
+                    $this->errorMsg($message);
404
+        }
364 405
         $this->callBack($url, $message);
365 406
     }
366 407
 
367 408
 
368
-	protected function getTransaliasSettings() {
409
+	protected function getTransaliasSettings()
410
+	{
369 411
 		$modx = evolutionCMS();
370 412
 
371 413
 		// Cleaning uploaded filename?
@@ -385,7 +427,8 @@  discard block
 block discarded – undo
385 427
 	}
386 428
 
387 429
 
388
-	protected function normalizeFilename($filename) {
430
+	protected function normalizeFilename($filename)
431
+	{
389 432
 		if ($this->getTransaliasSettings()) {
390 433
         		$format = strrchr($filename, ".");
391 434
         		$filename = str_replace($format, "", $filename);
@@ -394,16 +437,19 @@  discard block
 block discarded – undo
394 437
         	return $filename;
395 438
 	}
396 439
 
397
-	protected function normalizeDirname($dirname) {
440
+	protected function normalizeDirname($dirname)
441
+	{
398 442
         return $this->modx->stripAlias($dirname);
399 443
     }
400 444
 
401
-    protected function checkUploadedFile(array $aFile=null) {
445
+    protected function checkUploadedFile(array $aFile=null)
446
+    {
402 447
         $config = &$this->config;
403 448
         $file = ($aFile === null) ? $this->file : $aFile;
404 449
 
405
-        if (!is_array($file) || !isset($file['name']))
406
-            return $this->label("Unknown error");
450
+        if (!is_array($file) || !isset($file['name'])) {
451
+                    return $this->label("Unknown error");
452
+        }
407 453
 
408 454
         if (is_array($file['name'])) {
409 455
             foreach ($file['name'] as $i => $name) {
@@ -412,8 +458,9 @@  discard block
 block discarded – undo
412 458
                     'tmp_name' => $file['tmp_name'][$i],
413 459
                     'error' => $file['error'][$i]
414 460
                 ));
415
-                if ($return !== true)
416
-                    return "$name: $return";
461
+                if ($return !== true) {
462
+                                    return "$name: $return";
463
+                }
417 464
             }
418 465
             return true;
419 466
         }
@@ -422,8 +469,8 @@  discard block
 block discarded – undo
422 469
         $typePatt = strtolower(text::clearWhitespaces($this->types[$this->type]));
423 470
 
424 471
         // CHECK FOR UPLOAD ERRORS
425
-        if ($file['error'])
426
-            return
472
+        if ($file['error']) {
473
+                    return
427 474
                 ($file['error'] == UPLOAD_ERR_INI_SIZE) ?
428 475
                     $this->label("The uploaded file exceeds {size} bytes.",
429 476
                         array('size' => ini_get('upload_max_filesize'))) : (
@@ -440,14 +487,17 @@  discard block
 block discarded – undo
440 487
                     $this->label("Failed to write file.") :
441 488
                     $this->label("Unknown error.")
442 489
             )))));
490
+        }
443 491
 
444 492
         // HIDDEN FILENAMES CHECK
445
-        elseif (substr($file['name'], 0, 1) == ".")
446
-            return $this->label("File name shouldn't begins with '.'");
493
+        elseif (substr($file['name'], 0, 1) == ".") {
494
+                    return $this->label("File name shouldn't begins with '.'");
495
+        }
447 496
 
448 497
         // EXTENSION CHECK
449
-        elseif (!$this->validateExtension($extension, $this->type))
450
-            return $this->label("Denied file extension.");
498
+        elseif (!$this->validateExtension($extension, $this->type)) {
499
+                    return $this->label("Denied file extension.");
500
+        }
451 501
 
452 502
         // SPECIAL DIRECTORY TYPES CHECK (e.g. *img)
453 503
         elseif (preg_match('/^\*([^ ]+)(.*)?$/s', $typePatt, $patt)) {
@@ -457,70 +507,84 @@  discard block
 block discarded – undo
457 507
                 $type = new $class();
458 508
                 $cfg = $config;
459 509
                 $cfg['filename'] = $file['name'];
460
-                if (strlen($params))
461
-                    $cfg['params'] = trim($params);
510
+                if (strlen($params)) {
511
+                                    $cfg['params'] = trim($params);
512
+                }
462 513
                 $response = $type->checkFile($file['tmp_name'], $cfg);
463
-                if ($response !== true)
464
-                    return $this->label($response);
465
-            } else
466
-                return $this->label("Non-existing directory type.");
514
+                if ($response !== true) {
515
+                                    return $this->label($response);
516
+                }
517
+            } else {
518
+                            return $this->label("Non-existing directory type.");
519
+            }
467 520
         }
468 521
 
469 522
         // IMAGE RESIZE
470 523
         $img = image::factory($this->imageDriver, $file['tmp_name']);
471
-        if (!$img->initError && !$this->imageResize($img, $file['tmp_name']))
472
-            return $this->label("The image is too big and/or cannot be resized.");
524
+        if (!$img->initError && !$this->imageResize($img, $file['tmp_name'])) {
525
+                    return $this->label("The image is too big and/or cannot be resized.");
526
+        }
473 527
 
474 528
 
475 529
 	// CHECK FOR MODX MAX FILE SIZE
476 530
 	$actualfilesize=filesize($file['tmp_name']);
477
-	if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize'])
478
-	    return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
531
+	if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize']) {
532
+		    return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
533
+	}
479 534
 
480 535
         return true;
481 536
     }
482 537
 
483
-    protected function checkInputDir($dir, $inclType=true, $existing=true) {
538
+    protected function checkInputDir($dir, $inclType=true, $existing=true)
539
+    {
484 540
         $dir = path::normalize($dir);
485
-        if (substr($dir, 0, 1) == "/")
486
-            $dir = substr($dir, 1);
541
+        if (substr($dir, 0, 1) == "/") {
542
+                    $dir = substr($dir, 1);
543
+        }
487 544
 
488
-        if ((substr($dir, 0, 1) == ".") || (substr(basename($dir), 0, 1) == "."))
489
-            return false;
545
+        if ((substr($dir, 0, 1) == ".") || (substr(basename($dir), 0, 1) == ".")) {
546
+                    return false;
547
+        }
490 548
 
491 549
         if ($inclType) {
492 550
             $first = explode("/", $dir);
493 551
             $first = $first[0];
494
-            if ($first != $this->type)
495
-                return false;
552
+            if ($first != $this->type) {
553
+                            return false;
554
+            }
496 555
             $return = $this->removeTypeFromPath($dir);
497 556
         } else {
498 557
             $return = $dir;
499 558
             $dir = "{$this->type}/$dir";
500 559
         }
501 560
 
502
-        if (!$existing)
503
-            return $return;
561
+        if (!$existing) {
562
+                    return $return;
563
+        }
504 564
 
505 565
         $path = "{$this->config['uploadDir']}/$dir";
506 566
         return (is_dir($path) && is_readable($path)) ? $return : false;
507 567
     }
508 568
 
509
-    protected function validateExtension($ext, $type) {
569
+    protected function validateExtension($ext, $type)
570
+    {
510 571
         $ext = trim(strtolower($ext));
511
-        if (!isset($this->types[$type]))
512
-            return false;
572
+        if (!isset($this->types[$type])) {
573
+                    return false;
574
+        }
513 575
 
514 576
         $exts = strtolower(text::clearWhitespaces($this->config['deniedExts']));
515 577
         if (strlen($exts)) {
516 578
             $exts = explode(" ", $exts);
517
-            if (in_array($ext, $exts))
518
-                return false;
579
+            if (in_array($ext, $exts)) {
580
+                            return false;
581
+            }
519 582
         }
520 583
 
521 584
         $exts = trim($this->types[$type]);
522
-        if (!strlen($exts) || substr($exts, 0, 1) == "*")
523
-            return true;
585
+        if (!strlen($exts) || substr($exts, 0, 1) == "*") {
586
+                    return true;
587
+        }
524 588
 
525 589
         if (substr($exts, 0, 1) == "!") {
526 590
             $exts = explode(" ", trim(strtolower(substr($exts, 1))));
@@ -531,26 +595,32 @@  discard block
 block discarded – undo
531 595
         return in_array($ext, $exts);
532 596
     }
533 597
 
534
-    protected function getTypeFromPath($path) {
598
+    protected function getTypeFromPath($path)
599
+    {
535 600
         return preg_match('/^([^\/]*)\/.*$/', $path, $patt)
536 601
             ? $patt[1] : $path;
537 602
     }
538 603
 
539
-    protected function removeTypeFromPath($path) {
604
+    protected function removeTypeFromPath($path)
605
+    {
540 606
         return preg_match('/^[^\/]*\/(.*)$/', $path, $patt)
541 607
             ? $patt[1] : "";
542 608
     }
543 609
 
544
-    protected function imageResize($image, $file=null) {
610
+    protected function imageResize($image, $file=null)
611
+    {
545 612
 
546 613
         if (!($image instanceof image)) {
547 614
             $img = image::factory($this->imageDriver, $image);
548
-            if ($img->initError) return false;
615
+            if ($img->initError) {
616
+                return false;
617
+            }
549 618
             $file = $image;
550
-        } elseif ($file === null)
551
-            return false;
552
-        else
553
-            $img = $image;
619
+        } elseif ($file === null) {
620
+                    return false;
621
+        } else {
622
+                    $img = $image;
623
+        }
554 624
 
555 625
         $orientation = 1;
556 626
         if (function_exists("exif_read_data")) {
@@ -572,8 +642,9 @@  discard block
 block discarded – undo
572 642
             )
573 643
             ) &&
574 644
             ($orientation == 1)
575
-        )
576
-            return true;
645
+        ) {
646
+                    return true;
647
+        }
577 648
 
578 649
 
579 650
         // PROPORTIONAL RESIZE
@@ -593,15 +664,17 @@  discard block
 block discarded – undo
593 664
                 $width = $img->getPropWidth($height);
594 665
             }
595 666
 
596
-            if (isset($width) && isset($height) && !$img->resize($width, $height))
597
-                return false;
667
+            if (isset($width) && isset($height) && !$img->resize($width, $height)) {
668
+                            return false;
669
+            }
598 670
 
599 671
         // RESIZE TO FIT
600 672
         } elseif (
601 673
             $this->config['maxImageWidth'] && $this->config['maxImageHeight'] &&
602 674
             !$img->resizeFit($this->config['maxImageWidth'], $this->config['maxImageHeight'])
603
-        )
604
-            return false;
675
+        ) {
676
+                    return false;
677
+        }
605 678
 
606 679
         // AUTO FLIP AND ROTATE FROM EXIF
607 680
         if ((($orientation == 2) && !$img->flipHorizontal()) ||
@@ -611,11 +684,13 @@  discard block
 block discarded – undo
611 684
             (($orientation == 6) && !$img->rotate(90)) ||
612 685
             (($orientation == 7) && (!$img->flipHorizontal() || !$img->rotate(90))) ||
613 686
             (($orientation == 8) && !$img->rotate(270))
614
-        )
615
-            return false;
616
-        if (($orientation >= 2) && ($orientation <= 8) && ($this->imageDriver == "imagick"))
617
-            try {
687
+        ) {
688
+                    return false;
689
+        }
690
+        if (($orientation >= 2) && ($orientation <= 8) && ($this->imageDriver == "imagick")) {
691
+                    try {
618 692
                 $img->image->setImageProperty('exif:Orientation', "1");
693
+        }
619 694
             } catch (Exception $e) {}
620 695
 
621 696
         // WATERMARK
@@ -646,22 +721,26 @@  discard block
 block discarded – undo
646 721
 
647 722
     }
648 723
 
649
-    protected function makeThumb($file, $overwrite=true) {
724
+    protected function makeThumb($file, $overwrite=true)
725
+    {
650 726
         $img = image::factory($this->imageDriver, $file);
651 727
 
652 728
         // Drop files which are not images
653
-        if ($img->initError)
654
-            return true;
729
+        if ($img->initError) {
730
+                    return true;
731
+        }
655 732
 
656 733
         $thumb = substr($file, strlen($this->config['uploadDir']));
657 734
         $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb;
658 735
         $thumb = path::normalize($thumb);
659 736
         $thumbDir = dirname($thumb);
660
-        if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true))
661
-            return false;
737
+        if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) {
738
+                    return false;
739
+        }
662 740
 
663
-        if (!$overwrite && is_file($thumb))
664
-            return true;
741
+        if (!$overwrite && is_file($thumb)) {
742
+                    return true;
743
+        }
665 744
 
666 745
         // Images with smaller resolutions than thumbnails
667 746
         /*if (($img->width <= $this->config['thumbWidth']) &&
@@ -674,8 +753,9 @@  discard block
 block discarded – undo
674 753
 
675 754
         // Resize image
676 755
         } else */
677
-        if (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight']))
678
-            return false;
756
+        if (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight'])) {
757
+                    return false;
758
+        }
679 759
 
680 760
         if ( $this->imageDriver == 'gd' ) {
681 761
             $width  = imagesx( $img->image );
@@ -697,7 +777,8 @@  discard block
 block discarded – undo
697 777
         ));
698 778
     }
699 779
 
700
-    protected function localize($langCode) {
780
+    protected function localize($langCode)
781
+    {
701 782
         require "lang/{$langCode}.php";
702 783
         setlocale(LC_ALL, $lang['_locale']);
703 784
         $this->charset = $lang['_charset'];
@@ -712,27 +793,34 @@  discard block
 block discarded – undo
712 793
         $this->labels = $lang;
713 794
     }
714 795
 
715
-    protected function label($string, array $data=null) {
796
+    protected function label($string, array $data=null)
797
+    {
716 798
         $return = isset($this->labels[$string]) ? $this->labels[$string] : $string;
717
-        if (is_array($data))
718
-            foreach ($data as $key => $val)
799
+        if (is_array($data)) {
800
+                    foreach ($data as $key => $val)
719 801
                 $return = str_replace("{{$key}}", $val, $return);
802
+        }
720 803
         return $return;
721 804
     }
722 805
 
723
-    protected function backMsg($message, array $data=null) {
806
+    protected function backMsg($message, array $data=null)
807
+    {
724 808
         $message = $this->label($message, $data);
725
-        if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name']))
726
-            @unlink($this->file['tmp_name']);
809
+        if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) {
810
+                    @unlink($this->file['tmp_name']);
811
+        }
727 812
         $this->callBack("", $message);
728 813
         die;
729 814
     }
730 815
 
731
-    protected function callBack($url, $message="") {
816
+    protected function callBack($url, $message="")
817
+    {
732 818
         $message = text::jsValue($message);
733 819
         $CKfuncNum = isset($this->opener['CKEditor']['funcNum'])
734 820
             ? $this->opener['CKEditor']['funcNum'] : 0;
735
-        if (!$CKfuncNum) $CKfuncNum = 0;
821
+        if (!$CKfuncNum) {
822
+            $CKfuncNum = 0;
823
+        }
736 824
         header("Content-Type: text/html; charset={$this->charset}");
737 825
 
738 826
 ?><html>
@@ -769,7 +857,8 @@  discard block
 block discarded – undo
769 857
 
770 858
     }
771 859
 
772
-    protected function get_htaccess() {
860
+    protected function get_htaccess()
861
+    {
773 862
         return "<IfModule mod_php4.c>
774 863
   php_value engine off
775 864
 </IfModule>
Please login to merge, or discard this patch.
manager/processors/undelete_content.processor.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@
 block discarded – undo
47 47
 /**
48 48
  * @param int $parent
49 49
  */
50
-function getChildren($parent) {
50
+function getChildren($parent)
51
+{
51 52
 
52 53
 	$modx = evolutionCMS();
53 54
 	global $children;
Please login to merge, or discard this patch.
manager/processors/login.processor.php 1 patch
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -296,7 +296,8 @@  discard block
 block discarded – undo
296 296
  *
297 297
  * @param string $msg
298 298
  */
299
-function jsAlert($msg) {
299
+function jsAlert($msg)
300
+{
300 301
 	$modx = evolutionCMS();
301 302
 	if($_POST['ajax'] != 1) {
302 303
 		echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
@@ -311,7 +312,8 @@  discard block
 block discarded – undo
311 312
  * @param string $dbasePassword
312 313
  * @return bool
313 314
  */
314
-function login($username, $givenPassword, $dbasePassword) {
315
+function login($username, $givenPassword, $dbasePassword)
316
+{
315 317
 	$modx = evolutionCMS();
316 318
 	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
317 319
 }
@@ -323,7 +325,8 @@  discard block
 block discarded – undo
323 325
  * @param string $username
324 326
  * @return bool
325 327
  */
326
-function loginV1($internalKey, $givenPassword, $dbasePassword, $username) {
328
+function loginV1($internalKey, $givenPassword, $dbasePassword, $username)
329
+{
327 330
 	$modx = evolutionCMS();
328 331
 
329 332
 	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
@@ -353,7 +356,8 @@  discard block
 block discarded – undo
353 356
  * @param string $username
354 357
  * @return bool
355 358
  */
356
-function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) {
359
+function loginMD5($internalKey, $givenPassword, $dbasePassword, $username)
360
+{
357 361
 	$modx = evolutionCMS();
358 362
 
359 363
 	if($dbasePassword != md5($givenPassword)) {
@@ -367,7 +371,8 @@  discard block
 block discarded – undo
367 371
  * @param string $username
368 372
  * @param string $password
369 373
  */
370
-function updateNewHash($username, $password) {
374
+function updateNewHash($username, $password)
375
+{
371 376
 	$modx = evolutionCMS();
372 377
 
373 378
 	$field = array();
@@ -381,16 +386,19 @@  discard block
 block discarded – undo
381 386
  * @param int $failed_allowed
382 387
  * @param int $blocked_minutes
383 388
  */
384
-function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) {
389
+function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes)
390
+{
385 391
 	$modx = evolutionCMS();
386 392
 
387 393
 	$failedlogins += 1;
388 394
 
389 395
 	$fields = array('failedlogincount' => $failedlogins);
390
-	if($failedlogins >= $failed_allowed) //block user for too many fail attempts
396
+	if($failedlogins >= $failed_allowed) {
397
+	    //block user for too many fail attempts
391 398
 	{
392 399
 		$fields['blockeduntil'] = time() + ($blocked_minutes * 60);
393 400
 	}
401
+	}
394 402
 
395 403
 	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
396 404
 
Please login to merge, or discard this patch.
manager/processors/save_user.processor.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -356,7 +356,8 @@  discard block
 block discarded – undo
356 356
  * @param string $pwd
357 357
  * @param string $ufn
358 358
  */
359
-function sendMailMessage($email, $uid, $pwd, $ufn) {
359
+function sendMailMessage($email, $uid, $pwd, $ufn)
360
+{
360 361
 	$modx = evolutionCMS(); global $_lang, $signupemail_message;
361 362
 	global $emailsubject, $emailsender;
362 363
 	global $site_name;
@@ -389,7 +390,8 @@  discard block
 block discarded – undo
389 390
  *
390 391
  * @param int $id
391 392
  */
392
-function saveUserSettings($id) {
393
+function saveUserSettings($id)
394
+{
393 395
 	$modx = evolutionCMS();
394 396
 	$tbl_user_settings = $modx->getFullTableName('user_settings');
395 397
 
@@ -477,7 +479,8 @@  discard block
 block discarded – undo
477 479
  *
478 480
  * @param $msg
479 481
  */
480
-function webAlertAndQuit($msg) {
482
+function webAlertAndQuit($msg)
483
+{
481 484
 	global $id, $modx;
482 485
 	$mode = $_POST['mode'];
483 486
 	$modx->manager->saveFormValues($mode);
@@ -490,7 +493,8 @@  discard block
 block discarded – undo
490 493
  * @param int $length
491 494
  * @return string
492 495
  */
493
-function generate_password($length = 10) {
496
+function generate_password($length = 10)
497
+{
494 498
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
495 499
 	$ps_len = strlen($allowable_characters);
496 500
 	mt_srand((double) microtime() * 1000000);
Please login to merge, or discard this patch.
manager/processors/save_plugin.processor.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -177,7 +177,9 @@  discard block
 block discarded – undo
177 177
     // save selected system events
178 178
     $formEventList = array();
179 179
     foreach ($sysevents as $evtId) {
180
-        if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId);
180
+        if(!preg_match('@^[1-9][0-9]*$@',$evtId)) {
181
+            $evtId = getEventIdByName($evtId);
182
+        }
181 183
         if ($mode == '101') {
182 184
             $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'");
183 185
         } else {
@@ -203,10 +205,14 @@  discard block
 block discarded – undo
203 205
     $dbEventList = array();
204 206
     $del = array();
205 207
     while($row = $modx->db->getRow($rs)) {
206
-        if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid'];
208
+        if(!in_array($row['evtid'], $evtids)) {
209
+            $del[] = $row['evtid'];
210
+        }
207 211
     }
208 212
 
209
-    if(empty($del)) return;
213
+    if(empty($del)) {
214
+        return;
215
+    }
210 216
 
211 217
     foreach($del as $delid) {
212 218
         $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id));
@@ -222,7 +228,9 @@  discard block
 block discarded – undo
222 228
     $modx = evolutionCMS();
223 229
     static $eventIds=array();
224 230
 
225
-    if(isset($eventIds[$name])) return $eventIds[$name];
231
+    if(isset($eventIds[$name])) {
232
+        return $eventIds[$name];
233
+    }
226 234
 
227 235
     $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames');
228 236
     while ($row = $modx->db->getRow($rs)) {
Please login to merge, or discard this patch.
manager/processors/cache_sync.class.processor.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,8 @@  discard block
 block discarded – undo
79 79
      * @return string
80 80
      */
81 81
     public function getParents($id, $path = '')
82
-    { // modx:returns child's parent
82
+    {
83
+// modx:returns child's parent
83 84
         $modx = evolutionCMS();
84 85
         if (empty($this->aliases)) {
85 86
             $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible";
@@ -456,7 +457,8 @@  discard block
 block discarded – undo
456 457
                         $_ = trim($_);
457 458
                     }
458 459
                     $lastChar = substr($_, -1);
459
-                    if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289
460
+                    if (!in_array($lastChar, $chars)) {
461
+// ,320,327,288,284,289
460 462
                         if (!in_array($prev_token,
461 463
                             array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) {
462 464
                             $_ .= ' ';
Please login to merge, or discard this patch.
manager/processors/move_document.processor.php 1 patch
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,12 +12,20 @@  discard block
 block discarded – undo
12 12
 // ok, two things to check.
13 13
 // first, document cannot be moved to itself
14 14
 // second, new parent must be a folder. If not, set it to folder.
15
-if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]);
16
-if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
17
-if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
15
+if($documentID==$newParentID) {
16
+    $modx->webAlertAndQuit($_lang["error_movedocument1"]);
17
+}
18
+if($documentID <= 0) {
19
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
20
+}
21
+if($newParentID < 0) {
22
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
23
+}
18 24
 
19 25
 $parents = $modx->getParentIds($newParentID);
20
-if (in_array($documentID, $parents))  $modx->webAlertAndQuit($_lang["error_movedocument2"]);
26
+if (in_array($documentID, $parents)) {
27
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
28
+}
21 29
 
22 30
 $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'");
23 31
 $oldparent = $modx->db->getValue($rs);
@@ -42,7 +50,8 @@  discard block
 block discarded – undo
42 50
  * @param int $currDocID
43 51
  * @return array
44 52
  */
45
-function allChildren($currDocID) {
53
+function allChildren($currDocID)
54
+{
46 55
 	$modx = evolutionCMS();
47 56
 	$children= array();
48 57
 	$currDocID = $modx->db->escape($currDocID);
@@ -59,11 +68,11 @@  discard block
 block discarded – undo
59 68
 	"old_parent" => $oldparent,
60 69
 	"new_parent" => $newParentID
61 70
 ));
62
-if (is_array($evtOut) && count($evtOut) > 0){
71
+if (is_array($evtOut) && count($evtOut) > 0) {
63 72
 	$newParent = array_pop($evtOut);
64 73
 	if($newParent == $oldparent) {
65 74
 		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
75
+	} else {
67 76
 		$newParentID = $newParent;
68 77
 	}
69 78
 }
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -340,7 +340,8 @@  discard block
 block discarded – undo
340 340
  * @param string $string
341 341
  * @return string
342 342
  */
343
-function save_user_quoted_printable($string) {
343
+function save_user_quoted_printable($string)
344
+{
344 345
 	$crlf = "\n";
345 346
 	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346 347
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
@@ -359,7 +360,8 @@  discard block
 block discarded – undo
359 360
  * @param string $pwd
360 361
  * @param string $ufn
361 362
  */
362
-function sendMailMessage($email, $uid, $pwd, $ufn) {
363
+function sendMailMessage($email, $uid, $pwd, $ufn)
364
+{
363 365
 	$modx = evolutionCMS(); global $_lang, $websignupemail_message;
364 366
 	global $emailsubject, $emailsender;
365 367
 	global $site_name, $site_url;
@@ -387,7 +389,8 @@  discard block
 block discarded – undo
387 389
 }
388 390
 
389 391
 // Save User Settings
390
-function saveUserSettings($id) {
392
+function saveUserSettings($id)
393
+{
391 394
 	$modx = evolutionCMS();
392 395
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393 396
 
@@ -416,7 +419,8 @@  discard block
 block discarded – undo
416 419
 }
417 420
 
418 421
 // Web alert -  sends an alert to web browser
419
-function webAlertAndQuit($msg) {
422
+function webAlertAndQuit($msg)
423
+{
420 424
 	global $id, $modx;
421 425
 	$mode = $_POST['mode'];
422 426
 	$modx->manager->saveFormValues($mode);
@@ -424,7 +428,8 @@  discard block
 block discarded – undo
424 428
 }
425 429
 
426 430
 // Generate password
427
-function generate_password($length = 10) {
431
+function generate_password($length = 10)
432
+{
428 433
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429 434
 	$ps_len = strlen($allowable_characters);
430 435
 	mt_srand((double) microtime() * 1000000);
@@ -435,7 +440,8 @@  discard block
 block discarded – undo
435 440
 	return $pass;
436 441
 }
437 442
 
438
-function sanitize($str = '', $safecount = 0) {
443
+function sanitize($str = '', $safecount = 0)
444
+{
439 445
 	$modx = evolutionCMS();
440 446
 	$safecount++;
441 447
 	if(1000 < $safecount) {
Please login to merge, or discard this patch.