<?php
$command="core show channels";
$socket = fsockopen("10.0.0.200","5038", $errno, $errstr, 10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: 144\r\n\r\n");
fputs($socket, "Action: Command\r\n");
fputs($socket, "Command: $command\r\n\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while (!feof($socket)){
echo $result=fgets($socket);
}
}
?>
[public]
exten=>_x.,1,Answer()
same=>n,Set(calls=${SHELL(php /home/phpagi-2.20/calls_ami.php | grep "active calls" | awk '{print $2}')})
same=>n,Set(trunk=issabel)
same=>n,Set(limit=0)
same=>n,GotoIf($["${calls:0:-1}">="${limit}"]?queue)
same=>n,Dial(SIP/${trunk}/${EXTEN})
same=>n,hangup
same=>n(queue),queue(support)
same=>n,hangup
<?php
$queue=$argv[1];
$dst=$argv[2];
//$chan=shell_exec("asterisk -x \" core show channels concise\" | awk -F! '{print $1}' |awk 'NR==1'");
echo $chan=shell_exec("asterisk -x \" queue show $queue\" | grep SIP | awk '{print $2}' |awk 'NR==1'");
$chan =preg_replace('/\s+/', '',$chan);
echo "$chan\n";
echo $redirectn=shell_exec("/usr/sbin/asterisk -x \"channel redirect $chan redirect,$dst,1\"");
?>
[redirect]
exten=>_x.,1,Noop(******transferring call***)
same=>n,Dial(SIP/${trunk}/${EXTEN})
No hay comentarios:
Publicar un comentario