#!/usr/bin/perl #------------------------------------------------------------------------------# use DBI; #use lib "/mnt/stor15-wc2-dfw1/422298/shared/lib/perl"; use CGI::Carp qw(carpout fatalsToBrowser); use CGI::Simple; #$CGI::Simple::POST_MAX = 1024 * 10240; #(10MB) #$CGI::Simple::DISABLE_UPLOADS = 0; use Mail::RFC822::Address qw(valid validlist); use MIME::Lite; #------------------------------------------------------------------------------# # Email HTML header $hdrEmail =&hdr; # Email HTML footer $ftrEmail =&ftr; #Email Text Signature (no HTML, use \n for line breaks) $SigT ="\n\nBody Rebuilders"; $SigT.="\nwww.bodyrebuilders.com"; $SigT.="\n610-668-4055\n"; # Email HTML Signature $SigH =""; # Path Prefix (When Using MOD REWRITE) $pfx = "/asset/forms/"; # Logo Path $logo = "/assets/logo-sm.png"; #email prefix $emailPrefix="[Body Rebuilders]"; #no reply email $emailNoreply="noreply\@imanpro.com"; #admin email overide #my $sendAdminTo=""; #domain $domain = "www.bodyrebuilders.com"; #dealer name $dealerName ="Body Rebuilders"; #Email HTML Signature OVERIDE in SENDCGI my $sigAdd="

 

 

Body Rebuilders
One Belmont Ave, Suite 400, Bala Cynwyd, PA 19004
(610)-668-4055

