186 lines
10 KiB
PHP
186 lines
10 KiB
PHP
<?php
|
|
$pageTitle = 'Installer';
|
|
$step = (int)($step ?? 1);
|
|
$values = is_array($values ?? null) ? $values : [];
|
|
$smtpResult = is_array($smtp_result ?? null) ? $smtp_result : [];
|
|
$checks = is_array($checks ?? null) ? $checks : [];
|
|
|
|
$val = static function (string $key, string $default = '') use ($values): string {
|
|
return (string)($values[$key] ?? $default);
|
|
};
|
|
|
|
ob_start();
|
|
?>
|
|
<section class="card" style="max-width:980px; margin:0 auto;">
|
|
<div class="badge">Setup</div>
|
|
<h1 style="margin:16px 0 6px; font-size:30px;">AudioCore V1.5 Installer</h1>
|
|
<p style="margin:0; color:rgba(235,241,255,.75);">Deploy a fresh instance with validated SMTP and baseline health checks.</p>
|
|
|
|
<div style="display:flex; gap:10px; margin-top:18px; flex-wrap:wrap;">
|
|
<div style="padding:8px 12px; border-radius:999px; border:1px solid rgba(255,255,255,.16); background:<?= $step === 1 ? 'rgba(57,244,179,.18)' : 'rgba(255,255,255,.03)' ?>;">
|
|
<span style="font-size:11px; letter-spacing:.18em; text-transform:uppercase;">1. Core Setup</span>
|
|
</div>
|
|
<div style="padding:8px 12px; border-radius:999px; border:1px solid rgba(255,255,255,.16); background:<?= $step === 2 ? 'rgba(57,244,179,.18)' : 'rgba(255,255,255,.03)' ?>;">
|
|
<span style="font-size:11px; letter-spacing:.18em; text-transform:uppercase;">2. Site + SMTP</span>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (!empty($error)): ?>
|
|
<div style="margin-top:16px; border:1px solid rgba(255,124,124,.45); background:rgba(180,40,40,.18); border-radius:12px; padding:12px 14px; color:#ffd6d6;">
|
|
<?= htmlspecialchars((string)$error, ENT_QUOTES, 'UTF-8') ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($success)): ?>
|
|
<div style="margin-top:16px; border:1px solid rgba(57,244,179,.45); background:rgba(10,90,60,.22); border-radius:12px; padding:12px 14px; color:#b8ffe5;">
|
|
<?= htmlspecialchars((string)$success, ENT_QUOTES, 'UTF-8') ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($step === 1): ?>
|
|
<form method="post" action="/admin/install" style="margin-top:18px; display:grid; gap:14px;">
|
|
<input type="hidden" name="installer_action" value="setup_core">
|
|
<div style="display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px;">
|
|
<div>
|
|
<label>DB Host *</label>
|
|
<input class="input" name="db_host" value="<?= htmlspecialchars($val('db_host', 'localhost'), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>DB Port *</label>
|
|
<input class="input" name="db_port" value="<?= htmlspecialchars($val('db_port', '3306'), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>DB Name *</label>
|
|
<input class="input" name="db_name" value="<?= htmlspecialchars($val('db_name', ''), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>DB User *</label>
|
|
<input class="input" name="db_user" value="<?= htmlspecialchars($val('db_user', ''), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div style="grid-column:1/-1;">
|
|
<label>DB Password</label>
|
|
<input class="input" type="password" name="db_pass" value="">
|
|
</div>
|
|
</div>
|
|
|
|
<div style="margin-top:6px; padding-top:14px; border-top:1px solid rgba(255,255,255,.1); display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px;">
|
|
<div>
|
|
<label>Admin Name *</label>
|
|
<input class="input" name="admin_name" value="<?= htmlspecialchars($val('admin_name', 'Admin'), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>Admin Email *</label>
|
|
<input class="input" type="email" name="admin_email" value="<?= htmlspecialchars($val('admin_email', ''), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>Admin Password *</label>
|
|
<input class="input" type="password" name="admin_password" value="" placeholder="Minimum 8 characters">
|
|
</div>
|
|
</div>
|
|
|
|
<div style="display:flex; justify-content:flex-end; margin-top:4px;">
|
|
<button type="submit" class="button button-primary">Create Core Setup</button>
|
|
</div>
|
|
</form>
|
|
<?php else: ?>
|
|
<form method="post" action="/admin/install" style="margin-top:18px; display:grid; gap:14px;">
|
|
<div style="display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px;">
|
|
<div>
|
|
<label>Site Title *</label>
|
|
<input class="input" name="site_title" value="<?= htmlspecialchars($val('site_title', 'AudioCore V1.5'), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>Site Tagline</label>
|
|
<input class="input" name="site_tagline" value="<?= htmlspecialchars($val('site_tagline', 'Core CMS for DJs & Producers'), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>SEO Title Suffix</label>
|
|
<input class="input" name="seo_title_suffix" value="<?= htmlspecialchars($val('seo_title_suffix', 'AudioCore V1.5'), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div style="grid-column:1/-1;">
|
|
<label>SEO Meta Description</label>
|
|
<textarea class="input" name="seo_meta_description" rows="3" style="resize:vertical;"><?= htmlspecialchars($val('seo_meta_description', ''), ENT_QUOTES, 'UTF-8') ?></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="padding-top:12px; border-top:1px solid rgba(255,255,255,.1); display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px;">
|
|
<div>
|
|
<label>SMTP Host *</label>
|
|
<input class="input" name="smtp_host" value="<?= htmlspecialchars($val('smtp_host', ''), ENT_QUOTES, 'UTF-8') ?>" placeholder="smtp.example.com">
|
|
</div>
|
|
<div>
|
|
<label>SMTP Port *</label>
|
|
<input class="input" name="smtp_port" value="<?= htmlspecialchars($val('smtp_port', '587'), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>SMTP User</label>
|
|
<input class="input" name="smtp_user" value="<?= htmlspecialchars($val('smtp_user', ''), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>SMTP Password</label>
|
|
<input class="input" type="password" name="smtp_pass" value="<?= htmlspecialchars($val('smtp_pass', ''), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>SMTP Encryption</label>
|
|
<input class="input" name="smtp_encryption" value="<?= htmlspecialchars($val('smtp_encryption', 'tls'), ENT_QUOTES, 'UTF-8') ?>" placeholder="tls or ssl">
|
|
</div>
|
|
<div>
|
|
<label>SMTP From Email *</label>
|
|
<input class="input" type="email" name="smtp_from_email" value="<?= htmlspecialchars($val('smtp_from_email', ''), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>SMTP From Name</label>
|
|
<input class="input" name="smtp_from_name" value="<?= htmlspecialchars($val('smtp_from_name', 'AudioCore V1.5'), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
<div>
|
|
<label>Test Recipient Email *</label>
|
|
<input class="input" type="email" name="smtp_test_email" value="<?= htmlspecialchars($val('smtp_test_email', ''), ENT_QUOTES, 'UTF-8') ?>">
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (!empty($smtpResult)): ?>
|
|
<div style="border:1px solid <?= !empty($smtpResult['ok']) ? 'rgba(57,244,179,.45)' : 'rgba(255,124,124,.45)' ?>; background:<?= !empty($smtpResult['ok']) ? 'rgba(10,90,60,.22)' : 'rgba(180,40,40,.18)' ?>; border-radius:12px; padding:12px 14px;">
|
|
<div style="font-weight:700; margin-bottom:4px; color:<?= !empty($smtpResult['ok']) ? '#b8ffe5' : '#ffd6d6' ?>">
|
|
<?= !empty($smtpResult['ok']) ? 'SMTP test passed' : 'SMTP test failed' ?>
|
|
</div>
|
|
<div style="color:<?= !empty($smtpResult['ok']) ? '#b8ffe5' : '#ffd6d6' ?>;">
|
|
<?= htmlspecialchars((string)($smtpResult['message'] ?? ''), ENT_QUOTES, 'UTF-8') ?>
|
|
</div>
|
|
<?php if (!empty($smtpResult['debug'])): ?>
|
|
<details style="margin-top:8px;">
|
|
<summary style="cursor:pointer;">Debug output</summary>
|
|
<pre style="white-space:pre-wrap; margin-top:8px; font-size:12px; color:#cfd6f5;"><?= htmlspecialchars((string)$smtpResult['debug'], ENT_QUOTES, 'UTF-8') ?></pre>
|
|
</details>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($checks)): ?>
|
|
<div style="padding:12px; border:1px solid rgba(255,255,255,.1); border-radius:12px; background:rgba(255,255,255,.02);">
|
|
<div style="font-size:12px; text-transform:uppercase; letter-spacing:.16em; color:rgba(255,255,255,.65); margin-bottom:10px;">Installer Health Checks</div>
|
|
<div style="display:grid; gap:8px;">
|
|
<?php foreach ($checks as $check): ?>
|
|
<div style="display:flex; gap:10px; align-items:flex-start;">
|
|
<span style="display:inline-flex; align-items:center; justify-content:center; width:18px; height:18px; border-radius:999px; font-size:12px; margin-top:2px; background:<?= !empty($check['ok']) ? 'rgba(57,244,179,.2)' : 'rgba(255,124,124,.2)' ?>; color:<?= !empty($check['ok']) ? '#9ff8d8' : '#ffb7b7' ?>;">
|
|
<?= !empty($check['ok']) ? '✓' : '!' ?>
|
|
</span>
|
|
<div>
|
|
<div style="font-weight:600;"><?= htmlspecialchars((string)($check['label'] ?? ''), ENT_QUOTES, 'UTF-8') ?></div>
|
|
<div style="color:rgba(235,241,255,.65); font-size:13px;"><?= htmlspecialchars((string)($check['detail'] ?? ''), ENT_QUOTES, 'UTF-8') ?></div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div style="display:flex; justify-content:flex-end; gap:10px; flex-wrap:wrap; margin-top:4px;">
|
|
<button type="submit" name="installer_action" value="test_smtp" class="button">Send Test Email + Run Checks</button>
|
|
<button type="submit" name="installer_action" value="finish_install" class="button button-primary">Finish Installation</button>
|
|
</div>
|
|
</form>
|
|
<?php endif; ?>
|
|
</section>
|
|
<?php
|
|
$content = ob_get_clean();
|
|
require __DIR__ . '/../../../views/site/layout.php';
|