diff --git a/mozilla/webtools/graph/query.cgi b/mozilla/webtools/graph/query.cgi new file mode 100755 index 00000000000..d8fe4af482b --- /dev/null +++ b/mozilla/webtools/graph/query.cgi @@ -0,0 +1,101 @@ +#!/usr/bin/perl +use CGI::Carp qw(fatalsToBrowser); +use CGI::Request; +use Date::Calc qw(Add_Delta_Days); # http://www.engelschall.com/u/sb/download/Date-Calc/ + +my $req = new CGI::Request; + +my $TESTNAME = lc($req->param('testname')); +my $UNITS = lc($req->param('units')); +my $TBOX = lc($req->param('tbox')); +my $AUTOSCALE = lc($req->param('autoscale')); +my $DAYS = lc($req->param('days')); + +sub make_filenames_list { + my ($dir) = @_; + + my @result; + + if (-d "$dir") { + chdir "$dir"; + while(<*>) { + if( $_ ne 'config.txt' ) { + push @result, $_; + } + } + chdir "../.."; + } + return @result; +} + +# Print out a list of testnames in db directory +sub print_testnames { + my ($testname) = @_; + + # HTTP header + print "Content-type: text/html\n\n\n"; + print "testnames"; + print "

testnames

"; + print "

"; + print ""; + print "
Select one of the following tests:
\n"; + print "
    \n"; + + my @machines = make_filenames_list("db"); + my $machines_string = join(" ", @machines); + + foreach (@machines) { + print "
  • $_\n"; + } + print "
"; + +} + + +# Print out a list of machines in db/ directory, with links. +sub print_machines { + my ($testname) = @_; + + # HTTP header + print "Content-type: text/html\n\n\n"; + print "$TESTNAME machines"; + print "

$TESTNAME machines:

"; + print "

"; + print ""; + print "
Select one of the following machines:
\n"; + print "
    \n"; + + my @machines = make_filenames_list("db/$testname"); + my $machines_string = join(" ", @machines); + + foreach (@machines) { + print "
  • $_\n"; + } + print "
"; + +} + +sub show_graph { + # HTTP header + print "Content-type: text/html\n\n\n"; + + my $neg_autoscale = !$AUTOSCALE; + + print "autoscale
\n"; + + + # graph + print ""; +} + +if(!$TESTNAME) { + print_testnames(); +} elsif(!$TBOX) { + print_machines($TESTNAME); +} else { + show_graph(); +} + + +exit 0; +