#!/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);
$number_of_users = find_number_users($domainname);

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

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

# display tabs
require $tabdisplay;

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

if ( $number_of_users >= $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;

Please input your new FTP user's details below:
 
<form method=post action="/$script_bin/$confirm_create_ftp_user" class=text>
HEADER
	
	$new_ftp_user = create_new_user($domainname, "ftp");
	print "<b>User name:</b><BR>Your new user name is: <b>$new_ftp_user</b><br>";
	print "<BR><b>Password:</b><br>Please select the password for this user from this list: <select name=new_password>";

	for ( $i = 1 ; $i <= $numpasswords ; $i++ )
	{
		@new_password = ();
		@new_password = create_new_password();
		$password = $new_password[0];
		$pronounciation = $new_password[1];
		print "<option value=$password>$password ($pronounciation)";
	}
	print "</select>";
	print "<BR>(The password's pronounciation is in brackets)";
	print "<br><br><b>User's home directory:</b><BR>Please select the directory you wish to give this user access to: ";
	print "<select name=new_directory>";
	system "./listdirectories.sh $domainname";
	print "</select>";

	print "<input type=hidden name=new_ftp_user value=$new_ftp_user>";

	print_end_of_form();
}
require $footer;
