PluginProbe
The WP Remote WordPress Plugin / trunk
The WP Remote WordPress Plugin vtrunk
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
← All changes | protect/lp.php +34 -34 6.69trunk View file →
@@ -1,9 +1,9 @@
1 1 <?php
2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
3 3
4 -if (!class_exists('WPRProtectLP_V669')) :
5 -class WPRProtectLP_V669 {
4 +if (!class_exists('WPRProtectLP_V672')) :
5 +class WPRProtectLP_V672 {
6 6 private $ip;
7 7 private $time;
8 8 private $ipstore;
9 9 private $logger;
@@ -8,9 +8,9 @@
8 8 private $ipstore;
9 9 private $logger;
10 10 private $brand_name;
11 11
12 - private $mode = WPRProtectLP_V669::MODE_DISABLED;
12 + private $mode = WPRProtectLP_V672::MODE_DISABLED;
13 13 private $captcha_limit = 3;
14 14 private $temp_block_limit = 10;
15 15 private $block_all_limit = 100;
16 16 private $failed_login_gap = 1800;
@@ -16,9 +16,9 @@
16 16 private $failed_login_gap = 1800;
17 17 private $success_login_gap = 1800;
18 18 private $all_blocked_gap = 1800;
19 19
20 - private $category = WPRProtectLP_V669::CATEGORY_ALLOWED;
20 + private $category = WPRProtectLP_V672::CATEGORY_ALLOWED;
21 21 private $username = '';
22 22 private $message = '';
23 23
24 24 private static $instance;
@@ -45,10 +45,10 @@
45 45
46 46 private function __construct($request, $config, $brand_name) {
47 47 $this->ip = $request->getIP();
48 48 $this->brand_name = $brand_name;
49 - $this->ipstore = new WPRProtectIpstore_V669();
50 - $this->logger = new WPRProtectLogger_V669(WPRProtectLP_V669::TABLE_NAME);
49 + $this->ipstore = new WPRProtectIpstore_V672();
50 + $this->logger = new WPRProtectLogger_V672(WPRProtectLP_V672::TABLE_NAME);
51 51 $this->time = strtotime(gmdate("Y-m-d H:i:s"));
52 52
53 53 if (is_array($config)) {
54 54 if (array_key_exists('mode', $config) && is_int($config['mode'])) {
@@ -89,9 +89,9 @@
89 89 return self::$instance;
90 90 }
91 91
92 92 public static function uninstall() {
93 - WPRProtect_V669::$db->dropBVTable(WPRProtectLP_V669::TABLE_NAME);
93 + WPRProtect_V672::$db->dropBVTable(WPRProtectLP_V672::TABLE_NAME);
94 94 }
95 95
96 96 public function init() {
97 97 if ($this->isActive()) {
@@ -101,9 +101,9 @@
101 101 }
102 102 }
103 103
104 104 private function getCaptchaLink() {
105 - $account = WPRAccount::apiPublicAccount(WPRProtect_V669::$settings);
105 + $account = WPRAccount::apiPublicAccount(WPRProtect_V672::$settings);
106 106
107 107 $url = $account->authenticatedUrl('/captcha/solve');
108 108 $url .= "&adminurl=".base64_encode(get_admin_url());
109 109
@@ -110,13 +110,13 @@
110 110 return $url;
111 111 }
112 112
113 113 private function getAllowLoginsTransient() {
114 - return WPRProtect_V669::$settings->getTransient('bvlp_allow_logins');
114 + return WPRProtect_V672::$settings->getTransient('bvlp_allow_logins');
115 115 }
116 116
117 117 private function getBlockLoginsTransient() {
118 - return WPRProtect_V669::$settings->getTransient('bvlp_block_logins');
118 + return WPRProtect_V672::$settings->getTransient('bvlp_block_logins');
119 119 }
120 120
121 121 private function terminateTemplate() {
122 122 $templates = array (
@@ -140,13 +140,13 @@
140 140 </div>";
141 141 }
142 142
143 143 private function isProtecting() {
144 - return $this->mode === WPRProtectLP_V669::MODE_PROTECT;
144 + return $this->mode === WPRProtectLP_V672::MODE_PROTECT;
145 145 }
146 146
147 147 private function isActive() {
148 - return $this->mode !== WPRProtectLP_V669::MODE_DISABLED;
148 + return $this->mode !== WPRProtectLP_V672::MODE_DISABLED;
149 149 }
150 150
151 151 private function isBlacklistedIP() {
152 152 return $this->ipstore->isLPIPBlacklisted($this->ip);
@@ -156,13 +156,13 @@
156 156 return $this->ipstore->isLPIPWhitelisted($this->ip);
157 157 }
158 158
159 159 private function isUnBlockedIP() {
160 - $transient_name = WPRProtectLP_V669::UNBLOCK_IP_TRANSIENT_PREFIX . $this->ip;
161 - $attempts = WPRProtect_V669::$settings->getTransient($transient_name);
160 + $transient_name = WPRProtectLP_V672::UNBLOCK_IP_TRANSIENT_PREFIX . $this->ip;
161 + $attempts = WPRProtect_V672::$settings->getTransient($transient_name);
162 162
163 163 if ($attempts && $attempts > 0) {
164 - WPRProtect_V669::$settings->setTransient($transient_name, $attempts - 1, 600 * $attempts);
164 + WPRProtect_V672::$settings->setTransient($transient_name, $attempts - 1, 600 * $attempts);
165 165 return true;
166 166 }
167 167
168 168 return false;
@@ -169,9 +169,9 @@
169 169 }
170 170
171 171 private function isLoginBlocked() {
172 172 if ($this->getAllowLoginsTransient() ||
173 - ($this->getLoginCount(WPRProtectLP_V669::LOGIN_STATUS_FAILURE, null, $this->all_blocked_gap) < $this->block_all_limit)) {
173 + ($this->getLoginCount(WPRProtectLP_V672::LOGIN_STATUS_FAILURE, null, $this->all_blocked_gap) < $this->block_all_limit)) {
174 174 return false;
175 175 }
176 176
177 177 return true;
@@ -192,9 +192,9 @@
192 192 }
193 193
194 194 private function terminateLogin() {
195 195 $this->message = 'Login Blocked';
196 - $this->log(WPRProtectLP_V669::LOGIN_STATUS_BLOCKED);
196 + $this->log(WPRProtectLP_V672::LOGIN_STATUS_BLOCKED);
197 197 if ($this->isProtecting()) {
198 198 header("Cache-Control: no-cache, no-store, must-revalidate");
199 199 header("Pragma: no-cache");
200 200 header("Expires: 0");
@@ -206,30 +206,30 @@
206 206 }
207 207
208 208 public function loginInit($user, $username = '', $password = '') {
209 209 if ($this->isUnBlockedIP()) {
210 - $this->category = WPRProtectLP_V669::CATEGORY_UNBLOCKED;
210 + $this->category = WPRProtectLP_V672::CATEGORY_UNBLOCKED;
211 211 } else {
212 - $failed_attempts = $this->getLoginCount(WPRProtectLP_V669::LOGIN_STATUS_FAILURE,
212 + $failed_attempts = $this->getLoginCount(WPRProtectLP_V672::LOGIN_STATUS_FAILURE,
213 213 $this->ip, $this->failed_login_gap);
214 214
215 215 if ($this->isWhitelistedIP()) {
216 - $this->category = WPRProtectLP_V669::CATEGORY_BYPASSED;
217 - } elseif (WPRProtectUtils_V669::isPrivateIP($this->ip)) {
218 - $this->category = WPRProtectLP_V669::CATEGORY_PRIVATEIP;
216 + $this->category = WPRProtectLP_V672::CATEGORY_BYPASSED;
217 + } elseif (WPRProtectUtils_V672::isPrivateIP($this->ip)) {
218 + $this->category = WPRProtectLP_V672::CATEGORY_PRIVATEIP;
219 219 } elseif ($this->isBlacklistedIP()) {
220 - $this->category = WPRProtectLP_V669::CATEGORY_BLACKLISTED;
220 + $this->category = WPRProtectLP_V672::CATEGORY_BLACKLISTED;
221 221 $this->terminateLogin();
222 222 } elseif ($this->isKnownLogin()) {
223 - $this->category = WPRProtectLP_V669::CATEGORY_BYPASSED;
223 + $this->category = WPRProtectLP_V672::CATEGORY_BYPASSED;
224 224 } elseif ($this->isLoginBlocked()) {
225 - $this->category = WPRProtectLP_V669::CATEGORY_ALL_BLOCKED;
225 + $this->category = WPRProtectLP_V672::CATEGORY_ALL_BLOCKED;
226 226 $this->terminateLogin();
227 227 } elseif ($failed_attempts >= $this->temp_block_limit) {
228 - $this->category = WPRProtectLP_V669::CATEGORY_TEMP_BLOCK;
228 + $this->category = WPRProtectLP_V672::CATEGORY_TEMP_BLOCK;
229 229 $this->terminateLogin();
230 230 } elseif ($failed_attempts >= $this->captcha_limit) {
231 - $this->category = WPRProtectLP_V669::CATEGORY_CAPTCHA_BLOCK;
231 + $this->category = WPRProtectLP_V672::CATEGORY_CAPTCHA_BLOCK;
232 232 $this->terminateLogin();
233 233 }
234 234 }
235 235
@@ -241,33 +241,33 @@
241 241 }
242 242
243 243 public function loginFailed($username) {
244 244 $this->username = $username;
245 - $this->log(WPRProtectLP_V669::LOGIN_STATUS_FAILURE);
245 + $this->log(WPRProtectLP_V672::LOGIN_STATUS_FAILURE);
246 246 }
247 247
248 248 public function loginSuccess($username) {
249 249 $this->username = $username;
250 250 $this->message = 'Login Success';
251 - $this->log(WPRProtectLP_V669::LOGIN_STATUS_SUCCESS);
251 + $this->log(WPRProtectLP_V672::LOGIN_STATUS_SUCCESS);
252 252 }
253 253
254 254 private function isKnownLogin() {
255 - return $this->getLoginCount(WPRProtectLP_V669::LOGIN_STATUS_SUCCESS,
255 + return $this->getLoginCount(WPRProtectLP_V672::LOGIN_STATUS_SUCCESS,
256 256 $this->ip, $this->success_login_gap) > 0;
257 257 }
258 258
259 259 private function getLoginCount($status, $ip, $gap) {
260 - $table = WPRProtect_V669::$db->getBVTable(WPRProtectLP_V669::TABLE_NAME);
260 + $table = WPRProtect_V672::$db->getBVTable(WPRProtectLP_V672::TABLE_NAME);
261 261 $query_str = "SELECT COUNT(*) as count from `$table` WHERE status=%d && time > %d";
262 262 $query_args = array($status, ($this->time - $gap));
263 263
264 - $query = WPRProtect_V669::$db->prepare($query_str, $query_args);
264 + $query = WPRProtect_V672::$db->prepare($query_str, $query_args);
265 265 if ($ip) {
266 - $query .= WPRProtect_V669::$db->prepare(" && ip=%s", $ip);
266 + $query .= WPRProtect_V672::$db->prepare(" && ip=%s", $ip);
267 267 }
268 268
269 - $rows = WPRProtect_V669::$db->getResult($query);
269 + $rows = WPRProtect_V672::$db->getResult($query);
270 270 if (!$rows) {
271 271 return 0;
272 272 }
273 273