<?php
$dirs = [
    __DIR__ . '/api',
    __DIR__ . '/includes',
    __DIR__ . '/css',
    __DIR__ . '/js',
    dirname(__DIR__, 2) // root of where cookie might be? No, cookie is in dirname(__DIR__, 2) relative to ProxyHelper?
    // ProxyHelper says: dirname(__DIR__, 2) which is office-system/
];

// We want to ensure 'api' and 'includes' exist in 'public'
$base = __DIR__;
$targets = ['api', 'includes', 'css', 'js'];

foreach ($targets as $t) {
    $path = $base . '/' . $t;
    if (!file_exists($path)) {
        if (mkdir($path, 0755, true)) {
            echo "Created $t<br>";
        } else {
            echo "Failed to create $t<br>";
        }
    } else {
        echo "$t exists<br>";
    }
}

// Also ensure the cookie directory is writable?
// ProxyHelper writes to dirname(__DIR__, 2).
// If this file is in public/, __DIR__ is public.
// dirname(__DIR__) is office-system.
// dirname(__DIR__, 2) is public_html (or whatever parent).
// ProxyHelper says: $baseDir = dirname(__DIR__, 2); where __DIR__ is includes.
// includes is in public. so public/includes.
// dirname(public/includes) = public.
// dirname(public) = office-system.
// So cookie file is in office-system/.
// We need to ensure office-system is writable, which it usually is.

echo "Done.";
