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/GXModules/Gambio/StyleEdit/Adapters/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/moncbefd/www.moneta.at/GXModules/Gambio/StyleEdit/Adapters//ShopCacheCleaner.php
<?php
/*--------------------------------------------------------------------------------------------------
    ShopCacheCleaner.php 2019-10-22
    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]
    --------------------------------------------------------------------------------------------------
 */

namespace Gambio\StyleEdit\Adapters;

use CacheControl;
use FileNotFoundException;
use FilesystemAdapter;
use Gambio\StyleEdit\Adapters\Interfaces\CacheCleanerInterface;
use Gambio\StyleEdit\Core\BuildStrategies\Interfaces\SingletonStrategyInterface;
use Gambio\StyleEdit\StyleEditConfiguration;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use MainFactory;
use RuntimeException;

/**
 * Class ShopCacheCleaner
 * @package Gambio\StyleEdit\Adapters
 */
class ShopCacheCleaner implements CacheCleanerInterface, SingletonStrategyInterface
{
    /**
     * @var FilesystemAdapter
     */
    protected $adapter;
    
    /**
     * @var CacheControl
     */
    protected $cacheControl;
    
    
    /**
     * ShopCacheCleaner constructor.
     *
     * @param FilesystemAdapter $adapter
     * @param CacheControl      $cacheControl
     */
    public function __construct(FilesystemAdapter $adapter, CacheControl $cacheControl)
    {
        $this->adapter      = $adapter;
        $this->cacheControl = $cacheControl;
    }
    
    
    /**
     * @return ShopCacheCleaner
     */
    public static function create(): ShopCacheCleaner
    {
        $settings          = new StyleEditConfiguration;
        $filesystemAdapter = new Local($settings->baseFolderPath(), LOCK_EX, Local::DISALLOW_LINKS, [
            'file' => [
                'public'  => 0777,
                'private' => 0700,
            ],
            'dir'  => [
                'public'  => 0777,
                'private' => 0700,
            ]
        ]);
        $filesystem        = new Filesystem($filesystemAdapter);
        
        $adapter      = MainFactory::create(FilesystemAdapter::class, $filesystem);
        $cacheControl = MainFactory::create_object(CacheControl::class);
        
        return new self($adapter, $cacheControl);
    }
    
    
    /**
     * @param $themeId
     *
     * @throws FileNotFoundException
     */
    public function clearThemeCache($themeId): void
    {
        $previewFilename = "themes/$themeId/preview.json";
        if ($this->adapter->has($previewFilename)) {
            $previewContent    = $this->adapter->read($previewFilename);
            $previewFileObject = json_decode($previewContent);
            if (json_last_error()) {
                throw new RuntimeException ("Invalid Preview file $previewFilename");
            }
            if ($this->adapter->has($previewFileObject->publishPath)) {
                $this->adapter->deleteDir($previewFileObject->publishPath);
                $this->adapter->createDir($previewFileObject->publishPath, ['visibility' => 'public']);
            }
            if ($this->adapter->has($previewFileObject->compilePath)) {
                $this->adapter->deleteDir($previewFileObject->compilePath);
                $this->adapter->createDir($previewFileObject->compilePath, ['visibility' => 'public']);
            }
        }
    }
    
    
    /**
     */
    public function clearShopCache(): void
    {
        $this->cacheControl->clear_content_view_cache();
        $this->cacheControl->clear_templates_c();
        $dir = "public/theme";
        
        if ($this->adapter->has($dir)) {
            $this->adapter->deleteDir($dir);
            @$this->adapter->createDir($dir, ['visibility' => 'public']);
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit