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/video.php
<?php
/**
 * Halaman Video Galeri (YouTube Shorts & Video)
 * Menampilkan semua video dari tabel gallery
 */

require_once 'includes/config.php';
require_once 'includes/init.php';
require_once 'track-visitor.php';

// =====================================================
// HELPER: getYouTubeId (fallback)
// =====================================================
if (!function_exists('getYouTubeId')) {
    function getYouTubeId($url) {
        if (empty($url)) return '';
        $pattern = '~(?:youtube(?:-nocookie)?\.com/(?:(?:[^/]+/.+/)|(?:v|e(?:mbed)?|shorts|live)/|.*[?&]v=)|youtu\.be/)([A-Za-z0-9_-]{11})~x';
        return preg_match($pattern, $url, $m) ? $m[1] : '';
    }
}

global $conn;

// =====================================================
// PAGE META
// =====================================================
$page_title       = 'Galeri Video - ' . ($settings['site_title'] ?? 'Website Instansi');
$meta_description = 'Kumpulan video kegiatan dan informasi dari ' . ($settings['site_title'] ?? 'instansi');
$meta_keywords    = 'video, galeri video, youtube, shorts, ' . ($settings['site_keywords'] ?? '');

// =====================================================
// FILTER & PAGINATION
// =====================================================
$category_filter = isset($_GET['category']) ? trim($_GET['category']) : '';
$search_filter   = isset($_GET['q']) ? trim($_GET['q']) : '';
$page            = isset($_GET['page']) ? max(1, (int)$_GET['page']) : 1;
$limit           = 12;
$offset          = ($page - 1) * $limit;

// =====================================================
// BUILD QUERY
// =====================================================
$where  = ["type = 'video'", "status = 'active'"];
$params = [];

if ($category_filter !== '') {
    $cat_safe = $conn->real_escape_string($category_filter);
    $where[]  = "category = '$cat_safe'";
}

if ($search_filter !== '') {
    $q_safe = $conn->real_escape_string($search_filter);
    $where[] = "(title LIKE '%$q_safe%' OR description LIKE '%$q_safe%')";
}

$where_clause = implode(' AND ', $where);

// Total records
$total_videos = 0;
$total_pages  = 1;

$count_res = $conn->query("SELECT COUNT(*) as total FROM gallery WHERE $where_clause");
if ($count_res) {
    $total_videos = (int)$count_res->fetch_assoc()['total'];
    $total_pages  = $total_videos > 0 ? ceil($total_videos / $limit) : 1;
}

// Ambil data
$videos = [];
$res = $conn->query("
    SELECT id, title, description, image, video_url, category, featured, created_at
    FROM gallery
    WHERE $where_clause
    ORDER BY featured DESC, created_at DESC
    LIMIT $offset, $limit
");
if ($res) {
    while ($row = $res->fetch_assoc()) {
        $videos[] = $row;
    }
}

// =====================================================
// AMBIL SEMUA KATEGORI VIDEO UNTUK FILTER
// =====================================================
$video_categories = [];
$cat_res = $conn->query("
    SELECT category, COUNT(*) as total
    FROM gallery
    WHERE type = 'video' AND status = 'active' AND category != ''
    GROUP BY category
    ORDER BY category
");
if ($cat_res) {
    while ($row = $cat_res->fetch_assoc()) {
        $video_categories[] = $row;
    }
}

// =====================================================
// RENDER
// =====================================================
$body_class = 'has-video-page';
include 'includes/header.php';
?>

<style>
/* ============================================
   VIDEO PAGE
   ============================================ */
.video-page-hero {
    background: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%);
    color: white;
    padding: 60px 0 50px;
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
}

.video-page-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="15" fill="white" opacity="0.05"/><circle cx="80" cy="70" r="25" fill="white" opacity="0.05"/></svg>');
    pointer-events: none;
}

.video-page-hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 15px;
    position: relative;
    z-index: 2;
}

