PluginProbe
The WP Remote WordPress Plugin / 5.65
The WP Remote WordPress Plugin v5.65
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 / watch.php

watch.php in The WP Remote WordPress Plugin 5.65, at callback/wings/watch.php

236 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('BVWatchCallback')) :
5
6 class BVWatchCallback extends BVCallbackBase {
7 public $db;
8 public $settings;
9
10 const WATCH_WING_VERSION = 1.4;
11
12 public function __construct($callback_handler) {
13 $this->db = $callback_handler->db;
14 $this->settings = $callback_handler->settings;
15 }
16
17 public function getData($table, $limit = 0, $filter = "") {
18 $result = array();
19 $data = array();
20 $rows = $this->db->getTableContent($table, '*', $filter, $limit);
21 $last_id = 0;
22 foreach ($rows as $row) {
23 $result[] = $row;
24 $last_id = $row['id'];
25 }
26 $data['last_id'] = $last_id;
27 $data['rows'] = $result;
28 return $data;
29 }
30
31 public function deleteBvDynamicEvents($filter = "") {
32 $name = BVWPDynSync::$dynsync_table;
33 return $this->db->deleteBVTableContent($name, $filter);
34 }
35
36 public function setWatchTime() {
37 return $this->settings->updateOption('bvwatchtime', time());
38 }
39
40 public function getFWPrependLog($params) {
41 $result = array();
42 $fname = $params['fname'];
43 $limit = intval($params['limit']);
44
45 if (file_exists($fname)) {
46
47 $result['exists'] = true;
48 $tmpfname = $fname."tmp";
49
50 if (!@rename($fname, $tmpfname)) {
51
52 $result = array('status' => 'Error', 'message' => 'UNABLE_TO_RENAME_LOGFILE');
53
54 } else {
55
56 if (file_exists($tmpfname)) {
57
58 $fsize = filesize($tmpfname);
59 $result["size"] = $fsize;
60
61 if ($fsize <= $limit) {
62
63 $result['content'] = file_get_contents($tmpfname);
64
65 } else {
66 $handle = fopen($tmpfname, "rb");
67 $result['content'] = fread($handle, $limit);
68 $result['incomplete'] = true;
69 fclose($handle);
70 }
71
72 $result['tmpfile'] = unlink($tmpfname);
73 } else {
74 $result['tmpfile'] = 'DOES_NOT_EXISTS';
75 }
76
77 }
78 }
79
80 return $result;
81 }
82
83 public function getDomainInfo($params) {
84 $domain = $params["domain"];
85 if (empty($domain)) {
86 return array('domainData' => "DOMAIN_NOT_PRESENT");
87 }
88
89 $whoisServer = $params["host"];
90 if (empty($whoisServer)) {
91 return array('domainData' => "WHOIS_SERVER_NOT_PRESENT : $domain");
92 }
93
94 $conn = @fsockopen($whoisServer, $params["port"], $errno, $errstr, $params["timeout"]);
95 if (!$conn) {
96 return array('domainData' => "UNABLE_TO_CONNECT_TO_WHOIS_SERVER : $whoisServer : DOMAIN : $domain : ERROR : $errstr ($errno)");
97 }
98
99 try {
100 fwrite($conn, "$domain\r\n");
101
102 $response = '';
103 while (!feof($conn)) {
104 $response .= fgets($conn, 1024);
105 }
106
107 fclose($conn);
108 } catch (Exception $e) {
109 fclose($conn);
110 return array('domainData' => "ERROR_WHILE_FETCHING_DATA : " . $e->getMessage());
111 }
112
113 return array('domainData' => $response);
114 }
115
116 public function process($request) {
117 $db = $this->db;
118 $settings = $this->settings;
119 $this->setWatchTime();
120 $params = $request->params;
121
122 switch ($request->method) {
123 case "getdata":
124 $resp = array();
125
126 if (isset($params['domain_params']) && is_array($params['domain_params'])) {
127 $resp = array_merge($resp, $this->getDomainInfo($params['domain_params']));
128 }
129
130 if (array_key_exists('lp', $params)) {
131 require_once dirname( __FILE__ ) . '/../../protect/lp.php';
132 $lp_params = $params['lp'];
133 if (!isset($lp_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(WPRProtectLP_V565::TABLE_NAME))) {
134 $limit = intval($lp_params['limit']);
135 $filter = $lp_params['filter'];
136 $db->deleteBVTableContent(WPRProtectLP_V565::TABLE_NAME, $lp_params['rmfilter']);
137 $table = $db->getBVTable(WPRProtectLP_V565::TABLE_NAME);
138 $resp["lplogs"] = $this->getData($table, $limit, $filter);
139 } else {
140 $resp["lplogs"] = array("status" => "TABLE_NOT_PRESENT");
141 }
142 }
143
144 if (array_key_exists('prelog', $params)) {
145 $prelog_params = $params['prelog'];
146 $resp["prelog"] = $this->getFWPrependLog($prelog_params);
147 }
148
149 if (array_key_exists('fw', $params)) {
150 require_once dirname( __FILE__ ) . '/../../protect/fw.php';
151 $fw_params = $params['fw'];
152 if (!isset($fw_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(WPRProtectFW_V565::TABLE_NAME))) {
153 $limit = intval($fw_params['limit']);
154 $filter = $fw_params['filter'];
155 $db->deleteBVTableContent(WPRProtectFW_V565::TABLE_NAME, $fw_params['rmfilter']);
156 $table = $db->getBVTable(WPRProtectFW_V565::TABLE_NAME);
157 $resp["fwlogs"] = $this->getData($table, $limit, $filter);
158 } else {
159 $resp["fwlogs"] = array("status" => "TABLE_NOT_PRESENT");
160 }
161 }
162
163 if (array_key_exists('dynevent', $params)) {
164 require_once dirname( __FILE__ ) . '/../../wp_dynsync.php';
165 $isdynsyncactive = $settings->getOption('bvDynSyncActive');
166 if ($isdynsyncactive == 'yes') {
167 if (!isset($params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVWPDynSync::$dynsync_table))) {
168 $limit = intval($params['limit']);
169 $filter = $params['filter'];
170 $this->deleteBvDynamicEvents($params['rmfilter']);
171 $table = $db->getBVTable(BVWPDynSync::$dynsync_table);
172 $data = $this->getData($table, $limit, $filter);
173 $resp['last_id'] = $data['last_id'];
174 $resp['events'] = $data['rows'];
175 $resp['timestamp'] = time();
176 $resp["status"] = true;
177 }
178 }
179 }
180
181 if (array_key_exists('actlog', $params)) {
182 require_once dirname( __FILE__ ) . '/../../wp_actlog.php';
183 $actlog_params = $params['actlog'];
184 if (!isset($actlog_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVWPActLog::$actlog_table))) {
185 $limit = intval($actlog_params['limit']);
186 $filter = $actlog_params['filter'];
187 $db->deleteBVTableContent(BVWPActLog::$actlog_table, $actlog_params['rmfilter']);
188 $table = $db->getBVTable(BVWPActLog::$actlog_table);
189 $resp["actlogs"] = $this->getData($table, $limit, $filter);
190 } else {
191 $resp["actlogs"] = array("status" => "TABLE_NOT_PRESENT");
192 }
193 }
194
195 if (array_key_exists('airlift_stats', $params)) {
196 $airlift_stats_table = "airlift_stats";
197 $airlift_stats_params = $params['airlift_stats'];
198 $table = $db->getBVTable($airlift_stats_table);
199 if (!isset($airlift_stats_params['bv_check_table']) || $db->isTablePresent($table)) {
200 $limit = intval($airlift_stats_params['limit']);
201 $filter = $airlift_stats_params['filter'];
202 $db->deleteBVTableContent($airlift_stats_table, $airlift_stats_params['rmfilter']);
203 $resp["airlift_stats"] = $this->getData($table, $limit, $filter);
204 } else {
205 $resp["airlift_stats"] = array("status" => "TABLE_NOT_PRESENT");
206 }
207 }
208
209 if (array_key_exists('php_error_monitoring', $params)) {
210 require_once dirname( __FILE__ ) . '/../../php_error_monitoring/monitoring.php';
211 $php_error_monit_params = $params['php_error_monitoring'];
212 $table = $db->getBVTable(WPRWPPHPErrorMonitoring::ERROR_TABLE);
213 if (!isset($php_error_monit_params['bv_check_table']) || $db->isTablePresent($table)) {
214 $limit = intval($php_error_monit_params['limit']);
215 $filter = $php_error_monit_params['filter'];
216 $db->deleteBVTableContent(WPRWPPHPErrorMonitoring::ERROR_TABLE, $php_error_monit_params['rmfilter']);
217 $resp["php_error_monitoring"] = $this->getData($table, $limit, $filter);
218 } else {
219 $resp["php_error_monitoring"] = array("status" => "TABLE_NOT_PRESENT");
220 }
221 }
222
223 $resp["status"] = "done";
224 break;
225 case "rmdata":
226 require_once dirname( __FILE__ ) . '/../../wp_dynsync.php';
227 $filter = $params['filter'];
228 $resp = array("status" => $this->deleteBvDynamicEvents($filter));
229 break;
230 default:
231 $resp = false;
232 }
233 return $resp;
234 }
235 }
236 endif;