#!/usr/local/bin/perl
#########################################################
#                                                       #
#                     RedirectPro                       #
#                                                       #
#########################################################
#                                                       #
#                      admin.pl                         #
#                                                       #
#   Configure this script by filling in the variables   #
#   below. After that put all three scripts into your   #
#   CGI-BIN and CHMOD them 755. Put the datafile into   #
#   into a non-web accessable directory (if you don't   #
#   have access to one a web accessable directory will  #
#   work but is much less secure) and CHMOD it 777.     #
#                                                       #
#   If you have any further questions, direct them to   #
#   the support forum at http://www.go2cgi.com/         #
#                                                       #
#########################################################
#                                                       #
#         Copyright © 1999 W. Dustin Alligood           #
#                                                       #
#########################################################

# The path to the datafile
$datafile='data.txt';

# The URL to this script
$script='admin.pl';

# Path to the redirect.pl script relative to the
# member's directories
$rescript='../redirect.pl';

# Path to the directory users accounts are stored in
$redirect='/data1/hypermart.net/go2/redirect';

# Exention needed to parse for SSI
$ext='shtml';

# Admin password
$password='password';

# The path to the countries data file
$countries='countries.txt';

# Change nothing below this line
#########################################################


$errtype='Admin';

if ($ENV{'QUERY_STRING'} eq "do=showall$password")
{
	&steptwo;
}
if($ENV{'QUERY_STRING'} =~ /do=addcount$password/)
{
	&stepeight;
}
if($ENV{'QUERY_STRING'} =~ /do=countdel$password/)
{
	&stepnine;
}
if($ENV{'QUERY_STRING'} =~ /do=editcount$password/)
{
	&stepten;
}
elsif ($ENV{'QUERY_STRING'} =~ /do=edit$password/)
{
	&stepthree;
}
elsif ($ENV{'QUERY_STRING'} =~ /do=edit2$password/)
{
	&stepfour;
}
elsif ($ENV{'QUERY_STRING'} =~ /do=delete$password/)
{
	&stepfive;
}
elsif ($ENV{'QUERY_STRING'} =~ /do=ads$password/)
{
	&stepsix;
}
elsif ($ENV{'QUERY_STRING'} =~ /do=count$password/)
{
	&stepseven;
}
elsif ($ENV{'QUERY_STRING'} eq "do=$password")
{
	&stepone;
}
else{
	&into;
}

sub stepten
{
	print "Content-type: text/html\n\n";
	@fval=split(/&/,$ENV{'QUERY_STRING'});
	foreach $i (0 .. $#fval){
		($name,$val)=split (/=/,$fval[$i],2);
		$val=~tr/+/ /;
		$val=~ s/%(..)/pack("c",hex($1))/ge;
		$name=~tr/+/ /;
		$name=~ s/%(..)/pack("c",hex($1))/ge;
		$field{$name}=$val;
	}
	open(FILE,"<$countries");
	@cnt=<FILE>;
	close(FILE);
	$nu=0;
	$s=0;
	foreach $item (@cnt){
		($n,$p,$d,$h)=split(/\|/,$item);
		if ($n eq $field{'name'}){
			if($s==0){
				@cnt[$nu]="$field{'name'}|$field{'popup'}|$field{'delay'}|$field{'html'}\n";
				$s=1;
			}
		}
		$nu++;
	}
	@newcnt=sort(@cnt);
	open(FILE,">$countries");
	foreach $item (@newcnt){
		if ($item=~/Other\|http:\/\//i){
		$other=$item;
		}else{
		print FILE "$item";
		}
	}
	print FILE "$other";
	close(FILE);

	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\"><input type=hidden name=do value=$password>\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white><tr><td bgcolor=blue>\n";
	print "<font face=arial color=white>RedirectPro Admin</font>\n";
	print "</td></tr><tr><td>\n";
	print "<center><TABLE PADDING=5>\n";
	print "<TR><TD>\n";

	print "<p><center>The country \"$field{'name'}\" has been edited.</center></p>\n";
	print "<p><center><p><input type=Submit value=\"Okay\"></p></center>\n";

	print "</td></tr></table></center></td></tr></table></center></p>\n";
	print "</form></body></html>\n";
	exit 0 ;


}

