From cb25801eb10b57c74eefbf3972e2f2b2691c684e Mon Sep 17 00:00:00 2001 From: Artem Los Date: Wed, 7 Jun 2023 11:36:05 +0200 Subject: [PATCH] Import old file for backward compatibility --- Cryptolens_old.php | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Cryptolens_old.php diff --git a/Cryptolens_old.php b/Cryptolens_old.php new file mode 100644 index 0000000..c7b8c59 --- /dev/null +++ b/Cryptolens_old.php @@ -0,0 +1,90 @@ + $token + , 'ProductId' => $product_id + , 'Key' => $key + , 'Sign' => 'True' + , 'MachineCode' => $machine_code + , 'SignMethod' => 1 + , 'v' => 1 + ); + $postfields = ''; + $first = TRUE; + foreach ($params as $i => $x) { + if ($first) { $first = FALSE; } else { $postfields .= '&'; } + + $postfields .= urlencode($i); + $postfields .= '='; + $postfields .= urlencode($x); + } + unset($i, $x); + + $curl = curl_init(); + curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1 + , CURLOPT_URL => 'https://api.cryptolens.io/api/key/Activate' + , CURLOPT_POST => 1 + , CURLOPT_POSTFIELDS => $postfields + )); + $result = curl_exec($curl); + curl_close($curl); + + $resp = json_decode($result); + if ( is_null($resp) + || !property_exists($resp, 'message') + || $resp->{'message'} !== '' + || !property_exists($resp, 'licenseKey') + || !property_exists($resp, 'signature') + ) + { + return FALSE; + } + + $license_key_string = base64_decode($resp->{'licenseKey'}); + if (!$license_key_string) { return FALSE; } + + $license_key = json_decode($license_key_string); + if ( is_null($license_key) + || !property_exists($license_key, 'ProductId') + || !is_int($license_key->{'ProductId'}) + || !property_exists($license_key, 'Key') + || !is_string($license_key->{'Key'}) + || !property_exists($license_key, 'Expires') + || !is_int($license_key->{'Expires'}) + || !property_exists($license_key, 'ActivatedMachines') + //|| !is_iterable($license_key->{'ActivatedMachines'}) + ) + { + return FALSE; + } + + if ( $license_key->{'ProductId'} !== $product_id + || $license_key->{'Key'} !== $key + ) + { + return FALSE; + } + + $machine_found = FALSE; + foreach ($license_key->{'ActivatedMachines'} as $machine) { + if (!property_exists($machine, 'Mid')) + { + return FALSE; + } + + if ($machine->{'Mid'} == $machine_code) { $machine_found = TRUE; } + } + unset($machine); + if (!$machine_found) { return FALSE; } + + $time = time(); + if ($license_key->{'Expires'} < $time) { return FALSE; } + + return TRUE; +} + +?> \ No newline at end of file