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
/api/stt.php
<?php declare(strict_types=1); header('Content-Type: application/json; charset=utf-8'); header('Cache-Control: no-store'); function get_client_key(): string { $h = getallheaders(); if (!empty($h['X-OpenAI-Key'])) return trim((string)$h['X-OpenAI-Key']); if (!empty($h['x-openai-key'])) return trim((string)$h['x-openai-key']); return ''; } function openai_key(): string { $k = get_client_key(); if ($k !== '') return $k; $env = trim((string)(getenv('OPENAI_API_KEY') ?: '')); if ($env !== '') return $env; $candidates = [ dirname(__DIR__) . '/_inc/secrets.php', dirname(__DIR__) . '/../_inc/secrets.php', __DIR__ . '/secrets.php', ]; foreach ($candidates as $file) { if (!is_file($file)) continue; $data = require $file; if (is_array($data)) { foreach (['OPENAI_API_KEY', 'openai_api_key', 'api_key'] as $key) { $value = trim((string)($data[$key] ?? '')); if ($value !== '') return $value; } } if (defined('OPENAI_API_KEY')) { $constant = trim((string)constant('OPENAI_API_KEY')); if ($constant !== '') return $constant; } } return ''; } function json_out(array $data, int $code=200): void { http_response_code($code); echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); exit; } $apiKey = openai_key(); if ($apiKey === '') json_out(['ok'=>false,'error'=>'Missing OPENAI_API_KEY'], 500); if (empty($_FILES['file']) || !is_uploaded_file($_FILES['file']['tmp_name'])) { json_out(['ok'=>false,'error'=>'Missing upload file'], 400); } $tmp = $_FILES['file']['tmp_name']; $name = $_FILES['file']['name'] ?? 'audio.webm'; $model = trim((string)(getenv('OPENAI_STT_MODEL') ?: 'gpt-4o-mini-transcribe')); $ch = curl_init('https://api.openai.com/v1/audio/transcriptions'); $post = [ 'model' => $model, 'file' => new CURLFile($tmp, 'audio/webm', $name), ]; curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $apiKey, ], CURLOPT_POSTFIELDS => $post, CURLOPT_TIMEOUT => 90, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_ENCODING => '', ]); $resp = curl_exec($ch); $err = curl_error($ch); $code = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE); curl_close($ch); if ($resp === false) json_out(['ok'=>false,'error'=>'cURL error: '.$err], 500); $j = json_decode($resp, true); if (!is_array($j)) json_out(['ok'=>false,'error'=>'Bad JSON from OpenAI','raw'=>mb_substr($resp,0,300)], 500); if ($code < 200 || $code >= 300) { $msg = $j['error']['message'] ?? ('OpenAI HTTP '.$code); json_out(['ok'=>false,'error'=>(string)$msg], 500); } $text = (string)($j['text'] ?? ''); json_out(['ok'=>true,'text'=>trim($text)]);
Save file
Quick jump
open a path
Open