diff -urN smeserver-qmHandle-1.4.old/createlinks smeserver-qmHandle-1.4/createlinks --- smeserver-qmHandle-1.4.old/createlinks 2012-08-23 01:51:59.000000000 +0400 +++ smeserver-qmHandle-1.4/createlinks 2021-05-25 23:03:12.824000000 +0400 @@ -16,6 +16,17 @@ # actions for console-save event: #-------------------------------------------------- +#-------------------------------------------------- +# actions for smeserver-qmHandle-update event: +#-------------------------------------------------- + +my $event = 'smeserver-qmHandle-update'; + +safe_symlink('restart', "root/etc/e-smith/events/$event/services2adjust/smanager"); + +event_link('navigation2-conf', "$event", '80'); +event_link('routes2-conf', "$event", '80'); +event_link('locales2-conf', "$event", '80'); #-------------------------------------------------- # The End diff -urN smeserver-qmHandle-1.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Qmh.pm smeserver-qmHandle-1.4/root/usr/share/smanager/lib/SrvMngr/Controller/Qmh.pm --- smeserver-qmHandle-1.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Qmh.pm 1970-01-01 04:00:00.000000000 +0400 +++ smeserver-qmHandle-1.4/root/usr/share/smanager/lib/SrvMngr/Controller/Qmh.pm 2021-05-29 23:22:56.000000000 +0400 @@ -0,0 +1,321 @@ +package SrvMngr::Controller::Qmh; + +#---------------------------------------------------------------------- +# heading : Administration +# description : E-Mail queue management +# navigation : 5000 5100 +# menu : A +# +# name : qmhandle, method : get, url : /qmh, ctlact : qmh#main +# name : qmhandle2, method : post, url : /qmh, ctlact : qmh#do_update +# name : qmhandled, method : get, url : /qmh2, ctlact : qmh#do_update + +# routes : end +# Copyright (C) 2005/2008 Peter Schubert, SACO Software and Consulting GmbH +#---------------------------------------------------------------------- +use strict; +use warnings; +use Mojo::Base 'Mojolicious::Controller'; + +use esmith::FormMagick qw(gen_locale_date_string); +use esmith::ConfigDB; + +use Locale::gettext; +use SrvMngr::I18N; + +use SrvMngr qw(theme_list init_session); + +our $cdb = esmith::ConfigDB->open() || die 'Cannot open configuration base'; + +sub main { + + my $c = shift; + $c->app->log->info($c->log_req); + + my %qmh_datas = (); + my $title = $c->l('qmh_QMH_TITLE'); + + $qmh_datas{'trt'} = 'LST'; + $qmh_datas{'altq'} = 0; + + $c->stash( title => $title, qmh_datas => \%qmh_datas ); + $c->render('qmh'); +}; + + +sub do_update { + + my $c = shift; + $c->app->log->info($c->log_req); + + my %qmh_datas = (); + my $result = ""; + + my $report_type = $c->param('Report_type'); + + my $trt = $c->param('trt'); + $qmh_datas{'trt'} = $trt; + + my $altq = $c->param('altq'); + $qmh_datas{'altq'} = $altq; + + if ($trt eq 'LST') { + if ($report_type =~ /^(\S+)$/) { + $report_type = $1; + } else { + $result = $c->l('INVALID_REPORT_TYPE') . " : $report_type"; + $report_type = undef; + } + + $altq = 0; + my $function = $report_type || ''; + if ($function =~ s/^alt-//) { + $altq = 1; + } + $qmh_datas{'altq'} = $altq; + + if ($function eq 'list-queues') { + $result = showListQueues ($c, $altq); + } elsif ($function eq 'list-local-queue') { + $result = showListLocalQueue ($c, $altq); + } elsif ($function eq 'list-remote-queue') { + $result = showListRemoteQueue ($c, $altq); + } elsif ($function eq 'resend') { + $result = resend($c, $altq); + } + + $qmh_datas{'trt'} = 'REP'; + } + + + if ($trt eq 'REP') { + $c->redirect_to('/qmh'); + } + + + if ($trt eq 'MSG') { + my $msgid = $c->param('msgid'); + $result = $c->render_to_string(inline => showDeleteMessageNumber($c, $msgid)) if $msgid; + $qmh_datas{'msgid'} = $msgid; + } + + + if ($trt eq 'DEL') { + my $msgid = $c->param('msgid'); + $result = $c->render_to_string(inline => deleteMessageNumber($c, $msgid)) if $msgid; + my $message = $c->l('qmh_DELETE') . '
' . $msgid; + #$c->app->log->info($message.' '.$result); + $c->flash( success => $message ); + $c->redirect_to('/qmh'); + } + + + my $title = $c->l('qmh_QMH_TITLE'); + $c->stash( title => $title, qmh_datas => \%qmh_datas, modul => $result ); + $c->render('qmh'); + +}; + + +sub reportType_list { + + my $c = shift; + + my $rec = $cdb->get('altqmail'); + my $altqmail = ($cdb->get('altqmail')->value || 0) if $rec; + + return [[ $c->l('qmh_LIST_QUEUE') => 'list-queues' ], + [ $c->l('qmh_LIST_LOCAL_QUEUE') => 'list-local-queue' ], + [ $c->l('qmh_LIST_REMOTE_QUEUE') => 'list-remote-queue' ], + [ $c->l('qmh_RESEND_QUEUE') => 'resend' ]] + unless $altqmail; + + return [[ $c->l('qmh_LIST_QUEUE') => 'list-queues' ], + [ $c->l('qmh_LIST_LOCAL_QUEUE') => 'list-local-queue' ], + [ $c->l('qmh_LIST_REMOTE_QUEUE') => 'list-remote-queue' ], + [ $c->l('qmh_RESEND_QUEUE') => 'resend' ], + [ "altqmail: ". $c->l('qmh_LIST_QUEUE') => 'alt-list-queues' ], + [ "altqmail: ". $c->l('qmh_LIST_LOCAL_QUEUE') => 'alt-list-local-queue' ], + [ "altqmail: ". $c->l('qmh_LIST_REMOTE_QUEUE') => 'alt-list-remote-queue' ], + [ "altqmail: ". $c->l('qmh_RESEND_QUEUE') => 'alt-resend' ]]; +} + + +#------------------------------------------------------------ +# subroutine to showListQueues +#------------------------------------------------------------ +sub showListQueues { + + my ($c, $altq) = @_; + + my $out = ''; + + my $opt = ($altq ? 'altqmail: ' : ''); + $out .= sprintf("

