<?
/** 
 * @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");

function kiemtra_captcha($security_code)
{
	if( $_SESSION['security_code'] != md5($security_code) ) 
		return false;
	else
		return true;
}

function viewchar($login) {
	include('config/config.php');
	$form_data = "action=view_char&login=$login&passtransfer=$passtransfer";
	$show_reponse = @file_get_contents($server_url."/view.php?".$form_data);
	$char = explode('<vwebmu>',$show_reponse);
	for ($i=0; $i<5; ++$i)
	{
		if ( !empty($char[$i]))
		{
			$showchar[] = $char[$i];
		}
	}
	return $showchar;
}

function kiemtra_kitudacbiet($login) {
	if (!preg_match("/^[a-zA-Z0-9_]*$/i", $login))
	{
    echo "Du lieu loi : $login . Chi duoc su dung ki tu a-z, A-Z, so (1-9) va dau _."; exit();
	}
}

function kiemtra_kituso($login) {
	if (!preg_match("/^[0-9]*$/i", $login))
	{
    echo "Du lieu loi : $login . Chi duoc su dung so (1-9)."; exit();
	}
}

function kiemtra_email($email) {
	if (!preg_match("/^[a-zA-Z0-9\.@_-]*$/i", $email))	{
    echo "Email Khong duoc su dung nhung ky tu dac biet."; exit();
	}
	if (!preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,6}$/i", $email)) {
	echo "Dia chi Email khong dung. Xin vui long kiem tra lai."; exit();
	}
}

function _getdaugia_list ($file_host = 'data/daugia_bidding.txt', $time_wait = 60) {
    global $server_url, $getcontent_method, $getcontent_curl, $passtransfer;
    
    $time = time()+date("25200");

	$fp_host = fopen($file_host, "a+");
	$time_host = fgets($fp_host);
	fclose($fp_host);
	if ($time >= ($time_host+$time_wait) || $time_host > $time)
	{
		$getcontent_url = $server_url . "/sv_com.php";
        $getcontent_data = array(
            'login'    =>  $_SESSION['mu_username'],
            'name'    =>  $_SESSION['mu_nvchon'],
            
            'action'    =>  'listitem_biding',
            'pagesv'    =>  'sv_com_daugia',
            'string_login'    =>  $_SESSION['checklogin'],
            'passtransfer'    =>  $passtransfer
        );
        
        $reponse = _getContent($getcontent_url, $getcontent_data, $getcontent_method, $getcontent_curl);

		if ( !empty($reponse) )
		{
            $reponse_explode = explode('<vweb>', $reponse);
            if($reponse_explode[1] == 'OK') {
                //Ghi vào file
        			$fp = fopen($file_host, "w+");  
        			fputs ($fp, $time."\n".$reponse_explode[2]);
        			fclose($fp);
        		//End Ghi vào File
            } else {
                $err = "Lỗi : $reponse";
                echo $err;
            }
		} else {
		  echo "Không nhận được dữ liệu";
		}
	}
}

function jum($local) {
	header("Location: $local");
}

function empty_field($login) {
	if (empty($login))
	{
    	$error = "<font size='2' color='red'>Chưa điền đầy đủ tất cả dữ liệu cần thiết.</font>"; 
	}
}

function get_ip()
{
	# Enable X_FORWARDED_FOR IP matching?
	$do_check = 1;
	$addrs = array();

	if( $do_check )
	{
		if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
		  foreach( array_reverse(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])) as $x_f )
    		{
    			$x_f = trim($x_f);
    			if( preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $x_f) )
    			{
    				$addrs[] = $x_f;
    			}
    		}
		}
            
		if(isset($_SERVER['HTTP_CLIENT_IP'])) $addrs[] = $_SERVER['HTTP_CLIENT_IP'];
		if(isset($_SERVER['HTTP_PROXY_USER'])) $addrs[] = $_SERVER['HTTP_PROXY_USER'];
	}

	$addrs[] = $_SERVER['REMOTE_ADDR'];

	foreach( $addrs as $v )
	{
		if( $v )
		{
			preg_match("/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/", $v, $match);
			$ip = $match[1].'.'.$match[2].'.'.$match[3].'.'.$match[4];

			if( $ip && $ip != '...' )
			{
				break;
			}
		}
	}

	if( ! $ip || $ip == '...' )
	{
		$ip = GetRealUserIp("127.0.0.1",FILTER_FLAG_IPV4);
	}
	
	if( ! $ip || $ip == '...' )
	{
		print_error("Không thể xác định địa chỉ IP của bạn.");
	}

	return $ip;
}

function GetRealUserIp($default = NULL, $filter_options = 12582912) {
    $HTTP_X_FORWARDED_FOR = isset($_SERVER)? $_SERVER["HTTP_X_FORWARDED_FOR"]:getenv('HTTP_X_FORWARDED_FOR');
    $HTTP_X_FORWARDED = isset($_SERVER)? $_SERVER["HTTP_X_FORWARDED"]:getenv('HTTP_X_FORWARDED');
    $HTTP_FORWARDED_FOR = isset($_SERVER)? $_SERVER["HTTP_FORWARDED_FOR"]:getenv('HTTP_FORWARDED_FOR');
    $HTTP_FORWARDED = isset($_SERVER)? $_SERVER["HTTP_FORWARDED"]:getenv('HTTP_FORWARDED');
    $HTTP_CLIENT_IP = isset($_SERVER)?$_SERVER["HTTP_CLIENT_IP"]:getenv('HTTP_CLIENT_IP');
    $HTTP_CF_CONNECTING_IP = isset($_SERVER)?$_SERVER["HTTP_CF_CONNECTING_IP"]:getenv('HTTP_CF_CONNECTING_IP');
    $REMOTE_ADDR = isset($_SERVER)?$_SERVER["REMOTE_ADDR"]:getenv('REMOTE_ADDR');

    $all_ips = explode(",", "$HTTP_X_FORWARDED_FOR,$HTTP_X_FORWARDED,$HTTP_FORWARDED_FOR,$HTTP_FORWARDED,$HTTP_CLIENT_IP,$HTTP_CF_CONNECTING_IP,$REMOTE_ADDR");
    foreach ($all_ips as $ip) {
        if ($ip = filter_var($ip, FILTER_VALIDATE_IP, $filter_options))
            break;
    }
    return $ip?$ip:$default;
}

function print_error($msg)
{
	echo "
	<html>
	<head><title>Hệ thống chống xâm nhập</title>
		<style type='text/css'>
			html{ overflow-x:auto; }
			body{ background:#FFF; color:#222; font-family:Arial, Verdana, Tahoma, Times New Roman, Courier; font-size:11px; line-height:135%; margin:0; padding:0; text-align:center; }
			a:link, a:visited, a:active{ background:transparent; color:#0066CC; text-decoration:none; }
			a:hover{ background:transparent; color:#000000; text-decoration:underline; }
			#wrapper{ margin:5px auto 20px auto; text-align:left; width:80%; }
			.borderwrap{ background:#FFF; border:1px solid #EEE; padding:3px; margin:0; }
			.borderwrap p{ background:#F9F9F9; border:1px solid #CCC; margin:5px; padding:10px; text-align:left; }
			.warnbox{ border:1px solid #F00; background:#FFE0E0; padding:6px; margin-right:1%; margin-left:1%; text-align:left; }
		</style>
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
	</head>
	<body>
	<div id='wrapper'><br /><br />
		<div class='borderwrap'>
			<p style='font-size:15pt; color:#FF3300;'><b>Cảnh Báo:</b></p><br /><br />
			<div class='warnbox'>
				<b>$msg</b>
			</div><br />
		</div><br />
		<div align='center' style='border:1px solid #EEE; padding:5px 0px 5px 5px; color:#808080; font-face:Tahoma;'><a href='http://vwebmu.com/' target='_blank'>Hệ thống chống xâm nhập</a> &copy; ".date('Y')." <a href='mailto:quangvuviettel@gmail.com'>VWebMU Security</a></div>
	</div>
	</body>
	</html>";
	exit();
}

function _trimendslashurl ($url)
{
    // Trim End URL /
    while(substr($url, -1) == "/") {
        $url = substr($url, 0, -1);
    }
    return $url;
}


function _checksendsv( $second_check = 1 )
{
    if(isset($_COOKIE['last_sendsv'])) $last_send = $_COOKIE['last_sendsv'];
    $timenowcheck = time();
    if(isset($last_send) && $last_send>0) {
        if( ($timenowcheck - $last_send) > $second_check ) {
            $expire=time()+60*60*24*30;
            setcookie("last_sendsv", time(), $expire);
            return true;
        } else {
            return false;
        }
    } else {
        $expire=time()+60*60*24*30;
        setcookie("last_sendsv", time(), $expire);
        return true;
    }
    return true;
}

/**
 * _langarr()
 * 
 * @param mixed $string
 * @param mixed $arr
 * @return
 */
function _langarr($string, $arr) {
    foreach($arr as $str_replace) {
        $string = preg_replace('/%s/', $str_replace, $string, 1);
    }
    
    return $string;
}

