diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page new file mode 100644 index 000000000..f0f4305a8 --- /dev/null +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page @@ -0,0 +1,699 @@ +Menu="ManagementAccess:100" +Title="Unraid Connect" +Icon="icon-u-globe" +Tag="globe" +--- + + +$keyfile = empty($var['regFILE']) ? null : @file_get_contents($var['regFILE']); +if ($keyfile !== false) { + $keyfile = @base64_encode($keyfile); +} +// note: $myservers variable defined in myservers1.php, by parsing myservers.cfg +// ensure some vars are defined here so we don't have to test them later +if (empty($myservers['remote']['apikey'])) { + $myservers['remote']['apikey'] = ""; +} +if (empty($myservers['remote']['wanaccess'])) { + $myservers['remote']['wanaccess'] = "no"; +} +if (empty($myservers['remote']['wanport'])) { + $myservers['remote']['wanport'] = 33443; +} +if (empty($myservers['remote']['upnpEnabled'])) { + $myservers['remote']['upnpEnabled'] = "no"; +} +if (empty($myservers['remote']['dynamicRemoteAccessType'])) { + $myservers['remote']['dynamicRemoteAccessType'] = "DISABLED"; +} +$showT2Fa = (file_exists('/boot/config/plugins/dynamix.my.servers/showT2Fa')); + +$nginx = parse_ini_file('/var/local/emhttp/nginx.ini'); +$hasMyUnraidNetCert = preg_match('/.*\.myunraid\.net$/', $nginx['NGINX_CERTNAME']); + +$isRegistered = !empty($myservers['remote']['username']); + +$myservers_memory_cfg_path ='/var/local/emhttp/myservers.cfg'; +$mystatus = (file_exists($myservers_memory_cfg_path)) ? @parse_ini_file($myservers_memory_cfg_path) : []; +$isConnected = (($mystatus['minigraph']??'')==='CONNECTED') ? true : false; +$flashbackup_ini = '/var/local/emhttp/flashbackup.ini'; +$flashbackup_status = (file_exists($flashbackup_ini)) ? @parse_ini_file($flashbackup_ini) : []; + +$passwd_result = exec('/usr/bin/passwd --status root'); +$boolWebUIAuth = $isRegistered && (($passwd_result !== false) && (substr($passwd_result, 0, 6) == 'root P')); + +// Helper to determine the current value for the remote access input +$dynamicRemoteAccessType = $myservers['remote']['dynamicRemoteAccessType']; +$upnpEnabled = $myservers['remote']['upnpEnabled'] === 'yes'; +$wanaccessEnabled = $myservers['remote']['wanaccess'] === 'yes'; + +$currentRemoteAccessValue = 'OFF'; +if ($dynamicRemoteAccessType === 'STATIC') { + $currentRemoteAccessValue = 'DYNAMIC_MANUAL'; +} elseif ($dynamicRemoteAccessType === 'UPNP') { + $currentRemoteAccessValue = 'DYNAMIC_UPNP'; +} elseif ($dynamicRemoteAccessType === 'DISABLED' && $wanaccessEnabled && $upnpEnabled) { + $currentRemoteAccessValue = 'ALWAYS_UPNP'; +} elseif ($dynamicRemoteAccessType === 'DISABLED' && $wanaccessEnabled && !$upnpEnabled) { + $currentRemoteAccessValue = 'ALWAYS_MANUAL'; +} + +/** + * mimicking PHP vars below in javascript to ensure people can't trick the js postobj + * by disabling html attrs and vars before the post sends to set the field + */ +$enableRemoteT2fa = $showT2Fa && $currentRemoteAccessValue !== 'OFF' && $hasMyUnraidNetCert; +$enableLocalT2fa = $showT2Fa && $var['USE_SSL'] === 'auto' && $hasMyUnraidNetCert; +$shade="shade-".($display['theme']??'unk'); +?> + + + +
+ +