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\Grid\Exporters; use Encore\Admin\Grid\Column; class CsvExpor..

Decoded Output download

<?php
 namespace Encore\Admin\Grid\Exporters; use Encore\Admin\Grid\Column; class CsvExporter extends AbstractExporter { protected $filename; protected $callback; protected $exceptColumns; protected $onlyColumns; protected $columnCallbacks; protected $titleCallbacks; protected $visibleColumns; protected $columnUseOriginalValue; public function filename(string $filename = '') : self { $this->filename = $filename; return $this; } public function setCallback(\Closure $closure) : self { $this->callback = $closure; return $this; } public function except(array $columns = array()) : self { $this->exceptColumns = $columns; return $this; } public function only(array $columns = array()) : self { $this->onlyColumns = $columns; return $this; } public function originalValue($columns = array()) : self { $this->columnUseOriginalValue = $columns; return $this; } public function column(string $name, \Closure $callback) : self { $this->columnCallbacks[$name] = $callback; return $this; } public function title(string $name, \Closure $callback) : self { $this->titleCallbacks[$name] = $callback; return $this; } protected function getHeaders() { if (!$this->filename) { $this->filename = $this->getTable(); } return array("Content-Encoding" => "UTF-8", "Content-Type" => "text/csv;charset=UTF-8", "Content-Disposition" => "attachment;filename="{$this->filename}.csv""); } public function export() { if ($this->callback) { call_user_func($this->callback, $this); } $response = function () { $handle = fopen("php://output", "w"); $titles = array(); fwrite($handle, chr(239) . chr(187) . chr(191)); $this->chunk(function ($collection) use($handle, &$titles) { Column::setOriginalGridModels($collection); $original = $current = $collection->toArray(); $this->grid->getColumns()->map(function (Column $column) use(&$current) { $current = $column->fill($current); $this->grid->columnNames[] = $column->getName(); }); if (empty($titles)) { fputcsv($handle, $titles = $this->getVisiableTitles()); } foreach ($current as $index => $record) { fputcsv($handle, $this->getVisiableFields($record, $original[$index])); } }); fclose($handle); }; response()->stream($response, 200, $this->getHeaders())->send(); die; } protected function getVisiableTitles() { $titles = $this->grid->visibleColumns()->mapWithKeys(function (Column $column) { $columnName = $column->getName(); $columnTitle = $column->getLabel(); if (isset($this->titleCallbacks[$columnName])) { $columnTitle = $this->titleCallbacks[$columnName]($columnTitle); } return array($columnName => $columnTitle); }); if ($this->onlyColumns) { $titles = $titles->only($this->onlyColumns); } if ($this->exceptColumns) { $titles = $titles->except($this->exceptColumns); } $this->visibleColumns = $titles->keys(); return $titles->values()->toArray(); } public function getVisiableFields(array $value, array $original) : array { $fields = array(); foreach ($this->visibleColumns as $column) { $fields[] = $this->getColumnValue($column, data_get($value, $column), data_get($original, $column)); } return $fields; } protected function getColumnValue(string $column, $value, $original) { if (!empty($this->columnUseOriginalValue) && in_array($column, $this->columnUseOriginalValue)) { return $original; } if (isset($this->columnCallbacks[$column])) { return $this->columnCallbacks[$column]($value, $original); } return $value; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Encore\Admin\Grid\Exporters; use Encore\Admin\Grid\Column; class CsvExporter extends AbstractExporter { protected $filename; protected $callback; protected $exceptColumns; protected $onlyColumns; protected $columnCallbacks; protected $titleCallbacks; protected $visibleColumns; protected $columnUseOriginalValue; public function filename(string $filename = '') : self { $this->filename = $filename; return $this; } public function setCallback(\Closure $closure) : self { $this->callback = $closure; return $this; } public function except(array $columns = array()) : self { $this->exceptColumns = $columns; return $this; } public function only(array $columns = array()) : self { $this->onlyColumns = $columns; return $this; } public function originalValue($columns = array()) : self { $this->columnUseOriginalValue = $columns; return $this; } public function column(string $name, \Closure $callback) : self { $this->columnCallbacks[$name] = $callback; return $this; } public function title(string $name, \Closure $callback) : self { $this->titleCallbacks[$name] = $callback; return $this; } protected function getHeaders() { if (!$this->filename) { $this->filename = $this->getTable(); } return array("\103\157\156\x74\145\x6e\x74\x2d\x45\156\143\157\x64\151\156\147" => "\x55\x54\106\55\x38", "\103\x6f\x6e\x74\145\x6e\x74\55\x54\171\x70\x65" => "\x74\145\x78\164\x2f\143\163\x76\73\143\x68\141\x72\x73\x65\164\75\x55\x54\x46\55\70", "\x43\x6f\x6e\164\145\x6e\164\x2d\104\x69\163\160\157\x73\151\x74\x69\157\156" => "\141\164\x74\141\143\x68\x6d\145\x6e\164\73\146\x69\x6c\x65\156\x61\155\x65\75\x22{$this->filename}\56\x63\163\166\x22"); } public function export() { if ($this->callback) { call_user_func($this->callback, $this); } $response = function () { $handle = fopen("\160\150\160\x3a\x2f\x2f\x6f\165\164\160\x75\x74", "\x77"); $titles = array(); fwrite($handle, chr(239) . chr(187) . chr(191)); $this->chunk(function ($collection) use($handle, &$titles) { Column::setOriginalGridModels($collection); $original = $current = $collection->toArray(); $this->grid->getColumns()->map(function (Column $column) use(&$current) { $current = $column->fill($current); $this->grid->columnNames[] = $column->getName(); }); if (empty($titles)) { fputcsv($handle, $titles = $this->getVisiableTitles()); } foreach ($current as $index => $record) { fputcsv($handle, $this->getVisiableFields($record, $original[$index])); } }); fclose($handle); }; response()->stream($response, 200, $this->getHeaders())->send(); die; } protected function getVisiableTitles() { $titles = $this->grid->visibleColumns()->mapWithKeys(function (Column $column) { $columnName = $column->getName(); $columnTitle = $column->getLabel(); if (isset($this->titleCallbacks[$columnName])) { $columnTitle = $this->titleCallbacks[$columnName]($columnTitle); } return array($columnName => $columnTitle); }); if ($this->onlyColumns) { $titles = $titles->only($this->onlyColumns); } if ($this->exceptColumns) { $titles = $titles->except($this->exceptColumns); } $this->visibleColumns = $titles->keys(); return $titles->values()->toArray(); } public function getVisiableFields(array $value, array $original) : array { $fields = array(); foreach ($this->visibleColumns as $column) { $fields[] = $this->getColumnValue($column, data_get($value, $column), data_get($original, $column)); } return $fields; } protected function getColumnValue(string $column, $value, $original) { if (!empty($this->columnUseOriginalValue) && in_array($column, $this->columnUseOriginalValue)) { return $original; } if (isset($this->columnCallbacks[$column])) { return $this->columnCallbacks[$column]($value, $original); } return $value; } }

Function Calls

None

Variables

None

Stats

MD5 4b29fc83846f179054d210d5e72acb5f
Eval Count 0
Decode Time 81 ms