<?php
require_once __DIR__ . '/../../../../../function/connect.php';

if (!isset($koneksi)) {
    exit('DB NOT CONNECTED');
}

/***********************
 * USER (OPTIONAL)
 ***********************/
$user = $_SESSION['username'] ?? '';

/***********************
 * FOLDER BANNER SPORTBOK
 ***********************/
$bannerDir = __DIR__ . '/../../../../../uploads/game_pic/fishing/';
$bannerUrl = '../uploads/game_pic/fishing/';

/***********************
 * AMBIL SEMUA GAMBAR
 ***********************/
$allowedExt = ['jpg', 'jpeg', 'png', 'webp'];
$banners = [];

if (is_dir($bannerDir)) {
    foreach (scandir($bannerDir) as $file) {

        if ($file === '.' || $file === '..') continue;

        $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));

        if (in_array($ext, $allowedExt)) {
            $banners[] = $bannerUrl . $file;
        }
    }
}

// OPTIONAL: urutkan nama file
sort($banners);
?>

<!-- ================= GAME LIST ================= -->
<?php foreach ($banners as $banner): ?>

<div class="sgx-game-card">

    <div class="sgx-game-thumb">
        <img src="<?= htmlspecialchars($banner); ?>" alt="Sportbook">
    </div>

<a href="?page=fishing&pesan=39" class="sgx-game-hover">
    <div class="game-thumb"></div>
    <div class="game-hover-overlay">
        <div class="play-content">
            <i class="fa fa-play"></i>
        </div>
    </div>
</a>
</div>

<style>


</style>
<?php endforeach; ?>

