403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bpkd//berita.php
<?php
/**
 * Halaman Daftar Berita
 */

// Load inisialisasi
require_once 'admin/config/database.php';
require_once 'includes/init.php';

// Set page variables
$page_title = 'Berita Terbaru - ' . ($settings['site_title'] ?? 'Website Instansi');
$meta_description = 'Daftar berita dan artikel terbaru dari instansi';

// =====================================================
// HANDLE SEARCH & FILTER KATEGORI
// =====================================================
$search_keyword = isset($_GET['search']) ? trim($_GET['search']) : '';
$category_slug = isset($_GET['slug']) ? trim($_GET['slug']) : '';
$selected_category_name = '';
$category_filter = 0;

// Jika ada slug, cari ID kategori
if (!empty($category_slug)) {
    $cat_query = $conn->query("SELECT id, name FROM categories WHERE slug = '$category_slug'");
    if ($cat_query && $cat_query->num_rows > 0) {
        $cat_data = $cat_query->fetch_assoc();
        $category_filter = $cat_data['id'];
        $selected_category_name = $cat_data['name'];
    }
}

// Sanitasi untuk tampilan
$search_display = htmlspecialchars($search_keyword, ENT_QUOTES, 'UTF-8');

// Pagination
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$limit = 9;
$offset = ($page - 1) * $limit;

// =====================================================
// BUILD WHERE CLAUSE
// =====================================================
$where_clause = "a.status = 'published'";
$params = [];
$types = "";

// Filter berdasarkan kata kunci
if (!empty($search_keyword)) {
    $search_param = "%$search_keyword%";
    $where_clause .= " AND (a.title LIKE ? OR a.content LIKE ? OR a.excerpt LIKE ?)";
    $params[] = $search_param;
    $params[] = $search_param;
    $params[] = $search_param;
    $types .= "sss";
}

// Filter berdasarkan kategori
if ($category_filter > 0) {
    $where_clause .= " AND a.category_id = ?";
    $params[] = $category_filter;
    $types .= "i";
}

// =====================================================
// HITUNG TOTAL ARTICLES
// =====================================================
if (!empty($params)) {
    $count_sql = "SELECT COUNT(*) as total FROM articles a WHERE $where_clause";
    $count_stmt = $conn->prepare($count_sql);
    if ($count_stmt) {
        $count_stmt->bind_param($types, ...$params);
        $count_stmt->execute();
        $total_result = $count_stmt->get_result();
        $total = $total_result->fetch_assoc()['total'];
        $count_stmt->close();
    } else {
        $total = 0;
    }
} else {
    $total_result = $conn->query("SELECT COUNT(*) as total FROM articles a WHERE $where_clause");
    $total = $total_result->fetch_assoc()['total'];
}
$total_pages = ceil($total / $limit);

