PHP Класс Horde\ManageSieve

Автор: Richard Heyes ([email protected])
Автор: Damian Fernandez Sosa ([email protected])
Автор: Anish Mistry ([email protected])
Автор: Jan Schneider ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$supportedAuthMethods array Can be overwritten if having problems with certain methods.
$supportedSASLAuthMethods array SASL authentication methods that require Auth_SASL.

Защищенные свойства (Protected)

Свойство Тип Описание
$_logger string | array Logging handler.
$_maxReferralCount array Maximum number of referral loops
$_params array Parameters and connection information.
$_sock Horde\Socket\Client The socket client.
$_state integer One of the STATE_* constants.

Открытые методы

Метод Описание
__construct ( array $params = [] ) Constructor.
connect ( string $host = null, string $port = null, array $context = null, boolean $secure = null ) Handles connecting to the server and checks the response validity.
disconnect ( boolean $sendLogoutCMD = true ) Disconnect from the Sieve server.
getActive ( ) : string Returns the active script.
getAuthMechs ( ) : array Returns the list of authentication methods the server supports.
getExtensions ( ) : array Returns the list of extensions the server supports.
getScript ( string $scriptname ) : string Retrieves a script.
hasAuthMech ( string $method ) : boolean Returns whether the server supports an authentication method.
hasExtension ( string $extension ) : boolean Returns whether the server supports an extension.
hasSpace ( string $scriptname, integer $size ) : boolean Checks if the server has space to store the script by the server.
installScript ( string $scriptname, string $script, boolean $makeactive = false ) Adds a script to the server.
listScripts ( ) : array Returns an indexed array of scripts currently on the server.
login ( string $user = null, string $password = null, string $authmethod = null, string $euser = null ) Logs into server.
removeScript ( string $scriptname ) Removes a script from the server.
setActive ( string $scriptname ) Sets the active script.
setLogger ( object $logger ) Passes a logger for debug logging.

Защищенные методы

Метод Описание
_authCRAMMD5 ( string $user, string $pass, string $euser ) Authenticates the user using the CRAM-MD5 method.
_authDigestMD5 ( string $user, string $pass, string $euser ) Authenticates the user using the DIGEST-MD5 method.
_authEXTERNAL ( string $user, string $pass, string $euser ) Authenticates the user using the EXTERNAL method.
_authLOGIN ( string $user, string $pass, string $euser ) Authenticates the user using the LOGIN method.
_authPLAIN ( string $user, string $pass, string $euser ) Authenticates the user using the PLAIN method.
_checkAuthenticated ( ) Asserts that the client is in authenticated state.
_checkConnected ( ) Asserts that the client is in disconnected state.
_cmdAuthenticate ( string $uid, string $pwd, string $authmethod = null, string $euser = '' ) Handles the authentication using any known method.
_cmdCapability ( ) Sends the CAPABILITY command
_cmdDeleteScript ( string $scriptname ) Removes a script from the server.
_cmdGetScript ( string $scriptname ) : string Retrieves the contents of the named script.
_cmdListScripts ( ) : array Returns the list of scripts on the server.
_cmdLogout ( boolean $sendLogoutCMD = true ) Logs out of the server and terminates the connection.
_cmdPutScript ( string $scriptname, string $scriptdata ) Adds a script to the server.
_cmdSetActive ( string $scriptname ) Sets the active script, i.e. the one that gets run on new mail by the server.
_debug ( string $message ) Write debug text to the current log handler.
_doCmd ( string $cmd = '', boolean $auth = false ) : string Send a command and retrieves a response from the server.
_escape ( string $string ) : string Converts strings into RFC's quoted-string or literal-c2s form.
_getBestAuthMethod ( string $authmethod = null ) : string Returns the name of the best authentication method that the server has advertised.
_handleConnectAndLogin ( ) Connects to the server and logs in.
_parseCapability ( string $data ) Parses the response from the CAPABILITY command and stores the result in $_capability.
_recvBytes ( integer $length ) : string Receives a number of bytes from the server.
_recvLn ( ) : string Receives a single line from the server.
_sendCmd ( string $cmd ) Sends a command to the server
_sendStringResponse ( string $str ) Sends a string response to the server.

Описание методов

__construct() публичный Метод

