@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class uploader { |
|
15 | +class uploader{ |
|
16 | 16 | |
17 | 17 | /** Release version */ |
18 | 18 | const VERSION = "2.54"; |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | |
73 | 73 | /** Next three properties are got from the current language file |
74 | 74 | * @var string */ |
75 | - protected $dateTimeFull; // Currently not used |
|
76 | - protected $dateTimeMid; // Currently not used |
|
75 | + protected $dateTimeFull; // Currently not used |
|
76 | + protected $dateTimeMid; // Currently not used |
|
77 | 77 | protected $dateTimeSmall; |
78 | 78 | |
79 | 79 | /** Contain Specified language labels |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | /** Magic method which allows read-only access to protected or private class properties |
105 | 105 | * @param string $property |
106 | 106 | * @return mixed */ |
107 | - public function __get($property) { |
|
107 | + public function __get($property){ |
|
108 | 108 | return property_exists($this, $property) ? $this->$property : null; |
109 | 109 | } |
110 | 110 | |
111 | - public function __construct($modx) { |
|
111 | + public function __construct($modx){ |
|
112 | 112 | |
113 | 113 | //MODX |
114 | 114 | try { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | // COOKIES INIT |
208 | 208 | $ip = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; |
209 | - $ip = '/^' . implode('\.', array($ip, $ip, $ip, $ip)) . '$/'; |
|
209 | + $ip = '/^'.implode('\.', array($ip, $ip, $ip, $ip)).'$/'; |
|
210 | 210 | if (preg_match($ip, $_SERVER['HTTP_HOST']) || |
211 | 211 | preg_match('/^[^\.]+$/', $_SERVER['HTTP_HOST']) |
212 | 212 | ) |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | ) { |
225 | 225 | list($unused, $protocol, $domain, $unused, $port, $path) = $patt; |
226 | 226 | $path = path::normalize($path); |
227 | - $this->config['uploadURL'] = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/$path"; |
|
227 | + $this->config['uploadURL'] = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/$path"; |
|
228 | 228 | $this->config['uploadDir'] = strlen($this->config['uploadDir']) |
229 | 229 | ? path::normalize($this->config['uploadDir']) |
230 | 230 | : path::url2fullPath("/$path"); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | foreach ($this->langInputNames as $key) |
268 | 268 | if (isset($this->get[$key]) && |
269 | 269 | preg_match('/^[a-z][a-z\._\-]*$/i', $this->get[$key]) && |
270 | - file_exists("lang/" . strtolower($this->get[$key]) . ".php") |
|
270 | + file_exists("lang/".strtolower($this->get[$key]).".php") |
|
271 | 271 | ) { |
272 | 272 | $this->lang = $this->get[$key]; |
273 | 273 | break; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $this->backMsg("Cannot read upload folder."); |
299 | 299 | } |
300 | 300 | |
301 | - public function upload() { |
|
301 | + public function upload(){ |
|
302 | 302 | $config = &$this->config; |
303 | 303 | $file = &$this->file; |
304 | 304 | $url = $message = ""; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | @mkdir(path::normalize($dir), $this->config['dirPerms'], true); |
330 | 330 | |
331 | 331 | $filename = $this->normalizeFilename($file['name']); |
332 | - $target = file::getInexistantFilename($dir . $filename); |
|
332 | + $target = file::getInexistantFilename($dir.$filename); |
|
333 | 333 | |
334 | 334 | if (!@move_uploaded_file($file['tmp_name'], $target) && |
335 | 335 | !@rename($file['tmp_name'], $target) && |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | $this->makeThumb($target); |
343 | 343 | $url = $this->typeURL; |
344 | 344 | if (isset($udir)) $url .= "/$udir"; |
345 | - $url .= "/" . basename($target); |
|
345 | + $url .= "/".basename($target); |
|
346 | 346 | if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)$/', $url, $patt)) { |
347 | 347 | list($unused, $protocol, $domain, $unused, $port, $path) = $patt; |
348 | - $base = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/"; |
|
349 | - $url = $base . path::urlPathEncode($path); |
|
348 | + $base = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/"; |
|
349 | + $url = $base.path::urlPathEncode($path); |
|
350 | 350 | } else |
351 | 351 | $url = path::urlPathEncode($url); |
352 | 352 | } |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | - protected function getTransaliasSettings() { |
|
368 | + protected function getTransaliasSettings(){ |
|
369 | 369 | global $modx; |
370 | 370 | |
371 | 371 | // Cleaning uploaded filename? |
372 | 372 | $setting = $modx->db->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1'); |
373 | - if ($modx->db->getValue($setting)>0) { |
|
373 | + if ($modx->db->getValue($setting) > 0) { |
|
374 | 374 | // Transalias plugin active? |
375 | 375 | $res = $modx->db->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0'); |
376 | 376 | if ($properties = $modx->db->getValue($res)) { |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | |
388 | - protected function normalizeFilename($filename) { |
|
388 | + protected function normalizeFilename($filename){ |
|
389 | 389 | if ($this->getTransaliasSettings()) { |
390 | 390 | $format = strrchr($filename, "."); |
391 | 391 | $filename = str_replace($format, "", $filename); |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | return $filename; |
395 | 395 | } |
396 | 396 | |
397 | - protected function normalizeDirname($dirname) { |
|
397 | + protected function normalizeDirname($dirname){ |
|
398 | 398 | return $this->modx->stripAlias($dirname); |
399 | 399 | } |
400 | 400 | |
401 | - protected function checkUploadedFile(array $aFile=null) { |
|
401 | + protected function checkUploadedFile(array $aFile = null){ |
|
402 | 402 | $config = &$this->config; |
403 | 403 | $file = ($aFile === null) ? $this->file : $aFile; |
404 | 404 | |
@@ -437,8 +437,7 @@ discard block |
||
437 | 437 | ($file['error'] == UPLOAD_ERR_NO_TMP_DIR) ? |
438 | 438 | $this->label("Missing a temporary folder.") : ( |
439 | 439 | ($file['error'] == UPLOAD_ERR_CANT_WRITE) ? |
440 | - $this->label("Failed to write file.") : |
|
441 | - $this->label("Unknown error.") |
|
440 | + $this->label("Failed to write file.") : $this->label("Unknown error.") |
|
442 | 441 | ))))); |
443 | 442 | |
444 | 443 | // HIDDEN FILENAMES CHECK |
@@ -473,14 +472,14 @@ discard block |
||
473 | 472 | |
474 | 473 | |
475 | 474 | // CHECK FOR MODX MAX FILE SIZE |
476 | - $actualfilesize=filesize($file['tmp_name']); |
|
475 | + $actualfilesize = filesize($file['tmp_name']); |
|
477 | 476 | if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize']) |
478 | 477 | return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)"); |
479 | 478 | |
480 | 479 | return true; |
481 | 480 | } |
482 | 481 | |
483 | - protected function checkInputDir($dir, $inclType=true, $existing=true) { |
|
482 | + protected function checkInputDir($dir, $inclType = true, $existing = true){ |
|
484 | 483 | $dir = path::normalize($dir); |
485 | 484 | if (substr($dir, 0, 1) == "/") |
486 | 485 | $dir = substr($dir, 1); |
@@ -506,7 +505,7 @@ discard block |
||
506 | 505 | return (is_dir($path) && is_readable($path)) ? $return : false; |
507 | 506 | } |
508 | 507 | |
509 | - protected function validateExtension($ext, $type) { |
|
508 | + protected function validateExtension($ext, $type){ |
|
510 | 509 | $ext = trim(strtolower($ext)); |
511 | 510 | if (!isset($this->types[$type])) |
512 | 511 | return false; |
@@ -531,17 +530,17 @@ discard block |
||
531 | 530 | return in_array($ext, $exts); |
532 | 531 | } |
533 | 532 | |
534 | - protected function getTypeFromPath($path) { |
|
533 | + protected function getTypeFromPath($path){ |
|
535 | 534 | return preg_match('/^([^\/]*)\/.*$/', $path, $patt) |
536 | 535 | ? $patt[1] : $path; |
537 | 536 | } |
538 | 537 | |
539 | - protected function removeTypeFromPath($path) { |
|
538 | + protected function removeTypeFromPath($path){ |
|
540 | 539 | return preg_match('/^[^\/]*\/(.*)$/', $path, $patt) |
541 | 540 | ? $patt[1] : ""; |
542 | 541 | } |
543 | 542 | |
544 | - protected function imageResize($image, $file=null) { |
|
543 | + protected function imageResize($image, $file = null){ |
|
545 | 544 | |
546 | 545 | if (!($image instanceof image)) { |
547 | 546 | $img = image::factory($this->imageDriver, $image); |
@@ -629,24 +628,24 @@ discard block |
||
629 | 628 | $img->watermark($this->config['watermark']['file'], $left, $top); |
630 | 629 | } |
631 | 630 | |
632 | - $options = array( 'file' => $file ); |
|
631 | + $options = array('file' => $file); |
|
633 | 632 | |
634 | - $type = exif_imagetype( $file ); |
|
633 | + $type = exif_imagetype($file); |
|
635 | 634 | |
636 | - switch ( $type ) { |
|
635 | + switch ($type) { |
|
637 | 636 | case IMAGETYPE_GIF: |
638 | - return $img->output( 'gif', $options ); |
|
637 | + return $img->output('gif', $options); |
|
639 | 638 | |
640 | 639 | case IMAGETYPE_PNG: |
641 | - return $img->output( 'png', $options ); |
|
640 | + return $img->output('png', $options); |
|
642 | 641 | |
643 | 642 | default: |
644 | - return $img->output( 'jpeg', array_merge( $options, array( 'quality' => $this->config['jpegQuality'] ) ) ); |
|
643 | + return $img->output('jpeg', array_merge($options, array('quality' => $this->config['jpegQuality']))); |
|
645 | 644 | } |
646 | 645 | |
647 | 646 | } |
648 | 647 | |
649 | - protected function makeThumb($file, $overwrite=true) { |
|
648 | + protected function makeThumb($file, $overwrite = true){ |
|
650 | 649 | $img = image::factory($this->imageDriver, $file); |
651 | 650 | |
652 | 651 | // Drop files which are not images |
@@ -654,7 +653,7 @@ discard block |
||
654 | 653 | return true; |
655 | 654 | |
656 | 655 | $thumb = substr($file, strlen($this->config['uploadDir'])); |
657 | - $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb; |
|
656 | + $thumb = $this->config['uploadDir']."/".$this->config['thumbsDir']."/".$thumb; |
|
658 | 657 | $thumb = path::normalize($thumb); |
659 | 658 | $thumbDir = dirname($thumb); |
660 | 659 | if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) |
@@ -677,15 +676,15 @@ discard block |
||
677 | 676 | if (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight'])) |
678 | 677 | return false; |
679 | 678 | |
680 | - if ( $this->imageDriver == 'gd' ) { |
|
681 | - $width = imagesx( $img->image ); |
|
682 | - $height = imagesy( $img->image ); |
|
683 | - $back = image::factory( $this->imageDriver, array( $width, $height ) ); |
|
684 | - $tile = image::factory( $this->imageDriver, __DIR__ . '/../themes/' . $this->config['theme'] . '/img/bg_transparent.png' ); |
|
679 | + if ($this->imageDriver == 'gd') { |
|
680 | + $width = imagesx($img->image); |
|
681 | + $height = imagesy($img->image); |
|
682 | + $back = image::factory($this->imageDriver, array($width, $height)); |
|
683 | + $tile = image::factory($this->imageDriver, __DIR__.'/../themes/'.$this->config['theme'].'/img/bg_transparent.png'); |
|
685 | 684 | |
686 | - imagesettile( $back->image, $tile->image ); |
|
687 | - imagefilledrectangle( $back->image, 0, 0, $width, $height, IMG_COLOR_TILED ); |
|
688 | - imagecopy( $back->image, $img->image, 0, 0, 0, 0, $width, $height ); |
|
685 | + imagesettile($back->image, $tile->image); |
|
686 | + imagefilledrectangle($back->image, 0, 0, $width, $height, IMG_COLOR_TILED); |
|
687 | + imagecopy($back->image, $img->image, 0, 0, 0, 0, $width, $height); |
|
689 | 688 | |
690 | 689 | $img = $back; |
691 | 690 | } |
@@ -697,7 +696,7 @@ discard block |
||
697 | 696 | )); |
698 | 697 | } |
699 | 698 | |
700 | - protected function localize($langCode) { |
|
699 | + protected function localize($langCode){ |
|
701 | 700 | require "lang/{$langCode}.php"; |
702 | 701 | setlocale(LC_ALL, $lang['_locale']); |
703 | 702 | $this->charset = $lang['_charset']; |
@@ -712,7 +711,7 @@ discard block |
||
712 | 711 | $this->labels = $lang; |
713 | 712 | } |
714 | 713 | |
715 | - protected function label($string, array $data=null) { |
|
714 | + protected function label($string, array $data = null){ |
|
716 | 715 | $return = isset($this->labels[$string]) ? $this->labels[$string] : $string; |
717 | 716 | if (is_array($data)) |
718 | 717 | foreach ($data as $key => $val) |
@@ -720,7 +719,7 @@ discard block |
||
720 | 719 | return $return; |
721 | 720 | } |
722 | 721 | |
723 | - protected function backMsg($message, array $data=null) { |
|
722 | + protected function backMsg($message, array $data = null){ |
|
724 | 723 | $message = $this->label($message, $data); |
725 | 724 | if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) |
726 | 725 | @unlink($this->file['tmp_name']); |
@@ -728,7 +727,7 @@ discard block |
||
728 | 727 | die; |
729 | 728 | } |
730 | 729 | |
731 | - protected function callBack($url, $message="") { |
|
730 | + protected function callBack($url, $message = ""){ |
|
732 | 731 | $message = text::jsValue($message); |
733 | 732 | $CKfuncNum = isset($this->opener['CKEditor']['funcNum']) |
734 | 733 | ? $this->opener['CKEditor']['funcNum'] : 0; |
@@ -769,7 +768,7 @@ discard block |
||
769 | 768 | |
770 | 769 | } |
771 | 770 | |
772 | - protected function get_htaccess() { |
|
771 | + protected function get_htaccess(){ |
|
773 | 772 | return "<IfModule mod_php4.c> |
774 | 773 | php_value engine off |
775 | 774 | </IfModule> |
@@ -1,2 +1,2 @@ |
||
1 | -<link href="css.php?type=<?php echo $this->type ?><?php echo ($this->cms ? "&cms={$this->cms}" : "" ) ?>" rel="stylesheet" type="text/css" /> |
|
1 | +<link href="css.php?type=<?php echo $this->type ?><?php echo ($this->cms ? "&cms={$this->cms}" : "") ?>" rel="stylesheet" type="text/css" /> |
|
2 | 2 | <link href="themes/<?php echo $this->config['theme'] ?>/style.css" rel="stylesheet" type="text/css" /> |
@@ -9,8 +9,8 @@ |
||
9 | 9 | |
10 | 10 | $lang = array( |
11 | 11 | |
12 | - '_locale' => "pt_BR.UTF-8", // UNIX localization code |
|
13 | - '_charset' => "utf-8", // Browser charset |
|
12 | + '_locale' => "pt_BR.UTF-8", // UNIX localization code |
|
13 | + '_charset' => "utf-8", // Browser charset |
|
14 | 14 | |
15 | 15 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
16 | 16 | '_dateTimeFull' => "%A, %e %B, %Y %H:%M", |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | $lang = array( |
8 | 8 | |
9 | - '_locale' => "de_DE.UTF-8", // UNIX localization code |
|
10 | - '_charset' => "utf-8", // Browser charset |
|
9 | + '_locale' => "de_DE.UTF-8", // UNIX localization code |
|
10 | + '_charset' => "utf-8", // Browser charset |
|
11 | 11 | |
12 | 12 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
13 | 13 | '_dateTimeFull' => "%A, %e.%B.%Y %I:%M %p", |
@@ -7,8 +7,8 @@ |
||
7 | 7 | |
8 | 8 | $lang = array( |
9 | 9 | |
10 | - '_locale' => "uk_UA.UTF-8", // UNIX localization code |
|
11 | - '_charset' => "utf-8", // Browser charset |
|
10 | + '_locale' => "uk_UA.UTF-8", // UNIX localization code |
|
11 | + '_charset' => "utf-8", // Browser charset |
|
12 | 12 | |
13 | 13 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
14 | 14 | '_dateTimeFull' => "%A, %e %B, %Y %H:%M", |
@@ -11,8 +11,8 @@ |
||
11 | 11 | |
12 | 12 | $lang = array( |
13 | 13 | |
14 | - '_locale' => "ja_JP.UTF-8", // UNIX localization code |
|
15 | - '_charset' => "utf-8", // Browser charset |
|
14 | + '_locale' => "ja_JP.UTF-8", // UNIX localization code |
|
15 | + '_charset' => "utf-8", // Browser charset |
|
16 | 16 | |
17 | 17 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
18 | 18 | '_dateTimeFull' => "%Y/%m/%d %H:%M", |
@@ -7,8 +7,8 @@ |
||
7 | 7 | |
8 | 8 | $lang = array( |
9 | 9 | |
10 | - '_locale' => "fr_FR.UTF-8", // UNIX localization code |
|
11 | - '_charset' => "utf-8", // Browser charset |
|
10 | + '_locale' => "fr_FR.UTF-8", // UNIX localization code |
|
11 | + '_charset' => "utf-8", // Browser charset |
|
12 | 12 | |
13 | 13 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
14 | 14 | '_dateTimeFull' => "%A %e %B %Y %H:%M", |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | $lang = array( |
8 | 8 | |
9 | - '_locale' => "he_IL.UTF-8", // UNIX localization code |
|
10 | - '_charset' => "utf-8", // Browser charset |
|
9 | + '_locale' => "he_IL.UTF-8", // UNIX localization code |
|
10 | + '_charset' => "utf-8", // Browser charset |
|
11 | 11 | |
12 | 12 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
13 | 13 | '_dateTimeFull' => "%H:%M %Y %B %e %A", |
@@ -5,8 +5,8 @@ |
||
5 | 5 | |
6 | 6 | $lang = array( |
7 | 7 | |
8 | - '_locale' => "ro_RO.UTF-8", // UNIX localization code |
|
9 | - '_charset' => "utf-8", // Browser charset |
|
8 | + '_locale' => "ro_RO.UTF-8", // UNIX localization code |
|
9 | + '_charset' => "utf-8", // Browser charset |
|
10 | 10 | |
11 | 11 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
12 | 12 | '_dateTimeFull' => "%A, %e %B, %Y %H:%M", |