about summary refs log tree commit diff stats
path: root/classes/Handler/CoverHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Handler/CoverHandler.php')
-rw-r--r--classes/Handler/CoverHandler.php50
1 files changed, 25 insertions, 25 deletions
diff --git a/classes/Handler/CoverHandler.php b/classes/Handler/CoverHandler.php
index d219f84..d4c0a2c 100644
--- a/classes/Handler/CoverHandler.php
+++ b/classes/Handler/CoverHandler.php
@@ -11,32 +11,32 @@ use PDO;
 
 class CoverHandler implements RequestHandlerInterface, AuthRequired
 {
-    public function handle(Request $request): Response
-    {
-        $id = (int) $request->getAttribute('id');
-        $db = new PDO('sqlite:' . Config::get(Config::CALIBRE_DB));
-        $sth = $db->prepare("SELECT has_cover, path FROM books WHERE id = ?");
-        $sth->execute([$id]);
+	public function handle(Request $request): Response
+	{
+		$id = (int) $request->getAttribute('id');
+		$db = new PDO('sqlite:' . Config::get(Config::CALIBRE_DB));
+		$sth = $db->prepare("SELECT has_cover, path FROM books WHERE id = ?");
+		$sth->execute([$id]);
 
-        while ($line = $sth->fetch()) {
-            $filename = Config::get(Config::BOOKS_DIR) . "/" . $line["path"] . "/" . "cover.jpg";
+		while ($line = $sth->fetch()) {
+			$filename = Config::get(Config::BOOKS_DIR) . "/" . $line["path"] . "/" . "cover.jpg";
 
-            if (file_exists($filename)) {
-                return (new Response())
-                    ->withHeader("Content-type", mime_content_type($filename))
-                    ->withHeader('Cache-control', "max-age=" . STATIC_EXPIRES)
-                    ->withHeader("Expires", gmdate("D, d M Y H:i:s \G\M\T", time()+STATIC_EXPIRES))
-                    ->withHeader("Last-Modified", gmdate("D, d M Y H:i:s \G\M\T", filemtime($filename)))
-                    ->withBody(readfile($filename) ?: '');
-            } else {
-                return (new Response())
-                    ->withStatus(404)
-                    ->withBody("File not found.");
-            }
-        }
+			if (file_exists($filename)) {
+				return (new Response())
+					->withHeader("Content-type", mime_content_type($filename))
+					->withHeader('Cache-control', "max-age=" . STATIC_EXPIRES)
+					->withHeader("Expires", gmdate("D, d M Y H:i:s \G\M\T", time()+STATIC_EXPIRES))
+					->withHeader("Last-Modified", gmdate("D, d M Y H:i:s \G\M\T", filemtime($filename)))
+					->withBody(readfile($filename) ?: '');
+			} else {
+				return (new Response())
+					->withStatus(404)
+					->withBody("File not found.");
+			}
+		}
 
-        return (new Response())
-            ->withStatus(404)
-            ->withBody("File not found.");
-    }
+		return (new Response())
+			->withStatus(404)
+			->withBody("File not found.");
+	}
 }