[ 'verify_peer' => false, 'verify_peer_name' => false, ], ]); } } $response = @file_get_contents($endpointUrl, false, $context ?: null); if ($response === false && strcasecmp($scheme, 'https') === 0) { $fallbackUrl = preg_replace('#^https#i', 'http', $endpointUrl); $response = @file_get_contents($fallbackUrl); if ($response !== false) { $endpointUrl = $fallbackUrl; } } if ($response === false) { throw new RuntimeException('Unable to reach shared endpoint: ' . $endpointUrl); } try { $payload = json_decode($response, true, flags: JSON_THROW_ON_ERROR); } catch (JsonException $exception) { throw new RuntimeException('Malformed JSON from shared endpoint', 0, $exception); } if (($payload['status'] ?? null) !== 'ok') { $message = $payload['message'] ?? 'unknown error'; throw new RuntimeException('Shared endpoint returned an error: ' . $message); } if (!isset($payload['items']) || !is_array($payload['items'])) { $snippet = substr(strip_tags($response), 0, 200); throw new RuntimeException('Shared endpoint response missing items. Snippet: ' . $snippet); } foreach ($payload['items'] as $item) { $tagKey = str_pad((string) $item['tagId'], 5, '0', STR_PAD_LEFT); $value[$item['name']] = $item['value']; $rounded[$item['name']] = $item['rounded1']; $rounded1[$item['name']] = $item['rounded2']; $roundedid[$tagKey] = $item['rounded2']; $ID[$tagKey] = $item['value']; } $endpointDataLoaded = true; } catch (Throwable $exception) { $endpointErrorMessage = $exception->getMessage(); error_log('Milling shared endpoint failed: ' . $endpointErrorMessage); } $dataSourceLabel = 'Shared endpoint'; if (!$endpointDataLoaded) { require __DIR__ . '/../items.php'; require __DIR__ . '/../items2dec.php'; $dataSourceLabel = 'Legacy items.php data'; } // Helper function for rendering data rows function renderDataRow($label, $value, $unit = "") { $safeValue = htmlspecialchars($value); return "
|
Data source:
Endpoint error: |
|||
| Scale Data | |||
| Cane In Today: | Tons | ||
| Cane In Yesterday: | Tons | ||
| YTD Cane Total Tons: | Tons | ||
| Overview | |||
| Vapor 2: | PSI | ||
| Tank Levels | |||
| Total Syrup Level: | |||
| Total A1 Molasses: | |||
| Total A2 Molasses: | |||
| Total B Molasses: | |||