head	1.3;
access;
symbols;
locks; strict;
comment	@# @;


1.3
date	2005.08.14.21.08.41;	author rse;	state Exp;
branches;
next	1.2;

1.2
date	2005.08.14.20.55.35;	author rse;	state Exp;
branches;
next	1.1;

1.1
date	2004.02.27.20.03.29;	author rse;	state Exp;
branches;
next	;


desc
@@


1.3
log
@the email is mandatory for the form because a mail is generated which needs a correct sender
@
text
@#!/v/openpkg/sw/bin/perl -w
##
##  feedback.cgi -- Send feedback mail
##  Copyright (c) 1999-2003 Ralf S. Engelschall, All Rights Reserved. 
##

use CGI;

#   switch to unbuffered I/O
$|++;

my $cgi = new CGI;

#   generate a webpage
sub send_page {
    my ($text) = @@_;

    $O = '';
    $O .= "Content-type: text/html\n" .
          "Connection: close\n" .
          "\n";
    open(FP, "<feedback.cgi.head.html");
    $O .= $_ while (<FP>); 
    close(FP);
    $O .= $text;
    open(FP, "<feedback.cgi.foot.html");
    $O .= $_ while (<FP>); 
    close(FP);
    print $O;
}

#   let us catch runtime errors...
eval {

#   check for parameter consistency
die "You supplied no Personal Name." 
    if ($cgi->param("person-name") eq '');
die "You supplied no Personal Email address." 
    if ($cgi->param("person-email") eq '');
die "Hmmm... <tt>".$cgi->param('person-email')."</tt> doesn't look like a valid RFC822 mail address."
    if ($cgi->param("person-email") ne '' and $cgi->param("person-email") !~ m|^[a-zA-Z0-9_=%,.~+-]+@@([a-zA-Z0-9]+)(\.[a-zA-Z0-9]+)*$|);

#   generate mail
my $mail = '';
$mail .= "From: \"".$cgi->param('person-name')."\" <".$cgi->param('person-email').">\n";
$mail .= "Reply-To: ".$cgi->param('person-email')."\n";
$mail .= "Subject: OpenPKG Community Feedback\n";
$mail .= "To: openpkg-team\@@openpkg.org\n";
$mail .= "\n";
$mail .= "Remote Client Information:\n";
foreach my $var (qw(
    REMOTE_ADDR
    HTTP_USER_AGENT
)) {
    $mail .= sprintf("  %-21s", "$var:") . $ENV{$var} . "\n";
}
$mail .= "\n";
$mail .= "Feedback Form Information:\n";
foreach my $item (qw(
    person-name
    person-email
    organisation-name
    organisation-url
    organisation-class
    heard-month
    heard-year
    heard-media
    usage-phase
    usage-platforms
    usage-machines
    usage-multiinstance
    usage-environment
    usage-release
    feedback-reqpackage
    feedback-like
    feedback-dislike
    advocacy-statement
)) {
    my $text = join(", ", $cgi->param($item));
    $text =~ s|\r?\n$||s;
    $text =~ s|\n|"\n"."  ".(" " x 21)|sge;
    $mail .= sprintf("  %-21s", "$item:") . $text . "\n";
}
$mail .= "\n";

#  send out mail
open(MAIL, "|/v/openpkg/sw/sbin/sendmail -oi -oee openpkg-team\@@openpkg.org") || die;
print MAIL $mail;
close(MAIL);

#  generate result page
my $mail_html = $mail;
$mail_html =~ s|&|&amp;|sg;
$mail_html =~ s|<|&lt;|sg;
$mail_html =~ s|>|&gt;|sg;
&send_page(
    "Thanks. Your feedback was successfully parsed " .
    "and forwarded to the OpenPKG project."
    # "leader via Email in the following format:" .
    # "<p>" .
    # "<table width=100% cellpadding=5 bgcolor=\"#e5e0d5\"><tr><td>" .
    # "<pre>$mail_html</pre>\n" .
    # "</td></tr></table>"
);

#   die gracefully
exit(0);

#   ...the runtime error handler:
};
if ($@@) {
    my $text = $@@;
    $text =~ s|at /.*||;
    &send_page(
        "A fatal error occured while processing the contents of your " .
        "feedback. Please check the error message below, go back to" .
        "the form and fix the problem." .
        "<p>\n" .
        "<font color=\"#cc3333\"><b>$text</b></font>\n"
    );
}

@


1.2
log
@unbreak the feedback form after last migrations
@
text
@d38 2
@


1.1
log
@add feedback page to CVS
@
text
@d1 1
a1 1
#!/e/openpkg/sw/bin/perl -w
d85 1
a85 1
open(MAIL, "|/e/openpkg/sw/sbin/sendmail -oi -oee openpkg-team\@@openpkg.org") || die;
@

