From 2ab1263a0663cc94a5b757e1cef94a18d6eac080 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 20 Feb 2026 15:02:03 +0000 Subject: [PATCH] editing license --- license_manager/database.sql | 9 +++-- license_manager/index.php | 27 +++++++++---- license_manager/manage.php | 77 ++++++++++++++++++++++++++++++++++-- 3 files changed, 99 insertions(+), 14 deletions(-) diff --git a/license_manager/database.sql b/license_manager/database.sql index 37a8578..1954f43 100644 --- a/license_manager/database.sql +++ b/license_manager/database.sql @@ -5,7 +5,10 @@ CREATE TABLE IF NOT EXISTS licenses ( id INT AUTO_INCREMENT PRIMARY KEY, license_key VARCHAR(255) UNIQUE NOT NULL, max_activations INT DEFAULT 1, + max_counters INT DEFAULT 1, status ENUM('active', 'suspended', 'expired') DEFAULT 'active', + owner VARCHAR(255), + address TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB; @@ -21,6 +24,6 @@ CREATE TABLE IF NOT EXISTS activations ( ) ENGINE=InnoDB; -- Seed some test data -INSERT INTO licenses (license_key, max_activations) VALUES ('FLAT-8822-1192-3301', 1); -INSERT INTO licenses (license_key, max_activations) VALUES ('FLAT-TEST-KEY-0001', 5); -INSERT INTO licenses (license_key, max_activations) VALUES ('FLAT-DEV-UNLIMITED', 999); +INSERT INTO licenses (license_key, max_activations, max_counters, owner) VALUES ('FLAT-8822-1192-3301', 1, 1, 'Client A'); +INSERT INTO licenses (license_key, max_activations, max_counters, owner) VALUES ('FLAT-TEST-KEY-0001', 5, 10, 'Test User'); +INSERT INTO licenses (license_key, max_activations, max_counters, owner) VALUES ('FLAT-DEV-UNLIMITED', 999, 999, 'Developer'); diff --git a/license_manager/index.php b/license_manager/index.php index f201f20..e0d7a5c 100644 --- a/license_manager/index.php +++ b/license_manager/index.php @@ -81,11 +81,13 @@ if ($endpoint === 'activate') { $stmt->execute([$license['id'], $fingerprint, $domain, $product]); } - // Success: Return signed token + // Success: Return signed token and license info $token = hash_hmac('sha256', $key . $fingerprint, SERVER_SECRET); echo json_encode([ 'success' => true, - 'activation_token' => $token + 'activation_token' => $token, + 'max_activations' => (int)$license['max_activations'], + 'max_counters' => (int)$license['max_counters'] ]); exit; } @@ -103,12 +105,17 @@ if ($endpoint === 'verify') { exit; } - $stmt = $pdo->prepare("SELECT status FROM licenses WHERE license_key = ?"); + $stmt = $pdo->prepare("SELECT * FROM licenses WHERE license_key = ?"); $stmt->execute([$key]); - $status = $stmt->fetchColumn(); + $license = $stmt->fetch(); + $status = $license['status'] ?? 'suspended'; if ($status === 'active') { - echo json_encode(['success' => true]); + echo json_encode([ + 'success' => true, + 'max_activations' => (int)$license['max_activations'], + 'max_counters' => (int)$license['max_counters'] + ]); } else { echo json_encode(['success' => false, 'error' => 'License is no longer active.']); } @@ -154,6 +161,7 @@ if ($endpoint === 'issue') { } $max_activations = (int)($input['max_activations'] ?? 1); + $max_counters = (int)($input['max_counters'] ?? 1); $prefix = strtoupper(trim($input['prefix'] ?? 'FLAT')); $owner = $input['owner'] ?? null; $address = $input['address'] ?? null; @@ -163,13 +171,14 @@ if ($endpoint === 'issue') { $key = strtoupper($key); try { - $stmt = $pdo->prepare("INSERT INTO licenses (license_key, max_activations, owner, address) VALUES (?, ?, ?, ?)"); - $stmt->execute([$key, $max_activations, $owner, $address]); + $stmt = $pdo->prepare("INSERT INTO licenses (license_key, max_activations, max_counters, owner, address) VALUES (?, ?, ?, ?, ?)"); + $stmt->execute([$key, $max_activations, $max_counters, $owner, $address]); echo json_encode([ 'success' => true, 'license_key' => $key, 'max_activations' => $max_activations, + 'max_counters' => $max_counters, 'owner' => $owner, 'address' => $address ]); @@ -214,6 +223,8 @@ if ($endpoint === 'update') { $status = $input['status'] ?? null; $owner = $input['owner'] ?? null; $address = $input['address'] ?? null; + $max_activations = isset($input['max_activations']) ? (int)$input['max_activations'] : null; + $max_counters = isset($input['max_counters']) ? (int)$input['max_counters'] : null; if (!$id) { echo json_encode(['success' => false, 'error' => 'ID is required.']); @@ -226,6 +237,8 @@ if ($endpoint === 'update') { if ($status !== null) { $fields[] = "status = ?"; $params[] = $status; } if ($owner !== null) { $fields[] = "owner = ?"; $params[] = $owner; } if ($address !== null) { $fields[] = "address = ?"; $params[] = $address; } + if ($max_activations !== null) { $fields[] = "max_activations = ?"; $params[] = $max_activations; } + if ($max_counters !== null) { $fields[] = "max_counters = ?"; $params[] = $max_counters; } if (empty($fields)) { echo json_encode(['success' => false, 'error' => 'No fields to update.']); diff --git a/license_manager/manage.php b/license_manager/manage.php index b081eb7..a8268e5 100644 --- a/license_manager/manage.php +++ b/license_manager/manage.php @@ -81,10 +81,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { case 'issue': $prefix = strtoupper(trim($_POST['prefix'] ?? 'FLAT')); $max_activations = (int)($_POST['max_activations'] ?? 1); + $max_counters = (int)($_POST['max_counters'] ?? 1); + $owner = trim($_POST['owner'] ?? ''); + $address = trim($_POST['address'] ?? ''); $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]); + $stmt = $pdo->prepare("INSERT INTO licenses (license_key, max_activations, max_counters, owner, address, status) VALUES (?, ?, ?, ?, ?, 'active')"); + $stmt->execute([$key, $max_activations, $max_counters, $owner, $address]); $message = "New license issued: $key"; break; } @@ -140,9 +143,21 @@ $licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC")->fetc
- +
+
+ + +
+
+ + +
+
+ + +
@@ -160,7 +175,9 @@ $licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC")->fetc Key - Activations + Owner + Machines + Counters Status Created Actions @@ -170,6 +187,7 @@ $licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC")->fetc + prepare("SELECT COUNT(*) FROM activations WHERE license_id = ?"); @@ -178,6 +196,9 @@ $licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC")->fetc ?> / + + + @@ -186,6 +207,9 @@ $licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC")->fetc
+
@@ -204,6 +228,51 @@ $licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC")->fetc
+ + + No licenses found.