@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * @author Dmitry (dio) Levashov |
| 33 | 33 | **/ |
| 34 | 34 | public function __construct() { |
| 35 | - $this->options['alias'] = ''; // alias to replace root dir name |
|
| 36 | - $this->options['dirMode'] = 0755; // new dirs mode |
|
| 37 | - $this->options['fileMode'] = 0644; // new files mode |
|
| 38 | - $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) |
|
| 39 | - $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
| 35 | + $this->options['alias'] = ''; // alias to replace root dir name |
|
| 36 | + $this->options['dirMode'] = 0755; // new dirs mode |
|
| 37 | + $this->options['fileMode'] = 0644; // new files mode |
|
| 38 | + $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) |
|
| 39 | + $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
| 40 | 40 | $this->options['rootCssClass'] = 'elfinder-navbar-root-local'; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | protected function init() { |
| 54 | 54 | // Normalize directory separator for windows |
| 55 | 55 | if (DIRECTORY_SEPARATOR !== '/') { |
| 56 | - foreach(array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) { |
|
| 56 | + foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) { |
|
| 57 | 57 | if (!empty($this->options[$key])) { |
| 58 | 58 | $this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]); |
| 59 | 59 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | // if no thumbnails url - try detect it |
| 103 | 103 | if ($root['read'] && !$this->tmbURL && $this->URL) { |
| 104 | 104 | if (strpos($this->tmbPath, $this->root) === 0) { |
| 105 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); |
|
| 105 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); |
|
| 106 | 106 | if (preg_match("|[^/?&=]$|", $this->tmbURL)) { |
| 107 | 107 | $this->tmbURL .= '/'; |
| 108 | 108 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @author Dmitry (dio) Levashov |
| 179 | 179 | **/ |
| 180 | 180 | protected function _joinPath($dir, $name) { |
| 181 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
| 181 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $comps = $new_comps; |
| 231 | 231 | $path = implode('/', $comps); |
| 232 | 232 | if ($initial_slashes) { |
| 233 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
| 233 | + $path = str_repeat('/', $initial_slashes).$path; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | if ($changeSep) { |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | **/ |
| 302 | 302 | protected function _inpath($path, $parent) { |
| 303 | 303 | $cwd = getcwd(); |
| 304 | - $real_path = $this->getFullPath($path, $cwd); |
|
| 304 | + $real_path = $this->getFullPath($path, $cwd); |
|
| 305 | 305 | $real_parent = $this->getFullPath($parent, $cwd); |
| 306 | 306 | if ($real_path && $real_parent) { |
| 307 | 307 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $stat = array(); |
| 361 | 361 | return $stat; |
| 362 | 362 | } else { |
| 363 | - $stat['mime'] = 'symlink-broken'; |
|
| 363 | + $stat['mime'] = 'symlink-broken'; |
|
| 364 | 364 | $target = readlink($path); |
| 365 | 365 | $lstat = lstat($path); |
| 366 | 366 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $fstat = stat($path); |
| 377 | 377 | $uid = $fstat['uid']; |
| 378 | 378 | $gid = $fstat['gid']; |
| 379 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
| 379 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
| 380 | 380 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 381 | 381 | } |
| 382 | 382 | |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
| 387 | 387 | } |
| 388 | 388 | //logical rights first |
| 389 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
| 390 | - $stat['write'] = is_writable($path)? null : false; |
|
| 389 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
| 390 | + $stat['write'] = is_writable($path) ? null : false; |
|
| 391 | 391 | |
| 392 | 392 | if (is_null($stat['read'])) { |
| 393 | 393 | $stat['size'] = $dir ? 0 : $size; |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | |
| 458 | 458 | if (is_dir($path)) { |
| 459 | 459 | $path = strtr($path, array('[' => '\\[', ']' => '\\]', '*' => '\\*', '?' => '\\?')); |
| 460 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
| 460 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
| 461 | 461 | } |
| 462 | 462 | return false; |
| 463 | 463 | } |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | $br = true; |
| 539 | 539 | } else { |
| 540 | 540 | $_path = $fpath; |
| 541 | - $stat['mime'] = 'symlink-broken'; |
|
| 541 | + $stat['mime'] = 'symlink-broken'; |
|
| 542 | 542 | $target = readlink($_path); |
| 543 | 543 | $lstat = lstat($_path); |
| 544 | 544 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -563,13 +563,13 @@ discard block |
||
| 563 | 563 | if ($statOwner && !$linkreadable) { |
| 564 | 564 | $uid = $file->getOwner(); |
| 565 | 565 | $gid = $file->getGroup(); |
| 566 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
| 566 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
| 567 | 567 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | //logical rights first |
| 571 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
| 572 | - $stat['write'] = $file->isWritable()? null : false; |
|
| 571 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
| 572 | + $stat['write'] = $file->isWritable() ? null : false; |
|
| 573 | 573 | |
| 574 | 574 | if (is_null($stat['read'])) { |
| 575 | 575 | $stat['size'] = $dir ? 0 : $size; |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | if ($cache) { |
| 587 | 587 | $cache = $this->convEncOut($cache, false); |
| 588 | - foreach($cache as $d) { |
|
| 588 | + foreach ($cache as $d) { |
|
| 589 | 589 | $this->updateCache($d[0], $d[1]); |
| 590 | 590 | } |
| 591 | 591 | } |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | * @return resource|false |
| 602 | 602 | * @author Dmitry (dio) Levashov |
| 603 | 603 | **/ |
| 604 | - protected function _fopen($path, $mode='rb') { |
|
| 604 | + protected function _fopen($path, $mode = 'rb') { |
|
| 605 | 605 | return @fopen($path, $mode); |
| 606 | 606 | } |
| 607 | 607 | |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | * @return bool |
| 613 | 613 | * @author Dmitry (dio) Levashov |
| 614 | 614 | **/ |
| 615 | - protected function _fclose($fp, $path='') { |
|
| 615 | + protected function _fclose($fp, $path = '') { |
|
| 616 | 616 | return @fclose($fp); |
| 617 | 617 | } |
| 618 | 618 | |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | $path = $this->_joinPath($dir, $name); |
| 745 | 745 | |
| 746 | 746 | $meta = stream_get_meta_data($fp); |
| 747 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
| 747 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
| 748 | 748 | if ($uri && @is_file($uri)) { |
| 749 | 749 | fclose($fp); |
| 750 | 750 | $isCmdPaste = ($this->ARGS['cmd'] === 'paste'); |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | * @return bool |
| 809 | 809 | **/ |
| 810 | 810 | protected function _chmod($path, $mode) { |
| 811 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
| 811 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
| 812 | 812 | $ret = @chmod($path, $modeOct); |
| 813 | 813 | $ret && clearstatcache(); |
| 814 | 814 | return $ret; |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | $src = $dir; |
| 927 | 927 | $name = basename($path); |
| 928 | 928 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 929 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 929 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 930 | 930 | } |
| 931 | 931 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
| 932 | 932 | if (file_exists($test) || is_link($test)) { |
@@ -935,9 +935,9 @@ discard block |
||
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | if ($name !== '') { |
| 938 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 938 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 939 | 939 | |
| 940 | - if (! @rename($src, $result)) { |
|
| 940 | + if (!@rename($src, $result)) { |
|
| 941 | 941 | $this->delTree($dir); |
| 942 | 942 | return false; |
| 943 | 943 | } |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | $dstDir = dirname($path); |
| 946 | 946 | $res = false; |
| 947 | 947 | $result = array(); |
| 948 | - foreach($ls as $name) { |
|
| 948 | + foreach ($ls as $name) { |
|
| 949 | 949 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
| 950 | 950 | if (is_dir($target)) { |
| 951 | 951 | $this->delTree($target); |
@@ -1037,10 +1037,10 @@ discard block |
||
| 1037 | 1037 | |
| 1038 | 1038 | $path = strtr($path, $escaper); |
| 1039 | 1039 | $_q = strtr($q, $escaper); |
| 1040 | - $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
| 1041 | - $match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$_q.'*', GLOB_NOSORT); |
|
| 1040 | + $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
| 1041 | + $match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$_q.'*', GLOB_NOSORT); |
|
| 1042 | 1042 | if ($match) { |
| 1043 | - foreach($match as $p) { |
|
| 1043 | + foreach ($match as $p) { |
|
| 1044 | 1044 | $stat = $this->stat($p); |
| 1045 | 1045 | |
| 1046 | 1046 | if (!$stat) { // invalid links |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | $stat['path'] = $this->path($stat['hash']); |
| 1058 | 1058 | if ($this->URL && !isset($stat['url'])) { |
| 1059 | 1059 | $path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1)); |
| 1060 | - $stat['url'] = $this->URL . $path; |
|
| 1060 | + $stat['url'] = $this->URL.$path; |
|
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | $result[] = $stat; |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | } |
| 1066 | 1066 | } |
| 1067 | 1067 | if ($dirs) { |
| 1068 | - foreach($dirs as $dir) { |
|
| 1068 | + foreach ($dirs as $dir) { |
|
| 1069 | 1069 | $stat = $this->stat($dir); |
| 1070 | 1070 | if ($stat['read'] && !isset($stat['alias'])) { |
| 1071 | 1071 | @set_time_limit(30); |