#!/usr/bin/perl
# ================================================================================
# $Rev: 226 $ $URL: svn://localhost/PlayChess/trunk/cgi/pos.cgi $
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Author: $Author: Thomas $
# Modified: $Date: 2006-10-10 21:22:56 +0000 (Di, 10 Okt 2006) $
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Copyright at playchess.de - all rights reserved
# ================================================================================
my $startTime = time;
use lib "../cgi-bin";
use CGI qw( :standard );
use CGI::Carp qw(fatalsToBrowser);
use Time::HiRes qw( time );
use Cache::FileCache;
use PCLeagueUtil;
use PCRobin;
use PCBoard;
use GamePage;
use PCMove;
use PCPlayer;
use PC;
use PCSession;
use Pos;
use PosStat;
use Template;
use Util;
use ChessConfig;
use MyDbi;
##--------------------------------------------------------------------------
## LOCAL CONFIGURATION
##--------------------------------------------------------------------------
$debug = 0 || Util::isDebug;
##--------------------------------------------------------------------------
## External CGI parameters
##--------------------------------------------------------------------------
local $cgi = CGI->new();
local $sobj = PCSession->new( $cgi );
my $action = $cgi->param( 'action' ) || 'tree';
# Page requires membership
# ~~~~~~~~~~~~~~~~~~~~~~~~
$sobj->assertMember();
# Profiling
printf( "Time for startup: %2.3f sec
", time-$startTime ) if($debug);
# Fetch content
my $tpl;
if( $action eq 'tree' )
{
$tpl = Pos::showTreePage( $cgi, $sobj );
}
elsif( $action eq 'list' )
{
$tpl = Pos::showListPage( $cgi, $sobj );
}
elsif( $action eq 'pgn' )
{
# set "page size" to 100 games
$cgi->param( 'min', 0 );
$cgi->param( 'ppp', 100 );
$tpl = Pos::showPgnPage( $cgi, $sobj );
}
# print "action=$action tpl=$tpl
";
# Profiling
printf( "Time for calculation: %2.3f sec
", time-$startTime ) if($debug);
# display Page
print $tpl->Expand( $sobj );
# Profiling
printf( "Time for everything: %2.3f sec
", time-$startTime ) if($debug);
exit(0);