Advertisement
viamvadens

Untitled

Jan 26th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1.  
  2. function _executeRules($s, $RULES, $CF, $M1, $M2, $FI, $ARGS=array()){
  3. $vars = explode(" ", "CF M1 M2 FI");
  4. foreach($ARGS as $k => $v){
  5. if(@eval(($_code="\$$k = \$ARGS['$k'];")." return true;") !== true){
  6. throw new Exception(__("ERROR: cant execute code: '%s'", $_code));
  7. }
  8. $vars[] = $k;
  9. }
  10.  
  11.  
  12. foreach($RULES as $_rule){
  13. if(($_rule=trim($_rule)) == ""){
  14. continue;
  15. }
  16. if(!preg_match("!^[\[\|]([\+\-])[\]\|]:[ ]+(.+)$!", $_rule, $_m) or !(list($_, $op, $code)=$_m)){
  17. throw new Exception(__("ERROR: cant parse rule: '%s'", $_rule));
  18. }
  19. $code = trim(preg_replace(__("!( |[\(\)]|^)((?:%s))( |\(\)]|$)!", implode('|', $vars)), "$1\$$2$3", $code));
  20.  
  21. $_we_have_it = true;
  22. if($code != "any"){
  23. $_we_have_it = false;
  24. if(@eval("\$_we_have_it=($code); return true;") !== true){
  25. throw new Exception(__("ERROR: cant execute code: '%s'", $code));
  26. }
  27. #echo "$op: $code: "; var_dump($_we_have_it); echo "\n\n";
  28. }
  29. if($_we_have_it){
  30. $status = ($op == '+');
  31. $s->_echo( __("[#] %s by $_rule \n", ($status ? 'ALLOWED': 'DENIED')) );
  32. return $status;
  33. }
  34. }
  35.  
  36. throw new Exception(__("ERROR: something`s going wrong while exec BURGER_RULES"));
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement