[], 'error'=>'Please log in.']); exit; } $Request = ['SESSION'=>['PHPSESSID'=>$_POST['DUMMYSESSID'], 'REMOTE_ADDR'=>$_SERVER['REMOTE_ADDR'] ?? '']]; $Response = []; require_once __DIR__.'/Home_include.php'; PAWebAdminSessionInfo($Request,$Response); if ((int)($Response['SESSION']['Active'] ?? 0) !== 1) { http_response_code(401); echo json_encode(['data'=>[], 'error'=>'Session expired. Please log in again.']); exit; } require_once __DIR__.'/PA_WEB_IDLE_DEVICES_DATA.php'; try { $rows=[]; $count=0; $error=''; $status=''; PACommonDBSelectMultipleRecords(PAIdleDevicesSQL(),$rows,$count,$error,$status); if (!empty($error)) throw new RuntimeException('Idle device query failed'); echo json_encode(['data'=>$rows ?? [], 'updatedAt'=>gmdate('Y-m-d H:i:s')], JSON_INVALID_UTF8_SUBSTITUTE); } catch (Throwable $error) { error_log('[PART_IDLE_DEVICES] Query failed: '.get_class($error)); http_response_code(500); echo json_encode(['data'=>[], 'error'=>'Unable to load idle devices. Please retry.']); }