| 1 |
<?php |
| 2 |
if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; |
| 3 |
|
| 4 |
if (!class_exists('WPRProtectIpstore_V672')) : |
| 5 |
require_once dirname( __FILE__ ) . '/request.php'; |
| 6 |
require_once dirname( __FILE__ ) . '/ipstore/fs.php'; |
| 7 |
require_once dirname( __FILE__ ) . '/ipstore/db.php'; |
| 8 |
|
| 9 |
class WPRProtectIpstore_V672 { |
| 10 |
private $storage; |
| 11 |
private $storage_type; |
| 12 |
|
| 13 |
const STORAGE_TYPE_FS = 0; |
| 14 |
const STORAGE_TYPE_DB = 1; |
| 15 |
|
| 16 |
function __construct($storage_type = WPRProtectIpstore_V672::STORAGE_TYPE_DB) { |
| 17 |
$this->storage_type = $storage_type; |
| 18 |
if ($this->storage_type == WPRProtectIpstore_V672::STORAGE_TYPE_FS) { |
| 19 |
$this->storage = new WPRProtectIpstoreFS_V672(); |
| 20 |
} else { |
| 21 |
$this->storage = new WPRProtectIpstoreDB_V672(); |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
public static function uninstall() { |
| 26 |
WPRProtectIpstoreDB_V672::uninstall(); |
| 27 |
} |
| 28 |
|
| 29 |
public function isLPIPBlacklisted($ip) { |
| 30 |
if ($this->storage_type == WPRProtectIpstore_V672::STORAGE_TYPE_DB) { |
| 31 |
return $this->storage->isLPIPBlacklisted($ip); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
public function isLPIPWhitelisted($ip) { |
| 36 |
if ($this->storage_type == WPRProtectIpstore_V672::STORAGE_TYPE_DB) { |
| 37 |
return $this->storage->isLPIPWhitelisted($ip); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
public function getTypeIfBlacklistedIP($ip) { |
| 42 |
return $this->storage->getTypeIfBlacklistedIP($ip); |
| 43 |
} |
| 44 |
|
| 45 |
public function isFWIPBlacklisted($ip) { |
| 46 |
return $this->storage->isFWIPBlacklisted($ip); |
| 47 |
} |
| 48 |
|
| 49 |
public function isFWIPWhitelisted($ip) { |
| 50 |
return $this->storage->isFWIPWhitelisted($ip); |
| 51 |
} |
| 52 |
} |
| 53 |
endif; |