@@ -139,11 +139,14 @@ |
||
139 | 139 | * @param string $itemid |
140 | 140 | * @return string |
141 | 141 | */ |
142 | -function getAction($actionId, $itemid='') { |
|
142 | +function getAction($actionId, $itemid='') |
|
143 | +{ |
|
143 | 144 | global $action_list; |
144 | 145 | |
145 | 146 | $ret = sprintf($action_list[$actionId], $itemid); |
146 | - if (!$ret) $ret = "Idle (unknown)"; |
|
147 | + if (!$ret) { |
|
148 | + $ret = "Idle (unknown)"; |
|
149 | + } |
|
147 | 150 | |
148 | 151 | return $ret; |
149 | 152 | } |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | if (file_exists(MODX_BASE_PATH . 'assets/cache/installProc.inc.php')) { |
22 | 22 | include_once(MODX_BASE_PATH . 'assets/cache/installProc.inc.php'); |
23 | 23 | if (isset($installStartTime)) { |
24 | - if ((time() - $installStartTime) > 5 * 60) { // if install flag older than 5 minutes, discard |
|
24 | + if ((time() - $installStartTime) > 5 * 60) { |
|
25 | +// if install flag older than 5 minutes, discard |
|
25 | 26 | unset($installStartTime); |
26 | 27 | @ chmod(MODX_BASE_PATH . 'assets/cache/installProc.inc.php', 0755); |
27 | 28 | unlink(MODX_BASE_PATH . 'assets/cache/installProc.inc.php'); |
@@ -163,7 +164,8 @@ discard block |
||
163 | 164 | } elseif (is_file($theme_path . 'templates/actions/login.tpl')) { |
164 | 165 | $target = $theme_path . 'templates/actions/login.tpl'; |
165 | 166 | $login_tpl = file_get_contents($target); |
166 | - } elseif (is_file($theme_path . 'html/login.html')) { // ClipperCMS compatible |
|
167 | + } elseif (is_file($theme_path . 'html/login.html')) { |
|
168 | +// ClipperCMS compatible |
|
167 | 169 | $target = $theme_path . 'html/login.html'; |
168 | 170 | $login_tpl = file_get_contents($target); |
169 | 171 | } else { |
@@ -1,10 +1,13 @@ |
||
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 = evolutionCMS(); global $_lang; |
9 | 12 | |
10 | 13 | $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
@@ -1,8 +1,11 @@ |
||
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 = evolutionCMS(); global$_lang; |
7 | 10 | |
8 | 11 | $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
@@ -1,13 +1,17 @@ discard block |
||
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 |
||
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'; |
@@ -12,7 +12,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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> |
@@ -113,7 +113,9 @@ |
||
113 | 113 | <?php |
114 | 114 | // invoke OnMiscSettingsRender event |
115 | 115 | $evtOut = $modx->invokeEvent('OnFileManagerSettingsRender'); |
116 | - if(is_array($evtOut)) echo implode("",$evtOut); |
|
116 | + if(is_array($evtOut)) { |
|
117 | + echo implode("",$evtOut); |
|
118 | + } |
|
117 | 119 | ?> |
118 | 120 | </td> |
119 | 121 | </tr> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br /> |
4 | 4 | Please use the EVO Content Manager instead of accessing this file directly."); |
5 | 5 | } |
@@ -10,26 +10,26 @@ discard block |
||
10 | 10 | $modx_textdir = isset($modx_textdir) ? $modx_textdir : null; |
11 | 11 | $onManagerMainFrameHeaderHTMLBlock = is_array($evtOut) ? implode("\n", $evtOut) : ''; |
12 | 12 | $textdir = $modx_textdir === 'rtl' ? 'rtl' : 'ltr'; |
13 | -if (!isset($modx->config['mgr_jquery_path'])) { |
|
13 | +if (!isset($modx->config['mgr_jquery_path'])) { |
|
14 | 14 | $modx->config['mgr_jquery_path'] = 'media/script/jquery/jquery.min.js'; |
15 | 15 | } |
16 | -if (!isset($modx->config['mgr_date_picker_path'])) { |
|
16 | +if (!isset($modx->config['mgr_date_picker_path'])) { |
|
17 | 17 | $modx->config['mgr_date_picker_path'] = 'media/script/air-datepicker/datepicker.inc.php'; |
18 | 18 | } |
19 | 19 | |
20 | 20 | $body_class = ''; |
21 | 21 | $theme_modes = array('', 'lightness', 'light', 'dark', 'darkness'); |
22 | -if (!empty($theme_modes[$_COOKIE['MODX_themeMode']])) { |
|
22 | +if (!empty($theme_modes[$_COOKIE['MODX_themeMode']])) { |
|
23 | 23 | $body_class .= ' ' . $theme_modes[$_COOKIE['MODX_themeMode']]; |
24 | -} elseif (!empty($theme_modes[$modx->config['manager_theme_mode']])) { |
|
24 | +} elseif (!empty($theme_modes[$modx->config['manager_theme_mode']])) { |
|
25 | 25 | $body_class .= ' ' . $theme_modes[$modx->config['manager_theme_mode']]; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $css = 'media/style/' . $modx->config['manager_theme'] . '/style.css?v=' . $lastInstallTime; |
29 | 29 | |
30 | -if ($modx->config['manager_theme'] == 'default') { |
|
30 | +if ($modx->config['manager_theme'] == 'default') { |
|
31 | 31 | if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') |
32 | - && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { |
|
32 | + && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { |
|
33 | 33 | $files = array( |
34 | 34 | 'bootstrap' => MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css', |
35 | 35 | 'font-awesome' => MODX_MANAGER_PATH . 'media/style/common/font-awesome/css/font-awesome.min.css', |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'source' => 'manager', |
49 | 49 | 'theme' => $modx->config['manager_theme'] |
50 | 50 | )); |
51 | - switch (true) { |
|
51 | + switch (true) { |
|
52 | 52 | case empty($evtOut): |
53 | 53 | case is_array($evtOut) && count($evtOut) === 0: |
54 | 54 | break; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $css |
67 | 67 | ); |
68 | 68 | } |
69 | - if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
69 | + if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
70 | 70 | $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime; |
71 | 71 | } |
72 | 72 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | <script src="media/script/main.js"></script> |
125 | 125 | <script> |
126 | 126 | <?php |
127 | - if (isset($_REQUEST['r']) && preg_match('@^[0-9]+$@', $_REQUEST['r'])) { |
|
127 | + if (isset($_REQUEST['r']) && preg_match('@^[0-9]+$@', $_REQUEST['r'])) { |
|
128 | 128 | echo 'doRefresh(' . $_REQUEST['r'] . ");\n"; |
129 | 129 | } |
130 | 130 | ?> |
@@ -1,20 +1,22 @@ |
||
1 | 1 | <?php |
2 | 2 | // Determine upgradeability |
3 | 3 | $upgradeable = 0; |
4 | -if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { // Include the file so we can test its validity |
|
4 | +if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { |
|
5 | +// Include the file so we can test its validity |
|
5 | 6 | include_once $base_path . MGR_DIR . '/includes/config.inc.php'; |
6 | 7 | // We need to have all connection settings - tho prefix may be empty so we have to ignore it |
7 | 8 | if (isset($dbase)) { |
8 | - if (!$conn = @mysqli_connect($database_server, $database_user, $database_password)) |
|
9 | - $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2; |
|
10 | - elseif (!@mysqli_select_db($conn, trim($dbase, '`'))) |
|
11 | - $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2; |
|
12 | - else |
|
13 | - $upgradeable = 1; |
|
9 | + if (!$conn = @mysqli_connect($database_server, $database_user, $database_password)) { |
|
10 | + $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2; |
|
11 | + } elseif (!@mysqli_select_db($conn, trim($dbase, '`'))) { |
|
12 | + $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2; |
|
13 | + } else { |
|
14 | + $upgradeable = 1; |
|
15 | + } |
|
16 | + } else { |
|
17 | + $upgradeable = 2; |
|
18 | + } |
|
14 | 19 | } |
15 | - else |
|
16 | - $upgradeable = 2; |
|
17 | -} |
|
18 | 20 | |
19 | 21 | $ph['moduleName'] = $moduleName; |
20 | 22 | $ph['displayNew'] = ($upgradeable!=0) ? 'display:none;' : ''; |