PluginProbe
The WP Remote WordPress Plugin / 4.66
The WP Remote WordPress Plugin v4.66
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 4.66, at callback/wings/watch.php

171 lines 5.1 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.0;
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/wp/lp/config.php';
95 $lp_params = $params['lp'];
96 if (!isset($lp_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVWPLPConfig::$requests_table))) {
97 $limit = intval(urldecode($lp_params['limit']));
98 $filter = urldecode($lp_params['filter']);
99 $db->deleteBVTableContent(BVWPLPConfig::$requests_table, $lp_params['rmfilter']);
100 $table = $db->getBVTable(BVWPLPConfig::$requests_table);
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/config.php';
114 $fw_params = $params['fw'];
115 if (!isset($fw_params['bv_check_table']) || $db->isTablePresent($db->getBVTable(BVFWConfig::$requests_table))) {
116 $limit = intval(urldecode($fw_params['limit']));
117 $filter = urldecode($fw_params['filter']);
118 $db->deleteBVTableContent(BVFWConfig::$requests_table, $fw_params['rmfilter']);
119 $table = $db->getBVTable(BVFWConfig::$requests_table);
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(urldecode($params['limit']));
132 $filter = urldecode($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(urldecode($actlog_params['limit']));
149 $filter = urldecode($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 $resp["status"] = "done";
159 break;
160 case "rmdata":
161 require_once dirname( __FILE__ ) . '/../../wp_dynsync.php';
162 $filter = urldecode($params['filter']);
163 $resp = array("status" => $this->deleteBvDynamicEvents($filter));
164 break;
165 default:
166 $resp = false;
167 }
168 return $resp;
169 }
170 }
171 endif;