<?php
require("config/koneksi.php");
require("config/function.php");
require("config/crud.php");

$token = isset($_GET['token']) ? $_GET['token'] : 'false';
$idn = isset($_GET['idn']) ? $_GET['idn'] : 'false';
$idu = isset($_GET['idu']) ? $_GET['idu'] : 'false';
$ids = isset($_GET['ids']) ? $_GET['ids'] : 'false';
$querys = mysqli_query($koneksi, "select token_api from aplikasi where token_api='$token'");
$cektoken = mysqli_num_rows($querys);

if ($cektoken <> 0) {

    $sql_idn = '';
    if (!empty($idn)) {
        $sql_idn = " where idnilai='$idn' AND idsiswa='$ids' AND idujian='$idu'";
    }
    $query = mysqli_query($koneksi, "select * from reset " . $sql_server);
    $array_data = array();
    while ($baris = mysqli_fetch_assoc($query)) {
        $array_data[] = $baris;
    }

    echo json_encode([
        'cek' => $array_data
    ]);
	sleep(10);
	delete($koneksi,'reset',['idsiswa'=>$ids]);
} else {
    echo "<script>location.href='.'</script>";
}
