<?php
session_start();
header("Connection: Keep-alive");
header("access-control-allow-origin: *");
header('X-XSS-Protection: 1; mode=block');
if($_SESSION['id_user']){
	$level=$_SESSION['level'];
	require_once('inc/dbcon.php');
	require_once('inc/function.php');
	require_once('inc/config.php');
	$now=date('Y-m-d H:i:s');
	foreach($_GET as $p => $v){
		${$p}=$v;
	}
	if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
		header('Content-type: application/json');
		ob_start();
		if(is_file('view/'.$level.'/v_'.$page.'.php')){
			require_once('view/'.$level.'/v_'.$page.'.php');
		}else{
			require_once('view/'.$level.'/v_home.php');
		}
		$html = ob_html_compress(ob_get_contents());
		ob_end_clean();
		$data = array('page'=>$page,'title'=>getTitle($page),'html'=>$html);
		echo json_encode($data);
	}else{
		header('Content-type: text/html');
		ob_start("ob_html_compress");
		if(is_file('view/'.$level.'/v_'.$page.'.php')){
			require_once('view/'.$level.'/v_'.$page.'.php');
		}else{
			require_once('view/'.$level.'/v_home.php');
		}
		ob_end_flush();
	}
}
?>