sub stepnine
{
	print "Content-type: text/html\n\n";
	@fval=split(/&/,$ENV{'QUERY_STRING'});
	foreach $i (0 .. $#fval){
		($name,$val)=split (/=/,$fval[$i],2);
		$val=~tr/+/ /;
		$val=~ s/%(..)/pack("c",hex($1))/ge;
		$name=~tr/+/ /;
		$name=~ s/%(..)/pack("c",hex($1))/ge;
		$field{$name}=$val;
	}
	open(FILE,"<$countries");
	@cnt=<FILE>;
	close(FILE);
	$nu=0;
	$s=0;
	foreach $item (@cnt){
		($n,$p,$d,$h)=split(/\|/,$item);
		if ($n eq $field{'name'}){
			if($s==0){
				@cnt[$nu]="000000000A|A|A|A\n";
				$s=1;
			}
		}
		$nu++;
	}
	@newcnt=sort(@cnt);
	if($s==1){
		shift(@newcnt);
	}
	open(FILE,">$countries");
	foreach $item (@newcnt){
		if ($item=~/Other\|http:\/\//i){
		$other=$item;
		}else{
		print FILE "$item";
		}
	}
	print FILE "$other";
	close(FILE);

	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\"><input type=hidden name=do value=$password>\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white><tr><td bgcolor=blue>\n";
	print "<font face=arial color=white>RedirectPro Admin</font>\n";
	print "</td></tr><tr><td>\n";
	print "<center><TABLE PADDING=5>\n";
	print "<TR><TD>\n";

	print "<p><center>The country \"$field{'name'}\" has been deleted.</center></p>\n";
	print "<p><center><p><input type=Submit value=\"Okay\"></p></center>\n";

	print "</td></tr></table></center></td></tr></table></center></p>\n";
	print "</form></body></html>\n";
	exit 0 ;


}
sub stepeight
{
	@fval=split(/&/,$ENV{'QUERY_STRING'});
	foreach $i (0 .. $#fval){
		($name,$val)=split (/=/,$fval[$i],2);
		$val=~tr/+/ /;
		$val=~ s/%(..)/pack("c",hex($1))/ge;
		$name=~tr/+/ /;
		$name=~ s/%(..)/pack("c",hex($1))/ge;
		$field{$name}=$val;
	}
	open(FILE,"<$countries");
	@cnt=<FILE>;
	close(FILE);
	push(@cnt,"$field{'name'}|$field{'popup'}|$field{'delay'}|$field{'html'}");
	@newcnt=sort(@cnt);
	open(FILE,">$countries");
	foreach $item (@newcnt){
		if ($item=~/Other\|http:\/\//i){
		$other=$item;
		}else{
		print FILE "$item";
		}
	}
	print FILE "$other";
	close(FILE);
	

	print "Content-type: text/html\n\n";
	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\"><input type=hidden name=do value=$password>\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white><tr><td bgcolor=blue>\n";
	print "<font face=arial color=white>RedirectPro Admin</font>\n";
	print "</td></tr><tr><td>\n";
	print "<center><TABLE PADDING=5>\n";
	print "<TR><TD>\n";

	print "<p><center>The country \"$field{'name'}\" has been added.</center></p>\n";
	print "<p><center><p><input type=Submit value=\"Okay\"></p></center>\n";

	print "</td></tr></table></center></td></tr></table></center></p>\n";
	print "</form></body></html>\n";
	exit 0 ;
}

