Encode in base64 item_id rather than urlencode
This commit is contained in:
parent
315c0ff92c
commit
4fe64668a5
20
index.php
20
index.php
@ -95,7 +95,7 @@ Router\post_action('login', function() {
|
|||||||
|
|
||||||
Router\get_action('show', 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(
|
Response\html(Template\layout('read_item', array(
|
||||||
'item' => Model\get_item($id)
|
'item' => Model\get_item($id)
|
||||||
@ -105,7 +105,7 @@ Router\get_action('show', function() {
|
|||||||
|
|
||||||
Router\get_action('read', function() {
|
Router\get_action('read', function() {
|
||||||
|
|
||||||
$id = Request\param('id');
|
$id = Model\decode_item_id(Request\param('id'));
|
||||||
$item = Model\get_item($id);
|
$item = Model\get_item($id);
|
||||||
$nav = Model\get_nav_item($item); // must be placed before set_item_read()
|
$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() {
|
Router\get_action('mark-item-read', function() {
|
||||||
|
|
||||||
$id = Request\param('id');
|
$id = Model\decode_item_id(Request\param('id'));
|
||||||
Model\set_item_read($id);
|
Model\set_item_read($id);
|
||||||
Response\Redirect('?action=default');
|
Response\Redirect('?action=default');
|
||||||
});
|
});
|
||||||
@ -128,7 +128,7 @@ Router\get_action('mark-item-read', function() {
|
|||||||
|
|
||||||
Router\get_action('mark-item-unread', 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);
|
Model\set_item_unread($id);
|
||||||
Response\Redirect('?action=history');
|
Response\Redirect('?action=history');
|
||||||
});
|
});
|
||||||
@ -136,7 +136,7 @@ Router\get_action('mark-item-unread', function() {
|
|||||||
|
|
||||||
Router\get_action('mark-item-removed', 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);
|
Model\set_item_removed($id);
|
||||||
Response\Redirect('?action=history');
|
Response\Redirect('?action=history');
|
||||||
});
|
});
|
||||||
@ -144,7 +144,7 @@ Router\get_action('mark-item-removed', function() {
|
|||||||
|
|
||||||
Router\post_action('mark-item-read', 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);
|
Model\set_item_read($id);
|
||||||
Response\json(array('Ok'));
|
Response\json(array('Ok'));
|
||||||
});
|
});
|
||||||
@ -152,7 +152,7 @@ Router\post_action('mark-item-read', function() {
|
|||||||
|
|
||||||
Router\post_action('mark-item-unread', 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);
|
Model\set_item_unread($id);
|
||||||
Response\json(array('Ok'));
|
Response\json(array('Ok'));
|
||||||
});
|
});
|
||||||
@ -160,7 +160,7 @@ Router\post_action('mark-item-unread', function() {
|
|||||||
|
|
||||||
Router\post_action('change-item-status', function() {
|
Router\post_action('change-item-status', function() {
|
||||||
|
|
||||||
$id = Request\param('id');
|
$id = Model\decode_item_id(Request\param('id'));
|
||||||
|
|
||||||
Response\json(array(
|
Response\json(array(
|
||||||
'item_id' => urlencode($id),
|
'item_id' => urlencode($id),
|
||||||
@ -182,7 +182,7 @@ Router\get_action('confirm-remove', function() {
|
|||||||
|
|
||||||
$id = Request\int_param('feed_id');
|
$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),
|
'feed' => Model\get_feed($id),
|
||||||
'menu' => 'feeds'
|
'menu' => 'feeds'
|
||||||
)));
|
)));
|
||||||
@ -241,7 +241,7 @@ Router\get_action('mark-as-read', function() {
|
|||||||
|
|
||||||
Router\get_action('confirm-flush-history', 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'
|
'menu' => 'history'
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
12
model.php
12
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()
|
function export_feeds()
|
||||||
{
|
{
|
||||||
$opml = new Export(get_feeds());
|
$opml = new Export(get_feeds());
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
|
|
||||||
<section class="items" id="listing">
|
<section class="items" id="listing">
|
||||||
<?php foreach ($items as $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<article id="item-<?= urlencode($item['id']) ?>" data-item-id="<?= urlencode($item['id']) ?>">
|
<?php $item_id = Model\encode_item_id($item['id']) ?>
|
||||||
|
<article id="item-<?= $item_id ?>" data-item-id="<?= $item_id ?>">
|
||||||
<h2>
|
<h2>
|
||||||
<a
|
<a
|
||||||
href="?action=show&id=<?= urlencode($item['id']) ?>"
|
href="?action=show&id=<?= $item_id ?>"
|
||||||
id="open-<?= urlencode($item['id']) ?>"
|
id="open-<?= $item_id ?>"
|
||||||
>
|
>
|
||||||
<?= Helper\escape($item['title']) ?>
|
<?= Helper\escape($item['title']) ?>
|
||||||
</a>
|
</a>
|
||||||
@ -25,14 +26,14 @@
|
|||||||
<p>
|
<p>
|
||||||
<?= Helper\get_host_from_url($item['url']) ?> |
|
<?= Helper\get_host_from_url($item['url']) ?> |
|
||||||
<?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
|
<?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
|
||||||
<a href="?action=mark-item-unread&id=<?= urlencode($item['id']) ?>"><?= t('mark as unread') ?></a> |
|
<a href="?action=mark-item-unread&id=<?= $item_id ?>"><?= t('mark as unread') ?></a> |
|
||||||
<a href="?action=mark-item-removed&id=<?= urlencode($item['id']) ?>"><?= t('remove') ?></a> |
|
<a href="?action=mark-item-removed&id=<?= $item_id ?>"><?= t('remove') ?></a> |
|
||||||
<a
|
<a
|
||||||
href="<?= $item['url'] ?>"
|
href="<?= $item['url'] ?>"
|
||||||
id="original-<?= urlencode($item['id']) ?>"
|
id="original-<?= $item_id ?>"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
data-item-id="<?= urlencode($item['id']) ?>"
|
data-item-id="<?= $item_id ?>"
|
||||||
>
|
>
|
||||||
<?= t('original link') ?>
|
<?= t('original link') ?>
|
||||||
</a>
|
</a>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<p class="alert alert-info"><?= t('Item not found') ?></p>
|
<p class="alert alert-info"><?= t('Item not found') ?></p>
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<article class="item" id="current-item" data-item-id="<?= urlencode($item['id']) ?>">
|
<article class="item" id="current-item" data-item-id="<?= Model\encode_item_id($item['id']) ?>">
|
||||||
<h1>
|
<h1>
|
||||||
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" id="original-item"><?= Helper\escape($item['title']) ?></a>
|
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" id="original-item"><?= Helper\escape($item['title']) ?></a>
|
||||||
</h1>
|
</h1>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<span class="nav-left">
|
<span class="nav-left">
|
||||||
<?php if ($item_nav['previous']): ?>
|
<?php if ($item_nav['previous']): ?>
|
||||||
<a href="?action=read&id=<?= urlencode($item_nav['previous']['id']) ?>" id="previous-item">« <?= t('Previous') ?></a>
|
<a href="?action=read&id=<?= Model\encode_item_id($item_nav['previous']['id']) ?>" id="previous-item">« <?= t('Previous') ?></a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
« <?= t('Previous') ?>
|
« <?= t('Previous') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
@ -27,11 +27,11 @@
|
|||||||
|
|
||||||
<span class="nav-middle">
|
<span class="nav-middle">
|
||||||
<?php if ($item_nav['previous'] && $item_nav['next']): ?>
|
<?php if ($item_nav['previous'] && $item_nav['next']): ?>
|
||||||
<a href="?action=default#item-<?= urlencode($item_nav['next']['id']) ?>"><?= t('Unread items') ?></a>
|
<a href="?action=default#item-<?= Model\encode_item_id($item_nav['next']['id']) ?>"><?= t('Unread items') ?></a>
|
||||||
<?php elseif ($item_nav['previous'] && ! $item_nav['next']): ?>
|
<?php elseif ($item_nav['previous'] && ! $item_nav['next']): ?>
|
||||||
<a href="?action=default#item-<?= urlencode($item_nav['previous']['id']) ?>"><?= t('Unread items') ?></a>
|
<a href="?action=default#item-<?= Model\encode_item_id($item_nav['previous']['id']) ?>"><?= t('Unread items') ?></a>
|
||||||
<?php elseif (! $item_nav['previous'] && $item_nav['next']): ?>
|
<?php elseif (! $item_nav['previous'] && $item_nav['next']): ?>
|
||||||
<a href="?action=default#item-<?= urlencode($item_nav['next']['id']) ?>"><?= t('Unread items') ?></a>
|
<a href="?action=default#item-<?= Model\encode_item_id($item_nav['next']['id']) ?>"><?= t('Unread items') ?></a>
|
||||||
<?php elseif (! $item_nav['previous'] && ! $item_nav['next']): ?>
|
<?php elseif (! $item_nav['previous'] && ! $item_nav['next']): ?>
|
||||||
<a href="?action=default"><?= t('Unread items') ?></a>
|
<a href="?action=default"><?= t('Unread items') ?></a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<span class="nav-right">
|
<span class="nav-right">
|
||||||
<?php if ($item_nav['next']): ?>
|
<?php if ($item_nav['next']): ?>
|
||||||
<a href="?action=read&id=<?= urlencode($item_nav['next']['id']) ?>" id="next-item"><?= t('Next') ?> »</a>
|
<a href="?action=read&id=<?= Model\encode_item_id($item_nav['next']['id']) ?>" id="next-item"><?= t('Next') ?> »</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= t('Next') ?> »
|
<?= t('Next') ?> »
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
|
|
||||||
<section class="items" id="listing">
|
<section class="items" id="listing">
|
||||||
<?php foreach ($items as $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<article id="item-<?= urlencode($item['id']) ?>" data-item-id="<?= urlencode($item['id']) ?>">
|
<?php $item_id = Model\encode_item_id($item['id']) ?>
|
||||||
|
<article id="item-<?= $item_id ?>" data-item-id="<?= $item_id ?>">
|
||||||
<h2>
|
<h2>
|
||||||
<a
|
<a
|
||||||
href="?action=read&id=<?= urlencode($item['id']) ?>"
|
href="?action=read&id=<?= $item_id ?>"
|
||||||
id="open-<?= urlencode($item['id']) ?>"
|
id="open-<?= $item_id ?>"
|
||||||
>
|
>
|
||||||
<?= Helper\escape($item['title']) ?>
|
<?= Helper\escape($item['title']) ?>
|
||||||
</a>
|
</a>
|
||||||
@ -27,13 +28,13 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<?= Helper\get_host_from_url($item['url']) ?> |
|
<?= Helper\get_host_from_url($item['url']) ?> |
|
||||||
<a href="?action=mark-item-read&id=<?= urlencode($item['id']) ?>"><?= t('mark as read') ?></a> |
|
<a href="?action=mark-item-read&id=<?= $item_id ?>"><?= t('mark as read') ?></a> |
|
||||||
<a
|
<a
|
||||||
href="<?= $item['url'] ?>"
|
href="<?= $item['url'] ?>"
|
||||||
id="original-<?= urlencode($item['id']) ?>"
|
id="original-<?= $item_id ?>"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
data-item-id="<?= urlencode($item['id']) ?>"
|
data-item-id="<?= $item_id ?>"
|
||||||
data-action="mark-read"
|
data-action="mark-read"
|
||||||
>
|
>
|
||||||
<?= t('original link') ?>
|
<?= t('original link') ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user