#
# Report services and host counts.
#

my $myurl="saint_info_class.pl";
$Exclusions::service_flag=0;
&make_service_exclusion_info();

print CLIENT <<EOF;
<HTML>
<HEAD>
<title> Host Tables - by Class of Service </title>
<LINK REV="made" HREF="mailto:saint\@saintcorporation.com">
</HEAD>
<BODY BGCOLOR="white" vlink="#000000" link="#04289D">

<P></P>

<P>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
	<TR>
		<TD COLSPAN="2"><IMG SRC="$HTML_ROOT/images/data_analysis_banner.gif" WIDTH="621" HEIGHT="106" ALIGN="BOTTOM" ALT="Data Analysis" BORDER="0"></TD>
	</TR>
	<TR>
	  <TD WIDTH="86" VALIGN="TOP">
	    <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
		<TR>
		    <TD WIDTH="86"><A HREF="http://www.saintcorporation.com"><IMG SRC="$HTML_ROOT/images/home.gif" WIDTH="86" HEIGHT="55" ALIGN="BOTTOM" ALT="SAINT Corporation"
			BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_ROOT/saint.html"><IMG SRC="$HTML_ROOT/images/home_button.gif" WIDTH="86" HEIGHT="46"
			ALIGN="BOTTOM" ALT="SAINT Home" BORDER="0" STYLE="Background-Image : none"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/data/saint_data_form.pl"><IMG SRC="$HTML_ROOT/images/data_mgmt_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Data Management" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/running/saint_run_form.pl"><IMG SRC="$HTML_ROOT/images/target_selection_button.gif"
			WIDTH="86" HEIGHT="46" ALIGN="BOTTOM" ALT="Target Selection" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/reporting/analysis.pl"><IMG SRC="$HTML_ROOT/images/data_analysis_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Data Analysis" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/admin/saint_cf_form.pl"><IMG SRC="$HTML_ROOT/images/config_mgmt_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Configuration Management" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_ROOT/saint_documentation.html"><IMG SRC="$HTML_ROOT/images/documentation_button.gif"
			WIDTH="86" HEIGHT="46" ALIGN="BOTTOM" ALT="SAINT Documentation" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86" HEIGHT="46"><A HREF="$HTML_ROOT/docs/FAQ.html#trouble"><IMG SRC="$HTML_ROOT/images/troubleshooting_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Troubleshooting" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86" HEIGHT="65"><IMG SRC="$HTML_ROOT/images/bottom_border.gif" WIDTH="86" HEIGHT="75" ALIGN="BOTTOM" ALT="--------" BORDER="0"></TD>
		</TR>
	    </TABLE>
	  </TD>
	  <TD VALIGN="TOP">
		<DL>
			<P>
		</DL>
<CENTER><H1>Host Tables - by Class of Service </H1></CENTER>
<hr><UL><UL>
EOF

my $txtstr="Number of server systems (vulnerable/total)";
if ( $Exclusions::display_ignored)
{     $txtstr="Number of server systems (vulnerable[ignored]/total)";
}

if (sizeof(*servers) > 0) {
    print CLIENT "<p> <h3>$txtstr </h3> <ul>\n";
    for (sort keys %servers) {
	# Mask possible blanks or slashes in service names.
	($_service = $_) =~ tr / \//?!/;
	$_dot = $server_severities{$_} ? "reddot" : "blackdot";
	$_alt = $server_severities{$_} ? "*" : "-";
	if ($server_counts{$_} > 0) {
           $txtstr="$server_severities{$_}/$server_counts{$_}";
           if ( $Exclusions::display_ignored &&
               $Exclusions::server_severities_ignored{$_} )
           {   $txtstr="$server_severities{$_}\[$Exclusions::server_severities_ignored{$_}\]/$server_counts{$_}";
           }
	    print CLIENT <<EOF;
	    <dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
	    <a href="saint_info_servers.pl,$_service,"> $_</a>
	    ($txtstr) 
EOF
#	} else {
#	    print CLIENT <<EOF;
#	    <dt><IMG SRC=$HTML_ROOT/dots/blackdot.gif ALT="-"> $_
#EOF
	}
    }
    print CLIENT "</ul>\n";
}

$txtstr="Number of client systems (vulnerable/total)";
if ( $Exclusions::display_ignored)
{     $txtstr="Number of client systems (vulnerable[ignored]/total)";
}

if (sizeof(*clients) > 0) {
    print CLIENT "<p> <h3> $txtstr </h3> <ul>\n";
    for (sort keys %clients) {
	# Mask possible blanks or slashes in service names.
	($_service = $_) =~ tr / \//?!/;
	$_dot = $client_severities{$_} ? "reddot" : "blackdot";
	$_alt = $client_severities{$_} ? "*" : "-";
	if ($client_counts{$_} > 0) {
           $txtstr="$client_severities{$_}/$client_counts{$_}";
           if ( $Exclusions::display_ignored &&
               $Exclusions::client_severities_ignored{$_} )
           {   $txtstr="$client_severities{$_}\[$Exclusions::client_severities_ignored{$_}\]/$client_counts{$_}";
           }
	    print CLIENT <<EOF;
	    <dt><IMG SRC=$HTML_ROOT/dots/$_dot.gif ALT="$_alt"> 
	    <a href="saint_info_clients.pl,$_service,"> $_</a>
	    ($txtstr)
EOF
#	} else {
#	    print CLIENT <<EOF;
#	    <dt><IMG SRC=$HTML_ROOT/dots/blackdot.gif ALT="-"> $_
#EOF
	}
    }
    print CLIENT "</ul>\n";
}

if (sizeof(*servers) > 0 || sizeof(*clients) > 0) {
    print CLIENT <<EOF;
	<strong>Note: hosts may appear in multiple categories. </strong>
	<HL>
	<strong>Service types with a red dot next to them have a vulnerable host contained within</strong>
EOF
} else {
    print CLIENT <<EOF;
	No service information found.
EOF
}
print_show_hide_html_message(\*::CLIENT,$myurl);

print CLIENT <<EOF
<hr> <a href=$HTML_STARTPAGE> Back to the SAINT start page </a> |
<a href=analysis.pl> Back to SAINT Reporting and Analysis </a>
</UL></UL>
	  </TD>
	</TR>
</TABLE>
</BODY>
</HTML>
EOF
