From 3cffac479ee998bfdac6821d1ffe3c3ec46528b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 14 May 2013 21:35:43 +0200 Subject: [PATCH] Add an handler to access epub internal files. --HG-- extra : rebase_source : 31f7f77fba14f09117d08dd1228da0a8221f8747 --- epubfs.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 epubfs.php diff --git a/epubfs.php b/epubfs.php new file mode 100644 index 0000000..9a5ea3c --- /dev/null +++ b/epubfs.php @@ -0,0 +1,37 @@ +initSpineComponent (); + +$component = $_GET["comp"]; + +if (empty ($component)) { + notFound (); +} + +try { + $data = $book->component ($component); + $directory = dirname ($component); + + $data = preg_replace ("/src=[\"']([^:]*?)[\"']/", "src='epubfs.php?comp=$1'", $data); + $data = preg_replace ("/href=[\"']([^:]*?)[\"']/", "href='epubfs.php?comp=$1'", $data); + $data = preg_replace ("/\@import\s+[\"'](.*?)[\"'];/", "@import 'epubfs.php?comp={$directory}/$1';", $data); + + header ("Content-Type: " . $book->componentContentType($component)); + echo $data; +} +catch (Exception $e) { + notFound (); +} + + +?> \ No newline at end of file