<?
/** 
 * @Project GoldMU.Net
 * @copyright 03/03/2022
 * @Email: goldmu.net@gmail.com
 * @Zalo: 0923 117 898
 */
if (!defined('GoldWebMU')) die("Ban khong co quyen truy cap he thong");
if(!isset($_SESSION['char_choise_time']) || $_SESSION['char_choise_time'] < time() - 3) {
    $_SESSION['char_choise_time'] = time();
    $ip_client = get_ip();
    
    if(isset($_GET['nhanvat'])) $nhanvat = $_GET['nhanvat'];
    else $nhanvat = $_SESSION['mu_nvchon'];
    
	if (!preg_match("/^[a-zA-Z0-9_]*$/i", $nhanvat)){
		echo "<font color='red'>Dữ liệu lỗi - Tên nhân vật chỉ được sử dụng kí tự a-z, A-Z, số (1-9) và _.</font><br>";
	}
	else{
		
		$getcontent_url = $server_url . "/view.php";
		$getcontent_data = array(
			'action'    =>  'chonNV',
			'login'    =>  $_SESSION['mu_username'],
			'name'    =>  $nhanvat,
			'ip'    =>  $ip_client,
			'string_login'  =>  $_SESSION['checklogin'],
			'passtransfer'    =>  $passtransfer
		);
		
		$reponse = _getContent($getcontent_url, $getcontent_data, $getcontent_method, $getcontent_curl);
		
		if ( empty($reponse) ) echo "Server bảo trì.";
		elseif($reponse == "login_other") {
			echo "Tài khoản đã được đăng nhập trên trình duyệt khác hoặc máy tính khác.";
			session_destroy();
		}
		else {
			if (read_TagName($reponse, 'info', 1) != 'OK') { echo $reponse; }
			else {
				$_SESSION['mu_nvchon'] = $nhanvat;
				
				$_SESSION['nv_online'] = read_TagName($reponse, 'online', 1);
				$_SESSION['nv_doinv'] = read_TagName($reponse, 'doinv', 1);
				$_SESSION['nv_class_id'] = read_TagName($reponse, 'class_id', 1);
				$_SESSION['nv_class_name'] = read_TagName($reponse, 'class_name', 1);
				$_SESSION['nv_class_img'] = read_TagName($reponse, 'class_img', 1);
				$_SESSION['nv_class_master'] = read_TagName($reponse, 'class_master', 1);
				$_SESSION['nv_level'] = read_TagName($reponse, 'level', 1);
				$_SESSION['nv_point'] = read_TagName($reponse, 'point', 1);
				$_SESSION['nv_pointdutru'] = read_TagName($reponse, 'point_dutru', 1);
				$_SESSION['nv_zen'] = read_TagName($reponse, 'zen', 1);
				$_SESSION['nv_reset'] = read_TagName($reponse, 'reset', 1);
				$_SESSION['nv_resetday'] = read_TagName($reponse, 'resetday', 1);
				$_SESSION['nv_resetmonth'] = read_TagName($reponse, 'resetmonth', 1);
				$_SESSION['nv_relife'] = read_TagName($reponse, 'relife', 1);
				$_SESSION['nv_khoado'] = read_TagName($reponse, 'khoado', 1);
				$_SESSION['nv_thuepoint'] = read_TagName($reponse, 'thuepoint', 1);
				$_SESSION['nv_pointevent'] = read_TagName($reponse, 'pointevent', 1);
				$_SESSION['nv_uythaconline'] = read_TagName($reponse, 'uythacon', 1);
				$_SESSION['nv_point_uythac'] = read_TagName($reponse, 'pointuythac', 1);
				$_SESSION['nv_point_uythac_event'] = read_TagName($reponse, 'pointuythac_event', 1);
				$_SESSION['nv_uythac_offline'] = read_TagName($reponse, 'uythacoff', 1);
				$_SESSION['nv_uythac_offline_time'] = read_TagName($reponse, 'uythacoff_time', 1);
				$_SESSION['nv_uythac_offline_daily'] = read_TagName($reponse, 'uythacoff_daily', 1);
				$_SESSION['nv_top50'] = read_TagName($reponse, 'top50', 1);
				$_SESSION['point_event'] = read_TagName($reponse, 'point_event', 1);
				$_SESSION['event1_type1'] = read_TagName($reponse, 'event1_type1', 1);
				$_SESSION['event1_type2'] = read_TagName($reponse, 'event1_type2', 1);
				$_SESSION['event1_type3'] = read_TagName($reponse, 'event1_type3', 1);
				$_SESSION['event1_type1_daily'] = read_TagName($reponse, 'event1_type1_daily', 1);
				$_SESSION['event1_type2_daily'] = read_TagName($reponse, 'event1_type2_daily', 1);
				$_SESSION['event1_type3_daily'] = read_TagName($reponse, 'event1_type3_daily', 1);
				$_SESSION['quest_daily'] = read_TagName($reponse, 'qwait', 1);
				$_SESSION['nv_pkcount'] = read_TagName($reponse, 'PkCount', 1);
				$_SESSION['nv_levelmaster'] = read_TagName($reponse, 'levelmaster', 1);
				$_SESSION['nv_pointmaster'] = read_TagName($reponse, 'pointmaster', 1);
				$_SESSION['resets_0h'] = read_TagName($reponse, 'resets_0h', 1);
				$_SESSION['relifes_0h'] = read_TagName($reponse, 'relifes_0h', 1);
				$_SESSION['top1_rl'] = read_TagName($reponse, 'top1_rl', 1);
				$_SESSION['top1_rs'] = read_TagName($reponse, 'top1_rs', 1);
				$_SESSION['sum_top1_rs'] = read_TagName($reponse, 'sum_top1_rs', 1);
				$_SESSION['top1_rl_now'] = read_TagName($reponse, 'top1_rl_now', 1);
				$_SESSION['top1_rs_now'] = read_TagName($reponse, 'top1_rs_now', 1);
				$_SESSION['nv_ghrs'] = read_TagName($reponse, 'gioihanrs', 1);
				$_SESSION['nv_str'] = read_TagName($reponse, 'str', 1);
				$_SESSION['nv_dex'] = read_TagName($reponse, 'dex', 1);
				$_SESSION['nv_vit'] = read_TagName($reponse, 'vit', 1);
				$_SESSION['nv_ene'] = read_TagName($reponse, 'ene', 1);
				$_SESSION['nv_com'] = read_TagName($reponse, 'com', 1);
				$_SESSION['mapnumber'] = read_TagName($reponse, 'mapnumber', 1);
				$_SESSION['nv_pcpoint'] = read_TagName($reponse, 'pcpoint', 1);
				
				setcookie("vweb_loaddata", time(), time()+3600);
				
				if(!isset($_SESSION['nv_class_id'])) $_SESSION['nv_class_id'] = 0;
				
				echo "|OK|
				<div class='selected-character' id='reload_char'><div class='image-character character-". $_SESSION['nv_class_id'] ."'></div>
				<div class='info-character'>
				<p class='character-name'>".$_SESSION['mu_nvchon']."</p>
				<div class='level'>
				Level: ". $_SESSION['nv_level'] ."<br />
				Reset: ". $_SESSION['nv_reset'] ."<br />
				Relife: ". $_SESSION['nv_relife'] ."<br />
				Class: ". $_SESSION['nv_class_name'] ."
				</div>
				</div></div>|". $_SESSION['quest_daily'] ."|";
				$remove_choisenv = 1;
			}
		}
	}
} 
else {
    echo "Thao tác quá nhanh. Vui lòng chọn lại.";
}
?>