From d8d2f946ce12db789f9bde79397eed77cc72d5d8 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 31 Jul 2021 15:41:32 +0200 Subject: [PATCH] Minor optimisations --- Sccp_manager.class.php | 36 +++++++++++++--------------- sccpManClasses/dbinterface.class.php | 2 +- sccpManTraits/helperFunctions.php | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 68e6b29..4c9d38a 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1090,25 +1090,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { for ($i = 0; $i < count($raw_settings); $i++) { 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)) { - foreach ($dir_list as $filek) { - switch ($search_mode) { - case 'pro': - case 'on': - case 'internal': - if (strpos(strtolower($filek), strtolower($raw_settings[$i]['loadimage'])) !== false) { - $raw_settings[$i]['validate'] = 'yes;'; - } - break; - case 'internal2': - break; - case 'off': - default: // Place in root TFTP dir - if (strpos(strtolower($filek), strtolower($dir . '/' . $raw_settings[$i]['loadimage'])) !== false) { - $raw_settings[$i]['validate'] = 'yes;'; - } - break; - } + foreach ($dir_list as $filek) { + switch ($search_mode) { + case 'pro': + case 'on': + case 'internal': + if (strpos($filek, $raw_settings[$i]['loadimage']) !== false) { + $raw_settings[$i]['validate'] = 'yes;'; + } + break; + case 'internal2': + break; + case 'off': + default: // Place in root TFTP dir + if (strpos($filek, strtolower($dir . '/' . $raw_settings[$i]['loadimage'])) !== false) { + $raw_settings[$i]['validate'] = 'yes;'; + } + break; } } } else { diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index dd68f9a..55cc299 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -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. //break; // above includes expansion modules but was not original behaviour so commented out. Falls through to 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; 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"); diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 6bfec78..791513a 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -124,7 +124,7 @@ trait helperfunctions { if (!empty($file_mask)) { $foundFile = false; foreach ($file_mask as $k) { - if (strpos($value, $k)) { + if (strpos($value, $k) !== false) { $foundFile = true; break; }