示例#1
0
function get_gatewaystats()
{
    $a_gateways = return_gateways_array();
    $gateways_status = array();
    $gateways_status = return_gateways_status(true);
    $data = "";
    $isfirst = true;
    foreach ($a_gateways as $gname => $gw) {
        if (!$isfirst) {
            $data .= ",";
        }
        $isfirst = false;
        $data .= $gw['name'] . ",";
        if ($gateways_status[$gname]) {
            $data .= lookup_gateway_ip_by_name($gname) . ",";
            $gws = $gateways_status[$gname];
            switch (strtolower($gws['status'])) {
                case "none":
                    $online = "Online";
                    $bgcolor = "#90EE90";
                    // lightgreen
                    break;
                case "down":
                    $online = "Offline";
                    $bgcolor = "#F08080";
                    // lightcoral
                    break;
                case "delay":
                    $online = "Latency";
                    $bgcolor = "#F0E68C";
                    // khaki
                    break;
                case "loss":
                    $online = "Packetloss";
                    $bgcolor = "#F0E68C";
                    // khaki
                    break;
                default:
                    $online = "Pending";
                    break;
            }
        } else {
            $data .= "~,";
            $gws['delay'] = "~";
            $gws['loss'] = "~";
            $online = "Unknown";
            $bgcolor = "#ADD8E6";
            // lightblue
        }
        $data .= $online == "Pending" ? "{$online},{$online}," : "{$gws['delay']},{$gws['loss']},";
        $data .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" style=\"table-layout: fixed;\" summary=\"status\"><tr><td bgcolor=\"{$bgcolor}\">&nbsp;{$online}&nbsp;</td></tr></table>";
    }
    return $data;
}
示例#2
0
function get_gatewaystats()
{
    $a_gateways = return_gateways_array();
    $gateways_status = array();
    $gateways_status = return_gateways_status(true);
    $data = "";
    $isfirst = true;
    foreach ($a_gateways as $gname => $gw) {
        if (!$isfirst) {
            $data .= ",";
        }
        $isfirst = false;
        $data .= $gw['name'] . ",";
        if ($gateways_status[$gname]) {
            $data .= "<b>" . lookup_gateway_ip_by_name($gname) . "</b>,";
            $gws = $gateways_status[$gname];
            switch (strtolower($gws['status'])) {
                case "none":
                    $online = "Online";
                    $bgcolor = "#90EE90";
                    // lightgreen
                    break;
                case "down":
                    $online = "Offline";
                    $bgcolor = "#F08080";
                    // lightcoral
                    break;
                case "delay":
                    $online = "Latency";
                    $bgcolor = "#F0E68C";
                    // khaki
                    break;
                case "loss":
                    $online = "Packetloss";
                    $bgcolor = "#F0E68C";
                    // khaki
                    break;
                default:
                    $online = "Pending";
                    break;
            }
        } else {
            $data .= "~,";
            $gws['delay'] = "~";
            $gws['loss'] = "~";
            $online = "Unknown";
            $bgcolor = "#ADD8E6";
            // lightblue
        }
        $data .= $online == "Pending" ? "{$online},{$online}," : "{$gws['delay']},{$gws['loss']},";
        $data .= "{$online}^{$bgcolor}";
    }
    return $data;
}
示例#3
0
function get_gatewaystats()
{
    $a_gateways = return_gateways_array();
    $gateways_status = array();
    $gateways_status = return_gateways_status(true);
    $data = "";
    $isfirst = true;
    foreach ($a_gateways as $gname => $gw) {
        if (!$isfirst) {
            $data .= ",";
        }
        $isfirst = false;
        $data .= $gw['name'] . ",";
        $data .= lookup_gateway_ip_by_name($gname) . ",";
        if ($gateways_status[$gname]) {
            $gws = $gateways_status[$gname];
            switch (strtolower($gws['status'])) {
                case "none":
                    $online = "Bağlandı";
                    $class = 'label label-success';
                    break;
                case "down":
                    $online = 'Bağlantı yok';
                    $class = 'label label-important';
                    break;
                case "delay":
                    $online = 'Uyarı: Gecikme';
                    $class = 'label label-warning';
                    break;
                case "loss":
                    $online = 'Uyarı, Paket kaybı';
                    $class = 'label label-warning';
                    break;
                default:
                    $online = 'Veri alınıyor.';
                    break;
            }
        } else {
            $online = 'Veri alınıyor.';
            $class = 'label';
        }
        $data .= $online == 'Veri alınıyor.' ? "{$online},{$online}," : "{$gws['delay']},{$gws['loss']},";
        $data .= "<span class=\"{$class}\">{$online}</span>";
    }
    return $data;
}
示例#4
0
function get_gatewaystats() {
	$a_gateways = return_gateways_array();
	$gateways_status = array();
	$gateways_status = return_gateways_status(true);
	$data = "";
	$isfirst = true;
	foreach($a_gateways as $gname => $gw) {
		if(!$isfirst) 
			$data .= ",";
		$isfirst = false;
		$data .= $gw['name'] . ",";
		$data .= lookup_gateway_ip_by_name($gname) . ",";
		if ($gateways_status[$gname]) {
			$gws = $gateways_status[$gname];
			switch(strtolower($gws['status'])) {
			case "none":
				$online = "Online";
				$bgcolor = "lightgreen";
				break;
			case "down":
				$online = "Offline";
				$bgcolor = "lightcoral";
				break;
			case "delay":
				$online = "Warning: Latency";
				$bgcolor = "khaki";
				break;
			case "loss":
				$online = "Warning: Packetloss";
				$bgcolor = "khaki";
				break;
			default:
				$online = "Gathering data";
				break;
			}
		} else {
			$online = "Gathering data";
			$bgcolor = "lightgray";
		}
		$data .= ($online == "Gathering data") ? "{$online},{$online}," : "{$gws['delay']},{$gws['loss']},";
		$data .= "<table><tr><td bgcolor=\"$bgcolor\" > $online </td></td></tr></table>";
	}
	return $data;
}
                 }
                 if ($_POST['ipprotocol'] == "inet" && $_POST['ipprotocol'] != $family) {
                     $input_errors[] = gettext("You can not assign an IPv6 gateway group on IPv4 Address Family rule");
                 }
             }
         }
     }
 }
 if ($_POST['ipprotocol'] != "" && $_POST['gateway'] != "" && is_ipaddr(lookup_gateway_ip_by_name($_POST['gateway']))) {
     if ($_POST['ipprotocol'] == "inet46" && $_POST['gateway'] != "") {
         $input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
     }
     if ($_POST['ipprotocol'] == "inet6" && !is_ipaddrv6(lookup_gateway_ip_by_name($_POST['gateway']))) {
         $input_errors[] = gettext("You can not assign an IPv4 Gateway to an IPv6 Filter rule");
     }
     if ($_POST['ipprotocol'] == "inet" && !is_ipaddrv4(lookup_gateway_ip_by_name($_POST['gateway']))) {
         $input_errors[] = gettext("You can not assign an IPv6 Gateway to an IPv4 Filter rule");
     }
 }
 if ($_POST['proto'] == "icmp" && $_POST['icmptype'] != "") {
     if ($_POST['ipprotocol'] == "inet46") {
         $input_errors[] = gettext("You can not assign a ICMP type to a rule that applies to IPv4 and IPv6");
     }
 }
 if ($_POST['proto'] != "tcp" && $_POST['proto'] != "udp" && $_POST['proto'] != "tcp/udp") {
     $_POST['srcbeginport'] = 0;
     $_POST['srcendport'] = 0;
     $_POST['dstbeginport'] = 0;
     $_POST['dstendport'] = 0;
 } else {
     if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport']) {
示例#6
0
$section->addInput(new Form_Input('domain', 'Domain', 'text', $pconfig['domain'], ['placeholder' => 'mycorp.com, home, office, private, etc.']))->setHelp('Do not use \'local\' as a domain name. It will cause local ' . 'hosts running mDNS (avahi, bonjour, etc.) to be unable to resolve ' . 'local hosts not running mDNS.');
$form->add($section);
$section = new Form_Section('DNS Server Settings');
for ($i = 1; $i < 5; $i++) {
    //	if (!isset($pconfig['dns'.$i]))
    //		continue;
    $group = new Form_Group('DNS Server ' . $i);
    $group->add(new Form_Input('dns' . $i, 'DNS Server', 'text', $pconfig['dns' . $i]))->setHelp($i == 4 ? 'Address' : null);
    $help = "Enter IP addresses to be used by the system for DNS resolution. " . "These are also used for the DHCP service, DNS forwarder and for PPTP VPN clients.";
    if ($multiwan) {
        $options = array('none' => 'none');
        foreach ($arr_gateways as $gwname => $gwitem) {
            if (is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && is_ipaddrv6($gwitem['gateway'])) {
                continue;
            }
            if (is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && is_ipaddrv4($gwitem['gateway'])) {
                continue;
            }
            $options[$gwname] = $gwname . ' - ' . $gwitem['friendlyiface'] . ' - ' . $gwitem['gateway'];
        }
        $group->add(new Form_Select('dns' . $i . 'gw', 'Gateway', $pconfig['dns' . $i . 'gw'], $options))->setHelp($i == 4 ? 'Gateway' : null);
        $help .= '<br/>' . "In addition, optionally select the gateway for each DNS server. " . "When using multiple WAN connections there should be at least one unique DNS server per gateway.";
    }
    if ($i == 4) {
        $group->setHelp($help);
    }
    $section->add($group);
}
$section->addInput(new Form_Checkbox('dnsallowoverride', 'DNS Server Override', 'Allow DNS server list to be overridden by DHCP/PPP on WAN', $pconfig['dnsallowoverride']))->setHelp(sprintf(gettext('If this option is set, %s will use DNS servers ' . 'assigned by a DHCP/PPP server on WAN for its own purposes (including ' . 'the DNS forwarder). However, they will not be assigned to DHCP and PPTP ' . 'VPN clients.'), $g['product_name']));
$section->addInput(new Form_Checkbox('dnslocalhost', 'Disable DNS Forwarder', 'Do not use the DNS Forwarder as a DNS server for the firewall', $pconfig['dnslocalhost']))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS ' . 'server where the DNS Forwarder or DNS Resolver is enabled and set to ' . 'listen on Localhost, so system can use the local DNS service to perform ' . 'lookups. Checking this box omits localhost from the list of DNS servers.');
$form->add($section);
 }
 if ($_POST['ipprotocol'] != "" && $_POST['gateway'] != "") {
     if (is_array($config['gateways']['gateway_group'])) {
         foreach ($config['gateways']['gateway_group'] as $gw_group) {
             if ($gw_group['name'] == $_POST['gateway'] && $_POST['ipprotocol'] != $a_gatewaygroups[$_POST['gateway']]['ipprotocol']) {
                 if ($_POST['ipprotocol'] == "inet46") {
                     $input_errors[] = gettext("Gateways can not be assigned in a rule that applies to both IPv4 and IPv6.");
                 } elseif ($_POST['ipprotocol'] == "inet6") {
                     $input_errors[] = gettext("An IPv4 gateway group can not be assigned in IPv6 rules.");
                 } elseif ($_POST['ipprotocol'] == "inet") {
                     $input_errors[] = gettext("An IPv6 gateway group can not be assigned in IPv4 rules.");
                 }
             }
         }
     }
     if ($iptype = is_ipaddr(lookup_gateway_ip_by_name($_POST['gateway']))) {
         // this also implies that  $_POST['gateway'] was set and not empty
         if ($_POST['ipprotocol'] == "inet46") {
             $input_errors[] = gettext("Gateways can not be assigned in a rule that applies to both IPv4 and IPv6.");
         }
         if ($_POST['ipprotocol'] == "inet6" && $iptype != 6) {
             $input_errors[] = gettext("An IPv4 gateway can not be assigned in IPv6 rules.");
         }
         if ($_POST['ipprotocol'] == "inet" && $iptype != 4) {
             $input_errors[] = gettext("An IPv6 gateway can not be assigned in IPv4 rules.");
         }
     }
 }
 if ($_POST['proto'] == "icmp" && $_POST['icmptype'] != "") {
     if ($_POST['ipprotocol'] == "inet46") {
         $input_errors[] = gettext("An ICMP type can not be assigned to a rule that applies to IPv4 and IPv6");
示例#8
0
 $pconfig = $_POST;
 /* input validation */
 $reqdfields = explode(" ", "network network_subnet gateway");
 $reqdfieldsn = explode(",", gettext("Destination network") . "," . gettext("Destination network bit count") . "," . gettext("Gateway"));
 do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
 if ($_POST['network'] && !is_ipaddr($_POST['network']) && !is_alias($_POST['network'])) {
     $input_errors[] = gettext("A valid IPv4 or IPv6 destination network must be specified.");
 }
 if ($_POST['network_subnet'] && !is_numeric($_POST['network_subnet'])) {
     $input_errors[] = gettext("A valid destination network bit count must be specified.");
 }
 if ($_POST['gateway'] && is_ipaddr($_POST['network'])) {
     if (!isset($a_gateways[$_POST['gateway']])) {
         $input_errors[] = gettext("A valid gateway must be specified.");
     }
     if (!validate_address_family($_POST['network'], lookup_gateway_ip_by_name($_POST['gateway']))) {
         $input_errors[] = gettext("The gateway '{$a_gateways[$_POST['gateway']]['gateway']}' is a different Address Family as network '{$_POST['network']}'.");
     }
 }
 /* check for overlaps */
 $current_targets = get_staticroutes(true);
 $new_targets = array();
 if (is_ipaddrv6($_POST['network'])) {
     $osn = Net_IPv6::compress(gen_subnetv6($_POST['network'], $_POST['network_subnet'])) . "/" . $_POST['network_subnet'];
     $new_targets[] = $osn;
 }
 if (is_ipaddr($_POST['network'])) {
     if ($_POST['network_subnet'] > 32) {
         $input_errors[] = gettext("A IPv4 subnet can not be over 32 bits.");
     } else {
         $osn = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
示例#9
0
echo gettext("Description");
?>
</td>
		</tr>
		  <?php 
foreach ($a_gateways as $gname => $gateway) {
    ?>
                <tr>
                  <td class="listlr">
				<?php 
    echo $gateway['name'];
    ?>
                  </td>
                  <td class="listr" align="center" >
                                <?php 
    echo lookup_gateway_ip_by_name($gname);
    ?>
                  </td>
                  <td class="listr" align="center" >
                                <?php 
    if ($gateways_status[$gname]) {
        echo $gateways_status[$gname]['monitorip'];
    } else {
        echo $gateway['monitorip'];
    }
    ?>
                  </td>
		<td class="listr" align="center">
		<?php 
    if ($gateways_status[$gname]) {
        echo $gateways_status[$gname]['delay'];
示例#10
0
function get_gatewaystats()
{
    global $config;
    if (isset($config["widgets"]["gateways_widget"]["display_type"])) {
        $display_type = $config["widgets"]["gateways_widget"]["display_type"];
    } else {
        $display_type = "gw_ip";
    }
    $a_gateways = return_gateways_array();
    $gateways_status = array();
    $gateways_status = return_gateways_status(true);
    $data = "";
    $isfirst = true;
    foreach ($a_gateways as $gname => $gw) {
        if (!$isfirst) {
            $data .= ",";
        }
        $isfirst = false;
        $data .= $gw['name'] . ",";
        $monitor_address = "";
        $monitor_address_disp = "";
        if ($display_type == "monitor_ip" || $display_type == "both_ip") {
            $monitor_address = $gw['monitor'];
            if ($monitor_address != "" && $display_type == "both_ip") {
                $monitor_address_disp = " (" . $monitor_address . ")";
            } else {
                $monitor_address_disp = $monitor_address;
            }
        }
        if ($gateways_status[$gname]) {
            if ($display_type == "gw_ip" || $display_type == "both_ip" || $display_type == "monitor_ip" && $monitor_address == "") {
                $if_gw = lookup_gateway_ip_by_name($gname);
            } else {
                $if_gw = "";
            }
            if ($monitor_address == $if_gw) {
                $monitor_address_disp = "";
            }
            $data .= "<b>" . $if_gw . $monitor_address_disp . "</b>,";
            $gws = $gateways_status[$gname];
            switch (strtolower($gws['status'])) {
                case "none":
                    $online = "Online";
                    $bgcolor = "#90EE90";
                    // lightgreen
                    break;
                case "down":
                    $online = "Offline";
                    $bgcolor = "#F08080";
                    // lightcoral
                    break;
                case "delay":
                    $online = "Latency";
                    $bgcolor = "#F0E68C";
                    // khaki
                    break;
                case "loss":
                    $online = "Packetloss";
                    $bgcolor = "#F0E68C";
                    // khaki
                    break;
                default:
                    $online = "Pending";
                    break;
            }
        } else {
            if ($display_type == "gw_ip" || $display_type == "both_ip" || $display_type == "monitor_ip" && $monitor_address == "") {
                $if_gw = "~";
            } else {
                $if_gw = "";
            }
            $data .= $if_gw . $monitor_address_disp . ",";
            $gws['delay'] = "~";
            $gws['loss'] = "~";
            $online = "Unknown";
            $bgcolor = "#ADD8E6";
            // lightblue
        }
        $data .= $online == "Pending" ? "{$online},{$online}," : "{$gws['delay']},{$gws['loss']},";
        $data .= "{$online}^{$bgcolor}";
    }
    return $data;
}
                    <br> <span class="vexpl"><?php 
echo gettext("Group Name");
?>
</span></td>
                </tr>
		<tr>
                  <td width="22%" valign="top" class="vncellreq"><?php 
echo gettext("Gateway Priority");
?>
</td>
                  <td width="78%" class="vtable"> 
		<?php 
foreach ($a_gateways as $gwname => $gateway) {
    if (!empty($pconfig['item'])) {
        $af = explode("|", $pconfig['item'][0]);
        if (!validate_address_family(lookup_gateway_ip_by_name($af[0]), $gateway['gateway'])) {
            continue;
        }
    }
    $selected = array();
    $interface = $gateway['interface'];
    foreach ((array) $pconfig['item'] as $item) {
        $itemsplit = explode("|", $item);
        if ($itemsplit[0] == $gwname) {
            $selected[$itemsplit[1]] = "selected";
            break;
        } else {
            $selected[0] = "selected";
        }
    }
    echo "<select name='{$gwname}' class='formfldselect' id='{$gwname}'>";
示例#12
0
    }
    if ($gwname == $pconfig['gateway']) {
        $selected = " SELECTED";
    } else {
        $selected = "";
    }
    echo "<option value=\"{$gwname}\" {$selected}>{$gw['name']} - {$gw['gateway']}</option>\n";
}
/* add gateway groups to the list */
if (is_array($config['gateways']['gateway_group'])) {
    foreach ($config['gateways']['gateway_group'] as $gw_group) {
        $af = explode("|", $gw_group['item'][0]);
        if ($pconfig['ipprotocol'] == "inet6" && !is_ipaddrv6(lookup_gateway_ip_by_name($af[0]))) {
            continue;
        }
        if ($pconfig['ipprotocol'] == "inet" && !is_ipaddrv4(lookup_gateway_ip_by_name($af[0]))) {
            continue;
        }
        if ($gw_group['name'] == "") {
            continue;
        }
        if ($pconfig['gateway'] == $gw_group['name']) {
            $selected = " SELECTED";
        } else {
            $selected = "";
        }
        echo "<option value=\"{$gw_group['name']}\" {$selected}>{$gw_group['name']}</option>\n";
    }
}
?>
					</select>