#!/sw/local/bin/perl -- use base; use CGI; require "hostname.pl"; # $ENV{PATH} = "/bin:/usr/bin:/usr/local/bin:/usr/gnu/bin"; # ---------------------------------------------------------------------- # Configuration variables. $hostname = hostname; if ($hostname eq "twilight") { $datdir = "F:/adv/adventure"; } else { $datdir = "/home/sites/www.if-legends.org/users/adventure/web"; } $debug = 0; # End of configuration variables. #---------------------------------------------------------------------- #$game_file = "$datdir/search.dat"; $game_file = "search.dat"; open(GAMES, "$game_file") || die("Can't open $game_file!"); $req = new CGI; $r_mode = $req->param('mode'); $r_string = $req->param('string'); $r_game = $req->param('game'); $r_year = $req->param('year'); $r_company = $req->param('company'); $r_type = $req->param('type'); $r_author = $req->param('author'); print $req->header; print "Adventureland: Search Results\n"; print "\n"; print "

Adventureland: Search Results

\n"; print "


\n"; $hits = 0; if ($r_mode eq "game") { $r_game = $r_string; } elsif ($r_mode eq "year") { $r_year = $r_string; } elsif ($r_mode eq "company") { $r_company = $r_string; } elsif ($r_mode eq "type") { $r_type = $r_string; } elsif ($r_mode eq "author") { $r_author = $r_string; } print "

Search was: $r_mode = $r_string\n" if ($r_mode); while ($line = ) { ($company, $s_company, $game, $s_game, $year, $type, $author) = split(/\t/, $line); $year =~ s/\s+$//; if ($r_game) { next unless $game =~ m/$r_game/i; } elsif ($r_year) { next unless $year =~ m/$r_year/; } elsif ($r_company) { next unless $company =~ m/$r_company/i; } elsif ($r_type) { next unless $type =~ m/\b$r_type\b/i; } elsif ($r_author) { next unless $author =~ m/$r_author/i; } print "

$company: $game" . ($year ? " ($year)" : "") . "\n"; $hits++; } print "

$hits game" . ($hits == 1 ? "" : "s") . " match your query.\n"; print "


\n" if ($debug); print "
game = $r_game\n" if ($debug); print "
year = $r_year\n" if ($debug); print "
company = $r_company\n" if ($debug); print "
type = $r_type\n" if ($debug); print "
Looking in $datdir with host '$hostname'.\n" if ($debug); print "


\n"; print "

Adventureland was created by Hans Persson and is now maintained by Stefan Meier (adventureland\@if-legends.org).\n"; print "

If you find any errors or have information that is missing, please let me know.\n"; print "\n"; print $req->end_html;