aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/3rdparty/libraries/tcpdf/tcpdf.php10
-rwxr-xr-xinc/poche/Poche.class.php41
-rwxr-xr-xinc/poche/Routing.class.php5
-rw-r--r--inc/poche/WallabagEBooks.class.php41
-rwxr-xr-xinc/poche/config.inc.default.php2
5 files changed, 84 insertions, 15 deletions
diff --git a/inc/3rdparty/libraries/tcpdf/tcpdf.php b/inc/3rdparty/libraries/tcpdf/tcpdf.php
index 78694a0e..70c1747a 100644
--- a/inc/3rdparty/libraries/tcpdf/tcpdf.php
+++ b/inc/3rdparty/libraries/tcpdf/tcpdf.php
@@ -2927,11 +2927,17 @@ class TCPDF {
2927 public function Error($msg) { 2927 public function Error($msg) {
2928 // unset all class variables 2928 // unset all class variables
2929 $this->_destroy(true); 2929 $this->_destroy(true);
2930 throw new Exception('TCPDF ERROR: '.$msg);
2931 /*
2932
2933 I had problems with the constants for some reason, so here we force
2934
2935 $this->_destroy(true);
2930 if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) { 2936 if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) {
2931 die('<strong>TCPDF ERROR: </strong>'.$msg); 2937 die('<strong>TCPDF ERROR: </strong>'.$msg);
2932 } else { 2938 } else {
2933 throw new Exception('TCPDF ERROR: '.$msg); 2939 throw new Exception('TCPDF ERROR: '.$msg);
2934 } 2940 }*/
2935 } 2941 }
2936 2942
2937 /** 2943 /**
@@ -6915,7 +6921,7 @@ class TCPDF {
6915 $ph = $this->getHTMLUnitToUnits($h, 0, $this->pdfunit, true) * $this->imgscale * $this->k; 6921 $ph = $this->getHTMLUnitToUnits($h, 0, $this->pdfunit, true) * $this->imgscale * $this->k;
6916 $imsize = array($pw, $ph); 6922 $imsize = array($pw, $ph);
6917 } else { 6923 } else {
6918 $this->Error('[Image] Unable to get the size of the image: '.$file); 6924 $this->Error('[Image] Unable to fetch image: '.$file);
6919 } 6925 }
6920 } 6926 }
6921 // file hash 6927 // file hash
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 6a742019..a601f0a8 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -195,10 +195,11 @@ class Poche
195 } 195 }
196 196
197 if ($autoclose == TRUE) { 197 if ($autoclose == TRUE) {
198 Tools::redirect('?view=home'); 198 Tools::redirect('?view=home&closewin=true');
199 } else { 199 } else {
200 Tools::redirect('?view=home&closewin=true'); 200 Tools::redirect('?view=home');
201 } 201 }
202 return $last_id;
202 break; 203 break;
203 case 'delete': 204 case 'delete':
204 if (isset($_GET['search'])) { 205 if (isset($_GET['search'])) {
@@ -336,6 +337,27 @@ class Poche
336 $this->messages->add('s', _('The tag has been successfully deleted')); 337 $this->messages->add('s', _('The tag has been successfully deleted'));
337 Tools::redirect(); 338 Tools::redirect();
338 break; 339 break;
340
341 case 'reload_article' :
342 Tools::logm('reload article');
343 $id = $_GET['id'];
344 $entry = $this->store->retrieveOneById($id, $this->user->getId());
345 Tools::logm('reload url ' . $entry['url']);
346 $url = new Url(base64_encode($entry['url']));
347 $this->action('add', $url);
348 break;
349
350 /* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
351 case 'random':
352 $id = 0;
353 while ($this->store->retrieveOneById($id,$this->user->getId()) == null) {
354 $count = $this->store->getEntriesByViewCount($view, $this->user->getId());
355 $id = rand(1,$count);
356 }
357 Tools::logm('get a random article');
358 Tools::redirect('?view=view&id=' . $id);
359 //$this->displayView('view', $id);
360 break;
339 default: 361 default:
340 break; 362 break;
341 } 363 }
@@ -576,6 +598,8 @@ class Poche
576 Tools::redirect($referer); 598 Tools::redirect($referer);
577 } 599 }
578 $this->messages->add('e', _('login failed: bad login or password')); 600 $this->messages->add('e', _('login failed: bad login or password'));
601 // log login failure in web server log to allow fail2ban usage
602 error_log('user '.$login.' authentication failure');
579 Tools::logm('login failed'); 603 Tools::logm('login failed');
580 Tools::redirect(); 604 Tools::redirect();
581 } 605 }
@@ -661,7 +685,18 @@ class Poche
661 $urlsInserted[] = $url; //add 685 $urlsInserted[] = $url; //add
662 if (isset($record['tags']) && trim($record['tags'])) { 686 if (isset($record['tags']) && trim($record['tags'])) {
663 687
664 // @TODO: set tags 688 $tags = explode(',', $record['tags']);
689 foreach($tags as $tag) {
690 $entry_id = $id;
691 $tag_id = $this->store->retrieveTagByValue($tag);
692 if ($tag_id) {
693 $this->store->setTagToEntry($tag_id['id'], $entry_id);
694 } else {
695 $this->store->createTag($tag);
696 $tag_id = $this->store->retrieveTagByValue($tag);
697 $this->store->setTagToEntry($tag_id['id'], $entry_id);
698 }
699 }
665 700
666 } 701 }
667 } 702 }
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php
index be06a433..709831d5 100755
--- a/inc/poche/Routing.class.php
+++ b/inc/poche/Routing.class.php
@@ -33,6 +33,7 @@ class Routing
33 $this->view = Tools::checkVar('view', 'home'); 33 $this->view = Tools::checkVar('view', 'home');
34 $this->action = Tools::checkVar('action'); 34 $this->action = Tools::checkVar('action');
35 $this->id = Tools::checkVar('id'); 35 $this->id = Tools::checkVar('id');
36 $this->autoclose = Tools::checkVar('autoclose',FALSE);
36 $_SESSION['sort'] = Tools::checkVar('sort', 'id'); 37 $_SESSION['sort'] = Tools::checkVar('sort', 'id');
37 $this->url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); 38 $this->url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
38 } 39 }
@@ -64,7 +65,7 @@ class Routing
64 $tplVars = array(); 65 $tplVars = array();
65 66
66 if (\Session::isLogged()) { 67 if (\Session::isLogged()) {
67 $this->wallabag->action($this->action, $this->url, $this->id); 68 $this->wallabag->action($this->action, $this->url, $this->id, FALSE, $this->autoclose);
68 $tplFile = Tools::getTplFile($this->view); 69 $tplFile = Tools::getTplFile($this->view);
69 $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id)); 70 $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id));
70 } elseif(isset($_SERVER['PHP_AUTH_USER'])) { 71 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
@@ -116,7 +117,7 @@ class Routing
116 // update password 117 // update password
117 $this->wallabag->updatePassword($_POST['password'], $_POST['password_repeat']); 118 $this->wallabag->updatePassword($_POST['password'], $_POST['password_repeat']);
118 } elseif (isset($_GET['newuser'])) { 119 } elseif (isset($_GET['newuser'])) {
119 $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser']); 120 $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail']);
120 } elseif (isset($_GET['deluser'])) { 121 } elseif (isset($_GET['deluser'])) {
121 $this->wallabag->deleteUser($_POST['password4deletinguser']); 122 $this->wallabag->deleteUser($_POST['password4deletinguser']);
122 } elseif (isset($_GET['epub'])) { 123 } elseif (isset($_GET['epub'])) {
diff --git a/inc/poche/WallabagEBooks.class.php b/inc/poche/WallabagEBooks.class.php
index bc40990b..55831571 100644
--- a/inc/poche/WallabagEBooks.class.php
+++ b/inc/poche/WallabagEBooks.class.php
@@ -33,7 +33,7 @@ class WallabagEBooks
33 $entry = $this->wallabag->store->retrieveOneById($entryID, $this->wallabag->user->getId()); 33 $entry = $this->wallabag->store->retrieveOneById($entryID, $this->wallabag->user->getId());
34 $this->entries = array($entry); 34 $this->entries = array($entry);
35 $this->bookTitle = $entry['title']; 35 $this->bookTitle = $entry['title'];
36 $this->bookFileName = substr($this->bookTitle, 0, 200); 36 $this->bookFileName = str_replace('/', '_', substr($this->bookTitle, 0, 200));
37 $this->author = preg_replace('#^w{3}.#', '', Tools::getdomain($entry["url"])); # if only one article, set author to domain name (we strip the eventual www part) 37 $this->author = preg_replace('#^w{3}.#', '', Tools::getdomain($entry["url"])); # if only one article, set author to domain name (we strip the eventual www part)
38 Tools::logm('Producing ebook from article ' . $this->bookTitle); 38 Tools::logm('Producing ebook from article ' . $this->bookTitle);
39 break; 39 break;
@@ -81,6 +81,9 @@ class WallabagEpub extends WallabagEBooks
81 public function produceEpub() 81 public function produceEpub()
82 { 82 {
83 Tools::logm('Starting to produce ePub 3 file'); 83 Tools::logm('Starting to produce ePub 3 file');
84
85 try {
86
84 $content_start = 87 $content_start =
85 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 88 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
86 . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n" 89 . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
@@ -155,6 +158,11 @@ class WallabagEpub extends WallabagEBooks
155 $book->finalize(); 158 $book->finalize();
156 $zipData = $book->sendBook($this->bookFileName); 159 $zipData = $book->sendBook($this->bookFileName);
157 Tools::logm('Ebook produced'); 160 Tools::logm('Ebook produced');
161 }
162 catch (Exception $e) {
163 Tools::logm('PHPePub has encountered an error : '.$e->getMessage());
164 $this->wallabag->messages->add('e', $e->getMessage());
165 }
158 } 166 }
159} 167}
160 168
@@ -167,7 +175,7 @@ class WallabagMobi extends WallabagEBooks
167 175
168 public function produceMobi() 176 public function produceMobi()
169 { 177 {
170 178 try {
171 Tools::logm('Starting to produce Mobi file'); 179 Tools::logm('Starting to produce Mobi file');
172 $mobi = new MOBI(); 180 $mobi = new MOBI();
173 $content = new MOBIFile(); 181 $content = new MOBIFile();
@@ -194,9 +202,17 @@ class WallabagMobi extends WallabagEBooks
194 } 202 }
195 $mobi->setContentProvider($content); 203 $mobi->setContentProvider($content);
196 204
205 // the browser inside Kindle Devices doesn't likes special caracters either, we limit to A-z/0-9
206 $this->bookFileName = preg_replace('/[^A-Za-z0-9\-]/', '', $this->bookFileName);
207
197 // we offer file to download 208 // we offer file to download
198 $mobi->download($this->bookFileName.'.mobi'); 209 $mobi->download($this->bookFileName.'.mobi');
199 Tools::logm('Mobi file produced'); 210 Tools::logm('Mobi file produced');
211 }
212 catch (Exception $e) {
213 Tools::logm('PHPMobi has encountered an error : '.$e->getMessage());
214 $this->wallabag->messages->add('e', $e->getMessage());
215 }
200 } 216 }
201} 217}
202 218
@@ -206,15 +222,16 @@ class WallabagPDF extends WallabagEbooks
206 { 222 {
207 223
208 Tools::logm('Starting to produce PDF file'); 224 Tools::logm('Starting to produce PDF file');
209 225 @define ('K_TCPDF_THROW_EXCEPTION_ERROR', TRUE);
226 try {
210 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 227 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
211 228
212 Tools::logm('Filling metadata for PDF...'); 229 Tools::logm('Filling metadata for PDF...');
213 $pdf->SetCreator(PDF_CREATOR); 230 $pdf->SetCreator(PDF_CREATOR);
214 $pdf->SetAuthor(''); 231 $pdf->SetAuthor('wallabag');
215 $pdf->SetTitle($this->bookTitle); 232 $pdf->SetTitle($this->bookTitle);
216 $pdf->SetSubject('TCPDF Tutorial'); 233 $pdf->SetSubject('Articles via wallabag');
217 $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); 234 $pdf->SetKeywords('wallabag');
218 235
219 Tools::logm('Adding introduction...'); 236 Tools::logm('Adding introduction...');
220 $pdf->AddPage(); 237 $pdf->AddPage();
@@ -229,18 +246,26 @@ class WallabagPDF extends WallabagEbooks
229 $i = 1; 246 $i = 1;
230 Tools::logm('Adding actual content...'); 247 Tools::logm('Adding actual content...');
231 foreach ($this->entries as $item) { 248 foreach ($this->entries as $item) {
249 $tags = $this->wallabag->store->retrieveTagsByEntry($entry['id']);
250 foreach ($tags as $tag) {
251 $pdf->SetKeywords($tag['value']);
252 }
232 $pdf->AddPage(); 253 $pdf->AddPage();
233 $html = '<h1>' . $item['title'] . '</h1>'; 254 $html = '<h1>' . $item['title'] . '</h1>';
234 $html .= $item['content']; 255 $html .= $item['content'];
235 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); 256 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
236 $i = $i+1;
237 } 257 }
238 258
239 // set image scale factor 259 // set image scale factor
240 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 260 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
241 261
242 262
243 $pdf->Output($this->bookFileName . '.pdf', 'FD'); 263 $pdf->Output($this->bookFileName . '.pdf', 'FD');
264 }
265 catch (Exception $e) {
266 Tools::logm('TCPDF has encountered an error : '.$e->getMessage());
267 $this->wallabag->messages->add('e', $e->getMessage());
268 }
244 269
245 } 270 }
246} 271}
diff --git a/inc/poche/config.inc.default.php b/inc/poche/config.inc.default.php
index a159e713..91b50c24 100755
--- a/inc/poche/config.inc.default.php
+++ b/inc/poche/config.inc.default.php
@@ -44,6 +44,7 @@
44@define ('SHARE_MAIL', TRUE); 44@define ('SHARE_MAIL', TRUE);
45@define ('SHARE_SHAARLI', FALSE); 45@define ('SHARE_SHAARLI', FALSE);
46@define ('SHAARLI_URL', 'http://myshaarliurl.com'); 46@define ('SHAARLI_URL', 'http://myshaarliurl.com');
47@define ('SHARE_EVERNOTE', FALSE);
47@define ('SHARE_DIASPORA', FALSE); 48@define ('SHARE_DIASPORA', FALSE);
48@define ('DIASPORA_URL', 'http://diasporapod.com'); # Don't add a / at the end 49@define ('DIASPORA_URL', 'http://diasporapod.com'); # Don't add a / at the end
49@define ('FLATTR', TRUE); 50@define ('FLATTR', TRUE);
@@ -62,6 +63,7 @@
62@define ('SHOW_PRINTLINK', '1'); 63@define ('SHOW_PRINTLINK', '1');
63// display or not percent of read in article view. Affects only default theme. 64// display or not percent of read in article view. Affects only default theme.
64@define ('SHOW_READPERCENT', '1'); 65@define ('SHOW_READPERCENT', '1');
66@define ('RELOAD_ARTICLE', TRUE);
65@define ('ABS_PATH', 'assets/'); 67@define ('ABS_PATH', 'assets/');
66 68
67@define ('DEFAULT_THEME', 'baggy'); 69@define ('DEFAULT_THEME', 'baggy');