<?php require_once __DIR__.'/../includes/functions.php'; header('Content-Type: application/json');
$resource=$_GET['resource']??'status';
if($resource==='countries'){ echo json_encode(all_rows('SELECT id,iso2,name,slug,currency_code,timezone_default,is_active FROM mj_countries WHERE is_active=1 ORDER BY name')); exit; }
if($resource==='listings'){ echo json_encode(all_rows('SELECT id,title,price,currency_code,country_id,created_at FROM mj_listings WHERE status="active" ORDER BY id DESC LIMIT 50')); exit; }
if($resource==='companies'){ echo json_encode(all_rows('SELECT id,name,country_id,is_verified,created_at FROM mj_companies WHERE status="active" ORDER BY id DESC LIMIT 50')); exit; }
echo json_encode(['ok'=>true,'app'=>'MJ Marketplace Global Pro','time'=>date('c')]);
