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

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

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

# display tabs
require $tabdisplay;

print_header("Creation of a spam trap for $domainname");

print "Thank you for your request to create a spam trap for your account $domainname.<BR><BR>";

if ( $spam_trap_status eq "off" )
{
	# Get the spam trap name and password
	$spam_trap_name = "spam".$mainuser;
	@spam_trap_password = create_new_password();

	# Create the spam trap
	open ( ADDTRAP, ">>$create_spam_trap_file" ) || file_error($create_spam_protection_file);
	print ADDTRAP "$domainname,$spam_trap_name\n";
	close (ADDTRAP);

	# Create the user
	open (NEWUSER, ">>$newuserfile" ) || file_error($newuserfile);
	print NEWUSER "web $spam_trap_name $spam_trap_password[0] $domainname\n";
	close (NEWUSER);
	
	# Confirm these settings
	print "
		The details of your new spam trap are below:<BR><BR>
		Spam trap name: <b>$spam_trap_name</b><BR>
		Spam trap password (for webmail): <b>$spam_trap_password[0]</b><BR>
	( pronounciation: $spam_trap_password[1] ) 
	";

	show_time_to_change();

} else {
	print "Sorry, but it seems that you already have a spam trap installed or awaiting installation. ";
	print_support_contact_information();	
}

require $footer;