// =====================================================
// AMBIL ARTICLES
// =====================================================
if (!empty($params)) {
    $sql = "
        SELECT a.*, c.name as category_name, c.slug as category_slug, 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 $where_clause 
        ORDER BY a.published_at DESC 
        LIMIT ? OFFSET ?
    ";
    $stmt = $conn->prepare($sql);
    $params[] = $limit;
    $params[] = $offset;
    $types .= "ii";
    
    if ($stmt) {
        $stmt->bind_param($types, ...$params);
        $stmt->execute();
        $articles = $stmt->get_result();
        $stmt->close();
    } else {
        $articles = false;
    }
} else {
    $articles = $conn->query("
        SELECT a.*, c.name as category_name, c.slug as category_slug, 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 $offset, $limit
    ");
}

$search_has_results = ($articles && $articles->num_rows > 0);

// =====================================================
// AMBIL SEMUA KATEGORI UNTUK FILTER (DENGAN JUMLAH ARTIKEL)
// =====================================================
$categories = $conn->query("
    SELECT c.*, COUNT(a.id) as article_count 
    FROM categories c
    LEFT JOIN articles a ON a.category_id = c.id AND a.status = 'published'
    GROUP BY c.id
    ORDER BY c.name ASC
");

//tim kontribur
$query = "SELECT id, username, email, full_name, role, avatar, last_login, created_at 
          FROM users 
          ORDER BY full_name ASC";

$result = $conn->query($query);
$users = [];
if ($result && $result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $users[] = $row;
    }
}

// =====================================================
// HITUNG TOTAL USER
// =====================================================
$total_users = count($users);

// =====================================================
// FUNGSI UNTUK AVATAR
// =====================================================
function getAvatarUrl($avatar, $full_name) {
    if (!empty($avatar)) {
        // Normalisasi path
        $avatar = ltrim($avatar, '/');
        
        // Cek di BASE_PATH
        $file_path = BASE_PATH . $avatar;
        $file_path = str_replace('\\', '/', $file_path);
        
        if (file_exists($file_path)) {
            return BASE_URL . '/' . $avatar;
        }
        
        // Cek di document root
        $doc_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $avatar;
        $doc_path = str_replace('\\', '/', $doc_path);
        if (file_exists($doc_path)) {
            return BASE_URL . '/' . $avatar;
        }
        
        // Cek di document root + bpkd
        $bpkd_path = $_SERVER['DOCUMENT_ROOT'] . '/bpkd/' . $avatar;
        $bpkd_path = str_replace('\\', '/', $bpkd_path);
        if (file_exists($bpkd_path)) {
            return BASE_URL . '/' . $avatar;
        }
    }
    
    // Fallback: inisial nama
    $initials = '';
    $names = explode(' ', $full_name);
    foreach ($names as $name) {
        if (!empty($name)) {
            $initials .= strtoupper($name[0]);
        }
    }
    return $initials ?: strtoupper(substr($full_name, 0, 2));
}

function getInitialsAvatar($full_name, $id) {
    $initials = '';
    $names = explode(' ', $full_name);
    foreach ($names as $name) {
        if (!empty($name)) {
            $initials .= strtoupper($name[0]);
        }
    }
    if (empty($initials)) {
        $initials = strtoupper(substr($full_name, 0, 2));
    }
    return $initials;
}

// Fungsi untuk random warna avatar
function getAvatarColor($id) {
    $colors = [
        '#4e73df', '#1cc88a', '#36b9cc', '#f6c23e', '#e74a3b',
        '#858796', '#5a5c69', '#2e59d9', '#17a673', '#2c9faf',
        '#dda20a', '#c21e2d', '#6b6d7d', '#3a3b45'
    ];
    return $colors[$id % count($colors)];
}

// =====================================================
// ROLE BADGE
// =====================================================
function getRoleBadge($role) {
    $badges = [
        'superadmin' => '<span class="badge bg-danger"><i class="fas fa-crown me-1"></i>Super Admin</span>',
        'admin' => '<span class="badge bg-primary"><i class="fas fa-user-shield me-1"></i>Admin</span>',
        'editor' => '<span class="badge bg-info"><i class="fas fa-user-edit me-1"></i>Editor</span>'
    ];
    return $badges[$role] ?? '<span class="badge bg-secondary">' . $role . '</span>';
}

// Include header
include 'includes/header.php';
?>

<style>
/* ============================================
   BERITA PAGE STYLES
   ============================================ */

/* Search Widget */
.berita-search-widget {
    background: white;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 30px;
    border: 1px solid #eef2f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.berita-search-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.berita-search-title i {
    color: #3b82f6;
}

.berita-search-title .berita-title-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, #e2e8f0, transparent);
}

.berita-search-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.berita-search-input-group {
    flex: 1;
    position: relative;
}

.berita-search-input-group input,
.berita-search-input-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.9rem;
    transition: all 0.3s;
    background: white;
}

.berita-search-input-group input:focus,
.berita-search-input-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.berita-search-btn {
    padding: 0 24px;
    background: #3b82f6;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.berita-search-btn:hover {
    background: #1d4ed8;
}

