@@ -24,10 +24,10 @@ |
||
| 24 | 24 | |
| 25 | 25 | // й ё Й Ё Ø Å |
| 26 | 26 | $patterns = array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"); |
| 27 | -$replace = array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5"); |
|
| 27 | +$replace = array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5"); |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | -foreach(scandir($path) as $f) { |
|
| 30 | +foreach (scandir($path) as $f) { |
|
| 31 | 31 | if ($f != '.' && $f != '..' && substr($f, 0, 1) != '.') { |
| 32 | 32 | |
| 33 | 33 | // echo mb_detect_encoding($f); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return void |
| 35 | 35 | * @author Dmitry (dio) Levashov |
| 36 | 36 | **/ |
| 37 | - public function __construct($elFinder, $debug=false) { |
|
| 37 | + public function __construct($elFinder, $debug = false) { |
|
| 38 | 38 | |
| 39 | 39 | $this->elFinder = $elFinder; |
| 40 | 40 | if ($debug) { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) { |
| 55 | 55 | // for support IE XDomainRequest() |
| 56 | 56 | $parts = explode('&', $rawPostData); |
| 57 | - foreach($parts as $part) { |
|
| 57 | + foreach ($parts as $part) { |
|
| 58 | 58 | list($key, $value) = array_pad(explode('=', $part), 2, ''); |
| 59 | 59 | $key = rawurldecode($key); |
| 60 | 60 | if (substr($key, -2) === '[]') { |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | **/ |
| 122 | 122 | protected function output(array $data) { |
| 123 | 123 | // clear output buffer |
| 124 | - while(@ob_get_level()){ @ob_end_clean(); } |
|
| 124 | + while (@ob_get_level()) { @ob_end_clean(); } |
|
| 125 | 125 | |
| 126 | 126 | $header = isset($data['header']) ? $data['header'] : $this->header; |
| 127 | 127 | unset($data['header']); |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | $psize = $end - $start + 1; |
| 163 | 163 | |
| 164 | 164 | header('HTTP/1.1 206 Partial Content'); |
| 165 | - header('Content-Length: ' . $psize); |
|
| 166 | - header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size); |
|
| 165 | + header('Content-Length: '.$psize); |
|
| 166 | + header('Content-Range: bytes '.$start.'-'.$end.'/'.$size); |
|
| 167 | 167 | |
| 168 | 168 | fseek($fp, $start); |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | - if (is_null($psize)){ |
|
| 172 | + if (is_null($psize)) { |
|
| 173 | 173 | rewind($fp); |
| 174 | 174 | } |
| 175 | 175 | } else { |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | ); |
| 104 | 104 | $this->options = array_merge($this->options, $opts); |
| 105 | 105 | $this->options['mimeDetect'] = 'internal'; |
| 106 | - $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
| 106 | + $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $scheme = parse_url($this->options['host'], PHP_URL_SCHEME); |
| 164 | 164 | |
| 165 | 165 | if ($scheme) { |
| 166 | - $this->options['host'] = substr($this->options['host'], strlen($scheme)+3); |
|
| 166 | + $this->options['host'] = substr($this->options['host'], strlen($scheme) + 3); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // normalize root path |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | if ($this->encoding) { |
| 236 | 236 | @ftp_exec($this->connect, 'OPTS UTF8 OFF'); |
| 237 | 237 | } else { |
| 238 | - @ftp_exec($this->connect, 'OPTS UTF8 ON' ); |
|
| 238 | + @ftp_exec($this->connect, 'OPTS UTF8 ON'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // switch off extended passive mode - may be usefull for some servers |
| 242 | - @ftp_exec($this->connect, 'epsv4 off' ); |
|
| 242 | + @ftp_exec($this->connect, 'epsv4 off'); |
|
| 243 | 243 | // enter passive mode if required |
| 244 | 244 | ftp_pasv($this->connect, $this->options['mode'] == 'passive'); |
| 245 | 245 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $name = $info[8]; |
| 308 | 308 | |
| 309 | 309 | if (preg_match('|(.+)\-\>(.+)|', $name, $m)) { |
| 310 | - $name = trim($m[1]); |
|
| 310 | + $name = trim($m[1]); |
|
| 311 | 311 | // check recursive processing |
| 312 | 312 | if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) { |
| 313 | 313 | return array(); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $stat['owner'] = $info[2]; |
| 344 | 344 | $stat['group'] = $info[3]; |
| 345 | 345 | $stat['perm'] = substr($info[0], 1); |
| 346 | - $stat['isowner'] = $stat['owner']? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
| 346 | + $stat['isowner'] = $stat['owner'] ? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | $perm = $this->parsePermissions($info[0], $stat['owner']); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $info[4] = 0; |
| 376 | 376 | $info[0] = 'drwxr-xr-x'; |
| 377 | 377 | } else { |
| 378 | - $info[4] = (int)$size; |
|
| 378 | + $info[4] = (int) $size; |
|
| 379 | 379 | $info[0] = '-rw-r--r--'; |
| 380 | 380 | } |
| 381 | 381 | return $info; |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | protected function parsePermissions($perm, $user = '') { |
| 392 | 392 | $res = array(); |
| 393 | 393 | $parts = array(); |
| 394 | - $owner = $user? ($user == $this->options['user']) : $this->options['owner']; |
|
| 394 | + $owner = $user ? ($user == $this->options['user']) : $this->options['owner']; |
|
| 395 | 395 | for ($i = 0, $l = strlen($perm); $i < $l; $i++) { |
| 396 | 396 | $parts[] = substr($perm, $i, 1); |
| 397 | 397 | } |
@@ -422,10 +422,10 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | $list = $this->convEncOut($list); |
| 425 | - $prefix = ($path === $this->separator)? $this->separator : $path . $this->separator; |
|
| 425 | + $prefix = ($path === $this->separator) ? $this->separator : $path.$this->separator; |
|
| 426 | 426 | $targets = array(); |
| 427 | - foreach($list as $stat) { |
|
| 428 | - $p = $prefix . $stat['name']; |
|
| 427 | + foreach ($list as $stat) { |
|
| 428 | + $p = $prefix.$stat['name']; |
|
| 429 | 429 | if (isset($stat['target'])) { |
| 430 | 430 | // stat later |
| 431 | 431 | $targets[$stat['name']] = $stat['target']; |
@@ -437,10 +437,10 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | // stat link targets |
| 440 | - foreach($targets as $name => $target) { |
|
| 440 | + foreach ($targets as $name => $target) { |
|
| 441 | 441 | $stat = array(); |
| 442 | 442 | $stat['name'] = $name; |
| 443 | - $p = $prefix . $name; |
|
| 443 | + $p = $prefix.$name; |
|
| 444 | 444 | $cacheDirTarget = $this->cacheDirTarget; |
| 445 | 445 | $this->cacheDirTarget = $this->convEncIn($target, true); |
| 446 | 446 | if ($tstat = $this->stat($target)) { |
@@ -449,12 +449,12 @@ discard block |
||
| 449 | 449 | $stat['thash'] = $tstat['hash']; |
| 450 | 450 | $stat['mime'] = $tstat['mime']; |
| 451 | 451 | $stat['read'] = $tstat['read']; |
| 452 | - $stat['write'] = $tstat['write']; |
|
| 452 | + $stat['write'] = $tstat['write']; |
|
| 453 | 453 | |
| 454 | - if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
| 455 | - if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
| 456 | - if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
| 457 | - if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
| 454 | + if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
| 455 | + if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
| 456 | + if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
| 457 | + if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
| 458 | 458 | if (isset($tstat['isowner'])) { $stat['isowner'] = $tstat['isowner']; } |
| 459 | 459 | } else { |
| 460 | 460 | |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | $comps = $new_comps; |
| 568 | 568 | $path = implode($this->separator, $comps); |
| 569 | 569 | if ($initial_slashes) { |
| 570 | - $path = str_repeat($this->separator, $initial_slashes) . $path; |
|
| 570 | + $path = str_repeat($this->separator, $initial_slashes).$path; |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | return $path ? $path : '.'; |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | * @author Dmitry (dio) Levashov |
| 634 | 634 | **/ |
| 635 | 635 | protected function _inpath($path, $parent) { |
| 636 | - return $path == $parent || strpos($path, $parent. $this->separator) === 0; |
|
| 636 | + return $path == $parent || strpos($path, $parent.$this->separator) === 0; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /***************** file stat ********************/ |
@@ -672,9 +672,9 @@ discard block |
||
| 672 | 672 | ); |
| 673 | 673 | } |
| 674 | 674 | $this->cacheDir($this->convEncOut($this->_dirname($path))); |
| 675 | - return $this->convEncIn(isset($this->cache[$outPath])? $this->cache[$outPath] : array()); |
|
| 675 | + return $this->convEncIn(isset($this->cache[$outPath]) ? $this->cache[$outPath] : array()); |
|
| 676 | 676 | } |
| 677 | - $raw = ftp_raw($this->connect, 'MLST ' . $path); |
|
| 677 | + $raw = ftp_raw($this->connect, 'MLST '.$path); |
|
| 678 | 678 | if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) { |
| 679 | 679 | $parts = explode(';', trim($raw[1])); |
| 680 | 680 | array_pop($parts); |
@@ -704,8 +704,8 @@ discard block |
||
| 704 | 704 | |
| 705 | 705 | case 'perm': |
| 706 | 706 | $val = strtolower($val); |
| 707 | - $stat['read'] = (int)preg_match('/e|l|r/', $val); |
|
| 708 | - $stat['write'] = (int)preg_match('/w|m|c/', $val); |
|
| 707 | + $stat['read'] = (int) preg_match('/e|l|r/', $val); |
|
| 708 | + $stat['write'] = (int) preg_match('/w|m|c/', $val); |
|
| 709 | 709 | if (!preg_match('/f|d/', $val)) { |
| 710 | 710 | $stat['locked'] = 1; |
| 711 | 711 | } |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | if (!$this->ftpOsUnix) { |
| 791 | 791 | $info = $this->normalizeRawWindows($str); |
| 792 | 792 | } |
| 793 | - $name = isset($info[8])? trim($info[8]) : ''; |
|
| 793 | + $name = isset($info[8]) ? trim($info[8]) : ''; |
|
| 794 | 794 | if ($name && $name !== '.' && $name !== '..' && substr(strtolower($info[0]), 0, 1) === 'd') { |
| 795 | 795 | return true; |
| 796 | 796 | } |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | * @return resource|false |
| 846 | 846 | * @author Dmitry (dio) Levashov |
| 847 | 847 | **/ |
| 848 | - protected function _fopen($path, $mode='rb') { |
|
| 848 | + protected function _fopen($path, $mode = 'rb') { |
|
| 849 | 849 | |
| 850 | 850 | if ($this->tmp) { |
| 851 | 851 | $local = $this->getTempFile($path); |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | * @return bool |
| 870 | 870 | * @author Dmitry (dio) Levashov |
| 871 | 871 | **/ |
| 872 | - protected function _fclose($fp, $path='') { |
|
| 872 | + protected function _fclose($fp, $path = '') { |
|
| 873 | 873 | @fclose($fp); |
| 874 | 874 | if ($path) { |
| 875 | 875 | @unlink($this->getTempFile($path)); |
@@ -1044,7 +1044,7 @@ discard block |
||
| 1044 | 1044 | if (@file_put_contents($local, $content, LOCK_EX) !== false |
| 1045 | 1045 | && ($fp = @fopen($local, 'rb'))) { |
| 1046 | 1046 | clearstatcache(); |
| 1047 | - $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
| 1047 | + $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
| 1048 | 1048 | @fclose($fp); |
| 1049 | 1049 | } |
| 1050 | 1050 | file_exists($local) && @unlink($local); |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | * @return bool |
| 1070 | 1070 | **/ |
| 1071 | 1071 | protected function _chmod($path, $mode) { |
| 1072 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
| 1072 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
| 1073 | 1073 | return @ftp_chmod($this->connect, $modeOct, $path); |
| 1074 | 1074 | } |
| 1075 | 1075 | |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | $basename = $this->_basename($path); |
| 1125 | - $localPath = $dir . DIRECTORY_SEPARATOR . $basename; |
|
| 1125 | + $localPath = $dir.DIRECTORY_SEPARATOR.$basename; |
|
| 1126 | 1126 | |
| 1127 | 1127 | if (!ftp_get($this->connect, $localPath, $path, FTP_BINARY)) { |
| 1128 | 1128 | //cleanup |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | |
| 1160 | 1160 | // archive contains one item - extract in archive dir |
| 1161 | 1161 | $name = ''; |
| 1162 | - $src = $dir . DIRECTORY_SEPARATOR . $filesToProcess[0]; |
|
| 1162 | + $src = $dir.DIRECTORY_SEPARATOR.$filesToProcess[0]; |
|
| 1163 | 1163 | if (($extractTo === 'auto' || !$extractTo) && count($filesToProcess) === 1 && is_file($src)) { |
| 1164 | 1164 | $name = $filesToProcess[0]; |
| 1165 | 1165 | } else if ($extractTo === 'auto' || $extractTo) { |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | $src = $dir; |
| 1169 | 1169 | $name = basename($path); |
| 1170 | 1170 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 1171 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 1171 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | $test = $this->_joinPath(dirname($path), $name); |
| 1174 | 1174 | if ($this->stat($test)) { |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | if ($name !== '' && is_file($src)) { |
| 1180 | 1180 | $result = $this->_joinPath(dirname($path), $name); |
| 1181 | 1181 | |
| 1182 | - if (! ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
| 1182 | + if (!ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
| 1183 | 1183 | $this->rmdirRecursive($dir); |
| 1184 | 1184 | return false; |
| 1185 | 1185 | } |
@@ -1193,19 +1193,19 @@ discard block |
||
| 1193 | 1193 | } |
| 1194 | 1194 | $result[] = $dstDir; |
| 1195 | 1195 | } |
| 1196 | - foreach($filesToProcess as $name) { |
|
| 1196 | + foreach ($filesToProcess as $name) { |
|
| 1197 | 1197 | $name = rtrim($name, DIRECTORY_SEPARATOR); |
| 1198 | - $src = $dir . DIRECTORY_SEPARATOR . $name; |
|
| 1198 | + $src = $dir.DIRECTORY_SEPARATOR.$name; |
|
| 1199 | 1199 | if (is_dir($src)) { |
| 1200 | 1200 | $p = dirname($name); |
| 1201 | 1201 | $name = basename($name); |
| 1202 | - if (! $target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
| 1202 | + if (!$target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
| 1203 | 1203 | $this->rmdirRecursive($dir); |
| 1204 | 1204 | return false; |
| 1205 | 1205 | } |
| 1206 | 1206 | } else { |
| 1207 | 1207 | $target = $this->_joinPath($dstDir, $name); |
| 1208 | - if (! ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
| 1208 | + if (!ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
| 1209 | 1209 | $this->rmdirRecursive($dir); |
| 1210 | 1210 | return false; |
| 1211 | 1211 | } |
@@ -1221,7 +1221,7 @@ discard block |
||
| 1221 | 1221 | is_dir($dir) && $this->rmdirRecursive($dir); |
| 1222 | 1222 | |
| 1223 | 1223 | $this->clearcache(); |
| 1224 | - return $result? $result : false; |
|
| 1224 | + return $result ? $result : false; |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | /** |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | //cleanup |
| 1264 | - if(!$this->rmdirRecursive($tmpDir)) { |
|
| 1264 | + if (!$this->rmdirRecursive($tmpDir)) { |
|
| 1265 | 1265 | return false; |
| 1266 | 1266 | } |
| 1267 | 1267 | |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | $remoteDirLen = strlen($remote_directory); |
| 1366 | 1366 | foreach ($contents as $item) { |
| 1367 | 1367 | $relative_path = substr($item['path'], $remoteDirLen); |
| 1368 | - $local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path; |
|
| 1368 | + $local_path = $dest_local_directory.DIRECTORY_SEPARATOR.$relative_path; |
|
| 1369 | 1369 | switch ($item['type']) { |
| 1370 | 1370 | case 'd': |
| 1371 | 1371 | $success = mkdir($local_path); |
@@ -1396,8 +1396,8 @@ discard block |
||
| 1396 | 1396 | } else { |
| 1397 | 1397 | $success = true; |
| 1398 | 1398 | foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) { |
| 1399 | - $path = $dirPath . DIRECTORY_SEPARATOR . $path; |
|
| 1400 | - if(is_link($path)) { |
|
| 1399 | + $path = $dirPath.DIRECTORY_SEPARATOR.$path; |
|
| 1400 | + if (is_link($path)) { |
|
| 1401 | 1401 | unlink($path); |
| 1402 | 1402 | } else if (is_dir($path)) { |
| 1403 | 1403 | $success = rmdir($path); |
@@ -1408,11 +1408,11 @@ discard block |
||
| 1408 | 1408 | break; |
| 1409 | 1409 | } |
| 1410 | 1410 | } |
| 1411 | - if($success) { |
|
| 1411 | + if ($success) { |
|
| 1412 | 1412 | $success = rmdir($dirPath); |
| 1413 | 1413 | } |
| 1414 | 1414 | } |
| 1415 | - if(!$success) { |
|
| 1415 | + if (!$success) { |
|
| 1416 | 1416 | $this->setError(elFinder::ERROR_RM, $dirPath); |
| 1417 | 1417 | return false; |
| 1418 | 1418 | } |
@@ -1434,25 +1434,25 @@ discard block |
||
| 1434 | 1434 | if (!is_dir($dir)) { |
| 1435 | 1435 | return false; |
| 1436 | 1436 | } |
| 1437 | - $excludes = array(".",".."); |
|
| 1437 | + $excludes = array(".", ".."); |
|
| 1438 | 1438 | $result = array(); |
| 1439 | 1439 | $files = scandir($dir); |
| 1440 | - if(!$files) { |
|
| 1440 | + if (!$files) { |
|
| 1441 | 1441 | return array(); |
| 1442 | 1442 | } |
| 1443 | - foreach($files as $file) { |
|
| 1444 | - if(!in_array($file, $excludes)) { |
|
| 1443 | + foreach ($files as $file) { |
|
| 1444 | + if (!in_array($file, $excludes)) { |
|
| 1445 | 1445 | $path = $dir.DIRECTORY_SEPARATOR.$file; |
| 1446 | - if(is_link($path)) { |
|
| 1447 | - if($omitSymlinks) { |
|
| 1446 | + if (is_link($path)) { |
|
| 1447 | + if ($omitSymlinks) { |
|
| 1448 | 1448 | continue; |
| 1449 | 1449 | } else { |
| 1450 | 1450 | $result[] = $prefix.$file; |
| 1451 | 1451 | } |
| 1452 | - } else if(is_dir($path)) { |
|
| 1452 | + } else if (is_dir($path)) { |
|
| 1453 | 1453 | $result[] = $prefix.$file.DIRECTORY_SEPARATOR; |
| 1454 | 1454 | $subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix.$file.DIRECTORY_SEPARATOR); |
| 1455 | - if($subs) { |
|
| 1455 | + if ($subs) { |
|
| 1456 | 1456 | $result = array_merge($result, $subs); |
| 1457 | 1457 | } |
| 1458 | 1458 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | $dirs = array(); |
| 312 | 312 | if ($path != $this->root) { |
| 313 | 313 | $inpath = array(intval($path)); |
| 314 | - while($inpath) { |
|
| 314 | + while ($inpath) { |
|
| 315 | 315 | $in = '('.join(',', $inpath).')'; |
| 316 | 316 | $inpath = array(); |
| 317 | 317 | $sql = 'SELECT f.id FROM %s AS f WHERE f.parent_id IN '.$in.' AND `mime` = \'directory\''; |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | if ($mimes) { |
| 332 | 332 | $whrs = array(); |
| 333 | - foreach($mimes as $mime) { |
|
| 333 | + foreach ($mimes as $mime) { |
|
| 334 | 334 | if (strpos($mime, '/') === false) { |
| 335 | 335 | $whrs[] = sprintf('f.mime LIKE "%s/%%"', $this->db->real_escape_string($mime)); |
| 336 | 336 | } else { |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | $whr = sprintf('f.name RLIKE "%s"', $this->db->real_escape_string($q)); |
| 343 | 343 | } |
| 344 | 344 | if ($dirs) { |
| 345 | - $whr = '(' . $whr . ') AND (`parent_id` IN (' . join(',', $dirs) . '))'; |
|
| 345 | + $whr = '('.$whr.') AND (`parent_id` IN ('.join(',', $dirs).'))'; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | $sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | * @return resource|false |
| 588 | 588 | * @author Dmitry (dio) Levashov |
| 589 | 589 | **/ |
| 590 | - protected function _fopen($path, $mode='rb') { |
|
| 590 | + protected function _fopen($path, $mode = 'rb') { |
|
| 591 | 591 | $fp = $this->tmbPath |
| 592 | 592 | ? @fopen($this->getTempFile($path), 'w+') |
| 593 | 593 | : @tmpfile(); |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | * @return bool |
| 615 | 615 | * @author Dmitry (dio) Levashov |
| 616 | 616 | **/ |
| 617 | - protected function _fclose($fp, $path='') { |
|
| 617 | + protected function _fclose($fp, $path = '') { |
|
| 618 | 618 | @fclose($fp); |
| 619 | 619 | if ($path) { |
| 620 | 620 | @unlink($this->getTempFile($path)); |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | $this->clearcache(); |
| 747 | 747 | |
| 748 | 748 | $mime = $stat['mime']; |
| 749 | - $w = !empty($stat['width']) ? $stat['width'] : 0; |
|
| 749 | + $w = !empty($stat['width']) ? $stat['width'] : 0; |
|
| 750 | 750 | $h = !empty($stat['height']) ? $stat['height'] : 0; |
| 751 | 751 | |
| 752 | 752 | $id = $this->_joinPath($dir, $name); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | **/ |
| 62 | 62 | protected function _dirname($path) {
|
| 63 | 63 | |
| 64 | - $newpath = preg_replace("/\/$/", "", $path);
|
|
| 65 | - $dn = substr($path, 0, strrpos($newpath, '/')) ; |
|
| 64 | + $newpath = preg_replace("/\/$/", "", $path);
|
|
| 65 | + $dn = substr($path, 0, strrpos($newpath, '/')); |
|
| 66 | 66 | |
| 67 | 67 | if (substr($dn, 0, 1) != '/') {
|
| 68 | 68 | $dn = "/$dn"; |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | * @author Troex Nevelin |
| 106 | 106 | **/ |
| 107 | 107 | protected function _normpath($path) {
|
| 108 | - $tmp = preg_replace("/^\//", "", $path);
|
|
| 109 | - $tmp = preg_replace("/\/\//", "/", $tmp);
|
|
| 110 | - $tmp = preg_replace("/\/$/", "", $tmp);
|
|
| 108 | + $tmp = preg_replace("/^\//", "", $path);
|
|
| 109 | + $tmp = preg_replace("/\/\//", "/", $tmp);
|
|
| 110 | + $tmp = preg_replace("/\/$/", "", $tmp);
|
|
| 111 | 111 | return $tmp; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | $newpath = "/$newpath"; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $newpath = preg_replace("/\/$/", "", $newpath);
|
|
| 131 | + $newpath = preg_replace("/\/$/", "", $newpath);
|
|
| 132 | 132 | |
| 133 | - $ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root)+1); |
|
| 133 | + $ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root) + 1); |
|
| 134 | 134 | |
| 135 | 135 | return $ret; |
| 136 | 136 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $np = $this->_normpath($path); |
| 232 | 232 | |
| 233 | 233 | try {
|
| 234 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
|
|
| 234 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
|
|
| 235 | 235 | } catch (Exception $e) {
|
| 236 | 236 | |
| 237 | 237 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | if (!isset($obj) || ($obj->GetObjectResponse->Status->Code != 200)) {
|
| 240 | 240 | $np .= '/'; |
| 241 | 241 | try {
|
| 242 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
|
|
| 242 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false));
|
|
| 243 | 243 | } catch (Exception $e) {
|
| 244 | 244 | |
| 245 | 245 | } |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | **/ |
| 342 | 342 | protected function _scandir($path) {
|
| 343 | 343 | |
| 344 | - $s3path = preg_replace("/^\//", "", $path) . '/';
|
|
| 344 | + $s3path = preg_replace("/^\//", "", $path).'/';
|
|
| 345 | 345 | |
| 346 | 346 | $files = $this->s3->ListBucket(array('Bucket' => $this->options['bucket'], 'delimiter' => '/', 'Prefix' => $s3path))->ListBucketResponse->Contents;
|
| 347 | 347 | |
| 348 | 348 | $finalfiles = array(); |
| 349 | 349 | |
| 350 | 350 | foreach ($files as $file) {
|
| 351 | - if (preg_match("|^" . $s3path . "[^/]*/?$|", $file->Key)) {
|
|
| 351 | + if (preg_match("|^".$s3path."[^/]*/?$|", $file->Key)) {
|
|
| 352 | 352 | $fname = preg_replace("/\/$/", "", $file->Key);
|
| 353 | 353 | $fname = $file->Key; |
| 354 | 354 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | * @author Dmitry (dio) Levashov, |
| 374 | 374 | * @author Alexey Sukhotin |
| 375 | 375 | **/ |
| 376 | - protected function _fopen($path, $mode="rb") {
|
|
| 376 | + protected function _fopen($path, $mode = "rb") {
|
|
| 377 | 377 | |
| 378 | 378 | $tn = $this->getTempFile($path); |
| 379 | 379 | |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | if ($fp) {
|
| 386 | 386 | |
| 387 | 387 | try {
|
| 388 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path) , 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true));
|
|
| 389 | - } catch (Exception $e) {
|
|
| 388 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path), 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true));
|
|
| 389 | + } catch (Exception $e) {
|
|
| 390 | 390 | |
| 391 | 391 | } |
| 392 | 392 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | * @return bool |
| 411 | 411 | * @author Dmitry (dio) Levashov |
| 412 | 412 | **/ |
| 413 | - protected function _fclose($fp, $path='') {
|
|
| 413 | + protected function _fclose($fp, $path = '') {
|
|
| 414 | 414 | @fclose($fp); |
| 415 | 415 | if ($path) {
|
| 416 | 416 | @unlink($this->getTempFile($path)); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $newkey = "$newkey/$name/"; |
| 436 | 436 | |
| 437 | 437 | try {
|
| 438 | - $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => ''));
|
|
| 438 | + $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => ''));
|
|
| 439 | 439 | } catch (Exception $e) {
|
| 440 | 440 | |
| 441 | 441 | } |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | $newkey = "$newkey/$name"; |
| 463 | 463 | |
| 464 | 464 | try {
|
| 465 | - $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain'))));
|
|
| 465 | + $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain'))));
|
|
| 466 | 466 | } catch (Exception $e) {
|
| 467 | 467 | |
| 468 | 468 | } |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | * @author Dmitry (dio) Levashov |
| 564 | 564 | **/ |
| 565 | 565 | protected function _rmdir($path) {
|
| 566 | - return $this->_unlink($path . '/'); |
|
| 566 | + return $this->_unlink($path.'/'); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | /** |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | /* Getting list of S3 web service functions which requires signing */ |
| 683 | 683 | $funcs = $this->__getFunctions(); |
| 684 | 684 | |
| 685 | - $funcnames = array(); |
|
| 685 | + $funcnames = array(); |
|
| 686 | 686 | |
| 687 | 687 | foreach ($funcs as $func) {
|
| 688 | 688 | preg_match("/\S+\s+([^\)]+)\(/", $func, $m);
|
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | 'Timestamp' => gmdate('Y-m-d\TH:i:s.000\Z'),
|
| 724 | 724 | ); |
| 725 | 725 | |
| 726 | - $sign_str = 'AmazonS3' . $operation . $params['Timestamp']; |
|
| 726 | + $sign_str = 'AmazonS3'.$operation.$params['Timestamp']; |
|
| 727 | 727 | |
| 728 | 728 | $params['Signature'] = base64_encode(hash_hmac('sha1', $sign_str, $this->secretkey, TRUE));
|
| 729 | 729 | |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function __construct($opts) { |
| 52 | 52 | $defaults = array( |
| 53 | - 'enable' => true, // For control by volume driver |
|
| 54 | - 'maxWidth' => 1024, // Path to Water mark image |
|
| 55 | - 'maxHeight' => 1024, // Margin right pixel |
|
| 56 | - 'quality' => 95, // JPEG image save quality |
|
| 57 | - 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
| 53 | + 'enable' => true, // For control by volume driver |
|
| 54 | + 'maxWidth' => 1024, // Path to Water mark image |
|
| 55 | + 'maxHeight' => 1024, // Margin right pixel |
|
| 56 | + 'quality' => 95, // JPEG image save quality |
|
| 57 | + 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field ) |
|
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | 60 | $this->opts = array_merge($defaults, $opts); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $opts = array_merge($this->opts, $volOpts); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if (! $opts['enable']) { |
|
| 71 | + if (!$opts['enable']) { |
|
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | IMAGETYPE_PNG => IMG_PNG, |
| 85 | 85 | IMAGETYPE_WBMP => IMG_WBMP, |
| 86 | 86 | ); |
| 87 | - if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
| 87 | + if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
| 88 | 88 | return false; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality) { |
| 99 | - $zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1])); |
|
| 100 | - $width = round($srcImgInfo[0] * $zoom); |
|
| 101 | - $height = round($srcImgInfo[1] * $zoom); |
|
| 99 | + $zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1])); |
|
| 100 | + $width = round($srcImgInfo[0]*$zoom); |
|
| 101 | + $height = round($srcImgInfo[1]*$zoom); |
|
| 102 | 102 | |
| 103 | 103 | if (class_exists('Imagick')) { |
| 104 | 104 | return $this->resize_imagick($src, $width, $height, $quality); |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | break; |
| 119 | 119 | case 'image/jpeg': |
| 120 | 120 | if (@imagetypes() & IMG_JPG) { |
| 121 | - $oSrcImg = @imagecreatefromjpeg($src) ; |
|
| 121 | + $oSrcImg = @imagecreatefromjpeg($src); |
|
| 122 | 122 | } else { |
| 123 | 123 | $ermsg = 'JPEG images are not supported'; |
| 124 | 124 | } |
| 125 | 125 | break; |
| 126 | 126 | case 'image/png': |
| 127 | 127 | if (@imagetypes() & IMG_PNG) { |
| 128 | - $oSrcImg = @imagecreatefrompng($src) ; |
|
| 128 | + $oSrcImg = @imagecreatefrompng($src); |
|
| 129 | 129 | } else { |
| 130 | 130 | $ermsg = 'PNG images are not supported'; |
| 131 | 131 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | break; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 146 | + if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
| 147 | 147 | |
| 148 | 148 | if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) { |
| 149 | 149 | return false; |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function __construct($opts) { |
| 59 | 59 | $defaults = array( |
| 60 | - 'enable' => true, // For control by volume driver |
|
| 60 | + 'enable' => true, // For control by volume driver |
|
| 61 | 61 | 'source' => 'logo.png', // Path to Water mark image |
| 62 | - 'marginRight' => 5, // Margin right pixel |
|
| 63 | - 'marginBottom' => 5, // Margin bottom pixel |
|
| 64 | - 'quality' => 95, // JPEG image save quality |
|
| 65 | - 'transparency' => 70, // Water mark image transparency ( other than PNG ) |
|
| 66 | - 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) |
|
| 62 | + 'marginRight' => 5, // Margin right pixel |
|
| 63 | + 'marginBottom' => 5, // Margin bottom pixel |
|
| 64 | + 'quality' => 95, // JPEG image save quality |
|
| 65 | + 'transparency' => 70, // Water mark image transparency ( other than PNG ) |
|
| 66 | + 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field ) |
|
| 67 | 67 | 'targetMinPixel' => 200 // Target image minimum pixel size |
| 68 | 68 | ); |
| 69 | 69 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $opts = array_merge($this->opts, $volOpts); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (! $opts['enable']) { |
|
| 82 | + if (!$opts['enable']) { |
|
| 83 | 83 | return false; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // check water mark image |
| 97 | - if (! file_exists($opts['source'])) { |
|
| 98 | - $opts['source'] = dirname(__FILE__) . "/" . $opts['source']; |
|
| 97 | + if (!file_exists($opts['source'])) { |
|
| 98 | + $opts['source'] = dirname(__FILE__)."/".$opts['source']; |
|
| 99 | 99 | } |
| 100 | 100 | if (is_readable($opts['source'])) { |
| 101 | 101 | $watermarkImgInfo = @getimagesize($opts['source']); |
| 102 | - if (! $watermarkImgInfo) { |
|
| 102 | + if (!$watermarkImgInfo) { |
|
| 103 | 103 | return false; |
| 104 | 104 | } |
| 105 | 105 | } else { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | IMAGETYPE_PNG => IMG_PNG, |
| 120 | 120 | IMAGETYPE_WBMP => IMG_WBMP, |
| 121 | 121 | ); |
| 122 | - if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
| 122 | + if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
| 123 | 123 | return false; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -192,14 +192,14 @@ discard block |
||
| 192 | 192 | break; |
| 193 | 193 | case 'image/jpeg': |
| 194 | 194 | if (@imagetypes() & IMG_JPG) { |
| 195 | - $oWatermarkImg = @imagecreatefromjpeg($watermark) ; |
|
| 195 | + $oWatermarkImg = @imagecreatefromjpeg($watermark); |
|
| 196 | 196 | } else { |
| 197 | 197 | $ermsg = 'JPEG images are not supported'; |
| 198 | 198 | } |
| 199 | 199 | break; |
| 200 | 200 | case 'image/png': |
| 201 | 201 | if (@imagetypes() & IMG_PNG) { |
| 202 | - $oWatermarkImg = @imagecreatefrompng($watermark) ; |
|
| 202 | + $oWatermarkImg = @imagecreatefrompng($watermark); |
|
| 203 | 203 | } else { |
| 204 | 204 | $ermsg = 'PNG images are not supported'; |
| 205 | 205 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | break; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if (! $ermsg) { |
|
| 220 | + if (!$ermsg) { |
|
| 221 | 221 | switch ($srcImgInfo['mime']) { |
| 222 | 222 | case 'image/gif': |
| 223 | 223 | if (@imagetypes() & IMG_GIF) { |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | break; |
| 229 | 229 | case 'image/jpeg': |
| 230 | 230 | if (@imagetypes() & IMG_JPG) { |
| 231 | - $oSrcImg = @imagecreatefromjpeg($src) ; |
|
| 231 | + $oSrcImg = @imagecreatefromjpeg($src); |
|
| 232 | 232 | } else { |
| 233 | 233 | $ermsg = 'JPEG images are not supported'; |
| 234 | 234 | } |
| 235 | 235 | break; |
| 236 | 236 | case 'image/png': |
| 237 | 237 | if (@imagetypes() & IMG_PNG) { |
| 238 | - $oSrcImg = @imagecreatefrompng($src) ; |
|
| 238 | + $oSrcImg = @imagecreatefrompng($src); |
|
| 239 | 239 | } else { |
| 240 | 240 | $ermsg = 'PNG images are not supported'; |
| 241 | 241 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | if ($srcImgInfo['mime'] === 'image/png') { |
| 262 | 262 | if (function_exists('imagecolorallocatealpha')) { |
| 263 | 263 | $bg = imagecolorallocatealpha($oSrcImg, 255, 255, 255, 127); |
| 264 | - imagefill($oSrcImg, 0, 0 , $bg); |
|
| 264 | + imagefill($oSrcImg, 0, 0, $bg); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | public function __construct($opts) { |
| 51 | 51 | $defaults = array( |
| 52 | - 'enable' => true, // For control by volume driver |
|
| 53 | - 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars |
|
| 52 | + 'enable' => true, // For control by volume driver |
|
| 53 | + 'targets' => array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), // target chars |
|
| 54 | 54 | 'replace' => '_' // replace to this |
| 55 | 55 | ); |
| 56 | 56 | |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function cmdPreprocess($cmd, &$args, $elfinder, $volume) { |
| 61 | 61 | $opts = $this->getOpts($volume); |
| 62 | - if (! $opts['enable']) { |
|
| 62 | + if (!$opts['enable']) { |
|
| 63 | 63 | return false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (isset($args['name'])) { |
| 67 | 67 | if (is_array($args['name'])) { |
| 68 | - foreach($args['name'] as $i => $name) { |
|
| 68 | + foreach ($args['name'] as $i => $name) { |
|
| 69 | 69 | $args['name'][$i] = $this->sanitizeFileName($name, $opts); |
| 70 | 70 | } |
| 71 | 71 | } else { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) { |
| 79 | 79 | $opts = $this->getOpts($volume); |
| 80 | - if (! $opts['enable']) { |
|
| 80 | + if (!$opts['enable']) { |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | private function sanitizeFileName($filename, $opts, $allows = array()) { |
| 103 | - $targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets']; |
|
| 103 | + $targets = $allows ? array_diff($opts['targets'], $allows) : $opts['targets']; |
|
| 104 | 104 | return str_replace($targets, $opts['replace'], $filename); |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -203,14 +203,14 @@ discard block |
||
| 203 | 203 | const ERROR_INV_PARAMS = 'errCmdParams'; |
| 204 | 204 | const ERROR_OPEN = 'errOpen'; |
| 205 | 205 | const ERROR_DIR_NOT_FOUND = 'errFolderNotFound'; |
| 206 | - const ERROR_FILE_NOT_FOUND = 'errFileNotFound'; // 'File not found.' |
|
| 206 | + const ERROR_FILE_NOT_FOUND = 'errFileNotFound'; // 'File not found.' |
|
| 207 | 207 | const ERROR_TRGDIR_NOT_FOUND = 'errTrgFolderNotFound'; // 'Target folder "$1" not found.' |
| 208 | 208 | const ERROR_NOT_DIR = 'errNotFolder'; |
| 209 | 209 | const ERROR_NOT_FILE = 'errNotFile'; |
| 210 | 210 | const ERROR_PERM_DENIED = 'errPerm'; |
| 211 | - const ERROR_LOCKED = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.' |
|
| 212 | - const ERROR_EXISTS = 'errExists'; // 'File named "$1" already exists.' |
|
| 213 | - const ERROR_INVALID_NAME = 'errInvName'; // 'Invalid file name.' |
|
| 211 | + const ERROR_LOCKED = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.' |
|
| 212 | + const ERROR_EXISTS = 'errExists'; // 'File named "$1" already exists.' |
|
| 213 | + const ERROR_INVALID_NAME = 'errInvName'; // 'Invalid file name.' |
|
| 214 | 214 | const ERROR_MKDIR = 'errMkdir'; |
| 215 | 215 | const ERROR_MKFILE = 'errMkfile'; |
| 216 | 216 | const ERROR_RENAME = 'errRename'; |
@@ -219,20 +219,20 @@ discard block |
||
| 219 | 219 | const ERROR_COPY_FROM = 'errCopyFrom'; |
| 220 | 220 | const ERROR_COPY_TO = 'errCopyTo'; |
| 221 | 221 | const ERROR_COPY_ITSELF = 'errCopyInItself'; |
| 222 | - const ERROR_REPLACE = 'errReplace'; // 'Unable to replace "$1".' |
|
| 223 | - const ERROR_RM = 'errRm'; // 'Unable to remove "$1".' |
|
| 224 | - const ERROR_RM_SRC = 'errRmSrc'; // 'Unable remove source file(s)' |
|
| 225 | - const ERROR_MKOUTLINK = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.' |
|
| 226 | - const ERROR_UPLOAD = 'errUpload'; // 'Upload error.' |
|
| 227 | - const ERROR_UPLOAD_FILE = 'errUploadFile'; // 'Unable to upload "$1".' |
|
| 228 | - const ERROR_UPLOAD_NO_FILES = 'errUploadNoFiles'; // 'No files found for upload.' |
|
| 229 | - const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.' |
|
| 230 | - const ERROR_UPLOAD_FILE_SIZE = 'errUploadFileSize'; // 'File exceeds maximum allowed size.' |
|
| 231 | - const ERROR_UPLOAD_FILE_MIME = 'errUploadMime'; // 'File type not allowed.' |
|
| 232 | - const ERROR_UPLOAD_TRANSFER = 'errUploadTransfer'; // '"$1" transfer error.' |
|
| 233 | - const ERROR_UPLOAD_TEMP = 'errUploadTemp'; // 'Unable to make temporary file for upload.' |
|
| 222 | + const ERROR_REPLACE = 'errReplace'; // 'Unable to replace "$1".' |
|
| 223 | + const ERROR_RM = 'errRm'; // 'Unable to remove "$1".' |
|
| 224 | + const ERROR_RM_SRC = 'errRmSrc'; // 'Unable remove source file(s)' |
|
| 225 | + const ERROR_MKOUTLINK = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.' |
|
| 226 | + const ERROR_UPLOAD = 'errUpload'; // 'Upload error.' |
|
| 227 | + const ERROR_UPLOAD_FILE = 'errUploadFile'; // 'Unable to upload "$1".' |
|
| 228 | + const ERROR_UPLOAD_NO_FILES = 'errUploadNoFiles'; // 'No files found for upload.' |
|
| 229 | + const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.' |
|
| 230 | + const ERROR_UPLOAD_FILE_SIZE = 'errUploadFileSize'; // 'File exceeds maximum allowed size.' |
|
| 231 | + const ERROR_UPLOAD_FILE_MIME = 'errUploadMime'; // 'File type not allowed.' |
|
| 232 | + const ERROR_UPLOAD_TRANSFER = 'errUploadTransfer'; // '"$1" transfer error.' |
|
| 233 | + const ERROR_UPLOAD_TEMP = 'errUploadTemp'; // 'Unable to make temporary file for upload.' |
|
| 234 | 234 | // const ERROR_ACCESS_DENIED = 'errAccess'; |
| 235 | - const ERROR_NOT_REPLACE = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type. |
|
| 235 | + const ERROR_NOT_REPLACE = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type. |
|
| 236 | 236 | const ERROR_SAVE = 'errSave'; |
| 237 | 237 | const ERROR_EXTRACT = 'errExtract'; |
| 238 | 238 | const ERROR_ARCHIVE = 'errArchive'; |
@@ -247,14 +247,14 @@ discard block |
||
| 247 | 247 | const ERROR_NETMOUNT = 'errNetMount'; |
| 248 | 248 | const ERROR_NETUNMOUNT = 'errNetUnMount'; |
| 249 | 249 | const ERROR_NETMOUNT_NO_DRIVER = 'errNetMountNoDriver'; |
| 250 | - const ERROR_NETMOUNT_FAILED = 'errNetMountFailed'; |
|
| 250 | + const ERROR_NETMOUNT_FAILED = 'errNetMountFailed'; |
|
| 251 | 251 | |
| 252 | - const ERROR_SESSION_EXPIRES = 'errSessionExpires'; |
|
| 252 | + const ERROR_SESSION_EXPIRES = 'errSessionExpires'; |
|
| 253 | 253 | |
| 254 | 254 | const ERROR_CREATING_TEMP_DIR = 'errCreatingTempDir'; |
| 255 | 255 | const ERROR_FTP_DOWNLOAD_FILE = 'errFtpDownloadFile'; |
| 256 | - const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile'; |
|
| 257 | - const ERROR_FTP_MKDIR = 'errFtpMkdir'; |
|
| 256 | + const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile'; |
|
| 257 | + const ERROR_FTP_MKDIR = 'errFtpMkdir'; |
|
| 258 | 258 | const ERROR_ARCHIVE_EXEC = 'errArchiveExec'; |
| 259 | 259 | const ERROR_EXTRACT_EXEC = 'errExtractExec'; |
| 260 | 260 | |
@@ -281,17 +281,17 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | $this->time = $this->utime(); |
| 283 | 283 | $this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false); |
| 284 | - $this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true; |
|
| 284 | + $this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true; |
|
| 285 | 285 | $this->sessionUseCmds = array_flip($sessionUseCmds); |
| 286 | 286 | $this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0); |
| 287 | 287 | $this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : ''); |
| 288 | - $this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes'; |
|
| 288 | + $this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes'; |
|
| 289 | 289 | $this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : ''); |
| 290 | 290 | self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches'; |
| 291 | 291 | |
| 292 | 292 | // check session cache |
| 293 | 293 | $_optsMD5 = md5(json_encode($opts['roots'])); |
| 294 | - if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) { |
|
| 294 | + if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) { |
|
| 295 | 295 | $_SESSION[self::$sessionCacheKey] = array( |
| 296 | 296 | '_optsMD5' => $_optsMD5 |
| 297 | 297 | ); |
@@ -310,20 +310,20 @@ discard block |
||
| 310 | 310 | $_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : ''; |
| 311 | 311 | foreach ($opts['bind'] as $cmd => $handlers) { |
| 312 | 312 | $doRegist = (strpos($cmd, '*') !== false); |
| 313 | - if (! $doRegist) { |
|
| 313 | + if (!$doRegist) { |
|
| 314 | 314 | $_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);'); |
| 315 | 315 | $doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd)))); |
| 316 | 316 | } |
| 317 | 317 | if ($doRegist) { |
| 318 | - if (! is_array($handlers) || is_object($handlers[0])) { |
|
| 318 | + if (!is_array($handlers) || is_object($handlers[0])) { |
|
| 319 | 319 | $handlers = array($handlers); |
| 320 | 320 | } |
| 321 | - foreach($handlers as $handler) { |
|
| 321 | + foreach ($handlers as $handler) { |
|
| 322 | 322 | if ($handler) { |
| 323 | 323 | if (is_string($handler) && strpos($handler, '.')) { |
| 324 | 324 | list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, ''); |
| 325 | 325 | if (strcasecmp($_domain, 'plugin') === 0) { |
| 326 | - if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array()) |
|
| 326 | + if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array()) |
|
| 327 | 327 | and method_exists($plugin, $_method)) { |
| 328 | 328 | $this->bind($cmd, array($plugin, $_method)); |
| 329 | 329 | } |
@@ -410,13 +410,13 @@ discard block |
||
| 410 | 410 | public function bind($cmd, $handler) { |
| 411 | 411 | $allCmds = array_keys($this->commands); |
| 412 | 412 | $cmds = array(); |
| 413 | - foreach(explode(' ', $cmd) as $_cmd) { |
|
| 413 | + foreach (explode(' ', $cmd) as $_cmd) { |
|
| 414 | 414 | if ($_cmd !== '') { |
| 415 | 415 | if ($all = strpos($_cmd, '*') !== false) { |
| 416 | 416 | list(, $sub) = array_pad(explode('.', $_cmd), 2, ''); |
| 417 | 417 | if ($sub) { |
| 418 | 418 | $sub = str_replace('\'', '\\\'', $sub); |
| 419 | - $addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');'); |
|
| 419 | + $addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');'); |
|
| 420 | 420 | $cmds = array_merge($cmds, array_map($addSub, $allCmds)); |
| 421 | 421 | } else { |
| 422 | 422 | $cmds = array_merge($cmds, $allCmds); |
@@ -496,16 +496,16 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | private function session_expires() { |
| 498 | 498 | |
| 499 | - if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) { |
|
| 500 | - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time(); |
|
| 499 | + if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) { |
|
| 500 | + $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time(); |
|
| 501 | 501 | return false; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) { |
|
| 504 | + if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) { |
|
| 505 | 505 | return true; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time(); |
|
| 508 | + $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time(); |
|
| 509 | 509 | return false; |
| 510 | 510 | } |
| 511 | 511 | |
@@ -538,9 +538,9 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | // call pre handlers for this command |
| 541 | - $args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier; |
|
| 541 | + $args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier; |
|
| 542 | 542 | if (!empty($this->listeners[$cmd.'.pre'])) { |
| 543 | - $volume = isset($args['target'])? $this->volume($args['target']) : false; |
|
| 543 | + $volume = isset($args['target']) ? $this->volume($args['target']) : false; |
|
| 544 | 544 | foreach ($this->listeners[$cmd.'.pre'] as $handler) { |
| 545 | 545 | call_user_func_array($handler, array($cmd, &$args, $this, $volume)); |
| 546 | 546 | } |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | // call handlers for this command |
| 563 | 563 | if (!empty($this->listeners[$cmd])) { |
| 564 | 564 | foreach ($this->listeners[$cmd] as $handler) { |
| 565 | - if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) { |
|
| 565 | + if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) { |
|
| 566 | 566 | // handler return true to force sync client after command completed |
| 567 | 567 | $result['sync'] = true; |
| 568 | 568 | } |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * @return string |
| 622 | 622 | * @author Dmitry (dio) Levashov |
| 623 | 623 | **/ |
| 624 | - public function realpath($hash) { |
|
| 624 | + public function realpath($hash) { |
|
| 625 | 625 | if (($volume = $this->volume($hash)) == false) { |
| 626 | 626 | return false; |
| 627 | 627 | } |
@@ -677,11 +677,11 @@ discard block |
||
| 677 | 677 | */ |
| 678 | 678 | protected function getPluginInstance($name, $opts = array()) { |
| 679 | 679 | $key = strtolower($name); |
| 680 | - if (! isset($this->plugins[$key])) { |
|
| 681 | - $p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php'; |
|
| 680 | + if (!isset($this->plugins[$key])) { |
|
| 681 | + $p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php'; |
|
| 682 | 682 | if (is_file($p_file)) { |
| 683 | 683 | require_once $p_file; |
| 684 | - $class = 'elFinderPlugin' . $name; |
|
| 684 | + $class = 'elFinderPlugin'.$name; |
|
| 685 | 685 | $this->plugins[$key] = new $class($opts); |
| 686 | 686 | } else { |
| 687 | 687 | $this->plugins[$key] = false; |
@@ -773,8 +773,8 @@ discard block |
||
| 773 | 773 | |
| 774 | 774 | $netVolumes = $this->getNetVolumes(); |
| 775 | 775 | if ($volume->mount($options)) { |
| 776 | - if (! $key = @ $volume->netMountKey) { |
|
| 777 | - $key = md5($protocol . '-' . join('-', $options)); |
|
| 776 | + if (!$key = @ $volume->netMountKey) { |
|
| 777 | + $key = md5($protocol.'-'.join('-', $options)); |
|
| 778 | 778 | } |
| 779 | 779 | $options['driver'] = $driver; |
| 780 | 780 | $options['netkey'] = $key; |
@@ -979,10 +979,10 @@ discard block |
||
| 979 | 979 | $dispInlineRegex = $volume->getOption('dispInlineRegex'); |
| 980 | 980 | $inlineRegex = false; |
| 981 | 981 | if ($dispInlineRegex) { |
| 982 | - $inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#'; |
|
| 982 | + $inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#'; |
|
| 983 | 983 | try { |
| 984 | 984 | preg_match($inlineRegex, ''); |
| 985 | - } catch(Exception $e) { |
|
| 985 | + } catch (Exception $e) { |
|
| 986 | 986 | $inlineRegex = false; |
| 987 | 987 | } |
| 988 | 988 | } |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | $inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#'; |
| 991 | 991 | } |
| 992 | 992 | $mime = $file['mime']; |
| 993 | - $disp = preg_match($inlineRegex, $mime)? 'inline' : 'attachment'; |
|
| 993 | + $disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment'; |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | $filenameEncoded = rawurlencode($file['name']); |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | $name = $args['name']; |
| 1100 | 1100 | |
| 1101 | 1101 | if (($volume = $this->volume($target)) == false |
| 1102 | - || ($rm = $volume->file($target)) == false) { |
|
| 1102 | + || ($rm = $volume->file($target)) == false) { |
|
| 1103 | 1103 | return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND)); |
| 1104 | 1104 | } |
| 1105 | 1105 | $rm['realpath'] = $volume->realpath($target); |
@@ -1177,9 +1177,9 @@ discard block |
||
| 1177 | 1177 | * @retval false error |
| 1178 | 1178 | * @author Naoki Sawada |
| 1179 | 1179 | **/ |
| 1180 | - protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) { |
|
| 1181 | - $method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; |
|
| 1182 | - return $this->$method( $url, $timeout, $redirect_max, $ua, $fp ); |
|
| 1180 | + protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) { |
|
| 1181 | + $method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; |
|
| 1182 | + return $this->$method($url, $timeout, $redirect_max, $ua, $fp); |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | /** |
@@ -1195,26 +1195,26 @@ discard block |
||
| 1195 | 1195 | * @retval false error |
| 1196 | 1196 | * @author Naoki Sawada |
| 1197 | 1197 | **/ |
| 1198 | - protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){ |
|
| 1198 | + protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
| 1199 | 1199 | $ch = curl_init(); |
| 1200 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 1201 | - curl_setopt( $ch, CURLOPT_HEADER, false ); |
|
| 1200 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1201 | + curl_setopt($ch, CURLOPT_HEADER, false); |
|
| 1202 | 1202 | if ($outfp) { |
| 1203 | - curl_setopt( $ch, CURLOPT_FILE, $outfp ); |
|
| 1203 | + curl_setopt($ch, CURLOPT_FILE, $outfp); |
|
| 1204 | 1204 | } else { |
| 1205 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
| 1206 | - curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true ); |
|
| 1207 | - } |
|
| 1208 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 ); |
|
| 1209 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout ); |
|
| 1210 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); |
|
| 1211 | - curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); |
|
| 1212 | - curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
| 1213 | - curl_setopt( $ch, CURLOPT_USERAGENT, $ua); |
|
| 1214 | - $result = curl_exec( $ch ); |
|
| 1205 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 1206 | + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); |
|
| 1207 | + } |
|
| 1208 | + curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1); |
|
| 1209 | + curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout); |
|
| 1210 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 1211 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
| 1212 | + curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
| 1213 | + curl_setopt($ch, CURLOPT_USERAGENT, $ua); |
|
| 1214 | + $result = curl_exec($ch); |
|
| 1215 | 1215 | $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
| 1216 | - curl_close( $ch ); |
|
| 1217 | - return $outfp? $outfp : $result; |
|
| 1216 | + curl_close($ch); |
|
| 1217 | + return $outfp ? $outfp : $result; |
|
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | 1220 | /** |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | * @retval false error |
| 1231 | 1231 | * @author Naoki Sawada |
| 1232 | 1232 | */ |
| 1233 | - protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) { |
|
| 1233 | + protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
| 1234 | 1234 | |
| 1235 | 1235 | $connect_timeout = 3; |
| 1236 | 1236 | $connect_try = 3; |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | $headers = ''; |
| 1242 | 1242 | |
| 1243 | 1243 | $arr = parse_url($url); |
| 1244 | - if (!$arr){ |
|
| 1244 | + if (!$arr) { |
|
| 1245 | 1245 | // Bad request |
| 1246 | 1246 | return false; |
| 1247 | 1247 | } |
@@ -1249,7 +1249,7 @@ discard block |
||
| 1249 | 1249 | // query |
| 1250 | 1250 | $arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : ''; |
| 1251 | 1251 | // port |
| 1252 | - $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80); |
|
| 1252 | + $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80); |
|
| 1253 | 1253 | |
| 1254 | 1254 | $url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port']; |
| 1255 | 1255 | $url_path = isset($arr['path']) ? $arr['path'] : '/'; |
@@ -1258,21 +1258,21 @@ discard block |
||
| 1258 | 1258 | $query = $method.' '.$uri." HTTP/1.0\r\n"; |
| 1259 | 1259 | $query .= "Host: ".$arr['host']."\r\n"; |
| 1260 | 1260 | if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n"; |
| 1261 | - if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
| 1261 | + if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n"; |
|
| 1262 | 1262 | |
| 1263 | 1263 | $query .= $headers; |
| 1264 | 1264 | |
| 1265 | 1265 | $query .= "\r\n"; |
| 1266 | 1266 | |
| 1267 | 1267 | $fp = $connect_try_count = 0; |
| 1268 | - while( !$fp && $connect_try_count < $connect_try ) { |
|
| 1268 | + while (!$fp && $connect_try_count < $connect_try) { |
|
| 1269 | 1269 | |
| 1270 | 1270 | $errno = 0; |
| 1271 | 1271 | $errstr = ""; |
| 1272 | 1272 | $fp = @ fsockopen( |
| 1273 | 1273 | $arr['https'].$arr['host'], |
| 1274 | 1274 | $arr['port'], |
| 1275 | - $errno,$errstr,$connect_timeout); |
|
| 1275 | + $errno, $errstr, $connect_timeout); |
|
| 1276 | 1276 | if ($fp) break; |
| 1277 | 1277 | $connect_try_count++; |
| 1278 | 1278 | if (connection_aborted()) { |
@@ -1297,13 +1297,13 @@ discard block |
||
| 1297 | 1297 | |
| 1298 | 1298 | $_response = ''; |
| 1299 | 1299 | $header = ''; |
| 1300 | - while($_response !== "\r\n"){ |
|
| 1300 | + while ($_response !== "\r\n") { |
|
| 1301 | 1301 | $_response = fgets($fp, $readsize); |
| 1302 | 1302 | $header .= $_response; |
| 1303 | 1303 | }; |
| 1304 | 1304 | |
| 1305 | - $rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
| 1306 | - $rc = (int)$rccd[1]; |
|
| 1305 | + $rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
| 1306 | + $rc = (int) $rccd[1]; |
|
| 1307 | 1307 | |
| 1308 | 1308 | // Redirect |
| 1309 | 1309 | switch ($rc) { |
@@ -1312,19 +1312,19 @@ discard block |
||
| 1312 | 1312 | case 302: // Moved Temporarily |
| 1313 | 1313 | case 301: // Moved Permanently |
| 1314 | 1314 | $matches = array(); |
| 1315 | - if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) { |
|
| 1315 | + if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) { |
|
| 1316 | 1316 | $url = trim($matches[1]); |
| 1317 | - $hash = isset($matches[2])? trim($matches[2]) : ''; |
|
| 1318 | - if (!preg_match('/^https?:\//',$url)) { // no scheme |
|
| 1317 | + $hash = isset($matches[2]) ? trim($matches[2]) : ''; |
|
| 1318 | + if (!preg_match('/^https?:\//', $url)) { // no scheme |
|
| 1319 | 1319 | if ($url{0} != '/') { // Relative path |
| 1320 | 1320 | // to Absolute path |
| 1321 | - $url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url; |
|
| 1321 | + $url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url; |
|
| 1322 | 1322 | } |
| 1323 | 1323 | // add sheme,host |
| 1324 | 1324 | $url = $url_base.$url; |
| 1325 | 1325 | } |
| 1326 | 1326 | fclose($fp); |
| 1327 | - return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp ); |
|
| 1327 | + return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp); |
|
| 1328 | 1328 | } |
| 1329 | 1329 | } |
| 1330 | 1330 | |
@@ -1333,7 +1333,7 @@ discard block |
||
| 1333 | 1333 | $outfp = fopen('php://temp', 'rwb'); |
| 1334 | 1334 | $body = true; |
| 1335 | 1335 | } |
| 1336 | - while(fwrite($outfp, fread($fp, $readsize))) { |
|
| 1336 | + while (fwrite($outfp, fread($fp, $readsize))) { |
|
| 1337 | 1337 | if ($timeout) { |
| 1338 | 1338 | $_status = socket_get_status($fp); |
| 1339 | 1339 | if ($_status['timed_out']) { |
@@ -1352,7 +1352,7 @@ discard block |
||
| 1352 | 1352 | |
| 1353 | 1353 | fclose($fp); |
| 1354 | 1354 | |
| 1355 | - return $outfp? $outfp : $body; // Data |
|
| 1355 | + return $outfp ? $outfp : $body; // Data |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | /** |
@@ -1363,13 +1363,13 @@ discard block |
||
| 1363 | 1363 | * @return array |
| 1364 | 1364 | * @author Naoki Sawada |
| 1365 | 1365 | */ |
| 1366 | - protected function parse_data_scheme( $str, $extTable ) { |
|
| 1366 | + protected function parse_data_scheme($str, $extTable) { |
|
| 1367 | 1367 | $data = $name = ''; |
| 1368 | 1368 | if ($fp = fopen('data://'.substr($str, 5), 'rb')) { |
| 1369 | 1369 | if ($data = stream_get_contents($fp)) { |
| 1370 | 1370 | $meta = stream_get_meta_data($fp); |
| 1371 | - $ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : ''; |
|
| 1372 | - $name = substr(md5($data), 0, 8) . $ext; |
|
| 1371 | + $ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : ''; |
|
| 1372 | + $name = substr(md5($data), 0, 8).$ext; |
|
| 1373 | 1373 | } |
| 1374 | 1374 | fclose($fp); |
| 1375 | 1375 | } |
@@ -1433,7 +1433,7 @@ discard block |
||
| 1433 | 1433 | } |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | - return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : ''; |
|
| 1436 | + return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : ''; |
|
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | /** |
@@ -1449,26 +1449,26 @@ discard block |
||
| 1449 | 1449 | private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) { |
| 1450 | 1450 | if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) { |
| 1451 | 1451 | $fname = $m[1]; |
| 1452 | - $encname = md5($cid . '_' . $fname); |
|
| 1453 | - $base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname; |
|
| 1452 | + $encname = md5($cid.'_'.$fname); |
|
| 1453 | + $base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname; |
|
| 1454 | 1454 | $clast = intval($m[3]); |
| 1455 | 1455 | if (is_null($tmpname)) { |
| 1456 | 1456 | ignore_user_abort(true); |
| 1457 | 1457 | sleep(10); // wait 10 sec |
| 1458 | 1458 | // chunked file upload fail |
| 1459 | - foreach(glob($base . '*') as $cf) { |
|
| 1459 | + foreach (glob($base.'*') as $cf) { |
|
| 1460 | 1460 | @unlink($cf); |
| 1461 | 1461 | } |
| 1462 | 1462 | ignore_user_abort(false); |
| 1463 | 1463 | return; |
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | - $range = isset($_POST['range'])? trim($_POST['range']) : ''; |
|
| 1466 | + $range = isset($_POST['range']) ? trim($_POST['range']) : ''; |
|
| 1467 | 1467 | if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) { |
| 1468 | 1468 | $start = $ranges[1]; |
| 1469 | 1469 | $len = $ranges[2]; |
| 1470 | 1470 | $size = $ranges[3]; |
| 1471 | - $tmp = $base . '.part'; |
|
| 1471 | + $tmp = $base.'.part'; |
|
| 1472 | 1472 | $csize = filesize($tmpname); |
| 1473 | 1473 | |
| 1474 | 1474 | $tmpExists = is_file($tmp); |
@@ -1493,7 +1493,7 @@ discard block |
||
| 1493 | 1493 | } else { |
| 1494 | 1494 | // wait until makeing temp file (for anothor session) |
| 1495 | 1495 | $cnt = 100; // Time limit 10 sec |
| 1496 | - while(!is_file($base) && --$cnt) { |
|
| 1496 | + while (!is_file($base) && --$cnt) { |
|
| 1497 | 1497 | usleep(100000); // wait 100ms |
| 1498 | 1498 | } |
| 1499 | 1499 | if (!$cnt) { |
@@ -1528,13 +1528,13 @@ discard block |
||
| 1528 | 1528 | } |
| 1529 | 1529 | } else { |
| 1530 | 1530 | // old way |
| 1531 | - $part = $base . $m[2]; |
|
| 1531 | + $part = $base.$m[2]; |
|
| 1532 | 1532 | if (move_uploaded_file($tmpname, $part)) { |
| 1533 | 1533 | @chmod($part, 0600); |
| 1534 | - if ($clast < count(glob($base . '*'))) { |
|
| 1534 | + if ($clast < count(glob($base.'*'))) { |
|
| 1535 | 1535 | $parts = array(); |
| 1536 | 1536 | for ($i = 0; $i <= $clast; $i++) { |
| 1537 | - $name = $base . '.' . $i . '_' . $clast; |
|
| 1537 | + $name = $base.'.'.$i.'_'.$clast; |
|
| 1538 | 1538 | if (is_readable($name)) { |
| 1539 | 1539 | $parts[] = $name; |
| 1540 | 1540 | } else { |
@@ -1547,7 +1547,7 @@ discard block |
||
| 1547 | 1547 | touch($base); |
| 1548 | 1548 | if ($resfile = tempnam($tempDir, 'ELF')) { |
| 1549 | 1549 | $target = fopen($resfile, 'wb'); |
| 1550 | - foreach($parts as $f) { |
|
| 1550 | + foreach ($parts as $f) { |
|
| 1551 | 1551 | $fp = fopen($f, 'rb'); |
| 1552 | 1552 | while (!feof($fp)) { |
| 1553 | 1553 | fwrite($target, fread($fp, 8192)); |
@@ -1588,15 +1588,15 @@ discard block |
||
| 1588 | 1588 | $testDirs[] = rtrim(realpath($volumeTempPath), DIRECTORY_SEPARATOR); |
| 1589 | 1589 | } |
| 1590 | 1590 | $tempDir = ''; |
| 1591 | - $test = DIRECTORY_SEPARATOR . microtime(true); |
|
| 1592 | - foreach($testDirs as $testDir) { |
|
| 1591 | + $test = DIRECTORY_SEPARATOR.microtime(true); |
|
| 1592 | + foreach ($testDirs as $testDir) { |
|
| 1593 | 1593 | if (!$testDir || !is_dir($testDir)) continue; |
| 1594 | 1594 | $testFile = $testDir.$test; |
| 1595 | 1595 | if (touch($testFile)) { |
| 1596 | 1596 | unlink($testFile); |
| 1597 | 1597 | $tempDir = $testDir; |
| 1598 | 1598 | $gc = time() - 3600; |
| 1599 | - foreach(glob($tempDir . '/ELF*') as $cf) { |
|
| 1599 | + foreach (glob($tempDir.'/ELF*') as $cf) { |
|
| 1600 | 1600 | if (filemtime($cf) < $gc) { |
| 1601 | 1601 | @unlink($cf); |
| 1602 | 1602 | } |
@@ -1616,7 +1616,7 @@ discard block |
||
| 1616 | 1616 | **/ |
| 1617 | 1617 | protected function chmod($args) { |
| 1618 | 1618 | $targets = $args['targets']; |
| 1619 | - $mode = intval((string)$args['mode'], 8); |
|
| 1619 | + $mode = intval((string) $args['mode'], 8); |
|
| 1620 | 1620 | |
| 1621 | 1621 | if (!is_array($targets)) { |
| 1622 | 1622 | $targets = array($targets); |
@@ -1631,10 +1631,10 @@ discard block |
||
| 1631 | 1631 | |
| 1632 | 1632 | $files = array(); |
| 1633 | 1633 | $errors = array(); |
| 1634 | - foreach($targets as $target) { |
|
| 1634 | + foreach ($targets as $target) { |
|
| 1635 | 1635 | $file = $volume->chmod($target, $mode); |
| 1636 | 1636 | if ($file) { |
| 1637 | - $files = array_merge($files, is_array($file)? $file : array($file)); |
|
| 1637 | + $files = array_merge($files, is_array($file) ? $file : array($file)); |
|
| 1638 | 1638 | } else { |
| 1639 | 1639 | $errors = array_merge($errors, $volume->error()); |
| 1640 | 1640 | } |
@@ -1666,15 +1666,15 @@ discard block |
||
| 1666 | 1666 | $files = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array(); |
| 1667 | 1667 | $header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8'); |
| 1668 | 1668 | $result = array_merge(array('added' => array()), $header); |
| 1669 | - $paths = $args['upload_path']? $args['upload_path'] : array(); |
|
| 1670 | - $chunk = $args['chunk']? $args['chunk'] : ''; |
|
| 1671 | - $cid = $args['cid']? (int)$args['cid'] : ''; |
|
| 1669 | + $paths = $args['upload_path'] ? $args['upload_path'] : array(); |
|
| 1670 | + $chunk = $args['chunk'] ? $args['chunk'] : ''; |
|
| 1671 | + $cid = $args['cid'] ? (int) $args['cid'] : ''; |
|
| 1672 | 1672 | |
| 1673 | - $renames= array(); |
|
| 1673 | + $renames = array(); |
|
| 1674 | 1674 | $suffix = '~'; |
| 1675 | 1675 | if ($args['renames'] && is_array($args['renames'])) { |
| 1676 | 1676 | $renames = array_flip($args['renames']); |
| 1677 | - if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) { |
|
| 1677 | + if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) { |
|
| 1678 | 1678 | $suffix = $args['suffix']; |
| 1679 | 1679 | } |
| 1680 | 1680 | } |
@@ -1706,7 +1706,7 @@ discard block |
||
| 1706 | 1706 | if (empty($files)) { |
| 1707 | 1707 | if (!$args['upload'] && $args['name'] && is_array($args['name'])) { |
| 1708 | 1708 | $result['name'] = array(); |
| 1709 | - foreach($args['name'] as $_i => $_name) { |
|
| 1709 | + foreach ($args['name'] as $_i => $_name) { |
|
| 1710 | 1710 | $result['name'][$_i] = preg_replace($ngReg, '_', $_name); |
| 1711 | 1711 | } |
| 1712 | 1712 | $result = array_merge_recursive($result, $this->ls($args)); |
@@ -1719,7 +1719,7 @@ discard block |
||
| 1719 | 1719 | } |
| 1720 | 1720 | if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) { |
| 1721 | 1721 | $names = array(); |
| 1722 | - foreach($args['upload'] as $i => $url) { |
|
| 1722 | + foreach ($args['upload'] as $i => $url) { |
|
| 1723 | 1723 | // check chunked file upload commit |
| 1724 | 1724 | if ($args['chunk']) { |
| 1725 | 1725 | if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') { |
@@ -1729,7 +1729,7 @@ discard block |
||
| 1729 | 1729 | } |
| 1730 | 1730 | return $result; |
| 1731 | 1731 | } else { |
| 1732 | - $tmpfname = $tempDir . '/' . $args['chunk']; |
|
| 1732 | + $tmpfname = $tempDir.'/'.$args['chunk']; |
|
| 1733 | 1733 | $files['tmp_name'][$i] = $tmpfname; |
| 1734 | 1734 | $files['name'][$i] = $url; |
| 1735 | 1735 | $files['error'][$i] = 0; |
@@ -1738,7 +1738,7 @@ discard block |
||
| 1738 | 1738 | } |
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | - $tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true)); |
|
| 1741 | + $tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true)); |
|
| 1742 | 1742 | |
| 1743 | 1743 | $_name = ''; |
| 1744 | 1744 | // check is data: |
@@ -1774,8 +1774,8 @@ discard block |
||
| 1774 | 1774 | list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, ''); |
| 1775 | 1775 | if ($_b === '') { |
| 1776 | 1776 | if ($_ext) { |
| 1777 | - rename($tmpfname, $tmpfname . $_ext); |
|
| 1778 | - $tmpfname = $tmpfname . $_ext; |
|
| 1777 | + rename($tmpfname, $tmpfname.$_ext); |
|
| 1778 | + $tmpfname = $tmpfname.$_ext; |
|
| 1779 | 1779 | } |
| 1780 | 1780 | $_b = $this->detectFileExtension($tmpfname); |
| 1781 | 1781 | $_name = $_a.$_b; |
@@ -1810,7 +1810,7 @@ discard block |
||
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | 1812 | $tmpname = $files['tmp_name'][$i]; |
| 1813 | - $path = ($paths && !empty($paths[$i]))? $paths[$i] : ''; |
|
| 1813 | + $path = ($paths && !empty($paths[$i])) ? $paths[$i] : ''; |
|
| 1814 | 1814 | if ($name === 'blob') { |
| 1815 | 1815 | if ($chunk) { |
| 1816 | 1816 | if ($tempDir = $this->getTempDir($volume->getTempPath())) { |
@@ -1820,7 +1820,7 @@ discard block |
||
| 1820 | 1820 | preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m); |
| 1821 | 1821 | $result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname); |
| 1822 | 1822 | $result['_chunkfailure'] = true; |
| 1823 | - $this->uploadDebug = 'Upload error: ' . $tmpname; |
|
| 1823 | + $this->uploadDebug = 'Upload error: '.$tmpname; |
|
| 1824 | 1824 | } else if ($name) { |
| 1825 | 1825 | $result['_chunkmerged'] = basename($tmpname); |
| 1826 | 1826 | $result['_name'] = $name; |
@@ -1834,14 +1834,14 @@ discard block |
||
| 1834 | 1834 | } else { |
| 1835 | 1835 | // for form clipboard with Google Chrome |
| 1836 | 1836 | $type = $files['type'][$i]; |
| 1837 | - $ext = isset($extTable[$type])? '.' . $extTable[$type] : ''; |
|
| 1838 | - $name = substr(md5(basename($tmpname)), 0, 8) . $ext; |
|
| 1837 | + $ext = isset($extTable[$type]) ? '.'.$extTable[$type] : ''; |
|
| 1838 | + $name = substr(md5(basename($tmpname)), 0, 8).$ext; |
|
| 1839 | 1839 | } |
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | 1842 | // do hook function 'upload.presave' |
| 1843 | - if (! empty($this->listeners['upload.presave'])) { |
|
| 1844 | - foreach($this->listeners['upload.presave'] as $handler) { |
|
| 1843 | + if (!empty($this->listeners['upload.presave'])) { |
|
| 1844 | + foreach ($this->listeners['upload.presave'] as $handler) { |
|
| 1845 | 1845 | call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume)); |
| 1846 | 1846 | } |
| 1847 | 1847 | } |
@@ -1849,7 +1849,7 @@ discard block |
||
| 1849 | 1849 | if (($fp = fopen($tmpname, 'rb')) == false) { |
| 1850 | 1850 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER); |
| 1851 | 1851 | $this->uploadDebug = 'Upload error: unable open tmp file'; |
| 1852 | - if (! is_uploaded_file($tmpname)) { |
|
| 1852 | + if (!is_uploaded_file($tmpname)) { |
|
| 1853 | 1853 | if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
| 1854 | 1854 | continue; |
| 1855 | 1855 | } |
@@ -1871,18 +1871,18 @@ discard block |
||
| 1871 | 1871 | } |
| 1872 | 1872 | } |
| 1873 | 1873 | } |
| 1874 | - if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
| 1874 | + if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
| 1875 | 1875 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error()); |
| 1876 | 1876 | fclose($fp); |
| 1877 | - if (! is_uploaded_file($tmpname)) { |
|
| 1878 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);; |
|
| 1877 | + if (!is_uploaded_file($tmpname)) { |
|
| 1878 | + if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ; |
|
| 1879 | 1879 | continue; |
| 1880 | 1880 | } |
| 1881 | 1881 | break; |
| 1882 | 1882 | } |
| 1883 | 1883 | |
| 1884 | 1884 | is_resource($fp) && fclose($fp); |
| 1885 | - if (! is_uploaded_file($tmpname)){ |
|
| 1885 | + if (!is_uploaded_file($tmpname)) { |
|
| 1886 | 1886 | clearstatcache(); |
| 1887 | 1887 | if (!is_file($tmpname) || @ unlink($tmpname)) { |
| 1888 | 1888 | unset($GLOBALS['elFinderTempFiles'][$tmpname]); |
@@ -1894,7 +1894,7 @@ discard block |
||
| 1894 | 1894 | } |
| 1895 | 1895 | } |
| 1896 | 1896 | if ($GLOBALS['elFinderTempFiles']) { |
| 1897 | - foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
| 1897 | + foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
| 1898 | 1898 | @ unlink($_temp); |
| 1899 | 1899 | } |
| 1900 | 1900 | } |
@@ -1931,7 +1931,7 @@ discard block |
||
| 1931 | 1931 | $suffix = '~'; |
| 1932 | 1932 | if (!empty($args['renames'])) { |
| 1933 | 1933 | $renames = array_flip($args['renames']); |
| 1934 | - if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
| 1934 | + if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
| 1935 | 1935 | $suffix = $args['suffix']; |
| 1936 | 1936 | } |
| 1937 | 1937 | } |
@@ -1989,9 +1989,9 @@ discard block |
||
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | 1991 | if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) { |
| 1992 | - $mime = isset($file['mime'])? $file['mime'] : ''; |
|
| 1992 | + $mime = isset($file['mime']) ? $file['mime'] : ''; |
|
| 1993 | 1993 | if ($mime && strtolower(substr($mime, 0, 4)) === 'text') { |
| 1994 | - if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) { |
|
| 1994 | + if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) { |
|
| 1995 | 1995 | if (strtolower($enc) !== 'utf-8') { |
| 1996 | 1996 | $content = mb_convert_encoding($content, 'UTF-8', $enc); |
| 1997 | 1997 | } |
@@ -2003,7 +2003,7 @@ discard block |
||
| 2003 | 2003 | |
| 2004 | 2004 | if ($json === false || strlen($json) < strlen($content)) { |
| 2005 | 2005 | if ($args['conv']) { |
| 2006 | - return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
| 2006 | + return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
| 2007 | 2007 | } else { |
| 2008 | 2008 | return array('doconv' => true); |
| 2009 | 2009 | } |
@@ -2045,7 +2045,7 @@ discard block |
||
| 2045 | 2045 | $target = $args['target']; |
| 2046 | 2046 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
| 2047 | 2047 | $error = array(self::ERROR_EXTRACT, '#'.$target); |
| 2048 | - $makedir = isset($args['makedir'])? (bool)$args['makedir'] : null; |
|
| 2048 | + $makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null; |
|
| 2049 | 2049 | |
| 2050 | 2050 | if (($volume = $this->volume($target)) == false |
| 2051 | 2051 | || ($file = $volume->file($target)) == false) { |
@@ -2053,7 +2053,7 @@ discard block |
||
| 2053 | 2053 | } |
| 2054 | 2054 | |
| 2055 | 2055 | return ($file = $volume->extract($target, $makedir)) |
| 2056 | - ? array('added' => isset($file['read'])? array($file) : $file) |
|
| 2056 | + ? array('added' => isset($file['read']) ? array($file) : $file) |
|
| 2057 | 2057 | : array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error())); |
| 2058 | 2058 | } |
| 2059 | 2059 | |
@@ -2068,7 +2068,7 @@ discard block |
||
| 2068 | 2068 | protected function archive($args) { |
| 2069 | 2069 | $type = $args['type']; |
| 2070 | 2070 | $targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array(); |
| 2071 | - $name = isset($args['name'])? $args['name'] : ''; |
|
| 2071 | + $name = isset($args['name']) ? $args['name'] : ''; |
|
| 2072 | 2072 | |
| 2073 | 2073 | if (($volume = $this->volume($targets[0])) == false) { |
| 2074 | 2074 | return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND); |
@@ -2089,7 +2089,7 @@ discard block |
||
| 2089 | 2089 | protected function search($args) { |
| 2090 | 2090 | $q = trim($args['q']); |
| 2091 | 2091 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
| 2092 | - $target = !empty($args['target'])? $args['target'] : null; |
|
| 2092 | + $target = !empty($args['target']) ? $args['target'] : null; |
|
| 2093 | 2093 | $result = array(); |
| 2094 | 2094 | |
| 2095 | 2095 | if (!is_null($target)) { |
@@ -2153,11 +2153,11 @@ discard block |
||
| 2153 | 2153 | $target = $args['target']; |
| 2154 | 2154 | $width = $args['width']; |
| 2155 | 2155 | $height = $args['height']; |
| 2156 | - $x = (int)$args['x']; |
|
| 2157 | - $y = (int)$args['y']; |
|
| 2156 | + $x = (int) $args['x']; |
|
| 2157 | + $y = (int) $args['y']; |
|
| 2158 | 2158 | $mode = $args['mode']; |
| 2159 | 2159 | $bg = null; |
| 2160 | - $degree = (int)$args['degree']; |
|
| 2160 | + $degree = (int) $args['degree']; |
|
| 2161 | 2161 | |
| 2162 | 2162 | if (($volume = $this->volume($target)) == false |
| 2163 | 2163 | || ($file = $volume->file($target)) == false) { |
@@ -2178,7 +2178,7 @@ discard block |
||
| 2178 | 2178 | **/ |
| 2179 | 2179 | protected function url($args) { |
| 2180 | 2180 | $target = $args['target']; |
| 2181 | - $options = isset($args['options'])? $args['options'] : array(); |
|
| 2181 | + $options = isset($args['options']) ? $args['options'] : array(); |
|
| 2182 | 2182 | if (($volume = $this->volume($target)) != false) { |
| 2183 | 2183 | $url = $volume->getContentUrl($target, $options); |
| 2184 | 2184 | return $url ? array('url' => $url) : array(); |
@@ -2195,18 +2195,18 @@ discard block |
||
| 2195 | 2195 | */ |
| 2196 | 2196 | protected function callback($args) { |
| 2197 | 2197 | $checkReg = '/[^a-zA-Z0-9;._-]/'; |
| 2198 | - $node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : ''; |
|
| 2199 | - $json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}'; |
|
| 2200 | - $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : ''; |
|
| 2198 | + $node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : ''; |
|
| 2199 | + $json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}'; |
|
| 2200 | + $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : ''; |
|
| 2201 | 2201 | $done = (!empty($args['done'])); |
| 2202 | 2202 | |
| 2203 | - while( ob_get_level() ) { |
|
| 2204 | - if (! ob_end_clean()) { |
|
| 2203 | + while (ob_get_level()) { |
|
| 2204 | + if (!ob_end_clean()) { |
|
| 2205 | 2205 | break; |
| 2206 | 2206 | } |
| 2207 | 2207 | } |
| 2208 | 2208 | |
| 2209 | - if ($done || ! $this->callbackWindowURL) { |
|
| 2209 | + if ($done || !$this->callbackWindowURL) { |
|
| 2210 | 2210 | $script = ''; |
| 2211 | 2211 | if ($node) { |
| 2212 | 2212 | $script .= ' |
@@ -2248,13 +2248,13 @@ discard block |
||
| 2248 | 2248 | |
| 2249 | 2249 | } else { |
| 2250 | 2250 | $url = $this->callbackWindowURL; |
| 2251 | - $url .= ((strpos($url, '?') === false)? '?' : '&') |
|
| 2252 | - . '&node=' . rawurlencode($node) |
|
| 2253 | - . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '') |
|
| 2254 | - . ($bind? ('&bind=' . rawurlencode($bind)) : '') |
|
| 2251 | + $url .= ((strpos($url, '?') === false) ? '?' : '&') |
|
| 2252 | + . '&node='.rawurlencode($node) |
|
| 2253 | + . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '') |
|
| 2254 | + . ($bind ? ('&bind='.rawurlencode($bind)) : '') |
|
| 2255 | 2255 | . '&done=1'; |
| 2256 | 2256 | |
| 2257 | - header('Location: ' . $url); |
|
| 2257 | + header('Location: '.$url); |
|
| 2258 | 2258 | |
| 2259 | 2259 | } |
| 2260 | 2260 | exit(); |
@@ -2324,7 +2324,7 @@ discard block |
||
| 2324 | 2324 | |
| 2325 | 2325 | protected function utime() { |
| 2326 | 2326 | $time = explode(" ", microtime()); |
| 2327 | - return (double)$time[1] + (double)$time[0]; |
|
| 2327 | + return (double) $time[1] + (double) $time[0]; |
|
| 2328 | 2328 | } |
| 2329 | 2329 | |
| 2330 | 2330 | |
@@ -2350,7 +2350,7 @@ discard block |
||
| 2350 | 2350 | $imgcnt = 0; |
| 2351 | 2351 | $fp = fopen($path, 'rb'); |
| 2352 | 2352 | @fread($fp, 4); |
| 2353 | - $c = @fread($fp,1); |
|
| 2353 | + $c = @fread($fp, 1); |
|
| 2354 | 2354 | if (ord($c) != 0x39) { // GIF89a |
| 2355 | 2355 | return false; |
| 2356 | 2356 | } |
@@ -2358,13 +2358,13 @@ discard block |
||
| 2358 | 2358 | while (!feof($fp)) { |
| 2359 | 2359 | do { |
| 2360 | 2360 | $c = fread($fp, 1); |
| 2361 | - } while(ord($c) != 0x21 && !feof($fp)); |
|
| 2361 | + } while (ord($c) != 0x21 && !feof($fp)); |
|
| 2362 | 2362 | |
| 2363 | 2363 | if (feof($fp)) { |
| 2364 | 2364 | break; |
| 2365 | 2365 | } |
| 2366 | 2366 | |
| 2367 | - $c2 = fread($fp,2); |
|
| 2367 | + $c2 = fread($fp, 2); |
|
| 2368 | 2368 | if (bin2hex($c2) == "f904") { |
| 2369 | 2369 | $imgcnt++; |
| 2370 | 2370 | } |