ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/Search/trunk/search.cgi.in
Revision: 232
Committed: 2003-08-07T15:58:21-07:00 (19 years, 6 months ago) by douglas
Original Path: trunk/Search/search.cgi.in
File size: 1247 byte(s)
Log Message:
Made search.cgi.in the automake way. And added some better error checking to it.
Added a check for which perl to configure.ac.

File Contents

# Content
1 #!@which_perl@
2 #
3 # Douglas Thrift's Search Engine CGI Script
4 #
5 # Douglas Thrift
6 #
7 # $Id: search.cgi.in,v 1.2 2003/08/07 22:58:21 douglas Exp $
8
9 use strict;
10 use CGI qw/:standard :cgi/;
11 use File::Temp qw/ tempfile tempdir /;
12
13 my $prefix = "@prefix@";
14 my $exec_prefix = "@exec_prefix@";
15 my $bindir = "@bindir@";
16 my $search = "$bindir/Search@EXEEXT@";
17
18 open(TEST, "< $search") || die "$0: cannot open $search";
19 close(TEST);
20
21 my $page = param('p');
22 my $query = param('q');
23
24 # These can be edited to customize your configuration:
25 my $data = "$prefix/data";
26 my $index = "$data/*.xml";
27 my $header = "$data/header.html";
28 my $body = "$data/body.html";
29 my $footer = "$data/footer.html";
30 my $notfound = "$data/notfound.html";
31 my $pages = "$data/pages.html";
32 #
33
34 if ($page == 0)
35 {
36 $page = 1;
37 }
38
39 my ($temphandle, $temp) = tempfile();
40
41 open($temphandle, "> $temp") || die "$0: cannot open $temp";
42 print $temphandle "$query\n";
43 close $temphandle;
44
45 open(SEARCH, "$search $index -P $page -h $header -b $body -f $footer -n " .
46 "$notfound -p $pages <$temp |" ) || die "$0: cannot fork $!";
47
48 print "Content-Type: text/html
49
50 ";
51
52 my $line;
53 while($line = <SEARCH>)
54 {
55 chomp($line);
56 print "$line\n";
57 }
58
59 unlink $temp;
60 close(SEARCH) || die "$0: cannot close $search: $!";