editing activation

This commit is contained in:
Flatlogic Bot 2026-02-18 18:33:58 +00:00
parent e84ed5d57e
commit 75abfd68ed
3 changed files with 69 additions and 2 deletions

View File

@ -4,8 +4,8 @@
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'license_manager_db');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_USER', 'license_manager');
define('DB_PASS', 'jHG3lC03GbTSErdw');
define('SERVER_SECRET', 'CHANGE_THIS_TO_A_RANDOM_STRING_FOR_SECURITY');
function db_manager() {

View File

@ -16,6 +16,7 @@ $endpoint = '';
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 running as a simple script without proper URL rewriting
if (empty($endpoint)) {
@ -112,4 +113,64 @@ if ($endpoint === 'verify') {
exit;
}
if ($endpoint === 'deactivate') {
$key = strtoupper(trim($input['license_key'] ?? ''));
$fingerprint = $input['fingerprint'] ?? '';
// Deactivation should ideally require a token or signature, but for simplicity:
// We check if the license exists and the activation matches
// Find License ID
$stmt = $pdo->prepare("SELECT id FROM licenses WHERE license_key = ?");
$stmt->execute([$key]);
$licenseId = $stmt->fetchColumn();
if (!$licenseId) {
echo json_encode(['success' => false, 'error' => 'Invalid license key.']);
exit;
}
// Delete Activation
$stmt = $pdo->prepare("DELETE FROM activations WHERE license_id = ? AND fingerprint = ?");
$stmt->execute([$licenseId, $fingerprint]);
if ($stmt->rowCount() > 0) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['success' => false, 'error' => 'Activation not found.']);
}
exit;
}
if ($endpoint === 'issue') {
$secret = $input['secret'] ?? '';
// Basic security check using the config constant
if ($secret !== SERVER_SECRET) {
echo json_encode(['success' => false, 'error' => 'Unauthorized. Invalid secret.']);
exit;
}
$max_activations = (int)($input['max_activations'] ?? 1);
$prefix = strtoupper(trim($input['prefix'] ?? 'FLAT'));
// Generate a formatted key: PREFIX-XXXX-XXXX
$key = $prefix . '-' . bin2hex(random_bytes(2)) . '-' . bin2hex(random_bytes(2));
$key = strtoupper($key);
try {
$stmt = $pdo->prepare("INSERT INTO licenses (license_key, max_activations) VALUES (?, ?)");
$stmt->execute([$key, $max_activations]);
echo json_encode([
'success' => true,
'license_key' => $key,
'max_activations' => $max_activations
]);
} catch (Exception $e) {
echo json_encode(['success' => false, 'error' => 'Failed to generate license.']);
}
exit;
}
echo json_encode(['success' => false, 'error' => 'Invalid endpoint.']);

View File

@ -35,3 +35,9 @@
2026-02-18 15:40:14 - POST: {"action":"save_theme","theme":"ocean"}
2026-02-18 15:40:20 - POST: {"action":"save_theme","theme":"default"}
2026-02-18 17:02:02 - POST: {"settings":{"customer_display_greeting_title":"Welcome","customer_display_greeting_text":"\u0623\u0647\u0644\u0627 \u0648\u0633\u0647\u0644\u0627\u064b \u0628\u0643\u0640\u0640\u0645"},"update_settings":""}
2026-02-18 18:09:07 - POST: {"open_register":"1","register_id":"1","opening_balance":"0"}
2026-02-18 18:09:25 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":0.383}]","total_amount":"0.3825","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":1,\"price\":0.3825}]"}
2026-02-18 18:09:27 - POST: {"open_register":"1","register_id":"1","opening_balance":"0"}
2026-02-18 18:09:44 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":0.595}]","total_amount":"0.595","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":2,\"qty\":1,\"price\":0.2125},{\"id\":1,\"qty\":1,\"price\":0.3825}]"}
2026-02-18 18:09:48 - POST: {"open_register":"1","register_id":"1","opening_balance":"0"}
2026-02-18 18:10:17 - POST: {"close_register":"1","session_id":"2","cash_in_hand":"5","notes":""}