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,275
Folders
405
Scanned Size
3.84 GB
PHP Files
870
Editable Text Files
12,538
File viewer
guarded to /htdocs
/admin/admin_common.php
<?php declare(strict_types=1); session_start(); const SIMON_APP_NAME = 'SIMON Intelligence Admin Suite'; const SIMON_APP_VERSION = '1.0.0'; const SIMON_DEFAULT_PASSWORD = 'KEITH@1'; const SIMON_ROOT_PATH = __DIR__ . '/'; const SIMON_DATA_DIR = __DIR__ . '/data'; const SIMON_REGISTRY_FILE = __DIR__ . '/data/dashboard_registry.json'; const SIMON_AUDIT_FILE = __DIR__ . '/data/dashboard_audit.log'; if (!is_dir(SIMON_DATA_DIR)) { @mkdir(SIMON_DATA_DIR, 0775, true); } function simon_e(string $value): string { return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } function simon_password(): string { return getenv('SIMON_DASHBOARD_PASSWORD') ?: SIMON_DEFAULT_PASSWORD; } function simon_base_url(): string { $https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || ((int)($_SERVER['SERVER_PORT'] ?? 0) === 443); $scheme = $https ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST'] ?? 'localhost'; $basePath = rtrim(str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'] ?? '/')), '/'); return $scheme . '://' . $host . ($basePath === '' ? '' : $basePath); } function simon_default_registry(): array { return [ 'company' => [ 'name' => 'Gaylord Sinclair Publishing LLC', 'mission' => 'Publishing, software, AI systems, investor-grade project intelligence, and digital products.', 'investor_notes' => 'Centralized visibility across projects, files, costs, revenue, risk, and roadmap.', 'monthly_sales' => 0, 'monthly_revenue' => 0, 'monthly_bills' => 0, 'cash_on_hand' => 0, 'debt_total' => 0, 'projected_value' => 0, ], 'financials' => [ 'bills' => [ ['name' => 'Hosting', 'amount' => 65, 'frequency' => 'monthly', 'status' => 'active', 'due_day' => 1], ['name' => 'Domains', 'amount' => 120, 'frequency' => 'annual', 'status' => 'active', 'due_day' => 15], ['name' => 'AI / API', 'amount' => 100, 'frequency' => 'monthly', 'status' => 'active', 'due_day' => 5], ], 'sales_channels' => [ ['name' => 'Books', 'amount' => 300, 'status' => 'active'], ['name' => 'Art', 'amount' => 150, 'status' => 'active'], ['name' => 'Software', 'amount' => 0, 'status' => 'planned'], ], ], 'modules' => [ '/admin/' => [ 'title' => 'Admin Suite', 'description' => 'Private operations and visibility center.', 'category' => 'Operations', 'phase' => 'Critical', 'status' => 'Active', 'completion' => 55, 'current_future' => 'current', 'value' => 40000, 'revenue' => 0, 'cost' => 0, 'what' => 'Administrative control layer', 'why' => 'Manage operations, security, and reporting', 'who' => 'Owner and future team', 'when' => 'Now', 'where' => '/admin/', 'how' => 'PHP dashboards, JSON registry, auth, and reporting', ], '/simon/' => [ 'title' => 'SIMON Intelligence', 'description' => 'Routing, memory, dashboards, and AI orchestration.', 'category' => 'AI / Intelligence', 'phase' => 'Core Build', 'status' => 'Active', 'completion' => 62, 'current_future' => 'current', 'value' => 125000, 'revenue' => 0, 'cost' => 250, 'what' => 'Decision and intelligence layer', 'why' => 'Coordinate systems and provide analysis', 'who' => 'Admin, company, future users', 'when' => 'Current', 'where' => '/simon/', 'how' => 'PHP logic, AI APIs, memory, 5W1H analysis', ], '/web360/' => [ 'title' => 'WEB360 Studio', 'description' => 'Website builder and editor platform.', 'category' => 'Software', 'phase' => 'Prototype / Expansion', 'status' => 'Active', 'completion' => 58, 'current_future' => 'current', 'value' => 180000, 'revenue' => 0, 'cost' => 400, 'what' => 'Builder platform', 'why' => 'Create websites faster', 'who' => 'Owner, developers, future clients', 'when' => 'In development', 'where' => '/web360/', 'how' => 'Xcode app + PHP web layer + AI providers', ], '/books/' => [ 'title' => 'Books', 'description' => 'Publishing catalog and sales.', 'category' => 'Publishing', 'phase' => 'Growth', 'status' => 'Active', 'completion' => 72, 'current_future' => 'current', 'value' => 30000, 'revenue' => 300, 'cost' => 40, 'what' => 'Book catalog', 'why' => 'Sales and credibility', 'who' => 'Readers, customers', 'when' => 'Current', 'where' => '/books/', 'how' => 'Catalog pages, product detail, SEO', ], ], 'notes' => [ 'blueprint' => 'Build command center first, then investor/accounting/security drilldowns, then database-backed workflow and automation.', 'investor_summary' => 'Key value drivers: WEB360, SIMON Intelligence, book catalog, art/comics, and digital products.', ], ]; } function simon_load_registry(): array { if (!is_file(SIMON_REGISTRY_FILE)) { $default = simon_default_registry(); file_put_contents(SIMON_REGISTRY_FILE, json_encode($default, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); return $default; } $data = json_decode((string) file_get_contents(SIMON_REGISTRY_FILE), true); return is_array($data) ? $data : simon_default_registry(); } function simon_save_registry(array $data): bool { return (bool) file_put_contents(SIMON_REGISTRY_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } function simon_write_audit(string $message): void { $line = '[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL; @file_put_contents(SIMON_AUDIT_FILE, $line, FILE_APPEND); } function simon_csrf_token(): string { if (empty($_SESSION['simon_csrf'])) { $_SESSION['simon_csrf'] = bin2hex(random_bytes(16)); } return $_SESSION['simon_csrf']; } function simon_verify_csrf(): bool { return isset($_POST['csrf_token'], $_SESSION['simon_csrf']) && hash_equals($_SESSION['simon_csrf'], (string) $_POST['csrf_token']); } function simon_is_logged_in(): bool { return !empty($_SESSION['simon_auth']); } function simon_require_login(): void { if (!simon_is_logged_in()) { header('Location: login.php'); exit; } } function simon_handle_auth(): void { if (isset($_GET['logout'])) { $_SESSION = []; session_destroy(); header('Location: login.php'); exit; } } function simon_login_attempt(string $password): bool { if (hash_equals(simon_password(), $password)) { $_SESSION['simon_auth'] = true; session_regenerate_id(true); simon_write_audit('Login successful from ' . ($_SERVER['REMOTE_ADDR'] ?? 'unknown')); return true; } return false; } function simon_rel_path(string $path): string { $path = str_replace('\\', '/', $path); $root = rtrim(str_replace('\\', '/', realpath(SIMON_ROOT_PATH) ?: SIMON_ROOT_PATH), '/'); $real = str_replace('\\', '/', realpath($path) ?: $path); $rel = str_replace($root, '', $real); return $rel === '' ? '/' : $rel; } function simon_scan_tree(array $ignore = []): array { $results = []; $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator(SIMON_ROOT_PATH, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($iterator as $item) { $rel = simon_rel_path($item->getPathname()); foreach ($ignore as $skip) { if (str_contains($rel, $skip)) { continue 2; } } $results[] = [ 'path' => $rel, 'name' => $item->getFilename(), 'type' => $item->isDir() ? 'dir' : 'file', 'size' => $item->isFile() ? (int) $item->getSize() : 0, 'modified' => (int) $item->getMTime(), 'extension' => $item->isFile() ? strtolower(pathinfo($item->getFilename(), PATHINFO_EXTENSION)) : '', 'readable' => is_readable($item->getPathname()), 'writable' => is_writable($item->getPathname()), ]; } usort($results, fn($a, $b) => strcmp($a['path'], $b['path'])); return $results; } function simon_group_files(array $files): array { $groups = []; foreach ($files as $item) { $path = trim((string) $item['path'], '/'); $parts = $path === '' ? [] : explode('/', $path); $key = empty($parts) ? '/' : '/' . $parts[0] . '/'; $groups[$key][] = $item; } ksort($groups); return $groups; } function simon_detect_special_files(): array { $checks = [ '.htaccess' => SIMON_ROOT_PATH . '.htaccess', 'robots.txt' => SIMON_ROOT_PATH . 'robots.txt', 'sitemap.xml' => SIMON_ROOT_PATH . 'sitemap.xml', 'security.txt' => SIMON_ROOT_PATH . '.well-known/security.txt', 'site.webmanifest' => SIMON_ROOT_PATH . 'site.webmanifest', 'browserconfig.xml' => SIMON_ROOT_PATH . 'browserconfig.xml', 'admin/.htaccess' => SIMON_ROOT_PATH . 'admin/.htaccess', 'data/.htaccess' => SIMON_ROOT_PATH . 'data/.htaccess', ]; $out = []; foreach ($checks as $label => $path) { $out[] = [ 'label' => $label, 'exists' => file_exists($path), 'path' => simon_rel_path($path), ]; } return $out; } function simon_security_checks(): array { $https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || ((int)($_SERVER['SERVER_PORT'] ?? 0) === 443); return [ ['name' => 'HTTPS', 'status' => $https, 'details' => $https ? 'Secure request detected.' : 'HTTPS not detected on current request.'], ['name' => 'Root .htaccess', 'status' => file_exists(SIMON_ROOT_PATH . '.htaccess'), 'details' => 'Rewrite rules and security headers.'], ['name' => 'robots.txt', 'status' => file_exists(SIMON_ROOT_PATH . 'robots.txt'), 'details' => 'Crawler guidance present.'], ['name' => 'sitemap.xml', 'status' => file_exists(SIMON_ROOT_PATH . 'sitemap.xml'), 'details' => 'Search sitemap present.'], ['name' => 'Audit log', 'status' => file_exists(SIMON_AUDIT_FILE), 'details' => 'Edit/login logging.'], ['name' => 'Registry storage', 'status' => file_exists(SIMON_REGISTRY_FILE), 'details' => 'JSON registry present.'], ['name' => 'Session auth', 'status' => true, 'details' => 'This suite uses PHP session-based auth.'], ['name' => 'CSRF protection', 'status' => true, 'details' => 'Post forms protected by token.'], ]; } function simon_totals(array $registry): array { $monthlyBills = 0.0; foreach (($registry['financials']['bills'] ?? []) as $bill) { $amount = (float) ($bill['amount'] ?? 0); $frequency = strtolower((string) ($bill['frequency'] ?? 'monthly')); if ($frequency === 'annual') { $monthlyBills += $amount / 12; } elseif ($frequency === 'weekly') { $monthlyBills += $amount * 4.33; } else { $monthlyBills += $amount; } } $salesTotal = 0.0; foreach (($registry['financials']['sales_channels'] ?? []) as $channel) { $salesTotal += (float) ($channel['amount'] ?? 0); } $value = 0.0; $revenue = 0.0; $cost = 0.0; $completion = 0.0; $count = max(1, count($registry['modules'] ?? [])); foreach (($registry['modules'] ?? []) as $module) { $value += (float) ($module['value'] ?? 0); $revenue += (float) ($module['revenue'] ?? 0); $cost += (float) ($module['cost'] ?? 0); $completion += (float) ($module['completion'] ?? 0); } return [ 'monthly_bills' => $monthlyBills, 'sales_total' => $salesTotal, 'module_value' => $value, 'module_revenue' => $revenue, 'module_cost' => $cost, 'avg_completion' => $completion / $count, 'runway_months' => $monthlyBills > 0 ? ((float)($registry['company']['cash_on_hand'] ?? 0) / $monthlyBills) : 0, ]; } function simon_ai_review(array $registry, array $files, array $security): array { $totals = simon_totals($registry); $warnings = []; $wins = []; $next = []; if ($totals['module_value'] >= 100000) { $wins[] = 'Portfolio value narrative is strong enough for investor-facing storytelling.'; } if ($totals['avg_completion'] >= 50) { $wins[] = 'The suite reflects an operating ecosystem, not just concept-stage assets.'; } else { $warnings[] = 'Average completion is below 50%; finish core modules before broad expansion.'; } if ($totals['monthly_bills'] > $totals['sales_total']) { $warnings[] = 'Current sales do not fully cover normalized monthly bills.'; } if (count(array_filter($security, fn($c) => empty($c['status']))) > 0) { $warnings[] = 'Security baseline has missing or unverified items.'; } if (count($files) >= 25) { $wins[] = 'File footprint is large enough to justify centralized registry, audit, and risk review.'; } $next[] = 'Split investor, accounting, sales, security, file registry, and AI review into dedicated pages.'; $next[] = 'Move JSON data into MySQL when edits become frequent or multi-user.'; $next[] = 'Add backup status, integrity checks, role permissions, and finance ledgers.'; $next[] = 'Track due dates, blockers, risk, and dependencies for every module.'; return [ 'headline' => 'SIMON review: the ecosystem has real strategic potential, but the next gains come from operational discipline, stronger security posture, and tighter monetization tracking.', 'wins' => $wins, 'warnings' => $warnings, 'next' => $next, ]; } function simon_bytes(int $bytes): string { $units = ['B', 'KB', 'MB', 'GB', 'TB']; $size = (float) $bytes; $i = 0; while ($size >= 1024 && $i < count($units) - 1) { $size /= 1024; $i++; } return number_format($size, $i === 0 ? 0 : 2) . ' ' . $units[$i]; } function simon_phase_class(string $phase): string { $phase = strtolower($phase); return match (true) { str_contains($phase, 'active') => 'green', str_contains($phase, 'growth') => 'blue', str_contains($phase, 'core') => 'cyan', str_contains($phase, 'prototype') => 'amber', str_contains($phase, 'planned') => 'slate', str_contains($phase, 'critical') => 'purple', default => 'slate', }; } function simon_suite_nav(string $current = ''): array { return [ 'dashboard.php' => 'Dashboard', 'investor_relations.php' => 'Investor Relations', 'accounting.php' => 'Accounting', 'sales.php' => 'Sales', 'security.php' => 'Security', 'file_registry.php' => 'File Registry', 'ai_review.php' => 'AI Review', ]; } function simon_render_header(string $title, string $current = ''): void { $nav = simon_suite_nav($current); $csrf = simon_csrf_token(); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"> <title><?= simon_e($title) ?></title> <meta name="robots" content="noindex,nofollow"> <style> :root{--bg:#07111a;--bg2:#0c1624;--panel:rgba(16,25,40,.82);--line:rgba(138,178,255,.14);--text:#e7f0ff;--muted:#9cb0d0;--cyan:#6ee7ff;--blue:#6da8ff;--purple:#a78bfa;--green:#34d399;--amber:#fbbf24;--red:#fb7185;--radius:18px;--shadow:0 16px 50px rgba(0,0,0,.35)} *{box-sizing:border-box}html,body{margin:0;padding:0;background:radial-gradient(circle at top right, rgba(109,168,255,.14), transparent 28%),radial-gradient(circle at top left, rgba(167,139,250,.12), transparent 24%),linear-gradient(180deg,var(--bg),var(--bg2));color:var(--text);font-family:Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif} a{color:var(--cyan);text-decoration:none}.wrap{max-width:1540px;margin:0 auto;padding:22px}.hero,.card{background:var(--panel);border:1px solid var(--line);border-radius:22px;box-shadow:var(--shadow)}.hero{padding:24px;margin-bottom:18px;position:relative;overflow:hidden}.hero:before{content:"";position:absolute;inset:-20%;background:radial-gradient(circle, rgba(110,231,255,.08), transparent 20%),radial-gradient(circle at 70% 20%, rgba(167,139,250,.12), transparent 18%);animation:drift 14s linear infinite}@keyframes drift{from{transform:translate3d(0,0,0)}to{transform:translate3d(-5%,2%,0)}}.card{padding:18px}.grid{display:grid;gap:18px}.g-4{grid-template-columns:repeat(4,minmax(0,1fr))}.g-3{grid-template-columns:repeat(3,minmax(0,1fr))}.g-2{grid-template-columns:repeat(2,minmax(0,1fr))}.tabs{display:flex;flex-wrap:wrap;gap:10px}.tab{padding:8px 12px;border-radius:999px;background:rgba(255,255,255,.04);border:1px solid var(--line);font-size:.86rem}.tab.active{background:rgba(110,231,255,.14);color:#fff}.muted{color:var(--muted)}.badge{display:inline-flex;align-items:center;gap:8px;padding:6px 10px;border-radius:999px;border:1px solid var(--line);background:rgba(255,255,255,.04);font-size:.8rem}.green{background:rgba(52,211,153,.13)}.cyan{background:rgba(110,231,255,.13)}.amber{background:rgba(251,191,36,.12)}.purple{background:rgba(167,139,250,.13)}.blue{background:rgba(109,168,255,.13)}.slate{background:rgba(156,176,208,.12)}.danger{background:rgba(251,113,133,.14)}table{width:100%;border-collapse:collapse}th,td{padding:10px 12px;text-align:left;border-top:1px solid var(--line);vertical-align:top}th{color:#cfe0ff;font-size:.88rem}.input,.select,.textarea{width:100%;padding:11px 12px;border-radius:12px;border:1px solid var(--line);background:rgba(255,255,255,.03);color:var(--text)}.textarea{min-height:110px;resize:vertical}.btn{border:1px solid var(--line);background:linear-gradient(180deg,rgba(110,231,255,.15),rgba(109,168,255,.08));color:#fff;padding:10px 14px;border-radius:12px;cursor:pointer;font-weight:700}.btn.secondary{background:rgba(255,255,255,.04)}.stat{padding:18px;border-radius:18px;background:rgba(255,255,255,.03);border:1px solid var(--line)}.n{font-size:1.8rem;font-weight:800}.kpi-label{font-size:.82rem;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.bar{height:10px;border-radius:999px;background:rgba(255,255,255,.08);overflow:hidden}.bar>span{display:block;height:100%;background:linear-gradient(90deg,var(--cyan),var(--blue))}.ok{color:var(--green)}.bad{color:var(--red)}.warn{color:var(--amber)}.notice{padding:12px 14px;border-radius:12px;background:rgba(52,211,153,.12);border:1px solid rgba(52,211,153,.2)}.error{padding:12px 14px;border-radius:12px;background:rgba(251,113,133,.12);border:1px solid rgba(251,113,133,.22)}.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.section-title{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:12px}.tiny{font-size:.82rem}@media (max-width:1200px){.g-4,.g-3{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (max-width:760px){.g-4,.g-3,.g-2{grid-template-columns:1fr}.wrap{padding:14px}} </style> </head> <body> <div class="wrap"> <section class="hero"> <div style="display:flex;justify-content:space-between;gap:16px;align-items:flex-start;flex-wrap:wrap;position:relative;z-index:2;"> <div> <div class="badge cyan">SIMON ADMIN SUITE</div> <h1 style="margin:.6rem 0 .35rem;"><?= simon_e($title) ?></h1> <div class="muted">Centralized investor, accounting, sales, security, file visibility, and AI review.</div> </div> <div class="tabs"> <?php foreach ($nav as $file => $label): ?> <a class="tab <?= $file === $current ? 'active' : '' ?>" href="<?= simon_e($file) ?>"><?= simon_e($label) ?></a> <?php endforeach; ?> <a class="tab" href="?logout=1">Logout</a> </div> </div> </section> <?php } function simon_render_footer(): void { ?> </div> </body> </html> <?php }
Save file
Quick jump
open a path
Open