'', 'site_tagline' => '', 'language' => 'en', 'base_url' => '', 'admin_username' => '', ]; // Determine language early so t() renders in the chosen language throughout. $values['language'] = trim($_POST['language'] ?? $_GET['lang'] ?? 'en'); lang_init($values['language']); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $values['site_title'] = trim($_POST['site_title'] ?? ''); $values['site_tagline'] = trim($_POST['site_tagline'] ?? ''); $values['language'] = trim($_POST['language'] ?? 'en'); $values['base_url'] = trim($_POST['base_url'] ?? ''); $values['admin_username'] = trim($_POST['admin_username'] ?? ''); $password = $_POST['password'] ?? ''; $confirm = $_POST['confirm_password'] ?? ''; if ($values['site_title'] === '') { $errors[] = t('setup.error_title'); } if ($values['admin_username'] === '') { $errors[] = t('setup.error_username'); } if ($password === '' || $confirm === '') { $errors[] = t('setup.error_password'); } elseif ($password !== $confirm) { $errors[] = t('setup.error_mismatch'); } if (!$errors) { $config = default_config(); $config['site_title'] = $values['site_title']; $config['site_tagline'] = $values['site_tagline']; $config['language'] = $values['language'] !== '' ? $values['language'] : 'en'; $config['base_url'] = $values['base_url'] !== '' ? $values['base_url'] : get_base_url(); $config['admin_username'] = $values['admin_username']; $config['admin_password_hash'] = password_hash($password, PASSWORD_DEFAULT); $configDir = dirname(PUREBLOG_CONFIG_PATH); if (!is_dir($configDir) && !mkdir($configDir, 0755, true)) { $errors[] = t('setup.error_config_dir'); } elseif (save_config($config)) { header('Location: ' . base_path() . '/admin/index.php?setup=1', true, 303); exit; } if (!$errors) { $errors[] = t('setup.error_config_write'); } } } $adminTitle = t('setup.page_title'); $fontStack = font_stack_css($config['theme']['admin_font_stack'] ?? 'sans'); $hideAdminNav = true; require __DIR__ . '/includes/admin-head.php'; ?>