PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.0
Defender Security – Malware Scanner, Login Security & Firewall v5.7.0
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 / helper / analytics / class-firewall.php

class-firewall.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.0, at src/helper/analytics/class-firewall.php

103 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Responsible for gathering analytics data for the firewall feature.
4 *
5 * @package WP_Defender\Helper\Analytics
6 */
7
8 namespace WP_Defender\Helper\Analytics;
9
10 use WP_Defender\Event;
11
12 /**
13 * Gather analytics data required for firewall feature.
14 */
15 class Firewall extends Event {
16
17 public const EVENT_IP_DETECTION = 'def_ip_detection';
18 public const PROP_IP_DETECTION = 'Detection Method';
19
20 /**
21 * Provides data for the frontend.
22 *
23 * @return array An array of data for the frontend.
24 */
25 public function data_frontend(): array {
26 return array();
27 }
28
29 /**
30 * Converts the current state of the object to an array.
31 *
32 * @return array Returns an associative array of object properties.
33 */
34 public function to_array(): array {
35 return array();
36 }
37
38 /**
39 * Imports data into the model.
40 *
41 * @param array $data Data to be imported into the model.
42 */
43 public function import_data( array $data ) {
44 }
45
46 /**
47 * Removes settings for all submodules.
48 */
49 public function remove_settings() {
50 }
51
52 /**
53 * Delete all the data & the cache.
54 *
55 * @return mixed
56 */
57 public function remove_data() {
58 }
59
60 /**
61 * Exports strings.
62 *
63 * @return array
64 */
65 public function export_strings() {
66 return array();
67 }
68
69 /**
70 * Get a label of the detection method.
71 *
72 * @param string $ip_detection_type IP detection type.
73 * @param string $http_ip_header HTTP IP header.
74 *
75 * @return string
76 */
77 public static function get_detection_method_label( string $ip_detection_type, string $http_ip_header ): string {
78 if ( 'automatic' === $ip_detection_type ) {
79 $detection_method = 'Automatic';
80 } else {
81 // Manual options.
82 $detection_method = 'Manual - ';
83 switch ( $http_ip_header ) {
84 case 'HTTP_X_FORWARDED_FOR':
85 $detection_method .= 'X-Forward-For';
86 break;
87 case 'HTTP_X_REAL_IP':
88 $detection_method .= 'X-Real-IP';
89 break;
90 case 'HTTP_CF_CONNECTING_IP':
91 $detection_method .= 'CF-Connecting-IP';
92 break;
93 case 'REMOTE_ADDR':
94 default:
95 $detection_method .= 'Remote-Addr';
96 break;
97 }
98 }
99
100 return $detection_method;
101 }
102 }
103