| 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 : /bpkd_/ |
Upload File : |
<?php
/**
* Halaman Galeri - Menampilkan Album & Foto
* Website Instansi - CMS
*/
require_once 'includes/init.php';
// Set page variables
$page_title = 'Galeri Foto & Video - ' . ($settings['site_title'] ?? 'Website Instansi');
$meta_description = 'Galeri foto dan video kegiatan, acara, dan momen penting instansi.';
$meta_keywords = 'galeri, foto, video, dokumentasi, kegiatan, acara';
global $conn;
// =====================================================
// CEK PARAMETER ALBUM
// =====================================================
$album_slug = isset($_GET['album']) ? sanitize($_GET['album']) : '';
if (!empty($album_slug)) {
// === TAMPILKAN FOTO DALAM SATU ALBUM ===
$album = $conn->query("SELECT * FROM albums WHERE slug = '$album_slug' AND status = 'active'")->fetch_assoc();
if (!$album) {
header('Location: ' . BASE_URL . '/galeri');
exit;
}
$page_title = $album['name'] . ' - Galeri ' . ($settings['site_title'] ?? 'Website Instansi');
$meta_description = $album['description'] ?? 'Galeri foto ' . $album['name'];
// Ambil semua foto dalam album
$photos = $conn->query("
SELECT * FROM gallery
WHERE album_id = " . $album['id'] . " AND status = 'active'
ORDER BY featured DESC, created_at DESC
");
$is_album_view = true;
} else {
// === TAMPILKAN DAFTAR SEMUA ALBUM ===
$albums = $conn->query("
SELECT a.*, COUNT(g.id) as total_photos
FROM albums a
LEFT JOIN gallery g ON a.id = g.album_id AND g.status = 'active'
WHERE a.status = 'active'
GROUP BY a.id
ORDER BY a.created_at DESC
");
$is_album_view = false;
}
include 'includes/header.php';
?>
<div class="container py-5">
<!-- Header -->
<div class="art-header-with-lines row mx-auto">
<h2 class="art-title-left">
<?php echo $is_album_view ? 'Album: ' . htmlspecialchars($album['name']) : 'Galeri'; ?>
</h2>
<div class="art-line-left-only"></div>
</div>
<?php if ($is_album_view): ?>
<!-- =====================================================
TAMPILAN FOTO DALAM ALBUM
===================================================== -->
<?php if (!empty($album['description'])): ?>
<div class="album-description mb-4">
<p class="text-muted"><?php echo htmlspecialchars($album['description']); ?></p>
</div>
<?php endif; ?>
<div class="mb-3">
<a href="<?php echo BASE_URL; ?>/galeri" class="btn btn-outline-primary btn-sm">
<i class="fas fa-arrow-left me-1"></i> Kembali ke Semua Album
</a>
</div>
<?php if ($photos && $photos->num_rows > 0): ?>
<div class="row g-4" id="gallery-grid">
<?php while($item = $photos->fetch_assoc()):
// =============================================
// VALIDASI FILE SEBELUM TAMPIL
// =============================================
$photo_url = getPhotoUrl($item['image']);
?>
<div class="col-lg-3 col-md-4 col-sm-6" data-aos="fade-up">
<div class="gallery-card">
<div class="gallery-image">
<img src="<?php echo $photo_url; ?>"
alt="<?php echo htmlspecialchars($item['title']); ?>"
class="img-fluid"
loading="lazy"
onerror="this.onerror=null; this.src='<?php echo BASE_URL; ?>/uploads/gallery/default.jpg'">
<div class="gallery-overlay">
<div class="gallery-info">
<h6 class="text-white"><?php echo htmlspecialchars(substr($item['title'], 0, 30)); ?></h6>
<small class="text-white-50"><i class="far fa-calendar me-1"></i> <?php echo tgl_indonesia($item['created_at']); ?></small>
<div class="gallery-actions mt-2">
<button class="btn btn-light btn-sm view-image"
data-image="<?php echo $photo_url; ?>"
data-title="<?php echo htmlspecialchars($item['title']); ?>"
data-desc="<?php echo htmlspecialchars($item['description'] ?? ''); ?>"
data-date="<?php echo tgl_indonesia($item['created_at']); ?>">
<i class="fas fa-search-plus"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php else: ?>
<div class="text-center py-5">
<i class="fas fa-images fa-4x text-muted mb-3"></i>
<h4>Belum Ada Foto di Album Ini</h4>
<p class="text-muted">Album ini masih kosong.</p>
</div>
<?php endif; ?>
<?php else: ?>
<!-- =====================================================
TAMPILAN DAFTAR SEMUA ALBUM
===================================================== -->
<?php if ($albums && $albums->num_rows > 0): ?>
<div class="row g-4">
<?php while($album = $albums->fetch_assoc()):
// =============================================
// COVER ALBUM (1 FOTO SAJA)
// =============================================
$cover_url = getAlbumCover($conn, $album['id']);
?>
<div class="col-lg-3 col-md-4 col-sm-6" data-aos="fade-up">
<a href="<?php echo BASE_URL; ?>/galeri/album/<?php echo $album['slug']; ?>" class="text-decoration-none">
<div class="album-card">
<div class="album-image">
<img src="<?php echo $cover_url; ?>"
alt="<?php echo htmlspecialchars($album['name']); ?>"
class="img-fluid"
loading="lazy"
onerror="this.onerror=null; this.src='<?php echo BASE_URL; ?>/uploads/gallery/default.jpg'">
<div class="album-overlay">
<span class="badge bg-primary"><?php echo $album['total_photos']; ?> Foto</span>
</div>
</div>
<div class="album-info p-3">
<h5 class="mb-1 text-truncate"><?php echo htmlspecialchars($album['name']); ?></h5>
<small class="text-muted">
<i class="far fa-calendar me-1"></i> <?php echo tgl_indonesia($album['created_at']); ?>
</small>
</div>
</div>
</a>
</div>
<?php endwhile; ?>
</div>
<?php else: ?>
<div class="text-center py-5">
<i class="fas fa-folder-open fa-4x text-muted mb-3"></i>
<h4>Belum Ada Album</h4>
<p class="text-muted">Belum ada album galeri yang tersedia.</p>
</div>
<?php endif; ?>
<?php endif; ?>
<!-- Lightbox Modal -->
<div class="modal fade" id="imageModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content bg-transparent border-0">
<div class="modal-body p-0">
<button type="button" class="btn-close btn-close-white position-absolute top-0 end-0 m-3" data-bs-dismiss="modal" aria-label="Close"></button>
<img src="" id="modalImage" class="img-fluid rounded" alt="">
<div class="bg-dark text-white p-3 rounded-bottom mt-2" id="modalCaption">
<h5 id="modalTitle"></h5>
<p id="modalDesc"></p>
<small id="modalDate"></small>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Image modal
document.querySelectorAll('.view-image').forEach(btn => {
btn.addEventListener('click', function() {
const image = this.dataset.image;
const title = this.dataset.title;
const desc = this.dataset.desc;
const date = this.dataset.date;
document.getElementById('modalImage').src = image;
document.getElementById('modalTitle').textContent = title;
document.getElementById('modalDesc').textContent = desc;
document.getElementById('modalDate').textContent = '📅 ' + date;
new bootstrap.Modal(document.getElementById('imageModal')).show();
});
});
// Close modal with Escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
const modal = bootstrap.Modal.getInstance(document.getElementById('imageModal'));
if (modal) modal.hide();
}
});
</script>
<style>
/* =====================================================
STYLE GALERI
===================================================== */
/* Album Card */
.album-card {
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 5px 15px rgba(0,0,0,0.08);
transition: all 0.3s;
height: 100%;
}
.album-card:hover {
transform: translateY(-8px);
box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}
.album-image {
position: relative;
aspect-ratio: 4/3;
overflow: hidden;
background: #f1f5f9;
}
.album-image img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.5s;
}
.album-card:hover .album-image img {
transform: scale(1.05);
}
.album-overlay {
position: absolute;
bottom: 10px;
right: 10px;
}
.album-info h5 {
color: #1e293b;
font-weight: 600;
font-size: 1rem;
}
/* Gallery Card */
.gallery-card {
position: relative;
overflow: hidden;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
transition: all 0.3s;
cursor: pointer;
height: 100%;
}
.gallery-card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}
.gallery-image {
position: relative;
aspect-ratio: 4/3;
overflow: hidden;
background: #f1f5f9;
}
.gallery-image img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.5s;
}
.gallery-card:hover .gallery-image img {
transform: scale(1.1);
}
.gallery-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 60%, transparent 100%);
display: flex;
align-items: flex-end;
padding: 20px;
opacity: 0;
transition: opacity 0.3s;
}
.gallery-card:hover .gallery-overlay {
opacity: 1;
}
.gallery-info {
color: white;
transform: translateY(20px);
transition: transform 0.3s;
width: 100%;
}
.gallery-card:hover .gallery-info {
transform: translateY(0);
}
.gallery-info h6 {
margin-bottom: 4px;
color: white;
font-weight: 600;
}
.gallery-actions {
display: flex;
gap: 5px;
}
/* Album Description */
.album-description {
background: #f8fafc;
padding: 15px 20px;
border-radius: 10px;
border-left: 4px solid #2563eb;
}
/* Responsive */
@media (max-width: 576px) {
.gallery-overlay {
padding: 12px;
}
.gallery-info h6 {
font-size: 0.85rem;
}
.album-info h5 {
font-size: 0.9rem;
}
}
/* Badge counter */
.badge.bg-primary {
background: rgba(37, 99, 235, 0.9) !important;
font-size: 0.75rem;
padding: 4px 10px;
}
</style>
<?php include 'includes/footer.php'; ?>