<?php
session_start();
// ==================			  
include("../php_crud/my_class.php");



$obj = new my_class();
// ==================		
//echo "hello";
//exit;
$username = trim($_POST["username"]);
$password = md5(trim($_POST["password"]));
$username = str_replace("'", "", $username);

$password = str_replace("'", "", $password);

$active_flag_y='Y';
$table_name = 'ST_USER_INFO ';
$where_cond = "USER_LOGIN_ID='$username' AND USER_PASSWORD='$password' AND ACTIVE_FLAG='Y'";



//$where ="USER_LOGIN_ID=:username AND USER_PASSWORD=:password AND ACTIVE_FLAG=:active_flag_y ";
//$bind_value=[':username'=>$username,':password'=>$password ,':active_flag_y'=> $active_flag_y] ;



//echo 'SELECT * FROM '.$table_name.' WHERE '.$where_cond;

//exit;

$val = $obj->Login_Check($table_name, $where_cond);
//$val =$obj->Login_Check_bind($table_name,$where,$bind_value);
$flag = $val['USER_ID'];
//echo "hello";


if ($flag != 0 or $flag != "") {
	$_SESSION["valid"] = "true";

	$_SESSION["LOGIN_USER"] = $val['USER_FULL_NAME']; //$username;
	//$_SESSION["_image_location"] = isset($val['_image_location']) ? $val['_image_location'] : '';//$username;
	$_SESSION["_image_location"] = ''; //$username;
	$_SESSION["_full_name"] = isset($val['USER_FULL_NAME']) ? $val['USER_FULL_NAME'] : ''; // From pf_address_info
	$_SESSION["LOGIN_USERID"] = $val['USER_ID'];
	$_SESSION["LOGIN_EMPLOYEEID"] = $val['PID'];
	$_SESSION["LOGIN_USERGRP"] = $val['USER_GROUP_ID'];
	$_SESSION["LOGIN_INSTITUTE"] = $val['INSTITUTE_ID'];
	$_SESSION["LOGIN_BRANCHES"] = $val['BRANCH'];
	$_SESSION["LOGIN_IP"] = $_SERVER["REMOTE_ADDR"];
	$_SESSION["powred"] = 'leotechbd.com';

	//$_SESSION["BASE_URL"] ='http://202.161.188.108/school/schoobee/dev/development/app';
	$_SESSION["BASE_URL"] = '.';

	//$_SESSION["BASE_URL"] ='http://localhost:8088/schoobee'; 
	//$_SESSION["BASE_URL"] ='http://192.162.0.100:8088/schoobee'; 

	$_SESSION["LOGIN_TIME"] = date("Y-m-d H:i:s");

	echo 1;
} else {
	echo 0;
}
?>
