[! use strict; use Proxmox::Utils; use Proxmox::ConfigServer; use Proxmox::HTMLTable; use HTML::Entities; use Encode; !] [- my $conn; my $cinfo = $fdat{__cinfo}; my $cid = $fdat{cid} || $udat{__cid} || $cinfo->{local}->{cid}; $udat{__cid} = $fdat{cid} if defined ($fdat{cid}); my $nodeinfo; my $out = ""; if ($cinfo->{local}->{role} ne '-') { my $frm = Proxmox::Form->new (\%fdat); my @nodes; foreach my $ni (@{$cinfo->{nodes}}) { if ($ni->{cid} == $cinfo->{local}->{cid}) { push @nodes, [$ni->{cid}, "localhost ($ni->{ip})"]; } else { push @nodes, [$ni->{cid}, "$ni->{name} ($ni->{ip})"]; } } $frm->add_element("cid", "dynamicdropdown", $cid,'', \@nodes); my $html_form = $frm->out_js_code() . $frm->out_formheader(); $html_form .= ""; $html_form .= "

Cluster node selection: "; $html_form .= $frm->out_element("cid"); $html_form .= $frm->out_formfooter(); $out .= $html_form . "


"; } if ($cid) { foreach my $ni (@{$cinfo->{nodes}}) { if ($ni->{cid} eq $cid) { $nodeinfo = $ni; last; } } if ($nodeinfo) { eval { $conn = Proxmox::ConfigClient::connect ($nodeinfo->{configport}); $conn->alive (); # test connection }; my $err = $@; if ($err) { $udat{popup_error} = $err; $out .= "

unable to connect to node '$nodeinfo->{ip}'

"; return $out; } } else { $out .= "

No such node (CID = $cid)

"; return $out; } } else { $nodeinfo = $cinfo->{local}; $conn = Proxmox::ConfigClient::connect ($nodeinfo->{configport}); } if ($fdat{domain}) { my $limit = 200; my $res = $conn->mailq ($fdat{domain}, $limit)->result; my @cellwidth = ( '80px', '70px', '50px', '250px', '300px'); my @header = ( '1', '80px', __('Date'), '1', '70px', __('Time'), '1', '50px', 'KByte', '1', '250px', __('Sender'), '1', '300px', __('Receiver(s)'), ); $out .= "

"; $out .= sprintf (__("Deferred Mails for Domain '%s' (max %d entries)") . "


", $fdat{domain}, $limit); my $table = Proxmox::HTMLTable->new (\@cellwidth); $table->add_headline (\@header); foreach my $ref (@$res) { my $receivers = join (' ', @{$ref->{receivers}}); $table->set_row_link ("?domain=$fdat{domain}&qid=$ref->{qid}"); $table->add_row ('', "$ref->{date}", $ref->{time}, int($ref->{size}/1024), $ref->{sender}, $receivers); $table->set_col_span ([5]); my $reason = $ref->{reason}; $reason = Proxmox::Utils::escape_html ($reason); $table->add_row ('', "
SMTP RESULT: $reason
"); } $out .= $table->out_table('700px'); } else { $out .= "

"; $out .= sprintf (__("Deferred mails per recipient domain (max %d entries)") . "


", 200); my @cellwidth = ( '180px', '50px', '50px', '50px', '50px', '50px', '50px', '50px', '50px', '50px', '50px', '50px' ); my @header = ( '1', '180px', __('Recipient domain'), '1', '50px', __('Total'), '1', '50px', '5s', '1', '50px', '10s', '1', '50px', '20s', '1', '50px', '40s', '1', '50px', '80s', '1', '50px', '160s', '1', '50px', '320s', '1', '50px', '640s', '1', '50px', '1280s', '1', '50px', '1280s+' ); my $table = Proxmox::HTMLTable->new (\@cellwidth); $table->add_headline (\@header); if ($fdat{action}) { if ($udat{AM} eq 'w') { if ($fdat{action} eq 'delete') { my $resp = $conn->postfix_del ('ALL'); } elsif ($fdat{action} eq 'flush') { my $resp = $conn->postfix_flush (); } } else { $udat{popup_error} = Proxmox::Utils::msg ('nowr'); } } my $res = $conn->qshape ('deferred')->result; my @total; foreach my $k (sort @$res) { my @v = split (/\s+/, Encode::encode_utf8 ($k)); if ($v[0] eq 'TOTAL') { @total = @v; } else { my $domain = $v[0]; $table->set_row_link ("?domain=$domain"); $table->add_row ('', @v); } } $table->add_row ('', @total) if @total; $out .= $table->out_table(); } print OUT $out; -]