#!/usr/bin/perl
###
#######################################################
#		Home Free v3.20
#     
#    		Created by Solution Scripts
# 		Email: solutions@solutionscripts.com
#		Web: http://solutionscripts.com
#
#######################################################
#
#
# COPYRIGHT NOTICE:
#
# Copyright 1998 Solution Scripts  All Rights Reserved.
#
# Selling the code for this program without prior written consent is
# expressly forbidden. In all cases
# copyright and header must remain intact.
#
#######################################################


($0 =~ m,(.*)/[^/]+,)   && unshift (@INC, "$1");
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1");

require "variables.pl";
require "dblib.pl";
require "acc_auth.pl";
require "emaillib.pl";
require "dem_data.pl";


print "Content-type: text/html\n\n ";
&Account::initialize;


&Header;

if ($INPUT{'join'}) { &join; }
elsif ($INPUT{'view'}) { &view; }
elsif ($INPUT{'signup'}) { &signup; }
elsif ($INPUT{'action'} eq "remove") { &remove; }
elsif ($INPUT{'newpass'}) { &newpass; }
elsif ($INPUT{'delete_select'}) { &delete_select; }
elsif ($INPUT{'delete_final'}) { &delete_final; }
elsif ($INPUT{'sendemail'}) { &sendemail; }
else { &main; }
exit;


########## JOIN NOW SCREEN ##########
sub main {

&Header;

## IF category MAKE USER SELECT category ##
if ($category) {
print <<EOF;
<FONT face=$font_face size=$font_size> 
$lang::s1
<BR>
<FORM METHOD=POST ACTION="$cgiurl">
<table cellspacing=0 cellpadding=5 border=1 bgcolor=$table_bg>
EOF
	$select_list = '';
	if ($cata_base) {
		$select_list .= "<OPTION VALUE=\"accounts\">$lang::no $cata_name \n";
	}

	%cata = &Account::get_cata_hash;

	foreach $key (Account::sort_hash(\%cata)) {
		@abbo = split(/\|/,$cata{$key});
		$openings = $abbo[7] - $abbo[8];
		if ($openings < 1) {
			$openings = "$cata_name $lang::full";
		}
		else {
			$select_list .= "<OPTION VALUE=\"$key\">$abbo[1]\n";
		}

print <<EOF;
<TR align=left><TD>
<font face=$font_face size=$font_size color=$text_table>
<B>$cata_name</B> - $abbo[1]<BR>
<B>$lang::s2</B> - $url/$abbo[0]<BR>
<B>$lang::s3</B> - $openings<BR>
<B>$lang::s4</B> - 
<BLOCKQUOTE>
$abbo[2]
</BLOCKQUOTE>
</TD></TR>
EOF
	}
print <<EOF;
<TR align=center bgcolor=$table_head_bg><TD>
<font face=$font_face size=$font_size color=$text_table_head>
$lang::s5
<BR><BR>
<select name="category">
$select_list
</select>&nbsp;&nbsp;&nbsp;<input type="Submit" name="signup" value=" $lang::continue ">
</TD></TR></TABLE>
</FORM>
EOF
&Footer;
exit;
}
## NO category STRAIT TO JOIN SCREEN ## 
else {
	&signup;
}
}

