From cd6f64679bed63fd582ed831ef4b04abd0d89274 Mon Sep 17 00:00:00 2001 From: adrien Date: Wed, 16 Oct 2024 10:43:11 +0200 Subject: [PATCH] include error message --- options.php | 11 ++++++++++- scan.php | 13 +++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/options.php b/options.php index 13e7a51..e4049c8 100755 --- a/options.php +++ b/options.php @@ -34,6 +34,15 @@ include_once 'filter_inputs.php';
+ + +
+ +
Erreur
+

+
+ +

Scanner un

@@ -443,4 +452,4 @@ foreach ($services as $name => [$portid, $protocol]) { - \ No newline at end of file + diff --git a/scan.php b/scan.php index 305982a..a28b427 100755 --- a/scan.php +++ b/scan.php @@ -5,7 +5,9 @@ include_once 'filter_inputs.php'; if (!$targets) { http_response_code(400); - die('Paramètre manquant : targets, lan ou host'); + $errorMessage = 'Paramètre manquant : targets, lan ou host'; + include_once "options.php"; + die(); } if (!file_exists($SCANSDIR)) mkdir($SCANSDIR); @@ -14,7 +16,9 @@ $args = ''; foreach ($inputs as $arg => $value) { if (is_null($value)) { http_response_code(400); - die("Valeur incorecte pour le paramètre $arg : " . filter_input(INPUT_GET, $arg, FILTER_SANITIZE_FULL_SPECIAL_CHARS)); + $errorMessage = "Valeur incorecte pour le paramètre $arg : " . filter_input(INPUT_GET, $arg, FILTER_SANITIZE_FULL_SPECIAL_CHARS); + include_once "options.php"; + die(); } else if ($value) { if ($value === true) { if (strlen($arg) <= 2) $args .= " -$arg"; @@ -34,13 +38,14 @@ exec($command, $stderr, $retcode); if ($retcode && strpos(implode($stderr), " root ") !== false) { // Retry with sudo - $recode = 0; exec("sudo $command", $stderr, $retcode); } if ($retcode) { http_response_code(500); - die(implode("
\n", $stderr)); + $errorMessage = implode("
\n", $stderr); + include_once "options.php"; + die(); } $xml = new DOMDocument();