mirror of
https://github.com/YGGverse/YGGstate.git
synced 2025-01-24 21:44:20 +00:00
add url support in search requests
This commit is contained in:
parent
8dc0889460
commit
baed74f0a8
@ -50,17 +50,30 @@ class SphinxQL {
|
||||
private static function _match(string $keyword) : string {
|
||||
|
||||
$keyword = trim($keyword);
|
||||
$keyword = preg_replace('/[\:]+/', ':', $keyword);
|
||||
|
||||
// Parse url request
|
||||
$peerAddress = $keyword;
|
||||
$peerRemoteScheme = $keyword;
|
||||
$peerRemoteHost = $keyword;
|
||||
$peerRemotePort = $keyword;
|
||||
|
||||
if ($url = Yggverse\Parser\Url::parse($keyword)) {
|
||||
|
||||
$peerAddress = $url->host->name ? $url->host->name : $keyword;
|
||||
$peerRemoteScheme = $url->host->scheme ? $url->host->scheme : $keyword;
|
||||
$peerRemoteHost = $url->host->name ? $url->host->name : $keyword;
|
||||
$peerRemotePort = $url->host->port ? $url->host->port : $keyword;
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'@peerAddress "%s" | @peerKey "%s" | @peerCoordinatePort "%s" | @peerCoordinateRoute "%s" | @peerRemoteScheme "%s" | @peerRemoteHost "%s" | @peerRemotePort "%s"',
|
||||
preg_replace('/[^A-z0-9\:]/', '', $keyword),
|
||||
preg_replace('/[^A-z0-9]/', '', $keyword),
|
||||
preg_replace('/[^\d]/', '', $keyword),
|
||||
preg_replace('/[^\d]/', '', $keyword),
|
||||
preg_replace('/[^A-z]/', '', $keyword),
|
||||
preg_replace('/[^A-z0-9\.\:]/', '', $keyword),
|
||||
preg_replace('/[^\d]/', '', $keyword),
|
||||
preg_replace('/[^A-z0-9\:\[\]]/', '', $peerAddress),
|
||||
preg_replace('/[^A-z0-9]/', '', $keyword),
|
||||
preg_replace('/[^\d]/', '', $keyword),
|
||||
preg_replace('/[^\d]/', '', $keyword),
|
||||
preg_replace('/[^A-z]/', '', $peerRemoteScheme),
|
||||
preg_replace('/[^A-z0-9\.\:\[\]]/', '', $peerRemoteHost),
|
||||
preg_replace('/[^\d]/', '', $peerRemotePort),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,9 @@ $results = $sphinx->searchPeers($requestQuery,
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if (false === strpos($result->peerremotescheme, $requestQuery)) { ?>
|
||||
<?php if (false === strpos(
|
||||
$result->peerremotescheme,
|
||||
Yggverse\Parser\Url::is($requestQuery) ? Yggverse\Parser\Url::parse($requestQuery)->host->scheme : $requestQuery)) { ?>
|
||||
<span title="<?php echo $result->peerremotescheme ?>" class="font-size-22 cursor-default text-color-red">
|
||||
•
|
||||
</span>
|
||||
@ -157,7 +159,9 @@ $results = $sphinx->searchPeers($requestQuery,
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if (false === strpos($result->peerremotehost, $requestQuery)) { ?>
|
||||
<?php if (false === strpos(
|
||||
$result->peerremotehost,
|
||||
Yggverse\Parser\Url::is($requestQuery) ? Yggverse\Parser\Url::parse($requestQuery)->host->name : $requestQuery)) { ?>
|
||||
<span title="<?php echo $result->peerremotehost ?>" class="font-size-22 cursor-default text-color-red">
|
||||
•
|
||||
</span>
|
||||
@ -168,7 +172,9 @@ $results = $sphinx->searchPeers($requestQuery,
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if (false === strpos($result->peerremoteport, $requestQuery)) { ?>
|
||||
<?php if (false === strpos(
|
||||
$result->peerremoteport,
|
||||
Yggverse\Parser\Url::is($requestQuery) ? (int) Yggverse\Parser\Url::parse($requestQuery)->host->port : $requestQuery)) { ?>
|
||||
<span title="<?php echo $result->peerremoteport ?>" class="font-size-22 cursor-default text-color-red">
|
||||
•
|
||||
</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user