From 590f247c083db93cb1085ad3c16d2ef5b6a29191 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 20 Feb 2026 14:04:38 +0000 Subject: [PATCH] updating license issuing --- index.php | 10 -- license_manager/manage.php | 221 +++++++++++++++++++++++++++++++++++++ 2 files changed, 221 insertions(+), 10 deletions(-) create mode 100644 license_manager/manage.php diff --git a/index.php b/index.php index 33afa5d..0790992 100644 --- a/index.php +++ b/index.php @@ -2009,7 +2009,6 @@ $page_permissions = [ 'logs' => 'logs_view', 'cash_registers' => 'cash_registers_view', 'register_sessions' => 'register_sessions_view', - 'licenses' => 'licenses_view', ]; if (isset($page_permissions[$page]) && !can($page_permissions[$page])) { @@ -2101,7 +2100,6 @@ $permission_groups = [ 'users' => 'Users', 'cash_registers' => 'Cash Registers', 'register_sessions' => 'Register Sessions', - 'licenses' => 'Licenses', 'logs' => 'System Logs' ] ]; @@ -2782,11 +2780,6 @@ switch ($page) { $data['cash_registers'] = db()->query("SELECT * FROM cash_registers WHERE status = 'active'")->fetchAll(); $data['users'] = db()->query("SELECT id, username FROM users ORDER BY username ASC")->fetchAll(); break; - case 'licenses': - $res = LicenseService::listLicenses(); - $data['licenses'] = $res['success'] ? $res['data'] : []; - $data['license_error'] = $res['success'] ? '' : ($res['error'] ?? 'Failed to fetch licenses.'); - break; default: $data['customers'] = db()->query("SELECT * FROM customers ORDER BY id DESC LIMIT 5")->fetchAll(); $data['stats'] = [ @@ -3119,9 +3112,6 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; - - - diff --git a/license_manager/manage.php b/license_manager/manage.php new file mode 100644 index 0000000..b081eb7 --- /dev/null +++ b/license_manager/manage.php @@ -0,0 +1,221 @@ + + + + + + + License Admin Login + + + + +
+

License Manager

+
+
+ + +
+ +
+ +
Invalid password
+ +
+ + + prepare("UPDATE licenses SET status = ? WHERE id = ?"); + $stmt->execute([$new_status, $id]); + $message = "License status updated to $new_status."; + break; + + case 'delete_license': + $id = (int)$_POST['id']; + $stmt = $pdo->prepare("DELETE FROM licenses WHERE id = ?"); + $stmt->execute([$id]); + $message = "License deleted successfully."; + break; + + case 'issue': + $prefix = strtoupper(trim($_POST['prefix'] ?? 'FLAT')); + $max_activations = (int)($_POST['max_activations'] ?? 1); + $key = $prefix . '-' . strtoupper(bin2hex(random_bytes(2))) . '-' . strtoupper(bin2hex(random_bytes(2))) . '-' . strtoupper(bin2hex(random_bytes(2))); + + $stmt = $pdo->prepare("INSERT INTO licenses (license_key, max_activations, status) VALUES (?, ?, 'active')"); + $stmt->execute([$key, $max_activations]); + $message = "New license issued: $key"; + break; + } + } +} + +// Fetch Licenses +$licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC")->fetchAll(); +?> + + + + + + Manage Licenses + + + + + + + + +
+ + + + +
+ +
+
+
Issue New License
+
+ +
+ + +
+
+ + +
+ +
+
+
+ + +
+
+
+
Existing Licenses
+ Total +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
KeyActivationsStatusCreatedActions
+ prepare("SELECT COUNT(*) FROM activations WHERE license_id = ?"); + $stmt->execute([$l['id']]); + $count = $stmt->fetchColumn(); + ?> + / + + + + + +
+
+ + + + +
+
+ + + +
+
+
No licenses found.
+
+
+
+
+
+ + + +