Update gateway_copy.php

This commit is contained in:
FusionPBX
2018-06-14 01:37:44 -06:00
committed by GitHub
parent f432d4dccb
commit adb442039f
+35 -20
View File
@@ -17,23 +17,27 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012 Portions created by the Initial Developer are Copyright (C) 2008-2018
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
include "root.php";
require_once "resources/require.php"; //includes
require_once "resources/check_auth.php"; include "root.php";
require_once "resources/paging.php"; require_once "resources/require.php";
if (permission_exists('gateway_add')) { require_once "resources/check_auth.php";
//access granted require_once "resources/paging.php";
}
else { //check permissions
echo "access denied"; if (permission_exists('gateway_add')) {
exit; //access granted
} }
else {
echo "access denied";
exit;
}
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
@@ -46,12 +50,11 @@ else {
//get the data //get the data
$sql = "select * from v_gateways "; $sql = "select * from v_gateways ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where gateway_uuid = '$gateway_uuid' ";
$sql .= "and gateway_uuid = '$gateway_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) { foreach ($gateways as &$row) {
$gateway = $row["gateway"]; $gateway = $row["gateway"];
$username = $row["username"]; $username = $row["username"];
$password = $row["password"]; $password = $row["password"];
@@ -80,10 +83,17 @@ else {
$context = $row["context"]; $context = $row["context"];
$enabled = $row["enabled"]; $enabled = $row["enabled"];
$description = 'copy: '.$row["description"]; $description = 'copy: '.$row["description"];
break; //limit to 1 row
} }
unset ($prep_statement); unset ($prep_statement);
//set defaults
if (strlen($expire_seconds) == 0) {
$expire_seconds = '800';
}
if (strlen($retry_seconds) == 0) {
$retry_seconds = '30';
}
//copy the gateways //copy the gateways
$gateway_uuid = uuid(); $gateway_uuid = uuid();
$sql = "insert into v_gateways "; $sql = "insert into v_gateways ";
@@ -107,7 +117,7 @@ else {
$sql .= "extension, "; $sql .= "extension, ";
$sql .= "codec_prefs, "; $sql .= "codec_prefs, ";
$sql .= "ping, "; $sql .= "ping, ";
$sql .= "channels, "; //$sql .= "channels, ";
$sql .= "caller_id_in_from, "; $sql .= "caller_id_in_from, ";
$sql .= "supress_cng, "; $sql .= "supress_cng, ";
$sql .= "extension_in_contact, "; $sql .= "extension_in_contact, ";
@@ -117,7 +127,12 @@ else {
$sql .= ")"; $sql .= ")";
$sql .= "values "; $sql .= "values ";
$sql .= "("; $sql .= "(";
$sql .= "'$domain_uuid', "; if (strlen($domain_uuid) == 0) {
$sql .= "'$domain_uuid', ";
}
else {
$sql .= "null, ";
}
$sql .= "'$gateway_uuid', "; $sql .= "'$gateway_uuid', ";
$sql .= "'$gateway', "; $sql .= "'$gateway', ";
$sql .= "'$username', "; $sql .= "'$username', ";
@@ -136,7 +151,7 @@ else {
$sql .= "'$extension', "; $sql .= "'$extension', ";
$sql .= "'$codec_prefs', "; $sql .= "'$codec_prefs', ";
$sql .= "'$ping', "; $sql .= "'$ping', ";
$sql .= "'$channels', "; //$sql .= "'$channels', ";
$sql .= "'$caller_id_in_from', "; $sql .= "'$caller_id_in_from', ";
$sql .= "'$supress_cng', "; $sql .= "'$supress_cng', ";
$sql .= "'$extension_in_contact', "; $sql .= "'$extension_in_contact', ";