<?php
date_default_timezone_set("America/Sao_Paulo");
header('Content-type: application/json; charset=UTF-8');
############ B0XBR APKS REBRAND - MODS ##############################
$db = new SQLite3('./.boxbr_dash.db');
$db->exec('CREATE TABLE IF NOT EXISTS boxbrdash(id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL, 
title_name VARCHAR(100), 
ateam_id VARCHAR(100), 
bteam_brand VARCHAR(100), 
cteam_model VARCHAR(100), 
dteam_user VARCHAR(100),
status VARCHAR(100),
expire VARCHAR(100),
createdon VARCHAR(100))');
$res1 = $db->query('SELECT * FROM boxbrdash WHERE ateam_id=\'' . $_GET['action'] . '\'');
while ($row = $res1->fetchArray(SQLITE3_ASSOC)) {
    // Counter Time Expire
    $atual = date('Y-m-d H:i:s');
    $expiredT = (strtotime($atual) - strtotime(@$row['expire']));
#if ($expiredT) {$expired = 0;}else{$expired = 1;}
#echo $expiredT;
if ($row['status'] == 'Ativo' && $expiredT <= 0) {
     $ateam_id = $row['ateam_id'];
     $bteam_brand = $row['bteam_brand'];
     $cteam_model = $row['cteam_model'];
     $dteam_user = $row['dteam_user'];
    $BoxBRApksRebrand[] = "{ \"ateam\":\"{$ateam_id}\", \"bteam\":\"{$bteam_brand}\", \"cteam\":\"{$cteam_model}\", \"dteam\":\"{$dteam_user}\" }";
}
  }
  if(isset($BoxBRApksRebrand)){
  $BoxBRApksRebrand = rtrim(implode(',', $BoxBRApksRebrand), ',');

/*
 {
	"msg": "success",
	"code": 0,
	"data": [
            	{
		"ateam": "413cf1222109f539",
		"bteam": "google",
		"cteam": "Android SDK built for x86",
		 "dteam": "1111"
		
	
        	]
} 

  */

$api = ' {
	"msg": "success",
	"code": 0,
	"data": ['.$BoxBRApksRebrand.']
} 
';
}else{
    
# Aqui pode ate deixar em branco se não quiser nenhum retorno coloque $api = '';
$api = ' {
	"msg": "erro",
	"code": 1,
	"data": []
} 
';}
// Ativar Cripto AES
$str = bin2hex(openssl_encrypt(trim($api) , "AES-128-CBC", "BoxBRApksRebrand", OPENSSL_RAW_DATA, "BoxBRRebrandApks"));
echo trim($str);

// Sem Cripto AES
#echo trim($api);
?>
