80 lines
3.2 KiB
PHP
80 lines
3.2 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
// If the user is already logged in, redirect them to the admin dashboard
|
|
if (isset($_SESSION['is_admin']) && $_SESSION['is_admin'] === true) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
// WARNING: This is a highly insecure, hardcoded password for demonstration purposes only.
|
|
// In a real-world application, you MUST use a secure, hashed password system.
|
|
$hardcoded_password = 'admin123';
|
|
|
|
if (isset($_POST['password']) && $_POST['password'] === $hardcoded_password) {
|
|
// On successful login, set a session variable
|
|
$_SESSION['is_admin'] = true;
|
|
header('Location: index.php');
|
|
exit;
|
|
} else {
|
|
$error = 'رمز عبور اشتباه است.';
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fa" dir="rtl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>ورود به پنل مدیریت</title>
|
|
<meta name="robots" content="noindex, nofollow">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="../assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
</head>
|
|
<body class="bg-dark text-white">
|
|
|
|
<div class="container">
|
|
<div class="row justify-content-center align-items-center" style="height: 100vh;">
|
|
<div class="col-md-4">
|
|
<div class="card bg-dark-2">
|
|
<div class="card-body p-4">
|
|
<h1 class="font-lalezar text-center mb-4">ورود به پنل</h1>
|
|
<p class="text-center text-muted mb-4">رمز عبور: admin123</p>
|
|
<?php if ($error): ?>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
Swal.fire({
|
|
toast: true,
|
|
position: 'top-start',
|
|
icon: 'error',
|
|
title: '<?php echo $error; ?>',
|
|
showConfirmButton: false,
|
|
timer: 3000,
|
|
timerProgressBar: true,
|
|
background: '#2C2C2C',
|
|
color: '#D5D5D5'
|
|
});
|
|
});
|
|
</script>
|
|
<?php endif; ?>
|
|
<form method="POST">
|
|
<div class="mb-3">
|
|
<label for="password" class="form-label">رمز عبور</label>
|
|
<input type="password" class="form-control bg-dark text-white" id="password" name="password" required>
|
|
</div>
|
|
<div class="d-grid">
|
|
<button type="submit" class="btn btn-primary">ورود</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|