$myservers_flash_cfg_path='/boot/config/plugins/dynamix.my.servers/myservers.cfg'; $myservers = file_exists($myservers_flash_cfg_path) ? @parse_ini_file($myservers_flash_cfg_path,true) : []; $ALLOWED_UPC_ENV_VALS = [ 'production', 'staging', 'stagingLogs', 'development', 'local', ]; $UPC_ENV_CK = in_array($_COOKIE['UPC_ENV']??'', $ALLOWED_UPC_ENV_VALS) ? $_COOKIE['UPC_ENV'] : null; // Determine what source we should use for web components if (!file_exists('/usr/local/sbin/unraid-api')) { // When NOT using the plugin we should load the UPC from the file system unless $UPC_ENV_CK exists. $UPC_ENV = $UPC_ENV_CK ?? 'local'; } else { // When PLG exists load from local when not signed in but when signed in load UPC from production. $UPC_ENV = $UPC_ENV_CK ?? ((empty($myservers['remote']['username']) || empty($var['regFILE'])) ? 'local' : 'production'); } $upcLocalSrc = autov('/plugins/dynamix.my.servers/webComps/unraid.min.js', true); switch ($UPC_ENV) { case 'production': $upcSrc = 'https://registration.unraid.net/webComps/unraid.min.js'; break; case 'staging': $upcSrc = 'https://registration-dev.unraid.net/webComps/unraid.min.js'; break; case 'stagingLogs': $upcSrc = 'https://registration-dev-logs.unraid.net/webComps/unraid.min.js'; break; case 'development': $upcSrc = 'https://launchpad.unraid.test:6969/webComps/unraid.js?t=' . time(); break; default: // load from webGUI filesystem. $upcSrc = $upcLocalSrc; break; } // add the intended web component source to the DOM echo ''; ?>