Another test

--HG--
extra : rebase_source : d6fd95a2c138efdb1901d7b09af47e20e6bf993e
This commit is contained in:
Sébastien Lucas 2013-08-29 08:43:11 +02:00
parent a51a276805
commit 881f76d87a
2 changed files with 9 additions and 5 deletions

View file

@ -9,21 +9,25 @@ function notFound () {
$_SERVER['REDIRECT_STATUS'] = 404; $_SERVER['REDIRECT_STATUS'] = 404;
} }
$book = new EPub ("c:/Temp/Alice.epub"); $book = new EPub ("c:/Temp/Phare.epub");
$book->initSpineComponent (); $book->initSpineComponent ();
$component = $_GET["comp"]; $component = $_GET["comp"];
$elementPath = NULL;
if (!empty ($_GET) && isset($_GET["path"]) && $_GET["path"] != "") {
$elementPath = $_GET["path"];
}
if (empty ($component)) { if (empty ($component)) {
notFound (); notFound ();
} }
try { try {
$data = $book->component ($component); $data = $book->component ($component, $elementPath);
$directory = dirname ($component); $directory = dirname ($component);
$data = preg_replace ("/src=[\"']([^:]*?)[\"']/", "src='epubfs.php?comp=$1'", $data); $data = preg_replace ("/src=[\"']([^:]*?)[\"']/", "src='epubfs.php?path=$1&comp=$component'", $data);
$data = preg_replace ("/href=[\"']([^:]*?)[\"']/", "href='epubfs.php?comp=$1'", $data); $data = preg_replace ("/href=[\"']([^:]*?)[\"']/", "href='epubfs.php?path=$1&comp=$component'", $data);
$data = preg_replace ("/\@import\s+[\"'](.*?)[\"'];/", "@import 'epubfs.php?comp={$directory}/$1';", $data); $data = preg_replace ("/\@import\s+[\"'](.*?)[\"'];/", "@import 'epubfs.php?comp={$directory}/$1';", $data);
header ("Content-Type: " . $book->componentContentType($component)); header ("Content-Type: " . $book->componentContentType($component));

View file

@ -6,7 +6,7 @@ require_once ("resources/php-epub-meta/epub.php");
header ("Content-Type: text/html;charset=utf-8"); header ("Content-Type: text/html;charset=utf-8");
$book = new EPub ("c:/Temp/Alice.epub"); $book = new EPub ("c:/Temp/Phare.epub");
$book->initSpineComponent (); $book->initSpineComponent ();
?> ?>