diff --git a/en/cgi/ftp.cgi b/en/cgi/ftp.cgi index d8e48ecd7b..2029535f9c 100755 --- a/en/cgi/ftp.cgi +++ b/en/cgi/ftp.cgi @@ -1,37 +1,37 @@ -#!/usr/bin/perl +#!/usr/bin/perl -T # -# $FreeBSD$ +# $FreeBSD: www/en/cgi/ftp.cgi,v 1.3 2000/04/03 08:45:51 phantom Exp $ -require 'cgi-lib.pl'; -require 'cgi-style.pl'; +require './cgi-lib.pl'; +require './cgi-style.pl'; $newloc = "http://www.FreeBSD.org/"; print &html_header("FTP Download"); open (MIRRORS, "ftp.mirrors"); print "

Download $ARGV[0] from one of the following mirror sites:

\n"; $oldplace = ""; while () { if (/.*:.*:/ && !/^#/) { ($place, $site, $root) = split(':',$_); chop $root; $root =~ s/ *$//; if ($place ne $oldplace) { if ($oldplace ne "") { print "\n"; } print "$place\n\n"; print &html_footer; diff --git a/en/cgi/missing_handler.cgi b/en/cgi/missing_handler.cgi index a63f796ed6..d6ffe47910 100755 --- a/en/cgi/missing_handler.cgi +++ b/en/cgi/missing_handler.cgi @@ -1,109 +1,109 @@ -#!/usr/bin/perl +#!/usr/bin/perl -T # Copyright (c) Juli 1997-2000. Wolfram Schneider , Berlin. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # missing_handler.cgi - User friendly error response (Apache style) # # # default apache message: # ---------------------------------------------------------------------- # File Not found # The requested URL /~wosch/test/bla was not found on this server. # ---------------------------------------------------------------------- # # # missing_handler.cgi message: # ---------------------------------------------------------------------- # FreeBSD.org - Document not found # # The file # # http://www.FreeBSD.org/~wosch/test/bla # # does not exist at this server. You are coming from # # http://www.FreeBSD.org/~wosch/test/error.html. # # The closest match to your request is http://www.FreeBSD.org. # Please contact the server administrator wosch@FreeBSD.org. # # Thank you very much! # # _________________________________________________________________ # -# $FreeBSD: www/en/cgi/missing_handler.cgi,v 1.6 2000/01/05 15:47:44 phantom Exp $ +# $FreeBSD: www/en/cgi/missing_handler.cgi,v 1.8 2000/10/03 19:50:16 wosch Exp $ # ---------------------------------------------------------------------- # output title $title = $ENV{'MISSING_HANDLER_TITLE'} || 'FreeBSD.org - Document not found'; # footer message $footer = $ENV{'MISSING_HANDLER_FOOT'} || ''; # Server environment variables $http_referer=$ENV{'HTTP_REFERER'}; $redirect_url=$ENV{'REDIRECT_URL'}; $server_admin=$ENV{'SERVER_ADMIN'}; $http_host=$ENV{'HTTP_HOST'}; $server_name=$ENV{'SERVER_NAME'}; # rfc1738 says that ";"|"/"|"?"|":"|"@"|"&"|"=" may be reserved. $http_referer_url = $http_referer; $http_referer_url =~ s/([^a-zA-Z0-9;\/?:&=])/sprintf("%%%02x",ord($1))/eg; $redirect_url_save = $redirect_url; $redirect_url_save =~ s/([^a-zA-Z0-9;\/?:&=])/sprintf("%%%02x",ord($1))/eg; $hsty_base = ''; -require 'cgi-style.pl'; +require './cgi-style.pl'; print &html_header($title); # HTML body print qq[The file
http://$http_host$redirect_url
does not exist at this server.\n]; if ($http_referer) { print qq{You are coming from
$http_referer.

\n}; } print qq[ The closest match to your request is http://$server_name. Please contact the server administrator $server_admin.

Thank you very much!

]; print&html_footer; exit; diff --git a/en/cgi/query-pr-summary.cgi b/en/cgi/query-pr-summary.cgi index 7d6a8417fb..6cc9a042d1 100755 --- a/en/cgi/query-pr-summary.cgi +++ b/en/cgi/query-pr-summary.cgi @@ -1,554 +1,554 @@ -#!/usr/bin/perl -# $FreeBSD: www/en/cgi/query-pr-summary.cgi,v 1.28 2000/10/29 22:16:41 steve Exp $ +#!/usr/bin/perl -T +# $FreeBSD: www/en/cgi/query-pr-summary.cgi,v 1.29 2000/11/29 13:59:24 wosch Exp $ $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"; $closed_too = 0; %statemap = ( "open", "o", "analyzed", "a", "feedback", "f", "suspended", "s", "closed", "c" ); %severitymap = ( "critical", "c", "serious", "s", "non-critical", "n" ); %prioritymap = ( "high", "h", "medium", "m", "low", "l" ); -require "cgi-lib.pl"; -require "cgi-style.pl"; +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; $input{"responsible"} = $opt_r if $opt_r; $input{"state"} = $opt_s if $opt_s; $input{"quiet"} = $opt_q 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 = "

