Complete sucess =D
And I wanna share it with u ppl
This is my AGI
Code:
#!/usr/bin/php -q
<?
include (dirname(__FILE__)."/lib/phpagi/phpagi.php");
include (dirname(__FILE__)."/lib/phpagi/phpagi-asmanager.php");
$agi = new AGI();
$no = substr($agi->request[agi_dnid], 1);//Gets the DNID except the first digit (5), the prefix
$db = 'mydb';
$dbuser = 'root';
$dbpass = 'mypassword';
$dbhost = 'localhost';
mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db("$db");
$row=mysql_query("SELECT * FROM aa_alias WHERE alias = ".$no." LIMIT 1");
if(mysql_num_rows($row) == 1)
{
$row=mysql_fetch_object($row);
$agi->set_variable("blah", $row->extension);
}
?>
And in extensions.conf...
Code:
[a2billing]
; CallingCard application
exten => _5.,1,DeadAGI(internalcall.php)
exten => _5.,2,Dial(SIP/${blah})
exten => _5.,3,Hangup
exten => _X.,1,GotoIf($["${EXTEN}" = "6600"]? 4)
exten => _X.,2,DeadAGI(a2billing.php|1)
exten => _X.,3,Hangup
exten => _X.,4,VoicemailMain()
exten => _X.,5,Hangup
And that's it... when some dials 5 and then a short extension (alias), it'll run the SCRIPT and compare with a database, if it exists, it'll assign the real extension to "blah", then it'll dial to that extension.
And that's it =D