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\Arr; use Ill..

Decoded Output download

<?php 
namespace App\Services; use App\Models\Package; use Illuminate\Support\Arr; use Illuminate\Support\Str; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\MessageBag; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Artisan; 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()); TZSwj: } P2v7p: return $this; } public function uninstall() { Log::info("Uninstalling Package: " . $this->slug); $file = $this->path . "/src/Uninstaller.php"; if (!file_exists($file)) { goto jngyB; } include $file; jngyB: $class = $this->namespace . "\Uninstaller"; if (class_exists($class)) { goto wEGVp; } Log::info("Uninstaller not found in the package dir for " . $this->slug); throw new \Exception("Uninstaller not found for the package " . $this->slug); wEGVp: try { (new $class())->cleanDatabase(); $this->rollback(); } catch (\Exception $e) { Log::info("Package uninstallation failed: " . $this->slug); Log::error($e); 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 Dq4JP; } Log::info("No migration to roll back for package " . $this->slug); return $this; Dq4JP: Schema::disableForeignKeyConstraints(); DB::statement("SET FOREIGN_KEY_CHECKS = 0"); 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 b7eC_; } Log::info($migration . " was not migrated before, probably it\'s a new migration file."); Log::info("Skipping rolled back: " . $migration); goto qPQog; b7eC_: $class = Str::studly(implode("_", array_slice(explode("_", $migration), 4))); if (class_exists($class)) { goto M9Zfw; } include $filename; M9Zfw: (new $class())->down(); if ($row->delete()) { goto PTS_8; } Log::info("Rollback FAILED: " . $migration); throw new \Exception("Migration rollback failed: " . $this->slug); goto S3q7Z; PTS_8: Log::info("Rolled back: " . $migration); S3q7Z: qPQog: } lnFLg: Schema::enableForeignKeyConstraints(); DB::statement("SET FOREIGN_KEY_CHECKS = 1"); 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\Arr; use Illuminate\Support\Str; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\MessageBag; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Artisan; 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["\x73\154\x75\x67"]; $this->namespace = "\x5c\x49\x6e\x63\x65\166\151\157\x5c\120\141\143\x6b\x61\x67\145\x5c" . Str::studly(Str::replace("\55", "\137", $this->slug)); $this->path = $installable["\x70\141\x74\150"]; $this->migrations = str_replace(base_path(), '', $this->path . "\x2f\x64\x61\164\141\x62\x61\x73\145\57\x6d\151\x67\x72\x61\164\x69\157\x6e\x73"); } public function install() { Log::info("\111\156\x73\x74\141\154\154\x69\x6e\147\40\160\141\143\153\x61\x67\145\x20" . $this->slug); try { $package_data = array_merge($this->package, preparePackageInstallation($this->package)); Package::create($package_data); $this->migrate()->seed(); } catch (\Exception $exception) { Log::info("\120\x61\143\153\141\147\x65\x20\x69\156\163\164\x61\x6c\x6c\x61\x74\151\157\156\x20\146\141\x69\154\145\x64\40" . $this->slug); Log::error(get_exception_message($exception)); throw new \Exception("\x50\141\x63\x6b\141\147\145\40\x49\156\163\164\x61\154\154\141\164\151\x6f\x6e\40\x46\141\151\154\x65\x64\x20" . $this->slug); } Log::info("\123\x75\x63\143\145\163\x73\x66\165\x6c\154\x79\x20\151\x6e\x73\164\141\154\x6c\145\144\x20\x70\x61\x63\153\x61\x67\x65\x20" . $this->slug); return true; } public function migrate() { Log::info("\115\151\x67\x72\x61\164\x69\157\156\40\163\x74\x61\162\164\145\x64\40\146\157\162\40" . $this->slug); Artisan::call("\x6d\151\x67\x72\x61\x74\x65", ["\55\x2d\160\x61\x74\150" => $this->migrations, "\55\x2d\146\157\x72\x63\145" => true]); Log::info(Artisan::output()); return $this; } private function seed() { Log::info("\x53\x65\x65\x64\151\x6e\x67\40\160\141\x63\153\x61\147\x65\40\144\141\x74\141\x20\x66\157\162\x20" . $this->slug); foreach (glob($this->path . "\57\x64\141\x74\x61\142\x61\163\145\57\x73\x65\145\144\x73\57\52\56\x70\x68\160") 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\x6c\x6c\165\x6d\x69\156\x61\x74\145\x5c\104\x61\x74\x61\x62\x61\x73\x65\x5c\123\x65\x65\144\145\x72"; }); Artisan::call("\144\x62\72\163\x65\x65\144", ["\55\x2d\143\x6c\141\163\x73" => $migration, "\x2d\x2d\x66\x6f\x72\x63\x65" => true]); Log::info(Artisan::output()); TZSwj: } P2v7p: return $this; } public function uninstall() { Log::info("\125\x6e\151\x6e\x73\x74\x61\154\154\151\x6e\x67\40\x50\141\143\x6b\141\147\x65\72\x20" . $this->slug); $file = $this->path . "\57\x73\x72\143\57\125\x6e\151\x6e\x73\x74\141\x6c\x6c\145\162\x2e\x70\x68\160"; if (!file_exists($file)) { goto jngyB; } include $file; jngyB: $class = $this->namespace . "\x5c\x55\x6e\x69\x6e\163\x74\x61\154\154\x65\x72"; if (class_exists($class)) { goto wEGVp; } Log::info("\125\x6e\151\156\x73\164\x61\154\154\145\x72\x20\x6e\x6f\x74\x20\x66\x6f\x75\x6e\x64\40\151\x6e\40\x74\150\x65\40\x70\141\143\153\141\147\x65\40\144\x69\162\x20\x66\157\162\x20" . $this->slug); throw new \Exception("\125\x6e\x69\156\x73\x74\x61\x6c\x6c\145\162\x20\156\x6f\x74\x20\x66\157\165\156\144\x20\146\157\162\40\164\150\145\x20\160\141\143\x6b\141\147\145\x20" . $this->slug); wEGVp: try { (new $class())->cleanDatabase(); $this->rollback(); } catch (\Exception $e) { Log::info("\x50\x61\143\153\x61\x67\145\x20\165\x6e\151\156\x73\164\x61\154\154\x61\164\x69\x6f\156\40\146\x61\x69\154\x65\144\x3a\x20" . $this->slug); Log::error($e); throw new \Exception("\x55\x6e\151\156\163\164\141\x6c\154\141\x74\x69\x6f\x6e\40\x66\141\151\x6c\145\x64\72\x20" . $this->slug); } Log::info("\x53\165\143\143\145\x73\x73\x66\x75\x6c\x6c\x79\x20\x75\x6e\151\156\163\164\141\x6c\154\145\144\x20\x70\141\x63\x6b\x61\147\145\x20" . $this->slug); return $this; } private function rollback() { Log::info("\x52\x6f\x6c\154\40\x62\141\143\153\x20\143\x61\x6c\x6c\x65\144\x2e\56\x2e"); $migrations = array_reverse(glob($this->path . "\x2f\x64\141\x74\141\x62\141\x73\145\57\x6d\x69\x67\x72\x61\164\x69\x6f\156\x73\x2f\x2a\x5f\52\x2e\160\150\x70")); if (!empty($migrations)) { goto Dq4JP; } Log::info("\x4e\157\40\155\x69\x67\162\141\x74\x69\157\x6e\40\164\157\40\x72\x6f\154\154\x20\x62\141\143\x6b\x20\x66\157\x72\40\x70\141\143\153\x61\147\x65\x20" . $this->slug); return $this; Dq4JP: Schema::disableForeignKeyConstraints(); DB::statement("\123\x45\124\40\x46\x4f\122\x45\111\107\x4e\x5f\x4b\x45\131\x5f\x43\x48\x45\103\113\x53\x20\x3d\40\x30"); foreach ($migrations as $filename) { $migration = str_replace("\56\160\x68\x70", '', basename($filename)); Log::info("\x52\x6f\154\x6c\151\156\x67\x20\142\x61\x63\153\x3a\40" . $migration); $row = DB::table("\155\151\x67\x72\x61\x74\151\x6f\x6e\163")->where("\155\151\x67\x72\x61\164\x69\157\x6e", $migration); if ($row->first()) { goto b7eC_; } Log::info($migration . "\40\167\x61\x73\x20\156\x6f\164\x20\x6d\151\x67\x72\x61\164\x65\144\40\142\145\x66\x6f\162\145\54\40\160\x72\x6f\x62\x61\x62\154\x79\x20\x69\x74\x5c\47\x73\40\141\40\x6e\145\x77\x20\155\151\x67\x72\141\x74\x69\157\x6e\40\146\x69\154\145\56"); Log::info("\123\x6b\x69\x70\x70\151\x6e\x67\x20\x72\157\x6c\154\145\x64\x20\x62\x61\143\x6b\x3a\x20" . $migration); goto qPQog; b7eC_: $class = Str::studly(implode("\x5f", array_slice(explode("\x5f", $migration), 4))); if (class_exists($class)) { goto M9Zfw; } include $filename; M9Zfw: (new $class())->down(); if ($row->delete()) { goto PTS_8; } Log::info("\x52\x6f\x6c\154\142\x61\x63\153\40\106\101\x49\114\x45\104\72\40" . $migration); throw new \Exception("\115\151\147\x72\x61\164\151\157\x6e\x20\x72\x6f\154\x6c\142\141\x63\153\x20\x66\x61\x69\154\x65\144\x3a\x20" . $this->slug); goto S3q7Z; PTS_8: Log::info("\122\157\154\x6c\145\x64\x20\142\x61\143\153\72\40" . $migration); S3q7Z: qPQog: } lnFLg: Schema::enableForeignKeyConstraints(); DB::statement("\123\105\124\40\x46\117\122\x45\111\107\116\x5f\113\x45\131\137\x43\x48\x45\103\113\x53\40\x3d\x20\61"); Log::info("\101\154\154\40\155\x69\x67\162\141\164\x69\157\156\163\x20\x68\x61\x73\x20\142\x65\145\x6e\x20\162\157\154\154\145\x64\40\x62\x61\x63\153\x20\146\x6f\162\x20\160\x61\143\153\x61\147\145\40" . $this->slug); return $this; } }

Function Calls

None

Variables

None

Stats

MD5 7318e795989458b018b361f5b6b4ed24
Eval Count 0
Decode Time 56 ms