#!/usr/bin/perl -w

# $Id: draw_component_request.pl,v 1.4 1996/02/12 18:54:28 hoagland Exp $

# draw_component_request.pl, by Jim Hoagland (hoagland@cs) 1/96

# this routine generates the component request page for the ARPA IDS
# demo GUI
# outputs HTML to STDOUT

require 5.000;

require '/pkg/www/arpa/secret/cgi-bin/gui-helper.pl';
require '/pkg/arpa/demo.0/require.pl';

sub draw_component_request {
  my $state= shift;
  my ($thishour,$thisday)= split(/\s+/,`date "+%H %d"`);
  $thisday =~ s/^0+//;   $thishour =~ s/^0+//;
  my $hostname= $myhostname; # from require.pl

  my $host_opts= '';
  foreach (sort $state->hosts) {
    $host_opts.= "<OPTION";
    $host_opts.= " SELECTED" if $state->last_host eq $_;
    $host_opts.= ">$_";
  }

  my $domlist='';
  my $day;
  for ($day=1;$day <= 31;$day++) {
    $domlist.= "<OPTION";
    $domlist.= " SELECTED" if $day eq $thisday;
    $domlist.= ">$day";
  }
  
  my $hourlist='';
  my $hour=0;
  foreach $hourtext (qw(12m 1am 2am 3am 4am 5am 6am 7am 8am 9am 10am 11am 12n 1pm 2pm 3pm 4pm 5pm 6pm 7pm 8pm 9pm 10pm 11pm)) {
    $hourlist.= "<OPTION VALUE=\"$hour\"";
    $hourlist.= " SELECTED" if $hour eq $thishour;
    $hourlist.= ">$hourtext";
    $hour++;
  }
  $hourlist.= "<OPTION VALUE=0>12m";
  
  print "Content-type:  text/html\n\n";
  &output_instantiated_file('/pkg/www/arpa/secret/gui/html-src/component_request.html',*STDOUT,
			    '<!!! Insert this host here !!!>',$myhostname,
			    '<!!! Insert host options Here !!!>',$host_opts,
			    '<!!! Insert d.o.m. list here !!!>',$domlist,
			    '<!!! Insert hour list here !!!>',$hourlist);
			    
  

}
1;
