| @@ -1,9 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | +// phpcs:disable WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 2 | 3 | if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; |
| 3 | 4 | |
| 4 | -if (!trait_exists('WPRProtectFWRuleMiscFunc_V542')) : | |
| 5 | -trait WPRProtectFWRuleMiscFunc_V542 { | |
| 5 | +if (!trait_exists('WPRProtectFWRuleMiscFunc_V676')) : | |
| 6 | +trait WPRProtectFWRuleMiscFunc_V676 { | |
| 6 | 7 | private function _rf_isTrue() { |
| 7 | 8 | $args = $this->processRuleFunctionParams( |
| 8 | 9 | 'isTrue', |
| 9 | 10 | func_num_args(), |
| @@ -36,12 +37,28 @@ | ||
| 36 | 37 | ); |
| 37 | 38 | $value = $args[0]; |
| 38 | 39 | |
| 39 | 40 | $file = $this->_rf_getFiles($value); |
| 40 | - if (is_array($file) && in_array('tmp_name', $file)) { | |
| 41 | - return is_uploaded_file($file['tmp_name']); | |
| 41 | + if (!is_array($file) || !array_key_exists('tmp_name', $file)) { | |
| 42 | + return false; | |
| 42 | 43 | } |
| 43 | - | |
| 44 | + | |
| 45 | + $paths = array($file['tmp_name']); | |
| 46 | + while (!empty($paths)) { | |
| 47 | + $path = array_pop($paths); | |
| 48 | + | |
| 49 | + if (is_array($path)) { | |
| 50 | + foreach ($path as $nested_path) { | |
| 51 | + $paths[] = $nested_path; | |
| 52 | + } | |
| 53 | + continue; | |
| 54 | + } | |
| 55 | + | |
| 56 | + if (is_string($path) && $path !== '' && is_uploaded_file($path)) { | |
| 57 | + return true; | |
| 58 | + } | |
| 59 | + } | |
| 60 | + | |
| 44 | 61 | return false; |
| 45 | 62 | } |
| 46 | 63 | |
| 47 | 64 | private function _rf_getVarValue() { |
| @@ -54,9 +71,9 @@ | ||
| 54 | 71 | ); |
| 55 | 72 | $name = $args[0]; |
| 56 | 73 | |
| 57 | 74 | if (!array_key_exists($name, $this->variables)) { |
| 58 | - throw new WPRProtectRuleError_V542( | |
| 75 | + throw new WPRProtectRuleError_V676( | |
| 59 | 76 | $this->addExState("UndefinedVariableError: " . $name . " is not defined.") |
| 60 | 77 | ); |
| 61 | 78 | } |
| 62 | 79 | |
| @@ -115,9 +132,9 @@ | ||
| 115 | 132 | return false; |
| 116 | 133 | } |
| 117 | 134 | $resp = WPRHelper::safePregMatch((string) $pattern, (string) $subject); |
| 118 | 135 | if ($resp === false) { |
| 119 | - throw new WPRProtectRuleError_V542( | |
| 136 | + throw new WPRProtectRuleError_V676( | |
| 120 | 137 | $this->addExState('BVHelper::safePregMatch' . serialize($subject)) |
| 121 | 138 | ); |
| 122 | 139 | } elseif ($resp > 0) { |
| 123 | 140 | return true; |
| @@ -156,9 +173,9 @@ | ||
| 156 | 173 | return $count; |
| 157 | 174 | } |
| 158 | 175 | $count = preg_match_all((string) $pattern, (string) $subject, $matches); |
| 159 | 176 | if ($count === false) { |
| 160 | - throw new WPRProtectRuleError_V542( | |
| 177 | + throw new WPRProtectRuleError_V676( | |
| 161 | 178 | $this->addExState("preg_match_all: " . serialize($subject)) |
| 162 | 179 | ); |
| 163 | 180 | } |
| 164 | 181 | return $count; |
| @@ -182,9 +199,9 @@ | ||
| 182 | 199 | return $count; |
| 183 | 200 | } |
| 184 | 201 | $count = preg_match_all((string) $pattern, (string) $subject, $matches); |
| 185 | 202 | if ($count === false) { |
| 186 | - throw new WPRProtectRuleError_V542( | |
| 203 | + throw new WPRProtectRuleError_V676( | |
| 187 | 204 | $this->addExState("preg_match_all: " . serialize($subject)) |
| 188 | 205 | ); |
| 189 | 206 | } |
| 190 | 207 | return $count; |
| @@ -377,8 +394,9 @@ | ||
| 377 | 394 | func_num_args(), |
| 378 | 395 | func_get_args() |
| 379 | 396 | ); |
| 380 | 397 | |
| 398 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace -- Needed for stack trace functionality | |
| 381 | 399 | return debug_backtrace(); |
| 382 | 400 | } |
| 383 | 401 | |
| 384 | 402 | private function _rf_getFilesFromBacktrace() { |
| @@ -436,6 +454,90 @@ | ||
| 436 | 454 | $constant_name = $args[0]; |
| 437 | 455 | |
| 438 | 456 | return defined($constant_name); |
| 439 | 457 | } |
| 458 | + | |
| 459 | + private function _rf_isArray() { | |
| 460 | + $args = $this->processRuleFunctionParams( | |
| 461 | + 'isArray', | |
| 462 | + func_num_args(), | |
| 463 | + func_get_args(), | |
| 464 | + 1 | |
| 465 | + ); | |
| 466 | + $value = $args[0]; | |
| 467 | + | |
| 468 | + return is_array($value); | |
| 469 | + } | |
| 470 | + | |
| 471 | + private function _rf_isString() { | |
| 472 | + $args = $this->processRuleFunctionParams( | |
| 473 | + 'isString', | |
| 474 | + func_num_args(), | |
| 475 | + func_get_args(), | |
| 476 | + 1 | |
| 477 | + ); | |
| 478 | + $value = $args[0]; | |
| 479 | + | |
| 480 | + return is_string($value); | |
| 481 | + } | |
| 482 | + | |
| 483 | + private function _rf_isInt() { | |
| 484 | + $args = $this->processRuleFunctionParams( | |
| 485 | + 'isInt', | |
| 486 | + func_num_args(), | |
| 487 | + func_get_args(), | |
| 488 | + 1 | |
| 489 | + ); | |
| 490 | + $value = $args[0]; | |
| 491 | + | |
| 492 | + return is_int($value); | |
| 493 | + } | |
| 494 | + | |
| 495 | + private function _rf_isBool() { | |
| 496 | + $args = $this->processRuleFunctionParams( | |
| 497 | + 'isBool', | |
| 498 | + func_num_args(), | |
| 499 | + func_get_args(), | |
| 500 | + 1 | |
| 501 | + ); | |
| 502 | + $value = $args[0]; | |
| 503 | + | |
| 504 | + return is_bool($value); | |
| 505 | + } | |
| 506 | + | |
| 507 | + private function _rf_isFloat() { | |
| 508 | + $args = $this->processRuleFunctionParams( | |
| 509 | + 'isFloat', | |
| 510 | + func_num_args(), | |
| 511 | + func_get_args(), | |
| 512 | + 1 | |
| 513 | + ); | |
| 514 | + $value = $args[0]; | |
| 515 | + | |
| 516 | + return is_float($value); | |
| 517 | + } | |
| 518 | + | |
| 519 | + private function _rf_isObject() { | |
| 520 | + $args = $this->processRuleFunctionParams( | |
| 521 | + 'isObject', | |
| 522 | + func_num_args(), | |
| 523 | + func_get_args(), | |
| 524 | + 1 | |
| 525 | + ); | |
| 526 | + $value = $args[0]; | |
| 527 | + | |
| 528 | + return is_object($value); | |
| 529 | + } | |
| 530 | + | |
| 531 | + private function _rf_getType() { | |
| 532 | + $args = $this->processRuleFunctionParams( | |
| 533 | + 'getType', | |
| 534 | + func_num_args(), | |
| 535 | + func_get_args(), | |
| 536 | + 1 | |
| 537 | + ); | |
| 538 | + $value = $args[0]; | |
| 539 | + | |
| 540 | + return gettype($value); | |
| 541 | + } | |
| 440 | 542 | } |
| 441 | -endif; | |
| 543 | +endif; | |