abstract class FirewallModule in Anti Spam by CleanTalk 8.4
Same name and namespace in other branches
- 9.1.x src/lib/Cleantalk/Common/Firewall/FirewallModule.php \Cleantalk\Common\Firewall\FirewallModule
Hierarchy
- class \Cleantalk\Common\Firewall\FirewallModule
Expanded class hierarchy of FirewallModule
3 files declare their use of FirewallModule
- AntiCrawler.php in src/
lib/ Cleantalk/ Common/ Firewall/ Modules/ AntiCrawler.php - AntiFlood.php in src/
lib/ Cleantalk/ Common/ Firewall/ Modules/ AntiFlood.php - SFW.php in src/
lib/ Cleantalk/ Common/ Firewall/ Modules/ SFW.php
File
- src/
lib/ Cleantalk/ Common/ Firewall/ FirewallModule.php, line 20
Namespace
Cleantalk\Common\FirewallView source
abstract class FirewallModule {
/**
* @var string
*/
protected $api_key;
/**
* @var string
*/
public $module_name = 'FireWall Module';
/**
* @var array
*/
protected $ip_array = array();
/**
* @var DB
*/
protected $db;
/**
* @var string
*/
protected $db_log_table_name;
/**
* @var string
*/
protected $db_data_table_name;
/**
* @var Helper
*/
protected $helper;
/**
* @var string
*/
protected $real_ip;
/**
* @var string
*/
protected $test_ip;
/**
* @var bool
*/
protected $test;
/**
* @var bool
*/
protected $debug;
/**
* @var array
*/
protected $debug_data = array();
/**
* FirewallModule constructor.
* Use this method to prepare any data for the module working.
*
* @param string $data_table
* @param array $params
*/
public abstract function __construct($data_table, $params = array());
/**
* Use this method to execute main logic of the module.
*
* @return array Array of the check results
*/
public abstract function check();
/**
* Do logic for denied request.
*
* @param string $result
* @return void
*/
public abstract function actionsForDenied($result);
/**
* Do logic for allowed request.
*
* @param string $result
* @return void
*/
public abstract function actionsForPassed($result);
/**
* Configure and set additional properties: real_ip, test_ip, test
*
* @param array $ips
* @return void
*/
public function ipAppendAdditional($ips) {
$this->real_ip = isset($ips['real']) ? $ips['real'] : null;
if (Get::get('sfw_test_ip') && Helper::ip__validate(Get::get('sfw_test_ip')) !== false) {
$this->ip_array['sfw_test'] = Get::get('sfw_test_ip');
$this->test_ip = Get::get('sfw_test_ip');
$this->test = true;
}
}
/**
* Set specify CMS based DB instance
*
* @param DB $db
*/
public function setDb(DB $db) {
$this->db = $db;
}
/**
* Set Log Table name
*
* @param string $log_table_name
*/
public function setLogTableName($log_table_name) {
$this->db_data_table_name = $this->db->prefix . $this->db_data_table_name;
$this->db_log_table_name = $log_table_name;
}
/**
* Set specify CMS based Helper instance
*
* @param Helper $helper
*/
public function setHelper(Helper $helper) {
$this->helper = $helper;
}
/**
* Set API KEY
*
* @param string $api_key
*/
public function setApiKey($api_key) {
$this->api_key = $api_key;
}
/**
* Set is debug property.
*
* @param bool $debug
*/
public function setIsDebug($debug) {
$this->debug = $debug;
}
/**
* Set visitor's IP
*
* @param array $ip_array $ip_array = array( 'real' => '1.2.3.4' )
*/
public function setIpArray($ip_array) {
$this->ip_array = $ip_array;
}
/**
* Default die page for blocked requests.
*
* @param array $result
*/
public function _die($result) {
// Headers
if (headers_sent() === false) {
header('Expires: ' . date(DATE_RFC822, mktime(0, 0, 0, 1, 1, 1971)));
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
header("HTTP/1.0 403 Forbidden");
}
}
/**
* This is a placeholder for WP translation function.
* For compatibility with any CMS.
*
* @param $string
* @param $text_domain
* @return mixed
*/
public function __($string, $text_domain) {
if (function_exists('__')) {
return __($string, $text_domain);
}
return $string;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FirewallModule:: |
protected | property | ||
FirewallModule:: |
protected | property | ||
FirewallModule:: |
protected | property | ||
FirewallModule:: |
protected | property | ||
FirewallModule:: |
protected | property | ||
FirewallModule:: |
protected | property | ||
FirewallModule:: |
protected | property | ||
FirewallModule:: |
protected | property | ||
FirewallModule:: |
public | property | 3 | |
FirewallModule:: |
protected | property | * | |
FirewallModule:: |
protected | property | * | |
FirewallModule:: |
protected | property | * | |
FirewallModule:: |
abstract public | function | Do logic for denied request. | 3 |
FirewallModule:: |
abstract public | function | Do logic for allowed request. | 3 |
FirewallModule:: |
abstract public | function | Use this method to execute main logic of the module. | 3 |
FirewallModule:: |
public | function | Configure and set additional properties: real_ip, test_ip, test | |
FirewallModule:: |
public | function | Set API KEY | |
FirewallModule:: |
public | function | Set specify CMS based DB instance | |
FirewallModule:: |
public | function | Set specify CMS based Helper instance | |
FirewallModule:: |
public | function | Set visitor's IP | |
FirewallModule:: |
public | function | Set is debug property. | |
FirewallModule:: |
public | function | Set Log Table name | |
FirewallModule:: |
public | function | Default die page for blocked requests. | 3 |
FirewallModule:: |
public | function | This is a placeholder for WP translation function. For compatibility with any CMS. | |
FirewallModule:: |
abstract public | function | * FirewallModule constructor. * Use this method to prepare any data for the module working. * * | 3 |