include error message
This commit is contained in:
parent
6422830783
commit
cd6f64679b
11
options.php
11
options.php
@ -34,6 +34,15 @@ include_once 'filter_inputs.php';
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<main class="ui main container">
|
<main class="ui main container">
|
||||||
|
|
||||||
|
<?php if(isset($errorMessage)) { ?>
|
||||||
|
<div class="ui negative message">
|
||||||
|
<i class="close icon"></i>
|
||||||
|
<div class="header">Erreur</div>
|
||||||
|
<p><?=$errorMessage?></p>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<h1 class="header">Scanner un <?=$host? "hôte" : "réseau" ?></h1>
|
<h1 class="header">Scanner un <?=$host? "hôte" : "réseau" ?></h1>
|
||||||
|
|
||||||
<form id="newScanForm" class="ui form" method="get" action="scan.php">
|
<form id="newScanForm" class="ui form" method="get" action="scan.php">
|
||||||
@ -443,4 +452,4 @@ foreach ($services as $name => [$portid, $protocol]) {
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
13
scan.php
13
scan.php
@ -5,7 +5,9 @@ include_once 'filter_inputs.php';
|
|||||||
|
|
||||||
if (!$targets) {
|
if (!$targets) {
|
||||||
http_response_code(400);
|
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);
|
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
|
||||||
@ -14,7 +16,9 @@ $args = '';
|
|||||||
foreach ($inputs as $arg => $value) {
|
foreach ($inputs as $arg => $value) {
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
http_response_code(400);
|
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) {
|
} else if ($value) {
|
||||||
if ($value === true) {
|
if ($value === true) {
|
||||||
if (strlen($arg) <= 2) $args .= " -$arg";
|
if (strlen($arg) <= 2) $args .= " -$arg";
|
||||||
@ -34,13 +38,14 @@ exec($command, $stderr, $retcode);
|
|||||||
|
|
||||||
if ($retcode && strpos(implode($stderr), " root ") !== false) {
|
if ($retcode && strpos(implode($stderr), " root ") !== false) {
|
||||||
// Retry with sudo
|
// Retry with sudo
|
||||||
$recode = 0;
|
|
||||||
exec("sudo $command", $stderr, $retcode);
|
exec("sudo $command", $stderr, $retcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($retcode) {
|
if ($retcode) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
die(implode("<br/>\n", $stderr));
|
$errorMessage = implode("<br/>\n", $stderr);
|
||||||
|
include_once "options.php";
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$xml = new DOMDocument();
|
$xml = new DOMDocument();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user