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

echo "<div style='background:#000; color:#00f2ff; padding:20px; font-family:monospace; border:2px solid #00f2ff;'>";
echo "<h2>--- TAMIM 1280 LOCAL FOLDER DIAGNOSTIC ---</h2>";

// ১. সেশন রাইট টেস্ট
$s_path = __DIR__ . '/sessions';
if (!file_exists($s_path)) { @mkdir($s_path, 0755, true); }
echo "Session Folder: " . (is_writable($s_path) ? "✅ OK" : "❌ FAILED") . "<br>";

// ২. ডাটাবেস টেস্ট
if (file_exists('config.php')) {
    include 'config.php';
    if (isset($conn) && !$conn->connect_error) {
        echo "Database Status: ✅ CONNECTED<br>";
    } else {
        echo "Database Status: ❌ FAILED (" . ($conn->connect_error ?? "Check config.php credentials") . ")<br>";
    }
} else {
    echo "Database Status: ❌ config.php NOT FOUND<br>";
}

// ৩. পিএইচপি এরর চেক (লগইন লুপের জন্য)
echo "PHP Version: " . PHP_VERSION . "<br>";
echo "Current Directory: " . __DIR__ . "<br>";

echo "<h3>Copy the content below and send to AI:</h3>";
echo "<textarea id='report' style='width:100%; height:150px; background:#111; color:#0f0; border:1px solid #444;'>";
echo "LOCATION: " . __DIR__ . "\n";
echo "SESSION: " . (is_writable($s_path) ? "WORKING" : "NOT WORKING") . "\n";
if (isset($conn)) echo "DB_STATUS: " . ($conn->connect_error ? "ERROR: ".$conn->connect_error : "CONNECTED") . "\n";
echo "PHP_VER: " . PHP_VERSION . "\n";
echo "</textarea>";
echo "<button onclick='copyR()' style='padding:10px; margin-top:10px; cursor:pointer;'>COPY REPORT</button>";
echo "</div>";

echo "<script>function copyR(){ var t = document.getElementById('report'); t.select(); document.execCommand('copy'); alert('Copied!'); }</script>";
?>