| Server IP : 167.235.67.158 / Your IP : 216.73.216.95 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.
$defaultThreshold = 220;
$defaultRunning = false;
// File path for the JSON status.
$file = __DIR__ . '/stack-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['threshold']) && is_numeric($existingData['threshold'])) {
$defaultThreshold = (float)$existingData['threshold'];
}
if (isset($existingData['running'])) {
// Use FILTER_VALIDATE_BOOLEAN to convert to boolean.
$defaultRunning = filter_var($existingData['running'], FILTER_VALIDATE_BOOLEAN);
}
}
}
// Retrieve query parameters.
$threshold = isset($_GET['threshold']) ? $_GET['threshold'] : null;
$running = isset($_GET['running']) ? $_GET['running'] : null;
// Prepare the data array using defaults.
$data = [
'threshold' => $defaultThreshold,
'running' => $defaultRunning
];
// Override defaults if query parameters are provided.
if ($threshold !== null && is_numeric($threshold)) {
$data['threshold'] = (float)$threshold;
}
if ($running !== null) {
$data['running'] = (strtolower($running) === '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);
?>