0) { $ent['gatewayid'] = $_POST['ivrid']; } else { $ent['gatewayid'] = guid(); } $ent['gateway'] = $_POST['gateway']; $ent['username'] = $_POST['username']; $ent['auth-username'] = $_POST['auth-username']; $ent['password'] = $_POST['password']; $ent['realm'] = $_POST['realm']; $ent['from-user'] = $_POST['from-user']; $ent['from-domain'] = $_POST['from-domain']; $ent['proxy'] = $_POST['proxy']; $ent['expire-seconds'] = $_POST['expire-seconds']; $ent['register'] = $_POST['register']; $ent['register-transport'] = $_POST['register-transport']; $ent['retry-seconds'] = $_POST['retry-seconds']; $ent['extension'] = $_POST['extension']; $ent['ping'] = $_POST['ping']; $ent['caller-id-in-from'] = $_POST['caller-id-in-from']; $ent['supress-cng'] = $_POST['supress-cng']; $ent['effective_caller_id_name'] = $_POST['effective_caller_id_name']; $ent['effective_caller_id_number'] = $effective_caller_id_number; $ent['outbound_caller_id_name'] = $_POST['outbound_caller_id_name']; $ent['outbound_caller_id_number'] = $outbound_caller_id_number; $ent['context'] = $_POST['context']; $ent['enabled'] = $_POST['enabled']; $ent['description'] = $_POST['description']; if (isset($id) && $a_gateways[$id]) { //update $a_gateways[$id] = $ent; } else { //add $a_gateways[] = $ent; } if (strlen(trim($_POST['dialplan_expression']))> 0) { $gatewayid = $_POST['gatewayid']; $gateway = $_POST['gateway']; $context = $_POST['context']; $default_area_code = &$config['installedpackages']['freeswitchsettings']['config'][0]['default_area_code']; $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config']; $a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config']; $tmp_array = split("\\\n", $_POST['dialplan_expression']); foreach($tmp_array as $dialplan_expression) { $dialplan_expression = trim($dialplan_expression); if (strlen($dialplan_expression)>0) { switch ($dialplan_expression) { case "^(\d{7})$": $action_data = "sofia/gateway/".$gateway."/1".$default_area_code."\$1"; $label = "7 digits"; $abbrv = "7d"; break; case "^(\d{10})$": $action_data = "sofia/gateway/".$gateway."/1\$1"; $label = "10 digits"; $abbrv = "10d"; break; case "^(\d{11})$": $action_data = "sofia/gateway/".$gateway."/\$1"; $label = "11 digits"; $abbrv = "11d"; break; case "^(311)$": $action_data = "sofia/gateway/".$gateway."/\$1"; $label = "311"; $abbrv = "311"; break; case "^(411)$": $action_data = "sofia/gateway/".$gateway."/\$1"; $label = "411"; $abbrv = "411"; break; case "^(911)$": $action_data = "sofia/gateway/".$gateway."/\$1"; $label = "911"; $abbrv = "911"; break; case "^9(\d{3})$": $action_data = "sofia/gateway/".$gateway."/1".$default_area_code."\$1"; $label = "dial 9, 3 digits"; $abbrv = "9.3d"; break; case "^9(\d{4})$": $action_data = "sofia/gateway/".$gateway."/1".$default_area_code."\$1"; $label = "dial 9, 4 digits"; $abbrv = "9.4d"; break; case "^9(\d{7})$": $action_data = "sofia/gateway/".$gateway."/1".$default_area_code."\$1"; $label = "dial 9, 7 digits"; $abbrv = "9.7d"; break; case "^9(\d{10})$": $action_data = "sofia/gateway/".$gateway."/\$1"; $label = "dial 9, 10 digits"; $abbrv = "9.10d"; break; case "^9(\d{11})$": $action_data = "sofia/gateway/".$gateway."/\$1"; $label = "dial 9, 11 digits"; $abbrv = "9.11d"; break; case "^1?(8(00|55|66|77|88)[2-9]\d{6})$": $action_data = "sofia/gateway/".$gateway."/\$1"; $label = "toll free"; $abbrv = "tollfree"; break; default: $action_data = "sofia/gateway/".$gateway."/\$1"; $label = $dialplan_expression; $abbrv = $dialplan_expression; } $dialplanincludeid = guid(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['extensionname'] = $gateway.".".$abbrv; $ent['order'] = '9002'; //if update use the existing order number and extension name and desc $ent['context'] = $context; $ent['enabled'] = 'true'; $ent['descr'] = $label.' '.$gateway; $ent['opt1name'] = 'gatewayid'; $ent['opt1value'] = $gatewayid; $a_dialplan_includes[] = $ent; unset($ent); $ent = array(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['tag'] = 'condition'; //condition, action, antiaction $ent['fieldtype'] = 'destination_number'; $ent['fielddata'] = $dialplan_expression; $ent['fieldorder'] = '000'; $a_dialplan_include_details[] = $ent; unset($ent); if (strlen($effective_caller_id_name) > 0) { $ent = array(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['tag'] = 'action'; //condition, action, antiaction $ent['fieldtype'] = 'set'; $ent['fielddata'] = 'effective_caller_id_name='.$effective_caller_id_name; $ent['fieldorder'] = '001'; $a_dialplan_include_details[] = $ent; unset($ent); } if (strlen($effective_caller_id_number) > 0) { $ent = array(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['tag'] = 'action'; //condition, action, antiaction $ent['fieldtype'] = 'set'; $ent['fielddata'] = 'effective_caller_id_number='.$effective_caller_id_number; $ent['fieldorder'] = '001'; $a_dialplan_include_details[] = $ent; unset($ent); } if (strlen($outbound_caller_id_name) > 0) { $ent = array(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['tag'] = 'action'; //condition, action, antiaction $ent['fieldtype'] = 'set'; $ent['fielddata'] = 'outbound_caller_id_name='.$outbound_caller_id_name; $ent['fieldorder'] = '001'; $a_dialplan_include_details[] = $ent; unset($ent); } if (strlen($outbound_caller_id_number) > 0) { $ent = array(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['tag'] = 'action'; //condition, action, antiaction $ent['fieldtype'] = 'set'; $ent['fielddata'] = 'outbound_caller_id_number='.$outbound_caller_id_number; $ent['fieldorder'] = '001'; $a_dialplan_include_details[] = $ent; unset($ent); } $ent = array(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['tag'] = 'action'; //condition, action, antiaction $ent['fieldtype'] = 'bridge'; $ent['fielddata'] = $action_data; $ent['fieldorder'] = '001'; $a_dialplan_include_details[] = $ent; unset($ent); unset($label); unset($abbrv); unset($dialplan_expression); unset($action_data); } //if strlen } //end for each } write_config(); sync_package_freeswitch_gateways(); sync_package_freeswitch_dialplan_includes(); header("Location: freeswitch_gateways.php"); exit; } } include("head.inc"); ?>

FreeSWITCH: Gateways: Edit

Gateway Setup
The 'SIP Provider Examples' from the FreeSWITCH wiki can be used as reference to get started.
http://wiki.freeswitch.org/wiki/SIP_Provider_Examples


Gateway
Enter the gateway name here.
Username
Enter the username here.
Password
Enter the password here.
From-user
Enter the from-user here.
From-domain
Enter the from-domain here.
Proxy
Enter the proxy here.
Realm
Enter the realm here.
Expire-seconds
Enter the expire-seconds here. Example: 600
Register \n"; echo " \n"; switch (htmlspecialchars($pconfig['register'])) { case "true": echo " \n"; echo " \n"; break; case "false": echo " \n"; echo " \n"; break; default: echo " \n"; echo " \n"; } echo " \n"; ?> Choose whether to register.
Retry-seconds
Enter the retry_seconds here. Example: 30
Effective Caller ID Name
Enter the effective caller ID name here.
Effective Caller ID Number
Enter the effective caller ID number here.
Outbound Caller ID Name
Enter the outbound caller ID name here.
Outbound Caller ID Number
Enter the outbound caller ID number here.
Context
Enter the context here. Example: public
Show Advanced
Enabled \n"; echo " \n"; switch (htmlspecialchars($pconfig['enabled'])) { case "true": echo " \n"; echo " \n"; break; case "false": echo " \n"; echo " \n"; break; default: echo " \n"; echo " \n"; } echo " \n"; ?>
Dialplan Expression \n"; ?>

Shortcut to create the outbound dialplan entries for this Gateway. The entries are saved to and edited from the 'Dialplan' tab.
Gateway Description
Enter the description of the gateway here.