"; $h1_e = "

"; $h2 = "

"; $h2_e = "

"; $h3 = "

"; $h3_e = "

"; $h4 = "

"; $h4_e = "

"; $p = "

" ; $p_e = "

"; $br = "
"; $st = ""; $st_e = ""; $pr = "
";    $pr_e = "
"; $dl = "
"; $dl_e = "
"; $dt = "
"; $dd = "
"; $dd_x = ""; $hr = "
"; # print "Content-type: text/html\n"; } else { $h1 = ""; $h1_e = ""; $h2 = ""; $h2_e = ""; $h3 = ""; $h3_e = ""; $h4 = ""; $h4_e = ""; $p = ""; $p_e = ""; $br = ""; $st = ""; $st_e = ""; $pr = ""; $pr_e = ""; $dl = ""; $dl_e = ""; $dt = ""; $dd = " "; $dd_x = " "; $hr = "\n----------------------------------------" . "---------------------------------------\n"; } 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"; } 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 'Don',"'",'t show closed reports.'; } else { print 'Include closed reports too.'; } } } sub trailer_info { print &html_footer if $html_mode; } &header_info; #Usage: query-pr [-FhiPqVx] [-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] # [--full] [--help] [--sql] [--print-path] [--summary] [--version] # [--skip-closed] [--category=category] [--confidential=yes|no] # [--directory=directory] [--output=outfile] [--originator=name] # [--priority=level] [--class=class] [--responsible=person] # [--severity=severity] [--state=state] [--submitter=submitter] # [--list-categories] [--list-responsible] [--list-submitters] # [--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", "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)); } &trailer_info; exit(0); #------------------------------------------------------------------------ sub getline { local($_) = @_; ($tag,$remainder) = split(/[ \t]+/, $_, 2); return $remainder; } sub html_fixline { local($line) = @_[0]; $line =~ s/&/&/g; $line =~ s//>/g; $line; } sub printcnt { local($cnt) = $_[0]; if ($cnt) { printf("%d problem%s total.\n\n", $cnt, $cnt == 1 ? "" : "s"); } } sub cat_query { local($cat) = $_[0]; &printcnt(&gnats_summary("\$cat eq \"$cat\"", $html_mode)); } sub cat_summary { foreach (keys %status) { s|/\d+||; $cat{$_}++; } foreach (sort keys %cat) { &cat_query($_); } } sub resp_query { local($resp) = @_[0]; local($cnt); $cnt = &gnats_summary("\$resp eq \"$resp\"", $html_mode); print "${hr}${b}No problem reports assigned to $resp${b_e}\n" if (!$input{"quiet"} && $cnt == 0); } sub resp_summary { local($who, %who); foreach (keys %resp) { $who{$resp{$_}}++; } foreach $who (sort keys %who) { $cnt = &gnats_summary("\$resp eq \"$who\"", $html_mode); } } sub state_query { local($state) = @_[0]; print "${h3}Problems in state: $state${h3_e}\n"; $state = $statemap{$state} if ($statemap{$state} ne ''); &printcnt(&gnats_summary("\$state eq \"$state\" ", $html_mode)); } sub state_summary { foreach (sort keys %statemap) { next if ($_ eq "closed" && !$input{"closedtoo"}); &state_query($_); } } sub severity_summary { print "${h3}Critical problems${h3_e}\n"; &printcnt(&gnats_summary('$severity eq "critical"', $html_mode)); print "${h3}Serious problems${h3_e}\n"; &printcnt(&gnats_summary('$severity eq "serious"', $html_mode)); print "${h3}Non-critical problems${h3_e}\n"; &printcnt(&gnats_summary('$severity eq "non-critical"', $html_mode)); } sub get_categories { open(Q, "query-pr --list-categories 2>/dev/null |") || die "Cannot get categories\n"; while() { chop; local ($cat, $desc, $responsible, $notify) = split(/:/); push(@categories, $cat); } } sub read_gnats { local($report) = @_[0]; open(Q, "query-pr $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/); $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 = '' . $_ . ' '; } else { $title = $_; } print "$state [$date] $title" . (' ' x (12 - length($_))) . $resp . (' ' x (9 - length($resp))) . ($htmlmode ? $syn : substr($syn,0,41)) . "\n"; ++$counter; } print "${pr_e}\n" if $iteration; $counter; } sub displayform { print qq` Please select the items you wish to search for. Multiple items are AND'ed together.

