shifting license key to omanapp

This commit is contained in:
Flatlogic Bot 2026-02-20 02:38:52 +00:00
parent 2d29c8c62b
commit c970d434dd
6 changed files with 0 additions and 657 deletions

222
index.php
View File

@ -1686,7 +1686,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])) {
@ -1780,7 +1779,6 @@ $permission_groups = [
'scale_devices' => 'Scale Devices',
'customer_display_settings' => 'Customer Display',
'backups' => 'Backups',
'licenses' => 'Licenses',
'logs' => 'System Logs'
]
];
@ -2404,11 +2402,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 WHERE type = 'customer' ORDER BY id DESC LIMIT 5")->fetchAll();
// Dashboard stats
@ -2737,9 +2730,6 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<a href="index.php?page=backups" class="nav-link <?= $page === 'backups' ? 'active' : '' ?>">
<i class="fas fa-database"></i> <span><?= __('backups') ?></span>
</a>
<a href="index.php?page=licenses" class="nav-link <?= $page === 'licenses' ? 'active' : '' ?>">
<i class="fas fa-key"></i> <span><?= $lang === 'ar' ? 'إدارة التراخيص' : 'Manage Licenses' ?></span>
</a>
</div>
<?php endif; ?>
@ -7349,220 +7339,8 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
</table>
</div>
</div>
</div>
</div>
</div>
<?php elseif ($page === 'licenses'):
$license_password = 'Meezan@2026';
if (isset($_POST['license_password_submit'])) {
if ($_POST['license_password'] === $license_password) {
$_SESSION['license_auth'] = true;
} else {
$data['license_error'] = 'Invalid password.';
}
}
if (!isset($_SESSION['license_auth'])): ?>
<div class="row justify-content-center">
<div class="col-md-5">
<div class="card border-0 shadow-sm rounded-4 text-center p-5">
<div class="mb-4">
<i class="bi bi-shield-lock-fill text-primary display-1"></i>
</div>
<h4 class="fw-bold mb-3" data-en="Restricted Access" data-ar="وصول مقيد">Restricted Access</h4>
<p class="text-muted mb-4" data-en="Please enter the management password to continue." data-ar="يرجى إدخال كلمة مرور الإدارة للمتابعة.">Please enter the management password to continue.</p>
<?php if (!empty($data['license_error'])): ?>
<div class="alert alert-danger py-2 small"><?= htmlspecialchars($data['license_error']) ?></div>
<?php endif; ?>
<form method="POST">
<div class="mb-3">
<input type="password" name="license_password" class="form-control form-control-lg text-center" placeholder="••••••••" required autofocus>
</div>
<button type="submit" name="license_password_submit" class="btn btn-primary w-100 py-3 rounded-pill fw-bold">
<span data-en="Verify & Continue" data-ar="تحقق ومتابعة">Verify & Continue</span>
</button>
</form>
</div>
</div>
</div>
<?php else: ?>
<div class="card border-0 shadow-sm rounded-4">
<div class="card-header bg-white py-3 d-flex justify-content-between align-items-center border-0">
<div>
<h5 class="m-0 fw-bold text-primary" data-en="Manage Licenses" data-ar="إدارة التراخيص">Manage Licenses</h5>
<p class="text-muted small mb-0" data-en="View and search license keys activated on your system" data-ar="عرض والبحث في مفاتيح التراخيص المفعلة في نظامك">View and search license keys activated on your system</p>
</div>
<div class="d-flex gap-2">
<button class="btn btn-primary btn-sm rounded-pill px-3" data-bs-toggle="modal" data-bs-target="#issueLicenseModal">
<i class="bi bi-plus-circle"></i> <span data-en="Issue License" data-ar="إصدار ترخيص">Issue License</span>
</button>
<button onclick="location.reload()" class="btn btn-light btn-sm rounded-pill px-3">
<i class="bi bi-arrow-clockwise"></i> <span data-en="Refresh" data-ar="تحديث">Refresh</span>
</button>
</div>
</div>
<div class="card-body">
<?php if (!empty($data['license_error'])): ?>
<div class="alert alert-danger border-0 rounded-3">
<i class="bi bi-exclamation-circle me-2"></i>
<?= htmlspecialchars($data['license_error']) ?>
</div>
<?php endif; ?>
<div class="table-responsive">
<table class="table table-hover align-middle mb-0" id="licensesTable">
<thead class="bg-light">
<tr>
<th data-en="ID" data-ar="المعرف">ID</th>
<th data-en="License Key" data-ar="مفتاح الترخيص">License Key</th>
<th data-en="Owner" data-ar="المالك">Owner</th>
<th data-en="Max/Used" data-ar="الأقصى/المستخدم">Max/Used</th>
<th data-en="Status" data-ar="الحالة">Status</th>
<th data-en="Created At" data-ar="تاريخ الإنشاء">Created At</th>
<th data-en="Actions" data-ar="الإجراءات" class="text-end pe-4">Actions</th>
</tr>
</thead>
<tbody>
<?php if (empty($data['licenses'])): ?>
<tr>
<td colspan="7" class="text-center py-5 text-muted">
<i class="bi bi-key fs-1 d-block mb-3 opacity-25"></i>
<span data-en="No license data found on the server." data-ar="لم يتم العثور على بيانات ترخيص على السيرفر.">No license data found on the server.</span>
</td>
</tr>
<?php else: ?>
<?php foreach ($data['licenses'] as $l): ?>
<tr>
<td><span class="badge bg-light text-dark border">#<?= $l['id'] ?></span></td>
<td><code class="fw-bold text-primary"><?= htmlspecialchars($l['license_key']) ?></code></td>
<td>
<div class="fw-bold"><?= htmlspecialchars($l['owner'] ?? 'N/A') ?></div>
<div class="small text-muted"><?= htmlspecialchars($l['address'] ?? '') ?></div>
</td>
<td>
<span class="badge bg-secondary"><?= (int)$l['max_activations'] ?></span>
/
<span class="badge bg-<?= $l['activations_count'] >= $l['max_activations'] ? 'danger' : 'info' ?>"><?= (int)$l['activations_count'] ?></span>
</td>
<td>
<?php if ($l['is_active']): ?>
<span class="badge bg-success-subtle text-success border border-success-subtle rounded-pill">Active</span>
<?php else: ?>
<span class="badge bg-danger-subtle text-danger border border-danger-subtle rounded-pill">Inactive</span>
<?php endif; ?>
</td>
<td class="small text-muted"><?= htmlspecialchars($l['created_at']) ?></td>
<td class="text-end pe-4">
<div class="btn-group">
<button class="btn btn-sm btn-outline-primary"
onclick='editLicense(<?= json_encode($l) ?>)'
title="Edit"><i class="bi bi-pencil"></i></button>
<form method="POST" class="d-inline ms-1">
<input type="hidden" name="id" value="<?= $l['id'] ?>">
<input type="hidden" name="status" value="<?= $l['is_active'] ? 'suspended' : 'active' ?>">
<button type="submit" name="update_license" class="btn btn-sm btn-outline-<?= $l['is_active'] ? 'warning' : 'success' ?>"
title="<?= $l['is_active'] ? 'Disable' : 'Enable' ?>">
<i class="bi bi-power"></i>
</button>
</form>
</div>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- Issue License Modal -->
<div class="modal fade" id="issueLicenseModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title">Issue New License</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<form method="POST">
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Owner Name</label>
<input type="text" name="owner" class="form-control" placeholder="e.g. Acme Corp" required>
</div>
<div class="mb-3">
<label class="form-label">Address / Contact</label>
<textarea name="address" class="form-control" rows="2"></textarea>
</div>
<div class="mb-3">
<label class="form-label">Max Activations</label>
<input type="number" name="max_activations" class="form-control" value="1" min="1" max="100">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Cancel</button>
<button type="submit" name="issue_license" class="btn btn-primary">Generate Key</button>
</div>
</form>
</div>
</div>
</div>
<!-- Edit License Modal -->
<div class="modal fade" id="editLicenseModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title">Edit License</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<form method="POST">
<input type="hidden" name="id" id="edit_license_id">
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Owner Name</label>
<input type="text" name="owner" id="edit_license_owner" class="form-control">
</div>
<div class="mb-3">
<label class="form-label">Address / Contact</label>
<textarea name="address" id="edit_license_address" class="form-control" rows="2"></textarea>
</div>
<div class="mb-3">
<label class="form-label">Status</label>
<select name="status" id="edit_license_status" class="form-select">
<option value="active">Active</option>
<option value="suspended">Suspended</option>
<option value="expired">Expired</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Cancel</button>
<button type="submit" name="update_license" class="btn btn-primary">Save Changes</button>
</div>
</form>
</div>
</div>
</div>
<script>
function editLicense(license) {
document.getElementById('edit_license_id').value = license.id;
document.getElementById('edit_license_owner').value = license.owner || '';
document.getElementById('edit_license_address').value = license.address || '';
document.getElementById('edit_license_status').value = license.status;
var editModal = new bootstrap.Modal(document.getElementById('editLicenseModal'));
editModal.show();
}
</script>
<style>
#licensesTable td { padding: 1rem 0.75rem; }
</style>
<?php endif; ?>
<?php elseif ($page === 'users'): ?>
<div class="card border-0 shadow-sm rounded-4 overflow-hidden">
<div class="card-header bg-white py-3 d-flex justify-content-between align-items-center border-0">

