#!/usr/bin/perl
###################################################################
#	Applyfeedback Automatic Feedback Form v2.1
#
#			by Applytools.com
#
#
#		Instructions:
#		------------
#		1. Make all changes noted below
#		2. Read READMEFIRST.txt for full instructions
#
#		About this free product:
#		-----------------------
#		   ApplyContact is free as long as it is UNCHANGED AND
#		THE APPLYTOOLS.COM NAME IS KEPT! If you would like to remove the
#		"Powered By ApplyTools.com" messages with our name on it, please 
#		purchase the professional version. Our professional version uses an 
#		interface and has extra feature so you never have to enter the code.
#		Contact us at rudy@applymarketing.com, or through our site 
#		http://www.applytools.com
##################################################################
# 7 CHANGES:
#----------
#
#	1. Type in the location of sendmail on your server. Sendmail 
#		is almost always located at the default we have here.
#
#
$mailprog = '/usr/lib/sendmail';
#
#
#	2. Type in the e-mail you'd like the visitor info to be sent to.
#
$admin = 'wolvi79@yahoo.com.mx';
#
#
#	3. Type in the subject line for e-mails that are sent to you.
$adminsubject = 'Feedback';
#
#
#	4. Type in the URL to a thank you page vistors get sent to after
#		they complete the form.
#
$thankyou = 'http://www.geocities.com/lasolucionamihueva/tab/thankyou.html';
#
#
#	5. If you don't want an autoresponder to automatically e-mail someone
#		when they fill out your form, change this 1 to a 0.
#
#
$autoresponder = 1;
#
#
#	6. If you chose to use the autoresponder, what should the subject
#		and message of the autorespond e-mail be?
#
#
$autosubject = 'Thank You';
#
#
$automessage = 'Thank you for contacting Youdomain.com. We will get back to you within 24-48 hours.';
#
#
#	7. On the HTML code snippet (code.html) that you downloaded, change
#		the form = "http://www.geocities.com/lasolucionamihueva.com/cgi-bin/applyfeedback.pl to
#		the URL of this script on your server.
###################################################################
#		No more changes are necessary! Enjoy!
#################################################################
&parse;
&mime;
&get_date;
&br;
&prt;
$ver = '2.1';
$mailprog =~ s/[{}]//ig;
chomp($mailprog);
$name = $FORM{name};
$email = $FORM{email};
$URL = $FORM{URL};
$message = $FORM{message};
chomp($name);
chomp($email);
chomp($URL);
chomp($message);
open(FL, "|$mailprog -t") || die "Can't open $mailprog! on $now because of $!.\n";
print FL "TO: $admin\n";
print FL "FROM: $email\n";
print FL "SUBJECT: $adminsubject\n\n";
print FL "DATE: $now\n\n";
print FL "You have received an e-mail from a visitor with the following information:\n";
print FL "-------------------------------------------------------------------------\n\n";
print FL "Name: $name\n\n";
print FL "E-mail: $email\n\n";
print FL "URL: $URL\n\n";
print FL "Message: $message\n\n";
print FL "Form Page: $ENV{'HTTP_REFERER'}\n\n";
close(FL);
unless (!$autoresponder) {
	open(FL, "|$mailprog -t") || die "Can't open $mailprog! on $now because of $!.\n";
	print FL "TO: $email\n";
	print FL "FROM: $admin\n";
	print FL "SUBJECT: $autosubject\n\n";
	print FL "DATE: $now\n\n";
	print FL "$automessage\n\n";
	print FL "$br\n\n";
	close(FL);
}
open(FL2,">>applybackup.txt");
print FL2 "Message received on $now:\n";
print FL2 "Name: $name\n";
print FL2 "E-mail: $email\n";
print FL2 "URL: $URL\n";
print FL2 "Message: $message\n\n";
close(FL2);
sub br {
	$br='';
	$br1= "----------------------------------------------------------------------------------------\n";
	$br=$br1.'ApplyContact powered by www.ApplyTools.com!';
}
sub get_date {
	@days  = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
	@months = ('January','February','March','April','May','June','July','August','September','October','November','December');
	($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
	$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
	$year += 1900;
	$now = "$days[$wday], $months[$mon] $mday, $year";
}
sub prt {print "<html><head><META HTTP-EQUIV=Refresh CONTENT=\"2; URL=$thankyou\"></head><body><img src = \"http://www.applytools.com/wb/af.pl\" height = 1 width = 1>";}
sub parse {if ($ENV{"REQUEST_METHOD"} eq 'GET') {$buffer = $ENV{'QUERY_STRING'};} else {read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});}@pairs = split(/&/, $buffer);foreach $pair (@pairs) {($name, $value) = split(/=/, $pair);$value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;$FORM{$name} = $value;}}sub mime {print "Content-type:  text/html\n\n";}