/** * main -- main logic flow. * script checks for defined tables and then exports data and schema as demanded * * @return void */ public function main() { global $argv; $file = $this->getArgument('FILE'); $paramdir = $this->getArgument('DIRECTORY'); $dir = $paramdir ? $paramdir : BASEDIR; if ($file) { $book = new ebook($file); $book->file = $book->cleanupFile($file, $dir); $lib = new library(); $lib->insertBook($book); } else { echo "No ebook given.\n"; } }
function launch() { global $interface; global $configArray; global $user; $id = $_REQUEST['id']; $interface->assign('id', $id); $itemId = $_REQUEST['itemId']; $interface->assign('itemId', $itemId); $file = $_REQUEST['file']; $interface->assign('file', $file); $recordDriver = new RestrictedEContentDriver($id); $isAudio = false; if (!$recordDriver->isValid()) { $interface->setTemplate('../Record/invalidRecord.tpl'); $interface->display('layout.tpl'); die; } else { $interface->assign('recordDriver', $recordDriver); $itemId = $_REQUEST['itemId']; $errorOccurred = false; if ($user == false) { $interface->assign('errorMessage', 'Sorry, you must be logged in to view this title.'); $errorOccurred = true; $interface->assign('showLogin', true); } else { if (!$recordDriver->isCheckedOut($itemId)) { $interface->assign('errorMessage', "You must checkout this title before you view it, please <a href='{$configArray['Site']['path']}/PublicEContent/{$id}/Checkout'>click here</a> to checkout the title."); $errorOccurred = true; $interface->assign('showLogin', false); } else { require_once ROOT_DIR . '/sys/eContent/EContentRecord.php'; $filename = $_REQUEST['file']; $bookFile = $configArray['EContent']['library'] . '/' . $filename; if (file_exists($bookFile)) { //Check the database to see if there is an existing title $fileExtension = ''; if (strpos($bookFile, '.') !== FALSE) { $fileExtension = substr($bookFile, strrpos($bookFile, '.') + 1); } //Record that the title is being viewed. require_once ROOT_DIR . '/sys/eContent/EContentHistoryEntry.php'; $entry = new EContentHistoryEntry(); $entry->userId = $user->id; $entry->recordId = $id; $entry->itemId = $itemId; $entry->action = 'Read Online'; //Open date will be filled out automatically. $entry->insert(); if ($fileExtension == 'epub') { require_once ROOT_DIR . '/sys/eReader/ebook.php'; $ebook = new ebook($bookFile); if ($ebook->readErrorOccurred()) { $errorOccurred = true; $interface->assign('errorMessage', $ebook->readError()); } else { $spineInfo = $ebook->getSpine(); $toc = $ebook->getTOC(); $interface->assign('spineData', $spineInfo); $interface->assign('contents', $toc); $interface->assign('bookCreator', $ebook->getDcCreator()); //Load a translation map to translate locations into ids $manifest = array(); for ($i = 0; $i < $ebook->getManifestSize(); $i++) { $manifestId = $ebook->getManifestItem($i, 'id'); $manifestHref = $ebook->getManifestItem($i, 'href'); $manifestType = $ebook->getManifestItem($i, 'type'); $manifest[$manifestHref] = $manifestId; } $interface->assign('manifest', $manifest); $interface->assign('bookTitle', $ebook->getTitle()); $errorOccurred = false; } } elseif ($fileExtension == 'txt') { header("Content-Type: text/plain;\n"); header('Content-Length: ' . filesize($bookFile)); readfile($bookFile); exit; } elseif (is_dir($bookFile)) { //A folder of mp3 files? //Display information so patron can listen to the recording. //Table of contents is based on the actual files uploaded. $isAudio = true; $dirHnd = opendir($bookFile); $mp3Files = array(); while (false !== ($file = readdir($dirHnd))) { if (preg_match('/^.*?\\.mp3$/i', $file)) { $mp3Files[] = preg_replace('/\\.mp3/i', '', $file); } } $files = readdir($dirHnd); closedir($dirHnd); //Sort the mp3 files by name. sort($mp3Files); $interface->assign('mp3Filenames', $mp3Files); } } else { $errorOccurred = true; $interface->assign('errorMessage', 'Sorry, we could not find that title in our online library.'); } } $interface->assign('errorOccurred', $errorOccurred); if ($isAudio) { $interface->display('EcontentRecord/viewer-mp3.tpl'); } else { $interface->display('EcontentRecord/viewer-custom.tpl'); } } } }
function launch() { global $interface; global $configArray; $id = $_REQUEST['id']; $interface->assign('id', $id); $item = $_REQUEST['item']; $interface->assign('item', $item); $viewer = 'custom'; $errorOccurred = false; if ($this->user == false) { $interface->assign('errorMessage', 'User is not logged in.'); $errorOccurred = true; $interface->assign('showLogin', true); } else { require_once ROOT_DIR . '/sys/eContent/EContentRecord.php'; $eContentRecord = new EContentRecord(); $eContentRecord->id = $id; if ($eContentRecord->find(true)) { //Check the database to see if there is an existing title require_once ROOT_DIR . '/sys/eContent/EContentItem.php'; $eContentItem = new EContentItem(); $eContentItem->id = $_REQUEST['item']; if ($eContentItem->find(true)) { $bookFile = null; $libraryPath = $configArray['EContent']['library']; if ($eContentItem->item_type == 'mp3') { $bookFile = "{$libraryPath}/{$eContentItem->folder}"; } else { $bookFile = "{$libraryPath}/{$eContentItem->filename}"; } if (!file_exists($bookFile)) { $bookFile = null; } } } else { $errorOccurred = true; $interface->assign('errorMessage', 'Could not find the selected title.'); } if (file_exists($bookFile) && $errorOccurred == false) { require_once ROOT_DIR . '/Drivers/EContentDriver.php'; $driver = new EContentDriver(); //Check to see if the user has access to the title. $isCheckedOut = $driver->isRecordCheckedOutToUser($id); if (!$isCheckedOut) { $errorOccurred = true; $interface->assign('errorMessage', "Sorry, you do not have access to that title, please <a href='{$configArray['Site']['path']}/Record/{$id}/Hold'>place a hold</a> on the title and you will be notified when it is ready for pickup."); } if (!$errorOccurred) { //Record that the e-pub file is being opened. if (strcasecmp($eContentItem->item_type, 'epub') === 0) { $driver->recordEContentAction($id, "Read Online", $eContentRecord->accessType); require_once ROOT_DIR . '/sys/eReader/ebook.php'; $ebook = new ebook($bookFile); if ($ebook->readErrorOccurred()) { $errorOccurred = true; $interface->assign('errorMessage', $ebook->readError()); } else { $spineInfo = $ebook->getSpine(); $toc = $ebook->getTOC(); if ($viewer == 'monocle') { $spineData = addslashes(json_encode($spineInfo)); $interface->assign('spineData', $spineData); $contents = addslashes(json_encode($toc)); $interface->assign('contents', $contents); $metaData = addslashes(json_encode(array("title" => $ebook->getTitle(), "creator" => $ebook->getDcCreator()))); $interface->assign('metaData', $metaData); } else { $interface->assign('spineData', $spineInfo); $interface->assign('contents', $toc); $interface->assign('bookCreator', $ebook->getDcCreator()); //Load a translation map to translate locations into ids $manifest = array(); for ($i = 0; $i < $ebook->getManifestSize(); $i++) { $manifestId = $ebook->getManifestItem($i, 'id'); $manifestHref = $ebook->getManifestItem($i, 'href'); $manifestType = $ebook->getManifestItem($i, 'type'); $manifest[$manifestHref] = $manifestId; } $interface->assign('manifest', $manifest); } $interface->assign('bookTitle', $ebook->getTitle()); $errorOccurred = false; } } else { if ($eContentItem->item_type == 'mp3') { //Display information so patron can listen to the recording. //Table of contents is based on the actual files uploaded. $viewer = 'mp3'; $dirHnd = opendir($bookFile); $mp3Files = array(); while (false !== ($file = readdir($dirHnd))) { if (preg_match('/^.*?\\.mp3$/i', $file)) { $mp3Files[] = preg_replace('/\\.mp3/i', '', $file); } } $files = readdir($dirHnd); closedir($dirHnd); //Sort the mp3 files by name. sort($mp3Files); $interface->assign('mp3Filenames', $mp3Files); } else { $errorOccurred = true; $interface->assign('errorMessage', "Sorry, we could not find a viewer for that type of item, please contact support."); } } } } else { $errorOccurred = true; $interface->assign('errorMessage', 'Sorry, we could not find that book in our online library.'); } } $interface->assign('errorOccurred', $errorOccurred); if ($viewer == 'mp3') { $interface->display('EcontentRecord/viewer-mp3.tpl'); } else { $interface->display('EcontentRecord/viewer-custom.tpl'); } }
/** * Downloads an eContent file to the user's hard drive for offline usage. * * Parameters: * <ul> * <li>username - The barcode of the user. Can be truncated to the last 7 or 9 digits.</li> * <li>password - The pin number for the user. </li> * <li>recordId - The id of the record within the eContent database.</li> * <li>itemId - The id of the item attached to the record that should be downloaded.</li> * </ul> * * Returns: * false if the username or password were incorrect or the item cannot be downloaded * or the contents of the file that can be streamed directly to the client. * * @author Mark Noble <*****@*****.**> */ function downloadEContentFile() { global $configArray; $username = $_REQUEST['username']; $password = $_REQUEST['password']; $recordId = $_REQUEST['recordId']; //Trim off econtentRecord from the front of the id if provided if (preg_match('/econtentRecord\\d+/i', $recordId)) { $recordId = substr($recordId, 14); } $itemId = $_REQUEST['itemId']; global $user; $user = UserAccount::validateAccount($username, $password); if ($user && !PEAR_Singleton::isError($user)) { require_once ROOT_DIR . '/Drivers/EContentDriver.php'; $driver = new EContentDriver(); $eContentRecord = new EContentRecord(); $eContentRecord->id = $recordId; if (!$eContentRecord->find(true)) { return array('success' => false, 'message' => 'Could not find the record in the database.'); } //Check to see if the user has access to the title. if (!$driver->isRecordCheckedOutToUser($recordId)) { return array('success' => false, 'message' => 'The record is not checked out to you.'); } $eContentItem = new EContentItem(); $eContentItem->recordId = $recordId; $eContentItem->id = $itemId; if (!$eContentItem->find(true)) { return array('success' => false, 'message' => 'Could not find the item in the database.'); } $driver->recordEContentAction($recordId, 'Download', $eContentRecord->accessType); $libraryPath = $configArray['EContent']['library']; if (isset($eContentItem->filename) && strlen($eContentItem->filename) > 0) { $bookFile = "{$libraryPath}/{$eContentItem->filename}"; } else { $bookFile = "{$libraryPath}/{$eContentItem->folder}"; } if (strcasecmp($eContentItem->item_type, 'epub') == 0) { require_once ROOT_DIR . '/sys/eReader/ebook.php'; $ebook = new ebook($bookFile); //Return the contents of the epub file header("Content-Type: application/epub+zip;\n"); header('Content-Length: ' . filesize($bookFile)); header('Content-Description: ' . $ebook->getTitle()); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); echo readfile($bookFile); exit; } else { if (strcasecmp($eContentItem->item_type, 'pdf') == 0) { header("Content-Type: application/pdf;\n"); header('Content-Length: ' . filesize($bookFile)); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); echo readfile($bookFile); exit; } else { if (strcasecmp($eContentItem->item_type, 'kindle') == 0) { header('Content-Length: ' . filesize($bookFile)); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); echo readfile($bookFile); exit; } else { if (strcasecmp($eContentItem->item_type, 'plucker') == 0) { header('Content-Length: ' . filesize($bookFile)); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); echo readfile($bookFile); exit; } } } } } else { return array('success' => false, 'message' => 'Login unsuccessful'); } }
/** * Download a file from the server so a user can use it locally. **/ function launch() { global $interface; global $configArray; global $user; $id = $_REQUEST['id']; $interface->assign('id', $id); $recordDriver = new PublicEContentDriver($id); if (!$recordDriver->isValid()) { $interface->setTemplate('../Record/invalidRecord.tpl'); $interface->display('layout.tpl'); die; } else { $interface->assign('recordDriver', $recordDriver); $itemId = $_REQUEST['itemId']; if ($user == false) { $interface->assign('errorMessage', 'Sorry, you must be logged in to download this title.'); $errorOccurred = true; $interface->assign('showLogin', true); } else { if (!$recordDriver->isCheckedOut($itemId)) { $interface->assign('errorMessage', "You must checkout this title before you download it, please <a href='{$configArray['Site']['path']}/PublicEContent/{$id}/Checkout'>click here</a> to checkout the title."); $errorOccurred = true; $interface->assign('showLogin', false); } else { $errorOccurred = false; $filename = $_REQUEST['file']; $bookFile = $configArray['EContent']['library'] . '/' . $filename; if (file_exists($bookFile)) { global $user; //Record that the e-pub file is being downloaded. require_once ROOT_DIR . '/sys/eContent/EContentHistoryEntry.php'; $entry = new EContentHistoryEntry(); $entry->userId = $user->id; $entry->recordId = $id; $entry->itemId = $itemId; $entry->action = 'Download'; //Open date will be filled out automatically. $entry->insert(); $fileExtension = ''; if (strpos($bookFile, '.') !== FALSE) { $fileExtension = substr($bookFile, strrpos($bookFile, '.') + 1); } if (strcasecmp($fileExtension, 'epub') == 0) { require_once ROOT_DIR . '/sys/eReader/ebook.php'; $ebook = new ebook($bookFile); //Return the contents of the epub file header("Content-Type: application/epub+zip;\n"); //header('Content-Length: ' . filesize($bookFile)); header('Content-Description: ' . $ebook->getTitle()); //header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); die; } else { if (strcasecmp($fileExtension, 'pdf') == 0) { header("Content-Type: application/pdf;\n"); header('Content-Length: ' . filesize($bookFile)); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); exit; } else { if (strcasecmp($fileExtension, 'mobi') == 0) { header('Content-Length: ' . filesize($bookFile)); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); exit; } else { if (strcasecmp($fileExtension, 'pdb') == 0) { header('Content-Length: ' . filesize($bookFile)); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); exit; } else { if (strcasecmp($fileExtension, 'txt') == 0) { header("Content-Type: text/plain;\n"); header('Content-Length: ' . filesize($bookFile)); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); exit; } else { if (strcasecmp($fileExtension, 'mp3') == 0) { $id = $_REQUEST['id']; $interface->assign('id', $id); $item = $_REQUEST['item']; $interface->assign('item', $item); //Get all of the MP3 files that $dirHnd = opendir($bookFile); $mp3Files = array(); while (false !== ($file = readdir($dirHnd))) { if (preg_match('/^.*?\\.mp3$/i', $file)) { $mp3Files[] = array('name' => preg_replace('/\\.mp3/i', '', $file), 'size' => filesize($bookFile . '/' . $file)); } } $files = readdir($dirHnd); closedir($dirHnd); //Sort the mp3 files by name. sort($mp3Files); $interface->assign('mp3Filenames', $mp3Files); $interface->display('EcontentRecord/download-mp3.tpl'); exit; } } } } } } } else { $errorOccurred = true; $interface->assign('errorMessage', 'Sorry, we could not find that title in our online library.'); } } } } $interface->assign('errorOccurred', $errorOccurred); // Display Page $interface->assign('sidebar', 'PublicEContent/full-record-sidebar.tpl'); $interface->setTemplate('download-error.tpl'); $interface->display('layout.tpl'); }
function getFullText() { global $configArray; //Check to see if the text has already been extracted $fullText = ""; $fullTextPath = $configArray['EContent']['fullTextPath']; $textFile = "{$fullTextPath}/{$this->recordId}.txt"; if (file_exists($textFile)) { return file_get_contents($textFile); } else { if ($this->item_type == 'text') { return file_get_contents($textFile); } elseif ($this->item_type == 'epub') { require_once ROOT_DIR . '/sys/eReader/ebook.php'; $epubFile = $configArray['EContent']['library'] . '/' . $this->filename; $ebook = new ebook($epubFile); if (!$ebook->readErrorOccurred()) { $fhnd = fopen($textFile, 'w'); for ($i = 0; $i < $ebook->getManifestSize(); $i++) { $manifestId = $ebook->getManifestItem($i, 'id'); $manifestHref = $ebook->getManifestItem($i, 'href'); $manifestType = $ebook->getManifestItem($i, 'type'); if (!in_array($manifestType, array('image/jpeg', 'image/gif', 'image/tif', 'text/css'))) { try { $componentText = $ebook->getContentById($manifestId); fwrite($fhnd, strip_tags($componentText)); } catch (Exeption $e) { //Ignore it //'Unable to load content for component ' . $component; } } } fclose($fhnd); return file_get_contents($textFile); } else { return ""; } } elseif ($this->item_type == 'pdf') { /* This takes too long for large files */ /*$pdfboxJar = $configArray['EContent']['pdfbox']; $pdfFile = $configArray['EContent']['library'] . '/'. $this->filename; $textFile = $configArray['EContent']['fullTextPath'] . '/'. $this->filename; shell_exec('java -jar $pdfboxJar ExtractText $pdfFile $textFile'); return file_get_contents($textFile);*/ return ""; } else { //Full text not available return ""; } } }
/** * Download an EPUB file from the server so a user can use it locally. **/ function launch() { global $interface; global $configArray; $id = $_REQUEST['id']; $interface->assign('id', $id); $itemId = $_REQUEST['item']; $errorOccurred = false; if ($this->user == false) { $interface->assign('errorMessage', 'User is not logged in.'); $errorOccurred = true; $interface->assign('showLogin', true); } else { //Check the database to see if there is an existing title $epubFile = new EContentItem(); $epubFile->id = $itemId; $bookFile = null; if ($epubFile->find(true)) { $eContentRecord = new EContentRecord(); $eContentRecord->id = $epubFile->recordId; $eContentRecord->find(true); $libraryPath = $configArray['EContent']['library']; if (isset($epubFile->filename) && strlen($epubFile->filename) > 0) { $bookFile = "{$libraryPath}/{$epubFile->filename}"; } else { $bookFile = "{$libraryPath}/{$epubFile->folder}"; } if (!file_exists($bookFile)) { $bookFile = null; } } $errorOccurred = false; if (file_exists($bookFile)) { require_once ROOT_DIR . '/Drivers/EContentDriver.php'; $driver = new EContentDriver(); //Check to see if the user has access to the title. if (!$driver->isRecordCheckedOutToUser($id)) { $errorOccurred = true; $interface->assign('errorMessage', "Sorry, you do not have access to that title, please <a href='{$configArray['Site']['path']}/Record/{$id}/Hold'>place a hold</a> on the title and you will be notified when it is ready for pickup."); } if (!$errorOccurred) { //Record that the e-pub file is being opened. $driver->recordEContentAction($id, 'Download', $eContentRecord->accessType); if (strcasecmp($epubFile->item_type, 'epub') == 0) { require_once ROOT_DIR . '/sys/eReader/ebook.php'; $ebook = new ebook($bookFile); //Return the contents of the epub file header("Content-Type: application/epub+zip;\n"); //header('Content-Length: ' . filesize($bookFile)); header('Content-Description: ' . $ebook->getTitle()); //header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); die; } else { if (strcasecmp($epubFile->item_type, 'pdf') == 0) { header("Content-Type: application/pdf;\n"); header('Content-Length: ' . filesize($bookFile)); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); exit; } else { if (strcasecmp($epubFile->item_type, 'kindle') == 0) { header('Content-Length: ' . filesize($bookFile)); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); exit; } else { if (strcasecmp($epubFile->item_type, 'plucker') == 0) { header('Content-Length: ' . filesize($bookFile)); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); exit; } else { if (strcasecmp($epubFile->item_type, 'text') == 0) { header("Content-Type: text/plain;\n"); header('Content-Length: ' . filesize($bookFile)); //header('Content-Disposition: attachment; filename="' . basename($bookFile) . '"'); readfile($bookFile); exit; } else { if (strcasecmp($epubFile->item_type, 'mp3') == 0) { $id = $_REQUEST['id']; $interface->assign('id', $id); $item = $_REQUEST['item']; $interface->assign('item', $item); //Get all of the MP3 files that $dirHnd = opendir($bookFile); $mp3Files = array(); while (false !== ($file = readdir($dirHnd))) { if (preg_match('/^.*?\\.mp3$/i', $file)) { $mp3Files[] = array('name' => preg_replace('/\\.mp3/i', '', $file), 'size' => filesize($bookFile . '/' . $file)); } } $files = readdir($dirHnd); closedir($dirHnd); //Sort the mp3 files by name. sort($mp3Files); $interface->assign('mp3Filenames', $mp3Files); $interface->display('EcontentRecord/download-mp3.tpl'); exit; } } } } } } } } else { $errorOccurred = true; $interface->assign('errorMessage', 'Sorry, we could not find that book in our online library.'); } } $interface->assign('errorOccurred', $errorOccurred); $interface->display('EcontentRecord/download.tpl'); }
/** * @param ebook $ebook * @param string $id * @param string $item * @param string $file * @return mixed|string */ function getComponentCustom($ebook, $id, $item, $file) { global $configArray; $component = $_REQUEST['component']; $component = stripslashes($component); if (strpos($component, "#") > 0) { $component = substr($component, 0, strpos($component, "#")); } try { $componentText = $ebook->getContentById($component); } catch (Exception $e) { return 'Unable to load content for component ' . $component; } //Get the componentType of the content we are getting. for ($i = 0; $i < $ebook->getManifestSize(); $i++) { $manifestId = $ebook->getManifestItem($i, 'id'); $manifestType = $ebook->getManifestItem($i, 'type'); if ($manifestId == $component) { $componentType = $manifestType; } } if (isset($componentType) && in_array($componentType, array('image/jpeg', 'image/gif', 'image/tif', 'text/css'))) { header("Content-type: {$componentType}"); //Do not json encode the data } else { //After we get the component, we need to do some processing to fix internal links, images, and css files //so they display properly. //Loop through the manifest to find any files that are referenced for ($i = 0; $i < $ebook->getManifestSize(); $i++) { $manifestId = $ebook->getManifestItem($i, 'id'); $manifestHref = $ebook->getManifestItem($i, 'href'); $manifestType = $ebook->getManifestItem($i, 'type'); if (in_array($manifestType, array('image/jpeg', 'image/gif', 'image/tif', 'text/css'))) { //Javascript or image $pattern = str_replace("~", "\\~", preg_quote($manifestHref)); if ($manifestType == 'text/css') { //Ignore css for now $replacement = ''; } else { $replacement = $configArray['Site']['path'] . "/EContent/" . preg_quote($id) . "/JSON?method=getComponentCustom&item=" . $item . "&component=" . preg_quote($manifestId) . "&file=" . $file; } $componentText = preg_replace("~{$pattern}~", $replacement, $componentText); } else { //Link to another location within the document //convert to a window.reader.moveTo(componentId, location) //$componentText = preg_replace('/<a href=["\']#'. preg_quote($manifestHref) . '["\']/', "<a onclick=\"window.parent.reader.moveTo({componentId: '{$manifestId}', xpath:'//a[@id={$manifestId}]'})\" href=\"#\"", $componentText); $quotedManifest = preg_quote($manifestHref, '/'); $componentText = preg_replace('/<a href=["\']' . $quotedManifest . '["\']/', "<a onclick=\"return showTocEntry('{$manifestId}');\" href=\"#\"", $componentText); $componentText = preg_replace('/<a href=["\']' . $quotedManifest . '#(.*?)["\']/', "<a onclick=\"return showTocEntry('{$manifestId}#\\1');\" href=\"#\"", $componentText); /*$pattern = str_replace("~", "\~", '<a (.*?)href=["\']'. preg_quote($manifestHref) . '#(.*?)["\']'); $replacement = '<a \\1 onclick=\"window.parent.reader.moveTo({componentId: \'' . addslashes($manifestId) . '\', xpath:\'//a[@id=\\2]\'});return false;" href="#"'; $componentText = preg_replace("~$pattern~", $replacement, $componentText);*/ } } header('Content-type: text/plain'); header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past if (is_null($componentText)) { $componentText = ''; } $componentText = json_encode(array('result' => $componentText)); } return $componentText; }
?> <div id="content" class="clearfix"> <div id="main" role="main"> <?php $book_slug = get_query_var('book_slug') ? get_query_var('book_slug') : "leer"; $the_query = new WP_Query(array('post_type' => 'books', 'name' => $book_slug)); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); ?> <?php if (class_exists("ebook")) { $upload_dir = wp_upload_dir(); $epubFile = split("uploads", get_field('epub_version')); $file = $upload_dir["basedir"] . $epubFile[1]; $ebook = new ebook($file); $eBookData = $ebook->getEBookDataObject(); $toc = $eBookData->tocData; ?> <article id="post-<?php the_ID(); ?> " <?php post_class('clearfix'); ?> role="article"> <header style="z-index:10000;"> <div class="page-header page-header-series"> <div class="container container1160"> <div class="nomargin"> <a href="<?php
public function handleread($db, $path) { $book = $db->getBook($path[1]); $realbook = new ebook($book->file); header("Content-type: text/html"); echo $realbook->getChapter($path[2]); exit; }