#!/usr/bin/perl -T
# $FreeBSD: www/en/cgi/query-pr-summary.cgi,v 1.50 2005/09/12 20:30:25 remko 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) {
$pr = '
'; $pr_e = '
';
$h1 = ''; $h1_e = '
';
$h3 = ''; $h3_e = '
';
$table = "';
# Customizations for the look and feel of the summary tables.
$t_style = "";
} else {
$pr = ''; $pr_e = '';
$h1 = ''; $h1_e = '';
$h3 = ''; $h3_e = '';
$table = '';
$table_e = '';
}
sub cgiparam {
local ($result) = @_;
$result =~ s/[^A-Za-z0-9+.@-]/"%".sprintf("%02X", unpack("C", $&))/ge;
$result;
}
sub header_info {
if ($html_mode) {
print &html_header("Current $project problem reports");
}
else {
print "Current $project problem reports\n";
}
if (!$input{'quiet'}) {
print "The following is a listing of current problems submitted by $project users. " .
'These represent problem reports covering all versions including ' .
'experimental development code and obsolete releases. ';
if ($html_mode) {
print <
Bugs can be in one of several states:
- o - open
- A problem report has been submitted, no sanity checking
performed.
- a - analyzed
- The problem is understood and a solution is being sought.
- f - feedback
- Further work requires additional information from the originator
or the community - possibly confirmation of the effectiveness of a
proposed solution.
- p - patched
- A patch has been committed, but some issues (MFC and / or
confirmation from originator) are still open.
- r - repocopy
- The resolution of the problem report is dependent on a repocopy
operation within the CVS repository which is awaiting completion.
- s - suspended
- The problem is not being worked on, due to lack of information or
resources. This is a prime candidate for somebody who is looking for a
project to do. If the problem cannot be solved at all, it will be
closed, rather than suspended.
- c - closed
- A problem report is closed when any changes have been integrated,
documented, and tested -- or when fixing the problem is abandoned.
EOM
} else {
print <You may view summaries by Severity, ";
$self_ref1 .= '&' if ($self_ref1 !~/\?$/);
print "State, ";
print "Category, or ";
print "Responsible Party.";
$self_ref2 = $self_ref . '?';
foreach ('category', 'originator', 'priority', 'class', 'responsible',
'severity', 'state', 'submitter', 'text', 'multitext', 'closedtoo') {
if ($input{$_}) {
$self_ref2 .= '&' if ($self_ref2 !~/\?$/);
$self_ref2 .= $_ . '=' . cgiparam($input{$_});
}
}
print 'You may also sort by ';
print "Last-Modified, ";
print "Category, or ";
print "Responsible Party.\n";
print "Or formulate a specific query.\n";
$self_ref3 = $self_ref . '?';
foreach ('category', 'originator', 'priority', 'class', 'responsible',
'severity', 'state', 'submitter', 'text', 'multitext', 'sort') {
if ($input{$_}) {
$self_ref3 .= '&' if ($self_ref2 !~/\?$/);
$self_ref3 .= $_ . '=' . cgiparam($input{$_});
}
}
if ($input{'closedtoo'}) {
print "Do not show closed reports.";
} else {
print "Include closed reports too.";
}
}
}
&header_info;
#Usage: query-pr [-FGhiPRqVx] [-C confidential] [-c category] [-d directory]
# [-e severity] [-m mtext] [-O originator] [-o outfile] [-p priority]
# [-L class] [-r responsible] [-S submitter] [-s state] [-t text]
# [-b date] [-a date] [-B date] [-M date] [-z date] [-Z date]
# [-y synopsis] [-A release] [--full] [--help] [--print-path] [--version]
# [--summary] [--sql] [--skip-closed] [--category=category]
# [--confidential=yes|no] [--directory=directory] [--output=outfile]
# [--originator=name] [--priority=level] [--class=class]
# [--responsible=person] [--release=release] [--restricted]
# [--quarter=quarter] [--keywords=regexp]
# [--required-before=date] [--required-after=date]
# [--arrived-before=date] [--arrived-after=date]
# [--modified-before=date] [--modified-after=date]
# [--closed-before=date] [--closed-after=date]
# [--severity=severity] [--state=state] [--submitter=submitter]
# [--list-categories] [--list-classes] [--list-responsible]
# [--list-states] [--list-submitters] [--list-config]
# [--synopsis=synopsis] [--text=text] [--multitext=mtext] [PR] [PR]...
$query_args .= ' --skip-closed' unless $closed_too;
# Only read the appropriate PR's.
foreach ('category', 'originator', 'priority', 'class', 'responsible',
'release', 'severity', 'state', 'submitter', 'text', 'multitext') {
if ($input{$_} && $input{$_} ne 'summary') {
$d = $input{$_};
$d =~ s/^"(.*)"$/$&/;
$d =~ s/'/\\'/;
$query_args .= " --${_}='$d'";
}
}
&read_gnats($query_args);
if ($input{'sort'} eq 'lastmod') {
@prs = sort {$lastmod{$b} cmp $lastmod{$a}} @prs;
} elsif ($input{'sort'} eq 'category') {
@prs = sort {($ca,$na)=split(m|/|,$a); ($cb,$nb)=split(m|/|,$b); $ca eq $cb ? $na <=> $nb : $ca cmp $cb} @prs;
} elsif ($input{'sort'} eq 'responsible') {
@prs = sort {$resp{$a} cmp $resp{$b}} @prs;
} else {
$input{'sort'} = 'none';
}
if ($#prs < $[) {
print "${h1}No matches to your query${h1_e}\n";
} elsif ($input{'responsible'} eq 'summary') {
&resp_summary;
} elsif ($input{'state'} eq 'summary') {
&state_summary;
} elsif ($input{'category'} eq 'summary') {
&cat_summary;
} elsif ($input{'severity'} eq '') {
&severity_summary;
} else {
&printcnt(&gnats_summary(1, $html_mode));
}
print &html_footer if $html_mode;
print "\n