Update dynamix.unraid.net.plg

This commit is contained in:
Eric Schultz
2020-04-14 02:27:46 -05:00
committed by GitHub
parent 5be28fbd78
commit c0080e4c6d
+86 -35
View File
@@ -810,27 +810,19 @@ response_complete($httpcode, '{}');
<style>
#sb-title {display:none}
#sb-info {display:none}
#sb-wrapper {overflow:hidden}
#sb-overlay {opacity:0.8 !important}
</style>
<script markdown="0">
function showRegWizard() {
<? $license_state = strtoupper(empty($var['regCheck']) ? $var['regTy'] : $var['regCheck']); ?>
Shadowbox.open({
content:'https://forums.unraid.net/launchpad-overlay/?ts=<?=time()?>&guid=<?=$var['flashGUID']?>&state=<?=$license_state?>&keyfile=<?=str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE']))))?>&reggen=<?=$var['regGen']?>&flashproduct=<?=$var['flashProduct']?>&flashvendor=<?=$var['flashVendor']?>&servername=<?=$var['NAME']?>&serverip=<?=$_SERVER['SERVER_ADDR']?>&site='+location.origin,
player:'iframe',
options: {modal: true, animate: true, displayNav: false}
content:'https://forums.unraid.net/launchpad-overlay/?ts=<?=time()?>&guid=<?=$var['flashGUID']?>&state=<?=$license_state?>&keyfile=<?=str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE']))))?>&reggen=<?=$var['regGen']?>&flashproduct=<?=$var['flashProduct']?>&flashvendor=<?=$var['flashVendor']?>&registered=<?=empty($remote['apikey'])||empty($var['regFILE'])?0:1?>&servername=<?=$var['NAME']?>&serverip=<?=$_SERVER['SERVER_ADDR']?>&internalport=<?=$_SERVER['SERVER_PORT']?>&protocol=<?=$_SERVER['REQUEST_SCHEME']?>&site='+location.origin,
player: 'iframe',
options: {modal: true, animate: false, displayNav: false, overlayOpacity: 0.8, viewportPadding: 0, showMovieControls: false}
});
}
function hideRegWizard() {
function hideRegWizard(cb) {
Shadowbox.close();
var data = {};
data['#file'] = 'dynamix/dynamix.cfg';
data['#section'] = 'wizard';
data['hideWizard'] = 1;
$.post('/update.php',data,function() {
console.log('dynamix/dynamix.cfg: Updated hideWizard under [wizard] section');
});
$.post('/update.php', {'#file': 'dynamix/dynamix.cfg', '#section': 'wizard', hideWizard: '1'}, cb);
}
function handleMessage(e) {
//if (e.origin != "http://child.com") { return; }
@@ -845,53 +837,66 @@ function handleMessage(e) {
case "CLOSE_SHADOWBOX":
hideRegWizard();
break;
case "SHUTDOWN":
window.location.href = '/webGui/include/Boot.php';
break;
case "REG_WIZARD":
if (data.apikey) {
var data = {};
data['#file'] = 'dynamix/dynamix.cfg';
data['#section'] = 'remote';
data['apikey'] = data.apikey;
$.post('/update.php',data,function() {
$.post('/update.php', {'#file': 'dynamix/dynamix.cfg', '#section': 'remote', apikey: data.apikey}, function() {
console.log('dynamix/dynamix.cfg: Updated apikey under [remote] section');
}).fail(function() {
console.error('Failed to update apikey under [remote] section');
});
}
if (data.license) {
hideRegWizard();
$.get('/webGui/include/InstallKey.php', {url: data.license}, function() {
console.log('New license key installed: ' + data.license);
location = '/Main';
}).fail(function() {
console.error('Failed to license new key: ' + data.license);
hideRegWizard(function (){
$.get('/webGui/include/InstallKey.php', {url: data.license}, function() {
console.log('New license key installed: ' + data.license);
setTimeout(function(){ location = '/Main'; }, 1000);
}).fail(function() {
console.error('Failed to license new key: ' + data.license);
});
});
}
break;
case "INSTALL_KEY":
case "KEY_PURCHASE":
if (data.license) {
hideRegWizard();
$.get('/webGui/include/InstallKey.php', {url: data.license}, function() {
console.log('New license key installed: ' + data.license);
location = '/Main';
}).fail(function() {
console.error('Failed to license new key: ' + data.license);
hideRegWizard(function () {
$.get('/webGui/include/InstallKey.php', {url: data.license}, function() {
console.log('New license key installed: ' + data.license);
setTimeout(function(){ location = '/Main'; }, 1000);
}).fail(function() {
console.error('Failed to license new key: ' + data.license);
});
});
} else {
console.error('KEY_PURCHASE event fired! but missing license data:');
console.log(data);
console.error('KEY_PURCHASE event fired! but missing license data:', data);
}
break;
case "GET_STATE":
$.get('/plugins/dynamix.unraid.net/include/state.php', function(newstate) {
e.source.postMessage(newstate, e.origin);
}).fail(function(err) {
console.error('Failed to get new state: ' + err);
});
break;
case "MYSERVERS_UNREGISTER":
$.post('/update.php', {'#file': 'dynamix/dynamix.cfg', '#section': 'remote', apikey: ''}, function() {
console.log('dynamix/dynamix.cfg: Unregistered myservers, cleared apikey under [remote] section');
}).fail(function() {
console.error('Failed to unregister');
});
break;
default:
console.error('Unhandled event \'' + data.event + '\' fired. data:');
console.log(data);
console.error('Unhandled event \'' + data.event + '\' fired. data:', data);
break;
}
}
window.addEventListener('message', handleMessage, false);
<? if (empty($wizard['hideWizard'])) { ?>
$(function() {
setTimeout(function() { showWizard(); }, 100);
setTimeout(function() { showRegWizard(); }, 100);
});
<? } ?>
</script>
@@ -899,6 +904,52 @@ $(function() {
</INLINE>
</FILE>
<FILE Name="/usr/local/emhttp/plugins/dynamix.unraid.net/include/state.php">
<INLINE>
<![CDATA[
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Helpers.php";
$var = (array)parse_ini_file('state/var.ini');
$license_state = strtoupper(empty($var['regCheck']) ? $var['regTy'] : $var['regCheck']);
$key_contents = str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE']))));
$arr = [];
$arr['event'] = 'STATE';
$arr['ts'] = time();
$arr['guid'] = $var['flashGUID'];
$arr['state'] = $license_state;
$arr['keyfile'] = $key_contents;
$arr['reggen'] = $var['regGen'];
$arr['flashproduct'] = $var['flashProduct'];
$arr['flashvendor'] = $var['flashVendor'];
$arr['servername'] = $var['NAME'];
$arr['serverip'] = $_SERVER['SERVER_ADDR'];
$arr['internalport'] = $_SERVER['SERVER_PORT'];
$arr['protocol'] = $_SERVER['REQUEST_SCHEME'];
echo json_encode($arr);
?>
]]>
</INLINE>
</FILE>
<!-- Preserve in case plugin is removed -->
<FILE Run="/bin/bash" Method="install">
<INLINE>