aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/3rdparty/FlattrItem.class.php49
m---------inc/3rdparty/site_config0
-rw-r--r--inc/3rdparty/site_config/README.txt6
-rw-r--r--inc/3rdparty/site_config/custom/bfmtv.com.txt6
-rw-r--r--inc/3rdparty/site_config/custom/inthepoche.com.txt7
-rw-r--r--inc/3rdparty/site_config/custom/tldp.org.txt6
-rw-r--r--inc/3rdparty/site_config/index.php3
-rw-r--r--inc/3rdparty/site_config/standard/.wikipedia.org.txt19
-rw-r--r--inc/3rdparty/site_config/standard/index.php3
-rw-r--r--inc/3rdparty/site_config/standard/version.php2
-rw-r--r--inc/poche/Poche.class.php61
-rwxr-xr-xinc/poche/config.inc.php8
-rw-r--r--inc/poche/define.inc.php8
13 files changed, 65 insertions, 113 deletions
diff --git a/inc/3rdparty/FlattrItem.class.php b/inc/3rdparty/FlattrItem.class.php
new file mode 100644
index 00000000..c940fcd6
--- /dev/null
+++ b/inc/3rdparty/FlattrItem.class.php
@@ -0,0 +1,49 @@
1<?php
2/*
3* Class for Flattr querying
4*/
5class FlattrItem {
6
7 public $status;
8 public $urltoflattr;
9 public $flattrItemURL;
10 public $numflattrs;
11
12 public function checkItem($urltoflattr) {
13 $this->cacheflattrfile($urltoflattr);
14 $flattrResponse = file_get_contents(CACHE . "/flattr/".base64_encode($urltoflattr).".cache");
15 if($flattrResponse != FALSE) {
16 $result = json_decode($flattrResponse);
17 if (isset($result->message)){
18 if ($result->message == "flattrable") {
19 $this->status = FLATTRABLE;
20 }
21 }
22 elseif ($result->link) {
23 $this->status = FLATTRED;
24 $this->flattrItemURL = $result->link;
25 $this->numflattrs = $result->flattrs;
26 }
27 else {
28 $this->status = NOT_FLATTRABLE;
29 }
30 }
31 else {
32 $this->status = "FLATTR_ERR_CONNECTION";
33 }
34 }
35
36 private function cacheflattrfile($urltoflattr) {
37 if (!is_dir(CACHE . '/flattr')) {
38 mkdir(CACHE . '/flattr', 0777);
39 }
40
41 // if a cache flattr file for this url already exists and it's been less than one day than it have been updated, see in /cache
42 if ((!file_exists(CACHE . "/flattr/".base64_encode($urltoflattr).".cache")) || (time() - filemtime(CACHE . "/flattr/".base64_encode($urltoflattr).".cache") > 86400)) {
43 $askForFlattr = Tools::getFile(FLATTR_API . $urltoflattr);
44 $flattrCacheFile = fopen(CACHE . "/flattr/".base64_encode($urltoflattr).".cache", 'w+');
45 fwrite($flattrCacheFile, $askForFlattr);
46 fclose($flattrCacheFile);
47 }
48 }
49} \ No newline at end of file
diff --git a/inc/3rdparty/site_config b/inc/3rdparty/site_config
new file mode 160000
Subproject fe9f0d3f60d44a8701f3ecab0c4077a4ed39bfe
diff --git a/inc/3rdparty/site_config/README.txt b/inc/3rdparty/site_config/README.txt
deleted file mode 100644
index 0aff456b..00000000
--- a/inc/3rdparty/site_config/README.txt
+++ /dev/null
@@ -1,6 +0,0 @@
1Full-Text RSS Site Patterns
2---------------------------
3
4Site patterns allow you to specify what should be extracted from specific sites.
5
6Please see http://help.fivefilters.org/customer/portal/articles/223153-site-patterns for more information. \ No newline at end of file
diff --git a/inc/3rdparty/site_config/custom/bfmtv.com.txt b/inc/3rdparty/site_config/custom/bfmtv.com.txt
deleted file mode 100644
index 0ff28d56..00000000
--- a/inc/3rdparty/site_config/custom/bfmtv.com.txt
+++ /dev/null
@@ -1,6 +0,0 @@
1title: //title
2body: //h2 | //span[@class='masque'] | //article[@class='corps_article_right']
3prune: no
4tidy: no
5
6test_url: http://www.bfmtv.com/societe/cigarette-electronique-dangers-588622.html \ No newline at end of file
diff --git a/inc/3rdparty/site_config/custom/inthepoche.com.txt b/inc/3rdparty/site_config/custom/inthepoche.com.txt
deleted file mode 100644
index ede74b97..00000000
--- a/inc/3rdparty/site_config/custom/inthepoche.com.txt
+++ /dev/null
@@ -1,7 +0,0 @@
1title: //title
2body: //div[@class='post-content']
3
4prune: no
5tidy: no
6
7test_url: http://www.inthepoche.com/?post/poche-hosting \ No newline at end of file
diff --git a/inc/3rdparty/site_config/custom/tldp.org.txt b/inc/3rdparty/site_config/custom/tldp.org.txt
deleted file mode 100644
index 7dd5cdb5..00000000
--- a/inc/3rdparty/site_config/custom/tldp.org.txt
+++ /dev/null
@@ -1,6 +0,0 @@
1title: //title
2body: //h2 | //p | //ul
3prune: no
4tidy: no
5
6test_url: http://www.tldp.org/HOWTO/Plug-and-Play-HOWTO-7.html \ No newline at end of file
diff --git a/inc/3rdparty/site_config/index.php b/inc/3rdparty/site_config/index.php
deleted file mode 100644
index a3d5f739..00000000
--- a/inc/3rdparty/site_config/index.php
+++ /dev/null
@@ -1,3 +0,0 @@
1<?php
2// this is here to prevent directory listing over the web
3?> \ No newline at end of file
diff --git a/inc/3rdparty/site_config/standard/.wikipedia.org.txt b/inc/3rdparty/site_config/standard/.wikipedia.org.txt
deleted file mode 100644
index 8b98ae4b..00000000
--- a/inc/3rdparty/site_config/standard/.wikipedia.org.txt
+++ /dev/null
@@ -1,19 +0,0 @@
1title: //h1[@id='firstHeading']
2body: //div[@id = 'bodyContent']
3strip_id_or_class: editsection
4#strip_id_or_class: toc
5strip_id_or_class: vertical-navbox
6strip: //table[@id='toc']
7strip: //div[@id='catlinks']
8strip: //div[@id='jump-to-nav']
9strip: //div[@class='thumbcaption']//div[@class='magnify']
10strip: //table[@class='navbox']
11strip: //table[contains(@class, 'infobox')]
12strip: //div[@class='dablink']
13strip: //div[@id='contentSub']
14strip: //table[contains(@class, 'metadata')]
15strip: //*[contains(@class, 'noprint')]
16strip: //span[@title='pronunciation:']
17prune: no
18tidy: no
19test_url: http://en.wikipedia.org/wiki/Christopher_Lloyd \ No newline at end of file
diff --git a/inc/3rdparty/site_config/standard/index.php b/inc/3rdparty/site_config/standard/index.php
deleted file mode 100644
index a3d5f739..00000000
--- a/inc/3rdparty/site_config/standard/index.php
+++ /dev/null
@@ -1,3 +0,0 @@
1<?php
2// this is here to prevent directory listing over the web
3?> \ No newline at end of file
diff --git a/inc/3rdparty/site_config/standard/version.php b/inc/3rdparty/site_config/standard/version.php
deleted file mode 100644
index e61807ed..00000000
--- a/inc/3rdparty/site_config/standard/version.php
+++ /dev/null
@@ -1,2 +0,0 @@
1<?php
2return 1; \ No newline at end of file
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index b0efe69a..9db4a034 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -182,7 +182,7 @@ class Poche
182 } 182 }
183 183
184 if (!$import) { 184 if (!$import) {
185 Tools::redirect(); 185 Tools::redirect('?view=home');
186 } 186 }
187 break; 187 break;
188 case 'delete': 188 case 'delete':
@@ -248,9 +248,9 @@ class Poche
248 $tidy->cleanRepair(); 248 $tidy->cleanRepair();
249 $content = $tidy->value; 249 $content = $tidy->value;
250 250
251 // flattr checking 251 # flattr checking
252 $flattr = new FlattrItem(); 252 $flattr = new FlattrItem();
253 $flattr->checkitem($entry['url']); 253 $flattr->checkItem($entry['url']);
254 254
255 $tpl_vars = array( 255 $tpl_vars = array(
256 'entry' => $entry, 256 'entry' => $entry,
@@ -263,11 +263,12 @@ class Poche
263 Tools::logm('error in view call : entry is null'); 263 Tools::logm('error in view call : entry is null');
264 } 264 }
265 break; 265 break;
266 default : // home, favorites and archive views 266 default: # home, favorites and archive views
267 $entries = $this->store->getEntriesByView($view, $this->user->getId()); 267 $entries = $this->store->getEntriesByView($view, $this->user->getId());
268 $tpl_vars = array( 268 $tpl_vars = array(
269 'entries' => '', 269 'entries' => '',
270 'page_links' => '', 270 'page_links' => '',
271 'nb_results' => '',
271 ); 272 );
272 if (count($entries) > 0) { 273 if (count($entries) > 0) {
273 $this->pagination->set_total(count($entries)); 274 $this->pagination->set_total(count($entries));
@@ -275,6 +276,7 @@ class Poche
275 $datas = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit()); 276 $datas = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit());
276 $tpl_vars['entries'] = $datas; 277 $tpl_vars['entries'] = $datas;
277 $tpl_vars['page_links'] = $page_links; 278 $tpl_vars['page_links'] = $page_links;
279 $tpl_vars['nb_results'] = count($entries);
278 } 280 }
279 Tools::logm('display ' . $view . ' view'); 281 Tools::logm('display ' . $view . ' view');
280 break; 282 break;
@@ -564,53 +566,4 @@ class Poche
564 } 566 }
565 return $version; 567 return $version;
566 } 568 }
567} 569} \ No newline at end of file
568
569/* class for Flattr querying. Should be put in a separate file
570* Or maybe just create an array instead of a complete class... My mistake. :-°
571*/
572class FlattrItem{
573 public $status;
574 public $urltoflattr;
575 public $flattrItemURL;
576 public $numflattrs;
577
578 public function checkitem($urltoflattr){
579 $this->cacheflattrfile($urltoflattr);
580 $flattrResponse = file_get_contents("cache/flattr/".base64_encode($urltoflattr).".cache");
581 if($flattrResponse != FALSE){
582 $result = json_decode($flattrResponse);
583 if (isset($result->message)){
584 if ($result->message == "flattrable"){
585 $this->status = "flattrable";
586 }
587 }
588 elseif ($result->link) {
589 $this->status = "flattred";
590 $this->flattrItemURL = $result->link;
591 $this->numflattrs = $result->flattrs;
592 }
593 else{
594 $this->status = "not flattrable";
595 }
596 }
597 else
598 {
599 $this->status = "FLATTR_ERR_CONNECTION";
600 }
601 }
602
603 private function cacheflattrfile($urltoflattr){
604 if (!is_dir('cache/flattr')){
605 mkdir('./cache/flattr', 0777);
606 }
607 // if a cache flattr file for this url already exists and it's been less than one day than it have been updated, see in /cache
608 if ((!file_exists("cache/flattr/".base64_encode($urltoflattr).".cache")) || (time() - filemtime("cache/flattr/".base64_encode($urltoflattr).".cache") > 86400))
609 {
610 $askForFlattr = Tools::getFile("https://api.flattr.com/rest/v2/things/lookup/?url=".$urltoflattr);
611 $flattrCacheFile = fopen("cache/flattr/".base64_encode($urltoflattr).".cache", 'w+');
612 fwrite($flattrCacheFile, $askForFlattr);
613 fclose($flattrCacheFile);
614 }
615 }
616}
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php
index a1917295..45526695 100755
--- a/inc/poche/config.inc.php
+++ b/inc/poche/config.inc.php
@@ -3,7 +3,7 @@
3 * poche, a read it later open source system 3 * poche, a read it later open source system
4 * 4 *
5 * @category poche 5 * @category poche
6 * @author Nicolas Lœuillet <nicolas@loeuillet.org> 6 * @author Nicolas Lœuillet <support@inthepoche.com>
7 * @copyright 2013 7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
@@ -12,12 +12,9 @@ require_once __DIR__ . '/../../inc/poche/define.inc.php';
12 12
13# /!\ Be careful if you change the lines below /!\ 13# /!\ Be careful if you change the lines below /!\
14if (!file_exists(__DIR__ . '/../../vendor/autoload.php')) { 14if (!file_exists(__DIR__ . '/../../vendor/autoload.php')) {
15 die('Twig does not seem installed. Have a look at <a href="http://inthepoche.com/?pages/Documentation">the documentation.</a>'); 15 die('Twig does not seem installed. Have a look at <a href="inthepoche.com/doc">the documentation.</a>');
16} 16}
17 17
18// if (file_exists(__DIR__ . '/../../inc/poche/myconfig.inc.php')) {
19 // require_once __DIR__ . '/../../inc/poche/myconfig.inc.php';
20// }
21require_once __DIR__ . '/../../inc/poche/User.class.php'; 18require_once __DIR__ . '/../../inc/poche/User.class.php';
22require_once __DIR__ . '/../../inc/poche/Url.class.php'; 19require_once __DIR__ . '/../../inc/poche/Url.class.php';
23require_once __DIR__ . '/../../inc/3rdparty/class.messages.php'; 20require_once __DIR__ . '/../../inc/3rdparty/class.messages.php';
@@ -40,6 +37,7 @@ require_once __DIR__ . '/../../inc/3rdparty/humble-http-agent/CookieJar.php';
40require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedItem.php'; 37require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedItem.php';
41require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedWriter.php'; 38require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedWriter.php';
42require_once __DIR__ . '/../../inc/3rdparty/feedwriter/DummySingleItemFeed.php'; 39require_once __DIR__ . '/../../inc/3rdparty/feedwriter/DummySingleItemFeed.php';
40require_once __DIR__ . '/../../inc/3rdparty/FlattrItem.class.php';
43 41
44if (DOWNLOAD_PICTURES) { 42if (DOWNLOAD_PICTURES) {
45 require_once __DIR__ . '/../../inc/poche/pochePictures.php'; 43 require_once __DIR__ . '/../../inc/poche/pochePictures.php';
diff --git a/inc/poche/define.inc.php b/inc/poche/define.inc.php
index 62777282..40f77b5c 100644
--- a/inc/poche/define.inc.php
+++ b/inc/poche/define.inc.php
@@ -3,7 +3,7 @@
3 * poche, a read it later open source system 3 * poche, a read it later open source system
4 * 4 *
5 * @category poche 5 * @category poche
6 * @author Nicolas Lœuillet <nicolas@loeuillet.org> 6 * @author Nicolas Lœuillet <support@inthepoche.com>
7 * @copyright 2013 7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
@@ -20,9 +20,13 @@ define ('DEBUG_POCHE', FALSE);
20define ('DOWNLOAD_PICTURES', FALSE); 20define ('DOWNLOAD_PICTURES', FALSE);
21define ('SHARE_TWITTER', TRUE); 21define ('SHARE_TWITTER', TRUE);
22define ('SHARE_MAIL', TRUE); 22define ('SHARE_MAIL', TRUE);
23define ('SHARE_SHAARLI', TRUE); 23define ('SHARE_SHAARLI', FALSE);
24define ('SHAARLI_URL', 'http://myshaarliurl.com'); 24define ('SHAARLI_URL', 'http://myshaarliurl.com');
25define ('FLATTR', TRUE); 25define ('FLATTR', TRUE);
26define ('FLATTR_API', 'https://api.flattr.com/rest/v2/things/lookup/?url=');
27define ('NOT_FLATTRABLE', '0');
28define ('FLATTRABLE', '1');
29define ('FLATTRED', '2');
26define ('ABS_PATH', 'assets/'); 30define ('ABS_PATH', 'assets/');
27define ('TPL', __DIR__ . '/../../tpl'); 31define ('TPL', __DIR__ . '/../../tpl');
28define ('LOCALE', __DIR__ . '/../../locale'); 32define ('LOCALE', __DIR__ . '/../../locale');