mirror of https://github.com/YGGverse/YGGo.git
phpyggdrasilcrawlermysqljs-lessspideralt-websphinxopen-sourcedistributedwebsearch-engineparserfts5privacy-orientedsphinxsearchfederativeweb-archivepdocurl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.2 KiB
73 lines
1.2 KiB
2 years ago
|
<?php
|
||
|
|
||
|
class Parser {
|
||
|
|
||
|
static public function hostURL(string $string) {
|
||
|
|
||
|
$result = [
|
||
|
'string' => null,
|
||
|
'scheme' => null,
|
||
|
'name' => null,
|
||
|
'port' => null,
|
||
|
];
|
||
|
|
||
|
if ($hostScheme = parse_url($string, PHP_URL_SCHEME)) {
|
||
|
|
||
|
$result['string'] = $hostScheme . '://';
|
||
|
|
||
|
$result['scheme'] = $hostScheme;
|
||
|
|
||
|
} else {
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if ($hostName = parse_url($string, PHP_URL_HOST)) {
|
||
|
|
||
|
$result['string'] .= $hostName;
|
||
|
|
||
|
$result['name'] = $hostName;
|
||
|
|
||
|
} else {
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if ($hostPort = parse_url($string, PHP_URL_PORT)) {
|
||
|
|
||
|
$result['string'] .= ':' . $hostPort;
|
||
|
|
||
|
$result['port'] = $hostPort;
|
||
|
|
||
|
}
|
||
|
|
||
|
return (object) $result;
|
||
|
}
|
||
|
|
||
|
static public function uri(string $string) {
|
||
|
|
||
|
$result = [
|
||
|
'string' => '/',
|
||
|
'path' => '/',
|
||
|
'query' => null,
|
||
|
];
|
||
|
|
||
|
if ($path = parse_url($string, PHP_URL_PATH)) {
|
||
|
|
||
|
$result['string'] = $path;
|
||
|
|
||
|
$result['path'] = $path;
|
||
|
|
||
|
}
|
||
|
|
||
|
if ($query = parse_url($string, PHP_URL_QUERY)) {
|
||
|
|
||
|
$result['string'] .= '?' . $query;
|
||
|
|
||
|
$result['query'] = '?' . $query;
|
||
|
|
||
|
}
|
||
|
|
||
|
return (object) $result;
|
||
|
}
|
||
|
}
|