#!/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);
$hostingplan = find_hosting_plan ($domainname);
$spacelimit = find_space_limit ($domainname);
$userlimit = find_user_limit ($hostingplan);
$usersused = find_number_users ($domainname);
$spaceused = find_space_used ($domainname);
@mailservers = find_mail_servers($domainname);
$numservers = @mailservers;
# @nameservers = find_name_servers("eircom.net");
@nameservers = find_name_servers($domainname);
$numnameservers = @nameservers;

($rump, $spacenumber, $spaceunit ) = split ( /\s/, $spaceused);

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

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

# display tabs
require $tabdisplay;

if ( ( ! $hostingplan ) || ( ! $domainname ) || ( ! $spacelimit ) || ( ! $userlimit ) || ( ! $usersused ) || ( $numservers == 0 ) )
{
        quit_with_errors ("Incorrect domain parameters passed from get_account_info module for $domainname: 
	$hostingplan $domainname $spacelimit $userlimit $usersused $numservers");
}

$previously_shown = 0;
open ( LOGGEDALREADY, "<$loggedinuserfile") || file_error ($loggedinuserfile);
while (<LOGGEDALREADY>)
{
	if (/$mainuser/)
	{
		$previously_shown = 1;
	}
}
close (LOGGEDALREADY);

if ( $previously_shown == 0 )
{
        # show the improvements which have been made to the control panel since their last logon
        require $vpanel_changes_file;

        open ( LOGGED, ">>$loggedinuserfile") || file_error ($loggedinuserfile);
        print LOGGED "$mainuser\n";
        close LOGGED;
} else {
	# output the contant of this tab
	require $tab_front[$tab_section-1];
}

require $footer;
