Changeset 3283
- Timestamp:
- 12/06/06 14:34:42 (5 years ago)
- Files:
-
- freepbx/trunk/amp_conf/agi-bin/fixlocalprefix (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/trunk/amp_conf/agi-bin/fixlocalprefix
r2732 r3283 114 114 $chars = '0-9XNZwW#*\.\[\]\-'; //escaped pcre-ready 115 115 116 // convert x n and z to uppercase 117 $regex = str_replace(array('x','n','z'), array('X','N','Z'), $pattern); 116 118 // sanitize the pattern - remove any non-pattern chars 117 119 $regex = preg_replace("/[^0-9XNZwW#*\.\[\]\-\+\|]/", "", $regex); … … 119 121 $regex = preg_replace("/((?:\[[^\]]*\])*)([^\[\]\-]*)-?/", "$1$2", $regex); 120 122 123 $agi->verbose('Using pattern '.$regex, 4); 121 124 // attempt to grab the pieces of the pattern 122 if (preg_match('/^(([0-9XNZwW#*\.\[\]\-]+)\|)?(([0-9XNZwW#*\.\[\]\-]+)\+)?([0-9XNZwW#*\.\[\]\-]+)$/', $ pattern, $matches)) {125 if (preg_match('/^(([0-9XNZwW#*\.\[\]\-]+)\|)?(([0-9XNZwW#*\.\[\]\-]+)\+)?([0-9XNZwW#*\.\[\]\-]+)$/', $regex, $matches)) { 123 126 // one of NXXXXXX, 613|NXXXXXX 1+NXXXXXX 613|1+NXXXXXX, 124 127 // matches[2] = drop (eg 613), matches[4] = prefix (eg 1), matches[5] = rest of number (eg NXXXXX) … … 127 130 $prefix = $matches[4]; 128 131 $static = $matches[5]; 129 } else if (preg_match('/^(([0-9XNZwW#*\.\[\]\-]+)\+)?(([0-9XNZwW#*\.\[\]\-]+)\|)?([0-9XNZwW#*\.\[\]\-]+)$/', $ pattern, $matches)) {132 } else if (preg_match('/^(([0-9XNZwW#*\.\[\]\-]+)\+)?(([0-9XNZwW#*\.\[\]\-]+)\|)?([0-9XNZwW#*\.\[\]\-]+)$/', $regex, $matches)) { 130 133 // one of NXXXXXX, 613|NXXXXXX 1+NXXXXXX 1+613|NXXXXXX 131 134 // matches[2] = prefix (eg 1), matches[4] = drop (eg 613), matches[5] = rest of number (eg NXXXXX) … … 136 139 } else { 137 140 if (!is_null($agi)) { 138 $agi->verbose('Could not understand pattern "'.$pattern.'" ', 3);141 $agi->verbose('Could not understand pattern "'.$pattern.'" ('.$regex.')', 1); 139 142 } 140 143 return $false; … … 203 206 204 207 if ($newnum = fixNumber($rule, $number, $agi)) { 205 $agi->verbose('Dialpattern '.$rule.' matched. '.$number.' -> '.$newnum, 1);208 $agi->verbose('Dialpattern '.$rule.' matched. '.$number.' -> '.$newnum, 2); 206 209 $agi->set_variable("DIAL_NUMBER", $newnum); 207 210
