function epub_pack_book() { echo "packing epub\n"; $user = ""; if (isset($_POST['client'])) { $user = rawurldecode($_POST['client']) . '/'; } $meta = epub_get_metadirectory(); echo "{$meta}\n"; if (!epub_zip_handle() && epub_isWindows()) { epub_pack_ZipLib($meta); } elseif (!epub_zip_handle()) { chdir($meta); echo rawurlencode("*nix zip command used \n"); $cmd = 'zip -Xr9Dq my-book.epub *'; exec($cmd, $ar, $ret); if ($ret > 0) { echo "zip error: exit status={$ret}\n"; echo "<b>Error codes:</b>\n 4: memory allocation error\n 11-18: unable write to or create file\n 127: zip command not found\n"; echo "Trying ZipLib\n"; epub_pack_ZipLib($meta); } } else { echo "ziparchive used\n"; } $plugin =& plugin_load('syntax', 'epub'); $oldname = $meta . 'my-book.epub'; $rmdir = $plugin->getConf('rmdir'); $epub_file = strtolower(date("Y_F_j_h-i-s")) . '.epub'; $newname = mediaFN("epub:{$user}:{$epub_file}"); if (rename($oldname, $newname)) { $epub_id = cleanID("epub:{$user}:{$epub_file}"); $helper = new helper_plugin_epub(); $id = cleanID(rawurldecode($_POST['book_page'])); echo "ebook id={$id}\n"; $title = rawurldecode($_POST['title']); $helper->addBook($id, $epub_id, $title); echo "New Ebook: {$epub_id}\n"; } if ($rmdir == 'y') { if (epub_isWindows()) { $meta = str_replace('/', '\\', $meta); $cmd = "RMDIR /s /q {$meta}"; } else { $cmd = "rm -f -r {$meta}"; } system($cmd, $retval); if ($retval) { echo "unable to remove dir:<br /> {$meta}<br /> error code: {$retval}\n"; } else { echo "{$cmd}\n"; } } }
<?php if (!defined('DOKU_INC')) { define('DOKU_INC', realpath(dirname(__FILE__) . '/../../../../') . '/'); } if (!defined('NOSESSION')) { define('NOSESSION', true); } if (!defined('EPUB_DIR')) { define('EPUB_DIR', realpath(dirname(__FILE__) . '/../') . '/'); } require_once DOKU_INC . 'inc/init.php'; require_once EPUB_DIR . '/helper.php'; $helper = new helper_plugin_epub(); $id = rawurldecode($_POST['remove']); if (!$helper->is_inCache($id)) { echo "{$id} is not in the book creator list; you may use it for other purposes.\n"; echo "To restore it to the list you must make an edit, no matter how small, and re-save the page."; exit; } $helper->remove_page($id); if (!$helper->is_inCache($id)) { echo "{$id} has been successfully removed from the book creator list.\nTo restore it to the list you must make an edit,\nno matter how small, and re-save the page."; } else { echo "{$id} was not removed from book creator list.\n"; }