#!C:/Perl/bin/perl.exe
use Net::SMTP;
# This script was generated automatically by Perl Builder(tm): http://www.solutionsoft.com

# ***ENDAUTOGEN:HEADER*** Do NOT modify this line!!  You may enter custom code after this line.



# ***AUTOGEN:INPUT*** Do NOT modify this line!! Do NOT enter custom code in this section.

&GetFormInput;

# The intermediate variables below make your script more readable
# but somewhat less efficient since they are not really necessary.
# If you do not want to use these variables, clear the
# Intermediate Variables checkbox in the Tools | Options dialog box, CGI Wizard tab.


$adminmail = 'webmaster2\@adelphia.net';
$fname = $field{'fname'} ;	 
$lname = $field{'lname'} ;	 
$address = $field{'address'} ;	 
$city = $field{'city'} ;	 
$state = $field{'state'} ;	 
$zip = $field{'zip'} ;	 
$phone = $field{'phone'} ;	 
$email = $field{'email'} ;	 
$yes = $field{'yes'} ;	 
$no = $field{'no'} ;	 
$Submit = $field{'Submit'} ;	 

$message = "" ;
$found_err = "" ;

# ***ENDAUTOGEN:INPUT*** Do NOT modify this line!!  You may enter custom code after this line.



# ***AUTOGEN:VALIDATE*** Do NOT modify this line!! Do NOT enter custom code in this section.

$errmsg = "<p></p>\n" ;

if (length($fname) > 16843009) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p></p>\n" ;

if (length($lname) > 1009673588) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p></p>\n" ;

if (length($city) > 1) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p>Field 'state' must be filled in.</p>\n" ;

if ($state eq "") {
	$message = $message.$errmsg ;
	$found_err = 1 ; }

elsif (length($state) != 2) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p>Field 'zip' must be filled in.</p>\n" ;

if ($zip eq "") {
	$message = $message.$errmsg ;
	$found_err = 1 ; }

elsif (length($zip) != 5) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p>Field 'phone' must be filled in.</p>\n" ;

if ($phone eq "") {
	$message = $message.$errmsg ;
	$found_err = 1 ; }

elsif (length($phone) != 12) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p>Please enter a valid email address</p>\n" ;

if ($email !~ /.+\@.+\..+/) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p></p>\n" ;

if (length($yes) > 2) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p></p>\n" ;

if (length($no) > 5) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }


$errmsg = "<p></p>\n" ;

if (length($Submit) > 12) {
	$message = $message.$errmsg ;
	$found_err = 1 ; }

if ($found_err) {
	&PrintError; }


# ***ENDAUTOGEN:VALIDATE*** Do NOT modify this line!!  You may enter custom code after this line.



# ***AUTOGEN:LOGFILE*** Do NOT modify this line!! Do NOT enter custom code in this section.

# This will NOT work on your server unless you create the text file and set the permissions: chmod 660 webhost.txt


open (LOGFILE, ">> webhost.txt") ;

#The commented flock() and seek() lines below will lock the log file to prevent collisions from
#simultaneous users. However, flock() is probably not implemented in Perl for Windows and will
#give you a fatal error. Uncomment these lines only if/when you move your script to a Unix server.

#flock(LOGFILE, 2) ;     #LOCK - uncomment for locking on a Unix server.
#seek(LOGFILE, 0, 2) ;   #LOCK - uncomment for locking on a Unix server.
$datetime = localtime ;

print LOGFILE "$fname\t$lname\t$address\t$city\t$state\t$zip\t$phone\t$email\t$yes\t$no\t$datetime\n" ;

#flock(LOGFILE, 8) ;     #UNLOCK - uncomment for locking on a Unix server.

close (LOGFILE) ;


# ***ENDAUTOGEN:LOGFILE*** Do NOT modify this line!!  You may enter custom code after this line.



# ***AUTOGEN:EMAIL*** Do NOT modify this line!! Do NOT enter custom code in this section.


$recip = $email ;

my $MAIL = new Net::SMTP('mail.dc3.adelphia.net');
$MAIL->mail("$adminmail");
$MAIL->to("$recip");
$MAIL->data();
$MAIL->datasend("To: $email"."\n");
$MAIL->datasend("From: $adminmail"."\n");
$MAIL->datasend('Subject: Confirmation'."\n");
$MAIL->datasend("\n");
$MAIL->datasend("Thank you\n");
$MAIL->datasend("for choosing\n");
$MAIL->datasend("Fusion\'s Universe to\n");
$MAIL->datasend("Host your site\n");
$MAIL->datasend("\n");
$MAIL->datasend("Please take a moment to\n");
$MAIL->datasend("verify the information\n");
$MAIL->datasend("you submitted is correct\n");
$MAIL->datasend("as all info is verified\n");
$MAIL->datasend("\n");
$MAIL->datasend(".$fname"."\n");
$MAIL->datasend(".$lname"."\n");
$MAIL->datasend(".$address"."\n");
$MAIL->datasend(".$city"."\n");
$MAIL->datasend('.$state'."\n");
$MAIL->datasend('.$zip'."\n");
$MAIL->datasend(".$phone"."\n");
$MAIL->datasend(".$email"."\n");
$MAIL->datasend("\n");
$MAIL->datasend("If this information\n");
$MAIL->datasend("is incorrect please\n");
$MAIL->datasend("contact the administrator\n");
$MAIL->datasend("ASAP! so it can be\n");
$MAIL->datasend("\n");
$MAIL->datasend("Thank you again\n");
$MAIL->datasend("for choosing\n");
$MAIL->datasend("Fusion\'s Universe\n");
$MAIL->dataend();
$MAIL->quit;

# ***ENDAUTOGEN:EMAIL*** Do NOT modify this line!!  You may enter custom code after this line.



# ***AUTOGEN:HTML*** Do NOT modify this line!! Do NOT enter custom code in this section.
print "Location: http://www.fusions-ds9.com/thanks.html\nURI: http://www.fusions-ds9.com/thanks.html\n\n" ;

# ***ENDAUTOGEN:HTML*** Do NOT modify this line!!  You may enter custom code after this line.



# ***AUTOGEN:ERRPRINT*** Do NOT modify this line!! Do NOT enter custom code in this section.

sub PrintError { 
print "Content-type: text/html\n\n";
print $message ;

exit 0 ;
return 1 ; 
}

# ***ENDAUTOGEN:ERRPRINT*** Do NOT modify this line!!  You may enter custom code after this line.



# ***AUTOGEN:PARSE*** Do NOT modify this line!! Do NOT enter custom code in this section.
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;
			}
			else {
				$field{$name} .= ",$val";
				
				#if you want multi-selects to goto into an array change to:
				#$field{$name} .= "\0$val";
			}


		   }
		}
return 1;
}


# ***ENDAUTOGEN:PARSE*** Do NOT modify this line!!  You may enter custom code after this line.


