Install Trial key directly and skip email collection step

This commit is contained in:
Eric Schultz
2018-09-12 20:59:02 -05:00
parent 9d3911401b
commit 15786f174d
2 changed files with 39 additions and 44 deletions

View File

@@ -60,7 +60,7 @@ Flash GUID:
: <?=$var['flashGUID']?>
<span class="device"><?=$attached_devices?></span>
: <input type="submit" value="Purchase Key"> <input type="button" value="Get Trial Key" onclick="openBox('/webGui/include/TrialRequest.php','Get Trial Key',600,900);">
: <input type="submit" value="Purchase Key"> <input type="button" value="Get Trial Key" onclick="openBox('/webGui/include/TrialRequest.php','Get Trial Key',300,600);">
</form>
<?endif;?>
@@ -185,7 +185,7 @@ Flash GUID:
: <?=$var['flashGUID']?>
<span class="device"><?=$attached_devices?></span>
: <input type="submit" value="Purchase Key"> <input type="button" value="Request Extension" onclick="openBox('/webGui/include/TrialRequest.php','Request Trial Extension Key',600,900);">
: <input type="submit" value="Purchase Key"> <input type="button" value="Request Extension" onclick="openBox('/webGui/include/TrialRequest.php','Request Trial Extension',300,600);">
</form>
<?endif;?>

View File

@@ -14,59 +14,54 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Helpers.php";
$var = parse_ini_file('state/var.ini');
if (!empty($_POST['trial'])) {
file_put_contents('/boot/config/Trial.key', base64_decode($_POST['trial']));
exit;
}
?>
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-fonts.css")?>">
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-popup.css")?>">
<script src="<?autov('/webGui/javascript/dynamix.js')?>"></script>
<script>
function registerTrial(email, guid) {
if (email.length) {
var timestamp = <?=time()?>;
$('#status_panel').slideUp('fast');
$('#trial_form').find('input').prop('disabled', true);
// Nerds love spinners, Maybe place a spinner image next to the submit button; we'll show it now:
$('#spinner_image').fadeIn('fast');
$.post('https://keys.lime-technology.com/account/trial',{timestamp:timestamp,guid:guid,email:email},function(data) {
$('#spinner_image').fadeOut('fast');
var msg = "<p>Thank you for registering USB Flash GUID <strong>"+guid+"</strong></p>" +
"<p>An email has been sent to <strong>"+email+"</strong> containing your key file URL." +
" When received, please paste the URL into the <i>Key file URL</i> box and" +
" click <i>Install Key</i>.</p>" +
"<p>If you do not receive an email, please check your spam or junk-email folder.</p>";
$('#status_panel').hide().html(msg).slideDown('fast');
$('#trial_form').fadeOut('fast');
}).fail(function(data) {
$('#trial_form').find('input').prop('disabled', false);
$('#spinner_image').fadeOut('fast');
var status = data.status;
var obj = data.responseJSON;
var msg = "<p>Sorry, an error ("+status+") occurred registering USB Flash GUID <strong>"+guid+"</strong><p>" +
"<p>The error is: "+obj.error+"</p>";
$('#status_panel').hide().html(msg).slideDown('fast');
});
}
}
</script>
<body>
<div style="margin-top:20px;line-height:30px;margin-left:40px">
<div style="margin:20px;">
<div id="status_panel"></div>
<form markdown="1" id="trial_form">
Email address: <input type="text" name="email" maxlength="1024" value="" style="width:33%">
<p><input type="checkbox" id="eula" name="eula"><label for="eula">By using this software, you agree with our <a target="_blank" href="/Tools/EULA">End-User License Agreement</a> and <a target="_blank" href="https://unraid.net/policies">Privacy Policy</a>.</label></p>
<input type="button" value="Register Trial" onclick="registerTrial(this.form.email.value.trim(), '<?=$var['flashGUID']?>')">
<br><br>
<p>A link to your <i>Trial</i> key will be delivered to this email address.
<p><strong>Note:</strong>
Per our <a target="_blank" href="https://lime-technology.com/policies/">Policy Statement</a>, we never send
unsolicited email to anyone, nor do we authorize anyone else to do so on our behalf.
<p><a target="_blank" href="/Tools/EULA">End-User License Agreement</a>.
<center><input type="button" id="trial_button" value="<?=(strstr($var['regTy'], "expired")?"Extend":"Start")?> Trial" onclick="startTrial()" disabled></center>
</form>
</div>
<script>
function startTrial() {
var guid = '<?=$var['flashGUID']?>';
var timestamp = <?=time()?>;
$('#status_panel').slideUp('fast');
$('#trial_form').find('input').prop('disabled', true);
$('#spinner_image').fadeIn('fast');
$.post('https://keys.lime-technology.com/account/trial',{timestamp:timestamp,guid:guid},function(data) {
$.post('/webGui/include/TrialRequest.php',{trial:data.trial,csrf_token:'<?=$var['csrf_token']?>'},function(data2) {
$('#spinner_image,#status_panel').fadeOut('fast');
parent.swal({title:'Trial <?=(strstr($var['regTy'], "expired")?"extended":"started")?>',text:'Thank you for registering USB Flash GUID '+guid+'.',type:'success'},function(){parent.window.location='/Main';});
});
}).fail(function(data) {
$('#trial_form').find('input').prop('disabled', false);
$('#spinner_image').fadeOut('fast');
var status = data.status;
var obj = data.responseJSON;
var msg = "<p>Sorry, an error ("+status+") occurred registering USB Flash GUID <strong>"+guid+"</strong><p>" +
"<p>The error is: "+obj.error+"</p>";
$('#status_panel').hide().html(msg).slideDown('fast');
});
}
$('#eula').change(function() {
$('#trial_button').prop('disabled', !this.checked);
});
</script>
</body>