<?
/**
 * @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 ($Use_XepHang != 1) {
	echo "<center>Chức năng không có hoặc không được sử dụng</center>";
}
else {
if ( !isset($_SESSION['mu_username']) ) {
	echo "<div align=center><font color=red><b>Hãy Login trước khi thực hiện chức năng này</b></font></div>";
//	include('modules/home.php');
} else {
    // Chon The he
    if ($thehe_choise)
    {
        if(!isset($_SESSION['thehe'])) $_SESSION['thehe'] = count($thehe_choise)-1;
        if(isset($_GET['thehe'])) $_SESSION['thehe'] = abs(intval($_GET['thehe']));
    }

	if ($act == "event_toprs") { 
		$file_host = "data/toprs.txt"; 
		$action = "view_toprs"; 
		$name = $event_toprs_name;
		$info1_name = "Nhân Vật";
		$info2_name = "Tổng Reset";
		$time_begin = $event_toprs_begin;
		$time_end = $event_toprs_end;
	}
	elseif ($act == "event_toprs2") { 
		$file_host = "data/toprs2.txt"; 
		$action = "view_toprs2"; 
		$name = $event_toprs2_name;
		$info1_name = "Nhân Vật";
		$info2_name = "Tổng Reset";
		$time_begin = $event_toprs2_begin;
		$time_end = $event_toprs2_end;
	}
	elseif ($act == "event_toprs3") { 
		$file_host = "data/toprs3.txt"; 
		$action = "view_toprs3"; 
		$name = $event_toprs3_name;
		$info1_name = "Nhân Vật";
		$info2_name = "Tổng Reset";
		$time_begin = $event_toprs3_begin;
		$time_end = $event_toprs3_end;
	}
	elseif ($act == "event_topdanhvong") { 
		$file_host = "data/topdanhvong.txt"; 
		$action = "view_topdanhvong"; 
		$name = $event_topdanhvong_name;
		$info1_name = "Nhân Vật";
		$info2_name = "Tổng Điểm Reset";
		$time_begin = $event_topdanhvong_begin;
		$time_end = $event_topdanhvong_end;
	}
	elseif ($act == "event_toppoint") { 
		$file_host = "data/toppoint.txt"; 
		$action = "view_toppoint"; 
		$name = $event_toppoint_name; 
		$info1_name = "Nhân Vật";
		$info2_name = "Point";
		$time_begin = $event_toppoint_begin;
		$time_end = $event_toppoint_end;
	}
	elseif ($act == "event_topcard") { 
		$file_host = "data/topcard.txt"; 
		$action = "view_topcard"; 
		$name = $event_topcard_name; 
		$info1_name = "Nhân Vật";
		$info2_name = "Gcoin nạp";
		$time_begin = $event_topcard_begin;
		$time_end = $event_topcard_end;
	}
	elseif ($act == "event_topcard2") { 
		$file_host = "data/topcard2.txt"; 
		$action = "view_topcard2"; 
		$name = "TOP Nạp ngày $date_yesterday"; 
		$info1_name = "Nhân Vật";
		$info2_name = "Gcoin nạp";
		$time_begin = $date_yesterday;
		$time_end = $date_yesterday;
	}
	elseif ($act == "event_topcard3") { 
		$file_host = "data/topcard3.txt"; 
		$action = "view_topcard3"; 
		$name = "TOP Nạp ngày $date_now";
		$info1_name = "Nhân Vật";
		$info2_name = "Gcoin nạp";
		$time_begin = $date_now;
		$time_end = $date_now;
	}
	elseif ($act == "event_topcard4") { 
		$file_host = "data/topcard4.txt"; 
		$action = "view_topcard4"; 
		$name = $event_topcard3_name; 
		$info1_name = "Nhân Vật";
		$info2_name = "Gcoin nạp";
		$time_begin = $event_topcard3_begin;
		$time_end = $event_topcard3_end;
	}
	elseif ($act == "event_topmaster2point") { 
		$file_host = "data/topmaster2point.txt"; 
		$action = "view_topmaster2point"; 
		$name = $event_topmaster2point_name;
		$info1_name = "Nhân Vật";
		$info2_name = "Point đổi";
		$time_begin = $event_topmaster2point_begin;
		$time_end = $event_topmaster2point_end;
	}
	elseif ($act == "event_tongtop") { 
		$file_host = "data/tongtop.txt"; 
		$action = "view_tongtop"; 
		$name = $event_tongtop_name; 
		$info1_name = "Nhân Vật";
		$info2_name = "Resets";
		$info3_name = "Tổng nạp";
		$info4_name = "TOP Resets";
		$info5_name = "TOP Nạp";
		$info6_name = "Tổng TOP";
		$time_begin = $event_tongtop_begin;
		$time_end = $event_tongtop_end;
	}
	elseif ($act == "event_topvongquay") { 
		$file_host = "data/topvongquay.txt"; 
		$action = "view_topvongquay"; 
		$name = $event_topvongquay_name;
		$info1_name = "Nhân Vật";
		$info2_name = "Số Lần Quay";
		$time_begin = $event_topvongquay_begin;
		$time_end = $event_topvongquay_end;
	}

	$time = time()+date("25179");

	if(is_file($file_host)) $fp_host = fopen($file_host, "r");
	else $fp_host = fopen($file_host, "w");
	$time_host = fgets($fp_host,15);
	fclose($fp_host);
	if ($time >= ($time_host+60))
	{
		
		$getcontent_url = $server_url . "/view_eventtop_intime.php";
        $getcontent_data = array(
            'action'    =>  $action,
            'passtransfer'    =>  $passtransfer
        ); 
        
        $show = _getContent($getcontent_url, $getcontent_data, $getcontent_method, $getcontent_curl);
        
		//Ghi vào file
			$fp = fopen($file_host, "w");  
			fputs ($fp, $time."\n".$show);
			fclose($fp);
		//End Ghi vào File
	}
	
	$stt = 0;
	$fopen_host = fopen($file_host, "r");
	while (!feof($fopen_host)) {
		$character = fgets($fopen_host,200);
		$char_info = explode('<vweb>', $character);
		if ( empty($char_info[1]) && strlen($char_info[0] > 5))
		{
			$time_top = gmdate("h:iA d/m/Y", intval($character));
		}
		else {
            if( isset($char_info[2]) && $char_info[2] == $_SESSION['thehe'] ) {
                $info[] = array (
                    'info1'	=> $char_info[0],
                    'info2'	=> $char_info[1],
                    'info3'	=> $char_info[3],
                    'info4'	=> $char_info[4],
                    'info5'	=> $char_info[5],
                    'info6'	=> $char_info[6]
                );
			}
		}
	}
	fclose($fopen_host);
	
	$page_template = 'templates/event/eventtop_intime.tpl';
}
}
?>