PluginProbe
The WP Remote WordPress Plugin / 5.41
The WP Remote WordPress Plugin v5.41
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
wpremote / protect / ipstore / fs.php

fs.php in The WP Remote WordPress Plugin 5.41, at protect/ipstore/fs.php

46 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
3
4 if (!class_exists('WPRProtectIpstoreFS_V541')) :
5 class WPRProtectIpstoreFS_V541 {
6 private $whitelisted_ips;
7 private $blacklisted_ips;
8
9 const IP_TYPE_BLACKLISTED = 0;
10 const IP_TYPE_WHITELISTED = 1;
11
12 function __construct() {
13 $ip_store_file = MCDATAPATH . MCCONFKEY . '-' . 'mc_ips.conf';
14 $ips = WPRProtectUtils_V541::parseFile($ip_store_file);
15 $this->whitelisted_ips = array_key_exists('whitelisted', $ips) ? $ips['whitelisted'] : array();
16 $this->blacklisted_ips = array_key_exists('blacklisted', $ips) ? $ips['blacklisted'] : array();
17 }
18
19 public function getTypeIfBlacklistedIP($ip) {
20 return $this->getIPType($ip, WPRProtectIpstoreFS_V541::IP_TYPE_BLACKLISTED);
21 }
22
23 public function isFWIPBlacklisted($ip) {
24 return $this->checkIPPresent($ip, WPRProtectIpstoreFS_V541::IP_TYPE_BLACKLISTED);
25 }
26
27 public function isFWIPWhitelisted($ip) {
28 return $this->checkIPPresent($ip, WPRProtectIpstoreFS_V541::IP_TYPE_WHITELISTED);
29 }
30
31 private function checkIPPresent($ip, $type) {
32 $ip_category = $this->getIPType($ip, $type);
33 return isset($ip_category) ? true : false;
34 }
35
36 #XNOTE: getIPCategory or getIPType?
37 private function getIPType($ip, $type) {
38 switch ($type) {
39 case WPRProtectIpstoreFS_V541::IP_TYPE_BLACKLISTED:
40 return isset($this->blacklisted_ips[$ip]) ? $this->blacklisted_ips[$ip] : null;
41 case WPRProtectIpstoreFS_V541::IP_TYPE_WHITELISTED:
42 return isset($this->whitelisted_ips[$ip]) ? $this->whitelisted_ips[$ip] : null;
43 }
44 }
45 }
46 endif;