Exemplo n.º 1
2
#!/usr/bin/php-cli -q
<?php 
require dirname(__FILE__) . '/../lib/phpagi/phpagi.php';
require dirname(__FILE__) . '/../include/db_utils.inc.php';
require dirname(__FILE__) . '/common/AGI_Logger.class.php';
require dirname(__FILE__) . '/common/AGI_CDR.class.php';
require dirname(__FILE__) . '/common/AGI_Utils.php';
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
// Get Called Extension informations
$called_ext = $agi->request['agi_extension'];
$Extension_D = DB_Extension($called_ext);
// Get 'DialTone' Parameters
$DialTone = Database_Entry('Ext_DialTone', $Extension_D['PK_Extension']);
//CDR: Set called info
$cdr->set_called("{$DialTone['PK_Extension']}", "DialTone", "Dial Tone", "{$Extension_D['Extension']}");
// Call DISA Application
if ($DialTone['Password'] != '') {
    $agi->exec('DISA', array($DialTone['Password'], 'internal'));
} else {
    $agi->exec('DISA', array('no-password', 'internal'));
}
Exemplo n.º 2
0
            if (!empty($rule['Name'])) {
                $callerid['Name'] = $rule['Name'];
            }
            if (!empty($rule['Number'])) {
                $callerid['Number'] = $rule['Number'];
            }
        } elseif ($rule['Type'] == 'Multiple') {
            $callerid['Number'] = $callerid['Number'] + $rule['Add'];
            $callerid['Number'] = $rule['PrependDigits'] . $callerid['Number'];
        }
    }
    return $callerid;
}
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
//CDR : Flush existing entry if both called and caller are known
if ($cdr->caller_known() && $cdr->called_known()) {
    $cdr->flush_cdr();
}
// Get Called Extension informations
$called_ext = $agi->request['agi_extension'];
// Get Caller Extension infomation
$cid = $agi->parse_callerid();
$caller_ext = $cid['username'];
$Extension_S = DB_Extension($caller_ext);
//CDR: Set caller information
$cdr->set_caller($Extension_S['PK_Extension'], $Extension_S['Type'], DB_Extension_Name($caller_ext), $caller_ext);
//CDR: Set called information
$cdr->set_called(0, '', '', $called_ext);
// CDR: Push dial event
Exemplo n.º 3
0
#!/usr/bin/php-cli -q
<?php 
require dirname(__FILE__) . '/../lib/phpagi/phpagi.php';
require dirname(__FILE__) . '/../include/db_utils.inc.php';
require dirname(__FILE__) . '/common/AGI_Logger.class.php';
require dirname(__FILE__) . '/common/AGI_CDR.class.php';
require dirname(__FILE__) . '/common/AGI_Utils.php';
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
// Get Called Extension informations
$called_ext = $agi->request['agi_extension'];
$Extension_D = DB_Extension($called_ext);
// Get Called Queue information
$Queue = Database_Entry('Ext_Queues', $Extension_D['PK_Extension']);
//CDR: Set called info
$cdr->set_called("{$Queue['PK_Extension']}", "Queue", "{$Queue['Name']}", "{$Extension_D['Extension']}");
// Set values to pass to [Extension_Queue_RingQueue]
$QUEUE_ARGS = "queue-{$Queue['PK_Extension']}";
if ($Queue['PlayMohInQueue'] == 0) {
    $QUEUE_ARGS .= "|r||||";
} else {
    $QUEUE_ARGS .= "|||||";
}
// Maybe we can pass our cdr id to the agents called throught this url
//$QUEUE_ARGS .= "|http://www.google.com";
$QUEUES_NOAGENTS_EXTEN = "{$Queue['JoinEmptyExtension']}";
$QUEUE_MAXCYCLES_EXTEN = "{$Queue['CyclesExtension']}";
$QUEUE_MAXLEN_EXTEN = "{$Queue['MaxLenExtension']}";
$QUEUE_TIMEOUT_EXTEN = "{$Queue['TimeoutExtension']}";
$QUEUE_OPER_EXTEN = "{$Queue['OperatorExtension']}";
Exemplo n.º 4
0
        case 'append':
            $callerid[$param['Section']] = $callerid[$param['Section']] . "{$text}";
            break;
        case 'replace':
            $callerid[$param['Section']] = "{$text}";
            break;
    }
    $agi->request['calledid_name'] = $callerid['name'];
    $agi->request['agi_callerid'] = $callerid['number'];
    $agi->set_callerid("\"{$callerid['name']}\"<{$callerid['number']}>");
}
set_time_limit(300);
error_reporting(E_ALL);
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
$agi->answer();
$ext = $agi->request['agi_extension'];
// Get 'Extension' table info
$query = "SELECT PK_Extension, Extension, Type FROM Extensions WHERE Extension = '{$ext}' LIMIT 1";
$result = $mysqli->query($query) or $logger->error_sql("", $query, __FILE__, __LINE__);
$Extension = $result->fetch_assoc();
// Get Starting Parameters
$query = "SELECT * FROM Ext_IVR WHERE PK_Extension = '{$Extension['PK_Extension']}' LIMIT 1";
$result = $mysqli->query($query) or $logger->error_sql("", $query, __FILE__, __LINE__);
$Ext_IVR = $result->fetch_assoc();
// Get Starting Order
$query = "SELECT `Order` FROM IVR_Actions WHERE PK_Action = {$Ext_IVR['FK_Action']} LIMIT 1";
$result = $mysqli->query($query) or $logger->error_sql("", $query, __FILE__, __LINE__);
if ($mysqli->numrows($result) == 1) {
    $step = $mysqli->fetch_array($result);
Exemplo n.º 5
0
#!/usr/bin/php-cli -q
<?php 
require dirname(__FILE__) . '/../lib/phpagi/phpagi.php';
require dirname(__FILE__) . '/../include/db_utils.inc.php';
require dirname(__FILE__) . '/common/AGI_Logger.class.php';
require dirname(__FILE__) . '/common/AGI_CDR.class.php';
require dirname(__FILE__) . '/common/AGI_Utils.php';
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
// Get Called Extension informations
$called_ext = $agi->request['agi_extension'];
$Extension_D = DB_Extension($called_ext);
// Get 'Intercom' Parameters
$Intercom = Database_Entry('Ext_Intercom', $Extension_D['PK_Extension']);
// Get the extension of the caller
$cid = $agi->parse_callerid();
$caller_ext = $cid['username'];
// See if the caller is allowed to use this extension
if ($Intercom['Use_Admins_ByAccount']) {
    $query = "\n\t\tSELECT\n\t\t\tExtension\n\t\tFROM\n\t\t\tExt_Intercom_Admins\n\t\t\tINNER JOIN Extensions ON PK_Extension = FK_Ext_Admin\n\t\tWHERE\n\t\t\tFK_Extension = {$Intercom['PK_Extension']}\n\t\t\tAND\n\t\t\tExtensions.Extension = {$caller_ext}\n\t\tLIMIT 1\n\t";
} else {
    $query = "\n\t\tSELECT\n\t\t\tExtension\n\t\tFROM\n\t\t\tExt_Intercom_Admins\n\t\t\tINNER JOIN Extension_Groups ON Extension_Groups.FK_Group = Ext_Intercom_Admins.FK_Ext_Group\n\t\t\tINNER JOIN Extensions       ON Extensions.PK_Extension   = Extension_Groups.FK_Extension\n\t\tWHERE\n\t\t\tExt_Intercom_Admins.FK_Extension = {$Intercom['PK_Extension']}\n\t\t\tAND\n\t\t\tExtensions.Extension = {$caller_ext}\n\t\tLIMIT 1\n\t";
}
$result = $mysqli->query($query) or $agi->verbose($mysqli->error . $query);
if ($mysqli->numrows($result) != 1) {
    $agi->stream_file('beeperr');
    $agi->hangup();
    exit(0);
}
//CDR: Set called info
#!/usr/bin/php-cli -q
<?php 
require dirname(__FILE__) . '/../lib/phpagi/phpagi.php';
require dirname(__FILE__) . '/../include/db_utils.inc.php';
require dirname(__FILE__) . '/common/AGI_Logger.class.php';
require dirname(__FILE__) . '/common/AGI_CDR.class.php';
require dirname(__FILE__) . '/common/AGI_Utils.php';
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
// Get Called Extension informations
$called_ext = $agi->request['agi_extension'];
$Extension_D = DB_Extension($called_ext);
// Get 'Voicemail' Parameters
$SimpleConf = Database_Entry('Ext_SimpleConf', $Extension_D['PK_Extension']);
//CDR: Set called info
$cdr->set_called("{$SimpleConf['PK_Extension']}", "SimpleConf", "Simple Conference", "{$Extension_D['Extension']}");
// Set transfer extension if we have one
if ($SimpleConf['TransferExt'] != "") {
    $agi->set_variable('CONF_TRANSFER_EXT', $SimpleConf['TransferExt']);
}
// Call SimpleConf application
$params = 'S';
if ($SimpleConf['PlaySound'] == 1) {
    $params .= 'n';
}
if ($SimpleConf['PlayMOH'] == 1) {
    $params .= 'm';
}
$agi->exec('Conference', "simpleconf-{$Extension_D['PK_Extension']}/{$params}");
Exemplo n.º 7
0
#!/usr/bin/php-cli -q
<?php 
set_time_limit(30);
error_reporting(E_ALL);
require dirname(__FILE__) . '/../lib/phpagi/phpagi.php';
require dirname(__FILE__) . '/../include/db_utils.inc.php';
require dirname(__FILE__) . '/common/AGI_Logger.class.php';
require dirname(__FILE__) . '/common/AGI_CDR.class.php';
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
// CDR: Set call type
$cdr->set_type('IN');
// CDR: Set caller name and number
$cid = $agi->parse_callerid();
$agi->verbose($cid);
$caller_ext = $cid['username'];
$caller_name = $agi->request['agi_calleridname'];
$cdr->set_caller('', '', $caller_name, $caller_ext);
if ($agi->request['agi_type'] == 'SIP') {
    preg_match('/^sip_provider_(\\d+)/', $agi->request['agi_context'], $matches);
    $PK_SipProvider = $matches[1];
    $query = "SELECT Name FROM SipProviders WHERE PK_SipProvider={$PK_SipProvider} LIMIT 1";
    $result = $mysqli->query($query) or $agi->verbose($mysqli->error . $query);
    $prov = $result->fetch_assoc();
    $cdr->push_event("INPROVIDER", "SIP,{$prov['Name']}");
} elseif ($agi->request['agi_type'] == 'IAX2') {
    preg_match('/^iax_provider_(\\d+)/', $agi->request['agi_context'], $matches);
    $PK_IaxProvider = $matches[1];
    $query = "SELECT Name FROM IaxProviders WHERE PK_IaxProvider={$PK_IaxProvider} LIMIT 1";
    $result = $mysqli->query($query) or $agi->verbose($mysqli->error . $query);
Exemplo n.º 8
0
#!/usr/bin/php-cli -q
<?php 
require dirname(__FILE__) . '/../lib/phpagi/phpagi.php';
require dirname(__FILE__) . '/../include/db_utils.inc.php';
require dirname(__FILE__) . '/common/AGI_Logger.class.php';
require dirname(__FILE__) . '/common/AGI_CDR.class.php';
require dirname(__FILE__) . '/common/AGI_Utils.php';
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
// Get Called Extension informations
$called_ext = $agi->request['agi_extension'];
$Extension_D = DB_Extension($called_ext);
// Get Called SipPhone information
$SipPhone = Database_Entry('Ext_SipPhones', $Extension_D['PK_Extension']);
//CDR: Set called info
$cdr->set_called("{$SipPhone['PK_Extension']}", "SipPhone", "{$SipPhone['FirstName']} {$SipPhone['LastName']}", "{$Extension_D['Extension']}");
//CDR: Push RING event
$cdr->push_event('RING', "{$SipPhone['FirstName']} {$SipPhone['LastName']},{$Extension_D['Extension']}");
// Perform the Dial
$agi->exec('Dial', array("SIP/{$Extension_D['Extension']}", 10, 'tT'));
//CDR: Push DIALSTATUS
$resp = $agi->get_variable('DIALSTATUS');
$DIALSTATUS = $resp['data'];
$resp = $agi->get_variable('HANGUPCAUSE');
$HANGUPCAUSE = $resp['data'];
if ($DIALSTATUS != "") {
    $cdr->push_event('DIALSTATUS', "{$DIALSTATUS},{$HANGUPCAUSE}");
}
if ($DIALSTATUS != 'ANSWER') {
    // Exit if voicemail is not defined for this extension
Exemplo n.º 9
0
#!/usr/bin/php-cli -q
<?php 
set_time_limit(300);
error_reporting(E_ALL);
require dirname(__FILE__) . '/../lib/phpagi/phpagi.php';
require dirname(__FILE__) . '/../include/db_utils.inc.php';
require dirname(__FILE__) . '/common/AGI_Logger.class.php';
require dirname(__FILE__) . '/common/AGI_CDR.class.php';
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
//CDR : Flush existing entry if both called and caller are known
if ($cdr->caller_known() && $cdr->called_known()) {
    $cdr->push_hangup();
    $cdr->flush_cdr();
}
Exemplo n.º 10
-3
#!/usr/bin/php-cli -q
<?php 
require dirname(__FILE__) . '/../lib/phpagi/phpagi.php';
require dirname(__FILE__) . '/../include/db_utils.inc.php';
require dirname(__FILE__) . '/common/AGI_Logger.class.php';
require dirname(__FILE__) . '/common/AGI_CDR.class.php';
require dirname(__FILE__) . '/common/AGI_Utils.php';
$agi = new AGI();
$logger = new AGI_Logger($agi);
$cdr = new AGI_CDR($agi);
// Get Called Extension informations
$called_ext = $agi->request['agi_extension'];
$Extension_D = DB_Extension($called_ext);
// Get 'Voicemail' Parameters
$Voicemail = Database_Entry('Ext_Voicemail', $Extension_D['PK_Extension']);
//CDR: Set called info
$cdr->set_called("{$Voicemail['PK_Extension']}", "Voicemail", "Voice Mail", "{$Extension_D['Extension']}");
// Get the extension of the caller
$cid = $agi->parse_callerid();
$caller_ext = $cid['username'];
// Call Voicemail application
$VM_MAIN_ARGS = "{$caller_ext}@default";
if ($Voicemail['RequirePassword'] != 1) {
    $VM_MAIN_ARGS .= "|s";
}
$agi->exec('VoicemailMain', $VM_MAIN_ARGS);