xgit simple git

nexus

nexus

clone git clone https://kb.hax.al/nexus

includes/bootstrap.php


1<?php
2define('NEXUS', true);
3 
4require_once __DIR__ . '/config.php';
5require_once __DIR__ . '/db.php';
6require_once __DIR__ . '/functions.php';
7 
8start_session();
9 
10// Redirect to installer if not installed
11if (!file_exists(DATA . '/installed.lock')) {
12    $uri = $_SERVER['REQUEST_URI'] ?? '';
13    if (strpos($uri, '/install') === false) {
14        header('Location: ' . BASE . '/install/');
15        exit;
16    }
17}
18 
19// Auto-migrate: ensure all tables exist for upgraded installs.
20// CREATE TABLE IF NOT EXISTS is idempotent — safe to run on every request.
21// This fixes "table not found" errors when upgrading from older versions.
22static $_dbInited = false;
23if (!$_dbInited) {
24    try {
25        DB::init();
26        $_dbInited = true;
27    } catch (Throwable $e) {
28        // Log but don't crash — if DB is unreachable the next query will fail with a clearer error
29        error_log('Nexus DB::init() failed: ' . $e->getMessage());
30    }
31}
32 
33require_once __DIR__ . '/markdown.php';
34require_once __DIR__ . '/addons.php';
35 
36// Set global current user
37$USER = current_user();
38 
39// Boot addons after user is set
40AddonManager::boot();