First cut of log on page (#9)
- Add session support - Refactor security handling to use db connection - Fix db path issue
This commit is contained in:
@@ -229,7 +229,7 @@ class Feed {
|
||||
private static function refreshFeed(string $url, SQLite3 $db): array {
|
||||
$feedQuery = $db->prepare('SELECT id FROM feed WHERE url = :url AND user_id = :user');
|
||||
$feedQuery->bindValue(':url', $url);
|
||||
$feedQuery->bindValue(':user', $_REQUEST[Key::USER_ID]);
|
||||
$feedQuery->bindValue(':user', $_SESSION[Key::USER_ID]);
|
||||
$feedResult = $feedQuery->execute();
|
||||
$feedId = $feedResult ? $feedResult->fetchArray(SQLITE3_NUM)[0] : -1;
|
||||
if ($feedId < 0) return ['error' => "No feed for URL $url found"];
|
||||
@@ -273,7 +273,7 @@ class Feed {
|
||||
INSERT INTO feed (user_id, url, title, updated_on, checked_on)
|
||||
VALUES (:user, :url, :title, :updated, :checked)
|
||||
SQL);
|
||||
$query->bindValue(':user', $_REQUEST[Key::USER_ID]);
|
||||
$query->bindValue(':user', $_SESSION[Key::USER_ID]);
|
||||
$query->bindValue(':url', $feed['url']);
|
||||
$query->bindValue(':title', self::eltValue($feed['channel'], 'title'));
|
||||
$query->bindValue(':updated', $feed['updated']);
|
||||
@@ -300,7 +300,7 @@ class Feed {
|
||||
$query = $db->prepare('UPDATE feed SET url = :url WHERE id = :id AND user_id = :user');
|
||||
$query->bindValue(':url', $url);
|
||||
$query->bindValue(':id', $existing['id']);
|
||||
$query->bindValue(':user', $_REQUEST[Key::USER_ID]);
|
||||
$query->bindValue(':user', $_SESSION[Key::USER_ID]);
|
||||
$query->execute();
|
||||
|
||||
return self::refreshFeed($url, $db);
|
||||
@@ -312,7 +312,7 @@ class Feed {
|
||||
*/
|
||||
public static function refreshAll(SQLite3 $db): array {
|
||||
$query = $db->prepare('SELECT url FROM feed WHERE user_id = :user');
|
||||
$query->bindValue(':user', $_REQUEST[Key::USER_ID]);
|
||||
$query->bindValue(':user', $_SESSION[Key::USER_ID]);
|
||||
$result = $query->execute();
|
||||
$url = $result ? $result->fetchArray(SQLITE3_NUM) : false;
|
||||
if ($url) {
|
||||
|
||||
Reference in New Issue
Block a user