diff options
Diffstat (limited to 'inc/poche')
-rw-r--r-- | inc/poche/Database.class.php | 6 | ||||
-rw-r--r-- | inc/poche/Poche.class.php | 59 | ||||
-rw-r--r-- | inc/poche/pochePictures.php | 6 |
3 files changed, 38 insertions, 33 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index afe02a41..04731821 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -81,7 +81,7 @@ class Database { | |||
81 | 81 | ||
82 | if (STORAGE == 'sqlite') { | 82 | if (STORAGE == 'sqlite') { |
83 | $sql = ' | 83 | $sql = ' |
84 | CREATE TABLE tags_entries ( | 84 | CREATE TABLE IF NOT EXISTS tags_entries ( |
85 | id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, | 85 | id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, |
86 | entry_id INTEGER, | 86 | entry_id INTEGER, |
87 | tag_id INTEGER, | 87 | tag_id INTEGER, |
@@ -337,7 +337,7 @@ class Database { | |||
337 | 337 | ||
338 | public function retrieveEntriesByTag($tag_id) { | 338 | public function retrieveEntriesByTag($tag_id) { |
339 | $sql = | 339 | $sql = |
340 | "SELECT * FROM entries | 340 | "SELECT entries.* FROM entries |
341 | LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id | 341 | LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id |
342 | WHERE tags_entries.tag_id = ?"; | 342 | WHERE tags_entries.tag_id = ?"; |
343 | $query = $this->executeQuery($sql, array($tag_id)); | 343 | $query = $this->executeQuery($sql, array($tag_id)); |
@@ -348,7 +348,7 @@ class Database { | |||
348 | 348 | ||
349 | public function retrieveTagsByEntry($entry_id) { | 349 | public function retrieveTagsByEntry($entry_id) { |
350 | $sql = | 350 | $sql = |
351 | "SELECT * FROM tags | 351 | "SELECT tags.* FROM tags |
352 | LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id | 352 | LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id |
353 | WHERE tags_entries.entry_id = ?"; | 353 | WHERE tags_entries.entry_id = ?"; |
354 | $query = $this->executeQuery($sql, array($entry_id)); | 354 | $query = $this->executeQuery($sql, array($entry_id)); |
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 4f70afb7..76a73be2 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -333,7 +333,9 @@ class Poche | |||
333 | switch ($action) | 333 | switch ($action) |
334 | { | 334 | { |
335 | case 'add': | 335 | case 'add': |
336 | $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed'); | 336 | $options = array('http' => array('user_agent' => 'poche')); |
337 | $context = stream_context_create($options); | ||
338 | $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed', false, $context); | ||
337 | $content = json_decode($json, true); | 339 | $content = json_decode($json, true); |
338 | $title = $content['rss']['channel']['item']['title']; | 340 | $title = $content['rss']['channel']['item']['title']; |
339 | $body = $content['rss']['channel']['item']['description']; | 341 | $body = $content['rss']['channel']['item']['description']; |
@@ -806,34 +808,37 @@ class Poche | |||
806 | $url = NULL; | 808 | $url = NULL; |
807 | $favorite = FALSE; | 809 | $favorite = FALSE; |
808 | $archive = FALSE; | 810 | $archive = FALSE; |
809 | foreach ($value as $attr => $attr_value) { | 811 | foreach ($value as $item) { |
810 | if ($attr == 'article__url') { | 812 | foreach ($item as $attr => $value) { |
811 | $url = new Url(base64_encode($attr_value)); | 813 | if ($attr == 'article__url') { |
812 | } | 814 | $url = new Url(base64_encode($value)); |
813 | $sequence = ''; | ||
814 | if (STORAGE == 'postgres') { | ||
815 | $sequence = 'entries_id_seq'; | ||
816 | } | ||
817 | if ($attr_value == 'true') { | ||
818 | if ($attr == 'favorite') { | ||
819 | $favorite = TRUE; | ||
820 | } | 815 | } |
821 | if ($attr == 'archive') { | 816 | $sequence = ''; |
822 | $archive = TRUE; | 817 | if (STORAGE == 'postgres') { |
818 | $sequence = 'entries_id_seq'; | ||
819 | } | ||
820 | if ($value == 'true') { | ||
821 | if ($attr == 'favorite') { | ||
822 | $favorite = TRUE; | ||
823 | } | ||
824 | if ($attr == 'archive') { | ||
825 | $archive = TRUE; | ||
826 | } | ||
823 | } | 827 | } |
824 | } | 828 | } |
825 | } | 829 | |
826 | # we can add the url | 830 | # we can add the url |
827 | if (!is_null($url) && $url->isCorrect()) { | 831 | if (!is_null($url) && $url->isCorrect()) { |
828 | $this->action('add', $url, 0, TRUE); | 832 | $this->action('add', $url, 0, TRUE); |
829 | $count++; | 833 | $count++; |
830 | if ($favorite) { | 834 | if ($favorite) { |
831 | $last_id = $this->store->getLastId($sequence); | 835 | $last_id = $this->store->getLastId($sequence); |
832 | $this->action('toggle_fav', $url, $last_id, TRUE); | 836 | $this->action('toggle_fav', $url, $last_id, TRUE); |
833 | } | 837 | } |
834 | if ($archive) { | 838 | if ($archive) { |
835 | $last_id = $this->store->getLastId($sequence); | 839 | $last_id = $this->store->getLastId($sequence); |
836 | $this->action('toggle_archive', $url, $last_id, TRUE); | 840 | $this->action('toggle_archive', $url, $last_id, TRUE); |
841 | } | ||
837 | } | 842 | } |
838 | } | 843 | } |
839 | } | 844 | } |
@@ -951,7 +956,7 @@ class Poche | |||
951 | if (count($entries) > 0) { | 956 | if (count($entries) > 0) { |
952 | foreach ($entries as $entry) { | 957 | foreach ($entries as $entry) { |
953 | $newItem = $feed->createNewItem(); | 958 | $newItem = $feed->createNewItem(); |
954 | $newItem->setTitle(htmlentities($entry['title'])); | 959 | $newItem->setTitle($entry['title']); |
955 | $newItem->setLink(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']); | 960 | $newItem->setLink(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']); |
956 | $newItem->setDate(time()); | 961 | $newItem->setDate(time()); |
957 | $newItem->setDescription($entry['content']); | 962 | $newItem->setDescription($entry['content']); |
diff --git a/inc/poche/pochePictures.php b/inc/poche/pochePictures.php index 4e4a0b08..b0cfb9df 100644 --- a/inc/poche/pochePictures.php +++ b/inc/poche/pochePictures.php | |||
@@ -84,12 +84,12 @@ function create_assets_directory($id) | |||
84 | { | 84 | { |
85 | $assets_path = ABS_PATH; | 85 | $assets_path = ABS_PATH; |
86 | if(!is_dir($assets_path)) { | 86 | if(!is_dir($assets_path)) { |
87 | mkdir($assets_path, 0705); | 87 | mkdir($assets_path, 0715); |
88 | } | 88 | } |
89 | 89 | ||
90 | $article_directory = $assets_path . $id; | 90 | $article_directory = $assets_path . $id; |
91 | if(!is_dir($article_directory)) { | 91 | if(!is_dir($article_directory)) { |
92 | mkdir($article_directory, 0705); | 92 | mkdir($article_directory, 0715); |
93 | } | 93 | } |
94 | 94 | ||
95 | return $article_directory; | 95 | return $article_directory; |
@@ -107,4 +107,4 @@ function remove_directory($directory) | |||
107 | } | 107 | } |
108 | return rmdir($directory); | 108 | return rmdir($directory); |
109 | } | 109 | } |
110 | } \ No newline at end of file | 110 | } |