����JFIF��x�x����'403WebShell
403Webshell
Server IP : 66.29.137.217  /  Your IP : 18.188.119.49
Web Server : LiteSpeed
System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : gltevjme ( 1095)
PHP Version : 7.0.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/gltevjme/./bofirmacademy.com/vendor/spatie/laravel-backup/src/Tasks/Backup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gltevjme/./bofirmacademy.com/vendor/spatie/laravel-backup/src/Tasks/Backup/FileSelection.php
<?php

namespace Spatie\Backup\Tasks\Backup;

use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Symfony\Component\Finder\Finder;

class FileSelection
{
    protected Collection $includeFilesAndDirectories;

    protected Collection $excludeFilesAndDirectories;

    protected bool $shouldFollowLinks = false;

    protected bool $shouldIgnoreUnreadableDirs = false;

    public static function create(array | string $includeFilesAndDirectories = []): self
    {
        return new static($includeFilesAndDirectories);
    }

    public function __construct(array | string $includeFilesAndDirectories = [])
    {
        $this->includeFilesAndDirectories = collect($includeFilesAndDirectories);

        $this->excludeFilesAndDirectories = collect();
    }

    public function excludeFilesFrom(array | string $excludeFilesAndDirectories): self
    {
        $this->excludeFilesAndDirectories = $this->excludeFilesAndDirectories->merge($this->sanitize($excludeFilesAndDirectories));

        return $this;
    }

    public function shouldFollowLinks(bool $shouldFollowLinks): self
    {
        $this->shouldFollowLinks = $shouldFollowLinks;

        return $this;
    }

    public function shouldIgnoreUnreadableDirs(bool $ignoreUnreadableDirs): self
    {
        $this->shouldIgnoreUnreadableDirs = $ignoreUnreadableDirs;

        return $this;
    }

    public function selectedFiles(): Generator | array
    {
        if ($this->includeFilesAndDirectories->isEmpty()) {
            return [];
        }

        $finder = (new Finder())
            ->ignoreDotFiles(false)
            ->ignoreVCS(false);

        if ($this->shouldFollowLinks) {
            $finder->followLinks();
        }

        if ($this->shouldIgnoreUnreadableDirs) {
            $finder->ignoreUnreadableDirs();
        }

        foreach ($this->includedFiles() as $includedFile) {
            yield $includedFile;
        }

        if (! count($this->includedDirectories())) {
            return [];
        }

        $finder->in($this->includedDirectories());

        foreach ($finder->getIterator() as $file) {
            if ($this->shouldExclude($file)) {
                continue;
            }

            yield $file->getPathname();
        }
    }

    protected function includedFiles(): array
    {
        return $this
            ->includeFilesAndDirectories
            ->filter(fn ($path) => is_file($path))->toArray();
    }

    protected function includedDirectories(): array
    {
        return $this
            ->includeFilesAndDirectories
            ->reject(fn ($path) => is_file($path))->toArray();
    }

    protected function shouldExclude(string $path): bool
    {
        $path = realpath($path);
        if (is_dir($path)) {
            $path .= DIRECTORY_SEPARATOR ;
        }
        foreach ($this->excludeFilesAndDirectories as $excludedPath) {
            if (Str::startsWith($path, $excludedPath.(is_dir($excludedPath) ? DIRECTORY_SEPARATOR : ''))) {
                if ($path != $excludedPath && is_file($excludedPath)) {
                    continue;
                }

                return true;
            }
        }

        return false;
    }

    protected function sanitize(string | array $paths): Collection
    {
        return collect($paths)
            ->reject(fn ($path) => $path === '')
            ->flatMap(fn ($path) => $this->getMatchingPaths($path))
            ->map(fn ($path) => realpath($path))
            ->reject(fn ($path) => $path === false);
    }

    protected function getMatchingPaths(string $path): array
    {
        if ($this->canUseGlobBrace($path)) {
            return glob(str_replace('*', '{.[!.],}*', $path), GLOB_BRACE);
        }

        return glob($path);
    }

    protected function canUseGlobBrace(string $path): bool
    {
        return strpos($path, '*') !== false && defined('GLOB_BRACE');
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit