/** * Cache validation result */ private function cacheValidation($data) { file_put_contents($this->cacheFile, json_encode([ 'timestamp' => time(), 'data' => $data ])); }
/** * Log license actions */ private function logAction($licenseId, $action, $details) { $sql = "INSERT INTO license_logs (license_id, action, details, ip_address) VALUES (:license_id, :action, :details, :ip_address)"; $stmt = $this->db->prepare($sql); $stmt->execute([ ':license_id' => $licenseId, ':action' => $action, ':details' => $details, ':ip_address' => $_SERVER['REMOTE_ADDR'] ?? null ]); } } <?php // src/LicenseValidator.php require_once DIR . '/Database.php'; php license key system github
/** * Validate with remote server */ private function validateWithServer() { $ch = curl_init($this->apiUrl . '/validate.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'license_key' => $this->licenseKey, 'domain' => $this->domain, 'activation_code' => $this->activationCode ])); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode !== 200) { return ['valid' => false, 'error' => 'License server error']; } return json_decode($response, true); } /** * Cache validation result */ private function