diff options
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/bin/ping_hosts.sh | 22 | ||||
-rwxr-xr-x | usr/local/www/firewall_aliases_edit.php | 4 | ||||
-rwxr-xr-x | usr/local/www/firewall_aliases_import.php | 14 | ||||
-rw-r--r-- | usr/local/www/includes/functions.inc.php | 15 | ||||
-rwxr-xr-x | usr/local/www/interfaces.php | 8 | ||||
-rw-r--r-- | usr/local/www/services_dhcpv6.php | 10 | ||||
-rwxr-xr-x | usr/local/www/status_dhcp_leases.php | 16 | ||||
-rwxr-xr-x | usr/local/www/system_gateways_edit.php | 18 |
8 files changed, 53 insertions, 54 deletions
diff --git a/usr/local/bin/ping_hosts.sh b/usr/local/bin/ping_hosts.sh index 949a843..30782b8 100755 --- a/usr/local/bin/ping_hosts.sh +++ b/usr/local/bin/ping_hosts.sh @@ -75,31 +75,33 @@ for TOPING in $PINGHOSTS ; do fi echo Processing $DSTIP # Look for a service being down + # Read in previous status + PREVIOUSSTATUS="" + if [ -f "/var/db/pingstatus/${DSTIP}" ]; then + PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP` + fi $PINGCMD -c $COUNT -S $SRCIP $DSTIP if [ $? -eq 0 ]; then # Host is up - # Read in previous status - PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP` - if [ "$PREVIOUSSTATUS" = "DOWN" ]; then + if [ "$PREVIOUSSTATUS" != "UP" ]; then # Service restored if [ "$SERVICERESTOREDSCRIPT" != "" ]; then echo "$DSTIP is UP, previous state was DOWN .. Running $SERVICERESTOREDSCRIPT" echo "$DSTIP is UP, previous state was DOWN .. Running $SERVICERESTOREDSCRIPT" | logger -p daemon.info -i -t PingMonitor - echo "UP" > /var/db/pingstatus/$DSTIP sh -c $SERVICERESTOREDSCRIPT fi + echo "UP" > /var/db/pingstatus/$DSTIP fi else # Host is down - PREVIOUSSTATUS=`cat /var/db/pingstatus/$DSTIP` - if [ "$PREVIOUSSTATUS" = "UP" ]; then + if [ "$PREVIOUSSTATUS" != "DOWN" ]; then # Service is down if [ "$FAILURESCRIPT" != "" ]; then echo "$DSTIP is DOWN, previous state was UP .. Running $FAILURESCRIPT" echo "$DSTIP is DOWN, previous state was UP .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor - echo "DOWN" > /var/db/pingstatus/$DSTIP sh -c $FAILURESCRIPT fi + echo "DOWN" > /var/db/pingstatus/$DSTIP fi fi echo "Checking ping time $DSTIP" @@ -108,7 +110,7 @@ for TOPING in $PINGHOSTS ; do echo "Ping returned $?" echo $PINGTIME > /var/db/pingmsstatus/$DSTIP if [ "$THRESHOLD" != "" ]; then - if [ "$PINGTIME" -gt "$THRESHOLD" ]; then + if [ $(echo "${PINGTIME} > ${THRESHOLD}" | /usr/bin/bc) -eq 1 ]; then echo "$DSTIP has exceeded ping threshold $PINGTIME / $THRESHOLD .. Running $FAILURESCRIPT" echo "$DSTIP has exceeded ping threshold $PINGTIME / $THRESHOLD .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor sh -c $FAILURESCRIPT @@ -118,8 +120,8 @@ for TOPING in $PINGHOSTS ; do #WANTIME=`rrdtool fetch /var/db/rrd/wan-quality.rrd AVERAGE -r 120 -s -1min -e -1min | grep ":" | cut -f3 -d" " | cut -d"e" -f1` echo "Checking wan ping time $WANTIME" echo $WANTIME > /var/db/wanaverage - if [ "$WANTHRESHOLD" != "" ]; then - if [ "$WANTIME" -gt "$WANTHRESHOLD" ]; then + if [ "$WANTHRESHOLD" != "" -a "$WANTIME" != "" ]; then + if [ $(echo "${WANTIME} > ${WANTHRESHOLD}" | /usr/bin/bc) -eq 1 ]; then echo "$DSTIP has exceeded wan ping threshold $WANTIME / $WANTHRESHOLD .. Running $FAILURESCRIPT" echo "$DSTIP has exceeded wan ping threshold $WANTIME / $WANTHRESHOLD .. Running $FAILURESCRIPT" | logger -p daemon.info -i -t PingMonitor sh -c $FAILURESCRIPT diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php index 5ad2c7f..c5529a8 100755 --- a/usr/local/www/firewall_aliases_edit.php +++ b/usr/local/www/firewall_aliases_edit.php @@ -443,9 +443,9 @@ function typesel_change() { break; } - jQuery("select[id^='address_subnet']").prop("disabled", field_disabled); + jQuery("select[id='address_subnet']").prop("disabled", field_disabled); if (set_value == true); - jQuery("select[id^='address_subnet']").prop("value", field_value); + jQuery("select[id='address_subnet']").prop("value", field_value); } function add_alias_control() { diff --git a/usr/local/www/firewall_aliases_import.php b/usr/local/www/firewall_aliases_import.php index 9b9d735..c86a218 100755 --- a/usr/local/www/firewall_aliases_import.php +++ b/usr/local/www/firewall_aliases_import.php @@ -1,7 +1,7 @@ <?php /* $Id$ */ /* - firewall_aliases_edit.php + firewall_aliases_import.php Copyright (C) 2005 Scott Ullrich All rights reserved. @@ -38,7 +38,8 @@ ##|-PRIV -$reserved_keywords = array("pass", "out", "queue", "max", "min", "pptp", "pppoe", "L2TP", "OpenVPN", "IPsec"); +// Keywords not allowed in names +$reserved_keywords = array("all", "pass", "block", "out", "queue", "max", "min", "pptp", "pppoe", "L2TP", "OpenVPN", "IPsec"); require("guiconfig.inc"); require_once("util.inc"); @@ -47,8 +48,13 @@ require("shaper.inc"); $pgtitle = array(gettext("Firewall"),gettext("Aliases"),gettext("Bulk import")); +// Add all Load balance names to reserved_keywords +if (is_array($config['load_balancer']['lbpool'])) + foreach ($config['load_balancer']['lbpool'] as $lbpool) + $reserved_keywords[] = $lbpool['name']; + $reserved_ifs = get_configured_interface_list(false, true); -$reserved_keywords = array_merge($reserved_keywords, $reserved_ifs); +$reserved_keywords = array_merge($reserved_keywords, $reserved_ifs, $reserved_table_names); if (!is_array($config['aliases']['alias'])) $config['aliases']['alias'] = array(); @@ -89,7 +95,7 @@ if($_POST['aliasimport'] <> "") { if (is_iprange($impip)) { list($startip, $endip) = explode('-', $impip); $rangesubnets = ip_range_to_subnet_array($startip, $endip); - $address .= implode(" ", $rangesubnets); + $imported = array_merge($imported, $rangesubnets); } else if (!is_ipaddr($impip) && !is_subnet($impip) && !empty($impip)) { $input_errors[] = sprintf(gettext("%s is not an IP address. Please correct the error to continue"), $impip); } elseif (!empty($impip)) { diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 33cb585..1c57ba7 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -152,7 +152,10 @@ function get_pfstate($percent=false) { $curentries = $matches[1]; } if ($percent) - return round(($curentries / $maxstates) * 100, 0); + if ($maxstates > 0) + return round(($curentries / $maxstates) * 100, 0); + else + return "NA"; else return $curentries . "/" . $maxstates; } @@ -172,7 +175,10 @@ function get_mbuf($percent=false) { $mbufs_output=trim(`/usr/bin/netstat -mb | /usr/bin/grep "mbuf clusters in use" | /usr/bin/awk '{ print $1 }'`); list( $mbufs_current, $mbufs_cache, $mbufs_total, $mbufs_max ) = explode( "/", $mbufs_output); if ($percent) - return round(($mbufs_total / $mbufs_max) * 100, 0); + if ($mbufs_max > 0) + return round(($mbufs_total / $mbufs_max) * 100, 0); + else + return "NA"; else return "{$mbufs_total}/{$mbufs_max}"; } @@ -217,7 +223,10 @@ function mem_usage() { $totalMem = $memory[0]; $availMem = $memory[1] + $memory[2] + $memory[3]; $usedMem = $totalMem - $availMem; - $memUsage = round(($usedMem * 100) / $totalMem, 0); + if ($totalMem > 0) + $memUsage = round(($usedMem * 100) / $totalMem, 0); + else + $memUsage = "NA"; return $memUsage; } diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 4b74997..51c2a02 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -642,17 +642,15 @@ if ($_POST['apply']) { $input_errors[] = gettext("A valid MAC address must be specified."); if ($_POST['mtu']) { if ($_POST['mtu'] < 576 || $_POST['mtu'] > 9000) - $input_errors[] = gettext("The MTU must be greater than 576 bytes."); + $input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000."); if (stristr($wancfg['if'], "_vlan")) { $realhwif_array = get_parent_interface($wancfg['if']); // Need code to handle MLPPP if we ever use $realhwif for MLPPP handling $parent_realhwif = $realhwif_array[0]; $parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif); - if (!empty($parent_if) && isset($config['interfaces'][$parent_if]['mtu'])) { - $parent_mtu = $config['interfaces'][$parent_if]['mtu']; - - if ($_POST['mtu'] > $parent_mtu) + if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) { + if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu'])) $input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface."); } } else { diff --git a/usr/local/www/services_dhcpv6.php b/usr/local/www/services_dhcpv6.php index e367ed6..45f99ee 100644 --- a/usr/local/www/services_dhcpv6.php +++ b/usr/local/www/services_dhcpv6.php @@ -108,7 +108,6 @@ if (is_array($config['dhcpdv6'][$if])){ list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpdv6'][$if]['winsserver']; list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpdv6'][$if]['dnsserver']; $pconfig['enable'] = isset($config['dhcpdv6'][$if]['enable']); - $pconfig['denyunknown'] = isset($config['dhcpdv6'][$if]['denyunknown']); $pconfig['ddnsdomain'] = $config['dhcpdv6'][$if]['ddnsdomain']; $pconfig['ddnsupdate'] = isset($config['dhcpdv6'][$if]['ddnsupdate']); list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpdv6'][$if]['ntpserver']; @@ -293,7 +292,6 @@ if ($_POST) { $config['dhcpdv6'][$if]['domain'] = $_POST['domain']; $config['dhcpdv6'][$if]['domainsearchlist'] = $_POST['domainsearchlist']; - $config['dhcpdv6'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false; $config['dhcpdv6'][$if]['enable'] = ($_POST['enable']) ? true : false; $config['dhcpdv6'][$if]['ddnsdomain'] = $_POST['ddnsdomain']; $config['dhcpdv6'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false; @@ -407,7 +405,6 @@ include("head.inc"); document.iform.nextserver.disabled = endis; document.iform.filename.disabled = endis; document.iform.rootpath.disabled = endis; - document.iform.denyunknown.disabled = endis; } function show_shownumbervalue() { @@ -529,13 +526,6 @@ display_top_tabs($tab_array); "interface"),htmlspecialchars($iflist[$if]));?></strong></td> </tr> <tr> - <td width="22%" valign="top" class="vtable"> </td> - <td width="78%" class="vtable"> - <input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>> - <strong><?=gettext("Deny unknown clients");?></strong><br> - <?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?></td> - </tr> - <tr> <?php /* the PPPoE Server could well have no IPv6 address and operate fine with just link-local, just hide these */ if(is_ipaddrv6($ifcfgip)) { diff --git a/usr/local/www/status_dhcp_leases.php b/usr/local/www/status_dhcp_leases.php index 78733db..b7624d8 100755 --- a/usr/local/www/status_dhcp_leases.php +++ b/usr/local/www/status_dhcp_leases.php @@ -99,22 +99,16 @@ function leasecmp($a, $b) { function adjust_gmt($dt) { global $config; $dhcpd = $config['dhcpd']; - foreach ($dhcpd as $dhcpleaseinlocaltime) { - $dhcpleaseinlocaltime = $dhcpleaseinlocaltime['dhcpleaseinlocaltime']; + foreach ($dhcpd as $dhcpditem) { + $dhcpleaseinlocaltime = $dhcpditem['dhcpleaseinlocaltime']; if ($dhcpleaseinlocaltime == "yes") break; } - $timezone = $config['system']['timezone']; - $ts = strtotime($dt . " GMT"); if ($dhcpleaseinlocaltime == "yes") { - $this_tz = new DateTimeZone($timezone); - $dhcp_lt = new DateTime(strftime("%I:%M:%S%p", $ts), $this_tz); - $offset = $this_tz->getOffset($dhcp_lt); - $ts = $ts + $offset; + $ts = strtotime($dt . " GMT"); return strftime("%Y/%m/%d %I:%M:%S%p", $ts); - } - else - return strftime("%Y/%m/%d %H:%M:%S", $ts); + } else + return $dt; } function remove_duplicate($array, $field) diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php index 365ff11..b82bb31 100755 --- a/usr/local/www/system_gateways_edit.php +++ b/usr/local/www/system_gateways_edit.php @@ -387,16 +387,16 @@ if ($_POST) { $gateway['descr'] = $_POST['descr']; if ($_POST['monitor_disable'] == "yes") $gateway['monitor_disable'] = true; - else if (is_ipaddr($_POST['monitor'])) { - /* NOTE: If monitor ip is changed need to cleanup the old static route */ - if ($_POST['monitor'] != "dynamic" && !empty($a_gateway_item[$realid]) && is_ipaddr($a_gateway_item[$realid]['monitor']) && - $_POST['monitor'] != $a_gateway_item[$realid]['monitor'] && $gateway['gateway'] != $a_gateway_item[$realid]['monitor']) { - if (is_ipaddrv4($a_gateway_item[$realid]['monitor'])) - mwexec("/sbin/route delete " . escapeshellarg($a_gateway_item[$realid]['monitor'])); - else - mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateway_item[$realid]['monitor'])); - } + if (is_ipaddr($_POST['monitor'])) $gateway['monitor'] = $_POST['monitor']; + + /* NOTE: If monitor ip is changed need to cleanup the old static route */ + if ($_POST['monitor'] != "dynamic" && !empty($a_gateway_item[$realid]) && is_ipaddr($a_gateway_item[$realid]['monitor']) && + $_POST['monitor'] != $a_gateway_item[$realid]['monitor'] && $gateway['gateway'] != $a_gateway_item[$realid]['monitor']) { + if (is_ipaddrv4($a_gateway_item[$realid]['monitor'])) + mwexec("/sbin/route delete " . escapeshellarg($a_gateway_item[$realid]['monitor'])); + else + mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateway_item[$realid]['monitor'])); } if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") { |