Portions created by the Initial Developer are Copyright (C) 2008-2016 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose Riccardo Granchi Gill Abada */ //includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('outbound_route_add')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //show the header require_once "resources/header.php"; $document['title'] = $text['title-dialplan-outbound-add']; require_once "resources/paging.php"; //get the http post values and set theme as php variables if (count($_POST) > 0) { //set the variables $dialplan_name = check_str($_POST["dialplan_name"]); $dialplan_order = check_str($_POST["dialplan_order"]); $dialplan_expression = check_str($_POST["dialplan_expression"]); $prefix_number = check_str($_POST["prefix_number"]); $condition_field_1 = check_str($_POST["condition_field_1"]); $condition_expression_1 = check_str($_POST["condition_expression_1"]); $condition_field_2 = check_str($_POST["condition_field_2"]); $condition_expression_2 = check_str($_POST["condition_expression_2"]); $gateway = check_str($_POST["gateway"]); $limit = check_str($_POST["limit"]); $accountcode = check_str($_POST["accountcode"]); $toll_allow_enable = check_str($_POST["toll_allow_enabled"]); //set default to enabled if (strlen($toll_allow_enable) == 0) { $toll_allow_enable = "false"; } //set the default type $gateway_type = 'gateway'; $gateway_2_type = 'gateway'; $gateway_3_type = 'gateway'; //set the gateway type to enum if (strtolower(substr($gateway, 0, 7)) == "enum") { $gateway_type = 'enum'; } //set the gateway type to freetdm if (strtolower(substr($gateway, 0, 7)) == "freetdm") { $gateway_type = 'freetdm'; } //set the gateway type to transfer if (strtolower(substr($gateway, 0, 8)) == "transfer") { $gateway_type = 'transfer'; } //set the gateway type to dingaling if (strtolower(substr($gateway, 0, 4)) == "xmpp") { $gateway_type = 'xmpp'; } //set the gateway_uuid and gateway_name if ($gateway_type == "gateway") { $gateway_array = explode(":",$gateway); $gateway_uuid = $gateway_array[0]; $gateway_name = $gateway_array[1]; } else { $gateway_name = ''; $gateway_uuid = ''; } //set the gateway_2 variable $gateway_2 = check_str($_POST["gateway_2"]); //set the gateway type to enum if (strtolower(substr($gateway_2, 0, 4)) == "enum") { $gateway_2_type = 'enum'; } //set the gateway type to freetdm if (strtolower(substr($gateway_2, 0, 7)) == "freetdm") { $gateway_2_type = 'freetdm'; } //set the gateway type to dingaling if (strtolower(substr($gateway_2, 0, 4)) == "xmpp") { $gateway_2_type = 'xmpp'; } //set the gateway_2_id and gateway_2_name if ($gateway_2_type == "gateway" && strlen($_POST["gateway_2"]) > 0) { $gateway_2_array = explode(":",$gateway_2); $gateway_2_id = $gateway_2_array[0]; $gateway_2_name = $gateway_2_array[1]; } else { $gateway_2_id = ''; $gateway_2_name = ''; } //set the gateway_3 variable $gateway_3 = check_str($_POST["gateway_3"]); //set the gateway type to enum if (strtolower(substr($gateway_3, 0, 4)) == "enum") { $gateway_3_type = 'enum'; } //set the gateway type to freetdm if (strtolower(substr($gateway_3, 0, 7)) == "freetdm") { $gateway_3_type = 'freetdm'; } //set the gateway type to dingaling if (strtolower(substr($gateway_3, 0, 4)) == "xmpp") { $gateway_3_type = 'xmpp'; } //set the gateway_3_id and gateway_3_name if ($gateway_3_type == "gateway" && strlen($_POST["gateway_3"]) > 0) { $gateway_3_array = explode(":",$gateway_3); $gateway_3_id = $gateway_3_array[0]; $gateway_3_name = $gateway_3_array[1]; } else { $gateway_3_id = ''; $gateway_3_name = ''; } //set additional variables $dialplan_enabled = check_str($_POST["dialplan_enabled"]); $dialplan_description = check_str($_POST["dialplan_description"]); //set default to enabled if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } } //process the http form values if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data if (strlen($gateway) == 0) { $msg .= $text['message-provide'].": ".$text['label-gateway-name']."
\n"; } //if (strlen($gateway_2) == 0) { $msg .= "Please provide: Alternat 1
\n"; } //if (strlen($gateway_3) == 0) { $msg .= "Please provide: Alternat 2
\n"; } if (strlen($dialplan_expression) == 0) { $msg .= $text['message-provide'].": ".$text['label-dialplan-expression']."
\n"; } //if (strlen($dialplan_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } //if (strlen($condition_field_1) == 0) { $msg .= "Please provide: Condition Field
\n"; } //if (strlen($condition_expression_1) == 0) { $msg .= "Please provide: Condition Expression
\n"; } //if (strlen($limit) == 0) { $msg .= "Please provide: Limit
\n"; } //if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled True or False
\n"; } //if (strlen($description) == 0) { $msg .= "Please provide: Description
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //prepare to build the array if (strlen(trim($_POST['dialplan_expression'])) > 0) { $tmp_array = explode("\n", $_POST['dialplan_expression']); $x = 0; foreach($tmp_array as $dialplan_expression) { $dialplan_expression = trim($dialplan_expression); if (strlen($dialplan_expression) > 0) { switch ($dialplan_expression) { case "^(\d{7})$": $label = $text['label-7d']; $abbrv = "7d"; break; case "^(\d{8})$": $label = $text['label-8d']; $abbrv = "8d"; break; case "^(\d{9})$": $label = $text['label-9d']; $abbrv = "9d"; break; case "^(\d{10})$": $label = $text['label-10d']; $abbrv = "10d"; break; case "^\+?(\d{11})$": $label = $text['label-11d']; $abbrv = "11d"; break; case "^(?:\+?1)?(\d{10})$": $label = $text['label-north-america']; $abbrv = "10-11d"; break; case "^(011\d{9,17})$": $label = $text['label-north-america-intl']; $abbrv = "011.9-17d"; break; case "^(\d{12,20})$": $label = $text['label-intl']; $abbrv = $text['label-intl']; break; case "^(311)$": $label = $text['label-311']; $abbrv = "311"; break; case "^(411)$": $label = $text['label-411']; $abbrv = "411"; break; case "^(711)$": $label = $text['label-711']; $abbrv = "711"; break; case "^(911)$": $label = $text['label-911']; $abbrv = "911"; break; case "^9(\d{3})$": $label = $text['label-9d3']; $abbrv = "9.3d"; break; case "^9(\d{4})$": $label = $text['label-9d4']; $abbrv = "9.4d"; break; case "^9(\d{7})$": $label = $text['label-9d7']; $abbrv = "9.7d"; break; case "^9(\d{10})$": $label = $text['label-9d10']; $abbrv = "9.10d"; break; case "^9(\d{11})$": $label = $text['label-9d11']; $abbrv = "9.11d"; break; case "^9(\d{12,20})$": $label = $text['label-9d.12-20']; $abbrv = "9.12-20"; break; case "^1?(8(00|55|66|77|88)[2-9]\d{6})$": $label = $text['label-800']; $abbrv = "800"; break; case "^0118835100\d{8}$": $label = $text['label-inum']; $abbrv = "inum"; break; default: $label = $dialplan_expression; $abbrv = filename_safe($dialplan_expression); } // Use as outbound prefix all digits beetwen ^ and first ( $tmp_prefix = preg_replace("/^\^(\d{1,})\(.*/", "$1", $dialplan_expression); $tmp_prefix == $dialplan_expression ? $outbound_prefix = "" : $outbound_prefix = $tmp_prefix; if ($gateway_type == "gateway") { $dialplan_name = $gateway_name.".".$abbrv; $action_data = "sofia/gateway/".$gateway_uuid."/".$prefix_number."\$1"; } if (strlen($gateway_2_name) > 0 && $gateway_2_type == "gateway") { $extension_2_name = $gateway_2_id.".".$abbrv; $bridge_2_data .= "sofia/gateway/".$gateway_2_id."/".$prefix_number."\$1"; } if (strlen($gateway_3_name) > 0 && $gateway_3_type == "gateway") { $extension_3_name = $gateway_3_id.".".$abbrv; $bridge_3_data .= "sofia/gateway/".$gateway_3_id."/".$prefix_number."\$1"; } if ($gateway_type == "freetdm") { $dialplan_name = "freetdm.".$abbrv; $action_data = $gateway."/1/a/".$prefix_number."\$1"; } if ($gateway_2_type == "freetdm") { $extension_2_name = "freetdm.".$abbrv; $bridge_2_data .= $gateway_2."/1/a/".$prefix_number."\$1"; } if ($gateway_3_type == "freetdm") { $extension_3_name = "freetdm.".$abbrv; $bridge_3_data .= $gateway_3."/1/a/".$prefix_number."\$1"; } if ($gateway_type == "xmpp") { $dialplan_name = "xmpp.".$abbrv; $action_data = "dingaling/gtalk/+".$prefix_number."\$1@voice.google.com"; } if ($gateway_2_type == "xmpp") { $extension_2_name = "xmpp.".$abbrv; $bridge_2_data .= "dingaling/gtalk/+".$prefix_number."\$1@voice.google.com"; } if ($gateway_3_type == "xmpp") { $extension_3_name = "xmpp.".$abbrv; $bridge_3_data .= "dingaling/gtalk/+".$prefix_number."\$1@voice.google.com"; } if ($gateway_type == "enum") { if (strlen($bridge_2_data) == 0) { $dialplan_name = "enum.".$abbrv; } else { $dialplan_name = $extension_2_name; } $action_data = "\${enum_auto_route}"; } if ($gateway_2_type == "enum") { $bridge_2_data .= "\${enum_auto_route}"; } if ($gateway_3_type == "enum") { $bridge_3_data .= "\${enum_auto_route}"; } if ($gateway_type == "transfer") { $dialplan_name = "transfer.".$abbrv; $gateway_array = explode(":",$gateway); $action_data = $gateway_array[1]; } if ($gateway_2_type == "transfer") { $gateway_array = explode(":",$gateway_2); $bridge_2_data = $gateway_array[1]; } if ($gateway_3_type == "transfer") { $gateway_array = explode(":",$gateway_3); $bridge_3_data = $gateway_array[1]; } if (strlen($dialplan_order) == 0) { $dialplan_order ='333'; } $dialplan_context = $_SESSION['context']; $dialplan_continue = 'false'; $app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3'; //set the uuid $dialplan_uuid = uuid(); //build the array $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['app_uuid'] = $app_uuid; $array['dialplans'][$x]['dialplan_name'] = $dialplan_name; $array['dialplans'][$x]['dialplan_order'] = $dialplan_order; $array['dialplans'][$x]['dialplan_continue'] = $dialplan_continue; $array['dialplans'][$x]['dialplan_context'] = $dialplan_context; $array['dialplans'][$x]['dialplan_enabled'] = $dialplan_enabled; $array['dialplans'][$x]['dialplan_description'] = $dialplan_description; $y = 0; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'condition'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = '${user_exists}'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'false'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'condition'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'destination_number'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $dialplan_expression; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; if ($gateway_type != "transfer") { if (strlen($accountcode) > 0) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'sip_h_X-accountcode='.$accountcode; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } else { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'sip_h_X-accountcode=${accountcode}'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } } $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'export'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'call_direction=outbound'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'unset'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'call_timeout'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; if ($gateway_type != "transfer") { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'hangup_after_bridge=true'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; if ($dialplan_expression == '^(911)$') { $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'effective_caller_id_name=${emergency_caller_id_name}'; } else { $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'effective_caller_id_name=${outbound_caller_id_name}'; } $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; if ($dialplan_expression == '^(911)$') { $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'effective_caller_id_number=${emergency_caller_id_number}'; } else { $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'effective_caller_id_number=${outbound_caller_id_number}'; } $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'inherit_codec=true'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'ignore_display_updates=true'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'callee_id_number=$1'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'continue_on_fail=true'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } if ($gateway_type == "enum" || $gateway_2_type == "enum") { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'enum'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $prefix_number."$1 e164.org"; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } if (strlen($limit) > 0) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'limit'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = "hash \${domain_name} outbound ".$limit." !USER_BUSY"; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } if (strlen($outbound_prefix) > 0) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'outbound_prefix='.$outbound_prefix; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } if ($toll_allow_enable == "true") { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'lua'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'app.lua toll_allow ${uuid}'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } if ($gateway_type == "transfer") { $dialplan_detail_type = 'transfer'; } else { $dialplan_detail_type = 'bridge'; } $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = $dialplan_detail_type; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $action_data; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; if (strlen($bridge_2_data) > 0) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'bridge'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $bridge_2_data; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } if (strlen($bridge_3_data) > 0) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'bridge'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $bridge_3_data; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; } unset($bridge_2_data); unset($bridge_3_data); unset($label); unset($abbrv); unset($dialplan_expression); unset($action_data); } //if strlen $x++; } //end foreach } //save to the data $database = new database; $database->app_name = 'outbound_routes'; $database->app_uuid = $app_uuid; $database->save($array); $message = $database->message; //update the dialplan xml $dialplans = new dialplan; $dialplans->source = "details"; $dialplans->destination = "database"; $dialplans->uuid = $dialplan_uuid; $dialplans->xml(); //clear the cache $cache = new cache; $cache->delete("dialplan:".$dialplan_context); //synchronize the xml config save_dialplan_xml(); //redirect the browser messages::add($text['message-update']); header("Location: ".PROJECT_PATH."/app/dialplans/dialplans.php?app_uuid=8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3"); return; } //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) ?> \n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['label-outbound-routes']."\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
"; echo " ".$text['description-outbound-routes']."\n"; echo "
"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('outbound_route_toll_allow_lua')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo ""; echo "
\n"; echo " ".$text['label-gateway']."\n"; echo "\n"; if (if_group("superadmin")) { echo "\n"; echo "\n"; } //set the onchange if (if_group("superadmin")) { $onchange = "onchange='changeToInput(this);'"; } else { $onchange = ''; } $sql = "select * from v_gateways "; $sql .= "where enabled = 'true' "; if (permission_exists('outbound_route_any_gateway')) { $sql .= " order by domain_uuid = '$domain_uuid' "; } else { $sql .= " and domain_uuid = '$domain_uuid' "; } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); echo "\n"; echo "
\n"; echo $text['message-add-options']."\n"; echo "
\n"; echo " ".$text['label-alt1']."\n"; echo "\n"; $sql = "select * from v_gateways "; $sql .= "where enabled = 'true' "; if (permission_exists('outbound_route_any_gateway')) { $sql .= "order by domain_uuid = '$domain_uuid' "; } else { $sql .= "and domain_uuid = '$domain_uuid' "; } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); echo "\n"; echo "
\n"; echo $text['message-add-options1']."\n"; echo "
\n"; echo " ".$text['label-alt2']."\n"; echo "\n"; $sql = "select * from v_gateways "; $sql .= "where enabled = 'true' "; if (permission_exists('outbound_route_any_gateway')) { $sql .= "order by domain_uuid = '$domain_uuid' "; } else { $sql .= "and domain_uuid = '$domain_uuid' "; } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); echo "\n"; echo "
\n"; echo $text['message-add-options2']."\n"; echo "
".$text['label-dialplan-expression'].""; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
".$text['description-enter-custom-outbound-prefix'].".\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['description-shortcut']." \n"; echo "
\n"; echo " ".$text['label-prefix']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-enter-prefix']."\n"; echo "
\n"; echo " ".$text['label-limit']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-limit']."\n"; echo "
\n"; echo " ".$text['label-accountcode']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-accountcode']."\n"; echo "
\n"; echo " ".$text['label-toll_allow']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-enable-toll_allow']."\n"; echo "
\n"; echo " ".$text['label-order']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo " ".$text['description-order']."\n"; echo "
\n"; echo " ".$text['label-enabled']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-enabled']."\n"; echo "
\n"; echo " ".$text['label-description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-description']."\n"; echo "
\n"; if ($action == "update") { echo " \n"; } echo "
"; echo " \n"; echo "
"; echo "

"; echo ""; //show the footer require_once "resources/footer.php"; ?>