From 4fe64668a57c44910195842cd07c16f9b0b58ca9 Mon Sep 17 00:00:00 2001
From: Frederic Guillot
Date: Fri, 31 May 2013 22:01:01 -0400
Subject: [PATCH] Encode in base64 item_id rather than urlencode
---
index.php | 20 ++++++++++----------
model.php | 12 ++++++++++++
templates/history.php | 15 ++++++++-------
templates/read_item.php | 12 ++++++------
templates/unread_items.php | 13 +++++++------
5 files changed, 43 insertions(+), 29 deletions(-)
diff --git a/index.php b/index.php
index 23259a8..94e16e8 100644
--- a/index.php
+++ b/index.php
@@ -95,7 +95,7 @@ Router\post_action('login', function() {
Router\get_action('show', function() {
- $id = Request\param('id');
+ $id = Model\decode_item_id(Request\param('id'));
Response\html(Template\layout('read_item', array(
'item' => Model\get_item($id)
@@ -105,7 +105,7 @@ Router\get_action('show', function() {
Router\get_action('read', function() {
- $id = Request\param('id');
+ $id = Model\decode_item_id(Request\param('id'));
$item = Model\get_item($id);
$nav = Model\get_nav_item($item); // must be placed before set_item_read()
@@ -120,7 +120,7 @@ Router\get_action('read', function() {
Router\get_action('mark-item-read', function() {
- $id = Request\param('id');
+ $id = Model\decode_item_id(Request\param('id'));
Model\set_item_read($id);
Response\Redirect('?action=default');
});
@@ -128,7 +128,7 @@ Router\get_action('mark-item-read', function() {
Router\get_action('mark-item-unread', function() {
- $id = Request\param('id');
+ $id = Model\decode_item_id(Request\param('id'));
Model\set_item_unread($id);
Response\Redirect('?action=history');
});
@@ -136,7 +136,7 @@ Router\get_action('mark-item-unread', function() {
Router\get_action('mark-item-removed', function() {
- $id = Request\param('id');
+ $id = Model\decode_item_id(Request\param('id'));
Model\set_item_removed($id);
Response\Redirect('?action=history');
});
@@ -144,7 +144,7 @@ Router\get_action('mark-item-removed', function() {
Router\post_action('mark-item-read', function() {
- $id = Request\param('id');
+ $id = Model\decode_item_id(Request\param('id'));
Model\set_item_read($id);
Response\json(array('Ok'));
});
@@ -152,7 +152,7 @@ Router\post_action('mark-item-read', function() {
Router\post_action('mark-item-unread', function() {
- $id = Request\param('id');
+ $id = Model\decode_item_id(Request\param('id'));
Model\set_item_unread($id);
Response\json(array('Ok'));
});
@@ -160,7 +160,7 @@ Router\post_action('mark-item-unread', function() {
Router\post_action('change-item-status', function() {
- $id = Request\param('id');
+ $id = Model\decode_item_id(Request\param('id'));
Response\json(array(
'item_id' => urlencode($id),
@@ -182,7 +182,7 @@ Router\get_action('confirm-remove', function() {
$id = Request\int_param('feed_id');
- Response\html(Template\layout('confirm_remove', array(
+ Response\html(Template\layout('confirm_remove_feed', array(
'feed' => Model\get_feed($id),
'menu' => 'feeds'
)));
@@ -241,7 +241,7 @@ Router\get_action('mark-as-read', function() {
Router\get_action('confirm-flush-history', function() {
- Response\html(Template\layout('confirm_flush', array(
+ Response\html(Template\layout('confirm_flush_items', array(
'menu' => 'history'
)));
});
diff --git a/model.php b/model.php
index 7c374f3..a9ea1b1 100644
--- a/model.php
+++ b/model.php
@@ -42,6 +42,18 @@ function get_autoflush_options()
}
+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());
diff --git a/templates/history.php b/templates/history.php
index 41637b5..ae12234 100644
--- a/templates/history.php
+++ b/templates/history.php
@@ -13,11 +13,12 @@
-
+
+
= Helper\get_host_from_url($item['url']) ?> |
= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
- = t('mark as unread') ?> |
- = t('remove') ?> |
+ = t('mark as unread') ?> |
+ = t('remove') ?> |
= t('original link') ?>
diff --git a/templates/read_item.php b/templates/read_item.php
index e097335..6baa5a6 100644
--- a/templates/read_item.php
+++ b/templates/read_item.php
@@ -3,7 +3,7 @@
= t('Item not found') ?>
-
+
@@ -19,7 +19,7 @@
= Helper\get_host_from_url($item['url']) ?> |
- = t('mark as read') ?> |
+ = t('mark as read') ?> |
= t('original link') ?>