use Email::Valid; use CGI; # use the CGI as the default output object GetTime(); $query = new CGI; $mailserver_primary = '198.95.10.19'; #testing only #$mailserver_primary = '205.227.165.17'; $mailserver_secondary = '198.95.10.16'; $mailserver_lastresort = '198.95.10.254'; $remoteip = $ENV{'REMOTE_ADDR'}; $browsertype = $ENV{'HTTP_USER_AGENT'}; $toaddress = "mediarelations\@lronhubbard.org"; #testing only #$toaddress = "postmaster\@scientology.net"; $fromaddress = "website-relay\@scientology.net"; $adminaddress = "postmaster\@scientology.net"; $subject_line = "LRH Media Site Press-Ready Photo Request"; $logging_drive = "d:"; # the drive that it is possible to save data to $website_drive = "d:"; # the drive that contains the files that need to be read $moreinfopgfile = "$website_drive/lrh_media/eng/photo/page02\.htm"; $name = $query->param('name'); $email = $query->param('email'); $mediaco = $query->param('business'); $address = $query->param('address'); $city = $query->param('city'); $state = $query->param('state'); $prov = $query->param('prov'); $zip = $query->param('zip'); $country = $query->param('country'); $country =~ s/Select One//; $phone = $query->param('phonew'); $extension = $query->param('extension'); $fax = $query->param('faxw'); $photo1 = $query->param('LRH01TIF'); $photo2 = $query->param('LRH02TIF'); $photo3 = $query->param('LRH03TIF'); $photo4 = $query->param('LRH04TIF'); $photo5 = $query->param('LRH05TIF'); $photo6 = $query->param('LRH06TIF'); $photo7 = $query->param('LRH07TIF'); $photo8 = $query->param('LRH08TIF'); $photo9 = $query->param('LRH09TIF'); $photo10 = $query->param('LRH10TIF'); if (($email ne "")) { $emailtest = Email::Valid->address($email); if ($emailtest ne "") { $email = $emailtest; } } if (($name eq "") || ($email eq "") || ($mediaco eq "") || ($address eq "") || ($city eq "") || (($state eq "") && ($country eq "United States")) || ($zip eq "") || ($country eq "") || ($phone eq "")) { open(MOREINFOPG,$moreinfopgfile); undef $/; $moreinfohtml = ; close(MOREINFOPG); $moreinfohtml =~ s//Please ensure the entries marked in red are filled out correctly - this information is necessary to process your request.<\/font>/; if ($name eq "") { $moreinfohtml =~ s/<\/B> (.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/NAME="name" SIZE=40 MAXLENGTH=40>/NAME="name" SIZE=40 MAXLENGTH=40 VALUE="$name">/; } if ($mediaco eq "") { $moreinfohtml =~ s/<\/B> (.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/NAME="business" SIZE=40>/NAME="business" SIZE=40 VALUE="$mediaco">/; } if ($email eq "") { $moreinfohtml =~ s/<\/B> (.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/NAME="email" SIZE=40>/NAME="email" SIZE=40 VALUE="$email">/; } if ($address eq "") { $moreinfohtml =~ s/<\/B> (.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/NAME="address" SIZE=40 MAXLENGTH=75>/NAME="address" SIZE=40 MAXLENGTH=75 VALUE="$address">/; } if ($city eq "") { $moreinfohtml =~ s/<\/B> (.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/NAME="city" SIZE=40 MAXLENGTH=40>/NAME="city" SIZE=40 MAXLENGTH=40 VALUE="$city">/; } if (($state eq "") && ($country eq "United States")) { $moreinfohtml =~ s/<\/B> (.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/(.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/NAME="zip" SIZE=20 MAXLENGTH=20>/NAME="zip" SIZE=20 MAXLENGTH=20 VALUE="$zip">/; } if ($country eq "") { $moreinfohtml =~ s/<\/B> (.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/(.*?)<\/a>/ $1<\/a><\/b>/; } else { $moreinfohtml =~ s/NAME="phonew" SIZE=20 MAXLENGTH=20>/NAME="phonew" SIZE=20 MAXLENGTH=20 VALUE="$phone">/; } if ($extension ne "") { $moreinfohtml =~ s/NAME="extension" SIZE=20 MAXLENGTH=20>/NAME="extension" SIZE=20 MAXLENGTH=20 VALUE="$extension">/; } if ($fax ne "") { $moreinfohtml =~ s/NAME="faxw" SIZE=20 MAXLENGTH=20>/NAME="faxw" SIZE=20 MAXLENGTH=20 VALUE="$fax">/; } if ($photo1 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH01TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH01TIF">/; } if ($photo2 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH02TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH02TIF">/; } if ($photo3 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH03TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH03TIF">/; } if ($photo4 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH04TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH04TIF">/; } if ($photo5 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH05TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH05TIF">/; } if ($photo6 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH06TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH06TIF">/; } if ($photo7 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH07TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH07TIF">/; } if ($photo8 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH08TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH08TIF">/; } if ($photo9 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH09TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH09TIF">/; } if ($photo10 eq "on") { $moreinfohtml=~ s/TYPE="CHECKBOX" NAME="LRH10TIF">/TYPE="CHECKBOX" CHECKED NAME="LRH10TIF">/; } print "Content-type: text/html\n\n"; # tell the web-server the type of file that is being sent print $moreinfohtml; } else { undef $phototext; if ($photo1 eq "on") { $phototext = "1"; } if ($photo2 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 2"; } else { $phototext = "2"; } } if ($photo3 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 3"; } else { $phototext = "3"; } } if ($photo4 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 4"; } else { $phototext = "4"; } } if ($photo5 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 5"; } else { $phototext = "5"; } } if ($photo6 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 6"; } else { $phototext = "6"; } } if ($photo7 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 7"; } else { $phototext = "7"; } } if ($photo8 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 8"; } else { $phototext = "8"; } } if ($photo9 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 9"; } else { $phototext = "9"; } } if ($photo10 eq "on") { if ($phototext ne "") { $phototext = $phototext . ", 10"; } else { $phototext = "10"; } } $moreinfodata = "LRH Photo Request form: http://mediaresources.lronhubbard.org/photo/page02.htm\n\nName: $name\nMedia Company: $mediaco\nEmail: $email\nAddress: $address\nCity: $city\nState (US): $state\nState/Province (non US): $prov\nZip: $zip\nCountry: $country\nPhone: $phone\nExtension: $extension\nFax: $fax\nPhotos requested: $phototext\n\nDate: $date_time_full\nUser's Browser: $browsertype\nUser's IP address: $remoteip\n\n"; $deliverstatus = EmailDeliver($mailserver_primary); if ($deliverstatus) { $success=1; } else { $deliverstatus = EmailDeliver($mailserver_secondary); if ($deliverstatus) { $success=1; } else { $errorlogfile = ">>c:\\scripterrlog.txt"; open (LOG,$errorlogfile); print LOG "Couldn't talk to any mail servers for LRH Media photo download on $date_time_full\n\n"; close (LOG); } } print "Content-type: text/html\n\n"; $downloadpagefile = "d:\\lrh_media\\eng\\photo\\thankyou.htm"; open(DOWNLOADPG,$downloadpagefile); undef $/; $downloadpghtml = ; close (DOWNLOADPG); print $downloadpghtml; #print "phototext = $photo1\nsuccess = $success\n"; } sub EmailDeliver { use Net::SMTP; $maildeliver = Net::SMTP->new($_[0]); if (not($maildeliver)) { $deliverstatus=0; return($deliverstatus); } $maildeliver -> mail( $fromaddress ); if (not($maildeliver)) { $deliverstatus=0; # $emaildeliver_failedon = "Sending \"mail from\" to $_[0] failed.\n"; return($deliverstatus); } $maildeliver -> to($toaddress); if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Sending \"rcpt to\" to $_[0] failed.\n"; return($deliverstatus); } $maildeliver ->data(); if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Sending \"data\" to $_[0] failed.\n"; return($deliverstatus); } $maildeliver ->datasend("To: $toaddress\n"); if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Sending \"To\" header to $_[0] failed.\n"; return($deliverstatus); } $maildeliver ->datasend("From: $fromaddress\n"); if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Sending \"From\" header to $_[0] failed.\n"; return($deliverstatus); } $maildeliver ->datasend("Subject: $subject_line\n"); if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Sending \"Subject\" header to $_[0] failed.\n"; return($deliverstatus); } $maildeliver ->datasend("\n"); if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Sending newline after header to $_[0] failed.\n"; return($deliverstatus); } $maildeliver ->datasend("$moreinfodata\n"); if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Sending body to $_[0] failed.\n"; return($deliverstatus); } $maildeliver ->dataend(); if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Ending body to $_[0] failed.\n"; return($deliverstatus); } $maildeliver ->quit; if (not($maildeliver)) { $deliverstatus=0; $emaildeliver_failedon = "Disconnecting from $_[0] failed.\n"; return($deliverstatus); } $deliverstatus=1; return($deliverstatus); } sub GetTime { $seconds = time; @date = localtime($seconds); $year = $date[5]+1900; @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); $month = $months[$date[4]]; $hour = $date[2]; $min = sprintf("%02d", $date[1]); $sec = sprintf("%02d", $date[0]); if ($hour >= 12) { $pm = 1; if ($hour>12) { $hour = $hour-12;} } if ($hour == 0) { $hour = 12; } $date_only = "$date[3]-$month-$year"; $date_time = "$date_only $hour:$min"; if (length($min) == 1) { $min = $min . "0";} $date_time_full = "$date_only $hour:$min:$sec"; if ($pm) { $date_time_full = $date_time_full . " PM"; } else { $date_time_full = $date_time_full . " AM"; } }