Compare commits

...

2 Commits

Author SHA1 Message Date
poslop
f21f4c2bbf ini 2025-12-22 15:35:34 -06:00
poslop
5329f036f9 extension mapping 2025-12-22 15:30:15 -06:00
2 changed files with 18 additions and 8 deletions

1
extensions.ini Normal file
View File

@@ -0,0 +1 @@
extensions = 334,338

View File

@@ -22,10 +22,10 @@ function main(): void {
$argv = $_SERVER['argv'] ?? [];
$do_notify = in_array('--notify', $argv, true);
$pbdb = pull_db();
$pbdb = trim_db($pbdb);
$ext_list = ['338', '334'];
$pbdb = trim_db(pull_db());
$ext_list = read_extension_ini();
$mac_list = pull_mac_list();
foreach ($ext_list as $ext) {
@@ -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,29 @@ 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 read_extension_ini(): array {
$extensions = parse_ini_file('extensions.ini');
$ext_list = array_map('intval', explode(',', $extensions['extensions']));
return $ext_list;
}
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}");