FTP
[ class tree: FTP ] [ index: FTP ] [ all elements ]

File: Socket.php

Source Location: /Net_FTP-1.4.0a2/Net/FTP/Socket.php

Classes:

Page Details:

Net_FTP socket implementation of FTP functions.

The functions in this file emulate the ext/FTP functions through ext/Socket.

PHP versions 4 and 5

LICENSE: This source file is subject to version 3.0 of the PHP license that is available through the world-wide-web at the following URI: http://www.php.net/license/3_0.txt. If you did not receive a copy of the PHP License and are unable to obtain it through the web, please send a note to license@php.net so we can mail you a copy immediately.


FTP_ASCII [line 34]

FTP_ASCII = 0
Default FTP extension constants

[ Top ]



FTP_BINARY [line 36]

FTP_BINARY = 1

[ Top ]



FTP_IMAGE [line 37]

FTP_IMAGE = 1

[ Top ]



FTP_TEXT [line 35]

FTP_TEXT = 0

[ Top ]



FTP_TIMEOUT_SEC [line 38]

FTP_TIMEOUT_SEC = 0

[ Top ]



ftp_alloc [line 505]

boolean ftp_alloc( resource &$control, integer $int, [string &$msg = null])

boolean ftp_alloc ( resource stream, integer bytes [, string &message ] );

Allocates space for a file to be uploaded Return TRUE on success or FALSE on failure

NOTE; Many FTP servers do not support this command and/or don't need it.

FTP success respons key: Belive it's 200 Needs data connection: NO

  • Access: public


Parameters

resource   &$control   FTP stream
integer   $int   Space to allocate
string   &$msg   Optional, textual representation of the servers response will be returned by reference
[ Top ]



ftp_cdup [line 679]

boolean ftp_cdup( integer &$control)

Changes to the parent directory Returns TRUE on success or FALSE on failure
  • Access: public


Parameters

integer   &$control   Stream ID
[ Top ]



ftp_chdir [line 253]

boolean ftp_chdir( resource &$control, string $pwd)

boolean ftp_chdir ( resource stream, string directory );

Changes the current directory to the specified directory. Returns TRUE on success or FALSE on failure.

FTP success response code: 250 Needs data connection: NO

  • Access: public


Parameters

resource   &$control   FTP stream
string   $pwd   Directory name
[ Top ]



ftp_chmod [line 706]

integer ftp_chmod( integer &$control, integer $mode, string $file)

Set permissions on a file via FTP Returns the new file permission on success or false on error

NOTE: This command is *not* supported by the standard NOTE: This command not ready!

  • Todo: Figure out a way to chmod files via FTP
  • Access: public


Parameters

integer   &$control   Stream ID
integer   $mode   Octal value
string   $file   File to change permissions on
[ Top ]



ftp_close [line 195]

boolean ftp_close( resource &$control)

Alias to ftp_quit()


Parameters

resource   &$control   FTP resource
[ Top ]



ftp_connect [line 73]

&resource &ftp_connect( string $host, [int $port = 21], [int $timeout = 90])

&resource ftp_connect ( string host [, int port [, int timeout ] ] );

Opens an FTP connection and return resource or false on failure.

FTP Success respons code: 220

  • Todo: The FTP extension has ftp_set_option() function which sets the timeout variable. This function needs to be created and called here.
  • Todo: The FTP extension has ftp_get_option() function which returns the timeout variable. This function needs to be created and contain it as static variable.
  • Access: public


Parameters

string   $host   Host to connect to
int   $port   Optional, port to connect to
int   $timeout   Optional, seconds until function timeouts
[ Top ]



ftp_delete [line 737]

boolean ftp_delete( integer &$control, string $path)

Deletes a file on the FTP server Returns TRUE on success or FALSE on failure
  • Access: public


Parameters

integer   &$control   Stream ID
string   $path   File to delete
[ Top ]



ftp_exec [line 765]

boolean ftp_exec( integer &$control, string $cmd)

