Compare commits
2 Commits
b2fdfa2f1a
...
f21f4c2bbf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f21f4c2bbf | ||
|
|
5329f036f9 |
1
extensions.ini
Normal file
1
extensions.ini
Normal file
@@ -0,0 +1 @@
|
|||||||
|
extensions = 334,338
|
||||||
@@ -22,10 +22,10 @@ function main(): void {
|
|||||||
$argv = $_SERVER['argv'] ?? [];
|
$argv = $_SERVER['argv'] ?? [];
|
||||||
$do_notify = in_array('--notify', $argv, true);
|
$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();
|
$mac_list = pull_mac_list();
|
||||||
|
|
||||||
foreach ($ext_list as $ext) {
|
foreach ($ext_list as $ext) {
|
||||||
@@ -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,29 @@ 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 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 {
|
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