PluginProbe
The WP Remote WordPress Plugin / 5.41
The WP Remote WordPress Plugin v5.41
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 / callback / wings / protect.php

protect.php in The WP Remote WordPress Plugin 5.41, at callback/wings/protect.php

105 lines 3.2 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
4 if (!class_exists('BVProtectCallback')) :
5 require_once dirname( __FILE__ ) . '/../../protect/lp.php';
6
7 class BVProtectCallback extends BVCallbackBase {
8 public $db;
9 public $settings;
10
11 const PROTECT_WING_VERSION = 1.2;
12
13 public function __construct($callback_handler) {
14 $this->db = $callback_handler->db;
15 $this->settings = $callback_handler->settings;
16 }
17
18 public function serverConfig() {
19 return array(
20 'software' => $_SERVER['SERVER_SOFTWARE'],
21 'sapi' => (function_exists('php_sapi_name')) ? php_sapi_name() : false,
22 'has_apache_get_modules' => function_exists('apache_get_modules'),
23 'posix_getuid' => (function_exists('posix_getuid')) ? posix_getuid() : null,
24 'uid' => (function_exists('getmyuid')) ? getmyuid() : null,
25 'user_ini' => ini_get('user_ini.filename'),
26 'php_major_version' => PHP_MAJOR_VERSION
27 );
28 }
29
30 public function unBlockLogins() {
31 $this->settings->deleteTransient('bvlp_block_logins');
32 $this->settings->setTransient('bvlp_allow_logins', 'true', 1800);
33 return $this->settings->getTransient('bvlp_allow_logins');
34 }
35
36 public function blockLogins($time) {
37 $this->settings->deleteTransient('bvlp_allow_logins');
38 $this->settings->setTransient('bvlp_block_logins', 'true', $time);
39 return $this->settings->getTransient('bvlp_block_logins');
40 }
41
42 public function unBlockIP($ip, $attempts, $time) {
43 $transient_name = WPRProtectLP_V541::UNBLOCK_IP_TRANSIENT_PREFIX . $ip;
44 $this->settings->setTransient($transient_name, $attempts, $time);
45 return $this->settings->getTransient($transient_name);
46 }
47
48 public function process($request) {
49 $bvinfo = new WPRInfo($this->settings);
50 $params = $request->params;
51
52 switch ($request->method) {
53 case "gtipprobeinfo":
54 $resp = array();
55 $headers = $params['hdrs'];
56 $hdrsinfo = array();
57 if ($headers && is_array($headers)) {
58 foreach($headers as $hdr) {
59 if (array_key_exists($hdr, $_SERVER)) {
60 $hdrsinfo[$hdr] = $_SERVER[$hdr];
61 }
62 }
63 }
64 $resp["hdrsinfo"] = $hdrsinfo;
65 break;
66 case "gtrulcnf":
67 $resp = array('conf' => $this->settings->getOption('bvruleset'));
68 break;
69 case "clrrulcnf":
70 $this->settings->deleteOption('bvruleset');
71 $resp = array("clearconfig" => true);
72 break;
73 case "dorulcnf":
74 $this->settings->updateOption('bvruleset', $params['conf']);
75 $resp = array('conf' => $this->settings->getOption('bvruleset'));
76 break;
77 case "gtraddr":
78 $raddr = array_key_exists('REMOTE_ADDR', $_SERVER) ? $_SERVER['REMOTE_ADDR'] : false;
79 $resp = array("raddr" => $raddr);
80 break;
81 case "svrcnf":
82 $resp = array("serverconfig" => $this->serverConfig());
83 break;
84 case "unblklogins":
85 $resp = array("unblocklogins" => $this->unBlockLogins());
86 break;
87 case "blklogins":
88 $time = array_key_exists('time', $params) ? $params['time'] : 1800;
89 $resp = array("blocklogins" => $this->blockLogins($time));
90 break;
91 case "unblkip":
92 $resp = array("unblockip" => $this->unBlockIP($params['ip'], $params['attempts'], $params['time']));
93 break;
94 case "rmwatchtime":
95 $this->settings->deleteOption('bvwatchtime');
96 $resp = array("rmwatchtime" => !$bvinfo->getWatchTime());
97 break;
98 default:
99 $resp = false;
100 }
101
102 return $resp;
103 }
104 }
105 endif;