home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl
- $mail_prog = '/usr/lib/sendmail' ;
- # 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.
-
- $first = $field{'first'} ;
- $last = $field{'last'} ;
- $company = $field{'company'} ;
- $email = $field{'email'} ;
- $whereheard = $field{'whereheard'} ;
- $athome = $field{'athome'} ;
- $atwork = $field{'atwork'} ;
- $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>Field 'first' must be filled in.</p>\n" ;
-
- if ($first eq "") {
- $message = $message.$errmsg ;
- $found_err = 1 ; }
-
-
- $errmsg = "<p>Field 'last' must be filled in.</p>\n" ;
-
- if ($last eq "") {
- $message = $message.$errmsg ;
- $found_err = 1 ; }
-
-
- $errmsg = "<p>Please enter a valid email address</p>\n" ;
-
- if ($email !~ /.+\@.+\..+/) {
- $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 log.txt
-
-
- open (LOGFILE, ">> log.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.
-
- print LOGFILE "$first\t$last\t$company\t$email\t$whereheard\t$athome\t$atwork\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 = "webmaster\@yourownsite.com" ;
-
- open (MAIL, "|$mail_prog -t");
- print MAIL "To: $recip\n";
- print MAIL "Reply-to: $email\n";
- print MAIL "From: $email\n";
- print MAIL "Subject: DownLoad Alert!\n";
- print MAIL "\n\n";
- print MAIL "The following user has downloaded Power Widget:\n" ;
- print MAIL "\n" ;
- print MAIL "Name: ".$first." ".$last."\n" ;
- print MAIL "\n" ;
- print MAIL "Company: ".$company."\n" ;
- print MAIL "\n" ;
- print MAIL "Where Heard about Power Widget: ".$whereheard."\n" ;
- print MAIL "\n" ;
- print MAIL "Use at home? ".$athome."\n" ;
- print MAIL "Use at work? ".$atwork."\n" ;
- print MAIL "\n\n";
- close (MAIL);
-
-
- $recip = $email ;
-
- open (MAIL, "|$mail_prog -t");
- print MAIL "To: $recip\n";
- print MAIL "Reply-to: sales\@yourownsite.com\n";
- print MAIL "From: sales\@yourownsite.com\n";
- print MAIL "Subject: Power Widget\n";
- print MAIL "\n\n";
- print MAIL "Hi ".$first.",\n" ;
- print MAIL "\n" ;
- print MAIL "Thank you for downloading PowerWidget!\n" ;
- print MAIL "\n" ;
- print MAIL "Please contact us if you have any questions.\n" ;
- print MAIL "\n" ;
- print MAIL "Sincerely,\n" ;
- print MAIL "\n" ;
- print MAIL "Power Widget Sales Dept.\n" ;
- print MAIL "\n\n";
- close (MAIL);
-
- # ***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 "Content-type: text/html\n\n";
- print '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">'."\n" ;
- print "<html>\n" ;
- print "\n" ;
- print "<head>\n" ;
- print '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'."\n" ;
- print '<meta name="Author" content>'."\n" ;
- print '<meta name="GENERATOR" content="Microsoft FrontPage 3.0">'."\n" ;
- print "<title>Perl Builder Output Page Example</title>\n" ;
- print "</head>\n" ;
- print "\n" ;
- print '<body bgcolor="#8080C0" text="#000000" link="#800000" vlink="#000080" alink="#800000">'."\n" ;
- print "\n" ;
- print '<p align="center"><font color="#FFFFFF" face="Arial"><big><strong>Thank You, '.$first.'!</strong></big></font></p>'."\n" ;
- print "\n" ;
- print '<p align="left"> </p>'."\n" ;
- print "\n" ;
- print '<p align="center"><font color="#FFFFFF" face="Arial"><big><strong>Please click the link'."\n" ;
- print "below to download your software:</strong></big></font></p>\n" ;
- print "\n" ;
- print '<p align="center"><font face="Arial" color="#0000FF"><u><big><strong>DeadLink</strong></big></u></font></p>'."\n" ;
- print "\n" ;
- print "<hr>\n" ;
- print "\n" ;
- print '<p align="left"><font face="Arial" color="#000080"><big>You entered the following:</big></font></p>'."\n" ;
- print "\n" ;
- print '<p align="left"><font face="Arial" color="#000080"><big>Name: '.$first.' '.$last.'</big></font></p>'."\n" ;
- print "\n" ;
- print '<p align="left"><font face="Arial" color="#000080"><big>Company: '.$company.'</big></font></p>'."\n" ;
- print "\n" ;
- print '<p align="left"><font face="Arial" color="#000080"><big>Email: '.$email.' </big></font></p>'."\n" ;
- print "</body>\n" ;
- print "</html>\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 '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">'."\n" ;
- print "<html>\n" ;
- print "\n" ;
- print "<head>\n" ;
- print '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'."\n" ;
- print '<meta name="Author" content>'."\n" ;
- print '<meta name="GENERATOR" content="Microsoft FrontPage 3.0">'."\n" ;
- print "<title>Perl Builder Error Page Example</title>\n" ;
- print "</head>\n" ;
- print "\n" ;
- print '<body bgcolor="#8080C0" text="#000000" link="#800000" vlink="#000080" alink="#800000">'."\n" ;
- print "\n" ;
- print '<p align="center"><font color="#FFFFFF" face="Arial"><big><strong>Processing Error</strong></big></font></p>'."\n" ;
- print "\n" ;
- print '<p align="left"><font face="Arial" color="#000080"><strong>You forgot to enter one or more'."\n" ;
- print "values:</strong></font></p>\n" ;
- print "\n" ;
- print '<p align="left"><font color="#FFFFFF" face="Arial"><strong>'.$message.'</strong></font></p>'."\n" ;
- print "\n" ;
- print '<p align="left"><font face="Arial" color="#000080"><strong>Please click your browser\'s'."\n" ;
- print "Back button and try again.</strong></font></p>\n" ;
- print "</body>\n" ;
- print "</html>\n" ;
-
- 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.
-
-