View File

@ -137,34 +137,6 @@ class LicenseService {
return ['success' => true];
}
/**
* Fetches all licenses from the remote server.
*/
public static function listLicenses() {
return self::callRemoteApi('/list', []);
}
/**
* Updates an existing license.
*/
public static function updateLicense($id, $data) {
$params = array_merge(['id' => $id, 'secret' => '1485-5215-2578'], $data);
return self::callRemoteApi('/update', $params);
}
/**
* Issues a new license.
*/
public static function issueLicense($max_activations, $prefix = 'FLAT', $owner = null, $address = null) {
return self::callRemoteApi('/issue', [
'secret' => '1485-5215-2578',
'max_activations' => $max_activations,
'prefix' => $prefix,
'owner' => $owner,
'address' => $address
]);
}
/**
* Remote API Caller
*/

View File

@ -1,112 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>License Manager Admin</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { background-color: #f8f9fa; padding-top: 50px; }
.card { box-shadow: 0 4px 6px rgba(0,0,0,0.1); border: none; }
.header { margin-bottom: 30px; text-align: center; }
.response-area { background: #2d2d2d; color: #50fa7b; padding: 15px; border-radius: 5px; font-family: monospace; display: none; }
</style>
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6">
<div class="header">
<h2>License Manager</h2>
<p class="text-muted">Issue and Manage Licenses</p>
</div>
<div class="card p-4">
<form id="issueForm">
<div class="mb-3">
<label for="secret" class="form-label">Server Secret</label>
<input type="password" class="form-control" id="secret" placeholder="Enter SERVER_SECRET from config.php" required>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="prefix" class="form-label">License Prefix</label>
<input type="text" class="form-control" id="prefix" value="MYAPP" placeholder="e.g. PRO">
</div>
<div class="col-md-6 mb-3">
<label for="activations" class="form-label">Max Activations</label>
<input type="number" class="form-control" id="activations" value="1" min="1">
</div>
</div>
<button type="submit" class="btn btn-primary w-100">Generate License Key</button>
</form>
<div id="responseArea" class="mt-4 response-area">
<h6 class="text-white-50">Server Response:</h6>
<pre id="outputContent" class="mb-0"></pre>
</div>
</div>
<div class="text-center mt-3">
<small class="text-muted">Upload this file to the same directory as <code>index.php</code></small>
</div>
</div>
</div>
</div>
<script>
document.getElementById('issueForm').addEventListener('submit', async function(e) {
e.preventDefault();
const secret = document.getElementById('secret').value;
const prefix = document.getElementById('prefix').value;
const activations = document.getElementById('activations').value;
const responseArea = document.getElementById('responseArea');
const outputContent = document.getElementById('outputContent');
const btn = this.querySelector('button');
// UI Loading State
btn.disabled = true;
btn.textContent = 'Generating...';
responseArea.style.display = 'none';
try {
const res = await fetch('index.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: 'issue',
secret: secret,
prefix: prefix,
max_activations: parseInt(activations)
})
});
const data = await res.json();
outputContent.textContent = JSON.stringify(data, null, 2);
responseArea.style.display = 'block';
if (data.success) {
outputContent.style.color = '#50fa7b'; // Green
} else {
outputContent.style.color = '#ff5555'; // Red
}
} catch (error) {
responseArea.style.display = 'block';
outputContent.textContent = 'Error: ' + error.message;
outputContent.style.color = '#ff5555';
} finally {
btn.disabled = false;
btn.textContent = 'Generate License Key';
}
});
</script>
</body>
</html>

