Files
tobiasd ab997d8bb8
continuous-integration/drone/push Build is passing
internal forms
2026-02-16 13:51:40 +01:00

108 lines
3.6 KiB
Perl
Executable File

#!/usr/bin/perl
use CGI;
use HTML::Entities;
use POSIX qw(strftime);
# -----------------------------------------------------------------------------
# Get parameters
# -----------------------------------------------------------------------------
my $query = new CGI;
my $name = encode_entities(scalar $query->param("name"));
my $function = encode_entities(scalar $query->param("function"));
my $function2 = encode_entities(scalar $query->param("function2"));
my $radioaddress = encode_entities(scalar $query->param("address"));
my $otheraddress = encode_entities(scalar $query->param("other_address"));
my $phone = encode_entities(scalar $query->param("phone"));
my $mobile = encode_entities(scalar $query->param("mobile"));
my $fax = encode_entities(scalar $query->param("fax"));
my $email = encode_entities(scalar $query->param("email"));
my $jabber = encode_entities(scalar $query->param("jabber"));
my $fp = encode_entities(scalar $query->param("fingerprint"));
my $amount = encode_entities(scalar $query->param("amount"));
my $er = encode_entities(scalar $query->param("er"));
my $delivery = encode_entities(scalar $query->param("delivery_address"));
if ($function2 ne "") {
$function .= ", $function2";
}
if ($radioaddress eq "Berlin") { $address = "Revaler Straße 19, 10245 Berlin, Germany"; }
if ($radioaddress eq "other") { $address = "$otheraddress"; }
if ($delivery eq "") {
$delivery = "$address";
}
my $date = strftime "%Y-%m-%d", localtime;
my $time = strftime "%s", localtime;
my $reference = "bc.$date." . substr $time, -3;
my $subject = "Business card order $reference";
# -----------------------------------------------------------------------------
# Generate mail to office
# -----------------------------------------------------------------------------
my $boundary = "NextPart$reference";
my $replyto = "contact\@fsfe.org, $email";
open(MAIL, "|/usr/lib/sendmail -t -f $email");
print MAIL "From: $email\n";
print MAIL "Reply-To: $replyto\n";
print MAIL "Mail-Followup-To: $replyto\n";
print MAIL "To: contact\@fsfe.org\n";
print MAIL "Cc: $email\n";
print MAIL "Subject: $subject\n";
print MAIL "Mime-Version: 1.0\n";
print MAIL "Content-Type: multipart/mixed; boundary=$boundary\n";
print MAIL "Content-Transfer-Encoding: 8bit\n\n\n";
print MAIL "--$boundary\n";
print MAIL "Content-Type: text/plain; charset=utf-8\n";
print MAIL "Content-Transfer-Encoding: 8bit\n\n";
print MAIL "This business card order was sent via web interface\n\n";
print MAIL "--$boundary\n";
print MAIL "Content-Type: text/plain; charset=utf-8\n";
print MAIL "Content-Disposition: attachment; filename=$reference.txt\n";
print MAIL "Content-Description: Business card order\n";
print MAIL "Content-Transfer-Encoding: 8bit\n\n";
print MAIL "-----------------------------------------\n";
print MAIL "Form for ordering business cards\n";
print MAIL "-----------------------------------------\n\n";
print MAIL "Full name: $name\n\n";
print MAIL "Title: $function\n\n";
print MAIL "Address: $address\n\n";
print MAIL "Tel: +$phone\n\n";
print MAIL "Mobile: +$mobile\n\n";
print MAIL "Fax: +$fax\n\n";
print MAIL "E-Mail: $email\n\n";
print MAIL "XMPP: $jabber\n\n";
print MAIL "Fingerprint: $fp\n\n";
print MAIL "Number of business cards ordered: $amount\n\n";
print MAIL "Delivery Address: $delivery\n\n";
print MAIL "--$boundary--\n";
close MAIL;
# -----------------------------------------------------------------------------
# Inform user that everything was ok
# -----------------------------------------------------------------------------
print "Content-type: text/html\n\n";
print "Your order $reference was sent. Thank you.<br /><br />";