Lines Matching +full:delete +full:- +full:user -(+path:inc +path:lang) -(+path:lib +path:plugins +path:lang) -(+path:lib +path:tpl +path:dokuwiki +path:lang)

12  * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
32 * Rather than re-create the connection we re-use instances if possible
150 } elseif ($orig[strlen($orig) - 1] == '#') {
158 if (isset($this->context)) {
159 $context = stream_context_get_params($this->context);
161 $this->notification = $context['notification'];
165 if (preg_match('/^{[a-z0-9]+}$/i', $host)) {
170 $this->sftp = $host;
172 if (isset($this->context)) {
173 $context = stream_context_get_options($this->context);
182 $this->sftp = $sftp;
186 $user = $context[$scheme]['username'];
195 if (!isset($user) || !isset($pass)) {
200 if (isset(self::$instances[$host][$port][$user][(string) $pass])) {
201 $this->sftp = self::$instances[$host][$port][$user][(string) $pass];
203 $this->sftp = new SFTP($host, $port);
204 $this->sftp->disableStatCache();
205 if (isset($this->notification) && is_callable($this->notification)) {
206 /* if !is_callable($this->notification) we could do this:
208 user_error('fopen(): failed to call user notifier', E_USER_WARNING);
212 on which the fopen occurred as the line number - not the line that the
215 call_user_func($this->notification, STREAM_NOTIFY_CONNECT, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0);
216 call_user_func($this->notification, STREAM_NOTIFY_AUTH_REQUIRED, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0);
217 if (!$this->sftp->login($user, $pass)) {
218 call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_ERR, 'Login Failure', NET_SSH2_MSG_USERAUTH_FAILURE, 0, 0);
221 call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_INFO, 'Login Success', NET_SSH2_MSG_USERAUTH_SUCCESS, 0, 0);
223 if (!$this->sftp->login($user, $pass)) {
227 self::$instances[$host][$port][$user][(string) $pass] = $this->sftp;
245 $path = $this->parse_path($path);
250 $this->path = $path;
252 $this->size = $this->sftp->filesize($path);
253 $this->mode = preg_replace('#[bt]$#', '', $mode);
254 $this->eof = false;
256 if ($this->size === false) {
257 if ($this->mode[0] == 'r') {
260 $this->sftp->touch($path);
261 $this->size = 0;
264 switch ($this->mode[0]) {
268 $this->sftp->truncate($path, 0);
269 $this->size = 0;
273 $this->pos = $this->mode[0] != 'a' ? 0 : $this->size;
286 switch ($this->mode) {
294 // commented out because some files - eg. /dev/urandom - will say their size is 0 when in fact it's kinda infinite
295 //if ($this->pos >= $this->size) {
296 // $this->eof = true;
300 $result = $this->sftp->get($this->path, false, $this->pos, $count);
301 if (isset($this->notification) && is_callable($this->notification)) {
303 call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0);
307 call_user_func($this->notification, STREAM_NOTIFY_PROGRESS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, strlen($result), $this->size);
311 $this->eof = true;
314 $this->pos += strlen($result);
327 switch ($this->mode) {
332 $result = $this->sftp->put($this->path, $data, SFTP::SOURCE_STRING, $this->pos);
333 if (isset($this->notification) && is_callable($this->notification)) {
335 call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0);
339 call_user_func($this->notification, STREAM_NOTIFY_PROGRESS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, strlen($data), strlen($data));
345 $this->pos += strlen($data);
346 if ($this->pos > $this->size) {
347 $this->size = $this->pos;
349 $this->eof = false;
360 return $this->pos;
364 * Tests for end-of-file on a file pointer
377 return $this->eof;
396 $offset += $this->pos;
399 $offset += $this->size;
402 $this->pos = $offset;
403 $this->eof = false;
417 $path = $this->parse_path($path);
423 // see http://www.php.net/streamwrapper.stream-metadata and https://bugs.php.net/64246
424 // and https://github.com/php/php-src/blob/master/main/php_streams.h#L592
429 return $this->sftp->touch($path, $time, $atime);
434 return $this->sftp->chown($path, $var);
436 return $this->sftp->chgrp($path, $var);
438 return $this->sftp->chmod($path, $var) !== false;
450 return $this->sftp->fsock;
484 $path_from = $this->parse_path($path_from);
492 // -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-6.5
493 if (!$this->sftp->rename($path_from, $path_to)) {
494 if ($this->sftp->stat($path_to)) {
495 return $this->sftp->delete($path_to, true) && $this->sftp->rename($path_from, $path_to);
528 $path = $this->parse_path($path);
532 $this->pos = 0;
533 $this->entries = $this->sftp->nlist($path);
534 return $this->entries !== false;
544 if (isset($this->entries[$this->pos])) {
545 return $this->entries[$this->pos++];
557 $this->pos = 0;
583 $path = $this->parse_path($path);
588 return $this->sftp->mkdir($path, $mode, $options & STREAM_MKDIR_RECURSIVE);
605 $path = $this->parse_path($path);
610 return $this->sftp->rmdir($path);
632 $results = $this->sftp->stat($this->path);
640 * Delete a file
647 $path = $this->parse_path($path);
652 return $this->sftp->delete($path, false);
659 * might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll
668 $path = $this->parse_path($path);
673 $results = $flags & STREAM_URL_STAT_LINK ? $this->sftp->lstat($path) : $this->sftp->stat($path);
689 if (!$this->sftp->truncate($this->path, $new_size)) {
693 $this->eof = false;
694 $this->size = $new_size;
726 * When you're utilizing an SFTP stream you're not calling the methods in this class directly - PHP is calling them for you.
741 $last = count($arguments) - 1;
754 return $this->$name(...$arguments);