<?php
class License {
/**
* Max length of the license. Must be divisible by 5.
* @var int
*/
private $_licenseLength = 25;
public function __construct() { }
/**
* Generates a license key.
*
* @return string
*/
public function generateLicense() {
$license = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$charlen = strlen($chars);
if ($this->_licenseLength % 5 != 0)
$this->_licenseLength = 25;
for ($i = 0; $i < $this->_licenseLength; $i++) {
$key = mt_rand(0, $charlen);
if ($key > 0)
$key--;
$license .= $chars[$key];
}
$license = chunk_split($license, 5, '-';
$license = substr($license, 0, -1);
return $license;
}
}
<?php
// This will display the license key.
// Make sure to include the file that contains the class.
$licenseClass = new License();
echo $licenseClass->generateLicense() . "\n";
?>
Copyright © 2024, NextGenUpdate.
All Rights Reserved.