%s


", $opt . $c->l('qmh_SHOWLISTQUEUES')); + $out .= sprintf("%s
%s", $c->l('qmh_VIEW_TIME'), scalar localtime(time)); + + $opt = ($altq ? '-X -l' : '-l'); + my $MailQueues = `/usr/bin/qmHandle $opt`; + $MailQueues =~ s//'/g; + + $MailQueues = AddLinks($MailQueues, $c, $altq); + + $out .= sprintf "
";
+    $out .= "$MailQueues";
+    $out .= sprintf "
"; + return $out; +} + + +#------------------------------------------------------------ +# subroutine to showListLocalQueue +#------------------------------------------------------------ +sub showListLocalQueue { + + my ($c, $altq) = @_; + + my $out = ''; + + my $opt = ($altq ? 'altqmail: ' : ''); + $out .= sprintf("

%s


", $opt . $c->l('qmh_LIST_LOCAL_QUEUE')); + $out .= sprintf("%s
%s", $c->l('qmh_VIEW_TIME'), scalar localtime(time)); + + $opt = ($altq ? '-X -L' : '-L'); + my $LocalQueue = `/usr/bin/qmHandle $opt`; + $LocalQueue =~ s//'/g; + + $LocalQueue = AddLinks($LocalQueue, $c, $altq); + + $out .= sprintf "
";
+    $out .= "$LocalQueue";
+    $out .= sprintf "
"; + return $out; +} + + +#------------------------------------------------------------ +# subroutine to showListRemoteQueue +#------------------------------------------------------------ +sub showListRemoteQueue { + + my ($c, $altq) = @_; + + my $out = ''; + + my $opt = ($altq ? 'altqmail: ' : ''); + $out .= sprintf("

%s


", $opt . $c->l('qmh_LIST_REMOTE_QUEUE')); + $out .= sprintf("%s
%s", $c->l('qmh_VIEW_TIME'), scalar localtime(time)); + + $opt = ($altq ? '-X -R' : '-R'); + my $RemoteQueue = `/usr/bin/qmHandle $opt`; + $RemoteQueue =~ s//'/g; + + $RemoteQueue = AddLinks($RemoteQueue, $c, $altq); + + $out .= sprintf "
";
+    $out .= "$RemoteQueue";
+    $out .= sprintf "
"; + return $out; +} + + +#------------------------------------------------------------ +# subroutine to send ALARM to qmail +#------------------------------------------------------------ +sub resend { + + my ($c, $altq) = @_; + + my $out = ''; + + my $opt = ($altq ? 'altqmail: ' : ''); + $out .= sprintf("

