<?php
/* test key
http://www.estamos.de/makecd
555555555
H8HsRww)7Uz)!iXE5PUMfgP#VymA6
*/
error_reporting(E_ALL); ini_set('display_errors', TRUE);
//include 'stat.php';
if (isset($_GET['source'])) {
header('Content-Type: text/html; charset=utf-8');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MakeCD registration number generator source code</title>
<body>
<?php highlight_file(__FILE__)?>
</body>
</html>
<?php exit;
}
$levels = [
1 => 'private user',
2 => 'private user with disc-at-once',
3 => 'commercial user',
4 => 'professional publisher'
];
function Gen_Key($serial, $szint) {
$mod = [
1 => ['000000C2160EC163CD3BBA56F2CCFE0BCAA4D77B', '256257538298748946109', '257725486834819626647'],
2 => ['0000009DD1BB995C38E20E4EF082722C572007DD', '223057111979772211067', '240759480166694836871'],
3 => ['000000B321B91AF445F77290EAD3609284629A6B', '223298907890902816151', '272976567149646185549'],
4 => ['000000A1DCAFD7978ED21F8FEF94542386ECE807', '233556328724004143549', '235826640018421043987']
];
$chartab = [62, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 35, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 33, 63, 40, 41];
$key = str_pad(gmp_strval(gmp_init($serial, 10), 16), 8, '0', STR_PAD_LEFT);
$p = $mod[$szint];
$m = gmp_init($p[0], 16);
$p1 = gmp_init($p[1]);
$p2 = gmp_init($p[2]);
$d = gmp_invert(3, gmp_mul(gmp_sub($p1, 1), gmp_sub($p2, 1)));
$y = gmp_init('1ffffffffffffffffffff00' . $key, 16);
$x = gmp_powm($y, $d, $m);
$k = $key . str_pad(gmp_strval($x, 16), 34, '0', STR_PAD_LEFT);
$bits = str_pad(gmp_strval(gmp_init($k, 16), 2), 168, '0', STR_PAD_LEFT);
$chars = 'H';
for ($i = 0; $i < 168; $i += 6) {
$b = substr($bits, $i, 6);
$chars .= chr($chartab[base_convert($b, 2, 10)]);
}
return($chars);
}
if (isset($_POST['level']) && isset($_POST['serial'])) {
$level = intval($_POST['level']);
if (($level > 0) && ($level < 5)) {
$serial = $_POST['serial'];
if (preg_match('!^[0-9]+$!', $serial) && ($serial > 0) && ($serial < 2147483648)) {
echo Gen_Key($_POST['serial'], $_POST['level']);
} else {
echo 'Serial number must be between 1 and 2147483647!';
}
} else {
echo 'Choose level!';
}
exit;
}
header('Content-Type: text/html; charset=utf-8');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MakeCD registration number generator</title>
<style>
html,body {
background-color: #FFFFFF;
color: #000000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
}
.serial {
font-family: monospace;
text-align: right;
}
.reg {
font-family: monospace;
}
h1,h2 {
text-align: center;
}
td {
padding: 5px;
}
table, th, td {
border: 1px solid black;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
function GenKey() {
$('#regnum').load('<?=$_SERVER['PHP_SELF']?>',{
level: $('#level').val(),
serial: $('#serial').val()
});
}
$(function() {
$('#serial').on('keyup change', function() {
GenKey();
});
$('#level').on('change', function() {
GenKey();
});
});
</script>
</head>
<body>
<h1>MakeCD registration number generator V0.666</h1>
<h2>by LaySoft of Crimson Jihad</h2>
<table style="border-spacing: 0px; border-collapse: separate; margin-left:auto; margin-right:auto">
<tr>
<th>Level</th>
<th>Serial</th>
<th>Registration number</th>
</tr>
<tr>
<td><select id="level"><option value="0">Choose!</option><?php
foreach ($levels as $level => $duma) {
echo '<option value="' . $level . '">' . $duma . '</option>';
}?></select></td>
<td><input type="number" id="serial" placeholder="Enter serial number!" min="1" max="2147483647"/></td>
<td id="regnum" class="reg"> </td>
</tr>
<?php for ($i = 1; $i < 20; $i++) {
$level = mt_rand(1, 4);
$serial = mt_rand(1, 2147483647)?>
<tr>
<td><?=$levels[$level]?></td>
<td class="serial"><?=$serial?></td>
<td class="reg"><?=Gen_Key($serial, $level)?></td>
</tr>
<?php }?>
</table>
<p style="text-align: right"><a href="<?=$_SERVER['PHP_SELF']?>?source">source</a></p>
</body>
</html>