1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php if (!defined('MCDATAPATH')) exit;
if (!class_exists('BVPrependIPStore')) : class BVPrependIPStore { public $whitelistedIPs; public $blacklistedIPs;
#TYPE const BLACKLISTED = 1; const WHITELISTED = 2;
#CATEGORY const FW = 3;
function __construct($confHash) { $this->whitelistedIPs = array_key_exists('whitelisted', $confHash) ? $confHash['whitelisted'] : array(); $this->blacklistedIPs = array_key_exists('blacklisted', $confHash) ? $confHash['blacklisted'] : array(); }
public function isFWIPBlacklisted($ip) { return $this->checkIPPresent($ip, BVPrependIPStore::BLACKLISTED); }
public function isFWIPWhitelisted($ip) { return $this->checkIPPresent($ip, BVPrependIPStore::WHITELISTED); }
public function checkIPPresent($ip, $type) { $flag = false;
switch($type) {
case BVPrependIPStore::BLACKLISTED: if (isset($this->blacklistedIPs[$ip])) $flag = true; break;
case BVPrependIPStore::WHITELISTED: if (isset($this->whitelistedIPs[$ip])) $flag = true; break; }
return $flag; }
} endif;
|