%s


", $opt . $c->l('qmh_TRY_SEND_QUEUE')); + $out .= sprintf("%s
%s", $c->l('qmh_SEND_QUEUE_AT'), scalar localtime(time)); + + $opt = ($altq ? '-X -a' : '-a'); + my $Res = `/usr/bin/qmHandle $opt`; + $Res =~ s//'/g; + + $Res = AddLinks($Res, $c, $altq); + + $out .= sprintf "
";
+    $out .= "$Res";
+    $out .= sprintf "
"; + $out .= sprintf "

Done

"; + return $out; +} + + +sub AddLinks { + + my ($queues, $altq) = @_; + + my @splitq = split(/\n/, $queues); + + for (my $i = 0; $i < $#splitq; $i++) { + if ($splitq[$i] =~ /^(\d+)\s+(\(\d+\,\s+\d+\/+\d+\)\s*)$/ ) { + $splitq[$i] = "$1 $2"; + } + } + $queues = join("\n", @splitq); + + return $queues; +} + + +#------------------------------------------------------------ +# subroutine to showDeleteMessageNumber +#------------------------------------------------------------ +sub showDeleteMessageNumber { + + my ($c, $msgid, $altq) = @_; + + if ($msgid =~ /^(\d+)$/) { + $msgid = $1; + } else { + $msgid = undef; + } + + my $out = ''; + + my $opt = ($altq ? 'altqmail: ' : ''); + $out .= sprintf("

%s


