PHPAGI + HANDLE MULTIPLE DID NUMBER


extensions.conf

[ecentrix-agents]
exten => 3000,1,Ringing
exten => 3000,n,Answer
exten => 3000,n,AGI(inbound_flow_agi.php)

#!/usr/bin/php -q
<?php
/*simple ivr phpagi
by moses
*/
set_time_limit(0);
ob_implicit_flush(false);
require(‘include/phpagi.php’);
$agi = new AGI();

/*connection mysql*/
if (!$dbh = mysql_connect(‘localhost’, ‘root’, ‘root’)) {
$agi->verbose(‘mysql_connect() failed, exiting…’);
$agi->hangup();
exit;
}
mysql_select_db(‘voip’, $dbh);
$agi->verbose(‘mysql_connect() connected…’);
/*end connection mysql*/

$query = “SELECT * FROM acd WHERE number='{$agi->request[‘agi_callerid’]}'”;

if (!$res = mysql_query($query, $dbh)) {
$agi->verbose(‘mysql_query() failed: ‘ . mysql_error());
$agi->hangup();
exit;
}

if (mysql_num_rows($res) == 0) {
$agi->verbose(‘mysql_num_rows() returned zero’);
// $agi->stream_file(‘wrong_inbound_number’, ‘#’);
$agi->hangup();
exit;
}

$data = mysql_fetch_array($res);

$agi->verbose(“number : {$data[‘number’]} extension : {$data[‘extensions’]} type : {$data[‘type’]}”);

mysql_free_result($res);

//$agi->stream_file(‘igc_001′);
$ext_destination=””;
$loop=0;
while($ext_destination == “”){
//$result = $agi->fastpass_get_data($buffer,’igc_002′, 3000, 4);
$result = $agi->fastpass_get_data($buffer,’igc_002’, 5000, 4);
$ext_destination=$result[‘result’];
$loop++;
if($loop>2){
$agi->hangup();
$loop=0;
break;
}
}

$agi->verbose($agi->request[“agi_callerid”]);
//operator
if($ext_destination==0){
if ($data[‘type’] == ‘seq’) {
// Dial sequentially
$exts = split(‘,’, $data[‘extensions’]);
foreach ($exts as $ext) {
$agi->exec(‘Dial’, ‘SIP/’ . $ext . ‘,15’);
}
}else if ($data[‘type’] == ‘sim’) {
// Dial simultaneously
$exts = split(‘,’, $data[‘extensions’]);

$last = count($exts);
$i = 1;
// Build dial string
foreach ($exts as $ext) {
$args .= ‘SIP/’ . $ext;
if ($i != $last) {
$args .= ‘&’;
}
$i++;
}
$agi->exec(‘Dial’, $args . ‘,60′,’tT’);

}
}else{
//dial extension
$agi->exec(‘Dial’,’SIP/’ .$ext_destination. ‘,60′,’tT’);
$agi->verbose($agi->channel_status($agi->agi_channel));
}
mysql_close($dbh);
$agi->hangup();
?>

 

 

Advertisements

One thought on “PHPAGI + HANDLE MULTIPLE DID NUMBER

  1. Melisa October 9, 2014 at 9:38 am Reply

    You share interesting things here. I think that your website can go viral easily, but you must
    give it initial boost and i know how to do it, just search in google (with quotes) for –
    “mundillo traffic increase make your website go viral”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: