Reorganize a little the epubfs file
This commit is contained in:
parent
438b0dbc29
commit
a45d45f0ef
42
epubfs.php
42
epubfs.php
|
@ -12,23 +12,7 @@ function notFound () {
|
||||||
$_SERVER['REDIRECT_STATUS'] = 404;
|
$_SERVER['REDIRECT_STATUS'] = 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
$idData = getURLParam ("data", NULL);
|
function getComponentContent ($book, $component, $add) {
|
||||||
$add = "data=$idData&";
|
|
||||||
if (!is_null (GetUrlParam (DB))) $add .= DB . "=" . GetUrlParam (DB) . "&";
|
|
||||||
$myBook = Book::getBookByDataId($idData);
|
|
||||||
|
|
||||||
$book = new EPub ($myBook->getFilePath ("EPUB", $idData));
|
|
||||||
|
|
||||||
$book->initSpineComponent ();
|
|
||||||
|
|
||||||
if (!isset ($_GET["comp"])) {
|
|
||||||
notFound ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$component = $_GET["comp"];
|
|
||||||
|
|
||||||
try {
|
|
||||||
$data = $book->component ($component);
|
$data = $book->component ($component);
|
||||||
$directory = dirname ($component);
|
$directory = dirname ($component);
|
||||||
|
|
||||||
|
@ -61,6 +45,30 @@ try {
|
||||||
$data = preg_replace_callback ("/(\@import\s+)[\"'](.*?)[\"'];/", $callback, $data);
|
$data = preg_replace_callback ("/(\@import\s+)[\"'](.*?)[\"'];/", $callback, $data);
|
||||||
$data = preg_replace_callback ("/(src:\s*url\()(.*?)\)/", $callback, $data);
|
$data = preg_replace_callback ("/(src:\s*url\()(.*?)\)/", $callback, $data);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (php_sapi_name() === 'cli') { return; }
|
||||||
|
|
||||||
|
$idData = getURLParam ("data", NULL);
|
||||||
|
$add = "data=$idData&";
|
||||||
|
if (!is_null (GetUrlParam (DB))) $add .= DB . "=" . GetUrlParam (DB) . "&";
|
||||||
|
$myBook = Book::getBookByDataId($idData);
|
||||||
|
|
||||||
|
$book = new EPub ($myBook->getFilePath ("EPUB", $idData));
|
||||||
|
|
||||||
|
$book->initSpineComponent ();
|
||||||
|
|
||||||
|
if (!isset ($_GET["comp"])) {
|
||||||
|
notFound ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$component = $_GET["comp"];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$data = getComponentContent ($book, $component, $add);
|
||||||
|
|
||||||
$expires = 60*60*24*14;
|
$expires = 60*60*24*14;
|
||||||
header("Pragma: public");
|
header("Pragma: public");
|
||||||
header("Cache-Control: maxage=".$expires);
|
header("Cache-Control: maxage=".$expires);
|
||||||
|
|
Loading…
Reference in a new issue