$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)); } else if ($value) { if ($value === true) { if (strlen($arg)<=2) $args .= " -$arg"; else $arg = "--$arg"; } else { if (strlen($arg)<=2) $args .= " -$arg" . ($value); else $arg = "--$arg " . ($value); } } } exec("nmap$args --stylesheet $basedir/stylesheet.xsl -oX - $targets 2>&1", $result, $code); if ($code) { http_response_code(500); die(implode("
\n", $result)); } $xml = new DOMDocument(); $xml->loadXML(implode("\n", $result)); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='name' value='$name'"), $xml->documentElement); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='scansDir' value='$SCANS_DIR'"), $xml->documentElement); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='$compareWith'"), $xml->documentElement); if ($name) { if (!file_exists($SCANS_DIR)) mkdir($SCANS_DIR); $path = "$SCANS_DIR/$name.xml"; $xml->save($path); header("Location: $path"); exit(); } else { header('Content-type: text/xml'); exit($xml->saveXML()); }