<?php

declare(strict_types=1);

header('Content-Type: text/html; charset=utf-8');

$root = __DIR__;
$script = str_replace('\\', '/', (string)($_SERVER['SCRIPT_NAME'] ?? '/upload-check.php'));
$folder = rtrim(str_replace('\\', '/', dirname($script)), '/');
if ($folder === '/' || $folder === '.') {
    $folder = '';
}

?>
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Upload OK — Karvi</title>
    <style>
        body { font-family: Arial, sans-serif; max-width: 640px; margin: 2rem auto; padding: 0 1rem; line-height: 1.6; }
        .ok { background: #e8f5e9; border: 2px solid #2e7d32; padding: 1.25rem; border-radius: 10px; }
        code { background: #eee; padding: 2px 6px; border-radius: 4px; }
    </style>
</head>
<body>
    <div class="ok">
        <h1>Upload OK</h1>
        <p>PHP works. Files are in the correct folder.</p>
        <p><strong>Folder:</strong> <code><?= htmlspecialchars($folder !== '' ? $folder : '/', ENT_QUOTES, 'UTF-8') ?></code></p>
        <p><strong>PHP:</strong> <?= htmlspecialchars(PHP_VERSION, ENT_QUOTES, 'UTF-8') ?></p>
    </div>
    <p>Next steps:</p>
    <ol>
        <li>Upload the <strong>full</strong> zip (all files + vendor folder)</li>
        <li>Open <a href="install.php">install.php</a></li>
        <li>Then open <a href="index.php">index.php</a></li>
    </ol>
</body>
</html>
