ngFTPD v.1.0

Writing plugins ^ HOWTO

If you have any questions,ideas or found a bug then feel free and send me a email: ngftpd@hotmail.de or visit us on www.ngftpd.de.vu

First of all you must declare one of the fallowing functions in the class 'Plugin':

Note: All Properties/Methods/Function/Class names are case sensitive.

Events:

Load(ByVal Clients As Collection, ByVal FTPInfo As Object)
		
	Description: This will be called on the server startup.


UnLoad()

	Description: This will be called on the 'site unload' command.


OnLogin(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called when a new client is logged in.


OnCreateFolder(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called a client creates a new folder.


OnRemoveFolder(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called a client delete a folder.


OnRemoveFile(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called a client delete a file.


OnMove(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called a client moves or rename a file or folder.


OnSite(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called the client sends a 'site' command.


OnSFVNew(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called when the server recevied a new sfv file.


OnSFVFirstFile(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called when the server recevied a the first file from the sfv file.


OnSFVHalfway(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called when the you have uploaded 50% of the sfv files.


OnSFVComplete(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called when the you have uploaded 100% of the sfv files.


OnDisconnect(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called when the client disconnects.


OnList(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

	Description: This will be called when the server recevied the 'LIST' command.


"Clients":
Holds a referance to the a collection with the ClientData objects, with the users who are currently conntected to the server.

"ClientData":
Holds a referance to the ClientData object, the ClientData object contains the fallowing properties/methods to get information about the client:

Properties:

	ClientData.ClientThread

		Type: Thread
		Description: Gets / Sets the client Thread.

	ClientData.Command

		Type: String
		Description: Gets / Sets the last client command.

	ClientData.ConnectTime

		Type: String
		Description: Gets / Sets the datetime	the client connected.

	ClientData.Credits

		Type: String
		Description: Gets / Sets the clients credits.

	ClientData.CurrentFile

		Type: String
		Description: Gets / Sets the file, if the client is currently down- uploading a file.

	ClientData.CurrentSection

		Type: String
		Description: Gets / Sets the section name from the client.

	ClientData.CurrentDownloadSpeed

		Type: String
		Description: Gets / Sets the clients credits.

	ClientData.CurrentUploadSpeed

		Type: String
		Description: Gets / Sets the clients current upload speed.

	ClientData.DownloadTraffic

		Type: Int64
		Description: Gets / Sets the clients download traffic.

	ClientData.UploadTraffic

		Type: Int64
		Description: Gets / Sets the clients upload traffic.

	ClientData.Flags

		Type: String
		Description: Gets / Sets the group flags from the client.

	ClientData.GroupName

		Type: String
		Description: Gets / Sets the group name from the client.

	ClientData.HasSSL

		Type: Boolean
		Description: Returns True if the client is using ssl.

	ClientData.HomeDir

		Type: String
		Description: Gets / Sets the clients homedir.

	ClientData.ID

		Type: Integer
		Description: Gets / Sets the clients identification number.

	ClientData.LastAction

		Type: Date
		Description: Gets / Sets the clients datetime, since the last command was received.

	ClientData.LocalDir

		Type: String
		Description: Gets / Sets the clients current localdir.

	ClientData.LoggedIn

		Type: Boolean
		Description: Returns True if the client is loggedin.

	ClientData.Maxlogins

		Type: Integer
		Description: Gets / Sets the max client logins.

	ClientData.Param

		Type: Integer
		Description: Gets / Sets the max client logins.

	ClientData.Privilege

		Type: Integer
		Description: Gets / Sets the client privilege.
		'0' for normal user.
		'1' for group admin.
		'2' for admin.

	ClientData.Ratio

		Type: String
		Description: Gets / Sets the client ratio.

	ClientData.RemoteDir

		Type: String
		Description: Gets / Sets the client remote dir.

	ClientData.RemoteIP

		Type: String
		Description: Gets / Sets the client remote IP.

	ClientData.RemotePort

		Type: String
		Description: Gets / Sets the client remote port.

	ClientData.Rootdir

		Type: String
		Description: Gets / Sets the client root dir.

	ClientData.Slots

		Type: String
		Description: Gets / Sets the client slots, if 'ClientData.Maxlogins' is not set this property will work. Sets by the group.

	ClientData.Username

		Type: String
		Description: Gets / Sets the client username.

Methods:

	ClientData.Disconnect()

		Description: Disconnects the client. Use this for example, if you want to kick a client.

	ClientData.Send(str as String)

		Description: Sends a string to the client.

	ClientData.Traffic()

		Type: Int64
		Description: Returns the clients up+download traffic.

"FTPInfo":
Holds a referance to the FTPInfo object, the FTPInfo object contains the fallowing properties/methods to get information about the server:

Properties:

	FTPInfo.DownloadTraffic

		Type: Int64
		Description: Gets / Sets the servers download traffic.

	FTPInfo.UploadTraffic

		Type: Int64
		Description: Gets / Sets the servers upload traffic.

	FTPInfo.LocalIP

		Type: String
		Description: Gets / Sets the server IP.

	FTPInfo.Port

		Type: Integer
		Description: Gets / Sets the server Port.


Here is a example how to implement own site command:

Open VS 2005 -> Create New Project -> Visual Basic or C# -> Create new class libary.

in VB:

Public Class Plugin 'must named Plugin
    Sub OnSite(ByVal Clients As Collection, ByVal ClientData As Object, ByVal FTPInfo As Object)

        'Your code to do something

        ClientData.Send("200 Command successful." & vbCrLf) 'If your command completed send the ftp command to the client.
        Exit Sub 'Exit sub because we don't want to call a ngftpd site command.
    End Sub
End Class



