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 "; 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"; diff --git a/app/provision/index.php b/app/provision/index.php index 366ed87183..ae17fefba2 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 = strtolower(substr($name, 3, 12)); + unset($name); + } + } + //check alternate MAC source if (empty($mac)){ //set the http user agent @@ -283,7 +292,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'); diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 6905a786ed..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 "; @@ -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."' "; 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) { diff --git a/core/install/app_languages.php b/core/install/app_languages.php index 22ead46f1e..668e6dff7a 100644 --- a/core/install/app_languages.php +++ b/core/install/app_languages.php @@ -1,8 +1,8 @@ \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..ad08a3faeb 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 = ''; @@ -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 @@ -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"]); @@ -130,7 +129,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 +146,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 +167,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 +184,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"; @@ -224,6 +220,9 @@ if(!$install_step) { $install_step = 'select_language'; } echo " \n"; echo "\n"; }elseif($install_step == 'detect_config'){ + 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"; if($detect_ok){ echo "
\n"; @@ -238,6 +237,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'){ @@ -262,7 +267,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){ @@ -285,32 +290,34 @@ 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->debug = true; - $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; } } - $fusionPBX->install(); - + require_once "resources/classes/install_switch.php"; $switch = new install_switch($domain_name, $domain_uuid, $switch_detect); //$switch->debug = true; + //$system->debug = true; + $system->install(); $switch->install(); + $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"; } @@ -345,6 +352,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_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index b7482fe592..b38860fb10 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; @@ -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)'); @@ -94,9 +94,8 @@ include "root.php"; $this->create_superuser(); require "resources/require.php"; $this->create_menus(); - $this->app_defaults(); } - + protected function create_config_php() { $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); @@ -196,7 +196,7 @@ include "root.php"; unset($tmp_config); fclose($fout); } - + protected function create_database() { require $this->config_php; $this->write_progress("Creating database as " . $this->db_type); @@ -205,6 +205,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 { @@ -268,7 +269,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 { @@ -281,16 +282,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"; } @@ -303,7 +304,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; @@ -311,7 +312,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"; @@ -320,10 +321,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; @@ -340,7 +341,7 @@ include "root.php"; } unset ($file_contents, $sql); } - + protected function create_database_mysql() { //database connection try { @@ -377,7 +378,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 @@ -389,7 +390,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."'; "; @@ -400,7 +401,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") { @@ -408,7 +409,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; "; @@ -426,7 +427,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."; "; @@ -437,7 +438,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."'@'%'; "); @@ -447,7 +448,7 @@ include "root.php"; print "error: " . $error->getMessage() . "
"; } } - + //make the changes active try { $tmp_sql = "FLUSH PRIVILEGES; "; @@ -458,9 +459,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.";"); @@ -470,7 +471,7 @@ include "root.php"; print "error: " . $error->getMessage() . "
"; } } - + //add the database structure require_once "resources/classes/schema.php"; $schema = new schema; @@ -478,7 +479,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')){ @@ -488,10 +489,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; @@ -513,7 +514,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 "; @@ -530,7 +530,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 .= "("; @@ -544,11 +544,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'; @@ -580,7 +580,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; @@ -684,7 +684,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(); @@ -705,7 +705,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 "; @@ -732,7 +732,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; @@ -740,7 +740,7 @@ include "root.php"; include($config_path); $x++; } - + //add the groups $x = 0; $tmp[$x]['group_name'] = 'superadmin'; @@ -814,7 +814,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 "; @@ -933,14 +933,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."' "; @@ -971,7 +971,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; @@ -981,16 +981,19 @@ include "root.php"; unset($menu); } } - - protected function app_defaults() { + + 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; 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 "; @@ -1002,7 +1005,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 "; @@ -1017,37 +1020,41 @@ 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; + $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(); - + //run all app_defaults.php files $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); @@ -1064,4 +1071,5 @@ include "root.php"; clearstatcache(); } } + ?> \ No newline at end of file diff --git a/core/install/resources/classes/install_switch.php b/core/install/resources/classes/install_switch.php index b13c36b23d..715c2cef5b 100644 --- a/core/install/resources/classes/install_switch.php +++ b/core/install/resources/classes/install_switch.php @@ -35,7 +35,14 @@ include "root.php"; public $debug = false; function __construct($domain_name, $domain_uuid, $detect_switch) { - if(!is_a($detect_switch, 'detect_switch')){ + if($detect_switch == null){ + if(strlen($_SESSION['event_socket_ip_address']) == 0 or strlen($_SESSION['event_socket_port']) == 0 or strlen($_SESSION['event_socket_password']) == 0 ){ + throw new Exception('The parameter $detect_switch was empty and i could not find the event socket details from the session'); + } + $detect_switch = new detect_switch($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + $domain_name = $_SESSION['domain_name']; + $domain_uuid = $_SESSION['domain_uuid']; + }elseif(!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; @@ -166,13 +173,9 @@ 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() { @@ -182,10 +185,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)) { @@ -236,15 +239,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); } 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 928c6e5424..5d25ff6c43 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"; diff --git a/core/upgrade/app_defaults.php b/core/upgrade/app_defaults.php index b5625f3e7a..18edf8e23e 100644 --- a/core/upgrade/app_defaults.php +++ b/core/upgrade/app_defaults.php @@ -26,19 +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 - $install = new install; - $install->domain_uuid = $domain_uuid; - $install->switch_scripts_dir = $_SESSION['switch']['scripts']['dir']; - $install->copy_scripts(); - } //update the software table $sql = "select count(*) as num_rows from v_software "; 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']; } diff --git a/core/upgrade/upgrade.php b/core/upgrade/upgrade.php index 0a882c14c1..3698ef8332 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 the switch to perform upgrade functions + $obj = new install_switch; + $obj->upgrade(); + require_once "resources/classes/domains.php"; $domain = new domains; $domain->upgrade(); diff --git a/resources/classes/config.php b/resources/classes/config.php new file mode 100644 index 0000000000..a63ba0d03e --- /dev/null +++ b/resources/classes/config.php @@ -0,0 +1,127 @@ + $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() { + $this->find(); + if ($this->exists()) { + require $this->config_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; + } + } + + /** + * Find the path to the config.php + * @var string $config_path - full path to the config.php file + */ + public function find() { + //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; + } + + /** + * Determine whether the config.php exists + */ + public function exists() { + $this->find(); + if (strlen($this->config_path) > 0) { + return true; + } + else { + return false; + } + } +} +/* +$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; +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 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"; diff --git a/resources/install/scripts/fax_queue/exec.lua b/resources/install/scripts/app/fax/resources/scripts/queue/exec.lua similarity index 88% rename from resources/install/scripts/fax_queue/exec.lua rename to resources/install/scripts/app/fax/resources/scripts/queue/exec.lua index 7fbb58d826..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)) @@ -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/app/fax/resources/scripts/queue/next.lua similarity index 68% rename from resources/install/scripts/fax_queue/next.lua rename to resources/install/scripts/app/fax/resources/scripts/queue/next.lua index 0067d0e9b4..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 = { @@ -28,22 +28,26 @@ 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'," .. + 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()) - 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) + 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)) + end end) if esl then esl:close() end diff --git a/resources/install/scripts/fax_queue/retry.lua b/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua similarity index 91% rename from resources/install/scripts/fax_queue/retry.lua rename to resources/install/scripts/app/fax/resources/scripts/queue/retry.lua index ef099546b7..feb8f6ef4f 100644 --- a/resources/install/scripts/fax_queue/retry.lua +++ b/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua @@ -7,10 +7,10 @@ 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) + 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' @@ -76,6 +77,7 @@ log.noticef([[<<< CALL RESULT >>> uuid: = '%s' + task_session_uuid: = '%s' answered: = '%s' fax_file: = '%s' wav_file: = '%s' @@ -90,6 +92,7 @@ fax_options = '%s' ]], tostring(uuid) , + tostring(fax_queue_task_session) , tostring(answered) , tostring(fax_file) , tostring(wav_file) , @@ -338,9 +341,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/app/fax/resources/scripts/queue/tasks.lua similarity index 93% rename from resources/install/scripts/fax_queue/tasks.lua rename to resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua index 920f1e9087..96f6d612bf 100644 --- a/resources/install/scripts/fax_queue/tasks.lua +++ b/resources/install/scripts/app/fax/resources/scripts/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/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/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 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 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() 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..52f8e647e4 --- /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'}) + + diff --git a/resources/switch.php b/resources/switch.php index e4eb04c532..bf96fa85a3 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, '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; + } +} + ?> 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..2d9adbd63f 100644 --- a/resources/templates/provision/cisco/7940/SIP{$mac}.cnf +++ b/resources/templates/provision/cisco/7940/SIP{$mac}.cnf @@ -1,19 +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}" \ 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 +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}" + +# Sync value of the phone used for remote reset +sync: 1 ; Default 1 + +# 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/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/7940/directory-enterprise.xml b/resources/templates/provision/cisco/7940/directory-enterprise.xml index 7b84648f36..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}# - {else} - Dial:{$row.phone_extension}# - {/if} - - {/if} - {/foreach} - - Exit - SoftKey:Exit - 4 - - +{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/7940/directory-personal.xml b/resources/templates/provision/cisco/7940/directory-personal.xml index 9d774ab56a..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}# - {else} - Dial:{$row.phone_extension}# - {/if} - - {/if} - {/foreach} - - Exit - SoftKey:Exit - 4 - - +{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/7940/directory-speed_dial.xml b/resources/templates/provision/cisco/7940/directory-speed_dial.xml index f100c38cd6..16138ed111 100644 --- a/resources/templates/provision/cisco/7940/directory-speed_dial.xml +++ b/resources/templates/provision/cisco/7940/directory-speed_dial.xml @@ -1,32 +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}# - {else} - Dial:{$row.phone_extension}# - {/if} - - {/if} - {assign var=x value=$x+1} - {/foreach} - - Exit - SoftKey:Exit - 4 - - +{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/7940/directory.xml b/resources/templates/provision/cisco/7940/directory.xml index 9c90716c7c..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&mac={$mac} + --> Enterprise + http://{$domain_name}/app/provision/file/directory-enterprise.xml?mac={$mac} Speed Dial - http://{$domain_name}/app/provision/?file=directory-speed_dial&mac={$mac} + 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 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 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