From decb9a5814be82effde73f798fbdc0c76c3dd1de Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Thu, 27 Feb 2014 18:12:43 +0200 Subject: fix of #509, related to php 5.3 --- inc/poche/Poche.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index deec4226..e13e7e1b 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -366,7 +366,7 @@ class Poche // Saving and clearing context $REAL = array(); foreach( $GLOBALS as $key => $value ) { - if( $key != "GLOBALS" && $key != "_SESSION" ) { + if( $key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS' ) { $GLOBALS[$key] = array(); $REAL[$key] = $value; } -- cgit v1.2.3 From 346380e131ac41229fdcadb5bc5dcb99347552ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 27 Feb 2014 21:37:25 +0100 Subject: [add] label for brazilian language on config screen --- inc/poche/Poche.class.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 4100f156..714fa9ee 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -35,6 +35,7 @@ class Poche 'ru_RU.utf8' => 'Pусский', 'sl_SI.utf8' => 'Slovenščina', 'uk_UA.utf8' => 'Українська', + 'pt_BR.utf8' => 'Brasileiro', ); public function __construct() { -- cgit v1.2.3 From 6065553c137ec63ec3ffddda0350f1d3d805b852 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Fri, 28 Feb 2014 13:08:11 +0200 Subject: effect of block rebuilding on next page removed, issue #479 --- inc/poche/Poche.class.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 4100f156..d42da60d 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -660,6 +660,7 @@ class Poche 'entries' => '', 'page_links' => '', 'nb_results' => '', + 'listmode' => (isset($_COOKIE['listmode']) ? true : false), ); //if id is given - we retrive entries by tag: id is tag id -- cgit v1.2.3 From 31a10069a52c2fd2aca3a835a7bdc1accae197f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 28 Feb 2014 20:36:32 +0100 Subject: [add] upload form for import --- inc/poche/Poche.class.php | 24 +++++++++++++++++------- inc/poche/Tools.class.php | 1 - 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 49651c52..026b0b4e 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -1068,13 +1068,7 @@ class Poche Tools::redirect(); } - $targetDefinition = 'IMPORT_' . strtoupper($from) . '_FILE'; - $targetFile = constant($targetDefinition); - - if (! defined($targetDefinition)) { - $this->messages->add('e', _('Incomplete inc/poche/define.inc.php file, please define "' . $targetDefinition . '".')); - Tools::redirect(); - } + $targetFile = CACHE . '/' . constant(strtoupper($from) . '_FILE'); if (! file_exists($targetFile)) { $this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.')); @@ -1084,6 +1078,22 @@ class Poche $this->$providers[$from]($targetFile); } + public function uploadFile() { + if(isset($_FILES['file'])) + { + $dir = CACHE . '/'; + $file = basename($_FILES['file']['name']); + if(move_uploaded_file($_FILES['file']['tmp_name'], $dir . $file)) { + $this->messages->add('s', _('File uploaded. You can now execute import.')); + } + else { + $this->messages->add('e', _('Error while importing file. Do you have access to upload it?')); + } + } + + Tools::redirect('?view=config'); + } + /** * export poche entries in json * @return json all poche entries diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 4ed28ed1..eed7afbd 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -241,7 +241,6 @@ class Tools } } - public static function download_db() { header('Content-Disposition: attachment; filename="poche.sqlite.gz"'); self::status(200); -- cgit v1.2.3 From 53e3158dfe697ea59da1fa0e401e8da75ae13030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 28 Feb 2014 21:49:38 +0100 Subject: [add] cron to fetch content on imported entries --- inc/poche/Database.class.php | 67 +++++++++++++++++++++++----------- inc/poche/Poche.class.php | 86 ++++++++++---------------------------------- inc/poche/Tools.class.php | 56 ++++++++++++++++++++++++++++- 3 files changed, 120 insertions(+), 89 deletions(-) (limited to 'inc') diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index c998fe14..edc775f5 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -230,8 +230,30 @@ class Database { } } + public function updateContentAndTitle($id, $title, $body, $user_id) { + $sql_action = 'UPDATE entries SET content = ?, title = ? WHERE id=? AND user_id=?'; + $params_action = array($body, $title, $id, $user_id); + $query = $this->executeQuery($sql_action, $params_action); + + return $query; + } + + public function retrieveUnfetchedEntries($user_id, $limit) { + + $sql_limit = "LIMIT 0,".$limit; + if (STORAGE == 'postgres') { + $sql_limit = "LIMIT ".$limit." OFFSET 0"; + } + + $sql = "SELECT * FROM entries WHERE (content = '' OR content IS NULL) AND user_id=? ORDER BY id " . $sql_limit; + $query = $this->executeQuery($sql, array($user_id)); + $entries = $query->fetchAll(); + + return $entries; + } + public function retrieveAll($user_id) { - $sql = "SELECT * FROM entries WHERE user_id=? ORDER BY id"; + $sql = "SELECT * FROM entries WHERE content <> '' AND user_id=? ORDER BY id"; $query = $this->executeQuery($sql, array($user_id)); $entries = $query->fetchAll(); @@ -250,7 +272,7 @@ class Database { public function retrieveOneByURL($url, $user_id) { $entry = NULL; - $sql = "SELECT * FROM entries WHERE url=? AND user_id=?"; + $sql = "SELECT * FROM entries WHERE content <> '' AND url=? AND user_id=?"; $params = array($url, $user_id); $query = $this->executeQuery($sql, $params); $entry = $query->fetchAll(); @@ -267,21 +289,22 @@ class Database { public function getEntriesByView($view, $user_id, $limit = '', $tag_id = 0) { switch ($view) { case 'archive': - $sql = "SELECT * FROM entries WHERE user_id=? AND is_read=? "; + $sql = "SELECT * FROM entries WHERE content <> '' AND user_id=? AND is_read=? "; $params = array($user_id, 1); break; case 'fav' : - $sql = "SELECT * FROM entries WHERE user_id=? AND is_fav=? "; + $sql = "SELECT * FROM entries WHERE content <> '' AND user_id=? AND is_fav=? "; $params = array($user_id, 1); break; case 'tag' : $sql = "SELECT entries.* FROM entries LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id - WHERE entries.user_id=? AND tags_entries.tag_id = ? "; + WHERE entries.content <> '' AND + entries.user_id=? AND tags_entries.tag_id = ? "; $params = array($user_id, $tag_id); break; default: - $sql = "SELECT * FROM entries WHERE user_id=? AND is_read=? "; + $sql = "SELECT * FROM entries WHERE content <> '' AND user_id=? AND is_read=? "; $params = array($user_id, 0); break; } @@ -294,24 +317,25 @@ class Database { return $entries; } - public function getEntriesByViewCount($view, $user_id, $tag_id = 0) { - switch ($view) { + public function getEntriesByViewCount($view, $user_id, $tag_id = 0) { + switch ($view) { case 'archive': - $sql = "SELECT count(*) FROM entries WHERE user_id=? AND is_read=? "; + $sql = "SELECT count(*) FROM entries WHERE content <> '' AND user_id=? AND is_read=? "; $params = array($user_id, 1); break; case 'fav' : - $sql = "SELECT count(*) FROM entries WHERE user_id=? AND is_fav=? "; + $sql = "SELECT count(*) FROM entries WHERE content <> '' AND user_id=? AND is_fav=? "; $params = array($user_id, 1); break; - case 'tag' : - $sql = "SELECT count(*) FROM entries - LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id - WHERE entries.user_id=? AND tags_entries.tag_id = ? "; - $params = array($user_id, $tag_id); - break; + case 'tag' : + $sql = "SELECT count(*) FROM entries + LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id + WHERE entries.content <> '' AND + entries.user_id=? AND tags_entries.tag_id = ? "; + $params = array($user_id, $tag_id); + break; default: - $sql = "SELECT count(*) FROM entries WHERE user_id=? AND is_read=? "; + $sql = "SELECT count(*) FROM entries WHERE content <> '' AND user_id=? AND is_read=? "; $params = array($user_id, 0); break; } @@ -319,7 +343,7 @@ class Database { $query = $this->executeQuery($sql, $params); list($count) = $query->fetch(); - return $count; + return $count; } public function updateContent($id, $content, $user_id) { @@ -369,7 +393,7 @@ class Database { $sql = "SELECT DISTINCT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id LEFT JOIN entries ON tags_entries.entry_id=entries.id - WHERE entries.user_id=?"; + WHERE entries.content <> '' AND entries.user_id=?"; $query = $this->executeQuery($sql, array($user_id)); $tags = $query->fetchAll(); @@ -381,7 +405,7 @@ class Database { $sql = "SELECT DISTINCT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id LEFT JOIN entries ON tags_entries.entry_id=entries.id - WHERE tags.id=? AND entries.user_id=?"; + WHERE entries.content <> '' AND tags.id=? AND entries.user_id=?"; $params = array(intval($id), $user_id); $query = $this->executeQuery($sql, $params); $tag = $query->fetchAll(); @@ -393,7 +417,8 @@ class Database { $sql = "SELECT entries.* FROM entries LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id - WHERE tags_entries.tag_id = ? AND entries.user_id=?"; + WHERE entries.content <> '' AND + tags_entries.tag_id = ? AND entries.user_id=?"; $query = $this->executeQuery($sql, array($tag_id, $user_id)); $entries = $query->fetchAll(); diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 026b0b4e..5a89a8d2 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -362,60 +362,6 @@ class Poche ); } - protected function getPageContent(Url $url) - { - // Saving and clearing context - $REAL = array(); - foreach( $GLOBALS as $key => $value ) { - if( $key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS' ) { - $GLOBALS[$key] = array(); - $REAL[$key] = $value; - } - } - // Saving and clearing session - $REAL_SESSION = array(); - foreach( $_SESSION as $key => $value ) { - $REAL_SESSION[$key] = $value; - unset($_SESSION[$key]); - } - - // Running code in different context - $scope = function() { - extract( func_get_arg(1) ); - $_GET = $_REQUEST = array( - "url" => $url->getUrl(), - "max" => 5, - "links" => "preserve", - "exc" => "", - "format" => "json", - "submit" => "Create Feed" - ); - ob_start(); - require func_get_arg(0); - $json = ob_get_flush(); - return $json; - }; - $json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) ); - - // Clearing and restoring context - foreach( $GLOBALS as $key => $value ) { - if( $key != "GLOBALS" && $key != "_SESSION" ) { - unset($GLOBALS[$key]); - } - } - foreach( $REAL as $key => $value ) { - $GLOBALS[$key] = $value; - } - // Clearing and restoring session - foreach( $_SESSION as $key => $value ) { - unset($_SESSION[$key]); - } - foreach( $REAL_SESSION as $key => $value ) { - $_SESSION[$key] = $value; - } - return json_decode($json, true); - } - /** * Call action (mark as fav, archive, delete, etc.) */ @@ -424,15 +370,21 @@ class Poche switch ($action) { case 'add': - $content = $this->getPageContent($url); - $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); - $body = $content['rss']['channel']['item']['description']; - - // clean content from prevent xss attack - $config = HTMLPurifier_Config::createDefault(); - $purifier = new HTMLPurifier($config); - $title = $purifier->purify($title); - $body = $purifier->purify($body); + if (!$import) { + $content = Tools::getPageContent($url); + $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); + $body = $content['rss']['channel']['item']['description']; + + // clean content from prevent xss attack + $config = HTMLPurifier_Config::createDefault(); + $purifier = new HTMLPurifier($config); + $title = $purifier->purify($title); + $body = $purifier->purify($body); + } + else { + $title = ''; + $body = ''; + } //search for possible duplicate if not in import mode if (!$import) { @@ -897,7 +849,7 @@ class Poche # the second
    is for read links $read = 1; } - $this->messages->add('s', _('import from instapaper completed')); + $this->messages->add('s', _('import from instapaper completed. You have to execute the cron to fetch content.')); Tools::logm('import from instapaper completed'); Tools::redirect(); } @@ -941,7 +893,7 @@ class Poche # the second
      is for read links $read = 1; } - $this->messages->add('s', _('import from pocket completed')); + $this->messages->add('s', _('import from pocket completed. You have to execute the cron to fetch content.')); Tools::logm('import from pocket completed'); Tools::redirect(); } @@ -997,7 +949,7 @@ class Poche } } } - $this->messages->add('s', _('import from Readability completed. ' . $count . ' new links.')); + $this->messages->add('s', _('import from Readability completed. You have to execute the cron to fetch content.')); Tools::logm('import from Readability completed'); Tools::redirect(); } @@ -1043,7 +995,7 @@ class Poche } } - $this->messages->add('s', _('import from Poche completed. ' . $count . ' new links.')); + $this->messages->add('s', _('import from Poche completed. You have to execute the cron to fetch content.')); Tools::logm('import from Poche completed'); Tools::redirect(); } diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index eed7afbd..393a415d 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -193,7 +193,7 @@ class Tools public static function logm($message) { - if (DEBUG_POCHE) { + if (DEBUG_POCHE && php_sapi_name() != 'cli') { $t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n"; file_put_contents(CACHE . '/log.txt', $t, FILE_APPEND); error_log('DEBUG POCHE : ' . $message); @@ -251,4 +251,58 @@ class Tools exit; } + + public static function getPageContent(Url $url) + { + // Saving and clearing context + $REAL = array(); + foreach( $GLOBALS as $key => $value ) { + if( $key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS' ) { + $GLOBALS[$key] = array(); + $REAL[$key] = $value; + } + } + // Saving and clearing session + $REAL_SESSION = array(); + foreach( $_SESSION as $key => $value ) { + $REAL_SESSION[$key] = $value; + unset($_SESSION[$key]); + } + + // Running code in different context + $scope = function() { + extract( func_get_arg(1) ); + $_GET = $_REQUEST = array( + "url" => $url->getUrl(), + "max" => 5, + "links" => "preserve", + "exc" => "", + "format" => "json", + "submit" => "Create Feed" + ); + ob_start(); + require func_get_arg(0); + $json = ob_get_flush(); + return $json; + }; + $json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) ); + + // Clearing and restoring context + foreach( $GLOBALS as $key => $value ) { + if( $key != "GLOBALS" && $key != "_SESSION" ) { + unset($GLOBALS[$key]); + } + } + foreach( $REAL as $key => $value ) { + $GLOBALS[$key] = $value; + } + // Clearing and restoring session + foreach( $_SESSION as $key => $value ) { + unset($_SESSION[$key]); + } + foreach( $REAL_SESSION as $key => $value ) { + $_SESSION[$key] = $value; + } + return json_decode($json, true); + } } -- cgit v1.2.3 From 223268c2fa34c497d91338e2553bc74bb1b26859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 1 Mar 2014 13:09:37 +0100 Subject: [fix] RSS Feeds don't validate / W3C #384 --- inc/3rdparty/libraries/feedwriter/FeedItem.php | 1 + inc/poche/Poche.class.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/3rdparty/libraries/feedwriter/FeedItem.php b/inc/3rdparty/libraries/feedwriter/FeedItem.php index 9373deeb..0eae5e08 100644 --- a/inc/3rdparty/libraries/feedwriter/FeedItem.php +++ b/inc/3rdparty/libraries/feedwriter/FeedItem.php @@ -156,6 +156,7 @@ if($this->version == RSS2 || $this->version == RSS1) { $this->setElement('link', $link); + $this->setElement('guid', $link); } else { diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 49651c52..0c4143e1 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -1147,8 +1147,9 @@ class Poche $feed = new FeedWriter(RSS2); $feed->setTitle('wallabag — ' . $type . ' feed'); $feed->setLink(Tools::getPocheUrl()); - $feed->setChannelElement('updated', date(DATE_RSS , time())); - $feed->setChannelElement('author', 'wallabag'); + $feed->setChannelElement('pubDate', date(DATE_RSS , time())); + $feed->setChannelElement('generator', 'wallabag'); + $feed->setDescription('wallabag ' . $type . ' elements'); if ($type == 'tag') { $entries = $this->store->retrieveEntriesByTag($tag_id, $user_id); -- cgit v1.2.3 From 11c680f97aa07b48f33e264effb2975d6ca31a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 1 Mar 2014 19:10:17 +0100 Subject: [add] display last check of wallabag release --- inc/poche/Poche.class.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 0c4143e1..ba262c98 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -582,8 +582,12 @@ class Poche switch ($view) { case 'config': - $dev = trim($this->getPocheVersion('dev')); - $prod = trim($this->getPocheVersion('prod')); + $dev_infos = $this->getPocheVersion('dev'); + $dev = trim($dev_infos[0]); + $check_time_dev = date('d-M-Y H:i', $dev_infos[1]); + $prod_infos = $this->getPocheVersion('prod'); + $prod = trim($prod_infos[0]); + $check_time_prod = date('d-M-Y H:i', $prod_infos[1]); $compare_dev = version_compare(POCHE, $dev); $compare_prod = version_compare(POCHE, $prod); $themes = $this->getInstalledThemes(); @@ -595,6 +599,8 @@ class Poche 'languages' => $languages, 'dev' => $dev, 'prod' => $prod, + 'check_time_dev' => $check_time_dev, + 'check_time_prod' => $check_time_prod, 'compare_dev' => $compare_dev, 'compare_prod' => $compare_prod, 'token' => $token, @@ -1105,15 +1111,17 @@ class Poche private function getPocheVersion($which = 'prod') { $cache_file = CACHE . '/' . $which; + $check_time = time(); # checks if the cached version file exists if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 86400 ))) { $version = file_get_contents($cache_file); + $check_time = filemtime($cache_file); } else { $version = file_get_contents('http://static.wallabag.org/versions/' . $which); file_put_contents($cache_file, $version, LOCK_EX); } - return $version; + return array($version, $check_time); } public function generateToken() -- cgit v1.2.3 From 71b0d53c5e5d44a928870f7c98beac7b34199ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sun, 2 Mar 2014 08:38:26 +0100 Subject: [fix] #115 cookie lifetime was empty --- inc/3rdparty/Session.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/3rdparty/Session.class.php b/inc/3rdparty/Session.class.php index b30a31f3..599b68cd 100644 --- a/inc/3rdparty/Session.class.php +++ b/inc/3rdparty/Session.class.php @@ -33,7 +33,7 @@ class Session // his/her session is considered expired (3600 sec. = 1 hour) public static $inactivityTimeout = 86400; // Extra timeout for long sessions (if enabled) (82800 sec. = 23 hours) - public static $longSessionTimeout = 31536000; + public static $longSessionTimeout = 604800; // 604800 = a week // If you get disconnected often or if your IP address changes often. // Let you disable session cookie hijacking protection public static $disableSessionProtection = false; @@ -61,7 +61,7 @@ class Session if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $ssl = true; } - session_set_cookie_params($cookie['lifetime'], $cookiedir, $_SERVER['HTTP_HOST'], $ssl); + session_set_cookie_params(self::$longSessionTimeout, $cookiedir, $_SERVER['HTTP_HOST'], $ssl); // Use cookies to store session. ini_set('session.use_cookies', 1); // Force cookies for session (phpsessionID forbidden in URL) @@ -143,7 +143,14 @@ class Session */ public static function logout() { - unset($_SESSION['uid'],$_SESSION['ip'],$_SESSION['expires_on'],$_SESSION['tokens'], $_SESSION['login'], $_SESSION['pass'], $_SESSION['longlastingsession'], $_SESSION['poche_user']); + // unset($_SESSION['uid'],$_SESSION['ip'],$_SESSION['expires_on'],$_SESSION['tokens'], $_SESSION['login'], $_SESSION['pass'], $_SESSION['longlastingsession'], $_SESSION['poche_user']); + + // Destruction du cookie (le code peut paraître complexe mais c'est pour être certain de reprendre les mêmes paramètres) + $args = array_merge(array(session_name(), ''), array_values(session_get_cookie_params())); + $args[2] = time() - 3600; + call_user_func_array('setcookie', $args); + // Suppression physique de la session + session_destroy(); } /** -- cgit v1.2.3 From f98373cc34f1826ba93fd93ae7f291726af1f933 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Fri, 7 Mar 2014 12:54:08 +0200 Subject: getPageContent moved to Tools, fix of #426 --- inc/poche/Tools.class.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'inc') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 393a415d..eeb101b4 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -263,10 +263,12 @@ class Tools } } // Saving and clearing session - $REAL_SESSION = array(); - foreach( $_SESSION as $key => $value ) { - $REAL_SESSION[$key] = $value; - unset($_SESSION[$key]); + if ( isset($_SESSION) ) { + $REAL_SESSION = array(); + foreach( $_SESSION as $key => $value ) { + $REAL_SESSION[$key] = $value; + unset($_SESSION[$key]); + } } // Running code in different context @@ -282,7 +284,8 @@ class Tools ); ob_start(); require func_get_arg(0); - $json = ob_get_flush(); + $json = ob_get_contents(); + ob_end_clean(); return $json; }; $json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) ); @@ -297,12 +300,15 @@ class Tools $GLOBALS[$key] = $value; } // Clearing and restoring session - foreach( $_SESSION as $key => $value ) { - unset($_SESSION[$key]); - } - foreach( $REAL_SESSION as $key => $value ) { - $_SESSION[$key] = $value; + if ( isset($REAL_SESSION) ) { + foreach( $_SESSION as $key => $value ) { + unset($_SESSION[$key]); + } + foreach( $REAL_SESSION as $key => $value ) { + $_SESSION[$key] = $value; + } } + return json_decode($json, true); } } -- cgit v1.2.3 From 042486c511d07226715c2e0d7cd9823f591d8d10 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Fri, 7 Mar 2014 14:52:52 +0200 Subject: fix of #530 - import fail from Poche --- inc/poche/Poche.class.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index fb4e1a7f..13492506 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -377,6 +377,7 @@ class Poche // clean content from prevent xss attack $config = HTMLPurifier_Config::createDefault(); + $config->set('Cache.SerializerPath', CACHE); $purifier = new HTMLPurifier($config); $title = $purifier->purify($title); $body = $purifier->purify($body); -- cgit v1.2.3 From 17b2afefad1947042cc9fbbb841c3a023d00d96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 10 Mar 2014 08:10:03 +0100 Subject: [fix] test if user_id doesn't exist in feeds generation --- inc/poche/Poche.class.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 13492506..0c8e798c 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -1109,6 +1109,10 @@ class Poche $allowed_types = array('home', 'fav', 'archive', 'tag'); $config = $this->store->getConfigUser($user_id); + if ($config == null) { + die(_('User with this id (' . $user_id . ') does not exist.')); + } + if (!in_array($type, $allowed_types) || $token != $config['token']) { die(_('Uh, there is a problem while generating feeds.')); -- cgit v1.2.3 From fb26cc9375ce9ef8df748eb473eb6e58884421c6 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Mon, 10 Mar 2014 16:28:47 +0200 Subject: a lot of enhancements related to tags: tags list is now sorted, shows number of articles, autocomplete added according to #477, #542 --- inc/poche/Database.class.php | 11 ++++++---- inc/poche/Poche.class.php | 52 +++++++++++++++++++++++++++++--------------- inc/poche/Tools.class.php | 10 +++++++++ 3 files changed, 52 insertions(+), 21 deletions(-) mode change 100644 => 100755 inc/poche/Tools.class.php (limited to 'inc') diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index edc775f5..5b51b507 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -389,12 +389,15 @@ class Database { return $this->getHandle()->lastInsertId($column); } - public function retrieveAllTags($user_id) { - $sql = "SELECT DISTINCT tags.* FROM tags + public function retrieveAllTags($user_id, $term = null) { + $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id LEFT JOIN entries ON tags_entries.entry_id=entries.id - WHERE entries.content <> '' AND entries.user_id=?"; - $query = $this->executeQuery($sql, array($user_id)); + WHERE entries.content <> '' AND entries.user_id=? + ". (($term) ? "AND lower(tags.value) LIKE ?" : '') ." + GROUP BY tags.id, tags.value + ORDER BY tags.value"; + $query = $this->executeQuery($sql, (($term)? array($user_id, strtolower('%'.$term.'%')) : array($user_id) )); $tags = $query->fetchAll(); return $tags; diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 0c8e798c..480f6d45 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -488,25 +488,33 @@ class Poche Tools::logm('error : article not found'); Tools::redirect(); } + //get all already set tags to preven duplicates + $already_set_tags = array(); + $entry_tags = $this->store->retrieveTagsByEntry($entry_id); + foreach ($entry_tags as $tag) { + $already_set_tags[] = $tag['value']; + } 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']; + if ($value && !in_array($value, $already_set_tags)) { + $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); } - - # we assign the tag to the article - $this->store->setTagToEntry($tag_id, $entry_id); } if(!$import) { Tools::redirect(); @@ -579,7 +587,17 @@ class Poche break; case 'tags': $token = $this->user->getConfigValue('token'); - $tags = $this->store->retrieveAllTags($this->user->getId()); + //if term is set - search tags for this term + $term = Tools::checkVar('term'); + $tags = $this->store->retrieveAllTags($this->user->getId(), $term); + if (Tools::isAjaxRequest()) { + $result = array(); + foreach ($tags as $tag) { + $result[] = $tag['value']; + } + echo json_encode($result); + exit; + } $tpl_vars = array( 'token' => $token, 'user_id' => $this->user->getId(), diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php old mode 100644 new mode 100755 index eeb101b4..ad451fc6 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -311,4 +311,14 @@ class Tools return json_decode($json, true); } + + /** + * Returns whether we handle an AJAX (XMLHttpRequest) request. + * @return boolean whether we handle an AJAX (XMLHttpRequest) request. + */ + public static function isAjaxRequest() + { + return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'; + } + } -- cgit v1.2.3 From 8d7cd2ccd59e152e4023ed9f54b9f693597a40d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 14 Mar 2014 08:54:44 +0100 Subject: [add] remove import file in CACHE when import is over --- inc/poche/Poche.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 480f6d45..5b1a0672 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -388,6 +388,7 @@ class Poche } //search for possible duplicate if not in import mode + $duplicate = NULL; if (!$import) { $duplicate = $this->store->retrieveOneByURL($url->getUrl(), $this->user->getId()); } @@ -874,6 +875,8 @@ class Poche # the second
        is for read links $read = 1; } + + $unlink = unlink($targetFile); $this->messages->add('s', _('import from instapaper completed. You have to execute the cron to fetch content.')); Tools::logm('import from instapaper completed'); Tools::redirect(); @@ -918,6 +921,8 @@ class Poche # the second
          is for read links $read = 1; } + + $unlink = unlink($targetFile); $this->messages->add('s', _('import from pocket completed. You have to execute the cron to fetch content.')); Tools::logm('import from pocket completed'); Tools::redirect(); @@ -974,6 +979,8 @@ class Poche } } } + + unlink($targetFile); $this->messages->add('s', _('import from Readability completed. You have to execute the cron to fetch content.')); Tools::logm('import from Readability completed'); Tools::redirect(); @@ -1020,6 +1027,8 @@ class Poche } } + + unlink($targetFile); $this->messages->add('s', _('import from Poche completed. You have to execute the cron to fetch content.')); Tools::logm('import from Poche completed'); Tools::redirect(); -- cgit v1.2.3 From ed02e38e1d52705d74ca43325820e21eabad63b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 14 Mar 2014 09:35:48 +0100 Subject: [fix] in RSS, link to original article --- inc/poche/Poche.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 5b1a0672..7bf33308 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -1164,7 +1164,7 @@ class Poche foreach ($entries as $entry) { $newItem = $feed->createNewItem(); $newItem->setTitle($entry['title']); - $newItem->setLink(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']); + $newItem->setLink($entry['url']); $newItem->setDate(time()); $newItem->setDescription($entry['content']); $feed->addItem($newItem); -- cgit v1.2.3