#! /usr/bin/perl -wT

use strict;
use CGI;

my $q = new CGI;

print $q -> header( "text/html" );

open ( LOG, ">>log.dat" ) || die ( "error:  open LOG failed\n" );
# flock ( LOG, LOCK_EX );
seek ( LOG, 0, 2 );
print LOG "$ENV{"HTTP_USER_AGENT"} $ENV{"REMOTE_ADDR"} $ENV{"REMOTE_HOST"} $ENV{"HTTPS" } $ENV{"REMOTE_PORT"} $ENV{"SCRIPT_FILENAME"}";
# flock ( LOG, LOCK_UN );
close ( LOG ) || die ( "error:  close LOG failed\n" );

my $con = $q -> param ( "con" );
my $content = "con";

if ( $con eq "" ) {
	$content = open( INDEXDEF, "<index.html" ) || die( "error:  open INDEXDEF failed\n" );
#	flock ( INDEXDEF, LOCK_EX );
	seek( INDEXDEF, 0, 0 );
	while( <INDEXDEF> )
	{
		print $_;
	}
#	flock ( INDEXDEF, LOCK_UN );
	close( INDEXDEF ) || die( "error:  close INDEXDEF failed\n" );
}

elsif ( $con eq "index" ) {
	$content = open( INDEX, "<index.html" ) || die( "error:  open INDEX failed\n" );
#	flock ( INDEX, LOCK_EX );
	seek( INDEX, 0, 0 );
	while( <INDEX> )
	{
		print $_;
	}
#	flock ( INDEX, LOCK_UN );
	close( INDEX ) || die( "error:  close INDEX failed\n" );
}

elsif ( $con eq "index2" ) {
	$content = open( INDEX2, "<index2.html" ) || die( "error:  open INDEX2 failed\n" );
#	flock ( INDEX2, LOCK_EX );
	seek( INDEX2, 0, 0 );
	while( <INDEX2> )
	{
		print $_;
	}
#	flock ( INDEX2, LOCK_UN );
	close( INDEX2 ) || die( "error:  close INDEX2 failed\n" );
}

elsif ( $con eq "main" ) {
	$content = open( MAIN, "<main.html" ) || die( "error:  open MAIN failed\n" );
#	flock ( MAIN, LOCK_EX );
	seek( MAIN, 0, 0 );
	while( <MAIN> )
	{
		print $_;
	}
#	flock ( MAIN, LOCK_UN );
	close( MAIN ) || die( "error:  close MAIN failed\n" );
}

elsif ( $con eq "main2" ) {
	$content = open ( MAIN2, "<main2.html" ) || die ( "error:  open MAIN2 failed\n" );
#	flock ( MAIN2, LOCK_EX );
	seek ( MAIN2, 0, 0 );
	while( <MAIN2> )
	{
		print $_;
	}
#	flock ( MAIN2, LOCK_UN );
	close ( MAIN2 ) || die ( "error:  close MAIN2 failed\n" );
}

elsif ( $con eq "banner" ) {
	$content = open( BANNER, "<banner.html" ) || die( "error:  open BANNER failed\n" );
#	flock ( BANNER, LOCK_EX );
	seek( BANNER, 0, 0 );
	while( <BANNER> )
	{
		print $_;
	}
#	flock ( BANNER, LOCK_UN );
	close( BANNER ) || die( "error:  close BANNER failed\n" );
}

elsif ( $con eq "content" ) {
	$content = open ( CONTENT, "<content.html" ) || die ( "error:  open CONTENT failed\n" );
#	flock ( CONTENT, LOCK_EX );
	seek ( CONTENT, 0, 0 );
	while ( <CONTENT> )
	{
		print $_;
	}
#	flock ( CONTENT, LOCK_UN );
	close ( CONTENT ) || die ( "error:  close CONTENT failed\n" );
}

elsif ( $con eq "bot" ) {
	$content = open( BOT, "<bot.html" ) || die( "error:  open BOT failed\n" );
#	flock ( BOT, LOCK_EX );
	seek( BOT, 0, 0 );
	while( <BOT> )
	{
		print $_;
	}
#	flock ( BOT, LOCK_UN );
	close( BOT ) || die( "error:  close BOT failed\n" );
}

elsif ( $con eq "aboutus" ) {
	$content = open( ABOUTUS, "<aboutus.html" ) || die( "error:  open ABOUTUS failed\n" );
#	flock ( ABOUTUS, LOCK_EX );
	seek( ABOUTUS, 0, 0 );
	while( <ABOUTUS> )
	{
		print $_;
	}
#	flock ( ABOUTUS, LOCK_UN );
	close( ABOUTUS ) || die( "error:  close ABOUTUS failed\n" );
}

elsif ( $con eq "photos" ) {
	$content = open( PHOTOS, "<photos.html" ) || die( "error:  open PHOTOS failed\n" );
#	flock ( PHOTOS, LOCK_EX );
	seek( PHOTOS, 0, 0 );
	while( <PHOTOS> )
	{
		print $_;
	}
#	flock ( PHOTOS, LOCK_UN );
	close( PHOTOS ) || die( "error:  close PHOTOS failed\n" );
}

elsif ( $con eq "lyrics" ) {
	$content = open( LYRICS, "<lyrics.html" ) || die( "error:  open LYRICS failed\n" );
#	flock ( LYRICS, LOCK_EX );
	seek( LYRICS, 0, 0 );
	while( <LYRICS> )
	{
		print $_;
	}
#	flock ( LYRICS, LOCK_UN );
	close( LYRICS ) || die( "error:  close LYRICS failed\n" );
}

elsif ( $con eq "bios" ) {
	$content = open( BIOS, "<bios.html" ) || die( "error:  open BIOS failed\n" );
#	flock ( BIOS, LOCK_EX );
	seek( BIOS, 0, 0 );
	while( <BIOS> )
	{
		print $_;
	}
#	flock ( BIOS, LOCK_UN );
	close( BIOS ) || die( "error:  close BIOS failed\n" );
}

elsif ( $con eq "contactus" ) {
	$content = open( CONTACTUS, "<contactus.html" ) || die( "error:  open CONTACTUS failed\n" );
#	flock ( CONTACTUS, LOCK_EX );
	seek( CONTACTUS, 0, 0 );
	while( <CONTACTUS> )
	{
		print $_;
	}
#	flock ( CONTACTUS, LOCK_UN );
	close( CONTACTUS ) || die( "error:  close CONTACTUS failed\n" );
}

elsif ( $con eq "merch" ) {
	$content = open( MERCH, "<merch.html" ) || die ( "error:  open MERCH failed\n" );
#	flock ( MERCH, LOCK_EX );
	seek ( MERCH, 0, 0 );
	while ( <MERCH> )
	{
		print $_;
	}
#	flock ( MERCH, LOCK_UN );
	close ( MERCH ) || die ( "error:  close MERCH failed\n" );
}

elsif ( $con eq "chat" ) {
	$content = open( CHAT, "<chat.html" ) || die ( "error:  open CHAT failed\n" );
#	flock ( CHAT, LOCK_EX );
	seek ( CHAT, 0, 0 );
	while ( <CHAT> )
	{
		print $_;
	}
#	flock ( CHAT, LOCK_UN );
	close ( CHAT ) || die ( "error:  close CHAT failed\n" );
}

else {
	print "error:  content failed\n";
}

chop ( $content );

print <<"EndOfHTML";
$content
EndOfHTML
