#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(:standard :netscape);
use RFC::Main;
use RFC::Rig;
use RFC::RFCCGI qw(:cgi :html);

my $ref = &RFC::RFCCGI::get_user_data_ref();
my $uid = $$ref{'uid'};

if (!defined(param))
{
    print process('to_login.tt');
}
else
{
    if ($uid)
    {
	print process('main_nav.tt');
	$_ = param('action');
      CASE:
	{
            ### Insert case statements ###
	    ### Default response ####
	    &main_page;
	}
	print process('end_html.tt');
    }
    else 
    {
        print process('not_auth.tt');
    }
}

sub main_page()
{
    my $r = param('rig');
    my $l = param('log');
    $l = '' unless ($l);
    my %data = ();
    if ($r)
    {
	my $rig = RFC::Rig->new($r);
	if ($l eq 'errorlog')
	{
	    $data{'log'} = $rig->get_errorlog();
	}
	elsif ($l eq 'proglog')
	{
	    $data{'log'} = $rig->get_sessionlog();
	}
	elsif ($l eq 'userlog')
	{
	    $data{'log'} = $rig->get_userlog();
	}
	else
	{
	    $data{'log'} = $rig->info();	    
	}
    }
    print process('show_log.tt',&get_template_data_ref(\%data));
}
