<?php
ob_start();
if( !ini_get('safe_mode') ){
            set_time_limit(60);
} 
error_reporting(E_ALL); 
ignore_user_abort(TRUE);
date_default_timezone_set('Asia/Ho_Chi_Minh');
/*
if(preg_match('%(.*\.)?getlinkvn\.com%U', $_SERVER['HTTP_HOST'])) {
	include("./../../../../class.user.free/login.user.php");
	exit;
}
*/
class login {
	public function __construct(){
		$self = strtolower($this->isHttps().$_SERVER['HTTP_HOST'].preg_replace('/\?.*$/', '', isset($_SERVER['REQUEST_URI'])? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']));
		include("config.php");
		$this->self = $self;
		if(file_exists($fileinfo_dir.'/info.backup.php') && !file_exists($fileinfo_dir.'/info.php')) { 
			$data = @file_get_contents($fileinfo_dir.'/info.backup.php');
			$this->savedata($fileinfo_dir.'/info.php',$data);	
			header('location: index.php');
			exit;
		}
		elseif(!file_exists($fileinfo_dir."/info.php")) { 
			header('location: ./');
			exit;
		}
		$this->lang = $lang;
		$this->myip = $this->yourip();
		$this->linklogin = str_replace(substr(strrchr($this->self, '/'), 1),"",$this->self);
		$this->checkisp = $checkisp.'?url='.urlencode($this->self).'&ip=';
		$this->acc_type = $acc_type;
		if(isset($limit2MBIP)) $this->limitMBIP = $limitMBIP + $limit2MBIP;
		else $this->limitMBIP = $limitMBIP;
		$this->plusbw = $plusbw;
		$this->SecureID = $SecureID;
		$this->mailerror = $mailerror;
		$this->email = $email;
		$this->username = $username;
		$this->old = $old;
		$this->mobile = $mobile;
		$this->address = $address;
		if(isset($created)) $this->created = $created;
		else $this->created = '0';
		if(isset($expired)) $this->expired = $expired;
		else $this->expired = '0';
		$this->fileinfo_dir = $fileinfo_dir;
		$this->fileinfo = $fileinfo;
		$this->max_ip = $max_ip_login;
		$this->linkmail = $linkmail;
		$this->passmail = $passmail;
		$this->acc_api = $acc_api;
		$this->renew_url = $this->isHttps().$_SERVER['HTTP_HOST'].'/renew/';
		$this->renew_pass = 'M3Uwx_q|,Ao}';
		$this->load_info();
		if(isset($_REQUEST)) $this->main();
	}
	function yourip(){
		if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
		elseif(isset($_SERVER['HTTP_X_REAL_IP'])) $ip = $_SERVER['HTTP_X_REAL_IP'];
		else $ip = $_SERVER['REMOTE_ADDR'];
		$ip = preg_replace("/(\,.*)/i",'',$ip);
		return $ip;
	}

	function isHttps(){
		if (array_key_exists("HTTPS", $_SERVER) && 'on' === $_SERVER["HTTPS"]) {
			return 'https://';
		}
		if (array_key_exists("SERVER_PORT", $_SERVER) && 443 === (int)$_SERVER["SERVER_PORT"]) {
			return 'https://';
		}
		if (array_key_exists("HTTP_X_FORWARDED_SSL", $_SERVER) && 'on' === $_SERVER["HTTP_X_FORWARDED_SSL"]) {
			return 'https://';
		}
		if (array_key_exists("HTTP_X_FORWARDED_PROTO", $_SERVER) && 'https' === $_SERVER["HTTP_X_FORWARDED_PROTO"]) {
			return 'https://';
		}
		return 'http://';
	}

	function curl1($url,$cookies,$post){
		$ch = @curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HEADER, 1);
		if ($cookies) curl_setopt($ch, CURLOPT_COOKIE, $cookies);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_REFERER,'google.com'); 
		if ($post){
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
		}
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
		curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60);
		$page = curl_exec($ch);
        //if (!$page = curl_exec($ch)) echo "g() failed: url={$url}; curl_errno()=" . curl_errno($ch) . "; curl_eror()=" . curl_error($ch);
		curl_close($ch); 
		return $page;
	}
	function curl($url,$cookies,$post,$header=false){
		$ch = @curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HEADER, $header);
		if ($cookies) curl_setopt($ch, CURLOPT_COOKIE, $cookies);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_REFERER,'google.com'); 
		if ($post){
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
		}
		curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20);
		$page = curl_exec( $ch);
		curl_close($ch); 
		return $page;
	}

	function saveinfophp($pass='',$mail='',$user='',$old='',$mobile='',$address='',$created='',$expired='') {
		$str = "<?php";
		$str .= "\n\$SecureID = '".($pass?$pass:$this->SecureID)."';";
		$str .= "\n\$email  = '".($mail?$mail:$this->email)."';";
		$str .= "\n\$username  = '".($user?$user:$this->username)."';";
		$str .= "\n\$old  = '".($old?$old:$this->old)."';";
		$str .= "\n\$mobile  = '".($mobile?$mobile:$this->mobile)."';";
		$str .= "\n\$address  = '".($address?$address:$this->address)."';";
		$str .= "\n\$created  = ".($created?$created:$this->created).";";
		$str .= "\n\$expired  = ".($expired?$expired:$this->expired).";";
		$str .= "\n?>";
		$this->savedata($this->fileinfo_dir.'/info.php',$str);
	}

	function savedata($file,$data) {
		$fh = fopen($file, 'w+') 
		or die('<CENTER><font color=red size=3>Could not open file ! Try to chmod the file "<B>'.$file.'</B>" to 666</font></CENTER>');
		fwrite($fh, $data) 
		or die('<CENTER><font color=red size=3>Could not write file ! Try to chmod the file "<B>'.$file.'</B>" to 666</font></CENTER>');
		fclose($fh);
		@chmod($file, 0666);
	}
	function load_info(){
		if (isset($this->info)){
    		return;
		}
		if(file_exists($this->fileinfo_dir.'/'.$this->fileinfo)) { 
			$this->info_data = @file_get_contents($this->fileinfo_dir.'/'.$this->fileinfo);
			$this->info = @json_decode($this->info_data, true);	
		}
		elseif(file_exists($this->fileinfo_dir.'/info.backup.dat')) { 
			$this->info_data = @file_get_contents($this->fileinfo_dir.'/info.backup.dat');
			$this->info = @json_decode($this->info_data, true);	
		}
		if(!isset($this->info["status"]) AND file_exists($this->fileinfo_dir.'/info.backup.dat')) { 
			$this->info_data = @file_get_contents($this->fileinfo_dir.'/info.backup.dat');
			$this->info = @json_decode($this->info_data, true);	
		}
		if (!isset($this->info) || !is_array($this->info)){
			$this->info = array();
			$this->info_data = 'vng';
		}
		
	}

	function save_info(){
		if (!isset($this->info) || is_array($this->info)==false) return;
		$tmp = json_encode($this->info);
		if ($tmp !== $this->info_data){
			$this->info_data = $tmp;
			$this->savedata($this->fileinfo_dir.'/'.$this->fileinfo,$this->info_data);
			/*--------- save backup ---------*/
			if(!file_exists($this->fileinfo_dir.'/info.backup.dat') AND isset($this->info["status"])) { 
				$this->savedata($this->fileinfo_dir.'/info.backup.dat',$tmp);
			}
			/*--------- /save backup ---------*/

			####### Create file info.backup.php #############
			if(!file_exists($this->fileinfo_dir.'/info.backup.php') && empty($this->email)==false) { 
				$data = @file_get_contents($this->fileinfo_dir.'/info.php');
				$this->savedata($this->fileinfo_dir.'/info.backup.php',$data);
			}

			return true;	
		}
	}

	function rand_filename($folder){
		$namedata = $timeload = explode(" ", microtime());
		$namedata = $namedata[1]*1000 + round($namedata[0]*1000);
		$filename = $folder.$namedata. ".dat";
		if (file_exists($filename)) $this->rand_filename($folder);
		return $filename;
	}

	function savefile($file,$data,$type='w+') {
		$fh = fopen($file, $type) 
		or die('<CENTER><font color=red size=3>Could not open file ! Try to chmod the file "<B>'.$file.'</B>" to 666</font></CENTER>');
		fwrite($fh, $data) 
		or die('<CENTER><font color=red size=3>Could not write file ! Try to chmod the file "<B>'.$file.'</B>" to 666</font></CENTER>');
		fclose($fh);
		@chmod($file, 0666);
	}

	function save_bw($time=false, $txtlog=false){
		$fld_bw = $this->fileinfo_dir.$this->bw_dir;
		$file_logbw = $fld_bw.'logbw.txt';
		if (!isset($this->bw) || is_array($this->bw)==false) die('error 01: not found bw');
		$file_bw = $this->rand_filename($fld_bw);
		if(!file_exists ($fld_bw)) { 
			mkdir($fld_bw, 0777)  or die('<CENTER><font color=red size=4>Could not create folder! Try to chmod the folder "<B>'.$this->bw_dir.'</B>" to 777</font></CENTER>');

			if(!file_exists($fld_bw."index.php")) { 
				$clog=fopen($fld_bw."index.php","a") 
				or die('<CENTER><font color=red size=3>Could not create to file ! Try to chmod the folder "<B>bw</B>" to 777</font></CENTER>');
				fwrite($clog,'<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=https://getlink.vn">');
				fclose($clog);
			}
		}	

		if($time==false) $this->bw["time"] = time();
		if($time > 1262304000)  $this->bw["time"] = $time;
		$tmp = @json_encode($this->bw);
		$fh = fopen($file_bw, 'w+') or die('<CENTER><font color=red size=3>Could not open file ! Try to chmod the folder "<B>'.$this->fileinfo_dir.'</B>" to 777</font></CENTER>');
		fwrite($fh, $tmp);
		fclose($fh);
		if(!empty($txtlog)) $this->savefile($file_logbw,$txtlog."\r\n",'a');
		@chmod($file_bw, 0666);
		if (isset($this->listbw) && count($this->listbw)>0) foreach ($this->listbw as $file) if (file_exists($file)) @unlink($file);
		return true;
	}

	function countlogin() {
		if(!isset($this->info["logs"])) return; #khong co gia tri log se returns

		$listip = array();
		$ip_date = "";
		#phan tich gia tri logs
		krsort($this->info["logs"]);
		foreach($this->info["logs"] as $time => $ip) {
			if((date('Y',time()) == date('Y',$time)) && (date('z',time())  ==  date('z',$time))) {
				if(preg_match("/^(\d{1,3}\.\d{1,3}\.\d{1,3})/i", $ip, $value)) $iplog = $value[1];
				else if (preg_match("/^(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:(?!$)|$)|\2))(?4){5}((?4){2}|((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?7)){3})\z/i",  $ip, $value)) $iplog = $ip;
				if (!in_array($iplog, $listip)) {
					$listip[] = $iplog;
					$ip_date = $ip_date.$ip."&nbsp;&nbsp;(".date( 'H:i:s - d.m.Y',$time).")<BR>";
				}
			}
			else break;
		}
		$countlogin = count($listip); #dem so lan login

		if(!isset($this->info["lock"]["status"])) $this->info["lock"]["status"] = false;
		#xu ly khi so lan login vuot qua cho phep
		if($countlogin > $this->max_ip) {
			#chi xu ly voi truong hop chua lock
			if($this->info["lock"]["status"] == false){
				#Update status moi
				$this->info["status"] = "locked";
				$this->info["lock"]["status"] = true;
				if(isset($this->info["lock"]["count"])) $this->info["lock"]["count"] = $this->info["lock"]["count"] + 1;
				else $this->info["lock"]["count"] = 1;

				$this->info["lock"]["time"] = strtotime(date('d.m.Y',strtotime("+".$this->info["lock"]["count"]." day")));
				$this->save_info();
				# gui mail thong bao 
				if($this->info["lock"]["count"] > 3) {
					$post['mailto'] = $this->email;
					$post['subject'] = $this->lang['locked6'];
					$post['contents'] = sprintf($this->lang['locked7'],$ip_date, date( 'H:i:s - d.m.Y',$this->info["lock"]["time"]),  $this->lang['warning'], $this->linklogin,$this->lang['contactme']);
					$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);
				}
				else {
					$newpass =  substr(md5(microtime()), 0, 10);
					$post['mailto'] = $this->email;
					$post['subject'] = $this->lang['locked4'].date('H:i:s - d.m.Y',$this->info["lock"]["time"]);
					$post['contents'] = sprintf($this->lang['locked5'],$ip_date, date( 'H:i:s - d.m.Y',$this->info["lock"]["time"]), $this->info["lock"]["count"], $this->lang['warning'], $this->linklogin, $this->lang['mirror'], str_replace('getlink.vn','getlink.biz', $this->linklogin),$this->lang['contactme']);

					$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);
					if(stristr($data,"has been sent")) {
						$this->saveinfophp($newpass); #Create new password
					}
				}
				#/gui mail
			}
			die("<SCRIPT language='Javascript'>document.location.href ='./login.php?go=lock';</SCRIPT>");
		}
		#unlock khi het thoi gian lock 
		elseif($this->info["lock"]["status"] == true and $this->info["lock"]["time"] < time()) {
			$this->info["status"] = "true";
			$this->info["lock"]["status"] = false;
			$this->save_info();

		}
		#hien thong bao khi thoi gian lock con hieu luc
		elseif($this->info["lock"]["status"] == true && $this->info["lock"]["time"] > time()) {
			die(sprintf($this->lang['locked3'],date( 'H:i:s - d.m.Y',$this->info["lock"]["time"]), $this->lang['contactme']));
		}
		return $ip_date;
	}
	function main() {

		#------------------  convert to new data  ------------------#
		if(isset($this->info["created"]) AND isset($this->info["expired"])) {
			$this->saveinfophp('','','','','','',$this->info["created"],$this->info["expired"]);
			unset($this->info["created"]);
			unset($this->info["expired"]);
			$this->save_info();
			$data = file_get_contents($this->fileinfo_dir.'/info.php');
			$this->savedata($this->fileinfo_dir."/info.backup.php",$data);
			$data = file_get_contents($this->fileinfo_dir."/info.dat");
			$this->savedata($this->fileinfo_dir."/info.backup.dat",$data);

		}
		#------------------  convert to new data ------------------#
######### begin xu ly khi request download #########
		if (isset($_GET['ip'])) {
			if (isset($_GET['time'])) $timefile = trim($_GET['time']);
			else $timefile = time();
			if(!isset($_COOKIE["cookieip"]) || $_COOKIE["cookieip"] !== substr(md5("getlinkv3.2"), 0, 15)) die("false");
			//echo 'qua step 1<BR>';
			#----------------------- check lock -----------------------#
			if(isset($this->info["status"]) && $this->info["status"] == "locked"){
				if($this->info["lock"]["count"] > 3) {
					setcookie("secureid", "owner", time());
					die(sprintf($this->lang['locked1'],$this->lang['mail_contact']));
				}
				if($this->info["lock"]["time"] > time()) {
					setcookie("secureid", "owner", time());

					die(sprintf($this->lang['locked2'],date( 'H:i:s - d.m.Y',$this->info["lock"]["time"]), $this->lang['contactme']));
				}
				else {
					$this->info["status"] = "true";
					$this->info["lock"]["status"] = false;
					$this->save_info();

				}
			}
			#----------------------- check lock -----------------------#

			//echo 'qua step 2<BR>';
			if(preg_match("/^(\d{1,3}\.\d{1,3}\.\d{1,3})/i", $_GET['ip'], $value)) $ip = $value[1];
			else if (preg_match("/^(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:(?!$)|$)|\2))(?4){5}((?4){2}|((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?7)){3})\z/i",  $_GET['ip'], $value)) $iplog = $_GET['ip'];
			else die(sprintf($this->lang['warn_ip2'],$_GET['ip']));
			$checklog = false;
			/*
			krsort($this->info["logs"]);
			foreach($this->info["logs"] as $time => $iplog) {
				if($this->expired > time() && time() - $time < 24*60*60) {
					if (stristr($iplog,$ip)){
						$checklog = true;
						die("true1: đã login từ $iplog lúc: ".date('H:i:s - d.m.Y',$time));
					}
				}
				elseif($this->expired < time() && time() - $time < 24*60*60) {
					if(time() - $timefile > 6*60*60) die(_exacc1);
					if (stristr($iplog,$ip)){
						$checklog = true;
						die("true2: đã login từ $iplog lúc: ".date('H:i:s - d.m.Y',$time));
					}
				}
				else break;
			}
			*/


			//echo 'qua step 3<BR>';
			if($checklog == false) {
				$data = $this->curl($this->checkisp.$_GET['ip'],"","");
				//echo $this->checkisp.$_GET['ip'].'<textarea>'.$data.'</textarea>';exit;
				if (stristr($data,'blacklist')){
					$json =  @json_decode($data, true);
					$show_ip = '<b><font color=red>'.$ip.' (ISP: '.$json['isp'].' - '.$json['country'].')</font></b>';
					die(sprintf($this->lang['warn_ip2'],$show_ip, $this->lang['mail_hotro']));
				}
				if(!isset($this->info["logsdown"])) {
					$this->info["logsdown"][time()] = trim($_GET['ip']);
					$this->save_info();
					die("true");
				}

				krsort($this->info["logsdown"]);
				$total = 0;
				foreach($this->info["logsdown"] as $time => $iplog) {
					if($this->expired > time() && time() - $time < 24*60*60) {
						if (stristr($iplog,$ip)){
							$checklog = true;
							die("true");
						}
						$total++;
					}
					elseif($this->expired < time() && time() - $time < 24*60*60) {
						if(time() - $timefile > 6*60*60) die(_exacc1);
						if (stristr($iplog,$ip)){
							$checklog = true;
							die("true");
						}
						$total++;
					}
					else break;
				}

				if($total > 5) {
					die(sprintf($this->lang['warn_ip1'],$ip, $ip));
				}
				else {
					$this->info["logsdown"][time()] = trim($_GET['ip']);
					$this->save_info();
					die("true");
				}
			}
			exit;

		}

######### end xu ly khi request download #########
		#Manager login
		elseif (isset($_GET['userlogin']) && $_GET['userlogin'] == md5($this->SecureID)) {
			setcookie("secureid",$_GET['userlogin'],time()+3600*24*7);
		}
		#del cookie khi logout
		elseif (isset($_GET['go']) && $_GET['go']=='logout') {
			setcookie("secureid", "owner", time()-100000);
		}
		#/del cookie

######### begin xu ly khi login #########
		elseif(isset($_POST['secure'])) {
			if($_POST['secure'] == $this->SecureID){
				$this->countlogin();
				if($this->getinfo_ip == false) {
					$data = '{"realip":"'.$this->myip.'","ip":"'.$this->myip.'","status":"whitelist","host":"'.$this->myip.'","isp":"fpt","city":"unkown","country":"unkown","time":'.time().'}';
				}
				else $data = $this->curl($this->checkisp.$this->myip,"","");

				$json =  @json_decode($data, true);
				if (stristr($data,'blacklist')){
					$this->showip = '<b><font color=red>'.$this->myip.' (ISP: '.$json['isp'].' - '.$json['country'].')</font></b>';
					die(sprintf($this->lang['blacklist'],$this->showip));
				}
				if(stristr($data,'fpt')) $network = 'fpt';
				elseif(stristr($data,'viettel')) $network = 'viettel';
				elseif(stristr($data,'vnpt') || stristr($data,'VIETNAM POSTS')) $network = 'vnpt';
				elseif(stristr($data,'vdc')) $network = 'vnpt';
				else $network = $json['isp'];
				if(preg_match("/^(\d{1,3}\.\d{1,3}\.\d{1,3})/i", $this->myip, $value)) $myip = $value[1];
				else $myip = $this->myip;
				setcookie('network',$network,time()+10*60);
				setcookie('ip',$myip,time()+10*60);
				setcookie('country',$json['country'],time()+10*60);
				#-------------------- chọn random server ---------------#
				$sv_rand = array_rand($this->server, 2);
				$cookie = 'type[]=us';
				foreach($sv_rand as $sv) $cookie .= '&type[]='.$sv;
				setcookie('type', $cookie, time()+$this->acc_type['time']*24*60*60);
				#-------------------- chọn random server ---------------#
				#-------------------- save log  ------------------------#
				$this->info["logs"][time()] = $this->myip;
				$this->save_info();
				if(isset($_POST['remember-me'])) setcookie("secureid",md5($_POST['secure']),time()+3600*24*365);
				else setcookie("secureid",md5($_POST['secure']),time()+3600*24);
				#-------------------- save log  ------------------------#
				if(!isset($this->info["status"])) die("<SCRIPT language='Javascript'>document.location.href ='./login.php?go=welcome';</SCRIPT>");
				
				elseif($this->expired < time()) die("<SCRIPT language='Javascript'>document.location.href ='./login.php?go=expired';</SCRIPT>");
				else if(isset($this->info["forgotmail"]) && $this->info["forgotmail"]==true) die("<SCRIPT language='Javascript'>document.location.href ='./login.php?go=changepass';</SCRIPT>");
				#-------------------- check expired --------------------#
				if($this->expired < time()+3*24*60*60) {
					if(!isset($this->info["logsmail"]["expired"])) $this->info["logsmail"]["expired"] = false;
					if($this->info["logsmail"]["expired"] == false) {
						$contents = '';
						if(isset($this->lang['mail_'.strtolower($this->acc_type['type']).$this->acc_type['time']])) {
							$contents = $this->lang['mail_'.strtolower($this->acc_type['type']).$this->acc_type['time']];

							$renewtime = $this->expired + 24*60*60;
							if($this->expired < time()) $renewtime = $this->expired + 3*24*60*60;

							$post['mailto'] = $this->email;
							$post['subject'] = sprintf($this->lang['exp_title'],date('H:i:s - d.m.Y',$this->expired));
							$post['contents'] =  sprintf($contents,$this->linklogin, date('H:i:s - d.m.Y',$this->expired), date('d.m.Y',$renewtime));
							//print_r($post);
							$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);
							//echo $data;exit;
							//mail lưu
							$post['mailto'] = 'mail@getlink.com.vn';
							$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);

								//echo $data;exit;
							
							if(stristr($data,"has been sent")) {
								$this->info["logsmail"]["expired"] = true;
								$this->info["logsmail"]["time_mail_exp"] = time();
								$this->save_info();
							}
							//else die('error send mail');
						}
					}
					
				}
				elseif($this->expired > time()+3*24*60*60 && $this->acc_type['reset_bw'] == true && $this->info["logsmail"]["expired"] == true) {
					$this->info["logsmail"]["expired"] = false;
					$this->save_info();
				}
				#-------------------- check expired --------------------#

			}
			else {
				die("<SCRIPT language='Javascript'>alert(\"".$this->lang['wrongpass']."\");</SCRIPT><SCRIPT language='Javascript'> history.go(-1)</SCRIPT>");
			}
		}
