<?
/**
 * @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");
include('config/config_giftcode_card100.php');

if($giftcode_card100_use == 'none'){
	echo "Chức năng GiftCode nạp thẻ 100k không sử dụng"; exit();
}
elseif($giftcode_card100_use == 'down'){

	switch ($_SESSION['nv_class_id']){
		case 0:
		case 1:
		case 2:
		case 3:
			$GiftCode = $gift_dw;
			$msg_giftcode = $msg_dw;
		break;
	
		case 16:
		case 17:
		case 18:
		case 19:
			$GiftCode = $gift_dk;
			$msg_giftcode = $msg_dk;
		break;
	
		case 32:
		case 33:
		case 34:
		case 35:
			$GiftCode = $gift_elf;
			$msg_giftcode = $msg_elf;
		break;
		
		case 48:
		case 49:
		case 50:
			$GiftCode = $gift_mg;
			$msg_giftcode = $msg_mg;
		break;
		
		case 64:
		case 65:
		case 66:
			$GiftCode = $gift_dl;
			$msg_giftcode = $msg_dl;
		break;
		
		case 80:
		case 81:
		case 82:
		case 83:
			$GiftCode = $gift_sum;
			$msg_giftcode = $msg_sum;
		break;
		
		case 96:
		case 97:
		case 98:
			$GiftCode = $gift_rf;
			$msg_giftcode = $msg_rf;
		break;
		
		case 112:
		case 114:
			$GiftCode = $gift_gl;
			$msg_giftcode = $msg_gl;
		break;
	
		default :  echo "Lớp nhân vật chưa định nghĩa."; exit();
	}
		$item_read[] = array (
			'itemcode'	=> $GiftCode,
			'des'	=> $msg_giftcode,
			'rate'	=> 1,
			'rate_from'  =>  1,
			'rate_to'    =>  1
		);
		
	$hsd_time = $hsd;
}else{
	$file_giftcode = 'config/giftcode_random.txt';

	//Đọc File GiftCode
	$giftcode_arr = array();
	if(is_file($file_giftcode)) {
		$fopen_host = fopen($file_giftcode, "r");
		$giftcode_read = fgets($fopen_host);
		
		$giftcode_arr = json_decode($giftcode_read, true);
		fclose($fopen_host);
		if(!is_array($giftcode_arr)) $giftcode_arr = array();
	}
	
	$gift_name = $giftcode_arr[$giftcode_card100_use]['name'];
	$item_read = $giftcode_arr[$giftcode_card100_use]['gift'];
}

$page_template = "templates/event/giftcode_card100.tpl";
?>