PluginProbe
The WP Remote WordPress Plugin / 4.79
The WP Remote WordPress Plugin v4.79
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 / wp / ipstore.php

ipstore.php in The WP Remote WordPress Plugin 4.79, at protect/wp/ipstore.php

65 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit;
3 if (!class_exists('BVIPStore')) :
4
5 class BVIPStore {
6
7 public $db;
8 public static $name = 'ip_store';
9
10 #TYPE
11 const BLACKLISTED = 1;
12 const WHITELISTED = 2;
13
14 #CATEGORY
15 const FW = 3;
16 const LP = 4;
17
18 function __construct($db) {
19 $this->db = $db;
20 }
21
22 function init() {
23 add_action('clear_ip_store', array($this, 'clearConfig'));
24 }
25
26 public function clearConfig() {
27 $this->db->dropBVTable(BVIPStore::$name);
28 }
29
30 public function isLPIPBlacklisted($ip) {
31 return $this->checkIPPresent($ip, BVIPStore::BLACKLISTED, BVIPStore::LP);
32 }
33
34 public function isLPIPWhitelisted($ip) {
35 return $this->checkIPPresent($ip, BVIPStore::WHITELISTED, BVIPStore::LP);
36 }
37
38
39 public function isFWIPBlacklisted($ip) {
40 return $this->checkIPPresent($ip, BVIPStore::BLACKLISTED, BVIPStore::FW);
41 }
42
43 public function isFWIPWhitelisted($ip) {
44 return $this->checkIPPresent($ip, BVIPStore::WHITELISTED, BVIPStore::FW);
45 }
46
47 public function checkIPPresent($ip, $type, $category) {
48 $db = $this->db;
49 $table = $db->getBVTable(BVIPStore::$name);
50 if ($db->isTablePresent($table)) {
51 $binIP = BVProtectBase::bvInetPton($ip);
52 if ($binIP !== false) {
53 $category_str = ($category == BVIPStore::FW) ? "`is_fw` = true" : "`is_lp` = true";
54 $query_str = "SELECT * FROM $table WHERE %s >= `start_ip_range` && %s <= `end_ip_range` && " . $category_str . " && `type` = %d LIMIT 1;";
55 $query = $db->prepare($query_str, array($binIP, $binIP, $type));
56 if ($db->getVar($query) > 0)
57 return true;
58 }
59 return false;
60 }
61 return false;
62 }
63
64 }
65 endif;