diff --git a/hitagi-entrada.php b/hitagi-entrada.php index 21d3558..63f42bb 100644 --- a/hitagi-entrada.php +++ b/hitagi-entrada.php @@ -23,6 +23,7 @@ $agientrada = new \Hit\Ami\AGIEntrada( ), array( 'fgId' => $fgId, + 'asteriskip' => '177.107.205.248', 'logEnabled' => $logEnabled, 'appdir' => $appdir, 'isXampp' => $isXampp diff --git a/includes/wrapper-noswoole.php b/includes/wrapper-noswoole.php index 4197587..9ca4093 100644 --- a/includes/wrapper-noswoole.php +++ b/includes/wrapper-noswoole.php @@ -32,7 +32,6 @@ function agiLogWrapper($logEnabled) if (isset($options['new'])) { file_put_contents($target, $texto); } else { - $texto = $texto . PHP_EOL; file_put_contents($target, $texto, FILE_APPEND); } } diff --git a/src/AGIEntrada.php b/src/AGIEntrada.php index 0631be8..a817c87 100644 --- a/src/AGIEntrada.php +++ b/src/AGIEntrada.php @@ -11,6 +11,7 @@ class AGIEntrada { $globais['logEnabled'] = !isset($globais['logEnabled']) ? false : $globais['logEnabled']; $globais['appdir'] = !isset($globais['appdir']) ? dirname(__FILE__) : $globais['appdir']; + $globais['asteriskip'] = !isset($globais['asteriskip']) ? 'localhost' : $globais['asteriskip']; $globais['isXampp'] = !isset($globais['isXampp']) ? false : $globais['isXampp']; $this->globais = $globais; $this->injection = $injection; @@ -51,6 +52,38 @@ class AGIEntrada // -------------------------------------------------------------------------------------------------------------------------------- + public function ivrGet() + { + $this->globais['fgItens'] = array(); + $this->globais['fgItemStart'] = array(); + if ($this->globais['fgId'] != '') { + if ($this->globais['asteriskip'] != '') { + // http://177.107.205.248/fluxograma/data-json/8999.json + $target = 'http://' . $this->globais['asteriskip'] . '/fluxograma/data-json/' . $this->globais['fgId'] . '.json'; + } else { + if (file_exists('/etc/asterisk')) { + $target = '/var/www/html/fluxograma/data-json/' . $this->globais['fgId'] . '.json'; + } else { + $target = 'dial/' . $this->globais['fgId'] . '.json'; + } + } + $this->agiLog($target); + $itens = file_get_contents($target); + if ($itens !== false) { + $itens = json_decode($itens, true); + foreach ($itens as $item) { + $this->globais['fgItens'][$item['id']] = $item; + if ($item['cmd'] == 'start') { + $this->globais['fgItemStart'] = $item; + } + } + unset($itens); + } + } + } + + // -------------------------------------------------------------------------------------------------------------------------------- + public function agiVarGet($varName = '') { @@ -392,7 +425,7 @@ class AGIEntrada public function fgItemRunPlayaudio($fgItem = array()) { - $this->agiLog('fgItemRunPlayaudio'); + $this->agiLog('===> fgItemRunPlayaudio'); $this->agiLog(print_r($fgItem, true)); $this->globais['digitado'] = ''; @@ -538,7 +571,7 @@ class AGIEntrada function fgItemRunStart($fgItem = array()) { - $this->agiLog('fgItemRunStart'); + $this->agiLog('===> fgItemRunStart'); $this->agiLog(print_r($fgItem, true)); // queue_log @@ -552,7 +585,7 @@ class AGIEntrada function fgItemRunTimeout($fgItem = array()) { - $this->agiLog('fgItemRunTimeout'); + $this->agiLog('===> fgItemRunTimeout'); $this->agiLog(print_r($fgItem, true)); $run_next = true; @@ -592,27 +625,9 @@ class AGIEntrada $this->logStart(); $this->logAdd("
" . print_r($this->globais, true) . "

"); - $this->globais['fgItens'] = array(); - $this->globais['fgItemStart'] = array(); - if ($this->globais['fgId'] != '') { - // ... - if (file_exists('/etc/asterisk')) { - $target = '/var/www/html/fluxograma/data-json/' . $this->globais['fgId'] . '.json'; - } else { - $target = 'dial/' . $this->globais['fgId'] . '.json'; - } - if (file_exists($target)) { - $itens = file_get_contents($target); - $itens = json_decode($itens, true); - foreach ($itens as $item) { - $this->globais['fgItens'][$item['id']] = $item; - if ($item['cmd'] == 'start') { - $this->globais['fgItemStart'] = $item; - } - } - unset($itens); - } - } + + $this->ivrGet(); + $this->logAdd("
" . print_r($this->globais['fgItens'], true) . "

"); $this->logAdd("
" . print_r($this->globais['fgItemStart'], true) . "

");