#!/usr/bin/perl

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

# This script lists all user accounts and associated email addresses.
# The user is given the option to add/delete addresses, delete users and change a user's pw

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

$chosen_user = param ('user');
$type = param('type');

# Define the tab which appears to the front and populate the array of users
if ( $type eq "ftp" )
{
        $tab_section = $tabnum_website;
        @validusers = find_valid_ftp_users($domainname);
} else {
	$tab_section = $tabnum_email;
	@validusers = find_valid_users($domainname);
}

$num_validusers = @validusers;

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

# display tabs
require $tabdisplay;

print_header ("Changing a user's password for $domainname");

if ( ($num_validusers == 0) || ( ($num_validusers == 1) && ($type ne"ftp") ) )
{
	print "Sorry, but you don't seem to have any users set up yet.<BR><BR>";
	print_support_contact_information();	
} else {

print "Please select the user whose password you wish to change and the password you would like to use:<BR><BR>";

print "<table width=20% class=text>";
print "<form method=post action=/$script_bin/$confirm_reset_password class=text>";
print "<tr><td><B>User:</B></td><td><select name=user class=text>";


for $validuser ( @validusers )
{
	$mainuserstring = "$mainuser";
	if ( !($validuser =~ "^$mainuser") )
	{
		print "<option value=$validuser";
		if ( $chosen_user eq $validuser )
		{
			print " selected ";
		}
		print ">$validuser";
	}
}

print "</select></td></tr>";

print "<tr><td><B>Password:</B></td><td><select name=password class=text>";
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></td></tr></table>";

print "(The password's pronounciation is in brackets)";

print_end_of_form();

} 
require $footer;
