Class: Net_FTP
Source Location: /Net_FTP-1.3.2/Net/FTP.php
PEAR
|
--Net_FTP
Class for comfortable FTP-communication
Author(s):
Version:
- Release: @package_version@
Copyright:
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
Net_FTP (Constructor) [line 630]
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 1605]
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 1758]
boolean attach(
&$observer, 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 734]
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 1428]
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 861]
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 904]
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 655]
mixed connect(
[string
$host = null], [int
$port = 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 1778]
boolean detach(
object
$observer)
|
|
Removes a Net_FTP_Observer instance from the list of observers.
Parameters:
disconnect [line 680]
bool|PEAR_Error disconnect(
)
|
|
This function close the FTP-connection
execute [line 817]
mixed execute(
string
$command)
|
|
This method tries executing a command on the ftp, using SITE EXEC.
Parameters:
get [line 1212]
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 spcify a 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 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:
getExtensionMode [line 1729]
int getExtensionMode(
string
$ext)
|
|
Returns the mode set for a file-extension
Parameters:
getExtensionsFile [line 1635]
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!
Parameters:
getHostname [line 1656]
getMode [line 1704]
getPassword [line 1692]
getPort [line 1668]
getRecursive [line 1316]
mixed getRecursive(
string
$remote_path, string
$local_path, [bool
$overwrite = false], [int
$mode = null])
|
|
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.
Parameters:
getTimeout [line 1742]
Get the currently set timeout. Returns the actual timeout set.
getUsername [line 1680]
isPassive [line 1716]
Returns, whether the connection is set to passive mode or not
login [line 701]
mixed login(
[string
$username = null], [string
$password = null])
|
|
This logges 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.
Parameters:
ls [line 1129]
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. The 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 1043]
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 775]
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 1263]
mixed put(
string
$local_file, string
$remote_file, [bool
$overwrite = false], [int
$mode = null])
|
|
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 1379]
mixed putRecursive(
string
$local_path, string
$remote_path, [bool
$overwrite = false], [int
$mode = null])
|
|
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 753]
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 1619]
void removeExtension(
string
$ext)
|
|
This function removes an extension from the mode-directories (described above).
Parameters:
rename [line 996]
bool rename(
string
$remote_from, string
$remote_to)
|
|
Rename or move a file or a directory from the ftp-server
Parameters:
rm [line 1177]
mixed rm(
string
$path, [bool
$recursive = 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 1555]
Set the transfer-method to active mode
setHostname [line 1454]
bool setHostname(
string
$host)
|
|
Set the Hostname
Parameters:
setMode [line 1525]
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 1542]
Set the transfer-method to passive mode
setPort [line 1472]
setTimeout [line 1571]
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 1490]
mixed setUsername(
string
$user)
|
|
Set the Username
Parameters:
site [line 837]
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 1072]
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 14:36:34 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|