<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

echo "<pre style='font-family:monospace;font-size:13px;padding:20px'>";
echo "PHP: " . phpversion() . "\n\n";

// Test include satu per satu
$files = [
    'config/db.php',
    'config/helpers.php',
    'layout/header.php',
];

foreach ($files as $f) {
    $path = __DIR__ . '/' . $f;
    if (file_exists($path)) {
        echo "✅ Ada: $f\n";
    } else {
        echo "❌ TIDAK ADA: $f\n";
    }
}

echo "\n--- Mencoba include config/db.php ---\n";
try {
    require_once __DIR__ . '/config/db.php';
    echo "✅ db.php OK\n";
} catch(Throwable $e) {
    echo "❌ db.php ERROR: " . $e->getMessage() . " (line ".$e->getLine().")\n";
}

echo "\n--- Mencoba include config/helpers.php ---\n";
try {
    require_once __DIR__ . '/config/helpers.php';
    echo "✅ helpers.php OK\n";
} catch(Throwable $e) {
    echo "❌ helpers.php ERROR: " . $e->getMessage() . " (line ".$e->getLine().")\n";
}

echo "\n--- Session test ---\n";
session_start();
echo "✅ session OK\n";

echo "\n--- index.php syntax check ---\n";
$indexCode = file_get_contents(__DIR__ . '/index.php');
if ($indexCode === false) {
    echo "❌ index.php tidak bisa dibaca\n";
} else {
    echo "✅ index.php ada (".strlen($indexCode)." bytes)\n";
    // Cek baris pertama
    $lines = explode("\n", $indexCode);
    echo "Baris 1: " . htmlspecialchars($lines[0]) . "\n";
    echo "Baris 2: " . htmlspecialchars($lines[1]) . "\n";
}

echo "</pre>";
?>