diff options
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-x | inc/poche/Poche.class.php | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 4139c4f4..09a9f5ff 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -1083,11 +1083,10 @@ class Poche | |||
1083 | $config = $this->store->getConfigUser($user_id); | 1083 | $config = $this->store->getConfigUser($user_id); |
1084 | 1084 | ||
1085 | if ($config == null) { | 1085 | if ($config == null) { |
1086 | die(_('User with this id (' . $user_id . ') does not exist.')); | 1086 | die(sprintf(_('User with this id (%d) does not exist.'), $user_id)); |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | if (!in_array($type, $allowed_types) || | 1089 | if (!in_array($type, $allowed_types) || $token != $config['token']) { |
1090 | $token != $config['token']) { | ||
1091 | die(_('Uh, there is a problem while generating feeds.')); | 1090 | die(_('Uh, there is a problem while generating feeds.')); |
1092 | } | 1091 | } |
1093 | // Check the token | 1092 | // Check the token |
@@ -1145,16 +1144,18 @@ class Poche | |||
1145 | $config = HTMLPurifier_Config::createDefault(); | 1144 | $config = HTMLPurifier_Config::createDefault(); |
1146 | $config->set('Cache.SerializerPath', CACHE); | 1145 | $config->set('Cache.SerializerPath', CACHE); |
1147 | $config->set('HTML.SafeIframe', true); | 1146 | $config->set('HTML.SafeIframe', true); |
1148 | $config->set('URI.SafeIframeRegexp', '%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%'); //allow YouTube and Vimeo$purifier = new HTMLPurifier($config); | 1147 | |
1148 | //allow YouTube, Vimeo and dailymotion videos | ||
1149 | $config->set('URI.SafeIframeRegexp', '%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/|www\.dailymotion\.com/embed/video/)%'); | ||
1149 | 1150 | ||
1150 | return new HTMLPurifier($config); | 1151 | return new HTMLPurifier($config); |
1151 | } | 1152 | } |
1152 | 1153 | ||
1153 | /** | 1154 | /** |
1154 | * handle epub | 1155 | * handle epub |
1155 | */ | 1156 | */ |
1156 | public function createEpub() { | 1157 | public function createEpub() { |
1157 | 1158 | ||
1158 | switch ($_GET['method']) { | 1159 | switch ($_GET['method']) { |
1159 | case 'id': | 1160 | case 'id': |
1160 | $entryID = filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT); | 1161 | $entryID = filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT); |
@@ -1190,7 +1191,7 @@ class Poche | |||
1190 | break; | 1191 | break; |
1191 | case 'default': | 1192 | case 'default': |
1192 | die(_('Uh, there is a problem while generating epub.')); | 1193 | die(_('Uh, there is a problem while generating epub.')); |
1193 | 1194 | ||
1194 | } | 1195 | } |
1195 | 1196 | ||
1196 | $content_start = | 1197 | $content_start = |
@@ -1203,10 +1204,9 @@ class Poche | |||
1203 | . "<body>\n"; | 1204 | . "<body>\n"; |
1204 | 1205 | ||
1205 | $bookEnd = "</body>\n</html>\n"; | 1206 | $bookEnd = "</body>\n</html>\n"; |
1206 | 1207 | ||
1207 | $log = new Logger("wallabag", TRUE); | 1208 | $log = new Logger("wallabag", TRUE); |
1208 | $fileDir = CACHE; | 1209 | $fileDir = CACHE; |
1209 | |||
1210 | 1210 | ||
1211 | $book = new EPub(EPub::BOOK_VERSION_EPUB3, DEBUG_POCHE); | 1211 | $book = new EPub(EPub::BOOK_VERSION_EPUB3, DEBUG_POCHE); |
1212 | $log->logLine("new EPub()"); | 1212 | $log->logLine("new EPub()"); |
@@ -1215,7 +1215,7 @@ class Poche | |||
1215 | $log->logLine("Zip version: " . Zip::VERSION); | 1215 | $log->logLine("Zip version: " . Zip::VERSION); |
1216 | $log->logLine("getCurrentServerURL: " . $book->getCurrentServerURL()); | 1216 | $log->logLine("getCurrentServerURL: " . $book->getCurrentServerURL()); |
1217 | $log->logLine("getCurrentPageURL..: " . $book->getCurrentPageURL()); | 1217 | $log->logLine("getCurrentPageURL..: " . $book->getCurrentPageURL()); |
1218 | 1218 | ||
1219 | $book->setTitle(_('wallabag\'s articles')); | 1219 | $book->setTitle(_('wallabag\'s articles')); |
1220 | $book->setIdentifier("http://$_SERVER[HTTP_HOST]", EPub::IDENTIFIER_URI); // Could also be the ISBN number, prefered for published books, or a UUID. | 1220 | $book->setIdentifier("http://$_SERVER[HTTP_HOST]", EPub::IDENTIFIER_URI); // Could also be the ISBN number, prefered for published books, or a UUID. |
1221 | //$book->setLanguage("en"); // Not needed, but included for the example, Language is mandatory, but EPub defaults to "en". Use RFC3066 Language codes, such as "en", "da", "fr" etc. | 1221 | //$book->setLanguage("en"); // Not needed, but included for the example, Language is mandatory, but EPub defaults to "en". Use RFC3066 Language codes, such as "en", "da", "fr" etc. |
@@ -1225,39 +1225,39 @@ class Poche | |||
1225 | $book->setDate(time()); // Strictly not needed as the book date defaults to time(). | 1225 | $book->setDate(time()); // Strictly not needed as the book date defaults to time(). |
1226 | //$book->setRights("Copyright and licence information specific for the book."); // As this is generated, this _could_ contain the name or licence information of the user who purchased the book, if needed. If this is used that way, the identifier must also be made unique for the book. | 1226 | //$book->setRights("Copyright and licence information specific for the book."); // As this is generated, this _could_ contain the name or licence information of the user who purchased the book, if needed. If this is used that way, the identifier must also be made unique for the book. |
1227 | $book->setSourceURL("http://$_SERVER[HTTP_HOST]"); | 1227 | $book->setSourceURL("http://$_SERVER[HTTP_HOST]"); |
1228 | 1228 | ||
1229 | $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "PHP"); | 1229 | $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "PHP"); |
1230 | $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "wallabag"); | 1230 | $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "wallabag"); |
1231 | 1231 | ||
1232 | $cssData = "body {\n margin-left: .5em;\n margin-right: .5em;\n text-align: justify;\n}\n\np {\n font-family: serif;\n font-size: 10pt;\n text-align: justify;\n text-indent: 1em;\n margin-top: 0px;\n margin-bottom: 1ex;\n}\n\nh1, h2 {\n font-family: sans-serif;\n font-style: italic;\n text-align: center;\n background-color: #6b879c;\n color: white;\n width: 100%;\n}\n\nh1 {\n margin-bottom: 2px;\n}\n\nh2 {\n margin-top: -2px;\n margin-bottom: 2px;\n}\n"; | 1232 | $cssData = "body {\n margin-left: .5em;\n margin-right: .5em;\n text-align: justify;\n}\n\np {\n font-family: serif;\n font-size: 10pt;\n text-align: justify;\n text-indent: 1em;\n margin-top: 0px;\n margin-bottom: 1ex;\n}\n\nh1, h2 {\n font-family: sans-serif;\n font-style: italic;\n text-align: center;\n background-color: #6b879c;\n color: white;\n width: 100%;\n}\n\nh1 {\n margin-bottom: 2px;\n}\n\nh2 {\n margin-top: -2px;\n margin-bottom: 2px;\n}\n"; |
1233 | 1233 | ||
1234 | $log->logLine("Add Cover"); | 1234 | $log->logLine("Add Cover"); |
1235 | 1235 | ||
1236 | $fullTitle = "<h1> " . $bookTitle . "</h1>\n"; | 1236 | $fullTitle = "<h1> " . $bookTitle . "</h1>\n"; |
1237 | 1237 | ||
1238 | $book->setCoverImage("Cover.png", file_get_contents("themes/baggy/img/apple-touch-icon-152.png"), "image/png", $fullTitle); | 1238 | $book->setCoverImage("Cover.png", file_get_contents("themes/baggy/img/apple-touch-icon-152.png"), "image/png", $fullTitle); |
1239 | 1239 | ||
1240 | $cover = $content_start . '<div style="text-align:center;"><p>' . _('Produced by wallabag with PHPePub') . '</p><p>'. _('Please open <a href="https://github.com/wallabag/wallabag/issues" >an issue</a> if you have trouble with the display of this E-Book on your device.') . '</p></div>' . $bookEnd; | 1240 | $cover = $content_start . '<div style="text-align:center;"><p>' . _('Produced by wallabag with PHPePub') . '</p><p>'. _('Please open <a href="https://github.com/wallabag/wallabag/issues" >an issue</a> if you have trouble with the display of this E-Book on your device.') . '</p></div>' . $bookEnd; |
1241 | 1241 | ||
1242 | //$book->addChapter("Table of Contents", "TOC.xhtml", NULL, false, EPub::EXTERNAL_REF_IGNORE); | 1242 | //$book->addChapter("Table of Contents", "TOC.xhtml", NULL, false, EPub::EXTERNAL_REF_IGNORE); |
1243 | $book->addChapter("Notices", "Cover2.html", $cover); | 1243 | $book->addChapter("Notices", "Cover2.html", $cover); |
1244 | 1244 | ||
1245 | $book->buildTOC(); | 1245 | $book->buildTOC(); |
1246 | 1246 | ||
1247 | foreach ($entries as $entry) { //set tags as subjects | 1247 | foreach ($entries as $entry) { //set tags as subjects |
1248 | $tags = $this->store->retrieveTagsByEntry($entry['id']); | 1248 | $tags = $this->store->retrieveTagsByEntry($entry['id']); |
1249 | foreach ($tags as $tag) { | 1249 | foreach ($tags as $tag) { |
1250 | $book->setSubject($tag['value']); | 1250 | $book->setSubject($tag['value']); |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | $log->logLine("Set up parameters"); | 1253 | $log->logLine("Set up parameters"); |
1254 | 1254 | ||
1255 | $chapter = $content_start . $entry['content'] . $bookEnd; | 1255 | $chapter = $content_start . $entry['content'] . $bookEnd; |
1256 | $book->addChapter($entry['title'], htmlspecialchars($entry['title']) . ".html", $chapter, true, EPub::EXTERNAL_REF_ADD); | 1256 | $book->addChapter($entry['title'], htmlspecialchars($entry['title']) . ".html", $chapter, true, EPub::EXTERNAL_REF_ADD); |
1257 | $log->logLine("Added chapter " . $entry['title']); | 1257 | $log->logLine("Added chapter " . $entry['title']); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | if (DEBUG_POCHE) { | 1260 | if (DEBUG_POCHE) { |
1261 | $epuplog = $book->getLog(); | 1261 | $epuplog = $book->getLog(); |
1262 | $book->addChapter("Log", "Log.html", $content_start . $log->getLog() . "\n</pre>" . $bookEnd); // log generation | 1262 | $book->addChapter("Log", "Log.html", $content_start . $log->getLog() . "\n</pre>" . $bookEnd); // log generation |
1263 | } | 1263 | } |