<?php
session_start();
header("Connection: Keep-alive");
header("access-control-allow-origin: *");
header('X-XSS-Protection: 1; mode=block');
header('Content-type: application/json');
require_once('inc/dbcon.php');
require_once('inc/function.php');
ob_start('ob_html_compress');
if($_SESSION['id_user']){
	if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
		$level=$_SESSION['level'];
		filterPost($connect);
		date_default_timezone_set('Asia/Jakarta');
		$now=date('Y-m-d H:i:s');
		$p=$_POST['p'];
		if(isset($p)){
			header('Content-type: application/json');
			if(is_file('model/'.$level.'/m_'.$p.'.php')){
				require_once('model/'.$level.'/m_'.$p.'.php');
			}else{
				$data = array('status'=>0,'msg'=>'404 Not found!');
				echo json_encode($data);
			}
		}
	}else{
		$data = array('status'=>0,'msg'=>"403 Access denied!\nGunakan XMLHttpRequest");
		echo json_encode($data);
	}
}else{
	$data = array('status'=>0,'msg'=>"401 Unauthorized error!\nSilahkan Login");
	echo json_encode($data);
}
ob_end_flush();
mysqli_close( $connect );
?>