@@ -1344,7 +1344,7 @@ |
||
1344 | 1344 | * |
1345 | 1345 | * @param string $str |
1346 | 1346 | * @param array $extTable |
1347 | - * @return array |
|
1347 | + * @return string[] |
|
1348 | 1348 | * @author Naoki Sawada |
1349 | 1349 | */ |
1350 | 1350 | protected function parse_data_scheme( $str, $extTable ) { |
@@ -1149,18 +1149,18 @@ discard block |
||
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | /** |
1152 | - * Get remote contents |
|
1153 | - * |
|
1154 | - * @param string $url target url |
|
1155 | - * @param int $timeout timeout (sec) |
|
1156 | - * @param int $redirect_max redirect max count |
|
1157 | - * @param string $ua |
|
1158 | - * @param resource $fp |
|
1159 | - * @return string or bool(false) |
|
1160 | - * @retval string contents |
|
1161 | - * @retval false error |
|
1162 | - * @author Naoki Sawada |
|
1163 | - **/ |
|
1152 | + * Get remote contents |
|
1153 | + * |
|
1154 | + * @param string $url target url |
|
1155 | + * @param int $timeout timeout (sec) |
|
1156 | + * @param int $redirect_max redirect max count |
|
1157 | + * @param string $ua |
|
1158 | + * @param resource $fp |
|
1159 | + * @return string or bool(false) |
|
1160 | + * @retval string contents |
|
1161 | + * @retval false error |
|
1162 | + * @author Naoki Sawada |
|
1163 | + **/ |
|
1164 | 1164 | protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) { |
1165 | 1165 | $method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; |
1166 | 1166 | return $this->$method( $url, $timeout, $redirect_max, $ua, $fp ); |
@@ -2090,12 +2090,12 @@ discard block |
||
2090 | 2090 | } |
2091 | 2091 | |
2092 | 2092 | /** |
2093 | - * Return content URL |
|
2094 | - * |
|
2095 | - * @param array $args command arguments |
|
2096 | - * @return array |
|
2097 | - * @author Naoki Sawada |
|
2098 | - **/ |
|
2093 | + * Return content URL |
|
2094 | + * |
|
2095 | + * @param array $args command arguments |
|
2096 | + * @return array |
|
2097 | + * @author Naoki Sawada |
|
2098 | + **/ |
|
2099 | 2099 | protected function url($args) { |
2100 | 2100 | $target = $args['target']; |
2101 | 2101 | $options = isset($args['options'])? $args['options'] : array(); |
@@ -1241,8 +1241,12 @@ discard block |
||
1241 | 1241 | |
1242 | 1242 | $query = $method.' '.$uri." HTTP/1.0\r\n"; |
1243 | 1243 | $query .= "Host: ".$arr['host']."\r\n"; |
1244 | - if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n"; |
|
1245 | - if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1244 | + if (!empty($ua)) { |
|
1245 | + $query .= "User-Agent: ".$ua."\r\n"; |
|
1246 | + } |
|
1247 | + if (!is_null($getSize)) { |
|
1248 | + $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1249 | + } |
|
1246 | 1250 | |
1247 | 1251 | $query .= $headers; |
1248 | 1252 | |
@@ -1257,7 +1261,9 @@ discard block |
||
1257 | 1261 | $arr['https'].$arr['host'], |
1258 | 1262 | $arr['port'], |
1259 | 1263 | $errno,$errstr,$connect_timeout); |
1260 | - if ($fp) break; |
|
1264 | + if ($fp) { |
|
1265 | + break; |
|
1266 | + } |
|
1261 | 1267 | $connect_try_count++; |
1262 | 1268 | if (connection_aborted()) { |
1263 | 1269 | exit(); |
@@ -1574,7 +1580,9 @@ discard block |
||
1574 | 1580 | $tempDir = ''; |
1575 | 1581 | $test = DIRECTORY_SEPARATOR . microtime(true); |
1576 | 1582 | foreach($testDirs as $testDir) { |
1577 | - if (!$testDir || !is_dir($testDir)) continue; |
|
1583 | + if (!$testDir || !is_dir($testDir)) { |
|
1584 | + continue; |
|
1585 | + } |
|
1578 | 1586 | $testFile = $testDir.$test; |
1579 | 1587 | if (touch($testFile)) { |
1580 | 1588 | unlink($testFile); |
@@ -1810,7 +1818,9 @@ discard block |
||
1810 | 1818 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER); |
1811 | 1819 | $this->uploadDebug = 'Upload error: unable open tmp file'; |
1812 | 1820 | if (! is_uploaded_file($tmpname)) { |
1813 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
|
1821 | + if (@ unlink($tmpname)) { |
|
1822 | + unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
|
1823 | + } |
|
1814 | 1824 | continue; |
1815 | 1825 | } |
1816 | 1826 | break; |
@@ -1824,7 +1834,10 @@ discard block |
||
1824 | 1834 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error()); |
1825 | 1835 | fclose($fp); |
1826 | 1836 | if (! is_uploaded_file($tmpname)) { |
1827 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);; |
|
1837 | + if (@ unlink($tmpname)) { |
|
1838 | + unset($GLOBALS['elFinderTempFiles'][$tmpname]); |
|
1839 | + } |
|
1840 | + ; |
|
1828 | 1841 | continue; |
1829 | 1842 | } |
1830 | 1843 | break; |
@@ -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); |
|
853 | + $sleep = max(1, (int) $volume->getOption('lsPlSleep')); |
|
854 | + $limit = max(1, (int) $volume->getOption('plStandby')/$sleep); |
|
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 | } |
@@ -234,7 +234,6 @@ discard block |
||
234 | 234 | * process of on netunmount |
235 | 235 | * Drop table `dropbox` & rm thumbs |
236 | 236 | * |
237 | - * @param array $options |
|
238 | 237 | * @return boolean |
239 | 238 | */ |
240 | 239 | public function netunmount($netVolumes, $key) { |
@@ -431,7 +430,7 @@ discard block |
||
431 | 430 | /** |
432 | 431 | * Check DB for delta cache |
433 | 432 | * |
434 | - * @return void |
|
433 | + * @return boolean |
|
435 | 434 | */ |
436 | 435 | private function checkDB() { |
437 | 436 | $res = $this->query('SELECT * FROM sqlite_master WHERE type=\'table\' AND name=\''.$this->DB_TableName.'\''); |
@@ -685,7 +684,7 @@ discard block |
||
685 | 684 | * @param string $src source path |
686 | 685 | * @param string $dst destination dir path |
687 | 686 | * @param string $name new file name (optionaly) |
688 | - * @return string|false |
|
687 | + * @return string|boolean |
|
689 | 688 | * @author Dmitry (dio) Levashov |
690 | 689 | * @author Naoki Sawada |
691 | 690 | **/ |
@@ -739,10 +738,6 @@ discard block |
||
739 | 738 | * Create thumnbnail and return it's URL on success |
740 | 739 | * |
741 | 740 | * @param string $path file path |
742 | - * @param string $mime file mime type |
|
743 | - * @return string|false |
|
744 | - * @author Dmitry (dio) Levashov |
|
745 | - * @author Naoki Sawada |
|
746 | 741 | **/ |
747 | 742 | protected function createTmb($path, $stat) { |
748 | 743 | if (!$stat || !$this->canCreateTmb($path, $stat)) { |
@@ -1099,7 +1094,6 @@ discard block |
||
1099 | 1094 | * Open file and return file pointer |
1100 | 1095 | * |
1101 | 1096 | * @param string $path file path |
1102 | - * @param bool $write open file for writing |
|
1103 | 1097 | * @return resource|false |
1104 | 1098 | * @author Dmitry (dio) Levashov |
1105 | 1099 | **/ |
@@ -1141,7 +1135,7 @@ discard block |
||
1141 | 1135 | * Close opened file |
1142 | 1136 | * |
1143 | 1137 | * @param resource $fp file pointer |
1144 | - * @return bool |
|
1138 | + * @return boolean|null |
|
1145 | 1139 | * @author Dmitry (dio) Levashov |
1146 | 1140 | **/ |
1147 | 1141 | protected function _fclose($fp, $path='') { |
@@ -1225,7 +1219,7 @@ discard block |
||
1225 | 1219 | * Return new file path or false. |
1226 | 1220 | * |
1227 | 1221 | * @param string $source source file path |
1228 | - * @param string $target target dir path |
|
1222 | + * @param string $targetDir target dir path |
|
1229 | 1223 | * @param string $name file name |
1230 | 1224 | * @return string|bool |
1231 | 1225 | * @author Dmitry (dio) Levashov |
@@ -1274,7 +1268,6 @@ discard block |
||
1274 | 1268 | * Return new file path or false on error. |
1275 | 1269 | * |
1276 | 1270 | * @param resource $fp file pointer |
1277 | - * @param string $dir target dir path |
|
1278 | 1271 | * @param string $name file name |
1279 | 1272 | * @param array $stat file stat (required by some virtual fs) |
1280 | 1273 | * @return bool|string |
@@ -1320,7 +1313,7 @@ discard block |
||
1320 | 1313 | * |
1321 | 1314 | * @param string $path file path |
1322 | 1315 | * @param string $content new file content |
1323 | - * @return bool |
|
1316 | + * @return boolean|string |
|
1324 | 1317 | * @author Dmitry (dio) Levashov |
1325 | 1318 | **/ |
1326 | 1319 | protected function _filePutContents($path, $content) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $options['url'] = $this->getConnectorUrl(); |
193 | 193 | } |
194 | 194 | $callback = $options['url'] |
195 | - . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
|
195 | + . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
|
196 | 196 | |
197 | 197 | try { |
198 | 198 | $tokens = $this->oauth->getRequestToken(); |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | */ |
266 | 266 | private function getConnectorUrl() { |
267 | 267 | $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
268 | - . $_SERVER['SERVER_NAME'] // host |
|
269 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
270 | - . $_SERVER['REQUEST_URI']; // path & query |
|
268 | + . $_SERVER['SERVER_NAME'] // host |
|
269 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
270 | + . $_SERVER['REQUEST_URI']; // path & query |
|
271 | 271 | list($url) = explode('?', $url); |
272 | 272 | return $url; |
273 | 273 | } |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
606 | 606 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
607 | 607 | $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
608 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
608 | + (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
609 | 609 | $stat['dirs'] = 0; |
610 | 610 | if ($raw['is_dir']) { |
611 | 611 | $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
@@ -648,14 +648,14 @@ discard block |
||
648 | 648 | } |
649 | 649 | |
650 | 650 | /** |
651 | - * Recursive files search |
|
652 | - * |
|
653 | - * @param string $path dir path |
|
654 | - * @param string $q search string |
|
655 | - * @param array $mimes |
|
656 | - * @return array |
|
657 | - * @author Naoki Sawada |
|
658 | - **/ |
|
651 | + * Recursive files search |
|
652 | + * |
|
653 | + * @param string $path dir path |
|
654 | + * @param string $q search string |
|
655 | + * @param array $mimes |
|
656 | + * @return array |
|
657 | + * @author Naoki Sawada |
|
658 | + **/ |
|
659 | 659 | protected function doSearch($path, $q, $mimes) { |
660 | 660 | $result = array(); |
661 | 661 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
@@ -679,16 +679,16 @@ discard block |
||
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
682 | - * Copy file/recursive copy dir only in current volume. |
|
683 | - * Return new file path or false. |
|
684 | - * |
|
685 | - * @param string $src source path |
|
686 | - * @param string $dst destination dir path |
|
687 | - * @param string $name new file name (optionaly) |
|
688 | - * @return string|false |
|
689 | - * @author Dmitry (dio) Levashov |
|
690 | - * @author Naoki Sawada |
|
691 | - **/ |
|
682 | + * Copy file/recursive copy dir only in current volume. |
|
683 | + * Return new file path or false. |
|
684 | + * |
|
685 | + * @param string $src source path |
|
686 | + * @param string $dst destination dir path |
|
687 | + * @param string $name new file name (optionaly) |
|
688 | + * @return string|false |
|
689 | + * @author Dmitry (dio) Levashov |
|
690 | + * @author Naoki Sawada |
|
691 | + **/ |
|
692 | 692 | protected function copy($src, $dst, $name) { |
693 | 693 | |
694 | 694 | $this->clearcache(); |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
702 | - * Remove file/ recursive remove dir |
|
703 | - * |
|
704 | - * @param string $path file path |
|
705 | - * @param bool $force try to remove even if file locked |
|
706 | - * @return bool |
|
707 | - * @author Dmitry (dio) Levashov |
|
708 | - * @author Naoki Sawada |
|
709 | - **/ |
|
702 | + * Remove file/ recursive remove dir |
|
703 | + * |
|
704 | + * @param string $path file path |
|
705 | + * @param bool $force try to remove even if file locked |
|
706 | + * @return bool |
|
707 | + * @author Dmitry (dio) Levashov |
|
708 | + * @author Naoki Sawada |
|
709 | + **/ |
|
710 | 710 | protected function remove($path, $force = false, $recursive = false) { |
711 | 711 | $stat = $this->stat($path); |
712 | 712 | $stat['realpath'] = $path; |
@@ -736,14 +736,14 @@ discard block |
||
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
739 | - * Create thumnbnail and return it's URL on success |
|
740 | - * |
|
741 | - * @param string $path file path |
|
742 | - * @param string $mime file mime type |
|
743 | - * @return string|false |
|
744 | - * @author Dmitry (dio) Levashov |
|
745 | - * @author Naoki Sawada |
|
746 | - **/ |
|
739 | + * Create thumnbnail and return it's URL on success |
|
740 | + * |
|
741 | + * @param string $path file path |
|
742 | + * @param string $mime file mime type |
|
743 | + * @return string|false |
|
744 | + * @author Dmitry (dio) Levashov |
|
745 | + * @author Naoki Sawada |
|
746 | + **/ |
|
747 | 747 | protected function createTmb($path, $stat) { |
748 | 748 | if (!$stat || !$this->canCreateTmb($path, $stat)) { |
749 | 749 | return false; |
@@ -828,13 +828,13 @@ discard block |
||
828 | 828 | } |
829 | 829 | |
830 | 830 | /** |
831 | - * Return content URL |
|
832 | - * |
|
833 | - * @param string $hash file hash |
|
834 | - * @param array $options options |
|
835 | - * @return array |
|
836 | - * @author Naoki Sawada |
|
837 | - **/ |
|
831 | + * Return content URL |
|
832 | + * |
|
833 | + * @param string $hash file hash |
|
834 | + * @param array $options options |
|
835 | + * @return array |
|
836 | + * @author Naoki Sawada |
|
837 | + **/ |
|
838 | 838 | public function getContentUrl($hash, $options = array()) { |
839 | 839 | if (($file = $this->file($hash)) == false || !$file['url'] || $file['url'] == 1) { |
840 | 840 | $path = $this->decode($hash); |
@@ -897,9 +897,9 @@ discard block |
||
897 | 897 | try { |
898 | 898 | $request2 = new HTTP_Request2(); |
899 | 899 | $request2->setConfig(array( |
900 | - 'ssl_verify_peer' => false, |
|
901 | - 'ssl_verify_host' => false |
|
902 | - )); |
|
900 | + 'ssl_verify_peer' => false, |
|
901 | + 'ssl_verify_host' => false |
|
902 | + )); |
|
903 | 903 | $request2->setUrl($url); |
904 | 904 | $request2->setMethod(HTTP_Request2::METHOD_HEAD); |
905 | 905 | $result = $request2->send(); |
@@ -132,8 +132,12 @@ discard block |
||
132 | 132 | * @author Naoki Sawada |
133 | 133 | **/ |
134 | 134 | public function netmountPrepare($options) { |
135 | - if (empty($options['consumerKey']) && defined('ELFINDER_DROPBOX_CONSUMERKEY')) $options['consumerKey'] = ELFINDER_DROPBOX_CONSUMERKEY; |
|
136 | - if (empty($options['consumerSecret']) && defined('ELFINDER_DROPBOX_CONSUMERSECRET')) $options['consumerSecret'] = ELFINDER_DROPBOX_CONSUMERSECRET; |
|
135 | + if (empty($options['consumerKey']) && defined('ELFINDER_DROPBOX_CONSUMERKEY')) { |
|
136 | + $options['consumerKey'] = ELFINDER_DROPBOX_CONSUMERKEY; |
|
137 | + } |
|
138 | + if (empty($options['consumerSecret']) && defined('ELFINDER_DROPBOX_CONSUMERSECRET')) { |
|
139 | + $options['consumerSecret'] = ELFINDER_DROPBOX_CONSUMERSECRET; |
|
140 | + } |
|
137 | 141 | |
138 | 142 | if ($options['user'] === 'init') { |
139 | 143 | |
@@ -616,8 +620,12 @@ discard block |
||
616 | 620 | } else { |
617 | 621 | $stat['url'] = '1'; |
618 | 622 | } |
619 | - if (isset($raw['width'])) $stat['width'] = $raw['width']; |
|
620 | - if (isset($raw['height'])) $stat['height'] = $raw['height']; |
|
623 | + if (isset($raw['width'])) { |
|
624 | + $stat['width'] = $raw['width']; |
|
625 | + } |
|
626 | + if (isset($raw['height'])) { |
|
627 | + $stat['height'] = $raw['height']; |
|
628 | + } |
|
621 | 629 | |
622 | 630 | return $stat; |
623 | 631 | } |
@@ -1061,7 +1069,9 @@ discard block |
||
1061 | 1069 | * @author Dmitry (dio) Levashov |
1062 | 1070 | **/ |
1063 | 1071 | protected function _dimensions($path, $mime) { |
1064 | - if (strpos($mime, 'image') !== 0) return ''; |
|
1072 | + if (strpos($mime, 'image') !== 0) { |
|
1073 | + return ''; |
|
1074 | + } |
|
1065 | 1075 | $cache = $this->getDBdat($path); |
1066 | 1076 | if (isset($cache['width']) && isset($cache['height'])) { |
1067 | 1077 | return $cache['width'].'x'.$cache['height']; |
@@ -1281,7 +1291,9 @@ discard block |
||
1281 | 1291 | * @author Dmitry (dio) Levashov |
1282 | 1292 | **/ |
1283 | 1293 | protected function _save($fp, $path, $name, $stat) { |
1284 | - if ($name) $path .= '/'.$name; |
|
1294 | + if ($name) { |
|
1295 | + $path .= '/'.$name; |
|
1296 | + } |
|
1285 | 1297 | $path = $this->_normpath($path); |
1286 | 1298 | try { |
1287 | 1299 | $this->dropbox->putFile($path, $fp); |
@@ -1291,8 +1303,12 @@ discard block |
||
1291 | 1303 | $this->deltaCheck(); |
1292 | 1304 | if (is_array($stat)) { |
1293 | 1305 | $raw = $this->getDBdat($path); |
1294 | - if (isset($stat['width'])) $raw['width'] = $stat['width']; |
|
1295 | - if (isset($stat['height'])) $raw['height'] = $stat['height']; |
|
1306 | + if (isset($stat['width'])) { |
|
1307 | + $raw['width'] = $stat['width']; |
|
1308 | + } |
|
1309 | + if (isset($stat['height'])) { |
|
1310 | + $raw['height'] = $stat['height']; |
|
1311 | + } |
|
1296 | 1312 | $this->updateDBdat($path, $raw); |
1297 | 1313 | } |
1298 | 1314 | return $path; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | if ($options['user'] === 'init') { |
140 | 140 | |
141 | - if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
141 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
142 | 142 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
143 | 143 | } |
144 | 144 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | if (class_exists('OAuth', false)) { |
149 | 149 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
150 | 150 | } else { |
151 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
151 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
152 | 152 | // We're going to try to load in manually |
153 | 153 | include 'HTTP/OAuth/Consumer.php'; |
154 | 154 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - if (! $this->oauth) { |
|
161 | + if (!$this->oauth) { |
|
162 | 162 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
163 | 163 | } |
164 | 164 | |
@@ -179,25 +179,25 @@ discard block |
||
179 | 179 | unset($_SESSION['elFinderDropboxTokens']); |
180 | 180 | } |
181 | 181 | } |
182 | - if (! $html) { |
|
182 | + if (!$html) { |
|
183 | 183 | // get customdata |
184 | 184 | $cdata = ''; |
185 | 185 | $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); |
186 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
187 | - foreach($this->ARGS as $k => $v) { |
|
188 | - if (! in_array($k, $innerKeys)) { |
|
189 | - $cdata .= '&' . $k . '=' . rawurlencode($v); |
|
186 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
187 | + foreach ($this->ARGS as $k => $v) { |
|
188 | + if (!in_array($k, $innerKeys)) { |
|
189 | + $cdata .= '&'.$k.'='.rawurlencode($v); |
|
190 | 190 | } |
191 | 191 | } |
192 | - if (strpos($options['url'], 'http') !== 0 ) { |
|
192 | + if (strpos($options['url'], 'http') !== 0) { |
|
193 | 193 | $options['url'] = $this->getConnectorUrl(); |
194 | 194 | } |
195 | - $callback = $options['url'] |
|
195 | + $callback = $options['url'] |
|
196 | 196 | . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
197 | 197 | |
198 | 198 | try { |
199 | 199 | $tokens = $this->oauth->getRequestToken(); |
200 | - $url= $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
200 | + $url = $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
201 | 201 | } catch (Dropbox_Exception $e) { |
202 | 202 | return array('exit' => true, 'body' => '{msg:errAccess}'); |
203 | 203 | } |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | if (isset($netVolumes[$key])) { |
245 | 245 | $dropboxUid = $netVolumes[$key]['dropboxUid']; |
246 | 246 | } |
247 | - foreach($netVolumes as $volume) { |
|
247 | + foreach ($netVolumes as $volume) { |
|
248 | 248 | if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) { |
249 | 249 | $count++; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | if ($count === 1) { |
253 | 253 | $this->DB->exec('drop table '.$this->DB_TableName); |
254 | - foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
254 | + foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
255 | 255 | unlink($tmb); |
256 | 256 | } |
257 | 257 | } |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @author Naoki Sawada |
266 | 266 | */ |
267 | 267 | private function getConnectorUrl() { |
268 | - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
|
268 | + $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') |
|
269 | 269 | . $_SERVER['SERVER_NAME'] // host |
270 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
271 | - . $_SERVER['REQUEST_URI']; // path & query |
|
270 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) // port |
|
271 | + . $_SERVER['REQUEST_URI']; // path & query |
|
272 | 272 | list($url) = explode('?', $url); |
273 | 273 | return $url; |
274 | 274 | } |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | // make net mount key |
305 | 305 | $this->netMountKey = md5(join('-', array('dropbox', $this->options['path']))); |
306 | 306 | |
307 | - if (! $this->oauth) { |
|
307 | + if (!$this->oauth) { |
|
308 | 308 | if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) { |
309 | 309 | $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']); |
310 | 310 | } else { |
311 | 311 | if (class_exists('OAuth', false)) { |
312 | 312 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
313 | 313 | } else { |
314 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
314 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
315 | 315 | // We're going to try to load in manually |
316 | 316 | include 'HTTP/OAuth/Consumer.php'; |
317 | 317 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | - if (! $this->oauth) { |
|
325 | + if (!$this->oauth) { |
|
326 | 326 | return $this->setError('OAuth extension not loaded.'); |
327 | 327 | } |
328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $this->root = $this->options['path'] = $this->_normpath($this->options['path']); |
331 | 331 | |
332 | 332 | if (empty($this->options['alias'])) { |
333 | - $this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
333 | + $this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $this->rootName = $this->options['alias']; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | // setup PDO |
388 | - if (! $this->options['PDO_DSN']) { |
|
388 | + if (!$this->options['PDO_DSN']) { |
|
389 | 389 | $this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']); |
390 | 390 | } |
391 | 391 | // DataBase table name |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | // DataBase check or make table |
394 | 394 | try { |
395 | 395 | $this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']); |
396 | - if (! $this->checkDB()) { |
|
396 | + if (!$this->checkDB()) { |
|
397 | 397 | return $this->setError('Can not make DB table'); |
398 | 398 | } |
399 | 399 | } catch (PDOException $e) { |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | $res = false; |
456 | 456 | } |
457 | 457 | } |
458 | - if (! $res) { |
|
458 | + if (!$res) { |
|
459 | 459 | try { |
460 | 460 | $this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);'); |
461 | 461 | $this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)'); |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | private function updateDBdat($path, $dat) { |
507 | 507 | return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat)) |
508 | - . ', isdir=' . ($dat['is_dir']? 1 : 0) |
|
508 | + . ', isdir='.($dat['is_dir'] ? 1 : 0) |
|
509 | 509 | . ' where path='.$this->DB->quote(strtolower($this->_dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path)))); |
510 | 510 | } |
511 | 511 | /*********************************************************************/ |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | protected function deltaCheck($refresh = true) { |
532 | 532 | $chk = false; |
533 | - if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
533 | + if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
534 | 534 | $chk = unserialize($chk[0]); |
535 | 535 | } |
536 | 536 | if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) { |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | do { |
555 | 555 | @ ini_set('max_execution_time', 120); |
556 | 556 | $_info = $this->dropbox->delta($cursor); |
557 | - if (! empty($_info['reset'])) { |
|
557 | + if (!empty($_info['reset'])) { |
|
558 | 558 | $this->DB->exec('TRUNCATE table '.$this->DB_TableName); |
559 | 559 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);'); |
560 | 560 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array( |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | } |
568 | 568 | $cursor = $_info['cursor']; |
569 | 569 | |
570 | - foreach($_info['entries'] as $entry) { |
|
570 | + foreach ($_info['entries'] as $entry) { |
|
571 | 571 | $key = strtolower($entry[0]); |
572 | 572 | $pkey = strtolower($this->_dirname($key)); |
573 | 573 | |
@@ -576,22 +576,22 @@ discard block |
||
576 | 576 | $where = 'where path='.$path.' and fname='.$fname; |
577 | 577 | |
578 | 578 | if (empty($entry[1])) { |
579 | - $ptimes[$pkey] = isset($ptimes[$pkey])? max(array($now, $ptimes[$pkey])) : $now; |
|
579 | + $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($now, $ptimes[$pkey])) : $now; |
|
580 | 580 | $this->DB->exec('delete from '.$this->DB_TableName.' '.$where); |
581 | - ! $delete && $delete = true; |
|
581 | + !$delete && $delete = true; |
|
582 | 582 | continue; |
583 | 583 | } |
584 | 584 | |
585 | - $_itemTime = strtotime(isset($entry[1]['client_mtime'])? $entry[1]['client_mtime'] : $entry[1]['modified']); |
|
586 | - $ptimes[$pkey] = isset($ptimes[$pkey])? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime; |
|
585 | + $_itemTime = strtotime(isset($entry[1]['client_mtime']) ? $entry[1]['client_mtime'] : $entry[1]['modified']); |
|
586 | + $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime; |
|
587 | 587 | $sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1'; |
588 | - if (! $reset && $this->query($sql)) { |
|
589 | - $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where); |
|
588 | + if (!$reset && $this->query($sql)) { |
|
589 | + $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where); |
|
590 | 590 | } else { |
591 | - $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')'); |
|
591 | + $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')'); |
|
592 | 592 | } |
593 | 593 | } |
594 | - } while (! empty($_info['has_more'])); |
|
594 | + } while (!empty($_info['has_more'])); |
|
595 | 595 | |
596 | 596 | // update time stamp of parent holder |
597 | 597 | foreach ($ptimes as $_p => $_t) { |
@@ -613,14 +613,14 @@ discard block |
||
613 | 613 | } |
614 | 614 | |
615 | 615 | $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\''); |
616 | - if (! $this->DB->commit()) { |
|
616 | + if (!$this->DB->commit()) { |
|
617 | 617 | $e = $this->DB->errorInfo(); |
618 | 618 | return $e[2]; |
619 | 619 | } |
620 | 620 | if ($delete) { |
621 | 621 | $this->DB->exec('vacuum'); |
622 | 622 | } |
623 | - } catch(Dropbox_Exception $e) { |
|
623 | + } catch (Dropbox_Exception $e) { |
|
624 | 624 | return $e->getMessage(); |
625 | 625 | } |
626 | 626 | return true; |
@@ -636,15 +636,14 @@ discard block |
||
636 | 636 | protected function parseRaw($raw) { |
637 | 637 | $stat = array(); |
638 | 638 | |
639 | - $stat['rev'] = isset($raw['rev'])? $raw['rev'] : 'root'; |
|
639 | + $stat['rev'] = isset($raw['rev']) ? $raw['rev'] : 'root'; |
|
640 | 640 | $stat['name'] = basename($raw['path']); |
641 | - $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
|
641 | + $stat['mime'] = $raw['is_dir'] ? 'directory' : $raw['mime_type']; |
|
642 | 642 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
643 | - $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
|
644 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
643 | + $stat['ts'] = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
645 | 644 | $stat['dirs'] = 0; |
646 | 645 | if ($raw['is_dir']) { |
647 | - $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
646 | + $stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
648 | 647 | } |
649 | 648 | |
650 | 649 | if (!empty($raw['url'])) { |
@@ -670,7 +669,7 @@ discard block |
||
670 | 669 | $res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path))); |
671 | 670 | |
672 | 671 | if ($res) { |
673 | - foreach($res as $raw) { |
|
672 | + foreach ($res as $raw) { |
|
674 | 673 | $raw = unserialize($raw); |
675 | 674 | if ($stat = $this->parseRaw($raw)) { |
676 | 675 | $stat = $this->updateCache($raw['path'], $stat); |
@@ -695,10 +694,10 @@ discard block |
||
695 | 694 | protected function doSearch($path, $q, $mimes) { |
696 | 695 | $result = array(); |
697 | 696 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
698 | - $sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
697 | + $sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
699 | 698 | $res = $sth->fetchAll(PDO::FETCH_COLUMN); |
700 | 699 | if ($res) { |
701 | - foreach($res as $raw) { |
|
700 | + foreach ($res as $raw) { |
|
702 | 701 | $raw = unserialize($raw); |
703 | 702 | if ($stat = $this->parseRaw($raw)) { |
704 | 703 | if (!isset($this->cache[$raw['path']])) { |
@@ -789,10 +788,10 @@ discard block |
||
789 | 788 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
790 | 789 | |
791 | 790 | // copy image into tmbPath so some drivers does not store files on local fs |
792 | - if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
791 | + if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
793 | 792 | return false; |
794 | 793 | } |
795 | - if (! file_put_contents($tmb, $data)) { |
|
794 | + if (!file_put_contents($tmb, $data)) { |
|
796 | 795 | return false; |
797 | 796 | } |
798 | 797 | |
@@ -805,15 +804,15 @@ discard block |
||
805 | 804 | } |
806 | 805 | |
807 | 806 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
808 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
809 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
807 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
808 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
810 | 809 | |
811 | 810 | } else { |
812 | 811 | |
813 | 812 | if ($this->options['tmbCrop']) { |
814 | 813 | |
815 | 814 | /* Resize and crop if image bigger than thumbnail */ |
816 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
815 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
817 | 816 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
818 | 817 | } |
819 | 818 | |
@@ -827,7 +826,7 @@ discard block |
||
827 | 826 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
828 | 827 | } |
829 | 828 | |
830 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
829 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
831 | 830 | } |
832 | 831 | |
833 | 832 | if (!$result) { |
@@ -884,7 +883,7 @@ discard block |
||
884 | 883 | } |
885 | 884 | } |
886 | 885 | } |
887 | - if (! $url) { |
|
886 | + if (!$url) { |
|
888 | 887 | try { |
889 | 888 | $res = $this->dropbox->share($path, null, false); |
890 | 889 | $url = $res['url']; |
@@ -896,7 +895,7 @@ discard block |
||
896 | 895 | } |
897 | 896 | list($url) = explode('?', $url); |
898 | 897 | $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url); |
899 | - if (! isset($cache['share']) || $cache['share'] !== $url) { |
|
898 | + if (!isset($cache['share']) || $cache['share'] !== $url) { |
|
900 | 899 | $cache['share'] = $url; |
901 | 900 | $this->updateDBdat($path, $cache); |
902 | 901 | } |
@@ -920,12 +919,12 @@ discard block |
||
920 | 919 | if (function_exists('curl_exec')) { |
921 | 920 | |
922 | 921 | $c = curl_init(); |
923 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
|
924 | - curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
925 | - curl_setopt( $c, CURLOPT_HEADER, 1 ); |
|
926 | - curl_setopt( $c, CURLOPT_NOBODY, true ); |
|
927 | - curl_setopt( $c, CURLOPT_URL, $url ); |
|
928 | - $res = curl_exec( $c ); |
|
922 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
923 | + curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
924 | + curl_setopt($c, CURLOPT_HEADER, 1); |
|
925 | + curl_setopt($c, CURLOPT_NOBODY, true); |
|
926 | + curl_setopt($c, CURLOPT_URL, $url); |
|
927 | + $res = curl_exec($c); |
|
929 | 928 | |
930 | 929 | } else { |
931 | 930 | |
@@ -941,13 +940,13 @@ discard block |
||
941 | 940 | $result = $request2->send(); |
942 | 941 | $res = array(); |
943 | 942 | $res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase(); |
944 | - foreach($result->getHeader() as $key => $val) { |
|
945 | - $res[] = $key . ': ' . $val; |
|
943 | + foreach ($result->getHeader() as $key => $val) { |
|
944 | + $res[] = $key.': '.$val; |
|
946 | 945 | } |
947 | 946 | $res = join("\r\n", $res); |
948 | - } catch( HTTP_Request2_Exception $e ){ |
|
947 | + } catch (HTTP_Request2_Exception $e) { |
|
949 | 948 | $res = ''; |
950 | - } catch (Exception $e){ |
|
949 | + } catch (Exception $e) { |
|
951 | 950 | $res = ''; |
952 | 951 | } |
953 | 952 | |
@@ -1002,7 +1001,7 @@ discard block |
||
1002 | 1001 | if (DIRECTORY_SEPARATOR !== '/') { |
1003 | 1002 | $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); |
1004 | 1003 | } |
1005 | - $path = '/' . ltrim($path, '/'); |
|
1004 | + $path = '/'.ltrim($path, '/'); |
|
1006 | 1005 | return $path; |
1007 | 1006 | } |
1008 | 1007 | |
@@ -1145,7 +1144,7 @@ discard block |
||
1145 | 1144 | * @return resource|false |
1146 | 1145 | * @author Dmitry (dio) Levashov |
1147 | 1146 | **/ |
1148 | - protected function _fopen($path, $mode='rb') { |
|
1147 | + protected function _fopen($path, $mode = 'rb') { |
|
1149 | 1148 | |
1150 | 1149 | if (($mode == 'rb' || $mode == 'r')) { |
1151 | 1150 | try { |
@@ -1155,7 +1154,7 @@ discard block |
||
1155 | 1154 | fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); |
1156 | 1155 | fputs($fp, "Host: {$url['host']}\r\n"); |
1157 | 1156 | fputs($fp, "\r\n"); |
1158 | - while(trim(fgets($fp)) !== ''){}; |
|
1157 | + while (trim(fgets($fp)) !== '') {}; |
|
1159 | 1158 | return $fp; |
1160 | 1159 | } catch (Dropbox_Exception $e) { |
1161 | 1160 | return false; |
@@ -1186,7 +1185,7 @@ discard block |
||
1186 | 1185 | * @return bool |
1187 | 1186 | * @author Dmitry (dio) Levashov |
1188 | 1187 | **/ |
1189 | - protected function _fclose($fp, $path='') { |
|
1188 | + protected function _fclose($fp, $path = '') { |
|
1190 | 1189 | @fclose($fp); |
1191 | 1190 | if ($path) { |
1192 | 1191 | @unlink($this->getTempFile($path)); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * Return ftp transfer mode for file |
478 | 478 | * |
479 | 479 | * @param string $path file path |
480 | - * @return string |
|
480 | + * @return integer |
|
481 | 481 | * @author Dmitry (dio) Levashov |
482 | 482 | **/ |
483 | 483 | protected function ftpMode($path) { |
@@ -841,7 +841,6 @@ discard block |
||
841 | 841 | * Open file and return file pointer |
842 | 842 | * |
843 | 843 | * @param string $path file path |
844 | - * @param bool $write open file for writing |
|
845 | 844 | * @return resource|false |
846 | 845 | * @author Dmitry (dio) Levashov |
847 | 846 | **/ |
@@ -866,7 +865,7 @@ discard block |
||
866 | 865 | * Close opened file |
867 | 866 | * |
868 | 867 | * @param resource $fp file pointer |
869 | - * @return bool |
|
868 | + * @return boolean|null |
|
870 | 869 | * @author Dmitry (dio) Levashov |
871 | 870 | **/ |
872 | 871 | protected function _fclose($fp, $path='') { |
@@ -883,7 +882,7 @@ discard block |
||
883 | 882 | * |
884 | 883 | * @param string $path parent dir path |
885 | 884 | * @param string $name new directory name |
886 | - * @return string|bool |
|
885 | + * @return false|string |
|
887 | 886 | * @author Dmitry (dio) Levashov |
888 | 887 | **/ |
889 | 888 | protected function _mkdir($path, $name) { |
@@ -901,7 +900,7 @@ discard block |
||
901 | 900 | * |
902 | 901 | * @param string $path parent dir path |
903 | 902 | * @param string $name new file name |
904 | - * @return string|bool |
|
903 | + * @return string|false |
|
905 | 904 | * @author Dmitry (dio) Levashov |
906 | 905 | **/ |
907 | 906 | protected function _mkfile($path, $name) { |
@@ -933,7 +932,7 @@ discard block |
||
933 | 932 | * @param string $source source file path |
934 | 933 | * @param string $targetDir target directory path |
935 | 934 | * @param string $name new file name |
936 | - * @return bool |
|
935 | + * @return string|false |
|
937 | 936 | * @author Dmitry (dio) Levashov |
938 | 937 | **/ |
939 | 938 | protected function _copy($source, $targetDir, $name) { |
@@ -958,9 +957,9 @@ discard block |
||
958 | 957 | * Return new file path or false. |
959 | 958 | * |
960 | 959 | * @param string $source source file path |
961 | - * @param string $target target dir path |
|
960 | + * @param string $targetDir target dir path |
|
962 | 961 | * @param string $name file name |
963 | - * @return string|bool |
|
962 | + * @return string|false |
|
964 | 963 | * @author Dmitry (dio) Levashov |
965 | 964 | **/ |
966 | 965 | protected function _move($source, $targetDir, $name) { |
@@ -998,7 +997,7 @@ discard block |
||
998 | 997 | * @param string $dir target dir path |
999 | 998 | * @param string $name file name |
1000 | 999 | * @param array $stat file stat (required by some virtual fs) |
1001 | - * @return bool|string |
|
1000 | + * @return string|false |
|
1002 | 1001 | * @author Dmitry (dio) Levashov |
1003 | 1002 | **/ |
1004 | 1003 | protected function _save($fp, $dir, $name, $stat) { |
@@ -1231,7 +1230,7 @@ discard block |
||
1231 | 1230 | * @param array $files files names list |
1232 | 1231 | * @param string $name archive name |
1233 | 1232 | * @param array $arc archiver options |
1234 | - * @return string|bool |
|
1233 | + * @return false|string |
|
1235 | 1234 | * @author Dmitry (dio) Levashov, |
1236 | 1235 | * @author Alexey Sukhotin |
1237 | 1236 | **/ |
@@ -1350,9 +1349,9 @@ discard block |
||
1350 | 1349 | * Downloads specified files from remote directory |
1351 | 1350 | * if there is a directory among files it is downloaded recursively (omitting symbolic links). |
1352 | 1351 | * |
1353 | - * @param $remote_directory string remote FTP path to a source directory to download from. |
|
1352 | + * @param string $remote_directory string remote FTP path to a source directory to download from. |
|
1354 | 1353 | * @param array $files list of files to download from remote directory. |
1355 | - * @param $dest_local_directory string destination folder to store downloaded files. |
|
1354 | + * @param string $dest_local_directory string destination folder to store downloaded files. |
|
1356 | 1355 | * @return bool true on success and false on failure. |
1357 | 1356 | */ |
1358 | 1357 | private function ftp_download_files($remote_directory, array $files, $dest_local_directory) |
@@ -1423,6 +1422,7 @@ discard block |
||
1423 | 1422 | * Returns array of strings containing all files and folders in the specified local directory. |
1424 | 1423 | * @param $dir |
1425 | 1424 | * @param string $prefix |
1425 | + * @param boolean $omitSymlinks |
|
1426 | 1426 | * @internal param string $path path to directory to scan. |
1427 | 1427 | * @return array array of files and folders names relative to the $path |
1428 | 1428 | * or an empty array if the directory $path is empty, |
@@ -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 |
@@ -593,7 +593,6 @@ discard block |
||
593 | 593 | * Open file and return file pointer |
594 | 594 | * |
595 | 595 | * @param string $path file path |
596 | - * @param bool $write open file for writing |
|
597 | 596 | * @return resource|false |
598 | 597 | * @author Dmitry (dio) Levashov |
599 | 598 | **/ |
@@ -619,7 +618,7 @@ discard block |
||
619 | 618 | * |
620 | 619 | * @param string $path parent dir path |
621 | 620 | * @param string $name new directory name |
622 | - * @return string|bool |
|
621 | + * @return string|false |
|
623 | 622 | * @author Dmitry (dio) Levashov |
624 | 623 | **/ |
625 | 624 | protected function _mkdir($path, $name) { |
@@ -639,7 +638,7 @@ discard block |
||
639 | 638 | * |
640 | 639 | * @param string $path parent dir path |
641 | 640 | * @param string $name new file name |
642 | - * @return string|bool |
|
641 | + * @return string|false |
|
643 | 642 | * @author Dmitry (dio) Levashov |
644 | 643 | **/ |
645 | 644 | protected function _mkfile($path, $name) { |
@@ -687,9 +686,9 @@ discard block |
||
687 | 686 | * Return new file path or false. |
688 | 687 | * |
689 | 688 | * @param string $source source file path |
690 | - * @param string $target target dir path |
|
689 | + * @param string $targetDir target dir path |
|
691 | 690 | * @param string $name file name |
692 | - * @return string|bool |
|
691 | + * @return string|false |
|
693 | 692 | * @author Dmitry (dio) Levashov |
694 | 693 | **/ |
695 | 694 | protected function _move($source, $targetDir, $name) { |
@@ -733,7 +732,7 @@ discard block |
||
733 | 732 | * @param string $dir target dir path |
734 | 733 | * @param string $name file name |
735 | 734 | * @param array $stat file stat (required by some virtual fs) |
736 | - * @return bool|string |
|
735 | + * @return false|string |
|
737 | 736 | * @author Dmitry (dio) Levashov |
738 | 737 | **/ |
739 | 738 | protected function _save($fp, $dir, $name, $stat) { |
@@ -761,7 +760,7 @@ discard block |
||
761 | 760 | * Get file contents |
762 | 761 | * |
763 | 762 | * @param string $path file path |
764 | - * @return string|false |
|
763 | + * @return string |
|
765 | 764 | * @author Dmitry (dio) Levashov |
766 | 765 | **/ |
767 | 766 | protected function _getContents($path) { |
@@ -965,7 +964,7 @@ discard block |
||
965 | 964 | * @param array $files files names list |
966 | 965 | * @param string $name archive name |
967 | 966 | * @param array $arc archiver options |
968 | - * @return string|bool |
|
967 | + * @return string|false |
|
969 | 968 | * @author Dmitry (dio) Levashov, |
970 | 969 | * @author Alexey Sukhotin |
971 | 970 | **/ |
@@ -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); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * Close opened file |
612 | 612 | * |
613 | 613 | * @param resource $fp file pointer |
614 | - * @return bool |
|
614 | + * @return boolean|null |
|
615 | 615 | * @author Dmitry (dio) Levashov |
616 | 616 | **/ |
617 | 617 | protected function _fclose($fp, $path='') { |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @param string $path parent dir path |
630 | 630 | * @param string $name new directory name |
631 | - * @return string|bool |
|
631 | + * @return string|false |
|
632 | 632 | * @author Dmitry (dio) Levashov |
633 | 633 | **/ |
634 | 634 | protected function _mkdir($path, $name) { |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @param string $path parent dir path |
642 | 642 | * @param string $name new file name |
643 | - * @return string|bool |
|
643 | + * @return string|false |
|
644 | 644 | * @author Dmitry (dio) Levashov |
645 | 645 | **/ |
646 | 646 | protected function _mkfile($path, $name) { |
@@ -684,9 +684,9 @@ discard block |
||
684 | 684 | * Return new file path or false. |
685 | 685 | * |
686 | 686 | * @param string $source source file path |
687 | - * @param string $target target dir path |
|
687 | + * @param string $targetDir target dir path |
|
688 | 688 | * @param string $name file name |
689 | - * @return string|bool |
|
689 | + * @return string|false |
|
690 | 690 | * @author Dmitry (dio) Levashov |
691 | 691 | **/ |
692 | 692 | protected function _move($source, $targetDir, $name) { |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * |
870 | 870 | * @param string $path archive path |
871 | 871 | * @param array $arc archiver command and arguments (same as in $this->archivers) |
872 | - * @return true |
|
872 | + * @return boolean |
|
873 | 873 | * @author Dmitry (dio) Levashov, |
874 | 874 | * @author Alexey Sukhotin |
875 | 875 | **/ |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * @param array $files files names list |
885 | 885 | * @param string $name archive name |
886 | 886 | * @param array $arc archiver options |
887 | - * @return string|bool |
|
887 | + * @return boolean |
|
888 | 888 | * @author Dmitry (dio) Levashov, |
889 | 889 | * @author Alexey Sukhotin |
890 | 890 | **/ |
@@ -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); |
@@ -107,6 +107,10 @@ discard block |
||
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | + /** |
|
111 | + * @param double $width |
|
112 | + * @param double $height |
|
113 | + */ |
|
110 | 114 | private function resize_gd($src, $width, $height, $quality, $srcImgInfo) { |
111 | 115 | switch ($srcImgInfo['mime']) { |
112 | 116 | case 'image/gif': |
@@ -177,6 +181,10 @@ discard block |
||
177 | 181 | return false; |
178 | 182 | } |
179 | 183 | |
184 | + /** |
|
185 | + * @param double $width |
|
186 | + * @param double $height |
|
187 | + */ |
|
180 | 188 | private function resize_imagick($src, $width, $height, $quality) { |
181 | 189 | try { |
182 | 190 | $img = new imagick($src); |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | |
53 | 53 | public function __construct($opts) { |
54 | 54 | $defaults = array( |
55 | - 'enable' => true, // For control by volume driver |
|
56 | - 'maxWidth' => 1024, // Path to Water mark image |
|
57 | - 'maxHeight' => 1024, // Margin right pixel |
|
58 | - 'quality' => 95, // JPEG image save quality |
|
59 | - 'preserveExif' => false, // Preserve EXIF data (Imagick only) |
|
60 | - 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
55 | + 'enable' => true, // For control by volume driver |
|
56 | + 'maxWidth' => 1024, // Path to Water mark image |
|
57 | + 'maxHeight' => 1024, // Margin right pixel |
|
58 | + 'quality' => 95, // JPEG image save quality |
|
59 | + 'preserveExif' => false, // Preserve EXIF data (Imagick only) |
|
60 | + 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field ) |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | $this->opts = array_merge($defaults, $opts); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $opts = array_merge($this->opts, $volOpts); |
72 | 72 | } |
73 | 73 | |
74 | - if (! $opts['enable']) { |
|
74 | + if (!$opts['enable']) { |
|
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | IMAGETYPE_PNG => IMG_PNG, |
88 | 88 | IMAGETYPE_WBMP => IMG_WBMP, |
89 | 89 | ); |
90 | - if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
90 | + if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality, $preserveExif) { |
102 | - $zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1])); |
|
103 | - $width = round($srcImgInfo[0] * $zoom); |
|
104 | - $height = round($srcImgInfo[1] * $zoom); |
|
102 | + $zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1])); |
|
103 | + $width = round($srcImgInfo[0]*$zoom); |
|
104 | + $height = round($srcImgInfo[1]*$zoom); |
|
105 | 105 | |
106 | 106 | if (class_exists('Imagick', false)) { |
107 | 107 | return $this->resize_imagick($src, $width, $height, $quality, $preserveExif); |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | break; |
122 | 122 | case 'image/jpeg': |
123 | 123 | if (@imagetypes() & IMG_JPG) { |
124 | - $oSrcImg = @imagecreatefromjpeg($src) ; |
|
124 | + $oSrcImg = @imagecreatefromjpeg($src); |
|
125 | 125 | } else { |
126 | 126 | $ermsg = 'JPEG images are not supported'; |
127 | 127 | } |
128 | 128 | break; |
129 | 129 | case 'image/png': |
130 | 130 | if (@imagetypes() & IMG_PNG) { |
131 | - $oSrcImg = @imagecreatefrompng($src) ; |
|
131 | + $oSrcImg = @imagecreatefrompng($src); |
|
132 | 132 | } else { |
133 | 133 | $ermsg = 'PNG images are not supported'; |
134 | 134 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | break; |
147 | 147 | } |
148 | 148 | |
149 | - if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
149 | + if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
150 | 150 | |
151 | 151 | if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) { |
152 | 152 | return false; |
@@ -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 { |
@@ -212,8 +212,9 @@ |
||
212 | 212 | protected function input_filter($args) { |
213 | 213 | static $magic_quotes_gpc = NULL; |
214 | 214 | |
215 | - if ($magic_quotes_gpc === NULL) |
|
216 | - $magic_quotes_gpc = (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc()); |
|
215 | + if ($magic_quotes_gpc === NULL) { |
|
216 | + $magic_quotes_gpc = (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc()); |
|
217 | + } |
|
217 | 218 | |
218 | 219 | if (is_array($args)) { |
219 | 220 | return array_map(array(& $this, 'input_filter'), $args); |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Base class for elFinder volume. |
|
4 | - * Provide 2 layers: |
|
5 | - * 1. Public API (commands) |
|
6 | - * 2. abstract fs API |
|
7 | - * |
|
8 | - * All abstract methods begin with "_" |
|
9 | - * |
|
10 | - * @author Dmitry (dio) Levashov |
|
11 | - * @author Troex Nevelin |
|
12 | - * @author Alexey Sukhotin |
|
13 | - **/ |
|
3 | + * Base class for elFinder volume. |
|
4 | + * Provide 2 layers: |
|
5 | + * 1. Public API (commands) |
|
6 | + * 2. abstract fs API |
|
7 | + * |
|
8 | + * All abstract methods begin with "_" |
|
9 | + * |
|
10 | + * @author Dmitry (dio) Levashov |
|
11 | + * @author Troex Nevelin |
|
12 | + * @author Alexey Sukhotin |
|
13 | + **/ |
|
14 | 14 | abstract class elFinderVolumeDriver { |
15 | 15 | |
16 | 16 | /** |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | 'mimefile' => '', |
193 | 193 | // mime type normalize map : Array '[ext]:[detected mime type]' => '[normalized mime]' |
194 | 194 | 'mimeMap' => array( |
195 | - 'md:application/x-genesis-rom' => 'text/x-markdown', |
|
196 | - 'md:text/plain' => 'text/x-markdown', |
|
197 | - 'markdown:text/plain' => 'text/x-markdown', |
|
198 | - 'css:text/x-asm' => 'text/css' |
|
199 | - ), |
|
195 | + 'md:application/x-genesis-rom' => 'text/x-markdown', |
|
196 | + 'md:text/plain' => 'text/x-markdown', |
|
197 | + 'markdown:text/plain' => 'text/x-markdown', |
|
198 | + 'css:text/x-asm' => 'text/css' |
|
199 | + ), |
|
200 | 200 | // directory for thumbnails |
201 | 201 | 'tmbPath' => '.tmb', |
202 | 202 | // mode to create thumbnails dir |
@@ -4043,14 +4043,14 @@ discard block |
||
4043 | 4043 | // } |
4044 | 4044 | |
4045 | 4045 | /** |
4046 | - * Find position of first occurrence of string in a string with multibyte support |
|
4047 | - * |
|
4048 | - * @param string $haystack The string being checked. |
|
4049 | - * @param string $needle The string to find in haystack. |
|
4050 | - * @param int $offset The search offset. If it is not specified, 0 is used. |
|
4051 | - * @return int|bool |
|
4052 | - * @author Alexey Sukhotin |
|
4053 | - **/ |
|
4046 | + * Find position of first occurrence of string in a string with multibyte support |
|
4047 | + * |
|
4048 | + * @param string $haystack The string being checked. |
|
4049 | + * @param string $needle The string to find in haystack. |
|
4050 | + * @param int $offset The search offset. If it is not specified, 0 is used. |
|
4051 | + * @return int|bool |
|
4052 | + * @author Alexey Sukhotin |
|
4053 | + **/ |
|
4054 | 4054 | protected function stripos($haystack , $needle , $offset = 0) { |
4055 | 4055 | if (function_exists('mb_stripos')) { |
4056 | 4056 | return mb_stripos($haystack , $needle , $offset); |
@@ -859,7 +859,9 @@ discard block |
||
859 | 859 | |
860 | 860 | // This get's triggered if $this->root == '/' and alias is empty. |
861 | 861 | // Maybe modify _basename instead? |
862 | - if ($this->rootName === '') $this->rootName = $this->separator; |
|
862 | + if ($this->rootName === '') { |
|
863 | + $this->rootName = $this->separator; |
|
864 | + } |
|
863 | 865 | |
864 | 866 | $root = $this->stat($this->root); |
865 | 867 | |
@@ -2938,7 +2940,9 @@ discard block |
||
2938 | 2940 | if ($this->mimeDetect == 'finfo') { |
2939 | 2941 | if ($type = @finfo_file($this->finfo, $path)) { |
2940 | 2942 | if ($ext && preg_match('~^application/(?:octet-stream|(?:x-)?zip)~', $type)) { |
2941 | - if (isset(elFinderVolumeDriver::$mimetypes[$ext])) $type = elFinderVolumeDriver::$mimetypes[$ext]; |
|
2943 | + if (isset(elFinderVolumeDriver::$mimetypes[$ext])) { |
|
2944 | + $type = elFinderVolumeDriver::$mimetypes[$ext]; |
|
2945 | + } |
|
2942 | 2946 | } else if ($ext === 'js' && preg_match('~^text/~', $type)) { |
2943 | 2947 | $type = 'text/javascript'; |
2944 | 2948 | } |
@@ -4013,7 +4017,7 @@ discard block |
||
4013 | 4017 | imagesavealpha($image,true); |
4014 | 4018 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
4015 | 4019 | |
4016 | - }else{ |
|
4020 | + } else{ |
|
4017 | 4021 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
4018 | 4022 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
4019 | 4023 | } |
@@ -4203,7 +4207,9 @@ discard block |
||
4203 | 4207 | } |
4204 | 4208 | |
4205 | 4209 | // 'Here' |
4206 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
4210 | + if ($path === '' || $path === '.' . $separator) { |
|
4211 | + return $base; |
|
4212 | + } |
|
4207 | 4213 | |
4208 | 4214 | // Absolute path |
4209 | 4215 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
@@ -1238,7 +1238,6 @@ discard block |
||
1238 | 1238 | * Return file info or false on error |
1239 | 1239 | * |
1240 | 1240 | * @param string $hash file hash |
1241 | - * @param bool $realpath add realpath field to file info |
|
1242 | 1241 | * @return array|false |
1243 | 1242 | * @author Dmitry (dio) Levashov |
1244 | 1243 | **/ |
@@ -1259,7 +1258,6 @@ discard block |
||
1259 | 1258 | * Return folder info |
1260 | 1259 | * |
1261 | 1260 | * @param string $hash folder hash |
1262 | - * @param bool $hidden return hidden file info |
|
1263 | 1261 | * @return array|false |
1264 | 1262 | * @author Dmitry (dio) Levashov |
1265 | 1263 | **/ |
@@ -1592,7 +1590,6 @@ discard block |
||
1592 | 1590 | * |
1593 | 1591 | * @param Resource $fp file pointer |
1594 | 1592 | * @param string $dst destination folder hash |
1595 | - * @param string $src file name |
|
1596 | 1593 | * @param string $tmpname file tmp name - required to detect mime type |
1597 | 1594 | * @return array|false |
1598 | 1595 | * @author Dmitry (dio) Levashov |
@@ -1678,7 +1675,6 @@ discard block |
||
1678 | 1675 | * Paste files |
1679 | 1676 | * |
1680 | 1677 | * @param Object $volume source volume |
1681 | - * @param string $source file hash |
|
1682 | 1678 | * @param string $dst destination dir hash |
1683 | 1679 | * @param bool $rmSrc remove source after copy? |
1684 | 1680 | * @return array|false |
@@ -2301,7 +2297,6 @@ discard block |
||
2301 | 2297 | * Open file and return file pointer (with convert encording) |
2302 | 2298 | * |
2303 | 2299 | * @param string $path file path |
2304 | - * @param bool $write open file for writing |
|
2305 | 2300 | * @return resource|false |
2306 | 2301 | * @author Naoki Sawada |
2307 | 2302 | **/ |
@@ -2432,7 +2427,8 @@ discard block |
||
2432 | 2427 | * Not implemented |
2433 | 2428 | * |
2434 | 2429 | * @param string path |
2435 | - * @return mixed |
|
2430 | + * @param string $path |
|
2431 | + * @return string |
|
2436 | 2432 | * @author Dmitry (dio) Levashov |
2437 | 2433 | **/ |
2438 | 2434 | protected function crypt($path) { |
@@ -2444,7 +2440,8 @@ discard block |
||
2444 | 2440 | * Not implemented |
2445 | 2441 | * |
2446 | 2442 | * @param mixed hash |
2447 | - * @return mixed |
|
2443 | + * @param string $hash |
|
2444 | + * @return string |
|
2448 | 2445 | * @author Dmitry (dio) Levashov |
2449 | 2446 | **/ |
2450 | 2447 | protected function uncrypt($hash) { |
@@ -2477,7 +2474,6 @@ discard block |
||
2477 | 2474 | /** |
2478 | 2475 | * Return new unique name based on file name and suffix |
2479 | 2476 | * |
2480 | - * @param string $path file path |
|
2481 | 2477 | * @param string $suffix suffix append to name |
2482 | 2478 | * @return string |
2483 | 2479 | * @author Dmitry (dio) Levashov |
@@ -2545,6 +2541,7 @@ discard block |
||
2545 | 2541 | * @param string $to to character encoding |
2546 | 2542 | * @param string $locale local locale |
2547 | 2543 | * @param string $unknown replaces character for unknown |
2544 | + * @param boolean $restoreLocale |
|
2548 | 2545 | * @return mixed |
2549 | 2546 | */ |
2550 | 2547 | protected function convEnc($var, $from, $to, $locale, $restoreLocale, $unknown = '_') { |
@@ -2726,6 +2723,7 @@ discard block |
||
2726 | 2723 | * |
2727 | 2724 | * @param string $dir parent dir path |
2728 | 2725 | * @param string $name new file name |
2726 | + * @param boolean $isDir |
|
2729 | 2727 | * @return bool |
2730 | 2728 | * @author Dmitry (dio) Levashov |
2731 | 2729 | **/ |
@@ -3279,7 +3277,7 @@ discard block |
||
3279 | 3277 | * @param string $src source path |
3280 | 3278 | * @param string $dst destination dir path |
3281 | 3279 | * @param string $name new file name (optionaly) |
3282 | - * @return string|false |
|
3280 | + * @return boolean|string |
|
3283 | 3281 | * @author Dmitry (dio) Levashov |
3284 | 3282 | **/ |
3285 | 3283 | protected function copy($src, $dst, $name) { |
@@ -3332,7 +3330,7 @@ discard block |
||
3332 | 3330 | * @param string $src source path |
3333 | 3331 | * @param string $dst destination dir path |
3334 | 3332 | * @param string $name new file name |
3335 | - * @return string|false |
|
3333 | + * @return string|boolean |
|
3336 | 3334 | * @author Dmitry (dio) Levashov |
3337 | 3335 | **/ |
3338 | 3336 | protected function move($src, $dst, $name) { |
@@ -3358,7 +3356,7 @@ discard block |
||
3358 | 3356 | * @param string $src source file hash |
3359 | 3357 | * @param string $destination destination dir path |
3360 | 3358 | * @param string $name file name |
3361 | - * @return string|false |
|
3359 | + * @return boolean|string |
|
3362 | 3360 | * @author Dmitry (dio) Levashov |
3363 | 3361 | **/ |
3364 | 3362 | protected function copyFrom($volume, $src, $destination, $name) { |
@@ -3506,7 +3504,7 @@ discard block |
||
3506 | 3504 | * @param string $path thumnbnail path |
3507 | 3505 | * @param array $stat file stat |
3508 | 3506 | * @param bool $checkTmbPath |
3509 | - * @return string|bool |
|
3507 | + * @return boolean |
|
3510 | 3508 | * @author Dmitry (dio) Levashov |
3511 | 3509 | **/ |
3512 | 3510 | protected function canCreateTmb($path, $stat, $checkTmbPath = true) { |
@@ -3523,7 +3521,7 @@ discard block |
||
3523 | 3521 | * |
3524 | 3522 | * @param string $path thumnbnail path |
3525 | 3523 | * @param array $stat file stat |
3526 | - * @return string|bool |
|
3524 | + * @return boolean |
|
3527 | 3525 | * @author Dmitry (dio) Levashov |
3528 | 3526 | **/ |
3529 | 3527 | protected function canResize($path, $stat) { |
@@ -3534,7 +3532,6 @@ discard block |
||
3534 | 3532 | * Create thumnbnail and return it's URL on success |
3535 | 3533 | * |
3536 | 3534 | * @param string $path file path |
3537 | - * @param string $mime file mime type |
|
3538 | 3535 | * @return string|false |
3539 | 3536 | * @author Dmitry (dio) Levashov |
3540 | 3537 | **/ |
@@ -4013,7 +4010,7 @@ discard block |
||
4013 | 4010 | * |
4014 | 4011 | * @param string $command command line |
4015 | 4012 | * @param array $output stdout strings |
4016 | - * @param array $return_var process exit code |
|
4013 | + * @param integer $return_var process exit code |
|
4017 | 4014 | * @param array $error_output stderr strings |
4018 | 4015 | * @return int exit code |
4019 | 4016 | * @author Alexey Sukhotin |
@@ -4225,7 +4222,7 @@ discard block |
||
4225 | 4222 | * @param string $haystack The string being checked. |
4226 | 4223 | * @param string $needle The string to find in haystack. |
4227 | 4224 | * @param int $offset The search offset. If it is not specified, 0 is used. |
4228 | - * @return int|bool |
|
4225 | + * @return integer |
|
4229 | 4226 | * @author Alexey Sukhotin |
4230 | 4227 | **/ |
4231 | 4228 | protected function stripos($haystack , $needle , $offset = 0) { |
@@ -4450,7 +4447,7 @@ discard block |
||
4450 | 4447 | * @param array $files files names list |
4451 | 4448 | * @param string $name archive name |
4452 | 4449 | * @param array $arc archiver options |
4453 | - * @return string|bool |
|
4450 | + * @return string|false |
|
4454 | 4451 | * @author Dmitry (dio) Levashov, |
4455 | 4452 | * @author Alexey Sukhotin |
4456 | 4453 | * @author Naoki Sawada |
@@ -4507,7 +4504,7 @@ discard block |
||
4507 | 4504 | * @param string $dir target dir |
4508 | 4505 | * @param array $files files names list |
4509 | 4506 | * @param string|object $zipPath Zip archive name |
4510 | - * @return void |
|
4507 | + * @return boolean |
|
4511 | 4508 | * @author Naoki Sawada |
4512 | 4509 | */ |
4513 | 4510 | protected static function zipArchiveZip($dir, $files, $zipPath) { |
@@ -4763,7 +4760,7 @@ discard block |
||
4763 | 4760 | * Copy file into another file (only inside one volume) |
4764 | 4761 | * |
4765 | 4762 | * @param string $source source file path |
4766 | - * @param string $target target dir path |
|
4763 | + * @param string $targetDir target dir path |
|
4767 | 4764 | * @param string $name file name |
4768 | 4765 | * @return bool |
4769 | 4766 | * @author Dmitry (dio) Levashov |
@@ -4775,7 +4772,7 @@ discard block |
||
4775 | 4772 | * Return new file path or false. |
4776 | 4773 | * |
4777 | 4774 | * @param string $source source file path |
4778 | - * @param string $target target dir path |
|
4775 | + * @param string $targetDir target dir path |
|
4779 | 4776 | * @param string $name file name |
4780 | 4777 | * @return string|bool |
4781 | 4778 | * @author Dmitry (dio) Levashov |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | 'utf8fix' => false, |
299 | 299 | // й ё Й Ё Ø Å |
300 | 300 | 'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"), |
301 | - 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
301 | + 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
302 | 302 | ); |
303 | 303 | |
304 | 304 | /** |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | **/ |
594 | 594 | protected function configure() { |
595 | 595 | // set ARGS |
596 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
596 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
597 | 597 | // set thumbnails path |
598 | 598 | $path = $this->options['tmbPath']; |
599 | 599 | if ($path) { |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | |
625 | 625 | // check 'statOwner' for command `chmod` |
626 | 626 | if (empty($this->options['statOwner'])) { |
627 | - $this->disabled[] ='chmod'; |
|
627 | + $this->disabled[] = 'chmod'; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | // check 'mimeMap' |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | **/ |
749 | 749 | public function mount(array $opts) { |
750 | 750 | if (!isset($opts['path']) || $opts['path'] === '') { |
751 | - return $this->setError('Path undefined.');; |
|
751 | + return $this->setError('Path undefined.'); ; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | $this->options = array_merge($this->options, $opts); |
@@ -767,14 +767,14 @@ discard block |
||
767 | 767 | $argInit = !empty($this->ARGS['init']); |
768 | 768 | |
769 | 769 | // session cache |
770 | - if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
770 | + if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
771 | 771 | $_SESSION[elFinder::$sessionCacheKey][$this->id] = array(); |
772 | 772 | } |
773 | 773 | $this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id]; |
774 | 774 | |
775 | 775 | // default file attribute |
776 | 776 | $this->defaults = array( |
777 | - 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
777 | + 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
778 | 778 | 'write' => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true, |
779 | 779 | 'locked' => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false, |
780 | 780 | 'hidden' => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false |
@@ -801,8 +801,8 @@ discard block |
||
801 | 801 | $this->access = $this->options['accessControl']; |
802 | 802 | } |
803 | 803 | |
804 | - $this->today = mktime(0,0,0, date('m'), date('d'), date('Y')); |
|
805 | - $this->yesterday = $this->today-86400; |
|
804 | + $this->today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
805 | + $this->yesterday = $this->today - 86400; |
|
806 | 806 | |
807 | 807 | // debug($this->attributes); |
808 | 808 | if (!$this->init()) { |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | foreach ($mimecf as $line_num => $line) { |
902 | 902 | if (!preg_match('/^\s*#/', $line)) { |
903 | 903 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
904 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
904 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
905 | 905 | if (!isset(self::$mimetypes[$mime[$i]])) { |
906 | 906 | self::$mimetypes[$mime[$i]] = $mime[0]; |
907 | 907 | } |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | |
931 | 931 | if ($root['read']) { |
932 | 932 | // check startPath - path to open by default instead of root |
933 | - $startPath = $this->options['startPath']? $this->normpathCE($this->options['startPath']) : ''; |
|
933 | + $startPath = $this->options['startPath'] ? $this->normpathCE($this->options['startPath']) : ''; |
|
934 | 934 | if ($startPath) { |
935 | 935 | $start = $this->stat($startPath); |
936 | 936 | if (!empty($start) |
@@ -954,8 +954,8 @@ discard block |
||
954 | 954 | 'read' => false |
955 | 955 | )); |
956 | 956 | } |
957 | - $this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1; |
|
958 | - $this->tmbSize = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48; |
|
957 | + $this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1; |
|
958 | + $this->tmbSize = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48; |
|
959 | 959 | $this->URL = $this->options['URL']; |
960 | 960 | if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) { |
961 | 961 | $this->URL .= '/'; |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $this->configure(); |
1009 | 1009 | |
1010 | 1010 | // fix sync interval |
1011 | - $options['syncMinMs'] = max($options[$this->options['syncChkAsTs']? 'tsPlSleep' : 'lsPlSleep'] * 1000, intval($options['syncMinMs'])); |
|
1011 | + $options['syncMinMs'] = max($options[$this->options['syncChkAsTs'] ? 'tsPlSleep' : 'lsPlSleep']*1000, intval($options['syncMinMs'])); |
|
1012 | 1012 | |
1013 | 1013 | return $this->mounted = true; |
1014 | 1014 | } |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | public function options($hash) { |
1112 | 1112 | $create = $createext = array(); |
1113 | 1113 | if (isset($this->archivers['create']) && is_array($this->archivers['create'])) { |
1114 | - foreach($this->archivers['create'] as $m => $v) { |
|
1114 | + foreach ($this->archivers['create'] as $m => $v) { |
|
1115 | 1115 | $create[] = $m; |
1116 | 1116 | $createext[$m] = $v['ext']; |
1117 | 1117 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | 'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(), |
1133 | 1133 | 'createext' => $createext |
1134 | 1134 | ), |
1135 | - 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(), |
|
1135 | + 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(), |
|
1136 | 1136 | 'syncChkAsTs' => intval($this->options['syncChkAsTs']), |
1137 | 1137 | 'syncMinMs' => intval($this->options['syncMinMs']) |
1138 | 1138 | ); |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | * @author Naoki Sawada |
1147 | 1147 | */ |
1148 | 1148 | public function getOption($name) { |
1149 | - return isset($this->options[$name])? $this->options[$name] : null; |
|
1149 | + return isset($this->options[$name]) ? $this->options[$name] : null; |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | /** |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | */ |
1159 | 1159 | public function getOptionsPlugin($name = '') { |
1160 | 1160 | if ($name) { |
1161 | - return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array(); |
|
1161 | + return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array(); |
|
1162 | 1162 | } else { |
1163 | 1163 | return $this->options['plugin']; |
1164 | 1164 | } |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | $file = $this->stat($path); |
1293 | 1293 | |
1294 | 1294 | if ($isRoot) { |
1295 | - $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(); |
|
1295 | + $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(); |
|
1296 | 1296 | $file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON |
1297 | 1297 | } |
1298 | 1298 | |
@@ -1307,7 +1307,7 @@ discard block |
||
1307 | 1307 | * @return array|false |
1308 | 1308 | * @author Dmitry (dio) Levashov |
1309 | 1309 | **/ |
1310 | - public function dir($hash, $resolveLink=false) { |
|
1310 | + public function dir($hash, $resolveLink = false) { |
|
1311 | 1311 | if (($dir = $this->file($hash)) == false) { |
1312 | 1312 | return $this->setError(elFinder::ERROR_DIR_NOT_FOUND); |
1313 | 1313 | } |
@@ -1371,14 +1371,14 @@ discard block |
||
1371 | 1371 | * @return array|false |
1372 | 1372 | * @author Dmitry (dio) Levashov |
1373 | 1373 | **/ |
1374 | - public function tree($hash='', $deep=0, $exclude='') { |
|
1374 | + public function tree($hash = '', $deep = 0, $exclude = '') { |
|
1375 | 1375 | $path = $hash ? $this->decode($hash) : $this->root; |
1376 | 1376 | |
1377 | 1377 | if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') { |
1378 | 1378 | return false; |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - $dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null); |
|
1381 | + $dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null); |
|
1382 | 1382 | array_unshift($dirs, $dir); |
1383 | 1383 | return $dirs; |
1384 | 1384 | } |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | * @return array|false |
1609 | 1609 | * @author Dmitry (dio) Levashov |
1610 | 1610 | **/ |
1611 | - public function duplicate($hash, $suffix='copy') { |
|
1611 | + public function duplicate($hash, $suffix = 'copy') { |
|
1612 | 1612 | if ($this->commandDisabled('duplicate')) { |
1613 | 1613 | return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED); |
1614 | 1614 | } |
@@ -1684,7 +1684,7 @@ discard block |
||
1684 | 1684 | |
1685 | 1685 | if ($file) { // file exists |
1686 | 1686 | // check POST data `overwrite` for 3rd party uploader |
1687 | - $overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1687 | + $overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1688 | 1688 | if ($overwrite) { |
1689 | 1689 | if (!$file['write']) { |
1690 | 1690 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
@@ -1755,7 +1755,7 @@ discard block |
||
1755 | 1755 | if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) { |
1756 | 1756 | return $rmSrc |
1757 | 1757 | ? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test)) |
1758 | - : $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1758 | + : $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1759 | 1759 | } |
1760 | 1760 | |
1761 | 1761 | $test = $this->joinPathCE($destination, $name); |
@@ -1918,7 +1918,7 @@ discard block |
||
1918 | 1918 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
1919 | 1919 | } |
1920 | 1920 | $this->clearcache(); |
1921 | - $this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir; |
|
1921 | + $this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir; |
|
1922 | 1922 | |
1923 | 1923 | if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) { |
1924 | 1924 | if (is_array($path)) { |
@@ -1976,9 +1976,9 @@ discard block |
||
1976 | 1976 | if ($name === '') { |
1977 | 1977 | $name = count($files) == 1 ? $files[0] : 'Archive'; |
1978 | 1978 | } else { |
1979 | - $name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name)); |
|
1979 | + $name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name)); |
|
1980 | 1980 | } |
1981 | - $name .='.' . $archiver['ext']; |
|
1981 | + $name .= '.'.$archiver['ext']; |
|
1982 | 1982 | $name = $this->uniqueName($dir, $name, ''); |
1983 | 1983 | $this->clearcache(); |
1984 | 1984 | return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false; |
@@ -2017,7 +2017,7 @@ discard block |
||
2017 | 2017 | |
2018 | 2018 | $path = $this->decode($hash); |
2019 | 2019 | |
2020 | - $work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path); |
|
2020 | + $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path); |
|
2021 | 2021 | |
2022 | 2022 | if (!$work_path || !is_writable($work_path)) { |
2023 | 2023 | if ($work_path && $path !== $work_path && is_file($work_path)) { |
@@ -2032,7 +2032,7 @@ discard block |
||
2032 | 2032 | } |
2033 | 2033 | } |
2034 | 2034 | |
2035 | - switch($mode) { |
|
2035 | + switch ($mode) { |
|
2036 | 2036 | |
2037 | 2037 | case 'propresize': |
2038 | 2038 | $result = $this->imgResize($work_path, $width, $height, true, true, null, $jpgQuality); |
@@ -2128,7 +2128,7 @@ discard block |
||
2128 | 2128 | } |
2129 | 2129 | return ($q === '' || $this->commandDisabled('search')) |
2130 | 2130 | ? array() |
2131 | - : $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes); |
|
2131 | + : $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes); |
|
2132 | 2132 | } |
2133 | 2133 | |
2134 | 2134 | /** |
@@ -2200,9 +2200,9 @@ discard block |
||
2200 | 2200 | $path = ltrim($path, $this->separator); |
2201 | 2201 | $dirs = explode($this->separator, $path); |
2202 | 2202 | array_pop($dirs); |
2203 | - foreach($dirs as $dir) { |
|
2203 | + foreach ($dirs as $dir) { |
|
2204 | 2204 | $targetPath = $this->joinPathCE($base, $dir); |
2205 | - if (! $_realpath = $this->realpath($this->encode($targetPath))) { |
|
2205 | + if (!$_realpath = $this->realpath($this->encode($targetPath))) { |
|
2206 | 2206 | if ($stat = $this->mkdir($targetHash, $dir)) { |
2207 | 2207 | $result['added'][] = $stat; |
2208 | 2208 | $targetHash = $stat['hash']; |
@@ -2269,7 +2269,7 @@ discard block |
||
2269 | 2269 | * @author Naoki Sawada |
2270 | 2270 | **/ |
2271 | 2271 | protected function dirnameCE($path) { |
2272 | - return (!$this->encoding)? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2272 | + return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2273 | 2273 | } |
2274 | 2274 | |
2275 | 2275 | /** |
@@ -2280,7 +2280,7 @@ discard block |
||
2280 | 2280 | * @author Naoki Sawada |
2281 | 2281 | **/ |
2282 | 2282 | protected function basenameCE($path) { |
2283 | - return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2283 | + return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2284 | 2284 | } |
2285 | 2285 | |
2286 | 2286 | /** |
@@ -2293,7 +2293,7 @@ discard block |
||
2293 | 2293 | * @author Naoki Sawada |
2294 | 2294 | **/ |
2295 | 2295 | protected function joinPathCE($dir, $name) { |
2296 | - return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2296 | + return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2297 | 2297 | } |
2298 | 2298 | |
2299 | 2299 | /** |
@@ -2304,7 +2304,7 @@ discard block |
||
2304 | 2304 | * @author Naoki Sawada |
2305 | 2305 | **/ |
2306 | 2306 | protected function normpathCE($path) { |
2307 | - return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2307 | + return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2308 | 2308 | } |
2309 | 2309 | |
2310 | 2310 | /** |
@@ -2315,7 +2315,7 @@ discard block |
||
2315 | 2315 | * @author Naoki Sawada |
2316 | 2316 | **/ |
2317 | 2317 | protected function relpathCE($path) { |
2318 | - return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2318 | + return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2319 | 2319 | } |
2320 | 2320 | |
2321 | 2321 | /** |
@@ -2326,7 +2326,7 @@ discard block |
||
2326 | 2326 | * @author Naoki Sawada |
2327 | 2327 | **/ |
2328 | 2328 | protected function abspathCE($path) { |
2329 | - return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2329 | + return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2330 | 2330 | } |
2331 | 2331 | |
2332 | 2332 | /** |
@@ -2338,7 +2338,7 @@ discard block |
||
2338 | 2338 | * @author Naoki Sawada |
2339 | 2339 | **/ |
2340 | 2340 | protected function inpathCE($path, $parent) { |
2341 | - return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2341 | + return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2342 | 2342 | } |
2343 | 2343 | |
2344 | 2344 | /** |
@@ -2349,8 +2349,8 @@ discard block |
||
2349 | 2349 | * @return resource|false |
2350 | 2350 | * @author Naoki Sawada |
2351 | 2351 | **/ |
2352 | - protected function fopenCE($path, $mode='rb') { |
|
2353 | - return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2352 | + protected function fopenCE($path, $mode = 'rb') { |
|
2353 | + return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2354 | 2354 | } |
2355 | 2355 | |
2356 | 2356 | /** |
@@ -2361,8 +2361,8 @@ discard block |
||
2361 | 2361 | * @return bool |
2362 | 2362 | * @author Naoki Sawada |
2363 | 2363 | **/ |
2364 | - protected function fcloseCE($fp, $path='') { |
|
2365 | - return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2364 | + protected function fcloseCE($fp, $path = '') { |
|
2365 | + return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2366 | 2366 | } |
2367 | 2367 | |
2368 | 2368 | /** |
@@ -2377,7 +2377,7 @@ discard block |
||
2377 | 2377 | * @author Naoki Sawada |
2378 | 2378 | **/ |
2379 | 2379 | protected function saveCE($fp, $dir, $name, $stat) { |
2380 | - return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2380 | + return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2381 | 2381 | } |
2382 | 2382 | |
2383 | 2383 | /** |
@@ -2389,7 +2389,7 @@ discard block |
||
2389 | 2389 | **/ |
2390 | 2390 | protected function subdirsCE($path) { |
2391 | 2391 | if (!isset($this->subdirsCache[$path])) { |
2392 | - $this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2392 | + $this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2393 | 2393 | } |
2394 | 2394 | return $this->subdirsCache[$path]; |
2395 | 2395 | } |
@@ -2402,7 +2402,7 @@ discard block |
||
2402 | 2402 | * @author Naoki Sawada |
2403 | 2403 | **/ |
2404 | 2404 | protected function scandirCE($path) { |
2405 | - return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2405 | + return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2406 | 2406 | } |
2407 | 2407 | |
2408 | 2408 | /** |
@@ -2415,7 +2415,7 @@ discard block |
||
2415 | 2415 | * @author Naoki Sawada |
2416 | 2416 | **/ |
2417 | 2417 | protected function symlinkCE($source, $targetDir, $name) { |
2418 | - return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2418 | + return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2419 | 2419 | } |
2420 | 2420 | |
2421 | 2421 | /***************** paths *******************/ |
@@ -2434,7 +2434,7 @@ discard block |
||
2434 | 2434 | // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root |
2435 | 2435 | $p = $this->relpathCE($path); |
2436 | 2436 | // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt |
2437 | - if ($p === '') { |
|
2437 | + if ($p === '') { |
|
2438 | 2438 | $p = DIRECTORY_SEPARATOR; |
2439 | 2439 | } |
2440 | 2440 | |
@@ -2467,7 +2467,7 @@ discard block |
||
2467 | 2467 | // TODO uncrypt hash and return path |
2468 | 2468 | $path = $this->uncrypt($h); |
2469 | 2469 | // append ROOT to path after it was cut in encode |
2470 | - return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2470 | + return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2471 | 2471 | } |
2472 | 2472 | } |
2473 | 2473 | |
@@ -2527,21 +2527,21 @@ discard block |
||
2527 | 2527 | * @author Dmitry (dio) Levashov |
2528 | 2528 | **/ |
2529 | 2529 | public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) { |
2530 | - $ext = ''; |
|
2530 | + $ext = ''; |
|
2531 | 2531 | |
2532 | 2532 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
2533 | 2533 | $ext = '.'.$m[1]; |
2534 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
2534 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
2535 | 2535 | } |
2536 | 2536 | |
2537 | 2537 | if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) { |
2538 | - $i = (int)$m[2]; |
|
2539 | - $name = substr($name, 0, strlen($name)-strlen($m[2])); |
|
2538 | + $i = (int) $m[2]; |
|
2539 | + $name = substr($name, 0, strlen($name) - strlen($m[2])); |
|
2540 | 2540 | } else { |
2541 | 2541 | $i = $start; |
2542 | 2542 | $name .= $suffix; |
2543 | 2543 | } |
2544 | - $max = $i+100000; |
|
2544 | + $max = $i + 100000; |
|
2545 | 2545 | |
2546 | 2546 | while ($i <= $max) { |
2547 | 2547 | $n = $name.($i > 0 ? $i : '').$ext; |
@@ -2565,7 +2565,7 @@ discard block |
||
2565 | 2565 | * @author Naoki Sawada |
2566 | 2566 | */ |
2567 | 2567 | public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') { |
2568 | - return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2568 | + return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2569 | 2569 | } |
2570 | 2570 | |
2571 | 2571 | /** |
@@ -2578,7 +2578,7 @@ discard block |
||
2578 | 2578 | * @author Naoki Sawada |
2579 | 2579 | */ |
2580 | 2580 | public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') { |
2581 | - return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2581 | + return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2582 | 2582 | } |
2583 | 2583 | |
2584 | 2584 | /** |
@@ -2598,7 +2598,7 @@ discard block |
||
2598 | 2598 | } |
2599 | 2599 | if (is_array($var)) { |
2600 | 2600 | $_ret = array(); |
2601 | - foreach($var as $_k => $_v) { |
|
2601 | + foreach ($var as $_k => $_v) { |
|
2602 | 2602 | $_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_'); |
2603 | 2603 | } |
2604 | 2604 | $var = $_ret; |
@@ -2610,7 +2610,7 @@ discard block |
||
2610 | 2610 | $_var = str_replace('?', $unknown, $_var); |
2611 | 2611 | } |
2612 | 2612 | } |
2613 | - if ($_var !== false) { |
|
2613 | + if ($_var !== false) { |
|
2614 | 2614 | $var = $_var; |
2615 | 2615 | } |
2616 | 2616 | } |
@@ -2637,7 +2637,7 @@ discard block |
||
2637 | 2637 | |
2638 | 2638 | $key = ''; |
2639 | 2639 | if ($path !== '') { |
2640 | - $key = $this->id . '#' . $path; |
|
2640 | + $key = $this->id.'#'.$path; |
|
2641 | 2641 | if (isset($cache[$key])) { |
2642 | 2642 | return $cache[$key]; |
2643 | 2643 | } |
@@ -2669,7 +2669,7 @@ discard block |
||
2669 | 2669 | if ($work = $this->getTempFile()) { |
2670 | 2670 | if ($wfp = fopen($work, 'wb')) { |
2671 | 2671 | if ($fp = $this->_fopen($path)) { |
2672 | - while(!feof($fp)) { |
|
2672 | + while (!feof($fp)) { |
|
2673 | 2673 | fwrite($wfp, fread($fp, 8192)); |
2674 | 2674 | } |
2675 | 2675 | $this->_fclose($fp, $path); |
@@ -2713,7 +2713,7 @@ discard block |
||
2713 | 2713 | @set_time_limit(30); |
2714 | 2714 | $stat = $this->stat($this->convEncOut($p)); |
2715 | 2715 | $this->convEncIn(); |
2716 | - ($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p); |
|
2716 | + ($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p); |
|
2717 | 2717 | } |
2718 | 2718 | return $this->_rmdir($localpath); |
2719 | 2719 | } |
@@ -2730,7 +2730,7 @@ discard block |
||
2730 | 2730 | * @return bool |
2731 | 2731 | * @author Dmitry (dio) Levashov |
2732 | 2732 | **/ |
2733 | - protected function attr($path, $name, $val=null, $isDir=null) { |
|
2733 | + protected function attr($path, $name, $val = null, $isDir = null) { |
|
2734 | 2734 | if (!isset($this->defaults[$name])) { |
2735 | 2735 | return false; |
2736 | 2736 | } |
@@ -2762,7 +2762,7 @@ discard block |
||
2762 | 2762 | } |
2763 | 2763 | } |
2764 | 2764 | |
2765 | - return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm; |
|
2765 | + return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm; |
|
2766 | 2766 | } |
2767 | 2767 | |
2768 | 2768 | /** |
@@ -2806,7 +2806,7 @@ discard block |
||
2806 | 2806 | protected function allowPutMime($mime) { |
2807 | 2807 | // logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order |
2808 | 2808 | $allow = $this->mimeAccepted($mime, $this->uploadAllow, null); |
2809 | - $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2809 | + $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2810 | 2810 | $res = true; // default to allow |
2811 | 2811 | if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny' |
2812 | 2812 | $res = false; // default is deny |
@@ -2840,7 +2840,7 @@ discard block |
||
2840 | 2840 | $this->sessionCache['rootstat'] = array(); |
2841 | 2841 | } |
2842 | 2842 | //if (empty($this->ARGS['reload']) || empty($this->ARGS['target']) || strpos($this->ARGS['target'], $this->id) !== 0) { |
2843 | - if (! $this->isMyReload()) { |
|
2843 | + if (!$this->isMyReload()) { |
|
2844 | 2844 | // need $path as key for netmount/netunmount |
2845 | 2845 | if (isset($this->sessionCache['rootstat'][$rootKey])) { |
2846 | 2846 | if ($ret = elFinder::sessionDataDecode($this->sessionCache['rootstat'][$rootKey], 'array')) { |
@@ -2880,10 +2880,10 @@ discard block |
||
2880 | 2880 | if ($this->rootName) { |
2881 | 2881 | $stat['name'] = $this->rootName; |
2882 | 2882 | } |
2883 | - if (! empty($this->options['icon'])) { |
|
2883 | + if (!empty($this->options['icon'])) { |
|
2884 | 2884 | $stat['icon'] = $this->options['icon']; |
2885 | 2885 | } |
2886 | - if (! empty($this->options['rootCssClass'])) { |
|
2886 | + if (!empty($this->options['rootCssClass'])) { |
|
2887 | 2887 | $stat['csscls'] = $this->options['rootCssClass']; |
2888 | 2888 | } |
2889 | 2889 | } else { |
@@ -2931,7 +2931,7 @@ discard block |
||
2931 | 2931 | // lock when parent directory is not writable |
2932 | 2932 | if (!isset($stat['locked'])) { |
2933 | 2933 | $parent = $this->dirnameCE($path); |
2934 | - $pstat = isset($this->cache[$parent])? $this->cache[$parent] : array(); |
|
2934 | + $pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array(); |
|
2935 | 2935 | if (isset($pstat['write']) && !$pstat['write']) { |
2936 | 2936 | $stat['locked'] = true; |
2937 | 2937 | } |
@@ -2989,7 +2989,7 @@ discard block |
||
2989 | 2989 | } |
2990 | 2990 | if (!isset($stat['url']) && $this->URL && $this->encoding) { |
2991 | 2991 | $_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1)); |
2992 | - $stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true))); |
|
2992 | + $stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true))); |
|
2993 | 2993 | } |
2994 | 2994 | } else { |
2995 | 2995 | if ($isDir) { |
@@ -3112,7 +3112,7 @@ discard block |
||
3112 | 3112 | foreach ($mimecf as $line_num => $line) { |
3113 | 3113 | if (!preg_match('/^\s*#/', $line)) { |
3114 | 3114 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
3115 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
3115 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
3116 | 3116 | if (!isset(elFinderVolumeDriver::$mimetypes[$mime[$i]])) { |
3117 | 3117 | elFinderVolumeDriver::$mimetypes[$mime[$i]] = $mime[0]; |
3118 | 3118 | } |
@@ -3218,10 +3218,10 @@ discard block |
||
3218 | 3218 | } |
3219 | 3219 | |
3220 | 3220 | protected function isMyReload($target = '', $ARGtarget = '') { |
3221 | - if (! empty($this->ARGS['reload'])) { |
|
3221 | + if (!empty($this->ARGS['reload'])) { |
|
3222 | 3222 | if ($ARGtarget === '') { |
3223 | - $ARGtarget = isset($this->ARGS['target'])? $this->ARGS['target'] |
|
3224 | - : ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1)? |
|
3223 | + $ARGtarget = isset($this->ARGS['target']) ? $this->ARGS['target'] |
|
3224 | + : ((isset($this->ARGS['targets']) && is_array($this->ARGS['targets']) && count($this->ARGS['targets']) === 1) ? |
|
3225 | 3225 | $this->ARGS['targets'][0] : ''); |
3226 | 3226 | } |
3227 | 3227 | if ($ARGtarget !== '') { |
@@ -3270,7 +3270,7 @@ discard block |
||
3270 | 3270 | * @return array |
3271 | 3271 | * @author Dmitry (dio) Levashov |
3272 | 3272 | **/ |
3273 | - protected function gettree($path, $deep, $exclude='') { |
|
3273 | + protected function gettree($path, $deep, $exclude = '') { |
|
3274 | 3274 | $dirs = array(); |
3275 | 3275 | |
3276 | 3276 | !isset($this->dirsCache[$path]) && $this->cacheDir($path); |
@@ -3281,7 +3281,7 @@ discard block |
||
3281 | 3281 | if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') { |
3282 | 3282 | $dirs[] = $stat; |
3283 | 3283 | if ($deep > 0 && !empty($stat['dirs'])) { |
3284 | - $dirs = array_merge($dirs, $this->gettree($p, $deep-1)); |
|
3284 | + $dirs = array_merge($dirs, $this->gettree($p, $deep - 1)); |
|
3285 | 3285 | } |
3286 | 3286 | } |
3287 | 3287 | } |
@@ -3301,7 +3301,7 @@ discard block |
||
3301 | 3301 | protected function doSearch($path, $q, $mimes) { |
3302 | 3302 | $result = array(); |
3303 | 3303 | |
3304 | - foreach($this->scandirCE($path) as $p) { |
|
3304 | + foreach ($this->scandirCE($path) as $p) { |
|
3305 | 3305 | @set_time_limit(30); |
3306 | 3306 | $stat = $this->stat($p); |
3307 | 3307 | |
@@ -3322,7 +3322,7 @@ discard block |
||
3322 | 3322 | if ($this->encoding) { |
3323 | 3323 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
3324 | 3324 | } |
3325 | - $stat['url'] = $this->URL . $path; |
|
3325 | + $stat['url'] = $this->URL.$path; |
|
3326 | 3326 | } |
3327 | 3327 | |
3328 | 3328 | $result[] = $stat; |
@@ -3356,7 +3356,7 @@ discard block |
||
3356 | 3356 | if (!$this->inpathCE($target, $this->root)) { |
3357 | 3357 | return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK); |
3358 | 3358 | } |
3359 | - $stat = $this->stat($target); |
|
3359 | + $stat = $this->stat($target); |
|
3360 | 3360 | $this->clearcache(); |
3361 | 3361 | return $stat && $this->symlinkCE($target, $dst, $name) |
3362 | 3362 | ? $this->joinPathCE($dst, $name) |
@@ -3637,15 +3637,15 @@ discard block |
||
3637 | 3637 | } |
3638 | 3638 | |
3639 | 3639 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
3640 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3641 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3640 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3641 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3642 | 3642 | } else { |
3643 | 3643 | |
3644 | 3644 | if ($this->options['tmbCrop']) { |
3645 | 3645 | |
3646 | 3646 | $result = $tmb; |
3647 | 3647 | /* Resize and crop if image bigger than thumbnail */ |
3648 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3648 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3649 | 3649 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
3650 | 3650 | } |
3651 | 3651 | |
@@ -3662,7 +3662,7 @@ discard block |
||
3662 | 3662 | } |
3663 | 3663 | |
3664 | 3664 | if ($result) { |
3665 | - $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3665 | + $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3666 | 3666 | } |
3667 | 3667 | } |
3668 | 3668 | |
@@ -3708,18 +3708,18 @@ discard block |
||
3708 | 3708 | /* Resizing by biggest side */ |
3709 | 3709 | if ($resizeByBiggerSide) { |
3710 | 3710 | if ($orig_w > $orig_h) { |
3711 | - $size_h = round($orig_h * $width / $orig_w); |
|
3711 | + $size_h = round($orig_h*$width/$orig_w); |
|
3712 | 3712 | $size_w = $width; |
3713 | 3713 | } else { |
3714 | - $size_w = round($orig_w * $height / $orig_h); |
|
3714 | + $size_w = round($orig_w*$height/$orig_h); |
|
3715 | 3715 | $size_h = $height; |
3716 | 3716 | } |
3717 | 3717 | } else { |
3718 | 3718 | if ($orig_w > $orig_h) { |
3719 | - $size_w = round($orig_w * $height / $orig_h); |
|
3719 | + $size_w = round($orig_w*$height/$orig_h); |
|
3720 | 3720 | $size_h = $height; |
3721 | 3721 | } else { |
3722 | - $size_h = round($orig_h * $width / $orig_w); |
|
3722 | + $size_h = round($orig_h*$width/$orig_w); |
|
3723 | 3723 | $size_w = $width; |
3724 | 3724 | } |
3725 | 3725 | } |
@@ -3737,7 +3737,7 @@ discard block |
||
3737 | 3737 | // Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb |
3738 | 3738 | // resize bench: http://app-mgng.rhcloud.com/9 |
3739 | 3739 | // resize sample: http://www.dylanbeattie.net/magick/filters/result.html |
3740 | - $filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3740 | + $filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3741 | 3741 | |
3742 | 3742 | $ani = ($img->getNumberImages() > 1); |
3743 | 3743 | if ($ani && is_null($destformat)) { |
@@ -3762,11 +3762,11 @@ discard block |
||
3762 | 3762 | break; |
3763 | 3763 | |
3764 | 3764 | case 'gd': |
3765 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
3765 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
3766 | 3766 | |
3767 | - if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3767 | + if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3768 | 3768 | |
3769 | - $this->gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3769 | + $this->gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3770 | 3770 | |
3771 | 3771 | if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) { |
3772 | 3772 | return false; |
@@ -3847,11 +3847,11 @@ discard block |
||
3847 | 3847 | break; |
3848 | 3848 | |
3849 | 3849 | case 'gd': |
3850 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
3850 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
3851 | 3851 | |
3852 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3852 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3853 | 3853 | |
3854 | - $this->gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3854 | + $this->gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3855 | 3855 | |
3856 | 3856 | $size_w = $width; |
3857 | 3857 | $size_h = $height; |
@@ -3902,8 +3902,8 @@ discard block |
||
3902 | 3902 | $result = false; |
3903 | 3903 | |
3904 | 3904 | /* Coordinates for image over square aligning */ |
3905 | - $y = ceil(abs($height - $s[1]) / 2); |
|
3906 | - $x = ceil(abs($width - $s[0]) / 2); |
|
3905 | + $y = ceil(abs($height - $s[1])/2); |
|
3906 | + $x = ceil(abs($width - $s[0])/2); |
|
3907 | 3907 | |
3908 | 3908 | if (!$jpgQuality) { |
3909 | 3909 | $jpgQuality = $this->options['jpgQuality']; |
@@ -3927,7 +3927,7 @@ discard block |
||
3927 | 3927 | $gif->newImage($width, $height, new ImagickPixel($bgcolor)); |
3928 | 3928 | $gif->setImageColorspace($img->getImageColorspace()); |
3929 | 3929 | $gif->setImageFormat('gif'); |
3930 | - $gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3930 | + $gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3931 | 3931 | $gif->setImageDelay($img->getImageDelay()); |
3932 | 3932 | $gif->setImageIterations($img->getImageIterations()); |
3933 | 3933 | $img1->addImage($gif); |
@@ -3942,7 +3942,7 @@ discard block |
||
3942 | 3942 | $img1 = new Imagick(); |
3943 | 3943 | $img1->newImage($width, $height, new ImagickPixel($bgcolor)); |
3944 | 3944 | $img1->setImageColorspace($img->getImageColorspace()); |
3945 | - $img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3945 | + $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3946 | 3946 | $result = $this->imagickImage($img, $path, $destformat, $jpgQuality); |
3947 | 3947 | } |
3948 | 3948 | |
@@ -3953,11 +3953,11 @@ discard block |
||
3953 | 3953 | break; |
3954 | 3954 | |
3955 | 3955 | case 'gd': |
3956 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
3956 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
3957 | 3957 | |
3958 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3958 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3959 | 3959 | |
3960 | - $this->gdImageBackground($tmp,$bgcolor); |
|
3960 | + $this->gdImageBackground($tmp, $bgcolor); |
|
3961 | 3961 | |
3962 | 3962 | if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) { |
3963 | 3963 | return false; |
@@ -3989,15 +3989,15 @@ discard block |
||
3989 | 3989 | * @author Troex Nevelin |
3990 | 3990 | **/ |
3991 | 3991 | protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null, $jpgQuality = null) { |
3992 | - if (($s = @getimagesize($path)) == false || $degree % 360 === 0) { |
|
3992 | + if (($s = @getimagesize($path)) == false || $degree%360 === 0) { |
|
3993 | 3993 | return false; |
3994 | 3994 | } |
3995 | 3995 | |
3996 | 3996 | $result = false; |
3997 | 3997 | |
3998 | 3998 | // try lossless rotate |
3999 | - if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
4000 | - $count = ($degree / 90) % 4; |
|
3999 | + if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
4000 | + $count = ($degree/90)%4; |
|
4001 | 4001 | $exiftran = array( |
4002 | 4002 | 1 => '-9', |
4003 | 4003 | 2 => '-1', |
@@ -4013,7 +4013,7 @@ discard block |
||
4013 | 4013 | 'exiftran -i '.$exiftran[$count].' '.$path, |
4014 | 4014 | 'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath |
4015 | 4015 | ); |
4016 | - foreach($cmds as $cmd) { |
|
4016 | + foreach ($cmds as $cmd) { |
|
4017 | 4017 | if ($this->procExec($cmd) === 0) { |
4018 | 4018 | $result = true; |
4019 | 4019 | break; |
@@ -4053,12 +4053,12 @@ discard block |
||
4053 | 4053 | break; |
4054 | 4054 | |
4055 | 4055 | case 'gd': |
4056 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
4056 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
4057 | 4057 | |
4058 | 4058 | $degree = 360 - $degree; |
4059 | 4059 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
4060 | 4060 | $bgcolor = imagecolorallocate($img, $r, $g, $b); |
4061 | - $tmp = imageRotate($img, $degree, (int)$bgcolor); |
|
4061 | + $tmp = imageRotate($img, $degree, (int) $bgcolor); |
|
4062 | 4062 | |
4063 | 4063 | $result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality); |
4064 | 4064 | |
@@ -4083,11 +4083,11 @@ discard block |
||
4083 | 4083 | * @return int exit code |
4084 | 4084 | * @author Alexey Sukhotin |
4085 | 4085 | **/ |
4086 | - protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
4086 | + protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
4087 | 4087 | |
4088 | 4088 | $descriptorspec = array( |
4089 | - 0 => array("pipe", "r"), // stdin |
|
4090 | - 1 => array("pipe", "w"), // stdout |
|
4089 | + 0 => array("pipe", "r"), // stdin |
|
4090 | + 1 => array("pipe", "w"), // stdout |
|
4091 | 4091 | 2 => array("pipe", "w") // stderr |
4092 | 4092 | ); |
4093 | 4093 | |
@@ -4144,8 +4144,8 @@ discard block |
||
4144 | 4144 | * @param string $mime |
4145 | 4145 | * @return gd image resource identifier |
4146 | 4146 | */ |
4147 | - protected function gdImageCreate($path,$mime){ |
|
4148 | - switch($mime){ |
|
4147 | + protected function gdImageCreate($path, $mime) { |
|
4148 | + switch ($mime) { |
|
4149 | 4149 | case 'image/jpeg': |
4150 | 4150 | return imagecreatefromjpeg($path); |
4151 | 4151 | |
@@ -4170,7 +4170,7 @@ discard block |
||
4170 | 4170 | * @param string $mime The original image mime type |
4171 | 4171 | * @param int $jpgQuality JEPG quality (1-100) |
4172 | 4172 | */ |
4173 | - protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null ){ |
|
4173 | + protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null) { |
|
4174 | 4174 | |
4175 | 4175 | if (!$jpgQuality) { |
4176 | 4176 | $jpgQuality = $this->options['jpgQuality']; |
@@ -4194,7 +4194,7 @@ discard block |
||
4194 | 4194 | * @param string $destformat The Image type to use for $filename |
4195 | 4195 | * @param int $jpgQuality JEPG quality (1-100) |
4196 | 4196 | */ |
4197 | - protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ){ |
|
4197 | + protected function imagickImage($img, $filename, $destformat, $jpgQuality = null) { |
|
4198 | 4198 | |
4199 | 4199 | if (!$jpgQuality) { |
4200 | 4200 | $jpgQuality = $this->options['jpgQuality']; |
@@ -4249,13 +4249,13 @@ discard block |
||
4249 | 4249 | * @param resource $image gd image resource |
4250 | 4250 | * @param string $bgcolor background color in #rrggbb format |
4251 | 4251 | */ |
4252 | - protected function gdImageBackground($image, $bgcolor){ |
|
4252 | + protected function gdImageBackground($image, $bgcolor) { |
|
4253 | 4253 | |
4254 | - if( $bgcolor == 'transparent' ){ |
|
4255 | - imagesavealpha($image,true); |
|
4254 | + if ($bgcolor == 'transparent') { |
|
4255 | + imagesavealpha($image, true); |
|
4256 | 4256 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
4257 | 4257 | |
4258 | - }else{ |
|
4258 | + } else { |
|
4259 | 4259 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
4260 | 4260 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
4261 | 4261 | } |
@@ -4293,13 +4293,13 @@ discard block |
||
4293 | 4293 | * @return int|bool |
4294 | 4294 | * @author Alexey Sukhotin |
4295 | 4295 | **/ |
4296 | - protected function stripos($haystack , $needle , $offset = 0) { |
|
4296 | + protected function stripos($haystack, $needle, $offset = 0) { |
|
4297 | 4297 | if (function_exists('mb_stripos')) { |
4298 | - return mb_stripos($haystack , $needle , $offset, 'UTF-8'); |
|
4298 | + return mb_stripos($haystack, $needle, $offset, 'UTF-8'); |
|
4299 | 4299 | } else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) { |
4300 | 4300 | return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset); |
4301 | 4301 | } |
4302 | - return stripos($haystack , $needle , $offset); |
|
4302 | + return stripos($haystack, $needle, $offset); |
|
4303 | 4303 | } |
4304 | 4304 | |
4305 | 4305 | /** |
@@ -4349,22 +4349,22 @@ discard block |
||
4349 | 4349 | unset($o); |
4350 | 4350 | $this->procExec('zip -v', $o, $c); |
4351 | 4351 | if ($c == 0) { |
4352 | - $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4352 | + $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4353 | 4353 | } |
4354 | 4354 | unset($o); |
4355 | 4355 | $this->procExec('unzip --help', $o, $c); |
4356 | 4356 | if ($c == 0) { |
4357 | - $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4357 | + $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4358 | 4358 | } |
4359 | 4359 | unset($o); |
4360 | 4360 | $this->procExec('rar --version', $o, $c); |
4361 | 4361 | if ($c == 0 || $c == 7) { |
4362 | 4362 | $arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar'); |
4363 | - $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4363 | + $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4364 | 4364 | } else { |
4365 | 4365 | unset($o); |
4366 | 4366 | $test = $this->procExec('unrar', $o, $c); |
4367 | - if ($c==0 || $c == 7) { |
|
4367 | + if ($c == 0 || $c == 7) { |
|
4368 | 4368 | $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar'); |
4369 | 4369 | } |
4370 | 4370 | } |
@@ -4386,7 +4386,7 @@ discard block |
||
4386 | 4386 | if (empty($arcs['extract']['application/x-tar'])) { |
4387 | 4387 | $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar'); |
4388 | 4388 | } |
4389 | - } else if (substr(PHP_OS,0,3) === 'WIN') { |
|
4389 | + } else if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
4390 | 4390 | // check `7z` for Windows server. |
4391 | 4391 | unset($o); |
4392 | 4392 | $this->procExec('7z', $o, $c); |
@@ -4440,22 +4440,22 @@ discard block |
||
4440 | 4440 | |
4441 | 4441 | // normalize `/../` |
4442 | 4442 | $normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#'; |
4443 | - while(preg_match($normreg, $path)) { |
|
4443 | + while (preg_match($normreg, $path)) { |
|
4444 | 4444 | $path = preg_replace($normreg, '$1', $path); |
4445 | 4445 | } |
4446 | 4446 | |
4447 | 4447 | // 'Here' |
4448 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
4448 | + if ($path === '' || $path === '.'.$separator) return $base; |
|
4449 | 4449 | |
4450 | 4450 | // Absolute path |
4451 | 4451 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
4452 | 4452 | return $path; |
4453 | 4453 | } |
4454 | 4454 | |
4455 | - $preg_separator = '#' . $sepquoted . '#'; |
|
4455 | + $preg_separator = '#'.$sepquoted.'#'; |
|
4456 | 4456 | |
4457 | 4457 | // Relative path from 'Here' |
4458 | - if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) { |
|
4458 | + if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) { |
|
4459 | 4459 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4460 | 4460 | if ($arrn[0] !== '.') { |
4461 | 4461 | array_unshift($arrn, '.'); |
@@ -4469,12 +4469,11 @@ discard block |
||
4469 | 4469 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4470 | 4470 | $arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY); |
4471 | 4471 | |
4472 | - while (! empty($arrn) && $arrn[0] === '..') { |
|
4472 | + while (!empty($arrn) && $arrn[0] === '..') { |
|
4473 | 4473 | array_shift($arrn); |
4474 | 4474 | array_pop($arrp); |
4475 | 4475 | } |
4476 | - $path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) : |
|
4477 | - (! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot); |
|
4476 | + $path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot); |
|
4478 | 4477 | } |
4479 | 4478 | |
4480 | 4479 | return $path; |
@@ -4492,7 +4491,7 @@ discard block |
||
4492 | 4491 | @chmod($dir, 0777); |
4493 | 4492 | foreach (array_diff(scandir($dir), array('.', '..')) as $file) { |
4494 | 4493 | @set_time_limit(30); |
4495 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4494 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4496 | 4495 | if (!is_link($dir) && is_dir($path)) { |
4497 | 4496 | $this->rmdirRecursive($path); |
4498 | 4497 | } else { |
@@ -4579,22 +4578,22 @@ discard block |
||
4579 | 4578 | try { |
4580 | 4579 | if ($start = is_string($zipPath)) { |
4581 | 4580 | $zip = new ZipArchive(); |
4582 | - if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) { |
|
4581 | + if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) { |
|
4583 | 4582 | $zip = false; |
4584 | 4583 | } |
4585 | 4584 | } else { |
4586 | 4585 | $zip = $zipPath; |
4587 | 4586 | } |
4588 | 4587 | if ($zip) { |
4589 | - foreach($files as $file) { |
|
4590 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4588 | + foreach ($files as $file) { |
|
4589 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4591 | 4590 | if (is_dir($path)) { |
4592 | 4591 | $zip->addEmptyDir($file); |
4593 | 4592 | $_files = array(); |
4594 | 4593 | if ($handle = opendir($path)) { |
4595 | 4594 | while (false !== ($entry = readdir($handle))) { |
4596 | 4595 | if ($entry !== "." && $entry !== "..") { |
4597 | - $_files[] = $file . DIRECTORY_SEPARATOR . $entry; |
|
4596 | + $_files[] = $file.DIRECTORY_SEPARATOR.$entry; |
|
4598 | 4597 | } |
4599 | 4598 | } |
4600 | 4599 | closedir($handle); |
@@ -4779,7 +4778,7 @@ discard block |
||
4779 | 4778 | * @return resource|false |
4780 | 4779 | * @author Dmitry (dio) Levashov |
4781 | 4780 | **/ |
4782 | - abstract protected function _fopen($path, $mode="rb"); |
|
4781 | + abstract protected function _fopen($path, $mode = "rb"); |
|
4783 | 4782 | |
4784 | 4783 | /** |
4785 | 4784 | * Close opened file |
@@ -4789,7 +4788,7 @@ discard block |
||
4789 | 4788 | * @return bool |
4790 | 4789 | * @author Dmitry (dio) Levashov |
4791 | 4790 | **/ |
4792 | - abstract protected function _fclose($fp, $path=''); |
|
4791 | + abstract protected function _fclose($fp, $path = ''); |
|
4793 | 4792 | |
4794 | 4793 | /******************** file/dir manipulations *************************/ |
4795 | 4794 |