PHP Class Horde_Vfs_Smb, horde

Required values for $params: - username: (string) The username with which to connect to the SMB server. - password: (string) The password with which to connect to the SMB server. - hostspec: (string) The SMB server to connect to. - share: (string) The share to access on the SMB server. Any trailing paths will removed from the share and prepended to each path in further requests. Example: a share of 'myshare/basedir' and a request to 'dir/subdir' will result in a request to 'basedir/dir/subdir' on myshare. - smbclient: (string) The path to the 'smbclient' executable. Optional values for $params: - port: (integer) The SMB port number to connect to. - ipaddress: (string) The address of the server to connect to. Functions not implemented: - changePermissions(): The SMB permission style does not fit with the module. All paths need to use forward slashes!
Author: Paul Gareau ([email protected])
Author: Patrice Levesque ([email protected])
Inheritance: extends Horde_Vfs_Base
Datei anzeigen Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_credentials array List of additional credentials required for this VFS backend.
$_prefix string Passed as a path suffix to the share parameter.
$_rootCreated boolean Has the vfsroot already been created?

Public Methods

Method Description
__construct ( array $params = [] ) Constructor.
copy ( string $path, string $name, string $dest, boolean $autocreate = false ) Copies a file through the backend.
createFolder ( string $path, string $name ) Creates a folder on the VFS.
deleteFile ( string $path, string $name ) Deletes a file from the VFS.
deleteFolder ( string $path, string $name, boolean $recursive = false ) Deletes a folder from the VFS.
isFolder ( string $path, string $name ) : boolean Checks if a given pathname is a folder.
listFolder ( string $path = '', string | array $filter = null, boolean $dotfiles = true, boolean $dironly = false, boolean $recursive = false ) : array Returns a file list of the directory passed in.
move ( string $path, string $name, string $dest, boolean $autocreate = false ) Moves a file through the backend.
parseListing ( $res, $filter, $dotfiles, $dironly )
read ( string $path, string $name ) : string Retrieves a file from the VFS.
readFile ( string $path, string $name ) : string Retrieves a file from the VFS as an on-disk local file.
readStream ( string $path, string $name ) : resource Open a stream to a file in the VFS.
rename ( string $oldpath, string $oldname, string $newpath, string $newname ) Renames a file in the VFS.
size ( string $path, string $name ) : integer Retrieves the size of a file from the VFS.
write ( string $path, string $name, string $tmpFile, boolean $autocreate = false ) Stores a file in the VFS.
writeData ( string $path, string $name, string $data, boolean $autocreate = false ) Stores a file in the VFS from raw data.

Protected Methods

Method Description
_command ( array $path, array $cmd ) : array Executes SMB commands - without authentication - and returns output lines in array.
_connect ( ) Authenticates a user on the SMB server and share.
_createRoot ( ) Creates the vfsroot.
_escapeShellCommand ( ) : array Replacement for escapeshellcmd(), variable length args, as we only want certain characters escaped.
_execute ( string $cmd ) : array Executes a command and returns output lines in array.
_getNativePath ( string $path ) : string Returns the full path of a directory.

Method Details

__construct() public method

Constructor.
public __construct ( array $params = [] )
$params array A hash containing connection parameters.

_command() protected method

Executes SMB commands - without authentication - and returns output lines in array.
protected _command ( array $path, array $cmd ) : array
$path array Base path for command.
$cmd array Commands to be executed.
return array Array on success.

_connect() protected method

Authenticates a user on the SMB server and share.
protected _connect ( )

_createRoot() protected method

Creates the vfsroot.
protected _createRoot ( )

_escapeShellCommand() protected method

Replacement for escapeshellcmd(), variable length args, as we only want certain characters escaped.
protected _escapeShellCommand ( ) : array
return array TODO

_execute() protected method

Executes a command and returns output lines in array.
protected _execute ( string $cmd ) : array
$cmd string Command to be executed.
return array Array on success.

