Esempio n. 1
0
<tbody>
<?php 
foreach ($a_gateways as $gname => $gateway) {
    ?>
	<tr>
		<td>
<?php 
    $if_gw = '';
    if (is_ipaddr($gateway['gateway'])) {
        $if_gw = $gateway['gateway'];
    } else {
        if ($gateway['ipprotocol'] == "inet") {
            $if_gw = get_interface_gateway($gateway['friendlyiface']);
        }
        if ($gateway['ipprotocol'] == "inet6") {
            $if_gw = get_interface_gateway_v6($gateway['friendlyiface']);
        }
    }
    ?>
			<?php 
    echo htmlspecialchars($gateway['name']);
    ?>
<br />
			<i><?php 
    echo $if_gw == '' ? '~' : htmlspecialchars($if_gw);
    ?>
</i>
		</td>
<?php 
    if ($gateways_status[$gname]) {
        if (stristr($gateways_status[$gname]['status'], "force_down")) {
Esempio n. 2
0
	</td>
	<td colspan="3" class="listr ellipsis" summary="address" align="center">
				<div id="gateway<?php 
    echo $counter;
    ?>
" style="display:inline"><b>
					<?php 
    $if_gw = '';
    if (is_ipaddr($gateway['gateway'])) {
        $if_gw = htmlspecialchars($gateway['gateway']);
    } else {
        if ($gateway['ipprotocol'] == "inet") {
            $if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
        }
        if ($gateway['ipprotocol'] == "inet6") {
            $if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
        }
    }
    echo $if_gw == '' ? '~' : $if_gw;
    unset($if_gw);
    $counter++;
    ?>
				</b></div>
			</td>
	</tr>
	<tr>
			<td class="listr ellipsis" align="center" id="gateway<?php 
    echo $counter;
    ?>
">
			<?php 
Esempio n. 3
0
function compose_table_body_contents()
{
    global $config;
    $rtnstr = '';
    $a_gateways = return_gateways_array();
    $gateways_status = array();
    $gateways_status = return_gateways_status(true);
    if (isset($config["widgets"]["gateways_widget"]["display_type"])) {
        $display_type = $config["widgets"]["gateways_widget"]["display_type"];
    } else {
        $display_type = "gw_ip";
    }
    foreach ($a_gateways as $gname => $gateway) {
        $rtnstr .= "<tr>\n";
        $rtnstr .= "<td>\n";
        $rtnstr .= htmlspecialchars($gateway['name']) . "<br />";
        $rtnstr .= '<div id="gateway' . $counter . '" style="display:inline"><b>';
        $monitor_address = "";
        $monitor_address_disp = "";
        if ($display_type == "monitor_ip" || $display_type == "both_ip") {
            $monitor_address = $gateway['monitor'];
            if ($monitor_address != "" && $display_type == "both_ip") {
                $monitor_address_disp = " (" . $monitor_address . ")";
            } else {
                $monitor_address_disp = $monitor_address;
            }
        }
        $if_gw = '';
        // If the user asked to display Gateway IP or both IPs, or asked for just monitor IP but the monitor IP is blank
        // then find the gateway IP (which is also the monitor IP if the monitor IP was not explicitly set).
        if ($display_type == "gw_ip" || $display_type == "both_ip" || $display_type == "monitor_ip" && $monitor_address == "") {
            if (is_ipaddr($gateway['gateway'])) {
                $if_gw = htmlspecialchars($gateway['gateway']);
            } else {
                if ($gateway['ipprotocol'] == "inet") {
                    $if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
                }
                if ($gateway['ipprotocol'] == "inet6") {
                    $if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
                }
            }
            if ($if_gw == "") {
                $if_gw = "~";
            }
        }
        if ($monitor_address == $if_gw) {
            $monitor_address_disp = "";
        }
        $rtnstr .= $if_gw . $monitor_address_disp;
        unset($if_gw);
        unset($monitor_address);
        unset($monitor_address_disp);
        $counter++;
        $rtnstr .= "</b>";
        $rtnstr .= "</div>\n";
        $rtnstr .= "</td>\n";
        if ($gateways_status[$gname]) {
            if (stristr($gateways_status[$gname]['status'], "force_down")) {
                $online = gettext("Offline (forced)");
                $bgcolor = "danger";
                // lightcoral
            } elseif (stristr($gateways_status[$gname]['status'], "down")) {
                $online = gettext("Offline");
                $bgcolor = "danger";
                // lightcoral
            } elseif (stristr($gateways_status[$gname]['status'], "loss")) {
                $online = gettext("Packetloss");
                $bgcolor = "warning";
                // khaki
            } elseif (stristr($gateways_status[$gname]['status'], "delay")) {
                $online = gettext("Latency");
                $bgcolor = "warning";
                // khaki
            } elseif ($gateways_status[$gname]['status'] == "none") {
                $online = gettext("Online");
                $bgcolor = "success";
                // lightgreen
            } elseif ($gateways_status[$gname]['status'] == "") {
                $online = gettext("Pending");
                $bgcolor = "info";
                // lightgray
            }
        } else {
            $online = gettext("Unknown");
            $bgcolor = "info";
            // lightblue
        }
        $rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['delay']) : gettext("Pending")) . "</td>\n";
        $rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['stddev']) : gettext("Pending")) . "</td>\n";
        $rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['loss']) : gettext("Pending")) . "</td>\n";
        $rtnstr .= '<td class="bg-' . $bgcolor . '">' . $online . "</td>\n";
        $rtnstr .= "</tr>\n";
    }
    return $rtnstr;
}