######### end xu ly khi login #########


######### begin welcome #########
		elseif (isset($_GET['go']) && $_GET['go']=='welcome' && isset($_COOKIE["secureid"]) && $_COOKIE["secureid"] == md5($this->SecureID)) {
			if (!file_exists($this->fileinfo_dir.'/info.backup.dat') && !file_exists($this->fileinfo_dir.'/info.backup.php')) {
				$date = time();
				$expired = $this->acc_type['time']*24*60*60 + $date ;

		#------- begin xu ly post -------#
				if(isset($_POST['pass1']) && empty($_POST['pass1'])== false && isset($_POST['pass2'])&& empty($_POST['pass2'])==false && isset($_POST['mail1'])&& empty($_POST['mail1'])==false && isset($_POST['mail2'])&& empty($_POST['mail2'])==false && $_POST['pass1'] ==$_POST['pass2'] && $_POST['mail1'] == $_POST['mail2'] && preg_match("/^[^@]*@[^@]*\.[^@]*$/", trim($_POST['mail1']))){
					
					#-------------- Create file info.php --------------#
					$this->saveinfophp($_POST['pass1'],strtolower($_POST['mail1']),$_POST['username'],$_POST['old'],$_POST['mobile'],$_POST['address'],$date,$expired);

					#-------------- Create info -----------------#
					$this->info["status"] = "true";
					$this->info["lock"]["status"] = false;
					$this->info["lock"]["count"] = 0;
					$this->info["lock"]["time"] = 0;
					$this->save_info();
					#-------------- Create bandwitdh ------------#
					$this->bw = array();
					$this->bw["timeupdate"] = $date;
					$this->bw["bwupdate"] = $this->limitMBIP*1024*1024 + $this->plusbw*1024*1024;
					$txtlog = date('d.m.Y - H:i:s',$date).'|Khởi tạo account|'.$date.'|'.$this->bw["bwupdate"];
					$this->bw["logs"][$date] = $txtlog;
					$this->save_bw(false, $txtlog);
					#-------------- End Create  -----------------#
					setcookie("secureid",md5($_POST['pass1']),time()+3600*24); //set cookie login

					/* mail cho user */
					$post['mailto'] = strtolower($_POST['mail1']);
					$post['subject'] = $this->lang['acti_ss'];
					$post['contents'] = sprintf($this->lang['mail_user1'],$this->linklogin,str_replace('getlink.vn','getlink.com.vn',$this->linklogin),$this->lang['type'],$this->acc_type['fullname'],$this->acc_type['time'], $this->lang['days'],$this->lang['create'],date( 'H:i:s- d.m.Y',$date), $this->lang['expired'], date( 'H:i:s- d.m.Y',$expired), strtolower($_POST['mail1']), strtolower($_POST['username']), $_POST['old'], $_POST['mobile'], $_POST['address']);
					$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);

					/* mail cho Kien */
					$post['mailto'] = 'mail@getlink.com.vn';
					$post['subject'] = 'Kích hoạt tài khoản Getlink.vn thành công cho '.strtolower($_POST['mail1']);
					$post['contents'] = sprintf($this->lang['mail_me1'],$this->linklogin,str_replace('getlink.vn','getlink.com.vn',$this->linklogin),$this->lang['type'],$this->acc_type['fullname'],$this->acc_type['time'], $this->lang['days'],$this->lang['create'],date( 'H:i:s- d.m.Y',$date), $this->lang['expired'], date( 'H:i:s- d.m.Y',$expired), strtolower($_POST['mail1']), strtolower($_POST['username']), $_POST['old'], $_POST['mobile'], $_POST['address']);
					$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);
				}
		#------- end xu ly post -------#
		
		#------- begin main welcome -------#
				else {
					#################################### Config for new member ##############################################
				?>

		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11">
		<head>
			<link rel="SHORTCUT ICON" href="./../../../../images.user/favicon.ico" type="image/x-icon" />
			<title><?php printf($this->lang['welcome'],$this->lang['homepage']);?></title>
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
			<META NAME="ROBOTS" CONTENT="NOINDEX,FOLLOW" />
			<META NAME="GOOGLEBOT" CONTENT="NOINDEX,FOLLOW" />
			<META NAME="SLURP" CONTENT="NOINDEX,FOLLOW" />
			<link title="Rapidleech Style" href="./../../../../images.user/login.css" rel="stylesheet" type="text/css" />
		</head>
		<form action="./login.php?go=welcome" method="post">
		<table width="80%" align="center">
			<tr><td>
				<TABLE class='table1' border=0 cellPadding=0 cellSpacing=0>
					<tr><TD class="td11">
						<img src='./../../../../images.user/arrow_w.gif' border='0'  alt='&gt;' width='8' height='8' />&nbsp;<?php printf($this->lang['welcomemb'],$this->lang['homepage']);?>
					</TD></tr>
					<tr><TD height=2></td></tr>
					<tr><TD class="td12">&nbsp; &nbsp; <?php $this->lang['importpass'];?></TD></tr>
					<tr><td>
						<table cellspacing="10" align="center">
						<tr><td width="40%" valign="top">
							<fieldset>
							<div>
							<?php
								if(isset($_POST['pass1'])&& empty($_POST['pass1'])==true){
									echo $this->lang['wrongpass1'];
								}
								elseif(isset($_POST['pass1']) && isset($_POST['pass2']) && $_POST['pass1'] !== $_POST['pass2']){
									echo $this->lang['wrongpass2'];
								}
							?>
							</div>
							<legend><b><?php echo $this->lang['password'];?></b></legend>
								<table border=0 cellPadding=0 cellspacing="0">
									<tr>
										<td width="45%" nowrap="nowrap"><?php echo $this->lang['importpass1'];?></td>
										<td width="45%"><?php echo $this->lang['importpass2'];?></td>
									</tr>
									<tr>
										<td><input type="password" size="25" maxlength="32" value="" name="pass1" required/></td>
										<td><input type="password" size="25" maxlength="32" value="" name="pass2" required/></td>
									</tr>
								</table>
							</fieldset><br />
							<fieldset>
							<div>
							<?php
								if(isset($_POST['mail1'])&& empty($_POST['mail1'])==true){
									echo $this->lang['wrongmail1'];
								}
								elseif(isset($_POST['mail1']) && isset($_POST['mail2']) && $_POST['mail1'] !== $_POST['mail2']){
									echo $this->lang['wrongmail2'];
								}
								elseif (isset($_POST['mail1'])) {
									if(preg_match("/^[^@]*@[^@]*\.[^@]*$/", trim($_POST['mail1']))==false){
										printf($this->lang['wrongmail3'],$this->lang['mail_contact']);
									}
								} 
							?>
							</div>
							<legend><b><?php echo $this->lang['yourmail'];?>:</b></legend>
								<table border=0 cellPadding=0 cellspacing="0">
									<tr>
										<td width="45%" nowrap="nowrap"><?php echo $this->lang['importmail1'];?></td>

										<td width="45%"><?php echo $this->lang['importmail2'];?></td>
									</tr>
									<tr>
										<td><input type="email" size="25" maxlength="150" value="" name="mail1" required/></td>
										<td><input type="email" size="25" maxlength="150" value="" name="mail2" required/></td>
									</tr>
								</table>
							</fieldset><br />
							<fieldset>
							<div>
							<span style="FONT-FAMILY: Tahoma; COLOR: #993300; FONT-SIZE: 10px"><b><?php echo $this->lang['yourinfo'];?></b></span>
							</div>
							<legend><b><?php $this->lang['yourprofile'];?></b></legend>
								<table border=0 cellPadding=0 cellspacing="0">
									<tr><td height="5px"></td></tr>
									<tr>
										<td width="45%" nowrap="nowrap"><?php echo $this->lang['face'];?></td>

										<td width="45%"><?php echo $this->lang['old'];?></td>
									</tr>
									<tr>
										<td><input type="text" size="25" maxlength="150" value="" name="username"></td>
										<td><input type="number" size="25" maxlength="150" value="20" name="old"  required/></td>
									</tr>
									<tr><td height="5px"></td></tr>
									<tr>
										<td width="45%" nowrap="nowrap"><?php echo $this->lang['mobile'];?></td>

										<td width="45%"><?php echo $this->lang['address'];?></td>

									</tr>
									<tr>
										<td><input type="text" size="25" maxlength="150" value="09xxx" name="mobile"  required/></td>
										<td><input type="text" size="25" maxlength="150" value="Hà Nội" name="address"  required/></td>
									</tr>
								</table>
							</fieldset>
							
							<?php echo $this->lang['note1'];?><BR>
						</td><td width="40%" valign="top">
							<fieldset>
									<legend><B><?php echo $this->lang['profile'];?></B></legend>
									
										<div><?php echo $this->lang['type'].":  <B><font color=red>".$this->acc_type['fullname']." (<font size=5>".$this->acc_type['time']."</font> ".$this->lang['days']."</font>)</b>";?></div><br/>
										<div><?php echo $this->lang['create'].":  <B><font color=blue> ".date( 'H:i:s- d.m.Y',$date)."</font></b>";?></div>
										<div><?php echo $this->lang['expired'].":  <B><font color=red> ".date( 'H:i:s- d.m.Y',$expired)."</font></b>";?></div><br/>
										<div><?php echo $this->lang['currentpass'];?> <b><?php echo $this->SecureID?></b></div><br />
										
					

							</fieldset>
							
						</table>

						</td></tr>
					</td></tr>
				</TABLE>
			</td>
		</tr>
		<tr>
			<td class="td12">&nbsp; &nbsp; <?php echo $this->lang['note'];?></td>
		</tr>
		<tr>
			
			<td><input id="submit" type="submit" value="Save" class="button" /> </td>
		</tr>
	</table>
	</form>



				<?php
					exit;

					#################################### Config for new member ##############################################
				}

		#------- end main welcome -------#

			}
			elseif (file_exists($this->fileinfo_dir.'/info.backup.dat') AND !file_exists($this->fileinfo_dir.'/'.$this->fileinfo)) {
				/*--------- backup info.backup.dat ---------*/
					$info_data = @file_get_contents($this->fileinfo_dir.'/info.backup.dat');
					$this->savedata($this->fileinfo_dir.'/'.$this->fileinfo,$info_data);
				/*--------- /backup info.backup.dat  ---------*/
			}
		}

