diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 1dc2692..53c07f7 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -16,16 +16,16 @@ * + Model Information * + Device Right Menu - - - - + + + + * + Dial Templates + Configuration * + Dial Templates in Global Configuration ( Enabled / Disabled ; default template ) * ? Dial Templates - Howto IT Include in XML.Config ??????? * - Dial Templates in device Configuration ( Enabled / inheret / Disabled ; template ) - + * - WiFi Config (Bulk Deployment Utility for Cisco 7921, 7925, 7926)????? * + Change internal use Field to _Field (new feature in chan_sccp (added for Sccp_manager)) * + Delete phone XML @@ -76,7 +76,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // const General - teplet.xml = '20'; // const General - system_path = '2'; // const General - don't store = '99'; - // private $SCCP_LANG_DICTIONARY = 'SCCP-dictionary.xml'; // CISCO LANG file search in /tftp-path private $SCCP_LANG_DICTIONARY = 'be-sccp.jar'; // CISCO LANG file search in /tftp-path private $pagedata = null; @@ -84,14 +83,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private $tftpLang = array(); private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! private $val_null = 'NONE'; /// REPLACE to null Field - public $sccp_model_list = array(); private $cnf_wr = null; public $sccppath = array(); public $sccpvalues = array(); public $sccp_conf_init = array(); public $xml_data; - + public function __construct($freepbx = null) { if ($freepbx == null) { throw new Exception("Not given a FreePBX Object"); @@ -104,25 +102,25 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->v = new \Respect\Validation\Validator(); $driverNamespace = "\\FreePBX\\Modules\\Sccp_manager"; - if(class_exists($driverNamespace,false)) { - foreach(glob(__DIR__."/Sccp_manager.inc/*.class.php") as $driver) { - if(preg_match("/\/([a-z1-9]*)\.class\.php$/i",$driver,$matches)) { + if (class_exists($driverNamespace, false)) { + foreach (glob(__DIR__ . "/Sccp_manager.inc/*.class.php") as $driver) { + if (preg_match("/\/([a-z1-9]*)\.class\.php$/i", $driver, $matches)) { $name = $matches[1]; $class = $driverNamespace . "\\" . $name; - if(!class_exists($class,false)) { + if (!class_exists($class, false)) { include($driver); } - if(class_exists($class,false)) { + if (class_exists($class, false)) { $this->$name = new $class(); } else { - throw new \Exception("Invalid Class inside in the include folder".print_r($freepbx)); + throw new \Exception("Invalid Class inside in the include folder" . print_r($freepbx)); } - } + } } } else { return; } - + $this->getSccpSettingFromDB(); // Overwrite Exist // $this->getSccpSetingINI(false); // get from sccep.ini @@ -132,19 +130,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // Load Advanced Form Constuctor Data - $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v'.$this->sccpvalues['sccp_compatible']['data']; + $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v' . $this->sccpvalues['sccp_compatible']['data']; if (!file_exists($xml_vars)) { $xml_vars = __DIR__ . '/conf/sccpgeneral.xml'; } if (file_exists($xml_vars)) { $this->xml_data = simplexml_load_file($xml_vars); $this->initVarfromXml(); // Overwrite Exist - } + } } /* * Generate Input elements in Html Code from sccpgeneral.xml */ + public function ShowGroup($grup_name, $heder_show, $form_prefix = 'sccp', $form_values = null) { $htmlret = ""; if (empty($form_values)) { @@ -167,6 +166,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { /* * Load config vars from base array */ + public function initVarfromDefs() { foreach ($this->extconfigs->getextConfig('sccpDefaults') as $key => $value) { if (empty($this->sccpvalues[$key])) { @@ -178,6 +178,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { /* * Load config vars from xml */ + public function initVarfromXml() { if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group') as $item) { @@ -232,26 +233,31 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } /* unused */ + public function doConfigPageInit($page) { $this->doGeneralPost(); } /* unused */ + public function install() { } /* unused */ + public function uninstall() { } /* unused */ + public function backup() { } /* unused */ + public function restore($backup) { } @@ -513,7 +519,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public function ajaxRequest($req, &$setting) { switch ($req) { - case 'savesettings': /* !TODO!: mixing snake case and camel case, chooose one :-) */ + case 'savesettings': /* !TODO!: mixing snake case and camel case, chooose one :-) */ case "save_hardware": case "save_dp_template": case "delete_hardware": @@ -553,7 +559,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->save_submit($request); $this->sccp_db_save_setting(); // $this->sccp_create_sccp_init(); - + $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')); $msg = 'Config Saved: ' . $res['Response'] . '. Info :' . $res['data']; // needreload(); @@ -567,7 +573,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->save_hw_phone($request); break; - case "save_dp_template": /* !TODO!: dialplan templates should be removed (only required for very old devices (like ATA) */ + case "save_dp_template": /* !TODO!: dialplan templates should be removed (only required for very old devices (like ATA) */ $res = $this->save_DialPlant($request); if (empty($res)) { return array('status' => true, 'search' => '?display=sccp_adv', 'hash' => 'sccpdialplan'); @@ -579,7 +585,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!empty($request['dialplan'])) { $get_file = $request['dialplan']; $res = $this->del_DialPlant($get_file); - return array('status' => true, 'message' => 'Dial Template has been deleted ! ', 'table_reload'=>true); + return array('status' => true, 'message' => 'Dial Template has been deleted ! ', 'table_reload' => true); } else { return array('status' => false, 'message' => print_r($res)); } @@ -630,14 +636,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dev_list = $this->srvinterface->sccp_get_active_device(); foreach ($dev_list as $key => $data) { if ($cmd_id == 'reset_token') { - if (($data['token'] == 'Rej') || ($data['status'] == 'Token ') ) { + if (($data['token'] == 'Rej') || ($data['status'] == 'Token ')) { $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $key)); - $msg .= 'Send Token reset to :'. $key .' '; + $msg .= 'Send Token reset to :' . $key . ' '; } } else { $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $key)); $msg .= $res['Response'] . ' ' . $res['data'] . ' '; - } + } // $msg .= $res['Response'] . ' ' . $res['data'] . ' '; } } @@ -678,7 +684,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $save_settings = array(); if (!empty($request['model'])) { foreach ($request['model'] as $idv) { - $this->dbinterface ->sccp_save_db('sccpdevmodel', array('model' => $idv, 'enabled' => $model_set), 'update', "model"); + $this->dbinterface->sccp_save_db('sccpdevmodel', array('model' => $idv, 'enabled' => $model_set), 'update', "model"); } } return array('status' => true, 'table_reload' => true); @@ -772,7 +778,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dev_id['status'] = $staus[$id_name]['status']; $dev_id['address'] = $staus[$id_name]['address']; $dev_id['new_hw'] = 'N'; - $staus[$id_name]['news'] ='N'; + $staus[$id_name]['news'] = 'N'; } else { $dev_id['description'] = '- -'; $dev_id['status'] = 'not connected'; @@ -788,30 +794,28 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dev_data = $this->srvinterface->sccp_getdevice_info($id_name); if (!empty($dev_data['SCCP_Vendor']['model_id'])) { // $dev_data = $this->sccp_getdevice_info($id_name); - $dev_addon= $dev_data['SCCP_Vendor']['model_addon']; + $dev_addon = $dev_data['SCCP_Vendor']['model_addon']; if (empty($dev_addon)) { $dev_addon = null; } - $dev_schema = $this-> getSccp_model_information('byciscoid', false, "all", array('model' =>$dev_data['SCCP_Vendor']['model_id'])); - $result[] = array('name' => $id_name, 'mac' => $id_name, 'button' => '---', 'type' => $dev_schema[0]['model'], 'new_hw' => 'Y', - 'description' => '*NEW* '.$dev_ids['descr'], 'status' => '*NEW* '.$dev_ids['status'], 'address' => $dev_ids['address'], + $dev_schema = $this->getSccp_model_information('byciscoid', false, "all", array('model' => $dev_data['SCCP_Vendor']['model_id'])); + $result[] = array('name' => $id_name, 'mac' => $id_name, 'button' => '---', 'type' => $dev_schema[0]['model'], 'new_hw' => 'Y', + 'description' => '*NEW* ' . $dev_ids['descr'], 'status' => '*NEW* ' . $dev_ids['status'], 'address' => $dev_ids['address'], 'addon' => $dev_addon); } } } - } return $result; break; - + case "getDialTemplate": - $result = $this->get_DP_list(); /* !TODO!: please use DialPlan instead of DP */ + $result = $this->get_DP_list(); /* !TODO!: please use DialPlan instead of DP */ if (empty($result)) { $result = array(); } return $result; break; - } } @@ -826,6 +830,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * * Save Hardware Device Information to Db + ???? Create / update XML Profile * */ + function save_hw_phone($get_settings, $validateonly = false) { $hdr_prefix = 'sccp_hw_'; $hdr_arprefix = 'sccp_hw-ar_'; @@ -877,10 +882,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } if (!empty($get_settings[$hdr_arprefix . $key])) { $arr_data = ''; - foreach ($get_settings[$hdr_arprefix. $key] as $vkey => $vval) { + foreach ($get_settings[$hdr_arprefix . $key] as $vkey => $vval) { $tmp_data = ''; foreach ($vval as $vkey => $vval) { - $tmp_data .= $vval . '/'; + $tmp_data .= $vval . '/'; } if (strlen($tmp_data) > 2) { $arr_data .= substr($tmp_data, 0, -1) . ';'; @@ -889,7 +894,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $arr_data = substr($arr_data, 0, -1); $value = $arr_data; } - } if (!empty($value)) { $save_settings[$key] = $value; @@ -902,16 +906,16 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $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--) { + for ($it = $max_btn; $it >= 0; $it--) { if (!empty($get_settings['button' . $it . '_type'])) { $last_btn = $it; $btn_t = $get_settings['button' . $it . '_type']; - if ($btn_t != 'empty'){ + if ($btn_t != 'empty') { break; } } } - + for ($it = 0; $it <= $last_btn; $it++) { if (!empty($get_settings['button' . $it . '_type'])) { $btn_t = $get_settings['button' . $it . '_type']; @@ -938,7 +942,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'monitor': $btn_t = 'speeddial'; $btn_opt = (string) $get_settings['button' . $it . '_line']; - $db_res = $this-> dbinterface->get_db_SccpTableData('SccpExtension', array('name' => $btn_opt)); + $db_res = $this->dbinterface->get_db_SccpTableData('SccpExtension', array('name' => $btn_opt)); $btn_n = $db_res[0]['label']; $btn_opt .= ',' . $btn_opt . $this->hint_context; break; @@ -968,9 +972,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'adv.line': $btn_t = 'line'; $btn_n = (string) $get_settings['button' . $it . '_line']; - $btn_n .= '@'.(string)$get_settings['button' . $it . '_advline']; + $btn_n .= '@' . (string) $get_settings['button' . $it . '_advline']; $btn_opt = (string) $get_settings['button' . $it . '_advopt']; - + break; case 'line': case 'silent': @@ -998,7 +1002,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } // Sace Buttons config - $this->dbinterface ->sccp_save_db("sccpbuttons", $save_buttons, $update_hw, '', $name_dev); + $this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, $update_hw, '', $name_dev); // Create Device XML $this->sccp_create_device_XML($name_dev); @@ -1065,37 +1069,36 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'type' => $this->sccpvalues['allow']['type']); } break; - + case 'sccp_ntp_timezone': - $tz_id = $value; - $TZdata = $this-> extconfigs->getextConfig('sccp_timezone',$tz_id); - if (!empty($TZdata)){ - $save_settings[] = array('keyword' => 'tzoffset', 'data' => ($TZdata['offset']/60), + $tz_id = $value; + $TZdata = $this->extconfigs->getextConfig('sccp_timezone', $tz_id); + if (!empty($TZdata)) { + $save_settings[] = array('keyword' => 'tzoffset', 'data' => ($TZdata['offset'] / 60), 'seq' => '98', 'type' => '2'); - } + } break; } } if (!empty($save_settings)) { $this->sccp_db_save_setting($save_settings); - $this->getSccpSettingFromDB(); + $this->getSccpSettingFromDB(); // $this->sccp_create_sccp_init(); } $this->sccp_create_sccp_init(); // Rewrite Config. $save_settings[] = array('status' => true); return $save_settings; } - + public function getSccpSettingFromDB() { $raw_data = $this->dbinterface->get_db_SccpSetting(); foreach ($raw_data as $var) { $this->sccpvalues[$var['keyword']] = array('keyword' => $var['keyword'], 'data' => $var['data'], 'seq' => $var['seq'], 'type' => $var['type']); } return; - - } - + } + function sccp_get_keysetdata($name) { if ($name == 'default') { @@ -1126,7 +1129,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $file_context = $keysetData['name']; if ($file_context != 'default') { $confDir = $amp_conf["ASTETCDIR"]; - if (strlen($confDir) < 1) { /* !TODO!: Can this actually happen, or does it mean amp_conf array is empty ? */ + if (strlen($confDir) < 1) { /* !TODO!: Can this actually happen, or does it mean amp_conf array is empty ? */ $confDir = "/etc/asterisk"; } $inputfile = "$confDir/sccp.conf"; @@ -1406,6 +1409,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { /* * Check tftp/xml file path and permissions */ + private function init_tftp_lang_path() { $dir = $this->sccppath["tftp_path"]; foreach ($this->extconfigs->getextConfig('sccp_lang') as $lang_key => $lang_value) { @@ -1422,10 +1426,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Check file paths and permissions */ /* !TODO!: This function is getting a little big. Might be possible to sperate tftp work into it's own file/class */ + function init_sccp_path() { global $db; - global $amp_conf; - + global $amp_conf; + $confDir = $amp_conf["ASTETCDIR"]; if (empty($this->sccppath["asterisk"])) { if (strlen($confDir) < 1) { @@ -1446,8 +1451,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } if (empty($this->sccppath["tftp_path"])) { - if (file_exists($this->extconfigs->getextConfig('sccpDefaults',"tftp_path"))) { - $this->sccppath["tftp_path"] = $this->extconfigs->getextConfig('sccpDefaults',"tftp_path"); + if (file_exists($this->extconfigs->getextConfig('sccpDefaults', "tftp_path"))) { + $this->sccppath["tftp_path"] = $this->extconfigs->getextConfig('sccpDefaults', "tftp_path"); } } } @@ -1480,7 +1485,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } - $this->sccpvalues['sccp_compatible'] = array('keyword' => 'compatible', 'data' => $this->srvinterface->get_compatible_sccp(), 'type' => '1', 'seq' => '99'); + $this->sccpvalues['sccp_compatible'] = array('keyword' => 'compatible', 'data' => $this->srvinterface->get_compatible_sccp(), 'type' => '1', 'seq' => '99'); // $this->sccpvalues['sccp_compatible'] = '11'; $driver = $this->FreePBX->Core->getAllDriversInfo(); @@ -1489,17 +1494,17 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $driver_replace = 'yes'; } else { if (empty($driver['sccp']['Version'])) { - $driver_replace = 'yes'; + $driver_replace = 'yes'; } else { - if ($driver['sccp']['Version'] != $this->sccp_driver_ver){ - $driver_replace = 'yes'; + if ($driver['sccp']['Version'] != $this->sccp_driver_ver) { + $driver_replace = 'yes'; } } } $dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php'; - if (!file_exists($dst) || $driver_replace =='yes') { - $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst).'.v'.$this->sccpvalues['sccp_compatible']['data']; + if (!file_exists($dst) || $driver_replace == 'yes') { + $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst) . '.v' . $this->sccpvalues['sccp_compatible']['data']; if (file_exists($src_path)) { copy($src_path, $dst); } else { @@ -1507,9 +1512,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { copy($src_path, $dst); } } else { - $driver = $this->FreePBX->Core->getAllDriversInfo(); - - + $driver = $this->FreePBX->Core->getAllDriversInfo(); } if (!file_exists($this->sccppath["sccp_conf"])) { // System re Config @@ -1538,35 +1541,36 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ /* !TODO!: please use DialPlan instead of DP */ /* !TODO!: I think Dialplan stuff can be removed or at least commented out */ + function get_DP_list() { - $dir = $this->sccppath["tftp_DP"].'/*.xml'; - $base_len = strlen($this->sccppath["tftp_DP"])+ 1; - $res = glob($dir); + $dir = $this->sccppath["tftp_DP"] . '/*.xml'; + $base_len = strlen($this->sccppath["tftp_DP"]) + 1; + $res = glob($dir); $dp_list = array(); foreach ($res as $key => $value) { - $res[$key] = array('id'=> substr($value,$base_len,-4), 'file' => substr($value,$base_len)); + $res[$key] = array('id' => substr($value, $base_len, -4), 'file' => substr($value, $base_len)); } - + return $res; } function get_DialPlan($get_file) { - $file = $this->sccppath["tftp_DP"].'/'.$get_file.'.xml'; + $file = $this->sccppath["tftp_DP"] . '/' . $get_file . '.xml'; if (file_exists($file)) { // $load_xml_data = simplexml_load_file($file); - $fileContents= file_get_contents($file); + $fileContents = file_get_contents($file); $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); $fileContents = trim(str_replace('"', "'", $fileContents)); $fileContents = strtolower($fileContents); - $res = (array) simplexml_load_string($fileContents); + $res = (array) simplexml_load_string($fileContents); } return $res; } function del_DialPlan($get_file) { if (!empty($get_file)) { - $file = $this->sccppath["tftp_DP"].'/'.$get_file.'.xml'; + $file = $this->sccppath["tftp_DP"] . '/' . $get_file . '.xml'; if (file_exists($file)) { $res = unlink($file); } @@ -1574,59 +1578,61 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $res; } - function save_DialPlan($get_settings) { $xmlstr = "\n"; - $dialFelds = array('match','timeout','rewrite','tone'); //str -to lo ! + $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 .= ' $value) { + $xmlstr .= 'sccppath["tftp_DP"].'/'.$put_file.'.xml'; + $put_file = str_replace(array("\n", "\r", "\t", "/", "\\", ".", ","), '', $put_file); + $file = $this->sccppath["tftp_DP"] . '/' . $put_file . '.xml'; file_put_contents($file, $xmlstr); } - + return $errors; } - + /* * Save Config Value to mysql DB * sccp_db_save_setting(empty) - Save All settings from $sccpvalues */ - private function sccp_db_save_setting($save_value = array()) { global $db; global $amp_conf; @@ -1652,7 +1658,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ function sccp_create_tftp_XML() { - + foreach ($this->sccpvalues as $key => $value) { $data_value[$key] = $value['data']; } @@ -1661,99 +1667,99 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (empty($model_information)) $model_information = $this->getSccp_model_information($get = "all", $validate = false); // Get All - - $lang_data = $this->extconfigs->getextConfig('sccp_lang'); - - $this->xmlinterface->create_default_XML($this->sccppath["tftp_path"], $data_value, $model_information, $lang_data); - -/* - $def_xml_fields = array('authenticationURL', 'informationURL', 'messagesURL', 'servicesURL', 'directoryURL', 'proxyServerURL', 'idleTimeout', 'idleURL'); - $def_xml_locale = array('userLocale', 'networkLocaleInfo', 'networkLocale'); - $xml_name = $this->sccppath["tftp_path"] . '/XMLDefault.cnf.xml'; - $xml_template = $this->sccppath["tftp_templates"] . '/XMLDefault.cnf.xml_template'; - if (file_exists($xml_template)) { - $xml_work = simplexml_load_file($xml_template); + $lang_data = $this->extconfigs->getextConfig('sccp_lang'); + + $this->xmlinterface->create_default_XML($this->sccppath["tftp_path"], $data_value, $model_information, $lang_data); + + /* + $def_xml_fields = array('authenticationURL', 'informationURL', 'messagesURL', 'servicesURL', 'directoryURL', 'proxyServerURL', 'idleTimeout', 'idleURL'); + $def_xml_locale = array('userLocale', 'networkLocaleInfo', 'networkLocale'); + $xml_name = $this->sccppath["tftp_path"] . '/XMLDefault.cnf.xml'; + $xml_template = $this->sccppath["tftp_templates"] . '/XMLDefault.cnf.xml_template'; + + if (file_exists($xml_template)) { + $xml_work = simplexml_load_file($xml_template); - $xnode = &$xml_work->callManagerGroup->members; - if ($this->sccpvalues['bindaddr']['data'] == '0.0.0.0') { - $ifc = 0; - foreach ($this->getIP_information() as $value) { - if (!empty($value[0])) { - if (!in_array($value[0], array('0.0.0.0', '127.0.0.1'), true)) { - $xnode_obj = clone $xnode->member; - $xnode_obj['priority'] = $ifc; - //$xnode_obj = &$xnode -> member -> callManager; - $xnode_obj->callManager->name = $this->sccpvalues['servername']['data']; - $xnode_obj->callManager->ports->ethernetPhonePort = $this->sccpvalues['port']['data']; - $xnode_obj->callManager->processNodeName = $value[0]; - 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 = $this->sccpvalues['servername']['data']; - $xnode_obj->ports->ethernetPhonePort = $this->sccpvalues['port']['data']; - $xnode_obj->processNodeName = $this->sccpvalues['bindaddr']['data']; - } - $this->replaceSimpleXmlNode($xml_work->callManagerGroup->members, $xnode); + $xnode = &$xml_work->callManagerGroup->members; + if ($this->sccpvalues['bindaddr']['data'] == '0.0.0.0') { + $ifc = 0; + foreach ($this->getIP_information() as $value) { + if (!empty($value[0])) { + if (!in_array($value[0], array('0.0.0.0', '127.0.0.1'), true)) { + $xnode_obj = clone $xnode->member; + $xnode_obj['priority'] = $ifc; + //$xnode_obj = &$xnode -> member -> callManager; + $xnode_obj->callManager->name = $this->sccpvalues['servername']['data']; + $xnode_obj->callManager->ports->ethernetPhonePort = $this->sccpvalues['port']['data']; + $xnode_obj->callManager->processNodeName = $value[0]; + 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 = $this->sccpvalues['servername']['data']; + $xnode_obj->ports->ethernetPhonePort = $this->sccpvalues['port']['data']; + $xnode_obj->processNodeName = $this->sccpvalues['bindaddr']['data']; + } + $this->replaceSimpleXmlNode($xml_work->callManagerGroup->members, $xnode); - foreach ($def_xml_fields as $value) { - if (!empty($this->sccpvalues['dev_' . $value])) { - $xml_work->$value = trim($this->sccpvalues['dev_' . $value]['data']); - } - } - foreach ($def_xml_locale as $key) { - if (!empty($xml_work->$key)) { - $xnode = &$xml_work->$key; - switch ($key) { - case 'userLocale': - case 'networkLocaleInfo': - if ($key == 'networkLocaleInfo') { - $lang = $this->sccpvalues['netlang']['data']; - } else { - $lang = $this->sccpvalues['devlang']['data']; - } -// configs->getConfig('sccp_lang') - $lang_arr = $this->extconfigs->getextConfig('sccp_lang',$lang); - $xnode->name = $lang_arr['locale']; - $xnode->langCode = $$lang_arr['code']; -// $this -> replaceSimpleXmlNode($xml_work->$key,$xnode); - break; - case 'networkLocale': - $lang_arr = $this->extconfigs->getextConfig('sccp_lang',$this->sccpvalues['netlang']['data']); - $xnode = $lang_arr['language']; - break; - } - //$this-> replaceSimpleXmlNode($xml_work->$value, $xnode ); - } - } + foreach ($def_xml_fields as $value) { + if (!empty($this->sccpvalues['dev_' . $value])) { + $xml_work->$value = trim($this->sccpvalues['dev_' . $value]['data']); + } + } + foreach ($def_xml_locale as $key) { + if (!empty($xml_work->$key)) { + $xnode = &$xml_work->$key; + switch ($key) { + case 'userLocale': + case 'networkLocaleInfo': + if ($key == 'networkLocaleInfo') { + $lang = $this->sccpvalues['netlang']['data']; + } else { + $lang = $this->sccpvalues['devlang']['data']; + } + // configs->getConfig('sccp_lang') + $lang_arr = $this->extconfigs->getextConfig('sccp_lang',$lang); + $xnode->name = $lang_arr['locale']; + $xnode->langCode = $$lang_arr['code']; + // $this -> replaceSimpleXmlNode($xml_work->$key,$xnode); + break; + case 'networkLocale': + $lang_arr = $this->extconfigs->getextConfig('sccp_lang',$this->sccpvalues['netlang']['data']); + $xnode = $lang_arr['language']; + break; + } + //$this-> replaceSimpleXmlNode($xml_work->$value, $xnode ); + } + } - $msro = $this->getSccp_model_information($get = "enabled", $validate = false); // Get Active - if (empty($msro)) - $msro = $this->getSccp_model_information($get = "all", $validate = false); // Get All - foreach ($msro as $var) { - if (!empty($var['loadinformationid'])) { - $node = $xml_work->addChild($var['loadinformationid'], $var['loadimage']); - $node->addAttribute('model', $var['vendor'] . ' ' . $var['model']); - } - } - $xml_work->asXml($xml_name); // Save XMLDefault1.cnf.xml - // - // - // -// die(print_r($xml_work)); - } - * - */ + $msro = $this->getSccp_model_information($get = "enabled", $validate = false); // Get Active + if (empty($msro)) + $msro = $this->getSccp_model_information($get = "all", $validate = false); // Get All + foreach ($msro as $var) { + if (!empty($var['loadinformationid'])) { + $node = $xml_work->addChild($var['loadinformationid'], $var['loadimage']); + $node->addAttribute('model', $var['vendor'] . ' ' . $var['model']); + } + } + $xml_work->asXml($xml_name); // Save XMLDefault1.cnf.xml + // + // + // + // die(print_r($xml_work)); + } + * + */ } /* @@ -1761,7 +1767,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ function sccp_create_device_XML($dev_id = '') { - + if (empty($dev_id)) { return false; } @@ -1771,7 +1777,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 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['ntp_timezone_id'] = $this->extconfigs->getextConfig('sccp_timezone', $data_value['ntp_timezone']); $data_value['server_if_list'] = $this->getIP_information(); $dev_config['addon_info'] = array(); @@ -1782,234 +1788,234 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dev_config['addon_info'][$key] = $hw_data[0]['loadimage']; } } - $lang_data = $this->extconfigs->getextConfig('sccp_lang'); - + $lang_data = $this->extconfigs->getextConfig('sccp_lang'); + return $this->xmlinterface->create_SEP_XML($this->sccppath["tftp_path"], $data_value, $dev_config, $dev_id, $lang_data); - - - /* - - $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' - ); - $var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList'=> 'null', 'mobility' => 'null', - 'phoneServices' =>'null', 'certHash' =>'null', - 'deviceSecurityMode' => '1'); - - if (empty($dev_id)) { - return false; - } - $var_hw_config = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id)); - if (empty($var_hw_config)) { - return false; - } - if (!empty($var_hw_config['nametemplate'])) { - $xml_template = $this->sccppath["tftp_templates"] . '/' . $var_hw_config['nametemplate']; - } else { - $xml_template = $this->sccppath["tftp_templates"] . '/SEP0000000000.cnf.xml_79df_template'; - } - $xml_name = $this->sccppath["tftp_path"] . '/' . $dev_id . '.cnf.xml'; - 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 = $this->sccpvalues[$var_xml_general_fields[$key]]['data']; - } -// 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 = $this->sccpvalues['ntp_timezone']['data']; - $TZdata = $this-> extconfigs->getextConfig('sccp_timezone',$tz_id); - if (empty($TZdata)){ - $TZdata = array('offset' => '0', 'daylight' => ''); - } - $xnode->name = $tz_id; - $xnode->dateTemplate = $this->sccpvalues['dateformat']['data']; - $xnode->timeZone = $tz_id.((empty($TZdata['daylight']))? '': '/'.$TZdata['daylight']); + $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' + ); + $var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList'=> 'null', 'mobility' => 'null', + 'phoneServices' =>'null', 'certHash' =>'null', + 'deviceSecurityMode' => '1'); - if ($this->sccpvalues['ntp_config_enabled']['data'] == 'yes') { - $xnode->ntps->ntp->name = $this->sccpvalues['ntp_server']['data']; - $xnode->ntps->ntp->ntpMode = $this->sccpvalues['ntp_server_mode']['data']; - } else { - $xnode->ntps = ''; - } - // Ntp Config - break; - case 'srstInfo': - if ($this->sccpvalues['srst_Option']['data'] == 'user') { - break; - } - $xnode = &$xml_node->$dkey; - $xnode -> name = $this->sccpvalues['srst_Name']['data']; - $xnode -> srstOption = $this->sccpvalues['srst_Option']['data']; - $xnode -> userModifiable = $this->sccpvalues['srst_userModifiable']['data']; - $xnode -> isSecure = $this->sccpvalues['srst_isSecure']['data']; + if (empty($dev_id)) { + return false; + } + $var_hw_config = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id)); - $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(';', $this->sccpvalues[$srst_pro]['data']); - $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($this->sccpvalues['keepalive']['data'])* 0.75)); - break; - case 'callManagerGroup': - $xnode = &$xml_node->$dkey->members; - if ($this->sccpvalues['bindaddr']['data'] == '0.0.0.0') { - $ifc = 0; - foreach ($this->getIP_information() as $value) { - if (!empty($value[0])) { - if (!in_array($value[0], array('0.0.0.0', '127.0.0.1'), true)) { - $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 = $this->sccpvalues['servername']['data']; - $xnode_obj->callManager->ports->ethernetPhonePort = $this->sccpvalues['port']['data']; - $xnode_obj->callManager->processNodeName = $value[0]; - 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 = $this->sccpvalues['servername']['data']; - $xnode_obj->ports->ethernetPhonePort = $this->sccpvalues['port']['data']; - $xnode_obj->processNodeName = $this->sccpvalues['bindaddr']['data']; - } - break; - } - } - $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); - break; - case 'versionStamp': - $xml_work->$key = time(); - break; - case 'loadInformation': - $xml_work->$key = $var_hw_config["loadimage"]; - if (!empty($var_hw_config['addon'])) { - $hw_addon = explode(',', $var_hw_config['addon']); - $xnode = $xml_work->addChild('addOnModules'); - $ti = 1; - foreach ($hw_addon as $key) { - $hw_inf = $this->getSccp_model_information('byid', false, "all", array('model' => $key)); - $xnode_obj = $xnode->addChild('addOnModule'); -// if $hw_inf['loadimage'] - $xnode_obj->addAttribute('idx', $ti); - $xnode_obj->addChild('loadInformation', $hw_inf[0]['loadimage']); - $ti ++; - } -// $this->appendSimpleXmlNode($xml_work , $xnode_obj); - } - break; - case 'userLocale': - case 'networkLocaleInfo': - case 'networkLocale': - $hwlang = ''; - $lang = ''; - if (!empty($var_hw_config["_hwlang"])) { - $hwlang = explode(':', $var_hw_config["_hwlang"]); - } - if (($key == 'networkLocaleInfo') || ($key == 'networkLocale')) { -// $lang=$this->sccpvalues['netlang']['data']; - $lang = (empty($hwlang[0])) ? $this->sccpvalues['netlang']['data'] : $hwlang[0]; - } else { - $lang = (empty($hwlang[1])) ? $this->sccpvalues['devlang']['data'] : $hwlang[1]; -// $lang=$this->sccpvalues['devlang']['data']; - } - if (($lang !='null') && (!empty(trim($lang)))) { - if ($key == 'networkLocale') { - $xml_work->$key = $lang; - } else { - $lang_arr = $this->extconfigs->getextConfig('sccp_lang',$lang); - if (!empty($lang_arr)) { - $xml_node->name = $lang_arr['locale']; - $xml_node->langCode = $lang_arr['code']; - $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; - } - } + if (empty($var_hw_config)) { + return false; + } -// print_r($xml_work); - $xml_work->asXml($xml_name); // Save - } else { - die('Error Hardware template :' . $xml_template . ' not found'); - } - return time(); - * - */ + if (!empty($var_hw_config['nametemplate'])) { + $xml_template = $this->sccppath["tftp_templates"] . '/' . $var_hw_config['nametemplate']; + } else { + $xml_template = $this->sccppath["tftp_templates"] . '/SEP0000000000.cnf.xml_79df_template'; + } + $xml_name = $this->sccppath["tftp_path"] . '/' . $dev_id . '.cnf.xml'; + 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 = $this->sccpvalues[$var_xml_general_fields[$key]]['data']; + } + // 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 = $this->sccpvalues['ntp_timezone']['data']; + $TZdata = $this-> extconfigs->getextConfig('sccp_timezone',$tz_id); + if (empty($TZdata)){ + $TZdata = array('offset' => '0', 'daylight' => ''); + } + $xnode->name = $tz_id; + $xnode->dateTemplate = $this->sccpvalues['dateformat']['data']; + $xnode->timeZone = $tz_id.((empty($TZdata['daylight']))? '': '/'.$TZdata['daylight']); + + if ($this->sccpvalues['ntp_config_enabled']['data'] == 'yes') { + $xnode->ntps->ntp->name = $this->sccpvalues['ntp_server']['data']; + $xnode->ntps->ntp->ntpMode = $this->sccpvalues['ntp_server_mode']['data']; + } else { + $xnode->ntps = ''; + } + // Ntp Config + break; + case 'srstInfo': + if ($this->sccpvalues['srst_Option']['data'] == 'user') { + break; + } + $xnode = &$xml_node->$dkey; + $xnode -> name = $this->sccpvalues['srst_Name']['data']; + $xnode -> srstOption = $this->sccpvalues['srst_Option']['data']; + $xnode -> userModifiable = $this->sccpvalues['srst_userModifiable']['data']; + $xnode -> isSecure = $this->sccpvalues['srst_isSecure']['data']; + + $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(';', $this->sccpvalues[$srst_pro]['data']); + $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($this->sccpvalues['keepalive']['data'])* 0.75)); + break; + case 'callManagerGroup': + $xnode = &$xml_node->$dkey->members; + if ($this->sccpvalues['bindaddr']['data'] == '0.0.0.0') { + $ifc = 0; + foreach ($this->getIP_information() as $value) { + if (!empty($value[0])) { + if (!in_array($value[0], array('0.0.0.0', '127.0.0.1'), true)) { + $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 = $this->sccpvalues['servername']['data']; + $xnode_obj->callManager->ports->ethernetPhonePort = $this->sccpvalues['port']['data']; + $xnode_obj->callManager->processNodeName = $value[0]; + 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 = $this->sccpvalues['servername']['data']; + $xnode_obj->ports->ethernetPhonePort = $this->sccpvalues['port']['data']; + $xnode_obj->processNodeName = $this->sccpvalues['bindaddr']['data']; + } + break; + } + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + break; + case 'versionStamp': + $xml_work->$key = time(); + break; + case 'loadInformation': + $xml_work->$key = $var_hw_config["loadimage"]; + if (!empty($var_hw_config['addon'])) { + $hw_addon = explode(',', $var_hw_config['addon']); + $xnode = $xml_work->addChild('addOnModules'); + $ti = 1; + foreach ($hw_addon as $key) { + $hw_inf = $this->getSccp_model_information('byid', false, "all", array('model' => $key)); + $xnode_obj = $xnode->addChild('addOnModule'); + // if $hw_inf['loadimage'] + $xnode_obj->addAttribute('idx', $ti); + $xnode_obj->addChild('loadInformation', $hw_inf[0]['loadimage']); + $ti ++; + } + // $this->appendSimpleXmlNode($xml_work , $xnode_obj); + } + break; + case 'userLocale': + case 'networkLocaleInfo': + case 'networkLocale': + $hwlang = ''; + $lang = ''; + if (!empty($var_hw_config["_hwlang"])) { + $hwlang = explode(':', $var_hw_config["_hwlang"]); + } + if (($key == 'networkLocaleInfo') || ($key == 'networkLocale')) { + // $lang=$this->sccpvalues['netlang']['data']; + $lang = (empty($hwlang[0])) ? $this->sccpvalues['netlang']['data'] : $hwlang[0]; + } else { + $lang = (empty($hwlang[1])) ? $this->sccpvalues['devlang']['data'] : $hwlang[1]; + // $lang=$this->sccpvalues['devlang']['data']; + } + if (($lang !='null') && (!empty(trim($lang)))) { + if ($key == 'networkLocale') { + $xml_work->$key = $lang; + } else { + $lang_arr = $this->extconfigs->getextConfig('sccp_lang',$lang); + if (!empty($lang_arr)) { + $xml_node->name = $lang_arr['locale']; + $xml_node->langCode = $lang_arr['code']; + $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 sccp_delete_device_XML($dev_id = '') { if (empty($dev_id)) { return false; } - if ($dev_id =='all') { + if ($dev_id == 'all') { $xml_name = $this->sccppath["tftp_path"] . '/SEP*.cnf.xml'; array_map("unlink", glob($xml_name)); } else { - if (!strpos($dev_id,'SEP')) { + if (!strpos($dev_id, 'SEP')) { return false; } $xml_name = $this->sccppath["tftp_path"] . '/' . $dev_id . '.cnf.xml'; @@ -2018,10 +2024,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } - - - - + function sccp_create_sccp_init() { // Make sccp.conf data // [general] @@ -2057,8 +2060,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dir = $this->sccppath["tftp_path"]; $dir_tepl = $this->sccppath["tftp_templates"]; - $raw_settings = $this-> dbinterface -> getDb_model_info($get, $format_list, $filter) ; - + $raw_settings = $this->dbinterface->getDb_model_info($get, $format_list, $filter); + if ($validate) { for ($i = 0; $i < count($raw_settings); $i++) { $raw_settings[$i]['validate'] = '-;-'; @@ -2097,7 +2100,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } return $raw_settings; } - function getIP_information() { $interfaces['auto'] = array('0.0.0.0', 'All', '0'); diff --git a/Sccp_manager.inc/dbinterface.class.php b/Sccp_manager.inc/dbinterface.class.php index 53ee643..8f85e91 100644 --- a/Sccp_manager.inc/dbinterface.class.php +++ b/Sccp_manager.inc/dbinterface.class.php @@ -1,27 +1,32 @@ $Ver, - 'about' =>'Data access interface ver: '.$Ver); + 'about' => 'Data access interface ver: ' . $Ver); } /* * Core Access Function */ + public function get_db_SccpTableData($dataid, $data = array()) { if ($dataid == '') { return False; @@ -76,6 +81,7 @@ class dbinterface { /* * Get Sccp Device Model information */ + function getDb_model_info($get = "all", $format_list = "all", $filter = array()) { global $db; switch ($format_list) { @@ -93,9 +99,9 @@ class dbinterface { case "byciscoid": if (!empty($filter)) { if (!empty($filter['model'])) { - if (strpos($filter['model'],'loadInformation')) { + if (strpos($filter['model'], 'loadInformation')) { $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (`loadinformationid` ='" . $filter['model'] . "') ORDER BY model "; - } else { + } else { $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (`loadinformationid` ='loadInformation" . $filter['model'] . "') ORDER BY model "; } } else { @@ -204,4 +210,5 @@ class dbinterface { } return $result; } -} \ No newline at end of file + +} diff --git a/Sccp_manager.inc/extconfigs.class.php b/Sccp_manager.inc/extconfigs.class.php index 02ec8dd..31db7c6 100644 --- a/Sccp_manager.inc/extconfigs.class.php +++ b/Sccp_manager.inc/extconfigs.class.php @@ -1,213 +1,214 @@ $Ver, - 'about' =>'Default Setings and Enums ver: '.$Ver); - } + public function __construct() { - public function getextConfig($id = '', $index = '') { - switch ($id) { - case 'keyset': - $result = $this->keysetdefault; - break; - case 'sccp_lang': - $result = $this->cisco_language; - break; - case 'sccpDefaults': - $result = $this->sccpDefaults; - break; - case 'sccp_timezone': - $result = array(); - foreach ($this->cisco_timezone as $key => $value) { - $cisco_code = $key .' Standard'.((empty($value['daylight']))? '': '/'.$value['daylight']).' Time'; - if (isset($value['cisco_code'])) { - $cisco_code = (empty($value['cisco_code']))? $cisco_code : $value['cisco_code']; - } - $result[$key] = array('offset' => $value['offset'], 'daylight' => $value['daylight'], 'cisco_code' =>$cisco_code); + } + + public function info() { + $Ver = '13.0.2'; + return Array('Version' => $Ver, + 'about' => 'Default Setings and Enums ver: ' . $Ver); + } + + public function getextConfig($id = '', $index = '') { + switch ($id) { + case 'keyset': + $result = $this->keysetdefault; + break; + case 'sccp_lang': + $result = $this->cisco_language; + break; + case 'sccpDefaults': + $result = $this->sccpDefaults; + break; + case 'sccp_timezone': + $result = array(); + foreach ($this->cisco_timezone as $key => $value) { + $cisco_code = $key . ' Standard' . ((empty($value['daylight'])) ? '' : '/' . $value['daylight']) . ' Time'; + if (isset($value['cisco_code'])) { + $cisco_code = (empty($value['cisco_code'])) ? $cisco_code : $value['cisco_code']; } - break; -/* case 'cisco_time': - $result = array(); - foreach ($this->cisco_timezone as $key => $value) { - $result[] = array('id'=> ($value['offset']/60) ,'val'=>$key.((empty($value['daylight']))? '': '/'.$value['daylight'])); - } - break; - */ - case 'cisco_timezone': - $result = array(); - foreach ($this->cisco_timezone as $key => $value) { - $result[] = array('id'=> $key ,'val'=>$key.((empty($value['daylight']))? '': '/'.$value['daylight'])); -// $result[$key] =$key.((empty($value['daylight']))? '': '/'.$value['daylight']); - } - break; - default: - return array('noId'); - break; - } - if (empty($index)) { - return $result; - } else { - if (isset($result[$index])) { - return $result[$index]; - } else { - return array(); + $result[$key] = array('offset' => $value['offset'], 'daylight' => $value['daylight'], 'cisco_code' => $cisco_code); } + break; + /* case 'cisco_time': + $result = array(); + foreach ($this->cisco_timezone as $key => $value) { + $result[] = array('id'=> ($value['offset']/60) ,'val'=>$key.((empty($value['daylight']))? '': '/'.$value['daylight'])); + } + break; + */ + case 'cisco_timezone': + $result = array(); + foreach ($this->cisco_timezone as $key => $value) { + $result[] = array('id' => $key, 'val' => $key . ((empty($value['daylight'])) ? '' : '/' . $value['daylight'])); +// $result[$key] =$key.((empty($value['daylight']))? '': '/'.$value['daylight']); + } + break; + default: + return array('noId'); + break; + } + if (empty($index)) { + return $result; + } else { + if (isset($result[$index])) { + return $result[$index]; + } else { + return array(); } } + } - private $sccpDefaults = array( - "servername" => 'VPBXSCCP', - "bindaddr" => '0.0.0.0', "port" => '2000', # chan_sccp also supports ipv6 - # bindaddr = "::" will support ipv6 and ipv4 at the same time - "deny" => '0.0.0.0/0.0.0.0', - "permit" => '0.0.0.0/0.0.0.0', # !TODO!: please change this to 'internal' which would mean: - # permit:127.0.0.0/255.0.0.0,permit:10.0.0.0/255.0.0.0,permit:172.0.0.0/255.224.0.0,permit:192.168.0.0/255.255.0.0" - "dateformat" => 'D.M.Y', # This is the german default format. Should be "D/M/Y" or "D/M/YA" instead - "disallow" => 'all', "allow" => 'alaw;ulaw', - "hotline_enabled" => 'no', - "hotline_context" => 'default', # !TODO!: Should this not be from-internal on FreePBX ? - "hotline_extension" => '*60', # !TODO!: Is this a good default extension to dial for hotline ? - "hotline_label" => 'hotline', - "devicetable" => 'sccpdevice', - "linetable" => 'sccpline', - "tftp_path" => '/tftpboot' - ); - - private $keysetdefault = array('onhook' => 'redial,newcall,cfwdall,dnd,pickup,gpickup,private', - 'connected' => 'hold,endcall,park,vidmode,select,cfwdall,cfwdbusy,idivert', - 'onhold' => 'resume,newcall,endcall,transfer,conflist,select,dirtrfr,idivert,meetme', - 'ringin' => 'answer,endcall,transvm,idivert', - 'offhook' => 'redial,endcall,private,cfwdall,cfwdbusy,pickup,gpickup,meetme,barge', - 'conntrans' => 'hold,endcall,transfer,conf,park,select,dirtrfr,vidmode,meetme,cfwdall,cfwdbusy', - 'digitsfoll' => 'back,endcall,dial', - 'connconf' => 'conflist,newcall,endcall,hold,vidmode', - 'ringout' => 'empty,endcall,transfer,cfwdall,idivert', - 'offhookfeat' => 'redial,endcall', - 'onhint' => 'redial,newcall,pickup,gpickup,barge', - 'onstealable' => 'redial,newcall,cfwdall,pickup,gpickup,dnd,intrcpt', - 'holdconf' => 'resume,newcall,endcall,join', - 'uriaction' => 'default'); + private $sccpDefaults = array( + "servername" => 'VPBXSCCP', + "bindaddr" => '0.0.0.0', "port" => '2000', # chan_sccp also supports ipv6 + # bindaddr = "::" will support ipv6 and ipv4 at the same time + "deny" => '0.0.0.0/0.0.0.0', + "permit" => '0.0.0.0/0.0.0.0', # !TODO!: please change this to 'internal' which would mean: + # permit:127.0.0.0/255.0.0.0,permit:10.0.0.0/255.0.0.0,permit:172.0.0.0/255.224.0.0,permit:192.168.0.0/255.255.0.0" + "dateformat" => 'D.M.Y', # This is the german default format. Should be "D/M/Y" or "D/M/YA" instead + "disallow" => 'all', "allow" => 'alaw;ulaw', + "hotline_enabled" => 'no', + "hotline_context" => 'default', # !TODO!: Should this not be from-internal on FreePBX ? + "hotline_extension" => '*60', # !TODO!: Is this a good default extension to dial for hotline ? + "hotline_label" => 'hotline', + "devicetable" => 'sccpdevice', + "linetable" => 'sccpline', + "tftp_path" => '/tftpboot' + ); + private $keysetdefault = array('onhook' => 'redial,newcall,cfwdall,dnd,pickup,gpickup,private', + 'connected' => 'hold,endcall,park,vidmode,select,cfwdall,cfwdbusy,idivert', + 'onhold' => 'resume,newcall,endcall,transfer,conflist,select,dirtrfr,idivert,meetme', + 'ringin' => 'answer,endcall,transvm,idivert', + 'offhook' => 'redial,endcall,private,cfwdall,cfwdbusy,pickup,gpickup,meetme,barge', + 'conntrans' => 'hold,endcall,transfer,conf,park,select,dirtrfr,vidmode,meetme,cfwdall,cfwdbusy', + 'digitsfoll' => 'back,endcall,dial', + 'connconf' => 'conflist,newcall,endcall,hold,vidmode', + 'ringout' => 'empty,endcall,transfer,cfwdall,idivert', + 'offhookfeat' => 'redial,endcall', + 'onhint' => 'redial,newcall,pickup,gpickup,barge', + 'onstealable' => 'redial,newcall,cfwdall,pickup,gpickup,dnd,intrcpt', + 'holdconf' => 'resume,newcall,endcall,join', + 'uriaction' => 'default'); // Cisco Language Code / Directory - - private $cisco_language = array('ar_SA' => array('code' => 'ar', 'language' => 'Arabic', 'locale' => 'Arabic_Saudi_Arabia'), - 'bg_BG' => array('code' => 'bg', 'language' => 'Bulgarian', 'locale' => 'Bulgarian_Bulgaria'), - 'cz_CZ' => array('code' => 'cz', 'language' => 'Czech', 'locale' => 'Czech_Czech_Republic'), - 'da_DK' => array('code' => 'da', 'language' => 'Danish', 'locale' => 'Danish_Denmark'), - 'de_DE' => array('code' => 'de', 'language' => 'German', 'locale' => 'German_Germany'), - 'el_GR' => array('code' => 'el', 'language' => 'Greek', 'locale' => 'Greek_Greece'), - 'en_AU' => array('code' => 'en', 'language' => 'English', 'locale' => 'AU_English_United_States'), - 'en_GB' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_Kingdom'), - 'en_US' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_States'), - 'es_ES' => array('code' => 'es', 'language' => 'Spanish', 'locale' => 'Spanish_Spain'), - 'et_EE' => array('code' => 'et', 'language' => 'Estonian', 'locale' => 'Estonian_Estonia'), - 'fi_FI' => array('code' => 'fi', 'language' => 'Finnish', 'locale' => 'Finnish_Finland'), - 'fr_CA' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_Canada'), - 'fr_FR' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_France'), - 'he_IL' => array('code' => 'he', 'language' => 'Hebrew', 'locale' => 'Hebrew_Israel'), - 'hr_HR' => array('code' => 'hr', 'language' => 'Croatian', 'locale' => 'Croatian_Croatia'), - 'hu_HU' => array('code' => 'hu', 'language' => 'Hungarian', 'locale' => 'Hungarian_Hungary'), - 'it_IT' => array('code' => 'it', 'language' => 'Italian', 'locale' => 'Italian_Italy'), - 'ja_JP' => array('code' => 'ja', 'language' => 'Japanese', 'locale' => 'Japanese_Japan'), - 'ko_KO' => array('code' => 'ko', 'language' => 'Korean', 'locale' => 'Korean_Korea_Republic'), - 'lt_LT' => array('code' => 'lt', 'language' => 'Lithuanian', 'locale' => 'Lithuanian_Lithuania'), - 'lv_LV' => array('code' => 'lv', 'language' => 'Latvian', 'locale' => 'Latvian_Latvia'), - 'nl_NL' => array('code' => 'nl', 'language' => 'Dutch', 'locale' => 'Dutch_Netherlands'), - 'no_NO' => array('code' => 'no', 'language' => 'Norwegian', 'locale' => 'Norwegian_Norway'), - 'pl_PL' => array('code' => 'pl', 'language' => 'Polish', 'locale' => 'Polish_Poland'), - 'pt_BR' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Brazil'), - 'pt_PT' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Portugal'), - 'ro_RO' => array('code' => 'ro', 'language' => 'Romanian', 'locale' => 'Romanian_Romania'), - 'ru_RU' => array('code' => 'ru', 'language' => 'Russian', 'locale' => 'Russian_Russian_Federation'), - 'sk_SK' => array('code' => 'sk', 'language' => 'Slovakian', 'locale' => 'Slovak_Slovakia'), - 'sl_SL' => array('code' => 'sl', 'language' => 'Slovenian', 'locale' => 'Slovenian_Slovenia'), - 'sr_ME' => array('code' => 'sr', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Montenegro'), - 'sr_RS' => array('code' => 'rs', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Serbia'), - 'sv_SE' => array('code' => 'sv', 'language' => 'Swedish', 'locale' => 'Swedish_Sweden'), - 'th_TH' => array('code' => 'th', 'language' => 'Thailand', 'locale' => 'Thai_Thailand'), - 'tr_TR' => array('code' => 'tr', 'language' => 'Turkish', 'locale' => 'Turkish_Turkey'), - 'zh_CN' => array('code' => 'cn', 'language' => 'Chinese', 'locale' => 'Chinese_China'), - 'zh_TW' => array('code' => 'zh', 'language' => 'Chinese', 'locale' => 'Chinese_Taiwan') - ); - private $cisco_timezone = array( - 'Dateline' => array('offset' => '-720', 'daylight' => ''), - 'Samoa' => array('offset' => '-660', 'daylight' => ''), - 'Hawaiian' => array('offset' => '-600', 'daylight' => ''), - 'Alaskan' => array('offset' => '-540', 'daylight' => 'Daylight'), - 'Pacific' => array('offset' => '-480', 'daylight' => 'Daylight'), - 'Mountain' => array('offset' => '-420', 'daylight' => 'Daylight'), - 'US Mountain' => array('offset' => '-420', 'daylight' => ''), - 'Central' => array('offset' => '-360', 'daylight' => 'Daylight'), - 'Mexico' => array('offset' => '-360', 'daylight' => 'Daylight'), - 'Canada Central' => array('offset' => '-360', 'daylight' => ''), - 'SA Pacific' => array('offset' => '-300', 'daylight' => ''), - 'Eastern' => array('offset' => '-300', 'daylight' => 'Daylight'), - 'US Eastern' => array('offset' => '-300', 'daylight' => ''), - 'Atlantic' => array('offset' => '-240', 'daylight' => 'Daylight'), - 'SA Western' => array('offset' => '-240', 'daylight' => ''), - 'Pacific SA' => array('offset' => '-240', 'daylight' => ''), - 'Newfoundland' => array('offset' => '-210', 'daylight' => 'Daylight'), - 'E. South America' => array('offset' => '-180', 'daylight' => 'Daylight'), - 'SA Eastern' => array('offset' => '-180', 'daylight' => ''), - 'Pacific SA' => array('offset' => '-180', 'daylight' => 'Daylight'), - 'Mid-Atlantic' => array('offset' => '-120', 'daylight' => 'Daylight'), - 'Azores' => array('offset' => '-060', 'daylight' => 'Daylight'), - 'GMT' => array('offset' => '00', 'daylight' => 'Daylight'), - 'Greenwich' => array('offset' => '00', 'daylight' => ''), - 'W. Europe' => array('offset' => '60', 'daylight' => 'Daylight'), - 'GTB' => array('offset' => '60', 'daylight' => 'Daylight'), - 'Egypt' => array('offset' => '60', 'daylight' => 'Daylight'), - 'E. Europe' => array('offset' => '60', 'daylight' => 'Daylight'), - 'Romance' => array('offset' => '120', 'daylight' => 'Daylight'), - 'Central Europe' => array('offset' => '120', 'daylight' => 'Daylight'), - 'South Africa' => array('offset' => '120', 'daylight' => ''), - 'Jerusalem' => array('offset' => '120', 'daylight' => 'Daylight'), - 'Saudi Arabia' => array('offset' => '180', 'daylight' => ''), -/* Russion Regions */ - 'Russian/Kaliningrad' => array('offset' => '120', 'daylight' => '', 'cisco_code' => 'South Africa Standard Time'), - 'Russian/Moscow' => array('offset' => '180', 'daylight' => '', 'cisco_code' => 'Russian Standard Time'), - 'Russian/St.Peterburg' => array('offset' => '180', 'daylight' => '', 'cisco_code' => 'Russian Standard Time'), - 'Russian/Samara' => array('offset' => '240', 'daylight' => '', 'cisco_code' => 'Arabian Standard Time'), - 'Russian/Novosibirsk' => array('offset' => '300', 'daylight' => '', 'cisco_code' => 'Ekaterinburg Standard Time'), - 'Russian/Ekaterinburg' => array('offset' => '300', 'daylight' => '', 'cisco_code' => 'Ekaterinburg Standard Time'), - 'Russian/Irkutsk' => array('offset' => '480', 'daylight' => '', 'cisco_code' => 'China Standard Time'), - 'Russian/Yakutsk' => array('offset' => '540', 'daylight' => '', 'cisco_code' => 'Tokyo Standard Time'), - 'Russian/Khabarovsk' => array('offset' => '600', 'daylight' => '', 'cisco_code' => 'West Pacific Standard Time'), - 'Russian/Vladivostok' => array('offset' => '600', 'daylight' => '', 'cisco_code' => 'West Pacific Standard Time'), - 'Russian/Sakhalin' => array('offset' => '660', 'daylight' => '', 'cisco_code' => 'Central Pacific Standard Time'), - 'Russian/Magadan' => array('offset' => '660', 'daylight' => '', 'cisco_code' => 'Central Pacific Standard Time'), - 'Russian/Kamchatka' => array('offset' => '720', 'daylight' => '', 'cisco_code' => 'Fiji Standard Time'), - /* EnD - Russion Regions */ - - 'Iran' => array('offset' => '210', 'daylight' => 'Daylight'), - 'Caucasus' => array('offset' => '240', 'daylight' => 'Daylight'), - 'Arabian' => array('offset' => '240', 'daylight' => ''), - 'Afghanistan' => array('offset' => '270', 'daylight' => ''), - 'West Asia' => array('offset' => '300', 'daylight' => ''), - 'India' => array('offset' => '330', 'daylight' => ''), - 'Central Asia' => array('offset' => '360', 'daylight' => ''), - 'SE Asia' => array('offset' => '420', 'daylight' => ''), - 'China' => array('offset' => '480', 'daylight' => ''), - 'Taipei' => array('offset' => '480', 'daylight' => ''), - 'Tokyo' => array('offset' => '540', 'daylight' => ''), - 'Cen. Australia' => array('offset' => '570', 'daylight' => 'Daylight'), - 'AUS Central' => array('offset' => '570', 'daylight' => ''), - 'E. Australia' => array('offset' => '600', 'daylight' => ''), - 'AUS Eastern' => array('offset' => '600', 'daylight' => 'Daylight'), - 'West Pacific' => array('offset' => '600', 'daylight' => ''), - 'Tasmania' => array('offset' => '600', 'daylight' => 'Daylight'), - 'Central Pacific' => array('offset' => '660', 'daylight' => ''), - 'Fiji' => array('offset' => '720', 'daylight' => ''), - 'New Zealand' => array('offset' => '720', 'daylight' => 'Daylight') - ); - -} \ No newline at end of file + private $cisco_language = array('ar_SA' => array('code' => 'ar', 'language' => 'Arabic', 'locale' => 'Arabic_Saudi_Arabia'), + 'bg_BG' => array('code' => 'bg', 'language' => 'Bulgarian', 'locale' => 'Bulgarian_Bulgaria'), + 'cz_CZ' => array('code' => 'cz', 'language' => 'Czech', 'locale' => 'Czech_Czech_Republic'), + 'da_DK' => array('code' => 'da', 'language' => 'Danish', 'locale' => 'Danish_Denmark'), + 'de_DE' => array('code' => 'de', 'language' => 'German', 'locale' => 'German_Germany'), + 'el_GR' => array('code' => 'el', 'language' => 'Greek', 'locale' => 'Greek_Greece'), + 'en_AU' => array('code' => 'en', 'language' => 'English', 'locale' => 'AU_English_United_States'), + 'en_GB' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_Kingdom'), + 'en_US' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_States'), + 'es_ES' => array('code' => 'es', 'language' => 'Spanish', 'locale' => 'Spanish_Spain'), + 'et_EE' => array('code' => 'et', 'language' => 'Estonian', 'locale' => 'Estonian_Estonia'), + 'fi_FI' => array('code' => 'fi', 'language' => 'Finnish', 'locale' => 'Finnish_Finland'), + 'fr_CA' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_Canada'), + 'fr_FR' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_France'), + 'he_IL' => array('code' => 'he', 'language' => 'Hebrew', 'locale' => 'Hebrew_Israel'), + 'hr_HR' => array('code' => 'hr', 'language' => 'Croatian', 'locale' => 'Croatian_Croatia'), + 'hu_HU' => array('code' => 'hu', 'language' => 'Hungarian', 'locale' => 'Hungarian_Hungary'), + 'it_IT' => array('code' => 'it', 'language' => 'Italian', 'locale' => 'Italian_Italy'), + 'ja_JP' => array('code' => 'ja', 'language' => 'Japanese', 'locale' => 'Japanese_Japan'), + 'ko_KO' => array('code' => 'ko', 'language' => 'Korean', 'locale' => 'Korean_Korea_Republic'), + 'lt_LT' => array('code' => 'lt', 'language' => 'Lithuanian', 'locale' => 'Lithuanian_Lithuania'), + 'lv_LV' => array('code' => 'lv', 'language' => 'Latvian', 'locale' => 'Latvian_Latvia'), + 'nl_NL' => array('code' => 'nl', 'language' => 'Dutch', 'locale' => 'Dutch_Netherlands'), + 'no_NO' => array('code' => 'no', 'language' => 'Norwegian', 'locale' => 'Norwegian_Norway'), + 'pl_PL' => array('code' => 'pl', 'language' => 'Polish', 'locale' => 'Polish_Poland'), + 'pt_BR' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Brazil'), + 'pt_PT' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Portugal'), + 'ro_RO' => array('code' => 'ro', 'language' => 'Romanian', 'locale' => 'Romanian_Romania'), + 'ru_RU' => array('code' => 'ru', 'language' => 'Russian', 'locale' => 'Russian_Russian_Federation'), + 'sk_SK' => array('code' => 'sk', 'language' => 'Slovakian', 'locale' => 'Slovak_Slovakia'), + 'sl_SL' => array('code' => 'sl', 'language' => 'Slovenian', 'locale' => 'Slovenian_Slovenia'), + 'sr_ME' => array('code' => 'sr', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Montenegro'), + 'sr_RS' => array('code' => 'rs', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Serbia'), + 'sv_SE' => array('code' => 'sv', 'language' => 'Swedish', 'locale' => 'Swedish_Sweden'), + 'th_TH' => array('code' => 'th', 'language' => 'Thailand', 'locale' => 'Thai_Thailand'), + 'tr_TR' => array('code' => 'tr', 'language' => 'Turkish', 'locale' => 'Turkish_Turkey'), + 'zh_CN' => array('code' => 'cn', 'language' => 'Chinese', 'locale' => 'Chinese_China'), + 'zh_TW' => array('code' => 'zh', 'language' => 'Chinese', 'locale' => 'Chinese_Taiwan') + ); + private $cisco_timezone = array( + 'Dateline' => array('offset' => '-720', 'daylight' => ''), + 'Samoa' => array('offset' => '-660', 'daylight' => ''), + 'Hawaiian' => array('offset' => '-600', 'daylight' => ''), + 'Alaskan' => array('offset' => '-540', 'daylight' => 'Daylight'), + 'Pacific' => array('offset' => '-480', 'daylight' => 'Daylight'), + 'Mountain' => array('offset' => '-420', 'daylight' => 'Daylight'), + 'US Mountain' => array('offset' => '-420', 'daylight' => ''), + 'Central' => array('offset' => '-360', 'daylight' => 'Daylight'), + 'Mexico' => array('offset' => '-360', 'daylight' => 'Daylight'), + 'Canada Central' => array('offset' => '-360', 'daylight' => ''), + 'SA Pacific' => array('offset' => '-300', 'daylight' => ''), + 'Eastern' => array('offset' => '-300', 'daylight' => 'Daylight'), + 'US Eastern' => array('offset' => '-300', 'daylight' => ''), + 'Atlantic' => array('offset' => '-240', 'daylight' => 'Daylight'), + 'SA Western' => array('offset' => '-240', 'daylight' => ''), + 'Pacific SA' => array('offset' => '-240', 'daylight' => ''), + 'Newfoundland' => array('offset' => '-210', 'daylight' => 'Daylight'), + 'E. South America' => array('offset' => '-180', 'daylight' => 'Daylight'), + 'SA Eastern' => array('offset' => '-180', 'daylight' => ''), + 'Pacific SA' => array('offset' => '-180', 'daylight' => 'Daylight'), + 'Mid-Atlantic' => array('offset' => '-120', 'daylight' => 'Daylight'), + 'Azores' => array('offset' => '-060', 'daylight' => 'Daylight'), + 'GMT' => array('offset' => '00', 'daylight' => 'Daylight'), + 'Greenwich' => array('offset' => '00', 'daylight' => ''), + 'W. Europe' => array('offset' => '60', 'daylight' => 'Daylight'), + 'GTB' => array('offset' => '60', 'daylight' => 'Daylight'), + 'Egypt' => array('offset' => '60', 'daylight' => 'Daylight'), + 'E. Europe' => array('offset' => '60', 'daylight' => 'Daylight'), + 'Romance' => array('offset' => '120', 'daylight' => 'Daylight'), + 'Central Europe' => array('offset' => '120', 'daylight' => 'Daylight'), + 'South Africa' => array('offset' => '120', 'daylight' => ''), + 'Jerusalem' => array('offset' => '120', 'daylight' => 'Daylight'), + 'Saudi Arabia' => array('offset' => '180', 'daylight' => ''), + /* Russion Regions */ + 'Russian/Kaliningrad' => array('offset' => '120', 'daylight' => '', 'cisco_code' => 'South Africa Standard Time'), + 'Russian/Moscow' => array('offset' => '180', 'daylight' => '', 'cisco_code' => 'Russian Standard Time'), + 'Russian/St.Peterburg' => array('offset' => '180', 'daylight' => '', 'cisco_code' => 'Russian Standard Time'), + 'Russian/Samara' => array('offset' => '240', 'daylight' => '', 'cisco_code' => 'Arabian Standard Time'), + 'Russian/Novosibirsk' => array('offset' => '300', 'daylight' => '', 'cisco_code' => 'Ekaterinburg Standard Time'), + 'Russian/Ekaterinburg' => array('offset' => '300', 'daylight' => '', 'cisco_code' => 'Ekaterinburg Standard Time'), + 'Russian/Irkutsk' => array('offset' => '480', 'daylight' => '', 'cisco_code' => 'China Standard Time'), + 'Russian/Yakutsk' => array('offset' => '540', 'daylight' => '', 'cisco_code' => 'Tokyo Standard Time'), + 'Russian/Khabarovsk' => array('offset' => '600', 'daylight' => '', 'cisco_code' => 'West Pacific Standard Time'), + 'Russian/Vladivostok' => array('offset' => '600', 'daylight' => '', 'cisco_code' => 'West Pacific Standard Time'), + 'Russian/Sakhalin' => array('offset' => '660', 'daylight' => '', 'cisco_code' => 'Central Pacific Standard Time'), + 'Russian/Magadan' => array('offset' => '660', 'daylight' => '', 'cisco_code' => 'Central Pacific Standard Time'), + 'Russian/Kamchatka' => array('offset' => '720', 'daylight' => '', 'cisco_code' => 'Fiji Standard Time'), + /* EnD - Russion Regions */ + 'Iran' => array('offset' => '210', 'daylight' => 'Daylight'), + 'Caucasus' => array('offset' => '240', 'daylight' => 'Daylight'), + 'Arabian' => array('offset' => '240', 'daylight' => ''), + 'Afghanistan' => array('offset' => '270', 'daylight' => ''), + 'West Asia' => array('offset' => '300', 'daylight' => ''), + 'India' => array('offset' => '330', 'daylight' => ''), + 'Central Asia' => array('offset' => '360', 'daylight' => ''), + 'SE Asia' => array('offset' => '420', 'daylight' => ''), + 'China' => array('offset' => '480', 'daylight' => ''), + 'Taipei' => array('offset' => '480', 'daylight' => ''), + 'Tokyo' => array('offset' => '540', 'daylight' => ''), + 'Cen. Australia' => array('offset' => '570', 'daylight' => 'Daylight'), + 'AUS Central' => array('offset' => '570', 'daylight' => ''), + 'E. Australia' => array('offset' => '600', 'daylight' => ''), + 'AUS Eastern' => array('offset' => '600', 'daylight' => 'Daylight'), + 'West Pacific' => array('offset' => '600', 'daylight' => ''), + 'Tasmania' => array('offset' => '600', 'daylight' => 'Daylight'), + 'Central Pacific' => array('offset' => '660', 'daylight' => ''), + 'Fiji' => array('offset' => '720', 'daylight' => ''), + 'New Zealand' => array('offset' => '720', 'daylight' => 'Daylight') + ); + +} diff --git a/Sccp_manager.inc/srvinterface.class.php b/Sccp_manager.inc/srvinterface.class.php index 4634126..e4d0afb 100644 --- a/Sccp_manager.inc/srvinterface.class.php +++ b/Sccp_manager.inc/srvinterface.class.php @@ -1,27 +1,31 @@ $Ver, - 'about' =>'Server interface data ver: '.$Ver); - } + + } + + public function info() { + $Ver = '13.0.2'; + return Array('Version' => $Ver, + 'about' => 'Server interface data ver: ' . $Ver); + } + + /* + Core Access Function + */ -/* - Core Access Function - */ public function sccp_core_commands($params = array()) { global $astman; $cmd_list = array('get_softkey' => array('cmd' => "sccp show softkeyssets", 'param' => ''), @@ -41,7 +45,7 @@ class srvinterface { $id_param = $cmd_list[$id_cmd]['param']; if (!empty($id_param)) { if (!empty($params[$id_param])) { - $result = $astman->Command($cmd_list[$id_cmd]['cmd'] .' '. $params[$id_param]); + $result = $astman->Command($cmd_list[$id_cmd]['cmd'] . ' ' . $params[$id_param]); } } else { $result = $astman->Command($cmd_list[$id_cmd]['cmd']); @@ -73,24 +77,24 @@ class srvinterface { } return $result; } - + public function sccp_getdevice_info($dev_id) { if (empty($dev_id)) { return array(); } $res = $this->sccp_core_commands(array('cmd' => 'get_dev_info', 'name' => $dev_id)); - $res1 = str_replace(array("\r\n", "\r", "\n"), ';', strip_tags((string)$res['data'])); - if (strpos($res1,'MAC-Address')) { - $res2 = substr($res1,0,strpos($res1,'+--- Buttons ')); - $res1 = explode(';',substr($res2,strpos($res2,'MAC-Address'))); - foreach ($res1 as $data ){ + $res1 = str_replace(array("\r\n", "\r", "\n"), ';', strip_tags((string) $res['data'])); + if (strpos($res1, 'MAC-Address')) { + $res2 = substr($res1, 0, strpos($res1, '+--- Buttons ')); + $res1 = explode(';', substr($res2, strpos($res2, 'MAC-Address'))); + foreach ($res1 as $data) { if (!empty($data)) { - $tmp = explode(':',$data); - $data_key =str_replace(array(" ", "-", "\t"), '_', trim($tmp[0])); - $res3[$data_key] =$tmp[1]; + $tmp = explode(':', $data); + $data_key = str_replace(array(" ", "-", "\t"), '_', trim($tmp[0])); + $res3[$data_key] = $tmp[1]; } } - + $res1 = $res3['Skinny_Phone_Type']; $res4 = $res3['Config_Phone_Type']; if (!empty($res3['Addons'])) { @@ -98,19 +102,20 @@ class srvinterface { } else { $res2 = ''; } - $res3['SCCP_Vendor']= Array('vendor' => strtok($res1,' '),'model' => strtok('('), 'model_id' => strtok(')'), 'vendor_addon' => strtok($res2,' '), 'model_addon' => strtok(' ')); - if (empty($res3['SCCP_Vendor']['vendor']) || $res3['SCCP_Vendor']['vendor']=='Undefined'){ - $res3['SCCP_Vendor']= Array('vendor' => 'Undefined','model' => $res4, 'model_id' => '', 'vendor_addon' => $res3['SCCP_Vendor']['vendor_addon'], 'model_addon' => $res3['SCCP_Vendor']['model_addon']); + $res3['SCCP_Vendor'] = Array('vendor' => strtok($res1, ' '), 'model' => strtok('('), 'model_id' => strtok(')'), 'vendor_addon' => strtok($res2, ' '), 'model_addon' => strtok(' ')); + if (empty($res3['SCCP_Vendor']['vendor']) || $res3['SCCP_Vendor']['vendor'] == 'Undefined') { + $res3['SCCP_Vendor'] = Array('vendor' => 'Undefined', 'model' => $res4, 'model_id' => '', 'vendor_addon' => $res3['SCCP_Vendor']['vendor_addon'], 'model_addon' => $res3['SCCP_Vendor']['model_addon']); // return $res4; // return array(); - } + } return $res3; } else { return array(); } } -/* Current not use */ + /* Current not use */ + public function sccp_list_hints() { $ast_out = $this->sccp_core_commands(array('cmd' => 'get_hints')); $ast_out = preg_split("/[\n]/", $ast_out['data']); @@ -136,11 +141,12 @@ class srvinterface { return $ast_key; } - /* !TODO!: install.php is still using the other version number*/ + /* !TODO!: install.php is still using the other version number */ + public function get_compatible_sccp() { - $res = $this-> getChanSCCPVersion(); + $res = $this->getChanSCCPVersion(); if (empty($res)) { - $res = $this-> getChanSCCPVersion(); + $res = $this->getChanSCCPVersion(); } if (empty($res)) { return 0; @@ -153,105 +159,106 @@ class srvinterface { // return $res["vCode"]; } - /* !TODO!: Multiple Version functions (choose one)*/ - /* !TODO!: private ? */ - function getCoreSCCPVersion() { - $result = array(); + /* !TODO!: Multiple Version functions (choose one) */ + /* !TODO!: private ? */ + + function getCoreSCCPVersion() { + $result = array(); $ast_out = $this->sccp_version(); $result["Version"] = $ast_out[0]; - $version_parts=explode(".", $ast_out[0]); + $version_parts = explode(".", $ast_out[0]); $result["vCode"] = implode('', $version_parts); - if (!empty($ast_out[1]) && $ast_out[1] == 'develop'){ + if (!empty($ast_out[1]) && $ast_out[1] == 'develop') { $result["develop"] = $ast_out[1]; $res = 10; - if (base_convert($ast_out[3],16,10) == base_convert('702487a',16,10)) { /* !TODO!: This does not work as you might expect */ + if (base_convert($ast_out[3], 16, 10) == base_convert('702487a', 16, 10)) { /* !TODO!: This does not work as you might expect */ $result["vCode"] = 431; } - if (base_convert($ast_out[3],16,10) >= "10403") { // new method, RevisionNum is incremental - $result["vCode"] = 432; + if (base_convert($ast_out[3], 16, 10) >= "10403") { // new method, RevisionNum is incremental + $result["vCode"] = 432; } } return $result; - } /* !TODO!: Old Method */ /* !TODO!: rename public - > private - private function sccp_version() { - $ast_out = $this->sccp_core_commands(array('cmd' => 'get_version')); - if (preg_match("/Release.*\(/", $ast_out['data'] , $matches)) { - $ast_out = substr($matches[0],9,-1); - return explode(' ', $ast_out); - } else { - return aray('unknown'); + private function sccp_version() { + $ast_out = $this->sccp_core_commands(array('cmd' => 'get_version')); + if (preg_match("/Release.*\(/", $ast_out['data'] , $matches)) { + $ast_out = substr($matches[0],9,-1); + return explode(' ', $ast_out); + } else { + return aray('unknown'); + } + } + + /* !TODO!: Multiple Version functions (choose one :-) */ + /* !TODO!: private ? */ + + function getChanSCCPVersion() { + global $astman; + $result = array(); + if (!$astman) { + return $result; + } + $metadata = $this->astman_retrieveJSFromMetaData(""); + if ($metadata && array_key_exists("Version", $metadata)) { + $result["Version"] = $metadata["Version"]; + $version_parts = explode(".", $metadata["Version"]); + $result["vCode"] = 0; + + # not sure about this sccp_ver numbering. Might be better to just check "Version" and Revision + # $result["vCode"] = implode('', $version_parts); + $result["vCode"] = 0; + if ($version_parts[0] == "4") { + $result["vCode"] = 400; + if ($version_parts[1] == "1") { + $result["vCode"] = 410; + } else + if ($version_parts[1] == "2") { + $result["vCode"] = 420; + } else + if ($version_parts[1] >= "3") { + $result["vCode"] = 430; + } + } + + /* + if (array_key_exists("Branch",$metadata)) { + if ($metadata["Branch"] == "master") { + + } else + if ($metadata["Branch"] == "develop") { + + } + } + */ + + /* Revision got replaced by RevisionHash in 10404 (using the hash does not work) */ + if (array_key_exists("Revision", $metadata)) { + if (base_convert($metadata["Revision"], 16, 10) == base_convert('702487a', 16, 10)) { + $result["vCode"] = 431; + } + if (base_convert($metadata["Revision"], 16, 10) >= "10403") { + $result["vCode"] = 431; + } + } + if (array_key_exists("RevisionNum", $metadata)) { + $result["RevisionNum"] = $metadata["RevisionNum"]; + if ($metadata["RevisionNum"] >= "10403") { // new method, RevisionNum is incremental + $result["vCode"] = 432; + } + } + if (array_key_exists("ConfigureEnabled", $metadata)) { + $result["futures"] = implode(';', $metadata["ConfigureEnabled"]); + } + } else { + die_freepbx("Version information could not be retrieved from chan-sccp, via astman::SCCPConfigMetaData"); } - } - - /* !TODO!: Multiple Version functions (choose one :-)*/ - /* !TODO!: private ? */ - function getChanSCCPVersion() { - global $astman; - $result = array(); - if (!$astman) { return $result; } - $metadata = $this->astman_retrieveJSFromMetaData(""); - if ($metadata && array_key_exists("Version",$metadata)) { - $result["Version"] = $metadata["Version"]; - $version_parts=explode(".", $metadata["Version"]); - $result["vCode"] = 0; - - # not sure about this sccp_ver numbering. Might be better to just check "Version" and Revision - # $result["vCode"] = implode('', $version_parts); - $result["vCode"] = 0; - if ($version_parts[0] == "4") { - $result["vCode"] = 400; - if ($version_parts[1] == "1") { - $result["vCode"] = 410; - } else - if ($version_parts[1] == "2") { - $result["vCode"] = 420; - } else - if ($version_parts[1] >= "3") { - $result["vCode"] = 430; - } - } - /* - if (array_key_exists("Branch",$metadata)) { - if ($metadata["Branch"] == "master") { - - } else - if ($metadata["Branch"] == "develop") { - - } - } - */ - - /* Revision got replaced by RevisionHash in 10404 (using the hash does not work)*/ - if (array_key_exists("Revision",$metadata)) { - if (base_convert($metadata["Revision"],16,10) == base_convert('702487a',16,10)) { - $result["vCode"] = 431; - } - if (base_convert($metadata["Revision"],16,10) >= "10403") { - $result["vCode"] = 431; - } - } - if (array_key_exists("RevisionNum",$metadata)) { - $result["RevisionNum"]=$metadata["RevisionNum"]; - if ($metadata["RevisionNum"] >= "10403") { // new method, RevisionNum is incremental - $result["vCode"] = 432; - } - } - if (array_key_exists("ConfigureEnabled",$metadata)) { - $result["futures"] = implode(';', $metadata["ConfigureEnabled"]); - } - } else { - die_freepbx("Version information could not be retrieved from chan-sccp, via astman::SCCPConfigMetaData"); - } - return $result; -} - public function sccp_list_keysets() { $ast_out = $this->sccp_core_commands(array('cmd' => 'get_softkey')); @@ -308,29 +315,29 @@ class srvinterface { list ($descr, $adress, $devname, $status, $token, $junk) = explode(";|", implode(";|", $line_arr)); // list ($descr, $adress, $devname, $status, $junk) = $line_arr; - // if (strlen($ast_key[$devname]) < 1) { if (strlen($devname) > 1) { $ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $token); } -/* - if (isset($ast_key[$devname])) { - if (strlen($ast_key[$devname]) < 1) { - $ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $descr); - } - } else { - $ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $token); - } - * - */ + /* + if (isset($ast_key[$devname])) { + if (strlen($ast_key[$devname]) < 1) { + $ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $descr); + } + } else { + $ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $token); + } + * + */ } } return $ast_key; } -/* - * Replace sccp_core_commands($params = array()) { - */ - + + /* + * Replace sccp_core_commands($params = array()) { + */ + private function astman_retrieveJSFromMetaData($segment = "") { global $astman; $params = array(); @@ -340,11 +347,11 @@ class srvinterface { $response = $astman->send_request('SCCPConfigMetaData', $params); if ($response["Response"] == "Success") { //outn(_("JSON-content:").$response["JSON"]); - $decode=json_decode($response["JSON"], true); + $decode = json_decode($response["JSON"], true); return $decode; } else { return false; } } - -} \ No newline at end of file + +} diff --git a/Sccp_manager.inc/xmlinterface.class.php b/Sccp_manager.inc/xmlinterface.class.php index c47adb3..d3be152 100644 --- a/Sccp_manager.inc/xmlinterface.class.php +++ b/Sccp_manager.inc/xmlinterface.class.php @@ -1,26 +1,30 @@ $Ver, - 'about' =>'Create XML data interface ver: '.$Ver); - } + + } - - function create_default_XML($data_path = '', $data_values= array(), $model_information =array(), $lang_info =array()) { + public function info() { + $Ver = '13.0.2'; + return Array('Version' => $Ver, + 'about' => 'Create XML data interface ver: ' . $Ver); + } + + function create_default_XML($data_path = '', $data_values = array(), $model_information = array(), $lang_info = array()) { if (empty($data_path) || empty($data_values)) { return; } @@ -82,10 +86,10 @@ class xmlinterface { // configs->getConfig('sccp_lang') if (isset($lang_info[$lang])) { $xnode->name = $lang_info[$lang]['locale']; - $xnode->langCode = $lang_info[$lang]['code']; + $xnode->langCode = $lang_info[$lang]['code']; } else { $xnode->name = ''; - $xnode->langCode = ''; + $xnode->langCode = ''; } // $this -> replaceSimpleXmlNode($xml_work->$key,$xnode); break; @@ -111,18 +115,17 @@ class xmlinterface { $xml_work->asXml($xml_name); // Save XMLDefault1.cnf.xml } } - - - function create_SEP_XML($data_path = '', $data_values= array(), $dev_config = array(), $dev_id = '',$lang_info =array()) { - + + function create_SEP_XML($data_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' - ); - $var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList'=> 'null', 'mobility' => 'null', - 'phoneServices' =>'null', 'certHash' =>'null', - 'deviceSecurityMode' => '1'); - + ); + $var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList' => 'null', 'mobility' => 'null', + 'phoneServices' => 'null', 'certHash' => 'null', + 'deviceSecurityMode' => '1'); + if (empty($dev_id)) { return false; } @@ -151,12 +154,12 @@ class xmlinterface { } } } - + 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) { @@ -168,7 +171,7 @@ class xmlinterface { $xnode = &$xml_node->$dkey; $tz_id = $data_values['ntp_timezone']; $TZdata = $data_values['ntp_timezone_id']; - if (empty($TZdata)){ + if (empty($TZdata)) { $TZdata = array('offset' => '0', 'daylight' => '', 'cisco_code' => 'Greenwich Standard Time'); } $xnode->name = $tz_id; @@ -189,36 +192,36 @@ class xmlinterface { 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']; + $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_fld = array('srst_ip' => array('ipAddr','port') , 'srst_sip' => array('sipIpAddr','sipPort') ); - foreach ($srst_fld as $srst_pro => $srs_put){ + 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]; + $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 = ''; + 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)); + $xml_node->$dkey = strval(intval(intval($data_values['keepalive']) * 0.75)); break; case 'callManagerGroup': $xnode = &$xml_node->$dkey->members; @@ -286,7 +289,7 @@ class xmlinterface { } else { $lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1]; } - if (($lang !='null') && (!empty(trim($lang)))) { + if (($lang != 'null') && (!empty(trim($lang)))) { if ($key == 'networkLocale') { $xml_work->$key = $lang; } else { @@ -296,8 +299,8 @@ class xmlinterface { $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } } - } else { - $xml_work->$key =''; + } else { + $xml_work->$key = ''; } break; // Move all set to $var_xml_general_vars @@ -320,8 +323,6 @@ class xmlinterface { return time(); } - - private function replaceSimpleXmlNode($xml, $element = SimpleXMLElement) { $dom = dom_import_simplexml($xml); $import = $dom->ownerDocument->importNode( @@ -340,6 +341,4 @@ class xmlinterface { $dom->parentNode->appendChild($import->cloneNode(true)); } - - -} \ No newline at end of file +} diff --git a/conf/Sccp.class.php.v431 b/conf/Sccp.class.php.v431 index 456bd90..9ee4b67 100644 --- a/conf/Sccp.class.php.v431 +++ b/conf/Sccp.class.php.v431 @@ -1,4 +1,5 @@ array( - 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), - 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'), - 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL" ) - ), - 'sccpdevice' => array( - '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'), - //'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"), - //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'), - 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"), - 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"), - 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"), - 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"), + $db_config_v0 = array( + 'sccpdevmodel' => array( + 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), + 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'), + 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL") + ), + 'sccpdevice' => array( + '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'), + //'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"), + //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'), + 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), + 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), + 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), + 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), + 'transfer' => array('def_modify' => "on"), + 'cfwdall' => array('def_modify' => "on"), + 'cfwdbusy' => array('def_modify' => "on"), + 'directrtp' => array('def_modify' => "off"), + 'dndFeature' => array('def_modify' => "on"), + 'earlyrtp' => array('def_modify' => "on"), + 'audio_tos' => array('def_modify' => "0xB8"), + 'audio_cos' => array('def_modify' => "6"), + 'video_tos' => array('def_modify' => "0x88"), + 'video_cos' => array('def_modify' => "5"), + 'mwilamp' => array('def_modify' => "on"), + 'mwioncall' => array('def_modify' => "on"), + 'private' => array('def_modify' => "on"), + 'privacy' => array('def_modify' => "off"), + 'nat' => array('def_modify' => "auto"), + 'softkeyset' => array('def_modify' => "softkeyset") + ), + 'sccpline' => array( + 'namedcallgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), + 'namedpickupgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), + 'adhocNumber' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"), + 'meetme' => array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"), + 'meetmenum' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"), + 'meetmeopts' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"), + 'regexten' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"), + 'incominglimit' => array('def_modify' => "2"), + 'transfer' => array('def_modify' => "on"), + 'vmnum' => array('def_modify' => "*97"), + 'musicclass' => array('def_modify' => "default"), + 'echocancel' => array('def_modify' => "on"), + 'silencesuppression' => array('def_modify' => "off"), + 'id' => array('create' => 'VARCHAR( 20 ) NULL DEFAULT NULL', 'modify' => "VARCHAR(20)", 'def_modify' => "NULL"), + 'dnd' => array('create' => 'VARCHAR( 12 ) DEFAULT "reject" AFTER `amaflags`', 'modify' => "VARCHAR(12)", 'def_modify' => "reject") + ) + ); + /* Old */ + $db_config_v5 = array( + 'sccpdevmodel' => array( + 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), + 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'), + 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL") + ), + 'sccpdevice' => array( + 'pickupexten' => array('rename' => "directed_pickup"), + 'directed_pickup' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"), + 'pickupcontext' => array('rename' => "directed_pickup_context"), + 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"), + 'pickupmodeanswer' => array('rename' => "directed_pickup_modeanswer"), + 'directed_pickup_modeanswer' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"), + 'hwlang' => array('rename' => "_hwlang"), + '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'), + 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"), + //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'), + 'dtmfmode' => array('drop' => "yes"), + 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), + 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), + 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), + 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), + 'transfer' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), + 'cfwdall' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), + 'cfwdbusy' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), + 'directrtp' => array('create' => 'VARCHAR(3) DEFAULT "off"', 'modify' => "VARCHAR(3)", 'def_modify' => "off"), + 'dndFeature' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), + 'earlyrtp' => array('create' => 'VARCHAR(10) DEFAULT "progress"', 'modify' => "VARCHAR(10)", 'def_modify' => "progress"), + 'audio_tos' => array('def_modify' => "0xB8"), + 'audio_cos' => array('def_modify' => "6"), + 'video_tos' => array('def_modify' => "0x88"), + 'video_cos' => array('def_modify' => "5"), + 'trustphoneip' => array('drop' => "yes"), + 'mwilamp' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), + 'mwioncall' => array('create' => 'VARCHAR(5) DEFAULT "off"', 'modify' => "VARCHAR(5)", 'def_modify' => "off"), + 'private' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), + 'privacy' => array('create' => 'VARCHAR(100) DEFAULT "full"', 'modify' => "VARCHAR(5)", 'def_modify' => "full"), + 'nat' => array('create' => 'VARCHAR(7) DEFAULT "auto"', 'modify' => "VARCHAR(7)", 'def_modify' => "auto"), + 'softkeyset' => array('def_modify' => "softkeyset") + ), + 'sccpline' => array( + 'namedcallgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), + 'namedpickupgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), + 'adhocNumber' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"), + 'meetme' => array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"), + 'meetmenum' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"), + 'meetmeopts' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"), + 'regexten' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"), + 'rtptos' => array('drop' => "yes"), + 'audio_tos' => array('drop' => "yes"), + 'audio_cos' => array('drop' => "yes"), + 'video_tos' => array('drop' => "yes"), + 'video_cos' => array('drop' => "yes"), + 'incominglimit' => array('def_modify' => "2"), + 'transfer' => array('def_modify' => "on"), + 'vmnum' => array('def_modify' => "*97"), + 'musicclass' => array('def_modify' => "default"), + 'echocancel' => array('def_modify' => "on"), + 'silencesuppression' => array('def_modify' => "off"), + 'dnd' => array('create' => 'VARCHAR( 12 ) DEFAULT "reject" AFTER `amaflags`', 'modify' => "VARCHAR(12)", 'def_modify' => "reject") + ) + ); - 'transfer' =>array('def_modify' => "on"), - 'cfwdall' =>array('def_modify' => "on"), - 'cfwdbusy' =>array('def_modify' => "on"), - 'directrtp' =>array('def_modify' => "off"), - 'dndFeature' =>array('def_modify' => "on"), - 'earlyrtp' =>array('def_modify' => "on"), - 'audio_tos'=>array('def_modify' => "0xB8"), - 'audio_cos'=>array('def_modify' => "6"), - 'video_tos'=>array('def_modify' => "0x88"), - 'video_cos'=>array('def_modify' => "5"), - - 'mwilamp' =>array('def_modify' => "on"), - 'mwioncall' =>array('def_modify' => "on"), - 'private' =>array('def_modify' => "on"), - 'privacy' =>array('def_modify' => "off"), - 'nat' =>array('def_modify' => "auto"), - 'softkeyset' =>array('def_modify' => "softkeyset") - ), - - 'sccpline' => array( - 'namedcallgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), - 'namedpickupgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), - 'adhocNumber' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"), - 'meetme' =>array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"), - 'meetmenum' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"), - 'meetmeopts' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"), - 'regexten' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"), - 'incominglimit' =>array('def_modify' => "2"), - 'transfer' =>array('def_modify' => "on"), - 'vmnum' =>array('def_modify' => "*97"), - 'musicclass' =>array('def_modify' => "default"), - 'echocancel' =>array('def_modify' => "on"), - 'silencesuppression' =>array('def_modify' => "off"), - 'id' =>array('create' => 'VARCHAR( 20 ) NULL DEFAULT NULL', 'modify' => "VARCHAR(20)", 'def_modify' =>"NULL"), - 'dnd' =>array('create' => 'VARCHAR( 12 ) DEFAULT "reject" AFTER `amaflags`', 'modify' => "VARCHAR(12)", 'def_modify' =>"reject") - ) -); -/* Old */ -$db_config_v5 = array( - 'sccpdevmodel' => array( - 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), - 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'), - 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL" ) - ), - 'sccpdevice' => array( - 'pickupexten' => array('rename' => "directed_pickup"), - 'directed_pickup' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"), - 'pickupcontext' => array('rename' => "directed_pickup_context"), - 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"), - 'pickupmodeanswer' => array('rename' => "directed_pickup_modeanswer"), - 'directed_pickup_modeanswer' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"), - 'hwlang' => array('rename' => "_hwlang"), - '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'), - 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"), - - //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'), - 'dtmfmode' => array('drop' => "yes"), - - 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"), - 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"), - 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"), - 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"), - - 'transfer' =>array('create' => 'VARCHAR(5) DEFAULT "on"','modify' => "VARCHAR(5)",'def_modify' => "on"), - 'cfwdall' =>array('create' => 'VARCHAR(5) DEFAULT "on"','modify' => "VARCHAR(5)",'def_modify' => "on"), - 'cfwdbusy' =>array('create' => 'VARCHAR(5) DEFAULT "on"','modify' => "VARCHAR(5)",'def_modify' => "on"), - 'directrtp' =>array('create' => 'VARCHAR(3) DEFAULT "off"','modify' => "VARCHAR(3)",'def_modify' => "off"), - 'dndFeature' =>array('create' => 'VARCHAR(5) DEFAULT "on"','modify' => "VARCHAR(5)",'def_modify' => "on"), - 'earlyrtp' =>array('create' => 'VARCHAR(10) DEFAULT "progress"','modify' => "VARCHAR(10)",'def_modify' => "progress"), - 'audio_tos' =>array('def_modify' => "0xB8"), - 'audio_cos' =>array('def_modify' => "6"), - 'video_tos' =>array('def_modify' => "0x88"), - 'video_cos' =>array('def_modify' => "5"), - 'trustphoneip'=>array('drop' => "yes"), - - 'mwilamp' =>array('create' => 'VARCHAR(5) DEFAULT "on"','modify' => "VARCHAR(5)",'def_modify' => "on"), - 'mwioncall' =>array('create' => 'VARCHAR(5) DEFAULT "off"','modify' => "VARCHAR(5)",'def_modify' => "off"), - 'private' =>array('create' => 'VARCHAR(5) DEFAULT "on"','modify' => "VARCHAR(5)",'def_modify' => "on"), - 'privacy' =>array('create' => 'VARCHAR(100) DEFAULT "full"','modify' => "VARCHAR(5)",'def_modify' => "full"), - 'nat' =>array('create' => 'VARCHAR(7) DEFAULT "auto"','modify' => "VARCHAR(7)",'def_modify' => "auto"), - 'softkeyset' =>array('def_modify' => "softkeyset") - ), - 'sccpline' => array( - 'namedcallgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), - 'namedpickupgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), - 'adhocNumber' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"), - 'meetme' =>array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"), - 'meetmenum' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"), - 'meetmeopts' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"), - 'regexten' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"), - 'rtptos' => array('drop' => "yes"), - 'audio_tos' => array('drop' => "yes"), - 'audio_cos' => array('drop' => "yes"), - 'video_tos' => array('drop' => "yes"), - 'video_cos' => array('drop' => "yes"), - 'incominglimit' =>array('def_modify' => "2"), - 'transfer' =>array('def_modify' => "on"), - 'vmnum' =>array('def_modify' => "*97"), - 'musicclass' =>array('def_modify' => "default"), - 'echocancel' =>array('def_modify' => "on"), - 'silencesuppression' =>array('def_modify' => "off"), - 'dnd' =>array('create' => 'VARCHAR( 12 ) DEFAULT "reject" AFTER `amaflags`', 'modify' => "VARCHAR(12)", 'def_modify' =>"reject") - ) -); - -$db_config_v3 = array( - 'sccpdevmodel' => array( - 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), - 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'), - 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL" ) - ), - 'sccpdevice' => array( - 'pickupexten' => array('rename' => "directed_pickup"), - 'directed_pickup' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), - 'pickupcontext' => array('rename' => "directed_pickup_context"), - 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"), - 'pickupmodeanswer' => array('rename' => "directed_pickup_modeanswer"), - 'directed_pickup_modeanswer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), - 'hwlang' => array('rename' => "_hwlang"), - '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'), - 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"), - - //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'), - 'dtmfmode' => array('drop' => "yes"), - - 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"), - 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"), - 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"), - 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL','modify' => "VARCHAR(255)"), - - 'transfer' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), - 'cfwdall' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), - 'cfwdbusy' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), - 'directrtp' =>array('create' => "enum('on','off') NULL default NULL",'modify' => "enum('on','off')"), - 'dndFeature' =>array('create' => "enum('on','off') NULL default NULL",'modify' => "enum('on','off')"), - 'earlyrtp' =>array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NULL default NULL",'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"), - 'audio_tos'=>array('def_modify' => "0xB8"), - 'audio_cos'=>array('def_modify' => "6"), - 'video_tos'=>array('def_modify' => "0x88"), - 'video_cos'=>array('def_modify' => "5"), - 'trustphoneip'=>array('drop' => "yes"), - - 'mwilamp' =>array('create' => "enum('on','off','wink','flash','blink') NULL default 'on'" ,'modify' => "enum('on','off','wink','flash','blink')"), - 'mwioncall' =>array('create' => "enum('on','off') NULL default 'on'",'modify' => "enum('on','off')"), - 'private' =>array('create' => "enum('on','off') NOT NULL default 'off'",'modify' => "enum('on','off')"), // Что-то лишенне - 'privacy' =>array('create' => "enum('full','on','off') NOT NULL default 'full'",'modify' => "enum('full','on','off')"), // Что-то лишенне - 'nat' =>array('create' => "enum('on','off','auto') NULL default NULL",'modify' => "enum('on','off','auto')"), - 'conf_allow' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), - 'conf_play_part_announce' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), - 'conf_mute_on_entry' =>array('create' => "enum('on','off') NOT NULL default 'off'",'modify' => "enum('on','off')"), - 'conf_show_conflist' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), - - 'type' =>array('create' => 'VARCHAR(15) NULL DEFAULT NULL','modify' => "VARCHAR(15)"), - 'imageversion' =>array('create' => 'VARCHAR(31) NULL DEFAULT NULL','modify' => "VARCHAR(31)"), - - 'softkeyset' =>array('def_modify' => "softkeyset") - ), - 'sccpline' => array( - 'namedcallgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), - 'namedpickupgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), - 'adhocNumber' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"), - 'meetme' =>array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"), - 'meetmenum' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"), - 'meetmeopts' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"), - 'regexten' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"), - 'rtptos' => array('drop' => "yes"), - 'audio_tos' => array('drop' => "yes"), - 'audio_cos' => array('drop' => "yes"), - 'video_tos' => array('drop' => "yes"), - 'video_cos' => array('drop' => "yes"), - 'incominglimit' =>array('create' => "INT(11) DEFAULT '6'", 'modify' =>'INT(11)', 'def_modify' => "6"), - 'transfer' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), - 'vmnum' =>array('def_modify' => "*97"), - 'musicclass' =>array('def_modify' => "default"), - 'id' =>array('create' => 'MEDIUMINT(9) NOT NULL AUTO_INCREMENT, ADD UNIQUE(id);', 'modify' => "MEDIUMINT(9)",'index' =>'id'), + $db_config_v3 = array( + 'sccpdevmodel' => array( + 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), + 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'), + 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL") + ), + 'sccpdevice' => array( + 'pickupexten' => array('rename' => "directed_pickup"), + 'directed_pickup' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'pickupcontext' => array('rename' => "directed_pickup_context"), + 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"), + 'pickupmodeanswer' => array('rename' => "directed_pickup_modeanswer"), + 'directed_pickup_modeanswer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'hwlang' => array('rename' => "_hwlang"), + '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'), + 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"), + //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'), + 'dtmfmode' => array('drop' => "yes"), + 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), + 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), + 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), + 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), + 'transfer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'cfwdall' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'cfwdbusy' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'directrtp' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"), + 'dndFeature' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"), + 'earlyrtp' => array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NULL default NULL", 'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"), + 'audio_tos' => array('def_modify' => "0xB8"), + 'audio_cos' => array('def_modify' => "6"), + 'video_tos' => array('def_modify' => "0x88"), + 'video_cos' => array('def_modify' => "5"), + 'trustphoneip' => array('drop' => "yes"), + 'mwilamp' => array('create' => "enum('on','off','wink','flash','blink') NULL default 'on'", 'modify' => "enum('on','off','wink','flash','blink')"), + 'mwioncall' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"), + 'private' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), // Что-то лишенне + 'privacy' => array('create' => "enum('full','on','off') NOT NULL default 'full'", 'modify' => "enum('full','on','off')"), // Что-то лишенне + 'nat' => array('create' => "enum('on','off','auto') NULL default NULL", 'modify' => "enum('on','off','auto')"), + 'conf_allow' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'conf_play_part_announce' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'conf_mute_on_entry' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'conf_show_conflist' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'type' => array('create' => 'VARCHAR(15) NULL DEFAULT NULL', 'modify' => "VARCHAR(15)"), + 'imageversion' => array('create' => 'VARCHAR(31) NULL DEFAULT NULL', 'modify' => "VARCHAR(31)"), + 'softkeyset' => array('def_modify' => "softkeyset") + ), + 'sccpline' => array( + 'namedcallgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), + 'namedpickupgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), + 'adhocNumber' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"), + 'meetme' => array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"), + 'meetmenum' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"), + 'meetmeopts' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"), + 'regexten' => array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"), + 'rtptos' => array('drop' => "yes"), + 'audio_tos' => array('drop' => "yes"), + 'audio_cos' => array('drop' => "yes"), + 'video_tos' => array('drop' => "yes"), + 'video_cos' => array('drop' => "yes"), + 'incominglimit' => array('create' => "INT(11) DEFAULT '6'", 'modify' => 'INT(11)', 'def_modify' => "6"), + 'transfer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'vmnum' => array('def_modify' => "*97"), + 'musicclass' => array('def_modify' => "default"), + 'id' => array('create' => 'MEDIUMINT(9) NOT NULL AUTO_INCREMENT, ADD UNIQUE(id);', 'modify' => "MEDIUMINT(9)", 'index' => 'id'), // 'id' =>array('create' => 'VARCHAR( 20 ) NULL DEFAULT NULL', 'modify' => "VARCHAR(20)", 'def_modify' =>"NULL"), - - 'echocancel' =>array('create' => "enum('on','off') NOT NULL default 'off'",'modify' => "enum('on','off')"), - 'silencesuppression' =>array('create' => "enum('on','off') NOT NULL default 'off'",'modify' => "enum('on','off')"), - 'dnd' => array('create' => "enum('off','reject','silent','user') NOT NULL default 'reject'", 'modify' => "enum('off','reject','silent','user')", 'def_modify' =>"reject") - ) -); + 'echocancel' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'silencesuppression' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'dnd' => array('create' => "enum('off','reject','silent','user') NOT NULL default 'reject'", 'modify' => "enum('off','reject','silent','user')", 'def_modify' => "reject") + ) + ); if ($sccp_compatible >= 430) { return $db_config_v3; } else { @@ -242,16 +228,17 @@ function CheckSCCPManagerDBTables($table_req) { //print_r("none, creating table :". $value); outn(_("Can't find table: " . $value)); outn(_("Please goto the chan-sccp/conf directory and create the DB schema manually (See wiki)")); - die_freepbx("!!!! Installation error: Can not find required ".$value." table !!!!!!\n"); + die_freepbx("!!!! Installation error: Can not find required " . $value . " table !!!!!!\n"); } } } /* notused */ + function CheckPermissions() { outn("
  • " . _("Checking Filesystem Permissions") . "
  • "); $dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/views'; - if (fileowner($_SERVER['DOCUMENT_ROOT']) != fileowner($dst)){ + if (fileowner($_SERVER['DOCUMENT_ROOT']) != fileowner($dst)) { die_freepbx('Please (re-)check permissions by running "amportal chown. Installation Failed"'); } } @@ -276,7 +263,7 @@ function CheckAsteriskVersion() { } function CheckChanSCCPCompatible() { - global $srvinterface,$astman; + global $srvinterface, $astman; if (!$astman) { ie_freepbx('No asterisk manager connection provided!. Installation Failed'); } @@ -284,8 +271,7 @@ function CheckChanSCCPCompatible() { outn("
  • " . _("Sccp model Compatible code : ") . $sccp_compatible . "
  • "); return $sccp_compatible; } - - + function InstallDB_sccpsettings() { global $db; outn("
  • " . _("Creating sccpsettings table...") . "
  • "); @@ -334,58 +320,58 @@ function InstallDB_updateSchema($db_config) { outn("
  • " . _("Modify Database schema") . "
  • "); foreach ($db_config as $tabl_name => &$tab_modify) { // 0 - name 1-type 4- default - $sql = "DESCRIBE ".$tabl_name.""; - $db_result= $db->getAll($sql); + $sql = "DESCRIBE " . $tabl_name . ""; + $db_result = $db->getAll($sql); if (DB::IsError($db_result)) { - die_freepbx("Can not add get informations from ".$tabl_name." table\n"); + die_freepbx("Can not add get informations from " . $tabl_name . " table\n"); } - foreach ($db_result as $tabl_data){ + foreach ($db_result as $tabl_data) { $fld_id = $tabl_data[0]; if (!empty($tab_modify[$fld_id])) { - $db_config[$tabl_name][$fld_id]['status'] = 'yes'; + $db_config[$tabl_name][$fld_id]['status'] = 'yes'; if (!empty($tab_modify[$fld_id]['def_modify'])) { - if (strtoupper($tab_modify[$fld_id]['def_modify']) == strtoupper($tabl_data[4])) { - $db_config[$tabl_name][$fld_id]['def_mod_stat'] = 'no'; + if (strtoupper($tab_modify[$fld_id]['def_modify']) == strtoupper($tabl_data[4])) { + $db_config[$tabl_name][$fld_id]['def_mod_stat'] = 'no'; } } if (!empty($tab_modify[$fld_id]['modify'])) { - if ( strtoupper ($tab_modify[$fld_id]['modify']) == strtoupper($tabl_data[1])) { - $db_config[$tabl_name][$fld_id]['mod_stat'] = 'no'; + if (strtoupper($tab_modify[$fld_id]['modify']) == strtoupper($tabl_data[1])) { + $db_config[$tabl_name][$fld_id]['mod_stat'] = 'no'; } } if (!empty($tab_modify[$fld_id]['rename'])) { $fld_id_source = $tab_modify[$fld_id]['rename']; - $db_config[$tabl_name][$fld_id_source]['status'] = 'yes'; - $db_config[$tabl_name][$fld_id]['create'] = $db_config[$tabl_name][$fld_id_source]['create']; + $db_config[$tabl_name][$fld_id_source]['status'] = 'yes'; + $db_config[$tabl_name][$fld_id]['create'] = $db_config[$tabl_name][$fld_id_source]['create']; } } } - $sql_create =''; - $sql_modify =''; - $sql_update =''; - - foreach ($tab_modify as $row_fld => $row_data){ + $sql_create = ''; + $sql_modify = ''; + $sql_update = ''; + + foreach ($tab_modify as $row_fld => $row_data) { if (empty($row_data['status'])) { if (!empty($row_data['create'])) { - $sql_create .='ADD COLUMN `'.$row_fld.'` '. $row_data['create'].', '; + $sql_create .= 'ADD COLUMN `' . $row_fld . '` ' . $row_data['create'] . ', '; $count_modify ++; } } else { - if (!empty($row_data['rename'])) { - $sql_modify .= 'CHANGE COLUMN `'.$row_fld.'` `'. $row_data['rename'].'` '.$row_data['create'].', '; + if (!empty($row_data['rename'])) { + $sql_modify .= 'CHANGE COLUMN `' . $row_fld . '` `' . $row_data['rename'] . '` ' . $row_data['create'] . ', '; $count_modify ++; } if (!empty($row_data['modify'])) { if (empty($row_data['mod_stat'])) { if (!empty($row_data['create'])) { // $sql_modify .= "CHANGE COLUMN `".$row_fld."` `".$row_fld."` ".$row_data['create'].", "; - $sql_modify .= "MODIFY COLUMN `".$row_fld."` ".$row_data['create'].", "; + $sql_modify .= "MODIFY COLUMN `" . $row_fld . "` " . $row_data['create'] . ", "; } else { // $sql_modify .= "CHANGE COLUMN `".$row_fld."` `".$row_fld."` ".$row_data['modify']." DEFAULT '".$row_data['def_modify']."', "; - $sql_modify .= "MODIFY COLUMN `".$row_fld."` ".$row_data['modify']." DEFAULT '".$row_data['def_modify']."', "; + $sql_modify .= "MODIFY COLUMN `" . $row_fld . "` " . $row_data['modify'] . " DEFAULT '" . $row_data['def_modify'] . "', "; } - if (strpos($row_data['modify'],'enum') !== false ) { - $sql_update .= "UPDATE ".$tabl_name." set `".$row_fld."`=case when lower(`".$row_fld."`) in ('yes','true','1') then 'on' when lower(`".$row_fld."`) in ('no', 'false', '0') then 'off' else `".$row_fld."` end; "; + if (strpos($row_data['modify'], 'enum') !== false) { + $sql_update .= "UPDATE " . $tabl_name . " set `" . $row_fld . "`=case when lower(`" . $row_fld . "`) in ('yes','true','1') then 'on' when lower(`" . $row_fld . "`) in ('no', 'false', '0') then 'off' else `" . $row_fld . "` end; "; } $row_data['def_mod_stat'] = 'no'; $count_modify ++; @@ -393,24 +379,23 @@ function InstallDB_updateSchema($db_config) { } if (!empty($row_data['def_modify'])) { if (empty($row_data['def_mod_stat'])) { - $sql_modify .= "ALTER COLUMN `".$row_fld."` SET DEFAULT '".$row_data['def_modify']."', "; + $sql_modify .= "ALTER COLUMN `" . $row_fld . "` SET DEFAULT '" . $row_data['def_modify'] . "', "; $count_modify ++; } } - if (!empty($row_data['drop'])) { - $sql_create .='DROP COLUMN `'.$row_fld.'`, '; + if (!empty($row_data['drop'])) { + $sql_create .= 'DROP COLUMN `' . $row_fld . '`, '; $count_modify ++; } - } } if (!empty($sql_update)) { - $sql_update = 'BEGIN; '.$sql_update.' COMMIT;'; + $sql_update = 'BEGIN; ' . $sql_update . ' COMMIT;'; sql($sql_update); $affected_rows = $db->affectedRows(); // $check = $db->query($sql_update); // $db->closeCursor(); - outn("
  • " . _("Update table row :").$affected_rows. "
  • "); + outn("
  • " . _("Update table row :") . $affected_rows . "
  • "); // if (db::IsError($check)) { // die_freepbx("Can not update ".$tabl_name." table sql: ".$sql_update."n"); // die_freepbx("Can not update ".$tabl_name." table\n"); @@ -418,26 +403,26 @@ function InstallDB_updateSchema($db_config) { } if (!empty($sql_create)) { - outn("
  • " . _("Create New table"). "
  • "); - $sql_create = "ALTER TABLE `".$tabl_name."` ". substr($sql_create,0,-2); + outn("
  • " . _("Create New table") . "
  • "); + $sql_create = "ALTER TABLE `" . $tabl_name . "` " . substr($sql_create, 0, -2); $check = $db->query($sql_create); if (db::IsError($check)) { - die_freepbx("Can not create ".$tabl_name." table sql: ".$sql_create."n"); + die_freepbx("Can not create " . $tabl_name . " table sql: " . $sql_create . "n"); } } if (!empty($sql_modify)) { - outn("
  • " . _("Modify table"). "
  • "); + outn("
  • " . _("Modify table") . "
  • "); - $sql_modify = "ALTER TABLE `".$tabl_name."` ". substr($sql_modify,0,-2).';'; + $sql_modify = "ALTER TABLE `" . $tabl_name . "` " . substr($sql_modify, 0, -2) . ';'; $check = $db->query($sql_modify); if (db::IsError($check)) { - out("
  • " . print_r($check,1). "
  • "); - die("Can not modify ".$tabl_name." table sql: ".$sql_modify."n"); - die_freepbx("Can not modify ".$tabl_name." table sql: ".$sql_modify."n"); + out("
  • " . print_r($check, 1) . "
  • "); + die("Can not modify " . $tabl_name . " table sql: " . $sql_modify . "n"); + die_freepbx("Can not modify " . $tabl_name . " table sql: " . $sql_modify . "n"); } } } - outn("
  • " . _("Total modify count :") .$count_modify. "
  • "); + outn("
  • " . _("Total modify count :") . $count_modify . "
  • "); return true; } @@ -445,11 +430,11 @@ function InstallDB_fillsccpdevmodel() { global $db; outn("
  • " . _("Fill sccpdevmodel") . "
  • "); $sql = "REPLACE INTO `sccpdevmodel` (`model`, `vendor`, `dns`, `buttons`, `loadimage`, `loadinformationid`, `enabled`, `nametemplate`) VALUES ('12 SP', 'CISCO', 1, 1, '', 'loadInformation3', 0, NULL)," . - "('12 SP+', 'CISCO', 1, 1, '', 'loadInformation2', 0, NULL), ('30 SP+', 'CISCO', 1, 1, '', 'loadInformation1', 0, NULL), ('30 VIP', 'CISCO', 1, 1, '', 'loadInformation5', 0, NULL), ('3911', 'CISCO', 1, 1, '', 'loadInformation446', 0, NULL), ('3951', 'CISCO', 1, 1, '', 'loadInformation412', 0, ''), ('6901', 'CISCO', 1, 0, 'SCCP6901.9-2-1-a', 'loadInformation547', 0, NULL), ('6911', 'CISCO', 1, 0, 'SCCP6911.9-2-1-a', 'loadInformation548', 0, NULL), ('6921', 'CISCO', 1, 0, 'SCCP69xx.9-2-1-0', 'loadInformation496', 0, NULL), ('6941', 'CISCO', 1, 1, 'SCCP69xx.9-2-1-0', 'loadInformation495', 0, NULL), ('6945', 'CISCO', 1, 0, 'SCCP6945.9-2-1-0', 'loadInformation564', 0, NULL), ('6961', 'CISCO', 1, 0, 'SCCP69xx.9-2-1-0', 'loadInformation497', 0, NULL), ('7902', 'CISCO', 1, 1, 'CP7902080002SCCP060817A', 'loadInformation30008', 0, NULL), " . - "('7905', 'CISCO', 1, 1, 'CP7905080003SCCP070409A', 'loadInformation20000', 0, NULL), ('7906', 'CISCO', 1, 1, 'SCCP11.9-2-1S', 'loadInformation369', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7910', 'CISCO', 1, 1, 'SCCP11.9-2-1S', 'loadInformation6', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7911', 'CISCO', 1, 1, 'SCCP11.9-2-1S', 'loadInformation307', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7912', 'CISCO', 1, 1, 'CP7912080004SCCP080108A', 'loadInformation30007', 0, NULL), ('7914', 'CISCO', 0, 14, 'S00105000400', 'loadInformation124', 1, NULL),('7914,7914', 'CISCO', 0, 28, 'S00105000400', 'loadInformation124', 1, NULL), ('7915', 'CISCO', 0, 24, 'B015-1-0-4', 'loadInformation227', 1, NULL), ('7915,7915', 'CISCO', 0, 48, 'B015-1-0-4', 'loadInformation228', 1, NULL), ('7916', 'CISCO', 0, 24, 'B015-1-0-4', 'loadInformation229', 1, NULL), " . - "('7916,7916', 'CISCO', 0, 48, 'B016-1-0-4', 'loadInformation230', 1, NULL), ('7920', 'CISCO', 1, 1, 'cmterm_7920.4.0-03-02', 'loadInformation30002', 0, NULL), ('7921', 'CISCO', 1, 1, 'CP7921G-1.4.1SR1', 'loadInformation365', 0, NULL),('7925', 'CISCO', 1, 6, 'CP7925G-1.4.1SR1', 'loadInformation484', 0, NULL), ('7926', 'CISCO', 1, 1, 'CP7926G-1.4.1SR1', 'loadInformation557', 0, NULL), ('7931', 'CISCO', 1, 34, 'SCCP31.9-2-1S', 'loadInformation348', 0, NULL), ('7935', 'CISCO', 1, 2, 'P00503021900', 'loadInformation9', 0, NULL), ('7936', 'CISCO', 1, 1, 'cmterm_7936.3-3-21-0', 'loadInformation30019', 0, NULL), ('7937', 'CISCO', 1, 1, 'apps37sccp.1-4-4-0', 'loadInformation431', 0, 'SEP0000000000.cnf.xml_7937_template'), ('7940', 'CISCO', 1, 2, 'P0030801SR02', 'loadInformation8', 1, 'SEP0000000000.cnf.xml_796x_template'), " . - "('7941', 'CISCO', 1, 2, 'SCCP41.9-2-1S', 'loadInformation115', 0, 'SEP0000000000.cnf.xml_796x_template'),('7941G-GE', 'CISCO', 1, 2, 'SCCP41.9-2-1S', 'loadInformation309', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7942', 'CISCO', 1, 2, 'SCCP42.9-2-1S', 'loadInformation434', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7945', 'CISCO', 1, 2, 'SCCP45.9-2-1S', 'loadInformation435', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7960', 'CISCO', 3, 6, 'P0030801SR02', 'loadInformation7', 1, 'SEP0000000000.cnf.xml_796x_template'), ('7961', 'CISCO', 3, 6, 'SCCP41.9-2-1S', 'loadInformation30018', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7961G-GE', 'CISCO', 3, 6, 'SCCP41.9-2-1S', 'loadInformation308', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7962', 'CISCO', 3, 6, 'SCCP42.9-2-1S', 'loadInformation404', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7965', 'CISCO', 3, 6, 'SCCP45.9-2-1S', 'loadInformation436', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7970', 'CISCO', 3, 8, 'SCCP70.9-2-1S', 'loadInformation30006', 0, NULL), ('7971', 'CISCO', 1, 2, 'SCCP75.9-2-1S', 'loadInformation119', 0, NULL), ('7975', 'CISCO', 3, 8, 'SCCP75.9-2-1S', 'loadInformation437', 0, NULL), ('7985', 'CISCO', 3, 8, 'cmterm_7985.4-1-7-0', 'loadInformation302', 0, NULL), ('8941', 'CISCO', 1, 0, 'SCCP894x.9-2-2-0', 'loadInformation586', 0, NULL), ('8945', 'CISCO', 1, 0, 'SCCP894x.9-2-2-0', 'loadInformation585', 0, NULL), ('ATA 186', 'CISCO', 1, 1, 'ATA030204SCCP090202A', 'loadInformation12', 0, NULL), ('ATA 187', 'CISCO', 1, 1, 'ATA187.9-2-3-1', 'loadInformation550', 0, NULL), ('CN622', 'MOTOROLA', 1, 1, '', 'loadInformation335', 0, NULL), ('Digital Access', 'CISCO', 1, 1, 'D001M022', 'loadInformation40', 0, NULL), ('Digital Access+', 'CISCO', 1, 1, 'D00303010033', 'loadInformation42', 0, NULL), ('E-Series', 'NOKIA', 1, 1, '', '', 0, NULL), ('ICC', 'NOKIA', 1, 1, '', '', 0, NULL), " . - "('IP Communicator', 'CISCO', 1, 1, '', 'loadInformation30016', 0, NULL), ('Nokia E', 'Nokia', 0, 28, '', 'loadInformation275', 0, NULL), ('VGC Phone', 'CISCO', 1, 1, '', 'loadInformation10', 0, NULL), ('VGC Virtual', 'CISCO', 1, 1, '', 'loadInformation11', 0, NULL);"; + "('12 SP+', 'CISCO', 1, 1, '', 'loadInformation2', 0, NULL), ('30 SP+', 'CISCO', 1, 1, '', 'loadInformation1', 0, NULL), ('30 VIP', 'CISCO', 1, 1, '', 'loadInformation5', 0, NULL), ('3911', 'CISCO', 1, 1, '', 'loadInformation446', 0, NULL), ('3951', 'CISCO', 1, 1, '', 'loadInformation412', 0, ''), ('6901', 'CISCO', 1, 0, 'SCCP6901.9-2-1-a', 'loadInformation547', 0, NULL), ('6911', 'CISCO', 1, 0, 'SCCP6911.9-2-1-a', 'loadInformation548', 0, NULL), ('6921', 'CISCO', 1, 0, 'SCCP69xx.9-2-1-0', 'loadInformation496', 0, NULL), ('6941', 'CISCO', 1, 1, 'SCCP69xx.9-2-1-0', 'loadInformation495', 0, NULL), ('6945', 'CISCO', 1, 0, 'SCCP6945.9-2-1-0', 'loadInformation564', 0, NULL), ('6961', 'CISCO', 1, 0, 'SCCP69xx.9-2-1-0', 'loadInformation497', 0, NULL), ('7902', 'CISCO', 1, 1, 'CP7902080002SCCP060817A', 'loadInformation30008', 0, NULL), " . + "('7905', 'CISCO', 1, 1, 'CP7905080003SCCP070409A', 'loadInformation20000', 0, NULL), ('7906', 'CISCO', 1, 1, 'SCCP11.9-2-1S', 'loadInformation369', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7910', 'CISCO', 1, 1, 'SCCP11.9-2-1S', 'loadInformation6', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7911', 'CISCO', 1, 1, 'SCCP11.9-2-1S', 'loadInformation307', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7912', 'CISCO', 1, 1, 'CP7912080004SCCP080108A', 'loadInformation30007', 0, NULL), ('7914', 'CISCO', 0, 14, 'S00105000400', 'loadInformation124', 1, NULL),('7914,7914', 'CISCO', 0, 28, 'S00105000400', 'loadInformation124', 1, NULL), ('7915', 'CISCO', 0, 24, 'B015-1-0-4', 'loadInformation227', 1, NULL), ('7915,7915', 'CISCO', 0, 48, 'B015-1-0-4', 'loadInformation228', 1, NULL), ('7916', 'CISCO', 0, 24, 'B015-1-0-4', 'loadInformation229', 1, NULL), " . + "('7916,7916', 'CISCO', 0, 48, 'B016-1-0-4', 'loadInformation230', 1, NULL), ('7920', 'CISCO', 1, 1, 'cmterm_7920.4.0-03-02', 'loadInformation30002', 0, NULL), ('7921', 'CISCO', 1, 1, 'CP7921G-1.4.1SR1', 'loadInformation365', 0, NULL),('7925', 'CISCO', 1, 6, 'CP7925G-1.4.1SR1', 'loadInformation484', 0, NULL), ('7926', 'CISCO', 1, 1, 'CP7926G-1.4.1SR1', 'loadInformation557', 0, NULL), ('7931', 'CISCO', 1, 34, 'SCCP31.9-2-1S', 'loadInformation348', 0, NULL), ('7935', 'CISCO', 1, 2, 'P00503021900', 'loadInformation9', 0, NULL), ('7936', 'CISCO', 1, 1, 'cmterm_7936.3-3-21-0', 'loadInformation30019', 0, NULL), ('7937', 'CISCO', 1, 1, 'apps37sccp.1-4-4-0', 'loadInformation431', 0, 'SEP0000000000.cnf.xml_7937_template'), ('7940', 'CISCO', 1, 2, 'P0030801SR02', 'loadInformation8', 1, 'SEP0000000000.cnf.xml_796x_template'), " . + "('7941', 'CISCO', 1, 2, 'SCCP41.9-2-1S', 'loadInformation115', 0, 'SEP0000000000.cnf.xml_796x_template'),('7941G-GE', 'CISCO', 1, 2, 'SCCP41.9-2-1S', 'loadInformation309', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7942', 'CISCO', 1, 2, 'SCCP42.9-2-1S', 'loadInformation434', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7945', 'CISCO', 1, 2, 'SCCP45.9-2-1S', 'loadInformation435', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7960', 'CISCO', 3, 6, 'P0030801SR02', 'loadInformation7', 1, 'SEP0000000000.cnf.xml_796x_template'), ('7961', 'CISCO', 3, 6, 'SCCP41.9-2-1S', 'loadInformation30018', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7961G-GE', 'CISCO', 3, 6, 'SCCP41.9-2-1S', 'loadInformation308', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7962', 'CISCO', 3, 6, 'SCCP42.9-2-1S', 'loadInformation404', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7965', 'CISCO', 3, 6, 'SCCP45.9-2-1S', 'loadInformation436', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7970', 'CISCO', 3, 8, 'SCCP70.9-2-1S', 'loadInformation30006', 0, NULL), ('7971', 'CISCO', 1, 2, 'SCCP75.9-2-1S', 'loadInformation119', 0, NULL), ('7975', 'CISCO', 3, 8, 'SCCP75.9-2-1S', 'loadInformation437', 0, NULL), ('7985', 'CISCO', 3, 8, 'cmterm_7985.4-1-7-0', 'loadInformation302', 0, NULL), ('8941', 'CISCO', 1, 0, 'SCCP894x.9-2-2-0', 'loadInformation586', 0, NULL), ('8945', 'CISCO', 1, 0, 'SCCP894x.9-2-2-0', 'loadInformation585', 0, NULL), ('ATA 186', 'CISCO', 1, 1, 'ATA030204SCCP090202A', 'loadInformation12', 0, NULL), ('ATA 187', 'CISCO', 1, 1, 'ATA187.9-2-3-1', 'loadInformation550', 0, NULL), ('CN622', 'MOTOROLA', 1, 1, '', 'loadInformation335', 0, NULL), ('Digital Access', 'CISCO', 1, 1, 'D001M022', 'loadInformation40', 0, NULL), ('Digital Access+', 'CISCO', 1, 1, 'D00303010033', 'loadInformation42', 0, NULL), ('E-Series', 'NOKIA', 1, 1, '', '', 0, NULL), ('ICC', 'NOKIA', 1, 1, '', '', 0, NULL), " . + "('IP Communicator', 'CISCO', 1, 1, '', 'loadInformation30016', 0, NULL), ('Nokia E', 'Nokia', 0, 28, '', 'loadInformation275', 0, NULL), ('VGC Phone', 'CISCO', 1, 1, '', 'loadInformation10', 0, NULL), ('VGC Virtual', 'CISCO', 1, 1, '', 'loadInformation11', 0, NULL);"; $check = $db->query($sql); if (db::IsError($check)) { die_freepbx("Can not create sccpdevmodel table, error:$check\n"); @@ -497,8 +482,8 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) { global $db; outn("
  • " . _("(Re)Create sccpdeviceconfig view") . "
  • "); $sql = ""; - if ($sccp_compatible < 431) { - $sql= " + if ($sccp_compatible < 431) { + $sql = " CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpdeviceconfig AS @@ -537,7 +522,7 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) { die_freepbx(sprintf(_("Error updating sccpdeviceconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage())); } return true; -} +} function Setup_RealTime() { global $amp_conf; @@ -545,63 +530,62 @@ function Setup_RealTime() { $cnf_int = \FreePBX::Config(); $cnf_wr = \FreePBX::WriteConfig(); $cnf_read = \FreePBX::LoadConfig(); - $def_config =array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig','sccpline' => ' mysql,sccp,sccpline'); - $def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'], - 'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'], - 'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock'); + $def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline'); + $def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'], + 'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'], + 'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock'); $def_bd_sec = 'sccp'; $dir = $cnf_int->get('ASTETCDIR'); - + $res_conf_old = ''; $res_conf = ''; $ext_conf = ''; - if (file_exists($dir. '/extconfig.conf')) { + if (file_exists($dir . '/extconfig.conf')) { $ext_conf = $cnf_read->getConfig('extconfig.conf'); } - if (!empty($ext_conf)) { + if (!empty($ext_conf)) { $tmp = array(); if (!empty($ext_conf['settings']['sccpdevice'])) { $tmp = explode(',', $ext_conf['settings']['sccpdevice']); - $def_config['sccpdevice']=$ext_conf['settings']['sccpdevice']; - } - if (!empty($ext_conf['settings']['sccpline'])) { - if (empty($tmp)){ - $tmp = explode(',', $ext_conf['settings']['sccpline']); - $tmp[2] ='sccpdevice'; - $def_config['sccpdevice']= implode(',', $tmp); - } - $def_config['sccpline']=$ext_conf['settings']['sccpline']; + $def_config['sccpdevice'] = $ext_conf['settings']['sccpdevice']; } - if (!empty($tmp)){ + if (!empty($ext_conf['settings']['sccpline'])) { + if (empty($tmp)) { + $tmp = explode(',', $ext_conf['settings']['sccpline']); + $tmp[2] = 'sccpdevice'; + $def_config['sccpdevice'] = implode(',', $tmp); + } + $def_config['sccpline'] = $ext_conf['settings']['sccpline']; + } + if (!empty($tmp)) { $def_bd_sec = $tmp[1]; } } $ext_conf['settings']['sccpdevice'] = $def_config['sccpdevice']; $ext_conf['settings']['sccpline'] = $def_config['sccpline']; - if (file_exists($dir. '/res_mysql.conf')) { + if (file_exists($dir . '/res_mysql.conf')) { $res_conf = $cnf_read->getConfig('res_mysql.conf'); if (empty($res_conf[$def_bd_sec])) { - $res_conf[$def_bd_sec] = $def_bd_config; + $res_conf[$def_bd_sec] = $def_bd_config; } - $cnf_wr -> writeConfig('res_mysql.conf', $res_conf,false); + $cnf_wr->writeConfig('res_mysql.conf', $res_conf, false); } - if (file_exists($dir. '/res_config_mysql.conf')) { + if (file_exists($dir . '/res_config_mysql.conf')) { $res_conf = $cnf_read->getConfig('res_config_mysql.conf'); if (empty($res_conf_old[$def_bd_sec])) { - $res_conf[$def_bd_sec] = $def_bd_config; + $res_conf[$def_bd_sec] = $def_bd_config; } - $cnf_wr -> writeConfig('res_config_mysql.conf', $res_conf,false); + $cnf_wr->writeConfig('res_config_mysql.conf', $res_conf, false); } if (empty($res_conf)) { - $res_conf[$def_bd_sec] = $def_bd_config; + $res_conf[$def_bd_sec] = $def_bd_config; $res_conf['general']['dbsock'] = $res_conf[$def_bd_sec]['dbsock']; - $cnf_wr -> writeConfig('res_config_mysql.conf', $res_conf,false); + $cnf_wr->writeConfig('res_config_mysql.conf', $res_conf, false); } - $cnf_wr -> writeConfig('extconfig.conf', $ext_conf,false); - + $cnf_wr->writeConfig('extconfig.conf', $ext_conf, false); } CheckSCCPManagerDBTables($table_req);