<?php
/**
 * Install Script – create required upload directories
 * Run once: http://localhost/kursi/install.php
 */
$dirs = [
    'assets/images/slider',
    'assets/images/news',
    'assets/images/gallery',
    'assets/images/brands',
    'assets/images/projects',
    'assets/images/catalog',
    'assets/images/customers',
    'assets/images/about',
    'assets/images/products',
    'assets/files',
];

$base = __DIR__;
$results = [];
foreach ($dirs as $d) {
    $path = $base.'/'.$d;
    if (!is_dir($path)) {
        $ok = mkdir($path, 0755, true);
        $results[] = ['dir'=>$d,'status'=>$ok?'created':'failed'];
    } else {
        $results[] = ['dir'=>$d,'status'=>'exists'];
    }
}
?><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Install</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
</head>
<body class="bg-light py-5">
<div class="container" style="max-width:600px;">
    <h4 class="fw-bold mb-4">Directory Setup</h4>
    <table class="table table-bordered table-sm">
        <thead><tr><th>Directory</th><th>Status</th></tr></thead>
        <tbody>
        <?php foreach ($results as $r): ?>
        <tr>
            <td><code><?= htmlspecialchars($r['dir']) ?></code></td>
            <td>
                <?php if ($r['status']==='created'): ?>
                    <span class="badge bg-success">Created</span>
                <?php elseif ($r['status']==='exists'): ?>
                    <span class="badge bg-secondary">Already Exists</span>
                <?php else: ?>
                    <span class="badge bg-danger">Failed</span>
                <?php endif; ?>
            </td>
        </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
    <p class="text-muted small mt-3">You can delete this file after setup is complete.</p>
    <a href="index.php" class="btn btn-dark btn-sm">Go to Site</a>
    <a href="admin/" class="btn btn-outline-dark btn-sm ms-2">Go to Admin</a>
</div>
</body>
</html>
