cynic 4 years ago committed by GitHub
parent 2f90368e2a
commit 27e99039a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      db/info.json
  2. 32
      db/test.json
  3. BIN
      db/thumb/1.webp
  4. 7
      index.php
  5. 28
      instance.php
  6. 40
      routes.php

@ -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"
}
}
]
}
]

Binary file not shown.

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…
Cancel
Save