Category: Severity:
Priority: Class:
State: Sort by:
Text in single-line fields: Responsible:
Text in multi-line fields: Originator:
Closed reports too:
`; } diff --git a/en/cgi/query-pr.cgi b/en/cgi/query-pr.cgi index 74b6329df7..61231e326c 100755 --- a/en/cgi/query-pr.cgi +++ b/en/cgi/query-pr.cgi @@ -1,218 +1,218 @@ -#!/usr/bin/perl -# $FreeBSD: www/en/cgi/query-pr.cgi,v 1.22 2000/12/05 16:22:14 knu Exp $ +#!/usr/bin/perl -T +# $FreeBSD: www/en/cgi/query-pr.cgi,v 1.23 2000/12/06 07:16:59 ps Exp $ $ENV{'PATH'} = "/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin"; %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'); -require "cgi-lib.pl"; -require "cgi-style.pl"; +require "./cgi-lib.pl"; +require "./cgi-style.pl"; require "getopts.pl"; &Getopts('p:'); if ($opt_p) { $input{'pr'} = $opt_p; } else { if (! &ReadParse(*input)) { print &html_header("PR Query Interface"); print "

Please enter the PR number you wish to query:

\n"; ($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|; $scriptname =~ s|/$||; ($summary = $scriptname) =~ s/query-pr/query-pr-summary/; print "
\n"; print "
\n"; print "

See also the PR summary

\n"; print &html_footer; exit 0; } } # allow query-pr.cgi? queries if (!($pr = $input{'pr'}) && &MethGet) { $pr = $ENV{'QUERY_STRING'}; } # be tolerant to / queries $pr =~ s%^.+/%%; # remove / part $pr += 0; # numeralize: "0123" -> 123, "123;evil evil evil" -> 123, etc. if ($pr < 1 || $pr > 99999) { print &html_header("FreeBSD Problem Report"); print "

Invalid problem report number: $pr

\n"; print &html_footer; exit 0; } unless (open(Q, "query-pr --restricted -F $pr 2>&1 |")) { print &html_header("Server error"); print "

Unable to open PR database.

\n"; print &html_footer; die "Unable to query PR's"; } if ($input{'f'} eq 'raw') { print "Content-Type: text/plain\r\n\r\n"; print ; close(Q); exit 0; } $inhdr = 1; $multiline = 0; $from = ""; $replyto = ""; while() { chop; $html_fixup = 1; if (/^query-pr: /) { print &html_header("FreeBSD problem report"); if ($_ ne "query-pr: no PRs matched") { print "

query-pr said:\n"; print "

$_\n";
 	    print ;
 	    print "
\n"; } elsif (($* = 1) && `query-pr $pr 2>&1` =~ /^>Confidential:\s+yes/) { print "

Sorry, PR $pr exists but is confidential\n"; } else { print "

No PR found matching $pr\n"; } print &html_footer; exit; } # In e-mail header if ($inhdr && /^From:\s*(.*)$/i) { $from = $1; $from =~ s/.*<(.*)>.*/$1/; $from =~ s/\s*\(.*\)\s*//; } if ($inhdr && /^Reply-to:\s*(.*)$/i) { $replyto = $1; $replyto =~ s/.*<(.*)>.*/$1/; $replyto =~ s/\s*\(.*\)\s*//; } # End of e-mail header if ($inhdr && /^$/) { $from = $replyto if ($replyto); $email = $from; $email .= '@FreeBSD.org' unless ($email =~ /@/); $inhdr = 0; } if (/^>Responsible:/) { $_ = &getline($_); s/\(.*\)//; # remove personal name s/\s+//g; $_ = $_ . '@FreeBSD.org' if !/@/; $_ = '>Responsible:' . $_ . ''; $html_fixup = 0; } s/^>Last-Modified:\s*$/>Last-Modified: never/; if (/^>Number:/) { $number = &getline($_); } elsif (/^>Category:/) { $cat = &getline($_); } elsif (/^>Synopsis:/) { $syn = &getline($_); $syn =~ s/[\t]+/ /g; $origsyn = $syn; $syn = &fixline($syn); print &html_header("Problem Report $cat/$number"); print "$syn

\n

\n"; } else { next if $inhdr; if (/^>(\S+):\s*(.*)/) { print $trailer . "\n" unless ($blank); $trailer = "
$1
\n"; if ($html_fixup) { $trailer .= &fixline($2); } else { $trailer .= $2; } if ($1 eq "Originator" && $from ne "") { # add email address $trailer .= " <" . &fixline($from) . ">"; } $blank = !($2); $multiline = 0; } else { unless ($multiline) { next if /^\s*$/; print $trailer . "\n
\n";
 	    }
 	    $multiline = 1;
 	    $blank = 0;
 	    print $html_fixup ? &fixline($_) : $_ , "\n";
 	    $trailer = "
"; } } } close(Q); print "$trailer\n" unless ($blank); print "
"; $origsyn =~ s/[^a-zA-Z+.@-]/"%" . sprintf("%02X", unpack("C", $&))/eg; $email =~ s/[^a-zA-Z+.@-]/"%" . sprintf("%02X", unpack("C", $&))/eg; print qq`Submit Followup | Raw PR\n`; print &html_footer; exit 0; sub getline { local($_) = @_; ($tag,$remainder) = split(/[ \t]+/, $_, 2); return $remainder; } sub cvsweb { local($file) = shift; $file =~ s/[,.;]$//; return 'http://www.FreeBSD.org/cgi/cvsweb.cgi/' . $file; } sub srcref { local($_) = shift; local($rev) = '(rev\.?|revision):?\s+[0-9]\.[0-9.]+(\s+of)?'; local($src) = '((src|www|doc|ports)/[^\s]+)'; if (m%$rev\s*$src%oi || m%$src\s*$rev%) { s#$src#sprintf("%s", 34, &cvsweb($1), 34, $1)#ge; } return $_; } sub fixline { local($line) = shift; $line =~ s/&/&/g; $line =~ s//>/g; $line =~ s%((http|ftp)://[^\s"\)\>,;]+)%$1%gi; $line =~ s%(\WPR[:s# \t]+)([a-z386]+\/)?([0-9]+)%$1$2$3%ig; return &srcref($line); } diff --git a/en/cgi/search.cgi b/en/cgi/search.cgi index b3f945e0e5..326eff5470 100755 --- a/en/cgi/search.cgi +++ b/en/cgi/search.cgi @@ -1,268 +1,268 @@ -#!/usr/bin/perl +#!/usr/bin/perl -T # # mail-archive.pl -- a CGI interface to a wais indexed maling list archive. # # Origin: # Tony Sanders , Nov 1993 # # Hacked beyond recognition by: # John Fieber , Nov 1994 # # Format the mail messages a little nicer. # Add code to check database status before searching. # John Fieber , Aug 1996 # # Disclaimer: # This is pretty ugly in places. # -# $FreeBSD: www/en/cgi/search.cgi,v 1.18 2000/10/28 18:20:39 wosch Exp $ +# $FreeBSD: www/en/cgi/search.cgi,v 1.19 2000/11/05 19:05:43 wosch Exp $ $server_root = '/usr/local/www'; $waisq = "/usr/local/www/bin/waisq"; $sourcepath = "$server_root/db/index"; $hints = "/search/searchhints.html"; $searchpage = '/search/search.html'; $myurl = $ENV{'SCRIPT_NAME'}; require "open2.pl"; -require "cgi-lib.pl"; -require "cgi-style.pl"; +require "./cgi-lib.pl"; +require "./cgi-style.pl"; @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); sub do_wais { &ReadParse; @FORM_words = split(/ /, $in{"words"}); @FORM_source = split(/\0/, $in{"source"}); $FORM_max = $in{"max"}; $FORM_docnum = $in{"docnum"}; $FORM_index = $in{"index"}; if ($FORM_index =~ /^re[sc]ent$/) { $sourcepath = "$server_root/db/index-recent"; } if ($#FORM_words < 0) { print &html_header("Mail Archive Search") . "

No search term given."; print "

\nPlease return to the " . "search page and fill out the 'Search for' field!\n"; print &html_footer; exit 0; } @AVAIL_source = &checksource(@FORM_source); if ($#FORM_source != $#AVAIL_source) { $j = 0; $k = 0; foreach $i (0 .. $#FORM_source) { if ($FORM_source[$i] ne $AVAIL_source[$j]) { $badsource[$k] = $FORM_source[$i]; $k++; } else { $j++; } } $badsource = join(", ", @badsource); $badsource =~ s/,([^,]*)$/ and $1/; if ($#FORM_source - $#AVAIL_source > 1) { $availmsg = "

[The $badsource archives are currently unavailable.]

"; } else { $availmsg = "

[The $badsource archive is currently unavailable.]

"; } } if ($#AVAIL_source < 0) { $i = join("
, ", @FORM_source); $i =~ s/,([^,]*)$/ and $1/; print &html_header("Mail Archive Search") . "

None of the archives you requested ($i) are " . " available at this time.

\n"; print "

Please try again later, or return to the " . "search page and select a different archive.

\n"; print &html_footer; exit 0; } # Now we formulate the question to ask the server foreach $i (@AVAIL_source) { $w_sources .= "(:source-id\n :filename \"$i.src\"\n ) "; } $w_question = "\n (:question :version 2 :seed-words \"@FORM_words\" :relevant-documents ( ) :sourcepath \"$sourcepath/:\" :sources ( $w_sources ) :maximum-results $FORM_max :result-documents ( ) )\n"; # # First case, no document number so this is a regular search # print &html_header("Search Results"); print $availmsg; if ($#AVAIL_source > 0) { $src = join("
, ", @AVAIL_source); $src =~ s/,([^,]*)$/ and $1/; print "

The archives $src contain "; } else { print "The archive @AVAIL_source contains "; } print " the following items relevant to \`@FORM_words\':\n"; print "

    \n"; &open2(WAISOUT, WAISIN, $waisq, "-g"); print WAISIN $w_question; local(@mylist) = (); local($hits, $score, $headline, $lines, $bytes, $docid, $date, $file); while () { /:original-local-id.*#\(\s+([^\)]*)/ && ($docid = pack("C*", split(/\s+/, $1)), $docid =~ s/\s+/+/g); /:score\s+(\d+)/ && ($score = $1); /:filename "(.*)"/ && ($file = $1); /:number-of-lines\s+(\d+)/ && ($lines = $1); /:number-of-bytes\s+(\d+)/ && ($bytes = $1); /:headline "(.*)"/ && ($headline = $1, $headline =~ s/[Rr]e://); # XXX /:date "(\d+)"/ && ($date = $1, $hits++, push(@mylist, join("\t", $date, $headline, $docid, $bytes, $lines, $file, $score, $hits))); } if ($in{'sort'} eq "date") { foreach (reverse sort {$a <=> $b} @mylist) { ($date, $headline, $docid, $bytes, $lines, $file, $score, $hits) = split("\t"); &docdone; } } elsif ($in{'sort'} eq "subject") { local(@a, @c, $b, $d); foreach (@mylist) { @a = split("\t"); $b = $a[0]; # swap date and subject if ($a[1] =~ /(^[^:]+)(Re:.*)/) { $a[0] = "$2\t$1"; } else { $a[0] = "$a[1]\t."; } $a[1] = $b; push(@c, join("\t", @a)); } local($subject, $author); foreach (sort {$a cmp $b} @c) { ($subject, $author, $date, $docid, $bytes, $lines, $file, $score, $hits) = split("\t"); $headline = $author . $subject; &docdone; } } elsif ($in{'sort'} eq "author") { local(@a, @c, $b); foreach (@mylist) { @a = split("\t"); # swap date and subject $b = $a[0]; $a[0] = $a[1]; $a[1] = $b; push(@c, join("\t", @a)); } foreach (sort {$a cmp $b} @c) { ($headline, $date, $docid, $bytes, $lines, $file, $score, $hits) = split("\t"); &docdone; } } else { foreach (@mylist) { ($date, $headline, $docid, $bytes, $lines, $file, $score, $hits) = split("\t"); &docdone; } } #print qq[in: $in{'sort'}\n]; print "
\n"; print "

Didn't get what you expected? "; print "Look here for searching hints.

"; print qq{

Return to the search page

\n}; if ($hits == 0) { print "Nothing found.\n"; } print &html_footer; close(WAISOUT); close(WAISIN); } # Given an array of sources (sans .src extension), this routine # checks to see if they actually exist, and if they do, if they # are currently available (ie, not being updated). It returns # an array of sources that are actually available. sub checksource { local (@sources) = @_; $j = 0; foreach $i (@sources) { if (stat("$sourcepath/$i.src")) { if (!stat("$sourcepath/$i.update.lock")) { $goodsources[$j] = $i; $j++; } } } return(@goodsources); } sub htmlescape { local ($data) = @_; $data =~ s/&/&/g; $data =~ s/The archive $file contains no relevant documents.

" } else { $headline = &htmlescape($headline); $headline =~ s/\\"/\"/g; if ($file eq "www" || $file eq 'pkgdescr') { print "
  • $headline\n"; } else { print "
  • $headline\n"; } print "
    "; # print ""; print "Score: $score; "; $_ = $date; /(...?)(..)(..)/ && ($yr = $1 + 1900, $mo = $months[$2 - 1], $dy = $3); print "Lines: $lines; "; print "${dy}-${mo}-${yr}; "; print "Archive: $file"; print "

  • \n"; } $score = $headline = $lines = $bytes = $docid = $date = $file = ''; $yr = $mo = $dy = ''; } $| = 1; open (STDERR,"> /dev/null"); #open (STDERR,">> /tmp/search"); eval '&do_wais';