<?php
include("../db.php");
header('Content-Type: application/json');

  $admission = $_POST['admission_no'];
  $password = $_POST['password'];
  $session = $_POST['login_session'];

$pass = new password();
    $password = $pass->password(POST("password"));

$status = 0;
$idno = '';
$name = '';
$fname = '';
$class = '';
$section = '';
$institute_name = '';
$studyServer = '';
$photo = '';
//echo "select * from student where admissionno='".$admission."' and password='".$password."' limit 1 ";
$getData = $db->getRow("select * from student where admissionno='".$admission."' and password='".$password."' and session='".$session."' limit 1 ");

 if(count($getData)>1){
     $status=1;
     $idno = $getData['idno'];
     $name = $getData['name'];
     $fname = $getData['fname'];
     $class = $getData['class'];
     $section = $getData['section'];
     $photo = $getData['photo'];
 }
 else {
     $status= 0;
 }

    	$aryReturn=array();
		$arySetData=$db->getRows("select * from settings");
		if(is_array($arySetData) && count($arySetData)>1)
		{
			foreach($arySetData as $iSetData)
			{
				$aryReturn[$iSetData['field']]=$iSetData['value'];
			}
		}
		$institute_name = $aryReturn['site_name'];
		
		$studyserver = $db->getVal("select online_study_server from tbl_info");

 $array = array("status"=>$status, "institute_name"=>"$institute_name", "name"=>"$name",  "fname"=>"$fname", "class"=>"$class", "section"=>"$section", "idno"=>"$idno", "photo"=>"$photo", "study_server"=>"$studyserver");

 echo json_encode($array);
 
// $simple_string = json_encode($array);
// $ciphering = "AES-128-CTR"; 
// $iv_length = openssl_cipher_iv_length($ciphering); 
// $options = 0;
// $encryption_iv = '1234567891011121';
// $encryption_key = "GeeksforGeeks";
// $encryption = openssl_encrypt($simple_string, $ciphering,$encryption_key, $options, $encryption_iv); 

// echo $encryption;

?>