예제 #1
0
     * Get active channels with AGI lounched
     */
    $info = $asm->command("core show channels");
    $data = array();
    /*
     * Filter lines with AGI
     */
    foreach (preg_grep("/.*@.*:.*AGI/", explode("\n", $info["data"])) as $line) {
        $chan = preg_split("/ +/", $line);
        if (preg_match("/.*AGI\\((.*).*\\)/", $chan[3], $matches)) {
            $agi_params = preg_split("/,/", $matches[1]);
            /*
             * if ivr menu with name of second AGI param exist
             */
            if ($menu_table[$agi_params[1]]) {
                $call = array();
                $call['channel'] = $chan[0];
                $call['location'] = $chan[1];
                $call['state'] = $chan[2];
                $call['application'] = $chan[3];
                $cid = $asm->GetVar($chan[0], 'CALLERID(all)');
                $call['callerid'] = $cid['Value'];
                $data['calls'][] = $call;
            }
        }
    }
    if ($data && count($data)) {
        print_r(json_encode($data));
    }
    $asm->disconnect();
}
 if ($tmp2[5] == $sBridgeCall) {
     $i++;
     $leg1 = ExtrId($tmp2[0], $cDialplanSeparator);
     //после этого остаются только номера каналов без их технологии
     $leg2 = ExtrId($tmp2[$iSecondLegIndex], $cDialplanSeparator);
     //однако ZAP каналы будут называться как ZAPXXX
     //echo $leg1."\n";
     //echo $leg2."\n";
     if ($leg1 != $leg2) {
         $tmp3 = $ami->ExtensionState($leg1, $dialplan_context, $i * 1023);
         $connections[$leg1]["Status"] = $tmp3['Status'];
         $tmp3 = $ami->ExtensionState($leg2, $dialplan_context, $i * 1023);
         $connections[$leg2]["Status"] = $tmp3['Status'];
         $tmp3 = $ami->database_show("AMPUSER/{$leg1}/cidname");
         $leg1cid = $tmp3["/AMPUSER/{$leg1}/cidname"] . ' ';
         $tmp3 = $ami->GetVar($tmp2[$iSecondLegIndex], "CALLERID(name)");
         $leg2cid = $tmp3['Value'] . ' ';
         $connections[$leg1]["Connected"] = $leg2;
         $connections[$leg1]["Duration"] = @date("i:s", $tmp2[$iDurationIndex]);
         $connections[$leg1]["Application"] = $tmp2[5];
         $connections[$leg1]["CallerID"] = $leg2cid;
         $connections[$leg1]["Channel"] = $tmp2[$iSecondLegIndex];
         $connections[$leg2]["Connected"] = $leg1;
         $connections[$leg2]["Duration"] = @date("i:s", $tmp2[$iDurationIndex]);
         $connections[$leg2]["Application"] = $tmp2[5];
         $connections[$leg2]["CallerID"] = $leg1cid;
         $connections[$leg2]["Channel"] = $tmp2[0];
     }
 } elseif ($tmp2[4] == "Ring" and $tmp2[5] == "Dial") {
     $i++;
     $leg1 = ExtrId($tmp2[0], $cDialplanSeparator);
 if ($tmp2[5] == "Bridged Call") {
     $i++;
     $leg1 = ExtrId($tmp2[0]);
     //после этого остаются только номера каналов без их технологии
     $leg2 = ExtrId($tmp2[11]);
     //однако ZAP каналы будут называться как ZAPXXX
     //echo $leg1."\n";
     //echo $leg2."\n";
     if ($leg1 != $leg2) {
         $tmp3 = $ami->ExtensionState($leg1, "from-internal", $i * 1023);
         $connections[$leg1]["Status"] = $tmp3['Status'];
         $tmp3 = $ami->ExtensionState($leg2, "from-internal", $i * 1023);
         $connections[$leg2]["Status"] = $tmp3['Status'];
         $tmp3 = $ami->database_show("AMPUSER/{$leg1}/cidname");
         $leg1cid = $tmp3["/AMPUSER/{$leg1}/cidname"] . ' ';
         $tmp3 = $ami->GetVar($tmp2[11], "CALLERID(name)");
         $leg2cid = $tmp3['Value'] . ' ';
         $connections[$leg1]["Connected"] = $leg2;
         $connections[$leg1]["Duration"] = @date("i:s", $tmp2[10]);
         $connections[$leg1]["Application"] = $tmp2[5];
         $connections[$leg1]["CallerID"] = $leg2cid;
         $connections[$leg1]["Channel"] = $tmp2[11];
         $connections[$leg2]["Connected"] = $leg1;
         $connections[$leg2]["Duration"] = @date("i:s", $tmp2[10]);
         $connections[$leg2]["Application"] = $tmp2[5];
         $connections[$leg2]["CallerID"] = $leg1cid;
         $connections[$leg2]["Channel"] = $tmp2[0];
     }
 } elseif ($tmp2[4] == "Ring" and $tmp2[5] == "Dial") {
     $i++;
     $leg1 = ExtrId($tmp2[0]);