First commit

main
Alan Oliveira 2024-12-12 11:00:09 -03:00
commit eb95be64ec
2 changed files with 85 additions and 0 deletions

34
AGIEntrada.php 100644
View File

@ -0,0 +1,34 @@
<?php
class AGIEntrada
{
private $globais = array();
private $injection = array();
public function __construct($injection, $globais = array())
{
$this->globais = array();
$this->injection = $injection;
}
public function agiRunCmd($command)
{
return $this->injection['agiRunCmd']($command);
}
public function agiLog($texto)
{
return $this->injection['agiLog']($texto);
}
function tocarFila($queueId, $timeout)
{
return $this->agiRunCmd('EXEC Queue Q' . $queueId . ',ctT,,,' . $timeout);
}
public function run()
{
$this->globais['nomeFila'] = '10';
$response = $this->tocarFila($this->globais['nomeFila'], 1);
echo "\n" . $response . "\n";
}
}

51
hitagi-entrada.php 100644
View File

@ -0,0 +1,51 @@
<?php
require_once 'AGIEntrada.php';
function agiRunCmdWrapper($stdin, $stdout)
{
return function ($command) use ($stdin, $stdout) {
$texto = "-----> EXECUTAR COMANDO $command";
return $texto;
};
}
function agiLogWrapper($logEnabled)
{
return function ($texto) use ($logEnabled) {
if ($logEnabled) {
$filename = str_replace('.php', '-log.html', __FILE__);
$fp = fopen($filename, 'a');
fwrite($fp, $texto);
fclose($fp);
}
};
}
// --------------------------------------------------------------------------------------------------------------------------------
$stdin = fopen('php://stdin', 'r');
$stdout = fopen('php://stdout', 'w');
$isXampp = (file_exists('C:\xampp'));
$logEnabled = false;
$appdir = dirname(__FILE__);
chdir($appdir);
date_default_timezone_set('America/Bahia');
$agientrada = new AGIEntrada(
array(
'agiRunCmd' => agiRunCmdWrapper($stdin, $stdout),
'agiLog' => agiLogWrapper($logEnabled)
),
array(
'isxampp' => $isXampp,
'logEnabled' => $logEnabled
)
);
$agientrada->run();
fclose($stdin);
fclose($stdout);
exit();