From ff1e72c6d8f5ad8a70787574df40f77b465f564c Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 22 Aug 2023 19:40:16 +0300 Subject: [PATCH] redirect visitor to it peer page on empty search request --- src/public/search.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/public/search.php b/src/public/search.php index 2c3415c..26eecee 100644 --- a/src/public/search.php +++ b/src/public/search.php @@ -46,6 +46,15 @@ $requestQuery = !empty($_GET['query']) ? trim(html_entity_decode(urldecode($_GET $requestTheme = !empty($_GET['theme']) && in_array(['default'], $_GET['theme']) ? $_GET['theme'] : 'default'; $requestPage = !empty($_GET['page']) && $_GET['page'] > 1 ? (int) $_GET['page'] : 1; +// Redirect visitor to it peer page on empty search request +if ($requestQuery == '*' && !empty($_SERVER['REMOTE_ADDR'])) { + + if ($peer = $db->findPeer($_SERVER['REMOTE_ADDR'])) { + + header(sprintf('Location: %s/peer.php?peerId=%s', WEBSITE_URL, $peer->peerId)); + } +} + // Search request $total = $sphinx->searchPeersTotal($requestQuery); $results = $sphinx->searchPeers($requestQuery,