@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | 'utf8fix' => false, |
279 | 279 | // й ё Й Ё Ø Å |
280 | 280 | 'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"), |
281 | - 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
281 | + 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
282 | 282 | ); |
283 | 283 | |
284 | 284 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | **/ |
571 | 571 | protected function configure() { |
572 | 572 | // set ARGS |
573 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
573 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
574 | 574 | // set thumbnails path |
575 | 575 | $path = $this->options['tmbPath']; |
576 | 576 | if ($path) { |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | // check 'statOwner' for command `chmod` |
603 | 603 | if (empty($this->options['statOwner'])) { |
604 | - $this->disabled[] ='chmod'; |
|
604 | + $this->disabled[] = 'chmod'; |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | // check 'mimeMap' |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | **/ |
707 | 707 | public function mount(array $opts) { |
708 | 708 | if (!isset($opts['path']) || $opts['path'] === '') { |
709 | - return $this->setError('Path undefined.');; |
|
709 | + return $this->setError('Path undefined.'); ; |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | $this->options = array_merge($this->options, $opts); |
@@ -725,14 +725,14 @@ discard block |
||
725 | 725 | $argInit = !empty($this->ARGS['init']); |
726 | 726 | |
727 | 727 | // session cache |
728 | - if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
728 | + if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
729 | 729 | $_SESSION[elFinder::$sessionCacheKey][$this->id] = array(); |
730 | 730 | } |
731 | 731 | $this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id]; |
732 | 732 | |
733 | 733 | // default file attribute |
734 | 734 | $this->defaults = array( |
735 | - 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
735 | + 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
736 | 736 | 'write' => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true, |
737 | 737 | 'locked' => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false, |
738 | 738 | 'hidden' => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false |
@@ -759,8 +759,8 @@ discard block |
||
759 | 759 | $this->access = $this->options['accessControl']; |
760 | 760 | } |
761 | 761 | |
762 | - $this->today = mktime(0,0,0, date('m'), date('d'), date('Y')); |
|
763 | - $this->yesterday = $this->today-86400; |
|
762 | + $this->today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
763 | + $this->yesterday = $this->today - 86400; |
|
764 | 764 | |
765 | 765 | // debug($this->attributes); |
766 | 766 | if (!$this->init()) { |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | foreach ($mimecf as $line_num => $line) { |
860 | 860 | if (!preg_match('/^\s*#/', $line)) { |
861 | 861 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
862 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
862 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
863 | 863 | if (!isset(self::$mimetypes[$mime[$i]])) { |
864 | 864 | self::$mimetypes[$mime[$i]] = $mime[0]; |
865 | 865 | } |
@@ -911,8 +911,8 @@ discard block |
||
911 | 911 | 'read' => false |
912 | 912 | )); |
913 | 913 | } |
914 | - $this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1; |
|
915 | - $this->tmbSize = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48; |
|
914 | + $this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1; |
|
915 | + $this->tmbSize = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48; |
|
916 | 916 | $this->URL = $this->options['URL']; |
917 | 917 | if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) { |
918 | 918 | $this->URL .= '/'; |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | public function options($hash) { |
1054 | 1054 | $create = $createext = array(); |
1055 | 1055 | if (isset($this->archivers['create']) && is_array($this->archivers['create'])) { |
1056 | - foreach($this->archivers['create'] as $m => $v) { |
|
1056 | + foreach ($this->archivers['create'] as $m => $v) { |
|
1057 | 1057 | $create[] = $m; |
1058 | 1058 | $createext[$m] = $v['ext']; |
1059 | 1059 | } |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | 'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(), |
1074 | 1074 | 'createext' => $createext |
1075 | 1075 | ), |
1076 | - 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array() |
|
1076 | + 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array() |
|
1077 | 1077 | ); |
1078 | 1078 | } |
1079 | 1079 | |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | * @author Naoki Sawada |
1086 | 1086 | */ |
1087 | 1087 | public function getOption($name) { |
1088 | - return isset($this->options[$name])? $this->options[$name] : null; |
|
1088 | + return isset($this->options[$name]) ? $this->options[$name] : null; |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | /** |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | public function getOptionsPlugin($name = '') { |
1099 | 1099 | if ($name) { |
1100 | - return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array(); |
|
1100 | + return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array(); |
|
1101 | 1101 | } else { |
1102 | 1102 | return $this->options['plugin']; |
1103 | 1103 | } |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | $file = $this->stat($path); |
1228 | 1228 | |
1229 | 1229 | if ($hash === $this->root()) { |
1230 | - $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(); |
|
1230 | + $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(); |
|
1231 | 1231 | $file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON |
1232 | 1232 | } |
1233 | 1233 | |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | * @return array|false |
1243 | 1243 | * @author Dmitry (dio) Levashov |
1244 | 1244 | **/ |
1245 | - public function dir($hash, $resolveLink=false) { |
|
1245 | + public function dir($hash, $resolveLink = false) { |
|
1246 | 1246 | if (($dir = $this->file($hash)) == false) { |
1247 | 1247 | return $this->setError(elFinder::ERROR_DIR_NOT_FOUND); |
1248 | 1248 | } |
@@ -1306,14 +1306,14 @@ discard block |
||
1306 | 1306 | * @return array|false |
1307 | 1307 | * @author Dmitry (dio) Levashov |
1308 | 1308 | **/ |
1309 | - public function tree($hash='', $deep=0, $exclude='') { |
|
1309 | + public function tree($hash = '', $deep = 0, $exclude = '') { |
|
1310 | 1310 | $path = $hash ? $this->decode($hash) : $this->root; |
1311 | 1311 | |
1312 | 1312 | if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') { |
1313 | 1313 | return false; |
1314 | 1314 | } |
1315 | 1315 | |
1316 | - $dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null); |
|
1316 | + $dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null); |
|
1317 | 1317 | array_unshift($dirs, $dir); |
1318 | 1318 | return $dirs; |
1319 | 1319 | } |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | * @return array|false |
1544 | 1544 | * @author Dmitry (dio) Levashov |
1545 | 1545 | **/ |
1546 | - public function duplicate($hash, $suffix='copy') { |
|
1546 | + public function duplicate($hash, $suffix = 'copy') { |
|
1547 | 1547 | if ($this->commandDisabled('duplicate')) { |
1548 | 1548 | return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED); |
1549 | 1549 | } |
@@ -1619,7 +1619,7 @@ discard block |
||
1619 | 1619 | |
1620 | 1620 | if ($file) { // file exists |
1621 | 1621 | // check POST data `overwrite` for 3rd party uploader |
1622 | - $overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1622 | + $overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1623 | 1623 | if ($overwrite) { |
1624 | 1624 | if (!$file['write']) { |
1625 | 1625 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
@@ -1690,7 +1690,7 @@ discard block |
||
1690 | 1690 | if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) { |
1691 | 1691 | return $rmSrc |
1692 | 1692 | ? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test)) |
1693 | - : $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1693 | + : $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | $test = $this->joinPathCE($destination, $name); |
@@ -1853,7 +1853,7 @@ discard block |
||
1853 | 1853 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
1854 | 1854 | } |
1855 | 1855 | $this->clearcache(); |
1856 | - $this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir; |
|
1856 | + $this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir; |
|
1857 | 1857 | |
1858 | 1858 | if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) { |
1859 | 1859 | if (is_array($path)) { |
@@ -1911,9 +1911,9 @@ discard block |
||
1911 | 1911 | if ($name === '') { |
1912 | 1912 | $name = count($files) == 1 ? $files[0] : 'Archive'; |
1913 | 1913 | } else { |
1914 | - $name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name)); |
|
1914 | + $name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name)); |
|
1915 | 1915 | } |
1916 | - $name .='.' . $archiver['ext']; |
|
1916 | + $name .= '.'.$archiver['ext']; |
|
1917 | 1917 | $name = $this->uniqueName($dir, $name, ''); |
1918 | 1918 | $this->clearcache(); |
1919 | 1919 | return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false; |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | |
1950 | 1950 | $path = $this->decode($hash); |
1951 | 1951 | |
1952 | - $work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path); |
|
1952 | + $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path); |
|
1953 | 1953 | |
1954 | 1954 | if (!$work_path || !is_writable($work_path)) { |
1955 | 1955 | if ($work_path && $path !== $work_path && is_file($work_path)) { |
@@ -1964,7 +1964,7 @@ discard block |
||
1964 | 1964 | } |
1965 | 1965 | } |
1966 | 1966 | |
1967 | - switch($mode) { |
|
1967 | + switch ($mode) { |
|
1968 | 1968 | |
1969 | 1969 | case 'propresize': |
1970 | 1970 | $result = $this->imgResize($work_path, $width, $height, true, true); |
@@ -2060,7 +2060,7 @@ discard block |
||
2060 | 2060 | } |
2061 | 2061 | return ($q === '' || $this->commandDisabled('search')) |
2062 | 2062 | ? array() |
2063 | - : $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes); |
|
2063 | + : $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes); |
|
2064 | 2064 | } |
2065 | 2065 | |
2066 | 2066 | /** |
@@ -2129,9 +2129,9 @@ discard block |
||
2129 | 2129 | $path = ltrim($path, $this->separator); |
2130 | 2130 | $dirs = explode($this->separator, $path); |
2131 | 2131 | array_pop($dirs); |
2132 | - foreach($dirs as $dir) { |
|
2132 | + foreach ($dirs as $dir) { |
|
2133 | 2133 | $targetPath = $this->joinPathCE($base, $dir); |
2134 | - if (! $_realpath = $this->realpath($this->encode($targetPath))) { |
|
2134 | + if (!$_realpath = $this->realpath($this->encode($targetPath))) { |
|
2135 | 2135 | if ($stat = $this->mkdir($targetHash, $dir)) { |
2136 | 2136 | $result['added'][] = $stat; |
2137 | 2137 | $targetHash = $stat['hash']; |
@@ -2198,7 +2198,7 @@ discard block |
||
2198 | 2198 | * @author Naoki Sawada |
2199 | 2199 | **/ |
2200 | 2200 | protected function dirnameCE($path) { |
2201 | - return (!$this->encoding)? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2201 | + return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2202 | 2202 | } |
2203 | 2203 | |
2204 | 2204 | /** |
@@ -2209,7 +2209,7 @@ discard block |
||
2209 | 2209 | * @author Naoki Sawada |
2210 | 2210 | **/ |
2211 | 2211 | protected function basenameCE($path) { |
2212 | - return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2212 | + return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2213 | 2213 | } |
2214 | 2214 | |
2215 | 2215 | /** |
@@ -2222,7 +2222,7 @@ discard block |
||
2222 | 2222 | * @author Naoki Sawada |
2223 | 2223 | **/ |
2224 | 2224 | protected function joinPathCE($dir, $name) { |
2225 | - return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2225 | + return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | /** |
@@ -2233,7 +2233,7 @@ discard block |
||
2233 | 2233 | * @author Naoki Sawada |
2234 | 2234 | **/ |
2235 | 2235 | protected function normpathCE($path) { |
2236 | - return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2236 | + return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2237 | 2237 | } |
2238 | 2238 | |
2239 | 2239 | /** |
@@ -2244,7 +2244,7 @@ discard block |
||
2244 | 2244 | * @author Naoki Sawada |
2245 | 2245 | **/ |
2246 | 2246 | protected function relpathCE($path) { |
2247 | - return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2247 | + return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2248 | 2248 | } |
2249 | 2249 | |
2250 | 2250 | /** |
@@ -2255,7 +2255,7 @@ discard block |
||
2255 | 2255 | * @author Naoki Sawada |
2256 | 2256 | **/ |
2257 | 2257 | protected function abspathCE($path) { |
2258 | - return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2258 | + return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2259 | 2259 | } |
2260 | 2260 | |
2261 | 2261 | /** |
@@ -2267,7 +2267,7 @@ discard block |
||
2267 | 2267 | * @author Naoki Sawada |
2268 | 2268 | **/ |
2269 | 2269 | protected function inpathCE($path, $parent) { |
2270 | - return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2270 | + return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2271 | 2271 | } |
2272 | 2272 | |
2273 | 2273 | /** |
@@ -2278,8 +2278,8 @@ discard block |
||
2278 | 2278 | * @return resource|false |
2279 | 2279 | * @author Naoki Sawada |
2280 | 2280 | **/ |
2281 | - protected function fopenCE($path, $mode='rb') { |
|
2282 | - return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2281 | + protected function fopenCE($path, $mode = 'rb') { |
|
2282 | + return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2283 | 2283 | } |
2284 | 2284 | |
2285 | 2285 | /** |
@@ -2290,8 +2290,8 @@ discard block |
||
2290 | 2290 | * @return bool |
2291 | 2291 | * @author Naoki Sawada |
2292 | 2292 | **/ |
2293 | - protected function fcloseCE($fp, $path='') { |
|
2294 | - return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2293 | + protected function fcloseCE($fp, $path = '') { |
|
2294 | + return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2295 | 2295 | } |
2296 | 2296 | |
2297 | 2297 | /** |
@@ -2306,7 +2306,7 @@ discard block |
||
2306 | 2306 | * @author Naoki Sawada |
2307 | 2307 | **/ |
2308 | 2308 | protected function saveCE($fp, $dir, $name, $stat) { |
2309 | - return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2309 | + return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | /** |
@@ -2318,7 +2318,7 @@ discard block |
||
2318 | 2318 | **/ |
2319 | 2319 | protected function subdirsCE($path) { |
2320 | 2320 | if (!isset($this->subdirsCache[$path])) { |
2321 | - $this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2321 | + $this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2322 | 2322 | } |
2323 | 2323 | return $this->subdirsCache[$path]; |
2324 | 2324 | } |
@@ -2331,7 +2331,7 @@ discard block |
||
2331 | 2331 | * @author Naoki Sawada |
2332 | 2332 | **/ |
2333 | 2333 | protected function scandirCE($path) { |
2334 | - return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2334 | + return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2335 | 2335 | } |
2336 | 2336 | |
2337 | 2337 | /** |
@@ -2344,7 +2344,7 @@ discard block |
||
2344 | 2344 | * @author Naoki Sawada |
2345 | 2345 | **/ |
2346 | 2346 | protected function symlinkCE($source, $targetDir, $name) { |
2347 | - return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2347 | + return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2348 | 2348 | } |
2349 | 2349 | |
2350 | 2350 | /***************** paths *******************/ |
@@ -2363,7 +2363,7 @@ discard block |
||
2363 | 2363 | // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root |
2364 | 2364 | $p = $this->relpathCE($path); |
2365 | 2365 | // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt |
2366 | - if ($p === '') { |
|
2366 | + if ($p === '') { |
|
2367 | 2367 | $p = DIRECTORY_SEPARATOR; |
2368 | 2368 | } |
2369 | 2369 | |
@@ -2396,7 +2396,7 @@ discard block |
||
2396 | 2396 | // TODO uncrypt hash and return path |
2397 | 2397 | $path = $this->uncrypt($h); |
2398 | 2398 | // append ROOT to path after it was cut in encode |
2399 | - return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2399 | + return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2400 | 2400 | } |
2401 | 2401 | } |
2402 | 2402 | |
@@ -2453,21 +2453,21 @@ discard block |
||
2453 | 2453 | * @author Dmitry (dio) Levashov |
2454 | 2454 | **/ |
2455 | 2455 | public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) { |
2456 | - $ext = ''; |
|
2456 | + $ext = ''; |
|
2457 | 2457 | |
2458 | 2458 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
2459 | 2459 | $ext = '.'.$m[1]; |
2460 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
2460 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
2461 | 2461 | } |
2462 | 2462 | |
2463 | 2463 | if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) { |
2464 | - $i = (int)$m[2]; |
|
2465 | - $name = substr($name, 0, strlen($name)-strlen($m[2])); |
|
2464 | + $i = (int) $m[2]; |
|
2465 | + $name = substr($name, 0, strlen($name) - strlen($m[2])); |
|
2466 | 2466 | } else { |
2467 | 2467 | $i = $start; |
2468 | 2468 | $name .= $suffix; |
2469 | 2469 | } |
2470 | - $max = $i+100000; |
|
2470 | + $max = $i + 100000; |
|
2471 | 2471 | |
2472 | 2472 | while ($i <= $max) { |
2473 | 2473 | $n = $name.($i > 0 ? $i : '').$ext; |
@@ -2491,7 +2491,7 @@ discard block |
||
2491 | 2491 | * @author Naoki Sawada |
2492 | 2492 | */ |
2493 | 2493 | public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') { |
2494 | - return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2494 | + return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2495 | 2495 | } |
2496 | 2496 | |
2497 | 2497 | /** |
@@ -2504,7 +2504,7 @@ discard block |
||
2504 | 2504 | * @author Naoki Sawada |
2505 | 2505 | */ |
2506 | 2506 | public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') { |
2507 | - return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2507 | + return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | /** |
@@ -2524,7 +2524,7 @@ discard block |
||
2524 | 2524 | } |
2525 | 2525 | if (is_array($var)) { |
2526 | 2526 | $_ret = array(); |
2527 | - foreach($var as $_k => $_v) { |
|
2527 | + foreach ($var as $_k => $_v) { |
|
2528 | 2528 | $_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_'); |
2529 | 2529 | } |
2530 | 2530 | $var = $_ret; |
@@ -2536,7 +2536,7 @@ discard block |
||
2536 | 2536 | $_var = str_replace('?', $unknown, $_var); |
2537 | 2537 | } |
2538 | 2538 | } |
2539 | - if ($_var !== false) { |
|
2539 | + if ($_var !== false) { |
|
2540 | 2540 | $var = $_var; |
2541 | 2541 | } |
2542 | 2542 | } |
@@ -2563,7 +2563,7 @@ discard block |
||
2563 | 2563 | |
2564 | 2564 | $key = ''; |
2565 | 2565 | if ($path !== '') { |
2566 | - $key = $this->id . '#' . $path; |
|
2566 | + $key = $this->id.'#'.$path; |
|
2567 | 2567 | if (isset($cache[$key])) { |
2568 | 2568 | return $cache[$key]; |
2569 | 2569 | } |
@@ -2595,7 +2595,7 @@ discard block |
||
2595 | 2595 | if ($work = $this->getTempFile()) { |
2596 | 2596 | if ($wfp = fopen($work, 'wb')) { |
2597 | 2597 | if ($fp = $this->_fopen($path)) { |
2598 | - while(!feof($fp)) { |
|
2598 | + while (!feof($fp)) { |
|
2599 | 2599 | fwrite($wfp, fread($fp, 8192)); |
2600 | 2600 | } |
2601 | 2601 | $this->_fclose($fp, $path); |
@@ -2639,7 +2639,7 @@ discard block |
||
2639 | 2639 | @set_time_limit(30); |
2640 | 2640 | $stat = $this->stat($this->convEncOut($p)); |
2641 | 2641 | $this->convEncIn(); |
2642 | - ($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p); |
|
2642 | + ($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p); |
|
2643 | 2643 | } |
2644 | 2644 | return $this->_rmdir($localpath); |
2645 | 2645 | } |
@@ -2656,7 +2656,7 @@ discard block |
||
2656 | 2656 | * @return bool |
2657 | 2657 | * @author Dmitry (dio) Levashov |
2658 | 2658 | **/ |
2659 | - protected function attr($path, $name, $val=null, $isDir=null) { |
|
2659 | + protected function attr($path, $name, $val = null, $isDir = null) { |
|
2660 | 2660 | if (!isset($this->defaults[$name])) { |
2661 | 2661 | return false; |
2662 | 2662 | } |
@@ -2688,7 +2688,7 @@ discard block |
||
2688 | 2688 | } |
2689 | 2689 | } |
2690 | 2690 | |
2691 | - return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm; |
|
2691 | + return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm; |
|
2692 | 2692 | } |
2693 | 2693 | |
2694 | 2694 | /** |
@@ -2732,7 +2732,7 @@ discard block |
||
2732 | 2732 | protected function allowPutMime($mime) { |
2733 | 2733 | // logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order |
2734 | 2734 | $allow = $this->mimeAccepted($mime, $this->uploadAllow, null); |
2735 | - $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2735 | + $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2736 | 2736 | $res = true; // default to allow |
2737 | 2737 | if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny' |
2738 | 2738 | $res = false; // default is deny |
@@ -2803,10 +2803,10 @@ discard block |
||
2803 | 2803 | if ($this->rootName) { |
2804 | 2804 | $stat['name'] = $this->rootName; |
2805 | 2805 | } |
2806 | - if (! empty($this->options['icon'])) { |
|
2806 | + if (!empty($this->options['icon'])) { |
|
2807 | 2807 | $stat['icon'] = $this->options['icon']; |
2808 | 2808 | } |
2809 | - if (! empty($this->options['rootCssClass'])) { |
|
2809 | + if (!empty($this->options['rootCssClass'])) { |
|
2810 | 2810 | $stat['csscls'] = $this->options['rootCssClass']; |
2811 | 2811 | } |
2812 | 2812 | } else { |
@@ -2850,7 +2850,7 @@ discard block |
||
2850 | 2850 | // lock when parent directory is not writable |
2851 | 2851 | if (!isset($stat['locked'])) { |
2852 | 2852 | $parent = $this->dirnameCE($path); |
2853 | - $pstat = isset($this->cache[$parent])? $this->cache[$parent] : array(); |
|
2853 | + $pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array(); |
|
2854 | 2854 | if (isset($pstat['write']) && !$pstat['write']) { |
2855 | 2855 | $stat['locked'] = true; |
2856 | 2856 | } |
@@ -2908,7 +2908,7 @@ discard block |
||
2908 | 2908 | } |
2909 | 2909 | if (!isset($stat['url']) && $this->URL && $this->encoding) { |
2910 | 2910 | $_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1)); |
2911 | - $stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true))); |
|
2911 | + $stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true))); |
|
2912 | 2912 | } |
2913 | 2913 | } else { |
2914 | 2914 | if ($isDir) { |
@@ -3151,7 +3151,7 @@ discard block |
||
3151 | 3151 | * @return array |
3152 | 3152 | * @author Dmitry (dio) Levashov |
3153 | 3153 | **/ |
3154 | - protected function gettree($path, $deep, $exclude='') { |
|
3154 | + protected function gettree($path, $deep, $exclude = '') { |
|
3155 | 3155 | $dirs = array(); |
3156 | 3156 | |
3157 | 3157 | !isset($this->dirsCache[$path]) && $this->cacheDir($path); |
@@ -3162,7 +3162,7 @@ discard block |
||
3162 | 3162 | if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') { |
3163 | 3163 | $dirs[] = $stat; |
3164 | 3164 | if ($deep > 0 && !empty($stat['dirs'])) { |
3165 | - $dirs = array_merge($dirs, $this->gettree($p, $deep-1)); |
|
3165 | + $dirs = array_merge($dirs, $this->gettree($p, $deep - 1)); |
|
3166 | 3166 | } |
3167 | 3167 | } |
3168 | 3168 | } |
@@ -3182,7 +3182,7 @@ discard block |
||
3182 | 3182 | protected function doSearch($path, $q, $mimes) { |
3183 | 3183 | $result = array(); |
3184 | 3184 | |
3185 | - foreach($this->scandirCE($path) as $p) { |
|
3185 | + foreach ($this->scandirCE($path) as $p) { |
|
3186 | 3186 | @set_time_limit(30); |
3187 | 3187 | $stat = $this->stat($p); |
3188 | 3188 | |
@@ -3203,7 +3203,7 @@ discard block |
||
3203 | 3203 | if ($this->encoding) { |
3204 | 3204 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
3205 | 3205 | } |
3206 | - $stat['url'] = $this->URL . $path; |
|
3206 | + $stat['url'] = $this->URL.$path; |
|
3207 | 3207 | } |
3208 | 3208 | |
3209 | 3209 | $result[] = $stat; |
@@ -3237,7 +3237,7 @@ discard block |
||
3237 | 3237 | if (!$this->inpathCE($target, $this->root)) { |
3238 | 3238 | return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK); |
3239 | 3239 | } |
3240 | - $stat = $this->stat($target); |
|
3240 | + $stat = $this->stat($target); |
|
3241 | 3241 | $this->clearcache(); |
3242 | 3242 | return $stat && $this->symlinkCE($target, $dst, $name) |
3243 | 3243 | ? $this->joinPathCE($dst, $name) |
@@ -3518,15 +3518,15 @@ discard block |
||
3518 | 3518 | } |
3519 | 3519 | |
3520 | 3520 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
3521 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3522 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3521 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3522 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3523 | 3523 | } else { |
3524 | 3524 | |
3525 | 3525 | if ($this->options['tmbCrop']) { |
3526 | 3526 | |
3527 | 3527 | $result = $tmb; |
3528 | 3528 | /* Resize and crop if image bigger than thumbnail */ |
3529 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3529 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3530 | 3530 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
3531 | 3531 | } |
3532 | 3532 | |
@@ -3543,7 +3543,7 @@ discard block |
||
3543 | 3543 | } |
3544 | 3544 | |
3545 | 3545 | if ($result) { |
3546 | - $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3546 | + $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3547 | 3547 | } |
3548 | 3548 | } |
3549 | 3549 | |
@@ -3584,18 +3584,18 @@ discard block |
||
3584 | 3584 | /* Resizing by biggest side */ |
3585 | 3585 | if ($resizeByBiggerSide) { |
3586 | 3586 | if ($orig_w > $orig_h) { |
3587 | - $size_h = round($orig_h * $width / $orig_w); |
|
3587 | + $size_h = round($orig_h*$width/$orig_w); |
|
3588 | 3588 | $size_w = $width; |
3589 | 3589 | } else { |
3590 | - $size_w = round($orig_w * $height / $orig_h); |
|
3590 | + $size_w = round($orig_w*$height/$orig_h); |
|
3591 | 3591 | $size_h = $height; |
3592 | 3592 | } |
3593 | 3593 | } else { |
3594 | 3594 | if ($orig_w > $orig_h) { |
3595 | - $size_w = round($orig_w * $height / $orig_h); |
|
3595 | + $size_w = round($orig_w*$height/$orig_h); |
|
3596 | 3596 | $size_h = $height; |
3597 | 3597 | } else { |
3598 | - $size_h = round($orig_h * $width / $orig_w); |
|
3598 | + $size_h = round($orig_h*$width/$orig_w); |
|
3599 | 3599 | $size_w = $width; |
3600 | 3600 | } |
3601 | 3601 | } |
@@ -3613,7 +3613,7 @@ discard block |
||
3613 | 3613 | // Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb |
3614 | 3614 | // resize bench: http://app-mgng.rhcloud.com/9 |
3615 | 3615 | // resize sample: http://www.dylanbeattie.net/magick/filters/result.html |
3616 | - $filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3616 | + $filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3617 | 3617 | |
3618 | 3618 | $ani = ($img->getNumberImages() > 1); |
3619 | 3619 | if ($ani && is_null($destformat)) { |
@@ -3638,11 +3638,11 @@ discard block |
||
3638 | 3638 | break; |
3639 | 3639 | |
3640 | 3640 | case 'gd': |
3641 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3641 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3642 | 3642 | |
3643 | - if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3643 | + if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3644 | 3644 | |
3645 | - self::gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3645 | + self::gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3646 | 3646 | |
3647 | 3647 | if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) { |
3648 | 3648 | return false; |
@@ -3718,11 +3718,11 @@ discard block |
||
3718 | 3718 | break; |
3719 | 3719 | |
3720 | 3720 | case 'gd': |
3721 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3721 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3722 | 3722 | |
3723 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3723 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3724 | 3724 | |
3725 | - self::gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3725 | + self::gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3726 | 3726 | |
3727 | 3727 | $size_w = $width; |
3728 | 3728 | $size_h = $height; |
@@ -3772,8 +3772,8 @@ discard block |
||
3772 | 3772 | $result = false; |
3773 | 3773 | |
3774 | 3774 | /* Coordinates for image over square aligning */ |
3775 | - $y = ceil(abs($height - $s[1]) / 2); |
|
3776 | - $x = ceil(abs($width - $s[0]) / 2); |
|
3775 | + $y = ceil(abs($height - $s[1])/2); |
|
3776 | + $x = ceil(abs($width - $s[0])/2); |
|
3777 | 3777 | |
3778 | 3778 | switch ($this->imgLib) { |
3779 | 3779 | case 'imagick': |
@@ -3793,7 +3793,7 @@ discard block |
||
3793 | 3793 | $gif->newImage($width, $height, new ImagickPixel($bgcolor)); |
3794 | 3794 | $gif->setImageColorspace($img->getImageColorspace()); |
3795 | 3795 | $gif->setImageFormat('gif'); |
3796 | - $gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3796 | + $gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3797 | 3797 | $gif->setImageDelay($img->getImageDelay()); |
3798 | 3798 | $gif->setImageIterations($img->getImageIterations()); |
3799 | 3799 | $img1->addImage($gif); |
@@ -3809,7 +3809,7 @@ discard block |
||
3809 | 3809 | $img1->newImage($width, $height, new ImagickPixel($bgcolor)); |
3810 | 3810 | $img1->setImageColorspace($img->getImageColorspace()); |
3811 | 3811 | $img1->setImageFormat($destformat != null ? $destformat : $img->getFormat()); |
3812 | - $img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3812 | + $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3813 | 3813 | $result = $img1->writeImage($path); |
3814 | 3814 | } |
3815 | 3815 | |
@@ -3820,11 +3820,11 @@ discard block |
||
3820 | 3820 | break; |
3821 | 3821 | |
3822 | 3822 | case 'gd': |
3823 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3823 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3824 | 3824 | |
3825 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3825 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3826 | 3826 | |
3827 | - self::gdImageBackground($tmp,$bgcolor); |
|
3827 | + self::gdImageBackground($tmp, $bgcolor); |
|
3828 | 3828 | |
3829 | 3829 | if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) { |
3830 | 3830 | return false; |
@@ -3855,15 +3855,15 @@ discard block |
||
3855 | 3855 | * @author Troex Nevelin |
3856 | 3856 | **/ |
3857 | 3857 | protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) { |
3858 | - if (($s = @getimagesize($path)) == false || $degree % 360 === 0) { |
|
3858 | + if (($s = @getimagesize($path)) == false || $degree%360 === 0) { |
|
3859 | 3859 | return false; |
3860 | 3860 | } |
3861 | 3861 | |
3862 | 3862 | $result = false; |
3863 | 3863 | |
3864 | 3864 | // try lossless rotate |
3865 | - if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
3866 | - $count = ($degree / 90) % 4; |
|
3865 | + if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
3866 | + $count = ($degree/90)%4; |
|
3867 | 3867 | $exiftran = array( |
3868 | 3868 | 1 => '-9', |
3869 | 3869 | 2 => '-1', |
@@ -3879,7 +3879,7 @@ discard block |
||
3879 | 3879 | 'exiftran -i '.$exiftran[$count].' '.$path, |
3880 | 3880 | 'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath |
3881 | 3881 | ); |
3882 | - foreach($cmds as $cmd) { |
|
3882 | + foreach ($cmds as $cmd) { |
|
3883 | 3883 | if ($this->procExec($cmd) === 0) { |
3884 | 3884 | $result = true; |
3885 | 3885 | break; |
@@ -3915,12 +3915,12 @@ discard block |
||
3915 | 3915 | break; |
3916 | 3916 | |
3917 | 3917 | case 'gd': |
3918 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3918 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3919 | 3919 | |
3920 | 3920 | $degree = 360 - $degree; |
3921 | 3921 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
3922 | 3922 | $bgcolor = imagecolorallocate($img, $r, $g, $b); |
3923 | - $tmp = imageRotate($img, $degree, (int)$bgcolor); |
|
3923 | + $tmp = imageRotate($img, $degree, (int) $bgcolor); |
|
3924 | 3924 | |
3925 | 3925 | $result = self::gdImage($tmp, $path, $destformat, $s['mime']); |
3926 | 3926 | |
@@ -3945,11 +3945,11 @@ discard block |
||
3945 | 3945 | * @return int exit code |
3946 | 3946 | * @author Alexey Sukhotin |
3947 | 3947 | **/ |
3948 | - protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
3948 | + protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
3949 | 3949 | |
3950 | 3950 | $descriptorspec = array( |
3951 | - 0 => array("pipe", "r"), // stdin |
|
3952 | - 1 => array("pipe", "w"), // stdout |
|
3951 | + 0 => array("pipe", "r"), // stdin |
|
3952 | + 1 => array("pipe", "w"), // stdout |
|
3953 | 3953 | 2 => array("pipe", "w") // stderr |
3954 | 3954 | ); |
3955 | 3955 | |
@@ -4006,8 +4006,8 @@ discard block |
||
4006 | 4006 | * @param string $mime |
4007 | 4007 | * @return gd image resource identifier |
4008 | 4008 | */ |
4009 | - protected function gdImageCreate($path,$mime){ |
|
4010 | - switch($mime){ |
|
4009 | + protected function gdImageCreate($path, $mime) { |
|
4010 | + switch ($mime) { |
|
4011 | 4011 | case 'image/jpeg': |
4012 | 4012 | return imagecreatefromjpeg($path); |
4013 | 4013 | |
@@ -4031,7 +4031,7 @@ discard block |
||
4031 | 4031 | * @param string $destformat The Image type to use for $filename |
4032 | 4032 | * @param string $mime The original image mime type |
4033 | 4033 | */ |
4034 | - protected function gdImage($image, $filename, $destformat, $mime ){ |
|
4034 | + protected function gdImage($image, $filename, $destformat, $mime) { |
|
4035 | 4035 | |
4036 | 4036 | if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) { |
4037 | 4037 | return imagejpeg($image, $filename, 100); |
@@ -4050,13 +4050,13 @@ discard block |
||
4050 | 4050 | * @param resource $image gd image resource |
4051 | 4051 | * @param string $bgcolor background color in #rrggbb format |
4052 | 4052 | */ |
4053 | - protected function gdImageBackground($image, $bgcolor){ |
|
4053 | + protected function gdImageBackground($image, $bgcolor) { |
|
4054 | 4054 | |
4055 | - if( $bgcolor == 'transparent' ){ |
|
4056 | - imagesavealpha($image,true); |
|
4055 | + if ($bgcolor == 'transparent') { |
|
4056 | + imagesavealpha($image, true); |
|
4057 | 4057 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
4058 | 4058 | |
4059 | - }else{ |
|
4059 | + } else { |
|
4060 | 4060 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
4061 | 4061 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
4062 | 4062 | } |
@@ -4094,13 +4094,13 @@ discard block |
||
4094 | 4094 | * @return int|bool |
4095 | 4095 | * @author Alexey Sukhotin |
4096 | 4096 | **/ |
4097 | - protected function stripos($haystack , $needle , $offset = 0) { |
|
4097 | + protected function stripos($haystack, $needle, $offset = 0) { |
|
4098 | 4098 | if (function_exists('mb_stripos')) { |
4099 | - return mb_stripos($haystack , $needle , $offset); |
|
4099 | + return mb_stripos($haystack, $needle, $offset); |
|
4100 | 4100 | } else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) { |
4101 | 4101 | return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset); |
4102 | 4102 | } |
4103 | - return stripos($haystack , $needle , $offset); |
|
4103 | + return stripos($haystack, $needle, $offset); |
|
4104 | 4104 | } |
4105 | 4105 | |
4106 | 4106 | /** |
@@ -4150,22 +4150,22 @@ discard block |
||
4150 | 4150 | unset($o); |
4151 | 4151 | $this->procExec('zip -v', $o, $c); |
4152 | 4152 | if ($c == 0) { |
4153 | - $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4153 | + $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4154 | 4154 | } |
4155 | 4155 | unset($o); |
4156 | 4156 | $this->procExec('unzip --help', $o, $c); |
4157 | 4157 | if ($c == 0) { |
4158 | - $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4158 | + $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4159 | 4159 | } |
4160 | 4160 | unset($o); |
4161 | 4161 | $this->procExec('rar --version', $o, $c); |
4162 | 4162 | if ($c == 0 || $c == 7) { |
4163 | 4163 | $arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar'); |
4164 | - $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4164 | + $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4165 | 4165 | } else { |
4166 | 4166 | unset($o); |
4167 | 4167 | $test = $this->procExec('unrar', $o, $c); |
4168 | - if ($c==0 || $c == 7) { |
|
4168 | + if ($c == 0 || $c == 7) { |
|
4169 | 4169 | $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar'); |
4170 | 4170 | } |
4171 | 4171 | } |
@@ -4187,7 +4187,7 @@ discard block |
||
4187 | 4187 | if (empty($arcs['extract']['application/x-tar'])) { |
4188 | 4188 | $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar'); |
4189 | 4189 | } |
4190 | - } else if (substr(PHP_OS,0,3) === 'WIN') { |
|
4190 | + } else if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
4191 | 4191 | // check `7z` for Windows server. |
4192 | 4192 | unset($o); |
4193 | 4193 | $this->procExec('7z', $o, $c); |
@@ -4241,22 +4241,22 @@ discard block |
||
4241 | 4241 | |
4242 | 4242 | // normalize `/../` |
4243 | 4243 | $normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#'; |
4244 | - while(preg_match($normreg, $path)) { |
|
4244 | + while (preg_match($normreg, $path)) { |
|
4245 | 4245 | $path = preg_replace($normreg, '$1', $path); |
4246 | 4246 | } |
4247 | 4247 | |
4248 | 4248 | // 'Here' |
4249 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
4249 | + if ($path === '' || $path === '.'.$separator) return $base; |
|
4250 | 4250 | |
4251 | 4251 | // Absolute path |
4252 | 4252 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
4253 | 4253 | return $path; |
4254 | 4254 | } |
4255 | 4255 | |
4256 | - $preg_separator = '#' . $sepquoted . '#'; |
|
4256 | + $preg_separator = '#'.$sepquoted.'#'; |
|
4257 | 4257 | |
4258 | 4258 | // Relative path from 'Here' |
4259 | - if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) { |
|
4259 | + if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) { |
|
4260 | 4260 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4261 | 4261 | if ($arrn[0] !== '.') { |
4262 | 4262 | array_unshift($arrn, '.'); |
@@ -4270,12 +4270,11 @@ discard block |
||
4270 | 4270 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4271 | 4271 | $arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY); |
4272 | 4272 | |
4273 | - while (! empty($arrn) && $arrn[0] === '..') { |
|
4273 | + while (!empty($arrn) && $arrn[0] === '..') { |
|
4274 | 4274 | array_shift($arrn); |
4275 | 4275 | array_pop($arrp); |
4276 | 4276 | } |
4277 | - $path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) : |
|
4278 | - (! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot); |
|
4277 | + $path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot); |
|
4279 | 4278 | } |
4280 | 4279 | |
4281 | 4280 | return $path; |
@@ -4293,7 +4292,7 @@ discard block |
||
4293 | 4292 | @chmod($dir, 0777); |
4294 | 4293 | foreach (array_diff(scandir($dir), array('.', '..')) as $file) { |
4295 | 4294 | @set_time_limit(30); |
4296 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4295 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4297 | 4296 | if (!is_link($dir) && is_dir($path)) { |
4298 | 4297 | $this->rmdirRecursive($path); |
4299 | 4298 | } else { |
@@ -4380,22 +4379,22 @@ discard block |
||
4380 | 4379 | try { |
4381 | 4380 | if ($start = is_string($zipPath)) { |
4382 | 4381 | $zip = new ZipArchive(); |
4383 | - if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) { |
|
4382 | + if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) { |
|
4384 | 4383 | $zip = false; |
4385 | 4384 | } |
4386 | 4385 | } else { |
4387 | 4386 | $zip = $zipPath; |
4388 | 4387 | } |
4389 | 4388 | if ($zip) { |
4390 | - foreach($files as $file) { |
|
4391 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4389 | + foreach ($files as $file) { |
|
4390 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4392 | 4391 | if (is_dir($path)) { |
4393 | 4392 | $zip->addEmptyDir($file); |
4394 | 4393 | $_files = array(); |
4395 | 4394 | if ($handle = opendir($path)) { |
4396 | 4395 | while (false !== ($entry = readdir($handle))) { |
4397 | 4396 | if ($entry !== "." && $entry !== "..") { |
4398 | - $_files[] = $file . DIRECTORY_SEPARATOR . $entry; |
|
4397 | + $_files[] = $file.DIRECTORY_SEPARATOR.$entry; |
|
4399 | 4398 | } |
4400 | 4399 | } |
4401 | 4400 | closedir($handle); |
@@ -4580,7 +4579,7 @@ discard block |
||
4580 | 4579 | * @return resource|false |
4581 | 4580 | * @author Dmitry (dio) Levashov |
4582 | 4581 | **/ |
4583 | - abstract protected function _fopen($path, $mode="rb"); |
|
4582 | + abstract protected function _fopen($path, $mode = "rb"); |
|
4584 | 4583 | |
4585 | 4584 | /** |
4586 | 4585 | * Close opened file |
@@ -4590,7 +4589,7 @@ discard block |
||
4590 | 4589 | * @return bool |
4591 | 4590 | * @author Dmitry (dio) Levashov |
4592 | 4591 | **/ |
4593 | - abstract protected function _fclose($fp, $path=''); |
|
4592 | + abstract protected function _fclose($fp, $path = ''); |
|
4594 | 4593 | |
4595 | 4594 | /******************** file/dir manipulations *************************/ |
4596 | 4595 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $defaults = array( |
59 | 59 | 'enable' => true, // For control by volume driver |
60 | 60 | 'nfc' => true, // Canonical Decomposition followed by Canonical Composition |
61 | - 'nfkc' => true, // Compatibility Decomposition followed by Canonical |
|
61 | + 'nfkc' => true, // Compatibility Decomposition followed by Canonical |
|
62 | 62 | 'lowercase' => false // Make chars lowercase |
63 | 63 | ); |
64 | 64 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | |
68 | 68 | public function cmdPreprocess($cmd, &$args, $elfinder, $volume) { |
69 | 69 | $opts = $this->getOpts($volume); |
70 | - if (! $opts['enable']) { |
|
70 | + if (!$opts['enable']) { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | |
74 | 74 | if (isset($args['name'])) { |
75 | 75 | if (is_array($args['name'])) { |
76 | - foreach($args['name'] as $i => $name) { |
|
76 | + foreach ($args['name'] as $i => $name) { |
|
77 | 77 | $args['name'][$i] = $this->normalize($name, $opts); |
78 | 78 | } |
79 | 79 | } else { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) { |
87 | 87 | $opts = $this->getOpts($volume); |
88 | - if (! $opts['enable']) { |
|
88 | + if (!$opts['enable']) { |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | private function normalize($str, $opts) { |
111 | 111 | if ($opts['nfc'] || $opts['nfkc']) { |
112 | 112 | if (class_exists('Normalizer', false)) { |
113 | - if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
113 | + if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
114 | 114 | $str = Normalizer::normalize($str, Normalizer::FORM_C); |
115 | - if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
115 | + if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
116 | 116 | $str = Normalizer::normalize($str, Normalizer::FORM_KC); |
117 | 117 | } else { |
118 | - if (! class_exists('I18N_UnicodeNormalizer', false)) { |
|
118 | + if (!class_exists('I18N_UnicodeNormalizer', false)) { |
|
119 | 119 | @ include_once 'I18N/UnicodeNormalizer.php'; |
120 | 120 | } |
121 | 121 | if (class_exists('I18N_UnicodeNormalizer', false)) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | if ($options['user'] === 'init') { |
139 | 139 | |
140 | - if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
140 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
141 | 141 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
142 | 142 | } |
143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | if (class_exists('OAuth', false)) { |
148 | 148 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
149 | 149 | } else { |
150 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
150 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
151 | 151 | // We're going to try to load in manually |
152 | 152 | include 'HTTP/OAuth/Consumer.php'; |
153 | 153 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - if (! $this->oauth) { |
|
160 | + if (!$this->oauth) { |
|
161 | 161 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
162 | 162 | } |
163 | 163 | |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | unset($_SESSION['elFinderDropboxTokens']); |
179 | 179 | } |
180 | 180 | } |
181 | - if (! $html) { |
|
181 | + if (!$html) { |
|
182 | 182 | // get customdata |
183 | 183 | $cdata = ''; |
184 | 184 | $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); |
185 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
186 | - foreach($this->ARGS as $k => $v) { |
|
187 | - if (! in_array($k, $innerKeys)) { |
|
188 | - $cdata .= '&' . $k . '=' . rawurlencode($v); |
|
185 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
186 | + foreach ($this->ARGS as $k => $v) { |
|
187 | + if (!in_array($k, $innerKeys)) { |
|
188 | + $cdata .= '&'.$k.'='.rawurlencode($v); |
|
189 | 189 | } |
190 | 190 | } |
191 | - if (strpos($options['url'], 'http') !== 0 ) { |
|
191 | + if (strpos($options['url'], 'http') !== 0) { |
|
192 | 192 | $options['url'] = $this->getConnectorUrl(); |
193 | 193 | } |
194 | - $callback = $options['url'] |
|
194 | + $callback = $options['url'] |
|
195 | 195 | . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
196 | 196 | |
197 | 197 | try { |
198 | 198 | $tokens = $this->oauth->getRequestToken(); |
199 | - $url= $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
199 | + $url = $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
200 | 200 | } catch (Dropbox_Exception $e) { |
201 | 201 | return array('exit' => true, 'body' => '{msg:errAccess}'); |
202 | 202 | } |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | if (isset($netVolumes[$key])) { |
244 | 244 | $dropboxUid = $netVolumes[$key]['dropboxUid']; |
245 | 245 | } |
246 | - foreach($netVolumes as $volume) { |
|
246 | + foreach ($netVolumes as $volume) { |
|
247 | 247 | if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) { |
248 | 248 | $count++; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | if ($count === 1) { |
252 | 252 | $this->DB->exec('drop table '.$this->DB_TableName); |
253 | - foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
253 | + foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
254 | 254 | unlink($tmb); |
255 | 255 | } |
256 | 256 | } |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | * @author Naoki Sawada |
265 | 265 | */ |
266 | 266 | private function getConnectorUrl() { |
267 | - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
|
267 | + $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') |
|
268 | 268 | . $_SERVER['SERVER_NAME'] // host |
269 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
270 | - . $_SERVER['REQUEST_URI']; // path & query |
|
269 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) // port |
|
270 | + . $_SERVER['REQUEST_URI']; // path & query |
|
271 | 271 | list($url) = explode('?', $url); |
272 | 272 | return $url; |
273 | 273 | } |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | // make net mount key |
304 | 304 | $this->netMountKey = md5(join('-', array('dropbox', $this->options['path']))); |
305 | 305 | |
306 | - if (! $this->oauth) { |
|
306 | + if (!$this->oauth) { |
|
307 | 307 | if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) { |
308 | 308 | $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']); |
309 | 309 | } else { |
310 | 310 | if (class_exists('OAuth', false)) { |
311 | 311 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
312 | 312 | } else { |
313 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
313 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
314 | 314 | // We're going to try to load in manually |
315 | 315 | include 'HTTP/OAuth/Consumer.php'; |
316 | 316 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | - if (! $this->oauth) { |
|
324 | + if (!$this->oauth) { |
|
325 | 325 | return $this->setError('OAuth extension not loaded.'); |
326 | 326 | } |
327 | 327 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $this->root = $this->options['path'] = $this->_normpath($this->options['path']); |
330 | 330 | |
331 | 331 | if (empty($this->options['alias'])) { |
332 | - $this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
332 | + $this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | $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) { |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $res = false; |
445 | 445 | } |
446 | 446 | } |
447 | - if (! $res) { |
|
447 | + if (!$res) { |
|
448 | 448 | try { |
449 | 449 | $this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);'); |
450 | 450 | $this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)'); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | */ |
495 | 495 | private function updateDBdat($path, $dat) { |
496 | 496 | return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat)) |
497 | - . ', isdir=' . ($dat['is_dir']? 1 : 0) |
|
497 | + . ', isdir='.($dat['is_dir'] ? 1 : 0) |
|
498 | 498 | . ' where path='.$this->DB->quote(strtolower(dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path)))); |
499 | 499 | } |
500 | 500 | /*********************************************************************/ |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | */ |
520 | 520 | protected function deltaCheck($refresh = true) { |
521 | 521 | $chk = false; |
522 | - if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
522 | + if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
523 | 523 | $chk = unserialize($chk[0]); |
524 | 524 | } |
525 | 525 | if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) { |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | do { |
542 | 542 | @ ini_set('max_execution_time', 120); |
543 | 543 | $_info = $this->dropbox->delta($cursor); |
544 | - if (! empty($_info['reset'])) { |
|
544 | + if (!empty($_info['reset'])) { |
|
545 | 545 | $this->DB->exec('TRUNCATE table '.$this->DB_TableName); |
546 | 546 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);'); |
547 | 547 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array( |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | } |
555 | 555 | $cursor = $_info['cursor']; |
556 | 556 | |
557 | - foreach($_info['entries'] as $entry) { |
|
557 | + foreach ($_info['entries'] as $entry) { |
|
558 | 558 | $key = strtolower($entry[0]); |
559 | 559 | $pkey = strtolower(dirname($key)); |
560 | 560 | |
@@ -564,27 +564,27 @@ discard block |
||
564 | 564 | |
565 | 565 | if (empty($entry[1])) { |
566 | 566 | $this->DB->exec('delete from '.$this->DB_TableName.' '.$where); |
567 | - ! $delete && $delete = true; |
|
567 | + !$delete && $delete = true; |
|
568 | 568 | continue; |
569 | 569 | } |
570 | 570 | |
571 | 571 | $sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1'; |
572 | - if (! $reset && $this->query($sql)) { |
|
573 | - $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where); |
|
572 | + if (!$reset && $this->query($sql)) { |
|
573 | + $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where); |
|
574 | 574 | } else { |
575 | - $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')'); |
|
575 | + $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')'); |
|
576 | 576 | } |
577 | 577 | } |
578 | - } while (! empty($_info['has_more'])); |
|
578 | + } while (!empty($_info['has_more'])); |
|
579 | 579 | $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\''); |
580 | - if (! $this->DB->commit()) { |
|
580 | + if (!$this->DB->commit()) { |
|
581 | 581 | $e = $this->DB->errorInfo(); |
582 | 582 | return $e[2]; |
583 | 583 | } |
584 | 584 | if ($delete) { |
585 | 585 | $this->DB->exec('vacuum'); |
586 | 586 | } |
587 | - } catch(Dropbox_Exception $e) { |
|
587 | + } catch (Dropbox_Exception $e) { |
|
588 | 588 | return $e->getMessage(); |
589 | 589 | } |
590 | 590 | return true; |
@@ -600,15 +600,14 @@ discard block |
||
600 | 600 | protected function parseRaw($raw) { |
601 | 601 | $stat = array(); |
602 | 602 | |
603 | - $stat['rev'] = isset($raw['rev'])? $raw['rev'] : 'root'; |
|
603 | + $stat['rev'] = isset($raw['rev']) ? $raw['rev'] : 'root'; |
|
604 | 604 | $stat['name'] = basename($raw['path']); |
605 | - $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
|
605 | + $stat['mime'] = $raw['is_dir'] ? 'directory' : $raw['mime_type']; |
|
606 | 606 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
607 | - $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
|
608 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
607 | + $stat['ts'] = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
609 | 608 | $stat['dirs'] = 0; |
610 | 609 | if ($raw['is_dir']) { |
611 | - $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
610 | + $stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
612 | 611 | } |
613 | 612 | |
614 | 613 | if (!empty($raw['url'])) { |
@@ -634,7 +633,7 @@ discard block |
||
634 | 633 | $res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path))); |
635 | 634 | |
636 | 635 | if ($res) { |
637 | - foreach($res as $raw) { |
|
636 | + foreach ($res as $raw) { |
|
638 | 637 | $raw = unserialize($raw); |
639 | 638 | if ($stat = $this->parseRaw($raw)) { |
640 | 639 | $stat = $this->updateCache($raw['path'], $stat); |
@@ -659,10 +658,10 @@ discard block |
||
659 | 658 | protected function doSearch($path, $q, $mimes) { |
660 | 659 | $result = array(); |
661 | 660 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
662 | - $sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
661 | + $sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
663 | 662 | $res = $sth->fetchAll(PDO::FETCH_COLUMN); |
664 | 663 | if ($res) { |
665 | - foreach($res as $raw) { |
|
664 | + foreach ($res as $raw) { |
|
666 | 665 | $raw = unserialize($raw); |
667 | 666 | if ($stat = $this->parseRaw($raw)) { |
668 | 667 | if (!isset($this->cache[$raw['path']])) { |
@@ -753,10 +752,10 @@ discard block |
||
753 | 752 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
754 | 753 | |
755 | 754 | // copy image into tmbPath so some drivers does not store files on local fs |
756 | - if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
755 | + if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
757 | 756 | return false; |
758 | 757 | } |
759 | - if (! file_put_contents($tmb, $data)) { |
|
758 | + if (!file_put_contents($tmb, $data)) { |
|
760 | 759 | return false; |
761 | 760 | } |
762 | 761 | |
@@ -769,15 +768,15 @@ discard block |
||
769 | 768 | } |
770 | 769 | |
771 | 770 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
772 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
773 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
771 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
772 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
774 | 773 | |
775 | 774 | } else { |
776 | 775 | |
777 | 776 | if ($this->options['tmbCrop']) { |
778 | 777 | |
779 | 778 | /* Resize and crop if image bigger than thumbnail */ |
780 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
779 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
781 | 780 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
782 | 781 | } |
783 | 782 | |
@@ -791,7 +790,7 @@ discard block |
||
791 | 790 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
792 | 791 | } |
793 | 792 | |
794 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
793 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
795 | 794 | } |
796 | 795 | |
797 | 796 | if (!$result) { |
@@ -848,7 +847,7 @@ discard block |
||
848 | 847 | } |
849 | 848 | } |
850 | 849 | } |
851 | - if (! $url) { |
|
850 | + if (!$url) { |
|
852 | 851 | try { |
853 | 852 | $res = $this->dropbox->share($path, null, false); |
854 | 853 | $url = $res['url']; |
@@ -860,7 +859,7 @@ discard block |
||
860 | 859 | } |
861 | 860 | list($url) = explode('?', $url); |
862 | 861 | $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url); |
863 | - if (! isset($cache['share']) || $cache['share'] !== $url) { |
|
862 | + if (!isset($cache['share']) || $cache['share'] !== $url) { |
|
864 | 863 | $cache['share'] = $url; |
865 | 864 | $this->updateDBdat($path, $cache); |
866 | 865 | } |
@@ -884,12 +883,12 @@ discard block |
||
884 | 883 | if (function_exists('curl_exec')) { |
885 | 884 | |
886 | 885 | $c = curl_init(); |
887 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
|
888 | - curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
889 | - curl_setopt( $c, CURLOPT_HEADER, 1 ); |
|
890 | - curl_setopt( $c, CURLOPT_NOBODY, true ); |
|
891 | - curl_setopt( $c, CURLOPT_URL, $url ); |
|
892 | - $res = curl_exec( $c ); |
|
886 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
887 | + curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
888 | + curl_setopt($c, CURLOPT_HEADER, 1); |
|
889 | + curl_setopt($c, CURLOPT_NOBODY, true); |
|
890 | + curl_setopt($c, CURLOPT_URL, $url); |
|
891 | + $res = curl_exec($c); |
|
893 | 892 | |
894 | 893 | } else { |
895 | 894 | |
@@ -905,13 +904,13 @@ discard block |
||
905 | 904 | $result = $request2->send(); |
906 | 905 | $res = array(); |
907 | 906 | $res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase(); |
908 | - foreach($result->getHeader() as $key => $val) { |
|
909 | - $res[] = $key . ': ' . $val; |
|
907 | + foreach ($result->getHeader() as $key => $val) { |
|
908 | + $res[] = $key.': '.$val; |
|
910 | 909 | } |
911 | 910 | $res = join("\r\n", $res); |
912 | - } catch( HTTP_Request2_Exception $e ){ |
|
911 | + } catch (HTTP_Request2_Exception $e) { |
|
913 | 912 | $res = ''; |
914 | - } catch (Exception $e){ |
|
913 | + } catch (Exception $e) { |
|
915 | 914 | $res = ''; |
916 | 915 | } |
917 | 916 | |
@@ -964,7 +963,7 @@ discard block |
||
964 | 963 | **/ |
965 | 964 | protected function _normpath($path) { |
966 | 965 | $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); |
967 | - $path = '/' . ltrim($path, '/'); |
|
966 | + $path = '/'.ltrim($path, '/'); |
|
968 | 967 | return $path; |
969 | 968 | } |
970 | 969 | |
@@ -1103,7 +1102,7 @@ discard block |
||
1103 | 1102 | * @return resource|false |
1104 | 1103 | * @author Dmitry (dio) Levashov |
1105 | 1104 | **/ |
1106 | - protected function _fopen($path, $mode='rb') { |
|
1105 | + protected function _fopen($path, $mode = 'rb') { |
|
1107 | 1106 | |
1108 | 1107 | if (($mode == 'rb' || $mode == 'r')) { |
1109 | 1108 | try { |
@@ -1113,7 +1112,7 @@ discard block |
||
1113 | 1112 | fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); |
1114 | 1113 | fputs($fp, "Host: {$url['host']}\r\n"); |
1115 | 1114 | fputs($fp, "\r\n"); |
1116 | - while(trim(fgets($fp)) !== ''){}; |
|
1115 | + while (trim(fgets($fp)) !== '') {}; |
|
1117 | 1116 | return $fp; |
1118 | 1117 | } catch (Dropbox_Exception $e) { |
1119 | 1118 | return false; |
@@ -1144,7 +1143,7 @@ discard block |
||
1144 | 1143 | * @return bool |
1145 | 1144 | * @author Dmitry (dio) Levashov |
1146 | 1145 | **/ |
1147 | - protected function _fclose($fp, $path='') { |
|
1146 | + protected function _fclose($fp, $path = '') { |
|
1148 | 1147 | @fclose($fp); |
1149 | 1148 | if ($path) { |
1150 | 1149 | @unlink($this->getTempFile($path)); |