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,340
Folders
408
Scanned Size
3.84 GB
PHP Files
891
Editable Text Files
12,601
File viewer
guarded to /htdocs
/web360/connlink/normalize.php
<?php /** * /web360/connlink/normalize.php * Implements NR001–NR009 from the workbook. * Output schema (common SIMON feed object): * src, category, title, text, url, image, published (ISO8601), hash, severity? */ declare(strict_types=1); function conn_normalize(string $profile, array $raw): array { switch ($profile) { case 'news_standard': return conn_normalize_newsapi($raw); case 'gdelt_news': return conn_normalize_gdelt($raw); case 'nws_alert': return conn_normalize_nws($raw); case 'fema_declaration': return conn_normalize_fema($raw); case 'usgs_geojson': return conn_normalize_usgs($raw); case 'eonet_event': return conn_normalize_eonet($raw); default: return []; } } /* ---------- NR001 ---------- */ function conn_normalize_newsapi(array $d): array { $out = []; foreach (($d['articles'] ?? []) as $a) { if (empty($a['title'])) continue; $out[] = [ 'src' => $a['source']['name'] ?? 'NewsAPI', 'category' => 'news', 'title' => (string)$a['title'], 'text' => (string)($a['description'] ?? $a['content'] ?? ''), 'url' => (string)($a['url'] ?? ''), 'image' => (string)($a['urlToImage'] ?? ''), 'published' => $a['publishedAt'] ?? null, 'hash' => conn_sha1_short(($a['url'] ?? '') . '|' . ($a['title'] ?? '')), ]; } return $out; } /* ---------- NR002 ---------- */ function conn_normalize_gdelt(array $d): array { $out = []; foreach (($d['articles'] ?? []) as $a) { $out[] = [ 'src' => 'GDELT', 'category' => 'news', 'title' => (string)($a['title'] ?? ''), 'text' => (string)($a['snippet'] ?? ($a['sourcecountry'] ?? '')), 'url' => (string)($a['url'] ?? ''), 'image' => (string)($a['socialimage'] ?? ''), 'published' => conn_iso_from_gdelt((string)($a['seendate'] ?? '')), 'hash' => conn_sha1_short(($a['url'] ?? '') . '|' . ($a['title'] ?? '')), ]; } return $out; } function conn_iso_from_gdelt(string $s): ?string { if (preg_match('/^(\d{4})(\d{2})(\d{2})T?(\d{2})?(\d{2})?(\d{2})?Z?$/', $s, $m)) { return sprintf('%s-%s-%sT%s:%s:%sZ', $m[1], $m[2], $m[3], $m[4] ?? '00', $m[5] ?? '00', $m[6] ?? '00'); } return null; } /* ---------- NR003 ---------- */ function conn_normalize_nws(array $d): array { $out = []; foreach (($d['features'] ?? []) as $f) { $p = $f['properties'] ?? []; $out[] = [ 'src' => 'NWS', 'category' => 'alert', 'title' => (string)($p['headline'] ?? ($p['event'] ?? 'Alert')), 'text' => trim( (string)($p['areaDesc'] ?? '') . ' — ' . (string)($p['severity'] ?? '') . ' / ' . (string)($p['urgency'] ?? '') ), 'url' => (string)($p['@id'] ?? ($f['id'] ?? '')), 'published' => $p['sent'] ?? null, 'severity' => strtolower((string)($p['severity'] ?? '')), 'hash' => conn_sha1_short((string)($f['id'] ?? ($p['id'] ?? ''))), ]; } return $out; } /* ---------- NR004 ---------- */ function conn_normalize_fema(array $d): array { $out = []; foreach (($d['DisasterDeclarationsSummaries'] ?? []) as $r) { $out[] = [ 'src' => 'FEMA', 'category' => 'gov', 'title' => trim( (string)($r['declarationTitle'] ?? ($r['incidentType'] ?? 'Declaration')) . ' — ' . (string)($r['state'] ?? '') ), 'text' => 'Incident: ' . (string)($r['incidentType'] ?? '') . ' · Declared ' . substr((string)($r['declarationDate'] ?? ''), 0, 10), 'url' => 'https://www.fema.gov/disaster/' . (string)($r['disasterNumber'] ?? ''), 'published' => $r['declarationDate'] ?? null, 'hash' => conn_sha1_short(((string)($r['id'] ?? '')) . '|' . ((string)($r['disasterNumber'] ?? ''))), ]; } return $out; } /* ---------- USGS (new rule) ---------- */ function conn_normalize_usgs(array $d): array { $out = []; foreach (($d['features'] ?? []) as $f) { $p = $f['properties'] ?? []; $mag = $p['mag'] ?? null; $magLabel = ($mag !== null) ? 'M' . number_format((float)$mag, 1) . ' · ' : ''; $depth = $f['geometry']['coordinates'][2] ?? '—'; $time = $p['time'] ?? null; $out[] = [ 'src' => 'USGS', 'category' => 'quake', 'title' => $magLabel . (string)($p['place'] ?? ($p['title'] ?? 'Earthquake')), 'text' => 'Depth ' . $depth . ' km · ' . (string)($p['place'] ?? ''), 'url' => (string)($p['url'] ?? ''), 'published' => $time ? gmdate('c', (int)($time / 1000)) : null, 'severity' => ($mag !== null && (float)$mag >= 6) ? 'severe' : 'moderate', 'hash' => conn_sha1_short((string)($f['id'] ?? '')), ]; } return $out; } /* ---------- NASA EONET ---------- */ function conn_normalize_eonet(array $d): array { $out = []; foreach (($d['events'] ?? []) as $e) { $cats = []; foreach (($e['categories'] ?? []) as $c) { $cats[] = (string)($c['title'] ?? ''); } $url = $e['sources'][0]['url'] ?? ($e['link'] ?? ''); $pub = $e['geometry'][0]['date'] ?? null; $out[] = [ 'src' => 'NASA EONET', 'category' => 'space', 'title' => (string)($e['title'] ?? 'Event'), 'text' => 'Category: ' . implode(', ', $cats) . ' · ' . (string)($e['description'] ?? ''), 'url' => (string)$url, 'published' => $pub, 'hash' => conn_sha1_short((string)($e['id'] ?? '')), ]; } return $out; }
Save file
Quick jump
open a path
Open