rename saveAs to name

This commit is contained in:
Adrien MALINGREY 2024-10-23 15:17:03 +02:00
parent df4648e12a
commit 8e5f010da0
4 changed files with 8 additions and 8 deletions

View File

@ -109,7 +109,7 @@ if ($preset && isset($presets[$preset])) {
'-h' => FILTER_VALIDATE_BOOLEAN,
'--stylesheet' => FILTER_VALIDATE_URL,
// lanScan
'saveAs' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $fileNameRegex]],
'name' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $fileNameRegex]],
'originalURL' => FILTER_VALIDATE_URL,
'refreshPeriod' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0]],
'sudo' => FILTER_VALIDATE_BOOLEAN,

View File

@ -632,10 +632,10 @@ foreach (scandir($SCANSDIR) as $filename) {
</div>
<div class="field">
<label for="saveAsInput">Enregistrer sous le nom</label>
<input id="saveAsInput" type="text" name="saveAs" placeholder="Réseau local" pattern='[^&lt;&gt;:&quot;\\\/\|@?]+'
<label for="nameInput">Enregistrer sous le nom</label>
<input id="nameInput" type="text" name="name" placeholder="Réseau local" pattern='[^&lt;&gt;:&quot;\\\/\|@?]+'
title="Caractères interdits : &lt;&gt;:&quot;\/|@?"
value="<?= $options["saveAs"] ?? ""; ?>">
value="<?= $options["name"] ?? ""; ?>">
</div>
<button type="submit" class="ui teal submit button">Démarrer</button>

View File

@ -41,7 +41,7 @@ $xml = new DOMDocument();
$xml->load($tempPath);
`rm "$tempPath"`;
$thisURL = $options["saveAs"]?? false ? "$BASEDIR/$SCANSDIR/".rawurlencode($options["saveAs"]).".xml" : "";
$thisURL = $options["name"]?? false ? "$BASEDIR/$SCANSDIR/".rawurlencode($options["name"]).".xml" : "";
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='thisURL' value='".htmlentities($thisURL, ENT_QUOTES)."'"), $xml->documentElement);
foreach ($options as $option => $value) {
if (substr($option, 0, 1) != '-') {
@ -49,8 +49,8 @@ foreach ($options as $option => $value) {
}
}
if ($options["saveAs"] ?? false) {
$path = "$SCANSDIR/{$options["saveAs"]}.xml";
if ($options["name"] ?? false) {
$path = "$SCANSDIR/{$options["name"]}.xml";
$xml->save($path);
header("Location: $path");

View File

@ -24,7 +24,7 @@
<xsl:variable name="init" select="document($originalURL)/nmaprun"/>
<xsl:variable name="nextComparison">
<xsl:choose>
<xsl:when test="$thisURL"><xsl:value-of select="$saveAs"/></xsl:when>
<xsl:when test="$thisURL"><xsl:value-of select="$thisURL"/></xsl:when>
<xsl:when test="$originalURL"><xsl:value-of select="$originalURL"/></xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>