.video-page-hero p {
    font-size: 1.05rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.video-page-hero .badge {
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 20px;
    margin-bottom: 15px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
}

/* Filter bar */
.video-filter-bar {
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    margin-bottom: 30px;
}

.video-filter-bar .form-control,
.video-filter-bar .form-select {
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 10px 15px;
    font-size: 0.92rem;
}

.video-filter-bar .form-control:focus,
.video-filter-bar .form-select:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 0.2rem rgba(220,38,38,0.15);
}

.video-filter-bar .btn-filter {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 600;
}

.video-filter-bar .btn-filter:hover {
    background: linear-gradient(135deg, #b91c1c, #7f1d1d);
    color: white;
}

.video-filter-bar .btn-reset {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 15px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.video-filter-bar .btn-reset:hover {
    background: #e2e8f0;
    color: #334155;
}

/* Card Shorts */
.video-card {
    position: relative;
    display: block;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 9 / 16;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    transition: transform 0.3s, box-shadow 0.3s;
    text-decoration: none;
    cursor: pointer;
}

.video-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 14px 35px rgba(0,0,0,0.25);
}

.video-card .video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.video-card:hover .video-thumb {
    transform: scale(1.08);
}

.video-card .video-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0.4) 0%,
        transparent 25%,
        transparent 55%,
        rgba(0,0,0,0.88) 100%
    );
    pointer-events: none;
    z-index: 1;
}

.video-card .video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    background: rgba(255,255,255,0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dc2626;
    font-size: 24px;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 2;
}

.video-card:hover .video-play {
    transform: translate(-50%, -50%) scale(1.15);
    background: #dc2626;
    color: #fff;
}

.video-card .video-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    color: white;
    z-index: 3;
}

