30 lines
1.0 KiB
PHP
30 lines
1.0 KiB
PHP
<?php
|
|
// V79 Vault Stats Wrapper - adds bytes/size/size_kb aliases without touching immutable wevia-vault.php
|
|
// Doctrine #14: enrichissement additif zero ecrasement
|
|
header('Content-Type: application/json');
|
|
|
|
$action = $_GET['action'] ?? 'stats';
|
|
$ch = curl_init("http://127.0.0.1/api/wevia-vault.php?action=" . urlencode($action));
|
|
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, CURLOPT_SSL_VERIFYPEER => false]);
|
|
$body = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
$d = @json_decode($body, true);
|
|
if (!is_array($d)) {
|
|
echo json_encode(['error' => 'upstream error', 'raw' => substr($body, 0, 200)]);
|
|
exit;
|
|
}
|
|
|
|
// Add aliases if action=stats
|
|
if ($action === 'stats' && isset($d['total_bytes'])) {
|
|
$b = (int)$d['total_bytes'];
|
|
$d['bytes'] = $b;
|
|
$d['size'] = $b;
|
|
$d['size_kb'] = round($b / 1024);
|
|
$d['size_mb'] = round($b / 1024 / 1024, 2);
|
|
$d['size_human'] = $b >= 1048576 ? round($b/1048576,1) . ' MB' : round($b/1024) . ' KB';
|
|
$d['_v79_wrapper'] = true;
|
|
}
|
|
|
|
echo json_encode($d);
|