<?php
/**
 * debug_casino.php
 * ⚠️ শুধু Debug-এর জন্য — casino.json-এ ঠিক কী Content আছে,
 * JSON সঠিকভাবে Parse হচ্ছে কিনা, তা সরাসরি দেখানোর জন্য।
 */
header('Content-Type: text/plain; charset=utf-8');

$filePath = __DIR__ . '/deepanshu/api/webapi/data/casino.json';

echo "File Path: $filePath\n";
echo "File Exists: " . (file_exists($filePath) ? "হ্যাঁ" : "না") . "\n";

if (file_exists($filePath)) {
    echo "File Size: " . filesize($filePath) . " bytes\n\n";

    $rawContent = file_get_contents($filePath);
    echo "প্রথম ৩০০ Character (Raw):\n";
    echo substr($rawContent, 0, 300) . "\n\n";

    echo "শেষ ৩০০ Character (Raw):\n";
    echo substr($rawContent, -300) . "\n\n";

    $jsonData = json_decode($rawContent, true);
    echo "JSON Decode Error: " . json_last_error_msg() . "\n\n";

    if ($jsonData !== null) {
        echo "Top-Level Key-গুলো: " . implode(', ', array_keys($jsonData)) . "\n";
        if (isset($jsonData['data'])) {
            echo "'data'-এর ভেতরের Key-গুলো: " . implode(', ', array_keys($jsonData['data'])) . "\n";
        }
        if (isset($jsonData['gameLists'])) {
            echo "Top-Level gameLists-এ মোট Game: " . count($jsonData['gameLists']) . "\n";
        }
        if (isset($jsonData['data']['gameLists'])) {
            echo "data.gameLists-এ মোট Game: " . count($jsonData['data']['gameLists']) . "\n";
        }
    }
}