sub stepseven
{
	print "Content-type: text/html\n\n";
	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\">\n";
	print "<input type=hidden name=\"do\" value=\"editcount$password\">\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white width=390><tr><td bgcolor=blue>\n";
	print "<font face=arial color=white>RedirectPro Admin</font>\n";
	print "</td></tr><tr><td>\n";
	print "<TABLE PADDING=5>\n";
	print "<TR><TD>\n";

	print "<b>Edit Country:</b><br>For the country <SELECT NAME=\"name\">\n";
	open (FILE,"<$countries");
		@cntes=<FILE>;
	close(FILE);
	foreach $cnty (@cntes){
		($c,$p,$d,$h)=split(/\|/,$cnty);
		print "<OPTION VALUE=\"$c\">$c\n";
	}
	print "</SELECT> the popup's URL is \n";
	print "<input type=text size=20 name=\"popup\" value=\"http://\">,\n";
	print "the path to the delay file is \n";
	print "<input type=text size=20 name=\"delay\" value=\"/\">,\n";
	print "and the HTML a user must put on their page if they opt to is \n";
	print "<input type=text size=20 name=\"html\" value=\"\">.\n";
	print "<center><input type=Submit value=\"Edit Country\"></center>\n";
	print "<br><br>\n";
	print "</form><form action=\"$script\" method=\"get\">\n";
	print "<input type=hidden name=\"do\" value=\"addcount$password\">\n";
	print "<b>Add New Country:</b><br>The Country's name is <input type=text size=15 name=\"name\"value=\"\">,  the popup's URL is \n";
	print "<input type=text size=20 name=\"popup\" value=\"http://\">,\n";
	print "the path to the delay file is \n";
	print "<input type=text size=20 name=\"delay\" value=\"/\">,\n";
	print "and the HTML a user must put on their page if they opt to is \n";
	print "<input type=text size=20 name=\"html\" value=\"\">.\n";
	print "<center><input type=Submit value=\"Add Country\"></center>\n";
	print "<br><br>\n";
	print "</form><form action=\"$script\" method=\"get\"><input type=hidden name=\"do\" value=\"countdel$password\">\n";
	print "<b>Delete Country:</b><br>The Country's name is <input type=text size=20 name=\"name\" value=\"\">.\n";
	print "<center><input type=Submit value=\"Delete Country\"></center>\n";
	print "<p>&nbsp;</p><p>&nbsp;</p>\n";
	print "</form><form action=\"$script\" method=\"get\">\n";
	print "<input type=hidden name=\"do\" value=\"$password\">\n";
	print "<center><input type=Submit value=\"Return to Admin Menu\"></center>\n";
	print "</td></tr></table></td></tr></table></center></p>\n";
	print "</form></body></html>\n";
	exit 0 ;
}
sub into
{
	print "Content-type: text/html\n\n";
	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\">\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white><tr><td bgcolor=blue>\n";
	print "<font face=arial color=white>RedirectPro Admin</font>\n";
	print "</td></tr><tr><td>\n";
	print "<TABLE PADDING=5>\n";
	print "<TR><TD>\n";

	print "<center><p>Password: <input type=\"password\" name=\"do\" size=30></p><p><input type=Submit value=\"Okay\"></p></center>\n";

	print "</td></tr></table></td></tr></table></center></p>\n";
	print "</form></body></html>\n";
	exit 0 ;
}
sub stepsix
{
	@acco=split(/=/,$ENV{'QUERY_STRING'});
	$acc=@acco[2];
	if($acc eq ''){
		$message='No account name entered';
		&PrintError;
	}elsif($acc eq '++username'){
		$message='No account name entered';
		&PrintError;
	}else{
	open (DATA,"<$datafile");
		@data=<DATA>;
	close(DATA);
	$n=-1;
	foreach $user (@data){
		$n++;
		chomp($user);
		@subs=split(/\|/,$user);
		if(@subs[0] eq "$acc"){
			if(@subs[3] ne 'adsoff'){
				@subs[3]='adsoff';
				$done='removed from';
			}else{
				@subs[3]='popup';
				$done='inserted into';
			}
		}
		for ($i = 9; $i>0; --$i){
			if(@subs[$i] eq ""){
				@subs[$i]='not entered';
			}
			if(@subs[$i] eq "\n"){
				@subs[$i]='not entered\n';
			}
		}
		@data[$n]="@subs[0]|@subs[1]|@subs[2]|@subs[3]|@subs[4]|@subs[5]|@subs[6]|@subs[7]|@subs[8]|@subs[9]\n";
	}




	open(INDEX,">$redirect/@subs[0]/index.$ext");
		if(@subs[3] eq "popup"){
			print INDEX "<script language=\"JavaScript\"><!--\n";
			print INDEX "<!--#include virtual=\"$rescript?ad=popup&ct=@subs[9]\"-->\n";
			print INDEX "//--></script>\n\n";
			print INDEX "<html><head><title>@subs[6]</title><meta description=\"@subs[7]\"><meta keyword=\"@subs[8]\"></head>\n";
			print INDEX "<frameset rows=\"100%,*\" FRAMESPACING=0 FRAMEBORDER=0 BORDER=0>\n";
			print INDEX "<frame src=\"@subs[1]\" NAME=\"MAIN_FRAME\" SCROLLING=\"AUTO\" NORESIZE FRAMEBORDER=0 BORDER=0 MARGINHEIGHT=3 MARGINWIDTH=3>\n";
			print INDEX "</frameset></html>\n\n";
		}elsif(@subs[3] eq "delay"){
			print INDEX "<html><head><title>@subs[6]</title><meta description=\"@subs[7]\"><meta keyword=\"@subs[8]\"><meta http-Equiv=\"refresh\" content=\"8; url=@subs[1]\"></head><body>\n";
			print INDEX "<table border=0 width=100% height=95%><tr><td valign=middle><!--#include virtual=\"$rescript?ad=delay&ct=@subs[9]\"-->\n";
			print INDEX "<p><center>Please wait while you're taken to <a href=\"@subs[1]\">@subs[1]</a>.</center></p>\n";
			print INDEX "</td></tr></table></body></html>\n\n";
		}elsif(@subs[3] eq "frame"){
			print INDEX "<html><head><title>@subs[6]</title><meta description=\"@subs[7]\"><meta keyword=\"@subs[8]\"></head>\n";
			print INDEX "<frameset rows=\"62,*\" FRAMESPACING=0 FRAMEBORDER=0 BORDER=0>\n";
			print INDEX "<frame src=\"<!--#include virtual=\"$rescript?ad=frame&ct=@subs[9]\"-->\" NAME=\"AD_FRAME\" SCROLLING=\"NO\" NORESIZE FRAMEBORDER=0 BORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0>\n";
			print INDEX "<frame src=\"@subs[1]\" NAME=\"MAIN_FRAME\" SCROLLING=\"AUTO\" NORESIZE FRAMEBORDER=0 BORDER=0 MARGINHEIGHT=3 MARGINWIDTH=3>\n";
			print INDEX "</frameset></html>\n\n";
		}else{
			print INDEX "<html><head><title>@subs[6]</title><meta description=\"@subs[7]\"><meta keyword=\"@subs[8]\"></head>\n";
			print INDEX "<frameset rows=\"100%,*\" FRAMESPACING=0 FRAMEBORDER=0 BORDER=0>\n";
			print INDEX "<frame src=\"@subs[1]\" NAME=\"MAIN_FRAME\" SCROLLING=\"AUTO\" NORESIZE FRAMEBORDER=0 BORDER=0 MARGINHEIGHT=3 MARGINWIDTH=3>\n";
			print INDEX "</frameset></html>\n\n";
		}
	close(INDEX);
	chmod("$redirect/$fild{'username'}/index.$ext",0777);



	print "Content-type: text/html\n\n";
	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\"><input type=hidden name=do value=$password>\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white><tr><td bgcolor=blue>\n";
	print "<font face=arial color=white>RedirectPro Admin</font>\n";
	print "</td></tr><tr><td>\n";
	print "<center><TABLE PADDING=5>\n";
	print "<TR><TD>\n";

	open (DATA,">$datafile");
		foreach $item(@data){
			print DATA "$item";
		}
	close(DATA);

	print "<p><center>The ad has been $done the account \"@acco[2]\"</center></p>\n";
	print "<p><center><p><input type=Submit value=\"Okay\"></p></center>\n";

	print "</td></tr></table></center></td></tr></table></center></p>\n";
	print "</form></body></html>\n";
	exit 0 ;
	}
}
sub stepfive
{
	@acco=split(/=/,$ENV{'QUERY_STRING'});
	$acc=@acco[2];
	if($acc eq ''){
		$message='No account name entered';
		&PrintError;
	}elsif($acc eq '++username'){
		$message='No account name entered';
		&PrintError;
	}else{
	open (DATA,"<$datafile");
		@data=<DATA>;
	close(DATA);
	$n=-1;
	foreach $user (@data){
		$n++;
		@subs=split(/\|/,$user);
		if(@subs[0] eq "$acc"){
			@data[$n]='000000000A';
		}
	}
	@data=sort(@data);
	shift(@data);
	open (DATA,">$datafile");
		foreach $item(@data){
			print DATA "$item";
		}
	close(DATA);

	open(INDEX,">$redirect/@subs[0]/index.$ext");
	print INDEX "This account has been removed\n";
	close(INDEX);

	print "Content-type: text/html\n\n";
	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\"><input type=hidden name=do value=$password>\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white><tr><td bgcolor=blue>\n";
	print "<font face=arial color=white>RedirectPro Admin</font>\n";
	print "</td></tr><tr><td>\n";
	print "<center><TABLE PADDING=5>\n";
	print "<TR><TD>\n";

	print "<p><center>The account \"@acco[2]\" has been deleted</center></p>\n";
	print "<p><center><p><input type=Submit value=\"Okay\"></p></center>\n";

	print "</td></tr></table></center></td></tr></table></center></p>\n";
	print "</form></body></html>\n";
	exit 0 ;
	}
}
sub steptwo
{
	@fval=split(/&/,$ENV{'QUERY_STRING'});
	foreach $i (0 .. $#fval){
		($name,$val)=split (/=/,$fval[$i],2);
		$val=~tr/+/ /;
		$val=~ s/%(..)/pack("c",hex($1))/ge;
		$name=~tr/+/ /;
		$name=~ s/%(..)/pack("c",hex($1))/ge;
		$field{$name}=$val;
	}
	$amt1=$field{'amt1'};
	$amt2=$field{'amt2'};
	print "Content-type: text/html\n\n";
	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\"><input type=hidden name=\"do\" value=\"showall$password\">\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white><tr><td bgcolor=blue>\n";
	print "<font face=arial color=white>RedirectPro Admin</font>\n";
	print "</td></tr><tr><td>\n";
	if($amt1 eq ''){
		$amt1=0;
	}
	if($amt2 eq ''){
		$amt2=10;
	}
	if($amt2<$amt1){
		$amt2=10;
	}

	open(DATA,"<$datafile");
	@datau=<DATA>;
	close(DATA);
	$count=@datau;
	if($amt2>$count){
		$amt2=$count;
	}
	for ($n=$amt1; $n<$amt2; $n++){
		push(@data,@datau[$n]);
	}

	print "<TABLE PADDING=5>\n";
	print "<TR><TD><p><center>Show accounts <input type=\"text\" width=\"5\" name=\"amt1\" value=\"$amt1\"> through <input type=\"text\" width=\"5\" name=\"amt2\" value=\"$amt2\"> of $count <input type=Submit value=\"Okay\">\n";
	print "</center></p><p><center></form><form action=\"$script\" method=\"get\"><input type=hidden name=\"do\" value=\"$password\">\n";
	print "<table border=1><tr><td bgcolor=\"#ffffcc\">Username:</td><td>URL:</td><td>Password:</td><td>Ad-type:</td><td>Email Address:</td><td>Name:</td><td>Title:</td><td>Country:</td></tr>\n";

	foreach $d(@data){
		@dt=split(/\|/,$d);
		print "<tr><td bgcolor=\"#ffffcc\">@dt[0]</td><td><font size=1>@dt[1]</font></td><td><font size=1>@dt[2]</font></td><td><font size=1>@dt[3]</font></td><td><font size=1>@dt[4]</font></td><td><font size=1>@dt[5]</font></td><td><font size=1>@dt[6]</font></td><td><font size=1>@dt[9]</font></td></tr>\n";
	}
	print "</table>\n";

	print "<br><input type=Submit value=\"Okay\"></center></p></td></tr></table></td></tr></table></center></p>\n";
	print "</form></body></html>\n";
	exit 0 ; 
}

