| 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_29052026/ |
Upload File : |
<?php
/**
* Halaman Utama Frontend
* Website Instansi - CMS
*/
// Load inisialisasi
require_once 'includes/init.php';
// Set page variables
$page_title = $settings['site_title'] ?? 'Website Instansi';
$meta_description = $settings['site_description'] ?? 'Website resmi instansi yang melayani masyarakat dengan profesional, transparan, dan akuntabel.';
$meta_keywords = $settings['site_keywords'] ?? 'instansi, pemerintah, layanan publik, berita, informasi';
// Additional CSS untuk carousel
$additional_css = ['assets/css/carousel.css'];
// Gunakan global $conn
global $conn;
// ===== AMBIL DATA CAROUSEL DARI DATABASE =====
$carousel_slides = getCarouselSlides($conn, 5);
// ===== AMBIL DATA LAYANAN DARI DATABASE (jika ada tabel services) =====
// ===== CEK TABEL SERVICES DAN AMBIL DATA =====
$services = [];
// Cek apakah tabel services ada
$table_check = $conn->query("SHOW TABLES LIKE 'services'");
if ($table_check && $table_check->num_rows > 0) {
// Tabel services ada, ambil data dari database
$services_query = "SELECT * FROM services WHERE status = 'active' ORDER BY featured DESC, service_order ASC LIMIT 6";
$services_result = $conn->query($services_query);
if ($services_result && $services_result->num_rows > 0) {
while($row = $services_result->fetch_assoc()) {
$services[] = $row;
}
}
}
// ===== AMBIL ARTIKEL TERBARU =====
$latest_articles = $conn->query("
SELECT a.*, c.name as category_name, u.full_name as author_name
FROM articles a
LEFT JOIN categories c ON a.category_id = c.id
LEFT JOIN users u ON a.author_id = u.id
WHERE a.status = 'published'
ORDER BY a.published_at DESC
LIMIT 6
");
// ===== AMBIL ARTIKEL POPULER (berdasarkan views) =====
$featured_articles = $conn->query("
SELECT a.*, c.name as category_name
FROM articles a
LEFT JOIN categories c ON a.category_id = c.id
WHERE a.status = 'published'
ORDER BY a.views DESC
LIMIT 3
");
// ===== AMBIL KATEGORI DENGAN JUMLAH ARTIKEL =====
$categories = $conn->query("
SELECT c.*, COUNT(a.id) as article_count
FROM categories c
LEFT JOIN articles a ON c.id = a.category_id AND a.status = 'published'
GROUP BY c.id
ORDER BY c.name
");
// ===== AMBIL TESTIMONIAL =====
$testimonials = $conn->query("
SELECT * FROM testimonials
WHERE status = 'published'
ORDER BY id DESC
LIMIT 5
");
// ===== AMBIL FAQ =====
$faqs = $conn->query("
SELECT * FROM faq
WHERE status = 'published'
ORDER BY faq_order
LIMIT 5
");
// ===== AMBIL STATISTIK =====
$total_articles = $conn->query("SELECT COUNT(*) as total FROM articles WHERE status = 'published'")->fetch_assoc()['total'];
$total_visitors = $conn->query("SELECT COUNT(DISTINCT ip_address) as total FROM visitors")->fetch_assoc()['total'];
$total_services = 3; // Bisa diambil dari database jika ada tabel services
// ===== TRACK VISITOR =====
$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$page = $_SERVER['REQUEST_URI'];
$today = date('Y-m-d');
$time = date('H:i:s');
// Cek apakah visitor sudah tercatat hari ini
$check = $conn->query("SELECT id FROM visitors WHERE ip_address = '$ip' AND visit_date = '$today'");
if ($check->num_rows == 0) {
$conn->query("INSERT INTO visitors (ip_address, user_agent, page_visited, visit_date, visit_time)
VALUES ('$ip', '$user_agent', '$page', '$today', '$time')");
}
// Include header
include 'includes/header.php';
?>
<!-- Hero Section dengan Carousel -->
<section class="hero-carousel-section">
<div id="heroCarousel" class="carousel slide carousel-fade" data-bs-ride="carousel">
<!-- Carousel Indicators -->
<div class="carousel-indicators">
<?php if (!empty($carousel_slides)): ?>
<?php foreach ($carousel_slides as $index => $slide): ?>
<button type="button" data-bs-target="#heroCarousel" data-bs-slide-to="<?php echo $index; ?>"
class="<?php echo $index == 0 ? 'active' : ''; ?>"
aria-current="<?php echo $index == 0 ? 'true' : 'false'; ?>"
aria-label="Slide <?php echo $index + 1; ?>"></button>
<?php endforeach; ?>
<?php else: ?>
<!-- Default indicators if no slides -->
<button type="button" data-bs-target="#heroCarousel" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#heroCarousel" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#heroCarousel" data-bs-slide-to="2" aria-label="Slide 3"></button>
<?php endif; ?>
</div>
<!-- Carousel Inner -->
<div class="carousel-inner">
<?php if (!empty($carousel_slides)): ?>
<?php foreach ($carousel_slides as $index => $slide):
// Gunakan gambar default jika tidak ada
$image_url = !empty($slide['image']) ? $slide['image'] : getDefaultImage('carousel', $slide['title'], 1920, 800);
?>
<div class="carousel-item <?php echo $index == 0 ? 'active' : ''; ?>">
<div class="carousel-image" style="background-image: url('<?php echo $image_url; ?>');">
<div class="carousel-overlay"></div>
</div>
<div class="carousel-caption">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<?php if (!empty($slide['subtitle'])): ?>
<span class="carousel-subtitle" data-aos="fade-up" data-aos-duration="1000">
<?php echo $slide['subtitle']; ?>
</span>
<?php endif; ?>
<h2 class="carousel-title" data-aos="fade-up" data-aos-duration="1000" data-aos-delay="200">
<?php echo $slide['title']; ?>
</h2>
<?php if (!empty($slide['description'])): ?>
<p class="carousel-description" data-aos="fade-up" data-aos-duration="1000" data-aos-delay="400">
<?php echo $slide['description']; ?>
</p>
<?php endif; ?>
<div class="carousel-buttons" data-aos="fade-up" data-aos-duration="1000" data-aos-delay="600">
<?php if (!empty($slide['button_text']) && !empty($slide['button_link'])): ?>
<a href="<?php echo $slide['button_link']; ?>" class="btn btn-primary btn-lg me-2">
<i class="fas fa-info-circle me-2"></i><?php echo $slide['button_text']; ?>
</a>
<?php endif; ?>
<?php if (!empty($slide['button_text_2']) && !empty($slide['button_link_2'])): ?>
<a href="<?php echo $slide['button_link_2']; ?>" class="btn btn-outline-light btn-lg">
<i class="fas fa-arrow-right me-2"></i><?php echo $slide['button_text_2']; ?>
</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<!-- Default Carousel Slides (Fallback) -->
<div class="carousel-item active">
<div class="carousel-image" style="background-image: url('<?php echo getDefaultImage('carousel', 'Selamat Datang', 1920, 800); ?>');">
<div class="carousel-overlay"></div>
</div>
<div class="carousel-caption">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<span class="carousel-subtitle">Selamat Datang di</span>
<h2 class="carousel-title"><?php echo $settings['site_title'] ?? 'Website Resmi Instansi'; ?></h2>
<p class="carousel-description"><?php echo $settings['site_description'] ?? 'Melayani masyarakat dengan profesional, transparan, dan akuntabel.'; ?></p>
<div class="carousel-buttons">
<a href="profil.php" class="btn btn-primary btn-lg me-2">
<i class="fas fa-info-circle me-2"></i>Tentang Kami
</a>
<a href="kontak.php" class="btn btn-outline-light btn-lg">
<i class="fas fa-phone-alt me-2"></i>Hubungi Kami
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
<!-- Carousel Controls -->
<button class="carousel-control-prev" type="button" data-bs-target="#heroCarousel" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#heroCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</section>
<!-- Hero Stats Section (di bawah carousel) -->
<section class="hero-stats-section py-5">
<div class="container">
<div class="row text-center">
<div class="col-md-4 mb-3">
<div class="stats-card p-4">
<i class="fas fa-newspaper fa-3x text-primary mb-3"></i>
<h3 class="stats-number"><?php echo number_format($total_articles); ?></h3>
<p class="stats-label">Artikel Terbit</p>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="stats-card p-4">
<i class="fas fa-hand-holding-heart fa-3x text-primary mb-3"></i>
<h3 class="stats-number"><?php echo $total_services; ?></h3>
<p class="stats-label">Layanan Publik</p>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="stats-card p-4">
<i class="fas fa-users fa-3x text-primary mb-3"></i>
<h3 class="stats-number"><?php echo number_format($total_visitors); ?></h3>
<p class="stats-label">Pengunjung</p>
</div>
</div>
</div>
</div>
</section>
<!-- Layanan Section -->
<section class="services-section py-5 bg-light">
<div class="container">
<div class="section-header text-center mb-5" data-aos="fade-up">
<h2 class="section-title">Layanan Kami</h2>
<p class="section-subtitle">Berbagai layanan yang tersedia untuk masyarakat</p>
</div>
<div class="row">
<?php foreach ($services as $index => $service): ?>
<div class="col-lg-4 col-md-6 mb-4" data-aos="fade-up" data-aos-delay="<?php echo ($index + 1) * 100; ?>">
<div class="service-card h-100 p-4">
<div class="service-icon mb-4">
<i class="<?php echo $service['icon']; ?> fa-3x text-primary"></i>
</div>
<h3 class="h4 mb-3"><?php echo $service['title']; ?></h3>
<p class="text-muted mb-4"><?php echo $service['description']; ?></p>
<a href="<?php echo $service['link']; ?>" class="btn-link">
Selengkapnya <i class="fas fa-arrow-right ms-2"></i>
</a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
<!-- Berita Terbaru Section -->
<section class="news-section py-5">
<div class="container">
<div class="section-header text-center mb-5" data-aos="fade-up">
<h2 class="section-title">Berita & Artikel Terbaru</h2>
<p class="section-subtitle">Informasi terkini seputar kegiatan dan layanan instansi</p>
</div>
<div class="row">
<?php while($article = $latest_articles->fetch_assoc()):
// Gunakan fungsi article_url untuk membuat link
$article_link = article_url($article);
?>
<div class="col-lg-4 col-md-6 mb-4">
<div class="news-card">
<div class="news-image">
<?php if(!empty($article['featured_image'])): ?>
<img src="<?php echo $article['featured_image']; ?>" alt="<?php echo $article['title']; ?>">
<?php else: ?>
<img src="assets/images/news-default.jpg" alt="Default News Image">
<?php endif; ?>
<div class="news-category"><?php echo $article['category_name']; ?></div>
</div>
<div class="news-content">
<div class="news-meta">
<span><i class="far fa-calendar"></i> <?php echo tgl_indonesia($article['published_at']); ?></span>
<span><i class="far fa-user"></i> <?php echo $article['author_name']; ?></span>
</div>
<h3 class="news-title">
<a href="<?php echo $article_link; ?>"><?php echo $article['title']; ?></a>
</h3>
<p class="news-excerpt"><?php echo substr($article['excerpt'] ?? strip_tags($article['content']), 0, 100) . '...'; ?></p>
<a href="<?php echo $article_link; ?>" class="btn-link">
Baca Selengkapnya <i class="fas fa-arrow-right ms-2"></i>
</a>
</div>
</div>
</div>
<?php endwhile; ?>
<!-- Link Lihat Semua Berita -->
<a href="/cms_instansi/berita" class="btn btn-primary btn-lg">
<i class="fas fa-newspaper me-2"></i>Lihat Semua Berita
</a>
</div>
</section>
<!-- Artikel Populer Section -->
<?php if ($featured_articles && $featured_articles->num_rows > 0): ?>
<section class="featured-section py-5 bg-light">
<div class="container">
<div class="section-header text-center mb-5" data-aos="fade-up">
<h2 class="section-title">Artikel Populer</h2>
<p class="section-subtitle">Artikel dengan kunjungan terbanyak dari masyarakat</p>
</div>
<div class="row">
<?php while($featured = $featured_articles->fetch_assoc()):
$featured_url = 'artikel/' . ($featured['slug'] ?: createSlug($featured['title']));
$image_url = !empty($featured['featured_image']) ? $featured['featured_image'] : getDefaultImage('article', $featured['title'], 400, 250);
?>
<div class="col-md-4 mb-4" data-aos="fade-up">
<div class="card h-100 shadow-sm">
<img src="<?php echo $image_url; ?>" class="card-img-top" alt="<?php echo htmlspecialchars($featured['title']); ?>" style="height: 200px; object-fit: cover;">
<div class="card-body">
<h5 class="card-title"><?php echo $featured['title']; ?></h5>
<p class="card-text text-muted"><?php echo substr($featured['excerpt'] ?? strip_tags($featured['content']), 0, 100); ?>...</p>
<div class="d-flex justify-content-between align-items-center mt-3">
<small class="text-muted">
<i class="fas fa-eye me-1"></i> <?php echo number_format($featured['views']); ?> views
</small>
<a href="<?php echo $featured_url; ?>" class="btn btn-sm btn-outline-primary">Baca</a>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</section>
<?php endif; ?>
<!-- Kategori Section -->
<section class="categories-section py-5">
<div class="container">
<div class="section-header text-center mb-5" data-aos="fade-up">
<h2 class="section-title">Kategori Berita</h2>
<p class="section-subtitle">Temukan berita berdasarkan kategori yang Anda minati</p>
</div>
<div class="row">
<?php if ($categories && $categories->num_rows > 0): ?>
<?php while($category = $categories->fetch_assoc()):
$category_url = 'kategori/' . ($category['slug'] ?: createSlug($category['name']));
?>
<div class="col-lg-3 col-md-6 mb-4" data-aos="fade-up" data-aos-delay="<?php echo $category['id'] * 50; ?>">
<a href="<?php echo $category_url; ?>" class="category-card text-decoration-none">
<div class="category-icon">
<i class="fas fa-folder"></i>
</div>
<h3 class="h5 mt-3"><?php echo $category['name']; ?></h3>
<p class="category-count text-muted"><?php echo $category['article_count']; ?> Artikel</p>
</a>
</div>
<?php endwhile; ?>
<?php else: ?>
<div class="col-12 text-center py-5">
<i class="fas fa-folder-open fa-4x text-muted mb-3"></i>
<p class="text-muted">Belum ada kategori.</p>
</div>
<?php endif; ?>
</div>
</div>
</section>
<!-- Testimonial Section -->
<?php if ($testimonials && $testimonials->num_rows > 0): ?>
<section class="testimonial-section py-5 bg-light">
<div class="container">
<div class="section-header text-center mb-5" data-aos="fade-up">
<h2 class="section-title">Apa Kata Mereka</h2>
<p class="section-subtitle">Testimonial dari masyarakat tentang layanan kami</p>
</div>
<div class="row">
<?php while($testi = $testimonials->fetch_assoc()): ?>
<div class="col-md-6 mb-4" data-aos="fade-up">
<div class="testimonial-card h-100 p-4">
<div class="testimonial-rating mb-3">
<?php for($i = 1; $i <= 5; $i++): ?>
<i class="fas fa-star <?php echo $i <= $testi['rating'] ? 'text-warning' : 'text-muted'; ?>"></i>
<?php endfor; ?>
</div>
<p class="testimonial-content mb-4">"<?php echo htmlspecialchars($testi['content']); ?>"</p>
<div class="testimonial-author d-flex align-items-center">
<?php
$avatar_url = !empty($testi['photo']) ? $testi['photo'] : getDefaultImage('profile', $testi['name'], 60, 60);
?>
<img src="<?php echo $avatar_url; ?>" alt="<?php echo htmlspecialchars($testi['name']); ?>" class="rounded-circle me-3" style="width: 60px; height: 60px; object-fit: cover;">
<div>
<h4 class="h6 mb-1"><?php echo htmlspecialchars($testi['name']); ?></h4>
<p class="small text-muted mb-0"><?php echo htmlspecialchars($testi['position']); ?><?php echo $testi['company'] ? ' di ' . htmlspecialchars($testi['company']) : ''; ?></p>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</section>
<?php endif; ?>
<!-- FAQ Section -->
<?php if ($faqs && $faqs->num_rows > 0): ?>
<section class="faq-section py-5">
<div class="container">
<div class="section-header text-center mb-5" data-aos="fade-up">
<h2 class="section-title">Pertanyaan Umum</h2>
<p class="section-subtitle">Informasi yang sering ditanyakan masyarakat</p>
</div>
<div class="row justify-content-center">
<div class="col-lg-8" data-aos="fade-up">
<div class="accordion" id="faqAccordion">
<?php $no = 1; while($faq = $faqs->fetch_assoc()): ?>
<div class="accordion-item mb-3 border-0">
<h2 class="accordion-header">
<button class="accordion-button <?php echo $no > 1 ? 'collapsed' : ''; ?>"
type="button" data-bs-toggle="collapse"
data-bs-target="#faq<?php echo $faq['id']; ?>"
aria-expanded="<?php echo $no == 1 ? 'true' : 'false'; ?>">
<?php echo $no++ . '. ' . htmlspecialchars($faq['question']); ?>
</button>
</h2>
<div id="faq<?php echo $faq['id']; ?>"
class="accordion-collapse collapse <?php echo $no == 2 ? 'show' : ''; ?>"
data-bs-parent="#faqAccordion">
<div class="accordion-body">
<?php echo nl2br(htmlspecialchars($faq['answer'])); ?>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="text-center mt-4">
<a href="faq.php" class="btn btn-outline-primary">
Lihat Semua FAQ <i class="fas fa-arrow-right ms-2"></i>
</a>
</div>
</div>
</div>
</div>
</section>
<?php endif; ?>
<!-- CTA Section -->
<section class="cta-section py-5 bg-primary">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-8 text-center text-white" data-aos="zoom-in">
<h2 class="text-white h1 mb-3">Butuh bantuan atau informasi lebih lanjut?</h2>
<p class="text-white-50 mb-4">Hubungi kami melalui form kontak atau datang langsung ke kantor kami. Kami siap melayani Anda.</p>
<a href="kontak.php" class="btn btn-light btn-lg px-5">
<i class="fas fa-envelope me-2"></i>Hubungi Kami
</a>
</div>
</div>
</div>
</section>
<!-- Partners Section -->
<section class="partners-section py-5">
<div class="container">
<div class="section-header text-center mb-5" data-aos="fade-up">
<h2 class="section-title">Mitra Kerja Sama</h2>
<p class="section-subtitle">Instansi dan lembaga yang bekerja sama dengan kami</p>
</div>
<div class="row justify-content-center align-items-center">
<div class="col-6 col-md-3 mb-4" data-aos="fade-up" data-aos-delay="100">
<div class="partner-logo text-center">
<img src="assets/images/partner-1.png" alt="Partner 1" class="img-fluid grayscale" style="max-height: 80px;">
</div>
</div>
<div class="col-6 col-md-3 mb-4" data-aos="fade-up" data-aos-delay="200">
<div class="partner-logo text-center">
<img src="assets/images/partner-2.png" alt="Partner 2" class="img-fluid grayscale" style="max-height: 80px;">
</div>
</div>
<div class="col-6 col-md-3 mb-4" data-aos="fade-up" data-aos-delay="300">
<div class="partner-logo text-center">
<img src="assets/images/partner-3.png" alt="Partner 3" class="img-fluid grayscale" style="max-height: 80px;">
</div>
</div>
<div class="col-6 col-md-3 mb-4" data-aos="fade-up" data-aos-delay="400">
<div class="partner-logo text-center">
<img src="assets/images/partner-4.png" alt="Partner 4" class="img-fluid grayscale" style="max-height: 80px;">
</div>
</div>
</div>
</div>
</section>
<?php
// Include footer
include 'includes/footer.php';
?>