This commit is contained in:
gnhb 2010-06-08 07:06:46 +07:00
commit b20f736344
11 changed files with 113 additions and 618 deletions

View File

@ -256,8 +256,8 @@ function return_gateways_status() {
$target = $info[0];
$status[$target]['name'] = $info[1];
$status[$target]['lastcheck'] = $info[4] ? date('r', $info[4]) : date('r');
$status[$target]['delay'] = $info[5];
$status[$target]['loss'] = $info[6];
$status[$target]['delay'] = empty($info[5]) ? 0 : $info[5];
$status[$target]['loss'] = empty($info[6]) ? "0.0%" : $info[6] . "%";
$status[$target]['status'] = trim($info[7]);
}
return($status);
@ -458,19 +458,15 @@ function dhclient_update_gateway_groups_defaultroute($interface = "wan") {
}
function lookup_gateway_ip_by_name($name) {
global $config;
if(is_array($config['gateways']['gateway_item'])) {
foreach($config['gateways']['gateway_item'] as $gateway) {
if($gateway['name'] == $name)
return ($gateway['gateway']);
}
} else
return (false);
$gateways_arr = return_gateways_array();
if (!empty($gateways_arr[$name]))
return $gateways_arr[$name]['gateway'];
return false;
}
function lookup_gateway_monitor_ip_by_name($name) {
global $config;
$gateways_arr = return_gateways_array();
if (!empty($gateways_arr[$name])) {
@ -489,7 +485,6 @@ function lookup_gateway_monitor_ip_by_name($name) {
}
function lookup_gateway_interface_by_name($name) {
global $config;
$gateways_arr = return_gateways_array();
if (!empty($gateways_arr[$name])) {
@ -509,8 +504,14 @@ function get_interface_gateway($interface, &$dynamic = false) {
$gwcfg = $config['interfaces'][$interface];
if (is_ipaddr($gwcfg['gateway']))
$gw = $gwcfg['gateway'];
else if (!empty($gwcfg['gateway']))
$gw = lookup_gateway_ip_by_name($gwcfg['gateway']);
else if (!empty($gwcfg['gateway']) && is_array($config['gateways']['gateway_item'])) {
foreach($config['gateways']['gateway_item'] as $gateway) {
if ($gateway['name'] == $gwcfg['gateway']) {
$gw = $gateway['gateway'];
break;
}
}
}
// for dynamic interfaces we handle them through the $interface_router file.
if (!is_ipaddr($gw) && !is_ipaddr($gwcfg['ipaddr'])) {

View File

@ -1065,18 +1065,20 @@ EOD;
if (isset($pptpdcfg["wins"]) && $pptpdcfg['wins'] != "")
$mpdconf .= " set ipcp nbns {$pptpdcfg['wins']}\n";
if (is_array($pptpdcfg['dnsserver']) && ($pptpdcfg['dnsserver'][0])) {
$mpdconf .= " set ipcp dns " . join(" ", $pptpdcfg['dnsserver']) . "\n";
} else
if (isset ($config['dnsmasq']['enable'])) {
$mpdconf .= " set ipcp dns " . get_interface_ip("lan");
if ($syscfg['dnsserver'][0])
$mpdconf .= " " . $syscfg['dnsserver'][0];
$mpdconf .= "\n";
} else
if (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
$mpdconf .= " set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
}
if (!empty($pptpdcfg['dns1'])) {
$mpdconf .= " set ipcp dns " . $pptpdcfg['dns1'];
if (!empty($pptpdcfg['dns2']))
$mpdconf .= " " . $pptpdcfg['dns2'];
$mpdconf .= "\n";
} elseif (isset ($config['dnsmasq']['enable'])) {
$mpdconf .= " set ipcp dns " . get_interface_ip("lan");
if ($syscfg['dnsserver'][0])
$mpdconf .= " " . $syscfg['dnsserver'][0];
$mpdconf .= "\n";
} elseif (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
$mpdconf .= " set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
}
if (isset ($pptpdcfg['radius']['server']['enable'])) {
$authport = (isset($pptpdcfg['radius']['server']['port']) && strlen($pptpdcfg['radius']['server']['port']) > 1) ? $pptpdcfg['radius']['server']['port'] : 1812;
@ -1274,15 +1276,19 @@ pppoe_standart:
EOD;
if (isset ($config['dnsmasq']['enable'])) {
if (!empty($pppoecfg['dns1'])) {
$mpdconf .= " set ipcp dns " . $pppoecfg['dns1'];
if (!empty($pppoecfg['dns2']))
$mpdconf .= " " . $pppoecfg['dns2'];
$mpdconf .= "\n";
} elseif (isset ($config['dnsmasq']['enable'])) {
$mpdconf .= " set ipcp dns " . get_interface_ip("lan");
if ($syscfg['dnsserver'][0])
$mpdconf .= " " . $syscfg['dnsserver'][0];
$mpdconf .= "\n";
} else
if (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
} elseif (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
$mpdconf .= " set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
}
}
if (isset ($pppoecfg['radius']['enable'])) {
$mpdconf .=<<<EOD
@ -1454,15 +1460,19 @@ l2tp_standard:
EOD;
if (isset ($config['dnsmasq']['enable'])) {
if (!empty($l2tpcfg['dns1'])) {
$mpdconf .= " set ipcp dns " . $l2tpcfg['dns1'];
if (!empty($l2tpcfg['dns2']))
$mpdconf .= " " . $l2tpcfg['dns2'];
$mpdconf .= "\n";
} elseif (isset ($config['dnsmasq']['enable'])) {
$mpdconf .= " set ipcp dns " . get_interface_ip("lan");
if ($syscfg['dnsserver'][0])
$mpdconf .= " " . $syscfg['dnsserver'][0];
$mpdconf .= "\n";
} else
if (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
} elseif (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
$mpdconf .= " set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
}
}
if (isset ($l2tpcfg['radius']['enable'])) {
$mpdconf .=<<<EOD

Binary file not shown.

View File

@ -1,484 +0,0 @@
#! /bin/sh
# Install GRUB on your drive.
# Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Initialize some variables.
prefix=/usr/local
exec_prefix=${prefix}
sbindir=${exec_prefix}/sbin
libdir=/usr/local/share
PACKAGE=grub
VERSION=0.97
host_cpu=i386
host_os=freebsd7.0
host_vendor=freebsd
pkglibdir=${libdir}/${PACKAGE}/${host_cpu}-${host_vendor}
grub_shell=${sbindir}/grub
grub_set_default=${sbindir}/grub-set-default
log_file=/tmp/grub-install.log.$$
img_file=/tmp/grub-install.img.$$
rootdir=
grub_prefix=/boot/grub
install_device=
no_floppy=
force_lba=
recheck=no
debug=no
# look for secure tempfile creation wrappers on this platform
if test -x /bin/tempfile; then
mklog="/bin/tempfile --prefix=grub"
mkimg="/bin/tempfile --prefix=grub"
elif test -x /bin/mktemp; then
mklog="/bin/mktemp /tmp/grub-install.log.XXXXXX"
mkimg="/bin/mktemp /tmp/grub-install.img.XXXXXX"
else
mklog=""
mkimg=""
fi
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: grub-install [OPTION] install_device
Install GRUB on your drive.
-h, --help print this message and exit
-v, --version print the version information and exit
--root-directory=DIR install GRUB images under the directory DIR
instead of the root directory
--grub-shell=FILE use FILE as the grub shell
--no-floppy do not probe any floppy drive
--force-lba force GRUB to use LBA mode even for a buggy
BIOS
--recheck probe a device map even if it already exists
INSTALL_DEVICE can be a GRUB device name or a system device filename.
grub-install copies GRUB images into the DIR/boot directory specfied by
--root-directory, and uses the grub shell to install grub into the boot
sector.
Report bugs to <bug-grub@gnu.org>.
EOF
}
# Usage: convert os_device
# Convert an OS device to the corresponding GRUB drive.
# This part is OS-specific.
convert () {
# First, check if the device file exists.
if test -e "$1"; then
:
else
echo "$1: Not found or not a block device." 1>&2
exit 1
fi
# Break the device name into the disk part and the partition part.
case "$host_os" in
linux*)
tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
-e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
-e 's%\(fd[0-9]*\)$%\1%' \
-e 's%/part[0-9]*$%/disc%' \
-e 's%\(c[0-7]d[0-9]*\).*$%\1%'`
tmp_part=`echo "$1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
-e 's%.*d[0-9]*p%%' \
-e 's%.*/fd[0-9]*$%%' \
-e 's%.*/floppy/[0-9]*$%%' \
-e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
-e 's%.*c[0-7]d[0-9]*p%%'`
;;
gnu*)
tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'`
tmp_part=`echo "$1" | sed "s%$tmp_disk%%"` ;;
freebsd[234]* | kfreebsd*-gnu)
tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%r\1%' \
| sed 's%r\{0,1\}\(da[0-9]*\).*$%r\1%'`
tmp_part=`echo "$1" \
| sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \
| sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"`
;;
freebsd[567]*)
tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%\1%' \
| sed 's%r\{0,1\}\(da[0-9]*\).*$%\1%'`
tmp_part=`echo "$1" \
| sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \
| sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"`
;;
netbsd* | knetbsd*-gnu)
tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([sw]d[0-9]*\).*$%r\1d%' \
| sed 's%r\{0,1\}\(fd[0-9]*\).*$%r\1a%'`
tmp_part=`echo "$1" \
| sed "s%.*/r\{0,1\}[sw]d[0-9]\([abe-p]\)%\1%"`
;;
*)
echo "grub-install does not support your OS yet." 1>&2
exit 1 ;;
esac
# Get the drive name.
tmp_drive=`grep -v '^#' $device_map | grep "$tmp_disk *$" \
| sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'`
# If not found, print an error message and exit.
if test "x$tmp_drive" = x; then
echo "$1 does not have any corresponding BIOS drive." 1>&2
exit 1
fi
if test "x$tmp_part" != x; then
# If a partition is specified, we need to translate it into the
# GRUB's syntax.
case "$host_os" in
linux*)
echo "$tmp_drive" | sed "s%)$%,`expr $tmp_part - 1`)%" ;;
gnu*)
if echo $tmp_part | grep "^s" >/dev/null; then
tmp_pc_slice=`echo $tmp_part \
| sed "s%s\([0-9]*\)[a-g]*$%\1%"`
tmp_drive=`echo "$tmp_drive" \
| sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"`
fi
if echo $tmp_part | grep "[a-g]$" >/dev/null; then
tmp_bsd_partition=`echo "$tmp_part" \
| sed "s%[^a-g]*\([a-g]\)$%\1%"`
tmp_drive=`echo "$tmp_drive" \
| sed "s%)%,$tmp_bsd_partition)%"`
fi
echo "$tmp_drive" ;;
freebsd* | kfreebsd*-gnu)
if echo $tmp_part | grep "^s" >/dev/null; then
tmp_pc_slice=`echo $tmp_part \
| sed "s%s\([0-9]*\)[a-h]*$%\1%"`
tmp_drive=`echo "$tmp_drive" \
| sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"`
fi
if echo $tmp_part | grep "[a-h]$" >/dev/null; then
tmp_bsd_partition=`echo "$tmp_part" \
| sed "s%s\{0,1\}[0-9]*\([a-h]\)$%\1%"`
tmp_drive=`echo "$tmp_drive" \
| sed "s%)%,$tmp_bsd_partition)%"`
fi
echo "$tmp_drive" ;;
netbsd* | knetbsd*-gnu)
if echo $tmp_part | grep "^[abe-p]$" >/dev/null; then
tmp_bsd_partition=`echo "$tmp_part" \
| sed "s%\([a-p]\)$%\1%"`
tmp_drive=`echo "$tmp_drive" \
| sed "s%)%,$tmp_bsd_partition)%"`
fi
echo "$tmp_drive" ;;
esac
else
# If no partition is specified, just print the drive name.
echo "$tmp_drive"
fi
}
# Usage: resolve_symlink file
# Find the real file/device that file points at
resolve_symlink () {
tmp_fname=$1
# Resolve symlinks
while test -L $tmp_fname; do
tmp_new_fname=`ls -al $tmp_fname | sed -n 's%.*-> \(.*\)%\1%p'`
if test -z "$tmp_new_fname"; then
echo "Unrecognized ls output" 2>&1
exit 1
fi
# Convert relative symlinks
case $tmp_new_fname in
/*) tmp_fname="$tmp_new_fname"
;;
*) tmp_fname="`echo $tmp_fname | sed 's%/[^/]*$%%'`/$tmp_new_fname"
;;
esac
done
echo "$tmp_fname"
}
# Usage: find_device file
# Find block device on which the file resides.
find_device () {
# For now, this uses the program `df' to get the device name, but is
# this really portable?
tmp_fname=`df $1/ | sed -n 's%.*\(/dev/[^ ]*\).*%\1%p'`
if test -z "$tmp_fname"; then
echo "Could not find device for $1" 2>&1
exit 1
fi
tmp_fname=`resolve_symlink $tmp_fname`
echo "$tmp_fname"
}
# Check the arguments.
for option in "$@"; do
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${VERSION})"
exit 0 ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--grub-shell=*)
grub_shell=`echo "$option" | sed 's/--grub-shell=//'` ;;
--no-floppy)
no_floppy="--no-floppy" ;;
--force-lba)
force_lba="--force-lba" ;;
--recheck)
recheck=yes ;;
# This is an undocumented feature...
--debug)
debug=yes ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
exit 1
;;
*)
if test "x$install_device" != x; then
echo "More than one install_devices?" 1>&2
usage
exit 1
fi
install_device="${option}" ;;
esac
done
if test "x$install_device" = x; then
echo "install_device not specified." 1>&2
usage
exit 1
fi
# If the debugging feature is enabled, print commands.
if test $debug = yes; then
set -x
fi
# Initialize these directories here, since ROOTDIR was initialized.
case "$host_os" in
netbsd* | openbsd*)
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=/grub
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
grubdir=${bootdir}/grub
device_map=${grubdir}/device.map
# Check if GRUB is installed.
# This is necessary, because the user can specify "grub --read-only".
set $grub_shell dummy
if test -f "$1"; then
:
else
echo "$1: Not found." 1>&2
exit 1
fi
if test -f "$pkglibdir/stage1"; then
:
else
echo "${pkglibdir}/stage1: Not found." 1>&2
exit 1
fi
if test -f "$pkglibdir/stage2"; then
:
else
echo "${pkglibdir}/stage2: Not found." 1>&2
exit 1
fi
# Don't check for *stage1_5, because it is not fatal even if any
# Stage 1.5 does not exist.
# Create the GRUB directory if it is not present.
test -d "$bootdir" || mkdir "$bootdir" || exit 1
test -d "$grubdir" || mkdir "$grubdir" || exit 1
# If --recheck is specified, remove the device map, if present.
if test $recheck = yes; then
rm -f $device_map
fi
# Create the device map file if it is not present.
if test -f "$device_map"; then
:
else
# Create a safe temporary file.
test -n "$mklog" && log_file=`$mklog`
$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
quit
EOF
if grep "Error [0-9]*: " $log_file >/dev/null; then
cat $log_file 1>&2
exit 1
fi
rm -f $log_file
fi
# Make sure that there is no duplicated entry.
tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \
| sort | uniq -d | sed -n 1p`
if test -n "$tmp"; then
echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2
exit 1
fi
# Check for INSTALL_DEVICE.
case "$install_device" in
/dev/*)
install_device=`resolve_symlink "$install_device"`
install_drive=`convert "$install_device"`
# I don't know why, but some shells wouldn't die if exit is
# called in a function.
if test "x$install_drive" = x; then
exit 1
fi ;;
\([hf]d[0-9]*\))
install_drive="$install_device" ;;
[hf]d[0-9]*)
# The GRUB format with no parenthesis.
install_drive="($install_device)" ;;
*)
echo "Format of install_device not recognized." 1>&2
usage
exit 1 ;;
esac
# Get the root drive.
root_device=`find_device ${rootdir}`
bootdir_device=`find_device ${bootdir}`
# Check if the boot directory is in the same device as the root directory.
if test "x$root_device" != "x$bootdir_device"; then
# Perhaps the user has a separate boot partition.
root_device=$bootdir_device
grub_prefix="/grub"
fi
# Convert the root device to a GRUB drive.
root_drive=`convert "$root_device"`
if test "x$root_drive" = x; then
exit 1
fi
# Check if the root directory exists in the same device as the grub
# directory.
grubdir_device=`find_device ${grubdir}`
if test "x$grubdir_device" != "x$root_device"; then
# For now, cannot deal with this situation.
cat <<EOF 1>&2
You must set the root directory by the option --root-directory, because
$grubdir does not exist in the root device $root_device.
EOF
exit 1
fi
# Copy the GRUB images to the GRUB directory.
for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do
rm -f $file || exit 1
done
for file in \
${pkglibdir}/stage1 ${pkglibdir}/stage2 ${pkglibdir}/*stage1_5; do
cp -f $file ${grubdir} || exit 1
done
# Make a default file.
${grub_set_default} --root-directory=${rootdir} default
# Make sure that GRUB reads the same images as the host OS.
test -n "$mkimg" && img_file=`$mkimg`
test -n "$mklog" && log_file=`$mklog`
for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do
count=5
tmp=`echo $file | sed "s|^${grubdir}|${grub_prefix}|"`
while test $count -gt 0; do
$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
dump ${root_drive}${tmp} ${img_file}
quit
EOF
if grep "Error [0-9]*: " $log_file >/dev/null; then
:
elif cmp $file $img_file >/dev/null; then
break
fi
sleep 1
count=`expr $count - 1`
done
if test $count -eq 0; then
echo "The file $file not read correctly." 1>&2
echo
fi
done
rm -f $img_file
rm -f $log_file
# Create a safe temporary file.
test -n "$mklog" && log_file=`$mklog`
# Now perform the installation.
$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
root $root_drive
setup $force_lba --stage2=$grubdir/stage2 --prefix=$grub_prefix $install_drive
quit
EOF
if grep "Error [0-9]*: " $log_file >/dev/null || test $debug = yes; then
cat $log_file 1>&2
exit 1
fi
rm -f $log_file
# Prompt the user to check if the device map is correct.
echo "Installation finished. No error reported."
echo "This is the contents of the device map $device_map."
echo "Check if this is correct or not. If any of the lines is incorrect,"
echo "fix it and re-run the script \`grub-install'."
echo
cat $device_map
# Bye.
exit 0

Binary file not shown.

Binary file not shown.

View File

@ -116,29 +116,24 @@ include("head.inc");
echo "<tr>";
$c = 1;
while($c <= $priority_count) {
$monitor = lookup_gateway_monitor_ip_by_name($member);
if($p == $c) {
$monitor = lookup_gateway_monitor_ip_by_name($member);
switch($gateways_status[$monitor]['status']) {
case "None":
$online = "Online";
$bgcolor = "lightgreen";
break;
case "\"down\"":
$online = "Offline";
$bgcolor = "lightcoral";
break;
case "\"delay\"":
$online = "Latency";
$bgcolor = "khaki";
break;
case "\"loss\"":
$online = "Packetloss";
$bgcolor = "khaki";
break;
default:
$online = "Unknown";
$bgcolor = "lightblue";
break;
$status = $gateways_status[$monitor]['status'];
if (stristr($status, "down")) {
$online = "Offline";
$bgcolor = "lightcoral";
} elseif (stristr($status, "loss")) {
$online = "Warning, Packetloss";
$bgcolor = "khaki";
} elseif (stristr($status, "delay")) {
$online = "Warning, Latency";
$bgcolor = "khaki";
} elseif (stristr($status, "none")) {
$online = "Online";
$bgcolor = "lightgreen";
} else {
$online = "Unknown";
$bgcolor = "lightblue";
}
echo "<td bgcolor='$bgcolor'>". htmlspecialchars($member) .", $online</td>";
} else {

View File

@ -42,7 +42,6 @@
require("guiconfig.inc");
$a_gateways = return_gateways_array();
$gateways_status = array();
$gateways_status = return_gateways_status();
@ -76,51 +75,36 @@ include("head.inc");
<td width="30%" class="listhdrr">Status</td>
<td width="30%" class="listhdr">Description</td>
</tr>
<?php foreach ($a_gateways as $gateway) {
$i = 2;
<?php foreach ($gateways_status as $target => $gateway) {
?>
<tr>
<td class="listlr">
<?=strtoupper($gateway['name']);?>
</td>
<td class="listr" align="center" >
<?=$gateway['gateway'];?>
<?php echo lookup_gateway_ip_by_name($gateway['name']);?>
</td>
<td class="listr" align="center" >
<?=$gateway['monitor'];?>
<?=$target;?>
</td>
<td class="listr" >
<table border="0" cellpadding="0" cellspacing="2">
<?php
if($gateway['gateway'] == "dynamic") {
$gateway['monitor'] = "127.0.0.{$i}";
$i++;
if (stristr($gateway['status'], "down")) {
$online = "Offline";
$bgcolor = "lightcoral";
} elseif (stristr($gateway['status'], "loss")) {
$online = "Warning, Packetloss";
$bgcolor = "khaki";
} elseif (stristr($gateway['status'], "delay")) {
$online = "Warning, Latency";
$bgcolor = "khaki";
} elseif (stristr($gateway['status'], "none")) {
$online = "Online";
$bgcolor = "lightgreen";
}
$monitor = $gateway['monitor'];
if(empty($monitor)) {
$monitor = $gateway['gateway'];
}
switch($gateways_status[$monitor]['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;
}
PRINT "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
$lastchange = $gateways_status[$monitor]['lastcheck'];
echo "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
$lastchange = $gateway['lastcheck'];
if(!empty($lastchange)) {
$lastchange = explode(" ", $lastchange);
array_shift($lastchange);
@ -130,13 +114,11 @@ include("head.inc");
} else {
print "Gathering data";
}
PRINT "</td></tr>";
echo "</td></tr>";
?>
</table>
</td>
<td class="listbg" >
<?=$gateway['descr'];?></font>
</td>
<td class="listbg"> <?=$a_gateway[$gateway['name']]['descr']; ?></td>
</tr>
<?php } ?>
</table>

View File

@ -193,8 +193,12 @@ if ($_POST) {
if (!$input_errors) {
$reloadif = false;
$save = false;
if ($_POST['weight'] > 1 || $_POST['latencylow'] || $_POST['latencyhigh'] || $_POST['losslow'] || $_POST['losshigh'] || $_POST['down'] ||
$_POST['defaultgw'])
$save = true;
/* if we are processing a system gateway only save the monitorip */
if ($_POST['weight'] == 1 && (($_POST['attribute'] == "system" && empty($_POST['defaultgw'])) || (empty($_POST['interface']) && empty($_POST['gateway']) && empty($_POST['defaultgw'])))) {
if (!$save && empty($_POST['interface']) && empty($_POST['gateway'])) {
if (is_ipaddr($_POST['monitor'])) {
if (empty($_POST['interface']))
$interface = $pconfig['friendlyiface'];

View File

@ -214,7 +214,7 @@ function enable_change(enable_over) {
document.iform.radius_nasip.disabled = 0;
document.iform.radiusissueips.disabled = 0;
document.iform.radius_nasip.disabled = 0;
document.iform.radius_acct_update = 0;
document.iform.radius_acct_update.disabled = 0;
document.iform.radiussecenable.disabled = 0;
if (document.iform.radiussecenable.checked || enable_over) {
document.iform.radiusserver2.disabled = 0;
@ -236,7 +236,7 @@ function enable_change(enable_over) {
document.iform.radiusserveracctport.disabled = 1;
document.iform.radiusissueips.disabled = 1;
document.iform.radius_nasip.disabled = 1;
document.iform.radius_acct_update = 1;
document.iform.radius_acct_update.disabled = 1;
document.iform.radiussecenable.disabled = 1;
}
} else {
@ -260,7 +260,7 @@ function enable_change(enable_over) {
document.iform.radiusserver2acctport.disabled = 1;
document.iform.radiusissueips.disabled = 1;
document.iform.radius_nasip.disabled = 1;
document.iform.radius_acct_update = 1;
document.iform.radius_acct_update.disabled = 1;
}
}
//-->
@ -366,7 +366,7 @@ function enable_change(enable_over) {
<tr>
<td width="22%" valign="top" class="vncellreq">DNS servers</td>
<td width="78%" class="vtable">
<?=$mandfldhtml;?><input name="pppoe_dns1" type="text" class="formfld unkown" id="pppoe_dns1" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns1']);?>">
<?=$mandfldhtml;?><input name="pppoe_dns1" type="text" class="formfld unknown" id="pppoe_dns1" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns1']);?>">
<br>
<input name="pppoe_dns2" type="text" class="formfld unknown" id="pppoe_dns2" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns2']);?>">
<br>

View File

@ -30,8 +30,6 @@ require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
require_once("functions.inc");
$a_gateways = return_gateways_array();
$gateways_status = array();
$gateways_status = return_gateways_status();
@ -46,57 +44,47 @@ $counter = 1;
<td width="10%" class="listhdrr">Loss</td>
<td width="30%" class="listhdrr">Status</td>
</tr>
<?php foreach ($a_gateways as $gateway) { ?>
<?php foreach ($gateways_status as $target => $gateway) { ?>
<?php
$monitor = $gateway['monitor'];
if(empty($monitor)) {
$monitor = $gateway['gateway'];
}
?>
$monitor = $target;
if(empty($monitor)) {
$monitor = $gateway['gateway'];
}
?>
<tr>
<td class="listlr" id="gateway<?= $counter; ?>">
<?=$gateway['name'];?>
<?php $counter++; ?>
</td>
<td class="listr" align="center" id="gateway<?= $counter; ?>">
<?=$gateway['gateway'];?>
<?php echo lookup_gateway_ip_by_name($gateway['name']);?>
<?php $counter++; ?>
</td>
<td class="listr" align="center" id="gateway<?= $counter; ?>">
<?=$gateways_status[$monitor]['delay'];?>
<?=$gateway['delay'];?>
<?php $counter++; ?>
</td>
<td class="listr" align="center" id="gateway<?= $counter; ?>">
<?=$gateways_status[$monitor]['loss'];?>
<?=$gateway['loss'];?>
<?php $counter++; ?>
</td>
<td class="listr" id=\"gateway<?=$counter?>\" >
<table border="0" cellpadding="0" cellspacing="2">
<?php
$monitor = $gateway['monitor'];
if(empty($monitor)) {
$monitor = $gateway['gateway'];
}
switch($gateways_status[$monitor]['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";
}
if (stristr($gateway['status'], "down")) {
$online = "Offline";
$bgcolor = "lightcoral";
} elseif (stristr($gateway['status'], "loss")) {
$online = "Warning, Packetloss";
$bgcolor = "khaki";
} elseif (stristr($gateway['status'], "delay")) {
$online = "Warning, Latency";
$bgcolor = "khaki";
} elseif (stristr($gateway['status'], "none")) {
$online = "Online";
$bgcolor = "lightgreen";
} else
$online = "Gathering data";
echo "<tr><td bgcolor=\"$bgcolor\" > $online </td>";
$counter++;
?>
@ -104,7 +92,6 @@ $counter = 1;
</td>
</tr>
<?php
$i++;
}
?>
</table>