@@ -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 | /** |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | **/ |
| 574 | 574 | protected function configure() { |
| 575 | 575 | // set ARGS |
| 576 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
| 576 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
| 577 | 577 | // set thumbnails path |
| 578 | 578 | $path = $this->options['tmbPath']; |
| 579 | 579 | if ($path) { |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | // check 'statOwner' for command `chmod` |
| 606 | 606 | if (empty($this->options['statOwner'])) { |
| 607 | - $this->disabled[] ='chmod'; |
|
| 607 | + $this->disabled[] = 'chmod'; |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | // check 'mimeMap' |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | **/ |
| 711 | 711 | public function mount(array $opts) { |
| 712 | 712 | if (!isset($opts['path']) || $opts['path'] === '') { |
| 713 | - return $this->setError('Path undefined.');; |
|
| 713 | + return $this->setError('Path undefined.'); ; |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | $this->options = array_merge($this->options, $opts); |
@@ -729,14 +729,14 @@ discard block |
||
| 729 | 729 | $argInit = !empty($this->ARGS['init']); |
| 730 | 730 | |
| 731 | 731 | // session cache |
| 732 | - if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
| 732 | + if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
| 733 | 733 | $_SESSION[elFinder::$sessionCacheKey][$this->id] = array(); |
| 734 | 734 | } |
| 735 | 735 | $this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id]; |
| 736 | 736 | |
| 737 | 737 | // default file attribute |
| 738 | 738 | $this->defaults = array( |
| 739 | - 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
| 739 | + 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
| 740 | 740 | 'write' => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true, |
| 741 | 741 | 'locked' => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false, |
| 742 | 742 | 'hidden' => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false |
@@ -763,8 +763,8 @@ discard block |
||
| 763 | 763 | $this->access = $this->options['accessControl']; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - $this->today = mktime(0,0,0, date('m'), date('d'), date('Y')); |
|
| 767 | - $this->yesterday = $this->today-86400; |
|
| 766 | + $this->today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
| 767 | + $this->yesterday = $this->today - 86400; |
|
| 768 | 768 | |
| 769 | 769 | // debug($this->attributes); |
| 770 | 770 | if (!$this->init()) { |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | foreach ($mimecf as $line_num => $line) { |
| 864 | 864 | if (!preg_match('/^\s*#/', $line)) { |
| 865 | 865 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
| 866 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
| 866 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
| 867 | 867 | if (!isset(self::$mimetypes[$mime[$i]])) { |
| 868 | 868 | self::$mimetypes[$mime[$i]] = $mime[0]; |
| 869 | 869 | } |
@@ -915,8 +915,8 @@ discard block |
||
| 915 | 915 | 'read' => false |
| 916 | 916 | )); |
| 917 | 917 | } |
| 918 | - $this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1; |
|
| 919 | - $this->tmbSize = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48; |
|
| 918 | + $this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1; |
|
| 919 | + $this->tmbSize = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48; |
|
| 920 | 920 | $this->URL = $this->options['URL']; |
| 921 | 921 | if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) { |
| 922 | 922 | $this->URL .= '/'; |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | public function options($hash) { |
| 1058 | 1058 | $create = $createext = array(); |
| 1059 | 1059 | if (isset($this->archivers['create']) && is_array($this->archivers['create'])) { |
| 1060 | - foreach($this->archivers['create'] as $m => $v) { |
|
| 1060 | + foreach ($this->archivers['create'] as $m => $v) { |
|
| 1061 | 1061 | $create[] = $m; |
| 1062 | 1062 | $createext[$m] = $v['ext']; |
| 1063 | 1063 | } |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | 'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(), |
| 1078 | 1078 | 'createext' => $createext |
| 1079 | 1079 | ), |
| 1080 | - 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array() |
|
| 1080 | + 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array() |
|
| 1081 | 1081 | ); |
| 1082 | 1082 | } |
| 1083 | 1083 | |
@@ -1089,7 +1089,7 @@ discard block |
||
| 1089 | 1089 | * @author Naoki Sawada |
| 1090 | 1090 | */ |
| 1091 | 1091 | public function getOption($name) { |
| 1092 | - return isset($this->options[$name])? $this->options[$name] : null; |
|
| 1092 | + return isset($this->options[$name]) ? $this->options[$name] : null; |
|
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | 1095 | /** |
@@ -1101,7 +1101,7 @@ discard block |
||
| 1101 | 1101 | */ |
| 1102 | 1102 | public function getOptionsPlugin($name = '') { |
| 1103 | 1103 | if ($name) { |
| 1104 | - return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array(); |
|
| 1104 | + return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array(); |
|
| 1105 | 1105 | } else { |
| 1106 | 1106 | return $this->options['plugin']; |
| 1107 | 1107 | } |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | $file = $this->stat($path); |
| 1232 | 1232 | |
| 1233 | 1233 | if ($hash === $this->root()) { |
| 1234 | - $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(); |
|
| 1234 | + $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(); |
|
| 1235 | 1235 | $file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON |
| 1236 | 1236 | } |
| 1237 | 1237 | |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | * @return array|false |
| 1247 | 1247 | * @author Dmitry (dio) Levashov |
| 1248 | 1248 | **/ |
| 1249 | - public function dir($hash, $resolveLink=false) { |
|
| 1249 | + public function dir($hash, $resolveLink = false) { |
|
| 1250 | 1250 | if (($dir = $this->file($hash)) == false) { |
| 1251 | 1251 | return $this->setError(elFinder::ERROR_DIR_NOT_FOUND); |
| 1252 | 1252 | } |
@@ -1310,14 +1310,14 @@ discard block |
||
| 1310 | 1310 | * @return array|false |
| 1311 | 1311 | * @author Dmitry (dio) Levashov |
| 1312 | 1312 | **/ |
| 1313 | - public function tree($hash='', $deep=0, $exclude='') { |
|
| 1313 | + public function tree($hash = '', $deep = 0, $exclude = '') { |
|
| 1314 | 1314 | $path = $hash ? $this->decode($hash) : $this->root; |
| 1315 | 1315 | |
| 1316 | 1316 | if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') { |
| 1317 | 1317 | return false; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | - $dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null); |
|
| 1320 | + $dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null); |
|
| 1321 | 1321 | array_unshift($dirs, $dir); |
| 1322 | 1322 | return $dirs; |
| 1323 | 1323 | } |
@@ -1547,7 +1547,7 @@ discard block |
||
| 1547 | 1547 | * @return array|false |
| 1548 | 1548 | * @author Dmitry (dio) Levashov |
| 1549 | 1549 | **/ |
| 1550 | - public function duplicate($hash, $suffix='copy') { |
|
| 1550 | + public function duplicate($hash, $suffix = 'copy') { |
|
| 1551 | 1551 | if ($this->commandDisabled('duplicate')) { |
| 1552 | 1552 | return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED); |
| 1553 | 1553 | } |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | |
| 1624 | 1624 | if ($file) { // file exists |
| 1625 | 1625 | // check POST data `overwrite` for 3rd party uploader |
| 1626 | - $overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
| 1626 | + $overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
| 1627 | 1627 | if ($overwrite) { |
| 1628 | 1628 | if (!$file['write']) { |
| 1629 | 1629 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
@@ -1694,7 +1694,7 @@ discard block |
||
| 1694 | 1694 | if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) { |
| 1695 | 1695 | return $rmSrc |
| 1696 | 1696 | ? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test)) |
| 1697 | - : $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
| 1697 | + : $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | 1700 | $test = $this->joinPathCE($destination, $name); |
@@ -1857,7 +1857,7 @@ discard block |
||
| 1857 | 1857 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
| 1858 | 1858 | } |
| 1859 | 1859 | $this->clearcache(); |
| 1860 | - $this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir; |
|
| 1860 | + $this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir; |
|
| 1861 | 1861 | |
| 1862 | 1862 | if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) { |
| 1863 | 1863 | if (is_array($path)) { |
@@ -1915,9 +1915,9 @@ discard block |
||
| 1915 | 1915 | if ($name === '') { |
| 1916 | 1916 | $name = count($files) == 1 ? $files[0] : 'Archive'; |
| 1917 | 1917 | } else { |
| 1918 | - $name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name)); |
|
| 1918 | + $name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name)); |
|
| 1919 | 1919 | } |
| 1920 | - $name .='.' . $archiver['ext']; |
|
| 1920 | + $name .= '.'.$archiver['ext']; |
|
| 1921 | 1921 | $name = $this->uniqueName($dir, $name, ''); |
| 1922 | 1922 | $this->clearcache(); |
| 1923 | 1923 | return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false; |
@@ -1953,7 +1953,7 @@ discard block |
||
| 1953 | 1953 | |
| 1954 | 1954 | $path = $this->decode($hash); |
| 1955 | 1955 | |
| 1956 | - $work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path); |
|
| 1956 | + $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path); |
|
| 1957 | 1957 | |
| 1958 | 1958 | if (!$work_path || !is_writable($work_path)) { |
| 1959 | 1959 | if ($work_path && $path !== $work_path && is_file($work_path)) { |
@@ -1968,7 +1968,7 @@ discard block |
||
| 1968 | 1968 | } |
| 1969 | 1969 | } |
| 1970 | 1970 | |
| 1971 | - switch($mode) { |
|
| 1971 | + switch ($mode) { |
|
| 1972 | 1972 | |
| 1973 | 1973 | case 'propresize': |
| 1974 | 1974 | $result = $this->imgResize($work_path, $width, $height, true, true); |
@@ -2064,7 +2064,7 @@ discard block |
||
| 2064 | 2064 | } |
| 2065 | 2065 | return ($q === '' || $this->commandDisabled('search')) |
| 2066 | 2066 | ? array() |
| 2067 | - : $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes); |
|
| 2067 | + : $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes); |
|
| 2068 | 2068 | } |
| 2069 | 2069 | |
| 2070 | 2070 | /** |
@@ -2133,9 +2133,9 @@ discard block |
||
| 2133 | 2133 | $path = ltrim($path, $this->separator); |
| 2134 | 2134 | $dirs = explode($this->separator, $path); |
| 2135 | 2135 | array_pop($dirs); |
| 2136 | - foreach($dirs as $dir) { |
|
| 2136 | + foreach ($dirs as $dir) { |
|
| 2137 | 2137 | $targetPath = $this->joinPathCE($base, $dir); |
| 2138 | - if (! $_realpath = $this->realpath($this->encode($targetPath))) { |
|
| 2138 | + if (!$_realpath = $this->realpath($this->encode($targetPath))) { |
|
| 2139 | 2139 | if ($stat = $this->mkdir($targetHash, $dir)) { |
| 2140 | 2140 | $result['added'][] = $stat; |
| 2141 | 2141 | $targetHash = $stat['hash']; |
@@ -2202,7 +2202,7 @@ discard block |
||
| 2202 | 2202 | * @author Naoki Sawada |
| 2203 | 2203 | **/ |
| 2204 | 2204 | protected function dirnameCE($path) { |
| 2205 | - return (!$this->encoding)? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
| 2205 | + return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
| 2206 | 2206 | } |
| 2207 | 2207 | |
| 2208 | 2208 | /** |
@@ -2213,7 +2213,7 @@ discard block |
||
| 2213 | 2213 | * @author Naoki Sawada |
| 2214 | 2214 | **/ |
| 2215 | 2215 | protected function basenameCE($path) { |
| 2216 | - return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
| 2216 | + return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
| 2217 | 2217 | } |
| 2218 | 2218 | |
| 2219 | 2219 | /** |
@@ -2226,7 +2226,7 @@ discard block |
||
| 2226 | 2226 | * @author Naoki Sawada |
| 2227 | 2227 | **/ |
| 2228 | 2228 | protected function joinPathCE($dir, $name) { |
| 2229 | - return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
| 2229 | + return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
| 2230 | 2230 | } |
| 2231 | 2231 | |
| 2232 | 2232 | /** |
@@ -2237,7 +2237,7 @@ discard block |
||
| 2237 | 2237 | * @author Naoki Sawada |
| 2238 | 2238 | **/ |
| 2239 | 2239 | protected function normpathCE($path) { |
| 2240 | - return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
| 2240 | + return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | /** |
@@ -2248,7 +2248,7 @@ discard block |
||
| 2248 | 2248 | * @author Naoki Sawada |
| 2249 | 2249 | **/ |
| 2250 | 2250 | protected function relpathCE($path) { |
| 2251 | - return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
| 2251 | + return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | 2254 | /** |
@@ -2259,7 +2259,7 @@ discard block |
||
| 2259 | 2259 | * @author Naoki Sawada |
| 2260 | 2260 | **/ |
| 2261 | 2261 | protected function abspathCE($path) { |
| 2262 | - return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
| 2262 | + return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
| 2263 | 2263 | } |
| 2264 | 2264 | |
| 2265 | 2265 | /** |
@@ -2271,7 +2271,7 @@ discard block |
||
| 2271 | 2271 | * @author Naoki Sawada |
| 2272 | 2272 | **/ |
| 2273 | 2273 | protected function inpathCE($path, $parent) { |
| 2274 | - return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
| 2274 | + return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
| 2275 | 2275 | } |
| 2276 | 2276 | |
| 2277 | 2277 | /** |
@@ -2282,8 +2282,8 @@ discard block |
||
| 2282 | 2282 | * @return resource|false |
| 2283 | 2283 | * @author Naoki Sawada |
| 2284 | 2284 | **/ |
| 2285 | - protected function fopenCE($path, $mode='rb') { |
|
| 2286 | - return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
| 2285 | + protected function fopenCE($path, $mode = 'rb') { |
|
| 2286 | + return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
| 2287 | 2287 | } |
| 2288 | 2288 | |
| 2289 | 2289 | /** |
@@ -2294,8 +2294,8 @@ discard block |
||
| 2294 | 2294 | * @return bool |
| 2295 | 2295 | * @author Naoki Sawada |
| 2296 | 2296 | **/ |
| 2297 | - protected function fcloseCE($fp, $path='') { |
|
| 2298 | - return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
| 2297 | + protected function fcloseCE($fp, $path = '') { |
|
| 2298 | + return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
| 2299 | 2299 | } |
| 2300 | 2300 | |
| 2301 | 2301 | /** |
@@ -2310,7 +2310,7 @@ discard block |
||
| 2310 | 2310 | * @author Naoki Sawada |
| 2311 | 2311 | **/ |
| 2312 | 2312 | protected function saveCE($fp, $dir, $name, $stat) { |
| 2313 | - return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
| 2313 | + return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
| 2314 | 2314 | } |
| 2315 | 2315 | |
| 2316 | 2316 | /** |
@@ -2322,7 +2322,7 @@ discard block |
||
| 2322 | 2322 | **/ |
| 2323 | 2323 | protected function subdirsCE($path) { |
| 2324 | 2324 | if (!isset($this->subdirsCache[$path])) { |
| 2325 | - $this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
| 2325 | + $this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
| 2326 | 2326 | } |
| 2327 | 2327 | return $this->subdirsCache[$path]; |
| 2328 | 2328 | } |
@@ -2335,7 +2335,7 @@ discard block |
||
| 2335 | 2335 | * @author Naoki Sawada |
| 2336 | 2336 | **/ |
| 2337 | 2337 | protected function scandirCE($path) { |
| 2338 | - return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
| 2338 | + return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
| 2339 | 2339 | } |
| 2340 | 2340 | |
| 2341 | 2341 | /** |
@@ -2348,7 +2348,7 @@ discard block |
||
| 2348 | 2348 | * @author Naoki Sawada |
| 2349 | 2349 | **/ |
| 2350 | 2350 | protected function symlinkCE($source, $targetDir, $name) { |
| 2351 | - return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
| 2351 | + return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
| 2352 | 2352 | } |
| 2353 | 2353 | |
| 2354 | 2354 | /***************** paths *******************/ |
@@ -2367,7 +2367,7 @@ discard block |
||
| 2367 | 2367 | // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root |
| 2368 | 2368 | $p = $this->relpathCE($path); |
| 2369 | 2369 | // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt |
| 2370 | - if ($p === '') { |
|
| 2370 | + if ($p === '') { |
|
| 2371 | 2371 | $p = DIRECTORY_SEPARATOR; |
| 2372 | 2372 | } |
| 2373 | 2373 | |
@@ -2400,7 +2400,7 @@ discard block |
||
| 2400 | 2400 | // TODO uncrypt hash and return path |
| 2401 | 2401 | $path = $this->uncrypt($h); |
| 2402 | 2402 | // append ROOT to path after it was cut in encode |
| 2403 | - return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
| 2403 | + return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
| 2404 | 2404 | } |
| 2405 | 2405 | } |
| 2406 | 2406 | |
@@ -2457,21 +2457,21 @@ discard block |
||
| 2457 | 2457 | * @author Dmitry (dio) Levashov |
| 2458 | 2458 | **/ |
| 2459 | 2459 | public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) { |
| 2460 | - $ext = ''; |
|
| 2460 | + $ext = ''; |
|
| 2461 | 2461 | |
| 2462 | 2462 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 2463 | 2463 | $ext = '.'.$m[1]; |
| 2464 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 2464 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 2465 | 2465 | } |
| 2466 | 2466 | |
| 2467 | 2467 | if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) { |
| 2468 | - $i = (int)$m[2]; |
|
| 2469 | - $name = substr($name, 0, strlen($name)-strlen($m[2])); |
|
| 2468 | + $i = (int) $m[2]; |
|
| 2469 | + $name = substr($name, 0, strlen($name) - strlen($m[2])); |
|
| 2470 | 2470 | } else { |
| 2471 | 2471 | $i = $start; |
| 2472 | 2472 | $name .= $suffix; |
| 2473 | 2473 | } |
| 2474 | - $max = $i+100000; |
|
| 2474 | + $max = $i + 100000; |
|
| 2475 | 2475 | |
| 2476 | 2476 | while ($i <= $max) { |
| 2477 | 2477 | $n = $name.($i > 0 ? $i : '').$ext; |
@@ -2495,7 +2495,7 @@ discard block |
||
| 2495 | 2495 | * @author Naoki Sawada |
| 2496 | 2496 | */ |
| 2497 | 2497 | public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') { |
| 2498 | - return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
| 2498 | + return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
| 2499 | 2499 | } |
| 2500 | 2500 | |
| 2501 | 2501 | /** |
@@ -2508,7 +2508,7 @@ discard block |
||
| 2508 | 2508 | * @author Naoki Sawada |
| 2509 | 2509 | */ |
| 2510 | 2510 | public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') { |
| 2511 | - return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
| 2511 | + return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
| 2512 | 2512 | } |
| 2513 | 2513 | |
| 2514 | 2514 | /** |
@@ -2528,7 +2528,7 @@ discard block |
||
| 2528 | 2528 | } |
| 2529 | 2529 | if (is_array($var)) { |
| 2530 | 2530 | $_ret = array(); |
| 2531 | - foreach($var as $_k => $_v) { |
|
| 2531 | + foreach ($var as $_k => $_v) { |
|
| 2532 | 2532 | $_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_'); |
| 2533 | 2533 | } |
| 2534 | 2534 | $var = $_ret; |
@@ -2540,7 +2540,7 @@ discard block |
||
| 2540 | 2540 | $_var = str_replace('?', $unknown, $_var); |
| 2541 | 2541 | } |
| 2542 | 2542 | } |
| 2543 | - if ($_var !== false) { |
|
| 2543 | + if ($_var !== false) { |
|
| 2544 | 2544 | $var = $_var; |
| 2545 | 2545 | } |
| 2546 | 2546 | } |
@@ -2567,7 +2567,7 @@ discard block |
||
| 2567 | 2567 | |
| 2568 | 2568 | $key = ''; |
| 2569 | 2569 | if ($path !== '') { |
| 2570 | - $key = $this->id . '#' . $path; |
|
| 2570 | + $key = $this->id.'#'.$path; |
|
| 2571 | 2571 | if (isset($cache[$key])) { |
| 2572 | 2572 | return $cache[$key]; |
| 2573 | 2573 | } |
@@ -2599,7 +2599,7 @@ discard block |
||
| 2599 | 2599 | if ($work = $this->getTempFile()) { |
| 2600 | 2600 | if ($wfp = fopen($work, 'wb')) { |
| 2601 | 2601 | if ($fp = $this->_fopen($path)) { |
| 2602 | - while(!feof($fp)) { |
|
| 2602 | + while (!feof($fp)) { |
|
| 2603 | 2603 | fwrite($wfp, fread($fp, 8192)); |
| 2604 | 2604 | } |
| 2605 | 2605 | $this->_fclose($fp, $path); |
@@ -2643,7 +2643,7 @@ discard block |
||
| 2643 | 2643 | @set_time_limit(30); |
| 2644 | 2644 | $stat = $this->stat($this->convEncOut($p)); |
| 2645 | 2645 | $this->convEncIn(); |
| 2646 | - ($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p); |
|
| 2646 | + ($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p); |
|
| 2647 | 2647 | } |
| 2648 | 2648 | return $this->_rmdir($localpath); |
| 2649 | 2649 | } |
@@ -2660,7 +2660,7 @@ discard block |
||
| 2660 | 2660 | * @return bool |
| 2661 | 2661 | * @author Dmitry (dio) Levashov |
| 2662 | 2662 | **/ |
| 2663 | - protected function attr($path, $name, $val=null, $isDir=null) { |
|
| 2663 | + protected function attr($path, $name, $val = null, $isDir = null) { |
|
| 2664 | 2664 | if (!isset($this->defaults[$name])) { |
| 2665 | 2665 | return false; |
| 2666 | 2666 | } |
@@ -2692,7 +2692,7 @@ discard block |
||
| 2692 | 2692 | } |
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | - return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm; |
|
| 2695 | + return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm; |
|
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | 2698 | /** |
@@ -2736,7 +2736,7 @@ discard block |
||
| 2736 | 2736 | protected function allowPutMime($mime) { |
| 2737 | 2737 | // logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order |
| 2738 | 2738 | $allow = $this->mimeAccepted($mime, $this->uploadAllow, null); |
| 2739 | - $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
| 2739 | + $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
| 2740 | 2740 | $res = true; // default to allow |
| 2741 | 2741 | if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny' |
| 2742 | 2742 | $res = false; // default is deny |
@@ -2809,10 +2809,10 @@ discard block |
||
| 2809 | 2809 | if ($this->rootName) { |
| 2810 | 2810 | $stat['name'] = $this->rootName; |
| 2811 | 2811 | } |
| 2812 | - if (! empty($this->options['icon'])) { |
|
| 2812 | + if (!empty($this->options['icon'])) { |
|
| 2813 | 2813 | $stat['icon'] = $this->options['icon']; |
| 2814 | 2814 | } |
| 2815 | - if (! empty($this->options['rootCssClass'])) { |
|
| 2815 | + if (!empty($this->options['rootCssClass'])) { |
|
| 2816 | 2816 | $stat['csscls'] = $this->options['rootCssClass']; |
| 2817 | 2817 | } |
| 2818 | 2818 | } else { |
@@ -2860,7 +2860,7 @@ discard block |
||
| 2860 | 2860 | // lock when parent directory is not writable |
| 2861 | 2861 | if (!isset($stat['locked'])) { |
| 2862 | 2862 | $parent = $this->dirnameCE($path); |
| 2863 | - $pstat = isset($this->cache[$parent])? $this->cache[$parent] : array(); |
|
| 2863 | + $pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array(); |
|
| 2864 | 2864 | if (isset($pstat['write']) && !$pstat['write']) { |
| 2865 | 2865 | $stat['locked'] = true; |
| 2866 | 2866 | } |
@@ -2918,7 +2918,7 @@ discard block |
||
| 2918 | 2918 | } |
| 2919 | 2919 | if (!isset($stat['url']) && $this->URL && $this->encoding) { |
| 2920 | 2920 | $_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1)); |
| 2921 | - $stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true))); |
|
| 2921 | + $stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true))); |
|
| 2922 | 2922 | } |
| 2923 | 2923 | } else { |
| 2924 | 2924 | if ($isDir) { |
@@ -3162,7 +3162,7 @@ discard block |
||
| 3162 | 3162 | * @return array |
| 3163 | 3163 | * @author Dmitry (dio) Levashov |
| 3164 | 3164 | **/ |
| 3165 | - protected function gettree($path, $deep, $exclude='') { |
|
| 3165 | + protected function gettree($path, $deep, $exclude = '') { |
|
| 3166 | 3166 | $dirs = array(); |
| 3167 | 3167 | |
| 3168 | 3168 | !isset($this->dirsCache[$path]) && $this->cacheDir($path); |
@@ -3173,7 +3173,7 @@ discard block |
||
| 3173 | 3173 | if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') { |
| 3174 | 3174 | $dirs[] = $stat; |
| 3175 | 3175 | if ($deep > 0 && !empty($stat['dirs'])) { |
| 3176 | - $dirs = array_merge($dirs, $this->gettree($p, $deep-1)); |
|
| 3176 | + $dirs = array_merge($dirs, $this->gettree($p, $deep - 1)); |
|
| 3177 | 3177 | } |
| 3178 | 3178 | } |
| 3179 | 3179 | } |
@@ -3193,7 +3193,7 @@ discard block |
||
| 3193 | 3193 | protected function doSearch($path, $q, $mimes) { |
| 3194 | 3194 | $result = array(); |
| 3195 | 3195 | |
| 3196 | - foreach($this->scandirCE($path) as $p) { |
|
| 3196 | + foreach ($this->scandirCE($path) as $p) { |
|
| 3197 | 3197 | @set_time_limit(30); |
| 3198 | 3198 | $stat = $this->stat($p); |
| 3199 | 3199 | |
@@ -3214,7 +3214,7 @@ discard block |
||
| 3214 | 3214 | if ($this->encoding) { |
| 3215 | 3215 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
| 3216 | 3216 | } |
| 3217 | - $stat['url'] = $this->URL . $path; |
|
| 3217 | + $stat['url'] = $this->URL.$path; |
|
| 3218 | 3218 | } |
| 3219 | 3219 | |
| 3220 | 3220 | $result[] = $stat; |
@@ -3248,7 +3248,7 @@ discard block |
||
| 3248 | 3248 | if (!$this->inpathCE($target, $this->root)) { |
| 3249 | 3249 | return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK); |
| 3250 | 3250 | } |
| 3251 | - $stat = $this->stat($target); |
|
| 3251 | + $stat = $this->stat($target); |
|
| 3252 | 3252 | $this->clearcache(); |
| 3253 | 3253 | return $stat && $this->symlinkCE($target, $dst, $name) |
| 3254 | 3254 | ? $this->joinPathCE($dst, $name) |
@@ -3529,15 +3529,15 @@ discard block |
||
| 3529 | 3529 | } |
| 3530 | 3530 | |
| 3531 | 3531 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
| 3532 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
| 3533 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
| 3532 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
| 3533 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
| 3534 | 3534 | } else { |
| 3535 | 3535 | |
| 3536 | 3536 | if ($this->options['tmbCrop']) { |
| 3537 | 3537 | |
| 3538 | 3538 | $result = $tmb; |
| 3539 | 3539 | /* Resize and crop if image bigger than thumbnail */ |
| 3540 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
| 3540 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
| 3541 | 3541 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
| 3542 | 3542 | } |
| 3543 | 3543 | |
@@ -3554,7 +3554,7 @@ discard block |
||
| 3554 | 3554 | } |
| 3555 | 3555 | |
| 3556 | 3556 | if ($result) { |
| 3557 | - $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
| 3557 | + $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
| 3558 | 3558 | } |
| 3559 | 3559 | } |
| 3560 | 3560 | |
@@ -3595,18 +3595,18 @@ discard block |
||
| 3595 | 3595 | /* Resizing by biggest side */ |
| 3596 | 3596 | if ($resizeByBiggerSide) { |
| 3597 | 3597 | if ($orig_w > $orig_h) { |
| 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 | } else { |
| 3601 | - $size_w = round($orig_w * $height / $orig_h); |
|
| 3601 | + $size_w = round($orig_w*$height/$orig_h); |
|
| 3602 | 3602 | $size_h = $height; |
| 3603 | 3603 | } |
| 3604 | 3604 | } else { |
| 3605 | 3605 | if ($orig_w > $orig_h) { |
| 3606 | - $size_w = round($orig_w * $height / $orig_h); |
|
| 3606 | + $size_w = round($orig_w*$height/$orig_h); |
|
| 3607 | 3607 | $size_h = $height; |
| 3608 | 3608 | } else { |
| 3609 | - $size_h = round($orig_h * $width / $orig_w); |
|
| 3609 | + $size_h = round($orig_h*$width/$orig_w); |
|
| 3610 | 3610 | $size_w = $width; |
| 3611 | 3611 | } |
| 3612 | 3612 | } |
@@ -3624,7 +3624,7 @@ discard block |
||
| 3624 | 3624 | // Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb |
| 3625 | 3625 | // resize bench: http://app-mgng.rhcloud.com/9 |
| 3626 | 3626 | // resize sample: http://www.dylanbeattie.net/magick/filters/result.html |
| 3627 | - $filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
| 3627 | + $filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
| 3628 | 3628 | |
| 3629 | 3629 | $ani = ($img->getNumberImages() > 1); |
| 3630 | 3630 | if ($ani && is_null($destformat)) { |
@@ -3649,11 +3649,11 @@ discard block |
||
| 3649 | 3649 | break; |
| 3650 | 3650 | |
| 3651 | 3651 | case 'gd': |
| 3652 | - $img = self::gdImageCreate($path,$s['mime']); |
|
| 3652 | + $img = self::gdImageCreate($path, $s['mime']); |
|
| 3653 | 3653 | |
| 3654 | - if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
| 3654 | + if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
| 3655 | 3655 | |
| 3656 | - self::gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
| 3656 | + self::gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
| 3657 | 3657 | |
| 3658 | 3658 | if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) { |
| 3659 | 3659 | return false; |
@@ -3729,11 +3729,11 @@ discard block |
||
| 3729 | 3729 | break; |
| 3730 | 3730 | |
| 3731 | 3731 | case 'gd': |
| 3732 | - $img = self::gdImageCreate($path,$s['mime']); |
|
| 3732 | + $img = self::gdImageCreate($path, $s['mime']); |
|
| 3733 | 3733 | |
| 3734 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 3734 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 3735 | 3735 | |
| 3736 | - self::gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
| 3736 | + self::gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
| 3737 | 3737 | |
| 3738 | 3738 | $size_w = $width; |
| 3739 | 3739 | $size_h = $height; |
@@ -3783,8 +3783,8 @@ discard block |
||
| 3783 | 3783 | $result = false; |
| 3784 | 3784 | |
| 3785 | 3785 | /* Coordinates for image over square aligning */ |
| 3786 | - $y = ceil(abs($height - $s[1]) / 2); |
|
| 3787 | - $x = ceil(abs($width - $s[0]) / 2); |
|
| 3786 | + $y = ceil(abs($height - $s[1])/2); |
|
| 3787 | + $x = ceil(abs($width - $s[0])/2); |
|
| 3788 | 3788 | |
| 3789 | 3789 | switch ($this->imgLib) { |
| 3790 | 3790 | case 'imagick': |
@@ -3804,7 +3804,7 @@ discard block |
||
| 3804 | 3804 | $gif->newImage($width, $height, new ImagickPixel($bgcolor)); |
| 3805 | 3805 | $gif->setImageColorspace($img->getImageColorspace()); |
| 3806 | 3806 | $gif->setImageFormat('gif'); |
| 3807 | - $gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
| 3807 | + $gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
| 3808 | 3808 | $gif->setImageDelay($img->getImageDelay()); |
| 3809 | 3809 | $gif->setImageIterations($img->getImageIterations()); |
| 3810 | 3810 | $img1->addImage($gif); |
@@ -3820,7 +3820,7 @@ discard block |
||
| 3820 | 3820 | $img1->newImage($width, $height, new ImagickPixel($bgcolor)); |
| 3821 | 3821 | $img1->setImageColorspace($img->getImageColorspace()); |
| 3822 | 3822 | $img1->setImageFormat($destformat != null ? $destformat : $img->getFormat()); |
| 3823 | - $img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
| 3823 | + $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
| 3824 | 3824 | $result = $img1->writeImage($path); |
| 3825 | 3825 | } |
| 3826 | 3826 | |
@@ -3831,11 +3831,11 @@ discard block |
||
| 3831 | 3831 | break; |
| 3832 | 3832 | |
| 3833 | 3833 | case 'gd': |
| 3834 | - $img = self::gdImageCreate($path,$s['mime']); |
|
| 3834 | + $img = self::gdImageCreate($path, $s['mime']); |
|
| 3835 | 3835 | |
| 3836 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 3836 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 3837 | 3837 | |
| 3838 | - self::gdImageBackground($tmp,$bgcolor); |
|
| 3838 | + self::gdImageBackground($tmp, $bgcolor); |
|
| 3839 | 3839 | |
| 3840 | 3840 | if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) { |
| 3841 | 3841 | return false; |
@@ -3866,15 +3866,15 @@ discard block |
||
| 3866 | 3866 | * @author Troex Nevelin |
| 3867 | 3867 | **/ |
| 3868 | 3868 | protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) { |
| 3869 | - if (($s = @getimagesize($path)) == false || $degree % 360 === 0) { |
|
| 3869 | + if (($s = @getimagesize($path)) == false || $degree%360 === 0) { |
|
| 3870 | 3870 | return false; |
| 3871 | 3871 | } |
| 3872 | 3872 | |
| 3873 | 3873 | $result = false; |
| 3874 | 3874 | |
| 3875 | 3875 | // try lossless rotate |
| 3876 | - if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
| 3877 | - $count = ($degree / 90) % 4; |
|
| 3876 | + if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
| 3877 | + $count = ($degree/90)%4; |
|
| 3878 | 3878 | $exiftran = array( |
| 3879 | 3879 | 1 => '-9', |
| 3880 | 3880 | 2 => '-1', |
@@ -3890,7 +3890,7 @@ discard block |
||
| 3890 | 3890 | 'exiftran -i '.$exiftran[$count].' '.$path, |
| 3891 | 3891 | 'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath |
| 3892 | 3892 | ); |
| 3893 | - foreach($cmds as $cmd) { |
|
| 3893 | + foreach ($cmds as $cmd) { |
|
| 3894 | 3894 | if ($this->procExec($cmd) === 0) { |
| 3895 | 3895 | $result = true; |
| 3896 | 3896 | break; |
@@ -3926,12 +3926,12 @@ discard block |
||
| 3926 | 3926 | break; |
| 3927 | 3927 | |
| 3928 | 3928 | case 'gd': |
| 3929 | - $img = self::gdImageCreate($path,$s['mime']); |
|
| 3929 | + $img = self::gdImageCreate($path, $s['mime']); |
|
| 3930 | 3930 | |
| 3931 | 3931 | $degree = 360 - $degree; |
| 3932 | 3932 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
| 3933 | 3933 | $bgcolor = imagecolorallocate($img, $r, $g, $b); |
| 3934 | - $tmp = imageRotate($img, $degree, (int)$bgcolor); |
|
| 3934 | + $tmp = imageRotate($img, $degree, (int) $bgcolor); |
|
| 3935 | 3935 | |
| 3936 | 3936 | $result = self::gdImage($tmp, $path, $destformat, $s['mime']); |
| 3937 | 3937 | |
@@ -3956,11 +3956,11 @@ discard block |
||
| 3956 | 3956 | * @return int exit code |
| 3957 | 3957 | * @author Alexey Sukhotin |
| 3958 | 3958 | **/ |
| 3959 | - protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
| 3959 | + protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
| 3960 | 3960 | |
| 3961 | 3961 | $descriptorspec = array( |
| 3962 | - 0 => array("pipe", "r"), // stdin |
|
| 3963 | - 1 => array("pipe", "w"), // stdout |
|
| 3962 | + 0 => array("pipe", "r"), // stdin |
|
| 3963 | + 1 => array("pipe", "w"), // stdout |
|
| 3964 | 3964 | 2 => array("pipe", "w") // stderr |
| 3965 | 3965 | ); |
| 3966 | 3966 | |
@@ -4017,8 +4017,8 @@ discard block |
||
| 4017 | 4017 | * @param string $mime |
| 4018 | 4018 | * @return gd image resource identifier |
| 4019 | 4019 | */ |
| 4020 | - protected function gdImageCreate($path,$mime){ |
|
| 4021 | - switch($mime){ |
|
| 4020 | + protected function gdImageCreate($path, $mime) { |
|
| 4021 | + switch ($mime) { |
|
| 4022 | 4022 | case 'image/jpeg': |
| 4023 | 4023 | return imagecreatefromjpeg($path); |
| 4024 | 4024 | |
@@ -4042,7 +4042,7 @@ discard block |
||
| 4042 | 4042 | * @param string $destformat The Image type to use for $filename |
| 4043 | 4043 | * @param string $mime The original image mime type |
| 4044 | 4044 | */ |
| 4045 | - protected function gdImage($image, $filename, $destformat, $mime ){ |
|
| 4045 | + protected function gdImage($image, $filename, $destformat, $mime) { |
|
| 4046 | 4046 | |
| 4047 | 4047 | if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) { |
| 4048 | 4048 | return imagejpeg($image, $filename, 100); |
@@ -4061,13 +4061,13 @@ discard block |
||
| 4061 | 4061 | * @param resource $image gd image resource |
| 4062 | 4062 | * @param string $bgcolor background color in #rrggbb format |
| 4063 | 4063 | */ |
| 4064 | - protected function gdImageBackground($image, $bgcolor){ |
|
| 4064 | + protected function gdImageBackground($image, $bgcolor) { |
|
| 4065 | 4065 | |
| 4066 | - if( $bgcolor == 'transparent' ){ |
|
| 4067 | - imagesavealpha($image,true); |
|
| 4066 | + if ($bgcolor == 'transparent') { |
|
| 4067 | + imagesavealpha($image, true); |
|
| 4068 | 4068 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
| 4069 | 4069 | |
| 4070 | - }else{ |
|
| 4070 | + } else { |
|
| 4071 | 4071 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
| 4072 | 4072 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
| 4073 | 4073 | } |
@@ -4105,13 +4105,13 @@ discard block |
||
| 4105 | 4105 | * @return int|bool |
| 4106 | 4106 | * @author Alexey Sukhotin |
| 4107 | 4107 | **/ |
| 4108 | - protected function stripos($haystack , $needle , $offset = 0) { |
|
| 4108 | + protected function stripos($haystack, $needle, $offset = 0) { |
|
| 4109 | 4109 | if (function_exists('mb_stripos')) { |
| 4110 | - return mb_stripos($haystack , $needle , $offset, 'UTF-8'); |
|
| 4110 | + return mb_stripos($haystack, $needle, $offset, 'UTF-8'); |
|
| 4111 | 4111 | } else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) { |
| 4112 | 4112 | return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset); |
| 4113 | 4113 | } |
| 4114 | - return stripos($haystack , $needle , $offset); |
|
| 4114 | + return stripos($haystack, $needle, $offset); |
|
| 4115 | 4115 | } |
| 4116 | 4116 | |
| 4117 | 4117 | /** |
@@ -4161,22 +4161,22 @@ discard block |
||
| 4161 | 4161 | unset($o); |
| 4162 | 4162 | $this->procExec('zip -v', $o, $c); |
| 4163 | 4163 | if ($c == 0) { |
| 4164 | - $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
| 4164 | + $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
| 4165 | 4165 | } |
| 4166 | 4166 | unset($o); |
| 4167 | 4167 | $this->procExec('unzip --help', $o, $c); |
| 4168 | 4168 | if ($c == 0) { |
| 4169 | - $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
| 4169 | + $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
| 4170 | 4170 | } |
| 4171 | 4171 | unset($o); |
| 4172 | 4172 | $this->procExec('rar --version', $o, $c); |
| 4173 | 4173 | if ($c == 0 || $c == 7) { |
| 4174 | 4174 | $arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar'); |
| 4175 | - $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
| 4175 | + $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
| 4176 | 4176 | } else { |
| 4177 | 4177 | unset($o); |
| 4178 | 4178 | $test = $this->procExec('unrar', $o, $c); |
| 4179 | - if ($c==0 || $c == 7) { |
|
| 4179 | + if ($c == 0 || $c == 7) { |
|
| 4180 | 4180 | $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar'); |
| 4181 | 4181 | } |
| 4182 | 4182 | } |
@@ -4198,7 +4198,7 @@ discard block |
||
| 4198 | 4198 | if (empty($arcs['extract']['application/x-tar'])) { |
| 4199 | 4199 | $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar'); |
| 4200 | 4200 | } |
| 4201 | - } else if (substr(PHP_OS,0,3) === 'WIN') { |
|
| 4201 | + } else if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
| 4202 | 4202 | // check `7z` for Windows server. |
| 4203 | 4203 | unset($o); |
| 4204 | 4204 | $this->procExec('7z', $o, $c); |
@@ -4252,22 +4252,22 @@ discard block |
||
| 4252 | 4252 | |
| 4253 | 4253 | // normalize `/../` |
| 4254 | 4254 | $normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#'; |
| 4255 | - while(preg_match($normreg, $path)) { |
|
| 4255 | + while (preg_match($normreg, $path)) { |
|
| 4256 | 4256 | $path = preg_replace($normreg, '$1', $path); |
| 4257 | 4257 | } |
| 4258 | 4258 | |
| 4259 | 4259 | // 'Here' |
| 4260 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
| 4260 | + if ($path === '' || $path === '.'.$separator) return $base; |
|
| 4261 | 4261 | |
| 4262 | 4262 | // Absolute path |
| 4263 | 4263 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
| 4264 | 4264 | return $path; |
| 4265 | 4265 | } |
| 4266 | 4266 | |
| 4267 | - $preg_separator = '#' . $sepquoted . '#'; |
|
| 4267 | + $preg_separator = '#'.$sepquoted.'#'; |
|
| 4268 | 4268 | |
| 4269 | 4269 | // Relative path from 'Here' |
| 4270 | - if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) { |
|
| 4270 | + if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) { |
|
| 4271 | 4271 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
| 4272 | 4272 | if ($arrn[0] !== '.') { |
| 4273 | 4273 | array_unshift($arrn, '.'); |
@@ -4281,12 +4281,11 @@ discard block |
||
| 4281 | 4281 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
| 4282 | 4282 | $arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY); |
| 4283 | 4283 | |
| 4284 | - while (! empty($arrn) && $arrn[0] === '..') { |
|
| 4284 | + while (!empty($arrn) && $arrn[0] === '..') { |
|
| 4285 | 4285 | array_shift($arrn); |
| 4286 | 4286 | array_pop($arrp); |
| 4287 | 4287 | } |
| 4288 | - $path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) : |
|
| 4289 | - (! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot); |
|
| 4288 | + $path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot); |
|
| 4290 | 4289 | } |
| 4291 | 4290 | |
| 4292 | 4291 | return $path; |
@@ -4304,7 +4303,7 @@ discard block |
||
| 4304 | 4303 | @chmod($dir, 0777); |
| 4305 | 4304 | foreach (array_diff(scandir($dir), array('.', '..')) as $file) { |
| 4306 | 4305 | @set_time_limit(30); |
| 4307 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
| 4306 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
| 4308 | 4307 | if (!is_link($dir) && is_dir($path)) { |
| 4309 | 4308 | $this->rmdirRecursive($path); |
| 4310 | 4309 | } else { |
@@ -4391,22 +4390,22 @@ discard block |
||
| 4391 | 4390 | try { |
| 4392 | 4391 | if ($start = is_string($zipPath)) { |
| 4393 | 4392 | $zip = new ZipArchive(); |
| 4394 | - if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) { |
|
| 4393 | + if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) { |
|
| 4395 | 4394 | $zip = false; |
| 4396 | 4395 | } |
| 4397 | 4396 | } else { |
| 4398 | 4397 | $zip = $zipPath; |
| 4399 | 4398 | } |
| 4400 | 4399 | if ($zip) { |
| 4401 | - foreach($files as $file) { |
|
| 4402 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
| 4400 | + foreach ($files as $file) { |
|
| 4401 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
| 4403 | 4402 | if (is_dir($path)) { |
| 4404 | 4403 | $zip->addEmptyDir($file); |
| 4405 | 4404 | $_files = array(); |
| 4406 | 4405 | if ($handle = opendir($path)) { |
| 4407 | 4406 | while (false !== ($entry = readdir($handle))) { |
| 4408 | 4407 | if ($entry !== "." && $entry !== "..") { |
| 4409 | - $_files[] = $file . DIRECTORY_SEPARATOR . $entry; |
|
| 4408 | + $_files[] = $file.DIRECTORY_SEPARATOR.$entry; |
|
| 4410 | 4409 | } |
| 4411 | 4410 | } |
| 4412 | 4411 | closedir($handle); |
@@ -4591,7 +4590,7 @@ discard block |
||
| 4591 | 4590 | * @return resource|false |
| 4592 | 4591 | * @author Dmitry (dio) Levashov |
| 4593 | 4592 | **/ |
| 4594 | - abstract protected function _fopen($path, $mode="rb"); |
|
| 4593 | + abstract protected function _fopen($path, $mode = "rb"); |
|
| 4595 | 4594 | |
| 4596 | 4595 | /** |
| 4597 | 4596 | * Close opened file |
@@ -4601,7 +4600,7 @@ discard block |
||
| 4601 | 4600 | * @return bool |
| 4602 | 4601 | * @author Dmitry (dio) Levashov |
| 4603 | 4602 | **/ |
| 4604 | - abstract protected function _fclose($fp, $path=''); |
|
| 4603 | + abstract protected function _fclose($fp, $path = ''); |
|
| 4605 | 4604 | |
| 4606 | 4605 | /******************** file/dir manipulations *************************/ |
| 4607 | 4606 | |