mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Add. Use parameters in reverse-auth-lookup.lua (#2094)
This commit is contained in:
committed by
FusionPBX
parent
dd8e226c34
commit
dc838c91c0
@@ -31,22 +31,31 @@
|
|||||||
--group_call - call group has been called
|
--group_call - call group has been called
|
||||||
--user_call - user has been called
|
--user_call - user has been called
|
||||||
|
|
||||||
|
--get logger
|
||||||
|
local log = require "resources.functions.log".xml_handler;
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
require "resources.functions.database_handle";
|
local Database = require "resources.functions.database";
|
||||||
dbh = database_handle('system');
|
dbh = Database.new('system');
|
||||||
|
|
||||||
|
--include json library
|
||||||
|
local json
|
||||||
|
if (debug["sql"]) then
|
||||||
|
json = require "resources.functions.lunajson"
|
||||||
|
end
|
||||||
|
|
||||||
--exits the script if we didn't connect properly
|
--exits the script if we didn't connect properly
|
||||||
assert(dbh:connected());
|
assert(dbh:connected());
|
||||||
|
|
||||||
--get the domain_uuid
|
--get the domain_uuid
|
||||||
if (domain_uuid == nil and domain_name ~= nil) then
|
if (domain_uuid == nil) then
|
||||||
if (domain_name ~= nil) then
|
if (domain_name ~= nil) then
|
||||||
sql = "SELECT domain_uuid FROM v_domains ";
|
local sql = "SELECT domain_uuid FROM v_domains ";
|
||||||
sql = sql .. "WHERE domain_name = '" .. domain_name .."' ";
|
sql = sql .. "WHERE domain_name = :domain_name ";
|
||||||
|
local params = {domain_name = domain_name}
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
log.noticef("SQL: %s; params %s", sql, json.encode(params));
|
||||||
end
|
end
|
||||||
status = dbh:query(sql, function(rows)
|
dbh:query(sql, params, function(rows)
|
||||||
domain_uuid = rows["domain_uuid"];
|
domain_uuid = rows["domain_uuid"];
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
@@ -54,11 +63,14 @@
|
|||||||
|
|
||||||
--get the extension information
|
--get the extension information
|
||||||
if (domain_uuid ~= nil) then
|
if (domain_uuid ~= nil) then
|
||||||
sql = "SELECT * FROM v_extensions WHERE domain_uuid = '" .. domain_uuid .. "' and (extension = '" .. user .. "' or number_alias = '" .. user .. "') and enabled = 'true' ";
|
local sql = "SELECT * FROM v_extensions WHERE domain_uuid = :domain_uuid "
|
||||||
|
.. "and (extension = :user or number_alias = :user) "
|
||||||
|
.. "and enabled = 'true' ";
|
||||||
|
local params = {domain_uuid=domain_uuid, user=user};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
log.noticef("SQL: %s; params %s", sql, json.encode(params));
|
||||||
end
|
end
|
||||||
dbh:query(sql, function(row)
|
dbh:query(sql, params, function(row)
|
||||||
--general
|
--general
|
||||||
domain_uuid = row.domain_uuid;
|
domain_uuid = row.domain_uuid;
|
||||||
extension_uuid = row.extension_uuid;
|
extension_uuid = row.extension_uuid;
|
||||||
|
|||||||
Reference in New Issue
Block a user