Sindbad~EG File Manager
<?php
namespace App\Command;
use App\DataTransformer\Enrich;
use App\DataTransformer\Expand;
use App\DataTransformer\ServerSelector;
use App\Parser\ApacheHttpdParser;
use App\Parser\CpanelUserdataParser;
use App\Parser\LswsHttpdParser;
use App\Parser\ServerModeParser;
use App\Processor\OpenrestyProcessor;
use App\Service\Lsws\LswsCommandRunner;
use App\Service\Lsws\LswsConfigManager;
use App\Service\Lsws\LswsListenerManager;
use App\Service\Lsws\LswsVhostManager;
use O2switch\CpanelLib\Client\OpenrestyInternalApi;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Output\OutputInterface;
abstract class BaseCommand extends Command
{
const RETURN_OK = 0;
const RETURN_PARSE_ERR = 1;
const RETURN_CREATE_ERR = 2;
const RETURN_CONF_ERR = 3;
const RETURN_GENERIC_ERR = 4;
public function __construct(
protected string $apacheHttpdConf,
protected string $lswsHttpdConf,
protected int $period,
protected LoggerInterface $log,
protected CpanelUserdataParser $cpanelUserdataParser,
protected ApacheHttpdParser $apacheHttpdParser,
protected Enrich $enrichDt,
protected Expand $expandDt,
protected OpenrestyInternalApi $openrestyApiClient,
protected OpenrestyProcessor $openrestyProcessor,
protected ServerModeParser $serverModeParser,
protected LswsVhostManager $lswsVhostManager,
protected LswsCommandRunner $lswsCommandRunner,
protected LswsListenerManager $lswsListenerManager,
protected LswsConfigManager $lswsConfigManager,
protected ServerSelector $serverSelector,
protected LswsHttpdParser $lswsHttpdParser,
protected bool $disableOpenLitespeed,
$name = null
){
parent::__construct($name);
try {
@ini_set('memory_limit', -1);
} catch (\Throwable $e){
;
}
}
protected function writeError(OutputInterface $output, string $err): void
{
$output->writeln("<error>$err</error>");
}
protected function writeErrorAndDie(OutputInterface $output, string $err, int $status = self::RETURN_GENERIC_ERR){
$this->writeError($output, $err);
$this->setCode($status);
throw new RuntimeException($err);
}
/**
* Check if we need to generate the new conf, based on the last modified date of the httpd.conf
* @return bool
*/
protected function checkGenerateNeeded() : bool {
$apacheFileModifiedTime = filemtime($this->apacheHttpdConf);
$lswsFileModifiedTime = filemtime($this->lswsHttpdConf);
return ($apacheFileModifiedTime + $this->period > time()) || ($lswsFileModifiedTime + $this->period > time());
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists