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