#!/usr/bin/perl

print "Content-Type: Text/HTML\n\n";

use CGI ':standard';
use Vpanel 1.00;
require $header;
require $accountinfo;
$domainname = find_domain ($mainuser);
$chosen_user = param('user');

# Define the tab which appears to the front
$tab_section = $tabnum_email;

# Output the content associated with this tab
print "<body class=section-$tab_section>";

# display tabs
require $tabdisplay;

@userlist = find_valid_users($domainname);
$numusers = @userlist;

print_header ("Deletion of a user for $domainname");

print<<HEADER;

Please select the user you wish to delete from the list below and click on the Submit button.<BR>
Only users which have no email addresses attached can de deleted:

<form method=post action="/$script_bin/$confirm_delete_user" class=text>
<select name=user>

HEADER

for ( $i = 0 ; $i < $numusers ; $i++)
{
	@validaddresses = ();
	@validaddresses = find_valid_addresses_for_user($userlist[$i]);

	$num_valid_addresses = @validaddresses;
	# Only allow the deletion of users with no email addresses attached, non ftp users and non spam trap users
	if ( $num_valid_addresses == 0 &&  ( ! ( $userlist[$i] =~ /^ftp/ ) )  &&  ( ! ( $userlist[$i] =~ /^spam/ ) ) )
	{
		print "<option value=$userlist[$i]";
		if ( $chosen_user eq $userlist[$i] )
                {
                        print " selected ";
                }
		print ">$userlist[$i]";
	}
}
print "</select>";
print_end_of_form();

require $footer;
