#!/usr/bin/perl ####### Version release 12-16-2007 ## picks for captcha type formmail ####### This program was writen by Dr.D at CoastlandTech.com ####### It it to be used by coastlandtech.com customers only. ####### ####### This file should be called formmail.cgi ####### and it should be chmod 755 # # # This does not have require any data in the form to make work. # It will send anything from the form to the email address. #--------------------------------------------------------------# ## You will need to change the lines that lines that are marked in this program. ## the lines will have YOU MUST CHANGE THE NEXT LINE !! before them... ## go all the way to the end looking for places to change. ## If you wish to have the senders email address in the ## return box you must have the form send the persons ## email address in a field called " mailfrom " ## the $done_url is the page to send people to after ## they press the submit button. ## YOU MUST CHANGE THE NEXT LINE !! $done_url="http://www.diamondtrailersales.net/thanks.php"; $error_url="http://www.diamondtrailersales.net/thanks.php"; &mkdate; ## The $mysubject is the subject on the email you get/ ## You MAY CHANGE the next line but you don't need too. $mysubject="[Message sent from website on $the_date]"; ## You should not need to change this next line for users on my CoastlandTech.com servers. ## On other server this line could need changing. Ask your System Admin ## You MAY NEED TO CHANGE .. $mailprog = '/usr/sbin/sendmail'; &parse_form; &vform; ## test for the picks code... $body="$data "; $mailfrom=$FORM{'mailfrom'}; if ($mailfrom) { # we will use information in the form } else { # we will make out own $mailfrom="Your Website FormMail Script"; } &domail; print "Location: $done_url\n\n"; exit; sub mkdate { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($year > 100) { $year= $year-100 ; } if ($year < 10 ) { $year = "0$year"; } $month = ($mon + 1); @months = ("January","February","March","April","May","June","July","August","September","October","November","December"); $the_date = "$months[$mon] $mday, 20$year Time: $hour:$min "; } # Parse Form Subroutine sub parse_form { $data = "Information from form at $ENV{'SCRIPT_FILENAME'} by $ENV{'REMOTE_ADDR'}\n\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs){ ($val1, $val2) = split(/=/, $pair); $val1 =~ tr/+/ /; $val1 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $val2 =~ tr/+/ /; $val2 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ## 11/29/2003 Next lines are a fix from security problem.. ### $val2 =~ s/\@/at/g; $val2 =~ s/bcc://g; $val2 =~ s/To://g; $val2 =~ s/to://g; $val2 =~ s/to://g; $val2 =~ s/Subject://g; $val2 =~ s/bcc://g; $val2 =~ s/cc://g; $val2 =~ s/CC://g; $val2 =~ s/cC://g; $val2 =~ s/Cc://g; ## if ($FORM{$val1}) { $FORM{$val1} = "$FORM{$val1}, $val2"; } else { $FORM{$val1} = $val2; } if ($val2) { $data = "$data $val1: $val2 \n\n"; } } } sub domail { ## DO NOT MOVE THIS LINE FROM THIS LOCATION AND ## PUT IN YOUR EMAIL ADDRESS HERE. THIS IS DONE HERE FOR SECURITY !! ## PS: Note the \ before the @ it must be keep \@ or ## it will not work.... ## YOU MUST CHANGE NEXT LINE !! $mail_it_to="info\@diamondtrailersales.net"; open (MAIL, "|$mailprog -t") || Die; print MAIL "To: $mail_it_to\n", "From: $mailfrom\n", "Subject: $mysubject\n\n", "$body"; close (MAIL); } sub vform { ##Vform security $Testing=$FORM{'picks']; $Passed=""; open(GOODLIST,"../picks/picks.txt") ; while() { chomp; $hack = $_; if ( $Testing eq $hack) { $Passed= "Good Find" ; } } ; close GOODLIST ; if (!$Passed) { print "Location: $error_url\n\n"; exit; } } 1;