Browse Source

Properly test if the file requested (cover or book) exists and send a 404 if it doesn't. Should fix #70

master
Sébastien Lucas 10 years ago
parent
commit
f408a71f80
2 changed files with 26 additions and 1 deletions
  1. +1
    -0
      book.php
  2. +25
    -1
      fetch.php

+ 1
- 0
book.php View File

@@ -357,6 +357,7 @@ class Book extends Base {
else
{
$data = $this->getDataById ($idData);
if (!$data) return NULL;
$file = $data->name . "." . strtolower ($data->format);
}



+ 25
- 1
fetch.php View File

@@ -9,7 +9,14 @@
require_once ("config.php");
require_once ("book.php");
require_once ("data.php");

function notFound () {
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
header("Status: 404 Not Found");

$_SERVER['REDIRECT_STATUS'] = 404;
}
global $config;
$expires = 60*60*24*14;
header("Pragma: public");
@@ -26,6 +33,23 @@
{
$book = Book::getBookById($bookId);
}
if (!$book) {
notFound ();
return;
}
if ($book && ($type == "jpg" || empty ($config['calibre_internal_directory']))) {
if ($type == "jpg") {
$file = $book->getFilePath ($type);
} else {
$file = $book->getFilePath ($type, $idData);
}
if (!$file || !file_exists ($file)) {
notFound ();
return;
}
}
switch ($type)
{


Loading…
Cancel
Save