Public Method Details |
Bs_FtpClient |
|
public void Bs_FtpClient( )
|
| |
constructor
|
| Returns |
void |
|
reset |
|
public void reset( )
|
| |
clears up the object by resetting all class vars to its original state,
as if the object was newly created. reusing an object this way savesresources and time in php (instead of creating a new object).the subclassing class should implement a reset() method also, call thisone to clean up the vars of this class, and clean up it's own vars itself.and of course disconnect the connection first.
|
| Returns |
void |
|
connect |
|
public bool connect( )
|
| |
Opens up an FTP connection (to the current host/port).
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
login |
|
public bool login( )
|
| |
Logs in an FTP connection.
uses the current username/password.
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
pwd |
|
public string pwd( [ string $useCache ] )
|
| |
Returns the current remote directory name.
|
| Parameter |
|
| string |
$useCache |
= >>TRUE<< |
|
default is TRUE. if we should use the cached information if available. |
|
| Returns |
string |
| Throws |
bool FALSE |
|
localPwd |
|
public string localPwd( )
|
| |
Returns the current local directory name.
|
| Returns |
string |
|
cdUp |
|
public bool cdUp( )
|
| |
Changes to the remote parent directory.
it's like doing 'cd ..'.
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
localCdUp |
|
public bool localCdUp( )
|
| |
Changes to the local parent directory.
it's like doing 'cd ..'.
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
chDir |
|
public bool chDir( string $directory )
|
| |
Changes remote directory.
|
| Parameter |
|
| string |
$directory |
|
|
(the directory to go to.) |
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
localChDir |
|
public bool localChDir( )
|
| |
Changes local directory.
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
mkDir |
|
public bool mkDir( string $directory )
|
| |
Creates a remote directory.
your current working dir won't change [into that directory].
|
| Parameter |
|
| string |
$directory |
|
|
(the new directory name.) |
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
localMkDir |
|
public mixed localMkDir( string $directory )
|
| |
Creates a local directory.
|
| Parameter |
|
| string |
$directory |
|
|
(the new directory name.) |
|
| Returns |
mixed (string (the new directory name) on success, bool FALSE on failure. |
|
rmDir |
|
public bool rmDir( string $directory )
|
| |
Removes a remote directory.
the directory must be empty.if you are currently in that directory (current working dir) you better move out.the ftp command for this is RMD.
|
| Parameter |
|
| string |
$directory |
|
|
(the directory name.) |
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
rmDirRec |
|
public int rmDirRec( string $directory )
|
| |
Removes a remote directory recursively; with all content in it.
if you are currently in that directory (current working dir) you better move out.
|
| Parameter |
|
| string |
$directory |
|
|
(the directory name.) |
|
| Returns |
int (1 if everything was removed, 0 if parts were removed, -1 if nothing was removed.) |
|
localRmDir |
|
public bool localRmDir( string $directory )
|
| |
Removes a local directory.
|
| Parameter |
|
| string |
$directory |
|
|
(the directory name.) |
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
&nList |
|
public array &nList( string $directory )
|
| |
Returns a list of files in the given remote directory.
2do: does it return directories too? how about file- and dirlinks?are the values relative or absolute?
|
| Parameter |
|
| string |
$directory |
|
|
(the directory name.) |
|
| Returns |
array (vector of filenames.) |
| Throws |
bool FALSE |
|
localNlist |
|
public mixed localNlist( string $directory )
|
| |
Returns a list of files in the given local directory.
|
| Parameter |
|
| string |
$directory |
|
|
(the directory name.) |
|
| Returns |
mixed (an array (vector) of filenames on success, bool FALSE on failure. |
|
&rawList |
|
public mixed &rawList( string $directory, [ string $parse ] )
|
| |
Returns a detailed list of files in the given remote directory.
executes the FTP LIST command.if param $parse is TRUE, the return value is a vector holding a hash.each file is represented by a hash inside the vector. for details seeparseRawList().if param $parse is FALSE, the return value is a vector holding stringswith the unparsed information. use $this->sysType() to do something on your own.or better implement the missing functionality into your favorite ftp class!whatever! do something! don't just sit here and stare at these lines! and giveme some of your pizza! *yummy* :-)
|
| Parameter |
|
| string |
$directory |
|
|
(the directory name.) |
|
|
| string |
$parse |
= >>TRUE<< |
|
(default is TRUE, see above.) |
|
| Returns |
mixed (an array (vector) see above, bool FALSE on failure. |
|
&parseRawList |
|
public array &parseRawList( array &$rawList )
|
| |
parses the given $rawList.
i really don't see why the return of an ftp LIST command has never been standardized.see header documentation.different ftp servers return a different string format. please report here what you know.Serv-U version 2.4"-rw-r--r-- 1 user group 117 Sep 17 10:38 welcomeMessage.txt"comets ftpd (some linux ftpd, i should check that.)"drwxr-xr-x 3 root root 4096 Jan 25 2001 ircd"Serv-U and the linux one give the same output (one space different). that's pretty good.description of the parts:drwxr-xr-x => the first character can be a 'd' or a '-'. d means the 'file' is a directory,- means it is a file.3 => this integer is a number from 1 to n. if the 'file' is a file, it's alwaysset to 1. if it is a directory, it is 2-n. it is the number of (recursive)subdirectories plus the current directory plus 1. so a '3' means this dirhas exactly one subdir.root => the owner user.root => the owner group.4096 => the file size in bytes.Jan 25 2001 => this is the datetime in some strange format and with missing information.if the file has changed this year for the last time, we get month day andhour/minute. if it was in a previous year, we get month day and the year.anyway we never get the seconds. this makes it harder/more buggy tosynchronize files.ircd => the file/directory name (whatever it is). i've read about problems if the nameshave spaces in there. my suggestion: don't use spaces at all.the return array may have the following keys, depending on the ftpserver-os:'name' => 'someshit.txt' //file or directory name'size' => 4096 //bytes'date' => '2001/09/07 08:23' //or '2001/09/07'. see above.'attr' => 'drwxr-xr-x' //(directory yes/no, user rights, group rights, world rights)'type' => [dir|file] //can't tell if it's a link :('dirno' => [1-n] //the directory number, details see above.'user' => 'root' //the owner user. on windows this doesn't mean much.'group' => 'root' //the owner group. on windows this doesn't mean much.
|
| Parameter |
|
|
| Returns |
array (see above) |
| Throws |
bool FALSE if not capable = we did not get the format above. |
|
&localRawList |
|
public array &localRawList( string $localDir )
|
| |
Returns a detailed list of files in the given local directory.
in difference to rawList() the returned value is always 'parsed'. everything elsewould make no sense.
|
| Parameter |
|
|
| Returns |
array (vector holding hashes) |
|
sysType |
|
public string sysType( [ string $useCache ] )
|
| |
Returns the system type identifier of the remote FTP server.
executes the FTP SYST command.the name returned shall be one listed in the assigned numbers document. seethe kb file operatingSystemNames.txt (about 130 are listed).my Serv-U ftpd on windows returns 'UNIX', exactly like some ftpd on my linuxbox does. and because they give similar unix-like output on the LIST command(see parseRawList()) i think that's what it's for. if you want to know theoperating system you better use something else than ftp.
|
| Parameter |
|
| string |
$useCache |
= >>TRUE<< |
|
default is TRUE. if we should use the cached information if available. |
|
| Returns |
string |
| Throws |
bool FALSE |
|
pasv |
|
public bool pasv( bool $param )
|
| |
Turns passive mode on or off.
if $param is TRUE, passive mode will be activated, deactivated otherwise.in passive mode, data connections are initiated by the client, rather than by the server.
|
| Parameter |
|
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
get |
|
public bool get( string $localFile, string $remoteFile, [ string $mode ] )
|
| |
Downloads a file from the FTP server.
retrieves $remoteFile from the FTP server, and saves it to $localFile locally. Thetransfer mode specified must be either FTP_ASCII or FTP_BINARY.caution: overwrites any existing file.
|
| Parameter |
|
|
|
|
|
| string |
$mode |
= >>NULL<< |
|
(use constant, one of FTP_ASCII or FTP_BINARY. if not given $this->_transferMode is used.) |
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
fGet |
|
public bool fGet( int $fp, string $remoteFile, [ string $mode ] )
|
| |
Downloads a file from the FTP server and saves to an open file.
retrieves remote_file from the FTP server, and writes it to the given file pointer, fp.The transfer mode specified must be either FTP_ASCII or FTP_BINARY.
|
| Parameter |
|
|
|
|
|
| string |
$mode |
= >>NULL<< |
|
(use constant, one of FTP_ASCII or FTP_BINARY. if not given $this->_transferMode is used.) |
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
put |
|
public bool put( string $localFile, string $remoteFile, [ string $mode ] )
|
| |
Uploads a file to the FTP server.
stores local_file on the FTP server, as remote_file. The transfer mode specifiedmust be either FTP_ASCII or FTP_BINARY.caution: overwrites any existing file.
|
| Parameter |
|
|
|
|
|
| string |
$mode |
= >>NULL<< |
|
(use constant, one of FTP_ASCII or FTP_BINARY. if not given $this->_transferMode is used.) |
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
fPut |
|
public bool fPut( int $fp, string $remoteFile, [ string $mode ] )
|
| |
Uploads from an open file to the FTP server.
uploads the data from the file pointer fp until end of file. The results are storedin remote_file on the FTP server. The transfer mode specified must be either FTP_ASCIIor FTP_BINARY.
|
| Parameter |
|
|
|
|
|
| string |
$mode |
= >>NULL<< |
|
(use constant, one of FTP_ASCII or FTP_BINARY. if not given $this->_transferMode is used.) |
|
| Returns |
bool TRUE on success, FALSE on failure. |
|
fileExists |
|
public bool fileExists( string $remoteFile )
|
| |
tells if the given file exists on the server.
|
| Parameter |
|
|
| Returns |
bool TRUE if it does, FALSE if it does not |
| Throws |
null if we can't tell (error, no permission) |
|
size |
|
public int size( string $remoteFile )
|
| |
Returns the size of the given remote file.
caution: Not all servers support this feature. see header documentation.please report here which server do/don't support it. thanx.executes the FTP SIZE command.
|
| Parameter |
|
|
| Returns |
int the file size (in bytes i guess) |
| Throws |
bool FALSE on error or if not supported by server. |
| See Also |
localSize() |
|
localSize |
|
public int localSize( string $localFile )
|
| |
Returns the size of the given local file.
|
| Parameter |
|
|
| Returns |
int the file size (in bytes i guess) |
| Throws |
bool FALSE on error |
| See Also |
size() |
|
lastMod |
|
public int lastMod( string $remoteFile )
|
| |
Returns the last modified time of the given remote file.
caution: Not all servers support this feature. see header documentation.note: does not work with directories.executes the FTP MDTM command.
|
| Parameter |
|
|
| Returns |
int unix timestamp |
| Throws |
bool FALSE on error or if not supported by server. |
| See Also |
localLastMod() |
|
localLastMod |
|
public int localLastMod( string $localFile )
|
| |
Returns the last modified time of the given local file.
|
| Parameter |
|
|
| Returns |
int unix timestamp |
| Throws |
bool FALSE on error |
| See Also |
lastMod() |
|
rename |
|
public bool rename( string $remoteFile, string $newRemoteFile )
|
| |
Renames a file on the ftp server.
|
| Parameter |
|
|
|
|
| Returns |
bool TRUE on success, FALSE on failure. |
| See Also |
localRename() |
|
localRename |
|
public bool localRename( string $localFile, string $newLocalFile )
|
| |
Renames a local file.
|
| Parameter |
|
|
|
|
| Returns |
bool TRUE on success, FALSE on failure. |
| See Also |
rename() |
|
delete |
|
public bool delete( string $remoteFile )
|
| |
Deletes a file on the ftp server.
|
| Parameter |
|
|
| Returns |
bool TRUE on success, FALSE on failure. |
| See Also |
localDelete() |
|
localDelete |
|
public bool localDelete( string $localFile )
|
| |
Deletes a local file.
|
| Parameter |
|
|
| Returns |
bool TRUE on success, FALSE on failure. |
| See Also |
delete() |
|
site |
|
public void site( string $command )
|
| |
Sends a SITE command to the server.
sends the command $command to the FTP server. SITE commands are not standardized,and vary from server to server. They are useful for handling such things as filepermissions and group membership.
|
| Parameter |
|
|
| Returns |
void |
|
quit |
|
public void quit( )
|
| |
Closes the FTP connection.
|
| Returns |
void |
|