@@ -1344,7 +1344,7 @@ |
||
1344 | 1344 | * |
1345 | 1345 | * @param string $str |
1346 | 1346 | * @param array $extTable |
1347 | - * @return array |
|
1347 | + * @return string[] |
|
1348 | 1348 | * @author Naoki Sawada |
1349 | 1349 | */ |
1350 | 1350 | protected function parse_data_scheme( $str, $extTable ) { |
@@ -1149,18 +1149,18 @@ discard block |
||
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | /** |
1152 | - * Get remote contents |
|
1153 | - * |
|
1154 | - * @param string $url target url |
|
1155 | - * @param int $timeout timeout (sec) |
|
1156 | - * @param int $redirect_max redirect max count |
|
1157 | - * @param string $ua |
|
1158 | - * @param resource $fp |
|
1159 | - * @return string or bool(false) |
|
1160 | - * @retval string contents |
|
1161 | - * @retval false error |
|
1162 | - * @author Naoki Sawada |
|
1163 | - **/ |
|
1152 | + * Get remote contents |
|
1153 | + * |
|
1154 | + * @param string $url target url |
|
1155 | + * @param int $timeout timeout (sec) |
|
1156 | + * @param int $redirect_max redirect max count |
|
1157 | + * @param string $ua |
|
1158 | + * @param resource $fp |
|
1159 | + * @return string or bool(false) |
|
1160 | + * @retval string contents |
|
1161 | + * @retval false error |
|
1162 | + * @author Naoki Sawada |
|
1163 | + **/ |
|
1164 | 1164 | protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) { |
1165 | 1165 | $method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; |
1166 | 1166 | return $this->$method( $url, $timeout, $redirect_max, $ua, $fp ); |
@@ -2090,12 +2090,12 @@ discard block |
||
2090 | 2090 | } |
2091 | 2091 | |
2092 | 2092 | /** |
2093 | - * Return content URL |
|
2094 | - * |
|
2095 | - * @param array $args command arguments |
|
2096 | - * @return array |
|
2097 | - * @author Naoki Sawada |
|
2098 | - **/ |
|
2093 | + * Return content URL |
|
2094 | + * |
|
2095 | + * @param array $args command arguments |
|
2096 | + * @return array |
|
2097 | + * @author Naoki Sawada |
|
2098 | + **/ |
|
2099 | 2099 | protected function url($args) { |
2100 | 2100 | $target = $args['target']; |
2101 | 2101 | $options = isset($args['options'])? $args['options'] : array(); |
@@ -1241,8 +1241,12 @@ discard block |
||
1241 | 1241 | |
1242 | 1242 | $query = $method.' '.$uri." HTTP/1.0\r\n"; |
1243 | 1243 | $query .= "Host: ".$arr['host']."\r\n"; |
1244 | - if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n"; |
|
1245 | - if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1244 | + if (!empty($ua)) { |
|
1245 | + $query .= "User-Agent: ".$ua."\r\n"; |
|
1246 | + } |
|
1247 | + if (!is_null($getSize)) { |
|
1248 | + $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1249 | + } |
|
1246 | 1250 | |
1247 | 1251 | $query .= $headers; |
1248 | 1252 | |
@@ -1257,7 +1261,9 @@ discard block |
||
1257 | 1261 | $arr['https'].$arr['host'], |
1258 | 1262 | $arr['port'], |
1259 | 1263 | $errno,$errstr,$connect_timeout); |
1260 | - if ($fp) break; |
|
1264 | + if ($fp) { |
|
1265 | + break; |
|
1266 | + } |
|
1261 | 1267 | $connect_try_count++; |
1262 | 1268 | if (connection_aborted()) { |
1263 | 1269 | exit(); |
@@ -1574,7 +1580,9 @@ discard block |
||
1574 | 1580 | $tempDir = ''; |
1575 | 1581 | $test = DIRECTORY_SEPARATOR . microtime(true); |
1576 | 1582 | foreach($testDirs as $testDir) { |
1577 | - if (!$testDir || !is_dir($testDir)) continue; |
|
1583 | + if (!$testDir || !is_dir($testDir)) { |
|
1584 | + continue; |
|
1585 | + } |
|
1578 | 1586 | $testFile = $testDir.$test; |
1579 | 1587 | if (touch($testFile)) { |
1580 | 1588 | unlink($testFile); |
@@ -1810,7 +1818,9 @@ discard block |
||
1810 | 1818 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER); |
1811 | 1819 | $this->uploadDebug = 'Upload error: unable open tmp file'; |
1812 | 1820 | if (! is_uploaded_file($tmpname)) { |
1813 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
|
1821 | + if (@ unlink($tmpname)) { |
|
1822 | + unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
|
1823 | + } |
|
1814 | 1824 | continue; |
1815 | 1825 | } |
1816 | 1826 | break; |
@@ -1824,7 +1834,10 @@ discard block |
||
1824 | 1834 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error()); |
1825 | 1835 | fclose($fp); |
1826 | 1836 | if (! is_uploaded_file($tmpname)) { |
1827 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);; |
|
1837 | + if (@ unlink($tmpname)) { |
|
1838 | + unset($GLOBALS['elFinderTempFiles'][$tmpname]); |
|
1839 | + } |
|
1840 | + ; |
|
1828 | 1841 | continue; |
1829 | 1842 | } |
1830 | 1843 | break; |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | const ERROR_INV_PARAMS = 'errCmdParams'; |
204 | 204 | const ERROR_OPEN = 'errOpen'; |
205 | 205 | const ERROR_DIR_NOT_FOUND = 'errFolderNotFound'; |
206 | - const ERROR_FILE_NOT_FOUND = 'errFileNotFound'; // 'File not found.' |
|
206 | + const ERROR_FILE_NOT_FOUND = 'errFileNotFound'; // 'File not found.' |
|
207 | 207 | const ERROR_TRGDIR_NOT_FOUND = 'errTrgFolderNotFound'; // 'Target folder "$1" not found.' |
208 | 208 | const ERROR_NOT_DIR = 'errNotFolder'; |
209 | 209 | const ERROR_NOT_FILE = 'errNotFile'; |
210 | 210 | const ERROR_PERM_DENIED = 'errPerm'; |
211 | - const ERROR_LOCKED = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.' |
|
212 | - const ERROR_EXISTS = 'errExists'; // 'File named "$1" already exists.' |
|
213 | - const ERROR_INVALID_NAME = 'errInvName'; // 'Invalid file name.' |
|
211 | + const ERROR_LOCKED = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.' |
|
212 | + const ERROR_EXISTS = 'errExists'; // 'File named "$1" already exists.' |
|
213 | + const ERROR_INVALID_NAME = 'errInvName'; // 'Invalid file name.' |
|
214 | 214 | const ERROR_MKDIR = 'errMkdir'; |
215 | 215 | const ERROR_MKFILE = 'errMkfile'; |
216 | 216 | const ERROR_RENAME = 'errRename'; |
@@ -219,20 +219,20 @@ discard block |
||
219 | 219 | const ERROR_COPY_FROM = 'errCopyFrom'; |
220 | 220 | const ERROR_COPY_TO = 'errCopyTo'; |
221 | 221 | const ERROR_COPY_ITSELF = 'errCopyInItself'; |
222 | - const ERROR_REPLACE = 'errReplace'; // 'Unable to replace "$1".' |
|
223 | - const ERROR_RM = 'errRm'; // 'Unable to remove "$1".' |
|
224 | - const ERROR_RM_SRC = 'errRmSrc'; // 'Unable remove source file(s)' |
|
225 | - const ERROR_MKOUTLINK = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.' |
|
226 | - const ERROR_UPLOAD = 'errUpload'; // 'Upload error.' |
|
227 | - const ERROR_UPLOAD_FILE = 'errUploadFile'; // 'Unable to upload "$1".' |
|
228 | - const ERROR_UPLOAD_NO_FILES = 'errUploadNoFiles'; // 'No files found for upload.' |
|
229 | - const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.' |
|
230 | - const ERROR_UPLOAD_FILE_SIZE = 'errUploadFileSize'; // 'File exceeds maximum allowed size.' |
|
231 | - const ERROR_UPLOAD_FILE_MIME = 'errUploadMime'; // 'File type not allowed.' |
|
232 | - const ERROR_UPLOAD_TRANSFER = 'errUploadTransfer'; // '"$1" transfer error.' |
|
233 | - const ERROR_UPLOAD_TEMP = 'errUploadTemp'; // 'Unable to make temporary file for upload.' |
|
222 | + const ERROR_REPLACE = 'errReplace'; // 'Unable to replace "$1".' |
|
223 | + const ERROR_RM = 'errRm'; // 'Unable to remove "$1".' |
|
224 | + const ERROR_RM_SRC = 'errRmSrc'; // 'Unable remove source file(s)' |
|
225 | + const ERROR_MKOUTLINK = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.' |
|
226 | + const ERROR_UPLOAD = 'errUpload'; // 'Upload error.' |
|
227 | + const ERROR_UPLOAD_FILE = 'errUploadFile'; // 'Unable to upload "$1".' |
|
228 | + const ERROR_UPLOAD_NO_FILES = 'errUploadNoFiles'; // 'No files found for upload.' |
|
229 | + const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.' |
|
230 | + const ERROR_UPLOAD_FILE_SIZE = 'errUploadFileSize'; // 'File exceeds maximum allowed size.' |
|
231 | + const ERROR_UPLOAD_FILE_MIME = 'errUploadMime'; // 'File type not allowed.' |
|
232 | + const ERROR_UPLOAD_TRANSFER = 'errUploadTransfer'; // '"$1" transfer error.' |
|
233 | + const ERROR_UPLOAD_TEMP = 'errUploadTemp'; // 'Unable to make temporary file for upload.' |
|
234 | 234 | // const ERROR_ACCESS_DENIED = 'errAccess'; |
235 | - const ERROR_NOT_REPLACE = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type. |
|
235 | + const ERROR_NOT_REPLACE = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type. |
|
236 | 236 | const ERROR_SAVE = 'errSave'; |
237 | 237 | const ERROR_EXTRACT = 'errExtract'; |
238 | 238 | const ERROR_ARCHIVE = 'errArchive'; |
@@ -247,14 +247,14 @@ discard block |
||
247 | 247 | const ERROR_NETMOUNT = 'errNetMount'; |
248 | 248 | const ERROR_NETUNMOUNT = 'errNetUnMount'; |
249 | 249 | const ERROR_NETMOUNT_NO_DRIVER = 'errNetMountNoDriver'; |
250 | - const ERROR_NETMOUNT_FAILED = 'errNetMountFailed'; |
|
250 | + const ERROR_NETMOUNT_FAILED = 'errNetMountFailed'; |
|
251 | 251 | |
252 | - const ERROR_SESSION_EXPIRES = 'errSessionExpires'; |
|
252 | + const ERROR_SESSION_EXPIRES = 'errSessionExpires'; |
|
253 | 253 | |
254 | 254 | const ERROR_CREATING_TEMP_DIR = 'errCreatingTempDir'; |
255 | 255 | const ERROR_FTP_DOWNLOAD_FILE = 'errFtpDownloadFile'; |
256 | - const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile'; |
|
257 | - const ERROR_FTP_MKDIR = 'errFtpMkdir'; |
|
256 | + const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile'; |
|
257 | + const ERROR_FTP_MKDIR = 'errFtpMkdir'; |
|
258 | 258 | const ERROR_ARCHIVE_EXEC = 'errArchiveExec'; |
259 | 259 | const ERROR_EXTRACT_EXEC = 'errExtractExec'; |
260 | 260 | |
@@ -281,17 +281,17 @@ discard block |
||
281 | 281 | |
282 | 282 | $this->time = $this->utime(); |
283 | 283 | $this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false); |
284 | - $this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true; |
|
284 | + $this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true; |
|
285 | 285 | $this->sessionUseCmds = array_flip($sessionUseCmds); |
286 | 286 | $this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0); |
287 | 287 | $this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : ''); |
288 | - $this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes'; |
|
288 | + $this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes'; |
|
289 | 289 | $this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : ''); |
290 | 290 | self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches'; |
291 | 291 | |
292 | 292 | // check session cache |
293 | 293 | $_optsMD5 = md5(json_encode($opts['roots'])); |
294 | - if (! isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) { |
|
294 | + if (!isset($_SESSION[self::$sessionCacheKey]) || $_SESSION[self::$sessionCacheKey]['_optsMD5'] !== $_optsMD5) { |
|
295 | 295 | $_SESSION[self::$sessionCacheKey] = array( |
296 | 296 | '_optsMD5' => $_optsMD5 |
297 | 297 | ); |
@@ -310,20 +310,20 @@ discard block |
||
310 | 310 | $_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : ''; |
311 | 311 | foreach ($opts['bind'] as $cmd => $handlers) { |
312 | 312 | $doRegist = (strpos($cmd, '*') !== false); |
313 | - if (! $doRegist) { |
|
313 | + if (!$doRegist) { |
|
314 | 314 | $_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);'); |
315 | 315 | $doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd)))); |
316 | 316 | } |
317 | 317 | if ($doRegist) { |
318 | - if (! is_array($handlers) || is_object($handlers[0])) { |
|
318 | + if (!is_array($handlers) || is_object($handlers[0])) { |
|
319 | 319 | $handlers = array($handlers); |
320 | 320 | } |
321 | - foreach($handlers as $handler) { |
|
321 | + foreach ($handlers as $handler) { |
|
322 | 322 | if ($handler) { |
323 | 323 | if (is_string($handler) && strpos($handler, '.')) { |
324 | 324 | list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, ''); |
325 | 325 | if (strcasecmp($_domain, 'plugin') === 0) { |
326 | - if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array()) |
|
326 | + if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array()) |
|
327 | 327 | and method_exists($plugin, $_method)) { |
328 | 328 | $this->bind($cmd, array($plugin, $_method)); |
329 | 329 | } |
@@ -410,13 +410,13 @@ discard block |
||
410 | 410 | public function bind($cmd, $handler) { |
411 | 411 | $allCmds = array_keys($this->commands); |
412 | 412 | $cmds = array(); |
413 | - foreach(explode(' ', $cmd) as $_cmd) { |
|
413 | + foreach (explode(' ', $cmd) as $_cmd) { |
|
414 | 414 | if ($_cmd !== '') { |
415 | 415 | if ($all = strpos($_cmd, '*') !== false) { |
416 | 416 | list(, $sub) = array_pad(explode('.', $_cmd), 2, ''); |
417 | 417 | if ($sub) { |
418 | 418 | $sub = str_replace('\'', '\\\'', $sub); |
419 | - $addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\'' . $sub . '\');'); |
|
419 | + $addSub = create_function('$cmd', 'return $cmd . \'.\' . trim(\''.$sub.'\');'); |
|
420 | 420 | $cmds = array_merge($cmds, array_map($addSub, $allCmds)); |
421 | 421 | } else { |
422 | 422 | $cmds = array_merge($cmds, $allCmds); |
@@ -496,16 +496,16 @@ discard block |
||
496 | 496 | |
497 | 497 | private function session_expires() { |
498 | 498 | |
499 | - if (!isset($_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'])) { |
|
500 | - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time(); |
|
499 | + if (!isset($_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'])) { |
|
500 | + $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time(); |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
504 | - if ( ($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] > $this->timeout) ) { |
|
504 | + if (($this->timeout > 0) && (time() - $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] > $this->timeout)) { |
|
505 | 505 | return true; |
506 | 506 | } |
507 | 507 | |
508 | - $_SESSION[self::$sessionCacheKey . ':LAST_ACTIVITY'] = time(); |
|
508 | + $_SESSION[self::$sessionCacheKey.':LAST_ACTIVITY'] = time(); |
|
509 | 509 | return false; |
510 | 510 | } |
511 | 511 | |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | } |
539 | 539 | |
540 | 540 | // call pre handlers for this command |
541 | - $args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd])? false : $this->sessionCloseEarlier; |
|
541 | + $args['sessionCloseEarlier'] = isset($this->sessionUseCmds[$cmd]) ? false : $this->sessionCloseEarlier; |
|
542 | 542 | if (!empty($this->listeners[$cmd.'.pre'])) { |
543 | - $volume = isset($args['target'])? $this->volume($args['target']) : false; |
|
543 | + $volume = isset($args['target']) ? $this->volume($args['target']) : false; |
|
544 | 544 | foreach ($this->listeners[$cmd.'.pre'] as $handler) { |
545 | 545 | call_user_func_array($handler, array($cmd, &$args, $this, $volume)); |
546 | 546 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | // call handlers for this command |
563 | 563 | if (!empty($this->listeners[$cmd])) { |
564 | 564 | foreach ($this->listeners[$cmd] as $handler) { |
565 | - if (call_user_func_array($handler,array($cmd,&$result,$args,$this))) { |
|
565 | + if (call_user_func_array($handler, array($cmd, &$result, $args, $this))) { |
|
566 | 566 | // handler return true to force sync client after command completed |
567 | 567 | $result['sync'] = true; |
568 | 568 | } |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * @return string |
622 | 622 | * @author Dmitry (dio) Levashov |
623 | 623 | **/ |
624 | - public function realpath($hash) { |
|
624 | + public function realpath($hash) { |
|
625 | 625 | if (($volume = $this->volume($hash)) == false) { |
626 | 626 | return false; |
627 | 627 | } |
@@ -677,11 +677,11 @@ discard block |
||
677 | 677 | */ |
678 | 678 | protected function getPluginInstance($name, $opts = array()) { |
679 | 679 | $key = strtolower($name); |
680 | - if (! isset($this->plugins[$key])) { |
|
681 | - $p_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'plugin.php'; |
|
680 | + if (!isset($this->plugins[$key])) { |
|
681 | + $p_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.'plugin.php'; |
|
682 | 682 | if (is_file($p_file)) { |
683 | 683 | require_once $p_file; |
684 | - $class = 'elFinderPlugin' . $name; |
|
684 | + $class = 'elFinderPlugin'.$name; |
|
685 | 685 | $this->plugins[$key] = new $class($opts); |
686 | 686 | } else { |
687 | 687 | $this->plugins[$key] = false; |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | |
774 | 774 | $netVolumes = $this->getNetVolumes(); |
775 | 775 | if ($volume->mount($options)) { |
776 | - if (! $key = @ $volume->netMountKey) { |
|
777 | - $key = md5($protocol . '-' . join('-', $options)); |
|
776 | + if (!$key = @ $volume->netMountKey) { |
|
777 | + $key = md5($protocol.'-'.join('-', $options)); |
|
778 | 778 | } |
779 | 779 | $options['driver'] = $driver; |
780 | 780 | $options['netkey'] = $key; |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | $disp = 'attachment'; |
977 | 977 | $mime = $file['mime']; |
978 | 978 | } else { |
979 | - $disp = preg_match('/^(image|text)/i', $file['mime']) || $file['mime'] == 'application/x-shockwave-flash' |
|
979 | + $disp = preg_match('/^(image|text)/i', $file['mime']) || $file['mime'] == 'application/x-shockwave-flash' |
|
980 | 980 | ? 'inline' |
981 | 981 | : 'attachment'; |
982 | 982 | $mime = $file['mime']; |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | $name = $args['name']; |
1089 | 1089 | |
1090 | 1090 | if (($volume = $this->volume($target)) == false |
1091 | - || ($rm = $volume->file($target)) == false) { |
|
1091 | + || ($rm = $volume->file($target)) == false) { |
|
1092 | 1092 | return array('error' => $this->error(self::ERROR_RENAME, '#'.$target, self::ERROR_FILE_NOT_FOUND)); |
1093 | 1093 | } |
1094 | 1094 | $rm['realpath'] = $volume->realpath($target); |
@@ -1166,9 +1166,9 @@ discard block |
||
1166 | 1166 | * @retval false error |
1167 | 1167 | * @author Naoki Sawada |
1168 | 1168 | **/ |
1169 | - protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) { |
|
1170 | - $method = (function_exists('curl_exec') && !ini_get('safe_mode'))? 'curl_get_contents' : 'fsock_get_contents'; |
|
1171 | - return $this->$method( $url, $timeout, $redirect_max, $ua, $fp ); |
|
1169 | + protected function get_remote_contents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null) { |
|
1170 | + $method = (function_exists('curl_exec') && !ini_get('safe_mode')) ? 'curl_get_contents' : 'fsock_get_contents'; |
|
1171 | + return $this->$method($url, $timeout, $redirect_max, $ua, $fp); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | /** |
@@ -1184,26 +1184,26 @@ discard block |
||
1184 | 1184 | * @retval false error |
1185 | 1185 | * @author Naoki Sawada |
1186 | 1186 | **/ |
1187 | - protected function curl_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ){ |
|
1187 | + protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
1188 | 1188 | $ch = curl_init(); |
1189 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
1190 | - curl_setopt( $ch, CURLOPT_HEADER, false ); |
|
1189 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1190 | + curl_setopt($ch, CURLOPT_HEADER, false); |
|
1191 | 1191 | if ($outfp) { |
1192 | - curl_setopt( $ch, CURLOPT_FILE, $outfp ); |
|
1192 | + curl_setopt($ch, CURLOPT_FILE, $outfp); |
|
1193 | 1193 | } else { |
1194 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
1195 | - curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true ); |
|
1196 | - } |
|
1197 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 ); |
|
1198 | - curl_setopt( $ch, CURLOPT_LOW_SPEED_TIME, $timeout ); |
|
1199 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); |
|
1200 | - curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); |
|
1201 | - curl_setopt( $ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
1202 | - curl_setopt( $ch, CURLOPT_USERAGENT, $ua); |
|
1203 | - $result = curl_exec( $ch ); |
|
1194 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
1195 | + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); |
|
1196 | + } |
|
1197 | + curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1); |
|
1198 | + curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout); |
|
1199 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
1200 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
1201 | + curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max); |
|
1202 | + curl_setopt($ch, CURLOPT_USERAGENT, $ua); |
|
1203 | + $result = curl_exec($ch); |
|
1204 | 1204 | $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
1205 | - curl_close( $ch ); |
|
1206 | - return $outfp? $outfp : $result; |
|
1205 | + curl_close($ch); |
|
1206 | + return $outfp ? $outfp : $result; |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | /** |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | * @retval false error |
1220 | 1220 | * @author Naoki Sawada |
1221 | 1221 | */ |
1222 | - protected function fsock_get_contents( &$url, $timeout, $redirect_max, $ua, $outfp ) { |
|
1222 | + protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp) { |
|
1223 | 1223 | |
1224 | 1224 | $connect_timeout = 3; |
1225 | 1225 | $connect_try = 3; |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | $headers = ''; |
1231 | 1231 | |
1232 | 1232 | $arr = parse_url($url); |
1233 | - if (!$arr){ |
|
1233 | + if (!$arr) { |
|
1234 | 1234 | // Bad request |
1235 | 1235 | return false; |
1236 | 1236 | } |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | // query |
1239 | 1239 | $arr['query'] = isset($arr['query']) ? '?'.$arr['query'] : ''; |
1240 | 1240 | // port |
1241 | - $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https'])? 443 : 80); |
|
1241 | + $arr['port'] = isset($arr['port']) ? $arr['port'] : (!empty($arr['https']) ? 443 : 80); |
|
1242 | 1242 | |
1243 | 1243 | $url_base = $arr['scheme'].'://'.$arr['host'].':'.$arr['port']; |
1244 | 1244 | $url_path = isset($arr['path']) ? $arr['path'] : '/'; |
@@ -1247,21 +1247,21 @@ discard block |
||
1247 | 1247 | $query = $method.' '.$uri." HTTP/1.0\r\n"; |
1248 | 1248 | $query .= "Host: ".$arr['host']."\r\n"; |
1249 | 1249 | if (!empty($ua)) $query .= "User-Agent: ".$ua."\r\n"; |
1250 | - if (!is_null($getSize)) $query .= 'Range: bytes=0-' . ($getSize - 1) . "\r\n"; |
|
1250 | + if (!is_null($getSize)) $query .= 'Range: bytes=0-'.($getSize - 1)."\r\n"; |
|
1251 | 1251 | |
1252 | 1252 | $query .= $headers; |
1253 | 1253 | |
1254 | 1254 | $query .= "\r\n"; |
1255 | 1255 | |
1256 | 1256 | $fp = $connect_try_count = 0; |
1257 | - while( !$fp && $connect_try_count < $connect_try ) { |
|
1257 | + while (!$fp && $connect_try_count < $connect_try) { |
|
1258 | 1258 | |
1259 | 1259 | $errno = 0; |
1260 | 1260 | $errstr = ""; |
1261 | 1261 | $fp = @ fsockopen( |
1262 | 1262 | $arr['https'].$arr['host'], |
1263 | 1263 | $arr['port'], |
1264 | - $errno,$errstr,$connect_timeout); |
|
1264 | + $errno, $errstr, $connect_timeout); |
|
1265 | 1265 | if ($fp) break; |
1266 | 1266 | $connect_try_count++; |
1267 | 1267 | if (connection_aborted()) { |
@@ -1286,13 +1286,13 @@ discard block |
||
1286 | 1286 | |
1287 | 1287 | $_response = ''; |
1288 | 1288 | $header = ''; |
1289 | - while($_response !== "\r\n"){ |
|
1289 | + while ($_response !== "\r\n") { |
|
1290 | 1290 | $_response = fgets($fp, $readsize); |
1291 | 1291 | $header .= $_response; |
1292 | 1292 | }; |
1293 | 1293 | |
1294 | - $rccd = array_pad(explode(' ',$header,3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
1295 | - $rc = (int)$rccd[1]; |
|
1294 | + $rccd = array_pad(explode(' ', $header, 3), 3, ''); // array('HTTP/1.1','200','OK\r\n...') |
|
1295 | + $rc = (int) $rccd[1]; |
|
1296 | 1296 | |
1297 | 1297 | // Redirect |
1298 | 1298 | switch ($rc) { |
@@ -1301,19 +1301,19 @@ discard block |
||
1301 | 1301 | case 302: // Moved Temporarily |
1302 | 1302 | case 301: // Moved Permanently |
1303 | 1303 | $matches = array(); |
1304 | - if (preg_match('/^Location: (.+?)(#.+)?$/im',$header,$matches) && --$redirect_max > 0) { |
|
1304 | + if (preg_match('/^Location: (.+?)(#.+)?$/im', $header, $matches) && --$redirect_max > 0) { |
|
1305 | 1305 | $url = trim($matches[1]); |
1306 | - $hash = isset($matches[2])? trim($matches[2]) : ''; |
|
1307 | - if (!preg_match('/^https?:\//',$url)) { // no scheme |
|
1306 | + $hash = isset($matches[2]) ? trim($matches[2]) : ''; |
|
1307 | + if (!preg_match('/^https?:\//', $url)) { // no scheme |
|
1308 | 1308 | if ($url{0} != '/') { // Relative path |
1309 | 1309 | // to Absolute path |
1310 | - $url = substr($url_path,0,strrpos($url_path,'/')).'/'.$url; |
|
1310 | + $url = substr($url_path, 0, strrpos($url_path, '/')).'/'.$url; |
|
1311 | 1311 | } |
1312 | 1312 | // add sheme,host |
1313 | 1313 | $url = $url_base.$url; |
1314 | 1314 | } |
1315 | 1315 | fclose($fp); |
1316 | - return $this->fsock_get_contents( $url, $timeout, $redirect_max, $ua, $outfp ); |
|
1316 | + return $this->fsock_get_contents($url, $timeout, $redirect_max, $ua, $outfp); |
|
1317 | 1317 | } |
1318 | 1318 | } |
1319 | 1319 | |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | $outfp = fopen('php://temp', 'rwb'); |
1323 | 1323 | $body = true; |
1324 | 1324 | } |
1325 | - while(fwrite($outfp, fread($fp, $readsize))) { |
|
1325 | + while (fwrite($outfp, fread($fp, $readsize))) { |
|
1326 | 1326 | if ($timeout) { |
1327 | 1327 | $_status = socket_get_status($fp); |
1328 | 1328 | if ($_status['timed_out']) { |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | |
1342 | 1342 | fclose($fp); |
1343 | 1343 | |
1344 | - return $outfp? $outfp : $body; // Data |
|
1344 | + return $outfp ? $outfp : $body; // Data |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | /** |
@@ -1352,13 +1352,13 @@ discard block |
||
1352 | 1352 | * @return array |
1353 | 1353 | * @author Naoki Sawada |
1354 | 1354 | */ |
1355 | - protected function parse_data_scheme( $str, $extTable ) { |
|
1355 | + protected function parse_data_scheme($str, $extTable) { |
|
1356 | 1356 | $data = $name = ''; |
1357 | 1357 | if ($fp = fopen('data://'.substr($str, 5), 'rb')) { |
1358 | 1358 | if ($data = stream_get_contents($fp)) { |
1359 | 1359 | $meta = stream_get_meta_data($fp); |
1360 | - $ext = isset($extTable[$meta['mediatype']])? '.' . $extTable[$meta['mediatype']] : ''; |
|
1361 | - $name = substr(md5($data), 0, 8) . $ext; |
|
1360 | + $ext = isset($extTable[$meta['mediatype']]) ? '.'.$extTable[$meta['mediatype']] : ''; |
|
1361 | + $name = substr(md5($data), 0, 8).$ext; |
|
1362 | 1362 | } |
1363 | 1363 | fclose($fp); |
1364 | 1364 | } |
@@ -1422,7 +1422,7 @@ discard block |
||
1422 | 1422 | } |
1423 | 1423 | } |
1424 | 1424 | |
1425 | - return ($mime && isset($extTable[$mime]))? ('.' . $extTable[$mime]) : ''; |
|
1425 | + return ($mime && isset($extTable[$mime])) ? ('.'.$extTable[$mime]) : ''; |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | /** |
@@ -1438,26 +1438,26 @@ discard block |
||
1438 | 1438 | private function checkChunkedFile($tmpname, $chunk, $cid, $tempDir, $volume = null) { |
1439 | 1439 | if (preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m)) { |
1440 | 1440 | $fname = $m[1]; |
1441 | - $encname = md5($cid . '_' . $fname); |
|
1442 | - $base = $tempDir . DIRECTORY_SEPARATOR . 'ELF' . $encname; |
|
1441 | + $encname = md5($cid.'_'.$fname); |
|
1442 | + $base = $tempDir.DIRECTORY_SEPARATOR.'ELF'.$encname; |
|
1443 | 1443 | $clast = intval($m[3]); |
1444 | 1444 | if (is_null($tmpname)) { |
1445 | 1445 | ignore_user_abort(true); |
1446 | 1446 | sleep(10); // wait 10 sec |
1447 | 1447 | // chunked file upload fail |
1448 | - foreach(glob($base . '*') as $cf) { |
|
1448 | + foreach (glob($base.'*') as $cf) { |
|
1449 | 1449 | @unlink($cf); |
1450 | 1450 | } |
1451 | 1451 | ignore_user_abort(false); |
1452 | 1452 | return; |
1453 | 1453 | } |
1454 | 1454 | |
1455 | - $range = isset($_POST['range'])? trim($_POST['range']) : ''; |
|
1455 | + $range = isset($_POST['range']) ? trim($_POST['range']) : ''; |
|
1456 | 1456 | if ($range && preg_match('/^(\d+),(\d+),(\d+)$/', $range, $ranges)) { |
1457 | 1457 | $start = $ranges[1]; |
1458 | 1458 | $len = $ranges[2]; |
1459 | 1459 | $size = $ranges[3]; |
1460 | - $tmp = $base . '.part'; |
|
1460 | + $tmp = $base.'.part'; |
|
1461 | 1461 | $csize = filesize($tmpname); |
1462 | 1462 | |
1463 | 1463 | $tmpExists = is_file($tmp); |
@@ -1482,7 +1482,7 @@ discard block |
||
1482 | 1482 | } else { |
1483 | 1483 | // wait until makeing temp file (for anothor session) |
1484 | 1484 | $cnt = 100; // Time limit 10 sec |
1485 | - while(!is_file($base) && --$cnt) { |
|
1485 | + while (!is_file($base) && --$cnt) { |
|
1486 | 1486 | usleep(100000); // wait 100ms |
1487 | 1487 | } |
1488 | 1488 | if (!$cnt) { |
@@ -1517,13 +1517,13 @@ discard block |
||
1517 | 1517 | } |
1518 | 1518 | } else { |
1519 | 1519 | // old way |
1520 | - $part = $base . $m[2]; |
|
1520 | + $part = $base.$m[2]; |
|
1521 | 1521 | if (move_uploaded_file($tmpname, $part)) { |
1522 | 1522 | @chmod($part, 0600); |
1523 | - if ($clast < count(glob($base . '*'))) { |
|
1523 | + if ($clast < count(glob($base.'*'))) { |
|
1524 | 1524 | $parts = array(); |
1525 | 1525 | for ($i = 0; $i <= $clast; $i++) { |
1526 | - $name = $base . '.' . $i . '_' . $clast; |
|
1526 | + $name = $base.'.'.$i.'_'.$clast; |
|
1527 | 1527 | if (is_readable($name)) { |
1528 | 1528 | $parts[] = $name; |
1529 | 1529 | } else { |
@@ -1536,7 +1536,7 @@ discard block |
||
1536 | 1536 | touch($base); |
1537 | 1537 | if ($resfile = tempnam($tempDir, 'ELF')) { |
1538 | 1538 | $target = fopen($resfile, 'wb'); |
1539 | - foreach($parts as $f) { |
|
1539 | + foreach ($parts as $f) { |
|
1540 | 1540 | $fp = fopen($f, 'rb'); |
1541 | 1541 | while (!feof($fp)) { |
1542 | 1542 | fwrite($target, fread($fp, 8192)); |
@@ -1577,15 +1577,15 @@ discard block |
||
1577 | 1577 | $testDirs[] = rtrim(realpath($volumeTempPath), DIRECTORY_SEPARATOR); |
1578 | 1578 | } |
1579 | 1579 | $tempDir = ''; |
1580 | - $test = DIRECTORY_SEPARATOR . microtime(true); |
|
1581 | - foreach($testDirs as $testDir) { |
|
1580 | + $test = DIRECTORY_SEPARATOR.microtime(true); |
|
1581 | + foreach ($testDirs as $testDir) { |
|
1582 | 1582 | if (!$testDir || !is_dir($testDir)) continue; |
1583 | 1583 | $testFile = $testDir.$test; |
1584 | 1584 | if (touch($testFile)) { |
1585 | 1585 | unlink($testFile); |
1586 | 1586 | $tempDir = $testDir; |
1587 | 1587 | $gc = time() - 3600; |
1588 | - foreach(glob($tempDir . '/ELF*') as $cf) { |
|
1588 | + foreach (glob($tempDir.'/ELF*') as $cf) { |
|
1589 | 1589 | if (filemtime($cf) < $gc) { |
1590 | 1590 | @unlink($cf); |
1591 | 1591 | } |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | **/ |
1606 | 1606 | protected function chmod($args) { |
1607 | 1607 | $targets = $args['targets']; |
1608 | - $mode = intval((string)$args['mode'], 8); |
|
1608 | + $mode = intval((string) $args['mode'], 8); |
|
1609 | 1609 | |
1610 | 1610 | if (!is_array($targets)) { |
1611 | 1611 | $targets = array($targets); |
@@ -1620,10 +1620,10 @@ discard block |
||
1620 | 1620 | |
1621 | 1621 | $files = array(); |
1622 | 1622 | $errors = array(); |
1623 | - foreach($targets as $target) { |
|
1623 | + foreach ($targets as $target) { |
|
1624 | 1624 | $file = $volume->chmod($target, $mode); |
1625 | 1625 | if ($file) { |
1626 | - $files = array_merge($files, is_array($file)? $file : array($file)); |
|
1626 | + $files = array_merge($files, is_array($file) ? $file : array($file)); |
|
1627 | 1627 | } else { |
1628 | 1628 | $errors = array_merge($errors, $volume->error()); |
1629 | 1629 | } |
@@ -1655,15 +1655,15 @@ discard block |
||
1655 | 1655 | $files = isset($args['FILES']['upload']) && is_array($args['FILES']['upload']) ? $args['FILES']['upload'] : array(); |
1656 | 1656 | $header = empty($args['html']) ? array() : array('header' => 'Content-Type: text/html; charset=utf-8'); |
1657 | 1657 | $result = array_merge(array('added' => array()), $header); |
1658 | - $paths = $args['upload_path']? $args['upload_path'] : array(); |
|
1659 | - $chunk = $args['chunk']? $args['chunk'] : ''; |
|
1660 | - $cid = $args['cid']? (int)$args['cid'] : ''; |
|
1658 | + $paths = $args['upload_path'] ? $args['upload_path'] : array(); |
|
1659 | + $chunk = $args['chunk'] ? $args['chunk'] : ''; |
|
1660 | + $cid = $args['cid'] ? (int) $args['cid'] : ''; |
|
1661 | 1661 | |
1662 | - $renames= array(); |
|
1662 | + $renames = array(); |
|
1663 | 1663 | $suffix = '~'; |
1664 | 1664 | if ($args['renames'] && is_array($args['renames'])) { |
1665 | 1665 | $renames = array_flip($args['renames']); |
1666 | - if (is_string($args['suffix']) && ! preg_match($ngReg, $args['suffix'])) { |
|
1666 | + if (is_string($args['suffix']) && !preg_match($ngReg, $args['suffix'])) { |
|
1667 | 1667 | $suffix = $args['suffix']; |
1668 | 1668 | } |
1669 | 1669 | } |
@@ -1695,14 +1695,14 @@ discard block |
||
1695 | 1695 | if (empty($files)) { |
1696 | 1696 | if (!$args['upload'] && $args['name'] && is_array($args['name'])) { |
1697 | 1697 | $result['name'] = array(); |
1698 | - foreach($args['name'] as $_i => $_name) { |
|
1698 | + foreach ($args['name'] as $_i => $_name) { |
|
1699 | 1699 | $result['name'][$_i] = preg_replace($ngReg, '_', $_name); |
1700 | 1700 | } |
1701 | 1701 | return $result; |
1702 | 1702 | } |
1703 | 1703 | if (isset($args['upload']) && is_array($args['upload']) && ($tempDir = $this->getTempDir($volume->getTempPath()))) { |
1704 | 1704 | $names = array(); |
1705 | - foreach($args['upload'] as $i => $url) { |
|
1705 | + foreach ($args['upload'] as $i => $url) { |
|
1706 | 1706 | // check chunked file upload commit |
1707 | 1707 | if ($args['chunk']) { |
1708 | 1708 | if ($url === 'chunkfail' && $args['mimes'] === 'chunkfail') { |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | } |
1713 | 1713 | return $result; |
1714 | 1714 | } else { |
1715 | - $tmpfname = $tempDir . '/' . $args['chunk']; |
|
1715 | + $tmpfname = $tempDir.'/'.$args['chunk']; |
|
1716 | 1716 | $files['tmp_name'][$i] = $tmpfname; |
1717 | 1717 | $files['name'][$i] = $url; |
1718 | 1718 | $files['error'][$i] = 0; |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | } |
1722 | 1722 | } |
1723 | 1723 | |
1724 | - $tmpfname = $tempDir . DIRECTORY_SEPARATOR . 'ELF_FATCH_' . md5($url.microtime(true)); |
|
1724 | + $tmpfname = $tempDir.DIRECTORY_SEPARATOR.'ELF_FATCH_'.md5($url.microtime(true)); |
|
1725 | 1725 | |
1726 | 1726 | $_name = ''; |
1727 | 1727 | // check is data: |
@@ -1757,8 +1757,8 @@ discard block |
||
1757 | 1757 | list($_a, $_b) = array_pad(explode('.', $_name, 2), 2, ''); |
1758 | 1758 | if ($_b === '') { |
1759 | 1759 | if ($_ext) { |
1760 | - rename($tmpfname, $tmpfname . $_ext); |
|
1761 | - $tmpfname = $tmpfname . $_ext; |
|
1760 | + rename($tmpfname, $tmpfname.$_ext); |
|
1761 | + $tmpfname = $tmpfname.$_ext; |
|
1762 | 1762 | } |
1763 | 1763 | $_b = $this->detectFileExtension($tmpfname); |
1764 | 1764 | $_name = $_a.$_b; |
@@ -1793,7 +1793,7 @@ discard block |
||
1793 | 1793 | } |
1794 | 1794 | |
1795 | 1795 | $tmpname = $files['tmp_name'][$i]; |
1796 | - $path = ($paths && !empty($paths[$i]))? $paths[$i] : ''; |
|
1796 | + $path = ($paths && !empty($paths[$i])) ? $paths[$i] : ''; |
|
1797 | 1797 | if ($name === 'blob') { |
1798 | 1798 | if ($chunk) { |
1799 | 1799 | if ($tempDir = $this->getTempDir($volume->getTempPath())) { |
@@ -1803,7 +1803,7 @@ discard block |
||
1803 | 1803 | preg_match('/^(.+)(\.\d+_(\d+))\.part$/s', $chunk, $m); |
1804 | 1804 | $result['error'] = $this->error(self::ERROR_UPLOAD_FILE, $m[1], $tmpname); |
1805 | 1805 | $result['_chunkfailure'] = true; |
1806 | - $this->uploadDebug = 'Upload error: ' . $tmpname; |
|
1806 | + $this->uploadDebug = 'Upload error: '.$tmpname; |
|
1807 | 1807 | } else if ($name) { |
1808 | 1808 | $result['_chunkmerged'] = basename($tmpname); |
1809 | 1809 | $result['_name'] = $name; |
@@ -1817,14 +1817,14 @@ discard block |
||
1817 | 1817 | } else { |
1818 | 1818 | // for form clipboard with Google Chrome |
1819 | 1819 | $type = $files['type'][$i]; |
1820 | - $ext = isset($extTable[$type])? '.' . $extTable[$type] : ''; |
|
1821 | - $name = substr(md5(basename($tmpname)), 0, 8) . $ext; |
|
1820 | + $ext = isset($extTable[$type]) ? '.'.$extTable[$type] : ''; |
|
1821 | + $name = substr(md5(basename($tmpname)), 0, 8).$ext; |
|
1822 | 1822 | } |
1823 | 1823 | } |
1824 | 1824 | |
1825 | 1825 | // do hook function 'upload.presave' |
1826 | - if (! empty($this->listeners['upload.presave'])) { |
|
1827 | - foreach($this->listeners['upload.presave'] as $handler) { |
|
1826 | + if (!empty($this->listeners['upload.presave'])) { |
|
1827 | + foreach ($this->listeners['upload.presave'] as $handler) { |
|
1828 | 1828 | call_user_func_array($handler, array(&$path, &$name, $tmpname, $this, $volume)); |
1829 | 1829 | } |
1830 | 1830 | } |
@@ -1832,7 +1832,7 @@ discard block |
||
1832 | 1832 | if (($fp = fopen($tmpname, 'rb')) == false) { |
1833 | 1833 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, self::ERROR_UPLOAD_TRANSFER); |
1834 | 1834 | $this->uploadDebug = 'Upload error: unable open tmp file'; |
1835 | - if (! is_uploaded_file($tmpname)) { |
|
1835 | + if (!is_uploaded_file($tmpname)) { |
|
1836 | 1836 | if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpfname]); |
1837 | 1837 | continue; |
1838 | 1838 | } |
@@ -1854,18 +1854,18 @@ discard block |
||
1854 | 1854 | } |
1855 | 1855 | } |
1856 | 1856 | } |
1857 | - if (! $_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
1857 | + if (!$_target || ($file = $volume->upload($fp, $_target, $name, $tmpname)) === false) { |
|
1858 | 1858 | $result['warning'] = $this->error(self::ERROR_UPLOAD_FILE, $name, $volume->error()); |
1859 | 1859 | fclose($fp); |
1860 | - if (! is_uploaded_file($tmpname)) { |
|
1861 | - if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]);; |
|
1860 | + if (!is_uploaded_file($tmpname)) { |
|
1861 | + if (@ unlink($tmpname)) unset($GLOBALS['elFinderTempFiles'][$tmpname]); ; |
|
1862 | 1862 | continue; |
1863 | 1863 | } |
1864 | 1864 | break; |
1865 | 1865 | } |
1866 | 1866 | |
1867 | 1867 | is_resource($fp) && fclose($fp); |
1868 | - if (! is_uploaded_file($tmpname)){ |
|
1868 | + if (!is_uploaded_file($tmpname)) { |
|
1869 | 1869 | clearstatcache(); |
1870 | 1870 | if (!is_file($tmpname) || @ unlink($tmpname)) { |
1871 | 1871 | unset($GLOBALS['elFinderTempFiles'][$tmpname]); |
@@ -1877,7 +1877,7 @@ discard block |
||
1877 | 1877 | } |
1878 | 1878 | } |
1879 | 1879 | if ($GLOBALS['elFinderTempFiles']) { |
1880 | - foreach(array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
1880 | + foreach (array_keys($GLOBALS['elFinderTempFiles']) as $_temp) { |
|
1881 | 1881 | @ unlink($_temp); |
1882 | 1882 | } |
1883 | 1883 | } |
@@ -1914,7 +1914,7 @@ discard block |
||
1914 | 1914 | $suffix = '~'; |
1915 | 1915 | if (!empty($args['renames'])) { |
1916 | 1916 | $renames = array_flip($args['renames']); |
1917 | - if (is_string($args['suffix']) && ! preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
1917 | + if (is_string($args['suffix']) && !preg_match('/[\/\\?*:|"<>]/', $args['suffix'])) { |
|
1918 | 1918 | $suffix = $args['suffix']; |
1919 | 1919 | } |
1920 | 1920 | } |
@@ -1972,9 +1972,9 @@ discard block |
||
1972 | 1972 | } |
1973 | 1973 | |
1974 | 1974 | if ($args['conv'] && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) { |
1975 | - $mime = isset($file['mime'])? $file['mime'] : ''; |
|
1975 | + $mime = isset($file['mime']) ? $file['mime'] : ''; |
|
1976 | 1976 | if ($mime && strtolower(substr($mime, 0, 4)) === 'text') { |
1977 | - if ($enc = mb_detect_encoding ( $content , mb_detect_order(), true)) { |
|
1977 | + if ($enc = mb_detect_encoding($content, mb_detect_order(), true)) { |
|
1978 | 1978 | if (strtolower($enc) !== 'utf-8') { |
1979 | 1979 | $content = mb_convert_encoding($content, 'UTF-8', $enc); |
1980 | 1980 | } |
@@ -1986,7 +1986,7 @@ discard block |
||
1986 | 1986 | |
1987 | 1987 | if ($json === false || strlen($json) < strlen($content)) { |
1988 | 1988 | if ($args['conv']) { |
1989 | - return array('error' => $this->error(self::ERROR_CONV_UTF8,self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
1989 | + return array('error' => $this->error(self::ERROR_CONV_UTF8, self::ERROR_NOT_UTF8_CONTENT, $volume->path($target))); |
|
1990 | 1990 | } else { |
1991 | 1991 | return array('doconv' => true); |
1992 | 1992 | } |
@@ -2028,7 +2028,7 @@ discard block |
||
2028 | 2028 | $target = $args['target']; |
2029 | 2029 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
2030 | 2030 | $error = array(self::ERROR_EXTRACT, '#'.$target); |
2031 | - $makedir = isset($args['makedir'])? (bool)$args['makedir'] : null; |
|
2031 | + $makedir = isset($args['makedir']) ? (bool) $args['makedir'] : null; |
|
2032 | 2032 | |
2033 | 2033 | if (($volume = $this->volume($target)) == false |
2034 | 2034 | || ($file = $volume->file($target)) == false) { |
@@ -2036,7 +2036,7 @@ discard block |
||
2036 | 2036 | } |
2037 | 2037 | |
2038 | 2038 | return ($file = $volume->extract($target, $makedir)) |
2039 | - ? array('added' => isset($file['read'])? array($file) : $file) |
|
2039 | + ? array('added' => isset($file['read']) ? array($file) : $file) |
|
2040 | 2040 | : array('error' => $this->error(self::ERROR_EXTRACT, $volume->path($target), $volume->error())); |
2041 | 2041 | } |
2042 | 2042 | |
@@ -2051,7 +2051,7 @@ discard block |
||
2051 | 2051 | protected function archive($args) { |
2052 | 2052 | $type = $args['type']; |
2053 | 2053 | $targets = isset($args['targets']) && is_array($args['targets']) ? $args['targets'] : array(); |
2054 | - $name = isset($args['name'])? $args['name'] : ''; |
|
2054 | + $name = isset($args['name']) ? $args['name'] : ''; |
|
2055 | 2055 | |
2056 | 2056 | if (($volume = $this->volume($targets[0])) == false) { |
2057 | 2057 | return $this->error(self::ERROR_ARCHIVE, self::ERROR_TRGDIR_NOT_FOUND); |
@@ -2072,7 +2072,7 @@ discard block |
||
2072 | 2072 | protected function search($args) { |
2073 | 2073 | $q = trim($args['q']); |
2074 | 2074 | $mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array(); |
2075 | - $target = !empty($args['target'])? $args['target'] : null; |
|
2075 | + $target = !empty($args['target']) ? $args['target'] : null; |
|
2076 | 2076 | $result = array(); |
2077 | 2077 | |
2078 | 2078 | if (!is_null($target)) { |
@@ -2136,11 +2136,11 @@ discard block |
||
2136 | 2136 | $target = $args['target']; |
2137 | 2137 | $width = $args['width']; |
2138 | 2138 | $height = $args['height']; |
2139 | - $x = (int)$args['x']; |
|
2140 | - $y = (int)$args['y']; |
|
2139 | + $x = (int) $args['x']; |
|
2140 | + $y = (int) $args['y']; |
|
2141 | 2141 | $mode = $args['mode']; |
2142 | 2142 | $bg = null; |
2143 | - $degree = (int)$args['degree']; |
|
2143 | + $degree = (int) $args['degree']; |
|
2144 | 2144 | |
2145 | 2145 | if (($volume = $this->volume($target)) == false |
2146 | 2146 | || ($file = $volume->file($target)) == false) { |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | **/ |
2162 | 2162 | protected function url($args) { |
2163 | 2163 | $target = $args['target']; |
2164 | - $options = isset($args['options'])? $args['options'] : array(); |
|
2164 | + $options = isset($args['options']) ? $args['options'] : array(); |
|
2165 | 2165 | if (($volume = $this->volume($target)) != false) { |
2166 | 2166 | $url = $volume->getContentUrl($target, $options); |
2167 | 2167 | return $url ? array('url' => $url) : array(); |
@@ -2178,18 +2178,18 @@ discard block |
||
2178 | 2178 | */ |
2179 | 2179 | protected function callback($args) { |
2180 | 2180 | $checkReg = '/[^a-zA-Z0-9;._-]/'; |
2181 | - $node = (isset($args['node']) && !preg_match($checkReg, $args['node']))? $args['node'] : ''; |
|
2182 | - $json = (isset($args['json']) && @json_decode($args['json']))? $args['json'] : '{}'; |
|
2183 | - $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind']))? $args['bind'] : ''; |
|
2181 | + $node = (isset($args['node']) && !preg_match($checkReg, $args['node'])) ? $args['node'] : ''; |
|
2182 | + $json = (isset($args['json']) && @json_decode($args['json'])) ? $args['json'] : '{}'; |
|
2183 | + $bind = (isset($args['bind']) && !preg_match($checkReg, $args['bind'])) ? $args['bind'] : ''; |
|
2184 | 2184 | $done = (!empty($args['done'])); |
2185 | 2185 | |
2186 | - while( ob_get_level() ) { |
|
2187 | - if (! ob_end_clean()) { |
|
2186 | + while (ob_get_level()) { |
|
2187 | + if (!ob_end_clean()) { |
|
2188 | 2188 | break; |
2189 | 2189 | } |
2190 | 2190 | } |
2191 | 2191 | |
2192 | - if ($done || ! $this->callbackWindowURL) { |
|
2192 | + if ($done || !$this->callbackWindowURL) { |
|
2193 | 2193 | $script = ''; |
2194 | 2194 | if ($node) { |
2195 | 2195 | $script .= ' |
@@ -2231,13 +2231,13 @@ discard block |
||
2231 | 2231 | |
2232 | 2232 | } else { |
2233 | 2233 | $url = $this->callbackWindowURL; |
2234 | - $url .= ((strpos($url, '?') === false)? '?' : '&') |
|
2235 | - . '&node=' . rawurlencode($node) |
|
2236 | - . (($json !== '{}')? ('&json=' . rawurlencode($json)) : '') |
|
2237 | - . ($bind? ('&bind=' . rawurlencode($bind)) : '') |
|
2234 | + $url .= ((strpos($url, '?') === false) ? '?' : '&') |
|
2235 | + . '&node='.rawurlencode($node) |
|
2236 | + . (($json !== '{}') ? ('&json='.rawurlencode($json)) : '') |
|
2237 | + . ($bind ? ('&bind='.rawurlencode($bind)) : '') |
|
2238 | 2238 | . '&done=1'; |
2239 | 2239 | |
2240 | - header('Location: ' . $url); |
|
2240 | + header('Location: '.$url); |
|
2241 | 2241 | |
2242 | 2242 | } |
2243 | 2243 | exit(); |
@@ -2307,7 +2307,7 @@ discard block |
||
2307 | 2307 | |
2308 | 2308 | protected function utime() { |
2309 | 2309 | $time = explode(" ", microtime()); |
2310 | - return (double)$time[1] + (double)$time[0]; |
|
2310 | + return (double) $time[1] + (double) $time[0]; |
|
2311 | 2311 | } |
2312 | 2312 | |
2313 | 2313 | |
@@ -2333,7 +2333,7 @@ discard block |
||
2333 | 2333 | $imgcnt = 0; |
2334 | 2334 | $fp = fopen($path, 'rb'); |
2335 | 2335 | @fread($fp, 4); |
2336 | - $c = @fread($fp,1); |
|
2336 | + $c = @fread($fp, 1); |
|
2337 | 2337 | if (ord($c) != 0x39) { // GIF89a |
2338 | 2338 | return false; |
2339 | 2339 | } |
@@ -2341,13 +2341,13 @@ discard block |
||
2341 | 2341 | while (!feof($fp)) { |
2342 | 2342 | do { |
2343 | 2343 | $c = fread($fp, 1); |
2344 | - } while(ord($c) != 0x21 && !feof($fp)); |
|
2344 | + } while (ord($c) != 0x21 && !feof($fp)); |
|
2345 | 2345 | |
2346 | 2346 | if (feof($fp)) { |
2347 | 2347 | break; |
2348 | 2348 | } |
2349 | 2349 | |
2350 | - $c2 = fread($fp,2); |
|
2350 | + $c2 = fread($fp, 2); |
|
2351 | 2351 | if (bin2hex($c2) == "f904") { |
2352 | 2352 | $imgcnt++; |
2353 | 2353 | } |
@@ -1176,7 +1176,6 @@ discard block |
||
1176 | 1176 | * Return file info or false on error |
1177 | 1177 | * |
1178 | 1178 | * @param string $hash file hash |
1179 | - * @param bool $realpath add realpath field to file info |
|
1180 | 1179 | * @return array|false |
1181 | 1180 | * @author Dmitry (dio) Levashov |
1182 | 1181 | **/ |
@@ -1197,7 +1196,6 @@ discard block |
||
1197 | 1196 | * Return folder info |
1198 | 1197 | * |
1199 | 1198 | * @param string $hash folder hash |
1200 | - * @param bool $hidden return hidden file info |
|
1201 | 1199 | * @return array|false |
1202 | 1200 | * @author Dmitry (dio) Levashov |
1203 | 1201 | **/ |
@@ -1530,7 +1528,6 @@ discard block |
||
1530 | 1528 | * |
1531 | 1529 | * @param Resource $fp file pointer |
1532 | 1530 | * @param string $dst destination folder hash |
1533 | - * @param string $src file name |
|
1534 | 1531 | * @param string $tmpname file tmp name - required to detect mime type |
1535 | 1532 | * @return array|false |
1536 | 1533 | * @author Dmitry (dio) Levashov |
@@ -1616,7 +1613,6 @@ discard block |
||
1616 | 1613 | * Paste files |
1617 | 1614 | * |
1618 | 1615 | * @param Object $volume source volume |
1619 | - * @param string $source file hash |
|
1620 | 1616 | * @param string $dst destination dir hash |
1621 | 1617 | * @param bool $rmSrc remove source after copy? |
1622 | 1618 | * @return array|false |
@@ -2235,7 +2231,6 @@ discard block |
||
2235 | 2231 | * Open file and return file pointer (with convert encording) |
2236 | 2232 | * |
2237 | 2233 | * @param string $path file path |
2238 | - * @param bool $write open file for writing |
|
2239 | 2234 | * @return resource|false |
2240 | 2235 | * @author Naoki Sawada |
2241 | 2236 | **/ |
@@ -2366,7 +2361,8 @@ discard block |
||
2366 | 2361 | * Not implemented |
2367 | 2362 | * |
2368 | 2363 | * @param string path |
2369 | - * @return mixed |
|
2364 | + * @param string $path |
|
2365 | + * @return string |
|
2370 | 2366 | * @author Dmitry (dio) Levashov |
2371 | 2367 | **/ |
2372 | 2368 | protected function crypt($path) { |
@@ -2378,7 +2374,8 @@ discard block |
||
2378 | 2374 | * Not implemented |
2379 | 2375 | * |
2380 | 2376 | * @param mixed hash |
2381 | - * @return mixed |
|
2377 | + * @param string $hash |
|
2378 | + * @return string |
|
2382 | 2379 | * @author Dmitry (dio) Levashov |
2383 | 2380 | **/ |
2384 | 2381 | protected function uncrypt($hash) { |
@@ -2408,7 +2405,6 @@ discard block |
||
2408 | 2405 | /** |
2409 | 2406 | * Return new unique name based on file name and suffix |
2410 | 2407 | * |
2411 | - * @param string $path file path |
|
2412 | 2408 | * @param string $suffix suffix append to name |
2413 | 2409 | * @return string |
2414 | 2410 | * @author Dmitry (dio) Levashov |
@@ -2476,6 +2472,7 @@ discard block |
||
2476 | 2472 | * @param string $to to character encoding |
2477 | 2473 | * @param string $locale local locale |
2478 | 2474 | * @param string $unknown replaces character for unknown |
2475 | + * @param boolean $restoreLocale |
|
2479 | 2476 | * @return mixed |
2480 | 2477 | */ |
2481 | 2478 | protected function convEnc($var, $from, $to, $locale, $restoreLocale, $unknown = '_') { |
@@ -2657,6 +2654,7 @@ discard block |
||
2657 | 2654 | * |
2658 | 2655 | * @param string $dir parent dir path |
2659 | 2656 | * @param string $name new file name |
2657 | + * @param boolean $isDir |
|
2660 | 2658 | * @return bool |
2661 | 2659 | * @author Dmitry (dio) Levashov |
2662 | 2660 | **/ |
@@ -3186,7 +3184,7 @@ discard block |
||
3186 | 3184 | * @param string $src source path |
3187 | 3185 | * @param string $dst destination dir path |
3188 | 3186 | * @param string $name new file name (optionaly) |
3189 | - * @return string|false |
|
3187 | + * @return boolean|string |
|
3190 | 3188 | * @author Dmitry (dio) Levashov |
3191 | 3189 | **/ |
3192 | 3190 | protected function copy($src, $dst, $name) { |
@@ -3239,7 +3237,7 @@ discard block |
||
3239 | 3237 | * @param string $src source path |
3240 | 3238 | * @param string $dst destination dir path |
3241 | 3239 | * @param string $name new file name |
3242 | - * @return string|false |
|
3240 | + * @return string|boolean |
|
3243 | 3241 | * @author Dmitry (dio) Levashov |
3244 | 3242 | **/ |
3245 | 3243 | protected function move($src, $dst, $name) { |
@@ -3265,7 +3263,7 @@ discard block |
||
3265 | 3263 | * @param string $src source file hash |
3266 | 3264 | * @param string $destination destination dir path |
3267 | 3265 | * @param string $name file name |
3268 | - * @return string|false |
|
3266 | + * @return boolean|string |
|
3269 | 3267 | * @author Dmitry (dio) Levashov |
3270 | 3268 | **/ |
3271 | 3269 | protected function copyFrom($volume, $src, $destination, $name) { |
@@ -3409,7 +3407,7 @@ discard block |
||
3409 | 3407 | * @param string $path thumnbnail path |
3410 | 3408 | * @param array $stat file stat |
3411 | 3409 | * @param bool $checkTmbPath |
3412 | - * @return string|bool |
|
3410 | + * @return boolean |
|
3413 | 3411 | * @author Dmitry (dio) Levashov |
3414 | 3412 | **/ |
3415 | 3413 | protected function canCreateTmb($path, $stat, $checkTmbPath = true) { |
@@ -3426,7 +3424,7 @@ discard block |
||
3426 | 3424 | * |
3427 | 3425 | * @param string $path thumnbnail path |
3428 | 3426 | * @param array $stat file stat |
3429 | - * @return string|bool |
|
3427 | + * @return boolean |
|
3430 | 3428 | * @author Dmitry (dio) Levashov |
3431 | 3429 | **/ |
3432 | 3430 | protected function canResize($path, $stat) { |
@@ -3437,7 +3435,6 @@ discard block |
||
3437 | 3435 | * Create thumnbnail and return it's URL on success |
3438 | 3436 | * |
3439 | 3437 | * @param string $path file path |
3440 | - * @param string $mime file mime type |
|
3441 | 3438 | * @return string|false |
3442 | 3439 | * @author Dmitry (dio) Levashov |
3443 | 3440 | **/ |
@@ -3897,7 +3894,7 @@ discard block |
||
3897 | 3894 | * |
3898 | 3895 | * @param string $command command line |
3899 | 3896 | * @param array $output stdout strings |
3900 | - * @param array $return_var process exit code |
|
3897 | + * @param integer $return_var process exit code |
|
3901 | 3898 | * @param array $error_output stderr strings |
3902 | 3899 | * @return int exit code |
3903 | 3900 | * @author Alexey Sukhotin |
@@ -4048,7 +4045,7 @@ discard block |
||
4048 | 4045 | * @param string $haystack The string being checked. |
4049 | 4046 | * @param string $needle The string to find in haystack. |
4050 | 4047 | * @param int $offset The search offset. If it is not specified, 0 is used. |
4051 | - * @return int|bool |
|
4048 | + * @return integer |
|
4052 | 4049 | * @author Alexey Sukhotin |
4053 | 4050 | **/ |
4054 | 4051 | protected function stripos($haystack , $needle , $offset = 0) { |
@@ -4273,7 +4270,7 @@ discard block |
||
4273 | 4270 | * @param array $files files names list |
4274 | 4271 | * @param string $name archive name |
4275 | 4272 | * @param array $arc archiver options |
4276 | - * @return string|bool |
|
4273 | + * @return string|false |
|
4277 | 4274 | * @author Dmitry (dio) Levashov, |
4278 | 4275 | * @author Alexey Sukhotin |
4279 | 4276 | * @author Naoki Sawada |
@@ -4330,7 +4327,7 @@ discard block |
||
4330 | 4327 | * @param string $dir target dir |
4331 | 4328 | * @param array $files files names list |
4332 | 4329 | * @param string|object $zipPath Zip archive name |
4333 | - * @return void |
|
4330 | + * @return boolean |
|
4334 | 4331 | * @author Naoki Sawada |
4335 | 4332 | */ |
4336 | 4333 | protected static function zipArchiveZip($dir, $files, $zipPath) { |
@@ -4533,7 +4530,6 @@ discard block |
||
4533 | 4530 | * Open file and return file pointer |
4534 | 4531 | * |
4535 | 4532 | * @param string $path file path |
4536 | - * @param bool $write open file for writing |
|
4537 | 4533 | * @return resource|false |
4538 | 4534 | * @author Dmitry (dio) Levashov |
4539 | 4535 | **/ |
@@ -4586,7 +4582,7 @@ discard block |
||
4586 | 4582 | * Copy file into another file (only inside one volume) |
4587 | 4583 | * |
4588 | 4584 | * @param string $source source file path |
4589 | - * @param string $target target dir path |
|
4585 | + * @param string $targetDir target dir path |
|
4590 | 4586 | * @param string $name file name |
4591 | 4587 | * @return bool |
4592 | 4588 | * @author Dmitry (dio) Levashov |
@@ -4598,7 +4594,7 @@ discard block |
||
4598 | 4594 | * Return new file path or false. |
4599 | 4595 | * |
4600 | 4596 | * @param string $source source file path |
4601 | - * @param string $target target dir path |
|
4597 | + * @param string $targetDir target dir path |
|
4602 | 4598 | * @param string $name file name |
4603 | 4599 | * @return string|bool |
4604 | 4600 | * @author Dmitry (dio) Levashov |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Base class for elFinder volume. |
|
4 | - * Provide 2 layers: |
|
5 | - * 1. Public API (commands) |
|
6 | - * 2. abstract fs API |
|
7 | - * |
|
8 | - * All abstract methods begin with "_" |
|
9 | - * |
|
10 | - * @author Dmitry (dio) Levashov |
|
11 | - * @author Troex Nevelin |
|
12 | - * @author Alexey Sukhotin |
|
13 | - **/ |
|
3 | + * Base class for elFinder volume. |
|
4 | + * Provide 2 layers: |
|
5 | + * 1. Public API (commands) |
|
6 | + * 2. abstract fs API |
|
7 | + * |
|
8 | + * All abstract methods begin with "_" |
|
9 | + * |
|
10 | + * @author Dmitry (dio) Levashov |
|
11 | + * @author Troex Nevelin |
|
12 | + * @author Alexey Sukhotin |
|
13 | + **/ |
|
14 | 14 | abstract class elFinderVolumeDriver { |
15 | 15 | |
16 | 16 | /** |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | 'mimefile' => '', |
193 | 193 | // mime type normalize map : Array '[ext]:[detected mime type]' => '[normalized mime]' |
194 | 194 | 'mimeMap' => array( |
195 | - 'md:application/x-genesis-rom' => 'text/x-markdown', |
|
196 | - 'md:text/plain' => 'text/x-markdown', |
|
197 | - 'markdown:text/plain' => 'text/x-markdown', |
|
198 | - 'css:text/x-asm' => 'text/css' |
|
199 | - ), |
|
195 | + 'md:application/x-genesis-rom' => 'text/x-markdown', |
|
196 | + 'md:text/plain' => 'text/x-markdown', |
|
197 | + 'markdown:text/plain' => 'text/x-markdown', |
|
198 | + 'css:text/x-asm' => 'text/css' |
|
199 | + ), |
|
200 | 200 | // directory for thumbnails |
201 | 201 | 'tmbPath' => '.tmb', |
202 | 202 | // mode to create thumbnails dir |
@@ -4043,14 +4043,14 @@ discard block |
||
4043 | 4043 | // } |
4044 | 4044 | |
4045 | 4045 | /** |
4046 | - * Find position of first occurrence of string in a string with multibyte support |
|
4047 | - * |
|
4048 | - * @param string $haystack The string being checked. |
|
4049 | - * @param string $needle The string to find in haystack. |
|
4050 | - * @param int $offset The search offset. If it is not specified, 0 is used. |
|
4051 | - * @return int|bool |
|
4052 | - * @author Alexey Sukhotin |
|
4053 | - **/ |
|
4046 | + * Find position of first occurrence of string in a string with multibyte support |
|
4047 | + * |
|
4048 | + * @param string $haystack The string being checked. |
|
4049 | + * @param string $needle The string to find in haystack. |
|
4050 | + * @param int $offset The search offset. If it is not specified, 0 is used. |
|
4051 | + * @return int|bool |
|
4052 | + * @author Alexey Sukhotin |
|
4053 | + **/ |
|
4054 | 4054 | protected function stripos($haystack , $needle , $offset = 0) { |
4055 | 4055 | if (function_exists('mb_stripos')) { |
4056 | 4056 | return mb_stripos($haystack , $needle , $offset); |
@@ -859,7 +859,9 @@ discard block |
||
859 | 859 | |
860 | 860 | // This get's triggered if $this->root == '/' and alias is empty. |
861 | 861 | // Maybe modify _basename instead? |
862 | - if ($this->rootName === '') $this->rootName = $this->separator; |
|
862 | + if ($this->rootName === '') { |
|
863 | + $this->rootName = $this->separator; |
|
864 | + } |
|
863 | 865 | |
864 | 866 | $root = $this->stat($this->root); |
865 | 867 | |
@@ -2938,7 +2940,9 @@ discard block |
||
2938 | 2940 | if ($this->mimeDetect == 'finfo') { |
2939 | 2941 | if ($type = @finfo_file($this->finfo, $path)) { |
2940 | 2942 | if ($ext && preg_match('~^application/(?:octet-stream|(?:x-)?zip)~', $type)) { |
2941 | - if (isset(elFinderVolumeDriver::$mimetypes[$ext])) $type = elFinderVolumeDriver::$mimetypes[$ext]; |
|
2943 | + if (isset(elFinderVolumeDriver::$mimetypes[$ext])) { |
|
2944 | + $type = elFinderVolumeDriver::$mimetypes[$ext]; |
|
2945 | + } |
|
2942 | 2946 | } else if ($ext === 'js' && preg_match('~^text/~', $type)) { |
2943 | 2947 | $type = 'text/javascript'; |
2944 | 2948 | } |
@@ -4013,7 +4017,7 @@ discard block |
||
4013 | 4017 | imagesavealpha($image,true); |
4014 | 4018 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
4015 | 4019 | |
4016 | - }else{ |
|
4020 | + } else{ |
|
4017 | 4021 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
4018 | 4022 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
4019 | 4023 | } |
@@ -4203,7 +4207,9 @@ discard block |
||
4203 | 4207 | } |
4204 | 4208 | |
4205 | 4209 | // 'Here' |
4206 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
4210 | + if ($path === '' || $path === '.' . $separator) { |
|
4211 | + return $base; |
|
4212 | + } |
|
4207 | 4213 | |
4208 | 4214 | // Absolute path |
4209 | 4215 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | 'utf8fix' => false, |
275 | 275 | // й ё Й Ё Ø Å |
276 | 276 | 'utf8patterns' => array("\u0438\u0306", "\u0435\u0308", "\u0418\u0306", "\u0415\u0308", "\u00d8A", "\u030a"), |
277 | - 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
277 | + 'utf8replace' => array("\u0439", "\u0451", "\u0419", "\u0401", "\u00d8", "\u00c5") |
|
278 | 278 | ); |
279 | 279 | |
280 | 280 | /** |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | **/ |
567 | 567 | protected function configure() { |
568 | 568 | // set ARGS |
569 | - $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST'? $_POST : $_GET; |
|
569 | + $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; |
|
570 | 570 | // set thumbnails path |
571 | 571 | $path = $this->options['tmbPath']; |
572 | 572 | if ($path) { |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | |
598 | 598 | // check 'statOwner' for command `chmod` |
599 | 599 | if (empty($this->options['statOwner'])) { |
600 | - $this->disabled[] ='chmod'; |
|
600 | + $this->disabled[] = 'chmod'; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | // check 'mimeMap' |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | **/ |
703 | 703 | public function mount(array $opts) { |
704 | 704 | if (!isset($opts['path']) || $opts['path'] === '') { |
705 | - return $this->setError('Path undefined.');; |
|
705 | + return $this->setError('Path undefined.'); ; |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | $this->options = array_merge($this->options, $opts); |
@@ -721,14 +721,14 @@ discard block |
||
721 | 721 | $argInit = !empty($this->ARGS['init']); |
722 | 722 | |
723 | 723 | // session cache |
724 | - if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
724 | + if ($argInit || !isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) { |
|
725 | 725 | $_SESSION[elFinder::$sessionCacheKey][$this->id] = array(); |
726 | 726 | } |
727 | 727 | $this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id]; |
728 | 728 | |
729 | 729 | // default file attribute |
730 | 730 | $this->defaults = array( |
731 | - 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
731 | + 'read' => isset($this->options['defaults']['read']) ? !!$this->options['defaults']['read'] : true, |
|
732 | 732 | 'write' => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true, |
733 | 733 | 'locked' => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false, |
734 | 734 | 'hidden' => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false |
@@ -755,8 +755,8 @@ discard block |
||
755 | 755 | $this->access = $this->options['accessControl']; |
756 | 756 | } |
757 | 757 | |
758 | - $this->today = mktime(0,0,0, date('m'), date('d'), date('Y')); |
|
759 | - $this->yesterday = $this->today-86400; |
|
758 | + $this->today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
759 | + $this->yesterday = $this->today - 86400; |
|
760 | 760 | |
761 | 761 | // debug($this->attributes); |
762 | 762 | if (!$this->init()) { |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | foreach ($mimecf as $line_num => $line) { |
856 | 856 | if (!preg_match('/^\s*#/', $line)) { |
857 | 857 | $mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); |
858 | - for ($i = 1, $size = count($mime); $i < $size ; $i++) { |
|
858 | + for ($i = 1, $size = count($mime); $i < $size; $i++) { |
|
859 | 859 | if (!isset(self::$mimetypes[$mime[$i]])) { |
860 | 860 | self::$mimetypes[$mime[$i]] = $mime[0]; |
861 | 861 | } |
@@ -907,8 +907,8 @@ discard block |
||
907 | 907 | 'read' => false |
908 | 908 | )); |
909 | 909 | } |
910 | - $this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1; |
|
911 | - $this->tmbSize = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48; |
|
910 | + $this->treeDeep = $this->options['treeDeep'] > 0 ? (int) $this->options['treeDeep'] : 1; |
|
911 | + $this->tmbSize = $this->options['tmbSize'] > 0 ? (int) $this->options['tmbSize'] : 48; |
|
912 | 912 | $this->URL = $this->options['URL']; |
913 | 913 | if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) { |
914 | 914 | $this->URL .= '/'; |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | public function options($hash) { |
1050 | 1050 | $create = $createext = array(); |
1051 | 1051 | if (isset($this->archivers['create']) && is_array($this->archivers['create'])) { |
1052 | - foreach($this->archivers['create'] as $m => $v) { |
|
1052 | + foreach ($this->archivers['create'] as $m => $v) { |
|
1053 | 1053 | $create[] = $m; |
1054 | 1054 | $createext[$m] = $v['ext']; |
1055 | 1055 | } |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | 'extract' => isset($this->archivers['extract']) && is_array($this->archivers['extract']) ? array_keys($this->archivers['extract']) : array(), |
1069 | 1069 | 'createext' => $createext |
1070 | 1070 | ), |
1071 | - 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array() |
|
1071 | + 'uiCmdMap' => (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array() |
|
1072 | 1072 | ); |
1073 | 1073 | } |
1074 | 1074 | |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | */ |
1082 | 1082 | public function getOptionsPlugin($name = '') { |
1083 | 1083 | if ($name) { |
1084 | - return isset($this->options['plugin'][$name])? $this->options['plugin'][$name] : array(); |
|
1084 | + return isset($this->options['plugin'][$name]) ? $this->options['plugin'][$name] : array(); |
|
1085 | 1085 | } else { |
1086 | 1086 | return $this->options['plugin']; |
1087 | 1087 | } |
@@ -1211,7 +1211,7 @@ discard block |
||
1211 | 1211 | $file = $this->stat($path); |
1212 | 1212 | |
1213 | 1213 | if ($hash === $this->root()) { |
1214 | - $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array(); |
|
1214 | + $file['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap'])) ? $this->options['uiCmdMap'] : array(); |
|
1215 | 1215 | $file['disabled'] = array_merge(array_unique($this->disabled)); // `array_merge` for type array of JSON |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | * @return array|false |
1227 | 1227 | * @author Dmitry (dio) Levashov |
1228 | 1228 | **/ |
1229 | - public function dir($hash, $resolveLink=false) { |
|
1229 | + public function dir($hash, $resolveLink = false) { |
|
1230 | 1230 | if (($dir = $this->file($hash)) == false) { |
1231 | 1231 | return $this->setError(elFinder::ERROR_DIR_NOT_FOUND); |
1232 | 1232 | } |
@@ -1290,14 +1290,14 @@ discard block |
||
1290 | 1290 | * @return array|false |
1291 | 1291 | * @author Dmitry (dio) Levashov |
1292 | 1292 | **/ |
1293 | - public function tree($hash='', $deep=0, $exclude='') { |
|
1293 | + public function tree($hash = '', $deep = 0, $exclude = '') { |
|
1294 | 1294 | $path = $hash ? $this->decode($hash) : $this->root; |
1295 | 1295 | |
1296 | 1296 | if (($dir = $this->stat($path)) == false || $dir['mime'] != 'directory') { |
1297 | 1297 | return false; |
1298 | 1298 | } |
1299 | 1299 | |
1300 | - $dirs = $this->gettree($path, $deep > 0 ? $deep -1 : $this->treeDeep-1, $exclude ? $this->decode($exclude) : null); |
|
1300 | + $dirs = $this->gettree($path, $deep > 0 ? $deep - 1 : $this->treeDeep - 1, $exclude ? $this->decode($exclude) : null); |
|
1301 | 1301 | array_unshift($dirs, $dir); |
1302 | 1302 | return $dirs; |
1303 | 1303 | } |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | * @return array|false |
1528 | 1528 | * @author Dmitry (dio) Levashov |
1529 | 1529 | **/ |
1530 | - public function duplicate($hash, $suffix='copy') { |
|
1530 | + public function duplicate($hash, $suffix = 'copy') { |
|
1531 | 1531 | if ($this->commandDisabled('duplicate')) { |
1532 | 1532 | return $this->setError(elFinder::ERROR_COPY, '#'.$hash, elFinder::ERROR_PERM_DENIED); |
1533 | 1533 | } |
@@ -1603,7 +1603,7 @@ discard block |
||
1603 | 1603 | |
1604 | 1604 | if ($file) { // file exists |
1605 | 1605 | // check POST data `overwrite` for 3rd party uploader |
1606 | - $overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1606 | + $overwrite = isset($_POST['overwrite']) ? (bool) $_POST['overwrite'] : $this->options['uploadOverwrite']; |
|
1607 | 1607 | if ($overwrite) { |
1608 | 1608 | if (!$file['write']) { |
1609 | 1609 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
@@ -1674,7 +1674,7 @@ discard block |
||
1674 | 1674 | if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) { |
1675 | 1675 | return $rmSrc |
1676 | 1676 | ? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test)) |
1677 | - : $this->setError($err, $errpath, !empty($file['thash'])? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1677 | + : $this->setError($err, $errpath, !empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK); |
|
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | $test = $this->joinPathCE($destination, $name); |
@@ -1837,7 +1837,7 @@ discard block |
||
1837 | 1837 | return $this->setError(elFinder::ERROR_PERM_DENIED); |
1838 | 1838 | } |
1839 | 1839 | $this->clearcache(); |
1840 | - $this->extractToNewdir = is_null($makedir)? 'auto' : (bool)$makedir; |
|
1840 | + $this->extractToNewdir = is_null($makedir) ? 'auto' : (bool) $makedir; |
|
1841 | 1841 | |
1842 | 1842 | if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) { |
1843 | 1843 | if (is_array($path)) { |
@@ -1895,9 +1895,9 @@ discard block |
||
1895 | 1895 | if ($name === '') { |
1896 | 1896 | $name = count($files) == 1 ? $files[0] : 'Archive'; |
1897 | 1897 | } else { |
1898 | - $name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name)); |
|
1898 | + $name = str_replace(array('/', '\\'), '_', preg_replace('/\.'.preg_quote($archiver['ext'], '/').'$/i', '', $name)); |
|
1899 | 1899 | } |
1900 | - $name .='.' . $archiver['ext']; |
|
1900 | + $name .= '.'.$archiver['ext']; |
|
1901 | 1901 | $name = $this->uniqueName($dir, $name, ''); |
1902 | 1902 | $this->clearcache(); |
1903 | 1903 | return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false; |
@@ -1933,7 +1933,7 @@ discard block |
||
1933 | 1933 | |
1934 | 1934 | $path = $this->decode($hash); |
1935 | 1935 | |
1936 | - $work_path = $this->getWorkFile($this->encoding? $this->convEncIn($path, true) : $path); |
|
1936 | + $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path); |
|
1937 | 1937 | |
1938 | 1938 | if (!$work_path || !is_writable($work_path)) { |
1939 | 1939 | if ($work_path && $path !== $work_path && is_file($work_path)) { |
@@ -1948,7 +1948,7 @@ discard block |
||
1948 | 1948 | } |
1949 | 1949 | } |
1950 | 1950 | |
1951 | - switch($mode) { |
|
1951 | + switch ($mode) { |
|
1952 | 1952 | |
1953 | 1953 | case 'propresize': |
1954 | 1954 | $result = $this->imgResize($work_path, $width, $height, true, true); |
@@ -2044,7 +2044,7 @@ discard block |
||
2044 | 2044 | } |
2045 | 2045 | return ($q === '' || $this->commandDisabled('search')) |
2046 | 2046 | ? array() |
2047 | - : $this->doSearch(is_null($dir)? $this->root : $dir, $q, $mimes); |
|
2047 | + : $this->doSearch(is_null($dir) ? $this->root : $dir, $q, $mimes); |
|
2048 | 2048 | } |
2049 | 2049 | |
2050 | 2050 | /** |
@@ -2113,9 +2113,9 @@ discard block |
||
2113 | 2113 | $path = ltrim($path, $this->separator); |
2114 | 2114 | $dirs = explode($this->separator, $path); |
2115 | 2115 | array_pop($dirs); |
2116 | - foreach($dirs as $dir) { |
|
2116 | + foreach ($dirs as $dir) { |
|
2117 | 2117 | $targetPath = $this->joinPathCE($base, $dir); |
2118 | - if (! $_realpath = $this->realpath($this->encode($targetPath))) { |
|
2118 | + if (!$_realpath = $this->realpath($this->encode($targetPath))) { |
|
2119 | 2119 | if ($stat = $this->mkdir($targetHash, $dir)) { |
2120 | 2120 | $result['added'][] = $stat; |
2121 | 2121 | $targetHash = $stat['hash']; |
@@ -2182,7 +2182,7 @@ discard block |
||
2182 | 2182 | * @author Naoki Sawada |
2183 | 2183 | **/ |
2184 | 2184 | protected function dirnameCE($path) { |
2185 | - return (!$this->encoding)? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2185 | + return (!$this->encoding) ? $this->_dirname($path) : $this->convEncOut($this->_dirname($this->convEncIn($path))); |
|
2186 | 2186 | } |
2187 | 2187 | |
2188 | 2188 | /** |
@@ -2193,7 +2193,7 @@ discard block |
||
2193 | 2193 | * @author Naoki Sawada |
2194 | 2194 | **/ |
2195 | 2195 | protected function basenameCE($path) { |
2196 | - return (!$this->encoding)? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2196 | + return (!$this->encoding) ? $this->_basename($path) : $this->convEncOut($this->_basename($this->convEncIn($path))); |
|
2197 | 2197 | } |
2198 | 2198 | |
2199 | 2199 | /** |
@@ -2206,7 +2206,7 @@ discard block |
||
2206 | 2206 | * @author Naoki Sawada |
2207 | 2207 | **/ |
2208 | 2208 | protected function joinPathCE($dir, $name) { |
2209 | - return (!$this->encoding)? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2209 | + return (!$this->encoding) ? $this->_joinPath($dir, $name) : $this->convEncOut($this->_joinPath($this->convEncIn($dir), $this->convEncIn($name))); |
|
2210 | 2210 | } |
2211 | 2211 | |
2212 | 2212 | /** |
@@ -2217,7 +2217,7 @@ discard block |
||
2217 | 2217 | * @author Naoki Sawada |
2218 | 2218 | **/ |
2219 | 2219 | protected function normpathCE($path) { |
2220 | - return (!$this->encoding)? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2220 | + return (!$this->encoding) ? $this->_normpath($path) : $this->convEncOut($this->_normpath($this->convEncIn($path))); |
|
2221 | 2221 | } |
2222 | 2222 | |
2223 | 2223 | /** |
@@ -2228,7 +2228,7 @@ discard block |
||
2228 | 2228 | * @author Naoki Sawada |
2229 | 2229 | **/ |
2230 | 2230 | protected function relpathCE($path) { |
2231 | - return (!$this->encoding)? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2231 | + return (!$this->encoding) ? $this->_relpath($path) : $this->convEncOut($this->_relpath($this->convEncIn($path))); |
|
2232 | 2232 | } |
2233 | 2233 | |
2234 | 2234 | /** |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | * @author Naoki Sawada |
2240 | 2240 | **/ |
2241 | 2241 | protected function abspathCE($path) { |
2242 | - return (!$this->encoding)? $this->_abspath($path): $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2242 | + return (!$this->encoding) ? $this->_abspath($path) : $this->convEncOut($this->_abspath($this->convEncIn($path))); |
|
2243 | 2243 | } |
2244 | 2244 | |
2245 | 2245 | /** |
@@ -2251,7 +2251,7 @@ discard block |
||
2251 | 2251 | * @author Naoki Sawada |
2252 | 2252 | **/ |
2253 | 2253 | protected function inpathCE($path, $parent) { |
2254 | - return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2254 | + return (!$this->encoding) ? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent))); |
|
2255 | 2255 | } |
2256 | 2256 | |
2257 | 2257 | /** |
@@ -2262,8 +2262,8 @@ discard block |
||
2262 | 2262 | * @return resource|false |
2263 | 2263 | * @author Naoki Sawada |
2264 | 2264 | **/ |
2265 | - protected function fopenCE($path, $mode='rb') { |
|
2266 | - return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2265 | + protected function fopenCE($path, $mode = 'rb') { |
|
2266 | + return (!$this->encoding) ? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode)); |
|
2267 | 2267 | } |
2268 | 2268 | |
2269 | 2269 | /** |
@@ -2274,8 +2274,8 @@ discard block |
||
2274 | 2274 | * @return bool |
2275 | 2275 | * @author Naoki Sawada |
2276 | 2276 | **/ |
2277 | - protected function fcloseCE($fp, $path='') { |
|
2278 | - return (!$this->encoding)? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2277 | + protected function fcloseCE($fp, $path = '') { |
|
2278 | + return (!$this->encoding) ? $this->_fclose($fp, $path) : $this->convEncOut($this->_fclose($fp, $this->convEncIn($path))); |
|
2279 | 2279 | } |
2280 | 2280 | |
2281 | 2281 | /** |
@@ -2290,7 +2290,7 @@ discard block |
||
2290 | 2290 | * @author Naoki Sawada |
2291 | 2291 | **/ |
2292 | 2292 | protected function saveCE($fp, $dir, $name, $stat) { |
2293 | - return (!$this->encoding)? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2293 | + return (!$this->encoding) ? $this->_save($fp, $dir, $name, $stat) : $this->convEncOut($this->_save($fp, $this->convEncIn($dir), $this->convEncIn($name), $this->convEncIn($stat))); |
|
2294 | 2294 | } |
2295 | 2295 | |
2296 | 2296 | /** |
@@ -2302,7 +2302,7 @@ discard block |
||
2302 | 2302 | **/ |
2303 | 2303 | protected function subdirsCE($path) { |
2304 | 2304 | if (!isset($this->subdirsCache[$path])) { |
2305 | - $this->subdirsCache[$path] = (!$this->encoding)? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2305 | + $this->subdirsCache[$path] = (!$this->encoding) ? $this->_subdirs($path) : $this->convEncOut($this->_subdirs($this->convEncIn($path))); |
|
2306 | 2306 | } |
2307 | 2307 | return $this->subdirsCache[$path]; |
2308 | 2308 | } |
@@ -2315,7 +2315,7 @@ discard block |
||
2315 | 2315 | * @author Naoki Sawada |
2316 | 2316 | **/ |
2317 | 2317 | protected function scandirCE($path) { |
2318 | - return (!$this->encoding)? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2318 | + return (!$this->encoding) ? $this->_scandir($path) : $this->convEncOut($this->_scandir($this->convEncIn($path))); |
|
2319 | 2319 | } |
2320 | 2320 | |
2321 | 2321 | /** |
@@ -2328,7 +2328,7 @@ discard block |
||
2328 | 2328 | * @author Naoki Sawada |
2329 | 2329 | **/ |
2330 | 2330 | protected function symlinkCE($source, $targetDir, $name) { |
2331 | - return (!$this->encoding)? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2331 | + return (!$this->encoding) ? $this->_symlink($source, $targetDir, $name) : $this->convEncOut($this->_symlink($this->convEncIn($source), $this->convEncIn($targetDir), $this->convEncIn($name))); |
|
2332 | 2332 | } |
2333 | 2333 | |
2334 | 2334 | /***************** paths *******************/ |
@@ -2347,7 +2347,7 @@ discard block |
||
2347 | 2347 | // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root |
2348 | 2348 | $p = $this->relpathCE($path); |
2349 | 2349 | // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt |
2350 | - if ($p === '') { |
|
2350 | + if ($p === '') { |
|
2351 | 2351 | $p = DIRECTORY_SEPARATOR; |
2352 | 2352 | } |
2353 | 2353 | |
@@ -2380,7 +2380,7 @@ discard block |
||
2380 | 2380 | // TODO uncrypt hash and return path |
2381 | 2381 | $path = $this->uncrypt($h); |
2382 | 2382 | // append ROOT to path after it was cut in encode |
2383 | - return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2383 | + return $this->abspathCE($path); //$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path); |
|
2384 | 2384 | } |
2385 | 2385 | } |
2386 | 2386 | |
@@ -2437,21 +2437,21 @@ discard block |
||
2437 | 2437 | * @author Dmitry (dio) Levashov |
2438 | 2438 | **/ |
2439 | 2439 | public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) { |
2440 | - $ext = ''; |
|
2440 | + $ext = ''; |
|
2441 | 2441 | |
2442 | 2442 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
2443 | 2443 | $ext = '.'.$m[1]; |
2444 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
2444 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
2445 | 2445 | } |
2446 | 2446 | |
2447 | 2447 | if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) { |
2448 | - $i = (int)$m[2]; |
|
2449 | - $name = substr($name, 0, strlen($name)-strlen($m[2])); |
|
2448 | + $i = (int) $m[2]; |
|
2449 | + $name = substr($name, 0, strlen($name) - strlen($m[2])); |
|
2450 | 2450 | } else { |
2451 | 2451 | $i = $start; |
2452 | 2452 | $name .= $suffix; |
2453 | 2453 | } |
2454 | - $max = $i+100000; |
|
2454 | + $max = $i + 100000; |
|
2455 | 2455 | |
2456 | 2456 | while ($i <= $max) { |
2457 | 2457 | $n = $name.($i > 0 ? $i : '').$ext; |
@@ -2475,7 +2475,7 @@ discard block |
||
2475 | 2475 | * @author Naoki Sawada |
2476 | 2476 | */ |
2477 | 2477 | public function convEncIn($var = null, $restoreLocale = false, $unknown = '_') { |
2478 | - return (!$this->encoding)? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2478 | + return (!$this->encoding) ? $var : $this->convEnc($var, 'UTF-8', $this->encoding, $this->options['locale'], $restoreLocale, $unknown); |
|
2479 | 2479 | } |
2480 | 2480 | |
2481 | 2481 | /** |
@@ -2488,7 +2488,7 @@ discard block |
||
2488 | 2488 | * @author Naoki Sawada |
2489 | 2489 | */ |
2490 | 2490 | public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') { |
2491 | - return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2491 | + return (!$this->encoding) ? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown); |
|
2492 | 2492 | } |
2493 | 2493 | |
2494 | 2494 | /** |
@@ -2508,7 +2508,7 @@ discard block |
||
2508 | 2508 | } |
2509 | 2509 | if (is_array($var)) { |
2510 | 2510 | $_ret = array(); |
2511 | - foreach($var as $_k => $_v) { |
|
2511 | + foreach ($var as $_k => $_v) { |
|
2512 | 2512 | $_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_'); |
2513 | 2513 | } |
2514 | 2514 | $var = $_ret; |
@@ -2520,7 +2520,7 @@ discard block |
||
2520 | 2520 | $_var = str_replace('?', $unknown, $_var); |
2521 | 2521 | } |
2522 | 2522 | } |
2523 | - if ($_var !== false) { |
|
2523 | + if ($_var !== false) { |
|
2524 | 2524 | $var = $_var; |
2525 | 2525 | } |
2526 | 2526 | } |
@@ -2547,7 +2547,7 @@ discard block |
||
2547 | 2547 | |
2548 | 2548 | $key = ''; |
2549 | 2549 | if ($path !== '') { |
2550 | - $key = $this->id . '#' . $path; |
|
2550 | + $key = $this->id.'#'.$path; |
|
2551 | 2551 | if (isset($cache[$key])) { |
2552 | 2552 | return $cache[$key]; |
2553 | 2553 | } |
@@ -2579,7 +2579,7 @@ discard block |
||
2579 | 2579 | if ($work = $this->getTempFile()) { |
2580 | 2580 | if ($wfp = fopen($work, 'wb')) { |
2581 | 2581 | if ($fp = $this->_fopen($path)) { |
2582 | - while(!feof($fp)) { |
|
2582 | + while (!feof($fp)) { |
|
2583 | 2583 | fwrite($wfp, fread($fp, 8192)); |
2584 | 2584 | } |
2585 | 2585 | $this->_fclose($fp, $path); |
@@ -2623,7 +2623,7 @@ discard block |
||
2623 | 2623 | @set_time_limit(30); |
2624 | 2624 | $stat = $this->stat($this->convEncOut($p)); |
2625 | 2625 | $this->convEncIn(); |
2626 | - ($stat['mime'] === 'directory')? $this->delTree($p) : $this->_unlink($p); |
|
2626 | + ($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p); |
|
2627 | 2627 | } |
2628 | 2628 | return $this->_rmdir($localpath); |
2629 | 2629 | } |
@@ -2640,7 +2640,7 @@ discard block |
||
2640 | 2640 | * @return bool |
2641 | 2641 | * @author Dmitry (dio) Levashov |
2642 | 2642 | **/ |
2643 | - protected function attr($path, $name, $val=null, $isDir=null) { |
|
2643 | + protected function attr($path, $name, $val = null, $isDir = null) { |
|
2644 | 2644 | if (!isset($this->defaults[$name])) { |
2645 | 2645 | return false; |
2646 | 2646 | } |
@@ -2672,7 +2672,7 @@ discard block |
||
2672 | 2672 | } |
2673 | 2673 | } |
2674 | 2674 | |
2675 | - return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm; |
|
2675 | + return $perm === null ? (is_null($val) ? $this->defaults[$name] : $val) : !!$perm; |
|
2676 | 2676 | } |
2677 | 2677 | |
2678 | 2678 | /** |
@@ -2716,7 +2716,7 @@ discard block |
||
2716 | 2716 | protected function allowPutMime($mime) { |
2717 | 2717 | // logic based on http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order |
2718 | 2718 | $allow = $this->mimeAccepted($mime, $this->uploadAllow, null); |
2719 | - $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2719 | + $deny = $this->mimeAccepted($mime, $this->uploadDeny, null); |
|
2720 | 2720 | $res = true; // default to allow |
2721 | 2721 | if (strtolower($this->uploadOrder[0]) == 'allow') { // array('allow', 'deny'), default is to 'deny' |
2722 | 2722 | $res = false; // default is deny |
@@ -2787,10 +2787,10 @@ discard block |
||
2787 | 2787 | if ($this->rootName) { |
2788 | 2788 | $stat['name'] = $this->rootName; |
2789 | 2789 | } |
2790 | - if (! empty($this->options['icon'])) { |
|
2790 | + if (!empty($this->options['icon'])) { |
|
2791 | 2791 | $stat['icon'] = $this->options['icon']; |
2792 | 2792 | } |
2793 | - if (! empty($this->options['rootCssClass'])) { |
|
2793 | + if (!empty($this->options['rootCssClass'])) { |
|
2794 | 2794 | $stat['csscls'] = $this->options['rootCssClass']; |
2795 | 2795 | } |
2796 | 2796 | } else { |
@@ -2834,7 +2834,7 @@ discard block |
||
2834 | 2834 | // lock when parent directory is not writable |
2835 | 2835 | if (!isset($stat['locked'])) { |
2836 | 2836 | $parent = $this->dirnameCE($path); |
2837 | - $pstat = isset($this->cache[$parent])? $this->cache[$parent] : array(); |
|
2837 | + $pstat = isset($this->cache[$parent]) ? $this->cache[$parent] : array(); |
|
2838 | 2838 | if (isset($pstat['write']) && !$pstat['write']) { |
2839 | 2839 | $stat['locked'] = true; |
2840 | 2840 | } |
@@ -2892,7 +2892,7 @@ discard block |
||
2892 | 2892 | } |
2893 | 2893 | if (!isset($stat['url']) && $this->URL && $this->encoding) { |
2894 | 2894 | $_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1)); |
2895 | - $stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true))); |
|
2895 | + $stat['url'] = rtrim($this->URL, '/').'/'.str_replace('%2F', '/', rawurlencode($this->convEncIn($_path, true))); |
|
2896 | 2896 | } |
2897 | 2897 | } else { |
2898 | 2898 | if ($isDir) { |
@@ -3135,7 +3135,7 @@ discard block |
||
3135 | 3135 | * @return array |
3136 | 3136 | * @author Dmitry (dio) Levashov |
3137 | 3137 | **/ |
3138 | - protected function gettree($path, $deep, $exclude='') { |
|
3138 | + protected function gettree($path, $deep, $exclude = '') { |
|
3139 | 3139 | $dirs = array(); |
3140 | 3140 | |
3141 | 3141 | !isset($this->dirsCache[$path]) && $this->cacheDir($path); |
@@ -3146,7 +3146,7 @@ discard block |
||
3146 | 3146 | if ($stat && empty($stat['hidden']) && $p != $exclude && $stat['mime'] == 'directory') { |
3147 | 3147 | $dirs[] = $stat; |
3148 | 3148 | if ($deep > 0 && !empty($stat['dirs'])) { |
3149 | - $dirs = array_merge($dirs, $this->gettree($p, $deep-1)); |
|
3149 | + $dirs = array_merge($dirs, $this->gettree($p, $deep - 1)); |
|
3150 | 3150 | } |
3151 | 3151 | } |
3152 | 3152 | } |
@@ -3166,7 +3166,7 @@ discard block |
||
3166 | 3166 | protected function doSearch($path, $q, $mimes) { |
3167 | 3167 | $result = array(); |
3168 | 3168 | |
3169 | - foreach($this->scandirCE($path) as $p) { |
|
3169 | + foreach ($this->scandirCE($path) as $p) { |
|
3170 | 3170 | @set_time_limit(30); |
3171 | 3171 | $stat = $this->stat($p); |
3172 | 3172 | |
@@ -3187,7 +3187,7 @@ discard block |
||
3187 | 3187 | if ($this->encoding) { |
3188 | 3188 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
3189 | 3189 | } |
3190 | - $stat['url'] = $this->URL . $path; |
|
3190 | + $stat['url'] = $this->URL.$path; |
|
3191 | 3191 | } |
3192 | 3192 | |
3193 | 3193 | $result[] = $stat; |
@@ -3221,7 +3221,7 @@ discard block |
||
3221 | 3221 | if (!$this->inpathCE($target, $this->root)) { |
3222 | 3222 | return $this->setError(elFinder::ERROR_COPY, $this->path($srcStat['hash']), elFinder::ERROR_MKOUTLINK); |
3223 | 3223 | } |
3224 | - $stat = $this->stat($target); |
|
3224 | + $stat = $this->stat($target); |
|
3225 | 3225 | $this->clearcache(); |
3226 | 3226 | return $stat && $this->symlinkCE($target, $dst, $name) |
3227 | 3227 | ? $this->joinPathCE($dst, $name) |
@@ -3502,15 +3502,15 @@ discard block |
||
3502 | 3502 | } |
3503 | 3503 | |
3504 | 3504 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
3505 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3506 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3505 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
3506 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3507 | 3507 | } else { |
3508 | 3508 | |
3509 | 3509 | if ($this->options['tmbCrop']) { |
3510 | 3510 | |
3511 | 3511 | $result = $tmb; |
3512 | 3512 | /* Resize and crop if image bigger than thumbnail */ |
3513 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3513 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
3514 | 3514 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
3515 | 3515 | } |
3516 | 3516 | |
@@ -3527,7 +3527,7 @@ discard block |
||
3527 | 3527 | } |
3528 | 3528 | |
3529 | 3529 | if ($result) { |
3530 | - $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
3530 | + $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
3531 | 3531 | } |
3532 | 3532 | } |
3533 | 3533 | |
@@ -3568,18 +3568,18 @@ discard block |
||
3568 | 3568 | /* Resizing by biggest side */ |
3569 | 3569 | if ($resizeByBiggerSide) { |
3570 | 3570 | if ($orig_w > $orig_h) { |
3571 | - $size_h = round($orig_h * $width / $orig_w); |
|
3571 | + $size_h = round($orig_h*$width/$orig_w); |
|
3572 | 3572 | $size_w = $width; |
3573 | 3573 | } else { |
3574 | - $size_w = round($orig_w * $height / $orig_h); |
|
3574 | + $size_w = round($orig_w*$height/$orig_h); |
|
3575 | 3575 | $size_h = $height; |
3576 | 3576 | } |
3577 | 3577 | } else { |
3578 | 3578 | if ($orig_w > $orig_h) { |
3579 | - $size_w = round($orig_w * $height / $orig_h); |
|
3579 | + $size_w = round($orig_w*$height/$orig_h); |
|
3580 | 3580 | $size_h = $height; |
3581 | 3581 | } else { |
3582 | - $size_h = round($orig_h * $width / $orig_w); |
|
3582 | + $size_h = round($orig_h*$width/$orig_w); |
|
3583 | 3583 | $size_w = $width; |
3584 | 3584 | } |
3585 | 3585 | } |
@@ -3597,7 +3597,7 @@ discard block |
||
3597 | 3597 | // Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb |
3598 | 3598 | // resize bench: http://app-mgng.rhcloud.com/9 |
3599 | 3599 | // resize sample: http://www.dylanbeattie.net/magick/filters/result.html |
3600 | - $filter = ($destformat === 'png' /* createTmb */)? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3600 | + $filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS; |
|
3601 | 3601 | |
3602 | 3602 | $ani = ($img->getNumberImages() > 1); |
3603 | 3603 | if ($ani && is_null($destformat)) { |
@@ -3622,11 +3622,11 @@ discard block |
||
3622 | 3622 | break; |
3623 | 3623 | |
3624 | 3624 | case 'gd': |
3625 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3625 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3626 | 3626 | |
3627 | - if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3627 | + if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) { |
|
3628 | 3628 | |
3629 | - self::gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3629 | + self::gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3630 | 3630 | |
3631 | 3631 | if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) { |
3632 | 3632 | return false; |
@@ -3702,11 +3702,11 @@ discard block |
||
3702 | 3702 | break; |
3703 | 3703 | |
3704 | 3704 | case 'gd': |
3705 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3705 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3706 | 3706 | |
3707 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3707 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3708 | 3708 | |
3709 | - self::gdImageBackground($tmp,$this->options['tmbBgColor']); |
|
3709 | + self::gdImageBackground($tmp, $this->options['tmbBgColor']); |
|
3710 | 3710 | |
3711 | 3711 | $size_w = $width; |
3712 | 3712 | $size_h = $height; |
@@ -3756,8 +3756,8 @@ discard block |
||
3756 | 3756 | $result = false; |
3757 | 3757 | |
3758 | 3758 | /* Coordinates for image over square aligning */ |
3759 | - $y = ceil(abs($height - $s[1]) / 2); |
|
3760 | - $x = ceil(abs($width - $s[0]) / 2); |
|
3759 | + $y = ceil(abs($height - $s[1])/2); |
|
3760 | + $x = ceil(abs($width - $s[0])/2); |
|
3761 | 3761 | |
3762 | 3762 | switch ($this->imgLib) { |
3763 | 3763 | case 'imagick': |
@@ -3777,7 +3777,7 @@ discard block |
||
3777 | 3777 | $gif->newImage($width, $height, new ImagickPixel($bgcolor)); |
3778 | 3778 | $gif->setImageColorspace($img->getImageColorspace()); |
3779 | 3779 | $gif->setImageFormat('gif'); |
3780 | - $gif->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3780 | + $gif->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3781 | 3781 | $gif->setImageDelay($img->getImageDelay()); |
3782 | 3782 | $gif->setImageIterations($img->getImageIterations()); |
3783 | 3783 | $img1->addImage($gif); |
@@ -3793,7 +3793,7 @@ discard block |
||
3793 | 3793 | $img1->newImage($width, $height, new ImagickPixel($bgcolor)); |
3794 | 3794 | $img1->setImageColorspace($img->getImageColorspace()); |
3795 | 3795 | $img1->setImageFormat($destformat != null ? $destformat : $img->getFormat()); |
3796 | - $img1->compositeImage( $img, imagick::COMPOSITE_OVER, $x, $y ); |
|
3796 | + $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y); |
|
3797 | 3797 | $result = $img1->writeImage($path); |
3798 | 3798 | } |
3799 | 3799 | |
@@ -3804,11 +3804,11 @@ discard block |
||
3804 | 3804 | break; |
3805 | 3805 | |
3806 | 3806 | case 'gd': |
3807 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3807 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3808 | 3808 | |
3809 | - if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3809 | + if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
3810 | 3810 | |
3811 | - self::gdImageBackground($tmp,$bgcolor); |
|
3811 | + self::gdImageBackground($tmp, $bgcolor); |
|
3812 | 3812 | |
3813 | 3813 | if (!imagecopy($tmp, $img, $x, $y, 0, 0, $s[0], $s[1])) { |
3814 | 3814 | return false; |
@@ -3839,15 +3839,15 @@ discard block |
||
3839 | 3839 | * @author Troex Nevelin |
3840 | 3840 | **/ |
3841 | 3841 | protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null) { |
3842 | - if (($s = @getimagesize($path)) == false || $degree % 360 === 0) { |
|
3842 | + if (($s = @getimagesize($path)) == false || $degree%360 === 0) { |
|
3843 | 3843 | return false; |
3844 | 3844 | } |
3845 | 3845 | |
3846 | 3846 | $result = false; |
3847 | 3847 | |
3848 | 3848 | // try lossless rotate |
3849 | - if ($degree % 90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
3850 | - $count = ($degree / 90) % 4; |
|
3849 | + if ($degree%90 === 0 && in_array($s[2], array(IMAGETYPE_JPEG, IMAGETYPE_JPEG2000))) { |
|
3850 | + $count = ($degree/90)%4; |
|
3851 | 3851 | $exiftran = array( |
3852 | 3852 | 1 => '-9', |
3853 | 3853 | 2 => '-1', |
@@ -3863,7 +3863,7 @@ discard block |
||
3863 | 3863 | 'exiftran -i '.$exiftran[$count].' '.$path, |
3864 | 3864 | 'jpegtran -rotate '.$jpegtran[$count].' -copy all -outfile '.$quotedPath.' '.$quotedPath |
3865 | 3865 | ); |
3866 | - foreach($cmds as $cmd) { |
|
3866 | + foreach ($cmds as $cmd) { |
|
3867 | 3867 | if ($this->procExec($cmd) === 0) { |
3868 | 3868 | $result = true; |
3869 | 3869 | break; |
@@ -3899,12 +3899,12 @@ discard block |
||
3899 | 3899 | break; |
3900 | 3900 | |
3901 | 3901 | case 'gd': |
3902 | - $img = self::gdImageCreate($path,$s['mime']); |
|
3902 | + $img = self::gdImageCreate($path, $s['mime']); |
|
3903 | 3903 | |
3904 | 3904 | $degree = 360 - $degree; |
3905 | 3905 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
3906 | 3906 | $bgcolor = imagecolorallocate($img, $r, $g, $b); |
3907 | - $tmp = imageRotate($img, $degree, (int)$bgcolor); |
|
3907 | + $tmp = imageRotate($img, $degree, (int) $bgcolor); |
|
3908 | 3908 | |
3909 | 3909 | $result = self::gdImage($tmp, $path, $destformat, $s['mime']); |
3910 | 3910 | |
@@ -3929,11 +3929,11 @@ discard block |
||
3929 | 3929 | * @return int exit code |
3930 | 3930 | * @author Alexey Sukhotin |
3931 | 3931 | **/ |
3932 | - protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
3932 | + protected function procExec($command, array &$output = null, &$return_var = -1, array &$error_output = null) { |
|
3933 | 3933 | |
3934 | 3934 | $descriptorspec = array( |
3935 | - 0 => array("pipe", "r"), // stdin |
|
3936 | - 1 => array("pipe", "w"), // stdout |
|
3935 | + 0 => array("pipe", "r"), // stdin |
|
3936 | + 1 => array("pipe", "w"), // stdout |
|
3937 | 3937 | 2 => array("pipe", "w") // stderr |
3938 | 3938 | ); |
3939 | 3939 | |
@@ -3990,8 +3990,8 @@ discard block |
||
3990 | 3990 | * @param string $mime |
3991 | 3991 | * @return gd image resource identifier |
3992 | 3992 | */ |
3993 | - protected function gdImageCreate($path,$mime){ |
|
3994 | - switch($mime){ |
|
3993 | + protected function gdImageCreate($path, $mime) { |
|
3994 | + switch ($mime) { |
|
3995 | 3995 | case 'image/jpeg': |
3996 | 3996 | return imagecreatefromjpeg($path); |
3997 | 3997 | |
@@ -4015,7 +4015,7 @@ discard block |
||
4015 | 4015 | * @param string $destformat The Image type to use for $filename |
4016 | 4016 | * @param string $mime The original image mime type |
4017 | 4017 | */ |
4018 | - protected function gdImage($image, $filename, $destformat, $mime ){ |
|
4018 | + protected function gdImage($image, $filename, $destformat, $mime) { |
|
4019 | 4019 | |
4020 | 4020 | if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) { |
4021 | 4021 | return imagejpeg($image, $filename, 100); |
@@ -4034,13 +4034,13 @@ discard block |
||
4034 | 4034 | * @param resource $image gd image resource |
4035 | 4035 | * @param string $bgcolor background color in #rrggbb format |
4036 | 4036 | */ |
4037 | - protected function gdImageBackground($image, $bgcolor){ |
|
4037 | + protected function gdImageBackground($image, $bgcolor) { |
|
4038 | 4038 | |
4039 | - if( $bgcolor == 'transparent' ){ |
|
4040 | - imagesavealpha($image,true); |
|
4039 | + if ($bgcolor == 'transparent') { |
|
4040 | + imagesavealpha($image, true); |
|
4041 | 4041 | $bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127); |
4042 | 4042 | |
4043 | - }else{ |
|
4043 | + } else { |
|
4044 | 4044 | list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x"); |
4045 | 4045 | $bgcolor1 = imagecolorallocate($image, $r, $g, $b); |
4046 | 4046 | } |
@@ -4078,13 +4078,13 @@ discard block |
||
4078 | 4078 | * @return int|bool |
4079 | 4079 | * @author Alexey Sukhotin |
4080 | 4080 | **/ |
4081 | - protected function stripos($haystack , $needle , $offset = 0) { |
|
4081 | + protected function stripos($haystack, $needle, $offset = 0) { |
|
4082 | 4082 | if (function_exists('mb_stripos')) { |
4083 | - return mb_stripos($haystack , $needle , $offset); |
|
4083 | + return mb_stripos($haystack, $needle, $offset); |
|
4084 | 4084 | } else if (function_exists('mb_strtolower') && function_exists('mb_strpos')) { |
4085 | 4085 | return mb_strpos(mb_strtolower($haystack), mb_strtolower($needle), $offset); |
4086 | 4086 | } |
4087 | - return stripos($haystack , $needle , $offset); |
|
4087 | + return stripos($haystack, $needle, $offset); |
|
4088 | 4088 | } |
4089 | 4089 | |
4090 | 4090 | /** |
@@ -4134,22 +4134,22 @@ discard block |
||
4134 | 4134 | unset($o); |
4135 | 4135 | $this->procExec('zip -v', $o, $c); |
4136 | 4136 | if ($c == 0) { |
4137 | - $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4137 | + $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip'); |
|
4138 | 4138 | } |
4139 | 4139 | unset($o); |
4140 | 4140 | $this->procExec('unzip --help', $o, $c); |
4141 | 4141 | if ($c == 0) { |
4142 | - $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4142 | + $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip'); |
|
4143 | 4143 | } |
4144 | 4144 | unset($o); |
4145 | 4145 | $this->procExec('rar --version', $o, $c); |
4146 | 4146 | if ($c == 0 || $c == 7) { |
4147 | 4147 | $arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar'); |
4148 | - $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4148 | + $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar'); |
|
4149 | 4149 | } else { |
4150 | 4150 | unset($o); |
4151 | 4151 | $test = $this->procExec('unrar', $o, $c); |
4152 | - if ($c==0 || $c == 7) { |
|
4152 | + if ($c == 0 || $c == 7) { |
|
4153 | 4153 | $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar'); |
4154 | 4154 | } |
4155 | 4155 | } |
@@ -4171,7 +4171,7 @@ discard block |
||
4171 | 4171 | if (empty($arcs['extract']['application/x-tar'])) { |
4172 | 4172 | $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'x -ttar -y', 'ext' => 'tar'); |
4173 | 4173 | } |
4174 | - } else if (substr(PHP_OS,0,3) === 'WIN') { |
|
4174 | + } else if (substr(PHP_OS, 0, 3) === 'WIN') { |
|
4175 | 4175 | // check `7z` for Windows server. |
4176 | 4176 | unset($o); |
4177 | 4177 | $this->procExec('7z', $o, $c); |
@@ -4225,22 +4225,22 @@ discard block |
||
4225 | 4225 | |
4226 | 4226 | // normalize `/../` |
4227 | 4227 | $normreg = '#('.$sepquoted.')[^'.$sepquoted.']+'.$sepquoted.'\.\.'.$sepquoted.'#'; |
4228 | - while(preg_match($normreg, $path)) { |
|
4228 | + while (preg_match($normreg, $path)) { |
|
4229 | 4229 | $path = preg_replace($normreg, '$1', $path); |
4230 | 4230 | } |
4231 | 4231 | |
4232 | 4232 | // 'Here' |
4233 | - if ($path === '' || $path === '.' . $separator) return $base; |
|
4233 | + if ($path === '' || $path === '.'.$separator) return $base; |
|
4234 | 4234 | |
4235 | 4235 | // Absolute path |
4236 | 4236 | if ($path[0] === $separator || strpos($path, $systemroot) === 0) { |
4237 | 4237 | return $path; |
4238 | 4238 | } |
4239 | 4239 | |
4240 | - $preg_separator = '#' . $sepquoted . '#'; |
|
4240 | + $preg_separator = '#'.$sepquoted.'#'; |
|
4241 | 4241 | |
4242 | 4242 | // Relative path from 'Here' |
4243 | - if (substr($path, 0, 2) === '.' . $separator || $path[0] !== '.' || substr($path, 0, 3) !== '..' . $separator) { |
|
4243 | + if (substr($path, 0, 2) === '.'.$separator || $path[0] !== '.' || substr($path, 0, 3) !== '..'.$separator) { |
|
4244 | 4244 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4245 | 4245 | if ($arrn[0] !== '.') { |
4246 | 4246 | array_unshift($arrn, '.'); |
@@ -4254,12 +4254,11 @@ discard block |
||
4254 | 4254 | $arrn = preg_split($preg_separator, $path, -1, PREG_SPLIT_NO_EMPTY); |
4255 | 4255 | $arrp = preg_split($preg_separator, $base, -1, PREG_SPLIT_NO_EMPTY); |
4256 | 4256 | |
4257 | - while (! empty($arrn) && $arrn[0] === '..') { |
|
4257 | + while (!empty($arrn) && $arrn[0] === '..') { |
|
4258 | 4258 | array_shift($arrn); |
4259 | 4259 | array_pop($arrp); |
4260 | 4260 | } |
4261 | - $path = ! empty($arrp) ? $systemroot . join($separator, array_merge($arrp, $arrn)) : |
|
4262 | - (! empty($arrn) ? $systemroot . join($separator, $arrn) : $systemroot); |
|
4261 | + $path = !empty($arrp) ? $systemroot.join($separator, array_merge($arrp, $arrn)) : (!empty($arrn) ? $systemroot.join($separator, $arrn) : $systemroot); |
|
4263 | 4262 | } |
4264 | 4263 | |
4265 | 4264 | return $path; |
@@ -4277,7 +4276,7 @@ discard block |
||
4277 | 4276 | @chmod($dir, 0777); |
4278 | 4277 | foreach (array_diff(scandir($dir), array('.', '..')) as $file) { |
4279 | 4278 | @set_time_limit(30); |
4280 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4279 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4281 | 4280 | if (!is_link($dir) && is_dir($path)) { |
4282 | 4281 | $this->rmdirRecursive($path); |
4283 | 4282 | } else { |
@@ -4364,22 +4363,22 @@ discard block |
||
4364 | 4363 | try { |
4365 | 4364 | if ($start = is_string($zipPath)) { |
4366 | 4365 | $zip = new ZipArchive(); |
4367 | - if ($zip->open($dir . DIRECTORY_SEPARATOR . $zipPath, ZipArchive::CREATE) !== true) { |
|
4366 | + if ($zip->open($dir.DIRECTORY_SEPARATOR.$zipPath, ZipArchive::CREATE) !== true) { |
|
4368 | 4367 | $zip = false; |
4369 | 4368 | } |
4370 | 4369 | } else { |
4371 | 4370 | $zip = $zipPath; |
4372 | 4371 | } |
4373 | 4372 | if ($zip) { |
4374 | - foreach($files as $file) { |
|
4375 | - $path = $dir . DIRECTORY_SEPARATOR . $file; |
|
4373 | + foreach ($files as $file) { |
|
4374 | + $path = $dir.DIRECTORY_SEPARATOR.$file; |
|
4376 | 4375 | if (is_dir($path)) { |
4377 | 4376 | $zip->addEmptyDir($file); |
4378 | 4377 | $_files = array(); |
4379 | 4378 | if ($handle = opendir($path)) { |
4380 | 4379 | while (false !== ($entry = readdir($handle))) { |
4381 | 4380 | if ($entry !== "." && $entry !== "..") { |
4382 | - $_files[] = $file . DIRECTORY_SEPARATOR . $entry; |
|
4381 | + $_files[] = $file.DIRECTORY_SEPARATOR.$entry; |
|
4383 | 4382 | } |
4384 | 4383 | } |
4385 | 4384 | closedir($handle); |
@@ -4564,7 +4563,7 @@ discard block |
||
4564 | 4563 | * @return resource|false |
4565 | 4564 | * @author Dmitry (dio) Levashov |
4566 | 4565 | **/ |
4567 | - abstract protected function _fopen($path, $mode="rb"); |
|
4566 | + abstract protected function _fopen($path, $mode = "rb"); |
|
4568 | 4567 | |
4569 | 4568 | /** |
4570 | 4569 | * Close opened file |
@@ -4574,7 +4573,7 @@ discard block |
||
4574 | 4573 | * @return bool |
4575 | 4574 | * @author Dmitry (dio) Levashov |
4576 | 4575 | **/ |
4577 | - abstract protected function _fclose($fp, $path=''); |
|
4576 | + abstract protected function _fclose($fp, $path = ''); |
|
4578 | 4577 | |
4579 | 4578 | /******************** file/dir manipulations *************************/ |
4580 | 4579 |
@@ -234,7 +234,6 @@ discard block |
||
234 | 234 | * process of on netunmount |
235 | 235 | * Drop table `dropbox` & rm thumbs |
236 | 236 | * |
237 | - * @param array $options |
|
238 | 237 | * @return boolean |
239 | 238 | */ |
240 | 239 | public function netunmount($netVolumes, $key) { |
@@ -431,7 +430,7 @@ discard block |
||
431 | 430 | /** |
432 | 431 | * Check DB for delta cache |
433 | 432 | * |
434 | - * @return void |
|
433 | + * @return boolean |
|
435 | 434 | */ |
436 | 435 | private function checkDB() { |
437 | 436 | $res = $this->query('SELECT * FROM sqlite_master WHERE type=\'table\' AND name=\''.$this->DB_TableName.'\''); |
@@ -685,7 +684,7 @@ discard block |
||
685 | 684 | * @param string $src source path |
686 | 685 | * @param string $dst destination dir path |
687 | 686 | * @param string $name new file name (optionaly) |
688 | - * @return string|false |
|
687 | + * @return string|boolean |
|
689 | 688 | * @author Dmitry (dio) Levashov |
690 | 689 | * @author Naoki Sawada |
691 | 690 | **/ |
@@ -739,10 +738,6 @@ discard block |
||
739 | 738 | * Create thumnbnail and return it's URL on success |
740 | 739 | * |
741 | 740 | * @param string $path file path |
742 | - * @param string $mime file mime type |
|
743 | - * @return string|false |
|
744 | - * @author Dmitry (dio) Levashov |
|
745 | - * @author Naoki Sawada |
|
746 | 741 | **/ |
747 | 742 | protected function createTmb($path, $stat) { |
748 | 743 | if (!$stat || !$this->canCreateTmb($path, $stat)) { |
@@ -1099,7 +1094,6 @@ discard block |
||
1099 | 1094 | * Open file and return file pointer |
1100 | 1095 | * |
1101 | 1096 | * @param string $path file path |
1102 | - * @param bool $write open file for writing |
|
1103 | 1097 | * @return resource|false |
1104 | 1098 | * @author Dmitry (dio) Levashov |
1105 | 1099 | **/ |
@@ -1141,7 +1135,7 @@ discard block |
||
1141 | 1135 | * Close opened file |
1142 | 1136 | * |
1143 | 1137 | * @param resource $fp file pointer |
1144 | - * @return bool |
|
1138 | + * @return boolean|null |
|
1145 | 1139 | * @author Dmitry (dio) Levashov |
1146 | 1140 | **/ |
1147 | 1141 | protected function _fclose($fp, $path='') { |
@@ -1225,7 +1219,7 @@ discard block |
||
1225 | 1219 | * Return new file path or false. |
1226 | 1220 | * |
1227 | 1221 | * @param string $source source file path |
1228 | - * @param string $target target dir path |
|
1222 | + * @param string $targetDir target dir path |
|
1229 | 1223 | * @param string $name file name |
1230 | 1224 | * @return string|bool |
1231 | 1225 | * @author Dmitry (dio) Levashov |
@@ -1274,7 +1268,6 @@ discard block |
||
1274 | 1268 | * Return new file path or false on error. |
1275 | 1269 | * |
1276 | 1270 | * @param resource $fp file pointer |
1277 | - * @param string $dir target dir path |
|
1278 | 1271 | * @param string $name file name |
1279 | 1272 | * @param array $stat file stat (required by some virtual fs) |
1280 | 1273 | * @return bool|string |
@@ -1320,7 +1313,7 @@ discard block |
||
1320 | 1313 | * |
1321 | 1314 | * @param string $path file path |
1322 | 1315 | * @param string $content new file content |
1323 | - * @return bool |
|
1316 | + * @return boolean|string |
|
1324 | 1317 | * @author Dmitry (dio) Levashov |
1325 | 1318 | **/ |
1326 | 1319 | protected function _filePutContents($path, $content) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $options['url'] = $this->getConnectorUrl(); |
193 | 193 | } |
194 | 194 | $callback = $options['url'] |
195 | - . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
|
195 | + . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
|
196 | 196 | |
197 | 197 | try { |
198 | 198 | $tokens = $this->oauth->getRequestToken(); |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | */ |
266 | 266 | private function getConnectorUrl() { |
267 | 267 | $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
268 | - . $_SERVER['SERVER_NAME'] // host |
|
269 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
270 | - . $_SERVER['REQUEST_URI']; // path & query |
|
268 | + . $_SERVER['SERVER_NAME'] // host |
|
269 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
270 | + . $_SERVER['REQUEST_URI']; // path & query |
|
271 | 271 | list($url) = explode('?', $url); |
272 | 272 | return $url; |
273 | 273 | } |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
606 | 606 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
607 | 607 | $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
608 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
608 | + (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
609 | 609 | $stat['dirs'] = 0; |
610 | 610 | if ($raw['is_dir']) { |
611 | 611 | $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
@@ -648,14 +648,14 @@ discard block |
||
648 | 648 | } |
649 | 649 | |
650 | 650 | /** |
651 | - * Recursive files search |
|
652 | - * |
|
653 | - * @param string $path dir path |
|
654 | - * @param string $q search string |
|
655 | - * @param array $mimes |
|
656 | - * @return array |
|
657 | - * @author Naoki Sawada |
|
658 | - **/ |
|
651 | + * Recursive files search |
|
652 | + * |
|
653 | + * @param string $path dir path |
|
654 | + * @param string $q search string |
|
655 | + * @param array $mimes |
|
656 | + * @return array |
|
657 | + * @author Naoki Sawada |
|
658 | + **/ |
|
659 | 659 | protected function doSearch($path, $q, $mimes) { |
660 | 660 | $result = array(); |
661 | 661 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
@@ -679,16 +679,16 @@ discard block |
||
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
682 | - * Copy file/recursive copy dir only in current volume. |
|
683 | - * Return new file path or false. |
|
684 | - * |
|
685 | - * @param string $src source path |
|
686 | - * @param string $dst destination dir path |
|
687 | - * @param string $name new file name (optionaly) |
|
688 | - * @return string|false |
|
689 | - * @author Dmitry (dio) Levashov |
|
690 | - * @author Naoki Sawada |
|
691 | - **/ |
|
682 | + * Copy file/recursive copy dir only in current volume. |
|
683 | + * Return new file path or false. |
|
684 | + * |
|
685 | + * @param string $src source path |
|
686 | + * @param string $dst destination dir path |
|
687 | + * @param string $name new file name (optionaly) |
|
688 | + * @return string|false |
|
689 | + * @author Dmitry (dio) Levashov |
|
690 | + * @author Naoki Sawada |
|
691 | + **/ |
|
692 | 692 | protected function copy($src, $dst, $name) { |
693 | 693 | |
694 | 694 | $this->clearcache(); |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
702 | - * Remove file/ recursive remove dir |
|
703 | - * |
|
704 | - * @param string $path file path |
|
705 | - * @param bool $force try to remove even if file locked |
|
706 | - * @return bool |
|
707 | - * @author Dmitry (dio) Levashov |
|
708 | - * @author Naoki Sawada |
|
709 | - **/ |
|
702 | + * Remove file/ recursive remove dir |
|
703 | + * |
|
704 | + * @param string $path file path |
|
705 | + * @param bool $force try to remove even if file locked |
|
706 | + * @return bool |
|
707 | + * @author Dmitry (dio) Levashov |
|
708 | + * @author Naoki Sawada |
|
709 | + **/ |
|
710 | 710 | protected function remove($path, $force = false, $recursive = false) { |
711 | 711 | $stat = $this->stat($path); |
712 | 712 | $stat['realpath'] = $path; |
@@ -736,14 +736,14 @@ discard block |
||
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
739 | - * Create thumnbnail and return it's URL on success |
|
740 | - * |
|
741 | - * @param string $path file path |
|
742 | - * @param string $mime file mime type |
|
743 | - * @return string|false |
|
744 | - * @author Dmitry (dio) Levashov |
|
745 | - * @author Naoki Sawada |
|
746 | - **/ |
|
739 | + * Create thumnbnail and return it's URL on success |
|
740 | + * |
|
741 | + * @param string $path file path |
|
742 | + * @param string $mime file mime type |
|
743 | + * @return string|false |
|
744 | + * @author Dmitry (dio) Levashov |
|
745 | + * @author Naoki Sawada |
|
746 | + **/ |
|
747 | 747 | protected function createTmb($path, $stat) { |
748 | 748 | if (!$stat || !$this->canCreateTmb($path, $stat)) { |
749 | 749 | return false; |
@@ -828,13 +828,13 @@ discard block |
||
828 | 828 | } |
829 | 829 | |
830 | 830 | /** |
831 | - * Return content URL |
|
832 | - * |
|
833 | - * @param string $hash file hash |
|
834 | - * @param array $options options |
|
835 | - * @return array |
|
836 | - * @author Naoki Sawada |
|
837 | - **/ |
|
831 | + * Return content URL |
|
832 | + * |
|
833 | + * @param string $hash file hash |
|
834 | + * @param array $options options |
|
835 | + * @return array |
|
836 | + * @author Naoki Sawada |
|
837 | + **/ |
|
838 | 838 | public function getContentUrl($hash, $options = array()) { |
839 | 839 | if (($file = $this->file($hash)) == false || !$file['url'] || $file['url'] == 1) { |
840 | 840 | $path = $this->decode($hash); |
@@ -897,9 +897,9 @@ discard block |
||
897 | 897 | try { |
898 | 898 | $request2 = new HTTP_Request2(); |
899 | 899 | $request2->setConfig(array( |
900 | - 'ssl_verify_peer' => false, |
|
901 | - 'ssl_verify_host' => false |
|
902 | - )); |
|
900 | + 'ssl_verify_peer' => false, |
|
901 | + 'ssl_verify_host' => false |
|
902 | + )); |
|
903 | 903 | $request2->setUrl($url); |
904 | 904 | $request2->setMethod(HTTP_Request2::METHOD_HEAD); |
905 | 905 | $result = $request2->send(); |
@@ -132,8 +132,12 @@ discard block |
||
132 | 132 | * @author Naoki Sawada |
133 | 133 | **/ |
134 | 134 | public function netmountPrepare($options) { |
135 | - if (empty($options['consumerKey']) && defined('ELFINDER_DROPBOX_CONSUMERKEY')) $options['consumerKey'] = ELFINDER_DROPBOX_CONSUMERKEY; |
|
136 | - if (empty($options['consumerSecret']) && defined('ELFINDER_DROPBOX_CONSUMERSECRET')) $options['consumerSecret'] = ELFINDER_DROPBOX_CONSUMERSECRET; |
|
135 | + if (empty($options['consumerKey']) && defined('ELFINDER_DROPBOX_CONSUMERKEY')) { |
|
136 | + $options['consumerKey'] = ELFINDER_DROPBOX_CONSUMERKEY; |
|
137 | + } |
|
138 | + if (empty($options['consumerSecret']) && defined('ELFINDER_DROPBOX_CONSUMERSECRET')) { |
|
139 | + $options['consumerSecret'] = ELFINDER_DROPBOX_CONSUMERSECRET; |
|
140 | + } |
|
137 | 141 | |
138 | 142 | if ($options['user'] === 'init') { |
139 | 143 | |
@@ -616,8 +620,12 @@ discard block |
||
616 | 620 | } else { |
617 | 621 | $stat['url'] = '1'; |
618 | 622 | } |
619 | - if (isset($raw['width'])) $stat['width'] = $raw['width']; |
|
620 | - if (isset($raw['height'])) $stat['height'] = $raw['height']; |
|
623 | + if (isset($raw['width'])) { |
|
624 | + $stat['width'] = $raw['width']; |
|
625 | + } |
|
626 | + if (isset($raw['height'])) { |
|
627 | + $stat['height'] = $raw['height']; |
|
628 | + } |
|
621 | 629 | |
622 | 630 | return $stat; |
623 | 631 | } |
@@ -1061,7 +1069,9 @@ discard block |
||
1061 | 1069 | * @author Dmitry (dio) Levashov |
1062 | 1070 | **/ |
1063 | 1071 | protected function _dimensions($path, $mime) { |
1064 | - if (strpos($mime, 'image') !== 0) return ''; |
|
1072 | + if (strpos($mime, 'image') !== 0) { |
|
1073 | + return ''; |
|
1074 | + } |
|
1065 | 1075 | $cache = $this->getDBdat($path); |
1066 | 1076 | if (isset($cache['width']) && isset($cache['height'])) { |
1067 | 1077 | return $cache['width'].'x'.$cache['height']; |
@@ -1281,7 +1291,9 @@ discard block |
||
1281 | 1291 | * @author Dmitry (dio) Levashov |
1282 | 1292 | **/ |
1283 | 1293 | protected function _save($fp, $path, $name, $stat) { |
1284 | - if ($name) $path .= '/'.$name; |
|
1294 | + if ($name) { |
|
1295 | + $path .= '/'.$name; |
|
1296 | + } |
|
1285 | 1297 | $path = $this->_normpath($path); |
1286 | 1298 | try { |
1287 | 1299 | $this->dropbox->putFile($path, $fp); |
@@ -1291,8 +1303,12 @@ discard block |
||
1291 | 1303 | $this->deltaCheck(); |
1292 | 1304 | if (is_array($stat)) { |
1293 | 1305 | $raw = $this->getDBdat($path); |
1294 | - if (isset($stat['width'])) $raw['width'] = $stat['width']; |
|
1295 | - if (isset($stat['height'])) $raw['height'] = $stat['height']; |
|
1306 | + if (isset($stat['width'])) { |
|
1307 | + $raw['width'] = $stat['width']; |
|
1308 | + } |
|
1309 | + if (isset($stat['height'])) { |
|
1310 | + $raw['height'] = $stat['height']; |
|
1311 | + } |
|
1296 | 1312 | $this->updateDBdat($path, $raw); |
1297 | 1313 | } |
1298 | 1314 | return $path; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | if ($options['user'] === 'init') { |
139 | 139 | |
140 | - if (! $this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) { |
|
140 | + if (!$this->dropbox_phpFound || empty($options['consumerKey']) || empty($options['consumerSecret']) || !class_exists('PDO')) { |
|
141 | 141 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
142 | 142 | } |
143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | if (class_exists('OAuth')) { |
148 | 148 | $this->oauth = new Dropbox_OAuth_PHP($options['consumerKey'], $options['consumerSecret']); |
149 | 149 | } else { |
150 | - if (! class_exists('HTTP_OAuth_Consumer')) { |
|
150 | + if (!class_exists('HTTP_OAuth_Consumer')) { |
|
151 | 151 | // We're going to try to load in manually |
152 | 152 | include 'HTTP/OAuth/Consumer.php'; |
153 | 153 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - if (! $this->oauth) { |
|
160 | + if (!$this->oauth) { |
|
161 | 161 | return array('exit' => true, 'body' => '{msg:errNetMountNoDriver}'); |
162 | 162 | } |
163 | 163 | |
@@ -178,24 +178,24 @@ discard block |
||
178 | 178 | unset($_SESSION['elFinderDropboxTokens']); |
179 | 179 | } |
180 | 180 | } |
181 | - if (! $html) { |
|
181 | + if (!$html) { |
|
182 | 182 | // get customdata |
183 | 183 | $cdata = ''; |
184 | 184 | $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); |
185 | - foreach($this->ARGS as $k => $v) { |
|
186 | - if (! in_array($k, $innerKeys)) { |
|
187 | - $cdata .= '&' . $k . '=' . rawurlencode($v); |
|
185 | + foreach ($this->ARGS as $k => $v) { |
|
186 | + if (!in_array($k, $innerKeys)) { |
|
187 | + $cdata .= '&'.$k.'='.rawurlencode($v); |
|
188 | 188 | } |
189 | 189 | } |
190 | - if (strpos($options['url'], 'http') !== 0 ) { |
|
190 | + if (strpos($options['url'], 'http') !== 0) { |
|
191 | 191 | $options['url'] = $this->getConnectorUrl(); |
192 | 192 | } |
193 | - $callback = $options['url'] |
|
193 | + $callback = $options['url'] |
|
194 | 194 | . '?cmd=netmount&protocol=dropbox&host=dropbox.com&user=init&pass=return&node='.$options['id'].$cdata; |
195 | 195 | |
196 | 196 | try { |
197 | 197 | $tokens = $this->oauth->getRequestToken(); |
198 | - $url= $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
198 | + $url = $this->oauth->getAuthorizeUrl(rawurlencode($callback)); |
|
199 | 199 | } catch (Dropbox_Exception $e) { |
200 | 200 | return array('exit' => true, 'body' => '{msg:errAccess}'); |
201 | 201 | } |
@@ -242,14 +242,14 @@ discard block |
||
242 | 242 | if (isset($netVolumes[$key])) { |
243 | 243 | $dropboxUid = $netVolumes[$key]['dropboxUid']; |
244 | 244 | } |
245 | - foreach($netVolumes as $volume) { |
|
245 | + foreach ($netVolumes as $volume) { |
|
246 | 246 | if (@$volume['host'] === 'dropbox' && @$volume['dropboxUid'] === $dropboxUid) { |
247 | 247 | $count++; |
248 | 248 | } |
249 | 249 | } |
250 | 250 | if ($count === 1) { |
251 | 251 | $this->DB->exec('drop table '.$this->DB_TableName); |
252 | - foreach(glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
252 | + foreach (glob(rtrim($this->options['tmbPath'], '\\/').DIRECTORY_SEPARATOR.$this->tmbPrefix.'*.png') as $tmb) { |
|
253 | 253 | unlink($tmb); |
254 | 254 | } |
255 | 255 | } |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * @author Naoki Sawada |
264 | 264 | */ |
265 | 265 | private function getConnectorUrl() { |
266 | - $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')? 'https://' : 'http://') |
|
266 | + $url = ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https://' : 'http://') |
|
267 | 267 | . $_SERVER['SERVER_NAME'] // host |
268 | - . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) // port |
|
269 | - . $_SERVER['REQUEST_URI']; // path & query |
|
268 | + . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) // port |
|
269 | + . $_SERVER['REQUEST_URI']; // path & query |
|
270 | 270 | list($url) = explode('?', $url); |
271 | 271 | return $url; |
272 | 272 | } |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | // make net mount key |
303 | 303 | $this->netMountKey = md5(join('-', array('dropbox', $this->options['path']))); |
304 | 304 | |
305 | - if (! $this->oauth) { |
|
305 | + if (!$this->oauth) { |
|
306 | 306 | if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) { |
307 | 307 | $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']); |
308 | 308 | } else { |
309 | 309 | if (class_exists('OAuth')) { |
310 | 310 | $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']); |
311 | 311 | } else { |
312 | - if (! class_exists('HTTP_OAuth_Consumer')) { |
|
312 | + if (!class_exists('HTTP_OAuth_Consumer')) { |
|
313 | 313 | // We're going to try to load in manually |
314 | 314 | include 'HTTP/OAuth/Consumer.php'; |
315 | 315 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - if (! $this->oauth) { |
|
323 | + if (!$this->oauth) { |
|
324 | 324 | return $this->setError('OAuth extension not loaded.'); |
325 | 325 | } |
326 | 326 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $this->root = $this->options['path'] = $this->_normpath($this->options['path']); |
329 | 329 | |
330 | 330 | if (empty($this->options['alias'])) { |
331 | - $this->options['alias'] = ($this->options['path'] === '/')? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
331 | + $this->options['alias'] = ($this->options['path'] === '/') ? 'Dropbox.com' : 'Dropbox'.$this->options['path']; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | $this->rootName = $this->options['alias']; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | |
386 | 386 | // setup PDO |
387 | - if (! $this->options['PDO_DSN']) { |
|
387 | + if (!$this->options['PDO_DSN']) { |
|
388 | 388 | $this->options['PDO_DSN'] = 'sqlite:'.$this->metaCache.DIRECTORY_SEPARATOR.'.elFinder_dropbox_db_'.md5($this->dropboxUid.$this->options['consumerSecret']); |
389 | 389 | } |
390 | 390 | // DataBase table name |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | // DataBase check or make table |
393 | 393 | try { |
394 | 394 | $this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']); |
395 | - if (! $this->checkDB()) { |
|
395 | + if (!$this->checkDB()) { |
|
396 | 396 | return $this->setError('Can not make DB table'); |
397 | 397 | } |
398 | 398 | } catch (PDOException $e) { |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | $res = false; |
444 | 444 | } |
445 | 445 | } |
446 | - if (! $res) { |
|
446 | + if (!$res) { |
|
447 | 447 | try { |
448 | 448 | $this->DB->exec('CREATE TABLE '.$this->DB_TableName.'(path text, fname text, dat blob, isdir integer);'); |
449 | 449 | $this->DB->exec('CREATE UNIQUE INDEX nameidx ON '.$this->DB_TableName.'(path, fname)'); |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | */ |
494 | 494 | private function updateDBdat($path, $dat) { |
495 | 495 | return $this->query('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($dat)) |
496 | - . ', isdir=' . ($dat['is_dir']? 1 : 0) |
|
496 | + . ', isdir='.($dat['is_dir'] ? 1 : 0) |
|
497 | 497 | . ' where path='.$this->DB->quote(strtolower(dirname($path))).' and fname='.$this->DB->quote(strtolower(basename($path)))); |
498 | 498 | } |
499 | 499 | /*********************************************************************/ |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | */ |
519 | 519 | protected function deltaCheck($refresh = true) { |
520 | 520 | $chk = false; |
521 | - if (! $refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
521 | + if (!$refresh && $chk = $this->query('select dat from '.$this->DB_TableName.' where path=\'\' and fname=\'\' limit 1')) { |
|
522 | 522 | $chk = unserialize($chk[0]); |
523 | 523 | } |
524 | 524 | if ($chk && ($chk['mtime'] + $this->options['metaCacheTime']) > $_SERVER['REQUEST_TIME']) { |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | do { |
541 | 541 | @ ini_set('max_execution_time', 120); |
542 | 542 | $_info = $this->dropbox->delta($cursor); |
543 | - if (! empty($_info['reset'])) { |
|
543 | + if (!empty($_info['reset'])) { |
|
544 | 544 | $this->DB->exec('TRUNCATE table '.$this->DB_TableName); |
545 | 545 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'\', \'\', \''.serialize(array('cursor' => '', 'mtime' => 0)).'\', 0);'); |
546 | 546 | $this->DB->exec('insert into '.$this->DB_TableName.' values(\'/\', \'\', \''.serialize(array( |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | } |
554 | 554 | $cursor = $_info['cursor']; |
555 | 555 | |
556 | - foreach($_info['entries'] as $entry) { |
|
556 | + foreach ($_info['entries'] as $entry) { |
|
557 | 557 | $key = strtolower($entry[0]); |
558 | 558 | $pkey = strtolower(dirname($key)); |
559 | 559 | |
@@ -563,27 +563,27 @@ discard block |
||
563 | 563 | |
564 | 564 | if (empty($entry[1])) { |
565 | 565 | $this->DB->exec('delete from '.$this->DB_TableName.' '.$where); |
566 | - ! $delete && $delete = true; |
|
566 | + !$delete && $delete = true; |
|
567 | 567 | continue; |
568 | 568 | } |
569 | 569 | |
570 | 570 | $sql = 'select path from '.$this->DB_TableName.' '.$where.' limit 1'; |
571 | - if (! $reset && $this->query($sql)) { |
|
572 | - $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir']? 1 : 0).' ' .$where); |
|
571 | + if (!$reset && $this->query($sql)) { |
|
572 | + $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize($entry[1])).', isdir='.($entry[1]['is_dir'] ? 1 : 0).' '.$where); |
|
573 | 573 | } else { |
574 | - $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int)$entry[1]['is_dir'].')'); |
|
574 | + $this->DB->exec('insert into '.$this->DB_TableName.' values ('.$path.', '.$fname.', '.$this->DB->quote(serialize($entry[1])).', '.(int) $entry[1]['is_dir'].')'); |
|
575 | 575 | } |
576 | 576 | } |
577 | - } while (! empty($_info['has_more'])); |
|
577 | + } while (!empty($_info['has_more'])); |
|
578 | 578 | $this->DB->exec('update '.$this->DB_TableName.' set dat='.$this->DB->quote(serialize(array('cursor'=>$cursor, 'mtime'=>$_SERVER['REQUEST_TIME']))).' where path=\'\' and fname=\'\''); |
579 | - if (! $this->DB->commit()) { |
|
579 | + if (!$this->DB->commit()) { |
|
580 | 580 | $e = $this->DB->errorInfo(); |
581 | 581 | return $e[2]; |
582 | 582 | } |
583 | 583 | if ($delete) { |
584 | 584 | $this->DB->exec('vacuum'); |
585 | 585 | } |
586 | - } catch(Dropbox_Exception $e) { |
|
586 | + } catch (Dropbox_Exception $e) { |
|
587 | 587 | return $e->getMessage(); |
588 | 588 | } |
589 | 589 | return true; |
@@ -599,15 +599,14 @@ discard block |
||
599 | 599 | protected function parseRaw($raw) { |
600 | 600 | $stat = array(); |
601 | 601 | |
602 | - $stat['rev'] = isset($raw['rev'])? $raw['rev'] : 'root'; |
|
602 | + $stat['rev'] = isset($raw['rev']) ? $raw['rev'] : 'root'; |
|
603 | 603 | $stat['name'] = basename($raw['path']); |
604 | - $stat['mime'] = $raw['is_dir']? 'directory' : $raw['mime_type']; |
|
604 | + $stat['mime'] = $raw['is_dir'] ? 'directory' : $raw['mime_type']; |
|
605 | 605 | $stat['size'] = $stat['mime'] == 'directory' ? 0 : $raw['bytes']; |
606 | - $stat['ts'] = isset($raw['client_mtime'])? strtotime($raw['client_mtime']) : |
|
607 | - (isset($raw['modified'])? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
606 | + $stat['ts'] = isset($raw['client_mtime']) ? strtotime($raw['client_mtime']) : (isset($raw['modified']) ? strtotime($raw['modified']) : $_SERVER['REQUEST_TIME']); |
|
608 | 607 | $stat['dirs'] = 0; |
609 | 608 | if ($raw['is_dir']) { |
610 | - $stat['dirs'] = (int)(bool)$this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
609 | + $stat['dirs'] = (int) (bool) $this->query('select path from '.$this->DB_TableName.' where isdir=1 and path='.$this->DB->quote(strtolower($raw['path']))); |
|
611 | 610 | } |
612 | 611 | |
613 | 612 | if (!empty($raw['url'])) { |
@@ -633,7 +632,7 @@ discard block |
||
633 | 632 | $res = $this->query('select dat from '.$this->DB_TableName.' where path='.$this->DB->quote(strtolower($path))); |
634 | 633 | |
635 | 634 | if ($res) { |
636 | - foreach($res as $raw) { |
|
635 | + foreach ($res as $raw) { |
|
637 | 636 | $raw = unserialize($raw); |
638 | 637 | if ($stat = $this->parseRaw($raw)) { |
639 | 638 | $stat = $this->updateCache($raw['path'], $stat); |
@@ -658,10 +657,10 @@ discard block |
||
658 | 657 | protected function doSearch($path, $q, $mimes) { |
659 | 658 | $result = array(); |
660 | 659 | $sth = $this->DB->prepare('select dat from '.$this->DB_TableName.' WHERE path LIKE ? AND fname LIKE ?'); |
661 | - $sth->execute(array('%'.(($path === '/')? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
660 | + $sth->execute(array('%'.(($path === '/') ? '' : strtolower($path)), '%'.strtolower($q).'%')); |
|
662 | 661 | $res = $sth->fetchAll(PDO::FETCH_COLUMN); |
663 | 662 | if ($res) { |
664 | - foreach($res as $raw) { |
|
663 | + foreach ($res as $raw) { |
|
665 | 664 | $raw = unserialize($raw); |
666 | 665 | if ($stat = $this->parseRaw($raw)) { |
667 | 666 | if (!isset($this->cache[$raw['path']])) { |
@@ -752,10 +751,10 @@ discard block |
||
752 | 751 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
753 | 752 | |
754 | 753 | // copy image into tmbPath so some drivers does not store files on local fs |
755 | - if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
754 | + if (!$data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
756 | 755 | return false; |
757 | 756 | } |
758 | - if (! file_put_contents($tmb, $data)) { |
|
757 | + if (!file_put_contents($tmb, $data)) { |
|
759 | 758 | return false; |
760 | 759 | } |
761 | 760 | |
@@ -768,15 +767,15 @@ discard block |
||
768 | 767 | } |
769 | 768 | |
770 | 769 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
771 | - if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
772 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
770 | + if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
771 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
773 | 772 | |
774 | 773 | } else { |
775 | 774 | |
776 | 775 | if ($this->options['tmbCrop']) { |
777 | 776 | |
778 | 777 | /* Resize and crop if image bigger than thumbnail */ |
779 | - if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
778 | + if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
780 | 779 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
781 | 780 | } |
782 | 781 | |
@@ -790,7 +789,7 @@ discard block |
||
790 | 789 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
791 | 790 | } |
792 | 791 | |
793 | - $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' ); |
|
792 | + $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
794 | 793 | } |
795 | 794 | |
796 | 795 | if (!$result) { |
@@ -847,7 +846,7 @@ discard block |
||
847 | 846 | } |
848 | 847 | } |
849 | 848 | } |
850 | - if (! $url) { |
|
849 | + if (!$url) { |
|
851 | 850 | try { |
852 | 851 | $res = $this->dropbox->share($path, null, false); |
853 | 852 | $url = $res['url']; |
@@ -859,7 +858,7 @@ discard block |
||
859 | 858 | } |
860 | 859 | list($url) = explode('?', $url); |
861 | 860 | $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url); |
862 | - if (! isset($cache['share']) || $cache['share'] !== $url) { |
|
861 | + if (!isset($cache['share']) || $cache['share'] !== $url) { |
|
863 | 862 | $cache['share'] = $url; |
864 | 863 | $this->updateDBdat($path, $cache); |
865 | 864 | } |
@@ -883,12 +882,12 @@ discard block |
||
883 | 882 | if (function_exists('curl_exec')) { |
884 | 883 | |
885 | 884 | $c = curl_init(); |
886 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
|
887 | - curl_setopt( $c, CURLOPT_CUSTOMREQUEST, 'HEAD' ); |
|
888 | - curl_setopt( $c, CURLOPT_HEADER, 1 ); |
|
889 | - curl_setopt( $c, CURLOPT_NOBODY, true ); |
|
890 | - curl_setopt( $c, CURLOPT_URL, $url ); |
|
891 | - $res = curl_exec( $c ); |
|
885 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
886 | + curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
887 | + curl_setopt($c, CURLOPT_HEADER, 1); |
|
888 | + curl_setopt($c, CURLOPT_NOBODY, true); |
|
889 | + curl_setopt($c, CURLOPT_URL, $url); |
|
890 | + $res = curl_exec($c); |
|
892 | 891 | |
893 | 892 | } else { |
894 | 893 | |
@@ -904,13 +903,13 @@ discard block |
||
904 | 903 | $result = $request2->send(); |
905 | 904 | $res = array(); |
906 | 905 | $res[] = 'HTTP/'.$result->getVersion().' '.$result->getStatus().' '.$result->getReasonPhrase(); |
907 | - foreach($result->getHeader() as $key => $val) { |
|
908 | - $res[] = $key . ': ' . $val; |
|
906 | + foreach ($result->getHeader() as $key => $val) { |
|
907 | + $res[] = $key.': '.$val; |
|
909 | 908 | } |
910 | 909 | $res = join("\r\n", $res); |
911 | - } catch( HTTP_Request2_Exception $e ){ |
|
910 | + } catch (HTTP_Request2_Exception $e) { |
|
912 | 911 | $res = ''; |
913 | - } catch (Exception $e){ |
|
912 | + } catch (Exception $e) { |
|
914 | 913 | $res = ''; |
915 | 914 | } |
916 | 915 | |
@@ -963,7 +962,7 @@ discard block |
||
963 | 962 | **/ |
964 | 963 | protected function _normpath($path) { |
965 | 964 | $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); |
966 | - $path = '/' . ltrim($path, '/'); |
|
965 | + $path = '/'.ltrim($path, '/'); |
|
967 | 966 | return $path; |
968 | 967 | } |
969 | 968 | |
@@ -1102,7 +1101,7 @@ discard block |
||
1102 | 1101 | * @return resource|false |
1103 | 1102 | * @author Dmitry (dio) Levashov |
1104 | 1103 | **/ |
1105 | - protected function _fopen($path, $mode='rb') { |
|
1104 | + protected function _fopen($path, $mode = 'rb') { |
|
1106 | 1105 | |
1107 | 1106 | if (($mode == 'rb' || $mode == 'r')) { |
1108 | 1107 | try { |
@@ -1112,7 +1111,7 @@ discard block |
||
1112 | 1111 | fputs($fp, "GET {$url['path']} HTTP/1.0\r\n"); |
1113 | 1112 | fputs($fp, "Host: {$url['host']}\r\n"); |
1114 | 1113 | fputs($fp, "\r\n"); |
1115 | - while(trim(fgets($fp)) !== ''){}; |
|
1114 | + while (trim(fgets($fp)) !== '') {}; |
|
1116 | 1115 | return $fp; |
1117 | 1116 | } catch (Dropbox_Exception $e) { |
1118 | 1117 | return false; |
@@ -1143,7 +1142,7 @@ discard block |
||
1143 | 1142 | * @return bool |
1144 | 1143 | * @author Dmitry (dio) Levashov |
1145 | 1144 | **/ |
1146 | - protected function _fclose($fp, $path='') { |
|
1145 | + protected function _fclose($fp, $path = '') { |
|
1147 | 1146 | @fclose($fp); |
1148 | 1147 | if ($path) { |
1149 | 1148 | @unlink($this->getTempFile($path)); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * Return ftp transfer mode for file |
478 | 478 | * |
479 | 479 | * @param string $path file path |
480 | - * @return string |
|
480 | + * @return integer |
|
481 | 481 | * @author Dmitry (dio) Levashov |
482 | 482 | **/ |
483 | 483 | protected function ftpMode($path) { |
@@ -841,7 +841,6 @@ discard block |
||
841 | 841 | * Open file and return file pointer |
842 | 842 | * |
843 | 843 | * @param string $path file path |
844 | - * @param bool $write open file for writing |
|
845 | 844 | * @return resource|false |
846 | 845 | * @author Dmitry (dio) Levashov |
847 | 846 | **/ |
@@ -866,7 +865,7 @@ discard block |
||
866 | 865 | * Close opened file |
867 | 866 | * |
868 | 867 | * @param resource $fp file pointer |
869 | - * @return bool |
|
868 | + * @return boolean|null |
|
870 | 869 | * @author Dmitry (dio) Levashov |
871 | 870 | **/ |
872 | 871 | protected function _fclose($fp, $path='') { |
@@ -883,7 +882,7 @@ discard block |
||
883 | 882 | * |
884 | 883 | * @param string $path parent dir path |
885 | 884 | * @param string $name new directory name |
886 | - * @return string|bool |
|
885 | + * @return false|string |
|
887 | 886 | * @author Dmitry (dio) Levashov |
888 | 887 | **/ |
889 | 888 | protected function _mkdir($path, $name) { |
@@ -901,7 +900,7 @@ discard block |
||
901 | 900 | * |
902 | 901 | * @param string $path parent dir path |
903 | 902 | * @param string $name new file name |
904 | - * @return string|bool |
|
903 | + * @return string|false |
|
905 | 904 | * @author Dmitry (dio) Levashov |
906 | 905 | **/ |
907 | 906 | protected function _mkfile($path, $name) { |
@@ -933,7 +932,7 @@ discard block |
||
933 | 932 | * @param string $source source file path |
934 | 933 | * @param string $targetDir target directory path |
935 | 934 | * @param string $name new file name |
936 | - * @return bool |
|
935 | + * @return string|false |
|
937 | 936 | * @author Dmitry (dio) Levashov |
938 | 937 | **/ |
939 | 938 | protected function _copy($source, $targetDir, $name) { |
@@ -958,9 +957,9 @@ discard block |
||
958 | 957 | * Return new file path or false. |
959 | 958 | * |
960 | 959 | * @param string $source source file path |
961 | - * @param string $target target dir path |
|
960 | + * @param string $targetDir target dir path |
|
962 | 961 | * @param string $name file name |
963 | - * @return string|bool |
|
962 | + * @return string|false |
|
964 | 963 | * @author Dmitry (dio) Levashov |
965 | 964 | **/ |
966 | 965 | protected function _move($source, $targetDir, $name) { |
@@ -998,7 +997,7 @@ discard block |
||
998 | 997 | * @param string $dir target dir path |
999 | 998 | * @param string $name file name |
1000 | 999 | * @param array $stat file stat (required by some virtual fs) |
1001 | - * @return bool|string |
|
1000 | + * @return string|false |
|
1002 | 1001 | * @author Dmitry (dio) Levashov |
1003 | 1002 | **/ |
1004 | 1003 | protected function _save($fp, $dir, $name, $stat) { |
@@ -1231,7 +1230,7 @@ discard block |
||
1231 | 1230 | * @param array $files files names list |
1232 | 1231 | * @param string $name archive name |
1233 | 1232 | * @param array $arc archiver options |
1234 | - * @return string|bool |
|
1233 | + * @return false|string |
|
1235 | 1234 | * @author Dmitry (dio) Levashov, |
1236 | 1235 | * @author Alexey Sukhotin |
1237 | 1236 | **/ |
@@ -1350,9 +1349,9 @@ discard block |
||
1350 | 1349 | * Downloads specified files from remote directory |
1351 | 1350 | * if there is a directory among files it is downloaded recursively (omitting symbolic links). |
1352 | 1351 | * |
1353 | - * @param $remote_directory string remote FTP path to a source directory to download from. |
|
1352 | + * @param string $remote_directory string remote FTP path to a source directory to download from. |
|
1354 | 1353 | * @param array $files list of files to download from remote directory. |
1355 | - * @param $dest_local_directory string destination folder to store downloaded files. |
|
1354 | + * @param string $dest_local_directory string destination folder to store downloaded files. |
|
1356 | 1355 | * @return bool true on success and false on failure. |
1357 | 1356 | */ |
1358 | 1357 | private function ftp_download_files($remote_directory, array $files, $dest_local_directory) |
@@ -1423,6 +1422,7 @@ discard block |
||
1423 | 1422 | * Returns array of strings containing all files and folders in the specified local directory. |
1424 | 1423 | * @param $dir |
1425 | 1424 | * @param string $prefix |
1425 | + * @param boolean $omitSymlinks |
|
1426 | 1426 | * @internal param string $path path to directory to scan. |
1427 | 1427 | * @return array array of files and folders names relative to the $path |
1428 | 1428 | * or an empty array if the directory $path is empty, |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ); |
104 | 104 | $this->options = array_merge($this->options, $opts); |
105 | 105 | $this->options['mimeDetect'] = 'internal'; |
106 | - $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
106 | + $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $scheme = parse_url($this->options['host'], PHP_URL_SCHEME); |
164 | 164 | |
165 | 165 | if ($scheme) { |
166 | - $this->options['host'] = substr($this->options['host'], strlen($scheme)+3); |
|
166 | + $this->options['host'] = substr($this->options['host'], strlen($scheme) + 3); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // normalize root path |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | if ($this->encoding) { |
236 | 236 | @ftp_exec($this->connect, 'OPTS UTF8 OFF'); |
237 | 237 | } else { |
238 | - @ftp_exec($this->connect, 'OPTS UTF8 ON' ); |
|
238 | + @ftp_exec($this->connect, 'OPTS UTF8 ON'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // switch off extended passive mode - may be usefull for some servers |
242 | - @ftp_exec($this->connect, 'epsv4 off' ); |
|
242 | + @ftp_exec($this->connect, 'epsv4 off'); |
|
243 | 243 | // enter passive mode if required |
244 | 244 | ftp_pasv($this->connect, $this->options['mode'] == 'passive'); |
245 | 245 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $name = $info[8]; |
308 | 308 | |
309 | 309 | if (preg_match('|(.+)\-\>(.+)|', $name, $m)) { |
310 | - $name = trim($m[1]); |
|
310 | + $name = trim($m[1]); |
|
311 | 311 | // check recursive processing |
312 | 312 | if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) { |
313 | 313 | return array(); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $stat['owner'] = $info[2]; |
344 | 344 | $stat['group'] = $info[3]; |
345 | 345 | $stat['perm'] = substr($info[0], 1); |
346 | - $stat['isowner'] = $stat['owner']? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
346 | + $stat['isowner'] = $stat['owner'] ? ($stat['owner'] == $this->options['user']) : $this->options['owner']; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | $perm = $this->parsePermissions($info[0], $stat['owner']); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $info[4] = 0; |
376 | 376 | $info[0] = 'drwxr-xr-x'; |
377 | 377 | } else { |
378 | - $info[4] = (int)$size; |
|
378 | + $info[4] = (int) $size; |
|
379 | 379 | $info[0] = '-rw-r--r--'; |
380 | 380 | } |
381 | 381 | return $info; |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | protected function parsePermissions($perm, $user = '') { |
392 | 392 | $res = array(); |
393 | 393 | $parts = array(); |
394 | - $owner = $user? ($user == $this->options['user']) : $this->options['owner']; |
|
394 | + $owner = $user ? ($user == $this->options['user']) : $this->options['owner']; |
|
395 | 395 | for ($i = 0, $l = strlen($perm); $i < $l; $i++) { |
396 | 396 | $parts[] = substr($perm, $i, 1); |
397 | 397 | } |
@@ -422,10 +422,10 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | $list = $this->convEncOut($list); |
425 | - $prefix = ($path === $this->separator)? $this->separator : $path . $this->separator; |
|
425 | + $prefix = ($path === $this->separator) ? $this->separator : $path.$this->separator; |
|
426 | 426 | $targets = array(); |
427 | - foreach($list as $stat) { |
|
428 | - $p = $prefix . $stat['name']; |
|
427 | + foreach ($list as $stat) { |
|
428 | + $p = $prefix.$stat['name']; |
|
429 | 429 | if (isset($stat['target'])) { |
430 | 430 | // stat later |
431 | 431 | $targets[$stat['name']] = $stat['target']; |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | } |
438 | 438 | } |
439 | 439 | // stat link targets |
440 | - foreach($targets as $name => $target) { |
|
440 | + foreach ($targets as $name => $target) { |
|
441 | 441 | $stat = array(); |
442 | 442 | $stat['name'] = $name; |
443 | - $p = $prefix . $name; |
|
443 | + $p = $prefix.$name; |
|
444 | 444 | $cacheDirTarget = $this->cacheDirTarget; |
445 | 445 | $this->cacheDirTarget = $this->convEncIn($target, true); |
446 | 446 | if ($tstat = $this->stat($target)) { |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | $stat['thash'] = $tstat['hash']; |
450 | 450 | $stat['mime'] = $tstat['mime']; |
451 | 451 | $stat['read'] = $tstat['read']; |
452 | - $stat['write'] = $tstat['write']; |
|
452 | + $stat['write'] = $tstat['write']; |
|
453 | 453 | |
454 | - if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
455 | - if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
456 | - if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
457 | - if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
454 | + if (isset($tstat['ts'])) { $stat['ts'] = $tstat['ts']; } |
|
455 | + if (isset($tstat['owner'])) { $stat['owner'] = $tstat['owner']; } |
|
456 | + if (isset($tstat['group'])) { $stat['group'] = $tstat['group']; } |
|
457 | + if (isset($tstat['perm'])) { $stat['perm'] = $tstat['perm']; } |
|
458 | 458 | if (isset($tstat['isowner'])) { $stat['isowner'] = $tstat['isowner']; } |
459 | 459 | } else { |
460 | 460 | |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $comps = $new_comps; |
568 | 568 | $path = implode($this->separator, $comps); |
569 | 569 | if ($initial_slashes) { |
570 | - $path = str_repeat($this->separator, $initial_slashes) . $path; |
|
570 | + $path = str_repeat($this->separator, $initial_slashes).$path; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | return $path ? $path : '.'; |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * @author Dmitry (dio) Levashov |
634 | 634 | **/ |
635 | 635 | protected function _inpath($path, $parent) { |
636 | - return $path == $parent || strpos($path, $parent. $this->separator) === 0; |
|
636 | + return $path == $parent || strpos($path, $parent.$this->separator) === 0; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /***************** file stat ********************/ |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | ); |
673 | 673 | } |
674 | 674 | $this->cacheDir($this->convEncOut($this->_dirname($path))); |
675 | - return $this->convEncIn(isset($this->cache[$outPath])? $this->cache[$outPath] : array()); |
|
675 | + return $this->convEncIn(isset($this->cache[$outPath]) ? $this->cache[$outPath] : array()); |
|
676 | 676 | } |
677 | - $raw = ftp_raw($this->connect, 'MLST ' . $path); |
|
677 | + $raw = ftp_raw($this->connect, 'MLST '.$path); |
|
678 | 678 | if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) { |
679 | 679 | $parts = explode(';', trim($raw[1])); |
680 | 680 | array_pop($parts); |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | |
705 | 705 | case 'perm': |
706 | 706 | $val = strtolower($val); |
707 | - $stat['read'] = (int)preg_match('/e|l|r/', $val); |
|
708 | - $stat['write'] = (int)preg_match('/w|m|c/', $val); |
|
707 | + $stat['read'] = (int) preg_match('/e|l|r/', $val); |
|
708 | + $stat['write'] = (int) preg_match('/w|m|c/', $val); |
|
709 | 709 | if (!preg_match('/f|d/', $val)) { |
710 | 710 | $stat['locked'] = 1; |
711 | 711 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | if (!$this->ftpOsUnix) { |
791 | 791 | $info = $this->normalizeRawWindows($str); |
792 | 792 | } |
793 | - $name = isset($info[8])? trim($info[8]) : ''; |
|
793 | + $name = isset($info[8]) ? trim($info[8]) : ''; |
|
794 | 794 | if ($name && $name !== '.' && $name !== '..' && substr(strtolower($info[0]), 0, 1) === 'd') { |
795 | 795 | return true; |
796 | 796 | } |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * @return resource|false |
846 | 846 | * @author Dmitry (dio) Levashov |
847 | 847 | **/ |
848 | - protected function _fopen($path, $mode='rb') { |
|
848 | + protected function _fopen($path, $mode = 'rb') { |
|
849 | 849 | |
850 | 850 | if ($this->tmp) { |
851 | 851 | $local = $this->getTempFile($path); |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * @return bool |
870 | 870 | * @author Dmitry (dio) Levashov |
871 | 871 | **/ |
872 | - protected function _fclose($fp, $path='') { |
|
872 | + protected function _fclose($fp, $path = '') { |
|
873 | 873 | @fclose($fp); |
874 | 874 | if ($path) { |
875 | 875 | @unlink($this->getTempFile($path)); |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | if (@file_put_contents($local, $content, LOCK_EX) !== false |
1045 | 1045 | && ($fp = @fopen($local, 'rb'))) { |
1046 | 1046 | clearstatcache(); |
1047 | - $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
1047 | + $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path)); |
|
1048 | 1048 | @fclose($fp); |
1049 | 1049 | } |
1050 | 1050 | file_exists($local) && @unlink($local); |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | * @return bool |
1070 | 1070 | **/ |
1071 | 1071 | protected function _chmod($path, $mode) { |
1072 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
1072 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
1073 | 1073 | return @ftp_chmod($this->connect, $modeOct, $path); |
1074 | 1074 | } |
1075 | 1075 | |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | $basename = $this->_basename($path); |
1125 | - $localPath = $dir . DIRECTORY_SEPARATOR . $basename; |
|
1125 | + $localPath = $dir.DIRECTORY_SEPARATOR.$basename; |
|
1126 | 1126 | |
1127 | 1127 | if (!ftp_get($this->connect, $localPath, $path, FTP_BINARY)) { |
1128 | 1128 | //cleanup |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | // archive contains one item - extract in archive dir |
1161 | 1161 | $name = ''; |
1162 | - $src = $dir . DIRECTORY_SEPARATOR . $filesToProcess[0]; |
|
1162 | + $src = $dir.DIRECTORY_SEPARATOR.$filesToProcess[0]; |
|
1163 | 1163 | if (($extractTo === 'auto' || !$extractTo) && count($filesToProcess) === 1 && is_file($src)) { |
1164 | 1164 | $name = $filesToProcess[0]; |
1165 | 1165 | } else if ($extractTo === 'auto' || $extractTo) { |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | $src = $dir; |
1169 | 1169 | $name = basename($path); |
1170 | 1170 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
1171 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
1171 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
1172 | 1172 | } |
1173 | 1173 | $test = $this->_joinPath(dirname($path), $name); |
1174 | 1174 | if ($this->stat($test)) { |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | if ($name !== '' && is_file($src)) { |
1180 | 1180 | $result = $this->_joinPath(dirname($path), $name); |
1181 | 1181 | |
1182 | - if (! ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
1182 | + if (!ftp_put($this->connect, $result, $src, FTP_BINARY)) { |
|
1183 | 1183 | $this->rmdirRecursive($dir); |
1184 | 1184 | return false; |
1185 | 1185 | } |
@@ -1193,19 +1193,19 @@ discard block |
||
1193 | 1193 | } |
1194 | 1194 | $result[] = $dstDir; |
1195 | 1195 | } |
1196 | - foreach($filesToProcess as $name) { |
|
1196 | + foreach ($filesToProcess as $name) { |
|
1197 | 1197 | $name = rtrim($name, DIRECTORY_SEPARATOR); |
1198 | - $src = $dir . DIRECTORY_SEPARATOR . $name; |
|
1198 | + $src = $dir.DIRECTORY_SEPARATOR.$name; |
|
1199 | 1199 | if (is_dir($src)) { |
1200 | 1200 | $p = dirname($name); |
1201 | 1201 | $name = basename($name); |
1202 | - if (! $target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
1202 | + if (!$target = $this->_mkdir($this->_joinPath($dstDir, $p), $name)) { |
|
1203 | 1203 | $this->rmdirRecursive($dir); |
1204 | 1204 | return false; |
1205 | 1205 | } |
1206 | 1206 | } else { |
1207 | 1207 | $target = $this->_joinPath($dstDir, $name); |
1208 | - if (! ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
1208 | + if (!ftp_put($this->connect, $target, $src, FTP_BINARY)) { |
|
1209 | 1209 | $this->rmdirRecursive($dir); |
1210 | 1210 | return false; |
1211 | 1211 | } |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | is_dir($dir) && $this->rmdirRecursive($dir); |
1222 | 1222 | |
1223 | 1223 | $this->clearcache(); |
1224 | - return $result? $result : false; |
|
1224 | + return $result ? $result : false; |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | /** |
@@ -1261,7 +1261,7 @@ discard block |
||
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | //cleanup |
1264 | - if(!$this->rmdirRecursive($tmpDir)) { |
|
1264 | + if (!$this->rmdirRecursive($tmpDir)) { |
|
1265 | 1265 | return false; |
1266 | 1266 | } |
1267 | 1267 | |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | $remoteDirLen = strlen($remote_directory); |
1366 | 1366 | foreach ($contents as $item) { |
1367 | 1367 | $relative_path = substr($item['path'], $remoteDirLen); |
1368 | - $local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path; |
|
1368 | + $local_path = $dest_local_directory.DIRECTORY_SEPARATOR.$relative_path; |
|
1369 | 1369 | switch ($item['type']) { |
1370 | 1370 | case 'd': |
1371 | 1371 | $success = mkdir($local_path); |
@@ -1396,8 +1396,8 @@ discard block |
||
1396 | 1396 | } else { |
1397 | 1397 | $success = true; |
1398 | 1398 | foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) { |
1399 | - $path = $dirPath . DIRECTORY_SEPARATOR . $path; |
|
1400 | - if(is_link($path)) { |
|
1399 | + $path = $dirPath.DIRECTORY_SEPARATOR.$path; |
|
1400 | + if (is_link($path)) { |
|
1401 | 1401 | unlink($path); |
1402 | 1402 | } else if (is_dir($path)) { |
1403 | 1403 | $success = rmdir($path); |
@@ -1408,11 +1408,11 @@ discard block |
||
1408 | 1408 | break; |
1409 | 1409 | } |
1410 | 1410 | } |
1411 | - if($success) { |
|
1411 | + if ($success) { |
|
1412 | 1412 | $success = rmdir($dirPath); |
1413 | 1413 | } |
1414 | 1414 | } |
1415 | - if(!$success) { |
|
1415 | + if (!$success) { |
|
1416 | 1416 | $this->setError(elFinder::ERROR_RM, $dirPath); |
1417 | 1417 | return false; |
1418 | 1418 | } |
@@ -1434,25 +1434,25 @@ discard block |
||
1434 | 1434 | if (!is_dir($dir)) { |
1435 | 1435 | return false; |
1436 | 1436 | } |
1437 | - $excludes = array(".",".."); |
|
1437 | + $excludes = array(".", ".."); |
|
1438 | 1438 | $result = array(); |
1439 | 1439 | $files = scandir($dir); |
1440 | - if(!$files) { |
|
1440 | + if (!$files) { |
|
1441 | 1441 | return array(); |
1442 | 1442 | } |
1443 | - foreach($files as $file) { |
|
1444 | - if(!in_array($file, $excludes)) { |
|
1443 | + foreach ($files as $file) { |
|
1444 | + if (!in_array($file, $excludes)) { |
|
1445 | 1445 | $path = $dir.DIRECTORY_SEPARATOR.$file; |
1446 | - if(is_link($path)) { |
|
1447 | - if($omitSymlinks) { |
|
1446 | + if (is_link($path)) { |
|
1447 | + if ($omitSymlinks) { |
|
1448 | 1448 | continue; |
1449 | 1449 | } else { |
1450 | 1450 | $result[] = $prefix.$file; |
1451 | 1451 | } |
1452 | - } else if(is_dir($path)) { |
|
1452 | + } else if (is_dir($path)) { |
|
1453 | 1453 | $result[] = $prefix.$file.DIRECTORY_SEPARATOR; |
1454 | 1454 | $subs = elFinderVolumeFTP::listFilesInDirectory($path, $omitSymlinks, $prefix.$file.DIRECTORY_SEPARATOR); |
1455 | - if($subs) { |
|
1455 | + if ($subs) { |
|
1456 | 1456 | $result = array_merge($result, $subs); |
1457 | 1457 | } |
1458 | 1458 |
@@ -593,7 +593,6 @@ discard block |
||
593 | 593 | * Open file and return file pointer |
594 | 594 | * |
595 | 595 | * @param string $path file path |
596 | - * @param bool $write open file for writing |
|
597 | 596 | * @return resource|false |
598 | 597 | * @author Dmitry (dio) Levashov |
599 | 598 | **/ |
@@ -619,7 +618,7 @@ discard block |
||
619 | 618 | * |
620 | 619 | * @param string $path parent dir path |
621 | 620 | * @param string $name new directory name |
622 | - * @return string|bool |
|
621 | + * @return string|false |
|
623 | 622 | * @author Dmitry (dio) Levashov |
624 | 623 | **/ |
625 | 624 | protected function _mkdir($path, $name) { |
@@ -639,7 +638,7 @@ discard block |
||
639 | 638 | * |
640 | 639 | * @param string $path parent dir path |
641 | 640 | * @param string $name new file name |
642 | - * @return string|bool |
|
641 | + * @return string|false |
|
643 | 642 | * @author Dmitry (dio) Levashov |
644 | 643 | **/ |
645 | 644 | protected function _mkfile($path, $name) { |
@@ -687,9 +686,9 @@ discard block |
||
687 | 686 | * Return new file path or false. |
688 | 687 | * |
689 | 688 | * @param string $source source file path |
690 | - * @param string $target target dir path |
|
689 | + * @param string $targetDir target dir path |
|
691 | 690 | * @param string $name file name |
692 | - * @return string|bool |
|
691 | + * @return string|false |
|
693 | 692 | * @author Dmitry (dio) Levashov |
694 | 693 | **/ |
695 | 694 | protected function _move($source, $targetDir, $name) { |
@@ -733,7 +732,7 @@ discard block |
||
733 | 732 | * @param string $dir target dir path |
734 | 733 | * @param string $name file name |
735 | 734 | * @param array $stat file stat (required by some virtual fs) |
736 | - * @return bool|string |
|
735 | + * @return false|string |
|
737 | 736 | * @author Dmitry (dio) Levashov |
738 | 737 | **/ |
739 | 738 | protected function _save($fp, $dir, $name, $stat) { |
@@ -761,7 +760,7 @@ discard block |
||
761 | 760 | * Get file contents |
762 | 761 | * |
763 | 762 | * @param string $path file path |
764 | - * @return string|false |
|
763 | + * @return string |
|
765 | 764 | * @author Dmitry (dio) Levashov |
766 | 765 | **/ |
767 | 766 | protected function _getContents($path) { |
@@ -965,7 +964,7 @@ discard block |
||
965 | 964 | * @param array $files files names list |
966 | 965 | * @param string $name archive name |
967 | 966 | * @param array $arc archiver options |
968 | - * @return string|bool |
|
967 | + * @return string|false |
|
969 | 968 | * @author Dmitry (dio) Levashov, |
970 | 969 | * @author Alexey Sukhotin |
971 | 970 | **/ |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * @author Dmitry (dio) Levashov |
33 | 33 | **/ |
34 | 34 | public function __construct() { |
35 | - $this->options['alias'] = ''; // alias to replace root dir name |
|
36 | - $this->options['dirMode'] = 0755; // new dirs mode |
|
37 | - $this->options['fileMode'] = 0644; // new files mode |
|
38 | - $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) |
|
39 | - $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
35 | + $this->options['alias'] = ''; // alias to replace root dir name |
|
36 | + $this->options['dirMode'] = 0755; // new dirs mode |
|
37 | + $this->options['fileMode'] = 0644; // new files mode |
|
38 | + $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden) |
|
39 | + $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit) |
|
40 | 40 | $this->options['rootCssClass'] = 'elfinder-navbar-root-local'; |
41 | 41 | } |
42 | 42 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | protected function init() { |
54 | 54 | // Normalize directory separator for windows |
55 | 55 | if (DIRECTORY_SEPARATOR !== '/') { |
56 | - foreach(array('path', 'tmpPath', 'quarantine') as $key) { |
|
56 | + foreach (array('path', 'tmpPath', 'quarantine') as $key) { |
|
57 | 57 | if ($this->options[$key]) { |
58 | 58 | $this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]); |
59 | 59 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // if no thumbnails url - try detect it |
100 | 100 | if ($root['read'] && !$this->tmbURL && $this->URL) { |
101 | 101 | if (strpos($this->tmbPath, $this->root) === 0) { |
102 | - $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1)); |
|
102 | + $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1)); |
|
103 | 103 | if (preg_match("|[^/?&=]$|", $this->tmbURL)) { |
104 | 104 | $this->tmbURL .= '/'; |
105 | 105 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @author Dmitry (dio) Levashov |
176 | 176 | **/ |
177 | 177 | protected function _joinPath($dir, $name) { |
178 | - return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; |
|
178 | + return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $comps = $new_comps; |
228 | 228 | $path = implode('/', $comps); |
229 | 229 | if ($initial_slashes) { |
230 | - $path = str_repeat('/', $initial_slashes) . $path; |
|
230 | + $path = str_repeat('/', $initial_slashes).$path; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if ($changeSep) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | **/ |
299 | 299 | protected function _inpath($path, $parent) { |
300 | 300 | $cwd = getcwd(); |
301 | - $real_path = $this->getFullPath($path, $cwd); |
|
301 | + $real_path = $this->getFullPath($path, $cwd); |
|
302 | 302 | $real_parent = $this->getFullPath($parent, $cwd); |
303 | 303 | if ($real_path && $real_parent) { |
304 | 304 | return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0; |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $stat = array(); |
358 | 358 | return $stat; |
359 | 359 | } else { |
360 | - $stat['mime'] = 'symlink-broken'; |
|
360 | + $stat['mime'] = 'symlink-broken'; |
|
361 | 361 | $target = readlink($path); |
362 | 362 | $lstat = lstat($path); |
363 | 363 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $fstat = stat($path); |
374 | 374 | $uid = $fstat['uid']; |
375 | 375 | $gid = $fstat['gid']; |
376 | - $stat['perm'] = substr((string)decoct($fstat['mode']), -4); |
|
376 | + $stat['perm'] = substr((string) decoct($fstat['mode']), -4); |
|
377 | 377 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
378 | 378 | } |
379 | 379 | |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | $stat['mime'] = $dir ? 'directory' : $this->mimetype($path); |
384 | 384 | } |
385 | 385 | //logical rights first |
386 | - $stat['read'] = ($linkreadable || is_readable($path))? null : false; |
|
387 | - $stat['write'] = is_writable($path)? null : false; |
|
386 | + $stat['read'] = ($linkreadable || is_readable($path)) ? null : false; |
|
387 | + $stat['write'] = is_writable($path) ? null : false; |
|
388 | 388 | |
389 | 389 | if (is_null($stat['read'])) { |
390 | 390 | $stat['size'] = $dir ? 0 : $size; |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | protected function _subdirs($path) { |
454 | 454 | |
455 | 455 | if (is_dir($path)) { |
456 | - return (bool)glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
456 | + return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
457 | 457 | } |
458 | 458 | return false; |
459 | 459 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $br = true; |
535 | 535 | } else { |
536 | 536 | $_path = $fpath; |
537 | - $stat['mime'] = 'symlink-broken'; |
|
537 | + $stat['mime'] = 'symlink-broken'; |
|
538 | 538 | $target = readlink($_path); |
539 | 539 | $lstat = lstat($_path); |
540 | 540 | $ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']); |
@@ -559,13 +559,13 @@ discard block |
||
559 | 559 | if ($statOwner && !$linkreadable) { |
560 | 560 | $uid = $file->getOwner(); |
561 | 561 | $gid = $file->getGroup(); |
562 | - $stat['perm'] = substr((string)decoct($file->getPerms()), -4); |
|
562 | + $stat['perm'] = substr((string) decoct($file->getPerms()), -4); |
|
563 | 563 | $stat = array_merge($stat, $this->getOwnerStat($uid, $gid)); |
564 | 564 | } |
565 | 565 | |
566 | 566 | //logical rights first |
567 | - $stat['read'] = ($linkreadable || $file->isReadable())? null : false; |
|
568 | - $stat['write'] = $file->isWritable()? null : false; |
|
567 | + $stat['read'] = ($linkreadable || $file->isReadable()) ? null : false; |
|
568 | + $stat['write'] = $file->isWritable() ? null : false; |
|
569 | 569 | |
570 | 570 | if (is_null($stat['read'])) { |
571 | 571 | $stat['size'] = $dir ? 0 : $size; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | |
582 | 582 | if ($cache) { |
583 | 583 | $cache = $this->convEncOut($cache, false); |
584 | - foreach($cache as $d) { |
|
584 | + foreach ($cache as $d) { |
|
585 | 585 | $this->updateCache($d[0], $d[1]); |
586 | 586 | } |
587 | 587 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @return resource|false |
598 | 598 | * @author Dmitry (dio) Levashov |
599 | 599 | **/ |
600 | - protected function _fopen($path, $mode='rb') { |
|
600 | + protected function _fopen($path, $mode = 'rb') { |
|
601 | 601 | return @fopen($path, $mode); |
602 | 602 | } |
603 | 603 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @return bool |
609 | 609 | * @author Dmitry (dio) Levashov |
610 | 610 | **/ |
611 | - protected function _fclose($fp, $path='') { |
|
611 | + protected function _fclose($fp, $path = '') { |
|
612 | 612 | return @fclose($fp); |
613 | 613 | } |
614 | 614 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | $path = $this->_joinPath($dir, $name); |
741 | 741 | |
742 | 742 | $meta = stream_get_meta_data($fp); |
743 | - $uri = isset($meta['uri'])? $meta['uri'] : ''; |
|
743 | + $uri = isset($meta['uri']) ? $meta['uri'] : ''; |
|
744 | 744 | if ($uri && @is_file($uri)) { |
745 | 745 | fclose($fp); |
746 | 746 | if (!@rename($uri, $path) && !@copy($uri, $path)) { |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | * @return bool |
801 | 801 | **/ |
802 | 802 | protected function _chmod($path, $mode) { |
803 | - $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); |
|
803 | + $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); |
|
804 | 804 | $ret = @chmod($path, $modeOct); |
805 | 805 | $ret && clearstatcache(); |
806 | 806 | return $ret; |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | $src = $dir; |
919 | 919 | $name = basename($path); |
920 | 920 | if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) { |
921 | - $name = substr($name, 0, strlen($name)-strlen($m[0])); |
|
921 | + $name = substr($name, 0, strlen($name) - strlen($m[0])); |
|
922 | 922 | } |
923 | 923 | $test = dirname($path).DIRECTORY_SEPARATOR.$name; |
924 | 924 | if (file_exists($test) || is_link($test)) { |
@@ -927,9 +927,9 @@ discard block |
||
927 | 927 | } |
928 | 928 | |
929 | 929 | if ($name !== '') { |
930 | - $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
930 | + $result = dirname($path).DIRECTORY_SEPARATOR.$name; |
|
931 | 931 | |
932 | - if (! @rename($src, $result)) { |
|
932 | + if (!@rename($src, $result)) { |
|
933 | 933 | $this->delTree($dir); |
934 | 934 | return false; |
935 | 935 | } |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | $dstDir = dirname($path); |
938 | 938 | $res = false; |
939 | 939 | $result = array(); |
940 | - foreach($ls as $name) { |
|
940 | + foreach ($ls as $name) { |
|
941 | 941 | $target = $dstDir.DIRECTORY_SEPARATOR.$name; |
942 | 942 | if (is_dir($target)) { |
943 | 943 | $this->delTree($target); |
@@ -1013,14 +1013,14 @@ discard block |
||
1013 | 1013 | $result = array(); |
1014 | 1014 | |
1015 | 1015 | $path = $this->convEncIn($path); |
1016 | - $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); |
|
1017 | - $match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'.$q.'*', GLOB_NOSORT); |
|
1016 | + $dirs = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); |
|
1017 | + $match = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'.$q.'*', GLOB_NOSORT); |
|
1018 | 1018 | if ($dirs) { |
1019 | 1019 | $dirs = $this->convEncOut($dirs, false); |
1020 | 1020 | } |
1021 | 1021 | $match = $this->convEncOut($match); |
1022 | 1022 | if ($match) { |
1023 | - foreach($match as $p) { |
|
1023 | + foreach ($match as $p) { |
|
1024 | 1024 | $stat = $this->stat($p); |
1025 | 1025 | |
1026 | 1026 | if (!$stat) { // invalid links |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | if ($this->encoding) { |
1041 | 1041 | $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); |
1042 | 1042 | } |
1043 | - $stat['url'] = $this->URL . $path; |
|
1043 | + $stat['url'] = $this->URL.$path; |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | $result[] = $stat; |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | if ($dirs) { |
1051 | - foreach($dirs as $dir) { |
|
1051 | + foreach ($dirs as $dir) { |
|
1052 | 1052 | $stat = $this->stat($dir); |
1053 | 1053 | if ($stat['read'] && !isset($stat['alias'])) { |
1054 | 1054 | @set_time_limit(30); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * Close opened file |
612 | 612 | * |
613 | 613 | * @param resource $fp file pointer |
614 | - * @return bool |
|
614 | + * @return boolean|null |
|
615 | 615 | * @author Dmitry (dio) Levashov |
616 | 616 | **/ |
617 | 617 | protected function _fclose($fp, $path='') { |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @param string $path parent dir path |
630 | 630 | * @param string $name new directory name |
631 | - * @return string|bool |
|
631 | + * @return string|false |
|
632 | 632 | * @author Dmitry (dio) Levashov |
633 | 633 | **/ |
634 | 634 | protected function _mkdir($path, $name) { |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @param string $path parent dir path |
642 | 642 | * @param string $name new file name |
643 | - * @return string|bool |
|
643 | + * @return string|false |
|
644 | 644 | * @author Dmitry (dio) Levashov |
645 | 645 | **/ |
646 | 646 | protected function _mkfile($path, $name) { |
@@ -684,9 +684,9 @@ discard block |
||
684 | 684 | * Return new file path or false. |
685 | 685 | * |
686 | 686 | * @param string $source source file path |
687 | - * @param string $target target dir path |
|
687 | + * @param string $targetDir target dir path |
|
688 | 688 | * @param string $name file name |
689 | - * @return string|bool |
|
689 | + * @return string|false |
|
690 | 690 | * @author Dmitry (dio) Levashov |
691 | 691 | **/ |
692 | 692 | protected function _move($source, $targetDir, $name) { |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * |
870 | 870 | * @param string $path archive path |
871 | 871 | * @param array $arc archiver command and arguments (same as in $this->archivers) |
872 | - * @return true |
|
872 | + * @return boolean |
|
873 | 873 | * @author Dmitry (dio) Levashov, |
874 | 874 | * @author Alexey Sukhotin |
875 | 875 | **/ |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * @param array $files files names list |
885 | 885 | * @param string $name archive name |
886 | 886 | * @param array $arc archiver options |
887 | - * @return string|bool |
|
887 | + * @return boolean |
|
888 | 888 | * @author Dmitry (dio) Levashov, |
889 | 889 | * @author Alexey Sukhotin |
890 | 890 | **/ |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $dirs = array(); |
312 | 312 | if ($path != $this->root) { |
313 | 313 | $inpath = array(intval($path)); |
314 | - while($inpath) { |
|
314 | + while ($inpath) { |
|
315 | 315 | $in = '('.join(',', $inpath).')'; |
316 | 316 | $inpath = array(); |
317 | 317 | $sql = 'SELECT f.id FROM %s AS f WHERE f.parent_id IN '.$in.' AND `mime` = \'directory\''; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | if ($mimes) { |
332 | 332 | $whrs = array(); |
333 | - foreach($mimes as $mime) { |
|
333 | + foreach ($mimes as $mime) { |
|
334 | 334 | if (strpos($mime, '/') === false) { |
335 | 335 | $whrs[] = sprintf('f.mime LIKE "%s/%%"', $this->db->real_escape_string($mime)); |
336 | 336 | } else { |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $whr = sprintf('f.name RLIKE "%s"', $this->db->real_escape_string($q)); |
343 | 343 | } |
344 | 344 | if ($dirs) { |
345 | - $whr = '(' . $whr . ') AND (`parent_id` IN (' . join(',', $dirs) . '))'; |
|
345 | + $whr = '('.$whr.') AND (`parent_id` IN ('.join(',', $dirs).'))'; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | $sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | * @return resource|false |
588 | 588 | * @author Dmitry (dio) Levashov |
589 | 589 | **/ |
590 | - protected function _fopen($path, $mode='rb') { |
|
590 | + protected function _fopen($path, $mode = 'rb') { |
|
591 | 591 | $fp = $this->tmbPath |
592 | 592 | ? @fopen($this->getTempFile($path), 'w+') |
593 | 593 | : @tmpfile(); |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | * @return bool |
615 | 615 | * @author Dmitry (dio) Levashov |
616 | 616 | **/ |
617 | - protected function _fclose($fp, $path='') { |
|
617 | + protected function _fclose($fp, $path = '') { |
|
618 | 618 | @fclose($fp); |
619 | 619 | if ($path) { |
620 | 620 | @unlink($this->getTempFile($path)); |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | $this->clearcache(); |
747 | 747 | |
748 | 748 | $mime = $stat['mime']; |
749 | - $w = !empty($stat['width']) ? $stat['width'] : 0; |
|
749 | + $w = !empty($stat['width']) ? $stat['width'] : 0; |
|
750 | 750 | $h = !empty($stat['height']) ? $stat['height'] : 0; |
751 | 751 | |
752 | 752 | $id = $this->_joinPath($dir, $name); |
@@ -368,7 +368,6 @@ discard block |
||
368 | 368 | * Open file and return file pointer |
369 | 369 | * |
370 | 370 | * @param string $path file path |
371 | - * @param bool $write open file for writing |
|
372 | 371 | * @return resource|false |
373 | 372 | * @author Dmitry (dio) Levashov, |
374 | 373 | * @author Alexey Sukhotin |
@@ -407,7 +406,7 @@ discard block |
||
407 | 406 | * |
408 | 407 | * @param resource $fp file pointer |
409 | 408 | * @param string $path file path |
410 | - * @return bool |
|
409 | + * @return boolean|null |
|
411 | 410 | * @author Dmitry (dio) Levashov |
412 | 411 | **/ |
413 | 412 | protected function _fclose($fp, $path='') { |
@@ -492,7 +491,7 @@ discard block |
||
492 | 491 | * Copy file into another file (only inside one volume) |
493 | 492 | * |
494 | 493 | * @param string $source source file path |
495 | - * @param string $target target dir path |
|
494 | + * @param string $targetDir target dir path |
|
496 | 495 | * @param string $name file name |
497 | 496 | * @return bool |
498 | 497 | * @author Dmitry (dio) Levashov |
@@ -506,9 +505,9 @@ discard block |
||
506 | 505 | * Return new file path or false. |
507 | 506 | * |
508 | 507 | * @param string $source source file path |
509 | - * @param string $target target dir path |
|
508 | + * @param string $targetDir target dir path |
|
510 | 509 | * @param string $name file name |
511 | - * @return string|bool |
|
510 | + * @return boolean |
|
512 | 511 | * @author Dmitry (dio) Levashov |
513 | 512 | **/ |
514 | 513 | protected function _move($source, $targetDir, $name) { |
@@ -573,7 +572,7 @@ discard block |
||
573 | 572 | * @param resource $fp file pointer |
574 | 573 | * @param string $dir target dir path |
575 | 574 | * @param string $name file name |
576 | - * @return bool|string |
|
575 | + * @return boolean |
|
577 | 576 | * @author Dmitry (dio) Levashov |
578 | 577 | **/ |
579 | 578 | protected function _save($fp, $dir, $name, $mime, $stat) { |
@@ -584,7 +583,7 @@ discard block |
||
584 | 583 | * Get file contents |
585 | 584 | * |
586 | 585 | * @param string $path file path |
587 | - * @return string|false |
|
586 | + * @return boolean |
|
588 | 587 | * @author Dmitry (dio) Levashov |
589 | 588 | **/ |
590 | 589 | protected function _getContents($path) { |
@@ -623,7 +622,7 @@ discard block |
||
623 | 622 | * @param array $files files names list |
624 | 623 | * @param string $name archive name |
625 | 624 | * @param array $arc archiver options |
626 | - * @return string|bool |
|
625 | + * @return boolean |
|
627 | 626 | * @author Dmitry (dio) Levashov, |
628 | 627 | * @author Alexey Sukhotin |
629 | 628 | **/ |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | **/ |
62 | 62 | protected function _dirname($path) { |
63 | 63 | |
64 | - $newpath = preg_replace("/\/$/", "", $path); |
|
65 | - $dn = substr($path, 0, strrpos($newpath, '/')) ; |
|
64 | + $newpath = preg_replace("/\/$/", "", $path); |
|
65 | + $dn = substr($path, 0, strrpos($newpath, '/')); |
|
66 | 66 | |
67 | 67 | if (substr($dn, 0, 1) != '/') { |
68 | 68 | $dn = "/$dn"; |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @author Troex Nevelin |
106 | 106 | **/ |
107 | 107 | protected function _normpath($path) { |
108 | - $tmp = preg_replace("/^\//", "", $path); |
|
109 | - $tmp = preg_replace("/\/\//", "/", $tmp); |
|
110 | - $tmp = preg_replace("/\/$/", "", $tmp); |
|
108 | + $tmp = preg_replace("/^\//", "", $path); |
|
109 | + $tmp = preg_replace("/\/\//", "/", $tmp); |
|
110 | + $tmp = preg_replace("/\/$/", "", $tmp); |
|
111 | 111 | return $tmp; |
112 | 112 | } |
113 | 113 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | $newpath = "/$newpath"; |
129 | 129 | } |
130 | 130 | |
131 | - $newpath = preg_replace("/\/$/", "", $newpath); |
|
131 | + $newpath = preg_replace("/\/$/", "", $newpath); |
|
132 | 132 | |
133 | - $ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root)+1); |
|
133 | + $ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root) + 1); |
|
134 | 134 | |
135 | 135 | return $ret; |
136 | 136 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $np = $this->_normpath($path); |
232 | 232 | |
233 | 233 | try { |
234 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false)); |
|
234 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false)); |
|
235 | 235 | } catch (Exception $e) { |
236 | 236 | |
237 | 237 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | if (!isset($obj) || ($obj->GetObjectResponse->Status->Code != 200)) { |
240 | 240 | $np .= '/'; |
241 | 241 | try { |
242 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np , 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false)); |
|
242 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $np, 'GetMetadata' => true, 'InlineData' => false, 'GetData' => false)); |
|
243 | 243 | } catch (Exception $e) { |
244 | 244 | |
245 | 245 | } |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | **/ |
342 | 342 | protected function _scandir($path) { |
343 | 343 | |
344 | - $s3path = preg_replace("/^\//", "", $path) . '/'; |
|
344 | + $s3path = preg_replace("/^\//", "", $path).'/'; |
|
345 | 345 | |
346 | 346 | $files = $this->s3->ListBucket(array('Bucket' => $this->options['bucket'], 'delimiter' => '/', 'Prefix' => $s3path))->ListBucketResponse->Contents; |
347 | 347 | |
348 | 348 | $finalfiles = array(); |
349 | 349 | |
350 | 350 | foreach ($files as $file) { |
351 | - if (preg_match("|^" . $s3path . "[^/]*/?$|", $file->Key)) { |
|
351 | + if (preg_match("|^".$s3path."[^/]*/?$|", $file->Key)) { |
|
352 | 352 | $fname = preg_replace("/\/$/", "", $file->Key); |
353 | 353 | $fname = $file->Key; |
354 | 354 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @author Dmitry (dio) Levashov, |
374 | 374 | * @author Alexey Sukhotin |
375 | 375 | **/ |
376 | - protected function _fopen($path, $mode="rb") { |
|
376 | + protected function _fopen($path, $mode = "rb") { |
|
377 | 377 | |
378 | 378 | $tn = $this->getTempFile($path); |
379 | 379 | |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | if ($fp) { |
386 | 386 | |
387 | 387 | try { |
388 | - $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path) , 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true)); |
|
389 | - } catch (Exception $e) { |
|
388 | + $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path), 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true)); |
|
389 | + } catch (Exception $e) { |
|
390 | 390 | |
391 | 391 | } |
392 | 392 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @return bool |
411 | 411 | * @author Dmitry (dio) Levashov |
412 | 412 | **/ |
413 | - protected function _fclose($fp, $path='') { |
|
413 | + protected function _fclose($fp, $path = '') { |
|
414 | 414 | @fclose($fp); |
415 | 415 | if ($path) { |
416 | 416 | @unlink($this->getTempFile($path)); |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $newkey = "$newkey/$name/"; |
436 | 436 | |
437 | 437 | try { |
438 | - $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => '')); |
|
438 | + $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => '')); |
|
439 | 439 | } catch (Exception $e) { |
440 | 440 | |
441 | 441 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $newkey = "$newkey/$name"; |
463 | 463 | |
464 | 464 | try { |
465 | - $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain')))); |
|
465 | + $obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey, 'ContentLength' => 0, 'Data' => '', 'Metadata' => array(array('Name' => 'Content-Type', 'Value' => 'text/plain')))); |
|
466 | 466 | } catch (Exception $e) { |
467 | 467 | |
468 | 468 | } |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @author Dmitry (dio) Levashov |
564 | 564 | **/ |
565 | 565 | protected function _rmdir($path) { |
566 | - return $this->_unlink($path . '/'); |
|
566 | + return $this->_unlink($path.'/'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | /* Getting list of S3 web service functions which requires signing */ |
683 | 683 | $funcs = $this->__getFunctions(); |
684 | 684 | |
685 | - $funcnames = array(); |
|
685 | + $funcnames = array(); |
|
686 | 686 | |
687 | 687 | foreach ($funcs as $func) { |
688 | 688 | preg_match("/\S+\s+([^\)]+)\(/", $func, $m); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | 'Timestamp' => gmdate('Y-m-d\TH:i:s.000\Z'), |
724 | 724 | ); |
725 | 725 | |
726 | - $sign_str = 'AmazonS3' . $operation . $params['Timestamp']; |
|
726 | + $sign_str = 'AmazonS3'.$operation.$params['Timestamp']; |
|
727 | 727 | |
728 | 728 | $params['Signature'] = base64_encode(hash_hmac('sha1', $sign_str, $this->secretkey, TRUE)); |
729 | 729 |
@@ -386,7 +386,7 @@ |
||
386 | 386 | |
387 | 387 | try { |
388 | 388 | $obj = $this->s3->GetObject(array('Bucket' => $this->options['bucket'], 'Key' => $this->_normpath($path) , 'GetMetadata' => true, 'InlineData' => true, 'GetData' => true)); |
389 | - } catch (Exception $e) { |
|
389 | + } catch (Exception $e) { |
|
390 | 390 | |
391 | 391 | } |
392 | 392 |
@@ -107,6 +107,10 @@ discard block |
||
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | + /** |
|
111 | + * @param double $width |
|
112 | + * @param double $height |
|
113 | + */ |
|
110 | 114 | private function resize_gd($src, $width, $height, $quality, $srcImgInfo) { |
111 | 115 | switch ($srcImgInfo['mime']) { |
112 | 116 | case 'image/gif': |
@@ -177,6 +181,10 @@ discard block |
||
177 | 181 | return false; |
178 | 182 | } |
179 | 183 | |
184 | + /** |
|
185 | + * @param double $width |
|
186 | + * @param double $height |
|
187 | + */ |
|
180 | 188 | private function resize_imagick($src, $width, $height, $quality) { |
181 | 189 | try { |
182 | 190 | $img = new imagick($src); |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | |
51 | 51 | public function __construct($opts) { |
52 | 52 | $defaults = array( |
53 | - 'enable' => true, // For control by volume driver |
|
54 | - 'maxWidth' => 1024, // Path to Water mark image |
|
55 | - 'maxHeight' => 1024, // Margin right pixel |
|
56 | - 'quality' => 95, // JPEG image save quality |
|
57 | - 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP // Target image formats ( bit-field ) |
|
53 | + 'enable' => true, // For control by volume driver |
|
54 | + 'maxWidth' => 1024, // Path to Water mark image |
|
55 | + 'maxHeight' => 1024, // Margin right pixel |
|
56 | + 'quality' => 95, // JPEG image save quality |
|
57 | + 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP // Target image formats ( bit-field ) |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | $this->opts = array_merge($defaults, $opts); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $opts = array_merge($this->opts, $volOpts); |
69 | 69 | } |
70 | 70 | |
71 | - if (! $opts['enable']) { |
|
71 | + if (!$opts['enable']) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | IMAGETYPE_PNG => IMG_PNG, |
85 | 85 | IMAGETYPE_WBMP => IMG_WBMP, |
86 | 86 | ); |
87 | - if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
87 | + if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | private function resize($src, $srcImgInfo, $maxWidth, $maxHeight, $quality) { |
99 | - $zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1])); |
|
100 | - $width = round($srcImgInfo[0] * $zoom); |
|
101 | - $height = round($srcImgInfo[1] * $zoom); |
|
99 | + $zoom = min(($maxWidth/$srcImgInfo[0]), ($maxHeight/$srcImgInfo[1])); |
|
100 | + $width = round($srcImgInfo[0]*$zoom); |
|
101 | + $height = round($srcImgInfo[1]*$zoom); |
|
102 | 102 | |
103 | 103 | if (class_exists('Imagick')) { |
104 | 104 | return $this->resize_imagick($src, $width, $height, $quality); |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | break; |
119 | 119 | case 'image/jpeg': |
120 | 120 | if (@imagetypes() & IMG_JPG) { |
121 | - $oSrcImg = @imagecreatefromjpeg($src) ; |
|
121 | + $oSrcImg = @imagecreatefromjpeg($src); |
|
122 | 122 | } else { |
123 | 123 | $ermsg = 'JPEG images are not supported'; |
124 | 124 | } |
125 | 125 | break; |
126 | 126 | case 'image/png': |
127 | 127 | if (@imagetypes() & IMG_PNG) { |
128 | - $oSrcImg = @imagecreatefrompng($src) ; |
|
128 | + $oSrcImg = @imagecreatefrompng($src); |
|
129 | 129 | } else { |
130 | 130 | $ermsg = 'PNG images are not supported'; |
131 | 131 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | break; |
144 | 144 | } |
145 | 145 | |
146 | - if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
146 | + if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) { |
|
147 | 147 | |
148 | 148 | if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) { |
149 | 149 | return false; |
@@ -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); |