<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
header('Content-Type: application/json');
echo json_encode($_REQUEST, JSON_PRETTY_PRINT);
$timeout=100;
$host="127.0.0.1";
$port=5038;
$src = preg_replace('/\s+/', '', $_GET['src']);
$dst = preg_replace('/\s+/', '', $_GET['dst']);
$trunk = preg_replace('/\s+/', '', $_GET['trunk']);
$cid = preg_replace('/\s+/', '', $_GET['cid']);
$id = preg_replace('/\s+/', '', $_GET['id']);
$socket = fsockopen("$host","$port", $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: oy13xtq7h\r\n\r\n");
$wrets=fgets($socket,128);
// echo $wrets;
fputs($socket, "Action: Originate\r\n" );
fputs($socket, "Channel: Local/$src@internal\r\n" );
fputs($socket, "Exten: $dst\r\n" );
fputs($socket, "Context: internal\r\n" );
fputs($socket, "Priority: 1\r\n" );
fputs($socket, "CallerID: $cid\r\n" );
fputs($socket, "Variable: __ext=$ext\r\n" );
fputs($socket, "Variable: __dest=$dest\r\n" );
fputs($socket, "Variable: __cid=$callerid\r\n" );
fputs($socket, "Async: yes\r\n\r\n" );
fputs($socket, "Action: Logoff\r\n\r\n");
while (!feof($socket)){
$result=fgets($socket);
$result= stristr($result,"$number");
$d=strlen($result);
}
fclose($socket);
}
?>
No hay comentarios:
Publicar un comentario