true,CURLOPT_SSL_VERIFYPEER=>false,CURLOPT_TIMEOUT=>8]); $r = json_decode(curl_exec($ch),true); curl_close($ch); return $r['devices'] ?? []; } function vps_post(array $data): array { $ch = curl_init(VPS_API); curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>true,CURLOPT_POST=>true,CURLOPT_POSTFIELDS=>http_build_query($data),CURLOPT_SSL_VERIFYPEER=>false,CURLOPT_TIMEOUT=>8]); $r = json_decode(curl_exec($ch),true); curl_close($ch); return $r ?? []; } $msg = ''; $msgOk = true; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $uid = preg_replace('/[^0-9A-Fa-f]/', '', $_POST['uid'] ?? ''); if (!$uid) { $msg = 'UID invalido.'; $msgOk = false; } else { $res = vps_post($_POST); if (!empty($res['ok'])) { $msg = "[$uid] {$_POST['action']} OK"; } else { $msg = $res['error'] ?? 'Erro'; $msgOk = false; } } $qs = $msg ? ($msgOk ? '?ok='.urlencode($msg) : '?err='.urlencode($msg)) : ''; header("Location: /esp_vps.php$qs"); exit; } if (isset($_GET['ok'])) { $msg = htmlspecialchars($_GET['ok']); $msgOk = true; } if (isset($_GET['err'])) { $msg = htmlspecialchars($_GET['err']); $msgOk = false; } $devices = vps_get(); usort($devices, function($a,$b){ return strcmp((string)($a['uid']??''),(string)($b['uid']??'')); }); $title = "ESP Devices — VPS"; ob_start(); ?>
Sem dispositivos ou erro a ligar a VPS.
| UID | Versão | Versão | Online | Estado | Ultimo contacto | Brilho | Broker | |
|---|---|---|---|---|---|---|---|---|
| = h($uid) ?> | = ($d['fw']??'')!=='' ? h($d['fw']) : '—' ?> | = h($d['fw_ver'] ?? '—') ?> | onlineoffline | bloqueadoaprovadopendente | = h($last) ?> = $ago ?> |
>
= $bri ?>
|
V P |