#!/usr/local/bin/perl # list_routes.cgi # Display a list of SMTP routes require './qmail-lib.pl'; &ReadParse(); &ui_print_header(undef, $text{'routes_title'}, ""); @routes = &list_routes(); ($defroute) = grep { !$_->{'from'} } @routes; @routes = grep { $_ ne $defroute } @routes; &route_form(); if ($in{'search'}) { # Restrict to search results @routes = grep { $_->{'from'} =~ /$in{'search'}/ } @routes; } elsif ($config{'max_records'} && @routes > $config{'max_records'}) { # Show search form print $text{'routes_toomany'},"
\n"; print "
\n"; print "\n"; print "
\n"; undef(@routes); } if (@routes) { # sort if needed if ($config{'sort_mode'} == 1) { @routes = sort { lc($a->{'from'}) cmp lc($b->{'from'}) } @routes; } # render tables print &ui_form_start("delete_routes.cgi", "post"); print &select_all_link("d", 1),"\n"; print &select_invert_link("d", 1),"
\n"; if ($config{'columns'} == 2) { $mid = int((@routes+1)/2); print "
\n"; &routes_table(@routes[0..$mid-1]); print "\n"; if ($mid < @routes) { &routes_table(@routes[$mid..$#routes]); } print "

\n"; } else { &routes_table(@routes); } print &select_all_link("d", 1),"\n"; print &select_invert_link("d", 1),"
\n"; print &ui_form_end([ [ "delete", $text{'routes_delete'} ] ]); } print &ui_hr(); print "
\n"; print "\n" if ($defroute); print "$text{'routes_defroute'}\n"; printf " %s\n", $defroute ? "" : "checked", $text{'routes_direct'}; printf " %s\n", $defroute ? "checked" : ""; printf "\n"; print "
\n"; &ui_print_footer("", $text{'index_return'}); sub routes_table { print "\n"; print " ", "\n"; foreach $r (@_) { print "\n"; print "\n"; print "\n"; print "\n"; } print "

$text{'routes_from'}$text{'routes_to'}
",&ui_checkbox("d", $r->{'from'}),"{'idx'}\">", &html_escape($r->{'from'}),"",$r->{'port'} ? &html_escape("$r->{'to'}:$r->{'port'}") : $r->{'to'} ? &html_escape($r->{'to'}) : "$text{'routes_direct'}","
\n"; }