From adb442039f0bc9ff5fd1b3e7ee44cf798c4b26c7 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 14 Jun 2018 01:37:44 -0600 Subject: [PATCH] Update gateway_copy.php --- app/gateways/gateway_copy.php | 55 ++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/app/gateways/gateway_copy.php b/app/gateways/gateway_copy.php index b0fa0fa108..8edcd47755 100644 --- a/app/gateways/gateway_copy.php +++ b/app/gateways/gateway_copy.php @@ -17,23 +17,27 @@ The Initial Developer of the Original Code is Mark J Crane - 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. Contributor(s): Mark J Crane */ -include "root.php"; -require_once "resources/require.php"; -require_once "resources/check_auth.php"; -require_once "resources/paging.php"; -if (permission_exists('gateway_add')) { - //access granted -} -else { - echo "access denied"; - exit; -} + +//includes + include "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + require_once "resources/paging.php"; + +//check permissions + if (permission_exists('gateway_add')) { + //access granted + } + else { + echo "access denied"; + exit; + } //add multi-lingual support $language = new text; @@ -46,12 +50,11 @@ else { //get the data $sql = "select * from v_gateways "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and gateway_uuid = '$gateway_uuid' "; + $sql .= "where gateway_uuid = '$gateway_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { + $gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($gateways as &$row) { $gateway = $row["gateway"]; $username = $row["username"]; $password = $row["password"]; @@ -80,10 +83,17 @@ else { $context = $row["context"]; $enabled = $row["enabled"]; $description = 'copy: '.$row["description"]; - break; //limit to 1 row } unset ($prep_statement); +//set defaults + if (strlen($expire_seconds) == 0) { + $expire_seconds = '800'; + } + if (strlen($retry_seconds) == 0) { + $retry_seconds = '30'; + } + //copy the gateways $gateway_uuid = uuid(); $sql = "insert into v_gateways "; @@ -107,7 +117,7 @@ else { $sql .= "extension, "; $sql .= "codec_prefs, "; $sql .= "ping, "; - $sql .= "channels, "; + //$sql .= "channels, "; $sql .= "caller_id_in_from, "; $sql .= "supress_cng, "; $sql .= "extension_in_contact, "; @@ -117,7 +127,12 @@ else { $sql .= ")"; $sql .= "values "; $sql .= "("; - $sql .= "'$domain_uuid', "; + if (strlen($domain_uuid) == 0) { + $sql .= "'$domain_uuid', "; + } + else { + $sql .= "null, "; + } $sql .= "'$gateway_uuid', "; $sql .= "'$gateway', "; $sql .= "'$username', "; @@ -136,7 +151,7 @@ else { $sql .= "'$extension', "; $sql .= "'$codec_prefs', "; $sql .= "'$ping', "; - $sql .= "'$channels', "; + //$sql .= "'$channels', "; $sql .= "'$caller_id_in_from', "; $sql .= "'$supress_cng', "; $sql .= "'$extension_in_contact', ";