639 lines
17 KiB
Perl
Executable File
639 lines
17 KiB
Perl
Executable File
#!/usr/bin/perl -wT
|
|
#----------------------------------------------------------------------
|
|
# heading : Administration
|
|
# description : E-mail Warteschlange
|
|
# navigation : 5000 5100
|
|
# Copyright (C) 2005/2008 Peter Schubert, SACO Software and Consulting GmbH
|
|
#----------------------------------------------------------------------
|
|
use strict;
|
|
use esmith::FormMagick;
|
|
use esmith::ConfigDB;
|
|
use esmith::AccountsDB;
|
|
use esmith::config;
|
|
use esmith::cgi;
|
|
use esmith::util;
|
|
use esmith::lockfile;
|
|
|
|
my $fm = esmith::FormMagick->new();
|
|
|
|
use CGI;
|
|
$CGI::POST_MAX = -1;
|
|
$CGI::DISABLE_UPLOADS = 0;
|
|
$fm->{cgi} = CGI->new();
|
|
|
|
$fm->parse_xml();
|
|
|
|
my $conf = esmith::ConfigDB->open()
|
|
|| die $fm->localise('CANNOT_OPEN').'/home/e-smith/configuration';
|
|
|
|
# We need this hash for some esmith::cgi calls, so...
|
|
tie my %conf, 'esmith::config', $conf->file;
|
|
|
|
# Unbuffer standard output so that files and directories are listed as
|
|
# they are restored
|
|
$| = 1;
|
|
|
|
# Store away current gid of 'www' group.
|
|
my $www_gid = getgrnam("www");
|
|
|
|
#------------------------------------------------------------
|
|
# examine state parameter and display the appropriate form
|
|
#------------------------------------------------------------
|
|
|
|
my $q = $fm->{cgi};
|
|
|
|
if (! grep (/^state$/, $q->param))
|
|
{
|
|
showInitial ($q, '');
|
|
}
|
|
elsif ($q->param ('state') eq "perform")
|
|
{
|
|
performAndShowResult ($q);
|
|
}
|
|
else
|
|
{
|
|
esmith::cgi::genStateError ($q, \%conf);
|
|
}
|
|
|
|
exit (0);
|
|
|
|
#------------------------------------------------------------
|
|
# subroutine to display initial form
|
|
#------------------------------------------------------------
|
|
|
|
sub showInitial
|
|
{
|
|
my ($q, $msg) = @_;
|
|
|
|
if ($msg eq '')
|
|
{
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
$fm->localise('QMH_TITLE'));
|
|
}
|
|
else
|
|
{
|
|
esmith::cgi::genHeaderNonCacheable
|
|
($q, \%conf, $fm->localise('OPERATION_STATUS_REPORT'));
|
|
|
|
print $q->div ({-class => "sme-error"}, $msg);
|
|
print $q->hr;
|
|
}
|
|
|
|
# Hack to evaluate embedded vars
|
|
print eval 'return "'.$fm->localise('QMH_DESC').'\n";';
|
|
|
|
my %labels = (
|
|
"list-queues" => $fm->localise('LIST_QUEUE'),
|
|
"list-local-queue" => $fm->localise('LIST_LOCAL_QUEUE'),
|
|
"list-remote-queue" => $fm->localise('LIST_REMOTE_QUEUE'),
|
|
"resend" => $fm->localise('RESEND_QUEUE'),
|
|
);
|
|
|
|
my @labels = (
|
|
'list-queues',
|
|
'list-local-queue',
|
|
'list-remote-queue',
|
|
'resend',
|
|
);
|
|
|
|
my $altqmail=$conf->get('altqmail') || 0;
|
|
if ( $altqmail)
|
|
{
|
|
%labels = (
|
|
"list-queues" => $fm->localise('LIST_QUEUE'),
|
|
"list-local-queue" => $fm->localise('LIST_LOCAL_QUEUE'),
|
|
"list-remote-queue" => $fm->localise('LIST_REMOTE_QUEUE'),
|
|
"resend" => $fm->localise('RESEND_QUEUE'),
|
|
"alt-list-queues" => "altqmail: ". $fm->localise('LIST_QUEUE'),
|
|
"alt-list-local-queue" => "altqmail: ". $fm->localise('LIST_LOCAL_QUEUE'),
|
|
"alt-list-remote-queue" => "altqmail: ". $fm->localise('LIST_REMOTE_QUEUE'),
|
|
"alt-resend" => "altqmail: ". $fm->localise('RESEND_QUEUE'),
|
|
);
|
|
|
|
@labels = (
|
|
'list-queues',
|
|
'list-local-queue',
|
|
'list-remote-queue',
|
|
'resend',
|
|
'alt-list-queues',
|
|
'alt-list-local-queue',
|
|
'alt-list-remote-queue',
|
|
'alt-resend',
|
|
);
|
|
|
|
}
|
|
|
|
my $default_action = 'list-queues';
|
|
|
|
print $q->startform(
|
|
-method => 'POST',
|
|
-action => $q->url (-absolute => 1)
|
|
),"\n";
|
|
|
|
print $q->start_table ({-class => "sme-noborders"}),"\n";
|
|
|
|
print $q->Tr(
|
|
$q->td({-class => "sme-noborders-label"},
|
|
$fm->localise("SELECT_AN_ACTION")),
|
|
$q->td({-class => "sme-noborders-content"},
|
|
$q->popup_menu (
|
|
-name => 'function',
|
|
-values => [ @labels ],
|
|
-default => $default_action,
|
|
-labels => \%labels
|
|
)
|
|
)
|
|
),"\n";
|
|
|
|
|
|
print $q->end_table,"\n";
|
|
|
|
print $q->start_table ({width => "100%", -class => "sme-noborders"}),
|
|
"\n";
|
|
|
|
print esmith::cgi::genButtonRow(
|
|
$q,
|
|
$q->submit (-name => 'action', -value =>
|
|
$fm->localise('PERFORM'))
|
|
);
|
|
|
|
print $q->end_table,"\n";
|
|
|
|
print $q->hidden (
|
|
-name => 'state',
|
|
-override => 1,
|
|
-default => 'perform'
|
|
),"\n";
|
|
|
|
print $q->endform,"\n";
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
|
|
return;
|
|
}
|
|
|
|
sub performAndShowResult
|
|
{
|
|
my ($q) = @_;
|
|
|
|
my $function = $q->param ('function');
|
|
|
|
if ($function eq 'refresh')
|
|
{
|
|
showInitial ($q, '');
|
|
}
|
|
elsif ($function eq 'list-queues')
|
|
{
|
|
showListQueues ($q);
|
|
}
|
|
elsif ($function eq 'list-local-queue')
|
|
{
|
|
showListLocalQueue ($q);
|
|
}
|
|
elsif ($function eq 'list-remote-queue')
|
|
{
|
|
showListRemoteQueue ($q);
|
|
}
|
|
elsif ($function eq 'resend')
|
|
{
|
|
resend($q);
|
|
}
|
|
elsif ($function eq 'confirm-delete-message-number')
|
|
{
|
|
showDeleteMessageNumber ($q);
|
|
}
|
|
elsif ($function eq 'delete-message-number')
|
|
{
|
|
deleteMessageNumber($q);
|
|
}
|
|
|
|
elsif ($function eq 'alt-list-queues')
|
|
{
|
|
showListAltQueues ($q);
|
|
}
|
|
elsif ($function eq 'alt-list-local-queue')
|
|
{
|
|
showListLocalAltQueue ($q);
|
|
}
|
|
elsif ($function eq 'alt-list-remote-queue')
|
|
{
|
|
showListRemoteAltQueue ($q);
|
|
}
|
|
elsif ($function eq 'alt-resend')
|
|
{
|
|
Altresend($q);
|
|
}
|
|
elsif ($function eq 'alt-confirm-delete-message-number')
|
|
{
|
|
showDeleteAltMessageNumber ($q);
|
|
}
|
|
elsif ($function eq 'alt-delete-message-number')
|
|
{
|
|
deleteAltMessageNumber($q);
|
|
}
|
|
|
|
else
|
|
{
|
|
# Unknown function - refresh the screen anyway
|
|
showInitial ($q, 'unknown');
|
|
}
|
|
|
|
return;
|
|
|
|
print $q->p ( $function );
|
|
esmith::cgi::genFooter($fm);
|
|
}
|
|
|
|
#------------------------------------------------------------
|
|
# subroutine to showListQueues
|
|
#------------------------------------------------------------
|
|
sub showListQueues ($)
|
|
{
|
|
my ($q) = @_;
|
|
|
|
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
$fm->localise('SHOWLISTQUEUES'));
|
|
|
|
{
|
|
print $q->hr;
|
|
print $q->p($fm->localise('VIEW_TIME')),scalar localtime(time),"\n";
|
|
|
|
my $MailQueues = `/usr/bin/qmHandle -l`;
|
|
my $queuetype = 'list-queues';
|
|
|
|
$MailQueues =~ s/</'/g;
|
|
$MailQueues =~ s/>/'/g;
|
|
|
|
$MailQueues = AddLinks($MailQueues, $queuetype, $q);
|
|
|
|
print $q->p ($q->pre ("$MailQueues"));
|
|
}
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
return;
|
|
}
|
|
|
|
sub showListAltQueues ($)
|
|
{
|
|
my ($q) = @_;
|
|
|
|
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
"altqmail: ". $fm->localise('SHOWLISTQUEUES'));
|
|
|
|
{
|
|
print $q->hr;
|
|
print $q->p($fm->localise('VIEW_TIME')),scalar localtime(time),"\n";
|
|
|
|
my $MailQueues = `/usr/bin/qmHandle -X -l`;
|
|
my $queuetype = 'alt-list-queues';
|
|
|
|
$MailQueues =~ s/</'/g;
|
|
$MailQueues =~ s/>/'/g;
|
|
|
|
$MailQueues = AddAltLinks($MailQueues, $queuetype, $q);
|
|
|
|
print $q->p ($q->pre ("$MailQueues"));
|
|
}
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
return;
|
|
}
|
|
|
|
sub AddLinks
|
|
{
|
|
my $queues = shift;
|
|
my $queueType = shift;
|
|
|
|
my @splitq = split(/\n/, $queues);
|
|
|
|
for (my $i = 0; $i < $#splitq; $i++) {
|
|
if ($splitq[$i] =~ /^(\d+)\s+(\(\d+\,\s+\d+\/+\d+\)\s*)$/ ) {
|
|
$splitq[$i] = "<a href=\"" .
|
|
$q->url( -absolute => 1 ) .
|
|
"?state=perform&function=confirm-delete-message-number&queue=$queueType" .
|
|
"&msgid=$1\">$1</a> $2";
|
|
}
|
|
}
|
|
$queues = join("\n", @splitq);
|
|
|
|
return $queues;
|
|
}
|
|
|
|
sub AddAltLinks
|
|
{
|
|
my $queues = shift;
|
|
my $queueType = shift;
|
|
|
|
my @splitq = split(/\n/, $queues);
|
|
|
|
for (my $i = 0; $i < $#splitq; $i++) {
|
|
if ($splitq[$i] =~ /^(\d+)\s+(\(\d+\,\s+\d+\/+\d+\)\s*)$/ ) {
|
|
$splitq[$i] = "<a href=\"" .
|
|
$q->url( -absolute => 1 ) .
|
|
"?state=perform&function=alt-confirm-delete-message-number&queue=$queueType" .
|
|
"&msgid=$1\">$1</a> $2";
|
|
}
|
|
}
|
|
$queues = join("\n", @splitq);
|
|
|
|
return $queues;
|
|
}
|
|
|
|
|
|
#------------------------------------------------------------
|
|
# subroutine to showListLocalQueue
|
|
#------------------------------------------------------------
|
|
sub showListLocalQueue ($)
|
|
{
|
|
my ($q) = @_;
|
|
|
|
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
$fm->localise('LIST_LOCAL_QUEUE'));
|
|
{
|
|
print $q->hr;
|
|
print $q->p($fm->localise('VIEW_TIME')),scalar localtime(time),"\n";
|
|
my $LocalQueue = `/usr/bin/qmHandle -L`;
|
|
my $queuetype = 'list-local-queue';
|
|
|
|
$LocalQueue =~ s/</'/g;
|
|
$LocalQueue =~ s/>/'/g;
|
|
$LocalQueue = AddLinks($LocalQueue, $queuetype);
|
|
|
|
print $q->p ($q->pre ("$LocalQueue"));
|
|
}
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
return;
|
|
}
|
|
|
|
sub showListLocalAltQueue ($)
|
|
{
|
|
my ($q) = @_;
|
|
|
|
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
"altqmail: ". $fm->localise('LIST_LOCAL_QUEUE'));
|
|
{
|
|
print $q->hr;
|
|
print $q->p($fm->localise('VIEW_TIME')),scalar localtime(time),"\n";
|
|
my $LocalQueue = `/usr/bin/qmHandle -X -L`;
|
|
my $queuetype = 'alt-list-local-queue';
|
|
|
|
$LocalQueue =~ s/</'/g;
|
|
$LocalQueue =~ s/>/'/g;
|
|
$LocalQueue = AddAltLinks($LocalQueue, $queuetype);
|
|
|
|
print $q->p ($q->pre ("$LocalQueue"));
|
|
}
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
return;
|
|
}
|
|
|
|
|
|
#------------------------------------------------------------
|
|
# subroutine to showListRemoteQueue
|
|
#------------------------------------------------------------
|
|
sub showListRemoteQueue ($)
|
|
{
|
|
my ($q) = @_;
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
$fm->localise('LIST_REMOTE_QUEUE'));
|
|
|
|
{
|
|
print $q->hr;
|
|
print $q->p($fm->localise('VIEW_TIME')),scalar localtime(time),"\n";
|
|
|
|
my $RemoteQueue = `/usr/bin/qmHandle -R`;
|
|
my $queuetype = 'list-remote-queue';
|
|
|
|
$RemoteQueue =~ s/</'/g;
|
|
$RemoteQueue =~ s/>/'/g;
|
|
|
|
$RemoteQueue = AddLinks($RemoteQueue, $queuetype);
|
|
print $q->p ($q->pre ("$RemoteQueue"));
|
|
}
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
return;
|
|
}
|
|
|
|
sub showListRemoteAltQueue ($)
|
|
{
|
|
my ($q) = @_;
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
"altqmail: ". $fm->localise('LIST_REMOTE_QUEUE'));
|
|
|
|
{
|
|
print $q->hr;
|
|
print $q->p($fm->localise('VIEW_TIME')),scalar localtime(time),"\n";
|
|
|
|
my $RemoteQueue = `/usr/bin/qmHandle -X -R`;
|
|
my $queuetype = 'alt-list-remote-queue';
|
|
|
|
$RemoteQueue =~ s/</'/g;
|
|
$RemoteQueue =~ s/>/'/g;
|
|
|
|
$RemoteQueue = AddAltLinks($RemoteQueue, $queuetype);
|
|
print $q->p ($q->pre ("$RemoteQueue"));
|
|
}
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
return;
|
|
}
|
|
|
|
|
|
#------------------------------------------------------------
|
|
# subroutine to send ALARM to qmail
|
|
#------------------------------------------------------------
|
|
sub resend ($)
|
|
{
|
|
my ($q) = @_;
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
$fm->localise('TRY_SEND_QUEUE'));
|
|
|
|
{
|
|
print $q->hr;
|
|
print $q->p($fm->localise('SEND_QUEUE_AT')),scalar localtime(time),"\n";
|
|
|
|
my $res = `/usr/bin/qmHandle -a`;
|
|
|
|
print $q->p ($q->pre ("$res"));
|
|
print $q->h3 ("Done.");
|
|
}
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
return;
|
|
}
|
|
|
|
sub Altresend ($)
|
|
{
|
|
my ($q) = @_;
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
"altqmail: ". $fm->localise('TRY_SEND_QUEUE'));
|
|
|
|
{
|
|
print $q->hr;
|
|
print $q->p($fm->localise('SEND_QUEUE_AT')),scalar localtime(time),"\n";
|
|
|
|
my $res = `/usr/bin/qmHandle -X -a`;
|
|
|
|
print $q->p ($q->pre ("$res"));
|
|
print $q->h3 ("Done.");
|
|
}
|
|
|
|
esmith::cgi::genFooter($fm);
|
|
return;
|
|
}
|
|
|
|
#------------------------------------------------------------
|
|
# subroutine to showDeleteMessageNumber
|
|
#------------------------------------------------------------
|
|
sub showDeleteMessageNumber ($)
|
|
{
|
|
my ($q) = @_;
|
|
my $msgid = $q->param ('msgid');
|
|
my $queuetype = $q->param ('queue');
|
|
|
|
if ($msgid =~ /^(\d+)$/) {
|
|
$msgid = $1;
|
|
} else {
|
|
$msgid = undef;
|
|
}
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
$fm->localise('DELETE_MSG_TITLEB'));
|
|
|
|
print $q->hr;
|
|
print $q->p($fm->localise('DELETE_MESSAGE')),"\n";
|
|
my $Message = `/usr/bin/qmHandle -m$msgid|head -100`;
|
|
print $q->textarea (-name => 'message', -override => 1, -default => "$Message", -rows => 30, -cols => 80);
|
|
|
|
print $q->start_multipart_form(-method => 'POST', -action => $q->url (-absolute => 1));
|
|
print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
|
|
|
|
esmith::cgi::genButtonRow ($q,
|
|
$q->submit (-name => 'action', -value => $fm->localise('Delete'))));
|
|
print $q->hidden (-name => 'state', -override => 1, -default => 'perform');
|
|
print $q->hidden (-name => 'msgid', -override => 1, -default => "$msgid");
|
|
print $q->hidden (-name => 'function', -override => 1, -default => 'delete-message-number');
|
|
print $q->hidden (-name => 'queue', -override => 1, -default => "$queuetype");
|
|
print $q->endform;
|
|
|
|
esmith::cgi::genFooter ($q);
|
|
return;
|
|
}
|
|
|
|
sub showDeleteAltMessageNumber ($)
|
|
{
|
|
my ($q) = @_;
|
|
my $msgid = $q->param ('msgid');
|
|
my $queuetype = $q->param ('queue');
|
|
|
|
if ($msgid =~ /^(\d+)$/) {
|
|
$msgid = $1;
|
|
} else {
|
|
$msgid = undef;
|
|
}
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
"altqmail: ". $fm->localise('DELETE_MSG_TITLEB'));
|
|
|
|
print $q->hr;
|
|
print $q->p($fm->localise('DELETE_MESSAGE')),"\n";
|
|
my $Message = `/usr/bin/qmHandle -X -m$msgid|head -100`;
|
|
print $q->textarea (-name => 'message', -override => 1, -default => "$Message", -rows => 30, -cols => 80);
|
|
|
|
print $q->start_multipart_form(-method => 'POST', -action => $q->url (-absolute => 1));
|
|
print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
|
|
|
|
esmith::cgi::genButtonRow ($q,
|
|
$q->submit (-name => 'action', -value => $fm->localise('Delete'))));
|
|
|
|
print $q->hidden (-name => 'state', -override => 1, -default => 'perform');
|
|
print $q->hidden (-name => 'msgid', -override => 1, -default => "$msgid");
|
|
print $q->hidden (-name => 'function', -override => 1, -default => 'delete-message-number');
|
|
print $q->hidden (-name => 'queue', -override => 1, -default => "$queuetype");
|
|
print $q->endform;
|
|
|
|
esmith::cgi::genFooter ($q);
|
|
return;
|
|
}
|
|
|
|
|
|
sub deleteMessageNumber ($)
|
|
{
|
|
my ($q) = @_;
|
|
|
|
my $msgid = $q->param ('msgid');
|
|
my $queuetype = $q->param ('queue');
|
|
|
|
if ($msgid =~ /^(\d+)$/) {
|
|
$msgid = $1;
|
|
} else {
|
|
$msgid = undef;
|
|
}
|
|
my $Output = `/usr/bin/qmHandle -d$msgid`;
|
|
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
"qmail: ". $fm->localise('QMH_TITLE'));
|
|
|
|
print $q->hr;
|
|
print $q->h3 ($fm->localise('DELETED'))," $msgid ";
|
|
print $q->br();
|
|
print $q->br();
|
|
|
|
print $q->start_multipart_form(-method => 'POST', -action => $q->url (-absolute => 1));
|
|
print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
|
|
esmith::cgi::genButtonRow ($q,
|
|
$q->submit (-name => 'action', -value => $fm->localise('RETURN_TO_QUEUE'))));
|
|
|
|
print $q->hidden (-name => 'state', -override => 1, -default => 'perform');
|
|
print $q->hidden (-name => 'function', -override => 1, -default => "$queuetype");
|
|
print $q->endform;
|
|
|
|
esmith::cgi::genFooter ($q);
|
|
return;
|
|
}
|
|
|
|
sub deleteAltMessageNumber ($)
|
|
{
|
|
my ($q) = @_;
|
|
|
|
my $msgid = $q->param ('msgid');
|
|
my $queuetype = $q->param ('queue');
|
|
|
|
if ($msgid =~ /^(\d+)$/) {
|
|
$msgid = $1;
|
|
} else {
|
|
$msgid = undef;
|
|
}
|
|
my $Output = `/usr/bin/qmHandle -X -d$msgid`;
|
|
|
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf,
|
|
"altqmail: ". $fm->localise('QMH_TITLE'));
|
|
|
|
print $q->hr;
|
|
print $q->h3 ($fm->localise('DELETED'))," $msgid ";
|
|
print $q->br();
|
|
print $q->br();
|
|
|
|
print $q->start_multipart_form(-method => 'POST', -action => $q->url (-absolute => 1));
|
|
print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
|
|
esmith::cgi::genButtonRow ($q,
|
|
$q->submit (-name => 'action', -value => $fm->localise('RETURN_TO_QUEUE'))));
|
|
|
|
print $q->hidden (-name => 'state', -override => 1, -default => 'perform');
|
|
print $q->hidden (-name => 'function', -override => 1, -default => "$queuetype");
|
|
print $q->endform;
|
|
|
|
esmith::cgi::genFooter ($q);
|
|
return;
|
|
}
|
|
|
|
|
|
__DATA__
|
|
<form>
|
|
</form>
|