From 5329f036f93b6febbb518937143c79e95bf98912 Mon Sep 17 00:00:00 2001 From: poslop Date: Mon, 22 Dec 2025 15:30:15 -0600 Subject: [PATCH] extension mapping --- gen_pc_sidecar.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gen_pc_sidecar.php b/gen_pc_sidecar.php index 9f792d4..d627eb1 100755 --- a/gen_pc_sidecar.php +++ b/gen_pc_sidecar.php @@ -109,7 +109,7 @@ function pull_db(): array { function trim_db($pbdb): array { array_unshift($pbdb, [ - 'name' => 'Night time', + 'name' => 'Night Hours', 'extension' => '*271', ]); @@ -130,20 +130,22 @@ function pull_mac_list(): array { try { $stmt = $db->prepare(" - SELECT mac, ext + SELECT mac, SUBSTRING_INDEX(ext, '-', 1) AS ext FROM endpoint_extensions - WHERE ext REGEXP '^[0-9]+$' - ORDER BY CAST(extension AS UNSIGNED) + ORDER BY CAST(ext AS UNSIGNED) "); $stmt->execute(); $mac_db = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $e) { + echo $e; } - return array_column($mac_db, 'mac', 'ext'); } function pull_xml_file($file): DOMDocument { + if (!file_exists($file)) { + $file = '/tftpboot/000000000000-features.cfg'; + } $xmlString = file_get_contents($file); if ($xmlString === false) { throw new RuntimeException("Unable to read file: {$file}");