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\Command; use Symfony\Component\Console\Input\InputInterface; use Symf..
Decoded Output download
<?php
namespace App\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; use App\Command\Command as BaseCommand; use App\CloudPanel\Environment as CloudPanelEnvironment; use App\Entity\Notification; use App\Hetzner\Snapshot; use App\Notification\NotificationQueue; class HetznerSnapshotCreateCommand extends BaseCommand { protected function configure() : void { goto bc694; bc694: $this->setName("hetzner:snapshot:create"); goto Ca5c2; Cf25e: $this->addOption("frequency", null, InputOption::VALUE_REQUIRED); goto F5145; Ca5c2: $this->setDescription("clpctl hetzner:snapshot:create --frequency=3"); goto Cf25e; F5145: } protected function execute(InputInterface $input, OutputInterface $output) : int { try { goto c55a7; a5c4b: $cloud = $this->getConfigValue("cloud"); goto Ae054; A21b3: F15e5: goto c6a3f; f0f0d: $snapshotCreated = $this->createSnapshot(); goto f77f9; c6695: $snapshotsFrequency = (int) $this->getConfigValue("hetzner_snapshots_frequency"); goto Cc41b; F9e44: a2221: goto A21b3; c55a7: $this->validateInput($input); goto cedfe; Cc41b: if (!(CloudPanelEnvironment::CLOUD_PROVIDER_HETZNER == $cloud && true === $automaticSnapshots && false === empty($apiToken) && $snapshotsFrequency == $frequency)) { goto F15e5; } goto f0f0d; F746a: $apiToken = $this->getConfigValue("hetzner_api_token"); goto c6695; Aadd8: $this->cleanSnapshots(); goto F9e44; c6a3f: return BaseCommand::SUCCESS; goto a0e96; cedfe: $frequency = (int) $input->getOption("frequency"); goto a5c4b; Ae054: $automaticSnapshots = (bool) $this->getConfigValue("hetzner_automatic_snapshots"); goto F746a; f77f9: if (!(true === $snapshotCreated)) { goto a2221; } goto Aadd8; a0e96: } catch (\Exception $e) { goto Bf35c; a0fdc: $output->writeln(sprintf("<error>%s</error>", $errorMessage)); goto ebc4d; Bf35c: $errorMessage = $e->getMessage(); goto a0fdc; ebc4d: return BaseCommand::FAILURE; goto Aafcb; Aafcb: } } private function createSnapshot() : bool { try { goto Efb3a; ceb75: $snapshotName = $hetznerClient->getInstanceName(); goto ce8be; Abe81: $hetznerClient = $instance->getHetznerClient(); goto ceb75; e25e9: $dateTime = new \DateTime(); goto b1c56; b1c56: $dateTime->setTimezone(new \DateTimeZone("UTC")); goto e689a; d43b6: $hetznerClient->createSnapshot($snapshotName); goto C43c2; e689a: $snapshotName = sprintf("%s-%s", $snapshotName, $dateTime->format("c")); goto cb505; Efb3a: $instance = $this->getInstance(); goto Abe81; ce8be: if (!(false === empty($snapshotName))) { goto F6ab8; } goto e25e9; C43c2: return true; goto C8c6c; cb505: F6ab8: goto d43b6; C8c6c: } catch (\Exception $e) { $errorMessage = $e->getMessage(); $this->addNotification("Creating a Snapshot failed", $errorMessage); } return false; } private function cleanSnapshots() : bool { try { goto B4a2e; cb120: return true; goto fa119; D7b99: if (!count($snapshots)) { goto F99a9; } goto afadd; Fe89b: $snapshots = $hetznerClient->getSnapshots(); goto D7b99; c82df: $snapshotDeleteDateTime->modify("+5 minutes"); goto c077c; af1cc: $backupRetentionPeriod = (int) $this->getConfigValue("hetzner_snapshots_retention_period"); goto D8ae0; D8ae0: $dateTime = new \DateTime(); goto df9d0; B4a2e: $instance = $this->getInstance(); goto B0623; df9d0: $snapshotDeleteDateTime = clone $dateTime; goto de531; c077c: $snapshotDeleteDateTime->setTimezone(new \DateTimeZone("UTC")); goto Fe89b; C4c3a: B37e0: goto B6178; B0623: $hetznerClient = $instance->getHetznerClient(); goto af1cc; afadd: foreach ($snapshots as $snapshot) { goto a15d2; a15d2: $snapshotCreatedAt = $snapshot->getCreatedAt(); goto C3643; bdff0: if (!(Snapshot::STATUS_AVAILABLE == $snapshot->getStatus() && $snapshotCreatedAt < $snapshotDeleteDateTime && false === $isSnapshotDeleteProtected)) { goto E6756; } goto f3466; C0b5b: $hetznerClient->deleteSnapshot($id); goto Eec9a; Df49e: a1c78: goto d0053; Eec9a: E6756: goto Df49e; C3643: $isSnapshotDeleteProtected = $snapshot->isDeleteProtected(); goto bdff0; f3466: $id = $snapshot->getId(); goto C0b5b; d0053: } goto C4c3a; B6178: F99a9: goto cb120; de531: $snapshotDeleteDateTime->modify(sprintf("-%s days", $backupRetentionPeriod)); goto c82df; fa119: } catch (\Exception $e) { $errorMessage = $e->getMessage(); $this->addNotification("Cleaning Snapshots failed", $errorMessage); } return false; } private function addNotification(string $subject, string $errorMessage) : void { goto c5693; A731d: $notification->setSubject($subject); goto Ac38c; b2163: NotificationQueue::addNotification($notification); goto Df246; Ac38c: $notification->setMessage($errorMessage); goto D0dbb; c5693: $notification = new Notification(); goto A731d; D0dbb: $notification->setSeverity(Notification::SEVERITY_CRITICAL); goto b2163; Df246: } }
?>
Did this file decode correctly?
Original Code
<?php
namespace App\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; use App\Command\Command as BaseCommand; use App\CloudPanel\Environment as CloudPanelEnvironment; use App\Entity\Notification; use App\Hetzner\Snapshot; use App\Notification\NotificationQueue; class HetznerSnapshotCreateCommand extends BaseCommand { protected function configure() : void { goto bc694; bc694: $this->setName("\x68\x65\x74\x7a\x6e\145\x72\x3a\163\x6e\141\x70\x73\x68\157\x74\x3a\143\162\145\141\x74\145"); goto Ca5c2; Cf25e: $this->addOption("\x66\162\145\161\165\145\156\143\x79", null, InputOption::VALUE_REQUIRED); goto F5145; Ca5c2: $this->setDescription("\143\x6c\160\143\x74\x6c\x20\x68\x65\164\x7a\156\x65\162\x3a\x73\156\141\x70\x73\150\157\164\x3a\x63\162\x65\141\x74\145\x20\55\x2d\146\x72\145\161\x75\145\x6e\x63\x79\75\x33"); goto Cf25e; F5145: } protected function execute(InputInterface $input, OutputInterface $output) : int { try { goto c55a7; a5c4b: $cloud = $this->getConfigValue("\143\x6c\x6f\165\144"); goto Ae054; A21b3: F15e5: goto c6a3f; f0f0d: $snapshotCreated = $this->createSnapshot(); goto f77f9; c6695: $snapshotsFrequency = (int) $this->getConfigValue("\150\145\x74\172\156\145\x72\137\x73\x6e\141\160\163\150\x6f\164\x73\x5f\x66\x72\x65\161\165\x65\156\143\x79"); goto Cc41b; F9e44: a2221: goto A21b3; c55a7: $this->validateInput($input); goto cedfe; Cc41b: if (!(CloudPanelEnvironment::CLOUD_PROVIDER_HETZNER == $cloud && true === $automaticSnapshots && false === empty($apiToken) && $snapshotsFrequency == $frequency)) { goto F15e5; } goto f0f0d; F746a: $apiToken = $this->getConfigValue("\x68\145\164\172\x6e\x65\x72\137\141\x70\x69\x5f\x74\x6f\153\x65\x6e"); goto c6695; Aadd8: $this->cleanSnapshots(); goto F9e44; c6a3f: return BaseCommand::SUCCESS; goto a0e96; cedfe: $frequency = (int) $input->getOption("\x66\x72\x65\161\165\145\156\143\x79"); goto a5c4b; Ae054: $automaticSnapshots = (bool) $this->getConfigValue("\x68\145\164\172\x6e\x65\162\x5f\x61\x75\x74\x6f\x6d\141\x74\x69\x63\x5f\163\x6e\141\160\163\x68\157\x74\163"); goto F746a; f77f9: if (!(true === $snapshotCreated)) { goto a2221; } goto Aadd8; a0e96: } catch (\Exception $e) { goto Bf35c; a0fdc: $output->writeln(sprintf("\74\145\x72\x72\x6f\x72\x3e\x25\x73\x3c\57\x65\x72\x72\157\x72\x3e", $errorMessage)); goto ebc4d; Bf35c: $errorMessage = $e->getMessage(); goto a0fdc; ebc4d: return BaseCommand::FAILURE; goto Aafcb; Aafcb: } } private function createSnapshot() : bool { try { goto Efb3a; ceb75: $snapshotName = $hetznerClient->getInstanceName(); goto ce8be; Abe81: $hetznerClient = $instance->getHetznerClient(); goto ceb75; e25e9: $dateTime = new \DateTime(); goto b1c56; b1c56: $dateTime->setTimezone(new \DateTimeZone("\x55\124\x43")); goto e689a; d43b6: $hetznerClient->createSnapshot($snapshotName); goto C43c2; e689a: $snapshotName = sprintf("\x25\x73\x2d\x25\163", $snapshotName, $dateTime->format("\143")); goto cb505; Efb3a: $instance = $this->getInstance(); goto Abe81; ce8be: if (!(false === empty($snapshotName))) { goto F6ab8; } goto e25e9; C43c2: return true; goto C8c6c; cb505: F6ab8: goto d43b6; C8c6c: } catch (\Exception $e) { $errorMessage = $e->getMessage(); $this->addNotification("\103\x72\x65\x61\x74\151\x6e\147\40\x61\40\123\156\141\160\x73\x68\x6f\164\40\x66\x61\x69\x6c\x65\x64", $errorMessage); } return false; } private function cleanSnapshots() : bool { try { goto B4a2e; cb120: return true; goto fa119; D7b99: if (!count($snapshots)) { goto F99a9; } goto afadd; Fe89b: $snapshots = $hetznerClient->getSnapshots(); goto D7b99; c82df: $snapshotDeleteDateTime->modify("\x2b\x35\40\155\151\x6e\165\164\145\163"); goto c077c; af1cc: $backupRetentionPeriod = (int) $this->getConfigValue("\150\x65\x74\x7a\156\x65\x72\137\163\x6e\x61\160\x73\150\157\x74\163\x5f\162\x65\x74\145\x6e\x74\151\157\156\x5f\160\x65\162\x69\x6f\x64"); goto D8ae0; D8ae0: $dateTime = new \DateTime(); goto df9d0; B4a2e: $instance = $this->getInstance(); goto B0623; df9d0: $snapshotDeleteDateTime = clone $dateTime; goto de531; c077c: $snapshotDeleteDateTime->setTimezone(new \DateTimeZone("\125\x54\x43")); goto Fe89b; C4c3a: B37e0: goto B6178; B0623: $hetznerClient = $instance->getHetznerClient(); goto af1cc; afadd: foreach ($snapshots as $snapshot) { goto a15d2; a15d2: $snapshotCreatedAt = $snapshot->getCreatedAt(); goto C3643; bdff0: if (!(Snapshot::STATUS_AVAILABLE == $snapshot->getStatus() && $snapshotCreatedAt < $snapshotDeleteDateTime && false === $isSnapshotDeleteProtected)) { goto E6756; } goto f3466; C0b5b: $hetznerClient->deleteSnapshot($id); goto Eec9a; Df49e: a1c78: goto d0053; Eec9a: E6756: goto Df49e; C3643: $isSnapshotDeleteProtected = $snapshot->isDeleteProtected(); goto bdff0; f3466: $id = $snapshot->getId(); goto C0b5b; d0053: } goto C4c3a; B6178: F99a9: goto cb120; de531: $snapshotDeleteDateTime->modify(sprintf("\55\45\163\40\144\x61\x79\x73", $backupRetentionPeriod)); goto c82df; fa119: } catch (\Exception $e) { $errorMessage = $e->getMessage(); $this->addNotification("\x43\x6c\145\x61\156\151\x6e\147\40\123\x6e\x61\x70\163\x68\157\164\163\x20\x66\141\151\x6c\x65\144", $errorMessage); } return false; } private function addNotification(string $subject, string $errorMessage) : void { goto c5693; A731d: $notification->setSubject($subject); goto Ac38c; b2163: NotificationQueue::addNotification($notification); goto Df246; Ac38c: $notification->setMessage($errorMessage); goto D0dbb; c5693: $notification = new Notification(); goto A731d; D0dbb: $notification->setSeverity(Notification::SEVERITY_CRITICAL); goto b2163; Df246: } }
Function Calls
None |
Stats
MD5 | c3270f0532ab883601f4e3267a08976b |
Eval Count | 0 |
Decode Time | 88 ms |