<?php
session_start();
header('Content-Type: application/json');
error_reporting(0);

require_once __DIR__ . '/../../function/connect.php';

if (empty($_SESSION['extplayer'])) {
  echo json_encode(['status' => 'error', 'code' => 'NO_SESSION']);
  exit;
}

$extplayer = mysqli_real_escape_string($koneksi, $_SESSION['extplayer']);

$q = mysqli_query($koneksi, "
  SELECT COUNT(*) AS total
  FROM tb_transaksi
  WHERE id_user = '$extplayer'
    AND transaksi = 'Top Up'
    AND status = 'Sukses'
");

if (!$q) {
  echo json_encode(['status' => 'error', 'code' => 'QUERY_FAIL']);
  exit;
}

$d = mysqli_fetch_assoc($q);

echo json_encode([
  'status' => ((int)$d['total'] > 0) ? 'ok' : 'no_deposit'
]);
exit;