<?php
include 'common.php';



function ModelVersionIsSet($char_uid,$model_version)
{
	$dbhandle = DB_Connect();
	
	//Select DB
	$db_selected = mysqli_select_db($dbhandle, DB_NAME)
	or die("Could not select db");
	
	
	$response = "MODEL_VERSION_IS_SET_OK";
	$error = "";
	
	
	$stmt = $dbhandle->prepare("update character_list set model_version_is_set=1 , model_version=? where character_uid=?");
	$stmt->bind_param("ii",$model_version, $char_uid);
	$result = $stmt->execute();
	
	
	 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,'error'=>$error));
}

//아직 사용 안함. 참조용
$client_elios_version = $_GET['client_elios_version'];
$char_uid = $_GET['char_uid'];
$model_version = $_GET['model_version'];


if (CheckServerMaintenance())
{
	
	ModelVersionIsSet($char_uid,$model_version);
	
}
?>