smeserver-freepbx/root/etc/e-smith/events/actions/freepbx-dump-astdb

38 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env php
<?php
// No use outputting anything, as env forces php headers to appear. Sigh.
function getconf($filename) {
$file = file($filename);
foreach ($file as $line) {
if (preg_match("/^\s*([\w]+)\s*=\s*\"?([\w\/\:\.\%-]*)\"?\s*([;#].*)?/",$line,$matches)) {
$conf[ $matches[1] ] = $matches[2];
}
}
return $conf;
}
$amp_conf = getconf("/etc/amportal.conf");
// Start quickly.
$bootstrap_settings['freepbx_auth'] = false; // Just in case.
$restrict_mods = true; // Takes startup from 0.2 seconds to 0.07 seconds.
include '/etc/freepbx.conf';
$astman = new AGI_AsteriskManager();
if (! $res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) {
unset( $astman );
}
@mkdir("/home/e-smith/db/freepbx/");
$fh = fopen("/home/e-smith/db/freepbx/astdb.dump", "w");
$astdb = $astman->database_show();
foreach ($astdb as $key => $val) {
if ($key == "") { continue; }
if ($key == "Privilege") { continue; }
fwrite($fh, "[$key] [$val]\n");
}
fclose($fh);
?>