diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/acl.conf.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/acl.conf.lua
index b0663a0667..34750fcc10 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/acl.conf.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/acl.conf.lua
@@ -32,6 +32,9 @@
loopback.auto - ACL for your local lan.
]]
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--get the cache
local cache = require "resources.functions.cache"
local acl_cache_key = "configuration:acl.conf"
@@ -64,12 +67,12 @@
assert(dbh:connected());
--start the xml array
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--run the query
sql = "select * from v_access_controls ";
@@ -81,7 +84,7 @@
dbh:query(sql, function(row)
--list open tag
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--get the nodes
sql = "select * from v_access_control_nodes ";
@@ -93,23 +96,23 @@
x = 0;
dbh:query(sql, params, function(field)
if (string.len(field.node_domain) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
else
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
end)
--list close tag
- table.insert(xml, [[
]]);
+ xml:append([[
]]);
end)
--close the extension tag if it was left open
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
if (debug["xml_string"]) then
freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
end
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua
index 70b7398ca0..158ecc2c32 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua
@@ -27,6 +27,9 @@
--include functions
require "resources.functions.format_ringback"
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--get the cache
local cache = require "resources.functions.cache"
hostname = trim(api:execute("switchname", ""));
@@ -52,23 +55,23 @@
dsn_callcenter = freeswitch.getGlobalVariable("dsn_callcenter") or ''
--start the xml array
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
if #dsn_callcenter > 0 then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
elseif #dsn > 0 then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
- -- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ -- xml:append([[ ]]);
+ xml:append([[ ]]);
--write the queues
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
sql = "select * from v_call_center_queues as q, v_domains as d ";
sql = sql .. "where d.domain_uuid = q.domain_uuid; ";
if (debug["sql"]) then
@@ -103,59 +106,59 @@
queue_name = queue_name:gsub(" ", "-");
--start the xml
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--set ringback
queue_ringback = format_ringback(queue_moh_sound);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
if (queue_record_template ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_time_base_score ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_max_wait_time_with_no_agent ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_max_wait_time_with_no_agent ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_max_wait_time_with_no_agent_time_reached ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_tier_rules_apply ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_tier_rule_wait_second ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_tier_rule_wait_multiply_level ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_tier_rule_no_agent_no_wait ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_discard_abandoned_after ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_abandoned_resume_allowed ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_announce_sound ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (queue_announce_frequency ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--increment the value of x
x = x + 1;
end)
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--get the agents
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
sql = "select SPLIT_PART(SPLIT_PART(a.agent_contact, '/', 2), '@', 1) as extension, ";
sql = sql .. "(select extension_uuid from v_extensions where domain_uuid = a.domain_uuid ";
sql = sql .. "and extension = SPLIT_PART(SPLIT_PART(a.agent_contact, '/', 2), '@', 1) limit 1) as extension_uuid, ";
@@ -236,30 +239,30 @@
end
--build the xml string
- table.insert(xml, [[ ]]);
+ xml:append([[ />]]);
end)
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--get the tiers
sql = "select t.domain_uuid, d.domain_name, t.call_center_agent_uuid, t.call_center_queue_uuid, q.queue_extension, t.tier_level, t.tier_position ";
@@ -269,7 +272,7 @@
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
end
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
dbh:query(sql, function(row)
--get the values from the database and set as variables
domain_uuid = row.domain_uuid;
@@ -280,25 +283,25 @@
tier_level = row.tier_level;
tier_position = row.tier_position;
--build the xml
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end)
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--close the extension tag if it was left open
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
if (debug["xml_string"]) then
- freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
+ freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
end
--close the database connection
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/conference.conf.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/conference.conf.lua
index e8b72f6333..483c8fb72a 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/conference.conf.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/conference.conf.lua
@@ -37,15 +37,18 @@
--exits the script if we didn't connect properly
assert(dbh:connected());
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--set the xml array
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--start the conference controls
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
sql = [[SELECT * FROM v_conference_controls
WHERE control_enabled = 'true' ]];
if (debug["sql"]) then
@@ -53,7 +56,7 @@
end
dbh:query(sql, function(field)
conference_control_uuid = field["conference_control_uuid"];
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--get the conference control details from the database
sql = [[SELECT * FROM v_conference_control_details
@@ -67,15 +70,15 @@
dbh:query(sql, params, function(row)
--conference_control_uuid = row["conference_control_uuid"];
--conference_control_detail_uuid = row["conference_control_detail_uuid"];
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--start the conference profiles
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
sql = [[SELECT * FROM v_conference_profiles
WHERE profile_enabled = 'true' ]];
if (debug["sql"]) then
@@ -83,7 +86,7 @@
end
dbh:query(sql, function(field)
conference_profile_uuid = field["conference_profile_uuid"];
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--get the conference profile parameters from the database
sql = [[SELECT * FROM v_conference_profile_params
@@ -98,17 +101,17 @@
--conference_profile_uuid = row["conference_profile_uuid"];
--conference_profile_param_uuid = row["conference_profile_param_uuid"];
--profile_param_description = row["profile_param_description"];
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--set the xml array and then concatenate the array to a string
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
if (debug["xml_string"]) then
freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
end
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/ivr.conf.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/ivr.conf.lua
index 6203d45064..47ade48e55 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/ivr.conf.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/ivr.conf.lua
@@ -30,6 +30,9 @@
local log = require "resources.functions.log".ivr_menu
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--get the cache
local cache = require "resources.functions.cache"
local ivr_menu_cache_key = "configuration:ivr.conf:" .. ivr_menu_uuid
@@ -51,12 +54,12 @@
end
--start the xml array
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--set the sound prefix
sound_prefix = sounds_dir.."/${default_language}/${default_dialect}/${default_voice}/";
@@ -245,25 +248,25 @@
end
--add xml to the array
- table.insert(xml, [[ ]]);
end);
--add the xml closing tags
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
- --save the xml table into a string
- XML_STRING = table.concat(xml, "\n");
+ --save the xml into a string
+ XML_STRING = xml:build();
--optinonal debug message
if (debug["xml_string"]) then
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/local_stream.conf.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/local_stream.conf.lua
index c65257ba50..5505eacf11 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/local_stream.conf.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/local_stream.conf.lua
@@ -1,3 +1,5 @@
+--include xml library
+ local Xml = require "resources.functions.xml";
--get the cache
local cache = require "resources.functions.cache"
@@ -31,11 +33,11 @@
assert(dbh:connected());
--start the xml array
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--run the query
sql = "select d.domain_name, s.* "
@@ -90,30 +92,30 @@
end
--build the xml ]]..row.music_on_hold_name..[["
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
if (chime_list ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (row.music_on_hold_chime_freq ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (row.music_on_hold_chime_max ~= nil) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end)
--close the extension tag if it was left open
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
if (debug["xml_string"]) then
freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
end
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua
index 44eab72475..91026f2a94 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua
@@ -24,6 +24,9 @@
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--get the cache
local cache = require "resources.functions.cache"
local hostname = trim(api:execute("switchname", ""))
@@ -59,11 +62,11 @@
vars = trim(api:execute("global_getvar", ""));
--start the xml array
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--gt the global settings
sql = "select * from v_sofia_global_settings ";
@@ -71,11 +74,11 @@
sql = sql .. "order by global_setting_name asc ";
local params = {};
x = 0;
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
dbh:query(sql, params, function(row)
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end)
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--set defaults
previous_sip_profile_name = "";
@@ -94,7 +97,7 @@
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
end
x = 0;
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
dbh:query(sql, params, function(row)
--set as variables
sip_profile_uuid = row.sip_profile_uuid;
@@ -106,14 +109,14 @@
--open xml tag
if (sip_profile_name ~= previous_sip_profile_name) then
if (x > 1) then
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- --table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ --xml:append([[ ]]);
--get the gateways
sql = "select * from v_gateways ";
@@ -126,108 +129,108 @@
end
x = 0;
dbh:query(sql, params, function(field)
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
if (string.len(field.username) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.distinct_to) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.auth_username) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.password) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.realm) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.from_user) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.from_domain) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.proxy) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.register_proxy) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.outbound_proxy) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.expire_seconds) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.register) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (field.register_transport) then
if (field.register_transport == "udp") then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
elseif (field.register_transport == "tcp") then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
elseif (field.register_transport == "tls") then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
else
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
end
if (field.contact_params) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.retry_seconds) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.extension) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.ping) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.ping_min) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.ping_max) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.contact_in_ping) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.context) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.caller_id_in_from) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.supress_cng) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
if (string.len(field.extension_in_contact) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
if (string.len(field.sip_cid_type) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
end)
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--add sip profile domain: name, alias, and parse
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
sql = "SELECT sip_profile_domain_name, sip_profile_domain_alias, sip_profile_domain_parse FROM v_sip_profile_domains ";
sql = sql .. "WHERE sip_profile_uuid = :sip_profile_uuid";
local params = {sip_profile_uuid = sip_profile_uuid};
@@ -241,11 +244,11 @@
if (name == nil or name == '') then name = 'false'; end
if (alias == nil or alias == '') then alias = 'false'; end
if (parse == nil or parse == '') then parse = 'false'; end
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
profile_tag_status = "open";
end
@@ -266,7 +269,7 @@
--set the parameters
if (sip_profile_setting_name) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
--set the previous value
@@ -278,15 +281,15 @@
--close the extension tag if it was left open
if (profile_tag_status == "open") then
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
profile_tag_status = "close";
end
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
if (debug["xml_string"]) then
freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
end
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua
index f77cfb1f04..b89beb3aa2 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua
@@ -24,6 +24,9 @@
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--get the cache
local cache = require "resources.functions.cache"
local translate_cache_key = "configuration:translate.conf"
@@ -60,12 +63,12 @@
assert(dbh:connected());
--start the xml array
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--run the query
sql = "select * from v_number_translations ";
@@ -77,7 +80,7 @@
dbh:query(sql, function(row)
--list open tag
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--get the nodes
sql = "select * from v_number_translation_details ";
@@ -90,21 +93,21 @@
x = 0;
dbh:query(sql, params, function(field)
if (string.len(field.number_translation_detail_regex) > 0) then
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
end)
--list close tag
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end)
--close the extension tag if it was left open
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
if (debug["xml_string"]) then
freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
end
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua
index d50551d0e0..30424ce1f2 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua
@@ -28,6 +28,9 @@
local cache = require"resources.functions.cache"
local log = require"resources.functions.log"["xml_handler"]
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--connect to the database
local Database = require "resources.functions.database";
dbh = Database.new('system');
@@ -156,11 +159,11 @@
hostname = trim(api:execute("hostname", ""));
--set the xml array and then concatenate the array to a string
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
--get the dialplan xml
if (context_name == 'public' and dialplan_mode == 'single') then
@@ -193,19 +196,19 @@
if (row.domain_uuid ~= nil) then
domain_name = row.domain_name;
else
- table.insert(xml, row.dialplan_xml);
+ xml:append(row.dialplan_xml);
end
if (row.domain_enabled == true) then
- table.insert(xml, row.dialplan_xml);
+ xml:append(row.dialplan_xml);
end
end);
if (xml == nil) then
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
end
else
sql = "select dialplan_xml from v_dialplans as p ";
@@ -222,15 +225,15 @@
freeswitch.consoleLog("notice", "[dialplan] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
end
dbh:query(sql, params, function(row)
- table.insert(xml, row.dialplan_xml);
+ xml:append(row.dialplan_xml);
end);
end
--set the xml array and then concatenate the array to a string
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
--close the database connection
dbh:release();
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/acl.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/acl.lua
index 0d9de9351f..b183a2b38b 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/acl.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/acl.lua
@@ -10,10 +10,10 @@
end
--build the xml
- local xml = {}
- table.insert(xml, [[]])
- table.insert(xml, [[]])
- table.insert(xml, [[ ]])
+ local xml = Xml:new();
+ xml:append([[]])
+ xml:append([[]])
+ xml:append([[ ]])
--process when the sip profile is rescanned, sofia is reloaded, or sip redirect
local sql = "SELECT * FROM v_domains as d, v_extensions as e "
@@ -34,33 +34,33 @@
dbh:query(sql, params, function(row)
if prev_domain_name ~= row.domain_name then
if prev_domain_name then
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
end
prev_domain_name = row.domain_name
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
end
- local cidr = (#row.cidr > 0) and (' cidr="' .. row.cidr .. '"') or ''
- table.insert(xml, [[ ]])
+ local cidr = (#row.cidr > 0) and (' cidr="' .. xml.sanitize(row.cidr) .. '"') or ''
+ xml:append([[ ]])
end)
if prev_domain_name then
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
end
- table.insert(xml, [[ ]])
- table.insert(xml, [[]])
+ xml:append([[ ]])
+ xml:append([[]])
+ XML_STRING = xml:build();
- XML_STRING = table.concat(xml, "\n")
if (debug["xml_string"]) then
log.notice("XML_STRING "..XML_STRING)
end
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/directory.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/directory.lua
index c450859b84..ae30827c5f 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/directory.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/directory.lua
@@ -11,10 +11,10 @@
end
--build the xml
- local xml = {}
- table.insert(xml, [[]])
- table.insert(xml, [[]])
- table.insert(xml, [[ ]])
+ local xml = Xml:new();
+ xml:append([[]])
+ xml:append([[]])
+ xml:append([[ ]])
--process when the sip profile is rescanned, sofia is reloaded, or sip redirect
local sql = "SELECT * FROM v_domains as d, v_extensions as e "
@@ -48,54 +48,54 @@
dbh:query(sql, sql_params, function(row)
if prev_domain_name ~= row.domain_name then
if prev_domain_name then
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
end
prev_domain_name = row.domain_name
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
end
row.sip_from_user = row.extension
row.sip_from_number = (#number_alias > 0) and number_alias or row.extension
local number_alias_string = ''
if #row.number_alias > 0 then
- number_alias_string = ' number-alias="' .. row.number_alias .. '"'
+ number_alias_string = ' number-alias="' .. xml.sanitize(row.number_alias) .. '"'
end
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]])
+ xml:append([[ ]]);
+ xml:append([[ ]])
for name, param in pairs(params) do
if row[name] and #row[name] > 0 then
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
end
end
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
for name, param in pairs(variables) do
if row[name] and #row[name] > 0 then
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
end
end
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
end)
if prev_domain_name then
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
- table.insert(xml, [[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
+ xml:append([[ ]])
end
- table.insert(xml, [[ ]])
- table.insert(xml, [[]])
+ xml:append([[ ]])
+ xml:append([[]])
+ XML_STRING = xml:build();
- XML_STRING = table.concat(xml, "\n")
if (debug["xml_string"]) then
log.notice("XML_STRING "..XML_STRING)
end
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/domains.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/domains.lua
index e68a2a1f9a..48aa60304c 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/domains.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/domains.lua
@@ -24,6 +24,9 @@
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--connect to the database
local Database = require "resources.functions.database";
dbh = Database.new('system');
@@ -32,17 +35,17 @@
assert(dbh:connected());
--process when the sip profile is rescanned, sofia is reloaded, or sip redirect
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
local sql = "SELECT domain_name FROM v_domains ";
dbh:query(sql, function(row)
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
--close the database connection
dbh:release();
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/group_call.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/group_call.lua
index 384765f568..8a9f6a8676 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/group_call.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/group_call.lua
@@ -101,12 +101,12 @@
--end
--build the xml array
- local xml = {}
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ local xml = Xml:new();
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
previous_call_group = "";
for key, value in pairs(call_group_array) do
call_group = trim(key);
@@ -115,23 +115,23 @@
freeswitch.consoleLog("notice", "[directory] call_group: " .. call_group .. "\n");
freeswitch.consoleLog("notice", "[directory] extension_list: " .. extension_list .. "\n");
if (previous_call_group ~= call_group) then
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
extension_array = explode(",", extension_list);
for index,tmp_extension in pairs(extension_array) do
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
end
previous_call_group = call_group;
end
end
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
--close the database connection
dbh:release();
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/reverse-auth-lookup.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/reverse-auth-lookup.lua
index a9853bd145..a29b931bce 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/reverse-auth-lookup.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/action/reverse-auth-lookup.lua
@@ -46,6 +46,7 @@
--exits the script if we didn't connect properly
assert(dbh:connected());
+
--get the domain_uuid
if (domain_uuid == nil) then
if (domain_name ~= nil) then
@@ -90,21 +91,21 @@
--build the xml
if (domain_name ~= nil and extension ~= nil and password ~= nil) then
- local xml = {}
- --table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ local xml = Xml:new();
+ --xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
end
--close the database connection
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/directory.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/directory.lua
index 224b0de430..78f59fd2bf 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/directory.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/directory/directory.lua
@@ -52,6 +52,7 @@ continue = true;
json = require "resources.functions.lunajson"
end
+--include xml library
local Xml = require "resources.functions.xml";
--include cache library
diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/languages/languages.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/languages/languages.lua
index 0480236847..5775820290 100644
--- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/languages/languages.lua
+++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/languages/languages.lua
@@ -30,6 +30,9 @@
--general functions
require "resources.functions.is_uuid";
+--include xml library
+ local Xml = require "resources.functions.xml";
+
--set the default
continue = true;
@@ -96,15 +99,15 @@
-- if macro_name is a uuid get from the phrase details
if (is_uuid(macro_name)) then
--define the xml table
- local xml = {}
+ local xml = Xml:new();
--get the xml
- table.insert(xml, [[]]);
- table.insert(xml, [[]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[]]);
+ xml:append([[]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
local sql = "SELECT * FROM v_phrases as p, v_phrase_details as d ";
sql = sql .. "WHERE d.domain_uuid = :domain_uuid ";
@@ -128,32 +131,32 @@
--phrase_detail_type,phrase_detail_order
if (previous_phrase_uuid ~= row.phrase_uuid) then
if (x > 0) then
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
match_open_tag = true
end
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
previous_phrase_uuid = row.phrase_uuid;
x = x + 1;
end);
if (x > 0) then
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
end
- table.insert(xml, [[ ]]);
+ xml:append([[ ]]);
--output xml & close previous file
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[ ]]);
- table.insert(xml, [[]]);
- XML_STRING = table.concat(xml, "\n");
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[ ]]);
+ xml:append([[]]);
+ XML_STRING = xml:build();
end
--log to the console