This commit is contained in:
devdatt 2026-01-01 04:24:56 +05:30
parent 61b71ff589
commit 7e0b463e46
5 changed files with 57 additions and 4 deletions

View File

@ -1,4 +1,7 @@
<?php include 'static.php'; ?>
<?php
require 'require_login.php';
include 'static.php';
?>
<!doctype html>
<html lang="en">

View File

@ -1,6 +1,13 @@
<?php
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: 0');
session_start();
if (!empty($_SESSION['user'])) {
header('Location: /index.php', true, 302);
exit;
}
/* ---------- CONFIG ---------- */
$usersFile = '/var/www/users.json';
$attemptsFile = '/var/www/attempts.json';
@ -72,7 +79,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
unset($attempts[$ip]);
save_json($attemptsFile, $attempts);
$_SESSION['user'] = $username;
header('Location: dashboard.php');
header('Location: index.php');
exit;
}

22
encoder/logout.php Normal file
View File

@ -0,0 +1,22 @@
<?php
session_start();
$_SESSION = [];
if (ini_get('session.use_cookies')) {
$p = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 42000,
$p['path'],
$p['domain'],
$p['secure'],
$p['httponly']
);
}
session_destroy();
header('Location: /login.php');
exit;

21
encoder/require_login.php Normal file
View File

@ -0,0 +1,21 @@
<?php
// auth/require_login.php
declare(strict_types=1);
session_start();
/* ---------- SECURITY HEADERS (optional but recommended) ---------- */
header('X-Frame-Options: DENY');
header('X-Content-Type-Options: nosniff');
header('Referrer-Policy: strict-origin-when-cross-origin');
/* ---------- LOGIN CHECK ---------- */
if (empty($_SESSION['user'])) {
// Prevent cache of protected pages
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Location: /login.php', true, 302);
exit;
}

View File

@ -1,5 +1,5 @@
{
"shreebhattji": {
"password": "$2y$10$eImiTXuWVxfM37uY4JANjQ=="
"password": "$2y$10$BInKRv9mhK69VfYKIi4WVegAs9VWtLhfdZH4YoDk5aE2U61cmyT2a"
}
}