Updates...

main
Alan Oliveira 2024-12-20 13:08:25 -03:00
parent 272c662d82
commit 570ed7c29b
5 changed files with 68 additions and 12 deletions

View File

@ -94,8 +94,8 @@ class AGIEntrada
public function agiAddCallback($args = array())
{
// $this->agiLog("===> " . __FUNCTION__ . " <===");
// $this->agiLog(print_r($args, true));
$this->agiLog("===> " . __FUNCTION__ . " <===");
$this->agiLog(print_r($args, true));
// https://www.voip-info.org/asterisk-auto-dial-out/
@ -115,6 +115,7 @@ class AGIEntrada
// WaitTime
$filename = time() . '-' . rand(100, 999) . '.call';
/*
if (file_exists('/var/www/html/hitmanager/dial/')) {
$target = '/var/www/html/hitmanager/dial/' . $filename;
file_put_contents($target, $calldata);
@ -126,6 +127,26 @@ class AGIEntrada
$target2 = '/var/spool/asterisk/outgoing/' . $filename;
rename($target, $target2);
}
*/
/*
$target = $this->globais['appdir'] . DIRECTORY_SEPARATOR . 'outgoing' . DIRECTORY_SEPARATOR . $filename;
file_put_contents($target, $calldata);
$time = time() + 30;
touch($target, $time);
*/
$argssend = array();
// $argssend['filedir'] = '/var/spool/asterisk/outgoing';
$argssend['filedir'] = '/var/www/html/apagar';
$argssend['filename'] = $filename;
$argssend['filebase64'] = base64_encode($calldata);
$arquivoremoto = new ArquivoRemoto();
$arquivoremoto->ip = $this->globais['hostip'];
$this->agiLog(print_r($arquivoremoto, true));
$response = $arquivoremoto->salvar($argssend);
$this->agiLog(print_r($response, true));
}
public function agiRecordFilaIfAuditoria($args = array())
@ -583,7 +604,8 @@ class AGIEntrada
if ($varName == 'CALLERID') {
if (substr($response, 0, 14) == '200 result=1 (') {
$explodido = explode('<', $response);
$return = substr($explodido[1], 0, -2);
// $return = str_replace('>)', '', trim($explodido[1]));
$return = substr(trim($explodido[1]), 0, -2);
}
} else {
$explodido = explode("(", $response);
@ -2978,7 +3000,20 @@ class AGIEntrada
$cmd = 'EXEC QUEUELOG NONE,' . $this->globais['uniqueid'] . ',NONE,INFO|IVRAPPEND|->' . $this->globais['fgId'];
$response = $this->agiRunCmd($cmd);
$this->fgItemRun($this->globais['fgItemStart']);
if (1 == 1) {
// Teste
$callerid = $this->agiVarGet('CALLERID');
$this->agiLog('callerid: ' . $callerid);
$arr = array(
'ramal' => '6999',
'numero' => $callerid
);
$this->agiAddCallback($arr);
} else {
$this->fgItemRun($this->globais['fgItemStart']);
}
// 1353461660|1353461627.33271|NONE|NONE|INFO|IVRHANGUP|
//$cmd = 'EXEC QUEUELOG NONE,' . $GLOBALS['uniqueid'] . ',NONE,NONE,INFO|IVRHANGUP';

View File

@ -1,6 +1,6 @@
<?php
namespace Hit\Ami;
namespace Hitlabs\Hitagi;
class ArquivoRemoto
{

View File

@ -56,7 +56,7 @@ $server->on("receive", function ($server, $fd, $reactor_id, $data) {
$comando = trim($partes[0]);
if (substr($comando, 0, 8) == 'agi_arg_') {
$number = str_replace('agi_arg_', '', $comando);
$argv[$number] = trim($partes[$number]);
$argv[$number] = trim($partes[1]);
}
}
$table_data['agi_arg'] = json_encode($argv);
@ -67,7 +67,7 @@ $server->on("receive", function ($server, $fd, $reactor_id, $data) {
$server_close = true;
}
if ((isset($argv['1'])) && ($table_data['agi'] != 1)) {
if ((isset($argv['3'])) && ($table_data['agi'] != 1)) {
$table_data = [
'agi' => 1
@ -75,11 +75,11 @@ $server->on("receive", function ($server, $fd, $reactor_id, $data) {
$server->table->set($fd, $table_data);
$fgId = $argv[1]; // Numero do DID
// $hostname = $argv[2];
// $hostip = $argv[3];
$hostname = $argv[2];
$hostip = $argv[3];
// $fgId = '8999';
$hostname = 'hitpbx-050';
$hostip = '177.107.205.248';
// $hostname = 'hitpbx-050';
// $hostip = '177.107.205.248';
$logEnabled = true;
$isXampp = false;

View File

@ -21,6 +21,6 @@ function agiRunCmdWrapper($fd, $server)
function agiLogWrapper()
{
return function ($texto) {
// ...
print_r("-----> LOG $texto\n");
};
}

View File

@ -0,0 +1,21 @@
<?php
require __DIR__ . '/vendor/autoload.php';
use Hitlabs\Hitagi\ArquivoRemoto;
$calldata = "Channel: Local/6999@padrao" . "\n";
$calldata .= "Context: padrao\n";
$calldata .= "Extension: 06999\n";
$filename = time() . '-' . rand(100, 999) . '.call';
$argssend = array();
// $argssend['filedir'] = '/var/spool/asterisk/outgoing';
$argssend['filedir'] = '/var/www/html/apagar';
$argssend['filename'] = $filename;
$argssend['filebase64'] = base64_encode($calldata);
$arquivoremoto = new ArquivoRemoto();
$arquivoremoto->ip = '177.107.205.248';
print_r($arquivoremoto, true);
$response = $arquivoremoto->salvar($argssend);
print_r($response, true);