|
|
|
@ -1,5 +1,16 @@ |
|
|
|
|
<?php |
|
|
|
|
include_once("instance.php"); |
|
|
|
|
function substrInArr($needle, $haystack) |
|
|
|
|
{ |
|
|
|
|
foreach ($haystack as $str) |
|
|
|
|
{ |
|
|
|
|
if (strpos($str, $needle)) |
|
|
|
|
{ |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
function route($path, $ml) |
|
|
|
|
{ |
|
|
|
|
header('Content-Type:application/json'); |
|
|
|
@ -10,9 +21,16 @@ function route($path, $ml) |
|
|
|
|
break; |
|
|
|
|
case "/manga/search": |
|
|
|
|
$response = []; |
|
|
|
|
foreach ($ml->db["manga"] as $manga) |
|
|
|
|
foreach ($ml->getAllMangaInfo() as $manga) |
|
|
|
|
{ |
|
|
|
|
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["info"]); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|