prepare('INSERT INTO licenses (license_key, owner_name, issued_at, download_entitlement_until, max_machines, notes) VALUES (?, ?, NOW(), ?, ?, ?)') ->execute([$newKey, $owner, $until . ' 23:59:59', $maxMachines, $notes]); $message = "License émise avec succès. Note la clé maintenant — elle ne sera plus jamais affichée."; break; } catch (PDOException $e) { if (str_contains($e->getMessage(), 'Duplicate')) { continue; } throw $e; } } } elseif ($action === 'revoke') { $id = (int)($_POST['id'] ?? 0); $db->prepare('UPDATE licenses SET revoked_at = NOW() WHERE id = ?')->execute([$id]); $message = "License #{$id} révoquée."; } elseif ($action === 'unrevoke') { $id = (int)($_POST['id'] ?? 0); $db->prepare('UPDATE licenses SET revoked_at = NULL WHERE id = ?')->execute([$id]); $message = "License #{$id} réactivée."; } elseif ($action === 'extend') { $id = (int)($_POST['id'] ?? 0); $newUntil = trim($_POST['new_until'] ?? ''); if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $newUntil)) { throw new Exception('Date invalide.'); } $db->prepare('UPDATE licenses SET download_entitlement_until = ? WHERE id = ?') ->execute([$newUntil . ' 23:59:59', $id]); $message = "License #{$id} prolongée jusqu'au {$newUntil}."; } elseif ($action === 'reset_machines') { $id = (int)($_POST['id'] ?? 0); $db->prepare('DELETE FROM license_machines WHERE license_id = ?')->execute([$id]); $message = "Machines libérées pour la license #{$id}."; } } catch (Exception $e) { $message = $e->getMessage(); $messageType = 'error'; } } $licenses = $db->query( 'SELECT l.*, (SELECT COUNT(*) FROM license_machines m WHERE m.license_id = l.id) AS machines_count FROM licenses l ORDER BY l.id DESC' )->fetchAll(); Layout::header('Licenses', 'licenses'); ?>
= htmlspecialchars($newKey) ?>
Elle est stockée hashée — la prochaine fois que tu rechargeras cette page elle ne sera plus visible.
| ID | Client | Émise | Expire | Machines | Statut | Actions |
|---|---|---|---|---|---|---|
| #= $l['id'] ?> |
= htmlspecialchars($l['owner_name']) ?>
= htmlspecialchars($l['notes']) ?>
|
= date('d/m/Y', strtotime($l['issued_at'])) ?> | = date('d/m/Y', strtotime($l['download_entitlement_until'])) ?> | = $l['machines_count'] ?> / = $l['max_machines'] ?> | = $status ?> |
Prolonger |
| Aucune license émise. | ||||||