Приглашаем посетить
View Mail
#!/usr/bin/perl
# ViewMail version 1.1
# Written by: Dave Palmer <dave@upstatepress.com>
# http://upstatepress.com/dave/perl.shtml
#
# This small script is for viewing your MailWeb log.
# Its pretty simple now, but I intend to add features
# to this pretty soon.
###################################################################
$logfile = "/u3/home/upstate/public_html/mailweb/logfile.txt";
$cgi_url = "/cgi-bin/viewmail.pl";
###################################################################
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;
}
if ($FORM{'action'} eq "view message") {
&viewmessage;
} else {
&viewall;
}
sub viewall {
print "Content-type: text/html\n\n";
print "<html><head><title>ViewMail</title></head>\n";
print "<body>\n";
print "<table width=100\% border=1 cellpadding=2 cellspacing=2>\n";
open(FILE, "$logfile") || die $!;
while (<FILE>) {
chop;
@all = split(/\n/);
foreach $line (@all) {
local($recipient, $fromwho, $fromname, $subject, $message, $date, $messageID) = split(/&&/, $line);
print "<tr><td width=25\%><font size=-1 face=\"Arial\"><b>Recipient:</b> $recipient</td>\n";
print "<td width=25\%><font size=-1 face=\"Arial\">Sent by: <a href=\"mailto:$fromwho\">$fromname</a></td>\n";
print "<td width=25\%><font size=-1 face=\"Arial\"><b>Subject: </b>$subject</td>\n";
print "<td width=25\%><font size=-1 face=\"Arial\"><form action=\"$cgi_url\" method=POST><input type=submit name=\"action\"\n";
print "value=\"view message\"><input type=hidden name=\"id\" value=\"$messageID\"></form></td>\n";
print "</tr>\n";
}
}
print "</table></body></html>\n";
}
sub viewmessage {
open(FILE, "$logfile") || die $!;
while (<FILE>) {
chop;
@all = split(/\n/);
foreach $line (@all) {
local($recipient, $fromwho, $fromname, $subject, $message, $date, $messageID) = split(/&&/, $line);
if ($FORM{'id'} == $messageID) {
$match = 1;
&showit;
}
}
}
if (! $match) {
print "Content-type: text/html\n\n";
print "<html><head><title>Sorry</title></head>\n";
print "<body>\n";
print "<h1>Sorry</h1>\n";
print "<p>Sorry, but that message no longer exists in the log\n";
print "</body></html>\n";
}
sub showit {
print "Content-type: text/html\n\n";
print "<html><head><title>$fromname message on: $date</title></head>\n";
print "<body>\n";
print "<p><strong>Recipient:</strong> $recipient</p>\n";
print "<p><strong>From:</strong> $fromname \<\;<a href=\"mailto:$fromwho\"><em>$fromwho</em></a>\>\;</p>\n";
print "<p><strong>Subject:</strong> $subject</p>\n";
print "<p><strong>Date Sent</strong>: $date</p>\n";
print "<p>$message</p>\n";
print "</body>\n";
print "</html>\n";
}
}