| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | // phpcs:disable WordPress.Security.EscapeOutput.ExceptionNotEscaped |
| 3 | 3 | if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; |
| 4 | 4 | |
| 5 | -if (!trait_exists('WPRProtectFWRuleMiscFunc_V648')) : | |
| 6 | -trait WPRProtectFWRuleMiscFunc_V648 { | |
| 5 | +if (!trait_exists('WPRProtectFWRuleMiscFunc_V676')) : | |
| 6 | +trait WPRProtectFWRuleMiscFunc_V676 { | |
| 7 | 7 | private function _rf_isTrue() { |
| 8 | 8 | $args = $this->processRuleFunctionParams( |
| 9 | 9 | 'isTrue', |
| 10 | 10 | func_num_args(), |
| @@ -37,12 +37,28 @@ | ||
| 37 | 37 | ); |
| 38 | 38 | $value = $args[0]; |
| 39 | 39 | |
| 40 | 40 | $file = $this->_rf_getFiles($value); |
| 41 | - if (is_array($file) && in_array('tmp_name', $file)) { | |
| 42 | - return is_uploaded_file($file['tmp_name']); | |
| 41 | + if (!is_array($file) || !array_key_exists('tmp_name', $file)) { | |
| 42 | + return false; | |
| 43 | 43 | } |
| 44 | - | |
| 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 | + | |
| 45 | 61 | return false; |
| 46 | 62 | } |
| 47 | 63 | |
| 48 | 64 | private function _rf_getVarValue() { |
| @@ -55,9 +71,9 @@ | ||
| 55 | 71 | ); |
| 56 | 72 | $name = $args[0]; |
| 57 | 73 | |
| 58 | 74 | if (!array_key_exists($name, $this->variables)) { |
| 59 | - throw new WPRProtectRuleError_V648( | |
| 75 | + throw new WPRProtectRuleError_V676( | |
| 60 | 76 | $this->addExState("UndefinedVariableError: " . $name . " is not defined.") |
| 61 | 77 | ); |
| 62 | 78 | } |
| 63 | 79 | |
| @@ -116,9 +132,9 @@ | ||
| 116 | 132 | return false; |
| 117 | 133 | } |
| 118 | 134 | $resp = WPRHelper::safePregMatch((string) $pattern, (string) $subject); |
| 119 | 135 | if ($resp === false) { |
| 120 | - throw new WPRProtectRuleError_V648( | |
| 136 | + throw new WPRProtectRuleError_V676( | |
| 121 | 137 | $this->addExState('BVHelper::safePregMatch' . serialize($subject)) |
| 122 | 138 | ); |
| 123 | 139 | } elseif ($resp > 0) { |
| 124 | 140 | return true; |
| @@ -157,9 +173,9 @@ | ||
| 157 | 173 | return $count; |
| 158 | 174 | } |
| 159 | 175 | $count = preg_match_all((string) $pattern, (string) $subject, $matches); |
| 160 | 176 | if ($count === false) { |
| 161 | - throw new WPRProtectRuleError_V648( | |
| 177 | + throw new WPRProtectRuleError_V676( | |
| 162 | 178 | $this->addExState("preg_match_all: " . serialize($subject)) |
| 163 | 179 | ); |
| 164 | 180 | } |
| 165 | 181 | return $count; |
| @@ -183,9 +199,9 @@ | ||
| 183 | 199 | return $count; |
| 184 | 200 | } |
| 185 | 201 | $count = preg_match_all((string) $pattern, (string) $subject, $matches); |
| 186 | 202 | if ($count === false) { |
| 187 | - throw new WPRProtectRuleError_V648( | |
| 203 | + throw new WPRProtectRuleError_V676( | |
| 188 | 204 | $this->addExState("preg_match_all: " . serialize($subject)) |
| 189 | 205 | ); |
| 190 | 206 | } |
| 191 | 207 | return $count; |
| @@ -523,5 +539,5 @@ | ||
| 523 | 539 | |
| 524 | 540 | return gettype($value); |
| 525 | 541 | } |
| 526 | 542 | } |
| 527 | -endif; | |
| 543 | +endif; | |