From e72cc442bfc6a7fe48dd15d9bfaa54cdd4b6889b Mon Sep 17 00:00:00 2001 From: hnhx Date: Sat, 29 Oct 2022 14:41:05 +0200 Subject: [PATCH] added weather and tor check special query, fixed an issue with search types, removed an offline instance --- README.md | 1 - engines/google/text.php | 45 ++++++++++++++++++++++++++++--------- engines/special/ip.php | 4 ++-- engines/special/tor.php | 18 +++++++++++++++ engines/special/weather.php | 26 +++++++++++++++++++++ instances.json | 6 ----- search.php | 5 ++++- 7 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 engines/special/tor.php create mode 100644 engines/special/weather.php diff --git a/README.md b/README.md index 5c6f7c0..d199d03 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ | [librex.extravi.dev](https://librex.extravi.dev/) | [βœ…](http://ncblhz7q4sfbf755bdbhebfzxcpypz7ewafgi4agatecojz7pln4i3id.onion/) | [βœ…](http://rra33hiaf6nmby7jfpqe2gqmng3jnzkvbu2n7jgce7vbhoyuhzya.b32.i2p/) | πŸ‡©πŸ‡ͺ DE | | [lx.vern.cc](https://lx.vern.cc/) | [βœ…](http://lx.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/) | [βœ…](http://vernziqfqvweijfaacmwazohgpdo2bt2ib2jlupt2pwwu27bhgxq.b32.i2p/) | πŸ‡ΊπŸ‡Έ US | | [search.davidovski.xyz](https://search.davidovski.xyz/) | ❌ | ❌ | πŸ‡¬πŸ‡§ UK | -| [librex.kitscomputer.tk](https://librex.kitscomputer.tk/) | ❌ | ❌ | πŸ‡ΊπŸ‡Έ US | | [search.funami.tech](https://search.funami.tech/) | ❌ | ❌ | πŸ‡°πŸ‡· KR | | [librex.catalyst.sx](https://librex.catalyst.sx/) | ❌ | ❌ | πŸ‡ΊπŸ‡Έ US | | [search.madreyk.xyz](https://search.madreyk.xyz/) | ❌ | ❌ | πŸ‡©πŸ‡ͺ DE | diff --git a/engines/google/text.php b/engines/google/text.php index 5fb33a7..4f1a7e8 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -21,17 +21,25 @@ { if (strpos($query_lower, "ip")) { - return 4; + return 3; } else if (strpos($query_lower, "user agent") || strpos($query_lower, "ua")) { - return 5; + return 4; } } + else if (strpos($query_lower, "weather") !== false) + { + return 5; + } + else if (strpos($query_lower, "tor") !== false) + { + return 6; + } else if (3 > count(explode(" ", $query))) // wikipedia { - return 3; - } + return 7; + } return 0; } @@ -67,7 +75,13 @@ $word_to_define = $reversed_split_q[1]; $url = "https://api.dictionaryapi.dev/api/v2/entries/en/$word_to_define"; break; - case 3: + case 5: + $url = "https://wttr.in/@" . $_SERVER["REMOTE_ADDR"] . "?format=j1"; + break; + case 6: + $url = "https://check.torproject.org/torbulkexitlist"; + break; + case 7: $url = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded"; break; } @@ -98,18 +112,27 @@ require "engines/special/definition.php"; $special_result = definition_results($query, curl_multi_getcontent($special_ch)); break; + case 3: - require "engines/special/wikipedia.php"; - $special_result = wikipedia_results($query, curl_multi_getcontent($special_ch)); - break; - case 4: require "engines/special/ip.php"; $special_result = ip_result(); break; - case 5: + case 4: require "engines/special/user_agent.php"; $special_result = user_agent_result(); break; + case 5: + require "engines/special/weather.php"; + $special_result = weather_results(curl_multi_getcontent($special_ch)); + break; + case 6: + require "engines/special/tor.php"; + $special_result = tor_result(curl_multi_getcontent($special_ch)); + break; + case 7: + require "engines/special/wikipedia.php"; + $special_result = wikipedia_results($query, curl_multi_getcontent($special_ch)); + break; } if ($special_result != null) @@ -175,7 +198,7 @@ array_shift($results); } - + echo "
"; foreach($results as $result) diff --git a/engines/special/ip.php b/engines/special/ip.php index 63e01c7..91a16f8 100644 --- a/engines/special/ip.php +++ b/engines/special/ip.php @@ -3,9 +3,9 @@ { return array( "special_response" => array( - "response" => $_SERVER["REMOTE_ADDR"], + "response" => $_SERVER["REMOTE_ADDR"], "source" => null ) - ); + ); } ?> diff --git a/engines/special/tor.php b/engines/special/tor.php new file mode 100644 index 0000000..451bf4e --- /dev/null +++ b/engines/special/tor.php @@ -0,0 +1,18 @@ + array( + "response" => $formatted_response, + "source" => $source + ) + ); + } +?> diff --git a/engines/special/weather.php b/engines/special/weather.php new file mode 100644 index 0000000..f98b158 --- /dev/null +++ b/engines/special/weather.php @@ -0,0 +1,26 @@ + array( + "response" => htmlspecialchars($formatted_response), + "source" => $source + ) + ); + } + + } +?> diff --git a/instances.json b/instances.json index 39bc354..cf35ad1 100644 --- a/instances.json +++ b/instances.json @@ -18,12 +18,6 @@ "i2p": null, "country": "UK" }, - { - "clearnet": "https://librex.kitscomputer.tk/", - "tor": null, - "i2p": null, - "country": "US" - }, { "clearnet": "https://search.funami.tech/", "tor": null, diff --git a/search.php b/search.php index d7a9104..c03bb90 100644 --- a/search.php +++ b/search.php @@ -31,6 +31,9 @@ echo ""; } } + + $type = isset($_REQUEST["t"]) ? (int) $_REQUEST["t"] : 0; + echo ""; ?> @@ -47,7 +50,7 @@ $config = require "config.php"; require "misc/tools.php"; - $type = isset($_REQUEST["t"]) ? (int) $_REQUEST["t"] : 0; + $page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0; $start_time = microtime(true);