diff options
Diffstat (limited to 'inc/3rdparty')
-rw-r--r-- | inc/3rdparty/FlattrItem.class.php | 26 | ||||
-rw-r--r-- | inc/3rdparty/Session.class.php | 34 |
2 files changed, 51 insertions, 9 deletions
diff --git a/inc/3rdparty/FlattrItem.class.php b/inc/3rdparty/FlattrItem.class.php index 711b4ee0..5cf9e5fc 100644 --- a/inc/3rdparty/FlattrItem.class.php +++ b/inc/3rdparty/FlattrItem.class.php | |||
@@ -1,25 +1,32 @@ | |||
1 | <?php | 1 | <?php |
2 | /* | 2 | /** |
3 | * Class for Flattr querying | 3 | * wallabag, self hostable application allowing you to not miss any content anymore |
4 | */ | 4 | * |
5 | class FlattrItem { | 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 | */ | ||
6 | 10 | ||
11 | class FlattrItem | ||
12 | { | ||
7 | public $status; | 13 | public $status; |
8 | public $urltoflattr; | 14 | public $urltoflattr; |
9 | public $flattrItemURL; | 15 | public $flattrItemURL; |
10 | public $numflattrs; | 16 | public $numflattrs; |
11 | 17 | ||
12 | public function checkItem($urltoflattr,$id) { | 18 | public function checkItem($urltoflattr, $id) |
13 | $this->cacheflattrfile($urltoflattr, $id); | 19 | { |
20 | $this->_cacheflattrfile($urltoflattr, $id); | ||
14 | $flattrResponse = file_get_contents(CACHE . "/flattr/".$id.".cache"); | 21 | $flattrResponse = file_get_contents(CACHE . "/flattr/".$id.".cache"); |
15 | if($flattrResponse != FALSE) { | 22 | if($flattrResponse != FALSE) { |
16 | $result = json_decode($flattrResponse); | 23 | $result = json_decode($flattrResponse); |
17 | if (isset($result->message)){ | 24 | if (isset($result->message)) { |
18 | if ($result->message == "flattrable") { | 25 | if ($result->message == "flattrable") { |
19 | $this->status = FLATTRABLE; | 26 | $this->status = FLATTRABLE; |
20 | } | 27 | } |
21 | } | 28 | } |
22 | elseif (is_object($result) && $result->link) { | 29 | elseif (is_object($result) && $result->link) { |
23 | $this->status = FLATTRED; | 30 | $this->status = FLATTRED; |
24 | $this->flattrItemURL = $result->link; | 31 | $this->flattrItemURL = $result->link; |
25 | $this->numflattrs = $result->flattrs; | 32 | $this->numflattrs = $result->flattrs; |
@@ -33,7 +40,8 @@ class FlattrItem { | |||
33 | } | 40 | } |
34 | } | 41 | } |
35 | 42 | ||
36 | private function cacheflattrfile($urltoflattr, $id) { | 43 | private function _cacheflattrfile($urltoflattr, $id) |
44 | { | ||
37 | if (!is_dir(CACHE . '/flattr')) { | 45 | if (!is_dir(CACHE . '/flattr')) { |
38 | mkdir(CACHE . '/flattr', 0777); | 46 | mkdir(CACHE . '/flattr', 0777); |
39 | } | 47 | } |
diff --git a/inc/3rdparty/Session.class.php b/inc/3rdparty/Session.class.php index 59dfbe67..b56e4c54 100644 --- a/inc/3rdparty/Session.class.php +++ b/inc/3rdparty/Session.class.php | |||
@@ -309,4 +309,38 @@ class Session | |||
309 | 309 | ||
310 | return true; // User is not banned. | 310 | return true; // User is not banned. |
311 | } | 311 | } |
312 | |||
313 | |||
314 | /** | ||
315 | * Tells if a param exists in session | ||
316 | * | ||
317 | * @param $name name of the param to test | ||
318 | * @return bool | ||
319 | */ | ||
320 | public static function isInSession($name) | ||
321 | { | ||
322 | return (isset($_SESSION[$name]) ? : FALSE); | ||
323 | } | ||
324 | |||
325 | /** | ||
326 | * Returns param in session | ||
327 | * | ||
328 | * @param $name name of the param to return | ||
329 | * @return mixed param or null | ||
330 | */ | ||
331 | public static function getParam($name) | ||
332 | { | ||
333 | return (self::isInSession($name) ? $_SESSION[$name] : NULL); | ||
334 | } | ||
335 | |||
336 | /** | ||
337 | * Store value in session | ||
338 | * | ||
339 | * @param $name name of the variable to store | ||
340 | * @param $value value to store | ||
341 | */ | ||
342 | public static function setParam($name, $value) | ||
343 | { | ||
344 | $_SESSION[$name] = $value; | ||
345 | } | ||
312 | } | 346 | } |