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\Services; use App\Models\Package; use Illuminate\Support\Facades\..
Decoded Output download
<?php
namespace App\Services;
use App\Models\Package;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\MessageBag;
class PackageInstaller
{
public $package;
public $slug;
public $namespace;
public $path;
public $migrations;
public function __construct(Request $request, array $installable)
{
$this->package = array_merge($installable, $request->all());
$this->slug = $installable["slug"];
$this->namespace =
"\Incevio\Package\" .
Str::studly(Str::replace("-", "_", $this->slug));
$this->path = $installable["path"];
$this->migrations = str_replace(
base_path(),
"",
$this->path .
"/database/migrations"
);
}
public function install()
{
Log::info(
"Installing package " .
$this->slug
);
try {
$package_data = array_merge(
$this->package,
preparePackageInstallation($this->package)
);
Package::create($package_data);
$this->migrate()->seed();
} catch (\Exception $exception) {
Log::info(
"Package installation failed " .
$this->slug
);
Log::error(get_exception_message($exception));
throw new \Exception(
"Package Installation Failed " .
$this->slug
);
}
Log::info(
"Successfully installed package " .
$this->slug
);
return true;
}
public function migrate()
{
Log::info(
"Migration started for " .
$this->slug
);
Artisan::call("migrate", [
"--path" => $this->migrations,
"--force" => true,
]);
Log::info(Artisan::output());
return $this;
}
private function seed()
{
Log::info(
"Seeding package data for " .
$this->slug
);
foreach (
glob(
$this->path .
"/database/seeds/*.php"
)
as $filename
) {
$classes = get_declared_classes();
include $filename;
$temp = array_diff(get_declared_classes(), $classes);
$migration = Arr::last($temp, function ($value, $key) {
return $value !==
"Illuminate\Database\Seeder";
});
Artisan::call("db:seed", [
"--class" => $migration,
"--force" => true,
]);
Log::info(Artisan::output());
WKXas:
}
mM2J1:
return $this;
}
public function uninstall()
{
Log::info(
"Uninstalling Package: " .
$this->slug
);
$file =
$this->path .
"/src/Uninstaller.php";
if (!file_exists($file)) {
goto PQVcm;
}
include $file;
PQVcm:
$class =
$this->namespace .
"\Uninstaller";
if (class_exists($class)) {
goto savKd;
}
Log::info(
"Uninstaller not found in the package dir for " .
$this->slug
);
throw new \Exception(
"Uninstaller not found for the package " .
$this->slug
);
savKd:
try {
(new $class())->cleanDatabase();
$this->rollback();
} catch (\Exception $e) {
Log::info(
"Package uninstallation failed: " .
$this->slug
);
throw new \Exception(
"Uninstallation failed: " .
$this->slug
);
}
Log::info(
"Successfully uninstalled package " .
$this->slug
);
return $this;
}
private function rollback()
{
Log::info(
"Roll back called..."
);
$migrations = array_reverse(
glob(
$this->path .
"/database/migrations/*_*.php"
)
);
if (!empty($migrations)) {
goto OBdW4;
}
Log::info(
"No migration to roll back for package " .
$this->slug
);
return $this;
OBdW4:
foreach ($migrations as $filename) {
$migration = str_replace(
".php",
"",
basename($filename)
);
Log::info(
"Rolling back: " .
$migration
);
$row = DB::table("migrations")->where(
"migration",
$migration
);
if ($row->first()) {
goto gmmf9;
}
Log::info(
$migration .
" was not migrated before, probably it\'s a new migration file."
);
Log::info(
"Skipping rolled back: " .
$migration
);
goto ZOMJE;
gmmf9:
$class = Str::studly(
implode("_", array_slice(explode("_", $migration), 4))
);
if (class_exists($class)) {
goto lSvD7;
}
include $filename;
lSvD7:
(new $class())->down();
if ($row->delete()) {
goto aN26W;
}
Log::info(
"Rollback FAILED: " .
$migration
);
throw new \Exception(
"Migration rollback failed: " .
$this->slug
);
goto nID7P;
aN26W:
Log::info(
"Rolled back: " . $migration
);
nID7P:
ZOMJE:
}
whQNh:
Log::info(
"All migrations has been rolled back for package " .
$this->slug
);
return $this;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace App\Services;
use App\Models\Package;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\MessageBag;
class PackageInstaller
{
public $package;
public $slug;
public $namespace;
public $path;
public $migrations;
public function __construct(Request $request, array $installable)
{
$this->package = array_merge($installable, $request->all());
$this->slug = $installable["\163\154\165\147"];
$this->namespace =
"\134\111\x6e\x63\145\166\151\x6f\134\x50\141\143\153\141\x67\x65\x5c" .
Str::studly(Str::replace("\x2d", "\x5f", $this->slug));
$this->path = $installable["\160\141\x74\150"];
$this->migrations = str_replace(
base_path(),
"",
$this->path .
"\x2f\x64\x61\x74\x61\142\141\163\145\57\155\x69\147\162\141\164\151\x6f\x6e\163"
);
}
public function install()
{
Log::info(
"\x49\156\x73\x74\141\154\x6c\x69\156\x67\x20\x70\141\x63\153\x61\x67\x65\40" .
$this->slug
);
try {
$package_data = array_merge(
$this->package,
preparePackageInstallation($this->package)
);
Package::create($package_data);
$this->migrate()->seed();
} catch (\Exception $exception) {
Log::info(
"\x50\141\x63\x6b\141\147\x65\40\x69\x6e\163\164\141\154\x6c\141\x74\151\157\x6e\x20\x66\x61\x69\x6c\145\x64\40" .
$this->slug
);
Log::error(get_exception_message($exception));
throw new \Exception(
"\x50\x61\143\x6b\x61\x67\x65\40\x49\x6e\x73\x74\x61\x6c\154\141\x74\x69\x6f\156\x20\x46\141\151\x6c\x65\144\x20" .
$this->slug
);
}
Log::info(
"\x53\x75\x63\x63\145\163\163\146\x75\154\154\171\x20\151\156\x73\164\x61\154\x6c\145\144\x20\x70\141\x63\x6b\x61\x67\145\x20" .
$this->slug
);
return true;
}
public function migrate()
{
Log::info(
"\115\x69\147\162\x61\x74\x69\x6f\x6e\40\x73\164\x61\162\x74\145\144\x20\x66\157\162\40" .
$this->slug
);
Artisan::call("\155\151\147\x72\141\164\x65", [
"\x2d\x2d\x70\x61\164\150" => $this->migrations,
"\55\x2d\146\x6f\162\x63\145" => true,
]);
Log::info(Artisan::output());
return $this;
}
private function seed()
{
Log::info(
"\123\145\x65\144\151\156\x67\x20\160\x61\143\153\x61\x67\145\x20\x64\141\x74\x61\x20\x66\157\x72\40" .
$this->slug
);
foreach (
glob(
$this->path .
"\x2f\x64\x61\x74\x61\x62\141\x73\145\x2f\163\x65\145\x64\x73\57\52\56\x70\x68\x70"
)
as $filename
) {
$classes = get_declared_classes();
include $filename;
$temp = array_diff(get_declared_classes(), $classes);
$migration = Arr::last($temp, function ($value, $key) {
return $value !==
"\111\154\x6c\x75\x6d\x69\x6e\x61\164\x65\x5c\x44\x61\164\141\x62\x61\163\x65\134\x53\145\145\x64\x65\x72";
});
Artisan::call("\144\x62\72\163\145\x65\x64", [
"\x2d\x2d\x63\x6c\141\x73\x73" => $migration,
"\x2d\x2d\146\157\162\143\145" => true,
]);
Log::info(Artisan::output());
WKXas:
}
mM2J1:
return $this;
}
public function uninstall()
{
Log::info(
"\125\x6e\151\x6e\x73\164\x61\154\x6c\x69\156\x67\x20\x50\141\x63\x6b\x61\x67\x65\x3a\x20" .
$this->slug
);
$file =
$this->path .
"\x2f\x73\x72\x63\x2f\x55\x6e\151\156\163\x74\x61\x6c\x6c\145\162\56\x70\x68\160";
if (!file_exists($file)) {
goto PQVcm;
}
include $file;
PQVcm:
$class =
$this->namespace .
"\x5c\125\x6e\151\156\163\164\141\154\x6c\145\162";
if (class_exists($class)) {
goto savKd;
}
Log::info(
"\125\156\151\156\163\x74\141\x6c\154\x65\162\x20\156\x6f\164\x20\x66\157\x75\x6e\144\40\x69\156\40\164\150\145\x20\160\141\x63\153\x61\147\145\40\144\x69\x72\40\x66\x6f\162\x20" .
$this->slug
);
throw new \Exception(
"\125\156\151\156\163\x74\141\x6c\154\x65\162\x20\x6e\157\164\40\x66\157\165\156\x64\40\x66\157\x72\40\x74\x68\x65\x20\x70\141\x63\153\x61\x67\x65\x20" .
$this->slug
);
savKd:
try {
(new $class())->cleanDatabase();
$this->rollback();
} catch (\Exception $e) {
Log::info(
"\120\141\x63\153\x61\147\145\x20\x75\156\x69\156\x73\164\141\x6c\154\141\164\151\x6f\x6e\40\x66\x61\151\x6c\145\144\72\40" .
$this->slug
);
throw new \Exception(
"\125\x6e\151\156\163\164\x61\154\x6c\141\164\151\157\156\40\x66\141\x69\154\145\144\x3a\40" .
$this->slug
);
}
Log::info(
"\123\165\x63\143\145\163\x73\x66\165\154\154\171\x20\x75\156\x69\156\163\164\x61\154\x6c\x65\144\40\x70\141\x63\153\141\147\x65\x20" .
$this->slug
);
return $this;
}
private function rollback()
{
Log::info(
"\122\157\154\x6c\40\142\141\x63\x6b\x20\143\x61\x6c\154\x65\x64\x2e\56\x2e"
);
$migrations = array_reverse(
glob(
$this->path .
"\x2f\x64\x61\164\x61\142\x61\163\x65\x2f\155\x69\147\x72\141\164\151\157\156\163\57\x2a\137\52\x2e\160\150\160"
)
);
if (!empty($migrations)) {
goto OBdW4;
}
Log::info(
"\116\157\40\x6d\151\147\x72\141\164\151\x6f\156\40\x74\x6f\x20\162\x6f\154\x6c\x20\142\x61\143\153\40\146\x6f\x72\x20\160\141\143\x6b\141\x67\145\x20" .
$this->slug
);
return $this;
OBdW4:
foreach ($migrations as $filename) {
$migration = str_replace(
"\56\160\x68\x70",
"",
basename($filename)
);
Log::info(
"\122\157\154\x6c\151\x6e\x67\x20\x62\x61\143\x6b\72\x20" .
$migration
);
$row = DB::table("\155\151\147\x72\141\x74\151\157\156\x73")->where(
"\x6d\151\147\162\x61\164\151\157\x6e",
$migration
);
if ($row->first()) {
goto gmmf9;
}
Log::info(
$migration .
"\x20\167\141\163\x20\156\x6f\x74\x20\x6d\x69\147\162\x61\164\x65\144\x20\x62\145\146\x6f\x72\x65\54\40\x70\x72\157\x62\x61\142\x6c\171\40\x69\x74\x5c\x27\x73\40\141\40\156\x65\x77\x20\155\151\147\x72\x61\x74\x69\157\156\40\x66\151\154\x65\x2e"
);
Log::info(
"\x53\153\x69\160\x70\151\x6e\x67\40\162\x6f\154\154\145\144\40\x62\x61\x63\153\72\x20" .
$migration
);
goto ZOMJE;
gmmf9:
$class = Str::studly(
implode("\x5f", array_slice(explode("\137", $migration), 4))
);
if (class_exists($class)) {
goto lSvD7;
}
include $filename;
lSvD7:
(new $class())->down();
if ($row->delete()) {
goto aN26W;
}
Log::info(
"\x52\157\x6c\154\142\x61\x63\x6b\x20\106\101\x49\x4c\x45\x44\72\x20" .
$migration
);
throw new \Exception(
"\115\x69\x67\x72\141\x74\x69\x6f\156\40\x72\157\154\x6c\142\x61\143\153\40\146\x61\151\x6c\145\x64\72\x20" .
$this->slug
);
goto nID7P;
aN26W:
Log::info(
"\x52\157\x6c\154\145\x64\40\142\141\x63\153\72\40" . $migration
);
nID7P:
ZOMJE:
}
whQNh:
Log::info(
"\x41\154\154\x20\x6d\x69\x67\x72\x61\x74\151\x6f\156\163\40\x68\141\163\40\142\x65\145\x6e\40\162\157\x6c\x6c\x65\x64\40\142\141\143\153\x20\146\x6f\x72\x20\160\141\x63\153\141\147\x65\x20" .
$this->slug
);
return $this;
}
}
Function Calls
None |
Stats
MD5 | 2bb4e5b36188fe91bb3f979670924d1a |
Eval Count | 0 |
Decode Time | 74 ms |