diff options
Diffstat (limited to 'src/Wallabag/Wallabag/FlattrItem.php')
-rw-r--r-- | src/Wallabag/Wallabag/FlattrItem.php | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/Wallabag/Wallabag/FlattrItem.php b/src/Wallabag/Wallabag/FlattrItem.php deleted file mode 100644 index 17eccd3f..00000000 --- a/src/Wallabag/Wallabag/FlattrItem.php +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
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 | |||
11 | namespace Wallabag\Wallabag; | ||
12 | |||
13 | class FlattrItem | ||
14 | { | ||
15 | public $status; | ||
16 | public $urlToFlattr; | ||
17 | public $flattrItemURL; | ||
18 | public $numFlattrs; | ||
19 | |||
20 | public function checkItem($urlToFlattr, $id) | ||
21 | { | ||
22 | $this->_cacheFlattrFile($urlToFlattr, $id); | ||
23 | $flattrResponse = file_get_contents(CACHE . "/flattr/".$id.".cache"); | ||
24 | if($flattrResponse != FALSE) { | ||
25 | $result = json_decode($flattrResponse); | ||
26 | if (isset($result->message)) { | ||
27 | if ($result->message == "flattrable") { | ||
28 | $this->status = FLATTRABLE; | ||
29 | } | ||
30 | } | ||
31 | elseif (is_object($result) && $result->link) { | ||
32 | $this->status = FLATTRED; | ||
33 | $this->flattrItemURL = $result->link; | ||
34 | $this->numFlattrs = $result->flattrs; | ||
35 | } | ||
36 | else { | ||
37 | $this->status = NOT_FLATTRABLE; | ||
38 | } | ||
39 | } | ||
40 | else { | ||
41 | $this->status = "FLATTR_ERR_CONNECTION"; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | private function _cacheFlattrFile($urlToFlattr, $id) | ||
46 | { | ||
47 | if (!is_dir(CACHE . '/flattr')) { | ||
48 | mkdir(CACHE . '/flattr', 0777); | ||
49 | } | ||
50 | |||
51 | // 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 | ||
52 | if ((!file_exists(CACHE . "/flattr/".$id.".cache")) || (time() - filemtime(CACHE . "/flattr/".$id.".cache") > 86400)) { | ||
53 | $askForFlattr = Tools::getFile(FLATTR_API . $urlToFlattr); | ||
54 | $flattrCacheFile = fopen(CACHE . "/flattr/".$id.".cache", 'w+'); | ||
55 | fwrite($flattrCacheFile, $askForFlattr); | ||
56 | fclose($flattrCacheFile); | ||
57 | } | ||
58 | } | ||
59 | } | ||