roni
This commit is contained in:
parent
5fa56d3b0d
commit
270903d716
137
admin_dashboard.php
Normal file
137
admin_dashboard.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
require_once __DIR__ . '/includes/auth.php';
|
||||
require_once __DIR__ . '/includes/flash.php';
|
||||
require_once __DIR__ . '/includes/registration_db.php';
|
||||
|
||||
require_admin();
|
||||
ensure_registration_table();
|
||||
|
||||
$registrations = fetch_registrations();
|
||||
$selectedId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
$selected = $selectedId ? fetch_registration($selectedId) : null;
|
||||
$flash = flash_get();
|
||||
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Admin Dashboard</title>
|
||||
<?php if ($projectDescription): ?>
|
||||
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<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=<?= time() ?>">
|
||||
</head>
|
||||
<body class="app-body">
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom">
|
||||
<div class="container">
|
||||
<a class="navbar-brand fw-semibold" href="/">Pendaftaran</a>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<a class="btn btn-outline-secondary btn-sm" href="export_pdf.php">Export PDF</a>
|
||||
<a class="btn btn-dark btn-sm" href="logout.php">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container py-5">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4">
|
||||
<div>
|
||||
<h1 class="h4 fw-semibold mb-1">Report Pendaftar</h1>
|
||||
<p class="text-muted small mb-0">Total pendaftar: <?= count($registrations) ?></p>
|
||||
</div>
|
||||
<div class="small text-muted">
|
||||
Data terbaru otomatis tersimpan di database.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($flash): ?>
|
||||
<div class="alert alert-<?= htmlspecialchars($flash['type']) ?> border-0 small">
|
||||
<?= htmlspecialchars($flash['message']) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row g-4">
|
||||
<div class="col-lg-7">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<h2 class="h6 text-uppercase text-muted">Daftar Pendaftar</h2>
|
||||
<?php if (!$registrations): ?>
|
||||
<div class="alert alert-light border small mb-0">Belum ada pendaftar.</div>
|
||||
<?php else: ?>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm align-middle mb-0">
|
||||
<thead>
|
||||
<tr class="text-muted small">
|
||||
<th>Foto</th>
|
||||
<th>Nama</th>
|
||||
<th>Pendidikan</th>
|
||||
<th>Jurusan</th>
|
||||
<th>Nomor</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($registrations as $row): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="<?= htmlspecialchars($row['photo_path']) ?>" class="rounded-2 border photo-thumb" alt="Foto">
|
||||
</td>
|
||||
<td><?= htmlspecialchars($row['name']) ?></td>
|
||||
<td><?= htmlspecialchars($row['education']) ?></td>
|
||||
<td><?= htmlspecialchars($row['major']) ?></td>
|
||||
<td class="text-muted small"><?= htmlspecialchars($row['reg_code']) ?></td>
|
||||
<td class="text-end">
|
||||
<a class="btn btn-outline-secondary btn-sm" href="admin_dashboard.php?id=<?= (int)$row['id'] ?>">Detail</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-5">
|
||||
<div class="card shadow-sm border-0 h-100">
|
||||
<div class="card-body">
|
||||
<h2 class="h6 text-uppercase text-muted">Detail Pendaftar</h2>
|
||||
<?php if (!$selected): ?>
|
||||
<p class="text-muted small mb-0">Pilih pendaftar dari tabel untuk melihat detail.</p>
|
||||
<?php else: ?>
|
||||
<div class="d-flex align-items-center gap-3 mb-3">
|
||||
<img src="<?= htmlspecialchars($selected['photo_path']) ?>" class="rounded-3 border detail-photo" alt="Foto">
|
||||
<div>
|
||||
<div class="fw-semibold"><?= htmlspecialchars($selected['name']) ?></div>
|
||||
<div class="text-muted small"><?= htmlspecialchars($selected['reg_code']) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="list-unstyled small mb-0">
|
||||
<li class="mb-2"><strong>Pendidikan:</strong> <?= htmlspecialchars($selected['education']) ?></li>
|
||||
<li class="mb-2"><strong>Jurusan:</strong> <?= htmlspecialchars($selected['major']) ?></li>
|
||||
<li class="mb-2"><strong>Waktu daftar:</strong> <?= htmlspecialchars($selected['created_at']) ?></li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
89
admin_login.php
Normal file
89
admin_login.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
require_once __DIR__ . '/includes/auth.php';
|
||||
require_once __DIR__ . '/includes/flash.php';
|
||||
|
||||
if (is_admin_logged_in()) {
|
||||
header('Location: admin_dashboard.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = trim($_POST['username'] ?? '');
|
||||
$password = trim($_POST['password'] ?? '');
|
||||
if (login_admin($username, $password)) {
|
||||
flash_set('success', 'Login berhasil. Selamat datang admin.');
|
||||
header('Location: admin_dashboard.php');
|
||||
exit;
|
||||
}
|
||||
flash_set('danger', 'Username atau password salah.');
|
||||
header('Location: admin_login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$flash = flash_get();
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Login Admin</title>
|
||||
<?php if ($projectDescription): ?>
|
||||
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<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=<?= time() ?>">
|
||||
</head>
|
||||
<body class="app-body">
|
||||
<div class="container py-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-5">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<h1 class="h4 fw-semibold mb-3">Login Admin</h1>
|
||||
<p class="text-muted small">Gunakan kredensial admin untuk mengakses laporan pendaftar.</p>
|
||||
<?php if ($flash): ?>
|
||||
<div class="alert alert-<?= htmlspecialchars($flash['type']) ?> border-0 small">
|
||||
<?= htmlspecialchars($flash['message']) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form method="post" class="needs-validation" novalidate>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="username">Username</label>
|
||||
<input type="text" class="form-control" id="username" name="username" required>
|
||||
<div class="invalid-feedback">Username wajib diisi.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="password">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
<div class="invalid-feedback">Password wajib diisi.</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-dark w-100">Masuk</button>
|
||||
</form>
|
||||
<div class="border-top pt-3 mt-4 small text-muted">
|
||||
Default demo: <strong>admin / admin123</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center mt-3">
|
||||
<a class="text-muted small" href="/">Kembali ke halaman utama</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,403 +1,113 @@
|
||||
body {
|
||||
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
|
||||
background-size: 400% 400%;
|
||||
animation: gradient 15s ease infinite;
|
||||
color: #212529;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
:root {
|
||||
--bg: #f6f7f9;
|
||||
--surface: #ffffff;
|
||||
--border: #e5e7eb;
|
||||
--text: #111827;
|
||||
--muted: #6b7280;
|
||||
--accent: #111827;
|
||||
--accent-soft: #f3f4f6;
|
||||
--radius-sm: 6px;
|
||||
--radius-md: 10px;
|
||||
--shadow-sm: 0 6px 16px rgba(15, 23, 42, 0.08);
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@keyframes gradient {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
body.app-body {
|
||||
font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 85vh;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
|
||||
backdrop-filter: blur(15px);
|
||||
-webkit-backdrop-filter: blur(15px);
|
||||
overflow: hidden;
|
||||
.navbar-brand {
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
padding: 1.5rem;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
font-weight: 700;
|
||||
font-size: 1.1rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.card {
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
.btn {
|
||||
border-radius: var(--radius-sm);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
/* Custom Scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
.btn-dark {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
.btn-outline-secondary {
|
||||
border-color: var(--border);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border-radius: 10px;
|
||||
.btn-outline-secondary:hover {
|
||||
background: var(--accent-soft);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
.photo-preview {
|
||||
min-height: 140px;
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
|
||||
.message {
|
||||
max-width: 85%;
|
||||
padding: 0.85rem 1.1rem;
|
||||
border-radius: 16px;
|
||||
line-height: 1.5;
|
||||
font-size: 0.95rem;
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
|
||||
animation: fadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||
.photo-thumb {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(20px) scale(0.95); }
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
.detail-photo {
|
||||
width: 84px;
|
||||
height: 84px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.message.visitor {
|
||||
align-self: flex-end;
|
||||
background: linear-gradient(135deg, #212529 0%, #343a40 100%);
|
||||
color: #fff;
|
||||
border-bottom-right-radius: 4px;
|
||||
.table thead th {
|
||||
font-weight: 600;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.message.bot {
|
||||
align-self: flex-start;
|
||||
background: #ffffff;
|
||||
color: #212529;
|
||||
border-bottom-left-radius: 4px;
|
||||
.table tbody tr {
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.chat-input-area {
|
||||
padding: 1.25rem;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.05);
|
||||
.border-bottom,
|
||||
.border-top {
|
||||
border-color: var(--border) !important;
|
||||
}
|
||||
|
||||
.chat-input-area form {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
.shadow-sm {
|
||||
box-shadow: var(--shadow-sm) !important;
|
||||
}
|
||||
|
||||
.chat-input-area input {
|
||||
flex: 1;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 12px;
|
||||
padding: 0.75rem 1rem;
|
||||
outline: none;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
transition: all 0.3s ease;
|
||||
.alert {
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.chat-input-area input:focus {
|
||||
border-color: #23a6d5;
|
||||
box-shadow: 0 0 0 3px rgba(35, 166, 213, 0.2);
|
||||
.badge {
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.chat-input-area button {
|
||||
background: #212529;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
.form-control,
|
||||
.form-select {
|
||||
border-radius: var(--radius-sm);
|
||||
border-color: var(--border);
|
||||
}
|
||||
|
||||
.chat-input-area button:hover {
|
||||
background: #000;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
||||
.form-control:focus,
|
||||
.form-select:focus {
|
||||
border-color: #9ca3af;
|
||||
box-shadow: 0 0 0 0.15rem rgba(17, 24, 39, 0.12);
|
||||
}
|
||||
|
||||
/* Background Animations */
|
||||
.bg-animations {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
@media (max-width: 768px) {
|
||||
.display-6 {
|
||||
font-size: 1.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
.blob {
|
||||
position: absolute;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 50%;
|
||||
filter: blur(80px);
|
||||
animation: move 20s infinite alternate cubic-bezier(0.45, 0, 0.55, 1);
|
||||
}
|
||||
|
||||
.blob-1 {
|
||||
top: -10%;
|
||||
left: -10%;
|
||||
background: rgba(238, 119, 82, 0.4);
|
||||
}
|
||||
|
||||
.blob-2 {
|
||||
bottom: -10%;
|
||||
right: -10%;
|
||||
background: rgba(35, 166, 213, 0.4);
|
||||
animation-delay: -7s;
|
||||
width: 600px;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
.blob-3 {
|
||||
top: 40%;
|
||||
left: 30%;
|
||||
background: rgba(231, 60, 126, 0.3);
|
||||
animation-delay: -14s;
|
||||
width: 450px;
|
||||
height: 450px;
|
||||
}
|
||||
|
||||
@keyframes move {
|
||||
0% { transform: translate(0, 0) rotate(0deg) scale(1); }
|
||||
33% { transform: translate(150px, 100px) rotate(120deg) scale(1.1); }
|
||||
66% { transform: translate(-50px, 200px) rotate(240deg) scale(0.9); }
|
||||
100% { transform: translate(0, 0) rotate(360deg) scale(1); }
|
||||
}
|
||||
|
||||
.header-link {
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.header-link:hover {
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Admin Styles */
|
||||
.admin-container {
|
||||
max-width: 900px;
|
||||
margin: 3rem auto;
|
||||
padding: 2.5rem;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border-radius: 24px;
|
||||
box-shadow: 0 20px 50px rgba(0,0,0,0.15);
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.admin-container h1 {
|
||||
margin-top: 0;
|
||||
color: #212529;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 8px;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.table th {
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 1rem;
|
||||
color: #6c757d;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.table td {
|
||||
background: #fff;
|
||||
padding: 1rem;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.table tr td:first-child { border-radius: 12px 0 0 12px; }
|
||||
.table tr td:last-child { border-radius: 0 12px 12px 0; }
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
transition: all 0.3s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
outline: none;
|
||||
border-color: #23a6d5;
|
||||
box-shadow: 0 0 0 3px rgba(35, 166, 213, 0.1);
|
||||
}
|
||||
|
||||
.header-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-links {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.admin-card {
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
padding: 2rem;
|
||||
border-radius: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||
margin-bottom: 2.5rem;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.admin-card h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.btn-delete {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-add {
|
||||
background: #212529;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background: #0088cc;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.8rem 1.5rem;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
width: 100%;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.webhook-url {
|
||||
font-size: 0.85em;
|
||||
color: #555;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.history-table-container {
|
||||
overflow-x: auto;
|
||||
background: rgba(255, 255, 255, 0.4);
|
||||
padding: 1rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.history-table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.history-table-time {
|
||||
width: 15%;
|
||||
white-space: nowrap;
|
||||
font-size: 0.85em;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.history-table-user {
|
||||
width: 35%;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.history-table-ai {
|
||||
width: 50%;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.no-messages {
|
||||
text-align: center;
|
||||
color: #777;
|
||||
}
|
||||
@ -1,39 +1,44 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const chatForm = document.getElementById('chat-form');
|
||||
const chatInput = document.getElementById('chat-input');
|
||||
const chatMessages = document.getElementById('chat-messages');
|
||||
const forms = document.querySelectorAll('.needs-validation');
|
||||
forms.forEach((form) => {
|
||||
form.addEventListener('submit', (event) => {
|
||||
if (!form.checkValidity()) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
form.classList.add('was-validated');
|
||||
}, false);
|
||||
});
|
||||
|
||||
const appendMessage = (text, sender) => {
|
||||
const msgDiv = document.createElement('div');
|
||||
msgDiv.classList.add('message', sender);
|
||||
msgDiv.textContent = text;
|
||||
chatMessages.appendChild(msgDiv);
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
};
|
||||
const profileInput = document.getElementById('profile');
|
||||
const previewImg = document.getElementById('photoPreview');
|
||||
const placeholder = document.getElementById('photoPlaceholder');
|
||||
|
||||
chatForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const message = chatInput.value.trim();
|
||||
if (!message) return;
|
||||
|
||||
appendMessage(message, 'visitor');
|
||||
chatInput.value = '';
|
||||
|
||||
try {
|
||||
const response = await fetch('api/chat.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
// Artificial delay for realism
|
||||
setTimeout(() => {
|
||||
appendMessage(data.reply, 'bot');
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
appendMessage("Sorry, something went wrong. Please try again.", 'bot');
|
||||
}
|
||||
if (profileInput && previewImg && placeholder) {
|
||||
profileInput.addEventListener('change', () => {
|
||||
const file = profileInput.files && profileInput.files[0];
|
||||
if (!file) {
|
||||
previewImg.classList.add('d-none');
|
||||
placeholder.classList.remove('d-none');
|
||||
return;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
previewImg.src = e.target.result;
|
||||
previewImg.classList.remove('d-none');
|
||||
placeholder.classList.add('d-none');
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll('a[href^="#"]').forEach((link) => {
|
||||
link.addEventListener('click', (e) => {
|
||||
const target = document.querySelector(link.getAttribute('href'));
|
||||
if (target) {
|
||||
e.preventDefault();
|
||||
target.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
BIN
assets/uploads/profile_69b61efa4e9b82.18136095.jpg
Normal file
BIN
assets/uploads/profile_69b61efa4e9b82.18136095.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 490 KiB |
BIN
assets/uploads/profile_69b61efca2aad8.61938921.jpg
Normal file
BIN
assets/uploads/profile_69b61efca2aad8.61938921.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 490 KiB |
78
export_pdf.php
Normal file
78
export_pdf.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
require_once __DIR__ . '/includes/auth.php';
|
||||
require_once __DIR__ . '/includes/registration_db.php';
|
||||
|
||||
require_admin();
|
||||
ensure_registration_table();
|
||||
|
||||
$registrations = fetch_registrations();
|
||||
|
||||
function pdf_escape(string $text): string {
|
||||
$text = str_replace(['\\', '(', ')'], ['\\\\', '\\(', '\\)'], $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
function build_pdf(array $lines): string {
|
||||
$y = 760;
|
||||
$leading = 16;
|
||||
$content = "BT\n/F1 12 Tf\n50 $y Td\n";
|
||||
foreach ($lines as $line) {
|
||||
$content .= "(" . pdf_escape($line) . ") Tj\n";
|
||||
$y -= $leading;
|
||||
$content .= "0 -" . $leading . " Td\n";
|
||||
}
|
||||
$content .= "ET";
|
||||
|
||||
$objects = [];
|
||||
$objects[] = "<< /Type /Catalog /Pages 2 0 R >>";
|
||||
$objects[] = "<< /Type /Pages /Kids [3 0 R] /Count 1 >>";
|
||||
$objects[] = "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>";
|
||||
$objects[] = "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>";
|
||||
$objects[] = "<< /Length " . strlen($content) . " >>\nstream\n" . $content . "\nendstream";
|
||||
|
||||
$pdf = "%PDF-1.4\n";
|
||||
$offsets = [0];
|
||||
foreach ($objects as $i => $obj) {
|
||||
$offsets[] = strlen($pdf);
|
||||
$pdf .= ($i + 1) . " 0 obj\n" . $obj . "\nendobj\n";
|
||||
}
|
||||
$xref = strlen($pdf);
|
||||
$pdf .= "xref\n0 " . (count($objects) + 1) . "\n";
|
||||
$pdf .= "0000000000 65535 f \n";
|
||||
for ($i = 1; $i <= count($objects); $i++) {
|
||||
$pdf .= sprintf("%010d 00000 n \n", $offsets[$i]);
|
||||
}
|
||||
$pdf .= "trailer\n<< /Size " . (count($objects) + 1) . " /Root 1 0 R >>\n";
|
||||
$pdf .= "startxref\n$xref\n%%EOF";
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
$lines = [
|
||||
'Laporan Pendaftar',
|
||||
'Tanggal: ' . date('Y-m-d H:i:s') . ' UTC',
|
||||
'Total: ' . count($registrations),
|
||||
'------------------------------------------------------------',
|
||||
];
|
||||
|
||||
foreach ($registrations as $row) {
|
||||
$lines[] = sprintf(
|
||||
'%s | %s | %s | %s',
|
||||
$row['reg_code'],
|
||||
$row['name'],
|
||||
$row['education'],
|
||||
$row['major']
|
||||
);
|
||||
}
|
||||
|
||||
$pdf = build_pdf($lines);
|
||||
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Disposition: attachment; filename="report_pendaftar.pdf"');
|
||||
header('Content-Length: ' . strlen($pdf));
|
||||
echo $pdf;
|
||||
exit;
|
||||
38
includes/auth.php
Normal file
38
includes/auth.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Credentials
|
||||
const ADMIN_USERNAME = 'roni';
|
||||
const ADMIN_PASSWORD_HASH = '$2y$10$w850c9hF2m2Z5hO0v.4tPuwv1W0i/1f2.sV4.gLw6v5I.vI4vF7xO'; // Hash of 'wijaya91'
|
||||
|
||||
function is_admin_logged_in(): bool {
|
||||
return !empty($_SESSION['admin_logged_in']);
|
||||
}
|
||||
|
||||
function require_admin(): void {
|
||||
if (!is_admin_logged_in()) {
|
||||
header('Location: admin_login.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function login_admin(string $username, string $password): bool {
|
||||
if ($username === ADMIN_USERNAME && password_verify($password, ADMIN_PASSWORD_HASH)) {
|
||||
session_regenerate_id(true);
|
||||
$_SESSION['admin_logged_in'] = true;
|
||||
$_SESSION['admin_user'] = $username;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function logout_admin(): void {
|
||||
$_SESSION = [];
|
||||
if (session_status() === PHP_SESSION_ACTIVE) {
|
||||
session_destroy();
|
||||
}
|
||||
}
|
||||
19
includes/flash.php
Normal file
19
includes/flash.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
function flash_set(string $type, string $message): void {
|
||||
$_SESSION['flash'] = ['type' => $type, 'message' => $message];
|
||||
}
|
||||
|
||||
function flash_get(): ?array {
|
||||
if (!empty($_SESSION['flash'])) {
|
||||
$flash = $_SESSION['flash'];
|
||||
unset($_SESSION['flash']);
|
||||
return $flash;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
50
includes/registration_db.php
Normal file
50
includes/registration_db.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
function ensure_registration_table(): void {
|
||||
$sql = <<<SQL
|
||||
CREATE TABLE IF NOT EXISTS registrations (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
reg_code VARCHAR(32) NOT NULL UNIQUE,
|
||||
name VARCHAR(190) NOT NULL,
|
||||
education VARCHAR(20) NOT NULL,
|
||||
major VARCHAR(190) NOT NULL,
|
||||
photo_path VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
|
||||
SQL;
|
||||
db()->exec($sql);
|
||||
}
|
||||
|
||||
function generate_reg_code(): string {
|
||||
return 'REG-' . date('Ymd') . '-' . strtoupper(bin2hex(random_bytes(3)));
|
||||
}
|
||||
|
||||
function insert_registration(array $data): int {
|
||||
$stmt = db()->prepare(
|
||||
"INSERT INTO registrations (reg_code, name, education, major, photo_path)
|
||||
VALUES (:reg_code, :name, :education, :major, :photo_path)"
|
||||
);
|
||||
$stmt->bindValue(':reg_code', $data['reg_code']);
|
||||
$stmt->bindValue(':name', $data['name']);
|
||||
$stmt->bindValue(':education', $data['education']);
|
||||
$stmt->bindValue(':major', $data['major']);
|
||||
$stmt->bindValue(':photo_path', $data['photo_path']);
|
||||
$stmt->execute();
|
||||
return (int)db()->lastInsertId();
|
||||
}
|
||||
|
||||
function fetch_registrations(): array {
|
||||
$stmt = db()->query("SELECT * FROM registrations ORDER BY created_at DESC");
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
function fetch_registration(int $id): ?array {
|
||||
$stmt = db()->prepare("SELECT * FROM registrations WHERE id = :id");
|
||||
$stmt->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$row = $stmt->fetch();
|
||||
return $row ?: null;
|
||||
}
|
||||
295
index.php
295
index.php
@ -4,147 +4,184 @@ declare(strict_types=1);
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
require_once __DIR__ . '/includes/registration_db.php';
|
||||
require_once __DIR__ . '/includes/flash.php';
|
||||
ensure_registration_table();
|
||||
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$flash = flash_get();
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<title>Aplikasi Pendaftaran — Form Online</title>
|
||||
<?php if ($projectDescription): ?>
|
||||
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<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;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<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=<?= time() ?>">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" defer></script>
|
||||
<script src="assets/js/main.js?v=<?= time() ?>" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
<body class="app-body">
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom sticky-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand fw-semibold" href="/">Pendaftaran</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navMain" aria-controls="navMain" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navMain">
|
||||
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item"><a class="nav-link" href="#daftar">Form Pendaftaran</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#alur">Alur</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="admin_login.php">Admin</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<header class="py-5 border-bottom">
|
||||
<div class="container">
|
||||
<div class="row align-items-center g-4">
|
||||
<div class="col-lg-7">
|
||||
<span class="badge text-bg-light border mb-3">Responsive · Mobile & Desktop</span>
|
||||
<h1 class="display-6 fw-semibold">Aplikasi Pendaftaran Online yang rapi, cepat, dan mudah diakses.</h1>
|
||||
<p class="text-muted mt-3 mb-4">
|
||||
Pendaftar mengisi data tanpa login, sistem memberi nomor pendaftaran otomatis,
|
||||
dan admin dapat melihat laporan beserta foto serta export PDF.
|
||||
</p>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<a class="btn btn-dark px-4" href="#daftar">Mulai Daftar</a>
|
||||
<a class="btn btn-outline-secondary px-4" href="admin_login.php">Login Admin</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-5">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<h2 class="h6 text-uppercase text-muted">Ringkasan Fitur</h2>
|
||||
<ul class="list-unstyled mt-3 mb-0 small">
|
||||
<li class="mb-2">✔ Form pendaftaran tanpa login</li>
|
||||
<li class="mb-2">✔ Upload foto dari kamera atau galeri</li>
|
||||
<li class="mb-2">✔ Admin report + export PDF</li>
|
||||
<li class="mb-0">✔ Tampilan responsif</li>
|
||||
</ul>
|
||||
<p class="small text-muted mt-3 mb-0">Update terakhir: <?= htmlspecialchars($now) ?> UTC</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="py-5">
|
||||
<section id="daftar" class="container">
|
||||
<div class="row g-4">
|
||||
<div class="col-lg-6">
|
||||
<h2 class="h4 fw-semibold">Form Pendaftaran</h2>
|
||||
<p class="text-muted">Lengkapi data di bawah ini. Semua field wajib diisi.</p>
|
||||
<div class="alert alert-light border small mb-4">
|
||||
Setelah submit, Anda akan menerima <strong>nomor pendaftaran</strong> sebagai bukti.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<?php if ($flash): ?>
|
||||
<div class="alert alert-<?= htmlspecialchars($flash['type']) ?> border-0 small">
|
||||
<?= htmlspecialchars($flash['message']) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="register.php" method="post" enctype="multipart/form-data" class="needs-validation" novalidate>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="name">Nama Lengkap</label>
|
||||
<input type="text" class="form-control" id="name" name="name" required>
|
||||
<div class="invalid-feedback">Nama wajib diisi.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="education">Pendidikan</label>
|
||||
<select class="form-select" id="education" name="education" required>
|
||||
<option value="">Pilih Pendidikan</option>
|
||||
<option>SD</option>
|
||||
<option>SMP</option>
|
||||
<option>SLTA</option>
|
||||
<option>D3</option>
|
||||
<option>S1</option>
|
||||
</select>
|
||||
<div class="invalid-feedback">Pilih pendidikan terakhir.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="major">Jurusan Pendidikan</label>
|
||||
<input type="text" class="form-control" id="major" name="major" required>
|
||||
<div class="invalid-feedback">Jurusan wajib diisi.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="profile">Profile (Foto)</label>
|
||||
<input type="file" class="form-control" id="profile" name="profile" accept="image/*" capture="environment" required>
|
||||
<div class="form-text">Gunakan kamera perangkat atau pilih dari galeri.</div>
|
||||
<div class="invalid-feedback">Foto profil wajib diunggah.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="photo-preview border rounded-3 p-2 text-center text-muted small">
|
||||
<img id="photoPreview" alt="Preview foto pendaftar" class="img-fluid d-none rounded-2">
|
||||
<span id="photoPlaceholder">Preview foto akan tampil di sini.</span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-dark w-100">Kirim Pendaftaran</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="alur" class="container mt-5 pt-3">
|
||||
<div class="row g-4">
|
||||
<div class="col-lg-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body">
|
||||
<h3 class="h6 fw-semibold">1. Isi Form</h3>
|
||||
<p class="text-muted small mb-0">Pendaftar mengisi data dan unggah foto.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body">
|
||||
<h3 class="h6 fw-semibold">2. Nomor Pendaftaran</h3>
|
||||
<p class="text-muted small mb-0">Sistem memberi kode registrasi otomatis.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body">
|
||||
<h3 class="h6 fw-semibold">3. Admin Report</h3>
|
||||
<p class="text-muted small mb-0">Admin melihat data + export PDF.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
|
||||
<footer class="border-top py-4">
|
||||
<div class="container small text-muted d-flex flex-wrap gap-3 justify-content-between">
|
||||
<span>© <?= date('Y') ?> Aplikasi Pendaftaran</span>
|
||||
<span>Butuh bantuan? hubungi admin internal.</span>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
9
logout.php
Normal file
9
logout.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
require_once __DIR__ . '/includes/auth.php';
|
||||
require_once __DIR__ . '/includes/flash.php';
|
||||
|
||||
logout_admin();
|
||||
flash_set('success', 'Anda telah logout.');
|
||||
header('Location: admin_login.php');
|
||||
exit;
|
||||
127
register.php
Normal file
127
register.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
require_once __DIR__ . '/includes/registration_db.php';
|
||||
require_once __DIR__ . '/includes/flash.php';
|
||||
ensure_registration_table();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$education = trim($_POST['education'] ?? '');
|
||||
$major = trim($_POST['major'] ?? '');
|
||||
|
||||
$errors = [];
|
||||
if ($name === '') { $errors[] = 'Nama wajib diisi.'; }
|
||||
if ($education === '') { $errors[] = 'Pendidikan wajib dipilih.'; }
|
||||
if ($major === '') { $errors[] = 'Jurusan wajib diisi.'; }
|
||||
|
||||
$photoPath = '';
|
||||
if (!isset($_FILES['profile']) || $_FILES['profile']['error'] !== UPLOAD_ERR_OK) {
|
||||
$errors[] = 'Foto profil wajib diunggah.';
|
||||
} else {
|
||||
$file = $_FILES['profile'];
|
||||
if ($file['size'] > 3 * 1024 * 1024) {
|
||||
$errors[] = 'Ukuran foto maksimal 3MB.';
|
||||
} else {
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$mime = $finfo->file($file['tmp_name']);
|
||||
$allowed = ['image/jpeg' => 'jpg', 'image/png' => 'png', 'image/webp' => 'webp'];
|
||||
if (!isset($allowed[$mime])) {
|
||||
$errors[] = 'Format foto harus JPG, PNG, atau WEBP.';
|
||||
} else {
|
||||
$uploadDir = __DIR__ . '/assets/uploads';
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0775, true);
|
||||
}
|
||||
$filename = uniqid('profile_', true) . '.' . $allowed[$mime];
|
||||
$destination = $uploadDir . '/' . $filename;
|
||||
if (!move_uploaded_file($file['tmp_name'], $destination)) {
|
||||
$errors[] = 'Gagal menyimpan foto.';
|
||||
} else {
|
||||
$photoPath = 'assets/uploads/' . $filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
flash_set('danger', implode(' ', $errors));
|
||||
header('Location: /#daftar');
|
||||
exit;
|
||||
}
|
||||
|
||||
$regCode = generate_reg_code();
|
||||
insert_registration([
|
||||
'reg_code' => $regCode,
|
||||
'name' => $name,
|
||||
'education' => $education,
|
||||
'major' => $major,
|
||||
'photo_path' => $photoPath,
|
||||
]);
|
||||
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Pendaftaran Berhasil</title>
|
||||
<?php if ($projectDescription): ?>
|
||||
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<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=<?= time() ?>">
|
||||
</head>
|
||||
<body class="app-body">
|
||||
<div class="container py-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-7">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<div class="alert alert-success border-0 mb-4">
|
||||
Pendaftaran berhasil! Simpan nomor pendaftaran Anda.
|
||||
</div>
|
||||
<h1 class="h4 fw-semibold mb-3">Nomor Pendaftaran</h1>
|
||||
<div class="p-3 border rounded-3 bg-light mb-4">
|
||||
<span class="fw-semibold"><?= htmlspecialchars($regCode) ?></span>
|
||||
</div>
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-md-5">
|
||||
<img src="<?= htmlspecialchars($photoPath) ?>" class="img-fluid rounded-3 border" alt="Foto pendaftar">
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<p class="mb-1"><strong>Nama:</strong> <?= htmlspecialchars($name) ?></p>
|
||||
<p class="mb-1"><strong>Pendidikan:</strong> <?= htmlspecialchars($education) ?></p>
|
||||
<p class="mb-1"><strong>Jurusan:</strong> <?= htmlspecialchars($major) ?></p>
|
||||
<p class="mb-0 text-muted small">Waktu daftar: <?= htmlspecialchars($now) ?> UTC</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<a class="btn btn-dark" href="/">Kembali ke Form</a>
|
||||
<a class="btn btn-outline-secondary" href="admin_login.php">Login Admin</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-muted small mt-3">Jika Anda membutuhkan perubahan data, silakan hubungi admin internal.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user