######### end welcome #########


######### Begin history #########
		elseif (isset($_GET['go']) && $_GET['go']=='history' && isset($_COOKIE["secureid"]) && $_COOKIE["secureid"] == md5($this->SecureID)) {
			krsort($this->info["logs"]);

			if(count($this->info["logs"])>0) 
				echo '
				<tr class="flisttblhdr" valign="bottom">
					<td width="30%"><b>'.$this->lang['Date'].'</b></td>
					<td width="30%"><b>IP</b></td>
				</tr>';

			foreach($this->info["logs"] as $time => $iplog) {
				if(time() - $time > 3*24*60*60) continue;
				if(preg_match("/^(\d{1,3}\.\d{1,3}\.\d{1,3})/i", $iplog, $value)) $ip = $value[1];
				else if (preg_match("/^(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:(?!$)|$)|\2))(?4){5}((?4){2}|((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?7)){3})\z/i", $iplog, $value)) $ip = $iplog;
				echo "<tr class='flistmouseoff' align='center'>
						<td><span style='FONT-FAMILY: Arial; FONT-SIZE: 12px'>".date( 'H:i:s - d.m.Y',$time)."</span></td>
						<td><span style='FONT-FAMILY: Arial; FONT-SIZE: 12px'>".$ip.".***</span></td>
					</tr>";
			}
			exit;
		}

######### end history #########


######### Begin change pass #########

		elseif (isset($_GET['go']) && $_GET['go']=='changepass' AND isset($_COOKIE["secureid"]) AND $_COOKIE["secureid"] == md5($this->SecureID) AND $this->info["status"] == "true") {
		#------- begin xu ly post change pass -------#
			if(isset($_POST['pass1']) && empty($_POST['pass1'])== false && isset($_POST['pass2'])&& empty($_POST['pass2'])==false && isset($_POST['oldpass'])&& empty($_POST['oldpass'])==false && $_POST['pass1'] == $_POST['pass2'] && $_POST['oldpass'] == $this->SecureID){

				/*--------- Update file info.php ---------*/
				$this->info["forgotmail"] = false;
				$this->save_info();
				$this->saveinfophp($_POST['pass1']);

				setcookie("secureid",md5($_POST['pass1']),time()+3600*24*5);
				echo "<SCRIPT language='Javascript'>alert(\"".$this->lang['pass_ss']."\");</SCRIPT>";
				echo"<SCRIPT language='Javascript'>document.location.href ='./';</SCRIPT>";
				exit;

			}
	#------- end xu ly post change pass -------#

	#------- begin main change pass -------#
			else {
	?>
			<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
			<html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11">
			<head>
				<link rel="SHORTCUT ICON" href="./../../../../images.user/vngicon.png" type="image/x-icon" />
				<title><?php echo $this->lang['changepass'];?></title>
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
				<META NAME="ROBOTS" CONTENT="NOINDEX,FOLLOW" />
				<META NAME="GOOGLEBOT" CONTENT="NOINDEX,FOLLOW" />
				<META NAME="SLURP" CONTENT="NOINDEX,FOLLOW" />
				<link title="Rapidleech Style" href="./../../../../images.user/login.css" rel="stylesheet" type="text/css" />
			</head>
			<form action="./login.php?go=changepass" method="post">
			<table width="80%" align="center">
				<tr><td>
					<TABLE class='table1' border=0 cellPadding=0 cellSpacing=0 width="80%">
						<tr><TD class="td11">
							<img src='./../../../../images.user/arrow_w.gif' border='0'  alt='&gt;' width='8' height='8' />&nbsp;<?php printf($this->lang['welcomemb'],$this->lang['homepage']);?>
						</TD></tr>
						<tr><TD height=2></td></tr>
						<tr><TD class="td12">&nbsp; &nbsp; <?php echo $this->lang['insert_info'];?></TD></tr>
						<tr><td>
							<table cellspacing="10" align="center" width="100%">
							<tr><td width="40%" valign="top">
								<fieldset>
								<div>
								<?php
									if(isset($_POST['oldpass'])&& empty($_POST['oldpass'])==true){
										echo $this->lang['wrongpass1'];
									}
									elseif(isset($_POST['oldpass'])&& $_POST['oldpass'] !== $SecureID){
										echo '<font color=red><b>'.$this->lang['wrongpass'].'</b></font>';
									}
								?>
								</div>
								<legend><b><?php echo $this->lang['currentpass'];?></b></legend>
									<input type="text" size="25" maxlength="150" value="" name="oldpass" />
								</fieldset><br />
								<fieldset>
								<div>
								<?php
									if(isset($_POST['pass1'])&& empty($_POST['pass1'])==true){
										echo $this->lang['wrongpass1'];
									}
									elseif(isset($_POST['pass1']) && isset($_POST['pass2']) && $_POST['pass1'] !== $_POST['pass2']){
										echo $this->lang['wrongpass2'];
									}
								?>
								</div>
								<legend><b><?php echo $this->lang['importpass1'];?>:</b></legend>
									<table border=0 cellPadding=0 cellspacing="0">
										<tr>
											<td width="45%" nowrap="nowrap"><?php echo $this->lang['importpass1'];?></td>
											<td width="45%"><?php echo $this->lang['importpass2'];?></td>
										</tr>
										<tr>
											<td><input type="password" size="25" maxlength="32" value="" name="pass1" /></td>
											<td><input type="password" size="25" maxlength="32" value="" name="pass2" /></td>
										</tr>
									</table>
								</fieldset><br />
							</td><td width="40%" valign="top">
								<fieldset>
										<legend><B><?php echo $this->lang['profile'];?></B></legend>
										
											<div><?php echo $this->lang['type'].":  <B><font color=red>".$this->acc_type['fullname']." (<font size=5>".$this->acc_type['time']."</font> ng&#224;y</font>)</b>";?></div><br/>
											<div><?php echo $this->lang['create'].":  <B><font color=blue> ".date( 'H:i:s- d.m.Y',$this->created)."</font></b>";?></div>
											<div><?php echo $this->lang['expired'].":  <B><font color=red> ".date( 'H:i:s- d.m.Y',$this->expired)."</font></b>";?></div><br/>
											<div><?php echo $this->lang['yourmail'];?> <b><?php echo $this->email?></b></div><br />
											
						

								</fieldset>
								

							</td></tr>
							</table>
						</td></tr>
					</TABLE>
				</td>
			</tr>
			<tr>
				<td class="td12">&nbsp; &nbsp; <?php echo $this->lang['warn_pw'];?></td>
			</tr>
			<tr>
				
				<td><input id="submit" type="submit" value="Save" class="button" /> &nbsp; &nbsp; <a href="./"><b>Cancel</b></a></td>
			</tr>
		</table>
		</form>

<?php
				exit;
			}
		#------- begin main change pass -------#
		}
######### end change pass #########

######### Begin contact #########
		elseif (isset($_GET['go']) && $_GET['go']=='contact' && isset($_COOKIE["secureid"]) && $_COOKIE["secureid"] == md5($this->SecureID)) {

			if(!isset($this->info["logsmail"]["lasttime"])) $this->info["logsmail"]["lasttime"] = 0;

			$post['mailto'] = $this->mailerror;
			$post['subject'] = $_POST["tieude"];
			$post['contents'] = 
				"<b>".$_POST["tieude"]."</b><BR><BR>
				".$_POST["noidung"]."<BR><BR>
				".$_POST["link_loi"]."<BR><BR>

				<i>
				".$this->lang['tk_gl'].": ".$this->linklogin."<BR/>
				Email: ".$this->email."<BR/>
				".$this->lang['mobile'].$_POST["sodienthoai"]."</i><BR/><BR/>"
			;
			if($this->info["logsmail"]["lasttime"]+5*60 < time()) {
				$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);
				if(stristr($data,"has been sent")) {
					$this->info["logsmail"][time()] = $this->myip;
					$this->info["logsmail"]["lasttime"] = time();
					$this->save_info();
				}
				echo $this->lang['thanks1'];
			}
			else {
				$time = 5*60 - (time() - $this->info["logsmail"]["lasttime"]);
				if($time > 60) $time = round($time/60,1)." ".$this->lang['mins'];
				else  $time = $time." ".$this->lang['sec'];
				printf($this->lang['limit_mail'],$time);
			}
			
			exit;
		}
######### End contact #########

######### Begin add bw #########
		elseif (isset($_GET['go']) && $_GET['go']=='addbw' && isset($_COOKIE["secureid"]) && $_COOKIE["secureid"] == md5($this->SecureID)) {

			if(!isset($this->info["logsmail"]["lasttime"])) $this->info["logsmail"]["lasttime"] = 0;

			$post['mailto'] = $this->mailerror;
			$post['subject'] = $_POST["tieude"];
			$post['contents'] = 
				"<b>".$_POST["tieude"]." ".$_POST["hosting"]."</b><BR><BR>
				".$_POST["noidung"]."<BR><BR>

				<i>
				".$this->lang['tk_gl'].": ".$this->linklogin."<BR/>
				Email: ".$this->email."<BR/>
				".$this->lang['mobile'].$_POST["sodienthoai"]."</i><BR/><BR/>"
			;
			if($this->info["logsmail"]["lasttime"]+5*60 < time()) {
				$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);
				if(stristr($data,"has been sent")) {
					$this->info["logsmail"][time()] = $this->myip;
					$this->info["logsmail"]["lasttime"] = time();
					$this->save_info();
				}
				echo $this->lang['thanks1'];
			}
			else {
				$time = 5*60 - (time() - $this->info["logsmail"]["lasttime"]);
				if($time > 60) $time = round($time/60,1)." ".$this->lang['mins'];
				else  $time = $time." ".$this->lang['sec'];
				printf($this->lang['limit_mail'],$time);
			}
			
			exit;
		}
######### End add bw #########
######### Begin forgot #########
		elseif (isset($_GET['go']) && $_GET['go']=='forgot') {
			if(!isset($this->info["lastmail"])) $this->info["lastmail"] =array();
			echo "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
				<center><a href='http://getlink.vn' style='TEXT-DECORATION: none'><SPAN style='font-size:450%;font-weight:bold;font-style:normal;color:#666666;text-decoration:none;text-shadow:#000 2px 2px  2px;font-variant:small-caps;'>getlink.vn</SPAN></a><BR><BR>";
			if(isset($_POST['yourmail']) && empty($_POST['yourmail'])== false && strtolower($_POST['yourmail']) == strtolower($this->email)){

				$newpass = substr(md5(time()), 0, 10);
				if(!isset($this->info["logsmail"]["lasttime"])) $this->info["logsmail"]["lasttime"] = 0;
				$post['mailto'] = $this->email;
				$post['subject'] = $this->lang['forgot1'].' [#'.time().']';
				$post['contents'] = sprintf($this->lang['forgot2'],$this->linklogin,$this->lang['password'],$newpass,$this->linklogin."login.php?go=changepass");
				if($this->info["logsmail"]["lasttime"]+5*60 < time()) {
					$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);
					if(stristr($data,"has been sent")) {
						$this->info["logsmail"][time()] = $this->myip;
						$this->info["logsmail"]["lasttime"] = time();
						$this->info["forgotmail"] = true;
						$this->save_info();
						$this->saveinfophp($newpass);
					}
				}
				else $data ="mail has been sent";
				if(stristr($data,"has been sent")) {
					echo "<table width='80%' align='center'>					
						<tr>
							<Td>";
								printf($this->lang['rport_fg'],$this->email, $this->lang['mail_hotro'], $this->lang['mail_contact'], $this->lang['ymcontact']);
					echo "	</Td>
						</tr>
					</table>";
				}
				else {
					printf($this->lang['errormail'],$this->lang['mail_contact']);
					exit;
				}

			}
			else {
				if(isset($_POST['yourmail'])&& $_POST['yourmail'] !== strtolower($this->email))
					echo "<center><font color=red>".$this->lang['wrongmail2']."</font>";
				else echo "<center>".$this->lang['importmail1'];
				echo "<form action='./login.php?go=forgot' method='post'><BR>
					<input type='text' id='password' name='yourmail' size='44'/><BR><BR>
					<input type=submit value='".$this->lang['getpass']."' /></form><BR>
					</form></center>
				";
			}
			echo '<BR><BR><BR><BR><BR><BR><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 11px"><B>';
			printf($this->lang['copyright'],$this->lang['homepage'],$this->lang['mail_hotro'],$this->lang['mobile_sp']);
			echo '</B></span>';
			exit;

		}
######### End forgot #########
######### Begin renew #########
		elseif (isset($_GET['go']) && $_GET['go']=='renew') {
			die("<SCRIPT language='Javascript'>document.location.href ='http://getlink.vn/giahan.php';</SCRIPT>"); //ngừng sử dụng code
			echo "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
				<center><a href='http://getlink.vn' style='TEXT-DECORATION: none'><SPAN style='font-size:450%;font-weight:bold;font-style:normal;color:#666666;text-decoration:none;text-shadow:#000 2px 2px  2px;font-variant:small-caps;'>getlink.vn</SPAN></a><BR><BR>";
			
			if(isset($_POST['voucher'])&& empty($_POST['voucher'])==true) echo "<center><font color=red>".$this->lang['wrongcode1']."</font>";
			if(isset($_POST['voucher'])&& empty($_POST['voucher'])==false) {
				$code = trim($_POST['voucher']);
				if(!isset($this->info["logcode"]["lasttime"])) {
					$this->info["logcode"]["lasttime"] = 0;
					$this->info["logcode"]["count"] = 0;
				}
				elseif(time() - $this->info["logcode"]["lasttime"] > 5*60) {
					$this->info["logcode"]["count"] = 0;
					$this->info["logcode"]["lasttime"] = time();
				}
				else $this->info["logcode"]["lasttime"] = time();
				if(!isset($this->info["logcode"]["count"])) $this->info["logcode"]["count"] = 0;
				else $this->info["logcode"]["count"] = $this->info["logcode"]["count"]+1;
				$this->save_info();
				if($this->info["logcode"]["count"] > 3) die('<BR><BR><h2>'.$this->lang['wrongcode3'].'</h2><BR><BR>'.$this->lang['contactme']);
				$data = $this->curl($this->acc_api.'?code='.$code,'','');
				$page = json_decode($data,true);
				if($page['status'] !== 'ok') {
					echo "<center><font color=red>".$this->lang['wrongcode2']."</font><br><br>";
					echo "<form action='./login.php?go=renew' method='post'><BR>
						<input type='text' id='text' name='voucher' size='44'/><BR><BR>
						<input type=submit value='".$this->lang['entercode']."' /></form><BR>
						</form><BR>
						<a href=".($this->premium?'http://getlink.vn/giahanpremium.php':'http://getlink.vn/giahanpro.php')."><font color=blue><b>Hoặc click vào đây để mua code gia hạn</font></b></a>
						</center><BR>
					";

				}
				elseif($page['status'] == 'ok') {
					$date = time();
					$type = $this->acc_type['type'];
					if(isset($page['actived']) && $page['actived'] ==false) {
						if(isset($page['type']) && $page['type'] !== $type){
							printf($this->lang['wrongcode5'],$type,$page['type'], $this->lang['contactme']);	
						}
						elseif(isset($page['type']) && isset($page['time']) && $page['type'] == $type){
							$renew = $this->expired + $page['time']*24*60*60;
							$this->saveinfophp('','','','','','','',$renew);
							
							#-------------- Update info -----------------#
							$this->info["logcode"][$code] = $page;
							$this->info["logcode"][$code]['time'] = $date;
							$this->info["logcode"][$code]['ip'] = $this->myip;
							$this->info["lock"]["status"] = false;
							$this->info["lock"]["count"] = 0;
							$this->info["lock"]["time"] = 0;
							$this->save_info();
							#-------------- Update bandwitdh -----------------#
							$this->bw["timeupdate"] = $date;
							$this->bw["bwupdate"] = $this->limitMBIP*1024*1024 + $this->plusbw*1024*1024; //refresh bw
							$txtlog = date('d.m.Y - H:i:s',$date).'|cộng băng thông bằng voucher|'.$date.'|'.$this->bw["bwupdate"];
							$this->save_bw(false, $txtlog);
							printf($this->lang['truecode'],$page['time'],round($this->bw["bwupdate"]/(1024*1024*1024),0), $this->lang['contactme']);	
							#-------------- End Update  ----------------------#

							$data = $this->curl($this->acc_api,'vericode=vngveri','code='.$code.'&acc='.$this->linklogin.'&path='.$page['sold_path']);
							//echo $data.'<BR><BR>';
							//print_r($page);
							//print_r($this->info["logcode"]);
						}
						else echo $this->lang['wrongcode4'];
					}
					elseif(isset($page['actived']) && $page['actived'] !==false) {
						$info = explode("-", $page['actived']);
						if(count($info) == "3") {
							$time = $info[1];
							printf($this->lang['actived1'],date( 'H:i:s - d.m.Y',$time),$this->lang['contactme']);
						}
						else printf($this->lang['actived2'],$this->lang['contactme']);
					}
					else echo $this->lang['wrongcode4'];

				}
				else {
					die("<SCRIPT language='Javascript'>document.location.href ='./';</SCRIPT>");
					//print_r($page);
				}
			} else {
			
				echo "<form action='./login.php?go=renew' method='post'><BR>
					<input type='text' id='text' name='voucher' size='44'/><BR><BR>
					<input type=submit value='".$this->lang['entercode']."' /></form><BR>
					</form><BR>
					<a href=".($this->premium?'http://getlink.vn/giahanpremium.php':'http://getlink.vn/giahanpro.php')."><font color=blue><b>Hoặc click vào đây để mua code gia hạn</font></b></a>
					</center><BR>
				";
			}
			echo '<div style="padding:100px;FONT-FAMILY: Arial; FONT-SIZE: 11px" align="center"><B>';
			printf($this->lang['copyright'],$this->lang['homepage'],$this->lang['mail_hotro'],$this->lang['mobile_sp']);
			echo '</B></div>';
			exit;

		}
