@@ -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> |
@@ -134,8 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | //end webber |
| 136 | 136 | } |
| 137 | -} |
|
| 138 | -elseif ($alias) { |
|
| 137 | +} elseif ($alias) { |
|
| 139 | 138 | $alias = $modx->stripAlias($alias); |
| 140 | 139 | } |
| 141 | 140 | |
@@ -149,8 +148,7 @@ discard block |
||
| 149 | 148 | |
| 150 | 149 | if ($pub_date < $currentdate) { |
| 151 | 150 | $published = 1; |
| 152 | - } |
|
| 153 | - elseif ($pub_date > $currentdate) { |
|
| 151 | + } elseif ($pub_date > $currentdate) { |
|
| 154 | 152 | $published = 0; |
| 155 | 153 | } |
| 156 | 154 | } |
@@ -278,8 +276,7 @@ discard block |
||
| 278 | 276 | case 'new' : |
| 279 | 277 | |
| 280 | 278 | // invoke OnBeforeDocFormSave event |
| 281 | - switch($modx->config['docid_incrmnt_method']) |
|
| 282 | - { |
|
| 279 | + switch($modx->config['docid_incrmnt_method']) { |
|
| 283 | 280 | case '1': |
| 284 | 281 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
| 285 | 282 | $where = "T1.id IS NULL"; |
@@ -347,8 +344,9 @@ discard block |
||
| 347 | 344 | "alias_visible" => $aliasvisible |
| 348 | 345 | ); |
| 349 | 346 | |
| 350 | - if ($id != '') |
|
| 351 | - $dbInsert["id"] = $id; |
|
| 347 | + if ($id != '') { |
|
| 348 | + $dbInsert["id"] = $id; |
|
| 349 | + } |
|
| 352 | 350 | |
| 353 | 351 | $key = $modx->db->insert($dbInsert, $tbl_site_content); |
| 354 | 352 | |
@@ -424,11 +422,13 @@ discard block |
||
| 424 | 422 | // redirect/stay options |
| 425 | 423 | if ($_POST['stay'] != '') { |
| 426 | 424 | // weblink |
| 427 | - if ($_POST['mode'] == "72") |
|
| 428 | - $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent"; |
|
| 425 | + if ($_POST['mode'] == "72") { |
|
| 426 | + $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent"; |
|
| 427 | + } |
|
| 429 | 428 | // document |
| 430 | - if ($_POST['mode'] == "4") |
|
| 431 | - $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
|
| 429 | + if ($_POST['mode'] == "4") { |
|
| 430 | + $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
|
| 431 | + } |
|
| 432 | 432 | $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay']; |
| 433 | 433 | } else { |
| 434 | 434 | $header = "Location: index.php?a=3&id=$key&r=1"; |
@@ -489,10 +489,10 @@ discard block |
||
| 489 | 489 | if (!$was_published && $published) { |
| 490 | 490 | $publishedon = $currentdate; |
| 491 | 491 | $publishedby = $modx->getLoginUserID(); |
| 492 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 492 | + } elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 493 | 493 | $publishedon = $pub_date; |
| 494 | 494 | $publishedby = $modx->getLoginUserID(); |
| 495 | - }elseif ($was_published && !$published) { |
|
| 495 | + } elseif ($was_published && !$published) { |
|
| 496 | 496 | $publishedon = 0; |
| 497 | 497 | $publishedby = 0; |
| 498 | 498 | } else { |
@@ -548,7 +548,9 @@ discard block |
||
| 548 | 548 | $tvChanges = array(); |
| 549 | 549 | foreach ($tmplvars as $field => $value) { |
| 550 | 550 | if (!is_array($value)) { |
| 551 | - if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value]; |
|
| 551 | + if (isset($tvIds[$value])) { |
|
| 552 | + $tvDeletions[] = $tvIds[$value]; |
|
| 553 | + } |
|
| 552 | 554 | } else { |
| 553 | 555 | $tvId = $value[0]; |
| 554 | 556 | $tvVal = $value[1]; |
@@ -596,7 +598,9 @@ discard block |
||
| 596 | 598 | "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
| 597 | 599 | ); |
| 598 | 600 | $old_groups = array(); |
| 599 | - while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
|
| 601 | + while ($row = $modx->db->getRow($rs)) { |
|
| 602 | + $old_groups[$row['document_group']] = $row['id']; |
|
| 603 | + } |
|
| 600 | 604 | |
| 601 | 605 | // update the permissions in the database |
| 602 | 606 | $insertions = $deletions = array(); |
@@ -658,9 +662,9 @@ discard block |
||
| 658 | 662 | $modx->clearCache('full'); |
| 659 | 663 | } |
| 660 | 664 | |
| 661 | - if ($_POST['refresh_preview'] == '1') |
|
| 662 | - $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 663 | - else { |
|
| 665 | + if ($_POST['refresh_preview'] == '1') { |
|
| 666 | + $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 667 | + } else { |
|
| 664 | 668 | if ($_POST['stay'] != '2' && $id > 0) { |
| 665 | 669 | $modx->unlockElement(7, $id); |
| 666 | 670 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | $MODX_SITE_HOSTNAMES = MODX_SITE_HOSTNAMES; // Fix for PHP 5.4 |
| 3 | - if(empty($valid_hostnames) && empty($MODX_SITE_HOSTNAMES)) {
|
|
| 3 | + if(empty($valid_hostnames) && empty($MODX_SITE_HOSTNAMES)) { |
|
| 4 | 4 | $valid_hostnames = $_SERVER['HTTP_HOST']; |
| 5 | - } else {
|
|
| 5 | + } else { |
|
| 6 | 6 | $valid_hostnames = $MODX_SITE_HOSTNAMES; |
| 7 | 7 | } |
| 8 | 8 | ?> |
@@ -157,7 +157,9 @@ discard block |
||
| 157 | 157 | <th><?php echo $_lang['pwd_hash_algo_title'] ?><br><small>[(pwd_hash_algo)]</small></th> |
| 158 | 158 | <td> |
| 159 | 159 | <?php |
| 160 | -if(empty($pwd_hash_algo)) $phm['sel']['UNCRYPT'] = 1; |
|
| 160 | +if(empty($pwd_hash_algo)) { |
|
| 161 | + $phm['sel']['UNCRYPT'] = 1; |
|
| 162 | +} |
|
| 161 | 163 | $phm['e']['BLOWFISH_Y'] = $modx->manager->checkHashAlgorithm('BLOWFISH_Y') ? 0:1;
|
| 162 | 164 | $phm['e']['BLOWFISH_A'] = $modx->manager->checkHashAlgorithm('BLOWFISH_A') ? 0:1;
|
| 163 | 165 | $phm['e']['SHA512'] = $modx->manager->checkHashAlgorithm('SHA512') ? 0:1;
|
@@ -186,7 +188,9 @@ discard block |
||
| 186 | 188 | ?> |
| 187 | 189 | <?php |
| 188 | 190 | $gdAvailable = extension_loaded('gd');
|
| 189 | -if(!$gdAvailable) $use_captcha = 0; |
|
| 191 | +if(!$gdAvailable) { |
|
| 192 | + $use_captcha = 0; |
|
| 193 | +} |
|
| 190 | 194 | ?> |
| 191 | 195 | <tr> |
| 192 | 196 | <td nowrap class="warning"><?php echo $_lang['captcha_title'] ?><br><small>[(use_captcha)]</small></td> |
@@ -226,7 +230,9 @@ discard block |
||
| 226 | 230 | <?php |
| 227 | 231 | // invoke OnMiscSettingsRender event |
| 228 | 232 | $evtOut = $modx->invokeEvent('OnSecuritySettingsRender');
|
| 229 | - if(is_array($evtOut)) echo implode("",$evtOut);
|
|
| 233 | + if(is_array($evtOut)) { |
|
| 234 | + echo implode("",$evtOut); |
|
| 235 | + } |
|
| 230 | 236 | ?> |
| 231 | 237 | </td> |
| 232 | 238 | </tr> |
@@ -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> |
@@ -9,39 +9,27 @@ discard block |
||
| 9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
| 10 | 10 | unset($_POST); |
| 11 | 11 | |
| 12 | -if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
|
| 13 | -{ |
|
| 12 | +if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) { |
|
| 14 | 13 | $htaccess = $modx->config['base_path'] . '.htaccess'; |
| 15 | 14 | $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
| 16 | 15 | $dir = '/' . trim($modx->config['base_url'],'/'); |
| 17 | - if(is_file($htaccess)) |
|
| 18 | - { |
|
| 16 | + if(is_file($htaccess)) { |
|
| 19 | 17 | $_ = file_get_contents($htaccess); |
| 20 | - if(strpos($_,'RewriteBase')===false) |
|
| 21 | - { |
|
| 18 | + if(strpos($_,'RewriteBase')===false) { |
|
| 22 | 19 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 23 | - } |
|
| 24 | - elseif(is_writable($htaccess)) |
|
| 25 | - { |
|
| 20 | + } elseif(is_writable($htaccess)) { |
|
| 26 | 21 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
| 27 | - if(!@file_put_contents($htaccess,$_)) |
|
| 28 | - { |
|
| 22 | + if(!@file_put_contents($htaccess,$_)) { |
|
| 29 | 23 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 30 | 24 | } |
| 31 | 25 | } |
| 32 | - } |
|
| 33 | - elseif(is_file($sample_htaccess)) |
|
| 34 | - { |
|
| 35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
| 36 | - { |
|
| 26 | + } elseif(is_file($sample_htaccess)) { |
|
| 27 | + if(!@rename($sample_htaccess,$htaccess)) { |
|
| 37 | 28 | $warnings[] = $_lang["settings_friendlyurls_alert"]; |
| 38 | - } |
|
| 39 | - elseif($modx->config['base_url']!=='/') |
|
| 40 | - { |
|
| 29 | + } elseif($modx->config['base_url']!=='/') { |
|
| 41 | 30 | $_ = file_get_contents($htaccess); |
| 42 | 31 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
| 43 | - if(!@file_put_contents($htaccess,$_)) |
|
| 44 | - { |
|
| 32 | + if(!@file_put_contents($htaccess,$_)) { |
|
| 45 | 33 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
| 46 | 34 | } |
| 47 | 35 | } |
@@ -73,7 +61,7 @@ discard block |
||
| 73 | 61 | $v = htmlspecialchars($v); |
| 74 | 62 | break; |
| 75 | 63 | case 'settings_version':{ |
| 76 | - if($modx->getVersionData('version')!=$data['settings_version']){ |
|
| 64 | + if($modx->getVersionData('version')!=$data['settings_version']) { |
|
| 77 | 65 | $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
| 78 | 66 | $v = $modx->getVersionData('version'); |
| 79 | 67 | } |
@@ -134,7 +122,9 @@ discard block |
||
| 134 | 122 | |
| 135 | 123 | $modx->config[$k] = $v; |
| 136 | 124 | |
| 137 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 125 | + if(!empty($k)) { |
|
| 126 | + $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
| 127 | + } |
|
| 138 | 128 | } |
| 139 | 129 | |
| 140 | 130 | // Run a single query to save all the values |
@@ -148,8 +138,11 @@ discard block |
||
| 148 | 138 | $oldtemplate = (int)$data['old_template']; |
| 149 | 139 | $tbl = $modx->getFullTableName('site_content'); |
| 150 | 140 | $reset = $data['reset_template']; |
| 151 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 152 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 141 | + if($reset==1) { |
|
| 142 | + $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
| 143 | + } else if($reset==2) { |
|
| 144 | + $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
| 145 | + } |
|
| 153 | 146 | } |
| 154 | 147 | |
| 155 | 148 | // empty cache |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | // get user settings |
| 40 | 40 | $rs = $modx->db->select('*', $modx->getFullTableName('user_settings'), "user = '{$user}'"); |
| 41 | 41 | $usersettings = array(); |
| 42 | - while($row = $modx->db->getRow($rs)) $usersettings[$row['setting_name']] = $row['setting_value']; |
|
| 42 | + while($row = $modx->db->getRow($rs)) { |
|
| 43 | + $usersettings[$row['setting_name']] = $row['setting_value']; |
|
| 44 | + } |
|
| 43 | 45 | // manually extract so that user display settings are not overwritten |
| 44 | 46 | foreach($usersettings as $k => $v) { |
| 45 | 47 | if($k != 'manager_language' && $k != 'manager_theme') { |
@@ -763,13 +765,16 @@ discard block |
||
| 763 | 765 | |
| 764 | 766 | $groupsarray = array(); |
| 765 | 767 | |
| 766 | - if($modx->manager->action == '12') { // only do this bit if the user is being edited |
|
| 768 | + if($modx->manager->action == '12') { |
|
| 769 | +// only do this bit if the user is being edited |
|
| 767 | 770 | $rs = $modx->db->select('user_group', $modx->getFullTableName('member_groups'), "member='{$user}'"); |
| 768 | 771 | $groupsarray = $modx->db->getColumn('user_group', $rs); |
| 769 | 772 | } |
| 770 | 773 | // retain selected doc groups between post |
| 771 | 774 | if(is_array($_POST['user_groups'])) { |
| 772 | - foreach($_POST['user_groups'] as $n => $v) $groupsarray[] = $v; |
|
| 775 | + foreach($_POST['user_groups'] as $n => $v) { |
|
| 776 | + $groupsarray[] = $v; |
|
| 777 | + } |
|
| 773 | 778 | } |
| 774 | 779 | ?> |
| 775 | 780 | <div class="tab-page" id="tabAccess"> |
@@ -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 | ?> |
@@ -182,16 +182,18 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | -switch($installMode){ |
|
| 185 | +switch($installMode) { |
|
| 186 | 186 | case 0: |
| 187 | 187 | case 2: |
| 188 | 188 | $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
| 189 | 189 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 190 | 190 | $_POST['database_connection_charset'] = $database_charset; |
| 191 | - if(!empty($_POST['databaseloginpassword'])) |
|
| 192 | - $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
| 193 | - if(!empty($_POST['databaseloginname'])) |
|
| 194 | - $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
| 191 | + if(!empty($_POST['databaseloginpassword'])) { |
|
| 192 | + $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
| 193 | + } |
|
| 194 | + if(!empty($_POST['databaseloginname'])) { |
|
| 195 | + $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
| 196 | + } |
|
| 195 | 197 | break; |
| 196 | 198 | case 1: |
| 197 | 199 | include $base_path . MGR_DIR . '/includes/config.inc.php'; |
@@ -205,7 +207,9 @@ discard block |
||
| 205 | 207 | } |
| 206 | 208 | } |
| 207 | 209 | } |
| 208 | - if (empty ($database_collation)) $database_collation = 'utf8_general_ci'; |
|
| 210 | + if (empty ($database_collation)) { |
|
| 211 | + $database_collation = 'utf8_general_ci'; |
|
| 212 | + } |
|
| 209 | 213 | |
| 210 | 214 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 211 | 215 | if (!isset ($database_connection_charset) || empty ($database_connection_charset)) { |
@@ -214,7 +218,9 @@ discard block |
||
| 214 | 218 | |
| 215 | 219 | if (!isset ($database_connection_method) || empty ($database_connection_method)) { |
| 216 | 220 | $database_connection_method = 'SET CHARACTER SET'; |
| 217 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset); |
|
| 221 | + if (function_exists('mysqli_set_charset')) { |
|
| 222 | + mysqli_set_charset($conn, $database_connection_charset); |
|
| 223 | + } |
|
| 218 | 224 | } |
| 219 | 225 | if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) { |
| 220 | 226 | $database_connection_method = 'SET NAMES'; |
@@ -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;' : ''; |