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,026
Folders
377
Scanned Size
3.79 GB
PHP Files
791
Editable Text Files
12,310
File viewer
guarded to /htdocs
/bing_proxy.php
<?php /* ============================================================ * SIMON ยท Bing Search Proxy (HTML scraper) * ------------------------------------------------------------ * Upload to: /htdocs/connlink/test1/ui/bing_proxy.php * Reached at: https://www.gaylordsinclair.com/connlink/test1/ui/bing_proxy.php?q=QUERY * * Microsoft retired the Bing Web Search API (August 2025) so the * only way to include Bing results in a meta-search is to scrape * the public HTML page server-side. This proxy: * - fetches https://www.bing.com/search?q=... * - parses the top organic results out of the HTML * - returns a compact JSON shape matching gsearch_proxy.php: * { ok, query, results:[{title,snippet,url,source}], meta:{} } * - caches responses for CACHE_TTL seconds per query * * Query params: * q : query string (required) * num : 1..20 results (default 10) * mkt : market code, e.g. en-US (optional) * ============================================================ */ header('Content-Type: application/json; charset=utf-8'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, OPTIONS'); if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; } $q = trim((string)($_GET['q'] ?? '')); if ($q === '') { echo json_encode(['ok'=>false, 'err'=>'missing q', 'results'=>[]]); exit; } $num = max(1, min(20, intval($_GET['num'] ?? 10))); $mkt = preg_replace('/[^A-Za-z\-]/', '', (string)($_GET['mkt'] ?? 'en-US')); /* ----- cache ----- */ $CACHE_DIR = __DIR__ . '/cache'; $CACHE_TTL = 600; // 10 minutes if (!is_dir($CACHE_DIR)) { @mkdir($CACHE_DIR, 0755, true); } $ckey = sha1('bing|' . $q . '|' . $num . '|' . $mkt); $cfile = $CACHE_DIR . '/bing_' . $ckey . '.json'; if (file_exists($cfile) && (time() - filemtime($cfile)) < $CACHE_TTL) { header('X-SIMON-Cache: HIT'); readfile($cfile); exit; } /* ----- fetch Bing HTML ----- */ $upstream = 'https://www.bing.com/search?' . http_build_query([ 'q' => $q, 'count' => $num, 'mkt' => $mkt, 'form' => 'QBLH', ]); $ch = curl_init($upstream); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 12, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 3, CURLOPT_ENCODING => '', // accept gzip/deflate CURLOPT_HTTPHEADER => [ 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: en-US,en;q=0.9', 'Accept-Encoding: gzip, deflate, br', 'Referer: https://www.bing.com/', 'Cache-Control: no-cache', ], ]); $html = curl_exec($ch); $http = curl_getinfo($ch, CURLINFO_HTTP_CODE); $err = curl_error($ch); curl_close($ch); if ($html === false || $http >= 500 || $http === 0) { if (file_exists($cfile)) { header('X-SIMON-Cache: STALE'); readfile($cfile); exit; } http_response_code(502); echo json_encode(['ok'=>false,'err'=>'bing upstream failed','detail'=>$err,'status'=>$http,'query'=>$q,'results'=>[]]); exit; } /* ----- parse results out of the HTML ----- * Bing wraps each organic result in <li class="b_algo"> ... </li>. * Inside: <h2><a href="URL">TITLE</a></h2> + snippet in .b_caption p or .b_snippet. * We use DOMDocument for robustness, with libxml errors suppressed. */ $items = []; libxml_use_internal_errors(true); $doc = new DOMDocument(); // add meta charset so DOMDocument doesn't mangle unicode $prefix = '<?xml encoding="utf-8" ?>'; @$doc->loadHTML($prefix . $html); libxml_clear_errors(); $xp = new DOMXPath($doc); $nodes = $xp->query('//li[contains(concat(" ", normalize-space(@class), " "), " b_algo ")]'); if ($nodes && $nodes->length) { foreach ($nodes as $li) { $aNode = $xp->query('.//h2/a[@href]', $li)->item(0); if (!$aNode) continue; $url = $aNode->getAttribute('href'); $title = trim(preg_replace('/\s+/', ' ', $aNode->textContent)); if ($title === '' || $url === '' || stripos($url, 'http') !== 0) continue; // prefer .b_caption > p for snippet; fall back to .b_snippet or first <p> $snip = ''; $snippetCandidates = [ './/div[contains(@class,"b_caption")]//p', './/p[contains(@class,"b_lineclamp")]', './/div[contains(@class,"b_snippet")]', './/p', ]; foreach ($snippetCandidates as $xpq) { $sn = $xp->query($xpq, $li)->item(0); if ($sn) { $snip = trim(preg_replace('/\s+/', ' ', $sn->textContent)); if ($snip !== '') break; } } // displayLink $src = ''; $cite = $xp->query('.//cite', $li)->item(0); if ($cite) { $src = trim($cite->textContent); } if ($src === '') { $parsed = parse_url($url); $src = $parsed['host'] ?? ''; } // Bing sometimes wraps image thumbnails; skip if none. $img = ''; $imgNode = $xp->query('.//img[contains(@class,"rms_img") or contains(@class,"b_vid") or @src]', $li)->item(0); if ($imgNode) { $s = $imgNode->getAttribute('src'); if ($s && stripos($s, 'data:') !== 0) $img = $s; } $items[] = [ 'title' => $title, 'snippet' => $snip, 'url' => $url, 'source' => $src, 'image' => $img, ]; if (count($items) >= $num) break; } } $out = [ 'ok' => true, 'query' => $q, 'results' => $items, 'meta' => [ 'engine' => 'bing', 'count' => count($items), 'status' => $http, ], ]; $encoded = json_encode($out, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); @file_put_contents($cfile, $encoded, LOCK_EX); header('X-SIMON-Cache: MISS'); echo $encoded;
Save file
Quick jump
open a path
Open