case "addtrunk": if ($tech == 'pjsip') { $channelid = !empty($_REQUEST['trunk_name']) ? $_REQUEST['trunk_name'] : ''; } $trunknum = core_trunks_add($tech, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, trim($failtrunk), $disabletrunk, $trunk_name, $provider, $continue, $dialopts); core_trunks_update_dialrules($trunknum, $dialpattern_insert); needreload(); redirect_standard(); break; case "edittrunk": if ($tech == 'pjsip') { $channelid = !empty($_REQUEST['trunk_name']) ? $_REQUEST['trunk_name'] : ''; } core_trunks_edit($trunknum, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, trim($failtrunk), $disabletrunk, $trunk_name, $provider, $continue, $dialopts); // this can rewrite too, so edit is the same core_trunks_update_dialrules($trunknum, $dialpattern_insert, true); needreload(); redirect_standard('extdisplay'); break; case "deltrunk": core_trunks_del($trunknum); core_trunks_delete_dialrules($trunknum); core_routing_trunk_delbyid($trunknum); needreload(); redirect_standard(); break; case "populatenpanxx7": case "populatenpanxx10": $dialpattern_array = $dialpattern_insert; if (preg_match("/^([2-9]\\d\\d)-?([2-9]\\d\\d)\$/", $_REQUEST["npanxx"], $matches)) { // first thing we do is grab the exch:
foreach ($dialrules as $rule) { $match = $rule['match_pattern_pass']; $prefix = $rule['match_pattern_prefix']; $prepend = $rule['prepend_digits']; $dialrules_tmp[] = array('match_pattern_prefix' => $prefix, 'match_pattern_pass' => $match, 'prepend_digits' => $prepend); if ($match != 'NXXXXXX' || $prepend != $areacode || $prefix != '') { $dialrules_2[] = array('match_pattern_prefix' => $prefix, 'match_pattern_pass' => $match, 'prepend_digits' => $prepend); } } } else { $dialrules_2 = array(); $dialrules_tmp = array(); } array_unshift($dialrules_2, array('match_pattern_prefix' => '', 'match_pattern_pass' => 'NXXXXXX', 'prepend_digits' => $areacode)); if ($dialrules_2 != $dialrules_tmp) { core_trunks_update_dialrules($trunk, $dialrules_2, true); $need_reload = true; } unset($dialrules_2); unset($dialrules_tmp); unset($dialrules); } } else { $json_array['areacode_status'] = sprintf(_("The prefix you entered, %s, is not a proper prefix or the wrong length. It should be a 3 digit prefix."), $_POST['areacode']); } } $routes = core_routing_list(); foreach ($routes as $route) { $route_name = $route['name'] . $route['route_id']; $trunks = core_routing_getroutetrunksbyid($route['route_id']); $gw1 = array_search($trunknum1, $trunks);