#!/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);

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

# find all existing valid users
@ftp_users = find_valid_ftp_users($domainname);
$num_ftp_users = @ftp_users;

print_header ("List of FTP users for $domainname");

if ( $num_ftp_users == 0 )
{
	print qq!
	Sorry, but you do not have any FTP users set up yet. If you'd like to set up an FTP user please
	<a href=/$script_bin/$create_ftp_user><font color=#cc0000>click here</font></a>.<BR><BR>
	!;
} else {	
print<<HEADER;

Below is a list of all your FTP users and the website folders they are allowed to have access to. Everything inside the htdocs 
folder is viewable on the web.<BR><BR>

 <TABLE WIDTH=750 BORDER=0 CELLPADDING=0 CELLSPACING=15 class=text>
<tr><td width=100><b>Email User</b></td>
<td align=center width=300><b>Options</b></td>
<td width=300><b>Home Directory</td></tr>

HEADER

# Now loop for each of the user names.

for $ftp_user ( @ftp_users )
{
	print "\n<tr valign=middle><td><b>$ftp_user</b></td>\n";
	print "<td align=center><a href='/$script_bin/$reset_password?type=ftp&user=$ftp_user'>\n";
	print "<font color=#bb0000 size=2px>reset password</font></a>\n";
 	print "<br><a href='/$script_bin/$delete_ftp_user?user=$ftp_user'>";
	print "<font color=#bb0000 size=2px>delete user</font></a></td>";

	$ftp_home = find_user_home_directory($ftp_user);
	@directories = split ( /\//, $ftp_home);
	$number_directories = @directories;

	print "<TD>";
	for ( $i = 5; $i < $number_directories ; $i++ )
	{
		print "/$directories[$i]";
	}			
	print "</td></tr>";
}

print "</table><br><br>";

}
require $footer;
