@@ -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(); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @author Dmitry (dio) Levashov |
| 267 | 267 | **/ |
| 268 | 268 | protected function _joinPath($dir, $name) { |
| 269 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
| 269 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $comps = $new_comps; |
| 319 | 319 | $path = implode('/', $comps); |
| 320 | 320 | if ($initial_slashes) { |
| 321 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
| 321 | + $path = str_repeat('/', $initial_slashes).$path; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if ($changeSep) { |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | **/ |
| 390 | 390 | protected function _inpath($path, $parent) { |
| 391 | 391 | $cwd = getcwd(); |
| 392 | - $real_path = $this->getFullPath($path, $cwd); |
|
| 392 | + $real_path = $this->getFullPath($path, $cwd); |
|
| 393 | 393 | $real_parent = $this->getFullPath($parent, $cwd); |
| 394 | 394 | if ($real_path && $real_parent) { |
| 395 | 395 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | $stat = array(); |
| 449 | 449 | return $stat; |
| 450 | 450 | } else { |
| 451 | - $stat['mime'] = 'symlink-broken'; |
|
| 451 | + $stat['mime'] = 'symlink-broken'; |
|
| 452 | 452 | $target = readlink($path); |
| 453 | 453 | $lstat = lstat($path); |
| 454 | 454 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | $fstat = stat($path); |
| 465 | 465 | $uid = $fstat['uid']; |
| 466 | 466 | $gid = $fstat['gid']; |
| 467 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
| 467 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
| 468 | 468 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 469 | 469 | } |
| 470 | 470 | |
@@ -474,8 +474,8 @@ discard block |
||
| 474 | 474 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
| 475 | 475 | } |
| 476 | 476 | //logical rights first |
| 477 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
| 478 | - $stat['write'] = is_writable($path)? null : false; |
|
| 477 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
| 478 | + $stat['write'] = is_writable($path) ? null : false; |
|
| 479 | 479 | |
| 480 | 480 | if (is_null($stat['read'])) { |
| 481 | 481 | $stat['size'] = $dir ? 0 : $size; |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | $dirItr = new ParentIterator( |
| 548 | 548 | new RecursiveDirectoryIterator($path, |
| 549 | 549 | FilesystemIterator::SKIP_DOTS | |
| 550 | - (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')? |
|
| 550 | + (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ? |
|
| 551 | 551 | RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0) |
| 552 | 552 | ) |
| 553 | 553 | ); |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | $br = true; |
| 634 | 634 | } else { |
| 635 | 635 | $_path = $fpath; |
| 636 | - $stat['mime'] = 'symlink-broken'; |
|
| 636 | + $stat['mime'] = 'symlink-broken'; |
|
| 637 | 637 | $target = readlink($_path); |
| 638 | 638 | $lstat = lstat($_path); |
| 639 | 639 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -658,13 +658,13 @@ discard block |
||
| 658 | 658 | if ($statOwner && !$linkreadable) { |
| 659 | 659 | $uid = $file->getOwner(); |
| 660 | 660 | $gid = $file->getGroup(); |
| 661 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
| 661 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
| 662 | 662 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | //logical rights first |
| 666 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
| 667 | - $stat['write'] = $file->isWritable()? null : false; |
|
| 666 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
| 667 | + $stat['write'] = $file->isWritable() ? null : false; |
|
| 668 | 668 | |
| 669 | 669 | if (is_null($stat['read'])) { |
| 670 | 670 | $stat['size'] = $dir ? 0 : $size; |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | if ($cache) { |
| 682 | 682 | $cache = $this->convEncOut($cache, false); |
| 683 | - foreach($cache as $d) { |
|
| 683 | + foreach ($cache as $d) { |
|
| 684 | 684 | $this->updateCache($d[0], $d[1]); |
| 685 | 685 | } |
| 686 | 686 | } |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | * @return resource|false |
| 697 | 697 | * @author Dmitry (dio) Levashov |
| 698 | 698 | **/ |
| 699 | - protected function _fopen($path, $mode='rb') { |
|
| 699 | + protected function _fopen($path, $mode = 'rb') { |
|
| 700 | 700 | return @fopen($path, $mode); |
| 701 | 701 | } |
| 702 | 702 | |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | * @return bool |
| 708 | 708 | * @author Dmitry (dio) Levashov |
| 709 | 709 | **/ |
| 710 | - protected function _fclose($fp, $path='') { |
|
| 710 | + protected function _fclose($fp, $path = '') { |
|
| 711 | 711 | return @fclose($fp); |
| 712 | 712 | } |
| 713 | 713 | |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | $path = $this->_joinPath($dir, $name); |
| 840 | 840 | |
| 841 | 841 | $meta = stream_get_meta_data($fp); |
| 842 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
| 842 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
| 843 | 843 | if ($uri && @is_file($uri)) { |
| 844 | 844 | fclose($fp); |
| 845 | 845 | $isCmdPaste = ($this->ARGS['cmd'] === 'paste'); |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * @return bool |
| 904 | 904 | **/ |
| 905 | 905 | protected function _chmod($path, $mode) { |
| 906 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
| 906 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
| 907 | 907 | $ret = @chmod($path, $modeOct); |
| 908 | 908 | $ret && clearstatcache(); |
| 909 | 909 | return $ret; |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | $src = $dir; |
| 1022 | 1022 | $name = basename($path); |
| 1023 | 1023 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 1024 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 1024 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 1025 | 1025 | } |
| 1026 | 1026 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
| 1027 | 1027 | if (file_exists($test) || is_link($test)) { |
@@ -1030,9 +1030,9 @@ discard block |
||
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | 1032 | if ($name !== '') { |
| 1033 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 1033 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 1034 | 1034 | |
| 1035 | - if (! @rename($src, $result)) { |
|
| 1035 | + if (!@rename($src, $result)) { |
|
| 1036 | 1036 | $this->delTree($dir); |
| 1037 | 1037 | return false; |
| 1038 | 1038 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | $dstDir = dirname($path); |
| 1041 | 1041 | $res = false; |
| 1042 | 1042 | $result = array(); |
| 1043 | - foreach($ls as $name) { |
|
| 1043 | + foreach ($ls as $name) { |
|
| 1044 | 1044 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
| 1045 | 1045 | if (is_dir($target)) { |
| 1046 | 1046 | $this->delTree($target); |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | new RecursiveDirectoryIterator($path, |
| 1127 | 1127 | FilesystemIterator::KEY_AS_PATHNAME | |
| 1128 | 1128 | FilesystemIterator::SKIP_DOTS | |
| 1129 | - (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')? |
|
| 1129 | + (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ? |
|
| 1130 | 1130 | RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0) |
| 1131 | 1131 | ), |
| 1132 | 1132 | array($this, 'localFileSystemSearchIteratorFilter') |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | $result = array(); |
| 1149 | 1149 | |
| 1150 | 1150 | if ($match) { |
| 1151 | - foreach($match as $p) { |
|
| 1151 | + foreach ($match as $p) { |
|
| 1152 | 1152 | $stat = $this->stat($p); |
| 1153 | 1153 | |
| 1154 | 1154 | if (!$stat) { // invalid links |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | $stat['path'] = $this->path($stat['hash']); |
| 1166 | 1166 | if ($this->URL && !isset($stat['url'])) { |
| 1167 | 1167 | $path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1)); |
| 1168 | - $stat['url'] = $this->URL . $path; |
|
| 1168 | + $stat['url'] = $this->URL.$path; |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | $result[] = $stat; |
@@ -1180,9 +1180,9 @@ discard block |
||
| 1180 | 1180 | |
| 1181 | 1181 | public function localFileSystemSearchIteratorFilter($file, $key, $iterator) { |
| 1182 | 1182 | if ($iterator->hasChildren()) { |
| 1183 | - return (bool)$this->attr($key, 'read', null, true); |
|
| 1183 | + return (bool) $this->attr($key, 'read', null, true); |
|
| 1184 | 1184 | } |
| 1185 | - return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false)? false : true; |
|
| 1185 | + return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false) ? false : true; |
|
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | } // END class |