From edb71eb42ee67a88be510cb6cd61e17474e128c4 Mon Sep 17 00:00:00 2001 From: cynic Date: Tue, 11 May 2021 10:50:27 -0400 Subject: [PATCH] search options --- instance.php | 9 +++++++++ routes.php | 29 +++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/instance.php b/instance.php index 4fa3f97..2a01f48 100644 --- a/instance.php +++ b/instance.php @@ -20,6 +20,15 @@ class ml } return(0); } + function getAllMangaInfo() + { + $response = []; + foreach ($this->db["manga"] as $manga) + { + array_push($response, $manga["info"]); + } + return $response; + } function run() { echo(route($_SERVER["PATH_INFO"], $this)); diff --git a/routes.php b/routes.php index 0bbf5eb..751e359 100644 --- a/routes.php +++ b/routes.php @@ -1,5 +1,16 @@ db["manga"] as $manga) + foreach ($ml->getAllMangaInfo() as $manga) { - array_push($response, $manga["info"]); + if ((isset($_GET["title"]) && substrInArr($_GET["title"], $manga["titles"])) || + (isset($_GET["author"]) && in_array($_GET["author"], $manga["authors"])) || + (isset($_GET["artist"]) && in_array($_GET["artist"], $manga["artists"])) || + (isset($_GET["genre"]) && in_array($_GET["genre"], $manga["genres"])) || + (isset($_GET["sort"]))) + { + array_push($response, $manga); + } } return json_encode($response); break; @@ -39,6 +57,13 @@ function route($path, $ml) } http_response_code(400); break; + case "/manga/people": + return json_encode($ml->db["people"]); + break; + case "/manga/scanlators": + return json_encode($ml->db["scanlators"]); + break; + default: http_response_code(404); }