<?
# derived from the Aastra xml/php/agi scripts.
#include ("include/phpagi/misc.php");
include ("include/phpagi-2.14/phpagi-asmanager.php");
function isQueueMem($username,$queuenum,$userval){
$as = new AGI_AsteriskManager();
$res = $as->connect();
$res = $as->Command('show queue '.$queuenum);
$lines = split("\n",$res['data']);
$numlines = count($lines);
$ismem=0;
#i starts at three and ends at numlines-4 because there is garbage
#data there. Same thing with the other returns from the lines split:
#most of it we don't care about (some may be useful later, but not now.)
for ($i=3; $i<=($numlines-4); $i++){
$values=split(" ",$lines[$i]);
if ($values[$userval]=="SIP/" . $username){
$ismem="true";
}
}
# Disconnect properly
$as->disconnect();
return $ismem;
}
# Connect to AGI
# constant that defines which value contains the username in the return of the 'show queue' command
$uservalue = "6";
# name of the queue. in TB they're all numbers.
$queuename="6";
# user to add
$user="6606";
if (isQueueMem($user,$queuename,$uservalue)){
print "$user is a member of queue $queuename\n";
} else {
print "$user is not a member of queue $queuename\n";
}
$user="6643";
if (isQueueMem($user,$queuename,$uservalue)){
print "$user is a member of queue $queuename\n";
} else {
print "$user is not a member of queue $queuename\n";
}
?>