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\Models; use App\Module\Base; use Cache; /** * App\Models\ProjectTa..

Decoded Output download

<?php

namespace App\Models;

use App\Module\Base;
use Cache;

/**
 * App\Models\ProjectTaskFile
 *
 * @property int $id
 * @property int|null $project_id ID
 * @property int|null $task_id ID
 * @property string|null $name 
 * @property int|null $size (B)
 * @property string|null $ext 
 * @property string $path 
 * @property string $thumb 
 * @property int|null $userid ID
 * @property int|null $download 
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read int $height
 * @property-read int $width
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel cancelAppend()
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel cancelHidden()
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel change($array)
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel getKeyValue()
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile query()
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel remove()
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel saveOrIgnore()
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereDownload($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereExt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile wherePath($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereProjectId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereSize($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereTaskId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereThumb($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereUserid($value)
 * @mixin \Eloquent
 */
class ProjectTaskFile extends AbstractModel
{
    protected $appends = [
        'width',
        'height',
    ];

    /**
     * 
     * @param $value
     * @return string
     */
    public function getPathAttribute($value)
    {
        return Base::fillUrl($value);
    }

    /**
     * 
     * @param $value
     * @return string
     */
    public function getThumbAttribute($value)
    {
        return Base::fillUrl($value ?: Base::extIcon($this->ext));
    }

    /**
     * 
     * @return int
     */
    public function getWidthAttribute()
    {
        $this->generateSizeData();
        return $this->appendattrs['width'];
    }

    /**
     * 
     * @return int
     */
    public function getHeightAttribute()
    {
        $this->generateSizeData();
        return $this->appendattrs['height'];
    }

    /**
     * 
     */
    private function generateSizeData()
    {
        if (!isset($this->appendattrs['width'])) {
            $width = -1;
            $height = -1;
            if (in_array($this->ext, ['jpg', 'jpeg', 'webp', 'gif', 'png'])) {
                $path = public_path($this->getRawOriginal('path'));
                [$width, $height] = Cache::remember("File::size-" . md5($path), now()->addDays(7), function () use ($path) {
                    $width = -1;
                    $height = -1;
                    if (file_exists($path)) {
                        $paramet = getimagesize($path);
                        $width = $paramet[0];
                        $height = $paramet[1];
                    }
                    return [$width, $height];
                });
            }
            $this->appendattrs['width'] = $width;
            $this->appendattrs['height'] = $height;
        }
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace App\Models;

use App\Module\Base;
use Cache;

/**
 * App\Models\ProjectTaskFile
 *
 * @property int $id
 * @property int|null $project_id ID
 * @property int|null $task_id ID
 * @property string|null $name 
 * @property int|null $size (B)
 * @property string|null $ext 
 * @property string $path 
 * @property string $thumb 
 * @property int|null $userid ID
 * @property int|null $download 
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read int $height
 * @property-read int $width
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel cancelAppend()
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel cancelHidden()
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel change($array)
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel getKeyValue()
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile query()
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel remove()
 * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel saveOrIgnore()
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereDownload($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereExt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile wherePath($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereProjectId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereSize($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereTaskId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereThumb($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskFile whereUserid($value)
 * @mixin \Eloquent
 */
class ProjectTaskFile extends AbstractModel
{
    protected $appends = [
        'width',
        'height',
    ];

    /**
     * 
     * @param $value
     * @return string
     */
    public function getPathAttribute($value)
    {
        return Base::fillUrl($value);
    }

    /**
     * 
     * @param $value
     * @return string
     */
    public function getThumbAttribute($value)
    {
        return Base::fillUrl($value ?: Base::extIcon($this->ext));
    }

    /**
     * 
     * @return int
     */
    public function getWidthAttribute()
    {
        $this->generateSizeData();
        return $this->appendattrs['width'];
    }

    /**
     * 
     * @return int
     */
    public function getHeightAttribute()
    {
        $this->generateSizeData();
        return $this->appendattrs['height'];
    }

    /**
     * 
     */
    private function generateSizeData()
    {
        if (!isset($this->appendattrs['width'])) {
            $width = -1;
            $height = -1;
            if (in_array($this->ext, ['jpg', 'jpeg', 'webp', 'gif', 'png'])) {
                $path = public_path($this->getRawOriginal('path'));
                [$width, $height] = Cache::remember("File::size-" . md5($path), now()->addDays(7), function () use ($path) {
                    $width = -1;
                    $height = -1;
                    if (file_exists($path)) {
                        $paramet = getimagesize($path);
                        $width = $paramet[0];
                        $height = $paramet[1];
                    }
                    return [$width, $height];
                });
            }
            $this->appendattrs['width'] = $width;
            $this->appendattrs['height'] = $height;
        }
    }
}

Function Calls

None

Variables

None

Stats

MD5 8ea66548486368fe628248a82c3dcdac
Eval Count 0
Decode Time 88 ms