aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--inc/3rdparty/libraries/feedwriter/FeedItem.php354
-rwxr-xr-xinc/poche/Poche.class.php65
2 files changed, 216 insertions, 203 deletions
diff --git a/inc/3rdparty/libraries/feedwriter/FeedItem.php b/inc/3rdparty/libraries/feedwriter/FeedItem.php
index 0eae5e08..7e467ce8 100644
--- a/inc/3rdparty/libraries/feedwriter/FeedItem.php
+++ b/inc/3rdparty/libraries/feedwriter/FeedItem.php
@@ -10,177 +10,189 @@
10 */ 10 */
11 class FeedItem 11 class FeedItem
12 { 12 {
13 private $elements = array(); //Collection of feed elements 13 private $elements = array(); //Collection of feed elements
14 private $version; 14 private $version;
15 15
16 /** 16 /**
17 * Constructor 17 * Constructor
18 * 18 *
19 * @param contant (RSS1/RSS2/ATOM) RSS2 is default. 19 * @param contant (RSS1/RSS2/ATOM) RSS2 is default.
20 */ 20 */
21 function __construct($version = RSS2) 21 function __construct($version = RSS2)
22 { 22 {
23 $this->version = $version; 23 $this->version = $version;
24 } 24 }
25 25
26 /** 26 /**
27 * Set element (overwrites existing elements with $elementName) 27 * Set element (overwrites existing elements with $elementName)
28 * 28 *
29 * @access public 29 * @access public
30 * @param srting The tag name of an element 30 * @param srting The tag name of an element
31 * @param srting The content of tag 31 * @param srting The content of tag
32 * @param array Attributes(if any) in 'attrName' => 'attrValue' format 32 * @param array Attributes(if any) in 'attrName' => 'attrValue' format
33 * @return void 33 * @return void
34 */ 34 */
35 public function setElement($elementName, $content, $attributes = null) 35 public function setElement($elementName, $content, $attributes = null)
36 { 36 {
37 if (isset($this->elements[$elementName])) { 37 if (isset($this->elements[$elementName])) {
38 unset($this->elements[$elementName]); 38 unset($this->elements[$elementName]);
39 } 39 }
40 $this->addElement($elementName, $content, $attributes); 40 $this->addElement($elementName, $content, $attributes);
41 } 41 }
42 42
43 /** 43 /**
44 * Add an element to elements array 44 * Add an element to elements array
45 * 45 *
46 * @access public 46 * @access public
47 * @param srting The tag name of an element 47 * @param srting The tag name of an element
48 * @param srting The content of tag 48 * @param srting The content of tag
49 * @param array Attributes(if any) in 'attrName' => 'attrValue' format 49 * @param array Attributes(if any) in 'attrName' => 'attrValue' format
50 * @return void 50 * @return void
51 */ 51 */
52 public function addElement($elementName, $content, $attributes = null) 52 public function addElement($elementName, $content, $attributes = null)
53 { 53 {
54 $i = 0; 54 $i = 0;
55 if (isset($this->elements[$elementName])) { 55 if (isset($this->elements[$elementName])) {
56 $i = count($this->elements[$elementName]); 56 $i = count($this->elements[$elementName]);
57 } else { 57 } else {
58 $this->elements[$elementName] = array(); 58 $this->elements[$elementName] = array();
59 } 59 }
60 $this->elements[$elementName][$i]['name'] = $elementName; 60 $this->elements[$elementName][$i]['name'] = $elementName;
61 $this->elements[$elementName][$i]['content'] = $content; 61 $this->elements[$elementName][$i]['content'] = $content;
62 $this->elements[$elementName][$i]['attributes'] = $attributes; 62 $this->elements[$elementName][$i]['attributes'] = $attributes;
63 } 63 }
64 64
65 /** 65 /**
66 * Set multiple feed elements from an array. 66 * Set multiple feed elements from an array.
67 * Elements which have attributes cannot be added by this method 67 * Elements which have attributes cannot be added by this method
68 * 68 *
69 * @access public 69 * @access public
70 * @param array array of elements in 'tagName' => 'tagContent' format. 70 * @param array array of elements in 'tagName' => 'tagContent' format.
71 * @return void 71 * @return void
72 */ 72 */
73 public function addElementArray($elementArray) 73 public function addElementArray($elementArray)
74 { 74 {
75 if(! is_array($elementArray)) return; 75 if(! is_array($elementArray)) return;
76 foreach ($elementArray as $elementName => $content) 76 foreach ($elementArray as $elementName => $content)
77 { 77 {
78 $this->addElement($elementName, $content); 78 $this->addElement($elementName, $content);
79 } 79 }
80 } 80 }
81 81
82 /** 82 /**
83 * Return the collection of elements in this feed item 83 * Return the collection of elements in this feed item
84 * 84 *
85 * @access public 85 * @access public
86 * @return array 86 * @return array
87 */ 87 */
88 public function getElements() 88 public function getElements()
89 { 89 {
90 return $this->elements; 90 return $this->elements;
91 } 91 }
92 92
93 // Wrapper functions ------------------------------------------------------ 93 // Wrapper functions ------------------------------------------------------
94 94
95 /** 95 /**
96 * Set the 'dscription' element of feed item 96 * Set the 'dscription' element of feed item
97 * 97 *
98 * @access public 98 * @access public
99 * @param string The content of 'description' element 99 * @param string The content of 'description' element
100 * @return void 100 * @return void
101 */ 101 */
102 public function setDescription($description) 102 public function setDescription($description)
103 { 103 {
104 $tag = 'description'; 104 $tag = 'description';
105 $this->setElement($tag, $description); 105 $this->setElement($tag, $description);
106 } 106 }
107 107
108 /** 108 /**
109 * @desc Set the 'title' element of feed item 109 * @desc Set the 'title' element of feed item
110 * @access public 110 * @access public
111 * @param string The content of 'title' element 111 * @param string The content of 'title' element
112 * @return void 112 * @return void
113 */ 113 */
114 public function setTitle($title) 114 public function setTitle($title)
115 { 115 {
116 $this->setElement('title', $title); 116 $this->setElement('title', $title);
117 } 117 }
118 118
119 /** 119 /**
120 * Set the 'date' element of feed item 120 * Set the 'date' element of feed item
121 * 121 *
122 * @access public 122 * @access public
123 * @param string The content of 'date' element 123 * @param string The content of 'date' element
124 * @return void 124 * @return void
125 */ 125 */
126 public function setDate($date) 126 public function setDate($date)
127 { 127 {
128 if(! is_numeric($date)) 128 if(! is_numeric($date))
129 { 129 {
130 $date = strtotime($date); 130 $date = strtotime($date);
131 } 131 }
132 132
133 if($this->version == RSS2) 133 if($this->version == RSS2)
134 { 134 {
135 $tag = 'pubDate'; 135 $tag = 'pubDate';
136 $value = date(DATE_RSS, $date); 136 $value = date(DATE_RSS, $date);
137 } 137 }
138 else 138 else
139 { 139 {
140 $tag = 'dc:date'; 140 $tag = 'dc:date';
141 $value = date("Y-m-d", $date); 141 $value = date("Y-m-d", $date);
142 } 142 }
143 143
144 $this->setElement($tag, $value); 144 $this->setElement($tag, $value);
145 } 145 }
146 146
147 /** 147 /**
148 * Set the 'link' element of feed item 148 * Set the 'link' element of feed item
149 * 149 *
150 * @access public 150 * @access public
151 * @param string The content of 'link' element 151 * @param string The content of 'link' element
152 * @return void 152 * @return void
153 */ 153 */
154 public function setLink($link) 154 public function setLink($link)
155 { 155 {
156 if($this->version == RSS2 || $this->version == RSS1) 156 if($this->version == RSS2 || $this->version == RSS1)
157 { 157 {
158 $this->setElement('link', $link); 158 $this->setElement('link', $link);
159 $this->setElement('guid', $link); 159 $this->setElement('guid', $link);
160 } 160 }
161 else 161 else
162 { 162 {
163 $this->setElement('link','',array('href'=>$link)); 163 $this->setElement('link','',array('href'=>$link));
164 $this->setElement('id', FeedWriter::uuid($link,'urn:uuid:')); 164 $this->setElement('id', FeedWriter::uuid($link,'urn:uuid:'));
165 } 165 }
166 166
167 } 167 }
168 168
169 /** 169 /**
170 * Set the 'encloser' element of feed item 170 * Set the 'source' element of feed item
171 * For RSS 2.0 only 171 *
172 * 172 * @access public
173 * @access public 173 * @param string The content of 'source' element
174 * @param string The url attribute of encloser tag 174 * @return void
175 * @param string The length attribute of encloser tag 175 */
176 * @param string The type attribute of encloser tag 176 public function setSource($link)
177 * @return void 177 {
178 */ 178 $this->setElement('source', $link);
179 public function setEncloser($url, $length, $type) 179 }
180 { 180
181 $attributes = array('url'=>$url, 'length'=>$length, 'type'=>$type); 181 /**
182 $this->setElement('enclosure','',$attributes); 182 * Set the 'encloser' element of feed item
183 } 183 * For RSS 2.0 only
184 184 *
185 * @access public
186 * @param string The url attribute of encloser tag
187 * @param string The length attribute of encloser tag
188 * @param string The type attribute of encloser tag
189 * @return void
190 */
191 public function setEncloser($url, $length, $type)
192 {
193 $attributes = array('url'=>$url, 'length'=>$length, 'type'=>$type);
194 $this->setElement('enclosure','',$attributes);
195 }
196
185 } // end of class FeedItem 197 } // end of class FeedItem
186?> 198?> \ No newline at end of file
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&amp;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']);