includes/startup.php
<?php
declare(strict_types=1);
/*
|--------------------------------------------------------------------------
| Dashboard startup sequence
|--------------------------------------------------------------------------
|
| Included once at the top of index.php, before any dashboard page is
| rendered. Order matters: install check, then auth, then maintenance —
| each step can exit early, so nothing below it runs on a fresh/broken
| install or for an unauthenticated visitor.
|
*/
/*
|--------------------------------------------------------------------------
| Installation wizard
|--------------------------------------------------------------------------
*/
if (brivaciaNeedsInstall()) {
require __DIR__ . '/modules/wizard.php';
exit;
}
if (brivacia_installation_key_missing()) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
echo t('install.key.missing') . "\n";
echo t('install.key.restore') . "\n";
echo t('install.key.backup') . "\n";
echo t('install.key.warning') . "\n";
exit;
}
/*
|--------------------------------------------------------------------------
| Administrator authentication
|--------------------------------------------------------------------------
*/
require_once __DIR__ . '/modules/auth.php';
$authError = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$authError = brivaciaHandleAuthPost();
}
brivaciaRequireAuth($authError);
/*
|--------------------------------------------------------------------------
| Maintenance tasks
|--------------------------------------------------------------------------
*/
require_once __DIR__ . '/archive.php';
$archiveDb = brivaciaDb();
if (brivaciaShouldCheckYearArchive($archiveDb)) {
archiveClosedYears($archiveDb);
}