config reading
This commit is contained in:
@@ -5,15 +5,15 @@ $bootstrap_settings['freepbx_auth'] = false;
|
||||
require_once('/etc/freepbx.conf');
|
||||
|
||||
function main(): void {
|
||||
$TARGET_EXTENSIONS = "target_extensions";
|
||||
|
||||
$provision_dir = '/tftpboot';
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
$do_notify = in_array('--notify', $argv, true);
|
||||
|
||||
|
||||
$pbdb = trim_db(pull_db());
|
||||
|
||||
$ext_list = read_extension_ini();
|
||||
$ext_list = read_config_ini($TARGET_EXTENSIONS);
|
||||
$mac_list = pull_mac_list();
|
||||
|
||||
foreach ($ext_list as $ext) {
|
||||
@@ -64,6 +64,8 @@ function pull_db(): array {
|
||||
}
|
||||
|
||||
function trim_db($pbdb): array {
|
||||
$BLACKLISTED_TERMS = "blacklisted_terms";
|
||||
|
||||
$pbdb_prepend = [
|
||||
[ 'name' => 'Night Hours', 'extension' => '*271', ],
|
||||
[ 'name' => 'Overhead Page', 'extension' => '900', ],
|
||||
@@ -73,11 +75,8 @@ function trim_db($pbdb): array {
|
||||
];
|
||||
|
||||
array_unshift($pbdb, ...$pbdb_prepend);
|
||||
|
||||
$remove_names = [
|
||||
'inpatient',
|
||||
'vestibule'
|
||||
];
|
||||
|
||||
$remove_names = read_config_ini($BLACKLISTED_TERMS);
|
||||
|
||||
$filtered = array_filter($pbdb, function ($item) use ($remove_names) {
|
||||
if (!is_array($item) || !isset($item['name'])) {
|
||||
@@ -114,9 +113,9 @@ function pull_mac_list(): array {
|
||||
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']));
|
||||
function read_config_ini($CONFIG_KEY): array {
|
||||
$extensions = parse_ini_file('config.ini');
|
||||
$ext_list = array_map('intval', explode(',', $extensions[$CONFIG_KEY]));
|
||||
|
||||
return $ext_list;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user