managing licenses
This commit is contained in:
parent
1ce3baa5a2
commit
cc2f923ac2
@ -17,6 +17,7 @@ if (strpos($request_uri, '/activate') !== false) $endpoint = 'activate';
|
||||
if (strpos($request_uri, '/verify') !== false) $endpoint = 'verify';
|
||||
if (strpos($request_uri, '/deactivate') !== false) $endpoint = 'deactivate';
|
||||
if (strpos($request_uri, '/issue') !== false) $endpoint = 'issue';
|
||||
if (strpos($request_uri, '/list') !== false) $endpoint = 'list';
|
||||
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
@ -173,4 +174,28 @@ if ($endpoint === 'issue') {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($endpoint === 'list') {
|
||||
// Basic security check (Optional: You can use the secret here too)
|
||||
// For now, it fetches all licenses with their activation counts
|
||||
try {
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT l.*,
|
||||
(SELECT COUNT(*) FROM activations a WHERE a.license_id = l.id) as activations_count,
|
||||
(l.status = 'active') as is_active
|
||||
FROM licenses l
|
||||
ORDER BY l.created_at DESC
|
||||
");
|
||||
$stmt->execute();
|
||||
$licenses = $stmt->fetchAll();
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'data' => $licenses
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'error' => 'Failed to fetch licenses: ' . $e->getMessage()]);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['success' => false, 'error' => 'Invalid endpoint.']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user