<?php
$dirs = ['../assets/icons/', '../assets/videos/', '../games/'];
echo "<h2>Upload Probe</h2>";
foreach ($dirs as $dir) {
    echo "<h3>Testing: $dir</h3>";
    if (is_dir($dir)) {
        echo "<p style='color:green;'>Directory exists.</p>";
    } else {
        echo "<p style='color:orange;'>Directory does not exist. Attempting to create...</p>";
        if (mkdir($dir, 0777, true)) {
            echo "<p style='color:green;'>Successfully created directory.</p>";
        } else {
            echo "<p style='color:red;'>FAILED to create directory.</p>";
        }
    }

    if (is_writable($dir)) {
        echo "<p style='color:green;'>Directory is WRITABLE.</p>";
    } else {
        echo "<p style='color:red;'>Directory is NOT WRITABLE.</p>";
    }

    $testFile = $dir . 'test_write.txt';
    if (@file_put_contents($testFile, 'test')) {
        echo "<p style='color:green;'>Successfully wrote test file.</p>";
        unlink($testFile);
    } else {
        echo "<p style='color:red;'>FAILED to write test file.</p>";
    }
}

echo "<h3>Server Info</h3>";
echo "PHP User: " . get_current_user() . "<br>";
echo "upload_tmp_dir: " . ini_get('upload_tmp_dir') . "<br>";
echo "post_max_size: " . ini_get('post_max_size') . "<br>";
echo "upload_max_filesize: " . ini_get('upload_max_filesize') . "<br>";
?>