@@ -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 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // if no thumbnails url - try detect it |
118 | 118 | if ($root['read'] && !$this->tmbURL && $this->URL) { |
119 | 119 | if (strpos($this->tmbPath, $this->root) === 0) { |
120 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); |
|
120 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); |
|
121 | 121 | if (preg_match("|[^/?&=]$|", $this->tmbURL)) { |
122 | 122 | $this->tmbURL .= '/'; |
123 | 123 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | if ($mtime != $compare) { |
176 | 176 | return $mtime; |
177 | 177 | } |
178 | - $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; |
|
178 | + $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH') ? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; |
|
179 | 179 | $path = escapeshellarg($path); |
180 | 180 | $standby = max(1, intval($standby)); |
181 | 181 | $cmd = $inotifywait.' '.$path.' -t '.$standby.' -e moved_to,moved_from,move,create,delete,delete_self'; |
182 | - $this->procExec($cmd , $o, $r); |
|
182 | + $this->procExec($cmd, $o, $r); |
|
183 | 183 | if ($r === 0) { |
184 | 184 | // changed |
185 | 185 | clearstatcache(); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | // error |
192 | 192 | // cache to $_SESSION |
193 | - $sessionClose = true;; |
|
193 | + $sessionClose = true; ; |
|
194 | 194 | try { |
195 | 195 | $sessionStart = session_start(); |
196 | 196 | } catch (Exception $e) { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @author Dmitry (dio) Levashov |
243 | 243 | **/ |
244 | 244 | protected function _joinPath($dir, $name) { |
245 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
245 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $comps = $new_comps; |
295 | 295 | $path = implode('/', $comps); |
296 | 296 | if ($initial_slashes) { |
297 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
297 | + $path = str_repeat('/', $initial_slashes).$path; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | if ($changeSep) { |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | **/ |
366 | 366 | protected function _inpath($path, $parent) { |
367 | 367 | $cwd = getcwd(); |
368 | - $real_path = $this->getFullPath($path, $cwd); |
|
368 | + $real_path = $this->getFullPath($path, $cwd); |
|
369 | 369 | $real_parent = $this->getFullPath($parent, $cwd); |
370 | 370 | if ($real_path && $real_parent) { |
371 | 371 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $stat = array(); |
425 | 425 | return $stat; |
426 | 426 | } else { |
427 | - $stat['mime'] = 'symlink-broken'; |
|
427 | + $stat['mime'] = 'symlink-broken'; |
|
428 | 428 | $target = readlink($path); |
429 | 429 | $lstat = lstat($path); |
430 | 430 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | $fstat = stat($path); |
441 | 441 | $uid = $fstat['uid']; |
442 | 442 | $gid = $fstat['gid']; |
443 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
443 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
444 | 444 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
445 | 445 | } |
446 | 446 | |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
451 | 451 | } |
452 | 452 | //logical rights first |
453 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
454 | - $stat['write'] = is_writable($path)? null : false; |
|
453 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
454 | + $stat['write'] = is_writable($path) ? null : false; |
|
455 | 455 | |
456 | 456 | if (is_null($stat['read'])) { |
457 | 457 | $stat['size'] = $dir ? 0 : $size; |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | |
522 | 522 | if (is_dir($path)) { |
523 | 523 | $path = strtr($path, array('[' => '\\[', ']' => '\\]', '*' => '\\*', '?' => '\\?')); |
524 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
524 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
525 | 525 | } |
526 | 526 | return false; |
527 | 527 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | $br = true; |
603 | 603 | } else { |
604 | 604 | $_path = $fpath; |
605 | - $stat['mime'] = 'symlink-broken'; |
|
605 | + $stat['mime'] = 'symlink-broken'; |
|
606 | 606 | $target = readlink($_path); |
607 | 607 | $lstat = lstat($_path); |
608 | 608 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -627,13 +627,13 @@ discard block |
||
627 | 627 | if ($statOwner && !$linkreadable) { |
628 | 628 | $uid = $file->getOwner(); |
629 | 629 | $gid = $file->getGroup(); |
630 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
630 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
631 | 631 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
632 | 632 | } |
633 | 633 | |
634 | 634 | //logical rights first |
635 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
636 | - $stat['write'] = $file->isWritable()? null : false; |
|
635 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
636 | + $stat['write'] = $file->isWritable() ? null : false; |
|
637 | 637 | |
638 | 638 | if (is_null($stat['read'])) { |
639 | 639 | $stat['size'] = $dir ? 0 : $size; |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | |
650 | 650 | if ($cache) { |
651 | 651 | $cache = $this->convEncOut($cache, false); |
652 | - foreach($cache as $d) { |
|
652 | + foreach ($cache as $d) { |
|
653 | 653 | $this->updateCache($d[0], $d[1]); |
654 | 654 | } |
655 | 655 | } |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | * @return resource|false |
666 | 666 | * @author Dmitry (dio) Levashov |
667 | 667 | **/ |
668 | - protected function _fopen($path, $mode='rb') { |
|
668 | + protected function _fopen($path, $mode = 'rb') { |
|
669 | 669 | return @fopen($path, $mode); |
670 | 670 | } |
671 | 671 | |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | * @return bool |
677 | 677 | * @author Dmitry (dio) Levashov |
678 | 678 | **/ |
679 | - protected function _fclose($fp, $path='') { |
|
679 | + protected function _fclose($fp, $path = '') { |
|
680 | 680 | return @fclose($fp); |
681 | 681 | } |
682 | 682 | |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | $path = $this->_joinPath($dir, $name); |
809 | 809 | |
810 | 810 | $meta = stream_get_meta_data($fp); |
811 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
811 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
812 | 812 | if ($uri && @is_file($uri)) { |
813 | 813 | fclose($fp); |
814 | 814 | $isCmdPaste = ($this->ARGS['cmd'] === 'paste'); |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | * @return bool |
873 | 873 | **/ |
874 | 874 | protected function _chmod($path, $mode) { |
875 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
875 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
876 | 876 | $ret = @chmod($path, $modeOct); |
877 | 877 | $ret && clearstatcache(); |
878 | 878 | return $ret; |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | $src = $dir; |
991 | 991 | $name = basename($path); |
992 | 992 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
993 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
993 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
994 | 994 | } |
995 | 995 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
996 | 996 | if (file_exists($test) || is_link($test)) { |
@@ -999,9 +999,9 @@ discard block |
||
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | if ($name !== '') { |
1002 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
1002 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
1003 | 1003 | |
1004 | - if (! @rename($src, $result)) { |
|
1004 | + if (!@rename($src, $result)) { |
|
1005 | 1005 | $this->delTree($dir); |
1006 | 1006 | return false; |
1007 | 1007 | } |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | $dstDir = dirname($path); |
1010 | 1010 | $res = false; |
1011 | 1011 | $result = array(); |
1012 | - foreach($ls as $name) { |
|
1012 | + foreach ($ls as $name) { |
|
1013 | 1013 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
1014 | 1014 | if (is_dir($target)) { |
1015 | 1015 | $this->delTree($target); |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | new RecursiveDirectoryIterator($path, |
1094 | 1094 | FilesystemIterator::KEY_AS_PATHNAME | |
1095 | 1095 | FilesystemIterator::SKIP_DOTS | |
1096 | - (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')? |
|
1096 | + (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ? |
|
1097 | 1097 | RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0) |
1098 | 1098 | ), |
1099 | 1099 | RecursiveIteratorIterator::SELF_FIRST |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | $result = array(); |
1110 | 1110 | |
1111 | 1111 | if ($match) { |
1112 | - foreach($match as $p) { |
|
1112 | + foreach ($match as $p) { |
|
1113 | 1113 | $stat = $this->stat($p); |
1114 | 1114 | |
1115 | 1115 | if (!$stat) { // invalid links |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | $stat['path'] = $this->path($stat['hash']); |
1127 | 1127 | if ($this->URL && !isset($stat['url'])) { |
1128 | 1128 | $path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1)); |
1129 | - $stat['url'] = $this->URL . $path; |
|
1129 | + $stat['url'] = $this->URL.$path; |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | $result[] = $stat; |