<?php
if(count(get_included_files()) ==1) exit("Direct access not permitted.");
date_default_timezone_set('Asia/Jakarta');
if(!isset($_GET['data'])){
	echo "Data tidak ditemukan";
	exit;
}

include_once 'include/global.php';

$method = "AES-128-CBC";
$iv = '1244327671011121'; 
$options=0;
$keypass=substr(PRIVATE_KEY, 0,13);

$decryption=openssl_decrypt($_GET['data'], $method,  
        $keypass, $options, $iv);


$datajs=json_decode($decryption,true);
if(!isset($datajs['status'])) {
	echo "Login Gagal";
	?>
	<p>Halaman akan di alihkan dalam beberapa detik lagi</p>
	<meta http-equiv="refresh" content="5; url=<?php echo NPAGE;?>">
	<?php
}	

if($datajs['status']==1){
	$_SESSION['LOGINSINDI']=1;
	$jenislogin="default";	
	if(isset($datajs['data'])){
		$datalogin=$datajs['data'];
		if(isset($datalogin['jenis'])) $jenislogin=$datalogin['jenis'];
	}
	if($jenislogin=="default"){
		header('Location: https://eofficebdk.kuduscyber.id/member/');
	}else if($jenislogin=="regetr"){
		header('Location: https://bbtppi.kemenperin.go.id/pendaftaranetraining?id='.$datajs['data']['id'].'&statuslogin=1');
	}else if($jenislogin=="regetrs"){
		header('Location: https://bbtppi.kemenperin.go.id/pendaftaranetraining?id='.$datajs['data']['id'].'&statusreg='.$datajs['data']['streg']);
	}
}else{
	if(isset($_SESSION['LOGINSINDI'])) unset($_SESSION['LOGINSINDI']);
	echo "Login Gagal";
	?>
	<p>Halaman akan di alihkan dalam beberapa detik lagi</p>
	<meta http-equiv="refresh" content="5; url=<?php echo NPAGE;?>">
	<?php
}
?>