diff --git a/README.markdown b/README.markdown
index 7c0170e..4f163b5 100644
--- a/README.markdown
+++ b/README.markdown
@@ -178,7 +178,7 @@ Actually, the following constants can be overrided:
- `THEME_DIRECTORY` => default is themes
- `SESSION_SAVE_PATH` => default is empty (used to store session files in a custom directory)
-### How to change the session save path ?
+### How to change the session save path?
With several shared hosting providers, sessions are cleaned frequently, to avoid to login too often,
you can save sessions in a custom directory.
diff --git a/index.php b/index.php
index acfb58e..4f2246b 100644
--- a/index.php
+++ b/index.php
@@ -97,7 +97,7 @@ Router\get_action('show-help', function() {
// Show item without bottom nav
Router\get_action('show', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
$item = Model\get_item($id);
$feed = Model\get_feed($item['feed_id']);
@@ -114,7 +114,7 @@ Router\get_action('show', function() {
// Show item with bottom nav
Router\get_action('read', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
$item = Model\get_item($id);
$feed = Model\get_feed($item['feed_id']);
$nav = Model\get_nav_item($item); // must be placed before set_item_read()
@@ -133,7 +133,7 @@ Router\get_action('read', function() {
// Mark item as read and redirect to the listing page
Router\get_action('mark-item-read', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
$redirect = Request\param('redirect', 'unread');
$offset = Request\int_param('offset', 0);
@@ -146,7 +146,7 @@ Router\get_action('mark-item-read', function() {
// Mark item as unread and redirect to the listing page
Router\get_action('mark-item-unread', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
$redirect = Request\param('redirect', 'history');
$offset = Request\int_param('offset', 0);
@@ -159,7 +159,7 @@ Router\get_action('mark-item-unread', function() {
// Mark item as removed and redirect to the listing page
Router\get_action('mark-item-removed', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
$redirect = Request\param('redirect', 'history');
$offset = Request\int_param('offset', 0);
@@ -172,7 +172,7 @@ Router\get_action('mark-item-removed', function() {
// Ajax call to mark item read
Router\post_action('mark-item-read', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
Model\set_item_read($id);
Response\json(array('Ok'));
});
@@ -181,7 +181,7 @@ Router\post_action('mark-item-read', function() {
// Ajax call to mark item unread
Router\post_action('mark-item-unread', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
Model\set_item_unread($id);
Response\json(array('Ok'));
});
@@ -190,7 +190,7 @@ Router\post_action('mark-item-unread', function() {
// Ajax call to bookmark an item
Router\post_action('bookmark-item', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
Model\bookmark_item($id);
Response\json(array('Ok'));
});
@@ -199,10 +199,10 @@ Router\post_action('bookmark-item', function() {
// Ajax call change item status
Router\post_action('change-item-status', function() {
- $id = Model\decode_item_id(Request\param('id'));
+ $id = Request\param('id');
Response\json(array(
- 'item_id' => Model\encode_item_id($id),
+ 'item_id' => $id,
'status' => Model\switch_item_status($id)
));
});
@@ -211,8 +211,7 @@ Router\post_action('change-item-status', function() {
// Add new bookmark
Router\get_action('bookmark', function() {
- $param_id = Request\param('id');
- $id = Model\decode_item_id($param_id);
+ $id = Request\param('id');
$redirect = Request\param('redirect', 'unread');
$offset = Request\int_param('offset', 0);
@@ -220,11 +219,11 @@ Router\get_action('bookmark', function() {
if ($redirect === 'show') {
- Response\Redirect('?action=show&id='.$param_id);
+ Response\Redirect('?action=show&id='.$id);
}
else if ($redirect === 'read') {
- Response\Redirect('?action=read&id='.$param_id);
+ Response\Redirect('?action=read&id='.$id);
}
Response\Redirect('?action='.$redirect.'&offset='.$offset);
diff --git a/model.php b/model.php
index 2c17a86..7e3d97a 100644
--- a/model.php
+++ b/model.php
@@ -22,7 +22,7 @@ use PicoFeed\Reader;
use PicoFeed\Export;
-const DB_VERSION = 10;
+const DB_VERSION = 11;
const HTTP_USERAGENT = 'Miniflux - http://miniflux.net';
const LIMIT_ALL = -1;
@@ -99,18 +99,6 @@ function write_debug()
}
-function encode_item_id($input)
-{
- return strtr(base64_encode($input), '+/=', '-_,');
-}
-
-
-function decode_item_id($input)
-{
- return base64_decode(strtr($input, '-_,', '+/='));
-}
-
-
function export_feeds()
{
$opml = new Export(get_feeds());
@@ -530,8 +518,8 @@ function mark_items_as_read(array $items_id)
{
\PicoTools\singleton('db')->startTransaction();
- foreach($items_id as $encoded_id) {
- set_item_read(decode_item_id($encoded_id));
+ foreach ($items_id as $id) {
+ set_item_read($id);
}
\PicoTools\singleton('db')->closeTransaction();
diff --git a/schema.php b/schema.php
index 30e1e20..cc764be 100644
--- a/schema.php
+++ b/schema.php
@@ -3,6 +3,36 @@
namespace Schema;
+function version_11($pdo)
+{
+ $rq = $pdo->prepare('
+ SELECT
+ items.id, items.url AS item_url, feeds.site_url
+ FROM items
+ LEFT JOIN feeds ON feeds.id=items.feed_id
+ ');
+
+ $rq->execute();
+
+ $items = $rq->fetchAll(\PDO::FETCH_ASSOC);
+
+ foreach ($items as $item) {
+
+ if ($item['id'] !== $item['item_url']) {
+
+ $id = hash('crc32b', $item['id'].$item['site_url']);
+ }
+ else {
+
+ $id = hash('crc32b', $item['item_url'].$item['site_url']);
+ }
+
+ $rq = $pdo->prepare('UPDATE items SET id=? WHERE id=?');
+ $rq->execute(array($id, $item['id']));
+ }
+}
+
+
function version_10($pdo)
{
$pdo->exec('ALTER TABLE config ADD COLUMN theme TEXT DEFAULT "original"');
diff --git a/templates/bookmarks.php b/templates/bookmarks.php
index b04f6c6..9c44543 100644
--- a/templates/bookmarks.php
+++ b/templates/bookmarks.php
@@ -10,13 +10,12 @@
@@ -27,7 +26,7 @@