From 570ed7c29b83c5c385c7ff590ceb8bea46061f70 Mon Sep 17 00:00:00 2001 From: Alan Oliveira Date: Fri, 20 Dec 2024 13:08:25 -0300 Subject: [PATCH] Updates... --- classes/AGIEntrada.php | 43 +++++++++++++++++++++++++++++++++---- classes/ArquivoRemoto.php | 2 +- hitagi-entrada-swoole.php | 12 +++++------ includes/wrapper-swoole.php | 2 +- teste-arquivoremoto.php | 21 ++++++++++++++++++ 5 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 teste-arquivoremoto.php diff --git a/classes/AGIEntrada.php b/classes/AGIEntrada.php index 8d498e3..982cb66 100644 --- a/classes/AGIEntrada.php +++ b/classes/AGIEntrada.php @@ -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'; diff --git a/classes/ArquivoRemoto.php b/classes/ArquivoRemoto.php index 113da17..dcea55b 100644 --- a/classes/ArquivoRemoto.php +++ b/classes/ArquivoRemoto.php @@ -1,6 +1,6 @@ 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; diff --git a/includes/wrapper-swoole.php b/includes/wrapper-swoole.php index 40e103b..6c1f3f6 100644 --- a/includes/wrapper-swoole.php +++ b/includes/wrapper-swoole.php @@ -21,6 +21,6 @@ function agiRunCmdWrapper($fd, $server) function agiLogWrapper() { return function ($texto) { - // ... + print_r("-----> LOG $texto\n"); }; } diff --git a/teste-arquivoremoto.php b/teste-arquivoremoto.php new file mode 100644 index 0000000..818aa93 --- /dev/null +++ b/teste-arquivoremoto.php @@ -0,0 +1,21 @@ +ip = '177.107.205.248'; +print_r($arquivoremoto, true); +$response = $arquivoremoto->salvar($argssend); +print_r($response, true); \ No newline at end of file