diff --git a/db/migrations/20260218_create_license_table.sql b/db/migrations/20260218_create_license_table.sql new file mode 100644 index 0000000..d3eb201 --- /dev/null +++ b/db/migrations/20260218_create_license_table.sql @@ -0,0 +1,13 @@ +-- Migration: Create system_license table +-- Created at: 2026-02-18 + +CREATE TABLE IF NOT EXISTS system_license ( + id INT AUTO_INCREMENT PRIMARY KEY, + license_key VARCHAR(255) NOT NULL, + activation_token TEXT DEFAULT NULL, + fingerprint VARCHAR(255) DEFAULT NULL, + status ENUM('pending', 'active', 'expired', 'suspended') DEFAULT 'pending', + activated_at DATETIME DEFAULT NULL, + last_checked_at DATETIME DEFAULT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/index.php b/index.php index 40ecc7c..6875128 100644 --- a/index.php +++ b/index.php @@ -23,6 +23,78 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { file_put_contents('post_debug.log', date('Y-m-d H:i:s') . " - POST: " . json_encode($_POST) . "\n", FILE_APPEND); } require_once 'db/config.php'; +require_once 'lib/LicenseService.php'; + +// Licensing Middleware +$is_activated = LicenseService::isActivated(); +$page = $_GET['page'] ?? 'dashboard'; + +if (!$is_activated && $page !== 'activate') { + header("Location: index.php?page=activate"); + exit; +} + +// Activation Page UI (accessible without login) +if ($page === 'activate') { + $error = ''; + $success = ''; + if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['activate'])) { + $res = LicenseService::activate($_POST['license_key'] ?? ''); + if ($res['success']) { + $success = "System activated successfully! Redirecting..."; + header("refresh:2;url=index.php"); + } else { + $error = $res['error']; + } + } + ?> + + +
+ + +Please enter your serial key to continue using the application.
+ + +Need a key? Contact Support
+Monitor system activity and errors
+" . htmlspecialchars((string)$lines) . "
No accessible log files found.