Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace App\Site; use App\Entity\Site as SiteEntity; use App\System\Command..
Decoded Output download
<?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 = "/etc/nginx/sites-enabled/";
public const NGINX_SSL_CERTIFICATES_DIRECTORY = "/etc/nginx/ssl-certificates/";
public const LOGROTATE_DIRECTORY = "/etc/logrotate.d/";
protected Site $site;
protected CommandExecutor $commandExecutor;
public function __construct(Site $site)
{
$this->site = $site;
$this->commandExecutor = new CommandExecutor();
}
public function createUser(): void
{
goto D1b2c;
C688c:
$createUserCommand->setShell("/bin/bash");
goto e4aac;
D1b2c:
$siteUser = $this->site->getUser();
goto fb5e6;
Cc0fd:
$createUserCommand->setUserName($siteUser);
goto a9b07;
fe49d:
$homeDirectory = sprintf("/home/%s", $siteUser);
goto db720;
db720:
$skeletonDirectory = realpath(dirname(__FILE__) . "/../../resources/etc/skel/site-user/");
goto E3a81;
d4f4c:
$createUserCommand->setHomeDirectory($homeDirectory);
goto A2225;
E7030:
$this->commandExecutor->execute($createUserCommand);
goto cdc3e;
fb5e6:
$siteUserPassword = $this->site->getUserPassword();
goto fe49d;
E3a81:
$createUserCommand = new CreateUserCommand();
goto Cc0fd;
A2225:
$createUserCommand->createHomeDirectory(true);
goto E7030;
e4aac:
$createUserCommand->setSkeletonDirectory($skeletonDirectory);
goto d4f4c;
a9b07:
$createUserCommand->setPassword($siteUserPassword);
goto C688c;
cdc3e:
}
public function createRootDirectory()
{
goto Fb09a;
F1703:
$createRootDirectoryCommand = new CreateDirectoryCommand();
goto fa7a3;
D5daa:
$this->commandExecutor->execute($createRootDirectoryCommand);
goto e454d;
Fb09a:
$rootDirectory = $this->getRootDirectory();
goto F1703;
fa7a3:
$createRootDirectoryCommand->setDirectory($rootDirectory);
goto D5daa;
e454d:
}
public function createNginxVhost(): void
{
goto C5131;
Fdf75:
$vhostFileContent = $this->site->getVhostTemplate();
goto D1699;
b41f1:
$vhostTemplate->removeEmptyPlaceholders();
goto Eecb8;
Ccbba:
$writeVhostFileCommand = new WriteFileCommand();
goto bbba8;
De3a7:
$vhostTemplate->setContent($vhostFileContent);
goto a96a9;
Cd837: E45c9:
goto De3a7;
a96a9:
$vhostFile = sprintf("%s/%s.conf", rtrim(self::NGINX_VHOST_DIRECTORY, "/"), $domainName);
goto ce737;
F3bcd: B6f91:
goto Cd837;
d77ea:
$writeVhostFileCommand->setContent($vhostContent);
goto f40b4;
bbba8:
$writeVhostFileCommand->setFile($vhostFile);
goto d77ea;
D1699:
switch ($this->site->getType()) {
case SiteEntity::TYPE_PHP:
$vhostTemplate = new PhpTemplate($this->site);
goto E45c9;
case SiteEntity::TYPE_NODEJS:
$vhostTemplate = new NodejsTemplate($this->site);
goto E45c9;
case SiteEntity::TYPE_STATIC:
$vhostTemplate = new StaticTemplate($this->site);
goto E45c9;
case SiteEntity::TYPE_PYTHON:
$vhostTemplate = new PythonTemplate($this->site);
goto E45c9;
case SiteEntity::TYPE_REVERSE_PROXY:
$vhostTemplate = new ReverseProxyTemplate($this->site);
goto E45c9;
}
goto F3bcd;
C5131:
$domainName = $this->site->getDomainName();
goto Fdf75;
Eecb8:
$vhostContent = $vhostTemplate->getContent();
goto Ccbba;
f40b4:
$this->commandExecutor->execute($writeVhostFileCommand);
goto e19c5;
ce737:
$vhostTemplate->build();
goto b41f1;
e19c5:
}
public function createLogrotateFile()
{
goto c2d96;
de1b9:
$logrotateTemplateFile = realpath(dirname(__FILE__) . "/../../resources/etc/logrotate/template");
goto d0679;
b5409:
$logrotateFile = sprintf("%s/%s", rtrim(self::LOGROTATE_DIRECTORY, "/"), $siteUser);
goto d3f3f;
df94e:
$this->commandExecutor->execute($writeLogrotateFileCommand);
goto cb8f0;
a9020:
$writeLogrotateFileCommand = new WriteFileCommand();
goto Af343;
d0679:
$logrotateTemplate = file_get_contents($logrotateTemplateFile);
goto b5409;
B7130:
$writeLogrotateFileCommand->setContent($logrotateFileContent);
goto df94e;
d3f3f:
$logrotateFileContent = str_replace(["{{user}}", "{{group}}"], [$siteUser, $siteUser], $logrotateTemplate);
goto a9020;
c2d96:
$siteUser = $this->site->getUser();
goto de1b9;
Af343:
$writeLogrotateFileCommand->setFile($logrotateFile);
goto B7130;
cb8f0:
}
public function resetPermissions(): void
{
goto b9040;
B4f45:
$this->commandExecutor->execute($chownCommand, 90);
goto Eb73d;
D4ce7:
$userSshDirectoryChmodCommand = new FindChmodCommand();
goto B7942;
Cedae:
$userSshDirectoryChmodCommand->setDirectoryChmod(700);
goto D08bd;
Cd62c:
$homeDirectory = sprintf("/home/%s", $siteUser);
goto faa3c;
faa3c:
$chownCommand = new ChownCommand();
goto d44b6;
A7b14:
$homeDirectoryChmodCommand = new FindChmodCommand();
goto A7fca;
A7fca:
$homeDirectoryChmodCommand->setFile($homeDirectory);
goto Ff42b;
d44b6:
$chownCommand->setFile($homeDirectory);
goto e1213;
e8c30:
$userSshDirectory = sprintf("/home/%s/.ssh", $siteUser);
goto D4ce7;
ef0b6:
$homeDirectoryChmodCommand->setFileChmod(770);
goto e8c30;
D0f9a:
$chownCommand->setUser($siteUser);
goto A72c5;
b9040:
$siteUser = $this->site->getUser();
goto Cd62c;
D08bd:
$userSshDirectoryChmodCommand->setFileChmod(600);
goto B4f45;
B7942:
$userSshDirectoryChmodCommand->setFile($userSshDirectory);
goto Cedae;
Ff42b:
$homeDirectoryChmodCommand->setDirectoryChmod(770);
goto ef0b6;
Eb73d:
$this->commandExecutor->execute($homeDirectoryChmodCommand, 90);
goto De92b;
A72c5:
$chownCommand->setGroup($siteUser);
goto A7b14;
e1213:
$chownCommand->setRecursive(true);
goto D0f9a;
De92b:
$this->commandExecutor->execute($userSshDirectoryChmodCommand, 90);
goto b2a51;
b2a51:
}
public function reloadNginxService(): void
{
$this->reloadService("nginx");
}
protected function getRootDirectory(): string
{
goto ecae8;
Bd968:
$rootDirectory = sprintf("/home/%s/htdocs/%s", $siteUser, $rootDirectory);
goto B3ca5;
B3ca5:
return $rootDirectory;
goto B3d5c;
ecae8:
$siteUser = $this->site->getUser();
goto Eea07;
Eea07:
$rootDirectory = $this->site->getRootDirectory();
goto Bd968;
B3d5c:
}
public function createPrivateKeyAndCertificate(): void
{
goto f25b7;
fcf7b:
$this->commandExecutor->execute($writePrivateKeyFileCommand);
goto Ad3e0;
ff771:
$writePrivateKeyFileCommand->setFile($privateKeyFile);
goto ae5c3;
c3947:
$writeCertificateFileCommand = new WriteFileCommand();
goto A9c0e;
D3173:
$certificate = $this->site->getCertificate();
goto bc8ce;
D1dd8:
$writeCertificateFileCommand->setContent($certificate->getCertificate());
goto fcf7b;
ae5c3:
$writePrivateKeyFileCommand->setContent($certificate->getPrivateKey());
goto c3947;
D9d51:
$certificateFile = sprintf("%s/%s.crt", rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "/"), $domainName);
goto Ef28d;
Ef28d:
$writePrivateKeyFileCommand = new WriteFileCommand();
goto ff771;
bc8ce:
$privateKeyFile = sprintf("%s/%s.key", rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "/"), $domainName);
goto D9d51;
Ad3e0:
$this->commandExecutor->execute($writeCertificateFileCommand);
goto a1834;
f25b7:
$domainName = $this->site->getDomainName();
goto D3173;
A9c0e:
$writeCertificateFileCommand->setFile($certificateFile);
goto D1dd8;
a1834:
}
public function reloadService($serviceName)
{
goto d7fa9;
d7fa9:
if (!("dev" != $_ENV["APP_ENV"])) {
goto Bb24e;
}
goto Cb665;
Cb665:
$reloadServiceCommand = new ServiceReloadCommand();
goto e7d59;
Ff889:
$this->commandExecutor->execute($reloadServiceCommand);
goto c8514;
c8514: Bb24e:
goto cc150;
e7d59:
$reloadServiceCommand->setServiceName($serviceName);
goto Ff889;
cc150:
}
}
?>
Did this file decode correctly?
Original Code
<?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 = "\57\145\x74\x63\x2f\156\147\151\x6e\170\x2f\163\151\164\x65\163\x2d\x65\156\141\142\x6c\x65\144\57";
public const NGINX_SSL_CERTIFICATES_DIRECTORY = "\x2f\x65\x74\143\57\156\147\151\156\170\57\163\163\154\55\143\x65\x72\x74\151\146\151\143\x61\164\145\163\x2f";
public const LOGROTATE_DIRECTORY = "\x2f\145\164\x63\x2f\154\x6f\x67\162\x6f\164\x61\x74\x65\56\144\x2f";
protected Site $site;
protected CommandExecutor $commandExecutor;
public function __construct(Site $site)
{
$this->site = $site;
$this->commandExecutor = new CommandExecutor();
}
public function createUser(): void
{
goto D1b2c;
C688c:
$createUserCommand->setShell("\57\142\x69\156\57\x62\141\163\x68");
goto e4aac;
D1b2c:
$siteUser = $this->site->getUser();
goto fb5e6;
Cc0fd:
$createUserCommand->setUserName($siteUser);
goto a9b07;
fe49d:
$homeDirectory = sprintf("\57\150\157\x6d\145\57\x25\x73", $siteUser);
goto db720;
db720:
$skeletonDirectory = realpath(dirname(__FILE__) . "\x2f\x2e\56\57\56\56\57\x72\145\163\x6f\x75\162\x63\x65\x73\x2f\x65\164\143\x2f\x73\x6b\x65\154\x2f\163\x69\x74\145\55\165\x73\x65\x72\57");
goto E3a81;
d4f4c:
$createUserCommand->setHomeDirectory($homeDirectory);
goto A2225;
E7030:
$this->commandExecutor->execute($createUserCommand);
goto cdc3e;
fb5e6:
$siteUserPassword = $this->site->getUserPassword();
goto fe49d;
E3a81:
$createUserCommand = new CreateUserCommand();
goto Cc0fd;
A2225:
$createUserCommand->createHomeDirectory(true);
goto E7030;
e4aac:
$createUserCommand->setSkeletonDirectory($skeletonDirectory);
goto d4f4c;
a9b07:
$createUserCommand->setPassword($siteUserPassword);
goto C688c;
cdc3e:
}
public function createRootDirectory()
{
goto Fb09a;
F1703:
$createRootDirectoryCommand = new CreateDirectoryCommand();
goto fa7a3;
D5daa:
$this->commandExecutor->execute($createRootDirectoryCommand);
goto e454d;
Fb09a:
$rootDirectory = $this->getRootDirectory();
goto F1703;
fa7a3:
$createRootDirectoryCommand->setDirectory($rootDirectory);
goto D5daa;
e454d:
}
public function createNginxVhost(): void
{
goto C5131;
Fdf75:
$vhostFileContent = $this->site->getVhostTemplate();
goto D1699;
b41f1:
$vhostTemplate->removeEmptyPlaceholders();
goto Eecb8;
Ccbba:
$writeVhostFileCommand = new WriteFileCommand();
goto bbba8;
De3a7:
$vhostTemplate->setContent($vhostFileContent);
goto a96a9;
Cd837: E45c9:
goto De3a7;
a96a9:
$vhostFile = sprintf("\x25\x73\x2f\45\x73\56\143\157\x6e\146", rtrim(self::NGINX_VHOST_DIRECTORY, "\57"), $domainName);
goto ce737;
F3bcd: B6f91:
goto Cd837;
d77ea:
$writeVhostFileCommand->setContent($vhostContent);
goto f40b4;
bbba8:
$writeVhostFileCommand->setFile($vhostFile);
goto d77ea;
D1699:
switch ($this->site->getType()) {
case SiteEntity::TYPE_PHP:
$vhostTemplate = new PhpTemplate($this->site);
goto E45c9;
case SiteEntity::TYPE_NODEJS:
$vhostTemplate = new NodejsTemplate($this->site);
goto E45c9;
case SiteEntity::TYPE_STATIC:
$vhostTemplate = new StaticTemplate($this->site);
goto E45c9;
case SiteEntity::TYPE_PYTHON:
$vhostTemplate = new PythonTemplate($this->site);
goto E45c9;
case SiteEntity::TYPE_REVERSE_PROXY:
$vhostTemplate = new ReverseProxyTemplate($this->site);
goto E45c9;
}
goto F3bcd;
C5131:
$domainName = $this->site->getDomainName();
goto Fdf75;
Eecb8:
$vhostContent = $vhostTemplate->getContent();
goto Ccbba;
f40b4:
$this->commandExecutor->execute($writeVhostFileCommand);
goto e19c5;
ce737:
$vhostTemplate->build();
goto b41f1;
e19c5:
}
public function createLogrotateFile()
{
goto c2d96;
de1b9:
$logrotateTemplateFile = realpath(dirname(__FILE__) . "\x2f\56\x2e\57\x2e\56\x2f\x72\x65\x73\157\x75\162\x63\x65\163\57\145\164\x63\x2f\x6c\x6f\147\x72\x6f\164\x61\x74\x65\x2f\164\145\x6d\x70\154\x61\x74\145");
goto d0679;
b5409:
$logrotateFile = sprintf("\45\163\x2f\45\x73", rtrim(self::LOGROTATE_DIRECTORY, "\x2f"), $siteUser);
goto d3f3f;
df94e:
$this->commandExecutor->execute($writeLogrotateFileCommand);
goto cb8f0;
a9020:
$writeLogrotateFileCommand = new WriteFileCommand();
goto Af343;
d0679:
$logrotateTemplate = file_get_contents($logrotateTemplateFile);
goto b5409;
B7130:
$writeLogrotateFileCommand->setContent($logrotateFileContent);
goto df94e;
d3f3f:
$logrotateFileContent = str_replace(["\173\x7b\x75\x73\x65\x72\175\x7d", "\x7b\173\x67\162\x6f\165\x70\175\175"], [$siteUser, $siteUser], $logrotateTemplate);
goto a9020;
c2d96:
$siteUser = $this->site->getUser();
goto de1b9;
Af343:
$writeLogrotateFileCommand->setFile($logrotateFile);
goto B7130;
cb8f0:
}
public function resetPermissions(): void
{
goto b9040;
B4f45:
$this->commandExecutor->execute($chownCommand, 90);
goto Eb73d;
D4ce7:
$userSshDirectoryChmodCommand = new FindChmodCommand();
goto B7942;
Cedae:
$userSshDirectoryChmodCommand->setDirectoryChmod(700);
goto D08bd;
Cd62c:
$homeDirectory = sprintf("\57\x68\x6f\155\x65\57\45\163", $siteUser);
goto faa3c;
faa3c:
$chownCommand = new ChownCommand();
goto d44b6;
A7b14:
$homeDirectoryChmodCommand = new FindChmodCommand();
goto A7fca;
A7fca:
$homeDirectoryChmodCommand->setFile($homeDirectory);
goto Ff42b;
d44b6:
$chownCommand->setFile($homeDirectory);
goto e1213;
e8c30:
$userSshDirectory = sprintf("\x2f\x68\157\x6d\x65\x2f\x25\163\x2f\x2e\163\x73\x68", $siteUser);
goto D4ce7;
ef0b6:
$homeDirectoryChmodCommand->setFileChmod(770);
goto e8c30;
D0f9a:
$chownCommand->setUser($siteUser);
goto A72c5;
b9040:
$siteUser = $this->site->getUser();
goto Cd62c;
D08bd:
$userSshDirectoryChmodCommand->setFileChmod(600);
goto B4f45;
B7942:
$userSshDirectoryChmodCommand->setFile($userSshDirectory);
goto Cedae;
Ff42b:
$homeDirectoryChmodCommand->setDirectoryChmod(770);
goto ef0b6;
Eb73d:
$this->commandExecutor->execute($homeDirectoryChmodCommand, 90);
goto De92b;
A72c5:
$chownCommand->setGroup($siteUser);
goto A7b14;
e1213:
$chownCommand->setRecursive(true);
goto D0f9a;
De92b:
$this->commandExecutor->execute($userSshDirectoryChmodCommand, 90);
goto b2a51;
b2a51:
}
public function reloadNginxService(): void
{
$this->reloadService("\x6e\x67\x69\x6e\170");
}
protected function getRootDirectory(): string
{
goto ecae8;
Bd968:
$rootDirectory = sprintf("\x2f\150\157\x6d\145\x2f\45\x73\57\x68\x74\x64\x6f\x63\163\x2f\x25\163", $siteUser, $rootDirectory);
goto B3ca5;
B3ca5:
return $rootDirectory;
goto B3d5c;
ecae8:
$siteUser = $this->site->getUser();
goto Eea07;
Eea07:
$rootDirectory = $this->site->getRootDirectory();
goto Bd968;
B3d5c:
}
public function createPrivateKeyAndCertificate(): void
{
goto f25b7;
fcf7b:
$this->commandExecutor->execute($writePrivateKeyFileCommand);
goto Ad3e0;
ff771:
$writePrivateKeyFileCommand->setFile($privateKeyFile);
goto ae5c3;
c3947:
$writeCertificateFileCommand = new WriteFileCommand();
goto A9c0e;
D3173:
$certificate = $this->site->getCertificate();
goto bc8ce;
D1dd8:
$writeCertificateFileCommand->setContent($certificate->getCertificate());
goto fcf7b;
ae5c3:
$writePrivateKeyFileCommand->setContent($certificate->getPrivateKey());
goto c3947;
D9d51:
$certificateFile = sprintf("\x25\163\x2f\45\x73\x2e\x63\162\x74", rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "\57"), $domainName);
goto Ef28d;
Ef28d:
$writePrivateKeyFileCommand = new WriteFileCommand();
goto ff771;
bc8ce:
$privateKeyFile = sprintf("\x25\x73\x2f\45\163\56\153\145\171", rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "\57"), $domainName);
goto D9d51;
Ad3e0:
$this->commandExecutor->execute($writeCertificateFileCommand);
goto a1834;
f25b7:
$domainName = $this->site->getDomainName();
goto D3173;
A9c0e:
$writeCertificateFileCommand->setFile($certificateFile);
goto D1dd8;
a1834:
}
public function reloadService($serviceName)
{
goto d7fa9;
d7fa9:
if (!("\x64\145\166" != $_ENV["\x41\120\120\137\105\116\x56"])) {
goto Bb24e;
}
goto Cb665;
Cb665:
$reloadServiceCommand = new ServiceReloadCommand();
goto e7d59;
Ff889:
$this->commandExecutor->execute($reloadServiceCommand);
goto c8514;
c8514: Bb24e:
goto cc150;
e7d59:
$reloadServiceCommand->setServiceName($serviceName);
goto Ff889;
cc150:
}
}
Function Calls
None |
Stats
MD5 | ecb254d5bebb86f0958382387dcbd4a3 |
Eval Count | 0 |
Decode Time | 72 ms |