|
|
|
@ -4,47 +4,73 @@ use HydraterBootloader\Loader; |
|
|
|
|
|
|
|
|
|
|
|
class LicenseVerifier |
|
|
|
class LicenseVerifier |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function tryEnabledItem(string licenseFile, string keyFile, string featureName, string publicKeyPem, bool useInclude = true, bool forceRefresh = false) { |
|
|
|
public function tryEnabledItem(string licenseFile, string keyFile, string featureName, string publicKeyPem, bool useInclude = true, bool forceRefresh = false) -> array { |
|
|
|
var l, f, found, password, filePath, r, aesKey, aesIV, data; |
|
|
|
var l, f, found, password, filePath, r, aesKey, aesIV, data; |
|
|
|
|
|
|
|
var ran_okay, enabled, status, name, details = []; |
|
|
|
if featureName == "" || licenseFile == "" || publicKeyPem == "" { |
|
|
|
if featureName == "" || licenseFile == "" || publicKeyPem == "" { |
|
|
|
return false; |
|
|
|
throw new \Exception("Missing input Data!"); |
|
|
|
} |
|
|
|
} |
|
|
|
if ! this->verifySignature(licenseFile, publicKeyPem) { |
|
|
|
if ! this->verifySignature(licenseFile, publicKeyPem) { |
|
|
|
return false; |
|
|
|
throw new \Exception("Invalid Signatures!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let l = new Loader(); |
|
|
|
let l = new Loader(); |
|
|
|
|
|
|
|
|
|
|
|
if ! file_exists(keyFile) { |
|
|
|
if ! file_exists(keyFile) { |
|
|
|
return false; |
|
|
|
throw new \Exception("No Key File found!"); |
|
|
|
} |
|
|
|
} |
|
|
|
require keyFile; |
|
|
|
require keyFile; |
|
|
|
|
|
|
|
|
|
|
|
let r = rnd_q(); |
|
|
|
let r = rnd_q(); |
|
|
|
if r === false { |
|
|
|
if r === false { |
|
|
|
return false; |
|
|
|
throw new \Exception("Invalid Keys!"); |
|
|
|
} |
|
|
|
} |
|
|
|
let aesKey = r[0]; |
|
|
|
let aesKey = r[0]; |
|
|
|
let aesIV = r[1]; |
|
|
|
let aesIV = r[1]; |
|
|
|
|
|
|
|
|
|
|
|
let data = this->getEnabledFeatures(licenseFile, aesKey, aesIV); |
|
|
|
let data = this->getEnabledFeatures(licenseFile, aesKey, aesIV); |
|
|
|
let found = false; |
|
|
|
let found = false; |
|
|
|
|
|
|
|
let enabled = false; |
|
|
|
|
|
|
|
let name = false; |
|
|
|
for f in data { |
|
|
|
for f in data { |
|
|
|
if ! isset f["feature"] || f["feature"] != featureName { |
|
|
|
if ! isset f["feature"] || f["feature"] != featureName { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
let filePath = f["file"]; |
|
|
|
let name = true; |
|
|
|
if isset f["enabled"] && f["enabled"] == true { |
|
|
|
if isset f["enabled"] && f["enabled"] == true { |
|
|
|
|
|
|
|
let filePath = f["file"]; |
|
|
|
if isset f["password"] { |
|
|
|
if isset f["password"] { |
|
|
|
let password = f["password"]; |
|
|
|
let password = f["password"]; |
|
|
|
let found = true; |
|
|
|
let found = true; |
|
|
|
|
|
|
|
let enabled = true; |
|
|
|
|
|
|
|
if isset f["status"] { |
|
|
|
|
|
|
|
let status = f["status"]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
let status = "Invalid License!"; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
let filePath = ""; |
|
|
|
|
|
|
|
if isset f["status"] { |
|
|
|
|
|
|
|
let status = f["status"]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
let status = "Invalid License!"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if found { |
|
|
|
if found { |
|
|
|
return l->run(filePath, password, useInclude, forceRefresh); |
|
|
|
let ran_okay = l->run(filePath, password, useInclude, forceRefresh); |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
let ran_okay = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
let details = [ |
|
|
|
|
|
|
|
"feature_name_found": name, |
|
|
|
|
|
|
|
"enabled": enabled, |
|
|
|
|
|
|
|
"status": status, |
|
|
|
|
|
|
|
"ran_okay": ran_okay |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
return details; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -137,6 +163,14 @@ class LicenseVerifier |
|
|
|
"status": "License valid" |
|
|
|
"status": "License valid" |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if isset feature["feature"] { |
|
|
|
|
|
|
|
let result[] = [ |
|
|
|
|
|
|
|
"feature": feature["feature"], |
|
|
|
|
|
|
|
"enabled": false, |
|
|
|
|
|
|
|
"status": "No License!" |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|