From 60b0f48228bfde13dce12ab6e122136c62e5dd5a Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 10 Sep 2015 14:23:11 +0400 Subject: [PATCH 01/64] Add. database class ```Lua local Database = require "resources.functions.database" local dbh = Database.new('system') --get the domain_uuid if (domain_uuid == nil) and (domain_name ~= nil) then local sql = "SELECT domain_uuid FROM v_domains " sql = sql .. "WHERE domain_name='" .. domain_name .. "';" domain_uuid = dbh:first_value(sql) end local dbh_switch = Database.new('switch') -- check also SQLite file. local row = dbh_switch:first_row(sql) if row then ... end ``` --- .../scripts/resources/functions/database.lua | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 resources/install/scripts/resources/functions/database.lua diff --git a/resources/install/scripts/resources/functions/database.lua b/resources/install/scripts/resources/functions/database.lua new file mode 100644 index 0000000000..a8f7f662c6 --- /dev/null +++ b/resources/install/scripts/resources/functions/database.lua @@ -0,0 +1,107 @@ +require 'resources.config' +require 'resources.functions.database_handle' + +local unpack = unpack or table.unpack + +local Database = {} do + +Database.__index = Database + +function Database.new(name) + local dbh = assert(name) + if type(name) == 'string' then + if name == 'switch' and file_exists(database_dir.."/core.db") then + dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db") + else + dbh = database_handle(name) + end + end + assert(dbh:connected()) + + local self = setmetatable({ + _dbh = dbh; + }, Database) + + return self +end + +function Database:query(sql, fn) + return self._dbh:query(sql, fn) +end + +function Database:first_row(sql) + local result + local ok, err = self:query(sql, function(row) + result = row + return 1 + end) + if not ok then return nil, err end + return result +end + +function Database:first_value(sql) + local result, err = self:first_row(sql) + if not result then return nil, err end + local k, v = next(result) + return v +end + +function Database:first(sql, ...) + local result, err = self:first_row(sql) + if not result then return nil, err end + local t, n = {}, select('#', ...) + for i = 1, n do + t[i] = result[(select(i, ...))] + end + return unpack(t, 1, n) +end + +function Database:fetch_all(sql) + local result = {} + local ok, err = self:query(sql, function(row) + result[#result + 1] = row + end) + if not ok then return nil, err end + return result +end + +function Database:release(sql) + if self._dbh then + self._dbh:release() + self._dbh = nil + end +end + +function Database:connected(sql) + return self._dbh and self._dbh:connected() +end + +function Database.__self_test__() + local db = Database.new('system') + assert(db:connected()) + + assert("1" == db:first_value("select 1 as v")) + + local t = assert(db:first_row("select 1 as v")) + assert(t.v == "1") + + t = assert(db:fetch_all("select 1 as v union all select 2 as v")) + assert(#t == 2) + assert(t[1].v == "1") + assert(t[2].v == "2") + + local a, b = assert(db:first("select 1 as b, 2 as a", 'a', 'b')) + assert(a == "2") + assert(b == "1") + + -- assert(nil == db:first_value("some non sql query")) + + db:release() + assert(not db:connected()) +end + +end + +-- Database.__self_test__() + +return Database \ No newline at end of file From d146029f59329705ae6e68a79f7336b882c2d838 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 10 Sep 2015 14:36:30 +0400 Subject: [PATCH 02/64] Fix. load `file_exists` function --- resources/install/scripts/resources/functions/database.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/resources/functions/database.lua b/resources/install/scripts/resources/functions/database.lua index a8f7f662c6..50349b1b14 100644 --- a/resources/install/scripts/resources/functions/database.lua +++ b/resources/install/scripts/resources/functions/database.lua @@ -1,4 +1,5 @@ require 'resources.config' +require 'resources.functions.file_exists' require 'resources.functions.database_handle' local unpack = unpack or table.unpack @@ -76,8 +77,8 @@ function Database:connected(sql) return self._dbh and self._dbh:connected() end -function Database.__self_test__() - local db = Database.new('system') +function Database.__self_test__(name) + local db = Database.new(name or 'system') assert(db:connected()) assert("1" == db:first_value("select 1 as v")) From 8f93d4d548778e5167c866b7e975a0f9e6e0f774 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 26 Sep 2015 08:56:44 -0600 Subject: [PATCH 03/64] Dialplan page add mute=true back again. --- app/dialplan/resources/switch/conf/dialplan/240_page.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/dialplan/resources/switch/conf/dialplan/240_page.xml b/app/dialplan/resources/switch/conf/dialplan/240_page.xml index 0c080a2213..35b75b6470 100644 --- a/app/dialplan/resources/switch/conf/dialplan/240_page.xml +++ b/app/dialplan/resources/switch/conf/dialplan/240_page.xml @@ -6,6 +6,7 @@ + From b27bcdd820544fe1e130cdfe9694dc8927ee2d83 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 26 Sep 2015 08:59:36 -0600 Subject: [PATCH 04/64] After event socket class was added it created a bug in FAX email and forward. It was unable to find the new EventSocket class adding the include resolves the problem. --- .../install/scripts/app/fax/resources/scripts/hangup_rx.lua | 3 +++ secure/fax_to_email.php | 1 + 2 files changed, 4 insertions(+) diff --git a/resources/install/scripts/app/fax/resources/scripts/hangup_rx.lua b/resources/install/scripts/app/fax/resources/scripts/hangup_rx.lua index d70db541e9..81ac0ffd13 100644 --- a/resources/install/scripts/app/fax/resources/scripts/hangup_rx.lua +++ b/resources/install/scripts/app/fax/resources/scripts/hangup_rx.lua @@ -22,6 +22,9 @@ -- Contributor(s): -- Mark J. Crane +--set the debug options + debug["sql"] = false; + --create the api object api = freeswitch.API(); diff --git a/secure/fax_to_email.php b/secure/fax_to_email.php index a9d4269836..415428e10d 100644 --- a/secure/fax_to_email.php +++ b/secure/fax_to_email.php @@ -40,6 +40,7 @@ if (defined('STDIN')) { //includes if (!defined('STDIN')) { include "root.php"; } require_once "resources/require.php"; + include "resources/classes/EventSocket.php"; include "resources/phpmailer/class.phpmailer.php"; include "resources/phpmailer/class.smtp.php"; // optional, gets called from within class.phpmailer.php if not already loaded From 0ea162ae8c27f168b2ed5cfb9b90c0e3dc8affd7 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 26 Sep 2015 11:39:16 -0600 Subject: [PATCH 05/64] Update domain setting handling in fax to email. --- secure/fax_to_email.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/secure/fax_to_email.php b/secure/fax_to_email.php index 415428e10d..6972b225b9 100644 --- a/secure/fax_to_email.php +++ b/secure/fax_to_email.php @@ -132,7 +132,14 @@ if (defined('STDIN')) { $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as &$row) { - $_SESSION["domain_uuid"] = $row["domain_uuid"]; + //set the domain variables + $domain_uuid = $row["domain_uuid"]; + $_SESSION["domain_uuid"] = $row["domain_uuid"]; + $_SESSION["domain_name"] = $domain_name; + //set the setting arrays + $domain = new domains(); + $domain->db = $db; + $domain->set(); } unset ($prep_statement); From b374e5bdc518b8b9dd339e31feba2f0bdaea1469 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 27 Sep 2015 00:52:47 -0600 Subject: [PATCH 06/64] Fix the ring group missed call email body. --- resources/install/scripts/app/ring_groups/index.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 3a99d108af..545f5ecc68 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -12,7 +12,7 @@ -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- --- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +-- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, @@ -101,6 +101,7 @@ local log = require "resources.functions.log".ring_group status = dbh:query(sql, function(row) domain_uuid = row["domain_uuid"]; ring_group_name = row["ring_group_name"]; + ring_group_extension = row["ring_group_extension"]; ring_group_forward_enabled = row["ring_group_forward_enabled"]; ring_group_forward_destination = row["ring_group_forward_destination"]; ring_group_cid_name_prefix = row["ring_group_cid_name_prefix"]; @@ -152,6 +153,9 @@ local log = require "resources.functions.log".ring_group subject = subject:gsub("${caller_id_name}", caller_id_name); subject = subject:gsub("${caller_id_number}", caller_id_number); subject = subject:gsub("${ring_group_name}", ring_group_name); + subject = subject:gsub("${ring_group_extension}", ring_group_extension); + subject = subject:gsub("${sip_to_user}", ring_group_name); + subject = subject:gsub("${dialed_user}", ring_group_extension); subject = trim(subject); subject = '=?utf-8?B?'..base64.encode(subject)..'?='; @@ -162,6 +166,9 @@ local log = require "resources.functions.log".ring_group body = body:gsub("${caller_id_name}", caller_id_name); body = body:gsub("${caller_id_number}", caller_id_number); body = body:gsub("${ring_group_name}", ring_group_name); + body = body:gsub("${ring_group_extension}", ring_group_extension); + body = body:gsub("${sip_to_user}", ring_group_name); + body = body:gsub("${dialed_user}", ring_group_extension); body = body:gsub(" ", " "); body = body:gsub("%s+", ""); body = body:gsub(" ", " "); From dfc19a954db71dc53609fcac07974a3fb397daf0 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 29 Sep 2015 14:28:48 -0600 Subject: [PATCH 07/64] Set content lenght to prevent chunking when providing HTTP 401. This should fix Yealink provisioning for the new firmware changes. --- app/provision/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/provision/index.php b/app/provision/index.php index fa20304c10..73f2f73915 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -241,7 +241,7 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); header('WWW-Authenticate: Basic realm="'.$_SESSION['domain_name']." ".date('r').'"'); header('HTTP/1.0 401 Unauthorized'); header("Content-Type: text/plain"); - echo 'Authorization Required'; + header("Content-Length: 0"); exit; } else { if ($_SERVER['PHP_AUTH_USER'] == $provision["http_auth_username"] && $_SERVER['PHP_AUTH_PW'] == $provision["http_auth_password"]) { @@ -252,7 +252,9 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); header('WWW-Authenticate: Basic realm="'.$_SESSION['domain_name']." ".date('r').'"'); unset($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']); usleep(rand(1000000,3000000));//1-3 seconds. - echo 'Authorization Required'; + $content = 'Authorization Required'; + header("Content-Length: ".strval(strlen($content))); + echo $content; exit; } } From f64e96c4c668b14efef9fd54828124f160ab3335 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 30 Sep 2015 20:56:59 -0600 Subject: [PATCH 08/64] Remove absolute_codec_string='PCMU,PCMA' as it failed to allow PCMA. --- app/fax/fax_send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index cbd205bb87..e134e37bbe 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -608,7 +608,7 @@ function gs_cmd($args) { $fax_uri = $route_array[0]; $t38 = "fax_enable_t38=true,fax_enable_t38_request=true,"; } - $cmd = "api originate {for_fax=1,absolute_codec_string='PCMU,PCMA',accountcode='".$fax_accountcode."',sip_h_X-accountcode='".$fax_accountcode."',domain_uuid=".$_SESSION["domain_uuid"].",domain_name=".$_SESSION["domain_name"].",mailto_address='".$mailto_address."',mailfrom_address='".$mailfrom_address."',origination_caller_id_name='".$fax_caller_id_name."',origination_caller_id_number='".$fax_caller_id_number."',fax_ident='".$fax_caller_id_number."',fax_header='".$fax_caller_id_name."',fax_uri=".$fax_uri.",fax_file='".$fax_file."',fax_retry_attempts=1,fax_retry_limit=20,fax_retry_sleep=180,fax_verbose=true,fax_use_ecm=off,".$t38."api_hangup_hook='lua fax_retry.lua'}".$fax_uri." &txfax('".$fax_file."')"; + $cmd = "api originate {for_fax=1,accountcode='".$fax_accountcode."',sip_h_X-accountcode='".$fax_accountcode."',domain_uuid=".$_SESSION["domain_uuid"].",domain_name=".$_SESSION["domain_name"].",mailto_address='".$mailto_address."',mailfrom_address='".$mailfrom_address."',origination_caller_id_name='".$fax_caller_id_name."',origination_caller_id_number='".$fax_caller_id_number."',fax_ident='".$fax_caller_id_number."',fax_header='".$fax_caller_id_name."',fax_uri=".$fax_uri.",fax_file='".$fax_file."',fax_retry_attempts=1,fax_retry_limit=20,fax_retry_sleep=180,fax_verbose=true,fax_use_ecm=off,".$t38."api_hangup_hook='lua fax_retry.lua'}".$fax_uri." &txfax('".$fax_file."')"; //send the command to event socket $response = event_socket_request($fp, $cmd); $response = str_replace("\n", "", $response); From b8823225c54f5db6d86049ca7b28e4ee61e9e9f3 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 30 Sep 2015 21:01:17 -0600 Subject: [PATCH 09/64] Remove absolute_codec_string='PCMU,PCMA' from fax_retry.lua as it is not allowing PCMA. --- resources/install/scripts/fax_retry.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/fax_retry.lua b/resources/install/scripts/fax_retry.lua index 652c4c4180..a6f2ce6fad 100644 --- a/resources/install/scripts/fax_retry.lua +++ b/resources/install/scripts/fax_retry.lua @@ -391,7 +391,7 @@ --email_cmd = "/bin/echo '"..email_message_fail.."' | /usr/bin/mail -s 'Fax to: "..number_dialed.." FAILED' -r "..from_address.." -a '"..fax_file.."' "..email_address; --to keep the originate command shorter these are things we always send. One place to adjust for all. - originate_same = "for_fax=1,absolute_codec_string='PCMU,PCMA',accountcode='"..accountcode.."',domain_uuid="..domain_uuid..",domain_name="..domain_name..",mailto_address='"..email_address.."',mailfrom_address='"..from_address.."',origination_caller_id_name='"..origination_caller_id_name.. "',origination_caller_id_number="..origination_caller_id_number..",fax_uri="..fax_uri..",fax_retry_limit="..fax_retry_limit..",fax_retry_sleep="..fax_retry_sleep..",fax_verbose=true,fax_file='"..fax_file.."'"; + originate_same = "for_fax=1,accountcode='"..accountcode.."',domain_uuid="..domain_uuid..",domain_name="..domain_name..",mailto_address='"..email_address.."',mailfrom_address='"..from_address.."',origination_caller_id_name='"..origination_caller_id_name.. "',origination_caller_id_number="..origination_caller_id_number..",fax_uri="..fax_uri..",fax_retry_limit="..fax_retry_limit..",fax_retry_sleep="..fax_retry_sleep..",fax_verbose=true,fax_file='"..fax_file.."'"; if (fax_retry_attempts < fax_retry_limit) then From cbbe5acdad73d963f0926db70bbec0f1a59187a9 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 2 Oct 2015 17:23:52 -0600 Subject: [PATCH 10/64] Update functions.php Minor version update to 4.0.1 --- resources/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/functions.php b/resources/functions.php index 8ae34eb285..c1bd498810 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -27,7 +27,7 @@ if (!function_exists('software_version')) { function software_version() { - return '4.0.0'; + return '4.0.1'; } } @@ -1326,4 +1326,4 @@ function number_pad($number,$n) { } } -?> \ No newline at end of file +?> From ef3b08b08175199d02094912277c42b288ec6279 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 2 Oct 2015 17:46:39 -0600 Subject: [PATCH 11/64] Fix sip_to_user and dialed_user for voicemail. --- .../scripts/app/voicemail/resources/functions/send_email.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua index f00cb942a5..7009932369 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua @@ -131,6 +131,8 @@ body = body:gsub("${message_duration}", message_length_formatted); body = body:gsub("${account}", id); body = body:gsub("${domain_name}", domain_name); + body = body:gsub("${sip_to_user}", id); + body = body:gsub("${dialed_user}", id); if (voicemail_file == "attach") then body = body:gsub("${message}", text['label-attached'][default_language.."-"..default_dialect]); elseif (voicemail_file == "link") then From 876516e30725089b870a60f3aca27e7dd7cef22d Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 2 Oct 2015 23:39:12 -0600 Subject: [PATCH 12/64] Force the device_key_vendor to lower case so the key vendor can be case insenstive. --- app/provision/resources/classes/provision.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 237de12212..d2a4a6f562 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -465,7 +465,7 @@ include "root.php"; $sql .= "or device_profile_uuid = '".$device_profile_uuid."' "; } $sql .= ") "; - $sql .= "AND (device_key_vendor = '".$device_vendor."' or device_key_vendor is null) "; + $sql .= "AND (lower(device_key_vendor) = '".$device_vendor."' or device_key_vendor is null) "; $sql .= "ORDER BY device_key_category asc, device_key_id asc, device_uuid desc"; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); From 0b4a406359f0c301290427c8cdc24e4d40857dee Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Sat, 3 Oct 2015 08:58:41 -0700 Subject: [PATCH 13/64] Update {$mac}.cfg added support for second expansion module and tested the changes. --- .../provision/yealink/t46g/{$mac}.cfg | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/resources/templates/provision/yealink/t46g/{$mac}.cfg b/resources/templates/provision/yealink/t46g/{$mac}.cfg index d5a65ef413..82e6c3ebfc 100644 --- a/resources/templates/provision/yealink/t46g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t46g/{$mac}.cfg @@ -3013,16 +3013,26 @@ programablekey.1.label = #expansion_module.x.key.y.label = #expansion_module.X.key.Y.xml_phonebook = +{$rownum = 1} + {foreach $keys as $row} {if $row.device_key_category == "expansion"} -#Expansion module 1 key {$row.device_key_id} +{if $rownum <= 40} expansion_module.1.key.{$row.device_key_id}.type = {$row.device_key_type} expansion_module.1.key.{$row.device_key_id}.line = {$row.device_key_line} expansion_module.1.key.{$row.device_key_id}.value = {$row.device_key_value} expansion_module.1.key.{$row.device_key_id}.extension = {$row.device_key_extension} expansion_module.1.key.{$row.device_key_id}.label = {$row.device_key_label} -expansion_module.1.key.{$row.device_key_id}.xml_phonebook = - +expansion_module.1.key.{$row.device_key_id}.xml_phonebook = +{else} +expansion_module.2.key.{$row.device_key_id - 40}.type = {$row.device_key_type} +expansion_module.2.key.{$row.device_key_id - 40}.line = {$row.device_key_line} +expansion_module.2.key.{$row.device_key_id - 40}.value = {$row.device_key_value} +expansion_module.2.key.{$row.device_key_id - 40}.extension = {$row.device_key_extension} +expansion_module.2.key.{$row.device_key_id - 40}.label = {$row.device_key_label} +expansion_module.2.key.{$row.device_key_id - 40}.xml_phonebook = +{/if} +{$rownum = $rownum + 1} {/if} {/foreach} @@ -3038,4 +3048,4 @@ expansion_module.1.key.{$row.device_key_id}.xml_phonebook = #expansion_module.2.key.1.label = #expansion_module.2.key.1.xml_phonebook = #expansion_module.2.key.1.type = -#expansion_module.2.key.1.label = \ No newline at end of file +#expansion_module.2.key.1.label = From 58edf1613d7fc3ece09431ef92e26414ae4f2b6b Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 4 Oct 2015 01:29:03 -0600 Subject: [PATCH 14/64] Add h hostname to option for the gateways. --- app/gateways/app_config.php | 5 ++++ app/gateways/app_languages.php | 18 +++++++++++++ app/gateways/gateway_edit.php | 26 +++++++++++++++++++ app/gateways/gateways.php | 2 ++ .../scripts/configuration/sofia.conf.lua | 1 + 5 files changed, 52 insertions(+) diff --git a/app/gateways/app_config.php b/app/gateways/app_config.php index 049daf4f95..672be36cc3 100644 --- a/app/gateways/app_config.php +++ b/app/gateways/app_config.php @@ -189,6 +189,11 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "hostname"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(255)"; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "enabled"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; diff --git a/app/gateways/app_languages.php b/app/gateways/app_languages.php index 414807c343..4af02a678b 100644 --- a/app/gateways/app_languages.php +++ b/app/gateways/app_languages.php @@ -442,6 +442,15 @@ $text['label-expire_seconds']['de-at'] = "Expire Seconds"; $text['label-expire_seconds']['ar-eg'] = ""; $text['label-expire_seconds']['he'] = ""; +$text['label-hostname']['en-us'] = "Hostname"; +$text['label-hostname']['pt-pt'] = "Hostname"; +$text['label-hostname']['fr-fr'] = "Nom d'hôte"; +$text['label-hostname']['pt-br'] = "Hostname"; +$text['label-hostname']['pl'] = "Nazwa hosta"; +$text['label-hostname']['sv-se'] = "Hostname"; +$text['label-hostname']['uk'] = "Назва хоста"; +$text['label-hostname']['de-at'] = "Hostname"; + $text['label-enabled']['en-us'] = "Enabled"; $text['label-enabled']['es-cl'] = "Activado"; $text['label-enabled']['pt-pt'] = "Habilitado"; @@ -870,6 +879,15 @@ $text['description-expire_seconds']['de-at'] = "Geben Sie an, nach wie vielen Se $text['description-expire_seconds']['ar-eg'] = ""; $text['description-expire_seconds']['he'] = ""; +$text['description-hostname']['en-us'] = "Enter the hostname / switchname."; +$text['description-hostname']['pt-pt'] = "Introduza o hostname"; +$text['description-hostname']['fr-fr'] = "Entrer le nom de l'hôte / du switch."; +$text['description-hostname']['pt-br'] = "Insira o hostname"; +$text['description-hostname']['pl'] = "Wprowadź nazwę hosta / PBXu."; +$text['description-hostname']['sv-se'] = "Fyll i hostname / switchname."; +$text['description-hostname']['uk'] = "Введіть назву хоста / switchname."; +$text['description-hostname']['de-at'] = "Geben Sie den Hostnamen / Switchnamen an."; + $text['description-enabled']['en-us'] = "Enable or Disable the Gateway"; $text['description-enabled']['es-cl'] = "Activar o Desactivar la Pasarela"; $text['description-enabled']['pt-pt'] = "Habilitar ou Desabilitar o Gateway"; diff --git a/app/gateways/gateway_edit.php b/app/gateways/gateway_edit.php index 0ddb0a4f9a..a60a801163 100644 --- a/app/gateways/gateway_edit.php +++ b/app/gateways/gateway_edit.php @@ -95,6 +95,7 @@ else { $extension_in_contact = check_str($_POST["extension_in_contact"]); $context = check_str($_POST["context"]); $profile = check_str($_POST["profile"]); + $hostname = check_str($_POST["hostname"]); $enabled = check_str($_POST["enabled"]); $description = check_str($_POST["description"]); } @@ -198,6 +199,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "extension_in_contact, "; $sql .= "context, "; $sql .= "profile, "; + $sql .= "hostname, "; $sql .= "enabled, "; $sql .= "description "; $sql .= ")"; @@ -232,6 +234,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'$extension_in_contact', "; $sql .= "'$context', "; $sql .= "'$profile', "; + if (strlen($hostname) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'$hostname', "; + } $sql .= "'$enabled', "; $sql .= "'$description' "; $sql .= ")"; @@ -278,6 +286,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { else { $sql .= "domain_uuid = '$domain_uuid', "; } + if (strlen($hostname) == 0) { + $sql .= "hostname = null, "; + } + else { + $sql .= "hostname = '$hostname', "; + } $sql .= "enabled = '$enabled', "; $sql .= "description = '$description' "; $sql .= "where gateway_uuid = '$gateway_uuid'"; @@ -374,6 +388,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $extension_in_contact = $row["extension_in_contact"]; $context = $row["context"]; $profile = $row["profile"]; + $hostname = $row["hostname"]; $enabled = $row["enabled"]; $description = $row["description"]; } @@ -871,6 +886,17 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " ".$text['label-hostname']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-hostname']."\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " ".$text['label-enabled']."\n"; diff --git a/app/gateways/gateways.php b/app/gateways/gateways.php index bc890546dc..8ee5d35354 100644 --- a/app/gateways/gateways.php +++ b/app/gateways/gateways.php @@ -159,6 +159,7 @@ else { echo "".$text['label-action']."\n"; echo "".$text['label-state']."\n"; } + echo th_order_by('hostname', $text['label-hostname'], $order_by, $order); echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); echo th_order_by('description', $text['label-description'], $order_by, $order); echo ""; @@ -183,6 +184,7 @@ else { } echo "\n"; echo " ".$row["context"]."\n"; + echo " ".$row["hostname"]."\n"; if ($fp) { if ($row["enabled"] == "true") { $response = switch_gateway_status($row["gateway_uuid"]); diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua index 6656f619f3..52e70dc563 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua @@ -119,6 +119,7 @@ sql = "select * from v_gateways "; sql = sql .. "where enabled = 'true' and profile = '"..sip_profile_name.."' "; end + sql = sql .. "and (g.hostname = '" .. hostname.. "' or g.hostname is null or g.hostname = '') "; if (debug["sql"]) then freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); end From 3ee03fa8448fabfcff451e7cca5b061e8affab2c Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 4 Oct 2015 10:50:05 -0600 Subject: [PATCH 15/64] Fix the gateways list so it displays the hostname in the right place. --- app/gateways/gateways.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/gateways/gateways.php b/app/gateways/gateways.php index 8ee5d35354..f517fd5354 100644 --- a/app/gateways/gateways.php +++ b/app/gateways/gateways.php @@ -136,7 +136,7 @@ else { } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); $rows_per_page = 150; @@ -172,7 +172,7 @@ else { echo "\n"; if ($num_rows > 0) { - foreach($result as $row) { + foreach($gateways as $row) { $tr_link = (permission_exists('gateway_edit')) ? "href='gateway_edit.php?id=".$row['gateway_uuid']."'" : null; echo "\n"; echo " "; @@ -184,7 +184,6 @@ else { } echo "\n"; echo " ".$row["context"]."\n"; - echo " ".$row["hostname"]."\n"; if ($fp) { if ($row["enabled"] == "true") { $response = switch_gateway_status($row["gateway_uuid"]); @@ -213,6 +212,7 @@ else { echo "  \n"; echo "  \n"; } + echo " ".$row["hostname"]."\n"; if ($row["enabled"] == "true") { echo " ".$text['label-true']."\n"; } @@ -232,11 +232,11 @@ else { } if ($c==0) { $c=1; } else { $c=0; } } //end foreach - unset($sql, $result, $row_count); + unset($sql, $gateways, $row_count); } //end if results echo "\n"; - echo "\n"; + echo "\n"; echo " \n"; echo " \n"; echo " \n"; From 5cb4e7b9b957188dc407ef4f9e10b0a0a38c2237 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 6 Oct 2015 11:05:15 +0400 Subject: [PATCH 16/64] Fix. use timeout handler in Enterprise ring group see https://github.com/moteus/fusionpbx/commit/e5a0134ec6c36e44d0828301b20c9c194c25cd78#commitcomment-13601198 --- .../install/scripts/app/ring_groups/index.lua | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 545f5ecc68..bebe6817db 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -626,36 +626,27 @@ local log = require "resources.functions.log".ring_group app_data = app_data:gsub("%]", "}"); end freeswitch.consoleLog("NOTICE", "[ring group] app_data: "..app_data.."\n"); + -- log.noticef("bridge begin: originate_disposition:%s answered:%s ready:%s bridged:%s", session:getVariable("originate_disposition"), session:answered() and "true" or "false", session:ready() and "true" or "false", session:bridged() and "true" or "false") session:execute("bridge", app_data); -- log.noticef("bridge done: originate_disposition:%s answered:%s ready:%s bridged:%s", session:getVariable("originate_disposition"), session:answered() and "true" or "false", session:ready() and "true" or "false", session:bridged() and "true" or "false") end --timeout destination if (app_data ~= nil) then - if ring_group_strategy == "enterprise" - and ( true - --- I see 2 errors here `failure` and `PICKED_OFF` - --- but they be more. I think check `answered` is enough. - -- or session:getVariable("originate_disposition") == "failure" - -- or session:getVariable("originate_disposition") == "PICKED_OFF" - ) - and session:answered() then - -- for enterprise calls when intercept we get "failure" but session answered - return - end - - if (session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT" + if session:ready() and ( + session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT" or session:getVariable("originate_disposition") == "NO_ANSWER" or session:getVariable("originate_disposition") == "NO_USER_RESPONSE" or session:getVariable("originate_disposition") == "USER_NOT_REGISTERED" or session:getVariable("originate_disposition") == "NORMAL_TEMPORARY_FAILURE" or session:getVariable("originate_disposition") == "NO_ROUTE_DESTINATION" or session:getVariable("originate_disposition") == "USER_BUSY" - or session:getVariable("originate_disposition") == "failure") then - --send missed call notification - missed(); - --execute the time out action - session:execute(ring_group_timeout_app, ring_group_timeout_data); + or session:getVariable("originate_disposition") == "failure" + ) then + --send missed call notification + missed(); + --execute the time out action + session:execute(ring_group_timeout_app, ring_group_timeout_data); end else if (ring_group_timeout_app ~= nil) then From 53bee05f8a34bd524028a6032ed1ac7bd8d55234 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Tue, 6 Oct 2015 19:28:57 -0700 Subject: [PATCH 17/64] Fix Gateways and SIP profiles for single tenant systems. --- .../resources/scripts/configuration/sofia.conf.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua index 52e70dc563..a05f14188c 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua @@ -1,6 +1,6 @@ -- xml_handler.lua -- Part of FusionPBX --- Copyright (C) 2013 Mark J Crane +-- Copyright (C) 2013 - 2015 Mark J Crane -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -116,8 +116,8 @@ sql = sql .. "and g.enabled = 'true' "; sql = sql .. "and (g.domain_uuid = d.domain_uuid or g.domain_uuid is null) "; else - sql = "select * from v_gateways "; - sql = sql .. "where enabled = 'true' and profile = '"..sip_profile_name.."' "; + sql = "select * from v_gateways as g "; + sql = sql .. "where g.enabled = 'true' and g.profile = '"..sip_profile_name.."' "; end sql = sql .. "and (g.hostname = '" .. hostname.. "' or g.hostname is null or g.hostname = '') "; if (debug["sql"]) then From 8c9ca17e5cbc94f02d31661e79e1b9803f22f205 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 7 Oct 2015 10:45:28 -0700 Subject: [PATCH 18/64] Add default settings -> domain -> bridge -> text -> outbound to avoide loopback however loopback is also an option. --- core/default_settings/app_defaults.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/default_settings/app_defaults.php b/core/default_settings/app_defaults.php index 70ef5f0caf..a058969777 100644 --- a/core/default_settings/app_defaults.php +++ b/core/default_settings/app_defaults.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2010 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -30,12 +30,26 @@ if ($domains_processed == 1) { //define array of settings $x = 0; $array[$x]['default_setting_category'] = 'domain'; + $array[$x]['default_setting_subcategory'] = 'time_zone'; + $array[$x]['default_setting_name'] = 'name'; + $array[$x]['default_setting_value'] = ''; + $array[$x]['default_setting_enabled'] = 'true'; + $array[$x]['default_setting_description'] = ''; + $x++; + $array[$x]['default_setting_category'] = 'domain'; $array[$x]['default_setting_subcategory'] = 'language'; $array[$x]['default_setting_name'] = 'code'; $array[$x]['default_setting_value'] = 'en-us'; $array[$x]['default_setting_enabled'] = 'true'; $array[$x]['default_setting_description'] = ''; $x++; + $array[$x]['default_setting_category'] = 'domain'; + $array[$x]['default_setting_subcategory'] = 'bridge'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = 'outbound'; + $array[$x]['default_setting_enabled'] = 'true'; + $array[$x]['default_setting_description'] = 'outbound,loopback,lcr'; + $x++; $array[$x]['default_setting_category'] = 'security'; $array[$x]['default_setting_subcategory'] = 'password_length'; $array[$x]['default_setting_name'] = 'var'; From 0d3da4dcbe318e2e058f18e38ae8eeb87457841c Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 7 Oct 2015 11:52:06 -0700 Subject: [PATCH 19/64] Set presence-hosts as disabled by default. --- resources/templates/conf/sip_profiles/internal.xml.noload | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/conf/sip_profiles/internal.xml.noload b/resources/templates/conf/sip_profiles/internal.xml.noload index 012c50e59a..86452a2282 100644 --- a/resources/templates/conf/sip_profiles/internal.xml.noload +++ b/resources/templates/conf/sip_profiles/internal.xml.noload @@ -150,7 +150,7 @@ - + From a9ffc2ecac12920f0438f0788395312370aed7a0 Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Wed, 7 Oct 2015 13:41:17 -0700 Subject: [PATCH 20/64] {$mac}.cfg fix the port # for yealink DNS SRV --- resources/templates/provision/yealink/t42g/{$mac}.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/templates/provision/yealink/t42g/{$mac}.cfg b/resources/templates/provision/yealink/t42g/{$mac}.cfg index f61d7bfe92..a8541361af 100644 --- a/resources/templates/provision/yealink/t42g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t42g/{$mac}.cfg @@ -44,7 +44,11 @@ account.1.naptr_build = 0 account.1.fallback.redundancy_type = 0 account.1.fallback.timeout = 120 account.1.sip_server.1.address = +{if $sip_transport_1 == 'dns srv'} +account.1.sip_server.1.port = 0 +{else} account.1.sip_server.1.port = 5060 +{/if} #Configure the register expiry time (in seconds), the default value is 3600. account.1.sip_server.1.expires = {$register_expires_1} account.1.sip_server.1.retry_counts = 3 From 4784df09645ad22fc83d258983c8726768ec1a3e Mon Sep 17 00:00:00 2001 From: blackc2004 Date: Wed, 7 Oct 2015 13:43:17 -0700 Subject: [PATCH 21/64] Update {$mac}.cfg fix for yealink dns srv to work. --- resources/templates/provision/yealink/t46g/{$mac}.cfg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/templates/provision/yealink/t46g/{$mac}.cfg b/resources/templates/provision/yealink/t46g/{$mac}.cfg index d5a65ef413..a8541361af 100644 --- a/resources/templates/provision/yealink/t46g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t46g/{$mac}.cfg @@ -44,7 +44,11 @@ account.1.naptr_build = 0 account.1.fallback.redundancy_type = 0 account.1.fallback.timeout = 120 account.1.sip_server.1.address = +{if $sip_transport_1 == 'dns srv'} +account.1.sip_server.1.port = 0 +{else} account.1.sip_server.1.port = 5060 +{/if} #Configure the register expiry time (in seconds), the default value is 3600. account.1.sip_server.1.expires = {$register_expires_1} account.1.sip_server.1.retry_counts = 3 @@ -3038,4 +3042,4 @@ expansion_module.1.key.{$row.device_key_id}.xml_phonebook = #expansion_module.2.key.1.label = #expansion_module.2.key.1.xml_phonebook = #expansion_module.2.key.1.type = -#expansion_module.2.key.1.label = \ No newline at end of file +#expansion_module.2.key.1.label = From a72eebfbe5dbb27433dbc1ff98f6b6d9d536f2d9 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 8 Oct 2015 08:33:34 -0700 Subject: [PATCH 22/64] Enable aggressive nat detection and rport by default. --- resources/templates/conf/sip_profiles/internal.xml.noload | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/templates/conf/sip_profiles/internal.xml.noload b/resources/templates/conf/sip_profiles/internal.xml.noload index 86452a2282..787fde8f95 100644 --- a/resources/templates/conf/sip_profiles/internal.xml.noload +++ b/resources/templates/conf/sip_profiles/internal.xml.noload @@ -97,7 +97,7 @@ - + - +