diff options
Diffstat (limited to 'classes/Handler/GetinfoHandler.php')
| -rw-r--r-- | classes/Handler/GetinfoHandler.php | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/classes/Handler/GetinfoHandler.php b/classes/Handler/GetinfoHandler.php deleted file mode 100644 index ee4a69a..0000000 --- a/classes/Handler/GetinfoHandler.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Handler; - -use AuthRequired; -use Config; -use Request; -use RequestHandlerInterface; -use Response; -use PDO; -use Sanitizer; - -class GetinfoHandler implements RequestHandlerInterface, AuthRequired -{ - public function handle(Request $request): Response - { - $id = (int) $request->getAttribute('id'); - $caldb = new PDO('sqlite:' . Config::get(Config::CALIBRE_DB)); - - $sth = $caldb->prepare("SELECT books.*, s.name AS series_name, - (SELECT text FROM comments WHERE book = books.id) AS comment, - (SELECT id FROM data WHERE book = books.id AND format = 'EPUB' LIMIT 1) AS epub_id FROM books - LEFT JOIN books_series_link AS bsl ON (bsl.book = books.id) - LEFT JOIN series AS s ON (bsl.series = s.id) - WHERE books.id = ?"); - $sth->execute([$id]); - - if ($row = $sth->fetch()) { - $row['comment'] = Sanitizer::sanitize($row['comment'] ?? ""); - - return (new Response())->withBody(json_encode($row)); - } - - return (new Response()) - ->withStatus(404) - ->withBody(json_encode(["error" => "Not found."])); - } -} |