## NEW ACCOUNT SIGN UP ##
sub signup {

print <<EOF;
<FONT face=$font_face size=$font_size> 
<B>
$lang::s6
</B>
<BR>
<FORM METHOD=POST ACTION="$cgiurl">
EOF

if ($INPUT{'category'}) {
	print "<INPUT TYPE=HIDDEN NAME=\"category\" value=\"$INPUT{'category'}\">\n";
}
else {
	print "<INPUT TYPE=HIDDEN NAME=category value=\"accounts\">\n";
}

if ($terms) {
	open (PASSWORD, "$path/rules.txt");
	@rules = <PASSWORD>; 
	close (PASSWORD);

print <<EOF;
<table border=0 width=60%>
<TR align=left>
<TD><font face=$font_face size=$font_size>
<B>
$lang::s7
</B><BR><BR>
@rules
<BR><BR></TD></TR><TR><TD bgcolor = $table_head_bg align=center>
<font face=$font_face size=$font_size color=$text_table_head> 
<input type="Checkbox" name="agree"> -- <B>
$lang::s8
</B>
</TD></TR>
</TABLE><BR>
EOF

}

print <<EOF;
<table width=600 cellpadding=5 cellspacing=0 border=0>
EOF

&info_username;
unless ($acc_type eq "Email Random Password") { 
	&info_pass;
	&info_pass1;
}
&info_name;
&info_email;
&info_address;
&info_city;
&info_zip;
&info_country;
&info_tele;
&info_gender;
&info_marital;
&info_icq;
&info_edu;
&info_inc;
&info_job;
&info_dob;
&info_age;
&info_custom(1);
&info_custom(2);
&info_custom(3);
&info_custom(4);
&info_custom(5);
&info_custom(6);
&info_custom(7);
&info_custom(8);
&info_custom(9);
&info_custom(10);

print "$html";

print <<EOF;
<TR><TD align=center colspan=4><BR><BR><INPUT TYPE="SUBMIT" NAME="join" VALUE="  $lang::s9  ">
</TD></TR>
</TABLE>
</FORM>
EOF


&Footer;
exit;
}



