<?php
include 'common.php';


function GetGameWp($account_id, $character_uid)
{
	$dbhandle = DB_Connect();
	//Select DB
	$db_selected = mysqli_select_db($dbhandle, DB_NAME)
	or die("Could not select db");
	
	
	$stmt = $dbhandle->prepare("select wp from character_list where user_id=? and character_uid=?");
	$stmt->bind_param("si", $account_id,$character_uid);
	$stmt->execute();
	$result = $stmt->get_result();
	
	
	mysqli_stmt_free_result($stmt);
	$stmt->close();
	
	
	
	$response = "GET_WP_FAILED";	
	$error = "";
	$wp = "";
	if($result)
	{
		$response = "GET_WP_OK";
		$row = $result->fetch_assoc();
		$wp = $row["wp"];
	}
	else
	{
		$error = mysqli_error($dbhandle);
	}
	
	
	 mysqli_close($dbhandle);
 
    $isXmlHttpRequest = (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) ?
    (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') ? true : false: false;
    ($isXmlHttpRequest) ? header('Content-type: application/json') : header('Content-type: text/plain');
 
    echo json_encode(array('result'=>$response, 'wp'=>$wp,'error'=>$error));
}

$json = json_decode(file_get_contents('php://input'));
$account_id = $json->account_id;
$character_uid = $json->character_uid;
		
GetGameWp($account_id, $character_uid);




	

?>