.berita-search-reset {
    padding: 0 20px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.berita-search-reset:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Search Info */
.berita-search-info {
    background: #eff6ff;
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.berita-search-info-text {
    color: #1d4ed8;
    font-size: 0.9rem;
}

/* Categories Grid */
.berita-categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.berita-category-card {
    background: white;
    border-radius: 20px;
    padding: 25px 20px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid #eef2f6;
    text-decoration: none;
    display: block;
}

.berita-category-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 30px -12px rgba(0, 0, 0, 0.12);
    border-color: #3b82f6;
}

.berita-category-icon {
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    transition: all 0.3s;
}

.berita-category-card:hover .berita-category-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.berita-category-icon i {
    font-size: 1.5rem;
    color: #3b82f6;
    transition: all 0.3s;
}

.berita-category-card:hover .berita-category-icon i {
    color: white;
}

.berita-category-name {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: #1e293b;
}

.berita-category-count {
    font-size: 0.7rem;
    color: #64748b;
    margin: 0;
}

.berita-category-card:hover .berita-category-name,
.berita-category-card:hover .berita-category-count {
    color: #3b82f6;
}

/* News Card */
.berita-news-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #eef2f6;
    height: 100%;
}

.berita-news-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 30px -12px rgba(0, 0, 0, 0.1);
}

.berita-news-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.berita-news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.berita-news-card:hover .berita-news-image img {
    transform: scale(1.05);
}

.berita-news-category {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #3b82f6;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.berita-news-content {
    padding: 20px;
}

.berita-news-meta {
    font-size: 0.75rem;
    color: #6c7a8e;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.berita-news-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 0 0 10px 0;
}

.berita-news-title a {
    color: #1a2c3e;
    transition: color 0.3s;
    text-decoration: none;
}

.berita-news-title a:hover {
    color: #3b82f6;
}

.berita-news-excerpt {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 12px;
}

.berita-news-link {
    color: #3b82f6;
    font-weight: 600;
    font-size: 0.8rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: gap 0.3s;
}

.berita-news-link:hover {
    gap: 10px;
    color: #1d4ed8;
}

/* Pagination */
.berita-pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 40px;
}

.berita-pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    transition: all 0.3s;
}

.berita-pagination .page-link:hover,
.berita-pagination .active .page-link {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.berita-pagination .disabled .page-link {
    opacity: 0.5;
    pointer-events: none;
}

/* Empty State */
.berita-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border-radius: 20px;
}

.berita-empty-state i {
    font-size: 4rem;
    color: #cbd5e1;
    margin-bottom: 20px;
}

.berita-empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a2c3e;
    margin-bottom: 8px;
}

.berita-empty-state p {
    color: #6c7a8e;
    font-size: 0.85rem;
}

mark {
    background: #fef08a;
    padding: 0 2px;
    border-radius: 4px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .berita-categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .berita-search-form {
        flex-direction: column;
    }
    
    .berita-search-btn,
    .berita-search-reset {
        padding: 10px 20px;
        justify-content: center;
    }
    
    .berita-search-info {
        flex-direction: column;
        text-align: center;
    }
    
    .berita-news-image {
        height: 180px;
    }
    
    .berita-categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .berita-category-card {
        padding: 20px 15px;
    }
    
    .berita-news-meta {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 576px) {
    .berita-categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .berita-category-icon {
        width: 45px;
        height: 45px;
    }
    
    .berita-category-icon i {
        font-size: 1.2rem;
    }
    
    .berita-category-name {
        font-size: 0.8rem;
    }
    
    .berita-news-title {
        font-size: 0.9rem;
    }
    
    .berita-news-excerpt {
        font-size: 0.75rem;
    }
}
</style>

<style>
/* =====================================================
   CARD STYLE - UKURAN 1/2
   ===================================================== */
.user-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 10px 0;
}

