Improve security on the lua scripts, add lua json library, add *77 dnd toggle feature code, speed dial *0[ext], and improve blf support for extension number alias.

This commit is contained in:
markjcrane
2016-12-08 18:36:15 -07:00
parent 30acee4dff
commit 9b1b38fab6
84 changed files with 3881 additions and 1346 deletions
@@ -29,8 +29,13 @@
outbound_caller_id_number = session:getVariable("outbound_caller_id_number");
--connect to the database
require "resources.functions.database_handle";
dbh = database_handle('system');
local Database = require "resources.functions.database";
--include json library
local json
if (debug["sql"]) then
json = require "resources.functions.lunajson"
end
--prepare the api object
api = freeswitch.API();
@@ -43,13 +48,18 @@
--get the destination number
if (cache == "-ERR NOT FOUND") then
sql = "SELECT destination_number, destination_context "
local dbh = Database.new('system');
local sql = "SELECT destination_number, destination_context "
sql = sql .. "FROM v_destinations "
sql = sql .. "WHERE destination_number = '"..destination_number.."' "
sql = sql .. "WHERE destination_number = :destination_number "
sql = sql .. "AND destination_type = 'inbound' "
sql = sql .. "AND destination_enabled = 'true' "
--freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n");
assert(dbh:query(sql, function(row)
local params = {destination_number = destination_number};
if (debug["sql"]) then
freeswitch.consoleLog("notice", "SQL:" .. sql .. "; params: " .. json.encode(params) .. "\n");
end
dbh:query(sql, params, function(row)
--set the outbound caller id
if (outbound_caller_id_name ~= nil) then
@@ -77,7 +87,8 @@
--transfer the call
session:transfer(row.destination_number, "XML", row.destination_context);
end));
end);
else
--add the function
require "resources.functions.explode";