<?php
include '../config/database.php';
function _login($gid,$product,$version){
	$conn = _connectDB();
	$sql_get = "SELECT gid FROM free_bot WHERE product='".$product."' AND gid='".$gid."'";
	$result = $conn->query($sql_get);
	$status = false;
	if ((int)$result->num_rows == 0) {
		//INSERT
		$sql_insert = "INSERT INTO free_bot (gid,product,version) VALUES ('".$gid."','".$product."','".$version."');";
		$query_insert = $conn->query($sql_insert);
		$status = true;
	}
	return $status;
}
$_status =  false;
if( isset($_GET['gid']) OR isset($_GET['p']) OR isset($_GET['v'])){
	$_status = _login($_GET['gid'],$_GET['p'],$_GET['v']);
	echo json_encode(['status'=> $_status]);
}else{
	echo json_encode(['status'=> $_status]);
}


// Array
// (
//     [gid] => cc7a4032f71810699742a58cc3c3bb044
//     [p] => TAG
//     [v] => V01
// )