37 lines
1.8 KiB
PHP
37 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* intent-opus4-scan_file_smart.php · WAVE 203 · cause racine autonomie scan_file
|
|
* Extracts path from user message (received as base64 in ?msg=) then calls scan_file.
|
|
* Doctrine #4 ZERO FAKE — honest fallback if no path detected.
|
|
*/
|
|
header('Content-Type: application/json');
|
|
|
|
$msg = isset($_GET['msg']) ? base64_decode($_GET['msg']) : '';
|
|
if ($msg === '' || $msg === false) $msg = '';
|
|
|
|
// Priority path extraction (mirrors wevia-fast-path.php wave 203 logic)
|
|
$path = null;
|
|
if (preg_match('#(/var/www/[A-Za-z0-9_./\-]+\.(html|php|json|js|md|txt))#', $msg, $pm)) {
|
|
$path = $pm[1];
|
|
} elseif (preg_match('/\b([a-zA-Z0-9][a-zA-Z0-9_\-]{1,63}\.(html|php|json))\b/i', $msg, $pm)) {
|
|
$fn = $pm[1];
|
|
foreach (['/var/www/html/', '/var/www/html/api/', '/var/www/html/wevia-ia/', '/var/www/weval/', '/var/www/weval/wevia-ia/'] as $dir) {
|
|
if (file_exists($dir . $fn)) { $path = $dir . $fn; break; }
|
|
}
|
|
if (!$path) $path = '/var/www/html/' . $fn;
|
|
}
|
|
|
|
if (!$path) {
|
|
// Known aliases
|
|
if (preg_match('/all.ia.hub|hub\.html/i', $msg)) $path = '/var/www/html/all-ia-hub.html';
|
|
elseif (preg_match('/wtp|technology.platform/i', $msg)) $path = '/var/www/html/weval-technology-platform.html';
|
|
elseif (preg_match('/orchestrator/i', $msg)) $path = '/var/www/html/wevia-orchestrator.html';
|
|
elseif (preg_match('/master/i', $msg)) $path = '/var/www/html/wevia-master.html';
|
|
elseif (preg_match('/wepredict/i', $msg)) $path = '/var/www/html/wepredict.html';
|
|
else { echo json_encode(['ok'=>false,'error'=>'no path detected in message','msg'=>$msg,'source'=>'scan_file_smart']); exit; }
|
|
}
|
|
|
|
// Delegate to scan_file with extracted path
|
|
$_GET['path'] = $path;
|
|
include __DIR__ . '/scan_file_handler.php';
|