<?php /* $Id$ */ /* freeswitch_extensions_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_extensions = &$config['installedpackages']['freeswitchextensions']['config']; $id = $_GET['id']; if (isset($_POST['id'])) { $id = $_POST['id']; } if (isset($id) && $a_extensions[$id]) { $pconfig['extension'] = $a_extensions[$id]['extension']; $pconfig['password'] = $a_extensions[$id]['password']; $pconfig['mailbox'] = $a_extensions[$id]['mailbox']; $pconfig['vm-password'] = $a_extensions[$id]['vm-password']; $pconfig['accountcode'] = $a_extensions[$id]['accountcode']; $pconfig['effective_caller_id_name'] = $a_extensions[$id]['effective_caller_id_name']; $pconfig['effective_caller_id_number'] = $a_extensions[$id]['effective_caller_id_number']; $pconfig['effective_caller_id_number'] = $a_extensions[$id]['effective_caller_id_number']; $pconfig['outbound_caller_id_name'] = $a_extensions[$id]['outbound_caller_id_name']; $pconfig['outbound_caller_id_number'] = $a_extensions[$id]['outbound_caller_id_number']; $pconfig['vm-mailto'] = $a_extensions[$id]['vm-mailto']; $pconfig['vm-attach-file'] = $a_extensions[$id]['vm-attach-file']; $pconfig['vm-keep-local-after-email'] = $a_extensions[$id]['vm-keep-local-after-email']; $pconfig['user_context'] = $a_extensions[$id]['user_context']; $pconfig['callgroup'] = $a_extensions[$id]['callgroup']; $pconfig['auth-acl'] = $a_extensions[$id]['auth-acl']; $pconfig['cidr'] = $a_extensions[$id]['cidr']; $pconfig['sip-force-contact'] = $a_extensions[$id]['sip-force-contact']; $pconfig['enabled'] = $a_extensions[$id]['enabled']; $pconfig['description'] = $a_extensions[$id]['description']; } if ($_POST) { unset($input_errors); $pconfig = $_POST; if (!$input_errors) { $effective_caller_id_number = $_POST['effective_caller_id_number']; $outbound_caller_id_number = $_POST['outbound_caller_id_number']; $replace_array = array("(", ")", " ", "-"); $effective_caller_id_number = str_replace($replace_array, "", $effective_caller_id_number); $outbound_caller_id_number = str_replace($replace_array, "", $outbound_caller_id_number); $ent = array(); $ent['extension'] = $_POST['extension']; $ent['password'] = $_POST['password']; $ent['mailbox'] = $_POST['mailbox']; $ent['vm-password'] = $_POST['vm-password']; $ent['accountcode'] = $_POST['accountcode']; $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['vm-mailto'] = $_POST['vm-mailto']; $ent['vm-attach-file'] = $_POST['vm-attach-file']; $ent['vm-keep-local-after-email'] = $_POST['vm-keep-local-after-email']; $ent['user_context'] = $_POST['user_context']; $ent['callgroup'] = $_POST['callgroup']; $ent['auth-acl'] = $_POST['auth-acl']; $ent['cidr'] = $_POST['cidr']; $ent['sip-force-contact'] = $_POST['sip-force-contact']; $ent['enabled'] = $_POST['enabled']; $ent['description'] = $_POST['description']; if (isset($id) && $a_extensions[$id]) { //update $a_extensions[$id] = $ent; } else { //add $a_extensions[] = $ent; } write_config(); sync_package_freeswitch_extensions(); header("Location: freeswitch_extensions.php"); exit; } } include("head.inc"); ?> <script type="text/javascript" language="JavaScript"> 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">FreeSWITCH: Extensions: Edit</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 display_top_tabs(build_menu()); ?> </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>Extension Setup<br> </strong></span> /usr/local/freeswitch/conf/directory/default/ </p></td> </tr> </table> <br /> <form action="freeswitch_extensions_edit.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="6" cellspacing="0"> <tr> <td width="25%" valign="top" class="vncellreq">Extension</td> <td width="75%" class="vtable"> <input name="extension" type="text" class="formfld unknown" id="extension" size="40" value="<?=htmlspecialchars($pconfig['extension']);?>"> <br><span class="vexpl">Enter the extension here. The default configuration 3 or 4 digit extensions.<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq">Password</td> <td width="75%" class="vtable"> <input name="password" type="password" class="formfld pwd" id="password" size="40" value="<?=htmlspecialchars($pconfig['password']);?>"> <br><span class="vexpl">Enter the password here.<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq">Mailbox</td> <td width="75%" class="vtable"> <input name="mailbox" type="text" class="formfld unknown" id="mailbox" size="40" value="<?=htmlspecialchars($pconfig['mailbox']);?>"> <br><span class="vexpl">Enter the mailbox here. Example: extension 1001 then mailbox 1001<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq">Voicemail Password</td> <td width="75%" class="vtable"> <input name="vm-password" type="password" class="formfld pwd" id="vm-password" size="40" value="<?=htmlspecialchars($pconfig['vm-password']);?>"> <br><span class="vexpl">Enter the voicemail password here.<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq">Account Code</td> <td width="75%" class="vtable"> <input name="accountcode" type="text" class="formfld unknown" id="accountcode" size="40" value="<?=htmlspecialchars($pconfig['accountcode']);?>"> <br><span class="vexpl">Enter the account code here. Example: extension 1001 then accountcode 1001<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq" nowrap>Effective Caller ID Name</td> <td width="75%" class="vtable"> <input name="effective_caller_id_name" type="text" class="formfld unknown" id="effective_caller_id_name" size="40" value="<?=htmlspecialchars($pconfig['effective_caller_id_name']);?>"> <br><span class="vexpl">Enter the effective caller id name here.<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq" nowrap>Effective Caller ID Number</td> <td width="75%" class="vtable"> <input name="effective_caller_id_number" type="text" class="formfld unknown" id="effective_caller_id_number" size="40" value="<?=htmlspecialchars($pconfig['effective_caller_id_number']);?>"> <br><span class="vexpl">Enter the effective caller id number here.<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq" nowrap>Voicemail Mail To</td> <td width="75%" class="vtable"> <input name="vm-mailto" type="text" class="formfld unknown" id="vm-mailto" size="40" value="<?=htmlspecialchars($pconfig['vm-mailto']);?>"> <br><span class="vexpl">Optional: Enter the email address to send voicemail to.<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq" nowrap>Voicemail Attach File</td> <td width="75%" class="vtable"> <?php echo " <select name='vm-attach-file' class='formfld unknown'>\n"; echo " <option></option>\n"; switch (htmlspecialchars($pconfig['vm-attach-file'])) { 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 attach the file to the email. </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq" nowrap>VM Keep Local After Email</td> <td width="75%" class="vtable"> <?php echo " <select name='vm-keep-local-after-email' class='formfld unknown'>\n"; echo " <option></option>\n"; switch (htmlspecialchars($pconfig['vm-keep-local-after-email'])) { 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"; ?> Keep local file after sending the email. </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq">User Context</td> <td width="75%" class="vtable"> <input name="user_context" type="text" class="formfld unknown" id="user_context" size="40" value="<?=htmlspecialchars($pconfig['user_context']);?>"> <br><span class="vexpl">Enter the user context here. Example: default<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncellreq">Call Group</td> <td width="75%" class="vtable"> <input name="callgroup" type="text" class="formfld unknown" id="callgroup" size="40" value="<?=htmlspecialchars($pconfig['callgroup']);?>"> <br><span class="vexpl">Enter the user call group here. Example: sales, support<br></span> </td> </tr> </table> <div id="showadvancedbox"> <table width="100%" border="0" cellpadding="6" cellspacing="0"> <tr> <td width="25%" valign="top" class="vncell">Show Advanced</td> <td width="75%" 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="25%" valign="top" class="vncell">Auth-ACL</td> <td width="75%" class="vtable"> <input name="auth-acl" type="text" class="formfld unknown" id="auth-acl" size="40" value="<?=htmlspecialchars($pconfig['auth-acl']);?>"> <br> <span class="vexpl">Enter the auth acl here.<br></span> </td> </tr> <tr> <td valign="top" class="vncell">CIDR</td> <td class="vtable"> <input name="cidr" type="text" class="formfld unknown" id="cidr" size="40" value="<?=htmlspecialchars($pconfig['cidr']);?>"> <br> <span class="vexpl">Enter the cidr here.<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncell" nowrap>Outbound Caller ID Name</td> <td width="75%" class="vtable"> <input name="outbound_caller_id_name" type="text" class="formfld unknown" id="outbound_caller_id_name" size="40" value="<?=htmlspecialchars($pconfig['outbound_caller_id_name']);?>"> <br><span class="vexpl">Enter the outbound caller id name here.<br></span> </td> </tr> <tr> <td width="25%" valign="top" class="vncell" nowrap>Outbound Caller ID Number</td> <td width="75%" class="vtable"> <input name="outbound_caller_id_number" type="text" class="formfld unknown" id="outbound_caller_id_number" size="40" value="<?=htmlspecialchars($pconfig['outbound_caller_id_number']);?>"> <br><span class="vexpl">Enter the outbound caller id number here.<br></span> </td> </tr> <tr> <td width="22%" valign="top" class="vncell">SIP-Force-Contact</td> <td width="78%" class="vtable"> <?php echo " <select name='sip-force-contact' class='formfld'>\n"; echo " <option></option>\n"; switch (htmlspecialchars($pconfig['sip-force-contact'])) { case "NDLB-connectile-dysfunction": echo " <option value='NDLB-connectile-dysfunction' selected='yes'>Rewrite contact IP and port</option>\n"; echo " <option value='NDLB-tls-connectile-dysfunction'>Rewrite contact port</option>\n"; break; case "NDLB-tls-connectile-dysfunction": echo " <option value='NDLB-connectile-dysfunction'>Rewrite contact IP and port</option>\n"; echo " <option value='NDLB-tls-connectile-dysfunction' selected='yes'>Rewrite contact port</option>\n"; default: echo " <option value='NDLB-connectile-dysfunction'>Rewrite contact IP and port</option>\n"; echo " <option value='NDLB-tls-connectile-dysfunction'>Rewrite contact port</option>\n"; } echo " </select>\n"; ?> <br /> Choose sip-force-contact can be used to NDLB-connectile-dysfunction rewrites contact IP and port, <br />and NDLB-tls-connectile-dysfunction rewrites the contact port.<br /> </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="25%" valign="top" class="vncellreq">Extension Description</td> <td width="75%" class="vtable"> <input name="description" type="text" class="formfld unknown" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>"> <br><span class="vexpl">Enter the description of the extension here.<br></span> </td> </tr> <tr> <td valign="top"> </td> <td> <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()"> <?php if (isset($id) && $a_extensions[$id]): ?> <input name="id" type="hidden" value="<?=$id;?>"> <?php endif; ?> </td> </tr> </table> </form> <br> <br> <br> <br> <br> <br> </td> </tr> </table> </div> <?php include("fend.inc"); ?> </body> </html>