aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
authorMaryana Rozhankivska <mariroz@mr.lviv.ua>2014-04-08 11:49:41 +0300
committerMaryana Rozhankivska <mariroz@mr.lviv.ua>2014-04-08 11:49:41 +0300
commita8ef1f3f43236908fdabebf795cf7de370b538ec (patch)
tree953902d96e26c90f3edaf97879daf86fdbc6ed68 /inc/poche/Poche.class.php
parent86da39886d11e6058199fc7da5adc24d1f84cb76 (diff)
parenta7f39918bf67f189e30381fbbde95184b2f618fa (diff)
downloadwallabag-a8ef1f3f43236908fdabebf795cf7de370b538ec.tar.gz
wallabag-a8ef1f3f43236908fdabebf795cf7de370b538ec.tar.zst
wallabag-a8ef1f3f43236908fdabebf795cf7de370b538ec.zip
code formatting changes: tabs replaced with spaces, some other small formatting enhancements
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-xinc/poche/Poche.class.php95
1 files changed, 47 insertions, 48 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 90fbcb2d..613377c6 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -846,13 +846,13 @@ class Poche
846 foreach ($html->find($list) as $ul) { 846 foreach ($html->find($list) as $ul) {
847 foreach ($ul->find('li') as $li) { 847 foreach ($ul->find('li') as $li) {
848 $tmpEntry = array(); 848 $tmpEntry = array();
849 $a = $li->find('a'); 849 $a = $li->find('a');
850 $tmpEntry['url'] = $a[0]->href; 850 $tmpEntry['url'] = $a[0]->href;
851 $tmpEntry['tags'] = $a[0]->tags; 851 $tmpEntry['tags'] = $a[0]->tags;
852 $tmpEntry['is_read'] = $read; 852 $tmpEntry['is_read'] = $read;
853 if ($tmpEntry['url']) { 853 if ($tmpEntry['url']) {
854 $data[] = $tmpEntry; 854 $data[] = $tmpEntry;
855 } 855 }
856 } 856 }
857 # the second <ol/ul> is for read links 857 # the second <ol/ul> is for read links
858 $read = ((sizeof($data) && $read)?0:1); 858 $read = ((sizeof($data) && $read)?0:1);
@@ -943,16 +943,15 @@ class Poche
943 * export poche entries in json 943 * export poche entries in json
944 * @return json all poche entries 944 * @return json all poche entries
945 */ 945 */
946 public function export() 946 public function export() {
947 { 947 $filename = "wallabag-export-".$this->user->getId()."-".date("Y-m-d").".json";
948 $filename = "wallabag-export-".$this->user->getId()."-".date("Y-m-d").".json"; 948 header('Content-Disposition: attachment; filename='.$filename);
949 header('Content-Disposition: attachment; filename='.$filename); 949
950 950 $entries = $this->store->retrieveAll($this->user->getId());
951 $entries = $this->store->retrieveAll($this->user->getId()); 951 echo $this->tpl->render('export.twig', array(
952 echo $this->tpl->render('export.twig', array( 952 'export' => Tools::renderJson($entries),
953 'export' => Tools::renderJson($entries), 953 ));
954 )); 954 Tools::logm('export view');
955 Tools::logm('export view');
956 } 955 }
957 956
958 /** 957 /**
@@ -960,43 +959,42 @@ class Poche
960 * @param string $which 'prod' or 'dev' 959 * @param string $which 'prod' or 'dev'
961 * @return string latest $which version 960 * @return string latest $which version
962 */ 961 */
963 private function getPocheVersion($which = 'prod') 962 private function getPocheVersion($which = 'prod') {
964 { 963 $cache_file = CACHE . '/' . $which;
965 $cache_file = CACHE . '/' . $which; 964 $check_time = time();
966 $check_time = time(); 965
967 966 # checks if the cached version file exists
968 # checks if the cached version file exists 967 if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 86400 ))) {
969 if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 86400 ))) { 968 $version = file_get_contents($cache_file);
970 $version = file_get_contents($cache_file); 969 $check_time = filemtime($cache_file);
971 $check_time = filemtime($cache_file); 970 } else {
972 } else { 971 $version = file_get_contents('http://static.wallabag.org/versions/' . $which);
973 $version = file_get_contents('http://static.wallabag.org/versions/' . $which); 972 file_put_contents($cache_file, $version, LOCK_EX);
974 file_put_contents($cache_file, $version, LOCK_EX); 973 }
975 } 974 return array($version, $check_time);
976 return array($version, $check_time);
977 } 975 }
978 976
979 public function generateToken() 977 public function generateToken()
980 { 978 {
981 if (ini_get('open_basedir') === '') { 979 if (ini_get('open_basedir') === '') {
982 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { 980 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
983 echo 'This is a server using Windows!'; 981 echo 'This is a server using Windows!';
984 // alternative to /dev/urandom for Windows 982 // alternative to /dev/urandom for Windows
985 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); 983 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
986 } else { 984 } else {
987 $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); 985 $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
988 }
989 }
990 else {
991 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
992 } 986 }
987 }
988 else {
989 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
990 }
993 991
994 $token = str_replace('+', '', $token); 992 $token = str_replace('+', '', $token);
995 $this->store->updateUserConfig($this->user->getId(), 'token', $token); 993 $this->store->updateUserConfig($this->user->getId(), 'token', $token);
996 $currentConfig = $_SESSION['poche_user']->config; 994 $currentConfig = $_SESSION['poche_user']->config;
997 $currentConfig['token'] = $token; 995 $currentConfig['token'] = $token;
998 $_SESSION['poche_user']->setConfig($currentConfig); 996 $_SESSION['poche_user']->setConfig($currentConfig);
999 Tools::redirect(); 997 Tools::redirect();
1000 } 998 }
1001 999
1002 public function generateFeeds($token, $user_id, $tag_id, $type = 'home') 1000 public function generateFeeds($token, $user_id, $tag_id, $type = 'home')
@@ -1032,6 +1030,7 @@ class Poche
1032 foreach ($entries as $entry) { 1030 foreach ($entries as $entry) {
1033 $newItem = $feed->createNewItem(); 1031 $newItem = $feed->createNewItem();
1034 $newItem->setTitle($entry['title']); 1032 $newItem->setTitle($entry['title']);
1033 $newItem->setSource(Tools::getPocheUrl() . '?view=view&amp;id=' . $entry['id']);
1035 $newItem->setLink($entry['url']); 1034 $newItem->setLink($entry['url']);
1036 $newItem->setDate(time()); 1035 $newItem->setDate(time());
1037 $newItem->setDescription($entry['content']); 1036 $newItem->setDescription($entry['content']);