Changeset 13604

Show
Ignore:
Timestamp:
02/27/12 19:23:12 (1 year ago)
Author:
p_lindheimer
Message:

fixes #5628 we think don't mutilate channel variables passed in

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.10/amp_conf/htdocs/admin/libraries/extensions.class.php

    r13477 r13604  
    10251025      case 'app_confbridge': 
    10261026        $this->app = 'ConfBridge'; 
     1027       
    10271028        //remove invalid options 
    1028         $this->options = str_replace(array('b', 'C', 'd', 'D',  
    1029                           'e', 'E', 'F', 'i',  
    1030                           'I', 'l', 'o', 'P',  
    1031                           'r', 's', 't', 'T',  
    1032                           'x', 'X'), '', $this->options); 
     1029        $meetme_only = array('b', 'C', 'd', 'D',  
     1030                  'e', 'E', 'F', 'i',  
     1031                  'I', 'l', 'o', 'P',  
     1032                  'r', 's', 't', 'T',  
     1033                  'x', 'X'); 
     1034                   
     1035        //find asterisk variables in $this->options, if any 
     1036        if (preg_match_all('/\$|}/', $this->options, $matches, PREG_OFFSET_CAPTURE)) { 
     1037          $matches = $matches[0]; 
     1038          //build a range of start and endpoints of any asterisk variables 
     1039          for($i = 0; $i < count($matches); $i += 2) { 
     1040            if ($matches[$i][0] == '$') { 
     1041              $range[] = array( $matches[$i][1], $matches[$i + 1][1]); 
     1042            } 
     1043          } 
     1044           
     1045          //loop through each charachter in $this->options. If its not in the 
     1046          //range of asterisk variables $range, replace its charachter it its in $meetme_only 
     1047          $str_array = str_split($this->options); 
     1048          for ($i = 0; $i < count($str_array); $i++) { 
     1049            if (!$this->in_ast_var_range($i, $range)) { 
     1050              $str_array[$i] = str_replace($meetme_only, '', $stra[$i]); 
     1051            } 
     1052          } 
     1053          $this->options = implode($str_array); 
     1054        } else { 
     1055          $this->options = str_replace($meetme_only, '', $this->options); 
     1056        } 
     1057         
    10331058        $this->options = preg_replace('/[GpSL]\(.*\)/', '', $this->options); 
    10341059        $this->options = preg_replace('/w\(.*\)/', 'w', $this->options); 
     
    10431068  function output() { 
    10441069    return $this->app . "(".$this->confno.",".$this->options.",".$this->pin.")"; 
     1070  } 
     1071   
     1072  /** 
     1073   * @pram int 
     1074   * @pram array - multi dimensional with ranges 
     1075   * i.e. array( 
     1076   *  array(4 => 6), 
     1077   *  array(8 => 9) 
     1078   * ) 
     1079   * 
     1080   * @return true if $pos is not in range 
     1081   */ 
     1082  function in_ast_var_range($pos, $range) { 
     1083    foreach ($range as $r) { 
     1084      if ($pos >= $r[0] && $pos <= $r[1]) { 
     1085        return true; 
     1086      } 
     1087    } 
     1088 
     1089    return false; 
    10451090  } 
    10461091}