| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/bpkd_/admin/ |
Upload File : |
<?php
// =====================================================
// HAPUS redirect .php (sudah ditangani .htaccess)
// =====================================================
// Load konfigurasi database dulu
require_once 'config/database.php';
// Load fungsi-fungsi umum (termasuk sanitize)
require_once '../includes/config.php'; // Load BASE_URL
require_once '../includes/init.php';
require_once 'includes/init.php';
// Redirect if already logged in
if (isLoggedIn()) {
redirect(BASE_URL . '/admin/dashboard');
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = sanitize($_POST['username']);
$password = $_POST['password'];
// =====================================================
// PERBAIKAN: Cek struktur tabel terlebih dahulu
// =====================================================
// Cek apakah kolom 'status' ada
$check_columns = $conn->query("SHOW COLUMNS FROM users");
$has_status = false;
if ($check_columns) {
while($col = $check_columns->fetch_assoc()) {
if ($col['Field'] == 'status') {
$has_status = true;
break;
}
}
}
// Buat query sesuai struktur tabel
if ($has_status) {
$query = "SELECT * FROM users WHERE username = ? AND status = 'active'";
} else {
$query = "SELECT * FROM users WHERE username = ?";
}
$stmt = $conn->prepare($query);
// Cek apakah prepare berhasil
if ($stmt === false) {
$error = "Error database: " . $conn->error;
} else {
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result && $result->num_rows > 0) {
$user = $result->fetch_assoc();
// Cek password (support MD5 lama dan password_hash baru)
if (password_verify($password, $user['password']) || md5($password) == $user['password']) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
$_SESSION['full_name'] = $user['full_name'] ?? $user['username'];
$_SESSION['role'] = $user['role'] ?? 'editor';
// Update last login (cek dulu kolomnya ada)
$check_last_login = $conn->query("SHOW COLUMNS FROM users LIKE 'last_login'");
if ($check_last_login && $check_last_login->num_rows > 0) {
$conn->query("UPDATE users SET last_login = NOW() WHERE id = " . $user['id']);
}
redirect(BASE_URL . '/admin/dashboard');
} else {
$error = 'Username atau password salah!';
}
} else {
$error = 'Username atau password salah!';
}
$stmt->close();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - BPKD LUMAJANG</title>
<!-- Google Fonts -->
<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@300;400;500;600;700;800&family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome 6 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Animate.css -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
<link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>/admin/assets/images/favicon.png">
<link rel="shortcut icon" href="<?php echo BASE_URL; ?>/admin/assets/images/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" href="<?php echo BASE_URL; ?>/admin/assets/images/favicon.png">
<style>
:root {
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--font-primary: 'Inter', sans-serif;
--font-secondary: 'Poppins', sans-serif;
}
body {
background: var(--primary-gradient);
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-family: var(--font-primary);
position: relative;
overflow: hidden;
}
body::before {
content: '';
position: absolute;
width: 200%;
height: 200%;
background: repeating-linear-gradient(
45deg,
rgba(255,255,255,0.03) 0px,
rgba(255,255,255,0.03) 20px,
transparent 20px,
transparent 40px
);
animation: moveBg 20s linear infinite;
}
@keyframes moveBg {
0% { transform: translate(-10%, -10%) rotate(0deg); }
100% { transform: translate(10%, 10%) rotate(10deg); }
}
.login-card {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border-radius: 30px;
box-shadow: 0 25px 50px rgba(0,0,0,0.3);
padding: 50px;
width: 100%;
max-width: 450px;
position: relative;
z-index: 1;
animation: slideInUp 0.8s ease-out;
}
@keyframes slideInUp {
from {
opacity: 0;
transform: translateY(50px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.login-header {
text-align: center;
margin-bottom: 40px;
}
.login-header .logo {
width: 80px;
height: 80px;
background: var(--primary-gradient);
border-radius: 20px;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 25px;
color: white;
font-size: 40px;
transform: rotate(-5deg);
transition: transform 0.3s;
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}
.login-header .logo:hover {
transform: rotate(0deg);
}
.login-header h3 {
font-family: var(--font-secondary);
color: #333;
font-weight: 700;
font-size: 2rem;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.login-header p {
color: #666;
font-size: 0.95rem;
font-weight: 400;
}
.form-floating {
margin-bottom: 20px;
position: relative;
}
.form-floating input {
border: 2px solid #e9ecef;
border-radius: 15px;
padding: 1rem 1rem 1rem 3rem;
height: auto;
font-family: var(--font-primary);
font-size: 1rem;
transition: all 0.3s;
}
.form-floating input:focus {
border-color: #667eea;
box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
transform: translateY(-2px);
}
.form-floating label {
padding-left: 3rem;
color: #999;
}
.input-icon {
position: absolute;
left: 1rem;
top: 50%;
transform: translateY(-50%);
z-index: 10;
color: #667eea;
font-size: 1.2rem;
}
.btn-login {
background: var(--primary-gradient);
border: none;
color: white;
padding: 15px;
border-radius: 15px;
font-weight: 600;
width: 100%;
transition: all 0.3s;
font-size: 1.1rem;
letter-spacing: 0.5px;
margin-top: 20px;
position: relative;
overflow: hidden;
}
.btn-login::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
transition: left 0.5s;
}
.btn-login:hover {
transform: translateY(-3px);
box-shadow: 0 15px 30px rgba(102, 126, 234, 0.4);
}
.btn-login:hover::before {
left: 100%;
}
.alert {
border-radius: 15px;
border: none;
padding: 15px 20px;
font-size: 0.95rem;
animation: shake 0.5s;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.back-link {
text-align: center;
margin-top: 20px;
}
.back-link a {
color: #667eea;
text-decoration: none;
font-size: 0.85rem;
transition: all 0.3s;
}
.back-link a:hover {
color: #764ba2;
text-decoration: underline;
}
.floating-shape {
position: absolute;
background: rgba(255,255,255,0.1);
border-radius: 50%;
pointer-events: none;
}
.shape1 {
width: 300px;
height: 300px;
top: -150px;
right: -150px;
background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
animation: float 8s ease-in-out infinite;
}
.shape2 {
width: 200px;
height: 200px;
bottom: -100px;
left: -100px;
background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
animation: float 10s ease-in-out infinite reverse;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) rotate(0deg); }
33% { transform: translate(30px, -30px) rotate(120deg); }
66% { transform: translate(-20px, 20px) rotate(240deg); }
}
</style>
</head>
<body>
<div class="floating-shape shape1"></div>
<div class="floating-shape shape2"></div>
<div class="login-card animate__animated animate__fadeIn">
<div class="login-header">
<div class="logo">
<i class="fas fa-building"></i>
</div>
<h3>BPKD</h3>
<p>Silakan login untuk mengakses dashboard</p>
</div>
<?php if ($error): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="fas fa-exclamation-circle me-2"></i><?php echo $error; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<?php endif; ?>
<form method="POST" action="<?php echo BASE_URL; ?>/admin/login.php">
<div class="form-floating mb-3">
<i class="fas fa-user input-icon"></i>
<input type="text" class="form-control" id="username" name="username" placeholder="Username" required autofocus>
<label for="username">Username</label>
</div>
<div class="form-floating mb-4">
<i class="fas fa-lock input-icon"></i>
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
<label for="password">Password</label>
</div>
<button type="submit" class="btn btn-login">
<i class="fas fa-sign-in-alt me-2"></i>Login
</button>
</form>
<div class="back-link">
<a href="<?php echo BASE_URL; ?>">
<i class="fas fa-arrow-left me-1"></i> Kembali ke Website
</a>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>