<?php
// DISPLAY ALL ERRORS
//error_reporting(E_ALL);
ini_set('display_errors', 0);
session_start();
// START & CONFIG
ob_start();
require 'setup/config.php';

$LANG =  'cn';
// SET LANGUAGE
if (isset($_GET['lang'])){	
	$_SESSION['HTTP_ACCEPT_LANGUAGE'] = $_GET['lang'];
}
if (isset($_SESSION['HTTP_ACCEPT_LANGUAGE']) and file_exists('lang/' . $_SESSION['HTTP_ACCEPT_LANGUAGE'] . '.php')) {	
	if((@include 'lang/' . $_SESSION['HTTP_ACCEPT_LANGUAGE'] . '.php') === false){
		echo 'Caught exception: Translate file is wrong';
	}else{
		@include_once('lang/' . $_SESSION['HTTP_ACCEPT_LANGUAGE'] . '.php');
	}
} else {
	if((@include 'lang/' . $LANG . '.php') === false){
		echo 'Caught exception: Translate file is wrong';
	}else{
		@include_once('lang/' . $LANG . '.php');
	}
}

// INI VARs
$found = 0;                     // MARKER HOW MANY HITS FOUND A SEARCH
$done = 0;                     // MARKER HOW MANY ENTRYs ARE DONE
$msg = '';                    // TOAST MESSAGE
$file = 'data/Product.json'; // DATA FILE NAME
// LOGIN CHECK

$login = check_current_user_login($ARR_USERS, $SALT);
$currentuser = $login['user'];
//var_dump($login);
if ($login['status'] == 200) {
    //var_dump($login);
	if( !in_array('越南',$currentuser->filelocation) && !in_array('中国',$currentuser->filelocation) && !in_array('泰国',$currentuser->filelocation) && !in_array('总公司',$currentuser->filelocation) ){
		header('location: login.php');
	}
} else {
    header('location: login.php');
    exit;
}



// HEADER
ob_end_flush();
?>
<style>
	body {
		opacity:0;
	}
	nav .brand-logo {
   
    margin-top: 16px!important;
}
main {
       padding: 0 10px!important;
    background: #eee;
}
.page-footer {
   padding-top: 0px; 
   
   
}
</style>
<?php

include 'tpl/header.php';


?>
<?php       
if($_GET['nocontrol'] == 1){	
?>
<style>
.navbar-fixed {
	display:none;
}
</style>
<script>

</script>
<?php } ?>
<script>


// within a window load,dom ready or something like that place your:


$(document).ready(function(){
	function checkCookie(){
    var cookieEnabled = navigator.cookieEnabled;
    if (!cookieEnabled){ 
        document.cookie = "testcookie";
        cookieEnabled = document.cookie.indexOf("testcookie")!=-1;
    }
    return cookieEnabled || showCookieFail();
	}

	function showCookieFail(){
	  // do something here
	  alert('Please turn on your cookie browser');
	  $("iframe").hide();
	}


	checkCookie();
	$('#sabkjdsa').on('load', function() {
		$("body").css('opacity','1');
		$(this).height($( 'main' ).height()-20);
		//javascript:(function(o){o.style.height=o.contentWindow.document.body.scrollHeight+"px";}(this));
	});
	setTimeout(function(){ 
		location.reload();
	}, 900000);
});
     
</script>            
<?php

$filelink = '';
				if( in_array('越南',$currentuser->filelocation) && in_array('中国',$currentuser->filelocation) && in_array('泰国',$currentuser->filelocation) ){
					$filelink = '/administrator/index.php?user=vn-cn-th&passw=$2y$10$TBPqGxQktF7JqTRu9HyvLOjO2GwuFjegd/eLg.ia095q.sgIQGohC';
				}elseif(in_array('越南',$currentuser->filelocation) && in_array('中国',$currentuser->filelocation)){
					$filelink = '/administrator/index.php?user=vn-cn&passw=$2y$10$f3rkKMOt6rn5Yj3g4KlvEOuBYEhxURowQ/E8DOWRHMAREYj3h2xim';
				}elseif(in_array('越南',$currentuser->filelocation) && in_array('泰国',$currentuser->filelocation)){
					$filelink = '/administrator/index.php?user=vn-th&passw=$2y$10$l3OtwTl64yjlGMQb9qFg8.jgEZh.P1xB7CodvhCvbndes7kQQ9usC';
				}elseif(in_array('中国',$currentuser->filelocation) && in_array('泰国',$currentuser->filelocation)){
					$filelink = '/administrator/index.php?user=cn-th&passw=$2y$10$kbvaPw7meaM1SXHxxuN.5uKEgxK6v8QMtJYugjFUbfoaLHwwT2Tl.';
				}elseif(in_array('中国',$currentuser->filelocation)){
					$filelink = '/administrator/index.php?user=cn&passw=$2y$10$Fk.gLKy8N1AdTmCdixsmrOer18eRE.sAzG63WTQ9wzmVzvcom16pq';
				}elseif(in_array('泰国',$currentuser->filelocation)){
					$filelink = '/administrator/index.php?user=th&passw=$2y$10$JRhyqEs83R6I5reIqz2AsOyMc2Ynx17DSHP2cn//CLnWXCmfa/xS6';
				}elseif(in_array('越南',$currentuser->filelocation)){
					$filelink = '/administrator/index.php?user=vn&passw=$2y$10$saQ96xSvbXkU.0dVYacfo.plEFf00zRZJjUexAe/Yqm73w6ibJdEC';
				}
				
 ?>
<iframe  id="sabkjdsa" src="<?php echo $filelink; ?>" style="width:100%;overflow:hidden;height:100%; box-shadow: 1px 6px 7px 2px rgba(0, 0, 0, 0.18);  " frameborder="0"  width="100%"></iframe>        
<?php
// var_dump($sortdate); die;
// FOOTER
include 'tpl/footer.php';
?>
