| @@ -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('WPRProtectFWRuleArrayFunc_V672')) : | |
| 6 | -trait WPRProtectFWRuleArrayFunc_V672 { | |
| 5 | +if (!trait_exists('WPRProtectFWRuleArrayFunc_V676')) : | |
| 6 | +trait WPRProtectFWRuleArrayFunc_V676 { | |
| 7 | 7 | private function _rf_inArray() { |
| 8 | 8 | $args = $this->processRuleFunctionParams( |
| 9 | 9 | 'inArray', |
| 10 | 10 | func_num_args(), |
| @@ -15,15 +15,15 @@ | ||
| 15 | 15 | $array = $args[1]; |
| 16 | 16 | $strict = isset($args[2]) ? $args[2] : false; |
| 17 | 17 | |
| 18 | 18 | if (!is_array($array)) { |
| 19 | - throw new WPRProtectRuleError_V672( | |
| 19 | + throw new WPRProtectRuleError_V676( | |
| 20 | 20 | $this->addExState("inArray: 2nd param is not an array") |
| 21 | 21 | ); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!is_bool($strict)) { |
| 25 | - throw new WPRProtectRuleError_V672( | |
| 25 | + throw new WPRProtectRuleError_V676( | |
| 26 | 26 | $this->addExState("inArray: 3rd param is not a boolean") |
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
| @@ -52,9 +52,9 @@ | ||
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | } else { |
| 56 | - throw new WPRProtectRuleError_V672( | |
| 56 | + throw new WPRProtectRuleError_V676( | |
| 57 | 57 | $this->addExState("recInArray: Expects an array") |
| 58 | 58 | ); |
| 59 | 59 | } |
| 60 | 60 | |
| @@ -71,13 +71,13 @@ | ||
| 71 | 71 | $key = $args[0]; |
| 72 | 72 | $array = $args[1]; |
| 73 | 73 | |
| 74 | 74 | if (!is_array($array)) { |
| 75 | - throw new WPRProtectRuleError_V672( | |
| 75 | + throw new WPRProtectRuleError_V676( | |
| 76 | 76 | $this->addExState("arrayKeyExists: Array must be of type array") |
| 77 | 77 | ); |
| 78 | 78 | } elseif (!is_string($key) && !is_int($key)) { |
| 79 | - throw new WPRProtectRuleError_V672( | |
| 79 | + throw new WPRProtectRuleError_V676( | |
| 80 | 80 | $this->addExState("arrayKeyExists: Key must be of type string or int") |
| 81 | 81 | ); |
| 82 | 82 | } |
| 83 | 83 | |
| @@ -108,9 +108,9 @@ | ||
| 108 | 108 | $array = $args[0]; |
| 109 | 109 | $recursive = isset($args[1]) ? $args[1] : false; |
| 110 | 110 | |
| 111 | 111 | if (!is_bool($recursive)) { |
| 112 | - throw new WPRProtectRuleError_V672( | |
| 112 | + throw new WPRProtectRuleError_V676( | |
| 113 | 113 | $this->addExState("getArrayKeys: 2nd param must be a boolean") |
| 114 | 114 | ); |
| 115 | 115 | } |
| 116 | 116 | |
| @@ -138,9 +138,9 @@ | ||
| 138 | 138 | $keys = $args[1]; |
| 139 | 139 | $recursive = isset($args[2]) ? $args[2] : false; |
| 140 | 140 | |
| 141 | 141 | if (!is_bool($recursive)) { |
| 142 | - throw new WPRProtectRuleError_V672( | |
| 142 | + throw new WPRProtectRuleError_V676( | |
| 143 | 143 | $this->addExState("hasAnyArrayKey: 3rd param must be a boolean") |
| 144 | 144 | ); |
| 145 | 145 | } |
| 146 | 146 | |
| @@ -146,9 +146,9 @@ | ||
| 146 | 146 | |
| 147 | 147 | $key_lookup = array(); |
| 148 | 148 | foreach ($keys as $key) { |
| 149 | 149 | if (!is_int($key) && !is_string($key)) { |
| 150 | - throw new WPRProtectRuleError_V672( | |
| 150 | + throw new WPRProtectRuleError_V676( | |
| 151 | 151 | $this->addExState("hasAnyArrayKey: Key must be of type string or int") |
| 152 | 152 | ); |
| 153 | 153 | } |
| 154 | 154 | |
| @@ -187,9 +187,9 @@ | ||
| 187 | 187 | $array = $args[1]; |
| 188 | 188 | $recursive = isset($args[2]) ? $args[2] : false; |
| 189 | 189 | |
| 190 | 190 | if (!is_bool($recursive)) { |
| 191 | - throw new WPRProtectRuleError_V672( | |
| 191 | + throw new WPRProtectRuleError_V676( | |
| 192 | 192 | $this->addExState("keyMatches: 3rd param must be a boolean") |
| 193 | 193 | ); |
| 194 | 194 | } |
| 195 | 195 | |
| @@ -222,9 +222,9 @@ | ||
| 222 | 222 | restore_error_handler(); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | if ($resp === false) { |
| 226 | - throw new WPRProtectRuleError_V672( | |
| 226 | + throw new WPRProtectRuleError_V676( | |
| 227 | 227 | $this->addExState("keyMatches: Invalid regular expression") |
| 228 | 228 | ); |
| 229 | 229 | } |
| 230 | 230 | } |
| @@ -231,9 +231,9 @@ | ||
| 231 | 231 | |
| 232 | 232 | private function keyMatchesPattern($pattern, $key) { |
| 233 | 233 | $resp = WPRHelper::safePregMatch($pattern, (string) $key); |
| 234 | 234 | if ($resp === false) { |
| 235 | - throw new WPRProtectRuleError_V672( | |
| 235 | + throw new WPRProtectRuleError_V676( | |
| 236 | 236 | $this->addExState("keyMatches: Regex match failed") |
| 237 | 237 | ); |
| 238 | 238 | } |
| 239 | 239 | |
| @@ -240,9 +240,9 @@ | ||
| 240 | 240 | return $resp > 0; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | private function keyMatchesRecursive($array, $pattern, &$traversed_keys, $depth = 1) { |
| 244 | - if ($depth > WPRProtectFWRuleEngine_V672::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { | |
| 244 | + if ($depth > WPRProtectFWRuleEngine_V676::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { | |
| 245 | 245 | return false; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | foreach ($array as $key => $value) { |
| @@ -260,9 +260,9 @@ | ||
| 260 | 260 | return false; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | private function getArrayKeysRecursive($array, &$keys, &$traversed_keys, $depth = 1) { |
| 264 | - if ($depth > WPRProtectFWRuleEngine_V672::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { | |
| 264 | + if ($depth > WPRProtectFWRuleEngine_V676::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { | |
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | foreach ($array as $key => $value) { |
| @@ -275,9 +275,9 @@ | ||
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | private function hasAnyArrayKeyRecursive($array, $key_lookup, &$traversed_keys, $depth = 1) { |
| 279 | - if ($depth > WPRProtectFWRuleEngine_V672::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { | |
| 279 | + if ($depth > WPRProtectFWRuleEngine_V676::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { | |
| 280 | 280 | return false; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | foreach ($array as $key => $value) { |
| @@ -295,13 +295,13 @@ | ||
| 295 | 295 | return false; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | private function enforceArrayTraversalLimit($func_name, $traversed_keys) { |
| 299 | - if ($traversed_keys > WPRProtectFWRuleEngine_V672::MAX_ARRAY_KEYS_TO_TRAVERSE) { | |
| 300 | - throw new WPRProtectRuleError_V672( | |
| 299 | + if ($traversed_keys > WPRProtectFWRuleEngine_V676::MAX_ARRAY_KEYS_TO_TRAVERSE) { | |
| 300 | + throw new WPRProtectRuleError_V676( | |
| 301 | 301 | $this->addExState( |
| 302 | 302 | "TraversalLimitError: " . $func_name . " exceeded " . |
| 303 | - WPRProtectFWRuleEngine_V672::MAX_ARRAY_KEYS_TO_TRAVERSE . | |
| 303 | + WPRProtectFWRuleEngine_V676::MAX_ARRAY_KEYS_TO_TRAVERSE . | |
| 304 | 304 | " array keys" |
| 305 | 305 | ) |
| 306 | 306 | ); |
| 307 | 307 | } |
| @@ -319,9 +319,9 @@ | ||
| 319 | 319 | $keys = $args[1]; |
| 320 | 320 | |
| 321 | 321 | foreach ($keys as $key) { |
| 322 | 322 | if (!is_int($key) && !is_string($key)) { |
| 323 | - throw new WPRProtectRuleError_V672( | |
| 323 | + throw new WPRProtectRuleError_V676( | |
| 324 | 324 | $this->addExState("digArray: Keys must be a valid array of string, or integer type") |
| 325 | 325 | ); |
| 326 | 326 | } |
| 327 | 327 | } |
| @@ -340,18 +340,18 @@ | ||
| 340 | 340 | $array = $args[0]; |
| 341 | 341 | $keys = $args[1]; |
| 342 | 342 | |
| 343 | 343 | if (empty($keys)) { |
| 344 | - throw new WPRProtectRuleError_V672( | |
| 344 | + throw new WPRProtectRuleError_V676( | |
| 345 | 345 | $this->addExState("digArrayValues: Keys must not be empty") |
| 346 | 346 | ); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if (count($keys) > WPRProtectFWRuleEngine_V672::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { | |
| 350 | - throw new WPRProtectRuleError_V672( | |
| 349 | + if (count($keys) > WPRProtectFWRuleEngine_V676::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) { | |
| 350 | + throw new WPRProtectRuleError_V676( | |
| 351 | 351 | $this->addExState( |
| 352 | 352 | "digArrayValues: Keys exceeded " . |
| 353 | - WPRProtectFWRuleEngine_V672::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC . | |
| 353 | + WPRProtectFWRuleEngine_V676::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC . | |
| 354 | 354 | " levels of traversal" |
| 355 | 355 | ) |
| 356 | 356 | ); |
| 357 | 357 | } |
| @@ -357,9 +357,9 @@ | ||
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | foreach ($keys as $key) { |
| 360 | 360 | if (!is_int($key) && !is_string($key)) { |
| 361 | - throw new WPRProtectRuleError_V672( | |
| 361 | + throw new WPRProtectRuleError_V676( | |
| 362 | 362 | $this->addExState("digArrayValues: Keys must be a valid array of string, or integer type") |
| 363 | 363 | ); |
| 364 | 364 | } |
| 365 | 365 | } |
| @@ -374,9 +374,9 @@ | ||
| 374 | 374 | if (!is_array($node)) { |
| 375 | 375 | continue; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ($key === WPRProtectFWRuleEngine_V672::WILDCARD_KEY) { | |
| 378 | + if ($key === WPRProtectFWRuleEngine_V676::WILDCARD_KEY) { | |
| 379 | 379 | foreach ($node as $value) { |
| 380 | 380 | $traversed_keys += 1; |
| 381 | 381 | $this->enforceArrayTraversalLimit('digArrayValues', $traversed_keys); |
| 382 | 382 | $next_nodes[] = $value; |
| @@ -415,9 +415,9 @@ | ||
| 415 | 415 | $keys = $args[1]; |
| 416 | 416 | |
| 417 | 417 | foreach ($keys as $key) { |
| 418 | 418 | if (!is_int($key) && !is_string($key)) { |
| 419 | - throw new WPRProtectRuleError_V672( | |
| 419 | + throw new WPRProtectRuleError_V676( | |
| 420 | 420 | $this->addExState("filterArray: Keys must be a valid array of string, or integer type") |
| 421 | 421 | ); |
| 422 | 422 | } |
| 423 | 423 | } |
| @@ -436,9 +436,9 @@ | ||
| 436 | 436 | $array = $args[0]; |
| 437 | 437 | $key = $args[1]; |
| 438 | 438 | |
| 439 | 439 | if (!is_string($key) && !is_int($key)) { |
| 440 | - throw new WPRProtectRuleError_V672( | |
| 440 | + throw new WPRProtectRuleError_V676( | |
| 441 | 441 | $this->addExState("getArrayVal: Key must be a valid string or integer") |
| 442 | 442 | ); |
| 443 | 443 | } |
| 444 | 444 | |
| @@ -517,9 +517,9 @@ | ||
| 517 | 517 | $array = $args[1]; |
| 518 | 518 | |
| 519 | 519 | foreach ($array as $element) { |
| 520 | 520 | if (!is_scalar($element)) { |
| 521 | - throw new WPRProtectRuleError_V672( | |
| 521 | + throw new WPRProtectRuleError_V676( | |
| 522 | 522 | $this->addExState("arrayJoin: Array element must be of scalar type") |
| 523 | 523 | ); |
| 524 | 524 | } |
| 525 | 525 | } |