diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 5e28008..bb8e1c1 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -23,6 +23,7 @@ * + Dial Templates + Configuration * + Dial Templates in Global Configuration ( Enabled / Disabled ; default template ) * ? Dial Templates - Howto IT Include in XML.Config ??????? + * + Dial Templates - SIP Device * - Dial Templates in device Configuration ( Enabled / inheret / Disabled ; template ) * - WiFi Config (Bulk Deployment Utility for Cisco 7921, 7925, 7926)????? @@ -58,6 +59,7 @@ * + Create ATADefault.cnf.xml * - Create Second line Use MAC AABBCCDDEEFF rotation MAC BBCCDDEEFF01 (ATA 187 ) * + Add SEP, ATA, VG prefix. + * + Add Cisco SIP device Tftp config. * - VG248 ports start with VGXXXXXXXXXXXX0. * * I think this file should be split in 3 parts (as in Model-View-Controller(MVC)) * * XML/Database Parts -> Model directory @@ -477,10 +479,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { "name" => _("SCCP Device Keyset"), "page" => 'views/advserver.keyset.php' ), -// "sccpdialplan" => array( -// "name" => _("SCCP Dial Plan information"), -// "page" => 'views/advserver.dialtemplate.php' -// ) + "sccpdialplan" => array( + "name" => _("SIP Dial Plan information"), + "page" => 'views/advserver.dialtemplate.php' + ) ); break; } @@ -506,7 +508,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // print_r($inputform); if (empty($this->pagedata)) { switch ($inputform) { - case cisco: + case "cisco": $this->pagedata = array( "general" => array( "name" => _("Device configuration"), @@ -524,8 +526,25 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } break; + case "cisco-sip": + $this->pagedata = array( + "general" => array( + "name" => _("Sip device configuration"), + "page" => 'views/form.addsdevice.php' + ), + "buttons" => array( + "name" => _("Sip device Buttons"), + "page" => 'views/form.sbuttons.php' + )); +// if ($this->sccpvalues['sccp_compatible']['data'] < '433') { +// $this->pagedata["sccpcodec"] = array( +// "name" => _("Device SCCP Codec"), +// "page" => 'views/server.codec.php' +// ); +// } + break; - case r_user: + case "r_user": $this->pagedata = array( "general" => array( "name" => _("Rouming User configuration"), @@ -548,6 +567,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { "sccpdevice" => array( "name" => _("SCCP Phone"), "page" => 'views/hardware.phone.php' + ), + "sipdevice" => array( + "name" => _("SIP CISCO Phone"), + "page" => 'views/hardware.sphone.php' ) ); break; @@ -605,6 +628,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'backupsettings': case 'savesettings': case 'save_hardware': + case 'save_sip_hardware': case 'save_ruser': case 'save_dialplan_template': case 'delete_hardware': @@ -654,6 +678,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'message' => $msg, 'reload' => true); break; + case 'save_sip_hardware': case 'save_hardware': $this->save_hw_phone($request); // return array('status' => true, 'href' => 'config.php?display=sccp_phone', 'reload' => true); @@ -669,9 +694,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return array('status' => false, 'message' => print_r($res)); break; /* !TODO!: -TODO-: dialplan templates should be removed (only required for very old devices (like ATA) */ -// ------------------------------- Old deviece suport - In the development--- +// ------------------------------- Old + Sip deviece suport - In the development--- case 'save_dialplan_template': - $res = $this->save_DialPlant($request); + $res = $this->save_DialPlan($request); + //public if (empty($res)) { return array('status' => true, 'search' => '?display=sccp_adv', 'hash' => 'sccpdialplan'); } else { @@ -682,7 +708,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'delete_dialplan': if (!empty($request['dialplan'])) { $get_file = $request['dialplan']; - $res = $this->del_DialPlant($get_file); + $res = $this->del_DialPlan($get_file); // !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'message' => 'Dial Template has been deleted ! ', 'table_reload' => true); } else { @@ -717,6 +743,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { foreach ($models as $data) { $ver_id = $this->sccp_create_device_XML($data['name']); }; +// !TODO!: -TODO-: Check SIP Suport Enabled + $this->sccp_create_xmlSoftkey(); // Create Softkey Sets for SIP // !TODO!: -TODO-: Do these returned message strings work with i18n ? // !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'message' => 'Create new config files (version:' . $ver_id . ')'); @@ -855,6 +883,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } $this->sccp_create_sccp_init(); + +// !TODO!: -TODO-: Check SIP Suport Enabled + $this->sccp_create_xmlSoftkey(); + $msg = print_r($this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')), 1); return array('status' => true, 'table_reload' => true); @@ -906,7 +938,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $result; break; case 'getPhoneGrid': - $result = $this->dbinterface->get_db_SccpTableData('SccpDevice'); + $cmd_type = !empty($request['type']) ? $request['type'] : ''; + + $result = $this->dbinterface->get_db_SccpTableData('SccpDevice', array('type'=>$cmd_type)); + if ($cmd_type == 'cisco-sip'){ + return $result; + } $staus = $this->srvinterface->sccp_get_active_device(); if (empty($result)) { $result = array(); @@ -990,7 +1027,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // Get Model Buttons info $res = array(); - $lines_list = $this->dbinterface->get_db_SccpTableData('SccpExtension'); +// $lines_list = $this->dbinterface->get_db_SccpTableData('SccpExtension'); $max_btn = ((!empty($get_settings['buttonscount']) ? $get_settings['buttonscount'] : 100)); $last_btn = $max_btn; for ($it = $max_btn; $it >= 0; $it--) { @@ -1106,6 +1143,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $name_dev = ''; $db_field = $this->dbinterface->get_db_SccpTableData("get_colums_sccpdevice"); $hw_id = (empty($get_settings['sccp_deviceid'])) ? 'new' : $get_settings['sccp_deviceid']; + $hw_type = (empty($get_settings['sccp_device_typeid'])) ? 'sccpdevice' : $get_settings['sccp_device_typeid']; $update_hw = ($hw_id == 'new') ? 'update' : 'clear'; $hw_prefix = 'SEP'; if (!empty($get_settings[$hdr_prefix . 'type'])) { @@ -1162,6 +1200,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $value = $get_settings[$hdr_prefix . 'netlang'] . ':' . $get_settings[$hdr_prefix . 'devlang']; } break; +// case '_json': +// foreach ($get_settings[$hdr_arprefix . $key.'_sip'] as $vkey => $vval) { +// } +// break; +// default : if (!empty($get_settings[$hdr_prefix . $key])) { $value = $get_settings[$hdr_prefix . $key]; @@ -1217,7 +1260,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->dbinterface->sccp_save_db("sccpdevice", $save_settings, 'replace'); // Get Model Buttons info - $save_buttons = $this-> get_buttons_phone($get_settings,$name_dev, 'sccpdevice'); +// $save_buttons = $this-> get_buttons_phone($get_settings,$name_dev, 'sccpdevice'); + $save_buttons = $this-> get_buttons_phone($get_settings,$name_dev, $hw_type); // Sace Buttons config $this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, $update_hw, '', $name_dev); @@ -1714,15 +1758,25 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } - + /* + * Soft Key + * + */ + + function sccp_create_xmlSoftkey(){ + foreach ($this->srvinterface->sccp_list_keysets() as $keyl => $vall) { + $this->xmlinterface->create_xmlSoftkeyset($this->sccp_conf_init,$this->sccppath,$keyl); + } + } + /* * DialPlan * */ function get_DialPlanList() { - $dir = $this->sccppath["tftp_DP"] . '/*.xml'; - $base_len = strlen($this->sccppath["tftp_DP"]) + 1; + $dir = $this->sccppath["tftp_dialplan"] . '/dial*.xml'; + $base_len = strlen($this->sccppath["tftp_dialplan"]) + 1; $res = glob($dir); $dp_list = array(); foreach ($res as $key => $value) { @@ -1733,7 +1787,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function get_DialPlan($get_file) { - $file = $this->sccppath["tftp_DP"] . '/' . $get_file . '.xml'; + $file = $this->sccppath["tftp_dialplan"] . '/' . $get_file . '.xml'; if (file_exists($file)) { // $load_xml_data = simplexml_load_file($file); @@ -1748,7 +1802,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { function del_DialPlan($get_file) { if (!empty($get_file)) { - $file = $this->sccppath["tftp_DP"] . '/' . $get_file . '.xml'; + $file = $this->sccppath["tftp_dialplan"] . '/' . $get_file . '.xml'; if (file_exists($file)) { $res = unlink($file); } @@ -1757,53 +1811,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function save_DialPlan($get_settings) { - $xmlstr = "\n"; - $dialFelds = array('match', 'timeout', 'rewrite', 'tone'); //str -to lo ! - - $hdr_prefix = 'sccp_dial_'; - $hdr_arprefix = 'sccp_dial-ar_'; - $save_data = array(); - $integer_msg = _("%s must be a non-negative integer"); - $errors = array(); - foreach ($get_settings[$hdr_arprefix . 'dialtemplate'] as $key => $value) { - $xmlstr .= 'sccppath["tftp_DP"] . '/' . $put_file . '.xml'; - file_put_contents($file, $xmlstr); - } - - return $errors; + + $confDir = $this->sccppath["tftp_dialplan"]; + return $this->xmlinterface->save_DialPlan($confDir, $get_settings); } /* @@ -1907,33 +1917,38 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (empty($dev_id)) { return false; } - + $sccp_native = true; + $data_value = array(); + $dev_line_data = null; + $dev_config = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id)); - +// Support Cisco Sip Device + if (!empty($dev_config['type'])) { + if (strpos($dev_config['type'],'sip') !== false) { + $sccp_native = false; + $data_tmp =$this->sipconfigs->getSipConfig(); + $dev_ext_config = $this->dbinterface->get_db_SccpTableData("SccpDevice", array('name' => $dev_id, 'fields'=>'sip_ext')); + $data_value = array_merge($data_value, $dev_ext_config, $data_tmp); + $data_tmp = explode(';',$dev_ext_config['sip_lines']); + foreach ($data_tmp as $value) { + $tmp_line = explode(',',$value); + if ($tmp_line[0] == 'line') { + $dev_line_data= $this->sipconfigs->get_db_sip_TableData('DeviceById',array('id'=>$tmp_line[1])); + if (!empty($dev_line_data)) { + $data_value['siplines'][] = $dev_line_data; + } + } + } +// return print_r($dev_line_data,true); + } + } foreach ($this->sccpvalues as $key => $value) { $data_value[$key] = $value['data']; } $data_value['ntp_timezone_id'] = $this->extconfigs->getextConfig('sccp_timezone', $data_value['ntp_timezone']); $data_value['server_if_list'] = $this->getIP_information2('ip4'); - $dev_config['tftp_path'] = $this->sccppath["tftp_path"]; + $dev_config = array_merge($dev_config, $this->sccppath); $dev_config['tftp_firmware'] = ''; - /* if (!empty($this->sccpvalues['tftp_rewrite'])) { - if ( $this->sccpvalues['tftp_rewrite']['data'] == 'internal' ) { - $dir_list = $this->find_all_files($dev_config['tftp_path'], $dev_config['loadimage']); - foreach ($dir_list as $filek){ - if (!empty($filek)) { - $fnd_path= ''; - $fnd_path = str_replace($dev_config['tftp_path'],'',$filek); - $fnd_path = substr($fnd_path,1,strpos($fnd_path, $dev_config['loadimage'])-1); - if (!empty($fnd_path)) { - $dev_config['tftp_firmware'] = $fnd_path; - } - break; - } - } - } - } - */ $dev_config['addon_info'] = array(); if (!empty($dev_config['addon'])) { $hw_addon = explode(',', $dev_config['addon']); @@ -1942,9 +1957,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dev_config['addon_info'][$key] = $hw_data[0]['loadimage']; } } +// return print_r($dev_config,true); + $lang_data = $this->extconfigs->getextConfig('sccp_lang'); -// return $this->sccppath["tftp_path_store"]; - + if (!$sccp_native) { + return $this->xmlinterface->create_SEP_SIP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data); + } return $this->xmlinterface->create_SEP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data); } @@ -2068,10 +2086,16 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $search_mode = ''; if (!empty($this->sccpvalues['tftp_rewrite'])) { $search_mode = $this->sccpvalues['tftp_rewrite']['data']; - if ($search_mode == 'pro') { - $dir_list = $this->find_all_files($dir, $file_ext, 'fileonly'); - } else { - $dir_list = $this->find_all_files($dir, $file_ext); + switch ($search_mode) { + case 'pro': + case 'on': + case 'internal': + $dir_list = $this->find_all_files($dir, $file_ext, 'fileonly'); + break; + case 'off': + default: // Place in root TFTP dir + $dir_list = $this->find_all_files($dir, $file_ext); + break; } } else { $dir_list = $this->find_all_files($dir, $file_ext, 'fileonly'); @@ -2084,7 +2108,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $raw_settings[$i]['validate'] = '-;-'; if (!empty($raw_settings[$i]['loadimage'])) { $raw_settings[$i]['validate'] = 'no;'; - if ((strtolower($raw_settings[$i]['vendor'] == 'cisco')) || !empty($dir_list)) { + if (((strtolower($raw_settings[$i]['vendor']) == 'cisco') || (strtolower($raw_settings[$i]['vendor']) == 'cisco-sip')) && !empty($dir_list) ){ foreach ($dir_list as $filek) { switch ($search_mode) { case 'pro': diff --git a/Sccp_manager.inc/dbinterface.class.php b/Sccp_manager.inc/dbinterface.class.php index ee0bb0e..8173022 100644 --- a/Sccp_manager.inc/dbinterface.class.php +++ b/Sccp_manager.inc/dbinterface.class.php @@ -49,17 +49,59 @@ class dbinterface { $sql = "SELECT * FROM `sccpline` ORDER BY `name`"; $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); } else { - $sql = "SELECT * FROM `sccpline` WHERE `name`=" . $data['name']; + $sql = "SELECT * FROM `sccpline` WHERE `name`='" . $data['name']. "'";; $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); } break; case "SccpDevice": -// $sql = "SELECT * FROM `sccpdeviceconfig` ORDER BY `name`"; - $sql = "select `name`,`name` as `mac`, `type`, `button`, `addon`, `_description` as description from `sccpdeviceconfig` ORDER BY `name`"; - $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); + $filtred =''; + $singlrow = false; + if (empty($data['fields'])) { + $fld = '`name`,`name` as `mac`, `type`, `button`, `addon`, `_description` as description'; + } else { + switch ($data['fields']) { + case "all": + $fld ='*'; + break; + case "sip_ext": + $fld ='button as sip_lines, description as description, addon'; + break; + default: + $fld = $data['fields']; + break; + } + } + if (!empty($data['name'])) { + $filtred = "`name`='" . $data['name']. "'";; + $singlrow = true; + } + if (!empty($data['type'])) { + switch ($data['type']) { + case "cisco-sip": + $filtred = "`TYPE` LIKE '%-sip'"; + break; + case "cisco": + default: + $filtred = "`TYPE` not LIKE '%-sip'"; + break; + } + } + if (empty($filtred)) { + $sql = "SELECT ". $fld ." FROM `sccpdeviceconfig` ORDER BY `name`"; + } else { + $sql = "SELECT ". $fld ." FROM `sccpdeviceconfig` WHERE ".$filtred." ORDER BY `name`"; + } + if ($singlrow) { + $raw_settings = sql($sql, "getRow", DB_FETCHMODE_ASSOC); + } else { + $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); + } + break; + case "HWSipDevice": + $raw_settings = $this->getDb_model_info($get = "sipphones", $format_list = "model"); break; case "HWDevice": - $raw_settings = $this->getDb_model_info($get = "phones", $format_list = "model"); + $raw_settings = $this->getDb_model_info($get = "ciscophones", $format_list = "model"); break; case "HWextension": $raw_settings = $this->getDb_model_info($get = "extension", $format_list = "model"); @@ -169,6 +211,14 @@ class dbinterface { case "enabled": case "phones": $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (dns > 0) and (enabled > 0) ORDER BY model "; +// $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (enabled > 0) ORDER BY model "; + break; + case "ciscophones": + $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (dns > 0) and (enabled > 0) AND `vendor` not LIKE '%-sip' ORDER BY model "; +// $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (enabled > 0) ORDER BY model "; + break; + case "sipphones": + $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (dns > 0) and (enabled > 0) AND `vendor` LIKE '%-sip' ORDER BY model "; // $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (enabled > 0) ORDER BY model "; break; case "all": diff --git a/Sccp_manager.inc/extconfigs.class.php b/Sccp_manager.inc/extconfigs.class.php index 5220621..d27b6cf 100644 --- a/Sccp_manager.inc/extconfigs.class.php +++ b/Sccp_manager.inc/extconfigs.class.php @@ -216,25 +216,25 @@ class extconfigs { // global $amp_conf; // *** Setings for Provision Sccp $adv_config = Array('tftproot' => '', 'firmware' => 'firmware', 'settings' => 'settings', - 'locales' => 'locales', 'languages' => 'languages', 'templates' => 'templates'); + 'locales' => 'locales', 'languages' => 'languages', 'templates' => 'templates', 'dialplan' => 'dialplan', 'softkey' => 'softkey'); // 'pro' /tftpboot - root dir // /tftpboot/locales/locales/%Languge_name% // /tftpboot/settings/XMLdefault.cnf.xml // /tftpboot/settings/SEP[MAC].cnf.xml // /tftpboot/firmware/79xx/SCCPxxxx.loads - $adv_tree['pro'] = Array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales'); + $adv_tree['pro'] = Array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales', 'dialplan' => 'tftproot', 'softkey' => 'tftproot'); // 'def' /tftpboot - root dir // /tftpboot/languages/%Languge_name% // /tftpboot/XMLdefault.cnf.xml // /tftpboot/SEP[MAC].cnf.xml // /tftpboot/SCCPxxxx.loads - $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => '', 'firmware' => '', 'languages' => 'tftproot'); + $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => '', 'firmware' => '', 'languages' => 'tftproot','dialplan' => '', 'softkey' => ''); // $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => ''); // $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'tftproot'); //* **************------ **** - $base_tree = Array('tftp_templates' => 'templates', 'tftp_path_store' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path' => 'firmware'); + $base_tree = Array('tftp_templates' => 'templates', 'tftp_path_store' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path' => 'firmware', 'tftp_dialplan' => 'dialplan', 'tftp_softkey' => 'softkey'); if (empty($confDir)) { return array('error' => 'empty СonfDir'); @@ -309,7 +309,8 @@ class extconfigs { } } } - + print_r($base_config,1); +// die(print_r($base_config,1)); // $base_config['External_ini'] = $adv_config; // $base_config['External_mode'] = $adv_tree_mode; diff --git a/Sccp_manager.inc/sipconfigs.class.php b/Sccp_manager.inc/sipconfigs.class.php new file mode 100644 index 0000000..461f8d3 --- /dev/null +++ b/Sccp_manager.inc/sipconfigs.class.php @@ -0,0 +1,104 @@ +paren_class = $parent_class; +// $freepbx +// $this->database = $freepbx->Database; + } + + public function info() { + $Ver = '13.0.4'; + return Array('Version' => $Ver, + 'about' => 'Sip Setings ver: ' . $Ver); + } + + public function get_db_sip_TableData($dataid, $data = array()) { + global $db; + if ($dataid == '') { + return False; + } + switch ($dataid) { + case "Device": + $sql = "SELECT * FROM sip ORDER BY `id`"; + $tech = array(); + try { + $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); + foreach ($raw_settings as $value) { + if (empty($tech[$value['id']]['id'])) { + $tech[$value['id']]['id']= $value['id']; + } + $tech[$value['id']][$value['keyword']]=$value['data']; + } + } catch (\Exception $e) { + + } + return $tech; + case "DeviceById": + $sql = "SELECT keyword,data FROM sip WHERE id = ?"; + $sth = $db->prepare($sql); + $tech = array(); + try { + $id = $data['id']; + $sth->execute(array($id)); + $tech = $sth->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_GROUP); + foreach ($tech as &$value) { + $value = $value[0]; + } + } catch (\Exception $e) { + + } + return $tech; + } + + } + + public function getSipConfig() { + $result = array(); + $def_sip_proto = 'sip'; + $def_proto = 'tcp'; + $supp_proto = ''; + + $result['sipport'] = \FreePBX::Sipsettings()->getConfig('bindport'); + $result['tlsport'] = \FreePBX::Sipsettings()->getConfig('tlsbindport'); + $tmp_sipsetigs = \FreePBX::Sipsettings()->getChanSipSettings(); + $tmp_sip_binds = \FreePBX::Sipsettings()->getBinds(); + + $tmp_bind_ip = !empty($tmp_sipsetigs['externhost_val']) ? $tmp_sipsetigs['externhost_val'] : ''; + $tmp_bind_ip = !empty($tmp_sipsetigs['externip_val']) ? $tmp_sipsetigs['externip_val'] : $tmp_bind_ip; + $tmp_bind_ip = !empty($tmp_sipsetigs['bindaddr']) ? $tmp_sipsetigs['bindaddr'] : $tmp_bind_ip; + +// $result['sipbind'] = $tmp_bind_ip; + if (empty($tmp_sip_binds[$def_sip_proto])){ + $def_proto = 'pjsip'; + } + + foreach ($tmp_sip_binds[$def_sip_proto] as $key => $value) { + if (empty($value[$def_proto])) { + $def_proto = 'udp'; + $supp_proto = 'udp'; + } else { + $supp_proto = !empty($value['udp']) ? 'tcp;udp' : 'tcp'; + } + if (empty($def_key)) { + $def_key = $key; + } + if ($key != '0.0.0.0') { + $tmp_bind_ip = $key; + } + $result['sipbindport'] = $value[$def_proto]; + } + $result['sipbind'] = $tmp_bind_ip; + $result['sipsuportproto'] = $supp_proto; + return $result; + } +} diff --git a/Sccp_manager.inc/xmlinterface.class.php b/Sccp_manager.inc/xmlinterface.class.php index 66bfb8c..88fa965 100644 --- a/Sccp_manager.inc/xmlinterface.class.php +++ b/Sccp_manager.inc/xmlinterface.class.php @@ -18,11 +18,11 @@ class xmlinterface { private $val_null = 'NONE'; /// REPLACE to null Field public function __construct($parent_class = null) { - $this->paren_class = $parent_class; + $this->paren_class = $parent_class; } public function info() { - $Ver = '13.0.3'; + $Ver = '13.0.4'; return Array('Version' => $Ver, 'about' => 'Create XML data interface ver: ' . $Ver); } @@ -49,7 +49,7 @@ class xmlinterface { if (!empty($value['ip'])) { $ip_valid = true; if (!empty($data_values['ccm_address'])) { - if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false ) { + if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false) { // Skip } else { if (strpos($data_values['ccm_address'], $value['ip']) === false) { @@ -90,7 +90,6 @@ class xmlinterface { $node = $xml_work->$value; unset($node[0][0]); } - } foreach ($def_xml_locale as $key) { if (!empty($xml_work->$key)) { @@ -137,7 +136,7 @@ class xmlinterface { } function create_SEP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) { - + $var_xml_general_fields = array('authenticationURL' => 'dev_authenticationURL', 'informationURL' => 'dev_informationURL', 'messagesURL' => 'dev_messagesURL', 'servicesURL' => 'dev_servicesURL', 'directoryURL' => 'dev_directoryURL', 'proxyServerURL' => 'dev_proxyServerURL', 'idleTimeout' => 'dev_idleTimeout', 'idleURL' => 'dev_idleURL', 'sshUserId' => 'dev_sshUserId', 'sshPassword' => 'dev_sshPassword', 'deviceProtocol' => 'dev_deviceProtocol', @@ -146,7 +145,7 @@ class xmlinterface { $var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList' => 'null', 'mobility' => 'null', 'phoneServices' => 'null', 'certHash' => 'null', 'deviceSecurityMode' => '1'); - + // $var_hw_config = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id)); if (empty($dev_config)) { @@ -199,14 +198,14 @@ class xmlinterface { } $xnode->name = $tz_id; $xnode->dateTemplate = $data_values['dateformat']; - $xnode->timeZone = $TZdata['cisco_code']; + $xnode->timeZone = $TZdata['cisco_code']; // $xnode->timeZone = $tz_id.' Standard'.((empty($TZdata['daylight']))? '': '/'.$TZdata['daylight']).' Time'; if ($data_values['ntp_config_enabled'] == 'yes') { $xnode->ntps->ntp->name = $data_values['ntp_server']; $xnode->ntps->ntp->ntpMode = $data_values['ntp_server_mode']; } else { - $xnode->ntps = ''; + $xnode->ntps = null; } // Ntp Config break; @@ -248,48 +247,65 @@ class xmlinterface { break; case 'callManagerGroup': $xnode = &$xml_node->$dkey->members; - if ($data_values['bindaddr'] == '0.0.0.0') { - $ifc = 0; - foreach ($data_values['server_if_list'] as $value) { - - if (!empty($value['ip'])) { - $ip_valid = true; - if (!empty($data_values['ccm_address'])) { - if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false ) { - // Skip - } else { - if (strpos($data_values['ccm_address'], $value['ip']) === false) { - $ip_valid = false; - } - } - } - if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1'), true) && ($ip_valid)) { - - $xnode_obj = clone $xnode->member; -// $xnode_obj = $xnode -> member; -// $xnode_obj = $xnode -> addChild($xnode->member); - $xnode_obj['priority'] = $ifc; - //$xnode_obj = &$xnode -> member -> callManager; - $xnode_obj->callManager->name = $data_values['servername']; - $xnode_obj->callManager->ports->ethernetPhonePort = $data_values['port']; - $xnode_obj->callManager->processNodeName = $value['ip']; - if ($ifc === 0) { - $this->replaceSimpleXmlNode($xnode->member, $xnode_obj); - } else { - $this->appendSimpleXmlNode($xnode->member, $xnode_obj); - } - $ifc ++; - } - } + $bind_tmp = $this->get_server_sccp_bind($data_values); + $ifc = 0; + foreach ($bind_tmp as $bind_value) { + $xnode_obj = clone $xnode->member; + $xnode_obj['priority'] = $ifc; + $xnode_obj->callManager->name = $data_values['servername']; + $xnode_obj->callManager->ports->ethernetPhonePort = $bind_value['port']; + $xnode_obj->callManager->processNodeName = $bind_value['ip']; + if ($ifc === 0) { + $this->replaceSimpleXmlNode($xnode->member, $xnode_obj); + } else { + $this->appendSimpleXmlNode($xnode->member, $xnode_obj); } - } else { - $xnode->member['priority'] = '0'; - $xnode_obj = &$xnode->member->callManager; - $xnode_obj->name = $data_values['servername']; - $xnode_obj->ports->ethernetPhonePort = $data_values['port']; - $xnode_obj->processNodeName = $data_values['bindaddr']; + $ifc ++; } - break; + /* if ($data_values['bindaddr'] == '0.0.0.0') { + $ifc = 0; + foreach ($data_values['server_if_list'] as $value) { + + if (!empty($value['ip'])) { + $ip_valid = true; + if (!empty($data_values['ccm_address'])) { + if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false ) { + // Skip + } else { + if (strpos($data_values['ccm_address'], $value['ip']) === false) { + $ip_valid = false; + } + } + } + if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1'), true) && ($ip_valid)) { + + $xnode_obj = clone $xnode->member; + // $xnode_obj = $xnode -> member; + // $xnode_obj = $xnode -> addChild($xnode->member); + $xnode_obj['priority'] = $ifc; + //$xnode_obj = &$xnode -> member -> callManager; + $xnode_obj->callManager->name = $data_values['servername']; + $xnode_obj->callManager->ports->ethernetPhonePort = $data_values['port']; + $xnode_obj->callManager->processNodeName = $value['ip']; + if ($ifc === 0) { + $this->replaceSimpleXmlNode($xnode->member, $xnode_obj); + } else { + $this->appendSimpleXmlNode($xnode->member, $xnode_obj); + } + $ifc ++; + } + } + } + } else { + $xnode->member['priority'] = '0'; + $xnode_obj = &$xnode->member->callManager; + $xnode_obj->name = $data_values['servername']; + $xnode_obj->ports->ethernetPhonePort = $data_values['port']; + $xnode_obj->processNodeName = $data_values['bindaddr']; + } + break; + * + */ } } $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); @@ -300,7 +316,7 @@ class xmlinterface { case 'loadInformation': // Set Path Image ???? if (isset($dev_config["tftp_firmware"])) { - $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"].$dev_config["loadimage"] : ''; + $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : ''; } else { $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["loadimage"] : ''; } @@ -319,10 +335,10 @@ class xmlinterface { break; case 'commonProfile': $xml_node->phonePassword = $data_values['dev_sshPassword']; - $xml_node->backgroundImageAccess = (($data_values['backgroundImageAccess'] =='on') || ($data_values['backgroundImageAccess'] =='true') ) ? 'true':'false'; + $xml_node->backgroundImageAccess = (($data_values['backgroundImageAccess'] == 'on') || ($data_values['backgroundImageAccess'] == 'true') ) ? 'true' : 'false'; $xml_node->callLogBlfEnabled = $data_values['callLogBlfEnabled']; break; - + case 'userLocale': case 'networkLocaleInfo': case 'networkLocale': @@ -336,19 +352,19 @@ class xmlinterface { } else { $lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1]; } - if (($lang != 'null') && (!empty($lang))) { - if ($key == 'networkLocale') { - $xml_work->$key = $lang; - } else { - if (isset($lang_info[$lang])) { - $xml_node->name = $lang_info[$lang]['locale']; - $xml_node->langCode = $lang_info[$lang]['code']; - if ($key == 'userLocale') { - $xml_node->winCharSet = $lang_info[$lang]['codepage']; - } - $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + if (($lang != 'null') && (!empty($lang))) { + if ($key == 'networkLocale') { + $xml_work->$key = $lang; + } else { + if (isset($lang_info[$lang])) { + $xml_node->name = $lang_info[$lang]['locale']; + $xml_node->langCode = $lang_info[$lang]['code']; + if ($key == 'userLocale') { + $xml_node->winCharSet = $lang_info[$lang]['codepage']; } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } + } } else { $xml_work->$key = ''; } @@ -373,6 +389,461 @@ class xmlinterface { return time(); } + private function get_server_sccp_bind($data_values = array()) { + $res = array(); + + if ($data_values['bindaddr'] == '0.0.0.0') { + $ifc = 0; + foreach ($data_values['server_if_list'] as $value) { + if (!empty($value['ip'])) { + $ip_valid = true; + if (!empty($data_values['ccm_address'])) { + if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false) { + // Skip + } else { + if (strpos($data_values['ccm_address'], $value['ip']) === false) { + $ip_valid = false; + } + } + } + if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1'), true) && ($ip_valid)) { + $res[] = array('ip' => $value['ip'], 'port' => $data_values['port']); + } + } + } + } else { + $res[0] = array('ip' => $data_values['bindaddr'], 'port' => $data_values['port']); + } + return $res; + } + + private function get_server_sip_bind($data_values = array()) { + $res = array(); + + if (!empty($data_values['sipbind']) and ( $data_values['sipbind'] != '0.0.0.0')) { + $res[0] = array('ip' => $data_values['sipbind'], 'port' => $data_values['sipbindport'], 'tlsport' => $data_values['tlsport'], 'proto' => $data_values['sipsuportproto']); + } + + $ifc = 0; + foreach ($data_values['server_if_list'] as $value) { + if (!empty($value['ip'])) { + $ip_valid = true; + if (!empty($data_values['ccm_address'])) { + if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false) { + // Skip + } else { + if (strpos($data_values['ccm_address'], $value['ip']) === false) { + $ip_valid = false; + } + } + } + if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1', $data_values['sipbind']), true) && ($ip_valid)) { + $res[] = array('ip' => $value['ip'], 'port' => $data_values['sipbindport'], 'tlsport' => $data_values['tlsport'], 'proto' => $data_values['sipsuportproto']); + } + } + } + return $res; + } + + function create_SEP_SIP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) { + + $var_xml_general_fields = array('authenticationURL' => 'dev_authenticationURL', 'informationURL' => 'dev_informationURL', 'messagesURL' => 'dev_messagesURL', + 'servicesURL' => 'dev_servicesURL', 'directoryURL' => 'dev_directoryURL', 'proxyServerURL' => 'dev_proxyServerURL', 'idleTimeout' => 'dev_idleTimeout', + 'idleURL' => 'dev_idleURL', 'sshUserId' => 'dev_sshUserId', 'sshPassword' => 'dev_sshPassword', + 'phonePersonalization' => 'phonePersonalization' + ); + $var_xml_sipProfile = array('phoneLabel' => 'description', + 'transferOnhookEnabled' => 'transferOnhookEnabled', 'enableVad' => 'enableVad', 'voipControlPort' => 'sipport' + ); + $var_xml_sipline = array('name' => 'account', 'featureLabel' => 'account', 'displayName' => 'callerid', 'contact' => 'account', + 'authName' => 'account', 'authPassword' => 'secret'); + $var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList' => 'null', 'mobility' => 'null', + 'phoneServices' => 'null', 'certHash' => 'null', 'deviceProtocol' => 'SIP', + 'deviceSecurityMode' => '1'); + +// $var_hw_config = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id)); + + if (empty($dev_config)) { + return false; + } + $data_path = $dev_config['tftp_path']; + + if (empty($store_path) || empty($data_path) || empty($data_values) || empty($dev_id)) { + return; + } + + if (!empty($dev_config['nametemplate'])) { + $xml_template = $data_path . '/templates/' . $dev_config['nametemplate']; + if (!file_exists($xml_template)) { + $xml_template = $data_path . '/templates/SEP0000000000.cnf.xml_79df_sip_template'; + } + } else { + $xml_template = $data_path . '/templates/SEP0000000000.cnf.xml_79df_sip_template'; + } + $xml_name = $store_path . '/' . $dev_id . '.cnf.xml'; + $sip_bind = $this->get_server_sip_bind($data_values); + + if (file_exists($xml_template)) { + $xml_work = simplexml_load_file($xml_template); + + foreach ($var_xml_general_vars as $key => $data) { + if (isset($xml_work->$key)) { + if ($data != 'null') { + $xml_work->$key = $data; + } else { + $node = $xml_work->$key; + unset($node[0][0]); + } + } + } + + foreach ($xml_work as $key => $data) { +// Set System global Values + if (!empty($var_xml_general_fields[$key])) { + $xml_work->$key = $data_values[$var_xml_general_fields[$key]]; + } +// Set section Values + $xml_node = $xml_work->$key; + switch ($key) { + case 'devicePool': + $xml_node = $xml_work->$key; + foreach ($xml_work->$key->children() as $dkey => $ddata) { + switch ($dkey) { + case 'dateTimeSetting': + $xnode = &$xml_node->$dkey; + $tz_id = $data_values['ntp_timezone']; + $TZdata = $data_values['ntp_timezone_id']; + if (empty($TZdata)) { + $TZdata = array('offset' => '0', 'daylight' => '', 'cisco_code' => 'Greenwich Standard Time'); + } +// $xnode->name = $tz_id; + $xnode->dateTemplate = $data_values['dateformat']; + $xnode->timeZone = $TZdata['cisco_code']; +// $xnode->timeZone = $tz_id.' Standard'.((empty($TZdata['daylight']))? '': '/'.$TZdata['daylight']).' Time'; + + if ($data_values['ntp_config_enabled'] == 'yes') { + $xnode->ntps->ntp->name = $data_values['ntp_server']; + $xnode->ntps->ntp->ntpMode = $data_values['ntp_server_mode']; + } else { + $xnode->ntps = null; + } + // Ntp Config + break; + /* case 'srstInfo': + if ($data_values['srst_Option'] == 'user') { + break; + } + $xnode = &$xml_node->$dkey; + $xnode->name = $data_values['srst_Name']; + $xnode->srstOption = $data_values['srst_Option']; + $xnode->userModifiable = $data_values['srst_userModifiable']; + $xnode->isSecure = $data_values['srst_isSecure']; + + $srst_fld = array('srst_ip' => array('ipAddr', 'port')); + // $srst_fld = array('srst_ip' => array('ipAddr','port') , 'srst_sip' => array('sipIpAddr','sipPort') ); + foreach ($srst_fld as $srst_pro => $srs_put) { + $srst_data = explode(';', $data_values[$srst_pro]); + $si = 1; + // $xnode['test'] = $srst_data[0]; + foreach ($srst_data as $value) { + $srs_val = explode('/', $value); + $nod = $srs_put[0] . $si; + $xnode->$nod = $srs_val[0]; + $nod = $srs_put[1] . $si; + $xnode->$nod = $srs_val[1]; + $si ++; + } + while ($si < 4) { + $nod = $srs_put[0] . $si; + $xnode->$nod = ''; + $nod = $srs_put[1] . $si; + $xnode->$nod = ''; + $si ++; + } + } + break; + case 'connectionMonitorDuration': + $xml_node->$dkey = strval(intval(intval($data_values['keepalive']) * 0.75)); + break; + */ + case 'callManagerGroup': + $xnode = &$xml_node->$dkey->members; + $ifc = 0; + foreach ($sip_bind as $bind_value) { + $xnode_obj = clone $xnode->member; + $xnode_obj['priority'] = $ifc; + $xnode_obj->callManager->name = $data_values['servername']; + $xnode_obj->callManager->ports->sipPort = $bind_value['port']; + $xnode_obj->callManager->ports->securedSipPort = $bind_value['tlsport']; + $xnode_obj->callManager->processNodeName = $bind_value['ip']; + if ($ifc === 0) { + $this->replaceSimpleXmlNode($xnode->member, $xnode_obj); + } else { + $this->appendSimpleXmlNode($xnode->member, $xnode_obj); + } + $ifc ++; + } + } + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + break; + case 'sipProfile': + $xml_node = $xml_work->$key; + foreach ($xml_work->$key->children() as $dkey => $ddata) { + if (!empty($var_xml_sipProfile[$dkey])) { + if (!empty($data_values[$var_xml_sipProfile[$dkey]])) { + $xml_node->$dkey = $data_values[$var_xml_sipProfile[$dkey]]; + } else { + $xml_node->$dkey = null; + } + } + switch ($dkey) { + case 'sipProxies': + $xnode = &$xml_node->$dkey; + $xnode->backupProxy = $sip_bind[0]['ip']; + $xnode->backupProxyPort = $sip_bind[0]['port']; + $xnode->emergencyProxy = $sip_bind[0]['ip']; + $xnode->emergencyProxyPort = $sip_bind[0]['port']; + $xnode->outboundProxy = $sip_bind[0]['ip']; + $xnode->outboundProxyPort = $sip_bind[0]['port']; + $xnode->registerWithProxy = "true"; + + break; + case 'sipLines': + $xnode = &$xml_node->$dkey; + $ifc = 0; + if (!empty($data_values['siplines'])) { + foreach ($data_values['siplines'] as $spkey => $spvalue) { + $xnode_obj = clone $xnode->line; + + $xnode_obj['button'] = $ifc + 1; + $xnode_obj['lineIndex'] = $ifc + 1; + //$xnode_obj->proxy = $data_values['bindaddr']; + if ($xnode_obj->proxy != 'USECALLMANAGER') { + $xnode_obj->proxy = $sip_bind[0]['ip']; + $xnode_obj->port = $sip_bind[0]['port']; + } + + foreach ($var_xml_sipline as $line_key => $line_val) { + $xnode_obj->$line_key = $spvalue[$line_val]; + } + + if ($ifc === 0) { + $this->replaceSimpleXmlNode($xnode->line, $xnode_obj); + } else { + $this->appendSimpleXmlNode($xnode->line, $xnode_obj); + } + $ifc ++; + } + } +// $xnode = &$xml_node->$dkey->members; + //$xnode = null; + break; + case 'softKeyFile': + case 'dialTemplate': // Доработать ! + $xml_ext_file = ''; + $templet_path = (($dkey == 'softKeyFile') ? $dev_config['tftp_softkey'] : $dev_config['tftp_dialplan']); + $tmp_key = ($dkey == 'softKeyFile') ? 'softkeyset' : '_dialrules'; + if (!empty($dev_config[$tmp_key])) { + $xml_ext_file = (($dkey == 'softKeyFile') ? 'softkey'.$dev_config[$tmp_key].'.xml' : $dev_config[$tmp_key].'.xml'); + } +// $xml_node->$dkey = $templet_path . '/' . $xml_ext_file.'---'.$dev_config[$tmp_key]; +// break; + if (empty($xml_ext_file) || !file_exists($templet_path . '/' . $xml_ext_file)) { + $xml_ext_file = (($dkey == 'softKeyFile') ? 'softkeydefault.xml' : 'dialplan.xml'); + } + if (file_exists($templet_path . '/' . $xml_ext_file)) { + $xml_node->$dkey = $xml_ext_file; + } else { + $xml_node->$dkey = null; + } + break; + } + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + break; + + case 'versionStamp': + $xml_work->$key = time(); + break; + case 'loadInformation': +// Set Path Image ???? + if (isset($dev_config["tftp_firmware"])) { + $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : ''; + } else { + $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["loadimage"] : ''; + } +// $xml_work->$key = $dev_config["loadimage"]; + if (!empty($dev_config['addon'])) { + $xnode = $xml_work->addChild('addOnModules'); + $ti = 1; + foreach ($dev_config['addon_info'] as $add_key => $add_val) { + $xnode_obj = $xnode->addChild('addOnModule'); + $xnode_obj->addAttribute('idx', $ti); + $xnode_obj->addChild('loadInformation', $add_val); + $ti ++; + } +// $this->appendSimpleXmlNode($xml_work , $xnode_obj); + } + break; + case 'commonProfile': + $xml_node->phonePassword = $data_values['dev_sshPassword']; + $xml_node->backgroundImageAccess = (($data_values['backgroundImageAccess'] == 'on') || ($data_values['backgroundImageAccess'] == 'true') ) ? 'true' : 'false'; + $xml_node->callLogBlfEnabled = $data_values['callLogBlfEnabled']; + break; + + case 'userLocale': + case 'networkLocaleInfo': + case 'networkLocale': + $hwlang = ''; + $lang = ''; + if (!empty($dev_config["_hwlang"])) { + $hwlang = explode(':', $dev_config["_hwlang"]); + } + if (($key == 'networkLocaleInfo') || ($key == 'networkLocale')) { + $lang = (empty($hwlang[0])) ? $data_values['netlang'] : $hwlang[0]; + } else { + $lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1]; + } + if (($lang != 'null') && (!empty($lang))) { + if ($key == 'networkLocale') { + $xml_work->$key = $lang; + } else { + if (isset($lang_info[$lang])) { + $xml_node->name = $lang_info[$lang]['locale']; + $xml_node->langCode = $lang_info[$lang]['code']; + if ($key == 'userLocale') { + $xml_node->winCharSet = $lang_info[$lang]['codepage']; + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + } + } + } else { + $xml_work->$key = ''; + } + break; +// Move all set to $var_xml_general_vars +// case 'mobility': +// case 'capfList': +// break; +// case 'phoneServices': +// break; +// $xml_work->$key = ''; + default: + break; + } + } + +// print_r($xml_work); + $xml_work->asXml($xml_name); // Save + } else { + die('Error Hardware template :' . $xml_template . ' not found'); + } + return time(); + } + + function save_DialPlan($confDir,$get_settings) { + $xmlstr = "\n"; + $xmlstr .= "".time()."\n"; + $dialFelds = array('match', 'timeout', 'rewrite', 'tone'); //str -to lo ! + + $hdr_prefix = 'sccp_dial_'; + $hdr_arprefix = 'sccp_dial-ar_'; + $save_data = array(); + $integer_msg = _("%s must be a non-negative integer"); + $errors = array(); + foreach ($get_settings[$hdr_arprefix . 'dialtemplate'] as $key => $value) { + $xmlstr .= ''Access error'.$name); + } + } + return array(); + } else { + return array('error'=>'Invalid softkey Name'.$name); + } + } + $errors = array(); + $xmlstr = "\n"; + $xmlstr .= "".time()."\n"; +// $xmlstr .= "\n"; + $typeSoft = $confDir["tftp_templates"].'/SIPTypeSoftKey.xml_template'; + $read_soft = ""; + if(file_exists($typeSoft)){ + $f_read = fopen($typeSoft,'r'); + while (!feof($f_read)) { + $read_soft .= fread($f_read, 8192); + } + fclose($f_read); + } + $xmlstr .= $read_soft; +// $xmlstr .= $read_soft."\n\n"; + $xmlstr .= " \n"; + foreach ($config[$name] as $key => $value) { + $xmlstr .=' '."\n"; + foreach (explode(",",$value) as $keyvalue ) { + $xmlstr .= ' '."\n"; + } + $xmlstr .=" \n"; + } + $xmlstr .= " \n"; + + $xmlstr .= ''; + if (empty($errors)) { +// $put_file = str_replace(array("\n", "\r", "\t", "/", "\\", ".", ","), '', $put_file); + $file = $confDir["tftp_softkey"] . '/softkey' . $name . '.xml'; + file_put_contents($file, $xmlstr); + } + + return $errors; + + } + private function replaceSimpleXmlNode($xml, $element = SimpleXMLElement) { $dom = dom_import_simplexml($xml); $import = $dom->ownerDocument->importNode( diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 81640b4..735a7bb 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -65,6 +65,9 @@ $(document).ready(function () { if ($('.fpbx-submit').data('id') == "hw_edit") { snd_command = 'save_hardware'; } + if ($('.fpbx-submit').data('id') == "hw_sedit") { + snd_command = 'save_sip_hardware'; + } if ($('.fpbx-submit').data('id') == "ruser_edit") { snd_command = 'save_ruser'; } @@ -103,6 +106,9 @@ $(document).ready(function () { if ($('.fpbx-submit').data('id') == "hw_edit") { snd_command = 'save_hardware'; } + if ($('.fpbx-submit').data('id') == "hw_sedit") { + snd_command = 'save_sip_hardware'; + } if ($('.fpbx-submit').data('id') == "ruser_edit") { snd_command = 'save_ruser'; } diff --git a/conf/SEP0000000000.cnf.xml_791x_sip_template b/conf/SEP0000000000.cnf.xml_791x_sip_template new file mode 100644 index 0000000..a8a5edf --- /dev/null +++ b/conf/SEP0000000000.cnf.xml_791x_sip_template @@ -0,0 +1,300 @@ + + true + SIP + + + D/M/Y + + + + + unicast + + + + + + + + + 5060 + 5061 + + + + + + + + + + true + + + true + x-cisco-serviceuri-cfwdall + x-cisco-serviceuri-pickup + x-cisco-serviceuri-opickup + x-cisco-serviceuri-gpickup + x-cisco-serviceuri-meetme + x-cisco-serviceuri-abbrdial + false + 1 + true + true + 3 + 3 + 0 + true + false + 1 + + + 6 + 10 + 180 + 3600 + 5 + 120 + 120 + 5 + 500 + 4000 + 70 + true + Phone + + 1 + false + true + true + false + none + 101 + 3 + avt + false + false + 0 + + 0 + true + 15000 + 10 + false + 16384 + 32766 + false + false + + + + 9 + + USECALLMANAGER + 5060 + + + + 0 + + 3 + + + + false + 3 + 0 + + 4 + 5 + + true + true + false + true + + 5 + 4 + + + + 5060 + 184 + 0 + + + + 1 + + + + true + 2 + + + + false + false + false + true + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 1 + 1 + 0,1,2 + 1 + 1 + 1 + 0,1 + 0 + 0 + 0 + 1 + 1 + 10 + 0 + 0 + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 1 + + 0 + 0 + 1 + 2 + 2 + 1 + 1 + 1,7 + 08:00 + 10:00 + 00:10 + 1 + 0 + 1,7 + 08:00 + 10:00 + 00:10 + 1 + 0 + 100 + 50 + + 5 + 0 + + + 1 + 0 + 1 + 0 + true + 0 + 2 + + 0 + 0 + + 0 + 0 + 0 + 1 + 1 + 1 + 1 + + d902ed5a-c1e5-4233-b1d6-a960d53d1c3a + + + 2 + + Missed Calls + Application:Cisco/MissedCalls + + + + + Received Calls + Application:Cisco/ReceivedCalls + + + + + Placed Calls + Application:Cisco/PlacedCalls + + + + + Voicemail + Application:Cisco/Voicemail + + + + + + + 1 + + + utf-8 + + + + + + + 1 + 0 + + + + + + + + + + + + + + 1 + 3600 + 1 + true + 0 + 0 + 1 + 5 + 1 + 0 + 0 + 0 + + + false + + + diff --git a/conf/SEP0000000000.cnf.xml_79df_sip_template b/conf/SEP0000000000.cnf.xml_79df_sip_template new file mode 100644 index 0000000..babaa5c --- /dev/null +++ b/conf/SEP0000000000.cnf.xml_79df_sip_template @@ -0,0 +1,255 @@ + + true + SIP + + + D/M/Y + + + + + unicast + + + + + + + + + 5060 + 5061 + + + + + + + + + + true + $ASTERISK + 5060 + $ASTERISK + 5060 + $ASTERISK + 5060 + + + true + x-cisco-serviceuri-cfwdall + x-cisco-serviceuri-pickup + x-cisco-serviceuri-opickup + x-cisco-serviceuri-gpickup + x-cisco-serviceuri-meetme + x-cisco-serviceuri-abbrdial + false + 1 + true + true + 3 + 3 + 0 + true + false + + + 6 + 10 + 180 + 3600 + 5 + 120 + 120 + 5 + 500 + 4000 + 70 + true + Phone + + 1 + false + true + true + false + g711alaw + 101 + 3 + avt + false + false + 0 + + 0 + true + 15000 + 10 + false + 16384 + 32766 + false + false + + + + 9 + + USECALLMANAGER + 5060 + + + + 0 + + 3 + + + + false + 3 + 0 + + 4 + 5 + + true + true + false + true + + 5 + 4 + + + + 5060 + 184 + 0 + + + + 1 + + + true + 2 + + + false + false + false + true + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + 1 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 1 + 1 + 1,7 + 08:00 + 10:00 + 00:10 + 1 + 0 + 0 + 100 + 50 + + 5 + 0 + + 1 + 0 + 1 + 0 + + d902ed5a-c1e5-4233-b1d6-a960d53d1c3a + + + 2 + + Missed Calls + Application:Cisco/MissedCalls + + + + + Received Calls + Application:Cisco/ReceivedCalls + + + + + Placed Calls + Application:Cisco/PlacedCalls + + + + + Voicemail + Application:Cisco/Voicemail + + + + + + + 1 + + 10 + utf-8 + + + + + 10 + + 1 + 0 + + + + + + + + + + + + + + 1 + 3600 + 1 + true + 0 + 0 + 1 + 5 + 1 + 0 + 0 + 0 + + + false + + + diff --git a/conf/SIPDefaultSoftKey.xml_template b/conf/SIPDefaultSoftKey.xml_template new file mode 100644 index 0000000..22c35de --- /dev/null +++ b/conf/SIPDefaultSoftKey.xml_template @@ -0,0 +1,201 @@ + + 0200d4f8-e302-4315-b91e-9490e0b37fc5 + + + 0 + 0 + 0 + + + 1 + 1 + 301 + + + 2 + 2 + 302 + + + 3 + 3 + 303 + + + 4 + 4 + 304 + + + 5 + 5 + 305 + + + 8 + 8 + 308 + + + 9 + 9 + 309 + + + 10 + 10 + 310 + + + 11 + 11 + 311 + + + 13 + 13 + 313 + + + 14 + 14 + 314 + + + 15 + 15 + 315 + + + 16 + 16 + 316 + + + 17 + 17 + 317 + + + 18 + 18 + 318 + + + 57 + 19 + 319 + + + 63 + 69 + 369 + + + 65 + 20 + 320 + + + 75 + 22 + 322 + + + 76 + 27 + 327 + + + 78 + 29 + 329 + + + 79 + 30 + 330 + + + 80 + 31 + 331 + + + 91 + 34 + 334 + + + 92 + 35 + 335 + + + 7740 + 71 + 371 + + + 7747 + 74 + 374 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/SIPTypeSoftKey.xml_template b/conf/SIPTypeSoftKey.xml_template new file mode 100644 index 0000000..c330246 --- /dev/null +++ b/conf/SIPTypeSoftKey.xml_template @@ -0,0 +1,142 @@ + + + 0 + 0 + 0 + + + 1 + 1 + 301 + + + 2 + 2 + 302 + + + 3 + 3 + 303 + + + 4 + 4 + 304 + + + 5 + 5 + 305 + + + 8 + 8 + 308 + + + 9 + 9 + 309 + + + 10 + 10 + 310 + + + 11 + 11 + 311 + + + 13 + 13 + 313 + + + 14 + 14 + 314 + + + 15 + 15 + 315 + + + 16 + 16 + 316 + + + 17 + 17 + 317 + + + 18 + 18 + 318 + + + 57 + 19 + 319 + + + 63 + 69 + 369 + + + 65 + 20 + 320 + + + 75 + 22 + 322 + + + 76 + 27 + 327 + + + 78 + 29 + 329 + + + 79 + 30 + 330 + + + 80 + 31 + 331 + + + 91 + 34 + 334 + + + 92 + 35 + 335 + + + 7740 + 71 + 371 + + + 7747 + 74 + 374 + + diff --git a/conf/dialplan.xml_template b/conf/dialplan.xml_template new file mode 100644 index 0000000..e7a9ca4 --- /dev/null +++ b/conf/dialplan.xml_template @@ -0,0 +1,8 @@ + + e68d54c1-0354-4b1a-aca4-adffc4b7de2f +