View File

@ -1,22 +0,0 @@
<?php
// Configuration for omanaap.cloud
// 1. Database Credentials (for the live server)
define('DB_HOST', 'localhost');
define('DB_NAME', 'u128023052_meezan_license');
define('DB_USER', 'u128023052_meezan_license');
define('DB_PASS', 'Meezan@2026');
// 2. The Secret Key (Just the code, not the command)
define('SERVER_SECRET', '1485-5215-2578');
function db_manager() {
static $pdo;
if (!$pdo) {
$dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4";
$pdo = new PDO($dsn, DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
}
return $pdo;
}

View File

@ -1,26 +0,0 @@
-- SQL for the License Manager Database
-- Create a new database called 'license_manager_db' and run this script.
CREATE TABLE IF NOT EXISTS licenses (
id INT AUTO_INCREMENT PRIMARY KEY,
license_key VARCHAR(255) UNIQUE NOT NULL,
max_activations INT DEFAULT 1,
status ENUM('active', 'suspended', 'expired') DEFAULT 'active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS activations (
id INT AUTO_INCREMENT PRIMARY KEY,
license_id INT NOT NULL,
fingerprint VARCHAR(255) NOT NULL,
domain VARCHAR(255),
product VARCHAR(255),
activated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (license_id) REFERENCES licenses(id) ON DELETE CASCADE,
UNIQUE KEY (license_id, fingerprint)
) 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);