########### VERIFY AND ADD NEW ACCOUNT ##########
sub join {

$account = $INPUT{'username'};
$account = "\L$account\E";

$INPUT{'email'} =~ s/ //gi;

$not_entered ="<BR><font face=verdana size=-2 color=red>\&nbsp\;\&nbsp\;$lang::s10</FONT>\n";

&info_username;
unless ($acc_type eq "Email Random Password") { 
	&info_pass;
	&info_pass1;
}
&info_name;
&info_email;
&info_address;
&info_city;
&info_zip;
&info_country;
&info_tele;
&info_gender;
&info_marital;
&info_icq;
&info_edu;
&info_inc;
&info_job;
&info_dob;
&info_age;
&info_custom(1);
&info_custom(2);
&info_custom(3);
&info_custom(4);
&info_custom(5);
&info_custom(6);
&info_custom(7);
&info_custom(8);
&info_custom(9);
&info_custom(10);

if ($terms) {
	unless ($INPUT{'agree'}) {
print <<EOF;
<BR>
<table cellpadding=5 border=1 cellspacing=0 bgcolor=$table_bg>
<TR><TD><font face=$font_face size=$font_size><B>
$lang::s13
</TD></TR></TABLE>
<BR><BR>
EOF
	exit;
	}
}

if ($html =~ /$not_entered/gm) {
print <<EOF;
<FONT face=$font_face size=$font_size> 
<BR>
<FORM METHOD=POST ACTION="$cgiurl">
<INPUT TYPE=hidden name=agree value=on>
<INPUT TYPE=HIDDEN NAME="category" value="$INPUT{'category'}">
<table width=600 cellpadding=5 cellspacing=0 border=0 align=center>
<TR><TD colspan=4>
<FONT face=$font_face size=$font_size color=red> 
<B>
$lang::s11
</B><BR><BR>
</TD></TR>
$html
<TR><TD align=center colspan=4><BR><BR><INPUT TYPE="SUBMIT" NAME="join" VALUE="  $lang::s12  ">
</TD></TR>
</TABLE>
</FORM>
EOF
&Footer;
exit;
}


## CHECK FOR BAD CHARS ##
@out = split(//,$account);
$a=0;
foreach $char (@out) {
	$a++;
	unless ($char =~ /[a-z0-9]/) {
print <<EOF;
<FORM METHOD=POST ACTION="$cgiurl">
<INPUT TYPE=hidden name=agree value=on>
<INPUT TYPE=HIDDEN NAME="category" value="$INPUT{'category'}">
<table width=600 cellpadding=5 cellspacing=0 border=0 align=center>
<TR><TD colspan=4>
<FONT face=$font_face size=$font_size color=red> 
<B>
$lang::s14
<BR><BR>
</TD></TR>
$html
<TR><TD align=center colspan=4><BR><BR><INPUT TYPE="SUBMIT" NAME="join" VALUE="  $lang::s12  ">
</TD></TR>
</TABLE>
</FORM>
EOF
	&Footer;
	exit;
	}
}

if ($a < 3 || $a > 12) {
print <<EOF;
<FORM METHOD=POST ACTION="$cgiurl">
<INPUT TYPE=hidden name=agree value=on>
<INPUT TYPE=HIDDEN NAME="category" value="$INPUT{'category'}">
<table width=600 cellpadding=5 cellspacing=0 border=0 align=center>
<TR><TD colspan=4>
<FONT face=$font_face size=$font_size color=red> 
<B>
$lang::s14
<BR><BR>
</TD></TR>
$html
<TR><TD align=center colspan=4><BR><BR><INPUT TYPE="SUBMIT" NAME="join" VALUE="  $lang::s12  ">
</TD></TR>
</TABLE>
</FORM>
EOF
	&Footer;
	exit;
}

@res = split(/\,/,$reserved);

foreach $r(@res) {
	$r = "\L$r\E";
	if ($account eq $r) {
		&account_taken;
		&Footer;
		exit;
	}	
}

if ($INPUT{'email'}) {
	### CHECK BANNED EMAILS ###
	open (ACC, "$path/banned_email.txt");
	@ban_emails = <ACC>;
	close (ACC);

	foreach $email_line(@ban_emails) {
		chomp($email_line);
		if ($INPUT{'email'} =~ /$email_line/) { 
print <<EOF;
<BR>
<table cellpadding=5 border=1 cellspacing=0 bgcolor=$table_bg>
<TR><TD align=center><font face=$font_face size=$font_size color=$text_table>
$lang::s22
</TD></TR></TABLE>
<BR><BR>
EOF
	   		&Footer;
	   		exit;
		}
	}
}


### CHECK BANNED IPS ###
open (ACC, "$path/banned_ip.txt");
@ban_ip = <ACC>;
close (ACC);

foreach $ip_line(@ban_ip) {
	chomp($ip_line);
	if ($ENV{'REMOTE_ADDR'} =~ /$ip_line/) { 
print <<EOF;
<BR>
<table cellpadding=5 border=1 cellspacing=0 bgcolor=$table_bg>
<TR><TD align=center><font face=$font_face size=$font_size color=$text_table>
$lang::s22
</TD></TR></TABLE>
<BR><BR>
EOF
	   &Footer;
	   exit;
	}
}


%cata = &Account::get_cata_hash;

$cata{'accounts'} = 1;

if ($cata{$main::account}) { 
   &account_taken;
   &Footer;
   exit;
}

if ($INPUT{'email'}){
unless ($mult_email) {
	while (($key, $value) = each(%cata) ) {
		undef %acc_list;
		%acc_list = &Account::get_acc_hash($key);

		while ( ($akey, $avalue) = each(%acc_list) ) {
			@acco = split(/\|/,$avalue);
			if ($INPUT{'email'} =~ /^$acco[0]$/i) {
				print qq!
					<BR>
					<table cellpadding=5 border=0 cellspacing=0 width=400>
					<TR><TD><font face=$font_face size=$font_size>
				 	$lang::s15	
				 	</TD></TR></TABLE>
				 	<BR><BR>
				!;			
				&Footer;
				exit;
			}
		}
	}
}
}


$dir_acc = $account;
$real_cata = '';

if ($INPUT{'category'} eq "accounts") {
	if ($category) {
    	unless ($cata_base) { 
			print qq!
				<BR>
				<table cellpadding=5 border=0 cellspacing=0 width=400>
				<TR><TD><font face=$font_face size=$font_size>
			 	$lang::s15	
			 	</TD></TR></TABLE>
			 	<BR><BR>
			!;			
			&Footer;
			exit;
		}
	}
}
else {
	@abbo = split(/\|/,$cata{$INPUT{'category'}});
	$real_cata = "$cata_name: $abbo[1]\n";
	if ($abbo[0]) { 
		$dir_acc = "$abbo[0]/$account";
	}
	else {
		$dir_acc = $account;
	}
}

## UNIQUE CHECK ##
unless ($category eq "unique") {
	%cata_list = &Account::get_cata_hash;
	while ( ($key, $value) = each(%cata_list) ) {
		@abbo = split(/\|/,$value);
		if ($abbo[0]) { 
			$uni_acc = "$abbo[0]/$account";
		}
		else {
			$uni_acc = $account;
		}
		if (-e "$free_path/$uni_acc") {
   			&account_taken;
   			&Footer;
   			exit;
		}
	}
}

if (-e "$free_path/$dir_acc") {
   &account_taken;
   &Footer;
   exit;
}	


$! = '';

open(LIST,"$path/welcome_html.txt");
@welcs = <LIST>;
close(LIST);

open(LIST,"$path/welcome.txt");
@confirmit = <LIST>;
close(LIST);

$Account::email = $INPUT{'email'};
$Account::name = $INPUT{'name'};
$Account::pwd = $INPUT{'password'};
$Account::size = $total_k;
$Account::creation = $time;
$Account::last_log = 0;
$Account::size_added = '';
$Account::hf_on = 'on';
$Account::website_name = '';
$Account::website_des = '';
$Account::numdirs = '';
$Account::www_of = '';
$Account::www_name = '';
$Account::www_bgcolor = '';
$Account::www_bgimage = '';
$Account::www_text = '';
$Account::www_link = '';
$Account::www_vlink = '';
$Account::onhold = '';
$Account::address = $INPUT{'address'};
$Account::city = $INPUT{'city'};
$Account::state = $INPUT{'state'};
$Account::zip = $INPUT{'zip'};
$Account::country = $INPUT{'country'};
$Account::telephone = $INPUT{'tele'};
$Account::gender = $INPUT{'gender'};
$Account::age = $INPUT{'age'};
$Account::icq = $INPUT{'icq'};
$Account::education = $INPUT{'edu'};
$Account::income = $INPUT{'inc'};
$Account::occupation = $INPUT{'job'};
$Account::d_o_b = "$INPUT{'month'},$INPUT{'day'},$INPUT{'year1'},$INPUT{'year2'}";
$Account::moderator = '';
$Account::gbook_of = '';
$Account::op_in = '';
$Account::icon_url = '';
$Account::file_types = '';
$Account::ftp_per = '';
$Account::session = '';
$Account::num_dirs = $num_dirs;
$Account::num_files = $num_files;
$Account::custom_1 = $INPUT{'custom_1'};
$Account::custom_2 = $INPUT{'custom_2'};
$Account::custom_3 = $INPUT{'custom_3'};
$Account::custom_4 = $INPUT{'custom_4'};
$Account::custom_5 = $INPUT{'custom_5'};
$Account::custom_6 = $INPUT{'custom_6'};
$Account::custom_7 = $INPUT{'custom_7'};
$Account::custom_8 = $INPUT{'custom_8'};
$Account::custom_9 = $INPUT{'custom_9'};
$Account::custom_10 = $INPUT{'custom_10'};
$Account::marital = $INPUT{'marital'};

if ($main::log_ips) {
	$Account::last_ip = $main::ENV{'REMOTE_ADDR'};
}

#### CREATE NEW FOLDER AND SITE ####

mkdir("$free_path/$dir_acc", 0777) || &error("$lang::a7 $free_path/$dir_acc");
chmod(0777,"$free_path/$dir_acc");

mkdir("$free_path/$dir_acc/_data", 0777) || &error("$lang::a7 $free_path/$dir_acc/_data");
chmod(0777,"$free_path/$dir_acc/_data");

undef $/;

if (-e "$path/default") {
	&dir_lists("$path/default","$free_path/$dir_acc");
}
elsif (-e "$path/index.txt") {

	open(LIST,"$path/index.txt");
	$index = <LIST>;
	close(LIST);

	$index = &ins_replace($index);

	open(LIST,">$free_path/$dir_acc/index.html") || &error("$lang::a8 $free_path/$dir_acc/index.html");
	print LIST $index;
	close(LIST);
}
else {

	$index .= "<HTML><HEAD><TITLE>Welcome to $INPUT{'name'}\'s homepage</TITLE></HEAD>\n<BODY>\n<center>\n";
	$index .= "<BR><font face=$font_face>Welcome to $INPUT{'name'}\'s homepage<BR><BR>";
	$index .= "$INPUT{'name'} has yet to move in, but you can email them at <A HREF=\"mailto:$INPUT{'email'}\">$INPUT{'email'}</A>";
	$index .= "</BODY>\n</HTML>";

	open(LIST,">$free_path/$dir_acc/index.html") || &error("$lang::a8 $free_path/$dir_acc/index.html");
	print LIST $index;
	close(LIST);

}
$/="\n";

## PASSWORD EMAIL TO USER ##
if ($acc_type eq "Email Random Password") { 

	# generate random password
	srand($time);
	$password ="";
	@passset = ('a'..'k', 'm'..'z', 'A'..'N', 'P'..'Z', '2'..'9');
	for ($i = 0; $i < 8; $i++) {
		$randum_num = int(rand($#passset + 1));
		$password .= @passset[$randum_num];
	}

	$Account::pwd = $password;
	
print <<EOF;
<table cellpadding=5 border=1 cellspacing=0 bgcolor=$table_bg>
<TR><TD>
<font face=$font_face size=$font_size color=$text_table><B>
$lang::s20 "$account" $lang::s21</B>
<BR><BR>
$lang::s16<BR><BR>
$lang::s17<BR>
<A HREF="$url/$dir_acc/">$url/$dir_acc/</A>
<BR><BR>
$lang::s18
<A HREF="$files::manager">$files::manager</A><BR><BR>
$lang::s19<A HREF="mailto:$your_email">$your_email</A>
</TD></TR></TABLE>
<BR><BR>
@welcs
<BR><BR>
EOF

	$subject = "$lang::s23 $free_name\n";

	$message = "$lang::s23 $free_name, $lang::s24\n\n";
	$message .= "$lang::s26\n";
	$message .= "---------------------------------------\n";
	$message .= "$lang::m40 -- $account\n$real_cata";
	$message .= "$lang::m2 -- $Account::pwd\n";
	$message .= "$lang::m41 -- $url/$dir_acc/\n\n";
	$message .= "$lang::s25\n";
	$message .= "$files::manager\n\n";
	foreach $line(@confirmit) {
		$message .= "$line";
	}
	$message .= "\n\n";

	&write_email($INPUT{'email'},$subject,$message);
	
}
## USER SELECTED PASSWORD ##
elsif ($acc_type eq "User Selects Password") { 

print <<EOF;
<table cellpadding=5 border=1 cellspacing=0 bgcolor=$table_bg>
<TR><TD>
<font face=$font_face size=$font_size color=$text_table><B>
$lang::s20 "$account" $lang::s21</B>
<BR>
$lang::s17<BR>
<A HREF="$url/$dir_acc/">$url/$dir_acc/</A>
<BR><BR>
$lang::s18<A HREF="$files::manager">$files::manager</A><BR><BR>
$lang::s19 <A HREF="mailto:$your_email">$your_email</A>
</TD></TR></TABLE>
<BR><BR>
@welcs
<BR><BR>
EOF

	$subject = "$lang::s23 $free_name\n";

	$message = "$lang::s23 $free_name, $lang::s24\n\n";
	$message .= "$lang::s26\n";
	$message .= "---------------------------------------\n";
	$message .= "$lang::m40 -- $account\n$real_cata";
	$message .= "$lang::m2 -- $Account::pwd\n";
	$message .= "$lang::m41 -- $url/$dir_acc/\n\n";
	$message .= "$lang::s25\n";
	$message .= "$files::manager\n\n";
	foreach $line(@confirmit) {
		$message .= "$line";
	}
	$message .= "\n\n";

	&write_email($INPUT{'email'},$subject,$message);

}
else { ## ADMIN MUST CONFIRM ACCOUNT ##

	$Account::onhold = "All new accounts must be confirmed before they can be used";
		
print <<EOF;
<table cellpadding=5 border=1 cellspacing=0 bgcolor=$table_bg>
<TR><TD>
<font face=$font_face size=$font_size color=$text_table><B>
$lang::s20 "$account" $lang::s21</B>
<BR><BR>
$lang::s27<BR>
<A HREF="$url/$dir_acc/">$url/$dir_acc/</A>
<BR><BR>
$lang::s18 <A HREF="$files::manager">$files::manager</A><BR><BR>
$lang::s19 <A HREF="mailto:$your_email">$your_email</A>
</TD></TR></TABLE>
<BR><BR>
@welcs
<BR><BR>
EOF

}

## EMAIL ADMIN IF NEW ACCOUNT ##
if ($e_notify) {
	$subject = "$free_name -- New Signup";
	$message = "A new signup at $free_name\n\n";
	$message .= "Their information is as follows:\n";
	$message .= "---------------------------------------\n";
	$message .= "Account -- $account\n$real_cata";
	$message .= "Name -- $INPUT{'name'}\n";
	$message .= "Email -- $INPUT{'email'}\n";
	$message .= "Url -- $url/$dir_acc/\n\n";
	$message .= "\n\n";
	
	&write_email($your_email,$subject,$message);
}

########## CREATE ACCOUNT ENTRY ###########
$Account::account = $account;
$Account::cata = $INPUT{'category'};

&Account::print_account;
&Account::cate_increment($INPUT{'category'},1);

####
&Footer;
exit;
}

########## CREATE NEW WEB SITE ##########
sub dir_lists {

my $direc = $_[0];
my $pdirec = $_[1];
my (@dirs,$new_dir);

opendir(DIR,$direc);
@dirs = grep {!(/^\./) && -d "$direc/$_" } readdir(DIR);
close DIR;

opendir (DIR, "$direc");
@files = grep {!(/^\./) && -f "$direc/$_"}  readdir(DIR);
close (DIR); 

foreach $file(@files) {
	@stats = stat("$direc/$file");
	$mtime = $stats[9];
	$atime = $stats[8];
	$size = $stats[7];
	$size = $size /1000;
	$Account::Size = $size + $Account::size;

	$Account::num_files++;

	open(LIST,"$direc/$file");
	$index = <LIST>;
	close(LIST);

	$nindex = &ins_replace($index);

	open(LIST,">$pdirec/$file") || &error("Can't make $pdirec/$file");
	print LIST $nindex;
	close(LIST);
}

for $new_dir(0..$#dirs) {
	$show_dir = "$pdirec/$dirs[$new_dir]";
	mkdir("$show_dir", 0777) || &error("Can't make $show_dir");
	chmod(0777,"$show_dir");

	$Account::num_dirs++;
	
	&dir_lists("$direc/$dirs[$new_dir]","$pdirec/$dirs[$new_dir]");

}


}

########## INSERT/REPLACE DATA #########
sub ins_replace {

my $data = shift;

$data =~ s/\%\%ACCOUNT\%\%/$account/gmi;
$data =~ s/\%\%NAME\%\%/$Account::name/gmi;
$data =~ s/\%\%EMAIL\%\%/$Account::email/gmi;
$data =~ s/\%\%ADDRESS\%\%/$Account::address/gmi;
$data =~ s/\%\%CITY\%\%/$Account::city/gmi;
$data =~ s/\%\%STATE\%\%/$Account::state/gmi;
$data =~ s/\%\%ZIP\%\%/$Account::zip/gmi;
$data =~ s/\%\%COUNTRY\%\%/$Account::country/gmi;

$data =~ s/\%\%CUSTOM_1\%\%/$Account::custom_1/gmi;
$data =~ s/\%\%CUSTOM_2\%\%/$Account::custom_2/gmi;
$data =~ s/\%\%CUSTOM_3\%\%/$Account::custom_3/gmi;
$data =~ s/\%\%CUSTOM_4\%\%/$Account::custom_4/gmi;
$data =~ s/\%\%CUSTOM_5\%\%/$Account::custom_5/gmi;
$data =~ s/\%\%CUSTOM_6\%\%/$Account::custom_6/gmi;
$data =~ s/\%\%CUSTOM_7\%\%/$Account::custom_7/gmi;
$data =~ s/\%\%CUSTOM_8\%\%/$Account::custom_8/gmi;
$data =~ s/\%\%CUSTOM_9\%\%/$Account::custom_9/gmi;
$data =~ s/\%\%CUSTOM_10\%\%/$Account::custom_10/gmi;

return ($data);
}

########## SORT HASH ##########
sub sort_hash {
	my $x = shift;
	my %array = %$x;
	sort { $array{$b} cmp $array{$a}; } keys %array;
}

########## SORRY ACCOUNT NAME TAKEN ##########
sub account_taken {

print <<EOF;
<BR>
<table cellpadding=5 border=1 cellspacing=0 bgcolor=$table_bg>
<TR><TD align=center><font face=$font_face size=$font_size color=$text_table>
$lang::s29 "$account"<BR>	
$lang::s30
</TD></TR></TABLE>
EOF
}

########## EMAIL ALREADY USED ##########
sub email_taken {

print <<EOF;
<BR>
<table cellpadding=5 border=1 cellspacing=0 bgcolor=$table_bg>
<TR><TD><font face=$font_face size=$font_size color=$text_table>
$lang::s31
</TD></TR></TABLE>
EOF
}



########## CGI HEADER ##########
sub Header {

	print "<HTML><HEAD><TITLE>$free_name</TITLE></HEAD>\n";
	print "<body bgcolor=$over_bg text=$text_color link=$link_color alink=$link_color vlink=$link_color>\n";
	
	
	open (HEAD, "$path/header.txt");
	@head = <HEAD>;
	close (HEAD);
	foreach $line (@head) {
			print "$line";
	}
	print "<br>";
}

########## CGI FOOTER ##########
sub Footer {
    
	open (HEAD, "$path/footer.txt");
	@foot = <HEAD>;
	close (HEAD);
	foreach $line (@foot) {
		print "$line";
	}
	if ($credit) {
		print "<center><font size=$font_size><hr width=525 noshade size=1><a href=\"http://solutionscripts.com\">Home Free</a> v$version<br>Created by <a href=\"http://solutionscripts.com\">Solution Scripts</a><br><br>";
	}
	print "</BODY></HTML>\n";
}

########## AN ERRROR ##########
sub error {

my $error_msg = shift;

print <<EOF;
<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=1>
<TR><TD>
<FONT FACE=$font_face SIZE=$font_size>
<B>$lang::a14</B>
<BR><BR>
$lang::a15
<BR><BR>
<I>$error_msg - $1</I>
</TD></TR></TABLE>
EOF

&Account::log_it('1',$lang::a14,"$error_msg - $!","");	

&Account::footer;
exit;

}

########## LOGGING ##########
sub log_it {

$level = $_[0];
$subject = $_[1];
$more = $_[2];
$log_url = $_[3];

if ($main::log_level >= $level) {
	open (ACC, ">>$main::path/hf.log");
	print ACC "$level\|\%\|$main::time\|\%\|$Account::account\|\%\|$Account::cata\|\%\|$subject\|\%\|$more\|\%\|$log_url\|\%\|$main::ENV{'REMOTE_ADDR'}\n";
	close (ACC);
}

}