Finalise TFTP Mapping treatment

User no longer can select on or pro: If remapping is enabled and rules are set, then must use pro or phones will not find files
Otherwise is Off (flat directory)
This commit is contained in:
steve-lad 2021-07-12 12:26:56 +02:00
parent 5a184ededb
commit 651f3adb44
11 changed files with 88 additions and 93 deletions

View file

@ -749,7 +749,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
/** /**
* Retrieve Active Codecs * Retrieve Active Codecs
* return fiends Lag pack * return finds Languageg pack
*/ */
private function initTftpLang() { private function initTftpLang() {

View file

@ -1165,7 +1165,9 @@ and open the template in the editor. Base Version before all crash :-)
<element type='p'>This section is responsible for the modes of operation of external services: tftp http.</element> <element type='p'>This section is responsible for the modes of operation of external services: tftp http.</element>
<element type='p'> * off - Flat model cisco. All data is in the directory TFTP Server Path</element> <element type='p'> * off - Flat model cisco. All data is in the directory TFTP Server Path</element>
<element type='p'> * Provision - The directory structure is strictly defined in the manager. Requires tftpd mapping support.</element> <element type='p'> * Provision - The directory structure is strictly defined in the manager. Requires tftpd mapping support.</element>
<element type='p'> * Custom - TFTP Directory structure can be extended by index.cnf. This supports phones that can work on tftp and http. Remapping support is required</element> <element type='p'> The mode is determined by Sccp_manager based on the presence of a mapping file in TFTP defaults</element>
<element type='p'> and must be the same as the tftp server, or the phones will not find required files</element>
<element type='p'> To change the mode, add or remove the -m option.</element>
</item> </item>
<label>SCCP Server Path config</label> <label>SCCP Server Path config</label>
<item type="IE" id="1" seq="2"> <item type="IE" id="1" seq="2">
@ -1188,18 +1190,14 @@ and open the template in the editor. Base Version before all crash :-)
</input> </input>
<help>Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision"</help> <help>Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision"</help>
</item> </item>
<item type="IS" id="21" seq="20"> <item type="ISC" id="21" seq="20">
<name>tftp_rewrite</name> <name>tftp_rewrite</name>
<label>TFTP SERVER remapping support</label> <label>TFTP SERVER remapping support</label>
<default>off</default> <default>off</default>
<option_hide class=".custom_hide">custom</option_hide>
<option_show class=".custom_show">custom</option_show>
<option_disable class=".custom_disable">Custom</option_disable>
<option_disable class=".provision_disable">Provision</option_disable> <option_disable class=".provision_disable">Provision</option_disable>
<option_disable class=".off_disable">Off</option_disable> <option_disable class=".off_disable">Off</option_disable>
<button value="off">Off</button> <button value="off">Off</button>
<button value="pro">Provision</button> <button value="pro">Provision</button>
<button value="custom">Custom</button>
<help>Support the use of regular-expression-based filename remapping</help> <help>Support the use of regular-expression-based filename remapping</help>
</item> </item>
<item type="IE" id="2"> <item type="IE" id="2">

View file

@ -179,7 +179,7 @@ ri ^(ATA030204SCCP090202A.zup)$ firmware/ata186/\1
# settings # settings
# Do not disable the first rule - this is required by sccp_manager # Do not disable the first rule - this is required by sccp_manager
#ri ^(.+\.tlzz)?$ settings/\1 ri ^(.+\.tlzz)?$ settings/\1
#ri ^(.+\.tlv)?$ settings/\1 #ri ^(.+\.tlv)?$ settings/\1
#ri ^\/(.+\.tlv)?$ settings/\1 #ri ^\/(.+\.tlv)?$ settings/\1
#ri ^((.+\.cnf.xml)(\.enc)?(\.sgn)?)$ settings/\1 #ri ^((.+\.cnf.xml)(\.enc)?(\.sgn)?)$ settings/\1

View file

