<?php

	//Security
	if( ! defined( 'IS_INIT' ) )
	{
		die( 'Unauthorized Access');
	}
	
	global $Handler;
	
	$Handler->theme->SetValue( "SERVER_EXP" , EXP );
	$Handler->theme->SetValue( "SERVER_DROPS" , DROPS );
	
	$Handler->theme->SetValue( "SERVER_EXP" , EXP );
	$Handler->theme->SetValue( "SERVER_DROPS" , DROPS );
	
	$p = sqlsrv_prepare( $Handler->database->conn , "Select COUNT(*) from World00_Character.dbo.LoggedInChars" , array() );
	sqlsrv_execute( $p );
	$result = sqlsrv_fetch_array( $p , SQLSRV_FETCH_ASSOC );
	$Handler->theme->SetValue( "SERVER_PLAYERS" , $result[''] );
	
	$Handler->theme->SetValue( 'NEWS' , $Handler->fn->News() );
	if( LOGGED_IN == true && ACC_LEVEL > 0 )
	{
		$cash = sqlsrv_prepare( $Handler->database->conn , "Select cash from Account.dbo.tCash where userNo = ? and cashtype = 1 and status = 'true' " , array( &$Handler->user->UserOptions['nUserNo'] ) );
		sqlsrv_execute( $cash );
		$ret = sqlsrv_fetch_array( $cash , SQLSRV_FETCH_ASSOC );
		
		$Handler->theme->SetValue( 'SIDE_PANEL' , 
				
		"Hello, " . htmlentities( ucwords( strtolower( $_SESSION['UserID'] ) ) ) .
		"<br />Account Level : " . $Handler->user->UserOptions['nAuthID']. 
		"<br />Risorial Coins : " . $ret['cash'] .
		'<br /><a href="' . MAIN_URL . '?view=login&logout" style="position:absolute; display:block; margin-top:45px; margin-left:30px;">
		<button>Log Out!</button>
		</a>'
				
				
				
				); 
	} 
	else
	{
		$Handler->theme->SetValue( 'SIDE_PANEL' , $Not = '
		<form method="post" action="index.php?view=login">
		<label>' . $Handler->theme->GetValue( 'NAME' ) . '</label>
		<input type="text" name="username" AUTOCOMPLETE=OFF />
		<label>' . $Handler->theme->GetValue( 'PASS' ) . '</label>
		<input type="password" name="password" /><br />
		<input type="submit" name="register" value= "' . $Handler->theme->GetValue( 'LOG_IN' ) . '" />
		</form>
		<a href="index.php?view=register">' . $Handler->theme->GetValue( 'SIDE_ACCOUNT' ) . LOGGED_IN . '</a>' );	
	}
	
	$Handler->theme->Parse( 'home.html' );
?>