<?php

// simple shared token
$token = '6oz4OsFY2gShPmpMYlbmf9ZuYBtIPO3s35JWThJmYk';

if (!isset($_GET['token']) || $_GET['token'] !== $token) {
    http_response_code(403);
    exit('Forbidden');
}

$path = '/';

$total = disk_total_space($path);
$free  = disk_free_space($path);
$used  = $total - $free;

$percent = round(($used / $total) * 100, 2);

header('Content-Type: application/json');

echo json_encode([
    'hostname' => gethostname(),
    'used_percent' => $percent,
    'total_gb' => round($total / 1024 / 1024 / 1024, 2),
    'free_gb'  => round($free / 1024 / 1024 / 1024, 2),
    'time' => date('c')
]);
