Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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