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
+6 -11
View File
@@ -4,18 +4,13 @@
<head>
<link href="css/base.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://nerdfonts.com/assets/css/webfont.css">
<link rel="icon" type="image/x-icon" href="data/vintagecoding-favicon.png">
<link rel="icon" type="image/x-icon" href="data/vintagecoding-favicon.png" </link>
<?php
if ($_SESSION['theme'] == 'dark') {
echo '
<link href="css/dark.css" rel="stylesheet" type="text/css">
';
} elseif ($_SESSION['theme'] == 'light') {
echo '
<link href="css/light.css" rel="stylesheet" type="text/css">
';
}
?>
if (!isset($_SESSION['theme']) || $_SESSION['theme'] == 'dark')
echo '<link href="css/dark.css" rel="stylesheet" type="text/css">';
else
echo '<link href="css/light.css" rel="stylesheet" type="text/css">';
?>
</head>
+8 -8
View File
@@ -10,19 +10,19 @@ $nav = '
';
if (isset($_COOKIE['role_id']) && $_COOKIE['role_id'] <= 2) {
$nav .= '
$nav .= '
<li><a href="/admin.php?view=users"' . ($current_page == '/admin.php' ? ' class="underline"' : '') . '>Admin</a></li>
';
}
if (isset($_COOKIE['user_id'])) {
$nav .= '
$nav .= '
<li><a href="/user.php?action=view&user_id=' . $_COOKIE['user_id'] . '"' . ($current_page == '/user.php' ? ' class="underline"' : '') . '>Account</a></li>
';
}
if (isset($_COOKIE['role_id']) && $_COOKIE['role_id'] <= 3) {
$nav .= '
$nav .= '
<li><a href="/compose.php"' . ($current_page == '/compose.php' ? ' class="underline"' : '') . '>Compose</a></li>
';
}
@@ -36,21 +36,21 @@ $nav .= '
$theme_toggle = '';
if ($_SESSION['theme'] == 'dark')
$theme_toggle = 'light';
$theme_toggle = 'light';
else
$theme_toggle = 'dark';
$theme_toggle = 'dark';
$nav .= '
<button id="theme-toggle" value="' . $theme_toggle . '" name="theme" onchange="this.form.submit()"><i class="nf ' . ($theme_toggle == 'dark' ? 'nf-oct-moon' : 'nf-oct-sun') . '"></i></button>
<button id="theme_toggle" value="' . $theme_toggle . '" name="theme"><i class="nf ' . ($theme_toggle == 'dark' ? 'nf-oct-moon' : 'nf-oct-sun') . '"></i></button>
</form>
';
if (isset($_COOKIE['username'])) {
$nav .= '
$nav .= '
<a href="user.php?action=logout">Log Out</a>
';
} else {
$nav .= '
$nav .= '
<a href="user.php?action=login">Login</a>
<a href="user.php?action=signup">Sign Up</a>
';