Files
Wallos/endpoints/settings/fixer_usage.php
Miguel Ribeiro 11eaf402e8 feat!: complete ui overhaul (#1108)
feat: option for the week to start on sunday
feat: redesign login / registration pages
feat: more statistics
feat: declarative oidc settings
feat: grid view for subscriptions
feat: subscription details popup
feat: translate categories with ai
feat: google image search with serpapi
feat: selfh.st image search
feat: dashboard icons image search
fix: improve background removal feature for logos
feat: v2.0 api - write endpoints
fix: include todays subscriptions on amount due this month
fix: calendar occurrences to respect subscription start date
fix: honor configured outbound proxy for logo search without reopening httpoxy SSRF bypass
fix: remove hardcode string from the admin page
fix: ssrf via http proxy env var in payments logo search
fix: require cron auth guard on storetotalyearlycost.php
fix: validate per-user smtp host against ssrf
fix: escape iCal property values to prevent crlf injection
2026-07-11 23:54:52 +02:00

30 lines
1.0 KiB
PHP

<?php
require_once '../../includes/connect_endpoint.php';
header('Content-Type: application/json');
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
die(json_encode(["success" => false]));
}
// Usage is only available for the apilayer provider; it is captured from the
// response headers of rate updates, so this endpoint never calls the API.
if ($db->querySingle("SELECT COUNT(*) FROM pragma_table_info('fixer') WHERE name='usage_used'") == 0) {
die(json_encode(["success" => false]));
}
$stmt = $db->prepare("SELECT provider, usage_used, usage_limit FROM fixer WHERE user_id = :userId");
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
$result = $stmt->execute();
$row = $result ? $result->fetchArray(SQLITE3_ASSOC) : false;
if (!$row || (int) $row['provider'] !== 1 || $row['usage_used'] === null || !$row['usage_limit']) {
die(json_encode(["success" => false]));
}
die(json_encode([
"success" => true,
"used" => (int) $row['usage_used'],
"total" => (int) $row['usage_limit'],
]));