.user-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 14px 12px 12px;
    text-align: center;
    transition: all 0.2s ease;
    border: 1px solid #f0f0f0;
    position: relative;
}

.user-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
    border-color: #4e73df;
}

.user-card .card-badge {
    position: absolute;
    top: 6px;
    right: 6px;
}

/* Avatar - Lebih Kecil */
.user-card .avatar-wrapper {
    position: relative;
    width: 52px;
    height: 52px;
    margin: 0 auto 8px;
}

.user-card .avatar-wrapper .avatar-img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f0f0f0;
    transition: all 0.2s ease;
}

.user-card:hover .avatar-img {
    border-color: #4e73df;
}

.user-card .avatar-wrapper .avatar-initials {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin: 0 auto;
    border: 2px solid #f0f0f0;
    transition: all 0.2s ease;
}

.user-card:hover .avatar-initials {
    border-color: #4e73df;
}

/* Status indicator - Lebih Kecil */
.user-card .status-indicator {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: #2ecc71;
}

/* Username - Lebih Kecil */
.user-card .username {
    font-size: 0.8rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card .email {
    font-size: 0.65rem;
    color: #a0aec0;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card .user-role {
    margin-bottom: 6px;
}

/* Meta - Lebih Kecil */
.user-card .user-meta {
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 0.55rem;
    color: #a0aec0;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
}

.user-card .user-meta span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.user-card .user-meta i {
    font-size: 0.5rem;
}

/* Tombol Aksi - Lebih Kecil */
.user-card .action-buttons {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: center;
    gap: 6px;
}

.user-card .action-buttons .btn-sm {
    padding: 2px 6px;
    font-size: 0.6rem;
    border-radius: 6px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #e2e8f0;
}

.empty-state h4 {
    color: #2d3748;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 576px) {
    .user-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
}
</style>

<div class="container py-5">
    
    <!-- Header -->
    <div class="d-flex align-items-center justify-content-between mb-4 flex-wrap gap-3">
        <div>
            <h2 class="fw-bold mb-1">Berita Kita</h2>
            <div class="art-header-underline" style="width: 60px; height: 4px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); border-radius: 4px;"></div>
        </div>
    </div>

    <!-- Search Widget -->
    <div class="berita-search-widget">
        <div class="berita-search-title">
            <i class="fas fa-search"></i>
            <span>Cari Berita & Artikel</span>
            <div class="berita-title-line"></div>
        </div>
        <form action="berita.php" method="GET" class="berita-search-form">
            <div class="berita-search-input-group" style="flex: 2;">
                <input type="text" name="search" placeholder="Cari berita atau artikel..." 
                       value="<?php echo $search_display; ?>">
            </div>
            <div class="berita-search-input-group" style="flex: 1;">
                <select name="slug">
                    <option value="">Semua Kategori</option>
                    <?php 
                    if ($categories && $categories->num_rows > 0) {
                        $categories->data_seek(0);
                        while($cat = $categories->fetch_assoc()): 
                            $selected = ($category_slug == $cat['slug']) ? 'selected' : '';
                    ?>
                    <option value="<?php echo $cat['slug']; ?>" <?php echo $selected; ?>>
                        <?php echo htmlspecialchars($cat['name']); ?> (<?php echo $cat['article_count']; ?>)
                    </option>
                    <?php 
                        endwhile;
                    }
                    ?>
                </select>
            </div>
            <button type="submit" class="berita-search-btn">
                <i class="fas fa-search me-2"></i>Cari
            </button>
            <?php if (!empty($search_keyword) || !empty($category_slug)): ?>
            <a href="berita.php" class="berita-search-reset">
                <i class="fas fa-times me-1"></i> Reset
            </a>
            <?php endif; ?>
        </form>
    </div>

    <!-- Search Info -->
    <?php if (!empty($search_keyword) || !empty($category_slug)): ?>
    <div class="berita-search-info">
        <div class="berita-search-info-text">
            <i class="fas fa-search"></i> 
            Menampilkan hasil 
            <?php if (!empty($search_keyword)): ?>
                pencarian untuk: <strong>"<?php echo $search_display; ?>"</strong>
            <?php endif; ?>
            <?php if (!empty($selected_category_name)): ?>
                <?php if (!empty($search_keyword)): ?> dan <?php endif; ?>
                kategori: <strong><?php echo htmlspecialchars($selected_category_name); ?></strong>
            <?php endif; ?>
        </div>
        <div class="berita-search-info-text">
            <i class="fas fa-file-alt"></i> 
            Ditemukan <strong><?php echo $total; ?></strong> berita
        </div>
    </div>
    <?php endif; ?>
    
    <!-- Articles List -->
    <?php if ($search_has_results): ?>
        <div class="row g-4">
            <?php while($article = $articles->fetch_assoc()): 
                // Buat link artikel dengan benar
                if (!empty($article['url_hash'])) {
                    $article_url = BASE_URL . '/artikel/' . $article['url_hash'];
                } else {
                    $article_url = BASE_URL . '/detail-artikel.php?id=' . $article['id'];
                }

                //$article_url = article_url($article);
                $image_path = !empty($article['featured_image']) ? $article['featured_image'] : BASE_URL . '/assets/images/news-default.png';
            ?>
            <div class="col-lg-4 col-md-6">
                <div class="berita-news-card">
                    <div class="berita-news-image">
                        <img src="<?php echo $image_path; ?>" alt="<?php echo htmlspecialchars($article['title']); ?>">
                        <div class="berita-news-category"><?php echo htmlspecialchars($article['category_name'] ?? 'Umum'); ?></div>
                    </div>
                    <div class="berita-news-content">
                        <div class="berita-news-meta">
                            <span><i class="far fa-calendar me-1"></i> <?php echo tgl_indonesia($article['published_at']); ?></span>
                            <span><i class="far fa-user me-1"></i> <?php echo htmlspecialchars($article['author_name'] ?? 'Admin'); ?></span>
                            <span><i class="fas fa-eye text-primary me-1"></i> <?php echo number_format($article['views'] ?? 0); ?></span>
                        </div>
                        <h3 class="berita-news-title">
                            <a href="<?php echo $article_url; ?>">
                                <?php 
                                $title = htmlspecialchars($article['title']);
                                if (!empty($search_keyword)) {
                                    $title = preg_replace("/($search_display)/i", "<mark>$1</mark>", $title);
                                }
                                echo $title;
                                ?>
                            </a>
                        </h3>
                        <p class="berita-news-excerpt">
                            <?php 
                            $excerpt = substr($article['excerpt'] ?? strip_tags($article['content']), 0, 100) . '...';
                            if (!empty($search_keyword)) {
                                $excerpt = preg_replace("/($search_display)/i", "<mark>$1</mark>", $excerpt);
                            }
                            echo $excerpt;
                            ?>
                        </p>
                        <a href="<?php echo $article_url; ?>" class="berita-news-link">
                            Baca Selengkapnya <i class="fas fa-arrow-right ms-2"></i>
                        </a>
                    </div>
                </div>
            </div>
            <?php endwhile; ?>
        </div>
        
        <!-- Pagination -->
        <?php if ($total_pages > 1): ?>
        <div class="berita-pagination">
            <a class="page-link <?php echo $page <= 1 ? 'disabled' : ''; ?>" 
               href="?page=<?php echo $page-1; ?>&search=<?php echo urlencode($search_keyword); ?>&slug=<?php echo urlencode($category_slug); ?>">
                <i class="fas fa-chevron-left"></i>
            </a>
            
            <?php 
            $start_page = max(1, $page - 2);
            $end_page = min($total_pages, $page + 2);
            for($i = $start_page; $i <= $end_page; $i++): 
            ?>
            <a class="page-link <?php echo $i == $page ? 'active' : ''; ?>" 
               href="?page=<?php echo $i; ?>&search=<?php echo urlencode($search_keyword); ?>&slug=<?php echo urlencode($category_slug); ?>">
                <?php echo $i; ?>
            </a>
            <?php endfor; ?>
            
            <a class="page-link <?php echo $page >= $total_pages ? 'disabled' : ''; ?>" 
               href="?page=<?php echo $page+1; ?>&search=<?php echo urlencode($search_keyword); ?>&slug=<?php echo urlencode($category_slug); ?>">
                <i class="fas fa-chevron-right"></i>
            </a>
        </div>
        <?php endif; ?>
        
    <?php else: ?>
        <div class="berita-empty-state">
            <?php if (!empty($search_keyword) || !empty($category_slug)): ?>
                <i class="fas fa-search"></i>
                <h3>Tidak Ada Hasil Pencarian</h3>
                <p>Tidak ditemukan berita dengan kriteria yang Anda cari.</p>
                <a href="berita.php" class="btn btn-primary mt-3">
                    <i class="fas fa-arrow-left me-2"></i>Lihat Semua Berita
                </a>
            <?php else: ?>
                <i class="fas fa-newspaper"></i>
                <h3>Belum Ada Berita</h3>
                <p>Belum ada berita yang dipublikasikan.</p>
            <?php endif; ?>
        </div>
    <?php endif; ?>

</div>



<div class="container py-5">

    <div class="d-flex align-items-center justify-content-between mb-4 flex-wrap gap-3">
        <div>
            <h2 class="fw-bold mb-1">Tim Kontributor</h2>
            <div class="art-header-underline" style="width: 60px; height: 4px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); border-radius: 4px;"></div>
        </div>
    </div>

    <!-- Card Grid -->
    <?php if (!empty($users)): ?>
        <div class="user-card-grid">
            <?php foreach ($users as $user): 
                $avatar = getAvatarUrl($user['avatar'], $user['full_name'], $user['id']);
                $avatarColor = getAvatarColor($user['id']);
                $isAvatarImage = strpos($avatar, 'http') === 0 || strpos($avatar, '/') === 0;
            ?>
                <div class="user-card" data-user-id="<?php echo $user['id']; ?>">
                    <!-- Avatar -->
                    <div class="avatar-wrapper">
                        <?php if ($isAvatarImage): ?>
                            <img src="<?php echo $avatar; ?>" 
                                 alt="<?php echo htmlspecialchars($user['full_name']); ?>" 
                                 class="avatar-img"
                                 onerror="this.style.display='none'; this.parentElement.innerHTML='<div class=\'avatar-initials\' style=\'background:<?php echo $avatarColor; ?>;\'><?php echo getInitialsAvatar($user['full_name'], $user['id']); ?></div>'">
                        <?php else: ?>
                            <div class="avatar-initials" style="background: <?php echo $avatarColor; ?>;">
                                <?php echo $avatar; ?>
                            </div>
                        <?php endif; ?>
                        <div class="status-indicator" title="Aktif"></div>
                    </div>

                    <!-- Username -->
                    <div class="username"><?php echo htmlspecialchars($user['full_name']); ?></div>
                    <div class="email">
                        <i class="fas fa-envelope me-1" style="font-size: 10px;"></i>
                        <?php echo htmlspecialchars($user['email']); ?>
                    </div>
                    
                </div>
            <?php endforeach; ?>
        </div>
    <?php else: ?>
        <div class="empty-state">
            <i class="fas fa-users-slash"></i>
            <h4>Belum Ada Pengguna</h4>
            <p class="text-muted">Silakan tambahkan pengguna baru untuk memulai</p>
            <a href="<?php echo BASE_URL; ?>/admin/user-add.php" class="btn btn-primary mt-3">
                <i class="fas fa-plus me-2"></i>Tambah Pengguna Pertama
            </a>
        </div>
    <?php endif; ?>
</div>

<?php
// Include footer
include 'includes/footer.php';
?>

Youez - 2016 - github.com/yon3zu
LinuXploit