function core_trunks_edit($trunknum, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, $failtrunk, $disabletrunk, $name = "", $provider = "", $continue = 'off', $dialopts = false) { global $db; $name = trim($name) == "" ? $channelid : $name; $tech = core_trunks_getTrunkTech($trunknum); if ($tech == "") { return false; } core_trunks_del($trunknum, $tech); core_trunks_backendAdd($trunknum, $tech, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, $failtrunk, $disabletrunk, $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: $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "http://www.localcallingguide.com/xmllocalprefix.php?npa=" . $matches[1] . "&nxx=" . $matches[2]); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; FreePBX Local Trunks Configuration)"); $str = curl_exec($ch);
if (isset($_POST['remove_key_del_trunks'])) { $action = 'remove_all'; } switch ($action) { case "ajax_get": case "dest_post": case "route_post": case "reset_trunk": case "refresh_display": $action($_POST); exit; break; case "remove_all": //just delete and re-add foreach ($_POST['trunkid'] as $trunk_id) { core_trunks_del($trunk_id, 'sip'); } sipstation_remove_key(); needreload(); break; case "edit": //just delete and re-add if ($remove_key) { sipstation_remove_key(); $key_status = 'nokey'; } elseif ($key_status == 'nokey') { // TOOD: provide feedback if they give blank blank key, maybe just js validation? $set_key_status = sipstation_set_key($account_key); } break; default: