Project

General

Profile

Bug #12174 » guiconfig.inc_02AUG2021.patch

lufte grof, 08/02/2021 02:20 PM

View differences:

guiconfig.inc 2021-08-02 19:14:01.115537000 +0000
994 994
	return $content;
995 995
}
996 996

  
997
function gateway_info_popup($showgw) {
998
	global $config, $user_settings;
997
function gateway_info_popup($gw, $status) {
998
	global $config;
999 999

  
1000
	init_config_arr(array('gateways', 'gateway_group'));
1001
	$a_gateways = return_gateways_array();
1002
	$gateways_status = return_gateways_status(true);
1003

  
1004
	$content = "";
1005
	$gws = array();
1000
	/* Cache gateway status for this page load.
1001
	 * See https://redmine.pfsense.org/issues/12174 */
1006 1002
	$bgdanger = array('force_down', 'down', 'highloss', 'highdelay');
1007 1003
	$bgwarning = array('loss', 'delay');
1008
	$bgsuccess = array('none');
1004
	$bgsuccess = array('online', 'none');
1009 1005
	$bgcolor = "bg-info";
1010

  
1011
	if (is_array($a_gateways)) {
1012
		foreach ($a_gateways as $i => $gateway) {
1013
			if ($gateway['name'] == $showgw) {
1014
				$gws[] = $gateway['name'];
1015
			}
1016
		}
1017
	}
1018
	if (is_array($config['gateways']['gateway_group'])) {
1019
		foreach($config['gateways']['gateway_group'] as $gwgroup) {
1020
			if ($gwgroup['name'] == $showgw) {
1021
				foreach ($gwgroup['item'] as $member) {
1022
					$membersplit = explode("|", $member);
1023
					$gws[] = $membersplit[0];
1024
				}
1025
			}
1026
		}
1027
	}
1028

  
1029
	if (!empty($gws)) {
1030
		$content .= "<table>\n";
1031
		$content .= "<thead>\n";
1032
		$content .= "<tr>\n";
1033
		$content .= "<th>" . gettext("Name") . "</th><th style='padding-left: 10px;'>" . gettext("Interface") . "</th>";
1034
		$content .= "<th style='padding-left: 10px;'>" . gettext("Gateway") . "</th></tr>\n";
1035
		$content .= "</thead>\n";
1036
		$content .= "<tbody>\n";
1037
		foreach ($gws as $gw) {
1038
			foreach ($gateways_status as $gwstatus) {
1039
				if ($gwstatus['name'] == $gw) {
1040
					if (in_array($gwstatus['status'], $bgdanger)) {
1041
						$bgcolor = "bg-danger";
1042
					} elseif (in_array($gwstatus['status'], $bgwarning)) {
1043
						$bgcolor = "bg-warning";
1044
					} elseif (in_array($gwstatus['status'], $bgsuccess)) {
1045
						$bgcolor = "bg-success";
1046
					} else {
1047
						$bgcolor = "bg-info";
1048
					}
1049
				}
1050
			}
1051
			$content .= "	<tr class='{$bgcolor}'>\n";
1052
			$content .= "		<td>\n";
1053
			$content .= 			$gw;
1054
			$content .=	"		</td>\n";
1055
			$content .= "		<td style='padding-left: 10px;'>\n";
1056
			$content .= 			$config['interfaces'][lookup_gateway_interface_by_name($gw)]['descr'];
1057
			$content .=	"		</td>\n";
1058
			$content .= "		<td style='padding-left: 10px;'>\n";
1059
			$content .= 			lookup_gateway_ip_by_name($gw);
1060
			$content .=	"		</td>\n";
1061
			$content .= "	</tr>\n";
1062
			$idx++;
1063
		}
1064
		$content .= "</tbody>\n";
1065
		$content .= "</table>\n";
1006
	if (in_array($status[$gw]['status'], $bgdanger)) {
1007
		$bgcolor = "bg-danger";
1008
	} elseif (in_array($status[$gw]['status'], $bgwarning)) {
1009
		$bgcolor = "bg-warning";
1010
	} elseif (in_array($status[$gw]['status'], $bgsuccess)) {
1011
		$bgcolor = "bg-success";
1066 1012
	} else {
1067
		return;
1013
		$bgcolor = "bg-info";
1068 1014
	}
1069

  
1015
	$content .= "   <tr class='{$bgcolor}'>\n";
1016
	$content .= "           <td>\n";
1017
	$content .=                     $gw;
1018
	$content .=     "               </td>\n";
1019
	$content .= "           <td style='padding-left: 10px;'>\n";
1020
	$content .=                     $config['interfaces'][lookup_gateway_interface_by_name($gw)]['descr'];
1021
	$content .=     "               </td>\n";
1022
	$content .= "           <td style='padding-left: 10px;'>\n";
1023
	$content .=                     lookup_gateway_ip_by_name($gw);
1024
	$content .=     "               </td>\n";
1025
	$content .= "   </tr>\n";
1070 1026
	return $content;
1071 1027
}
1072 1028

  
(2-2/3)