%PDF- %PDF-
| Direktori : /home2/rezakur1/ternakdolar.my.id/Ternak-Dolar/ |
| Current File : //home2/rezakur1/ternakdolar.my.id/Ternak-Dolar/gate.php |
<?php
require_once __DIR__ . '/auth.php';
// Already logged in? redirect to main
if (isLoggedIn()) {
header('Location: index.php');
exit;
}
// Handle login POST
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Validate CSRF token
$csrfToken = $_POST['csrf_token'] ?? '';
if (!validateCSRFToken($csrfToken)) {
$error = 'Sesi tidak valid. Silakan muat ulang halaman.';
} else {
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
$result = loginUser($email, $password);
if ($result['success']) {
header('Location: index.php');
exit;
} else {
$error = $result['error'];
}
}
}
// Check if currently rate limited (for display)
$ip = getClientIP();
$rateLimit = checkLoginRateLimit($ip);
if ($rateLimit['blocked'] && empty($error)) {
$mins = (int) ceil($rateLimit['remaining_seconds'] / 60);
$error = "Terlalu banyak percobaan login. Coba lagi dalam {$mins} menit.";
}
$isLocked = $rateLimit['blocked'];
?>
<!DOCTYPE html>
<html lang="id" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login — Ternak Dolar</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
ink: {
950: '#08090d', 900: '#0d0f15', 850: '#12151d',
800: '#171b26', 750: '#1d2230', 700: '#252b3a',
600: '#333a4d', 500: '#4a5268',
}
},
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
mono: ['JetBrains Mono', 'ui-monospace', 'monospace']
},
animation: {
'fade-in': 'fadeIn .4s ease-out',
'slide-up': 'slideUp .5s cubic-bezier(.4, 0, .2, 1)',
'pulse-soft': 'pulseSoft 2s ease-in-out infinite',
'shake': 'shake .3s ease-in-out',
},
keyframes: {
fadeIn: { '0%': { opacity: 0 }, '100%': { opacity: 1 } },
slideUp: { '0%': { opacity: 0, transform: 'translateY(16px) scale(.98)' }, '100%': { opacity: 1, transform: 'translateY(0) scale(1)' } },
pulseSoft: { '0%, 100%': { opacity: 1 }, '50%': { opacity: .5 } },
shake: { '0%, 100%': { transform: 'translateX(0)' }, '25%': { transform: 'translateX(-6px)' }, '75%': { transform: 'translateX(6px)' } },
}
}
}
}
</script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
html, body { height: 100%; }
body {
background: #f1f5f9;
transition: background .3s ease;
font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
.dark body {
background: #08090d;
color: #e2e8f0;
background-image:
radial-gradient(ellipse 80% 60% at 50% -10%, rgba(56, 189, 248, .06), transparent),
radial-gradient(ellipse 60% 50% at 90% 100%, rgba(239, 68, 68, .05), transparent);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #94a3b8; background-clip: padding-box; border: 2px solid transparent; }
.dark ::-webkit-scrollbar-thumb { background: #252b3a; background-clip: padding-box; border: 2px solid transparent; }
.dark ::-webkit-scrollbar-thumb:hover { background-color: #333a4d; background-clip: padding-box; }
.grid-bg {
background-image:
linear-gradient(rgba(148, 163, 184, .04) 1px, transparent 1px),
linear-gradient(90deg, rgba(148, 163, 184, .04) 1px, transparent 1px);
background-size: 40px 40px;
}
</style>
</head>
<body class="min-h-screen text-slate-800 dark:text-slate-200 antialiased">
<div class="flex min-h-screen flex-col grid-bg">
<!-- Navbar -->
<nav class="sticky top-0 z-40 border-b border-slate-200/80 bg-white/70 backdrop-blur-xl dark:border-ink-700/60 dark:bg-ink-900/60">
<div class="flex items-center justify-between gap-4 px-6 py-3.5 lg:px-8">
<div class="flex items-center gap-3.5 min-w-0">
<div class="relative grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-gradient-to-br from-emerald-500 via-emerald-600 to-green-700 text-white shadow-lg shadow-emerald-500/20">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>
</svg>
</div>
<div class="min-w-0">
<h1 class="truncate text-base font-bold tracking-tight text-slate-900 dark:text-white">
Ternak Dolar
</h1>
<p class="truncate text-[11px] font-medium text-slate-500 dark:text-slate-500">
Ternak Dolar
</p>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="flex flex-1 items-center justify-center p-6 lg:p-8">
<div class="w-full max-w-sm animate-slide-up">
<!-- Login Card -->
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm dark:border-ink-700 dark:bg-ink-850">
<!-- Card Header -->
<div class="border-b border-slate-200/60 bg-slate-50/80 px-6 py-5 text-center dark:border-ink-700/40 dark:bg-ink-800/50">
<div class="mx-auto mb-3 grid h-12 w-12 place-items-center rounded-xl bg-gradient-to-br from-emerald-500 via-emerald-600 to-green-700 text-white shadow-lg shadow-emerald-500/20">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>
</svg>
</div>
<h2 class="text-lg font-bold tracking-tight text-slate-900 dark:text-white">Masuk ke Akun</h2>
<p class="mt-1 text-[11px] font-medium text-slate-500 dark:text-slate-400">Masukkan kredensial Anda untuk melanjutkan</p>
</div>
<!-- Error message -->
<?php if ($error): ?>
<div class="animate-shake border-b border-red-200 bg-red-50 px-6 py-3 dark:border-red-900/40 dark:bg-red-950/40">
<div class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5 shrink-0 text-red-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/>
</svg>
<p class="text-[11px] font-semibold text-red-700 dark:text-red-400"><?= htmlspecialchars($error) ?></p>
</div>
</div>
<?php endif; ?>
<!-- Form -->
<form method="POST" action="gate.php" class="p-6">
<?= getCSRFTokenField() ?>
<!-- Email -->
<div class="mb-4">
<label for="email" class="mb-2 block text-[10px] font-bold uppercase tracking-wider text-slate-400 dark:text-slate-500">
Email
</label>
<div class="relative">
<svg xmlns="http://www.w3.org/2000/svg" class="pointer-events-none absolute left-3.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400 dark:text-slate-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/>
</svg>
<input id="email" name="email" type="email" required autocomplete="email" autofocus
value="<?= htmlspecialchars($_POST['email'] ?? '') ?>"
placeholder="nama@email.com"
<?= $isLocked ? 'disabled' : '' ?>
class="w-full rounded-xl border border-slate-200 bg-white py-2.5 pl-10 pr-4 text-sm outline-none transition-all placeholder:text-slate-400 focus:border-emerald-400 focus:ring-4 focus:ring-emerald-500/10 dark:border-ink-700 dark:bg-ink-900 dark:text-slate-200 dark:placeholder:text-slate-500 dark:focus:border-emerald-500/60 dark:focus:ring-emerald-500/10 disabled:opacity-50 disabled:cursor-not-allowed">
</div>
</div>
<!-- Password -->
<div class="mb-6">
<label for="password" class="mb-2 block text-[10px] font-bold uppercase tracking-wider text-slate-400 dark:text-slate-500">
Password
</label>
<div class="relative">
<svg xmlns="http://www.w3.org/2000/svg" class="pointer-events-none absolute left-3.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400 dark:text-slate-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>
</svg>
<input id="password" name="password" type="password" required autocomplete="current-password"
placeholder="Masukkan password"
<?= $isLocked ? 'disabled' : '' ?>
class="w-full rounded-xl border border-slate-200 bg-white py-2.5 pl-10 pr-11 text-sm outline-none transition-all placeholder:text-slate-400 focus:border-emerald-400 focus:ring-4 focus:ring-emerald-500/10 dark:border-ink-700 dark:bg-ink-900 dark:text-slate-200 dark:placeholder:text-slate-500 dark:focus:border-emerald-500/60 dark:focus:ring-emerald-500/10 disabled:opacity-50 disabled:cursor-not-allowed">
<button type="button" onclick="togglePassword()" class="absolute right-3 top-1/2 -translate-y-1/2 rounded-md p-0.5 text-slate-400 transition hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300" tabindex="-1">
<svg id="eyeIcon" xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>
</svg>
</button>
</div>
</div>
<!-- Submit -->
<button type="submit"
<?= $isLocked ? 'disabled' : '' ?>
class="group flex w-full items-center justify-center gap-2 rounded-xl bg-gradient-to-b from-slate-900 to-slate-800 py-2.5 text-xs font-semibold text-white shadow-lg shadow-slate-900/10 transition-all hover:from-slate-800 hover:to-slate-700 hover:shadow-slate-900/20 active:scale-[.97] dark:from-white dark:to-slate-100 dark:text-ink-900 dark:shadow-white/5 dark:hover:from-slate-100 dark:hover:to-white disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100">
<?php if ($isLocked): ?>
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>
</svg>
Dikunci Sementara
<?php else: ?>
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5 transition-transform group-hover:translate-x-0.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/>
<polyline points="10 17 15 12 10 7"/>
<line x1="15" y1="12" x2="3" y2="12"/>
</svg>
Masuk
<?php endif; ?>
</button>
</form>
</div>
</div>
</main>
<!-- Footer -->
<footer class="border-t border-slate-200/70 bg-white/40 px-6 py-3 backdrop-blur dark:border-ink-700/60 dark:bg-ink-900/40 lg:px-8">
<div class="flex items-center justify-between text-[11px] font-medium text-slate-400 dark:text-slate-500">
<span>Ternak Dolar</span>
<span>© 2026 · Ternak Dolar</span>
</div>
</footer>
</div>
<script>
function togglePassword() {
const input = document.getElementById('password');
const icon = document.getElementById('eyeIcon');
if (input.type === 'password') {
input.type = 'text';
icon.innerHTML = '<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/>';
} else {
input.type = 'password';
icon.innerHTML = '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>';
}
}
</script>
</body>
</html>