Correct XML Path in installer and optimise findAllFiles
XML Path in installer was in single quotes - corrected Remove unnecessary tests in findallfiles
This commit is contained in:
parent
e313b9da3f
commit
43a656cebc
|
@ -1070,31 +1070,24 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) {
|
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 = $this->sccppath['tftp_firmware_path'];
|
||||||
$dir_tepl = $this->sccppath['tftp_templates_path'];
|
|
||||||
|
|
||||||
$search_mode = '';
|
$search_mode = $this->sccpvalues['tftp_rewrite']['data'];
|
||||||
if (!empty($this->sccpvalues['tftp_rewrite'])) {
|
switch ($search_mode) {
|
||||||
$search_mode = $this->sccpvalues['tftp_rewrite']['data'];
|
case 'pro':
|
||||||
switch ($search_mode) {
|
case 'on':
|
||||||
case 'pro':
|
case 'internal':
|
||||||
case 'on':
|
$dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly');
|
||||||
case 'internal':
|
break;
|
||||||
$dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly');
|
case 'off':
|
||||||
break;
|
default: // Place in root TFTP dir
|
||||||
case 'off':
|
$dir_list = $this->findAllFiles($dir, $file_ext);
|
||||||
default: // Place in root TFTP dir
|
break;
|
||||||
$dir_list = $this->findAllFiles($dir, $file_ext);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly');
|
|
||||||
}
|
}
|
||||||
$raw_settings = $this->dbinterface->getDb_model_info($get, $format_list, $filter);
|
$raw_settings = $this->dbinterface->getDb_model_info($get, $format_list, $filter);
|
||||||
if ($validate) {
|
if ($validate) {
|
||||||
for ($i = 0; $i < count($raw_settings); $i++) {
|
for ($i = 0; $i < count($raw_settings); $i++) {
|
||||||
$raw_settings[$i]['validate'] = '-;-';
|
|
||||||
if (!empty($raw_settings[$i]['loadimage'])) {
|
if (!empty($raw_settings[$i]['loadimage'])) {
|
||||||
$raw_settings[$i]['validate'] = 'no;';
|
$raw_settings[$i]['validate'] = 'no;';
|
||||||
if (((strtolower($raw_settings[$i]['vendor']) == 'cisco') || (strtolower($raw_settings[$i]['vendor']) == 'cisco-sip')) && !empty($dir_list)) {
|
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'] = '-;';
|
$raw_settings[$i]['validate'] = '-;';
|
||||||
}
|
}
|
||||||
if (!empty($raw_settings[$i]['nametemplate'])) {
|
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)) {
|
if (file_exists($file)) {
|
||||||
$raw_settings[$i]['validate'] .= 'yes';
|
$raw_settings[$i]['validate'] .= 'yes';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ function cleanUpSccpSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Clean up sccpsettings to remove legacy values.
|
// 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->xml_data = simplexml_load_file($xml_vars);
|
||||||
$thisInstaller->initVarfromXml();
|
$thisInstaller->initVarfromXml();
|
||||||
foreach ( array_diff_key($settingsFromDb,$thisInstaller->sccpvalues) as $key => $valueArray) {
|
foreach ( array_diff_key($settingsFromDb,$thisInstaller->sccpvalues) as $key => $valueArray) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ class dbinterface
|
||||||
{
|
{
|
||||||
$sel_inf = '*, 0 as validate';
|
$sel_inf = '*, 0 as validate';
|
||||||
if ($format_list === 'model') {
|
if ($format_list === 'model') {
|
||||||
$sel_inf = 'model, vendor, dns, buttons, 0 as validate';
|
$sel_inf = "model, vendor, dns, buttons, '-;-' as validate";
|
||||||
}
|
}
|
||||||
switch ($get) {
|
switch ($get) {
|
||||||
case 'byciscoid':
|
case 'byciscoid':
|
||||||
|
|
|
@ -113,51 +113,37 @@ trait helperfunctions {
|
||||||
return $enumFields;
|
return $enumFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findAllFiles($dir, $file_mask = null, $mode = 'full') {
|
private function findAllFiles($searchDir, $file_mask = array(), $mode = 'full') {
|
||||||
$result = null;
|
$result = array();
|
||||||
if (empty($dir) || (!file_exists($dir))) {
|
if (!is_dir($searchDir)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
foreach (array_diff(scandir($searchDir),array('.', '..')) as $value) {
|
||||||
$root = scandir($dir);
|
if (is_file("$searchDir/$value")) {
|
||||||
foreach ($root as $value) {
|
$foundFile = true;
|
||||||
if ($value === '.' || $value === '..') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (is_file("$dir/$value")) {
|
|
||||||
$filter = false;
|
|
||||||
if (!empty($file_mask)) {
|
if (!empty($file_mask)) {
|
||||||
if (is_array($file_mask)) {
|
$foundFile = false;
|
||||||
foreach ($file_mask as $k) {
|
foreach ($file_mask as $k) {
|
||||||
if (strpos(strtolower($value), strtolower($k)) !== false) {
|
if (strpos($value, $k)) {
|
||||||
$filter = true;
|
$foundFile = true;
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (strpos(strtolower($value), strtolower($file_mask)) !== false) {
|
|
||||||
$filter = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$filter = true;
|
|
||||||
}
|
}
|
||||||
if ($filter) {
|
if ($foundFile) {
|
||||||
if ($mode == 'fileonly') {
|
if ($mode == 'fileonly') {
|
||||||
$result[] = "$value";
|
$result[] = $value;
|
||||||
} else {
|
} else {
|
||||||
$result[] = "$dir/$value";
|
$result[] = "$searchDir/$value";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$result[] = null;
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$sub_fiend = $this->findAllFiles("$dir/$value", $file_mask, $mode);
|
// Now iterate over sub directories
|
||||||
if (!empty($sub_fiend)) {
|
$sub_find = $this->findAllFiles("$searchDir/$value", $file_mask, $mode);
|
||||||
foreach ($sub_fiend as $sub_value) {
|
if (!empty($sub_find)) {
|
||||||
if (!empty($sub_value)) {
|
foreach ($sub_find as $sub_value) {
|
||||||
$result[] = $sub_value;
|
$result[] = $sub_value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue