3
# Copyright 2001,2004 by Stefan Hornburg (Racke) <racke@linuxia.de>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public
16
# License along with this program; if not, write to the Free
17
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20
$ENV{'PATH'} = '/bin';
21
# Avoid taint problems when any of these environment variables are defined.
22
# See perlsec(1) manpage
23
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
26
use CGI qw/:standard/;
29
use lib qw(/usr/lib/swish++);
35
print header() unless param('file');
36
print start_html(-title=>'Debian Online Help: Search Result',
37
-author=>'dhelp@packages.debian.org'), "\n";
39
print img({src=>'file:/usr/share/doc/dhelp/debian.jpg',alt=>'Debian GNU/Linux'}), "\n";
41
print img({src=>'/doc/dhelp/debian.jpg',alt=>'Debian GNU/Linux'}), "\n";
45
unless (-x '/usr/bin/search++') {
46
print "No search engine installed. Please install swish++.<BR>";
51
unless (-f '/var/lib/dhelp/swish++.index') {
52
print q{No search database found.<BR>
53
Please run /etc/cron.weekly/dhelp as superuser to create it.<BR>};
58
# Fetch, untaint and check search parameter
59
my $search = param('search');
60
$search =~ m/([\w\d\@._-]+)/;
63
if ($search !~ /\S/) {
64
print "Please specify a search token.<BR>";
69
# Pass parameters to Swish++ search program
71
or exec '/usr/bin/search++', '-i', '/var/lib/dhelp/swish++.index', $search;
77
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
81
# Read the search results back.
85
if ( /^\# ignored: / ) {
87
# Get the ignored words so we can report them to the user.
93
if ( /^\# results: (\d+)/ && ! $1) {
96
print "No results (Ignored: $ignored).<BR>";
98
print "No results.<BR>";
104
# Future releases of SWISH++ may emit other comments: ignore ones we
109
my( $rank, $file, $size, $title ) = split( / /, $_, 4 );
111
my $desc = WWW::extract_description( "$file" );
112
WWW::hyperlink( $desc );
113
$size = int( $size / 1024 );
120
$file = "file:$file";
122
$file =~ s%^/usr/share/%/%;
124
unless ($title =~ /\S/ ) {
128
<TR VALIGN=top><TD ALIGN=right>$rank% </TD>
129
<TD><DL><DT><B><A HREF="$file">$title</A></B> ($size)<DD>$desc</DL></TD>
134
print "$chunk</TABLE>\n";
139
print end_html(), "\n";