@ -854,6 +854,11 @@ function checkTftpServer() {
global $thisInstaller; global $thisInstaller;
$confDir = $cnf_int->get('ASTETCDIR'); $confDir = $cnf_int->get('ASTETCDIR');
$tftpRootPath = ""; $tftpRootPath = "";
// put the rewrite rules into the required location
if (file_exists("{$confDir}/sccpManagerRewrite.rules")) {
rename("{$confDir}/sccpManagerRewrite.rules", "{$confDir}/sccpManagerRewrite.rules.bu");
}
copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules',"{$confDir}/sccpManagerRewrite.rules");
// TODO: add option to use external server // TODO: add option to use external server
$remoteFileName = ".sccp_manager_installer_probe_sentinel_temp".mt_rand(0, 9999999); $remoteFileName = ".sccp_manager_installer_probe_sentinel_temp".mt_rand(0, 9999999);
@ -873,9 +878,7 @@ function checkTftpServer() {
$tftpRootPath = $dirToTest; $tftpRootPath = $dirToTest;
outn("<li>" . _("Found ftp root dir at {$tftpRootPath}") . "</li>"); outn("<li>" . _("Found ftp root dir at {$tftpRootPath}") . "</li>");
if ($settingsFromDb['tftp_path']['data'] != $tftpRootPath) { if ($settingsFromDb['tftp_path']['data'] != $tftpRootPath) {
$settingsToDb["tftp_path"] = array( 'keyword' => 'tftp_path', 'seq' => 2, 'type' => 0, 'data' => $tftpRootPath); $settingsFromDb["tftp_path"] = array( 'keyword' => 'tftp_path', 'seq' => 2, 'type' => 0, 'data' => $tftpRootPath, 'systemdefault' => '');
// Need to set the new value here to pass to extconfigs below
$settingsFromDb['tftp_path']['data'] = $tftpRootPath;
} }
// Found sentinel file. Remove it and exit loop // Found sentinel file. Remove it and exit loop
if (file_exists($tempFile)) { if (file_exists($tempFile)) {
@ -893,27 +896,19 @@ function checkTftpServer() {
die_freepbx(_("Either TFTP server is down or TFTP root is non standard. Please fix, refresh, and try again")); die_freepbx(_("Either TFTP server is down or TFTP root is non standard. Please fix, refresh, and try again"));
} }
$settingsToDb['asterisk_etc_path'] = array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir); $settingsFromDb['asterisk_etc_path'] = array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir, 'systemdefault' => '');
$settingsFromDb['asterisk_etc_path'] = $settingsToDb['asterisk_etc_path'];
foreach ($settingsToDb as $settingToSave) { // Get TFTP mapping Status
$sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']});"; $settingsFromDb['tftp_rewrite'] = array('keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 0, 'data' => 'off', 'systemdefault' => '');
$results = $db->query($sql); if (\FreePbx::Sccp_manager()->checkTftpMapping()) {
if (DB::IsError($results)) { $settingsFromDb['tftp_rewrite']['data'] = 'pro';
die_freepbx(_("Error updating sccpsettings. $sql"));
}
unset($settingsToDb[$settingToSave['keyword']]);
} }
// put the rewrite rules into the required location
if (file_exists("{$confDir}/sccpManagerRewrite.rules")) {
rename("{$confDir}/sccpManagerRewrite.rules", "{$confDir}/sccpManagerRewrite.rules.bu");
}
copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules',"{$confDir}/sccpManagerRewrite.rules");
$settingsToDb = $extconfigs->updateTftpStructure($settingsFromDb);
foreach ($settingsToDb as $settingKey => $settingVal) { // Populate TFTP paths in SccpSettings
$settingsFromDb[$settingKey]['data'] = $settingVal; $settingsFromDb = $extconfigs->updateTftpStructure($settingsFromDb);
$sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingKey}', '{$settingVal}', 20, 0)";
foreach ($settingsFromDb as $settingToSave) {
$sql = "REPLACE INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']}, '{$settingToSave['systemdefault']}')";
$results = $db->query($sql); $results = $db->query($sql);
if (DB::IsError($results)) { if (DB::IsError($results)) {
die_freepbx(_("Error updating sccpsettings. $sql")); die_freepbx(_("Error updating sccpsettings. $sql"));
@ -1014,7 +1009,7 @@ function cleanUpSccpSettings() {
} }
} }
// Override certain chan-sccp defaults as they are based on a non-FreePbx system // Override certain chan-sccp defaults as they are based on a non-FreePbx system
$settingsFromDb['context']['systemdefault'] = 'from-internal' $settingsFromDb['context']['systemdefault'] = 'from-internal';
unset($sysConfiguration[$key]); unset($sysConfiguration[$key]);
} }

View file

