<?php
// Super detailed diagnostic
echo "<h2>PHP Diagnostic</h2>";
echo "PHP Version: " . phpversion() . "<br>";
echo "Current User: " . get_current_user() . "<br>";
echo "Script Owner: " . fileowner(__FILE__) . "<br>";
echo "File Perms: " . substr(sprintf('%o', fileperms(__FILE__)), -4) . "<br>";
echo "Document Root: " . $_SERVER['DOCUMENT_ROOT'] . "<br>";
echo "Script Name: " . $_SERVER['SCRIPT_FILENAME'] . "<br>";
echo "Request URI: " . $_SERVER['REQUEST_URI'] . "<br><hr>";

echo "<h3>Writable Paths:</h3>";
 $paths = [
    __DIR__,
    __DIR__ . '/../storage',
    __DIR__ . '/../bootstrap/cache',
    __DIR__ . '/../vendor'
];
foreach($paths as $p) {
    $exists = file_exists($p);
    $writable = is_writable($p);
    $perms = $exists ? substr(sprintf('%o', fileperms($p)), -4) : 'N/A';
    echo "$p → Exists:$exists Writable:$writable Perms:$perms<br>";
}

echo "<hr><h3>PHP Extensions:</h3>";
 $exts = ['bcmath','ctype','fileinfo','json','mbstring','openssl','pdo','tokenizer','xml'];
foreach($exts as $ext) {
    $loaded = extension_loaded($ext);
    echo "$ext: " . ($loaded ? '✅' : '❌ MISSING') . "<br>";
}

phpinfo();
?>