<?php
include "../db/dBase.php";
$dbase = new dBase();
$tcon = $dbase->con;
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");


if (isset($_GET['apikey'])) {
    $key_ = mysqli_real_escape_string($tcon, $_GET['apikey']);
    $key=md5($key_);
    // check API Validity
    $query_API = "SELECT `id` FROM `access_log` WHERE `token`='$key' ";
    $api_n = $dbase->countQuery($query_API); 
    if($api_n == 1) {
        $spit = array('EE' => 'GOOD');
    }else{ $spit = array('EE' => 'BAD'); }
} else{ $spit = array('EE' => 'BAD'); }
echo json_encode(array_filter($spit));
