diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-04-06 16:40:17 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-04-06 16:40:17 +0200 |
commit | 292cd0dbd579961cd43ab8fdedb190a9e4d82e7c (patch) | |
tree | 65c238e4234c57b209327472cd60b01255506575 /inc/poche | |
parent | 2dd5c1e4a30599a3478a055cb804d182e50d615e (diff) | |
parent | f86784c22d63ebd8315d0f86befa626779e36ff3 (diff) | |
download | wallabag-292cd0dbd579961cd43ab8fdedb190a9e4d82e7c.tar.gz wallabag-292cd0dbd579961cd43ab8fdedb190a9e4d82e7c.tar.zst wallabag-292cd0dbd579961cd43ab8fdedb190a9e4d82e7c.zip |
Merge pull request #606 from wallabag/fix-556
in RSS feed, add link to wallabag URL #556
Diffstat (limited to 'inc/poche')
-rwxr-xr-x | inc/poche/Poche.class.php | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index a662f695..a7bee65d 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -828,7 +828,7 @@ class Poche | |||
828 | define('IMPORT_LIMIT', 5); | 828 | define('IMPORT_LIMIT', 5); |
829 | } | 829 | } |
830 | if (!defined('IMPORT_DELAY')) { | 830 | if (!defined('IMPORT_DELAY')) { |
831 | define('IMPORT_DELAY', 5); | 831 | define('IMPORT_DELAY', 5); |
832 | } | 832 | } |
833 | 833 | ||
834 | if ( isset($_FILES['file']) ) { | 834 | if ( isset($_FILES['file']) ) { |
@@ -844,18 +844,18 @@ class Poche | |||
844 | $read = 0; | 844 | $read = 0; |
845 | foreach (array('ol','ul') as $list) { | 845 | foreach (array('ol','ul') as $list) { |
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); |
859 | } | 859 | } |
860 | } | 860 | } |
861 | } | 861 | } |
@@ -866,7 +866,7 @@ class Poche | |||
866 | $data[] = $record; | 866 | $data[] = $record; |
867 | foreach ($record as $record2) { | 867 | foreach ($record as $record2) { |
868 | if (is_array($record2)) { | 868 | if (is_array($record2)) { |
869 | $data[] = $record2; | 869 | $data[] = $record2; |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
@@ -886,7 +886,7 @@ class Poche | |||
886 | //increment no of records inserted | 886 | //increment no of records inserted |
887 | $i++; | 887 | $i++; |
888 | if ( isset($record['tags']) && trim($record['tags']) ) { | 888 | if ( isset($record['tags']) && trim($record['tags']) ) { |
889 | //@TODO: set tags | 889 | //@TODO: set tags |
890 | 890 | ||
891 | } | 891 | } |
892 | } | 892 | } |
@@ -919,17 +919,17 @@ class Poche | |||
919 | $purifier = new HTMLPurifier($config); | 919 | $purifier = new HTMLPurifier($config); |
920 | 920 | ||
921 | foreach ($items as $item) { | 921 | foreach ($items as $item) { |
922 | $url = new Url(base64_encode($item['url'])); | 922 | $url = new Url(base64_encode($item['url'])); |
923 | $content = Tools::getPageContent($url); | 923 | $content = Tools::getPageContent($url); |
924 | 924 | ||
925 | $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled')); | 925 | $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled')); |
926 | $body = (($content['rss']['channel']['item']['description'] != '') ? $content['rss']['channel']['item']['description'] : _('Undefined')); | 926 | $body = (($content['rss']['channel']['item']['description'] != '') ? $content['rss']['channel']['item']['description'] : _('Undefined')); |
927 | 927 | ||
928 | //clean content to prevent xss attack | 928 | //clean content to prevent xss attack |
929 | $title = $purifier->purify($title); | 929 | $title = $purifier->purify($title); |
930 | $body = $purifier->purify($body); | 930 | $body = $purifier->purify($body); |
931 | 931 | ||
932 | $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId()); | 932 | $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId()); |
933 | } | 933 | } |
934 | 934 | ||
935 | } | 935 | } |
@@ -944,8 +944,8 @@ class Poche | |||
944 | */ | 944 | */ |
945 | public function export() | 945 | public function export() |
946 | { | 946 | { |
947 | $filename = "wallabag-export-".$this->user->getId()."-".date("Y-m-d").".json"; | 947 | $filename = "wallabag-export-".$this->user->getId()."-".date("Y-m-d").".json"; |
948 | header('Content-Disposition: attachment; filename='.$filename); | 948 | header('Content-Disposition: attachment; filename='.$filename); |
949 | 949 | ||
950 | $entries = $this->store->retrieveAll($this->user->getId()); | 950 | $entries = $this->store->retrieveAll($this->user->getId()); |
951 | echo $this->tpl->render('export.twig', array( | 951 | echo $this->tpl->render('export.twig', array( |
@@ -978,13 +978,13 @@ class Poche | |||
978 | public function generateToken() | 978 | public function generateToken() |
979 | { | 979 | { |
980 | if (ini_get('open_basedir') === '') { | 980 | if (ini_get('open_basedir') === '') { |
981 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { | 981 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
982 | echo 'This is a server using Windows!'; | 982 | echo 'This is a server using Windows!'; |
983 | // alternative to /dev/urandom for Windows | 983 | // alternative to /dev/urandom for Windows |
984 | $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); | 984 | $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); |
985 | } else { | 985 | } else { |
986 | $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); | 986 | $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | else { | 989 | else { |
990 | $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); | 990 | $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); |
@@ -1031,6 +1031,7 @@ class Poche | |||
1031 | foreach ($entries as $entry) { | 1031 | foreach ($entries as $entry) { |
1032 | $newItem = $feed->createNewItem(); | 1032 | $newItem = $feed->createNewItem(); |
1033 | $newItem->setTitle($entry['title']); | 1033 | $newItem->setTitle($entry['title']); |
1034 | $newItem->setSource(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']); | ||
1034 | $newItem->setLink($entry['url']); | 1035 | $newItem->setLink($entry['url']); |
1035 | $newItem->setDate(time()); | 1036 | $newItem->setDate(time()); |
1036 | $newItem->setDescription($entry['content']); | 1037 | $newItem->setDescription($entry['content']); |