@@ -5,19 +5,19 @@ |
||
| 5 | 5 | if (! class_exists('RecursiveCallbackFilterIterator', false)) { |
| 6 | 6 | class RecursiveCallbackFilterIterator extends RecursiveFilterIterator { |
| 7 | 7 | |
| 8 | - public function __construct ( RecursiveIterator $iterator, $callback ) { |
|
| 9 | - $this->callback = $callback; |
|
| 10 | - parent::__construct($iterator); |
|
| 11 | - } |
|
| 8 | + public function __construct ( RecursiveIterator $iterator, $callback ) { |
|
| 9 | + $this->callback = $callback; |
|
| 10 | + parent::__construct($iterator); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function accept () { |
|
| 14 | - $callback = $this->callback; |
|
| 15 | - return $callback(parent::current(), parent::key(), parent::getInnerIterator()); |
|
| 16 | - } |
|
| 13 | + public function accept () { |
|
| 14 | + $callback = $this->callback; |
|
| 15 | + return $callback(parent::current(), parent::key(), parent::getInnerIterator()); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function getChildren () { |
|
| 19 | - return new self($this->getInnerIterator()->getChildren(), $this->callback); |
|
| 20 | - } |
|
| 18 | + public function getChildren () { |
|
| 19 | + return new self($this->getInnerIterator()->getChildren(), $this->callback); |
|
| 20 | + } |
|
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
@@ -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(); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | // error |
| 220 | 220 | // cache to $_SESSION |
| 221 | - $sessionClose = true;; |
|
| 221 | + $sessionClose = true; ; |
|
| 222 | 222 | try { |
| 223 | 223 | $sessionStart = session_start(); |
| 224 | 224 | } catch (Exception $e) { |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @author Dmitry (dio) Levashov |
| 271 | 271 | **/ |
| 272 | 272 | protected function _joinPath($dir, $name) { |
| 273 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
| 273 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | $comps = $new_comps; |
| 323 | 323 | $path = implode('/', $comps); |
| 324 | 324 | if ($initial_slashes) { |
| 325 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
| 325 | + $path = str_repeat('/', $initial_slashes).$path; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | if ($changeSep) { |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | **/ |
| 394 | 394 | protected function _inpath($path, $parent) { |
| 395 | 395 | $cwd = getcwd(); |
| 396 | - $real_path = $this->getFullPath($path, $cwd); |
|
| 396 | + $real_path = $this->getFullPath($path, $cwd); |
|
| 397 | 397 | $real_parent = $this->getFullPath($parent, $cwd); |
| 398 | 398 | if ($real_path && $real_parent) { |
| 399 | 399 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $stat = array(); |
| 453 | 453 | return $stat; |
| 454 | 454 | } else { |
| 455 | - $stat['mime'] = 'symlink-broken'; |
|
| 455 | + $stat['mime'] = 'symlink-broken'; |
|
| 456 | 456 | $target = readlink($path); |
| 457 | 457 | $lstat = lstat($path); |
| 458 | 458 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | $fstat = stat($path); |
| 469 | 469 | $uid = $fstat['uid']; |
| 470 | 470 | $gid = $fstat['gid']; |
| 471 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
| 471 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
| 472 | 472 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 473 | 473 | } |
| 474 | 474 | |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
| 479 | 479 | } |
| 480 | 480 | //logical rights first |
| 481 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
| 482 | - $stat['write'] = is_writable($path)? null : false; |
|
| 481 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
| 482 | + $stat['write'] = is_writable($path) ? null : false; |
|
| 483 | 483 | |
| 484 | 484 | if (is_null($stat['read'])) { |
| 485 | 485 | $stat['size'] = $dir ? 0 : $size; |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | if (is_dir($path)) { |
| 551 | 551 | $path = strtr($path, array('[' => '\\[', ']' => '\\]', '*' => '\\*', '?' => '\\?')); |
| 552 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
| 552 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
| 553 | 553 | } |
| 554 | 554 | return false; |
| 555 | 555 | } |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | $br = true; |
| 631 | 631 | } else { |
| 632 | 632 | $_path = $fpath; |
| 633 | - $stat['mime'] = 'symlink-broken'; |
|
| 633 | + $stat['mime'] = 'symlink-broken'; |
|
| 634 | 634 | $target = readlink($_path); |
| 635 | 635 | $lstat = lstat($_path); |
| 636 | 636 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -655,13 +655,13 @@ discard block |
||
| 655 | 655 | if ($statOwner && !$linkreadable) { |
| 656 | 656 | $uid = $file->getOwner(); |
| 657 | 657 | $gid = $file->getGroup(); |
| 658 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
| 658 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
| 659 | 659 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | //logical rights first |
| 663 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
| 664 | - $stat['write'] = $file->isWritable()? null : false; |
|
| 663 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
| 664 | + $stat['write'] = $file->isWritable() ? null : false; |
|
| 665 | 665 | |
| 666 | 666 | if (is_null($stat['read'])) { |
| 667 | 667 | $stat['size'] = $dir ? 0 : $size; |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | if ($cache) { |
| 679 | 679 | $cache = $this->convEncOut($cache, false); |
| 680 | - foreach($cache as $d) { |
|
| 680 | + foreach ($cache as $d) { |
|
| 681 | 681 | $this->updateCache($d[0], $d[1]); |
| 682 | 682 | } |
| 683 | 683 | } |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | * @return resource|false |
| 694 | 694 | * @author Dmitry (dio) Levashov |
| 695 | 695 | **/ |
| 696 | - protected function _fopen($path, $mode='rb') { |
|
| 696 | + protected function _fopen($path, $mode = 'rb') { |
|
| 697 | 697 | return @fopen($path, $mode); |
| 698 | 698 | } |
| 699 | 699 | |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | * @return bool |
| 705 | 705 | * @author Dmitry (dio) Levashov |
| 706 | 706 | **/ |
| 707 | - protected function _fclose($fp, $path='') { |
|
| 707 | + protected function _fclose($fp, $path = '') { |
|
| 708 | 708 | return @fclose($fp); |
| 709 | 709 | } |
| 710 | 710 | |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | $path = $this->_joinPath($dir, $name); |
| 837 | 837 | |
| 838 | 838 | $meta = stream_get_meta_data($fp); |
| 839 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
| 839 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
| 840 | 840 | if ($uri && @is_file($uri)) { |
| 841 | 841 | fclose($fp); |
| 842 | 842 | $isCmdPaste = ($this->ARGS['cmd'] === 'paste'); |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | * @return bool |
| 901 | 901 | **/ |
| 902 | 902 | protected function _chmod($path, $mode) { |
| 903 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
| 903 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
| 904 | 904 | $ret = @chmod($path, $modeOct); |
| 905 | 905 | $ret && clearstatcache(); |
| 906 | 906 | return $ret; |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | $src = $dir; |
| 1019 | 1019 | $name = basename($path); |
| 1020 | 1020 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 1021 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 1021 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
| 1024 | 1024 | if (file_exists($test) || is_link($test)) { |
@@ -1027,9 +1027,9 @@ discard block |
||
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | if ($name !== '') { |
| 1030 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 1030 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 1031 | 1031 | |
| 1032 | - if (! @rename($src, $result)) { |
|
| 1032 | + if (!@rename($src, $result)) { |
|
| 1033 | 1033 | $this->delTree($dir); |
| 1034 | 1034 | return false; |
| 1035 | 1035 | } |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | $dstDir = dirname($path); |
| 1038 | 1038 | $res = false; |
| 1039 | 1039 | $result = array(); |
| 1040 | - foreach($ls as $name) { |
|
| 1040 | + foreach ($ls as $name) { |
|
| 1041 | 1041 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
| 1042 | 1042 | if (is_dir($target)) { |
| 1043 | 1043 | $this->delTree($target); |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | new RecursiveDirectoryIterator($path, |
| 1124 | 1124 | FilesystemIterator::KEY_AS_PATHNAME | |
| 1125 | 1125 | FilesystemIterator::SKIP_DOTS | |
| 1126 | - (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')? |
|
| 1126 | + (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ? |
|
| 1127 | 1127 | RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0) |
| 1128 | 1128 | ), |
| 1129 | 1129 | array($this, 'localFileSystemSearchIteratorFilter') |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | $result = array(); |
| 1146 | 1146 | |
| 1147 | 1147 | if ($match) { |
| 1148 | - foreach($match as $p) { |
|
| 1148 | + foreach ($match as $p) { |
|
| 1149 | 1149 | $stat = $this->stat($p); |
| 1150 | 1150 | |
| 1151 | 1151 | if (!$stat) { // invalid links |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | $stat['path'] = $this->path($stat['hash']); |
| 1163 | 1163 | if ($this->URL && !isset($stat['url'])) { |
| 1164 | 1164 | $path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1)); |
| 1165 | - $stat['url'] = $this->URL . $path; |
|
| 1165 | + $stat['url'] = $this->URL.$path; |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | $result[] = $stat; |
@@ -1177,9 +1177,9 @@ discard block |
||
| 1177 | 1177 | |
| 1178 | 1178 | public function localFileSystemSearchIteratorFilter($file, $key, $iterator) { |
| 1179 | 1179 | if ($iterator->hasChildren()) { |
| 1180 | - return (bool)$this->attr($key, 'read', null, true); |
|
| 1180 | + return (bool) $this->attr($key, 'read', null, true); |
|
| 1181 | 1181 | } |
| 1182 | - return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false)? false : true; |
|
| 1182 | + return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false) ? false : true; |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | } // END class |