function _loaddata() {
    if( isset($_SESSION['mu_username']) && isset($_SESSION['mu_nvchon']) && isset($_SESSION['checklogin']) && strlen($_SESSION['mu_username']) > 0 && strlen($_SESSION['mu_nvchon']) > 0 && ( !isset($_COOKIE["vweb_loaddata"]) || $_COOKIE["vweb_loaddata"] < (time() - 300) ) ) {
        
        global $server_url, $getcontent_method, $getcontent_curl, $passtransfer;
        
        $getcontent_url = $server_url . "/view.php";
        $getcontent_data = array(
            'action'    =>  'view_infoacc',
            'login'    =>  $_SESSION['mu_username'],
            'name'    =>  $_SESSION['mu_nvchon'],
            'string_login'  =>  $_SESSION['checklogin'],
            'passtransfer'    =>  $passtransfer
        ); 
        
        $reponse = _getContent($getcontent_url, $getcontent_data, $getcontent_method, $getcontent_curl);
        $data = unserialize_safe($reponse);
        if(is_array($data)) {
            
            $_SESSION['acc_gcoin'] = $data['acc_gcoin'];
            $_SESSION['acc_gcoin_km'] = $data['acc_gcoin_km'];
            $_SESSION['acc_vpoint'] = $data['acc_vpoint'];
            $_SESSION['acc_zen'] = $data['acc_zen'];
            $_SESSION['acc_heart'] = $data['acc_heart'];
            $_SESSION['acc_chao'] = $data['acc_chao'];
            $_SESSION['acc_cre'] = $data['acc_cre'];
            $_SESSION['acc_blue'] = $data['acc_blue'];
            $_SESSION['IPBonusPoint'] = $data['acc_ipbonuspoint'];
            
            $_SESSION['nv_online'] = $data['online'];
			$_SESSION['nv_doinv'] = $data['doinv'];
			$_SESSION['nv_level'] = $data['nv_level'];
			$_SESSION['nv_point'] = $data['nv_point'];
			$_SESSION['nv_pointdutru'] = $data['nv_pointdutru'];
			$_SESSION['nv_zen'] = $data['nv_zen'];
			$_SESSION['nv_reset'] = $data['nv_reset'];
			$_SESSION['nv_resetday'] = $data['nv_resetday'];
			$_SESSION['nv_resetmonth'] = $data['nv_resetmonth'];
			$_SESSION['nv_relife'] = $data['nv_relife'];
			$_SESSION['nv_khoado'] = $data['nv_khoado'];
			$_SESSION['nv_uythaconline'] = $data['nv_uythacon'];
			$_SESSION['nv_point_uythac'] = $data['nv_pointuythac'];
            $_SESSION['nv_point_uythac_event'] = $data['nv_pointuythac_event'];
			$_SESSION['nv_uythac_offline'] = $data['nv_uythac_offline'];
			$_SESSION['nv_uythac_offline_time'] = $data['nv_uythac_offline_time'];
            $_SESSION['nv_uythac_offline_daily'] = $data['nv_uythac_offline_daily'];
            $_SESSION['nv_top50'] = $data['nv_top50'];
            $_SESSION['point_event'] = $data['nv_point_event'];
            $_SESSION['event1_type1'] = $data['nv_event1_type1'];
            $_SESSION['event1_type2'] = $data['nv_event1_type2'];
            $_SESSION['event1_type3'] = $data['nv_event1_type3'];
            $_SESSION['event1_type1_daily'] = $data['nv_event1_type1_daily'];
            $_SESSION['event1_type2_daily'] = $data['nv_event1_type2_daily'];
            $_SESSION['event1_type3_daily'] = $data['nv_event1_type3_daily'];
            $_SESSION['quest_daily'] = $data['qwait'];
            $_SESSION['nv_pcpoint'] = $data['nv_pcpoint'];
            
            setcookie("vweb_loaddata", time(), time()+24*60*60);
            
        } else {
            setcookie("vweb_loaddata", time()+3600, time()+24*60*60);
        }
    }
}

function unserialize_safe($serialized) {
    // unserialize will return false for object declared with small cap o
    // as well as if there is any ws between O and :
    if (is_string($serialized) && strpos($serialized, "\0") === false) {
        if (strpos($serialized, 'O:') === false) {
            // the easy case, nothing to worry about
            // let unserialize do the job
            return @unserialize($serialized);
        } else if (!preg_match('/(^|;|{|})O:[0-9]+:"/', $serialized)) {
            // in case we did have a string with O: in it,
            // but it was not a true serialized object
            return @unserialize($serialized);
        }
    }
    return false;
}

/**
 * read_TagName()
 * 
 * @param mixed $content
 * @param mixed $tagname
 * @param integer $vitri
 * $vitri = 0 : output All
 * $vitri = x : output Element x, Element 0 : Count Total Element
 * @return
 */
function read_TagName($content, $tagname, $vitri = 0)
{
    $tag_begin = '<'. $tagname . '>';
    $tag_end = '</'. $tagname . '>';
    $content1 = explode($tag_begin, $content);
    $slg_string = count($content1)-1;
    $output[] = $slg_string;    // Vị trí đầu tiên xuất ra số lượng phần tử
    for($i=1; $i<count($content1); $i++)    // Duyệt từ phần tử thứ 1 đến hết
    {
        $content2 = explode($tag_end, $content1[$i]);
        $output[] = $content2[0];
    }
    
    if($vitri == 0) return $output;
    else return isset($output[$vitri]) ? $output[$vitri] : null;
}

/**
 * _getContent()
 * 
 * @param string $url
 * @param array $data
 * @param string $method - GET OR POST
 * @param bool $use_curl - true OR false
 * @return
 */
