diff --git a/api.php b/api.php index b582e0e..374800f 100644 --- a/api.php +++ b/api.php @@ -4,11 +4,11 @@ if (!isset($_REQUEST["q"])) { - echo "
Example API request: ./api.php?q=gentoo&p=2&type=0
+ echo "Example API request: ./api.php?q=gentoo&p=2&t=0
\"q\" is the keyword
\"p\" is the result page (the first page is 0)
-\"type\" is the search type (0=text, 1=image, 2=video, 3=torrent)
+\"t\" is the search type (0=text, 1=image, 2=video, 3=torrent)
The results are going to be in JSON format.
The API supports both POST and GET requests.
"; @@ -19,7 +19,7 @@ $query = $_REQUEST["q"]; $query_encoded = urlencode($query); $page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0; - $type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0; + $type = isset($_REQUEST["t"]) ? (int) $_REQUEST["t"] : 0; $results = array(); diff --git a/config.php.example b/config.php.example index c43bb25..75e9717 100644 --- a/config.php.example +++ b/config.php.example @@ -39,7 +39,7 @@ // CURLOPT_PROXYTYPE => CURLPROXY_HTTP, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", - CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_PROTOCOLS => CURLPROTO_HTTPS | CURLPROTO_HTTP, diff --git a/engines/google/text.php b/engines/google/text.php index 67b4e3b..5fb33a7 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -14,9 +14,24 @@ return 1; } else if (strpos($query_lower, "mean") && count($split_query) >= 2) // definition + { return 2; + } + else if (strpos($query_lower, "my") !== false) + { + if (strpos($query_lower, "ip")) + { + return 4; + } + else if (strpos($query_lower, "user agent") || strpos($query_lower, "ua")) + { + return 5; + } + } else if (3 > count(explode(" ", $query))) // wikipedia + { return 3; + } return 0; } @@ -68,6 +83,7 @@ curl_multi_exec($mh, $running); } while ($running); + if ($special_search != 0) { $special_result = null; @@ -86,6 +102,14 @@ 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: + require "engines/special/user_agent.php"; + $special_result = user_agent_result(); + break; } if ($special_result != null) @@ -145,7 +169,8 @@ echo "