PluginProbe
The WP Remote WordPress Plugin / 5.47
The WP Remote WordPress Plugin v5.47
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.47, at callback/wings/watch.php

184 lines 5.6 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.3;
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 process($request) {
84 $db = $this->db;
85 $settings = $this->settings;
86 $this->setWatchTime();
87 $params = $request->params;
88
89 switch ($request->method) {
90 case "getdata":
91 $resp = array();
92
93 if (array_key_exists('lp', $params)) {
94 require_once dirname( __FILE__ ) . '/../../protect/lp.php';
95 $lp_params = $params['lp'];
96 if (!isset($lp_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(WPRProtectLP_V547::TABLE_NAME))) {
97 $limit = intval($lp_params['limit']);
98 $filter = $lp_params['filter'];
99 $db->deleteBVTableContent(WPRProtectLP_V547::TABLE_NAME, $lp_params['rmfilter']);
100 $table = $db->getBVTable(WPRProtectLP_V547::TABLE_NAME);
101 $resp["lplogs"] = $this->getData($table, $limit, $filter);
102 } else {
103 $resp["lplogs"] = array("status" => "TABLE_NOT_PRESENT");
104 }
105 }
106
107 if (array_key_exists('prelog', $params)) {
108 $prelog_params = $params['prelog'];
109 $resp["prelog"] = $this->getFWPrependLog($prelog_params);
110 }
111
112 if (array_key_exists('fw', $params)) {
113 require_once dirname( __FILE__ ) . '/../../protect/fw.php';
114 $fw_params = $params['fw'];
115 if (!isset($fw_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(WPRProtectFW_V547::TABLE_NAME))) {
116 $limit = intval($fw_params['limit']);
117 $filter = $fw_params['filter'];
118 $db->deleteBVTableContent(WPRProtectFW_V547::TABLE_NAME, $fw_params['rmfilter']);
119 $table = $db->getBVTable(WPRProtectFW_V547::TABLE_NAME);
120 $resp["fwlogs"] = $this->getData($table, $limit, $filter);
121 } else {
122 $resp["fwlogs"] = array("status" => "TABLE_NOT_PRESENT");
123 }
124 }
125
126 if (array_key_exists('dynevent', $params)) {
127 require_once dirname( __FILE__ ) . '/../../wp_dynsync.php';
128 $isdynsyncactive = $settings->getOption('bvDynSyncActive');
129 if ($isdynsyncactive == 'yes') {
130 if (!isset($params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVWPDynSync::$dynsync_table))) {
131 $limit = intval($params['limit']);
132 $filter = $params['filter'];
133 $this->deleteBvDynamicEvents($params['rmfilter']);
134 $table = $db->getBVTable(BVWPDynSync::$dynsync_table);
135 $data = $this->getData($table, $limit, $filter);
136 $resp['last_id'] = $data['last_id'];
137 $resp['events'] = $data['rows'];
138 $resp['timestamp'] = time();
139 $resp["status"] = true;
140 }
141 }
142 }
143
144 if (array_key_exists('actlog', $params)) {
145 require_once dirname( __FILE__ ) . '/../../wp_actlog.php';
146 $actlog_params = $params['actlog'];
147 if (!isset($actlog_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVWPActLog::$actlog_table))) {
148 $limit = intval($actlog_params['limit']);
149 $filter = $actlog_params['filter'];
150 $db->deleteBVTableContent(BVWPActLog::$actlog_table, $actlog_params['rmfilter']);
151 $table = $db->getBVTable(BVWPActLog::$actlog_table);
152 $resp["actlogs"] = $this->getData($table, $limit, $filter);
153 } else {
154 $resp["actlogs"] = array("status" => "TABLE_NOT_PRESENT");
155 }
156 }
157
158 if (array_key_exists('airlift_stats', $params)) {
159 $airlift_stats_table = "airlift_stats";
160 $airlift_stats_params = $params['airlift_stats'];
161 $table = $db->getBVTable($airlift_stats_table);
162 if (!isset($airlift_stats_params['bv_check_table']) || $db->isTablePresent($table)) {
163 $limit = intval($airlift_stats_params['limit']);
164 $filter = $airlift_stats_params['filter'];
165 $db->deleteBVTableContent($airlift_stats_table, $airlift_stats_params['rmfilter']);
166 $resp["airlift_stats"] = $this->getData($table, $limit, $filter);
167 } else {
168 $resp["airlift_stats"] = array("status" => "TABLE_NOT_PRESENT");
169 }
170 }
171 $resp["status"] = "done";
172 break;
173 case "rmdata":
174 require_once dirname( __FILE__ ) . '/../../wp_dynsync.php';
175 $filter = $params['filter'];
176 $resp = array("status" => $this->deleteBvDynamicEvents($filter));
177 break;
178 default:
179 $resp = false;
180 }
181 return $resp;
182 }
183 }
184 endif;