mirror of https://github.com/kurisufriend/mlPHP
parent
2f90368e2a
commit
27e99039a4
@ -0,0 +1,8 @@ |
|||||||
|
{ |
||||||
|
"name": "php instance testing", |
||||||
|
"test.cynic.moe": "localhost", |
||||||
|
"operator": "cynic", |
||||||
|
"icon": "", |
||||||
|
"description": "aaaathats4as", |
||||||
|
"version": "0.1" |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
[ |
||||||
|
{ |
||||||
|
"id": 1, |
||||||
|
"titles": ["testing!"], |
||||||
|
"authors": ["nipponeselandian"], |
||||||
|
"artists": ["nipponeselandian"], |
||||||
|
"last_updated": 1, |
||||||
|
"chapters": |
||||||
|
[ |
||||||
|
{ |
||||||
|
"id": 1, |
||||||
|
"manga_id": 1, |
||||||
|
"chapter_no": 1, |
||||||
|
"chapter_postfix": "", |
||||||
|
"ordinal": null, |
||||||
|
"title": "c001", |
||||||
|
"page_count": 6069, |
||||||
|
"version": 1, |
||||||
|
"language_id": "en", |
||||||
|
"group_id": null, |
||||||
|
"date_added": 1, |
||||||
|
"ipfs_link": "bafybeihnoou2av5w2bzmwkl6hi25scyzz6sjwdfqp4cwq2ikf6dfmev3ta", |
||||||
|
"scanlator": |
||||||
|
{ |
||||||
|
"id": 1, |
||||||
|
"name": "Yado Inn", |
||||||
|
"website": "https://yado-inn.com" |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
After Width: | Height: | Size: 103 KiB |
@ -0,0 +1,7 @@ |
|||||||
|
<?php |
||||||
|
header("Access-Control-Allow-Origin: *"); |
||||||
|
include_once("instance.php"); |
||||||
|
$ml = new ml(); |
||||||
|
$ml->run(); |
||||||
|
exit(); |
||||||
|
?> |
@ -0,0 +1,28 @@ |
|||||||
|
<?php |
||||||
|
include_once("routes.php"); |
||||||
|
class ml |
||||||
|
{ |
||||||
|
public $info; |
||||||
|
public $db; |
||||||
|
function __construct() |
||||||
|
{ |
||||||
|
$this->info = json_decode(file_get_contents("db/info.json"), $associative = true); |
||||||
|
$this->db = json_decode(file_get_contents("db/test.json"), $associative = true); |
||||||
|
} |
||||||
|
function getManga($id) |
||||||
|
{ |
||||||
|
foreach ($this->db as $manga) |
||||||
|
{ |
||||||
|
if ($manga["id"] == $id) |
||||||
|
{ |
||||||
|
return($manga); |
||||||
|
} |
||||||
|
} |
||||||
|
return(0); |
||||||
|
} |
||||||
|
function run() |
||||||
|
{ |
||||||
|
echo(route($_SERVER["PATH_INFO"], $this)); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,40 @@ |
|||||||
|
<?php |
||||||
|
include_once("instance.php"); |
||||||
|
function route($path, $ml) |
||||||
|
{ |
||||||
|
switch ($path) |
||||||
|
{ |
||||||
|
case "/info": |
||||||
|
return file_get_contents("db/info.json"); |
||||||
|
break; |
||||||
|
case "/manga/search": |
||||||
|
return file_get_contents("db/test.json"); |
||||||
|
break; |
||||||
|
case "/manga/from_id": |
||||||
|
if (!isset($_GET["id"])) |
||||||
|
{ |
||||||
|
return json_encode($ml->getManga($_GET["id"])); |
||||||
|
} |
||||||
|
http_response_code(404); |
||||||
|
break; |
||||||
|
case "/manga/get_chapters": |
||||||
|
if (isset($_GET["id"])) |
||||||
|
{ |
||||||
|
return json_encode($ml->getManga($_GET["id"])["chapters"]); |
||||||
|
} |
||||||
|
http_response_code(404); |
||||||
|
break; |
||||||
|
case "/manga/thumbnail": |
||||||
|
if (isset($_GET["id"])) |
||||||
|
{ |
||||||
|
header('Content-Type:image/webp'); |
||||||
|
readfile("db/thumb/".$_GET["id"].".webp"); |
||||||
|
return; |
||||||
|
} |
||||||
|
http_response_code(404); |
||||||
|
break; |
||||||
|
default: |
||||||
|
http_response_code(404); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
Loading…
Reference in new issue