<?php
$kodeku=cegah($_GET["hkode"]);

$filenya = base_url()."/android1212/i_deteksi";
$filenyax = base_url()."/android1212/i_deteksi";
$judul = "Deteksi Hardware";
$juduli = $judul;

$ku_hkode=$_GET['hkode'];
$tiga=$this->db->query("SELECT * from web_login where hkode='$ku_hkode'");
foreach ($tiga->result() as $rt) {
	$sesiku=$rt->sesiku;
	$sesinama=$rt->sesinama;
	$passx=$rt->passx;
	$departemen=$rt->departemen;
	$kd6_session=$rt->sesiku;
	$kodeabsen = $rt->sesiku;
	
}
if ((isset($_GET['aksi']) && $_GET['aksi'] == 'gpspalsu'))
	{
		?>
		<script language='javascript'>
		//membuat document jquery
			$(document).ready(function(){
					window.location.href = "gpspalsu.html";
			});
		</script>
		<?php
	}

if ((isset($_GET['aksi']) && $_GET['aksi'] == 'deteksi'))
	{
		if (!empty($passx))
		{
			//biarkan semua HP bisa untuk absen
	    $hkode = cegah($_GET["hkode"]);
			$ckode=$this->db->query("SELECT * from web_siswa where hardware_kode='$hkode'");
			$jkode=$ckode->num_rows();
			if ($jkode == 0)
			{
				$ceksiswa=$this->db->query("SELECT hardware_kode FROM web_siswa WHERE absen='$sesiku'");
				foreach ($ceksiswa->result() as $rt1) {
					$hardkode=$rt1->hardware_kode;
				}
				if (!empty($hardkode)) {
					?>
					<script language='javascript'>
					//membuat document jquery
						$(document).ready(function(){
								window.location.href = "deteksi.html";
						});
					</script>
					<?php
				} else {
					$this->db->query("UPDATE web_siswa SET hardware_kode='$hkode' WHERE absen='$sesiku'");
				}

			} else {
				$ckode1=$this->db->query("SELECT * from web_siswa where hardware_kode='$hkode' AND absen='$sesiku'");
				$jkode1=$ckode1->num_rows();
				//echo "<script>alert('".$jkode1."');</script>";
			 	if ($jkode1 == 1) {

				} else {
					?>
					
					<script>
					alert('Anda telah ganti HP atau ganti akun di HP yang sama\nMaka akan Otomatis logout\n\nHubungi admin');
					$(document).ready(function(){
								window.location.href = "akun_logout.html";
						});
					</script>
					<?php
				}
			} 
		}
  }
?>
