<?php
// Firebase Realtime Database URL
$firebaseUrl = "https://vertexstore-110fd.firebaseio.com/Power.json";

// Fetch the data using file_get_contents
$response = file_get_contents($firebaseUrl);

// Handle errors
if ($response === FALSE) {
    die("❌ Error: Unable to fetch data from Firebase.");
}

// Decode the JSON response
$data = json_decode($response, true);

// Check if data exists
if (!$data) {
    die("❌ Error: No valid data found.");
}

// Display the data as HTML
echo "<h2>🔥 Data from Firebase [Power]</h2>";
echo "<ul>";
echo "<li><strong>myString:</strong> " . htmlspecialchars($data['myString']) . "</li>";
echo "<li><strong>myInt:</strong> " . htmlspecialchars($data['myInt']) . "</li>";
echo "<li><strong>myFloat:</strong> " . htmlspecialchars($data['myFloat']) . "</li>";
echo "<li><strong>myBool:</strong> " . ($data['myBool'] ? "True" : "False") . "</li>";
echo "</ul>";

// Optional: Auto-refresh every 5 seconds
echo '<meta http-equiv="refresh" content="5">';
?>
