Skip to content

Commit

Permalink
get cid form channel info POSSA#1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mancy committed Jun 21, 2022
1 parent 7680481 commit a2f6755
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions inc/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

/* Asterisk CLI command specifics */
define("ASCLI","asterisk -rx 'queue show ?' | sed 1d");
define("ASCID","asterisk -rx 'core show channel ?'");
//define("ASCLI","asterisk -rx 'queue show ?'");
define("ASCLINOMEM","No Members");
define("ASCLINOCAL","No Callers");
Expand Down
15 changes: 14 additions & 1 deletion inc/functions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<?php
function resolveChannelCaller($chan)
{
$cli = str_replace("?", $chan, ASCID);
exec($cli, $output, $return_var);
//remove colors from CLI output
$output = preg_replace("/\x1b\[[0-9;]*[a-zA-Z]/", "", $output);
$output = preg_replace("/\x1b\[[0-9;]*[mGKH]/", "", $output);
$output = preg_replace("/\x1b\[[0-9;]*m/", "", $output);
$output = preg_replace("/\x1b\[[0-9;]*[mGKF]/", "", $output);
preg_match('/Caller ID:\s([\d\w]+)/', $output[5], $m);
return $m[1] ?? $chan;
}

function resolveAsteriskCommand() {
$array = array();
if(isset($_POST['queue']) && trim($_POST['queue'])) {
Expand Down Expand Up @@ -57,7 +70,7 @@ function getCallers($command) {

$array[$x] = array();
$array[$x]["no"] = $no;
$array[$x]["cid"] = $cid;
$array[$x]["cid"] = resolveChannelCaller($cid);
$array[$x]["wait"] = $wait;
$array[$x]["prio"] = $prio;
$array[$x]["debug"] = $command[$i];
Expand Down

0 comments on commit a2f6755

Please sign in to comment.