@ -1,7 +1,7 @@
<module> <module>
<rawname>sccp_manager</rawname> <rawname>sccp_manager</rawname>
<name>SCCP Manager</name> <name>SCCP Manager</name>
<version>14.3.0.1</version> <version>14.3.0.0</version>
<type>setup</type> <type>setup</type>
<category>SCCP Connectivity</category> <category>SCCP Connectivity</category>
<publisher>Steve Lad, Alex GP</publisher> <publisher>Steve Lad, Alex GP</publisher>

View file

@ -280,7 +280,7 @@ class extconfigs
'tftp_dialplan_path' => 'dialplan', 'tftp_dialplan_path' => 'dialplan',
'tftp_softkey_path' => 'softkey' 'tftp_softkey_path' => 'softkey'
); );
$base_config = array(); $baseConfig = array();
if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) { if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) {
// Have a setting in sccpsettings. It should start with $tftp_path // Have a setting in sccpsettings. It should start with $tftp_path
@ -288,8 +288,7 @@ class extconfigs
if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$settingsFromDb['tftp_path']['data'])) { if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$settingsFromDb['tftp_path']['data'])) {
$adv_ini = "{$settingsFromDb['tftp_path']['data']}/index.cnf"; $adv_ini = "{$settingsFromDb['tftp_path']['data']}/index.cnf";
$settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path']; $settingsFromDb['tftp_rewrite_path']['data'] = $settingsFromDb['tftp_path']['data'];
$settingsToDb['tftp_rewrite_path']['data'] = $settingsFromDb['tftp_path']['data'];
} }
$adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf"; $adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf";
} }
@ -313,17 +312,14 @@ class extconfigs
fwrite($indexFile, "{$advKey} = {$advVal}\n"); fwrite($indexFile, "{$advKey} = {$advVal}\n");
} }
fclose($indexFile); fclose($indexFile);
$settingsFromDb['tftp_rewrite']['data'] = 'pro';
$settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'pro', 'systemdefault' => '');
break; break;
case 'unavailable':
$settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'unavailable', 'systemdefault' => '');
case 'on': case 'on':
case 'internal': case 'internal':
case 'off': case 'off':
default: default:
// not defined so set here to off // not defined so set here to off
$settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off', 'systemdefault' => ''); $settingsFromDb['tftp_rewrite']['data'] = 'off';
} }
foreach ($adv_tree[$adv_tree_mode] as $key => $value) { foreach ($adv_tree[$adv_tree_mode] as $key => $value) {
@ -339,43 +335,31 @@ class extconfigs
} }
foreach ($base_tree as $key => $value) { foreach ($base_tree as $key => $value) {
$base_config[$key] = $adv_config[$value]; $baseConfig[$key] = $adv_config[$value];
// Save to sccpsettings if (!is_dir($baseConfig[$key])) {
$settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value], 'systemdefault' => ''); if (!mkdir($baseConfig[$key], 0755, true)) {
if (!is_dir($base_config[$key])) { die_freepbx(_("Error creating dir: $baseConfig[$key]"));
if (!mkdir($base_config[$key], 0755, true)) {
die_freepbx(_('Error creating dir : ' . $base_config[$key]));
} }
} }
} }
// Set up tftproot/settings so that can test if mapping is Enabled and configured. // Set up tftproot/settings so that can test if mapping is Enabled and configured.
if (!is_dir("{$settingsFromDb['tftp_path']['data']}/settings")) { if (!is_dir("{$settingsFromDb['tftp_path']['data']}/settings")) {
if (!mkdir("{$settingsFromDb['tftp_path']['data']}/settings", 0755, true)) { if (!mkdir("{$settingsFromDb['tftp_path']['data']}/settings", 0755, true)) {
die_freepbx(_('Error creating dir : ' . $base_config[$key])); die_freepbx(_("Error creating dir: {$settingsFromDb['tftp_path']['data']}/settings"));
} }
} }
// TODO: Need to add index.cnf, after setting defaults correctly // TODO: Need to add index.cnf, after setting defaults correctly
if (!file_exists($base_config["tftp_templates_path"] . '/XMLDefault.cnf.xml_template')) { if (!file_exists("{$baseConfig['tftp_templates_path']}/XMLDefault.cnf.xml_template")) {
$src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; $src_path = "{$_SERVER['DOCUMENT_ROOT']}/admin/modules/sccp_manager/conf/";
$dst_path = $base_config["tftp_templates_path"] . '/'; $dst_path = "{$baseConfig["tftp_templates_path"]}/";
foreach (glob($src_path . '*.*_template') as $filename) { foreach (glob("{$src_path}*.*_template") as $filename) {
copy($filename, $dst_path . basename($filename)); copy($filename, $dst_path . basename($filename));
} }
} }
// Remove keys that are not required before returning $base_config. foreach ($baseConfig as $baseKey => $baseValue) {
unset($base_config['asterisk'], $base_config['sccp_conf'], $base_config['tftp_path']); $settingsFromDb[$baseKey] = array('keyword' => $baseKey, 'seq' => 20, 'type' => 0, 'data' => $baseValue, 'systemdefault' => '');
return $settingsToDb;
}
private function initializeTFtpLanguagePath() {
$dir = $this->sccppath["tftp_lang_path"];
foreach ($this->extconfigs->getExtConfig('sccp_lang') as $lang_key => $lang_value) {
$filename = $dir . DIRECTORY_SEPARATOR . $lang_value['locale'];
if (!file_exists($filename)) {
if (!mkdir($filename, 0777, true)) {
die('Error creating tftp language directory');
}
}
} }
return $settingsFromDb;
} }
public function validate_RealTime( $connector ) public function validate_RealTime( $connector )

