| @@ -1,14 +1,15 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | if (!defined('ABSPATH')) exit; |
| 4 | +if (!class_exists('BVIPStoreCallback')) : | |
| 3 | 5 | |
| 4 | -if (!class_exists('WPRIPStoreCallback')) : | |
| 5 | -require_once dirname( __FILE__ ) . '/../../protect/ipstore.php'; | |
| 6 | +require_once dirname( __FILE__ ) . '/../../protect/wp/ipstore.php'; | |
| 6 | 7 | |
| 7 | -class WPRIPStoreCallback extends WPRCallbackBase { | |
| 8 | +class BVIPStoreCallback extends BVCallbackBase { | |
| 8 | 9 | public $db; |
| 9 | 10 | |
| 10 | - const IPSTORE_WING_VERSION = 1.4; | |
| 11 | + const IPSTORE_WING_VERSION = 1.0; | |
| 11 | 12 | |
| 12 | 13 | public function __construct($callback_handler) { |
| 13 | 14 | $this->db = $callback_handler->db; |
| 14 | 15 | } |
| @@ -48,10 +49,10 @@ | ||
| 48 | 49 | } |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | public function getIPs($table, $auto_increment_offset, $type, $category) { |
| 52 | - $query = "SELECT `start_ip_range` FROM $table WHERE id < $auto_increment_offset AND `type` in (" . implode(',', $type) . ") AND "; | |
| 53 | - $query .= ($category == WPRProtectIpstoreDB_V648::CATEGORY_FW) ? "`is_fw` = true;" : "`is_lp` = true;"; | |
| 53 | + $query = "SELECT `start_ip_range` FROM $table WHERE id < $auto_increment_offset AND `type` = $type AND "; | |
| 54 | + $query .= ($category == BVIPStore::FW) ? "`is_fw` = true;" : "`is_lp` = true;"; | |
| 54 | 55 | return $this->db->getCol($query); |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | public function getIPStoreOffset($table, $auto_increment_offset) { |
| @@ -59,23 +60,17 @@ | ||
| 59 | 60 | return intval($db->getVar("SELECT MAX(id) FROM $table WHERE id < $auto_increment_offset")); |
| 60 | 61 | } |
| 61 | 62 | |
| 62 | 63 | public function getIPStoreInfo($table, $auto_increment_offset) { |
| 63 | - $db = $this->db; | |
| 64 | - $info = array(); | |
| 65 | - | |
| 66 | - $info['fw_blacklisted_ips'] = $this->getIPs($table, $auto_increment_offset, | |
| 67 | - WPRProtectIpstoreDB_V648::blacklistedTypes(), WPRProtectIpstoreDB_V648::CATEGORY_FW); | |
| 68 | - $info['lp_blacklisted_ips'] = $this->getIPs($table, $auto_increment_offset, | |
| 69 | - WPRProtectIpstoreDB_V648::blacklistedTypes(), WPRProtectIpstoreDB_V648::CATEGORY_LP); | |
| 70 | - $info['fw_whitelisted_ips'] = $this->getIPs($table, $auto_increment_offset, | |
| 71 | - WPRProtectIpstoreDB_V648::whitelistedTypes(), WPRProtectIpstoreDB_V648::CATEGORY_FW); | |
| 72 | - $info['lp_whitelisted_ips'] = $this->getIPs($table, $auto_increment_offset, | |
| 73 | - WPRProtectIpstoreDB_V648::whitelistedTypes(), WPRProtectIpstoreDB_V648::CATEGORY_LP); | |
| 74 | - $info['ip_store_offset'] = $this->getIPStoreOffset($table, $auto_increment_offset); | |
| 75 | - $info['country_ips_size'] = intval($db->getVar("SELECT COUNT(id) FROM $table WHERE id >= $auto_increment_offset")); | |
| 76 | - | |
| 77 | - return $info; | |
| 64 | + $db = $this->db; | |
| 65 | + $info = array(); | |
| 66 | + $info['fw_blacklisted_ips'] = $this->getIPs($table, $auto_increment_offset, BVIPStore::BLACKLISTED, BVIPStore::FW); | |
| 67 | + $info['lp_blacklisted_ips'] = $this->getIPs($table, $auto_increment_offset, BVIPStore::BLACKLISTED, BVIPStore::LP); | |
| 68 | + $info['fw_whitelisted_ips'] = $this->getIPs($table, $auto_increment_offset, BVIPStore::WHITELISTED, BVIPStore::FW); | |
| 69 | + $info['lp_whitelisted_ips'] = $this->getIPs($table, $auto_increment_offset, BVIPStore::WHITELISTED, BVIPStore::LP); | |
| 70 | + $info['ip_store_offset'] = $this->getIPStoreOffset($table, $auto_increment_offset); | |
| 71 | + $info['country_ips_size'] = intval($db->getVar("SELECT COUNT(id) FROM $table WHERE id >= $auto_increment_offset")); | |
| 72 | + return $info; | |
| 78 | 73 | } |
| 79 | 74 | |
| 80 | 75 | public function process($request) { |
| 81 | 76 | $db = $this->db; |