function _getContent( $url, $data = null, $method = "GET", $use_curl = false ) {
    $file_logconnect = "data/log_connect.txt";
    $connect_err = false;
    $content = '';
    
    // Read Check Connect
    if(file_exists($file_logconnect)) {
        $fp = fopen($file_logconnect, "r");  
    	$data_read = fgets ($fp);
    	fclose($fp);
        
        $data_read_arr = explode('vweb', $data_read);
        if(isset($data_read_arr[2])) {
            $connect_status_read = $data_read_arr[1];
            $connect_time_read = $data_read_arr[2];
            
            if($connect_status_read == 0) {
                $time_now = time();
                if($connect_time_read > $time_now - 5) {
                    $time_wait = $connect_time_read + 5 - $time_now;
                    $content = "Kết nối đến Server đang xảy ra sự cố.<br /> Vui lòng chờ trong <strong>$time_wait giây</strong> rồi thực hiện lại. ";
                    $connect_err = true;
                }
            }
        }
    } else {
        $content = "Lỗi : Không tồn tại File : $file_logconnect";
        $connect_err = true;
    }
    // Read Check Connect _End
    
    if($connect_err === false) {
        if(!is_array($data)) $data = null;
        if( count($data) > 0 ) {
            $postdata = urldecode(http_build_query($data, '', '&'));
        }
        else $postdata = "";
        if($method != "POST") $method = "GET";
        
        if ( $use_curl === true ) {
            $ch = curl_init();
            if($method == "POST") {
                curl_setopt($ch,CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
            } else {
                curl_setopt($ch, CURLOPT_URL,$url . "?" . $postdata);
            }
            //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
        	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        	curl_setopt($ch, CURLOPT_TIMEOUT, 20);
        	$content = curl_exec($ch);
        	curl_close($ch);
        } else {
            $opts = array(
                'http' => array(
                    'method'    =>  $method,
                    'content'   =>  $postdata
                )
            );
            $context = stream_context_create($opts);
            
            if($method == "GET" && $postdata) $url = $url . "?" . $postdata;
            $content = @file_get_contents($url, false, $context);
        }
        
        // Write Log Connect
        if(empty($content)) {
            $connect_status = 0;
        } else {
            $connect_status = 1;
        }
        $time_now = time();
        
        if(file_exists($file_logconnect)) {
            $data = "<vweb>$connect_status<vweb>$time_now<vweb>";
            $fp = fopen($file_logconnect, "w");  
        	fputs ($fp, $data);
        	fclose($fp);
        } else {
            $error = "Lỗi : Không tồn tại File : $file_logconnect";
        }
        // Write Log Connect _End
        
        setcookie("vweb_loaddata", time(), time()+24*60*60);
    }
    
	return $content;
}

function danhhieu_load($filename)
{
	if(is_file($filename)) {
		$fopen_host = fopen($filename, "r");
		
		while (!feof($fopen_host)) {
			$get_danhhieu = fgets($fopen_host,200);
			$get_danhhieu = preg_replace('(\n)', '', $get_danhhieu);
			if($get_danhhieu) {
				$danhhieu_info = explode('<VWebMU>', $get_danhhieu);
				/*
				$id=$danhhieu_info[0];
				switch ($danhhieu_info[2]){
					case 'RankTitle3':
					$group = 0;
					break;
					case 'RankTitle2':
					$group = 1;
					break;
					case 'RankTitle1':
					$group = 2;
					break;
					default: $group = 00;
				}
				$Info_DanhHieu=GetInfoDanhHieu($group,$id);
				*/
				$danhhieu_read[] = array (
					'danhhieu_id'	=> $danhhieu_info[0],
					'danhhieu_name'	=> $danhhieu_info[1],
					'danhhieu_data'	=> $danhhieu_info[2],
					'danhhieu_reset'	=> $danhhieu_info[3],
					'danhhieu_relife'	=> $danhhieu_info[4],
					'danhhieu_napthe'	=> $danhhieu_info[5],
					'danhhieu_gia'	=> $danhhieu_info[6],
					'danhhieu_thue1'	=> $danhhieu_info[7],
					'danhhieu_thue7'	=> $danhhieu_info[8],
					'danhhieu_thue30'	=> $danhhieu_info[9],
					
					'ZEN' => $danhhieu_info[10],
					'GST' => $danhhieu_info[11],
					'PST' => $danhhieu_info[12],
					'RATE' => $danhhieu_info[13],
					'HP' => $danhhieu_info[14],
					'MN' => $danhhieu_info[15],
					'X2DAME' => $danhhieu_info[16],
					'DAME' => $danhhieu_info[17]
				);
			}
		}
	} else $fopen_host = fopen($filename, "w");
	fclose($fopen_host);
	return $danhhieu_read;
}

/*
function GetInfoDanhHieu($group,$id){
	$ListDanhHieu=file("./includes/RankTitleOption.dat");
	
	for($i=0;$i<count($ListDanhHieu);$i++){
		$ListDanhHieu[$i] = trim($ListDanhHieu[$i]);
		if(strlen($ListDanhHieu[$i])<=2 && strlen($ListDanhHieu[$i])>=1 && !strstr($ListDanhHieu[$i],'//')){
			if((int)$ListDanhHieu[$i]==$group){
				for($x=$i+1;;$x++){
					$ListDanhHieu[$x] = trim($ListDanhHieu[$x]);
					if(!strstr($ListDanhHieu[$x],'//')){
						if(strstr($ListDanhHieu[$x],'end') && strlen($ListDanhHieu[$x])==3) break;
						else{
							if((int)$ListDanhHieu[$x]==$id){
								$Columns=SplitIntoColumns($ListDanhHieu[$x]);
								$out=array(
									'ZEN' => $Columns[1],
									'GST' => $Columns[2],
									'PST' => $Columns[3],
									'RATE' => $Columns[4],
									'HP' => $Columns[5],
									'MN' => $Columns[6],
									'X2Dame' => $Columns[7],
									'DAME' => $Columns[8]
								);
								break;
							}
						}
					}
				}
			}
		}
	}
	return $out;
}
*/

function xl_xoso($string)
{
	$string=str_replace('<br>','-',$string);
	$string=str_replace(' ','',$string);
	$string=trim($string);
	
	$ketqua=explode("&nbsp;",$string);
	
	$u=0;
	for($i=0;$i<count($ketqua);$i++)
	{
		if($ketqua[$i]!='')
		{
			$return[$u]=$ketqua[$i];
			$u++;
		}
	}
	
	$return=implode("-",$return);
	
	return $return;
}

function xuly_ketqua_loxien($conso1,$conso2,$conso3,$conso4,$loop,$loop2,$array_ketqua)
{
	$socuoc[0]=$conso1;
	$socuoc[1]=$conso2;
	$socuoc[2]=$conso3;
	$socuoc[3]=$conso4;

	$result=0;
	for($a=0;$a<$loop2;$a++)
	{
		for($i=0;$i<$loop;$i++)
		{
			$vitri=array_search($socuoc[$i],$array_ketqua);
			if(strlen($vitri)>0)
			{
				unset($array_ketqua[$vitri]);
				$array_ketqua = array_values($array_ketqua);
				$result++;
			}	
		}
	}
	return $result;
}

function kiemtra_dodai($value,$info,$length_start,$length_end) 
{
	include("config.php");
	global $ContentUpdate;
	if (strlen($value)<$length_start || strlen($value)>$length_end)
	{
		echo "$info phải có độ dài từ $length_start tới $length_end kí tự.";
		exit();
	}
}
function kiemtra_null($value,$info) 
{
	include("config.php");
	global $ContentUpdate;
	if (!isset($value) OR $value=="" OR strlen($value)==0)
	{
		echo "$info không được để trống. ";
		exit();
	}
}
function kiemtra_so($value,$info)
{
	include("config.php");
	global $ContentUpdate;
	if (!preg_match("/^[0-9]*$/i", $value))
	{
		echo "$info chỉ được dùng ký tự số 0-9.";
		exit();
	}
}
function kiemtra_chu_so($value,$info)
{
	include("config.php");
	global $ContentUpdate;
	kiemtra_null($value,$info);
	if (!preg_match("/^[a-zA-Z0-9]*$/i", $value))
	{
		echo  "$info chỉ được dùng ký tự a-z,0-9.";
		exit();
	}
}
function kiemtra_chu_so_($value,$info) {
	include("config.php");
	global $ContentUpdate;
	if (!preg_match("/^[a-zA-Z0-9]*$/i", $value)){
    	echo  "$info chỉ được dùng ký tự a-z,0-9,_";
    	exit();
	}
}
function kiemtra_chu_so_dot($value,$info) {
	include("config.php");
	global $ContentUpdate;
	if (!preg_match("/^[a-zA-Z0-9]*$/i", $value)){
    	echo  "$info chỉ được dùng ký tự a-z,0-9,.";
    	exit();
	}
}
function WriteLog_($data,$file){
	$timestamp = time();
	$Date = date("h:iA, d/m/Y", $timestamp);
	if(!strstr($file,'..')) $file="./Logs/$file";
	
	$file = $file.'.html';
	
	if(!is_file($file)){
		$fp = fopen($file, "a+");
		fputs ($fp, "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n");
		fclose($fp);
	}
	$fp = fopen($file, "a+");  
	fputs ($fp, "<font color=blue>(Lúc: $Date)</font> $data<br><br>\n");  
	fclose($fp);
}

function ItemInfo($itemdata_arr, $string) {
	if ($string == 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' || $string == 'ffffffffffffffffffffffffffffffff') {
		$output = '';
		return $output;
	}
    $item_code = $string;
	// Phân tich Mã Item 32 số
	$id 			= hexdec(substr($string,0,2)); 	// Item ID
	$group 			= hexdec(substr($string,18,1)); 	// Item Type
	$option 		= hexdec(substr($string,2,2)); 	// Item Level/Skill/Option Data
	$durability		= hexdec(substr($string,4,2)); 	// Item Durability
        $dur = $durability;
	$serial			= substr($string,6,8);		// Item SKey
	$exc_option 	= hexdec(substr($string,14,2)); 	// Item Excellent Info/ Option
	$ancient		= hexdec(substr($string,16,2)); 	// Ancient data
	$harmony		= hexdec(substr($string,20,2));
	$socket_slot[1]	= hexdec(substr($string,22,2)); 	// Socket data
	$socket_slot[2]	= hexdec(substr($string,24,2)); 	// Socket data
	$socket_slot[3]	= hexdec(substr($string,26,2)); 	// Socket data
	$socket_slot[4]	= hexdec(substr($string,28,2)); 	// Socket data
	$socket_slot[5]	= hexdec(substr($string,30,2)); 	// Socket data
	// Điều chỉnh Item Thần
	if ($ancient == 4) $ancient = 5;
	if ($ancient == 9) $ancient = 10;
	// Kiểm tra Item có tuyệt chiêu
	if ($option < 128) $skill	= '';
	else {
		$skill	= '<font color=#8CB0EA>Vũ khí có tuyệt chiêu</font><br>';
		$option	= $option-128;
	}
	// Kiểm tra Cấp độ Item
	$item__level	= floor($option/8);
    $item_level = $item__level;
	$option		= $option-$item_level*8;
	// Kiểm tra Item luck
	if($option<4) $luck	= ''; 
	else {
		$luck	= '<font color=#8CB0EA>May Mắn (Tỉ lệ ép Ngọc Tâm Linh + 25%)<br>May Mắn (Sát thương tối đa + 5%)</font><br>';
		$option	= $option-4;
	}
	// Kiểm tra Excellent Option
    $exc_total = 0;
	if($exc_option >= 64)	{ $option += 4; $exc_option += -64; }
	if($exc_option < 32)	{ $iopx6=0; } else { $iopx6=1; $exc_option += -32; ++$exc_total;}
	if($exc_option < 16)	{ $iopx5=0; } else { $iopx5=1; $exc_option += -16; ++$exc_total;}
	if($exc_option < 8)	{ $iopx4=0; } else { $iopx4=1; $exc_option += -8; ++$exc_total;}
	if($exc_option < 4)	{ $iopx3=0; } else { $iopx3=1; $exc_option += -4; ++$exc_total;}
	if($exc_option < 2)	{ $iopx2=0; } else { $iopx2=1; $exc_option += -2; ++$exc_total;}
	if($exc_option < 1)	{ $iopx1=0; } else { $iopx1=1; $exc_option += -1; ++$exc_total;}
	
    $item_type = 99;
	if ($group < 6) $item_type = 0;
	else if ($group == 6) $item_type = 1;
	else if ($group < 12) $item_type = 2;
    else if ($group == 12 && in_array($id, array(36, 37, 38, 39, 40, 43, 50))) $item_type = 7;
    else if ($group == 12 && in_array($id, array(240, 241, 242, 243, 244, 245))) $item_type = 9;
    else if ($group == 12 && in_array($id, array(246, 247, 248, 249))) $item_type = 8;
	else if (($group == 12 && in_array($id, array(3,4,5,6,42,49))) || ($group == 13 && in_array($id, array(30)))) $item_type = 3;
	else if ($group == 13 && in_array($id, array(8, 9, 21, 22, 23, 24, 39, 40, 41)) ) $item_type = 4;
	else if ($group == 13 && in_array($id, array(12, 13, 25, 26, 27, 28)) ) $item_type = 5;
	else if ($group == 13 && $id == 37) $item_type = 6;
    
	$item_exc = '';
	switch ($item_type) {
	case 0 :
		$op1	= 'Tăng lượng MANA khi giết quái (MANA/8)';
		$op2	= 'Tăng lượng LIFE khi giết quái (LIFE/8)';
		$op3	= 'Tốc độ tấn công +7';
		$op4	= 'Tăng lực tấn công 2%';
		$op5	= 'Tăng lực tấn công (Cấp độ/20)';
		$op6	= 'Khả năng xuất hiện lực tấn công hoàn hảo +10%';
		$option_type = 'Tăng thêm sát thương'; $option_bonus = $option*4;
		break;
	case 1:
		$op1	= 'Lượng ZEN rơi ra khi giết quái +40%';
		$op2	= 'Khả năng xuất hiện phòng thủ hoàn hảo +10%';
		$op3	= 'Phản hồi sát thương +5%';
		$op4	= 'Giảm sát thương +4%';
		$op5	= 'Lượng MANA tối đa +4%';
		$op6	= 'Lượng HP tối đa +4%';
		$option_type = 'Tăng thêm phòng thủ'; $option_bonus = $option*5;
		break;
	case 2:
		$op1	= 'Lượng ZEN rơi ra khi giết quái +40%';
		$op2	= 'Khả năng xuất hiện phòng thủ hoàn hảo +10%';
		$op3	= 'Phản hồi sát thương +5%';
		$op4	= 'Giảm sát thương +4%';
		$op5	= 'Lượng MANA tối đa +4%';
		$op6	= 'Lượng HP tối đa +4%';
		$option_type = 'Tăng thêm phòng thủ'; $option_bonus = $option*4;
		$skill	= '';
		break;
	case 3: 
		$op1	= '+ 115 Lượng HP tối đa';
		$op2	= '+ 115 Lượng MP tối đa';
		$op3	= 'Khả năng loại bỏ phòng thủ đối phương +3%';
		$op4	= '+ 50 Lực hành động tối đa';
		$op5	= 'Tốc độ tấn công +7';
		$op6	= '';
		$option_type = 'Tự động hồi phục HP'; $option_bonus = $option.'%';
		$skill	= '';
		$nocolor= true;
        if($iopx6 == 1) --$exc_total;
		break;
	case 4:
		$op1	= 'Lượng ZEN rơi ra khi giết quái +40%';
		$op2	= 'Khả năng xuất hiện phòng thủ hoàn hảo +10%';
		$op3	= 'Phản hồi sát thương +5%';
		$op4	= 'Giảm sát thương +4%';
		$op5	= 'Lượng MANA tối đa 4%';
		$op6	= 'Lượng HP tối đa 4%';
		$option_type = 'Tự động hồi phục HP'; $option_bonus = $option.'%';
		$skill	= '';
		break;
	case 5:
		$op1	= 'Tăng lượng MANA khi giết quái (MANA/8)';
		$op2	= 'Tăng lượng LIFE khi giết quái (LIFE/8)';
		$op3	= 'Tốc độ tấn công +7';
		$op4	= 'Tăng lực tấn công 2%';
		$op5	= 'Tăng lực tấn công (Cấp độ/20)';
		$op6	= 'Khả năng xuất hiện lực tấn công hoàn hảo +10%';
		$option_type = 'Tự động hồi phục HP'; $option_bonus = $option.'%';
		$skill	= '';
		break;
	case 6:
		$op1	= 'Gia tăng mức phá hủy +10%<br>Tăng tốc độ di chuyển';
		$op2	= 'Gia tăng mức phòng thủ +10%<br>Tăng tốc độ di chuyển';
		$op3	= 'Tăng tốc độ di chuyển';
		$op4	= '';
		$op5	= '';
		$op6	= '';
		$option_type = ''; $option_bonus = '';
		$skill	= 'Tuyệt chiêu Bão Điện (MANA:50)';
        if($iopx4 == 1) --$exc_total;
        if($iopx5 == 1) --$exc_total;
        if($iopx6 == 1) --$exc_total;
		break;
    case 7:
		$op1	= '5% cơ hội loại bỏ sức phòng thủ';
		$op2	= '5 % phản đòn khi cận chiến';
		$op3	= '5% khả năng hồi phục hoàn toàn HP';
		$op4	= '5% khả năng hồi phục hoàn toàn nội lực';
		$op5	= '';
		$op6	= '';
		$option_type = 'Tự động hồi phục HP'; $option_bonus = $option.'%';
		$skill	= '';
		$nocolor= true;
        if($iopx5 == 1) --$exc_total;
        if($iopx6 == 1) --$exc_total;
		break;
    case 8:
		$op1	= '3% cơ hội loại bỏ sức phòng thủ';
		$op2	= '3 % phản đòn khi cận chiến';
		$op3	= '3% khả năng hồi phục hoàn toàn HP';
		$op4	= '3% khả năng hồi phục hoàn toàn nội lực';
		$op5	= '';
		$op6	= '';
		$option_type = 'Tự động hồi phục HP'; $option_bonus = $option.'%';
		$skill	= '';
		$nocolor= true;
        if($iopx5 == 1) --$exc_total;
        if($iopx6 == 1) --$exc_total;
		break;
    case 9:
		$op1	= '7% cơ hội loại bỏ sức phòng thủ';
		$op2	= '7 % phản đòn khi cận chiến';
		$op3	= '7% khả năng hồi phục hoàn toàn HP';
		$op4	= '7% khả năng hồi phục hoàn toàn nội lực';
		$op5	= '';
		$op6	= '';
		$option_type = 'Tự động hồi phục HP'; $option_bonus = $option.'%';
		$skill	= '';
		$nocolor= true;
        if($iopx5 == 1) --$exc_total;
        if($iopx6 == 1) --$exc_total;
		break;
	default:
		$op1	= '';
		$op2	= '';
		$op3	= '';
		$op4	= '';
		$op5	= '';
		$op6	= '';
		$option_type = ''; $option_bonus = '';
		$skill	= '';
		$nocolor= true;
	}
	if ($option_bonus != 0) $item_option = '<font color=#9AADD5>'.$option_type.' +'.$option_bonus.'</font><br>'; else $item_option = '';
	if ($iopx1 == 1) 		$item_exc .= '<br>'.$op1;
	if ($iopx2 == 1) 		$item_exc .= '<br>'.$op2;
	if ($iopx3 == 1) 		$item_exc .= '<br>'.$op3;
	if ($iopx4 == 1) 		$item_exc .= '<br>'.$op4;
	if ($iopx5 == 1) 		$item_exc .= '<br>'.$op5;
	if ($iopx6 == 1) 		$item_exc .= '<br>'.$op6;
	
	//Kiểm tra Socket Item
	$item_socket = '';
	for ($slot=1;$slot<6;$slot++) {
		$socket_slot[$slot]=$socket_slot[$slot]+1;
		if ($socket_slot[$slot] == 0) $socket[$slot] = 0;
		else if ($socket_slot[$slot] == 255) {$socket_type[$slot] = '(Chưa khảm dòng socket)'; $socket[$slot] = 1;}
		else {
			switch ($socket_slot[$slot]) {
				case 1: $socket_type[$slot] = 'Fire (Level type)Attack/Wizardry Increase + lvl/20'; $socket[$slot] = 1; break;
				case 2: $socket_type[$slot] = 'Fire (Attack speed Increase) + 7'; $socket[$slot] = 1; break;
				case 3: $socket_type[$slot] = 'Fire (Maximum Attack/Wizardry Increase) + 30'; $socket[$slot] = 1; break;
				case 4: $socket_type[$slot] = 'Fire (Minimum Attack/Wizardry Increase) + 20'; $socket[$slot] = 1; break;
				case 5: $socket_type[$slot] = 'Fire (Attack/Wizardry Increase) + 20'; $socket[$slot] = 1; break;
				case 6: $socket_type[$slot] = 'Fire (AG cost decrease) + 40%'; $socket[$slot] = 1; break;
				case 11: $socket_type[$slot] = 'Water (Block rating Increase) + 10%'; $socket[$slot] = 1; break;
				case 12: $socket_type[$slot] = 'Water (Increase Defense) + 30'; $socket[$slot] = 1; break;
				case 13: $socket_type[$slot] = 'Water (Shield protection Increase) + 7%'; $socket[$slot] = 1; break;
				case 14: $socket_type[$slot] = 'Water (Damage Reduction) + 4%'; $socket[$slot] = 1; break;
				case 15: $socket_type[$slot] = 'Water (Damage Reflections) + 5%'; $socket[$slot] = 1; break;
				case 17: $socket_type[$slot] = 'Ice (Monster destruction for the Life Increase) + hp/8'; $socket[$slot] = 1; break;
				case 18: $socket_type[$slot] = 'Ice (Monster destruction for the Mana Increase) + mp/8'; $socket[$slot] = 1; break;
				case 19: $socket_type[$slot] = 'Ice (Skill Attack Increase) + 37'; $socket[$slot] = 1; break;
				case 20: $socket_type[$slot] = 'Ice (Attack rating Increase) + 25'; $socket[$slot] = 1; break;
				case 21: $socket_type[$slot] = 'Ice (Item durability Increase) + 30%'; $socket[$slot] = 1; break;
				case 22: $socket_type[$slot] = 'Wind (Automatic Life recovery Increase) + 8'; $socket[$slot] = 1; break;
				case 23: $socket_type[$slot] = 'Wind (Increase Maximum Life) + 4%'; $socket[$slot] = 1; break;
				case 24: $socket_type[$slot] = 'Wind (Increase Maximum Mana) + 4%'; $socket[$slot] = 1; break;
				case 25: $socket_type[$slot] = 'Wind (Increase Mana AutoRecovery) + 7'; $socket[$slot] = 1; break;
				case 26: $socket_type[$slot] = 'Wind (Increase Maximum AG) + 50'; $socket[$slot] = 1; break;
				case 27: $socket_type[$slot] = 'Wind (AG value Increase) + 5'; $socket[$slot] = 1; break;
				case 30: $socket_type[$slot] = 'Lightning (Increase Excellent Damage) + 15'; $socket[$slot] = 1; break;
				case 31: $socket_type[$slot] = 'Lightning (Increase Excellent Damage Success Rate) + 10%'; $socket[$slot] = 1; break;
				case 32: $socket_type[$slot] = 'Lightning (Increase Critical Damage) + 30'; $socket[$slot] = 1; break;
				case 33: $socket_type[$slot] = 'Lightning (Increase Critical Damage Success Rate) + 8%'; $socket[$slot] = 1; break;
				case 37: $socket_type[$slot] = 'Earth (Health Increase) + 30'; $socket[$slot] = 1; break;
				case 51: $socket_type[$slot] = 'Fire (Level type)Attack/Wizardry Increase + lvl/19'; $socket[$slot] = 1; break;
				case 52: $socket_type[$slot] = 'Fire (Attack speed Increase) + 8'; $socket[$slot] = 1; break;
				case 53: $socket_type[$slot] = 'Fire (Maximum Attack/Wizardry Increase) + 32'; $socket[$slot] = 1; break;
				case 54: $socket_type[$slot] = 'Fire (Minimum Attack/Wizardry Increase) + 22'; $socket[$slot] = 1; break;
				case 55: $socket_type[$slot] = 'Fire (Attack/Wizardry Increase) + 22'; $socket[$slot] = 1; break;
				case 56: $socket_type[$slot] = 'Fire (AG cost decrease) + 41%'; $socket[$slot] = 1; break;
				case 61: $socket_type[$slot] = 'Water (Block rating Increase) + 11%'; $socket[$slot] = 1; break;
				case 62: $socket_type[$slot] = 'Water (Increase Defense) + 33'; $socket[$slot] = 1; break;
				case 63: $socket_type[$slot] = 'Water (Shield protection Increase) + 10%'; $socket[$slot] = 1; break;
				case 64: $socket_type[$slot] = 'Water (Damage Reduction) + 5%'; $socket[$slot] = 1; break;
				case 65: $socket_type[$slot] = 'Water (Damage Reflections) + 6%'; $socket[$slot] = 1; break;
				case 67: $socket_type[$slot] = 'Ice (Monster destruction for the Life Increase) + hp/7'; $socket[$slot] = 1; break;
				case 68: $socket_type[$slot] = 'Ice (Monster destruction for the Mana Increase) + mp/7'; $socket[$slot] = 1; break;
				case 69: $socket_type[$slot] = 'Ice (Skill Attack Increase) + 45'; $socket[$slot] = 1; break;
				case 70: $socket_type[$slot] = 'Ice (Attack rating Increase) + 27'; $socket[$slot] = 1; break;
				case 71: $socket_type[$slot] = 'Ice (Item durability Increase) + 32%'; $socket[$slot] = 1; break;
				case 72: $socket_type[$slot] = 'Wind (Automatic Life recovery Increase) + 10'; $socket[$slot] = 1; break;
				case 73: $socket_type[$slot] = 'Wind (Increase Maximum Life) + 5%'; $socket[$slot] = 1; break;
				case 74: $socket_type[$slot] = 'Wind (Increase Maximum Mana) + 5%'; $socket[$slot] = 1; break;
				case 75: $socket_type[$slot] = 'Wind (Increase Mana AutoRecovery) + 14'; $socket[$slot] = 1; break;
				case 76: $socket_type[$slot] = 'Wind (Increase Maximum AG) + 70'; $socket[$slot] = 1; break;
				case 77: $socket_type[$slot] = 'Wind (AG value Increase) + 7'; $socket[$slot] = 1; break;
				case 80: $socket_type[$slot] = 'Lightning (Increase Excellent Damage) + 20'; $socket[$slot] = 1; break;
				case 81: $socket_type[$slot] = 'Lightning (Increase Excellent Damage Success Rate) + 11%'; $socket[$slot] = 1; break;
				case 82: $socket_type[$slot] = 'Lightning (Increase Critical Damage) + 32'; $socket[$slot] = 1; break;
				case 83: $socket_type[$slot] = 'Lightning (Increase Critical Damage Success Rate) + 9%'; $socket[$slot] = 1; break;
				case 87: $socket_type[$slot] = 'Earth (Health Increase) + 32'; $socket[$slot] = 1; break;
				case 101: $socket_type[$slot] = 'Fire (Level type)Attack/Wizardry Increase + lvl/18'; $socket[$slot] = 1; break;
				case 102: $socket_type[$slot] = 'Fire (Attack speed Increase) + 9'; $socket[$slot] = 1; break;
				case 103: $socket_type[$slot] = 'Fire (Maximum Attack/Wizardry Increase) + 35'; $socket[$slot] = 1; break;
				case 104: $socket_type[$slot] = 'Fire (Minimum Attack/Wizardry Increase) + 25'; $socket[$slot] = 1; break;
				case 105: $socket_type[$slot] = 'Fire (Attack/Wizardry Increase) + 25'; $socket[$slot] = 1; break;
				case 106: $socket_type[$slot] = 'Fire (AG cost decrease) + 41%'; $socket[$slot] = 1; break;
				case 111: $socket_type[$slot] = 'Water (Block rating Increase) + 12%'; $socket[$slot] = 1; break;
				case 112: $socket_type[$slot] = 'Water (Increase Defense) + 36'; $socket[$slot] = 1; break;
				case 113: $socket_type[$slot] = 'Water (Shield protection Increase) + 15%'; $socket[$slot] = 1; break;
				case 114: $socket_type[$slot] = 'Water (Damage Reduction) + 6%'; $socket[$slot] = 1; break;
				case 115: $socket_type[$slot] = 'Water (Damage Reflections) + 7%'; $socket[$slot] = 1; break;
				case 117: $socket_type[$slot] = 'Ice (Monster destruction for the Life Increase) + hp/6'; $socket[$slot] = 1; break;
				case 118: $socket_type[$slot] = 'Ice (Monster destruction for the Mana Increase) + mp/6'; $socket[$slot] = 1; break;
				case 119: $socket_type[$slot] = 'Ice (Skill Attack Increase) + 50'; $socket[$slot] = 1; break;
				case 120: $socket_type[$slot] = 'Ice (Attack rating Increase) + 30'; $socket[$slot] = 1; break;
				case 121: $socket_type[$slot] = 'Ice (Item durability Increase) + 34%'; $socket[$slot] = 1; break;
				case 122: $socket_type[$slot] = 'Wind (Automatic Life recovery Increase) + 13'; $socket[$slot] = 1; break;
				case 123: $socket_type[$slot] = 'Wind (Increase Maximum Life) + 6%'; $socket[$slot] = 1; break;
				case 124: $socket_type[$slot] = 'Wind (Increase Maximum Mana) + 6%'; $socket[$slot] = 1; break;
				case 125: $socket_type[$slot] = 'Wind (Increase Mana AutoRecovery) + 21'; $socket[$slot] = 1; break;
				case 126: $socket_type[$slot] = 'Wind (Increase Maximum AG) + 90'; $socket[$slot] = 1; break;
				case 127: $socket_type[$slot] = 'Wind (AG value Increase) + 9'; $socket[$slot] = 1; break;
				case 130: $socket_type[$slot] = 'Lightning (Increase Excellent Damage) + 25'; $socket[$slot] = 1; break;
				case 131: $socket_type[$slot] = 'Lightning (Increase Excellent Damage Success Rate) + 12%'; $socket[$slot] = 1; break;
				case 132: $socket_type[$slot] = 'Lightning (Increase Critical Damage) + 35'; $socket[$slot] = 1; break;
				case 133: $socket_type[$slot] = 'Lightning (Increase Critical Damage Success Rate) + 10%'; $socket[$slot] = 1; break;
				case 137: $socket_type[$slot] = 'Earth (Health Increase) + 34'; $socket[$slot] = 1; break;
				case 151: $socket_type[$slot] = 'Fire (Level type)Attack/Wizardry Increase + lvl/17'; $socket[$slot] = 1; break;
				case 152: $socket_type[$slot] = 'Fire (Attack speed Increase) + 10'; $socket[$slot] = 1; break;
				case 153: $socket_type[$slot] = 'Fire (Maximum Attack/Wizardry Increase) + 40'; $socket[$slot] = 1; break;
				case 154: $socket_type[$slot] = 'Fire (Minimum Attack/Wizardry Increase) + 30'; $socket[$slot] = 1; break;
				case 155: $socket_type[$slot] = 'Fire (Attack/Wizardry Increase) + 30'; $socket[$slot] = 1; break;
				case 156: $socket_type[$slot] = 'Fire (AG cost decrease) + 43%'; $socket[$slot] = 1; break;
				case 161: $socket_type[$slot] = 'Water (Block rating Increase) + 13%'; $socket[$slot] = 1; break;
				case 162: $socket_type[$slot] = 'Water (Increase Defense) + 39'; $socket[$slot] = 1; break;
				case 163: $socket_type[$slot] = 'Water (Shield protection Increase) + 20%'; $socket[$slot] = 1; break;
				case 164: $socket_type[$slot] = 'Water (Damage Reduction) + 7%'; $socket[$slot] = 1; break;
				case 165: $socket_type[$slot] = 'Water (Damage Reflections) + 8%'; $socket[$slot] = 1; break;
				case 167: $socket_type[$slot] = 'Ice (Monster destruction for the Life Increase) + hp/5'; $socket[$slot] = 1; break;
				case 168: $socket_type[$slot] = 'Ice (Monster destruction for the Mana Increase) + mp/5'; $socket[$slot] = 1; break;
				case 169: $socket_type[$slot] = 'Ice (Skill Attack Increase) + 60'; $socket[$slot] = 1; break;
				case 170: $socket_type[$slot] = 'Ice (Attack rating Increase) + 35'; $socket[$slot] = 1; break;
				case 171: $socket_type[$slot] = 'Ice (Item durability Increase) + 36%'; $socket[$slot] = 1; break;
				case 172: $socket_type[$slot] = 'Wind (Automatic Life recovery Increase) + 16'; $socket[$slot] = 1; break;
				case 173: $socket_type[$slot] = 'Wind (Increase Maximum Life) + 7%'; $socket[$slot] = 1; break;
				case 174: $socket_type[$slot] = 'Wind (Increase Maximum Mana) + 7%'; $socket[$slot] = 1; break;
				case 175: $socket_type[$slot] = 'Wind (Increase Mana AutoRecovery) + 28'; $socket[$slot] = 1; break;
				case 176: $socket_type[$slot] = 'Wind (Increase Maximum AG) + 110'; $socket[$slot] = 1; break;
				case 177: $socket_type[$slot] = 'Wind (AG value Increase) + 11'; $socket[$slot] = 1; break;
				case 180: $socket_type[$slot] = 'Lightning (Increase Excellent Damage) + 30'; $socket[$slot] = 1; break;
				case 181: $socket_type[$slot] = 'Lightning (Increase Excellent Damage Success Rate) + 13%'; $socket[$slot] = 1; break;
				case 182: $socket_type[$slot] = 'Lightning (Increase Critical Damage) + 40'; $socket[$slot] = 1; break;
				case 183: $socket_type[$slot] = 'Lightning (Increase Critical Damage Success Rate) + 11%'; $socket[$slot] = 1; break;
				case 187: $socket_type[$slot] = 'Earth (Health Increase) + 36'; $socket[$slot] = 1; break;
				case 201: $socket_type[$slot] = 'Fire (Level type)Attack/Wizardry Increase + lvl/14'; $socket[$slot] = 1; break;
				case 202: $socket_type[$slot] = 'Fire (Attack speed Increase) + 11'; $socket[$slot] = 1; break;
				case 203: $socket_type[$slot] = 'Fire (Maximum Attack/Wizardry Increase) + 50'; $socket[$slot] = 1; break;
				case 204: $socket_type[$slot] = 'Fire (Minimum Attack/Wizardry Increase) + 35'; $socket[$slot] = 1; break;
				case 205: $socket_type[$slot] = 'Fire (Attack/Wizardry Increase) + 35'; $socket[$slot] = 1; break;
				case 206: $socket_type[$slot] = 'Fire (AG cost decrease) + 44%'; $socket[$slot] = 1; break;
				case 211: $socket_type[$slot] = 'Water (Block rating Increase) + 14%'; $socket[$slot] = 1; break;
				case 212: $socket_type[$slot] = 'Water (Increase Defense) + 42'; $socket[$slot] = 1; break;
				case 213: $socket_type[$slot] = 'Water (Shield protection Increase) + 30%'; $socket[$slot] = 1; break;
				case 214: $socket_type[$slot] = 'Water (Damage Reduction) + 8%'; $socket[$slot] = 1; break;
				case 215: $socket_type[$slot] = 'Water (Damage Reflections) + 9%'; $socket[$slot] = 1; break;
				case 217: $socket_type[$slot] = 'Ice (Monster destruction for the Life Increase) + hp/4'; $socket[$slot] = 1; break;
				case 218: $socket_type[$slot] = 'Ice (Monster destruction for the Mana Increase) + mp/4'; $socket[$slot] = 1; break;
				case 219: $socket_type[$slot] = 'Ice (Skill Attack Increase) + 70'; $socket[$slot] = 1; break;
				case 220: $socket_type[$slot] = 'Ice (Attack rating Increase) + 40'; $socket[$slot] = 1; break;
				case 221: $socket_type[$slot] = 'Ice (Item durability Increase) + 38%'; $socket[$slot] = 1; break;
				case 222: $socket_type[$slot] = 'Wind (Automatic Life recovery Increase) + 20'; $socket[$slot] = 1; break;
				case 223: $socket_type[$slot] = 'Wind (Increase Maximum Life) + 8%'; $socket[$slot] = 1; break;
				case 224: $socket_type[$slot] = 'Wind (Increase Maximum Mana) + 8%'; $socket[$slot] = 1; break;
				case 225: $socket_type[$slot] = 'Wind (Increase Mana AutoRecovery) + 35'; $socket[$slot] = 1; break;
				case 226: $socket_type[$slot] = 'Wind (Increase Maximum AG) + 130'; $socket[$slot] = 1; break;
				case 227: $socket_type[$slot] = 'Wind (AG value Increase) + 13'; $socket[$slot] = 1; break;
				case 230: $socket_type[$slot] = 'Lightning (Increase Excellent Damage) + 40'; $socket[$slot] = 1; break;
				case 231: $socket_type[$slot] = 'Lightning (Increase Excellent Damage Success Rate) + 14%'; $socket[$slot] = 1; break;
				case 232: $socket_type[$slot] = 'Lightning (Increase Critical Damage) + 50'; $socket[$slot] = 1; break;
				case 233: $socket_type[$slot] = 'Lightning (Increase Critical Damage Success Rate) + 12%'; $socket[$slot] = 1; break;
				case 237: $socket_type[$slot] = 'Earth (Health Increase) + 38'; $socket[$slot] = 1; break;
			}
		}
		if ($socket[$slot] == 1) $item_socket .= '<br>Socket '.$slot.': '.$socket_type[$slot];
	}
	$item_harmony = '';
	if ($harmony < 32) $item_harmony .= 'Lực tấn công tồi thiểu + ';
	else if ($harmony < 48) $item_harmony .= 'Lực tấn công tồi đa + ';
	else if ($harmony < 64) $item_harmony .= 'Điểm Sức mạnh yêu cầu - ';
	else if ($harmony < 80) $item_harmony .= 'Điểm nhanh nhẹn yêu cầu - ';
	else if ($harmony < 96) $item_harmony .= 'Lực tấn công (tối đa, tối thiểu) + ';
	else if ($harmony < 112) $item_harmony .= 'Sát thương trọng kích + ';
	else if ($harmony < 128) $item_harmony .= 'Lực tấn công kĩ năng + ';
	else if ($harmony < 144) $item_harmony .= 'Tỷ lệ tấn công % + ';
	else if ($harmony < 160) $item_harmony .= 'Tỷ lệ SD + ';
	else if ($harmony < 176) $item_harmony .= 'Tỷ lệ loại bỏ SD + ';
	switch ($harmony) {
		case 16: $item_harmony .= '2'; break;
		case 17: $item_harmony .= '3'; break;
		case 18: $item_harmony .= '4'; break;
		case 19: $item_harmony .= '5'; break;
		case 20: $item_harmony .= '6'; break;
		case 21: $item_harmony .= '7'; break;
		case 22: $item_harmony .= '9'; break;
		case 23: $item_harmony .= '11'; break;
		case 24: $item_harmony .= '12'; break;
		case 25: $item_harmony .= '14'; break;
		case 26: $item_harmony .= '15'; break;
		case 27: $item_harmony .= '16'; break;
		case 28: $item_harmony .= '17'; break;
		case 29: $item_harmony .= '20'; break;
		case 30: $item_harmony .= '100000'; break;
		case 31: $item_harmony .= '110000'; break;
		case 32: $item_harmony .= '3'; break;
		case 33: $item_harmony .= '4'; break;
		case 34: $item_harmony .= '5'; break;
		case 35: $item_harmony .= '6'; break;
		case 36: $item_harmony .= '7'; break;
		case 37: $item_harmony .= '8'; break;
		case 38: $item_harmony .= '10'; break;
		case 39: $item_harmony .= '12'; break;
		case 40: $item_harmony .= '14'; break;
		case 41: $item_harmony .= '17'; break;
		case 42: $item_harmony .= '20'; break;
		case 43: $item_harmony .= '23'; break;
		case 44: $item_harmony .= '26'; break;
		case 45: $item_harmony .= '29'; break;
		case 46: $item_harmony .= '100000'; break;
		case 47: $item_harmony .= '110000'; break;
		case 48: $item_harmony .= '6'; break;
		case 49: $item_harmony .= '8'; break;
		case 50: $item_harmony .= '10'; break;
		case 51: $item_harmony .= '12'; break;
		case 52: $item_harmony .= '14'; break;
		case 53: $item_harmony .= '16'; break;
		case 54: $item_harmony .= '20'; break;
		case 55: $item_harmony .= '23'; break;
		case 56: $item_harmony .= '26'; break;
		case 57: $item_harmony .= '29'; break;
		case 58: $item_harmony .= '32'; break;
		case 59: $item_harmony .= '35'; break;
		case 60: $item_harmony .= '37'; break;
		case 61: $item_harmony .= '40'; break;
		case 62: $item_harmony .= '100000'; break;
		case 63: $item_harmony .= '110000'; break;
		case 64: $item_harmony .= '6'; break;
		case 65: $item_harmony .= '8'; break;
		case 66: $item_harmony .= '10'; break;
		case 67: $item_harmony .= '12'; break;
		case 68: $item_harmony .= '14'; break;
		case 69: $item_harmony .= '16'; break;
		case 70: $item_harmony .= '20'; break;
		case 71: $item_harmony .= '23'; break;
		case 72: $item_harmony .= '26'; break;
		case 73: $item_harmony .= '29'; break;
		case 74: $item_harmony .= '32'; break;
		case 75: $item_harmony .= '35'; break;
		case 76: $item_harmony .= '37'; break;
		case 77: $item_harmony .= '40'; break;
		case 78: $item_harmony .= '100000'; break;
		case 79: $item_harmony .= '110000'; break;
		case 80: $item_harmony .= '0'; break;
		case 81: $item_harmony .= '0'; break;
		case 82: $item_harmony .= '0'; break;
		case 83: $item_harmony .= '0'; break;
		case 84: $item_harmony .= '0'; break;
		case 85: $item_harmony .= '0'; break;
		case 86: $item_harmony .= '7'; break;
		case 87: $item_harmony .= '8'; break;
		case 88: $item_harmony .= '9'; break;
		case 89: $item_harmony .= '11'; break;
		case 90: $item_harmony .= '12'; break;
		case 91: $item_harmony .= '14'; break;
		case 92: $item_harmony .= '16'; break;
		case 93: $item_harmony .= '19'; break;
		case 94: $item_harmony .= '0'; break;
		case 95: $item_harmony .= '0'; break;
		case 96: $item_harmony .= '0'; break;
		case 97: $item_harmony .= '0'; break;
		case 98: $item_harmony .= '0'; break;
		case 99: $item_harmony .= '0'; break;
		case 100: $item_harmony .= '0'; break;
		case 101: $item_harmony .= '0'; break;
		case 102: $item_harmony .= '12'; break;
		case 103: $item_harmony .= '14'; break;
		case 104: $item_harmony .= '16'; break;
		case 105: $item_harmony .= '18'; break;
		case 106: $item_harmony .= '20'; break;
		case 107: $item_harmony .= '22'; break;
		case 108: $item_harmony .= '24'; break;
		case 109: $item_harmony .= '30'; break;
		case 110: $item_harmony .= '0'; break;
		case 111: $item_harmony .= '0'; break;
		case 112: $item_harmony .= '0'; break;
		case 113: $item_harmony .= '0'; break;
		case 114: $item_harmony .= '0'; break;
		case 115: $item_harmony .= '0'; break;
		case 116: $item_harmony .= '0'; break;
		case 117: $item_harmony .= '0'; break;
		case 118: $item_harmony .= '0'; break;
		case 119: $item_harmony .= '0'; break;
		case 120: $item_harmony .= '0'; break;
		case 121: $item_harmony .= '12'; break;
		case 122: $item_harmony .= '14'; break;
		case 123: $item_harmony .= '16'; break;
		case 124: $item_harmony .= '18'; break;
		case 125: $item_harmony .= '22'; break;
		case 126: $item_harmony .= '0'; break;
		case 127: $item_harmony .= '0'; break;
		case 128: $item_harmony .= '0'; break;
		case 129: $item_harmony .= '0'; break;
		case 130: $item_harmony .= '0'; break;
		case 131: $item_harmony .= '0'; break;
		case 132: $item_harmony .= '0'; break;
		case 133: $item_harmony .= '0'; break;
		case 134: $item_harmony .= '0'; break;
		case 135: $item_harmony .= '0'; break;
		case 136: $item_harmony .= '0'; break;
		case 137: $item_harmony .= '5'; break;
		case 138: $item_harmony .= '7'; break;
		case 139: $item_harmony .= '9'; break;
		case 140: $item_harmony .= '11'; break;
		case 141: $item_harmony .= '14'; break;
		case 142: $item_harmony .= '0'; break;
		case 143: $item_harmony .= '0'; break;
		case 144: $item_harmony .= '0'; break;
		case 145: $item_harmony .= '0'; break;
		case 146: $item_harmony .= '0'; break;
		case 147: $item_harmony .= '0'; break;
		case 148: $item_harmony .= '0'; break;
		case 149: $item_harmony .= '0'; break;
		case 150: $item_harmony .= '0'; break;
		case 151: $item_harmony .= '0'; break;
		case 152: $item_harmony .= '0'; break;
		case 153: $item_harmony .= '3'; break;
		case 154: $item_harmony .= '5'; break;
		case 155: $item_harmony .= '7'; break;
		case 156: $item_harmony .= '9'; break;
		case 157: $item_harmony .= '10'; break;
		case 158: $item_harmony .= '0'; break;
		case 159: $item_harmony .= '0'; break;
		case 160: $item_harmony .= '0'; break;
		case 161: $item_harmony .= '0'; break;
		case 162: $item_harmony .= '0'; break;
		case 163: $item_harmony .= '0'; break;
		case 164: $item_harmony .= '0'; break;
		case 165: $item_harmony .= '0'; break;
		case 166: $item_harmony .= '0'; break;
		case 167: $item_harmony .= '0'; break;
		case 168: $item_harmony .= '0'; break;
		case 169: $item_harmony .= '0'; break;
		case 170: $item_harmony .= '0'; break;
		case 171: $item_harmony .= '0'; break;
		case 172: $item_harmony .= '0'; break;
		case 173: $item_harmony .= '10'; break;
		case 174: $item_harmony .= '0'; break;
		case 175: $item_harmony .= '0'; break;
	}
	$item_read = ItemsData($itemdata_arr, $id,$group,$item_level);
	// Tra ID và Group Item để lấy thông tin từ Items_Data.txt
	$item_image = $item_read['image'];
	$item_name = $item_read['name'];
    $item_name_en = $item_read['name_en'];
	$item_x = $item_read['x'];
	$item_y = $item_read['y'];
	$item_group = $item_read['groupid'];
	if ($ancient == 5) $ancient_set = $item_read['set1'];
	else if ($ancient == 10) $ancient_set = $item_read['set2'];
	//Sử lí màu Tên Item
	$color = '#FFFFFF'; // White -> Normal Item
	if (($option > 1) || ($luck != '')) $color = '#8CB0EA';
	if ($item_level > 6) $color = '#F4CB3F';
	$ExclAnci = 0;
	if ($item_type == 6) {//Sói tinh
		$color = '#8CB0EA';
		if ($iopx1 == 1) {
			$item_name .= ' + Tấn công';
			$ExclAnci = 1;
		}
		if ($iopx2 == 1) {
			$item_name .= ' + Phòng thủ';
			$ExclAnci = 1;
		}
		if ($iopx3 == 1) {
			$item_name .= ' Hoàng Kim';
			$color = '#F4CB3F';
			$ExclAnci = 1;
		}
	}
	else if ($item_exc != '') {//Item Excellent
		//Item Harmony
		if ($harmony > 0) $item_name = 'Tử Âm '.$item_name;
		$item_name = 'Hoàn Hảo '.$item_name;
		$color = '#2FF387';
		$ExclAnci = 1;
	}
	// Item Thần
	if ($ancient > 0) {
		$item_name = 'SET Thần'.' '.$ancient_set.' '.$item_name;
		$color = '#2347F3';
		$ExclAnci = 2;
	}
	// Item Socket
	if ($item_socket != '') {
		$color = '#AA1EAA';
        $is_socket = 1;
	} else $is_socket = 0;
	if ($nocolor) $color = '#F4CB3F';
	// Sử lí thông tin Item
	switch ($ExclAnci) {
		case 1:
			if (file_exists('items/EXE/'.$item_image.'.gif')) $item_image = "EXE/".$item_image;
			else $item_image = $item_image;
			break;
		case 2:
			if (file_exists('items/ANC/'.$item_image.'.gif')) $item_image = "ANC/".$item_image;
			else $item_image = $item_image;
			break;
		default: $item_image = $item_image; break;
	}
	//$item_image = ItemImage($id,$group,$ExclAnci,$item_level);
	if ($item_level == 0 || $durability == 0) $item_level = '';
	else $item_level = ' +'.$item_level;
    $_serial = $serial;
	$serial = 'Serial: '.$serial.'<br>';
	$durability = 'Độ bền: '.$durability.'<br>';
	if ($harmony > 0) $item_harmony = '<font color=#C8C800>'.$item_harmony.'</font><br>'; else $item_harmony = '';
	$item_exc = '<font color=#2FF387>'.$item_exc.'</font><br>';
	$item_socket = '<font color=#AA1EAA>'.$item_socket.'</font><br>';
	$item_info = '<center><strong><span style=color:#FFFFFF><font color='.$color.'>'.$item_name.$item_level.'</font><br>'
				.$durability
				.$luck
				.$skill
				.$item_option
				.$item_harmony
				.$item_exc
				.$item_socket.'</span></strong></center>';
	if(strlen($luck) > 0) $is_luck = 1;
    else $is_luck = 0;
    if(strlen($skill) > 0) $is_skill = 1;
    else $is_skill = 0;
    
    
    $output = array (
		'info' => $item_info,
		'name' => $item_name,
        'name_en' => $item_name_en,
		'image' => $item_image,
        'level' =>  $item__level,
        'opt'   =>  $option,
        'luck'  =>  $is_luck,           // 1: Luck, 0: Non Luck
        'skill' =>  $is_skill,
        'dur'   =>  $dur,
        'exc_total' =>  $exc_total,
        'exc_1' =>  $iopx1,
        'exc_2' =>  $iopx2,
        'exc_3' =>  $iopx3,
        'exc_4' =>  $iopx4,
        'exc_5' =>  $iopx5,
        'exc_6' =>  $iopx6,
        'serial'    =>  $_serial,
		'x' => $item_x,
		'y' => $item_y,
        'item_code'    =>  $item_code,
        'exc_anc'   =>  $ExclAnci,       // 1: Exc, 2: Anci
        'socket'    =>  $is_socket,       // 1: Socket, 0: Non Socket
        'id'    =>  $id,
        'type'  =>  $item_type,
        'group' =>  $group,
        'item_group' =>  $item_group
	);
	return $output;
}

function ItemDataArr($file_data = "Item_Data.txt") {
	$fopen_host = fopen($file_data, "r");
	$item_data = fgets($fopen_host);
    fclose($fopen_host);
    
    $item_data_arr = json_decode($item_data, true);
	
    foreach($item_data_arr as $item_v) {
        $group = $item_v[1];
        $id = $item_v[2];
        if(strlen($item_v[8]) > 0) {
            $item_name = $item_v[8];
            $item_name_en = $item_v[3];
        } else {
            $item_name = $item_v[3];
            $item_name_en = $item_v[3];
        }
        
        $item_read[$group][$id][] = array (
			'image'	=> $item_v[0],
            'group' =>  $item_v[1],
            'id'    =>  $item_v[2],
			'name'	=> $item_name,
            'name_en'	=> $item_name_en,
			'x'	=> $item_v[4],
			'y'	=> $item_v[5],
			'set1'	=> $item_v[6],
			'set2'	=> $item_v[7],
            'groupid'  =>  $item_v[9]
		);
    }
    
    return $item_read;
}

function ItemsData($itemdata_arr, $id,$group,$item_level=0) {
	
	if (!isset($itemdata_arr[$group][$id][$item_level])) {
		return $itemdata_arr[$group][$id][0];
	}
	else return $itemdata_arr[$group][$id][$item_level];
}


function shop_load($filename)
{
	$slg_item = 0;
	if(is_file($filename)) {
		$fopen_host = fopen($filename, "r");
		
		while (!feof($fopen_host)) {
			$get_item = fgets($fopen_host,200);
			$get_item = preg_replace('(\n)', '', $get_item);
			if($get_item) {
				$item_info = explode('<VWebMU>', $get_item);
				$itemdata_arr = ItemDataArr();
				$info = ItemInfo($itemdata_arr, $item_info[0]);
				$itemname = $info['name'];
				$itemlevel = $info['level'];
				if($itemlevel==0){$itemlevel="";}
				else{$itemlevel="+".$itemlevel;}
				$iteminfo = $itemname." ".$itemlevel;
				$item_read[] = array (
					'code'	=> $item_info[0],
					'name'	=> $iteminfo
				);
				++$slg_item;
			}
		}
	} else $fopen_host = fopen($filename, "w");
	fclose($fopen_host);
	return $item_read;
}

function shop_load_new($filename)
{
	$stt = 0;
	if(is_file($filename)) {
		$fopen_host = fopen($filename, "r");
		
		while (!feof($fopen_host)) {
			$get_item = fgets($fopen_host,200);
			$get_item = trim($get_item);
			if($get_item) {
				$item_info = explode('<vwebmu>', $get_item);

				$img=check_code($item_info[0],2);

				$item_read[] = array (
					'stt'	=> $stt,
					'price'	=> $item_info[1],
					'name_custom'	=> $item_info[2],
					'img'	=> $img[image],
					'name'	=> $img[name],
					'x'	=> $img[x],
					'y'	=> $img[y],
					'info'	=> $img[info]
				);
				$stt++;
			}
		}
	} else $fopen_host = fopen($filename, "w");
	fclose($fopen_host);
	return $item_read;
}

function shopset_load($filename)
{
	$stt = 0;
	if(is_file($filename)) {
		$fopen_host = fopen($filename, "r");
		
		while (!feof($fopen_host)) {
			$get_item = fgets($fopen_host,200);
			$get_item = trim($get_item);
			if($get_item) {
				$item_info = explode('<vwebmu>', $get_item);
				
				$img=check_code($item_info[0],2);
				
				$item_read[] = array (
					'stt'	=> $stt,
					'item_detail'	=> $item_info[1],
					'price'	=> $item_info[2],
					'img'	=> $item_info[3],
					'item_info'	=> $img[info]
				);
				$stt++;
			}
		}
	} else $fopen_host = fopen($filename, "w");
	fclose($fopen_host);
	return $item_read;
}
function GetTextByText($text,$ReadHtml)
{
	if (strpos($ReadHtml,$text))
	{
		$i=0;
		$pos=strpos($ReadHtml,$text)+strlen($text);
		while (substr($ReadHtml,$pos+$i,1) != ">")
		{
			$i++;
		}
		$pos=$pos+$i+1;
		$result="";
		$i=0;
		if($text=='Response'){
			$match="</$text";
			$lentext=strlen($text)+2;
		}else{
			$match="</";
			$lentext=2;		
		}
		while (substr($ReadHtml,$pos+$i,$lentext) != $match)
		{
			$result.=substr($ReadHtml,$pos+$i,1);
			$i++;
		}
		return $result;
	}
}
function ListItemVongQuay_load($filename)
{
	if(is_file($filename)) {
		$fopen_host = fopen($filename, "r");
		
		while (!feof($fopen_host)) {
			$get_item = fgets($fopen_host,200);
			if($get_item) {
				$get_item = trim($get_item);
				$item_read[] = $get_item;
			}
		}
	} else $fopen_host = fopen($filename, "w");
	fclose($fopen_host);
	return $item_read;
}

/**
 * _img_resize_view()
 * 
 * @param mixed $file_img (URL File)
 * @param string $width (Img Width Max)
 * @param string $height (IMG Height Max))
 * @return array(width, height)
 */
function _img_resize_view($file_img, $width = 'auto', $height = 'auto') {
    list($x, $y, $type, $attr) = getimagesize($file_img);
    
    if( $width !='auto' && $height != 'auto' ) {
        if( ($x/$y) > ($width/$height) ) {
            $height = 'auto';
        } else {
            $width = 'auto';
        }
    }
    
    if($width == 'auto' && is_numeric($height)){
		$width =($height/$y*100)*($x/100);
	}
	if($height == 'auto' && is_numeric($width)){
		$height = ($width/$x*100)*($y/100);
	}
    
    $out = array(
        'width'     =>  $width,
        'height'    =>  $height
    );
    
    return $out;
}

function _json_fileload($filename)
{
	if(is_file($filename)) {
		$fopen_host = fopen($filename, "r");
        $file_read = fgets($fopen_host);
        
        $out_arr = json_decode($file_read, true);

	} else $fopen_host = fopen($filename, "w");
	fclose($fopen_host);
    
    if(!is_array($out_arr)) $out_arr = array();
	return $out_arr;
}

function spin_load($filename){
	$stt = 0;
	if(is_file($filename)) {
		$fopen_host = fopen($filename, "r");
		while (!feof($fopen_host)) {
			$get_item = fgets($fopen_host);
			$get_item = preg_replace('(\n)', '', $get_item);
			if($get_item) {
				$item_info = explode('|', $get_item);
				$check_stat = substr($get_item,0,2);
				if($check_stat == '//') $stat = 0;
				else $stat = 1;
				$stt++;
				$item_read[] = array (
					'stt'	=> $stt,
					'type'	=> $item_info[0],
					'code'	=> $item_info[1],
					'des'	=> $item_info[2],
					'number'	=> $item_info[3],
					'percent'	=> $item_info[4],
					'img'	=> $item_info[5],
					'name'	=> $item_info[6],
					'stat'	=> $stat
				);
			}
		}
	} 
	else $fopen_host = fopen($filename, "w");
	fclose($fopen_host);
	return $item_read;
}

function display_spinlist($item_read,$act){
	$stt = count($item_read);
	$content = "<table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#9999FF'>
		<tr bgcolor='#FFFFFF' >
			<td align='center'>#</td>
			<td align='center'>Phần Thưởng</td>
			<td align='center'>Số Lượng</td>
			<td align='center'>Xác xuất</td>
		    <td align='center'>Hình</td>
		    <td align='center' width='50'>&nbsp;</td>
		</tr>";
	for($i=0;$i<$stt;$i++) {
		$content .= "<tr bgcolor='#FFFFFF' >
			<td align='center'>".$item_read[$i]['stt']."</td>
			<td align='center'>".$item_read[$i]['des']."</td>
			<td align='center'>".number_format($item_read[$i]['number'], 0, ',', '.')."</td>
			<td align='center'>".$item_read[$i]['percent']."</td>
			<td align='center'><img src='Items/".$item_read[$i]['img'].".gif'></td>
			<td align='center'><a href='admin.php?mod=editrelax&act=".$act."&page=del&item=".$item_read[$i]['stt']."' target='_self'>Xóa</a></td>
		</tr>";
	}
	$content .= "</table>";
	
	echo $content;
}
function ResetTotal($char_reset, $char_relife){
	include('config/config_relife.php');
	
	for($relife_i = 0; $relife_i <= $char_relife; $relife_i++) {
		$char_reset += $rl_reset_relife[$relife_i];
	}
	
	return $char_reset;
}

function doingoc_load($filename,$more=1)
{
	$stt = 0;
	if(is_file($filename)) {
		$fopen_host = fopen($filename, "r");
		
		while (!feof($fopen_host)) {
			$get_item = fgets($fopen_host,200);
			$get_item = trim($get_item);
			if($get_item) {
				$item_info = explode('<vwebmu>', $get_item);

				$item_read[] = array (
					'stt'	=> $stt,
					'item_code'	=> $item_info[0],
					'price'	=> $item_info[1],
					'tiente'	=> $item_info[2]
				);
				$stt++;
			}
		}
	} else $fopen_host = fopen($filename, "w");
	fclose($fopen_host);
	return $item_read;
}

?>