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:
+2
-4
@@ -15,9 +15,7 @@ $dotenv->safeLoad();
|
||||
if (!isset($_SESSION['initialized'])) {
|
||||
$_SESSION['initialized'] = true;
|
||||
$_SESSION['theme'] = 'dark';
|
||||
}
|
||||
|
||||
if ($_SESSION['initialized'] && isset($_POST['theme'])) {
|
||||
} else if (isset($_POST['theme'])) {
|
||||
$_SESSION['theme'] = $_POST['theme'];
|
||||
unset($_POST['theme']);
|
||||
}
|
||||
@@ -49,7 +47,7 @@ if (isset($_COOKIE['user_id'])) {
|
||||
|
||||
if (hash('sha256', $_SERVER['REMOTE_ADDR']) != $remember['remote_addr'] || (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && hash('sha256', $_SERVER['HTTP_X_FORWARDED_FOR']) != $remember['forwarded_for'])) {
|
||||
// TODO: Log the attempt to use a cookie from a different browser/device than the cookie was created
|
||||
echo 'Naughty, you are trying to use someone else\'s cookie...';
|
||||
echo "Naughty, you are trying to use someone else's cookie...";
|
||||
} else {
|
||||
$stmt = $conn->prepare('SELECT user_id, username, email, role_id, profile_picture FROM user WHERE user_id = ?');
|
||||
$stmt->bind_param('s', $remember['user_id']);
|
||||
|
||||
Reference in New Issue
Block a user