<?php
set_time_limit(30);
require('/var/lib/asterisk/agi-bin/phpagi-2.20/phpagi.php');
error_reporting(E_ALL);
$agi = new AGI();
$agi->answer();
$cid = $agi->parse_callerid();
$agi->stream_file("welcome");
$agi->exec("sayalpha","$cid[username]");
$result = $agi->get_data('agent-pass',8000,3);
$keys = $result['result'];
if($keys){
$agi->stream_file("you-entered");
$agi->exec("sayalpha","$keys");
}
$setting=array("username"=>"root","password"=>"11234","host"=>"localhost","db"=>"asterisk");
$link = mysqli_connect($setting["host"],$setting["username"],$setting["password"],$setting["db"]);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($keys){
$query = "select dst from cdr where src='$keys' order by calldate desc limit 1";
if ($result = mysqli_query($link, $query)) {
if ($row = mysqli_fetch_assoc($result)) {
$agi->exec("sayalpha","$row[dst]");
}
else {
$agi->stream_file("pin-invalid");
}
// printf(" Query failed: %s\n",mysqli_error($link));
}
}
else {
$agi->stream_file("im-sorry");
}
/* close connection */
mysqli_close($link);
?>
No hay comentarios:
Publicar un comentario