Minor optimisations

This commit is contained in:
steve-lad 2021-07-31 15:41:32 +02:00
parent 43a656cebc
commit d8d2f946ce
3 changed files with 19 additions and 21 deletions

View file

@ -1090,25 +1090,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
for ($i = 0; $i < count($raw_settings); $i++) { for ($i = 0; $i < count($raw_settings); $i++) {
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)) { foreach ($dir_list as $filek) {
foreach ($dir_list as $filek) { switch ($search_mode) {
switch ($search_mode) { case 'pro':
case 'pro': case 'on':
case 'on': case 'internal':
case 'internal': if (strpos($filek, $raw_settings[$i]['loadimage']) !== false) {
if (strpos(strtolower($filek), strtolower($raw_settings[$i]['loadimage'])) !== false) { $raw_settings[$i]['validate'] = 'yes;';
$raw_settings[$i]['validate'] = 'yes;'; }
} break;
break; case 'internal2':
case 'internal2': break;
break; case 'off':
case 'off': default: // Place in root TFTP dir
default: // Place in root TFTP dir if (strpos($filek, strtolower($dir . '/' . $raw_settings[$i]['loadimage'])) !== false) {
if (strpos(strtolower($filek), strtolower($dir . '/' . $raw_settings[$i]['loadimage'])) !== false) { $raw_settings[$i]['validate'] = 'yes;';
$raw_settings[$i]['validate'] = 'yes;'; }
} break;
break;
}
} }
} }
} else { } else {

View file

@ -237,7 +237,7 @@ class dbinterface
//$stmt = $db->prepare('SELECT ' . {$sel_inf} . ' FROM sccpdevmodel WHERE enabled = 1 ORDER BY model'); //previously this fell through to phones. //$stmt = $db->prepare('SELECT ' . {$sel_inf} . ' FROM sccpdevmodel WHERE enabled = 1 ORDER BY model'); //previously this fell through to phones.
//break; // above includes expansion modules but was not original behaviour so commented out. Falls through to phones. //break; // above includes expansion modules but was not original behaviour so commented out. Falls through to phones.
case 'phones': case 'phones':
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 1) ORDER BY model");
break; break;
case 'ciscophones': case 'ciscophones':
$stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor NOT LIKE '%-sip' ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor NOT LIKE '%-sip' ORDER BY model");

View file

@ -124,7 +124,7 @@ trait helperfunctions {
if (!empty($file_mask)) { if (!empty($file_mask)) {
$foundFile = false; $foundFile = false;
foreach ($file_mask as $k) { foreach ($file_mask as $k) {
if (strpos($value, $k)) { if (strpos($value, $k) !== false) {
$foundFile = true; $foundFile = true;
break; break;
} }