55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?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.txt', __FILE__);
|
|
$fp = fopen($filename, 'a');
|
|
fwrite($fp, $texto);
|
|
fclose($fp);
|
|
}
|
|
};
|
|
}
|
|
|
|
// --------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
$stdin = fopen('php://stdin', 'r');
|
|
$stdout = fopen('php://stdout', 'w');
|
|
|
|
$fgId = (isset($argv[1])) ? $argv[1] : ''; // DID
|
|
|
|
$logEnabled = true;
|
|
$isXampp = (file_exists('C:\xampp'));
|
|
|
|
$appdir = dirname(__FILE__);
|
|
chdir($appdir);
|
|
|
|
date_default_timezone_set('America/Bahia');
|
|
|
|
$agientrada = new AGIEntrada(
|
|
array(
|
|
'agiRunCmd' => agiRunCmdWrapper($stdin, $stdout),
|
|
'agiLog' => agiLogWrapper($logEnabled)
|
|
),
|
|
array(
|
|
'fgId' => $fgId,
|
|
'logEnabled' => $logEnabled,
|
|
'isXampp' => $isXampp
|
|
)
|
|
);
|
|
$agientrada->run();
|
|
|
|
fclose($stdin);
|
|
fclose($stdout);
|
|
exit();
|