2022-01-09 00:32:18 +00:00

45 lines
777 B
PHP
Executable File

<?php
session_set_cookie_params(3600);
session_start();
if (!isset($_SESSION['login_attempts'])) {
$_SESSION['login_attempts'] = 0;
}
$token = $_POST['token'];
if (!isset($_SESSION['uid'])) {
if ($_SESSION['login_attempts'] >= 5) {
http_response_code(403);
die("Error: too many login attempts.");
}
if (!isset($token)) {
?>
<!DOCTYPE HTML>
<html>
<body>
<form action="/admin/login.php" method="POST">
<div>
<p>Enter passcode:</p>
<input type="password" name="token">
</div>
<div>
<button type="submit">Login</button>
</div>
</form>
</body>
</html>
<?php
die;
} else if ($token !== '1445') {
$_SESSION['login_attempts']++;
http_response_code(403);
die("Error: incorrect token");
} else {
$_SESSION['uid'] = 1;
}
}
header('Location: /admin');