#!/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("Removal of Spam protection for $domainname");

print "Thank you for your request to turn off MailWall's Anti-Spam protection.";
show_time_to_change();

# Turn off spam scanning
$ret = php_request ("setSpamScanning", "domain:$domainname", "false");
#open (REMOVE, ">>$remove_spam_protection_file") || file_error($remove_spam_protection_file);
#print REMOVE $domainname, "\n";
#close (REMOVE);

# Turn off spam trap if already activated
if ( 0 )
#if ( $spam_trap_status eq "on" )
{
	# Get the spam trap name
	$spam_trap_name = "spam".$mainuser;

	# Write to file for later processing
	open (DELTRAP, ">>$delete_spam_trap_file") || file_error($delete_spam_trap_file);
	print DELTRAP "$domainname\n";
	close (DELTRAP);

	# Write the user to a file for later deletion
	open (DELUSER, ">>$deleteuserfile") || file_error($deleteuserfile);
	print DELUSER $spam_trap_name, "\n";
	close DELUSER;

	$content_management_status = content_management_scanning_status($domainname);
	if ( $content_management_status eq "on" )
	{
		# Turn off content management
		open ( TURNON, ">>$remove_content_management_file" ) || file_error($create_content_management_file);
		print TURNON "$domainname\n";
		close (TURNON);

		# Turn off images scanning if it's turned on
		$make_filetype_change = 0;
		$filetype_scanning_status = filetype_scanning_status($domainname);
		if ( $filetype_scanning_status eq "everything" )
		{
			$list_file_flag = "only_virus";
			$make_filetype_change = 1;
		} elsif ( $filetype_scanning_status eq "only_spam" ) {
			$list_file_flag = "nothing";
			$make_filetype_change = 1;
		}
	}

	if ( $make_filetype_change == 1 )
	{
		open ( CHANGE, ">>$change_filetype_scanning_file") || file_error($change_filetype_scanning_file);
		print CHANGE "$list_file_flag,$domainname\n";
		close (CHANGE);
	}

}


#}
require $footer;
