<?php 
header("Access-Control-Allow-Headers: Authorization, Content-Type");
header("Access-Control-Allow-Origin: *");
include("confiq.php");
$koneksi=open_connection2();
$username =addslashes(mysqli_real_escape_string($koneksi,$_GET['email']));
$password2=addslashes(mysqli_real_escape_string($koneksi,$_GET['password']));
$api=addslashes(trim($_GET['api']));

$pass = md5($password2);
$task="34567fghjkl;FGHJK09865fghjs12345@#$@#$!@#"; 	
																			
$pasw=$pass.$username.$task;
$password = md5($pasw);   
if(isset($_GET['api']))
{
    if($api=='AIzaSyARSSmIJjL5LuxZnrjkDnrD')
    {
        $query2 = "SELECT * FROM tbregistrasi WHERE (email='$username') and (password='$password')";
		$sql2 = mysqli_query($koneksi,$query2);
		$data2 = mysqli_fetch_array($sql2);
		$jum=mysqli_num_rows($sql2);	
		$iduser=$data2["nis"];
if($jum<>0)
			{
			$npsn=$data2["npns"];
		   // $koneksi_kantin=koneksi_kantin($npsn);
		   
		   // $sql_kantin = mysqli_query($koneksi_kantin,"SELECT * FROM tb_user WHERE  (id='".$data2["nis"]."')");
		   // $row_kantin = mysqli_fetch_array($sql_kantin);
		    
		    
		    $MyJson['kategori']=$data2["kat"];
            $MyJson['iduser']=$data2["nis"];
            $MyJson['nama']=$data2["nama_siswa"];
             $MyJson['sekolah']=$data2["nama_sekolah"];
            $MyJson['email']=$data2["email"];
            //$MyJson['profile']=$data2["profile"];
			//$MyJson['tgl']=$data2["tgl"];
            $MyJson['npsn']=$data2["npns"];
            
          
            $MyJson['password']=$password2;
            $MyJson['tokenid']=$data2["nis"];
            $MyJson['key']=md5($task.$iduser);
            $MyJson['status']='00';
            echo json_encode($MyJson);
}else {
            $MyJson['email']=$username;
            $MyJson['password']=$password2;
            $MyJson['status']='01';
            echo json_encode($MyJson);  
      }
} //end api
}  //end get api      
mysql_close();
?>