fusionpbx/app/gateways/gateway_edit.php

955 lines
35 KiB
PHP
Raw Permalink Normal View History

<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
2023-05-14 04:43:39 +02:00
Portions created by the Initial Developer are Copyright (C) 2008-2023
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
2016-10-02 20:54:30 +02:00
2022-10-11 00:35:14 +02:00
//includes files
Use magic constant dir (#6711) * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ to load only functions.php * replace spaces with tab character * update dirname command to use levels instead of nesting * use magic constant __DIR__ * update dirname command to use levels instead of nesting * Update access_control_edit.php * Update access_control_import.php * Update access_controls.php * Update dnd.php * Update access_controls_reload.php * Update call_center_agents.php * Update call_center_agents.php * Update fax_queue.php * Update login.php * Update pdo.php * Update pdo_vm.php * Update switch.php * Update index.php * Update css.php * Update v_mailto.php * Update fax_to_email.php --------- Co-authored-by: FusionPBX <markjcrane@gmail.com>
2023-06-15 19:28:23 +02:00
require_once dirname(__DIR__, 2) . "/resources/require.php";
2016-10-02 20:54:30 +02:00
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('gateway_add') || permission_exists('gateway_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
2012-12-23 09:18:15 +01:00
//add multi-lingual support
$language = new text;
$text = $language->get();
2012-12-23 09:18:15 +01:00
//action add or update
2023-05-14 04:43:39 +02:00
if (!empty($_REQUEST["id"])) {
$action = "update";
2023-05-14 04:43:39 +02:00
if (!empty($_POST["id"]) && is_uuid($_POST["id"])) {
2019-08-09 04:11:33 +02:00
$gateway_uuid = $_REQUEST["id"];
2016-10-02 20:54:30 +02:00
}
2023-05-14 04:43:39 +02:00
if (!empty($_POST["gateway_uuid"]) && is_uuid($_POST["gateway_uuid"])) {
2019-08-09 04:11:33 +02:00
$gateway_uuid = $_POST["gateway_uuid"];
2016-10-02 20:54:30 +02:00
}
}
else {
$action = "add";
2016-10-02 20:54:30 +02:00
$gateway_uuid = uuid();
}
//get total gateway count from the database, check limit, if defined
if ($action == 'add') {
2023-05-14 04:43:39 +02:00
if (!empty($_SESSION['limit']['gateways']['numeric'])) {
2019-08-09 04:11:33 +02:00
$sql = "select count(gateway_uuid) from v_gateways ";
$sql .= "where (domain_uuid = :domain_uuid ".(permission_exists('gateway_domain') ? " or domain_uuid is null " : null).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$total_gateways = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
if ($total_gateways >= $_SESSION['limit']['gateways']['numeric']) {
2018-08-31 05:09:01 +02:00
message::add($text['message-maximum_gateways'].' '.$_SESSION['limit']['gateways']['numeric'], 'negative');
header('Location: gateways.php');
2019-08-09 04:11:33 +02:00
exit;
}
}
}
2012-12-23 09:18:15 +01:00
//get http post variables and set them to php variables
2023-05-14 04:43:39 +02:00
if (!empty($_POST)) {
2019-08-09 04:11:33 +02:00
$domain_uuid = $_POST["domain_uuid"];
$gateway = $_POST["gateway"];
$username = $_POST["username"];
$password = $_POST["password"];
$distinct_to = $_POST["distinct_to"];
$auth_username = $_POST["auth_username"];
$realm = $_POST["realm"];
$from_user = $_POST["from_user"];
$from_domain = $_POST["from_domain"];
$proxy = $_POST["proxy"];
$register_proxy = $_POST["register_proxy"];
$outbound_proxy = $_POST["outbound_proxy"];
$expire_seconds = $_POST["expire_seconds"];
$register = $_POST["register"];
$register_transport = $_POST["register_transport"];
$contact_params = $_POST["contact_params"];
2019-08-09 04:11:33 +02:00
$retry_seconds = $_POST["retry_seconds"];
$extension = $_POST["extension"];
$ping = $_POST["ping"];
2020-11-11 07:15:46 +01:00
$ping_min = $_POST["ping_min"];
$ping_max = $_POST["ping_max"];
$contact_in_ping = $_POST["contact_in_ping"];
2019-08-09 04:11:33 +02:00
$channels = $_POST["channels"];
$caller_id_in_from = $_POST["caller_id_in_from"];
$supress_cng = $_POST["supress_cng"];
$sip_cid_type = $_POST["sip_cid_type"];
$codec_prefs = $_POST["codec_prefs"];
$extension_in_contact = $_POST["extension_in_contact"];
$context = $_POST["context"];
$profile = $_POST["profile"];
$hostname = $_POST["hostname"];
2023-06-07 00:05:05 +02:00
$enabled = $_POST["enabled"] ?? 'false';
2019-08-09 04:11:33 +02:00
$description = $_POST["description"];
}
//prevent the domain_uuid from not being set by someone without this permission
if (!permission_exists('gateway_domain')) {
$domain_uuid = $_SESSION['domain_uuid'];
}
2016-10-02 20:54:30 +02:00
//process the HTTP POST
if (!empty($_POST) && empty($_POST["persistformvar"])) {
2019-09-19 14:37:37 +02:00
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: gateways.php');
exit;
}
2016-10-02 20:54:30 +02:00
//check for all required data
$msg = '';
if (empty($gateway)) { $msg .= $text['message-required']." ".$text['label-gateway']."<br>\n"; }
2016-10-02 20:54:30 +02:00
if ($register == "true") {
if (empty($username)) { $msg .= $text['message-required']." ".$text['label-username']."<br>\n"; }
if (empty($password)) { $msg .= $text['message-required']." ".$text['label-password']."<br>\n"; }
2016-10-02 20:54:30 +02:00
}
if (empty($proxy)) { $msg .= $text['message-required']." ".$text['label-proxy']."<br>\n"; }
if (empty($expire_seconds)) { $msg .= $text['message-required']." ".$text['label-expire_seconds']."<br>\n"; }
if (empty($register)) { $msg .= $text['message-required']." ".$text['label-register']."<br>\n"; }
if (empty($retry_seconds)) { $msg .= $text['message-required']." ".$text['label-retry_seconds']."<br>\n"; }
if (empty($channels)) {
2016-10-02 20:54:30 +02:00
//$msg .= $text['message-required']." ".$text['label-channels']."<br>\n";
$channels = 0;
}
if (empty($context)) { $msg .= $text['message-required']." ".$text['label-context']."<br>\n"; }
if (empty($profile)) { $msg .= $text['message-required']." ".$text['label-profile']."<br>\n"; }
if (empty($enabled)) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
2016-10-02 20:54:30 +02:00
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
2018-04-25 00:30:52 +02:00
2016-10-02 20:54:30 +02:00
//add or update the database
2023-05-17 23:01:43 +02:00
if (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true") {
2016-10-02 20:54:30 +02:00
//build the gateway array
$x = 0;
2019-08-09 04:11:33 +02:00
$array['gateways'][$x]["domain_uuid"] = is_uuid($domain_uuid) ? $domain_uuid : null;
2016-10-02 20:54:30 +02:00
$array['gateways'][$x]["gateway_uuid"] = $gateway_uuid;
$array['gateways'][$x]["gateway"] = $gateway;
$array['gateways'][$x]["username"] = $username;
$array['gateways'][$x]["password"] = $password;
$array['gateways'][$x]["distinct_to"] = $distinct_to;
$array['gateways'][$x]["auth_username"] = $auth_username;
$array['gateways'][$x]["realm"] = $realm;
$array['gateways'][$x]["from_user"] = $from_user;
$array['gateways'][$x]["from_domain"] = $from_domain;
$array['gateways'][$x]["proxy"] = $proxy;
$array['gateways'][$x]["register_proxy"] = $register_proxy;
$array['gateways'][$x]["outbound_proxy"] = $outbound_proxy;
$array['gateways'][$x]["expire_seconds"] = $expire_seconds;
$array['gateways'][$x]["register"] = $register;
$array['gateways'][$x]["register_transport"] = $register_transport;
$array['gateways'][$x]["contact_params"] = $contact_params;
2016-10-02 20:54:30 +02:00
$array['gateways'][$x]["retry_seconds"] = $retry_seconds;
$array['gateways'][$x]["extension"] = $extension;
$array['gateways'][$x]["ping"] = $ping;
2020-11-11 07:15:46 +01:00
$array['gateways'][$x]["ping_min"] = $ping_min;
$array['gateways'][$x]["ping_max"] = $ping_max;
$array['gateways'][$x]["contact_in_ping"] = $contact_in_ping;
2016-10-02 20:54:30 +02:00
$array['gateways'][$x]["channels"] = $channels;
$array['gateways'][$x]["caller_id_in_from"] = $caller_id_in_from;
$array['gateways'][$x]["supress_cng"] = $supress_cng;
$array['gateways'][$x]["sip_cid_type"] = $sip_cid_type;
$array['gateways'][$x]["codec_prefs"] = $codec_prefs;
$array['gateways'][$x]["extension_in_contact"] = $extension_in_contact;
$array['gateways'][$x]["context"] = $context;
$array['gateways'][$x]["profile"] = $profile;
$array['gateways'][$x]["hostname"] = empty($hostname) ? null : $hostname;
2016-10-02 20:54:30 +02:00
$array['gateways'][$x]["enabled"] = $enabled;
$array['gateways'][$x]["description"] = $description;
//update gateway session variable
if ($enabled == 'true') {
$_SESSION['gateways'][$gateway_uuid] = $gateway;
}
else {
unset($_SESSION['gateways'][$gateway_uuid]);
}
2016-10-02 20:54:30 +02:00
//save to the data
2016-10-18 17:35:13 +02:00
$database = new database;
$database->app_name = 'gateways';
$database->app_uuid = '297ab33e-2c2f-8196-552c-f3567d2caaf8';
2019-08-09 04:11:33 +02:00
if (is_uuid($gateway_uuid)) {
2016-10-18 17:35:13 +02:00
$database->uuid($gateway_uuid);
}
2016-10-18 17:35:13 +02:00
$database->save($array);
$message = $database->message;
2016-10-02 20:54:30 +02:00
//remove xml file (if any) if not enabled
2023-05-14 04:43:39 +02:00
if ($enabled != 'true' && !empty($_SESSION['switch']['sip_profiles']['dir'])) {
2016-10-02 20:54:30 +02:00
$gateway_xml_file = $_SESSION['switch']['sip_profiles']['dir']."/".$profile."/v_".$gateway_uuid.".xml";
if (file_exists($gateway_xml_file)) {
unlink($gateway_xml_file);
}
}
2019-02-05 18:46:03 +01:00
2016-10-02 20:54:30 +02:00
//syncrhonize configuration
save_gateway_xml();
2019-02-05 18:46:03 +01:00
2018-07-24 23:21:32 +02:00
//clear the cache
$esl = event_socket::create();
$hostname = trim(event_socket::api('switchname'));
2018-07-24 23:21:32 +02:00
$cache = new cache;
2018-07-24 23:36:45 +02:00
$cache->delete("configuration:sofia.conf:".$hostname);
2019-02-05 18:46:03 +01:00
2016-10-02 20:54:30 +02:00
//rescan the external profile to look for new or stopped gateways
//create the event socket connection
$esl = event_socket::create();
$response = event_socket::api('sofia profile external rescan');
2016-10-02 20:54:30 +02:00
usleep(1000);
//clear the apply settings reminder
$_SESSION["reload_xml"] = false;
2019-08-09 04:11:33 +02:00
}
2019-02-05 18:46:03 +01:00
2016-10-02 20:54:30 +02:00
//redirect the user
if (isset($action)) {
if ($action == "add") {
2018-08-31 05:09:01 +02:00
message::add($text['message-add']);
2016-10-02 20:54:30 +02:00
}
if ($action == "update") {
2018-08-31 05:09:01 +02:00
message::add($text['message-update']);
2016-10-02 20:54:30 +02:00
}
header("Location: gateways.php");
2019-08-09 04:11:33 +02:00
exit;
}
2019-08-09 04:11:33 +02:00
}
//pre-populate the form
2023-05-14 04:52:18 +02:00
if (!empty($_GET) && !empty($_GET["id"]) && is_uuid($_GET["id"]) && empty($_POST["persistformvar"])) {
2019-08-09 04:11:33 +02:00
$gateway_uuid = $_GET["id"];
$sql = "select * from v_gateways ";
2019-08-09 04:11:33 +02:00
$sql .= "where gateway_uuid = :gateway_uuid ";
$parameters['gateway_uuid'] = $gateway_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
2023-05-14 04:43:39 +02:00
if (!empty($row)) {
$domain_uuid = $row["domain_uuid"];
$gateway = $row["gateway"];
$username = $row["username"];
$password = $row["password"];
$distinct_to = $row["distinct_to"];
$auth_username = $row["auth_username"];
$realm = $row["realm"];
$from_user = $row["from_user"];
$from_domain = $row["from_domain"];
$proxy = $row["proxy"];
$register_proxy = $row["register_proxy"];
$outbound_proxy = $row["outbound_proxy"];
$expire_seconds = $row["expire_seconds"];
$register = $row["register"];
$register_transport = $row["register_transport"];
$contact_params = $row["contact_params"];
$retry_seconds = $row["retry_seconds"];
$extension = $row["extension"];
$ping = $row["ping"];
2020-11-11 07:15:46 +01:00
$ping_min = $row["ping_min"];
$ping_max = $row["ping_max"];
$contact_in_ping = $row["contact_in_ping"];
2013-09-25 22:14:33 +02:00
$channels = $row["channels"];
$caller_id_in_from = $row["caller_id_in_from"];
$supress_cng = $row["supress_cng"];
$sip_cid_type = $row["sip_cid_type"];
$codec_prefs = $row["codec_prefs"];
$extension_in_contact = $row["extension_in_contact"];
$context = $row["context"];
$profile = $row["profile"];
$hostname = $row["hostname"];
$enabled = $row["enabled"];
$description = $row["description"];
}
2019-08-09 04:11:33 +02:00
unset($sql, $parameters, $row);
}
//get the sip profiles
$sql = "select sip_profile_name from v_sip_profiles ";
$sql .= "where sip_profile_enabled = 'true' ";
$sql .= "order by sip_profile_name asc ";
2019-08-09 04:11:33 +02:00
$database = new database;
$sip_profiles = $database->select($sql, null, 'all');
unset($sql);
//set defaults
2023-05-14 04:50:06 +02:00
if (empty($gateway_uuid)) { $gateway_uuid = ""; }
if (empty($enabled)) { $enabled = "true"; }
if (empty($register)) { $register = "true"; }
if (empty($retry_seconds)) { $retry_seconds = "30"; }
2023-05-14 04:43:39 +02:00
if (empty($gateway)) { $gateway = ''; }
if (empty($username)) { $username = ''; }
if (empty($password)) { $password = ''; }
if (empty($distinct_to)) { $distinct_to = ''; }
if (empty($auth_username)) { $auth_username = ''; }
if (empty($realm)) { $realm = ''; }
if (empty($from_user)) { $from_user = ''; }
if (empty($from_domain)) { $from_domain = ''; }
if (empty($proxy)) { $proxy = ''; }
if (empty($register_proxy)) { $register_proxy = ''; }
if (empty($outbound_proxy)) { $outbound_proxy = ''; }
if (empty($expire_seconds)) { $expire_seconds = ''; }
if (empty($register)) { $register = ''; }
if (empty($register_transport)) { $register_transport = ''; }
if (empty($contact_params)) { $contact_params = ''; }
if (empty($retry_seconds)) { $retry_seconds = ''; }
if (empty($extension)) { $extension = ''; }
if (empty($ping)) { $ping = ''; }
if (empty($ping_min)) { $ping_min = ''; }
if (empty($ping_max)) { $ping_max = ''; }
if (empty($contact_in_ping)) { $contact_in_ping = ''; }
if (empty($channels)) { $channels = ''; }
if (empty($caller_id_in_from)) { $caller_id_in_from = ''; }
if (empty($supress_cng)) { $supress_cng = ''; }
if (empty($sip_cid_type)) { $sip_cid_type = ''; }
if (empty($codec_prefs)) { $codec_prefs = ''; }
if (empty($extension_in_contact)) { $extension_in_contact = ''; }
if (empty($context)) { $context = ''; }
if (empty($profile)) { $profile = ''; }
if (empty($hostname)) { $hostname = ''; }
if (empty($enabled)) { $enabled = 'true'; }
if (empty($description)) { $description = ''; }
2019-09-19 14:37:37 +02:00
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
2020-01-06 15:49:16 +01:00
$document['title'] = $text['title-gateway'];
require_once "resources/header.php";
//show the content
echo "<script type=\"text/javascript\" language=\"JavaScript\">\n";
echo "\n";
echo "function enable_change(enable_over) {\n";
echo " var endis;\n";
echo " endis = !(document.iform.enable.checked || enable_over);\n";
echo " document.iform.range_from.disabled = endis;\n";
echo " document.iform.range_to.disabled = endis;\n";
echo "}\n";
echo "\n";
echo "function show_advanced_config() {\n";
echo " $('#show_advanced_box').slideToggle();\n";
echo " $('#show_advanced').slideToggle();\n";
echo "}\n";
echo "</script>";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-gateway']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'gateways.php']);
if ($action == "update" && permission_exists('gateway_add')) {
2020-03-26 16:50:34 +01:00
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>'margin-left: 15px;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;','onclick'=>'submit_form();']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
2020-03-26 16:50:34 +01:00
if ($action == "update" && permission_exists('gateway_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','link'=>'gateway_copy.php?id='.urlencode($gateway_uuid),'onclick'=>"modal_close();"])]);
}
echo $text['description-gateway-edit']."\n";
echo "<br /><br />\n";
echo "<form name='frm' id='frm' method='post'>\n";
2024-09-06 07:37:34 +02:00
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width=\"30%\" class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-gateway']."\n";
echo "</td>\n";
echo "<td width=\"70%\" class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='gateway' maxlength='255' value=\"".escape($gateway)."\" required='required'>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-gateway-name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-username']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='username' maxlength='255' autocomplete='off' value=\"".escape($username)."\">\n";
echo " <input type='text' style='display: none;' disabled='disabled'>\n"; //help defeat browser auto-fill
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-username']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-password']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input type='password' style='display: none;' disabled='disabled'>\n"; //help defeat browser auto-fill
echo " <input class='formfld password' type='password' name='password' id='password' autocomplete='new-password' maxlength='255' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" value=\"".escape($password)."\">\n";
2014-03-07 03:59:20 +01:00
echo " <br />\n";
echo " ".$text['description-password']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-from_user']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='from_user' maxlength='255' value=\"".escape($from_user)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-from_user']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-from_domain']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='from_domain' maxlength='255' value=\"".escape($from_domain)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-from_domain']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-proxy']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='proxy' maxlength='255' value=\"".escape($proxy)."\" required='required'>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-proxy']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-realm']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='realm' maxlength='255' value=\"".escape($realm)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-realm']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-expire_seconds']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (empty($expire_seconds)) { $expire_seconds = "800"; }
echo " <input class='formfld' type='number' name='expire_seconds' maxlength='255' value='".escape($expire_seconds)."' min='1' max='65535' step='1' required='required'>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-expire_seconds']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-register']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='register'>\n";
if ($register == "true") {
2012-12-23 09:18:15 +01:00
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='true'>".$text['label-true']."</option>\n";
}
2014-02-23 08:15:37 +01:00
if ($register == "false") {
2012-12-23 09:18:15 +01:00
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-register']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-retry_seconds']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='retry_seconds' maxlength='255' value='".escape($retry_seconds)."' min='1' max='65535' step='1' required='required'>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-retry_seconds']."\n";
echo "</td>\n";
echo "</tr>\n";
//--- begin: show_advanced -----------------------
echo "<tr>\n";
echo "<td style='padding: 0px;' colspan='2' class='' valign='top' align='left' nowrap>\n";
echo " <div id=\"show_advanced_box\">\n";
2015-02-15 08:59:02 +01:00
echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td width=\"30%\" valign=\"top\" class=\"vncell\">&nbsp;</td>\n";
echo " <td width=\"70%\" class=\"vtable\">\n";
echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','onclick'=>'show_advanced_config();']);
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " </div>\n";
echo " <div id=\"show_advanced\" style=\"display:none\">\n";
2015-02-15 08:59:02 +01:00
echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-distinct_to']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' name='distinct_to'>\n";
echo " <option value=''></option>\n";
2014-02-23 08:15:37 +01:00
if ($distinct_to == "true") {
2012-12-23 09:18:15 +01:00
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='true'>".$text['label-true']."</option>\n";
}
2014-02-23 08:15:37 +01:00
if ($distinct_to == "false") {
2012-12-23 09:18:15 +01:00
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-distinct_to']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-auth_username']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='auth_username' maxlength='255' value=\"".escape($auth_username)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-auth_username']."\n";
echo "</td>\n";
echo "</tr>\n";
2012-12-23 09:18:15 +01:00
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-extension']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='extension' maxlength='255' value=\"".escape($extension)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-extension']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-register_transport']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='register_transport'>\n";
echo " <option value=''></option>\n";
2014-02-23 08:15:37 +01:00
if ($register_transport == "udp") {
echo " <option value='udp' selected='selected'>udp</option>\n";
}
else {
echo " <option value='udp'>udp</option>\n";
}
2014-02-23 08:15:37 +01:00
if ($register_transport == "tcp") {
echo " <option value='tcp' selected='selected'>tcp</option>\n";
}
else {
echo " <option value='tcp'>tcp</option>\n";
}
2014-02-23 08:15:37 +01:00
if ($register_transport == "tls") {
echo " <option value='tls' selected='selected'>tls</option>\n";
}
else {
echo " <option value='tls'>tls</option>\n";
}
echo " </select>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-register_transport']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-contact_params']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='contact_params' maxlength='255' value=\"".escape($contact_params)."\">\n";
echo "<br />\n";
echo $text['description-contact_params']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-register_proxy']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='register_proxy' maxlength='255' value=\"".escape($register_proxy)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-register_proxy']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-outbound_proxy']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='outbound_proxy' maxlength='255' value=\"".escape($outbound_proxy)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-outbound_proxy']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-caller_id_in_from']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <select class='formfld' name='caller_id_in_from'>\n";
echo " <option value=''></option>\n";
2014-02-23 08:15:37 +01:00
if ($caller_id_in_from == "true") {
2012-12-23 09:18:15 +01:00
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='true'>".$text['label-true']."</option>\n";
}
2014-02-23 08:15:37 +01:00
if ($caller_id_in_from == "false") {
2012-12-23 09:18:15 +01:00
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-caller_id_in_from']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
2012-12-23 09:18:15 +01:00
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-supress_cng']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='supress_cng'>\n";
echo " <option value=''></option>\n";
2014-02-23 08:15:37 +01:00
if ($supress_cng == "true") {
2012-12-23 09:18:15 +01:00
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='true'>".$text['label-true']."</option>\n";
}
2014-02-23 08:15:37 +01:00
if ($supress_cng == "false") {
2012-12-23 09:18:15 +01:00
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-supress_cng']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-sip_cid_type']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='sip_cid_type' maxlength='255' value=\"".escape($sip_cid_type)."\" pattern='^(none|pid|rpid)$'>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-sip_cid_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-codec_prefs']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='codec_prefs' maxlength='255' value=\"".escape($codec_prefs)."\">\n";
echo "<br />\n";
echo $text['description-codec_prefs']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-extension_in_contact']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='extension_in_contact'>\n";
echo " <option value=''></option>\n";
2014-02-23 08:15:37 +01:00
if ($extension_in_contact == "true") {
2012-12-23 09:18:15 +01:00
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='true'>".$text['label-true']."</option>\n";
}
2014-02-23 08:15:37 +01:00
if ($extension_in_contact == "false") {
2012-12-23 09:18:15 +01:00
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
2012-12-23 09:18:15 +01:00
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-extension_in_contact']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-ping']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='ping' maxlength='255' min='1' max='65535' step='1' value=\"".escape($ping)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-ping']."\n";
echo "</td>\n";
echo "</tr>\n";
2020-11-11 07:15:46 +01:00
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-ping_min']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='ping_min' maxlength='255' min='1' max='65535' step='1' value=\"".escape($ping_min)."\">\n";
echo "<br />\n";
echo $text['description-ping_min']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-ping_max']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='ping_max' maxlength='255' min='1' max='65535' step='1' value=\"".escape($ping_max)."\">\n";
echo "<br />\n";
echo $text['description-ping_max']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-contact_in_ping']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='contact_in_ping'>\n";
echo " <option value=''></option>\n";
if ($contact_in_ping == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($contact_in_ping == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-contact_in_ping']."\n";
echo "</td>\n";
echo "</tr>\n";
if (permission_exists('gateway_channels')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-channels']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='channels' maxlength='255' value=\"".escape($channels)."\" min='0' max='65535' step='1'>\n";
echo "<br />\n";
echo $text['description-channels']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-hostname']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='hostname' maxlength='255' value=\"".escape($hostname)."\">\n";
echo "<br />\n";
echo $text['description-hostname']."\n";
echo "</td>\n";
echo "</tr>\n";
if (permission_exists('gateway_domain')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-domain']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='domain_uuid'>\n";
if (empty($domain_uuid)) {
echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
}
else {
echo " <option value=''>".$text['select-global']."</option>\n";
}
foreach ($_SESSION['domains'] as $row) {
if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
}
else {
echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n";
}
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-domain_name']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo " </table>\n";
echo " </div>";
echo "</td>\n";
echo "</tr>\n";
//--- end: show_advanced -----------------------
echo "<tr>\n";
2012-12-23 09:18:15 +01:00
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-context']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (empty($context)) { $context = "public"; }
echo " <input class='formfld' type='text' name='context' maxlength='255' value=\"".escape($context)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-context']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-profile']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='profile' required='required'>\n";
foreach ($sip_profiles as $row) {
$sip_profile_name = $row["sip_profile_name"];
if ($profile == $sip_profile_name) {
echo " <option value='$sip_profile_name' selected='selected'>".escape($sip_profile_name)."</option>\n";
}
else {
echo " <option value='".escape($sip_profile_name)."'>".escape($sip_profile_name)."</option>\n";
}
}
echo " </select>\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-profile']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
2012-12-23 09:18:15 +01:00
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='enabled' name='enabled' value='true' ".($enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
else {
echo " <select class='formfld' id='enabled' name='enabled'>\n";
echo " <option value='true' ".($enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
}
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
2012-12-23 09:18:15 +01:00
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='description' maxlength='255' value=\"".escape($description)."\">\n";
echo "<br />\n";
2012-12-23 09:18:15 +01:00
echo $text['description-description']."\n";
echo "</td>\n";
echo "</tr>\n";
2012-12-23 09:18:15 +01:00
echo "</table>";
2024-09-06 07:37:34 +02:00
echo "</div>\n";
if ($action == "update") {
echo "<input type='hidden' name='gateway_uuid' value='".escape($gateway_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
2024-09-06 07:37:34 +02:00
echo "<br><br>";
//hide password fields before submit
echo "<script>\n";
echo " function submit_form() {\n";
echo " hide_password_fields();\n";
echo " $('form#frm').submit();\n";
echo " }\n";
echo "</script>\n";
2012-12-23 09:18:15 +01:00
//include the footer
require_once "resources/footer.php";
2014-03-22 02:15:24 +01:00
?>