added login requirement to view articles to protect against potential data scrapping, with redirect functionality to the article the user attempts to view prior to login.

This commit is contained in:
2025-04-12 13:40:51 -06:00
parent f4dfaba1c6
commit 8d78a7d182
11 changed files with 102 additions and 195 deletions
+7 -2
View File
@@ -36,7 +36,6 @@ if (!isset($_GET['article_id']) && !isset($_GET['tag']) && !isset($_GET['author_
</form>
';
echo '
<div class="article_cards_grid">
<div class="article_filters">
@@ -50,7 +49,7 @@ if (!isset($_GET['article_id']) && !isset($_GET['tag']) && !isset($_GET['author_
</div>
</div>
';
} else if (isset($_GET['article_id'])) {
} else if (isset($_COOKIE['user_id']) && isset($_GET['article_id'])) {
increment_read_counter($_GET['article_id']);
echo article_page_from_markdown($_GET['article_id']);
} else if (isset($_GET['author_id'])) {
@@ -63,6 +62,12 @@ if (!isset($_GET['article_id']) && !isset($_GET['tag']) && !isset($_GET['author_
foreach ($ids as $id)
echo article_card($id);
} else {
$redirect = (isset($_GET['article_id']) ? 'articles.php?article_id=' . $_GET['article_id'] : '');
if ($redirect)
header('Location: user.php?action=login&redirect=' . urlencode($redirect));
else
header('Location: articles.php');
}
include_once 'components/foot.php';