#!/usr/bin/php -q
<?
set_time_limit(30);
require('/var/lib/asterisk/agi-bin/phpagi-2.20/phpagi.php');
require('conect.php'); //conection to the DB
error_reporting(E_ALL);
$agi = new AGI();
$agi->answer();
$agi->verbose("this is exten $argv[1] this is callerid $argv[2]");
$result = $agi->get_data('agent-pass',4000); //4 segundos de timeout acepta cualquier cantidad de numeros
//$result = $agi->get_data('/var/lib/asterisk/agi-bin/ivr-system/sounds/intro',4000 ,4); //esta opcion solo acepta entrada de 4 digitos maximo
//$result = $agi->get_data('/var/lib/asterisk/sounds/agi/recording_sound/intro',8000); //esta no tiene limite en la entrada pero tiene 8 segundo de timout
$keys = $result['result'];
$query = mysql_query("SELECT * FROM `users` WHERE password='$keys' LIMIT 1");
if ($query) {
if($row = mysql_fetch_array($query)) {
$agi->verbose( $row);
$agi->stream_file("/var/lib/asterisk/agi-bin/ivr_system/sounds/thankyou","#");
$result= $agi->get_data('/var/lib/asterisk/agi-bin/ivr_system/sounds/intro',4000); //4 segundos de timeout acepta cualquier cantidad de numeros
$keys = $result['result'];
$agi->verbose($callNum);
$channels="australia"; //trunk name
$agi->exec('DIAL',"SIP/$channels/$keys");
}
else
{
$agi->stream_file("/var/lib/asterisk/agi-bin/ivr_system/sounds/invalid","#");
$agi->stream_file("/var/lib/asterisk/agi-bin/ivr_system/sounds/goodbye","#");
//$agi->exec_goto('ivr-call',2727,1);
}
}
//$agi->hangup();
[ivr-call]
exten=>_0282091985,1,Set(GLOBAL(LOOPCOUNT)=1)
exten=>_0282091985,2,agi(/var/lib/asterisk/agi-bin/ivr_system/ivr_system.php,${EXTEN},${CALLERID(num)})
same=>n,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
same=>n,verbose(value of ${LOOPCOUNT})
same=>n,GotoIf($[${LOOPCOUNT} > 3]?hangup)
same=>n,Goto(ivr-call,0282091985,1)
same=>n(hangup),Hangup()
;;;using read
exten => 0204,1,Read(NUMBER,/var/lib/asterisk/agi-bin/ivr_system/sounds/intro,11,3) ;numero de 11 digitos eje: 18097143489
same=>n,DIal(SIP/callcentric/${NUMBER},,10)
;exten => 02,n,SayNumber(${NUMBER})
*/
?>
<?
$dbhost='localhost';
$dbuser='root';
$dbpass=12334;
$dbname='asterisk';
$db = mysql_connect($dbhost, $dbuser, $dbpass) or die("Couldn't connect to the database.");
mysql_select_db($dbname) or die("Couldn't select the database");
?>
No hay comentarios:
Publicar un comentario