PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.6.1
Defender Security – Malware Scanner, Login Security & Firewall v5.6.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / model / setting / class-antibot-global-firewall-setting.php

class-antibot-global-firewall-setting.php in Defender Security – Malware Scanner, Login Security & Firewall 5.6.1, at src/model/setting/class-antibot-global-firewall-setting.php

134 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handles AntiBot Global Firewall settings.
4 *
5 * @package WP_Defender\Model\Setting
6 */
7
8 namespace WP_Defender\Model\Setting;
9
10 use Calotes\Model\Setting;
11
12 /**
13 * Class Antibot_Global_Firewall_Setting
14 *
15 * @package WP_Defender\Model\Setting
16 */
17 class Antibot_Global_Firewall_Setting extends Setting {
18 public const MODULE_SLUG = 'global-ip';
19 public const MANAGED_BY_ALLOWED = array( '', 'plugin', 'hosting' );
20 public const MODE_BASIC = 'basic';
21 public const MODE_STRICT = 'strict';
22 public const MODE_BASIC_LABEL = 'Basic';
23 public const MODE_STRICT_LABEL = 'Strict';
24
25 /**
26 * Option name.
27 *
28 * @var string
29 */
30 protected $table = 'wd_antibot_global_firewall_settings';
31
32 /**
33 * Is module enabled?
34 *
35 * @var bool
36 * @defender_property
37 */
38 public $enabled = false;
39
40 /**
41 * The AntiBot will be managed by WPMU DEV or Defender plugin.
42 * By default '', 'plugin' if managed by Defender plugin, 'hosting' if managed by WPMU DEV.
43 *
44 * @var string
45 * @defender_property
46 * @rule in[plugin,hosting]
47 */
48 public $managed_by = '';
49
50 /**
51 * Mode for fetching AntiBot blockist.
52 *
53 * Allowed values:
54 * - self::MODE_BASIC: Excludes 404 and user agent IPs from the blocklist.
55 * - self::MODE_STRICT: Includes all IPs in the blocklist.
56 *
57 * Default is self::MODE_BASIC.
58 *
59 * @var string
60 * @defender_property
61 * @rule in[basic,strict]
62 */
63 public string $mode = self::MODE_BASIC;
64
65 /**
66 * Validation rules.
67 *
68 * @var array
69 */
70 protected $rules = array(
71 array( array( 'enabled' ), 'boolean' ),
72 array( array( 'managed_by' ), 'in', self::MANAGED_BY_ALLOWED ),
73 array( array( 'mode' ), 'in', array( self::MODE_BASIC, self::MODE_STRICT ) ),
74 );
75
76 /**
77 * Define settings labels.
78 *
79 * @return array
80 */
81 public function labels(): array {
82 return array(
83 'enabled' => self::get_module_name(),
84 );
85 }
86
87 /**
88 * Retrieves the module name.
89 *
90 * @return string The module name.
91 */
92 public static function get_module_name(): string {
93 return __( 'AntiBot Global Firewall', 'defender-security' );
94 }
95
96 /**
97 * Get the module state based on the given flag.
98 *
99 * @param bool $flag The flag indicating the module state.
100 *
101 * @return string The module state, either 'active' or 'inactive'.
102 */
103 public static function get_module_state( $flag ): string {
104 return $flag ? __( 'active', 'defender-security' ) : __( 'inactive', 'defender-security' );
105 }
106
107 /**
108 * Retrieves the module slug.
109 *
110 * @return string The module slug.
111 */
112 public static function get_module_slug(): string {
113 return self::MODULE_SLUG;
114 }
115
116 /**
117 * Retrieves the mode label.
118 *
119 * @return string The mode label.
120 */
121 public function get_mode_label(): string {
122 return self::MODE_STRICT === $this->mode ? self::MODE_STRICT_LABEL : self::MODE_BASIC_LABEL;
123 }
124
125 /**
126 * Retrieves the valid modes.
127 *
128 * @return array The valid modes.
129 */
130 public static function get_valid_modes(): array {
131 return array( self::MODE_BASIC, self::MODE_STRICT );
132 }
133 }
134