", $opt . $c->l('qmh_DELETE_MSG_TITLEB')); + $out .= sprintf("%s", $c->l('qmh_DELETE_MESSAGE')); + + $opt = ($altq ? "-X -m$msgid|head -100" : "-m$msgid|head -100"); + my $Message = `/usr/bin/qmHandle $opt`; + + $out .= sprintf "
";
+    $out .= "$Message";
+    $out .= sprintf "
"; + return $out; +} + + +sub deleteMessageNumber { + + my ($c, $msgid, $altq) = @_; + + if ($msgid =~ /^(\d+)$/) { + $msgid = $1; + } else { + $msgid = undef; + } + + my $out = ''; + my $opt = ($altq ? "-X -d$msgid" : "-d$msgid"); + my $Output = `/usr/bin/qmHandle $opt`; + + $out .= sprintf "
";
+    $out .= "$Output";
+    $out .= sprintf "
"; + return $out; + +} + + +1; diff -urN smeserver-qmHandle-1.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Qmh/qmh_en.lex smeserver-qmHandle-1.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Qmh/qmh_en.lex --- smeserver-qmHandle-1.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Qmh/qmh_en.lex 1970-01-01 04:00:00.000000000 +0400 +++ smeserver-qmHandle-1.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Qmh/qmh_en.lex 2021-05-29 23:33:51.431000000 +0400 @@ -0,0 +1,20 @@ +'qmh_QMH_TITLE' => 'Qmail queue management', +'qmh_OPERATION_STATUS_REPORT' => 'Operation status report', +'qmh_QMH_DESC' => 'This panel uses qmHandle to manage the qmail message queues. Key features are the ability to view and delete messages in the queues.', +'qmh_TRY_SEND_QUEUE' => 'Force resending of the Qmail queue', +'qmh_SEND_QUEUE_AT' => 'Resend Qmail queue at: ', +'qmh_LIST_QUEUE' => 'List message queues', +'qmh_LIST_LOCAL_QUEUE' => 'List local message queue', +'qmh_SHOWLISTQUEUES' => 'List Qmail local and remote queues', +'qmh_LIST_REMOTE_QUEUE' => 'List remote message queue', +'qmh_VIEW_TIME' => 'Qmail message queue, viewed at: ', +'qmh_LIST_LOCAL_QUEUE' => 'List Qmail local queue', +'qmh_LIST_REMOTE_QUEUE' => 'List Qmail remote queue', +'qmh_RESEND_QUEUE' => 'Try to send queued messages now (qmail must be running)', +'qmh_DELETE_MSG_TITLEB' => 'Queue management: delete Message', +'qmh_DELETE_MESSAGE' => 'Delete this message from the queue ? (Only the first 100 lines are listed)', +'qmh_DELETE' => 'Delete', +'qmh_SELECT_AN_ACTION' => 'Select an action', +'qmh_iFROM_QUEUE' => 'from message queue', +'qmh_Administration' => 'Administration', +'E-mail Warteschlange' => 'E-Mail queue management', diff -urN smeserver-qmHandle-1.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Qmh/qmh_fr.lex smeserver-qmHandle-1.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Qmh/qmh_fr.lex --- smeserver-qmHandle-1.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Qmh/qmh_fr.lex 1970-01-01 04:00:00.000000000 +0400 +++ smeserver-qmHandle-1.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Qmh/qmh_fr.lex 2021-05-29 23:35:14.502000000 +0400 @@ -0,0 +1,20 @@ +'qmh_QMH_TITLE' => 'Administration de file d\'attente', +'qmh_OPERATION_STATUS_REPORT' => 'Rapport d\'état de l\'opération', +'qmh_QMH_DESC' => 'Ce panel utilise qmHandle pour administrer la file d\'attente de Qmail. Les fonctionnalités principales sont de voir et d\'effacer des messages dans la file d\'attente. ', +'qmh_TRY_SEND_QUEUE' => 'Forcer le renvoi de la file d\'attente de qmail', +'qmh_SEND_QUEUE_AT' => 'Renvoi la file d\'attente Qmail le : ', +'qmh_LIST_QUEUE' => 'Message de la file d\'attente', +'qmh_LIST_LOCAL_QUEUE' => 'File d\'attente locale', +'qmh_SHOWLISTQUEUES' => 'Files d\'attente locale et distante', +'qmh_LIST_REMOTE_QUEUE' => 'File d\'attente distante de QMAIL', +'qmh_VIEW_TIME' => 'La file d\'attente des messages de Qmail le : ', +'qmh_LIST_LOCAL_QUEUE' => 'File d\'attente locale de QMAIL', +'qmh_LIST_REMOTE_QUEUE' => 'File d\'attente distante de QMAIL', +'qmh_RESEND_QUEUE' => 'Renvoyer les messages de la file d\'attente maintenant (Qmail doit être en fonction)', +'qmh_DELETE_MSG_TITLEB' => 'Administration de file d\'attente : effacer le Message', +'qmh_DELETE_MESSAGE' => 'Effacez ce message de la file d\'attente? (Seulement les 100 premières lignes sont affichées)', +'qmh_DELETE' => 'Supprimer', +'qmh_SELECT_AN_ACTION' => 'Sélectionnez une action :', +'qmh_iFROM_QUEUE' => 'de la file d\'attente des messages', +'qmh_Administration' => 'Administration', +'E-mail Warteschlange' => 'Administration de file d\'attente des courriels', diff -urN smeserver-qmHandle-1.4.old/root/usr/share/smanager/themes/default/templates/qmh.html.ep smeserver-qmHandle-1.4/root/usr/share/smanager/themes/default/templates/qmh.html.ep --- smeserver-qmHandle-1.4.old/root/usr/share/smanager/themes/default/templates/qmh.html.ep 1970-01-01 04:00:00.000000000 +0400 +++ smeserver-qmHandle-1.4/root/usr/share/smanager/themes/default/templates/qmh.html.ep 2021-05-29 23:37:47.093000000 +0400 @@ -0,0 +1,50 @@ +% layout 'default', title => "Sme server 2 - qmh"; + +% content_for 'module' => begin +
+ % if ($config->{debug} == 1) { +

+ %= dumper $c->current_route + %= dumper $qmh_datas +

+ %} + % if ( stash 'error' ) { +
+ %= $c->render_to_string(inline => stash 'error') +
+ %} +

<%= $title %>

+ + % my $btn = l('PERFORM'); + % my $url = '/qmh'; + + %= form_for "$url" => (method => 'POST') => begin + % if ($qmh_datas->{trt} eq 'LST') { + %= $c->render_to_string(inline => $c->l('qmh_QMH_DESC')); +

+ + %=l 'qmh_SELECT_AN_ACTION' + + + %= select_field 'Report_type' => $c->reportType_list() + +

+ %} + % if ($qmh_datas->{trt} eq 'REP') { + % $btn = l('NEXT'); + %= $c->render_to_string( inline => stash 'modul' ) + %} + % if ($qmh_datas->{trt} eq 'MSG') { + % $btn = l('Delete'); + %= $c->render_to_string( inline => stash 'modul' ) + %= hidden_field 'msgid' => $qmh_datas->{msgid} + % $qmh_datas->{trt} = 'DEL'; + %} +
+ %= submit_button "$btn", class => 'action' +
+ %= hidden_field 'trt' => $qmh_datas->{trt} + %= hidden_field 'altq' => $qmh_datas->{altq} + % end +
+%end