<?php
date_default_timezone_set("Europe/London");
$mac = isset($_GET['mac']) ? $_GET['mac'] : "";
$ip = isset($_GET['ip']) ? $_GET['ip'] : "";
$core = isset($_GET['core']) ? $_GET['core'] : "";

$serial = "+aGa-KS9u-hGtj-OYz8";
$date = new DateTime();
$rdate = $date->format('Y-m-d H:i:s');
$tnow = $date->getTimestamp();
$tsd = date('Y-m-d H:i:s', $tnow);
$mdate = $date->modify('+30 days');
$expires = $mdate->getTimestamp();
$expires_date = date('Y-m-d H:i:s', $expires);
$daysleft = ($expires - $tnow) / 3600 / 24;
    $reefpubkey = <<<EOD
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+oT6o3HT4VcknRthdU3J
mjApaHu+c+s7uRZ0s2bWRgOfArOKAxKhhvzk5KKMUQ+j/KheKCuSJitp0yj8D+Kx
YeghgP/k1Oijqv5HyAKq7jJZl7y0aEzZA1ipMY6pEMkj591rqs88vTE43neMYC4W
mKbmgxrhNXN2w85xp/fMPLnP3TUd8/Hx5D2pMouY49dYcy8OXbFJQyz8QV3aOQpT
132TVszZcqmIL7LaANPfQCseOV6O9xbVWq9w/sEca2vRy+Y5bnJnSgZH9EjQIhiu
WAcg+AyLPyho0UNUvU4LA1iHiuMF0Qj4OCt7djKz9BWQ3vIvZynp3F7MQ3jqmjQe
9wIDAQAB
-----END PUBLIC KEY-----
EOD;

    $privkey = <<<EOD
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD6hPqjcdPhVySd
G2F1TcmaMCloe75z6zu5FnSzZtZGA58Cs4oDEqGG/OTkooxRD6P8qF4oK5ImK2nT
KPwP4rFh6CGA/+TU6KOq/kfIAqruMlmXvLRoTNkDWKkxjqkQySPn3Wuqzzy9MTje
d4xgLhaYpuaDGuE1c3bDznGn98w8uc/dNR3z8fHkPakyi5jj11hzLw5dsUlDLPxB
Xdo5ClPXfZNWzN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SsF4d5NIoQhsCsqifeZ0V
Ahdy0JFQEwR55id8IX2mOvF772zIopnfGqXTofl60zH4uXkecqg5O7bWoyKshb2k
5Up9QNcx9O3NkkYB2k6Hsr3zyFjKvT/Rsq1zVEcBAoGBAN3JLhX9Zy3zCHa2SpND
zS92bnmZ4Fu2cCxexFYMQS5vPiGaGrPB+g7sL6Z3HOUI4zhk9ztTSl/oYGhKiANO
6bLRieCNHVMI14VEQ0XFGrHZd1BuKXvH6nEhfd6MLvxMPcJ51iZdem+o0aX5FMfO
ETCZGdUqibAeatm1gafjRe29
-----END PRIVATE KEY-----
EOD;

        $license_data = <<<EOF
Serial: $serial
Seq: 3
Expires: $expires
PROC: $core
Upg: $expires
TS: $tnow
F: 3
SIP: $ip
MAC: $mac

EOF;
 $readprikey = openssl_get_privatekey($privkey);
        openssl_private_encrypt($license_data, $license_encrypted, $readprikey, OPENSSL_PKCS1_PADDING);
header('Content-Type: application/license-key');
header("Content-Disposition: attachment; filename=license.key");
header("Content-length: " . strlen($license_encrypted));
die($license_encrypted);
