SIMON Master Console Rebuild
True command center for SIMON + WEB360
This rebuild gives you a cleaner production spine: interactive tree, live viewer, guarded editor, dynamic graphics, architecture map, and note storage. It is designed to sit beside your existing
console.php
and become the stronger replacement path.
Dashboard
Tree
Viewer
System Map
File Registry
Notes
Files
15,645
Folders
433
Scanned Size
3.88 GB
PHP Files
988
Editable Text Files
12,903
File viewer
guarded to /htdocs
/infinity/_infinity_private/runtime.php
<?php declare(strict_types=1); const INFINITY_PRIVATE_DIR = __DIR__; const INFINITY_DB_FILE = INFINITY_PRIVATE_DIR . '/infinity.sqlite'; const INFINITY_UPLOAD_DIR = INFINITY_PRIVATE_DIR . '/uploads'; const INFINITY_MAX_UPLOAD = 150_000_000; if (basename((string)($_SERVER['SCRIPT_FILENAME'] ?? '')) === basename(__FILE__)) { http_response_code(403); exit('Forbidden'); } if (!is_dir(INFINITY_PRIVATE_DIR)) { throw new RuntimeException('Infinity private directory is missing.'); } if (!is_dir(INFINITY_UPLOAD_DIR) && !mkdir(INFINITY_UPLOAD_DIR, 0700, true) && !is_dir(INFINITY_UPLOAD_DIR)) { throw new RuntimeException('Unable to create Infinity upload storage.'); } ini_set('session.use_strict_mode', '1'); ini_set('session.cookie_httponly', '1'); ini_set('session.cookie_samesite', 'Lax'); if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (int)($_SERVER['SERVER_PORT'] ?? 0) === 443) { ini_set('session.cookie_secure', '1'); } if (session_status() !== PHP_SESSION_ACTIVE) { session_name('INFINITYSESSID'); session_start(); } header('X-Content-Type-Options: nosniff'); header('Referrer-Policy: strict-origin-when-cross-origin'); header('X-Frame-Options: SAMEORIGIN'); function inf_e(string $value): string { return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } function inf_db(): PDO { static $db = null; if ($db instanceof PDO) { return $db; } if (!extension_loaded('pdo_sqlite')) { throw new RuntimeException('PDO SQLite is not enabled.'); } $db = new PDO('sqlite:' . INFINITY_DB_FILE, null, null, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]); $db->exec('PRAGMA journal_mode=WAL'); $db->exec('PRAGMA foreign_keys=ON'); inf_migrate($db); return $db; } function inf_migrate(PDO $db): void { $db->exec( 'CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY AUTOINCREMENT, display_name TEXT NOT NULL, email TEXT NOT NULL UNIQUE COLLATE NOCASE, password_hash TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, last_login_at TEXT )' ); $db->exec( 'CREATE TABLE IF NOT EXISTS profiles ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, name TEXT NOT NULL, profile_type TEXT NOT NULL DEFAULT "living", relationship TEXT NOT NULL DEFAULT "", about TEXT NOT NULL DEFAULT "", birth_date TEXT, memorial_date TEXT, privacy TEXT NOT NULL DEFAULT "private", publication_status TEXT NOT NULL DEFAULT "draft", avatar_media_id INTEGER, cover_media_id INTEGER, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE )' ); $db->exec( 'CREATE TABLE IF NOT EXISTS media ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, profile_id INTEGER NOT NULL, media_kind TEXT NOT NULL, original_name TEXT NOT NULL, storage_name TEXT NOT NULL, mime_type TEXT NOT NULL, size_bytes INTEGER NOT NULL, caption TEXT NOT NULL DEFAULT "", created_at TEXT NOT NULL, FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE )' ); $db->exec( 'CREATE TABLE IF NOT EXISTS living_entries ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, profile_id INTEGER NOT NULL, entry_date TEXT NOT NULL, title TEXT NOT NULL, body TEXT NOT NULL, created_at TEXT NOT NULL, FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE )' ); $db->exec( 'CREATE TABLE IF NOT EXISTS family_circles ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, profile_id INTEGER, name TEXT NOT NULL, description TEXT NOT NULL DEFAULT "", created_at TEXT NOT NULL, FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE SET NULL )' ); $db->exec( 'CREATE TABLE IF NOT EXISTS grave_records ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, profile_id INTEGER NOT NULL, cemetery_name TEXT NOT NULL DEFAULT "", section_name TEXT NOT NULL DEFAULT "", lot TEXT NOT NULL DEFAULT "", plot TEXT NOT NULL DEFAULT "", latitude REAL, longitude REAL, verification_status TEXT NOT NULL DEFAULT "unverified", notes TEXT NOT NULL DEFAULT "", created_at TEXT NOT NULL, updated_at TEXT NOT NULL, FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE )' ); $db->exec( 'CREATE TABLE IF NOT EXISTS visits ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, profile_id INTEGER NOT NULL, visited_at TEXT NOT NULL, note TEXT NOT NULL DEFAULT "", flowers_left TEXT NOT NULL DEFAULT "", condition_note TEXT NOT NULL DEFAULT "", privacy TEXT NOT NULL DEFAULT "private", created_at TEXT NOT NULL, FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE )' ); $db->exec( 'CREATE TABLE IF NOT EXISTS tributes ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, profile_id INTEGER NOT NULL, tribute_text TEXT NOT NULL, visibility TEXT NOT NULL DEFAULT "family", created_at TEXT NOT NULL, FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE )' ); } function inf_user_id(): int { return (int)($_SESSION['infinity_user_id'] ?? 0); } function inf_require_login(): int { $id = inf_user_id(); if ($id < 1) { header('Location: /infinity/login.php?notice=' . rawurlencode('Log in to open My Infinity.'), true, 302); exit; } return $id; } function inf_csrf(): string { if (empty($_SESSION['infinity_csrf'])) { $_SESSION['infinity_csrf'] = bin2hex(random_bytes(32)); } return (string)$_SESSION['infinity_csrf']; } function inf_csrf_ok(): bool { $posted = (string)($_POST['csrf'] ?? ''); return $posted !== '' && hash_equals(inf_csrf(), $posted); } function inf_redirect(string $tab, string $notice = '', string $error = ''): never { $params = ['tab' => $tab]; if ($notice !== '') $params['notice'] = $notice; if ($error !== '') $params['error'] = $error; header('Location: /infinity/dashboard.php?' . http_build_query($params), true, 303); exit; } function inf_profiles(PDO $db, int $userId): array { $stmt = $db->prepare( 'SELECT p.*, (SELECT COUNT(*) FROM media m WHERE m.profile_id = p.id) AS media_count FROM profiles p WHERE p.user_id = :user_id ORDER BY p.updated_at DESC, p.id DESC' ); $stmt->execute(['user_id' => $userId]); return $stmt->fetchAll(); } function inf_owned_profile(PDO $db, int $userId, int $profileId): ?array { $stmt = $db->prepare('SELECT * FROM profiles WHERE id = :id AND user_id = :user_id LIMIT 1'); $stmt->execute(['id' => $profileId, 'user_id' => $userId]); $row = $stmt->fetch(); return $row ?: null; } function inf_auto_profile(PDO $db, int $userId): int { $stmt = $db->prepare('SELECT id FROM profiles WHERE user_id = :user_id ORDER BY id LIMIT 1'); $stmt->execute(['user_id' => $userId]); $found = $stmt->fetchColumn(); if ($found) return (int)$found; $user = $db->prepare('SELECT display_name FROM users WHERE id = :id LIMIT 1'); $user->execute(['id' => $userId]); $name = trim((string)$user->fetchColumn()); if ($name === '') $name = 'My Infinity Profile'; $now = gmdate('c'); $insert = $db->prepare( 'INSERT INTO profiles (user_id, name, profile_type, relationship, about, privacy, publication_status, created_at, updated_at) VALUES (:user_id, :name, "living", "Self", "", "private", "draft", :created_at, :updated_at)' ); $insert->execute([ 'user_id' => $userId, 'name' => $name, 'created_at' => $now, 'updated_at' => $now, ]); return (int)$db->lastInsertId(); }
Save file
Quick jump
open a path
Open