<?php
session_start();
include_once('../../config/#Config.php');
if(!$_SESSION['UserName']){
die('<script>window.location.href=\''.$config['site']['url'].'index.php\';</script>');
} else {
$get_AD = mysqli_query($conn, "Select * From config_admin WHERE Account = '".$_SESSION['UserName']."'");
if(!mysqli_num_rows($get_AD)){
	die('Không đủ quyền.');
}	
    /* ------------------------------------------- CONNECT CHAR SV ------------------------------- */
    $get_Server = mysqli_query($conn, "Select * From config_server WHERE ServerID = '" . $_POST['sv'] . "'");
    if (!mysqli_num_rows($get_Server)) {
        die('Lấy thông tin Máy chủ thất bại.');
    }
    $get_Server = mysqli_fetch_array($get_Server, MYSQLI_ASSOC);
    $conn_char  = @mysqli_connect($get_Server['IPdata'], $get_Server['Userdata'], $get_Server['PassData'], $get_Server['Databases']);
    if ($conn_char->mysqli_connect_errno) {
        die("Connection failed: " . $conn_char->mysqli_connect_errno);
    }
	mysqli_query($conn_char, "SET NAMES 'utf8'"); 
    /* ------------------------------------------- CONNECT CHAR SV ------------------------------- */	
	    $get_nhannvat = mysqli_query($conn_char, "Select * From player_query_data WHERE RoleId = '" . $_POST['nvid'] . "'");
    if (mysqli_num_rows($get_nhannvat)) {
        $row = mysqli_fetch_assoc($get_nhannvat);
        $row_OK['Gold'] = number_format($row['Coin']);
        $row_OK['Money'] = number_format($row['Gold']);
        $row_OK['Contrib'] = number_format($row['Contrib']);
        $row_OK['FightPower'] = number_format($row['FightPower']);
        $row_OK['Lv'] = number_format($row['Level']);

        echo json_encode($row_OK);
	}
}

?>