diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 22a1465..68e6b29 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1070,31 +1070,24 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) { - $file_ext = array('.loads', '.sbn', '.bin', '.zup'); + $file_ext = array('.loads', '.sbn', '.bin', '.zup', '.sbin'); $dir = $this->sccppath['tftp_firmware_path']; - $dir_tepl = $this->sccppath['tftp_templates_path']; - $search_mode = ''; - if (!empty($this->sccpvalues['tftp_rewrite'])) { - $search_mode = $this->sccpvalues['tftp_rewrite']['data']; - switch ($search_mode) { - case 'pro': - case 'on': - case 'internal': - $dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly'); - break; - case 'off': - default: // Place in root TFTP dir - $dir_list = $this->findAllFiles($dir, $file_ext); - break; - } - } else { - $dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly'); + $search_mode = $this->sccpvalues['tftp_rewrite']['data']; + switch ($search_mode) { + case 'pro': + case 'on': + case 'internal': + $dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly'); + break; + case 'off': + default: // Place in root TFTP dir + $dir_list = $this->findAllFiles($dir, $file_ext); + break; } $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'] = '-;-'; if (!empty($raw_settings[$i]['loadimage'])) { $raw_settings[$i]['validate'] = 'no;'; if (((strtolower($raw_settings[$i]['vendor']) == 'cisco') || (strtolower($raw_settings[$i]['vendor']) == 'cisco-sip')) && !empty($dir_list)) { @@ -1122,7 +1115,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $raw_settings[$i]['validate'] = '-;'; } if (!empty($raw_settings[$i]['nametemplate'])) { - $file = $dir_tepl . '/' . $raw_settings[$i]['nametemplate']; + $file = $this->sccppath['tftp_templates_path'] . '/' . $raw_settings[$i]['nametemplate']; if (file_exists($file)) { $raw_settings[$i]['validate'] .= 'yes'; } else { diff --git a/install.php b/install.php index 311bb32..a720b2c 100644 --- a/install.php +++ b/install.php @@ -1044,7 +1044,7 @@ function cleanUpSccpSettings() { */ // Clean up sccpsettings to remove legacy values. - $xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}'; + $xml_vars = $_SERVER['DOCUMENT_ROOT'] . "/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}"; $thisInstaller->xml_data = simplexml_load_file($xml_vars); $thisInstaller->initVarfromXml(); foreach ( array_diff_key($settingsFromDb,$thisInstaller->sccpvalues) as $key => $valueArray) { diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index d16470c..dd68f9a 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -202,7 +202,7 @@ class dbinterface { $sel_inf = '*, 0 as validate'; if ($format_list === 'model') { - $sel_inf = 'model, vendor, dns, buttons, 0 as validate'; + $sel_inf = "model, vendor, dns, buttons, '-;-' as validate"; } switch ($get) { case 'byciscoid': diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index a0e168e..6bfec78 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -113,51 +113,37 @@ trait helperfunctions { return $enumFields; } - private function findAllFiles($dir, $file_mask = null, $mode = 'full') { - $result = null; - if (empty($dir) || (!file_exists($dir))) { + private function findAllFiles($searchDir, $file_mask = array(), $mode = 'full') { + $result = array(); + if (!is_dir($searchDir)) { return $result; } - - $root = scandir($dir); - foreach ($root as $value) { - if ($value === '.' || $value === '..') { - continue; - } - if (is_file("$dir/$value")) { - $filter = false; + foreach (array_diff(scandir($searchDir),array('.', '..')) as $value) { + if (is_file("$searchDir/$value")) { + $foundFile = true; if (!empty($file_mask)) { - if (is_array($file_mask)) { - foreach ($file_mask as $k) { - if (strpos(strtolower($value), strtolower($k)) !== false) { - $filter = true; - } - } - } else { - if (strpos(strtolower($value), strtolower($file_mask)) !== false) { - $filter = true; + $foundFile = false; + foreach ($file_mask as $k) { + if (strpos($value, $k)) { + $foundFile = true; + break; } } - } else { - $filter = true; } - if ($filter) { + if ($foundFile) { if ($mode == 'fileonly') { - $result[] = "$value"; + $result[] = $value; } else { - $result[] = "$dir/$value"; + $result[] = "$searchDir/$value"; } - } else { - $result[] = null; } continue; } - $sub_fiend = $this->findAllFiles("$dir/$value", $file_mask, $mode); - if (!empty($sub_fiend)) { - foreach ($sub_fiend as $sub_value) { - if (!empty($sub_value)) { - $result[] = $sub_value; - } + // Now iterate over sub directories + $sub_find = $this->findAllFiles("$searchDir/$value", $file_mask, $mode); + if (!empty($sub_find)) { + foreach ($sub_find as $sub_value) { + $result[] = $sub_value; } } }