| Current File : //usr/tmp/par-streamof/cache-019bf52da828c7d4df54624dfe058723871c67b9/e88c866b.pl |
package main; shift @INC;
#line 1 "script/FormProcess.pl"
#!/usr/bin/perl
my $userid=(getpwuid($>));
my $config_path="/var/wcp4/$userid/config/FormProcess";
my $invalid_str = "Invaild users.";
if (-f $config_path) {
require $config_path;
if($is_install ne "1") {
print "Content-type: text/html\n\n";
print $invalid_str;
exit;
}
$check_path = $ENV{'SCRIPT_NAME'};
if(!($check_path =~ /$prog_path/)) {
print "Content-type: text/html\n\n";
print $invalid_str;
exit;
}
} else {
print "Content-type: text/html\n\n";
print $invalid_str;
exit;
}
$HTTP_HOST = $ENV{'HTTP_HOST'};
$HTTP_REFERER = $ENV{'HTTP_REFERER'};
if($HTTP_REFERER =~ /(http:\/\/|https:\/\/)(.+)(\/)/) { $HTTP_REFERER = $2; }
if($HTTP_REFERER =~ /$HTTP_HOST/) { } else {
print "Content-type: text/html\n\n";
print $invalid_str;
exit;
}
$user_brow = $ENV{'HTTP_USER_AGENT'};
if(($user_brow eq "") or ($user_brow eq "-")) {
print "Content-type: text/html\n\n";
print $invalid_str;
exit;
}
$sendmail_loc = "/usr/lib/sendmail";
$sendername = "HelpDesk";
#$def_email =~ s/,/;/ge;
$fromemail = $def_email;
$mail_subject = "Email From Your Web Site";
$toemail = $def_email;
# Please note that you have to escape @ caracters. @ characters needs to be written as \@
$cgi_loc = "/home/".$userid."/public_html".$StatDir;
########################################################################
if ($ENV{'QUERY_STRING'} ne "") {
$temp = $ENV{'QUERY_STRING'};
} else {
read(STDIN, $temp, $ENV{'CONTENT_LENGTH'});
}
my @pairs;
@pairs=split(/&/,$temp);
$email = $email . "\nMessage:\n";
$email = $email . "===============\n";
foreach $item(@pairs) {
($key,$content)=split (/=/,$item,2);
if($content =~ /Content-Type/i) {
print "Content-type: text/html\n\n";
print $invalid_str;
exit;
} elsif($content =~ /Content-Transfer-Encoding/i) {
print "Content-type: text/html\n\n";
print $invalid_str;
exit;
} else {
$content=~tr/+/ /;
$content=~ s/%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
$crit = chr(13);
if ($key ne "button"){
if ((length($content) > 40) or ($content =~ /$crit/) or ($content =~ /\n/)) {
#$email = $email . "\n$key:\n";
#$email = $email . "===============\n";
$email = $email . "$content\n\n";
} else {
$email = $email . "$key: $content\n";
}
}
}
}
### CHECK FOR ERRORS
$exists = (-e "$cgi_loc/contact_error.txt");
if ($exists > 0) {
open (DRST, "$cgi_loc/contact_error.txt");
while (defined($line=<DRST>)) {
($formvar, $error_text)=split(/:/,$line,2);
if (defined($fields{$formvar})) {
if ($fields{$formvar} eq "") {
&got_error ($error_text);
}
}
}
close (DRST);
}
### SET MAILING PARAMETRES
if ($fields{'Name'} ne ""){$sendername = $fields{'Name'};}
if ($fields{'Email'} ne ""){$fromemail = $fields{'Email'};}
if ($fields{'Subject'} ne ""){$mail_subject = $fields{'Subject'};}
##### SEND AUTORESPONSE
$rsp = "contact_response.txt";
$exists = (-e "$cgi_loc/$rsp");
if ($exists > 0) {
$fsize1 = (-s "$cgi_loc/$rsp");
if ($fsize1 > 0) {
open (DRST, "$cgi_loc/$rsp");
read(DRST,$responder,$fsize1);
close (DRST);
}
$responder =~ s/!!Name!!/$fields{'Name'}/g;
#### SEND AUTORESPONDER MAIL
#&send_email ($sendmail_loc, $sendername, $fromemail, $fields{'Email'}, $def_email, $responder);
#&send_email ($sendmail_loc, $sendername, $fromemail, $fields{'Email'}, $mail_subject, $responder);
}
#### SEND MAIL TO FROM CONTACT FORM
&send_email ($sendmail_loc, $sendername, $fromemail, $toemail, $mail_subject, $email);
print "Content-type: text/html\n\n";
$thahtml = "$cgi_loc/contact_thanks.html";
$fsize1 = (-s "$thahtml");
if ($fsize1 > 0) {
open (DRST, "$thahtml");
read(DRST,$thankshtml,$fsize1);
close (DRST);
print "$thankshtml";
} else {
print "THANKS - WE WILL TEND TO YOUR REQUREST";
}
exit;
sub send_email {
my($sendmail_loc, $sendername, $fromemail, $toemail, $mail_subject, $email_message) = @_;
open(MAIL,"|$sendmail_loc -t");
print MAIL "Return-Path: $fromemail\n";
print MAIL "To: $toemail\n";
print MAIL "From: $sendername <$fromemail>\n";
print MAIL "Reply-To: $fromemail\n";
print MAIL "Sender: $fromemail\n";
print MAIL "Subject: $mail_subject\n";
print MAIL "Content-Type: text/plain; charset=\"UTF-8\"\n";
print MAIL "$email_message\n\n";
close (MAIL);
}
sub send_email_2 {
my($sendmail_loc, $sendername, $fromemail, $toemail, $mail_subject, $email_message) = @_;
### check for attacks
$toemail =~ s/\;//g;
$toemail =~ s/^\s+//g;
$toemail =~ s/\s+$//g;
if ($toemail =~ /^\S+\@\S+$/) {
open (SENDMAIL, "| $sendmail_loc $toemail");
print SENDMAIL <<End_of_Mail;
From: "$sendername" <$fromemail>
To: $toemail
Reply-To: $fromemail
Subject: $mail_subject
Sender: $fromemail
$email_message
End_of_Mail
}
}
sub got_error {
my ($etext) = @_;
print "Content-type: text/html\n\n";
$errhtml = "$cgi_loc/contact_error.html";
$fsize1 = (-s "$errhtml");
if ($fsize1 > 0){
open (DRST, "$errhtml");
read(DRST,$ehtml,$fsize1);
close (DRST);
$ehtml =~ s/%%problem%%/$etext/g;
} else {
$ehtml = $etext;
}
print "$ehtml";
exit;
}