@@ -64,7 +64,7 @@ |
||
| 64 | 64 | if (isset($context[$name])) { |
| 65 | 65 | $context = $context[$name]; |
| 66 | 66 | } else { |
| 67 | - throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set'); |
|
| 67 | + throw new \BadMethodCallException('Invalid context, "'.$name.'" options not set'); |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($context['session']) and $context['session'] instanceof \phpseclib\Net\SFTP) { |
| 70 | 70 | $this->sftp = $context['session']; |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | if (isset($context[$name])) { |
| 65 | 65 | $context = $context[$name]; |
| 66 | 66 | } else { |
| 67 | - throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set'); |
|
| 67 | + throw new \BadMethodCallException('Invalid context, "'.$name.'" options not set'); |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($context['session']) and $context['session'] instanceof \phpseclib\Net\SFTP) { |
| 70 | 70 | $this->sftp = $context['session']; |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | $input = $host; |
| 65 | 65 | if (strpos($host, '://') === false) { |
| 66 | 66 | // add a protocol to fix parse_url behavior with ipv6 |
| 67 | - $host = 'http://' . $host; |
|
| 67 | + $host = 'http://'.$host; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $parsed = parse_url($host); |
| 71 | - if(is_array($parsed) && isset($parsed['port'])) { |
|
| 71 | + if (is_array($parsed) && isset($parsed['port'])) { |
|
| 72 | 72 | return [$parsed['host'], $parsed['port']]; |
| 73 | 73 | } else if (is_array($parsed)) { |
| 74 | 74 | return [$parsed['host'], 22]; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | // Register sftp:// |
| 85 | 85 | Stream::register(); |
| 86 | 86 | |
| 87 | - $parsedHost = $this->splitHost($params['host']); |
|
| 87 | + $parsedHost = $this->splitHost($params['host']); |
|
| 88 | 88 | |
| 89 | 89 | $this->host = $parsedHost[0]; |
| 90 | 90 | $this->port = $parsedHost[1]; |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | $this->root |
| 109 | 109 | = isset($params['root']) ? $this->cleanPath($params['root']) : '/'; |
| 110 | 110 | |
| 111 | - $this->root = '/' . ltrim($this->root, '/'); |
|
| 112 | - $this->root = rtrim($this->root, '/') . '/'; |
|
| 111 | + $this->root = '/'.ltrim($this->root, '/'); |
|
| 112 | + $this->root = rtrim($this->root, '/').'/'; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -167,15 +167,15 @@ discard block |
||
| 167 | 167 | /** |
| 168 | 168 | * {@inheritdoc} |
| 169 | 169 | */ |
| 170 | - public function getId(){ |
|
| 171 | - $id = 'sftp::' . $this->user . '@' . $this->host; |
|
| 170 | + public function getId() { |
|
| 171 | + $id = 'sftp::'.$this->user.'@'.$this->host; |
|
| 172 | 172 | if ($this->port !== 22) { |
| 173 | - $id .= ':' . $this->port; |
|
| 173 | + $id .= ':'.$this->port; |
|
| 174 | 174 | } |
| 175 | 175 | // note: this will double the root slash, |
| 176 | 176 | // we should not change it to keep compatible with |
| 177 | 177 | // old storage ids |
| 178 | - $id .= '/' . $this->root; |
|
| 178 | + $id .= '/'.$this->root; |
|
| 179 | 179 | return $id; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @return string |
| 206 | 206 | */ |
| 207 | 207 | private function absPath($path) { |
| 208 | - return $this->root . $this->cleanPath($path); |
|
| 208 | + return $this->root.$this->cleanPath($path); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | try { |
| 216 | 216 | $storage_view = \OCP\Files::getStorage('files_external'); |
| 217 | 217 | if ($storage_view) { |
| 218 | - return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . |
|
| 219 | - $storage_view->getAbsolutePath('') . |
|
| 218 | + return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'). |
|
| 219 | + $storage_view->getAbsolutePath(''). |
|
| 220 | 220 | 'ssh_hostKeys'; |
| 221 | 221 | } |
| 222 | 222 | } catch (\Exception $e) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | if ($keyPath && file_exists($keyPath)) { |
| 235 | 235 | $fp = fopen($keyPath, 'w'); |
| 236 | 236 | foreach ($keys as $host => $key) { |
| 237 | - fwrite($fp, $host . '::' . $key . "\n"); |
|
| 237 | + fwrite($fp, $host.'::'.$key."\n"); |
|
| 238 | 238 | } |
| 239 | 239 | fclose($fp); |
| 240 | 240 | return true; |
@@ -306,15 +306,15 @@ discard block |
||
| 306 | 306 | return false; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - $id = md5('sftp:' . $path); |
|
| 309 | + $id = md5('sftp:'.$path); |
|
| 310 | 310 | $dirStream = array(); |
| 311 | - foreach($list as $file) { |
|
| 311 | + foreach ($list as $file) { |
|
| 312 | 312 | if ($file !== '.' && $file !== '..') { |
| 313 | 313 | $dirStream[] = $file; |
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | return IteratorDirectory::wrap($dirStream); |
| 317 | - } catch(\Exception $e) { |
|
| 317 | + } catch (\Exception $e) { |
|
| 318 | 318 | return false; |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -366,21 +366,21 @@ discard block |
||
| 366 | 366 | public function fopen($path, $mode) { |
| 367 | 367 | try { |
| 368 | 368 | $absPath = $this->absPath($path); |
| 369 | - switch($mode) { |
|
| 369 | + switch ($mode) { |
|
| 370 | 370 | case 'r': |
| 371 | 371 | case 'rb': |
| 372 | - if ( !$this->file_exists($path)) { |
|
| 372 | + if (!$this->file_exists($path)) { |
|
| 373 | 373 | return false; |
| 374 | 374 | } |
| 375 | 375 | SFTPReadStream::register(); |
| 376 | 376 | $context = stream_context_create(['sftp' => ['session' => $this->getConnection()]]); |
| 377 | - $handle = fopen('sftpread://' . trim($absPath, '/'), 'r', false, $context); |
|
| 377 | + $handle = fopen('sftpread://'.trim($absPath, '/'), 'r', false, $context); |
|
| 378 | 378 | return RetryWrapper::wrap($handle); |
| 379 | 379 | case 'w': |
| 380 | 380 | case 'wb': |
| 381 | 381 | SFTPWriteStream::register(); |
| 382 | 382 | $context = stream_context_create(['sftp' => ['session' => $this->getConnection()]]); |
| 383 | - return fopen('sftpwrite://' . trim($absPath, '/'), 'w', false, $context); |
|
| 383 | + return fopen('sftpwrite://'.trim($absPath, '/'), 'w', false, $context); |
|
| 384 | 384 | case 'a': |
| 385 | 385 | case 'ab': |
| 386 | 386 | case 'r+': |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | /** |
| 404 | 404 | * {@inheritdoc} |
| 405 | 405 | */ |
| 406 | - public function touch($path, $mtime=null) { |
|
| 406 | + public function touch($path, $mtime = null) { |
|
| 407 | 407 | try { |
| 408 | 408 | if (!is_null($mtime)) { |
| 409 | 409 | return false; |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | // Do not pass the password here. We want to use the Net_SFTP object |
| 479 | 479 | // supplied via stream context or fail. We only supply username and |
| 480 | 480 | // hostname because this might show up in logs (they are not used). |
| 481 | - $url = 'sftp://' . urlencode($this->user) . '@' . $this->host . ':' . $this->port . $this->root . $path; |
|
| 481 | + $url = 'sftp://'.urlencode($this->user).'@'.$this->host.':'.$this->port.$this->root.$path; |
|
| 482 | 482 | return $url; |
| 483 | 483 | } |
| 484 | 484 | } |