@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | 'utf8fix' => false, |
| 300 | 300 | // й ё Й Ё Ø Å |
| 301 | 301 | 'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"), |
| 302 | - 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
| 302 | + 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
| 303 | 303 | ); |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | **/ |
| 595 | 595 | protected function configure() { |
| 596 | 596 | // set ARGS |
| 597 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
| 597 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
| 598 | 598 | // set thumbnails path |
| 599 | 599 | $path = $this->options['tmbPath']; |
| 600 | 600 | if ($path) { |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | // check 'statOwner' for command `chmod` |
| 627 | 627 | if (empty($this->options['statOwner'])) { |
| 628 | - $this->disabled[] ='chmod'; |
|
| 628 | + $this->disabled[] = 'chmod'; |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | // check 'mimeMap' |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | **/ |
| 750 | 750 | public function mount(array $opts) { |
| 751 | 751 | if (!isset($opts['path']) || $opts['path'] === '') { |
| 752 | - return $this->setError('Path undefined.');; |
|
| 752 | + return $this->setError('Path undefined.'); ; |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | $this->options = array_merge($this->options, $opts); |
@@ -768,14 +768,14 @@ discard block |
||
| 768 | 768 | $argInit = !empty($this->ARGS['init']); |
| 769 | 769 | |
| 770 | 770 | // session cache |
| 771 | - if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
| 771 | + if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
| 772 | 772 | $_SESSION[elFinder::$sessionCacheKey][$this->id] = array(); |
| 773 | 773 | } |
| 774 | 774 | $this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id]; |
| 775 | 775 | |
| 776 | 776 | // default file attribute |
| 777 | 777 | $this->defaults = array( |
| 778 | - 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
| 778 | + 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
| 779 | 779 | 'write' => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true, |
| 780 | 780 | 'locked' => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false, |
| 781 | 781 | 'hidden' => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false |
@@ -802,8 +802,8 @@ discard block |
||
| 802 | 802 | $this->access = $this->options['accessControl']; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - $this->today = mktime(0,0,0, date('m'), date('d'), date('Y')); |
|
| 806 | - $this->yesterday = $this->today-86400; |
|
| 805 | + $this->today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
| 806 | + $this->yesterday = $this->today - 86400; |
|
| 807 | 807 | |
| 808 | 808 | // debug($this->attributes); |
| 809 | 809 | if (!$this->init()) { |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | foreach ($mimecf as $line_num => $line) { |
| 903 | 903 | if (!preg_match('/^\s*#/', $line)) { |
| 904 | 904 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
| 905 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
| 905 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
| 906 | 906 | if (!isset(self::$mimetypes[$mime[$i]])) { |
| 907 | 907 | self::$mimetypes[$mime[$i]] = $mime[0]; |
| 908 | 908 | } |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | |
| 932 | 932 | if ($root['read']) { |
| 933 | 933 | // check startPath - path to open by default instead of root |
| 934 | - $startPath = $this->options['startPath']? $this->normpathCE($this->options['startPath']) : ''; |
|
| 934 | + $startPath = $this->options['startPath'] ? $this->normpathCE($this->options['startPath']) : ''; |
|
| 935 | 935 | if ($startPath) { |
| 936 | 936 | $start = $this->stat($startPath); |
| 937 | 937 | if (!empty($start) |
@@ -955,8 +955,8 @@ discard block |
||
| 955 | 955 | 'read' => false |
| 956 | 956 | )); |
| 957 | 957 | } |
| 958 | - $this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1; |
|
| 959 | - $this->tmbSize = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48; |
|
| 958 | + $this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1; |
|
| 959 | + $this->tmbSize = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48; |
|
| 960 | 960 | $this->URL = $this->options['URL']; |
| 961 | 961 | if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) { |
| 962 | 962 | $this->URL .= '/'; |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | |
| 1011 | 1011 | // fix sync interval |
| 1012 | 1012 | if ($this->options['syncMinMs'] !== 0) { |
| 1013 | - $this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs']? 'tsPlSleep' : 'lsPlSleep'] * 1000, intval($this->options['syncMinMs'])); |
|
| 1013 | + $this->options['syncMinMs'] = max($this->options[$this->options['syncChkAsTs'] ? 'tsPlSleep' : 'lsPlSleep']*1000, intval($this->options['syncMinMs'])); |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | return $this->mounted = true; |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | public function options($hash) { |
| 1115 | 1115 | $create = $createext = array(); |
| 1116 | 1116 | if (isset($this->archivers['create']) && is_array($this->archivers['create'])) { |
| 1117 | - foreach($this->archivers['create'] as $m => $v) { |
|
| 1117 | + foreach ($this->archivers['create'] as $m => $v) { |
|
| 1118 | 1118 | $create[] = $m; |
| 1119 | 1119 | $createext[$m] = $v['ext']; |
| 1120 | 1120 | } |
@@ -1135,7 +1135,7 @@ discard block |
||
| 1135 | 1135 | 'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(), |
| 1136 | 1136 | 'createext' => $createext |
| 1137 | 1137 | ), |
| 1138 | - 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(), |
|
| 1138 | + 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(), |
|
| 1139 | 1139 | 'syncChkAsTs' => intval($this->options['syncChkAsTs']), |
| 1140 | 1140 | 'syncMinMs' => intval($this->options['syncMinMs']) |
| 1141 | 1141 | ); |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | * @author Naoki Sawada |
| 1150 | 1150 | */ |
| 1151 | 1151 | public function getOption($name) { |
| 1152 | - return isset($this->options[$name])? $this->options[$name] : null; |
|
| 1152 | + return isset($this->options[$name]) ? $this->options[$name] : null; |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | /** |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | */ |
| 1162 | 1162 | public function getOptionsPlugin($name = '') { |
| 1163 | 1163 | if ($name) { |
| 1164 | - return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array(); |
|
| 1164 | + return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array(); |
|
| 1165 | 1165 | } else { |
| 1166 | 1166 | return $this->options['plugin']; |
| 1167 | 1167 | } |
@@ -1295,7 +1295,7 @@ discard block |
||
| 1295 | 1295 | $file = $this->stat($path); |
| 1296 | 1296 | |
| 1297 | 1297 | if ($isRoot) { |
| 1298 | - $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(); |
|
| 1298 | + $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(); |
|
| 1299 | 1299 | $file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON |
| 1300 | 1300 | } |
| 1301 | 1301 | |
@@ -1310,7 +1310,7 @@ discard block |
||
| 1310 | 1310 | * @return array|false |
| 1311 | 1311 | * @author Dmitry (dio) Levashov |
| 1312 | 1312 | **/ |
| 1313 | - public function dir($hash, $resolveLink=false) { |
|
| 1313 | + public function dir($hash, $resolveLink = false) { |
|
| 1314 | 1314 | if (($dir = $this->file($hash)) == false) { |
| 1315 | 1315 | return $this->setError(elFinder::ERROR_DIR_NOT_FOUND); |
| 1316 | 1316 | } |
@@ -1374,14 +1374,14 @@ discard block |
||
| 1374 | 1374 | * @return array|false |
| 1375 | 1375 | * @author Dmitry (dio) Levashov |
| 1376 | 1376 | **/ |
| 1377 | - public function tree($hash='', $deep=0, $exclude='') { |
|
| 1377 | + public function tree($hash = '', $deep = 0, $exclude = '') { |
|
| 1378 | 1378 | $path = $hash ? $this->decode($hash) : $this->root; |
| 1379 | 1379 | |
| 1380 | 1380 | if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') { |
| 1381 | 1381 | return false; |
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | - $dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null); |
|
| 1384 | + $dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null); |
|
| 1385 | 1385 | array_unshift($dirs, $dir); |
| 1386 | 1386 | return $dirs; |
| 1387 | 1387 | } |
@@ -1611,7 +1611,7 @@ discard block |
||
| 1611 | 1611 | * @return array|false |
| 1612 | 1612 | * @author Dmitry (dio) Levashov |
| 1613 | 1613 | **/ |
| 1614 | - public function duplicate($hash, $suffix='copy') { |
|
| 1614 | + public function duplicate($hash, $suffix = 'copy') { |
|
| 1615 | 1615 | if ($this->commandDisabled('duplicate')) { |
| 1616 | 1616 | return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED); |
| 1617 | 1617 | } |
@@ -1687,7 +1687,7 @@ discard block |
||
| 1687 | 1687 | |
| 1688 | 1688 | if ($file) { // file exists |
| 1689 | 1689 | // check POST data `overwrite` for 3rd party uploader |
| 1690 | - $overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
| 1690 | + $overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
| 1691 | 1691 | if ($overwrite) { |
| 1692 | 1692 | if (!$file['write']) { |
| 1693 | 1693 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
@@ -1758,7 +1758,7 @@ discard block |
||
| 1758 | 1758 | if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) { |
| 1759 | 1759 | return $rmSrc |
| 1760 | 1760 | ? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test)) |
| 1761 | - : $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
| 1761 | + : $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
| 1762 | 1762 | } |
| 1763 | 1763 | |
| 1764 | 1764 | $test = $this->joinPathCE($destination, $name); |
@@ -1921,7 +1921,7 @@ discard block |
||
| 1921 | 1921 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
| 1922 | 1922 | } |
| 1923 | 1923 | $this->clearcache(); |
| 1924 | - $this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir; |
|
| 1924 | + $this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir; |
|
| 1925 | 1925 | |
| 1926 | 1926 | if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) { |
| 1927 | 1927 | if (is_array($path)) { |
@@ -1979,9 +1979,9 @@ discard block |
||
| 1979 | 1979 | if ($name === '') { |
| 1980 | 1980 | $name = count($files) == 1 ? $files[0] : 'Archive'; |
| 1981 | 1981 | } else { |
| 1982 | - $name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name)); |
|
| 1982 | + $name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name)); |
|
| 1983 | 1983 | } |
| 1984 | - $name .='.' . $archiver['ext']; |
|
| 1984 | + $name .= '.'.$archiver['ext']; |
|
| 1985 | 1985 | $name = $this->uniqueName($dir, $name, ''); |
| 1986 | 1986 | $this->clearcache(); |
| 1987 | 1987 | return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false; |
@@ -2020,7 +2020,7 @@ discard block |
||
| 2020 | 2020 | |
| 2021 | 2021 | $path = $this->decode($hash); |
| 2022 | 2022 | |
| 2023 | - $work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path); |
|
| 2023 | + $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path); |
|
| 2024 | 2024 | |
| 2025 | 2025 | if (!$work_path || !is_writable($work_path)) { |
| 2026 | 2026 | if ($work_path && $path !== $work_path && is_file($work_path)) { |
@@ -2035,7 +2035,7 @@ discard block |
||
| 2035 | 2035 | } |
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | - switch($mode) { |
|
| 2038 | + switch ($mode) { |
|
| 2039 | 2039 | |
| 2040 | 2040 | case 'propresize': |
| 2041 | 2041 | $result = $this->imgResize($work_path, $width, $height, true, true, null, $jpgQuality); |
@@ -2131,7 +2131,7 @@ discard block |
||
| 2131 | 2131 | } |
| 2132 | 2132 | return ($q === '' || $this->commandDisabled('search')) |
| 2133 | 2133 | ? array() |
| 2134 | - : $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes); |
|
| 2134 | + : $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | 2137 | /** |
@@ -2203,9 +2203,9 @@ discard block |
||
| 2203 | 2203 | $path = ltrim($path, $this->separator); |
| 2204 | 2204 | $dirs = explode($this->separator, $path); |
| 2205 | 2205 | array_pop($dirs); |
| 2206 | - foreach($dirs as $dir) { |
|
| 2206 | + foreach ($dirs as $dir) { |
|
| 2207 | 2207 | $targetPath = $this->joinPathCE($base, $dir); |
| 2208 | - if (! $_realpath = $this->realpath($this->encode($targetPath))) { |
|
| 2208 | + if (!$_realpath = $this->realpath($this->encode($targetPath))) { |
|
| 2209 | 2209 | if ($stat = $this->mkdir($targetHash, $dir)) { |
| 2210 | 2210 | $result['added'][] = $stat; |
| 2211 | 2211 | $targetHash = $stat['hash']; |
@@ -2272,7 +2272,7 @@ discard block |
||
| 2272 | 2272 | * @author Naoki Sawada |
| 2273 | 2273 | **/ |
| 2274 | 2274 | protected function dirnameCE($path) { |
| 2275 | - return (!$this->encoding)? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
| 2275 | + return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
| 2276 | 2276 | } |
| 2277 | 2277 | |
| 2278 | 2278 | /** |
@@ -2283,7 +2283,7 @@ discard block |
||
| 2283 | 2283 | * @author Naoki Sawada |
| 2284 | 2284 | **/ |
| 2285 | 2285 | protected function basenameCE($path) { |
| 2286 | - return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
| 2286 | + return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
| 2287 | 2287 | } |
| 2288 | 2288 | |
| 2289 | 2289 | /** |
@@ -2296,7 +2296,7 @@ discard block |
||
| 2296 | 2296 | * @author Naoki Sawada |
| 2297 | 2297 | **/ |
| 2298 | 2298 | protected function joinPathCE($dir, $name) { |
| 2299 | - return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
| 2299 | + return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
| 2300 | 2300 | } |
| 2301 | 2301 | |
| 2302 | 2302 | /** |
@@ -2307,7 +2307,7 @@ discard block |
||
| 2307 | 2307 | * @author Naoki Sawada |
| 2308 | 2308 | **/ |
| 2309 | 2309 | protected function normpathCE($path) { |
| 2310 | - return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
| 2310 | + return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
| 2311 | 2311 | } |
| 2312 | 2312 | |
| 2313 | 2313 | /** |
@@ -2318,7 +2318,7 @@ discard block |
||
| 2318 | 2318 | * @author Naoki Sawada |
| 2319 | 2319 | **/ |
| 2320 | 2320 | protected function relpathCE($path) { |
| 2321 | - return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
| 2321 | + return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
| 2322 | 2322 | } |
| 2323 | 2323 | |
| 2324 | 2324 | /** |
@@ -2329,7 +2329,7 @@ discard block |
||
| 2329 | 2329 | * @author Naoki Sawada |
| 2330 | 2330 | **/ |
| 2331 | 2331 | protected function abspathCE($path) { |
| 2332 | - return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
| 2332 | + return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
| 2333 | 2333 | } |
| 2334 | 2334 | |
| 2335 | 2335 | /** |
@@ -2341,7 +2341,7 @@ discard block |
||
| 2341 | 2341 | * @author Naoki Sawada |
| 2342 | 2342 | **/ |
| 2343 | 2343 | protected function inpathCE($path, $parent) { |
| 2344 | - return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
| 2344 | + return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
| 2345 | 2345 | } |
| 2346 | 2346 | |
| 2347 | 2347 | /** |
@@ -2352,8 +2352,8 @@ discard block |
||
| 2352 | 2352 | * @return resource|false |
| 2353 | 2353 | * @author Naoki Sawada |
| 2354 | 2354 | **/ |
| 2355 | - protected function fopenCE($path, $mode='rb') { |
|
| 2356 | - return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
| 2355 | + protected function fopenCE($path, $mode = 'rb') { |
|
| 2356 | + return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
| 2357 | 2357 | } |
| 2358 | 2358 | |
| 2359 | 2359 | /** |
@@ -2364,8 +2364,8 @@ discard block |
||
| 2364 | 2364 | * @return bool |
| 2365 | 2365 | * @author Naoki Sawada |
| 2366 | 2366 | **/ |
| 2367 | - protected function fcloseCE($fp, $path='') { |
|
| 2368 | - return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
| 2367 | + protected function fcloseCE($fp, $path = '') { |
|
| 2368 | + return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
| 2369 | 2369 | } |
| 2370 | 2370 | |
| 2371 | 2371 | /** |
@@ -2380,7 +2380,7 @@ discard block |
||
| 2380 | 2380 | * @author Naoki Sawada |
| 2381 | 2381 | **/ |
| 2382 | 2382 | protected function saveCE($fp, $dir, $name, $stat) { |
| 2383 | - return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
| 2383 | + return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
| 2384 | 2384 | } |
| 2385 | 2385 | |
| 2386 | 2386 | /** |
@@ -2392,7 +2392,7 @@ discard block |
||
| 2392 | 2392 | **/ |
| 2393 | 2393 | protected function subdirsCE($path) { |
| 2394 | 2394 | if (!isset($this->subdirsCache[$path])) { |
| 2395 | - $this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
| 2395 | + $this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
| 2396 | 2396 | } |
| 2397 | 2397 | return $this->subdirsCache[$path]; |
| 2398 | 2398 | } |
@@ -2405,7 +2405,7 @@ discard block |
||
| 2405 | 2405 | * @author Naoki Sawada |
| 2406 | 2406 | **/ |
| 2407 | 2407 | protected function scandirCE($path) { |
| 2408 | - return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
| 2408 | + return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
| 2409 | 2409 | } |
| 2410 | 2410 | |
| 2411 | 2411 | /** |
@@ -2418,7 +2418,7 @@ discard block |
||
| 2418 | 2418 | * @author Naoki Sawada |
| 2419 | 2419 | **/ |
| 2420 | 2420 | protected function symlinkCE($source, $targetDir, $name) { |
| 2421 | - return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
| 2421 | + return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
| 2422 | 2422 | } |
| 2423 | 2423 | |
| 2424 | 2424 | /***************** paths *******************/ |
@@ -2437,7 +2437,7 @@ discard block |
||
| 2437 | 2437 | // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root |
| 2438 | 2438 | $p = $this->relpathCE($path); |
| 2439 | 2439 | // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt |
| 2440 | - if ($p === '') { |
|
| 2440 | + if ($p === '') { |
|
| 2441 | 2441 | $p = DIRECTORY_SEPARATOR; |
| 2442 | 2442 | } |
| 2443 | 2443 | |
@@ -2470,7 +2470,7 @@ discard block |
||
| 2470 | 2470 | // TODO uncrypt hash and return path |
| 2471 | 2471 | $path = $this->uncrypt($h); |
| 2472 | 2472 | // append ROOT to path after it was cut in encode |
| 2473 | - return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
| 2473 | + return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
| 2474 | 2474 | } |
| 2475 | 2475 | } |
| 2476 | 2476 | |
@@ -2530,21 +2530,21 @@ discard block |
||
| 2530 | 2530 | * @author Dmitry (dio) Levashov |
| 2531 | 2531 | **/ |
| 2532 | 2532 | public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) { |
| 2533 | - $ext = ''; |
|
| 2533 | + $ext = ''; |
|
| 2534 | 2534 | |
| 2535 | 2535 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 2536 | 2536 | $ext = '.'.$m[1]; |
| 2537 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 2537 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 2538 | 2538 | } |
| 2539 | 2539 | |
| 2540 | 2540 | if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) { |
| 2541 | - $i = (int)$m[2]; |
|
| 2542 | - $name = substr($name, 0, strlen($name)-strlen($m[2])); |
|
| 2541 | + $i = (int) $m[2]; |
|
| 2542 | + $name = substr($name, 0, strlen($name) - strlen($m[2])); |
|
| 2543 | 2543 | } else { |
| 2544 | 2544 | $i = $start; |
| 2545 | 2545 | $name .= $suffix; |
| 2546 | 2546 | } |
| 2547 | - $max = $i+100000; |
|
| 2547 | + $max = $i + 100000; |
|
| 2548 | 2548 | |
| 2549 | 2549 | while ($i <= $max) { |
| 2550 | 2550 | $n = $name.($i > 0 ? $i : '').$ext; |
@@ -2568,7 +2568,7 @@ discard block |
||
| 2568 | 2568 | * @author Naoki Sawada |
| 2569 | 2569 | */ |
| 2570 | 2570 | public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') { |
| 2571 | - return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
| 2571 | + return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
| 2572 | 2572 | } |
| 2573 | 2573 | |
| 2574 | 2574 | /** |
@@ -2581,7 +2581,7 @@ discard block |
||
| 2581 | 2581 | * @author Naoki Sawada |
| 2582 | 2582 | */ |
| 2583 | 2583 | public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') { |
| 2584 | - return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
| 2584 | + return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
| 2585 | 2585 | } |
| 2586 | 2586 | |
| 2587 | 2587 | /** |
@@ -2601,7 +2601,7 @@ discard block |
||
| 2601 | 2601 | } |
| 2602 | 2602 | if (is_array($var)) { |
| 2603 | 2603 | $_ret = array(); |
| 2604 | - foreach($var as $_k => $_v) { |
|
| 2604 | + foreach ($var as $_k => $_v) { |
|
| 2605 | 2605 | $_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_'); |
| 2606 | 2606 | } |
| 2607 | 2607 | $var = $_ret; |
@@ -2613,7 +2613,7 @@ discard block |
||
| 2613 | 2613 | $_var = str_replace('?', $unknown, $_var); |
| 2614 | 2614 | } |
| 2615 | 2615 | } |
| 2616 | - if ($_var !== false) { |
|
| 2616 | + if ($_var !== false) { |
|
| 2617 | 2617 | $var = $_var; |
| 2618 | 2618 | } |
| 2619 | 2619 | } |
@@ -2640,7 +2640,7 @@ discard block |
||
| 2640 | 2640 | |
| 2641 | 2641 | $key = ''; |
| 2642 | 2642 | if ($path !== '') { |
| 2643 | - $key = $this->id . '#' . $path; |
|
| 2643 | + $key = $this->id.'#'.$path; |
|
| 2644 | 2644 | if (isset($cache[$key])) { |
| 2645 | 2645 | return $cache[$key]; |
| 2646 | 2646 | } |
@@ -2672,7 +2672,7 @@ discard block |
||
| 2672 | 2672 | if ($work = $this->getTempFile()) { |
| 2673 | 2673 | if ($wfp = fopen($work, 'wb')) { |
| 2674 | 2674 | if ($fp = $this->_fopen($path)) { |
| 2675 | - while(!feof($fp)) { |
|
| 2675 | + while (!feof($fp)) { |
|
| 2676 | 2676 | fwrite($wfp, fread($fp, 8192)); |
| 2677 | 2677 | } |
| 2678 | 2678 | $this->_fclose($fp, $path); |
@@ -2716,7 +2716,7 @@ discard block |
||
| 2716 | 2716 | @set_time_limit(30); |
| 2717 | 2717 | $stat = $this->stat($this->convEncOut($p)); |
| 2718 | 2718 | $this->convEncIn(); |
| 2719 | - ($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p); |
|
| 2719 | + ($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p); |
|
| 2720 | 2720 | } |
| 2721 | 2721 | return $this->_rmdir($localpath); |
| 2722 | 2722 | } |
@@ -2733,7 +2733,7 @@ discard block |
||
| 2733 | 2733 | * @return bool |
| 2734 | 2734 | * @author Dmitry (dio) Levashov |
| 2735 | 2735 | **/ |
| 2736 | - protected function attr($path, $name, $val=null, $isDir=null) { |
|
| 2736 | + protected function attr($path, $name, $val = null, $isDir = null) { |
|
| 2737 | 2737 | if (!isset($this->defaults[$name])) { |
| 2738 | 2738 | return false; |
| 2739 | 2739 | } |
@@ -2765,7 +2765,7 @@ discard block |
||
| 2765 | 2765 | } |
| 2766 | 2766 | } |
| 2767 | 2767 | |
| 2768 | - return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm; |
|
| 2768 | + return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm; |
|
| 2769 | 2769 | } |
| 2770 | 2770 | |
| 2771 | 2771 | /** |
@@ -2809,7 +2809,7 @@ discard block |
||
| 2809 | 2809 | protected function allowPutMime($mime) { |
| 2810 | 2810 | // logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order |
| 2811 | 2811 | $allow = $this->mimeAccepted($mime, $this->uploadAllow, null); |
| 2812 | - $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
| 2812 | + $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
| 2813 | 2813 | $res = true; // default to allow |
| 2814 | 2814 | if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny' |
| 2815 | 2815 | $res = false; // default is deny |
@@ -2843,7 +2843,7 @@ discard block |
||
| 2843 | 2843 | $this->sessionCache['rootstat'] = array(); |
| 2844 | 2844 | } |
| 2845 | 2845 | //if (empty($this->ARGS['reload']) || empty($this->ARGS['target']) || strpos($this->ARGS['target'], $this->id) !== 0) { |
| 2846 | - if (! $this->isMyReload()) { |
|
| 2846 | + if (!$this->isMyReload()) { |
|
| 2847 | 2847 | // need $path as key for netmount/netunmount |
| 2848 | 2848 | if (isset($this->sessionCache['rootstat'][$rootKey])) { |
| 2849 | 2849 | if ($ret = elFinder::sessionDataDecode($this->sessionCache['rootstat'][$rootKey], 'array')) { |
@@ -2883,10 +2883,10 @@ discard block |
||
| 2883 | 2883 | if ($this->rootName) { |
| 2884 | 2884 | $stat['name'] = $this->rootName; |
| 2885 | 2885 | } |
| 2886 | - if (! empty($this->options['icon'])) { |
|
| 2886 | + if (!empty($this->options['icon'])) { |
|
| 2887 | 2887 | $stat['icon'] = $this->options['icon']; |
| 2888 | 2888 | } |
| 2889 | - if (! empty($this->options['rootCssClass'])) { |
|
| 2889 | + if (!empty($this->options['rootCssClass'])) { |
|
| 2890 | 2890 | $stat['csscls'] = $this->options['rootCssClass']; |
| 2891 | 2891 | } |
| 2892 | 2892 | } else { |
@@ -2934,7 +2934,7 @@ discard block |
||
| 2934 | 2934 | // lock when parent directory is not writable |
| 2935 | 2935 | if (!isset($stat['locked'])) { |
| 2936 | 2936 | $parent = $this->dirnameCE($path); |
| 2937 | - $pstat = isset($this->cache[$parent])? $this->cache[$parent] : array(); |
|
| 2937 | + $pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array(); |
|
| 2938 | 2938 | if (isset($pstat['write']) && !$pstat['write']) { |
| 2939 | 2939 | $stat['locked'] = true; |
| 2940 | 2940 | } |
@@ -2992,7 +2992,7 @@ discard block |
||
| 2992 | 2992 | } |
| 2993 | 2993 | if (!isset($stat['url']) && $this->URL && $this->encoding) { |
| 2994 | 2994 | $_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1)); |
| 2995 | - $stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true))); |
|
| 2995 | + $stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true))); |
|
| 2996 | 2996 | } |
| 2997 | 2997 | } else { |
| 2998 | 2998 | if ($isDir) { |
@@ -3115,7 +3115,7 @@ discard block |
||
| 3115 | 3115 | foreach ($mimecf as $line_num => $line) { |
| 3116 | 3116 | if (!preg_match('/^\s*#/', $line)) { |
| 3117 | 3117 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
| 3118 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
| 3118 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
| 3119 | 3119 | if (!isset(elFinderVolumeDriver::$mimetypes[$mime[$i]])) { |
| 3120 | 3120 | elFinderVolumeDriver::$mimetypes[$mime[$i]] = $mime[0]; |
| 3121 | 3121 | } |
@@ -3221,10 +3221,10 @@ discard block |
||
| 3221 | 3221 | } |
| 3222 | 3222 | |
| 3223 | 3223 | protected function isMyReload($target = '', $ARGtarget = '') { |
| 3224 | - if (! empty($this->ARGS['reload'])) { |
|
| 3224 | + if (!empty($this->ARGS['reload'])) { |
|
| 3225 | 3225 | if ($ARGtarget === '') { |
| 3226 | - $ARGtarget = isset($this->ARGS['target'])? $this->ARGS['target'] |
|
| 3227 | - : ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1)? |
|
| 3226 | + $ARGtarget = isset($this->ARGS['target']) ? $this->ARGS['target'] |
|
| 3227 | + : ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1) ? |
|
| 3228 | 3228 | $this->ARGS['targets'][0] : ''); |
| 3229 | 3229 | } |
| 3230 | 3230 | if ($ARGtarget !== '') { |
@@ -3273,7 +3273,7 @@ discard block |
||
| 3273 | 3273 | * @return array |
| 3274 | 3274 | * @author Dmitry (dio) Levashov |
| 3275 | 3275 | **/ |
| 3276 | - protected function gettree($path, $deep, $exclude='') { |
|
| 3276 | + protected function gettree($path, $deep, $exclude = '') { |
|
| 3277 | 3277 | $dirs = array(); |
| 3278 | 3278 | |
| 3279 | 3279 | !isset($this->dirsCache[$path]) && $this->cacheDir($path); |
@@ -3284,7 +3284,7 @@ discard block |
||
| 3284 | 3284 | if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') { |
| 3285 | 3285 | $dirs[] = $stat; |
| 3286 | 3286 | if ($deep > 0 && !empty($stat['dirs'])) { |
| 3287 | - $dirs = array_merge($dirs, $this->gettree($p, $deep-1)); |
|
| 3287 | + $dirs = array_merge($dirs, $this->gettree($p, $deep - 1)); |
|
| 3288 | 3288 | } |
| 3289 | 3289 | } |
| 3290 | 3290 | } |
@@ -3304,7 +3304,7 @@ discard block |
||
| 3304 | 3304 | protected function doSearch($path, $q, $mimes) { |
| 3305 | 3305 | $result = array(); |
| 3306 | 3306 | |
| 3307 | - foreach($this->scandirCE($path) as $p) { |
|
| 3307 | + foreach ($this->scandirCE($path) as $p) { |
|
| 3308 | 3308 | @set_time_limit(30); |
| 3309 | 3309 | $stat = $this->stat($p); |
| 3310 | 3310 | |
@@ -3325,7 +3325,7 @@ discard block |
||
| 3325 | 3325 | if ($this->encoding) { |
| 3326 | 3326 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
| 3327 | 3327 | } |
| 3328 | - $stat['url'] = $this->URL . $path; |
|
| 3328 | + $stat['url'] = $this->URL.$path; |
|
| 3329 | 3329 | } |
| 3330 | 3330 | |
| 3331 | 3331 | $result[] = $stat; |
@@ -3359,7 +3359,7 @@ discard block |
||
| 3359 | 3359 | if (!$this->inpathCE($target, $this->root)) { |
| 3360 | 3360 | return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK); |
| 3361 | 3361 | } |
| 3362 | - $stat = $this->stat($target); |
|
| 3362 | + $stat = $this->stat($target); |
|
| 3363 | 3363 | $this->clearcache(); |
| 3364 | 3364 | return $stat && $this->symlinkCE($target, $dst, $name) |
| 3365 | 3365 | ? $this->joinPathCE($dst, $name) |
@@ -3640,15 +3640,15 @@ discard block |
||
| 3640 | 3640 | } |
| 3641 | 3641 | |
| 3642 | 3642 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
| 3643 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
| 3644 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
| 3643 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
| 3644 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
| 3645 | 3645 | } else { |
| 3646 | 3646 | |
| 3647 | 3647 | if ($this->options['tmbCrop']) { |
| 3648 | 3648 | |
| 3649 | 3649 | $result = $tmb; |
| 3650 | 3650 | /* Resize and crop if image bigger than thumbnail */ |
| 3651 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
| 3651 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
| 3652 | 3652 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
| 3653 | 3653 | } |
| 3654 | 3654 | |
@@ -3665,7 +3665,7 @@ discard block |
||
| 3665 | 3665 | } |
| 3666 | 3666 | |
| 3667 | 3667 | if ($result) { |
| 3668 | - $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
| 3668 | + $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
| 3669 | 3669 | } |
| 3670 | 3670 | } |
| 3671 | 3671 | |
@@ -3711,18 +3711,18 @@ discard block |
||
| 3711 | 3711 | /* Resizing by biggest side */ |
| 3712 | 3712 | if ($resizeByBiggerSide) { |
| 3713 | 3713 | if ($orig_w > $orig_h) { |
| 3714 | - $size_h = round($orig_h * $width / $orig_w); |
|
| 3714 | + $size_h = round($orig_h*$width/$orig_w); |
|
| 3715 | 3715 | $size_w = $width; |
| 3716 | 3716 | } else { |
| 3717 | - $size_w = round($orig_w * $height / $orig_h); |
|
| 3717 | + $size_w = round($orig_w*$height/$orig_h); |
|
| 3718 | 3718 | $size_h = $height; |
| 3719 | 3719 | } |
| 3720 | 3720 | } else { |
| 3721 | 3721 | if ($orig_w > $orig_h) { |
| 3722 | - $size_w = round($orig_w * $height / $orig_h); |
|
| 3722 | + $size_w = round($orig_w*$height/$orig_h); |
|
| 3723 | 3723 | $size_h = $height; |
| 3724 | 3724 | } else { |
| 3725 | - $size_h = round($orig_h * $width / $orig_w); |
|
| 3725 | + $size_h = round($orig_h*$width/$orig_w); |
|
| 3726 | 3726 | $size_w = $width; |
| 3727 | 3727 | } |
| 3728 | 3728 | } |
@@ -3740,7 +3740,7 @@ discard block |
||
| 3740 | 3740 | // Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb |
| 3741 | 3741 | // resize bench: http://app-mgng.rhcloud.com/9 |
| 3742 | 3742 | // resize sample: http://www.dylanbeattie.net/magick/filters/result.html |
| 3743 | - $filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
| 3743 | + $filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
| 3744 | 3744 | |
| 3745 | 3745 | $ani = ($img->getNumberImages() > 1); |
| 3746 | 3746 | if ($ani && is_null($destformat)) { |
@@ -3765,11 +3765,11 @@ discard block |
||
| 3765 | 3765 | break; |
| 3766 | 3766 | |
| 3767 | 3767 | case 'gd': |
| 3768 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
| 3768 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
| 3769 | 3769 | |
| 3770 | - if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
| 3770 | + if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
| 3771 | 3771 | |
| 3772 | - $this->gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
| 3772 | + $this->gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
| 3773 | 3773 | |
| 3774 | 3774 | if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) { |
| 3775 | 3775 | return false; |
@@ -3850,11 +3850,11 @@ discard block |
||
| 3850 | 3850 | break; |
| 3851 | 3851 | |
| 3852 | 3852 | case 'gd': |
| 3853 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
| 3853 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
| 3854 | 3854 | |
| 3855 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 3855 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 3856 | 3856 | |
| 3857 | - $this->gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
| 3857 | + $this->gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
| 3858 | 3858 | |
| 3859 | 3859 | $size_w = $width; |
| 3860 | 3860 | $size_h = $height; |
@@ -3905,8 +3905,8 @@ discard block |
||
| 3905 | 3905 | $result = false; |
| 3906 | 3906 | |
| 3907 | 3907 | /* Coordinates for image over square aligning */ |
| 3908 | - $y = ceil(abs($height - $s[1]) / 2); |
|
| 3909 | - $x = ceil(abs($width - $s[0]) / 2); |
|
| 3908 | + $y = ceil(abs($height - $s[1])/2); |
|
| 3909 | + $x = ceil(abs($width - $s[0])/2); |
|
| 3910 | 3910 | |
| 3911 | 3911 | if (!$jpgQuality) { |
| 3912 | 3912 | $jpgQuality = $this->options['jpgQuality']; |
@@ -3930,7 +3930,7 @@ discard block |
||
| 3930 | 3930 | $gif->newImage($width, $height, new ImagickPixel($bgcolor)); |
| 3931 | 3931 | $gif->setImageColorspace($img->getImageColorspace()); |
| 3932 | 3932 | $gif->setImageFormat('gif'); |
| 3933 | - $gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
| 3933 | + $gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
| 3934 | 3934 | $gif->setImageDelay($img->getImageDelay()); |
| 3935 | 3935 | $gif->setImageIterations($img->getImageIterations()); |
| 3936 | 3936 | $img1->addImage($gif); |
@@ -3945,7 +3945,7 @@ discard block |
||
| 3945 | 3945 | $img1 = new Imagick(); |
| 3946 | 3946 | $img1->newImage($width, $height, new ImagickPixel($bgcolor)); |
| 3947 | 3947 | $img1->setImageColorspace($img->getImageColorspace()); |
| 3948 | - $img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
| 3948 | + $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
| 3949 | 3949 | $result = $this->imagickImage($img, $path, $destformat, $jpgQuality); |
| 3950 | 3950 | } |
| 3951 | 3951 | |
@@ -3956,11 +3956,11 @@ discard block |
||
| 3956 | 3956 | break; |
| 3957 | 3957 | |
| 3958 | 3958 | case 'gd': |
| 3959 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
| 3959 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
| 3960 | 3960 | |
| 3961 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 3961 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 3962 | 3962 | |
| 3963 | - $this->gdImageBackground($tmp,$bgcolor); |
|
| 3963 | + $this->gdImageBackground($tmp, $bgcolor); |
|
| 3964 | 3964 | |
| 3965 | 3965 | if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) { |
| 3966 | 3966 | return false; |
@@ -3992,15 +3992,15 @@ discard block |
||
| 3992 | 3992 | * @author Troex Nevelin |
| 3993 | 3993 | **/ |
| 3994 | 3994 | protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null, $jpgQuality = null) { |
| 3995 | - if (($s = @getimagesize($path)) == false || $degree % 360 === 0) { |
|
| 3995 | + if (($s = @getimagesize($path)) == false || $degree%360 === 0) { |
|
| 3996 | 3996 | return false; |
| 3997 | 3997 | } |
| 3998 | 3998 | |
| 3999 | 3999 | $result = false; |
| 4000 | 4000 | |
| 4001 | 4001 | // try lossless rotate |
| 4002 | - if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
| 4003 | - $count = ($degree / 90) % 4; |
|
| 4002 | + if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
| 4003 | + $count = ($degree/90)%4; |
|
| 4004 | 4004 | $exiftran = array( |
| 4005 | 4005 | 1 => '-9', |
| 4006 | 4006 | 2 => '-1', |
@@ -4016,7 +4016,7 @@ discard block |
||
| 4016 | 4016 | 'exiftran -i '.$exiftran[$count].' '.$path, |
| 4017 | 4017 | 'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath |
| 4018 | 4018 | ); |
| 4019 | - foreach($cmds as $cmd) { |
|
| 4019 | + foreach ($cmds as $cmd) { |
|
| 4020 | 4020 | if ($this->procExec($cmd) === 0) { |
| 4021 | 4021 | $result = true; |
| 4022 | 4022 | break; |
@@ -4056,12 +4056,12 @@ discard block |
||
| 4056 | 4056 | break; |
| 4057 | 4057 | |
| 4058 | 4058 | case 'gd': |
| 4059 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
| 4059 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
| 4060 | 4060 | |
| 4061 | 4061 | $degree = 360 - $degree; |
| 4062 | 4062 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
| 4063 | 4063 | $bgcolor = imagecolorallocate($img, $r, $g, $b); |
| 4064 | - $tmp = imageRotate($img, $degree, (int)$bgcolor); |
|
| 4064 | + $tmp = imageRotate($img, $degree, (int) $bgcolor); |
|
| 4065 | 4065 | |
| 4066 | 4066 | $result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality); |
| 4067 | 4067 | |
@@ -4086,11 +4086,11 @@ discard block |
||
| 4086 | 4086 | * @return int exit code |
| 4087 | 4087 | * @author Alexey Sukhotin |
| 4088 | 4088 | **/ |
| 4089 | - protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
| 4089 | + protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
| 4090 | 4090 | |
| 4091 | 4091 | $descriptorspec = array( |
| 4092 | - 0 => array("pipe", "r"), // stdin |
|
| 4093 | - 1 => array("pipe", "w"), // stdout |
|
| 4092 | + 0 => array("pipe", "r"), // stdin |
|
| 4093 | + 1 => array("pipe", "w"), // stdout |
|
| 4094 | 4094 | 2 => array("pipe", "w") // stderr |
| 4095 | 4095 | ); |
| 4096 | 4096 | |
@@ -4147,8 +4147,8 @@ discard block |
||
| 4147 | 4147 | * @param string $mime |
| 4148 | 4148 | * @return gd image resource identifier |
| 4149 | 4149 | */ |
| 4150 | - protected function gdImageCreate($path,$mime){ |
|
| 4151 | - switch($mime){ |
|
| 4150 | + protected function gdImageCreate($path, $mime) { |
|
| 4151 | + switch ($mime) { |
|
| 4152 | 4152 | case 'image/jpeg': |
| 4153 | 4153 | return imagecreatefromjpeg($path); |
| 4154 | 4154 | |
@@ -4173,7 +4173,7 @@ discard block |
||
| 4173 | 4173 | * @param string $mime The original image mime type |
| 4174 | 4174 | * @param int $jpgQuality JEPG quality (1-100) |
| 4175 | 4175 | */ |
| 4176 | - protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null ){ |
|
| 4176 | + protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null) { |
|
| 4177 | 4177 | |
| 4178 | 4178 | if (!$jpgQuality) { |
| 4179 | 4179 | $jpgQuality = $this->options['jpgQuality']; |
@@ -4197,7 +4197,7 @@ discard block |
||
| 4197 | 4197 | * @param string $destformat The Image type to use for $filename |
| 4198 | 4198 | * @param int $jpgQuality JEPG quality (1-100) |
| 4199 | 4199 | */ |
| 4200 | - protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ){ |
|
| 4200 | + protected function imagickImage($img, $filename, $destformat, $jpgQuality = null) { |
|
| 4201 | 4201 | |
| 4202 | 4202 | if (!$jpgQuality) { |
| 4203 | 4203 | $jpgQuality = $this->options['jpgQuality']; |
@@ -4252,13 +4252,13 @@ discard block |
||
| 4252 | 4252 | * @param resource $image gd image resource |
| 4253 | 4253 | * @param string $bgcolor background color in #rrggbb format |
| 4254 | 4254 | */ |
| 4255 | - protected function gdImageBackground($image, $bgcolor){ |
|
| 4255 | + protected function gdImageBackground($image, $bgcolor) { |
|
| 4256 | 4256 | |
| 4257 | - if( $bgcolor == 'transparent' ){ |
|
| 4258 | - imagesavealpha($image,true); |
|
| 4257 | + if ($bgcolor == 'transparent') { |
|
| 4258 | + imagesavealpha($image, true); |
|
| 4259 | 4259 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
| 4260 | 4260 | |
| 4261 | - }else{ |
|
| 4261 | + } else { |
|
| 4262 | 4262 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
| 4263 | 4263 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
| 4264 | 4264 | } |
@@ -4296,13 +4296,13 @@ discard block |
||
| 4296 | 4296 | * @return int|bool |
| 4297 | 4297 | * @author Alexey Sukhotin |
| 4298 | 4298 | **/ |
| 4299 | - protected function stripos($haystack , $needle , $offset = 0) { |
|
| 4299 | + protected function stripos($haystack, $needle, $offset = 0) { |
|
| 4300 | 4300 | if (function_exists('mb_stripos')) { |
| 4301 | - return mb_stripos($haystack , $needle , $offset, 'UTF-8'); |
|
| 4301 | + return mb_stripos($haystack, $needle, $offset, 'UTF-8'); |
|
| 4302 | 4302 | } else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) { |
| 4303 | 4303 | return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset); |
| 4304 | 4304 | } |
| 4305 | - return stripos($haystack , $needle , $offset); |
|
| 4305 | + return stripos($haystack, $needle, $offset); |
|
| 4306 | 4306 | } |
| 4307 | 4307 | |
| 4308 | 4308 | /** |
@@ -4352,22 +4352,22 @@ discard block |
||
| 4352 | 4352 | unset($o); |
| 4353 | 4353 | $this->procExec('zip -v', $o, $c); |
| 4354 | 4354 | if ($c == 0) { |
| 4355 | - $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
| 4355 | + $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
| 4356 | 4356 | } |
| 4357 | 4357 | unset($o); |
| 4358 | 4358 | $this->procExec('unzip --help', $o, $c); |
| 4359 | 4359 | if ($c == 0) { |
| 4360 | - $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
| 4360 | + $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
| 4361 | 4361 | } |
| 4362 | 4362 | unset($o); |
| 4363 | 4363 | $this->procExec('rar --version', $o, $c); |
| 4364 | 4364 | if ($c == 0 || $c == 7) { |
| 4365 | 4365 | $arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar'); |
| 4366 | - $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
| 4366 | + $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
| 4367 | 4367 | } else { |
| 4368 | 4368 | unset($o); |
| 4369 | 4369 | $test = $this->procExec('unrar', $o, $c); |
| 4370 | - if ($c==0 || $c == 7) { |
|
| 4370 | + if ($c == 0 || $c == 7) { |
|
| 4371 | 4371 | $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar'); |
| 4372 | 4372 | } |
| 4373 | 4373 | } |
@@ -4389,7 +4389,7 @@ discard block |
||
| 4389 | 4389 | if (empty($arcs['extract']['application/x-tar'])) { |
| 4390 | 4390 | $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar'); |
| 4391 | 4391 | } |
| 4392 | - } else if (substr(PHP_OS,0,3) === 'WIN') { |
|
| 4392 | + } else if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
| 4393 | 4393 | // check `7z` for Windows server. |
| 4394 | 4394 | unset($o); |
| 4395 | 4395 | $this->procExec('7z', $o, $c); |
@@ -4443,22 +4443,22 @@ discard block |
||
| 4443 | 4443 | |
| 4444 | 4444 | // normalize `/../` |
| 4445 | 4445 | $normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#'; |
| 4446 | - while(preg_match($normreg, $path)) { |
|
| 4446 | + while (preg_match($normreg, $path)) { |
|
| 4447 | 4447 | $path = preg_replace($normreg, '$1', $path); |
| 4448 | 4448 | } |
| 4449 | 4449 | |
| 4450 | 4450 | // 'Here' |
| 4451 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
| 4451 | + if ($path === '' || $path === '.'.$separator) return $base; |
|
| 4452 | 4452 | |
| 4453 | 4453 | // Absolute path |
| 4454 | 4454 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
| 4455 | 4455 | return $path; |
| 4456 | 4456 | } |
| 4457 | 4457 | |
| 4458 | - $preg_separator = '#' . $sepquoted . '#'; |
|
| 4458 | + $preg_separator = '#'.$sepquoted.'#'; |
|
| 4459 | 4459 | |
| 4460 | 4460 | // Relative path from 'Here' |
| 4461 | - if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) { |
|
| 4461 | + if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) { |
|
| 4462 | 4462 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
| 4463 | 4463 | if ($arrn[0] !== '.') { |
| 4464 | 4464 | array_unshift($arrn, '.'); |
@@ -4472,12 +4472,11 @@ discard block |
||
| 4472 | 4472 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
| 4473 | 4473 | $arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY); |
| 4474 | 4474 | |
| 4475 | - while (! empty($arrn) && $arrn[0] === '..') { |
|
| 4475 | + while (!empty($arrn) && $arrn[0] === '..') { |
|
| 4476 | 4476 | array_shift($arrn); |
| 4477 | 4477 | array_pop($arrp); |
| 4478 | 4478 | } |
| 4479 | - $path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) : |
|
| 4480 | - (! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot); |
|
| 4479 | + $path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot); |
|
| 4481 | 4480 | } |
| 4482 | 4481 | |
| 4483 | 4482 | return $path; |
@@ -4495,7 +4494,7 @@ discard block |
||
| 4495 | 4494 | @chmod($dir, 0777); |
| 4496 | 4495 | foreach (array_diff(scandir($dir), array('.', '..')) as $file) { |
| 4497 | 4496 | @set_time_limit(30); |
| 4498 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
| 4497 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
| 4499 | 4498 | if (!is_link($dir) && is_dir($path)) { |
| 4500 | 4499 | $this->rmdirRecursive($path); |
| 4501 | 4500 | } else { |
@@ -4582,22 +4581,22 @@ discard block |
||
| 4582 | 4581 | try { |
| 4583 | 4582 | if ($start = is_string($zipPath)) { |
| 4584 | 4583 | $zip = new ZipArchive(); |
| 4585 | - if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) { |
|
| 4584 | + if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) { |
|
| 4586 | 4585 | $zip = false; |
| 4587 | 4586 | } |
| 4588 | 4587 | } else { |
| 4589 | 4588 | $zip = $zipPath; |
| 4590 | 4589 | } |
| 4591 | 4590 | if ($zip) { |
| 4592 | - foreach($files as $file) { |
|
| 4593 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
| 4591 | + foreach ($files as $file) { |
|
| 4592 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
| 4594 | 4593 | if (is_dir($path)) { |
| 4595 | 4594 | $zip->addEmptyDir($file); |
| 4596 | 4595 | $_files = array(); |
| 4597 | 4596 | if ($handle = opendir($path)) { |
| 4598 | 4597 | while (false !== ($entry = readdir($handle))) { |
| 4599 | 4598 | if ($entry !== "." && $entry !== "..") { |
| 4600 | - $_files[] = $file . DIRECTORY_SEPARATOR . $entry; |
|
| 4599 | + $_files[] = $file.DIRECTORY_SEPARATOR.$entry; |
|
| 4601 | 4600 | } |
| 4602 | 4601 | } |
| 4603 | 4602 | closedir($handle); |
@@ -4782,7 +4781,7 @@ discard block |
||
| 4782 | 4781 | * @return resource|false |
| 4783 | 4782 | * @author Dmitry (dio) Levashov |
| 4784 | 4783 | **/ |
| 4785 | - abstract protected function _fopen($path, $mode="rb"); |
|
| 4784 | + abstract protected function _fopen($path, $mode = "rb"); |
|
| 4786 | 4785 | |
| 4787 | 4786 | /** |
| 4788 | 4787 | * Close opened file |
@@ -4792,7 +4791,7 @@ discard block |
||
| 4792 | 4791 | * @return bool |
| 4793 | 4792 | * @author Dmitry (dio) Levashov |
| 4794 | 4793 | **/ |
| 4795 | - abstract protected function _fclose($fp, $path=''); |
|
| 4794 | + abstract protected function _fclose($fp, $path = ''); |
|
| 4796 | 4795 | |
| 4797 | 4796 | /******************** file/dir manipulations *************************/ |
| 4798 | 4797 | |
@@ -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 |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | if ($options['user'] === 'init') { |
| 140 | 140 | |
| 141 | - if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
| 141 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
| 142 | 142 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | if (class_exists('OAuth', false)) { |
| 149 | 149 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
| 150 | 150 | } else { |
| 151 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
| 151 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
| 152 | 152 | // We're going to try to load in manually |
| 153 | 153 | include 'HTTP/OAuth/Consumer.php'; |
| 154 | 154 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if (! $this->oauth) { |
|
| 161 | + if (!$this->oauth) { |
|
| 162 | 162 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -179,25 +179,25 @@ discard block |
||
| 179 | 179 | unset($_SESSION['elFinderDropboxTokens']); |
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | - if (! $html) { |
|
| 182 | + if (!$html) { |
|
| 183 | 183 | // get customdata |
| 184 | 184 | $cdata = ''; |
| 185 | 185 | $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); |
| 186 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
| 187 | - foreach($this->ARGS as $k => $v) { |
|
| 188 | - if (! in_array($k, $innerKeys)) { |
|
| 189 | - $cdata .= '&' . $k . '=' . rawurlencode($v); |
|
| 186 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
| 187 | + foreach ($this->ARGS as $k => $v) { |
|
| 188 | + if (!in_array($k, $innerKeys)) { |
|
| 189 | + $cdata .= '&'.$k.'='.rawurlencode($v); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - if (strpos($options['url'], 'http') !== 0 ) { |
|
| 192 | + if (strpos($options['url'], 'http') !== 0) { |
|
| 193 | 193 | $options['url'] = $this->getConnectorUrl(); |
| 194 | 194 | } |
| 195 | - $callback = $options['url'] |
|
| 195 | + $callback = $options['url'] |
|
| 196 | 196 | . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
| 197 | 197 | |
| 198 | 198 | try { |
| 199 | 199 | $tokens = $this->oauth->getRequestToken(); |
| 200 | - $url= $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
| 200 | + $url = $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
| 201 | 201 | } catch (Dropbox_Exception $e) { |
| 202 | 202 | return array('exit' => true, 'body' => '{msg:errAccess}'); |
| 203 | 203 | } |
@@ -244,14 +244,14 @@ discard block |
||
| 244 | 244 | if (isset($netVolumes[$key])) { |
| 245 | 245 | $dropboxUid = $netVolumes[$key]['dropboxUid']; |
| 246 | 246 | } |
| 247 | - foreach($netVolumes as $volume) { |
|
| 247 | + foreach ($netVolumes as $volume) { |
|
| 248 | 248 | if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) { |
| 249 | 249 | $count++; |
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | if ($count === 1) { |
| 253 | 253 | $this->DB->exec('drop table '.$this->DB_TableName); |
| 254 | - foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
| 254 | + foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
| 255 | 255 | unlink($tmb); |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | * @author Naoki Sawada |
| 266 | 266 | */ |
| 267 | 267 | private function getConnectorUrl() { |
| 268 | - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
|
| 268 | + $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') |
|
| 269 | 269 | . $_SERVER['SERVER_NAME'] // host |
| 270 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
| 271 | - . $_SERVER['REQUEST_URI']; // path & query |
|
| 270 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) // port |
|
| 271 | + . $_SERVER['REQUEST_URI']; // path & query |
|
| 272 | 272 | list($url) = explode('?', $url); |
| 273 | 273 | return $url; |
| 274 | 274 | } |
@@ -304,14 +304,14 @@ discard block |
||
| 304 | 304 | // make net mount key |
| 305 | 305 | $this->netMountKey = md5(join('-', array('dropbox', $this->options['path']))); |
| 306 | 306 | |
| 307 | - if (! $this->oauth) { |
|
| 307 | + if (!$this->oauth) { |
|
| 308 | 308 | if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) { |
| 309 | 309 | $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']); |
| 310 | 310 | } else { |
| 311 | 311 | if (class_exists('OAuth', false)) { |
| 312 | 312 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
| 313 | 313 | } else { |
| 314 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
| 314 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
| 315 | 315 | // We're going to try to load in manually |
| 316 | 316 | include 'HTTP/OAuth/Consumer.php'; |
| 317 | 317 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if (! $this->oauth) { |
|
| 325 | + if (!$this->oauth) { |
|
| 326 | 326 | return $this->setError('OAuth extension not loaded.'); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $this->root = $this->options['path'] = $this->_normpath($this->options['path']); |
| 331 | 331 | |
| 332 | 332 | if (empty($this->options['alias'])) { |
| 333 | - $this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
| 333 | + $this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | $this->rootName = $this->options['alias']; |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // setup PDO |
| 388 | - if (! $this->options['PDO_DSN']) { |
|
| 388 | + if (!$this->options['PDO_DSN']) { |
|
| 389 | 389 | $this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']); |
| 390 | 390 | } |
| 391 | 391 | // DataBase table name |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | // DataBase check or make table |
| 394 | 394 | try { |
| 395 | 395 | $this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']); |
| 396 | - if (! $this->checkDB()) { |
|
| 396 | + if (!$this->checkDB()) { |
|
| 397 | 397 | return $this->setError('Can not make DB table'); |
| 398 | 398 | } |
| 399 | 399 | } catch (PDOException $e) { |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $res = false; |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | - if (! $res) { |
|
| 458 | + if (!$res) { |
|
| 459 | 459 | try { |
| 460 | 460 | $this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);'); |
| 461 | 461 | $this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)'); |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | */ |
| 506 | 506 | private function updateDBdat($path, $dat) { |
| 507 | 507 | return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat)) |
| 508 | - . ', isdir=' . ($dat['is_dir']? 1 : 0) |
|
| 508 | + . ', isdir='.($dat['is_dir'] ? 1 : 0) |
|
| 509 | 509 | . ' where path='.$this->DB->quote(strtolower($this->_dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path)))); |
| 510 | 510 | } |
| 511 | 511 | /*********************************************************************/ |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | */ |
| 531 | 531 | protected function deltaCheck($refresh = true) { |
| 532 | 532 | $chk = false; |
| 533 | - if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
| 533 | + if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
| 534 | 534 | $chk = unserialize($chk[0]); |
| 535 | 535 | } |
| 536 | 536 | if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) { |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | do { |
| 555 | 555 | @ ini_set('max_execution_time', 120); |
| 556 | 556 | $_info = $this->dropbox->delta($cursor); |
| 557 | - if (! empty($_info['reset'])) { |
|
| 557 | + if (!empty($_info['reset'])) { |
|
| 558 | 558 | $this->DB->exec('TRUNCATE table '.$this->DB_TableName); |
| 559 | 559 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);'); |
| 560 | 560 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array( |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | } |
| 568 | 568 | $cursor = $_info['cursor']; |
| 569 | 569 | |
| 570 | - foreach($_info['entries'] as $entry) { |
|
| 570 | + foreach ($_info['entries'] as $entry) { |
|
| 571 | 571 | $key = strtolower($entry[0]); |
| 572 | 572 | $pkey = strtolower($this->_dirname($key)); |
| 573 | 573 | |
@@ -576,22 +576,22 @@ discard block |
||
| 576 | 576 | $where = 'where path='.$path.' and fname='.$fname; |
| 577 | 577 | |
| 578 | 578 | if (empty($entry[1])) { |
| 579 | - $ptimes[$pkey] = isset($ptimes[$pkey])? max(array($now, $ptimes[$pkey])) : $now; |
|
| 579 | + $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($now, $ptimes[$pkey])) : $now; |
|
| 580 | 580 | $this->DB->exec('delete from '.$this->DB_TableName.' '.$where); |
| 581 | - ! $delete && $delete = true; |
|
| 581 | + !$delete && $delete = true; |
|
| 582 | 582 | continue; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - $_itemTime = strtotime(isset($entry[1]['client_mtime'])? $entry[1]['client_mtime'] : $entry[1]['modified']); |
|
| 586 | - $ptimes[$pkey] = isset($ptimes[$pkey])? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime; |
|
| 585 | + $_itemTime = strtotime(isset($entry[1]['client_mtime']) ? $entry[1]['client_mtime'] : $entry[1]['modified']); |
|
| 586 | + $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime; |
|
| 587 | 587 | $sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1'; |
| 588 | - if (! $reset && $this->query($sql)) { |
|
| 589 | - $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where); |
|
| 588 | + if (!$reset && $this->query($sql)) { |
|
| 589 | + $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where); |
|
| 590 | 590 | } else { |
| 591 | - $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')'); |
|
| 591 | + $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')'); |
|
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | - } while (! empty($_info['has_more'])); |
|
| 594 | + } while (!empty($_info['has_more'])); |
|
| 595 | 595 | |
| 596 | 596 | // update time stamp of parent holder |
| 597 | 597 | foreach ($ptimes as $_p => $_t) { |
@@ -613,14 +613,14 @@ discard block |
||
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\''); |
| 616 | - if (! $this->DB->commit()) { |
|
| 616 | + if (!$this->DB->commit()) { |
|
| 617 | 617 | $e = $this->DB->errorInfo(); |
| 618 | 618 | return $e[2]; |
| 619 | 619 | } |
| 620 | 620 | if ($delete) { |
| 621 | 621 | $this->DB->exec('vacuum'); |
| 622 | 622 | } |
| 623 | - } catch(Dropbox_Exception $e) { |
|
| 623 | + } catch (Dropbox_Exception $e) { |
|
| 624 | 624 | return $e->getMessage(); |
| 625 | 625 | } |
| 626 | 626 | return true; |
@@ -636,15 +636,14 @@ discard block |
||
| 636 | 636 | protected function parseRaw($raw) { |
| 637 | 637 | $stat = array(); |
| 638 | 638 | |
| 639 | - $stat['rev'] = isset($raw['rev'])? $raw['rev'] : 'root'; |
|
| 639 | + $stat['rev'] = isset($raw['rev']) ? $raw['rev'] : 'root'; |
|
| 640 | 640 | $stat['name'] = basename($raw['path']); |
| 641 | - $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
|
| 641 | + $stat['mime'] = $raw['is_dir'] ? 'directory' : $raw['mime_type']; |
|
| 642 | 642 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
| 643 | - $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
|
| 644 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
| 643 | + $stat['ts'] = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
| 645 | 644 | $stat['dirs'] = 0; |
| 646 | 645 | if ($raw['is_dir']) { |
| 647 | - $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
| 646 | + $stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
| 648 | 647 | } |
| 649 | 648 | |
| 650 | 649 | if (!empty($raw['url'])) { |
@@ -670,7 +669,7 @@ discard block |
||
| 670 | 669 | $res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path))); |
| 671 | 670 | |
| 672 | 671 | if ($res) { |
| 673 | - foreach($res as $raw) { |
|
| 672 | + foreach ($res as $raw) { |
|
| 674 | 673 | $raw = unserialize($raw); |
| 675 | 674 | if ($stat = $this->parseRaw($raw)) { |
| 676 | 675 | $stat = $this->updateCache($raw['path'], $stat); |
@@ -695,10 +694,10 @@ discard block |
||
| 695 | 694 | protected function doSearch($path, $q, $mimes) { |
| 696 | 695 | $result = array(); |
| 697 | 696 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
| 698 | - $sth->execute(array((($path === '/')? '' : strtolower($path)).'%', '%'.strtolower($q).'%')); |
|
| 697 | + $sth->execute(array((($path === '/') ? '' : strtolower($path)).'%', '%'.strtolower($q).'%')); |
|
| 699 | 698 | $res = $sth->fetchAll(PDO::FETCH_COLUMN); |
| 700 | 699 | if ($res) { |
| 701 | - foreach($res as $raw) { |
|
| 700 | + foreach ($res as $raw) { |
|
| 702 | 701 | $raw = unserialize($raw); |
| 703 | 702 | if ($stat = $this->parseRaw($raw)) { |
| 704 | 703 | if (!isset($this->cache[$raw['path']])) { |
@@ -791,10 +790,10 @@ discard block |
||
| 791 | 790 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
| 792 | 791 | |
| 793 | 792 | // copy image into tmbPath so some drivers does not store files on local fs |
| 794 | - if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
| 793 | + if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
| 795 | 794 | return false; |
| 796 | 795 | } |
| 797 | - if (! file_put_contents($tmb, $data)) { |
|
| 796 | + if (!file_put_contents($tmb, $data)) { |
|
| 798 | 797 | return false; |
| 799 | 798 | } |
| 800 | 799 | |
@@ -807,15 +806,15 @@ discard block |
||
| 807 | 806 | } |
| 808 | 807 | |
| 809 | 808 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
| 810 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
| 811 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
| 809 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
| 810 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
| 812 | 811 | |
| 813 | 812 | } else { |
| 814 | 813 | |
| 815 | 814 | if ($this->options['tmbCrop']) { |
| 816 | 815 | |
| 817 | 816 | /* Resize and crop if image bigger than thumbnail */ |
| 818 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
| 817 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
| 819 | 818 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
| 820 | 819 | } |
| 821 | 820 | |
@@ -829,7 +828,7 @@ discard block |
||
| 829 | 828 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
| 830 | 829 | } |
| 831 | 830 | |
| 832 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
| 831 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
| 833 | 832 | } |
| 834 | 833 | |
| 835 | 834 | if (!$result) { |
@@ -886,7 +885,7 @@ discard block |
||
| 886 | 885 | } |
| 887 | 886 | } |
| 888 | 887 | } |
| 889 | - if (! $url) { |
|
| 888 | + if (!$url) { |
|
| 890 | 889 | try { |
| 891 | 890 | $res = $this->dropbox->share($path, null, false); |
| 892 | 891 | $url = $res['url']; |
@@ -898,7 +897,7 @@ discard block |
||
| 898 | 897 | } |
| 899 | 898 | list($url) = explode('?', $url); |
| 900 | 899 | $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url); |
| 901 | - if (! isset($cache['share']) || $cache['share'] !== $url) { |
|
| 900 | + if (!isset($cache['share']) || $cache['share'] !== $url) { |
|
| 902 | 901 | $cache['share'] = $url; |
| 903 | 902 | $this->updateDBdat($path, $cache); |
| 904 | 903 | } |
@@ -922,12 +921,12 @@ discard block |
||
| 922 | 921 | if (function_exists('curl_exec')) { |
| 923 | 922 | |
| 924 | 923 | $c = curl_init(); |
| 925 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
|
| 926 | - curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
| 927 | - curl_setopt( $c, CURLOPT_HEADER, 1 ); |
|
| 928 | - curl_setopt( $c, CURLOPT_NOBODY, true ); |
|
| 929 | - curl_setopt( $c, CURLOPT_URL, $url ); |
|
| 930 | - $res = curl_exec( $c ); |
|
| 924 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
| 925 | + curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
| 926 | + curl_setopt($c, CURLOPT_HEADER, 1); |
|
| 927 | + curl_setopt($c, CURLOPT_NOBODY, true); |
|
| 928 | + curl_setopt($c, CURLOPT_URL, $url); |
|
| 929 | + $res = curl_exec($c); |
|
| 931 | 930 | |
| 932 | 931 | } else { |
| 933 | 932 | |
@@ -943,13 +942,13 @@ discard block |
||
| 943 | 942 | $result = $request2->send(); |
| 944 | 943 | $res = array(); |
| 945 | 944 | $res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase(); |
| 946 | - foreach($result->getHeader() as $key => $val) { |
|
| 947 | - $res[] = $key . ': ' . $val; |
|
| 945 | + foreach ($result->getHeader() as $key => $val) { |
|
| 946 | + $res[] = $key.': '.$val; |
|
| 948 | 947 | } |
| 949 | 948 | $res = join("\r\n", $res); |
| 950 | - } catch( HTTP_Request2_Exception $e ){ |
|
| 949 | + } catch (HTTP_Request2_Exception $e) { |
|
| 951 | 950 | $res = ''; |
| 952 | - } catch (Exception $e){ |
|
| 951 | + } catch (Exception $e) { |
|
| 953 | 952 | $res = ''; |
| 954 | 953 | } |
| 955 | 954 | |
@@ -1001,7 +1000,7 @@ discard block |
||
| 1001 | 1000 | * @author Troex Nevelin |
| 1002 | 1001 | **/ |
| 1003 | 1002 | protected function _normpath($path) { |
| 1004 | - $path = '/' . ltrim($path, '/'); |
|
| 1003 | + $path = '/'.ltrim($path, '/'); |
|
| 1005 | 1004 | return $path; |
| 1006 | 1005 | } |
| 1007 | 1006 | |
@@ -1035,7 +1034,7 @@ discard block |
||
| 1035 | 1034 | * @author Dmitry (dio) Levashov |
| 1036 | 1035 | **/ |
| 1037 | 1036 | protected function _path($path) { |
| 1038 | - return $this->rootName . $this->_normpath(substr($path, strlen($this->root))); |
|
| 1037 | + return $this->rootName.$this->_normpath(substr($path, strlen($this->root))); |
|
| 1039 | 1038 | } |
| 1040 | 1039 | |
| 1041 | 1040 | /** |
@@ -1144,7 +1143,7 @@ discard block |
||
| 1144 | 1143 | * @return resource|false |
| 1145 | 1144 | * @author Dmitry (dio) Levashov |
| 1146 | 1145 | **/ |
| 1147 | - protected function _fopen($path, $mode='rb') { |
|
| 1146 | + protected function _fopen($path, $mode = 'rb') { |
|
| 1148 | 1147 | |
| 1149 | 1148 | if (($mode == 'rb' || $mode == 'r')) { |
| 1150 | 1149 | try { |
@@ -1154,7 +1153,7 @@ discard block |
||
| 1154 | 1153 | fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); |
| 1155 | 1154 | fputs($fp, "Host: {$url['host']}\r\n"); |
| 1156 | 1155 | fputs($fp, "\r\n"); |
| 1157 | - while(trim(fgets($fp)) !== ''){}; |
|
| 1156 | + while (trim(fgets($fp)) !== '') {}; |
|
| 1158 | 1157 | return $fp; |
| 1159 | 1158 | } catch (Dropbox_Exception $e) { |
| 1160 | 1159 | return false; |
@@ -1185,7 +1184,7 @@ discard block |
||
| 1185 | 1184 | * @return bool |
| 1186 | 1185 | * @author Dmitry (dio) Levashov |
| 1187 | 1186 | **/ |
| 1188 | - protected function _fclose($fp, $path='') { |
|
| 1187 | + protected function _fclose($fp, $path = '') { |
|
| 1189 | 1188 | @fclose($fp); |
| 1190 | 1189 | if ($path) { |
| 1191 | 1190 | @unlink($this->getTempFile($path)); |