View file

@ -328,7 +328,7 @@ class formcreate
<?php <?php
} }
function addElementIS($child, $fvalues, $sccp_defaults,$npref) { function addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons) {
if ($npref == 'sccp_hw_') { if ($npref == 'sccp_hw_') {
$this->buttonDefLabel = 'site'; $this->buttonDefLabel = 'site';
$this->buttonHelpLabel = 'device'; $this->buttonHelpLabel = 'device';
@ -449,14 +449,7 @@ class formcreate
} }
$opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" ';
} }
// If TFTP remapping is not available, disable options that require it
$disabledButtons = array();
if (($child['id'] == 21) && ($sccp_defaults['tftp_rewrite']['data'] == 'unavailable')) {
$disabledButtons = (array)$child->option_disable;
$unavailableButton = $child->addChild('button','Unavailable');
$unavailableButton->addAttribute('value', 'unavailable');
dbug('',$child);
}
foreach ($child->xpath('button') as $value) { foreach ($child->xpath('button') as $value) {
$opt_disabled = ''; $opt_disabled = '';

View file

@ -387,6 +387,7 @@ trait ajaxHelper {
} }
function handleSubmit($request, $validateonly = false) { function handleSubmit($request, $validateonly = false) {
dbug('',$request);
$hdr_prefix = 'sccp_'; $hdr_prefix = 'sccp_';
$hdr_arprefix = 'sccp-ar_'; $hdr_arprefix = 'sccp-ar_';
$save_settings = array(); $save_settings = array();
@ -448,15 +449,16 @@ trait ajaxHelper {
$key = (str_replace($hdr_prefix, '', $key, $count_mods)); $key = (str_replace($hdr_prefix, '', $key, $count_mods));
if ($count_mods) { if ($count_mods) {
if (!empty($this->sccpvalues[$key]) && (!($this->sccpvalues[$key]['data'] == $value))) { if (!empty($this->sccpvalues[$key]) && ($this->sccpvalues[$key]['data'] != $value)) {
$save_settings[$this->sccpvalues[$key]['keyword']] = array( $save_settings[$key] = array(
'keyword' => $this->sccpvalues[$key]['keyword'], 'keyword' => $key,
'data' => $value, 'data' => $value,
'seq' => $this->sccpvalues[$key]['seq'], 'seq' => $this->sccpvalues[$key]['seq'],
'type' => $this->sccpvalues[$key]['type'], 'type' => $this->sccpvalues[$key]['type'],
'systemdefault' => $this->sccpvalues[$key]['systemdefault'] 'systemdefault' => $this->sccpvalues[$key]['systemdefault']
); );
} }
} }
$key = (str_replace($hdr_arprefix, '', $key, $count_mods)); $key = (str_replace($hdr_arprefix, '', $key, $count_mods));
if ($count_mods) { if ($count_mods) {
@ -488,8 +490,8 @@ trait ajaxHelper {
$arr_data = substr($arr_data, 0, -1); $arr_data = substr($arr_data, 0, -1);
} }
if (!($this->sccpvalues[$key]['data'] == $arr_data)) { if (!($this->sccpvalues[$key]['data'] == $arr_data)) {
$save_settings[] = array( $save_settings[$key] = array(
'keyword' => $this->sccpvalues[$key]['keyword'], 'keyword' => $key,
'data' => $arr_data, 'data' => $arr_data,
'seq' => $this->sccpvalues[$key]['seq'], 'seq' => $this->sccpvalues[$key]['seq'],
'type' => $this->sccpvalues[$key]['type'], 'type' => $this->sccpvalues[$key]['type'],
@ -506,7 +508,7 @@ trait ajaxHelper {
}; };
$tmpv = implode(",", $save_codec); $tmpv = implode(",", $save_codec);
if (!($this->sccpvalues['allow']['data'] == $tmpv)) { if (!($this->sccpvalues['allow']['data'] == $tmpv)) {
$save_settings[] = array( $save_settings['allow'] = array(
'keyword' => 'allow', 'keyword' => 'allow',
'data' => $tmpv, 'data' => $tmpv,
'seq' => $this->sccpvalues['allow']['seq'], 'seq' => $this->sccpvalues['allow']['seq'],
@ -525,7 +527,7 @@ trait ajaxHelper {
$TZdata = $this->extconfigs->getExtConfig('sccp_timezone', $tz_id); $TZdata = $this->extconfigs->getExtConfig('sccp_timezone', $tz_id);
if (!empty($TZdata)) { if (!empty($TZdata)) {
$value = $TZdata['offset']/60; $value = $TZdata['offset']/60;
$save_settings[] = array( $save_settings['tzoffset'] = array(
'keyword' => 'tzoffset', 'keyword' => 'tzoffset',
'data' => $value, 'data' => $value,
'seq' => '98', 'seq' => '98',
@ -539,6 +541,7 @@ trait ajaxHelper {
$extSettings = $this->extconfigs->updateTftpStructure(array_merge($this->sccpvalues, $save_settings)); $extSettings = $this->extconfigs->updateTftpStructure(array_merge($this->sccpvalues, $save_settings));
$save_settings = array_merge($save_settings, $extSettings); $save_settings = array_merge($save_settings, $extSettings);
dbug('saveSettingsAfter', $save_settings);
if (!empty($save_settings)) { if (!empty($save_settings)) {
$this->saveSccpSettings($save_settings); $this->saveSccpSettings($save_settings);
$this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); $this->sccpvalues = $this->dbinterface->get_db_SccpSetting();

View file

@ -221,7 +221,7 @@ trait helperfunctions {
$tftpInfo = explode(',',$tftpInfo[0]); $tftpInfo = explode(',',$tftpInfo[0]);
$info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => 'Mapping not available'); $info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => 'Mapping not available');
$tftpInfo[1] = trim($tftpInfo[1]); $tftpInfo[1] = trim($tftpInfo[1]);
$this->sccpvalues['tftp-rewrite']['data'] = 'unavailable'; $this->sccpvalues['tftp_rewrite']['data'] = 'off';
if ($tftpInfo[1] == 'with remap') { if ($tftpInfo[1] == 'with remap') {
$info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => $tftpInfo[1]); $info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => $tftpInfo[1]);
@ -232,20 +232,23 @@ trait helperfunctions {
// write a sentinel to a tftp subdirectory to see if mapping is working // write a sentinel to a tftp subdirectory to see if mapping is working
if (is_dir($testFtpDir) && is_writable($testFtpDir)) { if (is_dir($testFtpDir) && is_writable($testFtpDir)) {
// TODO: Need to be sure that installer creates this directory
$tempFile = "${testFtpDir}/{$remoteFileName}"; $tempFile = "${testFtpDir}/{$remoteFileName}";
file_put_contents($tempFile, $remoteFileContent); file_put_contents($tempFile, $remoteFileContent);
// try to pull the written file through tftp. // try to pull the written file through tftp.
// this way we can determine if mapping is active and using sccp_manager maps // this way we can determine if mapping is active and using sccp_manager maps
if ($remoteFileContent != $this->tftpReadTestFile($remoteFileName)) { if ($remoteFileContent == $this->tftpReadTestFile($remoteFileName)) {
//found the file and contents are correct
$this->sccpvalues['tftp_rewrite']['data'] = 'pro';
} else {
// Did not find sentinel so mapping not available // Did not find sentinel so mapping not available
$this->sccpvalues['tftp_rewrite']['data'] = 'unavailable'; $this->sccpvalues['tftp_rewrite']['data'] = 'off';
} }
unlink($tempFile); unlink($tempFile);
} }
return true;
} }
} }
return false;
} }
// temporary helper function to save xml with proper indentation // temporary helper function to save xml with proper indentation
public function saveXml($xml, $filename) { public function saveXml($xml, $filename) {

View file

@ -50,6 +50,7 @@ if ($h_show==1) {
} }
foreach ($items as $child) { foreach ($items as $child) {
$disabledButtons = array();
if (empty($child->help)) { if (empty($child->help)) {
$child->help = 'Help is not available.'; $child->help = 'Help is not available.';
$child->meta_help = '1'; $child->meta_help = '1';
@ -62,8 +63,14 @@ foreach ($items as $child) {
case 'IED': case 'IED':
\FreePbx::sccp_manager()->formcreate->addElementIED($child, $fvalues, $sccp_defaults,$npref, $napref); \FreePbx::sccp_manager()->formcreate->addElementIED($child, $fvalues, $sccp_defaults,$npref, $napref);
break; break;
case 'ISC':
// This is a special case for Provision mode. Set some parameters here and fall through to IS.
$disabledButtons = array('pro' => 'Provision');
if ($sccp_defaults['tftp_rewrite']['data'] == 'pro') {
$disabledButtons = array('off' => 'Off');
}
case 'IS': case 'IS':
\FreePbx::sccp_manager()->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref); \FreePbx::sccp_manager()->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons);
break; break;
case 'SLD': case 'SLD':
case 'SLM': case 'SLM':

View file

@ -44,7 +44,17 @@ if (!empty($this->sccpvalues['SccpDBmodel'])) {
$info['DB Model'] = array('Version' => $this->sccpvalues['SccpDBmodel']['data'], 'about' => 'SCCP DB Configure'); $info['DB Model'] = array('Version' => $this->sccpvalues['SccpDBmodel']['data'], 'about' => 'SCCP DB Configure');
} }
// Start testing tftp server settings - this should be moved after debug to extConfigs exec('in.tftpd -V', $tftpInfo);
$info['TFTP Server'] = array('Version' => 'Not Found', 'about' => 'Mapping not available');
if (isset($tftpInfo[0])) {
$tftpInfo = explode(',',$tftpInfo[0]);
$info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => 'Mapping not available');
$tftpInfo[1] = trim($tftpInfo[1]);
if ($tftpInfo[1] == 'with remap') {
$info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => $tftpInfo[1]);
}
}
if (!empty($this->sccpvalues['tftp_rewrite']['data'])) { if (!empty($this->sccpvalues['tftp_rewrite']['data'])) {
switch ($this->sccpvalues['tftp_rewrite']['data']) { switch ($this->sccpvalues['tftp_rewrite']['data']) {
@ -52,14 +62,16 @@ if (!empty($this->sccpvalues['tftp_rewrite']['data'])) {
case 'pro': case 'pro':
$info['Provision_SCCP'] = array('Version' => 'base', 'about' => 'Provision Sccp enabled'); $info['Provision_SCCP'] = array('Version' => 'base', 'about' => 'Provision Sccp enabled');
break; break;
case 'unavailable':
$info['TFTP Mapping'] = array('Version' => 'off', 'about' => 'remapping is available, but mapping file not included in tftpd-hpa default settings.<br>
Add option <br>
-m /etc/asterisk/sccpManagerRewrite.rules <br>
to the tftpd defaults, location dependant on the system, and restart the tftpd server');
break;
default: default:
$info['TFTP_Mapping'] = array('Version' => 'off', 'about' => 'Rewrite Supported'); if ($tftpInfo[1] == 'with remap') {
$info['TFTP_Mapping'] = array('Version' => 'off', 'about' => "TFTP mapping is available but the mapping file is not included in tftpd-hpa default settings.<br>
To enable Provision mode, add option <br>
-m /etc/asterisk/sccpManagerRewrite.rules <br>
to the tftpd defaults, (location dependant on the system), and restart the tftpd server");
} else {
$info['TFTP_Mapping'] = array('Version' => 'off', 'about' => "Mapping capability is not built into the TFTP server. To enable Provision, upgrade the TFTP server.");
}
break; break;
} }
} }