sub stepone
{
	open(DATA,"<$datafile");
	@data=<DATA>;
	close(DATA);
	$count=@data;
	print "Content-type: text/html\n\n";
	print "<html><head><title>RedirectPro Admin</title></head><body>\n";
	print "<form action=\"$script\" method=\"get\">\n";
	print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
	print "<P><CENTER><TABLE BORDER=1 CELLSPACING=0 bgcolor=white>\n";
	print "<TR>\n";
	print "<TD bgcolor=blue>\n";
	print "<P><FONT FACE=\"arial\" color=\"white\">RedirectPro Admin</FONT>\n";
	print "</TD></TR>\n";
	print "<TR>\n";
	print "<TD>\n";
	print "<P><TABLE BORDER=0 CELLSPACING=5>\n";
	print "<TR>\n";
	print "<TD VALIGN=top>\n";
	print "<P>\n";
	print "<table border=0><tr><td><form action=\"$script\" method=\"get\"><input type=hidden name=\"do\" value=\"showall$password\">\n";
	print "Show all $count users:</td><td><input type=Submit value=\"Show all $count users\">\n";
	print "</td></form></tr>\n";
	print "<tr><td><form action=\"$script\" method=\"get\"><input type=hidden name=\"do\" value=\"delete$password\">\n";
	print "Delete user:</td><td><input type=text value=\"  username\" name=\"un\" size=12><input type=Submit value=\"Okay\">\n";
	print "</td></form></tr>\n";
	print "<tr><td><form action=\"$script\" method=\"get\"><input type=hidden name=\"do\" value=\"ads$password\">\n";
	print "Remove/Add ads:</td><td><input type=text value=\"  username\" name=\"un\" size=12><input type=Submit value=\"Okay\">\n";
	print "</td></form></tr>\n";
	print "<tr><td><form action=\"$script\" method=\"get\"><input type=hidden name=\"do\" value=\"count$password\">\n";
	print "Country File:</td><td><input type=Submit value=\"Click for menu...\">\n";
	print "</td></form></tr>\n";
	print "</table>\n";
	print "</P><center><font size=1><p>©1999 W. Dustin Alligood<br><A HREF=\"http://www.go2cgi.com/cgi-bin/support.pl\">If you have any problems take them to the Support Forum</a></p></font></center>\n";
	print "</TD><TD VALIGN=middle>\n";
	print "<P><A HREF=\"http://www.go2cgi.com/redirectpro/ver1-0.pl\"><IMG SRC=\"http://go2cgi.hypermart.net/redirectpro/ver1-0.gif\" BORDER=0 ALIGN=bottom></A>\n";
	print "</TD></TR>\n";
	print "</TABLE>\n";
	print "</TD></TR>\n";
	print "</TABLE></CENTER></P>\n";
	print "</form></body></html>\n";
	exit 0 ;
}

