HostRestriction
Class HostRestriction
Tags
Table of Contents
Constants
- ACTION_REDIRECT = 'redirect'
- ACTION_STOP = 'stop'
Methods
- __construct() : mixed
- getAction() : string
- getActionOptions() : array<string|int, mixed>
- getActive() : bool
- getHosts() : string
- getLogging() : bool
- getProperties() : array<string|int, mixed>
- getValidationRegExp() : string
- Return regular expressions (based on hosts) for checking.
- isValidHost() : bool
- Checking host by host restriction policy
- onPageStart() : void
- Handler for system event "OnPageStart", does nothing in CLI mode because it does not make sense
- process() : $this
- The main method that checks the current host, logging and starting action
- save() : $this
- Save all properties, enable automatic checking and clear cache if needed
- setAction() : $this
- Set action performed while checking
- setActive() : $this
- Activate or deactivate automatic checking
- setHosts() : $this
- Set allowed hosts
- setLogging() : $this
- Activate or deactivate logging on unallowed host requested
- setProperties() : $this
- Set various properties for host checking, now support: - hosts: a string with allowed hosts (wild card supported, e.g.: *.example.com) {@see setHosts} - action: a string with action for unallowed host {@see validActions} - action_options: array with some options for action {@see setAction} - logging: bool, set true if need logging unallowed host {@see setLogging} - active: bool, set true if automatic checking on every request needed
Constants
ACTION_REDIRECT
public
mixed
ACTION_REDIRECT
= 'redirect'
ACTION_STOP
public
mixed
ACTION_STOP
= 'stop'
Methods
__construct()
public
__construct() : mixed
getAction()
public
getAction() : string
Return values
stringgetActionOptions()
public
getActionOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getActive()
public
getActive() : bool
Return values
boolgetHosts()
public
getHosts() : string
Return values
stringgetLogging()
public
getLogging() : bool
Return values
boolgetProperties()
public
getProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>getValidationRegExp()
Return regular expressions (based on hosts) for checking.
public
getValidationRegExp() : string
Note: regular expression is cached for performance improvement and auto cleared after saving save
Return values
stringisValidHost()
Checking host by host restriction policy
public
isValidHost(string $host) : bool
Parameters
- $host : string
-
Host for checking.
Tags
Return values
bool —Return true for valid (allowed) host.
onPageStart()
Handler for system event "OnPageStart", does nothing in CLI mode because it does not make sense
public
static onPageStart() : void
process()
The main method that checks the current host, logging and starting action
public
process([string $host = null ]) : $this
Parameters
- $host : string = null
-
Requested host for checking.
Return values
$thissave()
Save all properties, enable automatic checking and clear cache if needed
public
save() : $this
Return values
$thissetAction()
Set action performed while checking
public
setAction(string $action[, array<string|int, mixed> $options = array() ]) : $this
Parameters
- $action : string
-
Some action, now supported: redirect and stop.
- $options : array<string|int, mixed> = array()
-
Some options for action, so far supported only host for redirect in redirect action.
Tags
Return values
$thissetActive()
Activate or deactivate automatic checking
public
setActive([bool $isActive = false ]) : $this
Parameters
- $isActive : bool = false
-
Set true for enable checking on every request.
Tags
Return values
$thissetHosts()
Set allowed hosts
public
setHosts(string $hosts[, bool $ignoreChecking = false ]) : $this
Parameters
- $hosts : string
-
Allowed hosts (wild card supported, e.g.: *.example.com).
- $ignoreChecking : bool = false
-
Set false for disable host validating before set.
Tags
Return values
$thissetLogging()
Activate or deactivate logging on unallowed host requested
public
setLogging([bool $isLogNeeded = true ]) : $this
Parameters
- $isLogNeeded : bool = true
-
Set true if need logging unallowed host.
Tags
Return values
$thissetProperties()
Set various properties for host checking, now support: - hosts: a string with allowed hosts (wild card supported, e.g.: *.example.com) {@see setHosts} - action: a string with action for unallowed host {@see validActions} - action_options: array with some options for action {@see setAction} - logging: bool, set true if need logging unallowed host {@see setLogging} - active: bool, set true if automatic checking on every request needed
public
setProperties(array<string|int, mixed> $properties) : $this
Parameters
- $properties : array<string|int, mixed>
-
See above.