"; #------------------------------------------------------------------------------# #DB Connect Strings\ my $DBHost="localhost"; my $DBName="DBBODRBLD"; my $DBUser="dbubodrbld"; my $DBPass="StaRLkTB96fDC3ac"; my $DBPort="3306"; #&dbconnect($DBHost,$DBName,$DBUser,$DBPass,$DBPort); #------------------------------------------------------------------------------# # Email Server Connection Strings $sendServerName ="smtp.mailgun.org"; $sendServerPort =587; $sendServerAUTH ="noreply\@imanpro.net"; # smtp username $sendServerPASS ="lEQFbQPxLZdzXClpwho1HfKyBjCS8d"; # smtp password #------------------------------------------------------------------------------# my $analytics=""; #------------------------------------------------------------------------------# #&dataDebug; # Uncomment to run debug routine #------------------------------------------------------------------------------# sub hdr { my $DAT=" Messenger "; return $DAT; } #------------------------------------------------------------------------------# sub ftr { my $DAT=" "; return $DAT; } #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# print "Content-type: text/html\n\n"; #------------------------------------------------------------------------------# $cgi = CGI::Simple->new; foreach $key ($cgi->param) { $FORM{$key}=$cgi->param($key); } $act=$cgi->param('act'); $reqF=$FORM{reqF}; #------------------------------------------------------------------------------# my $reqFile="./".$FORM{reqF}.".dat"; if (!$FORM{reqF}) { #print "\n Invalid File Request"; exit; } else { require $reqFile; } if (!$ENV{'HTTP_REFERER'}) { #$formError.="
" if ($formError); #$formError.="\n Invalid Referer"; #$formStop=1; #print $formError } if (($FORM{init}==1) && $formStop!=1) { &dataChk; } if ($e->{tveblacklist} eq "Yes" && $formStop!=1) { #print 1; exit; &runDisp('done'); exit; } if ($FORM{init}==1 && !$formError) { #print 2; exit; &send; # if($FORM{reqF}=="pri-2015"){ # &runDB; # } &runDisp('done'); }else { &runDisp; } exit; #------------------------------------------------------------------------------# sub runDisp { my $OPT=shift; print " Email Messenger "; if ($analytics && $OPT ne "done" && !$formError) { print " "; } print " "; if ($OPT eq "done") { print "
$formTitle
$sendRedirMsg
Redirecting...
"; } else { if ($formStop!=1) { if (!$formError) { print "" } print &dataPrt; } } print " \n\n"; } #------------------------------------------------------------------------------# sub send { # send Admin &dataReq; &sendMIME("sendAdmin"); # send Reply if ($sendReplyTrue==1){ &dataReq; &sendMIME("sendReply"); } } #------------------------------------------------------------------------------# sub sendMIME { my $ALT=shift; my $typ; my $fr; my $to; my $cc; my $bc; my $sbj; my $msg; if ($ALT=~/Reply$/) { if ($sendReplyType eq "TEXT") { $msg=$sendReplyBody; $msg.=$SigT; $typ="text/plain" } else { $msg=$hdrEmail.$sendReplyBody.$ftrEmail; $msg.=$SigH.$sigAdd; $typ="text/html"; } $fr =$sendReplyFr; $to =$sendReplyTo; $cc =$sendReplyCc; $bc =$sendReplyBc; $sbj=$sendReplySubj; } else { if ($sendAdminType eq "TEXT") { $msg=$sendAdminBody; $msg.=$SigT; $typ="text/plain" } else { $msg=$hdrEmail.$sendAdminBody.$ftrEmail; $msg.=$SigH.$sigAdd; $typ="text/html"; } $fr =$sendAdminFr; $to =$sendAdminTo; $cc =$sendAdminCc; $bc =$sendAdminBc; $sbj=$sendAdminSubj; } my $sendEmail = MIME::Lite->new( From => $fr, FromSender => $fr, To => $to, Cc => $cc, Bcc => $bc, Subject => $sbj, Type => $typ, Data => $msg ); #print "$fr,$to,$cc,$bc,$sbj,$msg,$typ"; exit; #&sendDebug($fr,$to,$cc,$bc,$sbj,$msg,$typ); #trim whitespace $fr=~s/^\s+|\s+$//g; $to=~s/^\s+|\s+$//g; #my @bl=dosql("SELECT 1 FROM TNT_blacklist WHERE LOWER(blemail)=LOWER('$fr') OR LOWER(blemail)=LOWER('$to')"); #if ($bl[0]==1) { # #do nothing; # } #else { # $sendEmail->send('smtp',$sendServerName,Port=>$sendServerPort,AuthUser=>$sendServerAUTH,AuthPass=>$sendServerPASS); # } $sendEmail->send('smtp',$sendServerName,Port=>$sendServerPort,AuthUser=>$sendServerAUTH,AuthPass=>$sendServerPASS); } #------------------------------------------------------------------------------# sub dbconnect { our $dbh=DBI->connect("DBI:mysql:$DBName:$DBHost:$DBPort","$DBUser","$DBPass",{RaiseError=>1,AutoCommit=>1}); } #------------------------------------------------------------------------------# sub disconnect { $dbh->disconnect(); } #------------------------------------------------------------------------------# sub parseIN { my $dat=shift; $dat=~s/'/'/g; $dat=~s/^\s+//; $dat=~s/\s+$//g; return $dat; } #------------------------------------------------------------------------------# sub dosql { my $doQuery=shift; my $rth = $dbh->prepare($doQuery); $rth->execute(); my @rrr = $rth->fetchrow_array; $rth->finish(); return @rrr; } #------------------------------------------------------------------------------# sub dosqlhr { my $doQuery=shift; my $rth = $dbh->prepare($doQuery); $rth->execute(); my $hash_ref = $rth->fetchrow_hashref; $rth->finish(); return $hash_ref; } #------------------------------------------------------------------------------# sub formatPhone { my $HTML; if (length($_[0])<10) { undef $HTML; } elsif(length($_[0])==10 && $_[1] eq "dash") { $_[0] =~ m/(\d{3})(\d{3})(\d{4})/; $HTML="$1\-$2\-$3"; } elsif(length($_[0])==10) { $_[0] =~ m/(\d{3})(\d{3})(\d{4})/; $HTML="($1) $2\-$3"; } else { $HTML=$_[0]; } return $HTML; } #------------------------------------------------------------------------------# sub formatPrice { my $PRICE=shift; my $FRMAT=shift; my $NOZER=shift; my $NOK =shift; my $COMMA=0; my $DOLLA=0; $PRICE=0 if (!$PRICE); if ($PRICE==0 && $NOZER==1) { return; } if ($PRICE==0 && $NOZER==2) { return "Call for Price"; } if ($PRICE==0 && $NOZER==3) { return "NA"; } if ($FRMAT eq "full") { $DOLLA=1; $COMMA=1; $PRICE=sprintf("%.2f",$PRICE); } elsif ($FRMAT eq "pfull") { $PRICE = substr($PRICE,0,-3) if (substr($PRICE,-3)=~/^\./); $DOLLA=1; $COMMA=1; } elsif ($FRMAT eq "trim") { $DOLLA=0; $COMMA=1; } elsif ($FRMAT eq "ptrim") { $PRICE = substr($PRICE,0,-3) if (substr($PRICE,-3)=~/^\./); $DOLLA=0; $COMMA=1; } elsif ($FRMAT eq "min") { $PRICE = substr($PRICE,0,-3) if (substr($PRICE,-3)=~/^\./); $DOLLA=0; $COMMA=0; } elsif ($FRMAT=~/^k/) { if ($PRICE>1000) { if (substr($PRICE,-3)=~/^\./) { $PRICE = substr($PRICE,0,-3); } $PRICE=($PRICE/1000); $PRICE=sprintf("%.2f",$PRICE+=0.05); # Round $PRICE=substr($PRICE,0,-1); $PRICE=substr($PRICE,0,-2) if ($PRICE=~/\.0$/); $PRICE.="K" unless $NOK==1; } else { if (substr($PRICE,-3)=~/^\./) { $PRICE = substr($PRICE,0,-3); } } if ($FRMAT=~/full$/) { $DOLLA=1; $COMMA=0; } else { $DOLLA=1; $COMMA=0; } } if ($COMMA==1) { $PRICE =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; } if ($DOLLA==1) { $PRICE = "\$".$PRICE; } return $PRICE; } #------------------------------------------------------------------------------# sub sendDebug { my $ALT=shift; print " Subject => $_[4] From => $_[0] To => $_[1] Cc => $_[2] Bcc => $_[3] Type => $_[6] Data => $_[5] "; exit; } #------------------------------------------------------------------------------#