PluginProbe
The WP Remote WordPress Plugin / 6.76
The WP Remote WordPress Plugin v6.76
6.76 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 All 54 releases
wpremote / protect / ipstore / db.php

db.php in The WP Remote WordPress Plugin 6.76, at protect/ipstore/db.php

74 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
3
4 if (!class_exists('WPRProtectIpstoreDB_V676')) :
5 class WPRProtectIpstoreDB_V676 {
6 const TABLE_NAME = 'ip_store';
7
8 const CATEGORY_FW = 3;
9 const CATEGORY_LP = 4;
10
11 #XNOTE: check this.
12 public static function blacklistedTypes() {
13 return WPRProtectRequest_V676::blacklistedCategories();
14 }
15
16 public static function whitelistedTypes() {
17 return WPRProtectRequest_V676::whitelistedCategories();
18 }
19
20 public static function uninstall() {
21 WPRProtect_V676::$db->dropBVTable(WPRProtectIpstoreDB_V676::TABLE_NAME);
22 }
23
24 public function isLPIPBlacklisted($ip) {
25 return $this->checkIPPresent($ip, self::blacklistedTypes(), WPRProtectIpstoreDB_V676::CATEGORY_LP);
26 }
27
28 public function isLPIPWhitelisted($ip) {
29 return $this->checkIPPresent($ip, self::whitelistedTypes(), WPRProtectIpstoreDB_V676::CATEGORY_LP);
30 }
31
32 public function getTypeIfBlacklistedIP($ip) {
33 return $this->getIPType($ip, self::blacklistedTypes(), WPRProtectIpstoreDB_V676::CATEGORY_FW);
34 }
35
36 public function isFWIPBlacklisted($ip) {
37 return $this->checkIPPresent($ip, self::blacklistedTypes(), WPRProtectIpstoreDB_V676::CATEGORY_FW);
38 }
39
40 public function isFWIPWhitelisted($ip) {
41 return $this->checkIPPresent($ip, self::whitelistedTypes(), WPRProtectIpstoreDB_V676::CATEGORY_FW);
42 }
43
44 private function checkIPPresent($ip, $types, $category) {
45 $ip_category = $this->getIPType($ip, $types, $category);
46
47 return isset($ip_category) ? true : false;
48 }
49
50 #XNOTE: getIPCategory or getIPType?
51 private function getIPType($ip, $types, $category) {
52 $table = WPRProtect_V676::$db->getBVTable(WPRProtectIpstoreDB_V676::TABLE_NAME);
53
54 if (WPRProtect_V676::$db->isTablePresent($table)) {
55 $binIP = WPRProtectUtils_V676::bvInetPton($ip);
56 $is_v6 = WPRProtectUtils_V676::isIPv6($ip);
57
58 if ($binIP !== false) {
59 $query_str = "SELECT * FROM $table WHERE %s >= `start_ip_range` && %s <= `end_ip_range` && ";
60 if ($category == WPRProtectIpstoreDB_V676::CATEGORY_FW) {
61 $query_str .= "`is_fw` = true";
62 } else {
63 $query_str .= "`is_lp` = true";
64 }
65 $query_str .= " && `type` in (" . implode(',', $types) . ") && `is_v6` = %d LIMIT 1;";
66
67 $query = WPRProtect_V676::$db->prepare($query_str, array($binIP, $binIP, $is_v6));
68
69 return WPRProtect_V676::$db->getVar($query, 5);
70 }
71 }
72 }
73 }
74 endif;