Add table to doc util script
- Remove db parameter from several places - Add constructors for document types
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
use BitBadger\Documents\DocumentException;
|
||||
use BitBadger\Documents\SQLite\Configuration;
|
||||
use BitBadger\Documents\SQLite\Find;
|
||||
use BitBadger\Documents\SQLite\Patch;
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Item;
|
||||
use FeedReaderCentral\Key;
|
||||
use FeedReaderCentral\Security;
|
||||
@@ -17,12 +17,12 @@ use FeedReaderCentral\Table;
|
||||
|
||||
include '../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db);
|
||||
Security::verifyUser();
|
||||
|
||||
$id = $_GET['id'];
|
||||
|
||||
// TODO: adapt query once "by fields" is available
|
||||
$db = Configuration::dbConn();
|
||||
$existsQuery = $db->prepare(
|
||||
'SELECT item.id FROM item INNER JOIN feed ON feed.id = item.feed_id WHERE item.id = :id AND feed.user_id = :user');
|
||||
$existsQuery->bindValue(':id', $id);
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
<?php
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
include '../../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db, redirectIfAnonymous: false);
|
||||
FeedReaderCentral\Security::verifyUser(redirectIfAnonymous: false);
|
||||
|
||||
page_head('Feeds | Documentation'); ?>
|
||||
<h1>Feeds</h1>
|
||||
@@ -75,4 +71,3 @@ php-cli util/refresh.php all</pre>
|
||||
add <code>nice -n 1</code> (with a trailing space) before the path to the script.
|
||||
</article><?php
|
||||
page_foot();
|
||||
$db->close();
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
<?php
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
include '../../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db, redirectIfAnonymous: false);
|
||||
FeedReaderCentral\Security::verifyUser(redirectIfAnonymous: false);
|
||||
|
||||
page_head('Documentation'); ?>
|
||||
<h1>Documentation Home</h1>
|
||||
@@ -35,4 +31,3 @@ page_head('Documentation'); ?>
|
||||
that can be performed via its command line interface.
|
||||
</article><?php
|
||||
page_foot();
|
||||
$db->close();
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
<?php
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
include '../../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db, redirectIfAnonymous: false);
|
||||
FeedReaderCentral\Security::verifyUser(redirectIfAnonymous: false);
|
||||
|
||||
page_head('Items | Documentation'); ?>
|
||||
<h1>Items</h1>
|
||||
@@ -70,4 +66,3 @@ page_head('Items | Documentation'); ?>
|
||||
others; if the items seem to move around in the list after a refresh, this is likely the cause.
|
||||
</article><?php
|
||||
page_foot();
|
||||
$db->close();
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
<?php
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
include '../../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db, redirectIfAnonymous: false);
|
||||
FeedReaderCentral\Security::verifyUser(redirectIfAnonymous: false);
|
||||
|
||||
page_head('Security Modes | Documentation'); ?>
|
||||
<h1>Configuring Security Modes</h1>
|
||||
@@ -63,4 +59,3 @@ page_head('Security Modes | Documentation'); ?>
|
||||
<p><code>php-cli util/user.php reset-single-password</code>
|
||||
</article><?php
|
||||
page_foot();
|
||||
$db->close();
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
<?php
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
include '../../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db, redirectIfAnonymous: false);
|
||||
FeedReaderCentral\Security::verifyUser(redirectIfAnonymous: false);
|
||||
|
||||
page_head('About the CLI | Documentation'); ?>
|
||||
<h1>About the CLI</h1>
|
||||
@@ -25,4 +21,3 @@ page_head('About the CLI | Documentation'); ?>
|
||||
<p><code>php-cli util/some-process.php command option1 option2</code>
|
||||
</article><?php
|
||||
page_foot();
|
||||
$db->close();
|
||||
|
||||
@@ -7,24 +7,23 @@
|
||||
|
||||
use BitBadger\Documents\DocumentException;
|
||||
use BitBadger\Documents\Field;
|
||||
use BitBadger\Documents\SQLite\Configuration;
|
||||
use BitBadger\Documents\SQLite\Delete;
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Feed;
|
||||
use FeedReaderCentral\Security;
|
||||
use FeedReaderCentral\Table;
|
||||
|
||||
include '../../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db);
|
||||
Security::verifyUser();
|
||||
|
||||
$feedId = $_GET['id'] ?? '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
|
||||
try {
|
||||
if (!($feed = Feed::retrieveById($feedId))) not_found();
|
||||
Delete::byFields(Table::ITEM, [Field::EQ('feed_id', $feed->id)], $db);
|
||||
Delete::byId(Table::FEED, $feed->id, $db);
|
||||
Delete::byFields(Table::ITEM, [Field::EQ('feed_id', $feed->id)]);
|
||||
Delete::byId(Table::FEED, $feed->id);
|
||||
add_info('Feed “' . htmlentities($feed->title) . '” deleted successfully');
|
||||
$db->close();
|
||||
frc_redirect('/feeds');
|
||||
@@ -33,6 +32,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
|
||||
}
|
||||
}
|
||||
|
||||
$db = Configuration::dbConn();
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
try {
|
||||
$isNew = $_POST['id'] == 'new';
|
||||
|
||||
@@ -5,18 +5,18 @@
|
||||
* Lists items in a given feed (all, unread, or bookmarked)
|
||||
*/
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use BitBadger\Documents\SQLite\Configuration;
|
||||
use FeedReaderCentral\Feed;
|
||||
use FeedReaderCentral\ItemList;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
include '../../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db);
|
||||
Security::verifyUser();
|
||||
|
||||
if (!($feed = Feed::retrieveById($_GET['id']))) not_found();
|
||||
|
||||
$db = Configuration::dbConn();
|
||||
$list = match (true) {
|
||||
key_exists('unread', $_GET) => ItemList::unreadForFeed($feed->id, $db),
|
||||
key_exists('bookmarked', $_GET) => ItemList::bookmarkedForFeed($feed->id, $db),
|
||||
|
||||
@@ -10,7 +10,6 @@ use BitBadger\Documents\Field;
|
||||
use BitBadger\Documents\JsonMapper;
|
||||
use BitBadger\Documents\Query;
|
||||
use BitBadger\Documents\SQLite\Custom;
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Feed;
|
||||
use FeedReaderCentral\Key;
|
||||
use FeedReaderCentral\Security;
|
||||
@@ -18,8 +17,7 @@ use FeedReaderCentral\Table;
|
||||
|
||||
include '../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db);
|
||||
Security::verifyUser();
|
||||
|
||||
// TODO: adapt query when document list is done
|
||||
$field = Field::EQ('user_id', $_SESSION[Key::USER_ID], '@user');
|
||||
@@ -52,4 +50,3 @@ page_head('Your Feeds'); ?>
|
||||
}); ?>
|
||||
</article><?php
|
||||
page_foot();
|
||||
$db->close();
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
* Displays a list of unread or bookmarked items for the current user
|
||||
*/
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use BitBadger\Documents\SQLite\Configuration;
|
||||
use FeedReaderCentral\Feed;
|
||||
use FeedReaderCentral\ItemList;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
include '../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db);
|
||||
Security::verifyUser();
|
||||
|
||||
$db = Configuration::dbConn();
|
||||
if (key_exists('refresh', $_GET)) {
|
||||
$refreshResult = Feed::refreshAll($db);
|
||||
if (key_exists('ok', $refreshResult)) {
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
use BitBadger\Documents\DocumentException;
|
||||
use BitBadger\Documents\SQLite\Configuration;
|
||||
use BitBadger\Documents\SQLite\Delete;
|
||||
use BitBadger\Documents\SQLite\Patch;
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Item;
|
||||
use FeedReaderCentral\Key;
|
||||
use FeedReaderCentral\Security;
|
||||
@@ -17,16 +17,14 @@ use FeedReaderCentral\Table;
|
||||
|
||||
include '../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db);
|
||||
Security::verifyUser();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
try {
|
||||
// "Keep as New" button sends a POST request to reset the is_read flag before going back to the item list
|
||||
if (Item::retrieveByIdForUser($_POST['id'])) {
|
||||
Patch::byId(Table::ITEM, $_POST['id'], ['is_read' => 0], $db);
|
||||
Patch::byId(Table::ITEM, $_POST['id'], ['is_read' => 0]);
|
||||
}
|
||||
$db->close();
|
||||
frc_redirect($_POST['from']);
|
||||
} catch (DocumentException $ex) {
|
||||
add_error("$ex");
|
||||
@@ -38,16 +36,16 @@ $from = $_GET['from'] ?? '/';
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
|
||||
try {
|
||||
if (Item::retrieveByIdForUser($_GET['id'])) {
|
||||
Delete::byId(Table::ITEM, $_GET['id'], $db);
|
||||
Delete::byId(Table::ITEM, $_GET['id']);
|
||||
}
|
||||
} catch (DocumentException $ex) {
|
||||
add_error("$ex");
|
||||
}
|
||||
$db->close();
|
||||
frc_redirect($from);
|
||||
}
|
||||
|
||||
// TODO: convert this query
|
||||
$db = Configuration::dbConn();
|
||||
$query = $db->prepare(<<<'SQL'
|
||||
SELECT item.title AS item_title, item.item_link, item.published_on, item.updated_on, item.content,
|
||||
feed.title AS feed_title
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
* Search for items across all feeds
|
||||
*/
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use BitBadger\Documents\SQLite\Configuration;
|
||||
use FeedReaderCentral\ItemList;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
include '../start.php';
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db);
|
||||
Security::verifyUser();
|
||||
|
||||
$search = $_GET['search'] ?? '';
|
||||
$items = $_GET['items'] ?? 'all';
|
||||
|
||||
$db = Configuration::dbConn();
|
||||
if ($search != '') {
|
||||
$list = ItemList::matchingSearch($search, $items == 'bookmarked', $db);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
<?php
|
||||
include '../../start.php';
|
||||
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Key;
|
||||
use FeedReaderCentral\Security;
|
||||
|
||||
$db = Data::getConnection();
|
||||
Security::verifyUser($db, redirectIfAnonymous: false);
|
||||
Security::verifyUser(redirectIfAnonymous: false);
|
||||
|
||||
// Users already logged on have no need of this page
|
||||
if (key_exists(Key::USER_ID, $_SESSION)) frc_redirect('/');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
Security::logOnUser($_POST['email'] ?? '', $_POST['password'], $_POST['returnTo'] ?? null, $db);
|
||||
Security::logOnUser($_POST['email'] ?? '', $_POST['password'], $_POST['returnTo'] ?? null);
|
||||
// If we're still here, something didn't work; preserve the returnTo parameter
|
||||
$_GET['returnTo'] = $_POST['returnTo'];
|
||||
}
|
||||
@@ -41,4 +39,3 @@ page_head('Log On'); ?>
|
||||
</form>
|
||||
</article><?php
|
||||
page_foot();
|
||||
$db->close();
|
||||
|
||||
Reference in New Issue
Block a user