View File

@ -1,247 +0,0 @@
<?php
/**
* LICENSE MANAGER SERVER (Standalone Module)
*
* This is the central authority that manages license keys and activations.
* It should be hosted on a secure, separate server.
*/
header('Content-Type: application/json');
require_once __DIR__ . '/config.php';
// Simple Router
$request_uri = $_SERVER['REQUEST_URI'] ?? '';
$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 (strpos($request_uri, '/list') !== false) $endpoint = 'list';
if (strpos($request_uri, '/update') !== false) $endpoint = 'update';
$input = json_decode(file_get_contents('php://input'), true);
// If running as a simple script without proper URL rewriting
if (empty($endpoint)) {
$endpoint = $_GET['action'] ?? $input['action'] ?? '';
}
try {
$pdo = db_manager();
} catch (Exception $e) {
echo json_encode(['success' => false, 'error' => 'Database connection failed.']);
exit;
}
if ($endpoint === 'activate') {
$key = strtoupper(trim($input['license_key'] ?? ''));
$fingerprint = $input['fingerprint'] ?? '';
$domain = $input['domain'] ?? '';
$product = $input['product'] ?? '';
if (empty($key) || empty($fingerprint)) {
echo json_encode(['success' => false, 'error' => 'Missing required parameters.']);
exit;
}
// 1. Find License
$stmt = $pdo->prepare("SELECT * FROM licenses WHERE license_key = ? LIMIT 1");
$stmt->execute([$key]);
$license = $stmt->fetch();
if (!$license) {
echo json_encode(['success' => false, 'error' => 'Invalid license key.']);
exit;
}
if ($license['status'] !== 'active') {
echo json_encode(['success' => false, 'error' => 'License is ' . $license['status'] . '.']);
exit;
}
// 2. Check current activations
$stmt = $pdo->prepare("SELECT COUNT(*) FROM activations WHERE license_id = ?");
$stmt->execute([$license['id']]);
$current_activations = $stmt->fetchColumn();
// 3. Check if this machine is already activated
$stmt = $pdo->prepare("SELECT * FROM activations WHERE license_id = ? AND fingerprint = ?");
$stmt->execute([$license['id'], $fingerprint]);
$existing = $stmt->fetch();
if (!$existing) {
if ($current_activations >= $license['max_activations']) {
echo json_encode(['success' => false, 'error' => 'Maximum activation limit reached.']);
exit;
}
// Record new activation
$stmt = $pdo->prepare("INSERT INTO activations (license_id, fingerprint, domain, product) VALUES (?, ?, ?, ?)");
$stmt->execute([$license['id'], $fingerprint, $domain, $product]);
}
// Success: Return signed token
$token = hash_hmac('sha256', $key . $fingerprint, SERVER_SECRET);
echo json_encode([
'success' => true,
'activation_token' => $token
]);
exit;
}
if ($endpoint === 'verify') {
$key = strtoupper(trim($input['license_key'] ?? ''));
$fingerprint = $input['fingerprint'] ?? '';
$token = $input['token'] ?? '';
// Simple validation: re-calculate token and check DB status
$expected_token = hash_hmac('sha256', $key . $fingerprint, SERVER_SECRET);
if ($token !== $expected_token) {
echo json_encode(['success' => false, 'error' => 'Invalid activation token.']);
exit;
}
$stmt = $pdo->prepare("SELECT status FROM licenses WHERE license_key = ?");
$stmt->execute([$key]);
$status = $stmt->fetchColumn();
if ($status === 'active') {
echo json_encode(['success' => true]);
} else {
echo json_encode(['success' => false, 'error' => 'License is no longer active.']);
}
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'));
$owner = $input['owner'] ?? null;
$address = $input['address'] ?? null;
// 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, owner, address) VALUES (?, ?, ?, ?)");
$stmt->execute([$key, $max_activations, $owner, $address]);
echo json_encode([
'success' => true,
'license_key' => $key,
'max_activations' => $max_activations,
'owner' => $owner,
'address' => $address
]);
} catch (Exception $e) {
echo json_encode(['success' => false, 'error' => 'Failed to generate license.']);
}
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;
}
if ($endpoint === 'update') {
$secret = $input['secret'] ?? '';
if ($secret !== SERVER_SECRET) {
echo json_encode(['success' => false, 'error' => 'Unauthorized.']);
exit;
}
$id = (int)($input['id'] ?? 0);
$status = $input['status'] ?? null;
$owner = $input['owner'] ?? null;
$address = $input['address'] ?? null;
if (!$id) {
echo json_encode(['success' => false, 'error' => 'ID is required.']);
exit;
}
try {
$fields = [];
$params = [];
if ($status !== null) { $fields[] = "status = ?"; $params[] = $status; }
if ($owner !== null) { $fields[] = "owner = ?"; $params[] = $owner; }
if ($address !== null) { $fields[] = "address = ?"; $params[] = $address; }
if (empty($fields)) {
echo json_encode(['success' => false, 'error' => 'No fields to update.']);
exit;
}
$params[] = $id;
$sql = "UPDATE licenses SET " . implode(', ', $fields) . " WHERE id = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
echo json_encode(['success' => true]);
} catch (Exception $e) {
echo json_encode(['success' => false, 'error' => 'Update failed: ' . $e->getMessage()]);
}
exit;
}
echo json_encode(['success' => false, 'error' => 'Invalid endpoint.']);