<?php
/**
 * strongswan_app_splash.php
 * DB의 is_active=1 레코드를 읽어 앱 스플래시 설정을 반환한다.
 * 관리: /adm/shop_admin/splash_config_form.php
 */
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-cache, no-store, must-revalidate');
header('X-Robots-Tag: noindex');

include_once(__DIR__ . '/_common.php');

$row = sql_fetch("SELECT * FROM app_splash_config WHERE is_active=1 ORDER BY updated_at DESC LIMIT 1", false);

if (!$row || empty($row['id'])) {
    echo json_encode(array('type'=>'default','url'=>'','duration_ms'=>2000,'skippable'=>false), JSON_UNESCAPED_UNICODE);
    exit;
}

echo json_encode(array(
    'type'        => $row['type'],
    'url'         => (string)$row['url'],
    'duration_ms' => (int)$row['duration_ms'],
    'skippable'   => (bool)(int)$row['skippable'],
), JSON_UNESCAPED_UNICODE);
