--- guiconfig.inc.orig 2021-08-02 18:45:37.458860000 +0000 +++ guiconfig.inc 2021-08-02 19:14:01.115537000 +0000 @@ -994,79 +994,35 @@ return $content; } -function gateway_info_popup($showgw) { - global $config, $user_settings; +function gateway_info_popup($gw, $status) { + global $config; - init_config_arr(array('gateways', 'gateway_group')); - $a_gateways = return_gateways_array(); - $gateways_status = return_gateways_status(true); - - $content = ""; - $gws = array(); + /* Cache gateway status for this page load. + * See https://redmine.pfsense.org/issues/12174 */ $bgdanger = array('force_down', 'down', 'highloss', 'highdelay'); $bgwarning = array('loss', 'delay'); - $bgsuccess = array('none'); + $bgsuccess = array('online', 'none'); $bgcolor = "bg-info"; - - if (is_array($a_gateways)) { - foreach ($a_gateways as $i => $gateway) { - if ($gateway['name'] == $showgw) { - $gws[] = $gateway['name']; - } - } - } - if (is_array($config['gateways']['gateway_group'])) { - foreach($config['gateways']['gateway_group'] as $gwgroup) { - if ($gwgroup['name'] == $showgw) { - foreach ($gwgroup['item'] as $member) { - $membersplit = explode("|", $member); - $gws[] = $membersplit[0]; - } - } - } - } - - if (!empty($gws)) { - $content .= "\n"; - $content .= "\n"; - $content .= "\n"; - $content .= ""; - $content .= "\n"; - $content .= "\n"; - $content .= "\n"; - foreach ($gws as $gw) { - foreach ($gateways_status as $gwstatus) { - if ($gwstatus['name'] == $gw) { - if (in_array($gwstatus['status'], $bgdanger)) { - $bgcolor = "bg-danger"; - } elseif (in_array($gwstatus['status'], $bgwarning)) { - $bgcolor = "bg-warning"; - } elseif (in_array($gwstatus['status'], $bgsuccess)) { - $bgcolor = "bg-success"; - } else { - $bgcolor = "bg-info"; - } - } - } - $content .= " \n"; - $content .= " \n"; - $content .= " \n"; - $content .= " \n"; - $content .= " \n"; - $idx++; - } - $content .= "\n"; - $content .= "
" . gettext("Name") . "" . gettext("Interface") . "" . gettext("Gateway") . "
\n"; - $content .= $gw; - $content .= " \n"; - $content .= $config['interfaces'][lookup_gateway_interface_by_name($gw)]['descr']; - $content .= " \n"; - $content .= lookup_gateway_ip_by_name($gw); - $content .= "
\n"; + if (in_array($status[$gw]['status'], $bgdanger)) { + $bgcolor = "bg-danger"; + } elseif (in_array($status[$gw]['status'], $bgwarning)) { + $bgcolor = "bg-warning"; + } elseif (in_array($status[$gw]['status'], $bgsuccess)) { + $bgcolor = "bg-success"; } else { - return; + $bgcolor = "bg-info"; } - + $content .= " \n"; + $content .= " \n"; + $content .= $gw; + $content .= " \n"; + $content .= " \n"; + $content .= $config['interfaces'][lookup_gateway_interface_by_name($gw)]['descr']; + $content .= " \n"; + $content .= " \n"; + $content .= lookup_gateway_ip_by_name($gw); + $content .= " \n"; + $content .= " \n"; return $content; }