#!/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);
$postmasteraddress = "postmaster@".$domainname;
$abuseaddress = "abuse@".$domainname;

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

print_header ("List of email forwarding for $domainname");

print<<HEADER;

Below is a list of email addresses which are being forwarded to other email addresses:<BR>

HEADER

@forwarding_addresses = find_email_forwarding($domainname);
$forwarding_number = @forwarding_addresses;

if ( $forwarding_number > 0 )
{

	print "<TABLE WIDTH=750 BORDER=0 CELLPADDING=0 CELLSPACING=15 class=text><br><tr><td><b>Email Address</b></td>";
	print "<td align=left><b>Forwarded to</b></td><td align=left><b>Options</b></td></tr>";

	for $forwarding_address (@forwarding_addresses)
	{
		( $from_address, $to_address ) = split (/\s+/, $forwarding_address);

		print "<tr><td>";
		( $emailuser, $emaildomain ) = split ( /@/, $from_address );
		if ( $emailuser eq "" )
		{
			print "Your multidrop account";
		} else {
			print "$from_address";
		}
		print "</td><td>$to_address</td> ";
		if ( $from_address ne $postmasteraddress && $from_address ne $abuseaddress )
		{
			print "<td><a href='/$script_bin/$confirm_delete_address?address=$from_address'>";
                	print "<font color=#bb0000 size=2px>delete forwarding</font></a></td></tr>";
		}
		print "</tr>";
	}

} else {
	print "<i><< You have no forwarding set up at the moment. >></i><BR>";
}

print qq!
	</table><BR><BR>If you would like to add to your email forwarding please <a href=/$script_bin/$create_forwarding>
	<font color=#cc0000>click here</a>.<BR><BR>
!;

require $footer;