_getNativePath() protected method

Returns the full path of a directory.
protected _getNativePath ( string $path ) : string
$path string The directory.
return string Full path to the directory.

copy() public method

Copies a file through the backend.
public copy ( string $path, string $name, string $dest, boolean $autocreate = false )
$path string The path to store the file in.
$name string The filename to use.
$dest string The destination of the file.
$autocreate boolean Automatically create directories?

createFolder() public method

Creates a folder on the VFS.
public createFolder ( string $path, string $name )
$path string The path of directory to create folder.
$name string The name of the new folder.

deleteFile() public method

Deletes a file from the VFS.
public deleteFile ( string $path, string $name )
$path string The path to delete the file from.
$name string The filename to use.

deleteFolder() public method

Deletes a folder from the VFS.
public deleteFolder ( string $path, string $name, boolean $recursive = false )
$path string The path to delete the folder from.
$name string The name of the folder to delete.
$recursive boolean Force a recursive delete?

isFolder() public method

Checks if a given pathname is a folder.
public isFolder ( string $path, string $name ) : boolean
$path string The path to the folder.
$name string The file or folder name.
return boolean True if it is a folder, false otherwise.

listFolder() public method

Returns a file list of the directory passed in.
public listFolder ( string $path = '', string | array $filter = null, boolean $dotfiles = true, boolean $dironly = false, boolean $recursive = false ) : array
$path string The path of the directory.
$filter string | array Regular expression(s) to filter file/directory name on.
$dotfiles boolean Show dotfiles?
$dironly boolean Show only directories?
$recursive boolean Return all directory levels recursively?
return array File list.

move() public method

Moves a file through the backend.
public move ( string $path, string $name, string $dest, boolean $autocreate = false )
$path string The path to store the file in.
$name string The filename to use.
$dest string The destination of the file.
$autocreate boolean Automatically create directories?

parseListing() public method

public parseListing ( $res, $filter, $dotfiles, $dironly )

read() public method

Retrieves a file from the VFS.
public read ( string $path, string $name ) : string
$path string The pathname to the file.
$name string The filename to retrieve.
return string The file data.

readFile() public method

This function provides a file on local disk with the data of a VFS file in it. This file cannot be modified! The behavior if you do modify it is undefined. It will be removed at the end of the request.
public readFile ( string $path, string $name ) : string
$path string The pathname to the file.
$name string The filename to retrieve.
return string A local filename.

readStream() public method

Open a stream to a file in the VFS.
public readStream ( string $path, string $name ) : resource
$path string The pathname to the file.
$name string The filename to retrieve.
return resource The stream.

rename() public method

Renames a file in the VFS.
public rename ( string $oldpath, string $oldname, string $newpath, string $newname )
$oldpath string The old path to the file.
$oldname string The old filename.
$newpath string The new path of the file.
$newname string The new filename.

size() public method

Retrieves the size of a file from the VFS.
public size ( string $path, string $name ) : integer
$path string The pathname to the file.
$name string The filename to retrieve.
return integer The file size.

write() public method

Stores a file in the VFS.
public write ( string $path, string $name, string $tmpFile, boolean $autocreate = false )
$path string The path to store the file in.
$name string The filename to use.
$tmpFile string The temporary file containing the data to be stored.
$autocreate boolean Automatically create directories?

writeData() public method

Stores a file in the VFS from raw data.
public writeData ( string $path, string $name, string $data, boolean $autocreate = false )
$path string The path to store the file in.
$name string The filename to use.
$data string The file data.
$autocreate boolean Automatically create directories?

Property Details

$_credentials protected_oe property

List of additional credentials required for this VFS backend.
protected array $_credentials
return array

$_prefix protected_oe property

Passed as a path suffix to the share parameter.
protected string $_prefix
return string

$_rootCreated protected_oe property

Has the vfsroot already been created?
protected bool $_rootCreated
return boolean