extension mapping
This commit is contained in:
@@ -109,7 +109,7 @@ function pull_db(): array {
|
|||||||
|
|
||||||
function trim_db($pbdb): array {
|
function trim_db($pbdb): array {
|
||||||
array_unshift($pbdb, [
|
array_unshift($pbdb, [
|
||||||
'name' => 'Night time',
|
'name' => 'Night Hours',
|
||||||
'extension' => '*271',
|
'extension' => '*271',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -130,20 +130,22 @@ function pull_mac_list(): array {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $db->prepare("
|
$stmt = $db->prepare("
|
||||||
SELECT mac, ext
|
SELECT mac, SUBSTRING_INDEX(ext, '-', 1) AS ext
|
||||||
FROM endpoint_extensions
|
FROM endpoint_extensions
|
||||||
WHERE ext REGEXP '^[0-9]+$'
|
ORDER BY CAST(ext AS UNSIGNED)
|
||||||
ORDER BY CAST(extension AS UNSIGNED)
|
|
||||||
");
|
");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$mac_db = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$mac_db = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
echo $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_column($mac_db, 'mac', 'ext');
|
return array_column($mac_db, 'mac', 'ext');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pull_xml_file($file): DOMDocument {
|
function pull_xml_file($file): DOMDocument {
|
||||||
|
if (!file_exists($file)) {
|
||||||
|
$file = '/tftpboot/000000000000-features.cfg';
|
||||||
|
}
|
||||||
$xmlString = file_get_contents($file);
|
$xmlString = file_get_contents($file);
|
||||||
if ($xmlString === false) {
|
if ($xmlString === false) {
|
||||||
throw new RuntimeException("Unable to read file: {$file}");
|
throw new RuntimeException("Unable to read file: {$file}");
|
||||||
|
|||||||
Reference in New Issue
Block a user