| @@ -2,20 +2,20 @@ discard block | ||
| 2 | 2 | |
| 3 | 3 | // Implement similar functionality in PHP 5.2 or 5.3 | 
| 4 | 4 | // http://php.net/manual/class.recursivecallbackfilteriterator.php#110974 | 
| 5 | -if (! class_exists('RecursiveCallbackFilterIterator', false)) { | |
| 5 | +if (!class_exists('RecursiveCallbackFilterIterator', false)) { | |
| 6 | 6 |  	class RecursiveCallbackFilterIterator extends RecursiveFilterIterator { | 
| 7 | 7 | |
| 8 | -	    public function __construct ( RecursiveIterator $iterator, $callback ) { | |
| 8 | +	    public function __construct(RecursiveIterator $iterator, $callback) { | |
| 9 | 9 | $this->callback = $callback; | 
| 10 | 10 | parent::__construct($iterator); | 
| 11 | 11 | } | 
| 12 | 12 | |
| 13 | -	    public function accept () { | |
| 13 | +	    public function accept() { | |
| 14 | 14 | $callback = $this->callback; | 
| 15 | 15 | return $callback(parent::current(), parent::key(), parent::getInnerIterator()); | 
| 16 | 16 | } | 
| 17 | 17 | |
| 18 | -	    public function getChildren () { | |
| 18 | +	    public function getChildren() { | |
| 19 | 19 | return new self($this->getInnerIterator()->getChildren(), $this->callback); | 
| 20 | 20 | } | 
| 21 | 21 | } | 
| @@ -60,11 +60,11 @@ discard block | ||
| 60 | 60 | * @author Dmitry (dio) Levashov | 
| 61 | 61 | **/ | 
| 62 | 62 |  	public function __construct() { | 
| 63 | - $this->options['alias'] = ''; // alias to replace root dir name | |
| 64 | - $this->options['dirMode'] = 0755; // new dirs mode | |
| 65 | - $this->options['fileMode'] = 0644; // new files mode | |
| 66 | - $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) | |
| 67 | - $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) | |
| 63 | + $this->options['alias'] = ''; // alias to replace root dir name | |
| 64 | + $this->options['dirMode'] = 0755; // new dirs mode | |
| 65 | + $this->options['fileMode'] = 0644; // new files mode | |
| 66 | + $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) | |
| 67 | + $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) | |
| 68 | 68 | $this->options['rootCssClass'] = 'elfinder-navbar-root-local'; | 
| 69 | 69 | } | 
| 70 | 70 | |
| @@ -81,7 +81,7 @@ discard block | ||
| 81 | 81 |  	protected function init() { | 
| 82 | 82 | // Normalize directory separator for windows | 
| 83 | 83 |  		if (DIRECTORY_SEPARATOR !== '/') { | 
| 84 | -			foreach(array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) { | |
| 84 | +			foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) { | |
| 85 | 85 |  				if (!empty($this->options[$key])) { | 
| 86 | 86 |  					$this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]); | 
| 87 | 87 | } | 
| @@ -145,7 +145,7 @@ discard block | ||
| 145 | 145 | // if no thumbnails url - try detect it | 
| 146 | 146 |  		if ($root['read'] && !$this->tmbURL && $this->URL) { | 
| 147 | 147 |  			if (strpos($this->tmbPath, $this->root) === 0) { | 
| 148 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); | |
| 148 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); | |
| 149 | 149 |  				if (preg_match("|[^/?&=]$|", $this->tmbURL)) { | 
| 150 | 150 | $this->tmbURL .= '/'; | 
| 151 | 151 | } | 
| @@ -203,11 +203,11 @@ discard block | ||
| 203 | 203 |  		if ($mtime != $compare) { | 
| 204 | 204 | return $mtime; | 
| 205 | 205 | } | 
| 206 | -		$inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; | |
| 206 | +		$inotifywait = defined('ELFINER_INOTIFYWAIT_PATH') ? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; | |
| 207 | 207 | $path = escapeshellarg($path); | 
| 208 | 208 | $standby = max(1, intval($standby)); | 
| 209 | 209 | $cmd = $inotifywait.' '.$path.' -t '.$standby.' -e moved_to,moved_from,move,create,delete,delete_self'; | 
| 210 | - $this->procExec($cmd , $o, $r); | |
| 210 | + $this->procExec($cmd, $o, $r); | |
| 211 | 211 |  		if ($r === 0) { | 
| 212 | 212 | // changed | 
| 213 | 213 | clearstatcache(); | 
| @@ -264,7 +264,7 @@ discard block | ||
| 264 | 264 | * @author Dmitry (dio) Levashov | 
| 265 | 265 | **/ | 
| 266 | 266 |  	protected function _joinPath($dir, $name) { | 
| 267 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; | |
| 267 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; | |
| 268 | 268 | } | 
| 269 | 269 | |
| 270 | 270 | /** | 
| @@ -316,7 +316,7 @@ discard block | ||
| 316 | 316 | $comps = $new_comps; | 
| 317 | 317 |  		$path = implode('/', $comps); | 
| 318 | 318 |  		if ($initial_slashes) { | 
| 319 | -			$path = str_repeat('/', $initial_slashes) . $path; | |
| 319 | +			$path = str_repeat('/', $initial_slashes).$path; | |
| 320 | 320 | } | 
| 321 | 321 | |
| 322 | 322 |  		if ($changeSep) { | 
| @@ -387,7 +387,7 @@ discard block | ||
| 387 | 387 | **/ | 
| 388 | 388 |  	protected function _inpath($path, $parent) { | 
| 389 | 389 | $cwd = getcwd(); | 
| 390 | - $real_path = $this->getFullPath($path, $cwd); | |
| 390 | + $real_path = $this->getFullPath($path, $cwd); | |
| 391 | 391 | $real_parent = $this->getFullPath($parent, $cwd); | 
| 392 | 392 |  		if ($real_path && $real_parent) { | 
| 393 | 393 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; | 
| @@ -446,7 +446,7 @@ discard block | ||
| 446 | 446 | $stat = array(); | 
| 447 | 447 | return $stat; | 
| 448 | 448 |  				} else { | 
| 449 | - $stat['mime'] = 'symlink-broken'; | |
| 449 | + $stat['mime'] = 'symlink-broken'; | |
| 450 | 450 | $target = readlink($path); | 
| 451 | 451 | $lstat = lstat($path); | 
| 452 | 452 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); | 
| @@ -462,7 +462,7 @@ discard block | ||
| 462 | 462 | $fstat = stat($path); | 
| 463 | 463 | $uid = $fstat['uid']; | 
| 464 | 464 | $gid = $fstat['gid']; | 
| 465 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); | |
| 465 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); | |
| 466 | 466 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); | 
| 467 | 467 | } | 
| 468 | 468 | |
| @@ -472,8 +472,8 @@ discard block | ||
| 472 | 472 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); | 
| 473 | 473 | } | 
| 474 | 474 | //logical rights first | 
| 475 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; | |
| 476 | - $stat['write'] = is_writable($path)? null : false; | |
| 475 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; | |
| 476 | + $stat['write'] = is_writable($path) ? null : false; | |
| 477 | 477 | |
| 478 | 478 |  		if (is_null($stat['read'])) { | 
| 479 | 479 | $stat['size'] = $dir ? 0 : $size; | 
| @@ -546,7 +546,7 @@ discard block | ||
| 546 | 546 | $dirItr = new ParentIterator( | 
| 547 | 547 | new RecursiveDirectoryIterator($path, | 
| 548 | 548 | FilesystemIterator::SKIP_DOTS | | 
| 549 | -					(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')? | |
| 549 | +					(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ? | |
| 550 | 550 | RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0) | 
| 551 | 551 | ) | 
| 552 | 552 | ); | 
| @@ -554,8 +554,8 @@ discard block | ||
| 554 | 554 |  			if ($dirItr->hasChildren()) { | 
| 555 | 555 | $dirs = true; | 
| 556 | 556 | $name = $dirItr->getSubPathName(); | 
| 557 | -				while($name) { | |
| 558 | -					if (!$this->attr($path . DIRECTORY_SEPARATOR . $name, 'read', null, true)) { | |
| 557 | +				while ($name) { | |
| 558 | +					if (!$this->attr($path.DIRECTORY_SEPARATOR.$name, 'read', null, true)) { | |
| 559 | 559 | $dirs = false; | 
| 560 | 560 | $dirItr->next(); | 
| 561 | 561 | $name = $dirItr->getSubPathName(); | 
| @@ -645,7 +645,7 @@ discard block | ||
| 645 | 645 | $br = true; | 
| 646 | 646 |  						} else { | 
| 647 | 647 | $_path = $fpath; | 
| 648 | - $stat['mime'] = 'symlink-broken'; | |
| 648 | + $stat['mime'] = 'symlink-broken'; | |
| 649 | 649 | $target = readlink($_path); | 
| 650 | 650 | $lstat = lstat($_path); | 
| 651 | 651 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); | 
| @@ -670,13 +670,13 @@ discard block | ||
| 670 | 670 |  					if ($statOwner && !$linkreadable) { | 
| 671 | 671 | $uid = $file->getOwner(); | 
| 672 | 672 | $gid = $file->getGroup(); | 
| 673 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); | |
| 673 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); | |
| 674 | 674 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); | 
| 675 | 675 | } | 
| 676 | 676 | |
| 677 | 677 | //logical rights first | 
| 678 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; | |
| 679 | - $stat['write'] = $file->isWritable()? null : false; | |
| 678 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; | |
| 679 | + $stat['write'] = $file->isWritable() ? null : false; | |
| 680 | 680 | |
| 681 | 681 |  					if (is_null($stat['read'])) { | 
| 682 | 682 | $stat['size'] = $dir ? 0 : $size; | 
| @@ -692,7 +692,7 @@ discard block | ||
| 692 | 692 | |
| 693 | 693 |  		if ($cache) { | 
| 694 | 694 | $cache = $this->convEncOut($cache, false); | 
| 695 | -			foreach($cache as $d) { | |
| 695 | +			foreach ($cache as $d) { | |
| 696 | 696 | $this->updateCache($d[0], $d[1]); | 
| 697 | 697 | } | 
| 698 | 698 | } | 
| @@ -708,7 +708,7 @@ discard block | ||
| 708 | 708 | * @return resource|false | 
| 709 | 709 | * @author Dmitry (dio) Levashov | 
| 710 | 710 | **/ | 
| 711 | -	protected function _fopen($path, $mode='rb') { | |
| 711 | +	protected function _fopen($path, $mode = 'rb') { | |
| 712 | 712 | return @fopen($path, $mode); | 
| 713 | 713 | } | 
| 714 | 714 | |
| @@ -719,7 +719,7 @@ discard block | ||
| 719 | 719 | * @return bool | 
| 720 | 720 | * @author Dmitry (dio) Levashov | 
| 721 | 721 | **/ | 
| 722 | -	protected function _fclose($fp, $path='') { | |
| 722 | +	protected function _fclose($fp, $path = '') { | |
| 723 | 723 | return @fclose($fp); | 
| 724 | 724 | } | 
| 725 | 725 | |
| @@ -851,7 +851,7 @@ discard block | ||
| 851 | 851 | $path = $this->_joinPath($dir, $name); | 
| 852 | 852 | |
| 853 | 853 | $meta = stream_get_meta_data($fp); | 
| 854 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; | |
| 854 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; | |
| 855 | 855 |  		if ($uri && @is_file($uri)) { | 
| 856 | 856 | fclose($fp); | 
| 857 | 857 | $isCmdPaste = ($this->ARGS['cmd'] === 'paste'); | 
| @@ -915,7 +915,7 @@ discard block | ||
| 915 | 915 | * @return bool | 
| 916 | 916 | **/ | 
| 917 | 917 |  	protected function _chmod($path, $mode) { | 
| 918 | -		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); | |
| 918 | +		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); | |
| 919 | 919 | $ret = @chmod($path, $modeOct); | 
| 920 | 920 | $ret && clearstatcache(); | 
| 921 | 921 | return $ret; | 
| @@ -1033,7 +1033,7 @@ discard block | ||
| 1033 | 1033 | $src = $dir; | 
| 1034 | 1034 | $name = basename($path); | 
| 1035 | 1035 |  				if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { | 
| 1036 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); | |
| 1036 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); | |
| 1037 | 1037 | } | 
| 1038 | 1038 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; | 
| 1039 | 1039 |  				if (file_exists($test) || is_link($test)) { | 
| @@ -1042,9 +1042,9 @@ discard block | ||
| 1042 | 1042 | } | 
| 1043 | 1043 | |
| 1044 | 1044 |  			if ($name !== '') { | 
| 1045 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; | |
| 1045 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; | |
| 1046 | 1046 | |
| 1047 | -				if (! @rename($src, $result)) { | |
| 1047 | +				if (!@rename($src, $result)) { | |
| 1048 | 1048 | $this->delTree($dir); | 
| 1049 | 1049 | return false; | 
| 1050 | 1050 | } | 
| @@ -1052,7 +1052,7 @@ discard block | ||
| 1052 | 1052 | $dstDir = dirname($path); | 
| 1053 | 1053 | $res = false; | 
| 1054 | 1054 | $result = array(); | 
| 1055 | -				foreach($ls as $name) { | |
| 1055 | +				foreach ($ls as $name) { | |
| 1056 | 1056 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; | 
| 1057 | 1057 |  					if (is_dir($target)) { | 
| 1058 | 1058 | $this->delTree($target); | 
| @@ -1138,7 +1138,7 @@ discard block | ||
| 1138 | 1138 | new RecursiveDirectoryIterator($path, | 
| 1139 | 1139 | FilesystemIterator::KEY_AS_PATHNAME | | 
| 1140 | 1140 | FilesystemIterator::SKIP_DOTS | | 
| 1141 | -						(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')? | |
| 1141 | +						(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ? | |
| 1142 | 1142 | RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0) | 
| 1143 | 1143 | ), | 
| 1144 | 1144 | array($this, 'localFileSystemSearchIteratorFilter') | 
| @@ -1160,7 +1160,7 @@ discard block | ||
| 1160 | 1160 | $result = array(); | 
| 1161 | 1161 | |
| 1162 | 1162 |  		if ($match) { | 
| 1163 | -			foreach($match as $p) { | |
| 1163 | +			foreach ($match as $p) { | |
| 1164 | 1164 | $stat = $this->stat($p); | 
| 1165 | 1165 | |
| 1166 | 1166 |  				if (!$stat) { // invalid links | 
| @@ -1177,7 +1177,7 @@ discard block | ||
| 1177 | 1177 | $stat['path'] = $this->path($stat['hash']); | 
| 1178 | 1178 |  					if ($this->URL && !isset($stat['url'])) { | 
| 1179 | 1179 | $path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1)); | 
| 1180 | - $stat['url'] = $this->URL . $path; | |
| 1180 | + $stat['url'] = $this->URL.$path; | |
| 1181 | 1181 | } | 
| 1182 | 1182 | |
| 1183 | 1183 | $result[] = $stat; | 
| @@ -1192,9 +1192,9 @@ discard block | ||
| 1192 | 1192 | |
| 1193 | 1193 |  	public function localFileSystemSearchIteratorFilter($file, $key, $iterator) { | 
| 1194 | 1194 |  		if ($iterator->hasChildren()) { | 
| 1195 | - return (bool)$this->attr($key, 'read', null, true); | |
| 1195 | + return (bool) $this->attr($key, 'read', null, true); | |
| 1196 | 1196 | } | 
| 1197 | - return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false)? false : true; | |
| 1197 | + return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false) ? false : true; | |
| 1198 | 1198 | } | 
| 1199 | 1199 | |
| 1200 | 1200 | } // END class | 
| @@ -301,7 +301,7 @@ discard block | ||
| 301 | 301 | 'utf8fix' => false, | 
| 302 | 302 | // й ё Й Ё Ø Å | 
| 303 | 303 |  		'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"), | 
| 304 | -		'utf8replace'  => array("\u0439",        "\u0451",       "\u0419",       "\u0401",       "\u00d8", "\u00c5") | |
| 304 | +		'utf8replace'  => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") | |
| 305 | 305 | ); | 
| 306 | 306 | |
| 307 | 307 | /** | 
| @@ -604,7 +604,7 @@ discard block | ||
| 604 | 604 | **/ | 
| 605 | 605 |  	protected function configure() { | 
| 606 | 606 | // set ARGS | 
| 607 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; | |
| 607 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; | |
| 608 | 608 | // set thumbnails path | 
| 609 | 609 | $path = $this->options['tmbPath']; | 
| 610 | 610 |  		if ($path) { | 
| @@ -635,7 +635,7 @@ discard block | ||
| 635 | 635 | |
| 636 | 636 | // check 'statOwner' for command `chmod` | 
| 637 | 637 |  		if (empty($this->options['statOwner'])) { | 
| 638 | - $this->disabled[] ='chmod'; | |
| 638 | + $this->disabled[] = 'chmod'; | |
| 639 | 639 | } | 
| 640 | 640 | |
| 641 | 641 | // check 'mimeMap' | 
| @@ -766,7 +766,7 @@ discard block | ||
| 766 | 766 | **/ | 
| 767 | 767 |  	public function mount(array $opts) { | 
| 768 | 768 |  		if (!isset($opts['path']) || $opts['path'] === '') { | 
| 769 | -			return $this->setError('Path undefined.');; | |
| 769 | +			return $this->setError('Path undefined.'); ; | |
| 770 | 770 | } | 
| 771 | 771 | |
| 772 | 772 | $this->options = array_merge($this->options, $opts); | 
| @@ -785,14 +785,14 @@ discard block | ||
| 785 | 785 | $argInit = !empty($this->ARGS['init']); | 
| 786 | 786 | |
| 787 | 787 | // session cache | 
| 788 | -		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { | |
| 788 | +		if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { | |
| 789 | 789 | $_SESSION[elFinder::$sessionCacheKey][$this->id] = array(); | 
| 790 | 790 | } | 
| 791 | 791 | $this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id]; | 
| 792 | 792 | |
| 793 | 793 | // default file attribute | 
| 794 | 794 | $this->defaults = array( | 
| 795 | - 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, | |
| 795 | + 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, | |
| 796 | 796 | 'write' => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true, | 
| 797 | 797 | 'locked' => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false, | 
| 798 | 798 | 'hidden' => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false | 
| @@ -819,8 +819,8 @@ discard block | ||
| 819 | 819 | $this->access = $this->options['accessControl']; | 
| 820 | 820 | } | 
| 821 | 821 | |
| 822 | -		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y')); | |
| 823 | - $this->yesterday = $this->today-86400; | |
| 822 | +		$this->today     = mktime(0, 0, 0, date('m'), date('d'), date('Y')); | |
| 823 | + $this->yesterday = $this->today - 86400; | |
| 824 | 824 | |
| 825 | 825 | // debug($this->attributes); | 
| 826 | 826 |  		if (!$this->init()) { | 
| @@ -919,7 +919,7 @@ discard block | ||
| 919 | 919 |  				foreach ($mimecf as $line_num => $line) { | 
| 920 | 920 |  					if (!preg_match('/^\s*#/', $line)) { | 
| 921 | 921 |  						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); | 
| 922 | -						for ($i = 1, $size = count($mime); $i < $size ; $i++) { | |
| 922 | +						for ($i = 1, $size = count($mime); $i < $size; $i++) { | |
| 923 | 923 |  							if (!isset(self::$mimetypes[$mime[$i]])) { | 
| 924 | 924 | self::$mimetypes[$mime[$i]] = $mime[0]; | 
| 925 | 925 | } | 
| @@ -948,7 +948,7 @@ discard block | ||
| 948 | 948 | |
| 949 | 949 |  		if ($root['read']) { | 
| 950 | 950 | // check startPath - path to open by default instead of root | 
| 951 | - $startPath = $this->options['startPath']? $this->normpathCE($this->options['startPath']) : ''; | |
| 951 | + $startPath = $this->options['startPath'] ? $this->normpathCE($this->options['startPath']) : ''; | |
| 952 | 952 |  			if ($startPath) { | 
| 953 | 953 | $start = $this->stat($startPath); | 
| 954 | 954 | if (!empty($start) | 
| @@ -972,8 +972,8 @@ discard block | ||
| 972 | 972 | 'read' => false | 
| 973 | 973 | )); | 
| 974 | 974 | } | 
| 975 | - $this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1; | |
| 976 | - $this->tmbSize = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48; | |
| 975 | + $this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1; | |
| 976 | + $this->tmbSize = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48; | |
| 977 | 977 | $this->URL = $this->options['URL']; | 
| 978 | 978 |  		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) { | 
| 979 | 979 | $this->URL .= '/'; | 
| @@ -1027,7 +1027,7 @@ discard block | ||
| 1027 | 1027 | |
| 1028 | 1028 | // fix sync interval | 
| 1029 | 1029 |  		if ($this->options['syncMinMs'] !== 0) { | 
| 1030 | - $this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs']? 'tsPlSleep' : 'lsPlSleep'] * 1000, intval($this->options['syncMinMs'])); | |
| 1030 | + $this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs'] ? 'tsPlSleep' : 'lsPlSleep']*1000, intval($this->options['syncMinMs'])); | |
| 1031 | 1031 | } | 
| 1032 | 1032 | |
| 1033 | 1033 | return $this->mounted = true; | 
| @@ -1131,7 +1131,7 @@ discard block | ||
| 1131 | 1131 |  	public function options($hash) { | 
| 1132 | 1132 | $create = $createext = array(); | 
| 1133 | 1133 |  		if (isset($this->archivers['create']) && is_array($this->archivers['create'])) { | 
| 1134 | -			foreach($this->archivers['create'] as $m => $v) { | |
| 1134 | +			foreach ($this->archivers['create'] as $m => $v) { | |
| 1135 | 1135 | $create[] = $m; | 
| 1136 | 1136 | $createext[$m] = $v['ext']; | 
| 1137 | 1137 | } | 
| @@ -1152,7 +1152,7 @@ discard block | ||
| 1152 | 1152 | 'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(), | 
| 1153 | 1153 | 'createext' => $createext | 
| 1154 | 1154 | ), | 
| 1155 | - 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(), | |
| 1155 | + 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(), | |
| 1156 | 1156 | 'syncChkAsTs' => intval($this->options['syncChkAsTs']), | 
| 1157 | 1157 | 'syncMinMs' => intval($this->options['syncMinMs']) | 
| 1158 | 1158 | ); | 
| @@ -1166,7 +1166,7 @@ discard block | ||
| 1166 | 1166 | * @author Naoki Sawada | 
| 1167 | 1167 | */ | 
| 1168 | 1168 |  	public function getOption($name) { | 
| 1169 | - return isset($this->options[$name])? $this->options[$name] : null; | |
| 1169 | + return isset($this->options[$name]) ? $this->options[$name] : null; | |
| 1170 | 1170 | } | 
| 1171 | 1171 | |
| 1172 | 1172 | /** | 
| @@ -1178,7 +1178,7 @@ discard block | ||
| 1178 | 1178 | */ | 
| 1179 | 1179 |  	public function getOptionsPlugin($name = '') { | 
| 1180 | 1180 |  		if ($name) { | 
| 1181 | - return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array(); | |
| 1181 | + return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array(); | |
| 1182 | 1182 |  		} else { | 
| 1183 | 1183 | return $this->options['plugin']; | 
| 1184 | 1184 | } | 
| @@ -1309,7 +1309,7 @@ discard block | ||
| 1309 | 1309 | $file = $this->stat($path); | 
| 1310 | 1310 | |
| 1311 | 1311 |  		if ($isRoot) { | 
| 1312 | - $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(); | |
| 1312 | + $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(); | |
| 1313 | 1313 | $file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON | 
| 1314 | 1314 |  			if (isset($this->options['netkey'])) { | 
| 1315 | 1315 | $file['netkey'] = $this->options['netkey']; | 
| @@ -1327,7 +1327,7 @@ discard block | ||
| 1327 | 1327 | * @return array|false | 
| 1328 | 1328 | * @author Dmitry (dio) Levashov | 
| 1329 | 1329 | **/ | 
| 1330 | -	public function dir($hash, $resolveLink=false) { | |
| 1330 | +	public function dir($hash, $resolveLink = false) { | |
| 1331 | 1331 |  		if (($dir = $this->file($hash)) == false) { | 
| 1332 | 1332 | return $this->setError(elFinder::ERROR_DIR_NOT_FOUND); | 
| 1333 | 1333 | } | 
| @@ -1391,14 +1391,14 @@ discard block | ||
| 1391 | 1391 | * @return array|false | 
| 1392 | 1392 | * @author Dmitry (dio) Levashov | 
| 1393 | 1393 | **/ | 
| 1394 | -	public function tree($hash='', $deep=0, $exclude='') { | |
| 1394 | +	public function tree($hash = '', $deep = 0, $exclude = '') { | |
| 1395 | 1395 | $path = $hash ? $this->decode($hash) : $this->root; | 
| 1396 | 1396 | |
| 1397 | 1397 |  		if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') { | 
| 1398 | 1398 | return false; | 
| 1399 | 1399 | } | 
| 1400 | 1400 | |
| 1401 | - $dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null); | |
| 1401 | + $dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null); | |
| 1402 | 1402 | array_unshift($dirs, $dir); | 
| 1403 | 1403 | return $dirs; | 
| 1404 | 1404 | } | 
| @@ -1628,7 +1628,7 @@ discard block | ||
| 1628 | 1628 | * @return array|false | 
| 1629 | 1629 | * @author Dmitry (dio) Levashov | 
| 1630 | 1630 | **/ | 
| 1631 | -	public function duplicate($hash, $suffix='copy') { | |
| 1631 | +	public function duplicate($hash, $suffix = 'copy') { | |
| 1632 | 1632 |  		if ($this->commandDisabled('duplicate')) { | 
| 1633 | 1633 | return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED); | 
| 1634 | 1634 | } | 
| @@ -1704,7 +1704,7 @@ discard block | ||
| 1704 | 1704 | |
| 1705 | 1705 |  		if ($file) { // file exists | 
| 1706 | 1706 | // check POST data `overwrite` for 3rd party uploader | 
| 1707 | - $overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite']; | |
| 1707 | + $overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite']; | |
| 1708 | 1708 |  			if ($overwrite) { | 
| 1709 | 1709 |  				if (!$file['write']) { | 
| 1710 | 1710 | return $this->setError(elFinder::ERROR_PERM_DENIED); | 
| @@ -1775,7 +1775,7 @@ discard block | ||
| 1775 | 1775 |  		if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) { | 
| 1776 | 1776 | return $rmSrc | 
| 1777 | 1777 | ? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test)) | 
| 1778 | - : $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); | |
| 1778 | + : $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); | |
| 1779 | 1779 | } | 
| 1780 | 1780 | |
| 1781 | 1781 | $test = $this->joinPathCE($destination, $name); | 
| @@ -1938,7 +1938,7 @@ discard block | ||
| 1938 | 1938 | return $this->setError(elFinder::ERROR_PERM_DENIED); | 
| 1939 | 1939 | } | 
| 1940 | 1940 | $this->clearcache(); | 
| 1941 | - $this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir; | |
| 1941 | + $this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir; | |
| 1942 | 1942 | |
| 1943 | 1943 |  		if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) { | 
| 1944 | 1944 |  			if (is_array($path)) { | 
| @@ -1996,9 +1996,9 @@ discard block | ||
| 1996 | 1996 |  		if ($name === '') { | 
| 1997 | 1997 | $name = count($files) == 1 ? $files[0] : 'Archive'; | 
| 1998 | 1998 |  		} else { | 
| 1999 | -			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name)); | |
| 1999 | +			$name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name)); | |
| 2000 | 2000 | } | 
| 2001 | - $name .='.' . $archiver['ext']; | |
| 2001 | + $name .= '.'.$archiver['ext']; | |
| 2002 | 2002 | $name = $this->uniqueName($dir, $name, ''); | 
| 2003 | 2003 | $this->clearcache(); | 
| 2004 | 2004 | return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false; | 
| @@ -2037,7 +2037,7 @@ discard block | ||
| 2037 | 2037 | |
| 2038 | 2038 | $path = $this->decode($hash); | 
| 2039 | 2039 | |
| 2040 | - $work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path); | |
| 2040 | + $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path); | |
| 2041 | 2041 | |
| 2042 | 2042 |  		if (!$work_path || !is_writable($work_path)) { | 
| 2043 | 2043 |  			if ($work_path && $path !== $work_path && is_file($work_path)) { | 
| @@ -2052,7 +2052,7 @@ discard block | ||
| 2052 | 2052 | } | 
| 2053 | 2053 | } | 
| 2054 | 2054 | |
| 2055 | -		switch($mode) { | |
| 2055 | +		switch ($mode) { | |
| 2056 | 2056 | |
| 2057 | 2057 | case 'propresize': | 
| 2058 | 2058 | $result = $this->imgResize($work_path, $width, $height, true, true, null, $jpgQuality); | 
| @@ -2149,7 +2149,7 @@ discard block | ||
| 2149 | 2149 | $this->searchStart = time(); | 
| 2150 | 2150 |  		return ($q === '' || $this->commandDisabled('search')) | 
| 2151 | 2151 | ? array() | 
| 2152 | - : $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes); | |
| 2152 | + : $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes); | |
| 2153 | 2153 | } | 
| 2154 | 2154 | |
| 2155 | 2155 | /** | 
| @@ -2221,9 +2221,9 @@ discard block | ||
| 2221 | 2221 | $path = ltrim($path, $this->separator); | 
| 2222 | 2222 | $dirs = explode($this->separator, $path); | 
| 2223 | 2223 | array_pop($dirs); | 
| 2224 | -		foreach($dirs as $dir) { | |
| 2224 | +		foreach ($dirs as $dir) { | |
| 2225 | 2225 | $targetPath = $this->joinPathCE($base, $dir); | 
| 2226 | -			if (! $_realpath = $this->realpath($this->encode($targetPath))) { | |
| 2226 | +			if (!$_realpath = $this->realpath($this->encode($targetPath))) { | |
| 2227 | 2227 |  				if ($stat = $this->mkdir($targetHash, $dir)) { | 
| 2228 | 2228 | $result['added'][] = $stat; | 
| 2229 | 2229 | $targetHash = $stat['hash']; | 
| @@ -2290,7 +2290,7 @@ discard block | ||
| 2290 | 2290 | * @author Naoki Sawada | 
| 2291 | 2291 | **/ | 
| 2292 | 2292 |  	protected function dirnameCE($path) { | 
| 2293 | - return (!$this->encoding)? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); | |
| 2293 | + return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); | |
| 2294 | 2294 | } | 
| 2295 | 2295 | |
| 2296 | 2296 | /** | 
| @@ -2301,7 +2301,7 @@ discard block | ||
| 2301 | 2301 | * @author Naoki Sawada | 
| 2302 | 2302 | **/ | 
| 2303 | 2303 |  	protected function basenameCE($path) { | 
| 2304 | - return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); | |
| 2304 | + return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); | |
| 2305 | 2305 | } | 
| 2306 | 2306 | |
| 2307 | 2307 | /** | 
| @@ -2314,7 +2314,7 @@ discard block | ||
| 2314 | 2314 | * @author Naoki Sawada | 
| 2315 | 2315 | **/ | 
| 2316 | 2316 |  	protected function joinPathCE($dir, $name) { | 
| 2317 | - return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); | |
| 2317 | + return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); | |
| 2318 | 2318 | } | 
| 2319 | 2319 | |
| 2320 | 2320 | /** | 
| @@ -2325,7 +2325,7 @@ discard block | ||
| 2325 | 2325 | * @author Naoki Sawada | 
| 2326 | 2326 | **/ | 
| 2327 | 2327 |  	protected function normpathCE($path) { | 
| 2328 | - return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); | |
| 2328 | + return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); | |
| 2329 | 2329 | } | 
| 2330 | 2330 | |
| 2331 | 2331 | /** | 
| @@ -2336,7 +2336,7 @@ discard block | ||
| 2336 | 2336 | * @author Naoki Sawada | 
| 2337 | 2337 | **/ | 
| 2338 | 2338 |  	protected function relpathCE($path) { | 
| 2339 | - return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); | |
| 2339 | + return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); | |
| 2340 | 2340 | } | 
| 2341 | 2341 | |
| 2342 | 2342 | /** | 
| @@ -2347,7 +2347,7 @@ discard block | ||
| 2347 | 2347 | * @author Naoki Sawada | 
| 2348 | 2348 | **/ | 
| 2349 | 2349 |  	protected function abspathCE($path) { | 
| 2350 | - return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path))); | |
| 2350 | + return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path))); | |
| 2351 | 2351 | } | 
| 2352 | 2352 | |
| 2353 | 2353 | /** | 
| @@ -2359,7 +2359,7 @@ discard block | ||
| 2359 | 2359 | * @author Naoki Sawada | 
| 2360 | 2360 | **/ | 
| 2361 | 2361 |  	protected function inpathCE($path, $parent) { | 
| 2362 | - return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); | |
| 2362 | + return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); | |
| 2363 | 2363 | } | 
| 2364 | 2364 | |
| 2365 | 2365 | /** | 
| @@ -2370,8 +2370,8 @@ discard block | ||
| 2370 | 2370 | * @return resource|false | 
| 2371 | 2371 | * @author Naoki Sawada | 
| 2372 | 2372 | **/ | 
| 2373 | -	protected function fopenCE($path, $mode='rb') { | |
| 2374 | - return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); | |
| 2373 | +	protected function fopenCE($path, $mode = 'rb') { | |
| 2374 | + return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); | |
| 2375 | 2375 | } | 
| 2376 | 2376 | |
| 2377 | 2377 | /** | 
| @@ -2382,8 +2382,8 @@ discard block | ||
| 2382 | 2382 | * @return bool | 
| 2383 | 2383 | * @author Naoki Sawada | 
| 2384 | 2384 | **/ | 
| 2385 | -	protected function fcloseCE($fp, $path='') { | |
| 2386 | - return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); | |
| 2385 | +	protected function fcloseCE($fp, $path = '') { | |
| 2386 | + return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); | |
| 2387 | 2387 | } | 
| 2388 | 2388 | |
| 2389 | 2389 | /** | 
| @@ -2398,7 +2398,7 @@ discard block | ||
| 2398 | 2398 | * @author Naoki Sawada | 
| 2399 | 2399 | **/ | 
| 2400 | 2400 |  	protected function saveCE($fp, $dir, $name, $stat) { | 
| 2401 | - return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); | |
| 2401 | + return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); | |
| 2402 | 2402 | } | 
| 2403 | 2403 | |
| 2404 | 2404 | /** | 
| @@ -2410,7 +2410,7 @@ discard block | ||
| 2410 | 2410 | **/ | 
| 2411 | 2411 |  	protected function subdirsCE($path) { | 
| 2412 | 2412 |  		if (!isset($this->subdirsCache[$path])) { | 
| 2413 | - $this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); | |
| 2413 | + $this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); | |
| 2414 | 2414 | } | 
| 2415 | 2415 | return $this->subdirsCache[$path]; | 
| 2416 | 2416 | } | 
| @@ -2423,7 +2423,7 @@ discard block | ||
| 2423 | 2423 | * @author Naoki Sawada | 
| 2424 | 2424 | **/ | 
| 2425 | 2425 |  	protected function scandirCE($path) { | 
| 2426 | - return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); | |
| 2426 | + return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); | |
| 2427 | 2427 | } | 
| 2428 | 2428 | |
| 2429 | 2429 | /** | 
| @@ -2436,7 +2436,7 @@ discard block | ||
| 2436 | 2436 | * @author Naoki Sawada | 
| 2437 | 2437 | **/ | 
| 2438 | 2438 |  	protected function symlinkCE($source, $targetDir, $name) { | 
| 2439 | - return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); | |
| 2439 | + return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); | |
| 2440 | 2440 | } | 
| 2441 | 2441 | |
| 2442 | 2442 | /***************** paths *******************/ | 
| @@ -2455,7 +2455,7 @@ discard block | ||
| 2455 | 2455 | // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root | 
| 2456 | 2456 | $p = $this->relpathCE($path); | 
| 2457 | 2457 | // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt | 
| 2458 | -			if ($p === '')	{ | |
| 2458 | +			if ($p === '') { | |
| 2459 | 2459 | $p = DIRECTORY_SEPARATOR; | 
| 2460 | 2460 | } | 
| 2461 | 2461 | |
| @@ -2488,7 +2488,7 @@ discard block | ||
| 2488 | 2488 | // TODO uncrypt hash and return path | 
| 2489 | 2489 | $path = $this->uncrypt($h); | 
| 2490 | 2490 | // append ROOT to path after it was cut in encode | 
| 2491 | - return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); | |
| 2491 | + return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); | |
| 2492 | 2492 | } | 
| 2493 | 2493 | } | 
| 2494 | 2494 | |
| @@ -2548,21 +2548,21 @@ discard block | ||
| 2548 | 2548 | * @author Dmitry (dio) Levashov | 
| 2549 | 2549 | **/ | 
| 2550 | 2550 |  	public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) { | 
| 2551 | - $ext = ''; | |
| 2551 | + $ext = ''; | |
| 2552 | 2552 | |
| 2553 | 2553 |  		if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { | 
| 2554 | 2554 | $ext = '.'.$m[1]; | 
| 2555 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); | |
| 2555 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); | |
| 2556 | 2556 | } | 
| 2557 | 2557 | |
| 2558 | 2558 |  		if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) { | 
| 2559 | - $i = (int)$m[2]; | |
| 2560 | - $name = substr($name, 0, strlen($name)-strlen($m[2])); | |
| 2559 | + $i = (int) $m[2]; | |
| 2560 | + $name = substr($name, 0, strlen($name) - strlen($m[2])); | |
| 2561 | 2561 |  		} else { | 
| 2562 | 2562 | $i = $start; | 
| 2563 | 2563 | $name .= $suffix; | 
| 2564 | 2564 | } | 
| 2565 | - $max = $i+100000; | |
| 2565 | + $max = $i + 100000; | |
| 2566 | 2566 | |
| 2567 | 2567 |  		while ($i <= $max) { | 
| 2568 | 2568 | $n = $name.($i > 0 ? $i : '').$ext; | 
| @@ -2586,7 +2586,7 @@ discard block | ||
| 2586 | 2586 | * @author Naoki Sawada | 
| 2587 | 2587 | */ | 
| 2588 | 2588 |  	public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') { | 
| 2589 | - return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); | |
| 2589 | + return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); | |
| 2590 | 2590 | } | 
| 2591 | 2591 | |
| 2592 | 2592 | /** | 
| @@ -2599,7 +2599,7 @@ discard block | ||
| 2599 | 2599 | * @author Naoki Sawada | 
| 2600 | 2600 | */ | 
| 2601 | 2601 |  	public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') { | 
| 2602 | - return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); | |
| 2602 | + return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); | |
| 2603 | 2603 | } | 
| 2604 | 2604 | |
| 2605 | 2605 | /** | 
| @@ -2619,7 +2619,7 @@ discard block | ||
| 2619 | 2619 | } | 
| 2620 | 2620 |  			if (is_array($var)) { | 
| 2621 | 2621 | $_ret = array(); | 
| 2622 | -				foreach($var as $_k => $_v) { | |
| 2622 | +				foreach ($var as $_k => $_v) { | |
| 2623 | 2623 | $_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_'); | 
| 2624 | 2624 | } | 
| 2625 | 2625 | $var = $_ret; | 
| @@ -2631,7 +2631,7 @@ discard block | ||
| 2631 | 2631 |  						$_var = str_replace('?', $unknown, $_var); | 
| 2632 | 2632 | } | 
| 2633 | 2633 | } | 
| 2634 | -				if  ($_var !== false) { | |
| 2634 | +				if ($_var !== false) { | |
| 2635 | 2635 | $var = $_var; | 
| 2636 | 2636 | } | 
| 2637 | 2637 | } | 
| @@ -2658,7 +2658,7 @@ discard block | ||
| 2658 | 2658 | |
| 2659 | 2659 | $key = ''; | 
| 2660 | 2660 |  		if ($path !== '') { | 
| 2661 | - $key = $this->id . '#' . $path; | |
| 2661 | + $key = $this->id.'#'.$path; | |
| 2662 | 2662 |  			if (isset($cache[$key])) { | 
| 2663 | 2663 | return $cache[$key]; | 
| 2664 | 2664 | } | 
| @@ -2690,7 +2690,7 @@ discard block | ||
| 2690 | 2690 |  		if ($work = $this->getTempFile()) { | 
| 2691 | 2691 |  			if ($wfp = fopen($work, 'wb')) { | 
| 2692 | 2692 |  				if ($fp = $this->_fopen($path)) { | 
| 2693 | -					while(!feof($fp)) { | |
| 2693 | +					while (!feof($fp)) { | |
| 2694 | 2694 | fwrite($wfp, fread($fp, 8192)); | 
| 2695 | 2695 | } | 
| 2696 | 2696 | $this->_fclose($fp, $path); | 
| @@ -2734,7 +2734,7 @@ discard block | ||
| 2734 | 2734 | @set_time_limit(30); | 
| 2735 | 2735 | $stat = $this->stat($this->convEncOut($p)); | 
| 2736 | 2736 | $this->convEncIn(); | 
| 2737 | - ($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p); | |
| 2737 | + ($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p); | |
| 2738 | 2738 | } | 
| 2739 | 2739 | return $this->_rmdir($localpath); | 
| 2740 | 2740 | } | 
| @@ -2751,7 +2751,7 @@ discard block | ||
| 2751 | 2751 | * @return bool | 
| 2752 | 2752 | * @author Dmitry (dio) Levashov | 
| 2753 | 2753 | **/ | 
| 2754 | -	protected function attr($path, $name, $val=null, $isDir=null) { | |
| 2754 | +	protected function attr($path, $name, $val = null, $isDir = null) { | |
| 2755 | 2755 |  		if (!isset($this->defaults[$name])) { | 
| 2756 | 2756 | return false; | 
| 2757 | 2757 | } | 
| @@ -2783,7 +2783,7 @@ discard block | ||
| 2783 | 2783 | } | 
| 2784 | 2784 | } | 
| 2785 | 2785 | |
| 2786 | - return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm; | |
| 2786 | + return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm; | |
| 2787 | 2787 | } | 
| 2788 | 2788 | |
| 2789 | 2789 | /** | 
| @@ -2827,7 +2827,7 @@ discard block | ||
| 2827 | 2827 |  	protected function allowPutMime($mime) { | 
| 2828 | 2828 | // logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order | 
| 2829 | 2829 | $allow = $this->mimeAccepted($mime, $this->uploadAllow, null); | 
| 2830 | - $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); | |
| 2830 | + $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); | |
| 2831 | 2831 | $res = true; // default to allow | 
| 2832 | 2832 |  		if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny' | 
| 2833 | 2833 | $res = false; // default is deny | 
| @@ -2860,7 +2860,7 @@ discard block | ||
| 2860 | 2860 |  			if (!isset($this->sessionCache['rootstat'])) { | 
| 2861 | 2861 | $this->sessionCache['rootstat'] = array(); | 
| 2862 | 2862 | } | 
| 2863 | -			if (! $this->isMyReload()) { | |
| 2863 | +			if (!$this->isMyReload()) { | |
| 2864 | 2864 | // need $path as key for netmount/netunmount | 
| 2865 | 2865 |  				if (isset($this->sessionCache['rootstat'][$rootKey])) { | 
| 2866 | 2866 |  					if ($ret = elFinder::sessionDataDecode($this->sessionCache['rootstat'][$rootKey], 'array')) { | 
| @@ -2901,10 +2901,10 @@ discard block | ||
| 2901 | 2901 |  			if ($this->rootName) { | 
| 2902 | 2902 | $stat['name'] = $this->rootName; | 
| 2903 | 2903 | } | 
| 2904 | -			if (! empty($this->options['icon'])) { | |
| 2904 | +			if (!empty($this->options['icon'])) { | |
| 2905 | 2905 | $stat['icon'] = $this->options['icon']; | 
| 2906 | 2906 | } | 
| 2907 | -			if (! empty($this->options['rootCssClass'])) { | |
| 2907 | +			if (!empty($this->options['rootCssClass'])) { | |
| 2908 | 2908 | $stat['csscls'] = $this->options['rootCssClass']; | 
| 2909 | 2909 | } | 
| 2910 | 2910 |  		} else { | 
| @@ -2952,7 +2952,7 @@ discard block | ||
| 2952 | 2952 | // lock when parent directory is not writable | 
| 2953 | 2953 |  			if (!isset($stat['locked'])) { | 
| 2954 | 2954 | $parent = $this->dirnameCE($path); | 
| 2955 | - $pstat = isset($this->cache[$parent])? $this->cache[$parent] : array(); | |
| 2955 | + $pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array(); | |
| 2956 | 2956 |  				if (isset($pstat['write']) && !$pstat['write']) { | 
| 2957 | 2957 | $stat['locked'] = true; | 
| 2958 | 2958 | } | 
| @@ -3010,7 +3010,7 @@ discard block | ||
| 3010 | 3010 | } | 
| 3011 | 3011 |  			if (!isset($stat['url']) && $this->URL && $this->encoding) { | 
| 3012 | 3012 | $_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1)); | 
| 3013 | -				$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true))); | |
| 3013 | +				$stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true))); | |
| 3014 | 3014 | } | 
| 3015 | 3015 |  		} else { | 
| 3016 | 3016 |  			if ($isDir) { | 
| @@ -3134,7 +3134,7 @@ discard block | ||
| 3134 | 3134 |  				foreach ($mimecf as $line_num => $line) { | 
| 3135 | 3135 |  					if (!preg_match('/^\s*#/', $line)) { | 
| 3136 | 3136 |  						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); | 
| 3137 | -						for ($i = 1, $size = count($mime); $i < $size ; $i++) { | |
| 3137 | +						for ($i = 1, $size = count($mime); $i < $size; $i++) { | |
| 3138 | 3138 |  							if (!isset(elFinderVolumeDriver::$mimetypes[$mime[$i]])) { | 
| 3139 | 3139 | elFinderVolumeDriver::$mimetypes[$mime[$i]] = $mime[0]; | 
| 3140 | 3140 | } | 
| @@ -3240,13 +3240,13 @@ discard block | ||
| 3240 | 3240 | } | 
| 3241 | 3241 | |
| 3242 | 3242 |  	protected function isMyReload($target = '', $ARGtarget = '') { | 
| 3243 | -		if (! empty($this->ARGS['cmd']) && $this->ARGS['cmd'] === 'parents') { | |
| 3243 | +		if (!empty($this->ARGS['cmd']) && $this->ARGS['cmd'] === 'parents') { | |
| 3244 | 3244 | return true; | 
| 3245 | 3245 | } | 
| 3246 | -		if (! empty($this->ARGS['reload'])) { | |
| 3246 | +		if (!empty($this->ARGS['reload'])) { | |
| 3247 | 3247 |  			if ($ARGtarget === '') { | 
| 3248 | - $ARGtarget = isset($this->ARGS['target'])? $this->ARGS['target'] | |
| 3249 | - : ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1)? | |
| 3248 | + $ARGtarget = isset($this->ARGS['target']) ? $this->ARGS['target'] | |
| 3249 | + : ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1) ? | |
| 3250 | 3250 | $this->ARGS['targets'][0] : ''); | 
| 3251 | 3251 | } | 
| 3252 | 3252 |  			if ($ARGtarget !== '') { | 
| @@ -3295,7 +3295,7 @@ discard block | ||
| 3295 | 3295 | * @return array | 
| 3296 | 3296 | * @author Dmitry (dio) Levashov | 
| 3297 | 3297 | **/ | 
| 3298 | -	protected function gettree($path, $deep, $exclude='') { | |
| 3298 | +	protected function gettree($path, $deep, $exclude = '') { | |
| 3299 | 3299 | $dirs = array(); | 
| 3300 | 3300 | |
| 3301 | 3301 | !isset($this->dirsCache[$path]) && $this->cacheDir($path); | 
| @@ -3306,7 +3306,7 @@ discard block | ||
| 3306 | 3306 |  			if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') { | 
| 3307 | 3307 | $dirs[] = $stat; | 
| 3308 | 3308 |  				if ($deep > 0 && !empty($stat['dirs'])) { | 
| 3309 | - $dirs = array_merge($dirs, $this->gettree($p, $deep-1)); | |
| 3309 | + $dirs = array_merge($dirs, $this->gettree($p, $deep - 1)); | |
| 3310 | 3310 | } | 
| 3311 | 3311 | } | 
| 3312 | 3312 | } | 
| @@ -3326,13 +3326,13 @@ discard block | ||
| 3326 | 3326 |  	protected function doSearch($path, $q, $mimes) { | 
| 3327 | 3327 | $result = array(); | 
| 3328 | 3328 | |
| 3329 | - $timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0; | |
| 3329 | + $timeout = $this->options['searchTimeout'] ? $this->searchStart + $this->options['searchTimeout'] : 0; | |
| 3330 | 3330 |  		if ($timeout && $timeout < time()) { | 
| 3331 | 3331 | $this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path))); | 
| 3332 | 3332 | return $result; | 
| 3333 | 3333 | } | 
| 3334 | 3334 | |
| 3335 | -		foreach($this->scandirCE($path) as $p) { | |
| 3335 | +		foreach ($this->scandirCE($path) as $p) { | |
| 3336 | 3336 | @set_time_limit($this->options['searchTimeout'] + 30); | 
| 3337 | 3337 | |
| 3338 | 3338 |  			if ($timeout && ($this->error || $timeout < time())) { | 
| @@ -3360,7 +3360,7 @@ discard block | ||
| 3360 | 3360 |  					if ($this->encoding) { | 
| 3361 | 3361 |  						$path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); | 
| 3362 | 3362 | } | 
| 3363 | - $stat['url'] = $this->URL . $path; | |
| 3363 | + $stat['url'] = $this->URL.$path; | |
| 3364 | 3364 | } | 
| 3365 | 3365 | |
| 3366 | 3366 | $result[] = $stat; | 
| @@ -3394,7 +3394,7 @@ discard block | ||
| 3394 | 3394 |  			if (!$this->inpathCE($target, $this->root)) { | 
| 3395 | 3395 | return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK); | 
| 3396 | 3396 | } | 
| 3397 | - $stat = $this->stat($target); | |
| 3397 | + $stat = $this->stat($target); | |
| 3398 | 3398 | $this->clearcache(); | 
| 3399 | 3399 | return $stat && $this->symlinkCE($target, $dst, $name) | 
| 3400 | 3400 | ? $this->joinPathCE($dst, $name) | 
| @@ -3675,15 +3675,15 @@ discard block | ||
| 3675 | 3675 | } | 
| 3676 | 3676 | |
| 3677 | 3677 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ | 
| 3678 | -		if ($s[0] <= $tmbSize && $s[1]	<= $tmbSize) { | |
| 3679 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); | |
| 3678 | +		if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { | |
| 3679 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); | |
| 3680 | 3680 |  		} else { | 
| 3681 | 3681 | |
| 3682 | 3682 |  			if ($this->options['tmbCrop']) { | 
| 3683 | 3683 | |
| 3684 | 3684 | $result = $tmb; | 
| 3685 | 3685 | /* Resize and crop if image bigger than thumbnail */ | 
| 3686 | -				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { | |
| 3686 | +				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { | |
| 3687 | 3687 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); | 
| 3688 | 3688 | } | 
| 3689 | 3689 | |
| @@ -3700,7 +3700,7 @@ discard block | ||
| 3700 | 3700 | } | 
| 3701 | 3701 | |
| 3702 | 3702 |  			if ($result) { | 
| 3703 | - $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); | |
| 3703 | + $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); | |
| 3704 | 3704 | } | 
| 3705 | 3705 | } | 
| 3706 | 3706 | |
| @@ -3746,18 +3746,18 @@ discard block | ||
| 3746 | 3746 | /* Resizing by biggest side */ | 
| 3747 | 3747 |  			if ($resizeByBiggerSide) { | 
| 3748 | 3748 |  				if ($orig_w > $orig_h) { | 
| 3749 | - $size_h = round($orig_h * $width / $orig_w); | |
| 3749 | + $size_h = round($orig_h*$width/$orig_w); | |
| 3750 | 3750 | $size_w = $width; | 
| 3751 | 3751 |  				} else { | 
| 3752 | - $size_w = round($orig_w * $height / $orig_h); | |
| 3752 | + $size_w = round($orig_w*$height/$orig_h); | |
| 3753 | 3753 | $size_h = $height; | 
| 3754 | 3754 | } | 
| 3755 | 3755 |  			} else { | 
| 3756 | 3756 |  				if ($orig_w > $orig_h) { | 
| 3757 | - $size_w = round($orig_w * $height / $orig_h); | |
| 3757 | + $size_w = round($orig_w*$height/$orig_h); | |
| 3758 | 3758 | $size_h = $height; | 
| 3759 | 3759 |  				} else { | 
| 3760 | - $size_h = round($orig_h * $width / $orig_w); | |
| 3760 | + $size_h = round($orig_h*$width/$orig_w); | |
| 3761 | 3761 | $size_w = $width; | 
| 3762 | 3762 | } | 
| 3763 | 3763 | } | 
| @@ -3775,7 +3775,7 @@ discard block | ||
| 3775 | 3775 | // Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb | 
| 3776 | 3776 | // resize bench: http://app-mgng.rhcloud.com/9 | 
| 3777 | 3777 | // resize sample: http://www.dylanbeattie.net/magick/filters/result.html | 
| 3778 | - $filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; | |
| 3778 | + $filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; | |
| 3779 | 3779 | |
| 3780 | 3780 | $ani = ($img->getNumberImages() > 1); | 
| 3781 | 3781 |  				if ($ani && is_null($destformat)) { | 
| @@ -3800,11 +3800,11 @@ discard block | ||
| 3800 | 3800 | break; | 
| 3801 | 3801 | |
| 3802 | 3802 | case 'gd': | 
| 3803 | - $img = $this->gdImageCreate($path,$s['mime']); | |
| 3803 | + $img = $this->gdImageCreate($path, $s['mime']); | |
| 3804 | 3804 | |
| 3805 | -				if ($img &&  false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { | |
| 3805 | +				if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { | |
| 3806 | 3806 | |
| 3807 | - $this->gdImageBackground($tmp,$this->options['tmbBgColor']); | |
| 3807 | + $this->gdImageBackground($tmp, $this->options['tmbBgColor']); | |
| 3808 | 3808 | |
| 3809 | 3809 |  					if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) { | 
| 3810 | 3810 | return false; | 
| @@ -3885,11 +3885,11 @@ discard block | ||
| 3885 | 3885 | break; | 
| 3886 | 3886 | |
| 3887 | 3887 | case 'gd': | 
| 3888 | - $img = $this->gdImageCreate($path,$s['mime']); | |
| 3888 | + $img = $this->gdImageCreate($path, $s['mime']); | |
| 3889 | 3889 | |
| 3890 | -				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) { | |
| 3890 | +				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { | |
| 3891 | 3891 | |
| 3892 | - $this->gdImageBackground($tmp,$this->options['tmbBgColor']); | |
| 3892 | + $this->gdImageBackground($tmp, $this->options['tmbBgColor']); | |
| 3893 | 3893 | |
| 3894 | 3894 | $size_w = $width; | 
| 3895 | 3895 | $size_h = $height; | 
| @@ -3940,8 +3940,8 @@ discard block | ||
| 3940 | 3940 | $result = false; | 
| 3941 | 3941 | |
| 3942 | 3942 | /* Coordinates for image over square aligning */ | 
| 3943 | - $y = ceil(abs($height - $s[1]) / 2); | |
| 3944 | - $x = ceil(abs($width - $s[0]) / 2); | |
| 3943 | + $y = ceil(abs($height - $s[1])/2); | |
| 3944 | + $x = ceil(abs($width - $s[0])/2); | |
| 3945 | 3945 | |
| 3946 | 3946 |  		if (!$jpgQuality) { | 
| 3947 | 3947 | $jpgQuality = $this->options['jpgQuality']; | 
| @@ -3965,7 +3965,7 @@ discard block | ||
| 3965 | 3965 | $gif->newImage($width, $height, new ImagickPixel($bgcolor)); | 
| 3966 | 3966 | $gif->setImageColorspace($img->getImageColorspace()); | 
| 3967 | 3967 |  						$gif->setImageFormat('gif'); | 
| 3968 | - $gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); | |
| 3968 | + $gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); | |
| 3969 | 3969 | $gif->setImageDelay($img->getImageDelay()); | 
| 3970 | 3970 | $gif->setImageIterations($img->getImageIterations()); | 
| 3971 | 3971 | $img1->addImage($gif); | 
| @@ -3980,7 +3980,7 @@ discard block | ||
| 3980 | 3980 | $img1 = new Imagick(); | 
| 3981 | 3981 | $img1->newImage($width, $height, new ImagickPixel($bgcolor)); | 
| 3982 | 3982 | $img1->setImageColorspace($img->getImageColorspace()); | 
| 3983 | - $img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); | |
| 3983 | + $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); | |
| 3984 | 3984 | $result = $this->imagickImage($img, $path, $destformat, $jpgQuality); | 
| 3985 | 3985 | } | 
| 3986 | 3986 | |
| @@ -3991,11 +3991,11 @@ discard block | ||
| 3991 | 3991 | break; | 
| 3992 | 3992 | |
| 3993 | 3993 | case 'gd': | 
| 3994 | - $img = $this->gdImageCreate($path,$s['mime']); | |
| 3994 | + $img = $this->gdImageCreate($path, $s['mime']); | |
| 3995 | 3995 | |
| 3996 | -				if ($img &&  false != ($tmp = imagecreatetruecolor($width, $height))) { | |
| 3996 | +				if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { | |
| 3997 | 3997 | |
| 3998 | - $this->gdImageBackground($tmp,$bgcolor); | |
| 3998 | + $this->gdImageBackground($tmp, $bgcolor); | |
| 3999 | 3999 | |
| 4000 | 4000 |  					if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) { | 
| 4001 | 4001 | return false; | 
| @@ -4027,15 +4027,15 @@ discard block | ||
| 4027 | 4027 | * @author Troex Nevelin | 
| 4028 | 4028 | **/ | 
| 4029 | 4029 |  	protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null, $jpgQuality = null) { | 
| 4030 | -		if (($s = @getimagesize($path)) == false || $degree % 360 === 0) { | |
| 4030 | +		if (($s = @getimagesize($path)) == false || $degree%360 === 0) { | |
| 4031 | 4031 | return false; | 
| 4032 | 4032 | } | 
| 4033 | 4033 | |
| 4034 | 4034 | $result = false; | 
| 4035 | 4035 | |
| 4036 | 4036 | // try lossless rotate | 
| 4037 | -		if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { | |
| 4038 | - $count = ($degree / 90) % 4; | |
| 4037 | +		if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { | |
| 4038 | + $count = ($degree/90)%4; | |
| 4039 | 4039 | $exiftran = array( | 
| 4040 | 4040 | 1 => '-9', | 
| 4041 | 4041 | 2 => '-1', | 
| @@ -4051,7 +4051,7 @@ discard block | ||
| 4051 | 4051 | 'exiftran -i '.$exiftran[$count].' '.$path, | 
| 4052 | 4052 | 'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath | 
| 4053 | 4053 | ); | 
| 4054 | -			foreach($cmds as $cmd) { | |
| 4054 | +			foreach ($cmds as $cmd) { | |
| 4055 | 4055 |  				if ($this->procExec($cmd) === 0) { | 
| 4056 | 4056 | $result = true; | 
| 4057 | 4057 | break; | 
| @@ -4091,12 +4091,12 @@ discard block | ||
| 4091 | 4091 | break; | 
| 4092 | 4092 | |
| 4093 | 4093 | case 'gd': | 
| 4094 | - $img = $this->gdImageCreate($path,$s['mime']); | |
| 4094 | + $img = $this->gdImageCreate($path, $s['mime']); | |
| 4095 | 4095 | |
| 4096 | 4096 | $degree = 360 - $degree; | 
| 4097 | 4097 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); | 
| 4098 | 4098 | $bgcolor = imagecolorallocate($img, $r, $g, $b); | 
| 4099 | - $tmp = imageRotate($img, $degree, (int)$bgcolor); | |
| 4099 | + $tmp = imageRotate($img, $degree, (int) $bgcolor); | |
| 4100 | 4100 | |
| 4101 | 4101 | $result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality); | 
| 4102 | 4102 | |
| @@ -4121,11 +4121,11 @@ discard block | ||
| 4121 | 4121 | * @return int exit code | 
| 4122 | 4122 | * @author Alexey Sukhotin | 
| 4123 | 4123 | **/ | 
| 4124 | -	protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) { | |
| 4124 | +	protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) { | |
| 4125 | 4125 | |
| 4126 | 4126 | $descriptorspec = array( | 
| 4127 | -			0 => array("pipe", "r"),  // stdin | |
| 4128 | -			1 => array("pipe", "w"),  // stdout | |
| 4127 | +			0 => array("pipe", "r"), // stdin | |
| 4128 | +			1 => array("pipe", "w"), // stdout | |
| 4129 | 4129 |  			2 => array("pipe", "w")   // stderr | 
| 4130 | 4130 | ); | 
| 4131 | 4131 | |
| @@ -4182,8 +4182,8 @@ discard block | ||
| 4182 | 4182 | * @param string $mime | 
| 4183 | 4183 | * @return gd image resource identifier | 
| 4184 | 4184 | */ | 
| 4185 | -	protected function gdImageCreate($path,$mime){ | |
| 4186 | -		switch($mime){ | |
| 4185 | +	protected function gdImageCreate($path, $mime) { | |
| 4186 | +		switch ($mime) { | |
| 4187 | 4187 | case 'image/jpeg': | 
| 4188 | 4188 | return imagecreatefromjpeg($path); | 
| 4189 | 4189 | |
| @@ -4208,7 +4208,7 @@ discard block | ||
| 4208 | 4208 | * @param string $mime The original image mime type | 
| 4209 | 4209 | * @param int $jpgQuality JEPG quality (1-100) | 
| 4210 | 4210 | */ | 
| 4211 | -	protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null ){ | |
| 4211 | +	protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null) { | |
| 4212 | 4212 | |
| 4213 | 4213 |  		if (!$jpgQuality) { | 
| 4214 | 4214 | $jpgQuality = $this->options['jpgQuality']; | 
| @@ -4232,7 +4232,7 @@ discard block | ||
| 4232 | 4232 | * @param string $destformat The Image type to use for $filename | 
| 4233 | 4233 | * @param int $jpgQuality JEPG quality (1-100) | 
| 4234 | 4234 | */ | 
| 4235 | -	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ){ | |
| 4235 | +	protected function imagickImage($img, $filename, $destformat, $jpgQuality = null) { | |
| 4236 | 4236 | |
| 4237 | 4237 |  		if (!$jpgQuality) { | 
| 4238 | 4238 | $jpgQuality = $this->options['jpgQuality']; | 
| @@ -4287,13 +4287,13 @@ discard block | ||
| 4287 | 4287 | * @param resource $image gd image resource | 
| 4288 | 4288 | * @param string $bgcolor background color in #rrggbb format | 
| 4289 | 4289 | */ | 
| 4290 | -	protected function gdImageBackground($image, $bgcolor){ | |
| 4290 | +	protected function gdImageBackground($image, $bgcolor) { | |
| 4291 | 4291 | |
| 4292 | -		if( $bgcolor == 'transparent' ){ | |
| 4293 | - imagesavealpha($image,true); | |
| 4292 | +		if ($bgcolor == 'transparent') { | |
| 4293 | + imagesavealpha($image, true); | |
| 4294 | 4294 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); | 
| 4295 | 4295 | |
| 4296 | -		}else{ | |
| 4296 | +		} else { | |
| 4297 | 4297 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); | 
| 4298 | 4298 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); | 
| 4299 | 4299 | } | 
| @@ -4331,13 +4331,13 @@ discard block | ||
| 4331 | 4331 | * @return int|bool | 
| 4332 | 4332 | * @author Alexey Sukhotin | 
| 4333 | 4333 | **/ | 
| 4334 | -	protected function stripos($haystack , $needle , $offset = 0) { | |
| 4334 | +	protected function stripos($haystack, $needle, $offset = 0) { | |
| 4335 | 4335 |  		if (function_exists('mb_stripos')) { | 
| 4336 | - return mb_stripos($haystack , $needle , $offset, 'UTF-8'); | |
| 4336 | + return mb_stripos($haystack, $needle, $offset, 'UTF-8'); | |
| 4337 | 4337 |  		} else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) { | 
| 4338 | 4338 | return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset); | 
| 4339 | 4339 | } | 
| 4340 | - return stripos($haystack , $needle , $offset); | |
| 4340 | + return stripos($haystack, $needle, $offset); | |
| 4341 | 4341 | } | 
| 4342 | 4342 | |
| 4343 | 4343 | /** | 
| @@ -4387,22 +4387,22 @@ discard block | ||
| 4387 | 4387 | unset($o); | 
| 4388 | 4388 |  			$this->procExec('zip -v', $o, $c); | 
| 4389 | 4389 |  			if ($c == 0) { | 
| 4390 | -				$arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); | |
| 4390 | +				$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); | |
| 4391 | 4391 | } | 
| 4392 | 4392 | unset($o); | 
| 4393 | 4393 |  			$this->procExec('unzip --help', $o, $c); | 
| 4394 | 4394 |  			if ($c == 0) { | 
| 4395 | -				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip'); | |
| 4395 | +				$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); | |
| 4396 | 4396 | } | 
| 4397 | 4397 | unset($o); | 
| 4398 | 4398 |  			$this->procExec('rar --version', $o, $c); | 
| 4399 | 4399 |  			if ($c == 0 || $c == 7) { | 
| 4400 | 4400 |  				$arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar'); | 
| 4401 | -				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar'); | |
| 4401 | +				$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); | |
| 4402 | 4402 |  			} else { | 
| 4403 | 4403 | unset($o); | 
| 4404 | 4404 |  				$test = $this->procExec('unrar', $o, $c); | 
| 4405 | -				if ($c==0 || $c == 7) { | |
| 4405 | +				if ($c == 0 || $c == 7) { | |
| 4406 | 4406 |  					$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar'); | 
| 4407 | 4407 | } | 
| 4408 | 4408 | } | 
| @@ -4424,7 +4424,7 @@ discard block | ||
| 4424 | 4424 |  				if (empty($arcs['extract']['application/x-tar'])) { | 
| 4425 | 4425 |  					$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar'); | 
| 4426 | 4426 | } | 
| 4427 | -			} else if (substr(PHP_OS,0,3) === 'WIN') { | |
| 4427 | +			} else if (substr(PHP_OS, 0, 3) === 'WIN') { | |
| 4428 | 4428 | // check `7z` for Windows server. | 
| 4429 | 4429 | unset($o); | 
| 4430 | 4430 |  				$this->procExec('7z', $o, $c); | 
| @@ -4478,22 +4478,22 @@ discard block | ||
| 4478 | 4478 | |
| 4479 | 4479 | // normalize `/../` | 
| 4480 | 4480 |  		$normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#'; | 
| 4481 | -		while(preg_match($normreg, $path)) { | |
| 4481 | +		while (preg_match($normreg, $path)) { | |
| 4482 | 4482 | $path = preg_replace($normreg, '$1', $path); | 
| 4483 | 4483 | } | 
| 4484 | 4484 | |
| 4485 | 4485 | // 'Here' | 
| 4486 | - if ($path === '' || $path === '.' . $separator) return $base; | |
| 4486 | + if ($path === '' || $path === '.'.$separator) return $base; | |
| 4487 | 4487 | |
| 4488 | 4488 | // Absolute path | 
| 4489 | 4489 |  		if ($path[0] === $separator || strpos($path, $systemroot) === 0) { | 
| 4490 | 4490 | return $path; | 
| 4491 | 4491 | } | 
| 4492 | 4492 | |
| 4493 | - $preg_separator = '#' . $sepquoted . '#'; | |
| 4493 | + $preg_separator = '#'.$sepquoted.'#'; | |
| 4494 | 4494 | |
| 4495 | 4495 | // Relative path from 'Here' | 
| 4496 | -		if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) { | |
| 4496 | +		if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) { | |
| 4497 | 4497 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); | 
| 4498 | 4498 |  			if ($arrn[0] !== '.') { | 
| 4499 | 4499 | array_unshift($arrn, '.'); | 
| @@ -4507,12 +4507,11 @@ discard block | ||
| 4507 | 4507 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); | 
| 4508 | 4508 | $arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY); | 
| 4509 | 4509 | |
| 4510 | -			while (! empty($arrn) && $arrn[0] === '..') { | |
| 4510 | +			while (!empty($arrn) && $arrn[0] === '..') { | |
| 4511 | 4511 | array_shift($arrn); | 
| 4512 | 4512 | array_pop($arrp); | 
| 4513 | 4513 | } | 
| 4514 | - $path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) : | |
| 4515 | - (! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot); | |
| 4514 | + $path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot); | |
| 4516 | 4515 | } | 
| 4517 | 4516 | |
| 4518 | 4517 | return $path; | 
| @@ -4530,7 +4529,7 @@ discard block | ||
| 4530 | 4529 | @chmod($dir, 0777); | 
| 4531 | 4530 |  			foreach (array_diff(scandir($dir), array('.', '..')) as $file) { | 
| 4532 | 4531 | @set_time_limit(30); | 
| 4533 | - $path = $dir . DIRECTORY_SEPARATOR . $file; | |
| 4532 | + $path = $dir.DIRECTORY_SEPARATOR.$file; | |
| 4534 | 4533 |  				if (!is_link($dir) && is_dir($path)) { | 
| 4535 | 4534 | $this->rmdirRecursive($path); | 
| 4536 | 4535 |  				} else { | 
| @@ -4617,22 +4616,22 @@ discard block | ||
| 4617 | 4616 |  		try { | 
| 4618 | 4617 |  			if ($start = is_string($zipPath)) { | 
| 4619 | 4618 | $zip = new ZipArchive(); | 
| 4620 | -				if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) { | |
| 4619 | +				if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) { | |
| 4621 | 4620 | $zip = false; | 
| 4622 | 4621 | } | 
| 4623 | 4622 |  			} else { | 
| 4624 | 4623 | $zip = $zipPath; | 
| 4625 | 4624 | } | 
| 4626 | 4625 |  			if ($zip) { | 
| 4627 | -				foreach($files as $file) { | |
| 4628 | - $path = $dir . DIRECTORY_SEPARATOR . $file; | |
| 4626 | +				foreach ($files as $file) { | |
| 4627 | + $path = $dir.DIRECTORY_SEPARATOR.$file; | |
| 4629 | 4628 |  					if (is_dir($path)) { | 
| 4630 | 4629 | $zip->addEmptyDir($file); | 
| 4631 | 4630 | $_files = array(); | 
| 4632 | 4631 |  						if ($handle = opendir($path)) { | 
| 4633 | 4632 |  							while (false !== ($entry = readdir($handle))) { | 
| 4634 | 4633 |  								if ($entry !== "." && $entry !== "..") { | 
| 4635 | - $_files[] = $file . DIRECTORY_SEPARATOR . $entry; | |
| 4634 | + $_files[] = $file.DIRECTORY_SEPARATOR.$entry; | |
| 4636 | 4635 | } | 
| 4637 | 4636 | } | 
| 4638 | 4637 | closedir($handle); | 
| @@ -4817,7 +4816,7 @@ discard block | ||
| 4817 | 4816 | * @return resource|false | 
| 4818 | 4817 | * @author Dmitry (dio) Levashov | 
| 4819 | 4818 | **/ | 
| 4820 | - abstract protected function _fopen($path, $mode="rb"); | |
| 4819 | + abstract protected function _fopen($path, $mode = "rb"); | |
| 4821 | 4820 | |
| 4822 | 4821 | /** | 
| 4823 | 4822 | * Close opened file | 
| @@ -4827,7 +4826,7 @@ discard block | ||
| 4827 | 4826 | * @return bool | 
| 4828 | 4827 | * @author Dmitry (dio) Levashov | 
| 4829 | 4828 | **/ | 
| 4830 | - abstract protected function _fclose($fp, $path=''); | |
| 4829 | + abstract protected function _fclose($fp, $path = ''); | |
| 4831 | 4830 | |
| 4832 | 4831 | /******************** file/dir manipulations *************************/ | 
| 4833 | 4832 | |