fix: PHP Warnings in Management Settings (#1805)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Enhanced remote access configuration handling to gracefully manage
missing or undefined parameter values.
* Improved overall system stability through safer default handling of
optional settings that may not be present.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Squidly271
2025-11-24 12:51:17 -05:00
committed by GitHub
parent 31af99e52f
commit 832e9d04f2
2 changed files with 6 additions and 6 deletions

View File

@@ -37,9 +37,9 @@ $passwd_result = exec('/usr/bin/passwd --status root');
$boolWebUIAuth = $isRegistered && (($passwd_result !== false) && (substr($passwd_result, 0, 6) == 'root P')); $boolWebUIAuth = $isRegistered && (($passwd_result !== false) && (substr($passwd_result, 0, 6) == 'root P'));
// Helper to determine the current value for the remote access input // Helper to determine the current value for the remote access input
$dynamicRemoteAccessType = $myServersFlashCfg['remote']['dynamicRemoteAccessType']; $dynamicRemoteAccessType = $myServersFlashCfg['remote']['dynamicRemoteAccessType'] ?? null;
$upnpEnabled = $myServersFlashCfg['remote']['upnpEnabled'] === 'yes'; $upnpEnabled = ($myServersFlashCfg['remote']['upnpEnabled'] ?? null) === 'yes';
$wanaccessEnabled = $myServersFlashCfg['remote']['wanaccess'] === 'yes'; $wanaccessEnabled = ($myServersFlashCfg['remote']['wanaccess'] ?? null) === 'yes';
$currentRemoteAccessValue = 'OFF'; $currentRemoteAccessValue = 'OFF';
if ($dynamicRemoteAccessType === 'STATIC') { if ($dynamicRemoteAccessType === 'STATIC') {
@@ -68,7 +68,7 @@ div.shade-gray{background-color:#121510;margin-top:10px;padding:8px 0 3px 0}
</style> </style>
<script> <script>
const hasMyUnraidNetCert = <?=($hasMyUnraidNetCert ? 'true' : 'false')?>; const hasMyUnraidNetCert = <?=($hasMyUnraidNetCert ? 'true' : 'false')?>;
const wanAccessOrg = "<?=$myServersFlashCfg['remote']['wanaccess']?>"; const wanAccessOrg = "<?=$myServersFlashCfg['remote']['wanaccess'] ?? null?>";
function registerServer(button) { function registerServer(button) {
@@ -196,7 +196,7 @@ function dnsCheckServer(button) {
} else { } else {
swal({ swal({
title: "Oops", title: "Oops",
text: "<?=sprintf(_("The Unraid server is unreachable from outside your network. Be sure you have configured your router to forward port") . " <strong style='font-weight: bold'>%u/TCP</strong> " . _("to the Unraid server at") . " <strong style='font-weight: bold'>%s</strong> " . _("port") . " <strong style='font-weight: bold'>%u</strong>", $myServersFlashCfg['remote']['wanport'], htmlspecialchars($eth0['IPADDR:0']??''), $var['PORTSSL']??443)?>", text: "<?=sprintf(_("The Unraid server is unreachable from outside your network. Be sure you have configured your router to forward port") . " <strong style='font-weight: bold'>%u/TCP</strong> " . _("to the Unraid server at") . " <strong style='font-weight: bold'>%s</strong> " . _("port") . " <strong style='font-weight: bold'>%u</strong>", $myServersFlashCfg['remote']['wanport']??"", htmlspecialchars($eth0['IPADDR:0']??''), $var['PORTSSL']??443)?>",
type: "error", type: "error",
html: true, html: true,
confirmButtonText: "_(Ok)_" confirmButtonText: "_(Ok)_"

View File

@@ -108,7 +108,7 @@ class UnraidOsCheck
* Note: CURLINFO_HEADER_OUT exposes request headers (not response headers) for curl_getinfo * Note: CURLINFO_HEADER_OUT exposes request headers (not response headers) for curl_getinfo
* @return string|false $out The fetched content * @return string|false $out The fetched content
*/ */
private function safe_http_get_contents(string $url, array $opts = [], array &$getinfo = NULL) { private function safe_http_get_contents(string $url, array $opts = [], ?array &$getinfo = NULL) {
// Use system http_get_contents if it exists // Use system http_get_contents if it exists
if (function_exists('http_get_contents')) { if (function_exists('http_get_contents')) {
return http_get_contents($url, $opts, $getinfo); return http_get_contents($url, $opts, $getinfo);