#!/usr/local/bin/perl -w

# redirect old AceDB pages to browser with the correct parameters

use strict;
use CGI qw(:standard);

my $query=param('name') || param('query') || param('study') || param('class') ;

$query =~ s/(.)_image$/$1/;

my $newpage=
    (param('class') eq 'Reference' && $query=~/^[A-Z].*-[12]\d\d\d/) 
    ? "/db/literature/pub_search?acedb=".escapeHTML($query)
    : '/db/searches/browser'
	.($query ? "?RGN=1&search_type=All&query=".escapeHTML($query)
	         : '' )
    ;

print redirect( -status => 301	# Permanent
		    #maybe more logical, but less convenient: 303  #See Other
	,-type => 'text/html'
        ,-location => 'http://'
	    . (virtual_host() || server_name() )
	    . (server_port() != 80 ? ":".server_port()
	                           : '' )
	    . $newpage
	);