sub PrintError { 

print "Content-type: text/html\n\n";
print "<html><head><title>RedirectPro</title></head><body>\n";
print "<form action=\"$script\" method=\"get\">\n";
print "<h2><center><font color=red>Redirect</font><font color=blue>Pro</font> Admin</center></h2>\n";
print "<input type=hidden name=\"do\" value=\"$password\">\n";
print "<p><center><table border=1 cellpadding=1 cellspacing=0 bgcolor=white><tr><td bgcolor=blue>\n";
print "<font face=arial color=white>$errtype - Error</font>\n";
print "</td></tr><tr><td>\n";
print "<TABLE PADDING=5>\n";
print "<TR><TD>\n";

print $message ;

print "<p><center><input type=Submit value=\"<- Back\" onClick=history.go(-1)></center></p>\n";

print "</td></tr></table></td></tr></table></center></p>\n";

print "</form></body></html>\n";

exit 0 ;
return 1 ; 

}

sub GetFormInput {

	(*fval) = @_ if @_ ;

	local ($buf);
	if ($ENV{'REQUEST_METHOD'} eq 'POST') {
		read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
	}
	else {
		$buf=$ENV{'QUERY_STRING'};
	}
	if ($buf eq "") {
			return 0 ;
		}
	else {
 		@fval=split(/&/,$buf);
		foreach $i (0 .. $#fval){
			($name,$val)=split (/=/,$fval[$i],2);
			$val=~tr/+/ /;
			$val=~ s/%(..)/pack("c",hex($1))/ge;
			$name=~tr/+/ /;
			$name=~ s/%(..)/pack("c",hex($1))/ge;

			if (!defined($field{$name})) {
				$field{$name}=$val;
			}

		   }
		}
return 1;
}