diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 8c0bd8d..36b3717 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1002,67 +1002,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $filename; } - function createDefaultSccpConfig() { - // Make sccp.conf data - // [general] - foreach ($this->sccpvalues as $key => $value) { - if ($value['seq'] == 0) { - switch ($key) { - case "allow": - case "disallow": - case "deny": - $this->sccp_conf_init['general'][$key] = explode(';', $value['data']); - break; - case "localnet": - case "permit": - $content = $value['data']; - if (strpos($content, 'internal') !== false) { - $content = str_replace(';0.0.0.0/0.0.0.0', '', $value['data']); - } - $this->sccp_conf_init['general'][$key] = explode(';', $content); - break; - case "devlang": - /* - $lang_data = $this->extconfigs->getExtConfig('sccp_lang', $value['data']); - if (!empty($lang_data)) { - // TODO: will always get here, but lang_data['codepage'] will be empty as not a valid key - $this->sccp_conf_init['general']['phonecodepage'] = $lang_data['codepage']; - } - break; - */ - case "netlang": // Remove Key - case "tftp_path": - case "sccp_compatible": // This is equal to SccpDBmodel - break; - default: - if (!empty($value['data'])) { - $this->sccp_conf_init['general'][$key] = $value['data']; - } - } - } - } - // [Namesoftkeyset] - // type=softkeyset - // - // ----- It is a very bad idea to add an external configuration file "sccp_custom.conf" !!!! - // This will add problems when solving problems caused by unexpected solutions from users. - // - if (file_exists($this->sccppath["asterisk"] . "/sccp_custom.conf")) { - $this->sccp_conf_init['HEADER'] = array( - "; ;", - "; It is a very bad idea to add an external configuration file !!!! ;", - "; This will add problems when solving problems caused by unexpected solutions ;", - "; from users. ;", - ";--------------------------------------------------------------------------------;", - "#include sccp_custom.conf" - ); - } - // ----- It is a very bad idea to add an external configuration file "sccp_custom.conf" !!!! - // TODO: Should only rewrite the general section - if users have extensions, this may overwrite - // Should read first and then rewrite all existing sections. - $this->cnf_wr->writeConfig('sccp.conf', $this->sccp_conf_init); - } - function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) { $file_ext = array('.loads', '.sbn', '.bin', '.zup', '.sbin', '.SBN', '.LOADS'); $dir = $this->sccppath['tftp_firmware_path']; diff --git a/conf/sccp.conf b/conf/sccp.conf index 52af4a5..2923196 100644 --- a/conf/sccp.conf +++ b/conf/sccp.conf @@ -41,10 +41,3 @@ hotline_context=default hotline_extension=111 devicetable=sccpdevice linetable=sccpline - -[KeySet1] ; Managed by sccp_manager -type=softkeyset -onhook=redial,newcall,cfwdall,dnd,pickup,gpickup,private -connected=hold,endcall,park,select,cfwdall,cfwdbusy -onhold=newcall - diff --git a/install.php b/install.php index ef92b19..a42b5f0 100644 --- a/install.php +++ b/install.php @@ -15,6 +15,8 @@ global $settingsFromDb; global $thisInstaller; global $cnf_int; global $sccp_compatible; +global $cnf_wr; + $mobile_hw = '0'; $autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT" : "AUTO_INCREMENT"; $table_req = array('sccpdevice', 'sccpline', 'sccpsettings'); @@ -1065,6 +1067,7 @@ function cleanUpSccpSettings() { global $aminterface; global $sccp_compatible; global $amp_conf; + global $cnf_int; // Get current default settings from db $stmt = $db->prepare("SELECT keyword, sccpsettings.* FROM sccpsettings"); @@ -1220,6 +1223,10 @@ function cleanUpSccpSettings() { )"; $results = $db->query($sql); } + + // Now correct sccp.conf to replace any illegal settings + $thisInstaller->createDefaultSccpConfig($settingsFromDb, $cnf_int->get('ASTETCDIR')); + // have to correct prior verion sccpline lists for allow/disallow and deny permit. Prior // versions used csl, but chan-sccp expects ; separated lists when returned by db. diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 3cd6859..ed62cc2 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -247,7 +247,7 @@ trait ajaxHelper { if (!empty($request['softkey'])) { $id_name = $request['softkey']; unset($this->sccp_conf_init[$id_name]); - $this->createDefaultSccpConfig(); + $this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]); $msg = print_r($this->aminterface->core_sccp_reload(), 1); return array('status' => true, 'table_reload' => true); } @@ -261,7 +261,7 @@ trait ajaxHelper { $this->sccp_conf_init[$id_name][$keyl] = $request[$keyl]; } } - $this->createDefaultSccpConfig(); + $this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]); // !TODO!: -TODO-: Check SIP Support Enabled $this->createSccpXmlSoftkey(); @@ -515,8 +515,8 @@ trait ajaxHelper { foreach ($dbSaveArray as $key => $rowToSave) { $this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']); } - - $this->createDefaultSccpConfig(); // Rewrite Config. + // rewrite sccp.conf + $this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]); $save_settings[] = array('status' => true, ); $this->createDefaultSccpXml(); diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index b30cebb..03d5b6a 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -274,6 +274,87 @@ trait helperfunctions { unset($sysConfig); } + public function createDefaultSccpConfig(array $sccpvalues, string $asteriskPath) { + global $cnf_wr; + // Make sccp.conf data + // [general] section + // TODO: Need to review sccpsettings seq numbering, as will speed this up, and remove the need for $permittedSettings. + $cnf_wr = \FreePBX::WriteConfig(); + //clear old settings, and initiate with allow/disallow and permit/deny keys in correct order + $this->sccp_conf_init = array(); + $this->sccp_conf_init['general']['disallow'] = 'all'; + $this->sccp_conf_init['general']['allow'] = ''; + $this->sccp_conf_init['general']['deny'] = '0.0.0.0/0.0.0.0'; + $this->sccp_conf_init['general']['permit'] = '0.0.0.0/0.0.0.0'; + // permitted chan-sccp settings array + $permittedSettings = array( + 'debug', 'servername', 'keepalive', 'context', 'dateformat', 'bindaddr', 'port', 'secbindaddr', 'secport', 'disallow', 'allow', 'deny', 'permit', + 'localnet', 'externip', 'externrefresh', 'firstdigittimeout', 'digittimeout', 'digittimeoutchar', 'recorddigittimeoutchar', 'simulate_enbloc', + 'ringtype', 'autoanswer_ring_time', 'autoanswer_tone', 'remotehangup_tone', 'transfer', 'transfer_tone', 'transfer_on_hangup', 'dnd_tone', + 'callwaiting_tone', 'callwaiting_interval', 'musicclass', 'language', 'callevents', 'accountcode', 'sccp_tos', 'sccp_cos', 'audio_tos', + 'audio_cos', 'video_tos', 'video_cos', 'echocancel', 'silencesuppression', 'earlyrtp', 'dndFeature', 'private', 'mwilamp', 'mwioncall', + 'cfwdall', 'cfwdbusy', 'cfwdnoanswer', 'cfwdnoanswer_timeout', 'nat', 'directrtp', 'allowoverlap', 'pickup_modeanswer', + 'callhistory_answered_elsewhere', 'amaflags', 'callanswerorder', 'devicetable', 'linetable', 'meetmeopts', 'jbenable', 'jbforce', + 'jblog', 'jbmaxsize', 'jbresyncthreshold', 'jbimpl', 'hotline_enabled', 'hotline_extension', 'hotline_context', 'hotline_label', 'fallback', + 'backoff_time', 'server_priority'); + + foreach ($sccpvalues as $key => $value) { + if (!in_array($key, $permittedSettings, true)) { + continue; + } + if ($value['seq'] == 0) { + switch ($key) { + case "allow": + case "disallow": + case "deny": + $this->sccp_conf_init['general'][$key] = explode(';', $value['data']); + break; + case "localnet": + case "permit": + $content = $value['data']; + if (strpos($content, 'internal') !== false) { + $content = str_replace(';0.0.0.0/0.0.0.0', '', $value['data']); + } + $this->sccp_conf_init['general'][$key] = explode(';', $content); + break; + case "devlang": + /* + $lang_data = $this->extconfigs->getExtConfig('sccp_lang', $value['data']); + if (!empty($lang_data)) { + // TODO: will always get here, but lang_data['codepage'] will be empty as not a valid key + $this->sccp_conf_init['general']['phonecodepage'] = $lang_data['codepage']; + } + break; + */ + case "netlang": // Remove Key + case "tftp_path": + case "sccp_compatible": // This is equal to SccpDBmodel + break; + default: + if (!empty($value['data'])) { + $this->sccp_conf_init['general'][$key] = $value['data']; + } + } + } + } + // + // ----- It is a very bad idea to add an external configuration file "sccp_custom.conf" !!!! + // This will complicate solving problems caused by unexpected solutions from users. + // + if (file_exists($asteriskPath . "/sccp_custom.conf")) { + $this->sccp_conf_init['HEADER'] = array( + "; ;", + "; It is a very bad idea to add an external configuration file !!!! ;", + "; This will complicate solving problems caused by unexpected solutions ;", + "; from users. ;", + ";--------------------------------------------------------------------------------;", + "#include sccp_custom.conf" + ); + } + $cnf_wr->WriteConfig('sccp.conf', $this->sccp_conf_init); + //$this->$cnf_wr->writeConfig('sccp.conf', $this->sccp_conf_init); + } + public function initVarfromXml() { if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group') as $item) { diff --git a/sccpManagerUpdater.json b/sccpManagerUpdater.json index 40814a1..330f055 100644 --- a/sccpManagerUpdater.json +++ b/sccpManagerUpdater.json @@ -2,7 +2,7 @@ "rawname": "sccp_manager", "repo": "stable", "name": "Sccp Manager", - "version": "14.3.0.19", + "version": "14.3.0.20", "publisher": "Steve Lad", "license": "GPL", "licenselink": "http://www.gnu.org/licenses/gpl.txt", @@ -15,7 +15,7 @@ "supported": { "version": "13.0" }, - "location": "https://github.com/chan-sccp/sccp_manager/archive/refs/tags/v14.3.0.19.tar.gz", - "md5sum": "d9d96ada20338e7e88ac8eb4681ca8b3", - "packaged": "1640775011" + "location": "https://github.com/chan-sccp/sccp_manager/archive/refs/tags/v14.3.0.20.tar.gz", + "md5sum": "5bade17a4df09da91bc4436d8e359fc1", + "packaged": "1640854870" }