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\Co..

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 = "/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: 
    } 
} 
 ?>

Function Calls

None

Variables

None

Stats

MD5 2222148a46d7a8532b123b351cce0553
Eval Count 0
Decode Time 75 ms