}
    $data['extensions'] = $extensions;
    echo json_encode($data);
    // $smarty->assign('data', $data);
    // $smarty->display('operator-json3d.tpl');
}
if ($_REQUEST['query'] == 'extstate') {
    $database = $ami->database_show('AMPUSER');
    // преобразуем масиив базы данных asterisk в массив для удобного отображения средствами smartly
    $i = 0;
    foreach ($database as $key => $value) {
        $keys = split("/", $key);
        if (count($keys) < 2) {
            continue;
        }
        $tmp3 = $ami->ExtensionState($keys[2], $dialplan_context, $i * 1023);
        $connections[$keys[2]]["Status"] = $tmp3['Status'];
    }
    if (file_exists('/etc/asterisk/operator.conf')) {
        $config = parse_ini_file('/etc/asterisk/operator.conf', true);
    }
    if ($config) {
        foreach ($config as $key => $value) {
            $tmp3 = $ami->ExtensionState($key, $dialplan_context, $i * 1023);
            $from_file[$key]['Status'] = $tmp3['Status'];
        }
    } else {
        $from_file[] = '';
    }
    $connections = $connections + $from_file;
    /*?><pre>connections:<?print_r($connections);?></pre><?*/
示例#2
0
$notifications = $argv[1];
$notify = explode(',', $notifications);
$extension = $argv[2];
$vars['__EXTENSION'] = $extension;
if ($argc == 4) {
    $vars['NAME_RECORDING'] = $argv[3];
}
# Connect to the AGI
$asm = new AGI_AsteriskManager();
$asm->connect();
# Get language
$language = Aastra_get_language();
# Notify each phone
for ($i = 0; $i < sizeof($notify); $i++) {
    $vars['__REALCALLERIDNUM'] = $notify[$i];
    $state = $asm->ExtensionState($notify[$i], 'default');
    if ($state['Status'] != 0) {
        $vars['NOTIFY_VM'] = 'true';
    }
    while (list($key, $val) = each($vars)) {
        $vars_arr[] = "{$key}={$val}";
    }
    if (Aastra_compare_version_Asterisk('1.6')) {
        $vars = implode(',', $vars_arr);
    } else {
        $vars = implode('|', $vars_arr);
    }
    $res = $asm->Originate2('Local/' . $notify[$i] . '@presence-notify', 9999, 'default', 1, null, null, null, sprintf(Aastra_get_label('%s is back <%s>', $language), $extension, $extension), $vars);
    flush();
    sleep(30);
    // give them a break inbetween calls, so they don't get flood of them all at once ;)
        }
    } else {
        $extensions = $buttons;
    }
    $data['extensions'] = $extensions;
    echo json_encode($data);
    // $smarty->assign('data', $data);
    // $smarty->display('operator-json3d.tpl');
}
if ($_REQUEST['query'] == 'extstate') {
    $database = $ami->database_show('AMPUSER');
    // преобразуем масиив базы данных asterisk в массив для удобного отображения средствами smartly
    $i = 0;
    foreach ($database as $key => $value) {
        $keys = split("/", $key);
        $tmp3 = $ami->ExtensionState($keys[2], "from-internal", $i * 1023);
        $connections[$keys[2]]["Status"] = $tmp3['Status'];
    }
    if (file_exists('/etc/asterisk/operator.conf')) {
        $config = parse_ini_file('/etc/asterisk/operator.conf', true);
    }
    if ($config) {
        foreach ($config as $key => $value) {
            $tmp3 = $ami->ExtensionState($key, "from-internal", $i * 1023);
            $from_file[$key]['Status'] = $tmp3['Status'];
        }
    } else {
        $from_file[] = '';
    }
    $connections = $connections + $from_file;
    /*?><pre>connections:<?print_r($connections);?></pre><?*/