php /root/event.php DTMFEnd
<?php
$host="localhost";
$username="admin";
$secret="456";
$socket = fsockopen($host,"5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: $username\r\n");
fputs($socket, "Secret: $secret\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
//if(stristr($result,'HangupRequest')){ //no used
if (preg_match("/\b$argv[1]\b/i", $result, $match)){
$r=explode("\n",$result);
$channel=explode(" ",$r[2]);
echo "channel name is $channel[1]\n";
system(" curl \"http://65.181.118.232/chanredirect.php?context=internal&exten=10&channel=$channel[1]\"");
foreach( $r as $key=>$value){
echo " $key : $value\n";
}
continue;
}
}
}
fclose($socket);
?>
@@@@@@@@@@@@@@@@@@@@@
<?php
//http://65.181.118.232/php-project/chanredirect.php?exten=1010&context=internal&channel=SIP/102-00000004
$pbx="localhost";
$timeout=45;
$chan=$_GET['channel'];
$exten=$_GET['exten'];
$context=$_GET['context'];
if($_GET['channel'] && $_GET['context'] && $_GET['exten']){
$socket = fsockopen($pbx,"5038", $errno, $errstr, $timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n"); //
fputs($socket, "Secret: 456\r\n\r\n"); //
//
$wrets=fgets($socket,128);
echo "<center>$wrets</center>";
fputs($socket, "Action: Redirect\r\n" );
fputs($socket, "Channel:$chan\r\n" );
fputs($socket, "Exten: $exten\r\n" );
fputs($socket, "Context: $context\r\n" );
fputs($socket, "Priority: 1\r\n" );
fputs($socket, "Async: yes\r\n\r\n" );
fputs($socket, "Action: Logoff\r\n\r\n");
sleep (1);
$wrets=fgets($socket,128);
echo "<center><h2>Transfer completed</h2></center>";
}
?>
No hay comentarios:
Publicar un comentario