diff options
author | lolcat <will@lolcat.ca> | 2025-08-11 01:55:15 +0000 |
---|---|---|
committer | lolcat <will@lolcat.ca> | 2025-08-11 01:55:15 +0000 |
commit | cdf958d29333d448f4521f4d2faa2592b58e9b27 (patch) | |
tree | 528f2a0ffa789a6f4279d9f54a4a2aaf391f390f /api/v1/news.php | |
download | shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.tar.gz shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.tar.bz2 shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.zip |
fix wikipedia crashgrafted
Diffstat (limited to 'api/v1/news.php')
-rw-r--r-- | api/v1/news.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/api/v1/news.php b/api/v1/news.php new file mode 100644 index 0000000..ab38781 --- /dev/null +++ b/api/v1/news.php @@ -0,0 +1,39 @@ +<?php + +chdir("../../"); +header("Content-Type: application/json"); + +include "data/config.php"; +if(config::API_ENABLED === false){ + + echo json_encode(["status" => "The server administrator disabled the API!"]); + return; +} + +include "lib/frontend.php"; +$frontend = new frontend(); + +/* + Captcha +*/ +include "lib/bot_protection.php"; +$null = null; +new bot_protection($null, $null, $null, "news", false); + +[$scraper, $filters] = $frontend->getscraperfilters( + "news", + isset($_GET["scraper"]) ? $_GET["scraper"] : null +); + +$get = $frontend->parsegetfilters($_GET, $filters); + +try{ + echo json_encode( + $scraper->news($get), + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_IGNORE + ); + +}catch(Exception $e){ + + echo json_encode(["status" => $e->getMessage()]); +} |