/** * @inheritdoc */ public function __construct($bookPath, \CakeRequest $cakeRequest) { $this->bookPath = $bookPath; $this->cakeRequest = $cakeRequest; \App::import('Vendor', 'EPub', array('file' => 'php-epub-meta' . DS . 'epub.php')); $this->epub = new \EPub($this->bookPath); $this->epub->initSpineComponent(); isset($this->cakeRequest->query['comp']) && $this->setVisibleContent(); }
$data = preg_replace_callback("/(href=)[\"']([^:]*?)[\"']/", $callback, $data); $data = preg_replace_callback("/(\\@import\\s+)[\"'](.*?)[\"'];/", $callback, $data); $data = preg_replace_callback("/(src\\s*:\\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; header("Pragma: public"); header("Cache-Control: maxage=" . $expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); header("Content-Type: " . $book->componentContentType($component)); echo $data; } catch (Exception $e) { error_log($e);