######### End renew #########

######### Begin lock #########
		elseif (isset($_GET['go']) && $_GET['go']=='lock') {
			if(isset($this->info["status"]) && $this->info["status"] == "locked"){
				if($this->info["lock"]["count"] > 3) {
					setcookie("secureid", "owner", time());
					printf($this->lang['locked1'],$this->lang['mail_contact']);
					exit;
				}
				if($this->info["lock"]["time"] > time()) {
					setcookie("secureid", "owner", time());
					printf($this->lang['locked2'],date( 'H:i:s - d.m.Y',$this->info["lock"]["time"]),$this->lang['contactme']);
					exit;
				}
				else {
					$this->info["status"] = "true";
					$this->info["lock"]["status"] = false;
					$this->save_info();
				}
			}
		}

######### End lock #########
######### Begin expired #########
		elseif (isset($_GET['go']) && $_GET['go']=='expired') {
			$myaccount  = strtolower(preg_replace('/\?.*$/', '', isset($_SERVER['REQUEST_URI'])? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']));
			$myaccount = str_replace("login.php","",$myaccount);
			$freeaccount = 'https://my68.getlinkvn.com'.$myaccount;
			$myaccount = 'https://my.getlink.vn'.$myaccount;
			//$host = 'https://giahan.getlink.vn/buy/gia-han-get-link.php?url='.$myaccount;

			if($this->expired < time()) {
				//setcookie("secureid", "owner", time()-100000);
				if($this->info["status"] !== 'expired') {
					$this->info["status"] = 'expired';
					$this->save_info();
				}

				echo "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
					<center><a href='http://getlink.vn' style='TEXT-DECORATION: none'><SPAN style='font-size:450%;font-weight:bold;font-style:normal;color:#666666;text-decoration:none;text-shadow:#000 2px 2px  2px;font-variant:small-caps;'>getlink.vn</SPAN></a><BR><BR>";
				if($this->acc_type['type'] == 'star') {
					printf($this->lang['star_expired'],date( 'H:i:s- d.m.Y',$this->expired), $freeaccount, $myaccount);
					printf($this->lang['acc_expired_free'], $freeaccount);

				}
				else {
					printf($this->lang['acc_expired'],date( 'H:i:s- d.m.Y',$this->expired), $freeaccount, $myaccount);
					printf($this->lang['acc_expired_free'], $freeaccount);
				}
				exit;
			}
			elseif($this->expired > time() && $this->info["status"] == 'expired') {
				$this->info["status"] = 'true';
				$this->save_info();
			}
			//else die('error expired');
		} 
######### End expired #########
######### Begin downgrade #########
		elseif (isset($_GET['go']) && $_GET['go']=='downgrade') {
			echo "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
				<center><a href='http://getlink.vn' style='TEXT-DECORATION: none'><SPAN style='font-size:450%;font-weight:bold;font-style:normal;color:#666666;text-decoration:none;text-shadow:#000 2px 2px  2px;font-variant:small-caps;'>getlink.vn</SPAN></a><BR><BR>";
			if($this->expired < time()) {
				$this->self = str_replace("login.php","",$this->self);
				$data = file_get_contents('config.php');
				if(stristr($data,'config.star')) $newconfig = 'star/other/config.star.php';
				elseif(stristr($data,'config.pro')) $newconfig = 'pro/other/config.pro.star.php';
				elseif(stristr($data,'config.spro')) $newconfig = 'spro/other/config.spro.star.php';
				elseif(stristr($data,'config.pre')) $newconfig = 'premium/other/config.pre.star.php';
				elseif(stristr($data,'config.vip')) $newconfig = 'vip/other/config.vip.star.php';
				$gach = explode("/", $this->self);
				$fd_user = '../'.$gach[3].'/'.$gach[4].'/'.$gach[5].'/'.$gach[6].'/';
				$expired = time() + 30*24*60*60;
				$post = array(
					'url' => $this->self,
					'newconfig' => $newconfig,
					'fd_user' => $fd_user,
					'expired' => $expired,
					'renew' => true,
				);
				$page = $this->curl($this->renew_url,'pass='.md5($this->renew_pass),'renew='.json_encode($post),0);
				$json = json_decode($page, true);
				if(isset($json['error'])) die($json['error']);
				elseif(!is_array($json)) die('<strong style="color:red">Chuyển đổi tài khoản không thành công!</strong>');
				else {
					$this->info["status"] = 'true';
					$this->save_info();
					echo $this->lang['star_done'];
					if($this->acc_type['type'] == 'star') $convert = 'gia hạn thành công.';
					else $convert = 'chuyển đổi thành công từ tài khoản <strong style="color:red">'.strtoupper($this->acc_type['type']).'</strong> sang loại tài khoản <strong style="color:blue">STAR</strong>.';
					$post['mailto'] = $this->email.','.$this->mailerror;
					$post['subject'] = $fd_user.' chuyển đổi tài khoản STAR thành công';
					$post['contents'] =  'Xin kính chào quý khách,<BR>
					Getlink.vn thông báo: Tài khoản <a href="'.$this->self.'">'.$fd_user.'</a> của quý khách<BR>đã '.$convert.'<BR>
					Tài khoản được kích hoạt lại sau mỗi 30 ngày sử dụng để để bổ sung băng thông.<BR>
					<BR>
					* Nếu cần hỗ trợ vui lòng liên hệ qua email hotro@getlink.vn hoặc liên hệ qua Box chat (ở góc phải màn hình) trang chủ Getlink.vn.<BR>Trong trường hợp không thể gửi email, bạn có thể liên hệ số 0947 132 059.<br><br>';
					$data = $this->curl($this->linkmail,"vngcookie=".md5($this->passmail),$post);


				}
			}
			else {
				printf($this->lang['star_error1']);
			}
			exit;
		} 
######### End downgrade #########
######### Begin api #########
//use api to login.php md5(email)
/*
		elseif (isset($_GET['api'])) {
			if($_GET['api'] = substr(md5($this->email), 0, 10)){
				$apidata = $this->info;
				unset($apidata['logs'],$apidata['logadmin'],$apidata['logcode']);
				$apidata['typeacc'] = $this->acc_type['time'];
				$apidata['premium'] = $this->premium;
				echo json_encode($apidata);
				//echo '<pre>';
				//print_r($apidata);
				exit;
			}
		} 
*/
######### End api #########
	} #main
} #class

$obj = new login(); 
header("location:./?id=leech");
ob_end_flush();



/*
- 23:26:00 - Thursday, 12 May 2016 [GMT+7]

*/
?>