]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge branch 'dev' of git://github.com/tcitworld/poche into tcitworld-dev
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Thu, 3 Oct 2013 12:51:20 +0000 (14:51 +0200)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Thu, 3 Oct 2013 12:51:20 +0000 (14:51 +0200)
inc/3rdparty/FlattrItem.class.php
inc/poche/Poche.class.php

index c940fcd65c63621da772c26030d1ee8389e947c2..2b7ea3fac0e2e7d47ed228fd7fd24048fce5c2fb 100644 (file)
@@ -9,9 +9,10 @@ class FlattrItem {
     public $flattrItemURL;
     public $numflattrs;
 
-    public function checkItem($urltoflattr) {
-        $this->cacheflattrfile($urltoflattr);
-        $flattrResponse = file_get_contents(CACHE . "/flattr/".base64_encode($urltoflattr).".cache");
+    public function checkItem($urltoflattr,$id) {
+        $this->cacheflattrfile($urltoflattr, $id);
+        $flattrResponse = file_get_contents(CACHE . "/flattr/".$id.".cache");
+        print_r($flattrResponse);
         if($flattrResponse != FALSE) {
             $result = json_decode($flattrResponse);
             if (isset($result->message)){
@@ -33,15 +34,15 @@ class FlattrItem {
         }
     }
 
-    private function cacheflattrfile($urltoflattr) {
+    private function cacheflattrfile($urltoflattr, $id) {
         if (!is_dir(CACHE . '/flattr')) {
             mkdir(CACHE . '/flattr', 0777);
         }
 
         // 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
-        if ((!file_exists(CACHE . "/flattr/".base64_encode($urltoflattr).".cache")) || (time() - filemtime(CACHE . "/flattr/".base64_encode($urltoflattr).".cache") > 86400)) {
+        if ((!file_exists(CACHE . "/flattr/".$id.".cache")) || (time() - filemtime(CACHE . "/flattr/".$id.".cache") > 86400)) {
             $askForFlattr = Tools::getFile(FLATTR_API . $urltoflattr);
-            $flattrCacheFile = fopen(CACHE . "/flattr/".base64_encode($urltoflattr).".cache", 'w+');
+            $flattrCacheFile = fopen(CACHE . "/flattr/".$id.".cache", 'w+');
             fwrite($flattrCacheFile, $askForFlattr);
             fclose($flattrCacheFile);
         }
index 8567cd8fb8ec30d126e8330c8572dfb5c9b5a5f7..8f54267dfa1f9883cb660c045f43713085566c94 100644 (file)
@@ -388,7 +388,7 @@ class Poche
 
                     # flattr checking
                     $flattr = new FlattrItem();
-                    $flattr->checkItem($entry['url']);
+                    $flattr->checkItem($entry['url'],$entry['id']);
 
                     $tpl_vars = array(
                     'entry' => $entry,