| Server IP : 167.235.67.158 / Your IP : 216.73.217.114 Web Server : Apache System : Linux ubuntu-8gb-nbg1-1 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/bc.the-word.com/ |
Upload File : |
<?php
header("Content-Type: application/json");
// Set default values.
$defaultPlaying = false;
// File path for the JSON status.
$file = __DIR__ . '/sketch-status.json';
// Attempt to load existing values from stack-status.json if it exists.
if (file_exists($file)) {
$jsonContent = file_get_contents($file);
$existingData = json_decode($jsonContent, true);
if (is_array($existingData)) {
if (isset($existingData['playing'])) {
// Use FILTER_VALIDATE_BOOLEAN to convert to boolean.
$defaultPlaying = filter_var($existingData['playing'], FILTER_VALIDATE_BOOLEAN);
}
}
}
// Retrieve query parameters.
$playing = isset($_GET['playing']) ? $_GET['playing'] : null;
// Prepare the data array using defaults.
$data = [
'playing' => $defaultPlaying
];
if ($playing !== null) {
$data['playing'] = (strtolower($playing) === 'true');
}
// Write the updated data to "stack-status.json".
if (file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT)) === false) {
http_response_code(500);
echo json_encode(["error" => "Failed to write to file."]);
exit;
}
// Output the JSON data.
echo json_encode($data, JSON_PRETTY_PRINT);
?>