aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2015-01-19 11:29:25 +0100
committerNicolas Lœuillet <nicolas@loeuillet.org>2015-01-19 11:29:25 +0100
commitdda7884ace3a3906b65668669fb67b37f596fd62 (patch)
tree28bd16f76ce3ca307b8f7384083b1b1f13c54551 /inc/poche
parent10939766de3b6fb677e8acdd74220ad2da612a26 (diff)
downloadwallabag-dda7884ace3a3906b65668669fb67b37f596fd62.tar.gz
wallabag-dda7884ace3a3906b65668669fb67b37f596fd62.tar.zst
wallabag-dda7884ace3a3906b65668669fb67b37f596fd62.zip
pagination with composer and move FlattrItem
Diffstat (limited to 'inc/poche')
-rw-r--r--inc/poche/FlattrItem.class.php57
-rwxr-xr-xinc/poche/global.inc.php2
2 files changed, 58 insertions, 1 deletions
diff --git a/inc/poche/FlattrItem.class.php b/inc/poche/FlattrItem.class.php
new file mode 100644
index 00000000..ef8c62f7
--- /dev/null
+++ b/inc/poche/FlattrItem.class.php
@@ -0,0 +1,57 @@
1<?php
2/**
3 * wallabag, self hostable application allowing you to not miss any content anymore
4 *
5 * @category wallabag
6 * @author Nicolas Lœuillet <nicolas@loeuillet.org>
7 * @copyright 2013
8 * @license http://opensource.org/licenses/MIT see COPYING file
9 */
10
11class FlattrItem
12{
13 public $status;
14 public $urlToFlattr;
15 public $flattrItemURL;
16 public $numFlattrs;
17
18 public function checkItem($urlToFlattr, $id)
19 {
20 $this->_cacheFlattrFile($urlToFlattr, $id);
21 $flattrResponse = file_get_contents(CACHE . "/flattr/".$id.".cache");
22 if($flattrResponse != FALSE) {
23 $result = json_decode($flattrResponse);
24 if (isset($result->message)) {
25 if ($result->message == "flattrable") {
26 $this->status = FLATTRABLE;
27 }
28 }
29 elseif (is_object($result) && $result->link) {
30 $this->status = FLATTRED;
31 $this->flattrItemURL = $result->link;
32 $this->numFlattrs = $result->flattrs;
33 }
34 else {
35 $this->status = NOT_FLATTRABLE;
36 }
37 }
38 else {
39 $this->status = "FLATTR_ERR_CONNECTION";
40 }
41 }
42
43 private function _cacheFlattrFile($urlToFlattr, $id)
44 {
45 if (!is_dir(CACHE . '/flattr')) {
46 mkdir(CACHE . '/flattr', 0777);
47 }
48
49 // 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
50 if ((!file_exists(CACHE . "/flattr/".$id.".cache")) || (time() - filemtime(CACHE . "/flattr/".$id.".cache") > 86400)) {
51 $askForFlattr = Tools::getFile(FLATTR_API . $urlToFlattr);
52 $flattrCacheFile = fopen(CACHE . "/flattr/".$id.".cache", 'w+');
53 fwrite($flattrCacheFile, $askForFlattr);
54 fclose($flattrCacheFile);
55 }
56 }
57}
diff --git a/inc/poche/global.inc.php b/inc/poche/global.inc.php
index 4d119456..c17d54e6 100755
--- a/inc/poche/global.inc.php
+++ b/inc/poche/global.inc.php
@@ -29,7 +29,7 @@ require_once INCLUDES . '/3rdparty/paginator.php';
29 29
30require_once INCLUDES . '/3rdparty/libraries/feedwriter/FeedItem.php'; 30require_once INCLUDES . '/3rdparty/libraries/feedwriter/FeedItem.php';
31require_once INCLUDES . '/3rdparty/libraries/feedwriter/FeedWriter.php'; 31require_once INCLUDES . '/3rdparty/libraries/feedwriter/FeedWriter.php';
32require_once INCLUDES . '/3rdparty/FlattrItem.class.php'; 32require_once INCLUDES . '/poche/FlattrItem.class.php';
33 33
34# epub library 34# epub library
35require_once INCLUDES . '/3rdparty/libraries/PHPePub/Logger.php'; 35require_once INCLUDES . '/3rdparty/libraries/PHPePub/Logger.php';