better lists
This commit is contained in:
@@ -26,10 +26,13 @@ function main(): void {
|
||||
$pbdb = trim_db($pbdb);
|
||||
|
||||
$ext_list = ['338', '334'];
|
||||
$mac_db = pull_mac_db();
|
||||
$mac_list = pull_mac_list();
|
||||
|
||||
foreach ($ext_list as $ext) {
|
||||
$mac = $mac_db[$ext];
|
||||
$mac = $mac_list[$ext] ?? null;
|
||||
|
||||
if (!$mac) { echo "Mac for $ext not found\n"; continue; }
|
||||
|
||||
$file = $provision_dir . '/' . $mac . '-features.cfg';
|
||||
|
||||
$xml = pull_xml_file($file);
|
||||
@@ -121,7 +124,7 @@ function trim_db($pbdb): array {
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
function pull_mac_db(): array {
|
||||
function pull_mac_list(): array {
|
||||
$db = FreePBX::Database();
|
||||
$mac_db = [];
|
||||
|
||||
@@ -136,7 +139,8 @@ function pull_mac_db(): array {
|
||||
$mac_db = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
return $mac_db;
|
||||
|
||||
return array_column($mac_db, 'mac', 'ext');
|
||||
}
|
||||
|
||||
function pull_xml_file($file): DOMDocument {
|
||||
|
||||
Reference in New Issue
Block a user