<?php

	//Security
	if( ! defined( 'IS_INIT' ) )
	{
		die( 'Unauthorized Access');
	}
    
    global $Handler;
    
    if( $Handler->user->HasEnoughCoins( 5000 ) == true )
    {
        if( $Handler->char->IsOnline() == false )
        {
           $Handler->char->ResetEXP();
           $Handler->user->SubPoints( 5000 );
           $Handler->theme->SetValue( 'MESSAGE' , $Handler->theme->GetValue( 'EXP_RESET_OK' ) );
           $Handler->theme->SetValue( 'GO_BACK' , 'Refresh' );
           $Handler->theme->SetValue( 'RED_URL' , MAIN_URL . "?view=cp&do=characters&char=" . $Handler->char->charinfo['sID'] );
           $Handler->theme->Parse( 'success.html' );
        }
        else
        {
            $Handler->theme->SetValue( 'ERROR' , $Handler->theme->GetValue( 'CHAR_LOGGED_IN' ) );
            $Handler->theme->SetValue( 'GO_BACK' , null );
            $Handler->theme->SetValue( 'RED_URL' , MAIN_URL . $_SERVER['REQUEST_URI'] );
            $Handler->theme->Parse( 'error.html' );
        }
    }
    else
    {
        $Handler->theme->SetValue( 'ERROR' , $Handler->theme->GetValue( 'ERR_MONEY' ) );
        $Handler->theme->SetValue( 'GO_BACK' , null );
        $Handler->theme->SetValue( 'RED_URL' , MAIN_URL . $_SERVER['REQUEST_URI'] );
        $Handler->theme->Parse( 'error.html' );
    }
    
?>