[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/includes/ -> class-wp-filesystem-ssh2.php (summary)

(no description)

File Size: 834 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Filesystem_SSH2:: (30 methods):
  __construct()
  connect()
  sftp_path()
  run_command()
  get_contents()
  get_contents_array()
  put_contents()
  cwd()
  chdir()
  chgrp()
  chmod()
  chown()
  owner()
  getchmod()
  group()
  copy()
  move()
  delete()
  exists()
  is_file()
  is_dir()
  is_readable()
  is_writable()
  atime()
  mtime()
  size()
  touch()
  mkdir()
  rmdir()
  dirlist()


Class: WP_Filesystem_SSH2  - X-Ref

WordPress Filesystem Class for implementing SSH2

To use this class you must follow these steps for PHP 5.2.6+

{@link http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/ - Installation Notes}

Compile libssh2 (Note: Only 0.14 is officially working with PHP 5.2.6+ right now, But many users have found the latest versions work)

cd /usr/src
wget https://www.libssh2.org/download/libssh2-0.14.tar.gz
tar -zxvf libssh2-0.14.tar.gz
cd libssh2-0.14/
./configure
make all install

Note: Do not leave the directory yet!

Enter: pecl install -f ssh2

Copy the ssh.so file it creates to your PHP Module Directory.
Open up your PHP.INI file and look for where extensions are placed.
Add in your PHP.ini file: extension=ssh2.so

Restart Apache!
Check phpinfo() streams to confirm that: ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp  exist.

Note: As of WordPress 2.8, this utilizes the PHP5+ function `stream_get_contents()`.

__construct( $opt = '' )   X-Ref
Constructor.

param: array $opt

connect()   X-Ref
Connects filesystem.

return: bool True on success, false on failure.

sftp_path( $path )   X-Ref
Gets the ssh2.sftp PHP stream wrapper path to open for the given file.

This method also works around a PHP bug where the root directory (/) cannot
be opened by PHP functions, causing a false failure. In order to work around
this, the path is converted to /./ which is semantically the same as /
See https://bugs.php.net/bug.php?id=64169 for more details.

param: string $path The File/Directory path on the remote server to return
return: string The ssh2.sftp:// wrapped path to use.

run_command( $command, $returnbool = false )   X-Ref

param: string $command
param: bool   $returnbool
return: bool|string True on success, false on failure. String if the command was executed, `$returnbool`

get_contents( $file )   X-Ref
Reads entire file into a string.

param: string $file Name of the file to read.
return: string|false Read data on success, false if no temporary file could be opened,

get_contents_array( $file )   X-Ref
Reads entire file into an array.

param: string $file Path to the file.
return: array|false File contents in an array on success, false on failure.

put_contents( $file, $contents, $mode = false )   X-Ref
Writes a string to a file.

param: string    $file     Remote path to the file where to write the data.
param: string    $contents The data to write.
param: int|false $mode     Optional. The file permissions as octal number, usually 0644.
return: bool True on success, false on failure.

cwd()   X-Ref
Gets the current working directory.

return: string|false The current working directory on success, false on failure.

chdir( $dir )   X-Ref
Changes current directory.

param: string $dir The new current directory.
return: bool True on success, false on failure.

chgrp( $file, $group, $recursive = false )   X-Ref
Changes the file group.

param: string     $file      Path to the file.
param: string|int $group     A group name or number.
param: bool       $recursive Optional. If set to true, changes file group recursively.
return: bool True on success, false on failure.

chmod( $file, $mode = false, $recursive = false )   X-Ref
Changes filesystem permissions.

param: string    $file      Path to the file.
param: int|false $mode      Optional. The permissions as octal number, usually 0644 for files,
param: bool      $recursive Optional. If set to true, changes file permissions recursively.
return: bool True on success, false on failure.

chown( $file, $owner, $recursive = false )   X-Ref
Changes the owner of a file or directory.

param: string     $file      Path to the file or directory.
param: string|int $owner     A user name or number.
param: bool       $recursive Optional. If set to true, changes file owner recursively.
return: bool True on success, false on failure.

owner( $file )   X-Ref
Gets the file owner.

param: string $file Path to the file.
return: string|false Username of the owner on success, false on failure.

getchmod( $file )   X-Ref
Gets the permissions of the specified file or filepath in their octal format.

param: string $file Path to the file.
return: string Mode of the file (the last 3 digits).

group( $file )   X-Ref
Gets the file's group.

param: string $file Path to the file.
return: string|false The group on success, false on failure.

copy( $source, $destination, $overwrite = false, $mode = false )   X-Ref
Copies a file.

param: string    $source      Path to the source file.
param: string    $destination Path to the destination file.
param: bool      $overwrite   Optional. Whether to overwrite the destination file if it exists.
param: int|false $mode        Optional. The permissions as octal number, usually 0644 for files,
return: bool True on success, false on failure.

move( $source, $destination, $overwrite = false )   X-Ref
Moves a file or directory.

After moving files or directories, OPcache will need to be invalidated.

If moving a directory fails, `copy_dir()` can be used for a recursive copy.

Use `move_dir()` for moving directories with OPcache invalidation and a
fallback to `copy_dir()`.

param: string $source      Path to the source file or directory.
param: string $destination Path to the destination file or directory.
param: bool   $overwrite   Optional. Whether to overwrite the destination if it exists.
return: bool True on success, false on failure.

delete( $file, $recursive = false, $type = false )   X-Ref
Deletes a file or directory.

param: string       $file      Path to the file or directory.
param: bool         $recursive Optional. If set to true, deletes files and folders recursively.
param: string|false $type      Type of resource. 'f' for file, 'd' for directory.
return: bool True on success, false on failure.

exists( $path )   X-Ref
Checks if a file or directory exists.

param: string $path Path to file or directory.
return: bool Whether $path exists or not.

is_file( $file )   X-Ref
Checks if resource is a file.

param: string $file File path.
return: bool Whether $file is a file.

is_dir( $path )   X-Ref
Checks if resource is a directory.

param: string $path Directory path.
return: bool Whether $path is a directory.

is_readable( $file )   X-Ref
Checks if a file is readable.

param: string $file Path to file.
return: bool Whether $file is readable.

is_writable( $path )   X-Ref
Checks if a file or directory is writable.

param: string $path Path to file or directory.
return: bool Whether $path is writable.

atime( $file )   X-Ref
Gets the file's last access time.

param: string $file Path to file.
return: int|false Unix timestamp representing last access time, false on failure.

mtime( $file )   X-Ref
Gets the file modification time.

param: string $file Path to file.
return: int|false Unix timestamp representing modification time, false on failure.

size( $file )   X-Ref
Gets the file size (in bytes).

param: string $file Path to file.
return: int|false Size of the file in bytes on success, false on failure.

touch( $file, $time = 0, $atime = 0 )   X-Ref
Sets the access and modification times of a file.

Note: Not implemented.

param: string $file  Path to file.
param: int    $time  Optional. Modified time to set for file.
param: int    $atime Optional. Access time to set for file.

mkdir( $path, $chmod = false, $chown = false, $chgrp = false )   X-Ref
Creates a directory.

param: string           $path  Path for new directory.
param: int|false        $chmod Optional. The permissions as octal number (or false to skip chmod).
param: string|int|false $chown Optional. A user name or number (or false to skip chown).
param: string|int|false $chgrp Optional. A group name or number (or false to skip chgrp).
return: bool True on success, false on failure.

rmdir( $path, $recursive = false )   X-Ref
Deletes a directory.

param: string $path      Path to directory.
param: bool   $recursive Optional. Whether to recursively remove files/directories.
return: bool True on success, false on failure.

dirlist( $path, $include_hidden = true, $recursive = false )   X-Ref
Gets details for files in a directory or a specific file.

param: string $path           Path to directory or file.
param: bool   $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
param: bool   $recursive      Optional. Whether to recursively include file details in nested directories.
return: array|false {



Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref