diff --git a/en/cgi/query-pr-summary.cgi b/en/cgi/query-pr-summary.cgi index 498fbc3339..d547bb6e6a 100755 --- a/en/cgi/query-pr-summary.cgi +++ b/en/cgi/query-pr-summary.cgi @@ -1,608 +1,655 @@ #!/usr/bin/perl -T -# $FreeBSD: www/en/cgi/query-pr-summary.cgi,v 1.43 2004/02/16 14:30:57 ceri Exp $ +# $FreeBSD: www/en/cgi/query-pr-summary.cgi,v 1.44 2004/04/06 11:22:37 ceri Exp $ sub escape($) { $_ = $_[0]; s/&/&/g; s/</g; s/>/>/g; $_; } $html_mode = 1 if $ENV{'DOCUMENT_ROOT'}; $self_ref = $ENV{'SCRIPT_NAME'}; ($query_pr_ref = $self_ref) =~ s/-summary//; $ENV{'PATH'} = '/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin'; $project = "FreeBSD"; $mail_prefix = "freebsd-"; $mail_unass = "freebsd-bugs"; $ports_unass = "ports-bugs"; $closed_too = 0; require "./cgi-lib.pl"; require "./cgi-style.pl"; require "getopts.pl"; if ($ENV{'QUERY_STRING'} eq 'query') { print &html_header("Query $project problem reports"); &displayform; print &html_footer; exit(0); } if ($html_mode) { $query_args = '--restricted '; &ReadParse(*input) if $html_mode; } else { &Getopts('CcqRr:s:'); $input{"responsible"} = "summary" if $opt_R; if ($opt_r) { ($input{"responsible"}) = ($opt_r =~ m/^(\^?[-_a-zA-Z0-9@.]*\$?)$/); die "Insecure args" if ($input{"responsible"} ne $opt_r) } if ($opt_s) { ($input{"state"}) = ($opt_s =~ m/^([a-zA-Z]*)$/); die "Insecure args" if ($input{"state"} ne $opt_s) } $input{"quiet"} = "yes" if $opt_q; if ($opt_C) { $query_args = '--confidential=yes '; } elsif (!$opt_c) { $query_args = '--restricted '; } } $closed_too = 1 if $input{'state'} eq 'closed' || $input{'closedtoo'}; #------------------------------------------------------------------------ %mons = ('Jan', '01', 'Feb', '02', 'Mar', '03', 'Apr', '04', 'May', '05', 'Jun', '06', 'Jul', '07', 'Aug', '08', 'Sep', '09', 'Oct', '10', 'Nov', '11', 'Dec', '12'); if ($html_mode) { $h1 = "
" ; $p_e = "
"; $br = ""; $pr_e = ""; $dl = "
) { chop; local ($cat, $desc, $responsible, $notify) = split(/:/); push(@categories, $cat); $catdesc{$cat} = $desc; } } sub get_states { @states = (); open(Q, "query-pr.web --list-states 2>/dev/null |") || die "Cannot get states\n"; while() { chop; local ($state, $type, $desc) = split(/:/); push(@states, $state); $statedesc{$state} = $desc; } } sub get_classes { @classes = (); open(Q, "query-pr.web --list-classes 2>/dev/null |") || die "Cannot get classes\n"; while() { chop; local ($class, $type, $desc) = split(/:/); push(@classes, $class); $classdesc{$class} = $desc; } } sub read_gnats { local($report) = @_[0]; open(Q, "query-pr.web $report 2>/dev/null |") || die "Cannot query the PR's\n"; while() { chop; if(/^>Number:/) { $number = &getline($_); } elsif (/Arrival-Date:/) { $date = &getline($_); # strip timezone if any (between HH:MM:SS and YYYY at end of line): $date =~ s/(\d\d:\d\d:\d\d)\D+(\d{4})$/\1 \2/; ($dow,$mon,$day,$time,$year,$xtra) = split(/[ \t]+/, $date); $day = "0$day" if $day =~ /^[0-9]$/; $date = "$year/$mons{$mon}/$day"; } elsif (/>Last-Modified:/) { $lastmod = &getline($_); if ($lastmod =~ /^[ ]*$/) { $lastmod = $date; } else { # strip timezone if any (between HH:MM:SS and YYYY at end of line): $lastmod =~ s/(\d\d:\d\d:\d\d)\D+(\d{4})$/\1 \2/; ($dow,$mon,$day,$time,$year,$xtra) = split(/[ \t]+/, $lastmod); $day = "0$day" if $day =~ /^[0-9]$/; $lastmod = "$year/$mons{$mon}/$day"; } } elsif (/>Category:/) { $cat = &getline($_); } elsif (/>Severity:/) { $sev = &getline($_); } elsif (/>Responsible:/) { $resp = &getline($_); $resp =~ s/@.*//; $resp =~ tr/A-Z/a-z/; $resp = "" if (($resp =~ /$mail_unass/o) or ($resp =~ /$ports_unass/o)); $resp =~ s/^$mail_prefix//; } elsif (/>State:/) { $status = &getline($_); $status =~ s/(.).*/\1/; } elsif (/>Synopsis:/) { $syn = &getline($_); $syn =~ s/[\t]+/ /g; } elsif (/^$/) { $_ = sprintf("%s/%s", $cat, $number); $status{$_} = $status; $date{$_} = $date; $resp{$_} = $resp; $syn{$_} = $syn; $sev{$_} = $sev; $lastmod{$_} = $lastmod; push(@prs,$_); } } close(Q); } sub gnats_summary { local($report) = @_[0]; local($htmlmode) = @_[1]; local($counter) = 0; - local($iteration)= 0; foreach (@prs) { $state = $status{$_}; $date = $date{$_}; $resp = $resp{$_}; $syn = $syn{$_}; $severity = $sev{$_}; ($cat, $number) = m|^([^/]+)/(\d+)$|; next if (($report ne '') && (eval($report) == 0)); - print "${pr}\nS Submitted Tracker Resp. Description${hr}" - if ($iteration++ == 0); - - $syn = &html_fixline($syn) if $htmlmode; - if ($htmlmode) { - $title = '' . - $_ . ' '; + $title = '' . + $_ . ' '; + $syn = &html_fixline($syn); + gnats_summary_line_html($counter, $state, $date, $title, $resp, $syn); } else { $title = $_; + gnats_summary_line_text($counter, $state, $date, $title, $resp, $syn); } - print "$state [$date] $title" . - (' ' x (16 - length($_))) . - $resp . (' ' x (12 - length($resp))) . - ($htmlmode ? $syn : substr($syn,0,41)) - . "\n"; - ++$counter; } - print "${pr_e}\n" if $iteration; + if ($htmlmode) { + print "${table_e}\n" if $counter; + } else { + print "${pr_e}\n" if $counter; + } $counter; } +sub gnats_summary_line_html { + local($counter) = shift; + local($state) = shift; + local($date) = shift; + local($title) = shift; + local($resp) = shift; + local($syn) = shift; + + print "${table}\n" . + "\n" . + " \n" + if ($counter == 0); + + print "S \n" . + "Submitted \n" . + "Tracker \n" . + "Resp. \n" . + "Description \n" . + "\n" . + " \n"; +} + +sub gnats_summary_line_text { + local($counter) = shift; + local($state) = shift; + local($date) = shift; + local($title) = shift; + local($resp) = shift; + local($syn) = shift; + + # Print the banner line if this is the first iteration. + print "${pr}\nS Submitted Tracker Resp. Description${hr}" + if ($counter == 0); + print "$state [$date] $title" . + (' ' x (16 - length($_))) . + $resp . (' ' x (12 - length($resp))) . + substr($syn,0,41) . "\n"; +} + sub displayform { print qq` Please select the items you wish to search for. Multiple items are AND'ed together.$state \n" . + "$date \n" . + "$title \n" . + "$resp \n" . + "$syn \n" . + "`; }