diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php index fdef02aad..37eaacdc5 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php @@ -1,20 +1,20 @@ = 300) { - // Get the remote manifest JSON - $remoteManifestJson = file_get_contents($remoteResourceUrl . 'manifest.json'); + // Get the remote manifest JSON + $remoteManifestJson = file_get_contents($remoteResourceUrl . 'manifest.json'); - // Compare the remote and local manifest versions - $remoteManifest = json_decode($remoteManifestJson, true); - $localManifest = json_decode(file_get_contents($localManifestFile), true); + // Compare the remote and local manifest versions + $remoteManifest = json_decode($remoteManifestJson, true); + $localManifest = json_decode(file_get_contents($localManifestFile), true); - if ($remoteManifest && $localManifest && $remoteManifest !== $localManifest) { - // Update the local manifest - file_put_contents($localManifestFile, $remoteManifestJson); + if ($remoteManifest && $localManifest && $remoteManifest !== $localManifest) { + // Update the local manifest + file_put_contents($localManifestFile, $remoteManifestJson); - // Download the file contents for the search value - $searchText = 'connect-components.client.mjs'; - $fileValue = null; + // Download the file contents for the search value + $searchText = 'connect-components.client.mjs'; + $fileValue = null; - foreach ($remoteManifest as $key => $value) { - if (strpos($key, $searchText) !== false && isset($value["file"])) { - $fileValue = file_get_contents($remoteResourceUrl . $value["file"]); - break; - } + foreach ($remoteManifest as $key => $value) { + if (strpos($key, $searchText) !== false && isset($value["file"])) { + $fileValue = file_get_contents($remoteResourceUrl . $value["file"]); + break; + } + } + + if ($fileValue !== null) { + // Extract the directory path from the URL + $directoryPath = pathinfo($value["file"], PATHINFO_DIRNAME); + // Set the local file path + $localFilePath = '/usr/local/emhttp/plugins/dynamix.my.servers' . $directoryPath; + // Create the directory if it doesn't exist + if (!is_dir($localFilePath)) { + mkdir($localFilePath, 0777, true); + } + // Save the file contents to a local file + file_put_contents($localFilePath . '/' . basename($value["file"]), $fileValue); + } } - if ($fileValue !== null) { - // Extract the directory path from the URL - $directoryPath = pathinfo($value["file"], PATHINFO_DIRNAME); - // Set the local file path - $localFilePath = '/usr/local/emhttp/plugins/dynamix.my.servers' . $directoryPath; - // Create the directory if it doesn't exist - if (!is_dir($localFilePath)) { - mkdir($localFilePath, 0777, true); - } - // Save the file contents to a local file - file_put_contents($localFilePath . '/' . basename($value["file"]), $fileValue); - } - } - - // Set the session cookie with the current timestamp - setcookie('manifest_last_checked', time(), time() + 300); // Expire in 5 minutes + // Set the session cookie with the current timestamp + setcookie('manifest_last_checked', time(), time() + 300); // Expire in 5 minutes } // Load the local manifest @@ -73,16 +73,16 @@ $searchText = 'connect-components.client.mjs'; $fileValue = null; foreach ($localManifest as $key => $value) { - if (strpos($key, $searchText) !== false && isset($value["file"])) { - $fileValue = $value["file"]; - break; - } + if (strpos($key, $searchText) !== false && isset($value["file"])) { + $fileValue = $value["file"]; + break; + } } if ($fileValue !== null) { - $prefixedPath = '/plugins/dynamix.my.servers/connect-components/'; - echo ''; + $prefixedPath = '/plugins/dynamix.my.servers/connect-components/'; + echo ''; } else { - echo ''; + echo ''; } ?> diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers2.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers2.php index 07e5a3866..16c333bd0 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers2.php +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers2.php @@ -1,33 +1,40 @@ - - 'UNKNOWN_ERROR', - "invalid" => 'INVALID', - "nokeyserver" => 'NO_KEY_SERVER', - "withdrawn" => 'WITHDRAWN', + +$configErrorEnum = [ + "error" => 'UNKNOWN_ERROR', + "invalid" => 'INVALID', + "nokeyserver" => 'NO_KEY_SERVER', + "withdrawn" => 'WITHDRAWN', ]; + // read flashbackup ini file $flashbackup_ini = '/var/local/emhttp/flashbackup.ini'; $flashbackup_status = (file_exists($flashbackup_ini)) ? @parse_ini_file($flashbackup_ini) : []; @@ -36,70 +43,69 @@ $nginx = parse_ini_file('/var/local/emhttp/nginx.ini'); $pluginInstalled = ''; if (!file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net') && !file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net.staging')) { - $pluginInstalled = ''; // base OS only, plugin not installed • show ad for plugin + $pluginInstalled = ''; // base OS only, plugin not installed • show ad for plugin } else { - // plugin is installed but if the unraid-api file doesn't fully install it's a failed install - if (file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net')) $pluginInstalled = 'dynamix.unraid.net.plg'; - if (file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net.staging')) $pluginInstalled = 'dynamix.unraid.net.staging.plg'; - // plugin install failed • append failure detected so we can show warning about failed install via UPC - if (!file_exists('/usr/local/sbin/unraid-api')) $pluginInstalled = $pluginInstalled . '_installFailed'; + // plugin is installed but if the unraid-api file doesn't fully install it's a failed install + if (file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net')) $pluginInstalled = 'dynamix.unraid.net.plg'; + if (file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net.staging')) $pluginInstalled = 'dynamix.unraid.net.staging.plg'; + // plugin install failed • append failure detected so we can show warning about failed install via UPC + if (!file_exists('/usr/local/sbin/unraid-api')) $pluginInstalled .= '_installFailed'; } + $plgversion = file_exists('/var/log/plugins/dynamix.unraid.net.plg') - ? trim(@exec('/usr/local/sbin/plugin version /var/log/plugins/dynamix.unraid.net.plg 2>/dev/null')) - : ( file_exists('/var/log/plugins/dynamix.unraid.net.staging.plg') - ? trim(@exec('/usr/local/sbin/plugin version /var/log/plugins/dynamix.unraid.net.staging.plg 2>/dev/null')) - : 'base-'.$var['version'] ); + ? trim(@exec('/usr/local/sbin/plugin version /var/log/plugins/dynamix.unraid.net.plg 2>/dev/null')) + : (file_exists('/var/log/plugins/dynamix.unraid.net.staging.plg') + ? trim(@exec('/usr/local/sbin/plugin version /var/log/plugins/dynamix.unraid.net.staging.plg 2>/dev/null')) + : 'base-' . $var['version']); $serverData = [ - "apiKey" => $myservers['upc']['apikey'] ?? '', - "apiVersion" => $myservers['api']['version'] ?? '', - "avatar" => (!empty($myservers['remote']['avatar']) && $pluginInstalled) ? $myservers['remote']['avatar'] : '', - "config" => [ - 'valid' => $var['configValid'] === 'yes', - 'error' => $var['configValid'] !== 'yes' - ? (array_key_exists($var['configValid'], $configErrorEnum) ? $configErrorEnum[$var['configValid']] : 'UNKNOWN_ERROR') - : null, - ], - "csrf" => $var['csrf_token'], - "description" => $var['COMMENT'] ?? '', - "deviceCount" => $var['deviceCount'], - "email" => $myservers['remote']['email'] ?? '', - "expireTime" => 1000 * ($var['regTy'] == 'Trial' || strstr($var['regTy'],'expired') ? $var['regTm2'] : 0), - "extraOrigins" => explode(',', $myservers['api']['extraOrigins']??''), - "flashProduct" => $var['flashProduct'], - "flashVendor" => $var['flashVendor'], - "flashBackupActivated" => empty($flashbackup_status['activated']) ? '' : 'true', - "guid" => $var['flashGUID'], - "hasRemoteApikey" => !empty($myservers['remote']['apikey']), - "internalIp" => ipaddr(), - "internalPort" => $_SERVER['SERVER_PORT'], - "keyfile" => empty($var['regFILE']) ? '' : str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE'])))), - "locale" => ($_SESSION['locale']) ? $_SESSION['locale'] : 'en_US', - "model" => $var['SYS_MODEL'], - "name" => $var['NAME'], - "osVersion" => $var['version'], - "pluginInstalled" => $pluginInstalled, - "pluginVersion" => $pluginVersion, - "protocol" => $_SERVER['REQUEST_SCHEME'], - "regGen" => (int)$var['regGen'], - "regGuid" => $var['regGUID'], - "registered" => (!empty($myservers['remote']['username']) && $pluginInstalled), - "registeredTime" => $myservers['remote']['regWizTime'] ?? '', - "site" => $_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'], - "state" => strtoupper(empty($var['regCheck']) ? $var['regTy'] : $var['regCheck']), - "theme" => [ - "banner" => $display['banner'] ?? '', - "bannerGradient" => $display['showBannerGradient'] ?? 'yes', - "bgColor" => ($backgnd) ? '#'.$backgnd : '', - "descriptionShow" => ($display['headerdescription'] ?? '' != 'no') ? 'true' : '', - "metaColor" => ($display['headermetacolor'] ?? '') ? '#'.$display['headermetacolor'] : '', - "name" => $display['theme'], - "textColor" => ($header) ? '#'.$header : '', - ], - "ts" => time(), - "uptime" => 1000 * (time() - round(strtok(exec("cat /proc/uptime"),' '))), - "username" => (!empty($myservers['remote']['username']) && $pluginInstalled) ? $myservers['remote']['username'] : '', - "wanFQDN" => $nginx['NGINX_WANFQDN'] ?? '', + "apiKey" => $myservers['upc']['apikey'] ?? '', + "apiVersion" => $myservers['api']['version'] ?? '', + "avatar" => (!empty($myservers['remote']['avatar']) && $pluginInstalled) ? $myservers['remote']['avatar'] : '', + "config" => [ + 'valid' => ($var['configValid'] === 'yes'), + 'error' => isset($configErrorEnum[$var['configValid']]) ? $configErrorEnum[$var['configValid']] : 'UNKNOWN_ERROR', + ], + "csrf" => $var['csrf_token'], + "description" => $var['COMMENT'] ?? '', + "deviceCount" => $var['deviceCount'], + "email" => $myservers['remote']['email'] ?? '', + "expireTime" => 1000 * (($var['regTy'] === 'Trial' || strstr($var['regTy'], 'expired')) ? $var['regTm2'] : 0), + "extraOrigins" => explode(',', $myservers['api']['extraOrigins'] ?? ''), + "flashProduct" => $var['flashProduct'], + "flashVendor" => $var['flashVendor'], + "flashBackupActivated" => empty($flashbackup_status['activated']) ? '' : 'true', + "guid" => $var['flashGUID'], + "hasRemoteApikey" => !empty($myservers['remote']['apikey']), + "internalIp" => ipaddr(), + "internalPort" => $_SERVER['SERVER_PORT'], + "keyfile" => empty($var['regFILE']) ? '' : str_replace(['+', '/', '='], ['-', '_', ''], trim(base64_encode(@file_get_contents($var['regFILE'])))), + "locale" => ($_SESSION['locale']) ? $_SESSION['locale'] : 'en_US', + "model" => $var['SYS_MODEL'], + "name" => $var['NAME'], + "osVersion" => $var['version'], + "pluginInstalled" => $pluginInstalled, + "pluginVersion" => $pluginVersion, + "protocol" => $_SERVER['REQUEST_SCHEME'], + "regGen" => (int)$var['regGen'], + "regGuid" => $var['regGUID'], + "registered" => (!empty($myservers['remote']['username']) && $pluginInstalled), + "registeredTime" => $myservers['remote']['regWizTime'] ?? '', + "site" => $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['HTTP_HOST'], + "state" => strtoupper(empty($var['regCheck']) ? $var['regTy'] : $var['regCheck']), + "theme" => [ + "banner" => $display['banner'] ?? '', + "bannerGradient" => $display['showBannerGradient'] ?? 'yes', + "bgColor" => ($backgnd) ? '#' . $backgnd : '', + "descriptionShow" => (!empty($display['headerdescription']) && $display['headerdescription'] !== 'no'), + "metaColor" => ($display['headermetacolor'] ?? '') ? '#' . $display['headermetacolor'] : '', + "name" => $display['theme'], + "textColor" => ($header) ? '#' . $header : '', + ], + "ts" => time(), + "uptime" => 1000 * (time() - round(strtok(exec("cat /proc/uptime"), ' '))), + "username" => (!empty($myservers['remote']['username']) && $pluginInstalled) ? $myservers['remote']['username'] : '', + "wanFQDN" => $nginx['NGINX_WANFQDN'] ?? '', ]; echo ""; @@ -111,9 +117,8 @@ echo " -