Completed
Pull Request — develop (#545)
by Agel_Nash
05:36
created
manager/includes/config_check.inc.php 1 patch
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 $warningspresent = 0;
20 20
 
21 21
 $sysfiles_check = $modx->manager->checkSystemChecksum();
22
-if ($sysfiles_check!=='0'){
22
+if ($sysfiles_check!=='0') {
23 23
       $warningspresent = 1;
24 24
       $warnings[] = array($_lang['configcheck_sysfiles_mod']);
25 25
 }
26 26
 
27
-if (is_writable("includes/config.inc.php")){
27
+if (is_writable("includes/config.inc.php")) {
28 28
     // Warn if world writable
29 29
     if(@fileperms('includes/config.inc.php') & 0x0002) {
30 30
       $warningspresent = 1;
@@ -120,7 +120,8 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @return bool
122 122
      */
123
-    function checkSiteCache() {
123
+    function checkSiteCache()
124
+    {
124 125
         $modx = DocumentParser::getInstance();
125 126
         $checked= true;
126 127
         if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) {
@@ -159,26 +160,36 @@  discard block
 block discarded – undo
159 160
 
160 161
 if ($warningspresent==1) {
161 162
 
162
-if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3';
163
+if(!isset($modx->config['send_errormail'])) {
164
+    $modx->config['send_errormail']='3';
165
+}
163 166
 $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>";
164 167
 
165 168
 for ($i=0;$i<count($warnings);$i++) {
166 169
     switch ($warnings[$i][0]) {
167 170
         case $_lang['configcheck_configinc'];
168 171
             $warnings[$i][1] = $_lang['configcheck_configinc_msg'];
169
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
172
+            if(!$_SESSION["mgrConfigCheck"]) {
173
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']);
174
+            }
170 175
             break;
171 176
         case $_lang['configcheck_installer'] :
172 177
             $warnings[$i][1] = $_lang['configcheck_installer_msg'];
173
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
178
+            if(!$_SESSION["mgrConfigCheck"]) {
179
+                $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']);
180
+            }
174 181
             break;
175 182
         case $_lang['configcheck_cache'] :
176 183
             $warnings[$i][1] = $_lang['configcheck_cache_msg'];
177
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
184
+            if(!$_SESSION["mgrConfigCheck"]) {
185
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']);
186
+            }
178 187
             break;
179 188
         case $_lang['configcheck_images'] :
180 189
             $warnings[$i][1] = $_lang['configcheck_images_msg'];
181
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
190
+            if(!$_SESSION["mgrConfigCheck"]) {
191
+                $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']);
192
+            }
182 193
             break;
183 194
         case $_lang['configcheck_sysfiles_mod']:
184 195
             $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"];
@@ -186,7 +197,9 @@  discard block
 block discarded – undo
186 197
 			if($modx->hasPermission('settings')) {
187 198
 				$warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>';
188 199
 			}
189
-            if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
200
+            if(!$_SESSION["mgrConfigCheck"]) {
201
+                $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']);
202
+            }
190 203
             break;
191 204
         case $_lang['configcheck_lang_difference'] :
192 205
             $warnings[$i][1] = $_lang['configcheck_lang_difference_msg'];
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 = DocumentParser::getInstance();
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/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 = DocumentParser::getInstance();
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 = DocumentParser::getInstance(); 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/style/common/moo-datepicker/datepicker.inc.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,11 @@
 block discarded – undo
1 1
 <?php
2
-class DATEPICKER {
3
-    function __construct() {
2
+class DATEPICKER
3
+{
4
+    function __construct()
5
+    {
4 6
     }
5
-    function getDP() {
7
+    function getDP()
8
+    {
6 9
         $modx = DocumentParser::getInstance(); global$_lang;
7 10
 
8 11
         $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl');
Please login to merge, or discard this patch.
manager/media/calendar/datepicker.inc.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-class DATEPICKER {
4
-	function __construct() {
3
+class DATEPICKER
4
+{
5
+	function __construct()
6
+	{
5 7
 	}
6 8
 
7
-	function getDP() {
9
+	function getDP()
10
+	{
8 11
 		$modx = DocumentParser::getInstance(); global $_lang;
9 12
 
10 13
 		$tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl');
Please login to merge, or discard this patch.
manager/actions/mutate_role.dynamic.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -299,7 +299,8 @@
 block discarded – undo
299 299
  * @param string $status
300 300
  * @return string
301 301
  */
302
-function render_form($name, $label, $status = '') {
302
+function render_form($name, $label, $status = '')
303
+{
303 304
 	$modx = DocumentParser::getInstance(); global $roledata;
304 305
 
305 306
 	$tpl = '<label class="d-block" for="[+name+]check">
Please login to merge, or discard this patch.
manager/actions/files.dynamic.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -893,7 +893,9 @@
 block discarded – undo
893 893
     $modx = DocumentParser::getInstance(); global $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions;
894 894
     $msg = '';
895 895
     foreach ($_FILES['userfile']['name'] as $i => $name) {
896
-        if (empty($_FILES['userfile']['tmp_name'][$i])) continue;
896
+        if (empty($_FILES['userfile']['tmp_name'][$i])) {
897
+            continue;
898
+        }
897 899
         $userfile= array();
898 900
 
899 901
         $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i];
Please login to merge, or discard this patch.
manager/actions/import_site.static.php 1 patch
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -104,7 +104,8 @@  discard block
 block discarded – undo
104 104
 /**
105 105
  * @return string
106 106
  */
107
-function run() {
107
+function run()
108
+{
108 109
 	$modx = DocumentParser::getInstance(); global $_lang;
109 110
 
110 111
 	$tbl_site_content = $modx->getFullTableName('site_content');
@@ -171,7 +172,8 @@  discard block
 block discarded – undo
171 172
  * @param array $files
172 173
  * @param string $mode
173 174
  */
174
-function importFiles($parent, $filedir, $files, $mode) {
175
+function importFiles($parent, $filedir, $files, $mode)
176
+{
175 177
 	$modx = DocumentParser::getInstance();
176 178
 	global $_lang, $allowedfiles;
177 179
 	global $search_default, $cache_default, $publish_default;
@@ -318,7 +320,8 @@  discard block
 block discarded – undo
318 320
  * @param int $count
319 321
  * @return array
320 322
  */
321
-function getFiles($directory, $listing = array(), $count = 0) {
323
+function getFiles($directory, $listing = array(), $count = 0)
324
+{
322 325
 	global $_lang;
323 326
 	global $filesfound;
324 327
 	$dummy = $count;
@@ -346,7 +349,8 @@  discard block
 block discarded – undo
346 349
  * @param string $filepath
347 350
  * @return bool|string
348 351
  */
349
-function getFileContent($filepath) {
352
+function getFileContent($filepath)
353
+{
350 354
 	global $_lang;
351 355
 	// get the file
352 356
 	if(!$buffer = file_get_contents($filepath)) {
@@ -360,7 +364,8 @@  discard block
 block discarded – undo
360 364
  * @param array $array
361 365
  * @return array
362 366
  */
363
-function pop_index($array) {
367
+function pop_index($array)
368
+{
364 369
 	$new_array = array();
365 370
 	foreach($array as $k => $v) {
366 371
 		if($v !== 'index.html' && $v !== 'index.htm') {
@@ -383,7 +388,8 @@  discard block
 block discarded – undo
383 388
  * @param string $alias
384 389
  * @return array
385 390
  */
386
-function treatContent($src, $filename, $alias) {
391
+function treatContent($src, $filename, $alias)
392
+{
387 393
 	$modx = DocumentParser::getInstance();
388 394
 
389 395
 	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
@@ -427,7 +433,8 @@  discard block
 block discarded – undo
427 433
 /**
428 434
  * @return void
429 435
  */
430
-function convertLink() {
436
+function convertLink()
437
+{
431 438
 	$modx = DocumentParser::getInstance();
432 439
 	$tbl_site_content = $modx->getFullTableName('site_content');
433 440
 
Please login to merge, or discard this patch.
manager/actions/resources/mgrResources.class.php 1 patch
Braces   +23 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,7 +3,8 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 
6
-class mgrResources {
6
+class mgrResources
7
+{
7 8
     /**
8 9
      * @var array
9 10
      */
@@ -24,7 +25,8 @@  discard block
 block discarded – undo
24 25
     /**
25 26
      * mgrResources constructor.
26 27
      */
27
-    public function __construct() {
28
+    public function __construct()
29
+    {
28 30
 		$this->setTypes();
29 31
 		$this->queryItemsFromDB();
30 32
 		$this->prepareCategoryArrays();
@@ -33,7 +35,8 @@  discard block
 block discarded – undo
33 35
     /**
34 36
      * @return void
35 37
      */
36
-    public function setTypes() {
38
+    public function setTypes()
39
+    {
37 40
 		global $_lang;
38 41
 		$this->types['site_templates']    = array(
39 42
 			'title'=>$_lang["manage_templates"],
@@ -71,7 +74,8 @@  discard block
 block discarded – undo
71 74
     /**
72 75
      * @return void
73 76
      */
74
-    public function queryItemsFromDB() {
77
+    public function queryItemsFromDB()
78
+    {
75 79
 		foreach($this->types as $resourceTable=>$type) {
76 80
 			if($this->hasAnyPermissions($type['permissions'])) {
77 81
 				$nameField = isset($type['name']) ? $type['name'] : 'name';
@@ -84,11 +88,13 @@  discard block
 block discarded – undo
84 88
      * @param array $permissions
85 89
      * @return bool
86 90
      */
87
-    public function hasAnyPermissions($permissions) {
91
+    public function hasAnyPermissions($permissions)
92
+    {
88 93
 		$modx = DocumentParser::getInstance();
89 94
 
90
-		foreach($permissions as $p)
91
-			if($modx->hasPermission($p)) return true;
95
+		foreach($permissions as $p) {
96
+					if($modx->hasPermission($p)) return true;
97
+		}
92 98
 
93 99
 		return false;
94 100
 	}
@@ -98,7 +104,8 @@  discard block
 block discarded – undo
98 104
      * @param string $nameField
99 105
      * @return array|bool
100 106
      */
101
-    public function queryResources($resourceTable, $nameField = 'name') {
107
+    public function queryResources($resourceTable, $nameField = 'name')
108
+    {
102 109
 		$modx = DocumentParser::getInstance(); global $_lang;
103 110
 
104 111
         $allowed = array(
@@ -115,8 +122,9 @@  discard block
 block discarded – undo
115 122
 			$tvsql    = 'site_tmplvars.caption, ';
116 123
 			$tvjoin   = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates'));
117 124
 			$sttfield = 'IF(stt.templateid,1,0) AS reltpl,';
125
+		} else {
126
+		    $sttfield = '';
118 127
 		}
119
-		else $sttfield = '';
120 128
 
121 129
 		$selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : "";
122 130
 
@@ -129,7 +137,9 @@  discard block
 block discarded – undo
129 137
 		);
130 138
 		$limit = $modx->db->getRecordCount($rs);
131 139
 
132
-		if($limit < 1) return false;
140
+		if($limit < 1) {
141
+		    return false;
142
+		}
133 143
 
134 144
 		$result = array();
135 145
 		while ($row = $modx->db->getRow($rs)) {
@@ -141,7 +151,8 @@  discard block
 block discarded – undo
141 151
     /**
142 152
      * @return void
143 153
      */
144
-    public function prepareCategoryArrays() {
154
+    public function prepareCategoryArrays()
155
+    {
145 156
 		foreach($this->items as $type=>$items) {
146 157
 			foreach((array)$items as $item) {
147 158
 				$catid = $item['catid'] ? $item['catid'] : 0;
@@ -157,7 +168,7 @@  discard block
 block discarded – undo
157 168
 
158 169
 		// Now sort by name
159 170
 		foreach($this->itemsPerCategory as $catid=>$items) {
160
-			usort($this->itemsPerCategory[$catid], function ($a, $b) {
171
+			usort($this->itemsPerCategory[$catid], function ($a, $b){
161 172
 				return strcasecmp($a['name'], $b['name']);
162 173
 			});
163 174
 		}
Please login to merge, or discard this patch.