/** Recursively read voicemail.conf (and any included files)
 * This function is called by getVoicemailConf()
 */
function parse_voicemailconf($filename, &$vmconf, &$section)
{
    if (is_null($vmconf)) {
        $vmconf = array();
    }
    if (is_null($section)) {
        $section = "general";
    }
    if (file_exists($filename)) {
        $fd = fopen($filename, "r");
        while ($line = fgets($fd, 1024)) {
            if (preg_match("/^\\s*(\\d+)\\s*=>\\s*([0-9A-D\\*#]*),(.*),(.*),(.*),(.*)\\s*([;#].*)?/i", $line, $matches)) {
                // "mailbox=>password,name,email,pager,options"
                // this is a voicemail line
                $vmconf[$section][$matches[1]] = array("mailbox" => $matches[1], "pwd" => $matches[2], "name" => $matches[3], "email" => $matches[4], "pager" => $matches[5], "options" => array());
                // parse options
                //output($matches);
                foreach (explode("|", $matches[6]) as $opt) {
                    $temp = explode("=", $opt);
                    //output($temp);
                    if (isset($temp[1])) {
                        list($key, $value) = $temp;
                        $vmconf[$section][$matches[1]]["options"][$key] = $value;
                    }
                }
            } else {
                if (preg_match('/^(?:\\s*)#include(?:\\s+)["\']{0,1}([^"\']*)["\']{0,1}(\\s*[;#].*)?$/', $line, $matches)) {
                    // include another file
                    if ($matches[1][0] == "/") {
                        // absolute path
                        $filename = trim($matches[1]);
                    } else {
                        // relative path
                        $filename = dirname($filename) . "/" . trim($matches[1]);
                    }
                    parse_voicemailconf($filename, $vmconf, $section);
                } else {
                    if (preg_match("/^\\s*\\[(.+)\\]/", $line, $matches)) {
                        // section name
                        $section = strtolower($matches[1]);
                    } else {
                        if (preg_match("/^\\s*([a-zA-Z0-9-_]+)\\s*=\\s*(.*?)\\s*([;#].*)?\$/", $line, $matches)) {
                            // name = value
                            // option line
                            $vmconf[$section][$matches[1]] = $matches[2];
                        }
                    }
                }
            }
        }
        fclose($fd);
    }
}
Beispiel #2
0
function voicemail_getVoicemail()
{
    global $amp_conf;
    $vmconf = null;
    $section = null;
    // yes, this is hardcoded.. is this a bad thing?
    parse_voicemailconf(rtrim($amp_conf["ASTETCDIR"], "/") . "/voicemail.conf", $vmconf, $section);
    return $vmconf;
}
Beispiel #3
0
function getVoicemail()
{
    $vmconf = null;
    $section = null;
    // yes, this is hardcoded.. is this a bad thing?
    parse_voicemailconf("/etc/asterisk/voicemail.conf", $vmconf, $section);
    return $vmconf;
}
Beispiel #4
0
        if (DB::IsError($do)) {
            out(_('cannot set e_id for directory_id = ' . $e['id'] . '. Please resubmit this directory manually to correct this issue.'));
        }
    }
}
//check to see if there is a need to migrate from legacy directory
$migrated = $db->getOne("SELECT value FROM `admin` WHERE `variable` = 'directory28_migrated'");
// TODO: restrucutre without the die_freepbx() where it is not critical (e.g. creating new directory failures
//       should not kill the install
if (!$migrated) {
    //migrate legacy directories to new directory
    //get a list of vm users
    $vmconf = null;
    $section = null;
    $vmusers = array();
    parse_voicemailconf(rtrim($amp_conf["ASTETCDIR"], "/") . "/voicemail.conf", $vmconf, $section);
    if (isset($vmconf) && is_array($vmconf)) {
        foreach ($vmconf['default'] as $ext => $vm) {
            $vmusers[$ext] = $vm['name'];
        }
    }
    //create a new directory if we have voicemail users
    if (isset($vmusers) && $vmusers) {
        out(_("Migrating Directory"));
        //TODO: make this the default directory
        $vals = array('Migrated Directory', '', '0', '', '', '2', '0', '0', 'app-blackhole,hangup,1', '', '1');
        $sql = 'INSERT INTO directory_details (dirname, description, announcement,
					callid_prefix, alert_info, repeat_loops, repeat_recording,
					invalid_recording, invalid_destination, retivr, say_extension)
					VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
        $new = $db->query($sql, $vals);