Requests execution of a program on the FTP server NOTE; SITE EXEC is *not* supported by the standart Returns TRUE on success or FALSE on error
  • Todo: Look a littlebit better into this
  • Access: public


Parameters

integer   &$control   Stream ID
string   $cmd   Command to send
[ Top ]



ftp_get [line 636]

boolean ftp_get( integer &$control, string $local, string $remote, integer $mode, [integer $resume = 0])

Retrieve a remote file to a local file Returns TRUE on success or FALSE on failure
  • Access: public


Parameters

integer   &$control   Stream ID
string   $local   Local filename
string   $remote   Remote filename
integer   $mode   Transfer mode (FTP_ASCII or FTP_BINARY)
integer   $resume   Resume the file transfer or not
[ Top ]



ftp_login [line 123]

boolean ftp_login( resource &$control, string $username, string $password)

boolean ftp_login ( resource stream, string username, string password );

Logs in to an given FTP connection stream. Returns TRUE on success or FALSE on failure.

NOTE: Username and password are *not* optional. Function will *not* assume "anonymous" if username and/or password is empty

FTP Success respons code: 230

  • Access: public


Parameters

resource   &$control   FTP resource to login to
string   $username   FTP Username to be used
string   $password   FTP Password to be used
[ Top ]



ftp_pasv [line 301]

boolean ftp_pasv( stream &$control, boolean $pasv)

boolean ftp_pasv ( resource stream, boolean passive );

Toggles passive mode ON/OFF. Returns TRUE on success or FALSE on failure.

Comment: Although my lack of C knowlege I checked how the PHP FTP extension do things here. Seems like they create the data connection and store it in object for other functions to use. This is now done here.

FTP success response code: 227

  • Access: public


Parameters

stream   &$control   FTP stream
boolean   $pasv   True to switch to passive, false for active mode
[ Top ]



ftp_put [line 542]

boolean ftp_put( resource &$control, string $remote, string $local, integer $mode, [integer $pos = 0])

bool ftp_put ( resource stream, string remote_file, string local_file, int mode [, int startpos ] );

Uploads a file to the FTP server Returns TRUE on success or FALSE on failure.

NOTE: The transfer mode specified must be either FTP_ASCII or FTP_BINARY.

  • Access: public


Parameters

resource   &$control   FTP stream
string   $remote   Remote file to write
string   $local   Local file to upload
integer   $mode   Upload mode, FTP_ASCI || FTP_BINARY
integer   $pos   Optional, start upload at position
[ Top ]



ftp_pwd [line 214]

string ftp_pwd( resource &$control)

string ftp_pwd ( resource stream );

Gets the current directory name. Returns the current directory.

Needs data connection: NO Success response code: 257

  • Access: public


Parameters

resource   &$control   FTP resource
[ Top ]



ftp_quit [line 174]

boolean ftp_quit( resource &$control)

boolean ftp_quit ( resource stream );

Closes FTP connection. Returns TRUE or FALSE on error.

NOTE: The PHP function ftp_quit is *alias* to ftp_close, here it is the *other-way-around* ( ftp_close() is alias to ftp_quit() ).

NOTE: resource is set to null since unset() can't unset the variable.

  • Access: public


Parameters

resource   &$control   FTP resource
[ Top ]



ftp_rawlist [line 402]

array ftp_rawlist( integer &$control, string $pwd, [boolean $recursive = false])

array ftp_rawlist ( resource stream, string directory [,bool recursive] );

Returns a detailed list of files in the given directory.

Needs data connection: YES

  • Todo: Enable the recursive feature.
  • Access: public


Parameters

integer   &$control   FTP resource
string   $pwd   Path to retrieve
boolean   $recursive   Optional, retrieve recursive listing
[ Top ]



ftp_systype [line 469]

string ftp_systype( resource &$control)

string ftp_systype ( resource stream );

Gets system type identifier of remote FTP server Returns the remote system type

  • Access: public


Parameters

resource   &$control   FTP resource
[ Top ]



Documentation generated on Mon, 19 May 2008 16:00:15 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.