#!/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);
$hostingplan = find_hosting_plan ($domainname);
$user_limit = find_user_limit($hostingplan);

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

# 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;

if ( $numusers >= $user_limit )
{

print<<TOOMANYUSERS;

Your user limit of $user_limit has been reached. Unfortunately, no further users can be created at the moment. 
Please either delete an existing user, or alternatively upgrade your current hosting plan by contacting 
our <a href="mailto:sales@ieinternet.com"><font color=#DD0000>sales department</font></a>.

TOOMANYUSERS

} else {

print_header ("Creation of a new user for $domainname");

print<<HEADER;

Below is the name of your new user. All you have to do now is choose the password you would like from the drop down list and click on 
the submit button:
 
<form method=post action="/$script_bin/create_user-confirm.pl" class=text>
HEADER
	
	$new_user = create_new_user($domainname,"email");
	print "<BR><b>User name:</b><BR>Your new user name is: <b>$new_user</b><br>";
	print "<BR><b>Password:</b><br>Please select the password for this user from this list: <select name=password>";

	for ( $i = 1 ; $i <= $numpasswords ; $i++ )
	{
		@new_password = ();
		@new_password = create_new_password();
		$password = $new_password[0];
		$pronounciation = $new_password[1];
		print "<option name=password value=$password>$password ($pronounciation)";
	}
	print "</select>";
	print "<BR>(The password's pronounciation is in brackets)";
	print "<br><br><b>Email address:</b><BR>If you would like to set up an email address for this user you can do so ";
	print "now, or you can do it later:<br><br>";
	print "<input type=text name=address size=15>\@$domainname<br><br>";
	print "<input type=hidden name=user value=$new_user>";
}

print_end_of_form();

require $footer;
