<?php ob_start();session_start();
$time_start = microtime(true);//get time start run script
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
require_once "../lib/php/autoload.php";

if(empty($_SESSION['sfd_user_id']))
{
	header("location:sfdSignOut.php?i=".rand());
	exit;
}

$DB=new DB();
$Msg=new Msg();
$Func=new Func();
$Jdf=new Jdf();
$Encryption=new Encryption();

$sfd_user_id=$SfdUserId=$sfdUserId=$Encryption->decode($_SESSION['sfd_user_id']);
define("sfd_user_id",$sfd_user_id);

if(!is_numeric($sfd_user_id))
	exit("error: user id is not valid");

	
if(!empty($_SESSION['admin']))
{
	if($sfd_user_id==$Encryption->decodeAdmin($_SESSION['admin']))
	{
		$Admin=$admin=true;
		define("admin",true);
	}
	else
	{
		$Admin=$admin=false;
		define("admin",false);
	}
}
else
{
	$Admin=$admin=false;
	define("admin",false);
}


//define table name var for make easy query!
$tbl_class=$DB->tablePrefix."class";
$tbl_class_student=$DB->tablePrefix."class_student";
$tbl_exam=$DB->tablePrefix."exam";
$tbl_exam_class=$DB->tablePrefix."exam_class";
$tbl_exam_question=$DB->tablePrefix."exam_question";
$tbl_exam_question_type=$DB->tablePrefix."exam_question_type";
$tbl_exam_result=$DB->tablePrefix."exam_result";
$tbl_logins=$DB->tablePrefix."logins";
$tbl_sfd_users=$DB->tablePrefix."sfd_users";
$tbl_student_answer=$DB->tablePrefix."student_answer";
$tbl_upload_files=$DB->tablePrefix."upload_files";

$_setting=parse_ini_file("settingAdmin.ini");
