#!/usr/bin/perl # Copyright Andrew Gavin 2009, 2010 # # This file is part of OpenDLP. # # OpenDLP is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenDLP is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with OpenDLP. If not, see . use CGI qw/:standard/; use DBI; my $user = remote_user(); my $db_admin_file = "../etc/db_admin"; my $is_valid = 1; my %systems = (); open( DB, $db_admin_file ); my $db_line = ; close( DB ); chomp $db_line; my ($db_username, $db_password) = split( ":", $db_line ); header(); my $query = CGI->new; my $scanname = $query->param('scanname'); if( $scanname ne "" && $scanname !~ /^[a-z0-9\ \,\.\-\_]+$/i ) { $is_valid = 0; print "Invalid scan name

\n"; } my $system = $query->param('system'); if( $system ne "" && $system !~ /^[A-Z0-9]{32}$/ ) { $is_valid = 0; print "Invalid system tracker

\n"; } if( $is_valid ) { print "Delete Scans

\n"; print "You can only delete scans whose agents have all finished or have been manually stopped and uninstalled. Scans currently running will not be displayed.

\n"; print "
\n"; print "\n"; print "\n"; my $dbh = DBI->connect("DBI:mysql:database=OpenDLP;host=localhost",$db_username,$db_password); my $string = "SELECT DISTINCT scan,ip,control FROM systems"; my $sth = $dbh->prepare( $string ); $sth->execute(); while( my $results = $sth->fetchrow_arrayref() ) { if( $$results[2] eq "running" ) { $scans{$$results[0]}{running}++; } elsif( $$results[2] eq "finished" ) { $scans{$$results[0]}{finished}++; } elsif( $$results[2] eq "stopped" ) { $scans{$$results[0]}{stopped}++; } elsif( $$results[2] eq "uninstalled" ) { $scans{$$results[0]}{uninstalled}++; } } foreach my $scankey( sort( keys( %scans ))) { my $total = $scans{$scankey}{running} + $scans{$scankey}{finished} + $scans{$scankey}{stopped} + $scans{$scankey}{uninstalled}; if( $total = ($scans{$scankey}{finished} + $scans{$scankey}{uninstalled} )) { print "\n"; print "\n"; # Finished if( $scans{$scankey}{finished} == 0 ) { print "\n"; } else { print "\n"; } # Uninstalled if( $scans{$scankey}{uninstalled} == 0 ) { print "\n"; } else { print "\n"; } print "\n"; } } print "\n"; print "
DeleteScan nameFinishedUninstalledTotal
$scankey0$scans{$scankey}{finished}0$scans{$scankey}{uninstalled}$total
\n"; } footer(); sub header { print "Content-type: text/html\n\n"; print "\n\n"; print "OpenDLP 0.1\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print '
' . "\n"; } sub footer { print "
\n"; }