/**
* PHP License Verification Example
*/
function verifyLicense($licenseKey, $machineId, $apiKey) {
// API endpoint URL
$apiUrl = 'https://getlicensetool.shop/api/verify.php';
// Prepare request data
$data = json_encode([
'license_key' => $licenseKey,
'machine_id' => $machineId
]);
// Initialize cURL session
$ch = curl_init($apiUrl);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($data),
'X-API-Key: ' . $apiKey
]);
// Execute cURL request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close cURL session
curl_close($ch);
// Check for errors
if ($response === false) {
$curlError = curl_error($ch);
return [
'valid' => false,
'message' => 'Failed to connect to license server: ' . $curlError
];
} else if ($httpCode === 200) {
return json_decode($response, true);
} else if ($httpCode === 401) {
return [
'valid' => false,
'message' => 'API key is invalid or missing'
];
} else {
return [
'valid' => false,
'message' => 'Failed to verify license. HTTP Code: ' . $httpCode
];
}
}
// Usage example
$licenseKey = 'XXXX-XXXX-XXXX-XXXX'; // Your license key
$machineId = md5(php_uname('n')); // Generate machine ID based on hostname
$apiKey = 'your_api_key_here'; // Your API key
$result = verifyLicense($licenseKey, $machineId, $apiKey);
if ($result['valid']) {
echo "License is valid! Expires in {$result['expires_in_days']} days.";
} else {
echo "License verification failed: {$result['message']}";
}
/**
* JavaScript License Verification Example (using Fetch API)
*/
async function verifyLicense(licenseKey, machineId, apiKey) {
// API endpoint URL
const apiUrl = 'https://getlicensetool.shop/api/verify.php';
// Prepare request data
const data = {
license_key: licenseKey,
machine_id: machineId
};
try {
// Send request
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey
},
body: JSON.stringify(data)
});
// Check for HTTP errors
if (!response.ok) {
if (response.status === 401) {
return {
valid: false,
message: 'API key is invalid or missing'
};
}
return {
valid: false,
message: `HTTP error: ${response.status}`
};
}
// Parse the JSON response
return await response.json();
} catch (error) {
return {
valid: false,
message: `Error: ${error.message}`
};
}
}
// Generate a machine ID
function generateMachineId() {
// In a real application, use something unique to the device
// This is a simple example that uses browser and screen info
const screenInfo = `${window.screen.width}x${window.screen.height}x${window.screen.colorDepth}`;
const browserInfo = navigator.userAgent;
// Create a simple hash of the combined information
let hash = 0;
const combined = screenInfo + browserInfo;
for (let i = 0; i < combined.length; i++) {
const char = combined.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash; // Convert to 32bit integer
}
// Convert to hexadecimal and ensure positive number
return Math.abs(hash).toString(16);
}
// Usage example
const licenseKey = 'XXXX-XXXX-XXXX-XXXX'; // Your license key
const machineId = generateMachineId(); // Generate a unique machine ID
const apiKey = 'your_api_key_here'; // Your API key
verifyLicense(licenseKey, machineId, apiKey)
.then(result => {
if (result.valid) {
console.log(`License is valid! Expires in ${result.expires_in_days} days.`);
// Enable features, allow access, etc.
} else {
console.log(`License verification failed: ${result.message}`);
// Show error, disable features, etc.
}
});
"""
Python License Verification Example
"""
import json
import requests
import uuid
import socket
import hashlib
def verify_license(license_key, machine_id, api_key):
"""Verify license with the license server"""
api_url = 'https://getlicensetool.shop/api/verify.php'
# Prepare request data
data = {
'license_key': license_key,
'machine_id': machine_id
}
try:
# Send POST request to license server
response = requests.post(
api_url,
data=json.dumps(data),
headers={
'Content-Type': 'application/json',
'X-API-Key': api_key
}
)
# Check if request was successful
if response.status_code == 200:
return response.json()
elif response.status_code == 401:
return {
'valid': False,
'message': 'API key is invalid or missing'
}
else:
return {
'valid': False,
'message': f'Failed to verify license. HTTP Code: {response.status_code}'
}
except Exception as e:
return {
'valid': False,
'message': f'Error: {str(e)}'
}
def get_machine_id():
"""Generate a unique machine ID"""
# Get hostname and MAC address
hostname = socket.gethostname()
mac_address = uuid.getnode()
# Combine them and create an MD5 hash
machine_str = f"{hostname}:{mac_address}"
machine_id = hashlib.md5(machine_str.encode()).hexdigest()
return machine_id
# Usage example
if __name__ == '__main__':
license_key = 'XXXX-XXXX-XXXX-XXXX' # Your license key
machine_id = get_machine_id() # Generate a unique machine ID
api_key = 'your_api_key_here' # Your API key
result = verify_license(license_key, machine_id, api_key)
if result['valid']:
print(f"License is valid! Expires in {result['expires_in_days']} days.")
# Enable features, allow access, etc.
else:
print(f"License verification failed: {result['message']}")
# Show error, disable features, etc.
/**
* Node.js License Verification Example
*/
const axios = require('axios');
const os = require('os');
const crypto = require('crypto');
/**
* Verify license with the license server
*/
async function verifyLicense(licenseKey, machineId, apiKey) {
// API endpoint URL
const apiUrl = 'https://getlicensetool.shop/api/verify.php';
// Prepare request data
const data = {
license_key: licenseKey,
machine_id: machineId
};
try {
// Send POST request to license server
const response = await axios.post(apiUrl, data, {
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey
}
});
// Return the response data
return response.data;
} catch (error) {
// Check for specific error codes
if (error.response && error.response.status === 401) {
return {
valid: false,
message: 'API key is invalid or missing'
};
}
return {
valid: false,
message: `Error: ${error.message}`
};
}
}
/**
* Generate a unique machine ID
*/
function getMachineId() {
// Get hostname and network interfaces
const hostname = os.hostname();
const networkInterfaces = os.networkInterfaces();
// Get the first MAC address we can find
let macAddress = '';
Object.keys(networkInterfaces).forEach((ifaceName) => {
if (macAddress) return;
networkInterfaces[ifaceName].forEach((iface) => {
if (macAddress) return;
if (iface.mac && iface.mac !== '00:00:00:00:00:00') {
macAddress = iface.mac;
}
});
});
// Combine hostname and MAC address and create MD5 hash
const machineStr = `${hostname}:${macAddress}`;
const machineId = crypto.createHash('md5').update(machineStr).digest('hex');
return machineId;
}
// Usage example
const licenseKey = 'XXXX-XXXX-XXXX-XXXX'; // Your license key
const machineId = getMachineId(); // Generate a unique machine ID
const apiKey = 'your_api_key_here'; // Your API key
verifyLicense(licenseKey, machineId, apiKey)
.then(result => {
if (result.valid) {
console.log(`License is valid! Expires in ${result.expires_in_days} days.`);
// Enable features, allow access, etc.
} else {
console.log(`License verification failed: ${result.message}`);
// Show error, disable features, etc.
}
})
.catch(error => {
console.error('Error:', error);
});