<?php

	//Security
	if( ! defined( 'IS_INIT' ) )
	{
		die( 'Unauthorized Access');
	}
	
	global $Handler;
	
	//Final html being returned
	$string = null;
        if( isset( $_POST['chars'] ) )
        {
            if( $Handler->char->IsOwner( $_POST['chars'] ) == true )
            {
                if( $Handler->char->CharExists( @$_GET['char'] ) == true )
                { 
                    $Handler->char->FetchAllInfo();
                    
                    $Handler->char->SetTemplateValues();
                    
                    if( isset( $_POST['CharName'] ) )
                    {
                        include( 'namechange.php' );
                    }
                    elseif( isset( $_POST['EXPReset'] ) )
                    {
                        include( 'expreset.php' );
                    }
                    elseif( isset( $_POST['JC'] ) )
                    {
                        include( 'jc.php' );
                    }
                }
                else
                {
                    $Handler->theme->SetValue( 'CONTENT' , $Handler->theme->GetValue( 'INVALID_CHAR' ) ) ;
                }
            }
            else
            {
                $Handler->theme->SetValue( 'CONTENT' , $Handler->theme->GetValue( 'INVALID_CHAR' ) ) ;
            }
        }
        if( isset( $_GET['char'] ) && $_GET['char'] <> NULL )
        {
            if( $Handler->char->CharExists( $_GET['char'] ) == true )
            {   
                $Handler->char->FetchAllInfo();
                
                $Handler->char->SetTemplateValues();
                
                $Handler->theme->SetValue( 'CONTENT' , $Handler->theme->QuietParse( 'char.html' ) );         
            }
            else
            {
                $Handler->theme->SetValue( 'CONTENT' , $Handler->theme->GetValue( 'INVALID_CHAR' ) ) ;
            }  
            
        }
        else
        {    
            $Handler->theme->SetValue( 'CONTENT' , "<center><span>Please enter a character</span></center>" );
        }
        //print_r( $Handler->user->UserOptions);
?>
