false, 'error'=>'path outside allowed roots', 'path'=>$target]); exit; } if (!file_exists($real)) { echo json_encode(['ok'=>false, 'error'=>'file not found', 'path'=>$target]); exit; } $stat = stat($real); $md5 = md5_file($real); $content = file_get_contents($real); // Version extraction patterns (HTML, PHP, JS) $version = 'unknown'; foreach ([ '/data-version="([^"]+)"/', '/"wevia-version"\s+content="([^"]+)"/', '/@version\s+([^\s\*]+)/', '/VERSION\s*=\s*[\'"]([^\'"]+)/', ] as $pat) { if (preg_match($pat, $content, $m)) { $version = $m[1]; break; } } // Detect live URL if under /var/www/html $url = null; if (strpos($real, '/var/www/html/') === 0) { $rel = substr($real, strlen('/var/www/html/')); $url = 'https://weval-consulting.com/' . $rel; } echo json_encode([ 'ok' => true, 'path' => $real, 'url' => $url, 'size' => $stat['size'], 'size_kb' => round($stat['size'] / 1024, 1), 'mtime' => date('c', $stat['mtime']), 'md5' => $md5, 'version' => $version, 'lines' => substr_count($content, "\n"), 'source' => 'intent-opus4-scan_file.php · ambre · doctrine#4 honest', ], JSON_PRETTY_PRINT);