If username and password are provided connects to the server and logs in too.
public __construct ( array $params = [] )
$params array A hash of connection parameters: - host: Hostname of server (DEFAULT: localhost). Optionally prefixed with protocol scheme. - port: Port of server (DEFAULT: 4190). - user: Login username (optional). - password: Login password (optional). - authmethod: Type of login to perform (see $supportedAuthMethods) (DEFAULT: AUTH_AUTOMATIC). - euser: Effective user. If authenticating as an administrator, login as this user. - bypassauth: Skip the authentication phase. Useful if passing an already open socket. - secure: Security layer requested. One of: - true: (TLS if available/necessary) [DEFAULT] - false: (No encryption) - 'ssl': (Auto-detect SSL version) - 'sslv2': (Force SSL version 3) - 'sslv3': (Force SSL version 2) - 'tls': (TLS; started via protocol-level negotation over unencrypted channel) - 'tlsv1': (TLS version 1.x connection) - context: Additional options for stream_context_create(). - logger: A log handler, must implement debug().

_authCRAMMD5() защищенный Метод

Authenticates the user using the CRAM-MD5 method.
protected _authCRAMMD5 ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as. Not used.

_authDigestMD5() защищенный Метод

Authenticates the user using the DIGEST-MD5 method.
protected _authDigestMD5 ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as.

_authEXTERNAL() защищенный Метод

Authenticates the user using the EXTERNAL method.
protected _authEXTERNAL ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as.

_authLOGIN() защищенный Метод

Authenticates the user using the LOGIN method.
protected _authLOGIN ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as. Not used.

_authPLAIN() защищенный Метод

Authenticates the user using the PLAIN method.
protected _authPLAIN ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as.

_checkAuthenticated() защищенный Метод

Asserts that the client is in authenticated state.
protected _checkAuthenticated ( )

_checkConnected() защищенный Метод

Asserts that the client is in disconnected state.
protected _checkConnected ( )

_cmdAuthenticate() защищенный Метод

Handles the authentication using any known method.
protected _cmdAuthenticate ( string $uid, string $pwd, string $authmethod = null, string $euser = '' )
$uid string The userid to authenticate as.
$pwd string The password to authenticate with.
$authmethod string The method to use. If empty, the class chooses the best (strongest) available method.
$euser string The effective uid to authenticate as.

_cmdCapability() защищенный Метод

Sends the CAPABILITY command
protected _cmdCapability ( )

_cmdDeleteScript() защищенный Метод

Removes a script from the server.
protected _cmdDeleteScript ( string $scriptname )
$scriptname string Name of the script to delete.

_cmdGetScript() защищенный Метод

Retrieves the contents of the named script.
protected _cmdGetScript ( string $scriptname ) : string
$scriptname string Name of the script to retrieve.
Результат string The script.

_cmdListScripts() защищенный Метод

Returns the list of scripts on the server.
protected _cmdListScripts ( ) : array
Результат array An array with the list of scripts in the first element and the active script in the second element.

_cmdLogout() защищенный Метод

Logs out of the server and terminates the connection.
protected _cmdLogout ( boolean $sendLogoutCMD = true )
$sendLogoutCMD boolean Whether to send LOGOUT command before disconnecting.

_cmdPutScript() защищенный Метод

Adds a script to the server.
protected _cmdPutScript ( string $scriptname, string $scriptdata )
$scriptname string Name of the new script.
$scriptdata string The new script.

_cmdSetActive() защищенный Метод

Sets the active script, i.e. the one that gets run on new mail by the server.
protected _cmdSetActive ( string $scriptname )
$scriptname string The name of the script to mark as active.

_debug() защищенный Метод

Write debug text to the current log handler.
protected _debug ( string $message )
$message string Debug message text.

_doCmd() защищенный Метод

Send a command and retrieves a response from the server.
protected _doCmd ( string $cmd = '', boolean $auth = false ) : string
$cmd string The command to send.
$auth boolean Whether this is an authentication command.
Результат string Reponse string if an OK response.

_escape() защищенный Метод

Converts strings into RFC's quoted-string or literal-c2s form.
protected _escape ( string $string ) : string
$string string The string to convert.
Результат string Result string.

_getBestAuthMethod() защищенный Метод

Returns the name of the best authentication method that the server has advertised.
protected _getBestAuthMethod ( string $authmethod = null ) : string
$authmethod string Only consider this method as available.
Результат string The name of the best supported authentication method.

_handleConnectAndLogin() защищенный Метод

