Release
This commit is contained in:
28
web/api/limits_set.php
Normal file
28
web/api/limits_set.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require __DIR__ . '/../lib/app.php';
|
||||
auth_require();
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$raw = file_get_contents('php://input');
|
||||
$in = json_decode((string)$raw, true);
|
||||
if (!is_array($in)) {
|
||||
echo json_encode(['ok' => false, 'error' => 'bad json']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$cap_gb = max(0, (int)($in['cap_gb'] ?? 0));
|
||||
$cap_reset_day = min(28, max(1, (int)($in['cap_reset_day'] ?? 1)));
|
||||
$rate_mbps = max(0, (int)($in['rate_mbps'] ?? 0));
|
||||
|
||||
$cfg = app_load_config();
|
||||
$cfg['cap_gb'] = $cap_gb;
|
||||
$cfg['cap_reset_day'] = $cap_reset_day;
|
||||
$cfg['rate_mbps'] = $rate_mbps;
|
||||
|
||||
if (!app_save_config($cfg)) {
|
||||
echo json_encode(['ok' => false, 'error' => 'save failed']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['ok' => true]);
|
||||
Reference in New Issue
Block a user