diff options
author | Mark Crane <mcrane@pfsense.org> | 2008-12-06 11:02:28 +0000 |
---|---|---|
committer | Mark Crane <mcrane@pfsense.org> | 2008-12-06 11:02:28 +0000 |
commit | 1022bb41bcb1c5e42bd088c93bab4e1d99df3b87 (patch) | |
tree | f4479dc830091175abe8424942a0fac604e0eb80 /packages/freeswitch/freeswitch_gateways_edit.tmp | |
parent | dedba3abe3b07e7447c008e3b4c4aca01c206a31 (diff) | |
download | pfsense-packages-1022bb41bcb1c5e42bd088c93bab4e1d99df3b87.tar.gz pfsense-packages-1022bb41bcb1c5e42bd088c93bab4e1d99df3b87.tar.bz2 pfsense-packages-1022bb41bcb1c5e42bd088c93bab4e1d99df3b87.zip |
Update FreeSWITCH package v0.3 added IVR, Recordings, enhanced GUI for Dialplan, Gateways, Public. Updated FreeSWITCH to revision 10638.
Diffstat (limited to 'packages/freeswitch/freeswitch_gateways_edit.tmp')
-rw-r--r-- | packages/freeswitch/freeswitch_gateways_edit.tmp | 565 |
1 files changed, 565 insertions, 0 deletions
diff --git a/packages/freeswitch/freeswitch_gateways_edit.tmp b/packages/freeswitch/freeswitch_gateways_edit.tmp new file mode 100644 index 00000000..bdd4f2c3 --- /dev/null +++ b/packages/freeswitch/freeswitch_gateways_edit.tmp @@ -0,0 +1,565 @@ +<?php +/* $Id$ */ +/* + + freeswitch_gateways_edit.php + Copyright (C) 2008 Mark J Crane + All rights reserved. + + FreeSWITCH (TM) + http://www.freeswitch.org/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require("guiconfig.inc"); +require("/usr/local/pkg/freeswitch.inc"); + + +$a_gateways = &$config['installedpackages']['freeswitchgateways']['config']; + +$id = $_GET['id']; +if (isset($_POST['id'])) { + $id = $_POST['id']; +} + +if (isset($id) && $a_gateways[$id]) { + + $pconfig['gatewayid'] = $a_gateways[$id]['gatewayid']; + $gatewayid = $a_gateways[$id]['gatewayid']; + $pconfig['gateway'] = $a_gateways[$id]['gateway']; + $pconfig['username'] = $a_gateways[$id]['username']; + $pconfig['password'] = $a_gateways[$id]['password']; + $pconfig['from-user'] = $a_gateways[$id]['from-user']; + $pconfig['from-domain'] = $a_gateways[$id]['from-domain']; + $pconfig['proxy'] = $a_gateways[$id]['proxy']; + $pconfig['expire-seconds'] = $a_gateways[$id]['expire-seconds']; + $pconfig['register'] = $a_gateways[$id]['register']; + $pconfig['register-transport'] = $a_gateways[$id]['register-transport']; + $pconfig['retry-seconds'] = $a_gateways[$id]['retry-seconds']; + $pconfig['extension'] = $a_gateways[$id]['extension']; + $pconfig['context'] = $a_gateways[$id]['context']; + $pconfig['caller-id-in-from'] = $a_gateways[$id]['caller-id-in-from']; + $pconfig['supress-cng'] = $a_gateways[$id]['supress-cng']; + $pconfig['enabled'] = $a_gateways[$id]['enabled']; + $pconfig['description'] = $a_gateways[$id]['description']; +} + +if ($_POST) { + + unset($input_errors); + $pconfig = $_POST; + + + if (!$input_errors) { + + $ent = array(); + if (strlen($_POST['ivrid']) > 0) { + $ent['gatewayid'] = $_POST['ivrid']; + } + else { + $ent['gatewayid'] = guid(); + } + $ent['gateway'] = $_POST['gateway']; + $ent['username'] = $_POST['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['context'] = $_POST['context']; + $ent['caller-id-in-from'] = $_POST['caller-id-in-from']; + $ent['supress-cng'] = $_POST['supress-cng']; + $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 "^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; + $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; + $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(); + + header("Location: freeswitch_gateways.php"); + exit; + } +} + +$pgtitle = "FreeSWITCH: Gateways: Edit"; +include("head.inc"); + +?> + + +<script type="text/javascript" language="JavaScript"> + +function enable_change(enable_over) { + var endis; + endis = !(document.iform.enable.checked || enable_over); + document.iform.range_from.disabled = endis; + document.iform.range_to.disabled = endis; +} + +function show_advanced_config() { + document.getElementById("showadvancedbox").innerHTML=''; + aodiv = document.getElementById('showadvanced'); + aodiv.style.display = "block"; +} + +</script> + + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<p class="pgtitle"><?=$pgtitle?></p> +<?php if ($input_errors) print_input_errors($input_errors); ?> + + +<div id="mainlevel"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabnavtbl"> +<?php + + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&id=0"); + $tab_array[] = array(gettext("Dialplan"), false, "/freeswitch/freeswitch_dialplan_includes.php"); + $tab_array[] = array(gettext("Extensions"), false, "/pkg.php?xml=freeswitch_extensions.xml"); + $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&id=0"); + $tab_array[] = array(gettext("Gateways"), true, "/freeswitch/freeswitch_gateways.php"); + $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&id=0"); + $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php"); + $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&id=0"); + $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php"); + $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_gateways.php"); + $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php"); + $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&id=0"); + display_top_tabs($tab_array); + +?> +</td></tr> +</table> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabcont" > + + + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td><p><span class="vexpl"><span class="red"><strong>Gateway Setup<br> + </strong></span> + The 'SIP Provider Examples' from the FreeSWITCH wiki can be used as reference to get started. <br /> + <a href='http://wiki.freeswitch.org/wiki/SIP_Provider_Examples' target='_blank'>http://wiki.freeswitch.org/wiki/SIP_Provider_Examples</a> + </p></td> + </tr> + </table> + <br /> + + <form action="freeswitch_gateways_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq">Gateway</td> + <td width="78%" class="vtable"> + <input name="gateway" type="text" class="formfld" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>"> + <br><span class="vexpl">Enter the gateway name here.<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Username</td> + <td width="78%" class="vtable"> + <input name="username" type="text" class="formfld" id="username" size="40" value="<?=htmlspecialchars($pconfig['username']);?>"> + <br><span class="vexpl">Enter the username here.<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Password</td> + <td width="78%" class="vtable"> + <input name="password" type="text" class="formfld" id="password" size="40" value="<?=htmlspecialchars($pconfig['password']);?>"> + <br><span class="vexpl">Enter the password here.<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">From-user</td> + <td width="78%" class="vtable"> + <input name="from-user" type="text" class="formfld" id="from-user" size="40" value="<?=htmlspecialchars($pconfig['from-user']);?>"> + <br><span class="vexpl">Enter the from-user here.<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">From-domain</td> + <td width="78%" class="vtable"> + <input name="from-domain" type="text" class="formfld" id="from-domain" size="40" value="<?=htmlspecialchars($pconfig['from-domain']);?>"> + <br><span class="vexpl">Enter the from-domain here.<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Proxy</td> + <td width="78%" class="vtable"> + <input name="proxy" type="text" class="formfld" id="proxy" size="40" value="<?=htmlspecialchars($pconfig['proxy']);?>"> + <br><span class="vexpl">Enter the proxy here.<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Realm</td> + <td width="78%" class="vtable"> + <input name="realm" type="text" class="formfld" id="realm" size="40" value="<?=htmlspecialchars($pconfig['realm']);?>"> + <br><span class="vexpl">Enter the realm here.<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Expire-seconds</td> + <td width="78%" class="vtable"> + <input name="expire-seconds" type="text" class="formfld" id="expire-seconds" size="40" value="<?=htmlspecialchars($pconfig['expire-seconds']);?>"> + <br><span class="vexpl">Enter the expire-seconds here. Example: 600<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Register</td> + <td width="78%" class="vtable"> + <?php + echo " <select name='register' class='formfld'>\n"; + echo " <option></option>\n"; + switch (htmlspecialchars($pconfig['register'])) { + case "true": + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + break; + case "false": + echo " <option value='true'>true</option>\n"; + echo " <option value='false' selected='yes'>false</option>\n"; + + break; + default: + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + } + echo " </select>\n"; + ?> + Choose whether to register. + </td> + </tr> + + <tr> + <td width="22%" valign="top" class="vncellreq">Retry-seconds</td> + <td width="78%" class="vtable"> + <input name="retry-seconds" type="text" class="formfld" id="retry-seconds" size="40" value="<?=htmlspecialchars($pconfig['retry-seconds']);?>"> + <br> <span class="vexpl">Enter the retry_seconds here. Example: 30<br></span> + </td> + </tr> + + <tr> + <td width="22%" valign="top" class="vncellreq">Context</td> + <td width="78%" class="vtable"> + <input name="context" type="text" class="formfld" id="context" size="40" value="<?=htmlspecialchars($pconfig['context']);?>"> + <br> <span class="vexpl">Enter the context here. Example: public<br></span> + </td> + </tr> + </table> + <div id="showadvancedbox"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncell">Show Advanced</td> + <td width="78%" class="vtable"> + <input type="button" onClick="show_advanced_config()" value="Advanced"></input></a> + </td> + </tr> + </table> + </div> + <div id="showadvanced" style="display:none"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncell">Register-transport</td> + <td width="78%" class="vtable"> + <?php + echo " <select name='register-transport' class='formfld'>\n"; + echo " <option></option>\n"; + switch (htmlspecialchars($pconfig['register-transport'])) { + case "udp": + echo " <option value='udp' selected='yes'>udp</option>\n"; + echo " <option value='tcp'>tcp</option>\n"; + break; + case "tcp": + echo " <option value='udp'>udp</option>\n"; + echo " <option value='tcp' selected='yes'>tcp</option>\n"; + + break; + default: + echo " <option value='udp'>udp</option>\n"; + echo " <option value='tcp'>tcp</option>\n"; + } + echo " </select>\n"; + ?> + Choose whether to register-transport. + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Extension</td> + <td width="78%" class="vtable"> + <input name="extension" type="text" class="formfld" id="extension" size="40" value="<?=htmlspecialchars($pconfig['extension']);?>"> + <br> <span class="vexpl">Enter the extension here.<br></span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Caller-id-in-from</td> + <td width="78%" class="vtable"> + <?php + echo " <select name='caller-id-in-from' class='formfld'>\n"; + echo " <option></option>\n"; + switch (htmlspecialchars($pconfig['caller-id-in-from'])) { + case "true": + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + break; + case "false": + echo " <option value='true'>true</option>\n"; + echo " <option value='false' selected='yes'>false</option>\n"; + + break; + default: + echo " <option value='true'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + } + echo " </select>\n"; + ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Supress-cng</td> + <td width="78%" class="vtable"> + <?php + echo " <select name='supress-cng' class='formfld'>\n"; + echo " <option></option>\n"; + switch (htmlspecialchars($pconfig['supress-cng'])) { + case "true": + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + break; + case "false": + echo " <option value='true'>true</option>\n"; + echo " <option value='false' selected='yes'>false</option>\n"; + + break; + default: + echo " <option value='true'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + } + echo " </select>\n"; + ?> + </td> + </tr> + </table> + + </div> + + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq">Enabled</td> + <td width="78%" class="vtable"> + <?php + echo " <select name='enabled' class='formfld'>\n"; + echo " <option></option>\n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + break; + case "false": + echo " <option value='true'>true</option>\n"; + echo " <option value='false' selected='yes'>false</option>\n"; + + break; + default: + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + } + echo " </select>\n"; + ?> + </td> + </tr> + + <tr> + <td width="22%" valign="top" class="vncell">Dialplan Expression</td> + <td width="78%" class="vtable"> + <?php + echo "<textarea name=\"dialplan_expression\" id=\"dialplan_expression\" cols=\"30\" rows=\"4\" wrap=\"off\"></textarea>\n"; + ?> + <br> + <select name='dialplan_expression_select' id='dialplan_expression_select' onchange="document.getElementById('dialplan_expression').value += document.getElementById('dialplan_expression_select').value + '\n';" class='formfld'> + <option></option> + <option value='^(\d{7})$'>7 digits local</option> + <option value='^(\d{10})$'>10 digits long distance</option> + <option value='^(\d{11})$'>11 digits long distance</option> + <option value='^311$'>311 information</option> + <option value='^411$'>411 information</option> + <option value='^911$'>911 emergency</option> + <option value='^1?(8(00|55|66|77|88)[2-9]\d{6})$'>toll free</option> + + </select> + <span class="vexpl"> + <br /> + Shortcut to create the outbound dialplan entries for this Gateway. The entries are saved to and edited from the 'Dialplan' tab. + </span></td> + </tr> + + <tr> + <td width="22%" valign="top" class="vncell">Gateway Description</td> + <td width="78%" class="vtable"> + <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>"> + <br> <span class="vexpl">Enter the description of the gateway here.</span></td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()"> + <?php if (isset($id) && $a_gateways[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>"> + <input name="gatewayid" type="hidden" value="<?=htmlspecialchars($pconfig['gatewayid']);?>"> + <?php endif; ?> + </td> + </tr> + </table> + </form> + + <br> + <br> + <br> + <br> + <br> + <br> + + </td> + </tr> +</table> + +</div> + +<?php include("fend.inc"); ?> +</body> +</html> |