From 759a375f5ea37350b9c1cca8a95d3816de4c9d28 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 25 Nov 2015 18:06:27 -0700 Subject: [PATCH 01/56] Remove trailing tabs. Fix some spelling mistakes. And update core/upgrade/app_defaults.php to fix advanced -> upgrade. --- core/install/index.php | 2 -- core/install/install_first_time.php | 18 ++++++++---------- .../resources/classes/install_switch.php | 17 ++++++++--------- core/upgrade/app_defaults.php | 6 ++---- .../provision/cisco/7940/SIPDefault.cnf | 4 ++-- .../provision/mitel/5324/MN_${mac}.cfg | 2 +- .../provision/mitel/5340/MN_${mac}.cfg | 2 +- 7 files changed, 22 insertions(+), 29 deletions(-) diff --git a/core/install/index.php b/core/install/index.php index 9011dd9574..492550f282 100644 --- a/core/install/index.php +++ b/core/install/index.php @@ -95,8 +95,6 @@ if (!if_group("superadmin")) { echo "

"; - echo "

WiP

"; - //include the footer require_once "resources/footer.php"; ?> \ No newline at end of file diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index b4366275fa..a091eb6825 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.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-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -28,7 +28,7 @@ require_once "root.php"; require_once "resources/functions.php"; require_once "resources/classes/text.php"; -//initialize varibles we are going to use +//initialize variables we are going to use $event_host = ''; $event_port = ''; $event_password = ''; @@ -130,7 +130,7 @@ if(!$install_step) { $install_step = 'select_language'; } if (isset($_SESSION['domain']['template']['name']) and strlen($_SESSION['domain']['template']['name']) != 0) { $default_template = $_SESSION['domain']['template']['name']; } - + //set a default enviroment if first_time if($first_time_install){ //initialize some varibles to cut down on warnings @@ -147,7 +147,7 @@ if(!$install_step) { $install_step = 'select_language'; } //buffer the content ob_end_clean(); //clean the buffer ob_start(); - + $messages = array(); if (!extension_loaded('PDO')) { $messages[] = "PHP PDO was not detected. Please install it before proceeding"; @@ -168,7 +168,7 @@ if(!$install_step) { $install_step = 'select_language'; } "You can use the following to find what ports are allowed
semanage port -l | grep '^http_port_t'
"; } } - + //action code if($return_install_step == 'config_detail'){ //check for all required data @@ -185,11 +185,8 @@ if(!$install_step) { $install_step = 'select_language'; } //set the max execution time to 1 hour ini_set('max_execution_time',3600); - } - - //display messages if (count($messages)>0) { echo "
\n"; @@ -262,7 +259,7 @@ if(!$install_step) { $install_step = 'select_language'; } try { $switch_detect->detect(); } catch(Exception $e){ - echo "

Failed to detect confgiuration detect_switch reported: " . $e->getMessage() . "

\n"; + echo "

Failed to detect configuration detect_switch reported: " . $e->getMessage() . "

\n"; $detect_ok = false; } if($detect_ok){ @@ -299,7 +296,7 @@ if(!$install_step) { $install_step = 'select_language'; } } } $fusionPBX->install(); - + require_once "resources/classes/install_switch.php"; $switch = new install_switch($domain_name, $domain_uuid, $switch_detect); //$switch->debug = true; @@ -345,6 +342,7 @@ if($first_time_install){ $_SESSION['permissions'][]['permission_name'] = 'superadmin'; $_SESSION['menu'] = ''; } + // add the content to the template and then send output $body = ob_get_contents(); //get the output from the buffer ob_end_clean(); //clean the buffer diff --git a/core/install/resources/classes/install_switch.php b/core/install/resources/classes/install_switch.php index b13c36b23d..71f500f9cc 100644 --- a/core/install/resources/classes/install_switch.php +++ b/core/install/resources/classes/install_switch.php @@ -35,9 +35,9 @@ include "root.php"; public $debug = false; function __construct($domain_name, $domain_uuid, $detect_switch) { - if(!is_a($detect_switch, 'detect_switch')){ - throw new Exception('The parameter $detect_switch must be a detect_switch object (or a subclass of)'); - } + //if(!is_a($detect_switch, 'detect_switch')){ + // throw new Exception('The parameter $detect_switch must be a detect_switch object (or a subclass of)'); + //} $this->domain_uuid = $domain_uuid; $this->domain = $domain_name; $this->detect_switch = $detect_switch; @@ -166,11 +166,10 @@ include "root.php"; } } - function install() { $this->copy_conf(); $this->copy_scripts(); - //tell freeswitch to restart + //tell freeswitch to restart $this->write_progress("Restarting switch"); $this->detect_switch->restart_switch(); } @@ -182,10 +181,10 @@ include "root.php"; function copy_conf() { $this->write_progress("Copying Config"); //make a backup of the config - if (file_exists($this->detect_switch->conf_dir())) { - $this->backup_dir($this->detect_switch->conf_dir(), 'fusionpbx_switch_config'); - $this->recursive_delete($this->detect_switch->conf_dir()); - } + if (file_exists($this->detect_switch->conf_dir())) { + $this->backup_dir($this->detect_switch->conf_dir(), 'fusionpbx_switch_config'); + $this->recursive_delete($this->detect_switch->conf_dir()); + } //make sure the conf directory exists if (!is_dir($this->detect_switch->conf_dir())) { if (!mkdir($this->detect_switch->conf_dir(), 0774, true)) { diff --git a/core/upgrade/app_defaults.php b/core/upgrade/app_defaults.php index b5625f3e7a..a904361bb8 100644 --- a/core/upgrade/app_defaults.php +++ b/core/upgrade/app_defaults.php @@ -34,10 +34,8 @@ if ($domains_processed == 1) { } //copy the files and directories from resources/install - $install = new install; - $install->domain_uuid = $domain_uuid; - $install->switch_scripts_dir = $_SESSION['switch']['scripts']['dir']; - $install->copy_scripts(); + $obj = new install_switch; + $obj->upgrade(); } //update the software table diff --git a/resources/templates/provision/cisco/7940/SIPDefault.cnf b/resources/templates/provision/cisco/7940/SIPDefault.cnf index 489f5c97ea..08ce3b7a15 100644 --- a/resources/templates/provision/cisco/7940/SIPDefault.cnf +++ b/resources/templates/provision/cisco/7940/SIPDefault.cnf @@ -126,6 +126,6 @@ directory_url: "http://{$domain_name}/app/provision/?file=directory.php" # URL for branding logo #logo_url: "http://{$domain_name}/app/provision/logo.bmp" -# Remote Party ID -remote_party_id: 1 ; 0-Disabled (default), 1-Enabled +# Remote Party ID 0-Disabled (default), 1-Enabled +remote_party_id: 1 diff --git a/resources/templates/provision/mitel/5324/MN_${mac}.cfg b/resources/templates/provision/mitel/5324/MN_${mac}.cfg index b081d013c3..ff200630c1 100644 --- a/resources/templates/provision/mitel/5324/MN_${mac}.cfg +++ b/resources/templates/provision/mitel/5324/MN_${mac}.cfg @@ -31,7 +31,7 @@ 1 0 1 - http://rss.news.yahoo.com/rss/topstories + 135.199.77.12 135.199.77.12 128.138.141.172 diff --git a/resources/templates/provision/mitel/5340/MN_${mac}.cfg b/resources/templates/provision/mitel/5340/MN_${mac}.cfg index ea1c742f2d..4b18dcce14 100644 --- a/resources/templates/provision/mitel/5340/MN_${mac}.cfg +++ b/resources/templates/provision/mitel/5340/MN_${mac}.cfg @@ -31,7 +31,7 @@ 1 0 1 - http://rss.news.yahoo.com/rss/topstories + 135.199.77.12 135.199.77.12 128.138.141.172 From 266cc76a03f912a3b218ea29626f9ae3e05ee3cb Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 25 Nov 2015 18:16:38 -0700 Subject: [PATCH 02/56] If the script dir is set in the session we know the location and don't need to ask freeswitch for it again. --- core/install/resources/classes/install_switch.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/install/resources/classes/install_switch.php b/core/install/resources/classes/install_switch.php index 71f500f9cc..65592e8903 100644 --- a/core/install/resources/classes/install_switch.php +++ b/core/install/resources/classes/install_switch.php @@ -235,15 +235,21 @@ include "root.php"; function copy_scripts() { $this->write_progress("Copying Scripts"); - if (file_exists($this->detect_switch->script_dir())) { + if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { + $script_dir = $_SESSION['switch']['scripts']['dir']; + } + else { + $script_dir = $this->detect_switch->script_dir() + } + if (file_exists($script_dir())) { if (file_exists('/usr/share/examples/fusionpbx/resources/install/scripts')){ $src_dir = '/usr/share/examples/fusionpbx/resources/install/scripts'; } else { $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts'; } - $dst_dir = $this->detect_switch->script_dir(); - if (is_readable($this->detect_switch->script_dir())) { + $dst_dir = $script_dir; + if (is_readable($script_dir)) { $this->recursive_copy($src_dir, $dst_dir, $_SESSION['scripts']['options']['text']); unset($src_dir, $dst_dir); } From cfdccded76461c7d4f7d05a70d3f4844f6120741 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 25 Nov 2015 18:17:48 -0700 Subject: [PATCH 03/56] Fix the syntax by adding a missing semi-colon. --- core/install/resources/classes/install_switch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/install/resources/classes/install_switch.php b/core/install/resources/classes/install_switch.php index 65592e8903..4eb4b04247 100644 --- a/core/install/resources/classes/install_switch.php +++ b/core/install/resources/classes/install_switch.php @@ -239,7 +239,7 @@ include "root.php"; $script_dir = $_SESSION['switch']['scripts']['dir']; } else { - $script_dir = $this->detect_switch->script_dir() + $script_dir = $this->detect_switch->script_dir(); } if (file_exists($script_dir())) { if (file_exists('/usr/share/examples/fusionpbx/resources/install/scripts')){ From 04f3fa6a7a2398a0a37ed1ab8313ec1a9ffb6431 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 25 Nov 2015 18:18:48 -0700 Subject: [PATCH 04/56] Another minor adjustment. --- core/install/resources/classes/install_switch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/install/resources/classes/install_switch.php b/core/install/resources/classes/install_switch.php index 4eb4b04247..ac959b8d16 100644 --- a/core/install/resources/classes/install_switch.php +++ b/core/install/resources/classes/install_switch.php @@ -241,7 +241,7 @@ include "root.php"; else { $script_dir = $this->detect_switch->script_dir(); } - if (file_exists($script_dir())) { + if (file_exists($script_dir)) { if (file_exists('/usr/share/examples/fusionpbx/resources/install/scripts')){ $src_dir = '/usr/share/examples/fusionpbx/resources/install/scripts'; } From 35752445c34a4b3b02bccb933bf0784496732f4a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 25 Nov 2015 21:55:17 -0700 Subject: [PATCH 05/56] Remove the old reference to install class and replaced with install_switch. --- core/upgrade/index.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/upgrade/index.php b/core/upgrade/index.php index ef686b4b33..6a83f51e10 100644 --- a/core/upgrade/index.php +++ b/core/upgrade/index.php @@ -72,10 +72,8 @@ if (sizeof($_POST) > 0) { //update scripts folder, if allowed (default) if ($_SESSION['switch']['scripts']['dir'] != '') { //copy the files and directories from resources/install - $install = new install; - $install->domain_uuid = $domain_uuid; - $install->switch_scripts_dir = $_SESSION['switch']['scripts']['dir']; - $install->copy_scripts(); + $obj = new install_switch; + $obj->upgrade(); //set the message $response_message = $text['message-upgrade_source_scripts']; } From f819eaf65cea6191c6756cf84d694d9f7b18a33a Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 11:23:52 +0000 Subject: [PATCH 06/56] Added check will now throw if the config.lua could not be opened for writing --- core/databases/app_defaults.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/databases/app_defaults.php b/core/databases/app_defaults.php index ea4d04d6c9..71adfaced2 100644 --- a/core/databases/app_defaults.php +++ b/core/databases/app_defaults.php @@ -126,6 +126,9 @@ if ($domains_processed == 1) { $config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua"; } $fout = fopen($config,"w"); + if(!$fout){ + throw new Exception("Failed to open '$config' for writing"); + } $tmp = "\n"; $tmp .= "--set the variables\n"; if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { From 40d5b5a0decbaa06411cb365a5da143d2130a575 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 13:20:04 +0000 Subject: [PATCH 07/56] fixed detection of timezone on debian removed add_new_switch temporarily, currently not supported --- core/install/index.php | 15 --------------- core/install/install_first_time.php | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/core/install/index.php b/core/install/index.php index 9011dd9574..1eb6efc8c9 100644 --- a/core/install/index.php +++ b/core/install/index.php @@ -78,21 +78,6 @@ if (!if_group("superadmin")) { echo "\n"; echo "\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
\n"; - echo " "; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - echo "

"; echo "

WiP

"; diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index b4366275fa..1416d39f69 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -63,7 +63,7 @@ if (is_link('/etc/localtime')) { // Ubuntu / Debian. $data = file_get_contents('/etc/timezone'); if ($data) { - $timezone = $data; + $timezone = rtrim($data); } } elseif (file_exists('/etc/sysconfig/clock')) { // RHEL / CentOS From ac44787e36ecdabb0ea0c2a0d8d6c061c2363bdf Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 26 Nov 2015 17:23:33 +0300 Subject: [PATCH 08/56] Fix. problem when same session can release task multiple times. It can be when originate has group dial-string. So it call `api_hangup_hook` for each channel. Now we release task in `retry.lua` only if originate success and this is same channel which execute `exec.lua`. If originate fail we release task `next.lua` --- resources/install/scripts/fax_queue/exec.lua | 6 ++++++ resources/install/scripts/fax_queue/next.lua | 13 ++++++------ resources/install/scripts/fax_queue/retry.lua | 15 ++++++++++---- resources/install/scripts/fax_queue/tasks.lua | 8 ++++++++ .../scripts/resources/functions/esl.lua | 20 ++++++++++++++----- 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/resources/install/scripts/fax_queue/exec.lua b/resources/install/scripts/fax_queue/exec.lua index 7fbb58d826..98de09adb7 100644 --- a/resources/install/scripts/fax_queue/exec.lua +++ b/resources/install/scripts/fax_queue/exec.lua @@ -132,6 +132,12 @@ local function check() end local function task() + local session_uuid = session:getVariable('uuid') + + session:setVariable('fax_queue_task_session', session_uuid) + + log.infof("SESSION UUID: %s", session_uuid) + session:waitForAnswer(session) while not session:answered() do diff --git a/resources/install/scripts/fax_queue/next.lua b/resources/install/scripts/fax_queue/next.lua index 0067d0e9b4..9e7ac0081f 100644 --- a/resources/install/scripts/fax_queue/next.lua +++ b/resources/install/scripts/fax_queue/next.lua @@ -28,10 +28,6 @@ local function next_task() local esl local ok, err = pcall(function() - for k, v in pairs(task) do - print(string.format(" `%s` => `%s`", tostring(k), tostring(v))) - end - local mode = (task.retry_counter % #FAX_OPTIONS) + 1 local dial_string = '{' .. task.dial_string .. "api_hangup_hook='lua fax_queue/retry.lua'," .. @@ -42,8 +38,13 @@ local function next_task() log.notice(originate) esl = assert(Esl.new()) - local ok, err = esl:api(originate) - log.notice(ok or err) + local ok, status, info = esl:api(originate) + if not ok then + Tasks.wait_task(task, false, info) + log.noticef('Can not originate to `%s` cause: %s: %s ', task.uri, tostring(status), tostring(info)) + else + log.noticef("originate successfuly: %s", tostring(info)) + end end) if esl then esl:close() end diff --git a/resources/install/scripts/fax_queue/retry.lua b/resources/install/scripts/fax_queue/retry.lua index ef099546b7..d22f6df7ed 100644 --- a/resources/install/scripts/fax_queue/retry.lua +++ b/resources/install/scripts/fax_queue/retry.lua @@ -10,7 +10,7 @@ local Tasks = require "fax_queue.tasks" local fax_task_uuid = env:getHeader('fax_task_uuid') - local task = Tasks.select_task(fax_task_uuid) + local task = Tasks.select_task(fax_task_uuid) if not task then log.warningf("Can not find fax task: %q", tostring(fax_task_uuid)) return @@ -25,6 +25,7 @@ -- Channel/FusionPBX variables local uuid = env:getHeader("uuid") + local fax_queue_task_session = env:getHeader('fax_queue_task_session') local domain_uuid = env:getHeader("domain_uuid") or task.domain_uuid local domain_name = env:getHeader("domain_name") or task.domain_name local origination_caller_id_name = env:getHeader("origination_caller_id_name") or '000000000000000' @@ -338,9 +339,15 @@ end end - Tasks.wait_task(task, answered, hangup_cause_q850) - if task.status ~= 0 then - Tasks.remove_task(task) + -- if task use group call then retry.lua will be called multiple times + -- here we check eathre that channel which execute `exec.lua` + -- Note that if there no one execute `exec.lua` we do not need call this + -- becase it should deal in `next.lua` + if fax_queue_task_session == uuid then + Tasks.wait_task(task, answered, hangup_cause_q850) + if task.status ~= 0 then + Tasks.remove_task(task) + end end end diff --git a/resources/install/scripts/fax_queue/tasks.lua b/resources/install/scripts/fax_queue/tasks.lua index 920f1e9087..96f6d612bf 100644 --- a/resources/install/scripts/fax_queue/tasks.lua +++ b/resources/install/scripts/fax_queue/tasks.lua @@ -103,6 +103,14 @@ local remove_finished_tasks_sql = [[ delete from v_fax_tasks where task_status > 3 ]] +local function serialize(task, header) + local str = header or '' + for k, v in pairs(task) do + str = str .. ('\n %q = %q'):format(tostring(k), tostring(v)) + end + return str +end + local function get_db() if not db then db = assert(Database.new('system')) diff --git a/resources/install/scripts/resources/functions/esl.lua b/resources/install/scripts/resources/functions/esl.lua index fcd4898754..f334be191c 100644 --- a/resources/install/scripts/resources/functions/esl.lua +++ b/resources/install/scripts/resources/functions/esl.lua @@ -117,7 +117,11 @@ function EventSocket:api(cmd) local event, err = self:_request('api ' .. cmd) if not event then return nil, err end local body = event:getBody() - if body then return body end + if body then + local ok, status, msg = split_status(body) + if ok == nil then return body end + return ok, status, msg + end return event:getReply() end @@ -134,6 +138,13 @@ if freeswitch then local api +-- [+-][OK|ERR|USAGE|...][Message] +local function split_status(str) + local ok, status, msg = string.match(str, "^%s*([-+])([^%s]+)%s*(.-)%s*$") + if not ok then return nil, str end + return ok == '+', status, msg +end + function EventSocket:__init() self._api = api or freeswitch.API() api = self._api @@ -142,10 +153,9 @@ end function EventSocket:api(cmd) local result = self._api:executeString(cmd) - if result and result:sub(1, 4) == '-ERR' then - return nil, result:sub(5) - end - return result + local ok, status, msg = split_status(result) + if ok == nil then return result end + return ok, status, msg end function EventSocket:close() From b00229e5fcfb0a941c7a1a8f907b2bcbc8fb5a80 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 26 Nov 2015 17:25:15 +0300 Subject: [PATCH 09/56] Fix. Remove task in next.lua --- resources/install/scripts/fax_queue/next.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/install/scripts/fax_queue/next.lua b/resources/install/scripts/fax_queue/next.lua index 9e7ac0081f..eaa8c0c790 100644 --- a/resources/install/scripts/fax_queue/next.lua +++ b/resources/install/scripts/fax_queue/next.lua @@ -51,6 +51,9 @@ local function next_task() if not ok then Tasks.release_task(task) + if task.status ~= 0 then + Tasks.remove_task(task) + end log.noticef("Error execute task: %s", tostring(err)) end From ed595a37081578dcb865cd8d35fe76ae437cb6c6 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 26 Nov 2015 17:30:56 +0300 Subject: [PATCH 10/56] Fix. Remove task in next.lua (Fix preview commit) --- resources/install/scripts/fax_queue/next.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/install/scripts/fax_queue/next.lua b/resources/install/scripts/fax_queue/next.lua index eaa8c0c790..9d5c0adfff 100644 --- a/resources/install/scripts/fax_queue/next.lua +++ b/resources/install/scripts/fax_queue/next.lua @@ -41,6 +41,9 @@ local function next_task() local ok, status, info = esl:api(originate) if not ok then Tasks.wait_task(task, false, info) + if task.status ~= 0 then + Tasks.remove_task(task) + end log.noticef('Can not originate to `%s` cause: %s: %s ', task.uri, tostring(status), tostring(info)) else log.noticef("originate successfuly: %s", tostring(info)) @@ -51,9 +54,6 @@ local function next_task() if not ok then Tasks.release_task(task) - if task.status ~= 0 then - Tasks.remove_task(task) - end log.noticef("Error execute task: %s", tostring(err)) end From 02b39d9256726f5663bba83b74cf1ba7e3a26f9a Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 14:33:08 +0000 Subject: [PATCH 11/56] Corrected storage of the event_port made a warning render correctly added a warning about choosing a remote host --- core/install/install_first_time.php | 10 ++++++++++ .../resources/page_parts/install_config_database.php | 2 +- .../resources/page_parts/install_config_detail.php | 2 +- .../resources/page_parts/install_event_socket.php | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 1416d39f69..43311d541e 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -224,6 +224,9 @@ if(!$install_step) { $install_step = 'select_language'; } echo " \n"; echo "\n"; }elseif($install_step == 'detect_config'){ + if(!($event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1')){ + echo "

Warning you have choosen a value other than localhost for event_host, this is unsoported at present

\n"; + } include "resources/page_parts/install_event_socket.php"; if($detect_ok){ echo "
\n"; @@ -238,6 +241,12 @@ if(!$install_step) { $install_step = 'select_language'; } echo " \n"; echo " \n"; echo "
\n"; + }else{ + echo "
\n"; + echo "
\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; } } elseif($install_step == 'config_detail'){ @@ -257,6 +266,7 @@ if(!$install_step) { $install_step = 'select_language'; } //if($_SERVER['HTTPS']) { $protocol = 'https'; } //echo ""; require_once "core/install/resources/classes/detect_switch.php"; + trigger_error("D:> using $event_host, $event_port, $event_password\n",E_USER_WARNING); $switch_detect = new detect_switch($event_host, $event_port, $event_password); $detect_ok = true; try { diff --git a/core/install/resources/page_parts/install_config_database.php b/core/install/resources/page_parts/install_config_database.php index ad8e632734..371a726b98 100644 --- a/core/install/resources/page_parts/install_config_database.php +++ b/core/install/resources/page_parts/install_config_database.php @@ -31,7 +31,7 @@ echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; diff --git a/core/install/resources/page_parts/install_config_detail.php b/core/install/resources/page_parts/install_config_detail.php index 8ee7597ba9..6fd2c8ce05 100644 --- a/core/install/resources/page_parts/install_config_detail.php +++ b/core/install/resources/page_parts/install_config_detail.php @@ -31,7 +31,7 @@ echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; diff --git a/core/install/resources/page_parts/install_event_socket.php b/core/install/resources/page_parts/install_event_socket.php index 7122925b4d..8588d13b1e 100644 --- a/core/install/resources/page_parts/install_event_socket.php +++ b/core/install/resources/page_parts/install_event_socket.php @@ -31,10 +31,10 @@ try { $switch_detect->detect(); } catch(Exception $e){ - $messages[] = "Failed to detect confgiuration detect_switch reported: " . $e->getMessage(); + echo "

Failed to detect configuration detect_switch reported: " . $e->getMessage() ."

\n"; $detect_ok = false; } - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "
\n"; From a439e7caa679ba2027c272f6067138a095512bbb Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 26 Nov 2015 17:41:48 +0300 Subject: [PATCH 12/56] Add. log session uuid --- resources/install/scripts/fax_queue/retry.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/install/scripts/fax_queue/retry.lua b/resources/install/scripts/fax_queue/retry.lua index d22f6df7ed..018cec372e 100644 --- a/resources/install/scripts/fax_queue/retry.lua +++ b/resources/install/scripts/fax_queue/retry.lua @@ -77,6 +77,7 @@ log.noticef([[<<< CALL RESULT >>> uuid: = '%s' + task_session_uuid: = '%s' answered: = '%s' fax_file: = '%s' wav_file: = '%s' @@ -91,6 +92,7 @@ fax_options = '%s' ]], tostring(uuid) , + tostring(fax_queue_task_session) , tostring(answered) , tostring(fax_file) , tostring(wav_file) , From e4d02022d6b9ca26ac1b222dd5009223314b0a32 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 14:56:56 +0000 Subject: [PATCH 13/56] moved fusionPBX install after switch install --- core/install/install_first_time.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 311a36091a..30452fcf8c 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -294,7 +294,6 @@ if(!$install_step) { $install_step = 'select_language'; } require_once "resources/classes/install_fusionpbx.php"; $fusionPBX = new install_fusionpbx($domain_name, null, $switch_detect); $domain_uuid = $fusionPBX->domain_uuid(); - //$fusionPBX->debug = true; $fusionPBX->admin_username = $admin_username; $fusionPBX->admin_password = $admin_password; $fusionPBX->default_country = $install_default_country; @@ -305,12 +304,13 @@ if(!$install_step) { $install_step = 'select_language'; } $fusionPBX->$key = $value; } } - $fusionPBX->install(); require_once "resources/classes/install_switch.php"; $switch = new install_switch($domain_name, $domain_uuid, $switch_detect); //$switch->debug = true; + //$fusionPBX->debug = true; $switch->install(); + $fusionPBX->install(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; From b793ccba9de0c2682eb0e1a436f498676c09f177 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 15:57:32 +0000 Subject: [PATCH 14/56] changed install order --- core/install/install_first_time.php | 6 +++--- core/install/resources/classes/install_fusionpbx.php | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 30452fcf8c..e31be9e062 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -221,7 +221,7 @@ if(!$install_step) { $install_step = 'select_language'; } echo " \n"; echo "\n"; }elseif($install_step == 'detect_config'){ - if(!($event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1')){ + if(!($event_host == '' || $event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1' )){ echo "

Warning you have choosen a value other than localhost for event_host, this is unsoported at present

\n"; } include "resources/page_parts/install_event_socket.php"; @@ -263,7 +263,6 @@ if(!$install_step) { $install_step = 'select_language'; } //if($_SERVER['HTTPS']) { $protocol = 'https'; } //echo ""; require_once "core/install/resources/classes/detect_switch.php"; - trigger_error("D:> using $event_host, $event_port, $event_password\n",E_USER_WARNING); $switch_detect = new detect_switch($event_host, $event_port, $event_password); $detect_ok = true; try { @@ -309,8 +308,9 @@ if(!$install_step) { $install_step = 'select_language'; } $switch = new install_switch($domain_name, $domain_uuid, $switch_detect); //$switch->debug = true; //$fusionPBX->debug = true; - $switch->install(); $fusionPBX->install(); + $switch->install(); + $fusionPBX->app_defaults(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 6d62060939..9c70cb7b2c 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -94,7 +94,6 @@ include "root.php"; $this->create_superuser(); require "resources/require.php"; $this->create_menus(); - $this->app_defaults(); } protected function create_config_php() { From 64e42958b390ea0564529093bba305ee2c3dc379 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 16:57:34 +0000 Subject: [PATCH 15/56] moved restart and unprotected app_defaults --- core/install/install_first_time.php | 1 + core/install/resources/classes/install_fusionpbx.php | 2 +- core/install/resources/classes/install_switch.php | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index e31be9e062..99f0ab043a 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -311,6 +311,7 @@ if(!$install_step) { $install_step = 'select_language'; } $fusionPBX->install(); $switch->install(); $fusionPBX->app_defaults(); + $detect_switch->restart_switch(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 9c70cb7b2c..57ee0c6403 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -975,7 +975,7 @@ include "root.php"; } } - protected function app_defaults() { + public function app_defaults() { $this->write_progress("Running app_defaults"); //set needed session settings diff --git a/core/install/resources/classes/install_switch.php b/core/install/resources/classes/install_switch.php index 97b12dd37a..715c2cef5b 100644 --- a/core/install/resources/classes/install_switch.php +++ b/core/install/resources/classes/install_switch.php @@ -176,9 +176,6 @@ include "root.php"; function install() { $this->copy_conf(); $this->copy_scripts(); - //tell freeswitch to restart - $this->write_progress("Restarting switch"); - $this->detect_switch->restart_switch(); } function upgrade() { From ca6bd18b64dc2296d7e06033906a920002701050 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 17:53:02 +0000 Subject: [PATCH 16/56] Corrected incorrect merge --- core/upgrade/app_defaults.php | 6 ++---- core/upgrade/index.php | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/core/upgrade/app_defaults.php b/core/upgrade/app_defaults.php index b5625f3e7a..a904361bb8 100644 --- a/core/upgrade/app_defaults.php +++ b/core/upgrade/app_defaults.php @@ -34,10 +34,8 @@ if ($domains_processed == 1) { } //copy the files and directories from resources/install - $install = new install; - $install->domain_uuid = $domain_uuid; - $install->switch_scripts_dir = $_SESSION['switch']['scripts']['dir']; - $install->copy_scripts(); + $obj = new install_switch; + $obj->upgrade(); } //update the software table diff --git a/core/upgrade/index.php b/core/upgrade/index.php index ef686b4b33..6a83f51e10 100644 --- a/core/upgrade/index.php +++ b/core/upgrade/index.php @@ -72,10 +72,8 @@ if (sizeof($_POST) > 0) { //update scripts folder, if allowed (default) if ($_SESSION['switch']['scripts']['dir'] != '') { //copy the files and directories from resources/install - $install = new install; - $install->domain_uuid = $domain_uuid; - $install->switch_scripts_dir = $_SESSION['switch']['scripts']['dir']; - $install->copy_scripts(); + $obj = new install_switch; + $obj->upgrade(); //set the message $response_message = $text['message-upgrade_source_scripts']; } From 55e463b0fffb18503440674eb2f96c30ac773a69 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 18:12:35 +0000 Subject: [PATCH 17/56] populate event_socket_* for core/upgrade/app_defaults --- core/install/resources/classes/install_fusionpbx.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 57ee0c6403..ebfccc3de1 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -983,7 +983,10 @@ include "root.php"; $_SESSION["domain_uuid"] = $this->_domain_uuid; require $this->config_php; require "resources/require.php"; - + $_SESSION['event_socket_ip_address'] = $this->detect_switch->event_host; + $_SESSION['event_socket_port'] = $this->detect_switch->event_port; + $_SESSION['event_socket_password'] = $this->detect_switch->event_password; + //get the groups assigned to the user and then set the groups in $_SESSION["groups"] $sql = "SELECT * FROM v_group_users "; $sql .= "where domain_uuid=:domain_uuid "; From f45881ec4ba173dc61ebac15bb7e4c0bc79a3611 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 18:24:09 +0000 Subject: [PATCH 18/56] moved upgrade function from app_defaults moved upgrade function out to upgrade.php otherwise during initial install all app_defaults get run twice --- core/install/resources/classes/install_fusionpbx.php | 4 ---- core/upgrade/app_defaults.php | 11 ----------- core/upgrade/upgrade.php | 5 ++++- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index ebfccc3de1..d72a42e4bc 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -1018,10 +1018,6 @@ include "root.php"; $_SESSION['permissions'] = $prep_statementsub->fetchAll(PDO::FETCH_NAMED); unset($sql, $prep_statementsub); - - - - require_once "resources/classes/schema.php"; global $db, $db_type, $db_name, $db_username, $db_password, $db_host, $db_path, $db_port; diff --git a/core/upgrade/app_defaults.php b/core/upgrade/app_defaults.php index a904361bb8..18edf8e23e 100644 --- a/core/upgrade/app_defaults.php +++ b/core/upgrade/app_defaults.php @@ -26,17 +26,6 @@ if ($domains_processed == 1) { - //process if the scripts directory exists - if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { - //if the resource scripts resource directory does not exist then create it - if (!is_dir($_SESSION['switch']['scripts']['dir']."/resources")) { - mkdir($_SESSION['switch']['scripts']['dir']."/resources",0755,true); - } - - //copy the files and directories from resources/install - $obj = new install_switch; - $obj->upgrade(); - } //update the software table $sql = "select count(*) as num_rows from v_software "; diff --git a/core/upgrade/upgrade.php b/core/upgrade/upgrade.php index 0a882c14c1..119d249bab 100644 --- a/core/upgrade/upgrade.php +++ b/core/upgrade/upgrade.php @@ -67,7 +67,10 @@ $obj = new schema; echo $obj->schema("text"); -//run all app_defaults.php files +//request teh switch to perform upgrade functions + $obj = new install_switch; + $obj->upgrade(); + require_once "resources/classes/domains.php"; $domain = new domains; $domain->upgrade(); From 14b873f5dbfa133161b768bade6f16a35e5abf04 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 18:25:46 +0000 Subject: [PATCH 19/56] corrected spelling mistake --- core/upgrade/upgrade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/upgrade/upgrade.php b/core/upgrade/upgrade.php index 119d249bab..3698ef8332 100644 --- a/core/upgrade/upgrade.php +++ b/core/upgrade/upgrade.php @@ -67,7 +67,7 @@ $obj = new schema; echo $obj->schema("text"); -//request teh switch to perform upgrade functions +//request the switch to perform upgrade functions $obj = new install_switch; $obj->upgrade(); From 6cb5fb5f5d123997bffa7c094657058eb6b88d7a Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 18:35:11 +0000 Subject: [PATCH 20/56] incorrect reference to get the switch to restart --- core/install/install_first_time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 99f0ab043a..5d4392e586 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -311,7 +311,7 @@ if(!$install_step) { $install_step = 'select_language'; } $fusionPBX->install(); $switch->install(); $fusionPBX->app_defaults(); - $detect_switch->restart_switch(); + $switch->detect_switch->restart_switch(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; From 98ba8ea089a44dddeb0e22ab1b80a2250dccb1d2 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Thu, 26 Nov 2015 18:45:11 +0000 Subject: [PATCH 21/56] corrected use of detect --- core/install/install_first_time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 5d4392e586..2a4c5ce344 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -311,7 +311,7 @@ if(!$install_step) { $install_step = 'select_language'; } $fusionPBX->install(); $switch->install(); $fusionPBX->app_defaults(); - $switch->detect_switch->restart_switch(); + $switch_detect->restart_switch(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; From 2aaba3b440a57773c9cfc129a9f00ed0283b9bde Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 27 Nov 2015 14:50:08 +0300 Subject: [PATCH 22/56] Fix. Use wrapper bat file to v_malito.php on Windows. Tested on WAMP and OpenServer. --- resources/switch.php | 66 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/resources/switch.php b/resources/switch.php index e4eb04c532..9088a49638 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -1267,10 +1267,24 @@ if (!function_exists('switch_conf_xml')) { //prepare the php variables if (stristr(PHP_OS, 'WIN')) { - $bindir = getenv(PHPRC); - $v_mailer_app ='""'. $bindir."/php". '" -f '.$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/v_mailto.php -- "'; - $v_mailer_app = sprintf("'%s'", $v_mailer_app); + $bindir = find_php_by_extension(); + if(!$bindir) + $bindir = getenv(PHPRC); + + $secure_path = path_join($_SERVER["DOCUMENT_ROOT"], PROJECT_PATH, 'secure'); + + $v_mail_bat = path_join($secure_path, 'v_mailto.bat'); + $v_mail_cmd = '@' . + '"' . str_replace('/', '\\', path_join($bindir, 'php.exe')) . '" ' . + '"' . str_replace('/', '\\', path_join($secure_path, 'v_mailto.php')) . '" '; + + $fout = fopen($v_mail_bat, "w+"); + fwrite($fout, $v_mail_cmd); + fclose($fout); + + $v_mailer_app = '"' . str_replace('/', '\\', $v_mail_bat) . '"'; $v_mailer_app_args = ""; + unset($v_mail_bat, $v_mail_cmd, $secure_path, $bindir, $fout); } else { if (file_exists(PHP_BINDIR.'/php')) { define("PHP_BIN", "php"); } @@ -1453,4 +1467,50 @@ if (!function_exists('save_switch_xml')) { } } +if(!function_exists('path_join')) { + function path_join() { + $args = func_get_args(); + $paths = array(); + foreach ($args as $arg) { + $paths = array_merge($paths, (array)$arg); + } + + $prefix = null; + foreach($paths as &$path) { + if($prefix === null && strlen($path) > 0) { + if(substr($path, 0, 1) == '/') $prefix = '/'; + else $prefix = ''; + } + $path = trim( $path, '/' ); + } + + if($prefix === null){ + return ''; + } + + $paths = array_filter($paths); + + return $prefix . join('/', $paths); + } +} + +if(!function_exists('find_php_by_extension')) { + /*Tesetd on WAMP and OpenServer*/ + function find_php_by_extension(){ + $bin_dir = get_cfg_var('extension_dir'); + + while($bin_dir){ + $bin_dir = dirname($bin_dir); + $php_bin = path_join($bin_dir, 'php.exe'); + if(file_exists($php_bin)) + break; + } + + if(!$bin_dir) + return false; + + return $bin_dir; + } +} + ?> From 406e95ab292c6999f9a64dc107b86aa1f7e9cbfa Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 27 Nov 2015 15:34:58 +0300 Subject: [PATCH 23/56] Add. `send_mail` wrapper function to freeswitch.email and v_mailto.php. Fix. Send voicemail when set unknown language/dialect. --- .../resources/functions/send_email.lua | 45 ++++---- .../scripts/resources/functions/send_mail.lua | 107 ++++++++++++++++++ 2 files changed, 130 insertions(+), 22 deletions(-) create mode 100644 resources/install/scripts/resources/functions/send_mail.lua 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 7009932369..0cb437c19e 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua @@ -23,6 +23,12 @@ -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. + local send_mail = require 'resources.functions.send_mail' + + local function T(str) + return text[str][default_language..'-'..default_dialect] or text[str]['en-us'] + end + --define a function to send email function send_email(id, uuid) --get voicemail message details @@ -103,10 +109,12 @@ end --prepare the headers - headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; - headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; - headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; - headers = headers..'"X-FusionPBX-Email-Type":"voicemail"}'; + local headers = { + ["X-FusionPBX-Domain-UUID"] = domain_uuid; + ["X-FusionPBX-Domain-Name"] = domain_name; + ["X-FusionPBX-Call-UUID"] = uuid; + ["X-FusionPBX-Email-Type"] = 'voicemail'; + } --prepare the subject local f = io.open(file_subject, "r"); @@ -134,11 +142,11 @@ 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]); + body = body:gsub("${message}", T'label-attached'); elseif (voicemail_file == "link") then - body = body:gsub("${message}", ""..text['label-download'][default_language.."-"..default_dialect]..""); + body = body:gsub("${message}", ""..T'label-download'..""); else - body = body:gsub("${message}", ""..text['label-listen'][default_language.."-"..default_dialect]..""); + body = body:gsub("${message}", ""..T'label-listen'..""); end body = body:gsub(" ", " "); body = body:gsub("%s+", ""); @@ -147,22 +155,15 @@ body = body:gsub("\n", ""); body = trim(body); - --send the email + --prepare file file = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext; - if (voicemail_file == "attach") then - freeswitch.email("", - "", - "To: "..voicemail_mail_to.."\nFrom: "..voicemail_mail_to.."\nX-Headers: "..headers.."\nSubject: "..subject, - body, - file - ); - else - freeswitch.email("", - "", - "To: "..voicemail_mail_to.."\nFrom: "..voicemail_mail_to.."\nX-Headers: "..headers.."\nSubject: "..subject, - body - ); - end + + --send the email + send_mail(headers, + voicemail_mail_to, + {subject, body}, + (voicemail_file == "attach") and file + ); end --whether to keep the voicemail message and details local after email diff --git a/resources/install/scripts/resources/functions/send_mail.lua b/resources/install/scripts/resources/functions/send_mail.lua new file mode 100644 index 0000000000..706e6c80b3 --- /dev/null +++ b/resources/install/scripts/resources/functions/send_mail.lua @@ -0,0 +1,107 @@ + +local send_mail + +if not freeswitch then + local Settings = require "resources.functions.lazy_settings" + local Database = require "resources.functions.database" + local log = require "resources.functions.log".sendmail + local sendmail = require "sendmail" + local uuid = require "uuid" + + function send_mail(headers, address, message, file) + local domain_uuid = headers["X-FusionPBX-Domain-UUID"] + local domain_name = headers["X-FusionPBX-Domain-Name"] + local email_type = headers["X-FusionPBX-Email-Type"] or 'info' + local call_uuid = headers["X-FusionPBX-Email-Type"] + local db = dbh or Database.new('system') + local settings = Settings.new(db, domain_name, domain_uuid) + + local ssl = settings:get('email', 'smtp_secure', 'var'); + + local ok, err = sendmail{ + server = { + address = settings:get('email','smtp_host','var'); + user = settings:get('email','smtp_username','var'); + password = settings:get('email','smtp_password','var'); + ssl = (ssl == 'true') and { verify = {"none"} }; + }, + + from = { + title = settings:get('email', 'smtp_from_name', 'var'); + address = settings:get('email', 'smtp_from', 'var'); + }, + + to = { + address = address; + }, + + message = message; + file = file; + } + + if not ok then + log.warningf("Mailer Error: %s", err) + + local email_uuid = uuid.new() + local sql = "insert into v_emails ( " + sql = sql .. "email_uuid, " + if call_uuid then sql = sql .. "call_uuid, " end + sql = sql .. "domain_uuid, " + sql = sql .. "sent_date, " + sql = sql .. "type, " + sql = sql .. "status, " + sql = sql .. "email " + sql = sql .. ") values ( " + sql = sql .. "'" .. email_uuid .. "', " + if call_uuid then sql = sql .. "'" .. call_uuid .. "', " end + sql = sql .. "'" .. domain_uuid .. "', " + sql = sql .. "now()," + sql = sql .. "'" .. email_type .. "', " + sql = sql .. "'failed', " + sql = sql .. "'' " + sql = sql .. ") " + + db:query(sql) + + log.infof("Retained in v_emails as email_uuid = %s", email_uuid) + else + log.infof("Mail to %s sent!", address) + end + end +end + +if freeswitch then + function send_mail(headers, address, message, file) + local xheaders = "{" + for k,v in pairs(headers) do + xheaders = xheaders .. ("'%s':'%s',"):format(k, v) + end + xheaders = xheaders:sub(1,-2) .. '}' + + local subject = message[1] + local body = message[2] or '' + + local mail_headers = + "To: " .. address .. "\n" .. + "From: " .. address .. "\n" .. + "Subject: " .. subject .. "\n" .. + "X-Headers: " .. xheaders + + if file then + freeswitch.email(address, address, mail_headers, body, file) + else + freeswitch.email(address, address, mail_headers, body, file) + end + end +end + +return send_mail + +-- local headers = { +-- ["X-FusionPBX-Domain-UUID"] = '2d171c4c-b237-49ca-9d76-9cffc1618fa7'; +-- ["X-FusionPBX-Domain-Name"] = 'domain.com'; +-- ["X-FusionPBX-Email-Type"] = 'voicemail'; +-- } +-- send_mail(headers, 'alexey@domain.com', {'hello', 'world'}) + + From 83022b60b2f67877e687fc542de45dbd10ed7960 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 27 Nov 2015 16:29:52 +0300 Subject: [PATCH 24/56] Fix. json encode x-headers --- resources/install/scripts/resources/functions/send_mail.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/resources/functions/send_mail.lua b/resources/install/scripts/resources/functions/send_mail.lua index 706e6c80b3..52f8e647e4 100644 --- a/resources/install/scripts/resources/functions/send_mail.lua +++ b/resources/install/scripts/resources/functions/send_mail.lua @@ -74,7 +74,7 @@ if freeswitch then function send_mail(headers, address, message, file) local xheaders = "{" for k,v in pairs(headers) do - xheaders = xheaders .. ("'%s':'%s',"):format(k, v) + xheaders = xheaders .. ('"%s":"%s",'):format(k, v) end xheaders = xheaders:sub(1,-2) .. '}' From 7c275f54af6d7afc1205359ea2c3e21b6124ed15 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 11:25:06 -0700 Subject: [PATCH 25/56] Add domain_uuid is null to the dialplan class similar to how already done in the ring_groups/index.lua. --- app/dialplan/resources/classes/dialplan.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/dialplan/resources/classes/dialplan.php b/app/dialplan/resources/classes/dialplan.php index c828cc25b1..92631e73d3 100644 --- a/app/dialplan/resources/classes/dialplan.php +++ b/app/dialplan/resources/classes/dialplan.php @@ -381,7 +381,11 @@ include "root.php"; if (!is_array($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) { //get the outbound routes from the database $sql = "select * from v_dialplans as d, v_dialplan_details as s "; - $sql .= "where d.domain_uuid = '".$this->domain_uuid."' "; + $sql .= "where "; + $sql .= "( "; + $sql .= "d.domain_uuid = '".$this->domain_uuid."' "; + $sql .= "or d.domain_uuid is null "; + $sql .= ") "; $sql .= "and d.app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; $sql .= "and d.dialplan_enabled = 'true' "; $sql .= "and d.dialplan_uuid = s.dialplan_uuid "; From c4ec6c0a931768393ff3bf185552e20ff185bff7 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 11:25:50 -0700 Subject: [PATCH 26/56] Add the additional language variables to app_languages.php. --- app/fax/app_languages.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/fax/app_languages.php b/app/fax/app_languages.php index 5d47714551..5ab3463d98 100644 --- a/app/fax/app_languages.php +++ b/app/fax/app_languages.php @@ -1112,8 +1112,26 @@ $text['label-accountcode']['ro'] = "Cod cont"; $text['label-accountcode']['he'] = "קוד חשבון"; $text['label-fax_send_greeting']['en-us'] = "Greeting"; +$text['label-fax_send_greeting']['es-cl'] = ""; +$text['label-fax_send_greeting']['pt-pt'] = ""; +$text['label-fax_send_greeting']['fr-fr'] = ""; +$text['label-fax_send_greeting']['pt-br'] = ""; +$text['label-fax_send_greeting']['pl'] = ""; +$text['label-fax_send_greeting']['sv-se'] = ""; +$text['label-fax_send_greeting']['de-at'] = ""; +$text['label-fax_send_greeting']['ro'] = ""; +$text['label-fax_send_greeting']['he'] = ""; $text['label-fax_send_channels']['en-us'] = "Number of channels"; +$text['label-fax_send_channels']['es-cl'] = ""; +$text['label-fax_send_channels']['pt-pt'] = ""; +$text['label-fax_send_channels']['fr-fr'] = ""; +$text['label-fax_send_channels']['pt-br'] = ""; +$text['label-fax_send_channels']['pl'] = ""; +$text['label-fax_send_channels']['sv-se'] = ""; +$text['label-fax_send_channels']['de-at'] = ""; +$text['label-fax_send_channels']['ro'] = ""; +$text['label-fax_send_channels']['he'] = ""; $text['header-sent']['en-us'] = "Sent Faxes"; $text['header-sent']['es-cl'] = "Los Faxes Enviados"; From 744ba6f9a4132198babc079650206910b9680aa5 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 13:56:53 -0700 Subject: [PATCH 27/56] Correct the file names of the Mitel templates. --- .../provision/mitel/5324/{MN_${mac}.cfg => MN_{$mac}.cfg} | 0 .../provision/mitel/5340/{MN_${mac}.cfg => MN_{$mac}.cfg} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename resources/templates/provision/mitel/5324/{MN_${mac}.cfg => MN_{$mac}.cfg} (100%) rename resources/templates/provision/mitel/5340/{MN_${mac}.cfg => MN_{$mac}.cfg} (100%) diff --git a/resources/templates/provision/mitel/5324/MN_${mac}.cfg b/resources/templates/provision/mitel/5324/MN_{$mac}.cfg similarity index 100% rename from resources/templates/provision/mitel/5324/MN_${mac}.cfg rename to resources/templates/provision/mitel/5324/MN_{$mac}.cfg diff --git a/resources/templates/provision/mitel/5340/MN_${mac}.cfg b/resources/templates/provision/mitel/5340/MN_{$mac}.cfg similarity index 100% rename from resources/templates/provision/mitel/5340/MN_${mac}.cfg rename to resources/templates/provision/mitel/5340/MN_{$mac}.cfg From 03f9843cb9c6572f167a564614971221baf062df Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 14:10:49 -0700 Subject: [PATCH 28/56] Fix the provision path. --- app/provision/resources/classes/provision.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 6905a786ed..5167454297 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -801,6 +801,13 @@ include "root.php"; $tmp_array = ''; $i = 0; + //build the provision array + foreach($_SESSION['provision'] as $key=>$val) { + if (strlen($val['var']) > 0) { $value = $val['var']; } + if (strlen($val['text']) > 0) { $value = $val['text']; } + $provision[$key] = $value; + } + //get the devices $sql = "select * from v_devices "; //$sql .= "where domain_uuid = '".$this->domain_uuid."' "; From 55c1679a513060af8bc5b64faf7f735a4e0638b8 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 17:14:44 -0700 Subject: [PATCH 29/56] Add some translations for the install. --- core/install/app_languages.php | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/core/install/app_languages.php b/core/install/app_languages.php index 7dcfb2145f..314dd79502 100644 --- a/core/install/app_languages.php +++ b/core/install/app_languages.php @@ -1,8 +1,8 @@ Date: Fri, 27 Nov 2015 17:47:28 -0700 Subject: [PATCH 30/56] Include the config.php file in the install so that the config.lua will have the db port, host, username and password values. --- core/install/install_first_time.php | 38 +++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 2a4c5ce344..32bb308e6b 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -80,7 +80,6 @@ $first_time_install = true; if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { $first_time_install = false; } elseif (file_exists("/etc/fusionpbx/config.php")) { - //linux $first_time_install = false; } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { $first_time_install = false; @@ -98,7 +97,7 @@ if(!$first_time_install) { $install_step = ''; $return_install_step = ''; -if (count($_POST)>0) { +if (count($_POST) > 0) { $install_language = check_str($_POST["install_language"]); $install_step = check_str($_POST["install_step"]); $return_install_step = check_str($_POST["return_install_step"]); @@ -291,34 +290,43 @@ if(!$install_step) { $install_step = 'select_language'; } #set_error_handler("error_handler"); try { require_once "resources/classes/install_fusionpbx.php"; - $fusionPBX = new install_fusionpbx($domain_name, null, $switch_detect); - $domain_uuid = $fusionPBX->domain_uuid(); - $fusionPBX->admin_username = $admin_username; - $fusionPBX->admin_password = $admin_password; - $fusionPBX->default_country = $install_default_country; - $fusionPBX->install_language = $install_language; - $fusionPBX->template_name = $install_template_name; + $system = new install_fusionpbx($domain_name, null, $switch_detect); + $domain_uuid = $system->domain_uuid(); + $system->admin_username = $admin_username; + $system->admin_password = $admin_password; + $system->default_country = $install_default_country; + $system->install_language = $install_language; + $system->template_name = $install_template_name; foreach($_POST as $key=>$value){ if(substr($key,0,3) == "db_"){ - $fusionPBX->$key = $value; + $system->$key = $value; } } + //include the config.php + if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { + require_once $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"; + } elseif (file_exists("/etc/fusionpbx/config.php")) { + require_once "/etc/fusionpbx/config.php"; + } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { + require_once "/usr/local/etc/fusionpbx/config.php"; + } + require_once "resources/classes/install_switch.php"; $switch = new install_switch($domain_name, $domain_uuid, $switch_detect); //$switch->debug = true; - //$fusionPBX->debug = true; - $fusionPBX->install(); + //$system->debug = true; + $system->install(); $switch->install(); - $fusionPBX->app_defaults(); + $system->app_defaults(); $switch_detect->restart_switch(); }catch(Exception $e){ echo "\n"; echo "

Failed to install
" . $e->getMessage() . "

\n"; try { require_once "resources/classes/install_fusionpbx.php"; - $fusionPBX = new install_fusionpbx($domain_name, $domain_uuid, $switch_detect); - $fusionPBX->remove_config(); + $system = new install_fusionpbx($domain_name, $domain_uuid, $switch_detect); + $system->remove_config(); }catch(Exception $e){ echo "

Failed to remove config: " . $e->getMessage() . "

\n"; } From 25e67742a538560920645632a527a73617841b57 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 18:04:59 -0700 Subject: [PATCH 31/56] Get rid of trailing tabs, correct some of the vertical line spacing, and other minor changes. --- .../resources/classes/install_fusionpbx.php | 95 ++++++++++--------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index d72a42e4bc..f9ef013c13 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -54,7 +54,7 @@ include "root.php"; public $db_name; public $db_username; public $db_password; - + function __construct($domain_name, $domain_uuid, $detect_switch) { if(!is_a($detect_switch, 'detect_switch')){ throw new Exception('The parameter $detect_switch must be a detect_switch object (or a subclass of)'); @@ -95,7 +95,7 @@ include "root.php"; require "resources/require.php"; $this->create_menus(); } - + protected function create_config_php() { $tmp_config = "config_php; $this->write_progress("Creating database as " . $this->db_type); @@ -204,6 +204,7 @@ include "root.php"; global $db; $db = $this->dbh; } + protected function create_database_sqlite() { //sqlite database will be created when the config.php is loaded and only if the database file does not exist try { @@ -267,7 +268,7 @@ include "root.php"; } protected function create_database_pgsql() { - + //if $this->db_create_username provided, attempt to create new PG role and database if (strlen($this->db_create_username) > 0) { try { @@ -280,16 +281,16 @@ include "root.php"; } catch (PDOException $error) { throw new Exception("error connecting to database: " . $error->getMessage()); } - + //create the database, user, grant perms $this->dbh->exec("CREATE DATABASE {$this->db_name}"); $this->dbh->exec("CREATE USER {$this->db_username} WITH PASSWORD '{$this->db_password}'"); $this->dbh->exec("GRANT ALL ON {$this->db_name} TO {$this->db_username}"); - + //close database connection_aborted $this->dbh = null; } - + //open database connection with $this->db_name try { if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } @@ -302,7 +303,7 @@ include "root.php"; catch (PDOException $error) { throw new Exception("error connecting to database: " . $error->getMessage()); } - + //add the database structure require_once "resources/classes/schema.php"; $schema = new schema; @@ -310,7 +311,7 @@ include "root.php"; $schema->db_type = $this->db_type; $schema->sql(); $schema->exec(); - + //get the contents of the sql file if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql')){ $filename = "/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql"; @@ -319,10 +320,10 @@ include "root.php"; $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/pgsql.sql'; } $file_contents = file_get_contents($filename); - + //replace \r\n with \n then explode on \n $file_contents = str_replace("\r\n", "\n", $file_contents); - + //loop line by line through all the lines of sql code $string_array = explode("\n", $file_contents); $x = 0; @@ -339,7 +340,7 @@ include "root.php"; } unset ($file_contents, $sql); } - + protected function create_database_mysql() { //database connection try { @@ -376,7 +377,7 @@ include "root.php"; catch (PDOException $error) { throw new Exception("error creating database: " . $error->getMessage() . "\n" . $sql ); } - + //create the table, user and set the permissions only if the db_create_username was provided if (strlen($this->db_create_username) > 0) { //select the mysql database @@ -388,7 +389,7 @@ include "root.php"; throw new Exception("error conencting to database: " . $error->getMessage()); } } - + //create user and set the permissions try { $tmp_sql = "CREATE USER '".$this->db_username."'@'%' IDENTIFIED BY '".$this->db_password."'; "; @@ -399,7 +400,7 @@ include "root.php"; print "error: " . $error->getMessage() . "
"; } } - + //set account to unlimited use try { if ($this->db_host == "localhost" || $this->db_host == "127.0.0.1") { @@ -407,7 +408,7 @@ include "root.php"; $tmp_sql .= "IDENTIFIED BY '".$this->db_password."' "; $tmp_sql .= "WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; "; $this->dbh->query($tmp_sql); - + $tmp_sql = "GRANT USAGE ON * . * TO '".$this->db_username."'@'127.0.0.1' "; $tmp_sql .= "IDENTIFIED BY '".$this->db_password."' "; $tmp_sql .= "WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; "; @@ -425,7 +426,7 @@ include "root.php"; print "error: " . $error->getMessage() . "
"; } } - + //create the database and set the create user with permissions try { $tmp_sql = "CREATE DATABASE IF NOT EXISTS ".$this->db_name."; "; @@ -436,7 +437,7 @@ include "root.php"; print "error: " . $error->getMessage() . "
"; } } - + //set user permissions try { $this->dbh->query("GRANT ALL PRIVILEGES ON ".$this->db_name.".* TO '".$this->db_username."'@'%'; "); @@ -446,7 +447,7 @@ include "root.php"; print "error: " . $error->getMessage() . "
"; } } - + //make the changes active try { $tmp_sql = "FLUSH PRIVILEGES; "; @@ -457,9 +458,9 @@ include "root.php"; print "error: " . $error->getMessage() . "
"; } } - + } //if (strlen($this->db_create_username) > 0) - + //select the database try { $this->dbh->query("USE ".$this->db_name.";"); @@ -469,7 +470,7 @@ include "root.php"; print "error: " . $error->getMessage() . "
"; } } - + //add the database structure require_once "resources/classes/schema.php"; $schema = new schema; @@ -477,7 +478,7 @@ include "root.php"; $schema->db_type = $this->db_type; $schema->sql(); $schema->exec(); - + //add the defaults data into the database //get the contents of the sql file if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/mysql.sql')){ @@ -487,10 +488,10 @@ include "root.php"; $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/mysql.sql'; } $file_contents = file_get_contents($filename); - + //replace \r\n with \n then explode on \n $file_contents = str_replace("\r\n", "\n", $file_contents); - + //loop line by line through all the lines of sql code $string_array = explode("\n", $file_contents); $x = 0; @@ -512,7 +513,6 @@ include "root.php"; unset ($file_contents, $sql); } - protected function create_domain() { $this->write_progress("Checking if domain exists '" . $this->domain_name . "'"); $sql = "select * from v_domains "; @@ -529,7 +529,7 @@ include "root.php"; if($result['domain_enabled'] != 'true'){ throw new Exception("Domain already exists but is disabled, this is unexpected"); } - }else{ + } else { $this->write_progress("... creating domain"); $sql = "insert into v_domains "; $sql .= "("; @@ -543,11 +543,11 @@ include "root.php"; $sql .= "'".$this->domain_name."', "; $sql .= "'' "; $sql .= ");"; - + $this->write_debug($sql); $this->dbh->exec(check_sql($sql)); unset($sql); - + //domain settings $x = 0; $tmp[$x]['name'] = 'uuid'; @@ -579,7 +579,7 @@ include "root.php"; $tmp[$x]['subcategory'] = 'template'; $tmp[$x]['enabled'] = 'true'; $x++; - + //switch settings $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_bin_dir; @@ -677,7 +677,7 @@ include "root.php"; $tmp[$x]['subcategory'] = 'dialplan'; $tmp[$x]['enabled'] = 'false'; $x++; - + //server settings $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $this->detect_switch->temp_dir(); @@ -698,7 +698,7 @@ include "root.php"; $tmp[$x]['subcategory'] = 'backup'; $tmp[$x]['enabled'] = 'true'; $x++; - + $this->dbh->beginTransaction(); foreach($tmp as $row) { $sql = "insert into v_default_settings "; @@ -725,7 +725,7 @@ include "root.php"; } $this->dbh->commit(); unset($tmp); - + //get the list of installed apps from the core and mod directories $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); $x=0; @@ -733,7 +733,7 @@ include "root.php"; include($config_path); $x++; } - + //add the groups $x = 0; $tmp[$x]['group_name'] = 'superadmin'; @@ -807,7 +807,7 @@ include "root.php"; $this->dbh->commit(); } } - + protected function create_superuser() { $this->write_progress("Checking if superuser exists '" . $this->domain_name . "'"); $sql = "select * from v_users "; @@ -926,14 +926,14 @@ include "root.php"; unset($sql); } } - + protected function create_menus() { $this->write_progress("Creating menus"); //set the defaults $menu_name = 'default'; $menu_language = 'en-us'; $menu_description = 'Default Menu Set'; - + $this->write_progress("Checking if menu exists"); $sql = "select count(*) from v_menus "; $sql .= "where menu_uuid = '".$this->menu_uuid."' "; @@ -964,7 +964,7 @@ include "root.php"; } $this->dbh->exec(check_sql($sql)); unset($sql); - + //add the menu items require_once "resources/classes/menu.php"; $menu = new menu; @@ -974,10 +974,10 @@ include "root.php"; unset($menu); } } - + public function app_defaults() { $this->write_progress("Running app_defaults"); - + //set needed session settings $_SESSION["username"] = $this->admin_username; $_SESSION["domain_uuid"] = $this->_domain_uuid; @@ -986,7 +986,7 @@ include "root.php"; $_SESSION['event_socket_ip_address'] = $this->detect_switch->event_host; $_SESSION['event_socket_port'] = $this->detect_switch->event_port; $_SESSION['event_socket_password'] = $this->detect_switch->event_password; - + //get the groups assigned to the user and then set the groups in $_SESSION["groups"] $sql = "SELECT * FROM v_group_users "; $sql .= "where domain_uuid=:domain_uuid "; @@ -998,7 +998,7 @@ include "root.php"; $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $_SESSION["groups"] = $result; unset($sql, $row_count, $prep_statement); - + //get the permissions assigned to the groups that the user is a member of set the permissions in $_SESSION['permissions'] $x = 0; $sql = "select distinct(permission_name) from v_group_permissions "; @@ -1028,18 +1028,18 @@ include "root.php"; $default_language = $this->install_language; $domain = new domains; $domain->upgrade(); - + //synchronize the config with the saved settings save_switch_xml(); - + //do not show the apply settings reminder on the login page $_SESSION["reload_xml"] = false; - + //clear the menu $_SESSION["menu"] = ""; - + } - + public function remove_config() { if (file_exists('/bin/rm')) { $this->write_debug('rm -f ' . $this->config_php); @@ -1056,4 +1056,5 @@ include "root.php"; clearstatcache(); } } + ?> \ No newline at end of file From 1408ca0b8a1826b59591f7297bca82506b2ab84b Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 18:13:13 -0700 Subject: [PATCH 32/56] Move config.php into install -> app defaults method. --- core/install/install_first_time.php | 9 --------- .../resources/classes/install_fusionpbx.php | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index 32bb308e6b..ad08a3faeb 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -303,15 +303,6 @@ if(!$install_step) { $install_step = 'select_language'; } } } - //include the config.php - if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { - require_once $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"; - } elseif (file_exists("/etc/fusionpbx/config.php")) { - require_once "/etc/fusionpbx/config.php"; - } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { - require_once "/usr/local/etc/fusionpbx/config.php"; - } - require_once "resources/classes/install_switch.php"; $switch = new install_switch($domain_name, $domain_uuid, $switch_detect); //$switch->debug = true; diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index f9ef013c13..75692d5ae6 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -978,6 +978,17 @@ include "root.php"; public function app_defaults() { $this->write_progress("Running app_defaults"); + //include the config.php + if (strlen($db_name) == 0) { + if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { + require_once $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"; + } elseif (file_exists("/etc/fusionpbx/config.php")) { + require_once "/etc/fusionpbx/config.php"; + } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { + require_once "/usr/local/etc/fusionpbx/config.php"; + } + } + //set needed session settings $_SESSION["username"] = $this->admin_username; $_SESSION["domain_uuid"] = $this->_domain_uuid; @@ -1020,10 +1031,10 @@ include "root.php"; require_once "resources/classes/schema.php"; global $db, $db_type, $db_name, $db_username, $db_password, $db_host, $db_path, $db_port; - + $schema = new schema; echo $schema->schema(); - + //run all app_defaults.php files $default_language = $this->install_language; $domain = new domains; From 377ab8cfd9362d3903c19f2d981b0b83c7d25d13 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 18:57:23 -0700 Subject: [PATCH 33/56] Add a new config.php class. --- resources/classes/config.php.txt | 88 ++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 resources/classes/config.php.txt diff --git a/resources/classes/config.php.txt b/resources/classes/config.php.txt new file mode 100644 index 0000000000..b7027186bb --- /dev/null +++ b/resources/classes/config.php.txt @@ -0,0 +1,88 @@ + $value) { + unset($this->$key); + } + } + + /** + * Determine whether the config.php exists + * @var string $db_type - type of database + * @var string $db_name - name of the database + * @var string $db_username - username to access the database + * @var string $db_password - password to access the database + * @var string $db_host - hostname of the database server + * @var string $db_path - path of the database file + * @var string $db_port - network port to connect to the database + */ + public function get() { + if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { + include($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"); + } elseif (file_exists("/etc/fusionpbx/config.php")) { + include("/etc/fusionpbx/config.php"); + } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { + include("/usr/local/etc/fusionpbx/config.php"); + } + $this->db_type = $db_type; + $this->db_name = $db_name; + $this->db_username = $db_username; + $this->db_password = $db_password; + $this->db_host = $db_host; + $this->db_path = $db_path; + $this->db_port = $db_port; + } + + /** + * Determine whether the config.php exists + */ + public function exists() { + if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { + return true; + } elseif (file_exists("/etc/fusionpbx/config.php")) { + return true; + } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { + return true; + } + else { + return false; + } + } +} +/* +$config = new config; +$config = $config->get; +$config_exists = $config->exists(); +*/ + +?> \ No newline at end of file From e4d850aa10165a1748be99b1c83afaffd25ca00b Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 19:03:25 -0700 Subject: [PATCH 34/56] Rename the config.php file and a few minor adjustments to install_fusionpbx. --- .../resources/classes/install_fusionpbx.php | 36 ++-- .../classes/{config.php.txt => config.php} | 0 .../resources/scripts/configuration/ivr.lua | 165 ++++++++++++++++++ 3 files changed, 183 insertions(+), 18 deletions(-) rename resources/classes/{config.php.txt => config.php} (100%) create mode 100644 resources/install/scripts/app/xml_handler/resources/scripts/configuration/ivr.lua diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 75692d5ae6..4e24c7ba4b 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -35,11 +35,11 @@ include "root.php"; protected $config_php; protected $menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286'; protected $dbh; - + public function domain_uuid() { return $this->_domain_uuid; } public $debug = false; - + public $install_msg; public $install_language = 'en-us'; public $admin_username; @@ -183,10 +183,11 @@ include "root.php"; $tmp_config .= " error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings"; $tmp_config .= "\n"; $tmp_config .= "?>"; - - if((file_exists($this->config_php) and !is_writable($this->config_php)) - or !is_writable(dirname($this->config_php)) - ){ + + if((file_exists($this->config_php) + and !is_writable($this->config_php)) + or !is_writable(dirname($this->config_php)) + ) { throw new Exception("cannot write to '" . $this->config_php . "'" ); } $this->write_progress("Creating " . $this->config_php); @@ -978,17 +979,6 @@ include "root.php"; public function app_defaults() { $this->write_progress("Running app_defaults"); - //include the config.php - if (strlen($db_name) == 0) { - if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { - require_once $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"; - } elseif (file_exists("/etc/fusionpbx/config.php")) { - require_once "/etc/fusionpbx/config.php"; - } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { - require_once "/usr/local/etc/fusionpbx/config.php"; - } - } - //set needed session settings $_SESSION["username"] = $this->admin_username; $_SESSION["domain_uuid"] = $this->_domain_uuid; @@ -1029,9 +1019,19 @@ include "root.php"; $_SESSION['permissions'] = $prep_statementsub->fetchAll(PDO::FETCH_NAMED); unset($sql, $prep_statementsub); + + //include the config.php + $db_type = $this->db_type; + $db_path = $this->db_path; + $db_host = $this->db_host; + $db_port = $this->db_port; + $db_name = $this->db_name; + $db_username = $this->db_username; + $db_password = $this->db_password; + + //add the database structure require_once "resources/classes/schema.php"; global $db, $db_type, $db_name, $db_username, $db_password, $db_host, $db_path, $db_port; - $schema = new schema; echo $schema->schema(); diff --git a/resources/classes/config.php.txt b/resources/classes/config.php similarity index 100% rename from resources/classes/config.php.txt rename to resources/classes/config.php diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/ivr.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/ivr.lua new file mode 100644 index 0000000000..4f7c500011 --- /dev/null +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/ivr.lua @@ -0,0 +1,165 @@ +-- xml_handler.lua +-- Part of FusionPBX +-- Copyright (C) 2015 Mark J Crane +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are met: +-- +-- 1. Redistributions of source code must retain the above copyright notice, +-- this list of conditions and the following disclaimer. +-- +-- 2. Redistributions in binary form must reproduce the above copyright +-- 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, +-- 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, +-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +-- POSSIBILITY OF SUCH DAMAGE. + +--get the cache + hostname = trim(api:execute("switchname", "")); + if (trim(api:execute("module_exists", "mod_memcache")) == "true") then + XML_STRING = trim(api:execute("memcache", "get configuration:ivr.conf:" .. hostname)); + else + XML_STRING = "-ERR NOT FOUND"; + end + +--set the cache + if (XML_STRING == "-ERR NOT FOUND") or (XML_STRING == "-ERR CONNECTION FAILURE") then + + --connect to the database + require "resources.functions.database_handle"; + dbh = database_handle('system'); + + --exits the script if we didn't connect properly + assert(dbh:connected()); + + --get the ivr menu from the database + sql = [[SELECT * FROM v_ivr_menus + WHERE ivr_menu_uuid = ']] .. ivr_menu_uuid ..[[' + AND ivr_menu_enabled = 'true' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); + end + status = dbh:query(sql, function(row) + domain_uuid = row["domain_uuid"]; + ivr_menu_name = row["ivr_menu_name"]; + --ivr_menu_extension = row["ivr_menu_extension"]; + ivr_menu_greet_long = row["ivr_menu_greet_long"]; + ivr_menu_greet_short = row["ivr_menu_greet_short"]; + ivr_menu_invalid_sound = row["ivr_menu_invalid_sound"]; + ivr_menu_exit_sound = row["ivr_menu_exit_sound"]; + ivr_menu_confirm_macro = row["ivr_menu_confirm_macro"]; + ivr_menu_confirm_key = row["ivr_menu_confirm_key"]; + ivr_menu_tts_engine = row["ivr_menu_tts_engine"]; + ivr_menu_tts_voice = row["ivr_menu_tts_voice"]; + ivr_menu_confirm_attempts = row["ivr_menu_confirm_attempts"]; + ivr_menu_timeout = row["ivr_menu_timeout"]; + --ivr_menu_exit_app = row["ivr_menu_exit_app"]; + --ivr_menu_exit_data = row["ivr_menu_exit_data"]; + ivr_menu_inter_digit_timeout = row["ivr_menu_inter_digit_timeout"]; + ivr_menu_max_failures = row["ivr_menu_max_failures"]; + ivr_menu_max_timeouts = row["ivr_menu_max_timeouts"]; + ivr_menu_digit_len = row["ivr_menu_digit_len"]; + + ivr_menu_direct_dial = row["ivr_menu_direct_dial"]; + ivr_menu_ringback = row["ivr_menu_ringback"]; + ivr_menu_cid_prefix = row["ivr_menu_cid_prefix"]; + ivr_menu_description = row["ivr_menu_description"]; + end); + + --recording path + + + --start the xml array + local xml = {} + table.insert(xml, [[]]); + table.insert(xml, [[]]); + table.insert(xml, [[
]]); + table.insert(xml, [[ ]]); + + table.insert(xml, [[ ]]); + dbh:query(sql, function(row) + + --build the xml + table.insert(xml, [[ ]]); + + --get the ivr menu options + sql = [[SELECT * FROM v_ivr_menu_options WHERE ivr_menu_uuid = ']] .. ivr_menu_uuid ..[[' ORDER BY ivr_menu_option_order asc ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); + end + status = dbh:query(sql, function(r) + dbh:query(sql, function(r) + ivr_menu_option_digits = r.ivr_menu_option_digits + ivr_menu_option_action = r.ivr_menu_option_action + ivr_menu_option_param = r.ivr_menu_option_param + ivr_menu_option_description = row.ivr_menu_option_description + table.insert(xml, [[]]); + end) + + --direct dial + if (ivr_menu_direct_dial == "true") then + table.insert(xml, [[\n"); + end + end) + table.insert(xml, [[ ]]); + + --close the extension tag if it was left open + table.insert(xml, [[ ]]); + table.insert(xml, [[
]]); + table.insert(xml, [[
]]); + XML_STRING = table.concat(xml, "\n"); + if (debug["xml_string"]) then + freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n"); + end + + --close the database connection + dbh:release(); + --freeswitch.consoleLog("notice", "[xml_handler]"..api:execute("eval ${dsn}")); + + --set the cache + result = trim(api:execute("memcache", "set configuration:ivr.conf:" .. hostname .." '"..XML_STRING:gsub("'", "'").."' ".."expire['ivr.conf']")); + + --send the xml to the console + if (debug["xml_string"]) then + local file = assert(io.open(temp_dir .. "/ivr.conf.xml", "w")); + file:write(XML_STRING); + file:close(); + end + + --send to the console + if (debug["cache"]) then + freeswitch.consoleLog("notice", "[xml_handler] configuration:ivr.conf:" .. hostname .." source: database\n"); + end + else + --replace the ' back to a single quote + XML_STRING = XML_STRING:gsub("'", "'"); + --send to the console + if (debug["cache"]) then + freeswitch.consoleLog("notice", "[xml_handler] configuration:ivr.conf source: memcache\n"); + end + end --if XML_STRING From ddcd8a5f2345ef5fbe9e044aff852f413d3873b0 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 19:25:16 -0700 Subject: [PATCH 35/56] Update the config php class. --- resources/classes/config.php | 65 ++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/resources/classes/config.php b/resources/classes/config.php index b7027186bb..f82b787ccb 100644 --- a/resources/classes/config.php +++ b/resources/classes/config.php @@ -4,12 +4,13 @@ * destinations * * @method get config.php - * @method exists check to see if the config.php exists + * @method exists determin if the the config.php file exists + * @method exists determin if the the config.php file exists */ class config { /** - * destinations array + * database variables and config path */ public $db_type; public $db_name; @@ -18,6 +19,7 @@ class config { public $db_host; public $db_path; public $db_port; + public $config_path; /** * Called when the object is created @@ -47,31 +49,44 @@ class config { * @var string $db_port - network port to connect to the database */ public function get() { - if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { - include($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"); - } elseif (file_exists("/etc/fusionpbx/config.php")) { - include("/etc/fusionpbx/config.php"); - } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { - include("/usr/local/etc/fusionpbx/config.php"); + $this->find(); + if ($this->exists) { + include($this->path); + $this->db_type = $db_type; + $this->db_name = $db_name; + $this->db_username = $db_username; + $this->db_password = $db_password; + $this->db_host = $db_host; + $this->db_path = $db_path; + $this->db_port = $db_port; + } } - $this->db_type = $db_type; - $this->db_name = $db_name; - $this->db_username = $db_username; - $this->db_password = $db_password; - $this->db_host = $db_host; - $this->db_path = $db_path; - $this->db_port = $db_port; + } + + /** + * determine if the config.php exists + * @var string $config_path - full path to the config.php file + */ + public function find() { + if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { + $this->config_path = $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"; + } elseif (file_exists("/etc/fusionpbx/config.php")) { + $this->config_path = "/etc/fusionpbx/config.php"; + } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { + $this->config_path = "/usr/local/etc/fusionpbx/config.php"; + } + else { + $this->config_path = ''; + } + return $this->config_path; } /** * Determine whether the config.php exists */ public function exists() { - if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { - return true; - } elseif (file_exists("/etc/fusionpbx/config.php")) { - return true; - } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { + $this->find(); + if (strlen($this->config_path) > 0) { return true; } else { @@ -81,8 +96,16 @@ class config { } /* $config = new config; -$config = $config->get; $config_exists = $config->exists(); +$config_path = $config->find(); +$config->get(); +$db_type = $config->db_type; +$db_name = $config->db_name; +$db_username = $config->db_username; +$db_password = $config->db_password; +$db_host = $config->db_host; +$db_path = $config->db_path; +$db_port = $config->db_port; */ ?> \ No newline at end of file From c0394ba790497dab3307bfd022304bb179db30c8 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 19:29:56 -0700 Subject: [PATCH 36/56] Remove some of the comments and an extra curly bracket. --- resources/classes/config.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/resources/classes/config.php b/resources/classes/config.php index f82b787ccb..b9961e02cd 100644 --- a/resources/classes/config.php +++ b/resources/classes/config.php @@ -1,10 +1,10 @@ find(); - if ($this->exists) { - include($this->path); - $this->db_type = $db_type; - $this->db_name = $db_name; - $this->db_username = $db_username; - $this->db_password = $db_password; - $this->db_host = $db_host; - $this->db_path = $db_path; - $this->db_port = $db_port; - } + $this->find(); + if ($this->exists) { + include($this->path); + $this->db_type = $db_type; + $this->db_name = $db_name; + $this->db_username = $db_username; + $this->db_password = $db_password; + $this->db_host = $db_host; + $this->db_path = $db_path; + $this->db_port = $db_port; } } /** - * determine if the config.php exists + * Find the path to the config.php * @var string $config_path - full path to the config.php file */ public function find() { From 9d9f2597bb310646ac14a96fbe4ac135678fb2f5 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 19:48:22 -0700 Subject: [PATCH 37/56] Correct the variable name and add the additional code examples. --- resources/classes/config.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/resources/classes/config.php b/resources/classes/config.php index b9961e02cd..8396bf01e7 100644 --- a/resources/classes/config.php +++ b/resources/classes/config.php @@ -51,7 +51,7 @@ class config { public function get() { $this->find(); if ($this->exists) { - include($this->path); + require $this->config_path; $this->db_type = $db_type; $this->db_name = $db_name; $this->db_username = $db_username; @@ -105,6 +105,19 @@ $db_password = $config->db_password; $db_host = $config->db_host; $db_path = $config->db_path; $db_port = $config->db_port; +echo "config_path: ".$config_path."\n"; +if ($config_exists) { + echo "config_exists: true\n"; +} else { + echo "config_exists: false\n"; +} +echo "db_type: ".$db_type."\n"; +echo "db_name: ".$db_name."\n"; +echo "db_username: ".$db_username."\n"; +echo "db_password: ".$db_password."\n"; +echo "db_host: ".$db_host."\n"; +echo "db_path: ".$db_path."\n"; +echo "db_port: ".$db_port."\n"; */ ?> \ No newline at end of file From 82e602e93ab07527051921771f8308d376f2d67e Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 19:53:30 -0700 Subject: [PATCH 38/56] Missed a set of round brackets on this->exists. --- core/install/resources/classes/install_fusionpbx.php | 10 ++++------ resources/classes/config.php | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 4e24c7ba4b..f0e4ca1597 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -1014,11 +1014,10 @@ include "root.php"; $x++; } } - $prep_statementsub = $this->dbh->prepare($sql); - $prep_statementsub->execute(); - $_SESSION['permissions'] = $prep_statementsub->fetchAll(PDO::FETCH_NAMED); - unset($sql, $prep_statementsub); - + $prep_statement_sub = $this->dbh->prepare($sql); + $prep_statement_sub->execute(); + $_SESSION['permissions'] = $prep_statement_sub->fetchAll(PDO::FETCH_NAMED); + unset($sql, $prep_statement_sub); //include the config.php $db_type = $this->db_type; @@ -1031,7 +1030,6 @@ include "root.php"; //add the database structure require_once "resources/classes/schema.php"; - global $db, $db_type, $db_name, $db_username, $db_password, $db_host, $db_path, $db_port; $schema = new schema; echo $schema->schema(); diff --git a/resources/classes/config.php b/resources/classes/config.php index 8396bf01e7..5254ed945a 100644 --- a/resources/classes/config.php +++ b/resources/classes/config.php @@ -50,7 +50,7 @@ class config { */ public function get() { $this->find(); - if ($this->exists) { + if ($this->exists()) { require $this->config_path; $this->db_type = $db_type; $this->db_name = $db_name; From 1691c3e5f03f4c988f7b5b342503cc0c20c998e4 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 27 Nov 2015 19:59:50 -0700 Subject: [PATCH 39/56] Use the new config class in the domains and schema classes. --- resources/classes/config.php | 26 +++++++++++++++----------- resources/classes/domains.php | 15 ++++++++++++++- resources/classes/schema.php | 16 ++++++++++++++-- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/resources/classes/config.php b/resources/classes/config.php index 5254ed945a..a63ba0d03e 100644 --- a/resources/classes/config.php +++ b/resources/classes/config.php @@ -67,17 +67,21 @@ class config { * @var string $config_path - full path to the config.php file */ public function find() { - if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { - $this->config_path = $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"; - } elseif (file_exists("/etc/fusionpbx/config.php")) { - $this->config_path = "/etc/fusionpbx/config.php"; - } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { - $this->config_path = "/usr/local/etc/fusionpbx/config.php"; - } - else { - $this->config_path = ''; - } - return $this->config_path; + //get the PROJECT PATH + include "root.php"; + // find the file + if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) { + $this->config_path = $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php"; + } elseif (file_exists("/etc/fusionpbx/config.php")) { + $this->config_path = "/etc/fusionpbx/config.php"; + } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { + $this->config_path = "/usr/local/etc/fusionpbx/config.php"; + } + else { + $this->config_path = ''; + } + //return the path + return $this->config_path; } /** diff --git a/resources/classes/domains.php b/resources/classes/domains.php index eecf800459..5ea36058bf 100644 --- a/resources/classes/domains.php +++ b/resources/classes/domains.php @@ -215,7 +215,20 @@ public function upgrade() { //set the global variable - global $db, $db_type, $db_name, $db_username, $db_password, $db_host, $db_path, $db_port; + global $db; + + //get the db variables + $config = new config; + $config_exists = $config->exists(); + $config_path = $config->find(); + $config->get(); + $db_type = $config->db_type; + $db_name = $config->db_name; + $db_username = $config->db_username; + $db_password = $config->db_password; + $db_host = $config->db_host; + $db_path = $config->db_path; + $db_port = $config->db_port; //get the PROJECT PATH include "root.php"; diff --git a/resources/classes/schema.php b/resources/classes/schema.php index df8f51835b..282d7dde05 100644 --- a/resources/classes/schema.php +++ b/resources/classes/schema.php @@ -448,8 +448,20 @@ include "root.php"; public function schema ($format) { //set the global variable - global $db, $db_type, $db_name, $db_username, $db_password; - global $db_host, $db_path, $db_port, $upgrade_data_types, $text; + global $db, $upgrade_data_types, $text; + + //get the db variables + $config = new config; + $config_exists = $config->exists(); + $config_path = $config->find(); + $config->get(); + $db_type = $config->db_type; + $db_name = $config->db_name; + $db_username = $config->db_username; + $db_password = $config->db_password; + $db_host = $config->db_host; + $db_path = $config->db_path; + $db_port = $config->db_port; //get the PROJECT PATH include "root.php"; From a5d6c85e6f0c534651318e0ac7b10428b8ef8cc9 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Sat, 28 Nov 2015 11:17:46 +0300 Subject: [PATCH 40/56] Change. Rename v_mailto.bat to mailto.bat --- resources/switch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/switch.php b/resources/switch.php index 9088a49638..bf96fa85a3 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -1273,7 +1273,7 @@ if (!function_exists('switch_conf_xml')) { $secure_path = path_join($_SERVER["DOCUMENT_ROOT"], PROJECT_PATH, 'secure'); - $v_mail_bat = path_join($secure_path, 'v_mailto.bat'); + $v_mail_bat = path_join($secure_path, 'mailto.bat'); $v_mail_cmd = '@' . '"' . str_replace('/', '\\', path_join($bindir, 'php.exe')) . '" ' . '"' . str_replace('/', '\\', path_join($secure_path, 'v_mailto.php')) . '" '; From 85634c801e77400d54990fbc064f9229014fc7cd Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Sat, 28 Nov 2015 11:40:54 +0300 Subject: [PATCH 41/56] Change. Move fax_queue to app/fax. --- .../{fax_queue => app/fax/resources/scripts/queue}/exec.lua | 6 +++--- .../{fax_queue => app/fax/resources/scripts/queue}/next.lua | 6 +++--- .../fax/resources/scripts/queue}/retry.lua | 2 +- .../fax/resources/scripts/queue}/tasks.lua | 0 resources/install/scripts/fax_queue_monitor.lua | 2 +- resources/install/scripts/fax_queue_poll_once.lua | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) rename resources/install/scripts/{fax_queue => app/fax/resources/scripts/queue}/exec.lua (91%) rename resources/install/scripts/{fax_queue => app/fax/resources/scripts/queue}/next.lua (84%) rename resources/install/scripts/{fax_queue => app/fax/resources/scripts/queue}/retry.lua (96%) rename resources/install/scripts/{fax_queue => app/fax/resources/scripts/queue}/tasks.lua (100%) diff --git a/resources/install/scripts/fax_queue/exec.lua b/resources/install/scripts/app/fax/resources/scripts/queue/exec.lua similarity index 91% rename from resources/install/scripts/fax_queue/exec.lua rename to resources/install/scripts/app/fax/resources/scripts/queue/exec.lua index 98de09adb7..5ff3fab443 100644 --- a/resources/install/scripts/fax_queue/exec.lua +++ b/resources/install/scripts/app/fax/resources/scripts/queue/exec.lua @@ -1,7 +1,7 @@ -- @usage without queue --- api: originate {fax_file='',wav_file='',fax_dtmf=''}user/108@domain.local &lua(fax_queue/exec.lua) +-- api: originate {fax_file='',wav_file='',fax_dtmf=''}user/108@domain.local &lua(app/fax/resources/scripts/queue/exec.lua) -- @usage with queue task --- api: originate {fax_task_uuid=''}user/108@domain.local &lua(fax_queue/exec.lua) +-- api: originate {fax_task_uuid=''}user/108@domain.local &lua(app/fax/resources/scripts/queue/exec.lua) -- @fax_dtmf -- 0-9*# - dtmf symbols -- @200 - dtmf duration in ms @@ -18,7 +18,7 @@ local log = require "resources.functions.log".fax_task -- If we handle queue task local fax_task_uuid = session:getVariable('fax_task_uuid') local task if fax_task_uuid then - local Tasks = require "fax_queue.tasks" + local Tasks = require "app.fax.resources.scripts.queue.tasks" task = Tasks.select_task(fax_task_uuid) if not task then log.warningf("Can not found fax task: %q", tostring(fax_task_uuid)) diff --git a/resources/install/scripts/fax_queue/next.lua b/resources/install/scripts/app/fax/resources/scripts/queue/next.lua similarity index 84% rename from resources/install/scripts/fax_queue/next.lua rename to resources/install/scripts/app/fax/resources/scripts/queue/next.lua index 9d5c0adfff..bb5607f5ca 100644 --- a/resources/install/scripts/fax_queue/next.lua +++ b/resources/install/scripts/app/fax/resources/scripts/queue/next.lua @@ -2,7 +2,7 @@ require "resources.functions.config" require "resources.functions.sleep" local log = require "resources.functions.log".next_fax_task -local Tasks = require "fax_queue.tasks" +local Tasks = require "app.fax.resources.scripts.queue.tasks" local Esl = require "resources.functions.esl" local FAX_OPTIONS = { @@ -30,11 +30,11 @@ local function next_task() local mode = (task.retry_counter % #FAX_OPTIONS) + 1 local dial_string = '{' .. - task.dial_string .. "api_hangup_hook='lua fax_queue/retry.lua'," .. + task.dial_string .. "api_hangup_hook='lua app/fax/resources/scripts/queue/retry.lua'," .. FAX_OPTIONS[mode] .. '}' .. task.uri - local originate = 'originate ' .. dial_string .. ' &lua(fax_queue/exec.lua)' + local originate = 'originate ' .. dial_string .. ' &lua(app/fax/resources/scripts/queue/exec.lua)' log.notice(originate) esl = assert(Esl.new()) diff --git a/resources/install/scripts/fax_queue/retry.lua b/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua similarity index 96% rename from resources/install/scripts/fax_queue/retry.lua rename to resources/install/scripts/app/fax/resources/scripts/queue/retry.lua index 018cec372e..feb8f6ef4f 100644 --- a/resources/install/scripts/fax_queue/retry.lua +++ b/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua @@ -7,7 +7,7 @@ local log = require "resources.functions.log".fax_retry local Database = require "resources.functions.database" local Settings = require "resources.functions.lazy_settings" - local Tasks = require "fax_queue.tasks" + local Tasks = require "app.fax.resources.scripts.queue.tasks" local fax_task_uuid = env:getHeader('fax_task_uuid') local task = Tasks.select_task(fax_task_uuid) diff --git a/resources/install/scripts/fax_queue/tasks.lua b/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua similarity index 100% rename from resources/install/scripts/fax_queue/tasks.lua rename to resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua diff --git a/resources/install/scripts/fax_queue_monitor.lua b/resources/install/scripts/fax_queue_monitor.lua index 1f4371d2b7..a9250d455e 100644 --- a/resources/install/scripts/fax_queue_monitor.lua +++ b/resources/install/scripts/fax_queue_monitor.lua @@ -9,7 +9,7 @@ require "resources.functions.sleep"; local log = require "resources.functions.log".fax_queue_monitor - local Next = require "fax_queue.next" + local Next = require "app.fax.resources.scripts.queue.next" mkdir(scripts_dir .. "/run"); diff --git a/resources/install/scripts/fax_queue_poll_once.lua b/resources/install/scripts/fax_queue_poll_once.lua index c42ee62c72..b8453bdafd 100644 --- a/resources/install/scripts/fax_queue_poll_once.lua +++ b/resources/install/scripts/fax_queue_poll_once.lua @@ -1 +1 @@ -require "fax_queue.next".poll_once() \ No newline at end of file +require "app.fax.resources.scripts.queue.next".poll_once() \ No newline at end of file From dde6c07a3f372fa1949e1514d3b0c0351e37e2f2 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 16:50:50 -0700 Subject: [PATCH 42/56] Clear the SIPDefault.cnf better to have full control per device of all setttings. --- .../provision/cisco/7940/SIPDefault.cnf | 131 --------------- .../provision/cisco/7940/SIP{$mac}.cnf | 153 ++++++++++++++++-- 2 files changed, 141 insertions(+), 143 deletions(-) diff --git a/resources/templates/provision/cisco/7940/SIPDefault.cnf b/resources/templates/provision/cisco/7940/SIPDefault.cnf index 489f5c97ea..e69de29bb2 100644 --- a/resources/templates/provision/cisco/7940/SIPDefault.cnf +++ b/resources/templates/provision/cisco/7940/SIPDefault.cnf @@ -1,131 +0,0 @@ -# Image Version -image_version: "P0S3-08-7-00" - -# Proxy Server -proxy1_address: "192.168.1.1" - -# Proxy Server Port (default - 5060) -proxy1_port:"5060" - -# Emergency Proxy info -proxy_emergency: "192.168.1.1" -proxy_emergency_port: "5060" - -# Backup Proxy info -proxy_backup: "192.168.1.1" -proxy_backup_port: "5060" - -# Outbound Proxy info -outbound_proxy: "" -outbound_proxy_port: "5060" - -# NAT/Firewall Traversal -nat_enable: "0" -nat_address: "" -voip_control_port: "5060" -start_media_port: "16384" -end_media_port: "32766" -nat_received_processing: "0" - -# Proxy Registration (0-disable (default), 1-enable) -proxy_register: "1" - -# Phone Registration Expiration [1-3932100 sec] (Default - 3600) -timer_register_expires: "80" - -# Codec for media stream (g711ulaw (default), g711alaw, g729) -preferred_codec: "none" - -# TOS bits in media stream [0-5] (Default - 5) -tos_media: "5" - -# Enable VAD (0-disable (default), 1-enable) -enable_vad: "0" - -# Allow for the bridge on a 3way call to join remaining parties upon hangup -cnf_join_enable: "1" ; 0-Disabled, 1-Enabled (default) - -# Allow Transfer to be completed while target phone is still ringing -semi_attended_transfer: "0" ; 0-Disabled, 1-Enabled (default) - -# Telnet Level (enable or disable the ability to telnet into this phone -telnet_level: "2" ; 0-Disabled (default), 1-Enabled, 2-Privileged - -# Inband DTMF Settings (0-disable, 1-enable (default)) -dtmf_inband: "1" - -# Out of band DTMF Settings (none-disable, avt-avt enable (default), avt_always - always avt ) -dtmf_outofband: "avt" - -# DTMF dB Level Settings (1-6dB down, 2-3db down, 3-nominal (default), 4-3db up, 5-6dB up) -dtmf_db_level: "3" - -# SIP Timers -timer_t1: "500" ; Default 500 msec -timer_t2: "4000" ; Default 4 sec -sip_retx: "10" ; Default 11 -sip_invite_retx: "6" ; Default 7 -timer_invite_expires: "180" ; Default 180 sec - -# Setting for Message speeddial to UOne box -messages_uri: "*97" - -# TFTP Phone Specific Configuration File Directory -tftp_cfg_dir: "" - -# Time Server -sntp_mode: "unicast" -sntp_server: "192.168.1.1" -time_zone: "EST" -dst_offset: "1" -dst_start_month: "Mar" -dst_start_day: "" -dst_start_day_of_week: "Sun" -dst_start_week_of_month: "2" -dst_start_time: "02" -dst_stop_month: "Nov" -dst_stop_day: "" -dst_stop_day_of_week: "Sunday" -dst_stop_week_of_month: "1" -dst_stop_time: "2" -dst_auto_adjust: "1" - -# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control) -dnd_control: "2" ; Default 0 (Do Not Disturb feature is off) - -# Caller ID Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control) -callerid_blocking: "0" ; Default 0 (Disable sending all calls as anonymous) - -# Anonymous Call Blocking (0-disbaled, 1-enabled, 2-disabled no user control, 3-enabled no user control) -anonymous_call_block: "0" ; Default 0 (Disable blocking of anonymous calls) - -# Call Waiting (0-disabled, 1-enabled, 2-disabled with no user control, 3-enabled with no user control) -call_waiting: "1" ; Default 1 (Call Waiting enabled) - -# DTMF AVT Payload (Dynamic payload range for AVT tones - 96-127) -dtmf_avt_payload: "101" ; Default 100 - -# XML file that specifies the dialplan desired -dial_template: "dialplan" - -# Network Media Type (auto, full100, full10, half100, half10) -network_media_type: "auto" - -#Autocompletion During Dial (0-off, 1-on [default]) -autocomplete: "1" - -#Time Format (0-12hr, 1-24hr [default]) -time_format_24hr: "0" - -# URL for external Phone Services -#services_url: "http://{$domain_name}/app/provision/?file=services.php" - -# URL for external Directory location -directory_url: "http://{$domain_name}/app/provision/?file=directory.php" - -# URL for branding logo -#logo_url: "http://{$domain_name}/app/provision/logo.bmp" - -# Remote Party ID -remote_party_id: 1 ; 0-Disabled (default), 1-Enabled - diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index 66cdbae8a0..7a74fb4cf7 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -1,19 +1,148 @@ -phone_label: "{$display_name_1}" -proxy1_address: "{$server_address_1}" + +# Image version +{if isset($cisco_time_zone)} +image_version: "{$cisco_image_version}" +{/if} + +# Phone settings +phone_label: "{$device_label}" proxy_register: 1 timer_register_expires: 300 preferred_codec: g711ulaw enable_vad: 0 dial_template: "dialplan" -line1_name: "{$user_id_1}" -line1_displayname: "{$user_id_1}" -line1_shortname: "{$short_name_1}" -line1_authname: "{$auth_id_1}" -line1_password: "{$user_password_1}" +{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.display_name}" +#registration information +proxy{$row.line_number}_address: "{$server_address_1}" +proxy{$row.line_number}_port:"5060" +line{$row.line_number}_name: "{$user_id_1}" +line{$row.line_number}_displayname: "{$row.user_id}" +line{$row.line_number}_shortname: "{$row.display_name}" +line{$row.line_number}_authname: "{$row.auth_id}" +line{$row.line_number}_password: "{$row.user_password}" -line2_name: "{$user_id_2}" -line2_displayname: "{$user_id_2}" -line2_shortname: "{$short_name_2}" -line2_authname: "{$auth_id_2}" -line2_password: "{$user_password_2}" \ No newline at end of file +{/foreach} +# Emergency Proxy info +proxy_emergency: "{$proxy_emergency}" +proxy_emergency_port: "{$proxy_emergency_port}" + +# Backup Proxy info +proxy_backup: "{$proxy_backup}" +proxy_backup_port: "{$proxy_backup_port}" + +# Outbound Proxy info +outbound_proxy: "{$outbound_proxy}" +outbound_proxy_port: "{$outbound_proxy_port}" + +# NAT/Firewall Traversal +nat_enable: "{$nat_enable}" +nat_address: "{$nat_nat_address}" +voip_control_port: "5060" +start_media_port: "16384" +end_media_port: "32768" +nat_received_processing: "0" + +# Proxy Registration (0-disable (default), 1-enable) +proxy_register: "1" + +# Phone Registration Expiration [1-3932100 sec] (Default - 3600) +timer_register_expires: "80" + +# Codec for media stream (g711ulaw (default), g711alaw, g729) +preferred_codec: "none" + +# TOS bits in media stream [0-5] (Default - 5) +tos_media: "5" + +# Enable VAD (0-disable (default), 1-enable) +enable_vad: "0" + +# Allow for the bridge on a 3way call to join remaining parties upon hangup +cnf_join_enable: "1" ; 0-Disabled, 1-Enabled (default) + +# Allow Transfer to be completed while target phone is still ringing +semi_attended_transfer: "0" ; 0-Disabled, 1-Enabled (default) + +# Telnet Level (enable or disable the ability to telnet into this phone +telnet_level: "2" ; 0-Disabled (default), 1-Enabled, 2-Privileged + +# Inband DTMF Settings (0-disable, 1-enable (default)) +dtmf_inband: "1" + +# Out of band DTMF Settings (none-disable, avt-avt enable (default), avt_always - always avt ) +dtmf_outofband: "avt" + +# DTMF dB Level Settings (1-6dB down, 2-3db down, 3-nominal (default), 4-3db up, 5-6dB up) +dtmf_db_level: "3" + +# SIP Timers +timer_t1: "500" ; Default 500 msec +timer_t2: "4000" ; Default 4 sec +sip_retx: "10" ; Default 11 +sip_invite_retx: "6" ; Default 7 +timer_invite_expires: "180" ; Default 180 sec + +# Setting for Message speeddial to UOne box +messages_uri: "*97" + +# TFTP Phone Specific Configuration File Directory +tftp_cfg_dir: "" + +# Time Server +sntp_mode: "unicast" +sntp_server: "{$sntp_server}" +{if isset($cisco_time_zone)} +time_zone: "{$cisco_time_zone}" +{/if} +dst_offset: "1" +dst_start_month: "Mar" +dst_start_day: "" +dst_start_day_of_week: "Sun" +dst_start_week_of_month: "2" +dst_start_time: "02" +dst_stop_month: "Nov" +dst_stop_day: "" +dst_stop_day_of_week: "Sunday" +dst_stop_week_of_month: "1" +dst_stop_time: "2" +dst_auto_adjust: "1" + +# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control) +dnd_control: "2" ; Default 0 (Do Not Disturb feature is off) + +# Caller ID Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control) +callerid_blocking: "0" ; Default 0 (Disable sending all calls as anonymous) + +# Anonymous Call Blocking (0-disbaled, 1-enabled, 2-disabled no user control, 3-enabled no user control) +anonymous_call_block: "0" ; Default 0 (Disable blocking of anonymous calls) + +# Call Waiting (0-disabled, 1-enabled, 2-disabled with no user control, 3-enabled with no user control) +call_waiting: "1" ; Default 1 (Call Waiting enabled) + +# DTMF AVT Payload (Dynamic payload range for AVT tones - 96-127) +dtmf_avt_payload: "101" ; Default 100 + +# XML file that specifies the dialplan desired +dial_template: "dialplan" + +# Network Media Type (auto, full100, full10, half100, half10) +network_media_type: "auto" + +#Autocompletion During Dial (0-off, 1-on [default]) +autocomplete: "1" + +#Time Format (0-12hr, 1-24hr [default]) +time_format_24hr: "0" + +# URL for external Phone Services +#services_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=services.php" + +# URL for external Directory location +directory_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=directory.php" + +# URL for branding logo +#logo_url: "http://{$domain_name}/app/provision/logo.bmp" + +# Remote Party ID +remote_party_id: 1 ; 0-Disabled (default), 1-Enabled From f94933498955c7ae7ab62e3b9207e0ad0f45c432 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 17:08:41 -0700 Subject: [PATCH 43/56] Update the Cisco 7940 template. --- .../templates/provision/cisco/7940/SIP{$mac}.cnf | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index 7a74fb4cf7..b7c95eed8b 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -1,6 +1,5 @@ - -# Image version {if isset($cisco_time_zone)} +# Image version image_version: "{$cisco_image_version}" {/if} @@ -14,13 +13,13 @@ dial_template: "dialplan" {foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.display_name}" #registration information -proxy{$row.line_number}_address: "{$server_address_1}" -proxy{$row.line_number}_port:"5060" -line{$row.line_number}_name: "{$user_id_1}" +proxy{$row.line_number}_address: "{$row.server_address}" +proxy{$row.line_number}_port:"{$row.sip_port}" +line{$row.line_number}_name: "{$row.user_id}" line{$row.line_number}_displayname: "{$row.user_id}" line{$row.line_number}_shortname: "{$row.display_name}" line{$row.line_number}_authname: "{$row.auth_id}" -line{$row.line_number}_password: "{$row.user_password}" +line{$row.line_number}_password: "{$row.password}" {/foreach} # Emergency Proxy info From be5fb172d50c94ffe672a8e758793762dcf4c8eb Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 17:31:31 -0700 Subject: [PATCH 44/56] Fix the device label for the Cisco 7940. --- resources/templates/provision/cisco/7940/SIP{$mac}.cnf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index b7c95eed8b..d9ef2441d3 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -4,7 +4,7 @@ image_version: "{$cisco_image_version}" {/if} # Phone settings -phone_label: "{$device_label}" +phone_label: "{$label}" proxy_register: 1 timer_register_expires: 300 preferred_codec: g711ulaw From 20eae285a9e647803451e28f3c6e8aa6e83ccc18 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 17:53:44 -0700 Subject: [PATCH 45/56] Set nat_enabled = 1 as a default, and add sync 1 to the Cisco 7940 template. --- resources/templates/provision/cisco/7940/SIP{$mac}.cnf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index d9ef2441d3..dfc433da1d 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -35,12 +35,15 @@ outbound_proxy: "{$outbound_proxy}" outbound_proxy_port: "{$outbound_proxy_port}" # NAT/Firewall Traversal -nat_enable: "{$nat_enable}" -nat_address: "{$nat_nat_address}" voip_control_port: "5060" start_media_port: "16384" end_media_port: "32768" nat_received_processing: "0" +{if isset($nat_enable)}nat_enable: "{$nat_enable}"{else}1{/if} +nat_address: "{$nat_nat_address}" + +# Sync value of the phone used for remote reset +sync: 1 ; Default 1 # Proxy Registration (0-disable (default), 1-enable) proxy_register: "1" From 71b7e1c0ff7f276c025fb64439f75f331e6dfcc8 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 18:03:47 -0700 Subject: [PATCH 46/56] Another adjustment to the Cisco 7940 template for nat_enable. --- resources/templates/provision/cisco/7940/SIP{$mac}.cnf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index dfc433da1d..c16df58d48 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -39,7 +39,7 @@ voip_control_port: "5060" start_media_port: "16384" end_media_port: "32768" nat_received_processing: "0" -{if isset($nat_enable)}nat_enable: "{$nat_enable}"{else}1{/if} +nat_enable: "{if isset($nat_enable)}{$nat_enable}{else}1{/if}" nat_address: "{$nat_nat_address}" # Sync value of the phone used for remote reset From 6d3494fff9ec6aa99876a9236dab4f878bdc546a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 18:29:15 -0700 Subject: [PATCH 47/56] Add the contact_category to contacts array in the provision class. --- 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 5167454297..62a8118182 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -402,7 +402,7 @@ include "root.php"; //get the contacts array and add to the template engine if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0 and $_SESSION['provision']['directory']['boolean'] == "true") { //get contacts from the database - $sql = "select c.contact_organization, c.contact_name_given, c.contact_name_family, p.phone_number, p.phone_extension "; + $sql = "select c.contact_category, c.contact_organization, c.contact_name_given, c.contact_name_family, p.phone_number, p.phone_extension "; $sql .= "from v_contacts as c, v_contact_phones as p "; $sql .= "where c.domain_uuid = '".$domain_uuid."' "; $sql .= "and c.contact_uuid = p.contact_uuid "; From 7ac51b5664b419a2a5608f0b9953fb3b315bb748 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 18:39:38 -0700 Subject: [PATCH 48/56] Improve the white space handling in the 7940 directory.xml files. --- .../cisco/7940/directory-enterprise.xml | 34 +++++++++--------- .../cisco/7940/directory-personal.xml | 34 +++++++++--------- .../cisco/7940/directory-speed_dial.xml | 35 +++++++++---------- 3 files changed, 51 insertions(+), 52 deletions(-) diff --git a/resources/templates/provision/cisco/7940/directory-enterprise.xml b/resources/templates/provision/cisco/7940/directory-enterprise.xml index 7b84648f36..4c145c770d 100644 --- a/resources/templates/provision/cisco/7940/directory-enterprise.xml +++ b/resources/templates/provision/cisco/7940/directory-enterprise.xml @@ -6,23 +6,23 @@ SoftKey:Select 1 - {assign var=x value=1} - {foreach $contacts as $row} - {if $row.contact_category == "enterprise"} - - {if $row.contact_name_given != ""} - {$row.contact_name_given} {$row.contact_name_family} - {else} - {$row.contact_organization} - {/if} - {if $row.phone_number != ""} - Dial:{$row.phone_number}# - {else} - Dial:{$row.phone_extension}# - {/if} - - {/if} - {/foreach} +{assign var=x value=1} +{foreach $contacts as $row}{if $row.contact_category == "enterprise"} + +{if $row.contact_name_given != ""} + {$row.contact_name_given} {$row.contact_name_family} +{else} + {$row.contact_organization} +{/if} +{if $row.phone_number != ""} + Dial:{$row.phone_number}# +{else} + Dial:{$row.phone_extension}# +{/if} + +{/if} +{assign var=x value=$x+1} +{/foreach} Exit SoftKey:Exit diff --git a/resources/templates/provision/cisco/7940/directory-personal.xml b/resources/templates/provision/cisco/7940/directory-personal.xml index 9d774ab56a..5bbde47349 100644 --- a/resources/templates/provision/cisco/7940/directory-personal.xml +++ b/resources/templates/provision/cisco/7940/directory-personal.xml @@ -6,23 +6,23 @@ SoftKey:Select 1 - {assign var=x value=1} - {foreach $contacts as $row} - {if $row.contact_category == "personal"} - - {if $row.contact_name_given != ""} - {$row.contact_name_given} {$row.contact_name_family} - {else} - {$row.contact_organization} - {/if} - {if $row.phone_number != ""} - Dial:{$row.phone_number}# - {else} - Dial:{$row.phone_extension}# - {/if} - - {/if} - {/foreach} +{assign var=x value=1} +{foreach $contacts as $row}{if $row.contact_category == "personal"} + +{if $row.contact_name_given != ""} + {$row.contact_name_given} {$row.contact_name_family} +{else} + {$row.contact_organization} +{/if} +{if $row.phone_number != ""} + Dial:{$row.phone_number}# +{else} + Dial:{$row.phone_extension}# +{/if} + +{/if} +{assign var=x value=$x+1} +{/foreach} Exit SoftKey:Exit diff --git a/resources/templates/provision/cisco/7940/directory-speed_dial.xml b/resources/templates/provision/cisco/7940/directory-speed_dial.xml index f100c38cd6..ab7714c740 100644 --- a/resources/templates/provision/cisco/7940/directory-speed_dial.xml +++ b/resources/templates/provision/cisco/7940/directory-speed_dial.xml @@ -6,24 +6,23 @@ SoftKey:Select 1 - {assign var=x value=1} - {foreach $contacts as $row} - {if $row.contact_category == "speed dial"} - - {if $row.contact_name_given != ""} - {$row.contact_name_given} {$row.contact_name_family} - {else} - {$row.contact_organization} - {/if} - {if $row.phone_number != ""} - Dial:{$row.phone_number}# - {else} - Dial:{$row.phone_extension}# - {/if} - - {/if} - {assign var=x value=$x+1} - {/foreach} +{assign var=x value=1} +{foreach $contacts as $row}{if $row.contact_category == "speed dial"} + +{if $row.contact_name_given != ""} + {$row.contact_name_given} {$row.contact_name_family} +{else} + {$row.contact_organization} +{/if} +{if $row.phone_number != ""} + Dial:{$row.phone_number}# +{else} + Dial:{$row.phone_extension}# +{/if} + +{/if} +{assign var=x value=$x+1} +{/foreach} Exit SoftKey:Exit From 7e67cbc16fc9d4f49d5837ace2a06c52e37e0374 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 18:47:52 -0700 Subject: [PATCH 49/56] Correct the paths to the Cisco 7940 directory xml files. --- resources/templates/provision/cisco/7940/SIP{$mac}.cnf | 4 ++-- resources/templates/provision/cisco/7940/directory.xml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index c16df58d48..dc21518c07 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -138,10 +138,10 @@ autocomplete: "1" time_format_24hr: "0" # URL for external Phone Services -#services_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=services.php" +#services_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=services.xml" # URL for external Directory location -directory_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=directory.php" +directory_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=directory.xml" # URL for branding logo #logo_url: "http://{$domain_name}/app/provision/logo.bmp" diff --git a/resources/templates/provision/cisco/7940/directory.xml b/resources/templates/provision/cisco/7940/directory.xml index 9c90716c7c..f3f7b94470 100644 --- a/resources/templates/provision/cisco/7940/directory.xml +++ b/resources/templates/provision/cisco/7940/directory.xml @@ -4,16 +4,16 @@ Enterprise - http://{$domain_name}/app/provision?file=directory-enterprise&mac={$mac} + http://{$domain_name}/app/provision?mac={$mac}&file=directory-enterprise.xml Speed Dial - http://{$domain_name}/app/provision/?file=directory-speed_dial&mac={$mac} + http://{$domain_name}/app/provision/?mac={$mac}&file=directory-speed_dial.xml Select From 4d7688a3ef4172a1e8ac780fd60fb64e415d59c7 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 19:15:29 -0700 Subject: [PATCH 50/56] Add a missing = so that the file is only provided as a download when the content type is set to application/octet-stream in the url. --- app/provision/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/provision/index.php b/app/provision/index.php index 366ed87183..efd76559bd 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -283,7 +283,7 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); //deliver the customized config over HTTP/HTTPS //need to make sure content-type is correct - if ($_REQUEST['content_type'] = 'application/octet-stream') { + if ($_REQUEST['content_type'] == 'application/octet-stream') { $file_name = str_replace("{\$mac}",$mac,$file); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); From 42b0cf5c769e741bc7ad0b3124b6592ab5b0913c Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 19:31:07 -0700 Subject: [PATCH 51/56] Escape the & in the directory url with & --- resources/templates/provision/cisco/7940/SIP{$mac}.cnf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index dc21518c07..f4a5ef6034 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -138,10 +138,10 @@ autocomplete: "1" time_format_24hr: "0" # URL for external Phone Services -#services_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=services.xml" +#services_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=services.xml" # URL for external Directory location -directory_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=directory.xml" +directory_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=directory.xml" # URL for branding logo #logo_url: "http://{$domain_name}/app/provision/logo.bmp" From 1a46a38c04beddb71d849432271cb1df46a1c0e2 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 19:48:45 -0700 Subject: [PATCH 52/56] Add option to get the mac address from &name=SEPxxxxx --- app/provision/index.php | 9 +++++++++ resources/templates/provision/cisco/7940/directory.xml | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/provision/index.php b/app/provision/index.php index efd76559bd..df3d72fa91 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -42,6 +42,15 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); // $device_template = check_str($_REQUEST['template']); //} +//get the mac address for Cisco 79xx in the URL as &name=SEP000000000000 + if (empty($mac)){ + $name = check_str($_REQUEST['name']); + if (substr($name, 0, 3) == "SEP") { + $mac = substr($name, 3, 12); + unset($name); + } + } + //check alternate MAC source if (empty($mac)){ //set the http user agent diff --git a/resources/templates/provision/cisco/7940/directory.xml b/resources/templates/provision/cisco/7940/directory.xml index f3f7b94470..2aeda06113 100644 --- a/resources/templates/provision/cisco/7940/directory.xml +++ b/resources/templates/provision/cisco/7940/directory.xml @@ -4,16 +4,16 @@ Enterprise - http://{$domain_name}/app/provision?mac={$mac}&file=directory-enterprise.xml + http://{$domain_name}/app/provision?file=directory-enterprise.xml Speed Dial - http://{$domain_name}/app/provision/?mac={$mac}&file=directory-speed_dial.xml + http://{$domain_name}/app/provision/?file=directory-speed_dial.xml Select From 37741c09269113101d3e220e94705aed681905d7 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 19:56:06 -0700 Subject: [PATCH 53/56] Remove the mac address from the path in one more location. --- resources/templates/provision/cisco/7940/SIP{$mac}.cnf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index f4a5ef6034..8cbd66528b 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -138,10 +138,10 @@ autocomplete: "1" time_format_24hr: "0" # URL for external Phone Services -#services_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=services.xml" +#services_url: "http://{$domain_name}/app/provision/?file=services.xml" # URL for external Directory location -directory_url: "http://{$domain_name}/app/provision/?mac={$mac}&file=directory.xml" +directory_url: "http://{$domain_name}/app/provision/?file=directory.xml" # URL for branding logo #logo_url: "http://{$domain_name}/app/provision/logo.bmp" From 918cc484cb077459120a53620acaa51aee43d84c Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 20:08:24 -0700 Subject: [PATCH 54/56] Set the mac address to lower case. --- app/provision/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/provision/index.php b/app/provision/index.php index df3d72fa91..ae17fefba2 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -46,7 +46,7 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); if (empty($mac)){ $name = check_str($_REQUEST['name']); if (substr($name, 0, 3) == "SEP") { - $mac = substr($name, 3, 12); + $mac = strtolower(substr($name, 3, 12)); unset($name); } } From f9a5aa2461d1d426607049f71aa3ad0ba39db8b1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 21:09:12 -0700 Subject: [PATCH 55/56] Complete the directory for Cisco 7940 template. --- .../provision/cisco/7940/SIP{$mac}.cnf | 4 +-- .../cisco/7940/directory-enterprise.xml | 26 +++++++------------ .../cisco/7940/directory-personal.xml | 25 +++++++----------- .../cisco/7940/directory-speed_dial.xml | 22 +++++----------- .../provision/cisco/7940/directory.xml | 21 ++++----------- 5 files changed, 32 insertions(+), 66 deletions(-) diff --git a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf index 8cbd66528b..2d9adbd63f 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -138,10 +138,10 @@ autocomplete: "1" time_format_24hr: "0" # URL for external Phone Services -#services_url: "http://{$domain_name}/app/provision/?file=services.xml" +#services_url: "http://{$domain_name}/app/provision/file/services.xml" # URL for external Directory location -directory_url: "http://{$domain_name}/app/provision/?file=directory.xml" +directory_url: "http://{$domain_name}/app/provision/file/directory.xml" # URL for branding logo #logo_url: "http://{$domain_name}/app/provision/logo.bmp" diff --git a/resources/templates/provision/cisco/7940/directory-enterprise.xml b/resources/templates/provision/cisco/7940/directory-enterprise.xml index 4c145c770d..5c977112b0 100644 --- a/resources/templates/provision/cisco/7940/directory-enterprise.xml +++ b/resources/templates/provision/cisco/7940/directory-enterprise.xml @@ -1,31 +1,25 @@ - + Enterprise Please choose... - - Dial - SoftKey:Select - 1 - {assign var=x value=1} {foreach $contacts as $row}{if $row.contact_category == "enterprise"} - + {if $row.contact_name_given != ""} {$row.contact_name_given} {$row.contact_name_family} {else} {$row.contact_organization} {/if} {if $row.phone_number != ""} - Dial:{$row.phone_number}# + {$row.phone_number} {else} - Dial:{$row.phone_extension}# + {$row.phone_extension} {/if} - + {/if} {assign var=x value=$x+1} {/foreach} - - Exit - SoftKey:Exit - 4 - - + + + + + diff --git a/resources/templates/provision/cisco/7940/directory-personal.xml b/resources/templates/provision/cisco/7940/directory-personal.xml index 5bbde47349..2e6750eb98 100644 --- a/resources/templates/provision/cisco/7940/directory-personal.xml +++ b/resources/templates/provision/cisco/7940/directory-personal.xml @@ -1,31 +1,24 @@ - + Personal Please choose... - - Dial - SoftKey:Select - 1 - {assign var=x value=1} {foreach $contacts as $row}{if $row.contact_category == "personal"} - + {if $row.contact_name_given != ""} {$row.contact_name_given} {$row.contact_name_family} {else} {$row.contact_organization} {/if} {if $row.phone_number != ""} - Dial:{$row.phone_number}# + {$row.phone_number} {else} - Dial:{$row.phone_extension}# + {$row.phone_extension} {/if} - + {/if} {assign var=x value=$x+1} {/foreach} - - Exit - SoftKey:Exit - 4 - - + + + + diff --git a/resources/templates/provision/cisco/7940/directory-speed_dial.xml b/resources/templates/provision/cisco/7940/directory-speed_dial.xml index ab7714c740..16138ed111 100644 --- a/resources/templates/provision/cisco/7940/directory-speed_dial.xml +++ b/resources/templates/provision/cisco/7940/directory-speed_dial.xml @@ -1,31 +1,21 @@ - + Speed Dial Please choose... - - Dial - SoftKey:Select - 1 - {assign var=x value=1} {foreach $contacts as $row}{if $row.contact_category == "speed dial"} - + {if $row.contact_name_given != ""} {$row.contact_name_given} {$row.contact_name_family} {else} {$row.contact_organization} {/if} {if $row.phone_number != ""} - Dial:{$row.phone_number}# + {$row.phone_number} {else} - Dial:{$row.phone_extension}# + {$row.phone_extension} {/if} - + {/if} {assign var=x value=$x+1} {/foreach} - - Exit - SoftKey:Exit - 4 - - + diff --git a/resources/templates/provision/cisco/7940/directory.xml b/resources/templates/provision/cisco/7940/directory.xml index 2aeda06113..24351b9b2d 100644 --- a/resources/templates/provision/cisco/7940/directory.xml +++ b/resources/templates/provision/cisco/7940/directory.xml @@ -1,28 +1,17 @@ Contacts Please choose... + - - Enterprise - http://{$domain_name}/app/provision?file=directory-enterprise.xml + --> Enterprise + http://{$domain_name}/app/provision/file/directory-enterprise.xml?mac={$mac} Speed Dial - http://{$domain_name}/app/provision/?file=directory-speed_dial.xml + http://{$domain_name}/app/provision/file/directory-speed_dial.xml?mac={$mac} - - Select - SoftKey:Select - 1 - - - Exit - SoftKey:Exit - 4 - \ No newline at end of file From 6fa7dcfa30a02cc5d8f9135ed13565d0c4ffa0ca Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 28 Nov 2015 21:12:16 -0700 Subject: [PATCH 56/56] Synchronize the cisco 7940 with the 7940 template. --- .../cisco/7960/DISTINCTIVERINGLIST.XML | 30 +++ .../provision/cisco/7960/RINGLIST.XML | 30 +++ .../provision/cisco/7960/SIPDefault.cnf | 131 -------------- .../provision/cisco/7960/SIP{$mac}.cnf | 171 ++++++++++++++---- .../cisco/7960/directory-enterprise.xml | 25 +++ .../cisco/7960/directory-personal.xml | 24 +++ .../cisco/7960/directory-speed_dial.xml | 21 +++ .../provision/cisco/7960/directory.xml | 17 ++ 8 files changed, 286 insertions(+), 163 deletions(-) create mode 100644 resources/templates/provision/cisco/7960/DISTINCTIVERINGLIST.XML create mode 100644 resources/templates/provision/cisco/7960/RINGLIST.XML create mode 100644 resources/templates/provision/cisco/7960/directory-enterprise.xml create mode 100644 resources/templates/provision/cisco/7960/directory-personal.xml create mode 100644 resources/templates/provision/cisco/7960/directory-speed_dial.xml create mode 100644 resources/templates/provision/cisco/7960/directory.xml diff --git a/resources/templates/provision/cisco/7960/DISTINCTIVERINGLIST.XML b/resources/templates/provision/cisco/7960/DISTINCTIVERINGLIST.XML new file mode 100644 index 0000000000..8841ee8303 --- /dev/null +++ b/resources/templates/provision/cisco/7960/DISTINCTIVERINGLIST.XML @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/templates/provision/cisco/7960/RINGLIST.XML b/resources/templates/provision/cisco/7960/RINGLIST.XML new file mode 100644 index 0000000000..c30df63119 --- /dev/null +++ b/resources/templates/provision/cisco/7960/RINGLIST.XML @@ -0,0 +1,30 @@ + + + Chirp 3 + ringer3.pcm + + + Old Style + ringer1.pcm + + + Door Chime + doorchime.pcm + + + Red Alert + redalert.pcm + + + Terri + terri.pcm + + + Door Chime 2 + chime2.pcm + + + Silence + silence.pcm + + diff --git a/resources/templates/provision/cisco/7960/SIPDefault.cnf b/resources/templates/provision/cisco/7960/SIPDefault.cnf index aa90396792..e69de29bb2 100644 --- a/resources/templates/provision/cisco/7960/SIPDefault.cnf +++ b/resources/templates/provision/cisco/7960/SIPDefault.cnf @@ -1,131 +0,0 @@ -# Image Version -image_version: "P0S3-08-7-00" - -# Proxy Server -proxy1_address: "192.168.1.1" - -# Proxy Server Port (default - 5060) -proxy1_port:"5060" - -# Emergency Proxy info -proxy_emergency: "192.168.1.1" -proxy_emergency_port: "5060" - -# Backup Proxy info -proxy_backup: "192.168.1.1" -proxy_backup_port: "5060" - -# Outbound Proxy info -outbound_proxy: "" -outbound_proxy_port: "5060" - -# NAT/Firewall Traversal -nat_enable: "0" -nat_address: "" -voip_control_port: "5060" -start_media_port: "16384" -end_media_port: "32766" -nat_received_processing: "0" - -# Proxy Registration (0-disable (default), 1-enable) -proxy_register: "1" - -# Phone Registration Expiration [1-3932100 sec] (Default - 3600) -timer_register_expires: "3600" - -# Codec for media stream (g711ulaw (default), g711alaw, g729) -preferred_codec: "none" - -# TOS bits in media stream [0-5] (Default - 5) -tos_media: "5" - -# Enable VAD (0-disable (default), 1-enable) -enable_vad: "0" - -# Allow for the bridge on a 3way call to join remaining parties upon hangup -cnf_join_enable: "1" ; 0-Disabled, 1-Enabled (default) - -# Allow Transfer to be completed while target phone is still ringing -semi_attended_transfer: "0" ; 0-Disabled, 1-Enabled (default) - -# Telnet Level (enable or disable the ability to telnet into this phone -telnet_level: "2" ; 0-Disabled (default), 1-Enabled, 2-Privileged - -# Inband DTMF Settings (0-disable, 1-enable (default)) -dtmf_inband: "1" - -# Out of band DTMF Settings (none-disable, avt-avt enable (default), avt_always - always avt ) -dtmf_outofband: "avt" - -# DTMF dB Level Settings (1-6dB down, 2-3db down, 3-nominal (default), 4-3db up, 5-6dB up) -dtmf_db_level: "3" - -# SIP Timers -timer_t1: "500" ; Default 500 msec -timer_t2: "4000" ; Default 4 sec -sip_retx: "10" ; Default 11 -sip_invite_retx: "6" ; Default 7 -timer_invite_expires: "180" ; Default 180 sec - -# Setting for Message speeddial to UOne box -messages_uri: "*98" - -# TFTP Phone Specific Configuration File Directory -tftp_cfg_dir: "" - -# Time Server -sntp_mode: "unicast" -sntp_server: "192.168.1.1" -time_zone: "EST" -dst_offset: "1" -dst_start_month: "Mar" -dst_start_day: "" -dst_start_day_of_week: "Sun" -dst_start_week_of_month: "2" -dst_start_time: "02" -dst_stop_month: "Nov" -dst_stop_day: "" -dst_stop_day_of_week: "Sunday" -dst_stop_week_of_month: "1" -dst_stop_time: "2" -dst_auto_adjust: "1" - -# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control) -dnd_control: "0" ; Default 0 (Do Not Disturb feature is off) - -# Caller ID Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control) -callerid_blocking: "0" ; Default 0 (Disable sending all calls as anonymous) - -# Anonymous Call Blocking (0-disbaled, 1-enabled, 2-disabled no user control, 3-enabled no user control) -anonymous_call_block: "0" ; Default 0 (Disable blocking of anonymous calls) - -# Call Waiting (0-disabled, 1-enabled, 2-disabled with no user control, 3-enabled with no user control) -call_waiting: "1" ; Default 1 (Call Waiting enabled) - -# DTMF AVT Payload (Dynamic payload range for AVT tones - 96-127) -dtmf_avt_payload: "101" ; Default 100 - -# XML file that specifies the dialplan desired -dial_template: "dialplan" - -# Network Media Type (auto, full100, full10, half100, half10) -network_media_type: "auto" - -#Autocompletion During Dial (0-off, 1-on [default]) -autocomplete: "1" - -#Time Format (0-12hr, 1-24hr [default]) -time_format_24hr: "0" - -# URL for external Phone Services -#services_url: "http://192.168.1.1/xmlservices/index.php" - -# URL for external Directory location -#directory_url: "http://192.168.1.1/xmlservices/PhoneDirectory.php" - -# URL for branding logo -#logo_url: "http://192.168.1.1/cisco/bmp/trixbox.bmp" - -# Remote Party ID -remote_party_id: 1 ; 0-Disabled (default), 1-Enabled - diff --git a/resources/templates/provision/cisco/7960/SIP{$mac}.cnf b/resources/templates/provision/cisco/7960/SIP{$mac}.cnf index f2dda35d42..2d9adbd63f 100644 --- a/resources/templates/provision/cisco/7960/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7960/SIP{$mac}.cnf @@ -1,43 +1,150 @@ -phone_label: "{$display_name_1}" -proxy1_address: "{$server_address_1}" +{if isset($cisco_time_zone)} +# Image version +image_version: "{$cisco_image_version}" +{/if} + +# Phone settings +phone_label: "{$label}" proxy_register: 1 timer_register_expires: 300 preferred_codec: g711ulaw enable_vad: 0 dial_template: "dialplan" -line1_name: "{$user_id_1}" -line1_displayname: "{$user_id_1}" -line1_shortname: "{$short_name_1}" -line1_authname: "{$auth_id_1}" -line1_password: "{$user_password_1}" +{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.display_name}" +#registration information +proxy{$row.line_number}_address: "{$row.server_address}" +proxy{$row.line_number}_port:"{$row.sip_port}" +line{$row.line_number}_name: "{$row.user_id}" +line{$row.line_number}_displayname: "{$row.user_id}" +line{$row.line_number}_shortname: "{$row.display_name}" +line{$row.line_number}_authname: "{$row.auth_id}" +line{$row.line_number}_password: "{$row.password}" -line2_name: "{$user_id_2}" -line2_displayname: "{$user_id_2}" -line2_shortname: "{$short_name_2}" -line2_authname: "{$auth_id_2}" -line2_password: "{$user_password_2}" +{/foreach} +# Emergency Proxy info +proxy_emergency: "{$proxy_emergency}" +proxy_emergency_port: "{$proxy_emergency_port}" -line3_name: "{$user_id_3}" -line3_displayname: "{$user_id_3}" -line3_shortname: "{$short_name_3}" -line3_authname: "{$auth_id_3}" -line3_password: "{$user_password_3}" +# Backup Proxy info +proxy_backup: "{$proxy_backup}" +proxy_backup_port: "{$proxy_backup_port}" + +# Outbound Proxy info +outbound_proxy: "{$outbound_proxy}" +outbound_proxy_port: "{$outbound_proxy_port}" + +# NAT/Firewall Traversal +voip_control_port: "5060" +start_media_port: "16384" +end_media_port: "32768" +nat_received_processing: "0" +nat_enable: "{if isset($nat_enable)}{$nat_enable}{else}1{/if}" +nat_address: "{$nat_nat_address}" -line4_name: "{$user_id_4}" -line4_displayname: "{$user_id_4}" -line4_shortname: "{$short_name_4}" -line4_authname: "{$auth_id_4}" -line4_password: "{$user_password_4}" +# Sync value of the phone used for remote reset +sync: 1 ; Default 1 -line5_name: "{$user_id_5}" -line5_displayname: "{$user_id_5}" -line5_shortname: "{$short_name_5}" -line5_authname: "{$auth_id_5}" -line5_password: "{$user_password_5}" +# Proxy Registration (0-disable (default), 1-enable) +proxy_register: "1" + +# Phone Registration Expiration [1-3932100 sec] (Default - 3600) +timer_register_expires: "80" + +# Codec for media stream (g711ulaw (default), g711alaw, g729) +preferred_codec: "none" + +# TOS bits in media stream [0-5] (Default - 5) +tos_media: "5" -line6_name: "{$user_id_6}" -line6_displayname: "{$user_id_6}" -line6_shortname: "{$short_name_6}" -line6_authname: "{$auth_id_6}" -line6_password: "{$user_password_6}" \ No newline at end of file +# Enable VAD (0-disable (default), 1-enable) +enable_vad: "0" + +# Allow for the bridge on a 3way call to join remaining parties upon hangup +cnf_join_enable: "1" ; 0-Disabled, 1-Enabled (default) + +# Allow Transfer to be completed while target phone is still ringing +semi_attended_transfer: "0" ; 0-Disabled, 1-Enabled (default) + +# Telnet Level (enable or disable the ability to telnet into this phone +telnet_level: "2" ; 0-Disabled (default), 1-Enabled, 2-Privileged + +# Inband DTMF Settings (0-disable, 1-enable (default)) +dtmf_inband: "1" + +# Out of band DTMF Settings (none-disable, avt-avt enable (default), avt_always - always avt ) +dtmf_outofband: "avt" + +# DTMF dB Level Settings (1-6dB down, 2-3db down, 3-nominal (default), 4-3db up, 5-6dB up) +dtmf_db_level: "3" + +# SIP Timers +timer_t1: "500" ; Default 500 msec +timer_t2: "4000" ; Default 4 sec +sip_retx: "10" ; Default 11 +sip_invite_retx: "6" ; Default 7 +timer_invite_expires: "180" ; Default 180 sec + +# Setting for Message speeddial to UOne box +messages_uri: "*97" + +# TFTP Phone Specific Configuration File Directory +tftp_cfg_dir: "" + +# Time Server +sntp_mode: "unicast" +sntp_server: "{$sntp_server}" +{if isset($cisco_time_zone)} +time_zone: "{$cisco_time_zone}" +{/if} +dst_offset: "1" +dst_start_month: "Mar" +dst_start_day: "" +dst_start_day_of_week: "Sun" +dst_start_week_of_month: "2" +dst_start_time: "02" +dst_stop_month: "Nov" +dst_stop_day: "" +dst_stop_day_of_week: "Sunday" +dst_stop_week_of_month: "1" +dst_stop_time: "2" +dst_auto_adjust: "1" + +# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control) +dnd_control: "2" ; Default 0 (Do Not Disturb feature is off) + +# Caller ID Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control) +callerid_blocking: "0" ; Default 0 (Disable sending all calls as anonymous) + +# Anonymous Call Blocking (0-disbaled, 1-enabled, 2-disabled no user control, 3-enabled no user control) +anonymous_call_block: "0" ; Default 0 (Disable blocking of anonymous calls) + +# Call Waiting (0-disabled, 1-enabled, 2-disabled with no user control, 3-enabled with no user control) +call_waiting: "1" ; Default 1 (Call Waiting enabled) + +# DTMF AVT Payload (Dynamic payload range for AVT tones - 96-127) +dtmf_avt_payload: "101" ; Default 100 + +# XML file that specifies the dialplan desired +dial_template: "dialplan" + +# Network Media Type (auto, full100, full10, half100, half10) +network_media_type: "auto" + +#Autocompletion During Dial (0-off, 1-on [default]) +autocomplete: "1" + +#Time Format (0-12hr, 1-24hr [default]) +time_format_24hr: "0" + +# URL for external Phone Services +#services_url: "http://{$domain_name}/app/provision/file/services.xml" + +# URL for external Directory location +directory_url: "http://{$domain_name}/app/provision/file/directory.xml" + +# URL for branding logo +#logo_url: "http://{$domain_name}/app/provision/logo.bmp" + +# Remote Party ID +remote_party_id: 1 ; 0-Disabled (default), 1-Enabled diff --git a/resources/templates/provision/cisco/7960/directory-enterprise.xml b/resources/templates/provision/cisco/7960/directory-enterprise.xml new file mode 100644 index 0000000000..5c977112b0 --- /dev/null +++ b/resources/templates/provision/cisco/7960/directory-enterprise.xml @@ -0,0 +1,25 @@ + + Enterprise + Please choose... +{assign var=x value=1} +{foreach $contacts as $row}{if $row.contact_category == "enterprise"} + +{if $row.contact_name_given != ""} + {$row.contact_name_given} {$row.contact_name_family} +{else} + {$row.contact_organization} +{/if} +{if $row.phone_number != ""} + {$row.phone_number} +{else} + {$row.phone_extension} +{/if} + +{/if} +{assign var=x value=$x+1} +{/foreach} + + + + + diff --git a/resources/templates/provision/cisco/7960/directory-personal.xml b/resources/templates/provision/cisco/7960/directory-personal.xml new file mode 100644 index 0000000000..2e6750eb98 --- /dev/null +++ b/resources/templates/provision/cisco/7960/directory-personal.xml @@ -0,0 +1,24 @@ + + Personal + Please choose... +{assign var=x value=1} +{foreach $contacts as $row}{if $row.contact_category == "personal"} + +{if $row.contact_name_given != ""} + {$row.contact_name_given} {$row.contact_name_family} +{else} + {$row.contact_organization} +{/if} +{if $row.phone_number != ""} + {$row.phone_number} +{else} + {$row.phone_extension} +{/if} + +{/if} +{assign var=x value=$x+1} +{/foreach} + + + + diff --git a/resources/templates/provision/cisco/7960/directory-speed_dial.xml b/resources/templates/provision/cisco/7960/directory-speed_dial.xml new file mode 100644 index 0000000000..16138ed111 --- /dev/null +++ b/resources/templates/provision/cisco/7960/directory-speed_dial.xml @@ -0,0 +1,21 @@ + + Speed Dial + Please choose... +{assign var=x value=1} +{foreach $contacts as $row}{if $row.contact_category == "speed dial"} + +{if $row.contact_name_given != ""} + {$row.contact_name_given} {$row.contact_name_family} +{else} + {$row.contact_organization} +{/if} +{if $row.phone_number != ""} + {$row.phone_number} +{else} + {$row.phone_extension} +{/if} + +{/if} +{assign var=x value=$x+1} +{/foreach} + diff --git a/resources/templates/provision/cisco/7960/directory.xml b/resources/templates/provision/cisco/7960/directory.xml new file mode 100644 index 0000000000..24351b9b2d --- /dev/null +++ b/resources/templates/provision/cisco/7960/directory.xml @@ -0,0 +1,17 @@ + + Contacts + Please choose... + + Enterprise + http://{$domain_name}/app/provision/file/directory-enterprise.xml?mac={$mac} + + + Speed Dial + http://{$domain_name}/app/provision/file/directory-speed_dial.xml?mac={$mac} + + \ No newline at end of file