<?php
declare(strict_types=1);
require_once __DIR__.'/common.php';
apiMethod('POST');
$cfg=apiCfg($mysqli);$device=apiAuth($mysqli);$id=(int)$device['id'];$ip=apiIp();
$stmt=$mysqli->prepare('UPDATE ti_mobile_dispositivos SET ultima_comunicacao=NOW(),ultimo_ip_remoto=? WHERE id=?');$stmt->bind_param('si',$ip,$id);$stmt->execute();$stmt->close();
apiOut(200,['ok'=>true,'server_time'=>date(DATE_ATOM),'sync_interval_min'=>(int)($cfg['sync_interval_min']??30),'collect_apps'=>(bool)($cfg['collect_apps']??1),'tracked_apps'=>apiTrackedApps($mysqli)]);
?>
