hitagi-entrada/hitagi-entrada.php

52 lines
1.2 KiB
PHP
Raw Normal View History

2024-12-12 14:00:09 +00:00
<?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();