2013-05-14 22:35:43 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once ("resources/php-epub-meta/epub.php");
|
|
|
|
|
|
|
|
function notFound () {
|
|
|
|
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
|
|
|
header("Status: 404 Not Found");
|
|
|
|
|
|
|
|
$_SERVER['REDIRECT_STATUS'] = 404;
|
|
|
|
}
|
|
|
|
|
2013-08-29 09:43:11 +03:00
|
|
|
$book = new EPub ("c:/Temp/Phare.epub");
|
2013-05-14 22:35:43 +03:00
|
|
|
$book->initSpineComponent ();
|
|
|
|
|
|
|
|
$component = $_GET["comp"];
|
2013-08-29 09:43:11 +03:00
|
|
|
$elementPath = NULL;
|
|
|
|
if (!empty ($_GET) && isset($_GET["path"]) && $_GET["path"] != "") {
|
|
|
|
$elementPath = $_GET["path"];
|
|
|
|
}
|
2013-05-14 22:35:43 +03:00
|
|
|
|
|
|
|
if (empty ($component)) {
|
|
|
|
notFound ();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2013-08-29 09:43:11 +03:00
|
|
|
$data = $book->component ($component, $elementPath);
|
2013-05-14 22:35:43 +03:00
|
|
|
$directory = dirname ($component);
|
|
|
|
|
2013-08-29 09:43:11 +03:00
|
|
|
$data = preg_replace ("/src=[\"']([^:]*?)[\"']/", "src='epubfs.php?path=$1&comp=$component'", $data);
|
|
|
|
$data = preg_replace ("/href=[\"']([^:]*?)[\"']/", "href='epubfs.php?path=$1&comp=$component'", $data);
|
2013-05-14 22:35:43 +03:00
|
|
|
$data = preg_replace ("/\@import\s+[\"'](.*?)[\"'];/", "@import 'epubfs.php?comp={$directory}/$1';", $data);
|
|
|
|
|
|
|
|
header ("Content-Type: " . $book->componentContentType($component));
|
|
|
|
echo $data;
|
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
notFound ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|