Connects to the server and logs in.
protected _handleConnectAndLogin ( )

_parseCapability() защищенный Метод

Parses the response from the CAPABILITY command and stores the result in $_capability.
protected _parseCapability ( string $data )
$data string The response from the capability command.

_recvBytes() защищенный Метод

Receives a number of bytes from the server.
protected _recvBytes ( integer $length ) : string
$length integer Number of bytes to read.
Результат string The server response.

_recvLn() защищенный Метод

Receives a single line from the server.
protected _recvLn ( ) : string
Результат string The server response line.

_sendCmd() защищенный Метод

Sends a command to the server
protected _sendCmd ( string $cmd )
$cmd string The command to send.

_sendStringResponse() защищенный Метод

Sends a string response to the server.
protected _sendStringResponse ( string $str )
$str string The string to send.

connect() публичный Метод

Defaults from the constructor are used for missing parameters.
public connect ( string $host = null, string $port = null, array $context = null, boolean $secure = null )
$host string Hostname of server.
$port string Port of server.
$context array List of options to pass to stream_context_create().
$secure boolean Security layer requested. @see __construct().

disconnect() публичный Метод

Disconnect from the Sieve server.
public disconnect ( boolean $sendLogoutCMD = true )
$sendLogoutCMD boolean Whether to send LOGOUT command before disconnecting.

getActive() публичный Метод

Returns the active script.
public getActive ( ) : string
Результат string The active scriptname.

getAuthMechs() публичный Метод

Returns the list of authentication methods the server supports.
public getAuthMechs ( ) : array
Результат array List of authentication methods.

getExtensions() публичный Метод

Returns the list of extensions the server supports.
public getExtensions ( ) : array
Результат array List of extensions.

getScript() публичный Метод

Retrieves a script.
public getScript ( string $scriptname ) : string
$scriptname string The name of the script to be retrieved.
Результат string The script.

hasAuthMech() публичный Метод

Returns whether the server supports an authentication method.
public hasAuthMech ( string $method ) : boolean
$method string The method to check.
Результат boolean Whether the method is supported.

hasExtension() публичный Метод

Returns whether the server supports an extension.
public hasExtension ( string $extension ) : boolean
$extension string The extension to check.
Результат boolean Whether the extension is supported.

hasSpace() публичный Метод

Checks if the server has space to store the script by the server.
public hasSpace ( string $scriptname, integer $size ) : boolean
$scriptname string The name of the script to mark as active.
$size integer The size of the script.
Результат boolean True if there is space.

installScript() публичный Метод

Adds a script to the server.
public installScript ( string $scriptname, string $script, boolean $makeactive = false )
$scriptname string Name of the script.
$script string The script content.
$makeactive boolean Whether to make this the active script.

listScripts() публичный Метод

Returns an indexed array of scripts currently on the server.
public listScripts ( ) : array
Результат array Indexed array of scriptnames.

login() публичный Метод

Defaults from the constructor are used for missing parameters.
public login ( string $user = null, string $password = null, string $authmethod = null, string $euser = null )
$user string Login username.
$password string Login password.
$authmethod string Type of login method to use.
$euser string Effective UID (perform on behalf of $euser).

removeScript() публичный Метод

Removes a script from the server.
public removeScript ( string $scriptname )
$scriptname string Name of the script.

setActive() публичный Метод

Sets the active script.
public setActive ( string $scriptname )
$scriptname string The name of the script to be set as active.

setLogger() публичный Метод

Passes a logger for debug logging.
public setLogger ( object $logger )
$logger object A log handler, must implement debug().

Описание свойств

$_logger защищенное свойство

Logging handler.
protected string|array $_logger
Результат string | array

$_maxReferralCount защищенное свойство

Maximum number of referral loops
protected array $_maxReferralCount
Результат array

$_params защищенное свойство

Parameters and connection information.
protected array $_params
Результат array

$_sock защищенное свойство

The socket client.
protected Client,Horde\Socket $_sock
Результат Horde\Socket\Client

$_state защищенное свойство

One of the STATE_* constants.
protected int $_state
Результат integer

$supportedAuthMethods публичное свойство

Can be overwritten if having problems with certain methods.
public array $supportedAuthMethods
Результат array

$supportedSASLAuthMethods публичное свойство

SASL authentication methods that require Auth_SASL.
public array $supportedSASLAuthMethods
Результат array