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

Class: HTTP_FloodControl

Source Location: /HTTP_FloodControl-0.1.1/FloodControl.php

Class Overview


Class for detecting and protecting from attempts to flood a site


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 65]
Class for detecting and protecting from attempts to flood a site

This class can be used to detect and protect a Web site from attempts to flood it with too many requests. It also allows to protect the site from automatic downloading many pages or files from the same IP address. The detection of flood is determine according to a set of parameters indicating the maximal allowed number of requests for the certain time interval. It is possible to set several parameters at once in order to perform more effective protection.



[ Top ]


Class Variables

$_container =  null

[line 76]

Container object used to store and retrieve data from request logs
  • Access: protected

Type:   object


[ Top ]

$_gcProbability =  30

[line 84]

Percent of probability that the garbage collection routine is started
  • Access: protected

Type:   integer


[ Top ]

$_incrementalLock =  false

[line 100]

Incremental locking flag
  • Access: protected

Type:   bool


[ Top ]

$_lifetime =  7200

[line 92]

Maximum lifetime of logs in seconds
  • Access: protected

Type:   int


[ Top ]



Method Detail

check   [line 259]

bool check( array $limits, [string $uniqueId = ''])

Detect a flooding attempt
  • Return: False, in case of flooding attempt detected.
  • Throws: HTTP_FloodControl_Exception if an error occured during checking process.
  • Access: public

Parameters:

array   $limits   —  Array of defined limits.
string   $uniqueId   —  Unique identifier.

[ Top ]

getIncrementalLock   [line 242]

bool getIncrementalLock( )

Gets the incremental lock flag

Gets the flag indicating if the incremental lock mode is enabled.

  • Return: Incremental lock flag.
  • Access: public

[ Top ]

getLifetime   [line 209]

int getLifetime( )

Gets the lifetime of the logs

Gets the maximum expire time of log entries.

  • Return: Lifetime in seconds.
  • Access: public

[ Top ]

getProbability   [line 172]

int getProbability( )

Gets probability of garbage collection

Gets the percent of probability that the garbage collection routine is started.

  • Return: Probability in percents.
  • Access: public

[ Top ]

getUserIP   [line 322]

string getUserIP( )

Tries to retrieve the real IP address behind proxy
  • Return: IP address.
  • Throws: HTTP_FloodControl_Exception when IP address seems to be invalid.
  • Access: public

[ Top ]

setContainer   [line 118]

void setContainer( string $container, mixed $options)

Init the storage container

Sets the user-defined storage functions which are used for storing and retrieving data associated with the class.

  • Throws: HTTP_FloodControl_Exception when container class does not exist or unable to set the container.
  • Access: public

Parameters:

string   $container   —  The name of the container to use.
mixed   $options   —  Additional options associated with the container.

[ Top ]

setIncrementalLock   [line 226]

void setIncrementalLock( bool $incrementalLock)

Sets the incremental lock mode

Sets the flag indicating if the incremental lock mode is enabled.

  • Access: public

Parameters:

bool   $incrementalLock   —  Incremental lock flag.

[ Top ]

setLifetime   [line 190]

void setLifetime( int $lifetime)

Sets the lifetime of the logs

Sets the maximum expire time of log entries.

  • Throws: HTTP_FloodControl_Exception in case of incorrect format of lifetime.
  • Access: public

Parameters:

int   $lifetime   —  Lifetime in seconds.

[ Top ]

setProbability   [line 148]

void setProbability( int $gcProbability)

Sets probability of garbage collection

Sets the percent of probability that the garbage collection routine is started.

  • Throws: HTTP_FloodControl_Exception in case of incorrect format of probability.
  • Access: public

Parameters:

int   $gcProbability   —  Probability in percents.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:57:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.