@@ -289,7 +289,7 @@ public function matchParameterValue($match, $value)
289289 return $ matchValue == $ value ;
290290 }
291291
292- if ($ matchType == 'bigger_than ' && is_scalar ($ value ) && is_scalar ($ matchValue )) {
292+ if ($ matchType == 'more_than ' && is_scalar ($ value ) && is_scalar ($ matchValue )) {
293293 return $ value > $ matchValue ;
294294 }
295295
@@ -317,7 +317,7 @@ public function matchParameterValue($match, $value)
317317 return @stripos ($ value , $ matchValue ) !== false ;
318318 }
319319
320- if ($ matchType == 'regex ' && is_scalar ($ value )) {
320+ if ($ matchType == 'regex ' && is_string ( $ matchValue ) && is_scalar ($ value )) {
321321 return @preg_match ($ matchValue , @urldecode ($ value )) === 1 ;
322322 }
323323
@@ -368,6 +368,14 @@ public function getParameterValue($parameter, $data = [])
368368 }
369369
370370 switch ($ type ) {
371+ case 'all ' :
372+ $ data = [
373+ 'post ' => $ _POST ,
374+ 'get ' => $ _GET ,
375+ 'url ' => isset ($ _SERVER ['REQUEST_URI ' ]) ? $ _SERVER ['REQUEST_URI ' ] : '' ,
376+ 'raw ' => ['raw ' => $ this ->getParameterValue ('raw ' )]
377+ ];
378+ break ;
371379 case 'post ' :
372380 $ data = $ _POST ;
373381 break ;
@@ -479,6 +487,14 @@ public function applyMutation($mutations, $value)
479487 'intval ' => [
480488 'args ' => [],
481489 'type ' => 'is_scalar '
490+ ],
491+ 'urldecode ' => [
492+ 'args ' => [],
493+ 'type ' => 'is_string '
494+ ],
495+ 'getArrayValues ' => [
496+ 'args ' => [],
497+ 'type ' => 'is_array '
482498 ]
483499 ];
484500
@@ -498,8 +514,12 @@ public function applyMutation($mutations, $value)
498514 }
499515
500516 // Call the function with given arguments.
501- $ value = call_user_func_array ($ mutation , array_merge ([$ value ], $ allowed [$ mutation ]['args ' ]));
502-
517+ if ($ mutation == 'getArrayValues ' ) {
518+ $ value = $ this ->getArrayValues ($ value );
519+ } else {
520+ $ value = call_user_func_array ($ mutation , array_merge ([$ value ], $ allowed [$ mutation ]['args ' ]));
521+ }
522+
503523 // No need to continue in these scenarios.
504524 if (is_null ($ value ) || $ value === false || $ value === 0 ) {
505525 return $ value ;
@@ -512,6 +532,31 @@ public function applyMutation($mutations, $value)
512532 return $ value ;
513533 }
514534
535+ /**
536+ * Given an array, multi-dimensional or not, extract all of its values.
537+ *
538+ * @param array $data
539+ * @return string
540+ */
541+ public function getArrayValues ($ data , $ glue = '& ' )
542+ {
543+ $ ret = '' ;
544+
545+ foreach ($ data as $ key => $ item ) {
546+ if (empty ($ item )) {
547+ continue ;
548+ }
549+
550+ if (is_array ($ item )) {
551+ $ ret .= $ this ->getArrayValues ($ item , $ glue ) . $ glue ;
552+ } else {
553+ $ ret .= $ key . '= ' . $ item . $ glue ;
554+ }
555+ }
556+
557+ return substr ($ ret , 0 , 0 - strlen ($ glue ));
558+ }
559+
515560 /**
516561 * The legacy firewall processor will only iterate over the general firewall rules.
517562 * Will return true if $mustExit is false and all of the rules were processed without a positive detection.
0 commit comments