.video-card .video-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-card .video-meta {
    font-size: 0.75rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.video-card .video-category {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(220, 38, 38, 0.95);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 3;
}

.video-card .video-featured {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(245, 158, 11, 0.95);
    color: white;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 3;
}

.video-card .video-label {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 8px 5px;
    border-radius: 6px;
    font-size: 0.65rem;
    letter-spacing: 2px;
    font-weight: 700;
    z-index: 3;
}

/* Empty state */
.video-empty {
    text-align: center;
    padding: 70px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

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

.video-empty h4 {
    color: #475569;
    font-weight: 700;
}

/* Pagination */
.video-pagination .page-link {
    border: none;
    color: #475569;
    padding: 10px 16px;
    margin: 0 3px;
    border-radius: 8px;
    font-weight: 500;
}

.video-pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

.video-pagination .page-link:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* Responsive */
@media (max-width: 575px) {
    .video-page-hero h1 { font-size: 1.8rem; }
    .video-card .video-title { font-size: 0.85rem; }
    .video-card .video-play { width: 50px; height: 50px; font-size: 18px; }
    .video-card .video-label { display: none; }
}
</style>

<!-- ============================================
     HERO
     ============================================ -->
<section class="video-page-hero text-center">
    <div class="container">
        <span class="badge">
            <i class="fab fa-youtube me-2"></i>Galeri Video
        </span>
        <h1>Video Kegiatan & Informasi</h1>
        <p>Kumpulan video resmi dan liputan kegiatan instansi</p>
    </div>
</section>

<!-- ============================================
     FILTER BAR
     ============================================ -->
<div class="container">
    <div class="video-filter-bar">
        <form method="GET" action="<?php echo BASE_URL; ?>/video.php" class="row g-2 align-items-center">
            <div class="col-md-4">
                <input type="text" name="q" class="form-control" 
                       placeholder="Cari judul video..." 
                       value="<?php echo htmlspecialchars($search_filter); ?>">
            </div>
            <div class="col-md-3">
                <select name="category" class="form-select">
                    <option value="">Semua Kategori</option>
                    <?php foreach ($video_categories as $cat): ?>
                        <option value="<?php echo htmlspecialchars($cat['category']); ?>"
                            <?php echo $category_filter === $cat['category'] ? 'selected' : ''; ?>>
                            <?php echo htmlspecialchars($cat['category']); ?> (<?php echo $cat['total']; ?>)
                        </option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="col-md-5 d-flex gap-2">
                <button type="submit" class="btn btn-filter flex-grow-1">
                    <i class="fas fa-search me-2"></i>Cari
                </button>
                <?php if ($category_filter !== '' || $search_filter !== ''): ?>
                <a href="<?php echo BASE_URL; ?>/video.php" class="btn btn-reset" title="Reset">
                    <i class="fas fa-sync-alt"></i>
                </a>
                <?php endif; ?>
            </div>
        </form>
    </div>
</div>

<!-- ============================================
     GRID VIDEO
     ============================================ -->
<div class="container" style="padding-bottom: 60px;">
    
    <?php if (!empty($videos)): ?>
        
        <div class="d-flex justify-content-between align-items-center mb-3">
            <p class="text-muted mb-0">
                Menampilkan <strong><?php echo count($videos); ?></strong> 
                dari <strong><?php echo number_format($total_videos); ?></strong> video
                <?php if ($category_filter !== ''): ?>
                    — Kategori: <strong><?php echo htmlspecialchars($category_filter); ?></strong>
                <?php endif; ?>
            </p>
        </div>
        
        <div class="row g-3">
            <?php foreach ($videos as $video): 
                $yt_id = getYouTubeId($video['video_url'] ?? '');
                
                $thumb_url      = '';
                $thumb_fallback = '';
                if (!empty($video['image']) && preg_match('#^https?://#', $video['image'])) {
                    $thumb_url = $video['image'];
                } elseif (!empty($yt_id)) {
                    $thumb_url      = 'https://img.youtube.com/vi/' . $yt_id . '/maxresdefault.jpg';
                    $thumb_fallback = 'https://img.youtube.com/vi/' . $yt_id . '/hqdefault.jpg';
                }
            ?>
            <div class="col-xl-2 col-lg-3 col-md-4 col-6">
                <a href="#"
                   class="video-card"
                   data-video-id="<?php echo htmlspecialchars($yt_id); ?>"
                   data-video-title="<?php echo htmlspecialchars($video['title']); ?>"
                   onclick="return openVideoModal(event, this);">
                    
                    <?php if (!empty($video['category'])): ?>
                    <span class="video-category">
                        <i class="fas fa-tag me-1"></i><?php echo htmlspecialchars($video['category']); ?>
                    </span>
                    <?php endif; ?>
                    
                    <?php if (!empty($video['featured'])): ?>
                    <span class="video-featured"><i class="fas fa-star"></i></span>
                    <?php endif; ?>
                    
                    <?php if ($thumb_url): ?>
                    <img src="<?php echo $thumb_url; ?>" 
                         alt="<?php echo htmlspecialchars($video['title']); ?>"
                         class="video-thumb"
                         loading="lazy"
                         onerror="this.src='<?php echo $thumb_fallback ?: $thumb_url; ?>'">
                    <?php else: ?>
                    <div class="video-thumb d-flex align-items-center justify-content-center bg-secondary">
                        <i class="fas fa-video fa-3x text-white"></i>
                    </div>
                    <?php endif; ?>
                    
                    <div class="video-overlay"></div>
                    <div class="video-play"><i class="fas fa-play"></i></div>
                    <span class="video-label">SHORTS</span>
                    
                    <div class="video-content">
                        <div class="video-title">
                            <?php echo htmlspecialchars($video['title']); ?>
                        </div>
                        <div class="video-meta">
                            <span>
                                <i class="far fa-calendar me-1"></i>
                                <?php echo date('d M Y', strtotime($video['created_at'])); ?>
                            </span>
                        </div>
                    </div>
                </a>
            </div>
            <?php endforeach; ?>
        </div>
        
        <!-- Pagination -->
        <?php if ($total_pages > 1): ?>
        <nav class="mt-5">
            <ul class="pagination video-pagination justify-content-center">
                <li class="page-item <?php echo $page <= 1 ? 'disabled' : ''; ?>">
                    <a class="page-link" href="?page=<?php echo max(1, $page-1); ?>&category=<?php echo urlencode($category_filter); ?>&q=<?php echo urlencode($search_filter); ?>">
                        <i class="fas fa-chevron-left"></i>
                    </a>
                </li>
                <?php 
                $start = max(1, $page - 2);
                $end   = min($total_pages, $page + 2);
                for ($i = $start; $i <= $end; $i++): 
                ?>
                <li class="page-item <?php echo $i == $page ? 'active' : ''; ?>">
                    <a class="page-link" href="?page=<?php echo $i; ?>&category=<?php echo urlencode($category_filter); ?>&q=<?php echo urlencode($search_filter); ?>">
                        <?php echo $i; ?>
                    </a>
                </li>
                <?php endfor; ?>
                <li class="page-item <?php echo $page >= $total_pages ? 'disabled' : ''; ?>">
                    <a class="page-link" href="?page=<?php echo min($total_pages, $page+1); ?>&category=<?php echo urlencode($category_filter); ?>&q=<?php echo urlencode($search_filter); ?>">
                        <i class="fas fa-chevron-right"></i>
                    </a>
                </li>
            </ul>
        </nav>
        <?php endif; ?>
        
    <?php else: ?>
        
        <div class="video-empty">
            <i class="fab fa-youtube"></i>
            <h4>Belum Ada Video</h4>
            <p class="text-muted">
                <?php if ($category_filter !== '' || $search_filter !== ''): ?>
                    Tidak ada video yang cocok dengan filter Anda.
                <?php else: ?>
                    Video akan muncul di sini setelah ditambahkan melalui admin.
                <?php endif; ?>
            </p>
            <?php if ($category_filter !== '' || $search_filter !== ''): ?>
                <a href="<?php echo BASE_URL; ?>/video.php" class="btn btn-outline-danger mt-3">
                    <i class="fas fa-sync-alt me-2"></i>Reset Filter
                </a>
            <?php endif; ?>
        </div>
        
    <?php endif; ?>
    
</div>

<!-- ============================================
     MODAL PREVIEW VIDEO
     ============================================ -->
<div class="modal fade" id="videoModal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-lg">
        <div class="modal-content border-0">
            <div class="modal-header bg-dark text-white border-0">
                <h5 class="modal-title">
                    <i class="fab fa-youtube text-danger me-2"></i>
                    <span id="videoModalTitle">Video</span>
                </h5>
                <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body p-0 bg-black">
                <div class="ratio ratio-16x9">
                    <iframe id="videoModalFrame" src="" title="YouTube video player"
                            allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
                            allowfullscreen referrerpolicy="strict-origin-when-cross-origin"></iframe>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
function openVideoModal(event, el) {
    event.preventDefault();
    const videoId    = el.getAttribute('data-video-id');
    const videoTitle = el.getAttribute('data-video-title');
    
    if (!videoId) {
        alert('Video tidak tersedia.');
        return false;
    }
    
    document.getElementById('videoModalTitle').textContent = videoTitle || 'Video';
    document.getElementById('videoModalFrame').src = 
        'https://www.youtube.com/embed/' + videoId + '?autoplay=1&rel=0';
    
    new bootstrap.Modal(document.getElementById('videoModal')).show();
    return false;
}

document.addEventListener('DOMContentLoaded', function () {
    const modal = document.getElementById('videoModal');
    if (modal) {
        modal.addEventListener('hidden.bs.modal', function () {
            document.getElementById('videoModalFrame').src = '';
        });
    }
});
</script>

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

Youez - 2016 - github.com/yon3zu
LinuXploit