Merge pull request #854 from ljm42/branch-2

fix path to unraid.min.js
This commit is contained in:
tom mortensen
2021-05-20 07:24:42 -07:00
committed by GitHub
3 changed files with 28 additions and 29 deletions

View File

@@ -44,7 +44,7 @@ if (file_exists('/boot/config/plugins/dynamix.my.servers/myservers.cfg')) { // c
}
// When signed out and there's no cookie, UPC ENV should be 'local' to avoid use of external resource. Otherwise default of 'production'.
$UPC_ENV = $_COOKIE['UPC_ENV'] ?? ((empty($remote['apikey']) || empty($var['regFILE'])) ? 'local' : 'production');
$upcBase = file_exists('/boot/config/plugins/dynamix.my.servers/webComps/unraid.js') ? 'unraid.js' : 'unraid.min.js'; // needed for the server to be agnostic of min or non min versions of the web components
$upcLocalSrc = '/plugins/dynamix.my.servers/webComps/unraid.min.js';
$upcSrc = 'https://registration.unraid.net/webComps/unraid.min.js'; // by default prod is loaded from hosted sources
switch ($UPC_ENV) {
case 'staging': // min version of staging
@@ -54,7 +54,7 @@ switch ($UPC_ENV) {
$upcSrc = 'https://registration-dev.unraid.net/webComps/unraid.js';
break;
case 'local': // forces load from webGUI filesystem.
$upcSrc = '/plugins/dynamix.my.servers/webComps/' . $upcBase; // @NOTE - that using autov(); would render the file name below the body tag. So dont use it :(
$upcSrc = $upcLocalSrc; // @NOTE - that using autov(); would render the file name below the body tag. So dont use it :(
break;
case 'development': // dev server for RegWiz development
$upcSrc = 'https://launchpad.unraid.test:6969/webComps/unraid.js';
@@ -72,7 +72,7 @@ setTimeout(() => {
console.log('[UPC] Fallback to filesystem src 😖');
const el = document.createElement('script');
el.type = 'text/javascript';
el.src = '<?autov('/plugins/dynamix.my.servers/webComps/' . $upcBase) ?>';
el.src = '<?autov($upcLocalSrc) ?>';
return document.head.appendChild(el);
}
return false;

View File

@@ -3,29 +3,6 @@
if (file_exists('/boot/config/plugins/dynamix.my.servers/myservers.cfg')) {
@extract(parse_ini_file('/boot/config/plugins/dynamix.my.servers/myservers.cfg',true));
}
$serverstate = [
"avatar" => $remote['avatar'],
"deviceCount" => $var['deviceCount'],
"email" => ($remote['email']) ? $remote['email'] : '',
"flashproduct" => $var['flashProduct'],
"flashvendor" => $var['flashVendor'],
"guid" => $var['flashGUID'],
"regGuid" => $var['regGUID'],
"internalip" => $_SERVER['SERVER_ADDR'],
"internalport" => $_SERVER['SERVER_PORT'],
"keyfile" => str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE'])))),
"protocol" => $_SERVER['REQUEST_SCHEME'],
"reggen" => (int)$var['regGen'],
"registered" => empty($remote['apikey']) || empty($var['regFILE']) ? 0 : 1,
"sendCrashInfo" => $remote['sendCrashInfo'] || 'no',
"serverip" => $_SERVER['SERVER_ADDR'],
"servername" => $var['NAME'],
"site" => $_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'],
"state" => strtoupper(empty($var['regCheck']) ? $var['regTy'] : $var['regCheck']),
"ts" => time(),
"username" => $remote['username'],
];
// upc translations
$upc_translations = [
($_SESSION['locale']) ? $_SESSION['locale'] : 'en_US' => [
@@ -453,9 +430,31 @@
],
],
];
// feeds server vars to Vuex store in a slightly different array than state.php
$serverstate = [
"avatar" => $remote['avatar'],
"deviceCount" => $var['deviceCount'],
"email" => ($remote['email']) ? $remote['email'] : '',
"flashproduct" => $var['flashProduct'],
"flashvendor" => $var['flashVendor'],
"guid" => $var['flashGUID'],
"regGuid" => $var['regGUID'],
"internalip" => $_SERVER['SERVER_ADDR'],
"internalport" => $_SERVER['SERVER_PORT'],
"keyfile" => str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE'])))),
"protocol" => $_SERVER['REQUEST_SCHEME'],
"reggen" => (int)$var['regGen'],
"registered" => empty($remote['apikey']) || empty($var['regFILE']) ? 0 : 1,
"serverip" => $_SERVER['SERVER_ADDR'],
"servername" => $var['NAME'],
"site" => $_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'],
"state" => strtoupper(empty($var['regCheck']) ? $var['regTy'] : $var['regCheck']),
"ts" => time(),
"username" => $remote['username'],
];
?>
<unraid-user-profile
apikey="<?=($remote['apikey']) ? $remote['apikey'] : ''?>"
apikey="<?=@$upc['apikey']?>"
banner="<?=($display['banner']) ? $display['banner'] : ''?>"
bgcolor="<?=($backgnd) ? '#'.$backgnd : ''?>"
csrf="<?=$var['csrf_token']?>"

View File

@@ -23,8 +23,8 @@ $dyn_cfg = '/boot/config/plugins/dynamix/dynamix.cfg';
$mys_cfg = '/boot/config/plugins/dynamix.my.servers/myservers.cfg';
if (file_exists($dyn_cfg) && !file_exists($mys_cfg)) {
$orig = parse_ini_file($dyn_cfg,true);
$var = (array)parse_ini_file('/usr/local/emhttp/state/var.ini',true);
$orig = @parse_ini_file($dyn_cfg,true);
$var = @(array)parse_ini_file('/usr/local/emhttp/state/var.ini',true);
$url = "http://localhost:".$var['PORT']."/update.php";
// write [remote] section to myservers.cfg