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/Transfer/Type/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/app/code/Soon/DataSync/Model/Transfer/Type/Local.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\Transfer\Type;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Data\Collection\Filesystem;
use Magento\Framework\Data\Collection\FilesystemFactory;
use Soon\DataSync\Model\File;
use Soon\DataSync\Model\FileFactory;

class Local extends TransferTypeAbstract
{
    /**
     * @var FileFactory
     */
    private $fileFactory;
    /**
     * @var DirectoryList
     */
    private $directoryList;
    /**
     * @var FilesystemFactory
     */
    private $filesystemFactory;

    public function __construct(
        DirectoryList $directoryList,
        FileFactory $fileFactory,
        FilesystemFactory $filesystemFactory
    )
    {
        $this->fileFactory = $fileFactory;
        $this->directoryList = $directoryList;
        $this->filesystemFactory = $filesystemFactory;
    }

    /**
     * @return string
     */
    public function pull(): string
    {
        return $this->file()->read();
    }

    /**
     * @return File
     */
    private function file()
    {
        return $this->fileFactory->create(['file' => $this->filepath()]);
    }

    /**
     * @param string $path
     * @return array
     */
    public function glob(string $path): array
    {
        list($file, $dir) = $this->splitPath($path);
        /** @var Filesystem $filesystem */
        $filesystem = $this->filesystemFactory->create();
        $filesystem->addTargetDir($dir);
        $filesystem->addCallbackFilter('basename', $file, 'and', [$this, 'filterCallbackContains']);
        $filesystem->loadData();

        return $filesystem->getColumnValues('filename');
    }

    /**
     * @param $field
     * @param $filterValue
     * @param $row
     * @return bool
     */
    public function filterCallbackContains($field, $filterValue, $row)
    {
        return $this->match($row[$field], trim(stripslashes($filterValue), '\''));
    }

    public function push(string $content)
    {
        $this->file()->write($content);
    }

    public function clean()
    {
        $this->file()->rm();
    }

    /**
     * @return string
     */
    protected function parseFilepath(): string
    {
        $baseDir = $this->directoryList->getPath(DirectoryList::ROOT);
        $filepath = str_replace(self::BASE_DIR_DIRECTIVE, $baseDir, $this->filepath);

        return $filepath;
    }
}

Spamworldpro Mini