mirror of
https://github.com/DeNNiiInc/UltyScan.git
synced 2026-04-17 18:26:00 +00:00
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* UltyScan Web Interface - Scan Status
|
|
* Returns current scan status as JSON
|
|
*/
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
// Check if any sniper scan process is actually running
|
|
// We look specifically for sniper with scan arguments, not just any process matching
|
|
$output = shell_exec('ps aux 2>/dev/null | grep -E "sniper[[:space:]]+-[tmfwp]" | grep -v "grep"');
|
|
$running = false;
|
|
$processes = [];
|
|
|
|
if (!empty($output)) {
|
|
$lines = explode("\n", trim($output));
|
|
foreach ($lines as $line) {
|
|
$line = trim($line);
|
|
if (!empty($line) && strpos($line, 'status.php') === false) {
|
|
$processes[] = $line;
|
|
}
|
|
}
|
|
$running = count($processes) > 0;
|
|
}
|
|
|
|
// Get recent log files
|
|
$logs = [];
|
|
$logDir = '/var/log/ultyscan';
|
|
if (is_dir($logDir)) {
|
|
$files = glob($logDir . '/scan_*.log');
|
|
if ($files && is_array($files)) {
|
|
usort($files, function ($a, $b) {
|
|
return filemtime($b) - filemtime($a);
|
|
});
|
|
$logs = array_slice($files, 0, 5);
|
|
}
|
|
}
|
|
|
|
echo json_encode([
|
|
'running' => $running,
|
|
'processCount' => count($processes),
|
|
'processes' => $processes,
|
|
'recentLogs' => $logs,
|
|
'timestamp' => date('Y-m-d H:i:s')
|
|
]);
|