Приглашаем посетить
Mail Web
#!/usr/bin/perl
# MailWeb version 3.1.2
# Written by: Dave Palmer <dave@upstatepress.com>
# http://upstatepress.com/dave/perl.shtml
############################################################
# MailWeb is a simple CGI program that creates a
# Web based interface for sendmail. It allows your visitors
# to send you or anyone you want, e-mail through the Web.
# This new version marks some new features like a report
# function that allows you to view a log of MailWeb through
# the browser. Also, installation is a bit easier.
#############################################################
$mailprog = '/usr/sbin/sendmail';
# For Windows users, you'll need Blat.exe
# $mailprog = 'c:/path/to/blat/blat.exe';
# Would you like to keep a log?
$log = "yes"; # or enter "no"
$logfile = "/u3/home/upstate/public_html/mailweb/logfile.txt";
$tempdirectory = "/u3/home/upstate/public_html/mailweb/";
$data = "/u3/home/upstate/public_html/mailweb/data.txt";
$date = '/bin/date';
# For Windows users:
# $date = localtime(time);
# What operating system are we on?
$os = "UNIX"; # enter: "WINDOWS" for NT or 95 machines.
# list of e-mail addresses
@email_list = ("dave@upstatepress.com","tracy@upstatepress.com",
"webmaster@upstatepress.com","info@upstatepress.com");
############################################################
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $input);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# Lets translate our hash variables
$recipient = $FORM{'recipient'};
$message = $FORM{'message'};
$fromwho = $FORM{'fromwho'};
$fromname = $FORM{'fromname'};
$subject = $FORM{'subject'};
# Get rid of blank lines
# this fixes the bug of wierd blank lines
$message =~ s/\cM//g;
$message =~ s/\n/ /g;
# Check fields
&missing(message) unless $message;
&missing(your_email_address) unless $fromwho;
&missing(subject) unless $subject;
# What we have to do
&getdate;
if($log eq "yes") {
&LogIt;
}
if ($os eq "UNIX") {
&SendIt;
} else {
require "winmail.pl";
&SendMail($mailprog, $tempdirectory, $subject,
$email_list[$recipient], $message);
}
&PrintResponse;
# functions #
sub SendIt {
open (MAIL, "|$mailprog -t") || die $!;
print MAIL "To: $email_list[$recipient]\n";
print MAIL "From: $fromname <$fromwho>\n";
print MAIL "Subject: $subject\n";
print MAIL "$message\n";
close(MAIL);
}
sub LogIt {
open(DATA, "$data") || die $!;
$number = <DATA>;
close(DATA);
$number++;
open(DATA, ">$data") || die $!;
print DATA "$number";
close(DATA);
open (FILE, ">>$logfile") || die $!;
print FILE "$email_list[$recipient]&&$fromwho&&$fromname&&$subject&&$message&&$date&&$number\n";
close(FILE);
}
sub getdate {
@days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
@months = ('January','Feburary','March','April','May','June','July','August','September',
'October','November','December');
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
if($hour < 10) { $hour = "0$hour"; }
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
$date = "$days[$wday], $months[$mon] $mday, 19$year";
}
sub PrintResponse {
print "Content-type: text/html\n\n";
print <<"END"
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<p><font size=6>Thanks!</font></p>
<p>Thanks for sending $email_list[$recipient] e-mail. We'll get back to you as soon as possible!</p>
<p><a href="/dave/perl.shtml">Return home</a></p>
</body>
</html>
END
}
sub missing {
local($what) = @_;
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>You Forgot: $what</TITLE></HEAD>\n";
print "<BODY>\n";
print "You forgot to fill out: <b>$what</b>\n";
print "<br><br>\n";
print "Please go back and try again!\n";
print "</BODY></HTML>\n";
exit;
}