Merge branch 'master' into number_alias_as_vm_id

Conflicts:
	app/hot_desking/extension_edit.php
This commit is contained in:
Alexey Melnichuk
2015-07-21 11:19:13 +04:00
79 changed files with 1168 additions and 1163 deletions

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Copyright (C) 2010-2014
Copyright (C) 2010-2015
All Rights Reserved.
Contributor(s):
@@ -35,16 +35,18 @@ include "root.php";
var $switch_scripts_dir;
var $switch_sounds_dir;
//$option '-n' --no-clobber
public function recursive_copy($src, $dst, $option = '') {
//$options '-n' --no-clobber
public function recursive_copy($src, $dst, $options = '') {
if (file_exists('/bin/cp')) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'SUN') {
//copy -R recursive, preserve attributes for SUN
exec ('cp -Rp '.$src.'/* '.$dst);
$cmd = 'cp -Rp '.$src.'/* '.$dst;
} else {
//copy -R recursive, -L follow symbolic links, -p preserve attributes for other Posix systemss
exec ('cp -RLp '.$option.' '.$src.'/* '.$dst);
$cmd = 'cp -RLp '.$options.' '.$src.'/* '.$dst;
}
exec ($cmd);
//echo $cmd."\n";
}
else {
$dir = opendir($src);
@@ -58,6 +60,23 @@ include "root.php";
throw new Exception("recursive_copy() failed to create destination directory '".$dst."'");
}
}
$scripts_dir_target = $_SESSION['switch']['scripts']['dir'];
$scripts_dir_source = realpath($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts');
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($src)) as $file_path_source) {
if (
substr_count($file_path_source, '/..') == 0 &&
substr_count($file_path_source, '/.') == 0 &&
substr_count($file_path_source, '/.svn') == 0 &&
substr_count($file_path_source, '/.git') == 0
) {
if ($dst != $src.'/resources/config.lua') {
//echo $file_path_source.' ---> '.$dst.'<br>';
copy($file_path_source, $dst);
chmod($dst, 0755);
}
}
}
while(false !== ($file = readdir($dir))) {
if (($file != '.') && ($file != '..')) {
if (is_dir($src.'/'.$file)) {
@@ -65,7 +84,7 @@ include "root.php";
}
else {
//copy only missing files -n --no-clobber
if ($option == '-n') {
if (strpos($options,'-n') !== false) {
if (!file_exists($dst.'/'.$file)) {
copy($src.'/'.$file, $dst.'/'.$file);
//echo "copy(".$src."/".$file.", ".$dst."/".$file.");<br />\n";
@@ -126,12 +145,10 @@ include "root.php";
}
}
//copy resources/templates/conf to the freeswitch conf dir
// added /examples/ into the string
if (file_exists('/usr/share/examples/fusionpbx/resources/templates/conf')){
$src_dir = "/usr/share/examples/fusionpbx/resources/templates/conf";
}
else {
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/conf";
}
$dst_dir = $this->switch_conf_dir;
@@ -152,7 +169,7 @@ include "root.php";
}
$dst_dir = $this->switch_scripts_dir;
if (is_readable($this->switch_scripts_dir)) {
$this->recursive_copy($src_dir, $dst_dir, "-n");
$this->recursive_copy($src_dir, $dst_dir, $_SESSION['scripts']['options']['text']);
unset($src_dir, $dst_dir);
}
chmod($dst_dir, 0774);

View File

@@ -1038,8 +1038,9 @@ function number_pad($number,$n) {
if ($file != '.' && $file != '..') {
$newpath = $dir.'/'.$file;
$level = explode('/',$newpath);
if (substr($newpath, -4) == ".svn") {
//ignore .svn dir and subdir
if (substr($newpath, -4) == ".svn" ||
substr($newpath, -4) == ".git") {
//ignore .svn and .git dir and subdir
}
else {
if (is_dir($newpath)) { //directories

View File

@@ -47,17 +47,10 @@ require_once "resources/functions.php";
//set the default time zone
date_default_timezone_set('UTC');
//get the domain
$domain_array = explode(":", $_SERVER["HTTP_HOST"]);
$domain_name = $domain_array[0];
//if the config file exists then disable the install page
$config_exists = false;
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) {
$config_exists = true;
} elseif (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) {
//original directory
$config_exists = true;
} elseif (file_exists("/etc/fusionpbx/config.php")) {
//linux
$config_exists = true;
@@ -86,6 +79,7 @@ require_once "resources/functions.php";
$db_host = $_POST["db_host"];
$db_port = $_POST["db_port"];
$db_name = $_POST["db_name"];
$domain_name = $_POST["domain_name"];
$db_username = $_POST["db_username"];
$db_password = $_POST["db_password"];
$db_create_username = $_POST["db_create_username"];
@@ -98,6 +92,12 @@ require_once "resources/functions.php";
$install_default_country = $_POST["install_default_country"];
$install_template_name = $_POST["install_template_name"];
if(!$domain_name){
//get the domain
$domain_array = explode(":", $_SERVER["HTTP_HOST"]);
$domain_name = $domain_array[0];
}
//clean up the values
if (strlen($install_switch_base_dir) > 0) {
$install_switch_base_dir = realpath($install_switch_base_dir);
@@ -813,7 +813,7 @@ if ($_POST["install_step"] == "3" && count($_POST) > 0 && strlen($_POST["persist
else {
$filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/mysql.sql';
}
$file_contents = file_get_contents($filename);
$file_contents = file_get_contents($filename);
//replace \r\n with \n then explode on \n
$file_contents = str_replace("\r\n", "\n", $file_contents);
@@ -883,7 +883,7 @@ if ($_POST["install_step"] == "3" && count($_POST) > 0 && strlen($_POST["persist
$tmp[$x]['subcategory'] = 'time_zone';
$tmp[$x]['enabled'] = 'true';
$x++;
$tmp[$x]['name'] = 'code';
$tmp[$x]['name'] = 'code';
$tmp[$x]['value'] = 'en-us';
$tmp[$x]['category'] = 'domain';
$tmp[$x]['subcategory'] = 'language';
@@ -953,19 +953,19 @@ if ($_POST["install_step"] == "3" && count($_POST) > 0 && strlen($_POST["persist
$tmp[$x]['value'] = $switch_extensions_dir;
$tmp[$x]['category'] = 'switch';
$tmp[$x]['subcategory'] = 'extensions';
$tmp[$x]['enabled'] = 'true';
$tmp[$x]['enabled'] = 'false';
$x++;
$tmp[$x]['name'] = 'dir';
$tmp[$x]['value'] = $switch_sip_profiles_dir;
$tmp[$x]['category'] = 'switch';
$tmp[$x]['subcategory'] = 'sip_profiles';
$tmp[$x]['enabled'] = 'true';
$tmp[$x]['enabled'] = 'false';
$x++;
$tmp[$x]['name'] = 'dir';
$tmp[$x]['value'] = $switch_dialplan_dir;
$tmp[$x]['category'] = 'switch';
$tmp[$x]['subcategory'] = 'dialplan';
$tmp[$x]['enabled'] = 'true';
$tmp[$x]['enabled'] = 'false';
$x++;
$tmp[$x]['name'] = 'dir';
$tmp[$x]['value'] = $switch_mod_dir;
@@ -1236,7 +1236,7 @@ if ($_POST["install_step"] == "3" && count($_POST) > 0 && strlen($_POST["persist
$db->exec(check_sql($sql));
unset($sql);
//add the menu items
//add the menu items
require_once "resources/classes/menu.php";
$menu = new menu;
$menu->db = $db;
@@ -1745,7 +1745,7 @@ EOL;
$theme_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes')) {
while (false !== ($dir_name = readdir($handle))) {
if ($dir_name != "." && $dir_name != ".." && $dir_name != ".svn" && is_readable($theme_dir.'/'.$dir_name)) {
if ($dir_name != "." && $dir_name != ".." && $dir_name != ".svn" && $dir_name != ".git" && is_readable($theme_dir.'/'.$dir_name)) {
$dir_label = str_replace('_', ' ', $dir_name);
$dir_label = str_replace('-', ' ', $dir_label);
if ($dir_name == $install_template_name) {
@@ -1764,6 +1764,17 @@ EOL;
echo " </td>\n";
echo " </tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " Domain name\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='domain_name' maxlength='255' value=\"$domain_name\"><br />\n";
echo " Enter the default domain name. \n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
echo " <input type='hidden' name='install_switch_base_dir' value='$install_switch_base_dir'>\n";
@@ -1816,6 +1827,7 @@ EOL;
echo " <input type='hidden' name='db_type' value='$db_type'>\n";
echo " <input type='hidden' name='admin_username' value='$admin_username'>\n";
echo " <input type='hidden' name='admin_password' value='$admin_password'>\n";
echo " <input type='hidden' name='domain_name' value='$domain_name'>\n";
echo " <input type='hidden' name='install_switch_base_dir' value='$install_switch_base_dir'>\n";
echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
echo " <input type='hidden' name='install_backup_dir' value='$install_backup_dir'>\n";
@@ -1931,6 +1943,7 @@ EOL;
echo " <input type='hidden' name='db_type' value='$db_type'>\n";
echo " <input type='hidden' name='admin_username' value='$admin_username'>\n";
echo " <input type='hidden' name='admin_password' value='$admin_password'>\n";
echo " <input type='hidden' name='domain_name' value='$domain_name'>\n";
echo " <input type='hidden' name='install_switch_base_dir' value='$install_switch_base_dir'>\n";
echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
echo " <input type='hidden' name='install_backup_dir' value='$install_backup_dir'>\n";
@@ -2044,6 +2057,7 @@ EOL;
echo " <input type='hidden' name='db_type' value='$db_type'>\n";
echo " <input type='hidden' name='admin_username' value='$admin_username'>\n";
echo " <input type='hidden' name='admin_password' value='$admin_password'>\n";
echo " <input type='hidden' name='domain_name' value='$domain_name'>\n";
echo " <input type='hidden' name='install_switch_base_dir' value='$install_switch_base_dir'>\n";
echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
echo " <input type='hidden' name='install_backup_dir' value='$install_backup_dir'>\n";

View File

@@ -300,6 +300,14 @@
delimiter = ":_:";
end
--leg delay settings
if (ring_group_strategy == "enterprise") then
delay_name = "originate_delay_start";
destination_delay = destination_delay * 1000;
else
delay_name = "leg_delay_start";
end
--create a new uuid and add it to the uuid list
new_uuid = api:executeString("create_uuid");
if (string.len(uuids) == 0) then
@@ -370,24 +378,24 @@
reply = trim(api:executeString(cmd));
--freeswitch.consoleLog("notice", "[ring group] reply "..cmd.." " .. reply .. "\n");
if (reply == "0 total.") then
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..",leg_delay_start="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid="..extension_uuid.."]user/" .. row.destination_number .. "@" .. domain_name;
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..","..delay_name.."="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid="..extension_uuid.."]user/" .. row.destination_number .. "@" .. domain_name;
else
if (string.find(reply, domain_name)) then
--active call
else
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..",leg_delay_start="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid="..extension_uuid.."]user/" .. row.destination_number .. "@" .. domain_name;
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..","..delay_name.."="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid="..extension_uuid.."]user/" .. row.destination_number .. "@" .. domain_name;
end
end
else
--look inside the reply to check for the correct domain_name
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..",leg_delay_start="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid="..extension_uuid.."]user/" .. row.destination_number .. "@" .. domain_name;
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..","..delay_name.."="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid="..extension_uuid.."]user/" .. row.destination_number .. "@" .. domain_name;
end
else
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..",leg_delay_start="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid="..extension_uuid.."]user/" .. row.destination_number .. "@" .. domain_name;
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..","..delay_name.."="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid="..extension_uuid.."]user/" .. row.destination_number .. "@" .. domain_name;
end
elseif (tonumber(destination_number) == nil) then
--sip uri
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..",leg_delay_start="..destination_delay.."]" .. row.destination_number;
dial_string = "[sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..","..delay_name.."="..destination_delay.."]" .. row.destination_number;
else
--external number
y = 0;
@@ -417,7 +425,7 @@
dialplan_detail_data = r.dialplan_detail_data:gsub("$1", destination_result);
--if the session is set then process the actions
if (y == 0) then
square = "[domain_name="..domain_name..",domain_uuid="..domain_uuid..",sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..",leg_delay_start="..destination_delay..",ignore_early_media=true,";
square = "[domain_name="..domain_name..",domain_uuid="..domain_uuid..",sip_invite_domain="..domain_name..","..group_confirm.."leg_timeout="..destination_timeout..","..delay_name.."="..destination_delay..",ignore_early_media=true,";
end
if (r.dialplan_detail_type == "set") then
--session:execute("eval", dialplan_detail_data);

View File

@@ -447,7 +447,11 @@
--copy the voicemail to each destination
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then
os.execute("cp "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext.." "..voicemail_dir.."/"..voicemail_id_copy.."/msg_"..voicemail_message_uuid.."."..vm_message_ext);
local src = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext
local dst = voicemail_dir.."/"..voicemail_id_copy.."/msg_"..voicemail_message_uuid.."."..vm_message_ext
if src ~= dst then
copy(src, dst)
end
end
--send the message waiting event

View File

@@ -31,13 +31,11 @@
--Please enter your id followed by
if (name == "voicemail_id") then
table.insert(actions, {app="streamFile",data="voicemail/vm-enter_id.wav"});
table.insert(actions, {app="streamFile",data="digits/pound.wav"});
table.insert(actions, {app="streamFile",data="phrase:voicemail_enter_id:#"});
end
--Please enter your id followed by
if (name == "voicemail_password") then
table.insert(actions, {app="streamFile",data="voicemail/vm-enter_pass.wav"});
table.insert(actions, {app="streamFile",data="digits/pound.wav"});
table.insert(actions, {app="streamFile",data="phrase:voicemail_enter_pass:#"});
end
--the person at extension 101 is not available record your message at the tone press any key or stop talking to end the recording
if (name == "person_not_available_record_message") then
@@ -74,25 +72,11 @@
end
--You have zero new messages
if (name == "new_messages") then
table.insert(actions, {app="streamFile",data="voicemail/vm-you_have.wav"});
table.insert(actions, {app="say.number.pronounced",data=param});
table.insert(actions, {app="streamFile",data="voicemail/vm-new.wav"});
if (param == "1") then
table.insert(actions, {app="streamFile",data="voicemail/vm-message.wav"});
else
table.insert(actions, {app="streamFile",data="voicemail/vm-messages.wav"});
end
table.insert(actions, {app="streamFile",data="phrase:voicemail_message_count:" .. param .. ":new"})
end
--You have zero saved messages
if (name == "saved_messages") then
table.insert(actions, {app="streamFile",data="voicemail/vm-you_have.wav"});
table.insert(actions, {app="say.number.pronounced",data=param});
table.insert(actions, {app="streamFile",data="voicemail/vm-saved.wav"});
if (param == "1") then
table.insert(actions, {app="streamFile",data="voicemail/vm-message.wav"});
else
table.insert(actions, {app="streamFile",data="voicemail/vm-messages.wav"});
end
table.insert(actions, {app="streamFile",data="phrase:voicemail_message_count:" .. param .. ":saved"})
end
--To listen to new messages press 1
if (name == "listen_to_new_messages") then
@@ -276,11 +260,15 @@
timeout = 100;
--loop through the action and data
for key, row in pairs(actions) do
--freeswitch.consoleLog("notice", "[voicemail] app: " .. row.app .. " data: " .. row.data .. "\n");
-- freeswitch.consoleLog("notice", "[voicemail] app: " .. row.app .. " data: " .. row.data .. "\n");
if (session:ready()) then
if (string.len(dtmf_digits) == 0) then
if (row.app == "streamFile") then
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..row.data);
if string.find(row.data, ':', nil, true) then
session:streamFile(row.data);
else
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..row.data);
end
elseif (row.app == "playback") then
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..row.data);
elseif (row.app == "tone_stream") then

View File

@@ -49,6 +49,7 @@
elseif (message_status == "saved") then
sql = sql .. [[AND message_status = 'saved' ]];
end
sql = sql .. [[ORDER BY created_epoch desc;]];
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
end

View File

@@ -143,26 +143,24 @@
body = body:gsub("&nbsp;", " ");
body = body:gsub("\n", "");
body = body:gsub("\n", "");
body = body:gsub("'", "&#39;");
body = body:gsub([["]], "&#34;");
body = trim(body);
--send the email
file = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
if (voicemail_file == "attach") then
if (voicemail_local_after_email == "false") then
delete = "true";
else
delete = "false";
end
cmd = "luarun email.lua "..voicemail_mail_to.." "..voicemail_mail_to.." "..headers.." '"..subject.."' '"..body.."' '"..file.."' "..delete;
freeswitch.email("",
"",
"To: "..voicemail_mail_to.."\nFrom: "..voicemail_mail_to.."\nX-Headers: "..headers.."\nSubject: "..subject,
body,
file
);
else
cmd = "luarun email.lua "..voicemail_mail_to.." "..voicemail_mail_to.." "..headers.." '"..subject.."' '"..body.."'";
freeswitch.email("",
"",
"To: "..voicemail_mail_to.."\nFrom: "..voicemail_mail_to.."\nX-Headers: "..headers.."\nSubject: "..subject,
body
);
end
if (debug["info"]) then
freeswitch.consoleLog("notice", "[voicemail] cmd: " .. cmd .. "\n");
end
result = api:executeString(cmd);
end
--whether to keep the voicemail message and details local after email

View File

@@ -304,7 +304,7 @@
--send the xml to the console
if (debug["xml_string"]) then
local file = assert(io.open("/tmp/dialplan-" .. call_context .. ".xml", "w"));
local file = assert(io.open(temp_dir .. "/dialplan-" .. call_context .. ".xml", "w"));
file:write(XML_STRING);
file:close();
end

View File

@@ -254,7 +254,7 @@
else
--set a default dial string
if (dial_string == null) then
dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. user .. "@" .. domain_name .. "}${sofia_contact(" .. user .. "@" .. domain_name .. ")}";
dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. user .. "@" .. domain_name .. "}${sofia_contact(" .. extension .. "@" .. domain_name .. ")}";
end
--set the an alternative dial string if the hostnames don't match
if (load_balancing) then
@@ -360,10 +360,10 @@
table.insert(xml, [[ <param name="auth-acl" value="]] .. auth_acl .. [["/>]]);
end
table.insert(xml, [[ <param name="dial-string" value="]] .. dial_string .. [["/>]]);
table.insert(xml, [[ <param name="verto-context" value="]] .. user_context .. [["/>]]);
table.insert(xml, [[ <param name="verto-dialplan" value="XML"/>]]);
table.insert(xml, [[ <param name="jsonrpc-allowed-methods" value="verto"/>]]);
table.insert(xml, [[ <param name="jsonrpc-allowed-event-channels" value="demo,conference,presence"/>]]);
table.insert(xml, [[ <param name="verto-context" value="]] .. user_context .. [["/>]]);
table.insert(xml, [[ <param name="verto-dialplan" value="XML"/>]]);
table.insert(xml, [[ <param name="jsonrpc-allowed-methods" value="verto"/>]]);
table.insert(xml, [[ <param name="jsonrpc-allowed-event-channels" value="demo,conference,presence"/>]]);
table.insert(xml, [[ </params>]]);
table.insert(xml, [[ <variables>]]);
table.insert(xml, [[ <variable name="domain_uuid" value="]] .. domain_uuid .. [["/>]]);

View File

@@ -209,6 +209,8 @@
if (session:ready() and enabled == "true") then
--set forward_all_enabled
forward_all_enabled = "true";
--say the destination number
session:say(forward_all_destination, default_language, "number", "iterated");
--notify the caller
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav");
end

View File

@@ -65,9 +65,11 @@
if (not default_voice) then default_voice = 'callie'; end
--if the screen file is found then set confirm to true
call_screen_file = "/tmp/" .. domain_name .. "-" .. caller_id_number .. "." .. record_ext;
if (file_exists(call_screen_file)) then
confirm = "true";
if (domain_name ~= nil) then
call_screen_file = "/tmp/" .. domain_name .. "-" .. caller_id_number .. "." .. record_ext;
if (file_exists(call_screen_file)) then
confirm = "true";
end
end
--confirm the calls
@@ -104,4 +106,4 @@
--send to the log
--freeswitch.consoleLog("NOTICE", "[confirm] automatically accepted\n");
end
end
end

View File

@@ -67,6 +67,8 @@ if ( session:ready() ) then
if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end
local conf_name = "page-"..destination_number.."%"..domain_name.."@page"
if (caller_id_name) then
--caller id name provided do nothing
else
@@ -82,14 +84,10 @@ if ( session:ready() ) then
end
--set conference flags
if (mute) then
if (mute == "false") then
flags = "flags{}";
else
flags = "flags{mute}";
end
else
if (mute == "true") then
flags = "flags{mute}";
else
flags = "flags{}";
end
--if the pin number is provided then require it
@@ -129,7 +127,7 @@ if ( session:ready() ) then
sub_table = explode("-",value);
for destination=sub_table[1],sub_table[2] do
--get the destination required for number-alias
destination = api:execute("user_data", destination .. "@" .. domain_name .. " attr id");
destination = api:execute("user_data", destination .. "@" .. domain_name .. " attr id");
--prevent calling the user that initiated the page
if (sip_from_user ~= destination) then
@@ -139,12 +137,12 @@ if ( session:ready() ) then
destination_status = "show channels like "..destination.."@";
reply = trim(api:executeString(destination_status));
if (reply == "0 total.") then
--freeswitch.consoleLog("NOTICE", "destination "..destination.." available\n");
freeswitch.consoleLog("NOTICE", "[page] destination "..destination.." available\n");
if (destination == tonumber(sip_from_user)) then
--this destination is the caller that initated the page
else
--originate the call
cmd_string = "bgapi originate {sip_auto_answer=true,sip_h_Alert-Info='Ring Answer',hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:page-"..destination_number.."@page+"..flags.." inline";
cmd_string = "bgapi originate {sip_auto_answer=true,sip_h_Alert-Info='Ring Answer',hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:"..conf_name.."+"..flags.." inline";
api:executeString(cmd_string);
destination_count = destination_count + 1;
end
@@ -159,7 +157,7 @@ if ( session:ready() ) then
--this destination is the caller that initated the page
else
--originate the call
cmd_string = "bgapi originate {sip_auto_answer=true,hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:page-"..destination_number.."@page+"..flags.." inline";
cmd_string = "bgapi originate {sip_auto_answer=true,hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:"..conf_name.."+"..flags.." inline";
api:executeString(cmd_string);
destination_count = destination_count + 1;
end
@@ -172,12 +170,12 @@ if ( session:ready() ) then
--send main call to the conference room
if (destination_count > 0) then
if (session:getVariable("moderator") ~= nil and session:getVariable("moderator") == "true") then
if (session:getVariable("moderator") == "true") then
moderator_flag = ",moderator";
else
moderator_flag = "";
end
session:execute("conference", "page-"..destination_number.."@page+flags{endconf"..moderator_flag.."}");
session:execute("conference", conf_name.."+flags{endconf"..moderator_flag.."}");
else
session:execute("playback", "tone_stream://%(500,500,480,620);loops=3");
end

View File

@@ -52,6 +52,7 @@
--get the default settings
sql = "SELECT * FROM v_default_settings ";
sql = sql .. "WHERE default_setting_enabled = 'true' ";
sql = sql .. "AND default_setting_value is not null ";
sql = sql .. "ORDER BY default_setting_category, default_setting_subcategory ASC";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "SQL: " .. sql .. "\n");
@@ -65,7 +66,7 @@
subcategory = row.default_setting_subcategory;
name = row.default_setting_name;
value = row.default_setting_value;
--add the category array
if (previous_category ~= category) then
array[category] = {}
@@ -100,6 +101,7 @@
sql = "SELECT * FROM v_domain_settings ";
sql = sql .. "WHERE domain_uuid = '" .. domain_uuid .. "' ";
sql = sql .. "AND domain_setting_enabled = 'true' ";
sql = sql .. "AND domain_setting_value is not null ";
sql = sql .. "ORDER BY domain_setting_category, domain_setting_subcategory ASC ";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[directory] SQL: " .. sql .. "\n");

View File

@@ -322,9 +322,7 @@ function event_socket_request($fp, $cmd) {
}
fputs($fp, "\n"); //second line feed to end the headers
usleep(100); //allow time for reponse
$response = "";
$response = '';
$i = 0;
$content_length = 0;
while (!feof($fp)) {
@@ -342,17 +340,16 @@ function event_socket_request($fp, $cmd) {
}
}
usleep(50); //allow time for reponse
//prevent an endless loop //optional because of script timeout
if ($i > 30000) { break; }
if ($content_length > 0) { //is content_length set
//stop reading if all content has been read.
if (strlen($response) >= $content_length) {
break;
}
}
else {
//prevent an endless loop
if ($i > 300000) { break; }
}
$i++;
}
@@ -364,6 +361,8 @@ function event_socket_request($fp, $cmd) {
}
function event_socket_request_cmd($cmd) {
global $db, $domain_uuid, $host;
@@ -2547,12 +2546,15 @@ if (!function_exists('save_sip_profile_xml')) {
return;
}
// make profile dir if needed
$profile_dir = $_SESSION['switch']['conf']['dir']."/sip_profiles";
if (!is_readable($profile_dir)) { mkdir($profile_dir,0775,true); }
//get the global variables
global $db, $domain_uuid;
//get the sip profiles from the database
$sql = "select * from v_sip_profiles ";
$sql .= "where sip_profile_enabled = 'true' ";
$sql = "select * from v_sip_profiles";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll();
@@ -2560,8 +2562,17 @@ if (!function_exists('save_sip_profile_xml')) {
unset ($prep_statement, $sql);
if ($result_count > 0) {
foreach($result as $row) {
$sip_profile_uuid = $row['sip_profile_uuid'];
$sip_profile_name = $row['sip_profile_name'];
$sip_profile_uuid = $row['sip_profile_uuid'];
$sip_profile_name = $row['sip_profile_name'];
$sip_profile_enabled = $row['sip_profile_enabled'];
if ($sip_profile_enabled == 'false') {
$fout = fopen($profile_dir.'/'.$sip_profile_name.".xml","w");
if ($fout) {
fclose($fout);
}
continue;
}
//get the xml sip profile template
if ($sip_profile_name == "internal" || $sip_profile_name == "external" || $sip_profile_name == "internal-ipv6") {
@@ -2589,14 +2600,14 @@ if (!function_exists('save_sip_profile_xml')) {
$file_contents = str_replace("{v_sip_profile_settings}", $sip_profile_settings, $file_contents);
//write the XML config file
if (is_readable($_SESSION['switch']['conf']['dir']."/sip_profiles/")) {
$fout = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name.".xml","w");
if (is_readable($profile_dir.'/')) {
$fout = fopen($profile_dir.'/'.$sip_profile_name.".xml","w");
fwrite($fout, $file_contents);
fclose($fout);
}
//if the directory does not exist then create it
if (!is_readable($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name)) { mkdir($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name,0775,true); }
if (!is_readable($profile_dir.'/'.$sip_profile_name)) { mkdir($profile_dir.'/'.$sip_profile_name,0775,true); }
} //end foreach
unset($sql, $result, $row_count);

View File

@@ -15,8 +15,8 @@
<!-- <param name="script-directory" value="/usr/local/lua/?.lua"/> -->
<!-- <param name="script-directory" value="$${base_dir}/scripts/?.lua"/> -->
<!--<param name="xml-handler-script" value="/dp.lua"/>-->
<!--<param name="xml-handler-bindings" value="dialplan"/>-->
<param name="xml-handler-script" value="app.lua xml_handler"/>
<param name="xml-handler-bindings" value="configuration,dialplan,directory"/>
<!--
The following options identifies a lua script that is launched

View File

@@ -180,7 +180,7 @@
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_cache as $_file) {
if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false || strpos($_file, '.git') !== false) continue;
// directory ?
if ($_file->isDir()) {
if (!$_cache->isDot()) {

View File

@@ -72,7 +72,7 @@ class Smarty_Internal_Utility
$_compile = new RecursiveIteratorIterator($_compileDirs);
foreach ($_compile as $_fileinfo) {
$_file = $_fileinfo->getFilename();
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false || strpos($_file, '.git') !== false) continue;
if (!substr_compare($_file, $extension, - strlen($extension)) == 0) continue;
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
$_template_file = $_file;
@@ -136,7 +136,7 @@ class Smarty_Internal_Utility
$_compile = new RecursiveIteratorIterator($_compileDirs);
foreach ($_compile as $_fileinfo) {
$_file = $_fileinfo->getFilename();
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false || strpos($_file, '.git') !== false) continue;
if (!substr_compare($_file, $extension, - strlen($extension)) == 0) continue;
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
$_config_file = $_file;
@@ -230,8 +230,7 @@ class Smarty_Internal_Utility
}
$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_compile as $_file) {
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false)
continue;
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false || strpos($_file, '.git') !== false) continue;
$_filepath = (string) $_file;

View File

@@ -1190,7 +1190,7 @@
<!-- Primary SIP Server -->
<!-- String: serveraddress -->
<P747>{#server_address_2}</P747>
<P747>{$server_address_2}</P747>
<!-- Failover SIP Server -->
<!-- String: serveraddress -->