home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl
-
- $HTTPD_NEWSHOME="/usr1/paul/news" ;
- $HTTPD_HOME="/usr1/paul/httpd" ;
-
- $idxdir="$HTTPD_NEWSHOME/groups";
-
- # To support an ISINDEX type search, set query string if given
- # an argument on the command line
- $prefix="query=" if ( $#ARGV >= 0 );
-
- # Check that a query has been made
- $query = $ENV{'QUERY_STRING'};
-
- # Strip the variables out from the query string,
- # and assign them into variables, prefixed by 'QS_'
- @qvars = split( /\&/, $prefix . $query );
- foreach (@qvars) {
- split(/=/);
- $fname = $_[0];
- $fvalue = $_[1];
- $fvalue =~ s/\'//g;
- $cmd = "\$QS_$fname = '$fvalue';" ;
- # print ">>>",$cmd,"\n";
- $cmd = eval $cmd if ( $fname =~ /^[a-z_A-Z]\w*$/ );
- }
- $QS_query =~ s|\+| |g;
- $QS_query =~ s|%(\w\w)|sprintf("%c", hex($1))|ge;
- $QS_query =~ s|\'|\\\'|g;
-
- if ($QS_maxlines =~ /\d+/) {
- $maxlines = $&;
- } else {
- $maxlines = 200;
- }
-
- $id = $QS_query;
- if (!$id) {
- print "Content-type: text/html\n\n";
- print "<TITLE>Search for news articles author</TITLE>\n";
- print "<H1>Search for news articles author</H1>\n";
- print "Please specify e-mail address this person posts from:\n";
- print "<ISINDEX>\n";
- exit;
- }
-
- require "look.pl";
-
- $id =~ tr/A-Z/a-z/;
- open(INDEX, "$idxdir/by_addr.idx") ||
- die "Cannot open $idxdir/by_addr.idx: $!";
- &look(INDEX,$id,undef,"casefold");
- undef @result;
- # push articles numbers in @result
- $artcount = 0;
- while (<INDEX>) {
- chop;
- split(/\t/);
- $_[0] =~ tr/A-Z/a-z/;
- last if substr($_[0],0,length($id)) gt $id;
- $artcount++;
- last if $artcount > $maxlines+3;
- push(@result,$_[1]);
- }
- close INDEX;
- if ($#result >= 0) {
- # search succeded - $id is an author
- print "Content-type: text/html\n\n";
- print "<HEAD><TITLE>Articles by $id</TITLE></HEAD>\n";
- print "<BODY><H1>Articles by $id:</H1><OL>\n";
- open(INDEX, "$idxdir/articles.db") ||
- die "Cannot open $idxdir/articles.db: $!";
- $artcount = 0;
- article: foreach $article (@result) {
- &look(INDEX,$article,undef,"casefold");
- $_ = <INDEX>;
- chop;
- s/\&/\&/;
- s/\</\</;
- s/\>/\>/;
- split(/\t/);
- $_[0] =~ tr/A-Z/a-z/;
- last if substr($_[0],0,length($article)) gt $article;
- $artcount++;
- if ($artcount > $maxlines) {
- $artcount = "at least $artcount";
- print "<LI>Limit of $maxlines articles exceeded\n";
- last article;
- }
- print "<LI><A HREF=\"/cgi-bin/article$article\">\n";
- print "$_[4]<BR><I>$_[5]</I></A>\n";
- }
- close INDEX;
- print "</OL><HR>Total of $artcount articles.\n";
- print "<P><a href=\"/cgi-bin/mfinger?$id\">\n";
- print "Look finger on $id</a>\n";
- print "</BODY>\n";
- } else {
- # search failed - maybe it's an article ID
- open(INDEX, "$idxdir/by_id.idx") ||
- die "Cannot open $idxdir/by_id.idx: $!";
- &look(INDEX,$id,undef,"casefold");
- $_ = <INDEX>;
- chop;
- split(/\t/);
- $_[0] =~ tr/A-Z/a-z/;
- close INDEX;
- if (substr($_[0],0,length($id)) gt $id) {
- # no luck - redirect to news server
- print "Location: news:$id\n\n";
- } else {
- $ENV{'PATH_INFO'} = $_[1];
- undef $ENV{'QUERY_STRING'};
- exec "$HTTPD_HOME/cgi-bin/article","getart $id";
- }
- }
-