From 6dd728ce0dae6aa152ac698fcae4d31acb2086a3 Mon Sep 17 00:00:00 2001 From: adrien Date: Mon, 7 Oct 2024 12:09:12 +0200 Subject: [PATCH] save only first scan --- new-scan.php => advanced-scan.php | 0 config.php | 2 +- index.php | 4 +-- scan.php | 50 +++++++++++++++++-------------- stylesheet.xsl | 7 ++--- 5 files changed, 33 insertions(+), 30 deletions(-) rename new-scan.php => advanced-scan.php (100%) diff --git a/new-scan.php b/advanced-scan.php similarity index 100% rename from new-scan.php rename to advanced-scan.php diff --git a/config.php b/config.php index 0edf7c0..a8b4d37 100644 --- a/config.php +++ b/config.php @@ -1,4 +1,4 @@ $targets\n"; } } diff --git a/scan.php b/scan.php index 0b5c89f..cbdc30f 100755 --- a/scan.php +++ b/scan.php @@ -1,5 +1,9 @@ loadXML($result); + $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='targets' value='$targets'"), $xml->documentElement); -exec($command, $output, $retval); + $dir = $SCANS_DIR; + if (!file_exists($SCANS_DIR)) { + mkdir($SCANS_DIR); + } + + $path = "$SCANS_DIR/".str_replace('/', '!', $targets).'.xml'; + if (!file_exists($path)) { + $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value=''"), $xml->documentElement); + $xml->save($path); + } else { + $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='$path'"), $xml->documentElement); + } -if (!file_exists($currentPath)) { + header('Content-type: text/xml'); + exit($xml->saveXML()); +} else { http_response_code(500); - exit(implode("
\n", $output)); -} - -// Add params -$xml = new DOMDocument(); -$xml->load($currentPath); -$processingInstruction = $xml->createProcessingInstruction('xslt-param', "name='targets' value='$targets'"); -$xml->insertBefore($processingInstruction, $xml->documentElement); -$processingInstruction = $xml->createProcessingInstruction('xslt-param', "name='basedir' value='$basedir'"); -$xml->insertBefore($processingInstruction, $xml->documentElement); -$processingInstruction = $xml->createProcessingInstruction('xslt-param', "name='compareWith' value='$initPath'"); -$xml->insertBefore($processingInstruction, $xml->documentElement); -$xml->save($currentPath); - -//header('Location: '.$currentPath); -header('Content-type: text/xml'); -exit($xml->saveXML()); + exit(); +} \ No newline at end of file diff --git a/stylesheet.xsl b/stylesheet.xsl index ebf8f03..f00d639 100755 --- a/stylesheet.xsl +++ b/stylesheet.xsl @@ -4,7 +4,6 @@ - @@ -20,7 +19,7 @@ - + @@ -32,7 +31,7 @@