From 785452873f0ee0a27fc157b482b7551560f0282d Mon Sep 17 00:00:00 2001 From: lolcat Date: Tue, 7 Nov 2023 08:04:56 -0500 Subject: fix typo --- api/v1/ac.php | 91 ++++++++++++++++++++++++++++++++----------------------- api/v1/images.php | 8 ++++- api/v1/music.php | 8 ++++- api/v1/news.php | 8 ++++- api/v1/videos.php | 8 ++++- api/v1/web.php | 16 ++++++++-- 6 files changed, 95 insertions(+), 44 deletions(-) (limited to 'api/v1') diff --git a/api/v1/ac.php b/api/v1/ac.php index 3ee1481..b1ec7dd 100644 --- a/api/v1/ac.php +++ b/api/v1/ac.php @@ -1,5 +1,6 @@ "https://api.yep.com/ac/?query={searchTerms}", "marginalia" => "https://search.marginalia.nu/suggest/?partial={searchTerms}", "yt" => "https://suggestqueries-clients6.youtube.com/complete/search?client=youtube&q={searchTerms}", - "sc" => "https://api-v2.soundcloud.com/search/queries?q={searchTerms}&client_id=ArYppSEotE3YiXCO4Nsgid2LLqJutiww&limit=10&offset=0&linked_partitioning=1&app_version=1693487844&app_locale=en" + "sc" => "https://api-v2.soundcloud.com/search/queries?q={searchTerms}&client_id=" . config::SC_CLIENT_TOKEN . "&limit=10&offset=0&linked_partitioning=1&app_version=1693487844&app_locale=en" ]; /* @@ -107,7 +108,8 @@ class autocomplete{ [ $_GET["s"], $json - ] + ], + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); break; @@ -132,7 +134,8 @@ class autocomplete{ [ $_GET["s"], $json - ] + ], + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); break; @@ -150,7 +153,8 @@ class autocomplete{ [ $_GET["s"], $json - ] + ], + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); break; @@ -162,7 +166,8 @@ class autocomplete{ [ $_GET["s"], $json[1] // ensure it contains valid key 0 - ] + ], + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); break; } @@ -170,45 +175,54 @@ class autocomplete{ private function get($url, $query){ - $curlproc = curl_init(); - - $url = str_replace("{searchTerms}", urlencode($query), $url); - - curl_setopt($curlproc, CURLOPT_URL, $url); - - curl_setopt($curlproc, CURLOPT_ENCODING, ""); // default encoding - curl_setopt($curlproc, CURLOPT_HTTPHEADER, - ["User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0", - "Accept: application/json, text/javascript, */*; q=0.01", - "Accept-Language: en-US,en;q=0.5", - "Accept-Encoding: gzip", - "DNT: 1", - "Connection: keep-alive", - "Sec-Fetch-Dest: empty", - "Sec-Fetch-Mode: cors", - "Sec-Fetch-Site: same-site"] - ); - - curl_setopt($curlproc, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curlproc, CURLOPT_SSL_VERIFYHOST, 2); - curl_setopt($curlproc, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($curlproc, CURLOPT_CONNECTTIMEOUT, 30); - curl_setopt($curlproc, CURLOPT_TIMEOUT, 30); - - $data = curl_exec($curlproc); + try{ + $curlproc = curl_init(); + + $url = str_replace("{searchTerms}", urlencode($query), $url); + + curl_setopt($curlproc, CURLOPT_URL, $url); + + curl_setopt($curlproc, CURLOPT_ENCODING, ""); // default encoding + curl_setopt($curlproc, CURLOPT_HTTPHEADER, + ["User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0", + "Accept: application/json, text/javascript, */*; q=0.01", + "Accept-Language: en-US,en;q=0.5", + "Accept-Encoding: gzip", + "DNT: 1", + "Connection: keep-alive", + "Sec-Fetch-Dest: empty", + "Sec-Fetch-Mode: cors", + "Sec-Fetch-Site: same-site"] + ); + + curl_setopt($curlproc, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlproc, CURLOPT_SSL_VERIFYHOST, 2); + curl_setopt($curlproc, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curlproc, CURLOPT_CONNECTTIMEOUT, 30); + curl_setopt($curlproc, CURLOPT_TIMEOUT, 30); + + $data = curl_exec($curlproc); + + if(curl_errno($curlproc)){ + + throw new Exception(curl_error($curlproc)); + } + + curl_close($curlproc); + return $data; - if(curl_errno($curlproc)){ + }catch(Exception $error){ - throw new Exception(curl_error($curlproc)); + do404("Curl error: " . $error->getMessage()); } - - curl_close($curlproc); - return $data; } private function do404($error){ - echo json_encode(["error" => $error]); + echo json_encode( + ["error" => $error], + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES + ); die(); } @@ -218,7 +232,8 @@ class autocomplete{ [ $_GET["s"], [] - ] + ], + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); die(); } diff --git a/api/v1/images.php b/api/v1/images.php index 34510b4..3072b05 100644 --- a/api/v1/images.php +++ b/api/v1/images.php @@ -1,8 +1,14 @@ "The server administrator disabled the API!"]); + return; +} include "lib/frontend.php"; $frontend = new frontend(); diff --git a/api/v1/music.php b/api/v1/music.php index 3c30953..409e6f0 100644 --- a/api/v1/music.php +++ b/api/v1/music.php @@ -1,8 +1,14 @@ "The server administrator disabled the API!"]); + return; +} include "lib/frontend.php"; $frontend = new frontend(); diff --git a/api/v1/news.php b/api/v1/news.php index bd8678f..ddfd72a 100644 --- a/api/v1/news.php +++ b/api/v1/news.php @@ -1,8 +1,14 @@ "The server administrator disabled the API!"]); + return; +} include "lib/frontend.php"; $frontend = new frontend(); diff --git a/api/v1/videos.php b/api/v1/videos.php index a42b29b..dab29af 100644 --- a/api/v1/videos.php +++ b/api/v1/videos.php @@ -1,8 +1,14 @@ "The server administrator disabled the API!"]); + return; +} include "lib/frontend.php"; $frontend = new frontend(); diff --git a/api/v1/web.php b/api/v1/web.php index 61bf82a..dc1a7cc 100644 --- a/api/v1/web.php +++ b/api/v1/web.php @@ -1,8 +1,14 @@ "The server administrator disabled the API!"]); + return; +} include "lib/frontend.php"; $frontend = new frontend(); @@ -21,7 +27,13 @@ new captcha($null, $null, $null, "web", false); $get = $frontend->parsegetfilters($_GET, $filters); -if(!isset($_GET["extendedsearch"])){ +if( + isset($_GET["extendedsearch"]) && + $_GET["extendedsearch"] == "yes" +){ + + $get["extendedsearch"] = "yes"; +}else{ $get["extendedsearch"] = "no"; } -- cgit v1.2.3