From 72c20a52978f31b84ffc817894f9f85f4a8506ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 3 Dec 2013 10:40:27 +0100 Subject: [add] atom feeds for unread / fav items --- inc/poche/Poche.class.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 3ecaf084..ac66dfc9 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -412,6 +412,7 @@ class Poche $compare_prod = version_compare(POCHE, $prod); $themes = $this->getInstalledThemes(); $languages = $this->getInstalledLanguages(); + $token = $this->user->getConfigValue('token'); $http_auth = (isset($_SERVER['PHP_AUTH_USER']))?true:false; $tpl_vars = array( 'themes' => $themes, @@ -420,6 +421,8 @@ class Poche 'prod' => $prod, 'compare_dev' => $compare_dev, 'compare_prod' => $compare_prod, + 'token' => $token, + 'user_id' => $this->user->getId(), 'http_auth' => $http_auth, ); Tools::logm('config view'); @@ -837,4 +840,52 @@ class Poche } return $version; } + + public function generateToken() + { + if (ini_get('open_basedir') === '') { + $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); + } + else { + $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); + } + + $this->store->updateUserConfig($this->user->getId(), 'token', $token); + $currentConfig = $_SESSION['poche_user']->config; + $currentConfig['token'] = $token; + $_SESSION['poche_user']->setConfig($currentConfig); + } + + public function generateFeeds($token, $user_id, $type = 'home') + { + $allowed_types = array('home', 'fav'); + $config = $this->store->getConfigUser($user_id); + + if (!in_array($type, $allowed_types) || + $token != $config['token']) { + die(_('Uh, there is a problem while generating feeds.')); + } + // Check the token + + $feed = new FeedWriter(ATOM); + $feed->setTitle('poche - ' . $type . ' feed'); + $feed->setLink(Tools::getPocheUrl()); + $feed->setChannelElement('updated', date(DATE_ATOM , time())); + $feed->setChannelElement('author', 'poche'); + + $entries = $this->store->getEntriesByView($type, $user_id); + if (count($entries) > 0) { + foreach ($entries as $entry) { + $newItem = $feed->createNewItem(); + $newItem->setTitle(htmlentities($entry['title'])); + $newItem->setLink(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']); + $newItem->setDate(time()); + $newItem->setDescription($entry['content']); + $feed->addItem($newItem); + } + } + + $feed->genarateFeed(); + exit; + } } -- cgit v1.2.3 From 59cc585271a5f253b15617d97e26a29403a929dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 5 Dec 2013 15:13:32 +0100 Subject: [add] add RSS feed for archive --- inc/poche/Poche.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index ac66dfc9..a8a54ff0 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -858,7 +858,7 @@ class Poche public function generateFeeds($token, $user_id, $type = 'home') { - $allowed_types = array('home', 'fav'); + $allowed_types = array('home', 'fav', 'archive'); $config = $this->store->getConfigUser($user_id); if (!in_array($type, $allowed_types) || -- cgit v1.2.3 From 42c80841c846610be280218d53fcde06b0f0063b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 09:45:27 +0100 Subject: [change] we now use Full-Text RSS 3.1, thank you so much @fivefilters --- inc/poche/Poche.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index a8a54ff0..5862befb 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -332,9 +332,12 @@ class Poche switch ($action) { case 'add': - $content = $url->extract(); + $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed'); + $content = json_decode($json, true); + $title = $content['rss']['channel']['item']['title']; + $body = $content['rss']['channel']['item']['description']; - if ($this->store->add($url->getUrl(), $content['title'], $content['body'], $this->user->getId())) { + if ($this->store->add($url->getUrl(), $title, $body, $this->user->getId())) { Tools::logm('add link ' . $url->getUrl()); $sequence = ''; if (STORAGE == 'postgres') { @@ -342,7 +345,7 @@ class Poche } $last_id = $this->store->getLastId($sequence); if (DOWNLOAD_PICTURES) { - $content = filtre_picture($content['body'], $url->getUrl(), $last_id); + $content = filtre_picture($body, $url->getUrl(), $last_id); Tools::logm('updating content article'); $this->store->updateContent($last_id, $content, $this->user->getId()); } -- cgit v1.2.3 From 9e7c840b186fb4ad2cd3768cec49ee348facf3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 10:14:59 +0100 Subject: [fix] RSS feeds were buggy when I update full-text RSS --- inc/poche/Poche.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 5862befb..d45d0c40 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -870,10 +870,10 @@ class Poche } // Check the token - $feed = new FeedWriter(ATOM); + $feed = new FeedWriter(RSS2); $feed->setTitle('poche - ' . $type . ' feed'); $feed->setLink(Tools::getPocheUrl()); - $feed->setChannelElement('updated', date(DATE_ATOM , time())); + $feed->setChannelElement('updated', date(DATE_RSS , time())); $feed->setChannelElement('author', 'poche'); $entries = $this->store->getEntriesByView($type, $user_id); -- cgit v1.2.3 From 7b171c73400ff2c0b8f3634e35d186b22176759b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 13:02:38 +0100 Subject: [add] send tags to article view --- inc/poche/Poche.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index d45d0c40..c9fb6382 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -443,12 +443,16 @@ class Poche # flattr checking $flattr = new FlattrItem(); - $flattr->checkItem($entry['url'],$entry['id']); + $flattr->checkItem($entry['url'], $entry['id']); + + # tags + $tags = $this->store->retrieveTagsByEntry($entry['id']); $tpl_vars = array( - 'entry' => $entry, - 'content' => $content, - 'flattr' => $flattr + 'entry' => $entry, + 'content' => $content, + 'flattr' => $flattr, + 'tags' => $tags ); } else { -- cgit v1.2.3 From 2e2ebe5ec767dcbee90394d12b03298592c87805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 13:15:06 +0100 Subject: [add] create tags page --- inc/poche/Poche.class.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index c9fb6382..802ec542 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -430,6 +430,12 @@ class Poche ); Tools::logm('config view'); break; + case 'tags': + $tags = $this->store->retrieveAllTags(); + $tpl_vars = array( + 'tags' => $tags, + ); + break; case 'view': $entry = $this->store->retrieveOneById($id, $this->user->getId()); if ($entry != NULL) { -- cgit v1.2.3 From 6cab59c3409f4edc9b309b76295cb4061bff3fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:03:14 +0100 Subject: [add] edit tags page --- inc/poche/Poche.class.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 802ec542..5d368842 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -430,6 +430,13 @@ class Poche ); Tools::logm('config view'); break; + case 'edit-tags': + # tags + $tags = $this->store->retrieveTagsByEntry($id); + $tpl_vars = array( + 'tags' => $tags, + ); + break; case 'tags': $tags = $this->store->retrieveAllTags(); $tpl_vars = array( -- cgit v1.2.3 From 4886ed6d3637df0b3e16e672d58d4ef8f17dc432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:22:29 +0100 Subject: [add] page which lists entries for a tag --- inc/poche/Poche.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 5d368842..fefbb02d 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -437,6 +437,14 @@ class Poche 'tags' => $tags, ); break; + case 'tag': + $entries = $this->store->retrieveEntriesByTag($id); + $tag = $this->store->retrieveTag($id); + $tpl_vars = array( + 'tag' => $tag, + 'entries' => $entries, + ); + break; case 'tags': $tags = $this->store->retrieveAllTags(); $tpl_vars = array( -- cgit v1.2.3 From f778e47283c9691d2992045e0fbcdfc6685f157f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:37:42 +0100 Subject: [add] rss for tag --- inc/poche/Poche.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index fefbb02d..68f56d62 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -446,8 +446,11 @@ class Poche ); break; case 'tags': + $token = $this->user->getConfigValue('token'); $tags = $this->store->retrieveAllTags(); $tpl_vars = array( + 'token' => $token, + 'user_id' => $this->user->getId(), 'tags' => $tags, ); break; @@ -884,9 +887,9 @@ class Poche $_SESSION['poche_user']->setConfig($currentConfig); } - public function generateFeeds($token, $user_id, $type = 'home') + public function generateFeeds($token, $user_id, $tag_id, $type = 'home') { - $allowed_types = array('home', 'fav', 'archive'); + $allowed_types = array('home', 'fav', 'archive', 'tag'); $config = $this->store->getConfigUser($user_id); if (!in_array($type, $allowed_types) || @@ -901,7 +904,13 @@ class Poche $feed->setChannelElement('updated', date(DATE_RSS , time())); $feed->setChannelElement('author', 'poche'); - $entries = $this->store->getEntriesByView($type, $user_id); + if ($type == 'tag') { + $entries = $this->store->retrieveEntriesByTag($tag_id); + } + else { + $entries = $this->store->getEntriesByView($type, $user_id); + } + if (count($entries) > 0) { foreach ($entries as $entry) { $newItem = $feed->createNewItem(); -- cgit v1.2.3 From c432fa1674fbe2b190cf0d0bab2e90302a61e98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 15:07:51 +0100 Subject: [add] assign and remove a tag to an entry --- inc/poche/Poche.class.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 68f56d62..d415dd03 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -397,6 +397,36 @@ class Poche Tools::redirect(); } break; + case 'add_tag' : + $tags = explode(',', $_POST['value']); + $entry_id = $_POST['entry_id']; + foreach($tags as $key => $tag_value) { + $value = trim($tag_value); + $tag = $this->store->retrieveTagByValue($value); + + if (is_null($tag)) { + # we create the tag + $tag = $this->store->createTag($value); + $sequence = ''; + if (STORAGE == 'postgres') { + $sequence = 'tags_id_seq'; + } + $tag_id = $this->store->getLastId($sequence); + } + else { + $tag_id = $tag['id']; + } + + # we assign the tag to the article + $this->store->setTagToEntry($tag_id, $entry_id); + } + Tools::redirect(); + break; + case 'remove_tag' : + $tag_id = $_GET['tag_id']; + $this->store->removeTagForEntry($id, $tag_id); + Tools::redirect(); + break; default: break; } @@ -434,6 +464,7 @@ class Poche # tags $tags = $this->store->retrieveTagsByEntry($id); $tpl_vars = array( + 'entry_id' => $id, 'tags' => $tags, ); break; -- cgit v1.2.3 From a0aa150418b628b32b18c70436d6be495129ee38 Mon Sep 17 00:00:00 2001 From: Dmitry Sandalov Date: Sat, 21 Dec 2013 23:39:45 +0400 Subject: fix for long lasting session --- inc/poche/Poche.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index d415dd03..adec9b28 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -678,7 +678,8 @@ class Poche $user = $this->store->login($login, Tools::encodeString($password . $login)); if ($user != array()) { # Save login into Session - Session::login($user['username'], $user['password'], $login, Tools::encodeString($password . $login), array('poche_user' => new User($user))); + $longlastingsession = isset($_POST['longlastingsession']); + Session::login($user['username'], $user['password'], $login, Tools::encodeString($password . $login), $longlastingsession, array('poche_user' => new User($user))); $this->messages->add('s', _('welcome to your poche')); Tools::logm('login successful'); Tools::redirect($referer); -- cgit v1.2.3 From 1810c13b55b01043620fd81a65ce6e84cccc429c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 23 Dec 2013 09:09:10 +0100 Subject: PHP_AUTH_USER isn't available when using php as cgi --- inc/poche/Poche.class.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index adec9b28..4b26574d 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -446,7 +446,7 @@ class Poche $themes = $this->getInstalledThemes(); $languages = $this->getInstalledLanguages(); $token = $this->user->getConfigValue('token'); - $http_auth = (isset($_SERVER['PHP_AUTH_USER']))?true:false; + $http_auth = (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['REMOTE_USER'])) ? true : false; $tpl_vars = array( 'themes' => $themes, 'languages' => $languages, @@ -649,14 +649,18 @@ class Poche * it redirects the user to the $referer link * @return array */ - private function credentials() { - if(isset($_SERVER['PHP_AUTH_USER'])) { - return array($_SERVER['PHP_AUTH_USER'],'php_auth'); - } - if(!empty($_POST['login']) && !empty($_POST['password'])) { - return array($_POST['login'],$_POST['password']); - } - return array(false,false); + private function credentials() { + if(isset($_SERVER['PHP_AUTH_USER'])) { + return array($_SERVER['PHP_AUTH_USER'],'php_auth'); + } + if(!empty($_POST['login']) && !empty($_POST['password'])) { + return array($_POST['login'],$_POST['password']); + } + if(isset($_SERVER['REMOTE_USER'])) { + return array($_SERVER['REMOTE_USER'],'http_auth'); + } + + return array(false,false); } /** -- cgit v1.2.3 From 5cfafc6110985236d9f212533faee79e460bf20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 23 Dec 2013 10:35:09 +0100 Subject: [add] check tags tables --- inc/poche/Poche.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 4b26574d..4f70afb7 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -49,6 +49,7 @@ class Poche if (! $this->store->isInstalled()) { $this->install(); } + $this->store->checkTags(); } } @@ -659,7 +660,7 @@ class Poche if(isset($_SERVER['REMOTE_USER'])) { return array($_SERVER['REMOTE_USER'],'http_auth'); } - + return array(false,false); } -- cgit v1.2.3