@@ -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 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | // call handlers for this command |
563 | 563 | if (!empty($this->listeners[$cmd])) { |
564 | 564 | foreach ($this->listeners[$cmd] as $handler) { |
565 | - if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) { |
|
565 | + if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) { |
|
566 | 566 | // handler return true to force sync client after command completed |
567 | 567 | $result['sync'] = true; |
568 | 568 | } |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * @return string |
622 | 622 | * @author Dmitry (dio) Levashov |
623 | 623 | **/ |
624 | - public function realpath($hash) { |
|
624 | + public function realpath($hash) { |
|
625 | 625 | if (($volume = $this->volume($hash)) == false) { |
626 | 626 | return false; |
627 | 627 | } |
@@ -677,11 +677,11 @@ discard block |
||
677 | 677 | */ |
678 | 678 | protected function getPluginInstance($name, $opts = array()) { |
679 | 679 | $key = strtolower($name); |
680 | - if (! isset($this->plugins[$key])) { |
|
681 | - $p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php'; |
|
680 | + if (!isset($this->plugins[$key])) { |
|
681 | + $p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php'; |
|
682 | 682 | if (is_file($p_file)) { |
683 | 683 | require_once $p_file; |
684 | - $class = 'elFinderPlugin' . $name; |
|
684 | + $class = 'elFinderPlugin'.$name; |
|
685 | 685 | $this->plugins[$key] = new $class($opts); |
686 | 686 | } else { |
687 | 687 | $this->plugins[$key] = false; |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | |
774 | 774 | $netVolumes = $this->getNetVolumes(); |
775 | 775 | if ($volume->mount($options)) { |
776 | - if (! $key = @ $volume->netMountKey) { |
|
777 | - $key = md5($protocol . '-' . join('-', $options)); |
|
776 | + if (!$key = @ $volume->netMountKey) { |
|
777 | + $key = md5($protocol.'-'.join('-', $options)); |
|
778 | 778 | } |
779 | 779 | $options['driver'] = $driver; |
780 | 780 | $options['netkey'] = $key; |
@@ -979,10 +979,10 @@ discard block |
||
979 | 979 | $dispInlineRegex = $volume->getOption('dispInlineRegex'); |
980 | 980 | $inlineRegex = false; |
981 | 981 | if ($dispInlineRegex) { |
982 | - $inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#'; |
|
982 | + $inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#'; |
|
983 | 983 | try { |
984 | 984 | preg_match($inlineRegex, ''); |
985 | - } catch(Exception $e) { |
|
985 | + } catch (Exception $e) { |
|
986 | 986 | $inlineRegex = false; |
987 | 987 | } |
988 | 988 | } |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | $inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#'; |
991 | 991 | } |
992 | 992 | $mime = $file['mime']; |
993 | - $disp = preg_match($inlineRegex, $mime)? 'inline' : 'attachment'; |
|
993 | + $disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment'; |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | $filenameEncoded = rawurlencode($file['name']); |
@@ -1099,7 +1099,7 @@ discard block |
||
1099 | 1099 | $name = $args['name']; |
1100 | 1100 | |
1101 | 1101 | if (($volume = $this->volume($target)) == false |
1102 | - || ($rm = $volume->file($target)) == false) { |
|
1102 | + || ($rm = $volume->file($target)) == false) { |
|
1103 | 1103 | return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND)); |
1104 | 1104 | } |
1105 | 1105 | $rm['realpath'] = $volume->realpath($target); |
@@ -1177,9 +1177,9 @@ discard block |
||
1177 | 1177 | * @retval false error |
1178 | 1178 | * @author Naoki Sawada |
1179 | 1179 | **/ |
1180 | - protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) { |
|
1181 | - $method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; |
|
1182 | - return $this->$method( $url, $timeout, $redirect_max, $ua, $fp ); |
|
1180 | + protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) { |
|
1181 | + $method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; |
|
1182 | + return $this->$method($url, $timeout, $redirect_max, $ua, $fp); |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /** |
@@ -1195,26 +1195,26 @@ discard block |
||
1195 | 1195 | * @retval false error |
1196 | 1196 | * @author Naoki Sawada |
1197 | 1197 | **/ |
1198 | - protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){ |
|
1198 | + protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
1199 | 1199 | $ch = curl_init(); |
1200 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
1201 | - curl_setopt( $ch, CURLOPT_HEADER, false ); |
|
1200 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1201 | + curl_setopt($ch, CURLOPT_HEADER, false); |
|
1202 | 1202 | if ($outfp) { |
1203 | - curl_setopt( $ch, CURLOPT_FILE, $outfp ); |
|
1203 | + curl_setopt($ch, CURLOPT_FILE, $outfp); |
|
1204 | 1204 | } else { |
1205 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
1206 | - curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true ); |
|
1207 | - } |
|
1208 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 ); |
|
1209 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout ); |
|
1210 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); |
|
1211 | - curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); |
|
1212 | - curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
1213 | - curl_setopt( $ch, CURLOPT_USERAGENT, $ua); |
|
1214 | - $result = curl_exec( $ch ); |
|
1205 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
1206 | + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); |
|
1207 | + } |
|
1208 | + curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1); |
|
1209 | + curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout); |
|
1210 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
1211 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
1212 | + curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
1213 | + curl_setopt($ch, CURLOPT_USERAGENT, $ua); |
|
1214 | + $result = curl_exec($ch); |
|
1215 | 1215 | $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
1216 | - curl_close( $ch ); |
|
1217 | - return $outfp? $outfp : $result; |
|
1216 | + curl_close($ch); |
|
1217 | + return $outfp ? $outfp : $result; |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | /** |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | * @retval false error |
1231 | 1231 | * @author Naoki Sawada |
1232 | 1232 | */ |
1233 | - protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) { |
|
1233 | + protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
1234 | 1234 | |
1235 | 1235 | $connect_timeout = 3; |
1236 | 1236 | $connect_try = 3; |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | $headers = ''; |
1242 | 1242 | |
1243 | 1243 | $arr = parse_url($url); |
1244 | - if (!$arr){ |
|
1244 | + if (!$arr) { |
|
1245 | 1245 | // Bad request |
1246 | 1246 | return false; |
1247 | 1247 | } |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | // query |
1250 | 1250 | $arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : ''; |
1251 | 1251 | // port |
1252 | - $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80); |
|
1252 | + $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80); |
|
1253 | 1253 | |
1254 | 1254 | $url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port']; |
1255 | 1255 | $url_path = isset($arr['path']) ? $arr['path'] : '/'; |
@@ -1258,21 +1258,21 @@ discard block |
||
1258 | 1258 | $query = $method.' '.$uri." HTTP/1.0\r\n"; |
1259 | 1259 | $query .= "Host: ".$arr['host']."\r\n"; |
1260 | 1260 | if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n"; |
1261 | - if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1261 | + if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n"; |
|
1262 | 1262 | |
1263 | 1263 | $query .= $headers; |
1264 | 1264 | |
1265 | 1265 | $query .= "\r\n"; |
1266 | 1266 | |
1267 | 1267 | $fp = $connect_try_count = 0; |
1268 | - while( !$fp && $connect_try_count < $connect_try ) { |
|
1268 | + while (!$fp && $connect_try_count < $connect_try) { |
|
1269 | 1269 | |
1270 | 1270 | $errno = 0; |
1271 | 1271 | $errstr = ""; |
1272 | 1272 | $fp = @ fsockopen( |
1273 | 1273 | $arr['https'].$arr['host'], |
1274 | 1274 | $arr['port'], |
1275 | - $errno,$errstr,$connect_timeout); |
|
1275 | + $errno, $errstr, $connect_timeout); |
|
1276 | 1276 | if ($fp) break; |
1277 | 1277 | $connect_try_count++; |
1278 | 1278 | if (connection_aborted()) { |
@@ -1297,13 +1297,13 @@ discard block |
||
1297 | 1297 | |
1298 | 1298 | $_response = ''; |
1299 | 1299 | $header = ''; |
1300 | - while($_response !== "\r\n"){ |
|
1300 | + while ($_response !== "\r\n") { |
|
1301 | 1301 | $_response = fgets($fp, $readsize); |
1302 | 1302 | $header .= $_response; |
1303 | 1303 | }; |
1304 | 1304 | |
1305 | - $rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
1306 | - $rc = (int)$rccd[1]; |
|
1305 | + $rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
1306 | + $rc = (int) $rccd[1]; |
|
1307 | 1307 | |
1308 | 1308 | // Redirect |
1309 | 1309 | switch ($rc) { |
@@ -1312,19 +1312,19 @@ discard block |
||
1312 | 1312 | case 302: // Moved Temporarily |
1313 | 1313 | case 301: // Moved Permanently |
1314 | 1314 | $matches = array(); |
1315 | - if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) { |
|
1315 | + if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) { |
|
1316 | 1316 | $url = trim($matches[1]); |
1317 | - $hash = isset($matches[2])? trim($matches[2]) : ''; |
|
1318 | - if (!preg_match('/^https?:\//',$url)) { // no scheme |
|
1317 | + $hash = isset($matches[2]) ? trim($matches[2]) : ''; |
|
1318 | + if (!preg_match('/^https?:\//', $url)) { // no scheme |
|
1319 | 1319 | if ($url{0} != '/') { // Relative path |
1320 | 1320 | // to Absolute path |
1321 | - $url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url; |
|
1321 | + $url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url; |
|
1322 | 1322 | } |
1323 | 1323 | // add sheme,host |
1324 | 1324 | $url = $url_base.$url; |
1325 | 1325 | } |
1326 | 1326 | fclose($fp); |
1327 | - return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp ); |
|
1327 | + return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp); |
|
1328 | 1328 | } |
1329 | 1329 | } |
1330 | 1330 | |
@@ -1333,7 +1333,7 @@ discard block |
||
1333 | 1333 | $outfp = fopen('php://temp', 'rwb'); |
1334 | 1334 | $body = true; |
1335 | 1335 | } |
1336 | - while(fwrite($outfp, fread($fp, $readsize))) { |
|
1336 | + while (fwrite($outfp, fread($fp, $readsize))) { |
|
1337 | 1337 | if ($timeout) { |
1338 | 1338 | $_status = socket_get_status($fp); |
1339 | 1339 | if ($_status['timed_out']) { |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | |
1353 | 1353 | fclose($fp); |
1354 | 1354 | |
1355 | - return $outfp? $outfp : $body; // Data |
|
1355 | + return $outfp ? $outfp : $body; // Data |
|
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | /** |
@@ -1363,13 +1363,13 @@ discard block |
||
1363 | 1363 | * @return array |
1364 | 1364 | * @author Naoki Sawada |
1365 | 1365 | */ |
1366 | - protected function parse_data_scheme( $str, $extTable ) { |
|
1366 | + protected function parse_data_scheme($str, $extTable) { |
|
1367 | 1367 | $data = $name = ''; |
1368 | 1368 | if ($fp = fopen('data://'.substr($str, 5), 'rb')) { |
1369 | 1369 | if ($data = stream_get_contents($fp)) { |
1370 | 1370 | $meta = stream_get_meta_data($fp); |
1371 | - $ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : ''; |
|
1372 | - $name = substr(md5($data), 0, 8) . $ext; |
|
1371 | + $ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : ''; |
|
1372 | + $name = substr(md5($data), 0, 8).$ext; |
|
1373 | 1373 | } |
1374 | 1374 | fclose($fp); |
1375 | 1375 | } |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | } |
1434 | 1434 | } |
1435 | 1435 | |
1436 | - return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : ''; |
|
1436 | + return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : ''; |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | /** |
@@ -1449,26 +1449,26 @@ discard block |
||
1449 | 1449 | private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) { |
1450 | 1450 | if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) { |
1451 | 1451 | $fname = $m[1]; |
1452 | - $encname = md5($cid . '_' . $fname); |
|
1453 | - $base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname; |
|
1452 | + $encname = md5($cid.'_'.$fname); |
|
1453 | + $base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname; |
|
1454 | 1454 | $clast = intval($m[3]); |
1455 | 1455 | if (is_null($tmpname)) { |
1456 | 1456 | ignore_user_abort(true); |
1457 | 1457 | sleep(10); // wait 10 sec |
1458 | 1458 | // chunked file upload fail |
1459 | - foreach(glob($base . '*') as $cf) { |
|
1459 | + foreach (glob($base.'*') as $cf) { |
|
1460 | 1460 | @unlink($cf); |
1461 | 1461 | } |
1462 | 1462 | ignore_user_abort(false); |
1463 | 1463 | return; |
1464 | 1464 | } |
1465 | 1465 | |
1466 | - $range = isset($_POST['range'])? trim($_POST['range']) : ''; |
|
1466 | + $range = isset($_POST['range']) ? trim($_POST['range']) : ''; |
|
1467 | 1467 | if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) { |
1468 | 1468 | $start = $ranges[1]; |
1469 | 1469 | $len = $ranges[2]; |
1470 | 1470 | $size = $ranges[3]; |
1471 | - $tmp = $base . '.part'; |
|
1471 | + $tmp = $base.'.part'; |
|
1472 | 1472 | $csize = filesize($tmpname); |
1473 | 1473 | |
1474 | 1474 | $tmpExists = is_file($tmp); |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | } else { |
1494 | 1494 | // wait until makeing temp file (for anothor session) |
1495 | 1495 | $cnt = 100; // Time limit 10 sec |
1496 | - while(!is_file($base) && --$cnt) { |
|
1496 | + while (!is_file($base) && --$cnt) { |
|
1497 | 1497 | usleep(100000); // wait 100ms |
1498 | 1498 | } |
1499 | 1499 | if (!$cnt) { |
@@ -1528,13 +1528,13 @@ discard block |
||
1528 | 1528 | } |
1529 | 1529 | } else { |
1530 | 1530 | // old way |
1531 | - $part = $base . $m[2]; |
|
1531 | + $part = $base.$m[2]; |
|
1532 | 1532 | if (move_uploaded_file($tmpname, $part)) { |
1533 | 1533 | @chmod($part, 0600); |
1534 | - if ($clast < count(glob($base . '*'))) { |
|
1534 | + if ($clast < count(glob($base.'*'))) { |
|
1535 | 1535 | $parts = array(); |
1536 | 1536 | for ($i = 0; $i <= $clast; $i++) { |
1537 | - $name = $base . '.' . $i . '_' . $clast; |
|
1537 | + $name = $base.'.'.$i.'_'.$clast; |
|
1538 | 1538 | if (is_readable($name)) { |
1539 | 1539 | $parts[] = $name; |
1540 | 1540 | } else { |
@@ -1547,7 +1547,7 @@ discard block |
||
1547 | 1547 | touch($base); |
1548 | 1548 | if ($resfile = tempnam($tempDir, 'ELF')) { |
1549 | 1549 | $target = fopen($resfile, 'wb'); |
1550 | - foreach($parts as $f) { |
|
1550 | + foreach ($parts as $f) { |
|
1551 | 1551 | $fp = fopen($f, 'rb'); |
1552 | 1552 | while (!feof($fp)) { |
1553 | 1553 | fwrite($target, fread($fp, 8192)); |
@@ -1588,15 +1588,15 @@ discard block |
||
1588 | 1588 | $testDirs[] = rtrim(realpath($volumeTempPath), DIRECTORY_SEPARATOR); |
1589 | 1589 | } |
1590 | 1590 | $tempDir = ''; |
1591 | - $test = DIRECTORY_SEPARATOR . microtime(true); |
|
1592 | - foreach($testDirs as $testDir) { |
|
1591 | + $test = DIRECTORY_SEPARATOR.microtime(true); |
|
1592 | + foreach ($testDirs as $testDir) { |
|
1593 | 1593 | if (!$testDir || !is_dir($testDir)) continue; |
1594 | 1594 | $testFile = $testDir.$test; |
1595 | 1595 | if (touch($testFile)) { |
1596 | 1596 | unlink($testFile); |
1597 | 1597 | $tempDir = $testDir; |
1598 | 1598 | $gc = time() - 3600; |
1599 | - foreach(glob($tempDir . '/ELF*') as $cf) { |
|
1599 | + foreach (glob($tempDir.'/ELF*') as $cf) { |
|
1600 | 1600 | if (filemtime($cf) < $gc) { |
1601 | 1601 | @unlink($cf); |
1602 | 1602 | } |
@@ -1616,7 +1616,7 @@ discard block |
||
1616 | 1616 | **/ |
1617 | 1617 | protected function chmod($args) { |
1618 | 1618 | $targets = $args['targets']; |
1619 | - $mode = intval((string)$args['mode'], 8); |
|
1619 | + $mode = intval((string) $args['mode'], 8); |
|
1620 | 1620 | |
1621 | 1621 | if (!is_array($targets)) { |
1622 | 1622 | $targets = array($targets); |
@@ -1631,10 +1631,10 @@ discard block |
||
1631 | 1631 | |
1632 | 1632 | $files = array(); |
1633 | 1633 | $errors = array(); |
1634 | - foreach($targets as $target) { |
|
1634 | + foreach ($targets as $target) { |
|
1635 | 1635 | $file = $volume->chmod($target, $mode); |
1636 | 1636 | if ($file) { |
1637 | - $files = array_merge($files, is_array($file)? $file : array($file)); |
|
1637 | + $files = array_merge($files, is_array($file) ? $file : array($file)); |
|
1638 | 1638 | } else { |
1639 | 1639 | $errors = array_merge($errors, $volume->error()); |
1640 | 1640 | } |
@@ -1666,15 +1666,15 @@ discard block |
||
1666 | 1666 | $files = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array(); |
1667 | 1667 | $header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8'); |
1668 | 1668 | $result = array_merge(array('added' => array()), $header); |
1669 | - $paths = $args['upload_path']? $args['upload_path'] : array(); |
|
1670 | - $chunk = $args['chunk']? $args['chunk'] : ''; |
|
1671 | - $cid = $args['cid']? (int)$args['cid'] : ''; |
|
1669 | + $paths = $args['upload_path'] ? $args['upload_path'] : array(); |
|
1670 | + $chunk = $args['chunk'] ? $args['chunk'] : ''; |
|
1671 | + $cid = $args['cid'] ? (int) $args['cid'] : ''; |
|
1672 | 1672 | |
1673 | - $renames= array(); |
|
1673 | + $renames = array(); |
|
1674 | 1674 | $suffix = '~'; |
1675 | 1675 | if ($args['renames'] && is_array($args['renames'])) { |
1676 | 1676 | $renames = array_flip($args['renames']); |
1677 | - if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) { |
|
1677 | + if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) { |
|
1678 | 1678 | $suffix = $args['suffix']; |
1679 | 1679 | } |
1680 | 1680 | } |
@@ -1706,7 +1706,7 @@ discard block |
||
1706 | 1706 | if (empty($files)) { |
1707 | 1707 | if (!$args['upload'] && $args['name'] && is_array($args['name'])) { |
1708 | 1708 | $result['name'] = array(); |
1709 | - foreach($args['name'] as $_i => $_name) { |
|
1709 | + foreach ($args['name'] as $_i => $_name) { |
|
1710 | 1710 | $result['name'][$_i] = preg_replace($ngReg, '_', $_name); |
1711 | 1711 | } |
1712 | 1712 | $result = array_merge_recursive($result, $this->ls($args)); |
@@ -1719,7 +1719,7 @@ discard block |
||
1719 | 1719 | } |
1720 | 1720 | if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) { |
1721 | 1721 | $names = array(); |
1722 | - foreach($args['upload'] as $i => $url) { |
|
1722 | + foreach ($args['upload'] as $i => $url) { |
|
1723 | 1723 | // check chunked file upload commit |
1724 | 1724 | if ($args['chunk']) { |
1725 | 1725 | if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') { |
@@ -1729,7 +1729,7 @@ discard block |
||
1729 | 1729 | } |
1730 | 1730 | return $result; |
1731 | 1731 | } else { |
1732 | - $tmpfname = $tempDir . '/' . $args['chunk']; |
|
1732 | + $tmpfname = $tempDir.'/'.$args['chunk']; |
|
1733 | 1733 | $files['tmp_name'][$i] = $tmpfname; |
1734 | 1734 | $files['name'][$i] = $url; |
1735 | 1735 | $files['error'][$i] = 0; |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | } |
1739 | 1739 | } |
1740 | 1740 | |
1741 | - $tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true)); |
|
1741 | + $tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true)); |
|
1742 | 1742 | |
1743 | 1743 | $_name = ''; |
1744 | 1744 | // check is data: |
@@ -1774,8 +1774,8 @@ discard block |
||
1774 | 1774 | list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, ''); |
1775 | 1775 | if ($_b === '') { |
1776 | 1776 | if ($_ext) { |
1777 | - rename($tmpfname, $tmpfname . $_ext); |
|
1778 | - $tmpfname = $tmpfname . $_ext; |
|
1777 | + rename($tmpfname, $tmpfname.$_ext); |
|
1778 | + $tmpfname = $tmpfname.$_ext; |
|
1779 | 1779 | } |
1780 | 1780 | $_b = $this->detectFileExtension($tmpfname); |
1781 | 1781 | $_name = $_a.$_b; |
@@ -1810,7 +1810,7 @@ discard block |
||
1810 | 1810 | } |
1811 | 1811 | |
1812 | 1812 | $tmpname = $files['tmp_name'][$i]; |
1813 | - $path = ($paths && !empty($paths[$i]))? $paths[$i] : ''; |
|
1813 | + $path = ($paths && !empty($paths[$i])) ? $paths[$i] : ''; |
|
1814 | 1814 | if ($name === 'blob') { |
1815 | 1815 | if ($chunk) { |
1816 | 1816 | if ($tempDir = $this->getTempDir($volume->getTempPath())) { |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m); |
1821 | 1821 | $result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname); |
1822 | 1822 | $result['_chunkfailure'] = true; |
1823 | - $this->uploadDebug = 'Upload error: ' . $tmpname; |
|
1823 | + $this->uploadDebug = 'Upload error: '.$tmpname; |
|
1824 | 1824 | } else if ($name) { |
1825 | 1825 | $result['_chunkmerged'] = basename($tmpname); |
1826 | 1826 | $result['_name'] = $name; |
@@ -1834,14 +1834,14 @@ discard block |
||
1834 | 1834 | } else { |
1835 | 1835 | // for form clipboard with Google Chrome |
1836 | 1836 | $type = $files['type'][$i]; |
1837 | - $ext = isset($extTable[$type])? '.' . $extTable[$type] : ''; |
|
1838 | - $name = substr(md5(basename($tmpname)), 0, 8) . $ext; |
|
1837 | + $ext = isset($extTable[$type]) ? '.'.$extTable[$type] : ''; |
|
1838 | + $name = substr(md5(basename($tmpname)), 0, 8).$ext; |
|
1839 | 1839 | } |
1840 | 1840 | } |
1841 | 1841 | |
1842 | 1842 | // do hook function 'upload.presave' |
1843 | - if (! empty($this->listeners['upload.presave'])) { |
|
1844 | - foreach($this->listeners['upload.presave'] as $handler) { |
|
1843 | + if (!empty($this->listeners['upload.presave'])) { |
|
1844 | + foreach ($this->listeners['upload.presave'] as $handler) { |
|
1845 | 1845 | call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume)); |
1846 | 1846 | } |
1847 | 1847 | } |
@@ -1849,7 +1849,7 @@ discard block |
||
1849 | 1849 | if (($fp = fopen($tmpname, 'rb')) == false) { |
1850 | 1850 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER); |
1851 | 1851 | $this->uploadDebug = 'Upload error: unable open tmp file'; |
1852 | - if (! is_uploaded_file($tmpname)) { |
|
1852 | + if (!is_uploaded_file($tmpname)) { |
|
1853 | 1853 | if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
1854 | 1854 | continue; |
1855 | 1855 | } |
@@ -1871,18 +1871,18 @@ discard block |
||
1871 | 1871 | } |
1872 | 1872 | } |
1873 | 1873 | } |
1874 | - if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
1874 | + if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
1875 | 1875 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error()); |
1876 | 1876 | fclose($fp); |
1877 | - if (! is_uploaded_file($tmpname)) { |
|
1878 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);; |
|
1877 | + if (!is_uploaded_file($tmpname)) { |
|
1878 | + if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ; |
|
1879 | 1879 | continue; |
1880 | 1880 | } |
1881 | 1881 | break; |
1882 | 1882 | } |
1883 | 1883 | |
1884 | 1884 | is_resource($fp) && fclose($fp); |
1885 | - if (! is_uploaded_file($tmpname)){ |
|
1885 | + if (!is_uploaded_file($tmpname)) { |
|
1886 | 1886 | clearstatcache(); |
1887 | 1887 | if (!is_file($tmpname) || @ unlink($tmpname)) { |
1888 | 1888 | unset($GLOBALS['elFinderTempFiles'][$tmpname]); |
@@ -1894,7 +1894,7 @@ discard block |
||
1894 | 1894 | } |
1895 | 1895 | } |
1896 | 1896 | if ($GLOBALS['elFinderTempFiles']) { |
1897 | - foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
1897 | + foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
1898 | 1898 | @ unlink($_temp); |
1899 | 1899 | } |
1900 | 1900 | } |
@@ -1931,7 +1931,7 @@ discard block |
||
1931 | 1931 | $suffix = '~'; |
1932 | 1932 | if (!empty($args['renames'])) { |
1933 | 1933 | $renames = array_flip($args['renames']); |
1934 | - if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
1934 | + if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
1935 | 1935 | $suffix = $args['suffix']; |
1936 | 1936 | } |
1937 | 1937 | } |
@@ -1989,9 +1989,9 @@ discard block |
||
1989 | 1989 | } |
1990 | 1990 | |
1991 | 1991 | if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) { |
1992 | - $mime = isset($file['mime'])? $file['mime'] : ''; |
|
1992 | + $mime = isset($file['mime']) ? $file['mime'] : ''; |
|
1993 | 1993 | if ($mime && strtolower(substr($mime, 0, 4)) === 'text') { |
1994 | - if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) { |
|
1994 | + if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) { |
|
1995 | 1995 | if (strtolower($enc) !== 'utf-8') { |
1996 | 1996 | $content = mb_convert_encoding($content, 'UTF-8', $enc); |
1997 | 1997 | } |
@@ -2003,7 +2003,7 @@ discard block |
||
2003 | 2003 | |
2004 | 2004 | if ($json === false || strlen($json) < strlen($content)) { |
2005 | 2005 | if ($args['conv']) { |
2006 | - return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
2006 | + return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
2007 | 2007 | } else { |
2008 | 2008 | return array('doconv' => true); |
2009 | 2009 | } |
@@ -2045,7 +2045,7 @@ discard block |
||
2045 | 2045 | $target = $args['target']; |
2046 | 2046 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
2047 | 2047 | $error = array(self::ERROR_EXTRACT, '#'.$target); |
2048 | - $makedir = isset($args['makedir'])? (bool)$args['makedir'] : null; |
|
2048 | + $makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null; |
|
2049 | 2049 | |
2050 | 2050 | if (($volume = $this->volume($target)) == false |
2051 | 2051 | || ($file = $volume->file($target)) == false) { |
@@ -2053,7 +2053,7 @@ discard block |
||
2053 | 2053 | } |
2054 | 2054 | |
2055 | 2055 | return ($file = $volume->extract($target, $makedir)) |
2056 | - ? array('added' => isset($file['read'])? array($file) : $file) |
|
2056 | + ? array('added' => isset($file['read']) ? array($file) : $file) |
|
2057 | 2057 | : array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error())); |
2058 | 2058 | } |
2059 | 2059 | |
@@ -2068,7 +2068,7 @@ discard block |
||
2068 | 2068 | protected function archive($args) { |
2069 | 2069 | $type = $args['type']; |
2070 | 2070 | $targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array(); |
2071 | - $name = isset($args['name'])? $args['name'] : ''; |
|
2071 | + $name = isset($args['name']) ? $args['name'] : ''; |
|
2072 | 2072 | |
2073 | 2073 | if (($volume = $this->volume($targets[0])) == false) { |
2074 | 2074 | return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND); |
@@ -2089,7 +2089,7 @@ discard block |
||
2089 | 2089 | protected function search($args) { |
2090 | 2090 | $q = trim($args['q']); |
2091 | 2091 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
2092 | - $target = !empty($args['target'])? $args['target'] : null; |
|
2092 | + $target = !empty($args['target']) ? $args['target'] : null; |
|
2093 | 2093 | $result = array(); |
2094 | 2094 | |
2095 | 2095 | if (!is_null($target)) { |
@@ -2153,11 +2153,11 @@ discard block |
||
2153 | 2153 | $target = $args['target']; |
2154 | 2154 | $width = $args['width']; |
2155 | 2155 | $height = $args['height']; |
2156 | - $x = (int)$args['x']; |
|
2157 | - $y = (int)$args['y']; |
|
2156 | + $x = (int) $args['x']; |
|
2157 | + $y = (int) $args['y']; |
|
2158 | 2158 | $mode = $args['mode']; |
2159 | 2159 | $bg = null; |
2160 | - $degree = (int)$args['degree']; |
|
2160 | + $degree = (int) $args['degree']; |
|
2161 | 2161 | |
2162 | 2162 | if (($volume = $this->volume($target)) == false |
2163 | 2163 | || ($file = $volume->file($target)) == false) { |
@@ -2178,7 +2178,7 @@ discard block |
||
2178 | 2178 | **/ |
2179 | 2179 | protected function url($args) { |
2180 | 2180 | $target = $args['target']; |
2181 | - $options = isset($args['options'])? $args['options'] : array(); |
|
2181 | + $options = isset($args['options']) ? $args['options'] : array(); |
|
2182 | 2182 | if (($volume = $this->volume($target)) != false) { |
2183 | 2183 | $url = $volume->getContentUrl($target, $options); |
2184 | 2184 | return $url ? array('url' => $url) : array(); |
@@ -2195,18 +2195,18 @@ discard block |
||
2195 | 2195 | */ |
2196 | 2196 | protected function callback($args) { |
2197 | 2197 | $checkReg = '/[^a-zA-Z0-9;._-]/'; |
2198 | - $node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : ''; |
|
2199 | - $json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}'; |
|
2200 | - $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : ''; |
|
2198 | + $node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : ''; |
|
2199 | + $json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}'; |
|
2200 | + $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : ''; |
|
2201 | 2201 | $done = (!empty($args['done'])); |
2202 | 2202 | |
2203 | - while( ob_get_level() ) { |
|
2204 | - if (! ob_end_clean()) { |
|
2203 | + while (ob_get_level()) { |
|
2204 | + if (!ob_end_clean()) { |
|
2205 | 2205 | break; |
2206 | 2206 | } |
2207 | 2207 | } |
2208 | 2208 | |
2209 | - if ($done || ! $this->callbackWindowURL) { |
|
2209 | + if ($done || !$this->callbackWindowURL) { |
|
2210 | 2210 | $script = ''; |
2211 | 2211 | if ($node) { |
2212 | 2212 | $script .= ' |
@@ -2248,13 +2248,13 @@ discard block |
||
2248 | 2248 | |
2249 | 2249 | } else { |
2250 | 2250 | $url = $this->callbackWindowURL; |
2251 | - $url .= ((strpos($url, '?') === false)? '?' : '&') |
|
2252 | - . '&node=' . rawurlencode($node) |
|
2253 | - . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '') |
|
2254 | - . ($bind? ('&bind=' . rawurlencode($bind)) : '') |
|
2251 | + $url .= ((strpos($url, '?') === false) ? '?' : '&') |
|
2252 | + . '&node='.rawurlencode($node) |
|
2253 | + . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '') |
|
2254 | + . ($bind ? ('&bind='.rawurlencode($bind)) : '') |
|
2255 | 2255 | . '&done=1'; |
2256 | 2256 | |
2257 | - header('Location: ' . $url); |
|
2257 | + header('Location: '.$url); |
|
2258 | 2258 | |
2259 | 2259 | } |
2260 | 2260 | exit(); |
@@ -2324,7 +2324,7 @@ discard block |
||
2324 | 2324 | |
2325 | 2325 | protected function utime() { |
2326 | 2326 | $time = explode(" ", microtime()); |
2327 | - return (double)$time[1] + (double)$time[0]; |
|
2327 | + return (double) $time[1] + (double) $time[0]; |
|
2328 | 2328 | } |
2329 | 2329 | |
2330 | 2330 | |
@@ -2350,7 +2350,7 @@ discard block |
||
2350 | 2350 | $imgcnt = 0; |
2351 | 2351 | $fp = fopen($path, 'rb'); |
2352 | 2352 | @fread($fp, 4); |
2353 | - $c = @fread($fp,1); |
|
2353 | + $c = @fread($fp, 1); |
|
2354 | 2354 | if (ord($c) != 0x39) { // GIF89a |
2355 | 2355 | return false; |
2356 | 2356 | } |
@@ -2358,13 +2358,13 @@ discard block |
||
2358 | 2358 | while (!feof($fp)) { |
2359 | 2359 | do { |
2360 | 2360 | $c = fread($fp, 1); |
2361 | - } while(ord($c) != 0x21 && !feof($fp)); |
|
2361 | + } while (ord($c) != 0x21 && !feof($fp)); |
|
2362 | 2362 | |
2363 | 2363 | if (feof($fp)) { |
2364 | 2364 | break; |
2365 | 2365 | } |
2366 | 2366 | |
2367 | - $c2 = fread($fp,2); |
|
2367 | + $c2 = fread($fp, 2); |
|
2368 | 2368 | if (bin2hex($c2) == "f904") { |
2369 | 2369 | $imgcnt++; |
2370 | 2370 | } |
@@ -1176,7 +1176,6 @@ discard block |
||
1176 | 1176 | * Return file info or false on error |
1177 | 1177 | * |
1178 | 1178 | * @param string $hash file hash |
1179 | - * @param bool $realpath add realpath field to file info |
|
1180 | 1179 | * @return array|false |
1181 | 1180 | * @author Dmitry (dio) Levashov |
1182 | 1181 | **/ |
@@ -1197,7 +1196,6 @@ discard block |
||
1197 | 1196 | * Return folder info |
1198 | 1197 | * |
1199 | 1198 | * @param string $hash folder hash |
1200 | - * @param bool $hidden return hidden file info |
|
1201 | 1199 | * @return array|false |
1202 | 1200 | * @author Dmitry (dio) Levashov |
1203 | 1201 | **/ |
@@ -1530,7 +1528,6 @@ discard block |
||
1530 | 1528 | * |
1531 | 1529 | * @param Resource $fp file pointer |
1532 | 1530 | * @param string $dst destination folder hash |
1533 | - * @param string $src file name |
|
1534 | 1531 | * @param string $tmpname file tmp name - required to detect mime type |
1535 | 1532 | * @return array|false |
1536 | 1533 | * @author Dmitry (dio) Levashov |
@@ -1616,7 +1613,6 @@ discard block |
||
1616 | 1613 | * Paste files |
1617 | 1614 | * |
1618 | 1615 | * @param Object $volume source volume |
1619 | - * @param string $source file hash |
|
1620 | 1616 | * @param string $dst destination dir hash |
1621 | 1617 | * @param bool $rmSrc remove source after copy? |
1622 | 1618 | * @return array|false |
@@ -2235,7 +2231,6 @@ discard block |
||
2235 | 2231 | * Open file and return file pointer (with convert encording) |
2236 | 2232 | * |
2237 | 2233 | * @param string $path file path |
2238 | - * @param bool $write open file for writing |
|
2239 | 2234 | * @return resource|false |
2240 | 2235 | * @author Naoki Sawada |
2241 | 2236 | **/ |
@@ -2366,7 +2361,8 @@ discard block |
||
2366 | 2361 | * Not implemented |
2367 | 2362 | * |
2368 | 2363 | * @param string path |
2369 | - * @return mixed |
|
2364 | + * @param string $path |
|
2365 | + * @return string |
|
2370 | 2366 | * @author Dmitry (dio) Levashov |
2371 | 2367 | **/ |
2372 | 2368 | protected function crypt($path) { |
@@ -2378,7 +2374,8 @@ discard block |
||
2378 | 2374 | * Not implemented |
2379 | 2375 | * |
2380 | 2376 | * @param mixed hash |
2381 | - * @return mixed |
|
2377 | + * @param string $hash |
|
2378 | + * @return string |
|
2382 | 2379 | * @author Dmitry (dio) Levashov |
2383 | 2380 | **/ |
2384 | 2381 | protected function uncrypt($hash) { |
@@ -2408,7 +2405,6 @@ discard block |
||
2408 | 2405 | /** |
2409 | 2406 | * Return new unique name based on file name and suffix |
2410 | 2407 | * |
2411 | - * @param string $path file path |
|
2412 | 2408 | * @param string $suffix suffix append to name |
2413 | 2409 | * @return string |
2414 | 2410 | * @author Dmitry (dio) Levashov |
@@ -2476,6 +2472,7 @@ discard block |
||
2476 | 2472 | * @param string $to to character encoding |
2477 | 2473 | * @param string $locale local locale |
2478 | 2474 | * @param string $unknown replaces character for unknown |
2475 | + * @param boolean $restoreLocale |
|
2479 | 2476 | * @return mixed |
2480 | 2477 | */ |
2481 | 2478 | protected function convEnc($var, $from, $to, $locale, $restoreLocale, $unknown = '_') { |
@@ -2657,6 +2654,7 @@ discard block |
||
2657 | 2654 | * |
2658 | 2655 | * @param string $dir parent dir path |
2659 | 2656 | * @param string $name new file name |
2657 | + * @param boolean $isDir |
|
2660 | 2658 | * @return bool |
2661 | 2659 | * @author Dmitry (dio) Levashov |
2662 | 2660 | **/ |
@@ -3186,7 +3184,7 @@ discard block |
||
3186 | 3184 | * @param string $src source path |
3187 | 3185 | * @param string $dst destination dir path |
3188 | 3186 | * @param string $name new file name (optionaly) |
3189 | - * @return string|false |
|
3187 | + * @return boolean|string |
|
3190 | 3188 | * @author Dmitry (dio) Levashov |
3191 | 3189 | **/ |
3192 | 3190 | protected function copy($src, $dst, $name) { |
@@ -3239,7 +3237,7 @@ discard block |
||
3239 | 3237 | * @param string $src source path |
3240 | 3238 | * @param string $dst destination dir path |
3241 | 3239 | * @param string $name new file name |
3242 | - * @return string|false |
|
3240 | + * @return string|boolean |
|
3243 | 3241 | * @author Dmitry (dio) Levashov |
3244 | 3242 | **/ |
3245 | 3243 | protected function move($src, $dst, $name) { |
@@ -3265,7 +3263,7 @@ discard block |
||
3265 | 3263 | * @param string $src source file hash |
3266 | 3264 | * @param string $destination destination dir path |
3267 | 3265 | * @param string $name file name |
3268 | - * @return string|false |
|
3266 | + * @return boolean|string |
|
3269 | 3267 | * @author Dmitry (dio) Levashov |
3270 | 3268 | **/ |
3271 | 3269 | protected function copyFrom($volume, $src, $destination, $name) { |
@@ -3409,7 +3407,7 @@ discard block |
||
3409 | 3407 | * @param string $path thumnbnail path |
3410 | 3408 | * @param array $stat file stat |
3411 | 3409 | * @param bool $checkTmbPath |
3412 | - * @return string|bool |
|
3410 | + * @return boolean |
|
3413 | 3411 | * @author Dmitry (dio) Levashov |
3414 | 3412 | **/ |
3415 | 3413 | protected function canCreateTmb($path, $stat, $checkTmbPath = true) { |
@@ -3426,7 +3424,7 @@ discard block |
||
3426 | 3424 | * |
3427 | 3425 | * @param string $path thumnbnail path |
3428 | 3426 | * @param array $stat file stat |
3429 | - * @return string|bool |
|
3427 | + * @return boolean |
|
3430 | 3428 | * @author Dmitry (dio) Levashov |
3431 | 3429 | **/ |
3432 | 3430 | protected function canResize($path, $stat) { |
@@ -3437,7 +3435,6 @@ discard block |
||
3437 | 3435 | * Create thumnbnail and return it's URL on success |
3438 | 3436 | * |
3439 | 3437 | * @param string $path file path |
3440 | - * @param string $mime file mime type |
|
3441 | 3438 | * @return string|false |
3442 | 3439 | * @author Dmitry (dio) Levashov |
3443 | 3440 | **/ |
@@ -3897,7 +3894,7 @@ discard block |
||
3897 | 3894 | * |
3898 | 3895 | * @param string $command command line |
3899 | 3896 | * @param array $output stdout strings |
3900 | - * @param array $return_var process exit code |
|
3897 | + * @param integer $return_var process exit code |
|
3901 | 3898 | * @param array $error_output stderr strings |
3902 | 3899 | * @return int exit code |
3903 | 3900 | * @author Alexey Sukhotin |
@@ -4048,7 +4045,7 @@ discard block |
||
4048 | 4045 | * @param string $haystack The string being checked. |
4049 | 4046 | * @param string $needle The string to find in haystack. |
4050 | 4047 | * @param int $offset The search offset. If it is not specified, 0 is used. |
4051 | - * @return int|bool |
|
4048 | + * @return integer |
|
4052 | 4049 | * @author Alexey Sukhotin |
4053 | 4050 | **/ |
4054 | 4051 | protected function stripos($haystack , $needle , $offset = 0) { |
@@ -4273,7 +4270,7 @@ discard block |
||
4273 | 4270 | * @param array $files files names list |
4274 | 4271 | * @param string $name archive name |
4275 | 4272 | * @param array $arc archiver options |
4276 | - * @return string|bool |
|
4273 | + * @return string|false |
|
4277 | 4274 | * @author Dmitry (dio) Levashov, |
4278 | 4275 | * @author Alexey Sukhotin |
4279 | 4276 | * @author Naoki Sawada |
@@ -4330,7 +4327,7 @@ discard block |
||
4330 | 4327 | * @param string $dir target dir |
4331 | 4328 | * @param array $files files names list |
4332 | 4329 | * @param string|object $zipPath Zip archive name |
4333 | - * @return void |
|
4330 | + * @return boolean |
|
4334 | 4331 | * @author Naoki Sawada |
4335 | 4332 | */ |
4336 | 4333 | protected static function zipArchiveZip($dir, $files, $zipPath) { |
@@ -4533,7 +4530,6 @@ discard block |
||
4533 | 4530 | * Open file and return file pointer |
4534 | 4531 | * |
4535 | 4532 | * @param string $path file path |
4536 | - * @param bool $write open file for writing |
|
4537 | 4533 | * @return resource|false |
4538 | 4534 | * @author Dmitry (dio) Levashov |
4539 | 4535 | **/ |
@@ -4586,7 +4582,7 @@ discard block |
||
4586 | 4582 | * Copy file into another file (only inside one volume) |
4587 | 4583 | * |
4588 | 4584 | * @param string $source source file path |
4589 | - * @param string $target target dir path |
|
4585 | + * @param string $targetDir target dir path |
|
4590 | 4586 | * @param string $name file name |
4591 | 4587 | * @return bool |
4592 | 4588 | * @author Dmitry (dio) Levashov |
@@ -4598,7 +4594,7 @@ discard block |
||
4598 | 4594 | * Return new file path or false. |
4599 | 4595 | * |
4600 | 4596 | * @param string $source source file path |
4601 | - * @param string $target target dir path |
|
4597 | + * @param string $targetDir target dir path |
|
4602 | 4598 | * @param string $name file name |
4603 | 4599 | * @return string|bool |
4604 | 4600 | * @author Dmitry (dio) Levashov |
@@ -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) { |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | 'utf8fix' => false, |
279 | 279 | // й ё Й Ё Ø Å |
280 | 280 | 'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"), |
281 | - 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
281 | + 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
282 | 282 | ); |
283 | 283 | |
284 | 284 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | **/ |
571 | 571 | protected function configure() { |
572 | 572 | // set ARGS |
573 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
573 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
574 | 574 | // set thumbnails path |
575 | 575 | $path = $this->options['tmbPath']; |
576 | 576 | if ($path) { |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | // check 'statOwner' for command `chmod` |
603 | 603 | if (empty($this->options['statOwner'])) { |
604 | - $this->disabled[] ='chmod'; |
|
604 | + $this->disabled[] = 'chmod'; |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | // check 'mimeMap' |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | **/ |
707 | 707 | public function mount(array $opts) { |
708 | 708 | if (!isset($opts['path']) || $opts['path'] === '') { |
709 | - return $this->setError('Path undefined.');; |
|
709 | + return $this->setError('Path undefined.'); ; |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | $this->options = array_merge($this->options, $opts); |
@@ -725,14 +725,14 @@ discard block |
||
725 | 725 | $argInit = !empty($this->ARGS['init']); |
726 | 726 | |
727 | 727 | // session cache |
728 | - if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
728 | + if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
729 | 729 | $_SESSION[elFinder::$sessionCacheKey][$this->id] = array(); |
730 | 730 | } |
731 | 731 | $this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id]; |
732 | 732 | |
733 | 733 | // default file attribute |
734 | 734 | $this->defaults = array( |
735 | - 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
735 | + 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
736 | 736 | 'write' => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true, |
737 | 737 | 'locked' => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false, |
738 | 738 | 'hidden' => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false |
@@ -759,8 +759,8 @@ discard block |
||
759 | 759 | $this->access = $this->options['accessControl']; |
760 | 760 | } |
761 | 761 | |
762 | - $this->today = mktime(0,0,0, date('m'), date('d'), date('Y')); |
|
763 | - $this->yesterday = $this->today-86400; |
|
762 | + $this->today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
763 | + $this->yesterday = $this->today - 86400; |
|
764 | 764 | |
765 | 765 | // debug($this->attributes); |
766 | 766 | if (!$this->init()) { |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | foreach ($mimecf as $line_num => $line) { |
860 | 860 | if (!preg_match('/^\s*#/', $line)) { |
861 | 861 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
862 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
862 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
863 | 863 | if (!isset(self::$mimetypes[$mime[$i]])) { |
864 | 864 | self::$mimetypes[$mime[$i]] = $mime[0]; |
865 | 865 | } |
@@ -911,8 +911,8 @@ discard block |
||
911 | 911 | 'read' => false |
912 | 912 | )); |
913 | 913 | } |
914 | - $this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1; |
|
915 | - $this->tmbSize = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48; |
|
914 | + $this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1; |
|
915 | + $this->tmbSize = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48; |
|
916 | 916 | $this->URL = $this->options['URL']; |
917 | 917 | if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) { |
918 | 918 | $this->URL .= '/'; |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | public function options($hash) { |
1054 | 1054 | $create = $createext = array(); |
1055 | 1055 | if (isset($this->archivers['create']) && is_array($this->archivers['create'])) { |
1056 | - foreach($this->archivers['create'] as $m => $v) { |
|
1056 | + foreach ($this->archivers['create'] as $m => $v) { |
|
1057 | 1057 | $create[] = $m; |
1058 | 1058 | $createext[$m] = $v['ext']; |
1059 | 1059 | } |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | 'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(), |
1074 | 1074 | 'createext' => $createext |
1075 | 1075 | ), |
1076 | - 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array() |
|
1076 | + 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array() |
|
1077 | 1077 | ); |
1078 | 1078 | } |
1079 | 1079 | |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | * @author Naoki Sawada |
1086 | 1086 | */ |
1087 | 1087 | public function getOption($name) { |
1088 | - return isset($this->options[$name])? $this->options[$name] : null; |
|
1088 | + return isset($this->options[$name]) ? $this->options[$name] : null; |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | /** |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | public function getOptionsPlugin($name = '') { |
1099 | 1099 | if ($name) { |
1100 | - return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array(); |
|
1100 | + return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array(); |
|
1101 | 1101 | } else { |
1102 | 1102 | return $this->options['plugin']; |
1103 | 1103 | } |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | $file = $this->stat($path); |
1228 | 1228 | |
1229 | 1229 | if ($hash === $this->root()) { |
1230 | - $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(); |
|
1230 | + $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(); |
|
1231 | 1231 | $file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON |
1232 | 1232 | } |
1233 | 1233 | |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | * @return array|false |
1243 | 1243 | * @author Dmitry (dio) Levashov |
1244 | 1244 | **/ |
1245 | - public function dir($hash, $resolveLink=false) { |
|
1245 | + public function dir($hash, $resolveLink = false) { |
|
1246 | 1246 | if (($dir = $this->file($hash)) == false) { |
1247 | 1247 | return $this->setError(elFinder::ERROR_DIR_NOT_FOUND); |
1248 | 1248 | } |
@@ -1306,14 +1306,14 @@ discard block |
||
1306 | 1306 | * @return array|false |
1307 | 1307 | * @author Dmitry (dio) Levashov |
1308 | 1308 | **/ |
1309 | - public function tree($hash='', $deep=0, $exclude='') { |
|
1309 | + public function tree($hash = '', $deep = 0, $exclude = '') { |
|
1310 | 1310 | $path = $hash ? $this->decode($hash) : $this->root; |
1311 | 1311 | |
1312 | 1312 | if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') { |
1313 | 1313 | return false; |
1314 | 1314 | } |
1315 | 1315 | |
1316 | - $dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null); |
|
1316 | + $dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null); |
|
1317 | 1317 | array_unshift($dirs, $dir); |
1318 | 1318 | return $dirs; |
1319 | 1319 | } |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | * @return array|false |
1544 | 1544 | * @author Dmitry (dio) Levashov |
1545 | 1545 | **/ |
1546 | - public function duplicate($hash, $suffix='copy') { |
|
1546 | + public function duplicate($hash, $suffix = 'copy') { |
|
1547 | 1547 | if ($this->commandDisabled('duplicate')) { |
1548 | 1548 | return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED); |
1549 | 1549 | } |
@@ -1619,7 +1619,7 @@ discard block |
||
1619 | 1619 | |
1620 | 1620 | if ($file) { // file exists |
1621 | 1621 | // check POST data `overwrite` for 3rd party uploader |
1622 | - $overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1622 | + $overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1623 | 1623 | if ($overwrite) { |
1624 | 1624 | if (!$file['write']) { |
1625 | 1625 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
@@ -1690,7 +1690,7 @@ discard block |
||
1690 | 1690 | if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) { |
1691 | 1691 | return $rmSrc |
1692 | 1692 | ? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test)) |
1693 | - : $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1693 | + : $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | $test = $this->joinPathCE($destination, $name); |
@@ -1853,7 +1853,7 @@ discard block |
||
1853 | 1853 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
1854 | 1854 | } |
1855 | 1855 | $this->clearcache(); |
1856 | - $this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir; |
|
1856 | + $this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir; |
|
1857 | 1857 | |
1858 | 1858 | if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) { |
1859 | 1859 | if (is_array($path)) { |
@@ -1911,9 +1911,9 @@ discard block |
||
1911 | 1911 | if ($name === '') { |
1912 | 1912 | $name = count($files) == 1 ? $files[0] : 'Archive'; |
1913 | 1913 | } else { |
1914 | - $name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name)); |
|
1914 | + $name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name)); |
|
1915 | 1915 | } |
1916 | - $name .='.' . $archiver['ext']; |
|
1916 | + $name .= '.'.$archiver['ext']; |
|
1917 | 1917 | $name = $this->uniqueName($dir, $name, ''); |
1918 | 1918 | $this->clearcache(); |
1919 | 1919 | return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false; |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | |
1950 | 1950 | $path = $this->decode($hash); |
1951 | 1951 | |
1952 | - $work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path); |
|
1952 | + $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path); |
|
1953 | 1953 | |
1954 | 1954 | if (!$work_path || !is_writable($work_path)) { |
1955 | 1955 | if ($work_path && $path !== $work_path && is_file($work_path)) { |
@@ -1964,7 +1964,7 @@ discard block |
||
1964 | 1964 | } |
1965 | 1965 | } |
1966 | 1966 | |
1967 | - switch($mode) { |
|
1967 | + switch ($mode) { |
|
1968 | 1968 | |
1969 | 1969 | case 'propresize': |
1970 | 1970 | $result = $this->imgResize($work_path, $width, $height, true, true); |
@@ -2060,7 +2060,7 @@ discard block |
||
2060 | 2060 | } |
2061 | 2061 | return ($q === '' || $this->commandDisabled('search')) |
2062 | 2062 | ? array() |
2063 | - : $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes); |
|
2063 | + : $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes); |
|
2064 | 2064 | } |
2065 | 2065 | |
2066 | 2066 | /** |
@@ -2129,9 +2129,9 @@ discard block |
||
2129 | 2129 | $path = ltrim($path, $this->separator); |
2130 | 2130 | $dirs = explode($this->separator, $path); |
2131 | 2131 | array_pop($dirs); |
2132 | - foreach($dirs as $dir) { |
|
2132 | + foreach ($dirs as $dir) { |
|
2133 | 2133 | $targetPath = $this->joinPathCE($base, $dir); |
2134 | - if (! $_realpath = $this->realpath($this->encode($targetPath))) { |
|
2134 | + if (!$_realpath = $this->realpath($this->encode($targetPath))) { |
|
2135 | 2135 | if ($stat = $this->mkdir($targetHash, $dir)) { |
2136 | 2136 | $result['added'][] = $stat; |
2137 | 2137 | $targetHash = $stat['hash']; |
@@ -2198,7 +2198,7 @@ discard block |
||
2198 | 2198 | * @author Naoki Sawada |
2199 | 2199 | **/ |
2200 | 2200 | protected function dirnameCE($path) { |
2201 | - return (!$this->encoding)? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2201 | + return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2202 | 2202 | } |
2203 | 2203 | |
2204 | 2204 | /** |
@@ -2209,7 +2209,7 @@ discard block |
||
2209 | 2209 | * @author Naoki Sawada |
2210 | 2210 | **/ |
2211 | 2211 | protected function basenameCE($path) { |
2212 | - return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2212 | + return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2213 | 2213 | } |
2214 | 2214 | |
2215 | 2215 | /** |
@@ -2222,7 +2222,7 @@ discard block |
||
2222 | 2222 | * @author Naoki Sawada |
2223 | 2223 | **/ |
2224 | 2224 | protected function joinPathCE($dir, $name) { |
2225 | - return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2225 | + return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | /** |
@@ -2233,7 +2233,7 @@ discard block |
||
2233 | 2233 | * @author Naoki Sawada |
2234 | 2234 | **/ |
2235 | 2235 | protected function normpathCE($path) { |
2236 | - return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2236 | + return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2237 | 2237 | } |
2238 | 2238 | |
2239 | 2239 | /** |
@@ -2244,7 +2244,7 @@ discard block |
||
2244 | 2244 | * @author Naoki Sawada |
2245 | 2245 | **/ |
2246 | 2246 | protected function relpathCE($path) { |
2247 | - return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2247 | + return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2248 | 2248 | } |
2249 | 2249 | |
2250 | 2250 | /** |
@@ -2255,7 +2255,7 @@ discard block |
||
2255 | 2255 | * @author Naoki Sawada |
2256 | 2256 | **/ |
2257 | 2257 | protected function abspathCE($path) { |
2258 | - return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2258 | + return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2259 | 2259 | } |
2260 | 2260 | |
2261 | 2261 | /** |
@@ -2267,7 +2267,7 @@ discard block |
||
2267 | 2267 | * @author Naoki Sawada |
2268 | 2268 | **/ |
2269 | 2269 | protected function inpathCE($path, $parent) { |
2270 | - return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2270 | + return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2271 | 2271 | } |
2272 | 2272 | |
2273 | 2273 | /** |
@@ -2278,8 +2278,8 @@ discard block |
||
2278 | 2278 | * @return resource|false |
2279 | 2279 | * @author Naoki Sawada |
2280 | 2280 | **/ |
2281 | - protected function fopenCE($path, $mode='rb') { |
|
2282 | - return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2281 | + protected function fopenCE($path, $mode = 'rb') { |
|
2282 | + return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2283 | 2283 | } |
2284 | 2284 | |
2285 | 2285 | /** |
@@ -2290,8 +2290,8 @@ discard block |
||
2290 | 2290 | * @return bool |
2291 | 2291 | * @author Naoki Sawada |
2292 | 2292 | **/ |
2293 | - protected function fcloseCE($fp, $path='') { |
|
2294 | - return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2293 | + protected function fcloseCE($fp, $path = '') { |
|
2294 | + return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2295 | 2295 | } |
2296 | 2296 | |
2297 | 2297 | /** |
@@ -2306,7 +2306,7 @@ discard block |
||
2306 | 2306 | * @author Naoki Sawada |
2307 | 2307 | **/ |
2308 | 2308 | protected function saveCE($fp, $dir, $name, $stat) { |
2309 | - return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2309 | + return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | /** |
@@ -2318,7 +2318,7 @@ discard block |
||
2318 | 2318 | **/ |
2319 | 2319 | protected function subdirsCE($path) { |
2320 | 2320 | if (!isset($this->subdirsCache[$path])) { |
2321 | - $this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2321 | + $this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2322 | 2322 | } |
2323 | 2323 | return $this->subdirsCache[$path]; |
2324 | 2324 | } |
@@ -2331,7 +2331,7 @@ discard block |
||
2331 | 2331 | * @author Naoki Sawada |
2332 | 2332 | **/ |
2333 | 2333 | protected function scandirCE($path) { |
2334 | - return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2334 | + return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2335 | 2335 | } |
2336 | 2336 | |
2337 | 2337 | /** |
@@ -2344,7 +2344,7 @@ discard block |
||
2344 | 2344 | * @author Naoki Sawada |
2345 | 2345 | **/ |
2346 | 2346 | protected function symlinkCE($source, $targetDir, $name) { |
2347 | - return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2347 | + return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2348 | 2348 | } |
2349 | 2349 | |
2350 | 2350 | /***************** paths *******************/ |
@@ -2363,7 +2363,7 @@ discard block |
||
2363 | 2363 | // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root |
2364 | 2364 | $p = $this->relpathCE($path); |
2365 | 2365 | // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt |
2366 | - if ($p === '') { |
|
2366 | + if ($p === '') { |
|
2367 | 2367 | $p = DIRECTORY_SEPARATOR; |
2368 | 2368 | } |
2369 | 2369 | |
@@ -2396,7 +2396,7 @@ discard block |
||
2396 | 2396 | // TODO uncrypt hash and return path |
2397 | 2397 | $path = $this->uncrypt($h); |
2398 | 2398 | // append ROOT to path after it was cut in encode |
2399 | - return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2399 | + return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2400 | 2400 | } |
2401 | 2401 | } |
2402 | 2402 | |
@@ -2453,21 +2453,21 @@ discard block |
||
2453 | 2453 | * @author Dmitry (dio) Levashov |
2454 | 2454 | **/ |
2455 | 2455 | public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) { |
2456 | - $ext = ''; |
|
2456 | + $ext = ''; |
|
2457 | 2457 | |
2458 | 2458 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
2459 | 2459 | $ext = '.'.$m[1]; |
2460 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
2460 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
2461 | 2461 | } |
2462 | 2462 | |
2463 | 2463 | if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) { |
2464 | - $i = (int)$m[2]; |
|
2465 | - $name = substr($name, 0, strlen($name)-strlen($m[2])); |
|
2464 | + $i = (int) $m[2]; |
|
2465 | + $name = substr($name, 0, strlen($name) - strlen($m[2])); |
|
2466 | 2466 | } else { |
2467 | 2467 | $i = $start; |
2468 | 2468 | $name .= $suffix; |
2469 | 2469 | } |
2470 | - $max = $i+100000; |
|
2470 | + $max = $i + 100000; |
|
2471 | 2471 | |
2472 | 2472 | while ($i <= $max) { |
2473 | 2473 | $n = $name.($i > 0 ? $i : '').$ext; |
@@ -2491,7 +2491,7 @@ discard block |
||
2491 | 2491 | * @author Naoki Sawada |
2492 | 2492 | */ |
2493 | 2493 | public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') { |
2494 | - return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2494 | + return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2495 | 2495 | } |
2496 | 2496 | |
2497 | 2497 | /** |
@@ -2504,7 +2504,7 @@ discard block |
||
2504 | 2504 | * @author Naoki Sawada |
2505 | 2505 | */ |
2506 | 2506 | public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') { |
2507 | - return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2507 | + return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | /** |
@@ -2524,7 +2524,7 @@ discard block |
||
2524 | 2524 | } |
2525 | 2525 | if (is_array($var)) { |
2526 | 2526 | $_ret = array(); |
2527 | - foreach($var as $_k => $_v) { |
|
2527 | + foreach ($var as $_k => $_v) { |
|
2528 | 2528 | $_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_'); |
2529 | 2529 | } |
2530 | 2530 | $var = $_ret; |
@@ -2536,7 +2536,7 @@ discard block |
||
2536 | 2536 | $_var = str_replace('?', $unknown, $_var); |
2537 | 2537 | } |
2538 | 2538 | } |
2539 | - if ($_var !== false) { |
|
2539 | + if ($_var !== false) { |
|
2540 | 2540 | $var = $_var; |
2541 | 2541 | } |
2542 | 2542 | } |
@@ -2563,7 +2563,7 @@ discard block |
||
2563 | 2563 | |
2564 | 2564 | $key = ''; |
2565 | 2565 | if ($path !== '') { |
2566 | - $key = $this->id . '#' . $path; |
|
2566 | + $key = $this->id.'#'.$path; |
|
2567 | 2567 | if (isset($cache[$key])) { |
2568 | 2568 | return $cache[$key]; |
2569 | 2569 | } |
@@ -2595,7 +2595,7 @@ discard block |
||
2595 | 2595 | if ($work = $this->getTempFile()) { |
2596 | 2596 | if ($wfp = fopen($work, 'wb')) { |
2597 | 2597 | if ($fp = $this->_fopen($path)) { |
2598 | - while(!feof($fp)) { |
|
2598 | + while (!feof($fp)) { |
|
2599 | 2599 | fwrite($wfp, fread($fp, 8192)); |
2600 | 2600 | } |
2601 | 2601 | $this->_fclose($fp, $path); |
@@ -2639,7 +2639,7 @@ discard block |
||
2639 | 2639 | @set_time_limit(30); |
2640 | 2640 | $stat = $this->stat($this->convEncOut($p)); |
2641 | 2641 | $this->convEncIn(); |
2642 | - ($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p); |
|
2642 | + ($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p); |
|
2643 | 2643 | } |
2644 | 2644 | return $this->_rmdir($localpath); |
2645 | 2645 | } |
@@ -2656,7 +2656,7 @@ discard block |
||
2656 | 2656 | * @return bool |
2657 | 2657 | * @author Dmitry (dio) Levashov |
2658 | 2658 | **/ |
2659 | - protected function attr($path, $name, $val=null, $isDir=null) { |
|
2659 | + protected function attr($path, $name, $val = null, $isDir = null) { |
|
2660 | 2660 | if (!isset($this->defaults[$name])) { |
2661 | 2661 | return false; |
2662 | 2662 | } |
@@ -2688,7 +2688,7 @@ discard block |
||
2688 | 2688 | } |
2689 | 2689 | } |
2690 | 2690 | |
2691 | - return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm; |
|
2691 | + return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm; |
|
2692 | 2692 | } |
2693 | 2693 | |
2694 | 2694 | /** |
@@ -2732,7 +2732,7 @@ discard block |
||
2732 | 2732 | protected function allowPutMime($mime) { |
2733 | 2733 | // logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order |
2734 | 2734 | $allow = $this->mimeAccepted($mime, $this->uploadAllow, null); |
2735 | - $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2735 | + $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2736 | 2736 | $res = true; // default to allow |
2737 | 2737 | if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny' |
2738 | 2738 | $res = false; // default is deny |
@@ -2803,10 +2803,10 @@ discard block |
||
2803 | 2803 | if ($this->rootName) { |
2804 | 2804 | $stat['name'] = $this->rootName; |
2805 | 2805 | } |
2806 | - if (! empty($this->options['icon'])) { |
|
2806 | + if (!empty($this->options['icon'])) { |
|
2807 | 2807 | $stat['icon'] = $this->options['icon']; |
2808 | 2808 | } |
2809 | - if (! empty($this->options['rootCssClass'])) { |
|
2809 | + if (!empty($this->options['rootCssClass'])) { |
|
2810 | 2810 | $stat['csscls'] = $this->options['rootCssClass']; |
2811 | 2811 | } |
2812 | 2812 | } else { |
@@ -2850,7 +2850,7 @@ discard block |
||
2850 | 2850 | // lock when parent directory is not writable |
2851 | 2851 | if (!isset($stat['locked'])) { |
2852 | 2852 | $parent = $this->dirnameCE($path); |
2853 | - $pstat = isset($this->cache[$parent])? $this->cache[$parent] : array(); |
|
2853 | + $pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array(); |
|
2854 | 2854 | if (isset($pstat['write']) && !$pstat['write']) { |
2855 | 2855 | $stat['locked'] = true; |
2856 | 2856 | } |
@@ -2908,7 +2908,7 @@ discard block |
||
2908 | 2908 | } |
2909 | 2909 | if (!isset($stat['url']) && $this->URL && $this->encoding) { |
2910 | 2910 | $_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1)); |
2911 | - $stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true))); |
|
2911 | + $stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true))); |
|
2912 | 2912 | } |
2913 | 2913 | } else { |
2914 | 2914 | if ($isDir) { |
@@ -3151,7 +3151,7 @@ discard block |
||
3151 | 3151 | * @return array |
3152 | 3152 | * @author Dmitry (dio) Levashov |
3153 | 3153 | **/ |
3154 | - protected function gettree($path, $deep, $exclude='') { |
|
3154 | + protected function gettree($path, $deep, $exclude = '') { |
|
3155 | 3155 | $dirs = array(); |
3156 | 3156 | |
3157 | 3157 | !isset($this->dirsCache[$path]) && $this->cacheDir($path); |
@@ -3162,7 +3162,7 @@ discard block |
||
3162 | 3162 | if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') { |
3163 | 3163 | $dirs[] = $stat; |
3164 | 3164 | if ($deep > 0 && !empty($stat['dirs'])) { |
3165 | - $dirs = array_merge($dirs, $this->gettree($p, $deep-1)); |
|
3165 | + $dirs = array_merge($dirs, $this->gettree($p, $deep - 1)); |
|
3166 | 3166 | } |
3167 | 3167 | } |
3168 | 3168 | } |
@@ -3182,7 +3182,7 @@ discard block |
||
3182 | 3182 | protected function doSearch($path, $q, $mimes) { |
3183 | 3183 | $result = array(); |
3184 | 3184 | |
3185 | - foreach($this->scandirCE($path) as $p) { |
|
3185 | + foreach ($this->scandirCE($path) as $p) { |
|
3186 | 3186 | @set_time_limit(30); |
3187 | 3187 | $stat = $this->stat($p); |
3188 | 3188 | |
@@ -3203,7 +3203,7 @@ discard block |
||
3203 | 3203 | if ($this->encoding) { |
3204 | 3204 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
3205 | 3205 | } |
3206 | - $stat['url'] = $this->URL . $path; |
|
3206 | + $stat['url'] = $this->URL.$path; |
|
3207 | 3207 | } |
3208 | 3208 | |
3209 | 3209 | $result[] = $stat; |
@@ -3237,7 +3237,7 @@ discard block |
||
3237 | 3237 | if (!$this->inpathCE($target, $this->root)) { |
3238 | 3238 | return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK); |
3239 | 3239 | } |
3240 | - $stat = $this->stat($target); |
|
3240 | + $stat = $this->stat($target); |
|
3241 | 3241 | $this->clearcache(); |
3242 | 3242 | return $stat && $this->symlinkCE($target, $dst, $name) |
3243 | 3243 | ? $this->joinPathCE($dst, $name) |
@@ -3518,15 +3518,15 @@ discard block |
||
3518 | 3518 | } |
3519 | 3519 | |
3520 | 3520 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
3521 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3522 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3521 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3522 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3523 | 3523 | } else { |
3524 | 3524 | |
3525 | 3525 | if ($this->options['tmbCrop']) { |
3526 | 3526 | |
3527 | 3527 | $result = $tmb; |
3528 | 3528 | /* Resize and crop if image bigger than thumbnail */ |
3529 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3529 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3530 | 3530 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
3531 | 3531 | } |
3532 | 3532 | |
@@ -3543,7 +3543,7 @@ discard block |
||
3543 | 3543 | } |
3544 | 3544 | |
3545 | 3545 | if ($result) { |
3546 | - $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3546 | + $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3547 | 3547 | } |
3548 | 3548 | } |
3549 | 3549 | |
@@ -3584,18 +3584,18 @@ discard block |
||
3584 | 3584 | /* Resizing by biggest side */ |
3585 | 3585 | if ($resizeByBiggerSide) { |
3586 | 3586 | if ($orig_w > $orig_h) { |
3587 | - $size_h = round($orig_h * $width / $orig_w); |
|
3587 | + $size_h = round($orig_h*$width/$orig_w); |
|
3588 | 3588 | $size_w = $width; |
3589 | 3589 | } else { |
3590 | - $size_w = round($orig_w * $height / $orig_h); |
|
3590 | + $size_w = round($orig_w*$height/$orig_h); |
|
3591 | 3591 | $size_h = $height; |
3592 | 3592 | } |
3593 | 3593 | } else { |
3594 | 3594 | if ($orig_w > $orig_h) { |
3595 | - $size_w = round($orig_w * $height / $orig_h); |
|
3595 | + $size_w = round($orig_w*$height/$orig_h); |
|
3596 | 3596 | $size_h = $height; |
3597 | 3597 | } else { |
3598 | - $size_h = round($orig_h * $width / $orig_w); |
|
3598 | + $size_h = round($orig_h*$width/$orig_w); |
|
3599 | 3599 | $size_w = $width; |
3600 | 3600 | } |
3601 | 3601 | } |
@@ -3613,7 +3613,7 @@ discard block |
||
3613 | 3613 | // Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb |
3614 | 3614 | // resize bench: http://app-mgng.rhcloud.com/9 |
3615 | 3615 | // resize sample: http://www.dylanbeattie.net/magick/filters/result.html |
3616 | - $filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3616 | + $filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3617 | 3617 | |
3618 | 3618 | $ani = ($img->getNumberImages() > 1); |
3619 | 3619 | if ($ani && is_null($destformat)) { |
@@ -3638,11 +3638,11 @@ discard block |
||
3638 | 3638 | break; |
3639 | 3639 | |
3640 | 3640 | case 'gd': |
3641 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3641 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3642 | 3642 | |
3643 | - if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3643 | + if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3644 | 3644 | |
3645 | - self::gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3645 | + self::gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3646 | 3646 | |
3647 | 3647 | if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) { |
3648 | 3648 | return false; |
@@ -3718,11 +3718,11 @@ discard block |
||
3718 | 3718 | break; |
3719 | 3719 | |
3720 | 3720 | case 'gd': |
3721 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3721 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3722 | 3722 | |
3723 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3723 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3724 | 3724 | |
3725 | - self::gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3725 | + self::gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3726 | 3726 | |
3727 | 3727 | $size_w = $width; |
3728 | 3728 | $size_h = $height; |
@@ -3772,8 +3772,8 @@ discard block |
||
3772 | 3772 | $result = false; |
3773 | 3773 | |
3774 | 3774 | /* Coordinates for image over square aligning */ |
3775 | - $y = ceil(abs($height - $s[1]) / 2); |
|
3776 | - $x = ceil(abs($width - $s[0]) / 2); |
|
3775 | + $y = ceil(abs($height - $s[1])/2); |
|
3776 | + $x = ceil(abs($width - $s[0])/2); |
|
3777 | 3777 | |
3778 | 3778 | switch ($this->imgLib) { |
3779 | 3779 | case 'imagick': |
@@ -3793,7 +3793,7 @@ discard block |
||
3793 | 3793 | $gif->newImage($width, $height, new ImagickPixel($bgcolor)); |
3794 | 3794 | $gif->setImageColorspace($img->getImageColorspace()); |
3795 | 3795 | $gif->setImageFormat('gif'); |
3796 | - $gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3796 | + $gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3797 | 3797 | $gif->setImageDelay($img->getImageDelay()); |
3798 | 3798 | $gif->setImageIterations($img->getImageIterations()); |
3799 | 3799 | $img1->addImage($gif); |
@@ -3809,7 +3809,7 @@ discard block |
||
3809 | 3809 | $img1->newImage($width, $height, new ImagickPixel($bgcolor)); |
3810 | 3810 | $img1->setImageColorspace($img->getImageColorspace()); |
3811 | 3811 | $img1->setImageFormat($destformat != null ? $destformat : $img->getFormat()); |
3812 | - $img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3812 | + $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3813 | 3813 | $result = $img1->writeImage($path); |
3814 | 3814 | } |
3815 | 3815 | |
@@ -3820,11 +3820,11 @@ discard block |
||
3820 | 3820 | break; |
3821 | 3821 | |
3822 | 3822 | case 'gd': |
3823 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3823 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3824 | 3824 | |
3825 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3825 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3826 | 3826 | |
3827 | - self::gdImageBackground($tmp,$bgcolor); |
|
3827 | + self::gdImageBackground($tmp, $bgcolor); |
|
3828 | 3828 | |
3829 | 3829 | if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) { |
3830 | 3830 | return false; |
@@ -3855,15 +3855,15 @@ discard block |
||
3855 | 3855 | * @author Troex Nevelin |
3856 | 3856 | **/ |
3857 | 3857 | protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) { |
3858 | - if (($s = @getimagesize($path)) == false || $degree % 360 === 0) { |
|
3858 | + if (($s = @getimagesize($path)) == false || $degree%360 === 0) { |
|
3859 | 3859 | return false; |
3860 | 3860 | } |
3861 | 3861 | |
3862 | 3862 | $result = false; |
3863 | 3863 | |
3864 | 3864 | // try lossless rotate |
3865 | - if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
3866 | - $count = ($degree / 90) % 4; |
|
3865 | + if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
3866 | + $count = ($degree/90)%4; |
|
3867 | 3867 | $exiftran = array( |
3868 | 3868 | 1 => '-9', |
3869 | 3869 | 2 => '-1', |
@@ -3879,7 +3879,7 @@ discard block |
||
3879 | 3879 | 'exiftran -i '.$exiftran[$count].' '.$path, |
3880 | 3880 | 'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath |
3881 | 3881 | ); |
3882 | - foreach($cmds as $cmd) { |
|
3882 | + foreach ($cmds as $cmd) { |
|
3883 | 3883 | if ($this->procExec($cmd) === 0) { |
3884 | 3884 | $result = true; |
3885 | 3885 | break; |
@@ -3915,12 +3915,12 @@ discard block |
||
3915 | 3915 | break; |
3916 | 3916 | |
3917 | 3917 | case 'gd': |
3918 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3918 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3919 | 3919 | |
3920 | 3920 | $degree = 360 - $degree; |
3921 | 3921 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
3922 | 3922 | $bgcolor = imagecolorallocate($img, $r, $g, $b); |
3923 | - $tmp = imageRotate($img, $degree, (int)$bgcolor); |
|
3923 | + $tmp = imageRotate($img, $degree, (int) $bgcolor); |
|
3924 | 3924 | |
3925 | 3925 | $result = self::gdImage($tmp, $path, $destformat, $s['mime']); |
3926 | 3926 | |
@@ -3945,11 +3945,11 @@ discard block |
||
3945 | 3945 | * @return int exit code |
3946 | 3946 | * @author Alexey Sukhotin |
3947 | 3947 | **/ |
3948 | - protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
3948 | + protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
3949 | 3949 | |
3950 | 3950 | $descriptorspec = array( |
3951 | - 0 => array("pipe", "r"), // stdin |
|
3952 | - 1 => array("pipe", "w"), // stdout |
|
3951 | + 0 => array("pipe", "r"), // stdin |
|
3952 | + 1 => array("pipe", "w"), // stdout |
|
3953 | 3953 | 2 => array("pipe", "w") // stderr |
3954 | 3954 | ); |
3955 | 3955 | |
@@ -4006,8 +4006,8 @@ discard block |
||
4006 | 4006 | * @param string $mime |
4007 | 4007 | * @return gd image resource identifier |
4008 | 4008 | */ |
4009 | - protected function gdImageCreate($path,$mime){ |
|
4010 | - switch($mime){ |
|
4009 | + protected function gdImageCreate($path, $mime) { |
|
4010 | + switch ($mime) { |
|
4011 | 4011 | case 'image/jpeg': |
4012 | 4012 | return imagecreatefromjpeg($path); |
4013 | 4013 | |
@@ -4031,7 +4031,7 @@ discard block |
||
4031 | 4031 | * @param string $destformat The Image type to use for $filename |
4032 | 4032 | * @param string $mime The original image mime type |
4033 | 4033 | */ |
4034 | - protected function gdImage($image, $filename, $destformat, $mime ){ |
|
4034 | + protected function gdImage($image, $filename, $destformat, $mime) { |
|
4035 | 4035 | |
4036 | 4036 | if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) { |
4037 | 4037 | return imagejpeg($image, $filename, 100); |
@@ -4050,13 +4050,13 @@ discard block |
||
4050 | 4050 | * @param resource $image gd image resource |
4051 | 4051 | * @param string $bgcolor background color in #rrggbb format |
4052 | 4052 | */ |
4053 | - protected function gdImageBackground($image, $bgcolor){ |
|
4053 | + protected function gdImageBackground($image, $bgcolor) { |
|
4054 | 4054 | |
4055 | - if( $bgcolor == 'transparent' ){ |
|
4056 | - imagesavealpha($image,true); |
|
4055 | + if ($bgcolor == 'transparent') { |
|
4056 | + imagesavealpha($image, true); |
|
4057 | 4057 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
4058 | 4058 | |
4059 | - }else{ |
|
4059 | + } else { |
|
4060 | 4060 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
4061 | 4061 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
4062 | 4062 | } |
@@ -4094,13 +4094,13 @@ discard block |
||
4094 | 4094 | * @return int|bool |
4095 | 4095 | * @author Alexey Sukhotin |
4096 | 4096 | **/ |
4097 | - protected function stripos($haystack , $needle , $offset = 0) { |
|
4097 | + protected function stripos($haystack, $needle, $offset = 0) { |
|
4098 | 4098 | if (function_exists('mb_stripos')) { |
4099 | - return mb_stripos($haystack , $needle , $offset); |
|
4099 | + return mb_stripos($haystack, $needle, $offset); |
|
4100 | 4100 | } else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) { |
4101 | 4101 | return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset); |
4102 | 4102 | } |
4103 | - return stripos($haystack , $needle , $offset); |
|
4103 | + return stripos($haystack, $needle, $offset); |
|
4104 | 4104 | } |
4105 | 4105 | |
4106 | 4106 | /** |
@@ -4150,22 +4150,22 @@ discard block |
||
4150 | 4150 | unset($o); |
4151 | 4151 | $this->procExec('zip -v', $o, $c); |
4152 | 4152 | if ($c == 0) { |
4153 | - $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4153 | + $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4154 | 4154 | } |
4155 | 4155 | unset($o); |
4156 | 4156 | $this->procExec('unzip --help', $o, $c); |
4157 | 4157 | if ($c == 0) { |
4158 | - $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4158 | + $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4159 | 4159 | } |
4160 | 4160 | unset($o); |
4161 | 4161 | $this->procExec('rar --version', $o, $c); |
4162 | 4162 | if ($c == 0 || $c == 7) { |
4163 | 4163 | $arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar'); |
4164 | - $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4164 | + $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4165 | 4165 | } else { |
4166 | 4166 | unset($o); |
4167 | 4167 | $test = $this->procExec('unrar', $o, $c); |
4168 | - if ($c==0 || $c == 7) { |
|
4168 | + if ($c == 0 || $c == 7) { |
|
4169 | 4169 | $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar'); |
4170 | 4170 | } |
4171 | 4171 | } |
@@ -4187,7 +4187,7 @@ discard block |
||
4187 | 4187 | if (empty($arcs['extract']['application/x-tar'])) { |
4188 | 4188 | $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar'); |
4189 | 4189 | } |
4190 | - } else if (substr(PHP_OS,0,3) === 'WIN') { |
|
4190 | + } else if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
4191 | 4191 | // check `7z` for Windows server. |
4192 | 4192 | unset($o); |
4193 | 4193 | $this->procExec('7z', $o, $c); |
@@ -4241,22 +4241,22 @@ discard block |
||
4241 | 4241 | |
4242 | 4242 | // normalize `/../` |
4243 | 4243 | $normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#'; |
4244 | - while(preg_match($normreg, $path)) { |
|
4244 | + while (preg_match($normreg, $path)) { |
|
4245 | 4245 | $path = preg_replace($normreg, '$1', $path); |
4246 | 4246 | } |
4247 | 4247 | |
4248 | 4248 | // 'Here' |
4249 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
4249 | + if ($path === '' || $path === '.'.$separator) return $base; |
|
4250 | 4250 | |
4251 | 4251 | // Absolute path |
4252 | 4252 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
4253 | 4253 | return $path; |
4254 | 4254 | } |
4255 | 4255 | |
4256 | - $preg_separator = '#' . $sepquoted . '#'; |
|
4256 | + $preg_separator = '#'.$sepquoted.'#'; |
|
4257 | 4257 | |
4258 | 4258 | // Relative path from 'Here' |
4259 | - if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) { |
|
4259 | + if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) { |
|
4260 | 4260 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4261 | 4261 | if ($arrn[0] !== '.') { |
4262 | 4262 | array_unshift($arrn, '.'); |
@@ -4270,12 +4270,11 @@ discard block |
||
4270 | 4270 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4271 | 4271 | $arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY); |
4272 | 4272 | |
4273 | - while (! empty($arrn) && $arrn[0] === '..') { |
|
4273 | + while (!empty($arrn) && $arrn[0] === '..') { |
|
4274 | 4274 | array_shift($arrn); |
4275 | 4275 | array_pop($arrp); |
4276 | 4276 | } |
4277 | - $path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) : |
|
4278 | - (! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot); |
|
4277 | + $path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot); |
|
4279 | 4278 | } |
4280 | 4279 | |
4281 | 4280 | return $path; |
@@ -4293,7 +4292,7 @@ discard block |
||
4293 | 4292 | @chmod($dir, 0777); |
4294 | 4293 | foreach (array_diff(scandir($dir), array('.', '..')) as $file) { |
4295 | 4294 | @set_time_limit(30); |
4296 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4295 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4297 | 4296 | if (!is_link($dir) && is_dir($path)) { |
4298 | 4297 | $this->rmdirRecursive($path); |
4299 | 4298 | } else { |
@@ -4380,22 +4379,22 @@ discard block |
||
4380 | 4379 | try { |
4381 | 4380 | if ($start = is_string($zipPath)) { |
4382 | 4381 | $zip = new ZipArchive(); |
4383 | - if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) { |
|
4382 | + if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) { |
|
4384 | 4383 | $zip = false; |
4385 | 4384 | } |
4386 | 4385 | } else { |
4387 | 4386 | $zip = $zipPath; |
4388 | 4387 | } |
4389 | 4388 | if ($zip) { |
4390 | - foreach($files as $file) { |
|
4391 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4389 | + foreach ($files as $file) { |
|
4390 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4392 | 4391 | if (is_dir($path)) { |
4393 | 4392 | $zip->addEmptyDir($file); |
4394 | 4393 | $_files = array(); |
4395 | 4394 | if ($handle = opendir($path)) { |
4396 | 4395 | while (false !== ($entry = readdir($handle))) { |
4397 | 4396 | if ($entry !== "." && $entry !== "..") { |
4398 | - $_files[] = $file . DIRECTORY_SEPARATOR . $entry; |
|
4397 | + $_files[] = $file.DIRECTORY_SEPARATOR.$entry; |
|
4399 | 4398 | } |
4400 | 4399 | } |
4401 | 4400 | closedir($handle); |
@@ -4580,7 +4579,7 @@ discard block |
||
4580 | 4579 | * @return resource|false |
4581 | 4580 | * @author Dmitry (dio) Levashov |
4582 | 4581 | **/ |
4583 | - abstract protected function _fopen($path, $mode="rb"); |
|
4582 | + abstract protected function _fopen($path, $mode = "rb"); |
|
4584 | 4583 | |
4585 | 4584 | /** |
4586 | 4585 | * Close opened file |
@@ -4590,7 +4589,7 @@ discard block |
||
4590 | 4589 | * @return bool |
4591 | 4590 | * @author Dmitry (dio) Levashov |
4592 | 4591 | **/ |
4593 | - abstract protected function _fclose($fp, $path=''); |
|
4592 | + abstract protected function _fclose($fp, $path = ''); |
|
4594 | 4593 | |
4595 | 4594 | /******************** file/dir manipulations *************************/ |
4596 | 4595 |
@@ -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; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | if ($options['user'] === 'init') { |
139 | 139 | |
140 | - if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) { |
|
140 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) { |
|
141 | 141 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
142 | 142 | } |
143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | if (class_exists('OAuth')) { |
148 | 148 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
149 | 149 | } else { |
150 | - if (! class_exists('HTTP_OAuth_Consumer')) { |
|
150 | + if (!class_exists('HTTP_OAuth_Consumer')) { |
|
151 | 151 | // We're going to try to load in manually |
152 | 152 | include 'HTTP/OAuth/Consumer.php'; |
153 | 153 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - if (! $this->oauth) { |
|
160 | + if (!$this->oauth) { |
|
161 | 161 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
162 | 162 | } |
163 | 163 | |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | unset($_SESSION['elFinderDropboxTokens']); |
179 | 179 | } |
180 | 180 | } |
181 | - if (! $html) { |
|
181 | + if (!$html) { |
|
182 | 182 | // get customdata |
183 | 183 | $cdata = ''; |
184 | 184 | $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); |
185 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
186 | - foreach($this->ARGS as $k => $v) { |
|
187 | - if (! in_array($k, $innerKeys)) { |
|
188 | - $cdata .= '&' . $k . '=' . rawurlencode($v); |
|
185 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
186 | + foreach ($this->ARGS as $k => $v) { |
|
187 | + if (!in_array($k, $innerKeys)) { |
|
188 | + $cdata .= '&'.$k.'='.rawurlencode($v); |
|
189 | 189 | } |
190 | 190 | } |
191 | - if (strpos($options['url'], 'http') !== 0 ) { |
|
191 | + if (strpos($options['url'], 'http') !== 0) { |
|
192 | 192 | $options['url'] = $this->getConnectorUrl(); |
193 | 193 | } |
194 | - $callback = $options['url'] |
|
194 | + $callback = $options['url'] |
|
195 | 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(); |
199 | - $url= $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
199 | + $url = $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
200 | 200 | } catch (Dropbox_Exception $e) { |
201 | 201 | return array('exit' => true, 'body' => '{msg:errAccess}'); |
202 | 202 | } |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | if (isset($netVolumes[$key])) { |
244 | 244 | $dropboxUid = $netVolumes[$key]['dropboxUid']; |
245 | 245 | } |
246 | - foreach($netVolumes as $volume) { |
|
246 | + foreach ($netVolumes as $volume) { |
|
247 | 247 | if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) { |
248 | 248 | $count++; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | if ($count === 1) { |
252 | 252 | $this->DB->exec('drop table '.$this->DB_TableName); |
253 | - foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
253 | + foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
254 | 254 | unlink($tmb); |
255 | 255 | } |
256 | 256 | } |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | * @author Naoki Sawada |
265 | 265 | */ |
266 | 266 | private function getConnectorUrl() { |
267 | - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
|
267 | + $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') |
|
268 | 268 | . $_SERVER['SERVER_NAME'] // host |
269 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
270 | - . $_SERVER['REQUEST_URI']; // path & query |
|
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 | } |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | // make net mount key |
304 | 304 | $this->netMountKey = md5(join('-', array('dropbox', $this->options['path']))); |
305 | 305 | |
306 | - if (! $this->oauth) { |
|
306 | + if (!$this->oauth) { |
|
307 | 307 | if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) { |
308 | 308 | $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']); |
309 | 309 | } else { |
310 | 310 | if (class_exists('OAuth')) { |
311 | 311 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
312 | 312 | } else { |
313 | - if (! class_exists('HTTP_OAuth_Consumer')) { |
|
313 | + if (!class_exists('HTTP_OAuth_Consumer')) { |
|
314 | 314 | // We're going to try to load in manually |
315 | 315 | include 'HTTP/OAuth/Consumer.php'; |
316 | 316 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | - if (! $this->oauth) { |
|
324 | + if (!$this->oauth) { |
|
325 | 325 | return $this->setError('OAuth extension not loaded.'); |
326 | 326 | } |
327 | 327 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $this->root = $this->options['path'] = $this->_normpath($this->options['path']); |
330 | 330 | |
331 | 331 | if (empty($this->options['alias'])) { |
332 | - $this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
332 | + $this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | $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) { |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $res = false; |
445 | 445 | } |
446 | 446 | } |
447 | - if (! $res) { |
|
447 | + if (!$res) { |
|
448 | 448 | try { |
449 | 449 | $this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);'); |
450 | 450 | $this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)'); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | */ |
495 | 495 | private function updateDBdat($path, $dat) { |
496 | 496 | return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat)) |
497 | - . ', isdir=' . ($dat['is_dir']? 1 : 0) |
|
497 | + . ', isdir='.($dat['is_dir'] ? 1 : 0) |
|
498 | 498 | . ' where path='.$this->DB->quote(strtolower(dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path)))); |
499 | 499 | } |
500 | 500 | /*********************************************************************/ |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | */ |
520 | 520 | protected function deltaCheck($refresh = true) { |
521 | 521 | $chk = false; |
522 | - if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
522 | + if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
523 | 523 | $chk = unserialize($chk[0]); |
524 | 524 | } |
525 | 525 | if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) { |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | do { |
542 | 542 | @ ini_set('max_execution_time', 120); |
543 | 543 | $_info = $this->dropbox->delta($cursor); |
544 | - if (! empty($_info['reset'])) { |
|
544 | + if (!empty($_info['reset'])) { |
|
545 | 545 | $this->DB->exec('TRUNCATE table '.$this->DB_TableName); |
546 | 546 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);'); |
547 | 547 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array( |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | } |
555 | 555 | $cursor = $_info['cursor']; |
556 | 556 | |
557 | - foreach($_info['entries'] as $entry) { |
|
557 | + foreach ($_info['entries'] as $entry) { |
|
558 | 558 | $key = strtolower($entry[0]); |
559 | 559 | $pkey = strtolower(dirname($key)); |
560 | 560 | |
@@ -564,27 +564,27 @@ discard block |
||
564 | 564 | |
565 | 565 | if (empty($entry[1])) { |
566 | 566 | $this->DB->exec('delete from '.$this->DB_TableName.' '.$where); |
567 | - ! $delete && $delete = true; |
|
567 | + !$delete && $delete = true; |
|
568 | 568 | continue; |
569 | 569 | } |
570 | 570 | |
571 | 571 | $sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1'; |
572 | - if (! $reset && $this->query($sql)) { |
|
573 | - $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where); |
|
572 | + if (!$reset && $this->query($sql)) { |
|
573 | + $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where); |
|
574 | 574 | } else { |
575 | - $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')'); |
|
575 | + $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')'); |
|
576 | 576 | } |
577 | 577 | } |
578 | - } while (! empty($_info['has_more'])); |
|
578 | + } while (!empty($_info['has_more'])); |
|
579 | 579 | $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\''); |
580 | - if (! $this->DB->commit()) { |
|
580 | + if (!$this->DB->commit()) { |
|
581 | 581 | $e = $this->DB->errorInfo(); |
582 | 582 | return $e[2]; |
583 | 583 | } |
584 | 584 | if ($delete) { |
585 | 585 | $this->DB->exec('vacuum'); |
586 | 586 | } |
587 | - } catch(Dropbox_Exception $e) { |
|
587 | + } catch (Dropbox_Exception $e) { |
|
588 | 588 | return $e->getMessage(); |
589 | 589 | } |
590 | 590 | return true; |
@@ -600,15 +600,14 @@ discard block |
||
600 | 600 | protected function parseRaw($raw) { |
601 | 601 | $stat = array(); |
602 | 602 | |
603 | - $stat['rev'] = isset($raw['rev'])? $raw['rev'] : 'root'; |
|
603 | + $stat['rev'] = isset($raw['rev']) ? $raw['rev'] : 'root'; |
|
604 | 604 | $stat['name'] = basename($raw['path']); |
605 | - $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
|
605 | + $stat['mime'] = $raw['is_dir'] ? 'directory' : $raw['mime_type']; |
|
606 | 606 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
607 | - $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
|
608 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
607 | + $stat['ts'] = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
609 | 608 | $stat['dirs'] = 0; |
610 | 609 | if ($raw['is_dir']) { |
611 | - $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
610 | + $stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
612 | 611 | } |
613 | 612 | |
614 | 613 | if (!empty($raw['url'])) { |
@@ -634,7 +633,7 @@ discard block |
||
634 | 633 | $res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path))); |
635 | 634 | |
636 | 635 | if ($res) { |
637 | - foreach($res as $raw) { |
|
636 | + foreach ($res as $raw) { |
|
638 | 637 | $raw = unserialize($raw); |
639 | 638 | if ($stat = $this->parseRaw($raw)) { |
640 | 639 | $stat = $this->updateCache($raw['path'], $stat); |
@@ -659,10 +658,10 @@ discard block |
||
659 | 658 | protected function doSearch($path, $q, $mimes) { |
660 | 659 | $result = array(); |
661 | 660 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
662 | - $sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
661 | + $sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
663 | 662 | $res = $sth->fetchAll(PDO::FETCH_COLUMN); |
664 | 663 | if ($res) { |
665 | - foreach($res as $raw) { |
|
664 | + foreach ($res as $raw) { |
|
666 | 665 | $raw = unserialize($raw); |
667 | 666 | if ($stat = $this->parseRaw($raw)) { |
668 | 667 | if (!isset($this->cache[$raw['path']])) { |
@@ -753,10 +752,10 @@ discard block |
||
753 | 752 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
754 | 753 | |
755 | 754 | // copy image into tmbPath so some drivers does not store files on local fs |
756 | - if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
755 | + if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
757 | 756 | return false; |
758 | 757 | } |
759 | - if (! file_put_contents($tmb, $data)) { |
|
758 | + if (!file_put_contents($tmb, $data)) { |
|
760 | 759 | return false; |
761 | 760 | } |
762 | 761 | |
@@ -769,15 +768,15 @@ discard block |
||
769 | 768 | } |
770 | 769 | |
771 | 770 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
772 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
773 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
771 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
772 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
774 | 773 | |
775 | 774 | } else { |
776 | 775 | |
777 | 776 | if ($this->options['tmbCrop']) { |
778 | 777 | |
779 | 778 | /* Resize and crop if image bigger than thumbnail */ |
780 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
779 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
781 | 780 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
782 | 781 | } |
783 | 782 | |
@@ -791,7 +790,7 @@ discard block |
||
791 | 790 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
792 | 791 | } |
793 | 792 | |
794 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
793 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
795 | 794 | } |
796 | 795 | |
797 | 796 | if (!$result) { |
@@ -848,7 +847,7 @@ discard block |
||
848 | 847 | } |
849 | 848 | } |
850 | 849 | } |
851 | - if (! $url) { |
|
850 | + if (!$url) { |
|
852 | 851 | try { |
853 | 852 | $res = $this->dropbox->share($path, null, false); |
854 | 853 | $url = $res['url']; |
@@ -860,7 +859,7 @@ discard block |
||
860 | 859 | } |
861 | 860 | list($url) = explode('?', $url); |
862 | 861 | $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url); |
863 | - if (! isset($cache['share']) || $cache['share'] !== $url) { |
|
862 | + if (!isset($cache['share']) || $cache['share'] !== $url) { |
|
864 | 863 | $cache['share'] = $url; |
865 | 864 | $this->updateDBdat($path, $cache); |
866 | 865 | } |
@@ -884,12 +883,12 @@ discard block |
||
884 | 883 | if (function_exists('curl_exec')) { |
885 | 884 | |
886 | 885 | $c = curl_init(); |
887 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
|
888 | - curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
889 | - curl_setopt( $c, CURLOPT_HEADER, 1 ); |
|
890 | - curl_setopt( $c, CURLOPT_NOBODY, true ); |
|
891 | - curl_setopt( $c, CURLOPT_URL, $url ); |
|
892 | - $res = curl_exec( $c ); |
|
886 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
887 | + curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
888 | + curl_setopt($c, CURLOPT_HEADER, 1); |
|
889 | + curl_setopt($c, CURLOPT_NOBODY, true); |
|
890 | + curl_setopt($c, CURLOPT_URL, $url); |
|
891 | + $res = curl_exec($c); |
|
893 | 892 | |
894 | 893 | } else { |
895 | 894 | |
@@ -905,13 +904,13 @@ discard block |
||
905 | 904 | $result = $request2->send(); |
906 | 905 | $res = array(); |
907 | 906 | $res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase(); |
908 | - foreach($result->getHeader() as $key => $val) { |
|
909 | - $res[] = $key . ': ' . $val; |
|
907 | + foreach ($result->getHeader() as $key => $val) { |
|
908 | + $res[] = $key.': '.$val; |
|
910 | 909 | } |
911 | 910 | $res = join("\r\n", $res); |
912 | - } catch( HTTP_Request2_Exception $e ){ |
|
911 | + } catch (HTTP_Request2_Exception $e) { |
|
913 | 912 | $res = ''; |
914 | - } catch (Exception $e){ |
|
913 | + } catch (Exception $e) { |
|
915 | 914 | $res = ''; |
916 | 915 | } |
917 | 916 | |
@@ -964,7 +963,7 @@ discard block |
||
964 | 963 | **/ |
965 | 964 | protected function _normpath($path) { |
966 | 965 | $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); |
967 | - $path = '/' . ltrim($path, '/'); |
|
966 | + $path = '/'.ltrim($path, '/'); |
|
968 | 967 | return $path; |
969 | 968 | } |
970 | 969 | |
@@ -1103,7 +1102,7 @@ discard block |
||
1103 | 1102 | * @return resource|false |
1104 | 1103 | * @author Dmitry (dio) Levashov |
1105 | 1104 | **/ |
1106 | - protected function _fopen($path, $mode='rb') { |
|
1105 | + protected function _fopen($path, $mode = 'rb') { |
|
1107 | 1106 | |
1108 | 1107 | if (($mode == 'rb' || $mode == 'r')) { |
1109 | 1108 | try { |
@@ -1113,7 +1112,7 @@ discard block |
||
1113 | 1112 | fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); |
1114 | 1113 | fputs($fp, "Host: {$url['host']}\r\n"); |
1115 | 1114 | fputs($fp, "\r\n"); |
1116 | - while(trim(fgets($fp)) !== ''){}; |
|
1115 | + while (trim(fgets($fp)) !== '') {}; |
|
1117 | 1116 | return $fp; |
1118 | 1117 | } catch (Dropbox_Exception $e) { |
1119 | 1118 | return false; |
@@ -1144,7 +1143,7 @@ discard block |
||
1144 | 1143 | * @return bool |
1145 | 1144 | * @author Dmitry (dio) Levashov |
1146 | 1145 | **/ |
1147 | - protected function _fclose($fp, $path='') { |
|
1146 | + protected function _fclose($fp, $path = '') { |
|
1148 | 1147 | @fclose($fp); |
1149 | 1148 | if ($path) { |
1150 | 1149 | @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 |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | if ($this->encoding) { |
236 | 236 | @ftp_exec($this->connect, 'OPTS UTF8 OFF'); |
237 | 237 | } else { |
238 | - @ftp_exec($this->connect, 'OPTS UTF8 ON' ); |
|
238 | + @ftp_exec($this->connect, 'OPTS UTF8 ON'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // switch off extended passive mode - may be usefull for some servers |
242 | - @ftp_exec($this->connect, 'epsv4 off' ); |
|
242 | + @ftp_exec($this->connect, 'epsv4 off'); |
|
243 | 243 | // enter passive mode if required |
244 | 244 | ftp_pasv($this->connect, $this->options['mode'] == 'passive'); |
245 | 245 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $name = $info[8]; |
308 | 308 | |
309 | 309 | if (preg_match('|(.+)\-\>(.+)|', $name, $m)) { |
310 | - $name = trim($m[1]); |
|
310 | + $name = trim($m[1]); |
|
311 | 311 | // check recursive processing |
312 | 312 | if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) { |
313 | 313 | return array(); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $stat['owner'] = $info[2]; |
344 | 344 | $stat['group'] = $info[3]; |
345 | 345 | $stat['perm'] = substr($info[0], 1); |
346 | - $stat['isowner'] = $stat['owner']? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
346 | + $stat['isowner'] = $stat['owner'] ? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | $perm = $this->parsePermissions($info[0], $stat['owner']); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $info[4] = 0; |
376 | 376 | $info[0] = 'drwxr-xr-x'; |
377 | 377 | } else { |
378 | - $info[4] = (int)$size; |
|
378 | + $info[4] = (int) $size; |
|
379 | 379 | $info[0] = '-rw-r--r--'; |
380 | 380 | } |
381 | 381 | return $info; |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | protected function parsePermissions($perm, $user = '') { |
392 | 392 | $res = array(); |
393 | 393 | $parts = array(); |
394 | - $owner = $user? ($user == $this->options['user']) : $this->options['owner']; |
|
394 | + $owner = $user ? ($user == $this->options['user']) : $this->options['owner']; |
|
395 | 395 | for ($i = 0, $l = strlen($perm); $i < $l; $i++) { |
396 | 396 | $parts[] = substr($perm, $i, 1); |
397 | 397 | } |
@@ -422,10 +422,10 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | $list = $this->convEncOut($list); |
425 | - $prefix = ($path === $this->separator)? $this->separator : $path . $this->separator; |
|
425 | + $prefix = ($path === $this->separator) ? $this->separator : $path.$this->separator; |
|
426 | 426 | $targets = array(); |
427 | - foreach($list as $stat) { |
|
428 | - $p = $prefix . $stat['name']; |
|
427 | + foreach ($list as $stat) { |
|
428 | + $p = $prefix.$stat['name']; |
|
429 | 429 | if (isset($stat['target'])) { |
430 | 430 | // stat later |
431 | 431 | $targets[$stat['name']] = $stat['target']; |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | } |
438 | 438 | } |
439 | 439 | // stat link targets |
440 | - foreach($targets as $name => $target) { |
|
440 | + foreach ($targets as $name => $target) { |
|
441 | 441 | $stat = array(); |
442 | 442 | $stat['name'] = $name; |
443 | - $p = $prefix . $name; |
|
443 | + $p = $prefix.$name; |
|
444 | 444 | $cacheDirTarget = $this->cacheDirTarget; |
445 | 445 | $this->cacheDirTarget = $this->convEncIn($target, true); |
446 | 446 | if ($tstat = $this->stat($target)) { |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | $stat['thash'] = $tstat['hash']; |
450 | 450 | $stat['mime'] = $tstat['mime']; |
451 | 451 | $stat['read'] = $tstat['read']; |
452 | - $stat['write'] = $tstat['write']; |
|
452 | + $stat['write'] = $tstat['write']; |
|
453 | 453 | |
454 | - if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
455 | - if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
456 | - if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
457 | - if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
454 | + if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
455 | + if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
456 | + if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
457 | + if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
458 | 458 | if (isset($tstat['isowner'])) { $stat['isowner'] = $tstat['isowner']; } |
459 | 459 | } else { |
460 | 460 | |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $comps = $new_comps; |
568 | 568 | $path = implode($this->separator, $comps); |
569 | 569 | if ($initial_slashes) { |
570 | - $path = str_repeat($this->separator, $initial_slashes) . $path; |
|
570 | + $path = str_repeat($this->separator, $initial_slashes).$path; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | return $path ? $path : '.'; |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * @author Dmitry (dio) Levashov |
634 | 634 | **/ |
635 | 635 | protected function _inpath($path, $parent) { |
636 | - return $path == $parent || strpos($path, $parent. $this->separator) === 0; |
|
636 | + return $path == $parent || strpos($path, $parent.$this->separator) === 0; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /***************** file stat ********************/ |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | ); |
673 | 673 | } |
674 | 674 | $this->cacheDir($this->convEncOut($this->_dirname($path))); |
675 | - return $this->convEncIn(isset($this->cache[$outPath])? $this->cache[$outPath] : array()); |
|
675 | + return $this->convEncIn(isset($this->cache[$outPath]) ? $this->cache[$outPath] : array()); |
|
676 | 676 | } |
677 | - $raw = ftp_raw($this->connect, 'MLST ' . $path); |
|
677 | + $raw = ftp_raw($this->connect, 'MLST '.$path); |
|
678 | 678 | if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) { |
679 | 679 | $parts = explode(';', trim($raw[1])); |
680 | 680 | array_pop($parts); |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | |
705 | 705 | case 'perm': |
706 | 706 | $val = strtolower($val); |
707 | - $stat['read'] = (int)preg_match('/e|l|r/', $val); |
|
708 | - $stat['write'] = (int)preg_match('/w|m|c/', $val); |
|
707 | + $stat['read'] = (int) preg_match('/e|l|r/', $val); |
|
708 | + $stat['write'] = (int) preg_match('/w|m|c/', $val); |
|
709 | 709 | if (!preg_match('/f|d/', $val)) { |
710 | 710 | $stat['locked'] = 1; |
711 | 711 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | if (!$this->ftpOsUnix) { |
791 | 791 | $info = $this->normalizeRawWindows($str); |
792 | 792 | } |
793 | - $name = isset($info[8])? trim($info[8]) : ''; |
|
793 | + $name = isset($info[8]) ? trim($info[8]) : ''; |
|
794 | 794 | if ($name && $name !== '.' && $name !== '..' && substr(strtolower($info[0]), 0, 1) === 'd') { |
795 | 795 | return true; |
796 | 796 | } |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * @return resource|false |
846 | 846 | * @author Dmitry (dio) Levashov |
847 | 847 | **/ |
848 | - protected function _fopen($path, $mode='rb') { |
|
848 | + protected function _fopen($path, $mode = 'rb') { |
|
849 | 849 | |
850 | 850 | if ($this->tmp) { |
851 | 851 | $local = $this->getTempFile($path); |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * @return bool |
870 | 870 | * @author Dmitry (dio) Levashov |
871 | 871 | **/ |
872 | - protected function _fclose($fp, $path='') { |
|
872 | + protected function _fclose($fp, $path = '') { |
|
873 | 873 | @fclose($fp); |
874 | 874 | if ($path) { |
875 | 875 | @unlink($this->getTempFile($path)); |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | if (@file_put_contents($local, $content, LOCK_EX) !== false |
1045 | 1045 | && ($fp = @fopen($local, 'rb'))) { |
1046 | 1046 | clearstatcache(); |
1047 | - $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
1047 | + $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
1048 | 1048 | @fclose($fp); |
1049 | 1049 | } |
1050 | 1050 | file_exists($local) && @unlink($local); |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | * @return bool |
1070 | 1070 | **/ |
1071 | 1071 | protected function _chmod($path, $mode) { |
1072 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
1072 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
1073 | 1073 | return @ftp_chmod($this->connect, $modeOct, $path); |
1074 | 1074 | } |
1075 | 1075 | |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | $basename = $this->_basename($path); |
1125 | - $localPath = $dir . DIRECTORY_SEPARATOR . $basename; |
|
1125 | + $localPath = $dir.DIRECTORY_SEPARATOR.$basename; |
|
1126 | 1126 | |
1127 | 1127 | if (!ftp_get($this->connect, $localPath, $path, FTP_BINARY)) { |
1128 | 1128 | //cleanup |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | // archive contains one item - extract in archive dir |
1161 | 1161 | $name = ''; |
1162 | - $src = $dir . DIRECTORY_SEPARATOR . $filesToProcess[0]; |
|
1162 | + $src = $dir.DIRECTORY_SEPARATOR.$filesToProcess[0]; |
|
1163 | 1163 | if (($extractTo === 'auto' || !$extractTo) && count($filesToProcess) === 1 && is_file($src)) { |
1164 | 1164 | $name = $filesToProcess[0]; |
1165 | 1165 | } else if ($extractTo === 'auto' || $extractTo) { |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | $src = $dir; |
1169 | 1169 | $name = basename($path); |
1170 | 1170 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
1171 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
1171 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
1172 | 1172 | } |
1173 | 1173 | $test = $this->_joinPath(dirname($path), $name); |
1174 | 1174 | if ($this->stat($test)) { |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | if ($name !== '' && is_file($src)) { |
1180 | 1180 | $result = $this->_joinPath(dirname($path), $name); |
1181 | 1181 | |
1182 | - if (! ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
1182 | + if (!ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
1183 | 1183 | $this->rmdirRecursive($dir); |
1184 | 1184 | return false; |
1185 | 1185 | } |
@@ -1193,19 +1193,19 @@ discard block |
||
1193 | 1193 | } |
1194 | 1194 | $result[] = $dstDir; |
1195 | 1195 | } |
1196 | - foreach($filesToProcess as $name) { |
|
1196 | + foreach ($filesToProcess as $name) { |
|
1197 | 1197 | $name = rtrim($name, DIRECTORY_SEPARATOR); |
1198 | - $src = $dir . DIRECTORY_SEPARATOR . $name; |
|
1198 | + $src = $dir.DIRECTORY_SEPARATOR.$name; |
|
1199 | 1199 | if (is_dir($src)) { |
1200 | 1200 | $p = dirname($name); |
1201 | 1201 | $name = basename($name); |
1202 | - if (! $target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
1202 | + if (!$target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
1203 | 1203 | $this->rmdirRecursive($dir); |
1204 | 1204 | return false; |
1205 | 1205 | } |
1206 | 1206 | } else { |
1207 | 1207 | $target = $this->_joinPath($dstDir, $name); |
1208 | - if (! ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
1208 | + if (!ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
1209 | 1209 | $this->rmdirRecursive($dir); |
1210 | 1210 | return false; |
1211 | 1211 | } |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | is_dir($dir) && $this->rmdirRecursive($dir); |
1222 | 1222 | |
1223 | 1223 | $this->clearcache(); |
1224 | - return $result? $result : false; |
|
1224 | + return $result ? $result : false; |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | /** |
@@ -1261,7 +1261,7 @@ discard block |
||
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | //cleanup |
1264 | - if(!$this->rmdirRecursive($tmpDir)) { |
|
1264 | + if (!$this->rmdirRecursive($tmpDir)) { |
|
1265 | 1265 | return false; |
1266 | 1266 | } |
1267 | 1267 | |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | $remoteDirLen = strlen($remote_directory); |
1366 | 1366 | foreach ($contents as $item) { |
1367 | 1367 | $relative_path = substr($item['path'], $remoteDirLen); |
1368 | - $local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path; |
|
1368 | + $local_path = $dest_local_directory.DIRECTORY_SEPARATOR.$relative_path; |
|
1369 | 1369 | switch ($item['type']) { |
1370 | 1370 | case 'd': |
1371 | 1371 | $success = mkdir($local_path); |
@@ -1396,8 +1396,8 @@ discard block |
||
1396 | 1396 | } else { |
1397 | 1397 | $success = true; |
1398 | 1398 | foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) { |
1399 | - $path = $dirPath . DIRECTORY_SEPARATOR . $path; |
|
1400 | - if(is_link($path)) { |
|
1399 | + $path = $dirPath.DIRECTORY_SEPARATOR.$path; |
|
1400 | + if (is_link($path)) { |
|
1401 | 1401 | unlink($path); |
1402 | 1402 | } else if (is_dir($path)) { |
1403 | 1403 | $success = rmdir($path); |
@@ -1408,11 +1408,11 @@ discard block |
||
1408 | 1408 | break; |
1409 | 1409 | } |
1410 | 1410 | } |
1411 | - if($success) { |
|
1411 | + if ($success) { |
|
1412 | 1412 | $success = rmdir($dirPath); |
1413 | 1413 | } |
1414 | 1414 | } |
1415 | - if(!$success) { |
|
1415 | + if (!$success) { |
|
1416 | 1416 | $this->setError(elFinder::ERROR_RM, $dirPath); |
1417 | 1417 | return false; |
1418 | 1418 | } |
@@ -1434,25 +1434,25 @@ discard block |
||
1434 | 1434 | if (!is_dir($dir)) { |
1435 | 1435 | return false; |
1436 | 1436 | } |
1437 | - $excludes = array(".",".."); |
|
1437 | + $excludes = array(".", ".."); |
|
1438 | 1438 | $result = array(); |
1439 | 1439 | $files = scandir($dir); |
1440 | - if(!$files) { |
|
1440 | + if (!$files) { |
|
1441 | 1441 | return array(); |
1442 | 1442 | } |
1443 | - foreach($files as $file) { |
|
1444 | - if(!in_array($file, $excludes)) { |
|
1443 | + foreach ($files as $file) { |
|
1444 | + if (!in_array($file, $excludes)) { |
|
1445 | 1445 | $path = $dir.DIRECTORY_SEPARATOR.$file; |
1446 | - if(is_link($path)) { |
|
1447 | - if($omitSymlinks) { |
|
1446 | + if (is_link($path)) { |
|
1447 | + if ($omitSymlinks) { |
|
1448 | 1448 | continue; |
1449 | 1449 | } else { |
1450 | 1450 | $result[] = $prefix.$file; |
1451 | 1451 | } |
1452 | - } else if(is_dir($path)) { |
|
1452 | + } else if (is_dir($path)) { |
|
1453 | 1453 | $result[] = $prefix.$file.DIRECTORY_SEPARATOR; |
1454 | 1454 | $subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix.$file.DIRECTORY_SEPARATOR); |
1455 | - if($subs) { |
|
1455 | + if ($subs) { |
|
1456 | 1456 | $result = array_merge($result, $subs); |
1457 | 1457 | } |
1458 | 1458 |
@@ -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', 'tmpPath', 'quarantine') as $key) { |
|
56 | + foreach (array('path', 'tmpPath', 'quarantine') as $key) { |
|
57 | 57 | if ($this->options[$key]) { |
58 | 58 | $this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]); |
59 | 59 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // if no thumbnails url - try detect it |
100 | 100 | if ($root['read'] && !$this->tmbURL && $this->URL) { |
101 | 101 | if (strpos($this->tmbPath, $this->root) === 0) { |
102 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); |
|
102 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); |
|
103 | 103 | if (preg_match("|[^/?&=]$|", $this->tmbURL)) { |
104 | 104 | $this->tmbURL .= '/'; |
105 | 105 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @author Dmitry (dio) Levashov |
176 | 176 | **/ |
177 | 177 | protected function _joinPath($dir, $name) { |
178 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
178 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $comps = $new_comps; |
228 | 228 | $path = implode('/', $comps); |
229 | 229 | if ($initial_slashes) { |
230 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
230 | + $path = str_repeat('/', $initial_slashes).$path; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if ($changeSep) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | **/ |
299 | 299 | protected function _inpath($path, $parent) { |
300 | 300 | $cwd = getcwd(); |
301 | - $real_path = $this->getFullPath($path, $cwd); |
|
301 | + $real_path = $this->getFullPath($path, $cwd); |
|
302 | 302 | $real_parent = $this->getFullPath($parent, $cwd); |
303 | 303 | if ($real_path && $real_parent) { |
304 | 304 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $stat = array(); |
358 | 358 | return $stat; |
359 | 359 | } else { |
360 | - $stat['mime'] = 'symlink-broken'; |
|
360 | + $stat['mime'] = 'symlink-broken'; |
|
361 | 361 | $target = readlink($path); |
362 | 362 | $lstat = lstat($path); |
363 | 363 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $fstat = stat($path); |
374 | 374 | $uid = $fstat['uid']; |
375 | 375 | $gid = $fstat['gid']; |
376 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
376 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
377 | 377 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
378 | 378 | } |
379 | 379 | |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
384 | 384 | } |
385 | 385 | //logical rights first |
386 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
387 | - $stat['write'] = is_writable($path)? null : false; |
|
386 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
387 | + $stat['write'] = is_writable($path) ? null : false; |
|
388 | 388 | |
389 | 389 | if (is_null($stat['read'])) { |
390 | 390 | $stat['size'] = $dir ? 0 : $size; |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | protected function _subdirs($path) { |
454 | 454 | |
455 | 455 | if (is_dir($path)) { |
456 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
456 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
457 | 457 | } |
458 | 458 | return false; |
459 | 459 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $br = true; |
535 | 535 | } else { |
536 | 536 | $_path = $fpath; |
537 | - $stat['mime'] = 'symlink-broken'; |
|
537 | + $stat['mime'] = 'symlink-broken'; |
|
538 | 538 | $target = readlink($_path); |
539 | 539 | $lstat = lstat($_path); |
540 | 540 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -559,13 +559,13 @@ discard block |
||
559 | 559 | if ($statOwner && !$linkreadable) { |
560 | 560 | $uid = $file->getOwner(); |
561 | 561 | $gid = $file->getGroup(); |
562 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
562 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
563 | 563 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
564 | 564 | } |
565 | 565 | |
566 | 566 | //logical rights first |
567 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
568 | - $stat['write'] = $file->isWritable()? null : false; |
|
567 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
568 | + $stat['write'] = $file->isWritable() ? null : false; |
|
569 | 569 | |
570 | 570 | if (is_null($stat['read'])) { |
571 | 571 | $stat['size'] = $dir ? 0 : $size; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | |
582 | 582 | if ($cache) { |
583 | 583 | $cache = $this->convEncOut($cache, false); |
584 | - foreach($cache as $d) { |
|
584 | + foreach ($cache as $d) { |
|
585 | 585 | $this->updateCache($d[0], $d[1]); |
586 | 586 | } |
587 | 587 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @return resource|false |
598 | 598 | * @author Dmitry (dio) Levashov |
599 | 599 | **/ |
600 | - protected function _fopen($path, $mode='rb') { |
|
600 | + protected function _fopen($path, $mode = 'rb') { |
|
601 | 601 | return @fopen($path, $mode); |
602 | 602 | } |
603 | 603 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @return bool |
609 | 609 | * @author Dmitry (dio) Levashov |
610 | 610 | **/ |
611 | - protected function _fclose($fp, $path='') { |
|
611 | + protected function _fclose($fp, $path = '') { |
|
612 | 612 | return @fclose($fp); |
613 | 613 | } |
614 | 614 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | $path = $this->_joinPath($dir, $name); |
741 | 741 | |
742 | 742 | $meta = stream_get_meta_data($fp); |
743 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
743 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
744 | 744 | if ($uri && @is_file($uri)) { |
745 | 745 | fclose($fp); |
746 | 746 | if (!@rename($uri, $path) && !@copy($uri, $path)) { |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | * @return bool |
801 | 801 | **/ |
802 | 802 | protected function _chmod($path, $mode) { |
803 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
803 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
804 | 804 | $ret = @chmod($path, $modeOct); |
805 | 805 | $ret && clearstatcache(); |
806 | 806 | return $ret; |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | $src = $dir; |
919 | 919 | $name = basename($path); |
920 | 920 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
921 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
921 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
922 | 922 | } |
923 | 923 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
924 | 924 | if (file_exists($test) || is_link($test)) { |
@@ -927,9 +927,9 @@ discard block |
||
927 | 927 | } |
928 | 928 | |
929 | 929 | if ($name !== '') { |
930 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
930 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
931 | 931 | |
932 | - if (! @rename($src, $result)) { |
|
932 | + if (!@rename($src, $result)) { |
|
933 | 933 | $this->delTree($dir); |
934 | 934 | return false; |
935 | 935 | } |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | $dstDir = dirname($path); |
938 | 938 | $res = false; |
939 | 939 | $result = array(); |
940 | - foreach($ls as $name) { |
|
940 | + foreach ($ls as $name) { |
|
941 | 941 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
942 | 942 | if (is_dir($target)) { |
943 | 943 | $this->delTree($target); |
@@ -1013,14 +1013,14 @@ discard block |
||
1013 | 1013 | $result = array(); |
1014 | 1014 | |
1015 | 1015 | $path = $this->convEncIn($path); |
1016 | - $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
1017 | - $match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$q.'*', GLOB_NOSORT); |
|
1016 | + $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
1017 | + $match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$q.'*', GLOB_NOSORT); |
|
1018 | 1018 | if ($dirs) { |
1019 | 1019 | $dirs = $this->convEncOut($dirs, false); |
1020 | 1020 | } |
1021 | 1021 | $match = $this->convEncOut($match); |
1022 | 1022 | if ($match) { |
1023 | - foreach($match as $p) { |
|
1023 | + foreach ($match as $p) { |
|
1024 | 1024 | $stat = $this->stat($p); |
1025 | 1025 | |
1026 | 1026 | if (!$stat) { // invalid links |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | if ($this->encoding) { |
1041 | 1041 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
1042 | 1042 | } |
1043 | - $stat['url'] = $this->URL . $path; |
|
1043 | + $stat['url'] = $this->URL.$path; |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | $result[] = $stat; |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | if ($dirs) { |
1051 | - foreach($dirs as $dir) { |
|
1051 | + foreach ($dirs as $dir) { |
|
1052 | 1052 | $stat = $this->stat($dir); |
1053 | 1053 | if ($stat['read'] && !isset($stat['alias'])) { |
1054 | 1054 | @set_time_limit(30); |
@@ -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); |
@@ -368,7 +368,6 @@ discard block |
||
368 | 368 | * Open file and return file pointer |
369 | 369 | * |
370 | 370 | * @param string $path file path |
371 | - * @param bool $write open file for writing |
|
372 | 371 | * @return resource|false |
373 | 372 | * @author Dmitry (dio) Levashov, |
374 | 373 | * @author Alexey Sukhotin |
@@ -407,7 +406,7 @@ discard block |
||
407 | 406 | * |
408 | 407 | * @param resource $fp file pointer |
409 | 408 | * @param string $path file path |
410 | - * @return bool |
|
409 | + * @return boolean|null |
|
411 | 410 | * @author Dmitry (dio) Levashov |
412 | 411 | **/ |
413 | 412 | protected function _fclose($fp, $path='') { |
@@ -492,7 +491,7 @@ discard block |
||
492 | 491 | * Copy file into another file (only inside one volume) |
493 | 492 | * |
494 | 493 | * @param string $source source file path |
495 | - * @param string $target target dir path |
|
494 | + * @param string $targetDir target dir path |
|
496 | 495 | * @param string $name file name |
497 | 496 | * @return bool |
498 | 497 | * @author Dmitry (dio) Levashov |
@@ -506,9 +505,9 @@ discard block |
||
506 | 505 | * Return new file path or false. |
507 | 506 | * |
508 | 507 | * @param string $source source file path |
509 | - * @param string $target target dir path |
|
508 | + * @param string $targetDir target dir path |
|
510 | 509 | * @param string $name file name |
511 | - * @return string|bool |
|
510 | + * @return boolean |
|
512 | 511 | * @author Dmitry (dio) Levashov |
513 | 512 | **/ |
514 | 513 | protected function _move($source, $targetDir, $name) { |
@@ -573,7 +572,7 @@ discard block |
||
573 | 572 | * @param resource $fp file pointer |
574 | 573 | * @param string $dir target dir path |
575 | 574 | * @param string $name file name |
576 | - * @return bool|string |
|
575 | + * @return boolean |
|
577 | 576 | * @author Dmitry (dio) Levashov |
578 | 577 | **/ |
579 | 578 | protected function _save($fp, $dir, $name, $mime, $stat) { |
@@ -584,7 +583,7 @@ discard block |
||
584 | 583 | * Get file contents |
585 | 584 | * |
586 | 585 | * @param string $path file path |
587 | - * @return string|false |
|
586 | + * @return boolean |
|
588 | 587 | * @author Dmitry (dio) Levashov |
589 | 588 | **/ |
590 | 589 | protected function _getContents($path) { |
@@ -623,7 +622,7 @@ discard block |
||
623 | 622 | * @param array $files files names list |
624 | 623 | * @param string $name archive name |
625 | 624 | * @param array $arc archiver options |
626 | - * @return string|bool |
|
625 | + * @return boolean |
|
627 | 626 | * @author Dmitry (dio) Levashov, |
628 | 627 | * @author Alexey Sukhotin |
629 | 628 | **/ |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | **/ |
62 | 62 | protected function _dirname($path) { |
63 | 63 | |
64 | - $newpath = preg_replace("/\/$/", "", $path); |
|
65 | - $dn = substr($path, 0, strrpos($newpath, '/')) ; |
|
64 | + $newpath = preg_replace("/\/$/", "", $path); |
|
65 | + $dn = substr($path, 0, strrpos($newpath, '/')); |
|
66 | 66 | |
67 | 67 | if (substr($dn, 0, 1) != '/') { |
68 | 68 | $dn = "/$dn"; |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @author Troex Nevelin |
106 | 106 | **/ |
107 | 107 | protected function _normpath($path) { |
108 | - $tmp = preg_replace("/^\//", "", $path); |
|
109 | - $tmp = preg_replace("/\/\//", "/", $tmp); |
|
110 | - $tmp = preg_replace("/\/$/", "", $tmp); |
|
108 | + $tmp = preg_replace("/^\//", "", $path); |
|
109 | + $tmp = preg_replace("/\/\//", "/", $tmp); |
|
110 | + $tmp = preg_replace("/\/$/", "", $tmp); |
|
111 | 111 | return $tmp; |
112 | 112 | } |
113 | 113 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | $newpath = "/$newpath"; |
129 | 129 | } |
130 | 130 | |
131 | - $newpath = preg_replace("/\/$/", "", $newpath); |
|
131 | + $newpath = preg_replace("/\/$/", "", $newpath); |
|
132 | 132 | |
133 | - $ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root)+1); |
|
133 | + $ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root) + 1); |
|
134 | 134 | |
135 | 135 | return $ret; |
136 | 136 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $np = $this->_normpath($path); |
232 | 232 | |
233 | 233 | try { |
234 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false)); |
|
234 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false)); |
|
235 | 235 | } catch (Exception $e) { |
236 | 236 | |
237 | 237 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | if (!isset($obj) || ($obj->GetObjectResponse->Status->Code != 200)) { |
240 | 240 | $np .= '/'; |
241 | 241 | try { |
242 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false)); |
|
242 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false)); |
|
243 | 243 | } catch (Exception $e) { |
244 | 244 | |
245 | 245 | } |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | **/ |
342 | 342 | protected function _scandir($path) { |
343 | 343 | |
344 | - $s3path = preg_replace("/^\//", "", $path) . '/'; |
|
344 | + $s3path = preg_replace("/^\//", "", $path).'/'; |
|
345 | 345 | |
346 | 346 | $files = $this->s3->ListBucket(array('Bucket' => $this->options['bucket'], 'delimiter' => '/', 'Prefix' => $s3path))->ListBucketResponse->Contents; |
347 | 347 | |
348 | 348 | $finalfiles = array(); |
349 | 349 | |
350 | 350 | foreach ($files as $file) { |
351 | - if (preg_match("|^" . $s3path . "[^/]*/?$|", $file->Key)) { |
|
351 | + if (preg_match("|^".$s3path."[^/]*/?$|", $file->Key)) { |
|
352 | 352 | $fname = preg_replace("/\/$/", "", $file->Key); |
353 | 353 | $fname = $file->Key; |
354 | 354 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @author Dmitry (dio) Levashov, |
374 | 374 | * @author Alexey Sukhotin |
375 | 375 | **/ |
376 | - protected function _fopen($path, $mode="rb") { |
|
376 | + protected function _fopen($path, $mode = "rb") { |
|
377 | 377 | |
378 | 378 | $tn = $this->getTempFile($path); |
379 | 379 | |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | if ($fp) { |
386 | 386 | |
387 | 387 | try { |
388 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path) , 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true)); |
|
389 | - } catch (Exception $e) { |
|
388 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path), 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true)); |
|
389 | + } catch (Exception $e) { |
|
390 | 390 | |
391 | 391 | } |
392 | 392 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @return bool |
411 | 411 | * @author Dmitry (dio) Levashov |
412 | 412 | **/ |
413 | - protected function _fclose($fp, $path='') { |
|
413 | + protected function _fclose($fp, $path = '') { |
|
414 | 414 | @fclose($fp); |
415 | 415 | if ($path) { |
416 | 416 | @unlink($this->getTempFile($path)); |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $newkey = "$newkey/$name/"; |
436 | 436 | |
437 | 437 | try { |
438 | - $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => '')); |
|
438 | + $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => '')); |
|
439 | 439 | } catch (Exception $e) { |
440 | 440 | |
441 | 441 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $newkey = "$newkey/$name"; |
463 | 463 | |
464 | 464 | try { |
465 | - $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain')))); |
|
465 | + $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain')))); |
|
466 | 466 | } catch (Exception $e) { |
467 | 467 | |
468 | 468 | } |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @author Dmitry (dio) Levashov |
564 | 564 | **/ |
565 | 565 | protected function _rmdir($path) { |
566 | - return $this->_unlink($path . '/'); |
|
566 | + return $this->_unlink($path.'/'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | /* Getting list of S3 web service functions which requires signing */ |
683 | 683 | $funcs = $this->__getFunctions(); |
684 | 684 | |
685 | - $funcnames = array(); |
|
685 | + $funcnames = array(); |
|
686 | 686 | |
687 | 687 | foreach ($funcs as $func) { |
688 | 688 | preg_match("/\S+\s+([^\)]+)\(/", $func, $m); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | 'Timestamp' => gmdate('Y-m-d\TH:i:s.000\Z'), |
724 | 724 | ); |
725 | 725 | |
726 | - $sign_str = 'AmazonS3' . $operation . $params['Timestamp']; |
|
726 | + $sign_str = 'AmazonS3'.$operation.$params['Timestamp']; |
|
727 | 727 | |
728 | 728 | $params['Signature'] = base64_encode(hash_hmac('sha1', $sign_str, $this->secretkey, TRUE)); |
729 | 729 |
@@ -386,7 +386,7 @@ |
||
386 | 386 | |
387 | 387 | try { |
388 | 388 | $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path) , 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true)); |
389 | - } catch (Exception $e) { |
|
389 | + } catch (Exception $e) { |
|
390 | 390 | |
391 | 391 | } |
392 | 392 |
@@ -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); |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | |
51 | 51 | public function __construct($opts) { |
52 | 52 | $defaults = array( |
53 | - 'enable' => true, // For control by volume driver |
|
54 | - 'maxWidth' => 1024, // Path to Water mark image |
|
55 | - 'maxHeight' => 1024, // Margin right pixel |
|
56 | - 'quality' => 95, // JPEG image save quality |
|
57 | - 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
53 | + 'enable' => true, // For control by volume driver |
|
54 | + 'maxWidth' => 1024, // Path to Water mark image |
|
55 | + 'maxHeight' => 1024, // Margin right pixel |
|
56 | + 'quality' => 95, // JPEG image save quality |
|
57 | + 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field ) |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | $this->opts = array_merge($defaults, $opts); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $opts = array_merge($this->opts, $volOpts); |
69 | 69 | } |
70 | 70 | |
71 | - if (! $opts['enable']) { |
|
71 | + if (!$opts['enable']) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | IMAGETYPE_PNG => IMG_PNG, |
85 | 85 | IMAGETYPE_WBMP => IMG_WBMP, |
86 | 86 | ); |
87 | - if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
87 | + if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality) { |
99 | - $zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1])); |
|
100 | - $width = round($srcImgInfo[0] * $zoom); |
|
101 | - $height = round($srcImgInfo[1] * $zoom); |
|
99 | + $zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1])); |
|
100 | + $width = round($srcImgInfo[0]*$zoom); |
|
101 | + $height = round($srcImgInfo[1]*$zoom); |
|
102 | 102 | |
103 | 103 | if (class_exists('Imagick')) { |
104 | 104 | return $this->resize_imagick($src, $width, $height, $quality); |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | break; |
119 | 119 | case 'image/jpeg': |
120 | 120 | if (@imagetypes() & IMG_JPG) { |
121 | - $oSrcImg = @imagecreatefromjpeg($src) ; |
|
121 | + $oSrcImg = @imagecreatefromjpeg($src); |
|
122 | 122 | } else { |
123 | 123 | $ermsg = 'JPEG images are not supported'; |
124 | 124 | } |
125 | 125 | break; |
126 | 126 | case 'image/png': |
127 | 127 | if (@imagetypes() & IMG_PNG) { |
128 | - $oSrcImg = @imagecreatefrompng($src) ; |
|
128 | + $oSrcImg = @imagecreatefrompng($src); |
|
129 | 129 | } else { |
130 | 130 | $ermsg = 'PNG images are not supported'; |
131 | 131 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | break; |
144 | 144 | } |
145 | 145 | |
146 | - if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
146 | + if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
147 | 147 | |
148 | 148 | if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) { |
149 | 149 | return false; |
@@ -1,49 +1,49 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * elFinder Plugin AutoResize |
|
4 | - * |
|
5 | - * Auto resize on file upload. |
|
6 | - * |
|
7 | - * ex. binding, configure on connector options |
|
8 | - * $opts = array( |
|
9 | - * 'bind' => array( |
|
10 | - * 'upload.presave' => array( |
|
11 | - * 'Plugin.AutoResize.onUpLoadPreSave' |
|
12 | - * ) |
|
13 | - * ), |
|
14 | - * // global configure (optional) |
|
15 | - * 'plugin' => array( |
|
16 | - * 'PluginAutoResize' => array( |
|
17 | - * 'enable' => true, // For control by volume driver |
|
18 | - * 'maxWidth' => 1024, // Path to Water mark image |
|
19 | - * 'maxHeight' => 1024, // Margin right pixel |
|
20 | - * 'quality' => 95, // JPEG image save quality |
|
21 | - * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
22 | - * ) |
|
23 | - * ), |
|
24 | - * // each volume configure (optional) |
|
25 | - * 'roots' => array( |
|
26 | - * array( |
|
27 | - * 'driver' => 'LocalFileSystem', |
|
28 | - * 'path' => '/path/to/files/', |
|
29 | - * 'URL' => 'http://localhost/to/files/' |
|
30 | - * 'plugin' => array( |
|
31 | - * 'PluginAutoResize' => array( |
|
32 | - * 'enable' => true, // For control by volume driver |
|
33 | - * 'maxWidth' => 1024, // Path to Water mark image |
|
34 | - * 'maxHeight' => 1024, // Margin right pixel |
|
35 | - * 'quality' => 95, // JPEG image save quality |
|
36 | - * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
37 | - * ) |
|
38 | - * ) |
|
39 | - * ) |
|
40 | - * ) |
|
41 | - * ); |
|
42 | - * |
|
43 | - * @package elfinder |
|
44 | - * @author Naoki Sawada |
|
45 | - * @license New BSD |
|
46 | - */ |
|
3 | + * elFinder Plugin AutoResize |
|
4 | + * |
|
5 | + * Auto resize on file upload. |
|
6 | + * |
|
7 | + * ex. binding, configure on connector options |
|
8 | + * $opts = array( |
|
9 | + * 'bind' => array( |
|
10 | + * 'upload.presave' => array( |
|
11 | + * 'Plugin.AutoResize.onUpLoadPreSave' |
|
12 | + * ) |
|
13 | + * ), |
|
14 | + * // global configure (optional) |
|
15 | + * 'plugin' => array( |
|
16 | + * 'PluginAutoResize' => array( |
|
17 | + * 'enable' => true, // For control by volume driver |
|
18 | + * 'maxWidth' => 1024, // Path to Water mark image |
|
19 | + * 'maxHeight' => 1024, // Margin right pixel |
|
20 | + * 'quality' => 95, // JPEG image save quality |
|
21 | + * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
22 | + * ) |
|
23 | + * ), |
|
24 | + * // each volume configure (optional) |
|
25 | + * 'roots' => array( |
|
26 | + * array( |
|
27 | + * 'driver' => 'LocalFileSystem', |
|
28 | + * 'path' => '/path/to/files/', |
|
29 | + * 'URL' => 'http://localhost/to/files/' |
|
30 | + * 'plugin' => array( |
|
31 | + * 'PluginAutoResize' => array( |
|
32 | + * 'enable' => true, // For control by volume driver |
|
33 | + * 'maxWidth' => 1024, // Path to Water mark image |
|
34 | + * 'maxHeight' => 1024, // Margin right pixel |
|
35 | + * 'quality' => 95, // JPEG image save quality |
|
36 | + * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
37 | + * ) |
|
38 | + * ) |
|
39 | + * ) |
|
40 | + * ) |
|
41 | + * ); |
|
42 | + * |
|
43 | + * @package elfinder |
|
44 | + * @author Naoki Sawada |
|
45 | + * @license New BSD |
|
46 | + */ |
|
47 | 47 | class elFinderPluginAutoResize { |
48 | 48 | |
49 | 49 | private $opts = array(); |
@@ -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); |