From fe55e86defb401fd4ea7374d8de393cf30f43649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Sun, 1 Jul 2012 14:24:54 +0200 Subject: [PATCH] Add a config option to not use URL rewriting by default Also fix a bug preventing download --- config_default.php | 10 +++++++++- data.php | 11 ++++++++++- fetch.php | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/config_default.php b/config_default.php index 6842e0c..2e156b6 100644 --- a/config_default.php +++ b/config_default.php @@ -79,5 +79,13 @@ * The two first will be displayed in book entries * The other only appear in book detail */ - $config['cops_prefered_format'] = array ("EPUB", "PDF", "MOBI", "CBR", "CBZ"); + $config['cops_prefered_format'] = array ("EPUB", "PDF", "MOBI", "CBR", "CBZ"); + + /* + * use URL rewriting for downloading of ebook in HTML catalog + * See README for more information + * 1 : enable + * 0 : disable + */ + $config['cops_use_url_rewriting'] = "0"; ?> \ No newline at end of file diff --git a/data.php b/data.php index 1ca0208..3b2c10b 100644 --- a/data.php +++ b/data.php @@ -70,7 +70,16 @@ class Data extends Base { } public function getHtmlLink () { - return "download/" . $this->id . "/" . urlencode ($this->getFilename ()); + global $config; + + if ($config['cops_use_url_rewriting'] == "1") + { + return "download/" . $this->id . "/" . urlencode ($this->getFilename ()); + } + else + { + return str_replace ("&", "&", "fetch.php?id=" . $this->book->id . "&data=" . $this->id . "&type=" . $this->extension); + } } public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL) diff --git a/fetch.php b/fetch.php index 885467b..1d16a75 100644 --- a/fetch.php +++ b/fetch.php @@ -8,6 +8,7 @@ require_once ("config.php"); require_once ("book.php"); + require_once ("data.php"); global $config; $expires = 60*60*24*14; @@ -82,7 +83,7 @@ } break; default: - header("Content-type: " . Book::$mimetypes[$type]); + header("Content-type: " . Data::$mimetypes[$type]); break; } $file = $book->getFilePath ($type, $idData, true);