diff --git a/config.php b/config.php index 67ce1a5..db6d2ec 100644 --- a/config.php +++ b/config.php @@ -20,3 +20,4 @@ $SCANSDIR = 'scans'; $DATADIR = '/usr/share/nmap'; $sudo = true; +$refreshPeriod = 60; diff --git a/filter_inputs.php b/filter_inputs.php index a376a41..6684a75 100644 --- a/filter_inputs.php +++ b/filter_inputs.php @@ -7,12 +7,12 @@ $portsListRegex = "/^([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*$/"; $tempoRegex = "/^\d+[smh]?$/"; $fileNameRegex = '/^[^<>:"\/|?]+$/'; -$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); -$lan = filter_input(INPUT_GET, 'lan', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); -$host = filter_input(INPUT_GET, 'host', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); -$saveAs = filter_input(INPUT_GET, 'saveAs', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $fileNameRegex]]); -$compareWith = filter_input(INPUT_GET, 'compareWith', FILTER_VALIDATE_URL); - +$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); +$lan = filter_input(INPUT_GET, 'lan', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); +$host = filter_input(INPUT_GET, 'host', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); +$saveAs = filter_input(INPUT_GET, 'saveAs', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $fileNameRegex]]); +$compareWith = filter_input(INPUT_GET, 'compareWith', FILTER_VALIDATE_URL); +$refreshPeriod = filter_input(INPUT_GET, 'refreshPeriod', FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]) ?? $refreshPeriod; if ($lan) { $targets = $lan; @@ -22,7 +22,7 @@ if ($lan) { $inputs = $HOSTSCAN_OPTIONS; } else { $inputs = filter_input_array(INPUT_GET, [ - 'iR' => FILTER_VALIDATE_INT, + 'iR' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0]], 'exclude' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], 'sL' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], diff --git a/hostScan.xsl b/hostScan.xsl index d7b994d..3569590 100755 --- a/hostScan.xsl +++ b/hostScan.xsl @@ -9,8 +9,13 @@ - + + + + + + @@ -18,10 +23,6 @@ - - - - @@ -41,12 +42,15 @@ - - - 60;URL= - - - + + + + + ;URL= + + + + <xsl:text>lanScan - </xsl:text> <xsl:value-of select="$targets"/> @@ -82,6 +86,7 @@ Exemples: 192.168.1.0/24 scanme.nmap.org 10.0-255.0-255.1-254"/> <i class="satellite dish icon"></i> </div> <input type="hidden" name="compareWith" value="{$nextCompareWith}"/> + <input type="hidden" name="refreshPeriod" value="{$refreshPeriod}"/> <button style="display: none;" type="submit" formmethod="get" formaction="{$basedir}/scan.php"></button> </div> <div class="item"> diff --git a/lanScan.xsl b/lanScan.xsl index 28a1d19..357bd0a 100755 --- a/lanScan.xsl +++ b/lanScan.xsl @@ -10,6 +10,12 @@ <xsl:param name="savedAs" select=""/> <xsl:param name="compareWith" select=""/> + <xsl:param name="refreshPeriod" select="0"/> + + <xsl:variable name="current" select="./nmaprun"/> + <xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href="'),'"')"/> + <xsl:variable name="basedir" select="concat($stylesheetURL, '/..')"/> + <xsl:variable name="init" select="document($compareWith)/nmaprun"/> <xsl:variable name="nextCompareWith"> <xsl:choose> <xsl:when test="$savedAs"><xsl:value-of select="$savedAs"/></xsl:when> @@ -17,10 +23,6 @@ <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:variable> - <xsl:variable name="current" select="./nmaprun"/> - <xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href="'),'"')"/> - <xsl:variable name="basedir" select="concat($stylesheetURL, '/..')"/> - <xsl:variable name="init" select="document($compareWith)/nmaprun"/> <xsl:template match="nmaprun"> <xsl:variable name="targets" select="substring-after(@args, '.xml ')"/> @@ -40,12 +42,15 @@ <html lang="fr"> <head> <meta charset="utf-8"/> - <meta http-equiv="refresh"> - <xsl:attribute name="content"> - <xsl:text>60;URL=</xsl:text> - <xsl:value-of select="$refreshURL"/> - </xsl:attribute> - </meta> + <xsl:if test="$refreshPeriod > 0"> + <meta http-equiv="refresh"> + <xsl:attribute name="content"> + <xsl:value-of select="$refreshPeriod"/> + <xsl:text>;URL=</xsl:text> + <xsl:value-of select="$refreshURL"/> + </xsl:attribute> + </meta> + </xsl:if> <title> <xsl:text>lanScan - </xsl:text> <xsl:value-of select="$targets"/> @@ -85,6 +90,7 @@ Exemples: 192.168.1.0/24 scanme.nmap.org 10.0-255.0-255.1-254"/> <i class="satellite dish icon"></i> </div> <input type="hidden" name="compareWith" value="{$nextCompareWith}"/> + <input type="hidden" name="refreshPeriod" value="{$refreshPeriod}"/> <button style="display: none;" type="submit" formmethod="get" formaction="{$basedir}/scan.php"></button> </div> <div class="item"> diff --git a/options.php b/options.php index cfac804..c6bbc36 100755 --- a/options.php +++ b/options.php @@ -246,6 +246,15 @@ foreach (scandir($SCANSDIR) as $filename) { ?> </select> </div> + + <div class="field"> + <label for="refreshPeriodInput">RafraƮchir toutes les</label> + <div class="ui right labeled input"> + <input type="number" min="0" id="refreshPeriodInput" name="refreshPeriod" placeholder="PƩriode" + value="<?= $refreshPeriod ?? "" ?>"> + <div class="ui label">secondes</div> + </div> + </div> </div> </div> diff --git a/scan.php b/scan.php index c606054..15a146f 100755 --- a/scan.php +++ b/scan.php @@ -41,6 +41,7 @@ $xml->load($tempPath); $saveAsURL = $saveAs? "$BASEDIR/$SCANSDIR/$saveAs.xml" : ""; $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='savedAs' value='".htmlentities($saveAsURL, ENT_QUOTES)."'"), $xml->documentElement); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='".htmlentities($compareWith, ENT_QUOTES)."'"), $xml->documentElement); +$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='refreshPeriod' value='".htmlentities($refreshPeriod, ENT_QUOTES)."'"), $xml->documentElement); if ($saveAs) { $path = "$SCANSDIR/$saveAs.xml";