mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Revert "Change. Use require "resources.functions.config" to load config file."
This commit is contained in:
@@ -24,22 +24,6 @@
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
global $IS_WINDOWS;
|
||||
|
||||
if ($IS_WINDOWS == null) {
|
||||
if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; }
|
||||
}
|
||||
|
||||
if (!function_exists('correct_path')) {
|
||||
function correct_path($p) {
|
||||
global $IS_WINDOWS;
|
||||
if ($IS_WINDOWS) {
|
||||
return str_replace('/', '\\', $p);
|
||||
}
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
|
||||
//proccess this only one time
|
||||
if ($domains_processed == 1) {
|
||||
|
||||
@@ -129,31 +113,28 @@ if ($domains_processed == 1) {
|
||||
$tmp = "\n";
|
||||
$tmp .= "--set the variables\n";
|
||||
if (strlen($_SESSION['switch']['sounds']['dir']) > 0) {
|
||||
$tmp .= correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n");
|
||||
$tmp .= " sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n";
|
||||
}
|
||||
if (strlen($_SESSION['switch']['db']['dir']) > 0) {
|
||||
$tmp .= correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n");
|
||||
$tmp .= " database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n";
|
||||
}
|
||||
if (strlen($_SESSION['switch']['recordings']['dir']) > 0) {
|
||||
$tmp .= correct_path(" recordings_dir = [[".$recordings_dir."]];\n");
|
||||
$tmp .= " recordings_dir = [[".$recordings_dir."]];\n";
|
||||
}
|
||||
if (strlen($_SESSION['switch']['storage']['dir']) > 0) {
|
||||
$tmp .= correct_path(" storage_dir = [[".$_SESSION['switch']['storage']['dir']."]];\n");
|
||||
$tmp .= " storage_dir = [[".$_SESSION['switch']['storage']['dir']."]];\n";
|
||||
}
|
||||
if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) {
|
||||
$tmp .= correct_path(" voicemail_dir = [[".$_SESSION['switch']['voicemail']['dir']."]];\n");
|
||||
$tmp .= " voicemail_dir = [[".$_SESSION['switch']['voicemail']['dir']."]];\n";
|
||||
}
|
||||
if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
|
||||
$tmp .= correct_path(" scripts_dir = [[".$_SESSION['switch']['scripts']['dir']."]];\n");
|
||||
}
|
||||
$tmp .= correct_path(" php_dir = [[".PHP_BINDIR."]];\n");
|
||||
$tmp .= " php_dir = [[".PHP_BINDIR."]];\n";
|
||||
if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
|
||||
$tmp .= " php_bin = \"php.exe\";\n";
|
||||
}
|
||||
else {
|
||||
$tmp .= " php_bin = \"php\";\n";
|
||||
}
|
||||
$tmp .= correct_path(" document_root = [[".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."]];\n");
|
||||
$tmp .= " document_root = [[".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."]];\n";
|
||||
$tmp .= "\n";
|
||||
|
||||
if ((strlen($db_type) > 0) || (strlen($dsn_name) > 0)) {
|
||||
@@ -161,7 +142,7 @@ if ($domains_processed == 1) {
|
||||
$tmp .= " database = {}\n";
|
||||
$tmp .= " database[\"type\"] = \"".$db_type."\";\n";
|
||||
$tmp .= " database[\"name\"] = \"".$db_name."\";\n";
|
||||
$tmp .= correct_path(" database[\"path\"] = [[".$db_path."]];\n");
|
||||
$tmp .= " database[\"path\"] = \"".$db_path."\";\n";
|
||||
|
||||
if (strlen($dsn_name) > 0) {
|
||||
$tmp .= " database[\"system\"] = \"odbc://".$dsn_name.":".$dsn_username.":".$dsn_password."\";\n";
|
||||
@@ -185,19 +166,19 @@ if ($domains_processed == 1) {
|
||||
|
||||
$tmp .= "--additional info\n";
|
||||
$tmp .= " domain_count = ".count($_SESSION["domains"]).";\n";
|
||||
$tmp .= correct_path(" temp_dir = [[".$_SESSION['server']['temp']['dir']."]];\n");
|
||||
$tmp .= " temp_dir = [[".$_SESSION['server']['temp']['dir']."]];\n";
|
||||
if (isset($_SESSION['domain']['dial_string']['text'])) {
|
||||
$tmp .= " dial_string = \"".$_SESSION['domain']['dial_string']['text']."\";\n";
|
||||
}
|
||||
$tmp .= "\n";
|
||||
$tmp .= "--include local.lua\n";
|
||||
$tmp .= " require(\"resources.functions.file_exists\");\n";
|
||||
$tmp .= " dofile(scripts_dir..\"/resources/functions/file_exists.lua\");\n";
|
||||
$tmp .= " if (file_exists(\"/etc/fusionpbx/local.lua\")) then\n";
|
||||
$tmp .= " dofile(\"/etc/fusionpbx/local.lua\");\n";
|
||||
$tmp .= " elseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n";
|
||||
$tmp .= " dofile(\"/usr/local/etc/fusionpbx/local.lua\");\n";
|
||||
$tmp .= " elseif (file_exists(scripts_dir..\"/resources/local.lua\")) then\n";
|
||||
$tmp .= " require(\"resources.local\");\n";
|
||||
$tmp .= " dofile(scripts_dir..\"/resources/local.lua\");\n";
|
||||
$tmp .= " end\n";
|
||||
fwrite($fout, $tmp);
|
||||
unset($tmp);
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--get the argv values
|
||||
script_name = argv[0];
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
debug["sql"] = true;
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--set the api
|
||||
|
||||
@@ -57,7 +57,7 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
local sql = nil
|
||||
|
||||
--define the functions
|
||||
require "resources.functions.trim";
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
|
||||
--define the logger function
|
||||
local function logger(level, log, data)
|
||||
@@ -88,7 +88,7 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
--if not cached then get the information from the database
|
||||
if (cache == "-ERR NOT FOUND") then
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--log if not connect
|
||||
@@ -123,7 +123,7 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
else
|
||||
--get from memcache
|
||||
--add the function
|
||||
require "resources.functions.explode";
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
--parse the cache
|
||||
array = explode("&", cache);
|
||||
|
||||
@@ -37,19 +37,19 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--prepare the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
--general functions
|
||||
require "resources.functions.base64";
|
||||
require "resources.functions.trim";
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.explode";
|
||||
require "resources.functions.format_seconds";
|
||||
require "resources.functions.mkdir";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
dofile(scripts_dir.."/resources/functions/format_seconds.lua");
|
||||
dofile(scripts_dir.."/resources/functions/mkdir.lua");
|
||||
|
||||
--get the session variables
|
||||
uuid = session:getVariable("uuid");
|
||||
@@ -153,7 +153,7 @@
|
||||
end_epoch = os.time();
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--get the conference sessions
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
--get the scripts directory and include the config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--additional includes
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.trim";
|
||||
require "resources.functions.mkdir";
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
dofile(scripts_dir.."/resources/functions/mkdir.lua");
|
||||
|
||||
--get the argv values
|
||||
script_name = argv[0];
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
-- the Initial Developer. All Rights Reserved.
|
||||
|
||||
--add functions
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.trim";
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
|
||||
--set the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
end
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--get the cache
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
else
|
||||
--add the function
|
||||
require "resources.functions.explode";
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
--parse the cache
|
||||
array = explode("&", cache);
|
||||
|
||||
@@ -23,8 +23,16 @@
|
||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||
-- Errol Samuels <voiptology@gmail.com>
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
--define explode
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--usage
|
||||
--luarun app.lua event_notify internal reboot 1003@domain.fusionpbx.com yealink
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
require "resources.functions.explode";
|
||||
require "resources.functions.trim";
|
||||
dofile(scripts_dir .. "/resources/functions/config.lua");
|
||||
dofile(scripts_dir .. "/resources/functions/explode.lua");
|
||||
dofile(scripts_dir .. "/resources/functions/trim.lua");
|
||||
|
||||
--check the missed calls
|
||||
function missed()
|
||||
|
||||
@@ -26,17 +26,33 @@
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--array count
|
||||
require "resources.functions.count";
|
||||
function count(t)
|
||||
c = 0;
|
||||
for k,v in pairs(t) do
|
||||
c = c+1;
|
||||
end
|
||||
return c;
|
||||
end
|
||||
|
||||
-- set channel variables to lua variables
|
||||
domain_uuid = env:getHeader("domain_uuid");
|
||||
@@ -52,7 +68,7 @@
|
||||
end
|
||||
|
||||
--settings
|
||||
require "resources.functions.settings";
|
||||
dofile(scripts_dir.."/resources/functions/settings.lua");
|
||||
settings = settings(domain_uuid);
|
||||
storage_type = "";
|
||||
storage_path = "";
|
||||
@@ -297,7 +313,7 @@
|
||||
if (fax_success =="1") then
|
||||
if (storage_type == "base64") then
|
||||
--include the base64 function
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--base64 encode the file
|
||||
local f = io.open(fax_file, "rb");
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--general functions
|
||||
require "resources.functions.config";
|
||||
require "resources.functions.explode";
|
||||
require "resources.functions.trim";
|
||||
-- require "resources.functions.file_exists";
|
||||
dofile(scripts_dir .. "/resources/functions/config.lua");
|
||||
dofile(scripts_dir .. "/resources/functions/explode.lua");
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
--dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
|
||||
--create the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
@@ -29,14 +29,18 @@
|
||||
outbound_caller_id_number = session:getVariable("outbound_caller_id_number");
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--prepare the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
--add the trim function
|
||||
function trim(s)
|
||||
if (s) then
|
||||
return s:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
end
|
||||
end
|
||||
|
||||
--get the cache
|
||||
cache = trim(api:execute("memcache", "get app:dialplan:outbound:is_local:" .. destination_number .. "@" .. domain_name));
|
||||
@@ -80,7 +84,7 @@
|
||||
end));
|
||||
else
|
||||
--add the function
|
||||
require "resources.functions.explode";
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
--define the array/table and variables
|
||||
local var = {}
|
||||
|
||||
@@ -26,8 +26,16 @@
|
||||
--set the debug options
|
||||
debug["sql"] = false;
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
--define explode
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--set the defaults
|
||||
max_tries = 3;
|
||||
@@ -36,8 +44,13 @@
|
||||
tries = 0;
|
||||
profile = "internal";
|
||||
|
||||
--include config.lua
|
||||
--scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
--dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
--dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--answer
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
-- Luis Daniel Lucio Qurioz <dlucio@okay.com.mx>
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--include functions
|
||||
require "resources.functions.trim";
|
||||
require "resources.functions.explode";
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
--get the variables
|
||||
domain_name = session:getVariable("domain_name");
|
||||
@@ -329,16 +329,16 @@
|
||||
or ring_group_strategy == "sequence"
|
||||
or ring_group_strategy == "rollover") then
|
||||
session:execute("set", "group_confirm_key=exec");
|
||||
session:execute("set", "group_confirm_file=lua ".. scripts_dir:gsub('\\','/') .."/confirm.lua");
|
||||
session:execute("set", "group_confirm_file=lua ".. scripts_dir .."/confirm.lua");
|
||||
end
|
||||
|
||||
--determine confirm prompt
|
||||
if (destination_prompt == nil) then
|
||||
group_confirm = "confirm=false,";
|
||||
elseif (destination_prompt == "1") then
|
||||
group_confirm = "group_confirm_key=exec,group_confirm_file=lua ".. scripts_dir:gsub('\\','/') .."/confirm.lua,confirm=true,";
|
||||
group_confirm = "group_confirm_key=exec,group_confirm_file=lua ".. scripts_dir .."/confirm.lua,confirm=true,";
|
||||
elseif (destination_prompt == "2") then
|
||||
group_confirm = "group_confirm_key=exec,group_confirm_file=lua ".. scripts_dir:gsub('\\','/') .."/confirm.lua,confirm=true,";
|
||||
group_confirm = "group_confirm_key=exec,group_confirm_file=lua ".. scripts_dir .."/confirm.lua,confirm=true,";
|
||||
else
|
||||
group_confirm = "confirm=false,";
|
||||
end
|
||||
|
||||
@@ -23,17 +23,27 @@
|
||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
|
||||
--set variables
|
||||
max_tries = "3";
|
||||
digit_timeout = "5000";
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
--add a trim function
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
--add the explode function
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--get the argv values
|
||||
script_name = argv[0];
|
||||
|
||||
@@ -33,11 +33,21 @@
|
||||
uuid = argv[1];
|
||||
timeout = argv[2];
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
--add a trim function
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
--add the explode function
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--prepare the api
|
||||
api = freeswitch.API();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
--debug
|
||||
debug["toll_type"] = false
|
||||
|
||||
require "resources.functions.explode";
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
--create the api object and get variables
|
||||
api = freeswitch.API()
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
password_tries = 0;
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--set the api
|
||||
@@ -123,7 +123,7 @@
|
||||
end
|
||||
|
||||
--settings
|
||||
require "resources.functions.settings";
|
||||
dofile(scripts_dir.."/resources/functions/settings.lua");
|
||||
settings = settings(domain_uuid);
|
||||
storage_type = "";
|
||||
storage_path = "";
|
||||
@@ -200,36 +200,36 @@
|
||||
end
|
||||
|
||||
--general functions
|
||||
require "resources.functions.base64";
|
||||
require "resources.functions.trim";
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.explode";
|
||||
require "resources.functions.format_seconds";
|
||||
require "resources.functions.mkdir";
|
||||
require "resources.functions.copy";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
dofile(scripts_dir.."/resources/functions/format_seconds.lua");
|
||||
dofile(scripts_dir.."/resources/functions/mkdir.lua");
|
||||
dofile(scripts_dir.."/resources/functions/copy.lua");
|
||||
|
||||
--voicemail functions
|
||||
require "app.voicemail.resources.functions.on_dtmf";
|
||||
require "app.voicemail.resources.functions.get_voicemail_id";
|
||||
require "app.voicemail.resources.functions.check_password";
|
||||
require "app.voicemail.resources.functions.change_password";
|
||||
require "app.voicemail.resources.functions.macro";
|
||||
require "app.voicemail.resources.functions.play_greeting";
|
||||
require "app.voicemail.resources.functions.record_message";
|
||||
require "app.voicemail.resources.functions.record_menu";
|
||||
require "app.voicemail.resources.functions.forward_to_extension";
|
||||
require "app.voicemail.resources.functions.main_menu";
|
||||
require "app.voicemail.resources.functions.listen_to_recording";
|
||||
require "app.voicemail.resources.functions.message_waiting";
|
||||
require "app.voicemail.resources.functions.send_email";
|
||||
require "app.voicemail.resources.functions.delete_recording";
|
||||
require "app.voicemail.resources.functions.message_saved";
|
||||
require "app.voicemail.resources.functions.return_call";
|
||||
require "app.voicemail.resources.functions.menu_messages";
|
||||
require "app.voicemail.resources.functions.advanced";
|
||||
require "app.voicemail.resources.functions.record_greeting";
|
||||
require "app.voicemail.resources.functions.choose_greeting";
|
||||
require "app.voicemail.resources.functions.record_name";
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/on_dtmf.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/get_voicemail_id.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/check_password.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/change_password.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/macro.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/play_greeting.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/record_message.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/record_menu.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/forward_to_extension.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/main_menu.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/listen_to_recording.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/message_waiting.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/send_email.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/delete_recording.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/message_saved.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/return_call.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/menu_messages.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/advanced.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/record_greeting.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/choose_greeting.lua");
|
||||
dofile(scripts_dir.."/app/voicemail/resources/functions/record_name.lua");
|
||||
|
||||
--send a message waiting event
|
||||
if (voicemail_action == "mwi") then
|
||||
@@ -318,7 +318,7 @@
|
||||
freeswitch.consoleLog("notice", "[voicemail] ".. storage_type .. "\n");
|
||||
|
||||
--include the base64 function
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--base64 encode the file
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then
|
||||
|
||||
@@ -82,3 +82,4 @@
|
||||
end
|
||||
end
|
||||
end
|
||||
--dofile(scripts_dir.."/app/voicemail/resources/functions/check_password.lua");
|
||||
@@ -96,7 +96,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the voicemail message path
|
||||
greeting_location = voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the voicemail message path
|
||||
message_location = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the voicemail message path
|
||||
greeting_location = voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
--if base64, encode file
|
||||
if (storage_type == "base64") then
|
||||
--include the base64 function
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
--base64 encode the file
|
||||
local f = io.open(real_file, "rb");
|
||||
local file_content = f:read("*all");
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
--record and save the file
|
||||
if (storage_type == "base64") then
|
||||
--include the base64 function
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the location
|
||||
voicemail_name_location = voicemail_dir.."/"..voicemail_id.."/recorded_name.wav";
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
--require the email address to send the email
|
||||
if (string.len(voicemail_mail_to) > 2) then
|
||||
--include languages file
|
||||
require "app.voicemail.app_languages";
|
||||
dofile(scripts_dir.."/app/voicemail/app_languages.lua");
|
||||
|
||||
--get voicemail message details
|
||||
sql = [[SELECT * FROM v_voicemail_messages
|
||||
@@ -73,7 +73,7 @@
|
||||
--get the recordings from the database
|
||||
if (storage_type == "base64") then
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the voicemail message path
|
||||
message_location = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--include the lua script
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--define general settings
|
||||
sleep = 300;
|
||||
@@ -39,18 +41,23 @@
|
||||
--only run the script a single time
|
||||
runonce = true
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--used to stop the lua service
|
||||
local file = assert(io.open(run_file, "w"));
|
||||
file:write("remove this file to stop the script");
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
--add the trim function
|
||||
function trim(s)
|
||||
return s:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
end
|
||||
|
||||
--check if a file exists
|
||||
require "resources.functions.file_exists";
|
||||
function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
end
|
||||
|
||||
--create the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
debug["cache"] = false;
|
||||
|
||||
--general functions
|
||||
require "resources.functions.trim";
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.explode";
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
--if the params class and methods do not exist then add them to prevent errors
|
||||
if (not params) then
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
if (XML_STRING == "-ERR NOT FOUND") or (XML_STRING == "-ERR CONNECTION FAILURE") then
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
if (XML_STRING == "-ERR NOT FOUND") or (XML_STRING == "-ERR CONNECTION FAILURE") then
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
if (XML_STRING == "-ERR NOT FOUND") then
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
--set the cache
|
||||
if (XML_STRING == "-ERR NOT FOUND") then
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
--user_call - user has been called
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
--database connection
|
||||
if (continue) then
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
@@ -154,14 +154,14 @@
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] local_hostname is " .. local_hostname .. "\n");
|
||||
|
||||
--add the file_exists function
|
||||
require "resources.functions.file_exists";
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
|
||||
--connect to the switch database
|
||||
if (file_exists(database_dir.."/core.db")) then
|
||||
--dbh_switch = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||
dbh_switch = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
||||
else
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh_switch = database_handle('switch');
|
||||
end
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
--database connection
|
||||
if (continue) then
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
|
||||
@@ -29,10 +29,12 @@
|
||||
digit_timeout = "5000";
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
if (session:ready()) then
|
||||
|
||||
@@ -32,14 +32,16 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--general functions
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.mkdir";
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
dofile(scripts_dir.."/resources/functions/mkdir.lua");
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--make sure the scripts/run dir exists
|
||||
|
||||
@@ -32,16 +32,28 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim"
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode"
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--create the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--check if the session is ready
|
||||
if (session:ready()) then
|
||||
@@ -71,7 +83,7 @@
|
||||
session:sleep(1000);
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--request id is true
|
||||
|
||||
@@ -30,10 +30,20 @@
|
||||
debug["sql"] = true;
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim"
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode"
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--create the api object
|
||||
api = freeswitch.API();
|
||||
@@ -69,20 +79,22 @@
|
||||
end;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--check if the session is ready
|
||||
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
|
||||
if (database["type"] == "mysql") then
|
||||
sql = "SELECT CONCAT(v_contacts.contact_name_given, ' ', v_contacts.contact_name_family,' (',v_contact_phones.phone_type,')') AS name FROM v_contacts ";
|
||||
else
|
||||
sql = "SELECT v_contacts.contact_name_given || ' ' || v_contacts.contact_name_family || ' (' || v_contact_phones.phone_type || ')' AS name FROM v_contacts ";
|
||||
end
|
||||
|
||||
|
||||
sql = sql .. "INNER JOIN v_contact_phones ON v_contact_phones.contact_uuid = v_contacts.contact_uuid ";
|
||||
sql = sql .. "INNER JOIN v_destinations ON v_destinations.domain_uuid = v_contacts.domain_uuid ";
|
||||
sql = sql .. "WHERE v_contact_phones.phone_number = '"..caller.."' AND v_destinations.destination_number='"..callee.."'";
|
||||
|
||||
@@ -26,7 +26,10 @@
|
||||
digit_timeout = "5000";
|
||||
|
||||
--check if a file exists
|
||||
require "resources.functions.file_exists"
|
||||
function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
end
|
||||
|
||||
--run if the session is ready
|
||||
if ( session:ready() ) then
|
||||
|
||||
@@ -25,14 +25,18 @@
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim"
|
||||
--add a trim function
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--get the variables
|
||||
domain_name = session:getVariable("domain_name");
|
||||
|
||||
@@ -34,10 +34,12 @@
|
||||
db_extension_uuid = "";
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
if ( session:ready() ) then
|
||||
|
||||
@@ -34,14 +34,21 @@
|
||||
search_count = 0;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--settings
|
||||
require "resources.functions.settings";
|
||||
dofile(scripts_dir.."/resources/functions/settings.lua");
|
||||
settings = settings(domain_uuid);
|
||||
storage_type = "";
|
||||
storage_path = "";
|
||||
@@ -151,8 +158,16 @@
|
||||
end
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode"
|
||||
--define explode
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--define a function to convert dialpad letters to numbers
|
||||
function dialpad_to_digit(letter)
|
||||
@@ -185,11 +200,16 @@
|
||||
return count
|
||||
end
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim"
|
||||
--define trim
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--check if a file exists
|
||||
require "resources.functions.file_exists"
|
||||
function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
end
|
||||
|
||||
--define select_entry function
|
||||
function select_entry()
|
||||
@@ -248,7 +268,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(field)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the voicemail message path
|
||||
file_location = voicemail_dir.."/"..row.extension.."/recorded_name.wav";
|
||||
|
||||
@@ -27,10 +27,12 @@
|
||||
debug["sql"] = true;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
api = freeswitch.API();
|
||||
|
||||
@@ -27,16 +27,18 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
api = freeswitch.API();
|
||||
|
||||
--other libs
|
||||
require "resources.functions.trim";
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
|
||||
aleg_number = argv[1];
|
||||
bleg_number = argv[2];
|
||||
|
||||
@@ -26,11 +26,19 @@ predefined_destination = "";
|
||||
max_tries = "3";
|
||||
digit_timeout = "5000";
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
if ( session:ready() ) then
|
||||
session:answer( );
|
||||
|
||||
@@ -31,19 +31,29 @@ digit_timeout = "5000";
|
||||
debug["sql"] = true;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
api = freeswitch.API();
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
if ( session:ready() ) then
|
||||
session:answer( );
|
||||
|
||||
@@ -32,16 +32,28 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--create the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--check if the session is ready
|
||||
if ( session:ready() ) then
|
||||
@@ -70,7 +82,7 @@
|
||||
session:sleep(1000);
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--determine whether to update the dial string
|
||||
|
||||
@@ -28,10 +28,12 @@ digit_timeout = "5000";
|
||||
extension = argv[1];
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--add the file_exists function
|
||||
require "resources.functions.file_exists";
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
|
||||
--connect to the database
|
||||
if (file_exists(database_dir.."/core.db")) then
|
||||
@@ -39,7 +41,7 @@ extension = argv[1];
|
||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
||||
freeswitch.consoleLog("NOTICE", "[eavesdrop] using core.db\n");
|
||||
else
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('switch');
|
||||
freeswitch.consoleLog("NOTICE", "[eavesdrop] using freeswitch db\n");
|
||||
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
-- Riccardo Granchi <riccardo.granchi@nems.it>
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
if (session:ready()) then
|
||||
|
||||
@@ -31,17 +31,33 @@
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--array count
|
||||
require "resources.functions.count";
|
||||
function count(t)
|
||||
c = 0;
|
||||
for k,v in pairs(t) do
|
||||
c = c+1;
|
||||
end
|
||||
return c;
|
||||
end
|
||||
|
||||
-- show all channel variables
|
||||
--dat = env:serialize()
|
||||
@@ -125,7 +141,7 @@
|
||||
end
|
||||
|
||||
--settings
|
||||
require "resources.functions.settings";
|
||||
dofile(scripts_dir.."/resources/functions/settings.lua");
|
||||
settings = settings(domain_uuid);
|
||||
storage_type = "";
|
||||
storage_path = "";
|
||||
@@ -288,7 +304,7 @@
|
||||
if (fax_success =="1") then
|
||||
if (storage_type == "base64") then
|
||||
--include the base64 function
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--base64 encode the file
|
||||
local f = io.open(fax_file, "rb");
|
||||
|
||||
@@ -32,16 +32,28 @@
|
||||
debug["sql"] = true;
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--create the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--check if the session is ready
|
||||
if ( session:ready() ) then
|
||||
@@ -69,7 +81,7 @@
|
||||
session:sleep(1000);
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--determine whether to update the dial string
|
||||
|
||||
@@ -32,14 +32,16 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
if (file_exists(database_dir.."/core.db")) then
|
||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
||||
else
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('switch');
|
||||
end
|
||||
|
||||
@@ -47,7 +49,7 @@
|
||||
api = freeswitch.API();
|
||||
|
||||
--add the function
|
||||
require "resources.functions.trim";
|
||||
dofile(scripts_dir.."/resources/functions/trim.lua");
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
assert(dbh:connected());
|
||||
|
||||
@@ -31,13 +31,15 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--add the function
|
||||
require "resources.functions.explode";
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--check if the session is ready
|
||||
@@ -147,7 +149,7 @@
|
||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
||||
else
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('switch');
|
||||
end
|
||||
|
||||
|
||||
@@ -32,10 +32,12 @@
|
||||
debug["tries"] = false;
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--get the variables
|
||||
@@ -47,7 +49,7 @@
|
||||
domain_uuid = session:getVariable("domain_uuid");
|
||||
|
||||
--settings
|
||||
require "resources.functions.settings";
|
||||
dofile(scripts_dir.."/resources/functions/settings.lua");
|
||||
settings = settings(domain_uuid);
|
||||
storage_type = "";
|
||||
storage_path = "";
|
||||
@@ -84,11 +86,16 @@
|
||||
--set default variable(s)
|
||||
tries = 0;
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim"
|
||||
--add the trim function
|
||||
function trim(s)
|
||||
return s:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
end
|
||||
|
||||
--check if a file exists
|
||||
require "resources.functions.file_exists"
|
||||
function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
end
|
||||
|
||||
--prepare the api object
|
||||
api = freeswitch.API();
|
||||
@@ -212,7 +219,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
--add the path to filename
|
||||
ivr_menu_greet_long = recordings_dir.."/"..greet_long_file_name;
|
||||
ivr_menu_greet_long_is_base64 = true;
|
||||
@@ -236,7 +243,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
--add the path to filename
|
||||
ivr_menu_greet_short = recordings_dir.."/"..greet_short_file_name;
|
||||
ivr_menu_greet_short_is_base64 = true;
|
||||
@@ -260,7 +267,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
--add the path to filename
|
||||
ivr_menu_invalid_sound = recordings_dir.."/"..invalid_sound_file_name;
|
||||
ivr_menu_invalid_sound_is_base64 = true;
|
||||
@@ -284,7 +291,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
--add the path to filename
|
||||
ivr_menu_exit_sound = recordings_dir.."/"..exit_sound_file_name;
|
||||
ivr_menu_exit_sound_is_base64 = true;
|
||||
|
||||
@@ -31,11 +31,16 @@
|
||||
local file = assert(io.open(tmp_file, "w"));
|
||||
file:write("remove this file to stop the script");
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim"
|
||||
--add the trim function
|
||||
function trim(s)
|
||||
return s:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
end
|
||||
|
||||
--check if a file exists
|
||||
require "resources.functions.file_exists"
|
||||
function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
end
|
||||
|
||||
--create the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
@@ -28,11 +28,19 @@ pin_number = "";
|
||||
max_tries = "3";
|
||||
digit_timeout = "3000";
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
if ( session:ready() ) then
|
||||
session:answer();
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
--action lua park.lua
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/park.db");
|
||||
--require "resources.functions.database_handle";
|
||||
--dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
--dbh = database_handle('system');
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
@@ -38,11 +40,21 @@
|
||||
park_timeout_seconds = session:getVariable("park_timeout_seconds");
|
||||
park_music = session:getVariable("park_music");
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
--add the explode function
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
--add the trim function
|
||||
function trim(s)
|
||||
return s:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
end
|
||||
|
||||
--if park_timeout_seconds is not defined set the timeout to 5 minutes
|
||||
if (not park_timeout_seconds) then
|
||||
|
||||
@@ -29,12 +29,14 @@
|
||||
--then send presence terminate, and delete from the database
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/park.db");
|
||||
--require "resources.functions.database_handle";
|
||||
--dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
--get the argv values
|
||||
script_name = argv[0];
|
||||
@@ -48,8 +50,10 @@
|
||||
--prepare the api
|
||||
api = freeswitch.API();
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
--add a trim function
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--monitor the parking lot if the call has hungup send a terminated event, and delete from the db
|
||||
x = 0
|
||||
|
||||
@@ -27,11 +27,19 @@ digit_timeout = 5000;
|
||||
max_retries = 3;
|
||||
tries = 0;
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--define the explode function
|
||||
require "resources.functions.explode";
|
||||
function explode ( seperator, str )
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found
|
||||
table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider
|
||||
pos = sp + 1 -- jump past current divider
|
||||
end
|
||||
table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider
|
||||
return arr
|
||||
end
|
||||
|
||||
function check_pin_number()
|
||||
--sleep
|
||||
|
||||
@@ -34,24 +34,26 @@
|
||||
recording_prefix = "";
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--get the domain_uuid
|
||||
domain_uuid = session:getVariable("domain_uuid");
|
||||
|
||||
--add functions
|
||||
require "resources.functions.mkdir";
|
||||
require "resources.functions.explode";
|
||||
dofile(scripts_dir.."/resources/functions/mkdir.lua");
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
--initialize the recordings
|
||||
api = freeswitch.API();
|
||||
|
||||
--settings
|
||||
require "resources.functions.settings";
|
||||
dofile(scripts_dir.."/resources/functions/settings.lua");
|
||||
settings = settings(domain_uuid);
|
||||
storage_type = "";
|
||||
storage_path = "";
|
||||
@@ -125,7 +127,7 @@
|
||||
--begin recording
|
||||
if (storage_type == "base64") then
|
||||
--include the base64 function
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--make the directory
|
||||
mkdir(recordings_dir);
|
||||
|
||||
@@ -6,7 +6,7 @@ function base64.encode(s)
|
||||
local mime = require("mime");
|
||||
return (mime.b64(s));
|
||||
else
|
||||
require "resources.functions.base64_alex";
|
||||
dofile(scripts_dir.."/resources/functions/base64_alex.lua");
|
||||
return base64.enc(s);
|
||||
end
|
||||
end
|
||||
@@ -17,7 +17,7 @@ function base64.decode(s)
|
||||
local mime = require("mime");
|
||||
return (mime.unb64(s));
|
||||
else
|
||||
require "resources.functions.base64_alex";
|
||||
dofile(scripts_dir.."/resources/functions/base64_alex.lua");
|
||||
return base64.dec(s);
|
||||
end
|
||||
end
|
||||
@@ -1,26 +1,12 @@
|
||||
|
||||
-- add file_exists function
|
||||
require "resources.functions.file_exists";
|
||||
|
||||
--find and return path to the config.lua
|
||||
function config()
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
if (file_exists("/etc/fusionpbx/config.lua")) then
|
||||
return "/etc/fusionpbx/config.lua";
|
||||
elseif (file_exists("/usr/local/etc/fusionpbx/config.lua")) then
|
||||
return "/usr/local/etc/fusionpbx/config.lua";
|
||||
else
|
||||
return "resources.config";
|
||||
return scripts_dir.."/resources/config.lua";
|
||||
end
|
||||
end
|
||||
|
||||
-- load config
|
||||
function load_config()
|
||||
local cfg = config()
|
||||
if cfg:sub(1,1) == '//' then
|
||||
dofile(cfg)
|
||||
else
|
||||
require(cfg)
|
||||
end
|
||||
end
|
||||
|
||||
load_config()
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
--array count
|
||||
function count(t)
|
||||
local c = 0;
|
||||
for k in pairs(t) do
|
||||
c = c + 1;
|
||||
end
|
||||
return c;
|
||||
end
|
||||
@@ -2,8 +2,10 @@
|
||||
--debug
|
||||
debug["sql"] = false;
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
--define trim
|
||||
function trim (s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
--get the domain_uuid
|
||||
if (domain_uuid == nil) then
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
file_name = argv[1];
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
--get the variables
|
||||
@@ -23,7 +25,7 @@
|
||||
if (not default_voice) then default_voice = 'callie'; end
|
||||
|
||||
--settings
|
||||
require "resources.functions.settings";
|
||||
dofile(scripts_dir.."/resources/functions/settings.lua");
|
||||
settings = settings(domain_uuid);
|
||||
storage_type = "";
|
||||
storage_path = "";
|
||||
@@ -59,7 +61,10 @@
|
||||
end
|
||||
|
||||
--check if a file exists
|
||||
require "resources.functions.file_exists";
|
||||
function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
end
|
||||
|
||||
--define the on_dtmf call back function
|
||||
function on_dtmf(s, type, obj, arg)
|
||||
@@ -102,7 +107,7 @@
|
||||
end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
require "resources.functions.base64";
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
--add the path to filename
|
||||
file_name = recordings_dir.."/"..file_name_only;
|
||||
--save the recording to the file system
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
domain_name = argv[1];
|
||||
wakeup_number = argv[2];
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
--add the trim function
|
||||
function trim(s)
|
||||
return s:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
end
|
||||
|
||||
--add is_numeric
|
||||
function is_numeric(text)
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
These entries will be pre-pended to the LUA_PATH environment variable
|
||||
-->
|
||||
<!-- <param name="script-directory" value="/usr/local/lua/?.lua"/> -->
|
||||
<!-- <param name="script-directory" value="$${base_dir}/scripts/?.lua"/> -->
|
||||
|
||||
<param name="script-directory" value="$${base_dir}/scripts/?.lua"/>
|
||||
<param name="xml-handler-script" value="app.lua xml_handler"/>
|
||||
<param name="xml-handler-bindings" value="configuration,dialplan,directory"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user