/
home
/
clp
/
htdocs
/
app
/
files
/
src
/
Site
/
up file
home
<?php namespace App\Site; use App\Entity\Site as SiteEntity; use App\System\CommandExecutor; use App\System\Command\CreateUserCommand; use App\System\Command\CreateDirectoryCommand; use App\System\Command\ServiceReloadCommand; use App\System\Command\ChownCommand; use App\System\Command\FindChmodCommand; use App\System\Command\WriteFileCommand; use App\Site\Nginx\Vhost\PhpTemplate; use App\Site\Nginx\Vhost\StaticTemplate; use App\Site\Nginx\Vhost\NodejsTemplate; use App\Site\Nginx\Vhost\PythonTemplate; use App\Site\Nginx\Vhost\ReverseProxyTemplate; abstract class Creator { public const NGINX_VHOST_DIRECTORY = "\x2f\x65\164\x63\57\x6e\x67\x69\x6e\170\57\163\151\x74\145\163\x2d\145\x6e\x61\142\154\x65\144\57"; public const NGINX_SSL_CERTIFICATES_DIRECTORY = "\x2f\145\x74\x63\x2f\x6e\147\151\x6e\170\x2f\163\x73\154\55\143\x65\162\164\x69\146\x69\x63\x61\x74\145\x73\x2f"; public const LOGROTATE_DIRECTORY = "\x2f\x65\x74\x63\x2f\154\x6f\x67\x72\157\164\141\x74\x65\x2e\x64\x2f"; protected Site $site; protected CommandExecutor $commandExecutor; public function __construct(Site $site) { $this->site = $site; $this->commandExecutor = new CommandExecutor(); } public function createUser() : void { goto D8b20; D7803: $skeletonDirectory = realpath(dirname(__FILE__) . "\x2f\x2e\56\x2f\x2e\x2e\57\162\145\163\157\x75\x72\x63\x65\x73\x2f\x65\x74\143\x2f\163\x6b\x65\x6c\x2f\163\x69\164\145\55\165\163\145\162\x2f"); goto f5588; Ea2ee: $createUserCommand->setShell("\57\x62\151\x6e\57\x62\x61\x73\x68"); goto fef03; A0518: $this->commandExecutor->execute($createUserCommand); goto Ef231; Aa4b8: $createUserCommand->setPassword($siteUserPassword); goto Ea2ee; Dfe73: $siteUserPassword = $this->site->getUserPassword(); goto d2520; D8b20: $siteUser = $this->site->getUser(); goto Dfe73; f5588: $createUserCommand = new CreateUserCommand(); goto b7bcb; fef03: $createUserCommand->setSkeletonDirectory($skeletonDirectory); goto ce71b; A6be0: $createUserCommand->createHomeDirectory(true); goto A0518; ce71b: $createUserCommand->setHomeDirectory($homeDirectory); goto A6be0; d2520: $homeDirectory = sprintf("\x2f\150\157\155\145\57\45\163", $siteUser); goto D7803; b7bcb: $createUserCommand->setUserName($siteUser); goto Aa4b8; Ef231: } public function createRootDirectory() { goto aa5cc; aa5cc: $rootDirectory = $this->getRootDirectory(); goto D0135; D0135: $createRootDirectoryCommand = new CreateDirectoryCommand(); goto f59ee; a6d6e: $this->commandExecutor->execute($createRootDirectoryCommand); goto cd1bb; f59ee: $createRootDirectoryCommand->setDirectory($rootDirectory); goto a6d6e; cd1bb: } public function createNginxVhost() : void { goto ddbc6; bc9ad: $vhostTemplate->removeEmptyPlaceholders(); goto ce6a0; f3447: $vhostTemplate->build(); goto bc9ad; bc27c: $writeVhostFileCommand = new WriteFileCommand(); goto Ca78c; ce6a0: $vhostContent = $vhostTemplate->getContent(); goto bc27c; a8d4b: $vhostTemplate->setContent($vhostFileContent); goto Cdf6b; aa421: f897b: goto e91bd; e91bd: ae547: goto a8d4b; Cdf6b: $vhostFile = sprintf("\x25\163\x2f\x25\163\56\x63\157\156\x66", rtrim(self::NGINX_VHOST_DIRECTORY, "\x2f"), $domainName); goto f3447; Ca78c: $writeVhostFileCommand->setFile($vhostFile); goto c998b; c998b: $writeVhostFileCommand->setContent($vhostContent); goto d5a9e; ddbc6: $domainName = $this->site->getDomainName(); goto Fac63; d5a9e: $this->commandExecutor->execute($writeVhostFileCommand); goto Ddd72; A6928: switch ($this->site->getType()) { case SiteEntity::TYPE_PHP: $vhostTemplate = new PhpTemplate($this->site); goto ae547; case SiteEntity::TYPE_NODEJS: $vhostTemplate = new NodejsTemplate($this->site); goto ae547; case SiteEntity::TYPE_STATIC: $vhostTemplate = new StaticTemplate($this->site); goto ae547; case SiteEntity::TYPE_PYTHON: $vhostTemplate = new PythonTemplate($this->site); goto ae547; case SiteEntity::TYPE_REVERSE_PROXY: $vhostTemplate = new ReverseProxyTemplate($this->site); goto ae547; } goto aa421; Fac63: $vhostFileContent = $this->site->getVhostTemplate(); goto A6928; Ddd72: } public function createLogrotateFile() { goto Ca110; edab4: $logrotateTemplate = file_get_contents($logrotateTemplateFile); goto A4309; A4309: $logrotateFile = sprintf("\x25\163\57\x25\163", rtrim(self::LOGROTATE_DIRECTORY, "\x2f"), $siteUser); goto f1708; fa089: $writeLogrotateFileCommand->setContent($logrotateFileContent); goto Aa7f9; b7598: $logrotateTemplateFile = realpath(dirname(__FILE__) . "\57\56\56\57\x2e\56\x2f\162\145\163\x6f\165\162\143\145\x73\x2f\x65\164\x63\x2f\x6c\157\x67\x72\157\x74\x61\x74\145\57\164\145\x6d\160\154\x61\x74\x65"); goto edab4; Aa7f9: $this->commandExecutor->execute($writeLogrotateFileCommand); goto e1797; D16b6: $writeLogrotateFileCommand = new WriteFileCommand(); goto B2449; f1708: $logrotateFileContent = str_replace(["\173\x7b\165\x73\145\x72\x7d\175", "\x7b\173\147\x72\x6f\x75\x70\x7d\175"], [$siteUser, $siteUser], $logrotateTemplate); goto D16b6; B2449: $writeLogrotateFileCommand->setFile($logrotateFile); goto fa089; Ca110: $siteUser = $this->site->getUser(); goto b7598; e1797: } public function resetPermissions() : void { goto Deaf6; Faab8: $homeDirectoryChmodCommand = new FindChmodCommand(); goto b5e96; d2953: $chownCommand = new ChownCommand(); goto Ed3f7; b5e96: $homeDirectoryChmodCommand->setFile($homeDirectory); goto d7c82; Ac2bf: $userSshDirectory = sprintf("\57\x68\x6f\x6d\145\x2f\x25\x73\57\56\x73\x73\150", $siteUser); goto Ce746; Deaf6: $siteUser = $this->site->getUser(); goto A5758; C4750: $this->commandExecutor->execute($userSshDirectoryChmodCommand, 90); goto Cd63e; f4e6b: $chownCommand->setUser($siteUser); goto A056d; Ffed5: $this->commandExecutor->execute($homeDirectoryChmodCommand, 90); goto C4750; d7c82: $homeDirectoryChmodCommand->setDirectoryChmod(770); goto f0397; A5758: $homeDirectory = sprintf("\57\x68\x6f\155\x65\57\x25\x73", $siteUser); goto d2953; Edb55: $userSshDirectoryChmodCommand->setDirectoryChmod(700); goto b46c1; Aae1d: $userSshDirectoryChmodCommand->setFile($userSshDirectory); goto Edb55; f0397: $homeDirectoryChmodCommand->setFileChmod(770); goto Ac2bf; b214e: $chownCommand->setRecursive(true); goto f4e6b; b46c1: $userSshDirectoryChmodCommand->setFileChmod(600); goto a1d63; A056d: $chownCommand->setGroup($siteUser); goto Faab8; a1d63: $this->commandExecutor->execute($chownCommand, 90); goto Ffed5; Ce746: $userSshDirectoryChmodCommand = new FindChmodCommand(); goto Aae1d; Ed3f7: $chownCommand->setFile($homeDirectory); goto b214e; Cd63e: } public function reloadNginxService() : void { $this->reloadService("\156\x67\151\156\170"); } protected function getRootDirectory() : string { goto E60e8; E60e8: $siteUser = $this->site->getUser(); goto Fb722; Fb722: $rootDirectory = $this->site->getRootDirectory(); goto e9db6; e9db6: $rootDirectory = sprintf("\x2f\150\x6f\155\145\x2f\x25\163\x2f\x68\164\144\157\x63\x73\57\x25\x73", $siteUser, $rootDirectory); goto f683f; f683f: return $rootDirectory; goto Aa897; Aa897: } public function createPrivateKeyAndCertificate() : void { goto C64fc; Bf535: $certificate = $this->site->getCertificate(); goto Aaecb; d7f52: $certificateFile = sprintf("\x25\163\57\x25\163\x2e\x63\x72\164", rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "\57"), $domainName); goto cb5e5; Fa8c9: $this->commandExecutor->execute($writeCertificateFileCommand); goto f6081; Ff63c: $writeCertificateFileCommand = new WriteFileCommand(); goto b586c; Ba81f: $this->commandExecutor->execute($writePrivateKeyFileCommand); goto Fa8c9; b2936: $writeCertificateFileCommand->setContent($certificate->getCertificate()); goto Ba81f; Bc8bb: $writePrivateKeyFileCommand->setFile($privateKeyFile); goto cdf72; C64fc: $domainName = $this->site->getDomainName(); goto Bf535; Aaecb: $privateKeyFile = sprintf("\45\x73\57\x25\163\x2e\x6b\145\x79", rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "\x2f"), $domainName); goto d7f52; cdf72: $writePrivateKeyFileCommand->setContent($certificate->getPrivateKey()); goto Ff63c; b586c: $writeCertificateFileCommand->setFile($certificateFile); goto b2936; cb5e5: $writePrivateKeyFileCommand = new WriteFileCommand(); goto Bc8bb; f6081: } public function reloadService($serviceName) { goto e5fbd; e5fbd: if (!("\x64\x65\166" != $_ENV["\101\120\x50\x5f\105\116\126"])) { goto d2d72; } goto Fe79b; b4b5d: $reloadServiceCommand->setServiceName($serviceName); goto Fdbcc; Fdbcc: $this->commandExecutor->execute($reloadServiceCommand); goto B8672; B8672: d2d72: goto Ed318; Fe79b: $reloadServiceCommand = new ServiceReloadCommand(); goto b4b5d; Ed318: } }