Class: Net_FTP
Source Location: /Net_FTP-1.4.0/Net/FTP.php
PEAR
|
--Net_FTP
Class for comfortable FTP-communication
Author(s):
Version:
Copyright:
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
Net_FTP (Constructor) [line 710]
void Net_FTP(
[string
$host = null], [int
$port = null], [int
$timeout = 90])
|
|
This generates a new FTP-Object. The FTP-connection will not be established, yet. You can leave $host and $port blank, if you want. The $host will not be set and the $port will be left at 21. You have to set the $host manualy before trying to connect or with the connect() method.
Parameters:
addExtension [line 1925]
void addExtension(
int
$mode, string
$ext)
|
|
Adds an extension to a mode-directory The mode-directory saves file-extensions coresponding to filetypes (ascii e.g.: 'php', 'txt', 'htm',...; binary e.g.: 'jpg', 'gif', 'exe',...). The extensions have to be saved without the '.'. And can be predefined in an external file (see: getExtensionsFile()). The array is build like this: 'php' => FTP_ASCII, 'png' => FTP_BINARY To change the mode of an extension, just add it again with the new mode!
Parameters:
attach [line 2113]
boolean attach(
object
&$observer)
|
|
Adds a Net_FTP_Observer instance to the list of observers that are listening for messages emitted by this Net_FTP instance.
Parameters:
cd [line 871]
This changes the currently used directory. You can use either an absolute directory-path (e.g. "/home/blah") or a relative one (e.g. "../test").
Parameters:
checkFileExtension [line 1719]
int checkFileExtension(
string
$filename)
|
|
This checks, whether a file should be transfered in ascii- or binary-mode by it's file-extension. If the file-extension is not set or the extension is not inside one of the extension-dirs, the actual set transfer-mode is returned.
Parameters:
chmod [line 1011]
mixed chmod(
mixed
$target, integer
$permissions)
|
|
This method will try to chmod the file specified on the server Currently, you must give a number as the the permission argument (777 or similar). The file can be either a relative or absolute path. NOTE: Some servers do not support this feature. In that case, you will get a PEAR error object returned. If successful, the method returns true
Parameters:
chmodRecursive [line 1057]
mixed chmodRecursive(
mixed
$target, integer
$permissions)
|
|
This method will try to chmod a folder and all of its contents on the server. The target argument must be a folder or an array of folders and the permissions argument have to be an integer (i.e. 777). The file can be either a relative or absolute path. NOTE: Some servers do not support this feature. In that case, you will get a PEAR error object returned. If successful, the method returns true
Parameters:
connect [line 760]
mixed connect(
[string
$host = null], [int
$port = null], [bool
$ssl = null])
|
|
This function generates the FTP-connection. You can optionally define a hostname and/or a port. If you do so, this data is stored inside the object.
Parameters:
detach [line 2133]
boolean detach(
object
$observer)
|
|
Removes a Net_FTP_Observer instance from the list of observers.
Parameters:
disconnect [line 795]
bool|PEAR_Error disconnect(
)
|
|
This function close the FTP-connection
execute [line 965]
mixed execute(
string
$command)
|
|
This method tries executing a command on the ftp, using SITE EXEC.
Parameters:
get [line 1402]
mixed get(
string
$remote_file, string
$local_file, [bool
$overwrite = false], [int
$mode = null])
|
|
This function will download a file from the ftp-server. You can either specify an absolute path to the file (beginning with "/") or a relative one, which will be completed with the actual directory you selected on the server. You can specify the path to which the file will be downloaded on the local machine, if the file should be overwritten if it exists (optionally, default is no overwriting) and in which mode (FTP_ASCII or FTP_BINARY) the file should be downloaded (if you do not specify this, the method tries to determine it automatically from the mode-directory or uses the default-mode, set by you). If you give a relative path to the local-file, the script-path is used as basepath.
Parameters:
getExtensionMode [line 2085]
int getExtensionMode(
string
$ext)
|
|
Returns the mode set for a file-extension
Parameters:
getExtensionsFile [line 1965]
mixed getExtensionsFile(
string
$filename)
|
|
This get's both (ascii- and binary-mode-directories) from the given file. Beware, if you read a file into the mode-directory, all former set values will be unset! Example file contents: [ASCII] asc = 0 txt = 0 [BINARY] bin = 1 jpg = 1
Parameters:
getHostname [line 2006]
getMode [line 2061]
getPassword [line 2050]
getPort [line 2017]
getRecursive [line 1555]
mixed getRecursive(
string
$remote_path, string
$local_path, [bool
$overwrite = false], [int
$mode = null], [array
$excluded_paths = array()])
|
|
This functionality allows you to transfer a whole directory-structure from the remote-ftp to your local host. You have to give a remote-directory (ending with '/') and the local directory (ending with '/') where to put the files you download. The remote path is automatically completed with the current-remote-dir, if you give a relative path to this function. You can give a relative path for the $local_path, too. Then the script-basedir will be used for comletion of the path. The parameter $overwrite will determine, whether to overwrite existing files or not. Standard for this is false. Fourth you can explicitly set a mode for all transfer actions done. If you do not set this, the method tries to determine the transfer mode by checking your mode-directory for the file extension. If the extension is not inside the mode-directory, it will get your default mode. Since 1.4 no error will be returned when a file exists while $overwrite is set to false.
Parameters:
getSsl [line 2028]
Returns whether to connect through secure SSL connection
getTimeout [line 2097]
Get the currently set timeout. Returns the actual timeout set.
getUsername [line 2039]
isPassive [line 2072]
Returns, whether the connection is set to passive mode or not
login [line 820]
mixed login(
[string
$username = null], [string
$password = null])
|
|
This logs you into the ftp-server. You are free to specify username and password in this method. If you specify it, the values will be taken into the corresponding attributes, if do not specify, the attributes are taken. If connect() has not been called yet, a connection will be setup
Parameters:
ls [line 1306]
mixed ls(
[string
$dir = null], [int
$mode = NET_FTP_DIRS_FILES])
|
|
This method returns a directory-list of the current directory or given one. To display the current selected directory, simply set the first parameter to null or leave it blank, if you do not want to use any other parameters.
There are 4 different modes of listing directories. Either to list only the files (using NET_FTP_FILES_ONLY), to list only directories (using NET_FTP_DIRS_ONLY) or to show both (using NET_FTP_DIRS_FILES, which is default).
The 4th one is the NET_FTP_RAWLIST, which returns just the array created by the ftp_rawlist()-function build into PHP.
The other function-modes will return an array containing the requested data. The files and dirs are listed in human-sorted order, but if you select NET_FTP_DIRS_FILES the directories will be added above the files, but although both sorted.
All elements in the arrays are associative arrays themselves. They have the following structure:
Dirs: ["name"] => string The name of the directory ["rights"] => string The rights of the directory (in style "rwxr-xr-x") ["user"] => string The owner of the directory ["group"] => string The group-owner of the directory ["files_inside"]=> string The number of files/dirs inside the directory excluding "." and ".." ["date"] => int The creation-date as Unix timestamp ["is_dir"] => bool true, cause this is a dir
Files: ["name"] => string The name of the file ["size"] => int Size in bytes ["rights"] => string The rights of the file (in style "rwxr-xr-x") ["user"] => string The owner of the file ["group"] => string The group-owner of the file ["date"] => int The creation-date as Unix timestamp ["is_dir"] => bool false, cause this is a file
Parameters:
mdtm [line 1207]
mixed mdtm(
string
$file, [string
$format = null])
|
|
This will return the last modification-time of a file. You can either give this function a relative or an absolute path to the file to check. NOTE: Some servers will not support this feature and the function works only on files, not directories! When successful, it will return the last modification-time as a unix-timestamp or, when $format is specified, a preformated timestring.
Parameters:
mkdir [line 914]
mixed mkdir(
string
$dir, [bool
$recursive = false])
|
|
This works similar to the mkdir-command on your local machine. You can either give it an absolute or relative path. The relative path will be completed with the actual selected server-path. (see: pwd())
Parameters:
put [line 1469]
mixed put(
string
$local_file, string
$remote_file, [bool
$overwrite = false], [int
$mode = null], [int
$options = 0])
|
|
This function will upload a file to the ftp-server. You can either specify a absolute path to the remote-file (beginning with "/") or a relative one, which will be completed with the actual directory you selected on the server. You can specify the path from which the file will be uploaded on the local maschine, if the file should be overwritten if it exists (optionally, default is no overwriting) and in which mode (FTP_ASCII or FTP_BINARY) the file should be downloaded (if you do not specify this, the method tries to determine it automatically from the mode-directory or uses the default-mode, set by you). If you give a relative path to the local-file, the script-path is used as basepath.
Parameters:
putRecursive [line 1653]
mixed putRecursive(
string
$local_path, string
$remote_path, [bool
$overwrite = false], [int
$mode = null], [array
$excluded_paths = array()])
|
|
This functionality allows you to transfer a whole directory-structure from your local host to the remote-ftp. You have to give a remote-directory (ending with '/') and the local directory (ending with '/') where to put the files you download. The remote path is automatically completed with the current-remote-dir, if you give a relative path to this function. You can give a relative path for the $local_path, too. Then the script-basedir will be used for comletion of the path. The parameter $overwrite will determine, whether to overwrite existing files or not. Standard for this is false. Fourth you can explicitly set a mode for all transfer actions done. If you do not set this, the method tries to determine the transfer mode by checking your mode-directory for the file-extension. If the extension is not inside the mode-directory, it will get your default mode.
Parameters:
pwd [line 891]
Show's you the actual path on the server This function questions the ftp-handle for the actual selected path and returns it.
removeExtension [line 1939]
void removeExtension(
string
$ext)
|
|
This function removes an extension from the mode-directories (described above).
Parameters:
rename [line 1155]
bool rename(
string
$remote_from, string
$remote_to)
|
|
Rename or move a file or a directory from the ftp-server
Parameters:
rm [line 1363]
mixed rm(
string
$path, [bool
$recursive = false], [bool
$filesonly = false])
|
|
This method will delete the given file or directory ($path) from the server (maybe recursive). Whether the given string is a file or directory is only determined by the last sign inside the string ("/" or not). If you specify a directory, you can optionally specify $recursive as true, to let the directory be deleted recursive (with all sub-directories and files inherited). You can either give a absolute or relative path for the file / dir. If you choose to use the relative path, it will be automatically completed with the actual selected directory.
Parameters:
setActive [line 1867]
Set the transfer-method to active mode
setDirMatcher [line 2181]
bool|PEAR_Error setDirMatcher(
string
$pattern, array
$matchmap)
|
|
Sets the directory listing matcher Use this method to set the directory listing matcher to a specific pattern. Indicate the pattern as a perl regular expression and give an array containing as keys the fields selected in the regular expression and as values the offset of the subpattern in the pattern. Example: $pattern = '/(?:(d)|.)([rwxt-]+)\s+(\w+)\s+([\w\d-]+)\s+([\w\d-]+)\s+(\w+) \s+(\S+\s+\S+\s+\S+)\s+(.+)/', $matchmap = array( 'is_dir' => 1, 'rights' => 2, 'files_inside' => 3, 'user' => 4, 'group' => 5, 'size' => 6, 'date' => 7, 'name' => 8, ) Make sure at least the is_dir and name keys are set. The is_dir key should point to a subpattern that is empty for non-directories and non-empty for directories.
Parameters:
setHostname [line 1743]
bool setHostname(
string
$host)
|
|
Set the hostname
Parameters:
setMode [line 1836]
mixed setMode(
int
$mode)
|
|
Set the transfer-mode. You can use the predefined constants FTP_ASCII or FTP_BINARY. The mode will be stored for any further transfers.
Parameters:
setPassive [line 1853]
Set the transfer-method to passive mode
setPort [line 1762]
setSsl [line 1778]
Set to connect through secure SSL connection
setTimeout [line 1887]
bool setTimeout(
[int
$timeout = 0])
|
|
Set the timeout for FTP operations Use this method to set a timeout for FTP operation. Timeout has to be an integer.
Parameters:
setUsername [line 1797]
mixed setUsername(
string
$user)
|
|
Set the Username
Parameters:
site [line 986]
mixed site(
string
$command)
|
|
Execute a SITE command on the server This method tries to execute a SITE command on the ftp server.
Parameters:
size [line 1240]
mixed size(
string
$file)
|
|
This will return the size of a given file in bytes. You can either give this function a relative or an absolute file-path. NOTE: Some servers do not support this feature!
Parameters:
Documentation generated on Mon, 11 Mar 2019 16:01:42 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|