@@ -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 |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | if ($this->encoding) { |
| 240 | 240 | @ftp_exec($this->connect, 'OPTS UTF8 OFF'); |
| 241 | 241 | } else { |
| 242 | - @ftp_exec($this->connect, 'OPTS UTF8 ON' ); |
|
| 242 | + @ftp_exec($this->connect, 'OPTS UTF8 ON'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // switch off extended passive mode - may be usefull for some servers |
| 246 | - @ftp_exec($this->connect, 'epsv4 off' ); |
|
| 246 | + @ftp_exec($this->connect, 'epsv4 off'); |
|
| 247 | 247 | // enter passive mode if required |
| 248 | 248 | ftp_pasv($this->connect, $this->options['mode'] == 'passive'); |
| 249 | 249 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | $name = $info[8]; |
| 312 | 312 | |
| 313 | 313 | if (preg_match('|(.+)\-\>(.+)|', $name, $m)) { |
| 314 | - $name = trim($m[1]); |
|
| 314 | + $name = trim($m[1]); |
|
| 315 | 315 | // check recursive processing |
| 316 | 316 | if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) { |
| 317 | 317 | return array(); |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | $stat['owner'] = $info[2]; |
| 348 | 348 | $stat['group'] = $info[3]; |
| 349 | 349 | $stat['perm'] = substr($info[0], 1); |
| 350 | - $stat['isowner'] = $stat['owner']? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
| 350 | + $stat['isowner'] = $stat['owner'] ? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | $perm = $this->parsePermissions($info[0], $stat['owner']); |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | $info[4] = 0; |
| 380 | 380 | $info[0] = 'drwxr-xr-x'; |
| 381 | 381 | } else { |
| 382 | - $info[4] = (int)$size; |
|
| 382 | + $info[4] = (int) $size; |
|
| 383 | 383 | $info[0] = '-rw-r--r--'; |
| 384 | 384 | } |
| 385 | 385 | return $info; |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | protected function parsePermissions($perm, $user = '') { |
| 396 | 396 | $res = array(); |
| 397 | 397 | $parts = array(); |
| 398 | - $owner = $user? ($user == $this->options['user']) : $this->options['owner']; |
|
| 398 | + $owner = $user ? ($user == $this->options['user']) : $this->options['owner']; |
|
| 399 | 399 | for ($i = 0, $l = strlen($perm); $i < $l; $i++) { |
| 400 | 400 | $parts[] = substr($perm, $i, 1); |
| 401 | 401 | } |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | $list = $this->convEncOut($list); |
| 429 | - $prefix = ($path === $this->separator)? $this->separator : $path . $this->separator; |
|
| 429 | + $prefix = ($path === $this->separator) ? $this->separator : $path.$this->separator; |
|
| 430 | 430 | $targets = array(); |
| 431 | - foreach($list as $stat) { |
|
| 432 | - $p = $prefix . $stat['name']; |
|
| 431 | + foreach ($list as $stat) { |
|
| 432 | + $p = $prefix.$stat['name']; |
|
| 433 | 433 | if (isset($stat['target'])) { |
| 434 | 434 | // stat later |
| 435 | 435 | $targets[$stat['name']] = $stat['target']; |
@@ -441,10 +441,10 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | // stat link targets |
| 444 | - foreach($targets as $name => $target) { |
|
| 444 | + foreach ($targets as $name => $target) { |
|
| 445 | 445 | $stat = array(); |
| 446 | 446 | $stat['name'] = $name; |
| 447 | - $p = $prefix . $name; |
|
| 447 | + $p = $prefix.$name; |
|
| 448 | 448 | $cacheDirTarget = $this->cacheDirTarget; |
| 449 | 449 | $this->cacheDirTarget = $this->convEncIn($target, true); |
| 450 | 450 | if ($tstat = $this->stat($target)) { |
@@ -453,12 +453,12 @@ discard block |
||
| 453 | 453 | $stat['thash'] = $tstat['hash']; |
| 454 | 454 | $stat['mime'] = $tstat['mime']; |
| 455 | 455 | $stat['read'] = $tstat['read']; |
| 456 | - $stat['write'] = $tstat['write']; |
|
| 456 | + $stat['write'] = $tstat['write']; |
|
| 457 | 457 | |
| 458 | - if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
| 459 | - if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
| 460 | - if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
| 461 | - if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
| 458 | + if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
| 459 | + if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
| 460 | + if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
| 461 | + if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
| 462 | 462 | if (isset($tstat['isowner'])) { $stat['isowner'] = $tstat['isowner']; } |
| 463 | 463 | } else { |
| 464 | 464 | |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | $comps = $new_comps; |
| 572 | 572 | $path = implode($this->separator, $comps); |
| 573 | 573 | if ($initial_slashes) { |
| 574 | - $path = str_repeat($this->separator, $initial_slashes) . $path; |
|
| 574 | + $path = str_repeat($this->separator, $initial_slashes).$path; |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | return $path ? $path : '.'; |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | * @author Dmitry (dio) Levashov |
| 638 | 638 | **/ |
| 639 | 639 | protected function _inpath($path, $parent) { |
| 640 | - return $path == $parent || strpos($path, $parent. $this->separator) === 0; |
|
| 640 | + return $path == $parent || strpos($path, $parent.$this->separator) === 0; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /***************** file stat ********************/ |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | } |
| 670 | 670 | if (!$this->MLSTsupprt) { |
| 671 | 671 | //if ($path == $this->root && (empty($this->ARGS['reload']) || !isset($this->ARGS['target']) || strpos($this->ARGS['target'], $this->id) !== 0)) { |
| 672 | - if ($path == $this->root && ! $this->isMyReload()) { |
|
| 672 | + if ($path == $this->root && !$this->isMyReload()) { |
|
| 673 | 673 | return array( |
| 674 | 674 | 'name' => $this->root, |
| 675 | 675 | 'mime' => 'directory', |
@@ -677,9 +677,9 @@ discard block |
||
| 677 | 677 | ); |
| 678 | 678 | } |
| 679 | 679 | $this->cacheDir($this->convEncOut($this->_dirname($path))); |
| 680 | - return $this->convEncIn(isset($this->cache[$outPath])? $this->cache[$outPath] : array()); |
|
| 680 | + return $this->convEncIn(isset($this->cache[$outPath]) ? $this->cache[$outPath] : array()); |
|
| 681 | 681 | } |
| 682 | - $raw = ftp_raw($this->connect, 'MLST ' . $path); |
|
| 682 | + $raw = ftp_raw($this->connect, 'MLST '.$path); |
|
| 683 | 683 | if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) { |
| 684 | 684 | $parts = explode(';', trim($raw[1])); |
| 685 | 685 | array_pop($parts); |
@@ -709,8 +709,8 @@ discard block |
||
| 709 | 709 | |
| 710 | 710 | case 'perm': |
| 711 | 711 | $val = strtolower($val); |
| 712 | - $stat['read'] = (int)preg_match('/e|l|r/', $val); |
|
| 713 | - $stat['write'] = (int)preg_match('/w|m|c/', $val); |
|
| 712 | + $stat['read'] = (int) preg_match('/e|l|r/', $val); |
|
| 713 | + $stat['write'] = (int) preg_match('/w|m|c/', $val); |
|
| 714 | 714 | if (!preg_match('/f|d/', $val)) { |
| 715 | 715 | $stat['locked'] = 1; |
| 716 | 716 | } |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | if (!$this->ftpOsUnix) { |
| 796 | 796 | $info = $this->normalizeRawWindows($str); |
| 797 | 797 | } |
| 798 | - $name = isset($info[8])? trim($info[8]) : ''; |
|
| 798 | + $name = isset($info[8]) ? trim($info[8]) : ''; |
|
| 799 | 799 | if ($name && $name !== '.' && $name !== '..' && substr(strtolower($info[0]), 0, 1) === 'd') { |
| 800 | 800 | return true; |
| 801 | 801 | } |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | * @return resource|false |
| 851 | 851 | * @author Dmitry (dio) Levashov |
| 852 | 852 | **/ |
| 853 | - protected function _fopen($path, $mode='rb') { |
|
| 853 | + protected function _fopen($path, $mode = 'rb') { |
|
| 854 | 854 | // try ftp stream wrapper |
| 855 | 855 | if (ini_get('allow_url_fopen')) { |
| 856 | 856 | $url = 'ftp://'.$this->options['user'].':'.$this->options['pass'].'@'.$this->options['host'].':'.$this->options['port'].$path; |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | * @return bool |
| 888 | 888 | * @author Dmitry (dio) Levashov |
| 889 | 889 | **/ |
| 890 | - protected function _fclose($fp, $path='') { |
|
| 890 | + protected function _fclose($fp, $path = '') { |
|
| 891 | 891 | @fclose($fp); |
| 892 | 892 | if ($path) { |
| 893 | 893 | @unlink($this->getTempFile($path)); |
@@ -1062,7 +1062,7 @@ discard block |
||
| 1062 | 1062 | if (@file_put_contents($local, $content, LOCK_EX) !== false |
| 1063 | 1063 | && ($fp = @fopen($local, 'rb'))) { |
| 1064 | 1064 | clearstatcache(); |
| 1065 | - $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
| 1065 | + $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
| 1066 | 1066 | @fclose($fp); |
| 1067 | 1067 | } |
| 1068 | 1068 | file_exists($local) && @unlink($local); |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | * @return bool |
| 1088 | 1088 | **/ |
| 1089 | 1089 | protected function _chmod($path, $mode) { |
| 1090 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
| 1090 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
| 1091 | 1091 | return @ftp_chmod($this->connect, $modeOct, $path); |
| 1092 | 1092 | } |
| 1093 | 1093 | |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | $basename = $this->_basename($path); |
| 1143 | - $localPath = $dir . DIRECTORY_SEPARATOR . $basename; |
|
| 1143 | + $localPath = $dir.DIRECTORY_SEPARATOR.$basename; |
|
| 1144 | 1144 | |
| 1145 | 1145 | if (!ftp_get($this->connect, $localPath, $path, FTP_BINARY)) { |
| 1146 | 1146 | //cleanup |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | |
| 1178 | 1178 | // archive contains one item - extract in archive dir |
| 1179 | 1179 | $name = ''; |
| 1180 | - $src = $dir . DIRECTORY_SEPARATOR . $filesToProcess[0]; |
|
| 1180 | + $src = $dir.DIRECTORY_SEPARATOR.$filesToProcess[0]; |
|
| 1181 | 1181 | if (($extractTo === 'auto' || !$extractTo) && count($filesToProcess) === 1 && is_file($src)) { |
| 1182 | 1182 | $name = $filesToProcess[0]; |
| 1183 | 1183 | } else if ($extractTo === 'auto' || $extractTo) { |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | $src = $dir; |
| 1187 | 1187 | $name = basename($path); |
| 1188 | 1188 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 1189 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 1189 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | $test = $this->_joinPath(dirname($path), $name); |
| 1192 | 1192 | if ($this->stat($test)) { |
@@ -1197,7 +1197,7 @@ discard block |
||
| 1197 | 1197 | if ($name !== '' && is_file($src)) { |
| 1198 | 1198 | $result = $this->_joinPath(dirname($path), $name); |
| 1199 | 1199 | |
| 1200 | - if (! ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
| 1200 | + if (!ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
| 1201 | 1201 | $this->rmdirRecursive($dir); |
| 1202 | 1202 | return false; |
| 1203 | 1203 | } |
@@ -1211,19 +1211,19 @@ discard block |
||
| 1211 | 1211 | } |
| 1212 | 1212 | $result[] = $dstDir; |
| 1213 | 1213 | } |
| 1214 | - foreach($filesToProcess as $name) { |
|
| 1214 | + foreach ($filesToProcess as $name) { |
|
| 1215 | 1215 | $name = rtrim($name, DIRECTORY_SEPARATOR); |
| 1216 | - $src = $dir . DIRECTORY_SEPARATOR . $name; |
|
| 1216 | + $src = $dir.DIRECTORY_SEPARATOR.$name; |
|
| 1217 | 1217 | if (is_dir($src)) { |
| 1218 | 1218 | $p = dirname($name); |
| 1219 | 1219 | $name = basename($name); |
| 1220 | - if (! $target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
| 1220 | + if (!$target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
| 1221 | 1221 | $this->rmdirRecursive($dir); |
| 1222 | 1222 | return false; |
| 1223 | 1223 | } |
| 1224 | 1224 | } else { |
| 1225 | 1225 | $target = $this->_joinPath($dstDir, $name); |
| 1226 | - if (! ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
| 1226 | + if (!ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
| 1227 | 1227 | $this->rmdirRecursive($dir); |
| 1228 | 1228 | return false; |
| 1229 | 1229 | } |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | is_dir($dir) && $this->rmdirRecursive($dir); |
| 1240 | 1240 | |
| 1241 | 1241 | $this->clearcache(); |
| 1242 | - return $result? $result : false; |
|
| 1242 | + return $result ? $result : false; |
|
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | /** |
@@ -1279,7 +1279,7 @@ discard block |
||
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | //cleanup |
| 1282 | - if(!$this->rmdirRecursive($tmpDir)) { |
|
| 1282 | + if (!$this->rmdirRecursive($tmpDir)) { |
|
| 1283 | 1283 | return false; |
| 1284 | 1284 | } |
| 1285 | 1285 | |
@@ -1383,7 +1383,7 @@ discard block |
||
| 1383 | 1383 | $remoteDirLen = strlen($remote_directory); |
| 1384 | 1384 | foreach ($contents as $item) { |
| 1385 | 1385 | $relative_path = substr($item['path'], $remoteDirLen); |
| 1386 | - $local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path; |
|
| 1386 | + $local_path = $dest_local_directory.DIRECTORY_SEPARATOR.$relative_path; |
|
| 1387 | 1387 | switch ($item['type']) { |
| 1388 | 1388 | case 'd': |
| 1389 | 1389 | $success = mkdir($local_path); |
@@ -1414,8 +1414,8 @@ discard block |
||
| 1414 | 1414 | } else { |
| 1415 | 1415 | $success = true; |
| 1416 | 1416 | foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) { |
| 1417 | - $path = $dirPath . DIRECTORY_SEPARATOR . $path; |
|
| 1418 | - if(is_link($path)) { |
|
| 1417 | + $path = $dirPath.DIRECTORY_SEPARATOR.$path; |
|
| 1418 | + if (is_link($path)) { |
|
| 1419 | 1419 | unlink($path); |
| 1420 | 1420 | } else if (is_dir($path)) { |
| 1421 | 1421 | $success = rmdir($path); |
@@ -1426,11 +1426,11 @@ discard block |
||
| 1426 | 1426 | break; |
| 1427 | 1427 | } |
| 1428 | 1428 | } |
| 1429 | - if($success) { |
|
| 1429 | + if ($success) { |
|
| 1430 | 1430 | $success = rmdir($dirPath); |
| 1431 | 1431 | } |
| 1432 | 1432 | } |
| 1433 | - if(!$success) { |
|
| 1433 | + if (!$success) { |
|
| 1434 | 1434 | $this->setError(elFinder::ERROR_RM, $dirPath); |
| 1435 | 1435 | return false; |
| 1436 | 1436 | } |
@@ -1452,25 +1452,25 @@ discard block |
||
| 1452 | 1452 | if (!is_dir($dir)) { |
| 1453 | 1453 | return false; |
| 1454 | 1454 | } |
| 1455 | - $excludes = array(".",".."); |
|
| 1455 | + $excludes = array(".", ".."); |
|
| 1456 | 1456 | $result = array(); |
| 1457 | 1457 | $files = scandir($dir); |
| 1458 | - if(!$files) { |
|
| 1458 | + if (!$files) { |
|
| 1459 | 1459 | return array(); |
| 1460 | 1460 | } |
| 1461 | - foreach($files as $file) { |
|
| 1462 | - if(!in_array($file, $excludes)) { |
|
| 1461 | + foreach ($files as $file) { |
|
| 1462 | + if (!in_array($file, $excludes)) { |
|
| 1463 | 1463 | $path = $dir.DIRECTORY_SEPARATOR.$file; |
| 1464 | - if(is_link($path)) { |
|
| 1465 | - if($omitSymlinks) { |
|
| 1464 | + if (is_link($path)) { |
|
| 1465 | + if ($omitSymlinks) { |
|
| 1466 | 1466 | continue; |
| 1467 | 1467 | } else { |
| 1468 | 1468 | $result[] = $prefix.$file; |
| 1469 | 1469 | } |
| 1470 | - } else if(is_dir($path)) { |
|
| 1470 | + } else if (is_dir($path)) { |
|
| 1471 | 1471 | $result[] = $prefix.$file.DIRECTORY_SEPARATOR; |
| 1472 | 1472 | $subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix.$file.DIRECTORY_SEPARATOR); |
| 1473 | - if($subs) { |
|
| 1473 | + if ($subs) { |
|
| 1474 | 1474 | $result = array_merge($result, $subs); |
| 1475 | 1475 | } |
| 1476 | 1476 | |
@@ -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', 'tmbPath', 'tmpPath', 'quarantine') as $key) { |
|
| 56 | + foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) { |
|
| 57 | 57 | if (!empty($this->options[$key])) { |
| 58 | 58 | $this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]); |
| 59 | 59 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | // if no thumbnails url - try detect it |
| 118 | 118 | if ($root['read'] && !$this->tmbURL && $this->URL) { |
| 119 | 119 | if (strpos($this->tmbPath, $this->root) === 0) { |
| 120 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); |
|
| 120 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); |
|
| 121 | 121 | if (preg_match("|[^/?&=]$|", $this->tmbURL)) { |
| 122 | 122 | $this->tmbURL .= '/'; |
| 123 | 123 | } |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | if ($mtime != $compare) { |
| 176 | 176 | return $mtime; |
| 177 | 177 | } |
| 178 | - $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; |
|
| 178 | + $inotifywait = defined('ELFINER_INOTIFYWAIT_PATH') ? ELFINER_INOTIFYWAIT_PATH : 'inotifywait'; |
|
| 179 | 179 | $path = escapeshellarg($path); |
| 180 | 180 | $standby = max(1, intval($standby)); |
| 181 | 181 | $cmd = $inotifywait.' '.$path.' -t '.$standby.' -e moved_to,moved_from,move,create,delete,delete_self'; |
| 182 | 182 | $o = $r = ''; |
| 183 | - $this->procExec($cmd , $o, $r); |
|
| 183 | + $this->procExec($cmd, $o, $r); |
|
| 184 | 184 | if ($r === 0) { |
| 185 | 185 | // changed |
| 186 | 186 | clearstatcache(); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | // error |
| 193 | 193 | // cache to $_SESSION |
| 194 | - $sessionClose = true;; |
|
| 194 | + $sessionClose = true; ; |
|
| 195 | 195 | try { |
| 196 | 196 | $sessionStart = session_start(); |
| 197 | 197 | } catch (Exception $e) { |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @author Dmitry (dio) Levashov |
| 244 | 244 | **/ |
| 245 | 245 | protected function _joinPath($dir, $name) { |
| 246 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
| 246 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | $comps = $new_comps; |
| 296 | 296 | $path = implode('/', $comps); |
| 297 | 297 | if ($initial_slashes) { |
| 298 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
| 298 | + $path = str_repeat('/', $initial_slashes).$path; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | if ($changeSep) { |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | **/ |
| 367 | 367 | protected function _inpath($path, $parent) { |
| 368 | 368 | $cwd = getcwd(); |
| 369 | - $real_path = $this->getFullPath($path, $cwd); |
|
| 369 | + $real_path = $this->getFullPath($path, $cwd); |
|
| 370 | 370 | $real_parent = $this->getFullPath($parent, $cwd); |
| 371 | 371 | if ($real_path && $real_parent) { |
| 372 | 372 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | $stat = array(); |
| 426 | 426 | return $stat; |
| 427 | 427 | } else { |
| 428 | - $stat['mime'] = 'symlink-broken'; |
|
| 428 | + $stat['mime'] = 'symlink-broken'; |
|
| 429 | 429 | $target = readlink($path); |
| 430 | 430 | $lstat = lstat($path); |
| 431 | 431 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | $fstat = stat($path); |
| 442 | 442 | $uid = $fstat['uid']; |
| 443 | 443 | $gid = $fstat['gid']; |
| 444 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
| 444 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
| 445 | 445 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 446 | 446 | } |
| 447 | 447 | |
@@ -451,8 +451,8 @@ discard block |
||
| 451 | 451 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
| 452 | 452 | } |
| 453 | 453 | //logical rights first |
| 454 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
| 455 | - $stat['write'] = is_writable($path)? null : false; |
|
| 454 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
| 455 | + $stat['write'] = is_writable($path) ? null : false; |
|
| 456 | 456 | |
| 457 | 457 | if (is_null($stat['read'])) { |
| 458 | 458 | $stat['size'] = $dir ? 0 : $size; |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | |
| 523 | 523 | if (is_dir($path)) { |
| 524 | 524 | $path = strtr($path, array('[' => '\\[', ']' => '\\]', '*' => '\\*', '?' => '\\?')); |
| 525 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
| 525 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
| 526 | 526 | } |
| 527 | 527 | return false; |
| 528 | 528 | } |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | $br = true; |
| 604 | 604 | } else { |
| 605 | 605 | $_path = $fpath; |
| 606 | - $stat['mime'] = 'symlink-broken'; |
|
| 606 | + $stat['mime'] = 'symlink-broken'; |
|
| 607 | 607 | $target = readlink($_path); |
| 608 | 608 | $lstat = lstat($_path); |
| 609 | 609 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -628,13 +628,13 @@ discard block |
||
| 628 | 628 | if ($statOwner && !$linkreadable) { |
| 629 | 629 | $uid = $file->getOwner(); |
| 630 | 630 | $gid = $file->getGroup(); |
| 631 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
| 631 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
| 632 | 632 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | //logical rights first |
| 636 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
| 637 | - $stat['write'] = $file->isWritable()? null : false; |
|
| 636 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
| 637 | + $stat['write'] = $file->isWritable() ? null : false; |
|
| 638 | 638 | |
| 639 | 639 | if (is_null($stat['read'])) { |
| 640 | 640 | $stat['size'] = $dir ? 0 : $size; |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | if ($cache) { |
| 652 | 652 | $cache = $this->convEncOut($cache, false); |
| 653 | - foreach($cache as $d) { |
|
| 653 | + foreach ($cache as $d) { |
|
| 654 | 654 | $this->updateCache($d[0], $d[1]); |
| 655 | 655 | } |
| 656 | 656 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | * @return resource|false |
| 667 | 667 | * @author Dmitry (dio) Levashov |
| 668 | 668 | **/ |
| 669 | - protected function _fopen($path, $mode='rb') { |
|
| 669 | + protected function _fopen($path, $mode = 'rb') { |
|
| 670 | 670 | return @fopen($path, $mode); |
| 671 | 671 | } |
| 672 | 672 | |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * @return bool |
| 678 | 678 | * @author Dmitry (dio) Levashov |
| 679 | 679 | **/ |
| 680 | - protected function _fclose($fp, $path='') { |
|
| 680 | + protected function _fclose($fp, $path = '') { |
|
| 681 | 681 | return @fclose($fp); |
| 682 | 682 | } |
| 683 | 683 | |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | $path = $this->_joinPath($dir, $name); |
| 810 | 810 | |
| 811 | 811 | $meta = stream_get_meta_data($fp); |
| 812 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
| 812 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
| 813 | 813 | if ($uri && @is_file($uri)) { |
| 814 | 814 | fclose($fp); |
| 815 | 815 | $isCmdPaste = ($this->ARGS['cmd'] === 'paste'); |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | * @return bool |
| 874 | 874 | **/ |
| 875 | 875 | protected function _chmod($path, $mode) { |
| 876 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
| 876 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
| 877 | 877 | $ret = @chmod($path, $modeOct); |
| 878 | 878 | $ret && clearstatcache(); |
| 879 | 879 | return $ret; |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | $src = $dir; |
| 992 | 992 | $name = basename($path); |
| 993 | 993 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
| 994 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
| 994 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
| 995 | 995 | } |
| 996 | 996 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
| 997 | 997 | if (file_exists($test) || is_link($test)) { |
@@ -1000,9 +1000,9 @@ discard block |
||
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | if ($name !== '') { |
| 1003 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 1003 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
| 1004 | 1004 | |
| 1005 | - if (! @rename($src, $result)) { |
|
| 1005 | + if (!@rename($src, $result)) { |
|
| 1006 | 1006 | $this->delTree($dir); |
| 1007 | 1007 | return false; |
| 1008 | 1008 | } |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | $dstDir = dirname($path); |
| 1011 | 1011 | $res = false; |
| 1012 | 1012 | $result = array(); |
| 1013 | - foreach($ls as $name) { |
|
| 1013 | + foreach ($ls as $name) { |
|
| 1014 | 1014 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
| 1015 | 1015 | if (is_dir($target)) { |
| 1016 | 1016 | $this->delTree($target); |
@@ -1102,10 +1102,10 @@ discard block |
||
| 1102 | 1102 | |
| 1103 | 1103 | $path = strtr($path, $escaper); |
| 1104 | 1104 | $_q = strtr($q, $escaper); |
| 1105 | - $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
| 1106 | - $match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$_q.'*', GLOB_NOSORT); |
|
| 1105 | + $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
| 1106 | + $match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$_q.'*', GLOB_NOSORT); |
|
| 1107 | 1107 | if ($match) { |
| 1108 | - foreach($match as $p) { |
|
| 1108 | + foreach ($match as $p) { |
|
| 1109 | 1109 | $stat = $this->stat($p); |
| 1110 | 1110 | |
| 1111 | 1111 | if (!$stat) { // invalid links |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | $stat['path'] = $this->path($stat['hash']); |
| 1123 | 1123 | if ($this->URL && !isset($stat['url'])) { |
| 1124 | 1124 | $path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1)); |
| 1125 | - $stat['url'] = $this->URL . $path; |
|
| 1125 | + $stat['url'] = $this->URL.$path; |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | $result[] = $stat; |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | } |
| 1131 | 1131 | } |
| 1132 | 1132 | if ($dirs) { |
| 1133 | - foreach($dirs as $dir) { |
|
| 1133 | + foreach ($dirs as $dir) { |
|
| 1134 | 1134 | $stat = $this->stat($dir); |
| 1135 | 1135 | if ($stat['read'] && !isset($stat['alias'])) { |
| 1136 | 1136 | @set_time_limit(30); |
@@ -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 | } |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | $this->sessionCloseEarlier && $args['sessionCloseEarlier'] && session_id() && session_write_close(); |
| 551 | 551 | unset($this->sessionCloseEarlier); |
| 552 | 552 | |
| 553 | - if (substr(PHP_OS,0,3) === 'WIN') { |
|
| 553 | + if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
| 554 | 554 | // set time out |
| 555 | 555 | if (($_max_execution_time = ini_get('max_execution_time')) && $_max_execution_time < 300) { |
| 556 | 556 | @set_time_limit(300); |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | // call handlers for this command |
| 570 | 570 | if (!empty($this->listeners[$cmd])) { |
| 571 | 571 | foreach ($this->listeners[$cmd] as $handler) { |
| 572 | - if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) { |
|
| 572 | + if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) { |
|
| 573 | 573 | // handler return true to force sync client after command completed |
| 574 | 574 | $result['sync'] = true; |
| 575 | 575 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | * @return string |
| 629 | 629 | * @author Dmitry (dio) Levashov |
| 630 | 630 | **/ |
| 631 | - public function realpath($hash) { |
|
| 631 | + public function realpath($hash) { |
|
| 632 | 632 | if (($volume = $this->volume($hash)) == false) { |
| 633 | 633 | return false; |
| 634 | 634 | } |
@@ -684,11 +684,11 @@ discard block |
||
| 684 | 684 | */ |
| 685 | 685 | protected function getPluginInstance($name, $opts = array()) { |
| 686 | 686 | $key = strtolower($name); |
| 687 | - if (! isset($this->plugins[$key])) { |
|
| 688 | - $p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php'; |
|
| 687 | + if (!isset($this->plugins[$key])) { |
|
| 688 | + $p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php'; |
|
| 689 | 689 | if (is_file($p_file)) { |
| 690 | 690 | require_once $p_file; |
| 691 | - $class = 'elFinderPlugin' . $name; |
|
| 691 | + $class = 'elFinderPlugin'.$name; |
|
| 692 | 692 | $this->plugins[$key] = new $class($opts); |
| 693 | 693 | } else { |
| 694 | 694 | $this->plugins[$key] = false; |
@@ -780,8 +780,8 @@ discard block |
||
| 780 | 780 | |
| 781 | 781 | $netVolumes = $this->getNetVolumes(); |
| 782 | 782 | if ($volume->mount($options)) { |
| 783 | - if (! $key = @ $volume->netMountKey) { |
|
| 784 | - $key = md5($protocol . '-' . join('-', $options)); |
|
| 783 | + if (!$key = @ $volume->netMountKey) { |
|
| 784 | + $key = md5($protocol.'-'.join('-', $options)); |
|
| 785 | 785 | } |
| 786 | 786 | $options['driver'] = $driver; |
| 787 | 787 | $options['netkey'] = $key; |
@@ -850,14 +850,14 @@ discard block |
||
| 850 | 850 | } |
| 851 | 851 | // long polling mode |
| 852 | 852 | if ($args['compare']) { |
| 853 | - $sleep = max(1, (int)$volume->getOption('lsPlSleep')); |
|
| 854 | - $limit = max(1, (int)$volume->getOption('plStandby') / $sleep) + 1; |
|
| 853 | + $sleep = max(1, (int) $volume->getOption('lsPlSleep')); |
|
| 854 | + $limit = max(1, (int) $volume->getOption('plStandby')/$sleep) + 1; |
|
| 855 | 855 | $timelimit = ini_get('max_execution_time'); |
| 856 | 856 | $compare = $args['compare']; |
| 857 | 857 | do { |
| 858 | 858 | $timelimit && @ set_time_limit($timelimit + $sleep); |
| 859 | 859 | $_mtime = 0; |
| 860 | - foreach($ls as $_f) { |
|
| 860 | + foreach ($ls as $_f) { |
|
| 861 | 861 | $_mtime = max($_mtime, $_f['ts']); |
| 862 | 862 | } |
| 863 | 863 | $compare = strval(count($ls)).':'.strval($_mtime); |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | break; |
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | - } while($limit); |
|
| 874 | + } while ($limit); |
|
| 875 | 875 | if ($ls === false) { |
| 876 | 876 | return array('error' => $this->error(self::ERROR_OPEN, $cwd['name'], $volume->error())); |
| 877 | 877 | } |
@@ -1014,24 +1014,24 @@ discard block |
||
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | // allow change MIME type by 'file.pre' callback functions |
| 1017 | - $mime = isset($args['mime'])? $args['mime'] : $file['mime']; |
|
| 1017 | + $mime = isset($args['mime']) ? $args['mime'] : $file['mime']; |
|
| 1018 | 1018 | if ($download) { |
| 1019 | 1019 | $disp = 'attachment'; |
| 1020 | 1020 | } else { |
| 1021 | 1021 | $dispInlineRegex = $volume->getOption('dispInlineRegex'); |
| 1022 | 1022 | $inlineRegex = false; |
| 1023 | 1023 | if ($dispInlineRegex) { |
| 1024 | - $inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#'; |
|
| 1024 | + $inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#'; |
|
| 1025 | 1025 | try { |
| 1026 | 1026 | preg_match($inlineRegex, ''); |
| 1027 | - } catch(Exception $e) { |
|
| 1027 | + } catch (Exception $e) { |
|
| 1028 | 1028 | $inlineRegex = false; |
| 1029 | 1029 | } |
| 1030 | 1030 | } |
| 1031 | 1031 | if (!$inlineRegex) { |
| 1032 | 1032 | $inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#'; |
| 1033 | 1033 | } |
| 1034 | - $disp = preg_match($inlineRegex, $mime)? 'inline' : 'attachment'; |
|
| 1034 | + $disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment'; |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | $filenameEncoded = rawurlencode($file['name']); |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | $name = $args['name']; |
| 1141 | 1141 | |
| 1142 | 1142 | if (($volume = $this->volume($target)) == false |
| 1143 | - || ($rm = $volume->file($target)) == false) { |
|
| 1143 | + || ($rm = $volume->file($target)) == false) { |
|
| 1144 | 1144 | return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND)); |
| 1145 | 1145 | } |
| 1146 | 1146 | $rm['realpath'] = $volume->realpath($target); |
@@ -1218,9 +1218,9 @@ discard block |
||
| 1218 | 1218 | * @retval false error |
| 1219 | 1219 | * @author Naoki Sawada |
| 1220 | 1220 | **/ |
| 1221 | - protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) { |
|
| 1222 | - $method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; |
|
| 1223 | - return $this->$method( $url, $timeout, $redirect_max, $ua, $fp ); |
|
| 1221 | + protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) { |
|
| 1222 | + $method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; |
|
| 1223 | + return $this->$method($url, $timeout, $redirect_max, $ua, $fp); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | /** |
@@ -1236,26 +1236,26 @@ discard block |
||
| 1236 | 1236 | * @retval false error |
| 1237 | 1237 | * @author Naoki Sawada |
| 1238 | 1238 | **/ |
| 1239 | - protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){ |
|
| 1239 | + protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
| 1240 | 1240 | $ch = curl_init(); |
| 1241 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 1242 | - curl_setopt( $ch, CURLOPT_HEADER, false ); |
|
| 1241 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1242 | + curl_setopt($ch, CURLOPT_HEADER, false); |
|
| 1243 | 1243 | if ($outfp) { |
| 1244 | - curl_setopt( $ch, CURLOPT_FILE, $outfp ); |
|
| 1244 | + curl_setopt($ch, CURLOPT_FILE, $outfp); |
|
| 1245 | 1245 | } else { |
| 1246 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
| 1247 | - curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true ); |
|
| 1248 | - } |
|
| 1249 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 ); |
|
| 1250 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout ); |
|
| 1251 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); |
|
| 1252 | - curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); |
|
| 1253 | - curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
| 1254 | - curl_setopt( $ch, CURLOPT_USERAGENT, $ua); |
|
| 1255 | - $result = curl_exec( $ch ); |
|
| 1246 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 1247 | + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); |
|
| 1248 | + } |
|
| 1249 | + curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1); |
|
| 1250 | + curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout); |
|
| 1251 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 1252 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
| 1253 | + curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
| 1254 | + curl_setopt($ch, CURLOPT_USERAGENT, $ua); |
|
| 1255 | + $result = curl_exec($ch); |
|
| 1256 | 1256 | $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
| 1257 | - curl_close( $ch ); |
|
| 1258 | - return $outfp? $outfp : $result; |
|
| 1257 | + curl_close($ch); |
|
| 1258 | + return $outfp ? $outfp : $result; |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | /** |
@@ -1271,7 +1271,7 @@ discard block |
||
| 1271 | 1271 | * @retval false error |
| 1272 | 1272 | * @author Naoki Sawada |
| 1273 | 1273 | */ |
| 1274 | - protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) { |
|
| 1274 | + protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
| 1275 | 1275 | |
| 1276 | 1276 | $connect_timeout = 3; |
| 1277 | 1277 | $connect_try = 3; |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | $headers = ''; |
| 1283 | 1283 | |
| 1284 | 1284 | $arr = parse_url($url); |
| 1285 | - if (!$arr){ |
|
| 1285 | + if (!$arr) { |
|
| 1286 | 1286 | // Bad request |
| 1287 | 1287 | return false; |
| 1288 | 1288 | } |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | // query |
| 1291 | 1291 | $arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : ''; |
| 1292 | 1292 | // port |
| 1293 | - $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80); |
|
| 1293 | + $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80); |
|
| 1294 | 1294 | |
| 1295 | 1295 | $url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port']; |
| 1296 | 1296 | $url_path = isset($arr['path']) ? $arr['path'] : '/'; |
@@ -1299,21 +1299,21 @@ discard block |
||
| 1299 | 1299 | $query = $method.' '.$uri." HTTP/1.0\r\n"; |
| 1300 | 1300 | $query .= "Host: ".$arr['host']."\r\n"; |
| 1301 | 1301 | if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n"; |
| 1302 | - if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
| 1302 | + if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n"; |
|
| 1303 | 1303 | |
| 1304 | 1304 | $query .= $headers; |
| 1305 | 1305 | |
| 1306 | 1306 | $query .= "\r\n"; |
| 1307 | 1307 | |
| 1308 | 1308 | $fp = $connect_try_count = 0; |
| 1309 | - while( !$fp && $connect_try_count < $connect_try ) { |
|
| 1309 | + while (!$fp && $connect_try_count < $connect_try) { |
|
| 1310 | 1310 | |
| 1311 | 1311 | $errno = 0; |
| 1312 | 1312 | $errstr = ""; |
| 1313 | 1313 | $fp = @ fsockopen( |
| 1314 | 1314 | $arr['https'].$arr['host'], |
| 1315 | 1315 | $arr['port'], |
| 1316 | - $errno,$errstr,$connect_timeout); |
|
| 1316 | + $errno, $errstr, $connect_timeout); |
|
| 1317 | 1317 | if ($fp) break; |
| 1318 | 1318 | $connect_try_count++; |
| 1319 | 1319 | if (connection_aborted()) { |
@@ -1338,13 +1338,13 @@ discard block |
||
| 1338 | 1338 | |
| 1339 | 1339 | $_response = ''; |
| 1340 | 1340 | $header = ''; |
| 1341 | - while($_response !== "\r\n"){ |
|
| 1341 | + while ($_response !== "\r\n") { |
|
| 1342 | 1342 | $_response = fgets($fp, $readsize); |
| 1343 | 1343 | $header .= $_response; |
| 1344 | 1344 | }; |
| 1345 | 1345 | |
| 1346 | - $rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
| 1347 | - $rc = (int)$rccd[1]; |
|
| 1346 | + $rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
| 1347 | + $rc = (int) $rccd[1]; |
|
| 1348 | 1348 | |
| 1349 | 1349 | // Redirect |
| 1350 | 1350 | switch ($rc) { |
@@ -1353,19 +1353,19 @@ discard block |
||
| 1353 | 1353 | case 302: // Moved Temporarily |
| 1354 | 1354 | case 301: // Moved Permanently |
| 1355 | 1355 | $matches = array(); |
| 1356 | - if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) { |
|
| 1356 | + if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) { |
|
| 1357 | 1357 | $url = trim($matches[1]); |
| 1358 | - $hash = isset($matches[2])? trim($matches[2]) : ''; |
|
| 1359 | - if (!preg_match('/^https?:\//',$url)) { // no scheme |
|
| 1358 | + $hash = isset($matches[2]) ? trim($matches[2]) : ''; |
|
| 1359 | + if (!preg_match('/^https?:\//', $url)) { // no scheme |
|
| 1360 | 1360 | if ($url{0} != '/') { // Relative path |
| 1361 | 1361 | // to Absolute path |
| 1362 | - $url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url; |
|
| 1362 | + $url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url; |
|
| 1363 | 1363 | } |
| 1364 | 1364 | // add sheme,host |
| 1365 | 1365 | $url = $url_base.$url; |
| 1366 | 1366 | } |
| 1367 | 1367 | fclose($fp); |
| 1368 | - return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp ); |
|
| 1368 | + return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | } |
| 1371 | 1371 | |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | $outfp = fopen('php://temp', 'rwb'); |
| 1375 | 1375 | $body = true; |
| 1376 | 1376 | } |
| 1377 | - while(fwrite($outfp, fread($fp, $readsize))) { |
|
| 1377 | + while (fwrite($outfp, fread($fp, $readsize))) { |
|
| 1378 | 1378 | if ($timeout) { |
| 1379 | 1379 | $_status = socket_get_status($fp); |
| 1380 | 1380 | if ($_status['timed_out']) { |
@@ -1393,7 +1393,7 @@ discard block |
||
| 1393 | 1393 | |
| 1394 | 1394 | fclose($fp); |
| 1395 | 1395 | |
| 1396 | - return $outfp? $outfp : $body; // Data |
|
| 1396 | + return $outfp ? $outfp : $body; // Data |
|
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | 1399 | /** |
@@ -1404,13 +1404,13 @@ discard block |
||
| 1404 | 1404 | * @return array |
| 1405 | 1405 | * @author Naoki Sawada |
| 1406 | 1406 | */ |
| 1407 | - protected function parse_data_scheme( $str, $extTable ) { |
|
| 1407 | + protected function parse_data_scheme($str, $extTable) { |
|
| 1408 | 1408 | $data = $name = ''; |
| 1409 | 1409 | if ($fp = fopen('data://'.substr($str, 5), 'rb')) { |
| 1410 | 1410 | if ($data = stream_get_contents($fp)) { |
| 1411 | 1411 | $meta = stream_get_meta_data($fp); |
| 1412 | - $ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : ''; |
|
| 1413 | - $name = substr(md5($data), 0, 8) . $ext; |
|
| 1412 | + $ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : ''; |
|
| 1413 | + $name = substr(md5($data), 0, 8).$ext; |
|
| 1414 | 1414 | } |
| 1415 | 1415 | fclose($fp); |
| 1416 | 1416 | } |
@@ -1474,7 +1474,7 @@ discard block |
||
| 1474 | 1474 | } |
| 1475 | 1475 | } |
| 1476 | 1476 | |
| 1477 | - return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : ''; |
|
| 1477 | + return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : ''; |
|
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | /** |
@@ -1496,12 +1496,12 @@ discard block |
||
| 1496 | 1496 | $testDirs[] = sys_get_temp_dir(); |
| 1497 | 1497 | } |
| 1498 | 1498 | $tempDir = ''; |
| 1499 | - foreach($testDirs as $testDir) { |
|
| 1499 | + foreach ($testDirs as $testDir) { |
|
| 1500 | 1500 | if (!$testDir || !is_dir($testDir)) continue; |
| 1501 | 1501 | if (is_writable($testDir)) { |
| 1502 | 1502 | $tempDir = $testDir; |
| 1503 | 1503 | $gc = time() - 3600; |
| 1504 | - foreach(glob($tempDir . DIRECTORY_SEPARATOR .'ELF*') as $cf) { |
|
| 1504 | + foreach (glob($tempDir.DIRECTORY_SEPARATOR.'ELF*') as $cf) { |
|
| 1505 | 1505 | if (filemtime($cf) < $gc) { |
| 1506 | 1506 | @unlink($cf); |
| 1507 | 1507 | } |
@@ -1521,7 +1521,7 @@ discard block |
||
| 1521 | 1521 | **/ |
| 1522 | 1522 | protected function chmod($args) { |
| 1523 | 1523 | $targets = $args['targets']; |
| 1524 | - $mode = intval((string)$args['mode'], 8); |
|
| 1524 | + $mode = intval((string) $args['mode'], 8); |
|
| 1525 | 1525 | |
| 1526 | 1526 | if (!is_array($targets)) { |
| 1527 | 1527 | $targets = array($targets); |
@@ -1536,10 +1536,10 @@ discard block |
||
| 1536 | 1536 | |
| 1537 | 1537 | $files = array(); |
| 1538 | 1538 | $errors = array(); |
| 1539 | - foreach($targets as $target) { |
|
| 1539 | + foreach ($targets as $target) { |
|
| 1540 | 1540 | $file = $volume->chmod($target, $mode); |
| 1541 | 1541 | if ($file) { |
| 1542 | - $files = array_merge($files, is_array($file)? $file : array($file)); |
|
| 1542 | + $files = array_merge($files, is_array($file) ? $file : array($file)); |
|
| 1543 | 1543 | } else { |
| 1544 | 1544 | $errors = array_merge($errors, $volume->error()); |
| 1545 | 1545 | } |
@@ -1570,26 +1570,26 @@ discard block |
||
| 1570 | 1570 | private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) { |
| 1571 | 1571 | if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) { |
| 1572 | 1572 | $fname = $m[1]; |
| 1573 | - $encname = md5($cid . '_' . $fname); |
|
| 1574 | - $base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname; |
|
| 1573 | + $encname = md5($cid.'_'.$fname); |
|
| 1574 | + $base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname; |
|
| 1575 | 1575 | $clast = intval($m[3]); |
| 1576 | 1576 | if (is_null($tmpname)) { |
| 1577 | 1577 | ignore_user_abort(true); |
| 1578 | 1578 | sleep(10); // wait 10 sec |
| 1579 | 1579 | // chunked file upload fail |
| 1580 | - foreach(glob($base . '*') as $cf) { |
|
| 1580 | + foreach (glob($base.'*') as $cf) { |
|
| 1581 | 1581 | @unlink($cf); |
| 1582 | 1582 | } |
| 1583 | 1583 | ignore_user_abort(false); |
| 1584 | 1584 | return; |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | - $range = isset($_POST['range'])? trim($_POST['range']) : ''; |
|
| 1587 | + $range = isset($_POST['range']) ? trim($_POST['range']) : ''; |
|
| 1588 | 1588 | if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) { |
| 1589 | 1589 | $start = $ranges[1]; |
| 1590 | 1590 | $len = $ranges[2]; |
| 1591 | 1591 | $size = $ranges[3]; |
| 1592 | - $tmp = $base . '.part'; |
|
| 1592 | + $tmp = $base.'.part'; |
|
| 1593 | 1593 | $csize = filesize($tmpname); |
| 1594 | 1594 | |
| 1595 | 1595 | $tmpExists = is_file($tmp); |
@@ -1615,7 +1615,7 @@ discard block |
||
| 1615 | 1615 | } else { |
| 1616 | 1616 | // wait until makeing temp file (for anothor session) |
| 1617 | 1617 | $cnt = 1200; // Time limit 120 sec |
| 1618 | - while(!is_file($base) && --$cnt) { |
|
| 1618 | + while (!is_file($base) && --$cnt) { |
|
| 1619 | 1619 | usleep(100000); // wait 100ms |
| 1620 | 1620 | } |
| 1621 | 1621 | if (!$cnt) { |
@@ -1650,13 +1650,13 @@ discard block |
||
| 1650 | 1650 | } |
| 1651 | 1651 | } else { |
| 1652 | 1652 | // old way |
| 1653 | - $part = $base . $m[2]; |
|
| 1653 | + $part = $base.$m[2]; |
|
| 1654 | 1654 | if (move_uploaded_file($tmpname, $part)) { |
| 1655 | 1655 | @chmod($part, 0600); |
| 1656 | - if ($clast < count(glob($base . '*'))) { |
|
| 1656 | + if ($clast < count(glob($base.'*'))) { |
|
| 1657 | 1657 | $parts = array(); |
| 1658 | 1658 | for ($i = 0; $i <= $clast; $i++) { |
| 1659 | - $name = $base . '.' . $i . '_' . $clast; |
|
| 1659 | + $name = $base.'.'.$i.'_'.$clast; |
|
| 1660 | 1660 | if (is_readable($name)) { |
| 1661 | 1661 | $parts[] = $name; |
| 1662 | 1662 | } else { |
@@ -1669,7 +1669,7 @@ discard block |
||
| 1669 | 1669 | touch($base); |
| 1670 | 1670 | if ($resfile = tempnam($tempDir, 'ELF')) { |
| 1671 | 1671 | $target = fopen($resfile, 'wb'); |
| 1672 | - foreach($parts as $f) { |
|
| 1672 | + foreach ($parts as $f) { |
|
| 1673 | 1673 | $fp = fopen($f, 'rb'); |
| 1674 | 1674 | while (!feof($fp)) { |
| 1675 | 1675 | fwrite($target, fread($fp, 8192)); |
@@ -1705,15 +1705,15 @@ discard block |
||
| 1705 | 1705 | $files = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array(); |
| 1706 | 1706 | $header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8'); |
| 1707 | 1707 | $result = array_merge(array('added' => array()), $header); |
| 1708 | - $paths = $args['upload_path']? $args['upload_path'] : array(); |
|
| 1709 | - $chunk = $args['chunk']? $args['chunk'] : ''; |
|
| 1710 | - $cid = $args['cid']? (int)$args['cid'] : ''; |
|
| 1708 | + $paths = $args['upload_path'] ? $args['upload_path'] : array(); |
|
| 1709 | + $chunk = $args['chunk'] ? $args['chunk'] : ''; |
|
| 1710 | + $cid = $args['cid'] ? (int) $args['cid'] : ''; |
|
| 1711 | 1711 | |
| 1712 | - $renames= array(); |
|
| 1712 | + $renames = array(); |
|
| 1713 | 1713 | $suffix = '~'; |
| 1714 | 1714 | if ($args['renames'] && is_array($args['renames'])) { |
| 1715 | 1715 | $renames = array_flip($args['renames']); |
| 1716 | - if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) { |
|
| 1716 | + if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) { |
|
| 1717 | 1717 | $suffix = $args['suffix']; |
| 1718 | 1718 | } |
| 1719 | 1719 | } |
@@ -1746,7 +1746,7 @@ discard block |
||
| 1746 | 1746 | if (!$args['upload'] && $args['name'] && is_array($args['name'])) { |
| 1747 | 1747 | $error = ''; |
| 1748 | 1748 | $result['name'] = array(); |
| 1749 | - foreach($args['name'] as $_i => $_name) { |
|
| 1749 | + foreach ($args['name'] as $_i => $_name) { |
|
| 1750 | 1750 | if (!$volume->isUploadableByName($_name)) { |
| 1751 | 1751 | $error = $this->error(self::ERROR_UPLOAD_FILE, $_name, self::ERROR_UPLOAD_FILE_MIME); |
| 1752 | 1752 | break; |
@@ -1767,7 +1767,7 @@ discard block |
||
| 1767 | 1767 | } |
| 1768 | 1768 | if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) { |
| 1769 | 1769 | $names = array(); |
| 1770 | - foreach($args['upload'] as $i => $url) { |
|
| 1770 | + foreach ($args['upload'] as $i => $url) { |
|
| 1771 | 1771 | // check chunked file upload commit |
| 1772 | 1772 | if ($args['chunk']) { |
| 1773 | 1773 | if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') { |
@@ -1777,7 +1777,7 @@ discard block |
||
| 1777 | 1777 | } |
| 1778 | 1778 | return $result; |
| 1779 | 1779 | } else { |
| 1780 | - $tmpfname = $tempDir . '/' . $args['chunk']; |
|
| 1780 | + $tmpfname = $tempDir.'/'.$args['chunk']; |
|
| 1781 | 1781 | $files['tmp_name'][$i] = $tmpfname; |
| 1782 | 1782 | $files['name'][$i] = $url; |
| 1783 | 1783 | $files['error'][$i] = 0; |
@@ -1786,7 +1786,7 @@ discard block |
||
| 1786 | 1786 | } |
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | - $tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true)); |
|
| 1789 | + $tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true)); |
|
| 1790 | 1790 | |
| 1791 | 1791 | $_name = ''; |
| 1792 | 1792 | // check is data: |
@@ -1822,8 +1822,8 @@ discard block |
||
| 1822 | 1822 | list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, ''); |
| 1823 | 1823 | if ($_b === '') { |
| 1824 | 1824 | if ($_ext) { |
| 1825 | - rename($tmpfname, $tmpfname . $_ext); |
|
| 1826 | - $tmpfname = $tmpfname . $_ext; |
|
| 1825 | + rename($tmpfname, $tmpfname.$_ext); |
|
| 1826 | + $tmpfname = $tmpfname.$_ext; |
|
| 1827 | 1827 | } |
| 1828 | 1828 | $_b = $this->detectFileExtension($tmpfname); |
| 1829 | 1829 | $_name = $_a.$_b; |
@@ -1858,7 +1858,7 @@ discard block |
||
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | 1860 | $tmpname = $files['tmp_name'][$i]; |
| 1861 | - $path = ($paths && !empty($paths[$i]))? $paths[$i] : ''; |
|
| 1861 | + $path = ($paths && !empty($paths[$i])) ? $paths[$i] : ''; |
|
| 1862 | 1862 | if ($name === 'blob') { |
| 1863 | 1863 | if ($chunk) { |
| 1864 | 1864 | if ($tempDir = $this->getTempDir($volume->getTempPath())) { |
@@ -1868,7 +1868,7 @@ discard block |
||
| 1868 | 1868 | preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m); |
| 1869 | 1869 | $result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname); |
| 1870 | 1870 | $result['_chunkfailure'] = true; |
| 1871 | - $this->uploadDebug = 'Upload error: ' . $tmpname; |
|
| 1871 | + $this->uploadDebug = 'Upload error: '.$tmpname; |
|
| 1872 | 1872 | } else if ($name) { |
| 1873 | 1873 | $result['_chunkmerged'] = basename($tmpname); |
| 1874 | 1874 | $result['_name'] = $name; |
@@ -1882,14 +1882,14 @@ discard block |
||
| 1882 | 1882 | } else { |
| 1883 | 1883 | // for form clipboard with Google Chrome |
| 1884 | 1884 | $type = $files['type'][$i]; |
| 1885 | - $ext = isset($extTable[$type])? '.' . $extTable[$type] : ''; |
|
| 1886 | - $name = substr(md5(basename($tmpname)), 0, 8) . $ext; |
|
| 1885 | + $ext = isset($extTable[$type]) ? '.'.$extTable[$type] : ''; |
|
| 1886 | + $name = substr(md5(basename($tmpname)), 0, 8).$ext; |
|
| 1887 | 1887 | } |
| 1888 | 1888 | } |
| 1889 | 1889 | |
| 1890 | 1890 | // do hook function 'upload.presave' |
| 1891 | - if (! empty($this->listeners['upload.presave'])) { |
|
| 1892 | - foreach($this->listeners['upload.presave'] as $handler) { |
|
| 1891 | + if (!empty($this->listeners['upload.presave'])) { |
|
| 1892 | + foreach ($this->listeners['upload.presave'] as $handler) { |
|
| 1893 | 1893 | call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume)); |
| 1894 | 1894 | } |
| 1895 | 1895 | } |
@@ -1897,7 +1897,7 @@ discard block |
||
| 1897 | 1897 | if (($fp = fopen($tmpname, 'rb')) == false) { |
| 1898 | 1898 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER); |
| 1899 | 1899 | $this->uploadDebug = 'Upload error: unable open tmp file'; |
| 1900 | - if (! is_uploaded_file($tmpname)) { |
|
| 1900 | + if (!is_uploaded_file($tmpname)) { |
|
| 1901 | 1901 | if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
| 1902 | 1902 | continue; |
| 1903 | 1903 | } |
@@ -1919,18 +1919,18 @@ discard block |
||
| 1919 | 1919 | } |
| 1920 | 1920 | } |
| 1921 | 1921 | } |
| 1922 | - if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
| 1922 | + if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
| 1923 | 1923 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error()); |
| 1924 | 1924 | fclose($fp); |
| 1925 | - if (! is_uploaded_file($tmpname)) { |
|
| 1926 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);; |
|
| 1925 | + if (!is_uploaded_file($tmpname)) { |
|
| 1926 | + if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ; |
|
| 1927 | 1927 | continue; |
| 1928 | 1928 | } |
| 1929 | 1929 | break; |
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | 1932 | is_resource($fp) && fclose($fp); |
| 1933 | - if (! is_uploaded_file($tmpname)){ |
|
| 1933 | + if (!is_uploaded_file($tmpname)) { |
|
| 1934 | 1934 | clearstatcache(); |
| 1935 | 1935 | if (!is_file($tmpname) || @ unlink($tmpname)) { |
| 1936 | 1936 | unset($GLOBALS['elFinderTempFiles'][$tmpname]); |
@@ -1942,7 +1942,7 @@ discard block |
||
| 1942 | 1942 | } |
| 1943 | 1943 | } |
| 1944 | 1944 | if ($GLOBALS['elFinderTempFiles']) { |
| 1945 | - foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
| 1945 | + foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
| 1946 | 1946 | @ unlink($_temp); |
| 1947 | 1947 | } |
| 1948 | 1948 | } |
@@ -1979,7 +1979,7 @@ discard block |
||
| 1979 | 1979 | $suffix = '~'; |
| 1980 | 1980 | if (!empty($args['renames'])) { |
| 1981 | 1981 | $renames = array_flip($args['renames']); |
| 1982 | - if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
| 1982 | + if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
| 1983 | 1983 | $suffix = $args['suffix']; |
| 1984 | 1984 | } |
| 1985 | 1985 | } |
@@ -2037,9 +2037,9 @@ discard block |
||
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) { |
| 2040 | - $mime = isset($file['mime'])? $file['mime'] : ''; |
|
| 2040 | + $mime = isset($file['mime']) ? $file['mime'] : ''; |
|
| 2041 | 2041 | if ($mime && strtolower(substr($mime, 0, 4)) === 'text') { |
| 2042 | - if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) { |
|
| 2042 | + if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) { |
|
| 2043 | 2043 | if (strtolower($enc) !== 'utf-8') { |
| 2044 | 2044 | $content = mb_convert_encoding($content, 'UTF-8', $enc); |
| 2045 | 2045 | } |
@@ -2051,7 +2051,7 @@ discard block |
||
| 2051 | 2051 | |
| 2052 | 2052 | if ($json === false || strlen($json) < strlen($content)) { |
| 2053 | 2053 | if ($args['conv']) { |
| 2054 | - return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
| 2054 | + return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
| 2055 | 2055 | } else { |
| 2056 | 2056 | return array('doconv' => true); |
| 2057 | 2057 | } |
@@ -2093,7 +2093,7 @@ discard block |
||
| 2093 | 2093 | $target = $args['target']; |
| 2094 | 2094 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
| 2095 | 2095 | $error = array(self::ERROR_EXTRACT, '#'.$target); |
| 2096 | - $makedir = isset($args['makedir'])? (bool)$args['makedir'] : null; |
|
| 2096 | + $makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null; |
|
| 2097 | 2097 | |
| 2098 | 2098 | if (($volume = $this->volume($target)) == false |
| 2099 | 2099 | || ($file = $volume->file($target)) == false) { |
@@ -2101,7 +2101,7 @@ discard block |
||
| 2101 | 2101 | } |
| 2102 | 2102 | |
| 2103 | 2103 | return ($file = $volume->extract($target, $makedir)) |
| 2104 | - ? array('added' => isset($file['read'])? array($file) : $file) |
|
| 2104 | + ? array('added' => isset($file['read']) ? array($file) : $file) |
|
| 2105 | 2105 | : array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error())); |
| 2106 | 2106 | } |
| 2107 | 2107 | |
@@ -2116,7 +2116,7 @@ discard block |
||
| 2116 | 2116 | protected function archive($args) { |
| 2117 | 2117 | $type = $args['type']; |
| 2118 | 2118 | $targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array(); |
| 2119 | - $name = isset($args['name'])? $args['name'] : ''; |
|
| 2119 | + $name = isset($args['name']) ? $args['name'] : ''; |
|
| 2120 | 2120 | |
| 2121 | 2121 | if (($volume = $this->volume($targets[0])) == false) { |
| 2122 | 2122 | return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND); |
@@ -2137,7 +2137,7 @@ discard block |
||
| 2137 | 2137 | protected function search($args) { |
| 2138 | 2138 | $q = trim($args['q']); |
| 2139 | 2139 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
| 2140 | - $target = !empty($args['target'])? $args['target'] : null; |
|
| 2140 | + $target = !empty($args['target']) ? $args['target'] : null; |
|
| 2141 | 2141 | $result = array(); |
| 2142 | 2142 | |
| 2143 | 2143 | if (!is_null($target)) { |
@@ -2168,7 +2168,7 @@ discard block |
||
| 2168 | 2168 | $compare = intval($args['compare']); |
| 2169 | 2169 | $hash = $args['targets'][0]; |
| 2170 | 2170 | if ($volume = $this->volume($hash)) { |
| 2171 | - $standby = (int)$volume->getOption('plStandby'); |
|
| 2171 | + $standby = (int) $volume->getOption('plStandby'); |
|
| 2172 | 2172 | $_compare = false; |
| 2173 | 2173 | if (($syncCheckFunc = $volume->getOption('syncCheckFunc')) && is_callable($syncCheckFunc)) { |
| 2174 | 2174 | $_compare = call_user_func_array($syncCheckFunc, array($volume->realpath($hash), $standby, $compare, $volume, $this)); |
@@ -2176,8 +2176,8 @@ discard block |
||
| 2176 | 2176 | if ($_compare !== false) { |
| 2177 | 2177 | $compare = $_compare; |
| 2178 | 2178 | } else { |
| 2179 | - $sleep = max(1, (int)$volume->getOption('tsPlSleep')); |
|
| 2180 | - $limit = max(1, $standby / $sleep) + 1; |
|
| 2179 | + $sleep = max(1, (int) $volume->getOption('tsPlSleep')); |
|
| 2180 | + $limit = max(1, $standby/$sleep) + 1; |
|
| 2181 | 2181 | $timelimit = ini_get('max_execution_time'); |
| 2182 | 2182 | do { |
| 2183 | 2183 | $timelimit && @ set_time_limit($timelimit + $sleep); |
@@ -2194,7 +2194,7 @@ discard block |
||
| 2194 | 2194 | if (--$limit) { |
| 2195 | 2195 | sleep($sleep); |
| 2196 | 2196 | } |
| 2197 | - } while($limit); |
|
| 2197 | + } while ($limit); |
|
| 2198 | 2198 | } |
| 2199 | 2199 | } |
| 2200 | 2200 | } else { |
@@ -2242,12 +2242,12 @@ discard block |
||
| 2242 | 2242 | $target = $args['target']; |
| 2243 | 2243 | $width = $args['width']; |
| 2244 | 2244 | $height = $args['height']; |
| 2245 | - $x = (int)$args['x']; |
|
| 2246 | - $y = (int)$args['y']; |
|
| 2245 | + $x = (int) $args['x']; |
|
| 2246 | + $y = (int) $args['y']; |
|
| 2247 | 2247 | $mode = $args['mode']; |
| 2248 | 2248 | $bg = null; |
| 2249 | - $degree = (int)$args['degree']; |
|
| 2250 | - $quality= (int)$args['quality']; |
|
| 2249 | + $degree = (int) $args['degree']; |
|
| 2250 | + $quality = (int) $args['quality']; |
|
| 2251 | 2251 | |
| 2252 | 2252 | if (($volume = $this->volume($target)) == false |
| 2253 | 2253 | || ($file = $volume->file($target)) == false) { |
@@ -2268,7 +2268,7 @@ discard block |
||
| 2268 | 2268 | **/ |
| 2269 | 2269 | protected function url($args) { |
| 2270 | 2270 | $target = $args['target']; |
| 2271 | - $options = isset($args['options'])? $args['options'] : array(); |
|
| 2271 | + $options = isset($args['options']) ? $args['options'] : array(); |
|
| 2272 | 2272 | if (($volume = $this->volume($target)) != false) { |
| 2273 | 2273 | $url = $volume->getContentUrl($target, $options); |
| 2274 | 2274 | return $url ? array('url' => $url) : array(); |
@@ -2285,18 +2285,18 @@ discard block |
||
| 2285 | 2285 | */ |
| 2286 | 2286 | protected function callback($args) { |
| 2287 | 2287 | $checkReg = '/[^a-zA-Z0-9;._-]/'; |
| 2288 | - $node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : ''; |
|
| 2289 | - $json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}'; |
|
| 2290 | - $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : ''; |
|
| 2288 | + $node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : ''; |
|
| 2289 | + $json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}'; |
|
| 2290 | + $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : ''; |
|
| 2291 | 2291 | $done = (!empty($args['done'])); |
| 2292 | 2292 | |
| 2293 | - while( ob_get_level() ) { |
|
| 2294 | - if (! ob_end_clean()) { |
|
| 2293 | + while (ob_get_level()) { |
|
| 2294 | + if (!ob_end_clean()) { |
|
| 2295 | 2295 | break; |
| 2296 | 2296 | } |
| 2297 | 2297 | } |
| 2298 | 2298 | |
| 2299 | - if ($done || ! $this->callbackWindowURL) { |
|
| 2299 | + if ($done || !$this->callbackWindowURL) { |
|
| 2300 | 2300 | $script = ''; |
| 2301 | 2301 | if ($node) { |
| 2302 | 2302 | $script .= ' |
@@ -2338,13 +2338,13 @@ discard block |
||
| 2338 | 2338 | |
| 2339 | 2339 | } else { |
| 2340 | 2340 | $url = $this->callbackWindowURL; |
| 2341 | - $url .= ((strpos($url, '?') === false)? '?' : '&') |
|
| 2342 | - . '&node=' . rawurlencode($node) |
|
| 2343 | - . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '') |
|
| 2344 | - . ($bind? ('&bind=' . rawurlencode($bind)) : '') |
|
| 2341 | + $url .= ((strpos($url, '?') === false) ? '?' : '&') |
|
| 2342 | + . '&node='.rawurlencode($node) |
|
| 2343 | + . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '') |
|
| 2344 | + . ($bind ? ('&bind='.rawurlencode($bind)) : '') |
|
| 2345 | 2345 | . '&done=1'; |
| 2346 | 2346 | |
| 2347 | - header('Location: ' . $url); |
|
| 2347 | + header('Location: '.$url); |
|
| 2348 | 2348 | |
| 2349 | 2349 | } |
| 2350 | 2350 | exit(); |
@@ -2414,7 +2414,7 @@ discard block |
||
| 2414 | 2414 | |
| 2415 | 2415 | protected function utime() { |
| 2416 | 2416 | $time = explode(" ", microtime()); |
| 2417 | - return (double)$time[1] + (double)$time[0]; |
|
| 2417 | + return (double) $time[1] + (double) $time[0]; |
|
| 2418 | 2418 | } |
| 2419 | 2419 | |
| 2420 | 2420 | |
@@ -2440,7 +2440,7 @@ discard block |
||
| 2440 | 2440 | $imgcnt = 0; |
| 2441 | 2441 | $fp = fopen($path, 'rb'); |
| 2442 | 2442 | @fread($fp, 4); |
| 2443 | - $c = @fread($fp,1); |
|
| 2443 | + $c = @fread($fp, 1); |
|
| 2444 | 2444 | if (ord($c) != 0x39) { // GIF89a |
| 2445 | 2445 | return false; |
| 2446 | 2446 | } |
@@ -2448,13 +2448,13 @@ discard block |
||
| 2448 | 2448 | while (!feof($fp)) { |
| 2449 | 2449 | do { |
| 2450 | 2450 | $c = fread($fp, 1); |
| 2451 | - } while(ord($c) != 0x21 && !feof($fp)); |
|
| 2451 | + } while (ord($c) != 0x21 && !feof($fp)); |
|
| 2452 | 2452 | |
| 2453 | 2453 | if (feof($fp)) { |
| 2454 | 2454 | break; |
| 2455 | 2455 | } |
| 2456 | 2456 | |
| 2457 | - $c2 = fread($fp,2); |
|
| 2457 | + $c2 = fread($fp, 2); |
|
| 2458 | 2458 | if (bin2hex($c2) == "f904") { |
| 2459 | 2459 | $imgcnt++; |
| 2460 | 2460 | } |