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 Encore\Admin\Widgets; use Closure; use Encore\Admin\Facades\Admin; use En..

Decoded Output download

<?php
 namespace Encore\Admin\Widgets; use Closure; use Encore\Admin\Facades\Admin; use Encore\Admin\Form as BaseForm; use Encore\Admin\Form\Field; use Encore\Admin\Layout\Content; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Renderable; use Illuminate\Http\Request; use Illuminate\Support\Arr; use Illuminate\Support\MessageBag; use Illuminate\Validation\Validator; class Form implements Renderable { use BaseForm\Concerns\HandleCascadeFields; public $title; public $description; protected $fields = array(); protected $data = array(); protected $attributes = array(); protected $buttons = array("reset", "submit"); protected $width = array("label" => 2, "field" => 8); public $inbox = true; public $confirm = ''; protected $form; public function __construct($data = array()) { $this->fill($data); $this->initFormAttributes(); } public function title() { return $this->title; } public function description() { return $this->description ?: " "; } public function data() { return $this->data; } public function confirm($message) { $this->confirm = $message; return $this; } public function fill($data = array()) { if ($data instanceof Arrayable) { $data = $data->toArray(); } if (!empty($data)) { $this->data = $data; } return $this; } public function sanitize() { foreach (array("_form_", "_token") as $key) { request()->request->remove($key); } return $this; } protected function initFormAttributes() { $this->attributes = array("id" => "widget-form-" . uniqid(), "method" => "POST", "action" => '', "class" => "form-horizontal", "accept-charset" => "UTF-8", "pjax-container" => true); } public function attribute($attr, $value = '') { if (is_array($attr)) { foreach ($attr as $key => $value) { $this->attribute($key, $value); } } else { $this->attributes[$attr] = $value; } return $this; } public function formatAttribute($attributes = array()) { $attributes = $attributes ?: $this->attributes; if ($this->hasFile()) { $attributes["enctype"] = "multipart/form-data"; } $html = array(); foreach ($attributes as $key => $val) { $html[] = "{$key}="{$val}""; } return implode(" ", $html) ?: ''; } public function action($action) { return $this->attribute("action", $action); } public function method($method = "POST") { if (strtolower($method) == "put") { $this->hidden("_method")->default($method); return $this; } return $this->attribute("method", strtoupper($method)); } public function disablePjax() { Arr::forget($this->attributes, "pjax-container"); return $this; } public function disableReset() { array_delete($this->buttons, "reset"); return $this; } public function disableSubmit() { array_delete($this->buttons, "submit"); return $this; } public function setWidth($fieldWidth = 8, $labelWidth = 2) { collect($this->fields)->each(function ($field) use($fieldWidth, $labelWidth) { $field->setWidth($fieldWidth, $labelWidth); }); $this->width = array("label" => $labelWidth, "field" => $fieldWidth); return $this; } public function hasField($name) { return isset(BaseForm::$availableFields[$name]); } public function pushField(Field $field) { $field->setWidgetForm($this); array_push($this->fields, $field); return $this; } public function fields() { return collect($this->fields); } protected function getVariables() { $this->fields()->each->fill($this->data()); return array("fields" => $this->fields, "attributes" => $this->formatAttribute(), "method" => $this->attributes["method"], "buttons" => $this->buttons, "width" => $this->width); } public function hasFile() { foreach ($this->fields as $field) { if ($field instanceof Field\File) { return true; } } return false; } public function validate(Request $request) { if (method_exists($this, "form")) { $this->form(); } $failedValidators = array(); foreach ($this->fields() as $field) { if (!($validator = $field->getValidator($request->all()))) { continue; } if ($validator instanceof Validator && !$validator->passes()) { $failedValidators[] = $validator; } } $message = $this->mergeValidationMessages($failedValidators); return $message->any() ? $message : false; } protected function mergeValidationMessages($validators) { $messageBag = new MessageBag(); foreach ($validators as $validator) { $messageBag = $messageBag->merge($validator->messages()); } return $messageBag; } public function fieldset(string $title, Closure $setCallback) { $fieldset = new Field\Fieldset(); $this->html($fieldset->start($title))->plain(); $setCallback($this); $this->html($fieldset->end())->plain(); return $fieldset; } public function unbox() { $this->inbox = false; return $this; } protected function addConfirmScript() { $id = $this->attributes["id"]; $trans = array("cancel" => trans("admin.cancel"), "submit" => trans("admin.submit")); $settings = array("type" => "question", "showCancelButton" => true, "confirmButtonText" => $trans["submit"], "cancelButtonText" => $trans["cancel"], "title" => $this->confirm, "text" => ''); $settings = trim(json_encode($settings, JSON_PRETTY_PRINT)); $script = "\xa$('form#{$id}').off('submit').on('submit', function (e) {
    e.preventDefault();
    var form = this;\xa    $.admin.swal({$settings}).then(function (result) {\xa        if (result.value == true) {
            form.submit();
        }
    });
    return false;\xa});"; Admin::script($script); } protected function addCascadeScript() { $id = $this->attributes["id"]; $script = ";(function () {
    $('form#{$id}').submit(function (e) {\xa        e.preventDefault();
        $(this).find('div.cascade-group.hide :input').attr('disabled', true);\xa    });
})();"; Admin::script($script); } protected function prepareForm() { if (method_exists($this, "form")) { $this->form(); } if (!empty($this->confirm)) { $this->addConfirmScript(); } $this->addCascadeScript(); } protected function prepareHandle() { if (method_exists($this, "handle")) { $this->method("POST"); $this->action(admin_url("_handle_form_")); $this->hidden("_form_")->default(get_called_class()); } } public function render() { $this->prepareForm(); $this->prepareHandle(); $form = view("admin::widgets.form", $this->getVariables())->render(); if (!($title = $this->title()) || !$this->inbox) { return $form; } return (new Box($title, $form))->render(); } public function __call($method, $arguments) { if (!$this->hasField($method)) { return $this; } $class = BaseForm::$availableFields[$method]; $field = new $class(Arr::get($arguments, 0), array_slice($arguments, 1)); return tap($field, function ($field) { $this->pushField($field); }); } public function __invoke(Content $content) { return $content->title($this->title())->description($this->description())->body($this); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Encore\Admin\Widgets; use Closure; use Encore\Admin\Facades\Admin; use Encore\Admin\Form as BaseForm; use Encore\Admin\Form\Field; use Encore\Admin\Layout\Content; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Renderable; use Illuminate\Http\Request; use Illuminate\Support\Arr; use Illuminate\Support\MessageBag; use Illuminate\Validation\Validator; class Form implements Renderable { use BaseForm\Concerns\HandleCascadeFields; public $title; public $description; protected $fields = array(); protected $data = array(); protected $attributes = array(); protected $buttons = array("\162\145\163\145\x74", "\x73\165\142\155\x69\164"); protected $width = array("\154\141\142\x65\x6c" => 2, "\x66\151\x65\x6c\144" => 8); public $inbox = true; public $confirm = ''; protected $form; public function __construct($data = array()) { $this->fill($data); $this->initFormAttributes(); } public function title() { return $this->title; } public function description() { return $this->description ?: "\40"; } public function data() { return $this->data; } public function confirm($message) { $this->confirm = $message; return $this; } public function fill($data = array()) { if ($data instanceof Arrayable) { $data = $data->toArray(); } if (!empty($data)) { $this->data = $data; } return $this; } public function sanitize() { foreach (array("\x5f\x66\x6f\162\x6d\x5f", "\x5f\x74\x6f\x6b\145\156") as $key) { request()->request->remove($key); } return $this; } protected function initFormAttributes() { $this->attributes = array("\151\144" => "\x77\x69\144\147\x65\164\55\146\157\x72\x6d\x2d" . uniqid(), "\x6d\145\164\x68\x6f\144" => "\x50\117\x53\124", "\141\x63\164\151\157\x6e" => '', "\x63\154\141\x73\163" => "\146\157\162\155\55\x68\x6f\x72\151\172\157\156\164\x61\154", "\x61\143\143\145\x70\164\55\143\x68\x61\x72\x73\x65\x74" => "\x55\124\x46\55\70", "\160\152\141\x78\55\x63\x6f\156\x74\141\151\156\x65\x72" => true); } public function attribute($attr, $value = '') { if (is_array($attr)) { foreach ($attr as $key => $value) { $this->attribute($key, $value); } } else { $this->attributes[$attr] = $value; } return $this; } public function formatAttribute($attributes = array()) { $attributes = $attributes ?: $this->attributes; if ($this->hasFile()) { $attributes["\145\156\x63\x74\x79\x70\145"] = "\155\165\154\164\x69\160\x61\x72\x74\x2f\146\x6f\162\155\x2d\x64\x61\x74\x61"; } $html = array(); foreach ($attributes as $key => $val) { $html[] = "{$key}\x3d\x22{$val}\42"; } return implode("\x20", $html) ?: ''; } public function action($action) { return $this->attribute("\x61\x63\164\151\157\x6e", $action); } public function method($method = "\x50\x4f\123\x54") { if (strtolower($method) == "\x70\165\164") { $this->hidden("\x5f\x6d\145\164\x68\x6f\144")->default($method); return $this; } return $this->attribute("\155\145\x74\x68\x6f\x64", strtoupper($method)); } public function disablePjax() { Arr::forget($this->attributes, "\x70\152\x61\170\x2d\143\x6f\x6e\164\141\x69\x6e\x65\162"); return $this; } public function disableReset() { array_delete($this->buttons, "\162\x65\163\x65\x74"); return $this; } public function disableSubmit() { array_delete($this->buttons, "\163\x75\142\x6d\151\x74"); return $this; } public function setWidth($fieldWidth = 8, $labelWidth = 2) { collect($this->fields)->each(function ($field) use($fieldWidth, $labelWidth) { $field->setWidth($fieldWidth, $labelWidth); }); $this->width = array("\154\x61\142\145\154" => $labelWidth, "\x66\x69\145\x6c\x64" => $fieldWidth); return $this; } public function hasField($name) { return isset(BaseForm::$availableFields[$name]); } public function pushField(Field $field) { $field->setWidgetForm($this); array_push($this->fields, $field); return $this; } public function fields() { return collect($this->fields); } protected function getVariables() { $this->fields()->each->fill($this->data()); return array("\146\151\x65\x6c\144\163" => $this->fields, "\x61\x74\x74\x72\x69\142\x75\164\145\163" => $this->formatAttribute(), "\x6d\145\x74\x68\157\x64" => $this->attributes["\155\145\164\150\157\144"], "\142\x75\164\164\157\156\163" => $this->buttons, "\x77\151\144\x74\x68" => $this->width); } public function hasFile() { foreach ($this->fields as $field) { if ($field instanceof Field\File) { return true; } } return false; } public function validate(Request $request) { if (method_exists($this, "\x66\x6f\162\155")) { $this->form(); } $failedValidators = array(); foreach ($this->fields() as $field) { if (!($validator = $field->getValidator($request->all()))) { continue; } if ($validator instanceof Validator && !$validator->passes()) { $failedValidators[] = $validator; } } $message = $this->mergeValidationMessages($failedValidators); return $message->any() ? $message : false; } protected function mergeValidationMessages($validators) { $messageBag = new MessageBag(); foreach ($validators as $validator) { $messageBag = $messageBag->merge($validator->messages()); } return $messageBag; } public function fieldset(string $title, Closure $setCallback) { $fieldset = new Field\Fieldset(); $this->html($fieldset->start($title))->plain(); $setCallback($this); $this->html($fieldset->end())->plain(); return $fieldset; } public function unbox() { $this->inbox = false; return $this; } protected function addConfirmScript() { $id = $this->attributes["\x69\144"]; $trans = array("\x63\141\x6e\x63\145\x6c" => trans("\141\x64\x6d\151\x6e\56\143\x61\156\x63\x65\x6c"), "\x73\x75\142\x6d\x69\164" => trans("\141\144\x6d\x69\156\x2e\163\165\142\155\x69\x74")); $settings = array("\164\x79\160\145" => "\x71\x75\145\163\x74\151\157\156", "\163\150\x6f\x77\103\x61\x6e\143\x65\154\x42\x75\164\x74\157\156" => true, "\143\x6f\x6e\146\151\x72\155\102\165\x74\164\157\x6e\124\145\x78\164" => $trans["\x73\x75\x62\155\x69\x74"], "\x63\x61\156\143\145\154\102\x75\x74\164\157\x6e\x54\x65\170\164" => $trans["\143\x61\156\x63\x65\154"], "\164\x69\x74\x6c\145" => $this->confirm, "\164\145\x78\164" => ''); $settings = trim(json_encode($settings, JSON_PRETTY_PRINT)); $script = "\xa\44\x28\x27\x66\157\162\x6d\x23{$id}\47\51\x2e\157\146\146\x28\x27\163\165\142\155\151\164\x27\51\56\157\x6e\50\47\163\x75\x62\155\151\x74\47\x2c\x20\x66\x75\x6e\x63\x74\x69\x6f\x6e\x20\50\x65\x29\x20\x7b\12\40\40\x20\x20\145\x2e\x70\162\145\x76\x65\156\164\104\145\x66\141\165\154\x74\50\51\x3b\12\x20\40\40\x20\x76\141\x72\x20\x66\x6f\x72\155\x20\x3d\x20\164\x68\151\163\x3b\xa\x20\x20\40\x20\44\56\141\144\x6d\x69\156\56\163\167\141\x6c\50{$settings}\x29\x2e\164\150\145\156\50\x66\x75\x6e\x63\x74\x69\157\156\40\50\x72\145\163\165\x6c\164\x29\x20\x7b\xa\x20\40\40\x20\x20\40\40\x20\151\146\40\x28\x72\145\163\x75\x6c\x74\x2e\166\x61\154\x75\x65\x20\x3d\75\40\x74\x72\165\x65\51\x20\x7b\12\40\x20\40\x20\x20\x20\40\40\40\x20\40\x20\146\157\x72\155\56\163\165\x62\155\x69\x74\x28\51\73\12\x20\40\40\x20\40\40\x20\40\x7d\12\40\x20\x20\x20\x7d\51\x3b\12\40\x20\x20\40\x72\x65\164\x75\x72\x6e\40\146\x61\154\163\145\x3b\xa\175\51\x3b"; Admin::script($script); } protected function addCascadeScript() { $id = $this->attributes["\151\x64"]; $script = "\73\50\x66\165\x6e\143\164\151\157\x6e\40\50\51\40\x7b\12\x20\x20\40\40\44\x28\x27\146\x6f\162\x6d\x23{$id}\x27\x29\56\x73\165\x62\155\x69\x74\50\x66\x75\x6e\x63\164\x69\x6f\156\x20\50\145\51\x20\173\xa\x20\x20\x20\x20\40\40\40\40\x65\56\x70\x72\145\x76\145\156\164\x44\145\x66\141\x75\x6c\x74\50\x29\x3b\12\40\x20\40\40\x20\x20\x20\40\x24\x28\164\x68\x69\163\x29\56\146\x69\x6e\144\x28\x27\x64\151\x76\x2e\143\x61\x73\x63\141\144\145\55\147\x72\x6f\165\160\56\x68\x69\144\145\40\72\x69\156\160\165\164\47\x29\56\141\164\x74\x72\x28\x27\144\x69\x73\141\x62\x6c\145\144\47\x2c\40\164\x72\x75\x65\51\x3b\xa\40\40\40\40\175\x29\x3b\12\175\51\x28\x29\x3b"; Admin::script($script); } protected function prepareForm() { if (method_exists($this, "\x66\157\162\x6d")) { $this->form(); } if (!empty($this->confirm)) { $this->addConfirmScript(); } $this->addCascadeScript(); } protected function prepareHandle() { if (method_exists($this, "\150\x61\156\144\154\x65")) { $this->method("\120\117\123\124"); $this->action(admin_url("\x5f\x68\x61\156\144\x6c\145\x5f\x66\x6f\x72\x6d\137")); $this->hidden("\x5f\146\x6f\162\155\x5f")->default(get_called_class()); } } public function render() { $this->prepareForm(); $this->prepareHandle(); $form = view("\x61\x64\155\151\156\x3a\72\167\x69\144\x67\145\164\163\x2e\x66\157\x72\155", $this->getVariables())->render(); if (!($title = $this->title()) || !$this->inbox) { return $form; } return (new Box($title, $form))->render(); } public function __call($method, $arguments) { if (!$this->hasField($method)) { return $this; } $class = BaseForm::$availableFields[$method]; $field = new $class(Arr::get($arguments, 0), array_slice($arguments, 1)); return tap($field, function ($field) { $this->pushField($field); }); } public function __invoke(Content $content) { return $content->title($this->title())->description($this->description())->body($this); } }

Function Calls

None

Variables

None

Stats

MD5 4cf74f8ac887180acd9a55aaba538064
Eval Count 0
Decode Time 102 ms