summaryrefslogtreecommitdiffstats
path: root/cgi-bin/htsearch
blob: a4b733a3e494218c258c469198820cf1e5263cb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl
use CGI;
my $q = new CGI;
my $nq = new CGI({});
my %methods = ('and'=>'all', 'or'=>'any', 'boolean'=>'bool');
my %sorts = ('time'=>'D', 'revtime'=>'d', 'score'=>'RP', 'revscore'=>'rp', 'title'=>'SRPD&su=title', 'revtitle'=>'srpd&su=title');
open(FOO, '>>/tmp/deleteme');
open(STDERR, '>&FOO');
$nq->param('wm', 'wrd');
$nq->param('form', 'extended');
for my $f ($q->param) {
    my @val = $q->param($f);
    if ($f eq 'restrict') {
	$nq->param('ul', $val[0] . '%') if length $val[0];
    } elsif ($f eq 'method') {
	my $m = $methods{lc $val[0]};
	$nq->param('m', $m);
    } elsif ($f eq 'sort') {
	my $s = $sorts{$val[0]};
	$nq->param('s', $s) if $s;
    } elsif ($f eq 'words') {
	$nq->param('q', @val);
    }
}

my $cmd = $nq->url(-relative=>1, -query=>1);

$cmd =~ s/^.*?\?/?/;
0 while $cmd =~ s/;/&/g;

print FOO $cmd, "\n";

print $nq->redirect("https://gcc.gnu.org/cgi-bin/search.cgi" . $cmd);
exit 0;
exec '/www/cgi-bin/search.cgi', $cmd;