@@ -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 | |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * @author Dmitry (dio) Levashov |
| 33 | 33 | **/ |
| 34 | 34 | public function __construct() { |
| 35 | - $this->options['alias'] = ''; // alias to replace root dir name |
|
| 36 | - $this->options['dirMode'] = 0755; // new dirs mode |
|
| 37 | - $this->options['fileMode'] = 0644; // new files mode |
|
| 38 | - $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) |
|
| 39 | - $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
| 35 | + $this->options['alias'] = ''; // alias to replace root dir name |
|
| 36 | + $this->options['dirMode'] = 0755; // new dirs mode |
|
| 37 | + $this->options['fileMode'] = 0644; // new files mode |
|
| 38 | + $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) |
|
| 39 | + $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
| 40 | 40 | $this->options['rootCssClass'] = 'elfinder-navbar-root-local'; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | protected function init() { |
| 54 | 54 | // Normalize directory separator for windows |
| 55 | 55 | if (DIRECTORY_SEPARATOR !== '/') { |
| 56 | - foreach(array('path', 'tmpPath', 'quarantine') as $key) { |
|
| 56 | + foreach (array('path', 'tmpPath', 'quarantine') as $key) { |
|
| 57 | 57 | if ($this->options[$key]) { |
| 58 | 58 | $this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]); |
| 59 | 59 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | // if no thumbnails url - try detect it |
| 100 | 100 | if ($root['read'] && !$this->tmbURL && $this->URL) { |
| 101 | 101 | if (strpos($this->tmbPath, $this->root) === 0) { |
| 102 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); |
|
| 102 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); |
|
| 103 | 103 | if (preg_match("|[^/?&=]$|", $this->tmbURL)) { |
| 104 | 104 | $this->tmbURL .= '/'; |
| 105 | 105 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @author Dmitry (dio) Levashov |
| 176 | 176 | **/ |
| 177 | 177 | protected function _joinPath($dir, $name) { |
| 178 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
| 178 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $comps = $new_comps; |
| 228 | 228 | $path = implode('/', $comps); |
| 229 | 229 | if ($initial_slashes) { |
| 230 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
| 230 | + $path = str_repeat('/', $initial_slashes).$path; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | if ($changeSep) { |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | **/ |
| 299 | 299 | protected function _inpath($path, $parent) { |
| 300 | 300 | $cwd = getcwd(); |
| 301 | - $real_path = $this->getFullPath($path, $cwd); |
|
| 301 | + $real_path = $this->getFullPath($path, $cwd); |
|
| 302 | 302 | $real_parent = $this->getFullPath($parent, $cwd); |
| 303 | 303 | if ($real_path && $real_parent) { |
| 304 | 304 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | $stat = array(); |
| 358 | 358 | return $stat; |
| 359 | 359 | } else { |
| 360 | - $stat['mime'] = 'symlink-broken'; |
|
| 360 | + $stat['mime'] = 'symlink-broken'; |
|
| 361 | 361 | $target = readlink($path); |
| 362 | 362 | $lstat = lstat($path); |
| 363 | 363 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $fstat = stat($path); |
| 374 | 374 | $uid = $fstat['uid']; |
| 375 | 375 | $gid = $fstat['gid']; |
| 376 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
| 376 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
| 377 | 377 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 378 | 378 | } |
| 379 | 379 | |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
| 384 | 384 | } |
| 385 | 385 | //logical rights first |
| 386 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
| 387 | - $stat['write'] = is_writable($path)? null : false; |
|
| 386 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
| 387 | + $stat['write'] = is_writable($path) ? null : false; |
|
| 388 | 388 | |
| 389 | 389 | if (is_null($stat['read'])) { |
| 390 | 390 | $stat['size'] = $dir ? 0 : $size; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | protected function _subdirs($path) { |
| 454 | 454 | |
| 455 | 455 | if (is_dir($path)) { |
| 456 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
| 456 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
| 457 | 457 | } |
| 458 | 458 | return false; |
| 459 | 459 | } |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | $br = true; |
| 535 | 535 | } else { |
| 536 | 536 | $_path = $fpath; |
| 537 | - $stat['mime'] = 'symlink-broken'; |
|
| 537 | + $stat['mime'] = 'symlink-broken'; |
|
| 538 | 538 | $target = readlink($_path); |
| 539 | 539 | $lstat = lstat($_path); |
| 540 | 540 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -559,13 +559,13 @@ discard block |
||
| 559 | 559 | if ($statOwner && !$linkreadable) { |
| 560 | 560 | $uid = $file->getOwner(); |
| 561 | 561 | $gid = $file->getGroup(); |
| 562 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
| 562 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
| 563 | 563 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | //logical rights first |
| 567 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
| 568 | - $stat['write'] = $file->isWritable()? null : false; |
|
| 567 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
| 568 | + $stat['write'] = $file->isWritable() ? null : false; |
|
| 569 | 569 | |
| 570 | 570 | if (is_null($stat['read'])) { |
| 571 | 571 | $stat['size'] = $dir ? 0 : $size; |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | if ($cache) { |
| 583 | 583 | $cache = $this->convEncOut($cache, false); |
| 584 | - foreach($cache as $d) { |
|
| 584 | + foreach ($cache as $d) { |
|
| 585 | 585 | $this->updateCache($d[0], $d[1]); |
| 586 | 586 | } |
| 587 | 587 | } |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | * @return resource|false |
| 598 | 598 | * @author Dmitry (dio) Levashov |
| 599 | 599 | **/ |
| 600 | - protected function _fopen($path, $mode='rb') { |
|
| 600 | + protected function _fopen($path, $mode = 'rb') { |
|
| 601 | 601 | return @fopen($path, $mode); |
| 602 | 602 | } |
| 603 | 603 | |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | * @return bool |
| 609 | 609 | * @author Dmitry (dio) Levashov |
| 610 | 610 | **/ |
| 611 | - protected function _fclose($fp, $path='') { |
|
| 611 | + protected function _fclose($fp, $path = '') { |
|
| 612 | 612 | return @fclose($fp); |
| 613 | 613 | } |
| 614 | 614 | |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $path = $this->_joinPath($dir, $name); |
| 741 | 741 | |
| 742 | 742 | $meta = stream_get_meta_data($fp); |
| 743 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
| 743 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
| 744 | 744 | if ($uri && @is_file($uri)) { |
| 745 | 745 | fclose($fp); |
| 746 | 746 | if (!@rename($uri, $path) && !@copy($uri, $path)) { |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | * @return bool |
| 801 | 801 | **/ |
| 802 | 802 | protected function _chmod($path, $mode) { |
| 803 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
| 803 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
| 804 | 804 | $ret = @chmod($path, $modeOct); |
| 805 | 805 | $ret && clearstatcache(); |
| 806 | 806 | return $ret; |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | $src = $dir; |
| 919 | 919 | $name = basename($path); |
| 920 | 920 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 921 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 921 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 922 | 922 | } |
| 923 | 923 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
| 924 | 924 | if (file_exists($test) || is_link($test)) { |
@@ -927,9 +927,9 @@ discard block |
||
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | if ($name !== '') { |
| 930 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 930 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 931 | 931 | |
| 932 | - if (! @rename($src, $result)) { |
|
| 932 | + if (!@rename($src, $result)) { |
|
| 933 | 933 | $this->delTree($dir); |
| 934 | 934 | return false; |
| 935 | 935 | } |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | $dstDir = dirname($path); |
| 938 | 938 | $res = false; |
| 939 | 939 | $result = array(); |
| 940 | - foreach($ls as $name) { |
|
| 940 | + foreach ($ls as $name) { |
|
| 941 | 941 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
| 942 | 942 | if (is_dir($target)) { |
| 943 | 943 | $this->delTree($target); |
@@ -1013,14 +1013,14 @@ discard block |
||
| 1013 | 1013 | $result = array(); |
| 1014 | 1014 | |
| 1015 | 1015 | $path = $this->convEncIn($path); |
| 1016 | - $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
| 1017 | - $match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$q.'*', GLOB_NOSORT); |
|
| 1016 | + $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
| 1017 | + $match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$q.'*', GLOB_NOSORT); |
|
| 1018 | 1018 | if ($dirs) { |
| 1019 | 1019 | $dirs = $this->convEncOut($dirs, false); |
| 1020 | 1020 | } |
| 1021 | 1021 | $match = $this->convEncOut($match); |
| 1022 | 1022 | if ($match) { |
| 1023 | - foreach($match as $p) { |
|
| 1023 | + foreach ($match as $p) { |
|
| 1024 | 1024 | $stat = $this->stat($p); |
| 1025 | 1025 | |
| 1026 | 1026 | if (!$stat) { // invalid links |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | if ($this->encoding) { |
| 1041 | 1041 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
| 1042 | 1042 | } |
| 1043 | - $stat['url'] = $this->URL . $path; |
|
| 1043 | + $stat['url'] = $this->URL.$path; |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | $result[] = $stat; |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | } |
| 1049 | 1049 | } |
| 1050 | 1050 | if ($dirs) { |
| 1051 | - foreach($dirs as $dir) { |
|
| 1051 | + foreach ($dirs as $dir) { |
|
| 1052 | 1052 | $stat = $this->stat($dir); |
| 1053 | 1053 | if ($stat['read'] && !isset($stat['alias'])) { |
| 1054 | 1054 | @set_time_limit(30); |
@@ -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 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | if ($options['user'] === 'init') { |
| 139 | 139 | |
| 140 | - if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) { |
|
| 140 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) { |
|
| 141 | 141 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | if (class_exists('OAuth')) { |
| 148 | 148 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
| 149 | 149 | } else { |
| 150 | - if (! class_exists('HTTP_OAuth_Consumer')) { |
|
| 150 | + if (!class_exists('HTTP_OAuth_Consumer')) { |
|
| 151 | 151 | // We're going to try to load in manually |
| 152 | 152 | include 'HTTP/OAuth/Consumer.php'; |
| 153 | 153 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if (! $this->oauth) { |
|
| 160 | + if (!$this->oauth) { |
|
| 161 | 161 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -178,24 +178,24 @@ discard block |
||
| 178 | 178 | unset($_SESSION['elFinderDropboxTokens']); |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | - if (! $html) { |
|
| 181 | + if (!$html) { |
|
| 182 | 182 | // get customdata |
| 183 | 183 | $cdata = ''; |
| 184 | 184 | $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); |
| 185 | - foreach($this->ARGS as $k => $v) { |
|
| 186 | - if (! in_array($k, $innerKeys)) { |
|
| 187 | - $cdata .= '&' . $k . '=' . rawurlencode($v); |
|
| 185 | + foreach ($this->ARGS as $k => $v) { |
|
| 186 | + if (!in_array($k, $innerKeys)) { |
|
| 187 | + $cdata .= '&'.$k.'='.rawurlencode($v); |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | - if (strpos($options['url'], 'http') !== 0 ) { |
|
| 190 | + if (strpos($options['url'], 'http') !== 0) { |
|
| 191 | 191 | $options['url'] = $this->getConnectorUrl(); |
| 192 | 192 | } |
| 193 | - $callback = $options['url'] |
|
| 193 | + $callback = $options['url'] |
|
| 194 | 194 | . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
| 195 | 195 | |
| 196 | 196 | try { |
| 197 | 197 | $tokens = $this->oauth->getRequestToken(); |
| 198 | - $url= $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
| 198 | + $url = $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
| 199 | 199 | } catch (Dropbox_Exception $e) { |
| 200 | 200 | return array('exit' => true, 'body' => '{msg:errAccess}'); |
| 201 | 201 | } |
@@ -242,14 +242,14 @@ discard block |
||
| 242 | 242 | if (isset($netVolumes[$key])) { |
| 243 | 243 | $dropboxUid = $netVolumes[$key]['dropboxUid']; |
| 244 | 244 | } |
| 245 | - foreach($netVolumes as $volume) { |
|
| 245 | + foreach ($netVolumes as $volume) { |
|
| 246 | 246 | if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) { |
| 247 | 247 | $count++; |
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | if ($count === 1) { |
| 251 | 251 | $this->DB->exec('drop table '.$this->DB_TableName); |
| 252 | - foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
| 252 | + foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
| 253 | 253 | unlink($tmb); |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | * @author Naoki Sawada |
| 264 | 264 | */ |
| 265 | 265 | private function getConnectorUrl() { |
| 266 | - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
|
| 266 | + $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') |
|
| 267 | 267 | . $_SERVER['SERVER_NAME'] // host |
| 268 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
| 269 | - . $_SERVER['REQUEST_URI']; // path & query |
|
| 268 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) // port |
|
| 269 | + . $_SERVER['REQUEST_URI']; // path & query |
|
| 270 | 270 | list($url) = explode('?', $url); |
| 271 | 271 | return $url; |
| 272 | 272 | } |
@@ -302,14 +302,14 @@ discard block |
||
| 302 | 302 | // make net mount key |
| 303 | 303 | $this->netMountKey = md5(join('-', array('dropbox', $this->options['path']))); |
| 304 | 304 | |
| 305 | - if (! $this->oauth) { |
|
| 305 | + if (!$this->oauth) { |
|
| 306 | 306 | if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) { |
| 307 | 307 | $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']); |
| 308 | 308 | } else { |
| 309 | 309 | if (class_exists('OAuth')) { |
| 310 | 310 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
| 311 | 311 | } else { |
| 312 | - if (! class_exists('HTTP_OAuth_Consumer')) { |
|
| 312 | + if (!class_exists('HTTP_OAuth_Consumer')) { |
|
| 313 | 313 | // We're going to try to load in manually |
| 314 | 314 | include 'HTTP/OAuth/Consumer.php'; |
| 315 | 315 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if (! $this->oauth) { |
|
| 323 | + if (!$this->oauth) { |
|
| 324 | 324 | return $this->setError('OAuth extension not loaded.'); |
| 325 | 325 | } |
| 326 | 326 | |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | $this->root = $this->options['path'] = $this->_normpath($this->options['path']); |
| 329 | 329 | |
| 330 | 330 | if (empty($this->options['alias'])) { |
| 331 | - $this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
| 331 | + $this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | $this->rootName = $this->options['alias']; |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // setup PDO |
| 387 | - if (! $this->options['PDO_DSN']) { |
|
| 387 | + if (!$this->options['PDO_DSN']) { |
|
| 388 | 388 | $this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']); |
| 389 | 389 | } |
| 390 | 390 | // DataBase table name |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | // DataBase check or make table |
| 393 | 393 | try { |
| 394 | 394 | $this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']); |
| 395 | - if (! $this->checkDB()) { |
|
| 395 | + if (!$this->checkDB()) { |
|
| 396 | 396 | return $this->setError('Can not make DB table'); |
| 397 | 397 | } |
| 398 | 398 | } catch (PDOException $e) { |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | $res = false; |
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | - if (! $res) { |
|
| 446 | + if (!$res) { |
|
| 447 | 447 | try { |
| 448 | 448 | $this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);'); |
| 449 | 449 | $this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)'); |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | */ |
| 494 | 494 | private function updateDBdat($path, $dat) { |
| 495 | 495 | return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat)) |
| 496 | - . ', isdir=' . ($dat['is_dir']? 1 : 0) |
|
| 496 | + . ', isdir='.($dat['is_dir'] ? 1 : 0) |
|
| 497 | 497 | . ' where path='.$this->DB->quote(strtolower(dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path)))); |
| 498 | 498 | } |
| 499 | 499 | /*********************************************************************/ |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | */ |
| 519 | 519 | protected function deltaCheck($refresh = true) { |
| 520 | 520 | $chk = false; |
| 521 | - if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
| 521 | + if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
| 522 | 522 | $chk = unserialize($chk[0]); |
| 523 | 523 | } |
| 524 | 524 | if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) { |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | do { |
| 541 | 541 | @ ini_set('max_execution_time', 120); |
| 542 | 542 | $_info = $this->dropbox->delta($cursor); |
| 543 | - if (! empty($_info['reset'])) { |
|
| 543 | + if (!empty($_info['reset'])) { |
|
| 544 | 544 | $this->DB->exec('TRUNCATE table '.$this->DB_TableName); |
| 545 | 545 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);'); |
| 546 | 546 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array( |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | } |
| 554 | 554 | $cursor = $_info['cursor']; |
| 555 | 555 | |
| 556 | - foreach($_info['entries'] as $entry) { |
|
| 556 | + foreach ($_info['entries'] as $entry) { |
|
| 557 | 557 | $key = strtolower($entry[0]); |
| 558 | 558 | $pkey = strtolower(dirname($key)); |
| 559 | 559 | |
@@ -563,27 +563,27 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | if (empty($entry[1])) { |
| 565 | 565 | $this->DB->exec('delete from '.$this->DB_TableName.' '.$where); |
| 566 | - ! $delete && $delete = true; |
|
| 566 | + !$delete && $delete = true; |
|
| 567 | 567 | continue; |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | $sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1'; |
| 571 | - if (! $reset && $this->query($sql)) { |
|
| 572 | - $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where); |
|
| 571 | + if (!$reset && $this->query($sql)) { |
|
| 572 | + $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where); |
|
| 573 | 573 | } else { |
| 574 | - $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')'); |
|
| 574 | + $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')'); |
|
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | - } while (! empty($_info['has_more'])); |
|
| 577 | + } while (!empty($_info['has_more'])); |
|
| 578 | 578 | $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\''); |
| 579 | - if (! $this->DB->commit()) { |
|
| 579 | + if (!$this->DB->commit()) { |
|
| 580 | 580 | $e = $this->DB->errorInfo(); |
| 581 | 581 | return $e[2]; |
| 582 | 582 | } |
| 583 | 583 | if ($delete) { |
| 584 | 584 | $this->DB->exec('vacuum'); |
| 585 | 585 | } |
| 586 | - } catch(Dropbox_Exception $e) { |
|
| 586 | + } catch (Dropbox_Exception $e) { |
|
| 587 | 587 | return $e->getMessage(); |
| 588 | 588 | } |
| 589 | 589 | return true; |
@@ -599,15 +599,14 @@ discard block |
||
| 599 | 599 | protected function parseRaw($raw) { |
| 600 | 600 | $stat = array(); |
| 601 | 601 | |
| 602 | - $stat['rev'] = isset($raw['rev'])? $raw['rev'] : 'root'; |
|
| 602 | + $stat['rev'] = isset($raw['rev']) ? $raw['rev'] : 'root'; |
|
| 603 | 603 | $stat['name'] = basename($raw['path']); |
| 604 | - $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
|
| 604 | + $stat['mime'] = $raw['is_dir'] ? 'directory' : $raw['mime_type']; |
|
| 605 | 605 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
| 606 | - $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
|
| 607 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
| 606 | + $stat['ts'] = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
| 608 | 607 | $stat['dirs'] = 0; |
| 609 | 608 | if ($raw['is_dir']) { |
| 610 | - $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
| 609 | + $stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
| 611 | 610 | } |
| 612 | 611 | |
| 613 | 612 | if (!empty($raw['url'])) { |
@@ -633,7 +632,7 @@ discard block |
||
| 633 | 632 | $res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path))); |
| 634 | 633 | |
| 635 | 634 | if ($res) { |
| 636 | - foreach($res as $raw) { |
|
| 635 | + foreach ($res as $raw) { |
|
| 637 | 636 | $raw = unserialize($raw); |
| 638 | 637 | if ($stat = $this->parseRaw($raw)) { |
| 639 | 638 | $stat = $this->updateCache($raw['path'], $stat); |
@@ -658,10 +657,10 @@ discard block |
||
| 658 | 657 | protected function doSearch($path, $q, $mimes) { |
| 659 | 658 | $result = array(); |
| 660 | 659 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
| 661 | - $sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
| 660 | + $sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
| 662 | 661 | $res = $sth->fetchAll(PDO::FETCH_COLUMN); |
| 663 | 662 | if ($res) { |
| 664 | - foreach($res as $raw) { |
|
| 663 | + foreach ($res as $raw) { |
|
| 665 | 664 | $raw = unserialize($raw); |
| 666 | 665 | if ($stat = $this->parseRaw($raw)) { |
| 667 | 666 | if (!isset($this->cache[$raw['path']])) { |
@@ -752,10 +751,10 @@ discard block |
||
| 752 | 751 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
| 753 | 752 | |
| 754 | 753 | // copy image into tmbPath so some drivers does not store files on local fs |
| 755 | - if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
| 754 | + if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
| 756 | 755 | return false; |
| 757 | 756 | } |
| 758 | - if (! file_put_contents($tmb, $data)) { |
|
| 757 | + if (!file_put_contents($tmb, $data)) { |
|
| 759 | 758 | return false; |
| 760 | 759 | } |
| 761 | 760 | |
@@ -768,15 +767,15 @@ discard block |
||
| 768 | 767 | } |
| 769 | 768 | |
| 770 | 769 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
| 771 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
| 772 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
| 770 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
| 771 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
| 773 | 772 | |
| 774 | 773 | } else { |
| 775 | 774 | |
| 776 | 775 | if ($this->options['tmbCrop']) { |
| 777 | 776 | |
| 778 | 777 | /* Resize and crop if image bigger than thumbnail */ |
| 779 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
| 778 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
| 780 | 779 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
| 781 | 780 | } |
| 782 | 781 | |
@@ -790,7 +789,7 @@ discard block |
||
| 790 | 789 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
| 791 | 790 | } |
| 792 | 791 | |
| 793 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
| 792 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
| 794 | 793 | } |
| 795 | 794 | |
| 796 | 795 | if (!$result) { |
@@ -847,7 +846,7 @@ discard block |
||
| 847 | 846 | } |
| 848 | 847 | } |
| 849 | 848 | } |
| 850 | - if (! $url) { |
|
| 849 | + if (!$url) { |
|
| 851 | 850 | try { |
| 852 | 851 | $res = $this->dropbox->share($path, null, false); |
| 853 | 852 | $url = $res['url']; |
@@ -859,7 +858,7 @@ discard block |
||
| 859 | 858 | } |
| 860 | 859 | list($url) = explode('?', $url); |
| 861 | 860 | $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url); |
| 862 | - if (! isset($cache['share']) || $cache['share'] !== $url) { |
|
| 861 | + if (!isset($cache['share']) || $cache['share'] !== $url) { |
|
| 863 | 862 | $cache['share'] = $url; |
| 864 | 863 | $this->updateDBdat($path, $cache); |
| 865 | 864 | } |
@@ -883,12 +882,12 @@ discard block |
||
| 883 | 882 | if (function_exists('curl_exec')) { |
| 884 | 883 | |
| 885 | 884 | $c = curl_init(); |
| 886 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
|
| 887 | - curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
| 888 | - curl_setopt( $c, CURLOPT_HEADER, 1 ); |
|
| 889 | - curl_setopt( $c, CURLOPT_NOBODY, true ); |
|
| 890 | - curl_setopt( $c, CURLOPT_URL, $url ); |
|
| 891 | - $res = curl_exec( $c ); |
|
| 885 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
| 886 | + curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
| 887 | + curl_setopt($c, CURLOPT_HEADER, 1); |
|
| 888 | + curl_setopt($c, CURLOPT_NOBODY, true); |
|
| 889 | + curl_setopt($c, CURLOPT_URL, $url); |
|
| 890 | + $res = curl_exec($c); |
|
| 892 | 891 | |
| 893 | 892 | } else { |
| 894 | 893 | |
@@ -904,13 +903,13 @@ discard block |
||
| 904 | 903 | $result = $request2->send(); |
| 905 | 904 | $res = array(); |
| 906 | 905 | $res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase(); |
| 907 | - foreach($result->getHeader() as $key => $val) { |
|
| 908 | - $res[] = $key . ': ' . $val; |
|
| 906 | + foreach ($result->getHeader() as $key => $val) { |
|
| 907 | + $res[] = $key.': '.$val; |
|
| 909 | 908 | } |
| 910 | 909 | $res = join("\r\n", $res); |
| 911 | - } catch( HTTP_Request2_Exception $e ){ |
|
| 910 | + } catch (HTTP_Request2_Exception $e) { |
|
| 912 | 911 | $res = ''; |
| 913 | - } catch (Exception $e){ |
|
| 912 | + } catch (Exception $e) { |
|
| 914 | 913 | $res = ''; |
| 915 | 914 | } |
| 916 | 915 | |
@@ -963,7 +962,7 @@ discard block |
||
| 963 | 962 | **/ |
| 964 | 963 | protected function _normpath($path) { |
| 965 | 964 | $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); |
| 966 | - $path = '/' . ltrim($path, '/'); |
|
| 965 | + $path = '/'.ltrim($path, '/'); |
|
| 967 | 966 | return $path; |
| 968 | 967 | } |
| 969 | 968 | |
@@ -1102,7 +1101,7 @@ discard block |
||
| 1102 | 1101 | * @return resource|false |
| 1103 | 1102 | * @author Dmitry (dio) Levashov |
| 1104 | 1103 | **/ |
| 1105 | - protected function _fopen($path, $mode='rb') { |
|
| 1104 | + protected function _fopen($path, $mode = 'rb') { |
|
| 1106 | 1105 | |
| 1107 | 1106 | if (($mode == 'rb' || $mode == 'r')) { |
| 1108 | 1107 | try { |
@@ -1112,7 +1111,7 @@ discard block |
||
| 1112 | 1111 | fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); |
| 1113 | 1112 | fputs($fp, "Host: {$url['host']}\r\n"); |
| 1114 | 1113 | fputs($fp, "\r\n"); |
| 1115 | - while(trim(fgets($fp)) !== ''){}; |
|
| 1114 | + while (trim(fgets($fp)) !== '') {}; |
|
| 1116 | 1115 | return $fp; |
| 1117 | 1116 | } catch (Dropbox_Exception $e) { |
| 1118 | 1117 | return false; |
@@ -1143,7 +1142,7 @@ discard block |
||
| 1143 | 1142 | * @return bool |
| 1144 | 1143 | * @author Dmitry (dio) Levashov |
| 1145 | 1144 | **/ |
| 1146 | - protected function _fclose($fp, $path='') { |
|
| 1145 | + protected function _fclose($fp, $path = '') { |
|
| 1147 | 1146 | @fclose($fp); |
| 1148 | 1147 | if ($path) { |
| 1149 | 1148 | @unlink($this->getTempFile($path)); |