<?php
error_reporting(0);
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();
session_start();
session_cache_limiter('private');
$cache_limiter 	= session_cache_limiter();
session_cache_expire(60);
$cache_expire 	= session_cache_expire(); 
date_default_timezone_set('Asia/Manila'); 
$CURRENT_DATE 	= date('Y-m-d H:i:s');
include_once('../config/minho.php');
include_once('../config/autoloadClass.php');
$autoload	 	=	new autoloadClass(); 
$users			=	new userClass();
$usertype 		= 	"";
if(isset($_POST['email']) && isset($_POST['pass'])){
$email			= isset($_POST['email']) ? htmlentities(addslashes(strip_tags(trim($_POST['email'])))) : ""; 
$password		= isset($_POST['pass']) ? htmlentities(addslashes(strip_tags(trim($_POST['pass'])))) : ""; 
$url = ""; 
$output = $users->checkUserAccess($email,$password);
if($output==true){
	$url = "index";
	$out = true;
	$details	=	array();
	$details 	=	$users->getUserDetails($email);
	$_SESSION['castalia_userid'] 		= $details['Id'];
	$_SESSION['castalia_firstname']		= $details['FirstName'];
	$_SESSION['castalia_lastname'] 		= $details['LastName'];
	$_SESSION['castalia_username']	 	= $details['Username'];
	$_SESSION['castalia_email']	 		= $details['EmailAddress'];
	$_SESSION['castalia_user_type']	 	= $details['UserType'];
	$_SESSION['castalia_project']	 	= "Villa Castalia";
	$_SESSION['castalia_project_venue'] = "";
	$_SESSION['castalia_log'] 			= "yes";
	
	/*
	* For release broker type (Danville E and Villa Castalia) will be template1 while (Danville S) will be template2
	*/
	$_SESSION['castalia_release_broker_type'] = "template1";  //(Danville E and Villa Castalia)
	//$_SESSION['castalia_release_broker_type'] = "template2";  //(Danville S) 

}else{
	$url = "index";
	$out = false;
} 
$resultArr 						= array();
$resultArr['output']	  		= $out; 
$resultArr['path']		  		= $url; 
echo json_encode($resultArr);
}
exit();
ob_end_flush();