#!/usr/local/bin/perl
# list_cws.cgi
# List domains for which we accept mail

require './sendmail-lib.pl';
$access{'cws'} || &error($text{'cws_ecannot'});
&header($text{'cws_title'}, "");
print "<hr>\n";

$conf = &get_sendmailcf();
foreach $f (&find_type("F", $conf)) {
	if ($f->{'value'} =~ /^w[^\/]*(\/\S+)/) { $cwfile = $1; }
	}
if ($cwfile) {
	# get domains listed in a separate file
	open(CW, $cwfile);
	while(<CW>) {
		s/\r|\n//g;
		s/#.*$//g;
		if (/\S/) { push(@dlist, $_); }
		}
	close(CW);
	}

# Add domains from sendmail.cf
foreach $f (&find_type("C", $conf)) {
	if ($f->{'value'} =~ /^w\s*(.*)$/) {
		push(@dlist, split(/\s+/, $1));
		}
	}

print "<form method=post action=save_cws.cgi enctype=multipart/form-data>\n";
print "<input type=hidden name=cwfile value=\"$cwfile\">\n";
print "<table cellpadding=5 width=100%><tr><td valign=top nowrap>\n";
print "<b>$text{'cws_domains'}</b><br>\n";
print "<textarea name=dlist rows=15 cols=65>",
	join("\n", @dlist),"</textarea><br>\n";
print "<input type=submit value=\"$text{'save'}\">\n";

print "</td><td valign=top>\n";
print &text('cws_desc1', "<tt>".&get_system_hostname()."</tt>"),"<p>\n";
print $text{'cws_desc2'},"\n";
print "</td></tr></table>\n";
print "</form>\n";

print "<hr>\n";
&footer("", $text{'index_return'});


