@@ -1344,7 +1344,7 @@ |
||
1344 | 1344 | * |
1345 | 1345 | * @param string $str |
1346 | 1346 | * @param array $extTable |
1347 | - * @return array |
|
1347 | + * @return string[] |
|
1348 | 1348 | * @author Naoki Sawada |
1349 | 1349 | */ |
1350 | 1350 | protected function parse_data_scheme( $str, $extTable ) { |
@@ -1149,18 +1149,18 @@ discard block |
||
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | /** |
1152 | - * Get remote contents |
|
1153 | - * |
|
1154 | - * @param string $url target url |
|
1155 | - * @param int $timeout timeout (sec) |
|
1156 | - * @param int $redirect_max redirect max count |
|
1157 | - * @param string $ua |
|
1158 | - * @param resource $fp |
|
1159 | - * @return string or bool(false) |
|
1160 | - * @retval string contents |
|
1161 | - * @retval false error |
|
1162 | - * @author Naoki Sawada |
|
1163 | - **/ |
|
1152 | + * Get remote contents |
|
1153 | + * |
|
1154 | + * @param string $url target url |
|
1155 | + * @param int $timeout timeout (sec) |
|
1156 | + * @param int $redirect_max redirect max count |
|
1157 | + * @param string $ua |
|
1158 | + * @param resource $fp |
|
1159 | + * @return string or bool(false) |
|
1160 | + * @retval string contents |
|
1161 | + * @retval false error |
|
1162 | + * @author Naoki Sawada |
|
1163 | + **/ |
|
1164 | 1164 | protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) { |
1165 | 1165 | $method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; |
1166 | 1166 | return $this->$method( $url, $timeout, $redirect_max, $ua, $fp ); |
@@ -2090,12 +2090,12 @@ discard block |
||
2090 | 2090 | } |
2091 | 2091 | |
2092 | 2092 | /** |
2093 | - * Return content URL |
|
2094 | - * |
|
2095 | - * @param array $args command arguments |
|
2096 | - * @return array |
|
2097 | - * @author Naoki Sawada |
|
2098 | - **/ |
|
2093 | + * Return content URL |
|
2094 | + * |
|
2095 | + * @param array $args command arguments |
|
2096 | + * @return array |
|
2097 | + * @author Naoki Sawada |
|
2098 | + **/ |
|
2099 | 2099 | protected function url($args) { |
2100 | 2100 | $target = $args['target']; |
2101 | 2101 | $options = isset($args['options'])? $args['options'] : array(); |
@@ -1241,8 +1241,12 @@ discard block |
||
1241 | 1241 | |
1242 | 1242 | $query = $method.' '.$uri." HTTP/1.0\r\n"; |
1243 | 1243 | $query .= "Host: ".$arr['host']."\r\n"; |
1244 | - if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n"; |
|
1245 | - if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1244 | + if (!empty($ua)) { |
|
1245 | + $query .= "User-Agent: ".$ua."\r\n"; |
|
1246 | + } |
|
1247 | + if (!is_null($getSize)) { |
|
1248 | + $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1249 | + } |
|
1246 | 1250 | |
1247 | 1251 | $query .= $headers; |
1248 | 1252 | |
@@ -1257,7 +1261,9 @@ discard block |
||
1257 | 1261 | $arr['https'].$arr['host'], |
1258 | 1262 | $arr['port'], |
1259 | 1263 | $errno,$errstr,$connect_timeout); |
1260 | - if ($fp) break; |
|
1264 | + if ($fp) { |
|
1265 | + break; |
|
1266 | + } |
|
1261 | 1267 | $connect_try_count++; |
1262 | 1268 | if (connection_aborted()) { |
1263 | 1269 | exit(); |
@@ -1574,7 +1580,9 @@ discard block |
||
1574 | 1580 | $tempDir = ''; |
1575 | 1581 | $test = DIRECTORY_SEPARATOR . microtime(true); |
1576 | 1582 | foreach($testDirs as $testDir) { |
1577 | - if (!$testDir || !is_dir($testDir)) continue; |
|
1583 | + if (!$testDir || !is_dir($testDir)) { |
|
1584 | + continue; |
|
1585 | + } |
|
1578 | 1586 | $testFile = $testDir.$test; |
1579 | 1587 | if (touch($testFile)) { |
1580 | 1588 | unlink($testFile); |
@@ -1810,7 +1818,9 @@ discard block |
||
1810 | 1818 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER); |
1811 | 1819 | $this->uploadDebug = 'Upload error: unable open tmp file'; |
1812 | 1820 | if (! is_uploaded_file($tmpname)) { |
1813 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
|
1821 | + if (@ unlink($tmpname)) { |
|
1822 | + unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
|
1823 | + } |
|
1814 | 1824 | continue; |
1815 | 1825 | } |
1816 | 1826 | break; |
@@ -1824,7 +1834,10 @@ discard block |
||
1824 | 1834 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error()); |
1825 | 1835 | fclose($fp); |
1826 | 1836 | if (! is_uploaded_file($tmpname)) { |
1827 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);; |
|
1837 | + if (@ unlink($tmpname)) { |
|
1838 | + unset($GLOBALS['elFinderTempFiles'][$tmpname]); |
|
1839 | + } |
|
1840 | + ; |
|
1828 | 1841 | continue; |
1829 | 1842 | } |
1830 | 1843 | break; |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | const ERROR_INV_PARAMS = 'errCmdParams'; |
204 | 204 | const ERROR_OPEN = 'errOpen'; |
205 | 205 | const ERROR_DIR_NOT_FOUND = 'errFolderNotFound'; |
206 | - const ERROR_FILE_NOT_FOUND = 'errFileNotFound'; // 'File not found.' |
|
206 | + const ERROR_FILE_NOT_FOUND = 'errFileNotFound'; // 'File not found.' |
|
207 | 207 | const ERROR_TRGDIR_NOT_FOUND = 'errTrgFolderNotFound'; // 'Target folder "$1" not found.' |
208 | 208 | const ERROR_NOT_DIR = 'errNotFolder'; |
209 | 209 | const ERROR_NOT_FILE = 'errNotFile'; |
210 | 210 | const ERROR_PERM_DENIED = 'errPerm'; |
211 | - const ERROR_LOCKED = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.' |
|
212 | - const ERROR_EXISTS = 'errExists'; // 'File named "$1" already exists.' |
|
213 | - const ERROR_INVALID_NAME = 'errInvName'; // 'Invalid file name.' |
|
211 | + const ERROR_LOCKED = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.' |
|
212 | + const ERROR_EXISTS = 'errExists'; // 'File named "$1" already exists.' |
|
213 | + const ERROR_INVALID_NAME = 'errInvName'; // 'Invalid file name.' |
|
214 | 214 | const ERROR_MKDIR = 'errMkdir'; |
215 | 215 | const ERROR_MKFILE = 'errMkfile'; |
216 | 216 | const ERROR_RENAME = 'errRename'; |
@@ -219,20 +219,20 @@ discard block |
||
219 | 219 | const ERROR_COPY_FROM = 'errCopyFrom'; |
220 | 220 | const ERROR_COPY_TO = 'errCopyTo'; |
221 | 221 | const ERROR_COPY_ITSELF = 'errCopyInItself'; |
222 | - const ERROR_REPLACE = 'errReplace'; // 'Unable to replace "$1".' |
|
223 | - const ERROR_RM = 'errRm'; // 'Unable to remove "$1".' |
|
224 | - const ERROR_RM_SRC = 'errRmSrc'; // 'Unable remove source file(s)' |
|
225 | - const ERROR_MKOUTLINK = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.' |
|
226 | - const ERROR_UPLOAD = 'errUpload'; // 'Upload error.' |
|
227 | - const ERROR_UPLOAD_FILE = 'errUploadFile'; // 'Unable to upload "$1".' |
|
228 | - const ERROR_UPLOAD_NO_FILES = 'errUploadNoFiles'; // 'No files found for upload.' |
|
229 | - const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.' |
|
230 | - const ERROR_UPLOAD_FILE_SIZE = 'errUploadFileSize'; // 'File exceeds maximum allowed size.' |
|
231 | - const ERROR_UPLOAD_FILE_MIME = 'errUploadMime'; // 'File type not allowed.' |
|
232 | - const ERROR_UPLOAD_TRANSFER = 'errUploadTransfer'; // '"$1" transfer error.' |
|
233 | - const ERROR_UPLOAD_TEMP = 'errUploadTemp'; // 'Unable to make temporary file for upload.' |
|
222 | + const ERROR_REPLACE = 'errReplace'; // 'Unable to replace "$1".' |
|
223 | + const ERROR_RM = 'errRm'; // 'Unable to remove "$1".' |
|
224 | + const ERROR_RM_SRC = 'errRmSrc'; // 'Unable remove source file(s)' |
|
225 | + const ERROR_MKOUTLINK = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.' |
|
226 | + const ERROR_UPLOAD = 'errUpload'; // 'Upload error.' |
|
227 | + const ERROR_UPLOAD_FILE = 'errUploadFile'; // 'Unable to upload "$1".' |
|
228 | + const ERROR_UPLOAD_NO_FILES = 'errUploadNoFiles'; // 'No files found for upload.' |
|
229 | + const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.' |
|
230 | + const ERROR_UPLOAD_FILE_SIZE = 'errUploadFileSize'; // 'File exceeds maximum allowed size.' |
|
231 | + const ERROR_UPLOAD_FILE_MIME = 'errUploadMime'; // 'File type not allowed.' |
|
232 | + const ERROR_UPLOAD_TRANSFER = 'errUploadTransfer'; // '"$1" transfer error.' |
|
233 | + const ERROR_UPLOAD_TEMP = 'errUploadTemp'; // 'Unable to make temporary file for upload.' |
|
234 | 234 | // const ERROR_ACCESS_DENIED = 'errAccess'; |
235 | - const ERROR_NOT_REPLACE = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type. |
|
235 | + const ERROR_NOT_REPLACE = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type. |
|
236 | 236 | const ERROR_SAVE = 'errSave'; |
237 | 237 | const ERROR_EXTRACT = 'errExtract'; |
238 | 238 | const ERROR_ARCHIVE = 'errArchive'; |
@@ -247,14 +247,14 @@ discard block |
||
247 | 247 | const ERROR_NETMOUNT = 'errNetMount'; |
248 | 248 | const ERROR_NETUNMOUNT = 'errNetUnMount'; |
249 | 249 | const ERROR_NETMOUNT_NO_DRIVER = 'errNetMountNoDriver'; |
250 | - const ERROR_NETMOUNT_FAILED = 'errNetMountFailed'; |
|
250 | + const ERROR_NETMOUNT_FAILED = 'errNetMountFailed'; |
|
251 | 251 | |
252 | - const ERROR_SESSION_EXPIRES = 'errSessionExpires'; |
|
252 | + const ERROR_SESSION_EXPIRES = 'errSessionExpires'; |
|
253 | 253 | |
254 | 254 | const ERROR_CREATING_TEMP_DIR = 'errCreatingTempDir'; |
255 | 255 | const ERROR_FTP_DOWNLOAD_FILE = 'errFtpDownloadFile'; |
256 | - const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile'; |
|
257 | - const ERROR_FTP_MKDIR = 'errFtpMkdir'; |
|
256 | + const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile'; |
|
257 | + const ERROR_FTP_MKDIR = 'errFtpMkdir'; |
|
258 | 258 | const ERROR_ARCHIVE_EXEC = 'errArchiveExec'; |
259 | 259 | const ERROR_EXTRACT_EXEC = 'errExtractExec'; |
260 | 260 | |
@@ -281,17 +281,17 @@ discard block |
||
281 | 281 | |
282 | 282 | $this->time = $this->utime(); |
283 | 283 | $this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false); |
284 | - $this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true; |
|
284 | + $this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true; |
|
285 | 285 | $this->sessionUseCmds = array_flip($sessionUseCmds); |
286 | 286 | $this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0); |
287 | 287 | $this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : ''); |
288 | - $this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes'; |
|
288 | + $this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes'; |
|
289 | 289 | $this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : ''); |
290 | 290 | self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches'; |
291 | 291 | |
292 | 292 | // check session cache |
293 | 293 | $_optsMD5 = md5(json_encode($opts['roots'])); |
294 | - if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) { |
|
294 | + if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) { |
|
295 | 295 | $_SESSION[self::$sessionCacheKey] = array( |
296 | 296 | '_optsMD5' => $_optsMD5 |
297 | 297 | ); |
@@ -310,20 +310,20 @@ discard block |
||
310 | 310 | $_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : ''; |
311 | 311 | foreach ($opts['bind'] as $cmd => $handlers) { |
312 | 312 | $doRegist = (strpos($cmd, '*') !== false); |
313 | - if (! $doRegist) { |
|
313 | + if (!$doRegist) { |
|
314 | 314 | $_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);'); |
315 | 315 | $doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd)))); |
316 | 316 | } |
317 | 317 | if ($doRegist) { |
318 | - if (! is_array($handlers) || is_object($handlers[0])) { |
|
318 | + if (!is_array($handlers) || is_object($handlers[0])) { |
|
319 | 319 | $handlers = array($handlers); |
320 | 320 | } |
321 | - foreach($handlers as $handler) { |
|
321 | + foreach ($handlers as $handler) { |
|
322 | 322 | if ($handler) { |
323 | 323 | if (is_string($handler) && strpos($handler, '.')) { |
324 | 324 | list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, ''); |
325 | 325 | if (strcasecmp($_domain, 'plugin') === 0) { |
326 | - if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array()) |
|
326 | + if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array()) |
|
327 | 327 | and method_exists($plugin, $_method)) { |
328 | 328 | $this->bind($cmd, array($plugin, $_method)); |
329 | 329 | } |
@@ -410,13 +410,13 @@ discard block |
||
410 | 410 | public function bind($cmd, $handler) { |
411 | 411 | $allCmds = array_keys($this->commands); |
412 | 412 | $cmds = array(); |
413 | - foreach(explode(' ', $cmd) as $_cmd) { |
|
413 | + foreach (explode(' ', $cmd) as $_cmd) { |
|
414 | 414 | if ($_cmd !== '') { |
415 | 415 | if ($all = strpos($_cmd, '*') !== false) { |
416 | 416 | list(, $sub) = array_pad(explode('.', $_cmd), 2, ''); |
417 | 417 | if ($sub) { |
418 | 418 | $sub = str_replace('\'', '\\\'', $sub); |
419 | - $addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');'); |
|
419 | + $addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');'); |
|
420 | 420 | $cmds = array_merge($cmds, array_map($addSub, $allCmds)); |
421 | 421 | } else { |
422 | 422 | $cmds = array_merge($cmds, $allCmds); |
@@ -496,16 +496,16 @@ discard block |
||
496 | 496 | |
497 | 497 | private function session_expires() { |
498 | 498 | |
499 | - if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) { |
|
500 | - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time(); |
|
499 | + if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) { |
|
500 | + $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time(); |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
504 | - if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) { |
|
504 | + if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) { |
|
505 | 505 | return true; |
506 | 506 | } |
507 | 507 | |
508 | - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time(); |
|
508 | + $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time(); |
|
509 | 509 | return false; |
510 | 510 | } |
511 | 511 | |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | } |
539 | 539 | |
540 | 540 | // call pre handlers for this command |
541 | - $args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier; |
|
541 | + $args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier; |
|
542 | 542 | if (!empty($this->listeners[$cmd.'.pre'])) { |
543 | - $volume = isset($args['target'])? $this->volume($args['target']) : false; |
|
543 | + $volume = isset($args['target']) ? $this->volume($args['target']) : false; |
|
544 | 544 | foreach ($this->listeners[$cmd.'.pre'] as $handler) { |
545 | 545 | call_user_func_array($handler, array($cmd, &$args, $this, $volume)); |
546 | 546 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | $this->sessionCloseEarlier && $args['sessionCloseEarlier'] && session_id() && session_write_close(); |
551 | 551 | unset($this->sessionCloseEarlier); |
552 | 552 | |
553 | - if (substr(PHP_OS,0,3) === 'WIN') { |
|
553 | + if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
554 | 554 | // set time out |
555 | 555 | if (($_max_execution_time = ini_get('max_execution_time')) && $_max_execution_time < 300) { |
556 | 556 | @set_time_limit(300); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | // call handlers for this command |
570 | 570 | if (!empty($this->listeners[$cmd])) { |
571 | 571 | foreach ($this->listeners[$cmd] as $handler) { |
572 | - if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) { |
|
572 | + if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) { |
|
573 | 573 | // handler return true to force sync client after command completed |
574 | 574 | $result['sync'] = true; |
575 | 575 | } |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * @return string |
629 | 629 | * @author Dmitry (dio) Levashov |
630 | 630 | **/ |
631 | - public function realpath($hash) { |
|
631 | + public function realpath($hash) { |
|
632 | 632 | if (($volume = $this->volume($hash)) == false) { |
633 | 633 | return false; |
634 | 634 | } |
@@ -684,11 +684,11 @@ discard block |
||
684 | 684 | */ |
685 | 685 | protected function getPluginInstance($name, $opts = array()) { |
686 | 686 | $key = strtolower($name); |
687 | - if (! isset($this->plugins[$key])) { |
|
688 | - $p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php'; |
|
687 | + if (!isset($this->plugins[$key])) { |
|
688 | + $p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php'; |
|
689 | 689 | if (is_file($p_file)) { |
690 | 690 | require_once $p_file; |
691 | - $class = 'elFinderPlugin' . $name; |
|
691 | + $class = 'elFinderPlugin'.$name; |
|
692 | 692 | $this->plugins[$key] = new $class($opts); |
693 | 693 | } else { |
694 | 694 | $this->plugins[$key] = false; |
@@ -780,8 +780,8 @@ discard block |
||
780 | 780 | |
781 | 781 | $netVolumes = $this->getNetVolumes(); |
782 | 782 | if ($volume->mount($options)) { |
783 | - if (! $key = @ $volume->netMountKey) { |
|
784 | - $key = md5($protocol . '-' . join('-', $options)); |
|
783 | + if (!$key = @ $volume->netMountKey) { |
|
784 | + $key = md5($protocol.'-'.join('-', $options)); |
|
785 | 785 | } |
786 | 786 | $options['driver'] = $driver; |
787 | 787 | $options['netkey'] = $key; |
@@ -980,24 +980,24 @@ discard block |
||
980 | 980 | } |
981 | 981 | |
982 | 982 | // allow change MIME type by 'file.pre' callback functions |
983 | - $mime = isset($args['mime'])? $args['mime'] : $file['mime']; |
|
983 | + $mime = isset($args['mime']) ? $args['mime'] : $file['mime']; |
|
984 | 984 | if ($download) { |
985 | 985 | $disp = 'attachment'; |
986 | 986 | } else { |
987 | 987 | $dispInlineRegex = $volume->getOption('dispInlineRegex'); |
988 | 988 | $inlineRegex = false; |
989 | 989 | if ($dispInlineRegex) { |
990 | - $inlineRegex = '#' . str_replace('#', '\\#', $dispInlineRegex) . '#'; |
|
990 | + $inlineRegex = '#'.str_replace('#', '\\#', $dispInlineRegex).'#'; |
|
991 | 991 | try { |
992 | 992 | preg_match($inlineRegex, ''); |
993 | - } catch(Exception $e) { |
|
993 | + } catch (Exception $e) { |
|
994 | 994 | $inlineRegex = false; |
995 | 995 | } |
996 | 996 | } |
997 | 997 | if (!$inlineRegex) { |
998 | 998 | $inlineRegex = '#^(?:(?:image|text)|application/x-shockwave-flash$)#'; |
999 | 999 | } |
1000 | - $disp = preg_match($inlineRegex, $mime)? 'inline' : 'attachment'; |
|
1000 | + $disp = preg_match($inlineRegex, $mime) ? 'inline' : 'attachment'; |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | $filenameEncoded = rawurlencode($file['name']); |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | $name = $args['name']; |
1107 | 1107 | |
1108 | 1108 | if (($volume = $this->volume($target)) == false |
1109 | - || ($rm = $volume->file($target)) == false) { |
|
1109 | + || ($rm = $volume->file($target)) == false) { |
|
1110 | 1110 | return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND)); |
1111 | 1111 | } |
1112 | 1112 | $rm['realpath'] = $volume->realpath($target); |
@@ -1184,9 +1184,9 @@ discard block |
||
1184 | 1184 | * @retval false error |
1185 | 1185 | * @author Naoki Sawada |
1186 | 1186 | **/ |
1187 | - protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) { |
|
1188 | - $method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; |
|
1189 | - return $this->$method( $url, $timeout, $redirect_max, $ua, $fp ); |
|
1187 | + protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) { |
|
1188 | + $method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; |
|
1189 | + return $this->$method($url, $timeout, $redirect_max, $ua, $fp); |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | /** |
@@ -1202,26 +1202,26 @@ discard block |
||
1202 | 1202 | * @retval false error |
1203 | 1203 | * @author Naoki Sawada |
1204 | 1204 | **/ |
1205 | - protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){ |
|
1205 | + protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
1206 | 1206 | $ch = curl_init(); |
1207 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
1208 | - curl_setopt( $ch, CURLOPT_HEADER, false ); |
|
1207 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1208 | + curl_setopt($ch, CURLOPT_HEADER, false); |
|
1209 | 1209 | if ($outfp) { |
1210 | - curl_setopt( $ch, CURLOPT_FILE, $outfp ); |
|
1210 | + curl_setopt($ch, CURLOPT_FILE, $outfp); |
|
1211 | 1211 | } else { |
1212 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
1213 | - curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true ); |
|
1214 | - } |
|
1215 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 ); |
|
1216 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout ); |
|
1217 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); |
|
1218 | - curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); |
|
1219 | - curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
1220 | - curl_setopt( $ch, CURLOPT_USERAGENT, $ua); |
|
1221 | - $result = curl_exec( $ch ); |
|
1212 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
1213 | + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); |
|
1214 | + } |
|
1215 | + curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1); |
|
1216 | + curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout); |
|
1217 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
1218 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
1219 | + curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
1220 | + curl_setopt($ch, CURLOPT_USERAGENT, $ua); |
|
1221 | + $result = curl_exec($ch); |
|
1222 | 1222 | $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
1223 | - curl_close( $ch ); |
|
1224 | - return $outfp? $outfp : $result; |
|
1223 | + curl_close($ch); |
|
1224 | + return $outfp ? $outfp : $result; |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | /** |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | * @retval false error |
1238 | 1238 | * @author Naoki Sawada |
1239 | 1239 | */ |
1240 | - protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) { |
|
1240 | + protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
1241 | 1241 | |
1242 | 1242 | $connect_timeout = 3; |
1243 | 1243 | $connect_try = 3; |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | $headers = ''; |
1249 | 1249 | |
1250 | 1250 | $arr = parse_url($url); |
1251 | - if (!$arr){ |
|
1251 | + if (!$arr) { |
|
1252 | 1252 | // Bad request |
1253 | 1253 | return false; |
1254 | 1254 | } |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | // query |
1257 | 1257 | $arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : ''; |
1258 | 1258 | // port |
1259 | - $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80); |
|
1259 | + $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80); |
|
1260 | 1260 | |
1261 | 1261 | $url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port']; |
1262 | 1262 | $url_path = isset($arr['path']) ? $arr['path'] : '/'; |
@@ -1265,21 +1265,21 @@ discard block |
||
1265 | 1265 | $query = $method.' '.$uri." HTTP/1.0\r\n"; |
1266 | 1266 | $query .= "Host: ".$arr['host']."\r\n"; |
1267 | 1267 | if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n"; |
1268 | - if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1268 | + if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n"; |
|
1269 | 1269 | |
1270 | 1270 | $query .= $headers; |
1271 | 1271 | |
1272 | 1272 | $query .= "\r\n"; |
1273 | 1273 | |
1274 | 1274 | $fp = $connect_try_count = 0; |
1275 | - while( !$fp && $connect_try_count < $connect_try ) { |
|
1275 | + while (!$fp && $connect_try_count < $connect_try) { |
|
1276 | 1276 | |
1277 | 1277 | $errno = 0; |
1278 | 1278 | $errstr = ""; |
1279 | 1279 | $fp = @ fsockopen( |
1280 | 1280 | $arr['https'].$arr['host'], |
1281 | 1281 | $arr['port'], |
1282 | - $errno,$errstr,$connect_timeout); |
|
1282 | + $errno, $errstr, $connect_timeout); |
|
1283 | 1283 | if ($fp) break; |
1284 | 1284 | $connect_try_count++; |
1285 | 1285 | if (connection_aborted()) { |
@@ -1304,13 +1304,13 @@ discard block |
||
1304 | 1304 | |
1305 | 1305 | $_response = ''; |
1306 | 1306 | $header = ''; |
1307 | - while($_response !== "\r\n"){ |
|
1307 | + while ($_response !== "\r\n") { |
|
1308 | 1308 | $_response = fgets($fp, $readsize); |
1309 | 1309 | $header .= $_response; |
1310 | 1310 | }; |
1311 | 1311 | |
1312 | - $rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
1313 | - $rc = (int)$rccd[1]; |
|
1312 | + $rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
1313 | + $rc = (int) $rccd[1]; |
|
1314 | 1314 | |
1315 | 1315 | // Redirect |
1316 | 1316 | switch ($rc) { |
@@ -1319,19 +1319,19 @@ discard block |
||
1319 | 1319 | case 302: // Moved Temporarily |
1320 | 1320 | case 301: // Moved Permanently |
1321 | 1321 | $matches = array(); |
1322 | - if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) { |
|
1322 | + if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) { |
|
1323 | 1323 | $url = trim($matches[1]); |
1324 | - $hash = isset($matches[2])? trim($matches[2]) : ''; |
|
1325 | - if (!preg_match('/^https?:\//',$url)) { // no scheme |
|
1324 | + $hash = isset($matches[2]) ? trim($matches[2]) : ''; |
|
1325 | + if (!preg_match('/^https?:\//', $url)) { // no scheme |
|
1326 | 1326 | if ($url{0} != '/') { // Relative path |
1327 | 1327 | // to Absolute path |
1328 | - $url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url; |
|
1328 | + $url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url; |
|
1329 | 1329 | } |
1330 | 1330 | // add sheme,host |
1331 | 1331 | $url = $url_base.$url; |
1332 | 1332 | } |
1333 | 1333 | fclose($fp); |
1334 | - return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp ); |
|
1334 | + return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp); |
|
1335 | 1335 | } |
1336 | 1336 | } |
1337 | 1337 | |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | $outfp = fopen('php://temp', 'rwb'); |
1341 | 1341 | $body = true; |
1342 | 1342 | } |
1343 | - while(fwrite($outfp, fread($fp, $readsize))) { |
|
1343 | + while (fwrite($outfp, fread($fp, $readsize))) { |
|
1344 | 1344 | if ($timeout) { |
1345 | 1345 | $_status = socket_get_status($fp); |
1346 | 1346 | if ($_status['timed_out']) { |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | |
1360 | 1360 | fclose($fp); |
1361 | 1361 | |
1362 | - return $outfp? $outfp : $body; // Data |
|
1362 | + return $outfp ? $outfp : $body; // Data |
|
1363 | 1363 | } |
1364 | 1364 | |
1365 | 1365 | /** |
@@ -1370,13 +1370,13 @@ discard block |
||
1370 | 1370 | * @return array |
1371 | 1371 | * @author Naoki Sawada |
1372 | 1372 | */ |
1373 | - protected function parse_data_scheme( $str, $extTable ) { |
|
1373 | + protected function parse_data_scheme($str, $extTable) { |
|
1374 | 1374 | $data = $name = ''; |
1375 | 1375 | if ($fp = fopen('data://'.substr($str, 5), 'rb')) { |
1376 | 1376 | if ($data = stream_get_contents($fp)) { |
1377 | 1377 | $meta = stream_get_meta_data($fp); |
1378 | - $ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : ''; |
|
1379 | - $name = substr(md5($data), 0, 8) . $ext; |
|
1378 | + $ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : ''; |
|
1379 | + $name = substr(md5($data), 0, 8).$ext; |
|
1380 | 1380 | } |
1381 | 1381 | fclose($fp); |
1382 | 1382 | } |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | } |
1441 | 1441 | } |
1442 | 1442 | |
1443 | - return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : ''; |
|
1443 | + return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : ''; |
|
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | /** |
@@ -1462,12 +1462,12 @@ discard block |
||
1462 | 1462 | $testDirs[] = sys_get_temp_dir(); |
1463 | 1463 | } |
1464 | 1464 | $tempDir = ''; |
1465 | - foreach($testDirs as $testDir) { |
|
1465 | + foreach ($testDirs as $testDir) { |
|
1466 | 1466 | if (!$testDir || !is_dir($testDir)) continue; |
1467 | 1467 | if (is_writable($testDir)) { |
1468 | 1468 | $tempDir = $testDir; |
1469 | 1469 | $gc = time() - 3600; |
1470 | - foreach(glob($tempDir . DIRECTORY_SEPARATOR .'ELF*') as $cf) { |
|
1470 | + foreach (glob($tempDir.DIRECTORY_SEPARATOR.'ELF*') as $cf) { |
|
1471 | 1471 | if (filemtime($cf) < $gc) { |
1472 | 1472 | @unlink($cf); |
1473 | 1473 | } |
@@ -1487,7 +1487,7 @@ discard block |
||
1487 | 1487 | **/ |
1488 | 1488 | protected function chmod($args) { |
1489 | 1489 | $targets = $args['targets']; |
1490 | - $mode = intval((string)$args['mode'], 8); |
|
1490 | + $mode = intval((string) $args['mode'], 8); |
|
1491 | 1491 | |
1492 | 1492 | if (!is_array($targets)) { |
1493 | 1493 | $targets = array($targets); |
@@ -1502,10 +1502,10 @@ discard block |
||
1502 | 1502 | |
1503 | 1503 | $files = array(); |
1504 | 1504 | $errors = array(); |
1505 | - foreach($targets as $target) { |
|
1505 | + foreach ($targets as $target) { |
|
1506 | 1506 | $file = $volume->chmod($target, $mode); |
1507 | 1507 | if ($file) { |
1508 | - $files = array_merge($files, is_array($file)? $file : array($file)); |
|
1508 | + $files = array_merge($files, is_array($file) ? $file : array($file)); |
|
1509 | 1509 | } else { |
1510 | 1510 | $errors = array_merge($errors, $volume->error()); |
1511 | 1511 | } |
@@ -1536,26 +1536,26 @@ discard block |
||
1536 | 1536 | private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) { |
1537 | 1537 | if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) { |
1538 | 1538 | $fname = $m[1]; |
1539 | - $encname = md5($cid . '_' . $fname); |
|
1540 | - $base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname; |
|
1539 | + $encname = md5($cid.'_'.$fname); |
|
1540 | + $base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname; |
|
1541 | 1541 | $clast = intval($m[3]); |
1542 | 1542 | if (is_null($tmpname)) { |
1543 | 1543 | ignore_user_abort(true); |
1544 | 1544 | sleep(10); // wait 10 sec |
1545 | 1545 | // chunked file upload fail |
1546 | - foreach(glob($base . '*') as $cf) { |
|
1546 | + foreach (glob($base.'*') as $cf) { |
|
1547 | 1547 | @unlink($cf); |
1548 | 1548 | } |
1549 | 1549 | ignore_user_abort(false); |
1550 | 1550 | return; |
1551 | 1551 | } |
1552 | 1552 | |
1553 | - $range = isset($_POST['range'])? trim($_POST['range']) : ''; |
|
1553 | + $range = isset($_POST['range']) ? trim($_POST['range']) : ''; |
|
1554 | 1554 | if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) { |
1555 | 1555 | $start = $ranges[1]; |
1556 | 1556 | $len = $ranges[2]; |
1557 | 1557 | $size = $ranges[3]; |
1558 | - $tmp = $base . '.part'; |
|
1558 | + $tmp = $base.'.part'; |
|
1559 | 1559 | $csize = filesize($tmpname); |
1560 | 1560 | |
1561 | 1561 | $tmpExists = is_file($tmp); |
@@ -1581,7 +1581,7 @@ discard block |
||
1581 | 1581 | } else { |
1582 | 1582 | // wait until makeing temp file (for anothor session) |
1583 | 1583 | $cnt = 1200; // Time limit 120 sec |
1584 | - while(!is_file($base) && --$cnt) { |
|
1584 | + while (!is_file($base) && --$cnt) { |
|
1585 | 1585 | usleep(100000); // wait 100ms |
1586 | 1586 | } |
1587 | 1587 | if (!$cnt) { |
@@ -1616,13 +1616,13 @@ discard block |
||
1616 | 1616 | } |
1617 | 1617 | } else { |
1618 | 1618 | // old way |
1619 | - $part = $base . $m[2]; |
|
1619 | + $part = $base.$m[2]; |
|
1620 | 1620 | if (move_uploaded_file($tmpname, $part)) { |
1621 | 1621 | @chmod($part, 0600); |
1622 | - if ($clast < count(glob($base . '*'))) { |
|
1622 | + if ($clast < count(glob($base.'*'))) { |
|
1623 | 1623 | $parts = array(); |
1624 | 1624 | for ($i = 0; $i <= $clast; $i++) { |
1625 | - $name = $base . '.' . $i . '_' . $clast; |
|
1625 | + $name = $base.'.'.$i.'_'.$clast; |
|
1626 | 1626 | if (is_readable($name)) { |
1627 | 1627 | $parts[] = $name; |
1628 | 1628 | } else { |
@@ -1635,7 +1635,7 @@ discard block |
||
1635 | 1635 | touch($base); |
1636 | 1636 | if ($resfile = tempnam($tempDir, 'ELF')) { |
1637 | 1637 | $target = fopen($resfile, 'wb'); |
1638 | - foreach($parts as $f) { |
|
1638 | + foreach ($parts as $f) { |
|
1639 | 1639 | $fp = fopen($f, 'rb'); |
1640 | 1640 | while (!feof($fp)) { |
1641 | 1641 | fwrite($target, fread($fp, 8192)); |
@@ -1671,15 +1671,15 @@ discard block |
||
1671 | 1671 | $files = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array(); |
1672 | 1672 | $header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8'); |
1673 | 1673 | $result = array_merge(array('added' => array()), $header); |
1674 | - $paths = $args['upload_path']? $args['upload_path'] : array(); |
|
1675 | - $chunk = $args['chunk']? $args['chunk'] : ''; |
|
1676 | - $cid = $args['cid']? (int)$args['cid'] : ''; |
|
1674 | + $paths = $args['upload_path'] ? $args['upload_path'] : array(); |
|
1675 | + $chunk = $args['chunk'] ? $args['chunk'] : ''; |
|
1676 | + $cid = $args['cid'] ? (int) $args['cid'] : ''; |
|
1677 | 1677 | |
1678 | - $renames= array(); |
|
1678 | + $renames = array(); |
|
1679 | 1679 | $suffix = '~'; |
1680 | 1680 | if ($args['renames'] && is_array($args['renames'])) { |
1681 | 1681 | $renames = array_flip($args['renames']); |
1682 | - if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) { |
|
1682 | + if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) { |
|
1683 | 1683 | $suffix = $args['suffix']; |
1684 | 1684 | } |
1685 | 1685 | } |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | if (!$args['upload'] && $args['name'] && is_array($args['name'])) { |
1713 | 1713 | $error = ''; |
1714 | 1714 | $result['name'] = array(); |
1715 | - foreach($args['name'] as $_i => $_name) { |
|
1715 | + foreach ($args['name'] as $_i => $_name) { |
|
1716 | 1716 | if (!$volume->isUploadableByName($_name)) { |
1717 | 1717 | $error = $this->error(self::ERROR_UPLOAD_FILE, $_name, self::ERROR_UPLOAD_FILE_MIME); |
1718 | 1718 | break; |
@@ -1733,7 +1733,7 @@ discard block |
||
1733 | 1733 | } |
1734 | 1734 | if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) { |
1735 | 1735 | $names = array(); |
1736 | - foreach($args['upload'] as $i => $url) { |
|
1736 | + foreach ($args['upload'] as $i => $url) { |
|
1737 | 1737 | // check chunked file upload commit |
1738 | 1738 | if ($args['chunk']) { |
1739 | 1739 | if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') { |
@@ -1743,7 +1743,7 @@ discard block |
||
1743 | 1743 | } |
1744 | 1744 | return $result; |
1745 | 1745 | } else { |
1746 | - $tmpfname = $tempDir . '/' . $args['chunk']; |
|
1746 | + $tmpfname = $tempDir.'/'.$args['chunk']; |
|
1747 | 1747 | $files['tmp_name'][$i] = $tmpfname; |
1748 | 1748 | $files['name'][$i] = $url; |
1749 | 1749 | $files['error'][$i] = 0; |
@@ -1752,7 +1752,7 @@ discard block |
||
1752 | 1752 | } |
1753 | 1753 | } |
1754 | 1754 | |
1755 | - $tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true)); |
|
1755 | + $tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true)); |
|
1756 | 1756 | |
1757 | 1757 | $_name = ''; |
1758 | 1758 | // check is data: |
@@ -1788,8 +1788,8 @@ discard block |
||
1788 | 1788 | list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, ''); |
1789 | 1789 | if ($_b === '') { |
1790 | 1790 | if ($_ext) { |
1791 | - rename($tmpfname, $tmpfname . $_ext); |
|
1792 | - $tmpfname = $tmpfname . $_ext; |
|
1791 | + rename($tmpfname, $tmpfname.$_ext); |
|
1792 | + $tmpfname = $tmpfname.$_ext; |
|
1793 | 1793 | } |
1794 | 1794 | $_b = $this->detectFileExtension($tmpfname); |
1795 | 1795 | $_name = $_a.$_b; |
@@ -1824,7 +1824,7 @@ discard block |
||
1824 | 1824 | } |
1825 | 1825 | |
1826 | 1826 | $tmpname = $files['tmp_name'][$i]; |
1827 | - $path = ($paths && !empty($paths[$i]))? $paths[$i] : ''; |
|
1827 | + $path = ($paths && !empty($paths[$i])) ? $paths[$i] : ''; |
|
1828 | 1828 | if ($name === 'blob') { |
1829 | 1829 | if ($chunk) { |
1830 | 1830 | if ($tempDir = $this->getTempDir($volume->getTempPath())) { |
@@ -1834,7 +1834,7 @@ discard block |
||
1834 | 1834 | preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m); |
1835 | 1835 | $result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname); |
1836 | 1836 | $result['_chunkfailure'] = true; |
1837 | - $this->uploadDebug = 'Upload error: ' . $tmpname; |
|
1837 | + $this->uploadDebug = 'Upload error: '.$tmpname; |
|
1838 | 1838 | } else if ($name) { |
1839 | 1839 | $result['_chunkmerged'] = basename($tmpname); |
1840 | 1840 | $result['_name'] = $name; |
@@ -1848,14 +1848,14 @@ discard block |
||
1848 | 1848 | } else { |
1849 | 1849 | // for form clipboard with Google Chrome |
1850 | 1850 | $type = $files['type'][$i]; |
1851 | - $ext = isset($extTable[$type])? '.' . $extTable[$type] : ''; |
|
1852 | - $name = substr(md5(basename($tmpname)), 0, 8) . $ext; |
|
1851 | + $ext = isset($extTable[$type]) ? '.'.$extTable[$type] : ''; |
|
1852 | + $name = substr(md5(basename($tmpname)), 0, 8).$ext; |
|
1853 | 1853 | } |
1854 | 1854 | } |
1855 | 1855 | |
1856 | 1856 | // do hook function 'upload.presave' |
1857 | - if (! empty($this->listeners['upload.presave'])) { |
|
1858 | - foreach($this->listeners['upload.presave'] as $handler) { |
|
1857 | + if (!empty($this->listeners['upload.presave'])) { |
|
1858 | + foreach ($this->listeners['upload.presave'] as $handler) { |
|
1859 | 1859 | call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume)); |
1860 | 1860 | } |
1861 | 1861 | } |
@@ -1863,7 +1863,7 @@ discard block |
||
1863 | 1863 | if (($fp = fopen($tmpname, 'rb')) == false) { |
1864 | 1864 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER); |
1865 | 1865 | $this->uploadDebug = 'Upload error: unable open tmp file'; |
1866 | - if (! is_uploaded_file($tmpname)) { |
|
1866 | + if (!is_uploaded_file($tmpname)) { |
|
1867 | 1867 | if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
1868 | 1868 | continue; |
1869 | 1869 | } |
@@ -1885,18 +1885,18 @@ discard block |
||
1885 | 1885 | } |
1886 | 1886 | } |
1887 | 1887 | } |
1888 | - if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
1888 | + if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
1889 | 1889 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error()); |
1890 | 1890 | fclose($fp); |
1891 | - if (! is_uploaded_file($tmpname)) { |
|
1892 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);; |
|
1891 | + if (!is_uploaded_file($tmpname)) { |
|
1892 | + if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ; |
|
1893 | 1893 | continue; |
1894 | 1894 | } |
1895 | 1895 | break; |
1896 | 1896 | } |
1897 | 1897 | |
1898 | 1898 | is_resource($fp) && fclose($fp); |
1899 | - if (! is_uploaded_file($tmpname)){ |
|
1899 | + if (!is_uploaded_file($tmpname)) { |
|
1900 | 1900 | clearstatcache(); |
1901 | 1901 | if (!is_file($tmpname) || @ unlink($tmpname)) { |
1902 | 1902 | unset($GLOBALS['elFinderTempFiles'][$tmpname]); |
@@ -1908,7 +1908,7 @@ discard block |
||
1908 | 1908 | } |
1909 | 1909 | } |
1910 | 1910 | if ($GLOBALS['elFinderTempFiles']) { |
1911 | - foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
1911 | + foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
1912 | 1912 | @ unlink($_temp); |
1913 | 1913 | } |
1914 | 1914 | } |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | $suffix = '~'; |
1946 | 1946 | if (!empty($args['renames'])) { |
1947 | 1947 | $renames = array_flip($args['renames']); |
1948 | - if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
1948 | + if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
1949 | 1949 | $suffix = $args['suffix']; |
1950 | 1950 | } |
1951 | 1951 | } |
@@ -2003,9 +2003,9 @@ discard block |
||
2003 | 2003 | } |
2004 | 2004 | |
2005 | 2005 | if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) { |
2006 | - $mime = isset($file['mime'])? $file['mime'] : ''; |
|
2006 | + $mime = isset($file['mime']) ? $file['mime'] : ''; |
|
2007 | 2007 | if ($mime && strtolower(substr($mime, 0, 4)) === 'text') { |
2008 | - if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) { |
|
2008 | + if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) { |
|
2009 | 2009 | if (strtolower($enc) !== 'utf-8') { |
2010 | 2010 | $content = mb_convert_encoding($content, 'UTF-8', $enc); |
2011 | 2011 | } |
@@ -2017,7 +2017,7 @@ discard block |
||
2017 | 2017 | |
2018 | 2018 | if ($json === false || strlen($json) < strlen($content)) { |
2019 | 2019 | if ($args['conv']) { |
2020 | - return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
2020 | + return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
2021 | 2021 | } else { |
2022 | 2022 | return array('doconv' => true); |
2023 | 2023 | } |
@@ -2059,7 +2059,7 @@ discard block |
||
2059 | 2059 | $target = $args['target']; |
2060 | 2060 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
2061 | 2061 | $error = array(self::ERROR_EXTRACT, '#'.$target); |
2062 | - $makedir = isset($args['makedir'])? (bool)$args['makedir'] : null; |
|
2062 | + $makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null; |
|
2063 | 2063 | |
2064 | 2064 | if (($volume = $this->volume($target)) == false |
2065 | 2065 | || ($file = $volume->file($target)) == false) { |
@@ -2067,7 +2067,7 @@ discard block |
||
2067 | 2067 | } |
2068 | 2068 | |
2069 | 2069 | return ($file = $volume->extract($target, $makedir)) |
2070 | - ? array('added' => isset($file['read'])? array($file) : $file) |
|
2070 | + ? array('added' => isset($file['read']) ? array($file) : $file) |
|
2071 | 2071 | : array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error())); |
2072 | 2072 | } |
2073 | 2073 | |
@@ -2082,7 +2082,7 @@ discard block |
||
2082 | 2082 | protected function archive($args) { |
2083 | 2083 | $type = $args['type']; |
2084 | 2084 | $targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array(); |
2085 | - $name = isset($args['name'])? $args['name'] : ''; |
|
2085 | + $name = isset($args['name']) ? $args['name'] : ''; |
|
2086 | 2086 | |
2087 | 2087 | if (($volume = $this->volume($targets[0])) == false) { |
2088 | 2088 | return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND); |
@@ -2103,7 +2103,7 @@ discard block |
||
2103 | 2103 | protected function search($args) { |
2104 | 2104 | $q = trim($args['q']); |
2105 | 2105 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
2106 | - $target = !empty($args['target'])? $args['target'] : null; |
|
2106 | + $target = !empty($args['target']) ? $args['target'] : null; |
|
2107 | 2107 | $result = array(); |
2108 | 2108 | |
2109 | 2109 | if (!is_null($target)) { |
@@ -2167,12 +2167,12 @@ discard block |
||
2167 | 2167 | $target = $args['target']; |
2168 | 2168 | $width = $args['width']; |
2169 | 2169 | $height = $args['height']; |
2170 | - $x = (int)$args['x']; |
|
2171 | - $y = (int)$args['y']; |
|
2170 | + $x = (int) $args['x']; |
|
2171 | + $y = (int) $args['y']; |
|
2172 | 2172 | $mode = $args['mode']; |
2173 | 2173 | $bg = null; |
2174 | - $degree = (int)$args['degree']; |
|
2175 | - $quality= (int)$args['quality']; |
|
2174 | + $degree = (int) $args['degree']; |
|
2175 | + $quality = (int) $args['quality']; |
|
2176 | 2176 | |
2177 | 2177 | if (($volume = $this->volume($target)) == false |
2178 | 2178 | || ($file = $volume->file($target)) == false) { |
@@ -2193,7 +2193,7 @@ discard block |
||
2193 | 2193 | **/ |
2194 | 2194 | protected function url($args) { |
2195 | 2195 | $target = $args['target']; |
2196 | - $options = isset($args['options'])? $args['options'] : array(); |
|
2196 | + $options = isset($args['options']) ? $args['options'] : array(); |
|
2197 | 2197 | if (($volume = $this->volume($target)) != false) { |
2198 | 2198 | $url = $volume->getContentUrl($target, $options); |
2199 | 2199 | return $url ? array('url' => $url) : array(); |
@@ -2210,18 +2210,18 @@ discard block |
||
2210 | 2210 | */ |
2211 | 2211 | protected function callback($args) { |
2212 | 2212 | $checkReg = '/[^a-zA-Z0-9;._-]/'; |
2213 | - $node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : ''; |
|
2214 | - $json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}'; |
|
2215 | - $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : ''; |
|
2213 | + $node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : ''; |
|
2214 | + $json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}'; |
|
2215 | + $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : ''; |
|
2216 | 2216 | $done = (!empty($args['done'])); |
2217 | 2217 | |
2218 | - while( ob_get_level() ) { |
|
2219 | - if (! ob_end_clean()) { |
|
2218 | + while (ob_get_level()) { |
|
2219 | + if (!ob_end_clean()) { |
|
2220 | 2220 | break; |
2221 | 2221 | } |
2222 | 2222 | } |
2223 | 2223 | |
2224 | - if ($done || ! $this->callbackWindowURL) { |
|
2224 | + if ($done || !$this->callbackWindowURL) { |
|
2225 | 2225 | $script = ''; |
2226 | 2226 | if ($node) { |
2227 | 2227 | $script .= ' |
@@ -2263,13 +2263,13 @@ discard block |
||
2263 | 2263 | |
2264 | 2264 | } else { |
2265 | 2265 | $url = $this->callbackWindowURL; |
2266 | - $url .= ((strpos($url, '?') === false)? '?' : '&') |
|
2267 | - . '&node=' . rawurlencode($node) |
|
2268 | - . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '') |
|
2269 | - . ($bind? ('&bind=' . rawurlencode($bind)) : '') |
|
2266 | + $url .= ((strpos($url, '?') === false) ? '?' : '&') |
|
2267 | + . '&node='.rawurlencode($node) |
|
2268 | + . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '') |
|
2269 | + . ($bind ? ('&bind='.rawurlencode($bind)) : '') |
|
2270 | 2270 | . '&done=1'; |
2271 | 2271 | |
2272 | - header('Location: ' . $url); |
|
2272 | + header('Location: '.$url); |
|
2273 | 2273 | |
2274 | 2274 | } |
2275 | 2275 | exit(); |
@@ -2339,7 +2339,7 @@ discard block |
||
2339 | 2339 | |
2340 | 2340 | protected function utime() { |
2341 | 2341 | $time = explode(" ", microtime()); |
2342 | - return (double)$time[1] + (double)$time[0]; |
|
2342 | + return (double) $time[1] + (double) $time[0]; |
|
2343 | 2343 | } |
2344 | 2344 | |
2345 | 2345 | |
@@ -2365,7 +2365,7 @@ discard block |
||
2365 | 2365 | $imgcnt = 0; |
2366 | 2366 | $fp = fopen($path, 'rb'); |
2367 | 2367 | @fread($fp, 4); |
2368 | - $c = @fread($fp,1); |
|
2368 | + $c = @fread($fp, 1); |
|
2369 | 2369 | if (ord($c) != 0x39) { // GIF89a |
2370 | 2370 | return false; |
2371 | 2371 | } |
@@ -2373,13 +2373,13 @@ discard block |
||
2373 | 2373 | while (!feof($fp)) { |
2374 | 2374 | do { |
2375 | 2375 | $c = fread($fp, 1); |
2376 | - } while(ord($c) != 0x21 && !feof($fp)); |
|
2376 | + } while (ord($c) != 0x21 && !feof($fp)); |
|
2377 | 2377 | |
2378 | 2378 | if (feof($fp)) { |
2379 | 2379 | break; |
2380 | 2380 | } |
2381 | 2381 | |
2382 | - $c2 = fread($fp,2); |
|
2382 | + $c2 = fread($fp, 2); |
|
2383 | 2383 | if (bin2hex($c2) == "f904") { |
2384 | 2384 | $imgcnt++; |
2385 | 2385 | } |
@@ -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', false)) { |
|
140 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO', false)) { |
|
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', false)) { |
148 | 148 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
149 | 149 | } else { |
150 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
150 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
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', false)) { |
311 | 311 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
312 | 312 | } else { |
313 | - if (! class_exists('HTTP_OAuth_Consumer', false)) { |
|
313 | + if (!class_exists('HTTP_OAuth_Consumer', false)) { |
|
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', 'tmbPath', 'tmpPath', 'quarantine') as $key) { |
|
56 | + foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) { |
|
57 | 57 | if (!empty($this->options[$key])) { |
58 | 58 | $this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]); |
59 | 59 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | // if no thumbnails url - try detect it |
103 | 103 | if ($root['read'] && !$this->tmbURL && $this->URL) { |
104 | 104 | if (strpos($this->tmbPath, $this->root) === 0) { |
105 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); |
|
105 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); |
|
106 | 106 | if (preg_match("|[^/?&=]$|", $this->tmbURL)) { |
107 | 107 | $this->tmbURL .= '/'; |
108 | 108 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @author Dmitry (dio) Levashov |
179 | 179 | **/ |
180 | 180 | protected function _joinPath($dir, $name) { |
181 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
181 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $comps = $new_comps; |
231 | 231 | $path = implode('/', $comps); |
232 | 232 | if ($initial_slashes) { |
233 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
233 | + $path = str_repeat('/', $initial_slashes).$path; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | if ($changeSep) { |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | **/ |
302 | 302 | protected function _inpath($path, $parent) { |
303 | 303 | $cwd = getcwd(); |
304 | - $real_path = $this->getFullPath($path, $cwd); |
|
304 | + $real_path = $this->getFullPath($path, $cwd); |
|
305 | 305 | $real_parent = $this->getFullPath($parent, $cwd); |
306 | 306 | if ($real_path && $real_parent) { |
307 | 307 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $stat = array(); |
361 | 361 | return $stat; |
362 | 362 | } else { |
363 | - $stat['mime'] = 'symlink-broken'; |
|
363 | + $stat['mime'] = 'symlink-broken'; |
|
364 | 364 | $target = readlink($path); |
365 | 365 | $lstat = lstat($path); |
366 | 366 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $fstat = stat($path); |
377 | 377 | $uid = $fstat['uid']; |
378 | 378 | $gid = $fstat['gid']; |
379 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
379 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
380 | 380 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
381 | 381 | } |
382 | 382 | |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
387 | 387 | } |
388 | 388 | //logical rights first |
389 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
390 | - $stat['write'] = is_writable($path)? null : false; |
|
389 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
390 | + $stat['write'] = is_writable($path) ? null : false; |
|
391 | 391 | |
392 | 392 | if (is_null($stat['read'])) { |
393 | 393 | $stat['size'] = $dir ? 0 : $size; |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | |
458 | 458 | if (is_dir($path)) { |
459 | 459 | $path = strtr($path, array('[' => '\\[', ']' => '\\]', '*' => '\\*', '?' => '\\?')); |
460 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
460 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
461 | 461 | } |
462 | 462 | return false; |
463 | 463 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $br = true; |
539 | 539 | } else { |
540 | 540 | $_path = $fpath; |
541 | - $stat['mime'] = 'symlink-broken'; |
|
541 | + $stat['mime'] = 'symlink-broken'; |
|
542 | 542 | $target = readlink($_path); |
543 | 543 | $lstat = lstat($_path); |
544 | 544 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -563,13 +563,13 @@ discard block |
||
563 | 563 | if ($statOwner && !$linkreadable) { |
564 | 564 | $uid = $file->getOwner(); |
565 | 565 | $gid = $file->getGroup(); |
566 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
566 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
567 | 567 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
568 | 568 | } |
569 | 569 | |
570 | 570 | //logical rights first |
571 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
572 | - $stat['write'] = $file->isWritable()? null : false; |
|
571 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
572 | + $stat['write'] = $file->isWritable() ? null : false; |
|
573 | 573 | |
574 | 574 | if (is_null($stat['read'])) { |
575 | 575 | $stat['size'] = $dir ? 0 : $size; |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | |
586 | 586 | if ($cache) { |
587 | 587 | $cache = $this->convEncOut($cache, false); |
588 | - foreach($cache as $d) { |
|
588 | + foreach ($cache as $d) { |
|
589 | 589 | $this->updateCache($d[0], $d[1]); |
590 | 590 | } |
591 | 591 | } |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | * @return resource|false |
602 | 602 | * @author Dmitry (dio) Levashov |
603 | 603 | **/ |
604 | - protected function _fopen($path, $mode='rb') { |
|
604 | + protected function _fopen($path, $mode = 'rb') { |
|
605 | 605 | return @fopen($path, $mode); |
606 | 606 | } |
607 | 607 | |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | * @return bool |
613 | 613 | * @author Dmitry (dio) Levashov |
614 | 614 | **/ |
615 | - protected function _fclose($fp, $path='') { |
|
615 | + protected function _fclose($fp, $path = '') { |
|
616 | 616 | return @fclose($fp); |
617 | 617 | } |
618 | 618 | |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | $path = $this->_joinPath($dir, $name); |
745 | 745 | |
746 | 746 | $meta = stream_get_meta_data($fp); |
747 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
747 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
748 | 748 | if ($uri && @is_file($uri)) { |
749 | 749 | fclose($fp); |
750 | 750 | $isCmdPaste = ($this->ARGS['cmd'] === 'paste'); |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | * @return bool |
809 | 809 | **/ |
810 | 810 | protected function _chmod($path, $mode) { |
811 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
811 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
812 | 812 | $ret = @chmod($path, $modeOct); |
813 | 813 | $ret && clearstatcache(); |
814 | 814 | return $ret; |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | $src = $dir; |
927 | 927 | $name = basename($path); |
928 | 928 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
929 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
929 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
930 | 930 | } |
931 | 931 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
932 | 932 | if (file_exists($test) || is_link($test)) { |
@@ -935,9 +935,9 @@ discard block |
||
935 | 935 | } |
936 | 936 | |
937 | 937 | if ($name !== '') { |
938 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
938 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
939 | 939 | |
940 | - if (! @rename($src, $result)) { |
|
940 | + if (!@rename($src, $result)) { |
|
941 | 941 | $this->delTree($dir); |
942 | 942 | return false; |
943 | 943 | } |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | $dstDir = dirname($path); |
946 | 946 | $res = false; |
947 | 947 | $result = array(); |
948 | - foreach($ls as $name) { |
|
948 | + foreach ($ls as $name) { |
|
949 | 949 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
950 | 950 | if (is_dir($target)) { |
951 | 951 | $this->delTree($target); |
@@ -1037,10 +1037,10 @@ discard block |
||
1037 | 1037 | |
1038 | 1038 | $path = strtr($path, $escaper); |
1039 | 1039 | $_q = strtr($q, $escaper); |
1040 | - $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
1041 | - $match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$_q.'*', GLOB_NOSORT); |
|
1040 | + $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
1041 | + $match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$_q.'*', GLOB_NOSORT); |
|
1042 | 1042 | if ($match) { |
1043 | - foreach($match as $p) { |
|
1043 | + foreach ($match as $p) { |
|
1044 | 1044 | $stat = $this->stat($p); |
1045 | 1045 | |
1046 | 1046 | if (!$stat) { // invalid links |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | $stat['path'] = $this->path($stat['hash']); |
1058 | 1058 | if ($this->URL && !isset($stat['url'])) { |
1059 | 1059 | $path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1)); |
1060 | - $stat['url'] = $this->URL . $path; |
|
1060 | + $stat['url'] = $this->URL.$path; |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | $result[] = $stat; |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | if ($dirs) { |
1068 | - foreach($dirs as $dir) { |
|
1068 | + foreach ($dirs as $dir) { |
|
1069 | 1069 | $stat = $this->stat($dir); |
1070 | 1070 | if ($stat['read'] && !isset($stat['alias'])) { |
1071 | 1071 | @set_time_limit(30); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * Close opened file |
612 | 612 | * |
613 | 613 | * @param resource $fp file pointer |
614 | - * @return bool |
|
614 | + * @return boolean|null |
|
615 | 615 | * @author Dmitry (dio) Levashov |
616 | 616 | **/ |
617 | 617 | protected function _fclose($fp, $path='') { |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @param string $path parent dir path |
630 | 630 | * @param string $name new directory name |
631 | - * @return string|bool |
|
631 | + * @return string|false |
|
632 | 632 | * @author Dmitry (dio) Levashov |
633 | 633 | **/ |
634 | 634 | protected function _mkdir($path, $name) { |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @param string $path parent dir path |
642 | 642 | * @param string $name new file name |
643 | - * @return string|bool |
|
643 | + * @return string|false |
|
644 | 644 | * @author Dmitry (dio) Levashov |
645 | 645 | **/ |
646 | 646 | protected function _mkfile($path, $name) { |
@@ -684,9 +684,9 @@ discard block |
||
684 | 684 | * Return new file path or false. |
685 | 685 | * |
686 | 686 | * @param string $source source file path |
687 | - * @param string $target target dir path |
|
687 | + * @param string $targetDir target dir path |
|
688 | 688 | * @param string $name file name |
689 | - * @return string|bool |
|
689 | + * @return string|false |
|
690 | 690 | * @author Dmitry (dio) Levashov |
691 | 691 | **/ |
692 | 692 | protected function _move($source, $targetDir, $name) { |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * |
870 | 870 | * @param string $path archive path |
871 | 871 | * @param array $arc archiver command and arguments (same as in $this->archivers) |
872 | - * @return true |
|
872 | + * @return boolean |
|
873 | 873 | * @author Dmitry (dio) Levashov, |
874 | 874 | * @author Alexey Sukhotin |
875 | 875 | **/ |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * @param array $files files names list |
885 | 885 | * @param string $name archive name |
886 | 886 | * @param array $arc archiver options |
887 | - * @return string|bool |
|
887 | + * @return boolean |
|
888 | 888 | * @author Dmitry (dio) Levashov, |
889 | 889 | * @author Alexey Sukhotin |
890 | 890 | **/ |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $dirs = array(); |
312 | 312 | if ($path != $this->root) { |
313 | 313 | $inpath = array(intval($path)); |
314 | - while($inpath) { |
|
314 | + while ($inpath) { |
|
315 | 315 | $in = '('.join(',', $inpath).')'; |
316 | 316 | $inpath = array(); |
317 | 317 | $sql = 'SELECT f.id FROM %s AS f WHERE f.parent_id IN '.$in.' AND `mime` = \'directory\''; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | if ($mimes) { |
332 | 332 | $whrs = array(); |
333 | - foreach($mimes as $mime) { |
|
333 | + foreach ($mimes as $mime) { |
|
334 | 334 | if (strpos($mime, '/') === false) { |
335 | 335 | $whrs[] = sprintf('f.mime LIKE "%s/%%"', $this->db->real_escape_string($mime)); |
336 | 336 | } else { |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $whr = sprintf('f.name RLIKE "%s"', $this->db->real_escape_string($q)); |
343 | 343 | } |
344 | 344 | if ($dirs) { |
345 | - $whr = '(' . $whr . ') AND (`parent_id` IN (' . join(',', $dirs) . '))'; |
|
345 | + $whr = '('.$whr.') AND (`parent_id` IN ('.join(',', $dirs).'))'; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | $sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | * @return resource|false |
588 | 588 | * @author Dmitry (dio) Levashov |
589 | 589 | **/ |
590 | - protected function _fopen($path, $mode='rb') { |
|
590 | + protected function _fopen($path, $mode = 'rb') { |
|
591 | 591 | $fp = $this->tmbPath |
592 | 592 | ? @fopen($this->getTempFile($path), 'w+') |
593 | 593 | : @tmpfile(); |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | * @return bool |
615 | 615 | * @author Dmitry (dio) Levashov |
616 | 616 | **/ |
617 | - protected function _fclose($fp, $path='') { |
|
617 | + protected function _fclose($fp, $path = '') { |
|
618 | 618 | @fclose($fp); |
619 | 619 | if ($path) { |
620 | 620 | @unlink($this->getTempFile($path)); |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | $this->clearcache(); |
747 | 747 | |
748 | 748 | $mime = $stat['mime']; |
749 | - $w = !empty($stat['width']) ? $stat['width'] : 0; |
|
749 | + $w = !empty($stat['width']) ? $stat['width'] : 0; |
|
750 | 750 | $h = !empty($stat['height']) ? $stat['height'] : 0; |
751 | 751 | |
752 | 752 | $id = $this->_joinPath($dir, $name); |
@@ -107,6 +107,10 @@ discard block |
||
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | + /** |
|
111 | + * @param double $width |
|
112 | + * @param double $height |
|
113 | + */ |
|
110 | 114 | private function resize_gd($src, $width, $height, $quality, $srcImgInfo) { |
111 | 115 | switch ($srcImgInfo['mime']) { |
112 | 116 | case 'image/gif': |
@@ -177,6 +181,10 @@ discard block |
||
177 | 181 | return false; |
178 | 182 | } |
179 | 183 | |
184 | + /** |
|
185 | + * @param double $width |
|
186 | + * @param double $height |
|
187 | + */ |
|
180 | 188 | private function resize_imagick($src, $width, $height, $quality) { |
181 | 189 | try { |
182 | 190 | $img = new imagick($src); |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | |
53 | 53 | public function __construct($opts) { |
54 | 54 | $defaults = array( |
55 | - 'enable' => true, // For control by volume driver |
|
56 | - 'maxWidth' => 1024, // Path to Water mark image |
|
57 | - 'maxHeight' => 1024, // Margin right pixel |
|
58 | - 'quality' => 95, // JPEG image save quality |
|
59 | - 'preserveExif' => false, // Preserve EXIF data (Imagick only) |
|
60 | - 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
55 | + 'enable' => true, // For control by volume driver |
|
56 | + 'maxWidth' => 1024, // Path to Water mark image |
|
57 | + 'maxHeight' => 1024, // Margin right pixel |
|
58 | + 'quality' => 95, // JPEG image save quality |
|
59 | + 'preserveExif' => false, // Preserve EXIF data (Imagick only) |
|
60 | + 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field ) |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | $this->opts = array_merge($defaults, $opts); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $opts = array_merge($this->opts, $volOpts); |
72 | 72 | } |
73 | 73 | |
74 | - if (! $opts['enable']) { |
|
74 | + if (!$opts['enable']) { |
|
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | IMAGETYPE_PNG => IMG_PNG, |
88 | 88 | IMAGETYPE_WBMP => IMG_WBMP, |
89 | 89 | ); |
90 | - if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
90 | + if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality, $preserveExif) { |
102 | - $zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1])); |
|
103 | - $width = round($srcImgInfo[0] * $zoom); |
|
104 | - $height = round($srcImgInfo[1] * $zoom); |
|
102 | + $zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1])); |
|
103 | + $width = round($srcImgInfo[0]*$zoom); |
|
104 | + $height = round($srcImgInfo[1]*$zoom); |
|
105 | 105 | |
106 | 106 | if (class_exists('Imagick', false)) { |
107 | 107 | return $this->resize_imagick($src, $width, $height, $quality, $preserveExif); |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | break; |
122 | 122 | case 'image/jpeg': |
123 | 123 | if (@imagetypes() & IMG_JPG) { |
124 | - $oSrcImg = @imagecreatefromjpeg($src) ; |
|
124 | + $oSrcImg = @imagecreatefromjpeg($src); |
|
125 | 125 | } else { |
126 | 126 | $ermsg = 'JPEG images are not supported'; |
127 | 127 | } |
128 | 128 | break; |
129 | 129 | case 'image/png': |
130 | 130 | if (@imagetypes() & IMG_PNG) { |
131 | - $oSrcImg = @imagecreatefrompng($src) ; |
|
131 | + $oSrcImg = @imagecreatefrompng($src); |
|
132 | 132 | } else { |
133 | 133 | $ermsg = 'PNG images are not supported'; |
134 | 134 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | break; |
147 | 147 | } |
148 | 148 | |
149 | - if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
149 | + if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
150 | 150 | |
151 | 151 | if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) { |
152 | 152 | return false; |
@@ -1,51 +1,51 @@ |
||
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 | - * 'AutoResize' => 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 | - * 'preserveExif' => false, // Preserve EXIF data (Imagick only) |
|
22 | - * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
23 | - * ) |
|
24 | - * ), |
|
25 | - * // each volume configure (optional) |
|
26 | - * 'roots' => array( |
|
27 | - * array( |
|
28 | - * 'driver' => 'LocalFileSystem', |
|
29 | - * 'path' => '/path/to/files/', |
|
30 | - * 'URL' => 'http://localhost/to/files/' |
|
31 | - * 'plugin' => array( |
|
32 | - * 'AutoResize' => array( |
|
33 | - * 'enable' => true, // For control by volume driver |
|
34 | - * 'maxWidth' => 1024, // Path to Water mark image |
|
35 | - * 'maxHeight' => 1024, // Margin right pixel |
|
36 | - * 'quality' => 95, // JPEG image save quality |
|
37 | - * 'preserveExif' => false, // Preserve EXIF data (Imagick only) |
|
38 | - * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
39 | - * ) |
|
40 | - * ) |
|
41 | - * ) |
|
42 | - * ) |
|
43 | - * ); |
|
44 | - * |
|
45 | - * @package elfinder |
|
46 | - * @author Naoki Sawada |
|
47 | - * @license New BSD |
|
48 | - */ |
|
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 | + * 'AutoResize' => 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 | + * 'preserveExif' => false, // Preserve EXIF data (Imagick only) |
|
22 | + * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
23 | + * ) |
|
24 | + * ), |
|
25 | + * // each volume configure (optional) |
|
26 | + * 'roots' => array( |
|
27 | + * array( |
|
28 | + * 'driver' => 'LocalFileSystem', |
|
29 | + * 'path' => '/path/to/files/', |
|
30 | + * 'URL' => 'http://localhost/to/files/' |
|
31 | + * 'plugin' => array( |
|
32 | + * 'AutoResize' => array( |
|
33 | + * 'enable' => true, // For control by volume driver |
|
34 | + * 'maxWidth' => 1024, // Path to Water mark image |
|
35 | + * 'maxHeight' => 1024, // Margin right pixel |
|
36 | + * 'quality' => 95, // JPEG image save quality |
|
37 | + * 'preserveExif' => false, // Preserve EXIF data (Imagick only) |
|
38 | + * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
39 | + * ) |
|
40 | + * ) |
|
41 | + * ) |
|
42 | + * ) |
|
43 | + * ); |
|
44 | + * |
|
45 | + * @package elfinder |
|
46 | + * @author Naoki Sawada |
|
47 | + * @license New BSD |
|
48 | + */ |
|
49 | 49 | class elFinderPluginAutoResize { |
50 | 50 | |
51 | 51 | 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); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return void |
35 | 35 | * @author Dmitry (dio) Levashov |
36 | 36 | **/ |
37 | - public function __construct($elFinder, $debug=false) { |
|
37 | + public function __construct($elFinder, $debug = false) { |
|
38 | 38 | |
39 | 39 | $this->elFinder = $elFinder; |
40 | 40 | if ($debug) { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) { |
55 | 55 | // for support IE XDomainRequest() |
56 | 56 | $parts = explode('&', $rawPostData); |
57 | - foreach($parts as $part) { |
|
57 | + foreach ($parts as $part) { |
|
58 | 58 | list($key, $value) = array_pad(explode('=', $part), 2, ''); |
59 | 59 | $key = rawurldecode($key); |
60 | 60 | if (substr($key, -2) === '[]') { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | **/ |
122 | 122 | protected function output(array $data) { |
123 | 123 | // clear output buffer |
124 | - while(@ob_get_level()){ @ob_end_clean(); } |
|
124 | + while (@ob_get_level()) { @ob_end_clean(); } |
|
125 | 125 | |
126 | 126 | $header = isset($data['header']) ? $data['header'] : $this->header; |
127 | 127 | unset($data['header']); |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | $psize = $end - $start + 1; |
163 | 163 | |
164 | 164 | header('HTTP/1.1 206 Partial Content'); |
165 | - header('Content-Length: ' . $psize); |
|
166 | - header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size); |
|
165 | + header('Content-Length: '.$psize); |
|
166 | + header('Content-Range: bytes '.$start.'-'.$end.'/'.$size); |
|
167 | 167 | |
168 | 168 | fseek($fp, $start); |
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
172 | - if (is_null($psize)){ |
|
172 | + if (is_null($psize)) { |
|
173 | 173 | rewind($fp); |
174 | 174 | } |
175 | 175 | } else { |
@@ -212,8 +212,9 @@ |
||
212 | 212 | protected function input_filter($args) { |
213 | 213 | static $magic_quotes_gpc = NULL; |
214 | 214 | |
215 | - if ($magic_quotes_gpc === NULL) |
|
216 | - $magic_quotes_gpc = (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc()); |
|
215 | + if ($magic_quotes_gpc === NULL) { |
|
216 | + $magic_quotes_gpc = (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc()); |
|
217 | + } |
|
217 | 218 | |
218 | 219 | if (is_array($args)) { |
219 | 220 | return array_map(array(& $this, 'input_filter'), $args); |
@@ -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) { |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | 'mimefile' => '', |
201 | 201 | // mime type normalize map : Array '[ext]:[detected mime type]' => '[normalized mime]' |
202 | 202 | 'mimeMap' => array( |
203 | - 'md:application/x-genesis-rom' => 'text/x-markdown', |
|
204 | - 'md:text/plain' => 'text/x-markdown', |
|
205 | - 'markdown:text/plain' => 'text/x-markdown', |
|
206 | - 'css:text/x-asm' => 'text/css' |
|
207 | - ), |
|
203 | + 'md:application/x-genesis-rom' => 'text/x-markdown', |
|
204 | + 'md:text/plain' => 'text/x-markdown', |
|
205 | + 'markdown:text/plain' => 'text/x-markdown', |
|
206 | + 'css:text/x-asm' => 'text/css' |
|
207 | + ), |
|
208 | 208 | // directory for thumbnails |
209 | 209 | 'tmbPath' => '.tmb', |
210 | 210 | // mode to create thumbnails dir |
@@ -4070,14 +4070,14 @@ discard block |
||
4070 | 4070 | // } |
4071 | 4071 | |
4072 | 4072 | /** |
4073 | - * Find position of first occurrence of string in a string with multibyte support |
|
4074 | - * |
|
4075 | - * @param string $haystack The string being checked. |
|
4076 | - * @param string $needle The string to find in haystack. |
|
4077 | - * @param int $offset The search offset. If it is not specified, 0 is used. |
|
4078 | - * @return int|bool |
|
4079 | - * @author Alexey Sukhotin |
|
4080 | - **/ |
|
4073 | + * Find position of first occurrence of string in a string with multibyte support |
|
4074 | + * |
|
4075 | + * @param string $haystack The string being checked. |
|
4076 | + * @param string $needle The string to find in haystack. |
|
4077 | + * @param int $offset The search offset. If it is not specified, 0 is used. |
|
4078 | + * @return int|bool |
|
4079 | + * @author Alexey Sukhotin |
|
4080 | + **/ |
|
4081 | 4081 | protected function stripos($haystack , $needle , $offset = 0) { |
4082 | 4082 | if (function_exists('mb_stripos')) { |
4083 | 4083 | return mb_stripos($haystack , $needle , $offset); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | 'utf8fix' => false, |
281 | 281 | // й ё Й Ё Ø Å |
282 | 282 | 'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"), |
283 | - 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
283 | + 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
284 | 284 | ); |
285 | 285 | |
286 | 286 | /** |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | **/ |
576 | 576 | protected function configure() { |
577 | 577 | // set ARGS |
578 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
578 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
579 | 579 | // set thumbnails path |
580 | 580 | $path = $this->options['tmbPath']; |
581 | 581 | if ($path) { |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | |
607 | 607 | // check 'statOwner' for command `chmod` |
608 | 608 | if (empty($this->options['statOwner'])) { |
609 | - $this->disabled[] ='chmod'; |
|
609 | + $this->disabled[] = 'chmod'; |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | // check 'mimeMap' |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | **/ |
713 | 713 | public function mount(array $opts) { |
714 | 714 | if (!isset($opts['path']) || $opts['path'] === '') { |
715 | - return $this->setError('Path undefined.');; |
|
715 | + return $this->setError('Path undefined.'); ; |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | $this->options = array_merge($this->options, $opts); |
@@ -731,14 +731,14 @@ discard block |
||
731 | 731 | $argInit = !empty($this->ARGS['init']); |
732 | 732 | |
733 | 733 | // session cache |
734 | - if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
734 | + if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
735 | 735 | $_SESSION[elFinder::$sessionCacheKey][$this->id] = array(); |
736 | 736 | } |
737 | 737 | $this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id]; |
738 | 738 | |
739 | 739 | // default file attribute |
740 | 740 | $this->defaults = array( |
741 | - 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
741 | + 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
742 | 742 | 'write' => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true, |
743 | 743 | 'locked' => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false, |
744 | 744 | 'hidden' => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false |
@@ -765,8 +765,8 @@ discard block |
||
765 | 765 | $this->access = $this->options['accessControl']; |
766 | 766 | } |
767 | 767 | |
768 | - $this->today = mktime(0,0,0, date('m'), date('d'), date('Y')); |
|
769 | - $this->yesterday = $this->today-86400; |
|
768 | + $this->today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
769 | + $this->yesterday = $this->today - 86400; |
|
770 | 770 | |
771 | 771 | // debug($this->attributes); |
772 | 772 | if (!$this->init()) { |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | foreach ($mimecf as $line_num => $line) { |
866 | 866 | if (!preg_match('/^\s*#/', $line)) { |
867 | 867 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
868 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
868 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
869 | 869 | if (!isset(self::$mimetypes[$mime[$i]])) { |
870 | 870 | self::$mimetypes[$mime[$i]] = $mime[0]; |
871 | 871 | } |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | |
895 | 895 | if ($root['read']) { |
896 | 896 | // check startPath - path to open by default instead of root |
897 | - $startPath = $this->options['startPath']? $this->normpathCE($this->options['startPath']) : ''; |
|
897 | + $startPath = $this->options['startPath'] ? $this->normpathCE($this->options['startPath']) : ''; |
|
898 | 898 | if ($startPath) { |
899 | 899 | $start = $this->stat($startPath); |
900 | 900 | if (!empty($start) |
@@ -918,8 +918,8 @@ discard block |
||
918 | 918 | 'read' => false |
919 | 919 | )); |
920 | 920 | } |
921 | - $this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1; |
|
922 | - $this->tmbSize = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48; |
|
921 | + $this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1; |
|
922 | + $this->tmbSize = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48; |
|
923 | 923 | $this->URL = $this->options['URL']; |
924 | 924 | if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) { |
925 | 925 | $this->URL .= '/'; |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | public function options($hash) { |
1074 | 1074 | $create = $createext = array(); |
1075 | 1075 | if (isset($this->archivers['create']) && is_array($this->archivers['create'])) { |
1076 | - foreach($this->archivers['create'] as $m => $v) { |
|
1076 | + foreach ($this->archivers['create'] as $m => $v) { |
|
1077 | 1077 | $create[] = $m; |
1078 | 1078 | $createext[$m] = $v['ext']; |
1079 | 1079 | } |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | 'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(), |
1095 | 1095 | 'createext' => $createext |
1096 | 1096 | ), |
1097 | - 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array() |
|
1097 | + 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array() |
|
1098 | 1098 | ); |
1099 | 1099 | } |
1100 | 1100 | |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | * @author Naoki Sawada |
1107 | 1107 | */ |
1108 | 1108 | public function getOption($name) { |
1109 | - return isset($this->options[$name])? $this->options[$name] : null; |
|
1109 | + return isset($this->options[$name]) ? $this->options[$name] : null; |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | /** |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | */ |
1119 | 1119 | public function getOptionsPlugin($name = '') { |
1120 | 1120 | if ($name) { |
1121 | - return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array(); |
|
1121 | + return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array(); |
|
1122 | 1122 | } else { |
1123 | 1123 | return $this->options['plugin']; |
1124 | 1124 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | $file = $this->stat($path); |
1249 | 1249 | |
1250 | 1250 | if ($hash === $this->root()) { |
1251 | - $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(); |
|
1251 | + $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(); |
|
1252 | 1252 | $file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON |
1253 | 1253 | } |
1254 | 1254 | |
@@ -1263,7 +1263,7 @@ discard block |
||
1263 | 1263 | * @return array|false |
1264 | 1264 | * @author Dmitry (dio) Levashov |
1265 | 1265 | **/ |
1266 | - public function dir($hash, $resolveLink=false) { |
|
1266 | + public function dir($hash, $resolveLink = false) { |
|
1267 | 1267 | if (($dir = $this->file($hash)) == false) { |
1268 | 1268 | return $this->setError(elFinder::ERROR_DIR_NOT_FOUND); |
1269 | 1269 | } |
@@ -1327,14 +1327,14 @@ discard block |
||
1327 | 1327 | * @return array|false |
1328 | 1328 | * @author Dmitry (dio) Levashov |
1329 | 1329 | **/ |
1330 | - public function tree($hash='', $deep=0, $exclude='') { |
|
1330 | + public function tree($hash = '', $deep = 0, $exclude = '') { |
|
1331 | 1331 | $path = $hash ? $this->decode($hash) : $this->root; |
1332 | 1332 | |
1333 | 1333 | if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') { |
1334 | 1334 | return false; |
1335 | 1335 | } |
1336 | 1336 | |
1337 | - $dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null); |
|
1337 | + $dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null); |
|
1338 | 1338 | array_unshift($dirs, $dir); |
1339 | 1339 | return $dirs; |
1340 | 1340 | } |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | * @return array|false |
1565 | 1565 | * @author Dmitry (dio) Levashov |
1566 | 1566 | **/ |
1567 | - public function duplicate($hash, $suffix='copy') { |
|
1567 | + public function duplicate($hash, $suffix = 'copy') { |
|
1568 | 1568 | if ($this->commandDisabled('duplicate')) { |
1569 | 1569 | return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED); |
1570 | 1570 | } |
@@ -1640,7 +1640,7 @@ discard block |
||
1640 | 1640 | |
1641 | 1641 | if ($file) { // file exists |
1642 | 1642 | // check POST data `overwrite` for 3rd party uploader |
1643 | - $overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1643 | + $overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1644 | 1644 | if ($overwrite) { |
1645 | 1645 | if (!$file['write']) { |
1646 | 1646 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
@@ -1711,7 +1711,7 @@ discard block |
||
1711 | 1711 | if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) { |
1712 | 1712 | return $rmSrc |
1713 | 1713 | ? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test)) |
1714 | - : $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1714 | + : $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1715 | 1715 | } |
1716 | 1716 | |
1717 | 1717 | $test = $this->joinPathCE($destination, $name); |
@@ -1874,7 +1874,7 @@ discard block |
||
1874 | 1874 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
1875 | 1875 | } |
1876 | 1876 | $this->clearcache(); |
1877 | - $this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir; |
|
1877 | + $this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir; |
|
1878 | 1878 | |
1879 | 1879 | if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) { |
1880 | 1880 | if (is_array($path)) { |
@@ -1932,9 +1932,9 @@ discard block |
||
1932 | 1932 | if ($name === '') { |
1933 | 1933 | $name = count($files) == 1 ? $files[0] : 'Archive'; |
1934 | 1934 | } else { |
1935 | - $name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name)); |
|
1935 | + $name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name)); |
|
1936 | 1936 | } |
1937 | - $name .='.' . $archiver['ext']; |
|
1937 | + $name .= '.'.$archiver['ext']; |
|
1938 | 1938 | $name = $this->uniqueName($dir, $name, ''); |
1939 | 1939 | $this->clearcache(); |
1940 | 1940 | return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false; |
@@ -1973,7 +1973,7 @@ discard block |
||
1973 | 1973 | |
1974 | 1974 | $path = $this->decode($hash); |
1975 | 1975 | |
1976 | - $work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path); |
|
1976 | + $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path); |
|
1977 | 1977 | |
1978 | 1978 | if (!$work_path || !is_writable($work_path)) { |
1979 | 1979 | if ($work_path && $path !== $work_path && is_file($work_path)) { |
@@ -1988,7 +1988,7 @@ discard block |
||
1988 | 1988 | } |
1989 | 1989 | } |
1990 | 1990 | |
1991 | - switch($mode) { |
|
1991 | + switch ($mode) { |
|
1992 | 1992 | |
1993 | 1993 | case 'propresize': |
1994 | 1994 | $result = $this->imgResize($work_path, $width, $height, true, true, null, $jpgQuality); |
@@ -2084,7 +2084,7 @@ discard block |
||
2084 | 2084 | } |
2085 | 2085 | return ($q === '' || $this->commandDisabled('search')) |
2086 | 2086 | ? array() |
2087 | - : $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes); |
|
2087 | + : $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes); |
|
2088 | 2088 | } |
2089 | 2089 | |
2090 | 2090 | /** |
@@ -2156,9 +2156,9 @@ discard block |
||
2156 | 2156 | $path = ltrim($path, $this->separator); |
2157 | 2157 | $dirs = explode($this->separator, $path); |
2158 | 2158 | array_pop($dirs); |
2159 | - foreach($dirs as $dir) { |
|
2159 | + foreach ($dirs as $dir) { |
|
2160 | 2160 | $targetPath = $this->joinPathCE($base, $dir); |
2161 | - if (! $_realpath = $this->realpath($this->encode($targetPath))) { |
|
2161 | + if (!$_realpath = $this->realpath($this->encode($targetPath))) { |
|
2162 | 2162 | if ($stat = $this->mkdir($targetHash, $dir)) { |
2163 | 2163 | $result['added'][] = $stat; |
2164 | 2164 | $targetHash = $stat['hash']; |
@@ -2225,7 +2225,7 @@ discard block |
||
2225 | 2225 | * @author Naoki Sawada |
2226 | 2226 | **/ |
2227 | 2227 | protected function dirnameCE($path) { |
2228 | - return (!$this->encoding)? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2228 | + return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2229 | 2229 | } |
2230 | 2230 | |
2231 | 2231 | /** |
@@ -2236,7 +2236,7 @@ discard block |
||
2236 | 2236 | * @author Naoki Sawada |
2237 | 2237 | **/ |
2238 | 2238 | protected function basenameCE($path) { |
2239 | - return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2239 | + return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2240 | 2240 | } |
2241 | 2241 | |
2242 | 2242 | /** |
@@ -2249,7 +2249,7 @@ discard block |
||
2249 | 2249 | * @author Naoki Sawada |
2250 | 2250 | **/ |
2251 | 2251 | protected function joinPathCE($dir, $name) { |
2252 | - return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2252 | + return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2253 | 2253 | } |
2254 | 2254 | |
2255 | 2255 | /** |
@@ -2260,7 +2260,7 @@ discard block |
||
2260 | 2260 | * @author Naoki Sawada |
2261 | 2261 | **/ |
2262 | 2262 | protected function normpathCE($path) { |
2263 | - return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2263 | + return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2264 | 2264 | } |
2265 | 2265 | |
2266 | 2266 | /** |
@@ -2271,7 +2271,7 @@ discard block |
||
2271 | 2271 | * @author Naoki Sawada |
2272 | 2272 | **/ |
2273 | 2273 | protected function relpathCE($path) { |
2274 | - return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2274 | + return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2275 | 2275 | } |
2276 | 2276 | |
2277 | 2277 | /** |
@@ -2282,7 +2282,7 @@ discard block |
||
2282 | 2282 | * @author Naoki Sawada |
2283 | 2283 | **/ |
2284 | 2284 | protected function abspathCE($path) { |
2285 | - return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2285 | + return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2286 | 2286 | } |
2287 | 2287 | |
2288 | 2288 | /** |
@@ -2294,7 +2294,7 @@ discard block |
||
2294 | 2294 | * @author Naoki Sawada |
2295 | 2295 | **/ |
2296 | 2296 | protected function inpathCE($path, $parent) { |
2297 | - return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2297 | + return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2298 | 2298 | } |
2299 | 2299 | |
2300 | 2300 | /** |
@@ -2305,8 +2305,8 @@ discard block |
||
2305 | 2305 | * @return resource|false |
2306 | 2306 | * @author Naoki Sawada |
2307 | 2307 | **/ |
2308 | - protected function fopenCE($path, $mode='rb') { |
|
2309 | - return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2308 | + protected function fopenCE($path, $mode = 'rb') { |
|
2309 | + return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | /** |
@@ -2317,8 +2317,8 @@ discard block |
||
2317 | 2317 | * @return bool |
2318 | 2318 | * @author Naoki Sawada |
2319 | 2319 | **/ |
2320 | - protected function fcloseCE($fp, $path='') { |
|
2321 | - return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2320 | + protected function fcloseCE($fp, $path = '') { |
|
2321 | + return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2322 | 2322 | } |
2323 | 2323 | |
2324 | 2324 | /** |
@@ -2333,7 +2333,7 @@ discard block |
||
2333 | 2333 | * @author Naoki Sawada |
2334 | 2334 | **/ |
2335 | 2335 | protected function saveCE($fp, $dir, $name, $stat) { |
2336 | - return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2336 | + return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2337 | 2337 | } |
2338 | 2338 | |
2339 | 2339 | /** |
@@ -2345,7 +2345,7 @@ discard block |
||
2345 | 2345 | **/ |
2346 | 2346 | protected function subdirsCE($path) { |
2347 | 2347 | if (!isset($this->subdirsCache[$path])) { |
2348 | - $this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2348 | + $this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2349 | 2349 | } |
2350 | 2350 | return $this->subdirsCache[$path]; |
2351 | 2351 | } |
@@ -2358,7 +2358,7 @@ discard block |
||
2358 | 2358 | * @author Naoki Sawada |
2359 | 2359 | **/ |
2360 | 2360 | protected function scandirCE($path) { |
2361 | - return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2361 | + return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2362 | 2362 | } |
2363 | 2363 | |
2364 | 2364 | /** |
@@ -2371,7 +2371,7 @@ discard block |
||
2371 | 2371 | * @author Naoki Sawada |
2372 | 2372 | **/ |
2373 | 2373 | protected function symlinkCE($source, $targetDir, $name) { |
2374 | - return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2374 | + return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2375 | 2375 | } |
2376 | 2376 | |
2377 | 2377 | /***************** paths *******************/ |
@@ -2390,7 +2390,7 @@ discard block |
||
2390 | 2390 | // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root |
2391 | 2391 | $p = $this->relpathCE($path); |
2392 | 2392 | // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt |
2393 | - if ($p === '') { |
|
2393 | + if ($p === '') { |
|
2394 | 2394 | $p = DIRECTORY_SEPARATOR; |
2395 | 2395 | } |
2396 | 2396 | |
@@ -2423,7 +2423,7 @@ discard block |
||
2423 | 2423 | // TODO uncrypt hash and return path |
2424 | 2424 | $path = $this->uncrypt($h); |
2425 | 2425 | // append ROOT to path after it was cut in encode |
2426 | - return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2426 | + return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2427 | 2427 | } |
2428 | 2428 | } |
2429 | 2429 | |
@@ -2483,21 +2483,21 @@ discard block |
||
2483 | 2483 | * @author Dmitry (dio) Levashov |
2484 | 2484 | **/ |
2485 | 2485 | public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) { |
2486 | - $ext = ''; |
|
2486 | + $ext = ''; |
|
2487 | 2487 | |
2488 | 2488 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
2489 | 2489 | $ext = '.'.$m[1]; |
2490 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
2490 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
2491 | 2491 | } |
2492 | 2492 | |
2493 | 2493 | if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) { |
2494 | - $i = (int)$m[2]; |
|
2495 | - $name = substr($name, 0, strlen($name)-strlen($m[2])); |
|
2494 | + $i = (int) $m[2]; |
|
2495 | + $name = substr($name, 0, strlen($name) - strlen($m[2])); |
|
2496 | 2496 | } else { |
2497 | 2497 | $i = $start; |
2498 | 2498 | $name .= $suffix; |
2499 | 2499 | } |
2500 | - $max = $i+100000; |
|
2500 | + $max = $i + 100000; |
|
2501 | 2501 | |
2502 | 2502 | while ($i <= $max) { |
2503 | 2503 | $n = $name.($i > 0 ? $i : '').$ext; |
@@ -2521,7 +2521,7 @@ discard block |
||
2521 | 2521 | * @author Naoki Sawada |
2522 | 2522 | */ |
2523 | 2523 | public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') { |
2524 | - return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2524 | + return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2525 | 2525 | } |
2526 | 2526 | |
2527 | 2527 | /** |
@@ -2534,7 +2534,7 @@ discard block |
||
2534 | 2534 | * @author Naoki Sawada |
2535 | 2535 | */ |
2536 | 2536 | public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') { |
2537 | - return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2537 | + return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2538 | 2538 | } |
2539 | 2539 | |
2540 | 2540 | /** |
@@ -2554,7 +2554,7 @@ discard block |
||
2554 | 2554 | } |
2555 | 2555 | if (is_array($var)) { |
2556 | 2556 | $_ret = array(); |
2557 | - foreach($var as $_k => $_v) { |
|
2557 | + foreach ($var as $_k => $_v) { |
|
2558 | 2558 | $_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_'); |
2559 | 2559 | } |
2560 | 2560 | $var = $_ret; |
@@ -2566,7 +2566,7 @@ discard block |
||
2566 | 2566 | $_var = str_replace('?', $unknown, $_var); |
2567 | 2567 | } |
2568 | 2568 | } |
2569 | - if ($_var !== false) { |
|
2569 | + if ($_var !== false) { |
|
2570 | 2570 | $var = $_var; |
2571 | 2571 | } |
2572 | 2572 | } |
@@ -2593,7 +2593,7 @@ discard block |
||
2593 | 2593 | |
2594 | 2594 | $key = ''; |
2595 | 2595 | if ($path !== '') { |
2596 | - $key = $this->id . '#' . $path; |
|
2596 | + $key = $this->id.'#'.$path; |
|
2597 | 2597 | if (isset($cache[$key])) { |
2598 | 2598 | return $cache[$key]; |
2599 | 2599 | } |
@@ -2625,7 +2625,7 @@ discard block |
||
2625 | 2625 | if ($work = $this->getTempFile()) { |
2626 | 2626 | if ($wfp = fopen($work, 'wb')) { |
2627 | 2627 | if ($fp = $this->_fopen($path)) { |
2628 | - while(!feof($fp)) { |
|
2628 | + while (!feof($fp)) { |
|
2629 | 2629 | fwrite($wfp, fread($fp, 8192)); |
2630 | 2630 | } |
2631 | 2631 | $this->_fclose($fp, $path); |
@@ -2669,7 +2669,7 @@ discard block |
||
2669 | 2669 | @set_time_limit(30); |
2670 | 2670 | $stat = $this->stat($this->convEncOut($p)); |
2671 | 2671 | $this->convEncIn(); |
2672 | - ($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p); |
|
2672 | + ($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p); |
|
2673 | 2673 | } |
2674 | 2674 | return $this->_rmdir($localpath); |
2675 | 2675 | } |
@@ -2686,7 +2686,7 @@ discard block |
||
2686 | 2686 | * @return bool |
2687 | 2687 | * @author Dmitry (dio) Levashov |
2688 | 2688 | **/ |
2689 | - protected function attr($path, $name, $val=null, $isDir=null) { |
|
2689 | + protected function attr($path, $name, $val = null, $isDir = null) { |
|
2690 | 2690 | if (!isset($this->defaults[$name])) { |
2691 | 2691 | return false; |
2692 | 2692 | } |
@@ -2718,7 +2718,7 @@ discard block |
||
2718 | 2718 | } |
2719 | 2719 | } |
2720 | 2720 | |
2721 | - return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm; |
|
2721 | + return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm; |
|
2722 | 2722 | } |
2723 | 2723 | |
2724 | 2724 | /** |
@@ -2762,7 +2762,7 @@ discard block |
||
2762 | 2762 | protected function allowPutMime($mime) { |
2763 | 2763 | // logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order |
2764 | 2764 | $allow = $this->mimeAccepted($mime, $this->uploadAllow, null); |
2765 | - $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2765 | + $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2766 | 2766 | $res = true; // default to allow |
2767 | 2767 | if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny' |
2768 | 2768 | $res = false; // default is deny |
@@ -2835,10 +2835,10 @@ discard block |
||
2835 | 2835 | if ($this->rootName) { |
2836 | 2836 | $stat['name'] = $this->rootName; |
2837 | 2837 | } |
2838 | - if (! empty($this->options['icon'])) { |
|
2838 | + if (!empty($this->options['icon'])) { |
|
2839 | 2839 | $stat['icon'] = $this->options['icon']; |
2840 | 2840 | } |
2841 | - if (! empty($this->options['rootCssClass'])) { |
|
2841 | + if (!empty($this->options['rootCssClass'])) { |
|
2842 | 2842 | $stat['csscls'] = $this->options['rootCssClass']; |
2843 | 2843 | } |
2844 | 2844 | } else { |
@@ -2886,7 +2886,7 @@ discard block |
||
2886 | 2886 | // lock when parent directory is not writable |
2887 | 2887 | if (!isset($stat['locked'])) { |
2888 | 2888 | $parent = $this->dirnameCE($path); |
2889 | - $pstat = isset($this->cache[$parent])? $this->cache[$parent] : array(); |
|
2889 | + $pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array(); |
|
2890 | 2890 | if (isset($pstat['write']) && !$pstat['write']) { |
2891 | 2891 | $stat['locked'] = true; |
2892 | 2892 | } |
@@ -2944,7 +2944,7 @@ discard block |
||
2944 | 2944 | } |
2945 | 2945 | if (!isset($stat['url']) && $this->URL && $this->encoding) { |
2946 | 2946 | $_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1)); |
2947 | - $stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN')? $_path : $this->convEncIn($_path, true))); |
|
2947 | + $stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true))); |
|
2948 | 2948 | } |
2949 | 2949 | } else { |
2950 | 2950 | if ($isDir) { |
@@ -3067,7 +3067,7 @@ discard block |
||
3067 | 3067 | foreach ($mimecf as $line_num => $line) { |
3068 | 3068 | if (!preg_match('/^\s*#/', $line)) { |
3069 | 3069 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
3070 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
3070 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
3071 | 3071 | if (!isset(elFinderVolumeDriver::$mimetypes[$mime[$i]])) { |
3072 | 3072 | elFinderVolumeDriver::$mimetypes[$mime[$i]] = $mime[0]; |
3073 | 3073 | } |
@@ -3205,7 +3205,7 @@ discard block |
||
3205 | 3205 | * @return array |
3206 | 3206 | * @author Dmitry (dio) Levashov |
3207 | 3207 | **/ |
3208 | - protected function gettree($path, $deep, $exclude='') { |
|
3208 | + protected function gettree($path, $deep, $exclude = '') { |
|
3209 | 3209 | $dirs = array(); |
3210 | 3210 | |
3211 | 3211 | !isset($this->dirsCache[$path]) && $this->cacheDir($path); |
@@ -3216,7 +3216,7 @@ discard block |
||
3216 | 3216 | if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') { |
3217 | 3217 | $dirs[] = $stat; |
3218 | 3218 | if ($deep > 0 && !empty($stat['dirs'])) { |
3219 | - $dirs = array_merge($dirs, $this->gettree($p, $deep-1)); |
|
3219 | + $dirs = array_merge($dirs, $this->gettree($p, $deep - 1)); |
|
3220 | 3220 | } |
3221 | 3221 | } |
3222 | 3222 | } |
@@ -3236,7 +3236,7 @@ discard block |
||
3236 | 3236 | protected function doSearch($path, $q, $mimes) { |
3237 | 3237 | $result = array(); |
3238 | 3238 | |
3239 | - foreach($this->scandirCE($path) as $p) { |
|
3239 | + foreach ($this->scandirCE($path) as $p) { |
|
3240 | 3240 | @set_time_limit(30); |
3241 | 3241 | $stat = $this->stat($p); |
3242 | 3242 | |
@@ -3257,7 +3257,7 @@ discard block |
||
3257 | 3257 | if ($this->encoding) { |
3258 | 3258 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
3259 | 3259 | } |
3260 | - $stat['url'] = $this->URL . $path; |
|
3260 | + $stat['url'] = $this->URL.$path; |
|
3261 | 3261 | } |
3262 | 3262 | |
3263 | 3263 | $result[] = $stat; |
@@ -3291,7 +3291,7 @@ discard block |
||
3291 | 3291 | if (!$this->inpathCE($target, $this->root)) { |
3292 | 3292 | return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK); |
3293 | 3293 | } |
3294 | - $stat = $this->stat($target); |
|
3294 | + $stat = $this->stat($target); |
|
3295 | 3295 | $this->clearcache(); |
3296 | 3296 | return $stat && $this->symlinkCE($target, $dst, $name) |
3297 | 3297 | ? $this->joinPathCE($dst, $name) |
@@ -3572,15 +3572,15 @@ discard block |
||
3572 | 3572 | } |
3573 | 3573 | |
3574 | 3574 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
3575 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3576 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3575 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3576 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3577 | 3577 | } else { |
3578 | 3578 | |
3579 | 3579 | if ($this->options['tmbCrop']) { |
3580 | 3580 | |
3581 | 3581 | $result = $tmb; |
3582 | 3582 | /* Resize and crop if image bigger than thumbnail */ |
3583 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3583 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3584 | 3584 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
3585 | 3585 | } |
3586 | 3586 | |
@@ -3597,7 +3597,7 @@ discard block |
||
3597 | 3597 | } |
3598 | 3598 | |
3599 | 3599 | if ($result) { |
3600 | - $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3600 | + $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3601 | 3601 | } |
3602 | 3602 | } |
3603 | 3603 | |
@@ -3643,18 +3643,18 @@ discard block |
||
3643 | 3643 | /* Resizing by biggest side */ |
3644 | 3644 | if ($resizeByBiggerSide) { |
3645 | 3645 | if ($orig_w > $orig_h) { |
3646 | - $size_h = round($orig_h * $width / $orig_w); |
|
3646 | + $size_h = round($orig_h*$width/$orig_w); |
|
3647 | 3647 | $size_w = $width; |
3648 | 3648 | } else { |
3649 | - $size_w = round($orig_w * $height / $orig_h); |
|
3649 | + $size_w = round($orig_w*$height/$orig_h); |
|
3650 | 3650 | $size_h = $height; |
3651 | 3651 | } |
3652 | 3652 | } else { |
3653 | 3653 | if ($orig_w > $orig_h) { |
3654 | - $size_w = round($orig_w * $height / $orig_h); |
|
3654 | + $size_w = round($orig_w*$height/$orig_h); |
|
3655 | 3655 | $size_h = $height; |
3656 | 3656 | } else { |
3657 | - $size_h = round($orig_h * $width / $orig_w); |
|
3657 | + $size_h = round($orig_h*$width/$orig_w); |
|
3658 | 3658 | $size_w = $width; |
3659 | 3659 | } |
3660 | 3660 | } |
@@ -3672,7 +3672,7 @@ discard block |
||
3672 | 3672 | // Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb |
3673 | 3673 | // resize bench: http://app-mgng.rhcloud.com/9 |
3674 | 3674 | // resize sample: http://www.dylanbeattie.net/magick/filters/result.html |
3675 | - $filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3675 | + $filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3676 | 3676 | |
3677 | 3677 | $ani = ($img->getNumberImages() > 1); |
3678 | 3678 | if ($ani && is_null($destformat)) { |
@@ -3697,11 +3697,11 @@ discard block |
||
3697 | 3697 | break; |
3698 | 3698 | |
3699 | 3699 | case 'gd': |
3700 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
3700 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
3701 | 3701 | |
3702 | - if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3702 | + if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3703 | 3703 | |
3704 | - $this->gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3704 | + $this->gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3705 | 3705 | |
3706 | 3706 | if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) { |
3707 | 3707 | return false; |
@@ -3782,11 +3782,11 @@ discard block |
||
3782 | 3782 | break; |
3783 | 3783 | |
3784 | 3784 | case 'gd': |
3785 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
3785 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
3786 | 3786 | |
3787 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3787 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3788 | 3788 | |
3789 | - $this->gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3789 | + $this->gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3790 | 3790 | |
3791 | 3791 | $size_w = $width; |
3792 | 3792 | $size_h = $height; |
@@ -3837,8 +3837,8 @@ discard block |
||
3837 | 3837 | $result = false; |
3838 | 3838 | |
3839 | 3839 | /* Coordinates for image over square aligning */ |
3840 | - $y = ceil(abs($height - $s[1]) / 2); |
|
3841 | - $x = ceil(abs($width - $s[0]) / 2); |
|
3840 | + $y = ceil(abs($height - $s[1])/2); |
|
3841 | + $x = ceil(abs($width - $s[0])/2); |
|
3842 | 3842 | |
3843 | 3843 | if (!$jpgQuality) { |
3844 | 3844 | $jpgQuality = $this->options['jpgQuality']; |
@@ -3862,7 +3862,7 @@ discard block |
||
3862 | 3862 | $gif->newImage($width, $height, new ImagickPixel($bgcolor)); |
3863 | 3863 | $gif->setImageColorspace($img->getImageColorspace()); |
3864 | 3864 | $gif->setImageFormat('gif'); |
3865 | - $gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3865 | + $gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3866 | 3866 | $gif->setImageDelay($img->getImageDelay()); |
3867 | 3867 | $gif->setImageIterations($img->getImageIterations()); |
3868 | 3868 | $img1->addImage($gif); |
@@ -3877,7 +3877,7 @@ discard block |
||
3877 | 3877 | $img1 = new Imagick(); |
3878 | 3878 | $img1->newImage($width, $height, new ImagickPixel($bgcolor)); |
3879 | 3879 | $img1->setImageColorspace($img->getImageColorspace()); |
3880 | - $img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3880 | + $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3881 | 3881 | $result = $this->imagickImage($img, $path, $destformat, $jpgQuality); |
3882 | 3882 | } |
3883 | 3883 | |
@@ -3888,11 +3888,11 @@ discard block |
||
3888 | 3888 | break; |
3889 | 3889 | |
3890 | 3890 | case 'gd': |
3891 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
3891 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
3892 | 3892 | |
3893 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3893 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3894 | 3894 | |
3895 | - $this->gdImageBackground($tmp,$bgcolor); |
|
3895 | + $this->gdImageBackground($tmp, $bgcolor); |
|
3896 | 3896 | |
3897 | 3897 | if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) { |
3898 | 3898 | return false; |
@@ -3924,15 +3924,15 @@ discard block |
||
3924 | 3924 | * @author Troex Nevelin |
3925 | 3925 | **/ |
3926 | 3926 | protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null, $jpgQuality = null) { |
3927 | - if (($s = @getimagesize($path)) == false || $degree % 360 === 0) { |
|
3927 | + if (($s = @getimagesize($path)) == false || $degree%360 === 0) { |
|
3928 | 3928 | return false; |
3929 | 3929 | } |
3930 | 3930 | |
3931 | 3931 | $result = false; |
3932 | 3932 | |
3933 | 3933 | // try lossless rotate |
3934 | - if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
3935 | - $count = ($degree / 90) % 4; |
|
3934 | + if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
3935 | + $count = ($degree/90)%4; |
|
3936 | 3936 | $exiftran = array( |
3937 | 3937 | 1 => '-9', |
3938 | 3938 | 2 => '-1', |
@@ -3948,7 +3948,7 @@ discard block |
||
3948 | 3948 | 'exiftran -i '.$exiftran[$count].' '.$path, |
3949 | 3949 | 'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath |
3950 | 3950 | ); |
3951 | - foreach($cmds as $cmd) { |
|
3951 | + foreach ($cmds as $cmd) { |
|
3952 | 3952 | if ($this->procExec($cmd) === 0) { |
3953 | 3953 | $result = true; |
3954 | 3954 | break; |
@@ -3988,12 +3988,12 @@ discard block |
||
3988 | 3988 | break; |
3989 | 3989 | |
3990 | 3990 | case 'gd': |
3991 | - $img = $this->gdImageCreate($path,$s['mime']); |
|
3991 | + $img = $this->gdImageCreate($path, $s['mime']); |
|
3992 | 3992 | |
3993 | 3993 | $degree = 360 - $degree; |
3994 | 3994 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
3995 | 3995 | $bgcolor = imagecolorallocate($img, $r, $g, $b); |
3996 | - $tmp = imageRotate($img, $degree, (int)$bgcolor); |
|
3996 | + $tmp = imageRotate($img, $degree, (int) $bgcolor); |
|
3997 | 3997 | |
3998 | 3998 | $result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality); |
3999 | 3999 | |
@@ -4018,11 +4018,11 @@ discard block |
||
4018 | 4018 | * @return int exit code |
4019 | 4019 | * @author Alexey Sukhotin |
4020 | 4020 | **/ |
4021 | - protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
4021 | + protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
4022 | 4022 | |
4023 | 4023 | $descriptorspec = array( |
4024 | - 0 => array("pipe", "r"), // stdin |
|
4025 | - 1 => array("pipe", "w"), // stdout |
|
4024 | + 0 => array("pipe", "r"), // stdin |
|
4025 | + 1 => array("pipe", "w"), // stdout |
|
4026 | 4026 | 2 => array("pipe", "w") // stderr |
4027 | 4027 | ); |
4028 | 4028 | |
@@ -4079,8 +4079,8 @@ discard block |
||
4079 | 4079 | * @param string $mime |
4080 | 4080 | * @return gd image resource identifier |
4081 | 4081 | */ |
4082 | - protected function gdImageCreate($path,$mime){ |
|
4083 | - switch($mime){ |
|
4082 | + protected function gdImageCreate($path, $mime) { |
|
4083 | + switch ($mime) { |
|
4084 | 4084 | case 'image/jpeg': |
4085 | 4085 | return imagecreatefromjpeg($path); |
4086 | 4086 | |
@@ -4105,7 +4105,7 @@ discard block |
||
4105 | 4105 | * @param string $mime The original image mime type |
4106 | 4106 | * @param int $jpgQuality JEPG quality (1-100) |
4107 | 4107 | */ |
4108 | - protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null ){ |
|
4108 | + protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null) { |
|
4109 | 4109 | |
4110 | 4110 | if (!$jpgQuality) { |
4111 | 4111 | $jpgQuality = $this->options['jpgQuality']; |
@@ -4129,7 +4129,7 @@ discard block |
||
4129 | 4129 | * @param string $destformat The Image type to use for $filename |
4130 | 4130 | * @param int $jpgQuality JEPG quality (1-100) |
4131 | 4131 | */ |
4132 | - protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ){ |
|
4132 | + protected function imagickImage($img, $filename, $destformat, $jpgQuality = null) { |
|
4133 | 4133 | |
4134 | 4134 | if (!$jpgQuality) { |
4135 | 4135 | $jpgQuality = $this->options['jpgQuality']; |
@@ -4184,13 +4184,13 @@ discard block |
||
4184 | 4184 | * @param resource $image gd image resource |
4185 | 4185 | * @param string $bgcolor background color in #rrggbb format |
4186 | 4186 | */ |
4187 | - protected function gdImageBackground($image, $bgcolor){ |
|
4187 | + protected function gdImageBackground($image, $bgcolor) { |
|
4188 | 4188 | |
4189 | - if( $bgcolor == 'transparent' ){ |
|
4190 | - imagesavealpha($image,true); |
|
4189 | + if ($bgcolor == 'transparent') { |
|
4190 | + imagesavealpha($image, true); |
|
4191 | 4191 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
4192 | 4192 | |
4193 | - }else{ |
|
4193 | + } else { |
|
4194 | 4194 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
4195 | 4195 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
4196 | 4196 | } |
@@ -4228,13 +4228,13 @@ discard block |
||
4228 | 4228 | * @return int|bool |
4229 | 4229 | * @author Alexey Sukhotin |
4230 | 4230 | **/ |
4231 | - protected function stripos($haystack , $needle , $offset = 0) { |
|
4231 | + protected function stripos($haystack, $needle, $offset = 0) { |
|
4232 | 4232 | if (function_exists('mb_stripos')) { |
4233 | - return mb_stripos($haystack , $needle , $offset, 'UTF-8'); |
|
4233 | + return mb_stripos($haystack, $needle, $offset, 'UTF-8'); |
|
4234 | 4234 | } else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) { |
4235 | 4235 | return mb_strpos(mb_strtolower($haystack, 'UTF-8'), mb_strtolower($needle, 'UTF-8'), $offset); |
4236 | 4236 | } |
4237 | - return stripos($haystack , $needle , $offset); |
|
4237 | + return stripos($haystack, $needle, $offset); |
|
4238 | 4238 | } |
4239 | 4239 | |
4240 | 4240 | /** |
@@ -4284,22 +4284,22 @@ discard block |
||
4284 | 4284 | unset($o); |
4285 | 4285 | $this->procExec('zip -v', $o, $c); |
4286 | 4286 | if ($c == 0) { |
4287 | - $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4287 | + $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4288 | 4288 | } |
4289 | 4289 | unset($o); |
4290 | 4290 | $this->procExec('unzip --help', $o, $c); |
4291 | 4291 | if ($c == 0) { |
4292 | - $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4292 | + $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4293 | 4293 | } |
4294 | 4294 | unset($o); |
4295 | 4295 | $this->procExec('rar --version', $o, $c); |
4296 | 4296 | if ($c == 0 || $c == 7) { |
4297 | 4297 | $arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar'); |
4298 | - $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4298 | + $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4299 | 4299 | } else { |
4300 | 4300 | unset($o); |
4301 | 4301 | $test = $this->procExec('unrar', $o, $c); |
4302 | - if ($c==0 || $c == 7) { |
|
4302 | + if ($c == 0 || $c == 7) { |
|
4303 | 4303 | $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar'); |
4304 | 4304 | } |
4305 | 4305 | } |
@@ -4321,7 +4321,7 @@ discard block |
||
4321 | 4321 | if (empty($arcs['extract']['application/x-tar'])) { |
4322 | 4322 | $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar'); |
4323 | 4323 | } |
4324 | - } else if (substr(PHP_OS,0,3) === 'WIN') { |
|
4324 | + } else if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
4325 | 4325 | // check `7z` for Windows server. |
4326 | 4326 | unset($o); |
4327 | 4327 | $this->procExec('7z', $o, $c); |
@@ -4375,22 +4375,22 @@ discard block |
||
4375 | 4375 | |
4376 | 4376 | // normalize `/../` |
4377 | 4377 | $normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#'; |
4378 | - while(preg_match($normreg, $path)) { |
|
4378 | + while (preg_match($normreg, $path)) { |
|
4379 | 4379 | $path = preg_replace($normreg, '$1', $path); |
4380 | 4380 | } |
4381 | 4381 | |
4382 | 4382 | // 'Here' |
4383 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
4383 | + if ($path === '' || $path === '.'.$separator) return $base; |
|
4384 | 4384 | |
4385 | 4385 | // Absolute path |
4386 | 4386 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
4387 | 4387 | return $path; |
4388 | 4388 | } |
4389 | 4389 | |
4390 | - $preg_separator = '#' . $sepquoted . '#'; |
|
4390 | + $preg_separator = '#'.$sepquoted.'#'; |
|
4391 | 4391 | |
4392 | 4392 | // Relative path from 'Here' |
4393 | - if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) { |
|
4393 | + if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) { |
|
4394 | 4394 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4395 | 4395 | if ($arrn[0] !== '.') { |
4396 | 4396 | array_unshift($arrn, '.'); |
@@ -4404,12 +4404,11 @@ discard block |
||
4404 | 4404 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4405 | 4405 | $arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY); |
4406 | 4406 | |
4407 | - while (! empty($arrn) && $arrn[0] === '..') { |
|
4407 | + while (!empty($arrn) && $arrn[0] === '..') { |
|
4408 | 4408 | array_shift($arrn); |
4409 | 4409 | array_pop($arrp); |
4410 | 4410 | } |
4411 | - $path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) : |
|
4412 | - (! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot); |
|
4411 | + $path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot); |
|
4413 | 4412 | } |
4414 | 4413 | |
4415 | 4414 | return $path; |
@@ -4427,7 +4426,7 @@ discard block |
||
4427 | 4426 | @chmod($dir, 0777); |
4428 | 4427 | foreach (array_diff(scandir($dir), array('.', '..')) as $file) { |
4429 | 4428 | @set_time_limit(30); |
4430 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4429 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4431 | 4430 | if (!is_link($dir) && is_dir($path)) { |
4432 | 4431 | $this->rmdirRecursive($path); |
4433 | 4432 | } else { |
@@ -4514,22 +4513,22 @@ discard block |
||
4514 | 4513 | try { |
4515 | 4514 | if ($start = is_string($zipPath)) { |
4516 | 4515 | $zip = new ZipArchive(); |
4517 | - if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) { |
|
4516 | + if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) { |
|
4518 | 4517 | $zip = false; |
4519 | 4518 | } |
4520 | 4519 | } else { |
4521 | 4520 | $zip = $zipPath; |
4522 | 4521 | } |
4523 | 4522 | if ($zip) { |
4524 | - foreach($files as $file) { |
|
4525 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4523 | + foreach ($files as $file) { |
|
4524 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4526 | 4525 | if (is_dir($path)) { |
4527 | 4526 | $zip->addEmptyDir($file); |
4528 | 4527 | $_files = array(); |
4529 | 4528 | if ($handle = opendir($path)) { |
4530 | 4529 | while (false !== ($entry = readdir($handle))) { |
4531 | 4530 | if ($entry !== "." && $entry !== "..") { |
4532 | - $_files[] = $file . DIRECTORY_SEPARATOR . $entry; |
|
4531 | + $_files[] = $file.DIRECTORY_SEPARATOR.$entry; |
|
4533 | 4532 | } |
4534 | 4533 | } |
4535 | 4534 | closedir($handle); |
@@ -4714,7 +4713,7 @@ discard block |
||
4714 | 4713 | * @return resource|false |
4715 | 4714 | * @author Dmitry (dio) Levashov |
4716 | 4715 | **/ |
4717 | - abstract protected function _fopen($path, $mode="rb"); |
|
4716 | + abstract protected function _fopen($path, $mode = "rb"); |
|
4718 | 4717 | |
4719 | 4718 | /** |
4720 | 4719 | * Close opened file |
@@ -4724,7 +4723,7 @@ discard block |
||
4724 | 4723 | * @return bool |
4725 | 4724 | * @author Dmitry (dio) Levashov |
4726 | 4725 | **/ |
4727 | - abstract protected function _fclose($fp, $path=''); |
|
4726 | + abstract protected function _fclose($fp, $path = ''); |
|
4728 | 4727 | |
4729 | 4728 | /******************** file/dir manipulations *************************/ |
4730 | 4729 |
@@ -1238,7 +1238,6 @@ discard block |
||
1238 | 1238 | * Return file info or false on error |
1239 | 1239 | * |
1240 | 1240 | * @param string $hash file hash |
1241 | - * @param bool $realpath add realpath field to file info |
|
1242 | 1241 | * @return array|false |
1243 | 1242 | * @author Dmitry (dio) Levashov |
1244 | 1243 | **/ |
@@ -1259,7 +1258,6 @@ discard block |
||
1259 | 1258 | * Return folder info |
1260 | 1259 | * |
1261 | 1260 | * @param string $hash folder hash |
1262 | - * @param bool $hidden return hidden file info |
|
1263 | 1261 | * @return array|false |
1264 | 1262 | * @author Dmitry (dio) Levashov |
1265 | 1263 | **/ |
@@ -1592,7 +1590,6 @@ discard block |
||
1592 | 1590 | * |
1593 | 1591 | * @param Resource $fp file pointer |
1594 | 1592 | * @param string $dst destination folder hash |
1595 | - * @param string $src file name |
|
1596 | 1593 | * @param string $tmpname file tmp name - required to detect mime type |
1597 | 1594 | * @return array|false |
1598 | 1595 | * @author Dmitry (dio) Levashov |
@@ -1678,7 +1675,6 @@ discard block |
||
1678 | 1675 | * Paste files |
1679 | 1676 | * |
1680 | 1677 | * @param Object $volume source volume |
1681 | - * @param string $source file hash |
|
1682 | 1678 | * @param string $dst destination dir hash |
1683 | 1679 | * @param bool $rmSrc remove source after copy? |
1684 | 1680 | * @return array|false |
@@ -2301,7 +2297,6 @@ discard block |
||
2301 | 2297 | * Open file and return file pointer (with convert encording) |
2302 | 2298 | * |
2303 | 2299 | * @param string $path file path |
2304 | - * @param bool $write open file for writing |
|
2305 | 2300 | * @return resource|false |
2306 | 2301 | * @author Naoki Sawada |
2307 | 2302 | **/ |
@@ -2432,7 +2427,8 @@ discard block |
||
2432 | 2427 | * Not implemented |
2433 | 2428 | * |
2434 | 2429 | * @param string path |
2435 | - * @return mixed |
|
2430 | + * @param string $path |
|
2431 | + * @return string |
|
2436 | 2432 | * @author Dmitry (dio) Levashov |
2437 | 2433 | **/ |
2438 | 2434 | protected function crypt($path) { |
@@ -2444,7 +2440,8 @@ discard block |
||
2444 | 2440 | * Not implemented |
2445 | 2441 | * |
2446 | 2442 | * @param mixed hash |
2447 | - * @return mixed |
|
2443 | + * @param string $hash |
|
2444 | + * @return string |
|
2448 | 2445 | * @author Dmitry (dio) Levashov |
2449 | 2446 | **/ |
2450 | 2447 | protected function uncrypt($hash) { |
@@ -2477,7 +2474,6 @@ discard block |
||
2477 | 2474 | /** |
2478 | 2475 | * Return new unique name based on file name and suffix |
2479 | 2476 | * |
2480 | - * @param string $path file path |
|
2481 | 2477 | * @param string $suffix suffix append to name |
2482 | 2478 | * @return string |
2483 | 2479 | * @author Dmitry (dio) Levashov |
@@ -2545,6 +2541,7 @@ discard block |
||
2545 | 2541 | * @param string $to to character encoding |
2546 | 2542 | * @param string $locale local locale |
2547 | 2543 | * @param string $unknown replaces character for unknown |
2544 | + * @param boolean $restoreLocale |
|
2548 | 2545 | * @return mixed |
2549 | 2546 | */ |
2550 | 2547 | protected function convEnc($var, $from, $to, $locale, $restoreLocale, $unknown = '_') { |
@@ -2726,6 +2723,7 @@ discard block |
||
2726 | 2723 | * |
2727 | 2724 | * @param string $dir parent dir path |
2728 | 2725 | * @param string $name new file name |
2726 | + * @param boolean $isDir |
|
2729 | 2727 | * @return bool |
2730 | 2728 | * @author Dmitry (dio) Levashov |
2731 | 2729 | **/ |
@@ -3279,7 +3277,7 @@ discard block |
||
3279 | 3277 | * @param string $src source path |
3280 | 3278 | * @param string $dst destination dir path |
3281 | 3279 | * @param string $name new file name (optionaly) |
3282 | - * @return string|false |
|
3280 | + * @return boolean|string |
|
3283 | 3281 | * @author Dmitry (dio) Levashov |
3284 | 3282 | **/ |
3285 | 3283 | protected function copy($src, $dst, $name) { |
@@ -3332,7 +3330,7 @@ discard block |
||
3332 | 3330 | * @param string $src source path |
3333 | 3331 | * @param string $dst destination dir path |
3334 | 3332 | * @param string $name new file name |
3335 | - * @return string|false |
|
3333 | + * @return string|boolean |
|
3336 | 3334 | * @author Dmitry (dio) Levashov |
3337 | 3335 | **/ |
3338 | 3336 | protected function move($src, $dst, $name) { |
@@ -3358,7 +3356,7 @@ discard block |
||
3358 | 3356 | * @param string $src source file hash |
3359 | 3357 | * @param string $destination destination dir path |
3360 | 3358 | * @param string $name file name |
3361 | - * @return string|false |
|
3359 | + * @return boolean|string |
|
3362 | 3360 | * @author Dmitry (dio) Levashov |
3363 | 3361 | **/ |
3364 | 3362 | protected function copyFrom($volume, $src, $destination, $name) { |
@@ -3506,7 +3504,7 @@ discard block |
||
3506 | 3504 | * @param string $path thumnbnail path |
3507 | 3505 | * @param array $stat file stat |
3508 | 3506 | * @param bool $checkTmbPath |
3509 | - * @return string|bool |
|
3507 | + * @return boolean |
|
3510 | 3508 | * @author Dmitry (dio) Levashov |
3511 | 3509 | **/ |
3512 | 3510 | protected function canCreateTmb($path, $stat, $checkTmbPath = true) { |
@@ -3523,7 +3521,7 @@ discard block |
||
3523 | 3521 | * |
3524 | 3522 | * @param string $path thumnbnail path |
3525 | 3523 | * @param array $stat file stat |
3526 | - * @return string|bool |
|
3524 | + * @return boolean |
|
3527 | 3525 | * @author Dmitry (dio) Levashov |
3528 | 3526 | **/ |
3529 | 3527 | protected function canResize($path, $stat) { |
@@ -3534,7 +3532,6 @@ discard block |
||
3534 | 3532 | * Create thumnbnail and return it's URL on success |
3535 | 3533 | * |
3536 | 3534 | * @param string $path file path |
3537 | - * @param string $mime file mime type |
|
3538 | 3535 | * @return string|false |
3539 | 3536 | * @author Dmitry (dio) Levashov |
3540 | 3537 | **/ |
@@ -4013,7 +4010,7 @@ discard block |
||
4013 | 4010 | * |
4014 | 4011 | * @param string $command command line |
4015 | 4012 | * @param array $output stdout strings |
4016 | - * @param array $return_var process exit code |
|
4013 | + * @param integer $return_var process exit code |
|
4017 | 4014 | * @param array $error_output stderr strings |
4018 | 4015 | * @return int exit code |
4019 | 4016 | * @author Alexey Sukhotin |
@@ -4225,7 +4222,7 @@ discard block |
||
4225 | 4222 | * @param string $haystack The string being checked. |
4226 | 4223 | * @param string $needle The string to find in haystack. |
4227 | 4224 | * @param int $offset The search offset. If it is not specified, 0 is used. |
4228 | - * @return int|bool |
|
4225 | + * @return integer |
|
4229 | 4226 | * @author Alexey Sukhotin |
4230 | 4227 | **/ |
4231 | 4228 | protected function stripos($haystack , $needle , $offset = 0) { |
@@ -4450,7 +4447,7 @@ discard block |
||
4450 | 4447 | * @param array $files files names list |
4451 | 4448 | * @param string $name archive name |
4452 | 4449 | * @param array $arc archiver options |
4453 | - * @return string|bool |
|
4450 | + * @return string|false |
|
4454 | 4451 | * @author Dmitry (dio) Levashov, |
4455 | 4452 | * @author Alexey Sukhotin |
4456 | 4453 | * @author Naoki Sawada |
@@ -4507,7 +4504,7 @@ discard block |
||
4507 | 4504 | * @param string $dir target dir |
4508 | 4505 | * @param array $files files names list |
4509 | 4506 | * @param string|object $zipPath Zip archive name |
4510 | - * @return void |
|
4507 | + * @return boolean |
|
4511 | 4508 | * @author Naoki Sawada |
4512 | 4509 | */ |
4513 | 4510 | protected static function zipArchiveZip($dir, $files, $zipPath) { |
@@ -4763,7 +4760,7 @@ discard block |
||
4763 | 4760 | * Copy file into another file (only inside one volume) |
4764 | 4761 | * |
4765 | 4762 | * @param string $source source file path |
4766 | - * @param string $target target dir path |
|
4763 | + * @param string $targetDir target dir path |
|
4767 | 4764 | * @param string $name file name |
4768 | 4765 | * @return bool |
4769 | 4766 | * @author Dmitry (dio) Levashov |
@@ -4775,7 +4772,7 @@ discard block |
||
4775 | 4772 | * Return new file path or false. |
4776 | 4773 | * |
4777 | 4774 | * @param string $source source file path |
4778 | - * @param string $target target dir path |
|
4775 | + * @param string $targetDir target dir path |
|
4779 | 4776 | * @param string $name file name |
4780 | 4777 | * @return string|bool |
4781 | 4778 | * @author Dmitry (dio) Levashov |