1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-11-30 12:52:24 -05:00

Merge branch 'dev' of git://github.com/tcitworld/poche into tcitworld-dev

This commit is contained in:
Nicolas Lœuillet 2013-10-03 14:51:20 +02:00
commit 747c6698b6
2 changed files with 8 additions and 7 deletions

View File

@ -9,9 +9,10 @@ class FlattrItem {
public $flattrItemURL; public $flattrItemURL;
public $numflattrs; public $numflattrs;
public function checkItem($urltoflattr) { public function checkItem($urltoflattr,$id) {
$this->cacheflattrfile($urltoflattr); $this->cacheflattrfile($urltoflattr, $id);
$flattrResponse = file_get_contents(CACHE . "/flattr/".base64_encode($urltoflattr).".cache"); $flattrResponse = file_get_contents(CACHE . "/flattr/".$id.".cache");
print_r($flattrResponse);
if($flattrResponse != FALSE) { if($flattrResponse != FALSE) {
$result = json_decode($flattrResponse); $result = json_decode($flattrResponse);
if (isset($result->message)){ if (isset($result->message)){
@ -33,15 +34,15 @@ class FlattrItem {
} }
} }
private function cacheflattrfile($urltoflattr) { private function cacheflattrfile($urltoflattr, $id) {
if (!is_dir(CACHE . '/flattr')) { if (!is_dir(CACHE . '/flattr')) {
mkdir(CACHE . '/flattr', 0777); 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 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); $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); fwrite($flattrCacheFile, $askForFlattr);
fclose($flattrCacheFile); fclose($flattrCacheFile);
} }

View File

@ -388,7 +388,7 @@ class Poche
# flattr checking # flattr checking
$flattr = new FlattrItem(); $flattr = new FlattrItem();
$flattr->checkItem($entry['url']); $flattr->checkItem($entry['url'],$entry['id']);
$tpl_vars = array( $tpl_vars = array(
'entry' => $entry, 'entry' => $entry,