PluginProbe
The WP Remote WordPress Plugin / 6.76
The WP Remote WordPress Plugin v6.76
6.76 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 All 54 releases
← All changes | protect/fw/rule/engine.php +34 -33 6.626.76 View file →
@@ -1,17 +1,17 @@
1 1 <?php
2 2 // phpcs:disable WordPress.Security.EscapeOutput.ExceptionNotEscaped
3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
4 4
5 -if (!class_exists('WPRProtectFWRuleEngine_V662')) :
5 +if (!class_exists('WPRProtectFWRuleEngine_V676')) :
6 6 require_once dirname( __FILE__ ) . '/functions.php';
7 7
8 -class WPRProtectFWRuleEngine_V662 {
9 - use WPRProtectFWRuleStringFunc_V662;
10 - use WPRProtectFWRuleArrayFunc_V662;
11 - use WPRProtectFWRuleMiscFunc_V662;
12 - use WPRProtectFWRuleRequestFunc_V662;
13 - use WPRProtectFWRuleWPFunc_V662;
8 +class WPRProtectFWRuleEngine_V676 {
9 + use WPRProtectFWRuleStringFunc_V676;
10 + use WPRProtectFWRuleArrayFunc_V676;
11 + use WPRProtectFWRuleMiscFunc_V676;
12 + use WPRProtectFWRuleRequestFunc_V676;
13 + use WPRProtectFWRuleWPFunc_V676;
14 14
15 15 private $request;
16 16 private $variables;
17 17
@@ -18,14 +18,15 @@
18 18 private $error;
19 19 private $ex_stack = array();
20 20 private $ex_stack_inx = -1;
21 21
22 - const VERSION = 1.3;
22 + const VERSION = 1.4;
23 23
24 24 const MAX_DEPTH_TO_ALLOWED_TYPE_FUNC = 8;
25 25 const MAX_ARRAY_KEYS_TO_TRAVERSE = 10000;
26 + const WILDCARD_KEY = '*';
26 27 const FUNC_NAME_PREFIX = '_rf_';
27 - const CONST_NAME_PREFIX = 'WPRProtectFWRule_V662::';
28 + const CONST_NAME_PREFIX = 'WPRProtectFWRule_V676::';
28 29 const ALLOWED_EXT_CONSTANTS = [
29 30 'DOING_CRON'
30 31 ];
31 32
@@ -50,9 +51,9 @@
50 51
51 52 public function evaluate($rule) {
52 53 try {
53 54 return $this->executeStmt($rule->logic);
54 - } catch (WPRProtectRuleError_V662 $e) {
55 + } catch (WPRProtectRuleError_V676 $e) {
55 56 $this->error = $e;
56 57 }
57 58 }
58 59
@@ -121,9 +122,9 @@
121 122 }
122 123
123 124 private function getValue($stmt) {
124 125 if (!is_array($stmt) || empty($stmt["type"])) {
125 - throw new WPRProtectRuleError_V662(
126 + throw new WPRProtectRuleError_V676(
126 127 $this->addExState("InvalidStatementError: Malformed value statement"));
127 128 }
128 129
129 130 $this->incrOpCnt();
@@ -130,9 +131,9 @@
130 131
131 132 switch ($stmt["type"]) {
132 133 case "NUMBER":
133 134 if (!isset($stmt["value"]) || !is_int($stmt["value"])) {
134 - throw new WPRProtectRuleError_V662(
135 + throw new WPRProtectRuleError_V676(
135 136 $this->addExState("TypeError: Value is not a number")
136 137 );
137 138 }
138 139
@@ -138,9 +139,9 @@
138 139
139 140 return $stmt["value"];
140 141 case "STRING":
141 142 if (!isset($stmt["value"]) || !is_string($stmt["value"])) {
142 - throw new WPRProtectRuleError_V662(
143 + throw new WPRProtectRuleError_V676(
143 144 $this->addExState("TypeError: Value is not a string")
144 145 );
145 146 }
146 147
@@ -146,9 +147,9 @@
146 147
147 148 return $stmt["value"];
148 149 case "BOOL":
149 150 if (!isset($stmt["value"]) || !is_bool($stmt["value"])) {
150 - throw new WPRProtectRuleError_V662(
151 + throw new WPRProtectRuleError_V676(
151 152 $this->addExState("TypeError: Value is not a boolean")
152 153 );
153 154 }
154 155
@@ -154,9 +155,9 @@
154 155
155 156 return $stmt["value"];
156 157 case "CONST":
157 158 if (!isset($stmt["value"]) || !is_string($stmt["value"])) {
158 - throw new WPRProtectRuleError_V662(
159 + throw new WPRProtectRuleError_V676(
159 160 $this->addExState("TypeError: Invalid constant name")
160 161 );
161 162 }
162 163
@@ -166,9 +167,9 @@
166 167 $name = self::CONST_NAME_PREFIX . $name;
167 168 }
168 169
169 170 if (!defined($name)) {
170 - throw new WPRProtectRuleError_V662(
171 + throw new WPRProtectRuleError_V676(
171 172 $this->addExState("TypeError: Undefined constant" . $stmt["value"])
172 173 );
173 174 }
174 175
@@ -174,9 +175,9 @@
174 175
175 176 return constant($name);
176 177 case "ARRAY":
177 178 if (!isset($stmt["value"]) || !is_array($stmt["value"])) {
178 - throw new WPRProtectRuleError_V662(
179 + throw new WPRProtectRuleError_V676(
179 180 $this->addExState("TypeError: Value is not a array")
180 181 );
181 182 }
182 183
@@ -205,9 +206,9 @@
205 206 }
206 207
207 208 private function executeStmt($stmt) {
208 209 if (!is_array($stmt) || empty($stmt["type"])) {
209 - throw new WPRProtectRuleError_V662(
210 + throw new WPRProtectRuleError_V676(
210 211 $this->addExState("InvalidStatementError: Malformed logic statement")
211 212 );
212 213 }
213 214
@@ -217,9 +218,9 @@
217 218
218 219 switch ($stmt["type"]) {
219 220 case "AND":
220 221 if (empty($stmt["left_operand"]) || empty($stmt["right_operand"])) {
221 - throw new WPRProtectRuleError_V662(
222 + throw new WPRProtectRuleError_V676(
222 223 $this->addExState("InvalidOperandError: Malformed operand(s)")
223 224 );
224 225 }
225 226
@@ -226,9 +227,9 @@
226 227 $return_val = $this->getValue($stmt["left_operand"]) && $this->getValue($stmt["right_operand"]);
227 228 break;
228 229 case "OR":
229 230 if (empty($stmt["left_operand"]) || empty($stmt["right_operand"])) {
230 - throw new WPRProtectRuleError_V662(
231 + throw new WPRProtectRuleError_V676(
231 232 $this->addExState("InvalidOperandError: Malformed operand(s)")
232 233 );
233 234 }
234 235
@@ -235,9 +236,9 @@
235 236 $return_val = $this->getValue($stmt["left_operand"]) || $this->getValue($stmt["right_operand"]);
236 237 break;
237 238 case "NOT":
238 239 if (empty($stmt["value"])) {
239 - throw new WPRProtectRuleError_V662(
240 + throw new WPRProtectRuleError_V676(
240 241 $this->addExState("InvalidOperandError: Malformed operand")
241 242 );
242 243 }
243 244
@@ -244,9 +245,9 @@
244 245 $return_val = !$this->getValue($stmt["value"]);
245 246 break;
246 247 case "FUNCTION":
247 248 if (empty($stmt["name"]) || !is_string($stmt["name"])) {
248 - throw new WPRProtectRuleError_V662(
249 + throw new WPRProtectRuleError_V676(
249 250 $this->addExState("InvalidFunctionName: Malformed name")
250 251 );
251 252 }
252 253
@@ -253,15 +254,15 @@
253 254 $name = self::FUNC_NAME_PREFIX . $stmt["name"];
254 255 $handler = array($this, $name);
255 256
256 257 if (!is_callable($handler)) {
257 - throw new WPRProtectRuleError_V662(
258 + throw new WPRProtectRuleError_V676(
258 259 $this->addExState("UndefinedFunctionCall: " . $stmt["name"])
259 260 );
260 261 }
261 262
262 263 if (!array_key_exists('args', $stmt) || !is_array($stmt['args'])) {
263 - throw new WPRProtectRuleError_V662(
264 + throw new WPRProtectRuleError_V676(
264 265 $this->addExState("InvalidArguments: Malformed args")
265 266 );
266 267 }
267 268
@@ -272,9 +273,9 @@
272 273
273 274 $return_val = self::toAllowedType(call_user_func_array($handler, $args));
274 275 break;
275 276 default:
276 - throw new WPRProtectRuleError_V662(
277 + throw new WPRProtectRuleError_V676(
277 278 $this->addExState("UnknownOperation: -")
278 279 );
279 280 }
280 281
@@ -283,9 +284,9 @@
283 284 }
284 285
285 286 private function processRuleFunctionParams($func_name, $args_cnt, $args, $required_params = 0, $param_types = array()) {
286 287 if (($args_cnt < $required_params)) {
287 - throw new WPRProtectRuleError_V662(
288 + throw new WPRProtectRuleError_V676(
288 289 $this->addExState("ArgumentCountError: Too few arguments for " . $func_name)
289 290 );
290 291 }
291 292
@@ -290,9 +291,9 @@
290 291 }
291 292
292 293 foreach ($param_types as $pos => $type) {
293 294 if (!is_int($pos)) {
294 - throw new WPRProtectRuleError_V662(
295 + throw new WPRProtectRuleError_V676(
295 296 $this->addExState("InvalidParamType: " . $pos)
296 297 );
297 298 }
298 299
@@ -298,9 +299,9 @@
298 299
299 300 switch ($type) {
300 301 case "string":
301 302 if (!isset($args[$pos]) || !is_string($args[$pos])) {
302 - throw new WPRProtectRuleError_V662(
303 + throw new WPRProtectRuleError_V676(
303 304 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a string.")
304 305 );
305 306 }
306 307 break;
@@ -305,9 +306,9 @@
305 306 }
306 307 break;
307 308 case 'integer':
308 309 if (!isset($args[$pos]) || !is_int($args[$pos])) {
309 - throw new WPRProtectRuleError_V662(
310 + throw new WPRProtectRuleError_V676(
310 311 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a integer.")
311 312 );
312 313 }
313 314 break;
@@ -312,9 +313,9 @@
312 313 }
313 314 break;
314 315 case 'double':
315 316 if (!isset($args[$pos]) || !is_double($args[$pos])) {
316 - throw new WPRProtectRuleError_V662(
317 + throw new WPRProtectRuleError_V676(
317 318 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a double.")
318 319 );
319 320 }
320 321 break;
@@ -319,9 +320,9 @@
319 320 }
320 321 break;
321 322 case 'boolean':
322 323 if (!isset($args[$pos]) || !is_bool($args[$pos])) {
323 - throw new WPRProtectRuleError_V662(
324 + throw new WPRProtectRuleError_V676(
324 325 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not a boolean.")
325 326 );
326 327 }
327 328 break;
@@ -326,9 +327,9 @@
326 327 }
327 328 break;
328 329 case 'array':
329 330 if (!isset($args[$pos]) || !is_array($args[$pos])) {
330 - throw new WPRProtectRuleError_V662(
331 + throw new WPRProtectRuleError_V676(
331 332 $this->addExState("TypeError: " . $func_name . " param at " . $pos . " is not an array.")
332 333 );
333 334 }
334 335 break;
@@ -334,9 +335,9 @@
334 335 break;
335 336 case 'mixed':
336 337 break;
337 338 default:
338 - throw new WPRProtectRuleError_V662(
339 + throw new WPRProtectRuleError_V676(
339 340 $this->addExState("InvalidParamTypeError: Invalid type at " . $pos . " for " . $func_name)
340 341 );
341 342 }
342 343 }